antechamber 0.2.3 → 0.2.5
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 +32 -0
- package/README.md +25 -10
- package/bin/opencode-antechamber +4 -6
- package/dist/cli.js +8 -0
- package/dist/commands/context.d.ts +4 -0
- package/dist/commands/context.js +19 -0
- package/dist/commands/doctor.js +8 -3
- package/dist/commands/help.d.ts +1 -1
- package/dist/commands/help.js +2 -0
- package/dist/commands/serve.js +14 -0
- package/dist/commands/setup.d.ts +1 -0
- package/dist/commands/setup.js +34 -5
- package/dist/commands/upgrade.d.ts +2 -0
- package/dist/commands/upgrade.js +7 -0
- package/dist/lifecycle.d.ts +1 -0
- package/dist/lifecycle.js +4 -0
- package/dist/mcp.d.ts +70 -0
- package/dist/mcp.js +494 -0
- package/dist/misc-routes.js +2 -3
- package/dist/monitor-sessions.d.ts +48 -0
- package/dist/monitor-sessions.js +295 -0
- package/dist/pi-event-translation.d.ts +2 -0
- package/dist/pi-event-translation.js +3 -0
- package/dist/pi-rpc.js +2 -0
- package/dist/route-services.d.ts +2 -0
- package/dist/routes-v1.js +24 -8
- package/dist/routes-v2.js +11 -5
- package/dist/self-update.d.ts +32 -0
- package/dist/self-update.js +188 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.js +2 -0
- package/dist/sessions.d.ts +6 -0
- package/dist/sessions.js +19 -1
- package/dist/types.d.ts +5 -0
- package/dist/v2.js +2 -0
- package/extensions/omo-dag/package.json +1 -1
- package/package.json +1 -1
package/dist/server.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/** HTTP/SSE composition root for the OpenCode API backed by pi. */
|
|
2
|
+
import { type SelfUpdateResult } from "./self-update.js";
|
|
2
3
|
export { isLoopbackHost, serverPassword } from "./http.js";
|
|
3
4
|
interface AdapterServerOptions {
|
|
4
5
|
port: number;
|
|
5
6
|
host: string;
|
|
6
7
|
/** Fallback directory when requests carry no ?directory= param. */
|
|
7
8
|
defaultDirectory: string;
|
|
9
|
+
/** Replaces the npm self-update behind POST /global/upgrade (tests). */
|
|
10
|
+
selfUpdate?: () => Promise<SelfUpdateResult>;
|
|
8
11
|
}
|
|
9
12
|
export declare class AdapterServer {
|
|
10
13
|
private options;
|
package/dist/server.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Http } from "./http.js";
|
|
|
8
8
|
import { SSE } from "./sse.js";
|
|
9
9
|
import { handleV1 } from "./routes-v1.js";
|
|
10
10
|
import { handleV2 } from "./routes-v2.js";
|
|
11
|
+
import { selfUpdate } from "./self-update.js";
|
|
11
12
|
export { isLoopbackHost, serverPassword } from "./http.js";
|
|
12
13
|
export class AdapterServer {
|
|
13
14
|
options;
|
|
@@ -203,6 +204,7 @@ export class AdapterServer {
|
|
|
203
204
|
body: (request) => this.http.body(request),
|
|
204
205
|
catalog: () => this.catalog(),
|
|
205
206
|
broadcast: (dir, event) => this.broadcast(dir, event),
|
|
207
|
+
selfUpdate: this.options.selfUpdate ?? (() => selfUpdate()),
|
|
206
208
|
};
|
|
207
209
|
if (path === "/api" || path.startsWith("/api/")) {
|
|
208
210
|
await handleV2(services, req, res, url, path, method, directory);
|
package/dist/sessions.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { ApprovalBridge, type PendingPermission, type PendingQuestion } from "./
|
|
|
9
9
|
import type { TodoBridge, Todo, TodoUpdated } from "./todo-bridge.js";
|
|
10
10
|
import { type SessionTreeState } from "./session-tree.js";
|
|
11
11
|
import { SubagentBridge } from "./subagents.js";
|
|
12
|
+
import { MonitorSessions } from "./monitor-sessions.js";
|
|
12
13
|
import { SessionStore, type TitleSource } from "./session-store.js";
|
|
13
14
|
import type { OCAssistantMessage, OCEvent, OCMessageWithParts, OCModelRef, OCPart, OCPromptPart, OCSession, OCSessionStatus, OCToolPart } from "./types.js";
|
|
14
15
|
export { ADAPTER_VERSION } from "./version.js";
|
|
@@ -65,6 +66,8 @@ export interface ManagedSession extends ThinkingState {
|
|
|
65
66
|
/** Hooks wired by the approvals and child-task bridges. */
|
|
66
67
|
hasPendingInteraction: () => boolean;
|
|
67
68
|
hasRunningChildren: () => boolean;
|
|
69
|
+
/** Live OmO background work (monitors) that keeps the agent process from idle eviction. */
|
|
70
|
+
hasBackgroundWork?: () => boolean;
|
|
68
71
|
}
|
|
69
72
|
type EventSink = (directory: string, event: OCEvent | TodoUpdated) => void;
|
|
70
73
|
export declare class SessionManager {
|
|
@@ -82,6 +85,7 @@ export declare class SessionManager {
|
|
|
82
85
|
private readonly store;
|
|
83
86
|
readonly lifecycle: SessionLifecycle;
|
|
84
87
|
readonly subagents: SubagentBridge;
|
|
88
|
+
readonly monitors: MonitorSessions;
|
|
85
89
|
/** directory → last scan freshness (pi dir mtime + wall clock). */
|
|
86
90
|
private scanCache;
|
|
87
91
|
/** freshness of the all-directories scan (see listAll). */
|
|
@@ -100,6 +104,8 @@ export declare class SessionManager {
|
|
|
100
104
|
private wirePi;
|
|
101
105
|
/** pi writes `<ts>_<sessionId>.jsonl` at startup — poll briefly for it. */
|
|
102
106
|
private resolvePiFile;
|
|
107
|
+
/** Sessions with a running agent in `directory`, most recently used first; never revives a dormant one. */
|
|
108
|
+
liveSessions(directory: string): ManagedSession[];
|
|
103
109
|
list(directory?: string): OCSession[];
|
|
104
110
|
/**
|
|
105
111
|
* Every restorable session on disk (all directories) plus live ones. Backs the
|
package/dist/sessions.js
CHANGED
|
@@ -16,6 +16,7 @@ import { getAgentName, getExposedAgentNames } from "./agent-name.js";
|
|
|
16
16
|
import { RequestBodyError } from "./http.js";
|
|
17
17
|
import { bindMessageEntries, durableShellTree, forkConversation, getEntries, navigate, readSessionTree, revertConversation, SessionTreeError, unrevertConversation, } from "./session-tree.js";
|
|
18
18
|
import { SubagentBridge } from "./subagents.js";
|
|
19
|
+
import { MonitorSessions } from "./monitor-sessions.js";
|
|
19
20
|
import { sessionDiff } from "./session-diff.js";
|
|
20
21
|
import { announceSessionNotice, slashTitlePrompt } from "./session-commands.js";
|
|
21
22
|
import { ocIdFor, piSessionDir, piSessionsRootMtime, scanAllPiSessions, scanPiSessions, SessionStore, readSessionTitle, } from "./session-store.js";
|
|
@@ -40,6 +41,7 @@ export class SessionManager {
|
|
|
40
41
|
store;
|
|
41
42
|
lifecycle;
|
|
42
43
|
subagents;
|
|
44
|
+
monitors;
|
|
43
45
|
/** directory → last scan freshness (pi dir mtime + wall clock). */
|
|
44
46
|
scanCache = new Map();
|
|
45
47
|
/** freshness of the all-directories scan (see listAll). */
|
|
@@ -50,9 +52,11 @@ export class SessionManager {
|
|
|
50
52
|
this.store = store ?? new SessionStore();
|
|
51
53
|
this.lifecycle = new SessionLifecycle(() => this.sessions.values(), lifecycleOptions);
|
|
52
54
|
this.subagents = new SubagentBridge(this.store, this.sessions, this.emit, (session, raw) => parsePiSessionText(session, getAgentName(), raw));
|
|
55
|
+
this.monitors = new MonitorSessions(this.sessions, this.emit);
|
|
53
56
|
this.events = new PiEventTranslator({
|
|
54
57
|
emit: this.emit,
|
|
55
58
|
subagents: this.subagents,
|
|
59
|
+
monitors: this.monitors,
|
|
56
60
|
store: this.store,
|
|
57
61
|
dirtyDiffs: this.dirtyDiffs,
|
|
58
62
|
ensureMessages: (s) => this.ensureMessages(s),
|
|
@@ -122,6 +126,7 @@ export class SessionManager {
|
|
|
122
126
|
this.sessions.set(info.id, managed);
|
|
123
127
|
published = true;
|
|
124
128
|
this.subagents.wire(managed);
|
|
129
|
+
this.monitors.wire(managed);
|
|
125
130
|
this.lifecycle.touch(managed);
|
|
126
131
|
this.wirePi(managed, pi);
|
|
127
132
|
if (options.model !== undefined)
|
|
@@ -236,6 +241,7 @@ export class SessionManager {
|
|
|
236
241
|
});
|
|
237
242
|
delete s.interruptRequested;
|
|
238
243
|
this.subagents.stopParent(s.info.id);
|
|
244
|
+
this.monitors.stopParent(s.info.id);
|
|
239
245
|
void this.lifecycle
|
|
240
246
|
.dormant(s)
|
|
241
247
|
.catch((error) => console.error("[lifecycle] exit cleanup failed:", error));
|
|
@@ -276,6 +282,14 @@ export class SessionManager {
|
|
|
276
282
|
}
|
|
277
283
|
return undefined;
|
|
278
284
|
}
|
|
285
|
+
/** Sessions with a running agent in `directory`, most recently used first; never revives a dormant one. */
|
|
286
|
+
liveSessions(directory) {
|
|
287
|
+
if (this.disposed)
|
|
288
|
+
return [];
|
|
289
|
+
return [...this.sessions.values()]
|
|
290
|
+
.filter((s) => s.pi !== undefined && s.info.directory === directory)
|
|
291
|
+
.sort((a, b) => this.lifecycle.lastUsed(b) - this.lifecycle.lastUsed(a));
|
|
292
|
+
}
|
|
279
293
|
list(directory) {
|
|
280
294
|
this.refreshNativeTitles();
|
|
281
295
|
this.subagents.restoreAll();
|
|
@@ -319,8 +333,9 @@ export class SessionManager {
|
|
|
319
333
|
this.sessions.delete(sessionId);
|
|
320
334
|
this.emit(s.info.directory, { type: "session.deleted", properties: { info: s.info } });
|
|
321
335
|
await this.lifecycle.dormant(s);
|
|
322
|
-
const piPath = this.subagents.owns(sessionId) ? undefined : (s.piPath ?? s.restored?.piPath);
|
|
336
|
+
const piPath = this.subagents.owns(sessionId) || this.monitors.owns(sessionId) ? undefined : (s.piPath ?? s.restored?.piPath);
|
|
323
337
|
this.subagents.remove(sessionId);
|
|
338
|
+
this.monitors.remove(sessionId);
|
|
324
339
|
if (piPath !== undefined) {
|
|
325
340
|
try {
|
|
326
341
|
unlinkSync(piPath);
|
|
@@ -1133,6 +1148,8 @@ export class SessionManager {
|
|
|
1133
1148
|
ensureMessages(s) {
|
|
1134
1149
|
if (this.subagents.owns(s.info.id))
|
|
1135
1150
|
return this.subagents.messages(s.info.id);
|
|
1151
|
+
if (this.monitors.owns(s.info.id))
|
|
1152
|
+
return this.monitors.messages(s.info.id);
|
|
1136
1153
|
if (s.messages === undefined) {
|
|
1137
1154
|
const admissions = s.tree.localShellTurns?.length;
|
|
1138
1155
|
s.messages = parsePiSessionFile(s, getAgentName());
|
|
@@ -1260,6 +1277,7 @@ export class SessionManager {
|
|
|
1260
1277
|
if (reg?.connectorOwned === true)
|
|
1261
1278
|
this.createdSessions.set(sc.piSessionId, sc.directory);
|
|
1262
1279
|
this.subagents.wire(managed);
|
|
1280
|
+
this.monitors.wire(managed);
|
|
1263
1281
|
return managed;
|
|
1264
1282
|
}
|
|
1265
1283
|
/** Resolve a bare session id (e.g. deep link after restart) via known directories. */
|
package/dist/types.d.ts
CHANGED
|
@@ -265,6 +265,11 @@ export type OCEvent = {
|
|
|
265
265
|
} | {
|
|
266
266
|
type: "server.connected";
|
|
267
267
|
properties: Record<string, unknown>;
|
|
268
|
+
} | {
|
|
269
|
+
type: "mcp.tools.changed";
|
|
270
|
+
properties: {
|
|
271
|
+
server: string;
|
|
272
|
+
};
|
|
268
273
|
} | {
|
|
269
274
|
type: "session.created";
|
|
270
275
|
properties: {
|
package/dist/v2.js
CHANGED