@botiverse/oar 0.100.0 → 0.101.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/README.md +2 -2
- package/dist/contracts/session-options.d.ts +1 -1
- package/dist/runtimes/claude/list-models.d.ts +4 -2
- package/dist/runtimes/claude/list-models.d.ts.map +1 -1
- package/dist/runtimes/claude/list-models.js +4 -2
- package/dist/runtimes/claude/list-models.js.map +1 -1
- package/dist/runtimes/codex/installation-candidates.d.ts +32 -0
- package/dist/runtimes/codex/installation-candidates.d.ts.map +1 -0
- package/dist/runtimes/codex/installation-candidates.js +107 -0
- package/dist/runtimes/codex/installation-candidates.js.map +1 -0
- package/dist/runtimes/codex/installation.d.ts +1 -30
- package/dist/runtimes/codex/installation.d.ts.map +1 -1
- package/dist/runtimes/codex/installation.js +2 -82
- package/dist/runtimes/codex/installation.js.map +1 -1
- package/dist/runtimes/cursor/access.d.ts +68 -0
- package/dist/runtimes/cursor/access.d.ts.map +1 -0
- package/dist/runtimes/cursor/access.js +77 -0
- package/dist/runtimes/cursor/access.js.map +1 -0
- package/dist/runtimes/cursor/auth-status.d.ts +4 -3
- package/dist/runtimes/cursor/auth-status.d.ts.map +1 -1
- package/dist/runtimes/cursor/auth-status.js +20 -18
- package/dist/runtimes/cursor/auth-status.js.map +1 -1
- package/dist/runtimes/cursor/index.d.ts +50 -10
- package/dist/runtimes/cursor/index.d.ts.map +1 -1
- package/dist/runtimes/cursor/index.js +40 -21
- package/dist/runtimes/cursor/index.js.map +1 -1
- package/dist/runtimes/cursor/installation.d.ts +1 -1
- package/dist/runtimes/cursor/installation.d.ts.map +1 -1
- package/dist/runtimes/cursor/installation.js +5 -2
- package/dist/runtimes/cursor/installation.js.map +1 -1
- package/dist/runtimes/cursor/list-models.d.ts +4 -2
- package/dist/runtimes/cursor/list-models.d.ts.map +1 -1
- package/dist/runtimes/cursor/list-models.js +31 -14
- package/dist/runtimes/cursor/list-models.js.map +1 -1
- package/dist/runtimes/cursor/login.d.ts +8 -3
- package/dist/runtimes/cursor/login.d.ts.map +1 -1
- package/dist/runtimes/cursor/login.js +29 -22
- package/dist/runtimes/cursor/login.js.map +1 -1
- package/dist/runtimes/cursor/logout.d.ts +3 -3
- package/dist/runtimes/cursor/logout.d.ts.map +1 -1
- package/dist/runtimes/cursor/logout.js +19 -18
- package/dist/runtimes/cursor/logout.js.map +1 -1
- package/dist/runtimes/cursor/model.d.ts +5 -0
- package/dist/runtimes/cursor/model.d.ts.map +1 -1
- package/dist/runtimes/cursor/model.js +10 -1
- package/dist/runtimes/cursor/model.js.map +1 -1
- package/dist/runtimes/cursor/sdk.d.ts +0 -4
- package/dist/runtimes/cursor/sdk.d.ts.map +1 -1
- package/dist/runtimes/cursor/sdk.js +5 -11
- package/dist/runtimes/cursor/sdk.js.map +1 -1
- package/dist/runtimes/cursor/session-process.d.ts +31 -0
- package/dist/runtimes/cursor/session-process.d.ts.map +1 -0
- package/dist/runtimes/cursor/session-process.js +80 -0
- package/dist/runtimes/cursor/session-process.js.map +1 -0
- package/dist/runtimes/cursor/session.d.ts +2 -2
- package/dist/runtimes/cursor/session.d.ts.map +1 -1
- package/dist/runtimes/cursor/session.js +10 -10
- package/dist/runtimes/cursor/session.js.map +1 -1
- package/dist/runtimes/cursor/subprocess/channel.d.ts +37 -0
- package/dist/runtimes/cursor/subprocess/channel.d.ts.map +1 -0
- package/dist/runtimes/cursor/subprocess/channel.js +170 -0
- package/dist/runtimes/cursor/subprocess/channel.js.map +1 -0
- package/dist/runtimes/cursor/subprocess/child-script.d.ts +12 -0
- package/dist/runtimes/cursor/subprocess/child-script.d.ts.map +1 -0
- package/dist/runtimes/cursor/subprocess/child-script.js +257 -0
- package/dist/runtimes/cursor/subprocess/child-script.js.map +1 -0
- package/dist/runtimes/cursor/subprocess/proxy.d.ts +11 -0
- package/dist/runtimes/cursor/subprocess/proxy.d.ts.map +1 -0
- package/dist/runtimes/cursor/subprocess/proxy.js +242 -0
- package/dist/runtimes/cursor/subprocess/proxy.js.map +1 -0
- package/dist/shared/executable/environment-marker.d.ts +21 -0
- package/dist/shared/executable/environment-marker.d.ts.map +1 -0
- package/dist/shared/executable/environment-marker.js +137 -0
- package/dist/shared/executable/environment-marker.js.map +1 -0
- package/dist/shared/executable/node-script.d.ts +53 -0
- package/dist/shared/executable/node-script.d.ts.map +1 -0
- package/dist/shared/executable/node-script.js +131 -0
- package/dist/shared/executable/node-script.js.map +1 -0
- package/package.json +5 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { asRecord, asRecordList } from "../../../shared/json.js";
|
|
2
|
+
function isModelSelection(value) {
|
|
3
|
+
return typeof asRecord(value)?.id === "string";
|
|
4
|
+
}
|
|
5
|
+
function isModelList(value) {
|
|
6
|
+
return Array.isArray(value) && asRecordList(value).length === value.length
|
|
7
|
+
&& asRecordList(value).every((model) => typeof model.id === "string" && typeof model.displayName === "string");
|
|
8
|
+
}
|
|
9
|
+
function isListRunsPage(value) {
|
|
10
|
+
const page = asRecord(value);
|
|
11
|
+
return page !== null && Array.isArray(page.items) && (page.nextCursor === undefined || typeof page.nextCursor === "string");
|
|
12
|
+
}
|
|
13
|
+
function isAuthStatus(value) {
|
|
14
|
+
const status = asRecord(value)?.status;
|
|
15
|
+
return status === "logged-in" || status === "logged-out";
|
|
16
|
+
}
|
|
17
|
+
function isSteerAck(value) {
|
|
18
|
+
return value === "complete_delivered" || value === "revert_to_followup";
|
|
19
|
+
}
|
|
20
|
+
function unexpected(call) {
|
|
21
|
+
return new Error(`cursor's child process answered ${call} with a shape oar cannot read`);
|
|
22
|
+
}
|
|
23
|
+
/** The run a `send` or `summarize` call made, as the child described it. */
|
|
24
|
+
function proxyRun(channel, key, value) {
|
|
25
|
+
const described = asRecord(value);
|
|
26
|
+
if (typeof described?.runId !== "string") {
|
|
27
|
+
throw unexpected("a send");
|
|
28
|
+
}
|
|
29
|
+
const runId = described.runId;
|
|
30
|
+
const run = {
|
|
31
|
+
id: runId,
|
|
32
|
+
stream: () => proxyStream(channel, key),
|
|
33
|
+
wait: async () => { const result = await channel.call("wait", [key]); return result; },
|
|
34
|
+
cancel: async () => { await channel.call("cancel", [key]); },
|
|
35
|
+
};
|
|
36
|
+
if (described.steer !== true) {
|
|
37
|
+
return run;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...run,
|
|
41
|
+
async steer(text) {
|
|
42
|
+
const ack = await channel.call("steer", [key, text]);
|
|
43
|
+
if (!isSteerAck(ack)) {
|
|
44
|
+
throw unexpected("a steer");
|
|
45
|
+
}
|
|
46
|
+
return ack;
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** The run's `stream()`: the child reads it and forwards each message; `return()` stops the child's reading. */
|
|
51
|
+
function proxyStream(channel, key) {
|
|
52
|
+
return {
|
|
53
|
+
[Symbol.asyncIterator]: () => {
|
|
54
|
+
const queue = [];
|
|
55
|
+
let wake = Promise.withResolvers();
|
|
56
|
+
const state = { ended: false, error: null };
|
|
57
|
+
const streaming = channel.start("stream", [key], (message) => { queue.push(message); wake.resolve(); });
|
|
58
|
+
void (async () => {
|
|
59
|
+
try {
|
|
60
|
+
await streaming.reply;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
state.error = error instanceof Error ? error : new Error(String(error));
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
state.ended = true;
|
|
67
|
+
wake.resolve();
|
|
68
|
+
}
|
|
69
|
+
})();
|
|
70
|
+
return {
|
|
71
|
+
async next() {
|
|
72
|
+
for (;;) {
|
|
73
|
+
if (queue.length > 0) {
|
|
74
|
+
return { done: false, value: queue.shift() };
|
|
75
|
+
}
|
|
76
|
+
if (state.ended) {
|
|
77
|
+
if (state.error !== null) {
|
|
78
|
+
throw state.error;
|
|
79
|
+
}
|
|
80
|
+
return { done: true, value: undefined };
|
|
81
|
+
}
|
|
82
|
+
await wake.promise;
|
|
83
|
+
wake = Promise.withResolvers();
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
async return() {
|
|
87
|
+
queue.length = 0;
|
|
88
|
+
// Not waiting for the child's reading to end: an SDK stream can queue return() behind its pending next() (run.ts).
|
|
89
|
+
if (!state.ended) {
|
|
90
|
+
try {
|
|
91
|
+
await channel.call("unstream", [streaming.id]);
|
|
92
|
+
}
|
|
93
|
+
catch { /* The child may be gone; nothing more arrives then. */ }
|
|
94
|
+
}
|
|
95
|
+
return { done: true, value: undefined };
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async function proxyAgent(channel, opening) {
|
|
102
|
+
const key = opening.id;
|
|
103
|
+
const value = await opening.reply;
|
|
104
|
+
const described = asRecord(value);
|
|
105
|
+
if (typeof described?.agentId !== "string") {
|
|
106
|
+
throw unexpected("an open");
|
|
107
|
+
}
|
|
108
|
+
const model = isModelSelection(described.model) ? described.model : undefined;
|
|
109
|
+
const launch = async (method, args, onDelta) => {
|
|
110
|
+
const started = channel.start(method, [key, ...args], onDelta === undefined ? undefined : (update) => { onDelta({ update }); });
|
|
111
|
+
return proxyRun(channel, started.id, await started.reply);
|
|
112
|
+
};
|
|
113
|
+
const agent = {
|
|
114
|
+
agentId: described.agentId,
|
|
115
|
+
model,
|
|
116
|
+
send: async (message, options) => {
|
|
117
|
+
const run = await launch("send", [message, options.local], options.onDelta);
|
|
118
|
+
return run;
|
|
119
|
+
},
|
|
120
|
+
close() {
|
|
121
|
+
void (async () => {
|
|
122
|
+
try {
|
|
123
|
+
await channel.call("close", [key]);
|
|
124
|
+
}
|
|
125
|
+
catch { /* The child ending closes the agent with it. */ }
|
|
126
|
+
})();
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
if (described.summarize !== true) {
|
|
130
|
+
return agent;
|
|
131
|
+
}
|
|
132
|
+
return { ...agent, summarize: async () => { const run = await launch("summarize", []); return run; } };
|
|
133
|
+
}
|
|
134
|
+
/** `Cursor.auth` over the child: the login's save is decided here, and done there. */
|
|
135
|
+
function proxyAuth(channel) {
|
|
136
|
+
const auth = {
|
|
137
|
+
async login(options) {
|
|
138
|
+
const stop = () => {
|
|
139
|
+
void (async () => {
|
|
140
|
+
try {
|
|
141
|
+
await channel.call("abortLogin", []);
|
|
142
|
+
}
|
|
143
|
+
catch { /* The child may be gone. */ }
|
|
144
|
+
})();
|
|
145
|
+
};
|
|
146
|
+
options.signal.addEventListener("abort", stop, { once: true });
|
|
147
|
+
try {
|
|
148
|
+
await channel.call("login", [], (event) => {
|
|
149
|
+
const step = asRecord(event);
|
|
150
|
+
if (typeof step?.url === "string") {
|
|
151
|
+
options.onLoginUrl(step.url);
|
|
152
|
+
}
|
|
153
|
+
if (step?.save === true) {
|
|
154
|
+
void decideSave(channel, options);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
finally {
|
|
159
|
+
options.signal.removeEventListener("abort", stop);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
async status() {
|
|
163
|
+
const status = await channel.call("status", []);
|
|
164
|
+
if (!isAuthStatus(status)) {
|
|
165
|
+
throw unexpected("Cursor.auth.status");
|
|
166
|
+
}
|
|
167
|
+
return status;
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
if (!channel.features.logout) {
|
|
171
|
+
return auth;
|
|
172
|
+
}
|
|
173
|
+
return { ...auth, logout: async () => { await channel.call("logout", []); } };
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The SDK in the child asked to save its key. The host's login store decides
|
|
177
|
+
* (login.ts): it refuses once OAR ended the login, or passes the save on to
|
|
178
|
+
* `FileCredentialStore.save`, which here tells the child to save to its own
|
|
179
|
+
* store (`commit`). The child is then told how it went.
|
|
180
|
+
*/
|
|
181
|
+
async function decideSave(channel, options) {
|
|
182
|
+
try {
|
|
183
|
+
// A placeholder: the credentials stay in the child.
|
|
184
|
+
await options.store.save({});
|
|
185
|
+
await channel.call("saved", []);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
try {
|
|
189
|
+
await channel.call("refused", [error instanceof Error ? error.message : String(error)]);
|
|
190
|
+
}
|
|
191
|
+
catch { /* The child is gone. */ }
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* `CursorSdk` over one cursor child. `apiKey` is the `CURSOR_API_KEY` the
|
|
196
|
+
* lease took out of the child's environment: it goes to the SDK as
|
|
197
|
+
* `AgentOptions.apiKey` (create, resume) and `CursorRequestOptions.apiKey`
|
|
198
|
+
* (`Cursor.models.list`), which SDK 1.3.1 uses instead of the variable.
|
|
199
|
+
* Local `Agent.listRuns` reads the local store and takes none.
|
|
200
|
+
*/
|
|
201
|
+
export function proxySdk(channel, apiKey) {
|
|
202
|
+
const keyed = (options) => (apiKey === undefined ? options : { ...options, apiKey });
|
|
203
|
+
const open = async (method, args) => {
|
|
204
|
+
const agent = await proxyAgent(channel, channel.start(method, args));
|
|
205
|
+
return agent;
|
|
206
|
+
};
|
|
207
|
+
const { features } = channel;
|
|
208
|
+
return {
|
|
209
|
+
Agent: {
|
|
210
|
+
create: async (options) => { const agent = await open("create", [keyed(options)]); return agent; },
|
|
211
|
+
resume: async (agentId, options) => { const agent = await open("resume", [agentId, keyed(options)]); return agent; },
|
|
212
|
+
async listRuns(agentId, options) {
|
|
213
|
+
const page = await channel.call("listRuns", [agentId, options]);
|
|
214
|
+
if (!isListRunsPage(page)) {
|
|
215
|
+
throw unexpected("Agent.listRuns");
|
|
216
|
+
}
|
|
217
|
+
return page;
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
Cursor: {
|
|
221
|
+
models: {
|
|
222
|
+
async list() {
|
|
223
|
+
const models = await channel.call("models", apiKey === undefined ? [] : [{ apiKey }]);
|
|
224
|
+
if (!isModelList(models)) {
|
|
225
|
+
throw unexpected("Cursor.models.list");
|
|
226
|
+
}
|
|
227
|
+
return models;
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
...(features.auth ? { auth: proxyAuth(channel) } : {}),
|
|
231
|
+
},
|
|
232
|
+
...(features.store ? {
|
|
233
|
+
FileCredentialStore: class {
|
|
234
|
+
// The argument is the login store's placeholder; the child saves what its SDK gave it.
|
|
235
|
+
async save() {
|
|
236
|
+
await channel.call("commit", []);
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
} : {}),
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sources":["../../../../src/runtimes/cursor/subprocess/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAwBjE,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,OAAO,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,QAAQ,CAAC;AACjD,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;WACrE,YAAY,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC;AACnH,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC;AAC9H,CAAC;AAED,SAAS,YAAY,CAAC,KAA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,MAAM,EAAE;gBACN,KAAK,CAAC,IAAI;oBACR,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;oBACtF,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;wBAAC,MAAM,UAAU,CAAC,oBAAoB,CAAC,CAAC;oBAAC,CAAC;oBACrE,OAAO,MAAM,CAAC;gBAChB,CAAC;aACF;YACD,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvD;QACD,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;YACnB,mBAAmB,EAAE;gBACnB,uFAAuF;gBACvF,KAAK,CAAC,IAAI;oBACR,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;gBACnC,CAAC;aACF;SACF,CAAC,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** A fresh marker: `NAME=1`, the name unique to one child. Not a secret. */
|
|
2
|
+
export declare function newEnvironmentMarker(): {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly entry: string;
|
|
5
|
+
};
|
|
6
|
+
/** The pids of this user's processes, other than this one, started with `entry` (`NAME=value`) in their environment. Linux only; empty elsewhere. */
|
|
7
|
+
export declare function markedProcesses(entry: string): number[];
|
|
8
|
+
/** SIGKILL every process `markedProcesses(entry)` finds, pass after pass until one finds none (at most five). Synchronous, so an `exit` hook can call it. */
|
|
9
|
+
export declare function killMarked(entry: string): void;
|
|
10
|
+
/** The same without blocking the event loop: `/proc` is read asynchronously. */
|
|
11
|
+
export declare function markedProcessesAsync(entry: string): Promise<number[]>;
|
|
12
|
+
/** `killMarked` without blocking the event loop. */
|
|
13
|
+
export declare function killMarkedAsync(entry: string): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Keep `entry` scanned for while its child may run: a host that calls
|
|
16
|
+
* `process.exit` ends the marked processes from its `exit` hook too.
|
|
17
|
+
* Returns the release, for once the child exited and its marked processes
|
|
18
|
+
* were ended.
|
|
19
|
+
*/
|
|
20
|
+
export declare function trackEnvironmentMarker(entry: string): () => void;
|
|
21
|
+
//# sourceMappingURL=environment-marker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-marker.d.ts","sources":["../../../src/shared/executable/environment-marker.ts"],"names":[],"mappings":"AAiBA,4EAA4E;AAC5E,wBAAgB,oBAAoB,IAAI;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAGxF;AAED,qJAAqJ;AACrJ,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBvD;AAcD,6JAA6J;AAC7J,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAM9C;AAED,gFAAgF;AAChF,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAkB3E;AAED,oDAAoD;AACpD,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOlE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,IAAI,CAShE"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
3
|
+
import { readdir, readFile, stat } from "node:fs/promises";
|
|
4
|
+
/*
|
|
5
|
+
* An environment marker: a variable a child is started with, which every
|
|
6
|
+
* process it starts inherits unless that process clears its environment.
|
|
7
|
+
* After the child is gone, the processes still carrying it are the ones it
|
|
8
|
+
* started, even those reparented away from it (a shell's `cmd &` or `nohup`
|
|
9
|
+
* job, once the shell exited) and outside its process group, which a
|
|
10
|
+
* parent-pid walk or a group kill cannot find. This is the approach of
|
|
11
|
+
* Jenkins' ProcessTreeKiller. Linux only: it reads `/proc/<pid>/environ`,
|
|
12
|
+
* which holds a process's environment as it was started; elsewhere there is
|
|
13
|
+
* no portable way to read another process's environment, and nothing is
|
|
14
|
+
* scanned.
|
|
15
|
+
*/
|
|
16
|
+
/** A fresh marker: `NAME=1`, the name unique to one child. Not a secret. */
|
|
17
|
+
export function newEnvironmentMarker() {
|
|
18
|
+
const name = `OAR_CURSOR_CHILD_${randomUUID().replaceAll("-", "")}`;
|
|
19
|
+
return { name, entry: `${name}=1` };
|
|
20
|
+
}
|
|
21
|
+
/** The pids of this user's processes, other than this one, started with `entry` (`NAME=value`) in their environment. Linux only; empty elsewhere. */
|
|
22
|
+
export function markedProcesses(entry) {
|
|
23
|
+
if (process.platform !== "linux") {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
const uid = process.getuid?.();
|
|
27
|
+
const found = [];
|
|
28
|
+
let names = [];
|
|
29
|
+
try {
|
|
30
|
+
names = readdirSync("/proc");
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return found;
|
|
34
|
+
}
|
|
35
|
+
for (const name of names) {
|
|
36
|
+
const pid = Number(name);
|
|
37
|
+
if (!/^\d+$/u.test(name) || pid === process.pid) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
if (statSync(`/proc/${name}`).uid !== uid) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (readFileSync(`/proc/${name}/environ`, "latin1").split("\0").includes(entry)) {
|
|
45
|
+
found.push(pid);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Gone meanwhile, or not readable: not ours to end.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return found;
|
|
53
|
+
}
|
|
54
|
+
const live = new Set();
|
|
55
|
+
let exitHookInstalled = false;
|
|
56
|
+
/** Scan passes at most: a marked process may fork between a pass's read and its kill, so a pass that found some is followed by another. */
|
|
57
|
+
const PASSES = 5;
|
|
58
|
+
function kill(pids) {
|
|
59
|
+
for (const pid of pids) {
|
|
60
|
+
try {
|
|
61
|
+
process.kill(pid, "SIGKILL");
|
|
62
|
+
}
|
|
63
|
+
catch { /* Gone meanwhile. */ }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** SIGKILL every process `markedProcesses(entry)` finds, pass after pass until one finds none (at most five). Synchronous, so an `exit` hook can call it. */
|
|
67
|
+
export function killMarked(entry) {
|
|
68
|
+
for (let pass = 0; pass < PASSES; pass += 1) {
|
|
69
|
+
const found = markedProcesses(entry);
|
|
70
|
+
if (found.length === 0) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
kill(found);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** The same without blocking the event loop: `/proc` is read asynchronously. */
|
|
77
|
+
export async function markedProcessesAsync(entry) {
|
|
78
|
+
if (process.platform !== "linux") {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
const uid = process.getuid?.();
|
|
82
|
+
let names = [];
|
|
83
|
+
try {
|
|
84
|
+
names = await readdir("/proc");
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
const checked = await Promise.all(names.map(async (name) => {
|
|
90
|
+
const pid = Number(name);
|
|
91
|
+
if (!/^\d+$/u.test(name) || pid === process.pid) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const owner = await stat(`/proc/${name}`);
|
|
96
|
+
if (owner.uid !== uid) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
const environment = await readFile(`/proc/${name}/environ`, "latin1");
|
|
100
|
+
return environment.split("\0").includes(entry) ? pid : null;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
106
|
+
return checked.filter((pid) => pid !== null);
|
|
107
|
+
}
|
|
108
|
+
/** `killMarked` without blocking the event loop. */
|
|
109
|
+
export async function killMarkedAsync(entry) {
|
|
110
|
+
for (let pass = 0; pass < PASSES; pass += 1) {
|
|
111
|
+
// oxlint-disable-next-line eslint/no-await-in-loop -- each pass reads the table after the previous pass's kills.
|
|
112
|
+
const found = await markedProcessesAsync(entry);
|
|
113
|
+
if (found.length === 0) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
kill(found);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Keep `entry` scanned for while its child may run: a host that calls
|
|
121
|
+
* `process.exit` ends the marked processes from its `exit` hook too.
|
|
122
|
+
* Returns the release, for once the child exited and its marked processes
|
|
123
|
+
* were ended.
|
|
124
|
+
*/
|
|
125
|
+
export function trackEnvironmentMarker(entry) {
|
|
126
|
+
live.add(entry);
|
|
127
|
+
if (!exitHookInstalled) {
|
|
128
|
+
exitHookInstalled = true;
|
|
129
|
+
process.once("exit", () => {
|
|
130
|
+
for (const marker of live) {
|
|
131
|
+
killMarked(marker);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return () => { live.delete(entry); };
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=environment-marker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-marker.js","sources":["../../../src/shared/executable/environment-marker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM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,CAAC,EAAE,CAAC;YAAC,OAAO;QAAC,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,iBAAiB,GAAG,IAAI,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;YACxB,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE,CAAC;gBAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** How a Node script child ended, with the last 8 KiB of its stderr. */
|
|
2
|
+
export interface NodeScriptExit {
|
|
3
|
+
readonly code: number | null;
|
|
4
|
+
readonly signal: NodeJS.Signals | null;
|
|
5
|
+
readonly stderr: string;
|
|
6
|
+
}
|
|
7
|
+
/** A Node child running a script given on its command line, talking over Node IPC. */
|
|
8
|
+
export interface NodeScriptChild {
|
|
9
|
+
readonly pid: number | undefined;
|
|
10
|
+
/** False once the channel is gone; a message sent then is dropped, and the exit is what gets recorded. */
|
|
11
|
+
send(message: object): boolean;
|
|
12
|
+
onMessage(listener: (message: unknown) => void): void;
|
|
13
|
+
/** Settles once the child exited (or could not be spawned) and the descendants seen before a stop were ended. */
|
|
14
|
+
readonly exited: Promise<NodeScriptExit>;
|
|
15
|
+
/**
|
|
16
|
+
* Stop the child and the descendants found below it. First the process table is
|
|
17
|
+
* read and the child's descendants remembered (by parent pid, so also
|
|
18
|
+
* tools that lead process groups of their own). Then `ask` lets the child
|
|
19
|
+
* stop itself, if given; after the grace period (`killGraceMs()`), or at
|
|
20
|
+
* once without `ask`, SIGTERM to its process group, SIGKILL to the group
|
|
21
|
+
* and the remembered descendants after another grace period (POSIX);
|
|
22
|
+
* `taskkill /T /F` on its tree (Windows). Once the child exited, the
|
|
23
|
+
* remembered descendants still running are sent SIGKILL
|
|
24
|
+
* (process-shutdown.ts, `killTree`). `captureTree: false` skips the read,
|
|
25
|
+
* for a child that starts nothing. Idempotent; settles with the exit.
|
|
26
|
+
*/
|
|
27
|
+
stop(ask?: () => void, captureTree?: boolean): Promise<NodeScriptExit>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Run `script` with this host's own Node (`process.execPath -e script
|
|
31
|
+
* argument`), stdin ignored, stdout and stderr piped (stdout is drained
|
|
32
|
+
* unread, stderr kept as a tail), and a Node IPC channel with `advanced`
|
|
33
|
+
* serialization. The child is spawned detached on every platform. On POSIX
|
|
34
|
+
* it leads its own process group. On Windows Node otherwise puts it in a job
|
|
35
|
+
* object that ends it together with a dying host, before it can end its own
|
|
36
|
+
* tree; the cost is that a detached Windows child has no console, so a
|
|
37
|
+
* console program it starts without `windowsHide` may open a visible window
|
|
38
|
+
* (process-signals.ts). The script itself must end its tree when its IPC
|
|
39
|
+
* channel disconnects (the host died, SIGKILL included): nothing in the host
|
|
40
|
+
* can then. It is tracked with `trackOwnedProcess`, so a host that calls
|
|
41
|
+
* `process.exit` still ends it and its descendants. On any exit the child's
|
|
42
|
+
* process group is sent SIGKILL (POSIX), which reaches what is left of it.
|
|
43
|
+
* With `marker` (an `environment-marker.ts` entry the caller put in `env`),
|
|
44
|
+
* every process of this user still carrying it is sent SIGKILL once the
|
|
45
|
+
* child exited, for whatever reason (an asynchronous `/proc` scan, repeated
|
|
46
|
+
* until a pass finds none, at most five), and from the host's own `exit`
|
|
47
|
+
* hook (Linux only). The
|
|
48
|
+
* caller sets the environment, including `ELECTRON_RUN_AS_NODE=1` when
|
|
49
|
+
* `process.execPath` may be Electron. Throws in a compiled single executable
|
|
50
|
+
* host (node-eval.ts), which cannot run one.
|
|
51
|
+
*/
|
|
52
|
+
export declare function spawnNodeScript(script: string, argument: string, env: NodeJS.ProcessEnv, marker?: string): NodeScriptChild;
|
|
53
|
+
//# sourceMappingURL=node-script.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-script.d.ts","sources":["../../../src/shared/executable/node-script.ts"],"names":[],"mappings":"AAQA,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,sFAAsF;AACtF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,0GAA0G;IAC1G,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,SAAS,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAAC;IACtD,iHAAiH;IACjH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACzC;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACxE;AAKD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,CAoF1H"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { nodeEvalExecutable } from "./node-eval.js";
|
|
3
|
+
import { StderrTail } from "./diagnostics.js";
|
|
4
|
+
import { killMarkedAsync, trackEnvironmentMarker } from "./environment-marker.js";
|
|
5
|
+
import { trackOwnedProcess } from "./ownership.js";
|
|
6
|
+
import { processShutdown } from "./process-shutdown.js";
|
|
7
|
+
import { killGraceMs, OWN_PROCESS_GROUP, signalProcessGroup } from "./process-signals.js";
|
|
8
|
+
/** How long the exit waits for stderr to drain after the process itself ended. */
|
|
9
|
+
const STDERR_DRAIN_MS = 250;
|
|
10
|
+
/**
|
|
11
|
+
* Run `script` with this host's own Node (`process.execPath -e script
|
|
12
|
+
* argument`), stdin ignored, stdout and stderr piped (stdout is drained
|
|
13
|
+
* unread, stderr kept as a tail), and a Node IPC channel with `advanced`
|
|
14
|
+
* serialization. The child is spawned detached on every platform. On POSIX
|
|
15
|
+
* it leads its own process group. On Windows Node otherwise puts it in a job
|
|
16
|
+
* object that ends it together with a dying host, before it can end its own
|
|
17
|
+
* tree; the cost is that a detached Windows child has no console, so a
|
|
18
|
+
* console program it starts without `windowsHide` may open a visible window
|
|
19
|
+
* (process-signals.ts). The script itself must end its tree when its IPC
|
|
20
|
+
* channel disconnects (the host died, SIGKILL included): nothing in the host
|
|
21
|
+
* can then. It is tracked with `trackOwnedProcess`, so a host that calls
|
|
22
|
+
* `process.exit` still ends it and its descendants. On any exit the child's
|
|
23
|
+
* process group is sent SIGKILL (POSIX), which reaches what is left of it.
|
|
24
|
+
* With `marker` (an `environment-marker.ts` entry the caller put in `env`),
|
|
25
|
+
* every process of this user still carrying it is sent SIGKILL once the
|
|
26
|
+
* child exited, for whatever reason (an asynchronous `/proc` scan, repeated
|
|
27
|
+
* until a pass finds none, at most five), and from the host's own `exit`
|
|
28
|
+
* hook (Linux only). The
|
|
29
|
+
* caller sets the environment, including `ELECTRON_RUN_AS_NODE=1` when
|
|
30
|
+
* `process.execPath` may be Electron. Throws in a compiled single executable
|
|
31
|
+
* host (node-eval.ts), which cannot run one.
|
|
32
|
+
*/
|
|
33
|
+
export function spawnNodeScript(script, argument, env, marker) {
|
|
34
|
+
const node = nodeEvalExecutable();
|
|
35
|
+
if (node === null) {
|
|
36
|
+
throw new Error("this host is a compiled single executable (Node SEA or Bun standalone): its executable would start the application again instead of a Node script, so it cannot run a Node script child");
|
|
37
|
+
}
|
|
38
|
+
const child = spawn(node, ["-e", script, argument], {
|
|
39
|
+
env,
|
|
40
|
+
stdio: ["ignore", "pipe", "pipe", "ipc"],
|
|
41
|
+
serialization: "advanced",
|
|
42
|
+
detached: true,
|
|
43
|
+
windowsHide: true,
|
|
44
|
+
});
|
|
45
|
+
trackOwnedProcess(child);
|
|
46
|
+
const releaseMarker = marker === undefined ? null : trackEnvironmentMarker(marker);
|
|
47
|
+
const shutdown = processShutdown(child, { killTree: true });
|
|
48
|
+
const stderr = new StderrTail();
|
|
49
|
+
const stderrClosed = Promise.withResolvers();
|
|
50
|
+
child.stdout?.resume();
|
|
51
|
+
// As for line processes, `OAR_CHILD_STDERR=inherit` also forwards it to the host's stderr.
|
|
52
|
+
const inherit = process.env.OAR_CHILD_STDERR === "inherit";
|
|
53
|
+
child.stderr?.on("data", (chunk) => {
|
|
54
|
+
stderr.append(chunk);
|
|
55
|
+
if (inherit) {
|
|
56
|
+
process.stderr.write(chunk);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
child.stderr?.once("close", () => { stderrClosed.resolve(); });
|
|
60
|
+
if (child.stderr === null) {
|
|
61
|
+
stderrClosed.resolve();
|
|
62
|
+
}
|
|
63
|
+
const ended = Promise.withResolvers();
|
|
64
|
+
let backstop = undefined;
|
|
65
|
+
child.once("exit", (code, signal) => {
|
|
66
|
+
clearTimeout(backstop);
|
|
67
|
+
// What it started may still be in its group (POSIX); the group is ours to end.
|
|
68
|
+
if (OWN_PROCESS_GROUP && child.pid !== undefined) {
|
|
69
|
+
signalProcessGroup(child, "SIGKILL");
|
|
70
|
+
}
|
|
71
|
+
ended.resolve({ code, signal });
|
|
72
|
+
shutdown.nativeExited();
|
|
73
|
+
});
|
|
74
|
+
child.on("error", (error) => {
|
|
75
|
+
if (child.pid === undefined) {
|
|
76
|
+
stderr.append(error.message);
|
|
77
|
+
stderrClosed.resolve();
|
|
78
|
+
ended.resolve({ code: null, signal: null });
|
|
79
|
+
shutdown.nativeExited();
|
|
80
|
+
releaseMarker?.();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const exited = (async () => {
|
|
84
|
+
const { code, signal } = await ended.promise;
|
|
85
|
+
// And what it started that kept the marker, wherever it was reparented (Linux; read without blocking the loop).
|
|
86
|
+
if (marker !== undefined && child.pid !== undefined) {
|
|
87
|
+
await killMarkedAsync(marker);
|
|
88
|
+
}
|
|
89
|
+
releaseMarker?.();
|
|
90
|
+
await shutdown.finished;
|
|
91
|
+
const drained = Promise.withResolvers();
|
|
92
|
+
const timer = setTimeout(drained.resolve, STDERR_DRAIN_MS);
|
|
93
|
+
await Promise.race([stderrClosed.promise, drained.promise]);
|
|
94
|
+
clearTimeout(timer);
|
|
95
|
+
return { code, signal, stderr: stderr.text() };
|
|
96
|
+
})();
|
|
97
|
+
const running = () => child.pid !== undefined && child.exitCode === null && child.signalCode === null;
|
|
98
|
+
let stopping = false;
|
|
99
|
+
return {
|
|
100
|
+
pid: child.pid,
|
|
101
|
+
send(message) {
|
|
102
|
+
if (!child.connected) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
return child.send(message, () => { });
|
|
106
|
+
},
|
|
107
|
+
onMessage(listener) { child.on("message", listener); },
|
|
108
|
+
exited,
|
|
109
|
+
async stop(ask, captureTree = true) {
|
|
110
|
+
if (!stopping && running()) {
|
|
111
|
+
stopping = true;
|
|
112
|
+
// Remember its descendants while it still runs: once it is gone they are no longer below it.
|
|
113
|
+
// A child known to start nothing skips the read (on Windows a process-table query of its own).
|
|
114
|
+
if (captureTree) {
|
|
115
|
+
await shutdown.prepare();
|
|
116
|
+
}
|
|
117
|
+
if (ask !== undefined && running()) {
|
|
118
|
+
shutdown.markNativeStop();
|
|
119
|
+
ask();
|
|
120
|
+
backstop = setTimeout(() => { shutdown.stop(); }, killGraceMs());
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
shutdown.stop();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const exit = await exited;
|
|
127
|
+
return exit;
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=node-script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-script.js","sources":["../../../src/shared/executable/node-script.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAgC1F,kFAAkF;AAClF,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,QAAgB,EAAE,GAAsB,EAAE,MAAe;IACvG,MAAM,IAAI,GAAG,kBAAkB,EAAE,CAAC;IAClC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,yLAAyL,CAAC,CAAC;IAC7M,CAAC;IACD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE;QAClD,GAAG;QACH,KAAK,EAAE,CA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B,GAAG,EAAE,CAAC;oBACN,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;gBACnE,CAAC;qBAAM,CAAC;oBACN,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAClB,CAAC;YACH,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC;YAC1B,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botiverse/oar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.101.1",
|
|
4
4
|
"description": "A programming interface for all agent harnesses: provider-independent contracts for controlling and observing agent runtimes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -51,6 +51,10 @@
|
|
|
51
51
|
"types": "./dist/pi-durable.d.ts",
|
|
52
52
|
"import": "./dist/pi-durable.js"
|
|
53
53
|
},
|
|
54
|
+
"./runtimes/codex/installation-candidates": {
|
|
55
|
+
"types": "./dist/runtimes/codex/installation-candidates.d.ts",
|
|
56
|
+
"import": "./dist/runtimes/codex/installation-candidates.js"
|
|
57
|
+
},
|
|
54
58
|
"./runtimes/*": {
|
|
55
59
|
"types": "./dist/runtimes/*/index.d.ts",
|
|
56
60
|
"import": "./dist/runtimes/*/index.js"
|