@chipschat/acp 1.0.18 → 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 +1 -1
- package/dist/main.js +91 -9
- package/package.json +1 -1
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 |
|
package/dist/main.js
CHANGED
|
@@ -27179,6 +27179,7 @@ var MOST_RESPAWN_MS = 6e4;
|
|
|
27179
27179
|
var IDLE_MS = 30 * 6e4;
|
|
27180
27180
|
var ANSWERED = 500;
|
|
27181
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.";
|
|
27182
27183
|
var Bridge = class {
|
|
27183
27184
|
constructor(options) {
|
|
27184
27185
|
this.options = options;
|
|
@@ -27766,6 +27767,10 @@ var Bridge = class {
|
|
|
27766
27767
|
thought: "",
|
|
27767
27768
|
next: [],
|
|
27768
27769
|
cancelled: false,
|
|
27770
|
+
prompting: false,
|
|
27771
|
+
stopping: false,
|
|
27772
|
+
pausing: false,
|
|
27773
|
+
asking: 0,
|
|
27769
27774
|
saidAt: 0,
|
|
27770
27775
|
gaugeAt: 0,
|
|
27771
27776
|
steps: /* @__PURE__ */ new Map(),
|
|
@@ -27774,14 +27779,27 @@ var Bridge = class {
|
|
|
27774
27779
|
folds: 0
|
|
27775
27780
|
};
|
|
27776
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
|
+
};
|
|
27777
27788
|
run2.on("cancel", () => {
|
|
27778
27789
|
turn.cancelled = true;
|
|
27779
|
-
|
|
27790
|
+
interrupt();
|
|
27780
27791
|
});
|
|
27781
27792
|
run2.on("steer", (steer) => {
|
|
27782
27793
|
turn.next.push(`${steer.from?.display_name ?? "The person"} adds: ${steer.text}`);
|
|
27783
|
-
if (steer.mode === "interrupt"
|
|
27794
|
+
if (steer.mode === "interrupt") interrupt();
|
|
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();
|
|
27784
27801
|
});
|
|
27802
|
+
run2.on("resume", () => this.log(`${record2.name} resumed in ${spaceId}`));
|
|
27785
27803
|
const client = await this.running();
|
|
27786
27804
|
if (client === void 0) {
|
|
27787
27805
|
if (!run2.over) await run2.fail({ error: `${kind2.name} isn't running right now.`, retryable: true });
|
|
@@ -27808,23 +27826,64 @@ var Bridge = class {
|
|
|
27808
27826
|
if (files.length > 0) words4 = `${words4}
|
|
27809
27827
|
|
|
27810
27828
|
${files.join("\n")}`;
|
|
27811
|
-
if (turn
|
|
27829
|
+
if (!await this.unpaused(turn)) return;
|
|
27812
27830
|
this.rules.told(sessionId, rules);
|
|
27813
27831
|
let stop2 = "end_turn";
|
|
27814
|
-
|
|
27832
|
+
let prompt = words4;
|
|
27833
|
+
while (prompt !== void 0) {
|
|
27834
|
+
if (!await this.unpaused(turn)) return;
|
|
27835
|
+
turn.prompting = true;
|
|
27836
|
+
turn.stopping = false;
|
|
27815
27837
|
try {
|
|
27816
27838
|
stop2 = await client.prompt(sessionId, [{ type: "text", text: prompt }]);
|
|
27817
27839
|
} catch (error62) {
|
|
27840
|
+
turn.prompting = false;
|
|
27818
27841
|
this.rules.forget(sessionId);
|
|
27819
27842
|
if (!run2.over) await run2.fail({ error: this.failure(record2, error62), retryable: true });
|
|
27820
27843
|
return;
|
|
27821
27844
|
}
|
|
27845
|
+
turn.prompting = false;
|
|
27822
27846
|
if (turn.cancelled) return;
|
|
27823
|
-
|
|
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
|
+
}
|
|
27824
27855
|
if (stop2 !== "end_turn" && stop2 !== "cancelled") break;
|
|
27856
|
+
prompt = turn.next.shift();
|
|
27825
27857
|
}
|
|
27826
27858
|
await this.finish(room, turn, stop2);
|
|
27827
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
|
+
}
|
|
27828
27887
|
/**
|
|
27829
27888
|
* The room's session: the one it had, loaded once, or a new one, in the agent's folder, put on
|
|
27830
27889
|
* the agent's model. One a change from Chips made stale is closed and loaded again first, so the
|
|
@@ -28608,6 +28667,7 @@ ${files.join("\n")}`;
|
|
|
28608
28667
|
const turn = this.turnOf(String(params["sessionId"]));
|
|
28609
28668
|
const options = Array.isArray(params["options"]) ? params["options"] : [];
|
|
28610
28669
|
if (turn === void 0) return { outcome: { outcome: "cancelled" } };
|
|
28670
|
+
if (turn.pausing) return { outcome: { outcome: "cancelled" } };
|
|
28611
28671
|
const call = params["toolCall"] ?? {};
|
|
28612
28672
|
const kind2 = toolOf(call) ?? "other";
|
|
28613
28673
|
const title2 = typeof call["title"] === "string" ? call["title"] : `use ${kind2}`;
|
|
@@ -28620,8 +28680,7 @@ ${files.join("\n")}`;
|
|
|
28620
28680
|
...input2 === void 0 ? {} : { preview: { format: "json", body: JSON.stringify(input2, null, 2).slice(0, 2e5) } },
|
|
28621
28681
|
...call["toolCallId"] === void 0 ? {} : { stepId: String(call["toolCallId"]) }
|
|
28622
28682
|
});
|
|
28623
|
-
const
|
|
28624
|
-
const decision = await Promise.race([asked, stopped2]);
|
|
28683
|
+
const decision = await this.answerOf(turn, asked);
|
|
28625
28684
|
if (decision === void 0) return { outcome: { outcome: "cancelled" } };
|
|
28626
28685
|
const chosen = optionFor(decision, options, carriesCommand(input2));
|
|
28627
28686
|
if (decision.allowed && chosen !== void 0 && call["toolCallId"] !== void 0) {
|
|
@@ -28641,8 +28700,10 @@ ${files.join("\n")}`;
|
|
|
28641
28700
|
if (turn === void 0 || questions.length === 0 || questions.length > 4 || questions.some((q) => q === void 0)) {
|
|
28642
28701
|
return { action: "decline" };
|
|
28643
28702
|
}
|
|
28644
|
-
|
|
28645
|
-
|
|
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" };
|
|
28646
28707
|
const content = {};
|
|
28647
28708
|
for (const [id2, field] of properties) {
|
|
28648
28709
|
const value = answer.answers[id2]?.values[0];
|
|
@@ -28651,6 +28712,26 @@ ${files.join("\n")}`;
|
|
|
28651
28712
|
}
|
|
28652
28713
|
return { action: "accept", content };
|
|
28653
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
|
+
}
|
|
28654
28735
|
};
|
|
28655
28736
|
function settingsFor(kind2, bridge2) {
|
|
28656
28737
|
const active = () => {
|
|
@@ -28836,6 +28917,7 @@ function keepIfAsked(label2, url2, names, log2, before = () => void 0) {
|
|
|
28836
28917
|
1
|
|
28837
28918
|
);
|
|
28838
28919
|
}
|
|
28920
|
+
if (kept2.state !== "off" && kept2.state !== "unsupported") return;
|
|
28839
28921
|
log2(
|
|
28840
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."
|
|
28841
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": {
|