antechamber 0.0.0-stage → 0.1.1
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 +166 -0
- package/LICENSE +22 -0
- package/README.md +316 -2
- package/bin/opencode-antechamber +18 -0
- package/bin/opencode-pi +3 -0
- package/dist/agent-dir.d.ts +6 -0
- package/dist/agent-dir.js +21 -0
- package/dist/agent-name.d.ts +24 -0
- package/dist/agent-name.js +110 -0
- package/dist/approvals.d.ts +86 -0
- package/dist/approvals.js +520 -0
- package/dist/catalog.d.ts +88 -0
- package/dist/catalog.js +118 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +86 -0
- package/dist/commands/context.d.ts +26 -0
- package/dist/commands/context.js +89 -0
- package/dist/commands/doctor.d.ts +13 -0
- package/dist/commands/doctor.js +92 -0
- package/dist/commands/help.d.ts +1 -0
- package/dist/commands/help.js +15 -0
- package/dist/commands/serve.d.ts +8 -0
- package/dist/commands/serve.js +29 -0
- package/dist/commands/setup.d.ts +14 -0
- package/dist/commands/setup.js +137 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.js +40 -0
- package/dist/http.d.ts +18 -0
- package/dist/http.js +168 -0
- package/dist/lifecycle.d.ts +43 -0
- package/dist/lifecycle.js +138 -0
- package/dist/misc-routes.d.ts +8 -0
- package/dist/misc-routes.js +119 -0
- package/dist/pi-event-translation.d.ts +79 -0
- package/dist/pi-event-translation.js +643 -0
- package/dist/pi-rpc.d.ts +74 -0
- package/dist/pi-rpc.js +291 -0
- package/dist/pidfd.d.ts +2 -0
- package/dist/pidfd.js +28 -0
- package/dist/question-forms.d.ts +30 -0
- package/dist/question-forms.js +46 -0
- package/dist/route-services.d.ts +26 -0
- package/dist/route-services.js +33 -0
- package/dist/routes-v1.d.ts +4 -0
- package/dist/routes-v1.js +346 -0
- package/dist/routes-v2.d.ts +4 -0
- package/dist/routes-v2.js +477 -0
- package/dist/server.d.ts +28 -0
- package/dist/server.js +113 -0
- package/dist/session-commands.d.ts +83 -0
- package/dist/session-commands.js +332 -0
- package/dist/session-diff.d.ts +14 -0
- package/dist/session-diff.js +152 -0
- package/dist/session-history.d.ts +35 -0
- package/dist/session-history.js +421 -0
- package/dist/session-hosts.d.ts +3 -0
- package/dist/session-hosts.js +188 -0
- package/dist/session-store.d.ts +103 -0
- package/dist/session-store.js +339 -0
- package/dist/session-tree.d.ts +58 -0
- package/dist/session-tree.js +287 -0
- package/dist/sessions.d.ts +175 -0
- package/dist/sessions.js +1124 -0
- package/dist/sse.d.ts +19 -0
- package/dist/sse.js +92 -0
- package/dist/subagents.d.ts +64 -0
- package/dist/subagents.js +625 -0
- package/dist/thinking-levels.d.ts +17 -0
- package/dist/thinking-levels.js +24 -0
- package/dist/todo-bridge.d.ts +26 -0
- package/dist/todo-bridge.js +100 -0
- package/dist/tool-map.d.ts +32 -0
- package/dist/tool-map.js +349 -0
- package/dist/types.d.ts +350 -0
- package/dist/types.js +6 -0
- package/dist/v2.d.ts +190 -0
- package/dist/v2.js +560 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +13 -0
- package/extensions/omo-dag/README.md +159 -0
- package/extensions/omo-dag/docs/DESIGN.md +105 -0
- package/extensions/omo-dag/icon.svg +1 -0
- package/extensions/omo-dag/package.json +33 -0
- package/extensions/omo-dag/panel/index.html +179 -0
- package/extensions/omo-dag/panel/main.js +176 -0
- package/extensions/omo-dag/service/main.js +378 -0
- package/package.json +77 -4
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-name detection: the adapter reports one OpenCode "agent" to the UI.
|
|
3
|
+
* Resolution order (<agent dir> is piAgentDir(), ~/.omo/agent by default):
|
|
4
|
+
* 1. ANTECHAMBER_AGENT env override
|
|
5
|
+
* 2. <agent dir>/../oh-my-pi.jsonc → orchestrator.agentName
|
|
6
|
+
* 3. <agent dir>/../omo.jsonc exists (an OmO install) → "OmO"
|
|
7
|
+
* 4. <agent dir>/settings.json packages containing oh-my-pi → "oh-my-pi"
|
|
8
|
+
* 5. "build" (plain pi)
|
|
9
|
+
* The result is memoized: config changes require an adapter restart.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
12
|
+
import { homedir } from "node:os";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
14
|
+
import { envSetting } from "./config.js";
|
|
15
|
+
import { piAgentDir } from "./agent-dir.js";
|
|
16
|
+
/** Strip JSONC comments without touching string literals or joining tokens. */
|
|
17
|
+
function stripComments(text) {
|
|
18
|
+
let out = "";
|
|
19
|
+
let inString = false;
|
|
20
|
+
let escaped = false;
|
|
21
|
+
for (let i = 0; i < text.length; i++) {
|
|
22
|
+
const c = text[i];
|
|
23
|
+
if (inString) {
|
|
24
|
+
out += c;
|
|
25
|
+
if (escaped)
|
|
26
|
+
escaped = false;
|
|
27
|
+
else if (c === "\\")
|
|
28
|
+
escaped = true;
|
|
29
|
+
else if (c === '"')
|
|
30
|
+
inString = false;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (c === '"') {
|
|
34
|
+
inString = true;
|
|
35
|
+
out += c;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (c === "/" && text[i + 1] === "/") {
|
|
39
|
+
while (i < text.length && text[i] !== "\n")
|
|
40
|
+
i++;
|
|
41
|
+
out += "\n";
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (c === "/" && text[i + 1] === "*") {
|
|
45
|
+
out += " ";
|
|
46
|
+
i += 2;
|
|
47
|
+
while (i < text.length && !(text[i] === "*" && text[i + 1] === "/")) {
|
|
48
|
+
if (text[i] === "\n")
|
|
49
|
+
out += "\n";
|
|
50
|
+
i++;
|
|
51
|
+
}
|
|
52
|
+
if (i === text.length)
|
|
53
|
+
throw new SyntaxError("Unterminated JSONC block comment");
|
|
54
|
+
i++;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
out += c;
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
export function detectAgentName(env = process.env, home = homedir(), fs = {
|
|
62
|
+
existsSync,
|
|
63
|
+
readFileSync,
|
|
64
|
+
}) {
|
|
65
|
+
const fromEnv = envSetting("AGENT", env);
|
|
66
|
+
if (typeof fromEnv === "string" && fromEnv.trim() !== "")
|
|
67
|
+
return fromEnv.trim();
|
|
68
|
+
const agentDir = piAgentDir(env, home);
|
|
69
|
+
try {
|
|
70
|
+
const raw = fs.readFileSync(join(dirname(agentDir), "oh-my-pi.jsonc"), "utf8");
|
|
71
|
+
const cfg = JSON.parse(stripComments(raw));
|
|
72
|
+
const name = cfg.orchestrator?.agentName;
|
|
73
|
+
if (typeof name === "string" && name.trim() !== "")
|
|
74
|
+
return name.trim();
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// missing or unparseable config → fall through
|
|
78
|
+
}
|
|
79
|
+
if (fs.existsSync(join(dirname(agentDir), "omo.jsonc")))
|
|
80
|
+
return "OmO";
|
|
81
|
+
try {
|
|
82
|
+
const raw = fs.readFileSync(join(agentDir, "settings.json"), "utf8");
|
|
83
|
+
const settings = JSON.parse(raw);
|
|
84
|
+
if (Array.isArray(settings.packages) &&
|
|
85
|
+
settings.packages.some((p) => typeof p === "string" && p.includes("oh-my-pi"))) {
|
|
86
|
+
return "oh-my-pi";
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// missing or unparseable settings → fall through
|
|
91
|
+
}
|
|
92
|
+
return "build";
|
|
93
|
+
}
|
|
94
|
+
let cached;
|
|
95
|
+
export function getAgentName() {
|
|
96
|
+
if (cached === undefined)
|
|
97
|
+
cached = detectAgentName();
|
|
98
|
+
return cached;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Agent names the adapter publishes to OpenChamber's picker. pi has exactly one
|
|
102
|
+
* agent. The resolved pi name is published first so OpenChamber chooses it for
|
|
103
|
+
* new sessions; `build` remains a compatibility alias for existing sessions.
|
|
104
|
+
* Both names run the same pi agent — the requested agent name is not forwarded
|
|
105
|
+
* to pi. When pi's name already is `build` the list collapses to one.
|
|
106
|
+
*/
|
|
107
|
+
export function getExposedAgentNames() {
|
|
108
|
+
const piName = getAgentName();
|
|
109
|
+
return piName === "build" ? ["build"] : [piName, "build"];
|
|
110
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { PermissionRequest, PermissionV2Request, QuestionInfo, QuestionRequest, EventPermissionAsked, EventPermissionReplied, EventQuestionReplied, EventQuestionRejected } from "@opencode-ai/sdk/v2";
|
|
2
|
+
type WithoutEventID<T> = T extends {
|
|
3
|
+
id: string;
|
|
4
|
+
} ? Omit<T, "id"> : never;
|
|
5
|
+
export type ApprovalEvent = WithoutEventID<EventPermissionAsked | EventPermissionReplied | EventQuestionRejected> | {
|
|
6
|
+
type: "question.asked";
|
|
7
|
+
properties: PendingQuestion;
|
|
8
|
+
} | {
|
|
9
|
+
type: "question.replied";
|
|
10
|
+
properties: EventQuestionReplied["properties"] & {
|
|
11
|
+
comment?: string;
|
|
12
|
+
formAnswer?: Record<string, string | string[]>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export type PermissionReply = "once" | "always" | "reject";
|
|
16
|
+
export type PendingPermission = PermissionRequest;
|
|
17
|
+
export type PendingQuestion = QuestionRequest & {
|
|
18
|
+
questionIDs?: string[];
|
|
19
|
+
metadata?: Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
export type ExtensionUiResponse = Record<string, unknown>;
|
|
22
|
+
export declare class ApprovalInputError extends Error {
|
|
23
|
+
}
|
|
24
|
+
interface Context {
|
|
25
|
+
sessionID: string;
|
|
26
|
+
directory: string;
|
|
27
|
+
messageID: string;
|
|
28
|
+
send: (response: Record<string, unknown>) => void;
|
|
29
|
+
}
|
|
30
|
+
interface UIRequest {
|
|
31
|
+
id: string;
|
|
32
|
+
method: "select" | "confirm" | "input" | "editor" | "question";
|
|
33
|
+
title: string;
|
|
34
|
+
options: string[];
|
|
35
|
+
toolCallId?: string;
|
|
36
|
+
timeout?: number;
|
|
37
|
+
requestId?: string;
|
|
38
|
+
questions?: Array<QuestionInfo & {
|
|
39
|
+
id: string;
|
|
40
|
+
}>;
|
|
41
|
+
waitForAnswer?: boolean;
|
|
42
|
+
deadlineAtMs?: number;
|
|
43
|
+
draft?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
export declare function extensionUiRequestFrom(value: Record<string, unknown>): UIRequest | undefined;
|
|
46
|
+
export declare function parsePermissionTitle(title: string): {
|
|
47
|
+
permission: string;
|
|
48
|
+
patterns: string[];
|
|
49
|
+
};
|
|
50
|
+
export declare function toV2Permission(card: PermissionRequest): PermissionV2Request;
|
|
51
|
+
/** Session-scoped dialog lifecycle; RPC select replies are labels, never indices. */
|
|
52
|
+
export declare class ApprovalBridge {
|
|
53
|
+
private sessionID;
|
|
54
|
+
private send;
|
|
55
|
+
private messageID;
|
|
56
|
+
private acknowledge?;
|
|
57
|
+
private pending;
|
|
58
|
+
private questionCalls;
|
|
59
|
+
private followups;
|
|
60
|
+
private emit;
|
|
61
|
+
private settled;
|
|
62
|
+
constructor(sessionID: string, emit: (event: ApprovalEvent) => void, send: (response: ExtensionUiResponse) => void, messageID: () => string | undefined, acknowledge?: ((response: ExtensionUiResponse) => Promise<boolean>) | undefined);
|
|
63
|
+
private context;
|
|
64
|
+
handle(request: UIRequest): void;
|
|
65
|
+
noteToolStart(toolCallId: string, toolName: string, args: unknown): void;
|
|
66
|
+
noteToolEnd(toolCallId: string): void;
|
|
67
|
+
finishTurn(): void;
|
|
68
|
+
cancelAll(): void;
|
|
69
|
+
permissions(sessionID?: string, directory?: string): PermissionRequest[];
|
|
70
|
+
questionRequests(sessionID?: string, directory?: string): PendingQuestion[];
|
|
71
|
+
questions(): PendingQuestion[];
|
|
72
|
+
hasPending(sessionID: string): boolean;
|
|
73
|
+
/** Merge a snapshot only after live subscriptions have been installed. */
|
|
74
|
+
hydrate(questions: unknown): void;
|
|
75
|
+
observeQuestion(ev: Record<string, unknown>): void;
|
|
76
|
+
observe(context: Context, ev: Record<string, unknown>): void;
|
|
77
|
+
private ask;
|
|
78
|
+
replyPermission(id: string, reply: PermissionReply, message?: string, sessionID?: string): boolean;
|
|
79
|
+
replyQuestion(id: string, answers: string[][], sessionID?: string, comment?: string): boolean | Promise<boolean>;
|
|
80
|
+
rejectQuestion(id: string, sessionID?: string): boolean | Promise<boolean>;
|
|
81
|
+
private respondStructured;
|
|
82
|
+
private follow;
|
|
83
|
+
private remove;
|
|
84
|
+
clear(sessionID: string, cancel: boolean, callID?: string): void;
|
|
85
|
+
}
|
|
86
|
+
export {};
|