@byok-sdk/protocol 0.26.0 → 0.27.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,3 +21,5 @@ import { encodeEnvelope, decodeEnvelope } from '@byok-sdk/protocol';
21
21
  ```
22
22
 
23
23
  MIT licensed. Node.js 24.15.0 or newer.
24
+
25
+ Runtime dependencies and size budgets: [entry dependency contract](../../README.md#entry-dependencies).
@@ -1,14 +1,4 @@
1
1
  import { z } from 'zod';
2
- /** Additive daemon capability names. Server/cloud admission consumes these exactly. */
3
- export declare const AGENT_EGRESS_POLICY_CAPABILITY: 'agent-egress-policy';
4
- export declare const AGENT_EGRESS_RELIABLE_ACK_CAPABILITY: 'agent-egress-reliable-ack';
5
- /** Admits the distinct offer whose runtime mints its session only after start. */
6
- export declare const AGENT_EGRESS_FRESH_SESSION_CAPABILITY: 'agent-egress-fresh-session';
7
- /** Admits the distinct Agent-authored message lane; activity policy remains independent. */
8
- export declare const AGENT_MESSAGE_EGRESS_CAPABILITY: 'agent-message-egress';
9
- export declare const AGENT_CONTENT_WORKSPACE_READ_CAPABILITY: 'agent-content-workspace-read';
10
- export declare const AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY: 'agent-content-transcript-read';
11
- export declare const AGENT_CONTENT_ARTIFACT_READ_CAPABILITY: 'agent-content-artifact-read';
12
2
  export declare const AGENT_MESSAGE_MAX_BYTES: number;
13
3
  export declare const AgentMessageContractSchema: z.ZodString;
14
4
  export declare const AgentMessageContentTypeSchema: z.ZodEnum<{
@@ -1,6 +1,4 @@
1
1
  import { z } from 'zod';
2
- /** Capability required before a task-free Agent-home projection is admitted. */
3
- export declare const AGENT_HOME_PROJECTION_CAPABILITY: 'agent-home-projection';
4
2
  /** Maximum UTF-8 encoded JSON bytes carried by one projection payload. */
5
3
  export declare const AGENT_HOME_PROJECTION_MAX_BYTES: number;
6
4
  /** PostgreSQL BIGINT maximum, kept as decimal text to avoid JavaScript precision loss. */
@@ -31,8 +31,6 @@ import { z } from 'zod';
31
31
  * `agentMemoryIntentOperationDigest(...)`, which a device recomputes with its
32
32
  * own enrolled tenant and device ids.
33
33
  */
34
- /** Device capability required before a Host may enqueue `agent.memory.intent.available`. */
35
- export declare const AGENT_MEMORY_INTENT_CAPABILITY: 'agent-memory-intent.v1';
36
34
  /** Maximum UTF-8 byte length of a released `replace` body (one memory file): 256 KiB. */
37
35
  export declare const AGENT_MEMORY_INTENT_CONTENT_MAX_BYTES = 262144;
38
36
  /** Maximum byte length of an intent `path` (ASCII, so bytes = characters). */
@@ -1,6 +1,4 @@
1
1
  import { z } from 'zod';
2
- /** Capability required before the optional hosted Agent-memory projection can be used. */
3
- export declare const AGENT_MEMORY_PROJECTION_CAPABILITY: 'agent.memory.projection';
4
2
  /** One hosted projection is bounded before it enters the redaction or storage seam. */
5
3
  export declare const AGENT_MEMORY_PROJECTION_MAX_REDACTED_BYTES: number;
6
4
  /** PostgreSQL `integer` ceiling shared by writer epochs and source sequences. */
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The ONE version of the input-preparation contract, shared by this relay wire
3
+ * (the `agent.input.preparation` payload and the completion receipt summary)
4
+ * and by the device-local request, receipt and artifact
5
+ * (`@byok-sdk/client`'s `INPUT_PREPARATION_VERSION`, which is this value).
6
+ *
7
+ * The relay wire carries no version field of its own, so a version change is
8
+ * made visible where admission actually happens: in the capability token
9
+ * below. See `INPUT_PREPARATION_VERSION` in the client for what each version
10
+ * changed.
11
+ */
12
+ export declare const INPUT_PREPARATION_WIRE_VERSION: 9;
13
+ /** Additive daemon capability names. Server/cloud admission consumes these exactly. */
14
+ export declare const AGENT_EGRESS_POLICY_CAPABILITY: 'agent-egress-policy';
15
+ export declare const AGENT_EGRESS_RELIABLE_ACK_CAPABILITY: 'agent-egress-reliable-ack';
16
+ /** Admits the distinct offer whose runtime mints its session only after start. */
17
+ export declare const AGENT_EGRESS_FRESH_SESSION_CAPABILITY: 'agent-egress-fresh-session';
18
+ /** Admits the distinct Agent-authored message lane; activity policy remains independent. */
19
+ export declare const AGENT_MESSAGE_EGRESS_CAPABILITY: 'agent-message-egress';
20
+ export declare const AGENT_CONTENT_WORKSPACE_READ_CAPABILITY: 'agent-content-workspace-read';
21
+ export declare const AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY: 'agent-content-transcript-read';
22
+ export declare const AGENT_CONTENT_ARTIFACT_READ_CAPABILITY: 'agent-content-artifact-read';
23
+ /** Capability required before a task-free Agent-home projection is admitted. */
24
+ export declare const AGENT_HOME_PROJECTION_CAPABILITY: 'agent-home-projection';
25
+ /** Capability required before an offer may select terminal projection behavior. */
26
+ export declare const TERMINAL_PROJECTION_SELECTION_CAPABILITY: 'terminal-projection-selection';
27
+ /** Contract §8.1's capability gate for `byok-task-assertion-v1` tool authority. */
28
+ export declare const HOST_MCP_TASK_CONTEXT_CAPABILITY: 'host-mcp-task-context';
29
+ /** Daemon capability required before an exact local provider profile may be offered. */
30
+ export declare const PROVIDER_PROFILE_BINDING_CAPABILITY: 'provider-profile-binding';
31
+ /** Device capability required before a Host may enqueue `provider.provisioning.available`. */
32
+ export declare const PROVIDER_PROVISIONING_CAPABILITY: 'provider-provisioning.v1';
33
+ /** Device capability required before a Host may enqueue `agent.memory.intent.available`. */
34
+ export declare const AGENT_MEMORY_INTENT_CAPABILITY: 'agent-memory-intent.v1';
35
+ /** Capability required before the optional hosted Agent-memory projection can be used. */
36
+ export declare const AGENT_MEMORY_PROJECTION_CAPABILITY: 'agent.memory.projection';
37
+ /** Exact capability of the single input-preparation wire authority. */
38
+ export declare const AGENT_INPUT_PREPARATION_CAPABILITY: "agent-input-preparation-v9";
39
+ /** Single value authority shared by schema validation and schema-free consumers. */
40
+ export declare const PREPARED_AGENT_MEMORY_MODES: readonly ['none', 'read', 'read-write'];
41
+ export declare function isPreparedAgentMemoryMode(value: unknown): value is (typeof PREPARED_AGENT_MEMORY_MODES)[number];
@@ -0,0 +1,4 @@
1
+ /** Schema-free protocol values. Import this entry when runtime schemas are unnecessary. */
2
+ export * from './version';
3
+ export * from './task-state';
4
+ export * from './capability-constants';
@@ -0,0 +1,84 @@
1
+ // src/capability-constants.ts
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_INPUT_PREPARATION_CAPABILITY = `agent-input-preparation-v${INPUT_PREPARATION_WIRE_VERSION}`;
18
+ var PREPARED_AGENT_MEMORY_MODES = ["none", "read", "read-write"];
19
+ function isPreparedAgentMemoryMode(value) {
20
+ return typeof value === "string" && PREPARED_AGENT_MEMORY_MODES.some((mode) => mode === value);
21
+ }
22
+
23
+ // src/version.ts
24
+ var MAILBOX_READ_AHEAD_MAX_SEQS = 4096;
25
+ var MAILBOX_READ_AHEAD_CAPABILITY = "mailbox-read-ahead";
26
+ var PROTOCOL_VERSION = 3;
27
+ var STRICT_AGENT_ONLY_CAPABILITY = "strict-agent-only";
28
+ var AGENT_HOME_READERS_CAPABILITY = "agent-home-readers";
29
+ var CUSTOM_HARNESS_CAPABILITY = "custom-harness";
30
+ var CAPABILITY_FLAGS = [
31
+ "steer",
32
+ "blob-upload",
33
+ "interactive-approval",
34
+ "approval_resolved",
35
+ "approval-targeting",
36
+ "dispatch-selection",
37
+ PROVIDER_PROFILE_BINDING_CAPABILITY,
38
+ "toolset-selection",
39
+ "agent-home-contract",
40
+ AGENT_HOME_READERS_CAPABILITY,
41
+ STRICT_AGENT_ONLY_CAPABILITY,
42
+ AGENT_EGRESS_POLICY_CAPABILITY,
43
+ AGENT_EGRESS_RELIABLE_ACK_CAPABILITY,
44
+ AGENT_MESSAGE_EGRESS_CAPABILITY,
45
+ AGENT_EGRESS_FRESH_SESSION_CAPABILITY,
46
+ AGENT_CONTENT_WORKSPACE_READ_CAPABILITY,
47
+ AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY,
48
+ AGENT_CONTENT_ARTIFACT_READ_CAPABILITY,
49
+ AGENT_HOME_PROJECTION_CAPABILITY,
50
+ AGENT_INPUT_PREPARATION_CAPABILITY,
51
+ TERMINAL_PROJECTION_SELECTION_CAPABILITY,
52
+ HOST_MCP_TASK_CONTEXT_CAPABILITY,
53
+ CUSTOM_HARNESS_CAPABILITY,
54
+ MAILBOX_READ_AHEAD_CAPABILITY,
55
+ PROVIDER_PROVISIONING_CAPABILITY,
56
+ AGENT_MEMORY_INTENT_CAPABILITY
57
+ ];
58
+
59
+ // src/task-state.ts
60
+ var TASK_STATES = [
61
+ "Offered",
62
+ "Claimed",
63
+ "Running",
64
+ "AwaitApproval",
65
+ "Complete",
66
+ "Failed",
67
+ "Cancelled"
68
+ ];
69
+ var TASK_TRANSITIONS = {
70
+ Offered: ["Claimed", "Cancelled", "Failed"],
71
+ Claimed: ["Running", "Failed", "Cancelled"],
72
+ Running: ["AwaitApproval", "Complete", "Failed", "Cancelled"],
73
+ AwaitApproval: ["Running", "Failed", "Cancelled"],
74
+ Complete: [],
75
+ Failed: [],
76
+ Cancelled: []
77
+ };
78
+ function canTransition(from, to) {
79
+ return TASK_TRANSITIONS[from].includes(to);
80
+ }
81
+
82
+ 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_PROJECTION_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, STRICT_AGENT_ONLY_CAPABILITY, TASK_STATES, TASK_TRANSITIONS, TERMINAL_PROJECTION_SELECTION_CAPABILITY, canTransition, isPreparedAgentMemoryMode };
83
+ //# sourceMappingURL=constants.js.map
84
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/capability-constants.ts","../src/version.ts","../src/task-state.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,GAAyC;AAG/C,IAAM,gCAAA,GAAmC;AAGzC,IAAM,wCAAA,GAA2C;AAGjD,IAAM,gCAAA,GAAmC;AAGzC,IAAM,mCAAA,GAAsC;AAG5C,IAAM,gCAAA,GAAmC;AAGzC,IAAM,8BAAA,GAAiC;AAGvC,IAAM,kCAAA,GAAqC;AAG3C,IAAM,kCAAA,GACX,4BAA4B,8BAA8B,CAAA;AAGrD,IAAM,2BAAA,GAA8B,CAAC,MAAA,EAAQ,MAAA,EAAQ,YAAY;AAEjE,SAAS,0BAA0B,KAAA,EAAuE;AAC/G,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,4BAA4B,IAAA,CAAK,CAAA,IAAA,KAAQ,SAAS,KAAK,CAAA;AAC7F;;;AC5DO,IAAM,2BAAA,GAA8B;AACpC,IAAM,6BAAA,GAAgC;AAgCtC,IAAM,gBAAA,GAAmB;AAGzB,IAAM,4BAAA,GAA+B;AASrC,IAAM,6BAAA,GAAgC;AA2DtC,IAAM,yBAAA,GAA4B;AAElC,IAAM,gBAAA,GAAmB;AAAA,EAC9B,OAAA;AAAA,EACA,aAAA;AAAA,EACA,sBAAA;AAAA,EACA,mBAAA;AAAA,EACA,oBAAA;AAAA,EACA,oBAAA;AAAA,EACA,mCAAA;AAAA,EACA,mBAAA;AAAA,EACA,qBAAA;AAAA,EACA,6BAAA;AAAA,EACA,4BAAA;AAAA,EACA,8BAAA;AAAA,EACA,oCAAA;AAAA,EACA,+BAAA;AAAA,EACA,qCAAA;AAAA,EACA,uCAAA;AAAA,EACA,wCAAA;AAAA,EACA,sCAAA;AAAA,EACA,gCAAA;AAAA,EACA,kCAAA;AAAA,EACA,wCAAA;AAAA,EACA,gCAAA;AAAA,EACA,yBAAA;AAAA,EACA,6BAAA;AAAA,EACA,gCAAA;AAAA,EACA;AACF;;;ACtIO,IAAM,WAAA,GAAc;AAAA,EACzB,SAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,eAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF;AAoBO,IAAM,gBAAA,GAAsE;AAAA,EACjF,OAAA,EAAS,CAAC,SAAA,EAAW,WAAA,EAAa,QAAQ,CAAA;AAAA,EAC1C,OAAA,EAAS,CAAC,SAAA,EAAW,QAAA,EAAU,WAAW,CAAA;AAAA,EAC1C,OAAA,EAAS,CAAC,eAAA,EAAiB,UAAA,EAAY,UAAU,WAAW,CAAA;AAAA,EAC5D,aAAA,EAAe,CAAC,SAAA,EAAW,QAAA,EAAU,WAAW,CAAA;AAAA,EAChD,UAAU,EAAC;AAAA,EACX,QAAQ,EAAC;AAAA,EACT,WAAW;AACb;AAGO,SAAS,aAAA,CAAc,MAAiB,EAAA,EAAwB;AACrE,EAAA,OAAO,gBAAA,CAAiB,IAAI,CAAA,CAAE,QAAA,CAAS,EAAE,CAAA;AAC3C","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/** 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/** 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 exchanged during the connection handshake (`conn.hello` /\n * `conn.ack`). Additional flags may be introduced without a protocol version\n * bump; unrecognized flags 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 * `CAPABILITY_FLAGS`/`conn.ack.capabilities` never includes it, so a new\n * daemon talking to an old server never sends `task.approval_resolved` at\n * all (see `packages/client`'s `task-runner.ts`) and falls back to the\n * pre-existing implicit-resume inference\n * (`ConnectionHub.resumeIfImplicitlyApproved`, `packages/server/src/hub.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 `ConnectionHub.approveTask`/`rejectTask`/\n * `onApprovalResolved` and `TaskRunner.handleApprove`/`handleReject`\n * (`packages/client`'s `task-runner.ts`). This flag exists only so each side\n * can advertise, and an embedder/operator can observe (`ConnectionHub.\n * getDeviceCapabilities`), whether the OTHER side is new enough to\n * participate in targeting at all -- the same N/N-1-safe shape as every\n * other 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] 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_INPUT_PREPARATION_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"]}
@@ -247,6 +247,7 @@ export declare const EnvelopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
247
247
  }, z.core.$strict>, z.ZodObject<{
248
248
  mode: z.ZodLiteral<"result-document">;
249
249
  contract: z.ZodString;
250
+ schema: z.ZodCustom<import("./result-schema").ResultSchema, import("./result-schema").ResultSchema>;
250
251
  }, z.core.$strict>], "mode">>;
251
252
  sessionRef: z.ZodOptional<z.ZodString>;
252
253
  limits: z.ZodOptional<z.ZodObject<{
@@ -315,6 +316,7 @@ export declare const EnvelopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
315
316
  }, z.core.$strict>, z.ZodObject<{
316
317
  mode: z.ZodLiteral<"result-document">;
317
318
  contract: z.ZodString;
319
+ schema: z.ZodCustom<import("./result-schema").ResultSchema, import("./result-schema").ResultSchema>;
318
320
  }, z.core.$strict>], "mode">>;
319
321
  limits: z.ZodOptional<z.ZodObject<{
320
322
  maxDurationMs: z.ZodOptional<z.ZodNumber>;
@@ -419,6 +421,7 @@ export declare const EnvelopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
419
421
  }, z.core.$strict>, z.ZodObject<{
420
422
  mode: z.ZodLiteral<"result-document">;
421
423
  contract: z.ZodString;
424
+ schema: z.ZodCustom<import("./result-schema").ResultSchema, import("./result-schema").ResultSchema>;
422
425
  }, z.core.$strict>], "mode">>;
423
426
  limits: z.ZodOptional<z.ZodObject<{
424
427
  maxDurationMs: z.ZodOptional<z.ZodNumber>;
@@ -513,6 +516,7 @@ export declare const EnvelopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
513
516
  }, z.core.$strict>, z.ZodObject<{
514
517
  mode: z.ZodLiteral<"result-document">;
515
518
  contract: z.ZodString;
519
+ schema: z.ZodCustom<import("./result-schema").ResultSchema, import("./result-schema").ResultSchema>;
516
520
  }, z.core.$strict>], "mode">>;
517
521
  limits: z.ZodOptional<z.ZodObject<{
518
522
  maxDurationMs: z.ZodOptional<z.ZodNumber>;
@@ -921,6 +925,10 @@ export declare const EnvelopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
921
925
  agentId: z.ZodString;
922
926
  profileRevision: z.ZodString;
923
927
  }, z.core.$strict>>;
928
+ code: z.ZodOptional<z.ZodEnum<{
929
+ agent_home_reader_busy: "agent_home_reader_busy";
930
+ agent_home_writer_busy: "agent_home_writer_busy";
931
+ }>>;
924
932
  }, z.core.$strip>;
925
933
  }, z.core.$strip>, z.ZodObject<{
926
934
  v: z.ZodNumber;