@anytowork/cli 0.12.44 → 0.12.45
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/package.json +1 -1
- package/src/listener/queue.js +5 -1
- package/src/listener/run.js +2 -1
- package/src/mt/inrun.js +7 -3
- package/src/wb-rules-text.js +4 -4
package/package.json
CHANGED
package/src/listener/queue.js
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
import { LISTENER_DEFAULTS } from './config.js';
|
|
14
14
|
|
|
15
|
+
const MAX_WAKE_IDS = 10; // wake-up ids kept per merged job (newest win)
|
|
16
|
+
|
|
15
17
|
export class WakeQueue {
|
|
16
18
|
/**
|
|
17
19
|
* @param {object} opts { config?: partial limits, nowMs?: () => number }
|
|
@@ -41,7 +43,9 @@ export class WakeQueue {
|
|
|
41
43
|
const have = this.waiting.get(sid);
|
|
42
44
|
if (have) {
|
|
43
45
|
// Merge: the newest wake's details, the earliest arrival time, "human" if any of them was.
|
|
44
|
-
|
|
46
|
+
// v0.38.9: keep the id of every merged wake-up; the platform finds the instructions each one covers.
|
|
47
|
+
const wakeIds = [...new Set([...(have.wakeIds || []), ...(wake.wakeIds || [])])].slice(-MAX_WAKE_IDS);
|
|
48
|
+
this.waiting.set(sid, { ...have, ...wake, wakeIds, addedAt: have.addedAt, readyAt: have.readyAt, human: have.human || wake.human });
|
|
45
49
|
return { result: 'merged' };
|
|
46
50
|
}
|
|
47
51
|
let readyAt = now;
|
package/src/listener/run.js
CHANGED
|
@@ -255,7 +255,7 @@ export class Listener {
|
|
|
255
255
|
if (!job.hireId && !taskId) return null;
|
|
256
256
|
const dirs = [this.cfg.cwd || process.cwd()];
|
|
257
257
|
if (jobInfo && jobInfo.path) dirs.push(jobInfo.path);
|
|
258
|
-
return this.usage.begin({ sid: job.sid, wakeId: job.wakeId, hireId: job.hireId, taskId, command, dirs, startMs: this.nowMs() });
|
|
258
|
+
return this.usage.begin({ sid: job.sid, wakeId: job.wakeId, hireId: job.hireId, taskId, command, dirs, startMs: this.nowMs(), wakeIds: job.wakeIds });
|
|
259
259
|
} catch {
|
|
260
260
|
return null;
|
|
261
261
|
}
|
|
@@ -336,6 +336,7 @@ export class Listener {
|
|
|
336
336
|
human: !fromAgent,
|
|
337
337
|
rewake: p.rewake === true,
|
|
338
338
|
msgId: Number.isFinite(msg) ? msg : null,
|
|
339
|
+
wakeIds: isSafeId(wakeId) ? [wakeId] : [],
|
|
339
340
|
payload: p,
|
|
340
341
|
});
|
|
341
342
|
this.logLine(`wake id=${wakeId} sid=${String(sid).slice(0, 8)} ${r.result}${r.dropped ? ' dropped_oldest' : ''}`);
|
package/src/mt/inrun.js
CHANGED
|
@@ -26,9 +26,13 @@ const SETTLE_MS = 60_000; // a call seen less than this l
|
|
|
26
26
|
const KEEP_FINISHED_MS = 10 * 60 * 1000; // finished runs stay known this long (to tell who owns what in a crowd)
|
|
27
27
|
|
|
28
28
|
/** The task a run belongs to: the session, the wake-up and the hire or task (ids the platform sent and the listener checked). */
|
|
29
|
-
export function buildTaskRef({ sid, wakeId, hireId, taskId }) {
|
|
29
|
+
export function buildTaskRef({ sid, wakeId, hireId, taskId, wakeIds }) {
|
|
30
30
|
const ref = { session_id: sid, wake_id: wakeId || '' };
|
|
31
31
|
if (hireId) ref.hire_id = hireId; else if (taskId) ref.task_id = taskId;
|
|
32
|
+
// v0.38.9: every wake-up this run answers (a merged job has several). The platform looks up which instructions each
|
|
33
|
+
// wake-up covers; the Agent never names instruction ids itself.
|
|
34
|
+
const ids = [...new Set((wakeIds || []).map(String).filter((x) => /^[0-9a-f-]{36}$/i.test(x)))].slice(-10);
|
|
35
|
+
if (ids.length > 1) ref.wake_ids = ids;
|
|
32
36
|
return ref;
|
|
33
37
|
}
|
|
34
38
|
|
|
@@ -132,12 +136,12 @@ export class RunUsageTracker {
|
|
|
132
136
|
}
|
|
133
137
|
|
|
134
138
|
/** A run starts. `dirs`: the folders the Agent works in (the listener's cwd, the hire work folder). */
|
|
135
|
-
begin({ sid, wakeId, hireId, taskId, command, dirs, startMs }) {
|
|
139
|
+
begin({ sid, wakeId, hireId, taskId, command, dirs, startMs, wakeIds }) {
|
|
136
140
|
const now = this.nowMs();
|
|
137
141
|
this.runs = this.runs.filter((x) => x.endMs == null || now - x.endMs < KEEP_FINISHED_MS);
|
|
138
142
|
const r = {
|
|
139
143
|
seq: (this.seq += 1), sid, startMs: startMs != null ? startMs : now, endMs: null,
|
|
140
|
-
taskRef: buildTaskRef({ sid, wakeId, hireId, taskId }),
|
|
144
|
+
taskRef: buildTaskRef({ sid, wakeId, hireId, taskId, wakeIds }),
|
|
141
145
|
dirs: [...new Set((dirs || []).map(norm).filter(Boolean))],
|
|
142
146
|
tokens: String(command || '').split(/\s+/).map((t) => t.replace(/^['"]+|['"]+$/g, '')).filter((t) => t.length >= 4 && !t.startsWith('-') && /[:_-]/.test(t)),
|
|
143
147
|
prog: programOfCommand(command), // v0.38.8: a run of one program never takes another program's sessions
|
package/src/wb-rules-text.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
// Since v0.35.3 the platform sends the finished words in `rules.text` (already in the owner's language, with the
|
|
3
3
|
// extra paragraphs attached); this file only holds the same words as a fallback for an old server that sends just
|
|
4
4
|
// {key, params:{sid}}. Wording must stay identical to PRD 26 section 7.3, connect.json, llms.txt and the docs site
|
|
5
|
-
// (agent-setup); the platform's copy (WB_RULES_REV =
|
|
5
|
+
// (agent-setup); the platform's copy (WB_RULES_REV = 5) is the reference.
|
|
6
6
|
import { pickLang } from "./model-pledge.js";
|
|
7
7
|
|
|
8
|
-
export const WB_RULES_REV =
|
|
8
|
+
export const WB_RULES_REV = 5;
|
|
9
9
|
|
|
10
10
|
export const WB_RULES_TEXT = {
|
|
11
11
|
"wb.rules.full": {
|
|
12
|
-
zh: "主人在工作台等你的回话,照这几步做:\n1. 先读消息:anytowork chat read {sid}\n2. 马上回一句,说你收到了、打算怎么做:anytowork chat send {sid} \"……\" --wip(还要接着做就带 --wip)\n3. 做的过程中隔一会儿说一两句进展:anytowork chat progress {sid} \"……\"。主人看不到动静,就分不清你是在忙还是没收到。\n4. 做完交成果:anytowork chat result {sid}\n读了消息就要有动作:回复、--wip 或 progress
|
|
13
|
-
en: "Your owner is waiting for your reply in the workbench. Do this:\n1. Read the message first: anytowork chat read {sid}\n2. Reply right away to say you got it and what you plan to do: anytowork chat send {sid} \"...\" --wip (keep --wip while you are still working)\n3. While you work, say a line or two now and then: anytowork chat progress {sid} \"...\". If they hear nothing, they cannot tell whether you are busy or never got it.\n4. When it is done, hand in the result: anytowork chat result {sid}\nOnce you read a message, act on it: reply, --wip or progress, pick one. If you only read and do nothing, the platform will call you once more. When your owner asks you something, answer with a reply in the chat (chat send); your owner cannot see progress, so it does not count as an answer.\nIf the answer of a command says there are N new messages, your owner has said more: you must run chat read first, then decide whether to carry on with the original work or change course. Do not wait until the step in hand is done. The same goes for a supplement or a progress question on an order: read first, then act.",
|
|
12
|
+
zh: "主人在工作台等你的回话,照这几步做:\n1. 先读消息:anytowork chat read {sid}\n2. 马上回一句,说你收到了、打算怎么做:anytowork chat send {sid} \"……\" --wip(还要接着做就带 --wip)\n3. 做的过程中隔一会儿说一两句进展:anytowork chat progress {sid} \"……\"。主人看不到动静,就分不清你是在忙还是没收到。\n4. 做完交成果:anytowork chat result {sid}\n读了消息就要有动作:回复、--wip 或 progress,三选一。只读不动,平台会再叫你一次。每一轮干完,必须发一条正式回复或交成果(不带 --wip);--wip 只用于中途进度,只发 --wip 平台算作没有回应。主人问你的问题,必须用聊天里的回复(chat send)回答;progress 主人看不到,不算回答。\n命令返回里如果提示「另有 N 条新消息」,说明主人又说话了:必须先 chat read 读完,再决定原来的活继续做还是改方向,不要等手头这一步做完再读。订单里有补充需求或追问进度,同样先读再动。",
|
|
13
|
+
en: "Your owner is waiting for your reply in the workbench. Do this:\n1. Read the message first: anytowork chat read {sid}\n2. Reply right away to say you got it and what you plan to do: anytowork chat send {sid} \"...\" --wip (keep --wip while you are still working)\n3. While you work, say a line or two now and then: anytowork chat progress {sid} \"...\". If they hear nothing, they cannot tell whether you are busy or never got it.\n4. When it is done, hand in the result: anytowork chat result {sid}\nOnce you read a message, act on it: reply, --wip or progress, pick one. If you only read and do nothing, the platform will call you once more. Every round must end with a formal reply or a result (without --wip); --wip is only for progress along the way, and a round answered only with --wip counts as no answer. When your owner asks you something, answer with a reply in the chat (chat send); your owner cannot see progress, so it does not count as an answer.\nIf the answer of a command says there are N new messages, your owner has said more: you must run chat read first, then decide whether to carry on with the original work or change course. Do not wait until the step in hand is done. The same goes for a supplement or a progress question on an order: read first, then act.",
|
|
14
14
|
},
|
|
15
15
|
"wb.rules.short": {
|
|
16
16
|
zh: "主人在等你:先读消息,先回一句收到,边做边说一两句,做完交成果。",
|