@qilin-agent/acp 3.1.3 → 3.1.4
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.i18n.yaml +31 -31
- package/lib/index.js +59 -17
- package/lib/types/session.d.ts +8 -4
- package/package.json +23 -23
package/README.i18n.yaml
CHANGED
|
@@ -5,78 +5,78 @@
|
|
|
5
5
|
/:
|
|
6
6
|
en: b360d0052dfc5542
|
|
7
7
|
zh: 7aec4db9e8e9c442
|
|
8
|
-
/qilin-acp:
|
|
9
|
-
en:
|
|
10
|
-
zh:
|
|
11
|
-
/qilin-acp/summary:
|
|
8
|
+
/qilin-agent-acp:
|
|
9
|
+
en: 5eabd3505ec2e935
|
|
10
|
+
zh: 32da6cca8a9f2bcc
|
|
11
|
+
/qilin-agent-acp/summary:
|
|
12
12
|
en: bf65128192214b7f
|
|
13
13
|
zh: 27b09c10d947f6a1
|
|
14
|
-
/qilin-acp/table-of-contents:
|
|
14
|
+
/qilin-agent-acp/table-of-contents:
|
|
15
15
|
en: d152484eb41ac6b4
|
|
16
16
|
zh: 09388d293f9be9cb
|
|
17
|
-
/qilin-acp/use-this-package:
|
|
17
|
+
/qilin-agent-acp/use-this-package:
|
|
18
18
|
en: 014a5573a8c05663
|
|
19
19
|
zh: e45302786655eea5
|
|
20
|
-
/qilin-acp/use-this-package/when-to-choose-it:
|
|
20
|
+
/qilin-agent-acp/use-this-package/when-to-choose-it:
|
|
21
21
|
en: 58290e9360ae5091
|
|
22
22
|
zh: 672d438827ce5f1a
|
|
23
|
-
/qilin-acp/use-this-package/minimal-configuration:
|
|
24
|
-
en:
|
|
25
|
-
zh:
|
|
26
|
-
/qilin-acp/use-this-package/start-a-server:
|
|
27
|
-
en:
|
|
28
|
-
zh:
|
|
29
|
-
/qilin-acp/use-this-package/protocol-contract:
|
|
23
|
+
/qilin-agent-acp/use-this-package/minimal-configuration:
|
|
24
|
+
en: 5d5e826cadc74ec3
|
|
25
|
+
zh: 8eaff9cfd0e98cc0
|
|
26
|
+
/qilin-agent-acp/use-this-package/start-a-server:
|
|
27
|
+
en: 6b6c81b4ce6c253b
|
|
28
|
+
zh: ca5e5f083fa68289
|
|
29
|
+
/qilin-agent-acp/use-this-package/protocol-contract:
|
|
30
30
|
en: 804b87d8ebed9f8d
|
|
31
31
|
zh: 1b0c1c7269cdf040
|
|
32
|
-
/qilin-acp/understand-the-implementation:
|
|
32
|
+
/qilin-agent-acp/understand-the-implementation:
|
|
33
33
|
en: ea8afe89dbdd1934
|
|
34
34
|
zh: 6567979f92f34afd
|
|
35
|
-
/qilin-acp/understand-the-implementation/design-philosophy:
|
|
35
|
+
/qilin-agent-acp/understand-the-implementation/design-philosophy:
|
|
36
36
|
en: 009136a2e340bf99
|
|
37
37
|
zh: 35b33047ed9802ab
|
|
38
|
-
/qilin-acp/understand-the-implementation/source-map:
|
|
38
|
+
/qilin-agent-acp/understand-the-implementation/source-map:
|
|
39
39
|
en: 9f85ae4ecdb5d022
|
|
40
40
|
zh: dc2b911360768b9e
|
|
41
|
-
/qilin-acp/understand-the-implementation/admission-and-prompt-settlement:
|
|
41
|
+
/qilin-agent-acp/understand-the-implementation/admission-and-prompt-settlement:
|
|
42
42
|
en: 6485d449b5945b4a
|
|
43
43
|
zh: 90e56a9b410c9c42
|
|
44
|
-
/qilin-acp/understand-the-implementation/teardown-and-connection-ownership:
|
|
44
|
+
/qilin-agent-acp/understand-the-implementation/teardown-and-connection-ownership:
|
|
45
45
|
en: 83e7a3b268ffbb86
|
|
46
46
|
zh: 9ec7e32ce259f6c2
|
|
47
|
-
/qilin-acp/further-exploration:
|
|
47
|
+
/qilin-agent-acp/further-exploration:
|
|
48
48
|
en: 70100881dc8023eb
|
|
49
49
|
zh: eeedfdabf0d70cba
|
|
50
|
-
/qilin-acp/model-experience:
|
|
50
|
+
/qilin-agent-acp/model-experience:
|
|
51
51
|
en: 215e7ba838619b7b
|
|
52
52
|
zh: a311da3843709f90
|
|
53
|
-
/qilin-acp/model-experience/prompt-content:
|
|
53
|
+
/qilin-agent-acp/model-experience/prompt-content:
|
|
54
54
|
en: 7fca865c9895801f
|
|
55
55
|
zh: 78a0ab12c0bb0499
|
|
56
|
-
/qilin-acp/model-experience/prompt-content/what-the-model-sees:
|
|
56
|
+
/qilin-agent-acp/model-experience/prompt-content/what-the-model-sees:
|
|
57
57
|
en: e3adbb072da5ff1d
|
|
58
58
|
zh: 0af2105dd9e171d3
|
|
59
|
-
/qilin-acp/model-experience/prompt-content/token-effect:
|
|
59
|
+
/qilin-agent-acp/model-experience/prompt-content/token-effect:
|
|
60
60
|
en: 93b8f76c67bef353
|
|
61
61
|
zh: 354fa2dca0804f72
|
|
62
|
-
/qilin-acp/model-experience/prompt-content/kv-cache-effect:
|
|
62
|
+
/qilin-agent-acp/model-experience/prompt-content/kv-cache-effect:
|
|
63
63
|
en: 54946b64b26a3171
|
|
64
64
|
zh: 09550292ccfb36b0
|
|
65
|
-
/qilin-acp/model-experience/permission-decisions:
|
|
65
|
+
/qilin-agent-acp/model-experience/permission-decisions:
|
|
66
66
|
en: 2e6d83c846a3a5e1
|
|
67
67
|
zh: 8d4339c26f3d8f68
|
|
68
|
-
/qilin-acp/model-experience/permission-decisions/what-the-model-sees:
|
|
68
|
+
/qilin-agent-acp/model-experience/permission-decisions/what-the-model-sees:
|
|
69
69
|
en: 87b55e04137085c3
|
|
70
70
|
zh: cdba4acf2e38b872
|
|
71
|
-
/qilin-acp/model-experience/permission-decisions/token-effect:
|
|
71
|
+
/qilin-agent-acp/model-experience/permission-decisions/token-effect:
|
|
72
72
|
en: bd0ded535cbedb19
|
|
73
73
|
zh: 47bcaa76827f88f2
|
|
74
|
-
/qilin-acp/model-experience/permission-decisions/kv-cache-effect:
|
|
74
|
+
/qilin-agent-acp/model-experience/permission-decisions/kv-cache-effect:
|
|
75
75
|
en: 83120763a07c4b72
|
|
76
76
|
zh: 6a1a181dc4da869d
|
|
77
|
-
/qilin-acp/known-limitations-and-deferred-work:
|
|
77
|
+
/qilin-agent-acp/known-limitations-and-deferred-work:
|
|
78
78
|
en: c7ec5c39a44e6e41
|
|
79
79
|
zh: cd45b7744413faee
|
|
80
|
-
/qilin-acp/known-limitations-and-deferred-work/dev-note:
|
|
80
|
+
/qilin-agent-acp/known-limitations-and-deferred-work/dev-note:
|
|
81
81
|
en: e67f633dc6fe7773
|
|
82
82
|
zh: 3bb0c20c93f16f98
|
package/lib/index.js
CHANGED
|
@@ -787,7 +787,7 @@ var AcpSession = class AcpSession {
|
|
|
787
787
|
/* v8 ignore stop */
|
|
788
788
|
}
|
|
789
789
|
/**
|
|
790
|
-
* Admit
|
|
790
|
+
* Admit one prompt and settle after the root, descendants, and updates finish.
|
|
791
791
|
* @param params - standard ACP prompt request for this session.
|
|
792
792
|
* @param imageEnabled - connection capability advertised at initialization.
|
|
793
793
|
* @param requestSignal - JSON-RPC request cancellation signal.
|
|
@@ -809,7 +809,8 @@ var AcpSession = class AcpSession {
|
|
|
809
809
|
admissionDone: admission.promise,
|
|
810
810
|
finishAdmission: admission.resolve,
|
|
811
811
|
admissionController,
|
|
812
|
-
|
|
812
|
+
cancellationDone: Promise.withResolvers(),
|
|
813
|
+
cancelStartedIdle: false,
|
|
813
814
|
settlementStarted: false,
|
|
814
815
|
outputError: void 0,
|
|
815
816
|
agentError: void 0
|
|
@@ -848,7 +849,7 @@ var AcpSession = class AcpSession {
|
|
|
848
849
|
} finally {
|
|
849
850
|
inflight.finishAdmission();
|
|
850
851
|
}
|
|
851
|
-
if (inflight.
|
|
852
|
+
if (inflight.admissionController.signal.aborted) {
|
|
852
853
|
this.settleAfterQuiescence(inflight);
|
|
853
854
|
return { stopReason: await completion.promise };
|
|
854
855
|
}
|
|
@@ -876,6 +877,10 @@ var AcpSession = class AcpSession {
|
|
|
876
877
|
* @param event - committed durable event.
|
|
877
878
|
*/
|
|
878
879
|
onSessionEvent(session, event) {
|
|
880
|
+
if (event.type === "turn/start" && this.inflight?.turn !== void 0) {
|
|
881
|
+
this.inflight.turn = event.data.turn;
|
|
882
|
+
this.inflight.endReason = void 0;
|
|
883
|
+
}
|
|
879
884
|
try {
|
|
880
885
|
if (event.type === "assistant/message") {
|
|
881
886
|
const inflight = this.inflight?.turn === event.data.turn ? this.inflight : void 0;
|
|
@@ -909,7 +914,10 @@ var AcpSession = class AcpSession {
|
|
|
909
914
|
}
|
|
910
915
|
} finally {
|
|
911
916
|
const inflight = this.inflight;
|
|
912
|
-
if (inflight !== void 0 && event.type === "turn/end" && inflight.turn === event.data.turn)
|
|
917
|
+
if (inflight !== void 0 && event.type === "turn/end" && inflight.turn === event.data.turn) {
|
|
918
|
+
inflight.endReason = event.data.reason;
|
|
919
|
+
inflight.agentError = void 0;
|
|
920
|
+
}
|
|
913
921
|
if (event.type === "turn/end") this.modelControl.releaseTurn(event.data.turn);
|
|
914
922
|
}
|
|
915
923
|
}
|
|
@@ -926,16 +934,23 @@ var AcpSession = class AcpSession {
|
|
|
926
934
|
}
|
|
927
935
|
/**
|
|
928
936
|
* Correlate an Agent interval failure with the active ACP prompt.
|
|
929
|
-
* @param turn - failed turn number.
|
|
930
937
|
* @param error - original same-process failure.
|
|
931
938
|
*/
|
|
932
|
-
onAgentError(
|
|
939
|
+
onAgentError(error) {
|
|
933
940
|
const inflight = this.inflight;
|
|
934
941
|
if (inflight === void 0 || !inflight.messageQueued) return;
|
|
935
|
-
if (inflight.turn === turn) return;
|
|
936
942
|
inflight.agentError = new Error(errorChain(error));
|
|
937
943
|
this.settleAfterQuiescence(inflight);
|
|
938
944
|
}
|
|
945
|
+
/**
|
|
946
|
+
* Complete cancelled activity without following a later root driver.
|
|
947
|
+
* @param status - the emitted transition, which may precede a reentrant wake.
|
|
948
|
+
*/
|
|
949
|
+
onAgentStatus(status) {
|
|
950
|
+
const inflight = this.inflight;
|
|
951
|
+
if (inflight === void 0 || !inflight.messageQueued || !inflight.admissionController.signal.aborted) return;
|
|
952
|
+
if (status === "idle" || inflight.cancelStartedIdle) inflight.cancellationDone.resolve(this.outputTail);
|
|
953
|
+
}
|
|
939
954
|
/** Await every update queued before this call. */
|
|
940
955
|
drainUpdates() {
|
|
941
956
|
return this.outputTail;
|
|
@@ -961,10 +976,10 @@ var AcpSession = class AcpSession {
|
|
|
961
976
|
}
|
|
962
977
|
const subagents = this.ctx.get("subagents");
|
|
963
978
|
try {
|
|
964
|
-
await subagents?.
|
|
979
|
+
await subagents?.drainDescendants([this.agent]);
|
|
965
980
|
} catch (error) {
|
|
966
|
-
this.ctx.logger.warn(`acp:
|
|
967
|
-
failures.push(new Error("
|
|
981
|
+
this.ctx.logger.warn(`acp: subagent teardown failed: ${errorChain(error)}`);
|
|
982
|
+
failures.push(new Error("subagent teardown failed", { cause: error }));
|
|
968
983
|
}
|
|
969
984
|
try {
|
|
970
985
|
await this.ctx.sessions.flush(this.agent.session);
|
|
@@ -990,10 +1005,21 @@ var AcpSession = class AcpSession {
|
|
|
990
1005
|
cancelPrompt(detail) {
|
|
991
1006
|
const inflight = this.inflight;
|
|
992
1007
|
if (inflight === void 0) return;
|
|
993
|
-
|
|
1008
|
+
const firstCancellation = !inflight.admissionController.signal.aborted;
|
|
1009
|
+
if (firstCancellation) inflight.cancelStartedIdle = this.agent.status === "idle";
|
|
994
1010
|
inflight.admissionController.abort(new Error(detail));
|
|
995
1011
|
this.settleAfterQuiescence(inflight);
|
|
996
|
-
if (inflight.messageQueued)
|
|
1012
|
+
if (!inflight.messageQueued) {
|
|
1013
|
+
inflight.cancellationDone.resolve();
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
this.agent.cancel({ kind: "user" });
|
|
1017
|
+
if (firstCancellation) {
|
|
1018
|
+
const done = inflight.cancellationDone;
|
|
1019
|
+
this.agent.whenIdle().then(() => {
|
|
1020
|
+
done.resolve(this.outputTail);
|
|
1021
|
+
}, done.reject);
|
|
1022
|
+
}
|
|
997
1023
|
}
|
|
998
1024
|
settleAfterQuiescence(inflight) {
|
|
999
1025
|
if (inflight.settlementStarted) return;
|
|
@@ -1001,13 +1027,26 @@ var AcpSession = class AcpSession {
|
|
|
1001
1027
|
(async () => {
|
|
1002
1028
|
await inflight.admissionDone;
|
|
1003
1029
|
if (inflight.messageQueued) {
|
|
1004
|
-
|
|
1005
|
-
|
|
1030
|
+
const subagents = this.ctx.get("subagents");
|
|
1031
|
+
const cancelled = inflight.cancellationDone.promise;
|
|
1032
|
+
const isCancelled = () => inflight.admissionController.signal.aborted;
|
|
1033
|
+
const idleAt = (seq) => this.agent.status === "idle" && this.agent.session.seq === seq;
|
|
1034
|
+
while (true) {
|
|
1035
|
+
await Promise.race([this.agent.whenIdle(), cancelled]);
|
|
1036
|
+
if (isCancelled()) break;
|
|
1037
|
+
const idleSeq = this.agent.session.seq;
|
|
1038
|
+
const children = await Promise.race([subagents?.waitForChildren(this.agent), cancelled]);
|
|
1039
|
+
if (isCancelled()) break;
|
|
1040
|
+
if (children || !idleAt(idleSeq)) continue;
|
|
1041
|
+
await this.outputTail;
|
|
1042
|
+
if (isCancelled() || idleAt(idleSeq)) break;
|
|
1043
|
+
}
|
|
1044
|
+
if (isCancelled()) await cancelled;
|
|
1006
1045
|
}
|
|
1007
1046
|
/* v8 ignore next -- this prompt owns the slot until this exact settlement clears it. */
|
|
1008
1047
|
if (this.inflight !== inflight) return;
|
|
1009
1048
|
this.inflight = void 0;
|
|
1010
|
-
if (inflight.
|
|
1049
|
+
if (inflight.admissionController.signal.aborted) {
|
|
1011
1050
|
inflight.resolve("cancelled");
|
|
1012
1051
|
return;
|
|
1013
1052
|
}
|
|
@@ -1107,8 +1146,11 @@ function apply(ctx, config) {
|
|
|
1107
1146
|
ctx.on("agent/inbox/claimed", ({ agent, message, turn }) => {
|
|
1108
1147
|
ownedRecord(agent)?.onInboxClaimed(message, turn);
|
|
1109
1148
|
});
|
|
1110
|
-
ctx.on("agent/error", ({ agent,
|
|
1111
|
-
ownedRecord(agent)?.onAgentError(
|
|
1149
|
+
ctx.on("agent/error", ({ agent, error }) => {
|
|
1150
|
+
ownedRecord(agent)?.onAgentError(error);
|
|
1151
|
+
});
|
|
1152
|
+
ctx.on("agent/status", ({ agent, status }) => {
|
|
1153
|
+
ownedRecord(agent)?.onAgentStatus(status);
|
|
1112
1154
|
});
|
|
1113
1155
|
ctx.on("llm/adapters-updated", () => {
|
|
1114
1156
|
for (const record of sessions.values()) record.topologyChanged();
|
package/lib/types/session.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** One standard ACP session's Agent, configuration, prompt, update, and teardown lifecycle. */
|
|
2
2
|
import type { Context } from '@qilin-agent/kylin';
|
|
3
3
|
import { type McpServer, type PromptRequest, type PromptResponse, type SessionConfigOption, type SessionNotification } from '@agentclientprotocol/sdk';
|
|
4
|
-
import type { Agent, AgentOptions, ModelSelection } from '@qilin-agent/agent';
|
|
4
|
+
import type { Agent, AgentOptions, AgentStatus, ModelSelection } from '@qilin-agent/agent';
|
|
5
5
|
import { type UserMessage } from '@qilin-agent/llm';
|
|
6
6
|
import { type Session, type SessionEvent, type SessionId } from '@qilin-agent/session';
|
|
7
7
|
/** Inputs shared by fresh and resumed ACP session construction. */
|
|
@@ -81,7 +81,7 @@ export declare class AcpSession {
|
|
|
81
81
|
/** Resolve topology state off-chain, then serialize its notification without blocking execution updates. */
|
|
82
82
|
topologyChanged(): void;
|
|
83
83
|
/**
|
|
84
|
-
* Admit
|
|
84
|
+
* Admit one prompt and settle after the root, descendants, and updates finish.
|
|
85
85
|
* @param params - standard ACP prompt request for this session.
|
|
86
86
|
* @param imageEnabled - connection capability advertised at initialization.
|
|
87
87
|
* @param requestSignal - JSON-RPC request cancellation signal.
|
|
@@ -104,10 +104,14 @@ export declare class AcpSession {
|
|
|
104
104
|
onInboxClaimed(message: UserMessage, turn: number): void;
|
|
105
105
|
/**
|
|
106
106
|
* Correlate an Agent interval failure with the active ACP prompt.
|
|
107
|
-
* @param turn - failed turn number.
|
|
108
107
|
* @param error - original same-process failure.
|
|
109
108
|
*/
|
|
110
|
-
onAgentError(
|
|
109
|
+
onAgentError(error: unknown): void;
|
|
110
|
+
/**
|
|
111
|
+
* Complete cancelled activity without following a later root driver.
|
|
112
|
+
* @param status - the emitted transition, which may precede a reentrant wake.
|
|
113
|
+
*/
|
|
114
|
+
onAgentStatus(status: AgentStatus): void;
|
|
111
115
|
/** Await every update queued before this call. */
|
|
112
116
|
drainUpdates(): Promise<void>;
|
|
113
117
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qilin-agent/acp",
|
|
3
3
|
"description": "Automation-only Agent Client Protocol server for driving QiLin agents over JSON-RPC stdio",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.4",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -31,19 +31,19 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@agentclientprotocol/sdk": "1.4.0",
|
|
34
|
-
"@qilin-agent/brand": "3.1.
|
|
34
|
+
"@qilin-agent/brand": "3.1.4",
|
|
35
35
|
"@qilin-agent/schemastery": "~3.18.3"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@qilin-agent/kylin": "~4.0.3",
|
|
39
|
-
"@qilin-agent/
|
|
40
|
-
"@qilin-agent/llm": "3.1.
|
|
41
|
-
"@qilin-agent/
|
|
42
|
-
"@qilin-agent/
|
|
43
|
-
"@qilin-agent/session-persistence": "3.1.
|
|
44
|
-
"@qilin-agent/
|
|
45
|
-
"@qilin-agent/token-meter": "3.1.
|
|
46
|
-
"@qilin-agent/
|
|
39
|
+
"@qilin-agent/agent": "3.1.4",
|
|
40
|
+
"@qilin-agent/llm": "3.1.4",
|
|
41
|
+
"@qilin-agent/attachment": "3.1.4",
|
|
42
|
+
"@qilin-agent/session": "3.1.4",
|
|
43
|
+
"@qilin-agent/session-persistence": "3.1.4",
|
|
44
|
+
"@qilin-agent/mcp-client": "3.1.4",
|
|
45
|
+
"@qilin-agent/token-meter": "3.1.4",
|
|
46
|
+
"@qilin-agent/user-approval": "3.1.4"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"@qilin-agent/token-meter": {
|
|
@@ -52,18 +52,18 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@qilin-agent/kylin": "~4.0.3",
|
|
55
|
-
"@qilin-agent/agent-loop": "3.1.
|
|
56
|
-
"@qilin-agent/agent
|
|
57
|
-
"@qilin-agent/agent": "3.1.
|
|
58
|
-
"@qilin-agent/attachment": "3.1.
|
|
59
|
-
"@qilin-agent/
|
|
60
|
-
"@qilin-agent/
|
|
61
|
-
"@qilin-agent/session
|
|
62
|
-
"@qilin-agent/session-
|
|
63
|
-
"@qilin-agent/session-
|
|
64
|
-
"@qilin-agent/
|
|
65
|
-
"@qilin-agent/user-approval": "3.1.
|
|
66
|
-
"@qilin-agent/
|
|
67
|
-
"@qilin-agent/token-meter": "3.1.
|
|
55
|
+
"@qilin-agent/agent-loop": "3.1.4",
|
|
56
|
+
"@qilin-agent/agent": "3.1.4",
|
|
57
|
+
"@qilin-agent/agent-loop-testkit": "3.1.4",
|
|
58
|
+
"@qilin-agent/attachment": "3.1.4",
|
|
59
|
+
"@qilin-agent/llm": "3.1.4",
|
|
60
|
+
"@qilin-agent/mcp-client": "3.1.4",
|
|
61
|
+
"@qilin-agent/session": "3.1.4",
|
|
62
|
+
"@qilin-agent/session-persistence": "3.1.4",
|
|
63
|
+
"@qilin-agent/session-projection": "3.1.4",
|
|
64
|
+
"@qilin-agent/tools": "3.1.4",
|
|
65
|
+
"@qilin-agent/user-approval": "3.1.4",
|
|
66
|
+
"@qilin-agent/session-persistence-jsonl": "3.1.4",
|
|
67
|
+
"@qilin-agent/token-meter": "3.1.4"
|
|
68
68
|
}
|
|
69
69
|
}
|