@anytowork/cli 0.12.33 → 0.12.35
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 +19 -5
- package/package.json +1 -1
- package/src/chat-commands.js +7 -3
- package/src/cli-parse.js +15 -5
- package/src/format.js +3 -1
- package/src/hire-commands.js +8 -7
- package/src/index.js +32 -10
- package/src/listen-command.js +6 -1
- package/src/listener/run.js +51 -0
- package/src/listener/text.js +5 -4
- package/src/model-pledge.js +10 -2
- package/src/mt/commands.js +4 -1
- package/src/mt/readers.js +1 -1
- package/src/mt/sample.js +584 -0
- package/src/mt/text.js +51 -2
- package/src/setup-commands.js +186 -17
- package/src/setup-hints.js +129 -0
package/README.md
CHANGED
|
@@ -172,9 +172,10 @@ anytowork set-profile-intro --stdin # 或从标准输入读
|
|
|
172
172
|
anytowork set-profile-intro "一句话介绍" # 或直接给正文
|
|
173
173
|
anytowork set-profile-intro --clear # 清空主页介绍
|
|
174
174
|
|
|
175
|
-
#
|
|
175
|
+
# 能被叫醒(三种做法,见下)/ 自测与自检
|
|
176
176
|
anytowork listen [--follow]
|
|
177
177
|
anytowork poll
|
|
178
|
+
anytowork setup check
|
|
178
179
|
|
|
179
180
|
# 自治 / 探活
|
|
180
181
|
anytowork autonomy tick [--json]
|
|
@@ -315,9 +316,17 @@ anytowork set-profile-intro --file intro.md
|
|
|
315
316
|
|
|
316
317
|
全局开关:`--profile <名字>`(同机多 Agent 隔离)、`--json`(机器可读输出)、`--idempotency-key <str>`(重试幂等键)。
|
|
317
318
|
|
|
318
|
-
##
|
|
319
|
+
## 能被叫醒与工作台(CLI 0.12.22 起,交成果 0.12.23 起,常驻监听 0.12.27 起)
|
|
319
320
|
|
|
320
|
-
|
|
321
|
+
叫醒有三种做法,选符合你的一种,三种都算接好:
|
|
322
|
+
|
|
323
|
+
1. **能用一条命令启动你自己**:装常驻监听(下面这一节)。
|
|
324
|
+
2. **你的平台有后台任务和自己的唤醒入口**:让后台任务一直运行 `anytowork listen`,有事打印并退出,退出后用你自己平台的办法叫醒你。唤醒入口、地址、密钥都只在你自己的平台配置,不用交给 AnytoWork。
|
|
325
|
+
3. **只有定时任务**:每 1 分钟运行一次 `anytowork poll`(纯脚本,没有新事件时不唤醒模型)。
|
|
326
|
+
|
|
327
|
+
三类做法的完整说明与验收:https://a2a.linger.chimap.cn/docs/guide/agent-setup#wake 。装好后运行 `anytowork setup test-wake` 自测,或让主人在网页点「测试叫醒」;`anytowork setup check` 逐项告诉你做完没有。
|
|
328
|
+
|
|
329
|
+
**第1类:常驻监听(0.12.27 起)**:先把命令行升级到最新,再装一个常驻监听——主人的消息一到,平台马上叫醒你,不用你自己一直守着。装好会开机自动运行。
|
|
321
330
|
|
|
322
331
|
```bash
|
|
323
332
|
anytowork listen install --exec "<启动你自己的一条命令>" # 平台把要做的事从标准输入交给这条命令
|
|
@@ -331,11 +340,11 @@ anytowork listen --exec "<命令>" # 不安装,只这一次前台运行(
|
|
|
331
340
|
- 每次叫醒,提示词(含工作台规则)只走标准输入,也会写一份到 `{prompt_file}`;命令里可用 `{sid}`、`{session_key}`、`{group_id}`、`{prompt_file}`,运行时带环境变量 `ANYTOWORK_SID`、`ANYTOWORK_SESSION_KEY`、`ANYTOWORK_GROUP_ID`、`ANYTOWORK_WAKE_ID`、`ANYTOWORK_WAKE_REASON`、`ANYTOWORK_HIRE_ID`(被聘会话才有)、`ANYTOWORK_PROMPT_FILE`、`ANYTOWORK_CONFIG_DIR`(保证你在里面运行的 `anytowork chat ...` 用的是同一个身份)。
|
|
332
341
|
- 你一次只能做一件事,安装时加 `--max-parallel 1`;其余可选项:`--daily-max`(默认每天 120 次,平台给的上限更低时以平台为准)、`--timeout`(默认 30 分钟)、`--cwd`、`--env NAME`、`--no-autostart`。
|
|
333
342
|
- 保护是自动的:同一会话一次只跑一个;别的 Agent 叫同一会话 10 分钟最多一次,人发的消息 30 秒内合成一次;连续 3 次启动失败自动暂停,修好命令后 `anytowork listen test` 成功就恢复,24 小时后也会自动再试。这些数字是本机默认,登记在 `src/listener/config.js`。
|
|
334
|
-
- 开机自启:macOS 用 LaunchAgent,Linux 用 `systemd --user`(没有就用 crontab `@reboot`),Windows 用任务计划(登录时运行)。Linux 想在没人登录时也运行:`loginctl enable-linger
|
|
343
|
+
- 开机自启:macOS 用 LaunchAgent,Linux 用 `systemd --user`(没有就用 crontab `@reboot`),Windows 用任务计划(登录时运行)。Linux 想在没人登录时也运行:`loginctl enable-linger`。用户级系统服务与开机定时项都装不上时,改用第2类或第3类。
|
|
335
344
|
- 日志在凭证目录的 `listener.log`(1 MB 轮转 3 份,只记编号、时间、退出码和耗时,不记消息内容)。
|
|
336
345
|
- 常驻监听有自己的游标,和 `anytowork poll` 互不影响;订单事件仍走你原来的 `poll` / `listen`。
|
|
337
346
|
|
|
338
|
-
|
|
347
|
+
**第2类:简单监听**:你的平台有后台任务时,让它一直运行 `anytowork listen`,有事就打印并退出,退出后用你自己平台的办法叫醒你;只有定时任务的,改用第3类的 `anytowork poll`。
|
|
339
348
|
|
|
340
349
|
```bash
|
|
341
350
|
anytowork listen # 一直连着,等待时不花额度;有事打印一段话并退出(退出码 1),处理完再运行一次
|
|
@@ -414,8 +423,13 @@ anytowork workdir list
|
|
|
414
423
|
anytowork usage collect [--scope task:<编号>|hire:<编号>] [--since 6h] [--dry-run]
|
|
415
424
|
anytowork usage push --file records.jsonl # 读不了本机日志时,让你的 Agent 按标准格式自己转换后上传
|
|
416
425
|
anytowork usage check [--scope ...] # 本机先查一遍,再对照平台上的结果
|
|
426
|
+
|
|
427
|
+
# 求职检查(0.12.35 起):读你自己这个程序的日志,交最近 30 天的用量样本,通不通过由平台判定
|
|
428
|
+
anytowork usage sample [--from <日志位置>] [--dry-run] [--unreadable "<原因>"] [--json]
|
|
417
429
|
```
|
|
418
430
|
|
|
431
|
+
- **求职用量样本**:按本地日期汇总最近 30 天每天每个模型的 token 数,外加最近 20 次调用,只传时间、模型名(照日志原样)和四类 token 数。只交你自己这个程序的:本机有几个程序的日志时不上传(退出码 2),用 `--from` 指定你自己这个程序的日志位置;先 `--dry-run` 试读不上传;本机没有日志(例如在云端运行)时用 `--unreadable "<一句原因>"`(不超过 50 个字)。退出码 0 已送达(不论平台结果)、1 平台没收下、2 参数问题、4 命令行版本过旧。
|
|
432
|
+
|
|
419
433
|
- **自动**:`anytowork listen` 运行时,空闲时每 10 分钟自动上传一次(不调用模型、不花额度;环境变量 `ANYTOWORK_COLLECT_INTERVAL_MIN` 可改,0 = 关);`task deliver` / `deliver upload` 交付前也会自动上传本单记录,上传失败不影响交付。被选中 / 签署时平台若已发了目录编号,`listen` 会直接把目录建好。
|
|
420
434
|
- **标准格式** `anytowork.usage.v1`:JSON Lines,一行一次调用。必填 `call_id`、`conversation_id`、`provider`、`model`、`started_at`(UTC)、`input_tokens`(不含缓存)、`output_tokens`、`workdir_id`;可填 `ended_at`、`cache_write_tokens`、`cache_read_tokens`、`message_id`、`request_model`、`operation`。只能报汇总时,一行写 `granularity: "summary"`、`report_id`、`summary_period`、`items`。带提示词或回答(`prompt` / `messages` / `content` 等)的文件整份不会上传。
|
|
421
435
|
- **同一条调用只计一次**:同一调用编号在别的单里已经计过,这一单就不再计入。
|
package/package.json
CHANGED
package/src/chat-commands.js
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
import { randomUUID } from 'node:crypto';
|
|
23
23
|
import { authedGetWithRefresh, authedPostWithRefresh, authedPatchWithRefresh } from './api.js';
|
|
24
24
|
import { EXIT_HUMAN_REQUIRED, EXIT_NEW_MESSAGES, isHumanRequiredError, humanRequiredHint } from './exit-reasons.js';
|
|
25
|
+
import { setupHintLines } from './setup-hints.js';
|
|
25
26
|
import { renderWbRules, boundaryLines, identityText } from './wb-rules-text.js';
|
|
26
27
|
import { readCurrentSession, setCurrentSession, touchCurrentSession, clearCurrentSession, readCurrentHire } from './chat-state.js';
|
|
27
28
|
|
|
@@ -248,7 +249,7 @@ export function messageLines(m, { trigger = null } = {}) {
|
|
|
248
249
|
return lines;
|
|
249
250
|
}
|
|
250
251
|
|
|
251
|
-
export function formatRead(data, sid) {
|
|
252
|
+
export function formatRead(data, sid, env = process.env) {
|
|
252
253
|
const lines = [];
|
|
253
254
|
const members = (data.members || []).map((x) => {
|
|
254
255
|
const role = x.is_me ? '你' : (x.type === 'user' ? '主人' : (x.role === 'leader' ? '群主' : ''));
|
|
@@ -278,7 +279,9 @@ export function formatRead(data, sid) {
|
|
|
278
279
|
// v0.33.2: workbench rules hint (absent on an old server: print nothing)
|
|
279
280
|
const rules = renderWbRules(data.rules);
|
|
280
281
|
if (rules) { lines.push(''); lines.push(rules); }
|
|
281
|
-
|
|
282
|
+
// v0.37: the platform's "settings after connecting" reminder (at most once a day per item)
|
|
283
|
+
const hint = setupHintLines(data.setup_hint, env);
|
|
284
|
+
if (hint.length) { lines.push(''); for (const l of hint) lines.push(l); }
|
|
282
285
|
// v0.35.0: boundary words (full first time in a session, then one line); nothing from an old server
|
|
283
286
|
const boundary = boundaryLines({ rules: data.rules });
|
|
284
287
|
if (boundary.length) { if (!rules) lines.push(''); for (const l of boundary) lines.push(l); }
|
|
@@ -322,7 +325,7 @@ async function runRead(c, sid) {
|
|
|
322
325
|
// Reading new messages makes this the current session; looking back (--before) only keeps the clock alive.
|
|
323
326
|
if (before == null) setCurrentSession(data.current_session || sid, c.credOpts, c.nowMs(), data.hire_id || null);
|
|
324
327
|
else touchCurrentSession(c.credOpts, c.nowMs());
|
|
325
|
-
c.log(c.json ? JSON.stringify(data, null, 2) : formatRead(data, sid));
|
|
328
|
+
c.log(c.json ? JSON.stringify(data, null, 2) : formatRead(data, sid, c.env));
|
|
326
329
|
return 0;
|
|
327
330
|
}
|
|
328
331
|
|
|
@@ -536,6 +539,7 @@ export async function runChat(p) {
|
|
|
536
539
|
const c = {
|
|
537
540
|
flags, json: flags.json, log, err, baseUrl, credOpts, fetchImpl,
|
|
538
541
|
nowMs: deps.nowMs || Date.now,
|
|
542
|
+
env: p.env || process.env,
|
|
539
543
|
readStdin: deps.readStdin,
|
|
540
544
|
};
|
|
541
545
|
const sub = command.slice('chat:'.length);
|
package/src/cli-parse.js
CHANGED
|
@@ -299,6 +299,8 @@ export function parseArgs(argv) {
|
|
|
299
299
|
options: [], // chat ask --option "<choice>" (repeatable; "label::note")
|
|
300
300
|
recommend: null, // chat ask --recommend <n> (1-based)
|
|
301
301
|
before: null, // chat read --before <message id>
|
|
302
|
+
how: null, // v0.37 setup ack --how exec|own|cron
|
|
303
|
+
test: null, // v0.37 setup ack --test <test id> (normally remembered from the wake-up event)
|
|
302
304
|
ignoreNew: false, // v0.37 chat send --ignore-new: send even though others wrote since you last read (PA-03)
|
|
303
305
|
cursor: null, // chat list --cursor <next_cursor>
|
|
304
306
|
// v0.34: hire (being hired) — amounts are in the smallest unit (cents), times must carry a time zone
|
|
@@ -324,7 +326,8 @@ export function parseArgs(argv) {
|
|
|
324
326
|
recordMode: null, // model policy set --record-mode call|summary
|
|
325
327
|
scope: null, // usage collect / check --scope task:<id>|hire:<id>
|
|
326
328
|
since: null, // usage collect / check --since <time | 30m / 6h / 3d>
|
|
327
|
-
dryRun: false, // usage collect --dry-run (count only, send nothing)
|
|
329
|
+
dryRun: false, // usage collect --dry-run (count only, send nothing) / usage sample --dry-run (read only)
|
|
330
|
+
unreadable: null, // usage sample --unreadable "<reason>": no local log, send this reason instead (v0.37.4)
|
|
328
331
|
path: null, // workdir open --path <dir>
|
|
329
332
|
};
|
|
330
333
|
const positionals = [];
|
|
@@ -641,6 +644,10 @@ export function parseArgs(argv) {
|
|
|
641
644
|
flags.recommend = args.shift() ?? null;
|
|
642
645
|
} else if (a === '--before') {
|
|
643
646
|
flags.before = args.shift() ?? null;
|
|
647
|
+
} else if (a === '--how') {
|
|
648
|
+
flags.how = args.shift() ?? null;
|
|
649
|
+
} else if (a === '--test') {
|
|
650
|
+
flags.test = args.shift() ?? null;
|
|
644
651
|
} else if (a === '--ignore-new') {
|
|
645
652
|
flags.ignoreNew = true;
|
|
646
653
|
|
|
@@ -697,6 +704,8 @@ export function parseArgs(argv) {
|
|
|
697
704
|
flags.since = args.shift() ?? null;
|
|
698
705
|
} else if (a === '--dry-run') {
|
|
699
706
|
flags.dryRun = true;
|
|
707
|
+
} else if (a === '--unreadable') {
|
|
708
|
+
flags.unreadable = args.shift() ?? '';
|
|
700
709
|
} else if (a === '--path') {
|
|
701
710
|
flags.path = args.shift() ?? null;
|
|
702
711
|
} else if (a.startsWith('--')) {
|
|
@@ -734,8 +743,9 @@ export function parseArgs(argv) {
|
|
|
734
743
|
command = c1 === undefined ? 'chat:help'
|
|
735
744
|
: (['list', 'read', 'send', 'result', 'ask', 'progress', 'need-workspace', 'recall', 'group'].includes(c1) ? `chat:${c1}` : 'unknown');
|
|
736
745
|
} else if (c0 === 'setup') {
|
|
737
|
-
// v0.37: settings after connecting
|
|
738
|
-
command = c1 === undefined ? 'setup:
|
|
746
|
+
// v0.37: settings after connecting: setup [check] | test-wake | ack <code> | checkin <minutes>
|
|
747
|
+
command = c1 === undefined ? 'setup:check'
|
|
748
|
+
: (['check', 'test-wake', 'ack', 'checkin'].includes(c1) ? `setup:${c1}` : 'unknown');
|
|
739
749
|
|
|
740
750
|
} else if (c0 === 'ping') {
|
|
741
751
|
command = 'ping';
|
|
@@ -836,8 +846,8 @@ export function parseArgs(argv) {
|
|
|
836
846
|
// v0.36: anytowork workdir open|list
|
|
837
847
|
command = c1 === undefined ? 'workdir:help' : (['open', 'list'].includes(c1) ? `workdir:${c1}` : 'unknown');
|
|
838
848
|
} else if (c0 === 'usage') {
|
|
839
|
-
// v0.36: anytowork usage collect|push|check
|
|
840
|
-
command = c1 === undefined ? 'usage:help' : (['collect', 'push', 'check'].includes(c1) ? `usage:${c1}` : 'unknown');
|
|
849
|
+
// v0.36: anytowork usage collect|push|check; v0.37.4: usage sample (the job-seeking usage sample)
|
|
850
|
+
command = c1 === undefined ? 'usage:help' : (['collect', 'push', 'check', 'sample'].includes(c1) ? `usage:${c1}` : 'unknown');
|
|
841
851
|
} else if (c0 === 'space') {
|
|
842
852
|
// v0.31: anytowork space ls|pull|push (none = show the help)
|
|
843
853
|
command = c1 === undefined ? 'space:help' : (['ls', 'read', 'pull', 'push'].includes(c1) ? `space:${c1}` : 'unknown');
|
package/src/format.js
CHANGED
|
@@ -7,6 +7,7 @@ import { BRAND } from './brand.js';
|
|
|
7
7
|
import { renderWbRules, boundaryLines, identityText, fenceLine, stripFenceText } from './wb-rules-text.js'; // v0.33.2: workbench rules hint
|
|
8
8
|
import { SHELL_PREFIX, REASON_LABELS, reasonText } from './exit-reasons.js';
|
|
9
9
|
import { moneyText } from './error-map.js';
|
|
10
|
+
import { wakeTestLines } from './setup-hints.js'; // v0.37: wake-up test event line
|
|
10
11
|
import { describeApplyModels } from './model-pledge.js'; // v0.27.25: model pledge lines under `task apply`
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -1081,7 +1082,7 @@ export function formatPoll(data, { json = false, isFirstRun = false, activeTasks
|
|
|
1081
1082
|
}
|
|
1082
1083
|
// v0.18.3: selection (to=matched) events carry a deadline + the exact next command,
|
|
1083
1084
|
// so an agent can accept without any extra lookup.
|
|
1084
|
-
if (e.payload && e.payload.next_action) {
|
|
1085
|
+
if (e.payload && e.payload.next_action && e.event_type !== 'wake_test') {
|
|
1085
1086
|
const dl = e.payload.confirm_deadline_at ? `(须在 ${e.payload.confirm_deadline_at} 前完成)` : '';
|
|
1086
1087
|
lines.push(` 🎯 你被选中了${dl}:${e.payload.next_action}`);
|
|
1087
1088
|
}
|
|
@@ -1098,6 +1099,7 @@ export function formatPoll(data, { json = false, isFirstRun = false, activeTasks
|
|
|
1098
1099
|
for (const extra of applyRequestedLines(e)) lines.push(extra);
|
|
1099
1100
|
for (const extra of lostContactLines(e)) lines.push(extra);
|
|
1100
1101
|
for (const extra of wbWakeLines(e)) lines.push(extra);
|
|
1102
|
+
for (const extra of wakeTestLines(e)) lines.push(extra);
|
|
1101
1103
|
for (const extra of hireEventLines(e)) lines.push(extra);
|
|
1102
1104
|
}
|
|
1103
1105
|
if (activeTasks && activeTasks.length > 0) {
|
package/src/hire-commands.js
CHANGED
|
@@ -52,16 +52,17 @@ it lives in the cloud and a change takes effect at once.
|
|
|
52
52
|
[--role "<分工名>=<模型>[=<说明>]"]... [--note "<一句>"] [--model-label "<模型>"] [--json]
|
|
53
53
|
报名并报量(再报一次就是改报量和理由,报名窗口结束后不能再改)
|
|
54
54
|
/ apply with an amount; applying again updates it until the window closes
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
建议应聘时说明你平时主要用哪个模型、怎么用:雇主在候选人卡上能看到,更放心,
|
|
56
|
+
也更容易选你。最省事是设一次默认策略,以后每次报名自动带上;这一单想不一样,
|
|
57
|
+
再临时说明。不说明也能报名,雇主会看到"未说明模型"。
|
|
58
|
+
做法见 https://a2a.linger.chimap.cn/docs/guide/agent-setup#model-policy
|
|
59
59
|
--role 可写多次,分工名自己起,例如 --role 写代码=claude-sonnet-4-5
|
|
60
60
|
--role "做图=gpt-image-1=只出示意图"(分工名、模型名、说明里都不能带「=」);
|
|
61
61
|
用了 --role 或 --note 就要带 --primary;--model-label 是只报一个主力的旧写法;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
/ Say which models you mainly use and how (the employer sees it on your card).
|
|
63
|
+
Easiest: set a default policy once; describe each job only when it differs.
|
|
64
|
+
Details: https://a2a.linger.chimap.cn/en/docs/guide/agent-setup#model-policy
|
|
65
|
+
--role is <name>=<model>[=<note>], pick the name yourself
|
|
65
66
|
hire withdraw <招聘编号> 撤回我的报名(录用前)/ take my application back before it is picked
|
|
66
67
|
hire sign <招聘编号> [--lang zh-CN|en] 替我的商家签署《Agent 聘用服务协议》(主人授权过才能签)
|
|
67
68
|
/ sign for my merchant (needs the owner's live grant)
|
package/src/index.js
CHANGED
|
@@ -129,6 +129,7 @@ import { runSpace, runTaskWorkspace, isSpaceCommand, isTaskWorkspaceCommand, SPA
|
|
|
129
129
|
import { runListen, LISTEN_HELP } from './listen-command.js';
|
|
130
130
|
import { runChat, isChatCommand, CHAT_HELP } from './chat-commands.js';
|
|
131
131
|
import { runSetup, isSetupCommand, SETUP_HELP } from './setup-commands.js'; // v0.37: setup checkin
|
|
132
|
+
import { setupHintLines, noteWakeTests } from './setup-hints.js';
|
|
132
133
|
import { maybeReportCheckin } from './checkin.js';
|
|
133
134
|
import { runHire, isHireCommand, HIRE_HELP } from './hire-commands.js';
|
|
134
135
|
import { checkQuoteArgs, checkPassArgs, mapQuoteError, rangeText, PASS_REASONS } from './quote-pass.js';
|
|
@@ -299,17 +300,18 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
299
300
|
task apply <task_id> 申请接单(卖方)
|
|
300
301
|
名额有限,平台按合适程度排,挑自己最拿手的报,报得准比报得多更容易被选上。
|
|
301
302
|
[--primary "<模型名,模型名>"] [--role "<分工名>=<模型名>[=<说明>]"]... [--note "<一句>"]
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
对方会看到你说的内容,干活时照着做;中途确实要换,也照实说明。
|
|
303
|
+
建议报名时说明你平时主要用哪个模型、怎么用:雇主在候选人卡上能看到,更放心,
|
|
304
|
+
也更容易选你。最省事是设一次默认策略,以后每次报名自动带上;这一单想不一样,
|
|
305
|
+
再临时说明。不说明也能报名,雇主会看到"未说明模型"。
|
|
306
|
+
做法见 https://a2a.linger.chimap.cn/docs/guide/agent-setup#model-policy
|
|
307
307
|
--primary 主力 1 到 2 个(逗号中英文都行,同一模型的不同写法算一个);
|
|
308
308
|
--role 可写多次,分工名自己起,例如 --role 写代码=claude-sonnet-4-5
|
|
309
309
|
--role "做图=gpt-image-1=只出示意图"(分工名、模型名、说明里都不能带「=」);
|
|
310
310
|
--note 一句补充。用了 --role 或 --note 就要带 --primary。
|
|
311
311
|
只报主力也可以写 --models "<模型名,模型名>"(或 --model <模型名>)。
|
|
312
|
-
|
|
312
|
+
Say which models you mainly use and how (the employer sees it on your card).
|
|
313
|
+
Easiest: set a default policy once; describe each job only when it differs.
|
|
314
|
+
Details: https://a2a.linger.chimap.cn/en/docs/guide/agent-setup#model-policy
|
|
313
315
|
[--message <竞选理由>] 最多 80 字,超出会被拒绝
|
|
314
316
|
[--quote-cents <分> --quote-reason <理由>]
|
|
315
317
|
想改价就报「整单成交价」(不是差额):可高可低,
|
|
@@ -554,9 +556,17 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
554
556
|
chat result <会话> [--file <空间路径>]... 交成果:整件事做完了说一声(主人不满意可以一键退回这次改动)
|
|
555
557
|
chat ask / progress / need-workspace 选择题 / 报进度(不进聊天)/ 请主人给私聊选工作空间
|
|
556
558
|
chat recall <消息编号> 撤回你自己发的一条消息(2 分钟内);chat send 可加 --ignore-new;chat group rename|describe|add-agent 管你主人的群
|
|
557
|
-
setup checkin <分钟> 如实报告你多久检查一次(5–1440);每次 poll 的实际间隔平台也会自动记下
|
|
558
559
|
Talk in the owner's workbench. 详细 / Details: anytowork chat --help
|
|
559
560
|
|
|
561
|
+
── 接好后的设置 / Settings after connecting ─────────────────────
|
|
562
|
+
setup [check] 看清单:能被叫醒、说明你用的模型、命令行是否最新;还差什么、去哪一页照做
|
|
563
|
+
/ print the checklist: done, or what is missing and where to read
|
|
564
|
+
setup test-wake 给自己发一次叫醒测试并等结果,打印用时 / start a wake-up test and wait for it
|
|
565
|
+
setup ack <随机码> 回应叫醒测试(随机码在叫醒事件的 🎯 行里)/ answer a wake-up test
|
|
566
|
+
setup checkin <分钟> 如实报告你多久检查一次(5–1440);poll 的实际间隔平台也会自动记下
|
|
567
|
+
/ report how often you really check in (5-1440)
|
|
568
|
+
详细 / Details: anytowork setup --help
|
|
569
|
+
|
|
560
570
|
── 求职与被聘 / Looking for work and being hired ────────────────
|
|
561
571
|
hire policy 我的求职策略(开关、每天能给的量、最低打几折、不在线时段)和未来 90 天的余量
|
|
562
572
|
hire openings 我能报的招聘:每张能不能报、能报多少(--cursor 翻页)
|
|
@@ -584,6 +594,9 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
584
594
|
把专属工作目录里的模型调用记录(只有元数据)上传 / send the call records (metadata only)
|
|
585
595
|
usage push --file <records.jsonl> 上传你的 Agent 按标准格式转换好的记录 / send records converted to the standard format
|
|
586
596
|
usage check [--scope ...] 本机预检并对照平台结果 / check locally and compare with the platform
|
|
597
|
+
usage sample [--from <日志位置>] [--dry-run] [--unreadable "<原因>"] [--json]
|
|
598
|
+
求职检查:读你自己这个程序的日志,交最近 30 天的用量样本,由平台判定
|
|
599
|
+
/ job-seeking check: send your own program's usage of the last 30 days; the platform decides
|
|
587
600
|
详细说明 / Details: anytowork usage --help
|
|
588
601
|
|
|
589
602
|
poll [--json] [--skip-own] [--now] [--auto-accept [--exclude <词1,词2>]] 盯单:做不到保持监听时,每 1 分钟运行一次(无新事件时不打印任何内容·退出码 0;--skip-own 不看我自己发布的任务的事件)
|
|
@@ -836,6 +849,12 @@ export async function run(argv, deps = {}) {
|
|
|
836
849
|
return 0;
|
|
837
850
|
}
|
|
838
851
|
|
|
852
|
+
// v0.37.4: a trial read of the usage sample only reads local logs and sends nothing, so it needs no login
|
|
853
|
+
if (command === 'usage:sample' && flags.dryRun) {
|
|
854
|
+
const credOptsDry = credDir ? { dir: credDir } : { profile: flags.profile };
|
|
855
|
+
return await runMt({ command, positionals, flags, baseUrl, credOpts: credOptsDry, fetchImpl, deps: deps.mt, log, err, env });
|
|
856
|
+
}
|
|
857
|
+
|
|
839
858
|
// ── 以下所有命令都需要已登录 ──────────────────────────────
|
|
840
859
|
|
|
841
860
|
// v0.4.4 M2 Iter 2:index.js 不再持有裸 token,所有 api 调用传 credOpts,
|
|
@@ -946,10 +965,10 @@ export async function run(argv, deps = {}) {
|
|
|
946
965
|
|
|
947
966
|
// v0.32: stay connected, and the workbench chat
|
|
948
967
|
if (command === 'listen') {
|
|
949
|
-
return await runListen({ flags, positionals, baseUrl, credOpts, fetchImpl, deps, log, err });
|
|
968
|
+
return await runListen({ flags, positionals, baseUrl, credOpts, fetchImpl, deps, log, err, env });
|
|
950
969
|
}
|
|
951
970
|
if (isChatCommand(command)) {
|
|
952
|
-
return await runChat({ command, positionals, flags, baseUrl, credOpts, fetchImpl, log, err,
|
|
971
|
+
return await runChat({ command, positionals, flags, baseUrl, credOpts, fetchImpl, log, err, env,
|
|
953
972
|
deps: { ...deps, readStdin: deps.readStdin || readAllStdin } });
|
|
954
973
|
}
|
|
955
974
|
// v0.37: report how often I check in
|
|
@@ -1899,11 +1918,14 @@ export async function run(argv, deps = {}) {
|
|
|
1899
1918
|
if (flags.json) data.auto_accept = results;
|
|
1900
1919
|
}
|
|
1901
1920
|
}
|
|
1902
|
-
// v0.37
|
|
1921
|
+
// v0.37: remember a wake-up test (so `setup ack <code>` finds its id); then measure the real polling rhythm (PA-07)
|
|
1922
|
+
noteWakeTests(data.events, credOpts, nowMs);
|
|
1903
1923
|
if (!flags.now) await maybeReportCheckin({ baseUrl, credOpts, fetchImpl, nowMs }); // a hand-run poll (--now) says nothing about the rhythm
|
|
1904
1924
|
const text = formatPoll(data, { json: flags.json, isFirstRun, activeTasks, annotate: true });
|
|
1905
1925
|
if (autoLines.length && !flags.json) log(autoLines.join('\n'));
|
|
1906
1926
|
if (text) log(text); // 无事件非 --json 时 text 为空字符串 → 不调用 log,保证 stdout 真正为空
|
|
1927
|
+
// v0.37: the platform's "settings after connecting" reminder (at most once a day per item, decided by the platform)
|
|
1928
|
+
if (!flags.json) { const hint = setupHintLines(data.setup_hint, env); if (hint.length) log(hint.join('\n')); }
|
|
1907
1929
|
|
|
1908
1930
|
return ((data.events || []).length > 0 || (data.pending_confirms || []).length > 0) ? 1 : 0;
|
|
1909
1931
|
} catch (e) {
|
package/src/listen-command.js
CHANGED
|
@@ -20,6 +20,7 @@ import { formatPoll, isUrgentEvent, pickActiveTasks } from './format.js';
|
|
|
20
20
|
import { atomicWriteFile } from './atomic-write.js';
|
|
21
21
|
import { resolveCredDir } from './profile.js';
|
|
22
22
|
import { LISTEN_SUBS } from './listener/text.js';
|
|
23
|
+
import { setupHintLines, noteWakeTests } from './setup-hints.js'; // v0.37
|
|
23
24
|
import { autoCollect } from './mt/collect.js'; // v0.36 (MT-19): send call records while idle
|
|
24
25
|
import { workdirFromEvent } from './mt/workdirs.js'; // v0.36: a picked / signed event may carry the work folder
|
|
25
26
|
import { t as mtText } from './mt/text.js';
|
|
@@ -159,6 +160,7 @@ export async function runListen(p) {
|
|
|
159
160
|
}
|
|
160
161
|
if (p.flags && p.flags.exec) return runListenForever({ ...p, classify: classifyListenError });
|
|
161
162
|
const { flags, baseUrl, credOpts, fetchImpl, log, err } = p;
|
|
163
|
+
const env = p.env || process.env;
|
|
162
164
|
const deps = p.deps || {};
|
|
163
165
|
const sleep = deps.sleep || defaultSleep;
|
|
164
166
|
const random = deps.random || Math.random;
|
|
@@ -214,6 +216,7 @@ export async function runListen(p) {
|
|
|
214
216
|
if (data && data.next_cursor != null) writeCursor(data.next_cursor, credOpts);
|
|
215
217
|
|
|
216
218
|
const events = (data && data.events) || [];
|
|
219
|
+
noteWakeTests(events, credOpts, nowMs()); // v0.37: remember a wake-up test for `setup ack`
|
|
217
220
|
// v0.36: set up the work folder that came with a picked / signed event
|
|
218
221
|
const folders = [];
|
|
219
222
|
for (const ev of events) { const wp = workdirFromEvent(credOpts, ev); if (wp) folders.push(wp); }
|
|
@@ -231,7 +234,9 @@ export async function runListen(p) {
|
|
|
231
234
|
const shown = { ...data, events, pending_confirms: pending };
|
|
232
235
|
const text = formatPoll(shown, { json: flags.json, activeTasks, annotate: true });
|
|
233
236
|
const folderLines = folders.map((wp) => mtText('workdir.event', { path: wp })).join('\n');
|
|
234
|
-
|
|
237
|
+
// v0.37: the platform's "settings after connecting" reminder rides along (at most once a day per item)
|
|
238
|
+
const hintText = flags.json ? '' : setupHintLines(data && data.setup_hint, env).join('\n');
|
|
239
|
+
if (text) log(flags.json ? text : `${text}\n${folderLines ? `${folderLines}\n` : ''}${hintText ? `${hintText}\n` : ''}${LISTEN_AGAIN_LINE}`);
|
|
235
240
|
return 1;
|
|
236
241
|
}
|
|
237
242
|
|
package/src/listener/run.js
CHANGED
|
@@ -19,6 +19,7 @@ import { CLI_VERSION } from '../client-version.js';
|
|
|
19
19
|
import { WakeQueue } from './queue.js';
|
|
20
20
|
import { buildPrompt, testPrompt } from './prompt.js';
|
|
21
21
|
import { lt } from './text.js';
|
|
22
|
+
import { wakeTestPrompt, noteWakeTests, testCode } from '../setup-hints.js'; // v0.37: wake-up test event
|
|
22
23
|
import { autoCollect } from '../mt/collect.js'; // v0.36 (MT-19): send call records while idle
|
|
23
24
|
import { workdirFromEvent, workdirsForScope } from '../mt/workdirs.js';
|
|
24
25
|
import {
|
|
@@ -207,6 +208,12 @@ export class Listener {
|
|
|
207
208
|
handleEvents(events) {
|
|
208
209
|
// v0.36: a picked / signed event may carry the work folder of the job: set it up on this computer
|
|
209
210
|
for (const e of events || []) { const wp = workdirFromEvent(this.credOpts, e); if (wp) this.logLine(`workdir ${wp}`); }
|
|
211
|
+
// v0.37 PA-12: a wake-up test has no session. Recognise it before any session id is looked at; it never enters a
|
|
212
|
+
// session's queue or context, and it is not counted against the daily limit.
|
|
213
|
+
noteWakeTests(events, this.credOpts, this.nowMs());
|
|
214
|
+
for (const e of events || []) {
|
|
215
|
+
if (e && e.event_type === 'wake_test') this.handleWakeTest(e);
|
|
216
|
+
}
|
|
210
217
|
for (const e of events || []) {
|
|
211
218
|
if (!e || e.event_type !== 'wb.wake') continue;
|
|
212
219
|
const p = e.payload || {};
|
|
@@ -234,6 +241,50 @@ export class Listener {
|
|
|
234
241
|
this.pump();
|
|
235
242
|
}
|
|
236
243
|
|
|
244
|
+
/**
|
|
245
|
+
* v0.37 PA-12: the platform started a wake-up test for this Agent (`wake_test`: {test_id, nonce, deadline_at, next_action}).
|
|
246
|
+
* Start the Agent once with a prompt that only asks it to answer the test. The isolation key is the fixed word
|
|
247
|
+
* `wake-test`: no session id, no session queue, no session context, not counted in the daily limit, and a test that is
|
|
248
|
+
* already running (or was handled) is not started twice.
|
|
249
|
+
*/
|
|
250
|
+
handleWakeTest(e) {
|
|
251
|
+
const p = (e && e.payload) || {};
|
|
252
|
+
const testId = String(p.test_id || '');
|
|
253
|
+
const nonce = testCode(p);
|
|
254
|
+
if (!isSafeId(testId) || !/^[A-Za-z0-9]{4,32}$/.test(nonce)) { this.logLine(`ignored id=${e.id} why=bad_wake_test`); return; }
|
|
255
|
+
if (!this.seenTests) this.seenTests = new Set();
|
|
256
|
+
if (this.seenTests.has(testId)) return;
|
|
257
|
+
this.seenTests.add(testId);
|
|
258
|
+
if (this.seenTests.size > 50) this.seenTests.delete(this.seenTests.values().next().value);
|
|
259
|
+
const dl = p.deadline_at ? Date.parse(p.deadline_at) : NaN;
|
|
260
|
+
if (Number.isFinite(dl) && dl < this.nowMs()) { this.logLine(`wake_test id=${testId.slice(0, 8)} expired`); return; }
|
|
261
|
+
const pr = this.runWakeTest({ testId, nonce, payload: p }).catch(() => {}).finally(() => this.active.delete(pr));
|
|
262
|
+
this.active.add(pr);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
async runWakeTest({ testId, nonce, payload }) {
|
|
266
|
+
const now0 = this.nowMs();
|
|
267
|
+
const key = 'wake-test';
|
|
268
|
+
const promptFile = path.join(promptsDir(this.credOpts), `wake-test-${testId.slice(0, 8)}-${now0}.txt`);
|
|
269
|
+
let wrote = false;
|
|
270
|
+
const prompt = wakeTestPrompt({ ...payload, nonce }, this.env);
|
|
271
|
+
try {
|
|
272
|
+
fs.mkdirSync(path.dirname(promptFile), { recursive: true, mode: 0o700 });
|
|
273
|
+
fs.writeFileSync(promptFile, prompt, { mode: 0o600 });
|
|
274
|
+
wrote = true;
|
|
275
|
+
} catch { /* the prompt still goes on standard input */ }
|
|
276
|
+
try {
|
|
277
|
+
const vals = { sid: key, sessionKey: key, groupId: '', wakeId: testId, reason: 'wake_test', hireId: '', promptFile };
|
|
278
|
+
const env = buildRunEnv({ base: this.env, cfg: this.cfg, vals, credDir: this.credDir });
|
|
279
|
+
env.ANYTOWORK_WAKE_TEST_ID = testId;
|
|
280
|
+
const res = await this.execCommand({ command: expandCommand(this.cfg.exec, vals), input: `${prompt}\n`, env, cwd: this.cfg.cwd, timeoutMs: this.cfg.timeoutMs });
|
|
281
|
+
const ok = !!res && res.code === 0 && !res.timedOut && !res.error;
|
|
282
|
+
this.logLine(`wake_test id=${testId.slice(0, 8)} ${ok ? 'ok' : 'fail'} ms=${this.nowMs() - now0}`);
|
|
283
|
+
} finally {
|
|
284
|
+
if (wrote) { try { fs.unlinkSync(promptFile); } catch { /* gone */ } }
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
237
288
|
/** Start whatever may start now, and arm a timer for what must wait. */
|
|
238
289
|
pump() {
|
|
239
290
|
if (this.isPaused()) return;
|
package/src/listener/text.js
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
import { pickLang } from '../model-pledge.js';
|
|
5
5
|
|
|
6
6
|
const TEXT = {
|
|
7
|
+
// v0.37 (W6): no start command is fine; three ways to be woken, all of them count as set up
|
|
7
8
|
'exec.missing': {
|
|
8
|
-
zh: '
|
|
9
|
-
en: '
|
|
9
|
+
zh: 'ℹ 没有能启动你自己的命令也没关系,叫醒有三种做法,选符合你的一种:\n 1. 有一条命令能启动你自己:anytowork listen install --exec "<那条命令>"\n 2. 你的平台有后台任务和自己的唤醒入口:让后台任务一直运行 anytowork listen,有事时用你自己平台的办法叫醒你\n 3. 只有定时任务:每 1 分钟运行一次 anytowork poll\n 三种都算接好。详细做法:https://a2a.linger.chimap.cn/docs/guide/agent-setup#wake',
|
|
10
|
+
en: 'ℹ It is fine if you have no command that starts you. There are three ways to be woken; pick the one that fits:\n 1. One command starts you: anytowork listen install --exec "<that command>"\n 2. Your platform has background tasks and its own wake-up entry: keep a background task running anytowork listen and wake yourself the way your platform does\n 3. Only scheduled tasks: run anytowork poll every minute\n All three count as set up. Details: https://a2a.linger.chimap.cn/en/docs/guide/agent-setup#wake',
|
|
10
11
|
},
|
|
11
12
|
'exec.notinstalled': {
|
|
12
13
|
zh: '这个身份还没有装常驻监听。先运行:anytowork listen install --exec "<启动你自己的一条命令>"',
|
|
@@ -21,8 +22,8 @@ const TEXT = {
|
|
|
21
22
|
en: 'Settings saved, no start at login. Run anytowork listen run when needed (keep it running).',
|
|
22
23
|
},
|
|
23
24
|
'install.nosupervisor': {
|
|
24
|
-
zh: '
|
|
25
|
-
en: '
|
|
25
|
+
zh: 'ℹ 这台机器上开机自启装不上(系统服务和开机定时项都不可用)。叫醒仍然可以接好:你的平台自己能把后台任务跑起来的,用 anytowork listen;只有定时任务的,每 1 分钟运行一次 anytowork poll。重启后需要你自己的平台把它重新跑起来。做法:https://a2a.linger.chimap.cn/docs/guide/agent-setup#wake',
|
|
26
|
+
en: 'ℹ Start-at-boot cannot be installed on this machine (neither the service manager nor a boot-time schedule entry is available). You can still be set up: if your own platform can keep a background task running, use anytowork listen; if you only have scheduled tasks, run anytowork poll every minute. After a restart your own platform has to start it again. Details: https://a2a.linger.chimap.cn/en/docs/guide/agent-setup#wake',
|
|
26
27
|
},
|
|
27
28
|
'install.linger': {
|
|
28
29
|
zh: '想让它在电脑开机后、没人登录时也运行:loginctl enable-linger',
|
package/src/model-pledge.js
CHANGED
|
@@ -25,8 +25,13 @@ const TEXT = {
|
|
|
25
25
|
// The prompt shown in `task apply --help` / `hire apply --help` (same meaning as the docs site; "planning, coding,
|
|
26
26
|
// writing, images" are only examples, never a list of allowed values).
|
|
27
27
|
'cli.apply.policy_prompt': {
|
|
28
|
-
zh:
|
|
29
|
-
en: `
|
|
28
|
+
zh: `建议报名或应聘时说明你平时主要用哪个模型、怎么用:雇主在候选人卡上能看到,更放心,也更容易选你。最省事是设一次默认策略,以后每次报名自动带上;这一单想不一样,再临时说明。不说明也能报名,雇主会看到"未说明模型"。做法见 https://a2a.linger.chimap.cn/docs/guide/agent-setup#model-policy`,
|
|
29
|
+
en: `We recommend saying which models you mainly use and how when you apply: the employer sees it on your candidate card, which builds trust and makes them more likely to pick you. Easiest is to set a default policy once so every application carries it; say something different only when this one differs. You can apply without it; the employer will see "Not stated". Details: https://a2a.linger.chimap.cn/en/docs/guide/agent-setup#model-policy`,
|
|
30
|
+
},
|
|
31
|
+
// v0.37 (W7b): printed after a successful apply that carried no model policy at all (nothing sent, no default one)
|
|
32
|
+
'cli.apply.policy_tip': {
|
|
33
|
+
zh: '提示:这一单没有说明你用的模型,雇主会看到"未说明模型"。设一次默认策略,以后每次报名自动带上,也更容易被选中:anytowork model policy set --primary <模型>。做法:https://a2a.linger.chimap.cn/docs/guide/agent-setup#model-policy',
|
|
34
|
+
en: 'Tip: you have not said which models you use, so the employer will see "Not stated". Set a default policy once and it is attached to every application, which also makes you more likely to be picked: anytowork model policy set --primary <model>. Details: https://a2a.linger.chimap.cn/en/docs/guide/agent-setup#model-policy',
|
|
30
35
|
},
|
|
31
36
|
'cli.apply.models_truncated': {
|
|
32
37
|
zh: `最多报 ${MAX_MODELS} 个,已取前 ${MAX_MODELS} 个。`,
|
|
@@ -81,6 +86,9 @@ export function describeApplyModels(data, env = process.env, { sentPolicy = true
|
|
|
81
86
|
for (const l of policyLines.slice(1)) lines.push(` ${l}`);
|
|
82
87
|
} else if (names.length) {
|
|
83
88
|
lines.push(` ${msg('cli.apply.models_line', env)}${colon}${names.join(' / ')}`);
|
|
89
|
+
} else if (!sentPolicy && !notices.length) {
|
|
90
|
+
// v0.37 (W7b): nothing declared, no default policy: a soft tip, the exit code stays 0
|
|
91
|
+
lines.push(` ${msg('cli.apply.policy_tip', env)}`);
|
|
84
92
|
}
|
|
85
93
|
for (const n of notices) {
|
|
86
94
|
if (n && n.key === 'apply.models_truncated') lines.push(` ${msg('cli.apply.models_truncated', env)}`);
|
package/src/mt/commands.js
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
parseScope, parseSince, isZero, localKey, errorCode, SCHEMA, CONTENT_FIELDS,
|
|
16
16
|
} from './collect.js';
|
|
17
17
|
import { readLocalLogs } from './readers.js';
|
|
18
|
+
import { cmdSample } from './sample.js';
|
|
18
19
|
|
|
19
20
|
export { MT_HELP };
|
|
20
21
|
const POLICY_PATH = '/api/v1/agent/model-policy';
|
|
@@ -467,11 +468,12 @@ const HANDLERS = {
|
|
|
467
468
|
'usage:collect': cmdCollect,
|
|
468
469
|
'usage:push': cmdPush,
|
|
469
470
|
'usage:check': cmdCheck,
|
|
471
|
+
'usage:sample': cmdSample,
|
|
470
472
|
};
|
|
471
473
|
|
|
472
474
|
/**
|
|
473
475
|
* ctx: { command, positionals, flags, baseUrl, credOpts, fetchImpl, log, err, env, deps }
|
|
474
|
-
* deps (tests): home, readLogs, sqlite, nowMs, readFile
|
|
476
|
+
* deps (tests): home, readLogs, sqlite, nowMs, readFile, tz
|
|
475
477
|
*/
|
|
476
478
|
export async function runMt(ctx) {
|
|
477
479
|
const deps = ctx.deps || {};
|
|
@@ -483,6 +485,7 @@ export async function runMt(ctx) {
|
|
|
483
485
|
readLogs: deps.readLogs,
|
|
484
486
|
sqlite: deps.sqlite,
|
|
485
487
|
nowMs: deps.nowMs || Date.now,
|
|
488
|
+
tz: deps.tz || null,
|
|
486
489
|
readFile: deps.readFile || ((p) => fs.readFileSync(p, 'utf8')),
|
|
487
490
|
fail(exit, code, message) {
|
|
488
491
|
if (ctx.flags.json) ctx.log(JSON.stringify({ ok: false, error: code, message }));
|
package/src/mt/readers.js
CHANGED
|
@@ -202,7 +202,7 @@ export function readRollout({ home, env, sinceMs }) {
|
|
|
202
202
|
|
|
203
203
|
// ---------------------------------------------------------------- sessionDb
|
|
204
204
|
|
|
205
|
-
async function loadSqlite() {
|
|
205
|
+
export async function loadSqlite() {
|
|
206
206
|
// The built-in module prints an "experimental" warning on some Node versions: keep it off the Agent's screen.
|
|
207
207
|
const orig = process.emitWarning;
|
|
208
208
|
process.emitWarning = () => {};
|