@abelxiaoxing/cadence 2.0.44 → 2.0.45
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/docs/conversation-mode.md +12 -3
- package/package.json +2 -1
- package/src/model-preview.mjs +3180 -0
- package/src/native-build.ts +1 -1
- package/src/service/contracts/models.ts +23 -12
- package/src/service-cli.mjs +15 -4
- package/src/service-host.mjs +493 -220
- package/web/dist/assets/cadence.js +18 -18
- package/web/dist/manifest.json +5 -5
package/src/native-build.ts
CHANGED
|
@@ -87,7 +87,8 @@ export interface ModelCandidate {
|
|
|
87
87
|
}[];
|
|
88
88
|
eligibility: "candidate" | "unsupported" | "auth-unavailable";
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
/** Credential-free discovery only: no owner version or installed selection. */
|
|
91
|
+
export interface ModelPreview {
|
|
91
92
|
status: "complete" | "capacity";
|
|
92
93
|
entries: ModelCandidate[];
|
|
93
94
|
/** Models left out because a provider/model ID contains a known credential
|
|
@@ -97,6 +98,7 @@ export interface ModelCatalog extends ModelChoiceState {
|
|
|
97
98
|
* offered only when it names a selectable entry of this catalog. */
|
|
98
99
|
remembered: ModelSelector | null;
|
|
99
100
|
}
|
|
101
|
+
export interface ModelCatalog extends ModelChoiceState, ModelPreview {}
|
|
100
102
|
export interface ChooseModelRequest {
|
|
101
103
|
expected: ChoiceVersion;
|
|
102
104
|
choice: ModelSelector;
|
|
@@ -189,16 +191,9 @@ export function catalogOffers(
|
|
|
189
191
|
e.thinking.some((t) => t.selectable && t.level === selector.thinking),
|
|
190
192
|
);
|
|
191
193
|
}
|
|
192
|
-
export function
|
|
194
|
+
export function decodeModelPreview(value: unknown): ModelPreview {
|
|
193
195
|
canonicalJson({ kind: "ok", value }, LIMITS.pageBytes);
|
|
194
|
-
const o = closed(value, [
|
|
195
|
-
"version",
|
|
196
|
-
"selected",
|
|
197
|
-
"status",
|
|
198
|
-
"entries",
|
|
199
|
-
"withheld",
|
|
200
|
-
"remembered",
|
|
201
|
-
]);
|
|
196
|
+
const o = closed(value, ["status", "entries", "withheld", "remembered"]);
|
|
202
197
|
const entries = list(o.entries, LIMITS.maxPageEntries, decodeModelCandidate);
|
|
203
198
|
const remembered = nullable(o.remembered, decodeModelSelector);
|
|
204
199
|
const status = oneOf(o.status, ["complete", "capacity"]);
|
|
@@ -212,11 +207,27 @@ export function decodeModelCatalog(value: unknown): ModelCatalog {
|
|
|
212
207
|
)
|
|
213
208
|
invalid();
|
|
214
209
|
return {
|
|
215
|
-
version: decodeChoiceVersion(o.version),
|
|
216
|
-
selected: nullable(o.selected, decodeModelSelection),
|
|
217
210
|
status,
|
|
218
211
|
entries,
|
|
219
212
|
withheld,
|
|
220
213
|
remembered,
|
|
221
214
|
};
|
|
222
215
|
}
|
|
216
|
+
|
|
217
|
+
export function decodeModelCatalog(value: unknown): ModelCatalog {
|
|
218
|
+
const o = closed(value, [
|
|
219
|
+
"version",
|
|
220
|
+
"selected",
|
|
221
|
+
"status",
|
|
222
|
+
"entries",
|
|
223
|
+
"withheld",
|
|
224
|
+
"remembered",
|
|
225
|
+
]);
|
|
226
|
+
const { version, selected, ...preview } = o;
|
|
227
|
+
canonicalJson({ kind: "ok", value }, LIMITS.pageBytes);
|
|
228
|
+
return {
|
|
229
|
+
...decodeModelPreview(preview),
|
|
230
|
+
version: decodeChoiceVersion(version),
|
|
231
|
+
selected: nullable(selected, decodeModelSelection),
|
|
232
|
+
};
|
|
233
|
+
}
|
package/src/service-cli.mjs
CHANGED
|
@@ -5902,9 +5902,9 @@ async function stopWorkers(ledger, epoch, reboot, inspect) {
|
|
|
5902
5902
|
let stopped = 0, running = 0;
|
|
5903
5903
|
for (const worker of ledger.read(epoch)) {
|
|
5904
5904
|
const holder = holderState({ ...worker, host: hostname5() });
|
|
5905
|
-
if (holder.state
|
|
5905
|
+
if (holder.state === "dead")
|
|
5906
5906
|
continue;
|
|
5907
|
-
if (!worker.started) {
|
|
5907
|
+
if (holder.state !== "live" || !worker.started) {
|
|
5908
5908
|
running++;
|
|
5909
5909
|
continue;
|
|
5910
5910
|
}
|
|
@@ -6444,9 +6444,16 @@ async function healWorkbench(store, options = {}) {
|
|
|
6444
6444
|
}
|
|
6445
6445
|
}
|
|
6446
6446
|
const cause = !activeNow || damaged ? "storage" : holder.reboot ? "reboot" : "crash";
|
|
6447
|
+
const ledger = new ProcessLedger(store.files);
|
|
6448
|
+
const epoch = value?.epoch ?? null;
|
|
6449
|
+
const workers = takenOver ? { stopped: 0, running: 0 } : await stopWorkers(ledger, epoch, holder.reboot, !!options.inspect);
|
|
6450
|
+
if (workers.running)
|
|
6451
|
+
return { status: "blocked", reason: "workers-running", pid };
|
|
6447
6452
|
if (options.inspect)
|
|
6448
|
-
return { status: "reclaimable", cause, workers:
|
|
6453
|
+
return { status: "reclaimable", cause, workers: workers.stopped };
|
|
6449
6454
|
const actions = new Set;
|
|
6455
|
+
if (workers.stopped)
|
|
6456
|
+
actions.add("stopped-workers");
|
|
6450
6457
|
const archive = log.archive();
|
|
6451
6458
|
for (const path2 of temporaries) {
|
|
6452
6459
|
archive.keep(path2);
|
|
@@ -6464,6 +6471,8 @@ async function healWorkbench(store, options = {}) {
|
|
|
6464
6471
|
store.files.remove(lockPath, lock.snapshot);
|
|
6465
6472
|
actions.add("released-locks");
|
|
6466
6473
|
}
|
|
6474
|
+
if (epoch)
|
|
6475
|
+
ledger.remove(epoch);
|
|
6467
6476
|
return {
|
|
6468
6477
|
status: "healed",
|
|
6469
6478
|
event: log.record({
|
|
@@ -6471,7 +6480,7 @@ async function healWorkbench(store, options = {}) {
|
|
|
6471
6480
|
path: null,
|
|
6472
6481
|
cause,
|
|
6473
6482
|
actions: [...actions],
|
|
6474
|
-
workers:
|
|
6483
|
+
workers: workers.stopped,
|
|
6475
6484
|
archive: archive.used() ? archive.name : null
|
|
6476
6485
|
})
|
|
6477
6486
|
};
|
|
@@ -6489,6 +6498,8 @@ function decodeGatewayRegistration(value) {
|
|
|
6489
6498
|
if (!o || typeof o !== "object" || !["alive", "stopping", "stopped", "quarantined"].includes(o.phase))
|
|
6490
6499
|
throw new ContractError("corrupt-selected");
|
|
6491
6500
|
integer(o.pid, 1, 2147483647);
|
|
6501
|
+
if (o.epoch !== undefined)
|
|
6502
|
+
decodeId(o.epoch);
|
|
6492
6503
|
return o;
|
|
6493
6504
|
}
|
|
6494
6505
|
|