skybridge 2.0.4 → 2.1.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.
Files changed (139) hide show
  1. package/README.md +9 -9
  2. package/dist/cli/build-helpers.d.ts +1 -1
  3. package/dist/cli/build-helpers.js +9 -1
  4. package/dist/cli/build-helpers.js.map +1 -1
  5. package/dist/cli/build-helpers.test.js +24 -0
  6. package/dist/cli/build-helpers.test.js.map +1 -1
  7. package/dist/cli/build-steps.js +16 -5
  8. package/dist/cli/build-steps.js.map +1 -1
  9. package/dist/cli/build-steps.test.js +20 -0
  10. package/dist/cli/build-steps.test.js.map +1 -1
  11. package/dist/cli/resolve-skybridge-config.d.ts +1 -0
  12. package/dist/cli/resolve-skybridge-config.js +11 -1
  13. package/dist/cli/resolve-skybridge-config.js.map +1 -1
  14. package/dist/cli/run-plain.js +2 -1
  15. package/dist/cli/run-plain.js.map +1 -1
  16. package/dist/cli/use-nodemon.d.ts +11 -1
  17. package/dist/cli/use-nodemon.js +19 -5
  18. package/dist/cli/use-nodemon.js.map +1 -1
  19. package/dist/cli/use-typescript-check.js +4 -2
  20. package/dist/cli/use-typescript-check.js.map +1 -1
  21. package/dist/commands/dev.js +3 -3
  22. package/dist/commands/dev.js.map +1 -1
  23. package/dist/server/app.d.ts +22 -5
  24. package/dist/server/app.js +24 -13
  25. package/dist/server/app.js.map +1 -1
  26. package/dist/server/app.test.js +81 -0
  27. package/dist/server/app.test.js.map +1 -1
  28. package/dist/server/auth/providers/custom.d.ts +4 -2
  29. package/dist/server/auth/providers/custom.js.map +1 -1
  30. package/dist/server/auth/providers/workos.d.ts +3 -2
  31. package/dist/server/auth/providers/workos.js +2 -1
  32. package/dist/server/auth/providers/workos.js.map +1 -1
  33. package/dist/server/auth/verify.d.ts +5 -3
  34. package/dist/server/auth/verify.js.map +1 -1
  35. package/dist/server/auth/verify.test.js +16 -0
  36. package/dist/server/auth/verify.test.js.map +1 -1
  37. package/dist/server/events.d.ts +113 -0
  38. package/dist/server/events.js +318 -0
  39. package/dist/server/events.js.map +1 -0
  40. package/dist/server/events.test.d.ts +1 -0
  41. package/dist/server/events.test.js +172 -0
  42. package/dist/server/events.test.js.map +1 -0
  43. package/dist/server/express.d.ts +3 -2
  44. package/dist/server/express.js +17 -11
  45. package/dist/server/express.js.map +1 -1
  46. package/dist/server/express.test.js +45 -0
  47. package/dist/server/express.test.js.map +1 -1
  48. package/dist/server/form-input.d.ts +120 -0
  49. package/dist/server/form-input.js +89 -0
  50. package/dist/server/form-input.js.map +1 -0
  51. package/dist/server/index.d.ts +4 -2
  52. package/dist/server/index.js +3 -1
  53. package/dist/server/index.js.map +1 -1
  54. package/dist/server/mcp-errors.test.js +188 -0
  55. package/dist/server/mcp-errors.test.js.map +1 -1
  56. package/dist/server/metric.d.ts +5 -3
  57. package/dist/server/metric.js +5 -5
  58. package/dist/server/metric.js.map +1 -1
  59. package/dist/server/register-tool.test.js +203 -0
  60. package/dist/server/register-tool.test.js.map +1 -1
  61. package/dist/server/server.d.ts +255 -10
  62. package/dist/server/server.js +278 -9
  63. package/dist/server/server.js.map +1 -1
  64. package/dist/server/templateHelper.d.ts +1 -0
  65. package/dist/server/templateHelper.js.map +1 -1
  66. package/dist/server/templates.generated.js +26 -12
  67. package/dist/server/templates.generated.js.map +1 -1
  68. package/dist/server/tool-extra.test.js +79 -0
  69. package/dist/server/tool-extra.test.js.map +1 -1
  70. package/dist/server/view-resource-resolution.test.js +35 -0
  71. package/dist/server/view-resource-resolution.test.js.map +1 -1
  72. package/dist/web/bridges/adaptor.d.ts +14 -3
  73. package/dist/web/bridges/adaptor.js +164 -14
  74. package/dist/web/bridges/adaptor.js.map +1 -1
  75. package/dist/web/bridges/adaptor.test.js +62 -6
  76. package/dist/web/bridges/adaptor.test.js.map +1 -1
  77. package/dist/web/bridges/apps-sdk/bridge.js +1 -1
  78. package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
  79. package/dist/web/bridges/apps-sdk/types.d.ts +2 -3
  80. package/dist/web/bridges/apps-sdk/types.js.map +1 -1
  81. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +3 -3
  82. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +3 -3
  83. package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
  84. package/dist/web/bridges/mcp-app/bridge.d.ts +1 -1
  85. package/dist/web/bridges/mcp-app/bridge.js +9 -2
  86. package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
  87. package/dist/web/bridges/mcp-app/types.d.ts +18 -3
  88. package/dist/web/bridges/mcp-app/types.js.map +1 -1
  89. package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +2 -2
  90. package/dist/web/bridges/mcp-app/use-mcp-app-context.js +1 -1
  91. package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
  92. package/dist/web/bridges/types.d.ts +57 -4
  93. package/dist/web/bridges/types.js +1 -1
  94. package/dist/web/bridges/types.js.map +1 -1
  95. package/dist/web/data-llm.js +3 -2
  96. package/dist/web/data-llm.js.map +1 -1
  97. package/dist/web/data-llm.test.js +6 -0
  98. package/dist/web/data-llm.test.js.map +1 -1
  99. package/dist/web/generate-helpers.d.ts +2 -2
  100. package/dist/web/generate-helpers.js +2 -2
  101. package/dist/web/generate-helpers.js.map +1 -1
  102. package/dist/web/hooks/index.d.ts +5 -1
  103. package/dist/web/hooks/index.js +5 -1
  104. package/dist/web/hooks/index.js.map +1 -1
  105. package/dist/web/hooks/openai-extensions.test.d.ts +1 -0
  106. package/dist/web/hooks/openai-extensions.test.js +107 -0
  107. package/dist/web/hooks/openai-extensions.test.js.map +1 -0
  108. package/dist/web/hooks/use-call-tool.d.ts +2 -2
  109. package/dist/web/hooks/use-call-tool.js +15 -10
  110. package/dist/web/hooks/use-call-tool.js.map +1 -1
  111. package/dist/web/hooks/use-call-tool.test.js +13 -2
  112. package/dist/web/hooks/use-call-tool.test.js.map +1 -1
  113. package/dist/web/hooks/use-deep-link.d.ts +22 -0
  114. package/dist/web/hooks/use-deep-link.js +34 -0
  115. package/dist/web/hooks/use-deep-link.js.map +1 -0
  116. package/dist/web/hooks/use-file-resource.d.ts +37 -0
  117. package/dist/web/hooks/use-file-resource.js +98 -0
  118. package/dist/web/hooks/use-file-resource.js.map +1 -0
  119. package/dist/web/hooks/use-file-resource.test.d.ts +1 -0
  120. package/dist/web/hooks/use-file-resource.test.js +65 -0
  121. package/dist/web/hooks/use-file-resource.test.js.map +1 -0
  122. package/dist/web/hooks/use-host.d.ts +27 -5
  123. package/dist/web/hooks/use-host.js +20 -5
  124. package/dist/web/hooks/use-host.js.map +1 -1
  125. package/dist/web/hooks/use-model-context.d.ts +44 -0
  126. package/dist/web/hooks/use-model-context.js +63 -0
  127. package/dist/web/hooks/use-model-context.js.map +1 -0
  128. package/dist/web/hooks/use-open-file.d.ts +20 -0
  129. package/dist/web/hooks/use-open-file.js +25 -0
  130. package/dist/web/hooks/use-open-file.js.map +1 -0
  131. package/dist/web/hooks/use-register-view-tool.d.ts +1 -1
  132. package/dist/web/hooks/use-register-view-tool.js +1 -1
  133. package/dist/web/hooks/use-register-view-tool.js.map +1 -1
  134. package/dist/web/hooks/use-send-follow-up-message.d.ts +8 -2
  135. package/dist/web/hooks/use-send-follow-up-message.js +6 -0
  136. package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
  137. package/dist/web/mount-view.js +3 -5
  138. package/dist/web/mount-view.js.map +1 -1
  139. package/package.json +6 -5
@@ -1 +1 @@
1
- {"version":3,"file":"register-tool.test.js","sourceRoot":"","sources":["../../src/server/register-tool.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,QAAQ,CAAC,iCAAiC,EAAE,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KAAK,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { Client, InMemoryTransport } from \"@modelcontextprotocol/client\";\nimport { describe, expect, it } from \"vitest\";\nimport { Skybridge } from \"./app.js\";\n\ndescribe(\"registerTool handler invocation\", () => {\n it(\"passes empty args and a usable extra to a schema-less tool handler\", async () => {\n let received: { args: unknown; extra: unknown } | undefined;\n const app = new Skybridge({\n name: \"test\",\n version: \"1.0.0\",\n handler: (server) =>\n server.registerTool(\n { name: \"no-input\", description: \"no-input\" },\n async (args, extra) => {\n received = { args, extra };\n return { content: [{ type: \"text\", text: \"ok\" }] };\n },\n ),\n });\n const instance = await app.createServerInstance();\n\n const client = new Client({ name: \"client\", version: \"1.0.0\" });\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await instance.connect(serverTransport);\n await client.connect(clientTransport);\n\n await client.callTool({ name: \"no-input\" });\n\n expect(received?.args).toEqual({});\n expect(received?.extra).toHaveProperty(\"mcpReq.send\");\n\n await client.close();\n await instance.close();\n });\n});\n"]}
1
+ {"version":3,"file":"register-tool.test.js","sourceRoot":"","sources":["../../src/server/register-tool.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,QAAQ,CAAC,iCAAiC,EAAE,GAAG,EAAE;IAC/C,EAAE,CAAC,oEAAoE,EAAE,KAAK,IAAI,EAAE;QAClF,IAAI,QAAuD,CAAC;QAC5D,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC;YACxB,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,CAAC,MAAM,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;QACxC,MAAM,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAEtC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC;QAC3C,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC;YAC7C,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;SACtD,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QAEzD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { Client, InMemoryTransport } from \"@modelcontextprotocol/client\";\nimport { describe, expect, it } from \"vitest\";\nimport { z } from \"zod\";\nimport { Skybridge } from \"./app.js\";\n\ndescribe(\"registerTool handler invocation\", () => {\n it(\"passes empty args and a usable extra to a schema-less tool handler\", async () => {\n let received: { args: unknown; extra: unknown } | undefined;\n const app = new Skybridge({\n name: \"test\",\n version: \"1.0.0\",\n handler: (server) =>\n server.registerTool(\n { name: \"no-input\", description: \"no-input\" },\n async (args, extra) => {\n received = { args, extra };\n return { content: [{ type: \"text\", text: \"ok\" }] };\n },\n ),\n });\n const instance = await app.createServerInstance();\n\n const client = new Client({ name: \"client\", version: \"1.0.0\" });\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await instance.connect(serverTransport);\n await client.connect(clientTransport);\n\n await client.callTool({ name: \"no-input\" });\n\n expect(received?.args).toEqual({});\n expect(received?.extra).toHaveProperty(\"mcpReq.send\");\n\n await client.close();\n await instance.close();\n });\n\n it(\"emits openai options as openai/ui metadata on the tool and its view\", async () => {\n const app = new Skybridge({\n name: \"test\",\n version: \"1.0.0\",\n handler: (server) =>\n server.registerTool(\n {\n name: \"library\",\n description: \"library\",\n view: { component: \"widget\" },\n openai: {\n entrypoints: [\n { type: \"global\" },\n { type: \"file\", extensions: [\".stl\"] },\n ],\n availableDisplayModes: [\"inline\", \"fullscreen\"],\n preferredDisplayMode: \"fullscreen\",\n },\n },\n async () => ({ content: \"ok\" }),\n ),\n });\n const instance = await app.createServerInstance();\n const client = new Client({ name: \"client\", version: \"1.0.0\" });\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await instance.connect(serverTransport);\n await client.connect(clientTransport);\n\n const { tools } = await client.listTools();\n const { resources } = await client.listResources();\n\n expect(tools[0]?._meta?.[\"openai/ui\"]).toEqual({\n entrypoints: [{ type: \"global\" }, { type: \"file\", extensions: [\".stl\"] }],\n });\n expect(resources[0]?._meta?.[\"openai/ui\"]).toEqual({\n availableDisplayModes: [\"inline\", \"fullscreen\"],\n preferredDisplayMode: \"fullscreen\",\n });\n\n await client.close();\n await instance.close();\n });\n\n it(\"rejects a global entrypoint on a tool that requires input\", async () => {\n const app = new Skybridge({\n name: \"test\",\n version: \"1.0.0\",\n handler: (server) =>\n server.registerTool(\n {\n name: \"search\",\n description: \"search\",\n inputSchema: { query: z.string() },\n view: { component: \"widget\" },\n openai: { entrypoints: [{ type: \"global\" }] },\n },\n async () => ({ content: \"ok\" }),\n ),\n });\n\n await expect(app.createServerInstance()).rejects.toThrow(/rejects `\\{\\}`/);\n });\n\n it(\"registers mention search as an app-only tool advertising the extension\", async () => {\n const app = new Skybridge({\n name: \"test\",\n version: \"1.0.0\",\n handler: (server) =>\n server.registerMentions({\n name: \"search_parts\",\n handler: async ({ query }) => ({\n items: [\n { type: \"resource_link\", uri: `parts://${query}`, name: query },\n ],\n }),\n }),\n });\n const instance = await app.createServerInstance();\n const client = new Client({ name: \"client\", version: \"1.0.0\" });\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await instance.connect(serverTransport);\n await client.connect(clientTransport);\n\n const { tools } = await client.listTools();\n expect(tools[0]?._meta).toMatchObject({\n \"openai/extensions\": { \"mentions/search\": {} },\n ui: { visibility: [\"app\"] },\n });\n const result = await client.callTool({\n name: \"search_parts\",\n arguments: { query: \"bolt\" },\n });\n expect(result.structuredContent).toEqual({\n items: [{ type: \"resource_link\", uri: \"parts://bolt\", name: \"bolt\" }],\n });\n\n await client.close();\n await instance.close();\n });\n\n it(\"registers settings tools and advertises the settings capability\", async () => {\n let stored = { units: \"mm\" as \"mm\" | \"in\", zoom: 3 };\n const fields = {\n units: { title: \"Units\", schema: z.enum([\"mm\", \"in\"]) },\n zoom: { title: \"Zoom\", schema: z.number() },\n };\n const app = new Skybridge({\n name: \"test\",\n version: \"1.0.0\",\n handler: (server) =>\n server.registerSettings({\n fields,\n layout: [\n {\n kind: \"group\",\n title: \"Display\",\n items: [{ kind: \"property\", property: \"units\" }],\n },\n ],\n read: () => stored,\n update: (set) => {\n stored = { ...stored, ...set };\n return stored;\n },\n }),\n });\n const instance = await app.createServerInstance();\n const client = new Client({ name: \"client\", version: \"1.0.0\" });\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await instance.connect(serverTransport);\n await client.connect(clientTransport);\n\n const capability = {\n readTool: \"settings.read\",\n updateTool: \"settings.update\",\n };\n expect(client.getServerCapabilities()).toMatchObject({\n extensions: { \"openai/settings\": capability },\n experimental: { \"openai/settings\": capability },\n });\n const { tools } = await client.listTools();\n expect(tools).toMatchObject([\n {\n name: \"settings.read\",\n annotations: { readOnlyHint: true },\n outputSchema: { required: [\"schema\", \"values\"] },\n },\n {\n name: \"settings.update\",\n inputSchema: {\n properties: {\n set: { additionalProperties: false, minProperties: 1 },\n },\n },\n },\n ]);\n const read = await client.callTool({\n name: \"settings.read\",\n arguments: {},\n });\n expect(read.structuredContent).toMatchObject({\n schema: {\n type: \"object\",\n properties: {\n units: { type: \"string\", enum: [\"mm\", \"in\"], title: \"Units\" },\n zoom: { type: \"number\", title: \"Zoom\" },\n },\n required: [\"units\", \"zoom\"],\n },\n values: { units: \"mm\", zoom: 3 },\n layout: [{ kind: \"group\", title: \"Display\" }],\n });\n const updated = await client.callTool({\n name: \"settings.update\",\n arguments: { set: { units: \"in\" } },\n });\n expect(updated.structuredContent).toEqual({\n values: { units: \"in\", zoom: 3 },\n });\n const empty = await client.callTool({\n name: \"settings.update\",\n arguments: { set: {} },\n });\n expect(empty.isError).toBe(true);\n\n await client.close();\n await instance.close();\n\n const withDefault = new Skybridge({\n name: \"test\",\n version: \"1.0.0\",\n handler: (server) =>\n server.registerSettings({\n fields: {\n grid: { title: \"Grid\", schema: z.boolean().prefault(true) },\n },\n read: () => ({ grid: true }),\n update: () => ({ grid: true }),\n }),\n });\n await expect(withDefault.createServerInstance()).rejects.toThrow(\n /declares a default/,\n );\n });\n\n it(\"registers a file viewer with the file input and a file entrypoint\", async () => {\n const app = new Skybridge({\n name: \"test\",\n version: \"1.0.0\",\n handler: (server) =>\n server.registerFileViewer(\n {\n name: \"part-viewer\",\n extensions: [\".stl\"],\n view: { component: \"widget\" },\n },\n async ({ file }) => ({ content: file.name }),\n ),\n });\n const instance = await app.createServerInstance();\n const client = new Client({ name: \"client\", version: \"1.0.0\" });\n const [clientTransport, serverTransport] =\n InMemoryTransport.createLinkedPair();\n await instance.connect(serverTransport);\n await client.connect(clientTransport);\n\n const { tools } = await client.listTools();\n expect(tools[0]?._meta?.[\"openai/ui\"]).toEqual({\n entrypoints: [{ type: \"file\", extensions: [\".stl\"] }],\n });\n expect(tools[0]?.inputSchema.required).toEqual([\"file\"]);\n\n await client.close();\n await instance.close();\n });\n});\n"]}
@@ -1,8 +1,10 @@
1
1
  import type { McpUiToolMeta } from "@modelcontextprotocol/ext-apps";
2
- import { type ContentBlock, type Implementation, McpServer as McpServerBase, type RequestMeta, type ServerOptions, type ServerResult, type StandardSchemaV1, type StandardSchemaWithJSON, type ToolAnnotations } from "@modelcontextprotocol/server";
2
+ import { type ContentBlock, type Icon, type Implementation, type InputRequiredResult, McpServer as McpServerBase, type RequestMeta, type ResourceLink, type ServerOptions, type ServerResult, type StandardSchemaV1, type StandardSchemaWithJSON, type ToolAnnotations } from "@modelcontextprotocol/server";
3
3
  import type express from "express";
4
+ import { z } from "zod/v4";
4
5
  import type { ResourceMetadataUrlResolver } from "./auth/setup.js";
5
6
  import type { ExtraClaims } from "./auth.js";
7
+ import { type EventConfig, type EventHooks, type InferEventSchema } from "./events.js";
6
8
  import type { McpExtra, McpExtraFor, McpMethodString, McpMiddlewareEntry, McpMiddlewareFilter, McpMiddlewareFn, McpResultFor, McpTypedMiddlewareFn, McpWildcard } from "./middleware.js";
7
9
  import { type SkillsManifest } from "./skills.js";
8
10
  /**
@@ -27,7 +29,7 @@ export interface ViewCsp {
27
29
  resourceDomains?: string[];
28
30
  /** Origins the view may contact via fetch/XHR. */
29
31
  connectDomains?: string[];
30
- /** Origins allowed for iframe embeds (opts into stricter app review). */
32
+ /** Origins allowed for iframe embeds (opts into stricter plugin review). */
31
33
  frameDomains?: string[];
32
34
  /** Origins that can receive openExternal redirects without the safe-link modal. */
33
35
  redirectDomains?: string[];
@@ -75,6 +77,65 @@ export type SecurityScheme = {
75
77
  type: "oauth2";
76
78
  scopes?: string[];
77
79
  };
80
+ /** A display mode ChatGPT can render a view in. ChatGPT doesn't support `pip`. */
81
+ export type OpenAIDisplayMode = "inline" | "fullscreen";
82
+ /** A sidebar shortcut that calls another tool of the same server. */
83
+ export interface OpenAIQuickAction {
84
+ title: string;
85
+ icons: [Icon, ...Icon[]];
86
+ target: {
87
+ type: "tool";
88
+ name: string;
89
+ arguments?: Record<string, unknown>;
90
+ };
91
+ }
92
+ /**
93
+ * A place in ChatGPT where users can open the tool's view without the model.
94
+ *
95
+ * - `global`: an entry in the sidebar, opened fullscreen.
96
+ * - `thread`: a tab in a conversation's side panel.
97
+ * - `file`: a viewer for files with these extensions, such as `".stl"`.
98
+ * ChatGPT calls the tool with `{ file: { name, resourceUri } }`.
99
+ * - `settings`: an entry in the plugin settings.
100
+ *
101
+ * ChatGPT calls the tool with `{}` for global and thread entrypoints, so the
102
+ * tool must not require any input.
103
+ */
104
+ export type OpenAIEntrypoint = {
105
+ type: "global";
106
+ quickAction?: OpenAIQuickAction;
107
+ } | {
108
+ type: "thread";
109
+ } | {
110
+ type: "file";
111
+ extensions: string[];
112
+ } | {
113
+ type: "settings";
114
+ searchTerms?: string[];
115
+ };
116
+ /**
117
+ * ChatGPT-only tool options, emitted as `_meta["openai/ui"]` on the tool and
118
+ * on its view resource. Every field is optional: ChatGPT applies the defaults
119
+ * of the OpenAI MCP extensions spec when one is omitted. Requires `view`.
120
+ *
121
+ * @see https://github.com/openai/mcp-extensions/blob/main/docs/spec.md
122
+ */
123
+ export interface OpenAIToolConfig {
124
+ /** Places where users can open the view directly. */
125
+ entrypoints?: OpenAIEntrypoint[];
126
+ /**
127
+ * Display modes the view supports, read before the view loads. Defaults to
128
+ * `[preferredDisplayMode]` when that is set, otherwise to both modes.
129
+ */
130
+ availableDisplayModes?: OpenAIDisplayMode[];
131
+ /**
132
+ * Display mode the view prefers to open in. Setting it alone makes it the
133
+ * only available mode, so also set `availableDisplayModes` to keep the other.
134
+ */
135
+ preferredDisplayMode?: OpenAIDisplayMode;
136
+ /** Display mode the view opens in first when the model calls the tool. */
137
+ preferredModelDisplayMode?: OpenAIDisplayMode;
138
+ }
78
139
  /**
79
140
  * Declarative per-tool auth. Enforced when the server has an `oauth` provider:
80
141
  * anonymous or under-scoped calls are rejected before the handler runs. Omit
@@ -112,16 +173,16 @@ export interface SkybridgeServerOptions {
112
173
  * Well-known keys recognized by host runtimes when set on a tool's `_meta`.
113
174
  * Use {@link ToolMeta} to also pass arbitrary custom metadata alongside these.
114
175
  *
115
- * @see https://developers.openai.com/apps-sdk/reference#tool-descriptor-parameters
176
+ * @see https://developers.openai.com/plugins/reference#tool-descriptor-parameters
116
177
  */
117
178
  export interface KnownToolMeta {
118
- /** Apps SDK: allow the rendered view to call this tool from inside its iframe. */
179
+ /** ChatGPT: allow the rendered view to call this tool from inside its iframe. */
119
180
  "openai/widgetAccessible"?: boolean;
120
- /** Apps SDK: status text shown while the tool is running (e.g. `"Searching trips"`). */
181
+ /** ChatGPT: status text shown while the tool is running (e.g. `"Searching trips"`). */
121
182
  "openai/toolInvocation/invoking"?: string;
122
- /** Apps SDK: status text shown once the tool returns (e.g. `"Found 3 trips"`). */
183
+ /** ChatGPT: status text shown once the tool returns (e.g. `"Found 3 trips"`). */
123
184
  "openai/toolInvocation/invoked"?: string;
124
- /** Apps SDK: input parameters that hold file references — the host attaches uploaded files to them. */
185
+ /** ChatGPT: input parameters that hold file references — the host attaches uploaded files to them. */
125
186
  "openai/fileParams"?: string[];
126
187
  /** MCP Apps: control whether the tool is exposed to the model, the app, or both. */
127
188
  ui?: Pick<McpUiToolMeta, "visibility">;
@@ -175,7 +236,15 @@ interface ToolConfigBase<TInput extends Record<string, StandardSchemaWithJSON> |
175
236
  inputSchema?: TInput;
176
237
  outputSchema?: Record<string, StandardSchemaWithJSON> | StandardSchemaWithJSON;
177
238
  annotations?: ToolAnnotations;
239
+ /**
240
+ * Icons for the tool, a standard MCP field. Hosts choose whether and where
241
+ * to show them. ChatGPT asks for them on every entrypoint tool, as a
242
+ * monochrome SVG on a 20x20 viewport that uses `currentColor`.
243
+ */
244
+ icons?: Icon[];
178
245
  view?: ViewConfig;
246
+ /** ChatGPT-only options. See {@link OpenAIToolConfig}. */
247
+ openai?: OpenAIToolConfig;
179
248
  _meta?: ToolMeta;
180
249
  }
181
250
  /**
@@ -197,11 +266,27 @@ type ToolAuthConfig = {
197
266
  securitySchemes?: SecurityScheme[];
198
267
  };
199
268
  type ToolConfig<TInput extends Record<string, StandardSchemaWithJSON> | StandardSchemaWithJSON> = ToolConfigBase<TInput> & ToolAuthConfig;
269
+ declare const fileEntrypointInput: {
270
+ file: z.ZodObject<{
271
+ name: z.ZodString;
272
+ resourceUri: z.ZodString;
273
+ }, z.core.$strip>;
274
+ };
275
+ type FileEntrypointInput = typeof fileEntrypointInput;
276
+ /** A ChatGPT file viewer, registered with `server.registerFileViewer`. */
277
+ export type OpenAIFileViewerConfig<TName extends string = string> = Omit<ToolConfigBase<FileEntrypointInput>, "inputSchema" | "openai" | "view"> & ToolAuthConfig & {
278
+ name: TName;
279
+ /** File extensions the viewer opens, each starting with `.`. */
280
+ extensions: string[];
281
+ view: ViewConfig;
282
+ /** Display modes. The file entrypoint is set from `extensions`. */
283
+ openai?: Omit<OpenAIToolConfig, "entrypoints">;
284
+ };
200
285
  /**
201
286
  * Optional client-supplied hints attached to `params._meta` on every tool call
202
- * by the Apps SDK host. Hints only: never use for authorization, and tolerate
287
+ * by the ChatGPT host. Hints only: never use for authorization, and tolerate
203
288
  * absence.
204
- * @see https://developers.openai.com/apps-sdk/reference#_meta-fields-the-client-provides
289
+ * @see https://developers.openai.com/plugins/reference#_meta-fields-the-client-provides
205
290
  */
206
291
  export interface ClientHintsMeta {
207
292
  /** Requested locale (BCP-47, e.g. `"en-US"`). */
@@ -225,17 +310,77 @@ export interface ClientHintsMeta {
225
310
  "openai/organization"?: string;
226
311
  /** Stable id for the currently mounted widget instance. */
227
312
  "openai/widgetSessionId"?: string;
313
+ /**
314
+ * Set by ChatGPT desktop on tool calls from a view opened through a file
315
+ * entrypoint. `path` is the absolute path of the opened file. Any MCP client
316
+ * can send this key: never use it for authorization, and resolve the path
317
+ * and keep it inside an allowed directory before touching the filesystem.
318
+ */
319
+ "openai/resource"?: {
320
+ path?: string;
321
+ };
228
322
  }
229
323
  type ToolHandlerExtra<TAuthExtra extends ExtraClaims = ExtraClaims> = Omit<McpExtra<TAuthExtra>, "mcpReq"> & {
230
324
  mcpReq: Omit<McpExtra<TAuthExtra>["mcpReq"], "_meta"> & {
231
325
  _meta?: RequestMeta & ClientHintsMeta;
232
326
  };
233
327
  };
328
+ /** Composer at-mention search, registered with `server.registerMentions`. */
329
+ export interface OpenAIMentionsConfig<TAuthExtra extends ExtraClaims = ExtraClaims> {
330
+ /** Name of the tool ChatGPT calls for each search. */
331
+ name: string;
332
+ description?: string;
333
+ /** Returns the items matching the typed text, which may be empty. */
334
+ handler: (params: {
335
+ query: string;
336
+ }, extra: ToolHandlerExtra<TAuthExtra>) => Promise<{
337
+ items: ResourceLink[];
338
+ }> | {
339
+ items: ResourceLink[];
340
+ };
341
+ }
342
+ /** One setting, registered with `server.registerSettings`. */
343
+ export interface OpenAISettingsField {
344
+ /** A boolean, string, string enum, number or integer schema, without a default. */
345
+ schema: z.ZodType<boolean | string | number>;
346
+ title: string;
347
+ description?: string;
348
+ }
349
+ /** Values of every setting, keyed by field name. */
350
+ export type OpenAISettingsValues<TFields extends Record<string, OpenAISettingsField>> = {
351
+ [K in keyof TFields]-?: Exclude<z.output<TFields[K]["schema"]>, undefined>;
352
+ };
353
+ /** App settings in ChatGPT, registered with `server.registerSettings`. */
354
+ export interface OpenAISettingsConfig<TFields extends Record<string, OpenAISettingsField>, TAuthExtra extends ExtraClaims = ExtraClaims> {
355
+ fields: TFields;
356
+ /** Sections of the settings page. Fields left out appear under "Other settings". */
357
+ layout?: {
358
+ kind: "group";
359
+ title: string;
360
+ items: ({
361
+ kind: "property";
362
+ property: Extract<keyof TFields, string>;
363
+ } | {
364
+ kind: "tool";
365
+ tool: string;
366
+ title: string;
367
+ description?: string;
368
+ })[];
369
+ }[];
370
+ /** Returns the current value of every field. */
371
+ read: (extra: ToolHandlerExtra<TAuthExtra>) => OpenAISettingsValues<TFields> | Promise<OpenAISettingsValues<TFields>>;
372
+ /** Saves the changed fields and returns the value of every field. */
373
+ update: (set: Partial<OpenAISettingsValues<TFields>>, extra: ToolHandlerExtra<TAuthExtra>) => OpenAISettingsValues<TFields> | Promise<OpenAISettingsValues<TFields>>;
374
+ /** Name of the read tool. Defaults to `settings.read`. */
375
+ readTool?: string;
376
+ /** Name of the update tool. Defaults to `settings.update`. */
377
+ updateTool?: string;
378
+ }
234
379
  type ToolHandler<TInput extends Record<string, StandardSchemaWithJSON>, TReturn extends {
235
380
  content?: HandlerContent;
236
381
  } = {
237
382
  content?: HandlerContent;
238
- }, TAuthExtra extends ExtraClaims = ExtraClaims> = (args: ShapeOutput<TInput>, extra: ToolHandlerExtra<TAuthExtra>) => TReturn | Promise<TReturn>;
383
+ }, TAuthExtra extends ExtraClaims = ExtraClaims> = (args: ShapeOutput<TInput>, extra: ToolHandlerExtra<TAuthExtra>) => TReturn | InputRequiredResult | Promise<TReturn | InputRequiredResult>;
239
384
  /**
240
385
  * Coerce a tool handler's return value into an MCP `content` array. Strings
241
386
  * become a single `TextContent`; a single block is wrapped in an array;
@@ -303,6 +448,7 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
303
448
  private resolveResourceMetadataUrl?;
304
449
  private readonly toolSecuritySchemes;
305
450
  private readonly userMiddlewareEntries;
451
+ private eventRegistry?;
306
452
  constructor(serverInfo: Implementation, options?: ServerOptions, skybridgeOptions?: SkybridgeServerOptions);
307
453
  /**
308
454
  * The per-tool security schemes collected during registration, keyed by tool
@@ -368,6 +514,7 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
368
514
  private decorateToolHandler;
369
515
  private computeViewVersionParam;
370
516
  private lookupViewFile;
517
+ private lookupViewPreloadFiles;
371
518
  private lookupDistFile;
372
519
  /**
373
520
  * Inject the Vite manifest as a value rather than letting `readManifest()`
@@ -379,6 +526,104 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
379
526
  file: string;
380
527
  }>): this;
381
528
  private readManifest;
529
+ /**
530
+ * @experimental Register an MCP Events type that hosts can subscribe to, per
531
+ * the Triggers & Events working group draft. Skybridge serves `events/list`,
532
+ * `events/subscribe` and `events/unsubscribe`, checks auth and arguments,
533
+ * verifies the callback URL, then hands each subscription to `onSubscribe`.
534
+ * Delivering the events is up to you, for example with {@link deliverEvent}.
535
+ * API may change.
536
+ *
537
+ * @example
538
+ * ```ts
539
+ * server.registerEvent(
540
+ * {
541
+ * name: "comment.created",
542
+ * description: "Fires when someone comments on a document",
543
+ * inputSchema: { documentId: z.string() },
544
+ * payloadSchema: { documentId: z.string(), excerpt: z.string() },
545
+ * },
546
+ * {
547
+ * onSubscribe: ({ documentId }, { subscription }) =>
548
+ * webhooks.upsert({ ...subscription, filter: { documentId } }),
549
+ * onUnsubscribe: (_args, { subscription }) =>
550
+ * webhooks.remove(subscription.id),
551
+ * },
552
+ * );
553
+ * ```
554
+ *
555
+ * @see https://docs.skybridge.tech/api-reference/register-event
556
+ */
557
+ registerEvent<TInput extends Record<string, StandardSchemaWithJSON> | StandardSchemaWithJSON = Record<never, StandardSchemaWithJSON>>(config: EventConfig<TInput>, hooks: EventHooks<InferEventSchema<TInput>, McpExtra<TAuthExtra>>): this;
558
+ /**
559
+ * Register a ChatGPT file viewer, from the OpenAI MCP extensions: a tool
560
+ * with a file entrypoint for `extensions` and a view. ChatGPT desktop calls
561
+ * it with the file the user opened, as `{ file: { name, resourceUri } }`.
562
+ * Read and save the file from the view with `useFileResource`.
563
+ *
564
+ * @example
565
+ * ```ts
566
+ * server.registerFileViewer(
567
+ * {
568
+ * name: "part-viewer",
569
+ * title: "Part Viewer",
570
+ * extensions: [".stl", ".step"],
571
+ * view: { component: "part-viewer" },
572
+ * },
573
+ * async ({ file }) => ({ structuredContent: { name: file.name } }),
574
+ * );
575
+ * ```
576
+ *
577
+ * @see https://docs.skybridge.tech/api-reference/register-file-viewer
578
+ */
579
+ registerFileViewer<TName extends string, TReturn extends {
580
+ content?: HandlerContent;
581
+ }>(config: OpenAIFileViewerConfig<TName>, cb: ToolHandler<FileEntrypointInput, TReturn, TAuthExtra>): AddTool<TTools, TName, FileEntrypointInput, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>, TAuthExtra>;
582
+ /**
583
+ * Register the composer at-mention search for ChatGPT, from the OpenAI MCP
584
+ * extensions. When the user types `@` and your app name, ChatGPT calls
585
+ * `handler` with the typed text and lists the returned resource links.
586
+ * Skybridge registers it as a tool hidden from the model.
587
+ *
588
+ * @example
589
+ * ```ts
590
+ * server.registerMentions({
591
+ * name: "search_parts",
592
+ * handler: async ({ query }) => ({
593
+ * items: findParts(query).map((part) => ({
594
+ * type: "resource_link",
595
+ * uri: `parts://${part.id}`,
596
+ * name: part.name,
597
+ * })),
598
+ * }),
599
+ * });
600
+ * ```
601
+ *
602
+ * @see https://docs.skybridge.tech/api-reference/register-mentions
603
+ */
604
+ registerMentions(config: OpenAIMentionsConfig<TAuthExtra>): this;
605
+ /**
606
+ * Register app settings for ChatGPT, from the OpenAI MCP extensions.
607
+ * Skybridge registers a read tool and an update tool from `fields`, and
608
+ * advertises them in the `openai/settings` server capability. ChatGPT shows
609
+ * the settings page and calls `update` with the changed fields only. Store
610
+ * the values yourself, for example per user.
611
+ *
612
+ * @example
613
+ * ```ts
614
+ * server.registerSettings({
615
+ * fields: {
616
+ * units: { title: "Units", schema: z.enum(["mm", "in"]) },
617
+ * showGrid: { title: "Show grid", schema: z.boolean() },
618
+ * },
619
+ * read: (extra) => loadSettings(extra),
620
+ * update: (set, extra) => saveSettings(set, extra),
621
+ * });
622
+ * ```
623
+ *
624
+ * @see https://docs.skybridge.tech/api-reference/register-settings
625
+ */
626
+ registerSettings<TFields extends Record<string, OpenAISettingsField>>(config: OpenAISettingsConfig<TFields, TAuthExtra>): this;
382
627
  /**
383
628
  * Register a tool. Pass a `config` describing the tool (name, schemas,
384
629
  * optional {@link ViewConfig}, optional {@link ToolMeta}) and a handler that