@tangle-network/agent-interface 3.2.0 → 5.0.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.
@@ -1,6 +1,9 @@
1
1
  import { z } from "zod";
2
+ import type { AgentProfile } from "./agent-profile.js";
3
+ import { type ResourceRequest, type WorkspaceRequest } from "./environment-requests.js";
2
4
  import type { Sha256Digest } from "./agent-candidate.js";
3
5
  import { type PortableContextPlan } from "./portable-context-plan.js";
6
+ import { type PortableContextTransferPlan } from "./portable-context-plan-wire.js";
4
7
  export declare const ContextPlanAcceptanceSchema: z.ZodObject<{
5
8
  planDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
6
9
  acceptedAt: z.ZodISODateTime;
@@ -13,15 +16,22 @@ export declare const ContextPlanAcceptanceSchema: z.ZodObject<{
13
16
  export type ContextPlanAcceptance = z.infer<typeof ContextPlanAcceptanceSchema>;
14
17
  export interface ContextTransferRequestMaterial {
15
18
  operationId: string;
16
- plan: PortableContextPlan;
19
+ plan: PortableContextPlan | PortableContextTransferPlan;
17
20
  acceptance: ContextPlanAcceptance;
21
+ profile?: AgentProfile;
22
+ workspace?: WorkspaceRequest;
23
+ resources?: ResourceRequest;
18
24
  }
19
25
  export declare function contextTransferRequestDigest(request: ContextTransferRequestMaterial): Sha256Digest;
26
+ /** Validate the complete local plan, then create the selected-content destination request. */
27
+ export declare function createContextTransferRequest(material: ContextTransferRequestMaterial): ContextTransferRequest;
20
28
  export declare const ContextTransferRequestSchema: z.ZodObject<{
21
29
  operationId: z.ZodString;
22
30
  requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
23
31
  plan: z.ZodObject<{
32
+ kind: z.ZodLiteral<"portable-context-transfer-plan">;
24
33
  planId: z.ZodString;
34
+ reviewDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
25
35
  source: z.ZodObject<{
26
36
  source: z.ZodObject<{
27
37
  runId: z.ZodString;
@@ -33,39 +43,32 @@ export declare const ContextTransferRequestSchema: z.ZodObject<{
33
43
  requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
34
44
  branchId: z.ZodOptional<z.ZodString>;
35
45
  }, z.core.$strict>;
46
+ digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
36
47
  completeness: z.ZodEnum<{
37
48
  complete: "complete";
38
49
  partial: "partial";
39
50
  }>;
40
51
  messages: z.ZodArray<z.ZodObject<{
41
- id: z.ZodString;
42
- role: z.ZodEnum<{
43
- assistant: "assistant";
44
- system: "system";
45
- user: "user";
46
- }>;
47
- parts: z.ZodArray<z.ZodCustom<unknown, unknown>>;
48
- timestamp: z.ZodISODateTime;
49
- metadata: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
52
+ messageId: z.ZodString;
53
+ metadataDigest: z.ZodOptional<z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>>;
54
+ parts: z.ZodArray<z.ZodNullable<z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>>>;
50
55
  }, z.core.$strict>>;
51
56
  attachments: z.ZodArray<z.ZodObject<{
52
57
  messageId: z.ZodString;
53
58
  partIndex: z.ZodNumber;
54
59
  digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
55
- name: z.ZodOptional<z.ZodString>;
56
- mediaType: z.ZodOptional<z.ZodString>;
57
60
  }, z.core.$strict>>;
58
- digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
59
61
  }, z.core.$strict>;
60
62
  destination: z.ZodObject<{
61
63
  runner: z.ZodString;
62
64
  provider: z.ZodString;
63
- environmentId: z.ZodString;
65
+ environmentId: z.ZodOptional<z.ZodString>;
64
66
  sessionId: z.ZodString;
65
67
  runId: z.ZodString;
66
68
  executionId: z.ZodString;
67
69
  model: z.ZodOptional<z.ZodString>;
68
70
  profileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
71
+ workspaceSnapshotDigest: z.ZodOptional<z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>>;
69
72
  }, z.core.$strict>;
70
73
  messages: z.ZodArray<z.ZodObject<{
71
74
  messageId: z.ZodString;
@@ -80,26 +83,8 @@ export declare const ContextTransferRequestSchema: z.ZodObject<{
80
83
  omit: "omit";
81
84
  transform: "transform";
82
85
  }>;
83
- output: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
84
- type: z.ZodLiteral<"text">;
85
- text: z.ZodString;
86
- }, z.core.$strict>, z.ZodObject<{
87
- type: z.ZodLiteral<"file">;
88
- filename: z.ZodOptional<z.ZodString>;
89
- mediaType: z.ZodOptional<z.ZodString>;
90
- url: z.ZodOptional<z.ZodString>;
91
- path: z.ZodOptional<z.ZodString>;
92
- content: z.ZodOptional<z.ZodString>;
93
- }, z.core.$strict>, z.ZodObject<{
94
- type: z.ZodLiteral<"image">;
95
- filename: z.ZodOptional<z.ZodString>;
96
- mediaType: z.ZodOptional<z.ZodString>;
97
- url: z.ZodOptional<z.ZodString>;
98
- path: z.ZodOptional<z.ZodString>;
99
- }, z.core.$strict>], "type">>;
100
- reason: z.ZodOptional<z.ZodString>;
86
+ outputDigest: z.ZodOptional<z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>>;
101
87
  }, z.core.$strict>>;
102
- reason: z.ZodOptional<z.ZodString>;
103
88
  }, z.core.$strict>>;
104
89
  context: z.ZodObject<{
105
90
  source: z.ZodObject<{
@@ -149,6 +134,324 @@ export declare const ContextTransferRequestSchema: z.ZodObject<{
149
134
  user: "user";
150
135
  }>;
151
136
  }, z.core.$strict>;
137
+ profile: z.ZodOptional<z.ZodObject<{
138
+ name: z.ZodOptional<z.ZodString>;
139
+ description: z.ZodOptional<z.ZodString>;
140
+ version: z.ZodOptional<z.ZodString>;
141
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
142
+ prompt: z.ZodOptional<z.ZodObject<{
143
+ systemPrompt: z.ZodOptional<z.ZodString>;
144
+ appendSystemPrompt: z.ZodOptional<z.ZodString>;
145
+ instructions: z.ZodOptional<z.ZodArray<z.ZodString>>;
146
+ }, z.core.$strict>>;
147
+ model: z.ZodOptional<z.ZodObject<{
148
+ default: z.ZodOptional<z.ZodString>;
149
+ small: z.ZodOptional<z.ZodString>;
150
+ provider: z.ZodOptional<z.ZodString>;
151
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
152
+ high: "high";
153
+ low: "low";
154
+ medium: "medium";
155
+ minimal: "minimal";
156
+ none: "none";
157
+ ultracode: "ultracode";
158
+ xhigh: "xhigh";
159
+ }>>;
160
+ maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
161
+ maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
162
+ maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
163
+ metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
164
+ }, z.core.$strict>>;
165
+ harness: z.ZodOptional<z.ZodEnum<{
166
+ acp: "acp";
167
+ amp: "amp";
168
+ "claude-code": "claude-code";
169
+ "cli-base": "cli-base";
170
+ codex: "codex";
171
+ cursor: "cursor";
172
+ "factory-droids": "factory-droids";
173
+ forge: "forge";
174
+ gemini: "gemini";
175
+ hermes: "hermes";
176
+ "kimi-code": "kimi-code";
177
+ nanoclaw: "nanoclaw";
178
+ openclaw: "openclaw";
179
+ opencode: "opencode";
180
+ pi: "pi";
181
+ prime: "prime";
182
+ }>>;
183
+ seats: z.ZodOptional<z.ZodArray<z.ZodObject<{
184
+ harness: z.ZodEnum<{
185
+ acp: "acp";
186
+ amp: "amp";
187
+ "claude-code": "claude-code";
188
+ "cli-base": "cli-base";
189
+ codex: "codex";
190
+ cursor: "cursor";
191
+ "factory-droids": "factory-droids";
192
+ forge: "forge";
193
+ gemini: "gemini";
194
+ hermes: "hermes";
195
+ "kimi-code": "kimi-code";
196
+ nanoclaw: "nanoclaw";
197
+ openclaw: "openclaw";
198
+ opencode: "opencode";
199
+ pi: "pi";
200
+ prime: "prime";
201
+ }>;
202
+ provider: z.ZodString;
203
+ model: z.ZodString;
204
+ selector: z.ZodUnion<readonly [z.ZodObject<{
205
+ kind: z.ZodLiteral<"all-eligible">;
206
+ }, z.core.$strict>, z.ZodObject<{
207
+ kind: z.ZodLiteral<"seat">;
208
+ id: z.ZodString;
209
+ }, z.core.$strict>]>;
210
+ tools: z.ZodOptional<z.ZodType<Record<string, boolean>, unknown, z.core.$ZodTypeInternals<Record<string, boolean>, unknown>>>;
211
+ permissions: z.ZodOptional<z.ZodType<Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">>, unknown, z.core.$ZodTypeInternals<Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">>, unknown>>>;
212
+ }, z.core.$strict>>>;
213
+ permissions: z.ZodOptional<z.ZodType<Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">>, unknown, z.core.$ZodTypeInternals<Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">>, unknown>>>;
214
+ tools: z.ZodOptional<z.ZodType<Record<string, boolean>, unknown, z.core.$ZodTypeInternals<Record<string, boolean>, unknown>>>;
215
+ mcp: z.ZodOptional<z.ZodType<Record<string, import("./agent-profile.js").AgentProfileMcpServer>, unknown, z.core.$ZodTypeInternals<Record<string, import("./agent-profile.js").AgentProfileMcpServer>, unknown>>>;
216
+ connections: z.ZodOptional<z.ZodArray<z.ZodObject<{
217
+ connectionId: z.ZodString;
218
+ capabilities: z.ZodArray<z.ZodString>;
219
+ alias: z.ZodOptional<z.ZodString>;
220
+ }, z.core.$strict>>>;
221
+ subagents: z.ZodOptional<z.ZodType<Record<string, {
222
+ description?: string | undefined;
223
+ prompt?: string | undefined;
224
+ model?: string | undefined;
225
+ tools?: Record<string, boolean> | undefined;
226
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
227
+ maxSteps?: number | undefined;
228
+ metadata?: Record<string, unknown> | undefined;
229
+ }>, unknown, z.core.$ZodTypeInternals<Record<string, {
230
+ description?: string | undefined;
231
+ prompt?: string | undefined;
232
+ model?: string | undefined;
233
+ tools?: Record<string, boolean> | undefined;
234
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
235
+ maxSteps?: number | undefined;
236
+ metadata?: Record<string, unknown> | undefined;
237
+ }>, unknown>>>;
238
+ resources: z.ZodOptional<z.ZodObject<{
239
+ files: z.ZodOptional<z.ZodArray<z.ZodObject<{
240
+ path: z.ZodString;
241
+ resource: z.ZodUnion<readonly [z.ZodObject<{
242
+ kind: z.ZodLiteral<"inline">;
243
+ name: z.ZodString;
244
+ content: z.ZodString;
245
+ }, z.core.$strict>, z.ZodObject<{
246
+ kind: z.ZodLiteral<"github">;
247
+ repository: z.ZodOptional<z.ZodString>;
248
+ path: z.ZodString;
249
+ ref: z.ZodOptional<z.ZodString>;
250
+ name: z.ZodOptional<z.ZodString>;
251
+ }, z.core.$strict>]>;
252
+ executable: z.ZodOptional<z.ZodBoolean>;
253
+ }, z.core.$strict>>>;
254
+ tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
255
+ kind: z.ZodLiteral<"inline">;
256
+ name: z.ZodString;
257
+ content: z.ZodString;
258
+ }, z.core.$strict>, z.ZodObject<{
259
+ kind: z.ZodLiteral<"github">;
260
+ repository: z.ZodOptional<z.ZodString>;
261
+ path: z.ZodString;
262
+ ref: z.ZodOptional<z.ZodString>;
263
+ name: z.ZodOptional<z.ZodString>;
264
+ }, z.core.$strict>]>>>;
265
+ skills: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
266
+ kind: z.ZodLiteral<"inline">;
267
+ name: z.ZodString;
268
+ content: z.ZodString;
269
+ }, z.core.$strict>, z.ZodObject<{
270
+ kind: z.ZodLiteral<"github">;
271
+ repository: z.ZodOptional<z.ZodString>;
272
+ path: z.ZodString;
273
+ ref: z.ZodOptional<z.ZodString>;
274
+ name: z.ZodOptional<z.ZodString>;
275
+ }, z.core.$strict>]>>>;
276
+ agents: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
277
+ kind: z.ZodLiteral<"inline">;
278
+ name: z.ZodString;
279
+ content: z.ZodString;
280
+ }, z.core.$strict>, z.ZodObject<{
281
+ kind: z.ZodLiteral<"github">;
282
+ repository: z.ZodOptional<z.ZodString>;
283
+ path: z.ZodString;
284
+ ref: z.ZodOptional<z.ZodString>;
285
+ name: z.ZodOptional<z.ZodString>;
286
+ }, z.core.$strict>]>>>;
287
+ commands: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
288
+ kind: z.ZodLiteral<"inline">;
289
+ name: z.ZodString;
290
+ content: z.ZodString;
291
+ }, z.core.$strict>, z.ZodObject<{
292
+ kind: z.ZodLiteral<"github">;
293
+ repository: z.ZodOptional<z.ZodString>;
294
+ path: z.ZodString;
295
+ ref: z.ZodOptional<z.ZodString>;
296
+ name: z.ZodOptional<z.ZodString>;
297
+ }, z.core.$strict>]>>>;
298
+ instructions: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
299
+ kind: z.ZodLiteral<"inline">;
300
+ name: z.ZodString;
301
+ content: z.ZodString;
302
+ }, z.core.$strict>, z.ZodObject<{
303
+ kind: z.ZodLiteral<"github">;
304
+ repository: z.ZodOptional<z.ZodString>;
305
+ path: z.ZodString;
306
+ ref: z.ZodOptional<z.ZodString>;
307
+ name: z.ZodOptional<z.ZodString>;
308
+ }, z.core.$strict>]>]>>;
309
+ failOnError: z.ZodOptional<z.ZodBoolean>;
310
+ }, z.core.$strict>>;
311
+ hooks: z.ZodOptional<z.ZodType<Record<string, {
312
+ command: string;
313
+ timeoutMs?: number | undefined;
314
+ blocking?: boolean | undefined;
315
+ matcher?: string | undefined;
316
+ env?: Record<string, {
317
+ kind: "public";
318
+ value: string;
319
+ } | {
320
+ kind: "secret-ref";
321
+ key: string;
322
+ format?: "bearer" | "raw" | undefined;
323
+ }> | undefined;
324
+ }[]>, unknown, z.core.$ZodTypeInternals<Record<string, {
325
+ command: string;
326
+ timeoutMs?: number | undefined;
327
+ blocking?: boolean | undefined;
328
+ matcher?: string | undefined;
329
+ env?: Record<string, {
330
+ kind: "public";
331
+ value: string;
332
+ } | {
333
+ kind: "secret-ref";
334
+ key: string;
335
+ format?: "bearer" | "raw" | undefined;
336
+ }> | undefined;
337
+ }[]>, unknown>>>;
338
+ modes: z.ZodOptional<z.ZodType<Record<string, {
339
+ description?: string | undefined;
340
+ model?: string | undefined;
341
+ prompt?: string | undefined;
342
+ tools?: Record<string, boolean> | undefined;
343
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
344
+ metadata?: Record<string, unknown> | undefined;
345
+ }>, unknown, z.core.$ZodTypeInternals<Record<string, {
346
+ description?: string | undefined;
347
+ model?: string | undefined;
348
+ prompt?: string | undefined;
349
+ tools?: Record<string, boolean> | undefined;
350
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
351
+ metadata?: Record<string, unknown> | undefined;
352
+ }>, unknown>>>;
353
+ confidential: z.ZodOptional<z.ZodObject<{
354
+ tee: z.ZodOptional<z.ZodString>;
355
+ attestationNonce: z.ZodOptional<z.ZodString>;
356
+ sealed: z.ZodOptional<z.ZodBoolean>;
357
+ attestationRefresh: z.ZodOptional<z.ZodBoolean>;
358
+ }, z.core.$strict>>;
359
+ metadata: z.ZodOptional<z.ZodType<import("./agent-profile.js").AgentProfileMetadata, unknown, z.core.$ZodTypeInternals<import("./agent-profile.js").AgentProfileMetadata, unknown>>>;
360
+ extensions: z.ZodOptional<z.ZodType<Record<string, Record<string, unknown> | undefined>, unknown, z.core.$ZodTypeInternals<Record<string, Record<string, unknown> | undefined>, unknown>>>;
361
+ }, z.core.$strict>>;
362
+ workspace: z.ZodOptional<z.ZodObject<{
363
+ environment: z.ZodOptional<z.ZodString>;
364
+ image: z.ZodOptional<z.ZodString>;
365
+ repoUrl: z.ZodOptional<z.ZodString>;
366
+ gitRef: z.ZodOptional<z.ZodString>;
367
+ cwd: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
368
+ base: z.ZodLiteral<"repository">;
369
+ path: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
370
+ }, z.core.$strict>, z.ZodObject<{
371
+ base: z.ZodLiteral<"host">;
372
+ path: z.ZodString;
373
+ }, z.core.$strict>], "base">>;
374
+ checkpoint: z.ZodOptional<z.ZodObject<{
375
+ checkpointId: z.ZodString;
376
+ provider: z.ZodString;
377
+ source: z.ZodObject<{
378
+ runId: z.ZodString;
379
+ provider: z.ZodString;
380
+ environmentId: z.ZodString;
381
+ sessionId: z.ZodString;
382
+ executionId: z.ZodString;
383
+ requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
384
+ }, z.core.$strict>;
385
+ idempotencyKey: z.ZodString;
386
+ requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
387
+ createdAt: z.ZodISODateTime;
388
+ metadata: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
389
+ }, z.core.$strict>>;
390
+ snapshot: z.ZodOptional<z.ZodObject<{
391
+ kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
392
+ digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
393
+ manifest: z.ZodObject<{
394
+ locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
395
+ kind: z.ZodLiteral<"s3">;
396
+ bucket: z.ZodString;
397
+ key: z.ZodString;
398
+ region: z.ZodOptional<z.ZodString>;
399
+ }, z.core.$strict>, z.ZodObject<{
400
+ kind: z.ZodLiteral<"ipfs">;
401
+ cid: z.ZodString;
402
+ path: z.ZodOptional<z.ZodString>;
403
+ }, z.core.$strict>, z.ZodObject<{
404
+ kind: z.ZodLiteral<"private-cas">;
405
+ namespace: z.ZodString;
406
+ digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
407
+ }, z.core.$strict>], "kind">;
408
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
409
+ byteLength: z.ZodNumber;
410
+ }, z.core.$strict>;
411
+ archive: z.ZodObject<{
412
+ locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
413
+ kind: z.ZodLiteral<"s3">;
414
+ bucket: z.ZodString;
415
+ key: z.ZodString;
416
+ region: z.ZodOptional<z.ZodString>;
417
+ }, z.core.$strict>, z.ZodObject<{
418
+ kind: z.ZodLiteral<"ipfs">;
419
+ cid: z.ZodString;
420
+ path: z.ZodOptional<z.ZodString>;
421
+ }, z.core.$strict>, z.ZodObject<{
422
+ kind: z.ZodLiteral<"private-cas">;
423
+ namespace: z.ZodString;
424
+ digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
425
+ }, z.core.$strict>], "kind">;
426
+ sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
427
+ byteLength: z.ZodNumber;
428
+ }, z.core.$strict>;
429
+ source: z.ZodObject<{
430
+ leaseId: z.ZodString;
431
+ leaseRecordDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
432
+ workspace: z.ZodObject<{
433
+ provider: z.ZodString;
434
+ root: z.ZodString;
435
+ identityDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
436
+ }, z.core.$strict>;
437
+ sourceSnapshotDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
438
+ sourceSnapshotPolicy: z.ZodObject<{
439
+ kind: z.ZodLiteral<"provider-declared">;
440
+ name: z.ZodString;
441
+ version: z.ZodNumber;
442
+ digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
443
+ }, z.core.$strict>;
444
+ }, z.core.$strict>;
445
+ }, z.core.$strict>>;
446
+ providerOptions: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
447
+ }, z.core.$strict>>;
448
+ resources: z.ZodOptional<z.ZodObject<{
449
+ cpu: z.ZodOptional<z.ZodNumber>;
450
+ memoryMb: z.ZodOptional<z.ZodNumber>;
451
+ diskMb: z.ZodOptional<z.ZodNumber>;
452
+ gpu: z.ZodOptional<z.ZodString>;
453
+ providerOptions: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
454
+ }, z.core.$strict>>;
152
455
  }, z.core.$strict>;
153
456
  export type ContextTransferRequest = z.infer<typeof ContextTransferRequestSchema>;
154
457
  export declare const ContextTransferReceiptSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -170,12 +473,13 @@ export declare const ContextTransferReceiptSchema: z.ZodDiscriminatedUnion<[z.Zo
170
473
  destination: z.ZodObject<{
171
474
  runner: z.ZodString;
172
475
  provider: z.ZodString;
173
- environmentId: z.ZodString;
476
+ environmentId: z.ZodOptional<z.ZodString>;
174
477
  sessionId: z.ZodString;
175
478
  runId: z.ZodString;
176
479
  executionId: z.ZodString;
177
480
  model: z.ZodOptional<z.ZodString>;
178
481
  profileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
482
+ workspaceSnapshotDigest: z.ZodOptional<z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>>;
179
483
  }, z.core.$strict>;
180
484
  provider: z.ZodString;
181
485
  environmentId: z.ZodString;
@@ -206,12 +510,13 @@ export declare const ContextTransferReceiptSchema: z.ZodDiscriminatedUnion<[z.Zo
206
510
  destination: z.ZodObject<{
207
511
  runner: z.ZodString;
208
512
  provider: z.ZodString;
209
- environmentId: z.ZodString;
513
+ environmentId: z.ZodOptional<z.ZodString>;
210
514
  sessionId: z.ZodString;
211
515
  runId: z.ZodString;
212
516
  executionId: z.ZodString;
213
517
  model: z.ZodOptional<z.ZodString>;
214
518
  profileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
519
+ workspaceSnapshotDigest: z.ZodOptional<z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>>;
215
520
  }, z.core.$strict>;
216
521
  provider: z.ZodString;
217
522
  environmentId: z.ZodString;
@@ -246,12 +551,13 @@ export declare const ContextTransferResultSchema: z.ZodDiscriminatedUnion<[z.Zod
246
551
  destination: z.ZodObject<{
247
552
  runner: z.ZodString;
248
553
  provider: z.ZodString;
249
- environmentId: z.ZodString;
554
+ environmentId: z.ZodOptional<z.ZodString>;
250
555
  sessionId: z.ZodString;
251
556
  runId: z.ZodString;
252
557
  executionId: z.ZodString;
253
558
  model: z.ZodOptional<z.ZodString>;
254
559
  profileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
560
+ workspaceSnapshotDigest: z.ZodOptional<z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>>;
255
561
  }, z.core.$strict>;
256
562
  provider: z.ZodString;
257
563
  environmentId: z.ZodString;
@@ -282,12 +588,13 @@ export declare const ContextTransferResultSchema: z.ZodDiscriminatedUnion<[z.Zod
282
588
  destination: z.ZodObject<{
283
589
  runner: z.ZodString;
284
590
  provider: z.ZodString;
285
- environmentId: z.ZodString;
591
+ environmentId: z.ZodOptional<z.ZodString>;
286
592
  sessionId: z.ZodString;
287
593
  runId: z.ZodString;
288
594
  executionId: z.ZodString;
289
595
  model: z.ZodOptional<z.ZodString>;
290
596
  profileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
597
+ workspaceSnapshotDigest: z.ZodOptional<z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>>;
291
598
  }, z.core.$strict>;
292
599
  provider: z.ZodString;
293
600
  environmentId: z.ZodString;
@@ -1,8 +1,13 @@
1
1
  import { z } from "zod";
2
+ import { agentProfileSchema } from "./profile-schema.js";
3
+ import { canonicalAgentProfileDigest } from "./agent-execution-preparation.js";
4
+ import { ResourceRequestSchema, WorkspaceRequestSchema } from "./environment-requests.js";
2
5
  import { boundedStringSchema, CONTRACT_MAX_ARRAY_LENGTH, } from "./contract-limits.js";
3
6
  import { PortableContextSourceBoundarySchema, } from "./portable-context-base.js";
4
7
  import { PortableContextDestinationSchema, PortableContextPlanSchema, } from "./portable-context-plan.js";
8
+ import { PortableContextTransferPlanSchema, projectPortableContextPlan } from "./portable-context-plan-wire.js";
5
9
  import { idSchema, sha256DigestSchema, wireDigest } from "./portable-context-shared.js";
10
+ import { agentWorkspaceSnapshotRefDigest } from "./workspace-snapshot.js";
6
11
  export const ContextPlanAcceptanceSchema = z.strictObject({
7
12
  planDigest: sha256DigestSchema,
8
13
  acceptedAt: z.iso.datetime().max(64),
@@ -10,8 +15,11 @@ export const ContextPlanAcceptanceSchema = z.strictObject({
10
15
  });
11
16
  const ContextTransferRequestMaterialSchema = z.strictObject({
12
17
  operationId: idSchema,
13
- plan: PortableContextPlanSchema,
18
+ plan: z.union([PortableContextTransferPlanSchema, PortableContextPlanSchema]),
14
19
  acceptance: ContextPlanAcceptanceSchema,
20
+ profile: agentProfileSchema.optional(),
21
+ workspace: WorkspaceRequestSchema.optional(),
22
+ resources: ResourceRequestSchema.optional(),
15
23
  });
16
24
  export function contextTransferRequestDigest(request) {
17
25
  const parsed = ContextTransferRequestMaterialSchema.parse(request);
@@ -19,16 +27,42 @@ export function contextTransferRequestDigest(request) {
19
27
  operationId: parsed.operationId,
20
28
  planDigest: parsed.plan.digest,
21
29
  acceptance: parsed.acceptance,
30
+ ...(parsed.profile === undefined ? {} : { profileDigest: canonicalAgentProfileDigest(parsed.profile) }),
31
+ ...(parsed.workspace === undefined ? {} : { workspace: parsed.workspace }),
32
+ ...(parsed.resources === undefined ? {} : { resources: parsed.resources }),
22
33
  });
23
34
  }
35
+ /** Validate the complete local plan, then create the selected-content destination request. */
36
+ export function createContextTransferRequest(material) {
37
+ const exact = ContextTransferRequestMaterialSchema.parse(material);
38
+ const plan = "kind" in exact.plan ? exact.plan : projectPortableContextPlan(exact.plan);
39
+ return ContextTransferRequestSchema.parse({ ...exact, plan, requestDigest: contextTransferRequestDigest(exact) });
40
+ }
24
41
  export const ContextTransferRequestSchema = z
25
42
  .strictObject({
26
43
  operationId: idSchema,
27
44
  requestDigest: sha256DigestSchema,
28
- plan: PortableContextPlanSchema,
45
+ plan: PortableContextTransferPlanSchema,
29
46
  acceptance: ContextPlanAcceptanceSchema,
47
+ profile: agentProfileSchema.optional(),
48
+ workspace: WorkspaceRequestSchema.optional(),
49
+ resources: ResourceRequestSchema.optional(),
30
50
  })
31
51
  .superRefine((request, refinement) => {
52
+ const snapshot = request.workspace?.snapshot;
53
+ if (snapshot === undefined ? request.plan.destination.workspaceSnapshotDigest !== undefined :
54
+ request.plan.destination.workspaceSnapshotDigest !== agentWorkspaceSnapshotRefDigest(snapshot)) {
55
+ refinement.addIssue({ code: "custom", path: ["plan", "destination", "workspaceSnapshotDigest"], message: "accepted workspace snapshot digest must match the exact transfer snapshot" });
56
+ }
57
+ if (request.plan.destination.environmentId === undefined && request.profile === undefined) {
58
+ refinement.addIssue({ code: "custom", path: ["profile"], message: "an unbound destination requires its exact profile" });
59
+ }
60
+ if (request.profile !== undefined && canonicalAgentProfileDigest(request.profile) !== request.plan.destination.profileDigest) {
61
+ refinement.addIssue({ code: "custom", path: ["profile"], message: "profile digest must match the accepted destination" });
62
+ }
63
+ if (request.profile?.harness !== undefined && request.profile.harness !== request.plan.destination.runner) {
64
+ refinement.addIssue({ code: "custom", path: ["profile", "harness"], message: "profile harness must match the accepted destination runner" });
65
+ }
32
66
  if (request.acceptance.planDigest !== request.plan.digest) {
33
67
  refinement.addIssue({
34
68
  code: "custom",
@@ -41,6 +75,9 @@ export const ContextTransferRequestSchema = z
41
75
  operationId: request.operationId,
42
76
  plan: request.plan,
43
77
  acceptance: request.acceptance,
78
+ ...(request.profile === undefined ? {} : { profile: request.profile }),
79
+ ...(request.workspace === undefined ? {} : { workspace: request.workspace }),
80
+ ...(request.resources === undefined ? {} : { resources: request.resources }),
44
81
  })) {
45
82
  refinement.addIssue({
46
83
  code: "custom",
@@ -145,7 +182,7 @@ export function contextTransferReceiptMatches(request, receipt) {
145
182
  wireDigest(exactReceipt.source) === wireDigest(source.source) &&
146
183
  wireDigest(exactReceipt.destination) === wireDigest(destination) &&
147
184
  exactReceipt.provider === destination.provider &&
148
- exactReceipt.environmentId === destination.environmentId &&
185
+ (destination.environmentId === undefined || exactReceipt.environmentId === destination.environmentId) &&
149
186
  exactReceipt.sessionId === destination.sessionId &&
150
187
  exactReceipt.runId === destination.runId &&
151
188
  exactReceipt.executionId === destination.executionId &&
@@ -1,5 +1,6 @@
1
1
  export * from "./portable-context-base.js";
2
2
  export * from "./portable-context-plan.js";
3
+ export * from "./portable-context-plan-wire.js";
3
4
  export * from "./portable-context-plan-request.js";
4
5
  export * from "./portable-context-transfer.js";
5
6
  export * from "./portable-context-continuation.js";
@@ -1,5 +1,6 @@
1
1
  export * from "./portable-context-base.js";
2
2
  export * from "./portable-context-plan.js";
3
+ export * from "./portable-context-plan-wire.js";
3
4
  export * from "./portable-context-plan-request.js";
4
5
  export * from "./portable-context-transfer.js";
5
6
  export * from "./portable-context-continuation.js";
@@ -5,13 +5,19 @@ import type { SdkHostServices } from "./host-services.js";
5
5
  import type { BackendCapabilities, ProviderConfig } from "./provider-config.js";
6
6
  import type { BackendArtifact, BackendListOptions, McpConfig, McpStatusResponse } from "./mcp.js";
7
7
  import type { StreamEvent } from "./stream-events.js";
8
+ import type { ContextTransferRequest } from "./portable-context.js";
9
+ /** Fresh runner session creation with an accepted portable history. */
10
+ export type SdkCreateSessionOptions = {
11
+ workspaceRoot?: string;
12
+ sessionId?: string;
13
+ /** Preserve the typed history and refuse every unsupported part. */
14
+ contextTransfer?: ContextTransferRequest;
15
+ };
8
16
  export interface SdkProviderAdapter {
9
17
  readonly provider: string;
10
18
  getCapabilities(): BackendCapabilities;
11
19
  initialize(config: ProviderConfig): Promise<void>;
12
- createSession?(options?: {
13
- workspaceRoot?: string;
14
- }): Promise<string>;
20
+ createSession?(options?: SdkCreateSessionOptions): Promise<string>;
15
21
  forkSession?(options: {
16
22
  sessionId: string;
17
23
  messageId?: string;
@@ -1,3 +1,4 @@
1
+ import type { InputPart } from "./parts.js";
1
2
  export type BackendCapabilities = {
2
3
  streaming: boolean;
3
4
  toolUse: boolean;
@@ -5,6 +6,10 @@ export type BackendCapabilities = {
5
6
  multimodal: boolean;
6
7
  contextWindow: number;
7
8
  interactions?: string[];
9
+ /** Native typed history import implemented by this runner. */
10
+ contextTransfer?: {
11
+ parts: Array<InputPart["type"]>;
12
+ };
8
13
  };
9
14
  export type ProviderCapabilities = {
10
15
  supportsVision: boolean;