@nylorun/runtime 0.15.1-beta → 0.16.0-beta

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 (220) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +33 -6
  3. package/dist/adapters/execution/restate.d.ts +9 -1
  4. package/dist/adapters/execution/restate.js +64 -5
  5. package/dist/adapters/replication/pgoutput.js +3 -1
  6. package/dist/adapters/sandbox/local.d.ts +10 -0
  7. package/dist/adapters/sandbox/local.js +195 -0
  8. package/dist/adapters/sandbox/virtual.js +36 -1
  9. package/dist/admin-openapi.json +37 -3
  10. package/dist/api/a2a/tasks.js +6 -1
  11. package/dist/api/ag-ui/history.js +6 -1
  12. package/dist/api/ag-ui/routes.js +5 -1
  13. package/dist/api/components.d.ts +2673 -655
  14. package/dist/api/components.js +17 -1
  15. package/dist/api/gate/keys.d.ts +4 -3
  16. package/dist/api/gate/routes.d.ts +19 -3
  17. package/dist/api/gate/routes.js +162 -53
  18. package/dist/api/http/app.js +4 -0
  19. package/dist/api/http/define.d.ts +10 -0
  20. package/dist/api/http/define.js +2 -1
  21. package/dist/api/http/routes/artifacts.d.ts +11 -0
  22. package/dist/api/http/routes/artifacts.js +518 -0
  23. package/dist/api/http/routes/sandboxes.d.ts +9 -0
  24. package/dist/api/http/routes/sandboxes.js +152 -0
  25. package/dist/api/http/routes/sessions.js +3 -1
  26. package/dist/api/http/routes/tenant.js +36 -2
  27. package/dist/artifacts/config.d.ts +23 -0
  28. package/dist/artifacts/config.js +27 -0
  29. package/dist/artifacts/export.d.ts +8 -0
  30. package/dist/artifacts/export.js +205 -0
  31. package/dist/artifacts/files.d.ts +36 -0
  32. package/dist/artifacts/files.js +45 -0
  33. package/dist/artifacts/folders.d.ts +60 -0
  34. package/dist/artifacts/folders.js +209 -0
  35. package/dist/artifacts/links.d.ts +28 -0
  36. package/dist/artifacts/links.js +92 -0
  37. package/dist/artifacts/media-types.d.ts +13 -0
  38. package/dist/artifacts/media-types.js +80 -0
  39. package/dist/artifacts/parts.d.ts +34 -0
  40. package/dist/artifacts/parts.js +38 -0
  41. package/dist/artifacts/service.d.ts +74 -0
  42. package/dist/artifacts/service.js +301 -0
  43. package/dist/artifacts/workspace.d.ts +60 -0
  44. package/dist/artifacts/workspace.js +57 -0
  45. package/dist/artifacts/zip.d.ts +10 -0
  46. package/dist/artifacts/zip.js +126 -0
  47. package/dist/blob/fs.d.ts +13 -0
  48. package/dist/blob/fs.js +194 -0
  49. package/dist/blob/index.d.ts +9 -0
  50. package/dist/blob/index.js +9 -0
  51. package/dist/blob/s3.d.ts +42 -0
  52. package/dist/blob/s3.js +366 -0
  53. package/dist/blob/types.d.ts +108 -0
  54. package/dist/blob/types.js +85 -0
  55. package/dist/core/sandbox-routes.d.ts +2 -2
  56. package/dist/core/sandbox-routes.js +4 -3
  57. package/dist/execution/memory.d.ts +11 -1
  58. package/dist/execution/memory.js +77 -3
  59. package/dist/execution/types.d.ts +54 -1
  60. package/dist/execution/types.js +31 -0
  61. package/dist/gates/contract.d.ts +14 -13
  62. package/dist/gates/contract.js +13 -12
  63. package/dist/gates/egress.d.ts +72 -0
  64. package/dist/gates/egress.js +319 -0
  65. package/dist/gates/handler.d.ts +3 -0
  66. package/dist/gates/handler.js +3 -2
  67. package/dist/gates/http-client.d.ts +3 -2
  68. package/dist/gates/http-client.js +17 -6
  69. package/dist/gates/in-process.d.ts +13 -1
  70. package/dist/gates/in-process.js +11 -0
  71. package/dist/gates/inflight.d.ts +23 -4
  72. package/dist/gates/inflight.js +18 -4
  73. package/dist/gates/model-gate.d.ts +6 -2
  74. package/dist/gates/tool-calls.d.ts +9 -5
  75. package/dist/gates/tool-calls.js +6 -6
  76. package/dist/gates/tool-client.d.ts +9 -2
  77. package/dist/gates/tool-client.js +56 -22
  78. package/dist/gates/tool-contract.d.ts +12 -7
  79. package/dist/gates/tool-contract.js +10 -4
  80. package/dist/gates/tool-gate.d.ts +1 -0
  81. package/dist/harness/calls.d.ts +52 -0
  82. package/dist/harness/calls.js +113 -0
  83. package/dist/harness/executors.d.ts +22 -0
  84. package/dist/harness/executors.js +96 -0
  85. package/dist/harness/main.d.ts +6 -0
  86. package/dist/harness/main.js +103 -0
  87. package/dist/harness/pod.d.ts +21 -0
  88. package/dist/harness/pod.js +119 -0
  89. package/dist/harness/run-tokens.d.ts +18 -0
  90. package/dist/harness/run-tokens.js +15 -0
  91. package/dist/harness/service.d.ts +46 -0
  92. package/dist/harness/service.js +179 -0
  93. package/dist/harness/ws-client.d.ts +43 -0
  94. package/dist/harness/ws-client.js +122 -0
  95. package/dist/harness/ws-port.d.ts +22 -0
  96. package/dist/harness/ws-port.js +78 -0
  97. package/dist/harness-api/in-process.d.ts +24 -0
  98. package/dist/harness-api/in-process.js +119 -0
  99. package/dist/harness-api/record.d.ts +44 -0
  100. package/dist/harness-api/record.js +250 -0
  101. package/dist/harness-api/renew.d.ts +37 -0
  102. package/dist/harness-api/renew.js +77 -0
  103. package/dist/harness-api/server.d.ts +104 -0
  104. package/dist/harness-api/server.js +408 -0
  105. package/dist/harness-api/start.d.ts +36 -0
  106. package/dist/harness-api/start.js +118 -0
  107. package/dist/harness-api/workspace.d.ts +53 -0
  108. package/dist/harness-api/workspace.js +201 -0
  109. package/dist/harness-api/ws-server.d.ts +34 -0
  110. package/dist/harness-api/ws-server.js +227 -0
  111. package/dist/host/app.js +23 -2
  112. package/dist/host/gates.d.ts +27 -2
  113. package/dist/host/gates.js +46 -1
  114. package/dist/host/http.d.ts +4 -1
  115. package/dist/host/http.js +6 -1
  116. package/dist/host/main.js +135 -27
  117. package/dist/host/stack-config.d.ts +101 -1
  118. package/dist/host/stack-config.js +199 -8
  119. package/dist/mcp/snapshot.d.ts +8 -1
  120. package/dist/mcp/snapshot.js +28 -0
  121. package/dist/media.d.ts +5 -24
  122. package/dist/media.js +5 -0
  123. package/dist/model/pi-model.d.ts +6 -2
  124. package/dist/model/pi-model.js +39 -22
  125. package/dist/node/index.d.ts +1 -1
  126. package/dist/node/index.js +1 -1
  127. package/dist/openapi.json +15245 -8850
  128. package/dist/record/index.d.ts +1 -0
  129. package/dist/record/index.js +1 -0
  130. package/dist/record/sandbox.d.ts +25 -0
  131. package/dist/record/sandbox.js +43 -0
  132. package/dist/sandbox/capability.d.ts +3 -0
  133. package/dist/sandbox/capability.js +10 -0
  134. package/dist/sandbox/egress-token.d.ts +26 -0
  135. package/dist/sandbox/egress-token.js +8 -0
  136. package/dist/sandbox/join.d.ts +37 -0
  137. package/dist/sandbox/join.js +165 -0
  138. package/dist/sandbox/manager.d.ts +99 -34
  139. package/dist/sandbox/manager.js +216 -84
  140. package/dist/sandbox/placement.d.ts +27 -0
  141. package/dist/sandbox/placement.js +44 -0
  142. package/dist/sandbox/pods/client.d.ts +90 -0
  143. package/dist/sandbox/pods/client.js +79 -0
  144. package/dist/sandbox/pods/lifecycle.d.ts +91 -0
  145. package/dist/sandbox/pods/lifecycle.js +178 -0
  146. package/dist/sandbox/pods/name.d.ts +1 -0
  147. package/dist/sandbox/pods/name.js +28 -0
  148. package/dist/sandbox/pods/network-gate.d.ts +25 -0
  149. package/dist/sandbox/pods/network-gate.js +71 -0
  150. package/dist/sandbox/pods/reconcile.d.ts +11 -0
  151. package/dist/sandbox/pods/reconcile.js +152 -0
  152. package/dist/sandbox/pods/spec.d.ts +45 -0
  153. package/dist/sandbox/pods/spec.js +62 -0
  154. package/dist/sandbox/records.d.ts +29 -0
  155. package/dist/sandbox/records.js +79 -0
  156. package/dist/sandbox/resolve.d.ts +5 -0
  157. package/dist/sandbox/resolve.js +3 -2
  158. package/dist/sandbox/session-sandbox.js +7 -5
  159. package/dist/sandbox/share.d.ts +11 -0
  160. package/dist/sandbox/share.js +10 -0
  161. package/dist/sandbox/tenant-config.d.ts +16 -1
  162. package/dist/sandbox/tenant-config.js +9 -0
  163. package/dist/sandbox/types.d.ts +29 -1
  164. package/dist/sandbox/types.js +13 -1
  165. package/dist/store/postgres/drizzle/0004_sandbox_resources.sql +20 -0
  166. package/dist/store/postgres/drizzle/0005_artifacts.sql +27 -0
  167. package/dist/store/postgres/drizzle/0006_folder_artifacts.sql +12 -0
  168. package/dist/store/postgres/drizzle/0007_sandbox_pods.sql +14 -0
  169. package/dist/store/postgres/drizzle/meta/_journal.json +28 -0
  170. package/dist/store/postgres/record-writer.d.ts +6 -1
  171. package/dist/store/postgres/record-writer.js +20 -2
  172. package/dist/store/postgres/schema.d.ts +894 -0
  173. package/dist/store/postgres/schema.js +130 -2
  174. package/dist/store/postgres/store.js +289 -4
  175. package/dist/store/types.d.ts +143 -6
  176. package/dist/streams/control.d.ts +2 -0
  177. package/dist/streams/control.js +5 -0
  178. package/dist/streams/types.d.ts +10 -1
  179. package/dist/tenant/advance.js +218 -160
  180. package/dist/tenant/artifact-tool.d.ts +5 -0
  181. package/dist/tenant/artifact-tool.js +119 -0
  182. package/dist/tenant/commands.js +30 -5
  183. package/dist/tenant/context.d.ts +64 -5
  184. package/dist/tenant/effects.d.ts +19 -13
  185. package/dist/tenant/effects.js +5 -382
  186. package/dist/tenant/history.d.ts +13 -23
  187. package/dist/tenant/history.js +14 -62
  188. package/dist/tenant/host-token.d.ts +92 -0
  189. package/dist/tenant/host-token.js +179 -0
  190. package/dist/tenant/module.js +1 -0
  191. package/dist/tenant/paths.d.ts +2 -1
  192. package/dist/tenant/paths.js +3 -1
  193. package/dist/tenant/reset.d.ts +5 -2
  194. package/dist/tenant/reset.js +22 -2
  195. package/dist/tenant/run-grants.d.ts +49 -0
  196. package/dist/tenant/run-grants.js +62 -0
  197. package/dist/tenant/run-token.d.ts +70 -0
  198. package/dist/tenant/run-token.js +138 -0
  199. package/dist/tenant/runtime.d.ts +38 -0
  200. package/dist/tenant/runtime.js +120 -32
  201. package/dist/tenant/sandboxes.d.ts +119 -0
  202. package/dist/tenant/sandboxes.js +551 -0
  203. package/dist/tenant/session.d.ts +2 -13
  204. package/dist/tenant/session.js +4 -28
  205. package/dist/tenant/sessions.d.ts +5 -0
  206. package/dist/tenant/sessions.js +28 -1
  207. package/dist/tenant/status.d.ts +8 -3
  208. package/dist/tenant/status.js +5 -0
  209. package/dist/tenant/streams.d.ts +7 -0
  210. package/dist/tenant/streams.js +24 -1
  211. package/dist/tenant/sweep.js +37 -4
  212. package/dist/tenant/tokens.js +9 -2
  213. package/dist/tenant/types.d.ts +18 -1
  214. package/dist/tenant/worker.d.ts +11 -5
  215. package/dist/tenant/worker.js +12 -6
  216. package/dist/version.d.ts +1 -1
  217. package/dist/version.js +1 -1
  218. package/package.json +13 -10
  219. package/dist/adapters/media.d.ts +0 -24
  220. package/dist/adapters/media.js +0 -111
@@ -25,10 +25,12 @@ import { lockedSession, } from "./context.js";
25
25
  import { fail } from "./http.js";
26
26
  import { accessOf } from "./auth.js";
27
27
  import { chargeTurn } from "./subject-limits.js";
28
+ import { checkSandboxTurn } from "./sandboxes.js";
28
29
  import { actionTarget, rebaseSessionState, turnManifestOf, variantStore, } from "./session.js";
29
- import { signalSessionCancel } from "./streams.js";
30
+ import { signalActionOutcome, signalSessionCancel } from "./streams.js";
30
31
  import { toolIds } from "./transcript.js";
31
32
  import { slimModelEffects } from "./slim.js";
33
+ import { resolveMessageParts } from "../artifacts/parts.js";
32
34
  /** `outcome`, or a failed one when a tool's output does not match its stored output schema. */
33
35
  export function acceptedOutcome(action, outcome) {
34
36
  if (action.kind !== "tool" || !action.outputSchema)
@@ -178,6 +180,9 @@ export async function command(ctx, id, input, scope) {
178
180
  if (command.type === "message") {
179
181
  if (!["idle", "completed", "failed", "cancelled"].includes(s.status))
180
182
  fail(409, "Session has active or unresolved work");
183
+ // Every turn start on a sandbox: it exists, the token's `sbx` reaches it, and no other
184
+ // session's turn holds it. Before the charge, so a refused turn costs nothing.
185
+ await checkSandboxTurn(t, s, scope, ctx);
181
186
  // After the replay check above, so a retried message is never charged twice.
182
187
  if (scope.kind === "token" && scope.limits)
183
188
  await chargeTurn(t, scope.subject, scope.limits);
@@ -186,8 +191,17 @@ export async function command(ctx, id, input, scope) {
186
191
  if (s.history?.snapshot !== undefined)
187
192
  s.history = { ...s.history, from: s.history.snapshot };
188
193
  s.activeTurnId = randomUUID();
194
+ // File parts name artifacts the caller may read; each is pinned to a version now.
195
+ const parts = "parts" in command
196
+ ? await resolveMessageParts(t, command.parts, id, accessOf(scope))
197
+ : undefined;
198
+ const data = "data" in command ? command.data : undefined;
189
199
  if (isWorkflowManifest(s.manifest)) {
190
- const input = "content" in command ? command.content : command.data;
200
+ const input = "content" in command
201
+ ? command.content
202
+ : parts
203
+ ? { parts: parts.pinned }
204
+ : data;
191
205
  s.checkpoint = createFlowCheckpoint({
192
206
  manifest: s.manifest,
193
207
  sessionId: id,
@@ -214,9 +228,11 @@ export async function command(ctx, id, input, scope) {
214
228
  turnId: s.activeTurnId,
215
229
  input: "content" in command
216
230
  ? command.content
217
- : typeof command.data === "string"
218
- ? command.data
219
- : JSON.stringify(command.data),
231
+ : parts
232
+ ? { content: parts.engine }
233
+ : typeof data === "string"
234
+ ? data
235
+ : JSON.stringify(data),
220
236
  state: s.state,
221
237
  info: s.info,
222
238
  });
@@ -334,6 +350,15 @@ export async function recordActionOutcome(t, ctx, s, action, received, options =
334
350
  dedupeKey: `action_result:${action.turnId}:${action.actionId}:${action.generation}`,
335
351
  };
336
352
  t.afterCommit(() => ctx.wake(s.id, resultWake));
353
+ // A run held while the Action was pending goes on with it in the same lease (F6.2): here, or
354
+ // on the process whose harness holds it. The wake finds the session settled, or resumes it
355
+ // by replay when the run had already ended.
356
+ t.afterCommit(() => {
357
+ if (ctx.harness.holds(s.id))
358
+ ctx.harness.resolved(s.id, action.actionId, outcome);
359
+ else
360
+ signalActionOutcome(ctx, s.id, action.actionId);
361
+ });
337
362
  const event = await t.event(s.id, s.activeTurnId, "action.completed", {
338
363
  actionId: action.actionId,
339
364
  ...actionTarget(action),
@@ -27,12 +27,18 @@ import type { Keys } from "../keys/keys.js";
27
27
  import type { VaultService } from "../vault/service.js";
28
28
  import type { McpPool } from "../mcp/pool.js";
29
29
  import type { McpDiagnostic, McpSnapshot } from "../mcp/snapshot.js";
30
- import type { SandboxManager } from "../sandbox/manager.js";
30
+ import type { HarnessApiServer } from "../harness-api/server.js";
31
+ import type { WorkspacePort } from "../harness-api/workspace.js";
32
+ import type { SandboxesClient } from "../sandbox/pods/client.js";
33
+ import type { SandboxSignal } from "../execution/types.js";
31
34
  import type { TenantConfig } from "./types.js";
32
35
  import type { SessionStreams } from "./session-streams.js";
33
36
  import type { StuckInvocation, Wake } from "../execution/types.js";
34
37
  import type { WorkState } from "./scheduler.js";
35
38
  import type { SigningKeys } from "./signing-keys.js";
39
+ import type { BlobStore } from "../blob/index.js";
40
+ import type { WorkspaceReader } from "../artifacts/workspace.js";
41
+ import type { RunGrants } from "./run-grants.js";
36
42
  export interface Session {
37
43
  id: string;
38
44
  agentId: string;
@@ -70,14 +76,19 @@ export interface Session {
70
76
  mcpDiagnostics?: readonly McpDiagnostic[];
71
77
  /** Session id that keys the shared sandbox; absent means this session owns it. */
72
78
  sandboxOwnerId?: string;
79
+ /**
80
+ * The sandbox resource the session is attached to (`sandbox: { id }`): its workspace is the
81
+ * sandbox's, shared with every session attached to it, and it outlives the session.
82
+ */
83
+ sandboxId?: string;
73
84
  /**
74
85
  * The sandbox chosen when the session was opened, resolved against the Tenant's limits, or
75
86
  * inherited from the session it shares with. Absent when the session has no sandbox or its
76
87
  * definition declares one (`.sandbox()`).
77
88
  */
78
89
  sandbox?: SandboxManifest;
79
- /** Where `sandbox` came from. */
80
- sandboxSource?: "default" | "inline" | "shared";
90
+ /** Where `sandbox` came from: `sandbox` is a sandbox resource's spec. */
91
+ sandboxSource?: "default" | "inline" | "shared" | "sandbox";
81
92
  }
82
93
  export type AuthScope = {
83
94
  kind: "application";
@@ -94,6 +105,8 @@ export type AuthScope = {
94
105
  agents: ReadonlySet<string> | "*";
95
106
  role: string;
96
107
  limits?: RoleLimits;
108
+ /** The token's `sbx` grants: the sandboxes it reaches. Absent reaches none. */
109
+ sandboxes?: readonly string[];
97
110
  epoch: number;
98
111
  expiresAt: number;
99
112
  tokenId: string;
@@ -138,8 +151,16 @@ export interface TenantContext {
138
151
  readonly envelope: TenantEnvelope;
139
152
  readonly store: SessionStore;
140
153
  readonly vault: VaultService;
141
- readonly mcp: McpPool;
142
- readonly sandbox: SandboxManager;
154
+ /**
155
+ * The MCP pool of the Tenant's in-process harness. Absent when harnesses run elsewhere
156
+ * (`NYLORUN_HARNESS=remote`): each keeps its own (F6.2).
157
+ */
158
+ readonly mcp?: McpPool;
159
+ /**
160
+ * The workspace capability (F6.2): the Tenant's SandboxManager with an in-process harness,
161
+ * else the harness that serves workspaces (`harness-api/workspace.ts`).
162
+ */
163
+ readonly sandbox: WorkspacePort;
143
164
  readonly flowLimits: FlowLimits;
144
165
  readonly modelProvider: ModelProvider;
145
166
  /** True when the model comes from the Tenant vault selection, served by `modelGate`. */
@@ -157,6 +178,28 @@ export interface TenantContext {
157
178
  * `signingKeys`' private key.
158
179
  */
159
180
  readonly keys: Keys;
181
+ /**
182
+ * The Object store's `BlobStore` seam (D35): the Host's `s3` store (RustFS in the local
183
+ * stack), or the `fs` store under `paths.blobs` without one. Bytes only; Postgres holds what
184
+ * they mean, and a blob counts once a committed row names its key.
185
+ */
186
+ readonly blobs: BlobStore;
187
+ /**
188
+ * How core reads a session's sandbox workspace at turn end, to export its outputs (F8.2): over
189
+ * this process's `sandbox` today; over the Harness API's `workspace.read` from F6.2.
190
+ */
191
+ readonly workspaces: WorkspaceReader;
192
+ /**
193
+ * The run token of each session an advance of this process owns (F5): the credential the
194
+ * HTTP gate clients present for that session's model and MCP calls (`run-grants.ts`).
195
+ * Absent when the gates run in this process, which needs no token (G6).
196
+ */
197
+ readonly runGrants?: RunGrants;
198
+ /**
199
+ * The Harness API server (D37): advances offer their segments here, and the Tenant's
200
+ * harnesses (the in-process one, or attached ones) run them.
201
+ */
202
+ readonly harness: HarnessApiServer;
160
203
  /** Set by drain/close; reset clears it again. Stops new advances. */
161
204
  closing: boolean;
162
205
  /** Set once close has finished releasing resources. */
@@ -187,6 +230,16 @@ export interface TenantContext {
187
230
  * from `t.afterCommit`. Dropped while the Tenant is closing; the sweep re-sends it.
188
231
  */
189
232
  deliver(actionId: string): Promise<void>;
233
+ /**
234
+ * Sandbox pods (F7.2): the sandboxes service and the Runtime image pods copy the engine from.
235
+ * Absent without a cluster (`nylorun sandbox enable`): kind `pod` is `sandbox_unavailable`.
236
+ */
237
+ readonly pods?: TenantPods;
238
+ /**
239
+ * Seam: reconcile a pod sandbox, or arm one of its timers (`DurableExecution.sandbox`). Call
240
+ * it from `t.afterCommit`. Dropped while the Tenant is closing; the sweep re-sends reconciles.
241
+ */
242
+ sandboxSignal(sandboxId: string, signal: SandboxSignal): Promise<void>;
190
243
  /** This Tenant's execution invocations that need an operator, for Tenant status. */
191
244
  readonly stuckInvocations?: () => Promise<StuckInvocation[]>;
192
245
  /** Callbacks the Tenant sweep runs after its own steps (`sweep.ts`). */
@@ -225,3 +278,9 @@ export declare function loadSession(ctx: TenantContext, id: string, access?: Ses
225
278
  * the sandbox-sharing helpers, which walk that chain synchronously.
226
279
  */
227
280
  export declare function sandboxLookup(t: Tx, start: string | undefined): Promise<(id: string) => Session | undefined>;
281
+ /** The sandboxes service a Tenant drives its pod sandboxes with (`TenantContext.pods`). */
282
+ export interface TenantPods {
283
+ readonly client: SandboxesClient;
284
+ /** The Runtime image the pods copy the engine from (`NYLORUN_SANDBOX_HARNESS_IMAGE`). */
285
+ readonly harnessImage: string;
286
+ }
@@ -1,18 +1,27 @@
1
+ /**
2
+ * Core's side of effects: `resolveNewFlowEffect` journals and dispatches new workflow effects
3
+ * (linked agent sessions, tool nodes, fn, verify); the takeover helpers say which calls their
4
+ * gate recovers. Also vault authorization for MCP servers. The journal of a run's effects is
5
+ * `harness-api/record.ts`; a harness readies the session's MCP servers itself (`session.mcp`).
6
+ *
7
+ * Every journal write runs in a transaction that locks the effect's session first and checks
8
+ * the advance's ownership epoch (`ownedSession`): after another Worker takes over, the next
9
+ * write throws `ownership.lost` and nothing is written. The model, MCP, sandbox and vault
10
+ * calls run between transactions, never inside one.
11
+ */
12
+ import type { ActionOutcome } from "@nylorun/core/contracts";
1
13
  import type { EffectResolution, HostEffect } from "@nylorun/harness/run";
14
+ import type { Tx } from "../store/types.js";
2
15
  import type { AuthorizeResult } from "../vault/service.js";
3
16
  import { type Lease, type Session, type TenantContext } from "./context.js";
4
- import type { ModelProvider } from "../core/provider.js";
5
- /** What one advance's segment decides for all its effects. */
6
- export interface SegmentOptions {
7
- /** Overrides the Tenant's model (the fixture-model Tenant setting, `model-setting.ts`). */
8
- model?: ModelProvider;
9
- }
10
17
  /**
11
- * Call the model for one effect. A provider failure comes back as a failure outcome
12
- * (Model Calls §6), whichever provider serves the call; only an abort throws, and the
13
- * advance decides what the abort means.
18
+ * The outcome of a flow `agent` effect once the linked turn it started ended, or undefined
19
+ * while it has not. The linked session may still show an earlier iteration's turn.
14
20
  */
15
- export declare function invokeModel(ctx: TenantContext, request: HostEffect, signal: AbortSignal, model?: ModelProvider): Promise<unknown>;
21
+ export declare function linkedOutcome(t: Tx, effect: {
22
+ request: HostEffect;
23
+ agentSessionId?: string;
24
+ }, agent: Session | undefined): Promise<ActionOutcome | undefined>;
16
25
  /**
17
26
  * True when this Tenant's remote MCP calls outlive the process that sent them (the gates
18
27
  * service, F4.1 G3): after a takeover or a shutdown, the journaled call is re-sent and joins
@@ -27,11 +36,8 @@ export declare function isRemoteMcpEffect(s: Session, request: HostEffect): bool
27
36
  * the running call or gets its outcome, instead of becoming `uncertain`.
28
37
  */
29
38
  export declare function recoversModelCalls(ctx: TenantContext): boolean;
30
- export declare function resolveEffect(ctx: TenantContext, request: HostEffect, signal: AbortSignal, lease: Lease, segment?: SegmentOptions): Promise<EffectResolution>;
31
39
  /** Journal and dispatch a new flow effect (agent / tool node / fn / verify). */
32
40
  export declare function resolveNewFlowEffect(ctx: TenantContext, request: HostEffect, signal: AbortSignal, lease: Lease): Promise<EffectResolution>;
33
- /** Discover the session's MCP tools once, or reconnect and refresh diagnostics. */
34
- export declare function prepareMcp(ctx: TenantContext, lease: Lease, signal: AbortSignal): Promise<void>;
35
41
  /** Vault authorization for an MCP server request made on behalf of a session. */
36
42
  export declare function authorize(ctx: TenantContext, sessionId: string, request: {
37
43
  url: string;