Repository navigation
fix(auth): 为普通定时任务发布创建者 CLI 凭证 - #1843
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟡 Changes recommended
Identity-preparation failures can leave partially registered ghost sessions after concurrent pause or revocation.
1 open finding
What changed in this PR
Extends scheduled-turn CLI identity preparation to ordinary tasks so creator credentials are safely bound to each invocation.
Changes:
- Resolves ordinary task creators from authoritative schedule records.
- Publishes turn-bound
lark-cliandbytedclicredentials or explicit denial. - Adds production callback and wrapper-level regression tests.
| File | Description |
|---|---|
src/daemon.ts |
Adds identity preparation for all scheduled tasks. |
test/turn-cli-identity.test.ts |
Tests credentials, denial, isolation, and scheduler wiring. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| { | ||
| prepareTurnIdentity: (session, turnId) => | ||
| prepareTurnCliIdentity(session, turnId), | ||
| } : undefined, | ||
| }, |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1a2fddcb7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // was removed receive a denial, even if this session once held valid tokens. | ||
| const senderOpenId = caller?.requestLarkAppId === ds.larkAppId | ||
| && caller.requestUserOpenId | ||
| && getDashboardAdminOpenIds(ds.larkAppId).includes(caller.requestUserOpenId) |
There was a problem hiding this comment.
Honor open-mode schedule creators when publishing credentials
When a bot has no configured allowlist, /schedule creation is legitimately allowed by canOperate's open-mode fallback (src/im/lark/event-dispatcher.ts:2294), and the existing scheduled-turn owner gate explicitly preserves that behavior (src/daemon.ts:7553-7563). In that mode getDashboardAdminOpenIds is empty, so this condition always clears senderOpenId and publishes a denial even when the human creator has already authorized lark-cli/bytedcli; every such ordinary scheduled tool call therefore fails. Reuse the scheduled-owner/canOperate permission predicate rather than requiring membership in the dashboard admin list.
Useful? React with 👍 / 👎.
| { | ||
| prepareTurnIdentity: (session, turnId) => | ||
| prepareTurnCliIdentity(session, turnId), |
There was a problem hiding this comment.
Roll back fresh sessions when identity preparation rejects
With triggerUserAuth enabled, if an ordinary run passes the callback's initial active-state check but is paused or removed while its precondition or Lark routing awaits, this new preparation callback rejects. On the fresh-session path, executeScheduledTask has already persisted and registered the DaemonSession before invoking it (src/core/session-manager.ts:4524-4539), and that catch only disarms silent state, so the failed run leaves a workerless initialStartPending owner occupying the chat/topic and blocking later turns. Run the revocation-sensitive preparation before registration or close/unregister the candidate on preparation failure.
Useful? React with 👍 / 👎.
1aac76e to
01cd215
Compare
01cd215 to
cb5aaae
Compare
|
🚀 Released in v3.43.0 |

开启
triggerUserAuth后,普通定时任务虽然携带创建者的TrustedCaller,却没有发布本轮lark-cli/bytedcli凭证:scheduler 只为 delegated 任务接入身份准备回调,而schedule:身份入口也只处理 delegated 任务。因此新会话会缺少凭证,复用会话可能因旧凭证的 turnId 不匹配而被拒绝。本次将身份准备回调接入所有定时任务,并从主机端 ScheduleAuthorityStore 的任务记录解析普通任务创建者。凭证绑定每次触发的 scheduled turnId;首次执行、周期复用,以及恢复/续跑共用该入口。创建者的操作权限复用
canOperate,保留未配置白名单时的开放模式语义。创建者身份不完整、应用不匹配、已失去 Bot 操作权限或未授权时,对应工具收到拒绝结果。手动暂停/撤销及目标群不匹配在派发前拒绝。自动完成的一次性任务允许恢复/续跑。有限次数 interval/cron 最后一轮自动完成后的续跑问题仍未解决。委托任务继续使用现有 runScopes 与控制人校验。身份准备在新会话注册前、复用会话修改路由和 prompt 前执行。准备失败时关闭新候选的持久化记录,保留已有会话状态以及并发注册者,避免留下占用话题的 workerless 会话或改写上一轮 deferred turn。
影响面:共享 daemon 调度路径,覆盖普通 CLI / RPC 使用的现有工具身份包装器;测试实际执行 lark-cli 与 bytedcli 包装脚本,并检查轮次交错时拒绝串用身份。开启/关闭开关对已有 CLI 进程的热更新不在本次范围。
验证(独立 checkout,Bun 1.4.2,Node 24.19.0):
bytedcli.env而失败;修复后通过。01cd215执行bun run test test/turn-cli-identity.test.ts test/cli-identity.test.ts test/scheduled-turn-provenance.test.ts test/schedule-delegated-runtime.test.ts test/scheduler-silent-execute.test.ts:5 个测试文件、225 个测试通过,包含身份准备失败后的会话清理/保留及开放模式权限回归。01cd215执行bun run build:通过,包含源码、脚本和指定测试 mock 类型检查、dashboard 打包及构建审计。git diff --check:通过。尚未部署到 live daemon,也未验证真实飞书/ByteCloud 授权与定时任务运行。