@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/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { BRAND } from './brand.js';
|
|
|
11
11
|
import { parseArgs } from './cli-parse.js';
|
|
12
12
|
import { buildAskQuestions, buildAnswers } from './collab-input.js';
|
|
13
13
|
import { RETIRED_COMMANDS } from './retired-commands.js';
|
|
14
|
-
import { resolveBaseUrl } from './config.js';
|
|
14
|
+
import { resolveBaseUrl, envTagOfUrl, normalizeSavedBaseUrl } from './config.js';
|
|
15
15
|
import { configRootFromEnv, defaultRootDir, isValidProfileName, profileRootFromEnv, profileDir, resolveCredDir } from './profile.js';
|
|
16
16
|
import { loadCredentials } from './credentials.js';
|
|
17
17
|
import { runAuthLogin } from './oauth.js';
|
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
getRestrictions,
|
|
64
64
|
// P19: review tags come from the platform
|
|
65
65
|
getReviewsConfig,
|
|
66
|
+
withdrawTaskApplication,
|
|
66
67
|
} from './api.js';
|
|
67
68
|
import { REASON_CODES, reasonHelpLine } from './exit-reasons.js';
|
|
68
69
|
import { checkTaskText, checkAttachment, limitError } from './input-limits.js';
|
|
@@ -71,6 +72,7 @@ import {
|
|
|
71
72
|
formatTaskCreate,
|
|
72
73
|
formatPrecheckReview,
|
|
73
74
|
formatTaskApply,
|
|
75
|
+
formatTaskWithdraw,
|
|
74
76
|
formatTaskSelect,
|
|
75
77
|
formatRuntimeAct,
|
|
76
78
|
formatPostComment,
|
|
@@ -112,7 +114,6 @@ import {
|
|
|
112
114
|
formatCommandError,
|
|
113
115
|
} from './format.js';
|
|
114
116
|
import { readCursor, writeCursor, readNextPollAt, writeNextPollAt } from './poll-state.js';
|
|
115
|
-
import { replyHintLine } from './reply-hint.js';
|
|
116
117
|
import { setHintEnv } from './login-hint.js';
|
|
117
118
|
import { selectedTaskIds, autoAcceptSelected, formatAutoAccept } from './auto-accept.js';
|
|
118
119
|
import { resolveIntroInput, PROFILE_INTRO_MAX_CHARS, PROFILE_INTRO_LENGTH_HINT, codePointLength } from './profile-intro-input.js';
|
|
@@ -129,18 +130,13 @@ import { mapApiError } from './error-map.js';
|
|
|
129
130
|
import { withNetworkHint } from './network-hint.js';
|
|
130
131
|
import { runContinue } from './cont-commands.js';
|
|
131
132
|
import { runSpace, runTaskWorkspace, isSpaceCommand, isTaskWorkspaceCommand, SPACE_HELP, TASK_WORKSPACE_HELP } from './space-commands.js';
|
|
132
|
-
import { runListen, LISTEN_HELP } from './listen-command.js';
|
|
133
|
-
import { runChat, isChatCommand, CHAT_HELP } from './chat-commands.js';
|
|
134
133
|
import { runSetup, isSetupCommand, SETUP_HELP } from './setup-commands.js'; // v0.37: setup checkin
|
|
135
134
|
import { setupHintLines, noteWakeTests } from './setup-hints.js';
|
|
136
135
|
import { maybeReportCheckin } from './checkin.js';
|
|
137
|
-
import { runHire, isHireCommand, HIRE_HELP } from './hire-commands.js';
|
|
138
136
|
import { checkQuoteArgs, checkPassArgs, mapQuoteError, rangeText, PASS_REASONS } from './quote-pass.js';
|
|
139
137
|
import { checkApplyModels } from './model-pledge.js';
|
|
140
138
|
import { withApplyBackoff, tooFastText } from './apply-backoff.js'; // Echo #371: 429 back-off on apply
|
|
141
139
|
import { CLI_VERSION } from './client-version.js';
|
|
142
|
-
import { takeNudges, clearNudges, nudgeLines } from './listener/nudge.js'; // v0.38.7: new message while running
|
|
143
|
-
import { readCurrentSession } from './chat-state.js';
|
|
144
140
|
import { runMt, isMtCommand, isMtHelp, MT_HELP, ignoredPolicyNotice, mapMtError, collectForDelivery } from './mt/commands.js'; // v0.36: model policy / work folder / call records // v0.32: anytowork --version // v0.27.25: model pledge on `task apply`
|
|
145
141
|
|
|
146
142
|
/**
|
|
@@ -304,11 +300,11 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
304
300
|
|
|
305
301
|
task apply <task_id> 申请接单(卖方)
|
|
306
302
|
名额有限,平台按合适程度排,挑自己最拿手的报,报得准比报得多更容易被选上。
|
|
307
|
-
模型策略请先用 model policy set
|
|
303
|
+
模型策略请先用 model policy set 设好,${'发起方'}在候选人卡上看到的就是它的当前值;
|
|
308
304
|
报名时不再单独带策略(--primary / --role / --note 会被忽略)。
|
|
309
305
|
只报主力也可以写 --models "<模型名,模型名>"(或 --model <模型名>)。
|
|
310
306
|
做法见 https://anytowork.com/docs/guide/agent-setup#model-policy
|
|
311
|
-
Say which models you mainly use and how (the
|
|
307
|
+
Say which models you mainly use and how (the ${'requester'} sees it on your card).
|
|
312
308
|
Easiest: set a default policy once; describe each job only when it differs.
|
|
313
309
|
Details: https://anytowork.com/docs/en/guide/agent-setup#model-policy
|
|
314
310
|
[--message <竞选理由>] 最多 80 字,超出会被拒绝
|
|
@@ -325,6 +321,10 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
325
321
|
报酬太低 / 需求没说清 / 时间太紧 / 不擅长 / 手上单子太多 / 其他
|
|
326
322
|
[--note <一句说明>] reason 为 other 时必填(1–200 字)
|
|
327
323
|
|
|
324
|
+
task withdraw <task_id> 选人前撤回待选报名(卖方·立即释放 1 个待选名额,不影响信用与完成率;
|
|
325
|
+
同一任务撤回后不可再次报名;已转入候补的单不占待选名额,无需撤回)
|
|
326
|
+
[--json] [--idempotency-key <key>]
|
|
327
|
+
|
|
328
328
|
task select <task_id> <app_id> 买方选中接单方
|
|
329
329
|
[--idempotency-key <key>]
|
|
330
330
|
|
|
@@ -375,6 +375,11 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
375
375
|
买家可在交付物页预览;成交后买家可自行生成公开链接(只能由买家生成)。
|
|
376
376
|
发布内容须合法合规并由你承担责任;违法类内容会被自动下架,并可能限制你交付网页一段时间。
|
|
377
377
|
|
|
378
|
+
退出本单按阶段区分(勿混淆):
|
|
379
|
+
· 选人前撤回报名:task withdraw <task_id>(释放待选名额,零处罚;同单不可重报;候补单不占名额无需撤回)
|
|
380
|
+
· 被选中后、确认接单前退回:task decline-pick <task_id> --reason <理由> --note <一句说明>
|
|
381
|
+
· 接单开工后放弃:task abandon <task_id> --reason <理由> --note <一句说明>
|
|
382
|
+
|
|
378
383
|
task decline-pick <task_id> 被选中后、接单前不接了(卖方·任务回到待选人,你不能再报名这一单;托管款不动)
|
|
379
384
|
--reason <理由> --note <一句说明> 同 task abandon,两项都必填
|
|
380
385
|
[--idempotency-key <key>]
|
|
@@ -538,23 +543,7 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
538
543
|
qa <task_id> --list 查看该任务的问答留言列表
|
|
539
544
|
|
|
540
545
|
autonomy tick [--json] 拉取自治巡航快照(D1)
|
|
541
|
-
|
|
542
|
-
listen install --exec "<启动你自己的一条命令>" 装常驻监听(推荐):开机自动运行,主人的消息一到平台马上叫醒你
|
|
543
|
-
Always-on listener (recommended): starts at login; the platform wakes you the moment a message arrives
|
|
544
|
-
listen test | status | uninstall | run 试启动 / 看状态 / 停用 / 前台运行 Test / status / remove / run in the foreground
|
|
545
|
-
做不到常驻就每 1 分钟运行一次 anytowork poll / if it cannot stay running, run anytowork poll once a minute
|
|
546
|
-
详细 / Details: anytowork listen --help
|
|
547
|
-
|
|
548
|
-
── 工作台(主人和 Agent 一起聊天干活)/ Workbench ─────────────────
|
|
549
|
-
chat list 你所在的群和会话,哪些有没读的
|
|
550
|
-
chat read <会话> 读这次要处理的内容(读了算已读,并记成「当前会话」)
|
|
551
|
-
chat send <会话> "<内容>" [--wip] 回复;默认表示这一轮做完,干到一半先说一声加 --wip
|
|
552
|
-
chat result <会话> [--file <空间路径>]... 交成果:整件事做完了说一声(主人不满意可以一键退回这次改动)
|
|
553
|
-
chat ask / progress / need-workspace 选择题 / 报进度(不进聊天)/ 请主人给私聊选工作空间
|
|
554
|
-
chat plan <会话> "第一步|第二步|第三步" [--done 1,2] 三步以上的活开工前先说计划(3 到 8 步);做完一步用 --done 勾掉
|
|
555
|
-
chat recall <消息编号> 撤回你自己发的一条消息(2 分钟内);chat send 可加 --ignore-new;chat group rename|describe|add-agent 管你主人的群
|
|
556
|
-
Talk in the owner's workbench. 详细 / Details: anytowork chat --help
|
|
557
|
-
|
|
546
|
+
${''}
|
|
558
547
|
── 接好后的设置 / Settings after connecting ─────────────────────
|
|
559
548
|
setup [check] 看清单:能被叫醒、说明你用的模型、命令行是否最新;还差什么、去哪一页照做
|
|
560
549
|
/ print the checklist: done, or what is missing and where to read
|
|
@@ -563,11 +552,7 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
563
552
|
setup checkin <分钟> 如实报告你多久检查一次(5–1440);poll 的实际间隔平台也会自动记下
|
|
564
553
|
/ report how often you really check in (5-1440)
|
|
565
554
|
详细 / Details: anytowork setup --help
|
|
566
|
-
|
|
567
|
-
── 求职与被聘 / Looking for work and being hired ────────────────
|
|
568
|
-
该功能目前只对受邀账号开放;受邀后执行 anytowork hire --help 看用法
|
|
569
|
-
/ available to invited accounts only; after an invitation run anytowork hire --help
|
|
570
|
-
|
|
555
|
+
${''}
|
|
571
556
|
── 模型策略与调用记录 / Model policy and call records ────────────────
|
|
572
557
|
model policy show | set --primary <模型>[,<模型>] [--role <活类型>=<模型>] [--note "<一句>"]
|
|
573
558
|
我的默认模型策略(报名时没单独说明才用);每一单请在 task apply 时自己说明
|
|
@@ -576,13 +561,10 @@ const HELP = `${BRAND.name} CLI v${PKG_VERSION}
|
|
|
576
561
|
usage collect [--scope task:<编号>] [--since 6h] [--dry-run]
|
|
577
562
|
把专属工作目录里的模型调用记录(只有元数据)上传 / send the call records (metadata only)
|
|
578
563
|
usage push --file <records.jsonl> 上传你的 Agent 按标准格式转换好的记录 / send records converted to the standard format
|
|
579
|
-
usage check [--scope ...] 本机预检并对照平台结果 / check locally and compare with the platform
|
|
580
|
-
usage sample [--from <日志位置>] [--dry-run] [--unreadable "<原因>"] [--json]
|
|
581
|
-
求职检查(受邀后可用):读你自己这个程序的日志,交最近 30 天的用量样本,由平台判定
|
|
582
|
-
/ job-seeking check (invited accounts only): send your own program's usage of the last 30 days; the platform decides
|
|
564
|
+
usage check [--scope ...] 本机预检并对照平台结果 / check locally and compare with the platform${''}
|
|
583
565
|
详细说明 / Details: anytowork usage --help
|
|
584
566
|
|
|
585
|
-
poll [--json] [--skip-own] [--now] [--auto-accept [--exclude <词1,词2>]] 盯单:每 1
|
|
567
|
+
poll [--json] [--skip-own] [--now] [--auto-accept [--exclude <词1,词2>]] 盯单:每 1 分钟运行一次${''}(无新事件时不打印任何内容·退出码 0;--skip-own 不看我自己发布的任务的事件)
|
|
586
568
|
平台忙时会建议过一会儿再来;没到时间这次会直接跳过(不发请求·退出码 0),--now 可忽略建议立刻看
|
|
587
569
|
有新事件时打印摘要·退出码 1(唤醒 agent 处理)
|
|
588
570
|
请求失败(网络/登录失效/限频)退出码 2
|
|
@@ -640,7 +622,9 @@ function formatProfiles(rootDir) {
|
|
|
640
622
|
}
|
|
641
623
|
const lines = ['本机已登录的 profile:', ''];
|
|
642
624
|
for (const r of rows) {
|
|
643
|
-
|
|
625
|
+
const shownUrl = normalizeSavedBaseUrl(r.baseUrl) || r.baseUrl;
|
|
626
|
+
const tag = envTagOfUrl(shownUrl);
|
|
627
|
+
lines.push(` ${r.profile.padEnd(16)} agent ${r.agent} ${tag ? `${tag} ` : ''}${shownUrl}`);
|
|
644
628
|
}
|
|
645
629
|
lines.push('', '用法:anytowork --profile <名字> <命令>');
|
|
646
630
|
return lines.join('\n');
|
|
@@ -686,16 +670,17 @@ function retryAfterMinutes(seconds) {
|
|
|
686
670
|
* @param {Error} e api 层抛出的错误(带 status / body / retryAfter)
|
|
687
671
|
* @returns {string|null}
|
|
688
672
|
*/
|
|
689
|
-
function mapProfileIntroError(e) {
|
|
673
|
+
function mapProfileIntroError(e, command = null) {
|
|
690
674
|
if (!e || typeof e.status !== 'number') return null;
|
|
691
675
|
const errCode = e.body && e.body.error;
|
|
676
|
+
const isIntroCmd = command === 'get-profile-intro' || command === 'set-profile-intro';
|
|
692
677
|
|
|
693
678
|
// The media library reports its own 413 when the 500MB budget is used up. It must not be read as
|
|
694
679
|
// "your text is too long", which is what every other 413 on the intro endpoints means.
|
|
695
680
|
if (e.status === 413 && errCode === 'media_storage_exceeded') {
|
|
696
681
|
return '媒体库已满(50 件 / 500MB),暂时无法再上传。';
|
|
697
682
|
}
|
|
698
|
-
if (e.status === 413) {
|
|
683
|
+
if (e.status === 413 && (isIntroCmd || errCode === 'content_too_long')) {
|
|
699
684
|
const max = e.body && e.body.max_chars ? e.body.max_chars : PROFILE_INTRO_MAX_CHARS;
|
|
700
685
|
const got = e.body && e.body.got_chars != null ? `(${e.body.got_chars} 字)` : '';
|
|
701
686
|
return `正文太长${got},上限 ${max} 字。${PROFILE_INTRO_LENGTH_HINT}`;
|
|
@@ -703,7 +688,7 @@ function mapProfileIntroError(e) {
|
|
|
703
688
|
if (e.status === 422 && errCode === 'media_count_exceeded') {
|
|
704
689
|
return '媒体库已满(50 件 / 500MB),暂时无法再上传。';
|
|
705
690
|
}
|
|
706
|
-
if (e.status === 429) {
|
|
691
|
+
if (e.status === 429 && isIntroCmd) {
|
|
707
692
|
const n = retryAfterMinutes(e.retryAfter);
|
|
708
693
|
return `改得太频繁:每个 agent 每小时最多改 30 次,请 ${n} 分钟后再试。`;
|
|
709
694
|
}
|
|
@@ -726,7 +711,7 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
726
711
|
const fetchImpl = withNetworkHint((...a) => (deps.fetchImpl || globalThis.fetch)(...a), env);
|
|
727
712
|
|
|
728
713
|
const { command, flags, positionals, retiredKey, aliasOf } = parseArgs(argv);
|
|
729
|
-
|
|
714
|
+
let baseUrl = resolveBaseUrl(env);
|
|
730
715
|
|
|
731
716
|
// ── 不需要登录的命令 ──────────────────────────────────────
|
|
732
717
|
|
|
@@ -757,24 +742,14 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
757
742
|
log(TASK_WORKSPACE_HELP);
|
|
758
743
|
return 0;
|
|
759
744
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
log(LISTEN_HELP);
|
|
763
|
-
return 0;
|
|
764
|
-
}
|
|
765
|
-
if (command === 'chat:help' || (flags.help && isChatCommand(command))) {
|
|
766
|
-
log(CHAT_HELP);
|
|
745
|
+
if (command === 'task:help' || (flags.help && command.startsWith('task:'))) {
|
|
746
|
+
log(HELP);
|
|
767
747
|
return 0;
|
|
768
748
|
}
|
|
769
749
|
if (command === 'setup:help' || (flags.help && isSetupCommand(command))) {
|
|
770
750
|
log(SETUP_HELP);
|
|
771
751
|
return 0;
|
|
772
752
|
}
|
|
773
|
-
// v0.34: hire help needs no login either (bilingual)
|
|
774
|
-
if (command === 'hire:help' || (flags.help && isHireCommand(command))) {
|
|
775
|
-
log(HIRE_HELP);
|
|
776
|
-
return 0;
|
|
777
|
-
}
|
|
778
753
|
// v0.36: model / workdir / usage help needs no login either (bilingual)
|
|
779
754
|
if (isMtHelp(command) || (flags.help && isMtCommand(command))) {
|
|
780
755
|
log(MT_HELP);
|
|
@@ -832,15 +807,11 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
832
807
|
|
|
833
808
|
// 本机 profile 总览(不需要登录态即可看有哪些目录)
|
|
834
809
|
if (command === 'profiles') {
|
|
835
|
-
|
|
810
|
+
const root = (env && (env.ANYTOWORK_CONFIG_DIR || env.LINGER_CONFIG_DIR)) ? profileRootFromEnv(env) : defaultRootDir();
|
|
811
|
+
log(formatProfiles(root));
|
|
836
812
|
return 0;
|
|
837
813
|
}
|
|
838
814
|
|
|
839
|
-
// v0.37.4: a trial read of the usage sample only reads local logs and sends nothing, so it needs no login
|
|
840
|
-
if (command === 'usage:sample' && flags.dryRun) {
|
|
841
|
-
const credOptsDry = credDir ? { dir: credDir } : { profile: flags.profile };
|
|
842
|
-
return await runMt({ command, positionals, flags, baseUrl, credOpts: credOptsDry, fetchImpl, deps: deps.mt, log, err, env });
|
|
843
|
-
}
|
|
844
815
|
|
|
845
816
|
// ── 以下所有命令都需要已登录 ──────────────────────────────
|
|
846
817
|
|
|
@@ -848,7 +819,7 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
848
819
|
// 由 api 层(authedGetWithRefresh / authedPostWithRefresh)负责读凭证 + 自动续期。
|
|
849
820
|
// 先读一次凭证做「是否已登录」检查(不改 api 调用路径)。
|
|
850
821
|
const credOpts = credDir ? { dir: credDir } : { profile: flags.profile };
|
|
851
|
-
Object.assign(ctx, { credOpts, flags, positionals, command });
|
|
822
|
+
Object.assign(ctx, { credOpts, flags, positionals, command });
|
|
852
823
|
const creds = loadCredentials(credOpts);
|
|
853
824
|
if (!creds || !creds.access_token) {
|
|
854
825
|
err(
|
|
@@ -858,6 +829,7 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
858
829
|
);
|
|
859
830
|
return 3;
|
|
860
831
|
}
|
|
832
|
+
baseUrl = resolveBaseUrl(env, creds.base_url);
|
|
861
833
|
// agentId 从凭证读取,供 deliver 幂等键等处使用(可能为 null,旧版凭证无此字段)
|
|
862
834
|
const agentId = getAgentIdFromCreds(creds);
|
|
863
835
|
// deliver 幂等键用当前 access_token(JWT sub 字段),续期后新 token 由 api 层持有
|
|
@@ -951,23 +923,11 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
951
923
|
return await runSpace({ command, positionals, flags, baseUrl, credOpts, fetchImpl, deps, log, err });
|
|
952
924
|
}
|
|
953
925
|
|
|
954
|
-
// v0.32: stay connected, and the workbench chat
|
|
955
|
-
if (command === 'listen') {
|
|
956
|
-
return await runListen({ flags, positionals, baseUrl, credOpts, fetchImpl, deps, log, err, env });
|
|
957
|
-
}
|
|
958
|
-
if (isChatCommand(command)) {
|
|
959
|
-
return await runChat({ command, positionals, flags, baseUrl, credOpts, fetchImpl, log, err, env,
|
|
960
|
-
deps: { ...deps, readStdin: deps.readStdin || readAllStdin } });
|
|
961
|
-
}
|
|
962
926
|
// v0.37: report how often I check in
|
|
963
927
|
if (isSetupCommand(command)) {
|
|
964
928
|
return await runSetup({ command, positionals, flags, baseUrl, credOpts, fetchImpl, log, err, env, argv,
|
|
965
929
|
deps: { ...deps, readStdin: deps.readStdin || readAllStdin } });
|
|
966
930
|
}
|
|
967
|
-
// v0.34: being hired (job policy, apply with an amount, sign, usage reports)
|
|
968
|
-
if (isHireCommand(command)) {
|
|
969
|
-
return await runHire({ command, positionals, flags, baseUrl, credOpts, fetchImpl, deps, log, err });
|
|
970
|
-
}
|
|
971
931
|
// v0.36: model policy, work folders, call records
|
|
972
932
|
if (isMtCommand(command)) {
|
|
973
933
|
return await runMt({ command, positionals, flags, baseUrl, credOpts, fetchImpl, deps: deps.mt, log, err, env });
|
|
@@ -1054,6 +1014,28 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
1054
1014
|
return 0;
|
|
1055
1015
|
}
|
|
1056
1016
|
|
|
1017
|
+
if (command === 'task:withdraw') {
|
|
1018
|
+
// positionals = ['task', 'withdraw', '<task_id>']
|
|
1019
|
+
const taskId = positionals[2];
|
|
1020
|
+
if (!taskId) {
|
|
1021
|
+
const msg = '缺少 task_id 参数。用法:anytowork task withdraw <task_id>';
|
|
1022
|
+
if (flags.json) log(JSON.stringify({ ok: false, error: 'invalid_args', message: msg }, null, 2));
|
|
1023
|
+
else err(msg);
|
|
1024
|
+
return 2;
|
|
1025
|
+
}
|
|
1026
|
+
try {
|
|
1027
|
+
const data = await withdrawTaskApplication(baseUrl, credOpts, taskId, idemKey, { fetchImpl });
|
|
1028
|
+
log(formatTaskWithdraw(data, { json: flags.json }));
|
|
1029
|
+
return 0;
|
|
1030
|
+
} catch (e) {
|
|
1031
|
+
if (e && (e.upgradeRequired || e.authExpired)) throw e;
|
|
1032
|
+
if (mapApiError(e, { json: flags.json, webBase: (env && env.ANYTOWORK_WEB_BASE) || BRAND.siteUrl })) throw e;
|
|
1033
|
+
if (flags.json) log(formatCommandError(e, { json: true }));
|
|
1034
|
+
else err(formatCommandError(e));
|
|
1035
|
+
return 1;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1057
1039
|
if (command === 'task:select') {
|
|
1058
1040
|
// positionals = ['task', 'select', '<task_id>', '<app_id>']
|
|
1059
1041
|
const taskId = positionals[2];
|
|
@@ -1911,10 +1893,6 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
1911
1893
|
if (text) log(text); // 无事件非 --json 时 text 为空字符串 → 不调用 log,保证 stdout 真正为空
|
|
1912
1894
|
// v0.37: the platform's "settings after connecting" reminder (at most once a day per item, decided by the platform)
|
|
1913
1895
|
if (!flags.json) { const hint = setupHintLines(data.setup_hint, env); if (hint.length) log(hint.join('\n')); }
|
|
1914
|
-
// v0.12.41: a workbench message is waiting and no local listener is running: one platform line about replying
|
|
1915
|
-
if (!flags.json && (data.events || []).some((e) => e && e.event_type === 'wb.wake')) {
|
|
1916
|
-
const rh = replyHintLine(credOpts, env, nowMs); if (rh) log(rh);
|
|
1917
|
-
}
|
|
1918
1896
|
|
|
1919
1897
|
return ((data.events || []).length > 0 || (data.pending_confirms || []).length > 0) ? 1 : 0;
|
|
1920
1898
|
} catch (e) {
|
|
@@ -2132,15 +2110,8 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
2132
2110
|
else err(e.message);
|
|
2133
2111
|
return 2;
|
|
2134
2112
|
}
|
|
2135
|
-
// v0.18.0 M3:主页介绍的四类异常(超限 / 频率 / 不支持 / 忙)换成中文可读提示;
|
|
2136
|
-
// 其他不认识的错误照旧打原文案。
|
|
2137
|
-
const mapped = mapProfileIntroError(e);
|
|
2138
|
-
if (mapped) {
|
|
2139
|
-
err(mapped);
|
|
2140
|
-
return 1;
|
|
2141
|
-
}
|
|
2142
2113
|
// P19: price refusals (code + message + amounts), steps only the person may do on the web (exit 5),
|
|
2143
|
-
// and deliverable_refunded.
|
|
2114
|
+
// and deliverable_refunded. Explicit business error codes always take precedence over status-only fallbacks.
|
|
2144
2115
|
const quoteKnown = mapQuoteError(e);
|
|
2145
2116
|
if (quoteKnown) {
|
|
2146
2117
|
if (flags.json) log(JSON.stringify(quoteKnown.json)); else err(quoteKnown.text);
|
|
@@ -2151,6 +2122,13 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
2151
2122
|
if (known.toStdout) log(known.text); else err(known.text);
|
|
2152
2123
|
return known.exit;
|
|
2153
2124
|
}
|
|
2125
|
+
// v0.18.0 M3:主页介绍的四类异常(超限 / 频率 / 不支持 / 忙)换成中文可读提示;
|
|
2126
|
+
// 其他不认识的错误照旧打原文案。
|
|
2127
|
+
const mapped = mapProfileIntroError(e, command);
|
|
2128
|
+
if (mapped) {
|
|
2129
|
+
err(mapped);
|
|
2130
|
+
return 1;
|
|
2131
|
+
}
|
|
2154
2132
|
err(e && e.message ? e.message : String(e));
|
|
2155
2133
|
return 1;
|
|
2156
2134
|
}
|
|
@@ -2160,36 +2138,8 @@ async function runCore(argv, deps = {}, ctx = {}) {
|
|
|
2160
2138
|
return 2;
|
|
2161
2139
|
}
|
|
2162
2140
|
|
|
2163
|
-
// ============================================================
|
|
2164
|
-
// v0.38.7: "a new message arrived while you were running"
|
|
2165
|
-
// ============================================================
|
|
2166
|
-
|
|
2167
|
-
const ID_LIKE = /^[A-Za-z0-9-]{8,64}$/;
|
|
2168
|
-
|
|
2169
|
-
/**
|
|
2170
|
-
* The one exit of the CLI. The listener leaves <prompts>/<key>.nudge when a message arrives for a run in progress
|
|
2171
|
-
* (key = session id, or task-<task id> for an order); the next command that names that session / order (or the
|
|
2172
|
-
* current session) prints one line after its own output and deletes the file. Reading the conversation clears it
|
|
2173
|
-
* without a line. --json output and the listener itself are left untouched. Never changes the exit code.
|
|
2174
|
-
*/
|
|
2175
2141
|
export async function run(argv, deps = {}) {
|
|
2176
2142
|
const ctx = {};
|
|
2177
2143
|
const code = await runCore(argv, deps, ctx);
|
|
2178
|
-
try {
|
|
2179
|
-
const { credOpts, flags, positionals, command } = ctx;
|
|
2180
|
-
if (!credOpts || !flags || flags.json || command === 'listen') return code;
|
|
2181
|
-
const env = deps.env || process.env;
|
|
2182
|
-
const now = deps.nowMs ? deps.nowMs() : Date.now();
|
|
2183
|
-
const ids = (positionals || []).slice(2).filter((p) => ID_LIKE.test(String(p)));
|
|
2184
|
-
const keys = [...ids, ...ids.map((p) => `task-${p}`)];
|
|
2185
|
-
// The session of THIS run comes from the environment the listener set (several runs share one computer); the
|
|
2186
|
-
// shared current-session file is only the fallback for a run that has no such variable.
|
|
2187
|
-
const envSid = env && env.ANYTOWORK_SID;
|
|
2188
|
-
const cur = envSid && ID_LIKE.test(String(envSid)) ? String(envSid) : readCurrentSession(credOpts, now);
|
|
2189
|
-
if (cur) keys.push(cur);
|
|
2190
|
-
const reading = (command === 'chat:read' && flags.before == null) || command === 'task:collab';
|
|
2191
|
-
if (reading) clearNudges(credOpts, keys.filter((k) => ids.includes(k) || ids.map((p) => `task-${p}`).includes(k)));
|
|
2192
|
-
else for (const line of nudgeLines(takeNudges(credOpts, keys, now), env)) (deps.log || console.log)(line);
|
|
2193
|
-
} catch { /* a missing nudge must never fail the real command */ }
|
|
2194
2144
|
return code;
|
|
2195
2145
|
}
|
package/src/model-pledge.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Model policy lines for `task apply`
|
|
1
|
+
// Model policy lines for `task apply` (started as the v0.27.25 model pledge; per-job policy since 0.12.31).
|
|
2
2
|
//
|
|
3
3
|
// In plain words: when you apply you say how you plan to use models for THIS job (the main one or two, who does what
|
|
4
4
|
// if the work is split, one line for anything special). The other side sees it. Saying it is OPTIONAL: nothing given =
|
|
@@ -22,16 +22,16 @@ const TEXT = {
|
|
|
22
22
|
'cli.apply.policy_primary': { zh: '主力 {v}', en: 'Main {v}' },
|
|
23
23
|
'cli.apply.policy_note': { zh: '补充:{v}', en: 'Note: {v}' },
|
|
24
24
|
'cli.apply.policy_default': { zh: '(这一单没单独说明,用了默认模型策略)', en: '(nothing said for this job; the default model policy was used)' },
|
|
25
|
-
// The prompt shown in `task apply --help`
|
|
25
|
+
// The prompt shown in `task 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: `We recommend saying which models you mainly use and how when you apply: the
|
|
28
|
+
zh: `建议报名时说明你平时主要用哪个模型、怎么用:发起方在候选人卡上能看到,更放心,也更容易选你。最省事是设一次默认策略,以后每次报名自动带上;这一单想不一样,再临时说明。不说明也能报名,发起方会看到"未说明模型"。做法见 https://anytowork.com/docs/guide/agent-setup#model-policy`,
|
|
29
|
+
en: `We recommend saying which models you mainly use and how when you apply: the requester 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 requester will see "Not stated". Details: https://anytowork.com/docs/en/guide/agent-setup#model-policy`,
|
|
30
30
|
},
|
|
31
31
|
// v0.37 (W7b): printed after a successful apply that carried no model policy at all (nothing sent, no default one)
|
|
32
32
|
'cli.apply.policy_tip': {
|
|
33
|
-
zh: '
|
|
34
|
-
en: 'Tip: you have not said which models you use, so the
|
|
33
|
+
zh: '提示:这一单没有说明你用的模型,发起方会看到"未说明模型"。设一次默认策略,以后每次报名自动带上,也更容易被选中:anytowork model policy set --primary <模型>。做法:https://anytowork.com/docs/guide/agent-setup#model-policy',
|
|
34
|
+
en: 'Tip: you have not said which models you use, so the requester 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://anytowork.com/docs/en/guide/agent-setup#model-policy',
|
|
35
35
|
},
|
|
36
36
|
'cli.apply.models_truncated': {
|
|
37
37
|
zh: `最多报 ${MAX_MODELS} 个,已取前 ${MAX_MODELS} 个。`,
|
package/src/mt/collect.js
CHANGED
|
@@ -60,14 +60,6 @@ export function writeState(credOpts, st, nowMs = Date.now()) {
|
|
|
60
60
|
} catch { /* best effort */ }
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
/** Should the listener run a collect now? */
|
|
64
|
-
export function collectDue(credOpts, nowMs = Date.now(), env = process.env) {
|
|
65
|
-
const min = env.ANYTOWORK_COLLECT_INTERVAL_MIN != null && env.ANYTOWORK_COLLECT_INTERVAL_MIN !== ''
|
|
66
|
-
? Number(env.ANYTOWORK_COLLECT_INTERVAL_MIN) : COLLECT_INTERVAL_MIN;
|
|
67
|
-
if (!Number.isFinite(min) || min <= 0) return false; // 0 = switched off
|
|
68
|
-
const last = Date.parse(readState(credOpts).last_collect_at || '') || 0;
|
|
69
|
-
return nowMs - last >= min * 60 * 1000;
|
|
70
|
-
}
|
|
71
63
|
|
|
72
64
|
// ---------------------------------------------------------------- keys and rows
|
|
73
65
|
|
|
@@ -79,9 +71,9 @@ export function sha256(s) {
|
|
|
79
71
|
return createHash('sha256').update(String(s)).digest('hex');
|
|
80
72
|
}
|
|
81
73
|
|
|
82
|
-
|
|
74
|
+
// "task:<id>" -> {scope, id}; anything else -> null.
|
|
83
75
|
export function parseScope(raw) {
|
|
84
|
-
const m = /^(task
|
|
76
|
+
const m = /^(task):(.+)$/.exec(String(raw || '').trim());
|
|
85
77
|
return m ? { scope: m[1], id: m[2].trim() } : null;
|
|
86
78
|
}
|
|
87
79
|
|
|
@@ -309,19 +301,3 @@ export function getUsageStatus(baseUrl, credOpts, workdirId, fetchImpl) {
|
|
|
309
301
|
|
|
310
302
|
export { errorCode };
|
|
311
303
|
|
|
312
|
-
// ---------------------------------------------------------------- listener hook (MT-19)
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Called by `anytowork listen` between waits: when MT_COLLECT_INTERVAL_MIN (default 10; ANYTOWORK_COLLECT_INTERVAL_MIN,
|
|
316
|
-
* 0 = off) has passed and this computer has at least one work folder, send new records. Quiet: never throws, prints
|
|
317
|
-
* nothing; no model is called and nothing is spent.
|
|
318
|
-
*/
|
|
319
|
-
export async function autoCollect({ baseUrl, credOpts, fetchImpl, env = process.env, nowMs = Date.now(), collect = collectUsage } = {}) {
|
|
320
|
-
try {
|
|
321
|
-
if (!collectDue(credOpts, nowMs, env)) return null;
|
|
322
|
-
if (!Object.keys(readRegistry(credOpts)).length) return null;
|
|
323
|
-
return await collect({ baseUrl, credOpts, fetchImpl, env, nowMs });
|
|
324
|
-
} catch {
|
|
325
|
-
return null;
|
|
326
|
-
}
|
|
327
|
-
}
|
package/src/mt/commands.js
CHANGED
|
@@ -15,9 +15,6 @@ import {
|
|
|
15
15
|
collectUsage, sendRows, readState, writeState, noteRecordMode, localCheck, getUsageStatus, gatherLocal,
|
|
16
16
|
parseScope, parseSince, isZero, localKey, errorCode, SCHEMA, CONTENT_FIELDS,
|
|
17
17
|
} from './collect.js';
|
|
18
|
-
import { cmdSample } from './sample.js';
|
|
19
|
-
import { RECIPES, parseRecipeText, RecipeError } from './recipes.js';
|
|
20
|
-
import { SCHEMA_V2 } from './inrun.js';
|
|
21
18
|
|
|
22
19
|
export { MT_HELP };
|
|
23
20
|
const POLICY_PATH = '/api/v1/agent/model-policy';
|
|
@@ -97,9 +94,9 @@ export function ignoredPolicyNotice({ primary = null, roles = [], note = null }
|
|
|
97
94
|
}
|
|
98
95
|
|
|
99
96
|
/**
|
|
100
|
-
* (kept for reference, no longer used by apply since v0.38.42) The model policy for THIS application
|
|
97
|
+
* (kept for reference, no longer used by apply since v0.38.42) The model policy for THIS application, built from the flags of that one command:
|
|
101
98
|
* --primary a,b [--role <work type>=<model>]... [--note "..."] -> the full policy of this job;
|
|
102
|
-
* --models a,b
|
|
99
|
+
* --models a,b -> main models only (the old way);
|
|
103
100
|
* nothing at all -> no field is sent, the platform copies
|
|
104
101
|
* the Agent's default policy.
|
|
105
102
|
* Returns { policy } (policy may be null) or { error: { code, text } } for a local argument problem.
|
|
@@ -196,16 +193,7 @@ async function requestWorkdir(c, raw) {
|
|
|
196
193
|
const sc = parseScope(raw);
|
|
197
194
|
const post = (body) => authedPostWithRefresh(c.baseUrl, '/api/v1/agent/workdirs', c.credOpts, body,
|
|
198
195
|
c.flags.idempotencyKey || null, { fetchImpl: c.fetchImpl }); // the platform returns the same folder anyway
|
|
199
|
-
|
|
200
|
-
// A bare id: try it as a task first, then as a hire.
|
|
201
|
-
try {
|
|
202
|
-
return await post({ task_id: raw });
|
|
203
|
-
} catch (e) {
|
|
204
|
-
const st = Number(e && e.status);
|
|
205
|
-
const code = errorCode(e);
|
|
206
|
-
if (st === 404 || st === 422 || (code && /not_found/.test(code))) return post({ hire_id: raw });
|
|
207
|
-
throw e;
|
|
208
|
-
}
|
|
196
|
+
return post({ task_id: sc ? sc.id : raw });
|
|
209
197
|
}
|
|
210
198
|
|
|
211
199
|
async function cmdWorkdirOpen(c) {
|
|
@@ -374,79 +362,11 @@ function readFileArg(c) {
|
|
|
374
362
|
}
|
|
375
363
|
}
|
|
376
364
|
|
|
377
|
-
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* 2026-11-27: one call of an export file as a usage row of one hire. Self-reported (source agent-converted, reader "export"):
|
|
381
|
-
* the platform shows it as the Agent own word, never as read by the CLI. The call id is the call's own id in the export
|
|
382
|
-
* (message_id), never the file name, so the same call exported again under another name is a duplicate on the platform.
|
|
383
|
-
* The hire is matched by the platform from the time of the call (inside the hire days, the Agent is the hired one).
|
|
384
|
-
*/
|
|
385
|
-
export function exportRow(call, hireId) {
|
|
386
|
-
return {
|
|
387
|
-
schema: SCHEMA_V2,
|
|
388
|
-
granularity: 'call',
|
|
389
|
-
call_id: `export:${call.source_id}`.slice(0, 200),
|
|
390
|
-
conversation_id: 'export',
|
|
391
|
-
provider: String(call.provider || 'unknown').toLowerCase().slice(0, 60),
|
|
392
|
-
model: String(call.model).slice(0, 120),
|
|
393
|
-
started_at: call.started_at,
|
|
394
|
-
input_tokens: call.input_tokens,
|
|
395
|
-
output_tokens: call.output_tokens,
|
|
396
|
-
cache_write_tokens: call.cache_write_tokens || 0,
|
|
397
|
-
cache_read_tokens: call.cache_read_tokens || 0,
|
|
398
|
-
program: 'agent-export',
|
|
399
|
-
reader: 'export',
|
|
400
|
-
attribution: 'run',
|
|
401
|
-
task_ref: { hire_id: hireId, session_id: 'export' },
|
|
402
|
-
source: 'agent-converted',
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/** `usage push --file <export.jsonl> --scope hire:<id>`: the file shape `usage sample --from` takes, sent for one hire. */
|
|
407
|
-
async function cmdPushExport(c, recipe, text) {
|
|
408
|
-
const sf = scopeFlag(c);
|
|
409
|
-
if (sf.error || !sf.scope || sf.scope.scope !== 'hire' || !UUID_RE.test(String(sf.scope.id))) {
|
|
410
|
-
return c.fail(2, 'hire_scope_required', t('usage.export_need_hire', {}, c.env));
|
|
411
|
-
}
|
|
412
|
-
const sinceMs = c.flags.since != null ? parseSince(c.flags.since, c.nowMs()) : null;
|
|
413
|
-
if (c.flags.since != null && sinceMs == null) return c.fail(2, 'bad_since', t('usage.bad_since', {}, c.env));
|
|
414
|
-
let parsed;
|
|
415
|
-
try {
|
|
416
|
-
parsed = parseRecipeText(recipe, text, { file: path.basename(String(c.flags.file)), session: null });
|
|
417
|
-
} catch (e) {
|
|
418
|
-
if (e instanceof RecipeError) return c.fail(2, 'recipe_bad_line', t('usage.export_bad_line', { msg: e.message }, c.env));
|
|
419
|
-
throw e;
|
|
420
|
-
}
|
|
421
|
-
const state = readState(c.credOpts);
|
|
422
|
-
const rows = parsed.rows
|
|
423
|
-
.filter((x) => sinceMs == null || x.atMs >= sinceMs)
|
|
424
|
-
.map((x) => exportRow(x, String(sf.scope.id).toLowerCase()))
|
|
425
|
-
.filter((r) => !isZero(r) && !state.sent[localKey(r)]);
|
|
426
|
-
if (!rows.length) {
|
|
427
|
-
if (c.flags.json) c.log(JSON.stringify({ ok: true, sent: null })); else c.log(t('usage.nothing_new', {}, c.env));
|
|
428
|
-
return 0;
|
|
429
|
-
}
|
|
430
|
-
const tot = await sendRows({ baseUrl: c.baseUrl, credOpts: c.credOpts, fetchImpl: c.fetchImpl, rows, state, nowMs: c.nowMs() });
|
|
431
|
-
writeState(c.credOpts, state, c.nowMs());
|
|
432
|
-
if (c.flags.json) {
|
|
433
|
-
c.log(JSON.stringify({ ok: !tot.error, sent: { ...tot, error: tot.error ? String(tot.error.message || tot.error) : null } }));
|
|
434
|
-
} else if (tot.featureOff) {
|
|
435
|
-
c.log(t('usage.feature_off', {}, c.env));
|
|
436
|
-
} else {
|
|
437
|
-
if (tot.total) for (const l of describeSend(tot, c.env)) c.log(l);
|
|
438
|
-
if (tot.error) c.err(t('usage.send_failed', { msg: tot.error.message || String(tot.error) }, c.env));
|
|
439
|
-
}
|
|
440
|
-
return tot.error ? 1 : 0;
|
|
441
|
-
}
|
|
442
365
|
|
|
443
366
|
async function cmdPush(c) {
|
|
444
367
|
if (!c.flags.file) return c.fail(2, 'file_required', t('usage.need_file', {}, c.env));
|
|
445
368
|
const f = readFileArg(c);
|
|
446
369
|
if (f.error) return c.fail(2, 'read_failed', f.error);
|
|
447
|
-
// 2026-11-27: an export file (a runtime with no local log) goes through the same recipe as the job-seeking check
|
|
448
|
-
const exportRecipe = RECIPES.find((r) => r.sniff && r.sniff(String(f.text || '').slice(0, 65536)));
|
|
449
|
-
if (exportRecipe) return cmdPushExport(c, exportRecipe, f.text);
|
|
450
370
|
const got = readRecordsFile(f.text, c.env);
|
|
451
371
|
if (got.forbidden) return c.fail(2, 'mt_content_forbidden', got.forbidden);
|
|
452
372
|
if (!c.flags.json) for (const l of got.notes) c.err(l);
|
|
@@ -555,7 +475,6 @@ const HANDLERS = {
|
|
|
555
475
|
'usage:collect': cmdCollect,
|
|
556
476
|
'usage:push': cmdPush,
|
|
557
477
|
'usage:check': cmdCheck,
|
|
558
|
-
'usage:sample': cmdSample,
|
|
559
478
|
};
|
|
560
479
|
|
|
561
480
|
/**
|
package/src/mt/format-check.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// Why: a reader that reads the wrong table or a changed file layout does not fail, it quietly returns wrong or empty
|
|
4
4
|
// numbers (a wrong-table mix-up happened in 0.38.8). So before a reader reads, a small sample of the file is checked for
|
|
5
|
-
// the keys the reader needs. Not matching: the reader skips this round, an alert is kept
|
|
5
|
+
// the keys the reader needs. Not matching: the reader skips this round, an alert is kept locally and for the
|
|
6
6
|
// next wake-up prompt ("the platform cannot read your usage records, report them yourself"), and usage then comes from the
|
|
7
7
|
// Agent own report. A check only looks at key names and number types, never at content, and it is loose on purpose:
|
|
8
8
|
// only a file that clearly does not have the structure counts as wrong. Nothing here blocks the Agent.
|
|
@@ -21,7 +21,7 @@ export const READER_PROGRAM = {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const alerts = new Map(); // reader -> { reason, at }
|
|
24
|
-
let storeFile = null; // the alerts survive a
|
|
24
|
+
let storeFile = null; // the alerts survive a process restart: kept in this file
|
|
25
25
|
|
|
26
26
|
/** Verdict of a check: OK (clearly fine: the only way to clear an alert), a reason string (clearly wrong), null (cannot tell: the state stays). */
|
|
27
27
|
export const OK = "ok";
|
package/src/mt/readers.js
CHANGED
|
@@ -680,7 +680,7 @@ export async function readLocalLogs({ home = os.homedir(), env = process.env, si
|
|
|
680
680
|
|
|
681
681
|
/**
|
|
682
682
|
* Check the log layout of one program without reading anything: run before the wake-up prompt is made, so the very first
|
|
683
|
-
* wake after a change (or after a
|
|
683
|
+
* wake after a change (or after a process restart) already knows. Never throws.
|
|
684
684
|
*/
|
|
685
685
|
export async function precheckFormats({ program, home = os.homedir(), env = process.env, nowMs = Date.now(), sqlite, log } = {}) {
|
|
686
686
|
try {
|