omo-web 0.1.7 → 0.1.8
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/app.js +52 -42
- package/dist/server.js +549 -169
- package/package.json +1 -1
- package/public/dag-graph.css +46 -0
- package/public/index.html +89 -22
- package/public/styles.css +1 -1
- package/public/tool-ledger.css +6 -5
- package/public/workbench.css +38 -6
package/dist/server.js
CHANGED
|
@@ -6910,8 +6910,8 @@ class CliHistory {
|
|
|
6910
6910
|
sessions: detailed.sessions.map(({ id, name, cwd, updatedAt }) => ({ id, name, cwd, updatedAt }))
|
|
6911
6911
|
};
|
|
6912
6912
|
}
|
|
6913
|
-
async listWithIds() {
|
|
6914
|
-
const scanned = await this.#scan();
|
|
6913
|
+
async listWithIds(scope) {
|
|
6914
|
+
const scanned = await this.#scan(scope);
|
|
6915
6915
|
if (!scanned.available)
|
|
6916
6916
|
return { available: false, sessions: [] };
|
|
6917
6917
|
const candidates = [];
|
|
@@ -6920,7 +6920,15 @@ class CliHistory {
|
|
|
6920
6920
|
const target = await lstat2(file.path);
|
|
6921
6921
|
if (!target.isFile())
|
|
6922
6922
|
continue;
|
|
6923
|
-
|
|
6923
|
+
const header = scope === undefined ? undefined : await this.#headerOf(file.path);
|
|
6924
|
+
if (scope !== undefined && header?.cwd !== scope.root)
|
|
6925
|
+
continue;
|
|
6926
|
+
candidates.push({
|
|
6927
|
+
file,
|
|
6928
|
+
mtimeMs: target.mtimeMs,
|
|
6929
|
+
size: target.size,
|
|
6930
|
+
...header === undefined ? {} : { sessionId: header.sessionId }
|
|
6931
|
+
});
|
|
6924
6932
|
} catch {
|
|
6925
6933
|
continue;
|
|
6926
6934
|
}
|
|
@@ -6929,41 +6937,38 @@ class CliHistory {
|
|
|
6929
6937
|
const sessions = [];
|
|
6930
6938
|
let bytes = 0;
|
|
6931
6939
|
let parsed = 0;
|
|
6940
|
+
const sampleLimit = 2 * CLI_HISTORY_LIMITS.maxHeaderBytes;
|
|
6941
|
+
const fullLimit = scope === undefined ? CLI_HISTORY_LIMITS.maxFileBytes : sampleLimit;
|
|
6932
6942
|
for (const candidate of candidates) {
|
|
6933
6943
|
if (sessions.length >= CLI_HISTORY_LIMITS.maxSessions || parsed >= CLI_HISTORY_LIMITS.maxListFiles || bytes >= CLI_HISTORY_LIMITS.maxListBytes)
|
|
6934
6944
|
break;
|
|
6945
|
+
const budget = candidate.size <= fullLimit ? candidate.size : sampleLimit;
|
|
6946
|
+
if (scope !== undefined && budget > CLI_HISTORY_LIMITS.maxListBytes - bytes)
|
|
6947
|
+
continue;
|
|
6935
6948
|
try {
|
|
6936
6949
|
if (!await this.#rootMatches(candidate.file))
|
|
6937
6950
|
continue;
|
|
6938
|
-
if (
|
|
6939
|
-
const loaded = await this.#loadContent(candidate.file.path);
|
|
6951
|
+
if (scope !== undefined) {
|
|
6940
6952
|
parsed += 1;
|
|
6941
|
-
bytes +=
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
id: loaded.sessionId,
|
|
6946
|
-
name: nameOf(loaded.entries, loaded.cwd),
|
|
6947
|
-
cwd: loaded.cwd,
|
|
6948
|
-
updatedAt: loaded.updatedAt,
|
|
6949
|
-
nativeSessionId: loaded.sessionId,
|
|
6950
|
-
...candidate.file.workspaceKey === undefined ? {} : { workspaceKey: candidate.file.workspaceKey }
|
|
6951
|
-
});
|
|
6952
|
-
} else {
|
|
6953
|
-
const oversized = await this.#summarizeOversized(candidate.file.path);
|
|
6953
|
+
bytes += budget;
|
|
6954
|
+
}
|
|
6955
|
+
const summary = candidate.size <= fullLimit ? await this.#loadContent(candidate.file.path, scope === undefined ? undefined : budget) : await this.#summarizeOversized(candidate.file.path, fullLimit);
|
|
6956
|
+
if (scope === undefined) {
|
|
6954
6957
|
parsed += 1;
|
|
6955
|
-
bytes +=
|
|
6956
|
-
if (oversized.cwd !== candidate.file.root || !await this.#rootMatches(candidate.file))
|
|
6957
|
-
continue;
|
|
6958
|
-
sessions.push({
|
|
6959
|
-
id: oversized.sessionId,
|
|
6960
|
-
name: oversized.name,
|
|
6961
|
-
cwd: oversized.cwd,
|
|
6962
|
-
updatedAt: oversized.updatedAt,
|
|
6963
|
-
nativeSessionId: oversized.sessionId,
|
|
6964
|
-
...candidate.file.workspaceKey === undefined ? {} : { workspaceKey: candidate.file.workspaceKey }
|
|
6965
|
-
});
|
|
6958
|
+
bytes += summary.bytes;
|
|
6966
6959
|
}
|
|
6960
|
+
if (summary.cwd !== candidate.file.root || candidate.sessionId !== undefined && summary.sessionId !== candidate.sessionId || !await this.#rootMatches(candidate.file))
|
|
6961
|
+
continue;
|
|
6962
|
+
const { sessionId, cwd, updatedAt } = summary;
|
|
6963
|
+
const name = "entries" in summary ? nameOf(summary.entries, cwd) : summary.name;
|
|
6964
|
+
sessions.push({
|
|
6965
|
+
id: sessionId,
|
|
6966
|
+
name,
|
|
6967
|
+
cwd,
|
|
6968
|
+
updatedAt,
|
|
6969
|
+
nativeSessionId: sessionId,
|
|
6970
|
+
...candidate.file.workspaceKey === undefined ? {} : { workspaceKey: candidate.file.workspaceKey }
|
|
6971
|
+
});
|
|
6967
6972
|
} catch {
|
|
6968
6973
|
continue;
|
|
6969
6974
|
}
|
|
@@ -6973,7 +6978,7 @@ class CliHistory {
|
|
|
6973
6978
|
}
|
|
6974
6979
|
async read(id, cwd, workspaceKey) {
|
|
6975
6980
|
checkId(id);
|
|
6976
|
-
const scanned = await this.#scan();
|
|
6981
|
+
const scanned = await this.#scan(cwd === undefined ? undefined : { root: cwd, workspaceKey });
|
|
6977
6982
|
if (!scanned.available)
|
|
6978
6983
|
throw unavailable();
|
|
6979
6984
|
for (const file of scanned.files) {
|
|
@@ -7007,7 +7012,7 @@ class CliHistory {
|
|
|
7007
7012
|
return;
|
|
7008
7013
|
}) !== cwd)
|
|
7009
7014
|
throw notFound();
|
|
7010
|
-
const scanned = await this.#scan();
|
|
7015
|
+
const scanned = await this.#scan({ root: cwd, workspaceKey });
|
|
7011
7016
|
if (!scanned.available)
|
|
7012
7017
|
throw unavailable();
|
|
7013
7018
|
let sourcePath;
|
|
@@ -7049,7 +7054,7 @@ class CliHistory {
|
|
|
7049
7054
|
async#rootMatches(file) {
|
|
7050
7055
|
return !(this.#workspaces instanceof WorkspaceAccess) || file.workspaceKey !== undefined && await this.#workspaces.exact(file.root) === file.workspaceKey;
|
|
7051
7056
|
}
|
|
7052
|
-
async#scan() {
|
|
7057
|
+
async#scan(scope) {
|
|
7053
7058
|
if (this.#agentDir === undefined)
|
|
7054
7059
|
return { available: false, files: [] };
|
|
7055
7060
|
const base = join2(this.#agentDir, "sessions");
|
|
@@ -7060,9 +7065,12 @@ class CliHistory {
|
|
|
7060
7065
|
return { available: false, files: [] };
|
|
7061
7066
|
}
|
|
7062
7067
|
const files = [];
|
|
7063
|
-
|
|
7068
|
+
const roots = await (scope === undefined || !(this.#workspaces instanceof WorkspaceAccess) ? this.#rootsList() : [scope.root]);
|
|
7069
|
+
for (const root of roots) {
|
|
7070
|
+
if (scope !== undefined && root !== scope.root)
|
|
7071
|
+
continue;
|
|
7064
7072
|
const workspaceKey = this.#workspaces instanceof WorkspaceAccess ? await this.#workspaces.exact(root) : undefined;
|
|
7065
|
-
if (this.#workspaces instanceof WorkspaceAccess && workspaceKey === undefined)
|
|
7073
|
+
if (this.#workspaces instanceof WorkspaceAccess && workspaceKey === undefined || scope?.workspaceKey !== undefined && workspaceKey !== scope.workspaceKey)
|
|
7066
7074
|
continue;
|
|
7067
7075
|
const dir = join2(base, sessionDirName(root));
|
|
7068
7076
|
try {
|
|
@@ -7072,7 +7080,7 @@ class CliHistory {
|
|
|
7072
7080
|
const names = dirents.filter((entry) => entry.isFile() && entry.name.endsWith(".jsonl")).map((entry) => entry.name);
|
|
7073
7081
|
names.sort();
|
|
7074
7082
|
for (const name of names.slice(0, CLI_HISTORY_LIMITS.maxFilesPerDir)) {
|
|
7075
|
-
files.push({ root,
|
|
7083
|
+
files.push({ root, path: join2(dir, name), ...workspaceKey === undefined ? {} : { workspaceKey } });
|
|
7076
7084
|
}
|
|
7077
7085
|
} catch {
|
|
7078
7086
|
continue;
|
|
@@ -7080,17 +7088,21 @@ class CliHistory {
|
|
|
7080
7088
|
}
|
|
7081
7089
|
return { available: true, files };
|
|
7082
7090
|
}
|
|
7083
|
-
async#headerOf(path
|
|
7091
|
+
async#headerOf(path) {
|
|
7084
7092
|
let handle;
|
|
7085
7093
|
try {
|
|
7086
7094
|
handle = await open3(path, constants2.O_RDONLY | constants2.O_NOFOLLOW | constants2.O_NONBLOCK);
|
|
7087
7095
|
const target = await handle.stat();
|
|
7088
|
-
if (!target.isFile()
|
|
7096
|
+
if (!target.isFile())
|
|
7089
7097
|
return;
|
|
7090
|
-
const
|
|
7098
|
+
const opening = await readAt(handle, 0, Math.min(target.size, 4096));
|
|
7099
|
+
const end = opening.indexOf(`
|
|
7100
|
+
`);
|
|
7101
|
+
const first = end < 0 ? undefined : parse4(opening.slice(0, end)).header;
|
|
7102
|
+
const header = first ?? parse4(await readPrefix(handle, CLI_HISTORY_LIMITS.maxHeaderBytes)).header;
|
|
7091
7103
|
if (!header || typeof header.cwd !== "string")
|
|
7092
7104
|
return;
|
|
7093
|
-
return { sessionId: header.id, cwd: header.cwd
|
|
7105
|
+
return { sessionId: header.id, cwd: header.cwd };
|
|
7094
7106
|
} catch {
|
|
7095
7107
|
return;
|
|
7096
7108
|
} finally {
|
|
@@ -7099,14 +7111,16 @@ class CliHistory {
|
|
|
7099
7111
|
});
|
|
7100
7112
|
}
|
|
7101
7113
|
}
|
|
7102
|
-
async#loadContent(path) {
|
|
7114
|
+
async#loadContent(path, summaryBudget) {
|
|
7103
7115
|
let handle;
|
|
7104
7116
|
try {
|
|
7105
7117
|
handle = await open3(path, constants2.O_RDONLY | constants2.O_NOFOLLOW | constants2.O_NONBLOCK);
|
|
7106
7118
|
const target = await handle.stat();
|
|
7107
7119
|
if (!target.isFile())
|
|
7108
7120
|
throw invalid();
|
|
7109
|
-
|
|
7121
|
+
if (summaryBudget !== undefined && target.size > summaryBudget)
|
|
7122
|
+
throw tooLarge();
|
|
7123
|
+
const { text, bytes } = summaryBudget === undefined ? await readText(handle, target.size, CLI_HISTORY_LIMITS.maxFileBytes) : { text: await readAt(handle, 0, target.size), bytes: target.size };
|
|
7110
7124
|
const { header, entries } = parse4(text);
|
|
7111
7125
|
if (!header || typeof header.cwd !== "string")
|
|
7112
7126
|
throw invalid();
|
|
@@ -7123,13 +7137,13 @@ class CliHistory {
|
|
|
7123
7137
|
});
|
|
7124
7138
|
}
|
|
7125
7139
|
}
|
|
7126
|
-
async#summarizeOversized(path) {
|
|
7140
|
+
async#summarizeOversized(path, fullLimit) {
|
|
7127
7141
|
const window = CLI_HISTORY_LIMITS.maxHeaderBytes;
|
|
7128
7142
|
let handle;
|
|
7129
7143
|
try {
|
|
7130
7144
|
handle = await open3(path, constants2.O_RDONLY | constants2.O_NOFOLLOW | constants2.O_NONBLOCK);
|
|
7131
7145
|
const target = await handle.stat();
|
|
7132
|
-
if (!target.isFile() || target.size <=
|
|
7146
|
+
if (!target.isFile() || target.size <= fullLimit)
|
|
7133
7147
|
throw invalid();
|
|
7134
7148
|
const headText = await readAt(handle, 0, window);
|
|
7135
7149
|
const cut = headText.lastIndexOf(`
|
|
@@ -7164,7 +7178,7 @@ class CliHistory {
|
|
|
7164
7178
|
cwd: header.cwd,
|
|
7165
7179
|
name: nameOf([...entries, ...tailEntries], header.cwd),
|
|
7166
7180
|
updatedAt: Math.floor(target.mtimeMs),
|
|
7167
|
-
|
|
7181
|
+
bytes: window + tailLen
|
|
7168
7182
|
};
|
|
7169
7183
|
} catch (error) {
|
|
7170
7184
|
if (error instanceof WebError)
|
|
@@ -10065,11 +10079,26 @@ function composeMessage(command, args) {
|
|
|
10065
10079
|
import { createHmac as createHmac2, randomBytes as randomBytes3 } from "crypto";
|
|
10066
10080
|
|
|
10067
10081
|
// src/native-runtime-projection.ts
|
|
10082
|
+
import { stripVTControlCharacters as stripVTControlCharacters2 } from "util";
|
|
10068
10083
|
var identity = string2().min(1).max(256).regex(/\S/u);
|
|
10069
10084
|
var count2 = int().nonnegative();
|
|
10070
10085
|
var timestamp2 = exports_iso.datetime().transform(Date.parse).pipe(int());
|
|
10071
10086
|
var RUNTIME_LIST_LIMIT = 256;
|
|
10072
10087
|
var boundedRows = (row, limit = RUNTIME_LIST_LIMIT) => preprocess((value) => Array.isArray(value) && value.length <= limit ? value : undefined, array(row));
|
|
10088
|
+
var malformed2 = { status: "malformed" };
|
|
10089
|
+
var ownershipChanged = { status: "ownership_changed" };
|
|
10090
|
+
var notFound2 = { status: "not_found" };
|
|
10091
|
+
var displayText2 = (maxBytes) => string2().max(maxBytes * 2).transform((value) => stripVTControlCharacters2(value).replace(/\s+/gu, " ").replace(/[\p{Cc}\p{Cf}\p{Cs}]/gu, "").trim()).refine((value) => value.length > 0 && Buffer.byteLength(value) <= maxBytes && !/[<>]|(?:^|[\s"'`(=])(?:~?\/(?!\s|$)|[a-z]:[\\/]|\\\\)/iu.test(value)).optional().catch(undefined);
|
|
10092
|
+
var title = displayText2(128);
|
|
10093
|
+
var description = displayText2(320);
|
|
10094
|
+
var model2 = string2().max(128).regex(/^(?![a-z]:\/)[a-z\d][a-z\d._:@+-]*(?:\/[a-z\d][a-z\d._:@+-]*)*$/iu);
|
|
10095
|
+
var configuredModel = model2.optional().catch(undefined);
|
|
10096
|
+
var effectiveModel = object({
|
|
10097
|
+
provider: string2().max(48).regex(/^[a-z\d][a-z\d._-]*$/iu),
|
|
10098
|
+
model_id: model2,
|
|
10099
|
+
reasoning: string2().max(32).regex(/^[a-z\d][a-z\d_-]*$/iu).optional().catch(undefined)
|
|
10100
|
+
}).transform(({ provider, model_id, reasoning }) => ({ provider, modelId: model_id, reasoning })).optional().catch(undefined);
|
|
10101
|
+
var optionalTime = timestamp2.optional().catch(undefined);
|
|
10073
10102
|
var agent = _enum(["explore", "librarian", "delivery-worker", "technical-writing", "quick-scan"]);
|
|
10074
10103
|
var category = _enum([
|
|
10075
10104
|
"quick",
|
|
@@ -10084,17 +10113,85 @@ var category = _enum([
|
|
|
10084
10113
|
"ultrabrain"
|
|
10085
10114
|
]);
|
|
10086
10115
|
var executionMode = _enum(["in-process", "process"]);
|
|
10087
|
-
var
|
|
10116
|
+
var taskId = string2().regex(/^st_[0-9a-f]{8}$/u).brand().optional().catch(undefined);
|
|
10117
|
+
var taskStatus = _enum(["pending", "running", "paused", "completed", "error", "cancelled", "interrupted", "lost"]);
|
|
10118
|
+
var taskRow = object({
|
|
10119
|
+
task_id: taskId,
|
|
10120
|
+
status: taskStatus,
|
|
10121
|
+
created_at: timestamp2,
|
|
10122
|
+
updated_at: timestamp2,
|
|
10088
10123
|
agent_type: agent.optional().catch(undefined),
|
|
10089
10124
|
category: category.optional().catch(undefined),
|
|
10090
|
-
execution_mode: executionMode.optional().catch(undefined)
|
|
10091
|
-
|
|
10125
|
+
execution_mode: executionMode.optional().catch(undefined),
|
|
10126
|
+
task_summary: title,
|
|
10127
|
+
description,
|
|
10128
|
+
model: configuredModel,
|
|
10129
|
+
effective_model: effectiveModel,
|
|
10130
|
+
description_truncated: boolean2().optional().catch(undefined)
|
|
10131
|
+
});
|
|
10132
|
+
var taskReply = object({
|
|
10133
|
+
parent_session_id: identity,
|
|
10134
|
+
tasks: boundedRows(taskRow),
|
|
10135
|
+
truncated_tasks: count2.optional()
|
|
10136
|
+
});
|
|
10137
|
+
function projectTasks(raw, owner) {
|
|
10138
|
+
switch (raw.kind) {
|
|
10139
|
+
case "unavailable":
|
|
10140
|
+
return { status: "unavailable", reason: "native_unavailable" };
|
|
10141
|
+
case "not_found":
|
|
10142
|
+
return ownershipChanged;
|
|
10143
|
+
case undefined:
|
|
10144
|
+
break;
|
|
10145
|
+
default:
|
|
10146
|
+
return malformed2;
|
|
10147
|
+
}
|
|
10148
|
+
const parsed = taskReply.safeParse(raw);
|
|
10149
|
+
if (!parsed.success)
|
|
10150
|
+
return malformed2;
|
|
10151
|
+
const { parent_session_id, tasks, truncated_tasks = 0 } = parsed.data;
|
|
10152
|
+
if (parent_session_id !== owner.sessionId)
|
|
10153
|
+
return ownershipChanged;
|
|
10154
|
+
if (truncated_tasks > 0 && tasks.length !== RUNTIME_LIST_LIMIT)
|
|
10155
|
+
return malformed2;
|
|
10156
|
+
if (tasks.length === 0)
|
|
10157
|
+
return { status: "empty" };
|
|
10158
|
+
const keys = new Set;
|
|
10159
|
+
const rows = [];
|
|
10160
|
+
for (const row of tasks) {
|
|
10161
|
+
const key = row.task_id === undefined ? undefined : owner.taskKey(row.task_id);
|
|
10162
|
+
if (key !== undefined) {
|
|
10163
|
+
if (keys.has(key))
|
|
10164
|
+
return malformed2;
|
|
10165
|
+
keys.add(key);
|
|
10166
|
+
}
|
|
10167
|
+
rows.push({
|
|
10168
|
+
key,
|
|
10169
|
+
status: row.status,
|
|
10170
|
+
createdAt: row.created_at,
|
|
10171
|
+
updatedAt: row.updated_at,
|
|
10172
|
+
agent: row.agent_type,
|
|
10173
|
+
category: row.category,
|
|
10174
|
+
executionMode: row.execution_mode,
|
|
10175
|
+
title: row.task_summary,
|
|
10176
|
+
description: row.description_truncated === true ? undefined : row.description,
|
|
10177
|
+
configuredModel: row.model,
|
|
10178
|
+
effectiveModel: row.effective_model
|
|
10179
|
+
});
|
|
10180
|
+
}
|
|
10181
|
+
return { status: "ok", rows, omittedCount: truncated_tasks };
|
|
10182
|
+
}
|
|
10092
10183
|
var runId = templateLiteral(["dag_", uuidv4()]);
|
|
10093
10184
|
var dagStatus = _enum(["pending", "running", "paused", "completed", "failed", "cancelled"]);
|
|
10185
|
+
var statusesByScope = {
|
|
10186
|
+
current: [dagStatus.enum.pending, dagStatus.enum.running, dagStatus.enum.paused],
|
|
10187
|
+
history: [dagStatus.enum.completed, dagStatus.enum.failed, dagStatus.enum.cancelled]
|
|
10188
|
+
};
|
|
10189
|
+
var dagStatuses = (scope) => statusesByScope[scope];
|
|
10094
10190
|
var nodeState = _enum(["pending", "blocked", "scheduled", "running", "paused", "completed", "failed", "cancelled", "skipped"]);
|
|
10095
10191
|
var optionalCount = count2.optional().catch(undefined);
|
|
10096
10192
|
var dagRow = object({
|
|
10097
10193
|
runId: runId.optional().catch(undefined),
|
|
10194
|
+
name: title,
|
|
10098
10195
|
parentSessionId: identity,
|
|
10099
10196
|
status: dagStatus,
|
|
10100
10197
|
createdAt: timestamp2,
|
|
@@ -10124,6 +10221,7 @@ function projectDagRow(row, keyForRun) {
|
|
|
10124
10221
|
const entries = Object.entries(counts).filter(([, value]) => value !== undefined && value <= total);
|
|
10125
10222
|
return {
|
|
10126
10223
|
status: row.status,
|
|
10224
|
+
name: row.name,
|
|
10127
10225
|
createdAt: row.createdAt,
|
|
10128
10226
|
updatedAt: row.updatedAt,
|
|
10129
10227
|
nodeCount: total,
|
|
@@ -10134,29 +10232,55 @@ function projectDagRow(row, keyForRun) {
|
|
|
10134
10232
|
var MAX_NODES = 64;
|
|
10135
10233
|
var MAX_EDGES = MAX_NODES * (MAX_NODES - 1) / 2;
|
|
10136
10234
|
var MAX_SNAPSHOT_BYTES = 1024 * 1024;
|
|
10137
|
-
var
|
|
10138
|
-
object({ kind: literal("agent"), agent: agent.optional().catch(undefined) }),
|
|
10235
|
+
var routeMetadata = discriminatedUnion("kind", [
|
|
10236
|
+
object({ kind: literal("agent"), agent: agent.optional().catch(undefined), model: configuredModel }),
|
|
10139
10237
|
object({ kind: literal("category"), category: category.optional().catch(undefined) })
|
|
10140
|
-
]).
|
|
10238
|
+
]).transform((route) => {
|
|
10239
|
+
switch (route.kind) {
|
|
10240
|
+
case "agent":
|
|
10241
|
+
return { agent: route.agent, configuredModel: route.model };
|
|
10242
|
+
case "category":
|
|
10243
|
+
return { category: route.category };
|
|
10244
|
+
}
|
|
10245
|
+
}).optional().catch(undefined);
|
|
10246
|
+
var executionTimes = { createdAt: optionalTime, startedAt: optionalTime, completedAt: optionalTime };
|
|
10141
10247
|
var snapshot = object({ ok: literal(true), value: object({
|
|
10142
10248
|
schemaVersion: literal(1),
|
|
10143
10249
|
runId,
|
|
10144
10250
|
parentSessionId: identity,
|
|
10145
10251
|
status: dagStatus,
|
|
10252
|
+
name: title,
|
|
10253
|
+
...executionTimes,
|
|
10146
10254
|
counts: object({ total: count2 }),
|
|
10147
10255
|
nodes: boundedRows(object({
|
|
10148
10256
|
id: identity,
|
|
10149
10257
|
state: nodeState,
|
|
10150
10258
|
attempt: count2,
|
|
10259
|
+
label: title,
|
|
10260
|
+
taskId,
|
|
10261
|
+
...executionTimes,
|
|
10262
|
+
lastActivityAt: optionalTime,
|
|
10151
10263
|
dependsOn: boundedRows(identity, MAX_NODES - 1),
|
|
10152
|
-
route:
|
|
10264
|
+
route: routeMetadata
|
|
10153
10265
|
}), MAX_NODES),
|
|
10154
10266
|
edges: boundedRows(object({ from: identity, to: identity }), MAX_EDGES),
|
|
10155
10267
|
waves: boundedRows(object({ index: count2, nodeIds: boundedRows(identity, MAX_NODES) }), MAX_NODES)
|
|
10156
10268
|
}) });
|
|
10157
|
-
var malformed2 = { status: "malformed" };
|
|
10158
|
-
var ownershipChanged = { status: "ownership_changed" };
|
|
10159
10269
|
function projectDagSnapshot(raw, expected) {
|
|
10270
|
+
if (raw.ok === false) {
|
|
10271
|
+
const error = object({ code: string2() }).safeParse(raw.error);
|
|
10272
|
+
if (!error.success)
|
|
10273
|
+
return malformed2;
|
|
10274
|
+
switch (error.data.code) {
|
|
10275
|
+
case "run_not_found":
|
|
10276
|
+
case "run_not_owned":
|
|
10277
|
+
return notFound2;
|
|
10278
|
+
case "history_unavailable":
|
|
10279
|
+
return { status: "unavailable", reason: "native_unavailable" };
|
|
10280
|
+
default:
|
|
10281
|
+
return malformed2;
|
|
10282
|
+
}
|
|
10283
|
+
}
|
|
10160
10284
|
try {
|
|
10161
10285
|
if (Buffer.byteLength(JSON.stringify(raw)) > MAX_SNAPSHOT_BYTES)
|
|
10162
10286
|
return malformed2;
|
|
@@ -10171,6 +10295,8 @@ function projectDagSnapshot(raw, expected) {
|
|
|
10171
10295
|
const graph = parsed.data.value;
|
|
10172
10296
|
if (graph.runId !== expected.runId || graph.parentSessionId !== expected.owner)
|
|
10173
10297
|
return ownershipChanged;
|
|
10298
|
+
if (!dagStatuses(expected.scope).includes(graph.status))
|
|
10299
|
+
return notFound2;
|
|
10174
10300
|
if (!graph.nodes.length || graph.nodes.length !== graph.counts.total || graph.waves.length > graph.nodes.length)
|
|
10175
10301
|
return malformed2;
|
|
10176
10302
|
const nativeNodes = new Map(graph.nodes.map((node) => [node.id, node]));
|
|
@@ -10217,16 +10343,29 @@ function projectDagSnapshot(raw, expected) {
|
|
|
10217
10343
|
state: node.state,
|
|
10218
10344
|
attempt: node.attempt,
|
|
10219
10345
|
upstream: [...position.upstream].sort((a, b) => a - b),
|
|
10220
|
-
|
|
10221
|
-
|
|
10346
|
+
label: node.label,
|
|
10347
|
+
createdAt: node.createdAt,
|
|
10348
|
+
startedAt: node.startedAt,
|
|
10349
|
+
completedAt: node.completedAt,
|
|
10350
|
+
lastActivityAt: node.lastActivityAt,
|
|
10351
|
+
...node.route,
|
|
10352
|
+
taskKey: node.taskId === undefined ? undefined : expected.taskKey(node.taskId)
|
|
10222
10353
|
});
|
|
10223
10354
|
}
|
|
10224
|
-
return {
|
|
10355
|
+
return {
|
|
10356
|
+
status: "ok",
|
|
10357
|
+
runStatus: graph.status,
|
|
10358
|
+
name: graph.name,
|
|
10359
|
+
createdAt: graph.createdAt,
|
|
10360
|
+
startedAt: graph.startedAt,
|
|
10361
|
+
completedAt: graph.completedAt,
|
|
10362
|
+
waves,
|
|
10363
|
+
nodes
|
|
10364
|
+
};
|
|
10225
10365
|
}
|
|
10226
10366
|
|
|
10227
10367
|
// src/runtime-branch.ts
|
|
10228
10368
|
var TODO_STATE_TYPE = "senpi.todo-state";
|
|
10229
|
-
var TODO_TOOL_NAMES = ["todo", "todowrite"];
|
|
10230
10369
|
var NUDGED_TYPE = "omo-kibitzer:nudged";
|
|
10231
10370
|
var GATE_TYPE = "omo-kibitzer:gate";
|
|
10232
10371
|
var UNAVAILABLE_TYPE = "omo-kibitzer:unavailable";
|
|
@@ -10341,9 +10480,10 @@ function readToolTodo(entry) {
|
|
|
10341
10480
|
if (entry.type !== "message")
|
|
10342
10481
|
return;
|
|
10343
10482
|
const message = record3(entry.message);
|
|
10344
|
-
if (message.role !== "toolResult" ||
|
|
10483
|
+
if (message.role !== "toolResult" || message.isError === true || message.toolName !== "todo" && message.toolName !== "todowrite")
|
|
10345
10484
|
return;
|
|
10346
|
-
|
|
10485
|
+
const details = record3(message.details);
|
|
10486
|
+
return details.op === "view" ? undefined : readTodoPayload(details);
|
|
10347
10487
|
}
|
|
10348
10488
|
function isNudgedRecord(data) {
|
|
10349
10489
|
const nudges = array3(data.nudges);
|
|
@@ -10467,6 +10607,15 @@ function capTodo(phases) {
|
|
|
10467
10607
|
}
|
|
10468
10608
|
return { phases: kept, truncated: false };
|
|
10469
10609
|
}
|
|
10610
|
+
function projectTodoRecord(entry) {
|
|
10611
|
+
const todo = readCustomTodo(entry) ?? readToolTodo(entry);
|
|
10612
|
+
if (todo === undefined || todo.truncated)
|
|
10613
|
+
return todo;
|
|
10614
|
+
return capTodo(todo.phases);
|
|
10615
|
+
}
|
|
10616
|
+
function currentBranchTodo(phases) {
|
|
10617
|
+
return phases.some((phase) => phase.tasks.some((task) => task.status === "pending" || task.status === "in_progress")) ? { status: "ok", phases } : { status: "none" };
|
|
10618
|
+
}
|
|
10470
10619
|
function projectRuntimeBranch(tree) {
|
|
10471
10620
|
const root = record3(tree);
|
|
10472
10621
|
if (!Array.isArray(root.tree))
|
|
@@ -10502,8 +10651,7 @@ function projectRuntimeBranch(tree) {
|
|
|
10502
10651
|
const todo = readCustomTodo(entry) ?? readToolTodo(entry);
|
|
10503
10652
|
if (todo) {
|
|
10504
10653
|
phases = todo.phases;
|
|
10505
|
-
|
|
10506
|
-
incomplete = true;
|
|
10654
|
+
incomplete = todo.truncated;
|
|
10507
10655
|
}
|
|
10508
10656
|
if (entry.type !== "custom" || typeof entry.customType !== "string")
|
|
10509
10657
|
continue;
|
|
@@ -10564,13 +10712,6 @@ function projectPagedRuntimeBranch(entries, leafId) {
|
|
|
10564
10712
|
|
|
10565
10713
|
// src/native-runtime.ts
|
|
10566
10714
|
var TIMEOUT = 6000;
|
|
10567
|
-
var taskStatus = _enum(["pending", "running", "paused", "completed", "error", "cancelled", "interrupted", "lost"]);
|
|
10568
|
-
var taskRow = object({ status: taskStatus, created_at: timestamp2, updated_at: timestamp2, ...taskDisplayFields });
|
|
10569
|
-
var taskReply = object({
|
|
10570
|
-
parent_session_id: identity,
|
|
10571
|
-
tasks: boundedRows(taskRow),
|
|
10572
|
-
truncated_tasks: count2.optional()
|
|
10573
|
-
});
|
|
10574
10715
|
var memoryReply = object({
|
|
10575
10716
|
schemaVersion: literal(1),
|
|
10576
10717
|
journal: object({ sessionId: identity, totalSteps: count2, reflectedSteps: count2 })
|
|
@@ -10586,7 +10727,12 @@ function bindNativeRuntime(raw, expected) {
|
|
|
10586
10727
|
if (!state.success || state.data.archived === true || !expected.route || state.data.sessionId === expected.route || state.data.cwd !== expected.cwd || state.data.sessionFile !== expected.sessionFile || expected.durableId !== undefined && state.data.sessionId !== expected.durableId)
|
|
10587
10728
|
return;
|
|
10588
10729
|
const secret = randomBytes3(32);
|
|
10589
|
-
return {
|
|
10730
|
+
return {
|
|
10731
|
+
...state.data,
|
|
10732
|
+
route: expected.route,
|
|
10733
|
+
dagKey: (runId) => createHmac2("sha256", secret).update(runId).digest("hex"),
|
|
10734
|
+
taskKey: (taskId) => createHmac2("sha256", secret).update("task\x00").update(taskId).digest("hex")
|
|
10735
|
+
};
|
|
10590
10736
|
}
|
|
10591
10737
|
var unavailable2 = (reason) => ({ status: "unavailable", reason });
|
|
10592
10738
|
var ownershipChanged2 = { status: "ownership_changed" };
|
|
@@ -10607,40 +10753,7 @@ function fault(error, extension) {
|
|
|
10607
10753
|
return unavailable2("engine_unavailable");
|
|
10608
10754
|
return unavailable2("native_unavailable");
|
|
10609
10755
|
}
|
|
10610
|
-
function
|
|
10611
|
-
return {
|
|
10612
|
-
status: row.status,
|
|
10613
|
-
createdAt: row.created_at,
|
|
10614
|
-
updatedAt: row.updated_at,
|
|
10615
|
-
...row.agent_type === undefined ? {} : { agent: row.agent_type },
|
|
10616
|
-
...row.category === undefined ? {} : { category: row.category },
|
|
10617
|
-
...row.execution_mode === undefined ? {} : { executionMode: row.execution_mode }
|
|
10618
|
-
};
|
|
10619
|
-
}
|
|
10620
|
-
function projectTasks(raw, durableId) {
|
|
10621
|
-
switch (raw.kind) {
|
|
10622
|
-
case "unavailable":
|
|
10623
|
-
return unavailable2("native_unavailable");
|
|
10624
|
-
case "not_found":
|
|
10625
|
-
return ownershipChanged2;
|
|
10626
|
-
case undefined:
|
|
10627
|
-
break;
|
|
10628
|
-
default:
|
|
10629
|
-
return malformed3;
|
|
10630
|
-
}
|
|
10631
|
-
const parsed = taskReply.safeParse(raw);
|
|
10632
|
-
if (!parsed.success)
|
|
10633
|
-
return malformed3;
|
|
10634
|
-
const { parent_session_id, tasks, truncated_tasks = 0 } = parsed.data;
|
|
10635
|
-
if (parent_session_id !== durableId)
|
|
10636
|
-
return ownershipChanged2;
|
|
10637
|
-
if (truncated_tasks > 0 && tasks.length !== RUNTIME_LIST_LIMIT)
|
|
10638
|
-
return malformed3;
|
|
10639
|
-
if (tasks.length === 0)
|
|
10640
|
-
return empty;
|
|
10641
|
-
return { status: "ok", omittedCount: truncated_tasks, rows: tasks.map(projectTaskRow) };
|
|
10642
|
-
}
|
|
10643
|
-
function readDagRows(raw, durableId) {
|
|
10756
|
+
function readDagRows(raw, durableId, selection) {
|
|
10644
10757
|
if (raw.ok === false) {
|
|
10645
10758
|
const error = object({ code: string2() }).safeParse(raw.error);
|
|
10646
10759
|
if (!error.success)
|
|
@@ -10661,6 +10774,8 @@ function readDagRows(raw, durableId) {
|
|
|
10661
10774
|
const { runs } = parsed.data.value;
|
|
10662
10775
|
if (runs.some((row) => row.parentSessionId !== durableId))
|
|
10663
10776
|
return ownershipChanged2;
|
|
10777
|
+
if (runs.some((row) => !dagStatuses(selection).includes(row.status)))
|
|
10778
|
+
return malformed3;
|
|
10664
10779
|
const ids = runs.flatMap((row) => row.runId === undefined ? [] : [row.runId]);
|
|
10665
10780
|
if (new Set(ids).size !== ids.length)
|
|
10666
10781
|
return malformed3;
|
|
@@ -10719,20 +10834,16 @@ async function withinBinding(scope, read) {
|
|
|
10719
10834
|
async function readNativeRuntime(scope) {
|
|
10720
10835
|
const { target } = scope;
|
|
10721
10836
|
const result = await withinBinding(scope, async () => {
|
|
10722
|
-
const [tasks,
|
|
10723
|
-
|
|
10724
|
-
|
|
10837
|
+
const [tasks, dag, memory] = await Promise.all([
|
|
10838
|
+
readTaskSection(scope),
|
|
10839
|
+
readDagSection(scope, "current"),
|
|
10725
10840
|
readExtension(scope, { name: "omo.memory.status", data: {} }, (raw) => projectMemory(raw, target.sessionId))
|
|
10726
10841
|
]);
|
|
10727
|
-
const dag = "status" in list ? list : list.runs.length === 0 ? empty : {
|
|
10728
|
-
status: "ok",
|
|
10729
|
-
limitReached: list.runs.length === RUNTIME_LIST_LIMIT,
|
|
10730
|
-
rows: list.runs.map((row) => projectDagRow(row, target.dagKey))
|
|
10731
|
-
};
|
|
10732
10842
|
return { tasks, dag, memory };
|
|
10733
10843
|
});
|
|
10734
10844
|
return "status" in result ? all(result) : result;
|
|
10735
10845
|
}
|
|
10846
|
+
var readTaskSection = (scope) => readExtension(scope, { name: "omo.task.list", data: { parent_session_id: scope.target.sessionId } }, (raw) => projectTasks(raw, scope.target));
|
|
10736
10847
|
async function readExtension(scope, request, project) {
|
|
10737
10848
|
let raw;
|
|
10738
10849
|
try {
|
|
@@ -10742,42 +10853,56 @@ async function readExtension(scope, request, project) {
|
|
|
10742
10853
|
}
|
|
10743
10854
|
return project(raw);
|
|
10744
10855
|
}
|
|
10745
|
-
var readDagList = (scope) => readExtension(scope, { name: "omo.dag.list", data: { limit: RUNTIME_LIST_LIMIT } }, (raw) => readDagRows(raw, scope.target.sessionId));
|
|
10746
|
-
|
|
10747
|
-
|
|
10856
|
+
var readDagList = (scope, selection) => readExtension(scope, { name: "omo.dag.list", data: { limit: RUNTIME_LIST_LIMIT, statuses: dagStatuses(selection) } }, (raw) => readDagRows(raw, scope.target.sessionId, selection));
|
|
10857
|
+
async function readDagSection(scope, selection) {
|
|
10858
|
+
const list = await readDagList(scope, selection);
|
|
10859
|
+
if ("status" in list)
|
|
10860
|
+
return list;
|
|
10861
|
+
if (list.runs.length === 0)
|
|
10862
|
+
return { status: "unavailable", reason: "native_window_unverified" };
|
|
10863
|
+
return {
|
|
10864
|
+
status: "ok",
|
|
10865
|
+
coverage: "native_window",
|
|
10866
|
+
limitReached: list.runs.length === RUNTIME_LIST_LIMIT,
|
|
10867
|
+
rows: list.runs.map((row) => projectDagRow(row, scope.target.dagKey))
|
|
10868
|
+
};
|
|
10869
|
+
}
|
|
10870
|
+
async function readNativeDagHistory(scope) {
|
|
10871
|
+
return typeof scope === "string" ? unavailable2(scope) : withinBinding(scope, () => readDagSection(scope, "history"));
|
|
10872
|
+
}
|
|
10873
|
+
var notFound3 = { status: "not_found" };
|
|
10874
|
+
async function readNativeDag(scope, key, selection) {
|
|
10748
10875
|
if (typeof scope === "string")
|
|
10749
10876
|
return unavailable2(scope);
|
|
10750
10877
|
return withinBinding(scope, async () => {
|
|
10751
|
-
const list = await readDagList(scope);
|
|
10878
|
+
const list = await readDagList(scope, selection);
|
|
10752
10879
|
if ("status" in list)
|
|
10753
10880
|
return list;
|
|
10754
10881
|
const runId = list.runs.find((row) => row.runId !== undefined && scope.target.dagKey(row.runId) === key)?.runId;
|
|
10755
10882
|
if (runId === undefined)
|
|
10756
|
-
return
|
|
10883
|
+
return notFound3;
|
|
10757
10884
|
const guard = await sameBinding(scope);
|
|
10758
10885
|
if (guard || !scope.isCurrent())
|
|
10759
10886
|
return guard ?? ownershipChanged2;
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
|
|
10887
|
+
const [snapshot, tasks] = await Promise.all([
|
|
10888
|
+
readExtension(scope, { name: "omo.dag.snapshot", data: { runId } }, (raw) => ({ raw })),
|
|
10889
|
+
readTaskSection(scope)
|
|
10890
|
+
]);
|
|
10891
|
+
if (!("raw" in snapshot))
|
|
10892
|
+
return snapshot;
|
|
10893
|
+
const keys = new Set(tasks.status === "ok" ? tasks.rows.map((row) => row.key) : []);
|
|
10894
|
+
return projectDagSnapshot(snapshot.raw, {
|
|
10895
|
+
runId,
|
|
10896
|
+
owner: scope.target.sessionId,
|
|
10897
|
+
scope: selection,
|
|
10898
|
+
taskKey: (id) => {
|
|
10899
|
+
const key = scope.target.taskKey(id);
|
|
10900
|
+
return keys.has(key) ? key : undefined;
|
|
10774
10901
|
}
|
|
10775
|
-
return projectDagSnapshot(raw, { runId, owner: scope.target.sessionId });
|
|
10776
10902
|
});
|
|
10777
10903
|
});
|
|
10778
10904
|
}
|
|
10779
10905
|
var BRANCH_PAGE_LIMIT = 4;
|
|
10780
|
-
var WORKBENCH_PAGE_LIMIT = 1;
|
|
10781
10906
|
var incomplete = { status: "unavailable", reason: "incomplete" };
|
|
10782
10907
|
function entryFailure(error) {
|
|
10783
10908
|
if (!(error instanceof WebError))
|
|
@@ -10903,13 +11028,17 @@ async function navigateSessionTree(scope, action, beforeWrite, isBusy) {
|
|
|
10903
11028
|
...typeof result.editorText === "string" && Buffer.byteLength(result.editorText, "utf8") <= 200000 ? { editorText: result.editorText } : {}
|
|
10904
11029
|
};
|
|
10905
11030
|
}
|
|
10906
|
-
|
|
11031
|
+
var TODO_HISTORY_LIMIT = 8;
|
|
11032
|
+
var TODO_HISTORY_BYTES = 256 * 1024;
|
|
11033
|
+
function branchFailure(result) {
|
|
11034
|
+
return result.status === "unavailable" ? result : { status: "unavailable", reason: result.status };
|
|
11035
|
+
}
|
|
11036
|
+
async function readBranchRuntime(scope) {
|
|
10907
11037
|
if (typeof scope === "string")
|
|
10908
11038
|
return { status: "unavailable", reason: scope };
|
|
10909
11039
|
const result = await withinBinding(scope, async () => {
|
|
10910
11040
|
const pages = [];
|
|
10911
|
-
|
|
10912
|
-
for (let i = 0;i < limit; i++) {
|
|
11041
|
+
for (let i = 0;i < BRANCH_PAGE_LIMIT; i++) {
|
|
10913
11042
|
let page;
|
|
10914
11043
|
const position = pages.at(-1)?.next;
|
|
10915
11044
|
if (position)
|
|
@@ -10926,15 +11055,103 @@ async function readBranchRuntime(scope, passive = false) {
|
|
|
10926
11055
|
const view = projectPagedRuntimeBranch(pages.toReversed().flatMap((page) => page.entries), page.leafId);
|
|
10927
11056
|
if (view.status === "invalid")
|
|
10928
11057
|
return view.reason === "tree-budget" ? incomplete : malformed3;
|
|
10929
|
-
|
|
11058
|
+
const todo = view.incomplete ? incomplete : view.todo.status === "ok" ? currentBranchTodo(view.todo.phases) : view.todo;
|
|
11059
|
+
return { status: "ok", leafId: view.leafId, todo, memory: view.memory };
|
|
10930
11060
|
}
|
|
10931
11061
|
}
|
|
10932
11062
|
return incomplete;
|
|
10933
11063
|
});
|
|
10934
|
-
return result.status === "
|
|
11064
|
+
return result.status === "ok" ? result : branchFailure(result);
|
|
11065
|
+
}
|
|
11066
|
+
async function walkTodo(scope, visit, finish) {
|
|
11067
|
+
if (typeof scope === "string")
|
|
11068
|
+
return { status: "unavailable", reason: scope };
|
|
11069
|
+
const result = await withinBinding(scope, async () => {
|
|
11070
|
+
let position;
|
|
11071
|
+
let leafId;
|
|
11072
|
+
let parent = null;
|
|
11073
|
+
const visited = new Set;
|
|
11074
|
+
for (let i = 0;i < BRANCH_PAGE_LIMIT; i++) {
|
|
11075
|
+
if (position)
|
|
11076
|
+
await scope.verifyWorkspace();
|
|
11077
|
+
let page;
|
|
11078
|
+
try {
|
|
11079
|
+
page = await readEntryPage(scope, { position, expectedLeafId: leafId, acceptLargeSingleton: true });
|
|
11080
|
+
} catch (error) {
|
|
11081
|
+
if (position && error instanceof WebError && error.code === "not_found")
|
|
11082
|
+
return ownershipChanged2;
|
|
11083
|
+
return entryFailure(error);
|
|
11084
|
+
}
|
|
11085
|
+
if (leafId === undefined)
|
|
11086
|
+
parent = leafId = page.leafId;
|
|
11087
|
+
for (const { id, parentId, raw } of page.entries.toReversed()) {
|
|
11088
|
+
visited.add(id);
|
|
11089
|
+
if (id !== parent)
|
|
11090
|
+
continue;
|
|
11091
|
+
if (parentId !== null && visited.has(parentId))
|
|
11092
|
+
return malformed3;
|
|
11093
|
+
parent = parentId;
|
|
11094
|
+
const outcome = visit(raw, leafId);
|
|
11095
|
+
if (outcome)
|
|
11096
|
+
return outcome;
|
|
11097
|
+
}
|
|
11098
|
+
if (parent === null)
|
|
11099
|
+
return finish(leafId, true);
|
|
11100
|
+
position = page.next;
|
|
11101
|
+
if (!position)
|
|
11102
|
+
return malformed3;
|
|
11103
|
+
}
|
|
11104
|
+
return finish(leafId ?? null, false);
|
|
11105
|
+
});
|
|
11106
|
+
return result.status === "ok" ? result : branchFailure(result);
|
|
11107
|
+
}
|
|
11108
|
+
function readCurrentTodo(scope) {
|
|
11109
|
+
return walkTodo(scope, (entry, leafId) => {
|
|
11110
|
+
const todo = projectTodoRecord(entry);
|
|
11111
|
+
if (!todo)
|
|
11112
|
+
return;
|
|
11113
|
+
return todo.truncated ? incomplete : { status: "ok", leafId, todo: currentBranchTodo(todo.phases) };
|
|
11114
|
+
}, (leafId, complete) => complete ? { status: "ok", leafId, todo: { status: "none" } } : incomplete);
|
|
11115
|
+
}
|
|
11116
|
+
function readTodoHistory(scope) {
|
|
11117
|
+
const snapshots = [];
|
|
11118
|
+
const seen = new Set;
|
|
11119
|
+
let newest = true;
|
|
11120
|
+
let skipped = false;
|
|
11121
|
+
let bytes = 0;
|
|
11122
|
+
return walkTodo(scope, (entry, leafId) => {
|
|
11123
|
+
const record = projectTodoRecord(entry);
|
|
11124
|
+
if (!record)
|
|
11125
|
+
return;
|
|
11126
|
+
const isNewest = newest;
|
|
11127
|
+
newest = false;
|
|
11128
|
+
if (record.truncated) {
|
|
11129
|
+
skipped = true;
|
|
11130
|
+
return;
|
|
11131
|
+
}
|
|
11132
|
+
if (!record.phases.some((phase) => phase.tasks.length !== 0))
|
|
11133
|
+
return;
|
|
11134
|
+
const snapshot = { phases: record.phases };
|
|
11135
|
+
const key = JSON.stringify(snapshot);
|
|
11136
|
+
if (seen.has(key))
|
|
11137
|
+
return;
|
|
11138
|
+
seen.add(key);
|
|
11139
|
+
if (isNewest && currentBranchTodo(record.phases).status === "ok")
|
|
11140
|
+
return;
|
|
11141
|
+
if (snapshots.length === TODO_HISTORY_LIMIT)
|
|
11142
|
+
return { status: "ok", leafId, snapshots, limitReached: true };
|
|
11143
|
+
const size = Buffer.byteLength(key) + 1;
|
|
11144
|
+
if (bytes + size > TODO_HISTORY_BYTES) {
|
|
11145
|
+
skipped = true;
|
|
11146
|
+
return;
|
|
11147
|
+
}
|
|
11148
|
+
bytes += size;
|
|
11149
|
+
snapshots.push(snapshot);
|
|
11150
|
+
return;
|
|
11151
|
+
}, (leafId, complete) => ({ status: "ok", leafId, snapshots, limitReached: skipped || !complete }));
|
|
10935
11152
|
}
|
|
10936
11153
|
async function readWorkbenchStatus(scope) {
|
|
10937
|
-
const view = await
|
|
11154
|
+
const view = await readCurrentTodo(scope);
|
|
10938
11155
|
if (view.status === "unavailable")
|
|
10939
11156
|
return view;
|
|
10940
11157
|
if (view.todo.status === "none")
|
|
@@ -11129,6 +11346,69 @@ import { createHash as createHash2, createHmac as createHmac3, randomBytes as ra
|
|
|
11129
11346
|
import { closeSync, mkdtempSync, openSync, readSync, rmSync, writeSync } from "fs";
|
|
11130
11347
|
import { tmpdir } from "os";
|
|
11131
11348
|
import { join as join6 } from "path";
|
|
11349
|
+
|
|
11350
|
+
// src/skill-input.ts
|
|
11351
|
+
var currentPrefix = 'The user explicitly invoked the "';
|
|
11352
|
+
var requestStart = `
|
|
11353
|
+
|
|
11354
|
+
<user-request>
|
|
11355
|
+
`;
|
|
11356
|
+
var requestEnd = `
|
|
11357
|
+
</user-request>`;
|
|
11358
|
+
function parseSkillInput(text) {
|
|
11359
|
+
if (!text.startsWith(currentPrefix)) {
|
|
11360
|
+
if (!text.startsWith("<skill name="))
|
|
11361
|
+
return;
|
|
11362
|
+
const legacy = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/u.exec(text);
|
|
11363
|
+
if (legacy)
|
|
11364
|
+
return {
|
|
11365
|
+
skills: [{ name: legacy[1], location: legacy[2], content: legacy[3] }],
|
|
11366
|
+
request: legacy[4] ?? ""
|
|
11367
|
+
};
|
|
11368
|
+
return;
|
|
11369
|
+
}
|
|
11370
|
+
const block = /The user explicitly invoked the "([^"]+)" skill\. Follow the instructions in <skill-instruction> as binding for this request, while respecting higher-priority instructions\.\n\n<skill-instruction name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill-instruction>/uy;
|
|
11371
|
+
const skills = [];
|
|
11372
|
+
let endOfSkills = 0;
|
|
11373
|
+
while (true) {
|
|
11374
|
+
block.lastIndex = endOfSkills;
|
|
11375
|
+
const match = block.exec(text);
|
|
11376
|
+
if (!match || match[1] !== match[2])
|
|
11377
|
+
return;
|
|
11378
|
+
skills.push({ name: match[1], location: match[3], content: match[4] });
|
|
11379
|
+
endOfSkills = block.lastIndex;
|
|
11380
|
+
if (!text.startsWith(`
|
|
11381
|
+
|
|
11382
|
+
${currentPrefix}`, endOfSkills))
|
|
11383
|
+
break;
|
|
11384
|
+
endOfSkills += 2;
|
|
11385
|
+
}
|
|
11386
|
+
if (endOfSkills === text.length)
|
|
11387
|
+
return { skills, request: "" };
|
|
11388
|
+
const start = endOfSkills + requestStart.length;
|
|
11389
|
+
const end = text.length - requestEnd.length;
|
|
11390
|
+
if (start <= end && text.startsWith(requestStart, endOfSkills) && text.endsWith(requestEnd)) {
|
|
11391
|
+
return { skills, request: text.slice(start, end) };
|
|
11392
|
+
}
|
|
11393
|
+
}
|
|
11394
|
+
function skillInputNames({ skills }) {
|
|
11395
|
+
const names = skills.slice(0, 3).map(({ name }) => {
|
|
11396
|
+
const head = name.slice(0, 24).replace(/[\uD800-\uDBFF]$/u, "").replace(/\s+/gu, " ").trim();
|
|
11397
|
+
return name.length > 24 ? `${head}\u2026` : head || "\u2026";
|
|
11398
|
+
});
|
|
11399
|
+
if (skills.length > names.length)
|
|
11400
|
+
names.push(`+${skills.length - names.length}`);
|
|
11401
|
+
return names.join(" \xB7 ");
|
|
11402
|
+
}
|
|
11403
|
+
function skillInputInstructions({ skills }) {
|
|
11404
|
+
return skills.map(({ name, location, content }) => `${name} \xB7 ${location}
|
|
11405
|
+
|
|
11406
|
+
${content}`).join(`
|
|
11407
|
+
|
|
11408
|
+
`);
|
|
11409
|
+
}
|
|
11410
|
+
|
|
11411
|
+
// src/transcript-pages.ts
|
|
11132
11412
|
var KiB2 = 1024;
|
|
11133
11413
|
var TRANSCRIPT_PAGE_BYTES = 256 * KiB2;
|
|
11134
11414
|
var TRANSCRIPT_CONTENT_BYTES = 64 * KiB2;
|
|
@@ -11258,6 +11538,23 @@ function preview(row) {
|
|
|
11258
11538
|
});
|
|
11259
11539
|
return small;
|
|
11260
11540
|
}
|
|
11541
|
+
function pagedSkill(row, cursor) {
|
|
11542
|
+
if (row.role !== "user")
|
|
11543
|
+
return;
|
|
11544
|
+
const blocks = Array.isArray(row.content) ? row.content : undefined;
|
|
11545
|
+
const texts = blocks?.filter((part) => part.type === "text");
|
|
11546
|
+
const text = typeof row.content === "string" ? row.content : texts?.length === 1 ? texts[0]?.text : undefined;
|
|
11547
|
+
const skill = typeof text === "string" ? parseSkillInput(text) : undefined;
|
|
11548
|
+
if (!skill)
|
|
11549
|
+
return;
|
|
11550
|
+
const projected = {
|
|
11551
|
+
...row,
|
|
11552
|
+
content: blocks ? blocks.map((part) => part.type === "text" ? { type: "text", text: skill.request } : part) : skill.request,
|
|
11553
|
+
historyContent: { cursor, skillNames: skillInputNames(skill) }
|
|
11554
|
+
};
|
|
11555
|
+
if (jsonBytes(projected) <= INLINE_BYTES)
|
|
11556
|
+
return { row: projected, instructions: skillInputInstructions(skill) };
|
|
11557
|
+
}
|
|
11261
11558
|
|
|
11262
11559
|
class TranscriptCapture {
|
|
11263
11560
|
owner;
|
|
@@ -11309,16 +11606,19 @@ class TranscriptCapture {
|
|
|
11309
11606
|
return;
|
|
11310
11607
|
}
|
|
11311
11608
|
if (size > INLINE_BYTES) {
|
|
11609
|
+
const cursor = this.#token(CONTENT, this.#next, 0);
|
|
11610
|
+
const skill = pagedSkill(row, cursor);
|
|
11312
11611
|
const role = row.role;
|
|
11313
|
-
const text = role === "user" || role === "assistant" || role === "custom" ? typeof row.content === "string" ? row.content : Array.isArray(row.content) && row.content.length === 1 ? record2(row.content[0]).text : undefined : undefined;
|
|
11314
|
-
const small = preview(row);
|
|
11315
|
-
if (typeof text === "string" && text.length > PREVIEW_UNITS) {
|
|
11612
|
+
const text = skill?.instructions ?? (role === "user" || role === "assistant" || role === "custom" ? typeof row.content === "string" ? row.content : Array.isArray(row.content) && row.content.length === 1 ? record2(row.content[0]).text : undefined : undefined);
|
|
11613
|
+
const small = skill?.row ?? preview(row);
|
|
11614
|
+
if (typeof text === "string" && (skill || text.length > PREVIEW_UNITS)) {
|
|
11316
11615
|
for (let start = 0;start < text.length; ) {
|
|
11317
11616
|
const end = textEnd(text, start, TEXT_UNITS);
|
|
11318
11617
|
chunks.push(Buffer.from(JSON.stringify(text.slice(start, end))));
|
|
11319
11618
|
start = end;
|
|
11320
11619
|
}
|
|
11321
|
-
|
|
11620
|
+
if (!skill)
|
|
11621
|
+
small.historyContent = { cursor };
|
|
11322
11622
|
if (Object.keys(small).some((key) => key !== "content" && key !== "historyContent" && small[key] !== row[key])) {
|
|
11323
11623
|
this.markOmitted();
|
|
11324
11624
|
}
|
|
@@ -12381,6 +12681,12 @@ ${source.nativeSessionId}`;
|
|
|
12381
12681
|
branchRuntime(id) {
|
|
12382
12682
|
return readBranchRuntime(this.#historyRead(id));
|
|
12383
12683
|
}
|
|
12684
|
+
currentTodo(id) {
|
|
12685
|
+
return readCurrentTodo(this.#historyRead(id));
|
|
12686
|
+
}
|
|
12687
|
+
todoHistory(id) {
|
|
12688
|
+
return readTodoHistory(this.#historyRead(id));
|
|
12689
|
+
}
|
|
12384
12690
|
async#navigate(id, action) {
|
|
12385
12691
|
const scope = this.#runtimeRead(id);
|
|
12386
12692
|
let write;
|
|
@@ -12396,8 +12702,11 @@ ${source.nativeSessionId}`;
|
|
|
12396
12702
|
write.pending = false;
|
|
12397
12703
|
}
|
|
12398
12704
|
}
|
|
12399
|
-
nativeDag(id, key) {
|
|
12400
|
-
return readNativeDag(this.#runtimeRead(id), key);
|
|
12705
|
+
nativeDag(id, key, scope) {
|
|
12706
|
+
return readNativeDag(this.#runtimeRead(id), key, scope);
|
|
12707
|
+
}
|
|
12708
|
+
nativeDagHistory(id) {
|
|
12709
|
+
return readNativeDagHistory(this.#runtimeRead(id));
|
|
12401
12710
|
}
|
|
12402
12711
|
findAlias(nativeSessionId, cwd, workspaceKey) {
|
|
12403
12712
|
for (const row of this.#rows.values()) {
|
|
@@ -14180,7 +14489,7 @@ function readWindowsPasswordFile(path) {
|
|
|
14180
14489
|
// src/web-access.ts
|
|
14181
14490
|
var headers = {
|
|
14182
14491
|
"Cache-Control": "no-store",
|
|
14183
|
-
"Content-Security-Policy": "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data: blob:; connect-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'",
|
|
14492
|
+
"Content-Security-Policy": "default-src 'none'; script-src 'self'; style-src 'self' 'sha256-PRkCmUvPlOG4zuGb5RMOg4JNxOnUv7s4ZwOqAp874Fw='; img-src 'self' data: blob:; connect-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'",
|
|
14184
14493
|
"Cross-Origin-Resource-Policy": "same-origin",
|
|
14185
14494
|
"Referrer-Policy": "no-referrer",
|
|
14186
14495
|
"X-Content-Type-Options": "nosniff",
|
|
@@ -14405,6 +14714,8 @@ var MAX_REQUEST_BYTES = 12 * 1024 * 1024;
|
|
|
14405
14714
|
var MAX_JSON_BYTES = 512 * 1024;
|
|
14406
14715
|
var MAX_SSE_FRAME_BYTES = 96 * 1024;
|
|
14407
14716
|
var MAX_STREAM_CLIENTS = 16;
|
|
14717
|
+
var MAX_HISTORY_DIRECTORIES = 32;
|
|
14718
|
+
var MAX_HISTORY_SELECTIONS_PER_DIRECTORY = 400;
|
|
14408
14719
|
var SSE_PREFIX = `event: omo
|
|
14409
14720
|
data: `;
|
|
14410
14721
|
var SSE_SUFFIX = `
|
|
@@ -14511,13 +14822,19 @@ async function startApp(settings) {
|
|
|
14511
14822
|
const profile = settings.cliAgentDir?.trim() || undefined;
|
|
14512
14823
|
const history = new CliHistory(profile, workspaces);
|
|
14513
14824
|
const native = new NativeActivity(profile);
|
|
14514
|
-
let
|
|
14825
|
+
let legacyHistorySessions = new Map;
|
|
14826
|
+
const scopedHistorySessions = new Map;
|
|
14515
14827
|
const historyKey = (session) => createHmac5("sha256", tokenBytes).update(JSON.stringify([session.cwd, session.id, session.workspaceKey])).digest("hex");
|
|
14516
|
-
async function activityFor(durableId, cwd) {
|
|
14517
|
-
|
|
14828
|
+
async function activityFor(durableId, cwd, expectedKey) {
|
|
14829
|
+
const key = await workspaces.exact(cwd);
|
|
14830
|
+
if (key === undefined || expectedKey !== undefined && key !== expectedKey) {
|
|
14518
14831
|
throw new WebError(403, "workspace_refused", "\u6B64\u5DE5\u4F5C\u76EE\u5F55\u5DF2\u4E0D\u53EF\u7528\u3002");
|
|
14519
14832
|
}
|
|
14520
|
-
|
|
14833
|
+
const data = await native.read(durableId, cwd);
|
|
14834
|
+
if (expectedKey !== undefined && await workspaces.exact(cwd) !== expectedKey) {
|
|
14835
|
+
throw new WebError(403, "workspace_refused", "\u6B64\u5DE5\u4F5C\u76EE\u5F55\u5DF2\u4E0D\u53EF\u7528\u3002");
|
|
14836
|
+
}
|
|
14837
|
+
return activityResponse(data);
|
|
14521
14838
|
}
|
|
14522
14839
|
const clients = new Set;
|
|
14523
14840
|
const disconnect = (client) => {
|
|
@@ -14594,7 +14911,16 @@ async function startApp(settings) {
|
|
|
14594
14911
|
throw error;
|
|
14595
14912
|
}
|
|
14596
14913
|
async function selectedHistory(id) {
|
|
14597
|
-
|
|
14914
|
+
let selected = id === undefined ? undefined : legacyHistorySessions.get(id);
|
|
14915
|
+
if (id !== undefined) {
|
|
14916
|
+
for (const catalog of scopedHistorySessions.values()) {
|
|
14917
|
+
const row = catalog.get(id);
|
|
14918
|
+
if (row !== undefined) {
|
|
14919
|
+
selected = row;
|
|
14920
|
+
break;
|
|
14921
|
+
}
|
|
14922
|
+
}
|
|
14923
|
+
}
|
|
14598
14924
|
if (!selected || selected.workspaceKey === undefined || await workspaces.exact(selected.cwd) !== selected.workspaceKey) {
|
|
14599
14925
|
throw new WebError(404, "history_not_found", "\u627E\u4E0D\u5230\u8FD9\u6761 CLI \u5386\u53F2\uFF0C\u8BF7\u5237\u65B0\u5217\u8868\u3002");
|
|
14600
14926
|
}
|
|
@@ -14650,18 +14976,58 @@ async function startApp(settings) {
|
|
|
14650
14976
|
return listing;
|
|
14651
14977
|
}
|
|
14652
14978
|
if (pathname === "/api/cli-history") {
|
|
14653
|
-
const
|
|
14654
|
-
|
|
14655
|
-
|
|
14656
|
-
|
|
14657
|
-
|
|
14658
|
-
|
|
14659
|
-
|
|
14660
|
-
|
|
14661
|
-
|
|
14662
|
-
|
|
14663
|
-
|
|
14664
|
-
}
|
|
14979
|
+
const requested = searchParams.has("cwd") ? workspacePath.shape.path.parse(searchParams.get("cwd")) : undefined;
|
|
14980
|
+
if (requested !== undefined && searchParams.size !== 1) {
|
|
14981
|
+
throw new WebError(400, "invalid_request", "\u8BF7\u6C42\u53C2\u6570\u4E0D\u6B63\u786E\u3002");
|
|
14982
|
+
}
|
|
14983
|
+
const scope = requested === undefined ? undefined : { root: requested, workspaceKey: await workspaces.exact(requested) };
|
|
14984
|
+
if (scope !== undefined && scope.workspaceKey === undefined) {
|
|
14985
|
+
throw new WebError(403, "workspace_refused", "\u6B64\u5DE5\u4F5C\u76EE\u5F55\u672A\u83B7\u6388\u6743\u6216\u5DF2\u4E0D\u53EF\u7528\u3002");
|
|
14986
|
+
}
|
|
14987
|
+
const { available, sessions: rows } = await history.listWithIds(scope);
|
|
14988
|
+
if (scope !== undefined && await workspaces.exact(scope.root) !== scope.workspaceKey) {
|
|
14989
|
+
throw new WebError(403, "workspace_refused", "\u6B64\u5DE5\u4F5C\u76EE\u5F55\u672A\u83B7\u6388\u6743\u6216\u5DF2\u4E0D\u53EF\u7528\u3002");
|
|
14990
|
+
}
|
|
14991
|
+
const returned = new Map;
|
|
14992
|
+
const result = [];
|
|
14993
|
+
let bytes = Buffer.byteLength(JSON.stringify({ available, sessions: [] }));
|
|
14994
|
+
const entries = rows.map((row) => [historyKey(row), row]);
|
|
14995
|
+
for (const [id, row] of scope === undefined ? new Map(entries) : entries) {
|
|
14996
|
+
if (returned.has(id))
|
|
14997
|
+
continue;
|
|
14998
|
+
const { cwd, updatedAt, nativeSessionId, workspaceKey } = row;
|
|
14999
|
+
const name = scope === undefined ? row.name : row.name.slice(0, 256);
|
|
15000
|
+
const summary = { id, name, cwd, updatedAt, adopted: sessions.findAlias(nativeSessionId, cwd, workspaceKey) !== undefined };
|
|
15001
|
+
if (scope !== undefined) {
|
|
15002
|
+
bytes += Buffer.byteLength(JSON.stringify(summary)) + Number(result.length > 0);
|
|
15003
|
+
if (bytes > MAX_JSON_BYTES)
|
|
15004
|
+
break;
|
|
15005
|
+
}
|
|
15006
|
+
result.push(summary);
|
|
15007
|
+
returned.set(id, row.name === name ? row : { ...row, name });
|
|
15008
|
+
}
|
|
15009
|
+
if (scope === undefined) {
|
|
15010
|
+
legacyHistorySessions = returned;
|
|
15011
|
+
} else if (returned.size) {
|
|
15012
|
+
const catalog = scopedHistorySessions.get(scope.root) ?? new Map;
|
|
15013
|
+
for (const [id, row] of returned) {
|
|
15014
|
+
catalog.delete(id);
|
|
15015
|
+
catalog.set(id, row);
|
|
15016
|
+
}
|
|
15017
|
+
for (const id of catalog.keys()) {
|
|
15018
|
+
if (catalog.size <= MAX_HISTORY_SELECTIONS_PER_DIRECTORY)
|
|
15019
|
+
break;
|
|
15020
|
+
catalog.delete(id);
|
|
15021
|
+
}
|
|
15022
|
+
scopedHistorySessions.delete(scope.root);
|
|
15023
|
+
scopedHistorySessions.set(scope.root, catalog);
|
|
15024
|
+
for (const cwd of scopedHistorySessions.keys()) {
|
|
15025
|
+
if (scopedHistorySessions.size <= MAX_HISTORY_DIRECTORIES)
|
|
15026
|
+
break;
|
|
15027
|
+
scopedHistorySessions.delete(cwd);
|
|
15028
|
+
}
|
|
15029
|
+
}
|
|
15030
|
+
return json({ available, sessions: result });
|
|
14665
15031
|
}
|
|
14666
15032
|
const historyRoute = /^\/api\/cli-history\/([a-f0-9]{64})(\/activity)?$/.exec(pathname);
|
|
14667
15033
|
if (historyRoute) {
|
|
@@ -14671,7 +15037,7 @@ async function startApp(settings) {
|
|
|
14671
15037
|
if (session.cwd !== selected.cwd)
|
|
14672
15038
|
throw new WebError(404, "history_not_found", "\u627E\u4E0D\u5230\u8FD9\u6761 CLI \u5386\u53F2\uFF0C\u8BF7\u5237\u65B0\u5217\u8868\u3002");
|
|
14673
15039
|
if (activity)
|
|
14674
|
-
return await activityFor(internal.nativeSessionId, session.cwd);
|
|
15040
|
+
return await activityFor(internal.nativeSessionId, session.cwd, selected.workspaceKey);
|
|
14675
15041
|
const { name, cwd, updatedAt } = session;
|
|
14676
15042
|
const preview = jsonWithin({ session: {
|
|
14677
15043
|
id,
|
|
@@ -14780,15 +15146,20 @@ async function startApp(settings) {
|
|
|
14780
15146
|
}
|
|
14781
15147
|
}
|
|
14782
15148
|
const dag = /^\/api\/sessions\/([a-z0-9-]+)\/native-runtime\/dag\/([a-f0-9]{64})$/u.exec(pathname);
|
|
14783
|
-
if (request.method === "GET" && dag?.[2])
|
|
14784
|
-
|
|
15149
|
+
if (request.method === "GET" && dag?.[2]) {
|
|
15150
|
+
const [scope = "current", ...extra] = searchParams.getAll("scope");
|
|
15151
|
+
if (extra.length || scope !== "current" && scope !== "history") {
|
|
15152
|
+
throw new WebError(400, "invalid_request", "\u8BF7\u6C42\u53C2\u6570\u4E0D\u6B63\u786E\u3002");
|
|
15153
|
+
}
|
|
15154
|
+
return json(await sessions.nativeDag(sessionKey.parse(dag[1]), dag[2], scope));
|
|
15155
|
+
}
|
|
14785
15156
|
const attachment = /^\/api\/sessions\/([a-z0-9-]+)\/attachments\/([a-f0-9-]+)$/u.exec(pathname);
|
|
14786
15157
|
if (request.method === "GET" && attachment?.[2] && sendFile) {
|
|
14787
15158
|
const id = sessionKey.parse(attachment[1]);
|
|
14788
15159
|
await sessions.authorizeAttachment(id);
|
|
14789
15160
|
return await sendFile.store.download(id, attachment[2], request.headers);
|
|
14790
15161
|
}
|
|
14791
|
-
const route = /^\/api\/sessions\/([a-z0-9-]+)(?:\/(options|model-preview|details|queue|tree|branch-runtime|instructions|capabilities|activity|native-runtime|workbench-status|actions|branch-options|branches|handoff|last-assistant|transcript(?:\/content)?))?$/i.exec(pathname);
|
|
15162
|
+
const route = /^\/api\/sessions\/([a-z0-9-]+)(?:\/(options|model-preview|details|queue|tree|branch-runtime|instructions|capabilities|activity|native-runtime(?:\/dag-history)?|todo-history|workbench-status|actions|branch-options|branches|handoff|last-assistant|transcript(?:\/content)?))?$/i.exec(pathname);
|
|
14792
15163
|
if (route) {
|
|
14793
15164
|
const id = sessionKey.parse(route[1]);
|
|
14794
15165
|
if (request.method === "POST" && route[2] === "actions") {
|
|
@@ -14834,20 +15205,29 @@ async function startApp(settings) {
|
|
|
14834
15205
|
throw new WebError(400, "invalid_request", "\u8BF7\u6C42\u53C2\u6570\u4E0D\u6B63\u786E\u3002");
|
|
14835
15206
|
return json(await sessions.tree(id, treeCursor.parse(searchParams.get("cursor"))));
|
|
14836
15207
|
}
|
|
14837
|
-
if ((route[2] === "details" || route[2] === "queue" || route[2] === "
|
|
15208
|
+
if ((route[2] === "details" || route[2] === "queue" || route[2] === "workbench-status" || route[2] === "native-runtime/dag-history" || route[2] === "todo-history") && searchParams.size > 0)
|
|
14838
15209
|
throw new WebError(400, "invalid_request", "\u8BF7\u6C42\u53C2\u6570\u4E0D\u6B63\u786E\u3002");
|
|
14839
15210
|
if (route[2] === "details")
|
|
14840
15211
|
return json(await sessions.details(id));
|
|
14841
15212
|
if (route[2] === "queue")
|
|
14842
15213
|
return json(await sessions.queue(id));
|
|
14843
|
-
if (route[2] === "branch-runtime")
|
|
14844
|
-
|
|
15214
|
+
if (route[2] === "branch-runtime") {
|
|
15215
|
+
if (searchParams.size === 0)
|
|
15216
|
+
return json(await sessions.branchRuntime(id));
|
|
15217
|
+
if (searchParams.size === 1 && searchParams.get("scope") === "todo")
|
|
15218
|
+
return json(await sessions.currentTodo(id));
|
|
15219
|
+
throw new WebError(400, "invalid_request", "\u8BF7\u6C42\u53C2\u6570\u4E0D\u6B63\u786E\u3002");
|
|
15220
|
+
}
|
|
15221
|
+
if (route[2] === "todo-history")
|
|
15222
|
+
return json(await sessions.todoHistory(id));
|
|
14845
15223
|
if (route[2] === "instructions")
|
|
14846
15224
|
return json(await sessions.instructions(id));
|
|
14847
15225
|
if (route[2] === "capabilities")
|
|
14848
15226
|
return json(await sessions.capabilities(id));
|
|
14849
15227
|
if (route[2] === "native-runtime")
|
|
14850
15228
|
return json(await sessions.nativeRuntime(id));
|
|
15229
|
+
if (route[2] === "native-runtime/dag-history")
|
|
15230
|
+
return json(await sessions.nativeDagHistory(id));
|
|
14851
15231
|
if (route[2] === "workbench-status")
|
|
14852
15232
|
return json(await sessions.workbenchStatus(id));
|
|
14853
15233
|
if (route[2] === "last-assistant") {
|