showrunner-agent-staging 0.2.4-staging.1289 → 0.2.5-staging.1291
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/src/adapter.d.ts
CHANGED
|
@@ -46,6 +46,8 @@ export type AgentModelOption = {
|
|
|
46
46
|
export declare const maxReportedModelOptions = 64;
|
|
47
47
|
export declare const maxModelOptionFieldLength = 100;
|
|
48
48
|
export interface AgentAdapter {
|
|
49
|
+
/** Release resources owned by this connector when it stops. */
|
|
50
|
+
close?(): Promise<void>;
|
|
49
51
|
readonly kind: AgentAdapterKind;
|
|
50
52
|
readonly version: string;
|
|
51
53
|
readonly mediaCapabilities: AdapterMediaCapabilities;
|
|
@@ -8,6 +8,7 @@ export class StdioCodexTransport {
|
|
|
8
8
|
#errorHandlers = new Set();
|
|
9
9
|
#failure;
|
|
10
10
|
#closing = false;
|
|
11
|
+
#closeTask;
|
|
11
12
|
#stderrTail = "";
|
|
12
13
|
constructor(command = "codex", args = ["app-server"]) {
|
|
13
14
|
this.#process = spawn(command, args, { stdio: ["pipe", "pipe", "pipe"], shell: false });
|
|
@@ -62,12 +63,22 @@ export class StdioCodexTransport {
|
|
|
62
63
|
return () => this.#errorHandlers.delete(handler);
|
|
63
64
|
}
|
|
64
65
|
close() {
|
|
65
|
-
this.#
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
this.#closeTask ??= new Promise((resolve) => {
|
|
67
|
+
this.#closing = true;
|
|
68
|
+
if (this.#process.pid === undefined || this.#process.exitCode !== null || this.#process.signalCode !== null) {
|
|
69
|
+
resolve();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const timeout = setTimeout(() => this.#process.kill("SIGKILL"), 1_000);
|
|
73
|
+
timeout.unref();
|
|
74
|
+
this.#process.once("close", () => {
|
|
75
|
+
clearTimeout(timeout);
|
|
76
|
+
resolve();
|
|
77
|
+
});
|
|
78
|
+
this.#process.stdin.end();
|
|
68
79
|
this.#process.kill("SIGTERM");
|
|
69
|
-
}
|
|
70
|
-
return
|
|
80
|
+
});
|
|
81
|
+
return this.#closeTask;
|
|
71
82
|
}
|
|
72
83
|
#fail(error) {
|
|
73
84
|
if (this.#failure !== undefined) {
|
|
@@ -69,6 +69,7 @@ export type CodexEvent = {
|
|
|
69
69
|
code?: string;
|
|
70
70
|
};
|
|
71
71
|
export interface CodexRuntime {
|
|
72
|
+
close?(): Promise<void>;
|
|
72
73
|
startThread(tools?: CodexDynamicTool[], config?: CodexSessionConfig): Promise<{
|
|
73
74
|
threadId: string;
|
|
74
75
|
model?: string;
|
|
@@ -105,6 +106,7 @@ export declare class CodexAdapter implements AgentAdapter {
|
|
|
105
106
|
runtime?: CodexRuntime;
|
|
106
107
|
workspaceRoot?: string;
|
|
107
108
|
});
|
|
109
|
+
close(): Promise<void>;
|
|
108
110
|
listModels(signal: AbortSignal): Promise<AgentModelOption[] | null>;
|
|
109
111
|
warmUp(): Promise<void>;
|
|
110
112
|
handle(event: AgentEvent, context: AgentInvocationContext, signal: AbortSignal): Promise<AgentAdapterResult>;
|
|
@@ -126,5 +128,6 @@ export declare class CodexAppServerRuntime implements CodexRuntime {
|
|
|
126
128
|
images?: NativeImageInput[];
|
|
127
129
|
}): AsyncIterable<CodexEvent>;
|
|
128
130
|
respond(requestId: string | number, result: unknown): Promise<void>;
|
|
131
|
+
close(): Promise<void>;
|
|
129
132
|
interrupt(threadId: string, turnId: string): Promise<void>;
|
|
130
133
|
}
|
|
@@ -14,6 +14,9 @@ export class CodexAdapter {
|
|
|
14
14
|
this.#runtime = input.runtime ?? new CodexAppServerRuntime();
|
|
15
15
|
this.#workspaceRoot = input.workspaceRoot ?? process.cwd();
|
|
16
16
|
}
|
|
17
|
+
close() {
|
|
18
|
+
return this.#runtime.close?.() ?? Promise.resolve();
|
|
19
|
+
}
|
|
17
20
|
listModels(signal) {
|
|
18
21
|
return this.#runtime.listModels?.(signal) ?? Promise.resolve(null);
|
|
19
22
|
}
|
|
@@ -234,6 +237,9 @@ export class CodexAppServerRuntime {
|
|
|
234
237
|
respond(requestId, result) {
|
|
235
238
|
return this.#client.respond(requestId, result);
|
|
236
239
|
}
|
|
240
|
+
close() {
|
|
241
|
+
return this.#client.close();
|
|
242
|
+
}
|
|
237
243
|
async interrupt(threadId, turnId) {
|
|
238
244
|
await this.#client.request("turn/interrupt", { threadId, turnId });
|
|
239
245
|
}
|
package/dist/src/cli.js
CHANGED
|
@@ -95,11 +95,17 @@ async function main() {
|
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
let shutdownTask;
|
|
99
|
+
const shutdown = () => shutdownTask ??= (async () => {
|
|
100
|
+
try {
|
|
101
|
+
await client.disconnect();
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
await adapter.close?.();
|
|
105
|
+
await instanceLock.release();
|
|
106
|
+
}
|
|
101
107
|
process.exitCode = 0;
|
|
102
|
-
};
|
|
108
|
+
})();
|
|
103
109
|
process.once("SIGINT", () => { void shutdown(); });
|
|
104
110
|
process.once("SIGTERM", () => { void shutdown(); });
|
|
105
111
|
}
|