flavor-code 1.4.1 → 1.4.3-beta.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 +32 -2
- package/README.zh-CN.md +32 -2
- package/dist/{app-4YRKE7VI.js → app-G35YBHPR.js} +873 -641
- package/dist/apply-WOW3QU5I.js +51 -0
- package/dist/broker-cli-X5H46FZV.js +15 -0
- package/dist/check-CSKTV4O2.js +16 -0
- package/dist/chunk-3563SW4X.js +10513 -0
- package/dist/chunk-3UX2CGDW.js +1955 -0
- package/dist/chunk-4TMLXZVZ.js +75 -0
- package/dist/chunk-6F66UXBI.js +48 -0
- package/dist/{chunk-FAORPP4F.js → chunk-6URQ7FIF.js} +24 -88
- package/dist/chunk-6X62CGMA.js +193 -0
- package/dist/chunk-7Y64WNBB.js +8930 -0
- package/dist/chunk-AA4QNKTF.js +501 -0
- package/dist/chunk-BDX777JR.js +11 -0
- package/dist/chunk-CVP5OUHD.js +103 -0
- package/dist/chunk-EWD7FWTH.js +14547 -0
- package/dist/chunk-FAJ6YDZK.js +630 -0
- package/dist/{chunk-N5MXHJKD.js → chunk-GTFP2R5I.js} +1 -1
- package/dist/{chunk-7YFHRORG.js → chunk-HGTCIHWA.js} +383 -172
- package/dist/chunk-IDJAHEG6.js +43501 -0
- package/dist/chunk-IQEEFDEE.js +389 -0
- package/dist/chunk-IU3UBETC.js +30 -0
- package/dist/chunk-K7UGGWJV.js +1003 -0
- package/dist/chunk-KRWWCVXA.js +74 -0
- package/dist/chunk-OKHV7CTB.js +482 -0
- package/dist/chunk-PULWAH6E.js +474 -0
- package/dist/chunk-PZ5NKRVA.js +85 -0
- package/dist/chunk-RBAZLFKB.js +1022 -0
- package/dist/chunk-RV3EXUXM.js +30 -0
- package/dist/chunk-SJUIIHIA.js +2130 -0
- package/dist/{chunk-VMQWXQEC.js → chunk-T6RE76D2.js} +2003 -493
- package/dist/chunk-TIEOVQW6.js +61 -0
- package/dist/chunk-WLZUAVVU.js +15 -0
- package/dist/chunk-X442CJJH.js +114 -0
- package/dist/{chunk-RAYH6K2H.js → chunk-Y7EH4NVO.js} +1 -1
- package/dist/{chunk-S32JRDZK.js → chunk-ZKKVSR37.js} +6 -1
- package/dist/{claude-ink-JZXNSAQS.js → claude-ink-BE56DB6N.js} +9 -4
- package/dist/cli-3MF6EL2H.js +163 -0
- package/dist/cli-main.js +3805 -473
- package/dist/cli.js +50 -4
- package/dist/config/load.d.ts +8 -0
- package/dist/config/schema.d.ts +11 -0
- package/dist/context/manager.d.ts +2 -0
- package/dist/desktop/main.js +4303 -1171
- package/dist/desktop/preload.cjs +30 -0
- package/dist/desktop-renderer/assets/index-BWklSoOO.css +1 -0
- package/dist/desktop-renderer/assets/index-DCqIrF1S.js +153 -0
- package/dist/desktop-renderer/assets/{interactive-terminal-1agnYY5L.js → interactive-terminal-B6GbpzIn.js} +1 -1
- package/dist/desktop-renderer/index.html +2 -2
- package/dist/doctor-OHCGK52S.js +20 -0
- package/dist/load-QK6CMLDF.js +25 -0
- package/dist/log-ATFIPRNU.js +19 -0
- package/dist/manager-5SI4MPES.js +191 -0
- package/dist/models/anthropic.d.ts +3 -0
- package/dist/node-LOIXT44J.js +879 -0
- package/dist/plugin-worker-entry.js +1 -1
- package/dist/production-6DIZ6YLQ.js +46 -0
- package/dist/production.d.ts +28 -1
- package/dist/project-3QXE22TG.js +11 -0
- package/dist/react-M6JGXSJZ.js +7 -0
- package/dist/recorder-FAGJJH3N.js +11 -0
- package/dist/sdk/index.js +30 -8
- package/dist/server-2KLKPHPL.js +11 -0
- package/dist/session/store.d.ts +1 -0
- package/dist/store-ZIHN6363.js +18 -0
- package/dist/ui/commands.d.ts +1 -5
- package/dist/usage-summary-G5FBOJLK.js +13 -0
- package/dist/utils/execFileNoThrow.d.ts +1 -0
- package/dist/write-stream-CGD57URC.js +77 -0
- package/package.json +1 -1
- package/dist/chunk-O2PC44GY.js +0 -26120
- package/dist/chunk-ZJCAQXA7.js +0 -169
- package/dist/desktop-renderer/assets/index-BM9ugkh9.js +0 -154
- package/dist/desktop-renderer/assets/index-Bk6FYhyh.css +0 -1
- package/dist/load-UPOG3XQR.js +0 -19
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as createFlavorRequire } from "node:module"; const require = createFlavorRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
external_exports
|
|
5
|
+
} from "./chunk-EWD7FWTH.js";
|
|
6
|
+
|
|
7
|
+
// src/pals/protocol.ts
|
|
8
|
+
var PROTOCOL_VERSION = 1;
|
|
9
|
+
var MAX_ALIAS_LENGTH = 64;
|
|
10
|
+
var MAX_MESSAGE_BYTES = 32 * 1024;
|
|
11
|
+
var MAX_CONTROL_FRAME_BYTES = 64 * 1024;
|
|
12
|
+
var MAX_PARTICIPANTS = 16;
|
|
13
|
+
var MAX_ACTIVE_PALS = 16;
|
|
14
|
+
var MAX_PLAN_TASKS = 32;
|
|
15
|
+
var MAX_PROJECT_PATH_BYTES = 1024;
|
|
16
|
+
var MAX_PLAN_ENCODED_BYTES = 24 * 1024;
|
|
17
|
+
var MAX_SNAPSHOT_ENCODED_BYTES = 56 * 1024;
|
|
18
|
+
var MAX_COMPLETION_DETAIL_BYTES = 4 * 1024;
|
|
19
|
+
var MAX_COMPLETION_ASSERTIONS_BYTES = 12 * 1024;
|
|
20
|
+
var MIN_UUID_PREFIX_LENGTH = 8;
|
|
21
|
+
function normalizePalIdentity(value) {
|
|
22
|
+
return value.trim().toLocaleLowerCase("en-US");
|
|
23
|
+
}
|
|
24
|
+
var VersionSchema = external_exports.literal(PROTOCOL_VERSION);
|
|
25
|
+
var UuidSchema = external_exports.uuid();
|
|
26
|
+
var PrintableIdentitySchema = external_exports.string().trim().min(1).max(MAX_ALIAS_LENGTH).refine(
|
|
27
|
+
(value) => !/[\p{Cc}\uD800-\uDFFF]/u.test(value),
|
|
28
|
+
"Identity must contain only printable non-control Unicode"
|
|
29
|
+
);
|
|
30
|
+
var PalAliasSchema = PrintableIdentitySchema;
|
|
31
|
+
var PalTargetSchema = PrintableIdentitySchema;
|
|
32
|
+
var BoundedTextSchema = external_exports.string().refine(
|
|
33
|
+
(value) => Buffer.byteLength(value, "utf8") <= MAX_MESSAGE_BYTES,
|
|
34
|
+
`Text must not exceed ${MAX_MESSAGE_BYTES} UTF-8 bytes`
|
|
35
|
+
);
|
|
36
|
+
var NonEmptyBoundedTextSchema = BoundedTextSchema.refine((value) => value.length > 0, "Text must not be empty");
|
|
37
|
+
var CompletionDetailSchema = external_exports.string().trim().min(1).refine(
|
|
38
|
+
(value) => Buffer.byteLength(value, "utf8") <= MAX_COMPLETION_DETAIL_BYTES,
|
|
39
|
+
`Completion evidence must not exceed ${MAX_COMPLETION_DETAIL_BYTES} UTF-8 bytes`
|
|
40
|
+
);
|
|
41
|
+
var PalPresenceSchema = external_exports.object({
|
|
42
|
+
version: VersionSchema,
|
|
43
|
+
id: UuidSchema,
|
|
44
|
+
alias: PalAliasSchema,
|
|
45
|
+
projectPath: external_exports.string().min(1).refine(
|
|
46
|
+
(value) => Buffer.byteLength(value, "utf8") <= MAX_PROJECT_PATH_BYTES,
|
|
47
|
+
`Project path must not exceed ${MAX_PROJECT_PATH_BYTES} UTF-8 bytes`
|
|
48
|
+
),
|
|
49
|
+
connectedAt: external_exports.iso.datetime(),
|
|
50
|
+
lastSeenAt: external_exports.iso.datetime()
|
|
51
|
+
}).strict();
|
|
52
|
+
var PalPresenceListSchema = external_exports.array(PalPresenceSchema).max(MAX_ACTIVE_PALS);
|
|
53
|
+
var PalTaskMessageSchema = external_exports.object({
|
|
54
|
+
version: VersionSchema,
|
|
55
|
+
type: external_exports.literal("task"),
|
|
56
|
+
messageId: UuidSchema,
|
|
57
|
+
target: PalTargetSchema,
|
|
58
|
+
goal: NonEmptyBoundedTextSchema
|
|
59
|
+
}).strict();
|
|
60
|
+
var PalTaskEventSchema = external_exports.object({
|
|
61
|
+
version: VersionSchema,
|
|
62
|
+
type: external_exports.literal("task-event"),
|
|
63
|
+
messageId: UuidSchema,
|
|
64
|
+
taskId: UuidSchema,
|
|
65
|
+
senderId: UuidSchema,
|
|
66
|
+
recipientId: UuidSchema,
|
|
67
|
+
status: external_exports.enum(["accepted", "started", "progress", "completed", "failed", "cancelled"]),
|
|
68
|
+
detail: BoundedTextSchema.optional()
|
|
69
|
+
}).strict();
|
|
70
|
+
var DeliveryReceiptSchema = external_exports.object({
|
|
71
|
+
version: VersionSchema,
|
|
72
|
+
type: external_exports.literal("delivery-receipt"),
|
|
73
|
+
messageId: UuidSchema,
|
|
74
|
+
status: external_exports.enum(["delivered", "duplicate", "rejected"]),
|
|
75
|
+
recipientIds: external_exports.array(UuidSchema).max(MAX_PARTICIPANTS),
|
|
76
|
+
error: BoundedTextSchema.optional()
|
|
77
|
+
}).strict();
|
|
78
|
+
var CoWorkParticipantSchema = external_exports.object({
|
|
79
|
+
palId: UuidSchema,
|
|
80
|
+
required: external_exports.boolean()
|
|
81
|
+
}).strict();
|
|
82
|
+
var CoWorkProposalParticipantsSchema = external_exports.array(CoWorkParticipantSchema).min(2).max(MAX_PARTICIPANTS).superRefine((participants, context) => {
|
|
83
|
+
const seen = /* @__PURE__ */ new Set();
|
|
84
|
+
for (const [index, participant] of participants.entries()) {
|
|
85
|
+
const id = participant.palId.toLowerCase();
|
|
86
|
+
if (seen.has(id)) {
|
|
87
|
+
context.addIssue({ code: "custom", path: [index, "palId"], message: "Duplicate participant" });
|
|
88
|
+
}
|
|
89
|
+
seen.add(id);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
var CoWorkPlanTaskSchema = external_exports.object({
|
|
93
|
+
id: external_exports.string().min(1).max(128),
|
|
94
|
+
assigneeId: UuidSchema,
|
|
95
|
+
description: NonEmptyBoundedTextSchema,
|
|
96
|
+
dependsOn: external_exports.array(external_exports.string().min(1).max(128)).max(MAX_PLAN_TASKS)
|
|
97
|
+
}).strict();
|
|
98
|
+
var CoWorkPlanSchema = external_exports.object({
|
|
99
|
+
version: VersionSchema,
|
|
100
|
+
coWorkId: UuidSchema,
|
|
101
|
+
epoch: external_exports.number().int().positive(),
|
|
102
|
+
goal: NonEmptyBoundedTextSchema,
|
|
103
|
+
participants: external_exports.array(CoWorkParticipantSchema).min(1).max(MAX_PARTICIPANTS),
|
|
104
|
+
tasks: external_exports.array(CoWorkPlanTaskSchema).min(1).max(MAX_PLAN_TASKS)
|
|
105
|
+
}).strict().superRefine((plan, context) => {
|
|
106
|
+
if (Buffer.byteLength(JSON.stringify(plan), "utf8") > MAX_PLAN_ENCODED_BYTES) {
|
|
107
|
+
context.addIssue({ code: "custom", message: `Encoded plan must not exceed ${MAX_PLAN_ENCODED_BYTES} UTF-8 bytes` });
|
|
108
|
+
}
|
|
109
|
+
const participantIds = /* @__PURE__ */ new Set();
|
|
110
|
+
for (const [index, participant] of plan.participants.entries()) {
|
|
111
|
+
if (participantIds.has(participant.palId)) {
|
|
112
|
+
context.addIssue({ code: "custom", path: ["participants", index, "palId"], message: "Duplicate participant" });
|
|
113
|
+
}
|
|
114
|
+
participantIds.add(participant.palId);
|
|
115
|
+
}
|
|
116
|
+
const taskIds = /* @__PURE__ */ new Set();
|
|
117
|
+
for (const [index, task] of plan.tasks.entries()) {
|
|
118
|
+
if (taskIds.has(task.id)) {
|
|
119
|
+
context.addIssue({ code: "custom", path: ["tasks", index, "id"], message: "Duplicate task id" });
|
|
120
|
+
}
|
|
121
|
+
taskIds.add(task.id);
|
|
122
|
+
if (!participantIds.has(task.assigneeId)) {
|
|
123
|
+
context.addIssue({ code: "custom", path: ["tasks", index, "assigneeId"], message: "Assignee is not a participant" });
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
for (const [index, task] of plan.tasks.entries()) {
|
|
127
|
+
for (const dependency of task.dependsOn) {
|
|
128
|
+
if (!taskIds.has(dependency) || dependency === task.id) {
|
|
129
|
+
context.addIssue({ code: "custom", path: ["tasks", index, "dependsOn"], message: "Invalid task dependency" });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const dependencies = new Map(plan.tasks.map((task) => [task.id, task.dependsOn]));
|
|
134
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
135
|
+
const visited = /* @__PURE__ */ new Set();
|
|
136
|
+
const visit = (taskId) => {
|
|
137
|
+
if (visiting.has(taskId)) return true;
|
|
138
|
+
if (visited.has(taskId)) return false;
|
|
139
|
+
visiting.add(taskId);
|
|
140
|
+
for (const dependency of dependencies.get(taskId) ?? []) {
|
|
141
|
+
if (dependencies.has(dependency) && visit(dependency)) return true;
|
|
142
|
+
}
|
|
143
|
+
visiting.delete(taskId);
|
|
144
|
+
visited.add(taskId);
|
|
145
|
+
return false;
|
|
146
|
+
};
|
|
147
|
+
for (const [index, task] of plan.tasks.entries()) {
|
|
148
|
+
if (visit(task.id)) {
|
|
149
|
+
context.addIssue({ code: "custom", path: ["tasks", index, "dependsOn"], message: "Task dependencies must be acyclic" });
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
var CoWorkPhaseSchema = external_exports.enum([
|
|
155
|
+
"proposed",
|
|
156
|
+
"planning",
|
|
157
|
+
"prepared",
|
|
158
|
+
"running",
|
|
159
|
+
"verifying",
|
|
160
|
+
"completed",
|
|
161
|
+
"failed",
|
|
162
|
+
"cancelled"
|
|
163
|
+
]);
|
|
164
|
+
var IntegrationResultSchema = external_exports.object({
|
|
165
|
+
passed: external_exports.boolean(),
|
|
166
|
+
evidence: CompletionDetailSchema
|
|
167
|
+
}).strict();
|
|
168
|
+
var CoWorkCompletionAssertionSchema = external_exports.object({
|
|
169
|
+
participantId: UuidSchema,
|
|
170
|
+
passed: external_exports.boolean(),
|
|
171
|
+
detail: CompletionDetailSchema.optional()
|
|
172
|
+
}).strict();
|
|
173
|
+
var CoWorkSnapshotSchema = external_exports.object({
|
|
174
|
+
version: VersionSchema,
|
|
175
|
+
coWorkId: UuidSchema,
|
|
176
|
+
epoch: external_exports.number().int().positive(),
|
|
177
|
+
phase: CoWorkPhaseSchema,
|
|
178
|
+
goal: NonEmptyBoundedTextSchema,
|
|
179
|
+
participants: external_exports.array(CoWorkParticipantSchema).min(1).max(MAX_PARTICIPANTS),
|
|
180
|
+
integrationOwnerId: UuidSchema,
|
|
181
|
+
acceptedParticipantIds: external_exports.array(UuidSchema).max(MAX_PARTICIPANTS),
|
|
182
|
+
planHash: external_exports.string().regex(/^[a-f0-9]{64}$/).nullable(),
|
|
183
|
+
plan: CoWorkPlanSchema.nullable(),
|
|
184
|
+
planAcceptedParticipantIds: external_exports.array(UuidSchema).max(MAX_PARTICIPANTS),
|
|
185
|
+
readyParticipantIds: external_exports.array(UuidSchema).max(MAX_PARTICIPANTS),
|
|
186
|
+
completedParticipantIds: external_exports.array(UuidSchema).max(MAX_PARTICIPANTS),
|
|
187
|
+
completionAssertions: external_exports.array(CoWorkCompletionAssertionSchema).max(MAX_PARTICIPANTS),
|
|
188
|
+
integration: IntegrationResultSchema.nullable()
|
|
189
|
+
}).strict().superRefine((snapshot, context) => {
|
|
190
|
+
if (Buffer.byteLength(JSON.stringify(snapshot), "utf8") > MAX_SNAPSHOT_ENCODED_BYTES) {
|
|
191
|
+
context.addIssue({ code: "custom", message: `Encoded snapshot must not exceed ${MAX_SNAPSHOT_ENCODED_BYTES} UTF-8 bytes` });
|
|
192
|
+
}
|
|
193
|
+
const participantIds = new Set(snapshot.participants.map(({ palId }) => palId));
|
|
194
|
+
const requiredParticipantIds = new Set(snapshot.participants.filter(({ required }) => required).map(({ palId }) => palId));
|
|
195
|
+
if (!requiredParticipantIds.has(snapshot.integrationOwnerId)) {
|
|
196
|
+
context.addIssue({ code: "custom", path: ["integrationOwnerId"], message: "Integration owner must be a required participant" });
|
|
197
|
+
}
|
|
198
|
+
const assertionIds = /* @__PURE__ */ new Set();
|
|
199
|
+
let assertionBytes = 0;
|
|
200
|
+
for (const [index, assertion] of snapshot.completionAssertions.entries()) {
|
|
201
|
+
if (!participantIds.has(assertion.participantId)) {
|
|
202
|
+
context.addIssue({ code: "custom", path: ["completionAssertions", index, "participantId"], message: "Assertion owner must be a participant" });
|
|
203
|
+
}
|
|
204
|
+
if (assertionIds.has(assertion.participantId)) {
|
|
205
|
+
context.addIssue({ code: "custom", path: ["completionAssertions", index, "participantId"], message: "Duplicate completion assertion" });
|
|
206
|
+
}
|
|
207
|
+
assertionIds.add(assertion.participantId);
|
|
208
|
+
assertionBytes += Buffer.byteLength(assertion.detail ?? "", "utf8");
|
|
209
|
+
}
|
|
210
|
+
if (assertionBytes > MAX_COMPLETION_ASSERTIONS_BYTES) {
|
|
211
|
+
context.addIssue({ code: "custom", path: ["completionAssertions"], message: `Completion assertions must not exceed ${MAX_COMPLETION_ASSERTIONS_BYTES} UTF-8 bytes in aggregate` });
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
var RequestBase = {
|
|
215
|
+
version: VersionSchema,
|
|
216
|
+
requestId: UuidSchema
|
|
217
|
+
};
|
|
218
|
+
var RegisterRequestSchema = external_exports.object({
|
|
219
|
+
...RequestBase,
|
|
220
|
+
type: external_exports.literal("register"),
|
|
221
|
+
authToken: external_exports.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
222
|
+
presence: PalPresenceSchema
|
|
223
|
+
}).strict();
|
|
224
|
+
var HeartbeatRequestSchema = external_exports.object({ ...RequestBase, type: external_exports.literal("heartbeat") }).strict();
|
|
225
|
+
var ListRequestSchema = external_exports.object({ ...RequestBase, type: external_exports.literal("list") }).strict();
|
|
226
|
+
var DisconnectRequestSchema = external_exports.object({ ...RequestBase, type: external_exports.literal("disconnect") }).strict();
|
|
227
|
+
var ChatRequestSchema = external_exports.object({
|
|
228
|
+
...RequestBase,
|
|
229
|
+
type: external_exports.literal("chat"),
|
|
230
|
+
messageId: UuidSchema,
|
|
231
|
+
target: PalTargetSchema,
|
|
232
|
+
message: NonEmptyBoundedTextSchema
|
|
233
|
+
}).strict();
|
|
234
|
+
var TaskRequestSchema = external_exports.object({
|
|
235
|
+
...RequestBase,
|
|
236
|
+
type: external_exports.literal("task"),
|
|
237
|
+
messageId: UuidSchema,
|
|
238
|
+
target: PalTargetSchema,
|
|
239
|
+
goal: NonEmptyBoundedTextSchema
|
|
240
|
+
}).strict();
|
|
241
|
+
var CoWorkProposeRequestSchema = external_exports.object({
|
|
242
|
+
...RequestBase,
|
|
243
|
+
type: external_exports.literal("cowork-propose"),
|
|
244
|
+
coWorkId: UuidSchema,
|
|
245
|
+
goal: NonEmptyBoundedTextSchema,
|
|
246
|
+
participants: CoWorkProposalParticipantsSchema
|
|
247
|
+
}).strict();
|
|
248
|
+
var CoWorkAcceptanceRequestSchema = external_exports.object({
|
|
249
|
+
...RequestBase,
|
|
250
|
+
type: external_exports.literal("cowork-accept"),
|
|
251
|
+
coWorkId: UuidSchema,
|
|
252
|
+
epoch: external_exports.number().int().positive()
|
|
253
|
+
}).strict();
|
|
254
|
+
var CoWorkPlanRequestSchema = external_exports.object({ ...RequestBase, type: external_exports.literal("cowork-plan"), plan: CoWorkPlanSchema }).strict();
|
|
255
|
+
var CoWorkPlanAcceptanceRequestSchema = external_exports.object({
|
|
256
|
+
...RequestBase,
|
|
257
|
+
type: external_exports.literal("cowork-plan-accept"),
|
|
258
|
+
coWorkId: UuidSchema,
|
|
259
|
+
epoch: external_exports.number().int().positive(),
|
|
260
|
+
planHash: external_exports.string().regex(/^[a-f0-9]{64}$/)
|
|
261
|
+
}).strict();
|
|
262
|
+
var CoWorkReadyRequestSchema = external_exports.object({
|
|
263
|
+
...RequestBase,
|
|
264
|
+
type: external_exports.literal("cowork-ready"),
|
|
265
|
+
coWorkId: UuidSchema,
|
|
266
|
+
epoch: external_exports.number().int().positive(),
|
|
267
|
+
planHash: external_exports.string().regex(/^[a-f0-9]{64}$/)
|
|
268
|
+
}).strict();
|
|
269
|
+
var CoWorkCompleteRequestSchema = external_exports.object({
|
|
270
|
+
...RequestBase,
|
|
271
|
+
type: external_exports.literal("cowork-complete"),
|
|
272
|
+
coWorkId: UuidSchema,
|
|
273
|
+
epoch: external_exports.number().int().positive(),
|
|
274
|
+
planHash: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
275
|
+
passed: external_exports.boolean(),
|
|
276
|
+
detail: CompletionDetailSchema.optional()
|
|
277
|
+
}).strict();
|
|
278
|
+
var CoWorkIntegrationRequestSchema = external_exports.object({
|
|
279
|
+
...RequestBase,
|
|
280
|
+
type: external_exports.literal("cowork-integration"),
|
|
281
|
+
coWorkId: UuidSchema,
|
|
282
|
+
epoch: external_exports.number().int().positive(),
|
|
283
|
+
planHash: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
284
|
+
passed: external_exports.boolean(),
|
|
285
|
+
evidence: CompletionDetailSchema
|
|
286
|
+
}).strict();
|
|
287
|
+
var CoWorkGetRequestSchema = external_exports.object({
|
|
288
|
+
...RequestBase,
|
|
289
|
+
type: external_exports.literal("cowork-get"),
|
|
290
|
+
coWorkId: UuidSchema
|
|
291
|
+
}).strict();
|
|
292
|
+
var CoWorkCancelRequestSchema = external_exports.object({
|
|
293
|
+
...RequestBase,
|
|
294
|
+
type: external_exports.literal("cowork-cancel"),
|
|
295
|
+
coWorkId: UuidSchema,
|
|
296
|
+
reason: NonEmptyBoundedTextSchema
|
|
297
|
+
}).strict();
|
|
298
|
+
var BrokerRequestSchema = external_exports.discriminatedUnion("type", [
|
|
299
|
+
RegisterRequestSchema,
|
|
300
|
+
HeartbeatRequestSchema,
|
|
301
|
+
ListRequestSchema,
|
|
302
|
+
DisconnectRequestSchema,
|
|
303
|
+
ChatRequestSchema,
|
|
304
|
+
TaskRequestSchema,
|
|
305
|
+
CoWorkProposeRequestSchema,
|
|
306
|
+
CoWorkAcceptanceRequestSchema,
|
|
307
|
+
CoWorkPlanRequestSchema,
|
|
308
|
+
CoWorkPlanAcceptanceRequestSchema,
|
|
309
|
+
CoWorkReadyRequestSchema,
|
|
310
|
+
CoWorkCompleteRequestSchema,
|
|
311
|
+
CoWorkIntegrationRequestSchema,
|
|
312
|
+
CoWorkGetRequestSchema,
|
|
313
|
+
CoWorkCancelRequestSchema
|
|
314
|
+
]);
|
|
315
|
+
var BrokerOkResponseSchema = external_exports.object({
|
|
316
|
+
version: VersionSchema,
|
|
317
|
+
type: external_exports.literal("ok"),
|
|
318
|
+
requestId: UuidSchema,
|
|
319
|
+
data: external_exports.unknown()
|
|
320
|
+
}).strict();
|
|
321
|
+
var BrokerErrorResponseSchema = external_exports.object({
|
|
322
|
+
version: VersionSchema,
|
|
323
|
+
type: external_exports.literal("error"),
|
|
324
|
+
requestId: UuidSchema,
|
|
325
|
+
code: external_exports.enum(["invalid-request", "authentication-failed", "not-found", "ambiguous-target", "alias-conflict", "invalid-transition", "stale-epoch", "duplicate"]),
|
|
326
|
+
message: BoundedTextSchema
|
|
327
|
+
}).strict();
|
|
328
|
+
var ChatEventSchema = external_exports.object({
|
|
329
|
+
version: VersionSchema,
|
|
330
|
+
type: external_exports.literal("chat-event"),
|
|
331
|
+
messageId: UuidSchema,
|
|
332
|
+
senderId: UuidSchema,
|
|
333
|
+
recipientId: UuidSchema,
|
|
334
|
+
message: NonEmptyBoundedTextSchema
|
|
335
|
+
}).strict();
|
|
336
|
+
var CoWorkEventSchema = external_exports.object({
|
|
337
|
+
version: VersionSchema,
|
|
338
|
+
type: external_exports.literal("cowork-event"),
|
|
339
|
+
action: external_exports.enum(["PROPOSE", "PLAN", "START", "END", "FAIL", "CANCEL"]),
|
|
340
|
+
actorId: UuidSchema,
|
|
341
|
+
coWorkId: UuidSchema,
|
|
342
|
+
epoch: external_exports.number().int().positive(),
|
|
343
|
+
planHash: external_exports.string().regex(/^[a-f0-9]{64}$/).nullable(),
|
|
344
|
+
snapshot: CoWorkSnapshotSchema
|
|
345
|
+
}).strict();
|
|
346
|
+
var BrokerEventSchema = external_exports.union([ChatEventSchema, PalTaskEventSchema, DeliveryReceiptSchema, CoWorkEventSchema]);
|
|
347
|
+
var BrokerEventResponseSchema = external_exports.object({
|
|
348
|
+
version: VersionSchema,
|
|
349
|
+
type: external_exports.literal("event"),
|
|
350
|
+
event: BrokerEventSchema
|
|
351
|
+
}).strict();
|
|
352
|
+
var BrokerResponseSchema = external_exports.discriminatedUnion("type", [
|
|
353
|
+
BrokerOkResponseSchema,
|
|
354
|
+
BrokerErrorResponseSchema,
|
|
355
|
+
BrokerEventResponseSchema
|
|
356
|
+
]);
|
|
357
|
+
var ControlFrameSchema = external_exports.string().refine(
|
|
358
|
+
(frame) => Buffer.byteLength(frame, "utf8") <= MAX_CONTROL_FRAME_BYTES,
|
|
359
|
+
`Control frame must not exceed ${MAX_CONTROL_FRAME_BYTES} UTF-8 bytes`
|
|
360
|
+
);
|
|
361
|
+
function encodeControlFrame(value) {
|
|
362
|
+
const encoded = JSON.stringify(value);
|
|
363
|
+
if (encoded === void 0) throw new Error("Control frame cannot encode undefined");
|
|
364
|
+
const parsed = ControlFrameSchema.safeParse(encoded);
|
|
365
|
+
if (!parsed.success) throw new Error(`Control frame is too large (maximum ${MAX_CONTROL_FRAME_BYTES} UTF-8 bytes)`);
|
|
366
|
+
return `${parsed.data}
|
|
367
|
+
`;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export {
|
|
371
|
+
MAX_ALIAS_LENGTH,
|
|
372
|
+
MAX_MESSAGE_BYTES,
|
|
373
|
+
MAX_CONTROL_FRAME_BYTES,
|
|
374
|
+
MAX_ACTIVE_PALS,
|
|
375
|
+
MAX_COMPLETION_DETAIL_BYTES,
|
|
376
|
+
MIN_UUID_PREFIX_LENGTH,
|
|
377
|
+
normalizePalIdentity,
|
|
378
|
+
PalAliasSchema,
|
|
379
|
+
PalTargetSchema,
|
|
380
|
+
PalPresenceSchema,
|
|
381
|
+
PalPresenceListSchema,
|
|
382
|
+
DeliveryReceiptSchema,
|
|
383
|
+
CoWorkProposalParticipantsSchema,
|
|
384
|
+
CoWorkPlanSchema,
|
|
385
|
+
CoWorkSnapshotSchema,
|
|
386
|
+
BrokerRequestSchema,
|
|
387
|
+
BrokerResponseSchema,
|
|
388
|
+
encodeControlFrame
|
|
389
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as createFlavorRequire } from "node:module"; const require = createFlavorRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/utils/execFileNoThrow.ts
|
|
5
|
+
import { execFile } from "child_process";
|
|
6
|
+
function execFileNoThrow(file, args, options = {}) {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
const child = execFile(file, args, {
|
|
9
|
+
timeout: options.timeout,
|
|
10
|
+
maxBuffer: options.maxBuffer,
|
|
11
|
+
cwd: options.useCwd === false ? void 0 : process.cwd(),
|
|
12
|
+
env: options.env,
|
|
13
|
+
encoding: "utf8",
|
|
14
|
+
windowsHide: true,
|
|
15
|
+
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
16
|
+
}, (error, stdout, stderr) => {
|
|
17
|
+
resolve({
|
|
18
|
+
stdout,
|
|
19
|
+
stderr,
|
|
20
|
+
code: typeof error?.code === "number" ? error.code : error ? 1 : 0,
|
|
21
|
+
...error === null ? {} : { error: error.message }
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
if (options.input !== void 0) child.stdin?.end(options.input);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
execFileNoThrow
|
|
30
|
+
};
|