@oyasmi/pipiclaw 0.9.4 → 0.9.5-beta.3
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.en.md +35 -31
- package/README.md +34 -30
- package/dist/agent/builtin-commands.d.ts +7 -2
- package/dist/agent/builtin-commands.js +19 -23
- package/dist/agent/channel-runner.d.ts +23 -35
- package/dist/agent/channel-runner.js +150 -89
- package/dist/agent/maintenance-context.d.ts +8 -5
- package/dist/agent/maintenance-context.js +30 -15
- package/dist/agent/prompt/manifest.js +1 -1
- package/dist/agent/prompt/resources.d.ts +1 -1
- package/dist/agent/prompt/resources.js +1 -1
- package/dist/agent/prompt/sections.js +11 -9
- package/dist/agent/prompt/types.d.ts +1 -1
- package/dist/agent/runner-factory.d.ts +6 -6
- package/dist/agent/runner-factory.js +7 -8
- package/dist/agent/session/command-extension.js +11 -0
- package/dist/agent/session/compaction-input.d.ts +6 -0
- package/dist/agent/session/compaction-input.js +75 -0
- package/dist/agent/session/compaction-snapshot.d.ts +30 -0
- package/dist/agent/session/compaction-snapshot.js +154 -0
- package/dist/agent/session/compaction-summary.d.ts +39 -0
- package/dist/agent/session/compaction-summary.js +162 -0
- package/dist/agent/session/compaction.d.ts +35 -0
- package/dist/agent/session/compaction.js +294 -0
- package/dist/agent/session/context-input.d.ts +15 -0
- package/dist/agent/session/context-input.js +82 -0
- package/dist/agent/session/context-snapshot.d.ts +11 -0
- package/dist/agent/session/context-snapshot.js +72 -0
- package/dist/agent/session/event-guards.d.ts +2 -0
- package/dist/agent/session/event-guards.js +4 -0
- package/dist/agent/session/execution-trace.d.ts +14 -0
- package/dist/agent/session/execution-trace.js +57 -0
- package/dist/agent/session/request-tools.d.ts +3 -0
- package/dist/agent/session/request-tools.js +20 -0
- package/dist/agent/session/session-adapter.d.ts +2 -1
- package/dist/agent/session/session-adapter.js +6 -3
- package/dist/agent/session/session-events.d.ts +4 -8
- package/dist/agent/session/session-events.js +80 -70
- package/dist/agent/session/session-host.d.ts +39 -61
- package/dist/agent/session/session-host.js +122 -124
- package/dist/agent/session/settings-diagnostics.d.ts +5 -0
- package/dist/agent/session/settings-diagnostics.js +21 -0
- package/dist/agent/status-render.js +5 -2
- package/dist/{runtime → agent}/stop-watchdog.d.ts +3 -1
- package/dist/{runtime → agent}/stop-watchdog.js +7 -3
- package/dist/agent/turn/progress-formatter.d.ts +1 -3
- package/dist/agent/turn/progress-formatter.js +3 -22
- package/dist/agent/turn/task-digest.d.ts +5 -4
- package/dist/agent/turn/task-digest.js +37 -34
- package/dist/agent/turn/turn-context.d.ts +12 -8
- package/dist/agent/turn/turn-context.js +27 -19
- package/dist/agent/turn/turn-finish.d.ts +18 -6
- package/dist/agent/turn/turn-finish.js +52 -77
- package/dist/agent/turn/turn-input.d.ts +2 -2
- package/dist/agent/turn/turn-input.js +4 -3
- package/dist/agent/turn/turn-output.d.ts +19 -0
- package/dist/agent/turn/turn-output.js +41 -0
- package/dist/agent/turn/turn-pipeline.d.ts +15 -10
- package/dist/agent/turn/turn-pipeline.js +86 -59
- package/dist/agent/turn/turn-prompt.d.ts +1 -1
- package/dist/agent/turn/turn-recovery.d.ts +11 -10
- package/dist/agent/turn/turn-recovery.js +14 -29
- package/dist/agent/types.d.ts +93 -24
- package/dist/agent/types.js +5 -1
- package/dist/app/auth-command.js +1 -1
- package/dist/app/home.js +34 -19
- package/dist/channel/active-session-store.d.ts +14 -12
- package/dist/channel/active-session-store.js +29 -25
- package/dist/channel/attachments.d.ts +25 -0
- package/dist/channel/attachments.js +56 -0
- package/dist/channel/channel-context.d.ts +87 -96
- package/dist/channel/channel-context.js +1 -66
- package/dist/channel/channel-event.d.ts +49 -47
- package/dist/channel/channel-event.js +6 -11
- package/dist/channel/channel-id.d.ts +22 -0
- package/dist/channel/channel-id.js +13 -0
- package/dist/channel/channel-index.d.ts +17 -34
- package/dist/channel/channel-index.js +41 -80
- package/dist/channel/config.d.ts +10 -0
- package/dist/channel/config.js +55 -0
- package/dist/channel/ingress.d.ts +93 -0
- package/dist/channel/ingress.js +5 -0
- package/dist/channel/store.d.ts +14 -16
- package/dist/channel/store.js +21 -25
- package/dist/channel/transport.d.ts +99 -0
- package/dist/channel/turn-context.d.ts +23 -0
- package/dist/channel/turn-context.js +1 -0
- package/dist/commands/catalog.d.ts +4 -7
- package/dist/commands/catalog.js +48 -49
- package/dist/commands/router.d.ts +28 -14
- package/dist/commands/router.js +30 -27
- package/dist/config/settings.d.ts +8 -14
- package/dist/config/settings.js +0 -7
- package/dist/config/tools.d.ts +2 -2
- package/dist/config/tools.js +2 -2
- package/dist/desk/bindings.d.ts +6 -0
- package/dist/desk/bindings.js +105 -0
- package/dist/desk/commands.d.ts +81 -0
- package/dist/desk/commands.js +145 -0
- package/dist/desk/default.d.ts +4 -0
- package/dist/desk/default.js +11 -0
- package/dist/desk/paths.d.ts +41 -0
- package/dist/desk/paths.js +81 -0
- package/dist/desk/registry.d.ts +17 -0
- package/dist/desk/registry.js +191 -0
- package/dist/desk/startup-error.d.ts +4 -0
- package/dist/desk/startup-error.js +7 -0
- package/dist/desk/types.d.ts +72 -0
- package/dist/desk/types.js +7 -0
- package/dist/dingtalk/bot.d.ts +20 -35
- package/dist/dingtalk/bot.js +25 -204
- package/dist/dingtalk/cards.d.ts +7 -0
- package/dist/dingtalk/cards.js +32 -2
- package/dist/dingtalk/channel-ids.d.ts +15 -0
- package/dist/dingtalk/channel-ids.js +39 -0
- package/dist/dingtalk/config.d.ts +6 -3
- package/dist/dingtalk/config.js +13 -25
- package/dist/dingtalk/connection.d.ts +1 -0
- package/dist/dingtalk/connection.js +5 -4
- package/dist/dingtalk/conversation-meta.d.ts +10 -5
- package/dist/dingtalk/conversation-meta.js +72 -50
- package/dist/dingtalk/delivery.d.ts +34 -14
- package/dist/dingtalk/delivery.js +332 -190
- package/dist/dingtalk/inbound-media.d.ts +2 -18
- package/dist/dingtalk/inbound-media.js +0 -53
- package/dist/dingtalk/inbound.d.ts +10 -11
- package/dist/dingtalk/inbound.js +12 -19
- package/dist/dingtalk/media.d.ts +9 -11
- package/dist/dingtalk/media.js +18 -31
- package/dist/dingtalk/progress.d.ts +57 -0
- package/dist/dingtalk/progress.js +199 -0
- package/dist/dingtalk/response-mode.d.ts +13 -0
- package/dist/dingtalk/response-mode.js +31 -0
- package/dist/dingtalk/transport.d.ts +47 -0
- package/dist/dingtalk/transport.js +71 -0
- package/dist/events/commands.d.ts +7 -2
- package/dist/events/commands.js +40 -22
- package/dist/events/pre-action-error.d.ts +10 -0
- package/dist/events/pre-action-error.js +10 -0
- package/dist/events/types.d.ts +20 -2
- package/dist/events/watcher.d.ts +14 -7
- package/dist/events/watcher.js +49 -26
- package/dist/file-store.d.ts +4 -0
- package/dist/file-store.js +6 -1
- package/dist/index.d.ts +4 -2
- package/dist/jobs/completion-observer.d.ts +20 -0
- package/dist/jobs/completion-observer.js +107 -0
- package/dist/jobs/completion-signal.d.ts +9 -0
- package/dist/jobs/completion-signal.js +32 -0
- package/dist/jobs/completion-wake.d.ts +14 -0
- package/dist/jobs/completion-wake.js +25 -0
- package/dist/jobs/manager.d.ts +29 -42
- package/dist/jobs/manager.js +130 -236
- package/dist/jobs/probe.d.ts +3 -0
- package/dist/jobs/probe.js +42 -0
- package/dist/jobs/record.d.ts +5 -6
- package/dist/jobs/record.js +2 -0
- package/dist/jobs/runtime.d.ts +28 -0
- package/dist/jobs/runtime.js +69 -0
- package/dist/log.d.ts +0 -1
- package/dist/log.js +1 -1
- package/dist/main.js +10 -3
- package/dist/memory/boundary-work.d.ts +19 -0
- package/dist/memory/boundary-work.js +204 -0
- package/dist/memory/commands.d.ts +4 -3
- package/dist/memory/commands.js +20 -17
- package/dist/memory/desk-memory-queue.d.ts +18 -0
- package/dist/memory/desk-memory-queue.js +33 -0
- package/dist/memory/index-budget.d.ts +3 -3
- package/dist/memory/index-budget.js +21 -18
- package/dist/memory/journal.d.ts +6 -6
- package/dist/memory/journal.js +16 -15
- package/dist/memory/lifecycle.d.ts +17 -28
- package/dist/memory/lifecycle.js +87 -147
- package/dist/memory/maintenance-state.d.ts +14 -15
- package/dist/memory/maintenance-state.js +43 -42
- package/dist/memory/reflect-job.d.ts +5 -10
- package/dist/memory/reflect-job.js +29 -44
- package/dist/memory/reflect.d.ts +6 -1
- package/dist/memory/reflect.js +44 -16
- package/dist/memory/render.d.ts +1 -1
- package/dist/memory/render.js +2 -2
- package/dist/memory/review-log.d.ts +17 -4
- package/dist/memory/review-log.js +54 -5
- package/dist/memory/scheduler.d.ts +12 -19
- package/dist/memory/scheduler.js +28 -64
- package/dist/memory/search.js +7 -4
- package/dist/memory/session-corpus.d.ts +4 -1
- package/dist/memory/session-corpus.js +70 -29
- package/dist/memory/session-search.d.ts +11 -3
- package/dist/memory/session-search.js +14 -11
- package/dist/memory/sidecar-worker.d.ts +1 -0
- package/dist/memory/sidecar-worker.js +57 -76
- package/dist/memory/source-window.d.ts +18 -7
- package/dist/memory/source-window.js +59 -29
- package/dist/memory/store.d.ts +14 -12
- package/dist/memory/store.js +89 -57
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +2 -0
- package/dist/playbooks/agent-delegation.md +23 -17
- package/dist/playbooks/background-jobs.md +7 -5
- package/dist/playbooks/event-scheduling.md +9 -7
- package/dist/playbooks/memory-and-learning.md +18 -14
- package/dist/playbooks/outbound-media.md +3 -3
- package/dist/playbooks/runtime-orientation.md +39 -23
- package/dist/playbooks/task-lead.md +57 -34
- package/dist/runtime/bootstrap.d.ts +45 -35
- package/dist/runtime/bootstrap.js +372 -167
- package/dist/runtime/channel-queue.d.ts +25 -0
- package/dist/{dingtalk → runtime}/channel-queue.js +25 -10
- package/dist/runtime/daemon-lock.d.ts +12 -0
- package/dist/runtime/daemon-lock.js +28 -0
- package/dist/runtime/desk-runtime.d.ts +131 -0
- package/dist/runtime/desk-runtime.js +402 -0
- package/dist/runtime/durable-dispatch.d.ts +18 -5
- package/dist/runtime/durable-dispatch.js +85 -14
- package/dist/runtime/inbound-images.d.ts +32 -10
- package/dist/runtime/inbound-images.js +95 -21
- package/dist/runtime/ingress-busy.d.ts +25 -0
- package/dist/runtime/ingress-busy.js +178 -0
- package/dist/runtime/ingress-commands.d.ts +7 -0
- package/dist/runtime/ingress-commands.js +170 -0
- package/dist/runtime/ingress-deps.d.ts +59 -0
- package/dist/runtime/ingress-deps.js +1 -0
- package/dist/runtime/ingress.d.ts +22 -0
- package/dist/runtime/ingress.js +386 -0
- package/dist/runtime/request-execution.d.ts +19 -0
- package/dist/runtime/request-execution.js +88 -0
- package/dist/runtime/shutdown.d.ts +14 -6
- package/dist/runtime/shutdown.js +11 -5
- package/dist/runtime/task-close.d.ts +4 -0
- package/dist/runtime/task-close.js +102 -0
- package/dist/runtime/task-control.d.ts +34 -0
- package/dist/runtime/task-control.js +225 -0
- package/dist/runtime/task-input.d.ts +13 -0
- package/dist/runtime/task-input.js +129 -0
- package/dist/runtime/task-lane-types.d.ts +123 -0
- package/dist/runtime/task-lane-types.js +14 -0
- package/dist/runtime/task-lane.d.ts +99 -0
- package/dist/runtime/task-lane.js +703 -0
- package/dist/runtime/task-pending.d.ts +8 -0
- package/dist/runtime/task-pending.js +40 -0
- package/dist/runtime/task-spawn.d.ts +8 -8
- package/dist/runtime/task-spawn.js +10 -9
- package/dist/runtime/task-step.d.ts +32 -0
- package/dist/runtime/task-step.js +276 -0
- package/dist/runtime/transports.d.ts +32 -0
- package/dist/runtime/transports.js +101 -0
- package/dist/runtime/turn-run.d.ts +20 -23
- package/dist/runtime/turn-run.js +252 -159
- package/dist/runtime/wake-coalescing.d.ts +12 -6
- package/dist/runtime/wake-coalescing.js +12 -4
- package/dist/security/config.js +5 -10
- package/dist/security/logger.js +1 -1
- package/dist/security/path-guard.js +7 -63
- package/dist/security/types.d.ts +27 -30
- package/dist/security/types.js +0 -1
- package/dist/shared/atomic-file.d.ts +2 -0
- package/dist/shared/atomic-file.js +14 -1
- package/dist/shared/file-lock.d.ts +35 -0
- package/dist/shared/file-lock.js +195 -0
- package/dist/shared/format.d.ts +0 -6
- package/dist/shared/format.js +0 -17
- package/dist/shared/host-process.d.ts +2 -0
- package/dist/shared/host-process.js +16 -1
- package/dist/shared/jsonl-appender.d.ts +5 -0
- package/dist/shared/jsonl-appender.js +25 -2
- package/dist/shared/with-timeout.d.ts +2 -0
- package/dist/shared/with-timeout.js +21 -0
- package/dist/skills/catalog.d.ts +9 -0
- package/dist/skills/catalog.js +34 -0
- package/dist/skills/commands.d.ts +3 -12
- package/dist/skills/commands.js +36 -22
- package/dist/skills/loader.d.ts +2 -31
- package/dist/skills/loader.js +101 -68
- package/dist/skills/roots.d.ts +12 -0
- package/dist/skills/roots.js +18 -0
- package/dist/skills/types.d.ts +24 -0
- package/dist/skills/types.js +1 -0
- package/dist/subagents/completion-wake.d.ts +11 -2
- package/dist/subagents/completion-wake.js +21 -18
- package/dist/subagents/discovery.d.ts +1 -1
- package/dist/subagents/discovery.js +10 -16
- package/dist/subagents/dispatch.d.ts +0 -10
- package/dist/subagents/dispatch.js +18 -44
- package/dist/subagents/external/cursor-cli.d.ts +2 -0
- package/dist/subagents/external/cursor-cli.js +256 -0
- package/dist/subagents/external/dispatch.js +1 -1
- package/dist/subagents/external/harness.d.ts +5 -5
- package/dist/subagents/external/reconciliation.d.ts +7 -0
- package/dist/subagents/external/reconciliation.js +105 -0
- package/dist/subagents/external/recovery.d.ts +20 -0
- package/dist/subagents/external/recovery.js +71 -0
- package/dist/subagents/external/registry.js +2 -0
- package/dist/subagents/external/role-warnings.d.ts +17 -0
- package/dist/subagents/external/role-warnings.js +42 -0
- package/dist/subagents/external/run.d.ts +1 -1
- package/dist/subagents/external/run.js +21 -25
- package/dist/subagents/format.d.ts +1 -1
- package/dist/subagents/format.js +1 -1
- package/dist/subagents/grace.d.ts +2 -2
- package/dist/subagents/grace.js +3 -3
- package/dist/subagents/internal/run.js +8 -6
- package/dist/subagents/internal/worker.js +37 -16
- package/dist/subagents/result.js +2 -3
- package/dist/subagents/run-archive.d.ts +11 -0
- package/dist/subagents/run-archive.js +49 -0
- package/dist/subagents/run-record.d.ts +13 -15
- package/dist/subagents/run-record.js +5 -5
- package/dist/subagents/run-registry.d.ts +5 -3
- package/dist/subagents/run-registry.js +22 -45
- package/dist/subagents/runs.d.ts +51 -54
- package/dist/subagents/runs.js +178 -304
- package/dist/subagents/task-envelope.js +9 -11
- package/dist/subagents/task-settlement.d.ts +3 -0
- package/dist/subagents/task-settlement.js +20 -0
- package/dist/subagents/types.d.ts +7 -7
- package/dist/subagents/workspace-summary.js +5 -1
- package/dist/tasks/archive.d.ts +11 -0
- package/dist/tasks/archive.js +141 -0
- package/dist/tasks/board.d.ts +5 -12
- package/dist/tasks/board.js +4 -30
- package/dist/tasks/bound-work.d.ts +13 -7
- package/dist/tasks/bound-work.js +41 -28
- package/dist/tasks/brief.d.ts +39 -15
- package/dist/tasks/brief.js +131 -73
- package/dist/tasks/budget.d.ts +3 -3
- package/dist/tasks/budget.js +9 -4
- package/dist/tasks/commands.d.ts +24 -10
- package/dist/tasks/commands.js +225 -131
- package/dist/tasks/completion.d.ts +12 -0
- package/dist/tasks/completion.js +35 -0
- package/dist/tasks/contract.d.ts +8 -19
- package/dist/tasks/contract.js +41 -45
- package/dist/tasks/control.d.ts +138 -0
- package/dist/tasks/control.js +1 -0
- package/dist/tasks/create.d.ts +4 -2
- package/dist/tasks/create.js +13 -7
- package/dist/tasks/delivery.d.ts +24 -0
- package/dist/tasks/delivery.js +221 -0
- package/dist/tasks/file-mutation.d.ts +5 -0
- package/dist/tasks/file-mutation.js +38 -0
- package/dist/tasks/frontmatter.d.ts +46 -27
- package/dist/tasks/frontmatter.js +90 -47
- package/dist/tasks/input-receipts.d.ts +7 -0
- package/dist/tasks/input-receipts.js +60 -0
- package/dist/tasks/loop-log.d.ts +150 -37
- package/dist/tasks/loop-log.js +250 -42
- package/dist/tasks/mutation-lock.d.ts +7 -5
- package/dist/tasks/mutation-lock.js +32 -9
- package/dist/tasks/receipts.d.ts +19 -0
- package/dist/tasks/receipts.js +48 -0
- package/dist/tasks/session-path.d.ts +3 -3
- package/dist/tasks/session-path.js +5 -5
- package/dist/tasks/state.d.ts +93 -0
- package/dist/tasks/state.js +156 -0
- package/dist/tasks/store.d.ts +86 -54
- package/dist/tasks/store.js +256 -156
- package/dist/tools/bash.d.ts +8 -10
- package/dist/tools/bash.js +27 -40
- package/dist/tools/contract/details.d.ts +6 -6
- package/dist/tools/contract/details.js +6 -6
- package/dist/tools/contract/execution-trace.d.ts +4 -0
- package/dist/tools/contract/execution-trace.js +23 -0
- package/dist/tools/contract/names.d.ts +7 -0
- package/dist/tools/contract/names.js +22 -0
- package/dist/tools/contract/presentation.js +6 -2
- package/dist/tools/edit.d.ts +1 -0
- package/dist/tools/edit.js +46 -43
- package/dist/tools/event-manage.d.ts +3 -1
- package/dist/tools/event-manage.js +34 -33
- package/dist/tools/glob.js +5 -5
- package/dist/tools/grep.js +2 -2
- package/dist/tools/index.d.ts +17 -20
- package/dist/tools/index.js +28 -22
- package/dist/tools/job.d.ts +4 -2
- package/dist/tools/job.js +11 -8
- package/dist/tools/memory-manage.d.ts +5 -3
- package/dist/tools/memory-manage.js +32 -25
- package/dist/tools/read.js +1 -1
- package/dist/tools/registry.d.ts +19 -19
- package/dist/tools/registry.js +65 -34
- package/dist/tools/send-media.d.ts +2 -2
- package/dist/tools/send-media.js +3 -3
- package/dist/tools/session-search.d.ts +3 -1
- package/dist/tools/session-search.js +8 -6
- package/dist/tools/skill.d.ts +2 -2
- package/dist/tools/skill.js +24 -10
- package/dist/tools/subagent-manage.d.ts +2 -8
- package/dist/tools/subagent-manage.js +26 -19
- package/dist/tools/subagent.d.ts +0 -2
- package/dist/tools/subagent.js +3 -8
- package/dist/tools/task-manage/control-tools.d.ts +4 -0
- package/dist/tools/task-manage/control-tools.js +65 -0
- package/dist/tools/task-manage/create.js +3 -2
- package/dist/tools/task-manage/factory.d.ts +12 -6
- package/dist/tools/task-manage/factory.js +73 -58
- package/dist/tools/task-manage/lifecycle.d.ts +7 -12
- package/dist/tools/task-manage/lifecycle.js +119 -65
- package/dist/tools/task-manage/log-view.js +10 -7
- package/dist/tools/task-manage/schema.d.ts +21 -26
- package/dist/tools/task-manage/schema.js +29 -35
- package/dist/tools/task-manage/shared.d.ts +8 -39
- package/dist/tools/task-manage/shared.js +20 -69
- package/dist/tools/task-manage/step-tools.d.ts +5 -0
- package/dist/tools/task-manage/step-tools.js +103 -0
- package/dist/tools/task-manage/types.d.ts +33 -21
- package/dist/tools/web-cache.d.ts +3 -3
- package/dist/tools/web-cache.js +12 -12
- package/dist/tools/web-fetch.d.ts +2 -2
- package/dist/tools/web-fetch.js +7 -7
- package/dist/tools/write-content.d.ts +1 -0
- package/dist/tools/write-content.js +7 -2
- package/dist/tools/write.d.ts +1 -0
- package/dist/tools/write.js +1 -0
- package/dist/tui/cli.d.ts +17 -5
- package/dist/tui/cli.js +90 -27
- package/dist/tui/client.d.ts +26 -0
- package/dist/tui/client.js +157 -0
- package/dist/tui/colors.d.ts +0 -1
- package/dist/tui/colors.js +0 -1
- package/dist/tui/commands.d.ts +10 -51
- package/dist/tui/commands.js +16 -39
- package/dist/tui/frontend.d.ts +2 -2
- package/dist/tui/frontend.js +2 -2
- package/dist/tui/pitui-frontend.d.ts +0 -2
- package/dist/tui/pitui-frontend.js +1 -6
- package/dist/tui/render.d.ts +62 -0
- package/dist/tui/render.js +123 -0
- package/dist/tui/session.d.ts +92 -0
- package/dist/tui/session.js +317 -0
- package/dist/usage/ledger.d.ts +9 -4
- package/dist/usage/ledger.js +2 -0
- package/dist/usage/render.d.ts +6 -1
- package/dist/usage/render.js +20 -15
- package/dist/web/search-providers.js +0 -33
- package/dist/webapi/auth.d.ts +13 -0
- package/dist/webapi/auth.js +29 -0
- package/dist/webapi/config.d.ts +29 -0
- package/dist/webapi/config.js +100 -0
- package/dist/webapi/errors.d.ts +39 -0
- package/dist/webapi/errors.js +32 -0
- package/dist/webapi/http.d.ts +25 -0
- package/dist/webapi/http.js +4 -0
- package/dist/webapi/ids.d.ts +9 -0
- package/dist/webapi/ids.js +20 -0
- package/dist/webapi/input.d.ts +17 -0
- package/dist/webapi/input.js +229 -0
- package/dist/webapi/items.d.ts +37 -0
- package/dist/webapi/items.js +48 -0
- package/dist/webapi/key-command.d.ts +2 -0
- package/dist/webapi/key-command.js +110 -0
- package/dist/webapi/limits.d.ts +47 -0
- package/dist/webapi/limits.js +48 -0
- package/dist/webapi/request-policy.d.ts +17 -0
- package/dist/webapi/request-policy.js +160 -0
- package/dist/webapi/response-record.d.ts +68 -0
- package/dist/webapi/response-record.js +58 -0
- package/dist/webapi/response-state.d.ts +90 -0
- package/dist/webapi/response-state.js +347 -0
- package/dist/webapi/routes/conversations.d.ts +8 -0
- package/dist/webapi/routes/conversations.js +80 -0
- package/dist/webapi/routes/models.d.ts +3 -0
- package/dist/webapi/routes/models.js +12 -0
- package/dist/webapi/routes/responses.d.ts +8 -0
- package/dist/webapi/routes/responses.js +118 -0
- package/dist/webapi/routes/websocket.d.ts +9 -0
- package/dist/webapi/routes/websocket.js +328 -0
- package/dist/webapi/server.d.ts +24 -0
- package/dist/webapi/server.js +229 -0
- package/dist/webapi/service.d.ts +130 -0
- package/dist/webapi/service.js +588 -0
- package/dist/webapi/store.d.ts +46 -0
- package/dist/webapi/store.js +245 -0
- package/dist/webapi/stream.d.ts +13 -0
- package/dist/webapi/stream.js +76 -0
- package/dist/webapi/transport.d.ts +43 -0
- package/dist/webapi/transport.js +100 -0
- package/examples/sub-agents/README.md +23 -16
- package/examples/sub-agents/agents/claude-high.md +1 -1
- package/examples/sub-agents/agents/claude-main.md +1 -1
- package/examples/sub-agents/agents/codex-flash.md +1 -1
- package/examples/sub-agents/agents/codex-high.md +1 -1
- package/examples/sub-agents/agents/codex-main.md +4 -4
- package/examples/sub-agents/agents/cursor-high.md +22 -0
- package/examples/sub-agents/agents/cursor-main.md +22 -0
- package/examples/sub-agents/agents/glm-flash.md +1 -1
- package/examples/sub-agents/agents/glm-high.md +2 -2
- package/examples/sub-agents/agents/scout.md +30 -0
- package/package.json +13 -7
- package/dist/channel/channel-paths.d.ts +0 -16
- package/dist/channel/channel-paths.js +0 -53
- package/dist/channel/commands.d.ts +0 -32
- package/dist/channel/commands.js +0 -109
- package/dist/channel/project-scope-store.d.ts +0 -51
- package/dist/channel/project-scope-store.js +0 -112
- package/dist/dingtalk/channel-queue.d.ts +0 -19
- package/dist/dingtalk/handler.d.ts +0 -90
- package/dist/memory/channel-maintenance-queue.d.ts +0 -5
- package/dist/memory/channel-maintenance-queue.js +0 -8
- package/dist/runtime/task-driver.d.ts +0 -100
- package/dist/runtime/task-driver.js +0 -417
- package/dist/runtime/task-migration.d.ts +0 -30
- package/dist/runtime/task-migration.js +0 -465
- package/dist/runtime/task-wake.d.ts +0 -46
- package/dist/runtime/task-wake.js +0 -32
- package/dist/runtime/turn-handler.d.ts +0 -47
- package/dist/runtime/turn-handler.js +0 -318
- package/dist/security/project-scope.d.ts +0 -45
- package/dist/security/project-scope.js +0 -105
- package/dist/shared/wake-claim.d.ts +0 -23
- package/dist/shared/wake-claim.js +0 -26
- package/dist/skills/validation.d.ts +0 -8
- package/dist/skills/validation.js +0 -91
- package/dist/skills/workspace.d.ts +0 -33
- package/dist/skills/workspace.js +0 -116
- package/dist/tasks/steer.d.ts +0 -8
- package/dist/tasks/steer.js +0 -79
- package/dist/tasks/ticket.d.ts +0 -71
- package/dist/tasks/ticket.js +0 -138
- package/dist/tools/task-manage/step-end.d.ts +0 -11
- package/dist/tools/task-manage/step-end.js +0 -117
- package/dist/tui/app.d.ts +0 -16
- package/dist/tui/app.js +0 -166
- package/dist/tui/terminal-context.d.ts +0 -27
- package/dist/tui/terminal-context.js +0 -84
- package/dist/tui/terminal-media-sender.d.ts +0 -9
- package/dist/tui/terminal-media-sender.js +0 -15
- package/dist/tui/turn-controller.d.ts +0 -64
- package/dist/tui/turn-controller.js +0 -311
- /package/dist/{dingtalk/handler.js → channel/transport.js} +0 -0
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
import { type Ticket } from "./ticket.js";
|
|
2
1
|
/**
|
|
3
|
-
* The task frontmatter (spec
|
|
2
|
+
* The task frontmatter (spec 064, D2).
|
|
4
3
|
*
|
|
5
|
-
* A task is a one-off project: it
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* (INV-
|
|
4
|
+
* A task is a one-off project: it is queued, runs, waits and is finally archived. Every field
|
|
5
|
+
* except the contract body belongs to the runtime — the lane and `tasks/store.ts` write them from
|
|
6
|
+
* observed facts, and no model tool can (INV-2). `state: waiting` ⟺ `waiting` present and
|
|
7
|
+
* `state: paused` ⟺ `paused` present (INV-3) are enforced on every read and every write rather
|
|
8
|
+
* than checked after the fact. An archived file carries `outcome` instead of a state.
|
|
9
9
|
*/
|
|
10
|
-
export type TaskState = "
|
|
10
|
+
export type TaskState = "queued" | "running" | "waiting" | "paused";
|
|
11
|
+
/** What a waiting task is waiting for — derived from facts, never declared by the model. */
|
|
12
|
+
export type TaskWaiting = {
|
|
13
|
+
kind: "work";
|
|
14
|
+
since: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "user";
|
|
17
|
+
question: string;
|
|
18
|
+
since: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: "time";
|
|
21
|
+
until: string;
|
|
22
|
+
since: string;
|
|
23
|
+
};
|
|
11
24
|
export interface TaskPaused {
|
|
12
25
|
by: "user" | "runtime";
|
|
13
26
|
reason: string;
|
|
@@ -20,8 +33,8 @@ export interface TaskUsage {
|
|
|
20
33
|
usd: number;
|
|
21
34
|
/** True once any cost came from an estimate rather than reported usage. */
|
|
22
35
|
usdEstimated: boolean;
|
|
23
|
-
/**
|
|
24
|
-
|
|
36
|
+
/** Contributions whose price is unavailable; usd is only the known subtotal in that case. */
|
|
37
|
+
unknownCostCount?: number;
|
|
25
38
|
}
|
|
26
39
|
export interface TaskBudget {
|
|
27
40
|
steps: number;
|
|
@@ -29,14 +42,24 @@ export interface TaskBudget {
|
|
|
29
42
|
}
|
|
30
43
|
export type TaskArchiveOutcome = "completed" | "cancelled";
|
|
31
44
|
export interface TaskFrontmatter {
|
|
45
|
+
/** Last state checkpoint applied from the loop log. Updated atomically with state and usage. */
|
|
46
|
+
revision?: number;
|
|
47
|
+
/** Meaningless once `outcome` is set: an archived task has no state. */
|
|
32
48
|
state: TaskState;
|
|
49
|
+
/** Present iff `state === "waiting"` (INV-3). */
|
|
50
|
+
waiting?: TaskWaiting;
|
|
51
|
+
/** Present iff `state === "paused"` (INV-3). */
|
|
33
52
|
paused?: TaskPaused;
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
53
|
+
/**
|
|
54
|
+
* The delivery channel: where every report, question and receipt of this task goes (spec 058,
|
|
55
|
+
* D13). Plain text so a human can retarget it by hand. Missing, or not bound to this task's
|
|
56
|
+
* desk, means the task is frozen until the channel is bound again (INV-7).
|
|
57
|
+
*/
|
|
58
|
+
channel?: string;
|
|
38
59
|
/** Name of the event whose template spawned this instance (spec 052, D2). */
|
|
39
60
|
origin?: string;
|
|
61
|
+
usage?: TaskUsage;
|
|
62
|
+
budget?: Partial<TaskBudget>;
|
|
40
63
|
/** Archive-only. */
|
|
41
64
|
outcome?: TaskArchiveOutcome;
|
|
42
65
|
closedAt?: string;
|
|
@@ -45,27 +68,23 @@ export interface ParsedTaskFrontmatter {
|
|
|
45
68
|
fields: TaskFrontmatter;
|
|
46
69
|
/** false => the block could not be read at all; the task is surfaced rather than skipped. */
|
|
47
70
|
readable: boolean;
|
|
48
|
-
/** True when a v3 line (`status`, `control`, `schedule`…) is present — the file is not converted, so it never runs. */
|
|
49
|
-
legacy: boolean;
|
|
50
71
|
}
|
|
51
72
|
/**
|
|
52
|
-
* The one user-facing name for a task state (spec 053, D8). `/tasks`, the
|
|
53
|
-
* spawn-skip receipt all read it here, so a third hand-written copy cannot drift
|
|
73
|
+
* The one user-facing name for a task's state (spec 053, D8; spec 064, D6). `/tasks`, the task
|
|
74
|
+
* agenda and the spawn-skip receipt all read it here, so a third hand-written copy cannot drift.
|
|
54
75
|
*/
|
|
55
|
-
export declare function taskStateLabel(
|
|
76
|
+
export declare function taskStateLabel(fields: Pick<TaskFrontmatter, "state" | "waiting">): string;
|
|
56
77
|
/**
|
|
57
|
-
* Read the leading frontmatter block. Unreadable input fails **open
|
|
58
|
-
*
|
|
59
|
-
*
|
|
78
|
+
* Read the leading frontmatter block. Unreadable input fails **open**: the task still appears in
|
|
79
|
+
* the ledger (as `queued`, flagged unreadable) so a corrupt file surfaces instead of vanishing; the
|
|
80
|
+
* lane will not execute it (`/tasks doctor` points at the repair).
|
|
60
81
|
*/
|
|
61
82
|
export declare function parseTaskFrontmatter(content: string): ParsedTaskFrontmatter;
|
|
62
83
|
/**
|
|
63
|
-
* Enforce INV-
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
84
|
+
* Enforce INV-3 on every write and read: `waiting` and `paused` states need their field, and the
|
|
85
|
+
* fields mean nothing outside their state. Doing it here rather than at each call site is what
|
|
86
|
+
* makes "waiting with nothing described" a property of the file format instead of a rule every
|
|
87
|
+
* writer has to remember.
|
|
67
88
|
*/
|
|
68
89
|
export declare function normalizeTaskFrontmatter(fields: TaskFrontmatter): TaskFrontmatter;
|
|
69
90
|
export declare function renderTaskFrontmatter(fields: TaskFrontmatter): string;
|
|
70
|
-
/** Whether the driver may schedule a step for this task right now. */
|
|
71
|
-
export declare function isTaskRunnable(fields: TaskFrontmatter): boolean;
|
|
@@ -1,19 +1,35 @@
|
|
|
1
|
-
import { formatLocalTime } from "../shared/local-time.js";
|
|
1
|
+
import { formatLocalTime, parseLocalTime } from "../shared/local-time.js";
|
|
2
2
|
import { isPlainObject } from "../shared/type-guards.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
3
|
+
const STATES = ["queued", "running", "waiting", "paused"];
|
|
4
|
+
/** Fixed render order, so a diff of a task file reads the same way every time. */
|
|
5
|
+
const FIELD_ORDER = ["state", "waiting", "paused", "channel", "origin", "usage", "budget", "revision"];
|
|
6
|
+
/** `2026-10-12T09:00:00.000+08:00` → `10-12 09:00`, read off the stored wall-clock text. */
|
|
7
|
+
function minuteOf(at) {
|
|
8
|
+
const match = /^\d{4}-(\d{2}-\d{2})T(\d{2}:\d{2})/.exec(at);
|
|
9
|
+
return match ? `${match[1]} ${match[2]}` : at;
|
|
10
|
+
}
|
|
6
11
|
/**
|
|
7
|
-
* The one user-facing name for a task state (spec 053, D8). `/tasks`, the
|
|
8
|
-
* spawn-skip receipt all read it here, so a third hand-written copy cannot drift
|
|
12
|
+
* The one user-facing name for a task's state (spec 053, D8; spec 064, D6). `/tasks`, the task
|
|
13
|
+
* agenda and the spawn-skip receipt all read it here, so a third hand-written copy cannot drift.
|
|
9
14
|
*/
|
|
10
|
-
export function taskStateLabel(
|
|
11
|
-
|
|
15
|
+
export function taskStateLabel(fields) {
|
|
16
|
+
switch (fields.state) {
|
|
17
|
+
case "queued":
|
|
18
|
+
return "排队中";
|
|
19
|
+
case "running":
|
|
20
|
+
return "执行中";
|
|
21
|
+
case "paused":
|
|
22
|
+
return "已暂停";
|
|
23
|
+
case "waiting": {
|
|
24
|
+
const waiting = fields.waiting;
|
|
25
|
+
if (waiting?.kind === "user")
|
|
26
|
+
return "等你回复";
|
|
27
|
+
if (waiting?.kind === "time")
|
|
28
|
+
return `等到 ${minuteOf(waiting.until)}`;
|
|
29
|
+
return "等结果";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
12
32
|
}
|
|
13
|
-
/** Fixed render order, so a diff of a task file reads the same way every time. */
|
|
14
|
-
const FIELD_ORDER = ["state", "paused", "origin", "ticket", "usage", "budget"];
|
|
15
|
-
/** v3 frontmatter keys; their presence means the one-time conversion has not run on this file. */
|
|
16
|
-
const LEGACY_KEYS = new Set(["status", "enabled", "control", "wake", "schedule"]);
|
|
17
33
|
function parseJsonObject(raw) {
|
|
18
34
|
try {
|
|
19
35
|
const value = JSON.parse(raw);
|
|
@@ -23,16 +39,38 @@ function parseJsonObject(raw) {
|
|
|
23
39
|
return undefined;
|
|
24
40
|
}
|
|
25
41
|
}
|
|
42
|
+
function nonEmptyString(value) {
|
|
43
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
44
|
+
}
|
|
45
|
+
function parseWaiting(raw) {
|
|
46
|
+
const value = parseJsonObject(raw);
|
|
47
|
+
if (!value)
|
|
48
|
+
return undefined;
|
|
49
|
+
const since = nonEmptyString(value.since) ?? formatLocalTime();
|
|
50
|
+
switch (value.kind) {
|
|
51
|
+
case "work":
|
|
52
|
+
return { kind: "work", since };
|
|
53
|
+
case "user": {
|
|
54
|
+
const question = nonEmptyString(value.question);
|
|
55
|
+
return question ? { kind: "user", question, since } : undefined;
|
|
56
|
+
}
|
|
57
|
+
case "time": {
|
|
58
|
+
const until = nonEmptyString(value.until);
|
|
59
|
+
return until && parseLocalTime(until) !== undefined ? { kind: "time", until, since } : undefined;
|
|
60
|
+
}
|
|
61
|
+
default:
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
26
65
|
function parsePaused(raw) {
|
|
27
66
|
const value = parseJsonObject(raw);
|
|
28
67
|
if (!value)
|
|
29
68
|
return undefined;
|
|
30
69
|
const by = value.by === "runtime" ? "runtime" : "user";
|
|
31
|
-
const reason =
|
|
32
|
-
const at = typeof value.at === "string" ? value.at.trim() : "";
|
|
70
|
+
const reason = nonEmptyString(value.reason);
|
|
33
71
|
if (!reason)
|
|
34
72
|
return undefined;
|
|
35
|
-
return { by, reason, at: at
|
|
73
|
+
return { by, reason, at: nonEmptyString(value.at) ?? formatLocalTime() };
|
|
36
74
|
}
|
|
37
75
|
function nonNegativeNumber(value, fallback) {
|
|
38
76
|
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : fallback;
|
|
@@ -42,11 +80,13 @@ function parseUsage(raw) {
|
|
|
42
80
|
if (!value)
|
|
43
81
|
return undefined;
|
|
44
82
|
return {
|
|
45
|
-
startedAt:
|
|
83
|
+
startedAt: nonEmptyString(value.startedAt) ?? formatLocalTime(),
|
|
46
84
|
steps: nonNegativeNumber(value.steps, 0),
|
|
47
85
|
usd: nonNegativeNumber(value.usd, 0),
|
|
48
86
|
usdEstimated: value.usdEstimated === true,
|
|
49
|
-
|
|
87
|
+
...(nonNegativeNumber(value.unknownCostCount, 0) > 0
|
|
88
|
+
? { unknownCostCount: Math.floor(nonNegativeNumber(value.unknownCostCount, 0)) }
|
|
89
|
+
: {}),
|
|
50
90
|
};
|
|
51
91
|
}
|
|
52
92
|
function parseBudget(raw) {
|
|
@@ -61,18 +101,17 @@ function parseBudget(raw) {
|
|
|
61
101
|
return Object.keys(budget).length > 0 ? budget : undefined;
|
|
62
102
|
}
|
|
63
103
|
/**
|
|
64
|
-
* Read the leading frontmatter block. Unreadable input fails **open
|
|
65
|
-
*
|
|
66
|
-
*
|
|
104
|
+
* Read the leading frontmatter block. Unreadable input fails **open**: the task still appears in
|
|
105
|
+
* the ledger (as `queued`, flagged unreadable) so a corrupt file surfaces instead of vanishing; the
|
|
106
|
+
* lane will not execute it (`/tasks doctor` points at the repair).
|
|
67
107
|
*/
|
|
68
108
|
export function parseTaskFrontmatter(content) {
|
|
69
109
|
if (!content.startsWith("---"))
|
|
70
|
-
return { fields: { state: "
|
|
110
|
+
return { fields: { state: "queued" }, readable: false };
|
|
71
111
|
const end = content.indexOf("\n---", 3);
|
|
72
112
|
if (end === -1)
|
|
73
|
-
return { fields: { state: "
|
|
74
|
-
const fields = { state: "
|
|
75
|
-
let legacy = false;
|
|
113
|
+
return { fields: { state: "queued" }, readable: false };
|
|
114
|
+
const fields = { state: "queued" };
|
|
76
115
|
let sawState = false;
|
|
77
116
|
for (const line of content.slice(3, end).split("\n")) {
|
|
78
117
|
const idx = line.indexOf(":");
|
|
@@ -81,18 +120,22 @@ export function parseTaskFrontmatter(content) {
|
|
|
81
120
|
const key = line.slice(0, idx).trim();
|
|
82
121
|
const value = line.slice(idx + 1).trim();
|
|
83
122
|
switch (key) {
|
|
123
|
+
case "revision":
|
|
124
|
+
if (/^\d+$/.test(value))
|
|
125
|
+
fields.revision = Number(value);
|
|
126
|
+
break;
|
|
84
127
|
case "state":
|
|
85
128
|
if (STATES.includes(value)) {
|
|
86
129
|
fields.state = value;
|
|
87
130
|
sawState = true;
|
|
88
131
|
}
|
|
89
132
|
break;
|
|
133
|
+
case "waiting":
|
|
134
|
+
fields.waiting = parseWaiting(value);
|
|
135
|
+
break;
|
|
90
136
|
case "paused":
|
|
91
137
|
fields.paused = parsePaused(value);
|
|
92
138
|
break;
|
|
93
|
-
case "ticket":
|
|
94
|
-
fields.ticket = parseTicket(value);
|
|
95
|
-
break;
|
|
96
139
|
case "usage":
|
|
97
140
|
fields.usage = parseUsage(value);
|
|
98
141
|
break;
|
|
@@ -102,6 +145,9 @@ export function parseTaskFrontmatter(content) {
|
|
|
102
145
|
case "origin":
|
|
103
146
|
fields.origin = value || undefined;
|
|
104
147
|
break;
|
|
148
|
+
case "channel":
|
|
149
|
+
fields.channel = value || undefined;
|
|
150
|
+
break;
|
|
105
151
|
case "outcome":
|
|
106
152
|
if (value === "completed" || value === "cancelled")
|
|
107
153
|
fields.outcome = value;
|
|
@@ -110,35 +156,34 @@ export function parseTaskFrontmatter(content) {
|
|
|
110
156
|
fields.closedAt = value || undefined;
|
|
111
157
|
break;
|
|
112
158
|
default:
|
|
113
|
-
if (LEGACY_KEYS.has(key))
|
|
114
|
-
legacy = true;
|
|
115
159
|
break;
|
|
116
160
|
}
|
|
117
161
|
}
|
|
118
|
-
if (fields.outcome)
|
|
119
|
-
fields.state = "done";
|
|
120
162
|
// A file with no recognizable marker is not frontmatter we understand.
|
|
121
|
-
const readable = sawState || fields.outcome !== undefined
|
|
122
|
-
return { fields: normalizeTaskFrontmatter(fields), readable
|
|
163
|
+
const readable = sawState || fields.outcome !== undefined;
|
|
164
|
+
return { fields: normalizeTaskFrontmatter(fields), readable };
|
|
123
165
|
}
|
|
124
166
|
/**
|
|
125
|
-
* Enforce INV-
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
167
|
+
* Enforce INV-3 on every write and read: `waiting` and `paused` states need their field, and the
|
|
168
|
+
* fields mean nothing outside their state. Doing it here rather than at each call site is what
|
|
169
|
+
* makes "waiting with nothing described" a property of the file format instead of a rule every
|
|
170
|
+
* writer has to remember.
|
|
129
171
|
*/
|
|
130
172
|
export function normalizeTaskFrontmatter(fields) {
|
|
131
173
|
const next = { ...fields };
|
|
132
174
|
if (next.outcome) {
|
|
133
|
-
next.
|
|
134
|
-
next.ticket = undefined;
|
|
175
|
+
next.waiting = undefined;
|
|
135
176
|
next.paused = undefined;
|
|
136
177
|
return next;
|
|
137
178
|
}
|
|
138
|
-
if (next.state === "
|
|
139
|
-
next.state = "
|
|
140
|
-
if (next.state
|
|
141
|
-
next.
|
|
179
|
+
if (next.state === "waiting" && !next.waiting)
|
|
180
|
+
next.state = "queued";
|
|
181
|
+
if (next.state === "paused" && !next.paused)
|
|
182
|
+
next.state = "queued";
|
|
183
|
+
if (next.state !== "waiting")
|
|
184
|
+
next.waiting = undefined;
|
|
185
|
+
if (next.state !== "paused")
|
|
186
|
+
next.paused = undefined;
|
|
142
187
|
return next;
|
|
143
188
|
}
|
|
144
189
|
export function renderTaskFrontmatter(fields) {
|
|
@@ -148,6 +193,8 @@ export function renderTaskFrontmatter(fields) {
|
|
|
148
193
|
lines.push(`outcome: ${document.outcome}`);
|
|
149
194
|
if (document.closedAt)
|
|
150
195
|
lines.push(`closedAt: ${document.closedAt}`);
|
|
196
|
+
if (document.channel)
|
|
197
|
+
lines.push(`channel: ${document.channel}`);
|
|
151
198
|
if (document.origin)
|
|
152
199
|
lines.push(`origin: ${document.origin}`);
|
|
153
200
|
if (document.usage)
|
|
@@ -164,7 +211,3 @@ export function renderTaskFrontmatter(fields) {
|
|
|
164
211
|
lines.push("---");
|
|
165
212
|
return lines.join("\n");
|
|
166
213
|
}
|
|
167
|
-
/** Whether the driver may schedule a step for this task right now. */
|
|
168
|
-
export function isTaskRunnable(fields) {
|
|
169
|
-
return fields.state === "open" && !fields.paused && !fields.outcome;
|
|
170
|
-
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function taskInputTag(id: string): string;
|
|
2
|
+
/** Read the actual transcript, not SDK queue/message events (those precede persistence). */
|
|
3
|
+
export declare function acknowledgeTaskInputs(deskDir: string, taskId: string, trace?: {
|
|
4
|
+
desk: string;
|
|
5
|
+
seq: number;
|
|
6
|
+
generation?: string;
|
|
7
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import * as log from "../log.js";
|
|
3
|
+
import { isPlainObject } from "../shared/type-guards.js";
|
|
4
|
+
import { appendTaskLog, newInputs, readTaskLog } from "./loop-log.js";
|
|
5
|
+
import { withTaskMutation } from "./mutation-lock.js";
|
|
6
|
+
import { taskSessionPath } from "./session-path.js";
|
|
7
|
+
export function taskInputTag(id) {
|
|
8
|
+
return `<task_input id="${id}" />`;
|
|
9
|
+
}
|
|
10
|
+
/** Read the actual transcript, not SDK queue/message events (those precede persistence). */
|
|
11
|
+
export async function acknowledgeTaskInputs(deskDir, taskId, trace) {
|
|
12
|
+
await withTaskMutation(deskDir, taskId, async () => {
|
|
13
|
+
const pending = newInputs(await readTaskLog(deskDir, taskId, { strict: true }));
|
|
14
|
+
if (pending.length === 0)
|
|
15
|
+
return;
|
|
16
|
+
let transcript;
|
|
17
|
+
try {
|
|
18
|
+
transcript = await readFile(taskSessionPath(deskDir, taskId), "utf-8");
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
22
|
+
return;
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
const received = new Set();
|
|
26
|
+
for (const line of transcript.split("\n")) {
|
|
27
|
+
let entry;
|
|
28
|
+
try {
|
|
29
|
+
entry = JSON.parse(line);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (!isPlainObject(entry) ||
|
|
35
|
+
entry.type !== "message" ||
|
|
36
|
+
!isPlainObject(entry.message) ||
|
|
37
|
+
entry.message.role !== "user")
|
|
38
|
+
continue;
|
|
39
|
+
const content = entry.message.content;
|
|
40
|
+
const text = typeof content === "string"
|
|
41
|
+
? content
|
|
42
|
+
: Array.isArray(content)
|
|
43
|
+
? content
|
|
44
|
+
.filter(isPlainObject)
|
|
45
|
+
.filter((part) => part.type === "text")
|
|
46
|
+
.map((part) => part.text)
|
|
47
|
+
.join("\n")
|
|
48
|
+
: "";
|
|
49
|
+
for (const match of text.matchAll(/<task_input id="([a-f0-9-]+)" \/>/g))
|
|
50
|
+
received.add(match[1]);
|
|
51
|
+
}
|
|
52
|
+
const ids = pending.flatMap((record) => (record.id && received.has(record.id) ? [record.id] : []));
|
|
53
|
+
if (ids.length > 0) {
|
|
54
|
+
await appendTaskLog(deskDir, taskId, { kind: "input_ack", ids });
|
|
55
|
+
log.logInfoEvent("tasks.input.received", "Task inputs received", {
|
|
56
|
+
fields: { deskDir, taskId, ...trace, ids },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|