@tangle-network/agent-interface 3.2.0 → 4.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.
package/README.md CHANGED
@@ -102,6 +102,8 @@ Partial input or output always requires explicit user or policy acceptance, even
102
102
  `ContextTransferRequest` binds an operation identifier to that accepted plan, while `ContextTransferResult` distinguishes first admission, exact replay, changed-input conflict, and unknown transport outcome.
103
103
  `contextTransferResultMatchesRequest()` checks the operation identifier and request digest for every outcome before a caller accepts, retries, or reports it.
104
104
  Its successful receipt repeats the exact destination and carries the provider's session-creation operation and timestamp, identifying the one fresh provider session that admitted the context.
105
+ An accepted destination may omit `environmentId` when the provider allocates that identity. The receipt preserves the original destination and binds its actual fresh `environmentId`; a prebound destination still requires exact equality. Unbound creation requires the inline `profile` with its accepted canonical digest. Optional `workspace` and `resources` inputs are frozen into the transfer request digest, so changed retries conflict.
106
+
105
107
  Providers expose this operation through `AgentEnvironmentProvider.contextTransfer`.
106
108
  They advertise `contextTransfer` only when transfer, retry idempotency, and lookup are all durable.
107
109
  An accepted destination can set `CreateAgentEnvironmentInput.requestedId` to bind environment creation to its exact identifier.
@@ -104,6 +104,14 @@ export interface ResourceRequest {
104
104
  gpu?: string;
105
105
  providerOptions?: Record<string, unknown>;
106
106
  }
107
+ /** The resource request used by environment creation and accepted transfers. */
108
+ export declare const ResourceRequestSchema: z.ZodObject<{
109
+ cpu: z.ZodOptional<z.ZodNumber>;
110
+ memoryMb: z.ZodOptional<z.ZodNumber>;
111
+ diskMb: z.ZodOptional<z.ZodNumber>;
112
+ gpu: z.ZodOptional<z.ZodString>;
113
+ providerOptions: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
114
+ }, z.core.$strict>;
107
115
  export interface AgentEnvironmentQuery {
108
116
  name?: string;
109
117
  metadata?: Record<string, unknown>;
@@ -63,3 +63,11 @@ export const WorkspaceRequestSchema = z
63
63
  });
64
64
  }
65
65
  });
66
+ /** The resource request used by environment creation and accepted transfers. */
67
+ export const ResourceRequestSchema = z.strictObject({
68
+ cpu: z.number().finite().positive().max(Number.MAX_SAFE_INTEGER).optional(),
69
+ memoryMb: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
70
+ diskMb: z.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
71
+ gpu: boundedIdentifierSchema.optional(),
72
+ providerOptions: boundedJsonRecordSchema.optional(),
73
+ });
@@ -348,7 +348,7 @@ export declare const AgentTurnInputSchema: z.ZodObject<{
348
348
  destination: z.ZodObject<{
349
349
  runner: z.ZodString;
350
350
  provider: z.ZodString;
351
- environmentId: z.ZodString;
351
+ environmentId: z.ZodOptional<z.ZodString>;
352
352
  sessionId: z.ZodString;
353
353
  runId: z.ZodString;
354
354
  executionId: z.ZodString;
@@ -437,6 +437,268 @@ export declare const AgentTurnInputSchema: z.ZodObject<{
437
437
  user: "user";
438
438
  }>;
439
439
  }, z.core.$strict>;
440
+ profile: z.ZodOptional<z.ZodObject<{
441
+ name: z.ZodOptional<z.ZodString>;
442
+ description: z.ZodOptional<z.ZodString>;
443
+ version: z.ZodOptional<z.ZodString>;
444
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
445
+ prompt: z.ZodOptional<z.ZodObject<{
446
+ systemPrompt: z.ZodOptional<z.ZodString>;
447
+ appendSystemPrompt: z.ZodOptional<z.ZodString>;
448
+ instructions: z.ZodOptional<z.ZodArray<z.ZodString>>;
449
+ }, z.core.$strict>>;
450
+ model: z.ZodOptional<z.ZodObject<{
451
+ default: z.ZodOptional<z.ZodString>;
452
+ small: z.ZodOptional<z.ZodString>;
453
+ provider: z.ZodOptional<z.ZodString>;
454
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
455
+ high: "high";
456
+ low: "low";
457
+ medium: "medium";
458
+ minimal: "minimal";
459
+ none: "none";
460
+ ultracode: "ultracode";
461
+ xhigh: "xhigh";
462
+ }>>;
463
+ maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
464
+ maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
465
+ maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
466
+ metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
467
+ }, z.core.$strict>>;
468
+ harness: z.ZodOptional<z.ZodEnum<{
469
+ acp: "acp";
470
+ amp: "amp";
471
+ "claude-code": "claude-code";
472
+ "cli-base": "cli-base";
473
+ codex: "codex";
474
+ cursor: "cursor";
475
+ "factory-droids": "factory-droids";
476
+ forge: "forge";
477
+ gemini: "gemini";
478
+ hermes: "hermes";
479
+ "kimi-code": "kimi-code";
480
+ nanoclaw: "nanoclaw";
481
+ openclaw: "openclaw";
482
+ opencode: "opencode";
483
+ pi: "pi";
484
+ prime: "prime";
485
+ }>>;
486
+ seats: z.ZodOptional<z.ZodArray<z.ZodObject<{
487
+ harness: z.ZodEnum<{
488
+ acp: "acp";
489
+ amp: "amp";
490
+ "claude-code": "claude-code";
491
+ "cli-base": "cli-base";
492
+ codex: "codex";
493
+ cursor: "cursor";
494
+ "factory-droids": "factory-droids";
495
+ forge: "forge";
496
+ gemini: "gemini";
497
+ hermes: "hermes";
498
+ "kimi-code": "kimi-code";
499
+ nanoclaw: "nanoclaw";
500
+ openclaw: "openclaw";
501
+ opencode: "opencode";
502
+ pi: "pi";
503
+ prime: "prime";
504
+ }>;
505
+ provider: z.ZodString;
506
+ model: z.ZodString;
507
+ selector: z.ZodUnion<readonly [z.ZodObject<{
508
+ kind: z.ZodLiteral<"all-eligible">;
509
+ }, z.core.$strict>, z.ZodObject<{
510
+ kind: z.ZodLiteral<"seat">;
511
+ id: z.ZodString;
512
+ }, z.core.$strict>]>;
513
+ tools: z.ZodOptional<z.ZodType<Record<string, boolean>, unknown, z.core.$ZodTypeInternals<Record<string, boolean>, unknown>>>;
514
+ 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>>>;
515
+ }, z.core.$strict>>>;
516
+ 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>>>;
517
+ tools: z.ZodOptional<z.ZodType<Record<string, boolean>, unknown, z.core.$ZodTypeInternals<Record<string, boolean>, unknown>>>;
518
+ mcp: z.ZodOptional<z.ZodType<Record<string, import("./agent-profile.js").AgentProfileMcpServer>, unknown, z.core.$ZodTypeInternals<Record<string, import("./agent-profile.js").AgentProfileMcpServer>, unknown>>>;
519
+ connections: z.ZodOptional<z.ZodArray<z.ZodObject<{
520
+ connectionId: z.ZodString;
521
+ capabilities: z.ZodArray<z.ZodString>;
522
+ alias: z.ZodOptional<z.ZodString>;
523
+ }, z.core.$strict>>>;
524
+ subagents: z.ZodOptional<z.ZodType<Record<string, {
525
+ description?: string | undefined;
526
+ prompt?: string | undefined;
527
+ model?: string | undefined;
528
+ tools?: Record<string, boolean> | undefined;
529
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
530
+ maxSteps?: number | undefined;
531
+ metadata?: Record<string, unknown> | undefined;
532
+ }>, unknown, z.core.$ZodTypeInternals<Record<string, {
533
+ description?: string | undefined;
534
+ prompt?: string | undefined;
535
+ model?: string | undefined;
536
+ tools?: Record<string, boolean> | undefined;
537
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
538
+ maxSteps?: number | undefined;
539
+ metadata?: Record<string, unknown> | undefined;
540
+ }>, unknown>>>;
541
+ resources: z.ZodOptional<z.ZodObject<{
542
+ files: z.ZodOptional<z.ZodArray<z.ZodObject<{
543
+ path: z.ZodString;
544
+ resource: z.ZodUnion<readonly [z.ZodObject<{
545
+ kind: z.ZodLiteral<"inline">;
546
+ name: z.ZodString;
547
+ content: z.ZodString;
548
+ }, z.core.$strict>, z.ZodObject<{
549
+ kind: z.ZodLiteral<"github">;
550
+ repository: z.ZodOptional<z.ZodString>;
551
+ path: z.ZodString;
552
+ ref: z.ZodOptional<z.ZodString>;
553
+ name: z.ZodOptional<z.ZodString>;
554
+ }, z.core.$strict>]>;
555
+ executable: z.ZodOptional<z.ZodBoolean>;
556
+ }, z.core.$strict>>>;
557
+ tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
558
+ kind: z.ZodLiteral<"inline">;
559
+ name: z.ZodString;
560
+ content: z.ZodString;
561
+ }, z.core.$strict>, z.ZodObject<{
562
+ kind: z.ZodLiteral<"github">;
563
+ repository: z.ZodOptional<z.ZodString>;
564
+ path: z.ZodString;
565
+ ref: z.ZodOptional<z.ZodString>;
566
+ name: z.ZodOptional<z.ZodString>;
567
+ }, z.core.$strict>]>>>;
568
+ skills: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
569
+ kind: z.ZodLiteral<"inline">;
570
+ name: z.ZodString;
571
+ content: z.ZodString;
572
+ }, z.core.$strict>, z.ZodObject<{
573
+ kind: z.ZodLiteral<"github">;
574
+ repository: z.ZodOptional<z.ZodString>;
575
+ path: z.ZodString;
576
+ ref: z.ZodOptional<z.ZodString>;
577
+ name: z.ZodOptional<z.ZodString>;
578
+ }, z.core.$strict>]>>>;
579
+ agents: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
580
+ kind: z.ZodLiteral<"inline">;
581
+ name: z.ZodString;
582
+ content: z.ZodString;
583
+ }, z.core.$strict>, z.ZodObject<{
584
+ kind: z.ZodLiteral<"github">;
585
+ repository: z.ZodOptional<z.ZodString>;
586
+ path: z.ZodString;
587
+ ref: z.ZodOptional<z.ZodString>;
588
+ name: z.ZodOptional<z.ZodString>;
589
+ }, z.core.$strict>]>>>;
590
+ commands: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
591
+ kind: z.ZodLiteral<"inline">;
592
+ name: z.ZodString;
593
+ content: z.ZodString;
594
+ }, z.core.$strict>, z.ZodObject<{
595
+ kind: z.ZodLiteral<"github">;
596
+ repository: z.ZodOptional<z.ZodString>;
597
+ path: z.ZodString;
598
+ ref: z.ZodOptional<z.ZodString>;
599
+ name: z.ZodOptional<z.ZodString>;
600
+ }, z.core.$strict>]>>>;
601
+ instructions: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
602
+ kind: z.ZodLiteral<"inline">;
603
+ name: z.ZodString;
604
+ content: z.ZodString;
605
+ }, z.core.$strict>, z.ZodObject<{
606
+ kind: z.ZodLiteral<"github">;
607
+ repository: z.ZodOptional<z.ZodString>;
608
+ path: z.ZodString;
609
+ ref: z.ZodOptional<z.ZodString>;
610
+ name: z.ZodOptional<z.ZodString>;
611
+ }, z.core.$strict>]>]>>;
612
+ failOnError: z.ZodOptional<z.ZodBoolean>;
613
+ }, z.core.$strict>>;
614
+ hooks: z.ZodOptional<z.ZodType<Record<string, {
615
+ command: string;
616
+ timeoutMs?: number | undefined;
617
+ blocking?: boolean | undefined;
618
+ matcher?: string | undefined;
619
+ env?: Record<string, {
620
+ kind: "public";
621
+ value: string;
622
+ } | {
623
+ kind: "secret-ref";
624
+ key: string;
625
+ format?: "bearer" | "raw" | undefined;
626
+ }> | undefined;
627
+ }[]>, unknown, z.core.$ZodTypeInternals<Record<string, {
628
+ command: string;
629
+ timeoutMs?: number | undefined;
630
+ blocking?: boolean | undefined;
631
+ matcher?: string | undefined;
632
+ env?: Record<string, {
633
+ kind: "public";
634
+ value: string;
635
+ } | {
636
+ kind: "secret-ref";
637
+ key: string;
638
+ format?: "bearer" | "raw" | undefined;
639
+ }> | undefined;
640
+ }[]>, unknown>>>;
641
+ modes: z.ZodOptional<z.ZodType<Record<string, {
642
+ description?: string | undefined;
643
+ model?: string | undefined;
644
+ prompt?: string | undefined;
645
+ tools?: Record<string, boolean> | undefined;
646
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
647
+ metadata?: Record<string, unknown> | undefined;
648
+ }>, unknown, z.core.$ZodTypeInternals<Record<string, {
649
+ description?: string | undefined;
650
+ model?: string | undefined;
651
+ prompt?: string | undefined;
652
+ tools?: Record<string, boolean> | undefined;
653
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
654
+ metadata?: Record<string, unknown> | undefined;
655
+ }>, unknown>>>;
656
+ confidential: z.ZodOptional<z.ZodObject<{
657
+ tee: z.ZodOptional<z.ZodString>;
658
+ attestationNonce: z.ZodOptional<z.ZodString>;
659
+ sealed: z.ZodOptional<z.ZodBoolean>;
660
+ attestationRefresh: z.ZodOptional<z.ZodBoolean>;
661
+ }, z.core.$strict>>;
662
+ metadata: z.ZodOptional<z.ZodType<import("./agent-profile.js").AgentProfileMetadata, unknown, z.core.$ZodTypeInternals<import("./agent-profile.js").AgentProfileMetadata, unknown>>>;
663
+ extensions: z.ZodOptional<z.ZodType<Record<string, Record<string, unknown> | undefined>, unknown, z.core.$ZodTypeInternals<Record<string, Record<string, unknown> | undefined>, unknown>>>;
664
+ }, z.core.$strict>>;
665
+ workspace: z.ZodOptional<z.ZodObject<{
666
+ environment: z.ZodOptional<z.ZodString>;
667
+ image: z.ZodOptional<z.ZodString>;
668
+ repoUrl: z.ZodOptional<z.ZodString>;
669
+ gitRef: z.ZodOptional<z.ZodString>;
670
+ cwd: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
671
+ base: z.ZodLiteral<"repository">;
672
+ path: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
673
+ }, z.core.$strict>, z.ZodObject<{
674
+ base: z.ZodLiteral<"host">;
675
+ path: z.ZodString;
676
+ }, z.core.$strict>], "base">>;
677
+ checkpoint: z.ZodOptional<z.ZodObject<{
678
+ checkpointId: z.ZodString;
679
+ provider: z.ZodString;
680
+ source: z.ZodObject<{
681
+ runId: z.ZodString;
682
+ provider: z.ZodString;
683
+ environmentId: z.ZodString;
684
+ sessionId: z.ZodString;
685
+ executionId: z.ZodString;
686
+ requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
687
+ }, z.core.$strict>;
688
+ idempotencyKey: z.ZodString;
689
+ requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
690
+ createdAt: z.ZodISODateTime;
691
+ metadata: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
692
+ }, z.core.$strict>>;
693
+ providerOptions: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
694
+ }, z.core.$strict>>;
695
+ resources: z.ZodOptional<z.ZodObject<{
696
+ cpu: z.ZodOptional<z.ZodNumber>;
697
+ memoryMb: z.ZodOptional<z.ZodNumber>;
698
+ diskMb: z.ZodOptional<z.ZodNumber>;
699
+ gpu: z.ZodOptional<z.ZodString>;
700
+ providerOptions: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
701
+ }, z.core.$strict>>;
440
702
  }, z.core.$strict>>;
441
703
  nativeContinuation: z.ZodOptional<z.ZodObject<{
442
704
  operationId: z.ZodString;
@@ -552,7 +814,7 @@ export declare const AgentTurnResultSchema: z.ZodObject<{
552
814
  destination: z.ZodObject<{
553
815
  runner: z.ZodString;
554
816
  provider: z.ZodString;
555
- environmentId: z.ZodString;
817
+ environmentId: z.ZodOptional<z.ZodString>;
556
818
  sessionId: z.ZodString;
557
819
  runId: z.ZodString;
558
820
  executionId: z.ZodString;
@@ -588,7 +850,7 @@ export declare const AgentTurnResultSchema: z.ZodObject<{
588
850
  destination: z.ZodObject<{
589
851
  runner: z.ZodString;
590
852
  provider: z.ZodString;
591
- environmentId: z.ZodString;
853
+ environmentId: z.ZodOptional<z.ZodString>;
592
854
  sessionId: z.ZodString;
593
855
  runId: z.ZodString;
594
856
  executionId: z.ZodString;
@@ -708,7 +970,7 @@ export declare const AgentNativeContextContinuationResultSchema: z.ZodUnion<read
708
970
  destination: z.ZodObject<{
709
971
  runner: z.ZodString;
710
972
  provider: z.ZodString;
711
- environmentId: z.ZodString;
973
+ environmentId: z.ZodOptional<z.ZodString>;
712
974
  sessionId: z.ZodString;
713
975
  runId: z.ZodString;
714
976
  executionId: z.ZodString;
@@ -744,7 +1006,7 @@ export declare const AgentNativeContextContinuationResultSchema: z.ZodUnion<read
744
1006
  destination: z.ZodObject<{
745
1007
  runner: z.ZodString;
746
1008
  provider: z.ZodString;
747
- environmentId: z.ZodString;
1009
+ environmentId: z.ZodOptional<z.ZodString>;
748
1010
  sessionId: z.ZodString;
749
1011
  runId: z.ZodString;
750
1012
  executionId: z.ZodString;
@@ -1106,6 +1368,8 @@ export interface AgentEnvironmentCapabilities {
1106
1368
  * exactly that, instead of advertising an egress mode it does not accept.
1107
1369
  */
1108
1370
  create?: {
1371
+ /** The provider durably binds keyed create input and can reconstruct it after restart. */
1372
+ durableIdempotency?: boolean;
1109
1373
  /**
1110
1374
  * Egress modes create accepts, each named once. A mode absent here is refused, never weakened
1111
1375
  * or widened. Absent altogether means create does not read
@@ -1268,6 +1532,7 @@ export declare const AgentEnvironmentCapabilitiesSchema: z.ZodObject<{
1268
1532
  open: "open";
1269
1533
  strict: "strict";
1270
1534
  }>>>;
1535
+ durableIdempotency: z.ZodOptional<z.ZodBoolean>;
1271
1536
  billingOwner: z.ZodOptional<z.ZodBoolean>;
1272
1537
  runtimeAttachments: z.ZodOptional<z.ZodObject<{
1273
1538
  mcp: z.ZodLiteral<true>;
@@ -241,6 +241,7 @@ export const AgentEnvironmentCapabilitiesSchema = z
241
241
  .min(1)
242
242
  .max(CONTRACT_MAX_ARRAY_LENGTH)
243
243
  .optional(),
244
+ durableIdempotency: z.boolean().optional(),
244
245
  billingOwner: z.boolean().optional(),
245
246
  runtimeAttachments: z.strictObject({ mcp: z.literal(true) }).optional(),
246
247
  workspaceCheckpoint: z.boolean().optional(),
@@ -350,7 +351,8 @@ export const AgentEnvironmentCapabilitiesSchema = z
350
351
  }
351
352
  const create = capabilities.create;
352
353
  if (create !== undefined) {
353
- if (create.egress === undefined &&
354
+ if (create.durableIdempotency === undefined &&
355
+ create.egress === undefined &&
354
356
  create.billingOwner === undefined &&
355
357
  create.runtimeAttachments === undefined &&
356
358
  create.workspaceCheckpoint === undefined) {
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export * from "./host-services.js";
9
9
  export * from "./mcp.js";
10
10
  export * from "./provider-adapter.js";
11
11
  export type * from "./environment-provider.js";
12
- export { AgentEnvironmentCapabilitiesSchema, AgentRuntimeAttachmentsSchema, AgentNativeContextContinuationAdmissionSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentEnvironmentCreateInputDigest, agentNativeContextContinuationAdmissionMatchesRequest, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentInteractiveSessionStopRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, createAgentEnvironmentWithIdempotency, canonicalWorkspaceCwd, MAX_WORKSPACE_CWD_LENGTH, workspaceCwdSchema, workspaceCwdPathForBase, WorkspaceRequestSchema, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
12
+ export { AgentEnvironmentCapabilitiesSchema, AgentRuntimeAttachmentsSchema, AgentNativeContextContinuationAdmissionSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentEnvironmentCreateInputDigest, agentNativeContextContinuationAdmissionMatchesRequest, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentInteractiveSessionStopRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, createAgentEnvironmentWithIdempotency, canonicalWorkspaceCwd, MAX_WORKSPACE_CWD_LENGTH, workspaceCwdSchema, workspaceCwdPathForBase, WorkspaceRequestSchema, ResourceRequestSchema, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
13
13
  export * from "./plan.js";
14
14
  export * from "./runtime-control.js";
15
15
  export * from "./portable-context.js";
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ export * from "./provider-config.js";
8
8
  export * from "./host-services.js";
9
9
  export * from "./mcp.js";
10
10
  export * from "./provider-adapter.js";
11
- export { AgentEnvironmentCapabilitiesSchema, AgentRuntimeAttachmentsSchema, AgentNativeContextContinuationAdmissionSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentEnvironmentCreateInputDigest, agentNativeContextContinuationAdmissionMatchesRequest, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentInteractiveSessionStopRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, createAgentEnvironmentWithIdempotency, canonicalWorkspaceCwd, MAX_WORKSPACE_CWD_LENGTH, workspaceCwdSchema, workspaceCwdPathForBase, WorkspaceRequestSchema, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
11
+ export { AgentEnvironmentCapabilitiesSchema, AgentRuntimeAttachmentsSchema, AgentNativeContextContinuationAdmissionSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentEnvironmentCreateInputDigest, agentNativeContextContinuationAdmissionMatchesRequest, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, observationContainsCredential, observationOf, AgentInteractiveSessionAttachSchema, AgentInteractiveSessionControlClaimAcknowledgementSchema, AgentInteractiveSessionControlClaimRequestSchema, AgentInteractiveSessionControlClaimSchema, AgentInteractiveSessionPromptAcknowledgementSchema, AgentInteractiveSessionPromptCommandSchema, AgentInteractiveSessionRefSchema, AgentInteractiveSessionStartSchema, AgentInteractiveSessionStopAcknowledgementSchema, AgentInteractiveSessionStopCommandSchema, AgentInteractiveSessionStatusSchema, agentInteractiveSessionControlClaimAcknowledgementMatchesRequest, agentInteractiveSessionControlClaimRequestDigest, agentInteractiveSessionControlClaimMatchesRef, agentInteractiveSessionControlClaimIsNewer, agentInteractiveSessionPromptAcknowledgementMatchesCommand, agentInteractiveSessionPromptRequestDigest, agentInteractiveSessionStopAcknowledgementMatchesCommand, agentInteractiveSessionStopRequestDigest, agentInteractiveSessionRefMatchesStart, agentInteractiveSessionRunRef, agentInteractiveSessionStatusMatchesRef, exactAgentInteractiveSessionStart, createAgentEnvironmentWithIdempotency, canonicalWorkspaceCwd, MAX_WORKSPACE_CWD_LENGTH, workspaceCwdSchema, workspaceCwdPathForBase, WorkspaceRequestSchema, ResourceRequestSchema, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
12
12
  export * from "./plan.js";
13
13
  export * from "./runtime-control.js";
14
14
  export * from "./portable-context.js";
@@ -54,7 +54,7 @@ export declare const PortableContextPlanRequestSchema: z.ZodObject<{
54
54
  destination: z.ZodObject<{
55
55
  runner: z.ZodString;
56
56
  provider: z.ZodString;
57
- environmentId: z.ZodString;
57
+ environmentId: z.ZodOptional<z.ZodString>;
58
58
  sessionId: z.ZodString;
59
59
  runId: z.ZodString;
60
60
  executionId: z.ZodString;
@@ -2,26 +2,17 @@ import { z } from "zod";
2
2
  import type { Sha256Digest } from "./agent-candidate.js";
3
3
  import type { InputPart } from "./parts.js";
4
4
  import { type PortableConversationContext } from "./portable-context-base.js";
5
- export interface PortableContextDestination {
6
- runner: string;
7
- provider: string;
8
- environmentId: string;
9
- sessionId: string;
10
- runId: string;
11
- executionId: string;
12
- model?: string;
13
- profileDigest: Sha256Digest;
14
- }
15
5
  export declare const PortableContextDestinationSchema: z.ZodObject<{
16
6
  runner: z.ZodString;
17
7
  provider: z.ZodString;
18
- environmentId: z.ZodString;
8
+ environmentId: z.ZodOptional<z.ZodString>;
19
9
  sessionId: z.ZodString;
20
10
  runId: z.ZodString;
21
11
  executionId: z.ZodString;
22
12
  model: z.ZodOptional<z.ZodString>;
23
13
  profileDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
24
14
  }, z.core.$strict>;
15
+ export type PortableContextDestination = z.infer<typeof PortableContextDestinationSchema>;
25
16
  export interface PortableContextPartPlan {
26
17
  partIndex: number;
27
18
  action: "include" | "transform" | "omit";
@@ -147,7 +138,7 @@ export declare const PortableContextPlanSchema: z.ZodObject<{
147
138
  destination: z.ZodObject<{
148
139
  runner: z.ZodString;
149
140
  provider: z.ZodString;
150
- environmentId: z.ZodString;
141
+ environmentId: z.ZodOptional<z.ZodString>;
151
142
  sessionId: z.ZodString;
152
143
  runId: z.ZodString;
153
144
  executionId: z.ZodString;
@@ -5,7 +5,8 @@ import { PortableConversationContextSchema } from "./portable-context-base.js";
5
5
  export const PortableContextDestinationSchema = z.strictObject({
6
6
  runner: idSchema,
7
7
  provider: idSchema,
8
- environmentId: idSchema,
8
+ /** Omitted when the provider allocates the environment after acceptance. */
9
+ environmentId: idSchema.optional(),
9
10
  sessionId: idSchema,
10
11
  runId: idSchema,
11
12
  executionId: idSchema,
@@ -1,4 +1,6 @@
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";
4
6
  export declare const ContextPlanAcceptanceSchema: z.ZodObject<{
@@ -15,6 +17,9 @@ export interface ContextTransferRequestMaterial {
15
17
  operationId: string;
16
18
  plan: PortableContextPlan;
17
19
  acceptance: ContextPlanAcceptance;
20
+ profile?: AgentProfile;
21
+ workspace?: WorkspaceRequest;
22
+ resources?: ResourceRequest;
18
23
  }
19
24
  export declare function contextTransferRequestDigest(request: ContextTransferRequestMaterial): Sha256Digest;
20
25
  export declare const ContextTransferRequestSchema: z.ZodObject<{
@@ -60,7 +65,7 @@ export declare const ContextTransferRequestSchema: z.ZodObject<{
60
65
  destination: z.ZodObject<{
61
66
  runner: z.ZodString;
62
67
  provider: z.ZodString;
63
- environmentId: z.ZodString;
68
+ environmentId: z.ZodOptional<z.ZodString>;
64
69
  sessionId: z.ZodString;
65
70
  runId: z.ZodString;
66
71
  executionId: z.ZodString;
@@ -149,6 +154,268 @@ export declare const ContextTransferRequestSchema: z.ZodObject<{
149
154
  user: "user";
150
155
  }>;
151
156
  }, z.core.$strict>;
157
+ profile: z.ZodOptional<z.ZodObject<{
158
+ name: z.ZodOptional<z.ZodString>;
159
+ description: z.ZodOptional<z.ZodString>;
160
+ version: z.ZodOptional<z.ZodString>;
161
+ tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
162
+ prompt: z.ZodOptional<z.ZodObject<{
163
+ systemPrompt: z.ZodOptional<z.ZodString>;
164
+ appendSystemPrompt: z.ZodOptional<z.ZodString>;
165
+ instructions: z.ZodOptional<z.ZodArray<z.ZodString>>;
166
+ }, z.core.$strict>>;
167
+ model: z.ZodOptional<z.ZodObject<{
168
+ default: z.ZodOptional<z.ZodString>;
169
+ small: z.ZodOptional<z.ZodString>;
170
+ provider: z.ZodOptional<z.ZodString>;
171
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
172
+ high: "high";
173
+ low: "low";
174
+ medium: "medium";
175
+ minimal: "minimal";
176
+ none: "none";
177
+ ultracode: "ultracode";
178
+ xhigh: "xhigh";
179
+ }>>;
180
+ maxVisibleOutputTokens: z.ZodOptional<z.ZodNumber>;
181
+ maxReasoningTokens: z.ZodOptional<z.ZodNumber>;
182
+ maxTotalOutputTokens: z.ZodOptional<z.ZodNumber>;
183
+ metadata: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
184
+ }, z.core.$strict>>;
185
+ harness: z.ZodOptional<z.ZodEnum<{
186
+ acp: "acp";
187
+ amp: "amp";
188
+ "claude-code": "claude-code";
189
+ "cli-base": "cli-base";
190
+ codex: "codex";
191
+ cursor: "cursor";
192
+ "factory-droids": "factory-droids";
193
+ forge: "forge";
194
+ gemini: "gemini";
195
+ hermes: "hermes";
196
+ "kimi-code": "kimi-code";
197
+ nanoclaw: "nanoclaw";
198
+ openclaw: "openclaw";
199
+ opencode: "opencode";
200
+ pi: "pi";
201
+ prime: "prime";
202
+ }>>;
203
+ seats: z.ZodOptional<z.ZodArray<z.ZodObject<{
204
+ harness: z.ZodEnum<{
205
+ acp: "acp";
206
+ amp: "amp";
207
+ "claude-code": "claude-code";
208
+ "cli-base": "cli-base";
209
+ codex: "codex";
210
+ cursor: "cursor";
211
+ "factory-droids": "factory-droids";
212
+ forge: "forge";
213
+ gemini: "gemini";
214
+ hermes: "hermes";
215
+ "kimi-code": "kimi-code";
216
+ nanoclaw: "nanoclaw";
217
+ openclaw: "openclaw";
218
+ opencode: "opencode";
219
+ pi: "pi";
220
+ prime: "prime";
221
+ }>;
222
+ provider: z.ZodString;
223
+ model: z.ZodString;
224
+ selector: z.ZodUnion<readonly [z.ZodObject<{
225
+ kind: z.ZodLiteral<"all-eligible">;
226
+ }, z.core.$strict>, z.ZodObject<{
227
+ kind: z.ZodLiteral<"seat">;
228
+ id: z.ZodString;
229
+ }, z.core.$strict>]>;
230
+ tools: z.ZodOptional<z.ZodType<Record<string, boolean>, unknown, z.core.$ZodTypeInternals<Record<string, boolean>, unknown>>>;
231
+ 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>>>;
232
+ }, z.core.$strict>>>;
233
+ 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>>>;
234
+ tools: z.ZodOptional<z.ZodType<Record<string, boolean>, unknown, z.core.$ZodTypeInternals<Record<string, boolean>, unknown>>>;
235
+ mcp: z.ZodOptional<z.ZodType<Record<string, import("./agent-profile.js").AgentProfileMcpServer>, unknown, z.core.$ZodTypeInternals<Record<string, import("./agent-profile.js").AgentProfileMcpServer>, unknown>>>;
236
+ connections: z.ZodOptional<z.ZodArray<z.ZodObject<{
237
+ connectionId: z.ZodString;
238
+ capabilities: z.ZodArray<z.ZodString>;
239
+ alias: z.ZodOptional<z.ZodString>;
240
+ }, z.core.$strict>>>;
241
+ subagents: z.ZodOptional<z.ZodType<Record<string, {
242
+ description?: string | undefined;
243
+ prompt?: string | undefined;
244
+ model?: string | undefined;
245
+ tools?: Record<string, boolean> | undefined;
246
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
247
+ maxSteps?: number | undefined;
248
+ metadata?: Record<string, unknown> | undefined;
249
+ }>, unknown, z.core.$ZodTypeInternals<Record<string, {
250
+ description?: string | undefined;
251
+ prompt?: string | undefined;
252
+ model?: string | undefined;
253
+ tools?: Record<string, boolean> | undefined;
254
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
255
+ maxSteps?: number | undefined;
256
+ metadata?: Record<string, unknown> | undefined;
257
+ }>, unknown>>>;
258
+ resources: z.ZodOptional<z.ZodObject<{
259
+ files: z.ZodOptional<z.ZodArray<z.ZodObject<{
260
+ path: z.ZodString;
261
+ resource: z.ZodUnion<readonly [z.ZodObject<{
262
+ kind: z.ZodLiteral<"inline">;
263
+ name: z.ZodString;
264
+ content: z.ZodString;
265
+ }, z.core.$strict>, z.ZodObject<{
266
+ kind: z.ZodLiteral<"github">;
267
+ repository: z.ZodOptional<z.ZodString>;
268
+ path: z.ZodString;
269
+ ref: z.ZodOptional<z.ZodString>;
270
+ name: z.ZodOptional<z.ZodString>;
271
+ }, z.core.$strict>]>;
272
+ executable: z.ZodOptional<z.ZodBoolean>;
273
+ }, z.core.$strict>>>;
274
+ tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
275
+ kind: z.ZodLiteral<"inline">;
276
+ name: z.ZodString;
277
+ content: z.ZodString;
278
+ }, z.core.$strict>, z.ZodObject<{
279
+ kind: z.ZodLiteral<"github">;
280
+ repository: z.ZodOptional<z.ZodString>;
281
+ path: z.ZodString;
282
+ ref: z.ZodOptional<z.ZodString>;
283
+ name: z.ZodOptional<z.ZodString>;
284
+ }, z.core.$strict>]>>>;
285
+ skills: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
286
+ kind: z.ZodLiteral<"inline">;
287
+ name: z.ZodString;
288
+ content: z.ZodString;
289
+ }, z.core.$strict>, z.ZodObject<{
290
+ kind: z.ZodLiteral<"github">;
291
+ repository: z.ZodOptional<z.ZodString>;
292
+ path: z.ZodString;
293
+ ref: z.ZodOptional<z.ZodString>;
294
+ name: z.ZodOptional<z.ZodString>;
295
+ }, z.core.$strict>]>>>;
296
+ agents: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
297
+ kind: z.ZodLiteral<"inline">;
298
+ name: z.ZodString;
299
+ content: z.ZodString;
300
+ }, z.core.$strict>, z.ZodObject<{
301
+ kind: z.ZodLiteral<"github">;
302
+ repository: z.ZodOptional<z.ZodString>;
303
+ path: z.ZodString;
304
+ ref: z.ZodOptional<z.ZodString>;
305
+ name: z.ZodOptional<z.ZodString>;
306
+ }, z.core.$strict>]>>>;
307
+ commands: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
308
+ kind: z.ZodLiteral<"inline">;
309
+ name: z.ZodString;
310
+ content: z.ZodString;
311
+ }, z.core.$strict>, z.ZodObject<{
312
+ kind: z.ZodLiteral<"github">;
313
+ repository: z.ZodOptional<z.ZodString>;
314
+ path: z.ZodString;
315
+ ref: z.ZodOptional<z.ZodString>;
316
+ name: z.ZodOptional<z.ZodString>;
317
+ }, z.core.$strict>]>>>;
318
+ instructions: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
319
+ kind: z.ZodLiteral<"inline">;
320
+ name: z.ZodString;
321
+ content: z.ZodString;
322
+ }, z.core.$strict>, z.ZodObject<{
323
+ kind: z.ZodLiteral<"github">;
324
+ repository: z.ZodOptional<z.ZodString>;
325
+ path: z.ZodString;
326
+ ref: z.ZodOptional<z.ZodString>;
327
+ name: z.ZodOptional<z.ZodString>;
328
+ }, z.core.$strict>]>]>>;
329
+ failOnError: z.ZodOptional<z.ZodBoolean>;
330
+ }, z.core.$strict>>;
331
+ hooks: z.ZodOptional<z.ZodType<Record<string, {
332
+ command: string;
333
+ timeoutMs?: number | undefined;
334
+ blocking?: boolean | undefined;
335
+ matcher?: string | undefined;
336
+ env?: Record<string, {
337
+ kind: "public";
338
+ value: string;
339
+ } | {
340
+ kind: "secret-ref";
341
+ key: string;
342
+ format?: "bearer" | "raw" | undefined;
343
+ }> | undefined;
344
+ }[]>, unknown, z.core.$ZodTypeInternals<Record<string, {
345
+ command: string;
346
+ timeoutMs?: number | undefined;
347
+ blocking?: boolean | undefined;
348
+ matcher?: string | undefined;
349
+ env?: Record<string, {
350
+ kind: "public";
351
+ value: string;
352
+ } | {
353
+ kind: "secret-ref";
354
+ key: string;
355
+ format?: "bearer" | "raw" | undefined;
356
+ }> | undefined;
357
+ }[]>, unknown>>>;
358
+ modes: z.ZodOptional<z.ZodType<Record<string, {
359
+ description?: string | undefined;
360
+ model?: string | undefined;
361
+ prompt?: string | undefined;
362
+ tools?: Record<string, boolean> | undefined;
363
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
364
+ metadata?: Record<string, unknown> | undefined;
365
+ }>, unknown, z.core.$ZodTypeInternals<Record<string, {
366
+ description?: string | undefined;
367
+ model?: string | undefined;
368
+ prompt?: string | undefined;
369
+ tools?: Record<string, boolean> | undefined;
370
+ permissions?: Record<string, "allow" | "ask" | "deny" | Record<string, "allow" | "ask" | "deny">> | undefined;
371
+ metadata?: Record<string, unknown> | undefined;
372
+ }>, unknown>>>;
373
+ confidential: z.ZodOptional<z.ZodObject<{
374
+ tee: z.ZodOptional<z.ZodString>;
375
+ attestationNonce: z.ZodOptional<z.ZodString>;
376
+ sealed: z.ZodOptional<z.ZodBoolean>;
377
+ attestationRefresh: z.ZodOptional<z.ZodBoolean>;
378
+ }, z.core.$strict>>;
379
+ metadata: z.ZodOptional<z.ZodType<import("./agent-profile.js").AgentProfileMetadata, unknown, z.core.$ZodTypeInternals<import("./agent-profile.js").AgentProfileMetadata, unknown>>>;
380
+ extensions: z.ZodOptional<z.ZodType<Record<string, Record<string, unknown> | undefined>, unknown, z.core.$ZodTypeInternals<Record<string, Record<string, unknown> | undefined>, unknown>>>;
381
+ }, z.core.$strict>>;
382
+ workspace: z.ZodOptional<z.ZodObject<{
383
+ environment: z.ZodOptional<z.ZodString>;
384
+ image: z.ZodOptional<z.ZodString>;
385
+ repoUrl: z.ZodOptional<z.ZodString>;
386
+ gitRef: z.ZodOptional<z.ZodString>;
387
+ cwd: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
388
+ base: z.ZodLiteral<"repository">;
389
+ path: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
390
+ }, z.core.$strict>, z.ZodObject<{
391
+ base: z.ZodLiteral<"host">;
392
+ path: z.ZodString;
393
+ }, z.core.$strict>], "base">>;
394
+ checkpoint: z.ZodOptional<z.ZodObject<{
395
+ checkpointId: z.ZodString;
396
+ provider: z.ZodString;
397
+ source: z.ZodObject<{
398
+ runId: z.ZodString;
399
+ provider: z.ZodString;
400
+ environmentId: z.ZodString;
401
+ sessionId: z.ZodString;
402
+ executionId: z.ZodString;
403
+ requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
404
+ }, z.core.$strict>;
405
+ idempotencyKey: z.ZodString;
406
+ requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
407
+ createdAt: z.ZodISODateTime;
408
+ metadata: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
409
+ }, z.core.$strict>>;
410
+ providerOptions: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
411
+ }, z.core.$strict>>;
412
+ resources: z.ZodOptional<z.ZodObject<{
413
+ cpu: z.ZodOptional<z.ZodNumber>;
414
+ memoryMb: z.ZodOptional<z.ZodNumber>;
415
+ diskMb: z.ZodOptional<z.ZodNumber>;
416
+ gpu: z.ZodOptional<z.ZodString>;
417
+ providerOptions: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
418
+ }, z.core.$strict>>;
152
419
  }, z.core.$strict>;
153
420
  export type ContextTransferRequest = z.infer<typeof ContextTransferRequestSchema>;
154
421
  export declare const ContextTransferReceiptSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -170,7 +437,7 @@ export declare const ContextTransferReceiptSchema: z.ZodDiscriminatedUnion<[z.Zo
170
437
  destination: z.ZodObject<{
171
438
  runner: z.ZodString;
172
439
  provider: z.ZodString;
173
- environmentId: z.ZodString;
440
+ environmentId: z.ZodOptional<z.ZodString>;
174
441
  sessionId: z.ZodString;
175
442
  runId: z.ZodString;
176
443
  executionId: z.ZodString;
@@ -206,7 +473,7 @@ export declare const ContextTransferReceiptSchema: z.ZodDiscriminatedUnion<[z.Zo
206
473
  destination: z.ZodObject<{
207
474
  runner: z.ZodString;
208
475
  provider: z.ZodString;
209
- environmentId: z.ZodString;
476
+ environmentId: z.ZodOptional<z.ZodString>;
210
477
  sessionId: z.ZodString;
211
478
  runId: z.ZodString;
212
479
  executionId: z.ZodString;
@@ -246,7 +513,7 @@ export declare const ContextTransferResultSchema: z.ZodDiscriminatedUnion<[z.Zod
246
513
  destination: z.ZodObject<{
247
514
  runner: z.ZodString;
248
515
  provider: z.ZodString;
249
- environmentId: z.ZodString;
516
+ environmentId: z.ZodOptional<z.ZodString>;
250
517
  sessionId: z.ZodString;
251
518
  runId: z.ZodString;
252
519
  executionId: z.ZodString;
@@ -282,7 +549,7 @@ export declare const ContextTransferResultSchema: z.ZodDiscriminatedUnion<[z.Zod
282
549
  destination: z.ZodObject<{
283
550
  runner: z.ZodString;
284
551
  provider: z.ZodString;
285
- environmentId: z.ZodString;
552
+ environmentId: z.ZodOptional<z.ZodString>;
286
553
  sessionId: z.ZodString;
287
554
  runId: z.ZodString;
288
555
  executionId: z.ZodString;
@@ -1,4 +1,7 @@
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";
@@ -12,6 +15,9 @@ const ContextTransferRequestMaterialSchema = z.strictObject({
12
15
  operationId: idSchema,
13
16
  plan: PortableContextPlanSchema,
14
17
  acceptance: ContextPlanAcceptanceSchema,
18
+ profile: agentProfileSchema.optional(),
19
+ workspace: WorkspaceRequestSchema.optional(),
20
+ resources: ResourceRequestSchema.optional(),
15
21
  });
16
22
  export function contextTransferRequestDigest(request) {
17
23
  const parsed = ContextTransferRequestMaterialSchema.parse(request);
@@ -19,6 +25,9 @@ export function contextTransferRequestDigest(request) {
19
25
  operationId: parsed.operationId,
20
26
  planDigest: parsed.plan.digest,
21
27
  acceptance: parsed.acceptance,
28
+ ...(parsed.profile === undefined ? {} : { profileDigest: canonicalAgentProfileDigest(parsed.profile) }),
29
+ ...(parsed.workspace === undefined ? {} : { workspace: parsed.workspace }),
30
+ ...(parsed.resources === undefined ? {} : { resources: parsed.resources }),
22
31
  });
23
32
  }
24
33
  export const ContextTransferRequestSchema = z
@@ -27,8 +36,20 @@ export const ContextTransferRequestSchema = z
27
36
  requestDigest: sha256DigestSchema,
28
37
  plan: PortableContextPlanSchema,
29
38
  acceptance: ContextPlanAcceptanceSchema,
39
+ profile: agentProfileSchema.optional(),
40
+ workspace: WorkspaceRequestSchema.optional(),
41
+ resources: ResourceRequestSchema.optional(),
30
42
  })
31
43
  .superRefine((request, refinement) => {
44
+ if (request.plan.destination.environmentId === undefined && request.profile === undefined) {
45
+ refinement.addIssue({ code: "custom", path: ["profile"], message: "an unbound destination requires its exact profile" });
46
+ }
47
+ if (request.profile !== undefined && canonicalAgentProfileDigest(request.profile) !== request.plan.destination.profileDigest) {
48
+ refinement.addIssue({ code: "custom", path: ["profile"], message: "profile digest must match the accepted destination" });
49
+ }
50
+ if (request.profile?.harness !== undefined && request.profile.harness !== request.plan.destination.runner) {
51
+ refinement.addIssue({ code: "custom", path: ["profile", "harness"], message: "profile harness must match the accepted destination runner" });
52
+ }
32
53
  if (request.acceptance.planDigest !== request.plan.digest) {
33
54
  refinement.addIssue({
34
55
  code: "custom",
@@ -41,6 +62,9 @@ export const ContextTransferRequestSchema = z
41
62
  operationId: request.operationId,
42
63
  plan: request.plan,
43
64
  acceptance: request.acceptance,
65
+ ...(request.profile === undefined ? {} : { profile: request.profile }),
66
+ ...(request.workspace === undefined ? {} : { workspace: request.workspace }),
67
+ ...(request.resources === undefined ? {} : { resources: request.resources }),
44
68
  })) {
45
69
  refinement.addIssue({
46
70
  code: "custom",
@@ -145,7 +169,7 @@ export function contextTransferReceiptMatches(request, receipt) {
145
169
  wireDigest(exactReceipt.source) === wireDigest(source.source) &&
146
170
  wireDigest(exactReceipt.destination) === wireDigest(destination) &&
147
171
  exactReceipt.provider === destination.provider &&
148
- exactReceipt.environmentId === destination.environmentId &&
172
+ (destination.environmentId === undefined || exactReceipt.environmentId === destination.environmentId) &&
149
173
  exactReceipt.sessionId === destination.sessionId &&
150
174
  exactReceipt.runId === destination.runId &&
151
175
  exactReceipt.executionId === destination.executionId &&
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-interface",
3
- "version": "3.2.0",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "license": "MIT",