@copilotkit/runtime 2.0.0-rc.41 → 2.0.0-rc.43

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 (63) hide show
  1. package/dist/agent/converters/aisdk.cjs +1 -1
  2. package/dist/agent/converters/aisdk.mjs +1 -1
  3. package/dist/agent/converters/tanstack.cjs +1 -1
  4. package/dist/agent/converters/tanstack.mjs +1 -1
  5. package/dist/index.cjs +2 -1
  6. package/dist/index.d.cts +3 -2
  7. package/dist/index.d.mts +3 -2
  8. package/dist/index.mjs +3 -2
  9. package/dist/runtime/core/package-info.cjs +1 -1
  10. package/dist/runtime/core/package-info.mjs +1 -1
  11. package/dist/runtime/core/runtime.cjs +1 -19
  12. package/dist/runtime/core/runtime.cjs.map +1 -1
  13. package/dist/runtime/core/runtime.d.cts +77 -29
  14. package/dist/runtime/core/runtime.d.cts.map +1 -1
  15. package/dist/runtime/core/runtime.d.mts +77 -29
  16. package/dist/runtime/core/runtime.d.mts.map +1 -1
  17. package/dist/runtime/core/runtime.mjs +2 -19
  18. package/dist/runtime/core/runtime.mjs.map +1 -1
  19. package/dist/runtime/event-transforms/recorded-events.cjs +11 -1
  20. package/dist/runtime/event-transforms/recorded-events.cjs.map +1 -1
  21. package/dist/runtime/event-transforms/recorded-events.d.cts +5 -1
  22. package/dist/runtime/event-transforms/recorded-events.d.cts.map +1 -1
  23. package/dist/runtime/event-transforms/recorded-events.d.mts +5 -1
  24. package/dist/runtime/event-transforms/recorded-events.d.mts.map +1 -1
  25. package/dist/runtime/event-transforms/recorded-events.mjs +12 -2
  26. package/dist/runtime/event-transforms/recorded-events.mjs.map +1 -1
  27. package/dist/runtime/generative-ui/a2ui-v09-actions.cjs +106 -0
  28. package/dist/runtime/generative-ui/a2ui-v09-actions.cjs.map +1 -0
  29. package/dist/runtime/generative-ui/a2ui-v09-actions.mjs +106 -0
  30. package/dist/runtime/generative-ui/a2ui-v09-actions.mjs.map +1 -0
  31. package/dist/runtime/generative-ui/a2ui-v09-catalog.cjs +422 -0
  32. package/dist/runtime/generative-ui/a2ui-v09-catalog.cjs.map +1 -0
  33. package/dist/runtime/generative-ui/a2ui-v09-catalog.mjs +422 -0
  34. package/dist/runtime/generative-ui/a2ui-v09-catalog.mjs.map +1 -0
  35. package/dist/runtime/generative-ui/a2ui-v09-middleware.cjs +84 -0
  36. package/dist/runtime/generative-ui/a2ui-v09-middleware.cjs.map +1 -0
  37. package/dist/runtime/generative-ui/a2ui-v09-middleware.d.cts +41 -0
  38. package/dist/runtime/generative-ui/a2ui-v09-middleware.d.cts.map +1 -0
  39. package/dist/runtime/generative-ui/a2ui-v09-middleware.d.mts +41 -0
  40. package/dist/runtime/generative-ui/a2ui-v09-middleware.d.mts.map +1 -0
  41. package/dist/runtime/generative-ui/a2ui-v09-middleware.mjs +83 -0
  42. package/dist/runtime/generative-ui/a2ui-v09-middleware.mjs.map +1 -0
  43. package/dist/runtime/generative-ui/a2ui-v09-operations.cjs +620 -0
  44. package/dist/runtime/generative-ui/a2ui-v09-operations.cjs.map +1 -0
  45. package/dist/runtime/generative-ui/a2ui-v09-operations.mjs +620 -0
  46. package/dist/runtime/generative-ui/a2ui-v09-operations.mjs.map +1 -0
  47. package/dist/runtime/generative-ui/index.d.cts +1 -0
  48. package/dist/runtime/generative-ui/index.d.mts +1 -0
  49. package/dist/runtime/handlers/get-runtime-info.cjs +19 -5
  50. package/dist/runtime/handlers/get-runtime-info.cjs.map +1 -1
  51. package/dist/runtime/handlers/get-runtime-info.mjs +20 -6
  52. package/dist/runtime/handlers/get-runtime-info.mjs.map +1 -1
  53. package/dist/runtime/handlers/handle-run.cjs +0 -2
  54. package/dist/runtime/handlers/handle-run.cjs.map +1 -1
  55. package/dist/runtime/handlers/handle-run.mjs +0 -2
  56. package/dist/runtime/handlers/handle-run.mjs.map +1 -1
  57. package/dist/runtime/handlers/shared/agent-utils.cjs +17 -14
  58. package/dist/runtime/handlers/shared/agent-utils.cjs.map +1 -1
  59. package/dist/runtime/handlers/shared/agent-utils.mjs +18 -15
  60. package/dist/runtime/handlers/shared/agent-utils.mjs.map +1 -1
  61. package/dist/runtime/index.d.cts +2 -1
  62. package/dist/runtime/index.d.mts +2 -1
  63. package/package.json +8 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a2ui-v09-middleware.d.mts","names":[],"sources":["../../../src/runtime/generative-ui/a2ui-v09-middleware.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAuFa,uBAAA,SAAgC,UAAA;EAAA,iBAC1B,YAAA;cAEL,OAAA;IAAW,YAAA,GAAe,WAAA;EAAA;EAKtC,GAAA,CAAI,KAAA,EAAO,aAAA,EAAe,IAAA,EAAM,aAAA,GAAgB,UAAA,CAAW,SAAA;AAAA"}
@@ -0,0 +1,83 @@
1
+ import { downgradeA2UIV09Action } from "./a2ui-v09-actions.mjs";
2
+ import { buildA2UIV09CatalogContext } from "./a2ui-v09-catalog.mjs";
3
+ import { createA2UIV09ActivityUpgrader } from "./a2ui-v09-operations.mjs";
4
+ import { concatMap } from "rxjs";
5
+ import { Middleware } from "@ag-ui/client";
6
+
7
+ //#region src/runtime/generative-ui/a2ui-v09-middleware.ts
8
+ /**
9
+ * The A2UI version of one agent, from the runtime's `generativeUI` option.
10
+ * Without `a2uiVersion`, and for an agent that is not in an `a2uiVersion`
11
+ * record, the version is `"1.0"`.
12
+ *
13
+ * @param generativeUI - The runtime's `generativeUI` option.
14
+ * @param agentId - The id of the agent.
15
+ * @returns `"0.9"` or `"1.0"`.
16
+ */
17
+ function resolveA2UIVersion(generativeUI, agentId) {
18
+ const option = typeof generativeUI === "object" ? generativeUI.a2uiVersion : void 0;
19
+ return (typeof option === "object" && option !== null ? option[agentId] : option) === "0.9" ? "0.9" : "1.0";
20
+ }
21
+ /**
22
+ * The input that the agent side of a run gets:
23
+ * - A click on a surface that was converted from v0.9 becomes the v0.9
24
+ * action (`forwardedProps.a2uiAction`), see {@link downgradeA2UIV09Action}.
25
+ * The input of a middleware has no activity messages (`AbstractAgent`
26
+ * removes them), so in practice `agentVersion` decides: every click of a
27
+ * run of a v0.9 agent becomes a v0.9 action.
28
+ * - For a v0.9 agent, the v0.9 component schema of the client's catalog is
29
+ * added to the context. An entry with the same description is replaced.
30
+ *
31
+ * It never mutates `input`.
32
+ */
33
+ function prepareA2UIV09AgentInput(input, agentVersion) {
34
+ const agentInput = downgradeA2UIV09Action(input, { agentVersion });
35
+ if (agentVersion !== "0.9") return agentInput;
36
+ const catalog = buildA2UIV09CatalogContext(agentInput);
37
+ if (!catalog) return agentInput;
38
+ const descriptions = new Set(catalog.context.map((e) => e.description));
39
+ return {
40
+ ...agentInput,
41
+ context: [...(agentInput.context ?? []).filter((entry) => !descriptions.has(entry.description)), ...catalog.context]
42
+ };
43
+ }
44
+ /**
45
+ * Connects agents that speak A2UI v0.9 to the A2UI 1.0 client.
46
+ *
47
+ * - Input: {@link prepareA2UIV09AgentInput}. Only the agent side gets the
48
+ * changed input. The runtime stores the input of the client, so the
49
+ * thread keeps the click message.
50
+ * - Output: every `a2ui-surface` activity event becomes a
51
+ * `generative-ui-surface` event, see `createA2UIV09ActivityUpgrader`.
52
+ * The version of each operation decides, so v0.9 surfaces convert also
53
+ * for a `"1.0"` agent (for example, from a tool result), and native 1.0
54
+ * operations on this path (for example, from ADK) reach the client as 1.0
55
+ * surfaces too.
56
+ *
57
+ * The first middleware given to `agent.use` is the outermost: it sees the
58
+ * input first and the events last. Use this middleware before
59
+ * `A2UIMiddleware`, so that `A2UIMiddleware` gets the v0.9 input and this
60
+ * middleware converts the surfaces that `A2UIMiddleware` emits.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * agent.use(
65
+ * new A2UIV09BridgeMiddleware({ agentVersion: "0.9" }),
66
+ * new A2UIMiddleware({ injectA2UITool: true }),
67
+ * );
68
+ * ```
69
+ */
70
+ var A2UIV09BridgeMiddleware = class extends Middleware {
71
+ constructor(options = {}) {
72
+ super();
73
+ this.agentVersion = options.agentVersion ?? "1.0";
74
+ }
75
+ run(input, next) {
76
+ const upgrader = createA2UIV09ActivityUpgrader();
77
+ return this.runNext(prepareA2UIV09AgentInput(input, this.agentVersion), next).pipe(concatMap((event) => upgrader.transform(event)));
78
+ }
79
+ };
80
+
81
+ //#endregion
82
+ export { A2UIV09BridgeMiddleware, resolveA2UIVersion };
83
+ //# sourceMappingURL=a2ui-v09-middleware.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a2ui-v09-middleware.mjs","names":[],"sources":["../../../src/runtime/generative-ui/a2ui-v09-middleware.ts"],"sourcesContent":["import { Middleware } from \"@ag-ui/client\";\nimport type { AbstractAgent, BaseEvent, RunAgentInput } from \"@ag-ui/client\";\nimport { concatMap } from \"rxjs\";\nimport type { Observable } from \"rxjs\";\nimport type { A2UIVersion, CopilotRuntimeOptions } from \"../core/runtime\";\nimport { downgradeA2UIV09Action } from \"./a2ui-v09-actions\";\nimport { buildA2UIV09CatalogContext } from \"./a2ui-v09-catalog\";\nimport { createA2UIV09ActivityUpgrader } from \"./a2ui-v09-operations\";\n\n/**\n * The A2UI version of one agent, from the runtime's `generativeUI` option.\n * Without `a2uiVersion`, and for an agent that is not in an `a2uiVersion`\n * record, the version is `\"1.0\"`.\n *\n * @param generativeUI - The runtime's `generativeUI` option.\n * @param agentId - The id of the agent.\n * @returns `\"0.9\"` or `\"1.0\"`.\n */\nexport function resolveA2UIVersion(\n generativeUI: CopilotRuntimeOptions[\"generativeUI\"],\n agentId: string,\n): A2UIVersion {\n const option =\n typeof generativeUI === \"object\" ? generativeUI.a2uiVersion : undefined;\n const version =\n typeof option === \"object\" && option !== null ? option[agentId] : option;\n return version === \"0.9\" ? \"0.9\" : \"1.0\";\n}\n\n/**\n * The input that the agent side of a run gets:\n * - A click on a surface that was converted from v0.9 becomes the v0.9\n * action (`forwardedProps.a2uiAction`), see {@link downgradeA2UIV09Action}.\n * The input of a middleware has no activity messages (`AbstractAgent`\n * removes them), so in practice `agentVersion` decides: every click of a\n * run of a v0.9 agent becomes a v0.9 action.\n * - For a v0.9 agent, the v0.9 component schema of the client's catalog is\n * added to the context. An entry with the same description is replaced.\n *\n * It never mutates `input`.\n */\nexport function prepareA2UIV09AgentInput(\n input: RunAgentInput,\n agentVersion: A2UIVersion,\n): RunAgentInput {\n const agentInput = downgradeA2UIV09Action(input, { agentVersion });\n if (agentVersion !== \"0.9\") return agentInput;\n const catalog = buildA2UIV09CatalogContext(agentInput);\n if (!catalog) return agentInput;\n const descriptions = new Set(catalog.context.map((e) => e.description));\n return {\n ...agentInput,\n context: [\n ...(agentInput.context ?? []).filter(\n (entry) => !descriptions.has(entry.description),\n ),\n ...catalog.context,\n ],\n };\n}\n\n/**\n * Connects agents that speak A2UI v0.9 to the A2UI 1.0 client.\n *\n * - Input: {@link prepareA2UIV09AgentInput}. Only the agent side gets the\n * changed input. The runtime stores the input of the client, so the\n * thread keeps the click message.\n * - Output: every `a2ui-surface` activity event becomes a\n * `generative-ui-surface` event, see `createA2UIV09ActivityUpgrader`.\n * The version of each operation decides, so v0.9 surfaces convert also\n * for a `\"1.0\"` agent (for example, from a tool result), and native 1.0\n * operations on this path (for example, from ADK) reach the client as 1.0\n * surfaces too.\n *\n * The first middleware given to `agent.use` is the outermost: it sees the\n * input first and the events last. Use this middleware before\n * `A2UIMiddleware`, so that `A2UIMiddleware` gets the v0.9 input and this\n * middleware converts the surfaces that `A2UIMiddleware` emits.\n *\n * @example\n * ```ts\n * agent.use(\n * new A2UIV09BridgeMiddleware({ agentVersion: \"0.9\" }),\n * new A2UIMiddleware({ injectA2UITool: true }),\n * );\n * ```\n */\nexport class A2UIV09BridgeMiddleware extends Middleware {\n private readonly agentVersion: A2UIVersion;\n\n constructor(options: { agentVersion?: A2UIVersion } = {}) {\n super();\n this.agentVersion = options.agentVersion ?? \"1.0\";\n }\n\n run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent> {\n const upgrader = createA2UIV09ActivityUpgrader();\n return this.runNext(\n prepareA2UIV09AgentInput(input, this.agentVersion),\n next,\n ).pipe(concatMap((event) => upgrader.transform(event)));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,SAAgB,mBACd,cACA,SACa;CACb,MAAM,SACJ,OAAO,iBAAiB,WAAW,aAAa,cAAc;AAGhE,SADE,OAAO,WAAW,YAAY,WAAW,OAAO,OAAO,WAAW,YACjD,QAAQ,QAAQ;;;;;;;;;;;;;;AAerC,SAAgB,yBACd,OACA,cACe;CACf,MAAM,aAAa,uBAAuB,OAAO,EAAE,cAAc,CAAC;AAClE,KAAI,iBAAiB,MAAO,QAAO;CACnC,MAAM,UAAU,2BAA2B,WAAW;AACtD,KAAI,CAAC,QAAS,QAAO;CACrB,MAAM,eAAe,IAAI,IAAI,QAAQ,QAAQ,KAAK,MAAM,EAAE,YAAY,CAAC;AACvE,QAAO;EACL,GAAG;EACH,SAAS,CACP,IAAI,WAAW,WAAW,EAAE,EAAE,QAC3B,UAAU,CAAC,aAAa,IAAI,MAAM,YAAY,CAChD,EACD,GAAG,QAAQ,QACZ;EACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BH,IAAa,0BAAb,cAA6C,WAAW;CAGtD,YAAY,UAA0C,EAAE,EAAE;AACxD,SAAO;AACP,OAAK,eAAe,QAAQ,gBAAgB;;CAG9C,IAAI,OAAsB,MAA4C;EACpE,MAAM,WAAW,+BAA+B;AAChD,SAAO,KAAK,QACV,yBAAyB,OAAO,KAAK,aAAa,EAClD,KACD,CAAC,KAAK,WAAW,UAAU,SAAS,UAAU,MAAM,CAAC,CAAC"}