@superdurable/dex-agents 0.2.0 → 0.4.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 (92) hide show
  1. package/README.md +143 -6
  2. package/dist/src/agent-context-compaction.d.ts +150 -4
  3. package/dist/src/agent-context-compaction.js +253 -5
  4. package/dist/src/agent-context-compaction.js.map +1 -1
  5. package/dist/src/agent-framework-runner.d.ts +89 -0
  6. package/dist/src/agent-framework-runner.js +26 -0
  7. package/dist/src/agent-framework-runner.js.map +1 -1
  8. package/dist/src/agent-session-codecs.js +9 -0
  9. package/dist/src/agent-session-codecs.js.map +1 -1
  10. package/dist/src/agent-session-failure.d.ts +58 -0
  11. package/dist/src/agent-session-failure.js +126 -0
  12. package/dist/src/agent-session-failure.js.map +1 -0
  13. package/dist/src/agent-session-flow-graph-cli.d.ts +2 -0
  14. package/dist/src/agent-session-flow-graph-cli.js +47 -0
  15. package/dist/src/agent-session-flow-graph-cli.js.map +1 -0
  16. package/dist/src/agent-session-flow-graph.d.ts +38 -0
  17. package/dist/src/agent-session-flow-graph.js +54 -0
  18. package/dist/src/agent-session-flow-graph.js.map +1 -0
  19. package/dist/src/agent-session-flow-graph.json +2204 -0
  20. package/dist/src/agent-session-flow.d.ts +23 -2
  21. package/dist/src/agent-session-flow.js +5 -0
  22. package/dist/src/agent-session-flow.js.map +1 -1
  23. package/dist/src/agent-session-spend-limit.d.ts +156 -0
  24. package/dist/src/agent-session-spend-limit.js +42 -0
  25. package/dist/src/agent-session-spend-limit.js.map +1 -0
  26. package/dist/src/agent-session-start.d.ts +49 -0
  27. package/dist/src/agent-session-start.js +67 -0
  28. package/dist/src/agent-session-start.js.map +1 -0
  29. package/dist/src/agent-session-step-options.d.ts +52 -1
  30. package/dist/src/agent-session-step-options.js +34 -2
  31. package/dist/src/agent-session-step-options.js.map +1 -1
  32. package/dist/src/agent-session-steps.d.ts +9 -0
  33. package/dist/src/agent-session-steps.js +247 -50
  34. package/dist/src/agent-session-steps.js.map +1 -1
  35. package/dist/src/agent-session-transitions.d.ts +14 -1
  36. package/dist/src/agent-session-transitions.js +61 -1
  37. package/dist/src/agent-session-transitions.js.map +1 -1
  38. package/dist/src/agent-session-values.d.ts +43 -2
  39. package/dist/src/agent-session-values.js +6 -0
  40. package/dist/src/agent-session-values.js.map +1 -1
  41. package/dist/src/agent-session-wait-steps.js +3 -3
  42. package/dist/src/agent-session-wait-steps.js.map +1 -1
  43. package/dist/src/connectors/connector-input-schema.d.ts +19 -0
  44. package/dist/src/connectors/connector-input-schema.js +228 -0
  45. package/dist/src/connectors/connector-input-schema.js.map +1 -0
  46. package/dist/src/connectors/connector-step-context.d.ts +77 -0
  47. package/dist/src/connectors/connector-step-context.js +124 -0
  48. package/dist/src/connectors/connector-step-context.js.map +1 -0
  49. package/dist/src/connectors/connector-tool-source.d.ts +353 -0
  50. package/dist/src/connectors/connector-tool-source.js +541 -0
  51. package/dist/src/connectors/connector-tool-source.js.map +1 -0
  52. package/dist/src/connectors/index.d.ts +3 -0
  53. package/dist/src/connectors/index.js +11 -0
  54. package/dist/src/connectors/index.js.map +1 -0
  55. package/dist/src/index.d.ts +10 -3
  56. package/dist/src/index.js +8 -2
  57. package/dist/src/index.js.map +1 -1
  58. package/dist/src/stepwise/agent-definition.d.ts +8 -0
  59. package/dist/src/stepwise/index.d.ts +2 -1
  60. package/dist/src/stepwise/index.js +2 -1
  61. package/dist/src/stepwise/index.js.map +1 -1
  62. package/dist/src/stepwise/stepwise-agent-runner.d.ts +15 -32
  63. package/dist/src/stepwise/stepwise-agent-runner.js +37 -200
  64. package/dist/src/stepwise/stepwise-agent-runner.js.map +1 -1
  65. package/dist/src/stepwise/stepwise-agent-session-flow.js +1 -0
  66. package/dist/src/stepwise/stepwise-agent-session-flow.js.map +1 -1
  67. package/dist/src/stepwise/tool-source.d.ts +11 -1
  68. package/dist/src/testing/agent-session-test-client.js +2 -5
  69. package/dist/src/testing/agent-session-test-client.js.map +1 -1
  70. package/dist/src/testing/context-window.d.ts +194 -0
  71. package/dist/src/testing/context-window.js +360 -0
  72. package/dist/src/testing/context-window.js.map +1 -0
  73. package/dist/src/testing/index.d.ts +1 -0
  74. package/dist/src/testing/index.js +1 -0
  75. package/dist/src/testing/index.js.map +1 -1
  76. package/dist/src/tool-source-router.d.ts +211 -0
  77. package/dist/src/tool-source-router.js +380 -0
  78. package/dist/src/tool-source-router.js.map +1 -0
  79. package/dist/src/ui-stream/agent-event-sse.d.ts +3 -2
  80. package/dist/src/ui-stream/agent-event-sse.js +11 -3
  81. package/dist/src/ui-stream/agent-event-sse.js.map +1 -1
  82. package/dist/src/ui-stream/agent-session-record-reader.d.ts +2 -0
  83. package/dist/src/ui-stream/agent-session-record-reader.js +5 -0
  84. package/dist/src/ui-stream/agent-session-record-reader.js.map +1 -1
  85. package/dist/src/ui-stream/agent-ui-message-stream-responses.js +3 -2
  86. package/dist/src/ui-stream/agent-ui-message-stream-responses.js.map +1 -1
  87. package/dist/src/ui-stream/agent-ui-message-stream.js +17 -3
  88. package/dist/src/ui-stream/agent-ui-message-stream.js.map +1 -1
  89. package/dist/src/ui-stream/agent-ui-messages.d.ts +2 -0
  90. package/dist/src/ui-stream/agent-ui-messages.js +5 -3
  91. package/dist/src/ui-stream/agent-ui-messages.js.map +1 -1
  92. package/package.json +15 -3
@@ -0,0 +1,38 @@
1
+ /** What an application chooses for the session Flow Definition Graph of one agent. */
2
+ export interface SessionFlowGraphOptions {
3
+ /** The Flow type of the agent, as passed to `createAgentSessionFlow`. */
4
+ readonly flowType: string;
5
+ /** The permission every session Action requires, such as `support-agent.operate`. */
6
+ readonly actionPermission: string;
7
+ }
8
+ /**
9
+ * Renders the Flow Definition Graph 2.0 file of one agent's session Flow.
10
+ *
11
+ * `dexcli visualize` cannot read the session Flow: the Flow lives in this library, and the application chooses its
12
+ * Flow type. This function fills both choices into the graph that ships with the package. Write the text to a file in
13
+ * the directory that Dex Web reads with `--flow-rendering-dir`. Dex Web then draws the session Steps and offers the
14
+ * `resolve_interrupt`, `answer_question`, `steer_user_message`, and `cancel_turn` Actions. Those Actions have no
15
+ * condition, because each RPC checks current state itself.
16
+ *
17
+ * The Python core renders the same bytes, so a graph from either core serves a session on Workers of either language.
18
+ * Render the file again after you upgrade this package. The `dex-agents-session-graph` command does the same from a
19
+ * build or deployment script.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { writeFileSync } from "node:fs";
24
+ * import { renderSessionFlowGraph } from "@superdurable/dex-agents";
25
+ *
26
+ * writeFileSync(
27
+ * "definitions/support-agent.json",
28
+ * renderSessionFlowGraph({ flowType: "SupportAgent", actionPermission: "support-agent.operate" }),
29
+ * );
30
+ * ```
31
+ *
32
+ * @param options - The Flow type and the Action permission.
33
+ * @returns The graph as JSON text that ends with a newline.
34
+ * @throws {TypeError} When `flowType` is blank, or when `actionPermission` is not lowercase letters, digits, dots, and
35
+ * hyphens that start with a letter.
36
+ * @since 0.3.0
37
+ */
38
+ export declare function renderSessionFlowGraph(options: SessionFlowGraphOptions): string;
@@ -0,0 +1,54 @@
1
+ // Copyright (c) 2026 Super Durable, Inc.
2
+ //
3
+ // Licensed under the Sustainable Use License 1.0.
4
+ // You may not use this file except in compliance with the License.
5
+ // See the LICENSE file in the repository root.
6
+ //
7
+ // SPDX-License-Identifier: LicenseRef-Sustainable-Use-1.0
8
+ import sessionFlowGraphTemplate from "./agent-session-flow-graph.json" with { type: "json" };
9
+ const actionPermissionPattern = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*$/;
10
+ /**
11
+ * Renders the Flow Definition Graph 2.0 file of one agent's session Flow.
12
+ *
13
+ * `dexcli visualize` cannot read the session Flow: the Flow lives in this library, and the application chooses its
14
+ * Flow type. This function fills both choices into the graph that ships with the package. Write the text to a file in
15
+ * the directory that Dex Web reads with `--flow-rendering-dir`. Dex Web then draws the session Steps and offers the
16
+ * `resolve_interrupt`, `answer_question`, `steer_user_message`, and `cancel_turn` Actions. Those Actions have no
17
+ * condition, because each RPC checks current state itself.
18
+ *
19
+ * The Python core renders the same bytes, so a graph from either core serves a session on Workers of either language.
20
+ * Render the file again after you upgrade this package. The `dex-agents-session-graph` command does the same from a
21
+ * build or deployment script.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { writeFileSync } from "node:fs";
26
+ * import { renderSessionFlowGraph } from "@superdurable/dex-agents";
27
+ *
28
+ * writeFileSync(
29
+ * "definitions/support-agent.json",
30
+ * renderSessionFlowGraph({ flowType: "SupportAgent", actionPermission: "support-agent.operate" }),
31
+ * );
32
+ * ```
33
+ *
34
+ * @param options - The Flow type and the Action permission.
35
+ * @returns The graph as JSON text that ends with a newline.
36
+ * @throws {TypeError} When `flowType` is blank, or when `actionPermission` is not lowercase letters, digits, dots, and
37
+ * hyphens that start with a letter.
38
+ * @since 0.3.0
39
+ */
40
+ export function renderSessionFlowGraph(options) {
41
+ if (options.flowType.trim() === "") {
42
+ throw new TypeError("flowType must not be empty");
43
+ }
44
+ if (!actionPermissionPattern.test(options.actionPermission)) {
45
+ throw new TypeError(`actionPermission ${JSON.stringify(options.actionPermission)} is not a valid permission`);
46
+ }
47
+ const graph = structuredClone(sessionFlowGraphTemplate);
48
+ graph.flow.name = options.flowType;
49
+ for (const action of graph.v2.actions) {
50
+ action.requiredPermission = options.actionPermission;
51
+ }
52
+ return `${JSON.stringify(graph, null, 2)}\n`;
53
+ }
54
+ //# sourceMappingURL=agent-session-flow-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-session-flow-graph.js","sourceRoot":"","sources":["../../src/agent-session-flow-graph.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,kDAAkD;AAClD,mEAAmE;AACnE,+CAA+C;AAC/C,EAAE;AACF,0DAA0D;AAE1D,OAAO,wBAAwB,MAAM,iCAAiC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAE7F,MAAM,uBAAuB,GAAG,oCAAoC,CAAC;AAUrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAgC;IACrE,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACnC,MAAM,IAAI,SAAS,CAAC,4BAA4B,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,SAAS,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,gBAAgB,CAAC,4BAA4B,CAAC,CAAC;IAChH,CAAC;IACD,MAAM,KAAK,GAAG,eAAe,CAAC,wBAAwB,CAAC,CAAC;IACxD,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC;IACnC,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;QACtC,MAAM,CAAC,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IACvD,CAAC;IACD,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC"}