@relayflows/sdk 2.0.55 → 2.0.56

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 (179) hide show
  1. package/dist/authored-broker.d.ts +13 -0
  2. package/dist/authored-broker.d.ts.map +1 -0
  3. package/dist/authored-broker.js +75 -0
  4. package/dist/authored-broker.js.map +1 -0
  5. package/dist/authored-budget.d.ts +1 -1
  6. package/dist/authored-budget.d.ts.map +1 -1
  7. package/dist/authored-budget.js +8 -2
  8. package/dist/authored-budget.js.map +1 -1
  9. package/dist/authored-flow-error.d.ts +6 -0
  10. package/dist/authored-flow-error.d.ts.map +1 -1
  11. package/dist/authored-flow-error.js.map +1 -1
  12. package/dist/authored-flow-executor.d.ts +11 -0
  13. package/dist/authored-flow-executor.d.ts.map +1 -1
  14. package/dist/authored-flow-executor.js +104 -20
  15. package/dist/authored-flow-executor.js.map +1 -1
  16. package/dist/authored-flow-loader.d.ts.map +1 -1
  17. package/dist/authored-flow-loader.js +42 -3
  18. package/dist/authored-flow-loader.js.map +1 -1
  19. package/dist/authored-helper-effect.d.ts.map +1 -1
  20. package/dist/authored-helper-effect.js +1 -1
  21. package/dist/authored-helper-effect.js.map +1 -1
  22. package/dist/authored-hooks.d.ts +2 -1
  23. package/dist/authored-hooks.d.ts.map +1 -1
  24. package/dist/authored-hooks.js +2 -2
  25. package/dist/authored-hooks.js.map +1 -1
  26. package/dist/authored-human.d.ts +18 -0
  27. package/dist/authored-human.d.ts.map +1 -1
  28. package/dist/authored-human.js +32 -4
  29. package/dist/authored-human.js.map +1 -1
  30. package/dist/authored-mcp.d.ts.map +1 -1
  31. package/dist/authored-mcp.js +3 -2
  32. package/dist/authored-mcp.js.map +1 -1
  33. package/dist/authored-node-entry.js +4 -0
  34. package/dist/authored-node-entry.js.map +1 -1
  35. package/dist/authored-node-runner.d.ts.map +1 -1
  36. package/dist/authored-node-runner.js +1 -0
  37. package/dist/authored-node-runner.js.map +1 -1
  38. package/dist/authored-plugin-effect.d.ts.map +1 -1
  39. package/dist/authored-plugin-effect.js +3 -2
  40. package/dist/authored-plugin-effect.js.map +1 -1
  41. package/dist/authored-preflight.d.ts.map +1 -1
  42. package/dist/authored-preflight.js +2 -1
  43. package/dist/authored-preflight.js.map +1 -1
  44. package/dist/authored-root.d.ts.map +1 -1
  45. package/dist/authored-root.js +13 -3
  46. package/dist/authored-root.js.map +1 -1
  47. package/dist/authored-serial-ordinals.d.ts +41 -0
  48. package/dist/authored-serial-ordinals.d.ts.map +1 -0
  49. package/dist/authored-serial-ordinals.js +45 -0
  50. package/dist/authored-serial-ordinals.js.map +1 -0
  51. package/dist/authored-worker-step.d.ts +5 -1
  52. package/dist/authored-worker-step.d.ts.map +1 -1
  53. package/dist/authored-worker-step.js +19 -2
  54. package/dist/authored-worker-step.js.map +1 -1
  55. package/dist/budget-preflight.d.ts.map +1 -1
  56. package/dist/budget-preflight.js +11 -2
  57. package/dist/budget-preflight.js.map +1 -1
  58. package/dist/bundle-transport.d.ts +2 -0
  59. package/dist/bundle-transport.d.ts.map +1 -1
  60. package/dist/bundle-transport.js +4 -0
  61. package/dist/bundle-transport.js.map +1 -1
  62. package/dist/cached-flow-runtime.d.ts +3 -0
  63. package/dist/cached-flow-runtime.d.ts.map +1 -0
  64. package/dist/cached-flow-runtime.js +37 -0
  65. package/dist/cached-flow-runtime.js.map +1 -0
  66. package/dist/cli/check.d.ts.map +1 -1
  67. package/dist/cli/check.js +13 -1
  68. package/dist/cli/check.js.map +1 -1
  69. package/dist/cli/cloud-deploy.js +6 -5
  70. package/dist/cli/cloud-deploy.js.map +1 -1
  71. package/dist/cli/cloud-mirror-session.d.ts +8 -2
  72. package/dist/cli/cloud-mirror-session.d.ts.map +1 -1
  73. package/dist/cli/cloud-mirror-session.js +20 -27
  74. package/dist/cli/cloud-mirror-session.js.map +1 -1
  75. package/dist/cli/direct-run.d.ts.map +1 -1
  76. package/dist/cli/direct-run.js +2 -1
  77. package/dist/cli/direct-run.js.map +1 -1
  78. package/dist/cli/run.d.ts.map +1 -1
  79. package/dist/cli/run.js +19 -4
  80. package/dist/cli/run.js.map +1 -1
  81. package/dist/cli.d.ts.map +1 -1
  82. package/dist/cli.js +39 -18
  83. package/dist/cli.js.map +1 -1
  84. package/dist/cloud-deploy.d.ts +3 -3
  85. package/dist/cloud-deploy.d.ts.map +1 -1
  86. package/dist/cloud-deploy.js +15 -9
  87. package/dist/cloud-deploy.js.map +1 -1
  88. package/dist/cloud-flow-source.d.ts +13 -0
  89. package/dist/cloud-flow-source.d.ts.map +1 -0
  90. package/dist/cloud-flow-source.js +55 -0
  91. package/dist/cloud-flow-source.js.map +1 -0
  92. package/dist/cloud-mirror-transport.d.ts +2 -0
  93. package/dist/cloud-mirror-transport.d.ts.map +1 -1
  94. package/dist/cloud-mirror-transport.js +2 -0
  95. package/dist/cloud-mirror-transport.js.map +1 -1
  96. package/dist/cloud-mirror.d.ts.map +1 -1
  97. package/dist/cloud-mirror.js +10 -1
  98. package/dist/cloud-mirror.js.map +1 -1
  99. package/dist/communication/broker-preflight.d.ts +3 -0
  100. package/dist/communication/broker-preflight.d.ts.map +1 -0
  101. package/dist/communication/broker-preflight.js +22 -0
  102. package/dist/communication/broker-preflight.js.map +1 -0
  103. package/dist/communication/broker-spec.d.ts +20 -0
  104. package/dist/communication/broker-spec.d.ts.map +1 -0
  105. package/dist/communication/broker-spec.js +46 -0
  106. package/dist/communication/broker-spec.js.map +1 -0
  107. package/dist/communication/broker-worker.d.ts +17 -0
  108. package/dist/communication/broker-worker.d.ts.map +1 -0
  109. package/dist/communication/broker-worker.js +214 -0
  110. package/dist/communication/broker-worker.js.map +1 -0
  111. package/dist/communication/pty.d.ts +29 -0
  112. package/dist/communication/pty.d.ts.map +1 -0
  113. package/dist/communication/pty.js +40 -0
  114. package/dist/communication/pty.js.map +1 -0
  115. package/dist/communication/relay.d.ts +18 -0
  116. package/dist/communication/relay.d.ts.map +1 -1
  117. package/dist/communication/relay.js +4 -0
  118. package/dist/communication/relay.js.map +1 -1
  119. package/dist/communication/skills.d.ts +3 -0
  120. package/dist/communication/skills.d.ts.map +1 -0
  121. package/dist/communication/skills.js +17 -0
  122. package/dist/communication/skills.js.map +1 -0
  123. package/dist/communication/worker.d.ts.map +1 -1
  124. package/dist/communication/worker.js +9 -26
  125. package/dist/communication/worker.js.map +1 -1
  126. package/dist/failure-kinds.d.ts +1 -1
  127. package/dist/failure-kinds.d.ts.map +1 -1
  128. package/dist/failure-kinds.js +2 -0
  129. package/dist/failure-kinds.js.map +1 -1
  130. package/dist/plugin-manifest.js +1 -1
  131. package/dist/plugin-manifest.js.map +1 -1
  132. package/dist/preflight.d.ts.map +1 -1
  133. package/dist/preflight.js +2 -1
  134. package/dist/preflight.js.map +1 -1
  135. package/dist/worker.d.ts +1 -0
  136. package/dist/worker.d.ts.map +1 -1
  137. package/dist/worker.js +12 -0
  138. package/dist/worker.js.map +1 -1
  139. package/package.json +2 -2
  140. package/src/authored-broker.ts +73 -0
  141. package/src/authored-budget.ts +6 -2
  142. package/src/authored-flow-error.ts +6 -0
  143. package/src/authored-flow-executor.ts +115 -20
  144. package/src/authored-flow-loader.ts +43 -3
  145. package/src/authored-helper-effect.ts +2 -1
  146. package/src/authored-hooks.ts +4 -3
  147. package/src/authored-human.ts +35 -4
  148. package/src/authored-mcp.ts +7 -2
  149. package/src/authored-node-entry.ts +4 -1
  150. package/src/authored-node-runner.ts +1 -0
  151. package/src/authored-plugin-effect.ts +7 -2
  152. package/src/authored-preflight.ts +2 -1
  153. package/src/authored-root.ts +13 -3
  154. package/src/authored-serial-ordinals.ts +76 -0
  155. package/src/authored-worker-step.ts +17 -2
  156. package/src/budget-preflight.ts +9 -1
  157. package/src/bundle-transport.ts +4 -0
  158. package/src/cached-flow-runtime.ts +32 -0
  159. package/src/cli/check.ts +11 -1
  160. package/src/cli/cloud-deploy.ts +5 -5
  161. package/src/cli/cloud-mirror-session.ts +23 -29
  162. package/src/cli/direct-run.ts +2 -1
  163. package/src/cli/run.ts +18 -3
  164. package/src/cli.ts +31 -13
  165. package/src/cloud-deploy.ts +19 -14
  166. package/src/cloud-flow-source.ts +58 -0
  167. package/src/cloud-mirror-transport.ts +4 -0
  168. package/src/cloud-mirror.ts +9 -1
  169. package/src/communication/broker-preflight.ts +22 -0
  170. package/src/communication/broker-spec.ts +48 -0
  171. package/src/communication/broker-worker.ts +198 -0
  172. package/src/communication/pty.ts +47 -0
  173. package/src/communication/relay.ts +12 -1
  174. package/src/communication/skills.ts +16 -0
  175. package/src/communication/worker.ts +9 -26
  176. package/src/failure-kinds.ts +2 -0
  177. package/src/plugin-manifest.ts +1 -1
  178. package/src/preflight.ts +3 -1
  179. package/src/worker.ts +11 -0
@@ -39,7 +39,7 @@ export interface PluginManifest {
39
39
  preflight: { credentials: readonly string[]; servers: readonly string[] };
40
40
  }
41
41
  const identifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
42
- const reserved = new Set(['run', 'llm', 'agent', 'human', 'dispatch', 'done', 'cloud', 'memory', 'mcp', 'slack', '__proto__', 'constructor', 'prototype', 'then']);
42
+ const reserved = new Set(['run', 'llm', 'agent', 'message', 'release', 'human', 'dispatch', 'done', 'cloud', 'memory', 'mcp', 'slack', '__proto__', 'constructor', 'prototype', 'then']);
43
43
  const object = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);
44
44
  const strings = (v: unknown): v is string[] => Array.isArray(v) && v.every(s => typeof s === 'string' && s.trim().length > 0);
45
45
  export function pluginPackageName(name: string): string {
package/src/preflight.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { brokerInstruction } from './communication/broker-spec.js';
1
2
  import { communicationInstruction } from './communication/spec.js';
2
3
  import { loadPlugins, type LoadedPlugin } from './plugin-loader.js';
3
4
  import { PluginError } from './plugin-manifest.js';
@@ -340,7 +341,8 @@ function preflightSync(flow: unknown, options: PreflightOptions): PreflightResul
340
341
  }
341
342
  const resolution = resolutionByStep.get(step.id)!;
342
343
  probeResolvedCli(resolution, options.probes, cliProbeResults, diagnostics,
343
- step.type === 'agent' && communicationInstruction(step.instruction) !== undefined, step.secrets);
344
+ step.type === 'agent' && (communicationInstruction(step.instruction) !== undefined || brokerInstruction(step.instruction) !== undefined),
345
+ step.secrets);
344
346
  }
345
347
 
346
348
  for (const trigger of compiled.triggers ?? []) {
package/src/worker.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { brokerInstruction } from './communication/broker-spec.js';
2
+ import { BrokerSessions } from './communication/broker-worker.js';
1
3
  import { communicationInstruction } from './communication/spec.js';
2
4
  import { workerSpend } from './worker-spend.js';
3
5
  import { reportedCost } from './reported-cost.js';
@@ -60,6 +62,7 @@ export interface AgentWorkerOptions {
60
62
  * shutdown.
61
63
  */
62
64
  export class AgentWorker extends EventEmitter {
65
+ private readonly brokerSessions: BrokerSessions;
63
66
  private attached = false;
64
67
  private closing = false;
65
68
  private readonly inFlight: Set<Promise<void>> = new Set();
@@ -69,6 +72,7 @@ export class AgentWorker extends EventEmitter {
69
72
  private readonly options: AgentWorkerOptions,
70
73
  ) {
71
74
  super();
75
+ this.brokerSessions = new BrokerSessions(options.runRoot, options.environment);
72
76
  }
73
77
 
74
78
  async attach(): Promise<void> {
@@ -107,6 +111,7 @@ export class AgentWorker extends EventEmitter {
107
111
  if (pending.length > 0) {
108
112
  await Promise.allSettled(pending);
109
113
  }
114
+ await this.brokerSessions.close();
110
115
  this.attached = false;
111
116
  }
112
117
 
@@ -128,6 +133,12 @@ export class AgentWorker extends EventEmitter {
128
133
  await completeHelperDispatch(this.client, dispatch, helper, this.options.dataDir);
129
134
  return;
130
135
  }
136
+ const broker = brokerInstruction(spec.instruction);
137
+ if (broker) {
138
+ if (!this.options.dataDir) throw new Error('Broker agents require a worker data directory');
139
+ await this.brokerSessions.complete(this.client, dispatch, broker, this.options.dataDir);
140
+ return;
141
+ }
131
142
  const communication = communicationInstruction(spec.instruction);
132
143
  if (communication) {
133
144
  if (!this.options.dataDir) throw new Error('Agent communication requires a worker data directory');