@byok-sdk/protocol 0.30.2 → 0.32.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 +1 -1
- package/dist/agent-event.d.ts +2 -6
- package/dist/agent-memory.d.ts +79 -0
- package/dist/agent-memory.js +5 -0
- package/dist/agent-memory.js.map +1 -0
- package/dist/capability-constants.d.ts +9 -0
- package/dist/codec.d.ts +10 -86
- package/dist/constants.d.ts +14 -0
- package/dist/constants.js +2 -114
- package/dist/constants.js.map +1 -1
- package/dist/envelope.d.ts +1 -1
- package/dist/failure-reason.d.ts +23 -0
- package/dist/http-api.d.ts +74 -5
- package/dist/index.d.ts +7 -8
- package/dist/index.js +3 -3053
- package/dist/index.js.map +1 -1
- package/dist/input-preparation.d.ts +1 -1
- package/dist/messages.d.ts +1345 -1369
- package/dist/open-vocabulary.d.ts +5 -0
- package/dist/sealed-payload.d.ts +16 -14
- package/dist/sealed-split-table.d.ts +61 -55
- package/dist/version.d.ts +22 -54
- package/dist/wire-additions.d.ts +11 -7
- package/package.json +7 -4
- package/dist/task-assertion.d.ts +0 -28
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ decimal `profileRevision`, SHA-256 `profileHash`, `modelId`, and bounded
|
|
|
9
9
|
`requiredCapabilities`. Endpoint, auth configuration, and credential material
|
|
10
10
|
remain outside the protocol.
|
|
11
11
|
|
|
12
|
-
`
|
|
12
|
+
An Agent offer's `dispatchSelection` is the optional strict dual-lane target
|
|
13
13
|
contract: subscription selects Claude/Codex + model, while BYOK selects Pi +
|
|
14
14
|
provider + model. When present it is authoritative and runtime disagreement
|
|
15
15
|
fails closed. Servers send it only to a daemon advertising the
|
package/dist/agent-event.d.ts
CHANGED
|
@@ -122,9 +122,6 @@ export declare const AgentEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
122
122
|
type: z.ZodLiteral<"artifact">;
|
|
123
123
|
name: z.ZodString;
|
|
124
124
|
contentType: z.ZodString;
|
|
125
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
126
|
-
type: z.ZodLiteral<"needs_approval">;
|
|
127
|
-
summary: z.ZodString;
|
|
128
125
|
}, z.core.$strip>, z.ZodObject<{
|
|
129
126
|
type: z.ZodLiteral<"turn_end">;
|
|
130
127
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -143,6 +140,7 @@ export declare const AgentEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
143
140
|
estimate: "estimate";
|
|
144
141
|
provider: "provider";
|
|
145
142
|
}>>;
|
|
143
|
+
model: z.ZodOptional<z.ZodString>;
|
|
146
144
|
}, z.core.$strip>], "type">;
|
|
147
145
|
export type AgentEvent = z.infer<typeof AgentEventSchema>;
|
|
148
146
|
/**
|
|
@@ -264,9 +262,6 @@ export declare const AgentEventOrUnknownSchema: z.ZodUnion<readonly [z.ZodDiscri
|
|
|
264
262
|
type: z.ZodLiteral<"artifact">;
|
|
265
263
|
name: z.ZodString;
|
|
266
264
|
contentType: z.ZodString;
|
|
267
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
268
|
-
type: z.ZodLiteral<"needs_approval">;
|
|
269
|
-
summary: z.ZodString;
|
|
270
265
|
}, z.core.$strip>, z.ZodObject<{
|
|
271
266
|
type: z.ZodLiteral<"turn_end">;
|
|
272
267
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -285,6 +280,7 @@ export declare const AgentEventOrUnknownSchema: z.ZodUnion<readonly [z.ZodDiscri
|
|
|
285
280
|
estimate: "estimate";
|
|
286
281
|
provider: "provider";
|
|
287
282
|
}>>;
|
|
283
|
+
model: z.ZodOptional<z.ZodString>;
|
|
288
284
|
}, z.core.$strip>], "type">, z.ZodObject<{
|
|
289
285
|
type: z.ZodString;
|
|
290
286
|
}, z.core.$loose>]>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@byok-sdk/protocol/agent-memory` — the Host-side Agent memory contract that both
|
|
3
|
+
* `@byok-sdk/client` (the device) and `@byok-sdk/server/execution-core` (the Host)
|
|
4
|
+
* use: the file and export shapes, the model path policy, the Host transport and
|
|
5
|
+
* projection ports, and the memory error bases. It is zod-free so the embedded
|
|
6
|
+
* `@byok-sdk/client/agent-memory` entry stays schema-free, and it is its own entry
|
|
7
|
+
* so the error classes have one runtime definition.
|
|
8
|
+
*/
|
|
9
|
+
import type { AgentMemoryIntentCompletion, AgentMemoryIntentReservation } from './agent-memory-intent';
|
|
10
|
+
import type { AgentMemoryProjectionMutation } from './agent-memory-projection';
|
|
11
|
+
import type { AgentRef } from './messages';
|
|
12
|
+
export declare class AgentMemoryError extends Error {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Deterministic refusal: the same input against the same home state fails the
|
|
17
|
+
* same way on every retry (an invalid path, a forbidden delete, an oversized or
|
|
18
|
+
* non-UTF-8 file, a non-regular leaf, a platform without a secure backend).
|
|
19
|
+
*/
|
|
20
|
+
export declare class AgentMemoryValidationError extends AgentMemoryError {
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
export interface AgentMemoryFile {
|
|
24
|
+
readonly path: string;
|
|
25
|
+
readonly revision: string;
|
|
26
|
+
readonly byteCount: number;
|
|
27
|
+
readonly content: string;
|
|
28
|
+
}
|
|
29
|
+
export interface AgentMemorySnapshot {
|
|
30
|
+
readonly files: readonly AgentMemoryFile[];
|
|
31
|
+
readonly totalBytes: number;
|
|
32
|
+
}
|
|
33
|
+
/** Raw local-only Host result. Never send this through the redacted projection port. */
|
|
34
|
+
export interface AgentMemoryExport extends AgentMemorySnapshot {
|
|
35
|
+
/** Validated Host request, not proof of a globally current profile revision. */
|
|
36
|
+
readonly requestedAgentRef: AgentRef;
|
|
37
|
+
/** Present only when the home has a durable applied profile projection. */
|
|
38
|
+
readonly appliedProfileRevision?: string;
|
|
39
|
+
/** sha256 of UTF-8 JSON ["byok-agent-memory-export.v1", [[path, revision, byteCount], ...]]. */
|
|
40
|
+
readonly snapshotDigest: string;
|
|
41
|
+
}
|
|
42
|
+
/** Model input can name one allowed file, never a root, directory, glob, or internal SDK state. */
|
|
43
|
+
export declare function validateAgentMemoryPath(value: unknown): string;
|
|
44
|
+
/** Exactly what the daemon hands the Host transport for one fetch. */
|
|
45
|
+
export interface AgentMemoryIntentFetchInput {
|
|
46
|
+
readonly intentId: string;
|
|
47
|
+
readonly agentRef: AgentRef;
|
|
48
|
+
/** `held`: a ledger slot is reserved; `none`: the Host must not release or change state. */
|
|
49
|
+
readonly reservation: AgentMemoryIntentReservation;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Host-injected transport for Host-approved Agent memory intents. The Host
|
|
53
|
+
* authenticates the device on its own routes; the SDK never sees an assertion.
|
|
54
|
+
*
|
|
55
|
+
* - `fetch` resolves with the Host's fetch answer (release / withheld /
|
|
56
|
+
* terminal / deferred) for exactly this intent and reservation.
|
|
57
|
+
* - `complete` delivers one terminal completion and resolves with the Host's
|
|
58
|
+
* DURABLE readback for it.
|
|
59
|
+
*
|
|
60
|
+
* Both answers are copied into inert plain data and strictly parsed. A throw
|
|
61
|
+
* from either is a transport failure: the notice is not acknowledged and a
|
|
62
|
+
* redelivery retries. Neither is ever called while the Agent home is leased.
|
|
63
|
+
*/
|
|
64
|
+
export interface AgentMemoryIntentTransport {
|
|
65
|
+
fetch(request: AgentMemoryIntentFetchInput): Promise<unknown>;
|
|
66
|
+
complete(completion: AgentMemoryIntentCompletion): Promise<unknown>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Optional bridge to a complete hosted client. It receives the canonical,
|
|
70
|
+
* already-redacted protocol mutation only; the SDK intentionally owns no
|
|
71
|
+
* consent, cloud transport, or raw-source upload fallback.
|
|
72
|
+
*/
|
|
73
|
+
export interface AgentMemoryProjectionPort {
|
|
74
|
+
publish(input: Readonly<{
|
|
75
|
+
mutation: AgentMemoryProjectionMutation;
|
|
76
|
+
}>): Promise<{
|
|
77
|
+
readonly accepted: boolean;
|
|
78
|
+
}>;
|
|
79
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var AgentMemoryError=class extends Error{constructor(message){super(message);this.name="AgentMemoryError";}};var AgentMemoryValidationError=class extends AgentMemoryError{constructor(message){super(message);this.name="AgentMemoryValidationError";}};var SAFE_SEGMENT=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u;var WINDOWS_ALIAS=/^(?:con|prn|aux|nul|com\d|lpt\d)(?:\.|$)|\.$/iu;var SECRET_LIKE=/(?:^|[-_.])(secret|token|credential|password|passwd|api[-_]?key|private[-_]?key|cookie)(?:$|[-_.])/iu;function safeSegment(value){return SAFE_SEGMENT.test(value)&&!WINDOWS_ALIAS.test(value)}function validateAgentMemoryPath(value){if(typeof value!=="string"||value.length===0||value.length>1024||/[\u0000\\]/u.test(value))throw new AgentMemoryValidationError("memory path is invalid");if(value==="MEMORY.md")return value;if(value.startsWith("/")||/[*?\[{]/u.test(value))throw new AgentMemoryValidationError("memory path must name exactly one file");const parts=value.split("/");if(parts.length<2||parts[0]!=="notes"||!value.endsWith(".md")||parts.some(part=>part===""||part==="."||part===".."||part===".byok"||!safeSegment(part)||SECRET_LIKE.test(part))){throw new AgentMemoryValidationError("memory path must be MEMORY.md or notes/<safe-relative>.md")}return value}
|
|
2
|
+
|
|
3
|
+
export { AgentMemoryError, AgentMemoryValidationError, validateAgentMemoryPath };
|
|
4
|
+
//# sourceMappingURL=agent-memory.js.map
|
|
5
|
+
//# sourceMappingURL=agent-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agent-memory.ts"],"names":[],"mappings":"AAYO,IAAM,gBAAA,CAAN,cAA+B,KAAM,CAC1C,YAAY,OAAA,CAAiB,CAAE,KAAA,CAAM,OAAO,CAAA,CAAG,IAAA,CAAK,IAAA,CAAO,mBAAoB,CACjF,EAMO,IAAM,0BAAA,CAAN,cAAyC,gBAAiB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— the Host-side Agent memory contract that both\n * `@byok-sdk/client` (the device) and `@byok-sdk/server/execution-core` (the Host)\n * use: the file and export shapes, the model path policy, the Host transport and\n * projection ports, and the memory error bases. It is zod-free so the embedded\n * `@byok-sdk/client/agent-memory` entry stays schema-free, and it is its own entry\n * so the error classes have one runtime definition.\n */\nimport type { AgentMemoryIntentCompletion, AgentMemoryIntentReservation } from './agent-memory-intent';\nimport type { AgentMemoryProjectionMutation } from './agent-memory-projection';\nimport type { AgentRef } from './messages';\n\nexport class AgentMemoryError extends Error {\n constructor(message: string) { super(message); this.name = 'AgentMemoryError'; }\n}\n/**\n * Deterministic refusal: the same input against the same home state fails the\n * same way on every retry (an invalid path, a forbidden delete, an oversized or\n * non-UTF-8 file, a non-regular leaf, a platform without a secure backend).\n */\nexport class AgentMemoryValidationError extends AgentMemoryError {\n constructor(message: string) { super(message); this.name = 'AgentMemoryValidationError'; }\n}\n\nexport interface AgentMemoryFile { readonly path: string; readonly revision: string; readonly byteCount: number; readonly content: string; }\nexport interface AgentMemorySnapshot { readonly files: readonly AgentMemoryFile[]; readonly totalBytes: number; }\n\n/** Raw local-only Host result. Never send this through the redacted projection port. */\nexport interface AgentMemoryExport extends AgentMemorySnapshot {\n /** Validated Host request, not proof of a globally current profile revision. */\n readonly requestedAgentRef: AgentRef;\n /** Present only when the home has a durable applied profile projection. */\n readonly appliedProfileRevision?: string;\n /** sha256 of UTF-8 JSON [\"byok-agent-memory-export.v1\", [[path, revision, byteCount], ...]]. */\n readonly snapshotDigest: string;\n}\n\nconst SAFE_SEGMENT = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u;\n// Windows maps a device name, with or without an extension, and a name that\n// ends in a dot to another name. Every platform refuses them.\nconst WINDOWS_ALIAS = /^(?:con|prn|aux|nul|com\\d|lpt\\d)(?:\\.|$)|\\.$/iu;\nconst SECRET_LIKE = /(?:^|[-_.])(secret|token|credential|password|passwd|api[-_]?key|private[-_]?key|cookie)(?:$|[-_.])/iu;\nfunction safeSegment(value: string): boolean { return SAFE_SEGMENT.test(value) && !WINDOWS_ALIAS.test(value); }\n\n/** Model input can name one allowed file, never a root, directory, glob, or internal SDK state. */\nexport function validateAgentMemoryPath(value: unknown): string {\n if (typeof value !== 'string' || value.length === 0 || value.length > 1024 || /[\\u0000\\\\]/u.test(value)) throw new AgentMemoryValidationError('memory path is invalid');\n if (value === 'MEMORY.md') return value;\n // POSIX absoluteness is exactly a leading '/'; backslashes were refused above.\n if (value.startsWith('/') || /[*?\\[{]/u.test(value)) throw new AgentMemoryValidationError('memory path must name exactly one file');\n const parts = value.split('/');\n if (parts.length < 2 || parts[0] !== 'notes' || !value.endsWith('.md') || parts.some((part) => part === '' || part === '.' || part === '..' || part === '.byok' || !safeSegment(part) || SECRET_LIKE.test(part))) {\n throw new AgentMemoryValidationError('memory path must be MEMORY.md or notes/<safe-relative>.md');\n }\n return value;\n}\n\n/** Exactly what the daemon hands the Host transport for one fetch. */\nexport interface AgentMemoryIntentFetchInput {\n readonly intentId: string;\n readonly agentRef: AgentRef;\n /** `held`: a ledger slot is reserved; `none`: the Host must not release or change state. */\n readonly reservation: AgentMemoryIntentReservation;\n}\n\n/**\n * Host-injected transport for Host-approved Agent memory intents. The Host\n * authenticates the device on its own routes; the SDK never sees an assertion.\n *\n * - `fetch` resolves with the Host's fetch answer (release / withheld /\n * terminal / deferred) for exactly this intent and reservation.\n * - `complete` delivers one terminal completion and resolves with the Host's\n * DURABLE readback for it.\n *\n * Both answers are copied into inert plain data and strictly parsed. A throw\n * from either is a transport failure: the notice is not acknowledged and a\n * redelivery retries. Neither is ever called while the Agent home is leased.\n */\nexport interface AgentMemoryIntentTransport {\n fetch(request: AgentMemoryIntentFetchInput): Promise<unknown>;\n complete(completion: AgentMemoryIntentCompletion): Promise<unknown>;\n}\n\n/**\n * Optional bridge to a complete hosted client. It receives the canonical,\n * already-redacted protocol mutation only; the SDK intentionally owns no\n * consent, cloud transport, or raw-source upload fallback.\n */\nexport interface AgentMemoryProjectionPort {\n publish(input: Readonly<{ mutation: AgentMemoryProjectionMutation }>): Promise<{ readonly accepted: boolean }>;\n}\n"]}
|
|
@@ -60,6 +60,15 @@ export declare const SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY: 'sealed-output-cip
|
|
|
60
60
|
* machine-readable runtime failure class (#869).
|
|
61
61
|
*/
|
|
62
62
|
export declare const RUNTIME_FAILURE_CLASS_CAPABILITY: 'runtime-failure-class';
|
|
63
|
+
/**
|
|
64
|
+
* The connection understands the typed pre-claim runtime-unavailable cause
|
|
65
|
+
* (#1103 D8): `task.decline.runtimeUnavailable`, `conn.hello.runtimeUnavailable`
|
|
66
|
+
* and the presence projection. A daemon declares it when it emits the cause.
|
|
67
|
+
* Older peers ignore the unknown flag; absence means the peer may not read
|
|
68
|
+
* the cause, so a Host falls back to `retryable` and treats the cause as
|
|
69
|
+
* unknown. It never infers availability or allow from absence.
|
|
70
|
+
*/
|
|
71
|
+
export declare const RUNTIME_UNAVAILABLE_CAUSE_CAPABILITY: 'runtime-unavailable-cause';
|
|
63
72
|
/**
|
|
64
73
|
* The closed classes of `task.fail.failure.class`: the vendored OAR
|
|
65
74
|
* `FailureClass` values. `unknown` means the runtime gave no structured
|
package/dist/codec.d.ts
CHANGED
|
@@ -22,50 +22,14 @@ interface EnvelopeShapeOptions {
|
|
|
22
22
|
taskId?: string;
|
|
23
23
|
seq?: number;
|
|
24
24
|
};
|
|
25
|
-
'conn.ack': {
|
|
26
|
-
taskId?: string;
|
|
27
|
-
seq: number;
|
|
28
|
-
};
|
|
29
25
|
'task.offer': {
|
|
30
26
|
taskId: string;
|
|
31
27
|
seq: number;
|
|
32
28
|
};
|
|
33
|
-
'task.offer_with_toolsets': {
|
|
34
|
-
taskId: string;
|
|
35
|
-
seq: number;
|
|
36
|
-
};
|
|
37
|
-
'task.offer_for_agent': {
|
|
38
|
-
taskId: string;
|
|
39
|
-
seq: number;
|
|
40
|
-
};
|
|
41
|
-
'task.offer_for_agent_with_egress': {
|
|
42
|
-
taskId: string;
|
|
43
|
-
seq: number;
|
|
44
|
-
};
|
|
45
|
-
'task.offer_for_agent_with_egress_fresh': {
|
|
46
|
-
taskId: string;
|
|
47
|
-
seq: number;
|
|
48
|
-
};
|
|
49
|
-
'task.offer_prepared': {
|
|
50
|
-
taskId: string;
|
|
51
|
-
seq: number;
|
|
52
|
-
};
|
|
53
|
-
'agent.egress.reliable': {
|
|
54
|
-
taskId?: string;
|
|
55
|
-
seq?: number;
|
|
56
|
-
};
|
|
57
29
|
'agent.egress.ack': {
|
|
58
30
|
taskId?: string;
|
|
59
31
|
seq: number;
|
|
60
32
|
};
|
|
61
|
-
'agent.message.draft': {
|
|
62
|
-
taskId: string;
|
|
63
|
-
seq?: number;
|
|
64
|
-
};
|
|
65
|
-
'agent.message.publish': {
|
|
66
|
-
taskId: string;
|
|
67
|
-
seq?: number;
|
|
68
|
-
};
|
|
69
33
|
'agent.message.disposition': {
|
|
70
34
|
taskId: string;
|
|
71
35
|
seq: number;
|
|
@@ -90,14 +54,6 @@ interface EnvelopeShapeOptions {
|
|
|
90
54
|
taskId?: never;
|
|
91
55
|
seq: number;
|
|
92
56
|
};
|
|
93
|
-
'e2ee.key_package.available': {
|
|
94
|
-
taskId?: never;
|
|
95
|
-
seq: number;
|
|
96
|
-
};
|
|
97
|
-
'agent.content.receipt': {
|
|
98
|
-
taskId?: string;
|
|
99
|
-
seq?: number;
|
|
100
|
-
};
|
|
101
57
|
'task.approve': {
|
|
102
58
|
taskId: string;
|
|
103
59
|
seq: number;
|
|
@@ -114,6 +70,10 @@ interface EnvelopeShapeOptions {
|
|
|
114
70
|
taskId: string;
|
|
115
71
|
seq: number;
|
|
116
72
|
};
|
|
73
|
+
'e2ee.key_package.available': {
|
|
74
|
+
taskId?: never;
|
|
75
|
+
seq: number;
|
|
76
|
+
};
|
|
117
77
|
'task.claim': {
|
|
118
78
|
taskId: string;
|
|
119
79
|
seq?: number;
|
|
@@ -154,56 +114,20 @@ interface EnvelopeShapeOptions {
|
|
|
154
114
|
taskId: string;
|
|
155
115
|
seq?: number;
|
|
156
116
|
};
|
|
157
|
-
'
|
|
158
|
-
taskId
|
|
159
|
-
seq: number;
|
|
160
|
-
};
|
|
161
|
-
'task.offer_with_toolsets_sealed': {
|
|
162
|
-
taskId: string;
|
|
163
|
-
seq: number;
|
|
164
|
-
};
|
|
165
|
-
'task.offer_for_agent_sealed': {
|
|
166
|
-
taskId: string;
|
|
167
|
-
seq: number;
|
|
168
|
-
};
|
|
169
|
-
'task.offer_for_agent_with_egress_sealed': {
|
|
170
|
-
taskId: string;
|
|
171
|
-
seq: number;
|
|
172
|
-
};
|
|
173
|
-
'task.offer_for_agent_with_egress_fresh_sealed': {
|
|
174
|
-
taskId: string;
|
|
175
|
-
seq: number;
|
|
176
|
-
};
|
|
177
|
-
'task.steer_sealed': {
|
|
178
|
-
taskId: string;
|
|
179
|
-
seq: number;
|
|
180
|
-
};
|
|
181
|
-
'task.complete_sealed': {
|
|
182
|
-
taskId: string;
|
|
183
|
-
seq?: number;
|
|
184
|
-
};
|
|
185
|
-
'task.fail_sealed': {
|
|
186
|
-
taskId: string;
|
|
187
|
-
seq?: number;
|
|
188
|
-
};
|
|
189
|
-
'task.decline_sealed': {
|
|
190
|
-
taskId: string;
|
|
191
|
-
seq?: number;
|
|
192
|
-
};
|
|
193
|
-
'task.cancelled_sealed': {
|
|
194
|
-
taskId: string;
|
|
117
|
+
'agent.egress.reliable': {
|
|
118
|
+
taskId?: string;
|
|
195
119
|
seq?: number;
|
|
196
120
|
};
|
|
197
|
-
'
|
|
121
|
+
'agent.message.draft': {
|
|
198
122
|
taskId: string;
|
|
199
123
|
seq?: number;
|
|
200
124
|
};
|
|
201
|
-
'
|
|
125
|
+
'agent.message.publish': {
|
|
202
126
|
taskId: string;
|
|
203
127
|
seq?: number;
|
|
204
128
|
};
|
|
205
|
-
'
|
|
206
|
-
taskId
|
|
129
|
+
'agent.content.receipt': {
|
|
130
|
+
taskId?: string;
|
|
207
131
|
seq?: number;
|
|
208
132
|
};
|
|
209
133
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -2,9 +2,23 @@
|
|
|
2
2
|
export * from './version';
|
|
3
3
|
export * from './task-state';
|
|
4
4
|
export * from './capability-constants';
|
|
5
|
+
export * from './failure-reason';
|
|
5
6
|
/** Maximum raw UTF-8 content bytes in one local Host Agent-memory export; no truncation. */
|
|
6
7
|
export declare const AGENT_MEMORY_MAX_SNAPSHOT_BYTES: number;
|
|
7
8
|
/** Maximum memory files in one local Host export, including MEMORY.md. */
|
|
8
9
|
export declare const AGENT_MEMORY_MAX_SNAPSHOT_FILES = 128;
|
|
9
10
|
/** The frozen wire runtime ids. Any other adapter id is a custom harness (`harnessId`). */
|
|
10
11
|
export declare const RUNTIME_IDS: readonly ["pi", "claude", "codex"];
|
|
12
|
+
/**
|
|
13
|
+
* Why a runtime is unavailable before claim (#1103 D6). Append-only: a cause is
|
|
14
|
+
* never renamed, removed or given a new meaning. The wire reads an unknown
|
|
15
|
+
* well-formed token as `unknown` and keeps it verbatim (#1121), so a newer
|
|
16
|
+
* device can add one without a protocol bump. Names are snake_case, unlike the
|
|
17
|
+
* kebab-case detection kinds, because the mapping is explicit and never a
|
|
18
|
+
* string transformation.
|
|
19
|
+
*/
|
|
20
|
+
export declare const RUNTIME_UNAVAILABLE_CAUSES: readonly ["not_installed", "not_executable", "probe_timeout", "probe_failed", "app_server_unavailable", "acp_unavailable", "platform_unsupported", "environment_unavailable", "version_blocked", "runtime_not_configured", "runtime_not_allowed", "none_available"];
|
|
21
|
+
/** One append-only `runtime_unavailable` cause. */
|
|
22
|
+
export type RuntimeUnavailableCause = (typeof RUNTIME_UNAVAILABLE_CAUSES)[number];
|
|
23
|
+
/** Maximum length of a served model name. */
|
|
24
|
+
export declare const TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH = 160;
|
package/dist/constants.js
CHANGED
|
@@ -1,117 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
var INPUT_PREPARATION_WIRE_VERSION = 9;
|
|
3
|
-
var AGENT_EGRESS_POLICY_CAPABILITY = "agent-egress-policy";
|
|
4
|
-
var AGENT_EGRESS_RELIABLE_ACK_CAPABILITY = "agent-egress-reliable-ack";
|
|
5
|
-
var AGENT_EGRESS_FRESH_SESSION_CAPABILITY = "agent-egress-fresh-session";
|
|
6
|
-
var AGENT_MESSAGE_EGRESS_CAPABILITY = "agent-message-egress";
|
|
7
|
-
var AGENT_CONTENT_WORKSPACE_READ_CAPABILITY = "agent-content-workspace-read";
|
|
8
|
-
var AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY = "agent-content-transcript-read";
|
|
9
|
-
var AGENT_CONTENT_ARTIFACT_READ_CAPABILITY = "agent-content-artifact-read";
|
|
10
|
-
var AGENT_HOME_PROJECTION_CAPABILITY = "agent-home-projection";
|
|
11
|
-
var TERMINAL_PROJECTION_SELECTION_CAPABILITY = "terminal-projection-selection";
|
|
12
|
-
var HOST_MCP_TASK_CONTEXT_CAPABILITY = "host-mcp-task-context";
|
|
13
|
-
var PROVIDER_PROFILE_BINDING_CAPABILITY = "provider-profile-binding";
|
|
14
|
-
var PROVIDER_PROVISIONING_CAPABILITY = "provider-provisioning.v1";
|
|
15
|
-
var AGENT_MEMORY_INTENT_CAPABILITY = "agent-memory-intent.v1";
|
|
16
|
-
var AGENT_MEMORY_PROJECTION_CAPABILITY = "agent.memory.projection";
|
|
17
|
-
var AGENT_MEMORY_SELECTION_CAPABILITY = "agent-memory-selection";
|
|
18
|
-
var AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY = "agent-memory-read-if-admitted";
|
|
19
|
-
var AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY = "agent-memory-read-write-if-admitted";
|
|
20
|
-
var AGENT_INPUT_PREPARATION_CAPABILITY = `agent-input-preparation-v${INPUT_PREPARATION_WIRE_VERSION}`;
|
|
21
|
-
var SEALED_PAYLOAD_CAPABILITY = "sealed-payload-v1";
|
|
22
|
-
var SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY = "sealed-output-ciphertext-ref";
|
|
23
|
-
var RUNTIME_FAILURE_CLASS_CAPABILITY = "runtime-failure-class";
|
|
24
|
-
var RUNTIME_FAILURE_CLASSES = [
|
|
25
|
-
"auth",
|
|
26
|
-
"quota",
|
|
27
|
-
"rate_limited",
|
|
28
|
-
"billing",
|
|
29
|
-
"model_unavailable",
|
|
30
|
-
"input_too_large",
|
|
31
|
-
"invalid_request",
|
|
32
|
-
"overloaded",
|
|
33
|
-
"provider",
|
|
34
|
-
"runtime_exited",
|
|
35
|
-
"limit_reached",
|
|
36
|
-
"output_schema",
|
|
37
|
-
"unknown"
|
|
38
|
-
];
|
|
39
|
-
var PREPARED_AGENT_MEMORY_MODES = ["none", "read", "read-write"];
|
|
40
|
-
function isPreparedAgentMemoryMode(value) {
|
|
41
|
-
return typeof value === "string" && PREPARED_AGENT_MEMORY_MODES.some((mode) => mode === value);
|
|
42
|
-
}
|
|
1
|
+
var INPUT_PREPARATION_WIRE_VERSION=9;var AGENT_EGRESS_POLICY_CAPABILITY="agent-egress-policy";var AGENT_EGRESS_RELIABLE_ACK_CAPABILITY="agent-egress-reliable-ack";var AGENT_EGRESS_FRESH_SESSION_CAPABILITY="agent-egress-fresh-session";var AGENT_MESSAGE_EGRESS_CAPABILITY="agent-message-egress";var AGENT_CONTENT_WORKSPACE_READ_CAPABILITY="agent-content-workspace-read";var AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY="agent-content-transcript-read";var AGENT_CONTENT_ARTIFACT_READ_CAPABILITY="agent-content-artifact-read";var AGENT_HOME_PROJECTION_CAPABILITY="agent-home-projection";var TERMINAL_PROJECTION_SELECTION_CAPABILITY="terminal-projection-selection";var HOST_MCP_TASK_CONTEXT_CAPABILITY="host-mcp-task-context";var PROVIDER_PROFILE_BINDING_CAPABILITY="provider-profile-binding";var PROVIDER_PROVISIONING_CAPABILITY="provider-provisioning.v1";var AGENT_MEMORY_INTENT_CAPABILITY="agent-memory-intent.v1";var AGENT_MEMORY_PROJECTION_CAPABILITY="agent.memory.projection";var AGENT_MEMORY_SELECTION_CAPABILITY="agent-memory-selection";var AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY="agent-memory-read-if-admitted";var AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY="agent-memory-read-write-if-admitted";var AGENT_INPUT_PREPARATION_CAPABILITY=`agent-input-preparation-v${INPUT_PREPARATION_WIRE_VERSION}`;var SEALED_PAYLOAD_CAPABILITY="sealed-payload-v1";var SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY="sealed-output-ciphertext-ref";var RUNTIME_FAILURE_CLASS_CAPABILITY="runtime-failure-class";var RUNTIME_UNAVAILABLE_CAUSE_CAPABILITY="runtime-unavailable-cause";var RUNTIME_FAILURE_CLASSES=["auth","quota","rate_limited","billing","model_unavailable","input_too_large","invalid_request","overloaded","provider","runtime_exited","limit_reached","output_schema","unknown"];var PREPARED_AGENT_MEMORY_MODES=["none","read","read-write"];function isPreparedAgentMemoryMode(value){return typeof value==="string"&&PREPARED_AGENT_MEMORY_MODES.some(mode=>mode===value)}var MAILBOX_READ_AHEAD_MAX_SEQS=4096;var MAILBOX_READ_AHEAD_CAPABILITY="mailbox-read-ahead";var PROTOCOL_VERSION=4;var AGENT_HOME_READERS_CAPABILITY="agent-home-readers";var CUSTOM_HARNESS_CAPABILITY="custom-harness";var CAPABILITY_FLAGS=["steer","blob-upload","dispatch-selection",PROVIDER_PROFILE_BINDING_CAPABILITY,"toolset-selection","agent-home-contract",AGENT_HOME_READERS_CAPABILITY,AGENT_EGRESS_POLICY_CAPABILITY,AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,AGENT_MESSAGE_EGRESS_CAPABILITY,AGENT_EGRESS_FRESH_SESSION_CAPABILITY,AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,AGENT_HOME_PROJECTION_CAPABILITY,AGENT_INPUT_PREPARATION_CAPABILITY,TERMINAL_PROJECTION_SELECTION_CAPABILITY,HOST_MCP_TASK_CONTEXT_CAPABILITY,CUSTOM_HARNESS_CAPABILITY,MAILBOX_READ_AHEAD_CAPABILITY,PROVIDER_PROVISIONING_CAPABILITY,AGENT_MEMORY_INTENT_CAPABILITY,AGENT_MEMORY_SELECTION_CAPABILITY,AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY,AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY,"agent-message-draft",SEALED_PAYLOAD_CAPABILITY,SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY,RUNTIME_FAILURE_CLASS_CAPABILITY,RUNTIME_UNAVAILABLE_CAUSE_CAPABILITY];var TASK_STATES=["Offered","Claimed","Running","AwaitApproval","Complete","Failed","Cancelled"];var TASK_TRANSITIONS={Offered:["Claimed","Cancelled","Failed"],Claimed:["Running","Failed","Cancelled"],Running:["AwaitApproval","Complete","Failed","Cancelled"],AwaitApproval:["Running","Failed","Cancelled"],Complete:[],Failed:[],Cancelled:[]};function canTransition(from,to){return TASK_TRANSITIONS[from].includes(to)}var TASK_FAIL_REASON_MAX_BYTES=2048;var REDACTED="[redacted]";var VALUE=String.raw`(?:"(?:\\[^\n]|[^"\\\n])*(?:\\)?"?|'(?:\\[^\n]|[^'\\\n])*(?:\\)?'?|[^\s"'\[\u2026,;&|][^\s"',;&|]*)`;var GAP="[ \\t]{0,16}";var RULES=[[new RegExp(String.raw`\b((?:proxy-)?authorization)(["']?${GAP}[:=]${GAP})(?:(?:bearer|basic|token|digest)[ \t]{1,16})?${VALUE}`,"gi"),`$1$2${REDACTED}`],[/\b(bearer)[ \t]{1,16}[A-Za-z0-9._~+/=-]{8,}/gi,`$1 ${REDACTED}`],[new RegExp(String.raw`(key|token|secret|passw(?:or)?d[\w.-]{0,64})(["']?${GAP}[:=]${GAP})${VALUE}`,"gi"),`$1$2${REDACTED}`],[/:\/\/[^\s/?#@]{1,256}@/g,`://${REDACTED}@`],[/\bsk-[A-Za-z0-9_-]{16,}/g,REDACTED],[/\bxai-[A-Za-z0-9_-]{16,}/g,REDACTED],[/\bAIza[0-9A-Za-z_-]{30,}/g,REDACTED],[/\bgh[pousr]_[A-Za-z0-9]{20,}/g,REDACTED],[/\bgithub_pat_[A-Za-z0-9_]{20,}/g,REDACTED],[/\bAKIA[0-9A-Z]{16}/g,REDACTED],[/\beyJ[A-Za-z0-9_-]{10,}(?:\.[A-Za-z0-9_-]*){0,2}/g,REDACTED]];var encoder=new TextEncoder;var decoder=new TextDecoder("utf-8");function redact(text){let out=text;for(const[pattern,replacement]of RULES)out=out.replace(pattern,replacement);return out}function boundFailureReason(reason){const redacted=redact(reason);const bytes=encoder.encode(redacted);if(bytes.length<=TASK_FAIL_REASON_MAX_BYTES)return redacted;let keep=TASK_FAIL_REASON_MAX_BYTES-encoder.encode(`\u2026[truncated ${bytes.length} bytes]`).length;while(keep>0&&((bytes[keep]??0)&192)===128)keep-=1;return `${decoder.decode(bytes.subarray(0,keep))}\u2026[truncated ${bytes.length-keep} bytes]`}var AGENT_MEMORY_MAX_SNAPSHOT_BYTES=1024*1024;var AGENT_MEMORY_MAX_SNAPSHOT_FILES=128;var RUNTIME_IDS=Object.freeze(["pi","claude","codex"]);var RUNTIME_UNAVAILABLE_CAUSES=Object.freeze(["not_installed","not_executable","probe_timeout","probe_failed","app_server_unavailable","acp_unavailable","platform_unsupported","environment_unavailable","version_blocked","runtime_not_configured","runtime_not_allowed","none_available"]);var TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH=160;
|
|
43
2
|
|
|
44
|
-
|
|
45
|
-
var MAILBOX_READ_AHEAD_MAX_SEQS = 4096;
|
|
46
|
-
var MAILBOX_READ_AHEAD_CAPABILITY = "mailbox-read-ahead";
|
|
47
|
-
var PROTOCOL_VERSION = 3;
|
|
48
|
-
var STRICT_AGENT_ONLY_CAPABILITY = "strict-agent-only";
|
|
49
|
-
var AGENT_HOME_READERS_CAPABILITY = "agent-home-readers";
|
|
50
|
-
var CUSTOM_HARNESS_CAPABILITY = "custom-harness";
|
|
51
|
-
var CAPABILITY_FLAGS = [
|
|
52
|
-
"steer",
|
|
53
|
-
"blob-upload",
|
|
54
|
-
"interactive-approval",
|
|
55
|
-
"approval_resolved",
|
|
56
|
-
"approval-targeting",
|
|
57
|
-
"dispatch-selection",
|
|
58
|
-
PROVIDER_PROFILE_BINDING_CAPABILITY,
|
|
59
|
-
"toolset-selection",
|
|
60
|
-
"agent-home-contract",
|
|
61
|
-
AGENT_HOME_READERS_CAPABILITY,
|
|
62
|
-
STRICT_AGENT_ONLY_CAPABILITY,
|
|
63
|
-
AGENT_EGRESS_POLICY_CAPABILITY,
|
|
64
|
-
AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,
|
|
65
|
-
AGENT_MESSAGE_EGRESS_CAPABILITY,
|
|
66
|
-
AGENT_EGRESS_FRESH_SESSION_CAPABILITY,
|
|
67
|
-
AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,
|
|
68
|
-
AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,
|
|
69
|
-
AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,
|
|
70
|
-
AGENT_HOME_PROJECTION_CAPABILITY,
|
|
71
|
-
AGENT_INPUT_PREPARATION_CAPABILITY,
|
|
72
|
-
TERMINAL_PROJECTION_SELECTION_CAPABILITY,
|
|
73
|
-
HOST_MCP_TASK_CONTEXT_CAPABILITY,
|
|
74
|
-
CUSTOM_HARNESS_CAPABILITY,
|
|
75
|
-
MAILBOX_READ_AHEAD_CAPABILITY,
|
|
76
|
-
PROVIDER_PROVISIONING_CAPABILITY,
|
|
77
|
-
AGENT_MEMORY_INTENT_CAPABILITY,
|
|
78
|
-
AGENT_MEMORY_SELECTION_CAPABILITY,
|
|
79
|
-
AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY,
|
|
80
|
-
AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY,
|
|
81
|
-
"agent-message-draft",
|
|
82
|
-
SEALED_PAYLOAD_CAPABILITY,
|
|
83
|
-
SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY,
|
|
84
|
-
RUNTIME_FAILURE_CLASS_CAPABILITY
|
|
85
|
-
];
|
|
86
|
-
|
|
87
|
-
// src/task-state.ts
|
|
88
|
-
var TASK_STATES = [
|
|
89
|
-
"Offered",
|
|
90
|
-
"Claimed",
|
|
91
|
-
"Running",
|
|
92
|
-
"AwaitApproval",
|
|
93
|
-
"Complete",
|
|
94
|
-
"Failed",
|
|
95
|
-
"Cancelled"
|
|
96
|
-
];
|
|
97
|
-
var TASK_TRANSITIONS = {
|
|
98
|
-
Offered: ["Claimed", "Cancelled", "Failed"],
|
|
99
|
-
Claimed: ["Running", "Failed", "Cancelled"],
|
|
100
|
-
Running: ["AwaitApproval", "Complete", "Failed", "Cancelled"],
|
|
101
|
-
AwaitApproval: ["Running", "Failed", "Cancelled"],
|
|
102
|
-
Complete: [],
|
|
103
|
-
Failed: [],
|
|
104
|
-
Cancelled: []
|
|
105
|
-
};
|
|
106
|
-
function canTransition(from, to) {
|
|
107
|
-
return TASK_TRANSITIONS[from].includes(to);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// src/constants.ts
|
|
111
|
-
var AGENT_MEMORY_MAX_SNAPSHOT_BYTES = 1024 * 1024;
|
|
112
|
-
var AGENT_MEMORY_MAX_SNAPSHOT_FILES = 128;
|
|
113
|
-
var RUNTIME_IDS = Object.freeze(["pi", "claude", "codex"]);
|
|
114
|
-
|
|
115
|
-
export { AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, AGENT_HOME_PROJECTION_CAPABILITY, AGENT_HOME_READERS_CAPABILITY, AGENT_INPUT_PREPARATION_CAPABILITY, AGENT_MEMORY_INTENT_CAPABILITY, AGENT_MEMORY_MAX_SNAPSHOT_BYTES, AGENT_MEMORY_MAX_SNAPSHOT_FILES, AGENT_MEMORY_PROJECTION_CAPABILITY, AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY, AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY, AGENT_MEMORY_SELECTION_CAPABILITY, AGENT_MESSAGE_EGRESS_CAPABILITY, CAPABILITY_FLAGS, CUSTOM_HARNESS_CAPABILITY, HOST_MCP_TASK_CONTEXT_CAPABILITY, INPUT_PREPARATION_WIRE_VERSION, MAILBOX_READ_AHEAD_CAPABILITY, MAILBOX_READ_AHEAD_MAX_SEQS, PREPARED_AGENT_MEMORY_MODES, PROTOCOL_VERSION, PROVIDER_PROFILE_BINDING_CAPABILITY, PROVIDER_PROVISIONING_CAPABILITY, RUNTIME_FAILURE_CLASSES, RUNTIME_FAILURE_CLASS_CAPABILITY, RUNTIME_IDS, SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY, SEALED_PAYLOAD_CAPABILITY, STRICT_AGENT_ONLY_CAPABILITY, TASK_STATES, TASK_TRANSITIONS, TERMINAL_PROJECTION_SELECTION_CAPABILITY, canTransition, isPreparedAgentMemoryMode };
|
|
3
|
+
export { AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, AGENT_HOME_PROJECTION_CAPABILITY, AGENT_HOME_READERS_CAPABILITY, AGENT_INPUT_PREPARATION_CAPABILITY, AGENT_MEMORY_INTENT_CAPABILITY, AGENT_MEMORY_MAX_SNAPSHOT_BYTES, AGENT_MEMORY_MAX_SNAPSHOT_FILES, AGENT_MEMORY_PROJECTION_CAPABILITY, AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY, AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY, AGENT_MEMORY_SELECTION_CAPABILITY, AGENT_MESSAGE_EGRESS_CAPABILITY, CAPABILITY_FLAGS, CUSTOM_HARNESS_CAPABILITY, HOST_MCP_TASK_CONTEXT_CAPABILITY, INPUT_PREPARATION_WIRE_VERSION, MAILBOX_READ_AHEAD_CAPABILITY, MAILBOX_READ_AHEAD_MAX_SEQS, PREPARED_AGENT_MEMORY_MODES, PROTOCOL_VERSION, PROVIDER_PROFILE_BINDING_CAPABILITY, PROVIDER_PROVISIONING_CAPABILITY, RUNTIME_FAILURE_CLASSES, RUNTIME_FAILURE_CLASS_CAPABILITY, RUNTIME_IDS, RUNTIME_UNAVAILABLE_CAUSES, RUNTIME_UNAVAILABLE_CAUSE_CAPABILITY, SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY, SEALED_PAYLOAD_CAPABILITY, TASK_FAIL_REASON_MAX_BYTES, TASK_STATES, TASK_TRANSITIONS, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_PROJECTION_SELECTION_CAPABILITY, boundFailureReason, canTransition, isPreparedAgentMemoryMode };
|
|
116
4
|
//# sourceMappingURL=constants.js.map
|
|
117
5
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/capability-constants.ts","../src/version.ts","../src/task-state.ts","../src/constants.ts"],"names":[],"mappings":";AAWO,IAAM,8BAAA,GAAiC;AAIvC,IAAM,8BAAA,GAAiC;AAEvC,IAAM,oCAAA,GAAuC;AAG7C,IAAM,qCAAA,GAAwC;AAG9C,IAAM,+BAAA,GAAkC;AAExC,IAAM,uCAAA,GAA0C;AAEhD,IAAM,wCAAA,GAA2C;AAEjD,IAAM,sCAAA,G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AAA,EAAU,OAAO,CAAU","file":"constants.js","sourcesContent":["/**\n * The ONE version of the input-preparation contract, shared by this relay wire\n * (the `agent.input.preparation` payload and the completion receipt summary)\n * and by the device-local request, receipt and artifact\n * (`@byok-sdk/client`'s `INPUT_PREPARATION_VERSION`, which is this value).\n *\n * The relay wire carries no version field of its own, so a version change is\n * made visible where admission actually happens: in the capability token\n * below. See `INPUT_PREPARATION_VERSION` in the client for what each version\n * changed.\n */\nexport const INPUT_PREPARATION_WIRE_VERSION = 9 as const;\n\n\n/** Additive daemon capability names. Server/cloud admission consumes these exactly. */\nexport const AGENT_EGRESS_POLICY_CAPABILITY = 'agent-egress-policy' as const;\n\nexport const AGENT_EGRESS_RELIABLE_ACK_CAPABILITY = 'agent-egress-reliable-ack' as const;\n\n/** Admits the distinct offer whose runtime mints its session only after start. */\nexport const AGENT_EGRESS_FRESH_SESSION_CAPABILITY = 'agent-egress-fresh-session' as const;\n\n/** Admits the distinct Agent-authored message lane; activity policy remains independent. */\nexport const AGENT_MESSAGE_EGRESS_CAPABILITY = 'agent-message-egress' as const;\n\nexport const AGENT_CONTENT_WORKSPACE_READ_CAPABILITY = 'agent-content-workspace-read' as const;\n\nexport const AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY = 'agent-content-transcript-read' as const;\n\nexport const AGENT_CONTENT_ARTIFACT_READ_CAPABILITY = 'agent-content-artifact-read' as const;\n\n/** Capability required before a task-free Agent-home projection is admitted. */\nexport const AGENT_HOME_PROJECTION_CAPABILITY = 'agent-home-projection' as const;\n\n/** Capability required before an offer may select terminal projection behavior. */\nexport const TERMINAL_PROJECTION_SELECTION_CAPABILITY = 'terminal-projection-selection' as const;\n\n/** Contract §8.1's capability gate for `byok-task-assertion-v1` tool authority. */\nexport const HOST_MCP_TASK_CONTEXT_CAPABILITY = 'host-mcp-task-context' as const;\n\n/** Daemon capability required before an exact local provider profile may be offered. */\nexport const PROVIDER_PROFILE_BINDING_CAPABILITY = 'provider-profile-binding' as const;\n\n/** Device capability required before a Host may enqueue `provider.provisioning.available`. */\nexport const PROVIDER_PROVISIONING_CAPABILITY = 'provider-provisioning.v1' as const;\n\n/** Device capability required before a Host may enqueue `agent.memory.intent.available`. */\nexport const AGENT_MEMORY_INTENT_CAPABILITY = 'agent-memory-intent.v1' as const;\n\n/** Capability required before the optional hosted Agent-memory projection can be used. */\nexport const AGENT_MEMORY_PROJECTION_CAPABILITY = 'agent.memory.projection' as const;\n\n/** Device capability required before an ordinary Agent offer may carry `agentMemory`. */\nexport const AGENT_MEMORY_SELECTION_CAPABILITY = 'agent-memory-selection' as const;\n\n/** Device capability required before an ordinary Agent offer may carry `agentMemory: 'read-if-admitted'`. */\nexport const AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY = 'agent-memory-read-if-admitted' as const;\n\n/** Device capability required before an ordinary Agent offer may carry `agentMemory: 'read-write-if-admitted'`. */\nexport const AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY = 'agent-memory-read-write-if-admitted' as const;\n\n/** Exact capability of the single input-preparation wire authority. */\nexport const AGENT_INPUT_PREPARATION_CAPABILITY =\n `agent-input-preparation-v${INPUT_PREPARATION_WIRE_VERSION}` as const;\n\n/**\n * Sealed payload v1 (#654). A device advertises it before a Host may send it\n * a sealed offer or steer; a server advertises it before a device may send it\n * sealed task output or a sealed decline code. Both gates read\n * `WIRE_ADDITIONS`.\n */\nexport const SEALED_PAYLOAD_CAPABILITY = 'sealed-payload-v1' as const;\n\n/**\n * A server advertises it before a device may send a sealed task output that\n * names its ciphertext blob (`sealed.ciphertextRef`) instead of carrying it\n * inline. The server then holds the blob for the life of the task.\n */\nexport const SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY = 'sealed-output-ciphertext-ref' as const;\n\n/**\n * A server advertises it before a device may send `task.fail.failure`, the\n * machine-readable runtime failure class (#869).\n */\nexport const RUNTIME_FAILURE_CLASS_CAPABILITY = 'runtime-failure-class' as const;\n\n/**\n * The closed classes of `task.fail.failure.class`: the vendored OAR\n * `FailureClass` values. `unknown` means the runtime gave no structured\n * evidence. Single value authority shared by schema validation and\n * schema-free consumers.\n */\nexport const RUNTIME_FAILURE_CLASSES = [\n 'auth', 'quota', 'rate_limited', 'billing', 'model_unavailable', 'input_too_large', 'invalid_request',\n 'overloaded', 'provider', 'runtime_exited', 'limit_reached', 'output_schema', 'unknown',\n] as const;\n\n/** Single value authority shared by schema validation and schema-free consumers. */\nexport const PREPARED_AGENT_MEMORY_MODES = ['none', 'read', 'read-write'] as const;\n\nexport function isPreparedAgentMemoryMode(value: unknown): value is (typeof PREPARED_AGENT_MEMORY_MODES)[number] {\n return typeof value === 'string' && PREPARED_AGENT_MEMORY_MODES.some(mode => mode === value);\n}\n","/** Bounded volatile navigation; only cursor is a durable acknowledgement. */\nexport const MAILBOX_READ_AHEAD_MAX_SEQS = 4096;\nexport const MAILBOX_READ_AHEAD_CAPABILITY = 'mailbox-read-ahead';\n\n/**\n * Wire protocol version. Every v3 change is a version bump, a gated addition\n * or a strip-safe addition: see docs/protocol.md \"Freeze rule\", which is the\n * one statement of the rule, and `src/wire-additions.ts`, which declares the\n * receiver-capability gates and additions. No v3 release has been published\n * yet, so `src/__tests__/compat.test.ts` has no published v3 decoder to prove\n * additions against; cross-release gates stay unproven until one exists.\n *\n * v3 makes `schema` required on the `terminalProjection.mode:\n * 'result-document'` arm (`terminal-projection.ts`, `result-schema.ts`): the\n * offer freezes the outcome schema, and the outcome reaches the Host only as\n * `task.complete.document`. That narrows a strict shape, so it is a wire\n * major. A v2 envelope is rejected; there is no v2 reader and no capability\n * negotiation between the two result-document shapes. Drain, then upgrade\n * server and client together. Every addition v2 declared is part of the v3\n * baseline, and the v2 `result-document` capability flag is gone: every v3\n * server keeps `task.complete.document`.\n *\n * v2 removed the task offer's `policy` (`PermissionPolicy`), the runtime\n * capability `permissionModes` and the input-preparation `permissionMode`.\n * Sessions run without an SDK permission gate; each local agent keeps its\n * own guardrails. A v1 envelope is rejected; there is no v1 reader.\n * v2 also removed the egress policy's `metadata-status` activity mode, its\n * `activity.mode` field and the `sanitizer_rejected` drop reason. Agent\n * egress goes to the Host as the runtime produced it.\n * v2 also removed the input-preparation artifact's `toolImplementationKinds`\n * and the readiness reason `executor_identity_unproven`. The SDK does not\n * attest tool executables. The artifact names its counted tools in\n * `toolNames`.\n */\nexport const PROTOCOL_VERSION = 3;\n\n/** Host declares that this device accepts only Agent-bound offer variants. */\nexport const STRICT_AGENT_ONLY_CAPABILITY = 'strict-agent-only' as const;\n\n/**\n * The device runs `homeAccess: 'memory-reader'` Agent offers: each reader\n * Attempt gets its own run directory under the Agent home, and readers are\n * counted apart from the one writer. The Agent offers are strict, so a host\n * must refuse a reader offer to a device without this flag before it creates\n * the task.\n */\nexport const AGENT_HOME_READERS_CAPABILITY = 'agent-home-readers' as const;\n\n/**\n * Capability flags. The daemon sends its flags in `conn.hello`; the server\n * sends its own on every long-poll response (`EventsPollResponse`). Additional\n * flags may be introduced without a protocol version bump; unrecognized flags\n * must be ignored by both sides.\n *\n * `interactive-approval` is RESERVED as of this addition: it gates the\n * (currently unexercised) approval seam — a server must not route an\n * approval-requiring policy to a daemon that hasn't advertised this flag. No\n * bundled runtime adapter emits it yet; that's expected until interactive\n * approval is actually wired up in a later wave.\n *\n * `approval_resolved` (additive-minor): a SERVER-advertised flag meaning\n * \"I understand the `task.approval_resolved` message\" (`messages.ts`). This\n * is the N/N-1 answer for that new daemon -> server message: an old server's\n * advertised capabilities never include it, so a new daemon talking to an old\n * server never sends `task.approval_resolved` at all (see `packages/client`'s\n * `task-runner.ts`) and falls back to the pre-existing implicit-resume inference\n * (the `relay.onTaskActivity` hook in `packages/server/src/index.ts`)\n * unconditionally, exactly as before this flag existed. Unlike\n * `interactive-approval`, this one IS exercised the moment both sides\n * support it — there is no reserved/dormant period for it.\n */\n/**\n * `approval-targeting` (M5, additive-minor): unlike `approval_resolved`\n * above, this flag is purely INFORMATIONAL/semantic, not a functional gate.\n * `task.await_approval`/`task.approve`/`task.reject` all carry their new\n * `approvalId` field UNCONDITIONALLY on both sides once each peer is\n * upgraded -- the wire is tolerant (a plain, non-`.strict()` `z.object()`\n * field, `messages.ts`), so no version/capability negotiation is needed just\n * to send it safely; an older peer that doesn't recognize the field simply\n * never reads it. Receivers decide whether to apply exact-match targeting\n * by FIELD PRESENCE on the specific message at hand (does this particular\n * `task.approve`/`task.reject`/`onApprovalResolved` payload carry an\n * `approvalId`, and does a stored one exist to compare it against?), never\n * by checking this flag -- see `approveTask`/`rejectTask` (`@byok-sdk/cloud`)\n * and `TaskRunner.handleApprove`/`handleReject` (`packages/client`'s\n * `task-runner.ts`). This flag exists only so each side can advertise\n * whether the OTHER side is new enough to participate in targeting at all (an\n * embedder could observe it through the old\n * reference server's `ConnectionHub.getDeviceCapabilities`; `@byok-sdk/server`\n * now reads it only internally) -- the same N/N-1-safe shape as every other\n * flag here, just consumed for observability instead of gating.\n */\n/**\n * `dispatch-selection` (additive-minor) is a correctness gate for the\n * optional `task.offer.dispatchSelection` control field. An older v1 daemon\n * legally strips unknown optional fields, so a server must never send an\n * authoritative provider/model selection unless the target connection\n * advertises this flag. Absence means reject before task creation, not send\n * a legacy runtime-only offer that could reach a different provider.\n *\n * `toolset-selection` (additive-minor) means the daemon understands\n * `task.offer_with_toolsets` and can resolve its logical ids against local\n * MCP configuration. The distinct message type is also the N/N-1 safety\n * boundary for long-poll: an older daemon skips it as unknown and therefore\n * cannot accidentally execute the instruction without the required tools.\n */\nexport const CUSTOM_HARNESS_CAPABILITY = 'custom-harness' as const;\n\nexport const CAPABILITY_FLAGS = [\n 'steer',\n 'blob-upload',\n 'interactive-approval',\n 'approval_resolved',\n 'approval-targeting',\n 'dispatch-selection',\n PROVIDER_PROFILE_BINDING_CAPABILITY,\n 'toolset-selection',\n 'agent-home-contract',\n AGENT_HOME_READERS_CAPABILITY,\n STRICT_AGENT_ONLY_CAPABILITY,\n AGENT_EGRESS_POLICY_CAPABILITY,\n AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,\n AGENT_MESSAGE_EGRESS_CAPABILITY,\n AGENT_EGRESS_FRESH_SESSION_CAPABILITY,\n AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,\n AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,\n AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,\n AGENT_HOME_PROJECTION_CAPABILITY,\n AGENT_INPUT_PREPARATION_CAPABILITY,\n TERMINAL_PROJECTION_SELECTION_CAPABILITY,\n HOST_MCP_TASK_CONTEXT_CAPABILITY,\n CUSTOM_HARNESS_CAPABILITY,\n MAILBOX_READ_AHEAD_CAPABILITY,\n PROVIDER_PROVISIONING_CAPABILITY,\n AGENT_MEMORY_INTENT_CAPABILITY,\n AGENT_MEMORY_SELECTION_CAPABILITY,\n AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY,\n AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY,\n 'agent-message-draft',\n SEALED_PAYLOAD_CAPABILITY,\n SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY,\n RUNTIME_FAILURE_CLASS_CAPABILITY,\n] as const;\n\nexport type CapabilityFlag = (typeof CAPABILITY_FLAGS)[number];\nimport {\n AGENT_EGRESS_POLICY_CAPABILITY,\n AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,\n AGENT_EGRESS_FRESH_SESSION_CAPABILITY,\n AGENT_MESSAGE_EGRESS_CAPABILITY,\n AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,\n AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,\n AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,\n AGENT_HOME_PROJECTION_CAPABILITY,\n TERMINAL_PROJECTION_SELECTION_CAPABILITY,\n HOST_MCP_TASK_CONTEXT_CAPABILITY,\n PROVIDER_PROFILE_BINDING_CAPABILITY,\n PROVIDER_PROVISIONING_CAPABILITY,\n AGENT_MEMORY_INTENT_CAPABILITY,\n AGENT_MEMORY_SELECTION_CAPABILITY,\n AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY,\n AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY,\n AGENT_INPUT_PREPARATION_CAPABILITY,\n SEALED_PAYLOAD_CAPABILITY,\n SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY,\n RUNTIME_FAILURE_CLASS_CAPABILITY,\n} from './capability-constants';\n","export const TASK_STATES = [\n 'Offered',\n 'Claimed',\n 'Running',\n 'AwaitApproval',\n 'Complete',\n 'Failed',\n 'Cancelled',\n] as const;\n\nexport type TaskState = (typeof TASK_STATES)[number];\n\n/**\n * Legal state transitions for a task. `Complete` / `Failed` / `Cancelled` are\n * terminal (no outgoing edges). `Running` and `AwaitApproval` form a loop:\n * the daemon can request approval mid-run and resume once the server\n * approves (or fail/cancel out of the approval wait).\n *\n * `Offered -> Failed` (M1 gap #5, \"Declined vs. Failed\"): a daemon that\n * declines an offer pre-claim (`task.decline`) reports it through the\n * existing `Failed` state rather than a new `Declined` state. A decline and\n * a post-claim failure are the same outcome from the dispatcher's point of\n * view — this attempt produced no result, `reason`/`retryable` say why and\n * whether retrying elsewhere makes sense — so reusing `Failed` keeps the\n * state machine minimal instead of forking every terminal-state consumer\n * into \"Failed or Declined, handle both\". See docs/protocol.md for the full\n * writeup.\n */\nexport const TASK_TRANSITIONS: Readonly<Record<TaskState, readonly TaskState[]>> = {\n Offered: ['Claimed', 'Cancelled', 'Failed'],\n Claimed: ['Running', 'Failed', 'Cancelled'],\n Running: ['AwaitApproval', 'Complete', 'Failed', 'Cancelled'],\n AwaitApproval: ['Running', 'Failed', 'Cancelled'],\n Complete: [],\n Failed: [],\n Cancelled: [],\n};\n\n/** Whether `from -> to` is a legal transition per {@link TASK_TRANSITIONS}. */\nexport function canTransition(from: TaskState, to: TaskState): boolean {\n return TASK_TRANSITIONS[from].includes(to);\n}\n","/** Schema-free protocol values. Import this entry when runtime schemas are unnecessary. */\nexport * from './version';\nexport * from './task-state';\nexport * from './capability-constants';\n\n/** Maximum raw UTF-8 content bytes in one local Host Agent-memory export; no truncation. */\nexport const AGENT_MEMORY_MAX_SNAPSHOT_BYTES = 1024 * 1024;\n/** Maximum memory files in one local Host export, including MEMORY.md. */\nexport const AGENT_MEMORY_MAX_SNAPSHOT_FILES = 128;\n\n/** The frozen wire runtime ids. Any other adapter id is a custom harness (`harnessId`). */\nexport const RUNTIME_IDS = Object.freeze(['pi', 'claude', 'codex'] as const);\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/capability-constants.ts","../src/version.ts","../src/task-state.ts","../src/failure-reason.ts","../src/constants.ts"],"names":[],"mappings":"AAWO,IAAM,8BAAA,CAAiC,EAIvC,IAAM,8BAAA,CAAiC,sBAEvC,IAAM,oCAAA,CAAuC,4BAG7C,IAAM,qCAAA,CAAwC,iCAGxC,+BAAA,CAAkC,uBAExC,IAAM,uCAAA,CAA0C,+BAEhD,IAAM,yCAA2C,gCAEjD,IAAM,sCAAA,CAAyC,8BAG/C,IAAM,gCAAA,CAAmC,wBAGzC,IAAM,wCAAA,CAA2C,gCAGjD,IAAM,gCAAA,CAAmC,4BAGnC,mCAAA,CAAsC,2BAG5C,IAAM,gCAAA,CAAmC,2BAGzC,IAAM,+BAAiC,yBAGvC,IAAM,kCAAA,CAAqC,0BAG3C,IAAM,iCAAA,CAAoC,yBAG1C,IAAM,wCAAA,CAA2C,gCAGjD,IAAM,8CAAA,CAAiD,0CAGjD,kCAAA,CACX,CAAA,yBAAA,EAA4B,8BAA8B,CAAA,EAQrD,IAAM,0BAA4B,oBAOlC,IAAM,uCAAA,CAA0C,+BAMhD,IAAM,gCAAA,CAAmC,wBAUzC,IAAM,oCAAA,CAAuC,4BAO7C,IAAM,uBAAA,CAA0B,CACrC,OAAQ,OAAA,CAAS,cAAA,CAAgB,SAAA,CAAW,mBAAA,CAAqB,iBAAA,CAAmB,iBAAA,CACpF,aAAc,UAAA,CAAY,gBAAA,CAAkB,eAAA,CAAiB,eAAA,CAAiB,SAChF,MAGa,2B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,OAAO,GACT,CAQO,SAAS,kBAAA,CAAmB,MAAA,CAAwB,CACzD,MAAM,QAAA,CAAW,MAAA,CAAO,MAAM,CAAA,CAC9B,MAAM,KAAA,CAAQ,OAAA,CAAQ,MAAA,CAAO,QAAQ,EACrC,GAAI,KAAA,CAAM,MAAA,EAAU,0BAAA,CAA4B,OAAO,QAAA,CAEvD,IAAI,IAAA,CAAO,0BAAA,CAA6B,OAAA,CAAQ,MAAA,CAAO,CAAA,iBAAA,EAAoB,KAAA,CAAM,MAAM,CAAA,OAAA,CAAS,CAAA,CAAE,MAAA,CAClG,MAAO,IAAA,CAAO,CAAA,EAAA,CAAA,CAAO,MAAM,IAAI,CAAA,EAAK,CAAA,EAAK,GAAA,IAAU,GAAA,CAAM,IAAA,EAAQ,EACjE,OAAO,CAAA,EAAG,OAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,QAAA,CAAS,EAAG,IAAI,CAAC,CAAC,CAAA,iBAAA,EAAoB,KAAA,CAAM,MAAA,CAAS,IAAI,CAAA,OAAA,CAC1F,CClEO,IAAM,+BAAA,CAAkC,IAAA,CAAO,SAEzC,+BAAA,CAAkC,IAGxC,IAAM,WAAA,CAAc,MAAA,CAAO,MAAA,CAAO,CAAC,IAAA,CAAM,QAAA,CAAU,OAAO,CAAU,EAUpE,IAAM,2BAA6B,MAAA,CAAO,MAAA,CAAO,CAEtD,eAAA,CAEA,gBAAA,CAEA,eAAA,CAEA,eAEA,wBAAA,CAEA,iBAAA,CAEA,sBAAA,CAEA,yBAAA,CAEA,iBAAA,CAEA,wBAAA,CAEA,sBAEA,gBACF,CAAU,EAMH,IAAM,yCAAA,CAA4C","file":"constants.js","sourcesContent":["/**\n * The ONE version of the input-preparation contract, shared by this relay wire\n * (the `agent.input.preparation` payload and the completion receipt summary)\n * and by the device-local request, receipt and artifact\n * (`@byok-sdk/client`'s `INPUT_PREPARATION_VERSION`, which is this value).\n *\n * The relay wire carries no version field of its own, so a version change is\n * made visible where admission actually happens: in the capability token\n * below. See `INPUT_PREPARATION_VERSION` in the client for what each version\n * changed.\n */\nexport const INPUT_PREPARATION_WIRE_VERSION = 9 as const;\n\n\n/** Additive daemon capability names. Server/cloud admission consumes these exactly. */\nexport const AGENT_EGRESS_POLICY_CAPABILITY = 'agent-egress-policy' as const;\n\nexport const AGENT_EGRESS_RELIABLE_ACK_CAPABILITY = 'agent-egress-reliable-ack' as const;\n\n/** Admits the distinct offer whose runtime mints its session only after start. */\nexport const AGENT_EGRESS_FRESH_SESSION_CAPABILITY = 'agent-egress-fresh-session' as const;\n\n/** Admits the distinct Agent-authored message lane; activity policy remains independent. */\nexport const AGENT_MESSAGE_EGRESS_CAPABILITY = 'agent-message-egress' as const;\n\nexport const AGENT_CONTENT_WORKSPACE_READ_CAPABILITY = 'agent-content-workspace-read' as const;\n\nexport const AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY = 'agent-content-transcript-read' as const;\n\nexport const AGENT_CONTENT_ARTIFACT_READ_CAPABILITY = 'agent-content-artifact-read' as const;\n\n/** Capability required before a task-free Agent-home projection is admitted. */\nexport const AGENT_HOME_PROJECTION_CAPABILITY = 'agent-home-projection' as const;\n\n/** Capability required before an offer may select terminal projection behavior. */\nexport const TERMINAL_PROJECTION_SELECTION_CAPABILITY = 'terminal-projection-selection' as const;\n\n/** Contract §8.1's capability gate for `byok-task-assertion-v1` tool authority. */\nexport const HOST_MCP_TASK_CONTEXT_CAPABILITY = 'host-mcp-task-context' as const;\n\n/** Daemon capability required before an exact local provider profile may be offered. */\nexport const PROVIDER_PROFILE_BINDING_CAPABILITY = 'provider-profile-binding' as const;\n\n/** Device capability required before a Host may enqueue `provider.provisioning.available`. */\nexport const PROVIDER_PROVISIONING_CAPABILITY = 'provider-provisioning.v1' as const;\n\n/** Device capability required before a Host may enqueue `agent.memory.intent.available`. */\nexport const AGENT_MEMORY_INTENT_CAPABILITY = 'agent-memory-intent.v1' as const;\n\n/** Capability required before the optional hosted Agent-memory projection can be used. */\nexport const AGENT_MEMORY_PROJECTION_CAPABILITY = 'agent.memory.projection' as const;\n\n/** Device capability required before an ordinary Agent offer may carry `agentMemory`. */\nexport const AGENT_MEMORY_SELECTION_CAPABILITY = 'agent-memory-selection' as const;\n\n/** Device capability required before an ordinary Agent offer may carry `agentMemory: 'read-if-admitted'`. */\nexport const AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY = 'agent-memory-read-if-admitted' as const;\n\n/** Device capability required before an ordinary Agent offer may carry `agentMemory: 'read-write-if-admitted'`. */\nexport const AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY = 'agent-memory-read-write-if-admitted' as const;\n\n/** Exact capability of the single input-preparation wire authority. */\nexport const AGENT_INPUT_PREPARATION_CAPABILITY =\n `agent-input-preparation-v${INPUT_PREPARATION_WIRE_VERSION}` as const;\n\n/**\n * Sealed payload v1 (#654). A device advertises it before a Host may send it\n * a sealed offer or steer; a server advertises it before a device may send it\n * sealed task output or a sealed decline code. Both gates read\n * `WIRE_ADDITIONS`.\n */\nexport const SEALED_PAYLOAD_CAPABILITY = 'sealed-payload-v1' as const;\n\n/**\n * A server advertises it before a device may send a sealed task output that\n * names its ciphertext blob (`sealed.ciphertextRef`) instead of carrying it\n * inline. The server then holds the blob for the life of the task.\n */\nexport const SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY = 'sealed-output-ciphertext-ref' as const;\n\n/**\n * A server advertises it before a device may send `task.fail.failure`, the\n * machine-readable runtime failure class (#869).\n */\nexport const RUNTIME_FAILURE_CLASS_CAPABILITY = 'runtime-failure-class' as const;\n\n/**\n * The connection understands the typed pre-claim runtime-unavailable cause\n * (#1103 D8): `task.decline.runtimeUnavailable`, `conn.hello.runtimeUnavailable`\n * and the presence projection. A daemon declares it when it emits the cause.\n * Older peers ignore the unknown flag; absence means the peer may not read\n * the cause, so a Host falls back to `retryable` and treats the cause as\n * unknown. It never infers availability or allow from absence.\n */\nexport const RUNTIME_UNAVAILABLE_CAUSE_CAPABILITY = 'runtime-unavailable-cause' as const;\n/**\n * The closed classes of `task.fail.failure.class`: the vendored OAR\n * `FailureClass` values. `unknown` means the runtime gave no structured\n * evidence. Single value authority shared by schema validation and\n * schema-free consumers.\n */\nexport const RUNTIME_FAILURE_CLASSES = [\n 'auth', 'quota', 'rate_limited', 'billing', 'model_unavailable', 'input_too_large', 'invalid_request',\n 'overloaded', 'provider', 'runtime_exited', 'limit_reached', 'output_schema', 'unknown',\n] as const;\n\n/** Single value authority shared by schema validation and schema-free consumers. */\nexport const PREPARED_AGENT_MEMORY_MODES = ['none', 'read', 'read-write'] as const;\n\nexport function isPreparedAgentMemoryMode(value: unknown): value is (typeof PREPARED_AGENT_MEMORY_MODES)[number] {\n return typeof value === 'string' && PREPARED_AGENT_MEMORY_MODES.some(mode => mode === value);\n}\n","/** Bounded volatile navigation; only cursor is a durable acknowledgement. */\nexport const MAILBOX_READ_AHEAD_MAX_SEQS = 4096;\nexport const MAILBOX_READ_AHEAD_CAPABILITY = 'mailbox-read-ahead';\n\n/**\n * Wire protocol version. Every v4 change is a version bump, a gated addition\n * or a strip-safe addition: see docs/protocol.md \"Freeze rule\", which is the\n * one statement of the rule, and `src/wire-additions.ts`, which declares the\n * receiver-capability gates and additions. No v4 release has been published\n * yet, so `src/__tests__/compat.test.ts` has no published v4 decoder to prove\n * additions against; cross-release gates stay unproven until one exists.\n *\n * v4 completes the ADR-034 cutover and retires the approval paths kept for\n * pre-M5 peers. It removes the v3 handshake answer, the runtime-only offers\n * (with and without toolsets) with their sealed twins, and the\n * `strict-agent-only` flag: every offer is Agent-bound. `approvalId` is\n * required on `task.await_approval`, `task.approve` and `task.reject`, so a\n * decision resolves only the approval it names. `task.approval_resolved` is\n * baseline: the daemon reports every locally resolved approval, and the\n * server no longer infers one from later task activity. The three approval\n * capability flags of v3 are gone. A v3 envelope is rejected; there is no v3 reader. Drain, then\n * upgrade server and client together.\n *\n * v3 made `schema` required on the `terminalProjection.mode:\n * 'result-document'` arm (`terminal-projection.ts`, `result-schema.ts`): the\n * offer freezes the outcome schema, and the outcome reaches the Host only as\n * `task.complete.document`. That narrows a strict shape, so it is a wire\n * major. A v2 envelope is rejected; there is no v2 reader and no capability\n * negotiation between the two result-document shapes. Drain, then upgrade\n * server and client together. Every addition v2 declared is part of the v3\n * baseline, and the v2 `result-document` capability flag is gone: every v3\n * server keeps `task.complete.document`.\n *\n * v2 removed the task offer's `policy` (`PermissionPolicy`), the runtime\n * capability `permissionModes` and the input-preparation `permissionMode`.\n * Sessions run without an SDK permission gate; each local agent keeps its\n * own guardrails. A v1 envelope is rejected; there is no v1 reader.\n * v2 also removed the egress policy's `metadata-status` activity mode, its\n * `activity.mode` field and the `sanitizer_rejected` drop reason. Agent\n * egress goes to the Host as the runtime produced it.\n * v2 also removed the input-preparation artifact's `toolImplementationKinds`\n * and the readiness reason `executor_identity_unproven`. The SDK does not\n * attest tool executables. The artifact names its counted tools in\n * `toolNames`.\n */\nexport const PROTOCOL_VERSION = 4;\n\n/**\n * The device runs `homeAccess: 'memory-reader'` Agent offers: each reader\n * Attempt gets its own run directory under the Agent home, and readers are\n * counted apart from the one writer. The Agent offers are strict, so a host\n * must refuse a reader offer to a device without this flag before it creates\n * the task.\n */\nexport const AGENT_HOME_READERS_CAPABILITY = 'agent-home-readers' as const;\n\n/**\n * Capability flags. The daemon sends its flags in `conn.hello`; the server\n * sends its own on every long-poll response (`EventsPollResponse`). Additional\n * flags may be introduced without a protocol version bump; unrecognized flags\n * must be ignored by both sides.\n *\n * `dispatch-selection` (additive-minor) is a correctness gate for the\n * optional offer `dispatchSelection` control field. An older v1 daemon\n * legally strips unknown optional fields, so a server must never send an\n * authoritative provider/model selection unless the target connection\n * advertises this flag. Absence means reject before task creation, not send\n * an offer that could reach a different provider.\n *\n * `toolset-selection` (additive-minor) means the daemon understands an\n * offer's `requiredToolsets` and can resolve its logical ids against local\n * MCP configuration.\n */\nexport const CUSTOM_HARNESS_CAPABILITY = 'custom-harness' as const;\n\nexport const CAPABILITY_FLAGS = [\n 'steer',\n 'blob-upload',\n 'dispatch-selection',\n PROVIDER_PROFILE_BINDING_CAPABILITY,\n 'toolset-selection',\n 'agent-home-contract',\n AGENT_HOME_READERS_CAPABILITY,\n AGENT_EGRESS_POLICY_CAPABILITY,\n AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,\n AGENT_MESSAGE_EGRESS_CAPABILITY,\n AGENT_EGRESS_FRESH_SESSION_CAPABILITY,\n AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,\n AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,\n AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,\n AGENT_HOME_PROJECTION_CAPABILITY,\n AGENT_INPUT_PREPARATION_CAPABILITY,\n TERMINAL_PROJECTION_SELECTION_CAPABILITY,\n HOST_MCP_TASK_CONTEXT_CAPABILITY,\n CUSTOM_HARNESS_CAPABILITY,\n MAILBOX_READ_AHEAD_CAPABILITY,\n PROVIDER_PROVISIONING_CAPABILITY,\n AGENT_MEMORY_INTENT_CAPABILITY,\n AGENT_MEMORY_SELECTION_CAPABILITY,\n AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY,\n AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY,\n 'agent-message-draft',\n SEALED_PAYLOAD_CAPABILITY,\n SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY,\n RUNTIME_FAILURE_CLASS_CAPABILITY,\n RUNTIME_UNAVAILABLE_CAUSE_CAPABILITY,\n] as const;\n\nexport type CapabilityFlag = (typeof CAPABILITY_FLAGS)[number];\nimport {\n AGENT_EGRESS_POLICY_CAPABILITY,\n AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,\n AGENT_EGRESS_FRESH_SESSION_CAPABILITY,\n AGENT_MESSAGE_EGRESS_CAPABILITY,\n AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,\n AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,\n AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,\n AGENT_HOME_PROJECTION_CAPABILITY,\n TERMINAL_PROJECTION_SELECTION_CAPABILITY,\n HOST_MCP_TASK_CONTEXT_CAPABILITY,\n PROVIDER_PROFILE_BINDING_CAPABILITY,\n PROVIDER_PROVISIONING_CAPABILITY,\n AGENT_MEMORY_INTENT_CAPABILITY,\n AGENT_MEMORY_SELECTION_CAPABILITY,\n AGENT_MEMORY_READ_IF_ADMITTED_CAPABILITY,\n AGENT_MEMORY_READ_WRITE_IF_ADMITTED_CAPABILITY,\n AGENT_INPUT_PREPARATION_CAPABILITY,\n SEALED_PAYLOAD_CAPABILITY,\n SEALED_OUTPUT_CIPHERTEXT_REF_CAPABILITY,\n RUNTIME_FAILURE_CLASS_CAPABILITY,\n RUNTIME_UNAVAILABLE_CAUSE_CAPABILITY,\n} from './capability-constants';\n","export const TASK_STATES = [\n 'Offered',\n 'Claimed',\n 'Running',\n 'AwaitApproval',\n 'Complete',\n 'Failed',\n 'Cancelled',\n] as const;\n\nexport type TaskState = (typeof TASK_STATES)[number];\n\n/**\n * Legal state transitions for a task. `Complete` / `Failed` / `Cancelled` are\n * terminal (no outgoing edges). `Running` and `AwaitApproval` form a loop:\n * the daemon can request approval mid-run and resume once the server\n * approves (or fail/cancel out of the approval wait).\n *\n * `Offered -> Failed` (M1 gap #5, \"Declined vs. Failed\"): a daemon that\n * declines an offer pre-claim (`task.decline`) reports it through the\n * existing `Failed` state rather than a new `Declined` state. A decline and\n * a post-claim failure are the same outcome from the dispatcher's point of\n * view — this attempt produced no result, `reason`/`retryable` say why and\n * whether retrying elsewhere makes sense — so reusing `Failed` keeps the\n * state machine minimal instead of forking every terminal-state consumer\n * into \"Failed or Declined, handle both\". See docs/protocol.md for the full\n * writeup.\n */\nexport const TASK_TRANSITIONS: Readonly<Record<TaskState, readonly TaskState[]>> = {\n Offered: ['Claimed', 'Cancelled', 'Failed'],\n Claimed: ['Running', 'Failed', 'Cancelled'],\n Running: ['AwaitApproval', 'Complete', 'Failed', 'Cancelled'],\n AwaitApproval: ['Running', 'Failed', 'Cancelled'],\n Complete: [],\n Failed: [],\n Cancelled: [],\n};\n\n/** Whether `from -> to` is a legal transition per {@link TASK_TRANSITIONS}. */\nexport function canTransition(from: TaskState, to: TaskState): boolean {\n return TASK_TRANSITIONS[from].includes(to);\n}\n","/**\n * The single authority for the display text of a `task.fail` `reason` (#1124).\n *\n * A runtime's stderr tail can carry credentials a runtime or proxy printed\n * while failing. The `task.fail` schema applies this to `reason` on every\n * parse, so `createEnvelope` bounds what a daemon sends (sealed or not) and\n * every decode bounds what a receiver holds. The raw tail stays local, on the\n * adapter's `RuntimeExecutionFailure`. The result is a fixed point: applying\n * it to its own output changes nothing, so a bounded envelope round-trips\n * byte-for-byte.\n *\n * Every pattern starts at a literal and its runs never backtrack into a\n * failure, so the cost stays linear in the input length.\n */\n\n/** Maximum UTF-8 bytes of a `task.fail` `reason` after normalization, truncation marker included. */\nexport const TASK_FAIL_REASON_MAX_BYTES = 2048;\n\nconst REDACTED = '[redacted]';\n\n// A secret value: a quoted string (an unclosed quote runs to the end of the\n// line), or an unquoted run. A backslash and its following character belong\n// to the value together, so an escaped quote cannot expose a secret suffix.\n// A dangling backslash in an unclosed value is consumed too. Every alternative\n// succeeds greedily without backtracking. An unquoted value never starts with `[` or `…`, so a\n// redaction or truncation marker is never mistaken for a value on a second pass.\nconst VALUE = String.raw`(?:\"(?:\\\\[^\\n]|[^\"\\\\\\n])*(?:\\\\)?\"?|'(?:\\\\[^\\n]|[^'\\\\\\n])*(?:\\\\)?'?|[^\\s\"'\\[\\u2026,;&|][^\\s\"',;&|]*)`;\n\n// Bounded runs keep a failed match from rescanning a long run at every literal.\nconst GAP = '[ \\\\t]{0,16}';\n\nconst RULES: ReadonlyArray<readonly [RegExp, string]> = [\n // `Authorization: Bearer …`, `proxy-authorization=Basic …`, JSON `\"authorization\": \"…\"`.\n [new RegExp(String.raw`\\b((?:proxy-)?authorization)([\"']?${GAP}[:=]${GAP})(?:(?:bearer|basic|token|digest)[ \\t]{1,16})?${VALUE}`, 'gi'), `$1$2${REDACTED}`],\n [/\\b(bearer)[ \\t]{1,16}[A-Za-z0-9._~+/=-]{8,}/gi, `$1 ${REDACTED}`],\n // `ANTHROPIC_API_KEY=…`, `x-api-key: …`, `GITHUB_TOKEN=…`, `client_secret: …`, `DB_PASSWORD_FILE=…`.\n [new RegExp(String.raw`(key|token|secret|passw(?:or)?d[\\w.-]{0,64})([\"']?${GAP}[:=]${GAP})${VALUE}`, 'gi'), `$1$2${REDACTED}`],\n // URL userinfo: `postgres://user:pass@host`, `https://token@host`.\n [/:\\/\\/[^\\s/?#@]{1,256}@/g, `://${REDACTED}@`],\n // Provider key shapes.\n [/\\bsk-[A-Za-z0-9_-]{16,}/g, REDACTED],\n [/\\bxai-[A-Za-z0-9_-]{16,}/g, REDACTED],\n [/\\bAIza[0-9A-Za-z_-]{30,}/g, REDACTED],\n [/\\bgh[pousr]_[A-Za-z0-9]{20,}/g, REDACTED],\n [/\\bgithub_pat_[A-Za-z0-9_]{20,}/g, REDACTED],\n [/\\bAKIA[0-9A-Z]{16}/g, REDACTED],\n // JWT-like tokens.\n [/\\beyJ[A-Za-z0-9_-]{10,}(?:\\.[A-Za-z0-9_-]*){0,2}/g, REDACTED],\n];\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder('utf-8');\n\nfunction redact(text: string): string {\n let out = text;\n for (const [pattern, replacement] of RULES) out = out.replace(pattern, replacement);\n return out;\n}\n\n/**\n * Redact credentials from a failure reason, then cap it at\n * {@link TASK_FAIL_REASON_MAX_BYTES} UTF-8 bytes on a code-point boundary\n * with a `…[truncated N bytes]` marker, where N counts the dropped redacted\n * bytes.\n */\nexport function boundFailureReason(reason: string): string {\n const redacted = redact(reason);\n const bytes = encoder.encode(redacted);\n if (bytes.length <= TASK_FAIL_REASON_MAX_BYTES) return redacted;\n // Reserve the widest marker this input can need; the final one is no wider.\n let keep = TASK_FAIL_REASON_MAX_BYTES - encoder.encode(`\\u2026[truncated ${bytes.length} bytes]`).length;\n while (keep > 0 && ((bytes[keep] ?? 0) & 0xc0) === 0x80) keep -= 1;\n return `${decoder.decode(bytes.subarray(0, keep))}\\u2026[truncated ${bytes.length - keep} bytes]`;\n}\n","/** Schema-free protocol values. Import this entry when runtime schemas are unnecessary. */\nexport * from './version';\nexport * from './task-state';\nexport * from './capability-constants';\nexport * from './failure-reason';\n\n/** Maximum raw UTF-8 content bytes in one local Host Agent-memory export; no truncation. */\nexport const AGENT_MEMORY_MAX_SNAPSHOT_BYTES = 1024 * 1024;\n/** Maximum memory files in one local Host export, including MEMORY.md. */\nexport const AGENT_MEMORY_MAX_SNAPSHOT_FILES = 128;\n\n/** The frozen wire runtime ids. Any other adapter id is a custom harness (`harnessId`). */\nexport const RUNTIME_IDS = Object.freeze(['pi', 'claude', 'codex'] as const);\n\n/**\n * Why a runtime is unavailable before claim (#1103 D6). Append-only: a cause is\n * never renamed, removed or given a new meaning. The wire reads an unknown\n * well-formed token as `unknown` and keeps it verbatim (#1121), so a newer\n * device can add one without a protocol bump. Names are snake_case, unlike the\n * kebab-case detection kinds, because the mapping is explicit and never a\n * string transformation.\n */\nexport const RUNTIME_UNAVAILABLE_CAUSES = Object.freeze([\n /** Detection: `not-found`. */\n 'not_installed',\n /** Detection: `not-executable`. */\n 'not_executable',\n /** Detection: `timeout`. */\n 'probe_timeout',\n /** Detection: `probe-failed`. */\n 'probe_failed',\n /** Detection: `refused` / `app_server_unavailable`. */\n 'app_server_unavailable',\n /** Detection: `refused` / `acp_unavailable`. */\n 'acp_unavailable',\n /** Detection: `refused` / `platform_unsupported`. */\n 'platform_unsupported',\n /** The login-shell environment capture failed (#1095). */\n 'environment_unavailable',\n /** A Host-configured version policy blocked the installed token (#1103). */\n 'version_blocked',\n /** The offer named an id this daemon has no adapter for. */\n 'runtime_not_configured',\n /** The device runtime allowlist excludes the requested id. */\n 'runtime_not_allowed',\n /** Automatic selection exhausted every candidate. */\n 'none_available',\n] as const);\n\n/** One append-only `runtime_unavailable` cause. */\nexport type RuntimeUnavailableCause = (typeof RUNTIME_UNAVAILABLE_CAUSES)[number];\n\n/** Maximum length of a served model name. */\nexport const TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH = 160;\n"]}
|
package/dist/envelope.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ type EnvelopeShape<T extends MessageType, TaskId extends z.ZodTypeAny, Seq exten
|
|
|
31
31
|
* optional for daemon -> server types (M1 redelivery cursor; see
|
|
32
32
|
* `conn.hello.cursor` in `messages.ts`).
|
|
33
33
|
*/
|
|
34
|
-
export declare const EnvelopeSchema: z.ZodDiscriminatedUnion<[EnvelopeShape<"conn.hello", z.ZodOptional<z.ZodString>, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"
|
|
34
|
+
export declare const EnvelopeSchema: z.ZodDiscriminatedUnion<[EnvelopeShape<"conn.hello", z.ZodOptional<z.ZodString>, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"task.offer", z.ZodString, z.ZodNumber>, EnvelopeShape<"agent.egress.ack", z.ZodOptional<z.ZodString>, z.ZodNumber>, EnvelopeShape<"agent.message.disposition", z.ZodString, z.ZodNumber>, EnvelopeShape<"agent.content.read", z.ZodOptional<z.ZodString>, z.ZodNumber>, EnvelopeShape<"agent.home.projection", z.ZodOptional<z.ZodNever>, z.ZodNumber>, EnvelopeShape<"agent.input.preparation", z.ZodOptional<z.ZodNever>, z.ZodNumber>, EnvelopeShape<"provider.provisioning.available", z.ZodOptional<z.ZodNever>, z.ZodNumber>, EnvelopeShape<"agent.memory.intent.available", z.ZodOptional<z.ZodNever>, z.ZodNumber>, EnvelopeShape<"task.approve", z.ZodString, z.ZodNumber>, EnvelopeShape<"task.reject", z.ZodString, z.ZodNumber>, EnvelopeShape<"task.cancel", z.ZodString, z.ZodNumber>, EnvelopeShape<"task.steer", z.ZodString, z.ZodNumber>, EnvelopeShape<"e2ee.key_package.available", z.ZodOptional<z.ZodNever>, z.ZodNumber>, EnvelopeShape<"task.claim", z.ZodString, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"task.started", z.ZodString, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"task.decline", z.ZodString, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"task.progress", z.ZodString, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"task.artifact", z.ZodString, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"task.await_approval", z.ZodString, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"task.complete", z.ZodString, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"task.fail", z.ZodString, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"task.cancelled", z.ZodString, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"task.approval_resolved", z.ZodString, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"agent.egress.reliable", z.ZodOptional<z.ZodString>, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"agent.message.draft", z.ZodString, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"agent.message.publish", z.ZodString, z.ZodOptional<z.ZodNumber>>, EnvelopeShape<"agent.content.receipt", z.ZodOptional<z.ZodString>, z.ZodOptional<z.ZodNumber>>], "type">;
|
|
35
35
|
export type Envelope = z.infer<typeof EnvelopeSchema>;
|
|
36
36
|
/** `true` for every message type the server sends to the daemon (envelope `seq` is required for these). */
|
|
37
37
|
export declare function isServerToDaemonType(type: MessageType): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single authority for the display text of a `task.fail` `reason` (#1124).
|
|
3
|
+
*
|
|
4
|
+
* A runtime's stderr tail can carry credentials a runtime or proxy printed
|
|
5
|
+
* while failing. The `task.fail` schema applies this to `reason` on every
|
|
6
|
+
* parse, so `createEnvelope` bounds what a daemon sends (sealed or not) and
|
|
7
|
+
* every decode bounds what a receiver holds. The raw tail stays local, on the
|
|
8
|
+
* adapter's `RuntimeExecutionFailure`. The result is a fixed point: applying
|
|
9
|
+
* it to its own output changes nothing, so a bounded envelope round-trips
|
|
10
|
+
* byte-for-byte.
|
|
11
|
+
*
|
|
12
|
+
* Every pattern starts at a literal and its runs never backtrack into a
|
|
13
|
+
* failure, so the cost stays linear in the input length.
|
|
14
|
+
*/
|
|
15
|
+
/** Maximum UTF-8 bytes of a `task.fail` `reason` after normalization, truncation marker included. */
|
|
16
|
+
export declare const TASK_FAIL_REASON_MAX_BYTES = 2048;
|
|
17
|
+
/**
|
|
18
|
+
* Redact credentials from a failure reason, then cap it at
|
|
19
|
+
* {@link TASK_FAIL_REASON_MAX_BYTES} UTF-8 bytes on a code-point boundary
|
|
20
|
+
* with a `…[truncated N bytes]` marker, where N counts the dropped redacted
|
|
21
|
+
* bytes.
|
|
22
|
+
*/
|
|
23
|
+
export declare function boundFailureReason(reason: string): string;
|