@anytowork/cli 0.12.72 → 0.12.74
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 +15 -79
- package/package.json +1 -1
- package/src/api.js +17 -50
- package/src/apply-backoff.js +5 -2
- package/src/cli-parse.js +12 -131
- package/src/config.js +34 -5
- package/src/connect.js +22 -3
- package/src/error-map.js +56 -0
- package/src/exit-reasons.js +0 -9
- package/src/format.js +77 -144
- package/src/index.js +62 -112
- package/src/model-pledge.js +6 -6
- package/src/mt/collect.js +2 -26
- package/src/mt/commands.js +3 -84
- package/src/mt/format-check.js +2 -2
- package/src/mt/readers.js +1 -1
- package/src/mt/text.js +20 -89
- package/src/mt/wake-attribution.js +2 -2
- package/src/mt/workdirs.js +1 -18
- package/src/setup-commands.js +6 -6
- package/src/setup-hints.js +3 -19
- package/src/space-commands.js +2 -41
- package/src/space-sync.js +2 -2
- package/src/chat-commands.js +0 -685
- package/src/chat-state.js +0 -77
- package/src/hire-commands.js +0 -706
- package/src/listen-command.js +0 -79
- package/src/listener/commands.js +0 -183
- package/src/listener/config.js +0 -216
- package/src/listener/hire-wake.js +0 -60
- package/src/listener/install.js +0 -233
- package/src/listener/nudge.js +0 -88
- package/src/listener/prompt.js +0 -111
- package/src/listener/queue.js +0 -112
- package/src/listener/run-error.js +0 -81
- package/src/listener/run.js +0 -723
- package/src/listener/text.js +0 -103
- package/src/mt/inrun.js +0 -351
- package/src/mt/recipes.js +0 -478
- package/src/mt/sample.js +0 -708
- package/src/reply-hint.js +0 -21
- package/src/wb-rules-text.js +0 -169
package/src/mt/text.js
CHANGED
|
@@ -10,8 +10,8 @@ import { pickLang } from '../model-pledge.js';
|
|
|
10
10
|
const TEXT = {
|
|
11
11
|
// ---- model policy
|
|
12
12
|
'policy.none': {
|
|
13
|
-
zh: '还没有设置默认模型策略。用 anytowork model policy set --primary <模型>[,<模型>] 设置(主力最多 2
|
|
14
|
-
en: 'No default model policy yet. Set one with anytowork model policy set --primary <model>[,<model>] (at most 2 main models); an application that says nothing about models uses it. The statement is for the
|
|
13
|
+
zh: '还没有设置默认模型策略。用 anytowork model policy set --primary <模型>[,<模型>] 设置(主力最多 2 个);报名时没单独说明,平台就用这一份。这份说明是给发起方看的,写他在乎的结果,不写程序怎么接线或配置;只用一个模型就报那一个,确有分工,只写「活类型=模型」(如 简单文本=<模型A>;复杂与主力交付=<模型B>),不写补充描述,其余写进说明。',
|
|
14
|
+
en: 'No default model policy yet. Set one with anytowork model policy set --primary <model>[,<model>] (at most 2 main models); an application that says nothing about models uses it. The statement is for the requester: write the results they care about, not how your program is wired. Use one model: report that one; write a division of labour only as work type = model (e.g. simple text=<modelA>; complex and main delivery=<modelB>), no extra description; put the rest in the note.',
|
|
15
15
|
},
|
|
16
16
|
'policy.title': { zh: '我的默认模型策略(报名时没单独说明,平台就用这一份):', en: 'My default model policy (used when an application says nothing about models):' },
|
|
17
17
|
'policy.primary': { zh: ' 主力模型:{v}', en: ' Main models: {v}' },
|
|
@@ -52,12 +52,12 @@ const TEXT = {
|
|
|
52
52
|
'policy.err.invalid_role': { zh: '第 {n} 条分工不能用:分工名不能为空、不能重复,模型名也请核对。', en: 'Role #{n} cannot be used: the name must not be empty or repeated, and check the model name too.' },
|
|
53
53
|
'policy.err.role_too_long': { zh: '第 {n} 条分工的名称太长,最多 {max} 个字。改短后整份重报。', en: 'The name of role #{n} is too long (at most {max} characters). Shorten it and send the whole policy again.' },
|
|
54
54
|
'policy.err.role_note_too_long': { zh: '第 {n} 条分工的说明太长,最多 {max} 个字。改短后整份重报。', en: 'The note of role #{n} is too long (at most {max} characters). Shorten it and send the whole policy again.' },
|
|
55
|
-
'policy.err.wiring': { zh: '
|
|
55
|
+
'policy.err.wiring': { zh: '这段说明带了命令或配置的写法,请改成发起方看得懂的一句话,再整份重报。', en: 'This statement carries a command or config wording; please rewrite it as one sentence the requester can understand, then send the whole policy again.' },
|
|
56
56
|
'policy.err.too_many_roles': { zh: '分工最多 {max} 条。改少后整份重报。', en: 'At most {max} roles. Reduce them and send the whole policy again.' },
|
|
57
57
|
'policy.err.note_too_long': { zh: '补充说明最多 {max} 个字。', en: 'The note is at most {max} characters.' },
|
|
58
58
|
|
|
59
59
|
// ---- workdir
|
|
60
|
-
'workdir.need_id': { zh: '缺少单号:anytowork workdir open
|
|
60
|
+
'workdir.need_id': { zh: '缺少单号:anytowork workdir open <任务编号> [--path <目录>]', en: 'Missing id: anytowork workdir open <task id> [--path <dir>]' },
|
|
61
61
|
'workdir.opened': { zh: '这一单的专属工作目录:{path}', en: 'Work folder for this job: {path}' },
|
|
62
62
|
'workdir.opened_line': {
|
|
63
63
|
zh: '这一单的活都在这个目录里做(让你的 Agent 以它为工作目录开会话),模型调用记录会按这个目录归到这一单。',
|
|
@@ -65,13 +65,13 @@ const TEXT = {
|
|
|
65
65
|
},
|
|
66
66
|
'workdir.list_empty': { zh: '这台电脑上还没有领过专属工作目录。', en: 'No work folders on this computer yet.' },
|
|
67
67
|
'workdir.list_title': { zh: '这台电脑上的专属工作目录:', en: 'Work folders on this computer:' },
|
|
68
|
-
'workdir.err.forbidden': { zh: '
|
|
68
|
+
'workdir.err.forbidden': { zh: '这一单现在不能领工作目录:只有被选中的接单方能领。', en: 'You cannot get a work folder for this job: only the picked seller can.' },
|
|
69
69
|
'workdir.err.closed': { zh: '这一单已经结束,不能再领工作目录。', en: 'This job has ended; no new work folder.' },
|
|
70
|
-
'workdir.err.not_found': { zh: '
|
|
70
|
+
'workdir.err.not_found': { zh: '没找到这一单,请核对编号(任务编号)。', en: 'Job not found. Check the id (task id).' },
|
|
71
71
|
'workdir.event': { zh: '这一单的专属工作目录已备好:{path}(这一单的活都在这个目录里做)', en: 'Work folder ready for this job: {path} (do the work of this job inside it)' },
|
|
72
72
|
|
|
73
73
|
// ---- usage collect / push / check
|
|
74
|
-
'usage.feature_off': { zh: '
|
|
74
|
+
'usage.feature_off': { zh: '平台暂时没有开放模型调用明细,已跳过(不影响交付)。', en: 'Call records are switched off on the platform for now; skipped (deliveries are not affected).' },
|
|
75
75
|
'usage.no_logs': {
|
|
76
76
|
zh: '没在本机常见的日志位置找到你的 Agent 的模型调用记录。请让你的 Agent 把每次模型调用的元数据(模型、token 数、时间、调用编号,不含提示词和回答)按标准格式写成 JSON Lines,再运行 anytowork usage push --file <文件>。格式见文档站。',
|
|
77
77
|
en: 'No model call records of your Agent were found in the usual log files on this computer. Ask your Agent to write the metadata of each model call (model, token counts, time, call id; no prompts, no answers) as JSON Lines in the standard format, then run anytowork usage push --file <file>. The format is on the docs site.',
|
|
@@ -81,7 +81,6 @@ const TEXT = {
|
|
|
81
81
|
en: 'Found {n} model calls, but none inside a work folder, so nothing was sent. After you get a job, run anytowork workdir open <id> and work inside that folder.',
|
|
82
82
|
},
|
|
83
83
|
'usage.dropped': { zh: '未上传 {n} 条:日志没有目录 {nocwd},不在工作目录 {other}。', en: 'Left out {n}: no folder in the log {nocwd}, not in a work folder {other}.' },
|
|
84
|
-
'sample.dry_dropped': { zh: ' 未计入:超出 30 天 {old},没有模型名 {nomodel}', en: ' Left out: older than 30 days {old}, no model name {nomodel}' },
|
|
85
84
|
'usage.nothing_new': { zh: '没有新的模型调用记录要上传。', en: 'No new model call records to send.' },
|
|
86
85
|
'usage.dry_title': { zh: '试运行(不上传):找到 {n} 条可上传的记录', en: 'Dry run (nothing sent): {n} records ready to send' },
|
|
87
86
|
'usage.dry_workdir': { zh: ' {wd}({scope}):{n} 条', en: ' {wd} ({scope}): {n} records' },
|
|
@@ -94,11 +93,6 @@ const TEXT = {
|
|
|
94
93
|
'usage.send_failed': { zh: '上传没有完成({msg}),下次会自动补传。', en: 'Sending did not finish ({msg}); it will be retried next time.' },
|
|
95
94
|
'usage.upgrade': { zh: '建议升级命令行到 {min} 或更高:{cmd}', en: 'Please upgrade the CLI to {min} or later: {cmd}' },
|
|
96
95
|
'usage.need_file': { zh: '缺少文件:anytowork usage push --file <records.jsonl>', en: 'File missing: anytowork usage push --file <records.jsonl>' },
|
|
97
|
-
'usage.export_need_hire': {
|
|
98
|
-
zh: '这是导出的用量文件,要说明算在哪一单:anytowork usage push --file <文件> --scope hire:<招聘编号>',
|
|
99
|
-
en: 'This is an exported usage file; say which hire it belongs to: anytowork usage push --file <file> --scope hire:<hire id>',
|
|
100
|
-
},
|
|
101
|
-
'usage.export_bad_line': { zh: '文件里有一行读不了,整份没有上传:{msg}', en: 'A line of the file cannot be read; nothing was sent: {msg}' },
|
|
102
96
|
'usage.read_failed': { zh: '读不了这个文件:{msg}', en: 'Cannot read the file: {msg}' },
|
|
103
97
|
'usage.bad_line': { zh: '第 {n} 行不是合法 JSON,已跳过。', en: 'Line {n} is not valid JSON; skipped.' },
|
|
104
98
|
'usage.content_forbidden': {
|
|
@@ -107,9 +101,9 @@ const TEXT = {
|
|
|
107
101
|
},
|
|
108
102
|
'usage.missing_field': { zh: '第 {n} 行缺少 {field},已跳过。', en: 'Line {n} has no {field}; skipped.' },
|
|
109
103
|
// 2026-11-27: aggregate skips into one line instead of one-per-row
|
|
110
|
-
'usage.skipped_summary': { zh: '{n} 行因缺少 {field}
|
|
104
|
+
'usage.skipped_summary': { zh: '{n} 行因缺少 {field} 被跳过,请确认文件格式正确。', en: '{n} rows skipped (missing {field}). Please check the file format.' },
|
|
111
105
|
'usage.zero_skipped': { zh: '{n} 行 token 全为 0,没有上传。', en: '{n} lines had all token counts at 0 and were not sent.' },
|
|
112
|
-
'usage.bad_scope': { zh: '--scope 写法是 task
|
|
106
|
+
'usage.bad_scope': { zh: '--scope 写法是 task:<任务编号>。', en: '--scope is task:<task id>.' },
|
|
113
107
|
'usage.bad_since': { zh: '--since 写法是时间(2026-11-16T08:00:00Z)或时长(30m、6h、3d)。', en: '--since is a time (2026-11-16T08:00:00Z) or a duration (30m, 6h, 3d).' },
|
|
114
108
|
'usage.deliver_title': { zh: '交付前已顺带上传本单模型调用记录:', en: 'Model call records of this job sent before delivery:' },
|
|
115
109
|
'usage.deliver_failed': { zh: '本单模型调用记录这次没有上传({msg}),不影响交付,之后会自动补传。', en: 'Model call records of this job were not sent this time ({msg}); delivery is not affected and they will be sent later.' },
|
|
@@ -128,50 +122,6 @@ const TEXT = {
|
|
|
128
122
|
'usage.check_server_counts': { zh: ' 已收 {received} 条,计入 {counted},重复未计入 {dup}{last}', en: ' Received {received}, counted {counted}, duplicates not counted {dup}{last}' },
|
|
129
123
|
'usage.check_server_last': { zh: ',最后一次 {at}', en: ', last at {at}' },
|
|
130
124
|
'usage.check_server_failed': { zh: ' 这次没取到平台上的结果({msg})。', en: ' Could not read the platform side this time ({msg}).' },
|
|
131
|
-
'usage.hire_prefer_records': {
|
|
132
|
-
zh: '建议:在专属工作目录里干活,用 anytowork usage collect 上传逐条记录,比汇总上报更能让雇主放心。',
|
|
133
|
-
en: 'Tip: work inside the work folder and send call-by-call records with anytowork usage collect; employers trust them more than summaries.',
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
// ---- usage sample (v0.37.4 job-seeking check, CLI 0.12.35)
|
|
137
|
-
'sample.dry_title': { zh: '试读(不上传):{reader},{days} 天,{calls} 次调用', en: 'Trial read (nothing sent): {reader}, {days} days, {calls} calls' },
|
|
138
|
-
'sample.client': { zh: ' 客户端:{v}', en: ' Client: {v}' },
|
|
139
|
-
'sample.dry_models': { zh: ' 模型(按输入 + 输出 token 占比):{v}', en: ' Models (share of input + output tokens): {v}' },
|
|
140
|
-
'sample.dry_recipe': { zh: ' 配方 {recipe}:{files} 个文件,{lines} 行命中,模型 {models}', en: ' Recipe {recipe}: {files} files, {lines} lines matched, models {models}' },
|
|
141
|
-
'sample.dry_row': { zh: ' 样例:{v}', en: ' Sample: {v}' },
|
|
142
|
-
'sample.recipe_bad': { zh: '配方 {recipe} 读不了:{file} 第 {line} 行,{msg}', en: 'Recipe {recipe} cannot be read: {file} line {line}, {msg}' },
|
|
143
|
-
'sample.dry_unreadable': {
|
|
144
|
-
zh: '试读(不上传):读不到可用的用量({reason})。正式运行会把这句原因交给平台。',
|
|
145
|
-
en: 'Trial read (nothing sent): no usable usage ({reason}). A real run sends this reason to the platform.',
|
|
146
|
-
},
|
|
147
|
-
'sample.export_note': {
|
|
148
|
-
zh: '来源是 Agent 导出的文件,平台会标为低可信来源。',
|
|
149
|
-
en: 'The source is a file exported by the Agent; the platform marks it as a low-trust source.',
|
|
150
|
-
},
|
|
151
|
-
'sample.own_only': {
|
|
152
|
-
zh: '只算你自己这个程序的用量:如果读到的不是你自己这个程序的日志,用 --from <你自己这个程序的日志位置> 指定。',
|
|
153
|
-
en: 'Only the usage of your own program counts: if this is not the log of your own program, point to it with --from <your own log path>.',
|
|
154
|
-
},
|
|
155
|
-
'sample.several': {
|
|
156
|
-
zh: '这台电脑上不止一个程序有最近 30 天的记录,这次没有上传。只交你自己这个程序的:用 anytowork usage sample --from <你自己这个程序的日志位置> 重跑。',
|
|
157
|
-
en: 'More than one program on this computer has records in the last 30 days; nothing was sent. Send only your own: rerun with anytowork usage sample --from <the log path of your own program>.',
|
|
158
|
-
},
|
|
159
|
-
'sample.several_row': { zh: ' {reader} {root}:{days} 天,{calls} 次调用,模型 {models}', en: ' {reader} {root}: {days} days, {calls} calls, models {models}' },
|
|
160
|
-
'sample.delivered': {
|
|
161
|
-
zh: '已送达平台({reader},{days} 天,{calls} 次调用)。通不通过由平台判定,平台的结果:',
|
|
162
|
-
en: 'Delivered to the platform ({reader}, {days} days, {calls} calls). The platform decides; its result:',
|
|
163
|
-
},
|
|
164
|
-
'sample.delivered_unreadable': {
|
|
165
|
-
zh: '已送达平台:读不到可用的用量({reason})。通不通过由平台判定,平台的结果:',
|
|
166
|
-
en: 'Delivered to the platform: no usable usage ({reason}). The platform decides; its result:',
|
|
167
|
-
},
|
|
168
|
-
'sample.state': { zh: ' state: {state},reason: {reason}', en: ' state: {state}, reason: {reason}' },
|
|
169
|
-
'sample.main_models': { zh: ' 平台认定的主力模型:{v}', en: ' Main models seen by the platform: {v}' },
|
|
170
|
-
'sample.unpriced': { zh: ' 平台没法给这个模型计价:{model}', en: ' The platform cannot price this model: {model}' },
|
|
171
|
-
'sample.no_log': { zh: ' 平台按「读不到用量」处理。', en: ' The platform treats it as no usable usage.' },
|
|
172
|
-
'sample.refused': { zh: '平台没有收下({msg})。', en: 'The platform did not take it ({msg}).' },
|
|
173
|
-
'sample.bad_reason': { zh: '--unreadable 后面写一句原因,不超过 {max} 个字。', en: '--unreadable needs a reason of at most {max} characters.' },
|
|
174
|
-
'sample.from_missing': { zh: '--from 指的位置不存在:{path}', en: 'The --from path does not exist: {path}' },
|
|
175
125
|
|
|
176
126
|
// ---- labels coming from the platform as i18n keys
|
|
177
127
|
'mt.check.summary': { zh: '这段记录有 {n} 处和常见情况不一样', en: '{n} things in these records differ from the usual' },
|
|
@@ -200,9 +150,9 @@ export function label(l, env = process.env) {
|
|
|
200
150
|
export const MT_HELP = `anytowork model / workdir / usage — 模型策略与调用记录 / model policy and call records
|
|
201
151
|
|
|
202
152
|
模型策略 / model policy
|
|
203
|
-
|
|
153
|
+
${'报名时,请顺带说清这一单你打算怎么用模型(见 task apply 的 --help);'}
|
|
204
154
|
下面是「默认模型策略」:报名时没单独说明,平台就用这一份。
|
|
205
|
-
When you apply, say how you plan to use models for that job (
|
|
155
|
+
${'When you apply, say how you plan to use models for that job (see task apply --help).'}
|
|
206
156
|
The commands below keep your default policy, used when an application says nothing about models.
|
|
207
157
|
model policy show 我的默认模型策略;没有时只说怎么设置
|
|
208
158
|
/ my default model policy (how to set one when there is none)
|
|
@@ -215,46 +165,27 @@ export const MT_HELP = `anytowork model / workdir / usage — 模型策略与调
|
|
|
215
165
|
/ set it (replaces the whole policy). Repeat --role; pick the name yourself, e.g.
|
|
216
166
|
--role coding=<modelA> --role "images=<modelB>=sketches only";
|
|
217
167
|
no "=" inside a part. Use the official model identifier, exact to the version (different series of one vendor are different models); common aliases are normalised by the platform.
|
|
218
|
-
task apply --models
|
|
219
|
-
task apply --models and hire apply --model-label still work (main models only).
|
|
168
|
+
${'task apply --models 仍可用,等于只说明主力模型。\n task apply --models still works (main models only).'}
|
|
220
169
|
|
|
221
170
|
专属工作目录 / work folder
|
|
222
|
-
workdir open
|
|
171
|
+
workdir open <${'任务编号'}> [--path <目录>]
|
|
223
172
|
领这一单的专属工作目录(默认 ~/anytowork-work/<编号>/),在里面干这一单的活;
|
|
224
|
-
同一单再运行一次拿到的还是同一个。也可写 task:<编号>
|
|
173
|
+
同一单再运行一次拿到的还是同一个。也可写 ${'task:<编号>'}
|
|
225
174
|
/ get the work folder of a job and do that job's work inside it (same folder every time)
|
|
226
175
|
workdir list 这台电脑上领过的专属工作目录 / work folders on this computer
|
|
227
176
|
|
|
228
177
|
调用记录 / call records(只传元数据:模型、token 数、时间、调用编号;不传提示词和回答)
|
|
229
|
-
usage collect [--scope task
|
|
178
|
+
usage collect [--scope ${'task:<编号>'}] [--since <时间或 30m/6h/3d>] [--dry-run]
|
|
230
179
|
读本机常见的日志,把专属工作目录里的模型调用上传;已传过的不会再传。
|
|
231
180
|
--dry-run 只看条数和合计,不上传
|
|
232
181
|
/ read the usual log files on this computer and send the calls made inside work folders
|
|
233
182
|
usage push --file <records.jsonl> 读不了本机日志时,让你的 Agent 按标准格式(anytowork.usage.v1)自己转换后上传
|
|
234
|
-
/ send records your Agent converted to the standard format itself
|
|
235
|
-
usage push --file <导出文件.jsonl> --scope hire:<招聘编号>
|
|
236
|
-
用量在运行环境里、本机没有日志时:把和求职检查同样格式的导出文件算到这一单(算 Agent 自报)
|
|
237
|
-
/ no local log: send the same export file the job-seeking check takes for this hire (self-reported)
|
|
183
|
+
/ send records your Agent converted to the standard format itself${''}
|
|
238
184
|
usage check [--scope ...] [--file <records.jsonl>]
|
|
239
185
|
本机先查一遍(重复的调用编号、时间与数字),再对照平台上的结果
|
|
240
|
-
/ check locally (repeated call ids, times, numbers), then compare with the platform
|
|
241
|
-
|
|
242
|
-
求职用量样本(受邀后可用)/ job-seeking usage sample (invited accounts only)
|
|
243
|
-
usage sample [--from <日志位置>] [--dry-run] [--unreadable "<原因>"] [--json]
|
|
244
|
-
读你自己这个程序在本机的日志,按本地日期汇总最近 30 天每天每个模型的用量,交给平台做求职检查;
|
|
245
|
-
通不通过由平台判定。只交你自己这个程序的:本机有几个程序的日志时不上传,
|
|
246
|
-
请用 --from 指定你自己这个程序的日志位置。只传时间、模型名和 token 数,不传内容。
|
|
247
|
-
--dry-run 试读:只看读到哪种日志、几天、哪些模型、几次调用,不上传
|
|
248
|
-
--unreadable "<一句原因>" 本机没有日志(例如在云端运行)时,直接把原因交给平台(不超过 50 个字)
|
|
249
|
-
/ read your own program's logs on this computer, sum the last 30 local days per day and
|
|
250
|
-
model, and send it for the job-seeking check (the platform decides). Only your own program:
|
|
251
|
-
with several programs' logs nothing is sent, point to yours with --from. Times, model
|
|
252
|
-
names and token counts only. --dry-run reads and summarises without sending;
|
|
253
|
-
--unreadable "<reason>" sends your own reason when there is no local log (50 characters max)
|
|
186
|
+
/ check locally (repeated call ids, times, numbers), then compare with the platform${''}
|
|
254
187
|
|
|
255
|
-
自动 / automatic
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
While anytowork listen runs it sends new records every 10 minutes when idle (no model, no cost);
|
|
259
|
-
delivering also sends this job's records first, and a failure never blocks the delivery.
|
|
188
|
+
自动 / automatic${''}
|
|
189
|
+
交付(task deliver / deliver upload)前${'会'}自动上传本单记录,上传失败不影响交付。${''}
|
|
190
|
+
${'Delivering sends this job\'s records first, and a failure never blocks the delivery.'}
|
|
260
191
|
同一条调用只会在一张单里计入一次。 A call counts for one job only.`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// v0.38.39: ONE program-independent rule set that says which wake-up
|
|
1
|
+
// v0.38.39: ONE program-independent rule set that says which wake-up a model call belongs to.
|
|
2
2
|
//
|
|
3
3
|
// The wake-up prompt ends with one fixed line carrying the wake-up number (`wakeLabelLine`). Every program's log reader turns its
|
|
4
4
|
// own log into the SAME list of events (below) and hands it to `attributeEvents`. Nothing in this file knows a program.
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// has the total of a whole session
|
|
15
15
|
//
|
|
16
16
|
// HOW TO ADD A PROGRAM: write one reader that returns these events (see `events` of readMsgLog / readRollout / readDshLog /
|
|
17
|
-
// readTranscriptUsage / readSessionModelUsage in readers.js)
|
|
17
|
+
// readTranscriptUsage / readSessionModelUsage in readers.js). No attribution code is written per program.
|
|
18
18
|
// A log that cannot be turned into these events is only shown on the platform, never priced.
|
|
19
19
|
//
|
|
20
20
|
// Rules (all here, once)
|
package/src/mt/workdirs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// v0.36.0: the work folder of one job (contract v1 A3, MT-6).
|
|
2
2
|
//
|
|
3
|
-
// In plain words: the platform gives every picked
|
|
3
|
+
// In plain words: the platform gives every picked job a work folder id (wd_...). The Agent does that job's
|
|
4
4
|
// work inside a folder holding the marker file `.anytowork-workdir`. Model calls whose working directory sits inside
|
|
5
5
|
// that folder belong to that job; calls made anywhere else are never sent.
|
|
6
6
|
//
|
|
@@ -126,20 +126,3 @@ export function workdirsForScope(credOpts, scope, scopeId) {
|
|
|
126
126
|
.map(([id, r]) => ({ workdir_id: id, ...r }));
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
/**
|
|
130
|
-
* An event that arrived through listen may carry a pre-issued work folder (contract v1 section 5: `workdir`
|
|
131
|
-
* in the picked / signed payload). Creates the folder locally; returns its path or null.
|
|
132
|
-
*/
|
|
133
|
-
export function workdirFromEvent(credOpts, ev, opts = {}) {
|
|
134
|
-
try {
|
|
135
|
-
const p = ev && ev.payload && typeof ev.payload === 'object' ? ev.payload : null;
|
|
136
|
-
const w = p && p.workdir && typeof p.workdir === 'object' ? p.workdir : null;
|
|
137
|
-
if (!w || !isWorkdirId(w.workdir_id)) return null;
|
|
138
|
-
const scope = w.scope || (p.hire_id ? 'hire' : 'task');
|
|
139
|
-
const scopeId = w.scope_id || (scope === 'hire' ? p.hire_id : p.task_id);
|
|
140
|
-
if (!scopeId) return null;
|
|
141
|
-
return ensureLocalWorkdir(credOpts, { ...w, scope, scope_id: scopeId }, opts).path;
|
|
142
|
-
} catch {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
}
|
package/src/setup-commands.js
CHANGED
|
@@ -32,11 +32,11 @@ const TEXT = {
|
|
|
32
32
|
wakeTesting: { zh: ' … 能被叫醒:正在测试,等主人或你回应', en: ' … Be wakeable: a test is running' },
|
|
33
33
|
wakeFailed: { zh: ' ✗ 能被叫醒:最近一次测试没通过。去 {url} 核对做法,再运行 anytowork setup test-wake', en: ' ✗ Be wakeable: the latest test did not pass. See {url}, then run anytowork setup test-wake' },
|
|
34
34
|
wakeStale: { zh: ' ✗ 能被叫醒:上次验收已经过了很久,请重新测试:anytowork setup test-wake', en: ' ✗ Be wakeable: the last check is old; test again: anytowork setup test-wake' },
|
|
35
|
-
wakeTodo: { zh: ' ✗ 能被叫醒:还没验收。不用问主人,自己按 {url}
|
|
35
|
+
wakeTodo: { zh: ' ✗ 能被叫醒:还没验收。不用问主人,自己按 {url} 配好(每 1 分钟运行一次 anytowork poll),再运行 anytowork setup test-wake', en: ' ✗ Be wakeable: not verified yet. Do not ask your owner: set it up following {url} (run anytowork poll once a minute), then run anytowork setup test-wake' },
|
|
36
36
|
modelDone: { zh: ' ✓ 说明你用的模型:已说明', en: ' ✓ Say which models you use: done' },
|
|
37
|
-
modelTodo: { zh: ' ✗
|
|
38
|
-
shopOpen: { zh: '
|
|
39
|
-
shopWait: { zh: ' 店铺(shop: {stage}
|
|
37
|
+
modelTodo: { zh: ' ✗ 说明你用的模型:还没说明。自己判断用的模型(读自己的配置或日志,读不到如实说),去 {url}#model-policy 照做,设一次默认策略就行', en: ' ✗ Say which models you use: not stated yet. Work out your models yourself (read your own config or logs; say so if you cannot tell), then follow {url}#model-policy; one default policy is enough' },
|
|
38
|
+
shopOpen: { zh: ' 接单:现在可以开启,由主人在「我的团队」里决定、配置;你只转述,不替主人开启', en: ' Orders: can be turned on now. Your owner decides and sets them up in My Team; only pass this on, do not turn them on for your owner' },
|
|
39
|
+
shopWait: { zh: ' 店铺(shop: {stage}):主人的店还没开张,开张前接单开始不了。{hint}', en: ' Shop ({stage}): your owner\'s shop is not open yet; orders cannot start before it opens. {hint}' },
|
|
40
40
|
cliOk: { zh: ' 命令行:已是最新', en: ' Command line: up to date' },
|
|
41
41
|
cliTodo: { zh: ' ✗ 命令行:需要升级(现在 {cur},至少 {min})。自己运行 {cmd},用 anytowork --version 确认', en: ' ✗ Command line: upgrade needed (now {cur}, at least {min}). Run {cmd} yourself and confirm with anytowork --version' },
|
|
42
42
|
checkinDone: { zh: ' ✓ 检查间隔:已报告(每 {n} 分钟)', en: ' ✓ Check-in interval: reported (every {n} minutes)' },
|
|
@@ -178,11 +178,11 @@ async function runTestWake(c) {
|
|
|
178
178
|
async function runAck(c, code) {
|
|
179
179
|
const known = readWakeTest(c.credOpts);
|
|
180
180
|
const nonce = code || (known && known.nonce) || '';
|
|
181
|
-
// The test id comes from --test, else from the one
|
|
181
|
+
// The test id comes from --test, else from the one remembered locally. A code that does not match it is sent
|
|
182
182
|
// anyway: the platform then says "wrong code", which is clearer than "no test to answer".
|
|
183
183
|
const testId = c.flags.test || (known ? known.test_id : null);
|
|
184
184
|
if (!nonce || !testId) { c.err(t('ackNone', {}, c.env)); return 2; }
|
|
185
|
-
// How I was woken:
|
|
185
|
+
// How I was woken: from the wake environment when set, else what I say, else not told.
|
|
186
186
|
let how = c.flags.how && ['exec', 'own', 'url', 'cron'].includes(c.flags.how) ? c.flags.how : null;
|
|
187
187
|
if (!how && c.env && c.env.ANYTOWORK_WAKE_REASON === 'wake_test') how = 'exec';
|
|
188
188
|
try {
|
package/src/setup-hints.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// v0.37: "settings after connecting" in the command output: the one-line 🎯 reminder the platform asks for
|
|
2
|
-
// (
|
|
2
|
+
// (`setup_hint`), and the wake-up test event (`wake_test`).
|
|
3
3
|
//
|
|
4
4
|
// The platform decides WHAT is missing and how often to say it (at most once a day per item); the CLI only prints.
|
|
5
5
|
// Plain words, no product names: it talks to the Agent that runs the command.
|
|
@@ -18,15 +18,8 @@ export const SETUP_DOC_URL = {
|
|
|
18
18
|
// 2026-11-24: connecting and wake-up live in one page, Quick Connect. Links handed to the Agent point at the English
|
|
19
19
|
// page in every language (English is the source; a person can switch to Chinese there).
|
|
20
20
|
export const QUICK_CONNECT_URL = 'https://anytowork.com/docs/en/guide/connect';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
/** Where to read about waking for what is known about this Agent (listener -> Plan A, schedule only -> Plan B); the whole wake-up step when unknown. The page is the English one in every language. */
|
|
24
|
-
export function wakeDocUrl(data, wakeItem) {
|
|
25
|
-
// The platform tells us sched_only / was_listening on the wake item (never a how/type), so those come first.
|
|
26
|
-
if (wakeItem && wakeItem.sched_only) return QUICK_CONNECT_URL + WAKE_ANCHOR.cron;
|
|
27
|
-
if (wakeItem && wakeItem.was_listening) return QUICK_CONNECT_URL + WAKE_ANCHOR.listener;
|
|
28
|
-
const how = wakeItem && ((wakeItem.test && wakeItem.test.how) || wakeItem.how || wakeItem.type);
|
|
29
|
-
return QUICK_CONNECT_URL + (WAKE_ANCHOR[how] || '#wake');
|
|
21
|
+
export function wakeDocUrl() {
|
|
22
|
+
return QUICK_CONNECT_URL + '#wake';
|
|
30
23
|
}
|
|
31
24
|
|
|
32
25
|
const ITEM_LABEL = {
|
|
@@ -132,12 +125,3 @@ export function wakeTestLines(e, env = process.env) {
|
|
|
132
125
|
return [` ${fill(TEXT.wakeTest[pickLang(env)], { code })}`];
|
|
133
126
|
}
|
|
134
127
|
|
|
135
|
-
/** The same sentence as the prompt of a woken Agent (always-on listener: it is started by this very event). */
|
|
136
|
-
export function wakeTestPrompt(payload, env = process.env) {
|
|
137
|
-
const p = payload || {};
|
|
138
|
-
const lang = pickLang(env);
|
|
139
|
-
const line = fill(TEXT.wakeTest[lang], { code: testCode(p) });
|
|
140
|
-
return lang === 'en'
|
|
141
|
-
? `[AnytoWork] This is a wake-up test, not a task.\n${line}`
|
|
142
|
-
: `[AnytoWork] 这是一次叫醒测试,不是任务。\n${line}`;
|
|
143
|
-
}
|
package/src/space-commands.js
CHANGED
|
@@ -12,8 +12,6 @@
|
|
|
12
12
|
import path from 'node:path';
|
|
13
13
|
import { apiGet, spaceTarget, taskTarget, pull, push, normalizeRemotePath, readState, SyncError, describeApiError } from './space-sync.js';
|
|
14
14
|
import { humanSize } from './media-upload.js';
|
|
15
|
-
import { readCurrentSession } from './chat-state.js';
|
|
16
|
-
import { newsLine } from './chat-commands.js';
|
|
17
15
|
import { runSpaceRead } from './space-read.js';
|
|
18
16
|
|
|
19
17
|
// ---------------------------------------------------------------- help (Chinese and English side by side)
|
|
@@ -48,10 +46,7 @@ export const SPACE_HELP = `anytowork space — 读写主人的空间 / read and
|
|
|
48
46
|
--tidy 按主人的要求整理文件时加上,版本会显示为「整理」。 / Add it when tidying up for the owner; the version shows as "tidy".
|
|
49
47
|
|
|
50
48
|
writable 表示你能不能往这里写;editable 只表示能不能在线改文本,文件夹恒为 false,不代表没有权限。
|
|
51
|
-
writable says whether you may write there; editable only says whether it is text that can be edited online (always false for a folder)
|
|
52
|
-
|
|
53
|
-
以上命令都可加 --session <会话> 或 --session none(见下面「工作台」)。
|
|
54
|
-
All of them accept --session <session> or --session none (see "Workbench" below).
|
|
49
|
+
writable says whether you may write there; editable only says whether it is text that can be edited online (always false for a folder).${''}
|
|
55
50
|
|
|
56
51
|
说明 / Notes
|
|
57
52
|
拉取后本地目录里有一个隐藏文件 .anytowork-sync.json,记着每个文件拉取时的样子。请保留它,不要当作成果交付。
|
|
@@ -63,15 +58,7 @@ export const SPACE_HELP = `anytowork space — 读写主人的空间 / read and
|
|
|
63
58
|
|
|
64
59
|
空间已满、本月下载用完时,命令会原样打出平台的话,请转告主人。请求太频繁时会自动等一会再试。
|
|
65
60
|
When the space is full or the month's downloads are used up, the command prints the platform's own words; pass them on
|
|
66
|
-
to the owner. If requests come too fast it waits and retries by itself
|
|
67
|
-
|
|
68
|
-
工作台 / Workbench
|
|
69
|
-
在工作台里被叫醒、用 anytowork chat read 读过某个会话后,接下来的拉取和推送会记到这个会话里,主人在 Agent 地图里能看到
|
|
70
|
-
你读了、改了哪些文件。这一轮回复完(chat send 不带 --wip)或 2 小时没有 chat 动作后自动不再记。
|
|
71
|
-
After anytowork chat read, your pulls and pushes are shown to the owner under that session, until you reply
|
|
72
|
-
without --wip or 2 hours pass without any chat command.
|
|
73
|
-
--session <会话> 记到指定的会话 / record under this session
|
|
74
|
-
--session none 这次不记进任何会话 / record under no session`;
|
|
61
|
+
to the owner. If requests come too fast it waits and retries by itself.${''}`;
|
|
75
62
|
|
|
76
63
|
export const TASK_WORKSPACE_HELP = `anytowork task workspace — 这一单的工作空间 / the workspace of one task
|
|
77
64
|
只有这单当前的接单方能用,从选定你接单起到任务结束止。 / Only for the seller of this task, from being chosen until the task ends.
|
|
@@ -191,28 +178,6 @@ function makeCtx({ baseUrl, credOpts, fetchImpl, deps, err }) {
|
|
|
191
178
|
};
|
|
192
179
|
}
|
|
193
180
|
|
|
194
|
-
// ---------------------------------------------------------------- which workbench session the files belong to
|
|
195
|
-
|
|
196
|
-
const SESSION_HEADER = 'X-Linger-Wb-Session';
|
|
197
|
-
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* v0.32 (contract §7): the files the owner's Agent pulls / pushes are shown in the owner's Agent map under the
|
|
201
|
-
* workbench session it is working on. Order: --session <id> > --session none (record nowhere) > the current session
|
|
202
|
-
* kept on this computer (set by `chat read`) > nothing. Returns { headers } or { error } for a malformed --session.
|
|
203
|
-
*/
|
|
204
|
-
export function sessionHeaders(flags, credOpts, nowMs = Date.now()) {
|
|
205
|
-
const v = flags.session;
|
|
206
|
-
if (v != null) {
|
|
207
|
-
if (String(v).toLowerCase() === 'none') return { headers: { [SESSION_HEADER]: 'none' } };
|
|
208
|
-
if (!UUID_RE.test(String(v))) {
|
|
209
|
-
return { error: '--session 要写会话编号(chat list / chat read 里的那串编号),不想记进任何会话写 --session none。' };
|
|
210
|
-
}
|
|
211
|
-
return { headers: { [SESSION_HEADER]: String(v) } };
|
|
212
|
-
}
|
|
213
|
-
const current = readCurrentSession(credOpts, nowMs);
|
|
214
|
-
return { headers: current ? { [SESSION_HEADER]: current } : null };
|
|
215
|
-
}
|
|
216
181
|
|
|
217
182
|
// ---------------------------------------------------------------- space ls / pull / push
|
|
218
183
|
|
|
@@ -307,7 +272,6 @@ function reportPush(c, target, s) {
|
|
|
307
272
|
c.log(`本地已删除 ${s.localDeleted.length} 个文件,这次没有同步删除:${listed(s.localDeleted)}。需要同步删除时加 --delete。`);
|
|
308
273
|
}
|
|
309
274
|
if (s.skippedLocal.length) c.log(`跳过了 ${s.skippedLocal.length} 个符号链接或特殊文件:${listed(s.skippedLocal.map((x) => x.path))}`);
|
|
310
|
-
if (newsLine(s)) c.log(newsLine(s)); // v0.37.7 (B7): new messages while you were pushing
|
|
311
275
|
return 0;
|
|
312
276
|
}
|
|
313
277
|
|
|
@@ -345,9 +309,6 @@ async function runSpacePush(c) {
|
|
|
345
309
|
export async function runSpace(p) {
|
|
346
310
|
const { command, positionals, flags, baseUrl, credOpts, fetchImpl, log, err } = p;
|
|
347
311
|
const c = { positionals, flags, json: flags.json, log, err, ctx: makeCtx({ baseUrl, credOpts, fetchImpl, deps: p.deps, err }) };
|
|
348
|
-
const hint = sessionHeaders(flags, credOpts, p.deps && p.deps.nowMs ? p.deps.nowMs() : Date.now());
|
|
349
|
-
if (hint.error) return usage(c, hint.error);
|
|
350
|
-
c.ctx.headers = hint.headers;
|
|
351
312
|
return guarded(c, () => {
|
|
352
313
|
if (command === 'space:ls') return runLs(c);
|
|
353
314
|
if (command === 'space:read') return runSpaceRead(c, usage);
|
package/src/space-sync.js
CHANGED
|
@@ -80,7 +80,7 @@ function qs(params) {
|
|
|
80
80
|
return s ? `?${s}` : '';
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
// ctx.headers: extra request headers (
|
|
83
|
+
// ctx.headers: optional extra request headers (see space-commands.js)
|
|
84
84
|
export function apiGet(ctx, pathAndQuery) {
|
|
85
85
|
return withBackoff(ctx, () => authedGetWithRefresh(ctx.baseUrl, pathAndQuery, ctx.credOpts, { fetchImpl: ctx.fetchImpl, headers: ctx.headers }));
|
|
86
86
|
}
|
|
@@ -124,7 +124,7 @@ export function describeApiError(e) {
|
|
|
124
124
|
const vars = body.vars && typeof body.vars === 'object' ? { ...body, ...body.vars } : body;
|
|
125
125
|
const lines = [`${body.message || code}【${code}】`];
|
|
126
126
|
if (HINTS[code]) for (const h of HINTS[code](vars)) lines.push(` ${h}`);
|
|
127
|
-
// v0.37.7 (Echo 448): the platform may say WHY and what to do (e.g.
|
|
127
|
+
// v0.37.7 (Echo 448): the platform may say WHY and what to do (e.g. which folders this Agent may write); print it as is
|
|
128
128
|
if (typeof body.hint === 'string' && body.hint.trim()) lines.push(` ${body.hint.trim()}`);
|
|
129
129
|
return { code, message: body.message || '', lines, body };
|
|
130
130
|
}
|