quick-acp 0.0.0-stage → 0.1.0
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 +21 -0
- package/README.md +405 -2
- package/dist/acp/agent.js +371 -0
- package/dist/acp-smoke.js +163 -0
- package/dist/concurrent-test.js +101 -0
- package/dist/doctor.js +86 -0
- package/dist/e2e.js +206 -0
- package/dist/fresh-machine-e2e.js +151 -0
- package/dist/inject-turn-test.js +119 -0
- package/dist/login-cli.js +86 -0
- package/dist/main.js +77 -0
- package/dist/no-outpost-e2e.js +86 -0
- package/dist/probe.js +308 -0
- package/dist/quick/auth.js +371 -0
- package/dist/quick/codec.js +499 -0
- package/dist/quick/credstore.js +439 -0
- package/dist/quick/gateway-contract.js +104 -0
- package/dist/quick/login.js +522 -0
- package/dist/quick/oidc.js +152 -0
- package/dist/quick/session-direct.js +200 -0
- package/dist/quick/session.js +385 -0
- package/dist/quick/transport.js +343 -0
- package/dist/tools/registry.js +411 -0
- package/dist/tools/strategies.js +188 -0
- package/dist/wss-smoke.js +230 -0
- package/package.json +53 -4
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Live gateway test: connect, session_connect, and send one real turn.
|
|
4
|
+
*
|
|
5
|
+
* This is the step that proves the bridge actually works end to end. It needs a
|
|
6
|
+
* valid Quick session (obtained via the outpost), so it is NOT part of
|
|
7
|
+
* `npm run verify`.
|
|
8
|
+
*
|
|
9
|
+
* What it does, in order, printing every frame:
|
|
10
|
+
* 1. resolve a session (starts the outpost if needed)
|
|
11
|
+
* 2. dial the gateway with the five required headers
|
|
12
|
+
* 3. send session_connect and wait for any inbound frame
|
|
13
|
+
* 4. send one user_message and stream whatever comes back
|
|
14
|
+
* 5. report exactly where it stopped if it stops
|
|
15
|
+
*
|
|
16
|
+
* Usage:
|
|
17
|
+
* node dist/wss-smoke.js # full run, default prompt
|
|
18
|
+
* node dist/wss-smoke.js "your prompt" # custom prompt
|
|
19
|
+
* node dist/wss-smoke.js --frames-only # stop after session_connect
|
|
20
|
+
* QUICK_ACP_FRAMING=json-base64 node dist/wss-smoke.js
|
|
21
|
+
*/
|
|
22
|
+
import { resolveSession, startOutpost, outpostIsUp } from './quick/auth.js';
|
|
23
|
+
import { QuickTransport, buildHandshake, DEFAULT_WS_PATH, ALT_WS_PATH } from './quick/transport.js';
|
|
24
|
+
import { resolveToolMode } from './tools/strategies.js';
|
|
25
|
+
const args = process.argv.slice(2);
|
|
26
|
+
const framesOnly = args.includes('--frames-only');
|
|
27
|
+
const promptArg = args.find((a) => !a.startsWith('--'));
|
|
28
|
+
/** How long to wait for the first inbound frame after session_connect. */
|
|
29
|
+
const FIRST_FRAME_TIMEOUT_MS = 75_000;
|
|
30
|
+
/** How long to wait for the turn to finish. */
|
|
31
|
+
const TURN_TIMEOUT_MS = 240_000;
|
|
32
|
+
function log(...parts) {
|
|
33
|
+
console.log(...parts);
|
|
34
|
+
}
|
|
35
|
+
function now() {
|
|
36
|
+
return new Date().toISOString().slice(11, 23);
|
|
37
|
+
}
|
|
38
|
+
async function main() {
|
|
39
|
+
const framing = (process.env.QUICK_ACP_FRAMING === 'json-base64' ? 'json-base64' : 'cbor');
|
|
40
|
+
log('quick-acp gateway test');
|
|
41
|
+
log(' framing :', framing);
|
|
42
|
+
log(' toolmode:', resolveToolMode());
|
|
43
|
+
log('');
|
|
44
|
+
// --- 1. session ---------------------------------------------------------
|
|
45
|
+
if (!(await outpostIsUp())) {
|
|
46
|
+
log('[1/5] no outpost; starting one…');
|
|
47
|
+
const r = await startOutpost();
|
|
48
|
+
if (!r.started) {
|
|
49
|
+
log(' FAILED to start outpost:', r.reason);
|
|
50
|
+
process.exitCode = 1;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
let session;
|
|
55
|
+
try {
|
|
56
|
+
session = await resolveSession({ force: true });
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
log(' FAILED to resolve session:', e instanceof Error ? e.message : String(e));
|
|
60
|
+
process.exitCode = 1;
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
log('[1/5] session ok');
|
|
64
|
+
log(' source :', session.source);
|
|
65
|
+
log(' wsHost :', session.wsHost);
|
|
66
|
+
log(' wsPath :', session.wsPath || `(default) ${DEFAULT_WS_PATH}`);
|
|
67
|
+
log(' surface :', session.surface);
|
|
68
|
+
log(' outpost :', session.outpostId || '(empty)');
|
|
69
|
+
log(' jwt :', session.jwt.length > 24
|
|
70
|
+
? `${session.jwt.slice(0, 10)}…${session.jwt.slice(-6)} (${session.jwt.length} chars)`
|
|
71
|
+
: `(short: ${session.jwt.length} chars)`);
|
|
72
|
+
log('');
|
|
73
|
+
// --- 2. dial ------------------------------------------------------------
|
|
74
|
+
const transport = new QuickTransport(session, { framing });
|
|
75
|
+
const frames = [];
|
|
76
|
+
let firstFrameAt = 0;
|
|
77
|
+
transport.on((ev) => {
|
|
78
|
+
if (ev.type === 'open') {
|
|
79
|
+
log('[2/5] socket open');
|
|
80
|
+
firstFrameAt = Date.now();
|
|
81
|
+
}
|
|
82
|
+
else if (ev.type === 'message') {
|
|
83
|
+
frames.push(ev.body);
|
|
84
|
+
let pretty = ev.body;
|
|
85
|
+
try {
|
|
86
|
+
pretty = JSON.stringify(JSON.parse(ev.body));
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
/* keep raw */
|
|
90
|
+
}
|
|
91
|
+
log(` << ${now()} ${pretty.slice(0, 400)}`);
|
|
92
|
+
}
|
|
93
|
+
else if (ev.type === 'error') {
|
|
94
|
+
log(` !! ${now()} ${ev.body}`);
|
|
95
|
+
}
|
|
96
|
+
else if (ev.type === 'close') {
|
|
97
|
+
log(` socket closed: ${ev.code} ${ev.reason}`);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
try {
|
|
101
|
+
await transport.connect();
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
log('[2/5] DIAL FAILED:', e instanceof Error ? e.message : String(e));
|
|
105
|
+
log('');
|
|
106
|
+
log('This is the failure that matters. Things to try, in order:');
|
|
107
|
+
log(' 1. QUICK_ACP_FRAMING=json-base64 (the two code paths disagree)');
|
|
108
|
+
log(' 2. a different ws path: set QUICK_ACP_WS_PATH=' + ALT_WS_PATH);
|
|
109
|
+
log(' 3. token may be opaque, not a JWT: check `node dist/doctor.js --refresh`');
|
|
110
|
+
process.exitCode = 1;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
// --- 3. session_connect -------------------------------------------------
|
|
114
|
+
log('[3/5] sending session_connect');
|
|
115
|
+
const handshake = buildHandshake(session, { framing });
|
|
116
|
+
log(' headers:', Object.keys(handshake.headers).join(', '));
|
|
117
|
+
transport.send({
|
|
118
|
+
type: 'session_connect',
|
|
119
|
+
payload: {
|
|
120
|
+
actor_id: session.actorArn ?? '',
|
|
121
|
+
external_agent_sign_in: 1,
|
|
122
|
+
recents_promotion: 1,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
// Wait for the server to say anything at all. Silence here means the socket
|
|
126
|
+
// is up but the session was not accepted, which is a distinct failure.
|
|
127
|
+
const sawFrame = await waitFor(() => frames.length > 0, FIRST_FRAME_TIMEOUT_MS);
|
|
128
|
+
if (!sawFrame) {
|
|
129
|
+
log('');
|
|
130
|
+
log('[3/5] NO INBOUND FRAME within', `${FIRST_FRAME_TIMEOUT_MS}ms.`);
|
|
131
|
+
log(' The socket opened and session_connect was sent, but the server');
|
|
132
|
+
log(' never replied. That means the server did not accept the session —');
|
|
133
|
+
log(' most likely the token (opaque vs JWT) or the outpost id.');
|
|
134
|
+
transport.terminate(1000, 'debug_done');
|
|
135
|
+
process.exitCode = 1;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
log(`[3/5] server replied (${frames.length} frame(s) so far)`);
|
|
139
|
+
if (framesOnly) {
|
|
140
|
+
log('');
|
|
141
|
+
log('--frames-only: stopping here.');
|
|
142
|
+
transport.terminate(1000, 'debug_done');
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// --- 4. one real turn ---------------------------------------------------
|
|
146
|
+
const text = promptArg ??
|
|
147
|
+
'Reply with exactly the word: READY. Do not use any tools and do not explain.';
|
|
148
|
+
const messageId = crypto.randomUUID();
|
|
149
|
+
const threadId = crypto.randomUUID();
|
|
150
|
+
log('');
|
|
151
|
+
log('[4/5] sending user_message');
|
|
152
|
+
log(' text :', text.slice(0, 120));
|
|
153
|
+
log(' thread_id :', threadId);
|
|
154
|
+
transport.send({
|
|
155
|
+
type: 'user_message',
|
|
156
|
+
payload: {
|
|
157
|
+
thread_id: threadId,
|
|
158
|
+
text,
|
|
159
|
+
message_id: messageId,
|
|
160
|
+
agent_mode: 'smart',
|
|
161
|
+
thinking_effort: 'high',
|
|
162
|
+
user_timezone: 'UTC',
|
|
163
|
+
user_locale: 'en-US',
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
// --- 5. collect ---------------------------------------------------------
|
|
167
|
+
const startedAt = Date.now();
|
|
168
|
+
let assistantText = '';
|
|
169
|
+
const sawReply = await waitFor(() => {
|
|
170
|
+
for (const f of frames) {
|
|
171
|
+
if (!f.includes('text_delta') && !f.includes('token_usage') && !f.includes('message_start')) {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
const m = JSON.parse(f);
|
|
176
|
+
const payload = m['payload'] && typeof m['payload'] === 'object'
|
|
177
|
+
? m['payload']
|
|
178
|
+
: {};
|
|
179
|
+
if (m['type'] === 'text_delta' && typeof payload['delta'] === 'string') {
|
|
180
|
+
assistantText += payload['delta'];
|
|
181
|
+
}
|
|
182
|
+
if (m['type'] === 'token_usage' || m['type'] === 'turn_end')
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
/* not a frame we parse */
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
}, TURN_TIMEOUT_MS);
|
|
191
|
+
log('');
|
|
192
|
+
log('[5/5] result');
|
|
193
|
+
log(' frames :', frames.length);
|
|
194
|
+
log(' elapsed :', `${Date.now() - startedAt}ms`);
|
|
195
|
+
log(' reply text :', assistantText ? JSON.stringify(assistantText.slice(0, 300)) : '(none)');
|
|
196
|
+
if (sawReply && assistantText) {
|
|
197
|
+
log('');
|
|
198
|
+
log('*** SUCCESS: the gateway answered with model output. ***');
|
|
199
|
+
log('*** The bridge works end to end. ***');
|
|
200
|
+
}
|
|
201
|
+
else if (sawReply) {
|
|
202
|
+
log('');
|
|
203
|
+
log('Turn completed but no assistant text was captured.');
|
|
204
|
+
log('That means the protocol works but the frame shapes differ from what');
|
|
205
|
+
log('session.ts expects. The raw frames above show the real shape.');
|
|
206
|
+
process.exitCode = 1;
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
log('');
|
|
210
|
+
log('No turn completion within', `${TURN_TIMEOUT_MS}ms.`);
|
|
211
|
+
log('Frames received:', frames.length);
|
|
212
|
+
process.exitCode = 1;
|
|
213
|
+
}
|
|
214
|
+
transport.terminate(1000, 'done');
|
|
215
|
+
}
|
|
216
|
+
/** Poll a predicate until it is true or the timeout elapses. */
|
|
217
|
+
async function waitFor(pred, timeoutMs) {
|
|
218
|
+
const deadline = Date.now() + timeoutMs;
|
|
219
|
+
while (Date.now() < deadline) {
|
|
220
|
+
if (pred())
|
|
221
|
+
return true;
|
|
222
|
+
await new Promise((r) => setTimeout(r, 250));
|
|
223
|
+
}
|
|
224
|
+
return pred();
|
|
225
|
+
}
|
|
226
|
+
void main().catch((e) => {
|
|
227
|
+
console.error('fatal:', e instanceof Error ? (e.stack ?? e.message) : String(e));
|
|
228
|
+
process.exit(1);
|
|
229
|
+
});
|
|
230
|
+
//# sourceMappingURL=wss-smoke.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quick-acp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "ACP agent that bridges AWS Quick (Quickwork) Claude quota to standard ACP clients",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/ana52070/Quick-acp.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"acp",
|
|
13
|
+
"agent-client-protocol",
|
|
14
|
+
"quick",
|
|
15
|
+
"quickwork",
|
|
16
|
+
"claude"
|
|
17
|
+
],
|
|
18
|
+
"bin": {
|
|
19
|
+
"quick-acp": "dist/main.js",
|
|
20
|
+
"quick-acp-login": "dist/login-cli.js"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=22"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc -p tsconfig.json",
|
|
32
|
+
"dev": "node --experimental-strip-types src/main.ts",
|
|
33
|
+
"start": "node dist/main.js",
|
|
34
|
+
"login": "node dist/login-cli.js",
|
|
35
|
+
"probe": "node dist/probe.js",
|
|
36
|
+
"smoke": "node dist/acp-smoke.js",
|
|
37
|
+
"e2e": "node dist/e2e.js",
|
|
38
|
+
"e2e:no-outpost": "node dist/no-outpost-e2e.js",
|
|
39
|
+
"e2e:fresh": "node dist/fresh-machine-e2e.js",
|
|
40
|
+
"test:tools": "node dist/inject-turn-test.js",
|
|
41
|
+
"test:concurrent": "node dist/concurrent-test.js",
|
|
42
|
+
"doctor": "node dist/doctor.js",
|
|
43
|
+
"verify": "npm run build && npm run probe && npm run smoke",
|
|
44
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@zed-industries/agent-client-protocol": "^0.4.5",
|
|
48
|
+
"ws": "^8.18.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^22.10.0",
|
|
52
|
+
"@types/ws": "^8.5.13",
|
|
53
|
+
"typescript": "^5.7.2"
|
|
54
|
+
}
|
|
55
|
+
}
|