@hearsay-tools/squawk 0.18.0-pr4008.7635 → 0.18.0-pr4009.7642
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/delegation/routes.d.ts +65 -65
- package/dist/runners/acp/events.d.ts +28 -0
- package/dist/runners/acp/events.js +182 -0
- package/dist/runners/acp/events.js.map +1 -0
- package/dist/runners/acp/protocol.d.ts +58 -0
- package/dist/runners/acp/protocol.js +14 -0
- package/dist/runners/acp/protocol.js.map +1 -0
- package/dist/runners/acp/session.d.ts +65 -0
- package/dist/runners/acp/session.js +195 -0
- package/dist/runners/acp/session.js.map +1 -0
- package/dist/runners/acp/transport.d.ts +37 -0
- package/dist/runners/acp/transport.js +133 -0
- package/dist/runners/acp/transport.js.map +1 -0
- package/package.json +4 -4
- package/scripts/mock-acp.mjs +107 -0
|
@@ -27,18 +27,6 @@ export declare function delegationFailure(error: unknown): {
|
|
|
27
27
|
export declare function createDelegationRoutes(service: DelegationService, credentials: CredentialRegistry): import("hono/hono-base").HonoBase<Env, {
|
|
28
28
|
"/list": {
|
|
29
29
|
$get: {
|
|
30
|
-
output: {
|
|
31
|
-
error: string;
|
|
32
|
-
code?: "invalid_input" | undefined;
|
|
33
|
-
};
|
|
34
|
-
outputFormat: "json";
|
|
35
|
-
status: 400;
|
|
36
|
-
input: {
|
|
37
|
-
query: {
|
|
38
|
-
offset?: string | undefined;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
} | {
|
|
42
30
|
output: {
|
|
43
31
|
workers: {
|
|
44
32
|
workerId: string;
|
|
@@ -85,6 +73,18 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
85
73
|
offset?: string | undefined;
|
|
86
74
|
};
|
|
87
75
|
};
|
|
76
|
+
} | {
|
|
77
|
+
output: {
|
|
78
|
+
error: string;
|
|
79
|
+
code?: "invalid_input" | undefined;
|
|
80
|
+
};
|
|
81
|
+
outputFormat: "json";
|
|
82
|
+
status: 400;
|
|
83
|
+
input: {
|
|
84
|
+
query: {
|
|
85
|
+
offset?: string | undefined;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
88
|
};
|
|
89
89
|
};
|
|
90
90
|
} & {
|
|
@@ -623,18 +623,6 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
623
623
|
} & {
|
|
624
624
|
"/:workerId": {
|
|
625
625
|
$get: {
|
|
626
|
-
output: {
|
|
627
|
-
error: string;
|
|
628
|
-
code?: "invalid_input" | undefined;
|
|
629
|
-
};
|
|
630
|
-
outputFormat: "json";
|
|
631
|
-
status: 400;
|
|
632
|
-
input: {
|
|
633
|
-
param: {
|
|
634
|
-
workerId: string;
|
|
635
|
-
};
|
|
636
|
-
};
|
|
637
|
-
} | {
|
|
638
626
|
output: {
|
|
639
627
|
workerId: string;
|
|
640
628
|
settled: boolean;
|
|
@@ -752,11 +740,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
752
740
|
workerId: string;
|
|
753
741
|
};
|
|
754
742
|
};
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
} & {
|
|
758
|
-
"/:workerId/collect": {
|
|
759
|
-
$post: {
|
|
743
|
+
} | {
|
|
760
744
|
output: {
|
|
761
745
|
error: string;
|
|
762
746
|
code?: "invalid_input" | undefined;
|
|
@@ -767,10 +751,12 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
767
751
|
param: {
|
|
768
752
|
workerId: string;
|
|
769
753
|
};
|
|
770
|
-
} & {
|
|
771
|
-
json: Record<string, never>;
|
|
772
754
|
};
|
|
773
|
-
}
|
|
755
|
+
};
|
|
756
|
+
};
|
|
757
|
+
} & {
|
|
758
|
+
"/:workerId/collect": {
|
|
759
|
+
$post: {
|
|
774
760
|
output: {
|
|
775
761
|
workerId: string;
|
|
776
762
|
parentRunId: string;
|
|
@@ -893,11 +879,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
893
879
|
} & {
|
|
894
880
|
json: Record<string, never>;
|
|
895
881
|
};
|
|
896
|
-
}
|
|
897
|
-
};
|
|
898
|
-
} & {
|
|
899
|
-
"/:workerId/steer": {
|
|
900
|
-
$post: {
|
|
882
|
+
} | {
|
|
901
883
|
output: {
|
|
902
884
|
error: string;
|
|
903
885
|
code?: "invalid_input" | undefined;
|
|
@@ -909,11 +891,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
909
891
|
workerId: string;
|
|
910
892
|
};
|
|
911
893
|
} & {
|
|
912
|
-
json:
|
|
913
|
-
text: string;
|
|
914
|
-
};
|
|
894
|
+
json: Record<string, never>;
|
|
915
895
|
};
|
|
916
|
-
}
|
|
896
|
+
};
|
|
897
|
+
};
|
|
898
|
+
} & {
|
|
899
|
+
"/:workerId/steer": {
|
|
900
|
+
$post: {
|
|
917
901
|
output: {
|
|
918
902
|
workerId: string;
|
|
919
903
|
state: "delivered" | "queued";
|
|
@@ -929,11 +913,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
929
913
|
text: string;
|
|
930
914
|
};
|
|
931
915
|
};
|
|
932
|
-
}
|
|
933
|
-
};
|
|
934
|
-
} & {
|
|
935
|
-
"/:workerId/stop": {
|
|
936
|
-
$post: {
|
|
916
|
+
} | {
|
|
937
917
|
output: {
|
|
938
918
|
error: string;
|
|
939
919
|
code?: "invalid_input" | undefined;
|
|
@@ -945,9 +925,15 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
945
925
|
workerId: string;
|
|
946
926
|
};
|
|
947
927
|
} & {
|
|
948
|
-
json:
|
|
928
|
+
json: {
|
|
929
|
+
text: string;
|
|
930
|
+
};
|
|
949
931
|
};
|
|
950
|
-
}
|
|
932
|
+
};
|
|
933
|
+
};
|
|
934
|
+
} & {
|
|
935
|
+
"/:workerId/stop": {
|
|
936
|
+
$post: {
|
|
951
937
|
output: {
|
|
952
938
|
workerId: string;
|
|
953
939
|
state: "stopping" | "terminated";
|
|
@@ -961,11 +947,7 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
961
947
|
} & {
|
|
962
948
|
json: Record<string, never>;
|
|
963
949
|
};
|
|
964
|
-
}
|
|
965
|
-
};
|
|
966
|
-
} & {
|
|
967
|
-
"/:workerId/destroy": {
|
|
968
|
-
$post: {
|
|
950
|
+
} | {
|
|
969
951
|
output: {
|
|
970
952
|
error: string;
|
|
971
953
|
code?: "invalid_input" | undefined;
|
|
@@ -977,11 +959,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
977
959
|
workerId: string;
|
|
978
960
|
};
|
|
979
961
|
} & {
|
|
980
|
-
json:
|
|
981
|
-
discardWork?: true | undefined;
|
|
982
|
-
};
|
|
962
|
+
json: Record<string, never>;
|
|
983
963
|
};
|
|
984
|
-
}
|
|
964
|
+
};
|
|
965
|
+
};
|
|
966
|
+
} & {
|
|
967
|
+
"/:workerId/destroy": {
|
|
968
|
+
$post: {
|
|
985
969
|
output: {
|
|
986
970
|
workerId: string;
|
|
987
971
|
state: "complete" | "incomplete";
|
|
@@ -1010,6 +994,22 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
1010
994
|
discardWork?: true | undefined;
|
|
1011
995
|
};
|
|
1012
996
|
};
|
|
997
|
+
} | {
|
|
998
|
+
output: {
|
|
999
|
+
error: string;
|
|
1000
|
+
code?: "invalid_input" | undefined;
|
|
1001
|
+
};
|
|
1002
|
+
outputFormat: "json";
|
|
1003
|
+
status: 400;
|
|
1004
|
+
input: {
|
|
1005
|
+
param: {
|
|
1006
|
+
workerId: string;
|
|
1007
|
+
};
|
|
1008
|
+
} & {
|
|
1009
|
+
json: {
|
|
1010
|
+
discardWork?: true | undefined;
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
1013
|
} | {
|
|
1014
1014
|
output: {
|
|
1015
1015
|
workerId: string;
|
|
@@ -1045,11 +1045,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
1045
1045
|
"/:workerId/diff": {
|
|
1046
1046
|
$get: {
|
|
1047
1047
|
output: {
|
|
1048
|
-
|
|
1049
|
-
|
|
1048
|
+
workerId: string;
|
|
1049
|
+
baselineSha: string;
|
|
1050
|
+
diff: string;
|
|
1051
|
+
truncated: boolean;
|
|
1050
1052
|
};
|
|
1051
1053
|
outputFormat: "json";
|
|
1052
|
-
status:
|
|
1054
|
+
status: 200;
|
|
1053
1055
|
input: {
|
|
1054
1056
|
param: {
|
|
1055
1057
|
workerId: string;
|
|
@@ -1057,13 +1059,11 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
1057
1059
|
};
|
|
1058
1060
|
} | {
|
|
1059
1061
|
output: {
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
diff: string;
|
|
1063
|
-
truncated: boolean;
|
|
1062
|
+
error: string;
|
|
1063
|
+
code?: "invalid_input" | undefined;
|
|
1064
1064
|
};
|
|
1065
1065
|
outputFormat: "json";
|
|
1066
|
-
status:
|
|
1066
|
+
status: 400;
|
|
1067
1067
|
input: {
|
|
1068
1068
|
param: {
|
|
1069
1069
|
workerId: string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AgentEvent } from '../../core/agent-runner.ts';
|
|
2
|
+
import type { UiEvent, StopReason } from '../../core/ui-events.ts';
|
|
3
|
+
import type { AcpHooks } from './protocol.ts';
|
|
4
|
+
export interface AcpEventSink {
|
|
5
|
+
event?(event: AgentEvent): void;
|
|
6
|
+
uiEvent?(event: UiEvent): void;
|
|
7
|
+
}
|
|
8
|
+
/** Stateful ACP-v1 -> Squawk v1/v2 mapping. No provider names or tool arguments live here. */
|
|
9
|
+
export declare class AcpEvents {
|
|
10
|
+
private readonly sink;
|
|
11
|
+
private readonly hooks;
|
|
12
|
+
private serial;
|
|
13
|
+
private turnId;
|
|
14
|
+
private block;
|
|
15
|
+
private tools;
|
|
16
|
+
constructor(sink: AcpEventSink, hooks: AcpHooks);
|
|
17
|
+
begin(): string;
|
|
18
|
+
finish(stopReason: StopReason): void;
|
|
19
|
+
update(update: Record<string, unknown>): void;
|
|
20
|
+
notice(message: string): void;
|
|
21
|
+
private mapUpdate;
|
|
22
|
+
private content;
|
|
23
|
+
private plan;
|
|
24
|
+
private flush;
|
|
25
|
+
private usage;
|
|
26
|
+
private tool;
|
|
27
|
+
private toolImages;
|
|
28
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const toolSchema = z.object({
|
|
3
|
+
toolCallId: z.string(), title: z.string().nullish(), name: z.string().nullish(),
|
|
4
|
+
kind: z.enum(['read', 'edit', 'delete', 'move', 'search', 'execute', 'think', 'fetch', 'switch_mode', 'other']).catch('other').nullish(),
|
|
5
|
+
status: z.enum(['pending', 'in_progress', 'completed', 'failed']).nullish().catch(undefined),
|
|
6
|
+
rawInput: z.unknown().optional(), rawOutput: z.unknown().optional(),
|
|
7
|
+
content: z.array(z.object({ type: z.string(), content: z.object({ type: z.string(), text: z.string().optional(), data: z.string().optional(), mimeType: z.string().optional() }).optional(),
|
|
8
|
+
path: z.string().optional(), oldText: z.string().nullable().optional(), newText: z.string().optional(),
|
|
9
|
+
}).passthrough()).nullish(),
|
|
10
|
+
locations: z.array(z.object({ path: z.string(), line: z.number().optional() })).nullish(),
|
|
11
|
+
}).passthrough();
|
|
12
|
+
const planStatusSchema = z.enum(['pending', 'in_progress', 'completed']);
|
|
13
|
+
const planSchema = z.array(z.object({ content: z.string(), status: planStatusSchema.catch('pending'), priority: z.enum(['high', 'medium', 'low']) }));
|
|
14
|
+
/** Stateful ACP-v1 -> Squawk v1/v2 mapping. No provider names or tool arguments live here. */
|
|
15
|
+
export class AcpEvents {
|
|
16
|
+
sink;
|
|
17
|
+
hooks;
|
|
18
|
+
serial = 0;
|
|
19
|
+
turnId;
|
|
20
|
+
block;
|
|
21
|
+
tools = new Map();
|
|
22
|
+
constructor(sink, hooks) {
|
|
23
|
+
this.sink = sink;
|
|
24
|
+
this.hooks = hooks;
|
|
25
|
+
}
|
|
26
|
+
begin() {
|
|
27
|
+
if (this.turnId)
|
|
28
|
+
throw new Error('ACP prompt already active');
|
|
29
|
+
this.turnId = `acp-turn-${++this.serial}`;
|
|
30
|
+
this.sink.uiEvent?.({ type: 'turn.started', turnId: this.turnId });
|
|
31
|
+
return this.turnId;
|
|
32
|
+
}
|
|
33
|
+
finish(stopReason) {
|
|
34
|
+
this.flush();
|
|
35
|
+
if (!this.turnId)
|
|
36
|
+
return;
|
|
37
|
+
this.sink.uiEvent?.({ type: 'turn.completed', turnId: this.turnId, stopReason });
|
|
38
|
+
this.turnId = undefined;
|
|
39
|
+
this.sink.event?.({ type: 'turn-end' });
|
|
40
|
+
}
|
|
41
|
+
update(update) {
|
|
42
|
+
try {
|
|
43
|
+
this.mapUpdate(update);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
this.notice('ACP ignored malformed session/update');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
notice(message) {
|
|
50
|
+
this.sink.event?.({ type: 'note', message });
|
|
51
|
+
this.sink.uiEvent?.({ type: 'session.error', message, fatal: false });
|
|
52
|
+
}
|
|
53
|
+
mapUpdate(update) {
|
|
54
|
+
switch (update.sessionUpdate) {
|
|
55
|
+
case 'agent_message_chunk':
|
|
56
|
+
this.content(update.content, 'message');
|
|
57
|
+
break;
|
|
58
|
+
case 'agent_thought_chunk':
|
|
59
|
+
this.content(update.content, 'reasoning');
|
|
60
|
+
break;
|
|
61
|
+
case 'tool_call':
|
|
62
|
+
case 'tool_call_update':
|
|
63
|
+
this.tool(update);
|
|
64
|
+
break;
|
|
65
|
+
case 'plan':
|
|
66
|
+
this.plan(update.entries);
|
|
67
|
+
break;
|
|
68
|
+
case 'usage_update':
|
|
69
|
+
this.usage(update);
|
|
70
|
+
break;
|
|
71
|
+
case 'config_option_update':
|
|
72
|
+
this.hooks.normalizeOptions?.(update.configOptions);
|
|
73
|
+
break;
|
|
74
|
+
default: this.notice('ACP ignored unsupported session/update');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
content(value, kind) {
|
|
78
|
+
const content = z.object({ type: z.string(), text: z.string().optional(), data: z.string().optional(), mimeType: z.string().optional() }).parse(value);
|
|
79
|
+
if (content.type !== 'text' && content.type !== 'image') {
|
|
80
|
+
this.notice(`ACP ignored unsupported content type: ${content.type}`);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (content.type === 'image' && content.data && content.mimeType) {
|
|
84
|
+
this.sink.event?.({ type: 'image', mediaType: content.mimeType, data: content.data });
|
|
85
|
+
this.sink.uiEvent?.({ type: 'image', mediaType: content.mimeType, data: content.data });
|
|
86
|
+
}
|
|
87
|
+
if (content.type !== 'text' || content.text === undefined)
|
|
88
|
+
return;
|
|
89
|
+
if (this.block?.kind !== kind) {
|
|
90
|
+
this.flush();
|
|
91
|
+
this.block = kind === 'message'
|
|
92
|
+
? { kind, id: `acp-item-${++this.serial}`, role: 'assistant', text: '' }
|
|
93
|
+
: { kind, id: `acp-item-${++this.serial}`, text: '' };
|
|
94
|
+
this.sink.uiEvent?.({ type: 'item.started', item: { ...this.block } });
|
|
95
|
+
}
|
|
96
|
+
this.block.text += content.text;
|
|
97
|
+
this.sink.uiEvent?.({ type: 'item.delta', itemId: this.block.id, field: kind === 'message' ? 'text' : 'reasoning', delta: content.text });
|
|
98
|
+
if (kind === 'message')
|
|
99
|
+
this.sink.event?.({ type: 'text', text: content.text });
|
|
100
|
+
}
|
|
101
|
+
plan(value) {
|
|
102
|
+
const entries = planSchema.parse(value);
|
|
103
|
+
const original = z.array(z.object({ status: z.unknown() })).parse(value);
|
|
104
|
+
if (original.some(entry => !planStatusSchema.safeParse(entry.status).success))
|
|
105
|
+
this.notice('ACP normalized unknown plan status');
|
|
106
|
+
this.flush();
|
|
107
|
+
this.sink.uiEvent?.({ type: 'plan.updated', entries });
|
|
108
|
+
}
|
|
109
|
+
flush() {
|
|
110
|
+
if (this.block)
|
|
111
|
+
this.sink.uiEvent?.({ type: 'item.completed', item: { ...this.block } });
|
|
112
|
+
this.block = undefined;
|
|
113
|
+
}
|
|
114
|
+
usage(update) {
|
|
115
|
+
const usage = z.object({ used: z.number().nonnegative(), size: z.number().nonnegative(),
|
|
116
|
+
cost: z.object({ amount: z.number().nonnegative(), currency: z.string() }).optional(),
|
|
117
|
+
}).parse(update);
|
|
118
|
+
const cost = usage.cost?.currency === 'USD' ? usage.cost.amount : undefined;
|
|
119
|
+
this.sink.event?.({ type: 'token-usage', tokensUsed: usage.used });
|
|
120
|
+
if (cost !== undefined)
|
|
121
|
+
this.sink.event?.({ type: 'cost', usd: cost });
|
|
122
|
+
this.sink.uiEvent?.({ type: 'usage.updated', usage: { input: 0, output: 0, total: usage.used, contextWindow: usage.size }, ...(cost === undefined ? {} : { costUsd: cost }) });
|
|
123
|
+
}
|
|
124
|
+
tool(update) {
|
|
125
|
+
this.flush();
|
|
126
|
+
const wire = toolSchema.parse(update);
|
|
127
|
+
if (wire.kind !== update.kind || wire.status !== update.status)
|
|
128
|
+
this.notice('ACP normalized unknown tool metadata');
|
|
129
|
+
const previous = this.tools.get(wire.toolCallId);
|
|
130
|
+
const item = { ...toolItem(wire, previous),
|
|
131
|
+
...this.hooks.normalizeTool?.(update, previous),
|
|
132
|
+
};
|
|
133
|
+
this.tools.set(item.id, item);
|
|
134
|
+
if (!previous)
|
|
135
|
+
this.sink.event?.({ type: 'tool-call', id: item.id, tool: item.name, input: item.input });
|
|
136
|
+
const complete = item.status === 'completed' || item.status === 'failed';
|
|
137
|
+
if (!previous)
|
|
138
|
+
this.sink.uiEvent?.({ type: 'item.started', item: { ...item } });
|
|
139
|
+
if (complete && previous?.status !== item.status) {
|
|
140
|
+
this.sink.event?.({ type: 'tool-result', toolCallId: item.id, result: item.output ?? '', isError: item.status === 'failed' });
|
|
141
|
+
this.sink.uiEvent?.({ type: 'item.completed', item: { ...item } });
|
|
142
|
+
}
|
|
143
|
+
else if (previous)
|
|
144
|
+
this.sink.uiEvent?.({ type: 'item.updated', item: { ...item } });
|
|
145
|
+
this.toolImages(wire, item.id);
|
|
146
|
+
}
|
|
147
|
+
toolImages(wire, itemId) {
|
|
148
|
+
for (const entry of wire.content ?? []) {
|
|
149
|
+
const content = entry.content;
|
|
150
|
+
if (content?.type !== 'image' || !content.data || !content.mimeType)
|
|
151
|
+
continue;
|
|
152
|
+
this.sink.event?.({ type: 'image', mediaType: content.mimeType, data: content.data });
|
|
153
|
+
this.sink.uiEvent?.({ type: 'image', itemId, mediaType: content.mimeType, data: content.data });
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function toolItem(wire, previous) {
|
|
158
|
+
return {
|
|
159
|
+
kind: 'tool', id: wire.toolCallId, ...previous,
|
|
160
|
+
name: wire.name ?? previous?.name ?? wire.title ?? 'tool',
|
|
161
|
+
title: wire.title ?? previous?.title ?? 'Tool call',
|
|
162
|
+
toolKind: wire.kind === 'switch_mode' ? 'other' : wire.kind ?? previous?.toolKind ?? 'other',
|
|
163
|
+
status: wire.status === 'in_progress' ? 'running' : wire.status ?? previous?.status ?? 'pending',
|
|
164
|
+
...(wire.rawInput == null ? {} : { input: wire.rawInput }),
|
|
165
|
+
...toolContent(wire),
|
|
166
|
+
...(wire.locations == null ? {} : { locations: wire.locations.map(location => ({ path: location.path,
|
|
167
|
+
...(location.line === undefined ? {} : { line: location.line }),
|
|
168
|
+
})) }),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function toolContent(wire) {
|
|
172
|
+
const fields = {};
|
|
173
|
+
if (wire.content) {
|
|
174
|
+
fields.output = wire.content.flatMap(c => c.content?.type === 'text' ? [c.content.text ?? ''] : []).join('\n');
|
|
175
|
+
fields.diffs = wire.content.flatMap(c => c.type === 'diff' && c.path && c.newText !== undefined
|
|
176
|
+
? [{ path: c.path, oldText: c.oldText ?? null, newText: c.newText }] : []);
|
|
177
|
+
}
|
|
178
|
+
if (wire.rawOutput != null)
|
|
179
|
+
fields.output = typeof wire.rawOutput === 'string' ? wire.rawOutput : JSON.stringify(wire.rawOutput);
|
|
180
|
+
return fields;
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/runners/acp/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IAC/E,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE;IACxI,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC;IAC5F,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACnE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAA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,MAAM,GAAyC,EAAE,CAAC;IACxD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/G,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS;YAC7F,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/E,CAAC;IACD,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI;QAAE,MAAM,CAAC,MAAM,GAAG,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjI,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { UiAskRequestedEvent, UiToolItem } from '../../core/ui-events.ts';
|
|
3
|
+
export declare const recordSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
4
|
+
export declare const initializeSchema: z.ZodObject<{
|
|
5
|
+
protocolVersion: z.ZodLiteral<1>;
|
|
6
|
+
agentCapabilities: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
7
|
+
authMethods: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
}, z.core.$loose>>>;
|
|
11
|
+
agentInfo: z.ZodOptional<z.ZodObject<{
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
version: z.ZodString;
|
|
14
|
+
}, z.core.$loose>>;
|
|
15
|
+
}, z.core.$loose>;
|
|
16
|
+
export type AcpInitializeResult = z.infer<typeof initializeSchema>;
|
|
17
|
+
export declare const permissionSchema: z.ZodObject<{
|
|
18
|
+
sessionId: z.ZodString;
|
|
19
|
+
toolCall: z.ZodObject<{
|
|
20
|
+
toolCallId: z.ZodString;
|
|
21
|
+
title: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$loose>;
|
|
23
|
+
options: z.ZodArray<z.ZodObject<{
|
|
24
|
+
optionId: z.ZodString;
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
kind: z.ZodEnum<{
|
|
27
|
+
allow_always: "allow_always";
|
|
28
|
+
allow_once: "allow_once";
|
|
29
|
+
reject_always: "reject_always";
|
|
30
|
+
reject_once: "reject_once";
|
|
31
|
+
}>;
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
}, z.core.$loose>;
|
|
34
|
+
export type AcpPermissionRequest = z.infer<typeof permissionSchema>;
|
|
35
|
+
export type AcpPermissionOutcome = {
|
|
36
|
+
outcome: 'selected';
|
|
37
|
+
optionId: string;
|
|
38
|
+
} | {
|
|
39
|
+
outcome: 'cancelled';
|
|
40
|
+
};
|
|
41
|
+
export interface AcpAsk {
|
|
42
|
+
questions: UiAskRequestedEvent['questions'];
|
|
43
|
+
/** ACP extensions encode answers differently. Only the runner knows that shape. */
|
|
44
|
+
answer(value: unknown): unknown;
|
|
45
|
+
}
|
|
46
|
+
export interface AcpHooks {
|
|
47
|
+
selectAuthMethod?(hello: AcpInitializeResult): string | undefined;
|
|
48
|
+
/** Return additional session/new, resume or load fields, including _meta. */
|
|
49
|
+
sessionParams?(method: 'new' | 'resume' | 'load', params: Record<string, unknown>): Record<string, unknown>;
|
|
50
|
+
normalizeTool?(update: Record<string, unknown>, previous: UiToolItem | undefined): Partial<Omit<UiToolItem, 'id' | 'kind'>>;
|
|
51
|
+
normalizeOptions?(options: unknown): void;
|
|
52
|
+
permissionPolicy?(request: AcpPermissionRequest): AcpPermissionOutcome | undefined;
|
|
53
|
+
permissionAsk?(request: AcpPermissionRequest): AcpAsk | undefined;
|
|
54
|
+
/** Only advertise filesystem reads when this callback is provided. */
|
|
55
|
+
readTextFile?(params: unknown): Promise<{
|
|
56
|
+
content: string;
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const recordSchema = z.record(z.string(), z.unknown());
|
|
3
|
+
export const initializeSchema = z.object({
|
|
4
|
+
protocolVersion: z.literal(1), agentCapabilities: recordSchema.default({}),
|
|
5
|
+
authMethods: z.array(z.object({ id: z.string(), name: z.string() }).passthrough()).default([]),
|
|
6
|
+
agentInfo: z.object({ name: z.string(), version: z.string() }).passthrough().optional(),
|
|
7
|
+
}).passthrough();
|
|
8
|
+
export const permissionSchema = z.object({
|
|
9
|
+
sessionId: z.string(), toolCall: z.object({ toolCallId: z.string(), title: z.string().optional() }).passthrough(),
|
|
10
|
+
options: z.array(z.object({ optionId: z.string(), name: z.string(),
|
|
11
|
+
kind: z.enum(['allow_once', 'allow_always', 'reject_once', 'reject_always']),
|
|
12
|
+
})).min(1),
|
|
13
|
+
}).passthrough();
|
|
14
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/runners/acp/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAA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AE,cAAc,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;KAC7E,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACX,CAAC,CAAC,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { Readable, Writable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { type AcpEventSink } from './events.ts';
|
|
4
|
+
import { AcpTransport } from './transport.ts';
|
|
5
|
+
import { type AcpHooks, type AcpInitializeResult } from './protocol.ts';
|
|
6
|
+
declare const promptResultSchema: z.ZodObject<{
|
|
7
|
+
stopReason: z.ZodEnum<{
|
|
8
|
+
cancelled: "cancelled";
|
|
9
|
+
end_turn: "end_turn";
|
|
10
|
+
max_tokens: "max_tokens";
|
|
11
|
+
max_turn_requests: "max_turn_requests";
|
|
12
|
+
refusal: "refusal";
|
|
13
|
+
}>;
|
|
14
|
+
}, z.core.$loose>;
|
|
15
|
+
export interface AcpSessionOptions extends AcpEventSink {
|
|
16
|
+
backend: string;
|
|
17
|
+
clientInfo: {
|
|
18
|
+
name: string;
|
|
19
|
+
version: string;
|
|
20
|
+
};
|
|
21
|
+
hooks?: AcpHooks;
|
|
22
|
+
onActivity?: () => void;
|
|
23
|
+
}
|
|
24
|
+
export interface AcpOpenOptions {
|
|
25
|
+
cwd: string;
|
|
26
|
+
mcpServers?: readonly Record<string, unknown>[];
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
/** Loading can replay history. A runner opts in instead of silently replaying tools. */
|
|
29
|
+
loadFallback?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** One logical ACP session on caller-owned stdio. The runner wraps this in AgentSession
|
|
32
|
+
* and owns process exit, deadlines, input delivery and its RunnerFacts. */
|
|
33
|
+
export declare class AcpSession {
|
|
34
|
+
private readonly options;
|
|
35
|
+
readonly transport: AcpTransport;
|
|
36
|
+
private readonly events;
|
|
37
|
+
private readonly hooks;
|
|
38
|
+
private hello;
|
|
39
|
+
private sessionId;
|
|
40
|
+
private opening;
|
|
41
|
+
private earlyUpdates;
|
|
42
|
+
private permissions;
|
|
43
|
+
private permissionSerial;
|
|
44
|
+
private promptActive;
|
|
45
|
+
private turnCancelled;
|
|
46
|
+
constructor(streams: {
|
|
47
|
+
input: Writable;
|
|
48
|
+
output: Readable;
|
|
49
|
+
}, options: AcpSessionOptions);
|
|
50
|
+
initialize(): Promise<AcpInitializeResult>;
|
|
51
|
+
authenticate(methodId: string): Promise<void>;
|
|
52
|
+
open(options: AcpOpenOptions): Promise<string>;
|
|
53
|
+
private openMethod;
|
|
54
|
+
prompt(content: readonly Record<string, unknown>[]): Promise<z.infer<typeof promptResultSchema>>;
|
|
55
|
+
cancel(): void;
|
|
56
|
+
setConfigOption(configId: string, value: string): Promise<unknown>;
|
|
57
|
+
respondPermission(requestId: string, optionId: string): boolean;
|
|
58
|
+
respondAsk(requestId: string, answer: unknown): boolean;
|
|
59
|
+
close(): void;
|
|
60
|
+
private requireSession;
|
|
61
|
+
private notification;
|
|
62
|
+
private request;
|
|
63
|
+
private cancelPermissions;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AcpEvents } from './events.js';
|
|
3
|
+
import { AcpRpcError, AcpTransport } from './transport.js';
|
|
4
|
+
import { initializeSchema, permissionSchema, recordSchema } from './protocol.js';
|
|
5
|
+
const updateSchema = z.object({ sessionId: z.string(), update: recordSchema });
|
|
6
|
+
const promptResultSchema = z.object({ stopReason: z.enum(['end_turn', 'max_tokens', 'max_turn_requests', 'refusal', 'cancelled']) }).passthrough();
|
|
7
|
+
/** One logical ACP session on caller-owned stdio. The runner wraps this in AgentSession
|
|
8
|
+
* and owns process exit, deadlines, input delivery and its RunnerFacts. */
|
|
9
|
+
export class AcpSession {
|
|
10
|
+
options;
|
|
11
|
+
transport;
|
|
12
|
+
events;
|
|
13
|
+
hooks;
|
|
14
|
+
hello;
|
|
15
|
+
sessionId;
|
|
16
|
+
opening = false;
|
|
17
|
+
earlyUpdates = [];
|
|
18
|
+
permissions = new Map();
|
|
19
|
+
permissionSerial = 0;
|
|
20
|
+
promptActive = false;
|
|
21
|
+
turnCancelled = false;
|
|
22
|
+
constructor(streams, options) {
|
|
23
|
+
this.options = options;
|
|
24
|
+
this.hooks = options.hooks ?? {};
|
|
25
|
+
this.events = new AcpEvents(options, this.hooks);
|
|
26
|
+
this.transport = new AcpTransport(streams, {
|
|
27
|
+
notification: (method, params) => this.notification(method, params),
|
|
28
|
+
request: (method, params) => this.request(method, params),
|
|
29
|
+
notice: message => this.events.notice(message),
|
|
30
|
+
...(options.onActivity ? { activity: options.onActivity } : {}),
|
|
31
|
+
});
|
|
32
|
+
void this.transport.completion.then(() => this.cancelPermissions());
|
|
33
|
+
}
|
|
34
|
+
async initialize() {
|
|
35
|
+
if (this.hello)
|
|
36
|
+
throw new Error('ACP already initialized');
|
|
37
|
+
this.hello = initializeSchema.parse(await this.transport.request('initialize', {
|
|
38
|
+
protocolVersion: 1, clientCapabilities: { fs: { readTextFile: !!this.hooks.readTextFile, writeTextFile: false } },
|
|
39
|
+
clientInfo: this.options.clientInfo,
|
|
40
|
+
}));
|
|
41
|
+
const method = this.hooks.selectAuthMethod?.(this.hello);
|
|
42
|
+
if (method)
|
|
43
|
+
await this.authenticate(method);
|
|
44
|
+
return this.hello;
|
|
45
|
+
}
|
|
46
|
+
async authenticate(methodId) {
|
|
47
|
+
if (!this.hello?.authMethods.some(method => method.id === methodId))
|
|
48
|
+
throw new Error(`ACP authentication method unavailable: ${methodId}`);
|
|
49
|
+
recordSchema.parse(await this.transport.request('authenticate', { methodId }));
|
|
50
|
+
}
|
|
51
|
+
async open(options) {
|
|
52
|
+
if (!this.hello)
|
|
53
|
+
throw new Error('Initialize ACP before opening a session');
|
|
54
|
+
if (this.opening || this.sessionId)
|
|
55
|
+
throw new Error('ACP session already opened');
|
|
56
|
+
this.opening = true;
|
|
57
|
+
try {
|
|
58
|
+
const method = this.openMethod(options);
|
|
59
|
+
const params = { cwd: options.cwd, mcpServers: options.mcpServers ?? [], ...(options.sessionId ? { sessionId: options.sessionId } : {}) };
|
|
60
|
+
const result = recordSchema.parse(await this.transport.request(`session/${method}`, {
|
|
61
|
+
...params, ...this.hooks.sessionParams?.(method, params),
|
|
62
|
+
}));
|
|
63
|
+
const id = method === 'new' ? z.string().min(1).parse(result.sessionId) : options.sessionId;
|
|
64
|
+
this.sessionId = id;
|
|
65
|
+
this.options.event?.({ type: 'session', sessionId: id, resumed: method !== 'new' });
|
|
66
|
+
this.options.uiEvent?.({ type: 'session.started', sessionId: id, backend: this.options.backend, cwd: options.cwd });
|
|
67
|
+
this.hooks.normalizeOptions?.(result.configOptions);
|
|
68
|
+
for (const update of this.earlyUpdates)
|
|
69
|
+
if (update.sessionId === id)
|
|
70
|
+
this.events.update(update.update);
|
|
71
|
+
return id;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
this.opening = false;
|
|
75
|
+
this.earlyUpdates = [];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
openMethod(options) {
|
|
79
|
+
if (!options.sessionId)
|
|
80
|
+
return 'new';
|
|
81
|
+
const caps = this.hello.agentCapabilities;
|
|
82
|
+
const sessions = recordSchema.safeParse(caps.sessionCapabilities);
|
|
83
|
+
if (sessions.success && sessions.data.resume !== undefined)
|
|
84
|
+
return 'resume';
|
|
85
|
+
if (options.loadFallback && caps.loadSession === true)
|
|
86
|
+
return 'load';
|
|
87
|
+
throw new Error('ACP agent does not support session/resume; session/load requires explicit opt-in');
|
|
88
|
+
}
|
|
89
|
+
async prompt(content) {
|
|
90
|
+
const sessionId = this.requireSession();
|
|
91
|
+
if (this.promptActive)
|
|
92
|
+
throw new Error('ACP prompt already active');
|
|
93
|
+
this.promptActive = true;
|
|
94
|
+
this.turnCancelled = false;
|
|
95
|
+
try {
|
|
96
|
+
this.events.begin();
|
|
97
|
+
const result = promptResultSchema.parse(await this.transport.request('session/prompt', { sessionId, prompt: content }));
|
|
98
|
+
const reason = result.stopReason === 'max_turn_requests' ? 'max_tokens' : result.stopReason;
|
|
99
|
+
this.events.finish(reason);
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
this.events.finish('error');
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
this.cancelPermissions();
|
|
108
|
+
this.promptActive = false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
cancel() {
|
|
112
|
+
const sessionId = this.requireSession();
|
|
113
|
+
this.turnCancelled = true;
|
|
114
|
+
try {
|
|
115
|
+
this.transport.notify('session/cancel', { sessionId });
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
this.cancelPermissions();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async setConfigOption(configId, value) {
|
|
122
|
+
const result = recordSchema.parse(await this.transport.request('session/set_config_option', { sessionId: this.requireSession(), configId, value }));
|
|
123
|
+
this.hooks.normalizeOptions?.(result.configOptions);
|
|
124
|
+
return result.configOptions;
|
|
125
|
+
}
|
|
126
|
+
respondPermission(requestId, optionId) {
|
|
127
|
+
const pending = this.permissions.get(requestId);
|
|
128
|
+
if (!pending || pending.ask || !pending.request.options.some(option => option.optionId === optionId))
|
|
129
|
+
return false;
|
|
130
|
+
this.permissions.delete(requestId);
|
|
131
|
+
pending.resolve({ outcome: { outcome: 'selected', optionId } });
|
|
132
|
+
this.options.uiEvent?.({ type: 'permission.resolved', requestId, optionId });
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
respondAsk(requestId, answer) {
|
|
136
|
+
const pending = this.permissions.get(requestId);
|
|
137
|
+
if (!pending?.ask)
|
|
138
|
+
return false;
|
|
139
|
+
const response = pending.ask.answer(answer);
|
|
140
|
+
this.permissions.delete(requestId);
|
|
141
|
+
pending.resolve(response);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
close() { this.cancelPermissions(); this.transport.close(); }
|
|
145
|
+
requireSession() {
|
|
146
|
+
if (!this.sessionId)
|
|
147
|
+
throw new Error('ACP session is not open');
|
|
148
|
+
return this.sessionId;
|
|
149
|
+
}
|
|
150
|
+
notification(method, params) {
|
|
151
|
+
if (method !== 'session/update')
|
|
152
|
+
return;
|
|
153
|
+
const update = updateSchema.parse(params);
|
|
154
|
+
if (this.opening)
|
|
155
|
+
this.earlyUpdates.push(update);
|
|
156
|
+
else if (update.sessionId === this.sessionId)
|
|
157
|
+
this.events.update(update.update);
|
|
158
|
+
}
|
|
159
|
+
request(method, params) {
|
|
160
|
+
if (method === 'fs/read_text_file' && this.hooks.readTextFile)
|
|
161
|
+
return this.hooks.readTextFile(params);
|
|
162
|
+
if (method !== 'session/request_permission')
|
|
163
|
+
throw new AcpRpcError(-32601, `Unsupported ACP client method: ${method}`);
|
|
164
|
+
const request = permissionSchema.parse(params);
|
|
165
|
+
if (request.sessionId !== this.sessionId)
|
|
166
|
+
throw new AcpRpcError(-32602, 'Permission requested for another session');
|
|
167
|
+
if (!this.promptActive || this.turnCancelled)
|
|
168
|
+
return { outcome: { outcome: 'cancelled' } };
|
|
169
|
+
const policy = this.hooks.permissionPolicy?.(request);
|
|
170
|
+
if (policy)
|
|
171
|
+
return { outcome: policy };
|
|
172
|
+
// Native JSON-RPC string IDs have no length bound; UI permission IDs do.
|
|
173
|
+
const requestId = `acp-permission-${++this.permissionSerial}`;
|
|
174
|
+
const ask = this.hooks.permissionAsk?.(request);
|
|
175
|
+
return new Promise(resolve => {
|
|
176
|
+
this.permissions.set(requestId, { request, resolve, ...(ask ? { ask } : {}) });
|
|
177
|
+
if (ask)
|
|
178
|
+
this.options.uiEvent?.({ type: 'ask.requested', requestId, questions: ask.questions });
|
|
179
|
+
else
|
|
180
|
+
this.options.uiEvent?.({ type: 'permission.requested', requestId, itemId: request.toolCall.toolCallId,
|
|
181
|
+
title: request.toolCall.title ?? 'Tool permission',
|
|
182
|
+
options: request.options.map(option => ({ id: option.optionId, label: option.name, kind: option.kind })),
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
cancelPermissions() {
|
|
187
|
+
for (const [requestId, pending] of this.permissions) {
|
|
188
|
+
pending.resolve({ outcome: { outcome: 'cancelled' } });
|
|
189
|
+
if (!pending.ask)
|
|
190
|
+
this.options.uiEvent?.({ type: 'permission.resolved', requestId, reason: 'cancelled' });
|
|
191
|
+
}
|
|
192
|
+
this.permissions.clear();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/runners/acp/session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAqB,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAmF,MAAM,eAAe,CAAC;AAElK,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;AAC/E,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,YAAY,EAAE,mBAAmB,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAgBnJ;2EAC2E;AAC3E,MAAM,OAAO,UAAU;IAawD,OAAO;IAZ3E,SAAS,CAAe;IAChB,MAAM,CAAY;IAClB,KAAK,CAAW;IACzB,KAAK,CAAkC;IACvC,SAAS,CAAqB;IAC9B,OAAO,GAAG,KA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AAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Readable, Writable } from 'node:stream';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
declare const idSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
4
|
+
export type RpcId = z.infer<typeof idSchema>;
|
|
5
|
+
export declare class AcpRpcError extends Error {
|
|
6
|
+
readonly code: number;
|
|
7
|
+
readonly data?: unknown;
|
|
8
|
+
constructor(code: number, message: string, data?: unknown);
|
|
9
|
+
}
|
|
10
|
+
/** ACP v1 uses one JSON-RPC object per UTF-8 line, not Content-Length headers.
|
|
11
|
+
* The caller owns the child, its deadline and process-tree cleanup. Closing this wire
|
|
12
|
+
* rejects receipts immediately; it does not claim that the child has exited. */
|
|
13
|
+
export declare class AcpTransport {
|
|
14
|
+
private readonly streams;
|
|
15
|
+
private readonly handlers;
|
|
16
|
+
private serial;
|
|
17
|
+
private failure;
|
|
18
|
+
private pending;
|
|
19
|
+
readonly completion: Promise<Error | undefined>;
|
|
20
|
+
constructor(streams: {
|
|
21
|
+
input: Writable;
|
|
22
|
+
output: Readable;
|
|
23
|
+
}, handlers: {
|
|
24
|
+
notification: (method: string, params: unknown) => void;
|
|
25
|
+
request: (method: string, params: unknown, id: RpcId) => unknown | Promise<unknown>;
|
|
26
|
+
activity?: () => void;
|
|
27
|
+
notice?: (message: string) => void;
|
|
28
|
+
});
|
|
29
|
+
request(method: string, params: unknown): Promise<unknown>;
|
|
30
|
+
notify(method: string, params: unknown): void;
|
|
31
|
+
close(error?: Error): void;
|
|
32
|
+
private write;
|
|
33
|
+
private read;
|
|
34
|
+
private notification;
|
|
35
|
+
private answer;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { readNdjson } from '../../core/ndjson.js';
|
|
3
|
+
const idSchema = z.union([z.string(), z.number()]);
|
|
4
|
+
const frameSchema = z.object({
|
|
5
|
+
jsonrpc: z.literal('2.0'), id: idSchema.optional(), method: z.string().optional(),
|
|
6
|
+
params: z.unknown().optional(), result: z.unknown().optional(),
|
|
7
|
+
error: z.object({ code: z.number(), message: z.string(), data: z.unknown().optional() }).optional(),
|
|
8
|
+
});
|
|
9
|
+
export class AcpRpcError extends Error {
|
|
10
|
+
code;
|
|
11
|
+
data;
|
|
12
|
+
constructor(code, message, data) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.code = code;
|
|
15
|
+
this.data = data;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** ACP v1 uses one JSON-RPC object per UTF-8 line, not Content-Length headers.
|
|
19
|
+
* The caller owns the child, its deadline and process-tree cleanup. Closing this wire
|
|
20
|
+
* rejects receipts immediately; it does not claim that the child has exited. */
|
|
21
|
+
export class AcpTransport {
|
|
22
|
+
streams;
|
|
23
|
+
handlers;
|
|
24
|
+
serial = 0;
|
|
25
|
+
failure;
|
|
26
|
+
pending = new Map();
|
|
27
|
+
completion;
|
|
28
|
+
constructor(streams, handlers) {
|
|
29
|
+
this.streams = streams;
|
|
30
|
+
this.handlers = handlers;
|
|
31
|
+
const fail = (error) => this.close(error);
|
|
32
|
+
streams.input.on('error', fail);
|
|
33
|
+
streams.output.on('error', fail);
|
|
34
|
+
this.completion = this.read().finally(() => {
|
|
35
|
+
streams.input.off('error', fail);
|
|
36
|
+
streams.output.off('error', fail);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
request(method, params) {
|
|
40
|
+
if (this.failure)
|
|
41
|
+
return Promise.reject(this.failure);
|
|
42
|
+
const id = ++this.serial;
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
this.pending.set(id, { resolve, reject });
|
|
45
|
+
try {
|
|
46
|
+
this.write({ jsonrpc: '2.0', id, method, params });
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
this.close(asError(error));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
notify(method, params) {
|
|
54
|
+
this.write({ jsonrpc: '2.0', method, params });
|
|
55
|
+
}
|
|
56
|
+
close(error = new Error('ACP transport closed')) {
|
|
57
|
+
this.failure ??= error;
|
|
58
|
+
for (const pending of this.pending.values())
|
|
59
|
+
pending.reject(this.failure);
|
|
60
|
+
this.pending.clear();
|
|
61
|
+
}
|
|
62
|
+
write(frame) {
|
|
63
|
+
if (this.failure)
|
|
64
|
+
throw this.failure;
|
|
65
|
+
if (!this.streams.input.writable)
|
|
66
|
+
throw new Error('ACP input is not writable');
|
|
67
|
+
this.streams.input.write(`${JSON.stringify(frame)}\n`, error => { if (error)
|
|
68
|
+
this.close(error); });
|
|
69
|
+
}
|
|
70
|
+
async read() {
|
|
71
|
+
try {
|
|
72
|
+
for await (const line of readNdjson(this.streams.output)) {
|
|
73
|
+
const frame = frameSchema.parse(JSON.parse(line));
|
|
74
|
+
this.handlers.activity?.();
|
|
75
|
+
if (frame.method !== undefined) {
|
|
76
|
+
if (frame.id === undefined)
|
|
77
|
+
this.notification(frame.method, frame.params);
|
|
78
|
+
else
|
|
79
|
+
void this.answer(frame.method, frame.params, frame.id);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
if (frame.id === undefined || (!('result' in frame) && !frame.error))
|
|
83
|
+
throw new Error('Invalid ACP response');
|
|
84
|
+
const pending = this.pending.get(frame.id);
|
|
85
|
+
this.pending.delete(frame.id);
|
|
86
|
+
if (frame.error)
|
|
87
|
+
pending?.reject(new AcpRpcError(frame.error.code, frame.error.message, frame.error.data));
|
|
88
|
+
else
|
|
89
|
+
pending?.resolve(frame.result);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
this.close();
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
const failure = asError(error);
|
|
97
|
+
this.close(failure);
|
|
98
|
+
return failure;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
notification(method, params) {
|
|
102
|
+
try {
|
|
103
|
+
this.handlers.notification(method, params);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
// A well-framed notification is not a transport failure. Provider extensions and
|
|
107
|
+
// malformed update payloads must not reject an unrelated in-flight prompt.
|
|
108
|
+
try {
|
|
109
|
+
this.handlers.notice?.(`ACP ignored ${method}: ${asError(error).message}`);
|
|
110
|
+
}
|
|
111
|
+
catch { /* A diagnostic consumer cannot turn a dropped notification into a disconnect. */ }
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async answer(method, params, id) {
|
|
115
|
+
try {
|
|
116
|
+
const result = await this.handlers.request(method, params, id);
|
|
117
|
+
this.write({ jsonrpc: '2.0', id, result });
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
if (this.failure)
|
|
121
|
+
return;
|
|
122
|
+
const rpc = error instanceof AcpRpcError ? error : new AcpRpcError(-32603, asError(error).message);
|
|
123
|
+
try {
|
|
124
|
+
this.write({ jsonrpc: '2.0', id, error: { code: rpc.code, message: rpc.message } });
|
|
125
|
+
}
|
|
126
|
+
catch (writeError) {
|
|
127
|
+
this.close(asError(writeError));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function asError(error) { return error instanceof Error ? error : new Error(String(error)); }
|
|
133
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/runners/acp/transport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AACn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4
|
"description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@babel/parser": "^8.0.8",
|
|
65
65
|
"@babel/types": "^8.0.8",
|
|
66
|
-
"@open-mercato/cezar-api-client": "0.18.0-
|
|
67
|
-
"@open-mercato/cezar-contract": "0.18.0-
|
|
66
|
+
"@open-mercato/cezar-api-client": "0.18.0-pr4009.7642",
|
|
67
|
+
"@open-mercato/cezar-contract": "0.18.0-pr4009.7642",
|
|
68
68
|
"@types/node": "^24.19.1",
|
|
69
69
|
"@types/ws": "^8.18.1",
|
|
70
70
|
"esbuild": "^0.28.1",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "bdb76361db526450ad0e3b0f009707e85b38a02e"
|
|
85
85
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ACP v1 stdio encoder. Scenarios stay in mock-scenario.mjs; this file owns only the wire.
|
|
3
|
+
import readline from 'node:readline';
|
|
4
|
+
import { appendFileSync } from 'node:fs';
|
|
5
|
+
import { scenarioFor, play } from './mock-scenario.mjs';
|
|
6
|
+
|
|
7
|
+
const write = frame => process.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', ...frame })}\n`);
|
|
8
|
+
const reply = (id, result) => write({ id, result });
|
|
9
|
+
let sessionId = 'mock-acp-session';
|
|
10
|
+
let active;
|
|
11
|
+
let serverId = 0;
|
|
12
|
+
const pending = new Map();
|
|
13
|
+
const update = value => write({ method: 'session/update', params: { sessionId, update: value } });
|
|
14
|
+
const content = (sessionUpdate, text) => update({ sessionUpdate, content: { type: 'text', text } });
|
|
15
|
+
const request = (method, params, nativeId) => new Promise(resolve => {
|
|
16
|
+
const id = nativeId ?? `agent-${++serverId}`;
|
|
17
|
+
pending.set(id, resolve);
|
|
18
|
+
write({ id, method, params });
|
|
19
|
+
});
|
|
20
|
+
const context = {
|
|
21
|
+
runner: 'acp', session: {},
|
|
22
|
+
// The shared layer has no provider MCP bridge. Its consumer supplies one.
|
|
23
|
+
unsupported: ['cezar-done', 'cezar-ask', 'cezar-wait', 'hold-cezar-done', 'hold-cezar-ask', 'busy-progress', 'multi-pr-refs', 'autonomous', 'silent-tail', 'cezar-tool', 'ci-wait', 'crash-stderr'],
|
|
24
|
+
};
|
|
25
|
+
function encoder(turn) {
|
|
26
|
+
const send = value => { if (active === turn && !turn.cancelled) update(value); };
|
|
27
|
+
const text = (sessionUpdate, value) => send({ sessionUpdate, content: { type: 'text', text: value } });
|
|
28
|
+
return {
|
|
29
|
+
open() {},
|
|
30
|
+
text: ({ parts }) => { for (const part of parts) text('agent_message_chunk', part); },
|
|
31
|
+
reasoning: step => text('agent_thought_chunk', step.text),
|
|
32
|
+
toolStart: ({ call }) => send({ sessionUpdate: 'tool_call', toolCallId: call.id, title: call.name, kind: 'other', status: 'in_progress', rawInput: call.input }),
|
|
33
|
+
toolEnd: ({ call }) => send({ sessionUpdate: 'tool_call_update', toolCallId: call.id, status: call.isError ? 'failed' : 'completed', rawOutput: call.output }),
|
|
34
|
+
progress: () => send({ sessionUpdate: 'usage_update', used: 7, size: 1048576 }),
|
|
35
|
+
end: ({ error } = {}) => { if (error) throw new Error(`mock provider ${error}`); },
|
|
36
|
+
readSteers: () => [],
|
|
37
|
+
hold: () => turn.cancelledPromise,
|
|
38
|
+
closeInput: () => process.stdin.destroy(),
|
|
39
|
+
child: () => { throw new Error('ACP mock has no subagent extension'); },
|
|
40
|
+
reply: ({ prompt }) => text('agent_message_chunk', `Investigating: ${prompt}`),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function prompt(frame) {
|
|
45
|
+
if (active) { write({ id: frame.id, error: { code: -32000, message: 'Prompt already active' } }); return; }
|
|
46
|
+
let cancel;
|
|
47
|
+
const turn = { cancelled: false, cancelledPromise: new Promise(resolve => { cancel = resolve; }), cancel: () => { turn.cancelled = true; cancel(); } };
|
|
48
|
+
active = turn;
|
|
49
|
+
const text = frame.params.prompt.filter(block => block.type === 'text').map(block => block.text).join('\n');
|
|
50
|
+
try {
|
|
51
|
+
if (text.includes('mock:acp-extended-updates')) extendedUpdates();
|
|
52
|
+
if (text.includes('mock:acp-permission') || text.includes('mock:acp-ask')) {
|
|
53
|
+
const result = await request('session/request_permission', { sessionId,
|
|
54
|
+
toolCall: { toolCallId: 'permission-tool', title: text.includes('mock:acp-ask') ? 'Question' : 'Execute command', rawInput: { command: 'pwd' } },
|
|
55
|
+
options: [{ optionId: 'allow-once', name: 'Allow once', kind: 'allow_once' }, { optionId: 'reject-once', name: 'Reject once', kind: 'reject_once' }],
|
|
56
|
+
}, text.includes('long-id') ? 'native-id-'.repeat(64) : undefined);
|
|
57
|
+
if (!turn.cancelled) content('agent_message_chunk', JSON.stringify(result));
|
|
58
|
+
} else {
|
|
59
|
+
const scenario = scenarioFor(text, context);
|
|
60
|
+
const wire = encoder(turn);
|
|
61
|
+
if (scenario) await Promise.race([play(scenario, wire), turn.cancelledPromise]);
|
|
62
|
+
else {
|
|
63
|
+
wire.text({ parts: ['Investigating: ', text] });
|
|
64
|
+
const call = { id: 'read-1', name: 'read', input: { path: 'README.md' }, output: 'mock file' };
|
|
65
|
+
wire.toolStart({ call }); wire.toolEnd({ call });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!turn.cancelled) update({ sessionUpdate: 'usage_update', used: 7, size: 1048576 });
|
|
69
|
+
reply(frame.id, { stopReason: turn.cancelled ? 'cancelled' : 'end_turn' });
|
|
70
|
+
} catch (error) { write({ id: frame.id, error: { code: -32603, message: error.message } }); }
|
|
71
|
+
finally { active = undefined; }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function extendedUpdates() {
|
|
75
|
+
content('agent_message_chunk', 'before extensions');
|
|
76
|
+
update({ sessionUpdate: 'tool_call', toolCallId: 'extended-tool', title: 'Vendor tool', kind: 'vendor_extension', status: 'in_progress' });
|
|
77
|
+
update({ sessionUpdate: 'tool_call_update', toolCallId: 'extended-tool', status: 'vendor_waiting' });
|
|
78
|
+
update({ sessionUpdate: 'plan', entries: [{ content: 'Vendor plan', status: 'cancelled', priority: 'high' }] });
|
|
79
|
+
update({ sessionUpdate: 'usage_update', used: 3 });
|
|
80
|
+
update({ sessionUpdate: 'agent_message_chunk', content: { type: 'resource_link', uri: 'file:///repo/a' } });
|
|
81
|
+
update({ sessionUpdate: 123 });
|
|
82
|
+
update({ sessionUpdate: 'vendor_update', value: {} });
|
|
83
|
+
update({ sessionUpdate: 'tool_call', toolCallId: 'bad-tool', title: 42 });
|
|
84
|
+
write({ method: 'session/update', params: { update: null } });
|
|
85
|
+
update({ sessionUpdate: 'tool_call_update', toolCallId: 'extended-tool', status: 'completed', rawOutput: 'extension survived' });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function handle(frame) {
|
|
89
|
+
if (process.env.CEZ_MOCK_STDIN_FILE) appendFileSync(process.env.CEZ_MOCK_STDIN_FILE, `${JSON.stringify(frame)}\n`);
|
|
90
|
+
if (!frame.method) { pending.get(frame.id)?.(frame.result); pending.delete(frame.id); return; }
|
|
91
|
+
switch (frame.method) {
|
|
92
|
+
case 'initialize': reply(frame.id, { protocolVersion: 1, agentCapabilities: { loadSession: true, sessionCapabilities: { resume: {} }, mcpCapabilities: { http: true, sse: true } }, authMethods: [{ id: 'mock-key', name: 'Mock key' }], agentInfo: { name: 'mock-acp', version: '1.0.0' } }); break;
|
|
93
|
+
case 'authenticate': reply(frame.id, {}); break;
|
|
94
|
+
case 'session/new':
|
|
95
|
+
update({ sessionUpdate: 'usage_update', used: 0, size: 1048576 });
|
|
96
|
+
reply(frame.id, { sessionId, configOptions: [] }); break;
|
|
97
|
+
case 'session/resume': case 'session/load': sessionId = frame.params.sessionId; reply(frame.id, { configOptions: [] }); break;
|
|
98
|
+
case 'session/set_config_option': reply(frame.id, { configOptions: [{ id: frame.params.configId, currentValue: frame.params.value }] }); break;
|
|
99
|
+
case 'session/prompt': await prompt(frame); break;
|
|
100
|
+
case 'session/cancel': active?.cancel(); break;
|
|
101
|
+
default: if (frame.id !== undefined) write({ id: frame.id, error: { code: -32601, message: `Unknown method: ${frame.method}` } });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const lines = readline.createInterface({ input: process.stdin });
|
|
106
|
+
lines.on('line', line => { void handle(JSON.parse(line)); });
|
|
107
|
+
lines.on('close', () => { active?.cancel(); for (const resolve of pending.values()) resolve({ outcome: { outcome: 'cancelled' } }); });
|