@yefengr/pi-reach 0.0.3 → 0.0.5
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 +2 -2
- package/dist/attachments/reservation.fixture.d.ts +1 -0
- package/dist/attachments/reservation.fixture.js +25 -0
- package/dist/attachments/reservation.fixture.js.map +1 -0
- package/dist/attachments/reservations.d.ts +21 -0
- package/dist/attachments/reservations.js +189 -0
- package/dist/attachments/reservations.js.map +1 -0
- package/dist/attachments/safe-files.d.ts +7 -0
- package/dist/attachments/safe-files.js +66 -0
- package/dist/attachments/safe-files.js.map +1 -0
- package/dist/attachments/store.d.ts +55 -0
- package/dist/attachments/store.js +518 -0
- package/dist/attachments/store.js.map +1 -0
- package/dist/attachments/types.d.ts +48 -0
- package/dist/attachments/types.js +20 -0
- package/dist/attachments/types.js.map +1 -0
- package/dist/index.js +42 -35
- package/dist/index.js.map +1 -1
- package/dist/runtime/attachment_binding.d.ts +17 -0
- package/dist/runtime/attachment_binding.js +70 -0
- package/dist/runtime/attachment_binding.js.map +1 -0
- package/dist/runtime/create_owner_binding.d.ts +27 -0
- package/dist/runtime/create_owner_binding.js +22 -0
- package/dist/runtime/create_owner_binding.js.map +1 -0
- package/dist/timeline/attachment_content.d.ts +21 -0
- package/dist/timeline/attachment_content.js +83 -0
- package/dist/timeline/attachment_content.js.map +1 -0
- package/dist/timeline/attachment_delivery.d.ts +65 -0
- package/dist/timeline/attachment_delivery.js +150 -0
- package/dist/timeline/attachment_delivery.js.map +1 -0
- package/dist/timeline/runtime.d.ts +4 -2
- package/dist/timeline/runtime.js +33 -34
- package/dist/timeline/runtime.js.map +1 -1
- package/dist/timeline/user_delivery.d.ts +7 -0
- package/dist/timeline/user_delivery.js +21 -12
- package/dist/timeline/user_delivery.js.map +1 -1
- package/dist/timeline/user_delivery_binding.d.ts +6 -1
- package/dist/timeline/user_delivery_binding.js +17 -1
- package/dist/timeline/user_delivery_binding.js.map +1 -1
- package/dist/timeline/v2_service.d.ts +9 -1
- package/dist/timeline/v2_service.js +26 -8
- package/dist/timeline/v2_service.js.map +1 -1
- package/dist/vendor/protocol/outer/codec.js +3 -0
- package/dist/vendor/protocol/outer/types.d.ts +5 -1
- package/dist/vendor/protocol/session/attachments.d.ts +78 -0
- package/dist/vendor/protocol/session/attachments.js +150 -0
- package/dist/vendor/protocol/session/frames.d.ts +541 -0
- package/dist/vendor/protocol/session/frames.js +39 -4
- package/dist/vendor/protocol/session/index.d.ts +1 -0
- package/dist/vendor/protocol/session/index.js +1 -0
- package/dist/vendor/protocol/session/schema.d.ts +2 -2
- package/dist/vendor/protocol/session/schema.js +4 -1
- package/package.json +1 -1
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { actionNameSchema, byeReasonSchema, channelIdSchema, harnessSchema, leafIdSchema, headSequenceSchema, idSchema, MAX_ARRAY_ITEMS, pairingCodeSchema, protocolVersionSchema, eventSequenceSchema, sequencedTimelineEventSchema, timelineEventFragmentSchema, timelinePartialSchema, thinkingLevelSchema, queuedMessageItemSchema, timestampSchema, userBlockSchema, wireImageSchema, wireModelSchema, CLIENT_FRAME_TYPES, SERVER_FRAME_TYPES, strictObject, textSchema, } from "./schema.js";
|
|
2
|
+
import { actionNameSchema, byeReasonSchema, channelIdSchema, harnessSchema, leafIdSchema, headSequenceSchema, idSchema, MAX_ARRAY_ITEMS, imageMimeSchema, pairingCodeSchema, protocolVersionSchema, eventSequenceSchema, sequencedTimelineEventSchema, timelineEventFragmentSchema, timelinePartialSchema, thinkingLevelSchema, queuedMessageItemSchema, timestampSchema, userBlockSchema, wireImageSchema, wireModelSchema, CLIENT_FRAME_TYPES, SERVER_FRAME_TYPES, strictObject, textSchema, } from "./schema.js";
|
|
3
|
+
import { ATTACHMENT_CHUNK_BYTES, ATTACHMENT_MAX_COUNT, ATTACHMENT_MAX_FILE_BYTES, ATTACHMENT_MAX_IN_FLIGHT, ATTACHMENT_MAX_MESSAGE_BYTES, attachmentByteLengthSchema, attachmentChunkDataSchema, attachmentDescriptorSchema, attachmentFileNameSchema, attachmentIdsSchema, attachmentPreviewSchema, attachmentSha256Schema, } from "./attachments.js";
|
|
3
4
|
const wireTimelineEventSchema = sequencedTimelineEventSchema;
|
|
4
5
|
const protocol = { protocol_version: protocolVersionSchema };
|
|
5
6
|
const channelRequest = { ...protocol, channel_id: channelIdSchema, session_id: idSchema, leaf_id: leafIdSchema };
|
|
6
7
|
const directResponse = { ...protocol, target_channel_id: channelIdSchema };
|
|
7
8
|
const ownerBroadcast = { ...protocol, session_id: idSchema, leaf_id: leafIdSchema };
|
|
9
|
+
const attachmentUploadRequest = { ...protocol, channel_id: channelIdSchema, session_id: idSchema, upload_scope: idSchema };
|
|
10
|
+
const attachmentUploadResponse = { ...directResponse, in_reply_to: idSchema, session_id: idSchema, upload_scope: idSchema };
|
|
11
|
+
const safeOffsetSchema = z.number().int().nonnegative().finite().max(Number.MAX_SAFE_INTEGER);
|
|
8
12
|
export const pairRequestFrameSchema = strictObject({ ...protocol, type: z.literal("pair_request"), id: idSchema, code: pairingCodeSchema, device_name: textSchema });
|
|
9
13
|
export const sessionHelloFrameSchema = strictObject({ ...protocol, type: z.literal("session_hello"), id: idSchema, channel_id: channelIdSchema });
|
|
10
|
-
export const
|
|
14
|
+
export const extensionInfoRequestFrameSchema = strictObject({ ...protocol, type: z.literal("extension_info_request"), id: idSchema, ...channelRequest });
|
|
15
|
+
export const userMessageFrameSchema = strictObject({ ...protocol, type: z.literal("user_message"), id: idSchema, ...channelRequest, client_request_id: idSchema, text: textSchema, images: z.array(wireImageSchema).max(1).optional(), attachment_ids: attachmentIdsSchema.optional(), streaming_behavior: z.literal("steer").optional() }).superRefine((frame, ctx) => {
|
|
16
|
+
if (frame.images !== undefined && frame.attachment_ids !== undefined) {
|
|
17
|
+
ctx.addIssue({ code: "custom", path: ["attachment_ids"], message: "attachment_ids and images are mutually exclusive" });
|
|
18
|
+
}
|
|
19
|
+
});
|
|
11
20
|
export const userMessageObservedFrameSchema = strictObject({ ...protocol, type: z.literal("user_message_observed"), id: idSchema, ...channelRequest, client_request_id: idSchema, message_id: idSchema, status: z.literal("committed") });
|
|
12
21
|
export const sessionSyncFrameSchema = strictObject({ ...protocol, type: z.literal("session_sync"), id: idSchema, ...channelRequest, before: eventSequenceSchema.nullable(), limit: z.number().int().min(1).finite().max(80).default(80) });
|
|
13
22
|
export const pingFrameSchema = strictObject({ ...protocol, type: z.literal("ping"), id: idSchema, ...channelRequest });
|
|
@@ -21,9 +30,17 @@ export const queuedMessageSetFrameSchema = strictObject({ ...protocol, type: z.l
|
|
|
21
30
|
export const queuedMessageClearFrameSchema = strictObject({ ...protocol, type: z.literal("queued_message_clear"), id: idSchema, ...channelRequest, target_id: idSchema.optional() });
|
|
22
31
|
export const queuedMessageSteerFrameSchema = strictObject({ ...protocol, type: z.literal("queued_message_steer"), id: idSchema, ...channelRequest, target_id: idSchema });
|
|
23
32
|
export const approveToolFrameSchema = strictObject({ ...protocol, type: z.literal("approve_tool"), id: idSchema, ...channelRequest, tool_call_id: idSchema, decision: z.enum(["allow", "deny"]) });
|
|
33
|
+
export const attachmentCapabilitiesRequestFrameSchema = strictObject({ ...protocol, type: z.literal("attachment_capabilities_request"), id: idSchema, ...channelRequest });
|
|
34
|
+
export const attachmentBeginFrameSchema = strictObject({ ...protocol, type: z.literal("attachment_begin"), id: idSchema, ...attachmentUploadRequest, upload_id: idSchema, file_name: attachmentFileNameSchema, mime_type: imageMimeSchema, byte_length: attachmentByteLengthSchema, sha256: attachmentSha256Schema, preview: attachmentPreviewSchema.optional() });
|
|
35
|
+
export const attachmentChunkFrameSchema = strictObject({ ...protocol, type: z.literal("attachment_chunk"), id: idSchema, ...attachmentUploadRequest, upload_id: idSchema, offset: safeOffsetSchema, data_base64: attachmentChunkDataSchema });
|
|
36
|
+
export const attachmentFinishFrameSchema = strictObject({ ...protocol, type: z.literal("attachment_finish"), id: idSchema, ...attachmentUploadRequest, upload_id: idSchema });
|
|
37
|
+
export const attachmentStatusRequestFrameSchema = strictObject({ ...protocol, type: z.literal("attachment_status_request"), id: idSchema, ...attachmentUploadRequest, upload_id: idSchema });
|
|
38
|
+
export const attachmentCancelFrameSchema = strictObject({ ...protocol, type: z.literal("attachment_cancel"), id: idSchema, ...attachmentUploadRequest, upload_id: idSchema });
|
|
39
|
+
export const attachmentDiscardFrameSchema = strictObject({ ...protocol, type: z.literal("attachment_discard"), id: idSchema, ...attachmentUploadRequest, attachment_id: idSchema });
|
|
24
40
|
export const pairOkFrameSchema = strictObject({ ...protocol, type: z.literal("pair_ok"), in_reply_to: idSchema, session_name: textSchema, session_started_at: timestampSchema, endpoint_id: idSchema, harness: harnessSchema.optional(), hostname: textSchema.optional() });
|
|
25
41
|
export const pairErrorFrameSchema = strictObject({ ...protocol, type: z.literal("pair_error"), in_reply_to: idSchema, code: z.enum(["token_expired", "token_consumed", "token_unknown", "internal_error"]), message: textSchema.min(1) });
|
|
26
42
|
export const sessionReadyFrameSchema = strictObject({ ...directResponse, type: z.literal("session_ready"), in_reply_to: idSchema, session_id: idSchema, leaf_id: leafIdSchema, head_seq: headSequenceSchema, self_sender_ref: idSchema });
|
|
43
|
+
export const extensionInfoFrameSchema = strictObject({ ...directResponse, type: z.literal("extension_info"), in_reply_to: idSchema, version: idSchema });
|
|
27
44
|
const startedMessageSchema = strictObject({ id: idSchema, group_id: idSchema, blocks: z.array(userBlockSchema).max(MAX_ARRAY_ITEMS), origin: z.enum(["pwa", "extension", "unknown"]), sender_ref: idSchema.optional(), delivery: z.enum(["normal", "queued", "unknown"]) }).superRefine((message, ctx) => {
|
|
28
45
|
if (message.origin === "pwa" && message.sender_ref === undefined)
|
|
29
46
|
ctx.addIssue({ code: "custom", path: ["sender_ref"], message: "pwa user messages require sender_ref" });
|
|
@@ -72,8 +89,26 @@ export const actionErrorFrameSchema = strictObject({ ...directResponse, type: z.
|
|
|
72
89
|
export const modelsListFrameSchema = strictObject({ ...directResponse, type: z.literal("models_list"), in_reply_to: idSchema, models: z.array(wireModelSchema).max(MAX_ARRAY_ITEMS), current: wireModelSchema.optional() });
|
|
73
90
|
export const queuedMessageStateFrameSchema = strictObject({ ...ownerBroadcast, type: z.literal("queued_message_state"), snapshot_id: idSchema, chunk_index: z.number().int().nonnegative().finite(), final: z.boolean(), items: z.array(queuedMessageItemSchema).max(MAX_ARRAY_ITEMS) });
|
|
74
91
|
export const byeFrameSchema = strictObject({ ...ownerBroadcast, type: z.literal("bye"), reason: byeReasonSchema });
|
|
75
|
-
export const
|
|
76
|
-
|
|
92
|
+
export const attachmentCapabilitiesFrameSchema = strictObject({ ...attachmentUploadResponse, type: z.literal("attachment_capabilities"), max_file_bytes: z.literal(ATTACHMENT_MAX_FILE_BYTES), max_message_bytes: z.literal(ATTACHMENT_MAX_MESSAGE_BYTES), max_attachments: z.literal(ATTACHMENT_MAX_COUNT), chunk_bytes: z.literal(ATTACHMENT_CHUNK_BYTES), max_in_flight: z.literal(ATTACHMENT_MAX_IN_FLIGHT) });
|
|
93
|
+
const attachmentStateBase = { ...attachmentUploadResponse, type: z.literal("attachment_state"), upload_id: idSchema, received_bytes: z.number().int().nonnegative().finite().max(ATTACHMENT_MAX_FILE_BYTES) };
|
|
94
|
+
export const attachmentStateFrameSchema = z.union([
|
|
95
|
+
strictObject({ ...attachmentStateBase, status: z.literal("receiving") }),
|
|
96
|
+
strictObject({ ...attachmentStateBase, status: z.literal("cancelled") }),
|
|
97
|
+
strictObject({ ...attachmentStateBase, status: z.literal("complete"), attachment: attachmentDescriptorSchema }).superRefine((state, ctx) => {
|
|
98
|
+
if (state.received_bytes !== state.attachment.byte_length) {
|
|
99
|
+
ctx.addIssue({ code: "custom", path: ["received_bytes"], message: "received_bytes must equal attachment.byte_length" });
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
]);
|
|
103
|
+
export const attachmentErrorCodeSchema = z.enum(["invalid_scope", "not_found", "invalid_upload", "too_large", "busy", "no_space", "io_error", "integrity_mismatch", "offset_mismatch", "cancelled"]);
|
|
104
|
+
export const attachmentDiscardedFrameSchema = strictObject({ ...attachmentUploadResponse, type: z.literal("attachment_discarded"), attachment_id: idSchema, status: z.enum(["cancelled", "retained"]) });
|
|
105
|
+
export const attachmentErrorFrameSchema = strictObject({ ...attachmentUploadResponse, type: z.literal("attachment_error"), upload_id: idSchema.optional(), attachment_id: idSchema.optional(), code: attachmentErrorCodeSchema, retryable: z.boolean() }).superRefine((frame, ctx) => {
|
|
106
|
+
if (frame.upload_id !== undefined && frame.attachment_id !== undefined) {
|
|
107
|
+
ctx.addIssue({ code: "custom", path: ["attachment_id"], message: "upload_id and attachment_id are mutually exclusive" });
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
export const clientFrameSchema = z.union([pairRequestFrameSchema, sessionHelloFrameSchema, extensionInfoRequestFrameSchema, userMessageFrameSchema, userMessageObservedFrameSchema, sessionSyncFrameSchema, pingFrameSchema, cancelFrameSchema, sessionNewFrameSchema, sessionCompactFrameSchema, modelSetFrameSchema, thinkingSetFrameSchema, listModelsFrameSchema, queuedMessageSetFrameSchema, queuedMessageClearFrameSchema, queuedMessageSteerFrameSchema, approveToolFrameSchema, attachmentCapabilitiesRequestFrameSchema, attachmentBeginFrameSchema, attachmentChunkFrameSchema, attachmentFinishFrameSchema, attachmentStatusRequestFrameSchema, attachmentCancelFrameSchema, attachmentDiscardFrameSchema]);
|
|
111
|
+
export const serverFrameSchema = z.union([pairOkFrameSchema, pairErrorFrameSchema, sessionReadyFrameSchema, extensionInfoFrameSchema, userMessageStartedFrameSchema, userMessageStatusFrameSchema, timelineEventFrameSchema, timelinePartialFrameSchema, timelineEventFragmentFrameSchema, sessionHistoryChunkFrameSchema, protocolErrorFrameSchema, resetFrameSchema, pongFrameSchema, cancelledFrameSchema, actionOkFrameSchema, actionErrorFrameSchema, modelsListFrameSchema, queuedMessageStateFrameSchema, byeFrameSchema, attachmentCapabilitiesFrameSchema, attachmentStateFrameSchema, attachmentErrorFrameSchema, attachmentDiscardedFrameSchema]);
|
|
77
112
|
export const ClientFrameSchema = clientFrameSchema;
|
|
78
113
|
export const ServerFrameSchema = serverFrameSchema;
|
|
79
114
|
export const SessionHistoryChunkSchema = sessionHistoryChunkFrameSchema;
|
|
@@ -852,7 +852,7 @@ export declare const harnessSchema: z.ZodObject<{
|
|
|
852
852
|
name: z.ZodString;
|
|
853
853
|
version: z.ZodString;
|
|
854
854
|
}, z.core.$strict>;
|
|
855
|
-
export declare const CLIENT_FRAME_TYPES: readonly ["pair_request", "session_hello", "user_message", "user_message_observed", "session_sync", "ping", "cancel", "session_new", "session_compact", "model_set", "thinking_set", "list_models", "queued_message_set", "queued_message_clear", "queued_message_steer", "approve_tool"];
|
|
856
|
-
export declare const SERVER_FRAME_TYPES: readonly ["pair_ok", "pair_error", "session_ready", "user_message_started", "user_message_status", "timeline_event", "timeline_partial", "timeline_event_fragment", "session_history_chunk", "protocol_error", "reset", "pong", "cancelled", "action_ok", "action_error", "models_list", "queued_message_state", "bye"];
|
|
855
|
+
export declare const CLIENT_FRAME_TYPES: readonly ["pair_request", "session_hello", "user_message", "user_message_observed", "session_sync", "ping", "cancel", "session_new", "session_compact", "model_set", "thinking_set", "list_models", "queued_message_set", "queued_message_clear", "queued_message_steer", "approve_tool", "extension_info_request", "attachment_capabilities_request", "attachment_begin", "attachment_chunk", "attachment_finish", "attachment_status_request", "attachment_cancel", "attachment_discard"];
|
|
856
|
+
export declare const SERVER_FRAME_TYPES: readonly ["pair_ok", "pair_error", "session_ready", "user_message_started", "user_message_status", "timeline_event", "timeline_partial", "timeline_event_fragment", "session_history_chunk", "protocol_error", "reset", "pong", "cancelled", "action_ok", "action_error", "models_list", "queued_message_state", "bye", "extension_info", "attachment_capabilities", "attachment_state", "attachment_error", "attachment_discarded"];
|
|
857
857
|
export type ClientFrameType = (typeof CLIENT_FRAME_TYPES)[number];
|
|
858
858
|
export type ServerFrameType = (typeof SERVER_FRAME_TYPES)[number];
|
|
@@ -247,10 +247,13 @@ export const harnessSchema = strictObject({ name: idSchema, version: idSchema })
|
|
|
247
247
|
export const CLIENT_FRAME_TYPES = [
|
|
248
248
|
"pair_request", "session_hello", "user_message", "user_message_observed", "session_sync", "ping", "cancel",
|
|
249
249
|
"session_new", "session_compact", "model_set", "thinking_set", "list_models", "queued_message_set",
|
|
250
|
-
"queued_message_clear", "queued_message_steer", "approve_tool",
|
|
250
|
+
"queued_message_clear", "queued_message_steer", "approve_tool", "extension_info_request",
|
|
251
|
+
"attachment_capabilities_request", "attachment_begin", "attachment_chunk", "attachment_finish", "attachment_status_request", "attachment_cancel", "attachment_discard",
|
|
251
252
|
];
|
|
252
253
|
export const SERVER_FRAME_TYPES = [
|
|
253
254
|
"pair_ok", "pair_error", "session_ready", "user_message_started", "user_message_status", "timeline_event",
|
|
254
255
|
"timeline_partial", "timeline_event_fragment", "session_history_chunk", "protocol_error", "reset", "pong",
|
|
255
256
|
"cancelled", "action_ok", "action_error", "models_list", "queued_message_state", "bye",
|
|
257
|
+
"extension_info",
|
|
258
|
+
"attachment_capabilities", "attachment_state", "attachment_error", "attachment_discarded",
|
|
256
259
|
];
|