@keyou007/agent-bot 0.1.25-alpha.0 → 0.1.25-alpha.2
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/CHANGELOG.md +27 -0
- package/README.md +60 -5
- package/README.zh.md +60 -5
- package/config.example.yaml +1 -3
- package/dist/cli/controlProtocol.js.map +1 -1
- package/dist/cli/help.js +14 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli.js +32 -0
- package/dist/cli.js.map +1 -1
- package/dist/codex/CodexRuntime.js +15 -5
- package/dist/codex/CodexRuntime.js.map +1 -1
- package/dist/commands/CommandRouter.js +7 -0
- package/dist/commands/CommandRouter.js.map +1 -1
- package/dist/config/SettingsStore.js +341 -0
- package/dist/config/SettingsStore.js.map +1 -0
- package/dist/config/loadConfig.js +1 -2
- package/dist/config/loadConfig.js.map +1 -1
- package/dist/config/schema.js +0 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/console/ConsoleTurnPresenter.js +3 -0
- package/dist/console/ConsoleTurnPresenter.js.map +1 -1
- package/dist/feishu/CardRenderer.js +32 -96
- package/dist/feishu/CardRenderer.js.map +1 -1
- package/dist/feishu/FeishuConnector.js +9 -0
- package/dist/feishu/FeishuConnector.js.map +1 -1
- package/dist/feishu/FeishuMessageClient.js +35 -14
- package/dist/feishu/FeishuMessageClient.js.map +1 -1
- package/dist/feishu/FeishuTurnPresenter.js +36 -23
- package/dist/feishu/FeishuTurnPresenter.js.map +1 -1
- package/dist/feishu/LocalCardImage.js.map +1 -1
- package/dist/feishu/LocalImageMarkdown.js +59 -3
- package/dist/feishu/LocalImageMarkdown.js.map +1 -1
- package/dist/feishu/SettingsCard.js +199 -0
- package/dist/feishu/SettingsCard.js.map +1 -0
- package/dist/index.js +17 -6
- package/dist/index.js.map +1 -1
- package/dist/local-files/TurnPreviewPage.js +8 -4
- package/dist/local-files/TurnPreviewPage.js.map +1 -1
- package/dist/presentation/TurnStateReducer.js +21 -2
- package/dist/presentation/TurnStateReducer.js.map +1 -1
- package/dist/presentation/turnStatus.js +34 -0
- package/dist/presentation/turnStatus.js.map +1 -0
- package/dist/proxy/ProxySessionController.js +688 -153
- package/dist/proxy/ProxySessionController.js.map +1 -1
- package/dist/runtime/submissionErrors.js +15 -0
- package/dist/runtime/submissionErrors.js.map +1 -0
- package/dist/scheduling/ScheduleCards.js +240 -0
- package/dist/scheduling/ScheduleCards.js.map +1 -0
- package/dist/scheduling/ScheduleCommand.js +67 -0
- package/dist/scheduling/ScheduleCommand.js.map +1 -0
- package/dist/scheduling/ScheduledTaskStore.js +226 -0
- package/dist/scheduling/ScheduledTaskStore.js.map +1 -0
- package/dist/scheduling/TaskScheduler.js +132 -0
- package/dist/scheduling/TaskScheduler.js.map +1 -0
- package/dist/scheduling/types.js +89 -0
- package/dist/scheduling/types.js.map +1 -0
- package/dist/state/ExecutionProvenanceStore.js +58 -0
- package/dist/state/ExecutionProvenanceStore.js.map +1 -0
- package/dist/state/StateStore.js +145 -45
- package/dist/state/StateStore.js.map +1 -1
- package/dist/state/migrations.js +37 -0
- package/dist/state/migrations.js.map +1 -1
- package/dist/supervision/SafeRestartNotifier.js +1 -1
- package/dist/supervision/SafeRestartNotifier.js.map +1 -1
- package/docs/technical-reference.md +11 -8
- package/docs/technical-reference.zh.md +11 -8
- package/npm-shrinkwrap.json +24 -2
- package/package.json +2 -1
- package/skills/agent-bot/SKILL.md +33 -3
- package/src/cli/controlProtocol.ts +1 -0
- package/src/cli/help.ts +14 -0
- package/src/cli.ts +25 -0
- package/src/codex/CodexRuntime.ts +14 -5
- package/src/commands/CommandRouter.ts +7 -0
- package/src/commands/commandTypes.ts +2 -0
- package/src/config/SettingsStore.ts +588 -0
- package/src/config/loadConfig.ts +1 -2
- package/src/config/schema.ts +0 -1
- package/src/console/ConsoleTurnPresenter.ts +2 -0
- package/src/feishu/CardRenderer.ts +33 -110
- package/src/feishu/FeishuConnector.ts +9 -0
- package/src/feishu/FeishuMessageClient.ts +39 -17
- package/src/feishu/FeishuTurnPresenter.ts +33 -22
- package/src/feishu/LocalCardImage.ts +0 -1
- package/src/feishu/LocalImageMarkdown.ts +54 -3
- package/src/feishu/SettingsCard.ts +231 -0
- package/src/index.ts +17 -6
- package/src/local-files/TurnPreviewPage.ts +8 -4
- package/src/presentation/TurnStateReducer.ts +21 -2
- package/src/presentation/turnStatus.ts +38 -0
- package/src/presentation/turnViewTypes.ts +3 -0
- package/src/proxy/ProxySessionController.ts +628 -152
- package/src/runtime/submissionErrors.ts +15 -0
- package/src/runtime/types.ts +1 -0
- package/src/scheduling/ScheduleCards.ts +317 -0
- package/src/scheduling/ScheduleCommand.ts +76 -0
- package/src/scheduling/ScheduledTaskStore.ts +332 -0
- package/src/scheduling/TaskScheduler.ts +171 -0
- package/src/scheduling/types.ts +151 -0
- package/src/state/ExecutionProvenanceStore.ts +100 -0
- package/src/state/StateStore.ts +167 -44
- package/src/state/migrations.ts +37 -0
- package/src/supervision/SafeRestartNotifier.ts +1 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyou007/agent-bot",
|
|
3
|
-
"version": "0.1.25-alpha.
|
|
3
|
+
"version": "0.1.25-alpha.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@keyou007/agent-bot",
|
|
9
|
-
"version": "0.1.25-alpha.
|
|
9
|
+
"version": "0.1.25-alpha.2",
|
|
10
10
|
"license": "GPL-3.0-only",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@agentclientprotocol/sdk": "1.2.1",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"@xterm/addon-fit": "0.11.0",
|
|
17
17
|
"@xterm/xterm": "6.0.0",
|
|
18
18
|
"better-sqlite3": "12.11.1",
|
|
19
|
+
"cron-parser": "5.10.2",
|
|
19
20
|
"dotenv": "17.4.2",
|
|
20
21
|
"highlight.js": "11.12.0",
|
|
21
22
|
"markdown-it": "15.0.1",
|
|
@@ -2539,6 +2540,18 @@
|
|
|
2539
2540
|
"layout-base": "^1.0.0"
|
|
2540
2541
|
}
|
|
2541
2542
|
},
|
|
2543
|
+
"node_modules/cron-parser": {
|
|
2544
|
+
"version": "5.10.2",
|
|
2545
|
+
"resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-5.10.2.tgz",
|
|
2546
|
+
"integrity": "sha512-JfAYMY0LZaWQTuict8PhtF/ksSnq8xefSDmQUnnoqvkPYkU/y3UP0DTWzJKFBz0P1IXsDG8q0vY3zHkoFZOhvw==",
|
|
2547
|
+
"license": "MIT",
|
|
2548
|
+
"dependencies": {
|
|
2549
|
+
"luxon": "^3.7.2"
|
|
2550
|
+
},
|
|
2551
|
+
"engines": {
|
|
2552
|
+
"node": ">=18"
|
|
2553
|
+
}
|
|
2554
|
+
},
|
|
2542
2555
|
"node_modules/cross-spawn": {
|
|
2543
2556
|
"version": "7.0.6",
|
|
2544
2557
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
|
@@ -4605,6 +4618,15 @@
|
|
|
4605
4618
|
"integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==",
|
|
4606
4619
|
"license": "Apache-2.0"
|
|
4607
4620
|
},
|
|
4621
|
+
"node_modules/luxon": {
|
|
4622
|
+
"version": "3.7.2",
|
|
4623
|
+
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.7.2.tgz",
|
|
4624
|
+
"integrity": "sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew==",
|
|
4625
|
+
"license": "MIT",
|
|
4626
|
+
"engines": {
|
|
4627
|
+
"node": ">=12"
|
|
4628
|
+
}
|
|
4629
|
+
},
|
|
4608
4630
|
"node_modules/magic-string": {
|
|
4609
4631
|
"version": "0.30.21",
|
|
4610
4632
|
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyou007/agent-bot",
|
|
3
|
-
"version": "0.1.25-alpha.
|
|
3
|
+
"version": "0.1.25-alpha.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Use Codex, TraeX, and compatible coding agents from Lark/Feishu.",
|
|
6
6
|
"license": "GPL-3.0-only",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"@xterm/addon-fit": "0.11.0",
|
|
75
75
|
"@xterm/xterm": "6.0.0",
|
|
76
76
|
"better-sqlite3": "12.11.1",
|
|
77
|
+
"cron-parser": "5.10.2",
|
|
77
78
|
"dotenv": "17.4.2",
|
|
78
79
|
"highlight.js": "11.12.0",
|
|
79
80
|
"markdown-it": "15.0.1",
|
|
@@ -121,6 +121,8 @@ TraeX plan-mode confirmations follow the task permission mode. With `auto`, Agen
|
|
|
121
121
|
|
|
122
122
|
## Change Settings
|
|
123
123
|
|
|
124
|
+
Feishu `/settings` opens the owner-only global configuration panel for the current Profile, without requiring a task. Common is initial: with multiple Agents it offers default Agent; with one Agent it offers default Provider/model instead, without an Agent selector. Response policy and stable auto-updates remain on Common. Agent contains model/reasoning/permission dropdowns (model stays on Common in single-Agent profiles). Choices come from runtime catalogs and preserve upstream IDs. Provider/model changes keep compatible defaults and clear incompatible reasoning overrides; unavailable catalogs warn without changing unrelated values. Group names contains templates; Advanced contains logging, console/terminal/Preview switches and listen host/port. Every component callback autosaves independently; there is no page Save button. Selectors/checkers save on change; text/number inputs still need their native submit icon because Feishu has no input blur callback. Invalid values remain unsaved and errors appear on the same card. Saves persist YAML only, take effect after an explicit safe restart, and never alter existing tasks/history. Field revisions prevent stale overwrites. Default working directory, public base URL, secrets, Agent process commands/environment and persistence paths remain local-only; existing values are preserved. Thinking cards use grouped rendering only. The CLI equivalent is explicit YAML editing followed by a safe restart, not task-setting commands.
|
|
125
|
+
|
|
124
126
|
Feishu slash commands accept unique prefixes: `/mo`, `/mod`, and `/mode` open the `/model` settings card and do not accept arguments. This is model selection, not an Agent mode switch. CLI `task model [model]` keeps its documented argument behavior.
|
|
125
127
|
|
|
126
128
|
```powershell
|
|
@@ -131,7 +133,7 @@ agentbot task thinking [effort]
|
|
|
131
133
|
agentbot task permissions [auto|confirm]
|
|
132
134
|
```
|
|
133
135
|
|
|
134
|
-
Omit the value to inspect the current setting and available choices. `agent` changes the default Agent for future tasks in that conversation. The other settings affect the specified task from its next request
|
|
136
|
+
Omit the value to inspect the current setting and available choices. `agent` changes the default Agent for future tasks in that conversation. The other settings affect only the specified task from its next request; they never create or update Agent defaults. Defaults for unrelated new tasks must be configured explicitly under `agents.<name>.defaults`. Same-Agent new tasks and explicit forks still inherit the source task's settings.
|
|
135
137
|
|
|
136
138
|
For App Server tasks, `permissions auto` applies `never` approval and `dangerFullAccess` sandbox policies on the next Turn; `permissions confirm` applies `on-request` and `workspaceWrite`, preserving configured workspace restrictions. No Agent restart, fork, or new task is needed. Steering or changing the setting does not re-sandbox tools already executing. Feishu `/permissions` takes no arguments: choose the mode on its card.
|
|
137
139
|
|
|
@@ -139,12 +141,36 @@ A successful Provider switch confirms settings, not inference connectivity. Mode
|
|
|
139
141
|
|
|
140
142
|
Providers such as a Responses bridge may omit assistant message phases. Unphased text stays in the progress timeline; successful completion promotes only the last message not followed by a tool start. Do not diagnose progress text in the answer area as a CSS issue without checking message phases. Old snapshots are not automatically backfilled.
|
|
141
143
|
|
|
142
|
-
Provider changes during an Agent Bot turn are staged until it ends; do not stop the turn. The settings card and CLI show the pending Provider/model, and model/thinking/permission selections edit that pending configuration. The latest selection is applied before the next turn, including queued/retried turns. Pending settings survive restart, remain separate from actual task settings, and are verified before saving Agent defaults. Deferred failures roll back to the original Provider/model. After the runtime confirms rollback, the card returns to the original settings, the pending selection is cleared, and queued prompts continue with the original settings. Failed or unverified rollback still pauses queued prompts and requires explicit recovery; never claim rollback success based only on unchanged local fields. Custom Providers discover models through their OpenAI-compatible `/models` endpoint when available. Switching keeps the previous model when supported, otherwise uses the Provider default or its first model. A missing model-list endpoint falls back to the current or configured model and does not by itself block switching. Wait for active work to finish; do not stop it without the user's request. Switching detaches only the selected thread and waits for its actual unload before resuming. On failure, previous settings are retained and recovery is attempted. If recovery fails, resolve the reported configuration or ownership issue and retry the Provider switch before sending another prompt. Never replace a forked task with an empty task to work around a switch failure.
|
|
144
|
+
Provider changes during an Agent Bot turn are staged until it ends; do not stop the turn. The settings card and CLI show the pending Provider/model, and model/thinking/permission selections edit that pending configuration. The latest selection is applied before the next turn, including queued/retried turns. Pending settings survive restart, remain separate from actual task settings, and are verified before saving the effective task settings; Agent defaults remain unchanged. Deferred failures roll back to the original Provider/model. After the runtime confirms rollback, the card returns to the original settings, the pending selection is cleared, and queued prompts continue with the original settings. Failed or unverified rollback still pauses queued prompts and requires explicit recovery; never claim rollback success based only on unchanged local fields. Custom Providers discover models through their OpenAI-compatible `/models` endpoint when available. Switching keeps the previous model when supported, otherwise uses the Provider default or its first model. A missing model-list endpoint falls back to the current or configured model and does not by itself block switching. Wait for active work to finish; do not stop it without the user's request. Switching detaches only the selected thread and waits for its actual unload before resuming. On failure, previous settings are retained and recovery is attempted. If recovery fails, resolve the reported configuration or ownership issue and retry the Provider switch before sending another prompt. Never replace a forked task with an empty task to work around a switch failure.
|
|
143
145
|
|
|
144
146
|
Provider changes for tasks with history must keep the same remote task ID and complete history. Never use Fork, synthetic Turns, or history repair to change settings. A verified empty task with no Turns, inherited history, or Goal may receive a new remote ID; Agent Bot keeps its local task and conversation bindings and commits only after verifying the target settings. Failure retains the original empty task. A rejected switch must report the reason and verify rollback; Codex is started with zero thread-unload delay, and switching waits for the selected thread to report notLoaded before resuming it. Other tasks may remain active, and empty sibling tasks stay untouched. An unload timeout does not prove external ownership; inspect the selected task and retry after releasing any remaining subscription. Do not restart or force-release the shared process to switch Provider. Settings inspection and selection must remain available when the old Provider cannot resume.
|
|
145
147
|
|
|
146
148
|
After the specific Codex Responses failure `unsupported_persisted_item_context` for `previous_response_id`, Agent Bot can automatically start one empty-input continuation in the same thread. It retains history and completed tool results without resending the original Prompt/images; it creates a new Turn/card, not a new task or Fork. Do not also send a retry Prompt while recovery is pending. Stop/Reset cancel recovery; changed settings, newer work, or a lost attachment block it. A second rejection remains a failure, not an unlimited retry. Matching progress warnings and final errors appear once in cards and Preview, with raw diagnostic events retained. This execution recovery is separate from Provider switching; it never changes settings or restarts the shared process.
|
|
147
149
|
|
|
150
|
+
## Scheduled Tasks
|
|
151
|
+
|
|
152
|
+
Use `agentbot schedule` for explicitly requested future or recurring Agent work:
|
|
153
|
+
|
|
154
|
+
```powershell
|
|
155
|
+
agentbot schedule add --task <task> --cron "0 9 * * 1-5" --timezone Asia/Singapore --prompt "Check the build"
|
|
156
|
+
agentbot schedule add --task <task> --at "2026-12-01T10:00:00+08:00" --prompt "Check results"
|
|
157
|
+
agentbot schedule list
|
|
158
|
+
agentbot schedule show|history <schedule-id>
|
|
159
|
+
agentbot schedule pause|resume|run|delete <schedule-id>
|
|
160
|
+
agentbot schedule edit <schedule-id> --cron "0 10 * * 1-5" --prompt "Check the build"
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
- Only create a schedule when the user explicitly requests scheduling; an ordinary task is not permission to add recurrence.
|
|
164
|
+
- `add` may omit `--task` inside an Agent Bot Agent. Bind the requested existing task; never fork or replace it to create a schedule.
|
|
165
|
+
- Creation/editing sends a draft confirmation card to the task's original conversation. Wait for the owner to confirm; do not activate drafts on their behalf.
|
|
166
|
+
- Plan details contain plan-editing controls; run history only contains per-run detail and verification actions. Use the card's navigation to switch views or refresh the current view.
|
|
167
|
+
- `edit` replaces the entire specification. Preserve unchanged fields from `show`. Specify exactly one of five-field `--cron` and offset-aware ISO `--at`; Prompts are limited to 1,000 characters.
|
|
168
|
+
- Agent Bot persists timezone and reply route, uses the task's execution-time settings, queues without steering, skips overlap, and expires starts after `--max-delay` minutes (default 60).
|
|
169
|
+
- At execution start, Agent Bot posts the original Prompt to the saved conversation/topic before the thinking card and model submission. Queueing alone sends nothing; recovery and approved-plan continuation do not repost it. Failed Prompt delivery prevents submission and pauses enabled plans.
|
|
170
|
+
- Missed slots are skipped by default. Use `--catch-up <minutes>` only when requested; it permits only the latest missed slot within the window and maximum start deadline.
|
|
171
|
+
- Do not automatically rerun ambiguous submissions. Ask the user to verify run history/Agent state; the owner can acknowledge an ended unknown run in its history card. Pause/delete cancels unsubmitted work only; Stop active work separately when requested.
|
|
172
|
+
- Scheduling requires the host and Agent Bot to remain running. Safe restart suspends dispatch and does not bulk-replay old Prompts.
|
|
173
|
+
|
|
148
174
|
## Goals And Turns
|
|
149
175
|
|
|
150
176
|
```powershell
|
|
@@ -233,7 +259,11 @@ Use `init --reset` only for an explicitly requested full reset. Without `--profi
|
|
|
233
259
|
|
|
234
260
|
## After Code Changes
|
|
235
261
|
|
|
236
|
-
|
|
262
|
+
Use `/turn <id or index>` execution details to explain why a recorded turn ran. Provenance includes trigger, logical instruction ID, optional parent/planned time and effective dispatch settings. It does not include Prompt bodies or credentials and is not reconstructed for old turns. Source `recovery` means confirmed unsubmitted preparation, not replay of submitted work.
|
|
263
|
+
|
|
264
|
+
Stop durably invalidates preparation, retries and automatic continuations accepted before it. A failed interrupt never revokes that intent, including across restart; do not claim termination without confirmation. Independent queued messages and future schedules are retained. A new explicit user instruction can start new work. Do not send extra continuation prompts to defeat Stop.
|
|
265
|
+
|
|
266
|
+
For tasks stuck after a Worker crash, inspect the recovery notice and any writer-conflict card before acting. Unconfirmed recovery checks stop after a one-minute window; a live writer conflict stops them immediately. Only durably proven unsubmitted requests may retry. Submitted turns are reattached by exact turn ID, never replayed on disconnect or transient model failure. Ambiguous execution is unverified, not cancelled; automatic queue dispatch pauses without deleting queued messages. Inspect execution records before explicitly continuing with a new message. An old unfinished rollout or a leftover lock file alone is not proof of a running task. Do not delete locks, edit task state, or close another Agent process automatically. Already-confirmed live turns remain monitored; ask the user before stopping them.
|
|
237
267
|
|
|
238
268
|
Run the relevant checks, then build:
|
|
239
269
|
|
|
@@ -13,6 +13,7 @@ import type { SessionRecord, PendingProviderSettings } from "../state/StateStore
|
|
|
13
13
|
import type { ShellCommandResult } from "../utils/executeShellCommand.js";
|
|
14
14
|
|
|
15
15
|
export type ControlRequest =
|
|
16
|
+
| { action: "schedule"; command: import("../scheduling/types.js").ScheduleCommand; localSessionId?: string }
|
|
16
17
|
| { action: "health" }
|
|
17
18
|
| {
|
|
18
19
|
action: "server_restart";
|
package/src/cli/help.ts
CHANGED
|
@@ -20,6 +20,12 @@ export function renderCliHelp(version: string, language: CliLanguage = cliLangua
|
|
|
20
20
|
server stop 停止 Agent Bot
|
|
21
21
|
skills status 显示内置 Skill 状态
|
|
22
22
|
skills install 安装内置 Skill
|
|
23
|
+
schedule list 列出定时计划(JSON)
|
|
24
|
+
schedule add --task <任务> --cron "0 9 * * 1-5" --prompt "检查构建" 创建待确认计划
|
|
25
|
+
schedule add --task <任务> --at <ISO时间> --prompt <提示词> 创建一次性计划
|
|
26
|
+
schedule edit <计划> <参数> 修改计划并重新确认;参数与 add 相同
|
|
27
|
+
schedule show|history <计划> 查看计划或最近运行记录
|
|
28
|
+
schedule pause|resume|run|delete <计划> 暂停、恢复、立即执行或删除
|
|
23
29
|
|
|
24
30
|
任务命令:
|
|
25
31
|
task list 列出任务;支持 --search,sessions 是别名
|
|
@@ -57,6 +63,7 @@ export function renderCliHelp(version: string, language: CliLanguage = cliLangua
|
|
|
57
63
|
选项:
|
|
58
64
|
--profile <目录> 使用独立的 Profile 目录
|
|
59
65
|
--config <路径> 使用指定的配置文件
|
|
66
|
+
全局配置:飞书 /settings 面板,或编辑此 YAML 文件
|
|
60
67
|
--json 在支持时输出 JSON
|
|
61
68
|
-h, --help 显示帮助
|
|
62
69
|
-v, --version 显示版本
|
|
@@ -115,6 +122,12 @@ Common commands:
|
|
|
115
122
|
server stop Stop Agent Bot
|
|
116
123
|
skills status Show the built-in Skill status
|
|
117
124
|
skills install Install the built-in Skill
|
|
125
|
+
schedule list List scheduled jobs as JSON
|
|
126
|
+
schedule add --task <task> --cron "0 9 * * 1-5" --prompt "Check build" Create a draft
|
|
127
|
+
schedule add --task <task> --at <ISO-time> --prompt <prompt> Schedule once
|
|
128
|
+
schedule edit <id> <options> Edit a draft; same options as add
|
|
129
|
+
schedule show|history <id> Inspect a plan or its recent runs
|
|
130
|
+
schedule pause|resume|run|delete <id> Manage a scheduled job
|
|
118
131
|
|
|
119
132
|
Task commands:
|
|
120
133
|
task list List tasks; supports --search; sessions is an alias
|
|
@@ -152,6 +165,7 @@ Task commands:
|
|
|
152
165
|
Options:
|
|
153
166
|
--profile <directory> Use an isolated profile directory
|
|
154
167
|
--config <path> Use a specific config file
|
|
168
|
+
Global settings: Lark /settings panel, or edit this YAML file
|
|
155
169
|
--json Print JSON when supported
|
|
156
170
|
-h, --help Show help
|
|
157
171
|
-v, --version Show version
|
package/src/cli.ts
CHANGED
|
@@ -115,6 +115,7 @@ import {
|
|
|
115
115
|
parseTaskNewGroupOptions,
|
|
116
116
|
} from "./cli/taskGroupOptions.js";
|
|
117
117
|
import { StateStore, type SessionRecord } from "./state/StateStore.js";
|
|
118
|
+
import { parseScheduleCommand } from "./scheduling/ScheduleCommand.js";
|
|
118
119
|
import {
|
|
119
120
|
nodeDiagnosticReportArguments,
|
|
120
121
|
prepareCrashReportDirectory,
|
|
@@ -181,6 +182,10 @@ async function main(input: string[]): Promise<void> {
|
|
|
181
182
|
await taskCommand(rest);
|
|
182
183
|
return;
|
|
183
184
|
}
|
|
185
|
+
if (command === "schedule") {
|
|
186
|
+
await scheduleCommand(rest);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
184
189
|
if (command === "skill" || command === "skills") {
|
|
185
190
|
skillsCommand(rest);
|
|
186
191
|
return;
|
|
@@ -1230,6 +1235,26 @@ function resolveRestartNotificationSessionId(sqlitePath: string, args: string[])
|
|
|
1230
1235
|
}
|
|
1231
1236
|
}
|
|
1232
1237
|
|
|
1238
|
+
async function scheduleCommand(input: string[]): Promise<void> {
|
|
1239
|
+
if (["--help", "-h", "help"].includes(input[0] ?? "")) { printHelp(); return; }
|
|
1240
|
+
const args = input.filter((argument) => argument !== "--json");
|
|
1241
|
+
const config = loadConfig();
|
|
1242
|
+
const store = new StateStore(config.storage.sqlitePath);
|
|
1243
|
+
try {
|
|
1244
|
+
let localSessionId: string | undefined;
|
|
1245
|
+
let command;
|
|
1246
|
+
if (args[0] === "add") {
|
|
1247
|
+
const target = resolveTaskCommandTarget(store.listAllSessions(), args.slice(1), "schedule add");
|
|
1248
|
+
localSessionId = target.session.localSessionId;
|
|
1249
|
+
command = parseScheduleCommand(["add", ...target.args]);
|
|
1250
|
+
} else command = parseScheduleCommand(args);
|
|
1251
|
+
const result = controlData<unknown>(await sendControlRequest(controlEndpoint(config.storage.sqlitePath), {
|
|
1252
|
+
action: "schedule", command, localSessionId,
|
|
1253
|
+
}, 60_000));
|
|
1254
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
1255
|
+
} finally { store.close(); }
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1233
1258
|
async function taskCommand(input: string[]): Promise<void> {
|
|
1234
1259
|
const [action = "list", ...rest] = input;
|
|
1235
1260
|
const config = loadConfig();
|
|
@@ -33,6 +33,7 @@ import type {
|
|
|
33
33
|
import { appendGeneratedImageMarkdown } from "../utils/generatedImageMarkdown.js";
|
|
34
34
|
import { normalizeTaskTitle } from "../utils/taskTitle.js";
|
|
35
35
|
import { isResponseContinuationError } from "../runtime/responseErrors.js";
|
|
36
|
+
import { TurnNotSubmittedError } from "../runtime/submissionErrors.js";
|
|
36
37
|
import { AppServerRequestError } from "./AppServerConnection.js";
|
|
37
38
|
import { workspaceSandboxFromConfig, workspaceSandboxFromResponse, type TurnSandboxPolicy, type WorkspaceSandboxPolicy } from "./AppServerPermissions.js";
|
|
38
39
|
import { formatCodexError, mapCodexNotification } from "./CodexEventMapper.js";
|
|
@@ -309,8 +310,15 @@ export class CodexRuntime implements AgentRuntime {
|
|
|
309
310
|
|
|
310
311
|
private async startTurnNow(sessionId: string, prompt: RuntimePrompt, responseContinuation = false): Promise<string> {
|
|
311
312
|
const session = this.requireSession(sessionId);
|
|
312
|
-
|
|
313
|
-
|
|
313
|
+
let { client, sandboxPolicy } = await (async () => {
|
|
314
|
+
try {
|
|
315
|
+
const client = await this.client();
|
|
316
|
+
await this.ensureSessionResumed(session, client);
|
|
317
|
+
return { client, sandboxPolicy: await this.turnSandboxPolicy(session, client) };
|
|
318
|
+
} catch (error) {
|
|
319
|
+
throw new TurnNotSubmittedError(error);
|
|
320
|
+
}
|
|
321
|
+
})();
|
|
314
322
|
const start = async () => client.request<{ turn: { id: string } }>("turn/start", {
|
|
315
323
|
threadId: session.remoteSessionId,
|
|
316
324
|
input: responseContinuation ? [] : codexUserInput(prompt),
|
|
@@ -325,7 +333,7 @@ export class CodexRuntime implements AgentRuntime {
|
|
|
325
333
|
} : {}),
|
|
326
334
|
summary: "auto",
|
|
327
335
|
approvalPolicy: session.permissionMode === "auto" ? "never" : "on-request",
|
|
328
|
-
sandboxPolicy
|
|
336
|
+
sandboxPolicy,
|
|
329
337
|
}, SESSION_REQUEST_TIMEOUT_MS);
|
|
330
338
|
let response: { turn: { id: string } };
|
|
331
339
|
try {
|
|
@@ -338,6 +346,7 @@ export class CodexRuntime implements AgentRuntime {
|
|
|
338
346
|
);
|
|
339
347
|
await this.resumeAppServerSession(session, client);
|
|
340
348
|
session.needsResume = false;
|
|
349
|
+
sandboxPolicy = await this.turnSandboxPolicy(session, client);
|
|
341
350
|
response = await start();
|
|
342
351
|
}
|
|
343
352
|
if (session.activeTurnId !== response.turn.id) {
|
|
@@ -1696,7 +1705,7 @@ export class CodexRuntime implements AgentRuntime {
|
|
|
1696
1705
|
session.activeTurnStartedAt = undefined;
|
|
1697
1706
|
session.messagePhases.clear();
|
|
1698
1707
|
this.emit({
|
|
1699
|
-
type: "
|
|
1708
|
+
type: "turn_status_unknown",
|
|
1700
1709
|
sessionId: session.localSessionId,
|
|
1701
1710
|
turnId: activeTurnId,
|
|
1702
1711
|
message: "The App Server no longer reports this execution in the thread history.",
|
|
@@ -1907,7 +1916,7 @@ export class CodexRuntime implements AgentRuntime {
|
|
|
1907
1916
|
session.activeTurnStartedAt = undefined;
|
|
1908
1917
|
session.generatedImagePaths = [];
|
|
1909
1918
|
this.emit({
|
|
1910
|
-
type: "
|
|
1919
|
+
type: intentionalRelease ? "turn_cancelled" : "turn_status_unknown",
|
|
1911
1920
|
sessionId: session.localSessionId,
|
|
1912
1921
|
turnId,
|
|
1913
1922
|
message: intentionalRelease
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Command } from "./commandTypes.js";
|
|
2
|
+
import { parseScheduleCommand } from "../scheduling/ScheduleCommand.js";
|
|
2
3
|
|
|
3
4
|
export const COMMAND_NAMES = [
|
|
4
5
|
"agent",
|
|
@@ -22,7 +23,9 @@ export const COMMAND_NAMES = [
|
|
|
22
23
|
"queue",
|
|
23
24
|
"release",
|
|
24
25
|
"restart",
|
|
26
|
+
"schedule",
|
|
25
27
|
"sessions",
|
|
28
|
+
"settings",
|
|
26
29
|
"status",
|
|
27
30
|
"stop",
|
|
28
31
|
"switch",
|
|
@@ -58,6 +61,10 @@ export class CommandRouter {
|
|
|
58
61
|
const command = resolveCommandName(rawCommand);
|
|
59
62
|
|
|
60
63
|
switch (command) {
|
|
64
|
+
case "settings":
|
|
65
|
+
return settingsCommand("/settings", args, { type: "settings" });
|
|
66
|
+
case "schedule":
|
|
67
|
+
return { type: "schedule", command: parseScheduleCommand(args) };
|
|
61
68
|
case "dir":
|
|
62
69
|
return { type: "dir", directory: args.join(" ").trim() || undefined };
|
|
63
70
|
case "file": {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export type Command =
|
|
2
|
+
| { type: "settings" }
|
|
3
|
+
| { type: "schedule"; command: import("../scheduling/types.js").ScheduleCommand }
|
|
2
4
|
| { type: "shell"; command: string }
|
|
3
5
|
| { type: "new"; title?: string; cwd?: string; projectless?: boolean; agentName?: string }
|
|
4
6
|
| { type: "newgroup"; title?: string; cwd?: string; projectless?: boolean; agentName?: string }
|