@chipschat/acp 1.0.20 → 1.0.21
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 +57 -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: the agents it named do not have the message yet, so it tells the person what is done and what is blocked rather than asking them again. Said once |
|
|
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,18 @@ var ContextFiles = class {
|
|
|
26995
26995
|
|
|
26996
26996
|
// src/fold.ts
|
|
26997
26997
|
var GATHER_MS = 150;
|
|
26998
|
+
function heldWords(answer) {
|
|
26999
|
+
if (answer?.held !== true) return void 0;
|
|
27000
|
+
const count = answer.exchange?.count;
|
|
27001
|
+
const since = typeof count === "number" && count > 0 ? ` (they have sent each other ${count} since a person last acted)` : "";
|
|
27002
|
+
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.`;
|
|
27003
|
+
}
|
|
27004
|
+
var BEFORE_HEADING = "Said in this space before you joined:";
|
|
27005
|
+
function beforeOf(message, earlier, before) {
|
|
27006
|
+
const said = /* @__PURE__ */ new Set([message.message_id, ...earlier.map((each) => each.message_id)]);
|
|
27007
|
+
const lines2 = (before?.lines ?? []).filter((line) => line.message_id === void 0 || !said.has(line.message_id));
|
|
27008
|
+
return lines2.length === 0 ? void 0 : [BEFORE_HEADING, ...lines2.map(renderLine)].join("\n");
|
|
27009
|
+
}
|
|
26998
27010
|
function folds(message) {
|
|
26999
27011
|
return message.handed !== true;
|
|
27000
27012
|
}
|
|
@@ -27057,17 +27069,24 @@ function contextOf(message, earlier, answered) {
|
|
|
27057
27069
|
return { ...context, lines: context.lines.filter((line) => line.message_id === void 0 || !waited.has(line.message_id)) };
|
|
27058
27070
|
}
|
|
27059
27071
|
function promptForAll(message, options = {}) {
|
|
27060
|
-
const { earlier = [], since = [], answered = [], ...rest } = options;
|
|
27061
|
-
|
|
27072
|
+
const { earlier = [], since = [], answered = [], before, heldPost, ...rest } = options;
|
|
27073
|
+
const held = heldWords(heldPost);
|
|
27074
|
+
const joinedBefore = beforeOf(message, earlier, before);
|
|
27075
|
+
if (earlier.length === 0 && since.length === 0 && answered.length === 0 && held === void 0 && joinedBefore === void 0) {
|
|
27076
|
+
return promptFor(message, rest);
|
|
27077
|
+
}
|
|
27062
27078
|
const taker = rest.taker ?? (message.for?.length === 1 ? message.for[0] : void 0);
|
|
27063
27079
|
const text = [
|
|
27080
|
+
joinedBefore,
|
|
27081
|
+
renderContext(contextOf(message, earlier, answered)),
|
|
27064
27082
|
earlier.length === 0 ? void 0 : waitedWords(earlier.length + 1),
|
|
27065
27083
|
...earlier.flatMap((each) => saidOf(each, rest, taker)),
|
|
27066
27084
|
...saidOf(message, rest, taker),
|
|
27067
27085
|
sinceOf(since, earlier)
|
|
27068
27086
|
].filter((part) => part !== void 0 && part !== "").join("\n\n");
|
|
27069
|
-
const { attachments: _files, replying_to: _reply, ...bare } = message;
|
|
27070
|
-
const
|
|
27087
|
+
const { attachments: _files, replying_to: _reply, context: _lines, exchange, ...bare } = message;
|
|
27088
|
+
const chips2 = [held, exchange?.note].filter((part) => part !== void 0 && part !== "").join("\n\n");
|
|
27089
|
+
const one = { ...bare, text, ...chips2 === "" ? {} : { exchange: { ...exchange, note: chips2 } } };
|
|
27071
27090
|
return promptFor(one, { ...rest, sayWho: false });
|
|
27072
27091
|
}
|
|
27073
27092
|
|
|
@@ -27272,6 +27291,7 @@ function nextTurn(queue) {
|
|
|
27272
27291
|
}
|
|
27273
27292
|
return taken;
|
|
27274
27293
|
}
|
|
27294
|
+
var CAUGHT_UP_MOST = 200;
|
|
27275
27295
|
var Bridge = class {
|
|
27276
27296
|
constructor(options) {
|
|
27277
27297
|
this.options = options;
|
|
@@ -27295,6 +27315,11 @@ var Bridge = class {
|
|
|
27295
27315
|
knew = () => void 0;
|
|
27296
27316
|
/** What is said in the rooms is taken in the order it came: a message, then what was overheard after it. */
|
|
27297
27317
|
arriving = Promise.resolve();
|
|
27318
|
+
/**
|
|
27319
|
+
* What was said in a room before one of its agents joined it (Chips ADR 0088), by the agent and
|
|
27320
|
+
* the room: said at the agent's first turn there, and kept no longer.
|
|
27321
|
+
*/
|
|
27322
|
+
caughtUp = /* @__PURE__ */ new Map();
|
|
27298
27323
|
/** Records are made one at a time, so two never take the same folder. */
|
|
27299
27324
|
making = Promise.resolve();
|
|
27300
27325
|
/** The feedback already answered, oldest first. */
|
|
@@ -27333,6 +27358,7 @@ var Bridge = class {
|
|
|
27333
27358
|
};
|
|
27334
27359
|
chips2.on("message.new", (message) => inOrder("a message", () => this.hear(message)));
|
|
27335
27360
|
chips2.on("message.overheard", (message) => inOrder("words overheard", async () => this.overheard(message)));
|
|
27361
|
+
chips2.on("agent.attached", (attached) => this.attached(attached));
|
|
27336
27362
|
chips2.on("agent.asked", (asked) => after("a new agent", () => this.make(asked)));
|
|
27337
27363
|
chips2.on("agent.fork", (fork) => after("a copy", () => this.copy(fork)));
|
|
27338
27364
|
chips2.on("feedback", (feedback2) => after("a second look", () => this.lookAgain(feedback2)));
|
|
@@ -27777,6 +27803,19 @@ var Bridge = class {
|
|
|
27777
27803
|
}
|
|
27778
27804
|
if (again2 === void 0) this.saidToOthers(spaceId, message, takes);
|
|
27779
27805
|
}
|
|
27806
|
+
/**
|
|
27807
|
+
* One of its agents put in a room (Chips ADR 0088): the room's last lines before it joined come
|
|
27808
|
+
* with the news, and are kept for the agent's first turn there, which says them once.
|
|
27809
|
+
*/
|
|
27810
|
+
attached(attached) {
|
|
27811
|
+
const { agent_id: agentId2, space_id: spaceId, catch_up: before } = attached;
|
|
27812
|
+
if (spaceId === void 0 || before === void 0 || before.lines.length === 0) return;
|
|
27813
|
+
this.caughtUp.set(`${agentId2}|${spaceId}`, before);
|
|
27814
|
+
for (const oldest of this.caughtUp.keys()) {
|
|
27815
|
+
if (this.caughtUp.size <= CAUGHT_UP_MOST) break;
|
|
27816
|
+
this.caughtUp.delete(oldest);
|
|
27817
|
+
}
|
|
27818
|
+
}
|
|
27780
27819
|
/**
|
|
27781
27820
|
* Words said in a room to others (Chips ADR 0294): kept where a message waits for one of its
|
|
27782
27821
|
* agents there, as said after the newest of them, and told to the turn that takes it. Chips
|
|
@@ -27960,12 +27999,15 @@ var Bridge = class {
|
|
|
27960
27999
|
project
|
|
27961
28000
|
};
|
|
27962
28001
|
const rules = rulesFor(message, asked);
|
|
28002
|
+
const joined2 = `${speakerId ?? record2.agentId}|${spaceId}`;
|
|
27963
28003
|
let words4 = promptForAll(message, {
|
|
27964
28004
|
...asked,
|
|
27965
28005
|
rulesHeld: this.rules.holds(sessionId, rules),
|
|
27966
28006
|
earlier,
|
|
27967
28007
|
since,
|
|
27968
|
-
answered: room.answered
|
|
28008
|
+
answered: room.answered,
|
|
28009
|
+
before: this.caughtUp.get(joined2),
|
|
28010
|
+
heldPost: room.heldPost
|
|
27969
28011
|
});
|
|
27970
28012
|
const files = [];
|
|
27971
28013
|
for (const each of [...earlier, message]) files.push(...await this.filesFor(record2, each));
|
|
@@ -27990,7 +28032,11 @@ ${files.join("\n")}`;
|
|
|
27990
28032
|
return;
|
|
27991
28033
|
}
|
|
27992
28034
|
turn.prompting = false;
|
|
27993
|
-
if (prompt === words4)
|
|
28035
|
+
if (prompt === words4) {
|
|
28036
|
+
keepAnswered(room.answered, [...earlier, message]);
|
|
28037
|
+
this.caughtUp.delete(joined2);
|
|
28038
|
+
room.heldPost = void 0;
|
|
28039
|
+
}
|
|
27994
28040
|
if (turn.cancelled) return;
|
|
27995
28041
|
const paused = turn.pausing;
|
|
27996
28042
|
turn.pausing = false;
|
|
@@ -28133,7 +28179,11 @@ ${files.join("\n")}`;
|
|
|
28133
28179
|
const post = await sendAnswer(words4, { folders: [room.record.folder], upload: (input2) => chips2.upload(input2) });
|
|
28134
28180
|
const reply = post.text;
|
|
28135
28181
|
if (reply !== "" || post.uploadIds.length > 0) {
|
|
28136
|
-
await turn.speaker.post({ spaceId: room.spaceId, runId: run2.id, text: reply, uploadIds: post.uploadIds, change });
|
|
28182
|
+
const taken = await turn.speaker.post({ spaceId: room.spaceId, runId: run2.id, text: reply, uploadIds: post.uploadIds, change });
|
|
28183
|
+
if (taken.held === true) {
|
|
28184
|
+
room.heldPost = { held: true, ...taken.exchange === void 0 ? {} : { exchange: taken.exchange } };
|
|
28185
|
+
this.log(`Chips held what ${room.record.name} said in ${room.spaceId} from the agents it named`);
|
|
28186
|
+
}
|
|
28137
28187
|
}
|
|
28138
28188
|
const cut2 = stop2 === "max_tokens" || stop2 === "max_turn_requests";
|
|
28139
28189
|
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.21",
|
|
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": {
|