@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,34 @@
|
|
|
1
|
+
/** On-demand catalog reads, shared by the skill tool and /skills. */
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { checkPathGuard } from "../security/path-guard-check.js";
|
|
4
|
+
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
5
|
+
import { errorMessage } from "../shared/text-utils.js";
|
|
6
|
+
import { loadPipiclawSkills } from "./loader.js";
|
|
7
|
+
import { skillSecurity } from "./roots.js";
|
|
8
|
+
export async function loadSkillFile(options, name, inspectRejected = false) {
|
|
9
|
+
const catalog = loadPipiclawSkills(options);
|
|
10
|
+
const skill = catalog.skills.find((item) => item.name === name);
|
|
11
|
+
const rejected = inspectRejected
|
|
12
|
+
? catalog.diagnostics.find((item) => item.rejected && item.name === name && item.path)
|
|
13
|
+
: undefined;
|
|
14
|
+
const path = skill?.filePath ?? rejected?.path;
|
|
15
|
+
if (!path) {
|
|
16
|
+
throw new RecoverableToolError(`Skill "${name}" does not exist or could not be loaded. Use action "list" to inspect skills and diagnostics.`);
|
|
17
|
+
}
|
|
18
|
+
const { securityConfig, securityContext } = skillSecurity(options);
|
|
19
|
+
const target = await checkPathGuard(path, "read", securityConfig, securityContext, {
|
|
20
|
+
tool: "skill",
|
|
21
|
+
channelId: options.channelId,
|
|
22
|
+
});
|
|
23
|
+
let content;
|
|
24
|
+
try {
|
|
25
|
+
content = await readFile(target, "utf-8");
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new RecoverableToolError(`Skill "${name}" could not be read: ${errorMessage(error)}. Use action "list" to refresh the catalog before retrying.`);
|
|
29
|
+
}
|
|
30
|
+
return { name, path: target, source: (skill ?? rejected).source, content, loaded: !!skill };
|
|
31
|
+
}
|
|
32
|
+
export function skillSourceLabel(source) {
|
|
33
|
+
return source === "workspace" ? "工作区" : "用户共享";
|
|
34
|
+
}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* shape: pure-ish functions returning markdown, no bot/event coupling.
|
|
5
|
-
*
|
|
6
|
-
* Deliberately a disk scan via `listWorkspaceSkills`, not the live `ChannelRunner`'s already-
|
|
7
|
-
* loaded catalog: that keeps `/skills` usable while a turn is streaming and for a channel with no
|
|
8
|
-
* active runner, and — the whole reason this exists rather than reusing `/help`'s discovery tail
|
|
9
|
-
* — it is the only place that shows a skill that failed the content scan and was silently dropped
|
|
10
|
-
* from the prompt's skill list (`src/skills/loader.ts`).
|
|
11
|
-
*/
|
|
12
|
-
export interface HandleSkillsCommandOptions {
|
|
1
|
+
import type { SkillOptions } from "./types.js";
|
|
2
|
+
/** Stateless disk inspection remains usable without an active session. */
|
|
3
|
+
export interface HandleSkillsCommandOptions extends Pick<SkillOptions, "sharedSkillsDir"> {
|
|
13
4
|
args: string;
|
|
14
5
|
workspaceDir: string;
|
|
15
6
|
appHomeDir: string;
|
package/dist/skills/commands.js
CHANGED
|
@@ -4,7 +4,8 @@ import { GuardBlockedError, renderGuardBlockForUser } from "../security/block-me
|
|
|
4
4
|
import { loadSecurityConfigWithDiagnostics } from "../security/config.js";
|
|
5
5
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
6
6
|
import { errorMessage } from "../shared/text-utils.js";
|
|
7
|
-
import {
|
|
7
|
+
import { loadSkillFile, skillSourceLabel } from "./catalog.js";
|
|
8
|
+
import { loadPipiclawSkills } from "./loader.js";
|
|
8
9
|
function usage() {
|
|
9
10
|
return renderSubcommandUsage("skills");
|
|
10
11
|
}
|
|
@@ -21,36 +22,45 @@ export function parseSkillsCommand(args) {
|
|
|
21
22
|
}
|
|
22
23
|
throw new Error(`未知子命令 \`${parts[0]}\`。`);
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
function diagnosticForUser(diagnostic, skills) {
|
|
26
|
+
const label = diagnostic.name ? `\`${diagnostic.name}\`` : "技能目录";
|
|
27
|
+
const source = skillSourceLabel(diagnostic.source);
|
|
28
|
+
if (diagnostic.type === "collision") {
|
|
29
|
+
return `- ${label}(${source}):同名版本已被覆盖;使用${skillSourceLabel(skills.find((skill) => skill.name === diagnostic.name).source)}版本。`;
|
|
29
30
|
}
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const active = skills.find((skill) => skill.name === diagnostic.name);
|
|
32
|
+
const status = diagnostic.rejected
|
|
33
|
+
? `该版本未加载${active ? `;当前使用${skillSourceLabel(active.source)}版本` : ""}`
|
|
34
|
+
: "格式提醒,仍可使用";
|
|
35
|
+
return `- ${label}(${source}):${status}。请检查${diagnostic.path ? ` \`${diagnostic.path}\`` : "目录权限或文件内容"},修改后发送 \`/reload\`。`;
|
|
36
|
+
}
|
|
37
|
+
function listSkills(options) {
|
|
38
|
+
const { skills, diagnostics } = loadPipiclawSkills(options);
|
|
39
|
+
if (skills.length === 0 && diagnostics.length === 0) {
|
|
40
|
+
return ("暂无技能。\n" +
|
|
41
|
+
`让我帮你创建,或放到 \`${options.workspaceDir}/skills/<name>/SKILL.md\`;也支持 \`~/.agents/skills/\`。`);
|
|
35
42
|
}
|
|
36
|
-
|
|
37
|
-
|
|
43
|
+
const lines = [`**技能**(${skills.length} 个)· 用 \`/skill:<名称>\` 调用`, ""];
|
|
44
|
+
for (const skill of skills) {
|
|
45
|
+
lines.push(`- \`${skill.name}\`(${skillSourceLabel(skill.source)}${skill.disableModelInvocation ? ",仅显式调用" : ""})— ${skill.description.replace(/\s+/g, " ")}`);
|
|
38
46
|
}
|
|
39
|
-
if (
|
|
40
|
-
lines.push("", "
|
|
41
|
-
lines.push(...rejected.map((skill) => `- \`${skill.name}\` — ${skill.warning}`));
|
|
47
|
+
if (diagnostics.length > 0) {
|
|
48
|
+
lines.push("", "加载提醒", "", ...diagnostics.map((item) => diagnosticForUser(item, skills)));
|
|
42
49
|
}
|
|
43
|
-
return capReply(lines.join("\n"), {
|
|
50
|
+
return capReply(lines.join("\n"), {
|
|
51
|
+
nextStepHint: "用 `/skills show <name>` 查看单个技能;外部修改后发送 `/reload` 更新当前会话",
|
|
52
|
+
}).text;
|
|
44
53
|
}
|
|
45
54
|
async function showSkill(options, name) {
|
|
46
55
|
try {
|
|
47
56
|
const securityConfig = loadSecurityConfigWithDiagnostics(options.appHomeDir).config;
|
|
48
|
-
const file = await
|
|
57
|
+
const file = await loadSkillFile({
|
|
49
58
|
workspaceDir: options.workspaceDir,
|
|
59
|
+
sharedSkillsDir: options.sharedSkillsDir,
|
|
50
60
|
securityConfig,
|
|
51
61
|
channelId: options.channelId,
|
|
52
|
-
}, name);
|
|
53
|
-
const body = `**Skill \`${file.name}\`**\n\n路径:\`${file.path}\`\n\n${flattenMarkdownForChat(file.content)}`;
|
|
62
|
+
}, name, true);
|
|
63
|
+
const body = `**Skill \`${file.name}\`**\n\n来源:${skillSourceLabel(file.source)}${file.loaded ? "" : "(未加载,仅供排错)"}\n\n路径:\`${file.path}\`\n\n${flattenMarkdownForChat(file.content)}`;
|
|
54
64
|
return capReply(body, { nextStepHint: `完整内容在 \`${file.path}\`` }).text;
|
|
55
65
|
}
|
|
56
66
|
catch (error) {
|
|
@@ -59,7 +69,7 @@ async function showSkill(options, name) {
|
|
|
59
69
|
return `未找到 skill \`${name}\`。用 \`/skills\` 查看可用的 skill。`;
|
|
60
70
|
if (error instanceof GuardBlockedError)
|
|
61
71
|
return renderGuardBlockForUser(error.blocked);
|
|
62
|
-
return `无法读取 skill \`${name}
|
|
72
|
+
return `无法读取 skill \`${name}\`。请检查文件权限和内容后重试。`;
|
|
63
73
|
}
|
|
64
74
|
}
|
|
65
75
|
export async function handleSkillsCommand(options) {
|
|
@@ -72,7 +82,11 @@ export async function handleSkillsCommand(options) {
|
|
|
72
82
|
}
|
|
73
83
|
switch (command.action) {
|
|
74
84
|
case "list":
|
|
75
|
-
return listSkills(
|
|
85
|
+
return listSkills({
|
|
86
|
+
workspaceDir: options.workspaceDir,
|
|
87
|
+
sharedSkillsDir: options.sharedSkillsDir,
|
|
88
|
+
securityConfig: loadSecurityConfigWithDiagnostics(options.appHomeDir).config,
|
|
89
|
+
});
|
|
76
90
|
case "show":
|
|
77
91
|
return showSkill(options, command.name);
|
|
78
92
|
}
|
package/dist/skills/loader.d.ts
CHANGED
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* SOUL.md and AGENTS.md are loaded by the prompt pipeline itself
|
|
5
|
-
* (`agent/prompt/resources.ts`), which owns their budgets and framing.
|
|
6
|
-
*/
|
|
7
|
-
import { type ResourceDiagnostic, type Skill } from "@earendil-works/pi-coding-agent";
|
|
8
|
-
export interface PipiclawSkillsResult {
|
|
9
|
-
skills: Skill[];
|
|
10
|
-
diagnostics: ResourceDiagnostic[];
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Load skills from the workspace-level skill directory.
|
|
14
|
-
*
|
|
15
|
-
* Diagnostics (an unreadable SKILL.md, bad frontmatter, a duplicate name, content that failed the
|
|
16
|
-
* scan above) were previously dropped on the floor, so a broken workspace skill silently vanished
|
|
17
|
-
* from the prompt. They are returned now and surfaced by the runner.
|
|
18
|
-
*/
|
|
19
|
-
export declare function loadPipiclawSkills(channelDir: string): PipiclawSkillsResult;
|
|
20
|
-
/**
|
|
21
|
-
* Merge pi's auto-discovered skills with the workspace ones. Workspace wins on a
|
|
22
|
-
* name collision (it is the layer the user actually edits), and the collision is
|
|
23
|
-
* reported rather than resolved in silence.
|
|
24
|
-
*/
|
|
25
|
-
export declare function resolvePipiclawSkills(base: {
|
|
26
|
-
skills: Skill[];
|
|
27
|
-
diagnostics: ResourceDiagnostic[];
|
|
28
|
-
}, workspace: PipiclawSkillsResult): {
|
|
29
|
-
skills: Skill[];
|
|
30
|
-
diagnostics: ResourceDiagnostic[];
|
|
31
|
-
};
|
|
1
|
+
import type { PipiclawSkillsResult, SkillOptions } from "./types.js";
|
|
2
|
+
export declare function loadPipiclawSkills(options: SkillOptions): PipiclawSkillsResult;
|
package/dist/skills/loader.js
CHANGED
|
@@ -1,77 +1,110 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* SOUL.md and AGENTS.md are loaded by the prompt pipeline itself
|
|
5
|
-
* (`agent/prompt/resources.ts`), which owns their budgets and framing.
|
|
6
|
-
*/
|
|
7
|
-
import { readFileSync } from "node:fs";
|
|
1
|
+
/** The sole skill discovery and name-resolution policy for Pipiclaw (spec 063). */
|
|
2
|
+
import { readdirSync, readFileSync, realpathSync } from "node:fs";
|
|
3
|
+
import { basename, dirname } from "node:path";
|
|
8
4
|
import { loadSkillsFromDir } from "@earendil-works/pi-coding-agent";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
import { guardPath } from "../security/path-guard.js";
|
|
6
|
+
import { isNodeError } from "../shared/os.js";
|
|
7
|
+
import { errorMessage } from "../shared/text-utils.js";
|
|
8
|
+
import { getSkillRoots, skillSecurity } from "./roots.js";
|
|
9
|
+
/** SDK diagnostics may lack a name when parsing failed. Keep an actionable file identifier. */
|
|
10
|
+
function diagnosticName(path) {
|
|
11
|
+
return basename(path) === "SKILL.md" ? basename(dirname(path)) : basename(path, ".md");
|
|
12
|
+
}
|
|
13
|
+
export function loadPipiclawSkills(options) {
|
|
14
|
+
const { securityConfig, securityContext } = skillSecurity(options);
|
|
15
|
+
const guardContext = {
|
|
16
|
+
...securityContext,
|
|
17
|
+
config: { ...securityConfig.pathGuard, enabled: securityConfig.enabled && securityConfig.pathGuard.enabled },
|
|
18
|
+
};
|
|
19
|
+
const skills = new Map();
|
|
20
|
+
const fileIdentities = new Map();
|
|
23
21
|
const diagnostics = [];
|
|
24
|
-
for (const
|
|
25
|
-
|
|
22
|
+
for (const { dir, source } of getSkillRoots(options.workspaceDir, options.sharedSkillsDir)) {
|
|
23
|
+
// The SDK swallows directory enumeration errors. Surface a failed source instead of
|
|
24
|
+
// silently making it look empty. Missing optional roots are normal.
|
|
26
25
|
try {
|
|
27
|
-
|
|
26
|
+
readdirSync(dir);
|
|
28
27
|
}
|
|
29
|
-
catch {
|
|
30
|
-
|
|
28
|
+
catch (error) {
|
|
29
|
+
if ((!isNodeError(error) || error.code !== "ENOENT") && guardPath(dir, "read", guardContext).allowed) {
|
|
30
|
+
diagnostics.push({
|
|
31
|
+
type: "warning",
|
|
32
|
+
source,
|
|
33
|
+
path: dir,
|
|
34
|
+
rejected: true,
|
|
35
|
+
message: `Skill directory could not be read: ${errorMessage(error)}. Check its permissions and reload.`,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
31
38
|
continue;
|
|
32
39
|
}
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
const loaded = loadSkillsFromDir({ dir, source });
|
|
41
|
+
const candidates = new Map(loaded.skills.map((skill) => [skill.filePath, skill]));
|
|
42
|
+
for (const diagnostic of loaded.diagnostics) {
|
|
43
|
+
if (diagnostic.path && !guardPath(diagnostic.path, "read", guardContext).allowed)
|
|
44
|
+
continue;
|
|
45
|
+
const candidate = diagnostic.path ? candidates.get(diagnostic.path) : undefined;
|
|
46
|
+
diagnostics.push({
|
|
47
|
+
...diagnostic,
|
|
48
|
+
source,
|
|
49
|
+
name: candidate?.name ?? (diagnostic.path ? diagnosticName(diagnostic.path) : undefined),
|
|
50
|
+
rejected: !candidate,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// Workspace roots come first; within one root, prefer the first usable path in a
|
|
54
|
+
// stable lexical order. Filtering precedes merging, so a broken override can fall back.
|
|
55
|
+
for (const skill of loaded.skills.sort((a, b) => a.filePath < b.filePath ? -1 : a.filePath > b.filePath ? 1 : 0)) {
|
|
56
|
+
const guarded = guardPath(skill.filePath, "read", guardContext);
|
|
57
|
+
if (!guarded.allowed || !guarded.resolvedPath)
|
|
58
|
+
continue;
|
|
59
|
+
let fileIdentity;
|
|
60
|
+
try {
|
|
61
|
+
// Verify the guarded target is readable; body wording does not gate loading.
|
|
62
|
+
readFileSync(guarded.resolvedPath, "utf-8");
|
|
63
|
+
fileIdentity = realpathSync(guarded.resolvedPath);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
diagnostics.push({
|
|
67
|
+
type: "warning",
|
|
68
|
+
source,
|
|
69
|
+
name: skill.name,
|
|
70
|
+
path: skill.filePath,
|
|
71
|
+
rejected: true,
|
|
72
|
+
message: `Skill could not be read: ${errorMessage(error)}. Check the file and reload.`,
|
|
73
|
+
});
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const winner = skills.get(skill.name);
|
|
77
|
+
if (winner) {
|
|
78
|
+
if (fileIdentities.get(skill.name) !== fileIdentity) {
|
|
79
|
+
diagnostics.push({
|
|
80
|
+
type: "collision",
|
|
81
|
+
source,
|
|
82
|
+
name: skill.name,
|
|
83
|
+
path: skill.filePath,
|
|
84
|
+
message: `Skill "${skill.name}" is shadowed by ${winner.filePath}. Edit the winning file or choose another name.`,
|
|
85
|
+
collision: {
|
|
86
|
+
resourceType: "skill",
|
|
87
|
+
name: skill.name,
|
|
88
|
+
winnerPath: winner.filePath,
|
|
89
|
+
loserPath: skill.filePath,
|
|
90
|
+
winnerSource: winner.source,
|
|
91
|
+
loserSource: source,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
skills.set(skill.name, {
|
|
98
|
+
...skill,
|
|
99
|
+
source,
|
|
100
|
+
filePath: guarded.resolvedPath,
|
|
101
|
+
baseDir: dirname(guarded.resolvedPath),
|
|
102
|
+
});
|
|
103
|
+
fileIdentities.set(skill.name, fileIdentity);
|
|
37
104
|
}
|
|
38
|
-
diagnostics.push({
|
|
39
|
-
type: "warning",
|
|
40
|
-
message: `Skill "${skill.name}" was not loaded: ${scan.error}.`,
|
|
41
|
-
path: skill.filePath,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
return { skills: kept, diagnostics };
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Load skills from the workspace-level skill directory.
|
|
48
|
-
*
|
|
49
|
-
* Diagnostics (an unreadable SKILL.md, bad frontmatter, a duplicate name, content that failed the
|
|
50
|
-
* scan above) were previously dropped on the floor, so a broken workspace skill silently vanished
|
|
51
|
-
* from the prompt. They are returned now and surfaced by the runner.
|
|
52
|
-
*/
|
|
53
|
-
export function loadPipiclawSkills(channelDir) {
|
|
54
|
-
const workspaceSkillsDir = join(channelDir, "..", "skills");
|
|
55
|
-
const loaded = loadSkillsFromDir({ dir: workspaceSkillsDir, source: "workspace" });
|
|
56
|
-
const scanned = filterScannedSkills(loaded.skills);
|
|
57
|
-
return { skills: scanned.skills, diagnostics: [...loaded.diagnostics, ...scanned.diagnostics] };
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Merge pi's auto-discovered skills with the workspace ones. Workspace wins on a
|
|
61
|
-
* name collision (it is the layer the user actually edits), and the collision is
|
|
62
|
-
* reported rather than resolved in silence.
|
|
63
|
-
*/
|
|
64
|
-
export function resolvePipiclawSkills(base, workspace) {
|
|
65
|
-
const workspaceNames = new Set(workspace.skills.map((skill) => skill.name));
|
|
66
|
-
const collisions = base.skills.filter((skill) => workspaceNames.has(skill.name));
|
|
67
|
-
const diagnostics = [...base.diagnostics, ...workspace.diagnostics];
|
|
68
|
-
for (const skill of collisions) {
|
|
69
|
-
diagnostics.push({
|
|
70
|
-
type: "collision",
|
|
71
|
-
message: `Skill "${skill.name}" is shadowed by the workspace skill of the same name.`,
|
|
72
|
-
path: skill.filePath,
|
|
73
|
-
});
|
|
74
105
|
}
|
|
75
|
-
|
|
76
|
-
|
|
106
|
+
return {
|
|
107
|
+
skills: [...skills.values()].sort((a, b) => a.name.localeCompare(b.name)),
|
|
108
|
+
diagnostics: diagnostics.sort((a, b) => a.source === b.source ? (a.path ?? "").localeCompare(b.path ?? "") : a.source === "workspace" ? -1 : 1),
|
|
109
|
+
};
|
|
77
110
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SkillOptions } from "./types.js";
|
|
2
|
+
export declare function getSkillRoots(workspaceDir: string, sharedSkillsDir?: string): ({
|
|
3
|
+
dir: string;
|
|
4
|
+
source: "workspace";
|
|
5
|
+
} | {
|
|
6
|
+
dir: string;
|
|
7
|
+
source: "user";
|
|
8
|
+
})[];
|
|
9
|
+
export declare function skillSecurity(options: SkillOptions): {
|
|
10
|
+
securityConfig: import("../security/types.js").SecurityConfig;
|
|
11
|
+
securityContext: import("../security/types.js").SecurityRuntimeContext;
|
|
12
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
4
|
+
export function getSkillRoots(workspaceDir, sharedSkillsDir = join(homedir(), ".agents", "skills")) {
|
|
5
|
+
return [
|
|
6
|
+
{ dir: resolve(workspaceDir, "skills"), source: "workspace" },
|
|
7
|
+
{ dir: resolve(sharedSkillsDir), source: "user" },
|
|
8
|
+
];
|
|
9
|
+
}
|
|
10
|
+
export function skillSecurity(options) {
|
|
11
|
+
return {
|
|
12
|
+
securityConfig: options.securityConfig ?? DEFAULT_SECURITY_CONFIG,
|
|
13
|
+
securityContext: options.securityContext ?? {
|
|
14
|
+
agentWorkspaceDir: options.workspaceDir,
|
|
15
|
+
cwd: options.workspaceDir,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ResourceDiagnostic, Skill } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
|
|
3
|
+
export type SkillSource = "workspace" | "user";
|
|
4
|
+
export interface SkillOptions {
|
|
5
|
+
workspaceDir: string;
|
|
6
|
+
/** Internal override for isolated callers/tests, not a user setting. */
|
|
7
|
+
sharedSkillsDir?: string;
|
|
8
|
+
securityConfig?: SecurityConfig;
|
|
9
|
+
securityContext?: SecurityRuntimeContext;
|
|
10
|
+
channelId?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PipiclawSkill extends Skill {
|
|
13
|
+
source: SkillSource;
|
|
14
|
+
}
|
|
15
|
+
export interface SkillDiagnostic extends ResourceDiagnostic {
|
|
16
|
+
source: SkillSource;
|
|
17
|
+
name?: string;
|
|
18
|
+
/** A load failure, distinct from an SDK warning on a usable skill. */
|
|
19
|
+
rejected?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface PipiclawSkillsResult {
|
|
22
|
+
skills: PipiclawSkill[];
|
|
23
|
+
diagnostics: SkillDiagnostic[];
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WakeEvent } from "../channel/channel-event.js";
|
|
2
2
|
import type { RunRecord } from "./run-record.js";
|
|
3
3
|
/** Chars of the reply text carried inline in the completion wake. P2-1: `output.md` bodies are
|
|
4
4
|
* routinely 3-10KB — a 2,000-char tail truncated most of them and regularly cost the reader an
|
|
@@ -8,10 +8,19 @@ export declare const WAKE_OUTPUT_TAIL_CHARS = 6000;
|
|
|
8
8
|
* The completion wake for a settled run: who finished, how, the (untrusted) output tail, and where
|
|
9
9
|
* the full output lives. Pure: the manager supplies the sibling count it alone can compute.
|
|
10
10
|
*/
|
|
11
|
+
/**
|
|
12
|
+
* Running runs that share this wake's question, "was this the last one?": the other runs of its
|
|
13
|
+
* task, or — for a chat-level run — the other chat-level runs of the same channel. The desk's other
|
|
14
|
+
* channels get their own wakes, so counting them would leave this channel waiting for nothing.
|
|
15
|
+
*/
|
|
16
|
+
export declare function countWakeSiblings(record: RunRecord, runs: Iterable<RunRecord>): number;
|
|
11
17
|
export declare function buildRunCompletionWake(input: {
|
|
18
|
+
/** The run's desk: stamped on the event so admission can drop it once the channel moves (D7). */
|
|
19
|
+
desk: string;
|
|
20
|
+
dispatchId: string;
|
|
12
21
|
record: RunRecord;
|
|
13
22
|
outputText: string;
|
|
14
23
|
outputSaved: boolean;
|
|
15
24
|
/** Other runs of the same task (or, for a chat-level run, the same channel) still running. */
|
|
16
25
|
siblingCount: number;
|
|
17
|
-
}):
|
|
26
|
+
}): WakeEvent;
|
|
@@ -11,8 +11,24 @@ export const WAKE_OUTPUT_TAIL_CHARS = 6_000;
|
|
|
11
11
|
* The completion wake for a settled run: who finished, how, the (untrusted) output tail, and where
|
|
12
12
|
* the full output lives. Pure: the manager supplies the sibling count it alone can compute.
|
|
13
13
|
*/
|
|
14
|
+
/**
|
|
15
|
+
* Running runs that share this wake's question, "was this the last one?": the other runs of its
|
|
16
|
+
* task, or — for a chat-level run — the other chat-level runs of the same channel. The desk's other
|
|
17
|
+
* channels get their own wakes, so counting them would leave this channel waiting for nothing.
|
|
18
|
+
*/
|
|
19
|
+
export function countWakeSiblings(record, runs) {
|
|
20
|
+
let count = 0;
|
|
21
|
+
for (const other of runs) {
|
|
22
|
+
if (other.runId === record.runId || other.status !== "running" || other.taskId !== record.taskId)
|
|
23
|
+
continue;
|
|
24
|
+
if (record.taskId === undefined && other.channelId !== record.channelId)
|
|
25
|
+
continue;
|
|
26
|
+
count++;
|
|
27
|
+
}
|
|
28
|
+
return count;
|
|
29
|
+
}
|
|
14
30
|
export function buildRunCompletionWake(input) {
|
|
15
|
-
const { record, outputText, outputSaved, siblingCount } = input;
|
|
31
|
+
const { desk, dispatchId, record, outputText, outputSaved, siblingCount } = input;
|
|
16
32
|
const tail = outputText.slice(-WAKE_OUTPUT_TAIL_CHARS).trim();
|
|
17
33
|
// P2-1: say so when the tail cut real content, instead of leaving the reader to guess and
|
|
18
34
|
// spend a `read` round trip finding out output.md has more.
|
|
@@ -27,8 +43,6 @@ export function buildRunCompletionWake(input) {
|
|
|
27
43
|
// K parallel fan-out runs otherwise produce K wake turns, each re-asking "is this the only
|
|
28
44
|
// one?" via a fresh subagent_list call — this answers it inline (review 2026-08-23
|
|
29
45
|
// §3.3), so the model can reliably reply [SILENT] to every wake but the last.
|
|
30
|
-
// A chat-level run's siblings are the other chat-level runs on this channel: the same "was this
|
|
31
|
-
// the last one?" question, without a task to scope it.
|
|
32
46
|
const siblingNote = siblingCount > 0
|
|
33
47
|
? ` ${siblingCount} other run(s) ${record.taskId ? "for this task" : "on this channel"} are still running.`
|
|
34
48
|
: "";
|
|
@@ -37,10 +51,9 @@ export function buildRunCompletionWake(input) {
|
|
|
37
51
|
? `\nVerdict: ${record.verificationVerdict === "pass" ? "PASS" : "FAIL"}`
|
|
38
52
|
: "";
|
|
39
53
|
return {
|
|
40
|
-
|
|
54
|
+
source: "wake",
|
|
41
55
|
channelId: record.channelId,
|
|
42
|
-
|
|
43
|
-
userName: "SUBAGENT",
|
|
56
|
+
producer: "SUBAGENT",
|
|
44
57
|
text: `[SUBAGENT:${record.runId}] Delegation "${record.label}" -> ${record.agent} (${harnessLabel}) finished: ` +
|
|
45
58
|
`${record.status} (${record.durationEstimated ? "≈" : ""}${formatDuration(record.durationMs ?? 0)}).${belongsTo}${verdictLine}\n` +
|
|
46
59
|
// The agent's own output is untrusted data, not an instruction — a fence plus an
|
|
@@ -58,19 +71,9 @@ export function buildRunCompletionWake(input) {
|
|
|
58
71
|
workspaceLine +
|
|
59
72
|
"Continue whatever was waiting on this delegation. If it needs no follow-up, respond with exactly [SILENT].",
|
|
60
73
|
ts: String(Date.now()),
|
|
61
|
-
|
|
62
|
-
|
|
74
|
+
dispatchId,
|
|
75
|
+
desk,
|
|
63
76
|
// The result is awaited; the wake itself still runs without a progress card.
|
|
64
77
|
presentation: "awaited",
|
|
65
|
-
...(record.taskId
|
|
66
|
-
? {
|
|
67
|
-
internalWake: {
|
|
68
|
-
kind: "subagent",
|
|
69
|
-
resourceId: record.runId,
|
|
70
|
-
taskId: record.taskId,
|
|
71
|
-
dispatchId: `subagent:${record.channelId}:${record.runId}:done`,
|
|
72
|
-
},
|
|
73
|
-
}
|
|
74
|
-
: {}),
|
|
75
78
|
};
|
|
76
79
|
}
|
|
@@ -5,7 +5,7 @@ declare const ALLOWED_CONTEXT_MODES: readonly ["isolated", "contextual"];
|
|
|
5
5
|
declare const ALLOWED_MEMORY_MODES: readonly ["none", "index"];
|
|
6
6
|
declare const ALLOWED_THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
7
7
|
declare const ALLOWED_RUNTIMES: readonly ["internal", "external"];
|
|
8
|
-
declare const ALLOWED_HARNESSES: readonly ["claude-code", "codex-cli", "exec"];
|
|
8
|
+
declare const ALLOWED_HARNESSES: readonly ["claude-code", "codex-cli", "cursor-cli", "exec"];
|
|
9
9
|
declare const ALLOWED_WORKLOADS: readonly ["light", "heavy"];
|
|
10
10
|
declare const ALLOWED_MUTATES: readonly ["read", "write"];
|
|
11
11
|
export type { SubAgentToolName };
|
|
@@ -9,6 +9,7 @@ import { SUB_AGENTS_DIR_NAME } from "../paths.js";
|
|
|
9
9
|
import { splitShellWords } from "../shared/shell-words.js";
|
|
10
10
|
import { errorMessage } from "../shared/text-utils.js";
|
|
11
11
|
import { SUBAGENT_TOOL_NAMES } from "../tools/contract/names.js";
|
|
12
|
+
import { externalRoleWarning } from "./external/role-warnings.js";
|
|
12
13
|
/** Re-exported from the leaf source of truth so validation and the tool set never drift. */
|
|
13
14
|
const ALLOWED_SUB_AGENT_TOOLS = SUBAGENT_TOOL_NAMES;
|
|
14
15
|
const DEFAULT_SUB_AGENT_TOOLS = ["read", "bash"];
|
|
@@ -25,7 +26,7 @@ const ALLOWED_MEMORY_MODES = ["none", "index"];
|
|
|
25
26
|
// "max" is a real SDK ThinkingLevel; pipiclaw's own whitelist previously omitted it (spec 040, D4).
|
|
26
27
|
const ALLOWED_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
27
28
|
const ALLOWED_RUNTIMES = ["internal", "external"];
|
|
28
|
-
const ALLOWED_HARNESSES = ["claude-code", "codex-cli", "exec"];
|
|
29
|
+
const ALLOWED_HARNESSES = ["claude-code", "codex-cli", "cursor-cli", "exec"];
|
|
29
30
|
const ALLOWED_WORKLOADS = ["light", "heavy"];
|
|
30
31
|
const ALLOWED_MUTATES = ["read", "write"];
|
|
31
32
|
/**
|
|
@@ -468,9 +469,6 @@ function parseExternalAgent(entryName, filePath, frontmatter, body, name, descri
|
|
|
468
469
|
const memoryMode = parseMemoryMode(frontmatter.memory, "none");
|
|
469
470
|
if (memoryMode.error)
|
|
470
471
|
return { warning: `${entryName}: ${memoryMode.error}` };
|
|
471
|
-
const memoryDisclosureWarning = memoryMode.value !== "none"
|
|
472
|
-
? `${entryName}: memory: ${memoryMode.value} sends the channel memory index / journal content to this external process`
|
|
473
|
-
: undefined;
|
|
474
472
|
const maxWallTimeSec = parsePositiveInteger(frontmatter.maxWallTimeSec, DEFAULT_EXTERNAL_MAX_WALL_TIME_SEC);
|
|
475
473
|
// An empty body is a legitimate declaration for an external role, not a defect: a capability
|
|
476
474
|
// entry ("this agent, this model, this reasoning level") deliberately carries no standing
|
|
@@ -488,18 +486,14 @@ function parseExternalAgent(entryName, filePath, frontmatter, body, name, descri
|
|
|
488
486
|
? `executable "${executable}" was not found on PATH; install it or fix "command" in ${filePath}`
|
|
489
487
|
: undefined;
|
|
490
488
|
const externalModelRef = readOptionalTrimmedString(frontmatter.model);
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
: undefined;
|
|
500
|
-
// All non-fatal (the role still loads); joined rather than picking one so an unlucky
|
|
501
|
-
// combination never silently loses one of them.
|
|
502
|
-
const combinedWarning = [memoryDisclosureWarning, modelPlaceholderWarning].filter(Boolean).join("; ") || undefined;
|
|
489
|
+
const combinedWarning = externalRoleWarning({
|
|
490
|
+
entryName,
|
|
491
|
+
harness: harness.value,
|
|
492
|
+
command,
|
|
493
|
+
mutates: mutates.value,
|
|
494
|
+
memory: memoryMode.value ?? "none",
|
|
495
|
+
modelConfigured: Boolean(externalModelRef),
|
|
496
|
+
});
|
|
503
497
|
return {
|
|
504
498
|
warning: combinedWarning,
|
|
505
499
|
agent: {
|
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import type { Api, Model } from "@earendil-works/pi-ai";
|
|
2
2
|
import type { ResolvedSubAgentConfig } from "./discovery.js";
|
|
3
3
|
import type { DelegationParams, DelegationResult, SubAgentToolFields, SubAgentToolOptions } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* D6.2's boundary check, hardened against symlinks (review 2026-08-23 §2.3): a plain
|
|
6
|
-
* `resolve()` + string-prefix comparison only judges the *requested* path, so `<projectRoot
|
|
7
|
-
* >/link -> /somewhere/else` passes the check and then everything downstream — the internal
|
|
8
|
-
* agent's own `securityContext.projectRoot`, an external process's `cwd` (which bypasses the
|
|
9
|
-
* path guard entirely) — trusts that escaped target. Comparing realpaths closes it, matching
|
|
10
|
-
* `project-scope.ts` and `workspaceLeaseKey`, the two other places in the tree that already do
|
|
11
|
-
* this.
|
|
12
|
-
*/
|
|
13
|
-
export declare function assertWithinProjectBoundary(target: string, base: string, requested: string): void;
|
|
14
4
|
/**
|
|
15
5
|
* A run's lifecycle is deliberately unlinked from the tool call's `AbortSignal` (spec 040, D2):
|
|
16
6
|
* `/stop` ends the current turn but no longer kills an in-flight delegation, matching background
|