@tangle-network/agent-interface 4.0.0 → 5.1.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 +9 -2
- package/dist/agent-candidate.d.ts +12 -0
- package/dist/environment-provider.d.ts +1 -0
- package/dist/environment-provider.js +1 -0
- package/dist/environment-requests.d.ts +64 -0
- package/dist/environment-requests.js +8 -0
- package/dist/environment-runtime.d.ts +526 -36
- package/dist/environment-runtime.js +16 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/portable-context-commitments.d.ts +47 -0
- package/dist/portable-context-commitments.js +48 -0
- package/dist/portable-context-plan-request.d.ts +1 -0
- package/dist/portable-context-plan-wire.d.ts +103 -0
- package/dist/portable-context-plan-wire.js +127 -0
- package/dist/portable-context-plan.d.ts +3 -1
- package/dist/portable-context-plan.js +10 -13
- package/dist/portable-context-transfer.d.ts +72 -32
- package/dist/portable-context-transfer.js +15 -2
- package/dist/portable-context.d.ts +1 -0
- package/dist/portable-context.js +1 -0
- package/dist/workspace-snapshot.d.ts +79 -0
- package/dist/workspace-snapshot.js +31 -0
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import type { AgentProfile } from "./agent-profile.js";
|
|
|
3
3
|
import { type ResourceRequest, type WorkspaceRequest } from "./environment-requests.js";
|
|
4
4
|
import type { Sha256Digest } from "./agent-candidate.js";
|
|
5
5
|
import { type PortableContextPlan } from "./portable-context-plan.js";
|
|
6
|
+
import { type PortableContextTransferPlan } from "./portable-context-plan-wire.js";
|
|
6
7
|
export declare const ContextPlanAcceptanceSchema: z.ZodObject<{
|
|
7
8
|
planDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
8
9
|
acceptedAt: z.ZodISODateTime;
|
|
@@ -15,18 +16,22 @@ export declare const ContextPlanAcceptanceSchema: z.ZodObject<{
|
|
|
15
16
|
export type ContextPlanAcceptance = z.infer<typeof ContextPlanAcceptanceSchema>;
|
|
16
17
|
export interface ContextTransferRequestMaterial {
|
|
17
18
|
operationId: string;
|
|
18
|
-
plan: PortableContextPlan;
|
|
19
|
+
plan: PortableContextPlan | PortableContextTransferPlan;
|
|
19
20
|
acceptance: ContextPlanAcceptance;
|
|
20
21
|
profile?: AgentProfile;
|
|
21
22
|
workspace?: WorkspaceRequest;
|
|
22
23
|
resources?: ResourceRequest;
|
|
23
24
|
}
|
|
24
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;
|
|
25
28
|
export declare const ContextTransferRequestSchema: z.ZodObject<{
|
|
26
29
|
operationId: z.ZodString;
|
|
27
30
|
requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
28
31
|
plan: z.ZodObject<{
|
|
32
|
+
kind: z.ZodLiteral<"portable-context-transfer-plan">;
|
|
29
33
|
planId: z.ZodString;
|
|
34
|
+
reviewDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
30
35
|
source: z.ZodObject<{
|
|
31
36
|
source: z.ZodObject<{
|
|
32
37
|
runId: z.ZodString;
|
|
@@ -38,29 +43,21 @@ export declare const ContextTransferRequestSchema: z.ZodObject<{
|
|
|
38
43
|
requestDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
39
44
|
branchId: z.ZodOptional<z.ZodString>;
|
|
40
45
|
}, z.core.$strict>;
|
|
46
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
41
47
|
completeness: z.ZodEnum<{
|
|
42
48
|
complete: "complete";
|
|
43
49
|
partial: "partial";
|
|
44
50
|
}>;
|
|
45
51
|
messages: z.ZodArray<z.ZodObject<{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
system: "system";
|
|
50
|
-
user: "user";
|
|
51
|
-
}>;
|
|
52
|
-
parts: z.ZodArray<z.ZodCustom<unknown, unknown>>;
|
|
53
|
-
timestamp: z.ZodISODateTime;
|
|
54
|
-
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>>>>;
|
|
55
55
|
}, z.core.$strict>>;
|
|
56
56
|
attachments: z.ZodArray<z.ZodObject<{
|
|
57
57
|
messageId: z.ZodString;
|
|
58
58
|
partIndex: z.ZodNumber;
|
|
59
59
|
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
60
|
-
name: z.ZodOptional<z.ZodString>;
|
|
61
|
-
mediaType: z.ZodOptional<z.ZodString>;
|
|
62
60
|
}, z.core.$strict>>;
|
|
63
|
-
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
64
61
|
}, z.core.$strict>;
|
|
65
62
|
destination: z.ZodObject<{
|
|
66
63
|
runner: z.ZodString;
|
|
@@ -71,6 +68,7 @@ export declare const ContextTransferRequestSchema: z.ZodObject<{
|
|
|
71
68
|
executionId: z.ZodString;
|
|
72
69
|
model: z.ZodOptional<z.ZodString>;
|
|
73
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>>>;
|
|
74
72
|
}, z.core.$strict>;
|
|
75
73
|
messages: z.ZodArray<z.ZodObject<{
|
|
76
74
|
messageId: z.ZodString;
|
|
@@ -85,26 +83,8 @@ export declare const ContextTransferRequestSchema: z.ZodObject<{
|
|
|
85
83
|
omit: "omit";
|
|
86
84
|
transform: "transform";
|
|
87
85
|
}>;
|
|
88
|
-
|
|
89
|
-
type: z.ZodLiteral<"text">;
|
|
90
|
-
text: z.ZodString;
|
|
91
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
92
|
-
type: z.ZodLiteral<"file">;
|
|
93
|
-
filename: z.ZodOptional<z.ZodString>;
|
|
94
|
-
mediaType: z.ZodOptional<z.ZodString>;
|
|
95
|
-
url: z.ZodOptional<z.ZodString>;
|
|
96
|
-
path: z.ZodOptional<z.ZodString>;
|
|
97
|
-
content: z.ZodOptional<z.ZodString>;
|
|
98
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
99
|
-
type: z.ZodLiteral<"image">;
|
|
100
|
-
filename: z.ZodOptional<z.ZodString>;
|
|
101
|
-
mediaType: z.ZodOptional<z.ZodString>;
|
|
102
|
-
url: z.ZodOptional<z.ZodString>;
|
|
103
|
-
path: z.ZodOptional<z.ZodString>;
|
|
104
|
-
}, z.core.$strict>], "type">>;
|
|
105
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
86
|
+
outputDigest: z.ZodOptional<z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>>;
|
|
106
87
|
}, z.core.$strict>>;
|
|
107
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
108
88
|
}, z.core.$strict>>;
|
|
109
89
|
context: z.ZodObject<{
|
|
110
90
|
source: z.ZodObject<{
|
|
@@ -407,6 +387,62 @@ export declare const ContextTransferRequestSchema: z.ZodObject<{
|
|
|
407
387
|
createdAt: z.ZodISODateTime;
|
|
408
388
|
metadata: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
409
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>>;
|
|
410
446
|
providerOptions: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
411
447
|
}, z.core.$strict>>;
|
|
412
448
|
resources: z.ZodOptional<z.ZodObject<{
|
|
@@ -443,6 +479,7 @@ export declare const ContextTransferReceiptSchema: z.ZodDiscriminatedUnion<[z.Zo
|
|
|
443
479
|
executionId: z.ZodString;
|
|
444
480
|
model: z.ZodOptional<z.ZodString>;
|
|
445
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>>>;
|
|
446
483
|
}, z.core.$strict>;
|
|
447
484
|
provider: z.ZodString;
|
|
448
485
|
environmentId: z.ZodString;
|
|
@@ -479,6 +516,7 @@ export declare const ContextTransferReceiptSchema: z.ZodDiscriminatedUnion<[z.Zo
|
|
|
479
516
|
executionId: z.ZodString;
|
|
480
517
|
model: z.ZodOptional<z.ZodString>;
|
|
481
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>>>;
|
|
482
520
|
}, z.core.$strict>;
|
|
483
521
|
provider: z.ZodString;
|
|
484
522
|
environmentId: z.ZodString;
|
|
@@ -519,6 +557,7 @@ export declare const ContextTransferResultSchema: z.ZodDiscriminatedUnion<[z.Zod
|
|
|
519
557
|
executionId: z.ZodString;
|
|
520
558
|
model: z.ZodOptional<z.ZodString>;
|
|
521
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>>>;
|
|
522
561
|
}, z.core.$strict>;
|
|
523
562
|
provider: z.ZodString;
|
|
524
563
|
environmentId: z.ZodString;
|
|
@@ -555,6 +594,7 @@ export declare const ContextTransferResultSchema: z.ZodDiscriminatedUnion<[z.Zod
|
|
|
555
594
|
executionId: z.ZodString;
|
|
556
595
|
model: z.ZodOptional<z.ZodString>;
|
|
557
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>>>;
|
|
558
598
|
}, z.core.$strict>;
|
|
559
599
|
provider: z.ZodString;
|
|
560
600
|
environmentId: z.ZodString;
|
|
@@ -5,7 +5,9 @@ import { ResourceRequestSchema, WorkspaceRequestSchema } from "./environment-req
|
|
|
5
5
|
import { boundedStringSchema, CONTRACT_MAX_ARRAY_LENGTH, } from "./contract-limits.js";
|
|
6
6
|
import { PortableContextSourceBoundarySchema, } from "./portable-context-base.js";
|
|
7
7
|
import { PortableContextDestinationSchema, PortableContextPlanSchema, } from "./portable-context-plan.js";
|
|
8
|
+
import { PortableContextTransferPlanSchema, projectPortableContextPlan } from "./portable-context-plan-wire.js";
|
|
8
9
|
import { idSchema, sha256DigestSchema, wireDigest } from "./portable-context-shared.js";
|
|
10
|
+
import { agentWorkspaceSnapshotRefDigest } from "./workspace-snapshot.js";
|
|
9
11
|
export const ContextPlanAcceptanceSchema = z.strictObject({
|
|
10
12
|
planDigest: sha256DigestSchema,
|
|
11
13
|
acceptedAt: z.iso.datetime().max(64),
|
|
@@ -13,7 +15,7 @@ export const ContextPlanAcceptanceSchema = z.strictObject({
|
|
|
13
15
|
});
|
|
14
16
|
const ContextTransferRequestMaterialSchema = z.strictObject({
|
|
15
17
|
operationId: idSchema,
|
|
16
|
-
plan: PortableContextPlanSchema,
|
|
18
|
+
plan: z.union([PortableContextTransferPlanSchema, PortableContextPlanSchema]),
|
|
17
19
|
acceptance: ContextPlanAcceptanceSchema,
|
|
18
20
|
profile: agentProfileSchema.optional(),
|
|
19
21
|
workspace: WorkspaceRequestSchema.optional(),
|
|
@@ -30,17 +32,28 @@ export function contextTransferRequestDigest(request) {
|
|
|
30
32
|
...(parsed.resources === undefined ? {} : { resources: parsed.resources }),
|
|
31
33
|
});
|
|
32
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
|
+
}
|
|
33
41
|
export const ContextTransferRequestSchema = z
|
|
34
42
|
.strictObject({
|
|
35
43
|
operationId: idSchema,
|
|
36
44
|
requestDigest: sha256DigestSchema,
|
|
37
|
-
plan:
|
|
45
|
+
plan: PortableContextTransferPlanSchema,
|
|
38
46
|
acceptance: ContextPlanAcceptanceSchema,
|
|
39
47
|
profile: agentProfileSchema.optional(),
|
|
40
48
|
workspace: WorkspaceRequestSchema.optional(),
|
|
41
49
|
resources: ResourceRequestSchema.optional(),
|
|
42
50
|
})
|
|
43
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
|
+
}
|
|
44
57
|
if (request.plan.destination.environmentId === undefined && request.profile === undefined) {
|
|
45
58
|
refinement.addIssue({ code: "custom", path: ["profile"], message: "an unbound destination requires its exact profile" });
|
|
46
59
|
}
|
|
@@ -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";
|
package/dist/portable-context.js
CHANGED
|
@@ -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";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { AgentCandidateArtifactRef, Sha256Digest } from "./agent-candidate.js";
|
|
3
|
+
import { type AgentWorkspaceLeaseRecord } from "./agent-workspace-lease.js";
|
|
4
|
+
/** Public source binding. A lease identifier or artifact locator grants no authority. */
|
|
5
|
+
export type AgentWorkspaceSnapshotSource = Pick<AgentWorkspaceLeaseRecord, "leaseId" | "workspace" | "sourceSnapshotDigest" | "sourceSnapshotPolicy"> & {
|
|
6
|
+
leaseRecordDigest: Sha256Digest;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Reference-only projection of the canonical candidate workspace archive.
|
|
10
|
+
* Runtime resolves and verifies the canonical manifest and archive before restore. The manifest
|
|
11
|
+
* digest binds file bytes and modes; the archive hash additionally binds Git HEAD and index state.
|
|
12
|
+
* Capture requires the source owner's private lease. Acceptance binds this complete value, not
|
|
13
|
+
* only `digest`. Receivers authorize each closed artifact reference for the accepted operation.
|
|
14
|
+
*/
|
|
15
|
+
export interface AgentWorkspaceSnapshotRef {
|
|
16
|
+
kind: "agent-candidate-workspace-snapshot";
|
|
17
|
+
digest: Sha256Digest;
|
|
18
|
+
manifest: AgentCandidateArtifactRef;
|
|
19
|
+
archive: AgentCandidateArtifactRef;
|
|
20
|
+
source: AgentWorkspaceSnapshotSource;
|
|
21
|
+
}
|
|
22
|
+
export declare const AgentWorkspaceSnapshotRefSchema: z.ZodObject<{
|
|
23
|
+
kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
|
|
24
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
25
|
+
manifest: z.ZodObject<{
|
|
26
|
+
locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
27
|
+
kind: z.ZodLiteral<"s3">;
|
|
28
|
+
bucket: z.ZodString;
|
|
29
|
+
key: z.ZodString;
|
|
30
|
+
region: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
32
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
33
|
+
cid: z.ZodString;
|
|
34
|
+
path: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
36
|
+
kind: z.ZodLiteral<"private-cas">;
|
|
37
|
+
namespace: z.ZodString;
|
|
38
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
39
|
+
}, z.core.$strict>], "kind">;
|
|
40
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
41
|
+
byteLength: z.ZodNumber;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
archive: z.ZodObject<{
|
|
44
|
+
locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
45
|
+
kind: z.ZodLiteral<"s3">;
|
|
46
|
+
bucket: z.ZodString;
|
|
47
|
+
key: z.ZodString;
|
|
48
|
+
region: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
51
|
+
cid: z.ZodString;
|
|
52
|
+
path: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
54
|
+
kind: z.ZodLiteral<"private-cas">;
|
|
55
|
+
namespace: z.ZodString;
|
|
56
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
57
|
+
}, z.core.$strict>], "kind">;
|
|
58
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
59
|
+
byteLength: z.ZodNumber;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
|
+
source: z.ZodObject<{
|
|
62
|
+
leaseId: z.ZodString;
|
|
63
|
+
leaseRecordDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
64
|
+
workspace: z.ZodObject<{
|
|
65
|
+
provider: z.ZodString;
|
|
66
|
+
root: z.ZodString;
|
|
67
|
+
identityDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
sourceSnapshotDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
70
|
+
sourceSnapshotPolicy: z.ZodObject<{
|
|
71
|
+
kind: z.ZodLiteral<"provider-declared">;
|
|
72
|
+
name: z.ZodString;
|
|
73
|
+
version: z.ZodNumber;
|
|
74
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
75
|
+
}, z.core.$strict>;
|
|
76
|
+
}, z.core.$strict>;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
/** Acceptance identity of the complete reference, including Git archive and source binding. */
|
|
79
|
+
export declare function agentWorkspaceSnapshotRefDigest(snapshot: AgentWorkspaceSnapshotRef): Sha256Digest;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { agentCandidateArtifactRefSchema } from "./agent-candidate-artifact-schema.js";
|
|
3
|
+
import { canonicalCandidateDigest, sha256DigestSchema } from "./agent-candidate-schema-common.js";
|
|
4
|
+
import { agentWorkspaceAllocationIdentitySchema, } from "./agent-workspace-lease.js";
|
|
5
|
+
import { agentWorkspacePublicIdentifierSchema, agentWorkspaceSourceSnapshotPolicySchema, } from "./agent-workspace-source-snapshot.js";
|
|
6
|
+
const nonemptyArtifactRefSchema = agentCandidateArtifactRefSchema.superRefine((ref, ctx) => {
|
|
7
|
+
if (!Number.isSafeInteger(ref.byteLength) || ref.byteLength < 1) {
|
|
8
|
+
ctx.addIssue({ code: "custom", path: ["byteLength"], message: "workspace artifact length must be a positive safe integer" });
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export const AgentWorkspaceSnapshotRefSchema = z.strictObject({
|
|
12
|
+
kind: z.literal("agent-candidate-workspace-snapshot"),
|
|
13
|
+
digest: sha256DigestSchema,
|
|
14
|
+
manifest: nonemptyArtifactRefSchema,
|
|
15
|
+
archive: nonemptyArtifactRefSchema,
|
|
16
|
+
source: z.strictObject({
|
|
17
|
+
leaseId: agentWorkspacePublicIdentifierSchema,
|
|
18
|
+
leaseRecordDigest: sha256DigestSchema,
|
|
19
|
+
workspace: agentWorkspaceAllocationIdentitySchema,
|
|
20
|
+
sourceSnapshotDigest: sha256DigestSchema,
|
|
21
|
+
sourceSnapshotPolicy: agentWorkspaceSourceSnapshotPolicySchema,
|
|
22
|
+
}),
|
|
23
|
+
}).superRefine((snapshot, ctx) => {
|
|
24
|
+
if (snapshot.digest !== snapshot.manifest.sha256) {
|
|
25
|
+
ctx.addIssue({ code: "custom", path: ["manifest", "sha256"], message: "workspace digest must equal the canonical manifest hash" });
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
/** Acceptance identity of the complete reference, including Git archive and source binding. */
|
|
29
|
+
export function agentWorkspaceSnapshotRefDigest(snapshot) {
|
|
30
|
+
return canonicalCandidateDigest(AgentWorkspaceSnapshotRefSchema.parse(snapshot));
|
|
31
|
+
}
|