scripts

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Durable Scripts

持久化脚本

This skill's
scripts/scripts.sh
launcher lives inside this skill directory and calls the identity-bound daemon through
TARIBOY_TOOLS_SOCKET
. Execute the launcher when command execution is available. If it is unavailable, return the exact command instead; never claim a script was queued, scheduled, rerun, cancelled, or removed unless the command succeeded.
Run once with
scripts/scripts.sh run <name> -- <command>
. Queue it exactly once, finish the iteration, and consume the later
script.result
message instead of waiting in the current iteration.
Run repeatedly with
scripts/scripts.sh schedule <name> --every <seconds> -- <command>
. Runs never overlap. A run that exits with
$TARIBOY_QUIET_EXIT
(
111
) publishes nothing and keeps the schedule; it is the only outcome that does. The daemon exports the code to every run, so a shell command stays quiet with
exit "${TARIBOY_QUIET_EXIT:-111}"
and a Python one with
sys.exit(int(os.environ.get("TARIBOY_QUIET_EXIT", "111")))
.
Inspect with
scripts/scripts.sh ls
,
scripts/scripts.sh runs
, and
scripts/scripts.sh logs
; use
scripts/scripts.sh rerun
,
scripts/scripts.sh cancel
, or
scripts/scripts.sh rm
for lifecycle control.
此 skill 的
scripts/scripts.sh
启动器位于此 skill 目录内,并通过
TARIBOY_TOOLS_SOCKET
调用与身份绑定的 daemon。 如果可以执行命令,请运行该启动器。如果无法执行,则原样返回确切命令;除非命令成功执行,否则绝不能声称脚本已排队、调度、重新运行、取消或删除。
使用
scripts/scripts.sh run <name> -- <command>
运行一次。恰好将其入队一次,完成本次迭代,并消费后续的
script.result
消息,而不要在当前迭代中等待。
使用
scripts/scripts.sh schedule <name> --every <seconds> -- <command>
定期重复运行。 各次运行绝不重叠。以
$TARIBOY_QUIET_EXIT
(
111
)退出的运行不会发布任何消息,并会保持调度继续运行;只有这种结果会如此。 daemon 会将该退出码导出给每次运行,因此 shell 命令可以使用
exit "${TARIBOY_QUIET_EXIT:-111}"
保持静默,Python 命令则可以使用
sys.exit(int(os.environ.get("TARIBOY_QUIET_EXIT", "111")))
。
使用
scripts/scripts.sh ls
、
scripts/scripts.sh runs
和
scripts/scripts.sh logs
进行检查;使用
scripts/scripts.sh rerun
、
scripts/scripts.sh cancel
或
scripts/scripts.sh rm
进行生命周期控制。

Address every definition by its script ID

使用 script ID 定位每个定义

REQUIRED:
rerun
,
cancel
, and
rm
accept only the
scr-...
script ID or a
srun-...
run ID. Names are not unique and are not resolved: passing one fails with
not found
, and
run <name> -- <command>
creates a second definition instead of resuming the stopped one.
Take the ID from the
script_id
field of the
script.result
message that woke you, from the creation output, or from
scripts/scripts.sh ls
. Record the script ID, not only the name, wherever a durable monitor is recorded.
必需:
rerun
、
cancel
和
rm
仅接受
scr-...
script ID 或
srun-...
run ID。名称并不唯一,也不会被解析:传入名称会因
not found
而失败;
run <name> -- <command>
会创建第二个定义,而不会恢复已停止的定义。
从唤醒你的
script.result
消息的
script_id
字段、创建输出或
scripts/scripts.sh ls
中获取 ID。在任何持久化监控记录中,都应记录 script ID,而不只是名称。

A published result stops the schedule

发布结果会停止调度

A recurring definition keeps its schedule only while every run stays quiet. The moment a run publishes a
script.result
message, the daemon sets the definition to
completed
and clears its next run: the agent is notified once instead of repeatedly, and no further runs happen until it is resumed.
This covers every published outcome:
EventEffect on the recurring definition
Run exits with
$TARIBOY_QUIET_EXIT
(
111
)
No message; schedule keeps running
Run exits with any other code, success or failureResult published; definition stopped
A command that never exits with
$TARIBOY_QUIET_EXIT
Every run publishes, so the schedule stops after the first run
cancel <run-id>
for one active run
That run still publishes a result, so the definition stops too
A run interrupted by a daemon restartRecovery publishes the interrupted result, so the definition stops
cancel <script-id>
Definition cancelled; it can never run again
循环定义仅在每次运行都保持静默时才会继续执行调度。一旦某次运行发布
script.result
消息,daemon 就会将定义设置为
completed
并清除下一次运行:Agent 只会被通知一次,而不是反复收到通知;并且在恢复之前不会继续运行。
这适用于所有已发布的结果:
事件对循环定义的影响
运行以
$TARIBOY_QUIET_EXIT
(
111
)退出
不发布消息;调度继续运行
运行以其他任何代码退出,无论成功还是失败发布结果;定义停止
命令从未以
$TARIBOY_QUIET_EXIT
退出
每次运行都会发布结果,因此调度在首次运行后停止
对一次活动运行执行
cancel <run-id>
该运行仍会发布结果,因此定义也会停止
运行被 daemon 重启中断恢复流程会发布中断运行的结果,因此定义停止
执行
cancel <script-id>
定义被取消;此后永远无法再次运行

Handling a
script.result
for a recurring definition

处理循环定义的
script.result

REQUIRED: Process the result, then close it with exactly one of these two decisions before the iteration ends. Doing neither silently ends the observation.
  1. Still needed — resume the same definition:
    bash
    scripts/scripts.sh rerun <script-id>
    rerun
    runs it now and returns the definition to
    active
    , so its fixed delay continues afterwards. Never create a replacement schedule for work the stopped definition already describes.
  2. No longer needed — remove it:
    bash
    scripts/scripts.sh rm <script-id>
    The published result already stopped it, so no
    cancel
    is needed. Run
    scripts/scripts.sh cancel <script-id>
    first only when
    ls
    still reports
    state: active
    .
A stopped definition is not a wait object. Never end an iteration describing a definition that published its result as an active monitor: either it was resumed with
rerun
in this iteration, or the iteration's wait object is something else.
必需: 处理结果后,在迭代结束前必须恰好采用以下两种决定之一来关闭它。两种决定都不采用会静默结束观察。
  1. 仍然需要 — 恢复同一定义:
    bash
    scripts/scripts.sh rerun <script-id>
    rerun
    会立即运行它,并将定义恢复为
    active
    ,之后固定延迟会继续生效。对于已停止定义所描述的工作,绝不能创建替代调度。
  2. 不再需要 — 删除它:
    bash
    scripts/scripts.sh rm <script-id>
    已发布的结果已经停止了该定义,因此无需
    cancel
    。仅当
    ls
    仍报告
    state: active
    时,才需要先运行
    scripts/scripts.sh cancel <script-id>
    。
已停止的定义不是等待对象。迭代结束时,绝不能将已经发布结果的定义描述为仍处于活动状态的监控对象:要么它已在本迭代中通过
rerun
恢复,要么本迭代的等待对象是其他对象。

External prerequisite failures

外部前置条件失败

REQUIRED: A recurring schedule whose command cannot succeed until an external prerequisite changes, such as a missing credential, binary, or dependency, is no longer a valid wait object. Its failing result already stopped it, so take branch 2 above and never
rerun
it:
bash
scripts/scripts.sh rm <script-id>
Run
scripts/scripts.sh cancel <script-id>
before it only when
ls
still reports
state: active
. Then, for a Native Task:
  1. Mention the customer and ask one blocking question. Reuse a matching unanswered question instead of creating or repeating it.
  2. Set the task to
    wait_customer
    if it is not already there and record the question as the only resume event.
  3. As the final action, finish the iteration through the
    loop
    skill with
    scripts/loop.sh done
    .
The failure is handled only after the definition is removed, the task has one customer-answer wait, and the iteration is finished. An action trace that omits any of these is incomplete.
Pausing or disabling leaves the useless definition behind; it does not complete this sequence. Do not rerun the command, create a replacement schedule, or repeat the failure comment while the question remains unanswered.
必需: 如果循环调度的命令在外部前置条件发生变化之前无法成功执行,例如缺少凭据、二进制文件或依赖项,那么该调度就不再是有效的等待对象。其失败结果已经停止了它,因此应采用上面的分支 2,绝不能
rerun
它:
bash
scripts/scripts.sh rm <script-id>
仅当
ls
仍报告
state: active
时,才需要在删除前运行
scripts/scripts.sh cancel <script-id>
。随后,对于 Native Task:
  1. 向客户说明情况并提出一个阻塞性问题。如果已有匹配且未回答的问题,应复用该问题,而不是新建或重复提问。
  2. 如果任务尚未处于
    wait_customer
    状态,则将其设置为该状态,并将该问题记录为唯一的恢复事件。
  3. 作为最后一个操作,通过
    loop
    skill 执行
    scripts/loop.sh done
    来结束本次迭代。
只有在定义已删除、任务包含且仅包含一个等待客户回答的事件,并且迭代已结束后,才算处理了此次失败。缺少任一步骤的操作轨迹都是不完整的。
暂停或禁用只会留下无效定义,并不算完成此流程。在客户问题得到回答之前,不要重新运行命令、创建替代调度或重复发布失败说明。

Red flags

危险信号

ThoughtReality
"The schedule keeps running, so I can just finish."Any published result stopped it. Resume with
rerun <script-id>
or remove it.
"Cancelling one run leaves the schedule intact."That run still publishes a result, which stops the definition.
"I will schedule it again to resume monitoring."A second definition duplicates the work.
rerun <script-id>
resumes the recorded one.
"
rerun <name>
is clearer than the ID."
Names are not resolved; only
scr-...
IDs work.
"It succeeded, so nothing stopped."Success is not quiet. Only
$TARIBOY_QUIET_EXIT
(
111
) is quiet.
想法实际情况
"调度会继续运行,所以我可以直接结束。"任何已发布的结果都会停止它。使用
rerun <script-id>
恢复,或将其删除。
"取消一次运行后,调度仍然完好。"该运行仍会发布结果,从而停止定义。
"我会重新调度它,以恢复监控。"第二个定义会造成工作重复。
rerun <script-id>
会恢复已记录的定义。
"使用
rerun <name>
比使用 ID 更清晰。"
名称不会被解析;只有
scr-...
ID 可用。
"它成功了,所以没有任何东西停止。"成功并不表示静默。只有
$TARIBOY_QUIET_EXIT
(
111
)表示静默。