@chipschat/acp 1.0.25 → 1.0.26
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/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/main.js +25 -19
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -26200,9 +26200,9 @@ function runsKept(label2, given = {}) {
|
|
|
26200
26200
|
const env2 = given.env ?? process.env;
|
|
26201
26201
|
if (env2["XPC_SERVICE_NAME"] === label2)
|
|
26202
26202
|
return true;
|
|
26203
|
-
const
|
|
26204
|
-
if (
|
|
26205
|
-
return
|
|
26203
|
+
const started2 = env2["SYSTEMD_EXEC_PID"] ?? "";
|
|
26204
|
+
if (started2 !== "")
|
|
26205
|
+
return started2 === String(given.pid ?? process.pid);
|
|
26206
26206
|
const terminal = given.terminal ?? process.stdout.isTTY === true;
|
|
26207
26207
|
return (env2["INVOCATION_ID"] ?? "") !== "" && !terminal;
|
|
26208
26208
|
}
|
|
@@ -28296,14 +28296,14 @@ ${files.join("\n")}`;
|
|
|
28296
28296
|
if (earlier.length > 0) this.log(`${record2.name} takes ${waiting.length} messages that waited in ${spaceId} as one turn`);
|
|
28297
28297
|
if (!await this.unpaused(turn)) return;
|
|
28298
28298
|
this.rules.told(sessionId, rules);
|
|
28299
|
-
let
|
|
28299
|
+
let stop = "end_turn";
|
|
28300
28300
|
let prompt = words4;
|
|
28301
28301
|
while (prompt !== void 0) {
|
|
28302
28302
|
if (!await this.unpaused(turn)) return;
|
|
28303
28303
|
turn.prompting = true;
|
|
28304
28304
|
turn.stopping = false;
|
|
28305
28305
|
try {
|
|
28306
|
-
|
|
28306
|
+
stop = await client.prompt(sessionId, [{ type: "text", text: prompt }]);
|
|
28307
28307
|
} catch (error62) {
|
|
28308
28308
|
turn.prompting = false;
|
|
28309
28309
|
this.rules.forget(sessionId);
|
|
@@ -28320,15 +28320,15 @@ ${files.join("\n")}`;
|
|
|
28320
28320
|
const paused = turn.pausing;
|
|
28321
28321
|
turn.pausing = false;
|
|
28322
28322
|
if (!await this.unpaused(turn)) return;
|
|
28323
|
-
if (
|
|
28323
|
+
if (stop === "cancelled" && (paused || turn.next.length > 0)) {
|
|
28324
28324
|
turn.reply = "";
|
|
28325
28325
|
prompt = paused ? [CARRY_ON, ...turn.next.splice(0)].join("\n\n") : turn.next.shift();
|
|
28326
28326
|
continue;
|
|
28327
28327
|
}
|
|
28328
|
-
if (
|
|
28328
|
+
if (stop !== "end_turn" && stop !== "cancelled") break;
|
|
28329
28329
|
prompt = turn.next.shift();
|
|
28330
28330
|
}
|
|
28331
|
-
await this.finish(room, turn,
|
|
28331
|
+
await this.finish(room, turn, stop);
|
|
28332
28332
|
}
|
|
28333
28333
|
/**
|
|
28334
28334
|
* Once the run isn't paused (Chips ADR 0293): true to go on, false when it was stopped, before or
|
|
@@ -28455,7 +28455,7 @@ ${files.join("\n")}`;
|
|
|
28455
28455
|
await run2.usage({ model: turn.agentName }).catch(() => void 0);
|
|
28456
28456
|
}
|
|
28457
28457
|
/** The turn is over: its words in the room, what it cost, and the run ended as it went. */
|
|
28458
|
-
async finish(room, turn,
|
|
28458
|
+
async finish(room, turn, stop) {
|
|
28459
28459
|
const { run: run2 } = turn;
|
|
28460
28460
|
if (run2.over) return;
|
|
28461
28461
|
await this.settleSteps(turn, "done");
|
|
@@ -28463,7 +28463,7 @@ ${files.join("\n")}`;
|
|
|
28463
28463
|
await run2.executed(approvalId, "executed", "The agent didn't say how it went.").catch(() => void 0);
|
|
28464
28464
|
}
|
|
28465
28465
|
if (turn.cost !== void 0) await this.sayCost(room, turn, turn.cost);
|
|
28466
|
-
if (
|
|
28466
|
+
if (stop === "refusal") {
|
|
28467
28467
|
await run2.fail({ error: `${room.record.name} refused.` });
|
|
28468
28468
|
return;
|
|
28469
28469
|
}
|
|
@@ -28480,12 +28480,12 @@ ${files.join("\n")}`;
|
|
|
28480
28480
|
this.log(`Chips held what ${room.record.name} said in ${room.spaceId} from the agents it named`);
|
|
28481
28481
|
}
|
|
28482
28482
|
}
|
|
28483
|
-
const cut2 =
|
|
28483
|
+
const cut2 = stop === "max_tokens" || stop === "max_turn_requests";
|
|
28484
28484
|
const said = post.summary;
|
|
28485
28485
|
const summary = said === "" ? "Done." : said.length <= 2e3 ? said : `${said.slice(0, 1990)}\u2026`;
|
|
28486
28486
|
await run2.complete({
|
|
28487
28487
|
summary,
|
|
28488
|
-
...cut2 ? { followUps: [`${room.record.name} stopped at its limit (${
|
|
28488
|
+
...cut2 ? { followUps: [`${room.record.name} stopped at its limit (${stop}).`] } : {}
|
|
28489
28489
|
});
|
|
28490
28490
|
}
|
|
28491
28491
|
/**
|
|
@@ -29554,6 +29554,16 @@ var link = process.env["CHIPS_JOIN_LINK"] || void 0;
|
|
|
29554
29554
|
var LABEL = `chat.chips.acp.${basename6(configTargetOf(words3[0]), ".json")}`;
|
|
29555
29555
|
if (stopping) forgetAdapter(basename6(configTargetOf(words3[0]), ".json"));
|
|
29556
29556
|
stopIfAsked(LABEL);
|
|
29557
|
+
var closing = [];
|
|
29558
|
+
var started = false;
|
|
29559
|
+
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
29560
|
+
process.on(signal, () => {
|
|
29561
|
+
for (const close of closing.reverse()) close();
|
|
29562
|
+
if (started) process.exit(0);
|
|
29563
|
+
process.removeAllListeners(signal);
|
|
29564
|
+
process.kill(process.pid, signal);
|
|
29565
|
+
});
|
|
29566
|
+
}
|
|
29557
29567
|
var log = (line) => process.stdout.write(`${(/* @__PURE__ */ new Date()).toISOString()} ${line}
|
|
29558
29568
|
`);
|
|
29559
29569
|
if (!handsOver) moveOld(configTargetOf(words3[0]), log);
|
|
@@ -29639,6 +29649,7 @@ var chips = await connect({
|
|
|
29639
29649
|
// An agent's files, its context window and its model, changed from its page (Chips ADRs 0134, 0146, 0241).
|
|
29640
29650
|
settings: settingsFor(kind, () => bridge)
|
|
29641
29651
|
});
|
|
29652
|
+
closing.push(() => chips.close());
|
|
29642
29653
|
var git = await checkGit();
|
|
29643
29654
|
if (!git.ok) log(`rooms' projects are off: ${git.why}`);
|
|
29644
29655
|
bridge = new Bridge({
|
|
@@ -29654,7 +29665,9 @@ bridge = new Bridge({
|
|
|
29654
29665
|
env,
|
|
29655
29666
|
log
|
|
29656
29667
|
});
|
|
29668
|
+
closing.push(() => bridge?.stop());
|
|
29657
29669
|
await bridge.start();
|
|
29670
|
+
started = true;
|
|
29658
29671
|
log(`connected as ${chips.harnessId} (${kind.name}), ${Object.keys(state.agents).length} agent(s)`);
|
|
29659
29672
|
await helloOnce(joined, {
|
|
29660
29673
|
name: kind.name,
|
|
@@ -29663,10 +29676,3 @@ await helloOnce(joined, {
|
|
|
29663
29676
|
chips.post({ spaceId, text: `Hi, I'm ${kind.name}. Ask me anything here, or make me an agent from any space.` })
|
|
29664
29677
|
)
|
|
29665
29678
|
}).catch((error62) => log(`hello not said: ${String(error62)}`));
|
|
29666
|
-
var stop = () => {
|
|
29667
|
-
bridge?.stop();
|
|
29668
|
-
chips.close();
|
|
29669
|
-
process.exit(0);
|
|
29670
|
-
};
|
|
29671
|
-
process.on("SIGINT", stop);
|
|
29672
|
-
process.on("SIGTERM", stop);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chipschat/acp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
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": {
|