@yitom/agy-acp-map 0.1.8 → 0.1.12
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/agent-sdk.d.ts +2 -0
- package/dist/agy-acp-win-x64.exe +2 -2
- package/dist/agy-headless.exe +0 -0
- package/dist/bin.js +68 -3
- package/dist/index.js +50 -2
- package/dist/lib/map-agy-to-acp.d.ts +7 -0
- package/package.json +1 -1
package/dist/agent-sdk.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export declare class AgyAcpService {
|
|
|
41
41
|
closeSession(params: any): Promise<any>;
|
|
42
42
|
deleteSession(params: any): Promise<any>;
|
|
43
43
|
cancelSession(params: any): void;
|
|
44
|
+
/** Kill every live agy child (bridge shutdown path; see sdk-server.ts). */
|
|
45
|
+
shutdown(): Promise<void>;
|
|
44
46
|
promptSession(params: any, notifyClient: (update: any) => Promise<void> | void, opts?: {
|
|
45
47
|
isPreLocked?: boolean;
|
|
46
48
|
}): Promise<{
|
package/dist/agy-acp-win-x64.exe
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/dist/agy-acp-win-x64.exe
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 86640640 bytes
|
|
4
|
+
sha256: c8e70067edbdf6ea2df6b33a207ca32035179f4c487a20ac7d4d78167af27583
|
package/dist/agy-headless.exe
CHANGED
|
Binary file
|
package/dist/bin.js
CHANGED
|
@@ -11020,6 +11020,7 @@ function createMapperState(richRoots) {
|
|
|
11020
11020
|
emittedImageUris: new Set,
|
|
11021
11021
|
emittedTextDelta: false,
|
|
11022
11022
|
emittedThoughtDelta: false,
|
|
11023
|
+
retryCount: 0,
|
|
11023
11024
|
richRoots
|
|
11024
11025
|
};
|
|
11025
11026
|
}
|
|
@@ -11035,7 +11036,8 @@ function resetTurnState(state) {
|
|
|
11035
11036
|
turnDone: false,
|
|
11036
11037
|
emittedImageUris: new Set,
|
|
11037
11038
|
emittedTextDelta: false,
|
|
11038
|
-
emittedThoughtDelta: false
|
|
11039
|
+
emittedThoughtDelta: false,
|
|
11040
|
+
retryCount: 0
|
|
11039
11041
|
};
|
|
11040
11042
|
}
|
|
11041
11043
|
function toolCallIdForStep(state, stepIndex) {
|
|
@@ -11184,6 +11186,31 @@ function extractThought(s) {
|
|
|
11184
11186
|
}
|
|
11185
11187
|
return;
|
|
11186
11188
|
}
|
|
11189
|
+
function extractErrorDetail(s, maxLen = 300) {
|
|
11190
|
+
const seen = new Set;
|
|
11191
|
+
const parts = [];
|
|
11192
|
+
const candidates = [
|
|
11193
|
+
s.error,
|
|
11194
|
+
s.message,
|
|
11195
|
+
s.text,
|
|
11196
|
+
s.description,
|
|
11197
|
+
s.reason,
|
|
11198
|
+
s.error_info?.message
|
|
11199
|
+
];
|
|
11200
|
+
for (const c of candidates) {
|
|
11201
|
+
if (typeof c !== "string")
|
|
11202
|
+
continue;
|
|
11203
|
+
const t = c.replace(/\s+/g, " ").trim();
|
|
11204
|
+
if (!t || seen.has(t))
|
|
11205
|
+
continue;
|
|
11206
|
+
seen.add(t);
|
|
11207
|
+
parts.push(t);
|
|
11208
|
+
if (parts.join(" | ").length >= maxLen)
|
|
11209
|
+
break;
|
|
11210
|
+
}
|
|
11211
|
+
const joined = parts.join(" | ");
|
|
11212
|
+
return joined.length > maxLen ? joined.slice(0, maxLen) + "…" : joined;
|
|
11213
|
+
}
|
|
11187
11214
|
function formatUpdateForProtocol(update, protocolVersion) {
|
|
11188
11215
|
if (protocolVersion >= 2) {
|
|
11189
11216
|
if (update.sessionUpdate === "tool_call") {
|
|
@@ -11310,6 +11337,23 @@ function mapAgyEvent(sessionId, event, state, opts) {
|
|
|
11310
11337
|
if (stepType === "user_input") {
|
|
11311
11338
|
return { notifications, state };
|
|
11312
11339
|
}
|
|
11340
|
+
if (stepType === "error_message") {
|
|
11341
|
+
const detail = extractErrorDetail(s);
|
|
11342
|
+
if (detail) {
|
|
11343
|
+
state.retryCount = (state.retryCount ?? 0) + 1;
|
|
11344
|
+
notifications.push(notify(sessionId, {
|
|
11345
|
+
sessionUpdate: "agent_message_chunk",
|
|
11346
|
+
messageId: `msg_agent_retry_${stepIndex}_${Date.now()}`,
|
|
11347
|
+
content: {
|
|
11348
|
+
type: "text",
|
|
11349
|
+
text: `
|
|
11350
|
+
> 第 ${state.retryCount} 次尝试遇到问题,正在重试…(${detail})
|
|
11351
|
+
`
|
|
11352
|
+
}
|
|
11353
|
+
}));
|
|
11354
|
+
}
|
|
11355
|
+
return { notifications, state };
|
|
11356
|
+
}
|
|
11313
11357
|
if (stepType === "agent_response") {
|
|
11314
11358
|
const text = s.text_delta;
|
|
11315
11359
|
if (typeof text === "string" && text.length > 0) {
|
|
@@ -12499,7 +12543,7 @@ class SessionHistoryStore {
|
|
|
12499
12543
|
var AGENT_INFO = {
|
|
12500
12544
|
name: "agy-acp",
|
|
12501
12545
|
title: "agy ACP (stream-json)",
|
|
12502
|
-
version: "0.1.
|
|
12546
|
+
version: "0.1.12"
|
|
12503
12547
|
};
|
|
12504
12548
|
var BRIDGE_CAPABILITIES = {
|
|
12505
12549
|
prompt: true,
|
|
@@ -17805,6 +17849,9 @@ class AgyAcpService {
|
|
|
17805
17849
|
cancelSession(params) {
|
|
17806
17850
|
this.core.cancelSession(params);
|
|
17807
17851
|
}
|
|
17852
|
+
async shutdown() {
|
|
17853
|
+
await this.core.shutdown();
|
|
17854
|
+
}
|
|
17808
17855
|
promptSession(params, notifyClient, opts) {
|
|
17809
17856
|
const targetSession = this.core.sessions.get(params?.sessionId);
|
|
17810
17857
|
const version = params?.protocolVersion === 2 || params?.protocolVersion !== 1 && targetSession?.protocolVersion === 2 ? 2 : 1;
|
|
@@ -17874,5 +17921,23 @@ var app = createDualAcpApp(service);
|
|
|
17874
17921
|
var stream = ndJsonStream2(Writable.toWeb(process.stdout), Readable.toWeb(process.stdin));
|
|
17875
17922
|
process.stderr.write(`[agy-acp-sdk] Starting official @agentclientprotocol/sdk stdio server...
|
|
17876
17923
|
`);
|
|
17924
|
+
var shuttingDown = false;
|
|
17925
|
+
async function shutdown(code) {
|
|
17926
|
+
if (shuttingDown)
|
|
17927
|
+
process.exit(code);
|
|
17928
|
+
shuttingDown = true;
|
|
17929
|
+
debugLog2(`shutdown code=${code}: killing supervised agy children`);
|
|
17930
|
+
try {
|
|
17931
|
+
await service.shutdown();
|
|
17932
|
+
} catch (err) {
|
|
17933
|
+
debugLog2(`shutdown kill error: ${err?.message}`);
|
|
17934
|
+
}
|
|
17935
|
+
debugLog2("shutdown complete");
|
|
17936
|
+
process.exit(code);
|
|
17937
|
+
}
|
|
17938
|
+
process.on("SIGINT", () => void shutdown(0));
|
|
17939
|
+
process.on("SIGTERM", () => void shutdown(0));
|
|
17940
|
+
process.stdin.on("end", () => void shutdown(0));
|
|
17941
|
+
process.stdin.on("close", () => void shutdown(0));
|
|
17877
17942
|
await app.connect(stream);
|
|
17878
|
-
debugLog2("CONNECT-SETUP-DONE (
|
|
17943
|
+
debugLog2("CONNECT-SETUP-DONE (serving; exit only via stdin close or signal)");
|
package/dist/index.js
CHANGED
|
@@ -10694,6 +10694,7 @@ function createMapperState(richRoots) {
|
|
|
10694
10694
|
emittedImageUris: new Set,
|
|
10695
10695
|
emittedTextDelta: false,
|
|
10696
10696
|
emittedThoughtDelta: false,
|
|
10697
|
+
retryCount: 0,
|
|
10697
10698
|
richRoots
|
|
10698
10699
|
};
|
|
10699
10700
|
}
|
|
@@ -10709,7 +10710,8 @@ function resetTurnState(state) {
|
|
|
10709
10710
|
turnDone: false,
|
|
10710
10711
|
emittedImageUris: new Set,
|
|
10711
10712
|
emittedTextDelta: false,
|
|
10712
|
-
emittedThoughtDelta: false
|
|
10713
|
+
emittedThoughtDelta: false,
|
|
10714
|
+
retryCount: 0
|
|
10713
10715
|
};
|
|
10714
10716
|
}
|
|
10715
10717
|
function toolCallIdForStep(state, stepIndex) {
|
|
@@ -10858,6 +10860,31 @@ function extractThought(s) {
|
|
|
10858
10860
|
}
|
|
10859
10861
|
return;
|
|
10860
10862
|
}
|
|
10863
|
+
function extractErrorDetail(s, maxLen = 300) {
|
|
10864
|
+
const seen = new Set;
|
|
10865
|
+
const parts = [];
|
|
10866
|
+
const candidates = [
|
|
10867
|
+
s.error,
|
|
10868
|
+
s.message,
|
|
10869
|
+
s.text,
|
|
10870
|
+
s.description,
|
|
10871
|
+
s.reason,
|
|
10872
|
+
s.error_info?.message
|
|
10873
|
+
];
|
|
10874
|
+
for (const c of candidates) {
|
|
10875
|
+
if (typeof c !== "string")
|
|
10876
|
+
continue;
|
|
10877
|
+
const t = c.replace(/\s+/g, " ").trim();
|
|
10878
|
+
if (!t || seen.has(t))
|
|
10879
|
+
continue;
|
|
10880
|
+
seen.add(t);
|
|
10881
|
+
parts.push(t);
|
|
10882
|
+
if (parts.join(" | ").length >= maxLen)
|
|
10883
|
+
break;
|
|
10884
|
+
}
|
|
10885
|
+
const joined = parts.join(" | ");
|
|
10886
|
+
return joined.length > maxLen ? joined.slice(0, maxLen) + "…" : joined;
|
|
10887
|
+
}
|
|
10861
10888
|
function formatUpdateForProtocol(update, protocolVersion) {
|
|
10862
10889
|
if (protocolVersion >= 2) {
|
|
10863
10890
|
if (update.sessionUpdate === "tool_call") {
|
|
@@ -10984,6 +11011,23 @@ function mapAgyEvent(sessionId, event, state, opts) {
|
|
|
10984
11011
|
if (stepType === "user_input") {
|
|
10985
11012
|
return { notifications, state };
|
|
10986
11013
|
}
|
|
11014
|
+
if (stepType === "error_message") {
|
|
11015
|
+
const detail = extractErrorDetail(s);
|
|
11016
|
+
if (detail) {
|
|
11017
|
+
state.retryCount = (state.retryCount ?? 0) + 1;
|
|
11018
|
+
notifications.push(notify(sessionId, {
|
|
11019
|
+
sessionUpdate: "agent_message_chunk",
|
|
11020
|
+
messageId: `msg_agent_retry_${stepIndex}_${Date.now()}`,
|
|
11021
|
+
content: {
|
|
11022
|
+
type: "text",
|
|
11023
|
+
text: `
|
|
11024
|
+
> 第 ${state.retryCount} 次尝试遇到问题,正在重试…(${detail})
|
|
11025
|
+
`
|
|
11026
|
+
}
|
|
11027
|
+
}));
|
|
11028
|
+
}
|
|
11029
|
+
return { notifications, state };
|
|
11030
|
+
}
|
|
10987
11031
|
if (stepType === "agent_response") {
|
|
10988
11032
|
const text = s.text_delta;
|
|
10989
11033
|
if (typeof text === "string" && text.length > 0) {
|
|
@@ -12286,7 +12330,7 @@ class SessionHistoryStore {
|
|
|
12286
12330
|
var AGENT_INFO = {
|
|
12287
12331
|
name: "agy-acp",
|
|
12288
12332
|
title: "agy ACP (stream-json)",
|
|
12289
|
-
version: "0.1.
|
|
12333
|
+
version: "0.1.12"
|
|
12290
12334
|
};
|
|
12291
12335
|
var BRIDGE_CAPABILITIES = {
|
|
12292
12336
|
prompt: true,
|
|
@@ -17605,6 +17649,9 @@ class AgyAcpService {
|
|
|
17605
17649
|
cancelSession(params) {
|
|
17606
17650
|
this.core.cancelSession(params);
|
|
17607
17651
|
}
|
|
17652
|
+
async shutdown() {
|
|
17653
|
+
await this.core.shutdown();
|
|
17654
|
+
}
|
|
17608
17655
|
promptSession(params, notifyClient, opts) {
|
|
17609
17656
|
const targetSession = this.core.sessions.get(params?.sessionId);
|
|
17610
17657
|
const version = params?.protocolVersion === 2 || params?.protocolVersion !== 1 && targetSession?.protocolVersion === 2 ? 2 : 1;
|
|
@@ -17712,6 +17759,7 @@ export {
|
|
|
17712
17759
|
deleteOnCloseEnabled,
|
|
17713
17760
|
discoverAgyCatalog,
|
|
17714
17761
|
escalateKill,
|
|
17762
|
+
extractErrorDetail,
|
|
17715
17763
|
extractImagePaths,
|
|
17716
17764
|
extractLaunchConfig,
|
|
17717
17765
|
fileToAcpImageBlock,
|
|
@@ -21,6 +21,8 @@ export interface MapperState {
|
|
|
21
21
|
emittedTextDelta?: boolean;
|
|
22
22
|
/** True when at least one agent_response thought_delta was emitted this turn. */
|
|
23
23
|
emittedThoughtDelta?: boolean;
|
|
24
|
+
/** Model-side retries seen this turn (error_message steps surfaced visibly). */
|
|
25
|
+
retryCount?: number;
|
|
24
26
|
/** Session roots for image allowlist (set by server). */
|
|
25
27
|
richRoots?: FileToAcpImageOpts;
|
|
26
28
|
}
|
|
@@ -33,6 +35,11 @@ export declare function createMapperState(richRoots?: FileToAcpImageOpts): Mappe
|
|
|
33
35
|
/** Reset per-turn tracking (keep conversationId / tools / richRoots / turnSeq+1). */
|
|
34
36
|
export declare function resetTurnState(state: MapperState): MapperState;
|
|
35
37
|
export declare function guessToolKind(name: unknown): string;
|
|
38
|
+
/**
|
|
39
|
+
* Pull a human-readable cause out of an error_message step. agy field names
|
|
40
|
+
* vary by failure kind, so probe the likely carriers and cap the length.
|
|
41
|
+
*/
|
|
42
|
+
export declare function extractErrorDetail(s: Record<string, unknown>, maxLen?: number): string;
|
|
36
43
|
/** Format or adapt updates according to client ACP protocol version (v1 vs v2). */
|
|
37
44
|
export declare function formatUpdateForProtocol(update: Record<string, unknown>, protocolVersion: number): Record<string, unknown> | null;
|
|
38
45
|
export interface MapAgyEventOpts {
|