@ggui-ai/mcp-server-handlers 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 +32 -0
- package/dist/app-discovery/errors.d.ts +23 -0
- package/dist/app-discovery/errors.d.ts.map +1 -0
- package/dist/app-discovery/errors.js +26 -0
- package/dist/app-discovery/index.d.ts +19 -0
- package/dist/app-discovery/index.d.ts.map +1 -0
- package/dist/app-discovery/index.js +18 -0
- package/dist/app-discovery/list-gadgets.d.ts +93 -0
- package/dist/app-discovery/list-gadgets.d.ts.map +1 -0
- package/dist/app-discovery/list-gadgets.js +93 -0
- package/dist/app-discovery/list-themes.d.ts +70 -0
- package/dist/app-discovery/list-themes.d.ts.map +1 -0
- package/dist/app-discovery/list-themes.js +80 -0
- package/dist/blueprints/describe-blueprint-format.d.ts +25 -0
- package/dist/blueprints/describe-blueprint-format.d.ts.map +1 -0
- package/dist/blueprints/describe-blueprint-format.js +138 -0
- package/dist/blueprints/describe-data-contract-format.d.ts +31 -0
- package/dist/blueprints/describe-data-contract-format.d.ts.map +1 -0
- package/dist/blueprints/describe-data-contract-format.js +292 -0
- package/dist/blueprints/get-blueprint-boilerplate.d.ts +45 -0
- package/dist/blueprints/get-blueprint-boilerplate.d.ts.map +1 -0
- package/dist/blueprints/get-blueprint-boilerplate.js +57 -0
- package/dist/blueprints/get-example-blueprints.d.ts +67 -0
- package/dist/blueprints/get-example-blueprints.d.ts.map +1 -0
- package/dist/blueprints/get-example-blueprints.js +315 -0
- package/dist/blueprints/index.d.ts +38 -0
- package/dist/blueprints/index.d.ts.map +1 -0
- package/dist/blueprints/index.js +34 -0
- package/dist/blueprints/list-available-primitives.d.ts +31 -0
- package/dist/blueprints/list-available-primitives.d.ts.map +1 -0
- package/dist/blueprints/list-available-primitives.js +44 -0
- package/dist/blueprints/list-featured-blueprints.d.ts +45 -0
- package/dist/blueprints/list-featured-blueprints.d.ts.map +1 -0
- package/dist/blueprints/list-featured-blueprints.js +47 -0
- package/dist/blueprints/render-blueprint.d.ts +80 -0
- package/dist/blueprints/render-blueprint.d.ts.map +1 -0
- package/dist/blueprints/render-blueprint.js +129 -0
- package/dist/blueprints/search-blueprints.d.ts +103 -0
- package/dist/blueprints/search-blueprints.d.ts.map +1 -0
- package/dist/blueprints/search-blueprints.js +225 -0
- package/dist/blueprints/validate-blueprint.d.ts +56 -0
- package/dist/blueprints/validate-blueprint.d.ts.map +1 -0
- package/dist/blueprints/validate-blueprint.js +69 -0
- package/dist/contract-tests/index.d.ts +20 -0
- package/dist/contract-tests/index.d.ts.map +1 -0
- package/dist/contract-tests/index.js +19 -0
- package/dist/contract-tests/push-handler.contract.d.ts +31 -0
- package/dist/contract-tests/push-handler.contract.d.ts.map +1 -0
- package/dist/contract-tests/push-handler.contract.js +378 -0
- package/dist/credits/get-credit-balance.d.ts +70 -0
- package/dist/credits/get-credit-balance.d.ts.map +1 -0
- package/dist/credits/get-credit-balance.js +69 -0
- package/dist/credits/index.d.ts +30 -0
- package/dist/credits/index.d.ts.map +1 -0
- package/dist/credits/index.js +27 -0
- package/dist/credits/list-credit-transactions.d.ts +79 -0
- package/dist/credits/list-credit-transactions.d.ts.map +1 -0
- package/dist/credits/list-credit-transactions.js +67 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/ops-apps/create-app.d.ts +40 -0
- package/dist/ops-apps/create-app.d.ts.map +1 -0
- package/dist/ops-apps/create-app.js +60 -0
- package/dist/ops-apps/delete-app.d.ts +35 -0
- package/dist/ops-apps/delete-app.d.ts.map +1 -0
- package/dist/ops-apps/delete-app.js +55 -0
- package/dist/ops-apps/identity.d.ts +18 -0
- package/dist/ops-apps/identity.d.ts.map +1 -0
- package/dist/ops-apps/identity.js +13 -0
- package/dist/ops-apps/in-memory-fake.test-util.d.ts +48 -0
- package/dist/ops-apps/in-memory-fake.test-util.d.ts.map +1 -0
- package/dist/ops-apps/in-memory-fake.test-util.js +90 -0
- package/dist/ops-apps/index.d.ts +31 -0
- package/dist/ops-apps/index.d.ts.map +1 -0
- package/dist/ops-apps/index.js +23 -0
- package/dist/ops-apps/list-apps.d.ts +35 -0
- package/dist/ops-apps/list-apps.d.ts.map +1 -0
- package/dist/ops-apps/list-apps.js +40 -0
- package/dist/ops-apps/rename-app.d.ts +45 -0
- package/dist/ops-apps/rename-app.d.ts.map +1 -0
- package/dist/ops-apps/rename-app.js +76 -0
- package/dist/ops-apps/set-default-app.d.ts +32 -0
- package/dist/ops-apps/set-default-app.d.ts.map +1 -0
- package/dist/ops-apps/set-default-app.js +51 -0
- package/dist/ops-apps/types.d.ts +112 -0
- package/dist/ops-apps/types.d.ts.map +1 -0
- package/dist/ops-apps/types.js +27 -0
- package/dist/ops-apps/update-app-system-prompt.d.ts +41 -0
- package/dist/ops-apps/update-app-system-prompt.d.ts.map +1 -0
- package/dist/ops-apps/update-app-system-prompt.js +69 -0
- package/dist/ops-blueprint/delete.d.ts +39 -0
- package/dist/ops-blueprint/delete.d.ts.map +1 -0
- package/dist/ops-blueprint/delete.js +56 -0
- package/dist/ops-blueprint/errors.d.ts +55 -0
- package/dist/ops-blueprint/errors.d.ts.map +1 -0
- package/dist/ops-blueprint/errors.js +65 -0
- package/dist/ops-blueprint/generate.d.ts +173 -0
- package/dist/ops-blueprint/generate.d.ts.map +1 -0
- package/dist/ops-blueprint/generate.js +322 -0
- package/dist/ops-blueprint/index.d.ts +26 -0
- package/dist/ops-blueprint/index.d.ts.map +1 -0
- package/dist/ops-blueprint/index.js +25 -0
- package/dist/ops-blueprint/list.d.ts +65 -0
- package/dist/ops-blueprint/list.d.ts.map +1 -0
- package/dist/ops-blueprint/list.js +121 -0
- package/dist/ops-blueprint/persona-normalization.d.ts +85 -0
- package/dist/ops-blueprint/persona-normalization.d.ts.map +1 -0
- package/dist/ops-blueprint/persona-normalization.js +134 -0
- package/dist/ops-blueprint/register.d.ts +126 -0
- package/dist/ops-blueprint/register.d.ts.map +1 -0
- package/dist/ops-blueprint/register.js +227 -0
- package/dist/ops-blueprint/update.d.ts +61 -0
- package/dist/ops-blueprint/update.d.ts.map +1 -0
- package/dist/ops-blueprint/update.js +138 -0
- package/dist/ops-connector-keys/in-memory-fake.test-util.d.ts +26 -0
- package/dist/ops-connector-keys/in-memory-fake.test-util.d.ts.map +1 -0
- package/dist/ops-connector-keys/in-memory-fake.test-util.js +60 -0
- package/dist/ops-connector-keys/index.d.ts +19 -0
- package/dist/ops-connector-keys/index.d.ts.map +1 -0
- package/dist/ops-connector-keys/index.js +14 -0
- package/dist/ops-connector-keys/issue-connector-key.d.ts +57 -0
- package/dist/ops-connector-keys/issue-connector-key.d.ts.map +1 -0
- package/dist/ops-connector-keys/issue-connector-key.js +83 -0
- package/dist/ops-connector-keys/list-connector-keys.d.ts +35 -0
- package/dist/ops-connector-keys/list-connector-keys.d.ts.map +1 -0
- package/dist/ops-connector-keys/list-connector-keys.js +37 -0
- package/dist/ops-connector-keys/revoke-connector-key.d.ts +36 -0
- package/dist/ops-connector-keys/revoke-connector-key.d.ts.map +1 -0
- package/dist/ops-connector-keys/revoke-connector-key.js +48 -0
- package/dist/ops-connector-keys/types.d.ts +85 -0
- package/dist/ops-connector-keys/types.d.ts.map +1 -0
- package/dist/ops-connector-keys/types.js +24 -0
- package/dist/ops-coupon/in-memory-fake.test-util.d.ts +28 -0
- package/dist/ops-coupon/in-memory-fake.test-util.d.ts.map +1 -0
- package/dist/ops-coupon/in-memory-fake.test-util.js +66 -0
- package/dist/ops-coupon/index.d.ts +15 -0
- package/dist/ops-coupon/index.d.ts.map +1 -0
- package/dist/ops-coupon/index.js +12 -0
- package/dist/ops-coupon/redeem-coupon.d.ts +42 -0
- package/dist/ops-coupon/redeem-coupon.d.ts.map +1 -0
- package/dist/ops-coupon/redeem-coupon.js +60 -0
- package/dist/ops-coupon/types.d.ts +59 -0
- package/dist/ops-coupon/types.d.ts.map +1 -0
- package/dist/ops-coupon/types.js +38 -0
- package/dist/ops-orgs/create-org.d.ts +39 -0
- package/dist/ops-orgs/create-org.d.ts.map +1 -0
- package/dist/ops-orgs/create-org.js +54 -0
- package/dist/ops-orgs/in-memory-fake.test-util.d.ts +59 -0
- package/dist/ops-orgs/in-memory-fake.test-util.d.ts.map +1 -0
- package/dist/ops-orgs/in-memory-fake.test-util.js +129 -0
- package/dist/ops-orgs/index.d.ts +24 -0
- package/dist/ops-orgs/index.d.ts.map +1 -0
- package/dist/ops-orgs/index.js +18 -0
- package/dist/ops-orgs/invite-to-org.d.ts +60 -0
- package/dist/ops-orgs/invite-to-org.d.ts.map +1 -0
- package/dist/ops-orgs/invite-to-org.js +71 -0
- package/dist/ops-orgs/list-orgs.d.ts +35 -0
- package/dist/ops-orgs/list-orgs.d.ts.map +1 -0
- package/dist/ops-orgs/list-orgs.js +36 -0
- package/dist/ops-orgs/revoke-invite.d.ts +42 -0
- package/dist/ops-orgs/revoke-invite.d.ts.map +1 -0
- package/dist/ops-orgs/revoke-invite.js +52 -0
- package/dist/ops-orgs/types.d.ts +116 -0
- package/dist/ops-orgs/types.d.ts.map +1 -0
- package/dist/ops-orgs/types.js +22 -0
- package/dist/provider-keys/index.d.ts +20 -0
- package/dist/provider-keys/index.d.ts.map +1 -0
- package/dist/provider-keys/index.js +15 -0
- package/dist/provider-keys/list-provider-keys.d.ts +42 -0
- package/dist/provider-keys/list-provider-keys.d.ts.map +1 -0
- package/dist/provider-keys/list-provider-keys.js +46 -0
- package/dist/provider-keys/remove-provider-key.d.ts +34 -0
- package/dist/provider-keys/remove-provider-key.d.ts.map +1 -0
- package/dist/provider-keys/remove-provider-key.js +47 -0
- package/dist/provider-keys/set-provider-key.d.ts +46 -0
- package/dist/provider-keys/set-provider-key.d.ts.map +1 -0
- package/dist/provider-keys/set-provider-key.js +68 -0
- package/dist/provider-keys/types.d.ts +66 -0
- package/dist/provider-keys/types.d.ts.map +1 -0
- package/dist/provider-keys/types.js +20 -0
- package/dist/session-mutations/apply-stack-item-patch.d.ts +79 -0
- package/dist/session-mutations/apply-stack-item-patch.d.ts.map +1 -0
- package/dist/session-mutations/apply-stack-item-patch.js +74 -0
- package/dist/session-mutations/assert-action-contract.d.ts +20 -0
- package/dist/session-mutations/assert-action-contract.d.ts.map +1 -0
- package/dist/session-mutations/assert-action-contract.js +29 -0
- package/dist/session-mutations/assert-contract-no-retired-fields.d.ts +31 -0
- package/dist/session-mutations/assert-contract-no-retired-fields.d.ts.map +1 -0
- package/dist/session-mutations/assert-contract-no-retired-fields.js +47 -0
- package/dist/session-mutations/assert-event-allowed.d.ts +29 -0
- package/dist/session-mutations/assert-event-allowed.d.ts.map +1 -0
- package/dist/session-mutations/assert-event-allowed.js +34 -0
- package/dist/session-mutations/assert-gadgets.d.ts +164 -0
- package/dist/session-mutations/assert-gadgets.d.ts.map +1 -0
- package/dist/session-mutations/assert-gadgets.js +245 -0
- package/dist/session-mutations/assert-generator.d.ts +35 -0
- package/dist/session-mutations/assert-generator.d.ts.map +1 -0
- package/dist/session-mutations/assert-generator.js +43 -0
- package/dist/session-mutations/assert-no-duplicate-gadget-hooks.d.ts +43 -0
- package/dist/session-mutations/assert-no-duplicate-gadget-hooks.d.ts.map +1 -0
- package/dist/session-mutations/assert-no-duplicate-gadget-hooks.js +57 -0
- package/dist/session-mutations/assert-props-contract.d.ts +19 -0
- package/dist/session-mutations/assert-props-contract.d.ts.map +1 -0
- package/dist/session-mutations/assert-props-contract.js +28 -0
- package/dist/session-mutations/assert-public-env.d.ts +100 -0
- package/dist/session-mutations/assert-public-env.d.ts.map +1 -0
- package/dist/session-mutations/assert-public-env.js +145 -0
- package/dist/session-mutations/assert-stream-contract.d.ts +27 -0
- package/dist/session-mutations/assert-stream-contract.d.ts.map +1 -0
- package/dist/session-mutations/assert-stream-contract.js +52 -0
- package/dist/session-mutations/blueprint-matcher.d.ts +124 -0
- package/dist/session-mutations/blueprint-matcher.d.ts.map +1 -0
- package/dist/session-mutations/blueprint-matcher.js +277 -0
- package/dist/session-mutations/blueprint-registry.d.ts +286 -0
- package/dist/session-mutations/blueprint-registry.d.ts.map +1 -0
- package/dist/session-mutations/blueprint-registry.js +425 -0
- package/dist/session-mutations/bootstrap-meta-derivation.d.ts +429 -0
- package/dist/session-mutations/bootstrap-meta-derivation.d.ts.map +1 -0
- package/dist/session-mutations/bootstrap-meta-derivation.js +657 -0
- package/dist/session-mutations/cache-trace-sink.d.ts +326 -0
- package/dist/session-mutations/cache-trace-sink.d.ts.map +1 -0
- package/dist/session-mutations/cache-trace-sink.js +92 -0
- package/dist/session-mutations/canvas-lifecycle.d.ts +33 -0
- package/dist/session-mutations/canvas-lifecycle.d.ts.map +1 -0
- package/dist/session-mutations/canvas-lifecycle.js +20 -0
- package/dist/session-mutations/client-observations.d.ts +79 -0
- package/dist/session-mutations/client-observations.d.ts.map +1 -0
- package/dist/session-mutations/client-observations.js +48 -0
- package/dist/session-mutations/close.d.ts +70 -0
- package/dist/session-mutations/close.d.ts.map +1 -0
- package/dist/session-mutations/close.js +127 -0
- package/dist/session-mutations/consume.d.ts +183 -0
- package/dist/session-mutations/consume.d.ts.map +1 -0
- package/dist/session-mutations/consume.js +302 -0
- package/dist/session-mutations/errors.d.ts +180 -0
- package/dist/session-mutations/errors.d.ts.map +1 -0
- package/dist/session-mutations/errors.js +187 -0
- package/dist/session-mutations/fetch-gadget-types.d.ts +60 -0
- package/dist/session-mutations/fetch-gadget-types.d.ts.map +1 -0
- package/dist/session-mutations/fetch-gadget-types.js +119 -0
- package/dist/session-mutations/generation-cache.d.ts +147 -0
- package/dist/session-mutations/generation-cache.d.ts.map +1 -0
- package/dist/session-mutations/generation-cache.js +151 -0
- package/dist/session-mutations/get-session.d.ts +71 -0
- package/dist/session-mutations/get-session.d.ts.map +1 -0
- package/dist/session-mutations/get-session.js +153 -0
- package/dist/session-mutations/get-stack.d.ts +32 -0
- package/dist/session-mutations/get-stack.d.ts.map +1 -0
- package/dist/session-mutations/get-stack.js +85 -0
- package/dist/session-mutations/handle-stream.d.ts +121 -0
- package/dist/session-mutations/handle-stream.d.ts.map +1 -0
- package/dist/session-mutations/handle-stream.js +67 -0
- package/dist/session-mutations/handshake.d.ts +464 -0
- package/dist/session-mutations/handshake.d.ts.map +1 -0
- package/dist/session-mutations/handshake.js +550 -0
- package/dist/session-mutations/index.d.ts +85 -0
- package/dist/session-mutations/index.d.ts.map +1 -0
- package/dist/session-mutations/index.js +93 -0
- package/dist/session-mutations/install-to-cache.d.ts +114 -0
- package/dist/session-mutations/install-to-cache.d.ts.map +1 -0
- package/dist/session-mutations/install-to-cache.js +87 -0
- package/dist/session-mutations/installed-blueprints-provider.d.ts +151 -0
- package/dist/session-mutations/installed-blueprints-provider.d.ts.map +1 -0
- package/dist/session-mutations/installed-blueprints-provider.js +0 -0
- package/dist/session-mutations/new-session.d.ts +108 -0
- package/dist/session-mutations/new-session.d.ts.map +1 -0
- package/dist/session-mutations/new-session.js +248 -0
- package/dist/session-mutations/no-credentials-card.d.ts +45 -0
- package/dist/session-mutations/no-credentials-card.d.ts.map +1 -0
- package/dist/session-mutations/no-credentials-card.js +30 -0
- package/dist/session-mutations/payload-trace-sink.d.ts +105 -0
- package/dist/session-mutations/payload-trace-sink.d.ts.map +1 -0
- package/dist/session-mutations/payload-trace-sink.js +97 -0
- package/dist/session-mutations/pop.d.ts +41 -0
- package/dist/session-mutations/pop.d.ts.map +1 -0
- package/dist/session-mutations/pop.js +62 -0
- package/dist/session-mutations/provisional-preview.d.ts +443 -0
- package/dist/session-mutations/provisional-preview.d.ts.map +1 -0
- package/dist/session-mutations/provisional-preview.js +369 -0
- package/dist/session-mutations/push.d.ts +839 -0
- package/dist/session-mutations/push.d.ts.map +1 -0
- package/dist/session-mutations/push.js +1908 -0
- package/dist/session-mutations/refresh-bootstrap.d.ts +133 -0
- package/dist/session-mutations/refresh-bootstrap.d.ts.map +1 -0
- package/dist/session-mutations/refresh-bootstrap.js +148 -0
- package/dist/session-mutations/stream-replay-ops.d.ts +240 -0
- package/dist/session-mutations/stream-replay-ops.d.ts.map +1 -0
- package/dist/session-mutations/stream-replay-ops.js +273 -0
- package/dist/session-mutations/stream.d.ts +57 -0
- package/dist/session-mutations/stream.d.ts.map +1 -0
- package/dist/session-mutations/stream.js +80 -0
- package/dist/session-mutations/submit-action.d.ts +155 -0
- package/dist/session-mutations/submit-action.d.ts.map +1 -0
- package/dist/session-mutations/submit-action.js +273 -0
- package/dist/session-mutations/sync-context.d.ts +90 -0
- package/dist/session-mutations/sync-context.d.ts.map +1 -0
- package/dist/session-mutations/sync-context.js +273 -0
- package/dist/session-mutations/update.d.ts +267 -0
- package/dist/session-mutations/update.d.ts.map +1 -0
- package/dist/session-mutations/update.js +397 -0
- package/dist/threads/append-message.d.ts +26 -0
- package/dist/threads/append-message.d.ts.map +1 -0
- package/dist/threads/append-message.js +5 -0
- package/dist/threads/apply-thread-action.d.ts +36 -0
- package/dist/threads/apply-thread-action.d.ts.map +1 -0
- package/dist/threads/apply-thread-action.js +5 -0
- package/dist/threads/context.d.ts +25 -0
- package/dist/threads/context.d.ts.map +1 -0
- package/dist/threads/context.js +1 -0
- package/dist/threads/create-thread.d.ts +19 -0
- package/dist/threads/create-thread.d.ts.map +1 -0
- package/dist/threads/create-thread.js +5 -0
- package/dist/threads/errors.d.ts +38 -0
- package/dist/threads/errors.d.ts.map +1 -0
- package/dist/threads/errors.js +41 -0
- package/dist/threads/get-thread.d.ts +23 -0
- package/dist/threads/get-thread.d.ts.map +1 -0
- package/dist/threads/get-thread.js +7 -0
- package/dist/threads/index.d.ts +34 -0
- package/dist/threads/index.d.ts.map +1 -0
- package/dist/threads/index.js +25 -0
- package/dist/threads/list-messages.d.ts +25 -0
- package/dist/threads/list-messages.d.ts.map +1 -0
- package/dist/threads/list-messages.js +5 -0
- package/dist/threads/list-threads.d.ts +18 -0
- package/dist/threads/list-threads.d.ts.map +1 -0
- package/dist/threads/list-threads.js +5 -0
- package/dist/threads/observe-messages.d.ts +31 -0
- package/dist/threads/observe-messages.d.ts.map +1 -0
- package/dist/threads/observe-messages.js +5 -0
- package/dist/threads/schemas.d.ts +73 -0
- package/dist/threads/schemas.d.ts.map +1 -0
- package/dist/threads/schemas.js +86 -0
- package/dist/types.d.ts +244 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +24 -0
- package/package.json +121 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ggui_list_themes` — per-app theme catalog discovery tool.
|
|
3
|
+
*
|
|
4
|
+
* Returns the list of `ThemeEntry` records the app exposes — every
|
|
5
|
+
* registered preset by default, or an operator-curated filter when
|
|
6
|
+
* `App.availableThemeIds` is set. Lets the agent reason about visual
|
|
7
|
+
* style ("calming" vs "urgent" vs "marketing") by reading descriptions
|
|
8
|
+
* instead of guessing at preset ids.
|
|
9
|
+
*
|
|
10
|
+
* ## Behavior
|
|
11
|
+
*
|
|
12
|
+
* 1. Validates input shape (`{appId?: string}`). Cross-tenant
|
|
13
|
+
* access protected the same way as `ggui_list_gadgets`.
|
|
14
|
+
* 2. Reads the global theme catalog via the bound `themes` dep
|
|
15
|
+
* (a `() => readonly ThemeCatalogEntry[]` resolver — keeps the
|
|
16
|
+
* handler design-package-agnostic).
|
|
17
|
+
* 3. If `app.availableThemeIds` is set, filters the catalog to just
|
|
18
|
+
* those ids; otherwise returns the full catalog.
|
|
19
|
+
*
|
|
20
|
+
* ## Audience
|
|
21
|
+
*
|
|
22
|
+
* `['agent']` — registered on `/mcp`. Agent-callable anytime; pair
|
|
23
|
+
* with `ggui_new_session({themeId})` or `ggui_push({themeId})` to
|
|
24
|
+
* apply a chosen theme.
|
|
25
|
+
*/
|
|
26
|
+
import { z } from 'zod';
|
|
27
|
+
import { AppAccessDeniedError } from './errors.js';
|
|
28
|
+
const inputSchema = {
|
|
29
|
+
appId: z
|
|
30
|
+
.string()
|
|
31
|
+
.min(1)
|
|
32
|
+
.optional()
|
|
33
|
+
.describe('App id whose theme catalog to return. Defaults to the caller-resolved app id from the auth header. Cross-tenant requests fail with app_access_denied.'),
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Wire shape for a single theme entry. Mirrors `@ggui-ai/design`'s
|
|
37
|
+
* `ThemeEntry` but kept local so this handler doesn't pull the design
|
|
38
|
+
* package as a hard dep — the caller passes the catalog via the
|
|
39
|
+
* `themes` resolver and is responsible for whatever upstream shape
|
|
40
|
+
* produces it.
|
|
41
|
+
*/
|
|
42
|
+
const themeEntryWireSchema = z
|
|
43
|
+
.object({
|
|
44
|
+
id: z.string().min(1),
|
|
45
|
+
name: z.string(),
|
|
46
|
+
description: z.string(),
|
|
47
|
+
modes: z.array(z.enum(['light', 'dark'])),
|
|
48
|
+
})
|
|
49
|
+
.passthrough();
|
|
50
|
+
const outputSchema = {
|
|
51
|
+
themes: z.array(themeEntryWireSchema),
|
|
52
|
+
};
|
|
53
|
+
export function createGguiListThemesHandler(deps) {
|
|
54
|
+
return {
|
|
55
|
+
name: 'ggui_list_themes',
|
|
56
|
+
title: 'List themes',
|
|
57
|
+
audience: ['agent'],
|
|
58
|
+
description: "List visual themes the agent may apply to a session via `ggui_new_session({themeId})` or `ggui_push({themeId})`. Each entry carries an `id` (pass to themeId), `name` (human-readable), `description` (agent-readable: e.g. 'warm marketing palette', 'high-contrast scientific dashboard'), and `modes` (light/dark variants the theme ships). Call this when the user's intent suggests a visual style choice — pick the theme whose description best matches the requested aesthetic. Operator-scoped: returns the per-app allowlist when one is configured, otherwise the full registered catalog.",
|
|
59
|
+
inputSchema,
|
|
60
|
+
outputSchema,
|
|
61
|
+
async handler(rawInput, ctx) {
|
|
62
|
+
const parsed = z.object(inputSchema).parse(rawInput);
|
|
63
|
+
const resolvedAppId = parsed.appId ?? ctx.appId;
|
|
64
|
+
if (parsed.appId !== undefined && parsed.appId !== ctx.appId) {
|
|
65
|
+
throw new AppAccessDeniedError();
|
|
66
|
+
}
|
|
67
|
+
const app = await deps.appMetadataStore.get(resolvedAppId);
|
|
68
|
+
const catalog = deps.themes();
|
|
69
|
+
// Filter when allowlist is configured. Preserves catalog order
|
|
70
|
+
// (so the picker UI stays stable) and silently drops ids that
|
|
71
|
+
// appear in the allowlist but aren't registered (defensive
|
|
72
|
+
// against operator typos — agent still sees a working list).
|
|
73
|
+
if (app?.availableThemeIds && app.availableThemeIds.length > 0) {
|
|
74
|
+
const allowed = new Set(app.availableThemeIds);
|
|
75
|
+
return { themes: catalog.filter((t) => allowed.has(t.id)) };
|
|
76
|
+
}
|
|
77
|
+
return { themes: catalog };
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ggui_describe_blueprint_format` — wire-format documentation for the
|
|
3
|
+
* blueprint envelope `ggui_ops_generate_blueprint` and `ggui_protocol_validate_blueprint`
|
|
4
|
+
* accept.
|
|
5
|
+
*
|
|
6
|
+
* Pure compute, no DDB. Returns a markdown explainer + a minimum-viable
|
|
7
|
+
* example. Pinning the format server-side guards against Claude
|
|
8
|
+
* composing from stale training-data assumptions about the shape.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import type { SharedHandler } from '../types.js';
|
|
12
|
+
declare const inputSchema: {};
|
|
13
|
+
declare const outputSchema: {
|
|
14
|
+
format: z.ZodLiteral<"AgentBlueprint">;
|
|
15
|
+
documentation: z.ZodString;
|
|
16
|
+
example: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
17
|
+
};
|
|
18
|
+
interface DescribeBlueprintFormatOutput {
|
|
19
|
+
readonly format: 'AgentBlueprint';
|
|
20
|
+
readonly documentation: string;
|
|
21
|
+
readonly example: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export declare function createDescribeBlueprintFormatHandler(): SharedHandler<typeof inputSchema, typeof outputSchema, DescribeBlueprintFormatOutput>;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=describe-blueprint-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-blueprint-format.d.ts","sourceRoot":"","sources":["../../src/blueprints/describe-blueprint-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,QAAA,MAAM,WAAW,IAAK,CAAC;AAEvB,QAAA,MAAM,YAAY;;;;CAIjB,CAAC;AAEF,UAAU,6BAA6B;IACrC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC3C;AA6GD,wBAAgB,oCAAoC,IAAI,aAAa,CACnE,OAAO,WAAW,EAClB,OAAO,YAAY,EACnB,6BAA6B,CAC9B,CAiBA"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ggui_describe_blueprint_format` — wire-format documentation for the
|
|
3
|
+
* blueprint envelope `ggui_ops_generate_blueprint` and `ggui_protocol_validate_blueprint`
|
|
4
|
+
* accept.
|
|
5
|
+
*
|
|
6
|
+
* Pure compute, no DDB. Returns a markdown explainer + a minimum-viable
|
|
7
|
+
* example. Pinning the format server-side guards against Claude
|
|
8
|
+
* composing from stale training-data assumptions about the shape.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
const inputSchema = {};
|
|
12
|
+
const outputSchema = {
|
|
13
|
+
format: z.literal('AgentBlueprint'),
|
|
14
|
+
documentation: z.string(),
|
|
15
|
+
example: z.record(z.string(), z.unknown()),
|
|
16
|
+
};
|
|
17
|
+
const DOCUMENTATION = `# AgentBlueprint format
|
|
18
|
+
|
|
19
|
+
The wire shape every blueprint authoring tool consumes:
|
|
20
|
+
|
|
21
|
+
\`\`\`ts
|
|
22
|
+
interface AgentBlueprint {
|
|
23
|
+
/** TSX source for the React component. MUST \`export default\` a component. */
|
|
24
|
+
source: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* DataContract envelope describing the component's wire surface
|
|
28
|
+
* (propsSpec / actionSpec / contextSpec / streamSpec /
|
|
29
|
+
* agentCapabilities / clientCapabilities). Optional — without it,
|
|
30
|
+
* the runtime probe
|
|
31
|
+
* skips and you only get compile + self-check tier validation.
|
|
32
|
+
* Strongly recommended. Get the full contract format via
|
|
33
|
+
* \`ggui_protocol_describe_data_contract_format\`.
|
|
34
|
+
*/
|
|
35
|
+
contract?: DataContract;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Optional concrete props to render with during the runtime probe.
|
|
39
|
+
* Must match \`contract.propsSpec\` shape. Defaults to mockup props
|
|
40
|
+
* synthesized from the prop schema when omitted.
|
|
41
|
+
*/
|
|
42
|
+
fixtureProps?: Record<string, JsonValue>;
|
|
43
|
+
}
|
|
44
|
+
\`\`\`
|
|
45
|
+
|
|
46
|
+
## Field semantics
|
|
47
|
+
|
|
48
|
+
- **\`source\`** is plain TSX — no preamble, no markdown fence.
|
|
49
|
+
Imports allowed: \`react\`, \`@ggui-ai/design/primitives\`,
|
|
50
|
+
\`@ggui-ai/design/components\`, \`@ggui-ai/design/compositions\`.
|
|
51
|
+
No external libraries, no \`fetch\`, no \`eval\`.
|
|
52
|
+
- **\`contract\`** is the same object \`defineContract({ ... } as const)\`
|
|
53
|
+
produces in path-(a) generation. Pass the literal — \`defineContract\`
|
|
54
|
+
is a TypeScript-only inference helper, not a runtime transform.
|
|
55
|
+
- **\`fixtureProps\`** is informational for the probe. It does NOT ride
|
|
56
|
+
onto the persisted blueprint — the user's runtime data fills props
|
|
57
|
+
at render time.
|
|
58
|
+
|
|
59
|
+
## Composition workflow
|
|
60
|
+
|
|
61
|
+
1. Call \`ggui_protocol_describe_data_contract_format\` to learn the contract shape.
|
|
62
|
+
2. Compose your contract object.
|
|
63
|
+
3. Call \`ggui_protocol_get_blueprint_boilerplate({ contract, intent?, shell?, screen? })\`
|
|
64
|
+
for a typed scaffold.
|
|
65
|
+
4. Modify the source for user intent.
|
|
66
|
+
5. Call \`ggui_protocol_validate_blueprint({ source, contract, fixtureProps? })\` —
|
|
67
|
+
iterate until \`valid: true\`.
|
|
68
|
+
6. Call \`ggui_ops_generate_blueprint({ name, blueprint, description?, tags? })\`.
|
|
69
|
+
|
|
70
|
+
## Validation tiers
|
|
71
|
+
|
|
72
|
+
\`ggui_protocol_validate_blueprint\` runs three tiers in order, short-circuiting on
|
|
73
|
+
the first failure:
|
|
74
|
+
|
|
75
|
+
| Tier | Check | What fails |
|
|
76
|
+
|------|-------|------------|
|
|
77
|
+
| 1 | \`compile\` | esbuild transform — syntax / import errors |
|
|
78
|
+
| 2 | \`selfCheck\` | default-export presence + prop coverage |
|
|
79
|
+
| 3 | \`runtime\` | happy-dom probe — action wiring, tool calls, prop usage |
|
|
80
|
+
|
|
81
|
+
Read \`failedAt\` on the result to know which tier stopped.`;
|
|
82
|
+
const EXAMPLE = {
|
|
83
|
+
source: `import { Card, Stack, Text, Button } from '@ggui-ai/design/primitives';
|
|
84
|
+
import { useAction } from '@ggui-ai/wire';
|
|
85
|
+
|
|
86
|
+
interface Props {
|
|
87
|
+
greeting: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default function Hello(props: Props) {
|
|
91
|
+
const dismiss = useAction<void>('dismiss');
|
|
92
|
+
return (
|
|
93
|
+
<Card>
|
|
94
|
+
<Stack gap={2}>
|
|
95
|
+
<Text size="lg">{props.greeting}</Text>
|
|
96
|
+
<Button onClick={() => dismiss()}>Dismiss</Button>
|
|
97
|
+
</Stack>
|
|
98
|
+
</Card>
|
|
99
|
+
);
|
|
100
|
+
}`,
|
|
101
|
+
contract: {
|
|
102
|
+
propsSpec: {
|
|
103
|
+
properties: {
|
|
104
|
+
greeting: {
|
|
105
|
+
schema: { type: 'string' },
|
|
106
|
+
required: true,
|
|
107
|
+
description: 'Salutation text shown in the card.',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
actionSpec: {
|
|
112
|
+
dismiss: {
|
|
113
|
+
label: 'Dismiss',
|
|
114
|
+
description: 'User dismissed the greeting.',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
fixtureProps: {
|
|
119
|
+
greeting: 'Hello, world',
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
export function createDescribeBlueprintFormatHandler() {
|
|
123
|
+
return {
|
|
124
|
+
name: 'ggui_protocol_describe_blueprint_format',
|
|
125
|
+
title: 'Describe blueprint format',
|
|
126
|
+
audience: ['protocol'],
|
|
127
|
+
description: "Returns the wire-format spec for the AgentBlueprint envelope — the shape `ggui_protocol_validate_blueprint` and `ggui_ops_generate_blueprint` accept. Includes field semantics, the composition workflow (which tools to call in what order), the three validation tiers, and a minimum-viable example. **Call this first** when composing a blueprint in a fresh conversation, alongside `ggui_protocol_describe_data_contract_format` for the contract sub-shape. Tools you'll then call: `ggui_protocol_get_blueprint_boilerplate` (scaffold) → `ggui_protocol_validate_blueprint` (check) → `ggui_ops_generate_blueprint` (save).",
|
|
128
|
+
inputSchema,
|
|
129
|
+
outputSchema,
|
|
130
|
+
async handler() {
|
|
131
|
+
return {
|
|
132
|
+
format: 'AgentBlueprint',
|
|
133
|
+
documentation: DOCUMENTATION,
|
|
134
|
+
example: EXAMPLE,
|
|
135
|
+
};
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ggui_describe_data_contract_format` — wire-format documentation for
|
|
3
|
+
* the DataContract envelope inside an AgentBlueprint.
|
|
4
|
+
*
|
|
5
|
+
* Pure compute, no DDB. Returns markdown explainer + 2-3 examples
|
|
6
|
+
* covering common shapes (display-only / collect-form / chat).
|
|
7
|
+
* Pinning the format server-side guards against contract drift between
|
|
8
|
+
* what Claude composes and what `ggui_protocol_validate_blueprint` expects.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import type { SharedHandler } from '../types.js';
|
|
12
|
+
declare const inputSchema: {};
|
|
13
|
+
declare const outputSchema: {
|
|
14
|
+
format: z.ZodLiteral<"DataContract">;
|
|
15
|
+
documentation: z.ZodString;
|
|
16
|
+
examples: z.ZodArray<z.ZodObject<{
|
|
17
|
+
title: z.ZodString;
|
|
18
|
+
contract: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
19
|
+
}, z.core.$strip>>;
|
|
20
|
+
};
|
|
21
|
+
interface DescribeDataContractFormatOutput {
|
|
22
|
+
readonly format: 'DataContract';
|
|
23
|
+
readonly documentation: string;
|
|
24
|
+
readonly examples: ReadonlyArray<{
|
|
25
|
+
readonly title: string;
|
|
26
|
+
readonly contract: Record<string, unknown>;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
export declare function createDescribeDataContractFormatHandler(): SharedHandler<typeof inputSchema, typeof outputSchema, DescribeDataContractFormatOutput>;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=describe-data-contract-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-data-contract-format.d.ts","sourceRoot":"","sources":["../../src/blueprints/describe-data-contract-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,QAAA,MAAM,WAAW,IAAK,CAAC;AAEvB,QAAA,MAAM,YAAY;;;;;;;CASjB,CAAC;AAEF,UAAU,gCAAgC;IACxC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;QAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAC5C,CAAC,CAAC;CACJ;AAoQD,wBAAgB,uCAAuC,IAAI,aAAa,CACtE,OAAO,WAAW,EAClB,OAAO,YAAY,EACnB,gCAAgC,CACjC,CAiBA"}
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ggui_describe_data_contract_format` — wire-format documentation for
|
|
3
|
+
* the DataContract envelope inside an AgentBlueprint.
|
|
4
|
+
*
|
|
5
|
+
* Pure compute, no DDB. Returns markdown explainer + 2-3 examples
|
|
6
|
+
* covering common shapes (display-only / collect-form / chat).
|
|
7
|
+
* Pinning the format server-side guards against contract drift between
|
|
8
|
+
* what Claude composes and what `ggui_protocol_validate_blueprint` expects.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
const inputSchema = {};
|
|
12
|
+
const outputSchema = {
|
|
13
|
+
format: z.literal('DataContract'),
|
|
14
|
+
documentation: z.string(),
|
|
15
|
+
examples: z.array(z.object({
|
|
16
|
+
title: z.string(),
|
|
17
|
+
contract: z.record(z.string(), z.unknown()),
|
|
18
|
+
})),
|
|
19
|
+
};
|
|
20
|
+
const DOCUMENTATION = `# DataContract format
|
|
21
|
+
|
|
22
|
+
Top-level shape on every blueprint's \`contract\` field:
|
|
23
|
+
|
|
24
|
+
\`\`\`ts
|
|
25
|
+
interface DataContract {
|
|
26
|
+
/** Initial render data — the props the component receives. */
|
|
27
|
+
propsSpec?: PropsSpec;
|
|
28
|
+
|
|
29
|
+
/** User-interaction events — flat map keyed by action name. */
|
|
30
|
+
actionSpec?: ActionSpec;
|
|
31
|
+
|
|
32
|
+
/** Observable client state — flat map keyed by slot name. */
|
|
33
|
+
contextSpec?: ContextSpec;
|
|
34
|
+
|
|
35
|
+
/** Live update payloads — flat map keyed by stream channel name. */
|
|
36
|
+
streamSpec?: StreamSpec;
|
|
37
|
+
|
|
38
|
+
/** Read-only catalog: MCP tools the AGENT may invoke. Referenced
|
|
39
|
+
* from actionSpec[*].nextStep and streamSpec[*].source.tool. The
|
|
40
|
+
* component NEVER calls these. */
|
|
41
|
+
agentCapabilities?: AgentCapabilitiesSpec;
|
|
42
|
+
|
|
43
|
+
/** Read-only catalog: browser-capability gadget hooks the COMPONENT
|
|
44
|
+
* imports (useGeolocation, useCamera, useClipboardWrite, …).
|
|
45
|
+
* Values reach the agent only when threaded into a contextSpec
|
|
46
|
+
* slot or an actionSpec payload. */
|
|
47
|
+
clientCapabilities?: ClientCapabilitiesSpec;
|
|
48
|
+
}
|
|
49
|
+
\`\`\`
|
|
50
|
+
|
|
51
|
+
\`intent\` is NOT a contract field — the outer pipeline owns it
|
|
52
|
+
(top-level \`intent\` on the flat \`ggui_handshake\` input). The
|
|
53
|
+
four-spec surface — propsSpec / actionSpec / contextSpec / streamSpec
|
|
54
|
+
— describes the wire exhaustively. See
|
|
55
|
+
\`docs/principles/actions-vs-context.md\` for the placement rule on
|
|
56
|
+
the two inbound specs.
|
|
57
|
+
|
|
58
|
+
## PropsSpec
|
|
59
|
+
|
|
60
|
+
\`\`\`ts
|
|
61
|
+
interface PropsSpec {
|
|
62
|
+
description?: string;
|
|
63
|
+
properties: Record<string, {
|
|
64
|
+
schema: JsonSchema; // draft-07 subset: type, enum, items, properties
|
|
65
|
+
required?: boolean; // default true
|
|
66
|
+
description?: string;
|
|
67
|
+
default?: JsonValue;
|
|
68
|
+
example?: JsonValue;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
71
|
+
\`\`\`
|
|
72
|
+
|
|
73
|
+
The boilerplate generator turns each \`properties\` entry into a typed
|
|
74
|
+
TypeScript field on \`Props\`. \`required: false\` becomes \`field?:\`.
|
|
75
|
+
\`schema.nullable: true\` becomes \`| null\`.
|
|
76
|
+
|
|
77
|
+
## ActionSpec entry
|
|
78
|
+
|
|
79
|
+
\`\`\`ts
|
|
80
|
+
interface ActionEntry {
|
|
81
|
+
/** Human label — drives button copy / accessibility name. */
|
|
82
|
+
label?: string;
|
|
83
|
+
description?: string;
|
|
84
|
+
/** Optional payload schema. Action with a payload becomes useAction<T>. */
|
|
85
|
+
schema?: JsonSchema;
|
|
86
|
+
/** Optional example payload — surfaces in tool descriptions. */
|
|
87
|
+
example?: JsonValue;
|
|
88
|
+
/** Optional hint: which agentCapabilities.tools entry the agent SHOULD
|
|
89
|
+
* invoke on its next turn after this action fires. Naming the
|
|
90
|
+
* tool here does NOT route the action server-side — every action
|
|
91
|
+
* is agent-routed. The hint surfaces on the action event so the
|
|
92
|
+
* agent picks the right tool. Must appear in agentCapabilities.tools. */
|
|
93
|
+
nextStep?: string;
|
|
94
|
+
}
|
|
95
|
+
\`\`\`
|
|
96
|
+
|
|
97
|
+
In the source, declare with \`const X = useAction<PayloadType>('X')\` and
|
|
98
|
+
fire as \`X(payload)\` (or \`X()\` when payload-less).
|
|
99
|
+
|
|
100
|
+
## StreamSpec entry
|
|
101
|
+
|
|
102
|
+
\`\`\`ts
|
|
103
|
+
interface StreamEntry {
|
|
104
|
+
description?: string;
|
|
105
|
+
/** Payload schema — every emitted event must conform. */
|
|
106
|
+
schema: JsonSchema;
|
|
107
|
+
/** Optional example payload. */
|
|
108
|
+
example?: JsonValue;
|
|
109
|
+
/** Optional source binding: agent-tool name whose deliveries feed
|
|
110
|
+
* this channel (runtime subscribes / polls). Must appear in
|
|
111
|
+
* agentCapabilities.tools. */
|
|
112
|
+
source?: { tool: string };
|
|
113
|
+
}
|
|
114
|
+
\`\`\`
|
|
115
|
+
|
|
116
|
+
In the source, declare with \`const stream = useStream<PayloadType>('channel')\`
|
|
117
|
+
and read latest as \`stream.latest\` or iterate \`stream.history\`.
|
|
118
|
+
|
|
119
|
+
## AgentCapabilitiesSpec entry
|
|
120
|
+
|
|
121
|
+
\`\`\`ts
|
|
122
|
+
interface AgentCapabilitiesSpec {
|
|
123
|
+
tools: Record<string, AgentToolEntry>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface AgentToolEntry {
|
|
127
|
+
description?: string;
|
|
128
|
+
inputSchema?: JsonSchema;
|
|
129
|
+
outputSchema?: JsonSchema;
|
|
130
|
+
usage?: string;
|
|
131
|
+
example?: { input?: JsonValue; output?: JsonValue };
|
|
132
|
+
required?: boolean;
|
|
133
|
+
}
|
|
134
|
+
\`\`\`
|
|
135
|
+
|
|
136
|
+
Pure catalog — declares tools the AGENT may invoke. Referenced from
|
|
137
|
+
\`actionSpec[*].nextStep\` (agent next-turn hint) and
|
|
138
|
+
\`streamSpec[*].source.tool\` (channel data source). The component
|
|
139
|
+
NEVER calls these. Cross-ref linter rejects dangling \`nextStep\` /
|
|
140
|
+
\`source.tool\` values that don't resolve to a key here.
|
|
141
|
+
|
|
142
|
+
## ClientCapabilitiesSpec entry
|
|
143
|
+
|
|
144
|
+
\`\`\`ts
|
|
145
|
+
interface ClientCapabilitiesSpec {
|
|
146
|
+
// Keyed by npm PACKAGE name; each value is a per-package use map.
|
|
147
|
+
gadgets: Record<string, GadgetPackageUse>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// One package's exports the UI uses, keyed by export NAME (>= 1).
|
|
151
|
+
// The export name's grammar discriminates kind: a 'use'-prefixed
|
|
152
|
+
// name is a hook, a PascalCase name is a component. There is no
|
|
153
|
+
// 'hook' / 'component' field and no 'kind' tag.
|
|
154
|
+
type GadgetPackageUse = Record<string, GadgetExportUse>;
|
|
155
|
+
|
|
156
|
+
interface GadgetExportUse {
|
|
157
|
+
/** Intent-specific override of the registered description. */
|
|
158
|
+
description?: string;
|
|
159
|
+
/** Intent-specific override of the registered usage hint. */
|
|
160
|
+
usage?: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Example: a contract that uses one Leaflet component + one stdlib hook
|
|
164
|
+
// gadgets: {
|
|
165
|
+
// '@my-org/leaflet': { LeafletMap: {} },
|
|
166
|
+
// '@ggui-ai/gadgets': { useGeolocation: {} },
|
|
167
|
+
// }
|
|
168
|
+
\`\`\`
|
|
169
|
+
|
|
170
|
+
The wire carries IDENTITY ONLY — \`(package, export name)\`. It does
|
|
171
|
+
NOT carry \`version\`: the operator's \`App.gadgets\` catalog owns the
|
|
172
|
+
version pin. Per-export registry metadata (\`permission\`, \`example\`,
|
|
173
|
+
the \`required\` flag) and transport fields (\`bundleUrl\`,
|
|
174
|
+
\`bundleSri\`, …) likewise live on the operator-registered gadget
|
|
175
|
+
package descriptor — NOT on the wire. The renderer resolves them
|
|
176
|
+
server-side from the app's gadget catalog at push time (e.g. a hook's
|
|
177
|
+
browser \`permission\` flows into the iframe's Permissions-Policy
|
|
178
|
+
directive set from there).
|
|
179
|
+
|
|
180
|
+
Pure declaration — items are React hooks the UI imports + calls. Pure
|
|
181
|
+
UI-side lifecycle; the agent never invokes them. Values reach the
|
|
182
|
+
agent only when threaded into a contextSpec slot or actionSpec
|
|
183
|
+
payload.
|
|
184
|
+
|
|
185
|
+
## defineContract helper (TypeScript only)
|
|
186
|
+
|
|
187
|
+
\`\`\`ts
|
|
188
|
+
import { defineContract } from '@ggui-ai/protocol';
|
|
189
|
+
|
|
190
|
+
export const myContract = defineContract({
|
|
191
|
+
propsSpec: { ... },
|
|
192
|
+
actionSpec: { ... },
|
|
193
|
+
} as const);
|
|
194
|
+
\`\`\`
|
|
195
|
+
|
|
196
|
+
\`defineContract\` is a TypeScript-only helper — at runtime it returns
|
|
197
|
+
its argument unchanged. Always pair with \`as const\` so prop+action
|
|
198
|
+
names propagate as literal-typed strings into \`useAction<T>(name)\` and
|
|
199
|
+
\`useStream<T>(name)\` for autocomplete on the consumer side.`;
|
|
200
|
+
const EXAMPLES = [
|
|
201
|
+
{
|
|
202
|
+
title: 'Display-only — no actions, no stream',
|
|
203
|
+
contract: {
|
|
204
|
+
propsSpec: {
|
|
205
|
+
properties: {
|
|
206
|
+
city: { schema: { type: 'string' }, required: true },
|
|
207
|
+
tempC: { schema: { type: 'number' }, required: true },
|
|
208
|
+
condition: {
|
|
209
|
+
schema: { type: 'string', enum: ['sunny', 'cloudy', 'rainy'] },
|
|
210
|
+
required: true,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
title: 'Collect-form — props + submit action with payload',
|
|
218
|
+
contract: {
|
|
219
|
+
propsSpec: {
|
|
220
|
+
properties: {
|
|
221
|
+
placeholder: { schema: { type: 'string' }, required: false, default: 'New task' },
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
actionSpec: {
|
|
225
|
+
submit: {
|
|
226
|
+
label: 'Add task',
|
|
227
|
+
description: 'User submitted a new task title.',
|
|
228
|
+
schema: {
|
|
229
|
+
type: 'object',
|
|
230
|
+
properties: { title: { type: 'string' } },
|
|
231
|
+
required: ['title'],
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
cancel: {
|
|
235
|
+
label: 'Cancel',
|
|
236
|
+
description: 'User dismissed without submitting.',
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
title: 'Live chat — initial messages prop + stream + send action',
|
|
243
|
+
contract: {
|
|
244
|
+
propsSpec: {
|
|
245
|
+
properties: {
|
|
246
|
+
messages: {
|
|
247
|
+
schema: {
|
|
248
|
+
type: 'array',
|
|
249
|
+
items: {
|
|
250
|
+
type: 'object',
|
|
251
|
+
properties: {
|
|
252
|
+
role: { type: 'string', enum: ['user', 'agent'] },
|
|
253
|
+
text: { type: 'string' },
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
required: true,
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
streamSpec: {
|
|
262
|
+
agentReply: {
|
|
263
|
+
description: 'Token-by-token agent response.',
|
|
264
|
+
schema: { type: 'object', properties: { delta: { type: 'string' } } },
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
actionSpec: {
|
|
268
|
+
send: {
|
|
269
|
+
label: 'Send',
|
|
270
|
+
schema: { type: 'object', properties: { text: { type: 'string' } } },
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
];
|
|
276
|
+
export function createDescribeDataContractFormatHandler() {
|
|
277
|
+
return {
|
|
278
|
+
name: 'ggui_protocol_describe_data_contract_format',
|
|
279
|
+
title: 'Describe data contract format',
|
|
280
|
+
audience: ['protocol'],
|
|
281
|
+
description: "Returns the wire-format spec for the DataContract envelope — the `contract` field inside an AgentBlueprint. Covers PropsSpec / ActionSpec / StreamSpec / AgentCapabilitiesSpec / ClientCapabilitiesSpec sub-shapes, the `defineContract({...} as const)` TypeScript helper, and three worked examples (display-only / collect-form / converse-stream). Call this alongside `ggui_protocol_describe_blueprint_format` when composing a blueprint in a fresh conversation. Then call `ggui_protocol_get_blueprint_boilerplate({ contract })` for a typed scaffold.",
|
|
282
|
+
inputSchema,
|
|
283
|
+
outputSchema,
|
|
284
|
+
async handler() {
|
|
285
|
+
return {
|
|
286
|
+
format: 'DataContract',
|
|
287
|
+
documentation: DOCUMENTATION,
|
|
288
|
+
examples: EXAMPLES,
|
|
289
|
+
};
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ggui_get_blueprint_boilerplate` — scaffolded TSX source tailored to a
|
|
3
|
+
* caller-supplied DataContract. A composition aid for agents that
|
|
4
|
+
* author UI source by hand.
|
|
5
|
+
*
|
|
6
|
+
* Pure compute, no database, no network. Wraps `generateBoilerplate`
|
|
7
|
+
* from `@ggui-ai/ui-gen/boilerplate` — the same composer the
|
|
8
|
+
* generation pipeline uses internally for first-attempt scaffolding
|
|
9
|
+
* (`buildSystemPrompt` relies on the same primitive). Returns a
|
|
10
|
+
* `.tsx` string that compiles
|
|
11
|
+
* out of the box: typed `Props` derived from `contract.propsSpec`, action
|
|
12
|
+
* handler stubs from `contract.actionSpec`, stream wiring from
|
|
13
|
+
* `contract.streamSpec`, and primitives pre-imported.
|
|
14
|
+
*
|
|
15
|
+
* Workflow guidance lives in the tool description — Claude is expected
|
|
16
|
+
* to call this AFTER `ggui_validate_data_contract` (when that ships in
|
|
17
|
+
* the next sub-slice) and BEFORE `ggui_protocol_validate_blueprint`. The contract
|
|
18
|
+
* is the load-bearing input: a richer contract → a more complete scaffold.
|
|
19
|
+
*/
|
|
20
|
+
import { z } from 'zod';
|
|
21
|
+
import type { SharedHandler } from '../types.js';
|
|
22
|
+
declare const inputSchema: {
|
|
23
|
+
contract: z.ZodUnknown;
|
|
24
|
+
intent: z.ZodOptional<z.ZodString>;
|
|
25
|
+
shell: z.ZodDefault<z.ZodEnum<{
|
|
26
|
+
chat: "chat";
|
|
27
|
+
fullscreen: "fullscreen";
|
|
28
|
+
spatial: "spatial";
|
|
29
|
+
}>>;
|
|
30
|
+
screen: z.ZodDefault<z.ZodEnum<{
|
|
31
|
+
mobile: "mobile";
|
|
32
|
+
tablet: "tablet";
|
|
33
|
+
desktop: "desktop";
|
|
34
|
+
universal: "universal";
|
|
35
|
+
}>>;
|
|
36
|
+
};
|
|
37
|
+
declare const outputSchema: {
|
|
38
|
+
source: z.ZodString;
|
|
39
|
+
};
|
|
40
|
+
interface GetBlueprintBoilerplateOutput {
|
|
41
|
+
readonly source: string;
|
|
42
|
+
}
|
|
43
|
+
export declare function createGetBlueprintBoilerplateHandler(): SharedHandler<typeof inputSchema, typeof outputSchema, GetBlueprintBoilerplateOutput>;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=get-blueprint-boilerplate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-blueprint-boilerplate.d.ts","sourceRoot":"","sources":["../../src/blueprints/get-blueprint-boilerplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;CAwBhB,CAAC;AAEF,QAAA,MAAM,YAAY;;CAEjB,CAAC;AAEF,UAAU,6BAA6B;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,oCAAoC,IAAI,aAAa,CACnE,OAAO,WAAW,EAClB,OAAO,YAAY,EACnB,6BAA6B,CAC9B,CAqBA"}
|