@muha-sdk/agy-adapter 0.0.0-stage → 0.1.13

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gao Sijie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,72 @@
1
- # Temporary Holding Version
1
+ # @muha-sdk/agy-adapter
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The stage-five AGY CLI Adapter for Muha SDK. It uses the caller-installed and
4
+ authenticated `agy` command on `PATH`; it never installs AGY or falls back to an
5
+ SDK or API integration. The current first-version qualification uses Claude
6
+ Sonnet 4.6; see the [acceptance results](https://github.com/Gao-Sijie/muha/blob/main/QUALIFICATION.md).
7
+
8
+ ```js
9
+ import { createMuhaRuntime } from "@muha-sdk/core";
10
+ import { agyAdapter } from "@muha-sdk/agy-adapter";
11
+
12
+ const runtime = await createMuhaRuntime({ harnesses: [agyAdapter()] });
13
+ try {
14
+ const session = await runtime.createSession({
15
+ harness: "agy",
16
+ workspacePath: process.cwd(),
17
+ model: "claude-sonnet-4-6",
18
+ approvalPolicy: "autoApprove",
19
+ });
20
+ const turn = await session.startTurn([{ type: "text", text: "Describe this project." }]);
21
+ for await (const event of turn) {
22
+ if (event.type === "assistant.message.delta") process.stdout.write(event.delta);
23
+ }
24
+ console.log(await turn.result);
25
+ } finally {
26
+ await runtime.close();
27
+ }
28
+ ```
29
+
30
+ `harnessManaged` delegates to native permissions; `autoApprove` applies
31
+ `--dangerously-skip-permissions` on creation, resume, and controlled reopen
32
+ after interruption. Native permission rules and plugins remain unmanaged.
33
+ The Core default `interactive` policy is unsupported, so select a supported
34
+ policy explicitly. Muha does not roll back native configuration on close.
35
+
36
+ The Profile supports text Turns, known-reference resume, assistant message
37
+ streaming, tool events, current-Turn usage, and explicit Workspace Skills.
38
+ Model and effort can be selected at create/resume and expose only caller
39
+ selections (`selectedOnly`); idle setters, listing, image input, structured
40
+ approvals/questions, reasoning streaming, and Muha-managed Workspace MCP are
41
+ unsupported. The accepted Claude Sonnet 4.6 model rejects an explicit
42
+ `--effort`; omit effort for that model. Native identifiers are not Muha aliases.
43
+
44
+ AGY cannot disable its native print timeout using `0` or `-1s`. This Adapter
45
+ uses `--print-timeout 60m` and emits `MUHA_AGY_NATIVE_TURN_TIMEOUT` when activated.
46
+ This is the total wait for each Turn, not an idle timeout; intermediate output
47
+ does not restart the clock. A native timeout is a failed Turn, including when
48
+ AGY returns partial output with a
49
+ `SUCCESS` status. This limitation does not add a Core or other-Harness timer.
50
+
51
+ Each new Session receives an independent native Project bound to its
52
+ Workspace. Resume reads only the referenced native SQLite metadata and its
53
+ Project to verify identity and directory binding, failing explicitly on an
54
+ unknown or inconsistent format. Closing does not delete native history or
55
+ Projects. Workspace Skills remain shared physical files between Sessions
56
+ using the same directory.
57
+
58
+ Malformed or incomplete native results fail explicitly and stop their owned
59
+ execution; native `SUCCESS` alone does not establish a completed Turn.
60
+
61
+ The package includes its Linux x64 process supervisor and C source. It needs
62
+ the existing glibc 2.28 platform, with no consumer compiler, Python, systemd,
63
+ namespace, or install script. It owns and reaps only its CLI descendants;
64
+ unexpected AGY loss closes the Runtime. Complete descendant reclamation is
65
+ guaranteed while this supervisor remains alive; supervisor death is still a
66
+ fatal error but is outside that reclamation guarantee. The consuming Node
67
+ process retains its signal handlers and child-process ownership.
68
+
69
+ Maintainers build the helper with `npm run build:native` using a C compiler
70
+ and `readelf`. Its startup compatibility source binds the existing x86-64
71
+ glibc ABI; keep the actual glibc 2.28 qualification when changing startup or
72
+ adding C constructors. The helper links the platform libc dynamically.
@@ -0,0 +1,41 @@
1
+ import type { HarnessErrorData, OfficialAdapterOptions } from "@muha-sdk/core";
2
+ import type { AdapterCreateSessionOptions, AdapterResumeSessionOptions, AdapterSession, AdapterTurn, AdapterTurnInput, LiveHarnessAdapter, LiveHarnessAdapterContext } from "@muha-sdk/core/internal";
3
+ export declare class AgyProcess implements LiveHarnessAdapter {
4
+ #private;
5
+ readonly options: OfficialAdapterOptions;
6
+ readonly context: LiveHarnessAdapterContext;
7
+ readonly kind: "agy";
8
+ readonly route: "native";
9
+ get closing(): boolean;
10
+ get initialized(): boolean;
11
+ constructor(options: OfficialAdapterOptions, context: LiveHarnessAdapterContext);
12
+ initialize(): Promise<void>;
13
+ createSession(options: AdapterCreateSessionOptions): Promise<AdapterSession>;
14
+ resumeSession(options: AdapterResumeSessionOptions): Promise<AdapterSession>;
15
+ listSessions(): Promise<never>;
16
+ lost(session: AgySession, error: HarnessErrorData): void;
17
+ release(session: AgySession): void;
18
+ close(): Promise<void>;
19
+ }
20
+ declare class AgySession implements AdapterSession {
21
+ #private;
22
+ readonly owner: AgyProcess;
23
+ readonly options: AdapterCreateSessionOptions;
24
+ readonly env: NodeJS.ProcessEnv;
25
+ nativeSessionId: string;
26
+ readonly model: string | undefined;
27
+ readonly effort: string | undefined;
28
+ closed: boolean;
29
+ constructor(owner: AgyProcess, options: AdapterCreateSessionOptions, env: NodeJS.ProcessEnv, resume?: {
30
+ id: string;
31
+ projectId: string;
32
+ });
33
+ open(): Promise<void>;
34
+ startTurn(input: readonly AdapterTurnInput[]): Promise<AdapterTurn>;
35
+ setModel(): Promise<never>;
36
+ setEffort(): Promise<never>;
37
+ fail(error: HarnessErrorData): void;
38
+ close(): Promise<void>;
39
+ }
40
+ export {};
41
+ //# sourceMappingURL=agy-process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agy-process.d.ts","sourceRoot":"","sources":["../src/agy-process.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,KAAK,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,cAAc,EAAE,WAAW,EAC/E,gBAAgB,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAKrH,qBAAa,UAAW,YAAW,kBAAkB;;IASvC,QAAQ,CAAC,OAAO,EAAE,sBAAsB;IAAE,QAAQ,CAAC,OAAO,EAAE,yBAAyB;IARjG,QAAQ,CAAC,IAAI,EAAG,KAAK,CAAU;IAC/B,QAAQ,CAAC,KAAK,EAAG,QAAQ,CAAU;IAKnC,IAAI,OAAO,IAAI,OAAO,CAAwC;IAC9D,IAAI,WAAW,IAAI,OAAO,CAA8B;gBACnC,OAAO,EAAE,sBAAsB,EAAW,OAAO,EAAE,yBAAyB;IAO3F,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAU3B,aAAa,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,cAAc,CAAC;IAM5E,aAAa,CAAC,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,cAAc,CAAC;IAO5E,YAAY,IAAI,OAAO,CAAC,KAAK,CAAC;IACpC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAIxD,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI;IAClC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CASvB;AAED,cAAM,UAAW,YAAW,cAAc;;IAa5B,QAAQ,CAAC,KAAK,EAAE,UAAU;IAAE,QAAQ,CAAC,OAAO,EAAE,2BAA2B;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU;IAZtH,eAAe,SAAM;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,MAAM,UAAS;gBASM,KAAK,EAAE,UAAU,EAAW,OAAO,EAAE,2BAA2B,EAAW,GAAG,EAAE,MAAM,CAAC,UAAU,EACpH,MAAM,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAKtC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiErB,SAAS,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAyBnE,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,KAAK,CAAC;IACjC,IAAI,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI;IACnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CASvB"}
@@ -0,0 +1,430 @@
1
+ import { mkdtemp, rm } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { OwnedCli } from "./owned-cli.js";
5
+ import { nativeBinding } from "./native-metadata.js";
6
+ import { bounded, Deferred, EventQueue, failure, object } from "./protocol.js";
7
+ export class AgyProcess {
8
+ options;
9
+ context;
10
+ kind = "agy";
11
+ route = "native";
12
+ #sessions = new Set();
13
+ #env;
14
+ #initialized = false;
15
+ #closing;
16
+ get closing() { return this.#closing !== undefined; }
17
+ get initialized() { return this.#initialized; }
18
+ constructor(options, context) {
19
+ this.options = options;
20
+ this.context = context;
21
+ this.#env = { ...process.env };
22
+ for (const [key, value] of Object.entries(options.env ?? {})) {
23
+ if (value === undefined)
24
+ delete this.#env[key];
25
+ else
26
+ this.#env[key] = value;
27
+ }
28
+ }
29
+ async initialize() {
30
+ const workspacePath = await mkdtemp(join(tmpdir(), "muha-agy-ready-"));
31
+ try {
32
+ const session = await this.createSession({ workspacePath, approvalPolicy: "harnessManaged" });
33
+ await session.close();
34
+ this.#initialized = true;
35
+ process.emitWarning("AGY cannot disable its native print timeout; AGY Turns use a 60 minute native limit.", { code: "MUHA_AGY_NATIVE_TURN_TIMEOUT" });
36
+ }
37
+ finally {
38
+ await rm(workspacePath, { recursive: true, force: true });
39
+ }
40
+ }
41
+ async createSession(options) {
42
+ const session = new AgySession(this, options, this.#env);
43
+ this.#sessions.add(session);
44
+ try {
45
+ await session.open();
46
+ return session;
47
+ }
48
+ catch (error) {
49
+ await session.close();
50
+ throw error;
51
+ }
52
+ }
53
+ async resumeSession(options) {
54
+ const projectId = await nativeBinding(this.#env, options.nativeSessionId, options.workspacePath);
55
+ const session = new AgySession(this, options, this.#env, { id: options.nativeSessionId, projectId });
56
+ this.#sessions.add(session);
57
+ try {
58
+ await session.open();
59
+ return session;
60
+ }
61
+ catch (error) {
62
+ await session.close();
63
+ throw error;
64
+ }
65
+ }
66
+ async listSessions() { throw failure("listSessions", "AGY listing is unsupported"); }
67
+ lost(session, error) {
68
+ session.fail(error);
69
+ if (this.#initialized && !this.#closing)
70
+ this.context.reportFatalError(error, [session]);
71
+ }
72
+ release(session) { this.#sessions.delete(session); }
73
+ close() {
74
+ return this.#closing ??= (async () => {
75
+ const results = await Promise.allSettled([...this.#sessions].map(session => session.close()));
76
+ const failed = results.find(result => result.status === "rejected");
77
+ if (failed?.status === "rejected")
78
+ throw {
79
+ ...failed.reason, code: "HARNESS_ERROR", harness: "agy", operation: "closeHarness", retryable: false,
80
+ };
81
+ })();
82
+ }
83
+ }
84
+ class AgySession {
85
+ owner;
86
+ options;
87
+ env;
88
+ nativeSessionId = "";
89
+ model;
90
+ effort;
91
+ closed = false;
92
+ #cli;
93
+ #turn;
94
+ #closePromise;
95
+ #restart = false;
96
+ #stepOwners = new Map();
97
+ #turnSequence = 0;
98
+ #resultCount;
99
+ #resume;
100
+ constructor(owner, options, env, resume) {
101
+ this.owner = owner;
102
+ this.options = options;
103
+ this.env = env;
104
+ this.model = options.model;
105
+ this.effort = options.effort;
106
+ this.#resume = resume;
107
+ }
108
+ async open() {
109
+ const operation = !this.owner.initialized ? "initialize" : this.#resume ? "resumeSession" : "createSession";
110
+ if (this.closed || this.owner.closing)
111
+ throw failure(operation, "AGY Session is closing");
112
+ this.#stepOwners.clear();
113
+ this.#resultCount = undefined;
114
+ const args = ["--input-format", "stream-json", "--output-format", "stream-json", "--print-timeout", "60m"];
115
+ if (this.#resume)
116
+ args.push("--conversation", this.#resume.id, "--project", this.#resume.projectId);
117
+ else
118
+ args.push("--new-project", "--add-dir", this.options.workspacePath);
119
+ if (this.model !== undefined)
120
+ args.push("--model", this.model);
121
+ if (this.effort !== undefined)
122
+ args.push("--effort", this.effort);
123
+ if (this.options.approvalPolicy === "autoApprove")
124
+ args.push("--dangerously-skip-permissions");
125
+ this.#cli = new OwnedCli(args, this.options.workspacePath, this.env, this.owner.options.shutdownTimeoutMs ?? 60_000, this.owner.context, (event, printTimedOut) => this.#receive(event, printTimedOut), error => this.owner.lost(this, error), operation);
126
+ const ready = await bounded(this.#cli.ready.promise, this.owner.options.startupTimeoutMs ?? 60_000, failure(operation, "AGY native readiness timed out"));
127
+ const init = object(ready.init);
128
+ if (typeof ready.conversation_id !== "string" || !ready.conversation_id || init.cwd !== this.options.workspacePath) {
129
+ throw failure(operation, "AGY initialized a different Workspace or invalid Session identity");
130
+ }
131
+ if (this.options.approvalPolicy === "autoApprove" && init.permission_mode !== "always-proceed") {
132
+ throw failure(operation, "AGY did not apply autonomous permissions");
133
+ }
134
+ this.nativeSessionId = ready.conversation_id;
135
+ if (this.#resume && this.nativeSessionId !== this.#resume.id) {
136
+ throw failure("resumeSession", "AGY resumed a different Session identity");
137
+ }
138
+ const projectId = await nativeBinding(this.env, this.nativeSessionId, this.options.workspacePath, operation);
139
+ if (this.#resume && projectId !== this.#resume.projectId) {
140
+ throw failure("resumeSession", "AGY resumed a different Session or changed Project binding");
141
+ }
142
+ if (this.closed || this.owner.closing)
143
+ throw failure(operation, "AGY Session closed during initialization");
144
+ }
145
+ #receive(event, printTimedOut) {
146
+ const turn = this.#turn;
147
+ if (!turn)
148
+ return;
149
+ // A timeout can happen before the new input is accepted, leaving the
150
+ // cumulative native count unchanged. Its explicit signal takes priority.
151
+ if (event.event === "result" && printTimedOut) {
152
+ turn.event(event, true);
153
+ return;
154
+ }
155
+ if (event.event === "step_update") {
156
+ const step = object(event.step_update);
157
+ const index = step.step_index;
158
+ if (step.conversation_id === this.nativeSessionId && typeof index === "number" && Number.isSafeInteger(index)) {
159
+ // Step IDs are Session-scoped. Preserve known ownership without
160
+ // assuming that new indexes must arrive in increasing order.
161
+ const owner = this.#stepOwners.get(index);
162
+ if (owner !== undefined && owner !== this.#turnSequence)
163
+ return;
164
+ this.#stepOwners.set(index, this.#turnSequence);
165
+ }
166
+ }
167
+ else if (event.event === "result") {
168
+ const result = object(event.result);
169
+ const count = result.num_turns;
170
+ if (result.conversation_id === this.nativeSessionId && typeof count === "number" && Number.isSafeInteger(count)) {
171
+ // Native num_turns is cumulative across the Session. A previous
172
+ // terminal must never settle input submitted after that terminal.
173
+ if (this.#resultCount !== undefined && count <= this.#resultCount)
174
+ return;
175
+ this.#resultCount = count;
176
+ }
177
+ }
178
+ turn.event(event, printTimedOut);
179
+ }
180
+ async startTurn(input) {
181
+ if (this.#restart) {
182
+ this.#restart = false;
183
+ try {
184
+ this.#resume = { id: this.nativeSessionId,
185
+ projectId: await nativeBinding(this.env, this.nativeSessionId, this.options.workspacePath) };
186
+ await this.open();
187
+ }
188
+ catch (error) {
189
+ this.owner.lost(this, failure("startTurn", "AGY could not reopen the interrupted Session"));
190
+ throw error;
191
+ }
192
+ }
193
+ const turn = new TextTurn(this.nativeSessionId, async () => {
194
+ await this.#cli.close(true);
195
+ this.#restart = !this.closed && !this.owner.closing;
196
+ });
197
+ this.#turnSequence++;
198
+ this.#turn = turn;
199
+ this.#cli.write({ event: "user", message: { content: input.map(part => {
200
+ if (part.type !== "text")
201
+ throw failure("startTurn", "AGY only supports text input");
202
+ return { type: "text", text: part.text };
203
+ }) } });
204
+ await turn.accepted.promise;
205
+ return turn;
206
+ }
207
+ async setModel() { throw failure("setModel", "AGY idle selection is unsupported"); }
208
+ async setEffort() { throw failure("setEffort", "AGY idle selection is unsupported"); }
209
+ fail(error) { this.#turn?.fail(error); }
210
+ close() {
211
+ return this.#closePromise ??= (async () => {
212
+ this.closed = true;
213
+ this.#turn?.fail(failure("closeSession", "AGY Session is closing"));
214
+ await this.#cli?.close();
215
+ // Keep a failed close reachable until the Harness aggregates it.
216
+ this.owner.release(this);
217
+ })();
218
+ }
219
+ }
220
+ class TextTurn {
221
+ sessionId;
222
+ stop;
223
+ nativeTurnId = "pending";
224
+ accepted = new Deferred();
225
+ #queue = new EventQueue();
226
+ #messages = new Map();
227
+ #completedMessages = new Map();
228
+ #usage = new Map();
229
+ #tools = new Map();
230
+ #accepted = false;
231
+ #ended = false;
232
+ #interrupting;
233
+ constructor(sessionId, stop) {
234
+ this.sessionId = sessionId;
235
+ this.stop = stop;
236
+ }
237
+ event(event, printTimedOut = false) {
238
+ if (this.#ended || this.#interrupting)
239
+ return;
240
+ if (event.event === "result" && printTimedOut) {
241
+ this.#interrupting = this.stop().then(() => this.fail({
242
+ ...failure("startTurn", "AGY reached its native 60 minute print timeout and returned partial output"), nativeCode: "timeout",
243
+ })).catch(() => this.fail(failure("startTurn", "AGY timed out and owned execution could not be stopped")));
244
+ return;
245
+ }
246
+ try {
247
+ this.#receive(event);
248
+ }
249
+ catch {
250
+ this.#protocol("Invalid AGY semantic event");
251
+ }
252
+ }
253
+ #receive(event) {
254
+ if (event.event === "step_update") {
255
+ const step = object(event.step_update);
256
+ if (step.conversation_id !== this.sessionId || !Number.isSafeInteger(step.step_index)) {
257
+ this.#protocol("AGY step identity is invalid");
258
+ return;
259
+ }
260
+ const index = step.step_index;
261
+ if (step.step_type === "user_input" && step.state === "DONE" && !this.#accepted) {
262
+ this.nativeTurnId = `${this.sessionId}:${index}`;
263
+ this.#accepted = true;
264
+ this.accepted.resolve();
265
+ this.#queue.push({ type: "turn.started" });
266
+ }
267
+ if (step.usage !== undefined) {
268
+ const native = object(step.usage);
269
+ const snapshot = {};
270
+ for (const [from, to] of Object.entries({ input_tokens: "inputTokens", output_tokens: "outputTokens",
271
+ cache_read_tokens: "cachedInputTokens", thinking_tokens: "reasoningTokens" })) {
272
+ const value = native[from];
273
+ if (value === undefined)
274
+ continue;
275
+ if (!Number.isSafeInteger(value) || value < 0) {
276
+ this.#protocol("AGY reported invalid token usage");
277
+ return;
278
+ }
279
+ snapshot[to] = value;
280
+ }
281
+ this.#usage.set(index, snapshot);
282
+ const total = {};
283
+ for (const usage of this.#usage.values())
284
+ for (const [key, count] of Object.entries(usage)) {
285
+ const sum = (total[key] ?? 0) + count;
286
+ if (!Number.isSafeInteger(sum)) {
287
+ this.#protocol("AGY token usage exceeds the safe integer range");
288
+ return;
289
+ }
290
+ total[key] = sum;
291
+ }
292
+ if (Object.keys(total).length)
293
+ this.#queue.push({ type: "usage.updated", usage: total });
294
+ }
295
+ if (step.step_type === "tool") {
296
+ const info = step.tool_info === undefined ? {} : object(step.tool_info);
297
+ const name = step.tool_name;
298
+ if (typeof name !== "string" || !name || (info.name !== undefined && info.name !== name)) {
299
+ this.#protocol("AGY tool identity is invalid");
300
+ return;
301
+ }
302
+ const existing = this.#tools.get(index);
303
+ if (existing && existing.name !== name) {
304
+ this.#protocol("AGY changed a Tool identity");
305
+ return;
306
+ }
307
+ const nativeToolCallId = `${this.sessionId}:${index}`;
308
+ if (!existing)
309
+ this.#queue.push({ type: "tool.started", nativeToolCallId, toolName: name, input: info.parameters ?? null });
310
+ const merged = { ...existing?.info, ...info };
311
+ this.#tools.set(index, { id: nativeToolCallId, name, state: step.state, info: merged,
312
+ ...(step.error === undefined ? {} : { error: step.error }) });
313
+ this.#queue.push({ type: "tool.updated", nativeToolCallId, update: { state: step.state, ...merged } });
314
+ }
315
+ if (step.step_type === "agent_response") {
316
+ if (this.#completedMessages.has(index)) {
317
+ if (step.state !== "DONE" || (step.text_delta !== undefined &&
318
+ step.text_delta !== this.#completedMessages.get(index))) {
319
+ this.#protocol("AGY changed a completed Assistant Message");
320
+ }
321
+ return;
322
+ }
323
+ const nativeMessageId = `${this.sessionId}:${index}`;
324
+ if (!this.#messages.has(index)) {
325
+ this.#messages.set(index, "");
326
+ this.#queue.push({ type: "assistant.message.started", nativeMessageId });
327
+ }
328
+ if (typeof step.text_delta === "string" && step.text_delta.length) {
329
+ this.#messages.set(index, this.#messages.get(index) + step.text_delta);
330
+ this.#queue.push({ type: "assistant.message.delta", nativeMessageId, delta: step.text_delta });
331
+ }
332
+ if (step.state === "DONE") {
333
+ this.#completedMessages.set(index, typeof step.text_delta === "string" ? step.text_delta : undefined);
334
+ this.#queue.push({ type: "assistant.message.completed", nativeMessageId, text: this.#messages.get(index) });
335
+ }
336
+ }
337
+ }
338
+ else if (event.event === "result") {
339
+ const result = object(event.result);
340
+ if (result.conversation_id !== this.sessionId) {
341
+ this.#protocol("AGY result belongs to a different Session");
342
+ return;
343
+ }
344
+ if (!Number.isSafeInteger(result.num_turns) || result.num_turns < 1) {
345
+ this.#protocol("AGY result has no valid cumulative Turn identity");
346
+ return;
347
+ }
348
+ if (result.status === "SUCCESS" && (this.#messages.size === 0 || this.#messages.size !== this.#completedMessages.size)) {
349
+ this.#protocol("AGY succeeded without a complete final Assistant Message");
350
+ return;
351
+ }
352
+ const denials = result.denied_actions ?? [];
353
+ if (!Array.isArray(denials)) {
354
+ this.#protocol("AGY denied_actions is invalid");
355
+ return;
356
+ }
357
+ const deniedByTool = new Map();
358
+ for (const value of denials) {
359
+ const denial = object(value);
360
+ // The qualified protocol supplies only an action category, not a
361
+ // call ID. Do not guess among multiple calls of the same category.
362
+ const candidates = [...this.#tools.values()].filter(tool => denial.action === "command" && tool.name === "run_command");
363
+ if (candidates.length !== 1) {
364
+ this.#protocol("AGY denial cannot be uniquely attributed to a Tool");
365
+ return;
366
+ }
367
+ const toolId = candidates[0].id;
368
+ deniedByTool.set(toolId, [...(deniedByTool.get(toolId) ?? []), denial]);
369
+ }
370
+ for (const tool of this.#tools.values()) {
371
+ if (tool.state !== "DONE" && tool.state !== "ERROR") {
372
+ if (result.status === "SUCCESS") {
373
+ this.#protocol("AGY succeeded with an unfinished Tool");
374
+ return;
375
+ }
376
+ continue;
377
+ }
378
+ const denied = deniedByTool.get(tool.id);
379
+ const error = tool.error ?? tool.info.error;
380
+ this.#queue.push({ type: "tool.completed", nativeToolCallId: tool.id,
381
+ output: denied ? { denied_actions: denied } : error ?? tool.info.output ?? null,
382
+ isError: denied !== undefined || tool.state === "ERROR" || error !== undefined });
383
+ }
384
+ if (result.status === "ERROR")
385
+ this.fail({
386
+ ...failure("startTurn", typeof result.error === "string" ? result.error : "AGY native Turn failed"), nativeCode: "ERROR",
387
+ });
388
+ else if (result.status !== "SUCCESS")
389
+ this.#protocol("AGY reported an unknown native Turn status");
390
+ else if (!this.#accepted)
391
+ this.fail(failure("startTurn", "AGY ended before accepting input"));
392
+ else {
393
+ this.#ended = true;
394
+ this.#queue.push({ type: "turn.completed" });
395
+ this.#queue.end();
396
+ }
397
+ }
398
+ }
399
+ #protocol(message) {
400
+ if (this.#ended || this.#interrupting)
401
+ return;
402
+ this.#interrupting = this.stop().then(() => {
403
+ this.#ended = true;
404
+ this.accepted.reject({ code: "ADAPTER_PROTOCOL_ERROR", harness: "agy", message });
405
+ this.#queue.push({ type: "adapter.protocolError", message });
406
+ this.#queue.end();
407
+ }).catch(() => this.fail(failure("startTurn", "AGY protocol failure could not stop owned execution")));
408
+ }
409
+ fail(error) {
410
+ if (this.#ended)
411
+ return;
412
+ this.#ended = true;
413
+ this.accepted.reject(error);
414
+ this.#queue.push({ type: "turn.failed", error });
415
+ this.#queue.end();
416
+ }
417
+ [Symbol.asyncIterator]() { return this.#queue[Symbol.asyncIterator](); }
418
+ interrupt() {
419
+ if (this.#ended)
420
+ return Promise.resolve();
421
+ return this.#interrupting ??= this.stop().then(() => {
422
+ this.#ended = true;
423
+ this.#queue.push({ type: "turn.interrupted" });
424
+ this.#queue.end();
425
+ });
426
+ }
427
+ async respondToApproval() { throw failure("respondToApproval", "AGY structured approvals are unsupported"); }
428
+ async respondToQuestion() { throw failure("respondToQuestion", "AGY structured questions are unsupported"); }
429
+ }
430
+ //# sourceMappingURL=agy-process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agy-process.js","sourceRoot":"","sources":["../src/agy-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AAEhG,MAAM,OAAO,UAAU;IASA;IAA0C;IARtD,IAAI,GAAG,KAAc,CAAC;IACtB,KAAK,GAAG,QAAiB,CAAC;IAC1B,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IAClC,IAAI,CAAoB;IACjC,YAAY,GAAG,KAAK,CA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MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;IACpB,CAAC;IACD,CAAC,MAAM,CAAC,aAAa,CAAC,KAAsC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC;IACzG,SAAS;QACP,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC,aAAa,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAClD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAC;YAC/C,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,iBAAiB,KAAqB,MAAM,OAAO,CAAC,mBAAmB,EAAE,0CAA0C,CAAC,CAAC,CAAC,CAAC;IAC7H,KAAK,CAAC,iBAAiB,KAAqB,MAAM,OAAO,CAAC,mBAAmB,EAAE,0CAA0C,CAAC,CAAC,CAAC,CAAC;CAC9H"}
Binary file
@@ -0,0 +1,17 @@
1
+ /* Link-only x86-64 glibc compatibility shim for the shared independent helper.
2
+ * Ubuntu 22.04 CRT references the default GLIBC_2.34 startup symbol. This
3
+ * helper has no program constructors, so the preserved GLIBC_2.2.5 startup
4
+ * entry is sufficient. Qualify under the actual minimum libc as well as
5
+ * checking the final ELF version requirements; do not infer portability from
6
+ * this source alone. Build with -Wl,--wrap=__libc_start_main. */
7
+ typedef int (*main_function)(int, char **, char **);
8
+ typedef void (*init_function)(void);
9
+
10
+ extern int legacy_libc_start_main(main_function main, int argc, char **argv,
11
+ init_function init, init_function fini, init_function rtld_fini, void *stack_end);
12
+ __asm__(".symver legacy_libc_start_main,__libc_start_main@GLIBC_2.2.5");
13
+
14
+ int __wrap___libc_start_main(main_function main, int argc, char **argv,
15
+ init_function init, init_function fini, init_function rtld_fini, void *stack_end) {
16
+ return legacy_libc_start_main(main, argc, argv, init, fini, rtld_fini, stack_end);
17
+ }