@chipschat/acp 1.0.20 → 1.0.22
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 +2 -0
- package/dist/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/main.js +60 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -147,6 +147,8 @@ minutes and loaded again with its memory. Fourteen runs, none failed, $0.35, all
|
|
|
147
147
|
|---|---|
|
|
148
148
|
| A message for an agent | `session/prompt` with the room note and who said it (`promptFor`), files saved under `<folder>/chips-files/` |
|
|
149
149
|
| What waited for an agent (Chips ADR 0294) | one prompt once the agent is free, not one each: under the newest message's note, each message that waited said in full, oldest first, then what was said in the room after, to others. A message Chips handed over, and a Not right?, are a prompt of their own. An idle agent starts 150 ms after the first words, so all it is sent at once, as when the bridge comes back, is one prompt |
|
|
150
|
+
| What was said before an agent joined (Chips ADR 0088) | the room's last lines from before the agent was put in it (`agent.attached`'s `catch_up`), said once, at its first prompt there, under "Said in this space before you joined:", ahead of the lines since |
|
|
151
|
+
| A message Chips held (Chips ADR 0097) | when Chips answers what an agent said with `held` (the agents in the room have sent each other the workspace's hold, or a person paused them), the agent's next prompt in the room opens by saying so, once. A person's act hands a held message on, and is usually what starts that prompt: then it says the message was held until a person acted and the agents it named have it now, so the agent does not send it again. Where the agents are held still (the message's `exchange.stage` is `held`), it says they do not have it yet, so the agent tells the person what is done and what is blocked |
|
|
150
152
|
| The room | a session in the agent's folder: `session/new` the first time, `session/load` after a restart or an idle close where the agent offers it |
|
|
151
153
|
| A room from the + | `claimSpace` under a new key; Chips makes its agent; the first words are its first prompt |
|
|
152
154
|
| A new agent (Add) | a record and a folder, registered with `madeFor` and the room |
|
package/dist/main.js
CHANGED
|
@@ -26995,6 +26995,21 @@ var ContextFiles = class {
|
|
|
26995
26995
|
|
|
26996
26996
|
// src/fold.ts
|
|
26997
26997
|
var GATHER_MS = 150;
|
|
26998
|
+
function heldWords(answer, released = false) {
|
|
26999
|
+
if (answer?.held !== true) return void 0;
|
|
27000
|
+
if (released) {
|
|
27001
|
+
return "Your last message in this space was held from the agents it named until a person acted. A person has now, so Chips has handed it to them: do not send it again.";
|
|
27002
|
+
}
|
|
27003
|
+
const count = answer.exchange?.count;
|
|
27004
|
+
const since = typeof count === "number" && count > 0 ? ` (they have sent each other ${count} since a person last acted)` : "";
|
|
27005
|
+
return `Your last message in this space was held, so the agents it named do not have it yet: messages between the agents here are held${since} until a person acts. Until then, tell the person what is done and what is blocked, rather than asking the agents again.`;
|
|
27006
|
+
}
|
|
27007
|
+
var BEFORE_HEADING = "Said in this space before you joined:";
|
|
27008
|
+
function beforeOf(message, earlier, before) {
|
|
27009
|
+
const said = /* @__PURE__ */ new Set([message.message_id, ...earlier.map((each) => each.message_id)]);
|
|
27010
|
+
const lines2 = (before?.lines ?? []).filter((line) => line.message_id === void 0 || !said.has(line.message_id));
|
|
27011
|
+
return lines2.length === 0 ? void 0 : [BEFORE_HEADING, ...lines2.map(renderLine)].join("\n");
|
|
27012
|
+
}
|
|
26998
27013
|
function folds(message) {
|
|
26999
27014
|
return message.handed !== true;
|
|
27000
27015
|
}
|
|
@@ -27057,17 +27072,24 @@ function contextOf(message, earlier, answered) {
|
|
|
27057
27072
|
return { ...context, lines: context.lines.filter((line) => line.message_id === void 0 || !waited.has(line.message_id)) };
|
|
27058
27073
|
}
|
|
27059
27074
|
function promptForAll(message, options = {}) {
|
|
27060
|
-
const { earlier = [], since = [], answered = [], ...rest } = options;
|
|
27061
|
-
|
|
27075
|
+
const { earlier = [], since = [], answered = [], before, heldPost, ...rest } = options;
|
|
27076
|
+
const held = heldWords(heldPost, message.exchange?.stage !== "held");
|
|
27077
|
+
const joinedBefore = beforeOf(message, earlier, before);
|
|
27078
|
+
if (earlier.length === 0 && since.length === 0 && answered.length === 0 && held === void 0 && joinedBefore === void 0) {
|
|
27079
|
+
return promptFor(message, rest);
|
|
27080
|
+
}
|
|
27062
27081
|
const taker = rest.taker ?? (message.for?.length === 1 ? message.for[0] : void 0);
|
|
27063
27082
|
const text = [
|
|
27083
|
+
joinedBefore,
|
|
27084
|
+
renderContext(contextOf(message, earlier, answered)),
|
|
27064
27085
|
earlier.length === 0 ? void 0 : waitedWords(earlier.length + 1),
|
|
27065
27086
|
...earlier.flatMap((each) => saidOf(each, rest, taker)),
|
|
27066
27087
|
...saidOf(message, rest, taker),
|
|
27067
27088
|
sinceOf(since, earlier)
|
|
27068
27089
|
].filter((part) => part !== void 0 && part !== "").join("\n\n");
|
|
27069
|
-
const { attachments: _files, replying_to: _reply, ...bare } = message;
|
|
27070
|
-
const
|
|
27090
|
+
const { attachments: _files, replying_to: _reply, context: _lines, exchange, ...bare } = message;
|
|
27091
|
+
const chips2 = [held, exchange?.note].filter((part) => part !== void 0 && part !== "").join("\n\n");
|
|
27092
|
+
const one = { ...bare, text, ...chips2 === "" ? {} : { exchange: { ...exchange, note: chips2 } } };
|
|
27071
27093
|
return promptFor(one, { ...rest, sayWho: false });
|
|
27072
27094
|
}
|
|
27073
27095
|
|
|
@@ -27272,6 +27294,7 @@ function nextTurn(queue) {
|
|
|
27272
27294
|
}
|
|
27273
27295
|
return taken;
|
|
27274
27296
|
}
|
|
27297
|
+
var CAUGHT_UP_MOST = 200;
|
|
27275
27298
|
var Bridge = class {
|
|
27276
27299
|
constructor(options) {
|
|
27277
27300
|
this.options = options;
|
|
@@ -27295,6 +27318,11 @@ var Bridge = class {
|
|
|
27295
27318
|
knew = () => void 0;
|
|
27296
27319
|
/** What is said in the rooms is taken in the order it came: a message, then what was overheard after it. */
|
|
27297
27320
|
arriving = Promise.resolve();
|
|
27321
|
+
/**
|
|
27322
|
+
* What was said in a room before one of its agents joined it (Chips ADR 0088), by the agent and
|
|
27323
|
+
* the room: said at the agent's first turn there, and kept no longer.
|
|
27324
|
+
*/
|
|
27325
|
+
caughtUp = /* @__PURE__ */ new Map();
|
|
27298
27326
|
/** Records are made one at a time, so two never take the same folder. */
|
|
27299
27327
|
making = Promise.resolve();
|
|
27300
27328
|
/** The feedback already answered, oldest first. */
|
|
@@ -27333,6 +27361,7 @@ var Bridge = class {
|
|
|
27333
27361
|
};
|
|
27334
27362
|
chips2.on("message.new", (message) => inOrder("a message", () => this.hear(message)));
|
|
27335
27363
|
chips2.on("message.overheard", (message) => inOrder("words overheard", async () => this.overheard(message)));
|
|
27364
|
+
chips2.on("agent.attached", (attached) => this.attached(attached));
|
|
27336
27365
|
chips2.on("agent.asked", (asked) => after("a new agent", () => this.make(asked)));
|
|
27337
27366
|
chips2.on("agent.fork", (fork) => after("a copy", () => this.copy(fork)));
|
|
27338
27367
|
chips2.on("feedback", (feedback2) => after("a second look", () => this.lookAgain(feedback2)));
|
|
@@ -27777,6 +27806,19 @@ var Bridge = class {
|
|
|
27777
27806
|
}
|
|
27778
27807
|
if (again2 === void 0) this.saidToOthers(spaceId, message, takes);
|
|
27779
27808
|
}
|
|
27809
|
+
/**
|
|
27810
|
+
* One of its agents put in a room (Chips ADR 0088): the room's last lines before it joined come
|
|
27811
|
+
* with the news, and are kept for the agent's first turn there, which says them once.
|
|
27812
|
+
*/
|
|
27813
|
+
attached(attached) {
|
|
27814
|
+
const { agent_id: agentId2, space_id: spaceId, catch_up: before } = attached;
|
|
27815
|
+
if (spaceId === void 0 || before === void 0 || before.lines.length === 0) return;
|
|
27816
|
+
this.caughtUp.set(`${agentId2}|${spaceId}`, before);
|
|
27817
|
+
for (const oldest of this.caughtUp.keys()) {
|
|
27818
|
+
if (this.caughtUp.size <= CAUGHT_UP_MOST) break;
|
|
27819
|
+
this.caughtUp.delete(oldest);
|
|
27820
|
+
}
|
|
27821
|
+
}
|
|
27780
27822
|
/**
|
|
27781
27823
|
* Words said in a room to others (Chips ADR 0294): kept where a message waits for one of its
|
|
27782
27824
|
* agents there, as said after the newest of them, and told to the turn that takes it. Chips
|
|
@@ -27960,12 +28002,15 @@ var Bridge = class {
|
|
|
27960
28002
|
project
|
|
27961
28003
|
};
|
|
27962
28004
|
const rules = rulesFor(message, asked);
|
|
28005
|
+
const joined2 = `${speakerId ?? record2.agentId}|${spaceId}`;
|
|
27963
28006
|
let words4 = promptForAll(message, {
|
|
27964
28007
|
...asked,
|
|
27965
28008
|
rulesHeld: this.rules.holds(sessionId, rules),
|
|
27966
28009
|
earlier,
|
|
27967
28010
|
since,
|
|
27968
|
-
answered: room.answered
|
|
28011
|
+
answered: room.answered,
|
|
28012
|
+
before: this.caughtUp.get(joined2),
|
|
28013
|
+
heldPost: room.heldPost
|
|
27969
28014
|
});
|
|
27970
28015
|
const files = [];
|
|
27971
28016
|
for (const each of [...earlier, message]) files.push(...await this.filesFor(record2, each));
|
|
@@ -27990,7 +28035,11 @@ ${files.join("\n")}`;
|
|
|
27990
28035
|
return;
|
|
27991
28036
|
}
|
|
27992
28037
|
turn.prompting = false;
|
|
27993
|
-
if (prompt === words4)
|
|
28038
|
+
if (prompt === words4) {
|
|
28039
|
+
keepAnswered(room.answered, [...earlier, message]);
|
|
28040
|
+
this.caughtUp.delete(joined2);
|
|
28041
|
+
room.heldPost = void 0;
|
|
28042
|
+
}
|
|
27994
28043
|
if (turn.cancelled) return;
|
|
27995
28044
|
const paused = turn.pausing;
|
|
27996
28045
|
turn.pausing = false;
|
|
@@ -28133,7 +28182,11 @@ ${files.join("\n")}`;
|
|
|
28133
28182
|
const post = await sendAnswer(words4, { folders: [room.record.folder], upload: (input2) => chips2.upload(input2) });
|
|
28134
28183
|
const reply = post.text;
|
|
28135
28184
|
if (reply !== "" || post.uploadIds.length > 0) {
|
|
28136
|
-
await turn.speaker.post({ spaceId: room.spaceId, runId: run2.id, text: reply, uploadIds: post.uploadIds, change });
|
|
28185
|
+
const taken = await turn.speaker.post({ spaceId: room.spaceId, runId: run2.id, text: reply, uploadIds: post.uploadIds, change });
|
|
28186
|
+
if (taken.held === true) {
|
|
28187
|
+
room.heldPost = { held: true, ...taken.exchange === void 0 ? {} : { exchange: taken.exchange } };
|
|
28188
|
+
this.log(`Chips held what ${room.record.name} said in ${room.spaceId} from the agents it named`);
|
|
28189
|
+
}
|
|
28137
28190
|
}
|
|
28138
28191
|
const cut2 = stop2 === "max_tokens" || stop2 === "max_turn_requests";
|
|
28139
28192
|
const said = post.summary;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chipschat/acp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
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": {
|