@byok-sdk/protocol 0.13.0 → 0.14.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.
@@ -1,4 +1,62 @@
1
1
  import { z } from 'zod';
2
+ /**
3
+ * Maximum UTF-16 length of {@link AgentEventSpillSchema}'s `unstoredReason`.
4
+ * The reason is a bounded diagnostic string, not a place to inline the
5
+ * content that failed to store: the whole point of a spill descriptor is
6
+ * that the event stays under the daemon's inline-event cap even when the
7
+ * blob upload failed.
8
+ */
9
+ export declare const AGENT_EVENT_SPILL_UNSTORED_REASON_MAX_LENGTH = 512;
10
+ /**
11
+ * Additive descriptor attached to a `tool_use` / `tool_result` event whose
12
+ * `input` / `output` was too large to travel inline and was therefore
13
+ * REPLACED, at the daemon's ingestion boundary, by a bounded head/tail
14
+ * preview (`{ preview: { head, tail } }`). See
15
+ * `packages/client/src/daemon/event-spill.ts` for the producer and
16
+ * `DaemonConfig.maxInlineEventBytes` for the cap.
17
+ *
18
+ * Presence of this field is the ONLY signal that the inline field is a
19
+ * projection rather than the whole value — a consumer that reads
20
+ * `tool_result.output` (or `tool_use.input`) without checking `spill` is
21
+ * reading a preview and calling it the result.
22
+ *
23
+ * Exactly one of `blob` / `unstoredReason` is present, and the union is
24
+ * closed on purpose:
25
+ *
26
+ * - `blob` — the full `JSON.stringify(<field>)` bytes are readable from the
27
+ * blob plane (protocol §7) under that `BlobRef`; `contentHash` is the
28
+ * sha256 of exactly those bytes, so a consumer can verify what it read
29
+ * back is what was omitted.
30
+ * - `unstoredReason` — the omitted bytes are not readable from this event:
31
+ * either the upload failed, or it succeeded but the returned locator did
32
+ * not fit the daemon's inline cap. Either way the content is not reachable
33
+ * through this event; the reason says which. This exists so an unreadable
34
+ * omission is observable rather than silently indistinguishable from a
35
+ * small output.
36
+ *
37
+ * `.strict()` because this is an SDK-authored descriptor with a closed
38
+ * shape, not free-form runtime data: an unrecognized key here means a
39
+ * producer and a consumer disagree about what the omission means, which is
40
+ * exactly the case that must fail loudly.
41
+ */
42
+ export declare const AgentEventSpillSchema: z.ZodObject<{
43
+ field: z.ZodEnum<{
44
+ input: "input";
45
+ output: "output";
46
+ }>;
47
+ totalBytes: z.ZodNumber;
48
+ omittedBytes: z.ZodNumber;
49
+ contentType: z.ZodLiteral<"application/json">;
50
+ blob: z.ZodOptional<z.ZodObject<{
51
+ blobId: z.ZodString;
52
+ contentHash: z.ZodString;
53
+ size: z.ZodNumber;
54
+ contentType: z.ZodString;
55
+ url: z.ZodOptional<z.ZodString>;
56
+ }, z.core.$strip>>;
57
+ unstoredReason: z.ZodOptional<z.ZodString>;
58
+ }, z.core.$strict>;
59
+ export type AgentEventSpill = z.infer<typeof AgentEventSpillSchema>;
2
60
  /**
3
61
  * Normalized event shape that every runtime adapter (pi / claude / codex)
4
62
  * translates its native JSONL output into. This is the interior of a
@@ -12,12 +70,46 @@ export declare const AgentEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
12
70
  tool: z.ZodString;
13
71
  input: z.ZodOptional<z.ZodUnknown>;
14
72
  toolCallId: z.ZodOptional<z.ZodString>;
73
+ spill: z.ZodOptional<z.ZodObject<{
74
+ field: z.ZodEnum<{
75
+ input: "input";
76
+ output: "output";
77
+ }>;
78
+ totalBytes: z.ZodNumber;
79
+ omittedBytes: z.ZodNumber;
80
+ contentType: z.ZodLiteral<"application/json">;
81
+ blob: z.ZodOptional<z.ZodObject<{
82
+ blobId: z.ZodString;
83
+ contentHash: z.ZodString;
84
+ size: z.ZodNumber;
85
+ contentType: z.ZodString;
86
+ url: z.ZodOptional<z.ZodString>;
87
+ }, z.core.$strip>>;
88
+ unstoredReason: z.ZodOptional<z.ZodString>;
89
+ }, z.core.$strict>>;
15
90
  }, z.core.$strip>, z.ZodObject<{
16
91
  type: z.ZodLiteral<"tool_result">;
17
92
  tool: z.ZodString;
18
93
  output: z.ZodOptional<z.ZodUnknown>;
19
94
  toolCallId: z.ZodOptional<z.ZodString>;
20
95
  isError: z.ZodOptional<z.ZodBoolean>;
96
+ spill: z.ZodOptional<z.ZodObject<{
97
+ field: z.ZodEnum<{
98
+ input: "input";
99
+ output: "output";
100
+ }>;
101
+ totalBytes: z.ZodNumber;
102
+ omittedBytes: z.ZodNumber;
103
+ contentType: z.ZodLiteral<"application/json">;
104
+ blob: z.ZodOptional<z.ZodObject<{
105
+ blobId: z.ZodString;
106
+ contentHash: z.ZodString;
107
+ size: z.ZodNumber;
108
+ contentType: z.ZodString;
109
+ url: z.ZodOptional<z.ZodString>;
110
+ }, z.core.$strip>>;
111
+ unstoredReason: z.ZodOptional<z.ZodString>;
112
+ }, z.core.$strict>>;
21
113
  }, z.core.$strip>, z.ZodObject<{
22
114
  type: z.ZodLiteral<"artifact">;
23
115
  name: z.ZodString;
@@ -106,12 +198,46 @@ export declare const AgentEventOrUnknownSchema: z.ZodUnion<readonly [z.ZodDiscri
106
198
  tool: z.ZodString;
107
199
  input: z.ZodOptional<z.ZodUnknown>;
108
200
  toolCallId: z.ZodOptional<z.ZodString>;
201
+ spill: z.ZodOptional<z.ZodObject<{
202
+ field: z.ZodEnum<{
203
+ input: "input";
204
+ output: "output";
205
+ }>;
206
+ totalBytes: z.ZodNumber;
207
+ omittedBytes: z.ZodNumber;
208
+ contentType: z.ZodLiteral<"application/json">;
209
+ blob: z.ZodOptional<z.ZodObject<{
210
+ blobId: z.ZodString;
211
+ contentHash: z.ZodString;
212
+ size: z.ZodNumber;
213
+ contentType: z.ZodString;
214
+ url: z.ZodOptional<z.ZodString>;
215
+ }, z.core.$strip>>;
216
+ unstoredReason: z.ZodOptional<z.ZodString>;
217
+ }, z.core.$strict>>;
109
218
  }, z.core.$strip>, z.ZodObject<{
110
219
  type: z.ZodLiteral<"tool_result">;
111
220
  tool: z.ZodString;
112
221
  output: z.ZodOptional<z.ZodUnknown>;
113
222
  toolCallId: z.ZodOptional<z.ZodString>;
114
223
  isError: z.ZodOptional<z.ZodBoolean>;
224
+ spill: z.ZodOptional<z.ZodObject<{
225
+ field: z.ZodEnum<{
226
+ input: "input";
227
+ output: "output";
228
+ }>;
229
+ totalBytes: z.ZodNumber;
230
+ omittedBytes: z.ZodNumber;
231
+ contentType: z.ZodLiteral<"application/json">;
232
+ blob: z.ZodOptional<z.ZodObject<{
233
+ blobId: z.ZodString;
234
+ contentHash: z.ZodString;
235
+ size: z.ZodNumber;
236
+ contentType: z.ZodString;
237
+ url: z.ZodOptional<z.ZodString>;
238
+ }, z.core.$strip>>;
239
+ unstoredReason: z.ZodOptional<z.ZodString>;
240
+ }, z.core.$strict>>;
115
241
  }, z.core.$strip>, z.ZodObject<{
116
242
  type: z.ZodLiteral<"artifact">;
117
243
  name: z.ZodString;
@@ -736,12 +736,46 @@ export declare const EnvelopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
736
736
  tool: z.ZodString;
737
737
  input: z.ZodOptional<z.ZodUnknown>;
738
738
  toolCallId: z.ZodOptional<z.ZodString>;
739
+ spill: z.ZodOptional<z.ZodObject<{
740
+ field: z.ZodEnum<{
741
+ input: "input";
742
+ output: "output";
743
+ }>;
744
+ totalBytes: z.ZodNumber;
745
+ omittedBytes: z.ZodNumber;
746
+ contentType: z.ZodLiteral<"application/json">;
747
+ blob: z.ZodOptional<z.ZodObject<{
748
+ blobId: z.ZodString;
749
+ contentHash: z.ZodString;
750
+ size: z.ZodNumber;
751
+ contentType: z.ZodString;
752
+ url: z.ZodOptional<z.ZodString>;
753
+ }, z.core.$strip>>;
754
+ unstoredReason: z.ZodOptional<z.ZodString>;
755
+ }, z.core.$strict>>;
739
756
  }, z.core.$strip>, z.ZodObject<{
740
757
  type: z.ZodLiteral<"tool_result">;
741
758
  tool: z.ZodString;
742
759
  output: z.ZodOptional<z.ZodUnknown>;
743
760
  toolCallId: z.ZodOptional<z.ZodString>;
744
761
  isError: z.ZodOptional<z.ZodBoolean>;
762
+ spill: z.ZodOptional<z.ZodObject<{
763
+ field: z.ZodEnum<{
764
+ input: "input";
765
+ output: "output";
766
+ }>;
767
+ totalBytes: z.ZodNumber;
768
+ omittedBytes: z.ZodNumber;
769
+ contentType: z.ZodLiteral<"application/json">;
770
+ blob: z.ZodOptional<z.ZodObject<{
771
+ blobId: z.ZodString;
772
+ contentHash: z.ZodString;
773
+ size: z.ZodNumber;
774
+ contentType: z.ZodString;
775
+ url: z.ZodOptional<z.ZodString>;
776
+ }, z.core.$strip>>;
777
+ unstoredReason: z.ZodOptional<z.ZodString>;
778
+ }, z.core.$strict>>;
745
779
  }, z.core.$strip>, z.ZodObject<{
746
780
  type: z.ZodLiteral<"artifact">;
747
781
  name: z.ZodString;
@@ -829,12 +829,46 @@ export declare const EventsPollResponseSchema: z.ZodObject<{
829
829
  tool: z.ZodString;
830
830
  input: z.ZodOptional<z.ZodUnknown>;
831
831
  toolCallId: z.ZodOptional<z.ZodString>;
832
+ spill: z.ZodOptional<z.ZodObject<{
833
+ field: z.ZodEnum<{
834
+ input: "input";
835
+ output: "output";
836
+ }>;
837
+ totalBytes: z.ZodNumber;
838
+ omittedBytes: z.ZodNumber;
839
+ contentType: z.ZodLiteral<"application/json">;
840
+ blob: z.ZodOptional<z.ZodObject<{
841
+ blobId: z.ZodString;
842
+ contentHash: z.ZodString;
843
+ size: z.ZodNumber;
844
+ contentType: z.ZodString;
845
+ url: z.ZodOptional<z.ZodString>;
846
+ }, z.core.$strip>>;
847
+ unstoredReason: z.ZodOptional<z.ZodString>;
848
+ }, z.core.$strict>>;
832
849
  }, z.core.$strip>, z.ZodObject<{
833
850
  type: z.ZodLiteral<"tool_result">;
834
851
  tool: z.ZodString;
835
852
  output: z.ZodOptional<z.ZodUnknown>;
836
853
  toolCallId: z.ZodOptional<z.ZodString>;
837
854
  isError: z.ZodOptional<z.ZodBoolean>;
855
+ spill: z.ZodOptional<z.ZodObject<{
856
+ field: z.ZodEnum<{
857
+ input: "input";
858
+ output: "output";
859
+ }>;
860
+ totalBytes: z.ZodNumber;
861
+ omittedBytes: z.ZodNumber;
862
+ contentType: z.ZodLiteral<"application/json">;
863
+ blob: z.ZodOptional<z.ZodObject<{
864
+ blobId: z.ZodString;
865
+ contentHash: z.ZodString;
866
+ size: z.ZodNumber;
867
+ contentType: z.ZodString;
868
+ url: z.ZodOptional<z.ZodString>;
869
+ }, z.core.$strip>>;
870
+ unstoredReason: z.ZodOptional<z.ZodString>;
871
+ }, z.core.$strict>>;
838
872
  }, z.core.$strip>, z.ZodObject<{
839
873
  type: z.ZodLiteral<"artifact">;
840
874
  name: z.ZodString;
@@ -1899,12 +1933,46 @@ export declare const MessagesSendRequestSchema: z.ZodObject<{
1899
1933
  tool: z.ZodString;
1900
1934
  input: z.ZodOptional<z.ZodUnknown>;
1901
1935
  toolCallId: z.ZodOptional<z.ZodString>;
1936
+ spill: z.ZodOptional<z.ZodObject<{
1937
+ field: z.ZodEnum<{
1938
+ input: "input";
1939
+ output: "output";
1940
+ }>;
1941
+ totalBytes: z.ZodNumber;
1942
+ omittedBytes: z.ZodNumber;
1943
+ contentType: z.ZodLiteral<"application/json">;
1944
+ blob: z.ZodOptional<z.ZodObject<{
1945
+ blobId: z.ZodString;
1946
+ contentHash: z.ZodString;
1947
+ size: z.ZodNumber;
1948
+ contentType: z.ZodString;
1949
+ url: z.ZodOptional<z.ZodString>;
1950
+ }, z.core.$strip>>;
1951
+ unstoredReason: z.ZodOptional<z.ZodString>;
1952
+ }, z.core.$strict>>;
1902
1953
  }, z.core.$strip>, z.ZodObject<{
1903
1954
  type: z.ZodLiteral<"tool_result">;
1904
1955
  tool: z.ZodString;
1905
1956
  output: z.ZodOptional<z.ZodUnknown>;
1906
1957
  toolCallId: z.ZodOptional<z.ZodString>;
1907
1958
  isError: z.ZodOptional<z.ZodBoolean>;
1959
+ spill: z.ZodOptional<z.ZodObject<{
1960
+ field: z.ZodEnum<{
1961
+ input: "input";
1962
+ output: "output";
1963
+ }>;
1964
+ totalBytes: z.ZodNumber;
1965
+ omittedBytes: z.ZodNumber;
1966
+ contentType: z.ZodLiteral<"application/json">;
1967
+ blob: z.ZodOptional<z.ZodObject<{
1968
+ blobId: z.ZodString;
1969
+ contentHash: z.ZodString;
1970
+ size: z.ZodNumber;
1971
+ contentType: z.ZodString;
1972
+ url: z.ZodOptional<z.ZodString>;
1973
+ }, z.core.$strip>>;
1974
+ unstoredReason: z.ZodOptional<z.ZodString>;
1975
+ }, z.core.$strict>>;
1908
1976
  }, z.core.$strip>, z.ZodObject<{
1909
1977
  type: z.ZodLiteral<"artifact">;
1910
1978
  name: z.ZodString;
package/dist/index.d.ts CHANGED
@@ -6,8 +6,8 @@ export { PermissionPolicySchema, PERMISSION_MODES } from './permission';
6
6
  export type { PermissionPolicy, PermissionMode } from './permission';
7
7
  export { PROVIDER_PROFILE_BINDING_CAPABILITY, PROVIDER_MODEL_CAPABILITIES, ProviderProfileRefSchema, ProviderProfileRevisionSchema, ProviderProfileHashSchema, ProviderModelCapabilitySchema, ProviderProfileBindingSchema, } from './provider-profile-binding';
8
8
  export type { ProviderProfileRef, ProviderProfileRevision, ProviderProfileHash, ProviderModelCapability, ProviderProfileBinding, } from './provider-profile-binding';
9
- export { AgentEventSchema, UnknownAgentEventSchema, AgentEventOrUnknownSchema, KNOWN_AGENT_EVENT_TYPES, isKnownAgentEvent, partitionAgentEvents, } from './agent-event';
10
- export type { AgentEvent, UnknownAgentEvent, AgentEventOrUnknown } from './agent-event';
9
+ export { AgentEventSchema, AgentEventSpillSchema, AGENT_EVENT_SPILL_UNSTORED_REASON_MAX_LENGTH, UnknownAgentEventSchema, AgentEventOrUnknownSchema, KNOWN_AGENT_EVENT_TYPES, isKnownAgentEvent, partitionAgentEvents, } from './agent-event';
10
+ export type { AgentEvent, AgentEventSpill, UnknownAgentEvent, AgentEventOrUnknown } from './agent-event';
11
11
  export { AgentEgressPolicySchema, AgentEgressActivityPolicySchema, AgentReliableQuotaPolicySchema, ContentReadPolicySchema, AgentEgressLaneSchema, AgentEgressDropReasonSchema, AgentContentReadSurfaceSchema, AgentContentActorKindSchema, AgentContentActorSchema, AgentContentDecodeAsSchema, AgentContentMimeTypeSchema, AgentContentReadDecisionSchema, AgentContentReadDenialReasonSchema, AgentEgressContentHashSchema, AgentEgressPolicyRevisionSchema, AgentMessageContractSchema, AgentMessageContentTypeSchema, AgentMessageDestinationBindingSchema, AgentMessageFreshnessCursorSchema, AgentMessageServerContextSchema, AgentMessageEgressRequirementSchema, AGENT_MESSAGE_MAX_BYTES, AGENT_MESSAGE_EGRESS_CAPABILITY, AGENT_EGRESS_POLICY_CAPABILITY, AGENT_EGRESS_RELIABLE_ACK_CAPABILITY, AGENT_EGRESS_FRESH_SESSION_CAPABILITY, AGENT_CONTENT_WORKSPACE_READ_CAPABILITY, AGENT_CONTENT_TRANSCRIPT_READ_CAPABILITY, AGENT_CONTENT_ARTIFACT_READ_CAPABILITY, } from './agent-egress';
12
12
  export type { AgentEgressPolicy, AgentEgressActivityPolicy, AgentReliableQuotaPolicy, ContentReadPolicy, AgentEgressLane, AgentEgressDropReason, AgentMessageContentType, AgentMessageEgressRequirement, AgentMessageServerContext, AgentContentReadSurface, AgentContentActorKind, AgentContentActor, AgentContentDecodeAs, AgentContentReadDecision, AgentContentReadDenialReason, } from './agent-egress';
13
13
  export { AGENT_HOME_PROJECTION_CAPABILITY, AGENT_HOME_PROJECTION_MAX_BYTES, AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM, AgentHomeProjectionProfileRevisionSchema, AgentHomeProjectionHashSchema, AgentHomeProjectionOutcomeSchema, AgentHomeProjectionValueSchema, } from './agent-home-projection';
@@ -18,7 +18,7 @@ export { TERMINAL_PROJECTION_SELECTION_CAPABILITY, TerminalProjectionContractSch
18
18
  export type { TerminalProjectionSelection } from './terminal-projection';
19
19
  export { TASK_STATES, TASK_TRANSITIONS, canTransition } from './task-state';
20
20
  export type { TaskState } from './task-state';
21
- export { MESSAGE_TYPES, MESSAGE_PAYLOAD_SCHEMAS, SERVER_TO_DAEMON_TYPES, DAEMON_TO_SERVER_TYPES, RuntimeIdSchema, ProtocolVersionNumberSchema, RuntimeInfoSchema, RuntimeCapabilitiesSchema, AgentRefSchema, AgentHomeProjectionAgentRefSchema, AGENT_REF_MAX_BYTES, DispatchSelectionSchema, ToolsetIdSchema, ConfiguredToolsetsSchema, RequiredToolsetsSchema, CONFIGURED_TOOLSETS_MAX_ITEMS, ConnHelloPayloadSchema, ConnAckPayloadSchema, TaskOfferPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, AgentEgressReliablePayloadSchema, AgentEgressAckPayloadSchema, AgentMessagePublishPayloadSchema, AgentMessageDispositionPayloadSchema, AgentContentReadPayloadSchema, AgentContentReceiptPayloadSchema, AgentHomeProjectionPayloadSchema, TaskApprovePayloadSchema, TaskRejectPayloadSchema, TaskCancelPayloadSchema, TaskSteerPayloadSchema, TaskClaimPayloadSchema, TaskStartedPayloadSchema, TaskDeclinePayloadSchema, TaskProgressPayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCompletePayloadSchema, TaskFailPayloadSchema, TaskCancelledPayloadSchema, TaskApprovalResolvedPayloadSchema, RESULT_DOCUMENT_MAX_BYTES, checkResultDocument, TerminalInferenceUsageSchema, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, } from './messages';
21
+ export { MESSAGE_TYPES, TASK_OFFER_TYPES, isTaskOfferType, MESSAGE_PAYLOAD_SCHEMAS, SERVER_TO_DAEMON_TYPES, DAEMON_TO_SERVER_TYPES, RuntimeIdSchema, ProtocolVersionNumberSchema, RuntimeInfoSchema, RuntimeCapabilitiesSchema, AgentRefSchema, AgentHomeProjectionAgentRefSchema, AGENT_REF_MAX_BYTES, DispatchSelectionSchema, ToolsetIdSchema, ConfiguredToolsetsSchema, RequiredToolsetsSchema, CONFIGURED_TOOLSETS_MAX_ITEMS, ConnHelloPayloadSchema, ConnAckPayloadSchema, TaskOfferPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, AgentEgressReliablePayloadSchema, AgentEgressAckPayloadSchema, AgentMessagePublishPayloadSchema, AgentMessageDispositionPayloadSchema, AgentContentReadPayloadSchema, AgentContentReceiptPayloadSchema, AgentHomeProjectionPayloadSchema, TaskApprovePayloadSchema, TaskRejectPayloadSchema, TaskCancelPayloadSchema, TaskSteerPayloadSchema, TaskClaimPayloadSchema, TaskStartedPayloadSchema, TaskDeclinePayloadSchema, TaskProgressPayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCompletePayloadSchema, TaskFailPayloadSchema, TaskCancelledPayloadSchema, TaskApprovalResolvedPayloadSchema, RESULT_DOCUMENT_MAX_BYTES, checkResultDocument, TerminalInferenceUsageSchema, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, } from './messages';
22
22
  export type { ResultDocumentCheck, MessageType, RuntimeId, RuntimeInfo, RuntimeCapabilities, AgentRef, AgentHomeProjectionAgentRef, DispatchSelection, ToolsetId, ConnHelloPayload, ConnAckPayload, TaskOfferPayload, TaskOfferWithToolsetsPayload, TaskOfferForAgentPayload, TaskOfferForAgentWithEgressPayload, TaskOfferForAgentWithEgressFreshPayload, AgentEgressReliablePayload, AgentEgressAckPayload, AgentMessagePublishPayload, AgentMessageDispositionPayload, AgentContentReadPayload, AgentContentReceiptPayload, AgentHomeProjectionPayload, TaskApprovePayload, TaskRejectPayload, TaskCancelPayload, TaskSteerPayload, TaskClaimPayload, TaskStartedPayload, TaskDeclinePayload, TaskProgressPayload, TaskArtifactPayload, TaskAwaitApprovalPayload, TaskCompletePayload, TaskFailPayload, TaskCancelledPayload, TaskApprovalResolvedPayload, TerminalInferenceUsage, } from './messages';
23
23
  export { EnvelopeSchema, isServerToDaemonType } from './envelope';
24
24
  export type { Envelope } from './envelope';
@@ -27,3 +27,4 @@ export { encodeEnvelope, decodeEnvelope, createEnvelope, parseMessage } from './
27
27
  export type { CreateEnvelopeOptions } from './codec';
28
28
  export { PairRequestSchema, PairResponseTenantIdSchema, PAIR_RESPONSE_TENANT_ID_MAX_LENGTH, PairResponseSchema, ChallengeRequestSchema, ChallengeResponseSchema, TokenRequestSchema, TokenResponseSchema, PresencePublishRequestSchema, CreateBlobRequestSchema, CreateBlobResponseSchema, BlobDownloadUrlResponseSchema, EventsPollQuerySchema, EventsPollResponseSchema, MessagesSendRequestSchema, MessagesSendResponseSchema, AgentHomeProjectionCompletionRequestSchema, AgentHomeProjectionStatusSchema, AgentHomeProjectionReadbackSchema, AgentMemoryProjectionCommitRequestSchema, AgentMemoryProjectionCommitResponseSchema, MAX_MESSAGES_PER_BATCH, BYOK_PAIR_PATH, BYOK_CHALLENGE_PATH, BYOK_TOKEN_PATH, BYOK_CAPABILITIES_PATH, BYOK_EVENTS_PATH, BYOK_MESSAGES_PATH, BYOK_AGENT_HOME_PROJECTIONS_PATH, BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE, byokAgentHomeProjectionCompletionPath, BYOK_AGENT_MEMORY_PROJECTIONS_PATH, BYOK_PRESENCE_PATH, BYOK_ACTIVITY_PATH, BYOK_BOARD_PATH, BYOK_BOARD_STREAM_PATH, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_BOARD_STATUS_ROUTE, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, byokRecordPath, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, byokSkillPackFilePath, BYOK_BLOBS_PATH, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BLOB_CONTENT_ROUTE, byokBlobFinalizePath, byokBlobUrlPath, byokBlobContentPath, } from './http-api';
29
29
  export type { PairRequest, PairResponse, ChallengeRequest, ChallengeResponse, TokenRequest, TokenResponse, PresencePublishRequest, CreateBlobRequest, CreateBlobResponse, BlobDownloadUrlResponse, EventsPollQuery, EventsPollResponse, MessagesSendRequest, MessagesSendResponse, AgentHomeProjectionCompletionRequest, AgentHomeProjectionStatus, AgentHomeProjectionReadback, AgentMemoryProjectionCommitRequest, AgentMemoryProjectionCommitResponse, } from './http-api';
30
+ export type { TaskOfferType } from './messages';
package/dist/index.js CHANGED
@@ -181,20 +181,42 @@ var PermissionPolicySchema = z.object({
181
181
  workspaceRoot: z.string().optional(),
182
182
  network: z.boolean().optional()
183
183
  }).strict();
184
+ var AGENT_EVENT_SPILL_UNSTORED_REASON_MAX_LENGTH = 512;
185
+ var AgentEventSpillSchema = z.object({
186
+ /** Which field of the event was replaced by a preview. */
187
+ field: z.enum(["input", "output"]),
188
+ /** UTF-8 byte length of the full `JSON.stringify(<field>)` that was spilled. */
189
+ totalBytes: z.number().int().nonnegative(),
190
+ /** `totalBytes` minus the UTF-8 bytes of the retained preview head + tail. */
191
+ omittedBytes: z.number().int().nonnegative(),
192
+ /** Always the JSON serialization of the field — never the tool's own notion of a content type. */
193
+ contentType: z.literal("application/json"),
194
+ /** Where the omitted bytes are readable. Mutually exclusive with `unstoredReason`. */
195
+ blob: BlobRefSchema.optional(),
196
+ /** Why the omitted bytes are NOT readable. Mutually exclusive with `blob`. */
197
+ unstoredReason: z.string().min(1).max(AGENT_EVENT_SPILL_UNSTORED_REASON_MAX_LENGTH).optional()
198
+ }).strict().refine(
199
+ (spill) => spill.blob === void 0 !== (spill.unstoredReason === void 0),
200
+ "spill must carry exactly one of blob (the omitted bytes are readable) or unstoredReason (they are not)"
201
+ );
184
202
  var AgentEventSchema = z.discriminatedUnion("type", [
185
203
  z.object({ type: z.literal("progress"), text: z.string() }),
186
204
  z.object({
187
205
  type: z.literal("tool_use"),
188
206
  tool: z.string(),
189
207
  input: z.unknown().optional(),
190
- toolCallId: z.string().regex(/\S/, "toolCallId must contain a non-whitespace character").optional()
208
+ toolCallId: z.string().regex(/\S/, "toolCallId must contain a non-whitespace character").optional(),
209
+ /** Present only when `input` is a preview of a spilled value — see {@link AgentEventSpillSchema}. */
210
+ spill: AgentEventSpillSchema.optional()
191
211
  }),
192
212
  z.object({
193
213
  type: z.literal("tool_result"),
194
214
  tool: z.string(),
195
215
  output: z.unknown().optional(),
196
216
  toolCallId: z.string().regex(/\S/, "toolCallId must contain a non-whitespace character").optional(),
197
- isError: z.boolean().optional()
217
+ isError: z.boolean().optional(),
218
+ /** Present only when `output` is a preview of a spilled value — see {@link AgentEventSpillSchema}. */
219
+ spill: AgentEventSpillSchema.optional()
198
220
  }),
199
221
  z.object({ type: z.literal("artifact"), name: z.string(), contentType: z.string() }),
200
222
  z.object({ type: z.literal("needs_approval"), summary: z.string() }),
@@ -647,14 +669,23 @@ var TaskApprovalResolvedPayloadSchema = z.object({
647
669
  resolvedBy: z.enum(["local"]),
648
670
  at: z.iso.datetime({ offset: true })
649
671
  });
650
- var MESSAGE_PAYLOAD_SCHEMAS = {
651
- "conn.hello": ConnHelloPayloadSchema,
652
- "conn.ack": ConnAckPayloadSchema,
672
+ var TASK_OFFER_PAYLOAD_SCHEMAS = {
653
673
  "task.offer": TaskOfferPayloadSchema,
654
674
  "task.offer_with_toolsets": TaskOfferWithToolsetsPayloadSchema,
655
675
  "task.offer_for_agent": TaskOfferForAgentPayloadSchema,
656
676
  "task.offer_for_agent_with_egress": TaskOfferForAgentWithEgressPayloadSchema,
657
- "task.offer_for_agent_with_egress_fresh": TaskOfferForAgentWithEgressFreshPayloadSchema,
677
+ "task.offer_for_agent_with_egress_fresh": TaskOfferForAgentWithEgressFreshPayloadSchema
678
+ };
679
+ var TASK_OFFER_TYPES = Object.freeze(
680
+ Object.keys(TASK_OFFER_PAYLOAD_SCHEMAS)
681
+ );
682
+ function isTaskOfferType(type) {
683
+ return Object.hasOwn(TASK_OFFER_PAYLOAD_SCHEMAS, type);
684
+ }
685
+ var MESSAGE_PAYLOAD_SCHEMAS = {
686
+ "conn.hello": ConnHelloPayloadSchema,
687
+ "conn.ack": ConnAckPayloadSchema,
688
+ ...TASK_OFFER_PAYLOAD_SCHEMAS,
658
689
  "agent.egress.reliable": AgentEgressReliablePayloadSchema,
659
690
  "agent.egress.ack": AgentEgressAckPayloadSchema,
660
691
  "agent.message.publish": AgentMessagePublishPayloadSchema,
@@ -1110,6 +1141,6 @@ function byokBlobContentPath(blobId) {
1110
1141
  return `/byok/blobs/${blobId}/content`;
1111
1142
  }
1112
1143
 
1113
- 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_PROJECTION_MAX_BYTES, AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM, AGENT_MEMORY_PROJECTION_CAPABILITY, AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE, AGENT_MEMORY_PROJECTION_MAX_REDACTED_BYTES, AGENT_MESSAGE_EGRESS_CAPABILITY, AGENT_MESSAGE_MAX_BYTES, AGENT_REF_MAX_BYTES, AgentContentActorKindSchema, AgentContentActorSchema, AgentContentDecodeAsSchema, AgentContentMimeTypeSchema, AgentContentReadDecisionSchema, AgentContentReadDenialReasonSchema, AgentContentReadPayloadSchema, AgentContentReadSurfaceSchema, AgentContentReceiptPayloadSchema, AgentEgressAckPayloadSchema, AgentEgressActivityPolicySchema, AgentEgressContentHashSchema, AgentEgressDropReasonSchema, AgentEgressLaneSchema, AgentEgressPolicyRevisionSchema, AgentEgressPolicySchema, AgentEgressReliablePayloadSchema, AgentEventOrUnknownSchema, AgentEventSchema, AgentHomeProjectionAgentRefSchema, AgentHomeProjectionCompletionRequestSchema, AgentHomeProjectionHashSchema, AgentHomeProjectionOutcomeSchema, AgentHomeProjectionPayloadSchema, AgentHomeProjectionProfileRevisionSchema, AgentHomeProjectionReadbackSchema, AgentHomeProjectionStatusSchema, AgentHomeProjectionValueSchema, AgentMemoryProjectionCommitRequestSchema, AgentMemoryProjectionCommitResponseSchema, AgentMemoryProjectionEraseResultSchema, AgentMemoryProjectionGrantRefSchema, AgentMemoryProjectionMeteringReceiptSchema, AgentMemoryProjectionMutationSchema, AgentMemoryProjectionReceiptSchema, AgentMemoryProjectionSessionRefSchema, AgentMemoryProjectionSnapshotSchema, AgentMemoryProjectionSourceSeqSchema, AgentMemoryProjectionWriterEpochSchema, AgentMessageContentTypeSchema, AgentMessageContractSchema, AgentMessageDestinationBindingSchema, AgentMessageDispositionPayloadSchema, AgentMessageEgressRequirementSchema, AgentMessageFreshnessCursorSchema, AgentMessagePublishPayloadSchema, AgentMessageServerContextSchema, AgentRefSchema, AgentReliableQuotaPolicySchema, BYOK_ACTIVITY_PATH, BYOK_AGENT_HOME_PROJECTIONS_PATH, BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE, BYOK_AGENT_MEMORY_PROJECTIONS_PATH, BYOK_BLOBS_PATH, BYOK_BLOB_CONTENT_ROUTE, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_PATH, BYOK_BOARD_STATUS_ROUTE, BYOK_BOARD_STREAM_PATH, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_CAPABILITIES_PATH, BYOK_CHALLENGE_PATH, BYOK_EVENTS_PATH, BYOK_MESSAGES_PATH, BYOK_PAIR_PATH, BYOK_PRESENCE_PATH, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, BYOK_TOKEN_PATH, BlobDownloadUrlResponseSchema, BlobRefSchema, CAPABILITY_FLAGS, CONFIGURED_TOOLSETS_MAX_ITEMS, CONTENT_HASH_RE, ChallengeRequestSchema, ChallengeResponseSchema, ConfiguredToolsetsSchema, ConnAckPayloadSchema, ConnHelloPayloadSchema, ContentReadPolicySchema, CreateBlobRequestSchema, CreateBlobResponseSchema, DAEMON_TO_SERVER_TYPES, DispatchSelectionSchema, EnvelopeParseError, EnvelopeSchema, EnvelopeValidationError, EventsPollQuerySchema, EventsPollResponseSchema, KNOWN_AGENT_EVENT_TYPES, MAX_MESSAGES_PER_BATCH, MESSAGE_PAYLOAD_SCHEMAS, MESSAGE_TYPES, MessagesSendRequestSchema, MessagesSendResponseSchema, PAIR_RESPONSE_TENANT_ID_MAX_LENGTH, PERMISSION_MODES, PROTOCOL_VERSION, PROVIDER_MODEL_CAPABILITIES, PROVIDER_PROFILE_BINDING_CAPABILITY, PairRequestSchema, PairResponseSchema, PairResponseTenantIdSchema, PermissionPolicySchema, PresencePublishRequestSchema, ProtocolError, ProtocolVersionNumberSchema, ProviderModelCapabilitySchema, ProviderProfileBindingSchema, ProviderProfileHashSchema, ProviderProfileRefSchema, ProviderProfileRevisionSchema, RESULT_DOCUMENT_MAX_BYTES, RequiredToolsetsSchema, RuntimeCapabilitiesSchema, RuntimeIdSchema, RuntimeInfoSchema, SERVER_TO_DAEMON_TYPES, STRICT_AGENT_ONLY_CAPABILITY, TASK_STATES, TASK_TRANSITIONS, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_PROJECTION_SELECTION_CAPABILITY, TaskApprovalResolvedPayloadSchema, TaskApprovePayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCancelPayloadSchema, TaskCancelledPayloadSchema, TaskClaimPayloadSchema, TaskCompletePayloadSchema, TaskDeclinePayloadSchema, TaskFailPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskProgressPayloadSchema, TaskRejectPayloadSchema, TaskStartedPayloadSchema, TaskSteerPayloadSchema, TerminalInferenceUsageSchema, TerminalProjectionContractSchema, TerminalProjectionSelectionSchema, TokenRequestSchema, TokenResponseSchema, ToolsetIdSchema, UnknownAgentEventSchema, UnknownMessageTypeError, agentMemoryProjectionBase64UrlByteLength, byokAgentHomeProjectionCompletionPath, byokBlobContentPath, byokBlobFinalizePath, byokBlobUrlPath, byokRecordPath, byokSkillPackFilePath, canTransition, checkResultDocument, createEnvelope, decodeEnvelope, encodeEnvelope, isKnownAgentEvent, isServerToDaemonType, parseMessage, partitionAgentEvents };
1144
+ 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_EVENT_SPILL_UNSTORED_REASON_MAX_LENGTH, AGENT_HOME_PROJECTION_CAPABILITY, AGENT_HOME_PROJECTION_MAX_BYTES, AGENT_HOME_PROJECTION_PROFILE_REVISION_MAXIMUM, AGENT_MEMORY_PROJECTION_CAPABILITY, AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE, AGENT_MEMORY_PROJECTION_MAX_REDACTED_BYTES, AGENT_MESSAGE_EGRESS_CAPABILITY, AGENT_MESSAGE_MAX_BYTES, AGENT_REF_MAX_BYTES, AgentContentActorKindSchema, AgentContentActorSchema, AgentContentDecodeAsSchema, AgentContentMimeTypeSchema, AgentContentReadDecisionSchema, AgentContentReadDenialReasonSchema, AgentContentReadPayloadSchema, AgentContentReadSurfaceSchema, AgentContentReceiptPayloadSchema, AgentEgressAckPayloadSchema, AgentEgressActivityPolicySchema, AgentEgressContentHashSchema, AgentEgressDropReasonSchema, AgentEgressLaneSchema, AgentEgressPolicyRevisionSchema, AgentEgressPolicySchema, AgentEgressReliablePayloadSchema, AgentEventOrUnknownSchema, AgentEventSchema, AgentEventSpillSchema, AgentHomeProjectionAgentRefSchema, AgentHomeProjectionCompletionRequestSchema, AgentHomeProjectionHashSchema, AgentHomeProjectionOutcomeSchema, AgentHomeProjectionPayloadSchema, AgentHomeProjectionProfileRevisionSchema, AgentHomeProjectionReadbackSchema, AgentHomeProjectionStatusSchema, AgentHomeProjectionValueSchema, AgentMemoryProjectionCommitRequestSchema, AgentMemoryProjectionCommitResponseSchema, AgentMemoryProjectionEraseResultSchema, AgentMemoryProjectionGrantRefSchema, AgentMemoryProjectionMeteringReceiptSchema, AgentMemoryProjectionMutationSchema, AgentMemoryProjectionReceiptSchema, AgentMemoryProjectionSessionRefSchema, AgentMemoryProjectionSnapshotSchema, AgentMemoryProjectionSourceSeqSchema, AgentMemoryProjectionWriterEpochSchema, AgentMessageContentTypeSchema, AgentMessageContractSchema, AgentMessageDestinationBindingSchema, AgentMessageDispositionPayloadSchema, AgentMessageEgressRequirementSchema, AgentMessageFreshnessCursorSchema, AgentMessagePublishPayloadSchema, AgentMessageServerContextSchema, AgentRefSchema, AgentReliableQuotaPolicySchema, BYOK_ACTIVITY_PATH, BYOK_AGENT_HOME_PROJECTIONS_PATH, BYOK_AGENT_HOME_PROJECTION_COMPLETION_ROUTE, BYOK_AGENT_MEMORY_PROJECTIONS_PATH, BYOK_BLOBS_PATH, BYOK_BLOB_CONTENT_ROUTE, BYOK_BLOB_FINALIZE_ROUTE, BYOK_BLOB_URL_ROUTE, BYOK_BOARD_CLAIM_ROUTE, BYOK_BOARD_PATH, BYOK_BOARD_STATUS_ROUTE, BYOK_BOARD_STREAM_PATH, BYOK_BOARD_UNCLAIM_ROUTE, BYOK_CAPABILITIES_PATH, BYOK_CHALLENGE_PATH, BYOK_EVENTS_PATH, BYOK_MESSAGES_PATH, BYOK_PAIR_PATH, BYOK_PRESENCE_PATH, BYOK_RECORDS_PATH, BYOK_RECORD_ROUTE, BYOK_SKILL_PACKS_PATH, BYOK_SKILL_PACK_FILE_ROUTE, BYOK_TOKEN_PATH, BlobDownloadUrlResponseSchema, BlobRefSchema, CAPABILITY_FLAGS, CONFIGURED_TOOLSETS_MAX_ITEMS, CONTENT_HASH_RE, ChallengeRequestSchema, ChallengeResponseSchema, ConfiguredToolsetsSchema, ConnAckPayloadSchema, ConnHelloPayloadSchema, ContentReadPolicySchema, CreateBlobRequestSchema, CreateBlobResponseSchema, DAEMON_TO_SERVER_TYPES, DispatchSelectionSchema, EnvelopeParseError, EnvelopeSchema, EnvelopeValidationError, EventsPollQuerySchema, EventsPollResponseSchema, KNOWN_AGENT_EVENT_TYPES, MAX_MESSAGES_PER_BATCH, MESSAGE_PAYLOAD_SCHEMAS, MESSAGE_TYPES, MessagesSendRequestSchema, MessagesSendResponseSchema, PAIR_RESPONSE_TENANT_ID_MAX_LENGTH, PERMISSION_MODES, PROTOCOL_VERSION, PROVIDER_MODEL_CAPABILITIES, PROVIDER_PROFILE_BINDING_CAPABILITY, PairRequestSchema, PairResponseSchema, PairResponseTenantIdSchema, PermissionPolicySchema, PresencePublishRequestSchema, ProtocolError, ProtocolVersionNumberSchema, ProviderModelCapabilitySchema, ProviderProfileBindingSchema, ProviderProfileHashSchema, ProviderProfileRefSchema, ProviderProfileRevisionSchema, RESULT_DOCUMENT_MAX_BYTES, RequiredToolsetsSchema, RuntimeCapabilitiesSchema, RuntimeIdSchema, RuntimeInfoSchema, SERVER_TO_DAEMON_TYPES, STRICT_AGENT_ONLY_CAPABILITY, TASK_OFFER_TYPES, TASK_STATES, TASK_TRANSITIONS, TERMINAL_INFERENCE_USAGE_CLIENT_VERSION_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_MAX_DURATION_MS, TERMINAL_INFERENCE_USAGE_MAX_TOKENS, TERMINAL_INFERENCE_USAGE_MODEL_MAX_LENGTH, TERMINAL_INFERENCE_USAGE_PROVIDER_MAX_LENGTH, TERMINAL_PROJECTION_SELECTION_CAPABILITY, TaskApprovalResolvedPayloadSchema, TaskApprovePayloadSchema, TaskArtifactPayloadSchema, TaskAwaitApprovalPayloadSchema, TaskCancelPayloadSchema, TaskCancelledPayloadSchema, TaskClaimPayloadSchema, TaskCompletePayloadSchema, TaskDeclinePayloadSchema, TaskFailPayloadSchema, TaskOfferForAgentPayloadSchema, TaskOfferForAgentWithEgressFreshPayloadSchema, TaskOfferForAgentWithEgressPayloadSchema, TaskOfferPayloadSchema, TaskOfferWithToolsetsPayloadSchema, TaskProgressPayloadSchema, TaskRejectPayloadSchema, TaskStartedPayloadSchema, TaskSteerPayloadSchema, TerminalInferenceUsageSchema, TerminalProjectionContractSchema, TerminalProjectionSelectionSchema, TokenRequestSchema, TokenResponseSchema, ToolsetIdSchema, UnknownAgentEventSchema, UnknownMessageTypeError, agentMemoryProjectionBase64UrlByteLength, byokAgentHomeProjectionCompletionPath, byokBlobContentPath, byokBlobFinalizePath, byokBlobUrlPath, byokRecordPath, byokSkillPackFilePath, canTransition, checkResultDocument, createEnvelope, decodeEnvelope, encodeEnvelope, isKnownAgentEvent, isServerToDaemonType, isTaskOfferType, parseMessage, partitionAgentEvents };
1114
1145
  //# sourceMappingURL=index.js.map
1115
1146
  //# sourceMappingURL=index.js.map