@particle-academy/agent-integrations 0.48.0 → 0.50.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +45 -0
  3. package/dist/bridges/screens.d.cts +36 -5
  4. package/dist/bridges/screens.d.ts +36 -5
  5. package/dist/bridges-catalog.cjs +24 -8
  6. package/dist/bridges-catalog.cjs.map +1 -1
  7. package/dist/bridges-catalog.js +1 -1
  8. package/dist/bridges-features.cjs +10 -6
  9. package/dist/bridges-features.cjs.map +1 -1
  10. package/dist/bridges-features.js +1 -1
  11. package/dist/bridges-navigation.cjs +4 -4
  12. package/dist/bridges-navigation.cjs.map +1 -1
  13. package/dist/bridges-navigation.js +1 -1
  14. package/dist/bridges-passkeys.cjs +6 -2
  15. package/dist/bridges-passkeys.cjs.map +1 -1
  16. package/dist/bridges-passkeys.js +1 -1
  17. package/dist/bridges-screens.cjs +71 -17
  18. package/dist/bridges-screens.cjs.map +1 -1
  19. package/dist/bridges-screens.js +1 -1
  20. package/dist/{chunk-G6CRHFWU.js → chunk-4WVLZ6YP.js} +8 -4
  21. package/dist/chunk-4WVLZ6YP.js.map +1 -0
  22. package/dist/{chunk-GVTBMJU6.js → chunk-5M5ELTHE.js} +12 -8
  23. package/dist/chunk-5M5ELTHE.js.map +1 -0
  24. package/dist/{chunk-OHNGURUJ.js → chunk-BG3QXNM6.js} +6 -6
  25. package/dist/chunk-BG3QXNM6.js.map +1 -0
  26. package/dist/{chunk-7NVATRLE.js → chunk-HOZCDDRA.js} +74 -19
  27. package/dist/chunk-HOZCDDRA.js.map +1 -0
  28. package/dist/{chunk-CS3CHGYC.js → chunk-NH6HUVXQ.js} +26 -10
  29. package/dist/chunk-NH6HUVXQ.js.map +1 -0
  30. package/dist/index.cjs +123 -44
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +1 -1
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js +6 -6
  35. package/package.json +2 -2
  36. package/dist/chunk-7NVATRLE.js.map +0 -1
  37. package/dist/chunk-CS3CHGYC.js.map +0 -1
  38. package/dist/chunk-G6CRHFWU.js.map +0 -1
  39. package/dist/chunk-GVTBMJU6.js.map +0 -1
  40. package/dist/chunk-OHNGURUJ.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/bridges/catalog.ts"],"names":[],"mappings":";;;;;AAkHA,IAAM,gBAAgB,EAAE,EAAA,EAAI,SAAS,IAAA,EAAM,OAAA,EAAS,OAAO,SAAA,EAAU;AAErE,IAAM,GAAA,GAAM,CAAC,CAAA,EAAY,QAAA,GAAW,OAAgB,OAAO,CAAA,KAAM,WAAW,CAAA,GAAI,QAAA;AAChF,IAAM,GAAA,GAAM,CAAC,CAAA,EAAY,QAAA,GAAW,CAAA,KAAe,OAAO,CAAA,KAAM,QAAA,IAAY,MAAA,CAAO,QAAA,CAAS,CAAC,CAAA,GAAI,CAAA,GAAI,QAAA;AAmB9F,SAAS,qBAAA,CAAsB,MAAgB,OAAA,EAAuC;AAC3F,EAAA,MAAM,EAAE,SAAQ,GAAI,OAAA;AACpB,EAAA,MAAM,KAAA,GAAQ,EAAE,GAAG,aAAA,EAAe,GAAI,OAAA,CAAQ,KAAA,IAAS,EAAC,EAAG;AAC3D,EAAA,MAAM,WAAA,GAAc,QAAQ,WAAA,IAAe,IAAA;AAC3C,EAAA,MAAM,SAAA,GAAY,QAAQ,EAAA,IAAM,SAAA;AAChC,EAAA,MAAM,YAA+B,EAAC;AAEtC,EAAA,yBAAA,CAA0B,IAAA,EAAM,EAAE,cAAA,EAAgB,KAAA,CAAM,IAAI,CAAA;AAE5D,EAAA,MAAM,MAAA,GAAS,CAAC,SAAA,EAAoB,KAAA,MAAiC;AAAA,IACnE,IAAA,EAAM,QAAA;AAAA,IACN,UAAU,OAAA,CAAQ,QAAA;AAAA,IAClB,SAAA;AAAA,IACA,OAAO,KAAA,IAAS;AAAA,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AAA,EAAG,CAAA,SAAA,EAAY,GAAA,CAAI,IAAA,CAAK,OAAO,CAAC,CAAA,CAAE;AAAA,GACrE;AAEA,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,WAAW,SAAS,CAAA,CAAA;AAAA,IACxB,KAAA,EAAO,QAAQ,KAAA,IAAS,SAAA;AAAA,IACxB,SAAS,MAAM;AACb,MAAA,KAAA,MAAW,CAAA,IAAK,SAAA,CAAU,MAAA,CAAO,CAAC,GAAG,CAAA,EAAE;AAAA,IACzC;AAAA,GACF;AACF","file":"chunk-NH6HUVXQ.js","sourcesContent":["import { textResult, errorResult } from \"../mcp/server\";\nimport type { ToolHost } from \"../mcp/tool-host\";\nimport type { JsonObject } from \"../mcp/types\";\nimport type { Bridge } from \"./types\";\nimport { wrapToolWithActivity } from \"../presence/wrap-tool-with-activity\";\nimport type { AgentTarget } from \"../presence/types\";\nimport { pushUndoEntry } from \"../undo/undo-stack\";\nimport { ensureUndoToolsRegistered } from \"../undo/undo-tools\";\n\n/**\n * Headless bridge for `@particle-academy/fancy-catalog` — a Stripe catalog with\n * NO UI surface. The adapter exposes the catalog's STORES + operations (not UI\n * getters/setters), and the tools are CRUD over products / prices + checkout +\n * Stripe sync. Mutations still funnel through `wrapToolWithActivity` so presence\n * + undo compose, and the destructive delete is `pendingMode`-gated.\n *\n * The adapter shapes below are STRUCTURAL mirrors of fancy-catalog's public\n * `Catalog` + store interfaces, defined LOCALLY so this bridge builds with the\n * sibling package absent (it's an optional peer). A real `Catalog` instance is\n * assignable to `CatalogBridgeAdapter` with no import — TypeScript is structural.\n */\n\n/** Minimal product shape crossing the MCP wire (mirror of fancy-catalog `Product`). */\nexport type CatalogProduct = {\n id: string;\n name: string;\n description?: string | null;\n active?: boolean;\n lookupKey?: string | null;\n externalId?: string | null;\n metadata?: Record<string, unknown> | null;\n [k: string]: unknown;\n};\n\n/** Minimal price shape crossing the MCP wire (mirror of fancy-catalog `Price`). */\nexport type CatalogPrice = {\n id: string;\n productId: string;\n active?: boolean;\n currency: string;\n unitAmount: number;\n type: \"recurring\" | \"one_time\";\n externalId?: string | null;\n [k: string]: unknown;\n};\n\n/** Common checkout args (mirror of fancy-catalog `CheckoutArgs`). */\nexport type CatalogCheckoutArgs = {\n customer?: string;\n successUrl: string;\n cancelUrl: string;\n metadata?: Record<string, string>;\n /** One-time checkouts only. */\n quantity?: number;\n};\n\n/**\n * Adapter = the catalog instance / stores. A live `Catalog` from fancy-catalog\n * satisfies this directly (`catalog.products`, `catalog.createProduct`, …); a\n * host can also hand-roll one over its own persistence.\n */\nexport type CatalogBridgeAdapter = {\n /** Stable id for this catalog instance (multiple catalogs ⇒ distinct ids). */\n id?: string;\n /** Display label for logs / presence. */\n title?: string;\n /** Optional fancy-screens screen id (usually unset — this is headless). */\n screenId?: string;\n\n /** Product store — `catalog.products`. */\n products: {\n find(id: string, opts?: { withTrashed?: boolean }): CatalogProduct | null | Promise<CatalogProduct | null>;\n all(opts?: { withTrashed?: boolean }): CatalogProduct[] | Promise<CatalogProduct[]>;\n remove(id: string): void | Promise<void>;\n };\n /** Price store — `catalog.prices`. */\n prices: {\n find(id: string, opts?: { withTrashed?: boolean }): CatalogPrice | null | Promise<CatalogPrice | null>;\n forProduct(productId: string, opts?: { withTrashed?: boolean }): CatalogPrice[] | Promise<CatalogPrice[]>;\n all(opts?: { withTrashed?: boolean }): CatalogPrice[] | Promise<CatalogPrice[]>;\n remove(id: string): void | Promise<void>;\n };\n\n /** Authoring helpers — `catalog.createProduct` / `catalog.createPrice` (ULIDs auto-assigned). */\n createProduct(input: Partial<CatalogProduct> & { name: string }): Promise<CatalogProduct> | CatalogProduct;\n createPrice(\n input: Partial<CatalogPrice> & { productId: string; currency: string; unitAmount: number; type: \"recurring\" | \"one_time\" },\n ): Promise<CatalogPrice> | CatalogPrice;\n\n /** Stripe sync — `catalog.syncProductAndPrices`. Optional (no-op when absent). */\n syncProductAndPrices?(product: CatalogProduct): Promise<CatalogProduct> | CatalogProduct;\n /** Connection test — `catalog.testConnection`. Optional. */\n testConnection?(): Promise<{ success: boolean; message: string; productCount?: number }> | { success: boolean; message: string; productCount?: number };\n\n /** Hosted Checkout — `catalog.getSubscriptionCheckoutUrl` / `getOneTimeCheckoutUrl`. Optional. */\n getSubscriptionCheckoutUrl?(price: CatalogPrice, args: CatalogCheckoutArgs): Promise<string> | string;\n getOneTimeCheckoutUrl?(price: CatalogPrice, args: CatalogCheckoutArgs): Promise<string> | string;\n};\n\nexport type CatalogBridgeOptions = {\n adapter: CatalogBridgeAdapter;\n /** Identity stamped on activity + undo entries. */\n agent?: { id: string; name?: string; color?: string };\n /**\n * Trust-but-verify. When on (default), destructive ops (`catalog_delete_product`,\n * `catalog_delete_price`) route through `adapter`-less staging: they require an\n * explicit `confirm: true` arg OR a host `confirm` callback. Read + create +\n * checkout-url tools are unaffected.\n */\n pendingMode?: boolean;\n /** Host confirm hook for destructive ops (pendingMode). Resolves true to proceed. */\n confirm?: (req: { action: string; id: string; label: string }) => Promise<boolean> | boolean;\n};\n\nconst DEFAULT_AGENT = { id: \"agent\", name: \"Agent\", color: \"#a855f7\" };\n\nconst str = (v: unknown, fallback = \"\"): string => (typeof v === \"string\" ? v : fallback);\nconst num = (v: unknown, fallback = 0): number => (typeof v === \"number\" && Number.isFinite(v) ? v : fallback);\n\n/**\n * registerCatalogBridge — full MCP tool set over a headless Stripe catalog.\n *\n * catalog_list_products list products ({ id, name, active, priceCount })\n * catalog_get_product full product JSON + its prices\n * catalog_create_product create a product (ULID auto-assigned)\n * catalog_delete_product soft-delete a product (pendingMode-gated, undoable*)\n * catalog_list_prices list a product's prices (or all)\n * catalog_create_price create a price under a product\n * catalog_delete_price soft-delete a price (pendingMode-gated)\n * catalog_sync_product push a product + its prices to Stripe\n * catalog_test_connection verify the Stripe connection\n * catalog_create_checkout build a hosted Checkout URL for a price\n *\n * *delete undo is best-effort: stores expose soft-delete (`remove`) but no\n * un-delete, so the undo closure re-creates from the captured snapshot.\n */\nexport function registerCatalogBridge(host: ToolHost, options: CatalogBridgeOptions): Bridge {\n const { adapter } = options;\n const agent = { ...DEFAULT_AGENT, ...(options.agent ?? {}) };\n const pendingMode = options.pendingMode ?? true;\n const catalogId = adapter.id ?? \"catalog\";\n const disposers: Array<() => void> = [];\n\n ensureUndoToolsRegistered(host, { defaultAgentId: agent.id });\n\n const target = (elementId?: string, label?: string): AgentTarget => ({\n kind: \"custom\",\n screenId: adapter.screenId,\n elementId,\n label: label ?? catalogId,\n });\n\n const reg = (\n name: string,\n description: string,\n properties: Record<string, unknown>,\n required: string[],\n handler: (args: JsonObject) => Promise<unknown> | unknown,\n resolveTarget: false | ((args: JsonObject) => AgentTarget),\n ) => {\n const wrapped = async (args: JsonObject) => {\n try {\n return await handler(args);\n } catch (e) {\n return errorResult(e instanceof Error ? e.message : String(e));\n }\n };\n const final = resolveTarget\n ? wrapToolWithActivity(wrapped as never, {\n toolName: name,\n agent,\n kind: \"custom\",\n screenId: adapter.screenId,\n resolveTarget: ({ args }) => resolveTarget(args as JsonObject),\n })\n : wrapped;\n disposers.push(\n host.registerTool(\n { name, description, inputSchema: { type: \"object\", properties: properties as Record<string, never>, required, additionalProperties: false } },\n final as never,\n ),\n );\n };\n\n /** Stage a destructive op behind the human (pendingMode). Returns null to proceed, or an errorResult to block. */\n const guardDestructive = async (action: string, id: string, label: string, hasConfirmArg: boolean) => {\n if (!pendingMode) return null;\n if (options.confirm) {\n const ok = await options.confirm({ action, id, label });\n return ok ? null : errorResult(`Declined: ${action} ${id} (human did not confirm).`);\n }\n // No host confirm hook → require an explicit confirm:true arg as the staged ack.\n if (!hasConfirmArg) {\n return errorResult(`${action} is staged (pendingMode). Re-call with confirm:true to apply, or wire a host confirm hook.`);\n }\n return null;\n };\n\n // ─── Read tools ──────────────────────────────────────────────────────────\n\n reg(\n \"catalog_list_products\",\n \"List products: { id, name, active, lookupKey, priceCount }. Pass withTrashed:true to include soft-deleted.\",\n { withTrashed: { type: \"boolean\" } },\n [],\n async (args) => {\n const products = await adapter.products.all({ withTrashed: args.withTrashed === true });\n const list = await Promise.all(\n products.map(async (p) => ({\n id: p.id,\n name: p.name,\n active: p.active ?? true,\n lookupKey: p.lookupKey ?? null,\n priceCount: (await adapter.prices.forProduct(p.id)).length,\n })),\n );\n return textResult(JSON.stringify(list, null, 2), list);\n },\n false,\n );\n\n reg(\n \"catalog_get_product\",\n \"Read a product's full JSON plus its prices.\",\n { id: { type: \"string\" }, withTrashed: { type: \"boolean\" } },\n [\"id\"],\n async (args) => {\n const id = str(args.id);\n const product = await adapter.products.find(id, { withTrashed: args.withTrashed === true });\n if (!product) return errorResult(`No product with id ${id}`);\n const prices = await adapter.prices.forProduct(id, { withTrashed: args.withTrashed === true });\n const out = { product, prices };\n return textResult(JSON.stringify(out, null, 2), out);\n },\n false,\n );\n\n reg(\n \"catalog_list_prices\",\n \"List prices for a product (pass productId), or every price (omit it).\",\n { productId: { type: \"string\" }, withTrashed: { type: \"boolean\" } },\n [],\n async (args) => {\n const withTrashed = args.withTrashed === true;\n const prices = args.productId !== undefined\n ? await adapter.prices.forProduct(str(args.productId), { withTrashed })\n : await adapter.prices.all({ withTrashed });\n const list = prices.map((p) => ({\n id: p.id,\n productId: p.productId,\n currency: p.currency,\n unitAmount: p.unitAmount,\n type: p.type,\n active: p.active ?? true,\n externalId: p.externalId ?? null,\n }));\n return textResult(JSON.stringify(list, null, 2), list);\n },\n false,\n );\n\n // ─── Create tools ────────────────────────────────────────────────────────\n\n reg(\n \"catalog_create_product\",\n \"Create a product. `name` is required; id (ULID) is auto-assigned. Returns the created product.\",\n {\n name: { type: \"string\" },\n description: { type: \"string\" },\n active: { type: \"boolean\" },\n lookupKey: { type: \"string\" },\n metadata: { type: \"object\" },\n },\n [\"name\"],\n async (args) => {\n const name = str(args.name);\n if (!name) return errorResult(\"name is required.\");\n const product = await adapter.createProduct({\n name,\n ...(args.description !== undefined ? { description: str(args.description) } : {}),\n ...(args.active !== undefined ? { active: args.active === true } : {}),\n ...(args.lookupKey !== undefined ? { lookupKey: str(args.lookupKey) } : {}),\n ...(args.metadata && typeof args.metadata === \"object\" ? { metadata: args.metadata as Record<string, unknown> } : {}),\n });\n pushUndoEntry(agent.id, {\n timestamp: Date.now(),\n bridgeId: catalogId,\n action: \"catalog_create_product\",\n label: `Created product ${product.id} (${product.name})`,\n undo: async () => { await adapter.products.remove(product.id); },\n redo: async () => { await adapter.createProduct({ ...product }); },\n });\n return textResult(`Created product ${product.id} (${product.name})`, product);\n },\n (args) => target(undefined, `create product ${str(args.name)}`),\n );\n\n reg(\n \"catalog_create_price\",\n \"Create a price under a product. unitAmount is integer minor units (cents). type is 'recurring' | 'one_time'.\",\n {\n productId: { type: \"string\" },\n currency: { type: \"string\", description: \"ISO-4217, e.g. 'USD'.\" },\n unitAmount: { type: \"number\", description: \"Price in cents.\" },\n type: { type: \"string\", enum: [\"recurring\", \"one_time\"] },\n recurringInterval: { type: \"string\", description: \"'month' | 'year' | … (recurring only).\" },\n nickname: { type: \"string\" },\n lookupKey: { type: \"string\" },\n metadata: { type: \"object\" },\n },\n [\"productId\", \"currency\", \"unitAmount\", \"type\"],\n async (args) => {\n const productId = str(args.productId);\n const product = await adapter.products.find(productId);\n if (!product) return errorResult(`No product with id ${productId}`);\n const type = str(args.type) as \"recurring\" | \"one_time\";\n if (type !== \"recurring\" && type !== \"one_time\") return errorResult(\"type must be 'recurring' or 'one_time'.\");\n const price = await adapter.createPrice({\n productId,\n currency: str(args.currency),\n unitAmount: num(args.unitAmount),\n type,\n ...(args.recurringInterval !== undefined ? { recurringInterval: str(args.recurringInterval) } : {}),\n ...(args.nickname !== undefined ? { nickname: str(args.nickname) } : {}),\n ...(args.lookupKey !== undefined ? { lookupKey: str(args.lookupKey) } : {}),\n ...(args.metadata && typeof args.metadata === \"object\" ? { metadata: args.metadata as Record<string, unknown> } : {}),\n });\n pushUndoEntry(agent.id, {\n timestamp: Date.now(),\n bridgeId: catalogId,\n action: \"catalog_create_price\",\n label: `Created price ${price.id} on ${productId}`,\n undo: async () => { await adapter.prices.remove(price.id); },\n redo: async () => { await adapter.createPrice({ ...price }); },\n });\n return textResult(`Created ${type} price ${price.id} on ${productId}`, price);\n },\n (args) => target(str(args.productId), `create price on ${str(args.productId)}`),\n );\n\n // ─── Destructive tools (pendingMode-gated) ───────────────────────────────\n\n reg(\n \"catalog_delete_product\",\n \"Soft-delete a product (preserves financial history). Staged in pendingMode — pass confirm:true or wire a host confirm hook.\",\n { id: { type: \"string\" }, confirm: { type: \"boolean\" } },\n [\"id\"],\n async (args) => {\n const id = str(args.id);\n const product = await adapter.products.find(id, { withTrashed: true });\n if (!product) return errorResult(`No product with id ${id}`);\n const blocked = await guardDestructive(\"catalog_delete_product\", id, product.name, args.confirm === true);\n if (blocked) return blocked;\n const snapshot = { ...product };\n await adapter.products.remove(id);\n pushUndoEntry(agent.id, {\n timestamp: Date.now(),\n bridgeId: catalogId,\n action: \"catalog_delete_product\",\n label: `Deleted product ${id} (${product.name})`,\n undo: async () => { await adapter.createProduct({ ...snapshot }); },\n redo: async () => { await adapter.products.remove(id); },\n });\n return textResult(`Deleted product ${id}`, { id });\n },\n (args) => target(str(args.id), `delete product ${str(args.id)}`),\n );\n\n reg(\n \"catalog_delete_price\",\n \"Soft-delete a price (mirrors Stripe archiving). Staged in pendingMode — pass confirm:true or wire a host confirm hook.\",\n { id: { type: \"string\" }, confirm: { type: \"boolean\" } },\n [\"id\"],\n async (args) => {\n const id = str(args.id);\n const price = await adapter.prices.find(id, { withTrashed: true });\n if (!price) return errorResult(`No price with id ${id}`);\n const blocked = await guardDestructive(\"catalog_delete_price\", id, id, args.confirm === true);\n if (blocked) return blocked;\n const snapshot = { ...price };\n await adapter.prices.remove(id);\n pushUndoEntry(agent.id, {\n timestamp: Date.now(),\n bridgeId: catalogId,\n action: \"catalog_delete_price\",\n label: `Deleted price ${id}`,\n undo: async () => { await adapter.createPrice({ ...snapshot }); },\n redo: async () => { await adapter.prices.remove(id); },\n });\n return textResult(`Deleted price ${id}`, { id });\n },\n (args) => target(str(args.id), `delete price ${str(args.id)}`),\n );\n\n // ─── Stripe sync ─────────────────────────────────────────────────────────\n\n reg(\n \"catalog_sync_product\",\n \"Push a product + its prices to Stripe (creates/updates the Stripe Product + Prices, stamps external ids).\",\n { id: { type: \"string\" } },\n [\"id\"],\n async (args) => {\n if (!adapter.syncProductAndPrices) return errorResult(\"Host did not wire Stripe sync.\");\n const id = str(args.id);\n const product = await adapter.products.find(id);\n if (!product) return errorResult(`No product with id ${id}`);\n const synced = await adapter.syncProductAndPrices(product);\n return textResult(`Synced product ${id} to Stripe (${synced.externalId ?? \"no external id\"})`, synced);\n },\n (args) => target(str(args.id), `sync product ${str(args.id)}`),\n );\n\n reg(\n \"catalog_test_connection\",\n \"Verify the Stripe connection — returns { success, message, productCount? }.\",\n {},\n [],\n async () => {\n if (!adapter.testConnection) return errorResult(\"Host did not wire a Stripe connection test.\");\n const result = await adapter.testConnection();\n return textResult(JSON.stringify(result, null, 2), result);\n },\n false,\n );\n\n // ─── Checkout ────────────────────────────────────────────────────────────\n\n reg(\n \"catalog_create_checkout\",\n \"Build a hosted Stripe Checkout URL for a price. Recurring prices → subscription; one-time → payment (pass quantity). Requires the price be synced to Stripe first.\",\n {\n priceId: { type: \"string\" },\n successUrl: { type: \"string\" },\n cancelUrl: { type: \"string\" },\n customer: { type: \"string\", description: \"Stripe customer id (optional — Checkout collects one if omitted).\" },\n quantity: { type: \"number\", description: \"One-time checkouts only. Default 1.\" },\n metadata: { type: \"object\" },\n },\n [\"priceId\", \"successUrl\", \"cancelUrl\"],\n async (args) => {\n const priceId = str(args.priceId);\n const price = await adapter.prices.find(priceId);\n if (!price) return errorResult(`No price with id ${priceId}`);\n const checkoutArgs: CatalogCheckoutArgs = {\n successUrl: str(args.successUrl),\n cancelUrl: str(args.cancelUrl),\n ...(args.customer !== undefined ? { customer: str(args.customer) } : {}),\n ...(args.metadata && typeof args.metadata === \"object\" ? { metadata: args.metadata as Record<string, string> } : {}),\n };\n let url: string;\n if (price.type === \"recurring\") {\n if (!adapter.getSubscriptionCheckoutUrl) return errorResult(\"Host did not wire subscription checkout.\");\n url = await adapter.getSubscriptionCheckoutUrl(price, checkoutArgs);\n } else {\n if (!adapter.getOneTimeCheckoutUrl) return errorResult(\"Host did not wire one-time checkout.\");\n url = await adapter.getOneTimeCheckoutUrl(price, { ...checkoutArgs, quantity: num(args.quantity, 1) });\n }\n return textResult(url || \"(no url)\", { priceId, type: price.type, url });\n },\n (args) => target(str(args.priceId), `checkout ${str(args.priceId)}`),\n );\n\n return {\n id: `catalog:${catalogId}`,\n title: adapter.title ?? \"Catalog\",\n dispose: () => {\n for (const d of disposers.splice(0)) d();\n },\n };\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1460,7 +1460,7 @@ function registerGridBridge(host, options) {
1460
1460
  throw new Error(`Unknown column "${id}". Available: ${known.join(", ")}`);
1461
1461
  }
1462
1462
  };
1463
- const commit = (next, action, label, previous) => {
1463
+ const commit2 = (next, action, label, previous) => {
1464
1464
  adapter.setState(next);
1465
1465
  fancyAutoCommon.pushUndoEntry(agent.id, {
1466
1466
  timestamp: Date.now(),
@@ -1521,7 +1521,7 @@ function registerGridBridge(host, options) {
1521
1521
  return { id: String(s.id), desc: Boolean(s.desc) };
1522
1522
  });
1523
1523
  const previous = adapter.getState();
1524
- commit({ ...previous, sorting }, "grid_sort", `Sorted by ${sorting.map((s) => s.id).join(", ") || "nothing"}`, previous);
1524
+ commit2({ ...previous, sorting }, "grid_sort", `Sorted by ${sorting.map((s) => s.id).join(", ") || "nothing"}`, previous);
1525
1525
  return textResult(`Sorted by ${sorting.map((s) => `${s.id}${s.desc ? " desc" : ""}`).join(", ") || "nothing"}.`);
1526
1526
  },
1527
1527
  true,
@@ -1550,7 +1550,7 @@ function registerGridBridge(host, options) {
1550
1550
  return { id: String(f.id), value: String(f.value) };
1551
1551
  });
1552
1552
  const previous = adapter.getState();
1553
- commit({ ...previous, filters }, "grid_filter", `Filtered ${filters.map((f) => f.id).join(", ") || "cleared"}`, previous);
1553
+ commit2({ ...previous, filters }, "grid_filter", `Filtered ${filters.map((f) => f.id).join(", ") || "cleared"}`, previous);
1554
1554
  return textResult(`Filtering on ${filters.map((f) => `${f.id}=${f.value}`).join(", ") || "nothing"}.`);
1555
1555
  },
1556
1556
  true,
@@ -1573,7 +1573,7 @@ function registerGridBridge(host, options) {
1573
1573
  const previous = adapter.getState();
1574
1574
  const rowSelection = {};
1575
1575
  for (const id of ids) rowSelection[id] = true;
1576
- commit({ ...previous, rowSelection }, "grid_select_rows", `Selected ${ids.length} row${ids.length === 1 ? "" : "s"}`, previous);
1576
+ commit2({ ...previous, rowSelection }, "grid_select_rows", `Selected ${ids.length} row${ids.length === 1 ? "" : "s"}`, previous);
1577
1577
  return textResult(`Selected ${ids.length} row${ids.length === 1 ? "" : "s"}.`);
1578
1578
  },
1579
1579
  true
@@ -1816,7 +1816,31 @@ function parseTriple(v) {
1816
1816
  }
1817
1817
 
1818
1818
  // src/bridges/screens.ts
1819
+ init_registry();
1819
1820
  var DEFAULT_AGENT7 = { id: "agent", name: "Agent", color: "#a855f7" };
1821
+ function hostErrorMessage(e, fallback) {
1822
+ let msg;
1823
+ if (e instanceof Error) msg = e.message;
1824
+ else if (typeof e === "string") msg = e;
1825
+ else if (e && typeof e === "object" && typeof e.message === "string") {
1826
+ msg = e.message;
1827
+ }
1828
+ const firstFrame = msg ? msg.search(/\n\s+at\s/) : -1;
1829
+ if (msg && firstFrame >= 0) msg = msg.slice(0, firstFrame);
1830
+ msg = msg?.trim();
1831
+ return msg ? msg : fallback;
1832
+ }
1833
+ async function commit(run, fallback) {
1834
+ try {
1835
+ const r = await run();
1836
+ if (r && typeof r === "object" && r.ok === false) {
1837
+ return { ok: false, error: hostErrorMessage(r.error, fallback) };
1838
+ }
1839
+ return { ok: true };
1840
+ } catch (e) {
1841
+ return { ok: false, error: hostErrorMessage(e, fallback) };
1842
+ }
1843
+ }
1820
1844
  function registerScreensBridge(host, options) {
1821
1845
  const { adapter } = options;
1822
1846
  const agent = { ...DEFAULT_AGENT7, ...options.agent ?? {} };
@@ -1832,7 +1856,7 @@ function registerScreensBridge(host, options) {
1832
1856
  try {
1833
1857
  return await handler(args);
1834
1858
  } catch (e) {
1835
- return errorResult(e instanceof Error ? e.message : String(e));
1859
+ return errorResult(hostErrorMessage(e, `${name} failed.`));
1836
1860
  }
1837
1861
  };
1838
1862
  const final = isMutation ? wrapToolWithActivity(wrapped, {
@@ -1894,20 +1918,40 @@ function registerScreensBridge(host, options) {
1894
1918
  config: { type: "object", description: "Template-specific config (e.g. { fields: [...] } for a form)." }
1895
1919
  },
1896
1920
  ["id", "kind"],
1897
- (args) => {
1898
- if (!adapter.createScreen) return errorResult("Host did not provide createScreen.");
1921
+ async (args) => {
1922
+ const createScreen = adapter.createScreen;
1923
+ if (!createScreen) return errorResult("Host did not provide createScreen.");
1899
1924
  const id = String(args.id);
1900
1925
  const kind = String(args.kind);
1901
1926
  if (adapter.listScreens().find((s) => s.id === id)) {
1902
1927
  return errorResult(`Screen ${id} already exists. Use screens_destroy first or pick a fresh id.`);
1903
1928
  }
1904
- adapter.createScreen({
1929
+ const created = await commit(() => createScreen({
1905
1930
  id,
1906
1931
  title: typeof args.title === "string" ? args.title : void 0,
1907
1932
  kind,
1908
1933
  config: args.config && typeof args.config === "object" ? args.config : void 0
1909
- });
1910
- adapter.setActive(id);
1934
+ }), `Host failed to create screen "${id}".`);
1935
+ if (!created.ok) return errorResult(created.error);
1936
+ const activated = await commit(() => adapter.setActive(id), `Host failed to activate screen "${id}".`);
1937
+ if (!activated.ok) {
1938
+ const state = { id, kind, created: true, activated: false };
1939
+ fancyAutoCommon.emitActivity({
1940
+ agentId: agent.id,
1941
+ agentName: agent.name,
1942
+ agentColor: agent.color,
1943
+ target: target(id),
1944
+ action: "screens_create",
1945
+ timestamp: Date.now(),
1946
+ meta: state
1947
+ });
1948
+ return {
1949
+ ...errorResult(
1950
+ `Screen "${id}" was created but not activated: ${activated.error} The screen exists; do not call screens_create again. Call screens_navigate to show it, or screens_destroy to remove it.`
1951
+ ),
1952
+ structuredContent: state
1953
+ };
1954
+ }
1911
1955
  return textResult(`Created ${kind} screen "${id}"`, { id, kind });
1912
1956
  },
1913
1957
  true,
@@ -1918,13 +1962,15 @@ function registerScreensBridge(host, options) {
1918
1962
  "Remove a previously-created screen. Active screen falls back to the first remaining one (or null).",
1919
1963
  { id: { type: "string" } },
1920
1964
  ["id"],
1921
- (args) => {
1922
- if (!adapter.destroyScreen) return errorResult("Host did not provide destroyScreen.");
1965
+ async (args) => {
1966
+ const destroyScreen = adapter.destroyScreen;
1967
+ if (!destroyScreen) return errorResult("Host did not provide destroyScreen.");
1923
1968
  const id = String(args.id);
1924
1969
  if (!adapter.listScreens().find((s) => s.id === id)) {
1925
1970
  return errorResult(`No screen with id ${id}`);
1926
1971
  }
1927
- adapter.destroyScreen(id);
1972
+ const done = await commit(() => destroyScreen(id), `Host failed to destroy screen "${id}".`);
1973
+ if (!done.ok) return errorResult(done.error);
1928
1974
  return textResult(`Destroyed screen ${id}`, { id });
1929
1975
  },
1930
1976
  true,
@@ -1938,9 +1984,15 @@ function registerScreensBridge(host, options) {
1938
1984
  layout: { type: "string", enum: ["single", "split-h", "split-v", "grid-2x2", "stack"] }
1939
1985
  },
1940
1986
  ["id", "layout"],
1941
- (args) => {
1942
- if (!adapter.updateScreenContent) return errorResult("Host did not provide updateScreenContent.");
1943
- adapter.updateScreenContent(String(args.id), { layout: String(args.layout) });
1987
+ async (args) => {
1988
+ const updateScreenContent = adapter.updateScreenContent;
1989
+ if (!updateScreenContent) return errorResult("Host did not provide updateScreenContent.");
1990
+ const id = String(args.id);
1991
+ const done = await commit(
1992
+ () => updateScreenContent(id, { layout: String(args.layout) }),
1993
+ `Host failed to change the layout of screen "${id}".`
1994
+ );
1995
+ if (!done.ok) return errorResult(done.error);
1944
1996
  return textResult(`Layout of ${args.id} \u2192 ${args.layout}`, { id: args.id, layout: args.layout });
1945
1997
  },
1946
1998
  true,
@@ -1954,11 +2006,13 @@ function registerScreensBridge(host, options) {
1954
2006
  partial: { type: "object", description: "Shallow-merged into the screen's config." }
1955
2007
  },
1956
2008
  ["id", "partial"],
1957
- (args) => {
1958
- if (!adapter.updateScreenContent) return errorResult("Host did not provide updateScreenContent.");
2009
+ async (args) => {
2010
+ const updateScreenContent = adapter.updateScreenContent;
2011
+ if (!updateScreenContent) return errorResult("Host did not provide updateScreenContent.");
1959
2012
  const id = String(args.id);
1960
2013
  const partial = args.partial && typeof args.partial === "object" ? args.partial : {};
1961
- adapter.updateScreenContent(id, partial);
2014
+ const done = await commit(() => updateScreenContent(id, partial), `Host failed to update screen "${id}".`);
2015
+ if (!done.ok) return errorResult(done.error);
1962
2016
  return textResult(`Updated content of ${id}`, { id });
1963
2017
  },
1964
2018
  true,
@@ -1969,13 +2023,14 @@ function registerScreensBridge(host, options) {
1969
2023
  "Switch the human's view to a different screen. The host updates its router / tab state and re-renders.",
1970
2024
  { screen: { type: "string", description: "Screen id to activate." } },
1971
2025
  ["screen"],
1972
- (args) => {
2026
+ async (args) => {
1973
2027
  const screenId = String(args.screen ?? "");
1974
2028
  const screens = adapter.listScreens();
1975
2029
  if (!screens.find((s) => s.id === screenId)) {
1976
2030
  return errorResult(`No screen registered with id "${screenId}". Call screens_list first.`);
1977
2031
  }
1978
- adapter.setActive(screenId);
2032
+ const done = await commit(() => adapter.setActive(screenId), `Host failed to navigate to screen "${screenId}".`);
2033
+ if (!done.ok) return errorResult(done.error);
1979
2034
  return textResult(`Navigated to ${screenId}`, { screen: screenId });
1980
2035
  },
1981
2036
  true,
@@ -3571,11 +3626,11 @@ function registerNavigationBridge(host, options) {
3571
3626
  bridgeId: "navigation",
3572
3627
  action: "nav_visit",
3573
3628
  label: `Navigate to ${url}`,
3574
- undo: () => {
3575
- adapter.visit(from);
3629
+ undo: async () => {
3630
+ await adapter.visit(from);
3576
3631
  },
3577
- redo: () => {
3578
- adapter.visit(url);
3632
+ redo: async () => {
3633
+ await adapter.visit(url);
3579
3634
  }
3580
3635
  });
3581
3636
  return textResult(`Navigated to ${url}`, { url });
@@ -3856,8 +3911,12 @@ function registerCatalogBridge(host, options) {
3856
3911
  bridgeId: catalogId,
3857
3912
  action: "catalog_create_product",
3858
3913
  label: `Created product ${product.id} (${product.name})`,
3859
- undo: () => void adapter.products.remove(product.id),
3860
- redo: () => void adapter.createProduct({ ...product })
3914
+ undo: async () => {
3915
+ await adapter.products.remove(product.id);
3916
+ },
3917
+ redo: async () => {
3918
+ await adapter.createProduct({ ...product });
3919
+ }
3861
3920
  });
3862
3921
  return textResult(`Created product ${product.id} (${product.name})`, product);
3863
3922
  },
@@ -3898,8 +3957,12 @@ function registerCatalogBridge(host, options) {
3898
3957
  bridgeId: catalogId,
3899
3958
  action: "catalog_create_price",
3900
3959
  label: `Created price ${price.id} on ${productId}`,
3901
- undo: () => void adapter.prices.remove(price.id),
3902
- redo: () => void adapter.createPrice({ ...price })
3960
+ undo: async () => {
3961
+ await adapter.prices.remove(price.id);
3962
+ },
3963
+ redo: async () => {
3964
+ await adapter.createPrice({ ...price });
3965
+ }
3903
3966
  });
3904
3967
  return textResult(`Created ${type} price ${price.id} on ${productId}`, price);
3905
3968
  },
@@ -3923,8 +3986,12 @@ function registerCatalogBridge(host, options) {
3923
3986
  bridgeId: catalogId,
3924
3987
  action: "catalog_delete_product",
3925
3988
  label: `Deleted product ${id} (${product.name})`,
3926
- undo: () => void adapter.createProduct({ ...snapshot }),
3927
- redo: () => void adapter.products.remove(id)
3989
+ undo: async () => {
3990
+ await adapter.createProduct({ ...snapshot });
3991
+ },
3992
+ redo: async () => {
3993
+ await adapter.products.remove(id);
3994
+ }
3928
3995
  });
3929
3996
  return textResult(`Deleted product ${id}`, { id });
3930
3997
  },
@@ -3948,8 +4015,12 @@ function registerCatalogBridge(host, options) {
3948
4015
  bridgeId: catalogId,
3949
4016
  action: "catalog_delete_price",
3950
4017
  label: `Deleted price ${id}`,
3951
- undo: () => void adapter.createPrice({ ...snapshot }),
3952
- redo: () => void adapter.prices.remove(id)
4018
+ undo: async () => {
4019
+ await adapter.createPrice({ ...snapshot });
4020
+ },
4021
+ redo: async () => {
4022
+ await adapter.prices.remove(id);
4023
+ }
3953
4024
  });
3954
4025
  return textResult(`Deleted price ${id}`, { id });
3955
4026
  },
@@ -4179,10 +4250,12 @@ function registerFeaturesBridge(host, options) {
4179
4250
  action: "features_grant",
4180
4251
  label: `Granted group ${groupKey}`,
4181
4252
  // Only reverse if WE added it (idempotent assign — don't revoke a pre-existing grant).
4182
- undo: () => {
4183
- if (!already) void adapter.detachGroup(args.subject, groupKey);
4253
+ undo: async () => {
4254
+ if (!already) await adapter.detachGroup(args.subject, groupKey);
4184
4255
  },
4185
- redo: () => void adapter.assignGroup(args.subject, groupKey)
4256
+ redo: async () => {
4257
+ await adapter.assignGroup(args.subject, groupKey);
4258
+ }
4186
4259
  });
4187
4260
  return textResult(`Granted group ${groupKey}`, { subject: args.subject, group: groupKey });
4188
4261
  },
@@ -4205,10 +4278,12 @@ function registerFeaturesBridge(host, options) {
4205
4278
  bridgeId: featuresId,
4206
4279
  action: "features_revoke",
4207
4280
  label: `Revoked group ${groupKey}`,
4208
- undo: () => {
4209
- if (had) void adapter.assignGroup(args.subject, groupKey);
4281
+ undo: async () => {
4282
+ if (had) await adapter.assignGroup(args.subject, groupKey);
4210
4283
  },
4211
- redo: () => void adapter.detachGroup(args.subject, groupKey)
4284
+ redo: async () => {
4285
+ await adapter.detachGroup(args.subject, groupKey);
4286
+ }
4212
4287
  });
4213
4288
  return textResult(`Revoked group ${groupKey}`, { subject: args.subject, group: groupKey });
4214
4289
  },
@@ -4366,8 +4441,12 @@ function registerPasskeyBridge(host, options) {
4366
4441
  bridgeId: surfaceId,
4367
4442
  action: "passkey_rename",
4368
4443
  label: `Renamed passkey to ${name || "(unnamed)"}`,
4369
- undo: () => void adapter.rename({ id, name: previous }),
4370
- redo: () => void adapter.rename({ id, name })
4444
+ undo: async () => {
4445
+ await adapter.rename({ id, name: previous });
4446
+ },
4447
+ redo: async () => {
4448
+ await adapter.rename({ id, name });
4449
+ }
4371
4450
  });
4372
4451
  return textResult(`Renamed passkey ${id} to ${name || "(unnamed)"}`, { id, name, previous });
4373
4452
  },
@@ -4446,7 +4525,7 @@ function registerDocBridge(host, options) {
4446
4525
  };
4447
4526
  const target = (elementId) => ({ kind: surface, screenId: adapter.screenId, elementId });
4448
4527
  const pending = /* @__PURE__ */ new Map();
4449
- function commit(op, label, targetId) {
4528
+ function commit2(op, label, targetId) {
4450
4529
  const prev = adapter.get();
4451
4530
  const next = reducer.reduce(prev, op);
4452
4531
  adapter.set(next);
@@ -4467,7 +4546,7 @@ function registerDocBridge(host, options) {
4467
4546
  options.onPending?.({ id: pendingId, op, label });
4468
4547
  return { staged: true, id: targetId, pendingId };
4469
4548
  }
4470
- commit(op, label, targetId);
4549
+ commit2(op, label, targetId);
4471
4550
  return { staged: false, id: targetId };
4472
4551
  }
4473
4552
  const reg = (verb, description, properties, required, handler, isMutation, resolveTarget) => {
@@ -4647,7 +4726,7 @@ function registerDocBridge(host, options) {
4647
4726
  const p = pending.get(id);
4648
4727
  if (!p) throw new Error(`No pending op ${id}`);
4649
4728
  pending.delete(id);
4650
- commit(p.op, p.label, p.targetId);
4729
+ commit2(p.op, p.label, p.targetId);
4651
4730
  return { ok: true, applied: p.label, id: p.targetId, _text: `applied ${p.label}` };
4652
4731
  },
4653
4732
  true,