@ggui-ai/protocol 0.1.0-rc.1
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/LICENSE +201 -0
- package/README.md +46 -0
- package/dist/bridge/invoke-agent.d.ts +65 -0
- package/dist/bridge/invoke-agent.d.ts.map +1 -0
- package/dist/bridge/invoke-agent.js +113 -0
- package/dist/envelope-adapters.d.ts +24 -0
- package/dist/envelope-adapters.d.ts.map +1 -0
- package/dist/envelope-adapters.js +14 -0
- package/dist/envelopes/builders.d.ts +145 -0
- package/dist/envelopes/builders.d.ts.map +1 -0
- package/dist/envelopes/builders.js +113 -0
- package/dist/errors/unknown-permission-name.d.ts +12 -0
- package/dist/errors/unknown-permission-name.d.ts.map +1 -0
- package/dist/errors/unknown-permission-name.js +29 -0
- package/dist/errors/version-mismatch.d.ts +55 -0
- package/dist/errors/version-mismatch.d.ts.map +1 -0
- package/dist/errors/version-mismatch.js +52 -0
- package/dist/gadgets/resolve-contract-gadgets.d.ts +93 -0
- package/dist/gadgets/resolve-contract-gadgets.d.ts.map +1 -0
- package/dist/gadgets/resolve-contract-gadgets.js +119 -0
- package/dist/gadgets/stdlib-gadgets.d.ts +43 -0
- package/dist/gadgets/stdlib-gadgets.d.ts.map +1 -0
- package/dist/gadgets/stdlib-gadgets.js +161 -0
- package/dist/iframe-bridge.d.ts +63 -0
- package/dist/iframe-bridge.d.ts.map +1 -0
- package/dist/iframe-bridge.js +166 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +79 -0
- package/dist/integrations/mcp-apps.d.ts +1218 -0
- package/dist/integrations/mcp-apps.d.ts.map +1 -0
- package/dist/integrations/mcp-apps.js +427 -0
- package/dist/navigation/index.d.ts +3 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/stack-navigation.d.ts +55 -0
- package/dist/navigation/stack-navigation.d.ts.map +1 -0
- package/dist/navigation/stack-navigation.js +80 -0
- package/dist/recommended-prompts.d.ts +56 -0
- package/dist/recommended-prompts.d.ts.map +1 -0
- package/dist/recommended-prompts.js +55 -0
- package/dist/registry/blueprint-key.d.ts +9 -0
- package/dist/registry/blueprint-key.d.ts.map +1 -0
- package/dist/registry/blueprint-key.js +28 -0
- package/dist/registry/canonicalize-contract.d.ts +35 -0
- package/dist/registry/canonicalize-contract.d.ts.map +1 -0
- package/dist/registry/canonicalize-contract.js +166 -0
- package/dist/registry/summarize-contract.d.ts +46 -0
- package/dist/registry/summarize-contract.d.ts.map +1 -0
- package/dist/registry/summarize-contract.js +63 -0
- package/dist/schema-learning/derive-contract.d.ts +67 -0
- package/dist/schema-learning/derive-contract.d.ts.map +1 -0
- package/dist/schema-learning/derive-contract.js +117 -0
- package/dist/schema-learning/merge.d.ts +32 -0
- package/dist/schema-learning/merge.d.ts.map +1 -0
- package/dist/schema-learning/merge.js +146 -0
- package/dist/schemas/blueprint.d.ts +32 -0
- package/dist/schemas/blueprint.d.ts.map +1 -0
- package/dist/schemas/blueprint.js +92 -0
- package/dist/schemas/data-contract.d.ts +750 -0
- package/dist/schemas/data-contract.d.ts.map +1 -0
- package/dist/schemas/data-contract.js +663 -0
- package/dist/schemas/gadget-name-grammar.d.ts +29 -0
- package/dist/schemas/gadget-name-grammar.d.ts.map +1 -0
- package/dist/schemas/gadget-name-grammar.js +28 -0
- package/dist/schemas/handshake-suggestion.d.ts +46 -0
- package/dist/schemas/handshake-suggestion.d.ts.map +1 -0
- package/dist/schemas/handshake-suggestion.js +107 -0
- package/dist/schemas/invoke.d.ts +337 -0
- package/dist/schemas/invoke.d.ts.map +1 -0
- package/dist/schemas/invoke.js +169 -0
- package/dist/schemas/mcp.d.ts +301 -0
- package/dist/schemas/mcp.d.ts.map +1 -0
- package/dist/schemas/mcp.js +373 -0
- package/dist/schemas/ops-blueprint.d.ts +176 -0
- package/dist/schemas/ops-blueprint.d.ts.map +1 -0
- package/dist/schemas/ops-blueprint.js +259 -0
- package/dist/schemas/sync-check.d.ts +11 -0
- package/dist/schemas/sync-check.d.ts.map +1 -0
- package/dist/schemas/sync-check.js +60 -0
- package/dist/screen-blueprints/define.d.ts +22 -0
- package/dist/screen-blueprints/define.d.ts.map +1 -0
- package/dist/screen-blueprints/define.js +3 -0
- package/dist/screen-blueprints/index.d.ts +4 -0
- package/dist/screen-blueprints/index.d.ts.map +1 -0
- package/dist/screen-blueprints/index.js +3 -0
- package/dist/screen-blueprints/match.d.ts +35 -0
- package/dist/screen-blueprints/match.d.ts.map +1 -0
- package/dist/screen-blueprints/match.js +51 -0
- package/dist/screen-blueprints/types.d.ts +164 -0
- package/dist/screen-blueprints/types.d.ts.map +1 -0
- package/dist/screen-blueprints/types.js +1 -0
- package/dist/stream/stream-parser.d.ts +62 -0
- package/dist/stream/stream-parser.d.ts.map +1 -0
- package/dist/stream/stream-parser.js +199 -0
- package/dist/transport/websocket.d.ts +178 -0
- package/dist/transport/websocket.d.ts.map +1 -0
- package/dist/transport/websocket.js +1 -0
- package/dist/types/app-config.d.ts +61 -0
- package/dist/types/app-config.d.ts.map +1 -0
- package/dist/types/app-config.js +1 -0
- package/dist/types/auth.d.ts +61 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +1 -0
- package/dist/types/blueprint.d.ts +206 -0
- package/dist/types/blueprint.d.ts.map +1 -0
- package/dist/types/blueprint.js +1 -0
- package/dist/types/canvas-lifecycle.d.ts +105 -0
- package/dist/types/canvas-lifecycle.d.ts.map +1 -0
- package/dist/types/canvas-lifecycle.js +38 -0
- package/dist/types/capabilities.d.ts +40 -0
- package/dist/types/capabilities.d.ts.map +1 -0
- package/dist/types/capabilities.js +19 -0
- package/dist/types/contract-inference.d.ts +401 -0
- package/dist/types/contract-inference.d.ts.map +1 -0
- package/dist/types/contract-inference.js +44 -0
- package/dist/types/credential.d.ts +41 -0
- package/dist/types/credential.d.ts.map +1 -0
- package/dist/types/credential.js +32 -0
- package/dist/types/data-bindings.d.ts +322 -0
- package/dist/types/data-bindings.d.ts.map +1 -0
- package/dist/types/data-bindings.js +29 -0
- package/dist/types/data-contract.d.ts +1296 -0
- package/dist/types/data-contract.d.ts.map +1 -0
- package/dist/types/data-contract.js +111 -0
- package/dist/types/events.d.ts +182 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +8 -0
- package/dist/types/feedback.d.ts +24 -0
- package/dist/types/feedback.d.ts.map +1 -0
- package/dist/types/feedback.js +7 -0
- package/dist/types/gadget.d.ts +121 -0
- package/dist/types/gadget.d.ts.map +1 -0
- package/dist/types/gadget.js +24 -0
- package/dist/types/handshake-suggestion.d.ts +264 -0
- package/dist/types/handshake-suggestion.d.ts.map +1 -0
- package/dist/types/handshake-suggestion.js +70 -0
- package/dist/types/host-context.d.ts +163 -0
- package/dist/types/host-context.d.ts.map +1 -0
- package/dist/types/host-context.js +142 -0
- package/dist/types/interface-context.d.ts +105 -0
- package/dist/types/interface-context.d.ts.map +1 -0
- package/dist/types/interface-context.js +115 -0
- package/dist/types/invoke.d.ts +28 -0
- package/dist/types/invoke.d.ts.map +1 -0
- package/dist/types/invoke.js +7 -0
- package/dist/types/live-channel.d.ts +613 -0
- package/dist/types/live-channel.d.ts.map +1 -0
- package/dist/types/live-channel.js +1 -0
- package/dist/types/llm.d.ts +61 -0
- package/dist/types/llm.d.ts.map +1 -0
- package/dist/types/llm.js +186 -0
- package/dist/types/mcp-proxy.d.ts +67 -0
- package/dist/types/mcp-proxy.d.ts.map +1 -0
- package/dist/types/mcp-proxy.js +46 -0
- package/dist/types/mcp.d.ts +637 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +30 -0
- package/dist/types/openrouter-models.d.ts +22 -0
- package/dist/types/openrouter-models.d.ts.map +1 -0
- package/dist/types/openrouter-models.js +4843 -0
- package/dist/types/region.d.ts +26 -0
- package/dist/types/region.d.ts.map +1 -0
- package/dist/types/region.js +36 -0
- package/dist/types/session.d.ts +419 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +1 -0
- package/dist/types/thread.d.ts +207 -0
- package/dist/types/thread.d.ts.map +1 -0
- package/dist/types/thread.js +57 -0
- package/dist/types/ui-generator.d.ts +100 -0
- package/dist/types/ui-generator.d.ts.map +1 -0
- package/dist/types/ui-generator.js +53 -0
- package/dist/validation/ajv-runtime.d.ts +140 -0
- package/dist/validation/ajv-runtime.d.ts.map +1 -0
- package/dist/validation/ajv-runtime.js +452 -0
- package/dist/validation/content-hash.d.ts +3 -0
- package/dist/validation/content-hash.d.ts.map +1 -0
- package/dist/validation/content-hash.js +21 -0
- package/dist/validation/contract-validator.d.ts +244 -0
- package/dist/validation/contract-validator.d.ts.map +1 -0
- package/dist/validation/contract-validator.js +711 -0
- package/dist/validation/cross-references.d.ts +105 -0
- package/dist/validation/cross-references.d.ts.map +1 -0
- package/dist/validation/cross-references.js +164 -0
- package/dist/validation/hygiene-rules.d.ts +250 -0
- package/dist/validation/hygiene-rules.d.ts.map +1 -0
- package/dist/validation/hygiene-rules.js +564 -0
- package/dist/validation/lint-contract.d.ts +130 -0
- package/dist/validation/lint-contract.d.ts.map +1 -0
- package/dist/validation/lint-contract.js +225 -0
- package/dist/validation/name-invariants.d.ts +117 -0
- package/dist/validation/name-invariants.d.ts.map +1 -0
- package/dist/validation/name-invariants.js +172 -0
- package/dist/validation/reserved-channels.d.ts +156 -0
- package/dist/validation/reserved-channels.d.ts.map +1 -0
- package/dist/validation/reserved-channels.js +356 -0
- package/dist/validation/resolve-stream-channel.d.ts +78 -0
- package/dist/validation/resolve-stream-channel.d.ts.map +1 -0
- package/dist/validation/resolve-stream-channel.js +64 -0
- package/dist/validation/sanitize-error.d.ts +46 -0
- package/dist/validation/sanitize-error.d.ts.map +1 -0
- package/dist/validation/sanitize-error.js +88 -0
- package/dist/validation/schema-compat-invariants.d.ts +140 -0
- package/dist/validation/schema-compat-invariants.d.ts.map +1 -0
- package/dist/validation/schema-compat-invariants.js +220 -0
- package/dist/validation/schema-meta-validation.d.ts +60 -0
- package/dist/validation/schema-meta-validation.d.ts.map +1 -0
- package/dist/validation/schema-meta-validation.js +131 -0
- package/dist/validation/schema-subset.d.ts +165 -0
- package/dist/validation/schema-subset.d.ts.map +1 -0
- package/dist/validation/schema-subset.js +295 -0
- package/dist/validation/ui-security.d.ts +54 -0
- package/dist/validation/ui-security.d.ts.map +1 -0
- package/dist/validation/ui-security.js +138 -0
- package/dist/validation/zod-to-json-schema.d.ts +63 -0
- package/dist/validation/zod-to-json-schema.d.ts.map +1 -0
- package/dist/validation/zod-to-json-schema.js +126 -0
- package/dist/version.d.ts +1458 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +1459 -0
- package/package.json +113 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-apps.d.ts","sourceRoot":"","sources":["../../src/integrations/mcp-apps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACV,MAAM,2BAA2B,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAG,4BAAqC,CAAC;AAE5E;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAG,mBAA4B,CAAC;AAEtE;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,EAAG,2BAAoC,CAAC;AAE/E;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;IAC5B,gFAAgF;;IAEhF,kEAAkE;;CAE1D,CAAC;AAEX;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,KAAK,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG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AQ,CAAC,IAAI,EAAE;YAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;SAAE,CAAC;KACjD,CAAC;CACH;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,uCAAuC;IACvC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,kDAAkD;IAClD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,UAAU,EAAE,SAAS,GAAG,IAAI,CAAC;QACtC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;KAChC,CAAC;IACF;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,kBAAkB,CA6C5B"}
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Apps integration — outbound delivery types for ggui.
|
|
3
|
+
*
|
|
4
|
+
* This module is the **boundary** for MCP Apps outbound delivery. Anything
|
|
5
|
+
* MCP-Apps-specific that ggui exposes to the rest of the codebase lives
|
|
6
|
+
* here — never in `types/live-channel.ts`, `types/mcp.ts`, `types/session.ts`,
|
|
7
|
+
* or any other core module. Consumers opt in via the subpath import:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import {
|
|
11
|
+
* MCP_APPS_UI_CAPABILITY,
|
|
12
|
+
* GGUI_SESSION_RESOURCE_URI,
|
|
13
|
+
* type GguiBootstrapMeta,
|
|
14
|
+
* } from '@ggui-ai/protocol/integrations/mcp-apps';
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* The root `@ggui-ai/protocol` barrel does NOT re-export this module.
|
|
18
|
+
* That's the isolation rule: core protocol consumers that don't integrate
|
|
19
|
+
* with MCP Apps pay none of its weight, and the blast radius of any spec
|
|
20
|
+
* drift is bounded to callers that explicitly import from here.
|
|
21
|
+
*
|
|
22
|
+
* Core still carries two fields that make the bootstrap flow work —
|
|
23
|
+
* `SubscribePayload.bootstrap?: string` and `AckPayload.sessionToken?:
|
|
24
|
+
* string`. Those are deliberately framed as **general transport bootstrap
|
|
25
|
+
* credentials** (opaque strings), not MCP-Apps-specific. Any future
|
|
26
|
+
* bootstrap mechanism (short-code auto-login, signed-URL bootstrap, etc.)
|
|
27
|
+
* reuses the same slots.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* MCP capability name ggui servers advertise in their MCP `initialize`
|
|
31
|
+
* response capabilities when they implement the MCP Apps outbound path.
|
|
32
|
+
* Spec-canonical; MUST match the string the MCP Apps protocol publishes.
|
|
33
|
+
*/
|
|
34
|
+
export const MCP_APPS_UI_CAPABILITY = 'io.modelcontextprotocol/ui';
|
|
35
|
+
/**
|
|
36
|
+
* The single MCP Apps resource URI ggui exposes for outbound delivery.
|
|
37
|
+
* `ggui_push` is the sole tool declaration that carries this in its
|
|
38
|
+
* `_meta.ui.resourceUri`. No other ggui tool gets a resource URI —
|
|
39
|
+
* `ggui_push` is the single outbound entry point.
|
|
40
|
+
*/
|
|
41
|
+
export const GGUI_SESSION_RESOURCE_URI = 'ui://ggui/session';
|
|
42
|
+
/**
|
|
43
|
+
* MIME type for the `ui://ggui/session` resource. Per MCP Apps spec, UI
|
|
44
|
+
* resources carry the `text/html` base type with a `profile=mcp-app`
|
|
45
|
+
* parameter so hosts that don't support MCP Apps don't accidentally
|
|
46
|
+
* render them as plain HTML.
|
|
47
|
+
*/
|
|
48
|
+
export const GGUI_SESSION_RESOURCE_MIME = 'text/html;profile=mcp-app';
|
|
49
|
+
/**
|
|
50
|
+
* The single `_meta.ui.resourceUri` value ggui uses across every MCP Apps
|
|
51
|
+
* host surface. Exposed as a named constant so tool-declaration code,
|
|
52
|
+
* resource-serving code, and tests all agree on one spelling.
|
|
53
|
+
*/
|
|
54
|
+
export const GGUI_PUSH_UI_META = {
|
|
55
|
+
/** Resource URI hosts fetch via `resources/read` on a `ggui_push` tool call. */
|
|
56
|
+
resourceUri: GGUI_SESSION_RESOURCE_URI,
|
|
57
|
+
/** Only `"model"` — outer agent can call, iframe views cannot. */
|
|
58
|
+
visibility: ['model'],
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Derives the PascalCase Context name from a contextSpec slot key.
|
|
62
|
+
* E.g., `currentStep` → `CurrentStepContext`. Consumed by the server
|
|
63
|
+
* (when populating bootstrap.contextSlots) and the iframe-runtime
|
|
64
|
+
* boilerplate (when generating destructuring lines).
|
|
65
|
+
*
|
|
66
|
+
* Edge cases:
|
|
67
|
+
* - Empty input → `'Context'` (caller-fault path; documented for
|
|
68
|
+
* determinism).
|
|
69
|
+
* - Single-character input → `<UPPER>Context` (e.g. `'a'` → `'AContext'`).
|
|
70
|
+
*
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export function deriveContextName(slotKey) {
|
|
74
|
+
if (slotKey.length === 0)
|
|
75
|
+
return 'Context';
|
|
76
|
+
return slotKey.charAt(0).toUpperCase() + slotKey.slice(1) + 'Context';
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Type guard: narrows a `SessionStackEntry` (or unknown) to
|
|
80
|
+
* {@link McpAppsStackItem}. Uses the discriminator.
|
|
81
|
+
*/
|
|
82
|
+
export function isMcpAppsStackItem(entry) {
|
|
83
|
+
return (entry !== null &&
|
|
84
|
+
typeof entry === 'object' &&
|
|
85
|
+
entry.type === 'mcpApps');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Structural validator for an `McpAppsStackItem` — not a Zod schema
|
|
89
|
+
* so we don't force a Zod dependency here. Returns null on failure
|
|
90
|
+
* (caller maps to an appropriate error code). Required when accepting
|
|
91
|
+
* one over the wire from an agent: the discriminator alone isn't
|
|
92
|
+
* enough.
|
|
93
|
+
*/
|
|
94
|
+
export function validateMcpAppsStackItem(input) {
|
|
95
|
+
if (input === null || typeof input !== 'object')
|
|
96
|
+
return null;
|
|
97
|
+
const item = input;
|
|
98
|
+
if (item.type !== 'mcpApps')
|
|
99
|
+
return null;
|
|
100
|
+
if (typeof item.id !== 'string' || item.id.length === 0)
|
|
101
|
+
return null;
|
|
102
|
+
if (typeof item.createdAt !== 'string')
|
|
103
|
+
return null;
|
|
104
|
+
const source = item.source;
|
|
105
|
+
if (!source || typeof source !== 'object')
|
|
106
|
+
return null;
|
|
107
|
+
if (typeof source.connectorId !== 'string' || source.connectorId.length === 0)
|
|
108
|
+
return null;
|
|
109
|
+
if (typeof source.toolName !== 'string' || source.toolName.length === 0)
|
|
110
|
+
return null;
|
|
111
|
+
if (typeof source.resourceUri !== 'string' || !source.resourceUri.startsWith('ui://'))
|
|
112
|
+
return null;
|
|
113
|
+
return input;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The closed set of valid lifecycle states. Exposed as a `readonly`
|
|
117
|
+
* tuple so consumers (renderer host filters, conformance tests) can
|
|
118
|
+
* iterate without re-typing the union literally.
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
export const MCP_APP_LIFECYCLE_STATES = [
|
|
123
|
+
'mounting',
|
|
124
|
+
'code-ready',
|
|
125
|
+
'error',
|
|
126
|
+
'disconnected',
|
|
127
|
+
];
|
|
128
|
+
/**
|
|
129
|
+
* Type guard for {@link McpAppLifecycleMessage}. Trust-boundary helper
|
|
130
|
+
* — apps consuming raw postMessage data MUST narrow before reading
|
|
131
|
+
* `event.state` to avoid reaching into untyped property bags.
|
|
132
|
+
*
|
|
133
|
+
* Validation rules (all required for `true`):
|
|
134
|
+
* - Outer envelope is an object with `type === 'ggui:lifecycle'`.
|
|
135
|
+
* - `event` is an object with `state` matching {@link
|
|
136
|
+
* MCP_APP_LIFECYCLE_STATES}.
|
|
137
|
+
* - If `stackItemId` is present, it is a non-empty string.
|
|
138
|
+
* - If `error` is present, it is an object with string `code` +
|
|
139
|
+
* `message`.
|
|
140
|
+
*
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
export function isMcpAppLifecycleMessage(message) {
|
|
144
|
+
if (message === null || typeof message !== 'object')
|
|
145
|
+
return false;
|
|
146
|
+
const m = message;
|
|
147
|
+
if (m.type !== 'ggui:lifecycle')
|
|
148
|
+
return false;
|
|
149
|
+
if (m.event === null || typeof m.event !== 'object')
|
|
150
|
+
return false;
|
|
151
|
+
const e = m.event;
|
|
152
|
+
if (typeof e.state !== 'string')
|
|
153
|
+
return false;
|
|
154
|
+
if (!MCP_APP_LIFECYCLE_STATES.includes(e.state)) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
if (e.stackItemId !== undefined) {
|
|
158
|
+
if (typeof e.stackItemId !== 'string' || e.stackItemId.length === 0) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (e.error !== undefined) {
|
|
163
|
+
if (e.error === null || typeof e.error !== 'object')
|
|
164
|
+
return false;
|
|
165
|
+
const err = e.error;
|
|
166
|
+
if (typeof err.code !== 'string' || typeof err.message !== 'string') {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Type guard for recognizing a `ggui_push` result `_meta` that carries a
|
|
174
|
+
* bootstrap block. Handy for views / tests that receive the raw result.
|
|
175
|
+
*
|
|
176
|
+
* Validates the three-mode discriminator: a well-formed bootstrap MUST
|
|
177
|
+
* carry `runtimeUrl` + `sessionId` + `appId` AND at least one of
|
|
178
|
+
* `{wsUrl, codeUrl, kind}` as a non-empty string. Live mode
|
|
179
|
+
* additionally requires `token` to pair with `wsUrl` — half-live
|
|
180
|
+
* (one without the other) is rejected as MALFORMED.
|
|
181
|
+
*/
|
|
182
|
+
export function hasPushBootstrapMeta(meta) {
|
|
183
|
+
if (meta === null || typeof meta !== 'object')
|
|
184
|
+
return false;
|
|
185
|
+
const ggui = meta.ggui;
|
|
186
|
+
if (ggui === null || typeof ggui !== 'object')
|
|
187
|
+
return false;
|
|
188
|
+
const bootstrap = ggui.bootstrap;
|
|
189
|
+
if (bootstrap === null || typeof bootstrap !== 'object')
|
|
190
|
+
return false;
|
|
191
|
+
const b = bootstrap;
|
|
192
|
+
// Required-everywhere fields.
|
|
193
|
+
if (!(typeof b.sessionId === 'string' &&
|
|
194
|
+
b.sessionId.length > 0 &&
|
|
195
|
+
typeof b.appId === 'string' &&
|
|
196
|
+
b.appId.length > 0 &&
|
|
197
|
+
typeof b.runtimeUrl === 'string' &&
|
|
198
|
+
b.runtimeUrl.length > 0)) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
// Mode discriminator — at least one of {wsUrl, codeUrl, kind} MUST
|
|
202
|
+
// be a non-empty string. Live mode requires `token` paired with
|
|
203
|
+
// `wsUrl`; half-live is MALFORMED. `codeUrl` is the static-component
|
|
204
|
+
// delivery channel (content-addressable URL the runtime fetches the
|
|
205
|
+
// compiled ES module from). System-card mode (`kind`) is mutually
|
|
206
|
+
// exclusive with `codeUrl`.
|
|
207
|
+
const hasWsUrl = typeof b.wsUrl === 'string' && b.wsUrl.length > 0;
|
|
208
|
+
const hasToken = typeof b.token === 'string' && b.token.length > 0;
|
|
209
|
+
const hasCodeUrl = typeof b.codeUrl === 'string' && b.codeUrl.length > 0;
|
|
210
|
+
const hasKind = typeof b.kind === 'string' && b.kind.length > 0;
|
|
211
|
+
if (hasWsUrl !== hasToken)
|
|
212
|
+
return false;
|
|
213
|
+
if (!hasWsUrl && !hasCodeUrl && !hasKind)
|
|
214
|
+
return false;
|
|
215
|
+
if (hasKind && hasCodeUrl)
|
|
216
|
+
return false;
|
|
217
|
+
// expiresAt is now optional (live-mode-only). When present, must be
|
|
218
|
+
// a string; type-only check, semantic validation lives in the
|
|
219
|
+
// iframe-runtime parser which has clock access.
|
|
220
|
+
if (b.expiresAt !== undefined && typeof b.expiresAt !== 'string') {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
// themeMode (when present) must be one of the closed set.
|
|
224
|
+
if (b.themeMode !== undefined &&
|
|
225
|
+
b.themeMode !== 'light' &&
|
|
226
|
+
b.themeMode !== 'dark') {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
// themeId / propsJson (when present) must be strings.
|
|
230
|
+
if (b.themeId !== undefined && typeof b.themeId !== 'string')
|
|
231
|
+
return false;
|
|
232
|
+
if (b.propsJson !== undefined && typeof b.propsJson !== 'string')
|
|
233
|
+
return false;
|
|
234
|
+
if (b.appCallableTools !== undefined) {
|
|
235
|
+
if (!Array.isArray(b.appCallableTools))
|
|
236
|
+
return false;
|
|
237
|
+
if (!b.appCallableTools.every((s) => typeof s === 'string'))
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
if (b.actionNextSteps !== undefined) {
|
|
241
|
+
if (b.actionNextSteps === null ||
|
|
242
|
+
typeof b.actionNextSteps !== 'object' ||
|
|
243
|
+
Array.isArray(b.actionNextSteps)) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
for (const value of Object.values(b.actionNextSteps)) {
|
|
247
|
+
if (typeof value !== 'string')
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// `contextSlots` is OPTIONAL on the wire. Each entry MUST carry
|
|
252
|
+
// non-empty `name`, non-empty `contextName`, a `schema` object, AND
|
|
253
|
+
// a `default` value (JsonValue, can be null — the runtime owns
|
|
254
|
+
// useState per slot and the Provider seed is load-bearing).
|
|
255
|
+
// Optional `debounceMs` MUST be a number when present.
|
|
256
|
+
if (b.contextSlots !== undefined) {
|
|
257
|
+
if (!Array.isArray(b.contextSlots))
|
|
258
|
+
return false;
|
|
259
|
+
for (const entry of b.contextSlots) {
|
|
260
|
+
if (entry === null || typeof entry !== 'object')
|
|
261
|
+
return false;
|
|
262
|
+
const e = entry;
|
|
263
|
+
if (typeof e.name !== 'string' || e.name.length === 0)
|
|
264
|
+
return false;
|
|
265
|
+
if (typeof e.contextName !== 'string' || e.contextName.length === 0) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
if (e.schema === null || typeof e.schema !== 'object' || Array.isArray(e.schema)) {
|
|
269
|
+
return false;
|
|
270
|
+
}
|
|
271
|
+
// `default` MUST be present (key exists). The value MAY be null
|
|
272
|
+
// — that's a legitimate JsonValue. Discriminate via `in` so a
|
|
273
|
+
// literal `null` passes while truly-missing fails.
|
|
274
|
+
if (!('default' in e))
|
|
275
|
+
return false;
|
|
276
|
+
if (e.debounceMs !== undefined && typeof e.debounceMs !== 'number') {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// `permissionsPolicy` is OPTIONAL on the wire. When present, MUST be
|
|
282
|
+
// an array of non-empty strings (the browser Permissions API names
|
|
283
|
+
// declared on `DataContract.clientCapabilities.gadgets[*].permission`).
|
|
284
|
+
if (b.permissionsPolicy !== undefined) {
|
|
285
|
+
if (!Array.isArray(b.permissionsPolicy))
|
|
286
|
+
return false;
|
|
287
|
+
for (const value of b.permissionsPolicy) {
|
|
288
|
+
if (typeof value !== 'string' || value.length === 0)
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* The three canonical gesture kinds — useful for exhaustiveness checks
|
|
296
|
+
* in `switch (kind) { ... }` blocks. Frozen so consumers can safely use
|
|
297
|
+
* `as const` against the readonly tuple.
|
|
298
|
+
*/
|
|
299
|
+
export const SUBMIT_ACTION_KINDS = [
|
|
300
|
+
'dispatch',
|
|
301
|
+
'openLink',
|
|
302
|
+
'requestDisplayMode',
|
|
303
|
+
];
|
|
304
|
+
/**
|
|
305
|
+
* Type guard narrowing an unknown value to {@link GguiSubmitActionInput}.
|
|
306
|
+
* Validates the `kind` discriminator + the per-kind `payload` shape.
|
|
307
|
+
* Used by the server-side `ggui_runtime_submit_action` handler to reject
|
|
308
|
+
* malformed envelopes with `INVALID_ACTION_KIND` instead of silently
|
|
309
|
+
* coercing.
|
|
310
|
+
*
|
|
311
|
+
* Unknown extension kinds are accepted at this guard layer (the
|
|
312
|
+
* `(string & {})` slot is part of the type) but the per-kind payload
|
|
313
|
+
* narrowing collapses to `Record<string, unknown>` — extension-handlers
|
|
314
|
+
* MUST validate shape before consuming.
|
|
315
|
+
*/
|
|
316
|
+
export function isGguiSubmitActionInput(value) {
|
|
317
|
+
if (value === null || typeof value !== 'object')
|
|
318
|
+
return false;
|
|
319
|
+
const v = value;
|
|
320
|
+
if (typeof v.kind !== 'string' || v.kind.length === 0)
|
|
321
|
+
return false;
|
|
322
|
+
if (typeof v.sessionId !== 'string' || v.sessionId.length === 0)
|
|
323
|
+
return false;
|
|
324
|
+
if (typeof v.appId !== 'string' || v.appId.length === 0)
|
|
325
|
+
return false;
|
|
326
|
+
if (typeof v.actionId !== 'string' || v.actionId.length === 0)
|
|
327
|
+
return false;
|
|
328
|
+
if (typeof v.firedAt !== 'string' || v.firedAt.length === 0)
|
|
329
|
+
return false;
|
|
330
|
+
if (v.stackItemId !== undefined &&
|
|
331
|
+
(typeof v.stackItemId !== 'string' || v.stackItemId.length === 0)) {
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
if (v.payload === null || typeof v.payload !== 'object')
|
|
335
|
+
return false;
|
|
336
|
+
// Per-kind payload narrowing for the closed primary set. Unknown
|
|
337
|
+
// kinds pass through with whatever payload-object the caller supplied
|
|
338
|
+
// — extension handlers own the validation.
|
|
339
|
+
const p = v.payload;
|
|
340
|
+
switch (v.kind) {
|
|
341
|
+
case 'dispatch':
|
|
342
|
+
if (typeof p.intent !== 'string' || p.intent.length === 0)
|
|
343
|
+
return false;
|
|
344
|
+
// `actionData` MUST be present (key exists). The value MAY be
|
|
345
|
+
// `null` — bare button clicks legitimately have no payload.
|
|
346
|
+
// Discriminate via `in` so an explicit `null` passes while
|
|
347
|
+
// truly-missing fails.
|
|
348
|
+
if (!('actionData' in p))
|
|
349
|
+
return false;
|
|
350
|
+
// `uiContext` MUST be a JSON object — `{}` when there's no
|
|
351
|
+
// contextSpec. Arrays and null are rejected.
|
|
352
|
+
if (p.uiContext === null || typeof p.uiContext !== 'object')
|
|
353
|
+
return false;
|
|
354
|
+
if (Array.isArray(p.uiContext))
|
|
355
|
+
return false;
|
|
356
|
+
return true;
|
|
357
|
+
case 'openLink':
|
|
358
|
+
return typeof p.url === 'string' && p.url.length > 0;
|
|
359
|
+
case 'requestDisplayMode':
|
|
360
|
+
return typeof p.mode === 'string' && p.mode.length > 0;
|
|
361
|
+
default:
|
|
362
|
+
// Extension slot — payload-object presence is the only invariant.
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Type guard for {@link GguiUserActionMeta}. Validates the
|
|
368
|
+
* discriminated shape on a `ui/message` envelope's
|
|
369
|
+
* `params._meta.ggui.userAction` field.
|
|
370
|
+
*
|
|
371
|
+
* Designed for `_meta.ggui.userAction`-aware consumers (sample agent
|
|
372
|
+
* dispatcher, e2e assertions, future SDKs) to route deterministically
|
|
373
|
+
* without speculative shape coercion.
|
|
374
|
+
*
|
|
375
|
+
* @public
|
|
376
|
+
*/
|
|
377
|
+
export function isGguiUserActionMeta(meta) {
|
|
378
|
+
if (meta === null || typeof meta !== 'object')
|
|
379
|
+
return false;
|
|
380
|
+
const m = meta;
|
|
381
|
+
if (typeof m.description !== 'string' || m.description.length === 0) {
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
if (typeof m.stackItemId !== 'string' || m.stackItemId.length === 0) {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
if (typeof m.actionId !== 'string' || m.actionId.length === 0) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
if (typeof m.submittedAt !== 'string' || m.submittedAt.length === 0) {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
if (typeof m.intent !== 'string' || m.intent.length === 0)
|
|
394
|
+
return false;
|
|
395
|
+
if (m.kind === 'queued') {
|
|
396
|
+
if (m.nextStep === null || typeof m.nextStep !== 'object')
|
|
397
|
+
return false;
|
|
398
|
+
const ns = m.nextStep;
|
|
399
|
+
if (ns.tool !== 'ggui_consume')
|
|
400
|
+
return false;
|
|
401
|
+
if (ns.args === null || typeof ns.args !== 'object')
|
|
402
|
+
return false;
|
|
403
|
+
const args = ns.args;
|
|
404
|
+
if (typeof args.stackItemId !== 'string' ||
|
|
405
|
+
args.stackItemId.length === 0) {
|
|
406
|
+
return false;
|
|
407
|
+
}
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
if (m.kind === 'inline') {
|
|
411
|
+
if (m.payload === null || typeof m.payload !== 'object')
|
|
412
|
+
return false;
|
|
413
|
+
const p = m.payload;
|
|
414
|
+
if (p.actionData === undefined)
|
|
415
|
+
return false; // explicit null OK
|
|
416
|
+
if (p.uiContext === null || typeof p.uiContext !== 'object')
|
|
417
|
+
return false;
|
|
418
|
+
if (Array.isArray(p.uiContext))
|
|
419
|
+
return false;
|
|
420
|
+
if (m.nextStep !== undefined &&
|
|
421
|
+
(typeof m.nextStep !== 'string' || m.nextStep.length === 0)) {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { stackNavigationReducer, initialNavigationState, } from './stack-navigation.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack Navigation — pure reducer for navigating ggui stack items.
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic state machine. Used by both @ggui-ai/react and
|
|
5
|
+
* @ggui-ai/react-native hooks.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Actions that can be dispatched to the {@link stackNavigationReducer}.
|
|
9
|
+
*
|
|
10
|
+
* - `GO_TO_INDEX` -- Navigate to a specific stack index (clamped to valid range)
|
|
11
|
+
* - `GO_HOME` -- Navigate to the first item (index 0)
|
|
12
|
+
* - `GO_BACK` -- Navigate one item backward (no-op if already at index 0)
|
|
13
|
+
* - `GO_FORWARD` -- Navigate one item forward (no-op if already at the latest)
|
|
14
|
+
* - `STACK_UPDATED` -- Notify the reducer that the stack length changed (push/pop)
|
|
15
|
+
* - `TOGGLE_OVERVIEW` -- Toggle the stack overview panel open/closed
|
|
16
|
+
* - `CLOSE_OVERVIEW` -- Close the stack overview panel
|
|
17
|
+
*/
|
|
18
|
+
export type StackNavigationAction = {
|
|
19
|
+
type: 'GO_TO_INDEX';
|
|
20
|
+
index: number;
|
|
21
|
+
} | {
|
|
22
|
+
type: 'GO_HOME';
|
|
23
|
+
} | {
|
|
24
|
+
type: 'GO_BACK';
|
|
25
|
+
} | {
|
|
26
|
+
type: 'GO_FORWARD';
|
|
27
|
+
} | {
|
|
28
|
+
type: 'STACK_UPDATED';
|
|
29
|
+
stackLength: number;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'TOGGLE_OVERVIEW';
|
|
32
|
+
} | {
|
|
33
|
+
type: 'CLOSE_OVERVIEW';
|
|
34
|
+
};
|
|
35
|
+
export interface StackNavigationState {
|
|
36
|
+
/** Currently viewed stack index */
|
|
37
|
+
currentIndex: number;
|
|
38
|
+
/** Whether the stack overview panel is open */
|
|
39
|
+
overviewOpen: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* When true, the navigator auto-follows new pushes (jumps to latest item).
|
|
42
|
+
* Disabled when the user manually navigates away from the latest item.
|
|
43
|
+
*/
|
|
44
|
+
autoFollow: boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare const initialNavigationState: StackNavigationState;
|
|
47
|
+
/**
|
|
48
|
+
* Pure reducer for stack navigation state.
|
|
49
|
+
*
|
|
50
|
+
* @param state Current navigation state
|
|
51
|
+
* @param action Navigation action to dispatch
|
|
52
|
+
* @param stackLength Current number of items in the stack
|
|
53
|
+
*/
|
|
54
|
+
export declare function stackNavigationReducer(state: StackNavigationState, action: StackNavigationAction, stackLength: number): StackNavigationState;
|
|
55
|
+
//# sourceMappingURL=stack-navigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-navigation.d.ts","sourceRoot":"","sources":["../../src/navigation/stack-navigation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,GACtB;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,iBAAiB,CAAA;CAAE,GAC3B;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAM/B,MAAM,WAAW,oBAAoB;IACnC,mCAAmC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,YAAY,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,sBAAsB,EAAE,oBAIpC,CAAC;AAMF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,oBAAoB,EAC3B,MAAM,EAAE,qBAAqB,EAC7B,WAAW,EAAE,MAAM,GAClB,oBAAoB,CAgEtB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack Navigation — pure reducer for navigating ggui stack items.
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic state machine. Used by both @ggui-ai/react and
|
|
5
|
+
* @ggui-ai/react-native hooks.
|
|
6
|
+
*/
|
|
7
|
+
export const initialNavigationState = {
|
|
8
|
+
currentIndex: 0,
|
|
9
|
+
overviewOpen: false,
|
|
10
|
+
autoFollow: true,
|
|
11
|
+
};
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Reducer
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
/**
|
|
16
|
+
* Pure reducer for stack navigation state.
|
|
17
|
+
*
|
|
18
|
+
* @param state Current navigation state
|
|
19
|
+
* @param action Navigation action to dispatch
|
|
20
|
+
* @param stackLength Current number of items in the stack
|
|
21
|
+
*/
|
|
22
|
+
export function stackNavigationReducer(state, action, stackLength) {
|
|
23
|
+
const maxIndex = Math.max(0, stackLength - 1);
|
|
24
|
+
switch (action.type) {
|
|
25
|
+
case 'GO_TO_INDEX': {
|
|
26
|
+
const clamped = Math.max(0, Math.min(action.index, maxIndex));
|
|
27
|
+
return {
|
|
28
|
+
...state,
|
|
29
|
+
currentIndex: clamped,
|
|
30
|
+
overviewOpen: false,
|
|
31
|
+
// Disable auto-follow if user navigated away from latest
|
|
32
|
+
autoFollow: clamped === maxIndex,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
case 'GO_HOME':
|
|
36
|
+
return {
|
|
37
|
+
...state,
|
|
38
|
+
currentIndex: 0,
|
|
39
|
+
overviewOpen: false,
|
|
40
|
+
autoFollow: maxIndex === 0,
|
|
41
|
+
};
|
|
42
|
+
case 'GO_BACK':
|
|
43
|
+
if (state.currentIndex <= 0)
|
|
44
|
+
return state;
|
|
45
|
+
return {
|
|
46
|
+
...state,
|
|
47
|
+
currentIndex: state.currentIndex - 1,
|
|
48
|
+
autoFollow: false,
|
|
49
|
+
};
|
|
50
|
+
case 'GO_FORWARD':
|
|
51
|
+
if (state.currentIndex >= maxIndex)
|
|
52
|
+
return state;
|
|
53
|
+
return {
|
|
54
|
+
...state,
|
|
55
|
+
currentIndex: state.currentIndex + 1,
|
|
56
|
+
autoFollow: state.currentIndex + 1 === maxIndex,
|
|
57
|
+
};
|
|
58
|
+
case 'STACK_UPDATED': {
|
|
59
|
+
const newMax = Math.max(0, action.stackLength - 1);
|
|
60
|
+
// If auto-follow is on, jump to the latest item
|
|
61
|
+
if (state.autoFollow) {
|
|
62
|
+
return {
|
|
63
|
+
...state,
|
|
64
|
+
currentIndex: newMax,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// Otherwise, clamp to valid range (handles pops)
|
|
68
|
+
return {
|
|
69
|
+
...state,
|
|
70
|
+
currentIndex: Math.min(state.currentIndex, newMax),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
case 'TOGGLE_OVERVIEW':
|
|
74
|
+
return { ...state, overviewOpen: !state.overviewOpen };
|
|
75
|
+
case 'CLOSE_OVERVIEW':
|
|
76
|
+
return { ...state, overviewOpen: false };
|
|
77
|
+
default:
|
|
78
|
+
return state;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recommended agent-side system prompts for hosts running ggui.
|
|
3
|
+
*
|
|
4
|
+
* The wire protocol already carries its own self-teaching surfaces:
|
|
5
|
+
*
|
|
6
|
+
* - Per-tool `description` strings on every `ggui_*` MCP tool.
|
|
7
|
+
* - The server's `InitializeResult.instructions` field (set via
|
|
8
|
+
* `@ggui-ai/mcp-server`'s `MCP_INSTRUCTIONS_PRESETS`).
|
|
9
|
+
*
|
|
10
|
+
* Those two carry the wire flow (new_session → handshake → push →
|
|
11
|
+
* consume → react), the contract-authoring rules, recovery shapes,
|
|
12
|
+
* and the mutation rule. **Agent builders should NOT replicate any
|
|
13
|
+
* of that in their system prompt.** The protocol is designed to be
|
|
14
|
+
* self-teaching from the host's side.
|
|
15
|
+
*
|
|
16
|
+
* What an agent-side system prompt SHOULD do: set the agent's role
|
|
17
|
+
* and posture — "you render UIs, you don't reply in plain text" —
|
|
18
|
+
* so the model reaches for ggui_* tools instead of conversational
|
|
19
|
+
* responses. That's a *posture cue*, not a procedural script.
|
|
20
|
+
*
|
|
21
|
+
* On hosts like claude.ai, the host's own baseline system prompt
|
|
22
|
+
* already nudges tool usage, so a one-line user instruction
|
|
23
|
+
* ("Always respond using ggui_* tools") is enough. On raw SDK hosts
|
|
24
|
+
* (Claude Agent SDK, OpenAI Assistants, etc.) that baseline is
|
|
25
|
+
* absent, so the recommended prompt below carries slightly more
|
|
26
|
+
* role context to compensate.
|
|
27
|
+
*
|
|
28
|
+
* If an agent isn't following the wire flow correctly even with
|
|
29
|
+
* this prompt, the bug lives in the protocol's tool descriptions
|
|
30
|
+
* or server instructions — fix THOSE, not this string.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* The recommended one-line system prompt for ggui-aware agents.
|
|
34
|
+
*
|
|
35
|
+
* Posture-setting only. Carries no procedural detail — the wire flow
|
|
36
|
+
* is taught by the server's `InitializeResult.instructions` and
|
|
37
|
+
* per-tool `description` strings.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
42
|
+
* import { GGUI_AGENT_SYSTEM_PROMPT } from '@ggui-ai/protocol/recommended-prompts';
|
|
43
|
+
*
|
|
44
|
+
* query({
|
|
45
|
+
* prompt: userInput,
|
|
46
|
+
* options: {
|
|
47
|
+
* systemPrompt: GGUI_AGENT_SYSTEM_PROMPT,
|
|
48
|
+
* mcpServers: { ggui: { type: 'http', url: 'http://localhost:6781/mcp' } },
|
|
49
|
+
* },
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export declare const GGUI_AGENT_SYSTEM_PROMPT = "You are a UI agent. Respond to every user request by rendering an interactive UI via the ggui_* MCP tools instead of by replying in plain text. The tool descriptions and server instructions explain the wire flow \u2014 follow them.";
|
|
56
|
+
//# sourceMappingURL=recommended-prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended-prompts.d.ts","sourceRoot":"","sources":["../src/recommended-prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,wBAAwB,4OACiM,CAAC"}
|