antechamber 2.0.12 → 2.0.14
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/CHANGELOG.md +12 -0
- package/dist/approvals.js +2 -3
- package/dist/background-results.d.ts +0 -17
- package/dist/background-results.js +12 -9
- package/dist/cli.js +2 -1
- package/dist/commands/doctor.js +5 -4
- package/dist/commands/serve.js +3 -2
- package/dist/guards.d.ts +5 -0
- package/dist/guards.js +9 -0
- package/dist/http.d.ts +0 -2
- package/dist/http.js +3 -2
- package/dist/instructions.d.ts +17 -0
- package/dist/instructions.js +53 -0
- package/dist/mcp.d.ts +0 -4
- package/dist/mcp.js +3 -8
- package/dist/misc-routes.d.ts +1 -1
- package/dist/misc-routes.js +2 -2
- package/dist/monitor-sessions.d.ts +0 -2
- package/dist/monitor-sessions.js +7 -9
- package/dist/omo-shells.d.ts +0 -1
- package/dist/pi-rpc.d.ts +2 -2
- package/dist/pi-rpc.js +2 -1
- package/dist/proc-table-darwin.d.ts +2 -1
- package/dist/prompt-parts.js +7 -11
- package/dist/route-services.d.ts +3 -2
- package/dist/route-services.js +2 -1
- package/dist/routes-v2.js +5 -4
- package/dist/running-servers.d.ts +1 -1
- package/dist/self-update.d.ts +2 -3
- package/dist/self-update.js +4 -3
- package/dist/session-commands.js +2 -4
- package/dist/session-history.js +4 -1
- package/dist/session-store.js +28 -30
- package/dist/sessions.d.ts +4 -1
- package/dist/sessions.js +29 -94
- package/dist/sse.d.ts +0 -2
- package/dist/sse.js +1 -1
- package/dist/subagents.js +19 -21
- package/dist/todo-bridge.d.ts +0 -2
- package/dist/todo-bridge.js +11 -13
- package/dist/tool-map.d.ts +1 -1
- package/dist/tool-map.js +22 -22
- package/dist/types.d.ts +8 -32
- package/dist/v2.d.ts +2 -7
- package/dist/v2.js +1 -1
- package/dist/vcs.js +2 -1
- package/dist/work-status.d.ts +2 -8
- package/dist/work-status.js +18 -20
- package/extensions/antechamber/package.json +1 -1
- package/package.json +4 -2
package/dist/subagents.js
CHANGED
|
@@ -7,12 +7,10 @@ import { syncSessionCost } from "./pi-event-translation.js";
|
|
|
7
7
|
import { ocIdFor, SessionPersistenceError, SessionStore, sessionUsageEntry } from "./session-store.js";
|
|
8
8
|
import { mapTool, resultText, toolMappers } from "./tool-map.js";
|
|
9
9
|
import { ADAPTER_VERSION } from "./version.js";
|
|
10
|
+
import { isRecord } from "./guards.js";
|
|
10
11
|
// macOS watches directories through FSEvents, which goes live asynchronously after
|
|
11
12
|
// watch() returns; a task record replaced inside that window raises no event.
|
|
12
13
|
const FSEVENTS_STARTUP_RECHECK_MS = 1_000;
|
|
13
|
-
function record(value) {
|
|
14
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
15
|
-
}
|
|
16
14
|
function taskId(value) {
|
|
17
15
|
return typeof value === "string" && /^st_[a-zA-Z0-9_-]+$/.test(value);
|
|
18
16
|
}
|
|
@@ -57,7 +55,7 @@ toolMappers.task = (args, result) => {
|
|
|
57
55
|
// OpenCode 2.x's own flag for a delegated call that returns at once (v2.ts `backgroundTask`).
|
|
58
56
|
...(args.run_in_background === true ? { background: true } : {}),
|
|
59
57
|
};
|
|
60
|
-
const details =
|
|
58
|
+
const details = isRecord(result?.details) ? result.details : {};
|
|
61
59
|
return {
|
|
62
60
|
tool: "task",
|
|
63
61
|
input,
|
|
@@ -72,7 +70,7 @@ toolMappers.task = (args, result) => {
|
|
|
72
70
|
export function taskParts(template, args) {
|
|
73
71
|
const items = Array.isArray(args.tasks) && args.tasks.length > 0 ? args.tasks : [args];
|
|
74
72
|
return items.map((item, index) => {
|
|
75
|
-
const mapped = mapTool("task", { ...args, ...(
|
|
73
|
+
const mapped = mapTool("task", { ...args, ...(isRecord(item) ? item : {}) });
|
|
76
74
|
return {
|
|
77
75
|
...template,
|
|
78
76
|
id: `prt_task_${template.callID}_${index}`,
|
|
@@ -88,13 +86,13 @@ export function taskParts(template, args) {
|
|
|
88
86
|
}
|
|
89
87
|
/** Keep task status independent of the parent tool returning a background handle. */
|
|
90
88
|
export function updateTaskParts(parts, result, ended, now) {
|
|
91
|
-
const details =
|
|
89
|
+
const details = isRecord(result.details) ? result.details : {};
|
|
92
90
|
const items = Array.isArray(details.items) ? details.items : undefined;
|
|
93
91
|
parts.forEach((part, index) => {
|
|
94
92
|
const previous = part.state.status !== "pending" ? part.state.metadata : undefined;
|
|
95
|
-
const old =
|
|
93
|
+
const old = isRecord(previous?.task) ? previous.task : {};
|
|
96
94
|
const item = items?.[index];
|
|
97
|
-
const current = items !== undefined ? (
|
|
95
|
+
const current = items !== undefined ? (isRecord(item) ? item : {}) : index === 0 ? details : {};
|
|
98
96
|
const data = { ...old, ...current };
|
|
99
97
|
const output = stripTaskSuffix(typeof data.final_response === "string"
|
|
100
98
|
? data.final_response
|
|
@@ -140,7 +138,7 @@ export function updateTaskParts(parts, result, ended, now) {
|
|
|
140
138
|
export function taskCompletions(value) {
|
|
141
139
|
if (Array.isArray(value))
|
|
142
140
|
return value.flatMap(taskCompletions);
|
|
143
|
-
if (!
|
|
141
|
+
if (!isRecord(value))
|
|
144
142
|
return [];
|
|
145
143
|
if (taskId(value.task_id))
|
|
146
144
|
return [value];
|
|
@@ -162,7 +160,7 @@ function jsonObject(path) {
|
|
|
162
160
|
return undefined;
|
|
163
161
|
try {
|
|
164
162
|
const value = JSON.parse(raw);
|
|
165
|
-
return
|
|
163
|
+
return isRecord(value) ? value : undefined;
|
|
166
164
|
}
|
|
167
165
|
catch (error) {
|
|
168
166
|
if (error instanceof SyntaxError)
|
|
@@ -186,7 +184,7 @@ function taskStores() {
|
|
|
186
184
|
const agent = piAgentDir();
|
|
187
185
|
const registry = jsonObject(join(agent, "rpc", "task-stores.json"));
|
|
188
186
|
return new Set([
|
|
189
|
-
...Object.keys(
|
|
187
|
+
...Object.keys(isRecord(registry?.stores) ? registry.stores : {}),
|
|
190
188
|
...directories(join(agent, "projects")).map((project) => join(project, "senpi-task")),
|
|
191
189
|
]);
|
|
192
190
|
}
|
|
@@ -357,7 +355,7 @@ export function evalAgentSession(parentPiId, args, claimed, after) {
|
|
|
357
355
|
const data = cached ?? childRecord(id, path);
|
|
358
356
|
if (data?.parent_session_id !== parentPiId)
|
|
359
357
|
continue;
|
|
360
|
-
const spec =
|
|
358
|
+
const spec = isRecord(data.spawn_spec) ? data.spawn_spec : {};
|
|
361
359
|
if (!recordedMatch(args.prompt, spec.prompt))
|
|
362
360
|
continue;
|
|
363
361
|
if (typeof args.label === "string" && !recordedMatch(args.label, data.name))
|
|
@@ -401,7 +399,7 @@ export function findTask(id, parentPiId) {
|
|
|
401
399
|
function transcriptSessionId(raw) {
|
|
402
400
|
try {
|
|
403
401
|
const header = JSON.parse(raw.split("\n", 1)[0] ?? "");
|
|
404
|
-
return
|
|
402
|
+
return isRecord(header) && header.type === "session" && typeof header.id === "string" ? header.id : undefined;
|
|
405
403
|
}
|
|
406
404
|
catch (error) {
|
|
407
405
|
if (error instanceof SyntaxError)
|
|
@@ -517,7 +515,7 @@ export class SubagentBridge {
|
|
|
517
515
|
return true;
|
|
518
516
|
}
|
|
519
517
|
wake(parent, event) {
|
|
520
|
-
const message =
|
|
518
|
+
const message = isRecord(event.message) ? event.message : event;
|
|
521
519
|
if (message.customType !== "omo-senpi:wake")
|
|
522
520
|
return;
|
|
523
521
|
for (const data of taskCompletions(message.details)) {
|
|
@@ -542,12 +540,12 @@ export class SubagentBridge {
|
|
|
542
540
|
* the snapshot is capped at 256 tasks.
|
|
543
541
|
*/
|
|
544
542
|
observe(parent, ev) {
|
|
545
|
-
if (ev.name !== "omo.task.updated" || !
|
|
543
|
+
if (ev.name !== "omo.task.updated" || !isRecord(ev.data) || !Array.isArray(ev.data.tasks))
|
|
546
544
|
return;
|
|
547
545
|
const rows = ev.data.tasks;
|
|
548
546
|
this.store.batch(() => withTaskLookups(this.store, () => {
|
|
549
547
|
for (const row of rows) {
|
|
550
|
-
if (!
|
|
548
|
+
if (!isRecord(row) || !taskId(row.task_id))
|
|
551
549
|
continue;
|
|
552
550
|
if (typeof row.parent_session_id === "string" &&
|
|
553
551
|
row.parent_session_id !== (parent.piSessionId ?? parent.restored?.piSessionId))
|
|
@@ -597,7 +595,7 @@ export class SubagentBridge {
|
|
|
597
595
|
if (!metadata || !taskId(metadata.taskID))
|
|
598
596
|
continue;
|
|
599
597
|
const id = metadata.taskID;
|
|
600
|
-
const details =
|
|
598
|
+
const details = isRecord(metadata.task) ? metadata.task : {};
|
|
601
599
|
const sessionID = this.sessionId(parent, id);
|
|
602
600
|
let child = this.children.get(sessionID);
|
|
603
601
|
if (!child && this.deleted(sessionID))
|
|
@@ -682,7 +680,7 @@ export class SubagentBridge {
|
|
|
682
680
|
if (!parent)
|
|
683
681
|
return undefined;
|
|
684
682
|
this.wire(parent);
|
|
685
|
-
const spec =
|
|
683
|
+
const spec = isRecord(found.data.spawn_spec) ? found.data.spawn_spec : {};
|
|
686
684
|
const name = found.data.name ?? found.data.description;
|
|
687
685
|
const child = this.create(parent, {
|
|
688
686
|
id: String(found.data.task_id),
|
|
@@ -831,7 +829,7 @@ export class SubagentBridge {
|
|
|
831
829
|
if (useRecord)
|
|
832
830
|
this.applyNative(child, found.data);
|
|
833
831
|
const host = found.data.host_session;
|
|
834
|
-
if (
|
|
832
|
+
if (isRecord(host) && typeof host.session_path === "string") {
|
|
835
833
|
child.livePath = host.session_path;
|
|
836
834
|
return found;
|
|
837
835
|
}
|
|
@@ -955,8 +953,8 @@ export class SubagentBridge {
|
|
|
955
953
|
}
|
|
956
954
|
fallback(child) {
|
|
957
955
|
const data = child.task.details;
|
|
958
|
-
const stats =
|
|
959
|
-
const resolved =
|
|
956
|
+
const stats = isRecord(data.run_stats) ? data.run_stats : {};
|
|
957
|
+
const resolved = isRecord(data.resolved_model) ? data.resolved_model : {};
|
|
960
958
|
const model = typeof data.model === "string"
|
|
961
959
|
? data.model
|
|
962
960
|
: `${resolved.provider ?? "unknown"}/${resolved.model_id ?? "unknown"}`;
|
package/dist/todo-bridge.d.ts
CHANGED
|
@@ -20,8 +20,6 @@ export interface TodoUpdated {
|
|
|
20
20
|
todos: Todo[];
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
/** The `senpi.todo-state` phases, keeping only well-formed phases and tasks. */
|
|
24
|
-
export declare function todoPhases(data: unknown): TodoPhase[];
|
|
25
23
|
export declare function flattenTodos(sessionID: string, data: unknown): Todo[];
|
|
26
24
|
/** Per-session snapshots; each card retains the state produced by its own call. */
|
|
27
25
|
export declare class TodoBridge {
|
package/dist/todo-bridge.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { toolMappers } from "./tool-map.js";
|
|
3
|
-
|
|
4
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5
|
-
}
|
|
3
|
+
import { isRecord } from "./guards.js";
|
|
6
4
|
function todoStatus(value) {
|
|
7
5
|
switch (value) {
|
|
8
6
|
case "in_progress":
|
|
@@ -18,14 +16,14 @@ function todoStatus(value) {
|
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
18
|
/** The `senpi.todo-state` phases, keeping only well-formed phases and tasks. */
|
|
21
|
-
|
|
22
|
-
if (!
|
|
19
|
+
function todoPhases(data) {
|
|
20
|
+
if (!isRecord(data) || !Array.isArray(data.phases))
|
|
23
21
|
return [];
|
|
24
|
-
return data.phases.filter(
|
|
22
|
+
return data.phases.filter(isRecord).flatMap((phase) => {
|
|
25
23
|
if (typeof phase.name !== "string" || !Array.isArray(phase.tasks))
|
|
26
24
|
return [];
|
|
27
25
|
const tasks = phase.tasks
|
|
28
|
-
.filter(
|
|
26
|
+
.filter(isRecord)
|
|
29
27
|
.flatMap((task) => typeof task.content === "string" ? [{ content: task.content, status: todoStatus(task.status) }] : []);
|
|
30
28
|
return [{ name: phase.name, tasks }];
|
|
31
29
|
});
|
|
@@ -57,7 +55,7 @@ export class TodoBridge {
|
|
|
57
55
|
if (part.tool !== "todowrite")
|
|
58
56
|
return;
|
|
59
57
|
part.state.input = { todos: this.todos };
|
|
60
|
-
if (!
|
|
58
|
+
if (!isRecord(args) || args.op !== "view")
|
|
61
59
|
this.awaitingState.push(part);
|
|
62
60
|
}
|
|
63
61
|
finish(part, isError) {
|
|
@@ -65,7 +63,7 @@ export class TodoBridge {
|
|
|
65
63
|
this.awaitingState = this.awaitingState.filter((candidate) => candidate !== part);
|
|
66
64
|
}
|
|
67
65
|
entry(entry, updatePart = () => { }) {
|
|
68
|
-
if (!
|
|
66
|
+
if (!isRecord(entry) || entry.type !== "custom" || entry.customType !== "senpi.todo-state")
|
|
69
67
|
return undefined;
|
|
70
68
|
this.todos = flattenTodos(this.sessionID, entry.data);
|
|
71
69
|
this.phases = todoPhases(entry.data);
|
|
@@ -78,19 +76,19 @@ export class TodoBridge {
|
|
|
78
76
|
}
|
|
79
77
|
restore(entries, parts) {
|
|
80
78
|
for (const entry of entries) {
|
|
81
|
-
if (!
|
|
79
|
+
if (!isRecord(entry))
|
|
82
80
|
continue;
|
|
83
81
|
const message = entry.message;
|
|
84
|
-
if (
|
|
82
|
+
if (isRecord(message) && message.role === "assistant" && Array.isArray(message.content)) {
|
|
85
83
|
for (const block of message.content) {
|
|
86
|
-
if (!
|
|
84
|
+
if (!isRecord(block) || block.type !== "toolCall" || typeof block.id !== "string")
|
|
87
85
|
continue;
|
|
88
86
|
const part = parts.get(block.id);
|
|
89
87
|
if (part !== undefined)
|
|
90
88
|
this.track(part, block.arguments);
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
|
-
if (
|
|
91
|
+
if (isRecord(message) && message.role === "toolResult" && typeof message.toolCallId === "string") {
|
|
94
92
|
const part = parts.get(message.toolCallId);
|
|
95
93
|
if (part !== undefined)
|
|
96
94
|
this.finish(part, message.isError === true);
|
package/dist/tool-map.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare function mapTool(omoName: string, args: unknown, result?: ToolRes
|
|
|
29
29
|
* What an eval cell started that has a session of its own. Its other calls are not shown:
|
|
30
30
|
* the cell's output already holds what it printed, and OmO records only a one-line preview.
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
interface NestedSessions {
|
|
33
33
|
/** The monitor child session for a recorded `monitor` call. */
|
|
34
34
|
monitor?: (args: Record<string, unknown>) => string | undefined;
|
|
35
35
|
/** The OpenCode shell id of a monitor child session's watch while it runs (omo-shells.ts). */
|
package/dist/tool-map.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { ocIdFor } from "./session-store.js";
|
|
2
|
-
|
|
3
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4
|
-
}
|
|
2
|
+
import { isRecord } from "./guards.js";
|
|
5
3
|
function generic(tool, input) {
|
|
6
4
|
const hint = [input.summary, input.description, input.query, input.url, input.path, input.command].find((value) => typeof value === "string" && value !== "");
|
|
7
5
|
return { tool, input, title: (hint ?? tool).slice(0, 60) };
|
|
@@ -37,7 +35,7 @@ export const toolMappers = {
|
|
|
37
35
|
if (typeof args.path !== "string" ||
|
|
38
36
|
!Array.isArray(args.edits) ||
|
|
39
37
|
args.edits.length === 0 ||
|
|
40
|
-
!args.edits.every((edit) =>
|
|
38
|
+
!args.edits.every((edit) => isRecord(edit) && typeof edit.oldText === "string" && typeof edit.newText === "string")) {
|
|
41
39
|
return generic("edit", args);
|
|
42
40
|
}
|
|
43
41
|
const edits = args.edits.map((edit) => ({
|
|
@@ -76,7 +74,7 @@ export const toolMappers = {
|
|
|
76
74
|
kill_bash: (args) => terminalTool("kill_bash", args),
|
|
77
75
|
bash_resize: (args) => terminalTool("bash_resize", args),
|
|
78
76
|
ask_user_question: (args) => {
|
|
79
|
-
if (!Array.isArray(args.questions) || !args.questions.every(
|
|
77
|
+
if (!Array.isArray(args.questions) || !args.questions.every(isRecord))
|
|
80
78
|
return generic("ask_user_question", args);
|
|
81
79
|
const questions = args.questions.map((question) => ({
|
|
82
80
|
question: question.question,
|
|
@@ -100,14 +98,14 @@ export const toolMappers = {
|
|
|
100
98
|
* details.isError instead (senpi-codemode src/tool/render-result.ts:42).
|
|
101
99
|
*/
|
|
102
100
|
export function toolFailed(result) {
|
|
103
|
-
return result.isError === true || (
|
|
101
|
+
return result.isError === true || (isRecord(result.details) && result.details.isError === true);
|
|
104
102
|
}
|
|
105
103
|
/** Text blocks only; images and structured details are not tool output text. */
|
|
106
104
|
export function resultText(content) {
|
|
107
105
|
if (!Array.isArray(content))
|
|
108
106
|
return "";
|
|
109
107
|
return content
|
|
110
|
-
.filter(
|
|
108
|
+
.filter(isRecord)
|
|
111
109
|
.filter((block) => block.type === "text" && typeof block.text === "string")
|
|
112
110
|
.map((block) => block.text)
|
|
113
111
|
.join("");
|
|
@@ -116,14 +114,14 @@ export function resultText(content) {
|
|
|
116
114
|
export function resultMetadata(tool, result) {
|
|
117
115
|
if (tool !== "edit" && tool !== "multiedit")
|
|
118
116
|
return {};
|
|
119
|
-
const details =
|
|
117
|
+
const details = isRecord(result.details) ? result.details : {};
|
|
120
118
|
return {
|
|
121
119
|
...(typeof details.patch === "string" ? { patch: details.patch } : {}),
|
|
122
120
|
...(typeof details.diff === "string" ? { diff: details.diff } : {}),
|
|
123
121
|
};
|
|
124
122
|
}
|
|
125
123
|
export function mapTool(omoName, args, result) {
|
|
126
|
-
const input =
|
|
124
|
+
const input = isRecord(args) ? args : {};
|
|
127
125
|
const handler = Object.hasOwn(toolMappers, omoName) ? toolMappers[omoName] : undefined;
|
|
128
126
|
const mapped = handler !== undefined ? handler(input, result) : generic(omoName, input);
|
|
129
127
|
if (result === undefined)
|
|
@@ -177,21 +175,21 @@ function nestedSubagent(heading, input, sessionID) {
|
|
|
177
175
|
* Monitors and `agent()` calls (recorded as `__agent__`) become subagent cards; everything else is skipped.
|
|
178
176
|
*/
|
|
179
177
|
export function nestedToolParts(parent, details, sessions = {}) {
|
|
180
|
-
if (!
|
|
178
|
+
if (!isRecord(details) || !Array.isArray(details.toolCalls))
|
|
181
179
|
return [];
|
|
182
180
|
const parts = [];
|
|
183
181
|
const start = parent.state.status === "pending" ? 0 : parent.state.time.start;
|
|
184
182
|
const claimed = new Set();
|
|
185
183
|
details.toolCalls.forEach((entry, index) => {
|
|
186
184
|
let failure;
|
|
187
|
-
if (!
|
|
185
|
+
if (!isRecord(entry) ||
|
|
188
186
|
(entry.name !== "monitor" && entry.name !== "__agent__" && entry.name !== "task") ||
|
|
189
187
|
typeof entry.ok !== "boolean" ||
|
|
190
188
|
typeof entry.durationMs !== "number" ||
|
|
191
189
|
!Number.isFinite(entry.durationMs) ||
|
|
192
190
|
entry.durationMs < 0)
|
|
193
191
|
return;
|
|
194
|
-
const args =
|
|
192
|
+
const args = isRecord(entry.args) ? entry.args : {};
|
|
195
193
|
let mapped;
|
|
196
194
|
if (entry.name === "monitor") {
|
|
197
195
|
const sessionID = entry.ok ? sessions.monitor?.(args) : undefined;
|
|
@@ -273,7 +271,7 @@ export function nestedToolParts(parent, details, sessions = {}) {
|
|
|
273
271
|
* Never execute provider content; invalid or incomplete literals are skipped.
|
|
274
272
|
*/
|
|
275
273
|
function providerRaw(value) {
|
|
276
|
-
if (
|
|
274
|
+
if (isRecord(value))
|
|
277
275
|
return value;
|
|
278
276
|
// Provider raw strings are display data, not an unbounded parser workload.
|
|
279
277
|
if (typeof value !== "string" || value.length > 1024 * 1024)
|
|
@@ -378,7 +376,7 @@ function providerRaw(value) {
|
|
|
378
376
|
return undefined;
|
|
379
377
|
}
|
|
380
378
|
}
|
|
381
|
-
return
|
|
379
|
+
return isRecord(parsed) ? parsed : undefined;
|
|
382
380
|
}
|
|
383
381
|
/** One card at each call's original block index; result blocks are not cards.
|
|
384
382
|
* Shared by RPC snapshots and history so ids and renderer state survive reloads.
|
|
@@ -387,7 +385,7 @@ export function providerToolParts(content, sessionID, messageID, timestamp) {
|
|
|
387
385
|
const parts = new Map();
|
|
388
386
|
if (!Array.isArray(content))
|
|
389
387
|
return parts;
|
|
390
|
-
const blocks = content.map((block) =>
|
|
388
|
+
const blocks = content.map((block) => isRecord(block) && block.type === "providerNative"
|
|
391
389
|
? { subtype: block.subtype, raw: providerRaw(block.raw) }
|
|
392
390
|
: undefined);
|
|
393
391
|
blocks.forEach((block, index) => {
|
|
@@ -404,13 +402,13 @@ export function providerToolParts(content, sessionID, messageID, timestamp) {
|
|
|
404
402
|
case "server_tool_use": {
|
|
405
403
|
if (typeof raw.name !== "string")
|
|
406
404
|
return;
|
|
407
|
-
input =
|
|
405
|
+
input = isRecord(raw.input) ? raw.input : {};
|
|
408
406
|
title = typeof input.query === "string" ? input.query : raw.name;
|
|
409
407
|
tool = raw.name === "web_search" ? "websearch" : raw.name;
|
|
410
408
|
break;
|
|
411
409
|
}
|
|
412
410
|
case "web_search_call": {
|
|
413
|
-
const action =
|
|
411
|
+
const action = isRecord(raw.action) ? raw.action : {};
|
|
414
412
|
const queries = Array.isArray(action.queries)
|
|
415
413
|
? action.queries.filter((q) => typeof q === "string")
|
|
416
414
|
: [];
|
|
@@ -453,15 +451,17 @@ export function applyProviderToolResults(content, parts, timestamp) {
|
|
|
453
451
|
const updated = [];
|
|
454
452
|
if (!Array.isArray(content))
|
|
455
453
|
return updated;
|
|
456
|
-
|
|
454
|
+
// Result blocks are rare: index the parts only when one appears, so history stays linear in its messages.
|
|
455
|
+
let byCallID;
|
|
457
456
|
for (const block of content) {
|
|
458
|
-
if (!
|
|
457
|
+
if (!isRecord(block) ||
|
|
459
458
|
block.type !== "providerNative" ||
|
|
460
459
|
(block.subtype !== "web_search_tool_result" && block.subtype !== "tool_search_tool_result"))
|
|
461
460
|
continue;
|
|
462
461
|
const raw = providerRaw(block.raw);
|
|
463
462
|
if (typeof raw?.tool_use_id !== "string")
|
|
464
463
|
continue;
|
|
464
|
+
byCallID ??= new Map([...parts].map((part) => [part.callID, part]));
|
|
465
465
|
const part = byCallID.get(raw.tool_use_id);
|
|
466
466
|
if (part === undefined)
|
|
467
467
|
continue;
|
|
@@ -470,18 +470,18 @@ export function applyProviderToolResults(content, parts, timestamp) {
|
|
|
470
470
|
let error;
|
|
471
471
|
if (Array.isArray(result)) {
|
|
472
472
|
output = result
|
|
473
|
-
.filter(
|
|
473
|
+
.filter(isRecord)
|
|
474
474
|
.filter((item) => typeof item.title === "string" && typeof item.url === "string")
|
|
475
475
|
.map((item) => `${item.title} - ${item.url}`)
|
|
476
476
|
.join("\n");
|
|
477
477
|
}
|
|
478
|
-
else if (
|
|
478
|
+
else if (isRecord(result)) {
|
|
479
479
|
if (typeof result.type === "string" && result.type.endsWith("_error")) {
|
|
480
480
|
error = typeof result.error_code === "string" ? result.error_code : "Server tool failed";
|
|
481
481
|
}
|
|
482
482
|
else if (Array.isArray(result.tool_references)) {
|
|
483
483
|
output = result.tool_references
|
|
484
|
-
.filter(
|
|
484
|
+
.filter(isRecord)
|
|
485
485
|
.map((item) => item.tool_name)
|
|
486
486
|
.filter((name) => typeof name === "string")
|
|
487
487
|
.join("\n");
|
package/dist/types.d.ts
CHANGED
|
@@ -109,7 +109,7 @@ export interface OCAssistantMessage {
|
|
|
109
109
|
/** Marks a compaction summary (OpenCode `AssistantMessage.summary`). */
|
|
110
110
|
summary?: boolean;
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
type OCMessage = OCUserMessage | OCAssistantMessage;
|
|
113
113
|
export interface OCTextPart {
|
|
114
114
|
id: string;
|
|
115
115
|
sessionID: string;
|
|
@@ -144,7 +144,7 @@ export interface OCToolStatePending {
|
|
|
144
144
|
input: Record<string, unknown>;
|
|
145
145
|
raw: string;
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
interface OCToolStateRunning {
|
|
148
148
|
status: "running";
|
|
149
149
|
input: Record<string, unknown>;
|
|
150
150
|
title?: string;
|
|
@@ -153,7 +153,7 @@ export interface OCToolStateRunning {
|
|
|
153
153
|
start: number;
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
-
|
|
156
|
+
interface OCToolStateCompleted {
|
|
157
157
|
status: "completed";
|
|
158
158
|
input: Record<string, unknown>;
|
|
159
159
|
output: string;
|
|
@@ -164,7 +164,7 @@ export interface OCToolStateCompleted {
|
|
|
164
164
|
end: number;
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
interface OCToolStateError {
|
|
168
168
|
status: "error";
|
|
169
169
|
input: Record<string, unknown>;
|
|
170
170
|
error: string;
|
|
@@ -174,7 +174,7 @@ export interface OCToolStateError {
|
|
|
174
174
|
end: number;
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
|
-
|
|
177
|
+
type OCToolState = OCToolStatePending | OCToolStateRunning | OCToolStateCompleted | OCToolStateError;
|
|
178
178
|
export interface OCToolPart {
|
|
179
179
|
id: string;
|
|
180
180
|
sessionID: string;
|
|
@@ -185,7 +185,7 @@ export interface OCToolPart {
|
|
|
185
185
|
state: OCToolState;
|
|
186
186
|
}
|
|
187
187
|
/** OpenChamber renders a user message holding this part as `/compact`. */
|
|
188
|
-
|
|
188
|
+
interface OCCompactionPart {
|
|
189
189
|
id: string;
|
|
190
190
|
sessionID: string;
|
|
191
191
|
messageID: string;
|
|
@@ -212,7 +212,7 @@ export type OCPromptPart = ({
|
|
|
212
212
|
}) & {
|
|
213
213
|
id?: string;
|
|
214
214
|
};
|
|
215
|
-
|
|
215
|
+
type OCInputPart = OCPromptPart & {
|
|
216
216
|
id: string;
|
|
217
217
|
sessionID: string;
|
|
218
218
|
messageID: string;
|
|
@@ -550,28 +550,4 @@ export type OCEvent = {
|
|
|
550
550
|
previous?: OCModelRef;
|
|
551
551
|
};
|
|
552
552
|
};
|
|
553
|
-
export
|
|
554
|
-
id: string;
|
|
555
|
-
worktree: string;
|
|
556
|
-
vcs?: "git";
|
|
557
|
-
time: {
|
|
558
|
-
created: number;
|
|
559
|
-
updated?: number;
|
|
560
|
-
initialized?: number;
|
|
561
|
-
};
|
|
562
|
-
sandboxes?: string[];
|
|
563
|
-
}
|
|
564
|
-
/** Incoming prompt body for POST /session/{id}/message and /prompt_async */
|
|
565
|
-
export interface OCPromptBody {
|
|
566
|
-
messageID?: string;
|
|
567
|
-
delivery?: "steer" | "queue";
|
|
568
|
-
model?: OCModelRef;
|
|
569
|
-
agent?: string;
|
|
570
|
-
noReply?: boolean;
|
|
571
|
-
system?: string;
|
|
572
|
-
parts: Array<{
|
|
573
|
-
type: string;
|
|
574
|
-
text?: string;
|
|
575
|
-
[key: string]: unknown;
|
|
576
|
-
}>;
|
|
577
|
-
}
|
|
553
|
+
export {};
|
package/dist/v2.d.ts
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* array (index-CgR5rJq_ `Zh`).
|
|
23
23
|
*/
|
|
24
24
|
import type { OCAssistantMessage, OCMessageWithParts, OCModelRef, OCSession, OCEvent } from "./types.js";
|
|
25
|
-
|
|
25
|
+
interface V2Tokens {
|
|
26
26
|
input: number;
|
|
27
27
|
output: number;
|
|
28
28
|
reasoning: number;
|
|
@@ -31,7 +31,7 @@ export interface V2Tokens {
|
|
|
31
31
|
write: number;
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
interface V2Model {
|
|
35
35
|
id: string;
|
|
36
36
|
modelID: string;
|
|
37
37
|
providerID: string;
|
|
@@ -172,11 +172,6 @@ export interface V2Message {
|
|
|
172
172
|
tokens?: V2Tokens;
|
|
173
173
|
error?: OCAssistantMessage["error"];
|
|
174
174
|
}
|
|
175
|
-
/**
|
|
176
|
-
* v2 assistant message: parts become `content` blocks. The UI rebuilds
|
|
177
|
-
* text/reasoning part ids from per-type indices into this array.
|
|
178
|
-
*/
|
|
179
|
-
export declare function toV2AssistantMessage(info: OCMessageWithParts): V2Message;
|
|
180
175
|
export declare function toV2Message(info: OCMessageWithParts): V2Message;
|
|
181
176
|
export interface V2Envelope {
|
|
182
177
|
durable?: {
|
package/dist/v2.js
CHANGED
|
@@ -151,7 +151,7 @@ function toV2UserMessage(info) {
|
|
|
151
151
|
* v2 assistant message: parts become `content` blocks. The UI rebuilds
|
|
152
152
|
* text/reasoning part ids from per-type indices into this array.
|
|
153
153
|
*/
|
|
154
|
-
|
|
154
|
+
function toV2AssistantMessage(info) {
|
|
155
155
|
const i = info.info;
|
|
156
156
|
const model = { id: i.modelID, providerID: i.providerID, variant: "default" };
|
|
157
157
|
const content = [];
|
package/dist/vcs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { devNull } from "node:os";
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
|
+
import { errorMessage } from "./guards.js";
|
|
4
5
|
const exec = promisify(execFile);
|
|
5
6
|
const GIT_EXEC_TIMEOUT_MS = 5_000;
|
|
6
7
|
const GIT_EXEC_MAX_BUFFER_BYTES = 16 * 1024 * 1024;
|
|
@@ -194,6 +195,6 @@ export async function vcsRead(directory, operation, url) {
|
|
|
194
195
|
catch (error) {
|
|
195
196
|
if (error instanceof VcsError)
|
|
196
197
|
throw error;
|
|
197
|
-
throw new VcsError(`Git VCS operation failed: ${
|
|
198
|
+
throw new VcsError(`Git VCS operation failed: ${errorMessage(error)}`);
|
|
198
199
|
}
|
|
199
200
|
}
|
package/dist/work-status.d.ts
CHANGED
|
@@ -2,12 +2,7 @@ import type { IncomingMessage, ServerResponse } from "node:http";
|
|
|
2
2
|
import type { MonitorSessions, MonitorView } from "./monitor-sessions.js";
|
|
3
3
|
import type { ManagedSession, SessionManager } from "./sessions.js";
|
|
4
4
|
import type { TodoPhase } from "./todo-bridge.js";
|
|
5
|
-
|
|
6
|
-
export declare const GOAL_TIMER_STATE_EVENT = "goal_continuation_timer_state";
|
|
7
|
-
export declare const GOAL_SCHEDULED_EVENT = "goal_continuation_scheduled";
|
|
8
|
-
export declare const GOAL_FIRE_NOW_REQUEST = "goal_continuation_fire_now";
|
|
9
|
-
export declare const CODEMODE_WAKE_SOURCE = "senpi-codemode";
|
|
10
|
-
export interface WakeSourceItem {
|
|
5
|
+
interface WakeSourceItem {
|
|
11
6
|
id: string;
|
|
12
7
|
description: string;
|
|
13
8
|
startedAtMs: number;
|
|
@@ -58,8 +53,6 @@ export declare class WorkStatusError extends Error {
|
|
|
58
53
|
readonly status: 400 | 404 | 409 | 502;
|
|
59
54
|
constructor(status: 400 | 404 | 409 | 502, message: string);
|
|
60
55
|
}
|
|
61
|
-
export declare function parseWakeSource(data: unknown): WakeSource | undefined;
|
|
62
|
-
export declare function parseEvalCell(value: unknown): EvalCellView | undefined;
|
|
63
56
|
/**
|
|
64
57
|
* Background sessions from the terminal manifest whose process is still alive. OmO writes the
|
|
65
58
|
* file on start and exit, but a crashed agent leaves its last entries behind.
|
|
@@ -96,3 +89,4 @@ export declare class WorkStatusBridge {
|
|
|
96
89
|
* OpenCode's: the OmO Work extension service authenticates with the run-record token.
|
|
97
90
|
*/
|
|
98
91
|
export declare function handleWorkStatus(sessions: Pick<SessionManager, "get" | "workStatus">, req: IncomingMessage, res: ServerResponse, url: URL, method: string): Promise<void>;
|
|
92
|
+
export {};
|