@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
package/README.md
CHANGED
|
@@ -45,6 +45,10 @@ A capability declaration is not evidence that it was delivered, opened, or appli
|
|
|
45
45
|
|
|
46
46
|
## Workspace paths
|
|
47
47
|
|
|
48
|
+
`WorkspaceRequest.snapshot` restores a portable workspace through closed content-addressed manifest and archive references. It includes the source lease and policy identities, and carries no inline file bytes. The accepted request binds both artifact hashes, because the archive also identifies Git HEAD and staged state. A snapshot cannot be combined with `repoUrl`, `gitRef` or a provider-native `checkpoint`; its `cwd` uses the repository base.
|
|
49
|
+
|
|
50
|
+
Only a qualified deployed receiver advertises `create.workspaceSnapshot`. It authorizes and verifies artifacts, enforces archive limits, and finishes restoration into a fresh owned destination before accepting a turn. An unsupported adapter refuses before credentials, provisioning or native admission. Hashes and public lease identities do not grant artifact access or workspace control.
|
|
51
|
+
|
|
48
52
|
`WorkspaceRequest.cwd` is an explicitly based path reference.
|
|
49
53
|
Use `base: "repository"` for a portable repository-relative POSIX path.
|
|
50
54
|
Use `base: "host"` for a provider-owned native host path.
|
|
@@ -95,11 +99,14 @@ An omitted permission scope permits only a one-time response; session and persis
|
|
|
95
99
|
The legacy `SdkProviderAdapter.respondToInteraction(response)` remains source-compatible, while new adapters use `respondToInteractionCommand(command)` for exact binding and durable acknowledgement.
|
|
96
100
|
|
|
97
101
|
Portable conversation transfer reuses `BackendMessage` and `InputPart` rather than defining another message format.
|
|
98
|
-
Planning is represented separately from execution
|
|
102
|
+
Planning is represented separately from execution. A local `PortableContextPlan` embeds the immutable source, lists every message and part decision, names the destination runner, contains the exact derived context, and carries a canonical digest. Keep this complete plan local.
|
|
99
103
|
Every plan request has a canonical request digest, and every ready, over-limit, or unsupported result repeats the request identifier and digest.
|
|
100
104
|
`portableContextPlanResultMatchesRequest()` verifies that the result belongs to the exact request, the returned source and destination match, and a ready plan stays within its requested token limit.
|
|
101
105
|
Partial input or output always requires explicit user or policy acceptance, even when no individual message was transformed.
|
|
102
|
-
`
|
|
106
|
+
`createContextTransferRequest()` validates a local plan and projects it into a `PortableContextTransferPlan` containing only selected typed content and hash commitments. Omitted messages, omitted parts, and human decision explanations do not travel to the destination. The destination verifies the same accepted plan digest using these commitments. Selected attachments use indexes in the selected output, even when earlier parts were omitted.
|
|
107
|
+
Individual commitments cover selected source metadata, parts, and attachments. Omitted parts and explanation text have no individual hashes; a combined review digest binds the full local source and decisions. Digests bind content and do not encrypt it.
|
|
108
|
+
`ContextTransferRequestSchema` accepts only this destination representation. The Interface 5 plan digest algorithm and transfer request shape require coordinated consumer and receiver upgrades. Preserve or settle legacy operation records through an explicit versioned recovery path before upgrading a receiver.
|
|
109
|
+
`ContextTransferRequest` binds an operation identifier to the accepted transfer plan, while `ContextTransferResult` distinguishes first admission, exact replay, changed-input conflict, and unknown transport outcome.
|
|
103
110
|
`contextTransferResultMatchesRequest()` checks the operation identifier and request digest for every outcome before a caller accepts, retries, or reports it.
|
|
104
111
|
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
112
|
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.
|
|
@@ -37,6 +37,18 @@ export interface AgentCandidateArtifactRef {
|
|
|
37
37
|
sha256: Sha256Digest;
|
|
38
38
|
byteLength: number;
|
|
39
39
|
}
|
|
40
|
+
/** Reads one content-addressed object through an authorized closed-locator resolver. */
|
|
41
|
+
export interface AgentCandidateArtifactPort {
|
|
42
|
+
read(ref: AgentCandidateArtifactRef): Promise<Uint8Array>;
|
|
43
|
+
/** Stream an artifact without materializing its complete contents. */
|
|
44
|
+
readStream?(ref: AgentCandidateArtifactRef, options?: {
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
}): AsyncIterable<Uint8Array>;
|
|
47
|
+
/** Find an already stored object by its exact content digest and length. */
|
|
48
|
+
locate?(object: Pick<AgentCandidateArtifactRef, "sha256" | "byteLength">, options?: {
|
|
49
|
+
signal?: AbortSignal;
|
|
50
|
+
}): Promise<AgentCandidateArtifactRef | undefined>;
|
|
51
|
+
}
|
|
40
52
|
/** Bytes embedded directly in a candidate manifest. */
|
|
41
53
|
export interface AgentCandidateEmbeddedArtifact {
|
|
42
54
|
encoding: "base64";
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import type { WorkspaceCwd } from "./workspace-cwd.js";
|
|
3
3
|
import { type WorkspaceCheckpointRef } from "./workspace-checkpoint.js";
|
|
4
4
|
import type { AgentProfile } from "./agent-profile.js";
|
|
5
|
+
import { type AgentWorkspaceSnapshotRef } from "./workspace-snapshot.js";
|
|
5
6
|
/** Portable profile reference: inline profile or provider catalog id. */
|
|
6
7
|
export type AgentProfileRef = AgentProfile | string;
|
|
7
8
|
export type AgentEnvironmentStatus = "pending" | "provisioning" | "running" | "stopped" | "failed" | "expired" | "unknown";
|
|
@@ -63,6 +64,13 @@ export interface WorkspaceRequest {
|
|
|
63
64
|
* checkpoint another provider took.
|
|
64
65
|
*/
|
|
65
66
|
checkpoint?: WorkspaceCheckpointRef;
|
|
67
|
+
/**
|
|
68
|
+
* Restore an accepted portable workspace from authorized immutable artifact references before
|
|
69
|
+
* create returns. This is independent of provider-native checkpoint IDs. The receiver verifies
|
|
70
|
+
* manifest, archive, limits and source binding, and publishes into a fresh owned destination.
|
|
71
|
+
* It refuses an occupied destination without changing it. Requires create.workspaceSnapshot.
|
|
72
|
+
*/
|
|
73
|
+
snapshot?: AgentWorkspaceSnapshotRef;
|
|
66
74
|
/** Opaque provider-native workspace fields. */
|
|
67
75
|
providerOptions?: Record<string, unknown>;
|
|
68
76
|
}
|
|
@@ -95,6 +103,62 @@ export declare const WorkspaceRequestSchema: z.ZodObject<{
|
|
|
95
103
|
createdAt: z.ZodISODateTime;
|
|
96
104
|
metadata: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
97
105
|
}, z.core.$strict>>;
|
|
106
|
+
snapshot: z.ZodOptional<z.ZodObject<{
|
|
107
|
+
kind: z.ZodLiteral<"agent-candidate-workspace-snapshot">;
|
|
108
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
109
|
+
manifest: z.ZodObject<{
|
|
110
|
+
locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
111
|
+
kind: z.ZodLiteral<"s3">;
|
|
112
|
+
bucket: z.ZodString;
|
|
113
|
+
key: z.ZodString;
|
|
114
|
+
region: z.ZodOptional<z.ZodString>;
|
|
115
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
116
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
117
|
+
cid: z.ZodString;
|
|
118
|
+
path: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
120
|
+
kind: z.ZodLiteral<"private-cas">;
|
|
121
|
+
namespace: z.ZodString;
|
|
122
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
123
|
+
}, z.core.$strict>], "kind">;
|
|
124
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
125
|
+
byteLength: z.ZodNumber;
|
|
126
|
+
}, z.core.$strict>;
|
|
127
|
+
archive: z.ZodObject<{
|
|
128
|
+
locator: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
129
|
+
kind: z.ZodLiteral<"s3">;
|
|
130
|
+
bucket: z.ZodString;
|
|
131
|
+
key: z.ZodString;
|
|
132
|
+
region: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
134
|
+
kind: z.ZodLiteral<"ipfs">;
|
|
135
|
+
cid: z.ZodString;
|
|
136
|
+
path: z.ZodOptional<z.ZodString>;
|
|
137
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
138
|
+
kind: z.ZodLiteral<"private-cas">;
|
|
139
|
+
namespace: z.ZodString;
|
|
140
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
141
|
+
}, z.core.$strict>], "kind">;
|
|
142
|
+
sha256: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
143
|
+
byteLength: z.ZodNumber;
|
|
144
|
+
}, z.core.$strict>;
|
|
145
|
+
source: z.ZodObject<{
|
|
146
|
+
leaseId: z.ZodString;
|
|
147
|
+
leaseRecordDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
148
|
+
workspace: z.ZodObject<{
|
|
149
|
+
provider: z.ZodString;
|
|
150
|
+
root: z.ZodString;
|
|
151
|
+
identityDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
152
|
+
}, z.core.$strict>;
|
|
153
|
+
sourceSnapshotDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
154
|
+
sourceSnapshotPolicy: z.ZodObject<{
|
|
155
|
+
kind: z.ZodLiteral<"provider-declared">;
|
|
156
|
+
name: z.ZodString;
|
|
157
|
+
version: z.ZodNumber;
|
|
158
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
159
|
+
}, z.core.$strict>;
|
|
160
|
+
}, z.core.$strict>;
|
|
161
|
+
}, z.core.$strict>>;
|
|
98
162
|
providerOptions: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
99
163
|
}, z.core.$strict>;
|
|
100
164
|
export interface ResourceRequest {
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { boundedIdentifierSchema, boundedJsonRecordSchema, boundedStringSchema, CONTRACT_MAX_ARRAY_LENGTH, } from "./contract-limits.js";
|
|
3
3
|
import { workspaceCwdSchema } from "./workspace-cwd.js";
|
|
4
4
|
import { WorkspaceCheckpointRefSchema } from "./workspace-checkpoint.js";
|
|
5
|
+
import { AgentWorkspaceSnapshotRefSchema } from "./workspace-snapshot.js";
|
|
5
6
|
/**
|
|
6
7
|
* One allowed destination host.
|
|
7
8
|
*
|
|
@@ -38,9 +39,16 @@ export const WorkspaceRequestSchema = z
|
|
|
38
39
|
gitRef: boundedIdentifierSchema.optional(),
|
|
39
40
|
cwd: workspaceCwdSchema.optional(),
|
|
40
41
|
checkpoint: WorkspaceCheckpointRefSchema.optional(),
|
|
42
|
+
snapshot: AgentWorkspaceSnapshotRefSchema.optional(),
|
|
41
43
|
providerOptions: boundedJsonRecordSchema.optional(),
|
|
42
44
|
})
|
|
43
45
|
.superRefine((workspace, refinement) => {
|
|
46
|
+
if (workspace.snapshot !== undefined && (workspace.repoUrl !== undefined || workspace.gitRef !== undefined || workspace.checkpoint !== undefined)) {
|
|
47
|
+
refinement.addIssue({ code: "custom", path: ["snapshot"], message: "workspace snapshot cannot be combined with another workspace source" });
|
|
48
|
+
}
|
|
49
|
+
if (workspace.snapshot !== undefined && workspace.cwd?.base === "host") {
|
|
50
|
+
refinement.addIssue({ code: "custom", path: ["cwd"], message: "workspace snapshot cwd must be relative to its restored repository" });
|
|
51
|
+
}
|
|
44
52
|
if (workspace.checkpoint !== undefined && workspace.repoUrl !== undefined) {
|
|
45
53
|
refinement.addIssue({
|
|
46
54
|
code: "custom",
|