@yuandc/aica 0.1.1 → 0.1.2
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/acp/agent.js +1 -54
- package/dist/acp/client/acp-client.js +1 -102
- package/dist/acp/client/acp-content.js +1 -13
- package/dist/acp/client/acp-events.js +1 -106
- package/dist/acp/client/acp-process.js +1 -34
- package/dist/acp/client/acp-runtime-pool.js +1 -248
- package/dist/acp/client/context-usage.js +1 -29
- package/dist/acp/client/json-rpc.js +4 -128
- package/dist/acp/provider-types.js +0 -1
- package/dist/acp/providers/codex/codex-process.js +1 -51
- package/dist/acp/providers/codex/events.js +28 -1473
- package/dist/acp/providers/codex/permissions.js +1 -49
- package/dist/acp/providers/codex/provider.js +1 -376
- package/dist/acp/providers/codex-acp/adapter.js +5 -947
- package/dist/acp/providers/codex-acp/context-maintenance.js +5 -148
- package/dist/acp/providers/codex-acp/launch.js +1 -35
- package/dist/acp/providers/codex-acp/provider.js +1 -486
- package/dist/acp/providers/mimo/provider.js +5 -448
- package/dist/acp/providers/opencode/provider.js +4 -489
- package/dist/acp/providers/registry.js +1 -23
- package/dist/acp/standard-events.js +1 -167
- package/dist/commands/start.js +1 -137
- package/dist/commands/worker-auth.js +4 -100
- package/dist/commands/worker-project.js +1 -57
- package/dist/core/aca-config.js +1 -74
- package/dist/core/aca-server-client.js +1 -57
- package/dist/core/acp-event-coalescer.js +1 -108
- package/dist/core/acp-event-upload-filter.js +1 -16
- package/dist/core/acp-orphan-cleanup.js +1 -91
- package/dist/core/affected-files.js +2 -268
- package/dist/core/auth.js +1 -36
- package/dist/core/file-transfer-worker.js +1 -169
- package/dist/core/fs.js +2 -28
- package/dist/core/heartbeat.js +3 -578
- package/dist/core/job-permission-policy.js +1 -42
- package/dist/core/job-worker.js +6 -749
- package/dist/core/logger.js +3 -42
- package/dist/core/long-poll-worker.js +1 -26
- package/dist/core/machine-filesystem-worker.js +3 -352
- package/dist/core/paths.js +1 -26
- package/dist/core/process-identity.js +1 -34
- package/dist/core/process.js +2 -33
- package/dist/core/provider-health.js +1 -54
- package/dist/core/runtime-options.js +1 -38
- package/dist/core/worktree.js +1 -95
- package/dist/worker-cli.js +1 -28
- package/dist/worker-single-cli.js +1 -16
- package/package.json +1 -1
|
@@ -1,128 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
lineBuffer = "";
|
|
6
|
-
pending = new Map();
|
|
7
|
-
peerName;
|
|
8
|
-
includeJsonRpc;
|
|
9
|
-
notifications = [];
|
|
10
|
-
stdout = "";
|
|
11
|
-
stderr = "";
|
|
12
|
-
exitCode = null;
|
|
13
|
-
signal = null;
|
|
14
|
-
constructor(child, handlers = {}) {
|
|
15
|
-
this.child = child;
|
|
16
|
-
this.handlers = handlers;
|
|
17
|
-
this.peerName = handlers.peerName || "JSON-RPC peer";
|
|
18
|
-
this.includeJsonRpc = handlers.includeJsonRpc === true;
|
|
19
|
-
child.stdout.on("data", (chunk) => this.handleStdout(String(chunk)));
|
|
20
|
-
child.stderr.on("data", (chunk) => {
|
|
21
|
-
this.stderr += String(chunk);
|
|
22
|
-
});
|
|
23
|
-
child.on("close", (code, signal) => {
|
|
24
|
-
this.exitCode = code;
|
|
25
|
-
this.signal = signal;
|
|
26
|
-
for (const [id, pending] of this.pending) {
|
|
27
|
-
clearTimeout(pending.timer);
|
|
28
|
-
pending.reject(new Error(`${this.peerName} exited before ${pending.method} completed (code=${code}, signal=${signal})`));
|
|
29
|
-
this.pending.delete(id);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
child.on("error", (error) => {
|
|
33
|
-
for (const [id, pending] of this.pending) {
|
|
34
|
-
clearTimeout(pending.timer);
|
|
35
|
-
pending.reject(error);
|
|
36
|
-
this.pending.delete(id);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
request(method, params, timeoutMs = 120_000) {
|
|
41
|
-
const id = this.nextId++;
|
|
42
|
-
return new Promise((resolve, reject) => {
|
|
43
|
-
const timer = this.createRequestTimeout(id, method, timeoutMs, reject);
|
|
44
|
-
timer.unref();
|
|
45
|
-
this.pending.set(id, { method, resolve, reject, timer, timeoutMs });
|
|
46
|
-
this.write({ ...(this.includeJsonRpc ? { jsonrpc: "2.0" } : {}), id, method, ...(params === undefined ? {} : { params }) });
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
notify(method, params) {
|
|
50
|
-
this.write({ ...(this.includeJsonRpc ? { jsonrpc: "2.0" } : {}), method, ...(params === undefined ? {} : { params }) });
|
|
51
|
-
}
|
|
52
|
-
refreshPendingRequestTimeout(method) {
|
|
53
|
-
for (const [id, pending] of this.pending) {
|
|
54
|
-
if (pending.method !== method)
|
|
55
|
-
continue;
|
|
56
|
-
clearTimeout(pending.timer);
|
|
57
|
-
pending.timer = this.createRequestTimeout(id, pending.method, pending.timeoutMs, pending.reject);
|
|
58
|
-
pending.timer.unref();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
respond(id, result) {
|
|
62
|
-
this.write({ ...(this.includeJsonRpc ? { jsonrpc: "2.0" } : {}), id, result });
|
|
63
|
-
}
|
|
64
|
-
respondError(id, error) {
|
|
65
|
-
this.write({ ...(this.includeJsonRpc ? { jsonrpc: "2.0" } : {}), id, error: { code: -32603, message: error.message } });
|
|
66
|
-
}
|
|
67
|
-
createRequestTimeout(id, method, timeoutMs, reject) {
|
|
68
|
-
return setTimeout(() => {
|
|
69
|
-
this.pending.delete(id);
|
|
70
|
-
reject(new Error(`${this.peerName} request timed out while waiting for ${method}`));
|
|
71
|
-
}, timeoutMs);
|
|
72
|
-
}
|
|
73
|
-
handleStdout(chunk) {
|
|
74
|
-
this.stdout += chunk;
|
|
75
|
-
this.lineBuffer += chunk;
|
|
76
|
-
const lines = this.lineBuffer.split("\n");
|
|
77
|
-
this.lineBuffer = lines.pop() ?? "";
|
|
78
|
-
for (const line of lines) {
|
|
79
|
-
const trimmed = line.trim();
|
|
80
|
-
if (!trimmed)
|
|
81
|
-
continue;
|
|
82
|
-
let message;
|
|
83
|
-
try {
|
|
84
|
-
message = JSON.parse(trimmed);
|
|
85
|
-
}
|
|
86
|
-
catch {
|
|
87
|
-
this.stderr += `\n[non-json stdout] ${trimmed}`;
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
void this.handleMessage(message);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
async handleMessage(message) {
|
|
94
|
-
if ("id" in message && ("result" in message || "error" in message) && typeof message.method !== "string") {
|
|
95
|
-
const id = Number(message.id);
|
|
96
|
-
const pending = this.pending.get(id);
|
|
97
|
-
if (!pending)
|
|
98
|
-
return;
|
|
99
|
-
this.pending.delete(id);
|
|
100
|
-
clearTimeout(pending.timer);
|
|
101
|
-
if ("error" in message) {
|
|
102
|
-
const error = message.error;
|
|
103
|
-
pending.reject(new Error(error?.message || `${this.peerName} error ${error?.code ?? "unknown"}`));
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
pending.resolve(message.result);
|
|
107
|
-
}
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (typeof message.method !== "string")
|
|
111
|
-
return;
|
|
112
|
-
if ("id" in message) {
|
|
113
|
-
try {
|
|
114
|
-
const result = await this.handlers.onRequest?.(message.method, message.params, message);
|
|
115
|
-
this.respond(message.id, result ?? null);
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
this.respondError(message.id, error instanceof Error ? error : new Error(String(error)));
|
|
119
|
-
}
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
this.notifications.push(message);
|
|
123
|
-
await this.handlers.onNotification?.(message.method, message.params, message);
|
|
124
|
-
}
|
|
125
|
-
write(message) {
|
|
126
|
-
this.child.stdin.write(`${JSON.stringify(message)}\n`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
1
|
+
class c{child;handlers;nextId=1;lineBuffer="";pending=new Map;peerName;includeJsonRpc;notifications=[];stdout="";stderr="";exitCode=null;signal=null;constructor(e,t={}){this.child=e,this.handlers=t,this.peerName=t.peerName||"JSON-RPC peer",this.includeJsonRpc=t.includeJsonRpc===!0,e.stdout.on("data",i=>this.handleStdout(String(i))),e.stderr.on("data",i=>{this.stderr+=String(i)}),e.on("close",(i,n)=>{this.exitCode=i,this.signal=n;for(const[r,o]of this.pending)clearTimeout(o.timer),o.reject(new Error(`${this.peerName} exited before ${o.method} completed (code=${i}, signal=${n})`)),this.pending.delete(r)}),e.on("error",i=>{for(const[n,r]of this.pending)clearTimeout(r.timer),r.reject(i),this.pending.delete(n)})}request(e,t,i=12e4){const n=this.nextId++;return new Promise((r,o)=>{const s=this.createRequestTimeout(n,e,i,o);s.unref(),this.pending.set(n,{method:e,resolve:r,reject:o,timer:s,timeoutMs:i}),this.write({...this.includeJsonRpc?{jsonrpc:"2.0"}:{},id:n,method:e,...t===void 0?{}:{params:t}})})}notify(e,t){this.write({...this.includeJsonRpc?{jsonrpc:"2.0"}:{},method:e,...t===void 0?{}:{params:t}})}refreshPendingRequestTimeout(e){for(const[t,i]of this.pending)i.method===e&&(clearTimeout(i.timer),i.timer=this.createRequestTimeout(t,i.method,i.timeoutMs,i.reject),i.timer.unref())}respond(e,t){this.write({...this.includeJsonRpc?{jsonrpc:"2.0"}:{},id:e,result:t})}respondError(e,t){this.write({...this.includeJsonRpc?{jsonrpc:"2.0"}:{},id:e,error:{code:-32603,message:t.message}})}createRequestTimeout(e,t,i,n){return setTimeout(()=>{this.pending.delete(e),n(new Error(`${this.peerName} request timed out while waiting for ${t}`))},i)}handleStdout(e){this.stdout+=e,this.lineBuffer+=e;const t=this.lineBuffer.split(`
|
|
2
|
+
`);this.lineBuffer=t.pop()??"";for(const i of t){const n=i.trim();if(!n)continue;let r;try{r=JSON.parse(n)}catch{this.stderr+=`
|
|
3
|
+
[non-json stdout] ${n}`;continue}this.handleMessage(r)}}async handleMessage(e){if("id"in e&&("result"in e||"error"in e)&&typeof e.method!="string"){const t=Number(e.id),i=this.pending.get(t);if(!i)return;if(this.pending.delete(t),clearTimeout(i.timer),"error"in e){const n=e.error;i.reject(new Error(n?.message||`${this.peerName} error ${n?.code??"unknown"}`))}else i.resolve(e.result);return}if(typeof e.method=="string"){if("id"in e){try{const t=await this.handlers.onRequest?.(e.method,e.params,e);this.respond(e.id,t??null)}catch(t){this.respondError(e.id,t instanceof Error?t:new Error(String(t)))}return}this.notifications.push(e),await this.handlers.onNotification?.(e.method,e.params,e)}}write(e){this.child.stdin.write(`${JSON.stringify(e)}
|
|
4
|
+
`)}}export{c as JsonLineRpcClient};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,51 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import { acpChildEnvironment } from "../../../core/process-identity.js";
|
|
4
|
-
export function startCodexAppServer(cwd) {
|
|
5
|
-
const command = resolveCodexPath();
|
|
6
|
-
const args = ["app-server", "--stdio"];
|
|
7
|
-
const child = spawn(command, args, {
|
|
8
|
-
cwd,
|
|
9
|
-
env: acpChildEnvironment({ CODEX_PATH: command }),
|
|
10
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
11
|
-
});
|
|
12
|
-
child.stdout.setEncoding("utf8");
|
|
13
|
-
child.stderr.setEncoding("utf8");
|
|
14
|
-
return { command, args, child };
|
|
15
|
-
}
|
|
16
|
-
export function resolveCodexPath() {
|
|
17
|
-
const explicit = process.env.CODEX_PATH;
|
|
18
|
-
if (explicit?.trim() && !isNodeWrapperCodexPath(explicit))
|
|
19
|
-
return explicit;
|
|
20
|
-
const nativeCandidates = [
|
|
21
|
-
"/usr/local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex"
|
|
22
|
-
];
|
|
23
|
-
const native = nativeCandidates.find((candidate) => isExecutableFile(candidate));
|
|
24
|
-
if (native)
|
|
25
|
-
return native;
|
|
26
|
-
const fallbackCandidates = [
|
|
27
|
-
...(explicit?.trim() ? [explicit] : []),
|
|
28
|
-
"/usr/local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex",
|
|
29
|
-
"/usr/local/bin/codex",
|
|
30
|
-
"codex"
|
|
31
|
-
];
|
|
32
|
-
return fallbackCandidates.find((candidate) => candidate === "codex" || isExecutableFile(candidate)) ?? "codex";
|
|
33
|
-
}
|
|
34
|
-
function isExecutableFile(filePath) {
|
|
35
|
-
try {
|
|
36
|
-
fs.accessSync(filePath, fs.constants.X_OK);
|
|
37
|
-
return fs.statSync(filePath).isFile();
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function isNodeWrapperCodexPath(filePath) {
|
|
44
|
-
try {
|
|
45
|
-
const realPath = fs.realpathSync(filePath);
|
|
46
|
-
return realPath.endsWith(".js");
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
import{spawn as c}from"node:child_process";import r from"node:fs";import{acpChildEnvironment as a}from"../../../core/process-identity.js";function f(e){const n=d(),o=["app-server","--stdio"],t=c(n,o,{cwd:e,env:a({CODEX_PATH:n}),stdio:["pipe","pipe","pipe"]});return t.stdout.setEncoding("utf8"),t.stderr.setEncoding("utf8"),{command:n,args:o,child:t}}function d(){const e=process.env.CODEX_PATH;if(e?.trim()&&!l(e))return e;const o=["/usr/local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex"].find(i=>s(i));return o||([...e?.trim()?[e]:[],"/usr/local/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex","/usr/local/bin/codex","codex"].find(i=>i==="codex"||s(i))??"codex")}function s(e){try{return r.accessSync(e,r.constants.X_OK),r.statSync(e).isFile()}catch{return!1}}function l(e){try{return r.realpathSync(e).endsWith(".js")}catch{return!1}}export{d as resolveCodexPath,f as startCodexAppServer};
|