@bill10/agent-007 0.9.2001 → 0.9.3000
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/VERSION +1 -1
- package/package.json +1 -1
- package/server/messages.js +34 -5
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.9.
|
|
1
|
+
0.9.3.0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bill10/agent-007",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3000",
|
|
4
4
|
"description": "From web terminals for your coding agents to a self-running agent company: Claude Code and Codex in parallel git worktrees, a job board they pick work from, and one agent that runs the board from a goal.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/server/messages.js
CHANGED
|
@@ -35,6 +35,14 @@ export const USER_TYPING_HOLD_MS = 30 * 1000;
|
|
|
35
35
|
// Enter is a newline; with this gap codex-cli 0.155.1 takes paste and Enter as
|
|
36
36
|
// one turn (checked in review).
|
|
37
37
|
export const SUBMIT_DELAY_MS = 150;
|
|
38
|
+
// Claude Code (2.1.x) folds a long paste into a "[Pasted text #1]" placeholder
|
|
39
|
+
// and hands the model that part wrapped as pasted_content, which it treats as
|
|
40
|
+
// maybe not from the user: a long message got a question back, not action.
|
|
41
|
+
// Seen at 500 chars or 31 lines in one paste; 300 chars, or a line or two,
|
|
42
|
+
// comes through as plain typing. So a message goes in as many small pastes,
|
|
43
|
+
// a line or less each, still bracketed so a newline stays a newline.
|
|
44
|
+
export const PASTE_CHUNK_CHARS = 200;
|
|
45
|
+
export const PASTE_GAP_MS = 10;
|
|
38
46
|
|
|
39
47
|
const queues = new Map(); // recipient session id -> [formatted text]
|
|
40
48
|
// How many at the front of a queue the server wrote (approvals, board
|
|
@@ -44,7 +52,7 @@ const queues = new Map(); // recipient session id -> [formatted text]
|
|
|
44
52
|
const serverAhead = new Map();
|
|
45
53
|
const sends = new Map(); // `${from.id}>${to.id}` -> [timestamps]
|
|
46
54
|
|
|
47
|
-
// Everything but newline and tab. The text goes inside
|
|
55
|
+
// Everything but newline and tab. The text goes inside bracketed pastes, and a
|
|
48
56
|
// message carrying ESC[201~ would end the paste early and type the rest as raw
|
|
49
57
|
// keystrokes — arrow keys, Enter, whatever it liked.
|
|
50
58
|
const clean = (s) => String(s ?? '').replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g, '');
|
|
@@ -147,7 +155,7 @@ export function formatNotice(headline, lines = []) {
|
|
|
147
155
|
// the permission rule nor the pair limit applies; the queue cap does, and
|
|
148
156
|
// text over it is refused.
|
|
149
157
|
//
|
|
150
|
-
// Cleaned here, whoever wrote it: it goes into
|
|
158
|
+
// Cleaned here, whoever wrote it: it goes into bracketed pastes, and a stray
|
|
151
159
|
// ESC[201~ anywhere in it — a tool name, a card title — would end the paste
|
|
152
160
|
// and type the rest as keystrokes of the user's own.
|
|
153
161
|
export function sendText(session, text, now = Date.now()) {
|
|
@@ -185,6 +193,8 @@ export function canDeliver(session, now = Date.now()) {
|
|
|
185
193
|
// Billion holds its mail until it says it is ready (billion_ready), so
|
|
186
194
|
// nothing lands in the middle of its introduction.
|
|
187
195
|
if (session.messagesHeld) return false;
|
|
196
|
+
// Still typing the last one: a second would interleave with its pastes.
|
|
197
|
+
if (session.messageTyping) return false;
|
|
188
198
|
// Both: the stored state is up to a second old, and a dialog that opened
|
|
189
199
|
// since is what this must not type into.
|
|
190
200
|
if (session.exited || session.state !== 'WAITING' || detectState(session, { now }) !== 'WAITING') return false;
|
|
@@ -202,23 +212,42 @@ function write(session, data) {
|
|
|
202
212
|
try { session.pty.write(data); return true; } catch { return false; }
|
|
203
213
|
}
|
|
204
214
|
|
|
215
|
+
// Lines, newline kept, cut to PASTE_CHUNK_CHARS by code point so an emoji's
|
|
216
|
+
// surrogate pair is never split across two pastes.
|
|
217
|
+
export function pasteChunks(text) {
|
|
218
|
+
return text.split(/(?<=\n)/).flatMap(line => {
|
|
219
|
+
const chars = Array.from(line);
|
|
220
|
+
const out = [];
|
|
221
|
+
for (let i = 0; i < chars.length; i += PASTE_CHUNK_CHARS) out.push(chars.slice(i, i + PASTE_CHUNK_CHARS).join(''));
|
|
222
|
+
return out;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
205
226
|
function deliver(session, text, now) {
|
|
206
227
|
session.messageDeliveredAt = now;
|
|
207
|
-
|
|
228
|
+
session.messageTyping = true;
|
|
229
|
+
const chunks = pasteChunks(text);
|
|
230
|
+
const type = () => {
|
|
231
|
+
if (session.exited) return;
|
|
232
|
+
write(session, `\x1b[200~${chunks.shift()}\x1b[201~`);
|
|
233
|
+
setTimeout(chunks.length ? type : submit, chunks.length ? PASTE_GAP_MS : SUBMIT_DELAY_MS);
|
|
234
|
+
};
|
|
208
235
|
// Checked again at the Enter: in those 150 ms a dialog may have opened, which
|
|
209
236
|
// the Enter would answer, or a person may have started typing, whose text
|
|
210
237
|
// would go with it. Left unsent, the message sits in the composer instead.
|
|
211
238
|
// The screen is read afresh rather than through session.state, which lags a
|
|
212
239
|
// second behind and reads WORKING for three after any output — the paste's
|
|
213
240
|
// own echo included.
|
|
214
|
-
|
|
241
|
+
const submit = () => {
|
|
242
|
+
session.messageTyping = false;
|
|
215
243
|
if (session.exited) return;
|
|
216
244
|
if (detectState(session, { stateTimeoutMs: 0 }) === 'MESSAGE' || (session.lastUserInputAt || 0) > now) {
|
|
217
245
|
session.messageUnsubmittedAt = Date.now();
|
|
218
246
|
return;
|
|
219
247
|
}
|
|
220
248
|
write(session, '\r');
|
|
221
|
-
}
|
|
249
|
+
};
|
|
250
|
+
type();
|
|
222
251
|
}
|
|
223
252
|
|
|
224
253
|
/**
|