@chipschat/acp 1.0.17 → 1.0.19
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.md +3 -2
- package/dist/THIRD-PARTY-NOTICES.md +3 -3
- package/dist/main.js +141 -14
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -159,9 +159,10 @@ minutes and loaded again with its memory. Fourteen runs, none failed, $0.35, all
|
|
|
159
159
|
| The reply | `agent_message_chunk`s gathered into one message; `NO_REPLY` alone is the turn passed |
|
|
160
160
|
| Files in the reply | each `MEDIA:<path>` line of the reply sent as an upload with its words, only from the agent's folder (`sendAnswer`); the post says why one could not go |
|
|
161
161
|
| Approval card | `session/request_permission`, asked in the agent's own words where the call has a `description` (Claude Code's commands: "Syntax-check game.js? `node --check game.js`"), else "Allow it to" and the call's title; allowed always picks `allow_always`, except for a command, which picks `allow_once` since Chips remembers it by how each part starts (Chips ADR 0239); no picks `reject_once`; Stop answers `cancelled`; the card hears how the call went |
|
|
162
|
-
| Question card | `elicitation/create` form of up to four choice or yes/no fields; anything else is declined |
|
|
162
|
+
| Question card | `elicitation/create` form of up to four choice or yes/no fields; anything else is declined; Stop answers `cancel` |
|
|
163
163
|
| Stop | `session/cancel` |
|
|
164
|
-
|
|
|
164
|
+
| Pause (Chips ADR 0293) | each run says `pausable: true` as it starts; Pause is `session/cancel` with the run kept and nothing posted, and Resume the next prompt of the same session: "You were paused partway through this. Carry on from where you stopped. Nothing you wrote before the pause reached the room, so write your whole reply.", then anything steered meanwhile. A Pause before a prompt holds it; one while an approval or question card waits stops nothing, and the answer reaches the agent on Resume |
|
|
165
|
+
| Steer | the next prompt of the same run, after `session/cancel` when it interrupts; the words it was cut off in are dropped, so the reply is one answer |
|
|
165
166
|
| Not right? (Chips ADR 0200) | a `correction`, or an older device's 👎: one more turn of the agent who said the reply (by its id in the room's lines), in that room's session, quoting its reply and what was wrong; the run is *Looking again: …*; a 👍 or any other reaction is nothing, and each is answered once |
|
|
166
167
|
| Restart | the agent's process stopped and run again |
|
|
167
168
|
| Trouble | the agent not running; it is run again after 2 s, longer each time it fails to start |
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Third-party notices
|
|
2
2
|
|
|
3
|
-
`dist/main.js` in @chipschat/acp 1.0.
|
|
3
|
+
`dist/main.js` in @chipschat/acp 1.0.19 carries these packages, bundled in. Each one's
|
|
4
4
|
licence follows.
|
|
5
5
|
|
|
6
|
-
## @chipschat/harness 1.0.
|
|
6
|
+
## @chipschat/harness 1.0.4 (Apache-2.0)
|
|
7
7
|
|
|
8
8
|
Apache License
|
|
9
9
|
Version 2.0, January 2004
|
|
@@ -207,7 +207,7 @@ Apache License
|
|
|
207
207
|
See the License for the specific language governing permissions and
|
|
208
208
|
limitations under the License.
|
|
209
209
|
|
|
210
|
-
## @chipschat/protocol 1.0.
|
|
210
|
+
## @chipschat/protocol 1.0.4 (Apache-2.0)
|
|
211
211
|
|
|
212
212
|
Apache License
|
|
213
213
|
Version 2.0, January 2004
|
package/dist/main.js
CHANGED
|
@@ -24283,6 +24283,8 @@ function refusalOf(kind2, error62) {
|
|
|
24283
24283
|
}
|
|
24284
24284
|
|
|
24285
24285
|
// node_modules/@chipschat/harness/dist/connect.js
|
|
24286
|
+
var HELD_MOST = 2e4;
|
|
24287
|
+
var OF_THE_CONNECTION = /* @__PURE__ */ new Set(["hello", "state", "receipt"]);
|
|
24286
24288
|
function agentOf(body) {
|
|
24287
24289
|
return {
|
|
24288
24290
|
agentId: String(body["agent_id"]),
|
|
@@ -24312,12 +24314,25 @@ var Chips = class _Chips {
|
|
|
24312
24314
|
/** Makes each ping's `ts` its own, so two in one millisecond are still told apart. */
|
|
24313
24315
|
pings = 0;
|
|
24314
24316
|
/**
|
|
24315
|
-
* Events held back, and why: one hold until the harness
|
|
24316
|
-
*
|
|
24317
|
-
*
|
|
24317
|
+
* Events held back, and why: one hold until the harness is listening, and one for each
|
|
24318
|
+
* catch-up on asked rooms still reading, so that a room's first words heard live and read from
|
|
24319
|
+
* its history are handed over once. Delivered in order when none is left.
|
|
24320
|
+
*
|
|
24321
|
+
* The first hold used to last one tick after `connect` resolved. Three bridges looked for git
|
|
24322
|
+
* and listed their agents before they attached a handler, so what `since` replayed was handed
|
|
24323
|
+
* to nobody, and the place in the log moved past it: a message sent while a bridge was down was
|
|
24324
|
+
* never answered (9 November 2026). An event nothing here could take is not heard. So the hold
|
|
24325
|
+
* lasts until something takes events: a handler, a waiter, a run, or a handler for rooms asked
|
|
24326
|
+
* (ADR 0289).
|
|
24318
24327
|
*/
|
|
24319
24328
|
held = [];
|
|
24320
24329
|
holds = 1;
|
|
24330
|
+
/** The handshake is done: `connect` has resolved. */
|
|
24331
|
+
started = false;
|
|
24332
|
+
/** Something here takes events (`listens`). */
|
|
24333
|
+
listening = false;
|
|
24334
|
+
/** The first hold is on its way out. */
|
|
24335
|
+
letting = false;
|
|
24321
24336
|
askHandlers = new Emitter();
|
|
24322
24337
|
asks = new Asks(() => this.me()?.harness_id, {
|
|
24323
24338
|
listening: () => this.askHandlers.count("asked") > 0,
|
|
@@ -24359,7 +24374,8 @@ var Chips = class _Chips {
|
|
|
24359
24374
|
const chips2 = new _Chips(options);
|
|
24360
24375
|
await chips2.open(true);
|
|
24361
24376
|
chips2.endOrphans();
|
|
24362
|
-
|
|
24377
|
+
chips2.started = true;
|
|
24378
|
+
chips2.letGo();
|
|
24363
24379
|
return chips2;
|
|
24364
24380
|
}
|
|
24365
24381
|
get state() {
|
|
@@ -24457,8 +24473,17 @@ var Chips = class _Chips {
|
|
|
24457
24473
|
get lastSeq() {
|
|
24458
24474
|
return this.since;
|
|
24459
24475
|
}
|
|
24476
|
+
/**
|
|
24477
|
+
* Hear events by name, or all of them as `event`. What `since` replayed, and what was said
|
|
24478
|
+
* since the connection opened, is handed over a tick after the first handler is attached:
|
|
24479
|
+
* attach every handler together, and all of them hear it. `hello`, `state` and `receipt` are
|
|
24480
|
+
* the connection's own, and attaching one of those alone starts nothing.
|
|
24481
|
+
*/
|
|
24460
24482
|
on(name, handler) {
|
|
24461
|
-
|
|
24483
|
+
const off = this.emitter.on(name, handler);
|
|
24484
|
+
if (!OF_THE_CONNECTION.has(name))
|
|
24485
|
+
this.listens();
|
|
24486
|
+
return off;
|
|
24462
24487
|
}
|
|
24463
24488
|
/** Say something in a space. */
|
|
24464
24489
|
post(input2) {
|
|
@@ -24488,6 +24513,7 @@ var Chips = class _Chips {
|
|
|
24488
24513
|
*/
|
|
24489
24514
|
onSpaceAsked(handler) {
|
|
24490
24515
|
const off = this.askHandlers.on("asked", handler);
|
|
24516
|
+
this.listens();
|
|
24491
24517
|
if (this.ready)
|
|
24492
24518
|
void this.catchUp();
|
|
24493
24519
|
return off;
|
|
@@ -24602,6 +24628,7 @@ var Chips = class _Chips {
|
|
|
24602
24628
|
lanes: this.lanes
|
|
24603
24629
|
}, laneId);
|
|
24604
24630
|
this.activeRuns.set(runId, run2);
|
|
24631
|
+
this.listens();
|
|
24605
24632
|
return run2;
|
|
24606
24633
|
}
|
|
24607
24634
|
/**
|
|
@@ -24702,6 +24729,7 @@ var Chips = class _Chips {
|
|
|
24702
24729
|
}
|
|
24703
24730
|
/** Resolve with the first event that matches, now or later. */
|
|
24704
24731
|
waitFor(match) {
|
|
24732
|
+
this.listens();
|
|
24705
24733
|
return new Promise((resolve5) => {
|
|
24706
24734
|
this.waiters.add({ match, resolve: resolve5 });
|
|
24707
24735
|
});
|
|
@@ -24925,6 +24953,21 @@ var Chips = class _Chips {
|
|
|
24925
24953
|
return;
|
|
24926
24954
|
}
|
|
24927
24955
|
}
|
|
24956
|
+
/** Something here takes events from now on, so the first hold can go. */
|
|
24957
|
+
listens() {
|
|
24958
|
+
this.listening = true;
|
|
24959
|
+
this.letGo();
|
|
24960
|
+
}
|
|
24961
|
+
/**
|
|
24962
|
+
* Let the first hold go, once the handshake is done and the harness is listening: on the next
|
|
24963
|
+
* tick, so handlers attached together all hear what was held.
|
|
24964
|
+
*/
|
|
24965
|
+
letGo() {
|
|
24966
|
+
if (!this.started || !this.listening || this.letting)
|
|
24967
|
+
return;
|
|
24968
|
+
this.letting = true;
|
|
24969
|
+
setTimeout(() => this.release(), 0);
|
|
24970
|
+
}
|
|
24928
24971
|
/** Let one hold go; with none left, deliver what was held, in order. */
|
|
24929
24972
|
release() {
|
|
24930
24973
|
this.holds -= 1;
|
|
@@ -24938,6 +24981,8 @@ var Chips = class _Chips {
|
|
|
24938
24981
|
onEvent(event) {
|
|
24939
24982
|
if (this.holds > 0) {
|
|
24940
24983
|
this.held.push(event);
|
|
24984
|
+
if (!this.listening && this.held.length > HELD_MOST)
|
|
24985
|
+
this.held.shift();
|
|
24941
24986
|
return;
|
|
24942
24987
|
}
|
|
24943
24988
|
const seq = event["seq"];
|
|
@@ -27134,6 +27179,7 @@ var MOST_RESPAWN_MS = 6e4;
|
|
|
27134
27179
|
var IDLE_MS = 30 * 6e4;
|
|
27135
27180
|
var ANSWERED = 500;
|
|
27136
27181
|
var QUOTED = 1500;
|
|
27182
|
+
var CARRY_ON = "You were paused partway through this. Carry on from where you stopped. Nothing you wrote before the pause reached the room, so write your whole reply.";
|
|
27137
27183
|
var Bridge = class {
|
|
27138
27184
|
constructor(options) {
|
|
27139
27185
|
this.options = options;
|
|
@@ -27721,6 +27767,10 @@ var Bridge = class {
|
|
|
27721
27767
|
thought: "",
|
|
27722
27768
|
next: [],
|
|
27723
27769
|
cancelled: false,
|
|
27770
|
+
prompting: false,
|
|
27771
|
+
stopping: false,
|
|
27772
|
+
pausing: false,
|
|
27773
|
+
asking: 0,
|
|
27724
27774
|
saidAt: 0,
|
|
27725
27775
|
gaugeAt: 0,
|
|
27726
27776
|
steps: /* @__PURE__ */ new Map(),
|
|
@@ -27729,14 +27779,27 @@ var Bridge = class {
|
|
|
27729
27779
|
folds: 0
|
|
27730
27780
|
};
|
|
27731
27781
|
room.turn = turn;
|
|
27782
|
+
this.sayPausable(run2, speakerId);
|
|
27783
|
+
const interrupt = () => {
|
|
27784
|
+
if (!turn.prompting || turn.stopping) return;
|
|
27785
|
+
turn.stopping = true;
|
|
27786
|
+
this.process.client?.cancel(turn.sessionId);
|
|
27787
|
+
};
|
|
27732
27788
|
run2.on("cancel", () => {
|
|
27733
27789
|
turn.cancelled = true;
|
|
27734
|
-
|
|
27790
|
+
interrupt();
|
|
27735
27791
|
});
|
|
27736
27792
|
run2.on("steer", (steer) => {
|
|
27737
27793
|
turn.next.push(`${steer.from?.display_name ?? "The person"} adds: ${steer.text}`);
|
|
27738
|
-
if (steer.mode === "interrupt"
|
|
27794
|
+
if (steer.mode === "interrupt") interrupt();
|
|
27739
27795
|
});
|
|
27796
|
+
run2.on("pause", () => {
|
|
27797
|
+
this.log(`${record2.name} paused in ${spaceId}`);
|
|
27798
|
+
if (turn.asking > 0 || !turn.prompting) return;
|
|
27799
|
+
turn.pausing = true;
|
|
27800
|
+
interrupt();
|
|
27801
|
+
});
|
|
27802
|
+
run2.on("resume", () => this.log(`${record2.name} resumed in ${spaceId}`));
|
|
27740
27803
|
const client = await this.running();
|
|
27741
27804
|
if (client === void 0) {
|
|
27742
27805
|
if (!run2.over) await run2.fail({ error: `${kind2.name} isn't running right now.`, retryable: true });
|
|
@@ -27763,23 +27826,64 @@ var Bridge = class {
|
|
|
27763
27826
|
if (files.length > 0) words4 = `${words4}
|
|
27764
27827
|
|
|
27765
27828
|
${files.join("\n")}`;
|
|
27766
|
-
if (turn
|
|
27829
|
+
if (!await this.unpaused(turn)) return;
|
|
27767
27830
|
this.rules.told(sessionId, rules);
|
|
27768
27831
|
let stop2 = "end_turn";
|
|
27769
|
-
|
|
27832
|
+
let prompt = words4;
|
|
27833
|
+
while (prompt !== void 0) {
|
|
27834
|
+
if (!await this.unpaused(turn)) return;
|
|
27835
|
+
turn.prompting = true;
|
|
27836
|
+
turn.stopping = false;
|
|
27770
27837
|
try {
|
|
27771
27838
|
stop2 = await client.prompt(sessionId, [{ type: "text", text: prompt }]);
|
|
27772
27839
|
} catch (error62) {
|
|
27840
|
+
turn.prompting = false;
|
|
27773
27841
|
this.rules.forget(sessionId);
|
|
27774
27842
|
if (!run2.over) await run2.fail({ error: this.failure(record2, error62), retryable: true });
|
|
27775
27843
|
return;
|
|
27776
27844
|
}
|
|
27845
|
+
turn.prompting = false;
|
|
27777
27846
|
if (turn.cancelled) return;
|
|
27778
|
-
|
|
27847
|
+
const paused = turn.pausing;
|
|
27848
|
+
turn.pausing = false;
|
|
27849
|
+
if (!await this.unpaused(turn)) return;
|
|
27850
|
+
if (stop2 === "cancelled" && (paused || turn.next.length > 0)) {
|
|
27851
|
+
turn.reply = "";
|
|
27852
|
+
prompt = paused ? [CARRY_ON, ...turn.next.splice(0)].join("\n\n") : turn.next.shift();
|
|
27853
|
+
continue;
|
|
27854
|
+
}
|
|
27779
27855
|
if (stop2 !== "end_turn" && stop2 !== "cancelled") break;
|
|
27856
|
+
prompt = turn.next.shift();
|
|
27780
27857
|
}
|
|
27781
27858
|
await this.finish(room, turn, stop2);
|
|
27782
27859
|
}
|
|
27860
|
+
/**
|
|
27861
|
+
* Once the run isn't paused (Chips ADR 0293): true to go on, false when it was stopped, before or
|
|
27862
|
+
* while it waited, which ends the turn with nothing more said, as a Stop does.
|
|
27863
|
+
*/
|
|
27864
|
+
async unpaused(turn) {
|
|
27865
|
+
if (turn.run.paused) await turn.run.whenRunning();
|
|
27866
|
+
return !turn.cancelled && !turn.run.over;
|
|
27867
|
+
}
|
|
27868
|
+
/**
|
|
27869
|
+
* That the run can pause (Chips ADR 0293), said once as it starts on a status of "Thinking…".
|
|
27870
|
+
* The SDK this is built on, 1.0.4, has no word for it in `run.status()`, so it goes on the
|
|
27871
|
+
* connection in the run's own envelope, as one of its agents' when it is theirs. A server from
|
|
27872
|
+
* before drops the word, and a send that fails costs the turn nothing.
|
|
27873
|
+
*/
|
|
27874
|
+
sayPausable(run2, speakerId) {
|
|
27875
|
+
const envelope2 = {
|
|
27876
|
+
space_id: run2.spaceId,
|
|
27877
|
+
run_id: run2.id,
|
|
27878
|
+
...speakerId === void 0 ? {} : { actor: { kind: "agent", id: speakerId } }
|
|
27879
|
+
};
|
|
27880
|
+
const unsaid = (error62) => this.log(`couldn't say run ${run2.id} can pause: ${messageOf(error62)}`);
|
|
27881
|
+
try {
|
|
27882
|
+
void this.options.chips.send("run.status", envelope2, { phase: "thinking", verb_phrase: "Thinking\u2026", pausable: true }).catch(unsaid);
|
|
27883
|
+
} catch (error62) {
|
|
27884
|
+
unsaid(error62);
|
|
27885
|
+
}
|
|
27886
|
+
}
|
|
27783
27887
|
/**
|
|
27784
27888
|
* The room's session: the one it had, loaded once, or a new one, in the agent's folder, put on
|
|
27785
27889
|
* the agent's model. One a change from Chips made stale is closed and loaded again first, so the
|
|
@@ -28563,6 +28667,7 @@ ${files.join("\n")}`;
|
|
|
28563
28667
|
const turn = this.turnOf(String(params["sessionId"]));
|
|
28564
28668
|
const options = Array.isArray(params["options"]) ? params["options"] : [];
|
|
28565
28669
|
if (turn === void 0) return { outcome: { outcome: "cancelled" } };
|
|
28670
|
+
if (turn.pausing) return { outcome: { outcome: "cancelled" } };
|
|
28566
28671
|
const call = params["toolCall"] ?? {};
|
|
28567
28672
|
const kind2 = toolOf(call) ?? "other";
|
|
28568
28673
|
const title2 = typeof call["title"] === "string" ? call["title"] : `use ${kind2}`;
|
|
@@ -28575,8 +28680,7 @@ ${files.join("\n")}`;
|
|
|
28575
28680
|
...input2 === void 0 ? {} : { preview: { format: "json", body: JSON.stringify(input2, null, 2).slice(0, 2e5) } },
|
|
28576
28681
|
...call["toolCallId"] === void 0 ? {} : { stepId: String(call["toolCallId"]) }
|
|
28577
28682
|
});
|
|
28578
|
-
const
|
|
28579
|
-
const decision = await Promise.race([asked, stopped2]);
|
|
28683
|
+
const decision = await this.answerOf(turn, asked);
|
|
28580
28684
|
if (decision === void 0) return { outcome: { outcome: "cancelled" } };
|
|
28581
28685
|
const chosen = optionFor(decision, options, carriesCommand(input2));
|
|
28582
28686
|
if (decision.allowed && chosen !== void 0 && call["toolCallId"] !== void 0) {
|
|
@@ -28596,8 +28700,10 @@ ${files.join("\n")}`;
|
|
|
28596
28700
|
if (turn === void 0 || questions.length === 0 || questions.length > 4 || questions.some((q) => q === void 0)) {
|
|
28597
28701
|
return { action: "decline" };
|
|
28598
28702
|
}
|
|
28599
|
-
|
|
28600
|
-
|
|
28703
|
+
if (turn.pausing) return { action: "cancel" };
|
|
28704
|
+
const asked = turn.run.question({ questions });
|
|
28705
|
+
const answer = await this.answerOf(turn, asked);
|
|
28706
|
+
if (answer === void 0 || answer.timedOut) return { action: "cancel" };
|
|
28601
28707
|
const content = {};
|
|
28602
28708
|
for (const [id2, field] of properties) {
|
|
28603
28709
|
const value = answer.answers[id2]?.values[0];
|
|
@@ -28606,6 +28712,26 @@ ${files.join("\n")}`;
|
|
|
28606
28712
|
}
|
|
28607
28713
|
return { action: "accept", content };
|
|
28608
28714
|
}
|
|
28715
|
+
/**
|
|
28716
|
+
* A person's answer to what the agent asked, once the agent may have it: one given while the run
|
|
28717
|
+
* is paused waits for Resume (Chips ADR 0293), and a Stop, before the answer or while it waits,
|
|
28718
|
+
* leaves none. While an ask waits, a Pause stops nothing.
|
|
28719
|
+
*/
|
|
28720
|
+
async answerOf(turn, asked) {
|
|
28721
|
+
let off = () => void 0;
|
|
28722
|
+
const stopped2 = new Promise((resolve5) => {
|
|
28723
|
+
off = turn.run.on("cancel", () => resolve5(void 0));
|
|
28724
|
+
});
|
|
28725
|
+
turn.asking += 1;
|
|
28726
|
+
try {
|
|
28727
|
+
const answer = await Promise.race([asked, stopped2]);
|
|
28728
|
+
if (answer === void 0) return void 0;
|
|
28729
|
+
return await this.unpaused(turn) ? answer : void 0;
|
|
28730
|
+
} finally {
|
|
28731
|
+
off();
|
|
28732
|
+
turn.asking -= 1;
|
|
28733
|
+
}
|
|
28734
|
+
}
|
|
28609
28735
|
};
|
|
28610
28736
|
function settingsFor(kind2, bridge2) {
|
|
28611
28737
|
const active = () => {
|
|
@@ -28791,6 +28917,7 @@ function keepIfAsked(label2, url2, names, log2, before = () => void 0) {
|
|
|
28791
28917
|
1
|
|
28792
28918
|
);
|
|
28793
28919
|
}
|
|
28920
|
+
if (kept2.state !== "off" && kept2.state !== "unsupported") return;
|
|
28794
28921
|
log2(
|
|
28795
28922
|
kept2.state === "off" ? "Keeping it running is off here (CHIPS_KEEP=off): it runs here, while this terminal is open." : "Nothing on this machine can keep it running (launchd, systemd): it runs here, while this terminal is open."
|
|
28796
28923
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chipschat/acp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"description": "An agent that speaks the Agent Client Protocol, as a Chips harness of its kind: agents made from Chips, each in a folder of its own, each room a session.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"release": "npm run build && npm test && npm pack"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@chipschat/conformance": "1.0.
|
|
37
|
-
"@chipschat/harness": "1.0.
|
|
38
|
-
"@chipschat/protocol": "1.0.
|
|
36
|
+
"@chipschat/conformance": "1.0.4",
|
|
37
|
+
"@chipschat/harness": "1.0.4",
|
|
38
|
+
"@chipschat/protocol": "1.0.4",
|
|
39
39
|
"@types/node": "22.19.0",
|
|
40
40
|
"esbuild": "0.27.7",
|
|
41
41
|
"tsx": "4.21.0",
|