@noodleseed/agent-kit 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,9 +8,9 @@ into a project's `.agents/` and `.claude/` skill directories via `noodle agents
8
8
 
9
9
  ## Contents
10
10
 
11
- - `skills/codex/` — the Codex (Codex CLI / AGENTS.md) skill: a `SKILL.md` router plus seven
11
+ - `skills/codex/` — the Codex (Codex CLI / AGENTS.md) skill: a `SKILL.md` router plus ten
12
12
  `references/*.md` files (sdk-surface, cli-commands, compile-errors, authoring-workflow,
13
- widgets-and-apps, deploy-and-ops, examples).
13
+ widgets-and-apps, test-in-hosts, troubleshooting, deploy-and-ops, publishing, examples).
14
14
  - `skills/claude-code/` — the Claude Code skill, same hierarchical tree.
15
15
  - `manifest.json` — `{ packageVersion, files: [{ path, sha256, agentTarget }] }`. The CLI verifies every
16
16
  file's sha256 against this manifest before writing it into a user's project; a mismatch refuses the
@@ -26,12 +26,13 @@ Skills updated in vX — run `noodle agents setup --write` to refresh.
26
26
  ```
27
27
 
28
28
  `noodle agents setup --write` then fetches this package, sha256-verifies it against the manifest, and
29
- writes the fresh `SKILL.md` bodies into the project (the managed `AGENTS.md`/`CLAUDE.md` block stays
30
- bundled, since it is project-specific). Offline or on verification failure it falls back to the bundled
31
- snapshot. Run `noodle agents doctor` to see installed vs registry skill versions.
29
+ writes the fresh skill tree into the project (the managed `AGENTS.md`/`CLAUDE.md` block stays bundled,
30
+ since it is project-specific). Offline or on verification failure it falls back to the bundled snapshot.
31
+ Run `noodle agents doctor` to see installed vs registry skill versions and detect local edits to bundled
32
+ reference files.
32
33
 
33
34
  ## License
34
35
 
35
36
  Apache-2.0. This package is generated and published from the
36
37
  [`noodle-borg`](https://github.com/NoodleSeed-com/noodle-borg) repository; the renderer is the private
37
- `@noodle-borg/agent-kit` workspace package.
38
+ `@noodle-borg/agent-kit` workspace package.
package/manifest.json CHANGED
@@ -1,84 +1,114 @@
1
1
  {
2
- "packageVersion": "0.8.0",
2
+ "packageVersion": "0.9.0",
3
3
  "files": [
4
4
  {
5
5
  "path": "skills/codex/SKILL.md",
6
- "sha256": "e17881258c58d957ad48050828c8c0362b6ecde062b25dbdb7836a4e0a2923b9",
6
+ "sha256": "f2481e82944f3369735b3f09965454d94333966546ae2718d0ac6dd5be186467",
7
7
  "agentTarget": "codex"
8
8
  },
9
9
  {
10
10
  "path": "skills/codex/references/sdk-surface.md",
11
- "sha256": "808225f0ae340016ee5826016770425cc83e19247cc892d4e98f76b66c067830",
11
+ "sha256": "959fa5fee6d2f0fbd82d8f8d39424deb5f6a4e1be2c1bfa4950a1a253c178045",
12
12
  "agentTarget": "codex"
13
13
  },
14
14
  {
15
15
  "path": "skills/codex/references/cli-commands.md",
16
- "sha256": "387bb7e4850dd13d220987cf829f2749c9561045d06bec3307eec9643a7d0972",
16
+ "sha256": "c50bf5ec6f43bd9fb7115ea9c9eb8de33c93e123f3e2d396785fe75ba094d40d",
17
17
  "agentTarget": "codex"
18
18
  },
19
19
  {
20
20
  "path": "skills/codex/references/compile-errors.md",
21
- "sha256": "d1a22fb9a897714a069390d00eecfc0b4d0f87a64fdf15c94970ecb6c166dfa8",
21
+ "sha256": "977d9b0022f7bb280cff1ff5737890f16eba1fee632868678dbdb45f9526e79a",
22
22
  "agentTarget": "codex"
23
23
  },
24
24
  {
25
25
  "path": "skills/codex/references/authoring-workflow.md",
26
- "sha256": "85f8cbbd628e8108e813d0606edd9243441c912fa2a68fb2824663df5b738ea9",
26
+ "sha256": "d88ee3cd351ce4a438bc5c2ecd2afae56b191d1a53954562bb38e116e554047f",
27
27
  "agentTarget": "codex"
28
28
  },
29
29
  {
30
30
  "path": "skills/codex/references/widgets-and-apps.md",
31
- "sha256": "e6b43810ca7a5f1e3e5191532557c0ac7857881b3e589448e514334fbbacbbfb",
31
+ "sha256": "10d644eb421deee8a99a366f18c848ca769116ec051b7c35a4ee7e2c7b5e2f0d",
32
+ "agentTarget": "codex"
33
+ },
34
+ {
35
+ "path": "skills/codex/references/test-in-hosts.md",
36
+ "sha256": "08e44784a0d838c322d443eae6b35d5c75b4252a0975db835ef504535e25584a",
37
+ "agentTarget": "codex"
38
+ },
39
+ {
40
+ "path": "skills/codex/references/troubleshooting.md",
41
+ "sha256": "4e0446d67d4ab037ecb6c9ffdf28494b42ed410f5c94ad7c498c3545f746eefb",
32
42
  "agentTarget": "codex"
33
43
  },
34
44
  {
35
45
  "path": "skills/codex/references/deploy-and-ops.md",
36
- "sha256": "3184d0855f08ddda65d2a551906e796f5552c22ffce61949747dc365f2de78df",
46
+ "sha256": "33c902d900b60202331cbbcc09b683d91e5c23a07ec7c11c66e48e1a9726f33b",
47
+ "agentTarget": "codex"
48
+ },
49
+ {
50
+ "path": "skills/codex/references/publishing.md",
51
+ "sha256": "fb0be4c9c9bc9fd68f4e7ed8e9b7e4c8677c415130d441c28590ba0df6cb5aae",
37
52
  "agentTarget": "codex"
38
53
  },
39
54
  {
40
55
  "path": "skills/codex/references/examples.md",
41
- "sha256": "e1871dbf9ea1dac079cd77b4f33467a99c7b03d06bc4ece30f8909398bf6d7b5",
56
+ "sha256": "560d7874eaccd209b2c358060327bce0051ad73cf9d12bdf13636c202835c83f",
42
57
  "agentTarget": "codex"
43
58
  },
44
59
  {
45
60
  "path": "skills/claude-code/SKILL.md",
46
- "sha256": "c0fdfe3aedfc710b1766d879068fa1c184f8d219c099b994af11887e779f2535",
61
+ "sha256": "0871a7834077a3970960f341baa4bff37836b530ae227a1381c31a59ecc232f8",
47
62
  "agentTarget": "claude-code"
48
63
  },
49
64
  {
50
65
  "path": "skills/claude-code/references/sdk-surface.md",
51
- "sha256": "808225f0ae340016ee5826016770425cc83e19247cc892d4e98f76b66c067830",
66
+ "sha256": "959fa5fee6d2f0fbd82d8f8d39424deb5f6a4e1be2c1bfa4950a1a253c178045",
52
67
  "agentTarget": "claude-code"
53
68
  },
54
69
  {
55
70
  "path": "skills/claude-code/references/cli-commands.md",
56
- "sha256": "387bb7e4850dd13d220987cf829f2749c9561045d06bec3307eec9643a7d0972",
71
+ "sha256": "c50bf5ec6f43bd9fb7115ea9c9eb8de33c93e123f3e2d396785fe75ba094d40d",
57
72
  "agentTarget": "claude-code"
58
73
  },
59
74
  {
60
75
  "path": "skills/claude-code/references/compile-errors.md",
61
- "sha256": "d1a22fb9a897714a069390d00eecfc0b4d0f87a64fdf15c94970ecb6c166dfa8",
76
+ "sha256": "977d9b0022f7bb280cff1ff5737890f16eba1fee632868678dbdb45f9526e79a",
62
77
  "agentTarget": "claude-code"
63
78
  },
64
79
  {
65
80
  "path": "skills/claude-code/references/authoring-workflow.md",
66
- "sha256": "85f8cbbd628e8108e813d0606edd9243441c912fa2a68fb2824663df5b738ea9",
81
+ "sha256": "d88ee3cd351ce4a438bc5c2ecd2afae56b191d1a53954562bb38e116e554047f",
67
82
  "agentTarget": "claude-code"
68
83
  },
69
84
  {
70
85
  "path": "skills/claude-code/references/widgets-and-apps.md",
71
- "sha256": "e6b43810ca7a5f1e3e5191532557c0ac7857881b3e589448e514334fbbacbbfb",
86
+ "sha256": "10d644eb421deee8a99a366f18c848ca769116ec051b7c35a4ee7e2c7b5e2f0d",
87
+ "agentTarget": "claude-code"
88
+ },
89
+ {
90
+ "path": "skills/claude-code/references/test-in-hosts.md",
91
+ "sha256": "08e44784a0d838c322d443eae6b35d5c75b4252a0975db835ef504535e25584a",
92
+ "agentTarget": "claude-code"
93
+ },
94
+ {
95
+ "path": "skills/claude-code/references/troubleshooting.md",
96
+ "sha256": "4e0446d67d4ab037ecb6c9ffdf28494b42ed410f5c94ad7c498c3545f746eefb",
72
97
  "agentTarget": "claude-code"
73
98
  },
74
99
  {
75
100
  "path": "skills/claude-code/references/deploy-and-ops.md",
76
- "sha256": "3184d0855f08ddda65d2a551906e796f5552c22ffce61949747dc365f2de78df",
101
+ "sha256": "33c902d900b60202331cbbcc09b683d91e5c23a07ec7c11c66e48e1a9726f33b",
102
+ "agentTarget": "claude-code"
103
+ },
104
+ {
105
+ "path": "skills/claude-code/references/publishing.md",
106
+ "sha256": "fb0be4c9c9bc9fd68f4e7ed8e9b7e4c8677c415130d441c28590ba0df6cb5aae",
77
107
  "agentTarget": "claude-code"
78
108
  },
79
109
  {
80
110
  "path": "skills/claude-code/references/examples.md",
81
- "sha256": "e1871dbf9ea1dac079cd77b4f33467a99c7b03d06bc4ece30f8909398bf6d7b5",
111
+ "sha256": "560d7874eaccd209b2c358060327bce0051ad73cf9d12bdf13636c202835c83f",
82
112
  "agentTarget": "claude-code"
83
113
  }
84
114
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noodleseed/agent-kit",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "private": false,
5
5
  "description": "Self-checking, self-updating agent skills for the Noodle Seed CLI. Authored in this repo by @noodle-borg/agent-kit; this is the published, independently-versioned canonical skills artifact the CLI fetches and verifies.",
6
6
  "license": "Apache-2.0",
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: noodle-seed
3
3
  description: Use when building, validating, testing, deploying, or operating a local or hosted Noodle Seed MCP server or app authored in TypeScript with the noodle CLI.
4
- version: 0.8.0
5
- hash: 0d6c0f71af5c88ec
4
+ version: 0.9.0
5
+ hash: afde8ab3db819772
6
6
  ---
7
7
 
8
8
  # Noodle Seed
@@ -18,6 +18,7 @@ Use this skill for project-local Noodle Seed authoring in Claude Code; preserve
18
18
  3. `noodle dev` — local loopback runtime that serves and hot-reloads the manifest.
19
19
  4. `noodle check` / `noodle devtools` — MCP Apps/widget readiness and preview (see `references/widgets-and-apps.md`).
20
20
  5. `noodle deploy` after `noodle login` + `noodle link` (see `references/deploy-and-ops.md`).
21
+ 6. Prove it in a real host — `noodle connect <client>` (see `references/test-in-hosts.md`); debug symptoms with `references/troubleshooting.md`.
21
22
 
22
23
  ## References
23
24
 
@@ -26,9 +27,12 @@ Load these on demand:
26
27
  - `references/sdk-surface.md` — what to import from `@noodleseed/one` and which builder to use.
27
28
  - `references/cli-commands.md` — every `noodle` command, grouped by area.
28
29
  - `references/compile-errors.md` — fix `noodle validate` errors by code.
29
- - `references/authoring-workflow.md` — input paths (scrape / OpenAPI import / user interview), the validate→test→dev repair loop, connectors, and secrets/variables.
30
- - `references/widgets-and-apps.md` — MCP Apps, React `view` widgets, and CSP.
30
+ - `references/authoring-workflow.md` — input paths (scrape / OpenAPI import / user interview), the fit check, the validate→test→dev repair loop, connectors, and secrets/variables.
31
+ - `references/widgets-and-apps.md` — MCP Apps, React `view` widgets, the widget hook surface, output shaping, and CSP.
32
+ - `references/test-in-hosts.md` — connect and test in ChatGPT (developer mode), Claude, agent hosts, and MCP Inspector.
33
+ - `references/troubleshooting.md` — runtime symptom → cause → fix, in-host and hosted.
31
34
  - `references/deploy-and-ops.md` — login/link/deploy/status/access and hosted operations.
35
+ - `references/publishing.md` — submit to the ChatGPT apps directory and Claude connectors directory.
32
36
  - `references/examples.md` — flagship example index and a canonical `server.ts`.
33
37
 
34
38
  ## Safety
@@ -3,8 +3,12 @@
3
3
  ## Contents
4
4
 
5
5
  - Input paths
6
+ - Fit check
6
7
  - Repair loop
7
8
  - Connectors
9
+ - HTTP connector example
10
+ - Compute connector example
11
+ - Tests
8
12
  - Secrets and variables
9
13
  - Boundaries
10
14
 
@@ -14,6 +18,10 @@
14
18
  2. **OpenAPI import** — `noodle import openapi <file>` emits a starter `server.ts` from a spec. Use it when the user provides an OpenAPI document.
15
19
  3. **User interview** — Noodle does not interview; you do. Cover custom APIs/integrations, eligibility rules, quoting/approval logic, and private schemas (SQL DDL or JSON samples for custom `connector` declarations). Ask for concrete examples and sample payloads; do not guess a schema from a URL or invent endpoints.
16
20
 
21
+ ## Fit check
22
+
23
+ Before building, confirm the idea fits a conversational surface: 1–3 focused actions where saying it beats clicking, plus data or actions the model lacks on its own. Poor fits — long-form or static content, dashboards, deep multi-step navigation, or a full app port. When an idea does not fit, narrow the scope to the actions that do.
24
+
17
25
  ## Repair loop
18
26
 
19
27
  Author in `server.ts`, then `noodle validate` → fix cited errors (see `compile-errors.md`) → re-validate → `noodle test` → `noodle dev`. Keep the loop tight and error-driven.
@@ -27,6 +35,76 @@ Declare connectors as data, not imperative code:
27
35
 
28
36
  Tools record connector calls into a flow; recording is not execution. Do not branch on runtime outputs with native `if` — use declarative `when(...)` conditions.
29
37
 
38
+ HTTP connector auth variants: `bearer` (`{ kind: "bearer", secret: secret("API_TOKEN") }`), `apiKey` (`{ kind: "apiKey", header: "X-API-Key", secret: secret("API_KEY") }`), `oauth2ClientCredentials`, `delegatedOAuth`, and `delegatedSessionCookie`. Use managed `secret(...)` / `variable(...)` refs for all values that differ by org/app/env.
39
+
40
+ ## HTTP connector example
41
+
42
+ ```ts
43
+ import { connector, secret, variable } from '@noodleseed/one';
44
+
45
+ const crm = connector('crm').version('1.0.0').http({
46
+ baseUrl: variable('CRM_BASE_URL'),
47
+ allowedOrigins: [variable('CRM_BASE_URL')],
48
+ auth: { kind: 'bearer', secret: secret('CRM_TOKEN') },
49
+ operations: {
50
+ findCustomer: {
51
+ type: 'read',
52
+ input: { email: { type: "string", required: true } },
53
+ output: { id: { type: "string", required: true }, name: { type: "string" } },
54
+ method: "GET",
55
+ path: "/customers",
56
+ request: { query: { email: "${args.email}" } },
57
+ response: { id: "${response.body.data.0.id}", name: "${response.body.data.0.name}" },
58
+ },
59
+ createTicket: {
60
+ type: 'action',
61
+ input: { customerId: { type: "string", required: true }, body: { type: "string", required: true } },
62
+ output: { ticketId: { type: "string", required: true } },
63
+ method: "POST",
64
+ path: "/tickets",
65
+ request: { body: { customer_id: "${args.customerId}", body: "${args.body}" } },
66
+ response: { ticketId: "${response.body.id}" },
67
+ },
68
+ },
69
+ });
70
+ ```
71
+
72
+ Use `${args.field}` for tool/operation inputs and `${response.body.path}` for response mapping. Prefer explicit `allowedOrigins`; OAuth token/session URLs must also be on an allowed origin. For client credentials use `{ kind: "oauth2ClientCredentials", tokenUrl, clientId, clientSecret, scopes? }`; for per-customer downstream calls use `delegatedOAuth` or `delegatedSessionCookie` with a matching `customerAuth` server option.
73
+
74
+ ## Compute connector example
75
+
76
+ ```ts
77
+ const scoring = connector('scoring').version('1.0.0').compute('normalize', {
78
+ input: { email: { type: "string", required: true }, priority: { type: "string" } },
79
+ output: { score: { type: "number", required: true } },
80
+ calls: { findCustomer: 'crm.findCustomer' },
81
+ limits: { timeoutMs: 1000, maxHostCalls: 2 },
82
+ run(input, { callOperation }) {
83
+ const customer = callOperation("findCustomer", { email: input.email }) as { id?: string };
84
+ return { score: customer.id && input.priority === "high" ? 100 : 50 };
85
+ },
86
+ });
87
+ ```
88
+
89
+ Compute `run` functions are serialized and sandboxed: no imports, no closure capture, no `fetch`, no `process`. Any backing-system call must be declared in `calls` and invoked through `callOperation`. For conditional flow edges, use `when(...)` in recorded fulfilment instead of native branching on connector outputs.
90
+
91
+ ## Tests
92
+
93
+ Use Vitest for app-local tests. Keep fixtures project-local; do not import from `examples/`. A minimum test suite imports the default server, checks the intended definitions compile, then lets `noodle test --json` perform the loopback MCP smoke.
94
+
95
+ ```ts
96
+ import { describe, expect, it } from 'vitest';
97
+ import app from '../src/server.js';
98
+
99
+ describe('server', () => {
100
+ it('declares the expected tool surface', () => {
101
+ expect(app.name).toBe('support_assistant');
102
+ });
103
+ });
104
+ ```
105
+
106
+ After focused tests pass, run `noodle validate --json`, `noodle test --json`, and then `noodle dev` for interactive local verification.
107
+
30
108
  ## Secrets and variables
31
109
 
32
110
  Author managed config as `secret("NAME")` / `variable("NAME")` and operate it with `noodle secrets set` / `noodle variables set` (scoped org/app/env). Never inline secret values in `server.ts`, tests, or generated files.
@@ -54,7 +54,7 @@ Every `noodle` command, grouped by area. Local authoring commands (`validate`, `
54
54
  | `noodle rollback` | Roll back to a previous deployment. |
55
55
  | `noodle archive` | Archive the whole app: endpoints answer 410 Gone; hard-deleted after the retention window. |
56
56
  | `noodle restore` | Restore an archived app within the retention window. |
57
- | `noodle access` | Set the access mode (owner-only|org-members|authenticated|customers). |
57
+ | `noodle access` | Set the access mode (owner-only\|org-members\|authenticated\|customers). |
58
58
  | `noodle apps` | List or inspect hosted apps for an org (`apps list`/`apps inspect <app>`). |
59
59
  | `noodle envs` | List or inspect environments for an app (`envs list`/`envs inspect <env>`). |
60
60
  | `noodle deployments` | List or inspect individual deployments (`deployments list`/`deployments inspect <id>`). |
@@ -64,7 +64,7 @@ Every `noodle` command, grouped by area. Local authoring commands (`validate`, `
64
64
  | `noodle whoami` | Print the current authenticated user. |
65
65
  | `noodle list` | Removed — promoted to `deployments list` (prints the recovery pointer and exits 2). |
66
66
  | `noodle github` | Connect, inspect, or disconnect the GitHub repository behind an app’s GitHub-native deploys (`connect`/`status`/`disconnect`; `connect` opens a browser install, `--repo` for headless). |
67
- | `noodle target` | Show or set the deployment target (local|cloud|other). |
67
+ | `noodle target` | Show or set the deployment target (local\|cloud\|other). |
68
68
 
69
69
  ## Org & members
70
70
 
@@ -87,8 +87,8 @@ Every `noodle` command, grouped by area. Local authoring commands (`validate`, `
87
87
  | `noodle audit` | Operator governance audit status and event queries. |
88
88
  | `noodle logs` | View service/deployment logs. |
89
89
  | `noodle metrics` | MCP analytics for a deployed server (volume, sessions, latency percentiles, two-tier errors, tools, clients). Agents: `noodle metrics --agent-output` for a health verdict + next actions. |
90
- | `noodle events` | The per-request MCP event stream with status/tool/client filters; `--session <id>` replays one session in order. Agents: add `--json` and filter (`--status tool_error|mcp_error`) when debugging. |
91
- | `noodle alerts` | Analytics alert rules (`add|list|remove|test`): an edge-triggered webhook fires when error share, error count, calls, or p95 latency breaches. Webhook URLs are stored server-side and shown redacted. |
90
+ | `noodle events` | The per-request MCP event stream with status/tool/client filters; `--session <id>` replays one session in order. Agents: add `--json` and filter (`--status tool_error\|mcp_error`) when debugging. |
91
+ | `noodle alerts` | Analytics alert rules (`add\|list\|remove\|test`): an edge-triggered webhook fires when error share, error count, calls, or p95 latency breaches. Webhook URLs are stored server-side and shown redacted. |
92
92
  | `noodle policy` | Manage policy (status/list/show/effective/simulate/suspend/quota/rate/...). |
93
93
 
94
94
  ## CLI maintenance
@@ -3,12 +3,40 @@
3
3
  ## Contents
4
4
 
5
5
  - The repair loop
6
+ - JSON shape
7
+ - Fix prompt
6
8
  - Error codes
7
9
 
8
10
  ## The repair loop
9
11
 
10
12
  Run `noodle validate` (add `--json` for machine-readable output, `--fix-prompt` for an agent repair prompt). Each error carries a `code`, a dotted `path` to the offending field, and a `message`; many also carry `expected`/`got`, `didYouMean`/`suggestions`, and a `docAnchor`. Fix the specific error the `path` locates, then re-validate. Do not freeform re-edit. Once `noodle validate` passes, run `noodle test`, then `noodle dev`.
11
13
 
14
+ ## JSON shape
15
+
16
+ Use `noodle validate --json` in automated repair loops. Treat `errors[]` as the work queue and change only the cited file/path before re-running validation.
17
+
18
+ ```json
19
+ {
20
+ "ok": false,
21
+ "errors": [
22
+ {
23
+ "code": "unknown_operation",
24
+ "path": "tools.search.fulfil.steps.0.operation",
25
+ "message": "Unknown connector operation.",
26
+ "expected": "operation declared on connector alias `crm`",
27
+ "got": "crm.find_customer",
28
+ "didYouMean": "crm.findCustomer",
29
+ "suggestions": ["crm.findCustomer"],
30
+ "docAnchor": "connectors.operations"
31
+ }
32
+ ]
33
+ }
34
+ ```
35
+
36
+ ## Fix prompt
37
+
38
+ `noodle validate --fix-prompt` prints a compact agent repair prompt with the same structured errors. Use it when delegating a repair pass, but still inspect the resulting code and re-run `noodle validate --json`.
39
+
12
40
  ## Error codes
13
41
 
14
42
  | Code | Fix |
@@ -8,6 +8,7 @@
8
8
  - Access modes
9
9
  - Org and members
10
10
  - Config and observability
11
+ - Agent-safe CLI recipes
11
12
 
12
13
  ## Authenticate
13
14
 
@@ -33,6 +34,26 @@
33
34
 
34
35
  Manage runtime config with `noodle secrets` / `noodle variables` (scoped org/app/env). Operators use `noodle logs`, `noodle audit`, and `noodle policy` for logs, governance audit, and policy.
35
36
 
37
+ ## Agent-safe CLI recipes
38
+
39
+ Use explicit flags in headless runs so commands never wait for a prompt:
40
+
41
+ ```sh
42
+ noodle link --org acme --app support-assistant --env prod
43
+ noodle secrets set CRM_TOKEN --scope env --org acme --app support-assistant --env prod --from-env CRM_TOKEN
44
+ noodle secrets set CRM_CERT --scope env --org acme --app support-assistant --env prod --from-file ./cert.pem
45
+ printf %s "$CRM_TOKEN" | noodle secrets set CRM_TOKEN --scope env --org acme --app support-assistant --env prod --from-stdin
46
+ noodle variables set CRM_BASE_URL --scope env --org acme --app support-assistant --env prod --value https://crm.example.com
47
+ noodle secrets list --scope env --org acme --app support-assistant --env prod --json
48
+ noodle validate --json
49
+ noodle test --json
50
+ noodle deploy --json
51
+ noodle smoke --json
52
+ noodle agents doctor --json
53
+ ```
54
+
55
+ `secrets resolve` is for local diagnostics only; do not print resolved values into prompts, logs, tests, or docs. Prefer `--from-env`, `--from-file`, or `--from-stdin` over inline `--value` for sensitive values. Variables may use `--value` when the value is non-secret.
56
+
36
57
  ## Analytics (verify after deploy, debug errors)
37
58
 
38
- After a deploy gets traffic, verify with `noodle metrics --agent-output` — it returns a `health` verdict (`ok`/`attention`), a one-line summary, and `attention[]` items each carrying the exact next command. When a tool errors, drill in with `noodle events --tool <name> --json` (filters: `--status tool_error|mcp_error`, `--client <name>`); `noodle events --session <id> --json` replays one session chronologically. `--json` on both returns the full payload; human runs get the branded report. Two-tier errors: `tool_error` is recoverable (handed back to the model), `mcp_error` needs attention (protocol/timeout/internal).
59
+ After a deploy gets traffic, verify with `noodle metrics --agent-output` — it returns a `health` verdict (`ok`/`attention`), a one-line summary, and `attention[]` items each carrying the exact next command. When a tool errors, drill in with `noodle events --tool <name> --json` (filters: `--status tool_error|mcp_error`, `--client <name>`); `noodle events --session <id> --json` replays one session chronologically. `--json` on both returns the full payload; human runs get the branded report. Two-tier errors: `tool_error` is recoverable (handed back to the model), `mcp_error` needs attention (protocol/timeout/internal). Wire edge-triggered webhooks on error share, error count, calls, or p95 latency with `noodle alerts add|list|remove|test`.
@@ -10,7 +10,10 @@ Flagship examples (one per capability). Read the matching example for the patter
10
10
  | `customer-auth` | End-user (customer) auth via OIDC/Firebase bridge with delegated credentials. |
11
11
  | `stateful-draft` | Durable, caller-scoped widget state handles with optimistic revisions. |
12
12
  | `perplexity` | A real SaaS API with bearer auth and a managed `secret`. |
13
+ | `bitcoin` | API-key HTTP connector, custom auth header, and compute normalization. |
14
+ | `sharepoint` | Microsoft SharePoint delegated Microsoft Entra auth and Graph tools. |
13
15
  | `internal-ops-demo` | Governed internal connectivity — tools/resources/prompts, role-shaped output. |
16
+ | `docs-assistant` | Docs/knowledge assistant grounding coding agents in the live docs export. |
14
17
 
15
18
  ## Canonical server.ts
16
19
 
@@ -0,0 +1,31 @@
1
+ # Publish to app directories
2
+
3
+ Directory requirements evolve — treat this as the workflow map and verify against the host’s current submission docs before submitting.
4
+
5
+ ## Contents
6
+
7
+ - Readiness gate
8
+ - ChatGPT apps directory
9
+ - Claude connectors directory
10
+
11
+ ## Readiness gate
12
+
13
+ Before any submission:
14
+
15
+ 1. `noodle check --target chatgpt` must be clean — every widget needs `domain` (one https origin per app) and an exact `csp` (hosts require the CSP to list precisely the domains you fetch from).
16
+ 2. Audit tool responses in developer mode: run realistic prompts and strip anything not strictly needed — PII, internal identifiers (session/trace/request IDs, internal account IDs), and any secrets.
17
+ 3. The server must be deployed and publicly reachable: `noodle deploy`, confirm with `noodle open --print` and `noodle smoke`. Reviewers connect to the real endpoint — never submit a placeholder or loopback URL, and the access mode must not be `owner-only` (`noodle access set`).
18
+ 4. Polish the listing surface: tool descriptions, widget titles, and the `server` branding tokens are what reviewers and users see.
19
+
20
+ ## ChatGPT apps directory
21
+
22
+ Submit from the OpenAI developer dashboard (platform.openai.com → Apps):
23
+
24
+ - Complete organization identity verification first (individual or business) — it is enforced at review time.
25
+ - The submission form asks for the app name, logo, description, company and privacy policy URLs, MCP server URL and tool information, screenshots, test prompts with expected responses, and localization details.
26
+ - One version may be published and one in review at a time; to revise a pending submission, cancel the review and resubmit rather than creating a new app.
27
+ - Review combines automated checks and manual evaluation; rejections come with feedback — fix and resubmit, or reply to appeal. An approved app is also distributed as a Codex plugin.
28
+
29
+ ## Claude connectors directory
30
+
31
+ Anthropic runs a connectors directory for Claude; submission goes through Anthropic’s published process (see the Anthropic connectors directory FAQ on support.claude.com). The same readiness gate applies: deployed public endpoint, clean `noodle check`, and graceful degradation where Apps rendering is unavailable.
@@ -1,6 +1,7 @@
1
1
  # @noodleseed/one SDK surface
2
2
 
3
- Import these from `@noodleseed/one`. They are declarative builders that emit manifest data — do not hand-author the manifest or runtime artifacts. React view helpers come from `@noodleseed/one/react` (`generateHelpers`).
3
+ Import these from `@noodleseed/one`. They are declarative builders that emit manifest data — do not hand-author the manifest or runtime artifacts. React view helpers come from `@noodleseed/one/react` (`generateHelpers`); the hook surface is documented in `widgets-and-apps.md`.
4
+ Platform helper connectors are explicit subpath imports from `@noodleseed/one/platform` (`noodlePlatform`, `noodlePlatformCatalog`) when an app needs first-party hosted state APIs.
4
5
 
5
6
  ## Server & tools
6
7
 
@@ -30,10 +31,25 @@ Import these from `@noodleseed/one`. They are declarative builders that emit man
30
31
  - `secret("NAME")` — reference a managed secret (operated via `noodle secrets`).
31
32
  - `variable("NAME")` — reference a managed variable (operated via `noodle variables`).
32
33
 
34
+ ## Customer auth
35
+
36
+ - `customerAuth.oidc(...)`, `.firebase(...)`, `.microsoft(...)`, or `.bridge(...)` — end-user/customer identity for `--access customers` deployments.
37
+
33
38
  ## Sessions
34
39
 
35
40
  - `handoffSession(...)` — typed cross-host handoff session envelopes.
36
41
 
37
42
  ## Schemas
38
43
 
39
- - `z` — Zod, for input/output schemas (compiles to JSON Schema 2020-12).
44
+ - `z` — Zod, for input/output schemas (compiles to JSON Schema 2020-12).
45
+
46
+ ## Authoring signatures
47
+
48
+ - `server(name, options, definitions)` — `options` commonly includes `title`, `version`, `instructions`, `branding`, `auth`, `use`, `provides`, `state`, and `handoff`; `definitions` is the array of tools/resources/prompts/widgets.
49
+ - `tool(name, { description, input, output, annotations?, fulfil })` — `input`/`output` are Zod schemas; `fulfil({ input, connectors, user })` returns data matching `output`.
50
+ - `toolWithWidget(name, { description, input, output, fulfil, view })` — same as `tool`, plus `view: { component, entry }` for a React widget.
51
+ - `toolForWidget(name, { input, output, fulfil })` — helper tool for widget actions; hidden from the model.
52
+ - `resource(name, { uri, description?, mimeType?, fulfil })` and `prompt(name, { description?, arguments?, fulfil })` expose MCP resources/prompts.
53
+ - `widget(name, { title, view, csp?, domain?, permissions? })` declares reusable view metadata; `asset("./path")` packages local files.
54
+ - `customerAuth.*(...)` belongs in `server` options when deployed customer callers need verified identity; inspect `examples/customer-auth` or `examples/sharepoint` before using it.
55
+ - `state` defines durable widget state handles; `handoff` declares allowed external domains for safe host handoff.
@@ -0,0 +1,39 @@
1
+ # Test in real hosts
2
+
3
+ Local `noodle dev` and `noodle devtools` prove the server works; the widget experience is only proven inside a real host. `noodle connect <client>` prints the exact setup flow per host.
4
+
5
+ ## Contents
6
+
7
+ - Local inspection first
8
+ - Agent hosts (Claude Code, Codex, editors)
9
+ - ChatGPT (developer mode)
10
+ - Claude
11
+ - Public URL for a local server
12
+ - What to verify
13
+
14
+ ## Local inspection first
15
+
16
+ Run `noodle dev` and inspect the loopback endpoint with MCP Inspector: `noodle connect inspector` prints the flow (`npx @modelcontextprotocol/inspector <printed endpoint>`). Preview widget metadata and rendering with `noodle devtools`.
17
+
18
+ ## Agent hosts (Claude Code, Codex, editors)
19
+
20
+ `noodle connect claude-code` / `noodle connect codex` (add `--write` for project-local setup). For other editors (`cursor`, `vscode`, `gemini`), `noodle connect <client>` prints the setup steps, and `noodle docs export --format llms` produces portable context. With a deployed endpoint, `noodle connect <client> --endpoint <url>` prints the MCP client registration config.
21
+
22
+ ## ChatGPT (developer mode)
23
+
24
+ 1. Deploy: `noodle deploy`, then `noodle open --print` for the hosted MCP URL (ChatGPT needs a public HTTPS endpoint, not loopback).
25
+ 2. In ChatGPT: Settings → Connectors → enable Developer mode → add the endpoint (`noodle connect chatgpt` prints these steps).
26
+ 3. Toggle the connector on in a new conversation and sign in when prompted; testers outside your org need a wider access mode (`noodle access set`).
27
+ 4. Test on mobile too — invoke the same connector from the ChatGPT iOS/Android apps to check widget layout.
28
+
29
+ ## Claude
30
+
31
+ `noodle connect claude` prints the flow: deploy, then add the hosted MCP URL as a custom connector in Claude settings and sign in when prompted. Widgets render in Apps-capable Claude surfaces; elsewhere the tool’s text/structured result is shown.
32
+
33
+ ## Public URL for a local server
34
+
35
+ To try an undeployed server in a host that requires a public URL, `noodle dev --tunnel` publishes a temporary public URL for the loopback endpoint (requires the external `cloudflared` binary on PATH). Treat it as a short-lived test URL — deploy for anything shared.
36
+
37
+ ## What to verify
38
+
39
+ Run a golden prompt set — direct (“use <tool> to…”), indirect (a natural request the model should route), and negative (requests that must not trigger the tool). Confirm the model picks the right tool with the right arguments, the widget renders and its actions work, external links open, and the experience degrades to readable text where Apps are unsupported. Symptoms → `references/troubleshooting.md`.
@@ -0,0 +1,29 @@
1
+ # Troubleshooting in hosts
2
+
3
+ ## Contents
4
+
5
+ - First moves
6
+ - Symptom map
7
+
8
+ ## First moves
9
+
10
+ Re-run the local gates before debugging in-host: `noodle validate`, `noodle check` (add `--target chatgpt` for ChatGPT-specific requirements), and `noodle doctor`. Confirm the CLI is current with `noodle update --check` and that the project-local skill is intact with `noodle agents doctor --json` — host metadata requirements evolve and fixes ship in the CLI/agent-kit. Never paste tokens, secrets, or `.env.noodle` values into prompts or logs while debugging.
11
+
12
+ For protocol/conformance checks, the headless harness is `@mcpjam/cli`, not a `noodle` subcommand. Use it against a local `noodle dev` URL without an access token, or against hosted URLs through the host/OAuth flow printed by `noodle connect`.
13
+
14
+ ## Symptom map
15
+
16
+ | Symptom | Likely cause | Fix |
17
+ | :-- | :-- | :-- |
18
+ | Images, fonts, or styles don’t load inside the widget | The host sandbox silently blocks origins not declared in the widget CSP | Add every asset origin to `csp: { resourceDomains: [...] }` (fetch/XHR origins go in `connectDomains`, embedded iframes in `frameDomains`), then re-run `noodle check --target chatgpt` |
19
+ | ChatGPT warns “Widget CSP is not set” | The widget declares no `csp` | Declare `csp` on the widget with the exact origins it uses |
20
+ | ChatGPT warns “Widget domain is not set” | No `domain` on the widget (required for app-store submission) | Set `domain: "https://…"` (one https origin per app) on each widget |
21
+ | External links do nothing, or show a safe-link warning | Link opened outside the host bridge, or the target origin is not allowlisted | Use `useOpenExternal()` (never `window.open`) and add the target origins to the server-level `handoff.allowedDomains` |
22
+ | Tool succeeds but no widget appears | The tool has no view, or the host surface doesn’t support MCP Apps | Use `toolWithWidget`, run `noodle check`, preview with `noodle devtools`; on non-Apps surfaces only the text/structured result renders |
23
+ | Widget shows stale or missing data | The widget reads `structuredContent`, which must match the `output` schema | Make `fulfil` return exactly the `output` shape (arrays and nested objects are supported); inspect the live result with `noodle devtools` |
24
+ | `useCallTool` fails from the widget | Tool name mismatch, or the helper tool is model-visible | List names with `noodle tools`; widget-only helpers must be declared with `toolForWidget` |
25
+ | `noodle validate` passes but React views fail to bundle (“requires Vite”) | Project dependencies are not installed — widget bundling uses the app-local Vite | Run the project’s package install, then retry `noodle dev` / `noodle deploy` |
26
+ | Hosted endpoint returns 401 to probes | Expected: hosted servers challenge unauthenticated calls with OAuth metadata | Sign in from the host when prompted; widen who may call with `noodle access set` if testers are outside the org |
27
+ | Tools error only after deploy | Runtime/config differences surface hosted (secrets, connector reachability) | Run `noodle smoke`, then `noodle metrics --agent-output` and `noodle events --tool <name> --status tool_error --json`; check `noodle secrets list` scope |
28
+ | Need to invoke a deployed tool from the terminal | The `noodle` CLI is not a general MCP client and has no `call` verb | Use `noodle test` for the local smoke, `noodle tools`/`resources`/`prompts` for local listing, MCP Inspector, or `npx @mcpjam/cli@latest tools call --url <url> ...` for headless MCP probing |
29
+ | One customer/session reports a bad answer or protocol error | The failure may be a model/tool error, host protocol error, or connector/runtime error | Run `noodle metrics --agent-output`, then `noodle events --tool <name> --status tool_error --json`; copy the `sessionId` into `noodle events --session <id> --json`, then match timestamps with `noodle logs` |
@@ -4,7 +4,10 @@
4
4
 
5
5
  - Tools and views
6
6
  - React authoring
7
- - CSP and permissions
7
+ - React hook surface
8
+ - Shaping tool output for widgets
9
+ - Widget state and model context
10
+ - CSP, domain, and permissions
8
11
  - Host bridge
9
12
  - Readiness and boundaries
10
13
 
@@ -18,15 +21,39 @@ Author views as React components. Get typed helpers from `@noodleseed/one/react`
18
21
 
19
22
  ```ts
20
23
  import { generateHelpers } from '@noodleseed/one/react';
21
- const { useCallTool, useLayout, useToolInfo, useViewState } = generateHelpers<AppType>();
24
+ const { useToolInfo, useCallTool, useViewState, useLayout, useOpenExternal, useSendFollowUpMessage } =
25
+ generateHelpers<AppType>();
22
26
  ```
23
27
 
24
28
  Bind interactive elements to tools (`useCallTool("place_order")`) and annotate model-facing context with `data-llm`. A raw `html` escape hatch exists for self-contained widgets (declarative `data-bind`/`data-action`; no inline `<script>`).
25
29
 
26
- ## CSP and permissions
30
+ ## React hook surface
31
+
32
+ | Hook | Use for |
33
+ | :-- | :-- |
34
+ | `useToolInfo` | Read the invoking tool result; `structuredContent` is the widget’s typed data payload. |
35
+ | `useCallTool` | Call a tool from the widget — returns `{ callTool, data, error, isPending }`; target a model-visible tool or a hidden `toolForWidget` helper. |
36
+ | `useViewState` | Persist per-widget UI state across re-renders and restores: `const [value, setValue] = useViewState("key", initial)`. |
37
+ | `useLayout` | Read host layout: `{ theme, displayMode, locale? }` (`theme` is `"light"`/`"dark"`, `displayMode` is `"inline"`/`"fullscreen"`) — adapt styling to the host theme and mode. |
38
+ | `useOpenExternal` | Open an external link through the host (never `window.open`); the target origin must be listed in the server-level `handoff.allowedDomains`. |
39
+ | `useSendFollowUpMessage` | Send a follow-up prompt to the model from a user interaction: `send({ prompt })` — trigger only from an explicit user action. |
40
+
41
+ Adapt to the host with `useLayout()` — style for both `theme` values, and keep the inline `displayMode` compact (content fits the space; no internal scrolling). Trigger `useOpenExternal()` and `useSendFollowUpMessage()` only from explicit user actions.
42
+
43
+ ## Shaping tool output for widgets
44
+
45
+ The widget reads the tool result’s `structuredContent`, typed by the tool’s `output` schema — arrays and nested objects are fully supported, so model the data naturally (`z.array(z.object({ ... }))`) instead of flattening. Keep the result’s `content` useful on its own: hosts without MCP Apps support show only the text/structured result, so the tool must degrade gracefully.
46
+
47
+ ## Widget state and model context
48
+
49
+ Persist UI state (selections, drafts, pagination) with `useViewState("key", initial)` — it survives re-renders and conversation restores. For durable, caller-scoped state handles with optimistic revisions, follow the `stateful-draft` example. Mark the DOM the model should see with `data-llm` attributes; everything else stays widget-only.
50
+
51
+ ## CSP, domain, and permissions
27
52
 
28
53
  Declare network/host needs explicitly: `csp: { connectDomains, resourceDomains, frameDomains }` and `permissions` (e.g. `clipboardWrite`). Secrets are never injected into widgets; tool output is redacted before widget delivery.
29
54
 
55
+ For ChatGPT: set `domain` on each widget (one https origin per app; required for app-store submission, optional for dev-mode testing), and declare external-link targets in the server-level `handoff.allowedDomains` — the compiler derives ChatGPT’s `redirect_domains` from it so `useOpenExternal()` links open without the safe-link warning. `noodle check --target chatgpt` verifies all of this.
56
+
30
57
  ## Host bridge
31
58
 
32
59
  One runtime targets both Claude’s ext-apps bridge and ChatGPT’s `window.openai`, detected at startup. Tool results still carry useful `content`/`structuredContent` so non-Apps hosts degrade gracefully.
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: noodle-seed
3
3
  description: Use when building, validating, testing, deploying, or operating a local or hosted Noodle Seed MCP server or app authored in TypeScript with the noodle CLI.
4
- version: 0.8.0
5
- hash: f297c7e0fa62058d
4
+ version: 0.9.0
5
+ hash: 097c37f2e7a3e482
6
6
  ---
7
7
 
8
8
  # Noodle Seed
@@ -18,6 +18,7 @@ Use this skill for local Noodle Seed project work in Codex.
18
18
  3. `noodle dev` — local loopback runtime that serves and hot-reloads the manifest.
19
19
  4. `noodle check` / `noodle devtools` — MCP Apps/widget readiness and preview (see `references/widgets-and-apps.md`).
20
20
  5. `noodle deploy` after `noodle login` + `noodle link` (see `references/deploy-and-ops.md`).
21
+ 6. Prove it in a real host — `noodle connect <client>` (see `references/test-in-hosts.md`); debug symptoms with `references/troubleshooting.md`.
21
22
 
22
23
  ## References
23
24
 
@@ -26,9 +27,12 @@ Load these on demand:
26
27
  - `references/sdk-surface.md` — what to import from `@noodleseed/one` and which builder to use.
27
28
  - `references/cli-commands.md` — every `noodle` command, grouped by area.
28
29
  - `references/compile-errors.md` — fix `noodle validate` errors by code.
29
- - `references/authoring-workflow.md` — input paths (scrape / OpenAPI import / user interview), the validate→test→dev repair loop, connectors, and secrets/variables.
30
- - `references/widgets-and-apps.md` — MCP Apps, React `view` widgets, and CSP.
30
+ - `references/authoring-workflow.md` — input paths (scrape / OpenAPI import / user interview), the fit check, the validate→test→dev repair loop, connectors, and secrets/variables.
31
+ - `references/widgets-and-apps.md` — MCP Apps, React `view` widgets, the widget hook surface, output shaping, and CSP.
32
+ - `references/test-in-hosts.md` — connect and test in ChatGPT (developer mode), Claude, agent hosts, and MCP Inspector.
33
+ - `references/troubleshooting.md` — runtime symptom → cause → fix, in-host and hosted.
31
34
  - `references/deploy-and-ops.md` — login/link/deploy/status/access and hosted operations.
35
+ - `references/publishing.md` — submit to the ChatGPT apps directory and Claude connectors directory.
32
36
  - `references/examples.md` — flagship example index and a canonical `server.ts`.
33
37
 
34
38
  ## Safety
@@ -3,8 +3,12 @@
3
3
  ## Contents
4
4
 
5
5
  - Input paths
6
+ - Fit check
6
7
  - Repair loop
7
8
  - Connectors
9
+ - HTTP connector example
10
+ - Compute connector example
11
+ - Tests
8
12
  - Secrets and variables
9
13
  - Boundaries
10
14
 
@@ -14,6 +18,10 @@
14
18
  2. **OpenAPI import** — `noodle import openapi <file>` emits a starter `server.ts` from a spec. Use it when the user provides an OpenAPI document.
15
19
  3. **User interview** — Noodle does not interview; you do. Cover custom APIs/integrations, eligibility rules, quoting/approval logic, and private schemas (SQL DDL or JSON samples for custom `connector` declarations). Ask for concrete examples and sample payloads; do not guess a schema from a URL or invent endpoints.
16
20
 
21
+ ## Fit check
22
+
23
+ Before building, confirm the idea fits a conversational surface: 1–3 focused actions where saying it beats clicking, plus data or actions the model lacks on its own. Poor fits — long-form or static content, dashboards, deep multi-step navigation, or a full app port. When an idea does not fit, narrow the scope to the actions that do.
24
+
17
25
  ## Repair loop
18
26
 
19
27
  Author in `server.ts`, then `noodle validate` → fix cited errors (see `compile-errors.md`) → re-validate → `noodle test` → `noodle dev`. Keep the loop tight and error-driven.
@@ -27,6 +35,76 @@ Declare connectors as data, not imperative code:
27
35
 
28
36
  Tools record connector calls into a flow; recording is not execution. Do not branch on runtime outputs with native `if` — use declarative `when(...)` conditions.
29
37
 
38
+ HTTP connector auth variants: `bearer` (`{ kind: "bearer", secret: secret("API_TOKEN") }`), `apiKey` (`{ kind: "apiKey", header: "X-API-Key", secret: secret("API_KEY") }`), `oauth2ClientCredentials`, `delegatedOAuth`, and `delegatedSessionCookie`. Use managed `secret(...)` / `variable(...)` refs for all values that differ by org/app/env.
39
+
40
+ ## HTTP connector example
41
+
42
+ ```ts
43
+ import { connector, secret, variable } from '@noodleseed/one';
44
+
45
+ const crm = connector('crm').version('1.0.0').http({
46
+ baseUrl: variable('CRM_BASE_URL'),
47
+ allowedOrigins: [variable('CRM_BASE_URL')],
48
+ auth: { kind: 'bearer', secret: secret('CRM_TOKEN') },
49
+ operations: {
50
+ findCustomer: {
51
+ type: 'read',
52
+ input: { email: { type: "string", required: true } },
53
+ output: { id: { type: "string", required: true }, name: { type: "string" } },
54
+ method: "GET",
55
+ path: "/customers",
56
+ request: { query: { email: "${args.email}" } },
57
+ response: { id: "${response.body.data.0.id}", name: "${response.body.data.0.name}" },
58
+ },
59
+ createTicket: {
60
+ type: 'action',
61
+ input: { customerId: { type: "string", required: true }, body: { type: "string", required: true } },
62
+ output: { ticketId: { type: "string", required: true } },
63
+ method: "POST",
64
+ path: "/tickets",
65
+ request: { body: { customer_id: "${args.customerId}", body: "${args.body}" } },
66
+ response: { ticketId: "${response.body.id}" },
67
+ },
68
+ },
69
+ });
70
+ ```
71
+
72
+ Use `${args.field}` for tool/operation inputs and `${response.body.path}` for response mapping. Prefer explicit `allowedOrigins`; OAuth token/session URLs must also be on an allowed origin. For client credentials use `{ kind: "oauth2ClientCredentials", tokenUrl, clientId, clientSecret, scopes? }`; for per-customer downstream calls use `delegatedOAuth` or `delegatedSessionCookie` with a matching `customerAuth` server option.
73
+
74
+ ## Compute connector example
75
+
76
+ ```ts
77
+ const scoring = connector('scoring').version('1.0.0').compute('normalize', {
78
+ input: { email: { type: "string", required: true }, priority: { type: "string" } },
79
+ output: { score: { type: "number", required: true } },
80
+ calls: { findCustomer: 'crm.findCustomer' },
81
+ limits: { timeoutMs: 1000, maxHostCalls: 2 },
82
+ run(input, { callOperation }) {
83
+ const customer = callOperation("findCustomer", { email: input.email }) as { id?: string };
84
+ return { score: customer.id && input.priority === "high" ? 100 : 50 };
85
+ },
86
+ });
87
+ ```
88
+
89
+ Compute `run` functions are serialized and sandboxed: no imports, no closure capture, no `fetch`, no `process`. Any backing-system call must be declared in `calls` and invoked through `callOperation`. For conditional flow edges, use `when(...)` in recorded fulfilment instead of native branching on connector outputs.
90
+
91
+ ## Tests
92
+
93
+ Use Vitest for app-local tests. Keep fixtures project-local; do not import from `examples/`. A minimum test suite imports the default server, checks the intended definitions compile, then lets `noodle test --json` perform the loopback MCP smoke.
94
+
95
+ ```ts
96
+ import { describe, expect, it } from 'vitest';
97
+ import app from '../src/server.js';
98
+
99
+ describe('server', () => {
100
+ it('declares the expected tool surface', () => {
101
+ expect(app.name).toBe('support_assistant');
102
+ });
103
+ });
104
+ ```
105
+
106
+ After focused tests pass, run `noodle validate --json`, `noodle test --json`, and then `noodle dev` for interactive local verification.
107
+
30
108
  ## Secrets and variables
31
109
 
32
110
  Author managed config as `secret("NAME")` / `variable("NAME")` and operate it with `noodle secrets set` / `noodle variables set` (scoped org/app/env). Never inline secret values in `server.ts`, tests, or generated files.
@@ -54,7 +54,7 @@ Every `noodle` command, grouped by area. Local authoring commands (`validate`, `
54
54
  | `noodle rollback` | Roll back to a previous deployment. |
55
55
  | `noodle archive` | Archive the whole app: endpoints answer 410 Gone; hard-deleted after the retention window. |
56
56
  | `noodle restore` | Restore an archived app within the retention window. |
57
- | `noodle access` | Set the access mode (owner-only|org-members|authenticated|customers). |
57
+ | `noodle access` | Set the access mode (owner-only\|org-members\|authenticated\|customers). |
58
58
  | `noodle apps` | List or inspect hosted apps for an org (`apps list`/`apps inspect <app>`). |
59
59
  | `noodle envs` | List or inspect environments for an app (`envs list`/`envs inspect <env>`). |
60
60
  | `noodle deployments` | List or inspect individual deployments (`deployments list`/`deployments inspect <id>`). |
@@ -64,7 +64,7 @@ Every `noodle` command, grouped by area. Local authoring commands (`validate`, `
64
64
  | `noodle whoami` | Print the current authenticated user. |
65
65
  | `noodle list` | Removed — promoted to `deployments list` (prints the recovery pointer and exits 2). |
66
66
  | `noodle github` | Connect, inspect, or disconnect the GitHub repository behind an app’s GitHub-native deploys (`connect`/`status`/`disconnect`; `connect` opens a browser install, `--repo` for headless). |
67
- | `noodle target` | Show or set the deployment target (local|cloud|other). |
67
+ | `noodle target` | Show or set the deployment target (local\|cloud\|other). |
68
68
 
69
69
  ## Org & members
70
70
 
@@ -87,8 +87,8 @@ Every `noodle` command, grouped by area. Local authoring commands (`validate`, `
87
87
  | `noodle audit` | Operator governance audit status and event queries. |
88
88
  | `noodle logs` | View service/deployment logs. |
89
89
  | `noodle metrics` | MCP analytics for a deployed server (volume, sessions, latency percentiles, two-tier errors, tools, clients). Agents: `noodle metrics --agent-output` for a health verdict + next actions. |
90
- | `noodle events` | The per-request MCP event stream with status/tool/client filters; `--session <id>` replays one session in order. Agents: add `--json` and filter (`--status tool_error|mcp_error`) when debugging. |
91
- | `noodle alerts` | Analytics alert rules (`add|list|remove|test`): an edge-triggered webhook fires when error share, error count, calls, or p95 latency breaches. Webhook URLs are stored server-side and shown redacted. |
90
+ | `noodle events` | The per-request MCP event stream with status/tool/client filters; `--session <id>` replays one session in order. Agents: add `--json` and filter (`--status tool_error\|mcp_error`) when debugging. |
91
+ | `noodle alerts` | Analytics alert rules (`add\|list\|remove\|test`): an edge-triggered webhook fires when error share, error count, calls, or p95 latency breaches. Webhook URLs are stored server-side and shown redacted. |
92
92
  | `noodle policy` | Manage policy (status/list/show/effective/simulate/suspend/quota/rate/...). |
93
93
 
94
94
  ## CLI maintenance
@@ -3,12 +3,40 @@
3
3
  ## Contents
4
4
 
5
5
  - The repair loop
6
+ - JSON shape
7
+ - Fix prompt
6
8
  - Error codes
7
9
 
8
10
  ## The repair loop
9
11
 
10
12
  Run `noodle validate` (add `--json` for machine-readable output, `--fix-prompt` for an agent repair prompt). Each error carries a `code`, a dotted `path` to the offending field, and a `message`; many also carry `expected`/`got`, `didYouMean`/`suggestions`, and a `docAnchor`. Fix the specific error the `path` locates, then re-validate. Do not freeform re-edit. Once `noodle validate` passes, run `noodle test`, then `noodle dev`.
11
13
 
14
+ ## JSON shape
15
+
16
+ Use `noodle validate --json` in automated repair loops. Treat `errors[]` as the work queue and change only the cited file/path before re-running validation.
17
+
18
+ ```json
19
+ {
20
+ "ok": false,
21
+ "errors": [
22
+ {
23
+ "code": "unknown_operation",
24
+ "path": "tools.search.fulfil.steps.0.operation",
25
+ "message": "Unknown connector operation.",
26
+ "expected": "operation declared on connector alias `crm`",
27
+ "got": "crm.find_customer",
28
+ "didYouMean": "crm.findCustomer",
29
+ "suggestions": ["crm.findCustomer"],
30
+ "docAnchor": "connectors.operations"
31
+ }
32
+ ]
33
+ }
34
+ ```
35
+
36
+ ## Fix prompt
37
+
38
+ `noodle validate --fix-prompt` prints a compact agent repair prompt with the same structured errors. Use it when delegating a repair pass, but still inspect the resulting code and re-run `noodle validate --json`.
39
+
12
40
  ## Error codes
13
41
 
14
42
  | Code | Fix |
@@ -8,6 +8,7 @@
8
8
  - Access modes
9
9
  - Org and members
10
10
  - Config and observability
11
+ - Agent-safe CLI recipes
11
12
 
12
13
  ## Authenticate
13
14
 
@@ -33,6 +34,26 @@
33
34
 
34
35
  Manage runtime config with `noodle secrets` / `noodle variables` (scoped org/app/env). Operators use `noodle logs`, `noodle audit`, and `noodle policy` for logs, governance audit, and policy.
35
36
 
37
+ ## Agent-safe CLI recipes
38
+
39
+ Use explicit flags in headless runs so commands never wait for a prompt:
40
+
41
+ ```sh
42
+ noodle link --org acme --app support-assistant --env prod
43
+ noodle secrets set CRM_TOKEN --scope env --org acme --app support-assistant --env prod --from-env CRM_TOKEN
44
+ noodle secrets set CRM_CERT --scope env --org acme --app support-assistant --env prod --from-file ./cert.pem
45
+ printf %s "$CRM_TOKEN" | noodle secrets set CRM_TOKEN --scope env --org acme --app support-assistant --env prod --from-stdin
46
+ noodle variables set CRM_BASE_URL --scope env --org acme --app support-assistant --env prod --value https://crm.example.com
47
+ noodle secrets list --scope env --org acme --app support-assistant --env prod --json
48
+ noodle validate --json
49
+ noodle test --json
50
+ noodle deploy --json
51
+ noodle smoke --json
52
+ noodle agents doctor --json
53
+ ```
54
+
55
+ `secrets resolve` is for local diagnostics only; do not print resolved values into prompts, logs, tests, or docs. Prefer `--from-env`, `--from-file`, or `--from-stdin` over inline `--value` for sensitive values. Variables may use `--value` when the value is non-secret.
56
+
36
57
  ## Analytics (verify after deploy, debug errors)
37
58
 
38
- After a deploy gets traffic, verify with `noodle metrics --agent-output` — it returns a `health` verdict (`ok`/`attention`), a one-line summary, and `attention[]` items each carrying the exact next command. When a tool errors, drill in with `noodle events --tool <name> --json` (filters: `--status tool_error|mcp_error`, `--client <name>`); `noodle events --session <id> --json` replays one session chronologically. `--json` on both returns the full payload; human runs get the branded report. Two-tier errors: `tool_error` is recoverable (handed back to the model), `mcp_error` needs attention (protocol/timeout/internal).
59
+ After a deploy gets traffic, verify with `noodle metrics --agent-output` — it returns a `health` verdict (`ok`/`attention`), a one-line summary, and `attention[]` items each carrying the exact next command. When a tool errors, drill in with `noodle events --tool <name> --json` (filters: `--status tool_error|mcp_error`, `--client <name>`); `noodle events --session <id> --json` replays one session chronologically. `--json` on both returns the full payload; human runs get the branded report. Two-tier errors: `tool_error` is recoverable (handed back to the model), `mcp_error` needs attention (protocol/timeout/internal). Wire edge-triggered webhooks on error share, error count, calls, or p95 latency with `noodle alerts add|list|remove|test`.
@@ -10,7 +10,10 @@ Flagship examples (one per capability). Read the matching example for the patter
10
10
  | `customer-auth` | End-user (customer) auth via OIDC/Firebase bridge with delegated credentials. |
11
11
  | `stateful-draft` | Durable, caller-scoped widget state handles with optimistic revisions. |
12
12
  | `perplexity` | A real SaaS API with bearer auth and a managed `secret`. |
13
+ | `bitcoin` | API-key HTTP connector, custom auth header, and compute normalization. |
14
+ | `sharepoint` | Microsoft SharePoint delegated Microsoft Entra auth and Graph tools. |
13
15
  | `internal-ops-demo` | Governed internal connectivity — tools/resources/prompts, role-shaped output. |
16
+ | `docs-assistant` | Docs/knowledge assistant grounding coding agents in the live docs export. |
14
17
 
15
18
  ## Canonical server.ts
16
19
 
@@ -0,0 +1,31 @@
1
+ # Publish to app directories
2
+
3
+ Directory requirements evolve — treat this as the workflow map and verify against the host’s current submission docs before submitting.
4
+
5
+ ## Contents
6
+
7
+ - Readiness gate
8
+ - ChatGPT apps directory
9
+ - Claude connectors directory
10
+
11
+ ## Readiness gate
12
+
13
+ Before any submission:
14
+
15
+ 1. `noodle check --target chatgpt` must be clean — every widget needs `domain` (one https origin per app) and an exact `csp` (hosts require the CSP to list precisely the domains you fetch from).
16
+ 2. Audit tool responses in developer mode: run realistic prompts and strip anything not strictly needed — PII, internal identifiers (session/trace/request IDs, internal account IDs), and any secrets.
17
+ 3. The server must be deployed and publicly reachable: `noodle deploy`, confirm with `noodle open --print` and `noodle smoke`. Reviewers connect to the real endpoint — never submit a placeholder or loopback URL, and the access mode must not be `owner-only` (`noodle access set`).
18
+ 4. Polish the listing surface: tool descriptions, widget titles, and the `server` branding tokens are what reviewers and users see.
19
+
20
+ ## ChatGPT apps directory
21
+
22
+ Submit from the OpenAI developer dashboard (platform.openai.com → Apps):
23
+
24
+ - Complete organization identity verification first (individual or business) — it is enforced at review time.
25
+ - The submission form asks for the app name, logo, description, company and privacy policy URLs, MCP server URL and tool information, screenshots, test prompts with expected responses, and localization details.
26
+ - One version may be published and one in review at a time; to revise a pending submission, cancel the review and resubmit rather than creating a new app.
27
+ - Review combines automated checks and manual evaluation; rejections come with feedback — fix and resubmit, or reply to appeal. An approved app is also distributed as a Codex plugin.
28
+
29
+ ## Claude connectors directory
30
+
31
+ Anthropic runs a connectors directory for Claude; submission goes through Anthropic’s published process (see the Anthropic connectors directory FAQ on support.claude.com). The same readiness gate applies: deployed public endpoint, clean `noodle check`, and graceful degradation where Apps rendering is unavailable.
@@ -1,6 +1,7 @@
1
1
  # @noodleseed/one SDK surface
2
2
 
3
- Import these from `@noodleseed/one`. They are declarative builders that emit manifest data — do not hand-author the manifest or runtime artifacts. React view helpers come from `@noodleseed/one/react` (`generateHelpers`).
3
+ Import these from `@noodleseed/one`. They are declarative builders that emit manifest data — do not hand-author the manifest or runtime artifacts. React view helpers come from `@noodleseed/one/react` (`generateHelpers`); the hook surface is documented in `widgets-and-apps.md`.
4
+ Platform helper connectors are explicit subpath imports from `@noodleseed/one/platform` (`noodlePlatform`, `noodlePlatformCatalog`) when an app needs first-party hosted state APIs.
4
5
 
5
6
  ## Server & tools
6
7
 
@@ -30,10 +31,25 @@ Import these from `@noodleseed/one`. They are declarative builders that emit man
30
31
  - `secret("NAME")` — reference a managed secret (operated via `noodle secrets`).
31
32
  - `variable("NAME")` — reference a managed variable (operated via `noodle variables`).
32
33
 
34
+ ## Customer auth
35
+
36
+ - `customerAuth.oidc(...)`, `.firebase(...)`, `.microsoft(...)`, or `.bridge(...)` — end-user/customer identity for `--access customers` deployments.
37
+
33
38
  ## Sessions
34
39
 
35
40
  - `handoffSession(...)` — typed cross-host handoff session envelopes.
36
41
 
37
42
  ## Schemas
38
43
 
39
- - `z` — Zod, for input/output schemas (compiles to JSON Schema 2020-12).
44
+ - `z` — Zod, for input/output schemas (compiles to JSON Schema 2020-12).
45
+
46
+ ## Authoring signatures
47
+
48
+ - `server(name, options, definitions)` — `options` commonly includes `title`, `version`, `instructions`, `branding`, `auth`, `use`, `provides`, `state`, and `handoff`; `definitions` is the array of tools/resources/prompts/widgets.
49
+ - `tool(name, { description, input, output, annotations?, fulfil })` — `input`/`output` are Zod schemas; `fulfil({ input, connectors, user })` returns data matching `output`.
50
+ - `toolWithWidget(name, { description, input, output, fulfil, view })` — same as `tool`, plus `view: { component, entry }` for a React widget.
51
+ - `toolForWidget(name, { input, output, fulfil })` — helper tool for widget actions; hidden from the model.
52
+ - `resource(name, { uri, description?, mimeType?, fulfil })` and `prompt(name, { description?, arguments?, fulfil })` expose MCP resources/prompts.
53
+ - `widget(name, { title, view, csp?, domain?, permissions? })` declares reusable view metadata; `asset("./path")` packages local files.
54
+ - `customerAuth.*(...)` belongs in `server` options when deployed customer callers need verified identity; inspect `examples/customer-auth` or `examples/sharepoint` before using it.
55
+ - `state` defines durable widget state handles; `handoff` declares allowed external domains for safe host handoff.
@@ -0,0 +1,39 @@
1
+ # Test in real hosts
2
+
3
+ Local `noodle dev` and `noodle devtools` prove the server works; the widget experience is only proven inside a real host. `noodle connect <client>` prints the exact setup flow per host.
4
+
5
+ ## Contents
6
+
7
+ - Local inspection first
8
+ - Agent hosts (Claude Code, Codex, editors)
9
+ - ChatGPT (developer mode)
10
+ - Claude
11
+ - Public URL for a local server
12
+ - What to verify
13
+
14
+ ## Local inspection first
15
+
16
+ Run `noodle dev` and inspect the loopback endpoint with MCP Inspector: `noodle connect inspector` prints the flow (`npx @modelcontextprotocol/inspector <printed endpoint>`). Preview widget metadata and rendering with `noodle devtools`.
17
+
18
+ ## Agent hosts (Claude Code, Codex, editors)
19
+
20
+ `noodle connect claude-code` / `noodle connect codex` (add `--write` for project-local setup). For other editors (`cursor`, `vscode`, `gemini`), `noodle connect <client>` prints the setup steps, and `noodle docs export --format llms` produces portable context. With a deployed endpoint, `noodle connect <client> --endpoint <url>` prints the MCP client registration config.
21
+
22
+ ## ChatGPT (developer mode)
23
+
24
+ 1. Deploy: `noodle deploy`, then `noodle open --print` for the hosted MCP URL (ChatGPT needs a public HTTPS endpoint, not loopback).
25
+ 2. In ChatGPT: Settings → Connectors → enable Developer mode → add the endpoint (`noodle connect chatgpt` prints these steps).
26
+ 3. Toggle the connector on in a new conversation and sign in when prompted; testers outside your org need a wider access mode (`noodle access set`).
27
+ 4. Test on mobile too — invoke the same connector from the ChatGPT iOS/Android apps to check widget layout.
28
+
29
+ ## Claude
30
+
31
+ `noodle connect claude` prints the flow: deploy, then add the hosted MCP URL as a custom connector in Claude settings and sign in when prompted. Widgets render in Apps-capable Claude surfaces; elsewhere the tool’s text/structured result is shown.
32
+
33
+ ## Public URL for a local server
34
+
35
+ To try an undeployed server in a host that requires a public URL, `noodle dev --tunnel` publishes a temporary public URL for the loopback endpoint (requires the external `cloudflared` binary on PATH). Treat it as a short-lived test URL — deploy for anything shared.
36
+
37
+ ## What to verify
38
+
39
+ Run a golden prompt set — direct (“use <tool> to…”), indirect (a natural request the model should route), and negative (requests that must not trigger the tool). Confirm the model picks the right tool with the right arguments, the widget renders and its actions work, external links open, and the experience degrades to readable text where Apps are unsupported. Symptoms → `references/troubleshooting.md`.
@@ -0,0 +1,29 @@
1
+ # Troubleshooting in hosts
2
+
3
+ ## Contents
4
+
5
+ - First moves
6
+ - Symptom map
7
+
8
+ ## First moves
9
+
10
+ Re-run the local gates before debugging in-host: `noodle validate`, `noodle check` (add `--target chatgpt` for ChatGPT-specific requirements), and `noodle doctor`. Confirm the CLI is current with `noodle update --check` and that the project-local skill is intact with `noodle agents doctor --json` — host metadata requirements evolve and fixes ship in the CLI/agent-kit. Never paste tokens, secrets, or `.env.noodle` values into prompts or logs while debugging.
11
+
12
+ For protocol/conformance checks, the headless harness is `@mcpjam/cli`, not a `noodle` subcommand. Use it against a local `noodle dev` URL without an access token, or against hosted URLs through the host/OAuth flow printed by `noodle connect`.
13
+
14
+ ## Symptom map
15
+
16
+ | Symptom | Likely cause | Fix |
17
+ | :-- | :-- | :-- |
18
+ | Images, fonts, or styles don’t load inside the widget | The host sandbox silently blocks origins not declared in the widget CSP | Add every asset origin to `csp: { resourceDomains: [...] }` (fetch/XHR origins go in `connectDomains`, embedded iframes in `frameDomains`), then re-run `noodle check --target chatgpt` |
19
+ | ChatGPT warns “Widget CSP is not set” | The widget declares no `csp` | Declare `csp` on the widget with the exact origins it uses |
20
+ | ChatGPT warns “Widget domain is not set” | No `domain` on the widget (required for app-store submission) | Set `domain: "https://…"` (one https origin per app) on each widget |
21
+ | External links do nothing, or show a safe-link warning | Link opened outside the host bridge, or the target origin is not allowlisted | Use `useOpenExternal()` (never `window.open`) and add the target origins to the server-level `handoff.allowedDomains` |
22
+ | Tool succeeds but no widget appears | The tool has no view, or the host surface doesn’t support MCP Apps | Use `toolWithWidget`, run `noodle check`, preview with `noodle devtools`; on non-Apps surfaces only the text/structured result renders |
23
+ | Widget shows stale or missing data | The widget reads `structuredContent`, which must match the `output` schema | Make `fulfil` return exactly the `output` shape (arrays and nested objects are supported); inspect the live result with `noodle devtools` |
24
+ | `useCallTool` fails from the widget | Tool name mismatch, or the helper tool is model-visible | List names with `noodle tools`; widget-only helpers must be declared with `toolForWidget` |
25
+ | `noodle validate` passes but React views fail to bundle (“requires Vite”) | Project dependencies are not installed — widget bundling uses the app-local Vite | Run the project’s package install, then retry `noodle dev` / `noodle deploy` |
26
+ | Hosted endpoint returns 401 to probes | Expected: hosted servers challenge unauthenticated calls with OAuth metadata | Sign in from the host when prompted; widen who may call with `noodle access set` if testers are outside the org |
27
+ | Tools error only after deploy | Runtime/config differences surface hosted (secrets, connector reachability) | Run `noodle smoke`, then `noodle metrics --agent-output` and `noodle events --tool <name> --status tool_error --json`; check `noodle secrets list` scope |
28
+ | Need to invoke a deployed tool from the terminal | The `noodle` CLI is not a general MCP client and has no `call` verb | Use `noodle test` for the local smoke, `noodle tools`/`resources`/`prompts` for local listing, MCP Inspector, or `npx @mcpjam/cli@latest tools call --url <url> ...` for headless MCP probing |
29
+ | One customer/session reports a bad answer or protocol error | The failure may be a model/tool error, host protocol error, or connector/runtime error | Run `noodle metrics --agent-output`, then `noodle events --tool <name> --status tool_error --json`; copy the `sessionId` into `noodle events --session <id> --json`, then match timestamps with `noodle logs` |
@@ -4,7 +4,10 @@
4
4
 
5
5
  - Tools and views
6
6
  - React authoring
7
- - CSP and permissions
7
+ - React hook surface
8
+ - Shaping tool output for widgets
9
+ - Widget state and model context
10
+ - CSP, domain, and permissions
8
11
  - Host bridge
9
12
  - Readiness and boundaries
10
13
 
@@ -18,15 +21,39 @@ Author views as React components. Get typed helpers from `@noodleseed/one/react`
18
21
 
19
22
  ```ts
20
23
  import { generateHelpers } from '@noodleseed/one/react';
21
- const { useCallTool, useLayout, useToolInfo, useViewState } = generateHelpers<AppType>();
24
+ const { useToolInfo, useCallTool, useViewState, useLayout, useOpenExternal, useSendFollowUpMessage } =
25
+ generateHelpers<AppType>();
22
26
  ```
23
27
 
24
28
  Bind interactive elements to tools (`useCallTool("place_order")`) and annotate model-facing context with `data-llm`. A raw `html` escape hatch exists for self-contained widgets (declarative `data-bind`/`data-action`; no inline `<script>`).
25
29
 
26
- ## CSP and permissions
30
+ ## React hook surface
31
+
32
+ | Hook | Use for |
33
+ | :-- | :-- |
34
+ | `useToolInfo` | Read the invoking tool result; `structuredContent` is the widget’s typed data payload. |
35
+ | `useCallTool` | Call a tool from the widget — returns `{ callTool, data, error, isPending }`; target a model-visible tool or a hidden `toolForWidget` helper. |
36
+ | `useViewState` | Persist per-widget UI state across re-renders and restores: `const [value, setValue] = useViewState("key", initial)`. |
37
+ | `useLayout` | Read host layout: `{ theme, displayMode, locale? }` (`theme` is `"light"`/`"dark"`, `displayMode` is `"inline"`/`"fullscreen"`) — adapt styling to the host theme and mode. |
38
+ | `useOpenExternal` | Open an external link through the host (never `window.open`); the target origin must be listed in the server-level `handoff.allowedDomains`. |
39
+ | `useSendFollowUpMessage` | Send a follow-up prompt to the model from a user interaction: `send({ prompt })` — trigger only from an explicit user action. |
40
+
41
+ Adapt to the host with `useLayout()` — style for both `theme` values, and keep the inline `displayMode` compact (content fits the space; no internal scrolling). Trigger `useOpenExternal()` and `useSendFollowUpMessage()` only from explicit user actions.
42
+
43
+ ## Shaping tool output for widgets
44
+
45
+ The widget reads the tool result’s `structuredContent`, typed by the tool’s `output` schema — arrays and nested objects are fully supported, so model the data naturally (`z.array(z.object({ ... }))`) instead of flattening. Keep the result’s `content` useful on its own: hosts without MCP Apps support show only the text/structured result, so the tool must degrade gracefully.
46
+
47
+ ## Widget state and model context
48
+
49
+ Persist UI state (selections, drafts, pagination) with `useViewState("key", initial)` — it survives re-renders and conversation restores. For durable, caller-scoped state handles with optimistic revisions, follow the `stateful-draft` example. Mark the DOM the model should see with `data-llm` attributes; everything else stays widget-only.
50
+
51
+ ## CSP, domain, and permissions
27
52
 
28
53
  Declare network/host needs explicitly: `csp: { connectDomains, resourceDomains, frameDomains }` and `permissions` (e.g. `clipboardWrite`). Secrets are never injected into widgets; tool output is redacted before widget delivery.
29
54
 
55
+ For ChatGPT: set `domain` on each widget (one https origin per app; required for app-store submission, optional for dev-mode testing), and declare external-link targets in the server-level `handoff.allowedDomains` — the compiler derives ChatGPT’s `redirect_domains` from it so `useOpenExternal()` links open without the safe-link warning. `noodle check --target chatgpt` verifies all of this.
56
+
30
57
  ## Host bridge
31
58
 
32
59
  One runtime targets both Claude’s ext-apps bridge and ChatGPT’s `window.openai`, detected at startup. Tool results still carry useful `content`/`structuredContent` so non-Apps hosts degrade gracefully.