@abelxiaoxing/cadence 2.0.30 → 2.0.32
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.de.md +5 -2
- package/README.es.md +5 -2
- package/README.fr.md +5 -2
- package/README.ja.md +7 -2
- package/README.ko.md +6 -2
- package/README.md +5 -2
- package/README.pt-BR.md +5 -2
- package/README.ru.md +5 -2
- package/README.zh-CN.md +5 -2
- package/docs/conversation-mode.md +3 -1
- package/docs/history.md +25 -6
- package/docs/service-management.md +3 -2
- package/package.json +9 -5
- package/src/cadence-mode.ts +3 -1
- package/src/index.ts +3 -0
- package/src/native-build.ts +1 -1
- package/src/sdk-worker.mjs +79 -20
- package/src/service/contracts/workbench.ts +231 -63
- package/src/service/coordination.ts +1 -0
- package/src/service-cli.mjs +4 -3
- package/src/service-host.mjs +1900 -1134
- package/src/session-entries.mjs +7 -0
- package/src/session-sharing.ts +120 -0
- package/web/dist/assets/cadence.css +1 -1
- package/web/dist/assets/cadence.js +13 -13
- package/web/dist/manifest.json +7 -7
- package/src/conversation-context.mjs +0 -225
|
@@ -51,7 +51,7 @@ export function decodeCadenceConversation(v: unknown): CadenceConversation {
|
|
|
51
51
|
...(degraded ? ["notice"] : []),
|
|
52
52
|
]);
|
|
53
53
|
return {
|
|
54
|
-
id:
|
|
54
|
+
id: decodeSessionId(o.id),
|
|
55
55
|
revision: integer(o.revision, 0),
|
|
56
56
|
enabled: bool(o.enabled),
|
|
57
57
|
head: nullable(o.head, decodeId),
|
|
@@ -60,7 +60,20 @@ export function decodeCadenceConversation(v: unknown): CadenceConversation {
|
|
|
60
60
|
...(degraded ? { notice: text(o.notice, 1024, true) } : {}),
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
/**
|
|
63
|
+
/** A conversation's identity: the Pi session id shared with the terminal. */
|
|
64
|
+
export function decodeSessionId(v: unknown): string {
|
|
65
|
+
const s = text(v, 128, true);
|
|
66
|
+
if (!/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/.test(s))
|
|
67
|
+
throw new ContractError("invalid");
|
|
68
|
+
return s;
|
|
69
|
+
}
|
|
70
|
+
/** One entry of a Pi session (eight hex characters when Pi writes it). */
|
|
71
|
+
export function decodeEntryId(v: unknown): string {
|
|
72
|
+
const s = text(v, 64, true);
|
|
73
|
+
if (!/^[A-Za-z0-9_-]+$/.test(s)) throw new ContractError("invalid");
|
|
74
|
+
return s;
|
|
75
|
+
}
|
|
76
|
+
/** The conversation (Pi session) that started an active workflow, browser or terminal. */
|
|
64
77
|
export interface WorkflowLink {
|
|
65
78
|
runId: string;
|
|
66
79
|
conversationId: string;
|
|
@@ -73,12 +86,20 @@ export type WorkbenchRead =
|
|
|
73
86
|
| { kind: "workflow-transcript"; id: string; stepId: string }
|
|
74
87
|
| { kind: "workflow"; id: string }
|
|
75
88
|
| { kind: "conversation-active" }
|
|
76
|
-
| { kind: "conversations"; after?: ChatCursor | null
|
|
89
|
+
| { kind: "conversations"; after?: ChatCursor | null }
|
|
77
90
|
| { kind: "task-origin"; taskId: string }
|
|
78
|
-
| {
|
|
91
|
+
| {
|
|
92
|
+
kind: "conversation";
|
|
93
|
+
id: string;
|
|
94
|
+
/** The branch to read, by its last entry; null reads the session's current leaf. */
|
|
95
|
+
leaf: string | null;
|
|
96
|
+
/** The leaf read last: the reply says whether the branch still continues it. */
|
|
97
|
+
known: string | null;
|
|
98
|
+
}
|
|
79
99
|
| {
|
|
80
100
|
kind: "conversation-turn";
|
|
81
101
|
id: string;
|
|
102
|
+
leaf: string | null;
|
|
82
103
|
ordinal: number;
|
|
83
104
|
/** Exclusive end of the steps to list; null lists the latest ones. */
|
|
84
105
|
before: number | null;
|
|
@@ -86,10 +107,13 @@ export type WorkbenchRead =
|
|
|
86
107
|
| {
|
|
87
108
|
kind: "conversation-step";
|
|
88
109
|
id: string;
|
|
110
|
+
leaf: string | null;
|
|
89
111
|
turnId: string;
|
|
90
112
|
step: number;
|
|
91
113
|
part: number;
|
|
92
114
|
}
|
|
115
|
+
| { kind: "conversation-tree"; id: string; leaf: string | null }
|
|
116
|
+
| { kind: "conversation-legacy" }
|
|
93
117
|
| { kind: "files"; path: string }
|
|
94
118
|
| { kind: "file"; path: string }
|
|
95
119
|
| { kind: "directories"; path: string }
|
|
@@ -152,7 +176,8 @@ export type WorkbenchCommand =
|
|
|
152
176
|
turnId: string;
|
|
153
177
|
epoch: string;
|
|
154
178
|
}
|
|
155
|
-
| { kind: "open-project"; commandId: string; path: string; epoch: string }
|
|
179
|
+
| { kind: "open-project"; commandId: string; path: string; epoch: string }
|
|
180
|
+
| { kind: "conversation-migrate"; commandId: string };
|
|
156
181
|
export type ChatStatus =
|
|
157
182
|
| "queued"
|
|
158
183
|
| "running"
|
|
@@ -197,16 +222,43 @@ export interface ChatStep {
|
|
|
197
222
|
/** Stored parts that hold the full item; 0 when nothing more is recorded. */
|
|
198
223
|
parts: number;
|
|
199
224
|
}
|
|
225
|
+
/** One turn of a conversation branch: a user message and what followed it. */
|
|
200
226
|
export interface ChatTurnHeader {
|
|
227
|
+
/** The user message's session entry id; a browser command id while Pi has not
|
|
228
|
+
* written that message yet. */
|
|
201
229
|
id: string;
|
|
202
|
-
epoch: string;
|
|
203
230
|
status: ChatStatus;
|
|
204
231
|
notice: string;
|
|
205
232
|
omitted: ChatTurn["omitted"];
|
|
206
233
|
steps: number;
|
|
207
234
|
/** Leading steps that can no longer change: all of them once settled. */
|
|
208
235
|
stable: number;
|
|
236
|
+
/** The turn's last session entry: a new branch can continue from it. */
|
|
237
|
+
entry: string | null;
|
|
238
|
+
/** When the turn began (epoch ms), 0 when unrecorded. */
|
|
239
|
+
at: number;
|
|
209
240
|
}
|
|
241
|
+
/** A browser message that left nothing in the session, shown after the branch
|
|
242
|
+
* it was sent from: a refusal before any model call or a Cadence control reply. */
|
|
243
|
+
export interface ChatAttempt {
|
|
244
|
+
commandId: string;
|
|
245
|
+
text: string;
|
|
246
|
+
status: ChatStatus;
|
|
247
|
+
notice: string;
|
|
248
|
+
}
|
|
249
|
+
/** A user message in a session's tree, linked to the nearest earlier one. */
|
|
250
|
+
export interface ChatTreeNode {
|
|
251
|
+
id: string;
|
|
252
|
+
parent: string | null;
|
|
253
|
+
text: string;
|
|
254
|
+
at: number;
|
|
255
|
+
/** The newest entry below this message: reading it shows this branch. */
|
|
256
|
+
leaf: string;
|
|
257
|
+
/** On the branch the read named. */
|
|
258
|
+
current: boolean;
|
|
259
|
+
}
|
|
260
|
+
/** Nodes one `conversation-tree` read returns, newest kept when more exist. */
|
|
261
|
+
export const TREE_NODES = 1000;
|
|
210
262
|
/** Encoded bytes of message text a listed step keeps. */
|
|
211
263
|
export const STEP_TEXT_BYTES = 16 * 1024;
|
|
212
264
|
const TARGET_BYTES = 1024;
|
|
@@ -274,15 +326,21 @@ export interface ChatCursor {
|
|
|
274
326
|
}
|
|
275
327
|
function decodeChatCursor(value: unknown): ChatCursor {
|
|
276
328
|
const o = closed(value, ["id", "updatedAt"]);
|
|
277
|
-
return { id:
|
|
329
|
+
return { id: decodeSessionId(o.id), updatedAt: integer(o.updatedAt, 0) };
|
|
278
330
|
}
|
|
279
331
|
export interface ChatSummary {
|
|
332
|
+
/** The Pi session id. */
|
|
280
333
|
id: string;
|
|
281
334
|
title: string;
|
|
282
|
-
|
|
335
|
+
/** The session's current leaf entry; null before Pi has written any entry. */
|
|
336
|
+
leaf: string | null;
|
|
283
337
|
status: ChatStatus;
|
|
284
338
|
updatedAt: number;
|
|
339
|
+
/** Who created the session: the Pi terminal or the browser. */
|
|
340
|
+
origin: "terminal" | "webui";
|
|
285
341
|
cadence?: boolean;
|
|
342
|
+
/** The browser reply in progress, which Stop interrupts. */
|
|
343
|
+
live?: { commandId: string; epoch: string };
|
|
286
344
|
}
|
|
287
345
|
export interface FileEntry {
|
|
288
346
|
name: string;
|
|
@@ -320,12 +378,38 @@ export type WorkbenchResult =
|
|
|
320
378
|
| { kind: "workflow"; commandId: string | null; response: WorkflowResponse }
|
|
321
379
|
| { kind: "task-origin"; taskId: string; conversationId: string | null }
|
|
322
380
|
| { kind: "conversation-active"; entries: ChatSummary[] }
|
|
323
|
-
| { kind: "conversations
|
|
324
|
-
| {
|
|
325
|
-
|
|
381
|
+
| { kind: "conversations"; entries: ChatSummary[]; next: ChatCursor | null }
|
|
382
|
+
| {
|
|
383
|
+
kind: "conversation";
|
|
384
|
+
summary: ChatSummary | null;
|
|
385
|
+
/** The branch read, by its last entry (null: nothing written yet). */
|
|
386
|
+
leaf: string | null;
|
|
387
|
+
/** False when the branch read no longer contains the requested `known` leaf. */
|
|
388
|
+
continues: boolean;
|
|
389
|
+
turns: number;
|
|
390
|
+
/** Leaves in the whole session tree: more than one means branches. */
|
|
391
|
+
branches: number;
|
|
392
|
+
/** Workflows the terminal started in this session. */
|
|
393
|
+
runs: string[];
|
|
394
|
+
attempt: ChatAttempt | null;
|
|
395
|
+
}
|
|
396
|
+
| {
|
|
397
|
+
kind: "conversation-tree";
|
|
398
|
+
conversationId: string;
|
|
399
|
+
nodes: ChatTreeNode[];
|
|
400
|
+
truncated: boolean;
|
|
401
|
+
}
|
|
402
|
+
| { kind: "conversation-legacy"; pending: number }
|
|
403
|
+
| {
|
|
404
|
+
kind: "conversation-migrated";
|
|
405
|
+
commandId: string;
|
|
406
|
+
migrated: number;
|
|
407
|
+
skipped: number;
|
|
408
|
+
}
|
|
326
409
|
| {
|
|
327
410
|
kind: "conversation-turn";
|
|
328
411
|
conversationId: string;
|
|
412
|
+
leaf: string | null;
|
|
329
413
|
ordinal: number;
|
|
330
414
|
turn: ChatTurnHeader;
|
|
331
415
|
/** Index of the first listed step. */
|
|
@@ -335,6 +419,7 @@ export type WorkbenchResult =
|
|
|
335
419
|
| {
|
|
336
420
|
kind: "conversation-step";
|
|
337
421
|
conversationId: string;
|
|
422
|
+
leaf: string | null;
|
|
338
423
|
turnId: string;
|
|
339
424
|
step: number;
|
|
340
425
|
part: number;
|
|
@@ -375,27 +460,37 @@ export function decodeWorkbenchRead(v: unknown): WorkbenchRead {
|
|
|
375
460
|
const kind = Object.getOwnPropertyDescriptor(v ?? {}, "kind")?.value;
|
|
376
461
|
switch (kind) {
|
|
377
462
|
case "conversation-turn": {
|
|
378
|
-
const o = closed(v, ["kind", "id", "ordinal", "before"]);
|
|
463
|
+
const o = closed(v, ["kind", "id", "leaf", "ordinal", "before"]);
|
|
379
464
|
return {
|
|
380
465
|
kind,
|
|
381
|
-
id:
|
|
466
|
+
id: decodeSessionId(o.id),
|
|
467
|
+
leaf: nullable(o.leaf, decodeEntryId),
|
|
382
468
|
ordinal: integer(o.ordinal, 0),
|
|
383
469
|
before: nullable(o.before, (b) => integer(b, 0)),
|
|
384
470
|
};
|
|
385
471
|
}
|
|
386
472
|
case "conversation-step": {
|
|
387
|
-
const o = closed(v, ["kind", "id", "turnId", "step", "part"]);
|
|
473
|
+
const o = closed(v, ["kind", "id", "leaf", "turnId", "step", "part"]);
|
|
388
474
|
return {
|
|
389
475
|
kind,
|
|
390
|
-
id:
|
|
391
|
-
|
|
476
|
+
id: decodeSessionId(o.id),
|
|
477
|
+
leaf: nullable(o.leaf, decodeEntryId),
|
|
478
|
+
turnId: decodeEntryId(o.turnId),
|
|
392
479
|
step: integer(o.step, 0),
|
|
393
480
|
part: integer(o.part, 0),
|
|
394
481
|
};
|
|
395
482
|
}
|
|
396
483
|
case "cadence-conversation": {
|
|
397
484
|
const o = closed(v, ["kind", "id"]);
|
|
398
|
-
return { kind, id:
|
|
485
|
+
return { kind, id: decodeSessionId(o.id) };
|
|
486
|
+
}
|
|
487
|
+
case "conversation-tree": {
|
|
488
|
+
const o = closed(v, ["kind", "id", "leaf"]);
|
|
489
|
+
return {
|
|
490
|
+
kind,
|
|
491
|
+
id: decodeSessionId(o.id),
|
|
492
|
+
leaf: nullable(o.leaf, decodeEntryId),
|
|
493
|
+
};
|
|
399
494
|
}
|
|
400
495
|
case "workflow-history": {
|
|
401
496
|
const continued = Object.hasOwn(v as object, "scan");
|
|
@@ -419,20 +514,15 @@ export function decodeWorkbenchRead(v: unknown): WorkbenchRead {
|
|
|
419
514
|
return { kind, id: decodeId(o.id) };
|
|
420
515
|
}
|
|
421
516
|
case "conversations": {
|
|
422
|
-
const after = Object.hasOwn(v as object, "after")
|
|
423
|
-
|
|
424
|
-
const o = closed(v, [
|
|
425
|
-
"kind",
|
|
426
|
-
...(after ? ["after"] : []),
|
|
427
|
-
...(scan ? ["scan"] : []),
|
|
428
|
-
]);
|
|
517
|
+
const after = Object.hasOwn(v as object, "after");
|
|
518
|
+
const o = closed(v, ["kind", ...(after ? ["after"] : [])]);
|
|
429
519
|
return {
|
|
430
520
|
kind,
|
|
431
521
|
...(after ? { after: nullable(o.after, decodeChatCursor) } : {}),
|
|
432
|
-
...(scan ? { scan: decodeId(o.scan) } : {}),
|
|
433
522
|
};
|
|
434
523
|
}
|
|
435
524
|
case "conversation-active":
|
|
525
|
+
case "conversation-legacy":
|
|
436
526
|
case "projects":
|
|
437
527
|
closed(v, ["kind"]);
|
|
438
528
|
return { kind };
|
|
@@ -441,8 +531,13 @@ export function decodeWorkbenchRead(v: unknown): WorkbenchRead {
|
|
|
441
531
|
return { kind, taskId: decodeId(o.taskId) };
|
|
442
532
|
}
|
|
443
533
|
case "conversation": {
|
|
444
|
-
const o = closed(v, ["kind", "id"]);
|
|
445
|
-
return {
|
|
534
|
+
const o = closed(v, ["kind", "id", "leaf", "known"]);
|
|
535
|
+
return {
|
|
536
|
+
kind,
|
|
537
|
+
id: decodeSessionId(o.id),
|
|
538
|
+
leaf: nullable(o.leaf, decodeEntryId),
|
|
539
|
+
known: nullable(o.known, decodeEntryId),
|
|
540
|
+
};
|
|
446
541
|
}
|
|
447
542
|
default: {
|
|
448
543
|
const o = closed(v, ["kind", "path"]);
|
|
@@ -478,8 +573,8 @@ export function decodeWorkbenchCommand(v: unknown): WorkbenchCommand {
|
|
|
478
573
|
return {
|
|
479
574
|
kind,
|
|
480
575
|
commandId: decodeId(o.commandId),
|
|
481
|
-
conversationId:
|
|
482
|
-
head: nullable(o.head,
|
|
576
|
+
conversationId: decodeSessionId(o.conversationId),
|
|
577
|
+
head: nullable(o.head, decodeEntryId),
|
|
483
578
|
revision: integer(o.revision, 0),
|
|
484
579
|
};
|
|
485
580
|
}
|
|
@@ -497,8 +592,8 @@ export function decodeWorkbenchCommand(v: unknown): WorkbenchCommand {
|
|
|
497
592
|
return {
|
|
498
593
|
kind,
|
|
499
594
|
commandId: decodeId(o.commandId),
|
|
500
|
-
conversationId:
|
|
501
|
-
head: nullable(o.head,
|
|
595
|
+
conversationId: decodeSessionId(o.conversationId),
|
|
596
|
+
head: nullable(o.head, decodeEntryId),
|
|
502
597
|
text: text(o.text, 16384, true),
|
|
503
598
|
model: decodeChoiceVersion(o.model),
|
|
504
599
|
revision: integer(o.revision, 0),
|
|
@@ -517,7 +612,7 @@ export function decodeWorkbenchCommand(v: unknown): WorkbenchCommand {
|
|
|
517
612
|
const o = closed(v, kind === "cadence-approve" ? [...keys, "grant"] : keys);
|
|
518
613
|
const base = {
|
|
519
614
|
commandId: decodeId(o.commandId),
|
|
520
|
-
conversationId:
|
|
615
|
+
conversationId: decodeSessionId(o.conversationId),
|
|
521
616
|
revision: integer(o.revision, 0),
|
|
522
617
|
proposalId: decodeId(o.proposalId),
|
|
523
618
|
digest: decodeHash(o.digest),
|
|
@@ -548,8 +643,8 @@ export function decodeWorkbenchCommand(v: unknown): WorkbenchCommand {
|
|
|
548
643
|
return {
|
|
549
644
|
kind,
|
|
550
645
|
commandId: decodeId(o.commandId),
|
|
551
|
-
conversationId:
|
|
552
|
-
head: nullable(o.head,
|
|
646
|
+
conversationId: decodeSessionId(o.conversationId),
|
|
647
|
+
head: nullable(o.head, decodeEntryId),
|
|
553
648
|
text: text(o.text, 16 * 1024, true),
|
|
554
649
|
model: decodeChoiceVersion(o.model),
|
|
555
650
|
};
|
|
@@ -565,11 +660,15 @@ export function decodeWorkbenchCommand(v: unknown): WorkbenchCommand {
|
|
|
565
660
|
return {
|
|
566
661
|
kind,
|
|
567
662
|
commandId: decodeId(o.commandId),
|
|
568
|
-
conversationId:
|
|
663
|
+
conversationId: decodeSessionId(o.conversationId),
|
|
569
664
|
turnId: decodeId(o.turnId),
|
|
570
665
|
epoch: decodeId(o.epoch),
|
|
571
666
|
};
|
|
572
667
|
}
|
|
668
|
+
if (kind === "conversation-migrate") {
|
|
669
|
+
const o = closed(v, ["kind", "commandId"]);
|
|
670
|
+
return { kind, commandId: decodeId(o.commandId) };
|
|
671
|
+
}
|
|
573
672
|
const o = closed(v, ["kind", "commandId", "path", "epoch"]);
|
|
574
673
|
return {
|
|
575
674
|
kind: oneOf(o.kind, ["open-project"]),
|
|
@@ -649,18 +748,20 @@ function decodeChatStep(v: unknown): ChatStep {
|
|
|
649
748
|
function decodeChatTurnHeader(v: unknown): ChatTurnHeader {
|
|
650
749
|
const o = closed(v, [
|
|
651
750
|
"id",
|
|
652
|
-
"epoch",
|
|
653
751
|
"status",
|
|
654
752
|
"notice",
|
|
655
753
|
"omitted",
|
|
656
754
|
"steps",
|
|
657
755
|
"stable",
|
|
756
|
+
"entry",
|
|
757
|
+
"at",
|
|
658
758
|
]);
|
|
659
759
|
const omitted = closed(o.omitted, ["thinking", "media", "other"]);
|
|
660
760
|
const steps = integer(o.steps, 0);
|
|
661
761
|
return {
|
|
662
|
-
id:
|
|
663
|
-
|
|
762
|
+
id: decodeEntryId(o.id),
|
|
763
|
+
entry: nullable(o.entry, decodeEntryId),
|
|
764
|
+
at: integer(o.at, 0),
|
|
664
765
|
status: oneOf(o.status, statuses),
|
|
665
766
|
notice: text(o.notice, 1024),
|
|
666
767
|
omitted: {
|
|
@@ -673,23 +774,55 @@ function decodeChatTurnHeader(v: unknown): ChatTurnHeader {
|
|
|
673
774
|
};
|
|
674
775
|
}
|
|
675
776
|
export function decodeChatSummary(v: unknown): ChatSummary {
|
|
676
|
-
const
|
|
677
|
-
v !== null && typeof v === "object" && Object.hasOwn(v,
|
|
777
|
+
const has = (key: string) =>
|
|
778
|
+
v !== null && typeof v === "object" && Object.hasOwn(v, key);
|
|
678
779
|
const o = closed(v, [
|
|
679
780
|
"id",
|
|
680
781
|
"title",
|
|
681
|
-
"
|
|
782
|
+
"leaf",
|
|
682
783
|
"status",
|
|
683
784
|
"updatedAt",
|
|
684
|
-
|
|
785
|
+
"origin",
|
|
786
|
+
...(has("cadence") ? ["cadence"] : []),
|
|
787
|
+
...(has("live") ? ["live"] : []),
|
|
685
788
|
]);
|
|
789
|
+
const live = has("live") ? closed(o.live, ["commandId", "epoch"]) : null;
|
|
686
790
|
return {
|
|
687
|
-
id:
|
|
791
|
+
id: decodeSessionId(o.id),
|
|
688
792
|
title: text(o.title, 512, true),
|
|
689
|
-
|
|
793
|
+
leaf: nullable(o.leaf, decodeEntryId),
|
|
690
794
|
status: oneOf(o.status, statuses),
|
|
691
795
|
updatedAt: integer(o.updatedAt, 0),
|
|
692
|
-
|
|
796
|
+
origin: oneOf(o.origin, ["terminal", "webui"]),
|
|
797
|
+
...(has("cadence") ? { cadence: bool(o.cadence) } : {}),
|
|
798
|
+
...(live
|
|
799
|
+
? {
|
|
800
|
+
live: {
|
|
801
|
+
commandId: decodeId(live.commandId),
|
|
802
|
+
epoch: decodeId(live.epoch),
|
|
803
|
+
},
|
|
804
|
+
}
|
|
805
|
+
: {}),
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
function decodeChatAttempt(v: unknown): ChatAttempt {
|
|
809
|
+
const o = closed(v, ["commandId", "text", "status", "notice"]);
|
|
810
|
+
return {
|
|
811
|
+
commandId: decodeId(o.commandId),
|
|
812
|
+
text: text(o.text, 16 * 1024),
|
|
813
|
+
status: oneOf(o.status, statuses),
|
|
814
|
+
notice: text(o.notice, 1024),
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
function decodeChatTreeNode(v: unknown): ChatTreeNode {
|
|
818
|
+
const o = closed(v, ["id", "parent", "text", "at", "leaf", "current"]);
|
|
819
|
+
return {
|
|
820
|
+
id: decodeEntryId(o.id),
|
|
821
|
+
parent: nullable(o.parent, decodeEntryId),
|
|
822
|
+
text: text(o.text, 1024),
|
|
823
|
+
at: integer(o.at, 0),
|
|
824
|
+
leaf: decodeEntryId(o.leaf),
|
|
825
|
+
current: bool(o.current),
|
|
693
826
|
};
|
|
694
827
|
}
|
|
695
828
|
export function decodeWorkbenchResult(v: unknown): WorkbenchResult {
|
|
@@ -743,7 +876,7 @@ export function decodeWorkbenchResult(v: unknown): WorkbenchResult {
|
|
|
743
876
|
const l = closed(value, ["runId", "conversationId"]);
|
|
744
877
|
return {
|
|
745
878
|
runId: decodeId(l.runId),
|
|
746
|
-
conversationId:
|
|
879
|
+
conversationId: decodeSessionId(l.conversationId),
|
|
747
880
|
};
|
|
748
881
|
})
|
|
749
882
|
: [];
|
|
@@ -787,15 +920,7 @@ export function decodeWorkbenchResult(v: unknown): WorkbenchResult {
|
|
|
787
920
|
return {
|
|
788
921
|
kind,
|
|
789
922
|
taskId: decodeId(o.taskId),
|
|
790
|
-
conversationId: nullable(o.conversationId,
|
|
791
|
-
};
|
|
792
|
-
}
|
|
793
|
-
if (kind === "conversations-progress") {
|
|
794
|
-
const o = closed(v, ["kind", "after", "scan"]);
|
|
795
|
-
return {
|
|
796
|
-
kind,
|
|
797
|
-
after: nullable(o.after, decodeChatCursor),
|
|
798
|
-
scan: decodeId(o.scan),
|
|
923
|
+
conversationId: nullable(o.conversationId, decodeSessionId),
|
|
799
924
|
};
|
|
800
925
|
}
|
|
801
926
|
if (kind === "conversation-active") {
|
|
@@ -803,25 +928,65 @@ export function decodeWorkbenchResult(v: unknown): WorkbenchResult {
|
|
|
803
928
|
return { kind, entries: list(o.entries, 8, decodeChatSummary) };
|
|
804
929
|
}
|
|
805
930
|
if (kind === "conversations") {
|
|
806
|
-
const
|
|
807
|
-
const o = closed(v, ["kind", "entries", ...(paged ? ["next"] : [])]);
|
|
931
|
+
const o = closed(v, ["kind", "entries", "next"]);
|
|
808
932
|
return {
|
|
809
933
|
kind,
|
|
810
934
|
entries: list(o.entries, 200, decodeChatSummary),
|
|
811
|
-
|
|
935
|
+
next: nullable(o.next, decodeChatCursor),
|
|
812
936
|
};
|
|
813
937
|
}
|
|
814
938
|
if (kind === "conversation") {
|
|
815
|
-
const o = closed(v, [
|
|
939
|
+
const o = closed(v, [
|
|
940
|
+
"kind",
|
|
941
|
+
"summary",
|
|
942
|
+
"leaf",
|
|
943
|
+
"continues",
|
|
944
|
+
"turns",
|
|
945
|
+
"branches",
|
|
946
|
+
"runs",
|
|
947
|
+
"attempt",
|
|
948
|
+
]);
|
|
816
949
|
const summary = nullable(o.summary, decodeChatSummary),
|
|
817
950
|
turns = integer(o.turns, 0);
|
|
818
951
|
if (!summary && turns) throw new ContractError("invalid");
|
|
819
|
-
return {
|
|
952
|
+
return {
|
|
953
|
+
kind,
|
|
954
|
+
summary,
|
|
955
|
+
leaf: nullable(o.leaf, decodeEntryId),
|
|
956
|
+
continues: bool(o.continues),
|
|
957
|
+
turns,
|
|
958
|
+
branches: integer(o.branches, 0),
|
|
959
|
+
runs: list(o.runs, 200, decodeId),
|
|
960
|
+
attempt: nullable(o.attempt, decodeChatAttempt),
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
if (kind === "conversation-tree") {
|
|
964
|
+
const o = closed(v, ["kind", "conversationId", "nodes", "truncated"]);
|
|
965
|
+
return {
|
|
966
|
+
kind,
|
|
967
|
+
conversationId: decodeSessionId(o.conversationId),
|
|
968
|
+
nodes: list(o.nodes, TREE_NODES, decodeChatTreeNode),
|
|
969
|
+
truncated: bool(o.truncated),
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
if (kind === "conversation-legacy") {
|
|
973
|
+
const o = closed(v, ["kind", "pending"]);
|
|
974
|
+
return { kind, pending: integer(o.pending, 0) };
|
|
975
|
+
}
|
|
976
|
+
if (kind === "conversation-migrated") {
|
|
977
|
+
const o = closed(v, ["kind", "commandId", "migrated", "skipped"]);
|
|
978
|
+
return {
|
|
979
|
+
kind,
|
|
980
|
+
commandId: decodeId(o.commandId),
|
|
981
|
+
migrated: integer(o.migrated, 0),
|
|
982
|
+
skipped: integer(o.skipped, 0),
|
|
983
|
+
};
|
|
820
984
|
}
|
|
821
985
|
if (kind === "conversation-turn") {
|
|
822
986
|
const o = closed(v, [
|
|
823
987
|
"kind",
|
|
824
988
|
"conversationId",
|
|
989
|
+
"leaf",
|
|
825
990
|
"ordinal",
|
|
826
991
|
"turn",
|
|
827
992
|
"start",
|
|
@@ -833,7 +998,8 @@ export function decodeWorkbenchResult(v: unknown): WorkbenchResult {
|
|
|
833
998
|
if (start + steps.length > turn.steps) throw new ContractError("invalid");
|
|
834
999
|
return {
|
|
835
1000
|
kind,
|
|
836
|
-
conversationId:
|
|
1001
|
+
conversationId: decodeSessionId(o.conversationId),
|
|
1002
|
+
leaf: nullable(o.leaf, decodeEntryId),
|
|
837
1003
|
ordinal: integer(o.ordinal, 0),
|
|
838
1004
|
turn,
|
|
839
1005
|
start,
|
|
@@ -844,6 +1010,7 @@ export function decodeWorkbenchResult(v: unknown): WorkbenchResult {
|
|
|
844
1010
|
const o = closed(v, [
|
|
845
1011
|
"kind",
|
|
846
1012
|
"conversationId",
|
|
1013
|
+
"leaf",
|
|
847
1014
|
"turnId",
|
|
848
1015
|
"step",
|
|
849
1016
|
"part",
|
|
@@ -851,8 +1018,9 @@ export function decodeWorkbenchResult(v: unknown): WorkbenchResult {
|
|
|
851
1018
|
]);
|
|
852
1019
|
return {
|
|
853
1020
|
kind,
|
|
854
|
-
conversationId:
|
|
855
|
-
|
|
1021
|
+
conversationId: decodeSessionId(o.conversationId),
|
|
1022
|
+
leaf: nullable(o.leaf, decodeEntryId),
|
|
1023
|
+
turnId: decodeEntryId(o.turnId),
|
|
856
1024
|
step: integer(o.step, 0),
|
|
857
1025
|
part: integer(o.part, 0),
|
|
858
1026
|
item: decodeChatItem(o.item),
|
package/src/service-cli.mjs
CHANGED
|
@@ -2291,7 +2291,7 @@ var HEADER = [
|
|
|
2291
2291
|
var TOKEN_BYTES = 1024;
|
|
2292
2292
|
function accessToken(value) {
|
|
2293
2293
|
const result = text(value, TOKEN_BYTES, true);
|
|
2294
|
-
if (
|
|
2294
|
+
if (/[\p{Cc}\p{Cf}]/u.test(result))
|
|
2295
2295
|
throw new ContractError("invalid");
|
|
2296
2296
|
return result;
|
|
2297
2297
|
}
|
|
@@ -2367,7 +2367,7 @@ function decode(source) {
|
|
|
2367
2367
|
try {
|
|
2368
2368
|
return { port: number, token: accessToken(t.value) };
|
|
2369
2369
|
} catch {
|
|
2370
|
-
return unusable(`has ${TOKEN_KEY} on line ${t.line}
|
|
2370
|
+
return unusable(`has ${TOKEN_KEY} on line ${t.line} that is empty, over ${TOKEN_BYTES} bytes or with control characters`);
|
|
2371
2371
|
}
|
|
2372
2372
|
}
|
|
2373
2373
|
var code = (error) => error?.code ?? "error";
|
|
@@ -3438,6 +3438,7 @@ class ServiceCoordination {
|
|
|
3438
3438
|
"host-config.json",
|
|
3439
3439
|
"history-v2",
|
|
3440
3440
|
"conversations-v1",
|
|
3441
|
+
"conversation-commands-v1",
|
|
3441
3442
|
"conversation-workflows-v1",
|
|
3442
3443
|
"workflows-v1"
|
|
3443
3444
|
]);
|
|
@@ -6712,7 +6713,7 @@ function observedServerResult(result, service) {
|
|
|
6712
6713
|
}
|
|
6713
6714
|
function serverConfigHint(error) {
|
|
6714
6715
|
return `Cadence changed nothing: ${error.path} ${error.reason}.
|
|
6715
|
-
Fix it and run the command again; the file holds the WebUI port and token as ${PORT_KEY}=<1-65535> and ${TOKEN_KEY}=<
|
|
6716
|
+
Fix it and run the command again; the file holds the WebUI port and token as ${PORT_KEY}=<1-65535> and ${TOKEN_KEY}=<a non-empty token>, one line each.
|
|
6716
6717
|
`;
|
|
6717
6718
|
}
|
|
6718
6719
|
function registryGuidance(_workspace, stateHome) {
|