@tangle-network/agent-interface 0.37.0 → 0.39.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/dist/agent-candidate-execution-plan-schema.d.ts +50 -27
- package/dist/agent-candidate-execution-plan-schema.js +4 -16
- package/dist/agent-candidate-profile-schema.d.ts +5 -25
- package/dist/agent-candidate-promotion-schema.d.ts +280 -285
- package/dist/agent-candidate-receipt-schema.d.ts +50 -27
- package/dist/agent-candidate-schema.d.ts +5 -25
- package/dist/agent-candidate.d.ts +2 -8
- package/dist/agent-execution-preparation.d.ts +366 -0
- package/dist/agent-execution-preparation.js +736 -0
- package/dist/agent-profile-activation.d.ts +41 -0
- package/dist/agent-profile-activation.js +24 -0
- package/dist/agent-profile-canonical.d.ts +12 -0
- package/dist/agent-profile-canonical.js +79 -0
- package/dist/agent-profile-improvement-schema.d.ts +3 -6
- package/dist/agent-profile-improvement-schema.js +94 -56
- package/dist/agent-profile-improvement.d.ts +3 -3
- package/dist/agent-profile-materialization.d.ts +34 -0
- package/dist/agent-profile-materialization.js +243 -0
- package/dist/agent-profile.d.ts +44 -7
- package/dist/agent-profile.js +39 -2
- package/dist/agent-workspace-lease.d.ts +138 -0
- package/dist/agent-workspace-lease.js +203 -0
- package/dist/harness-capabilities.d.ts +1 -1
- package/dist/harness-capabilities.js +2 -9
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/profile-diff.d.ts +11 -0
- package/dist/profile-diff.js +123 -3
- package/dist/profile-schema.d.ts +142 -84
- package/dist/profile-schema.js +152 -41
- package/package.json +1 -1
package/dist/agent-profile.d.ts
CHANGED
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These model portable agent intent at the application boundary. Individual
|
|
5
5
|
* backends translate this shape into their own native profile/configuration
|
|
6
|
-
* formats internally.
|
|
7
|
-
*
|
|
6
|
+
* formats internally. Profile content participates in unsalted public identity.
|
|
7
|
+
* Prompts, resources, metadata, commands, paths, and secret-reference keys are
|
|
8
|
+
* caller-declared public data; recognizable credential patterns are refused as
|
|
9
|
+
* defense in depth, not as proof that arbitrary text is non-secret. MCP and hook
|
|
10
|
+
* secret-capable fields structurally require tagged public values or opaque
|
|
11
|
+
* secret references, which a private executor resolves only after identity is
|
|
12
|
+
* fixed. This package is the canonical public home for these symbols.
|
|
8
13
|
*/
|
|
9
14
|
import type { HarnessType } from "./harness.js";
|
|
10
15
|
/**
|
|
@@ -96,7 +101,8 @@ export interface AgentProfileResources {
|
|
|
96
101
|
* A backend without a matching native tier may clamp down to its strongest supported level, but it
|
|
97
102
|
* must never turn reasoning on for `none` or silently increase a requested effort.
|
|
98
103
|
*/
|
|
99
|
-
export
|
|
104
|
+
export declare const REASONING_EFFORTS: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "ultracode"];
|
|
105
|
+
export type ReasoningEffort = (typeof REASONING_EFFORTS)[number];
|
|
100
106
|
/**
|
|
101
107
|
* Model selection hints for backends.
|
|
102
108
|
*/
|
|
@@ -136,6 +142,37 @@ export interface AgentProfilePrompt {
|
|
|
136
142
|
*/
|
|
137
143
|
instructions?: string[];
|
|
138
144
|
}
|
|
145
|
+
/** Deliberately public configuration included in profile identity. */
|
|
146
|
+
export interface AgentProfilePublicConfigValue {
|
|
147
|
+
kind: "public";
|
|
148
|
+
value: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Opaque reference resolved only inside the private prepared executor.
|
|
152
|
+
* `key` is caller-declared public identity naming provider/operator-owned
|
|
153
|
+
* secret material; callers must not put the secret value in it.
|
|
154
|
+
*/
|
|
155
|
+
export interface AgentProfileSecretRef {
|
|
156
|
+
kind: "secret-ref";
|
|
157
|
+
key: string;
|
|
158
|
+
/** Apply no decoration or a `Bearer ` prefix after private resolution. */
|
|
159
|
+
format?: "raw" | "bearer";
|
|
160
|
+
}
|
|
161
|
+
/** A configuration value is public bytes or an opaque secret identity. */
|
|
162
|
+
export type AgentProfileConfigValue = AgentProfilePublicConfigValue | AgentProfileSecretRef;
|
|
163
|
+
/**
|
|
164
|
+
* Private executor port for resolving one public secret-reference identity.
|
|
165
|
+
* Implementations return the raw undecorated value. Consumers must fail
|
|
166
|
+
* preparation on missing or blank values and must keep resolved values out of
|
|
167
|
+
* profiles, public plans, digests, receipts, diagnostics, and logs.
|
|
168
|
+
*/
|
|
169
|
+
export interface AgentProfileSecretProvider {
|
|
170
|
+
get(key: string): Promise<string | undefined>;
|
|
171
|
+
}
|
|
172
|
+
/** Mark an exact configuration value as public profile material. */
|
|
173
|
+
export declare function defineAgentProfilePublicConfig(value: string): AgentProfilePublicConfigValue;
|
|
174
|
+
/** Create a secret reference whose key is caller-declared public identity. */
|
|
175
|
+
export declare function defineAgentProfileSecretRef(key: string, format?: AgentProfileSecretRef["format"]): AgentProfileSecretRef;
|
|
139
176
|
/**
|
|
140
177
|
* Generic subagent definition.
|
|
141
178
|
*/
|
|
@@ -153,7 +190,7 @@ export interface AgentProfileHookCommand {
|
|
|
153
190
|
timeoutMs?: number;
|
|
154
191
|
blocking?: boolean;
|
|
155
192
|
matcher?: string;
|
|
156
|
-
env?: Record<string,
|
|
193
|
+
env?: Record<string, AgentProfileConfigValue>;
|
|
157
194
|
}
|
|
158
195
|
export interface AgentProfileMode {
|
|
159
196
|
description?: string;
|
|
@@ -198,8 +235,8 @@ interface AgentProfileLocalMcpServer extends AgentProfileMcpServerBase {
|
|
|
198
235
|
enabled?: true;
|
|
199
236
|
transport?: "stdio";
|
|
200
237
|
command: string;
|
|
201
|
-
args?:
|
|
202
|
-
env?: Record<string,
|
|
238
|
+
args?: AgentProfileConfigValue[];
|
|
239
|
+
env?: Record<string, AgentProfileConfigValue>;
|
|
203
240
|
cwd?: string;
|
|
204
241
|
url?: never;
|
|
205
242
|
headers?: never;
|
|
@@ -212,7 +249,7 @@ interface AgentProfileRemoteMcpServer extends AgentProfileMcpServerBase {
|
|
|
212
249
|
env?: never;
|
|
213
250
|
cwd?: never;
|
|
214
251
|
url: string;
|
|
215
|
-
headers?: Record<string,
|
|
252
|
+
headers?: Record<string, AgentProfileConfigValue>;
|
|
216
253
|
}
|
|
217
254
|
interface AgentProfileDisabledMcpServer extends AgentProfileMcpServerBase {
|
|
218
255
|
enabled: false;
|
package/dist/agent-profile.js
CHANGED
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These model portable agent intent at the application boundary. Individual
|
|
5
5
|
* backends translate this shape into their own native profile/configuration
|
|
6
|
-
* formats internally.
|
|
7
|
-
*
|
|
6
|
+
* formats internally. Profile content participates in unsalted public identity.
|
|
7
|
+
* Prompts, resources, metadata, commands, paths, and secret-reference keys are
|
|
8
|
+
* caller-declared public data; recognizable credential patterns are refused as
|
|
9
|
+
* defense in depth, not as proof that arbitrary text is non-secret. MCP and hook
|
|
10
|
+
* secret-capable fields structurally require tagged public values or opaque
|
|
11
|
+
* secret references, which a private executor resolves only after identity is
|
|
12
|
+
* fixed. This package is the canonical public home for these symbols.
|
|
8
13
|
*/
|
|
9
14
|
/**
|
|
10
15
|
* Helper for creating typed inline resource refs.
|
|
@@ -24,6 +29,38 @@ export function defineGitHubResource(path, options = {}) {
|
|
|
24
29
|
name: options.name,
|
|
25
30
|
};
|
|
26
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Portable reasoning/thinking effort. Backends map it to their native control at materialization:
|
|
34
|
+
* codex `model_reasoning_effort`, kimi `--thinking`/`--no-thinking`, claude thinking budget.
|
|
35
|
+
* Ordered low→high:
|
|
36
|
+
* - `none` — extended thinking OFF (no reasoning budget at all)
|
|
37
|
+
* - `minimal` — thinking ON, the lowest budget (distinct from `none`)
|
|
38
|
+
* - `low` / `medium` / `high` / `xhigh`
|
|
39
|
+
* - `ultracode` — maximum (Claude Code's `max` and Codex's `ultra` reconcile here).
|
|
40
|
+
* A backend without a matching native tier may clamp down to its strongest supported level, but it
|
|
41
|
+
* must never turn reasoning on for `none` or silently increase a requested effort.
|
|
42
|
+
*/
|
|
43
|
+
export const REASONING_EFFORTS = Object.freeze([
|
|
44
|
+
"none",
|
|
45
|
+
"minimal",
|
|
46
|
+
"low",
|
|
47
|
+
"medium",
|
|
48
|
+
"high",
|
|
49
|
+
"xhigh",
|
|
50
|
+
"ultracode",
|
|
51
|
+
]);
|
|
52
|
+
/** Mark an exact configuration value as public profile material. */
|
|
53
|
+
export function defineAgentProfilePublicConfig(value) {
|
|
54
|
+
return { kind: "public", value };
|
|
55
|
+
}
|
|
56
|
+
/** Create a secret reference whose key is caller-declared public identity. */
|
|
57
|
+
export function defineAgentProfileSecretRef(key, format) {
|
|
58
|
+
return {
|
|
59
|
+
kind: "secret-ref",
|
|
60
|
+
key,
|
|
61
|
+
...(format === undefined ? {} : { format }),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
27
64
|
/**
|
|
28
65
|
* Helper for declaring typed profiles in application code.
|
|
29
66
|
*/
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Sha256Digest } from "./agent-candidate.js";
|
|
3
|
+
export declare const AGENT_WORKSPACE_LEASE_PHASES: readonly ["copy-ready", "workspace-sealed", "execution-bound", "destroying", "cleanup-failed", "destroyed"];
|
|
4
|
+
export type AgentWorkspaceLeasePhase = (typeof AGENT_WORKSPACE_LEASE_PHASES)[number];
|
|
5
|
+
/**
|
|
6
|
+
* Public identity of the provider-owned rules used to capture workspace state.
|
|
7
|
+
* The digest binds the exact canonical policy document retained by the provider;
|
|
8
|
+
* this descriptor does not claim that every provider captures the same fields.
|
|
9
|
+
*/
|
|
10
|
+
export interface AgentWorkspaceSourceSnapshotPolicy {
|
|
11
|
+
kind: "provider-declared";
|
|
12
|
+
name: string;
|
|
13
|
+
version: number;
|
|
14
|
+
digest: Sha256Digest;
|
|
15
|
+
}
|
|
16
|
+
/** Public allocation identity. `root` locates bytes; it grants no authority. */
|
|
17
|
+
export interface AgentWorkspaceAllocationIdentity {
|
|
18
|
+
provider: string;
|
|
19
|
+
root: string;
|
|
20
|
+
/** Digest of the provider, lease/allocation identity, and canonical root. */
|
|
21
|
+
identityDigest: Sha256Digest;
|
|
22
|
+
}
|
|
23
|
+
interface AgentWorkspaceLeaseRecordBase {
|
|
24
|
+
kind: "agent-workspace-lease";
|
|
25
|
+
schemaVersion: 1;
|
|
26
|
+
leaseId: string;
|
|
27
|
+
ownerId: string;
|
|
28
|
+
workspace: AgentWorkspaceAllocationIdentity;
|
|
29
|
+
isolation: "per-run" | "shared";
|
|
30
|
+
sourceSnapshotDigest: Sha256Digest;
|
|
31
|
+
/** Governs both the source and prepared workspace digest interpretation. */
|
|
32
|
+
sourceSnapshotPolicy: AgentWorkspaceSourceSnapshotPolicy;
|
|
33
|
+
createdAtMs: number;
|
|
34
|
+
updatedAtMs: number;
|
|
35
|
+
expiresAtMs: number;
|
|
36
|
+
}
|
|
37
|
+
interface AgentWorkspaceUnpreparedEvidence {
|
|
38
|
+
preparedWorkspaceDigest?: never;
|
|
39
|
+
profileActivationDigest?: never;
|
|
40
|
+
executionPreparationDigest?: never;
|
|
41
|
+
}
|
|
42
|
+
interface AgentWorkspaceSealedEvidence {
|
|
43
|
+
preparedWorkspaceDigest: Sha256Digest;
|
|
44
|
+
profileActivationDigest: Sha256Digest;
|
|
45
|
+
executionPreparationDigest?: never;
|
|
46
|
+
}
|
|
47
|
+
interface AgentWorkspaceExecutionBoundEvidence {
|
|
48
|
+
preparedWorkspaceDigest: Sha256Digest;
|
|
49
|
+
profileActivationDigest: Sha256Digest;
|
|
50
|
+
executionPreparationDigest: Sha256Digest;
|
|
51
|
+
}
|
|
52
|
+
export type AgentWorkspaceCopyReadyLeaseRecordMaterial = AgentWorkspaceLeaseRecordBase & AgentWorkspaceUnpreparedEvidence & {
|
|
53
|
+
phase: "copy-ready";
|
|
54
|
+
cleanupAttempts: 0;
|
|
55
|
+
cleanupError?: never;
|
|
56
|
+
};
|
|
57
|
+
export type AgentWorkspaceSealedLeaseRecordMaterial = AgentWorkspaceLeaseRecordBase & AgentWorkspaceSealedEvidence & {
|
|
58
|
+
phase: "workspace-sealed";
|
|
59
|
+
cleanupAttempts: 0;
|
|
60
|
+
cleanupError?: never;
|
|
61
|
+
};
|
|
62
|
+
export type AgentWorkspaceExecutionBoundLeaseRecordMaterial = AgentWorkspaceLeaseRecordBase & AgentWorkspaceExecutionBoundEvidence & {
|
|
63
|
+
phase: "execution-bound";
|
|
64
|
+
cleanupAttempts: 0;
|
|
65
|
+
cleanupError?: never;
|
|
66
|
+
};
|
|
67
|
+
type AgentWorkspaceCleanupEvidence = AgentWorkspaceUnpreparedEvidence | AgentWorkspaceSealedEvidence | AgentWorkspaceExecutionBoundEvidence;
|
|
68
|
+
export type AgentWorkspaceDestroyingLeaseRecordMaterial = AgentWorkspaceLeaseRecordBase & AgentWorkspaceCleanupEvidence & {
|
|
69
|
+
phase: "destroying";
|
|
70
|
+
cleanupAttempts: number;
|
|
71
|
+
cleanupError?: never;
|
|
72
|
+
};
|
|
73
|
+
export type AgentWorkspaceCleanupFailedLeaseRecordMaterial = AgentWorkspaceLeaseRecordBase & AgentWorkspaceCleanupEvidence & {
|
|
74
|
+
phase: "cleanup-failed";
|
|
75
|
+
cleanupAttempts: number;
|
|
76
|
+
/** Sanitized public diagnostic; providers remain responsible for redaction. */
|
|
77
|
+
cleanupError: string;
|
|
78
|
+
};
|
|
79
|
+
export type AgentWorkspaceDestroyedLeaseRecordMaterial = AgentWorkspaceLeaseRecordBase & AgentWorkspaceCleanupEvidence & {
|
|
80
|
+
phase: "destroyed";
|
|
81
|
+
cleanupAttempts: number;
|
|
82
|
+
cleanupError?: never;
|
|
83
|
+
};
|
|
84
|
+
export type AgentWorkspaceLeaseRecordMaterial = AgentWorkspaceCopyReadyLeaseRecordMaterial | AgentWorkspaceSealedLeaseRecordMaterial | AgentWorkspaceExecutionBoundLeaseRecordMaterial | AgentWorkspaceDestroyingLeaseRecordMaterial | AgentWorkspaceCleanupFailedLeaseRecordMaterial | AgentWorkspaceDestroyedLeaseRecordMaterial;
|
|
85
|
+
type WithDigest<Material> = Material extends unknown ? Material & {
|
|
86
|
+
digest: Sha256Digest;
|
|
87
|
+
} : never;
|
|
88
|
+
/** Self-hashed public projection. Private authorization and durable state stay out. */
|
|
89
|
+
export type AgentWorkspaceLeaseRecord = WithDigest<AgentWorkspaceLeaseRecordMaterial>;
|
|
90
|
+
export type AgentWorkspaceCopyReadyLeaseRecord = WithDigest<AgentWorkspaceCopyReadyLeaseRecordMaterial>;
|
|
91
|
+
export type AgentWorkspaceSealedLeaseRecord = WithDigest<AgentWorkspaceSealedLeaseRecordMaterial>;
|
|
92
|
+
export type AgentWorkspaceExecutionBoundLeaseRecord = WithDigest<AgentWorkspaceExecutionBoundLeaseRecordMaterial>;
|
|
93
|
+
export type AgentWorkspaceDestroyingLeaseRecord = WithDigest<AgentWorkspaceDestroyingLeaseRecordMaterial>;
|
|
94
|
+
export type AgentWorkspaceCleanupFailedLeaseRecord = WithDigest<AgentWorkspaceCleanupFailedLeaseRecordMaterial>;
|
|
95
|
+
export type AgentWorkspaceDestroyedLeaseRecord = WithDigest<AgentWorkspaceDestroyedLeaseRecordMaterial>;
|
|
96
|
+
/**
|
|
97
|
+
* Request-only owner capability. Providers persist at most a one-way digest;
|
|
98
|
+
* this value never belongs in a public lease or execution receipt.
|
|
99
|
+
*/
|
|
100
|
+
export interface AgentWorkspaceLeaseAuthorization {
|
|
101
|
+
leaseId: string;
|
|
102
|
+
ownerToken: string;
|
|
103
|
+
}
|
|
104
|
+
export interface AgentWorkspaceSealRequest extends AgentWorkspaceLeaseAuthorization {
|
|
105
|
+
profileActivationDigest: Sha256Digest;
|
|
106
|
+
}
|
|
107
|
+
export interface AgentWorkspaceExecutionBindingRequest extends AgentWorkspaceLeaseAuthorization {
|
|
108
|
+
executionPreparationDigest: Sha256Digest;
|
|
109
|
+
}
|
|
110
|
+
export interface AgentWorkspaceLeaseRenewalRequest extends AgentWorkspaceLeaseAuthorization {
|
|
111
|
+
expiresAtMs: number;
|
|
112
|
+
}
|
|
113
|
+
export declare const agentWorkspaceLeasePhaseSchema: z.ZodEnum<{
|
|
114
|
+
"copy-ready": "copy-ready";
|
|
115
|
+
"workspace-sealed": "workspace-sealed";
|
|
116
|
+
"execution-bound": "execution-bound";
|
|
117
|
+
destroying: "destroying";
|
|
118
|
+
"cleanup-failed": "cleanup-failed";
|
|
119
|
+
destroyed: "destroyed";
|
|
120
|
+
}>;
|
|
121
|
+
export declare const agentWorkspaceSourceSnapshotPolicySchema: z.ZodObject<{
|
|
122
|
+
kind: z.ZodLiteral<"provider-declared">;
|
|
123
|
+
name: z.ZodString;
|
|
124
|
+
version: z.ZodNumber;
|
|
125
|
+
digest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
126
|
+
}, z.core.$strict>;
|
|
127
|
+
export declare const agentWorkspaceAllocationIdentitySchema: z.ZodObject<{
|
|
128
|
+
provider: z.ZodString;
|
|
129
|
+
root: z.ZodString;
|
|
130
|
+
identityDigest: z.ZodType<`sha256:${string}`, unknown, z.core.$ZodTypeInternals<`sha256:${string}`, unknown>>;
|
|
131
|
+
}, z.core.$strict>;
|
|
132
|
+
export declare const agentWorkspaceLeaseRecordMaterialSchema: z.ZodType<AgentWorkspaceLeaseRecordMaterial>;
|
|
133
|
+
export declare const agentWorkspaceLeaseRecordSchema: z.ZodType<AgentWorkspaceLeaseRecord>;
|
|
134
|
+
/** Canonical public identity; private token/state fields cannot enter its schema. */
|
|
135
|
+
export declare function canonicalAgentWorkspaceLeaseRecordDigest(material: AgentWorkspaceLeaseRecordMaterial): Sha256Digest;
|
|
136
|
+
/** Build and self-hash one phase-valid public workspace lease record. */
|
|
137
|
+
export declare function buildAgentWorkspaceLeaseRecord<Material extends AgentWorkspaceLeaseRecordMaterial>(material: Material): WithDigest<Material>;
|
|
138
|
+
export {};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { canonicalCandidateDigest, isCanonicalJsonValue, isWellFormedUnicode, looksLikeCredential, omitTopLevelDigest, sha256DigestSchema, } from "./agent-candidate-schema-common.js";
|
|
3
|
+
export const AGENT_WORKSPACE_LEASE_PHASES = [
|
|
4
|
+
"copy-ready",
|
|
5
|
+
"workspace-sealed",
|
|
6
|
+
"execution-bound",
|
|
7
|
+
"destroying",
|
|
8
|
+
"cleanup-failed",
|
|
9
|
+
"destroyed",
|
|
10
|
+
];
|
|
11
|
+
const controlCharacterPattern = /[\u0000-\u001f\u007f]/;
|
|
12
|
+
const publicIdentifierSchema = z
|
|
13
|
+
.string()
|
|
14
|
+
.min(1)
|
|
15
|
+
.max(500)
|
|
16
|
+
.refine((value) => value.trim().length > 0 &&
|
|
17
|
+
isWellFormedUnicode(value) &&
|
|
18
|
+
!controlCharacterPattern.test(value) &&
|
|
19
|
+
!looksLikeCredential(value), "public workspace identity cannot carry credential-like material");
|
|
20
|
+
const publicLocatorSchema = z
|
|
21
|
+
.string()
|
|
22
|
+
.min(1)
|
|
23
|
+
.max(16_384)
|
|
24
|
+
.refine((value) => value.trim().length > 0 &&
|
|
25
|
+
isWellFormedUnicode(value) &&
|
|
26
|
+
!controlCharacterPattern.test(value) &&
|
|
27
|
+
!looksLikeCredential(value), "workspace locator must be public, well-formed text");
|
|
28
|
+
const publicCleanupErrorSchema = z
|
|
29
|
+
.string()
|
|
30
|
+
.min(1)
|
|
31
|
+
.max(2_000)
|
|
32
|
+
.refine((value) => value.trim().length > 0 &&
|
|
33
|
+
isWellFormedUnicode(value) &&
|
|
34
|
+
!controlCharacterPattern.test(value) &&
|
|
35
|
+
!looksLikeCredential(value), "workspace cleanup error must be sanitized public text");
|
|
36
|
+
const timestampSchema = z
|
|
37
|
+
.number()
|
|
38
|
+
.int()
|
|
39
|
+
.nonnegative()
|
|
40
|
+
.max(Number.MAX_SAFE_INTEGER);
|
|
41
|
+
export const agentWorkspaceLeasePhaseSchema = z.enum(AGENT_WORKSPACE_LEASE_PHASES);
|
|
42
|
+
export const agentWorkspaceSourceSnapshotPolicySchema = z.strictObject({
|
|
43
|
+
kind: z.literal("provider-declared"),
|
|
44
|
+
name: publicIdentifierSchema,
|
|
45
|
+
version: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
46
|
+
digest: sha256DigestSchema,
|
|
47
|
+
});
|
|
48
|
+
export const agentWorkspaceAllocationIdentitySchema = z.strictObject({
|
|
49
|
+
provider: publicIdentifierSchema,
|
|
50
|
+
root: publicLocatorSchema,
|
|
51
|
+
identityDigest: sha256DigestSchema,
|
|
52
|
+
});
|
|
53
|
+
const agentWorkspaceLeaseRecordFields = {
|
|
54
|
+
kind: z.literal("agent-workspace-lease"),
|
|
55
|
+
schemaVersion: z.literal(1),
|
|
56
|
+
phase: agentWorkspaceLeasePhaseSchema,
|
|
57
|
+
leaseId: publicIdentifierSchema,
|
|
58
|
+
ownerId: publicIdentifierSchema,
|
|
59
|
+
workspace: agentWorkspaceAllocationIdentitySchema,
|
|
60
|
+
isolation: z.enum(["per-run", "shared"]),
|
|
61
|
+
sourceSnapshotDigest: sha256DigestSchema,
|
|
62
|
+
sourceSnapshotPolicy: agentWorkspaceSourceSnapshotPolicySchema,
|
|
63
|
+
preparedWorkspaceDigest: sha256DigestSchema.optional(),
|
|
64
|
+
profileActivationDigest: sha256DigestSchema.optional(),
|
|
65
|
+
executionPreparationDigest: sha256DigestSchema.optional(),
|
|
66
|
+
createdAtMs: timestampSchema,
|
|
67
|
+
updatedAtMs: timestampSchema,
|
|
68
|
+
expiresAtMs: timestampSchema,
|
|
69
|
+
cleanupAttempts: z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
70
|
+
cleanupError: publicCleanupErrorSchema.optional(),
|
|
71
|
+
};
|
|
72
|
+
const rawAgentWorkspaceLeaseRecordMaterialSchema = z
|
|
73
|
+
.strictObject(agentWorkspaceLeaseRecordFields)
|
|
74
|
+
.superRefine((record, context) => {
|
|
75
|
+
validateAgentWorkspaceLeaseState(record, context);
|
|
76
|
+
if (!isCanonicalJsonValue(record)) {
|
|
77
|
+
context.addIssue({
|
|
78
|
+
code: "custom",
|
|
79
|
+
message: "workspace lease material must contain only RFC 8785 JSON values",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
.transform((record) => record);
|
|
84
|
+
export const agentWorkspaceLeaseRecordMaterialSchema = rawAgentWorkspaceLeaseRecordMaterialSchema;
|
|
85
|
+
export const agentWorkspaceLeaseRecordSchema = z
|
|
86
|
+
.strictObject({
|
|
87
|
+
...agentWorkspaceLeaseRecordFields,
|
|
88
|
+
digest: sha256DigestSchema,
|
|
89
|
+
})
|
|
90
|
+
.superRefine((record, context) => {
|
|
91
|
+
validateAgentWorkspaceLeaseState(record, context);
|
|
92
|
+
if (!isCanonicalJsonValue(record)) {
|
|
93
|
+
context.addIssue({
|
|
94
|
+
code: "custom",
|
|
95
|
+
message: "workspace lease record must contain only RFC 8785 JSON values",
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else if (canonicalCandidateDigest(omitTopLevelDigest(record)) !== record.digest) {
|
|
99
|
+
context.addIssue({
|
|
100
|
+
code: "custom",
|
|
101
|
+
path: ["digest"],
|
|
102
|
+
message: "workspace lease record digest is invalid",
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
.transform((record) => record);
|
|
107
|
+
/** Canonical public identity; private token/state fields cannot enter its schema. */
|
|
108
|
+
export function canonicalAgentWorkspaceLeaseRecordDigest(material) {
|
|
109
|
+
return canonicalCandidateDigest(agentWorkspaceLeaseRecordMaterialSchema.parse(material));
|
|
110
|
+
}
|
|
111
|
+
/** Build and self-hash one phase-valid public workspace lease record. */
|
|
112
|
+
export function buildAgentWorkspaceLeaseRecord(material) {
|
|
113
|
+
const parsed = agentWorkspaceLeaseRecordMaterialSchema.parse(material);
|
|
114
|
+
return agentWorkspaceLeaseRecordSchema.parse({
|
|
115
|
+
...parsed,
|
|
116
|
+
digest: canonicalCandidateDigest(parsed),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function validateAgentWorkspaceLeaseState(record, context) {
|
|
120
|
+
if (record.updatedAtMs < record.createdAtMs) {
|
|
121
|
+
context.addIssue({
|
|
122
|
+
code: "custom",
|
|
123
|
+
path: ["updatedAtMs"],
|
|
124
|
+
message: "workspace lease update cannot precede creation",
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (record.expiresAtMs <= record.createdAtMs) {
|
|
128
|
+
context.addIssue({
|
|
129
|
+
code: "custom",
|
|
130
|
+
path: ["expiresAtMs"],
|
|
131
|
+
message: "workspace lease expiry must follow creation",
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const hasPrepared = record.preparedWorkspaceDigest !== undefined;
|
|
135
|
+
const hasActivation = record.profileActivationDigest !== undefined;
|
|
136
|
+
const hasExecution = record.executionPreparationDigest !== undefined;
|
|
137
|
+
if (hasPrepared !== hasActivation) {
|
|
138
|
+
context.addIssue({
|
|
139
|
+
code: "custom",
|
|
140
|
+
message: "prepared workspace and profile activation evidence must appear together",
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
if (hasExecution && (!hasPrepared || !hasActivation)) {
|
|
144
|
+
context.addIssue({
|
|
145
|
+
code: "custom",
|
|
146
|
+
path: ["executionPreparationDigest"],
|
|
147
|
+
message: "execution binding requires sealed workspace evidence",
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const active = record.phase === "copy-ready" ||
|
|
151
|
+
record.phase === "workspace-sealed" ||
|
|
152
|
+
record.phase === "execution-bound";
|
|
153
|
+
if (active && record.cleanupAttempts !== 0) {
|
|
154
|
+
context.addIssue({
|
|
155
|
+
code: "custom",
|
|
156
|
+
path: ["cleanupAttempts"],
|
|
157
|
+
message: "active workspace phases cannot have cleanup attempts",
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
if (!active && record.cleanupAttempts < 1) {
|
|
161
|
+
context.addIssue({
|
|
162
|
+
code: "custom",
|
|
163
|
+
path: ["cleanupAttempts"],
|
|
164
|
+
message: "cleanup workspace phases require at least one cleanup attempt",
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
if (record.phase === "copy-ready" && (hasPrepared || hasExecution)) {
|
|
168
|
+
context.addIssue({
|
|
169
|
+
code: "custom",
|
|
170
|
+
message: "copy-ready workspace cannot carry preparation evidence",
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
if (record.phase === "workspace-sealed" &&
|
|
174
|
+
(!hasPrepared || !hasActivation || hasExecution)) {
|
|
175
|
+
context.addIssue({
|
|
176
|
+
code: "custom",
|
|
177
|
+
message: "workspace-sealed phase requires preparation evidence without execution binding",
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
if (record.phase === "execution-bound" &&
|
|
181
|
+
(!hasPrepared || !hasActivation || !hasExecution)) {
|
|
182
|
+
context.addIssue({
|
|
183
|
+
code: "custom",
|
|
184
|
+
message: "execution-bound phase requires complete preparation evidence",
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (record.phase === "cleanup-failed") {
|
|
188
|
+
if (record.cleanupError === undefined) {
|
|
189
|
+
context.addIssue({
|
|
190
|
+
code: "custom",
|
|
191
|
+
path: ["cleanupError"],
|
|
192
|
+
message: "cleanup-failed phase requires a sanitized error",
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
else if (record.cleanupError !== undefined) {
|
|
197
|
+
context.addIssue({
|
|
198
|
+
code: "custom",
|
|
199
|
+
path: ["cleanupError"],
|
|
200
|
+
message: "cleanup error is valid only in cleanup-failed phase",
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { REASONING_EFFORTS, } from "./agent-profile.js";
|
|
1
2
|
/**
|
|
2
3
|
* The unified harness capability layer — the single source of truth for:
|
|
3
4
|
* 1. harness ↔ model compatibility (which models a harness can run), and
|
|
@@ -15,15 +16,7 @@
|
|
|
15
16
|
* caller supplies.
|
|
16
17
|
*/
|
|
17
18
|
/** low → high. `none` = thinking off; `ultracode` = max (claude-code mode). */
|
|
18
|
-
export const reasoningLadder =
|
|
19
|
-
"none",
|
|
20
|
-
"minimal",
|
|
21
|
-
"low",
|
|
22
|
-
"medium",
|
|
23
|
-
"high",
|
|
24
|
-
"xhigh",
|
|
25
|
-
"ultracode",
|
|
26
|
-
];
|
|
19
|
+
export const reasoningLadder = REASONING_EFFORTS;
|
|
27
20
|
// ── Harness ↔ model compatibility ────────────────────────────────────────────
|
|
28
21
|
/**
|
|
29
22
|
* Provider prefixes a harness is vendor-locked to (canonical-id prefix, e.g. `anthropic`, `openai`).
|
package/dist/index.d.ts
CHANGED
|
@@ -623,6 +623,10 @@ export * from "./agent-profile-improvement.js";
|
|
|
623
623
|
export * from "./agent-profile-improvement-schema.js";
|
|
624
624
|
export * from "./agent-execution-limits.js";
|
|
625
625
|
export * from "./agent-profile.js";
|
|
626
|
+
export * from "./agent-profile-activation.js";
|
|
627
|
+
export * from "./agent-profile-materialization.js";
|
|
628
|
+
export * from "./agent-execution-preparation.js";
|
|
629
|
+
export * from "./agent-workspace-lease.js";
|
|
626
630
|
export * from "./certified-context.js";
|
|
627
631
|
export * from "./profile-diff.js";
|
|
628
632
|
export * from "./harness.js";
|
package/dist/index.js
CHANGED
|
@@ -135,6 +135,10 @@ export * from "./agent-profile-improvement.js";
|
|
|
135
135
|
export * from "./agent-profile-improvement-schema.js";
|
|
136
136
|
export * from "./agent-execution-limits.js";
|
|
137
137
|
export * from "./agent-profile.js";
|
|
138
|
+
export * from "./agent-profile-activation.js";
|
|
139
|
+
export * from "./agent-profile-materialization.js";
|
|
140
|
+
export * from "./agent-execution-preparation.js";
|
|
141
|
+
export * from "./agent-workspace-lease.js";
|
|
138
142
|
export * from "./certified-context.js";
|
|
139
143
|
export * from "./profile-diff.js";
|
|
140
144
|
export * from "./harness.js";
|
package/dist/profile-diff.d.ts
CHANGED
|
@@ -57,6 +57,17 @@ export interface AgentProfileDiff {
|
|
|
57
57
|
metadata?: Record<string, unknown>;
|
|
58
58
|
}
|
|
59
59
|
export declare function defineAgentProfileDiff<T extends AgentProfileDiff>(diff: T): T;
|
|
60
|
+
/**
|
|
61
|
+
* Construct deterministic ordered profile patches that reproduce `candidate`'s
|
|
62
|
+
* canonical profile value exactly when applied to `baseline`.
|
|
63
|
+
*
|
|
64
|
+
* Profile overlays append arrays and merge records, so changed fields are reset
|
|
65
|
+
* first and then replaced. Comparison and copied values follow the same
|
|
66
|
+
* undefined-entry normalization as profile identity. The returned values use
|
|
67
|
+
* the existing {@link AgentProfileDiff} contract; an unchanged profile returns
|
|
68
|
+
* no steps.
|
|
69
|
+
*/
|
|
70
|
+
export declare function diffAgentProfiles(baseline: AgentProfile, candidate: AgentProfile): AgentProfileDiff[];
|
|
60
71
|
export declare function applyAgentProfileDiff(base: AgentProfile, diff: AgentProfileDiff): AgentProfile;
|
|
61
72
|
export declare function changedAgentProfileAxes(diff: AgentProfileDiff): AgentProfileDiffAxis[];
|
|
62
73
|
export declare function pruneAgentProfileDiff(diff: AgentProfileDiff, axesToRemove: readonly AgentProfileDiffAxis[]): AgentProfileDiff;
|