@neta-art/cohub 8.6.0 → 8.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/board/core/arrow-geometry.js +8 -45
- package/dist/board/core/draw-geometry.d.ts +8 -6
- package/dist/board/core/draw-geometry.js +6 -32
- package/dist/board/core/shape-types.d.ts +1 -1
- package/dist/board/export/scene.js +1 -0
- package/dist/board/geometry.d.ts +1 -1
- package/dist/board/index.d.ts +4 -3
- package/dist/board/index.js +2 -1
- package/dist/board/render/renderers/board-renderer-registry.d.ts +2 -0
- package/dist/board/render/renderers/draw-card-renderer.js +28 -18
- package/dist/board/semantic-document.d.ts +1 -1
- package/dist/board/semantic-document.js +23 -4
- package/dist/board/semantic-mutation.d.ts +1 -1
- package/dist/board/semantic-mutation.js +7 -1
- package/dist/chunks/http.d.ts +33 -4
- package/dist/chunks/http.js +97 -25
- package/dist/chunks/websocket.d.ts +469 -369
- package/dist/http.d.ts +3 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +7 -0
- package/dist/protocol/dist/board-authoring.d.ts +201 -181
- package/dist/protocol/dist/board-authoring.js +32 -21
- package/dist/protocol/dist/board-codec.js +200 -1
- package/dist/protocol/dist/board-geometry.d.ts +15 -0
- package/dist/protocol/dist/board-geometry.js +137 -0
- package/dist/protocol/dist/board-node.js +94 -1
- package/dist/protocol/dist/board.js +2 -2
- package/dist/protocol/dist/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/chunks/http.js
CHANGED
|
@@ -1013,12 +1013,17 @@ const idSchema = z.string().min(1).max(160);
|
|
|
1013
1013
|
const jsonObjectSchema = z.record(z.string(), z.unknown());
|
|
1014
1014
|
const finiteSchema = z.number().finite();
|
|
1015
1015
|
const extensionTypeSchema = z.string().regex(/^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)+$/).max(160);
|
|
1016
|
-
const
|
|
1016
|
+
const BoardAuthoringPositionSchema = z.object({
|
|
1017
1017
|
x: finiteSchema,
|
|
1018
|
-
y: finiteSchema
|
|
1018
|
+
y: finiteSchema
|
|
1019
|
+
}).strict();
|
|
1020
|
+
const BoardAuthoringSizeSchema = z.object({
|
|
1019
1021
|
width: finiteSchema.positive(),
|
|
1020
|
-
height: finiteSchema.positive()
|
|
1021
|
-
|
|
1022
|
+
height: finiteSchema.positive()
|
|
1023
|
+
}).strict();
|
|
1024
|
+
const BoardAuthoringPositionPatchSchema = z.object({
|
|
1025
|
+
x: finiteSchema.optional(),
|
|
1026
|
+
y: finiteSchema.optional()
|
|
1022
1027
|
}).strict();
|
|
1023
1028
|
const pointSchema = z.object({
|
|
1024
1029
|
x: finiteSchema,
|
|
@@ -1049,15 +1054,26 @@ const BoardItemSourceSchema = z.object({
|
|
|
1049
1054
|
path: z.string().refine(isSafeBoardSourcePath, "source path must be a safe relative Board file path"),
|
|
1050
1055
|
snapshot: sourceSnapshotSchema.optional()
|
|
1051
1056
|
}).strict();
|
|
1052
|
-
const
|
|
1057
|
+
const sizedBaseFields = {
|
|
1053
1058
|
id: idSchema,
|
|
1054
|
-
|
|
1059
|
+
position: BoardAuthoringPositionSchema.default({
|
|
1060
|
+
x: 0,
|
|
1061
|
+
y: 0
|
|
1062
|
+
}),
|
|
1063
|
+
rotation: finiteSchema.default(0),
|
|
1055
1064
|
parentId: idSchema.nullable().optional(),
|
|
1056
1065
|
locked: z.boolean().optional(),
|
|
1057
|
-
metadata: jsonObjectSchema.optional()
|
|
1066
|
+
metadata: jsonObjectSchema.optional(),
|
|
1067
|
+
size: BoardAuthoringSizeSchema.optional()
|
|
1058
1068
|
};
|
|
1059
1069
|
const styledBaseFields = {
|
|
1060
|
-
...
|
|
1070
|
+
...sizedBaseFields,
|
|
1071
|
+
style: BoardItemStyleSchema.optional()
|
|
1072
|
+
};
|
|
1073
|
+
const { position: _positionField, size: _sizeField, ...strokeBaseFields } = sizedBaseFields;
|
|
1074
|
+
const strokeStyledBaseFields = {
|
|
1075
|
+
...strokeBaseFields,
|
|
1076
|
+
rotation: z.literal(0).default(0),
|
|
1061
1077
|
style: BoardItemStyleSchema.optional()
|
|
1062
1078
|
};
|
|
1063
1079
|
const BoardTextAuthoringItemSchema = z.object({
|
|
@@ -1077,12 +1093,12 @@ const BoardGeoAuthoringItemSchema = z.object({
|
|
|
1077
1093
|
}).strict()
|
|
1078
1094
|
}).strict();
|
|
1079
1095
|
const BoardDrawAuthoringItemSchema = z.object({
|
|
1080
|
-
...
|
|
1096
|
+
...strokeStyledBaseFields,
|
|
1081
1097
|
type: z.literal("draw"),
|
|
1082
1098
|
props: z.object({ points: z.array(pointSchema).min(1) }).strict()
|
|
1083
1099
|
}).strict();
|
|
1084
1100
|
const BoardArrowAuthoringItemSchema = z.object({
|
|
1085
|
-
...
|
|
1101
|
+
...strokeStyledBaseFields,
|
|
1086
1102
|
type: z.literal("arrow"),
|
|
1087
1103
|
props: z.object({
|
|
1088
1104
|
start: worldPointSchema,
|
|
@@ -1099,7 +1115,7 @@ const BoardFrameAuthoringItemSchema = z.object({
|
|
|
1099
1115
|
props: z.object({ label: z.string().default("Frame") }).strict()
|
|
1100
1116
|
}).strict();
|
|
1101
1117
|
const fileBackedFields = {
|
|
1102
|
-
...
|
|
1118
|
+
...sizedBaseFields,
|
|
1103
1119
|
style: z.object({}).strict().optional(),
|
|
1104
1120
|
source: BoardItemSourceSchema
|
|
1105
1121
|
};
|
|
@@ -1130,7 +1146,7 @@ const builtinItemSchemas = [
|
|
|
1130
1146
|
props: z.object({}).strict()
|
|
1131
1147
|
}).strict(),
|
|
1132
1148
|
z.object({
|
|
1133
|
-
...
|
|
1149
|
+
...sizedBaseFields,
|
|
1134
1150
|
type: z.literal("task"),
|
|
1135
1151
|
props: z.object({
|
|
1136
1152
|
taskRunId: z.string().min(1),
|
|
@@ -1141,7 +1157,7 @@ const builtinItemSchemas = [
|
|
|
1141
1157
|
];
|
|
1142
1158
|
const BoardBuiltinAuthoringItemSchema = z.discriminatedUnion("type", builtinItemSchemas);
|
|
1143
1159
|
const BoardExtensionAuthoringItemSchema = z.object({
|
|
1144
|
-
...
|
|
1160
|
+
...sizedBaseFields,
|
|
1145
1161
|
type: extensionTypeSchema,
|
|
1146
1162
|
kindVersion: z.number().int().positive(),
|
|
1147
1163
|
props: jsonObjectSchema,
|
|
@@ -1153,16 +1169,11 @@ const BoardExtensionAuthoringItemSchema = z.object({
|
|
|
1153
1169
|
}).strict().optional()
|
|
1154
1170
|
}).strict();
|
|
1155
1171
|
const BoardAuthoringItemSchema = z.union([BoardBuiltinAuthoringItemSchema, BoardExtensionAuthoringItemSchema]);
|
|
1156
|
-
const framePatchSchema = z.object({
|
|
1157
|
-
x: finiteSchema.optional(),
|
|
1158
|
-
y: finiteSchema.optional(),
|
|
1159
|
-
width: finiteSchema.positive().optional(),
|
|
1160
|
-
height: finiteSchema.positive().optional(),
|
|
1161
|
-
rotation: finiteSchema.optional()
|
|
1162
|
-
}).strict();
|
|
1163
1172
|
/** JSON Merge Patch semantics, constrained to the stable Item envelope. */
|
|
1164
1173
|
const BoardItemPatchSchema = z.object({
|
|
1165
|
-
|
|
1174
|
+
position: BoardAuthoringPositionPatchSchema.optional(),
|
|
1175
|
+
size: BoardAuthoringSizeSchema.nullable().optional(),
|
|
1176
|
+
rotation: finiteSchema.optional(),
|
|
1166
1177
|
parentId: idSchema.nullable().optional(),
|
|
1167
1178
|
locked: z.boolean().nullable().optional(),
|
|
1168
1179
|
props: jsonObjectSchema.optional(),
|
|
@@ -2475,6 +2486,34 @@ function buildSpaceInvitePath(input) {
|
|
|
2475
2486
|
}
|
|
2476
2487
|
//#endregion
|
|
2477
2488
|
//#region src/apis/spaces.ts
|
|
2489
|
+
async function fetchTurnObject(url, fetchImpl = globalThis.fetch, signal) {
|
|
2490
|
+
const response = await fetchImpl(url, { signal });
|
|
2491
|
+
if (!response.ok) throw new Error(`Failed to fetch turn object: HTTP ${response.status}`);
|
|
2492
|
+
return response.json();
|
|
2493
|
+
}
|
|
2494
|
+
function extractToolCalls(content) {
|
|
2495
|
+
const byId = /* @__PURE__ */ new Map();
|
|
2496
|
+
for (const block of content) if (block.type === "tool_use") byId.set(block.id, {
|
|
2497
|
+
id: block.id,
|
|
2498
|
+
name: block.name,
|
|
2499
|
+
input: block.input,
|
|
2500
|
+
meta: block._meta ?? null,
|
|
2501
|
+
result: null
|
|
2502
|
+
});
|
|
2503
|
+
for (const block of content) {
|
|
2504
|
+
if (block.type !== "tool_result") continue;
|
|
2505
|
+
const existing = byId.get(block.tool_use_id);
|
|
2506
|
+
if (existing) byId.set(block.tool_use_id, {
|
|
2507
|
+
...existing,
|
|
2508
|
+
result: {
|
|
2509
|
+
content: block.content,
|
|
2510
|
+
isError: Boolean(block.is_error),
|
|
2511
|
+
meta: block._meta ?? null
|
|
2512
|
+
}
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
return [...byId.values()];
|
|
2516
|
+
}
|
|
2478
2517
|
const getFilenameFromContentDisposition = (value) => {
|
|
2479
2518
|
if (!value) return null;
|
|
2480
2519
|
const encodedMatch = value.match(/filename\*=UTF-8''([^;]+)/i);
|
|
@@ -2821,9 +2860,41 @@ var SessionMessagesClient = class {
|
|
|
2821
2860
|
var SessionTurnsClient = class {
|
|
2822
2861
|
transport;
|
|
2823
2862
|
sessionId;
|
|
2824
|
-
|
|
2863
|
+
spaceId;
|
|
2864
|
+
intermediate;
|
|
2865
|
+
constructor(transport, sessionId, spaceId) {
|
|
2825
2866
|
this.transport = transport;
|
|
2826
2867
|
this.sessionId = sessionId;
|
|
2868
|
+
this.spaceId = spaceId;
|
|
2869
|
+
this.intermediate = {
|
|
2870
|
+
get: (turnId, messagesObjectKey, options) => this.getIntermediate(turnId, messagesObjectKey, options),
|
|
2871
|
+
getToolCalls: (turnId, message, options) => this.getToolCalls(turnId, message, options)
|
|
2872
|
+
};
|
|
2873
|
+
}
|
|
2874
|
+
async getIntermediate(turnId, messagesObjectKey, options) {
|
|
2875
|
+
const objectKey = messagesObjectKey === void 0 ? (await this.get(turnId, options?.fetch)).turn.intermediateIndex?.messagesObjectKey : messagesObjectKey;
|
|
2876
|
+
if (!objectKey) return null;
|
|
2877
|
+
const { urls } = await this.signedUrls(turnId, [objectKey], options?.fetch);
|
|
2878
|
+
const url = urls[objectKey];
|
|
2879
|
+
if (!url) throw new Error("Missing signed URL for intermediate messages");
|
|
2880
|
+
return fetchTurnObject(url, options?.fetch, options?.signal);
|
|
2881
|
+
}
|
|
2882
|
+
async getToolCalls(turnId, message, options) {
|
|
2883
|
+
if (!message.toolCallsObjectKey) {
|
|
2884
|
+
const toolCalls = extractToolCalls(message.content);
|
|
2885
|
+
return toolCalls.length === 0 ? null : {
|
|
2886
|
+
version: 1,
|
|
2887
|
+
spaceId: this.spaceId,
|
|
2888
|
+
sessionId: this.sessionId,
|
|
2889
|
+
turnId,
|
|
2890
|
+
messageId: message.id,
|
|
2891
|
+
toolCalls
|
|
2892
|
+
};
|
|
2893
|
+
}
|
|
2894
|
+
const { urls } = await this.signedUrls(turnId, [message.toolCallsObjectKey], options?.fetch);
|
|
2895
|
+
const url = urls[message.toolCallsObjectKey];
|
|
2896
|
+
if (!url) throw new Error("Missing signed URL for tool calls");
|
|
2897
|
+
return fetchTurnObject(url, options?.fetch, options?.signal);
|
|
2827
2898
|
}
|
|
2828
2899
|
listPaginated(options, customFetch) {
|
|
2829
2900
|
const params = new URLSearchParams();
|
|
@@ -2855,11 +2926,12 @@ var SessionTurnsClient = class {
|
|
|
2855
2926
|
get(turnId, customFetch) {
|
|
2856
2927
|
return this.transport.request(`/api/sessions/${this.sessionId}/turns/${turnId}`, { fetch: customFetch });
|
|
2857
2928
|
}
|
|
2858
|
-
signedUrls(turnId, objectKeys) {
|
|
2929
|
+
signedUrls(turnId, objectKeys, customFetch) {
|
|
2859
2930
|
return this.transport.request(`/api/sessions/${this.sessionId}/turns/${turnId}/signed-urls`, {
|
|
2860
2931
|
method: "POST",
|
|
2861
2932
|
headers: { "Content-Type": "application/json" },
|
|
2862
|
-
body: JSON.stringify({ objectKeys })
|
|
2933
|
+
body: JSON.stringify({ objectKeys }),
|
|
2934
|
+
fetch: customFetch
|
|
2863
2935
|
});
|
|
2864
2936
|
}
|
|
2865
2937
|
};
|
|
@@ -2949,7 +3021,7 @@ var SessionClient = class {
|
|
|
2949
3021
|
this.id = id;
|
|
2950
3022
|
this.transport = transport;
|
|
2951
3023
|
this.messages = new SessionMessagesClient(transport, id);
|
|
2952
|
-
this.turns = new SessionTurnsClient(transport, id);
|
|
3024
|
+
this.turns = new SessionTurnsClient(transport, id, spaceId);
|
|
2953
3025
|
this.realtime = new SessionRealtimeClient(websocketClient, spaceId, id);
|
|
2954
3026
|
this.generation = new SessionGenerationStreamClient(websocketClient, spaceId, id, () => this.turns.streamSnapshot());
|
|
2955
3027
|
}
|