Skip to content

Commit 675c83e

Browse files
committed
fix: update FM HTTP mode documentation and config details
- Changed model name in btca.config.jsonc to lowercase. - Updated domain_map.yaml with new FM HTTP features and troubleshooting tips. - Expanded skill_spec.md to reflect increased failure modes for typegen-setup. - Added detailed instructions for local WebViewer development using FM HTTP in SKILL.md. - Clarified critical mistakes related to FmHttpAdapter usage and environment variable settings in typegen-setup documentation.
1 parent 81520b7 commit 675c83e

5 files changed

Lines changed: 206 additions & 27 deletions

File tree

_artifacts/domain_map.yaml

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Generated by skill-domain-discovery
33
# Library: ProofKit
44
# Version: fmdapi@5.0.3-beta.1, fmodata@0.1.0-beta.31, typegen@1.1.0-beta.15, webviewer@3.0.7-beta.0, better-auth@0.4.0-beta.7
5-
# Date: 2026-03-13
5+
# Date: 2026-03-16
66
# Status: reviewed
77

88
library:
@@ -50,6 +50,9 @@ skills:
5050
- 'Environment variables (FM_SERVER, FM_DATABASE, OTTO_API_KEY, FM_USERNAME, FM_PASSWORD)'
5151
- 'strictNumbers, strictValueLists options'
5252
- 'webviewerScriptName option'
53+
- 'fmHttp config (local FM HTTP proxy for typegen metadata fetching)'
54+
- 'FM HTTP env vars (FM_HTTP_BASE_URL, FM_CONNECTED_FILE_NAME)'
55+
- 'FM HTTP auto-discovery of connectedFileName via /connectedFiles'
5356
- 'Field type overrides for OData'
5457
- 'reduceMetadata, alwaysOverrideFieldNames'
5558
- 'Entity ID preservation across regeneration'
@@ -59,6 +62,8 @@ skills:
5962
- 'Regenerate types after FileMaker schema changes'
6063
- 'Switch from Data API to OData config'
6164
- 'Configure environment variables for FM connection'
65+
- 'Set up FM HTTP mode for local typegen without credentials'
66+
- 'Troubleshoot FM HTTP connectivity issues'
6267
- 'Customize generated schemas with override files'
6368
failure_modes:
6469
- mistake: 'Editing files in generated/ or client/ directories'
@@ -168,6 +173,60 @@ skills:
168173
status: active
169174
skills: ['typegen-setup', 'fmdapi-client', 'fmodata-client']
170175

176+
- mistake: 'Using FmHttpAdapter in production application code'
177+
mechanism: 'FmHttpAdapter is internal to typegen metadata fetching. Generated clients use WebViewerAdapter. Agent sees the adapter import in typegen source and uses it in app code.'
178+
wrong_pattern: |
179+
import { FmHttpAdapter } from "@proofkit/fmdapi/adapters/fm-http";
180+
const client = DataApi({
181+
adapter: new FmHttpAdapter({ baseUrl: "http://127.0.0.1:1365", connectedFileName: "MyFile" }),
182+
layout: "Contacts",
183+
});
184+
correct_pattern: |
185+
// Use typegen-generated client (which uses WebViewerAdapter internally)
186+
import { ContactsLayout } from "./schema/client";
187+
const { data } = await ContactsLayout.find({ query: { name: "==John" } });
188+
source: 'source: typegen.ts, buildLayoutClient.ts'
189+
priority: CRITICAL
190+
status: active
191+
skills: ['typegen-setup']
192+
193+
- mistake: 'Setting standard FM env vars when using fmHttp mode'
194+
mechanism: 'fmHttp mode does not need FM_SERVER, FM_DATABASE, or OTTO_API_KEY. Agent configures both standard and fmHttp env vars, causing confusion when standard vars fail validation.'
195+
wrong_pattern: |
196+
# .env — agent sets both
197+
FM_SERVER=https://fm.example.com
198+
FM_DATABASE=MyFile.fmp12
199+
OTTO_API_KEY=dk_abc123
200+
FM_HTTP_BASE_URL=http://127.0.0.1:1365
201+
correct_pattern: |
202+
# fmHttp mode only needs these (baseUrl defaults to 127.0.0.1:1365)
203+
# connectedFileName is auto-discovered if not set
204+
FM_CONNECTED_FILE_NAME=MyFile
205+
source: 'source: getEnvValues.ts, constants.ts'
206+
priority: HIGH
207+
status: active
208+
skills: ['typegen-setup']
209+
210+
- mistake: 'Suggesting OttoFMS/FetchAdapter fallback when FM HTTP fails'
211+
mechanism: 'Agent troubleshoots FM HTTP connection failure by suggesting standard auth. Developer chose fmHttp because they have no hosted credentials or are working offline. Correct troubleshooting: check daemon health (GET http://127.0.0.1:1365/health), check /connectedFiles, ensure FM file has run "Connect to MCP" script and WebViewer window is open in Browse mode.'
212+
source: 'maintainer interview'
213+
priority: HIGH
214+
status: active
215+
skills: ['typegen-setup']
216+
217+
- mistake: 'FM HTTP WebViewer window closed or in Layout mode'
218+
mechanism: 'The FM HTTP proxy works via a WebViewer window opened by the "Connect to MCP" script in FileMaker. If this window is closed or switched to Layout mode, all proxy requests fail. Error may not be obvious — typegen just fails to connect.'
219+
correct_pattern: |
220+
# Troubleshooting checklist:
221+
# 1. Is the fm-http daemon running? GET http://127.0.0.1:1365/health
222+
# 2. Is the file connected? GET http://127.0.0.1:1365/connectedFiles
223+
# 3. If file not listed: open it in FileMaker, run "Connect to MCP" script
224+
# 4. Ensure the WebViewer window stays open in Browse mode (not Layout mode)
225+
source: 'maintainer interview'
226+
priority: HIGH
227+
status: active
228+
skills: ['typegen-setup']
229+
171230
- name: 'Data API Client'
172231
slug: 'fmdapi-client'
173232
domain: 'data-access'
@@ -646,10 +705,12 @@ skills:
646705
- 'First typegen run'
647706
- 'First query with generated client'
648707
- 'Choosing between Data API and OData'
708+
- 'FM HTTP mode for local/offline WebViewer development (no credentials needed)'
649709
tasks:
650710
- 'Set up a new project with ProofKit'
651711
- 'Connect to FileMaker server for the first time'
652712
- 'Generate types and make first data query'
713+
- 'Set up FM HTTP mode for local WebViewer development'
653714
failure_modes:
654715
- mistake: 'Missing fmrest or fmodata privilege on FM account'
655716
mechanism: 'Data API requires fmrest extended privilege. OData requires fmodata privilege. Without these, all API calls return 401/403.'

_artifacts/skill_spec.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ProofKit is a monorepo of TypeScript tools for building web applications integra
1515

1616
| Skill | Type | Domain | What it covers | Failure modes |
1717
| --- | --- | --- | --- | --- |
18-
| typegen-setup | core | connecting | Config, CLI, Data API + OData modes, validators, generated file structure, env vars | 7 |
18+
| typegen-setup | core | connecting | Config, CLI, Data API + OData + FM HTTP modes, validators, generated file structure, env vars | 11 |
1919
| fmdapi-client | core | data-access | DataApi factory, adapters, token stores, CRUD, find variants, scripts, validation | 6 |
2020
| fmodata-client | core | data-access | FMServerConnection, schema/field builders, query builder, CRUD, relationships, batch, errors | 8 |
2121
| webviewer-integration | core | webviewer | fmFetch, callFMScript, WebViewerAdapter, browser-only constraints, local mode perf | 6 |
@@ -25,7 +25,7 @@ ProofKit is a monorepo of TypeScript tools for building web applications integra
2525

2626
## Failure Mode Inventory
2727

28-
### typegen-setup (7 failure modes)
28+
### typegen-setup (11 failure modes)
2929

3030
| # | Mistake | Priority | Source | Cross-skill? |
3131
| --- | --- | --- | --- | --- |
@@ -36,6 +36,10 @@ ProofKit is a monorepo of TypeScript tools for building web applications integra
3636
| 5 | Omitting type discriminator for OData config | HIGH | source + docs ||
3737
| 6 | Manually redefining types instead of using generated/inferred types | CRITICAL | maintainer | fmdapi-client, fmodata-client |
3838
| 7 | Mixing Zod v3 and v4 in the same project | HIGH | maintainer | fmdapi-client, fmodata-client |
39+
| 8 | Using FmHttpAdapter in production application code | CRITICAL | source ||
40+
| 9 | Setting standard FM env vars when using fmHttp mode | HIGH | source ||
41+
| 10 | Suggesting OttoFMS/FetchAdapter fallback when FM HTTP fails | HIGH | maintainer ||
42+
| 11 | FM HTTP WebViewer window closed or in Layout mode | HIGH | maintainer ||
3943

4044
### fmdapi-client (6 failure modes)
4145

btca.config.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"branch": "main"
99
}
1010
],
11-
"model": "GPT-5.3-Codex",
11+
"model": "gpt-5.3-codex",
1212
"provider": "openai"
1313
}

packages/typegen/skills/getting-started/SKILL.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,56 @@ if (error) {
187187
}
188188
```
189189

190+
### Path D: Local WebViewer Development (FM HTTP — no credentials)
191+
192+
For WebViewer apps running inside FileMaker, you can use FM HTTP mode to generate types from a local FileMaker file without any server credentials.
193+
194+
**Prerequisites:**
195+
- FM HTTP daemon installed and running (`curl http://127.0.0.1:1365/health`)
196+
- FileMaker file open locally with "Connect to MCP" script run
197+
198+
1. Install packages:
199+
200+
```bash
201+
pnpm add @proofkit/fmdapi @proofkit/webviewer zod
202+
```
203+
204+
2. No `.env` file needed for typegen (baseUrl defaults, connectedFileName is auto-discovered). Optionally set "connectedFileName" in the config.fmHttp.connectedFileName to override the auto-discovery.
205+
206+
3. Create typegen config with `fmHttp` enabled:
207+
208+
```jsonc
209+
{
210+
"$schema": "https://proofkit.dev/typegen-config-schema.json",
211+
"config": {
212+
"type": "fmdapi",
213+
"fmHttp": { "enabled": true },
214+
"layouts": [
215+
{ "layoutName": "api_Contacts", "schemaName": "Contacts" }
216+
],
217+
"path": "schema"
218+
}
219+
}
220+
```
221+
222+
4. Run typegen — it auto-discovers the connected file and writes it back to config:
223+
224+
```bash
225+
npx @proofkit/typegen
226+
```
227+
228+
5. First query (runs inside FileMaker WebViewer):
229+
230+
```ts
231+
import { ContactsLayout } from "./schema/client";
232+
233+
const { data } = await ContactsLayout.findOne({
234+
query: { id: "==123" },
235+
});
236+
```
237+
238+
The generated client uses `WebViewerAdapter` with `"execute_data_api"` as the default script name. No server URL or API keys are needed at runtime — all calls go through the FileMaker script engine.
239+
190240
## Choosing Data API vs OData
191241

192242
| Aspect | Data API (`@proofkit/fmdapi`) | OData (`@proofkit/fmodata`) |

packages/typegen/skills/typegen-setup/SKILL.md

Lines changed: 87 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ description: >
55
validators from FileMaker layouts or OData metadata. Covers
66
proofkit-typegen-config.jsonc, validator options (zod/v4, zod/v3),
77
generated vs override file structure, envNames, InferTableSchema,
8-
InferZodPortals, and the schema/generated/client directory layout.
8+
InferZodPortals, schema/generated/client directory layout, and
9+
fmHttp mode for local typegen without credentials.
910
type: core
1011
library: proofkit
1112
library_version: "1.1.0-beta.15"
@@ -181,35 +182,42 @@ import { Customers } from "./schema/odata/generated/Customers";
181182
type CustomerRow = InferTableSchema<typeof Customers>;
182183
```
183184

184-
### Multiple configs (mixed Data API + OData)
185+
### Multiple configs
186+
187+
The `config` key can be an array mixing `fmdapi` and `fmodata` entries, each with its own `path` and `envNames`.
188+
189+
### FM HTTP mode (local development, no credentials)
190+
191+
FM HTTP mode lets typegen fetch layout metadata from a locally running FileMaker file via the FM HTTP proxy, without needing OttoFMS, a hosted server, or any credentials. Generated clients still use `WebViewerAdapter` — FM HTTP is only used during typegen.
185192

186193
```jsonc
187194
{
188195
"$schema": "https://proofkit.dev/typegen-config-schema.json",
189-
"config": [
190-
{
191-
"type": "fmdapi",
192-
"path": "schema/dapi",
193-
"layouts": [
194-
{ "layoutName": "api_Contacts", "schemaName": "Contacts" }
195-
]
196-
},
197-
{
198-
"type": "fmodata",
199-
"path": "schema/odata",
200-
"envNames": {
201-
"server": "ODATA_SERVER_URL",
202-
"db": "ODATA_DATABASE_NAME",
203-
"auth": { "apiKey": "ODATA_API_KEY" }
204-
},
205-
"tables": [
206-
{ "tableName": "Products" }
207-
]
208-
}
209-
]
196+
"config": {
197+
"type": "fmdapi",
198+
"fmHttp": { "enabled": true },
199+
"layouts": [
200+
{ "layoutName": "api_Contacts", "schemaName": "Contacts" }
201+
]
202+
}
210203
}
211204
```
212205

206+
`fmHttp` accepts an object with optional overrides:
207+
208+
- `enabled``true` to enable (default when object is present)
209+
- `scriptName` — FM script the proxy calls for Data API operations. Resolution: `fmHttp.scriptName` > `webviewerScriptName` > `"execute_data_api"`
210+
- `baseUrl` — FM HTTP server URL (default: `http://127.0.0.1:1365`). Can also be set via `FM_HTTP_BASE_URL` env var
211+
- `connectedFileName` — FileMaker file name. If omitted, auto-discovered from `GET /connectedFiles` and written back to config
212+
213+
The generated client uses `WebViewerAdapter` with `webviewerScriptName` if set, otherwise `"execute_data_api"`.
214+
215+
**Prerequisites:**
216+
1. FM HTTP daemon running locally (`GET http://127.0.0.1:1365/health` should return OK)
217+
2. FileMaker file open on the local machine
218+
3. "Connect to MCP" script run in the FileMaker file (opens a WebViewer window that bridges HTTP requests)
219+
4. That WebViewer window must stay open in **Browse mode** (not Layout mode)
220+
213221
### Custom env variable names
214222

215223
```jsonc
@@ -418,6 +426,62 @@ Zod v3 and v4 have incompatible APIs (`z.infer` vs `z.output`, different `extend
418426

419427
Source: apps/docs/content/docs/typegen/config.mdx
420428

429+
### CRITICAL: Using FmHttpAdapter in production application code
430+
431+
Wrong:
432+
```ts
433+
import { FmHttpAdapter } from "@proofkit/fmdapi/adapters/fm-http";
434+
435+
const client = DataApi({
436+
adapter: new FmHttpAdapter({
437+
baseUrl: "http://127.0.0.1:1365",
438+
connectedFileName: "MyFile",
439+
}),
440+
layout: "Contacts",
441+
});
442+
```
443+
444+
Correct:
445+
```ts
446+
// Use the typegen-generated client (uses WebViewerAdapter internally)
447+
import { ContactsLayout } from "./schema/client";
448+
449+
const { data } = await ContactsLayout.find({ query: { name: "==John" } });
450+
```
451+
452+
`FmHttpAdapter` is internal to typegen's metadata fetching process. It only runs during code generation, never in production. Generated clients use `WebViewerAdapter` for runtime data access inside FileMaker WebViewer.
453+
454+
### HIGH: Setting standard FM env vars when using fmHttp mode
455+
456+
Wrong:
457+
```bash
458+
# Agent configures both standard and fmHttp vars
459+
FM_SERVER=https://fm.example.com
460+
FM_DATABASE=MyFile.fmp12
461+
OTTO_API_KEY=dk_abc123
462+
FM_HTTP_BASE_URL=http://127.0.0.1:1365
463+
```
464+
465+
Correct:
466+
```bash
467+
# fmHttp mode only — no server/db/auth needed
468+
# baseUrl defaults to http://127.0.0.1:1365 if not set
469+
# connectedFileName is auto-discovered if not set
470+
FM_CONNECTED_FILE_NAME=MyFile
471+
```
472+
473+
fmHttp mode bypasses the standard FM_SERVER/FM_DATABASE/auth env vars entirely. Setting both causes confusion when standard validation reports missing values.
474+
475+
### HIGH: FM HTTP connection failures — troubleshooting
476+
477+
If typegen fails to connect in fmHttp mode, do NOT suggest falling back to OttoFMS or FetchAdapter. The developer chose fmHttp because they don't have hosted credentials or are working with a local-only file.
478+
479+
Troubleshooting checklist:
480+
1. **Daemon running?** `curl http://127.0.0.1:1365/health` — should return `{"service":"fm-http","status":"ok"}`
481+
2. **File connected?** `curl http://127.0.0.1:1365/connectedFiles` — should list the target file
482+
3. **File not listed?** Open the FileMaker file and run the **"Connect to MCP"** script
483+
4. **Still not working?** Ensure the WebViewer window opened by "Connect to MCP" is in **Browse mode**, not Layout mode. Closing this window or switching to Layout mode silently breaks the proxy.
484+
421485
## References
422486

423487
- **fmdapi-client**: Typegen generates the layout-specific clients consumed by `@proofkit/fmdapi`. Override files and `InferZodPortals` bridge typegen output into fmdapi usage.

0 commit comments

Comments
 (0)