@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
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The channel plane's inbound contract (spec 061, D5): the one place a transport hands a message
|
|
3
|
+
* to the runtime. Authorization has already happened by the time a transport calls it.
|
|
4
|
+
*/
|
|
5
|
+
export interface InboundMessage {
|
|
6
|
+
channelId: string;
|
|
7
|
+
user: string;
|
|
8
|
+
userName?: string;
|
|
9
|
+
/** The group title or the peer's nickname, for the channel index; absent when there is none. */
|
|
10
|
+
channelName?: string;
|
|
11
|
+
/** The user's text; each attachment sits where its `[图片N]` / `[文件N]` marker is. */
|
|
12
|
+
text: string;
|
|
13
|
+
/** Raw attachment bytes. A transport downloads or decodes and checks size; persisting is the runtime's job. */
|
|
14
|
+
attachments?: InboundAttachment[];
|
|
15
|
+
/** The transport's correlation reference; replies to this message carry it back (`PushMessage.ref`). */
|
|
16
|
+
ref?: string;
|
|
17
|
+
ts: string;
|
|
18
|
+
/**
|
|
19
|
+
* The desks this sender may use; absent means any (an allow-listed DingTalk user, the local
|
|
20
|
+
* socket). The first entry is the sender's default desk: an unbound channel is bound to it.
|
|
21
|
+
*/
|
|
22
|
+
allowedDesks?: readonly string[];
|
|
23
|
+
context?: import("./turn-context.js").TurnContext;
|
|
24
|
+
/** Runtime-derived execution desk for a saved response continuation. */
|
|
25
|
+
desk?: string;
|
|
26
|
+
}
|
|
27
|
+
/** `index` is the N of the `[图片N]` / `[文件N]` marker the attachment belongs to. */
|
|
28
|
+
export type InboundAttachment = {
|
|
29
|
+
kind: "image";
|
|
30
|
+
index: number;
|
|
31
|
+
data: Buffer;
|
|
32
|
+
} | {
|
|
33
|
+
kind: "file";
|
|
34
|
+
index: number;
|
|
35
|
+
data: Buffer;
|
|
36
|
+
fileName: string;
|
|
37
|
+
};
|
|
38
|
+
export type IngressResult =
|
|
39
|
+
/** A turn for this message starts now. */
|
|
40
|
+
{
|
|
41
|
+
kind: "started";
|
|
42
|
+
}
|
|
43
|
+
/** It runs after the current turn, as a turn of its own. */
|
|
44
|
+
| {
|
|
45
|
+
kind: "queued";
|
|
46
|
+
}
|
|
47
|
+
/** A command or a steer was handled; the reply (if any) went out through `push` with the message's `ref`. */
|
|
48
|
+
| {
|
|
49
|
+
kind: "replied";
|
|
50
|
+
} | {
|
|
51
|
+
kind: "rejected";
|
|
52
|
+
reason: IngressRejection;
|
|
53
|
+
};
|
|
54
|
+
export type IngressRejection = {
|
|
55
|
+
code: "control_command";
|
|
56
|
+
command: "stop" | "steer" | "followup";
|
|
57
|
+
} | {
|
|
58
|
+
code: "desk_not_allowed";
|
|
59
|
+
desk: string;
|
|
60
|
+
} | {
|
|
61
|
+
code: "queue_full";
|
|
62
|
+
} | {
|
|
63
|
+
code: "request_capacity";
|
|
64
|
+
} | {
|
|
65
|
+
code: "shutting_down";
|
|
66
|
+
};
|
|
67
|
+
export type SteerResult = {
|
|
68
|
+
kind: "accepted";
|
|
69
|
+
} | {
|
|
70
|
+
kind: "rejected";
|
|
71
|
+
code: "response_not_active" | "too_many_pending_steers" | "invalid_input";
|
|
72
|
+
};
|
|
73
|
+
export interface Ingress {
|
|
74
|
+
receive(message: InboundMessage): Promise<IngressResult>;
|
|
75
|
+
/** Isolated generation: no channel binding, transcript archive, or automatic reflection. */
|
|
76
|
+
execute?(message: InboundMessage): Promise<IngressResult>;
|
|
77
|
+
/** Inject `message` into the turn running on `channelId`. */
|
|
78
|
+
steer(channelId: string, message: InboundMessage): Promise<SteerResult>;
|
|
79
|
+
/** The same as `/stop`: the running turn ends and everything queued behind it is dropped. */
|
|
80
|
+
cancel(channelId: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Stop the turn running on `channelId` only if it answers the message that carried `ref`;
|
|
83
|
+
* whether it did. What is queued behind it, and anything another sender is waiting for, stays.
|
|
84
|
+
*/
|
|
85
|
+
cancelTurn(channelId: string, ref: string): Promise<boolean>;
|
|
86
|
+
/** Drop a message that has not started; whether one with this `ref` was found. */
|
|
87
|
+
dropQueued(channelId: string, ref: string): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* The transport ended this channel for good (a deleted Web API conversation): nothing more is
|
|
90
|
+
* kept for it — no binding, no runner, no background scans. `busy` while a turn runs or waits.
|
|
91
|
+
*/
|
|
92
|
+
closeChannel(channelId: string): Promise<"closed" | "busy">;
|
|
93
|
+
}
|
package/dist/channel/store.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface LoggedMessage {
|
|
|
9
9
|
deliveryMode?: "steer" | "followUp";
|
|
10
10
|
skipContextSync?: boolean;
|
|
11
11
|
/**
|
|
12
|
-
* Paths of any images the user sent alongside `text` (spec 049), relative to the
|
|
12
|
+
* Paths of any images the user sent alongside `text` (spec 049), relative to the desk
|
|
13
13
|
* directory. Kept even for an image that never made it into the model's context (unsupported
|
|
14
14
|
* format, oversized, model without vision support) — this is the only place that record
|
|
15
15
|
* survives once the turn's `[图片N: ...]` marker has scrolled out of `HISTORY.md`.
|
|
@@ -17,7 +17,11 @@ export interface LoggedMessage {
|
|
|
17
17
|
images?: string[];
|
|
18
18
|
}
|
|
19
19
|
export interface ChannelStoreConfig {
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Where a channel's archive goes right now (spec 058, D17): its conversation directory in the
|
|
22
|
+
* desk it is bound to. `undefined` for an unbound channel, which is not archived at all.
|
|
23
|
+
*/
|
|
24
|
+
resolveArchiveDir: (channelId: string) => string | undefined;
|
|
21
25
|
}
|
|
22
26
|
export interface LoggedSubAgentRun {
|
|
23
27
|
date: string;
|
|
@@ -37,7 +41,7 @@ export interface LoggedSubAgentRun {
|
|
|
37
41
|
/** Spec 040, D7: the run this entry archives, and its lifecycle context. Only set on terminal archiving. */
|
|
38
42
|
runId?: string;
|
|
39
43
|
runtime?: "internal" | "external";
|
|
40
|
-
harness?: "claude-code" | "codex-cli" | "exec";
|
|
44
|
+
harness?: "claude-code" | "codex-cli" | "cursor-cli" | "exec";
|
|
41
45
|
status?: "completed" | "failed" | "cancelled" | "lost";
|
|
42
46
|
taskId?: string;
|
|
43
47
|
artifactDir?: string;
|
|
@@ -57,29 +61,23 @@ export interface LoggedSubAgentRun {
|
|
|
57
61
|
};
|
|
58
62
|
}
|
|
59
63
|
export declare class ChannelStore {
|
|
60
|
-
private
|
|
64
|
+
private readonly resolveArchiveDir;
|
|
61
65
|
private recentlyLogged;
|
|
62
66
|
private cleanupTimer;
|
|
63
67
|
private archiveAppender;
|
|
64
68
|
private closed;
|
|
65
69
|
constructor(config: ChannelStoreConfig);
|
|
66
|
-
/**
|
|
67
|
-
* The archive path for a channel — resolved, not created.
|
|
68
|
-
*
|
|
69
|
-
* This used to call `ensureChannelDir`, i.e. a synchronous `mkdirSync` on the event loop for
|
|
70
|
-
* every archived message. `logBotResponse` runs on every progress update of a streaming turn,
|
|
71
|
-
* so that was a blocking syscall per progress tick. The appender's own `ensureDir` already
|
|
72
|
-
* creates the directory before it writes, and memoizes it, so the mkdir here was pure
|
|
73
|
-
* duplicated I/O.
|
|
74
|
-
*/
|
|
75
|
-
private channelArchiveDir;
|
|
76
70
|
/**
|
|
77
71
|
* Log a message to the channel's log.jsonl raw archive.
|
|
78
72
|
* This file is cold storage and is not proactively loaded into memory context.
|
|
79
|
-
* Returns false if message was already logged (duplicate)
|
|
73
|
+
* Returns false if the message was already logged (duplicate), or the channel is unbound.
|
|
80
74
|
*/
|
|
81
75
|
logMessage(channelId: string, message: LoggedMessage): Promise<boolean>;
|
|
82
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Archive a settled run in the desk it ran in. Takes the desk directory rather than resolving the
|
|
78
|
+
* channel: a run that settles after its channel was rebound still belongs to its own desk.
|
|
79
|
+
*/
|
|
80
|
+
logSubAgentRun(deskDir: string, run: LoggedSubAgentRun): Promise<void>;
|
|
83
81
|
/**
|
|
84
82
|
* Log a bot response
|
|
85
83
|
*/
|
package/dist/channel/store.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* with de-duplication, size
|
|
2
|
+
* The message archive: each channel's `log.jsonl` (inbound messages, bot responses) in its
|
|
3
|
+
* conversation directory, and each desk's `subagent-runs.jsonl`, with de-duplication, size
|
|
4
|
+
* rotation and a debounced flush.
|
|
4
5
|
*/
|
|
5
|
-
import { existsSync, mkdirSync } from "fs";
|
|
6
6
|
import { writeFile } from "fs/promises";
|
|
7
7
|
import { basename, dirname, join } from "path";
|
|
8
|
+
import { getSubAgentRunsLogPath } from "../desk/paths.js";
|
|
9
|
+
import * as log from "../log.js";
|
|
8
10
|
import { createJsonlAppender } from "../shared/jsonl-appender.js";
|
|
9
11
|
import { formatLocalTime } from "../shared/local-time.js";
|
|
10
|
-
import { getChannelDir } from "./channel-paths.js";
|
|
11
12
|
const MAX_LOG_SIZE_BYTES = 1_000_000;
|
|
12
13
|
const DEDUPE_TTL_MS = 60_000;
|
|
13
14
|
const DEDUPE_CLEANUP_INTERVAL_MS = 30_000;
|
|
@@ -16,7 +17,7 @@ export class ChannelStore {
|
|
|
16
17
|
this.recentlyLogged = new Map();
|
|
17
18
|
this.cleanupTimer = null;
|
|
18
19
|
this.closed = false;
|
|
19
|
-
this.
|
|
20
|
+
this.resolveArchiveDir = config.resolveArchiveDir;
|
|
20
21
|
this.archiveAppender = createJsonlAppender({
|
|
21
22
|
pathFor: (_now, record) => record.filePath,
|
|
22
23
|
recordForWrite: (record) => record.value,
|
|
@@ -33,32 +34,23 @@ export class ChannelStore {
|
|
|
33
34
|
}
|
|
34
35
|
},
|
|
35
36
|
});
|
|
36
|
-
// Ensure working directory exists
|
|
37
|
-
if (!existsSync(this.workingDir)) {
|
|
38
|
-
mkdirSync(this.workingDir, { recursive: true });
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* The archive path for a channel — resolved, not created.
|
|
43
|
-
*
|
|
44
|
-
* This used to call `ensureChannelDir`, i.e. a synchronous `mkdirSync` on the event loop for
|
|
45
|
-
* every archived message. `logBotResponse` runs on every progress update of a streaming turn,
|
|
46
|
-
* so that was a blocking syscall per progress tick. The appender's own `ensureDir` already
|
|
47
|
-
* creates the directory before it writes, and memoizes it, so the mkdir here was pure
|
|
48
|
-
* duplicated I/O.
|
|
49
|
-
*/
|
|
50
|
-
channelArchiveDir(channelId) {
|
|
51
|
-
return getChannelDir(this.workingDir, channelId);
|
|
52
37
|
}
|
|
53
38
|
/**
|
|
54
39
|
* Log a message to the channel's log.jsonl raw archive.
|
|
55
40
|
* This file is cold storage and is not proactively loaded into memory context.
|
|
56
|
-
* Returns false if message was already logged (duplicate)
|
|
41
|
+
* Returns false if the message was already logged (duplicate), or the channel is unbound.
|
|
57
42
|
*/
|
|
58
43
|
async logMessage(channelId, message) {
|
|
59
44
|
if (this.closed) {
|
|
60
45
|
throw new Error("Channel archive is closed. Retry after the runtime has restarted.");
|
|
61
46
|
}
|
|
47
|
+
// Resolved, not created: the appender's own `ensureDir` creates the directory before it
|
|
48
|
+
// writes, and memoizes it — a sync mkdir here would block on every progress update.
|
|
49
|
+
const archiveDir = this.resolveArchiveDir(channelId);
|
|
50
|
+
if (!archiveDir) {
|
|
51
|
+
log.logDebugEvent("channel.archive.skipped", "Archive skipped: channel not bound to a desk", { channelId });
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
62
54
|
const dedupeKey = `${channelId}:${message.ts}`;
|
|
63
55
|
const now = Date.now();
|
|
64
56
|
const previousLogTime = this.recentlyLogged.get(dedupeKey);
|
|
@@ -68,7 +60,7 @@ export class ChannelStore {
|
|
|
68
60
|
}
|
|
69
61
|
this.recentlyLogged.delete(dedupeKey);
|
|
70
62
|
}
|
|
71
|
-
const logPath = join(
|
|
63
|
+
const logPath = join(archiveDir, "log.jsonl");
|
|
72
64
|
if (!message.date) {
|
|
73
65
|
message.date = formatLocalTime();
|
|
74
66
|
}
|
|
@@ -79,10 +71,14 @@ export class ChannelStore {
|
|
|
79
71
|
this.startCleanupTimer();
|
|
80
72
|
return true;
|
|
81
73
|
}
|
|
82
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Archive a settled run in the desk it ran in. Takes the desk directory rather than resolving the
|
|
76
|
+
* channel: a run that settles after its channel was rebound still belongs to its own desk.
|
|
77
|
+
*/
|
|
78
|
+
async logSubAgentRun(deskDir, run) {
|
|
83
79
|
if (this.closed)
|
|
84
80
|
return;
|
|
85
|
-
const logPath =
|
|
81
|
+
const logPath = getSubAgentRunsLogPath(deskDir);
|
|
86
82
|
if (!this.archiveAppender.tryAppend({ filePath: logPath, value: run })) {
|
|
87
83
|
throw new Error("Sub-agent archive queue is full. Retry after pending log writes drain.");
|
|
88
84
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The channel plane's transport contract (spec 061, D4): what the runtime asks of a transport.
|
|
3
|
+
* A transport does two things — hand normalized inbound messages to the runtime's `Ingress`, and
|
|
4
|
+
* render the runtime's structured output in its own protocol. Everything after authorization
|
|
5
|
+
* (binding, commands, busy handling, queueing) is the runtime's, never a transport's.
|
|
6
|
+
*/
|
|
7
|
+
import type { ConversationKind } from "../desk/types.js";
|
|
8
|
+
import type { ChannelContext } from "./channel-context.js";
|
|
9
|
+
import type { InboundImage } from "./channel-event.js";
|
|
10
|
+
import type { Ingress } from "./ingress.js";
|
|
11
|
+
export type TransportName = "dingtalk" | "webapi";
|
|
12
|
+
export interface TransportPolicy {
|
|
13
|
+
/** How a plain message is handled while its channel is busy. */
|
|
14
|
+
whenBusy: "steer" | "followUp" | "queue";
|
|
15
|
+
/** Whether the text `/stop`, `/steer` and `/followup` are accepted; a transport with its own control calls says false. */
|
|
16
|
+
textControlCommands: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** What one turn is about; the transport needs it to find the right conversation to answer into. */
|
|
19
|
+
export interface TurnInfo {
|
|
20
|
+
channelId: string;
|
|
21
|
+
user: string;
|
|
22
|
+
userName?: string;
|
|
23
|
+
text: string;
|
|
24
|
+
images?: InboundImage[];
|
|
25
|
+
/** The transport's correlation reference (`InboundMessage.ref`); a wake has none. */
|
|
26
|
+
ref?: string;
|
|
27
|
+
ts: string;
|
|
28
|
+
context?: import("./turn-context.js").TurnContext;
|
|
29
|
+
}
|
|
30
|
+
export interface PushMessage {
|
|
31
|
+
text: string;
|
|
32
|
+
/** Names the message where the transport shows a title (DingTalk's conversation list). */
|
|
33
|
+
title?: string;
|
|
34
|
+
/** The text is already markdown (a command reply); a transport that would otherwise guess honours it. */
|
|
35
|
+
markdown?: boolean;
|
|
36
|
+
/** Answering this inbound message: the `ref` it carried. */
|
|
37
|
+
ref?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A file the agent wants to push to a channel as a native attachment. Bytes travel in-band
|
|
41
|
+
* (`data`) so the sender is decoupled from where the file physically lives: the `send_media`
|
|
42
|
+
* tool reads it through its `Executor` (which may be remote) and hands over the bytes.
|
|
43
|
+
*/
|
|
44
|
+
export interface OutboundMedia {
|
|
45
|
+
data: Buffer;
|
|
46
|
+
/** Display name shown to the recipient (e.g. "report.pdf"). */
|
|
47
|
+
fileName: string;
|
|
48
|
+
/** `image` renders inline; `file` is a downloadable attachment. */
|
|
49
|
+
kind: "image" | "file";
|
|
50
|
+
}
|
|
51
|
+
/** The `send_media` tool's exit: the channel's transport sends the file. */
|
|
52
|
+
export type SendMedia = (channelId: string, media: OutboundMedia) => Promise<MediaSendResult>;
|
|
53
|
+
export interface MediaSendResult {
|
|
54
|
+
ok: boolean;
|
|
55
|
+
/** Why it failed, written for the agent: it says what to do instead. */
|
|
56
|
+
error?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface Transport {
|
|
59
|
+
readonly name: TransportName;
|
|
60
|
+
readonly policy: TransportPolicy;
|
|
61
|
+
/** Start receiving. `ingress` is the one place inbound messages go. */
|
|
62
|
+
start(ingress: Ingress): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Shutdown, first half: take no new messages (`ingress` is not called afterwards), but keep
|
|
65
|
+
* delivering — turns already running still finish through `openTurn`/`push` while the runtime
|
|
66
|
+
* waits for them.
|
|
67
|
+
*/
|
|
68
|
+
stopAccepting(): Promise<void>;
|
|
69
|
+
/** Shutdown, second half, once the turns are done: close every connection and release state. */
|
|
70
|
+
stop(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* One turn's output port. A `quiet` turn shows no progress; only its answer is delivered.
|
|
73
|
+
* Every human message the ingress accepted (`started` or `queued`) gets exactly one `openTurn`
|
|
74
|
+
* and one `finish`, whether it runs the agent or only answers a command — unless it is
|
|
75
|
+
* `dropped` first, or the process ends.
|
|
76
|
+
*/
|
|
77
|
+
openTurn(turn: TurnInfo, opts: {
|
|
78
|
+
quiet: boolean;
|
|
79
|
+
}): ChannelContext;
|
|
80
|
+
/** Outside any turn: command replies, receipts, task reports, wake-failure notices. Whether it was delivered. */
|
|
81
|
+
push(channelId: string, message: PushMessage): Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* Messages that were queued behind a running turn were dropped without ever running (`/stop`,
|
|
84
|
+
* `/new`); `refs` are the `ref`s they carried. A transport that tracks each message to an end
|
|
85
|
+
* (the Web API's responses) closes them here; one that does not simply omits this.
|
|
86
|
+
*/
|
|
87
|
+
dropped?(channelId: string, refs: string[]): void;
|
|
88
|
+
/**
|
|
89
|
+
* Whether the channel can receive files from `send_media`. Absent means it can; `false` keeps the
|
|
90
|
+
* tool (and its guidance) away from the model, rather than offering one that always fails.
|
|
91
|
+
*/
|
|
92
|
+
readonly sendsMedia?: boolean;
|
|
93
|
+
/** The `send_media` tool's exit. */
|
|
94
|
+
sendMedia(channelId: string, media: OutboundMedia): Promise<MediaSendResult>;
|
|
95
|
+
/** How a user sees this channel in `/desk`, `/tasks`, `/events` and CHANNELS.md. */
|
|
96
|
+
describe(channelId: string, knownName?: string): string;
|
|
97
|
+
/** The conversation kind (`conversations/<kind>-<n>/`) this transport gives the channel; `undefined` if it is not its address. */
|
|
98
|
+
conversationKindOf(channelId: string): ConversationKind | undefined;
|
|
99
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Structured input to one generation. History is context, never a sequence of new turns. */
|
|
2
|
+
export type ContextPart = {
|
|
3
|
+
type: "text";
|
|
4
|
+
text: string;
|
|
5
|
+
} | {
|
|
6
|
+
type: "image";
|
|
7
|
+
data: string;
|
|
8
|
+
mimeType: string;
|
|
9
|
+
};
|
|
10
|
+
export interface ContextMessage {
|
|
11
|
+
role: "user" | "assistant" | "system" | "developer";
|
|
12
|
+
content: ContextPart[];
|
|
13
|
+
phase?: "commentary" | "final_answer";
|
|
14
|
+
}
|
|
15
|
+
export interface TurnContext {
|
|
16
|
+
/**
|
|
17
|
+
* Imported before the generation, in place of a user prompt. Empty when the turn's own text and
|
|
18
|
+
* images are the input (a conversation's user message): it then runs as an ordinary channel turn.
|
|
19
|
+
*/
|
|
20
|
+
messages: ContextMessage[];
|
|
21
|
+
/** Applies only to this generation, including its tool iterations. */
|
|
22
|
+
instructions?: string;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* examples, plus the parsing and usage/help rendering built on top of them.
|
|
4
4
|
*
|
|
5
5
|
* It lives in its own domain, not in `src/agent/`, because the catalog describes commands handled
|
|
6
|
-
* in three different layers — the runtime (`/tasks`, `/events`, `/subagents`, `/
|
|
7
|
-
* `/skills`), the agent session (`/model`, `/compact`, `/new`) and memory (`/memory`) — and is read
|
|
6
|
+
* in three different layers — the runtime (`/tasks`, `/events`, `/subagents`, `/skills`), the agent session (`/model`, `/compact`, `/new`) and memory (`/memory`) — and is read
|
|
8
7
|
* by all of them plus the TUI. Only the catalog and the reply shape are shared: each *handler*
|
|
9
8
|
* still lives in the layer that owns the state it touches (`runtime/*-commands.ts`,
|
|
10
9
|
* `memory/commands.ts`, `agent/session/command-extension.ts`). This file has no imports at all, so nothing
|
|
@@ -13,7 +12,7 @@
|
|
|
13
12
|
* The user-facing copy conventions these commands follow are recorded in AGENTS.md; `reply-limits.ts`
|
|
14
13
|
* next to this file enforces rule 5 (the length budget).
|
|
15
14
|
*/
|
|
16
|
-
export type BuiltInCommandName = "help" | "steer" | "followup" | "stop" | "events" | "tasks" | "status" | "usage" | "context" | "subagents" | "
|
|
15
|
+
export type BuiltInCommandName = "help" | "steer" | "followup" | "stop" | "desk" | "events" | "tasks" | "status" | "usage" | "context" | "subagents" | "skills";
|
|
17
16
|
/** The five transport commands handled by `ChannelRunner.handleBuiltinCommand`. */
|
|
18
17
|
export type RunnerBuiltInCommandName = "help" | "stop" | "steer" | "followup" | "context";
|
|
19
18
|
/**
|
|
@@ -64,7 +63,7 @@ export interface CommandSpec {
|
|
|
64
63
|
/**
|
|
65
64
|
* True for the built-ins `ChannelRunner.handleBuiltinCommand` handles directly (help/stop/
|
|
66
65
|
* steer/followup/context); false for the stateless runtime reports (events/tasks/status/
|
|
67
|
-
* usage/subagents/
|
|
66
|
+
* usage/subagents/skills) dispatched through `runRuntimeCommand`. Meaningful only within
|
|
68
67
|
* `BUILT_IN_COMMANDS`.
|
|
69
68
|
*/
|
|
70
69
|
runnerHandled?: boolean;
|
|
@@ -87,8 +86,6 @@ export declare const SESSION_COMMANDS: readonly CommandSpec[];
|
|
|
87
86
|
/** Look up the shared description for a session command (used by the SDK extension). */
|
|
88
87
|
export declare function sessionCommandDescription(name: string): string;
|
|
89
88
|
export declare function isBuiltInCommandName(name: string): name is BuiltInCommandName;
|
|
90
|
-
/** True for a session-layer command name (`/model`, `/compact`, …) — needs the idle session layer. */
|
|
91
|
-
export declare function isSessionCommandName(name: string): boolean;
|
|
92
89
|
/** Narrow a parsed built-in to one `ChannelRunner.handleBuiltinCommand` accepts. */
|
|
93
90
|
export declare function isRunnerBuiltInCommand(command: BuiltInCommand): command is RunnerBuiltInCommand;
|
|
94
91
|
/**
|
|
@@ -99,7 +96,7 @@ export declare function isRunnerBuiltInCommand(command: BuiltInCommand): command
|
|
|
99
96
|
export declare function formatBusyHint(): string;
|
|
100
97
|
/**
|
|
101
98
|
* Renders a command's subcommand table as its `usage()` text — the single source `tasks/commands.ts`,
|
|
102
|
-
* `events/commands.ts`, `subagents/commands.ts`,
|
|
99
|
+
* `events/commands.ts`, `subagents/commands.ts`, and `memory/commands.ts` call
|
|
103
100
|
* on a parse error, replacing five hand-written `usage()` bodies (review 2026-08-24 §3.1).
|
|
104
101
|
*/
|
|
105
102
|
export declare function renderSubcommandUsage(name: string): string;
|
package/dist/commands/catalog.js
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* examples, plus the parsing and usage/help rendering built on top of them.
|
|
4
4
|
*
|
|
5
5
|
* It lives in its own domain, not in `src/agent/`, because the catalog describes commands handled
|
|
6
|
-
* in three different layers — the runtime (`/tasks`, `/events`, `/subagents`, `/
|
|
7
|
-
* `/skills`), the agent session (`/model`, `/compact`, `/new`) and memory (`/memory`) — and is read
|
|
6
|
+
* in three different layers — the runtime (`/tasks`, `/events`, `/subagents`, `/skills`), the agent session (`/model`, `/compact`, `/new`) and memory (`/memory`) — and is read
|
|
8
7
|
* by all of them plus the TUI. Only the catalog and the reply shape are shared: each *handler*
|
|
9
8
|
* still lives in the layer that owns the state it touches (`runtime/*-commands.ts`,
|
|
10
9
|
* `memory/commands.ts`, `agent/session/command-extension.ts`). This file has no imports at all, so nothing
|
|
@@ -27,7 +26,7 @@ export const BUILT_IN_COMMANDS = [
|
|
|
27
26
|
},
|
|
28
27
|
{
|
|
29
28
|
name: "stop",
|
|
30
|
-
description: "
|
|
29
|
+
description: "停止当前聊天回合并丢弃排在它后面的消息;后台任务不受影响,暂停任务用 /tasks pause",
|
|
31
30
|
examples: ["/stop"],
|
|
32
31
|
availableWhileBusy: true,
|
|
33
32
|
runnerHandled: true,
|
|
@@ -37,7 +36,7 @@ export const BUILT_IN_COMMANDS = [
|
|
|
37
36
|
argumentHint: "<消息>",
|
|
38
37
|
description: "在当前工具调用结束后调整正在运行的回合",
|
|
39
38
|
examples: ["/steer 改用上海时区,只汇总最新的更新"],
|
|
40
|
-
note: "回合进行中直接发送的普通消息默认按 `/steer` 处理。部署者可以在 channel.json
|
|
39
|
+
note: "回合进行中直接发送的普通消息默认按 `/steer` 处理。部署者可以在 channel.json 的 `dingtalk` 段把 `busyMessageDefault` 设为 `followUp`,改为排到当前回合之后执行;`responseMode` 控制答复的输出形态。",
|
|
41
40
|
availableWhileBusy: true,
|
|
42
41
|
runnerHandled: true,
|
|
43
42
|
},
|
|
@@ -49,6 +48,23 @@ export const BUILT_IN_COMMANDS = [
|
|
|
49
48
|
availableWhileBusy: true,
|
|
50
49
|
runnerHandled: true,
|
|
51
50
|
},
|
|
51
|
+
{
|
|
52
|
+
name: "desk",
|
|
53
|
+
argumentHint: "[list|new <名字>|bind <名字>]",
|
|
54
|
+
description: "进阶:创建工位,或把本频道切换到另一个工位",
|
|
55
|
+
// list/new answer mid-turn; bind refuses by itself while this channel is busy (spec 058, D5).
|
|
56
|
+
availableWhileBusy: true,
|
|
57
|
+
subcommands: [
|
|
58
|
+
{ name: "list", description: "列出所有工位和各自绑定的频道(默认动作,可省略)", example: "/desk" },
|
|
59
|
+
{ name: "new", args: "<名字>", description: "创建一个空工位,不绑定任何频道", example: "/desk new research" },
|
|
60
|
+
{
|
|
61
|
+
name: "bind",
|
|
62
|
+
args: "<名字>",
|
|
63
|
+
description: "把本频道绑定到这个工位,同时解除原来的绑定;回合进行中不能执行",
|
|
64
|
+
example: "/desk bind research",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
52
68
|
{
|
|
53
69
|
name: "events",
|
|
54
70
|
argumentHint: "<list|show|delete|history>",
|
|
@@ -73,15 +89,15 @@ export const BUILT_IN_COMMANDS = [
|
|
|
73
89
|
},
|
|
74
90
|
{
|
|
75
91
|
name: "tasks",
|
|
76
|
-
argumentHint: "[show <id>|log <id>|
|
|
77
|
-
description: "
|
|
92
|
+
argumentHint: "[show <id>|log <id>|msg <id> <内容>|pause <id>|resume <id> [+steps N|+usd X]|cancel <id>|archive|doctor]",
|
|
93
|
+
description: "查看、对话、暂停与取消本工位在后台执行的长程任务;任务与聊天互不占用",
|
|
78
94
|
availableWhileBusy: true,
|
|
79
95
|
subcommands: [
|
|
80
|
-
{ name: "list", description: "
|
|
96
|
+
{ name: "list", description: "列出本工位进行中的任务(默认动作,可省略)", example: "/tasks" },
|
|
81
97
|
{
|
|
82
98
|
name: "show",
|
|
83
99
|
args: "<id>",
|
|
84
|
-
description: "
|
|
100
|
+
description: "查看任务的当前活动、在途委派、工作项、最近记录与用量",
|
|
85
101
|
example: "/tasks show weekly-report",
|
|
86
102
|
},
|
|
87
103
|
{
|
|
@@ -91,43 +107,44 @@ export const BUILT_IN_COMMANDS = [
|
|
|
91
107
|
example: "/tasks log weekly-report",
|
|
92
108
|
},
|
|
93
109
|
{ name: "archive", description: "列出已归档(已关闭)的任务", example: "/tasks archive" },
|
|
110
|
+
{
|
|
111
|
+
name: "msg",
|
|
112
|
+
args: "<id> <内容>",
|
|
113
|
+
description: "对任务说话:步骤执行中直接送进当前步骤,否则排给下一步;也是回答任务提问的方式",
|
|
114
|
+
example: "/tasks msg weekly-report 先跑一遍 npm run check",
|
|
115
|
+
},
|
|
94
116
|
{
|
|
95
117
|
name: "pause",
|
|
96
118
|
args: "<id>",
|
|
97
|
-
description: "
|
|
119
|
+
description: "暂停任务:中止当前这一步,在途的委派和作业继续运行,结果会记下",
|
|
98
120
|
example: "/tasks pause weekly-report",
|
|
99
121
|
},
|
|
100
122
|
{
|
|
101
123
|
name: "resume",
|
|
102
124
|
args: "<id> [+steps N|+usd X]",
|
|
103
|
-
description: "
|
|
125
|
+
description: "恢复已暂停的任务,可同时追加预算",
|
|
104
126
|
example: "/tasks resume weekly-report +steps 20",
|
|
105
127
|
},
|
|
106
128
|
{
|
|
107
|
-
name: "
|
|
108
|
-
args: "<id>
|
|
109
|
-
description: "
|
|
110
|
-
example: "/tasks
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
name: "reply",
|
|
114
|
-
args: "<id> <内容>",
|
|
115
|
-
description: "回答该任务提出的问题,并让它继续",
|
|
116
|
-
example: "/tasks reply weekly-report 合并到 master",
|
|
129
|
+
name: "cancel",
|
|
130
|
+
args: "<id>",
|
|
131
|
+
description: "取消任务:中止当前步骤,取消在途的委派和作业,并归档",
|
|
132
|
+
example: "/tasks cancel weekly-report",
|
|
117
133
|
},
|
|
134
|
+
{ name: "archive", description: "列出已归档(已关闭)的任务", example: "/tasks archive" },
|
|
118
135
|
{ name: "doctor", description: "只读检查手工编辑造成的任务问题", example: "/tasks doctor" },
|
|
119
136
|
],
|
|
120
137
|
},
|
|
121
138
|
{
|
|
122
139
|
name: "status",
|
|
123
|
-
description: "
|
|
140
|
+
description: "显示运行状态、当前模型、上下文占用、运行时长、版本与本工位后台任务概况",
|
|
124
141
|
examples: ["/status"],
|
|
125
142
|
availableWhileBusy: true,
|
|
126
143
|
},
|
|
127
144
|
{
|
|
128
145
|
name: "usage",
|
|
129
146
|
argumentHint: "[7d|month]",
|
|
130
|
-
description: "
|
|
147
|
+
description: "显示本工位与全局的模型花费和 token,按类型与模型分解",
|
|
131
148
|
examples: ["/usage", "/usage 7d", "/usage month"],
|
|
132
149
|
availableWhileBusy: true,
|
|
133
150
|
},
|
|
@@ -181,31 +198,13 @@ export const BUILT_IN_COMMANDS = [
|
|
|
181
198
|
},
|
|
182
199
|
],
|
|
183
200
|
},
|
|
184
|
-
{
|
|
185
|
-
name: "project",
|
|
186
|
-
argumentHint: "[set <absolute-path>|reset]",
|
|
187
|
-
description: "查看或切换本频道的项目目录(读写文件与执行命令的工作目录);set/reset 需频道空闲",
|
|
188
|
-
// The read form answers like /status; set/reset validate idleness themselves and reply
|
|
189
|
-
// with a plain error instead of blocking the built-in-command dispatch path.
|
|
190
|
-
availableWhileBusy: true,
|
|
191
|
-
subcommands: [
|
|
192
|
-
{ name: "show", description: "查看当前频道的项目目录与访问边界(默认动作,可省略)", example: "/project" },
|
|
193
|
-
{
|
|
194
|
-
name: "set",
|
|
195
|
-
args: "<absolute-path>",
|
|
196
|
-
description: "切换项目目录(需频道空闲,且目录在允许的根目录内)",
|
|
197
|
-
example: "/project set /home/me/projects/foo",
|
|
198
|
-
},
|
|
199
|
-
{ name: "reset", description: "切回默认项目目录", example: "/project reset" },
|
|
200
|
-
],
|
|
201
|
-
},
|
|
202
201
|
{
|
|
203
202
|
name: "skills",
|
|
204
203
|
argumentHint: "[list|show <name>]",
|
|
205
|
-
description: "
|
|
204
|
+
description: "列出工作区与用户共享技能(含来源及加载提醒),或查看单个技能",
|
|
206
205
|
availableWhileBusy: true,
|
|
207
206
|
subcommands: [
|
|
208
|
-
{ name: "list", description: "
|
|
207
|
+
{ name: "list", description: "列出技能及来源(默认动作,可省略)", example: "/skills" },
|
|
209
208
|
{
|
|
210
209
|
name: "show",
|
|
211
210
|
args: "<name>",
|
|
@@ -224,7 +223,7 @@ export const SESSION_COMMANDS = [
|
|
|
224
223
|
{
|
|
225
224
|
name: "memory",
|
|
226
225
|
argumentHint: "[status|list [type]|show <name>|forget <name>|journal [date]]",
|
|
227
|
-
description: "
|
|
226
|
+
description: "查看本工位的记忆、观察期条目与后台整理状态;不经过模型的记忆管理入口",
|
|
228
227
|
subcommands: [
|
|
229
228
|
{
|
|
230
229
|
name: "status",
|
|
@@ -280,6 +279,11 @@ export const SESSION_COMMANDS = [
|
|
|
280
279
|
examples: ["/new"],
|
|
281
280
|
availableWhileBusy: true,
|
|
282
281
|
},
|
|
282
|
+
{
|
|
283
|
+
name: "reload",
|
|
284
|
+
description: "重新加载当前会话的技能、工具及其他资源,保留对话历史",
|
|
285
|
+
examples: ["/reload"],
|
|
286
|
+
},
|
|
283
287
|
{
|
|
284
288
|
name: "compact",
|
|
285
289
|
argumentHint: "[压缩要求]",
|
|
@@ -301,11 +305,6 @@ export function sessionCommandDescription(name) {
|
|
|
301
305
|
export function isBuiltInCommandName(name) {
|
|
302
306
|
return BUILT_IN_NAMES.has(name);
|
|
303
307
|
}
|
|
304
|
-
const SESSION_COMMAND_NAMES = new Set(SESSION_COMMANDS.map((command) => command.name));
|
|
305
|
-
/** True for a session-layer command name (`/model`, `/compact`, …) — needs the idle session layer. */
|
|
306
|
-
export function isSessionCommandName(name) {
|
|
307
|
-
return SESSION_COMMAND_NAMES.has(name);
|
|
308
|
-
}
|
|
309
308
|
const RUNNER_BUILT_IN_NAMES = new Set(BUILT_IN_COMMANDS.filter((command) => command.runnerHandled).map((command) => command.name));
|
|
310
309
|
/** Narrow a parsed built-in to one `ChannelRunner.handleBuiltinCommand` accepts. */
|
|
311
310
|
export function isRunnerBuiltInCommand(command) {
|
|
@@ -326,7 +325,7 @@ export function formatBusyHint() {
|
|
|
326
325
|
}
|
|
327
326
|
/**
|
|
328
327
|
* Renders a command's subcommand table as its `usage()` text — the single source `tasks/commands.ts`,
|
|
329
|
-
* `events/commands.ts`, `subagents/commands.ts`,
|
|
328
|
+
* `events/commands.ts`, `subagents/commands.ts`, and `memory/commands.ts` call
|
|
330
329
|
* on a parse error, replacing five hand-written `usage()` bodies (review 2026-08-24 §3.1).
|
|
331
330
|
*/
|
|
332
331
|
export function renderSubcommandUsage(name) {
|