@oyasmi/pipiclaw 0.9.3 → 0.9.4-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/builtin-commands.d.ts +19 -0
- package/dist/agent/builtin-commands.js +80 -0
- package/dist/agent/channel-runner.d.ts +20 -208
- package/dist/agent/channel-runner.js +167 -1188
- package/dist/agent/maintenance-context.d.ts +1 -1
- package/dist/agent/maintenance-context.js +1 -1
- package/dist/agent/prompt/manifest.d.ts +6 -1
- package/dist/agent/prompt/manifest.js +45 -64
- package/dist/agent/prompt/resources.d.ts +3 -0
- package/dist/agent/prompt/resources.js +11 -2
- package/dist/agent/runner-factory.d.ts +1 -43
- package/dist/agent/{command-extension.d.ts → session/command-extension.d.ts} +4 -0
- package/dist/agent/{command-extension.js → session/command-extension.js} +48 -35
- package/dist/agent/{type-guards.d.ts → session/event-guards.d.ts} +2 -2
- package/dist/agent/{type-guards.js → session/event-guards.js} +5 -1
- package/dist/agent/session/model-selection.d.ts +47 -0
- package/dist/agent/session/model-selection.js +99 -0
- package/dist/agent/{session-adapter.d.ts → session/session-adapter.d.ts} +21 -1
- package/dist/agent/session/session-adapter.js +159 -0
- package/dist/agent/{session-events.d.ts → session/session-events.d.ts} +9 -5
- package/dist/agent/{session-events.js → session/session-events.js} +24 -13
- package/dist/agent/session/session-host.d.ts +200 -0
- package/dist/agent/session/session-host.js +621 -0
- package/dist/agent/{session-resource-gate.js → session/session-resource-gate.js} +5 -3
- package/dist/agent/status-render.d.ts +0 -1
- package/dist/agent/status-render.js +4 -16
- package/dist/agent/{context-budget.js → turn/context-budget.js} +5 -1
- package/dist/agent/{progress-formatter.d.ts → turn/progress-formatter.d.ts} +4 -1
- package/dist/agent/{run-queue.d.ts → turn/run-queue.d.ts} +1 -1
- package/dist/agent/{run-queue.js → turn/run-queue.js} +10 -5
- package/dist/{memory → agent/turn}/task-digest.js +4 -4
- package/dist/agent/turn/turn-context.d.ts +14 -0
- package/dist/agent/turn/turn-context.js +64 -0
- package/dist/agent/turn/turn-error.d.ts +31 -0
- package/dist/agent/turn/turn-error.js +68 -0
- package/dist/agent/turn/turn-finish.d.ts +50 -0
- package/dist/agent/turn/turn-finish.js +188 -0
- package/dist/agent/turn/turn-input.d.ts +43 -0
- package/dist/agent/turn/turn-input.js +79 -0
- package/dist/agent/turn/turn-pipeline.d.ts +68 -0
- package/dist/agent/turn/turn-pipeline.js +257 -0
- package/dist/agent/{turn-prompt.d.ts → turn/turn-prompt.d.ts} +2 -2
- package/dist/agent/{turn-prompt.js → turn/turn-prompt.js} +6 -2
- package/dist/agent/{turn-recovery.js → turn/turn-recovery.js} +1 -1
- package/dist/agent/{turn-state.d.ts → turn/turn-state.d.ts} +1 -1
- package/dist/agent/types.d.ts +43 -2
- package/dist/agent/types.js +1 -1
- package/dist/{models/auth-cli.d.ts → app/auth-command.d.ts} +1 -1
- package/dist/{models/auth-cli.js → app/auth-command.js} +14 -10
- package/dist/{runtime/app-home.d.ts → app/home.d.ts} +6 -2
- package/dist/{runtime/app-home.js → app/home.js} +22 -75
- package/dist/{runtime → app}/proxy.js +4 -2
- package/dist/{app-services.d.ts → app/services.d.ts} +5 -5
- package/dist/{app-services.js → app/services.js} +17 -14
- package/dist/channel/channel-context.d.ts +12 -2
- package/dist/channel/channel-context.js +29 -2
- package/dist/channel/channel-event.d.ts +10 -2
- package/dist/channel/channel-event.js +1 -1
- package/dist/channel/channel-index.js +4 -1
- package/dist/{runtime/project-commands.d.ts → channel/commands.d.ts} +1 -1
- package/dist/{runtime/project-commands.js → channel/commands.js} +17 -16
- package/dist/channel/project-scope-store.js +1 -1
- package/dist/channel/store.js +4 -0
- package/dist/commands/catalog.d.ts +24 -7
- package/dist/commands/catalog.js +91 -44
- package/dist/commands/reply-limits.d.ts +6 -0
- package/dist/commands/reply-limits.js +24 -0
- package/dist/{runtime/report-commands.d.ts → commands/router.d.ts} +10 -3
- package/dist/{runtime/report-commands.js → commands/router.js} +6 -6
- package/dist/{settings.d.ts → config/settings.d.ts} +10 -10
- package/dist/{settings.js → config/settings.js} +11 -11
- package/dist/{tools/config.d.ts → config/tools.d.ts} +1 -2
- package/dist/{tools/config.js → config/tools.js} +5 -2
- package/dist/dingtalk/access-token.d.ts +12 -0
- package/dist/dingtalk/access-token.js +51 -0
- package/dist/dingtalk/api.d.ts +19 -0
- package/dist/dingtalk/api.js +67 -0
- package/dist/dingtalk/bot.d.ts +97 -0
- package/dist/dingtalk/bot.js +389 -0
- package/dist/dingtalk/cards.d.ts +56 -0
- package/dist/dingtalk/cards.js +318 -0
- package/dist/{runtime → dingtalk}/channel-queue.js +4 -1
- package/dist/dingtalk/config.d.ts +19 -0
- package/dist/dingtalk/config.js +95 -0
- package/dist/dingtalk/connection.d.ts +57 -0
- package/dist/dingtalk/connection.js +356 -0
- package/dist/dingtalk/conversation-meta.d.ts +16 -0
- package/dist/dingtalk/conversation-meta.js +77 -0
- package/dist/{runtime → dingtalk}/delivery.d.ts +6 -2
- package/dist/{runtime → dingtalk}/delivery.js +29 -15
- package/dist/dingtalk/handler.d.ts +90 -0
- package/dist/dingtalk/handler.js +1 -0
- package/dist/dingtalk/inbound.d.ts +66 -0
- package/dist/dingtalk/inbound.js +137 -0
- package/dist/dingtalk/media.d.ts +66 -0
- package/dist/dingtalk/media.js +214 -0
- package/dist/events/{event-commands.js → commands.js} +99 -45
- package/dist/events/parse.d.ts +14 -0
- package/dist/events/parse.js +114 -0
- package/dist/events/types.d.ts +93 -0
- package/dist/events/types.js +1 -0
- package/dist/events/{event-validation.d.ts → validation.d.ts} +14 -3
- package/dist/events/{event-validation.js → validation.js} +17 -9
- package/dist/events/watcher.d.ts +67 -0
- package/dist/events/{events.js → watcher.js} +63 -121
- package/dist/executor.js +2 -2
- package/dist/index.d.ts +6 -4
- package/dist/index.js +2 -2
- package/dist/jobs/launch.d.ts +42 -0
- package/dist/jobs/launch.js +118 -0
- package/dist/{agent/job-manager.d.ts → jobs/manager.d.ts} +1 -67
- package/dist/{agent/job-manager.js → jobs/manager.js} +34 -157
- package/dist/jobs/record.d.ts +55 -0
- package/dist/jobs/record.js +36 -0
- package/dist/log.d.ts +12 -2
- package/dist/log.js +26 -34
- package/dist/main.js +3 -3
- package/dist/memory/commands.js +29 -23
- package/dist/memory/lifecycle.js +26 -5
- package/dist/memory/maintenance-gates.d.ts +2 -2
- package/dist/memory/maintenance-state.js +4 -1
- package/dist/memory/maintenance-tuning.d.ts +15 -0
- package/dist/memory/maintenance-tuning.js +3 -0
- package/dist/memory/reflect-job.d.ts +2 -2
- package/dist/memory/reflect-job.js +4 -2
- package/dist/memory/scheduler.d.ts +3 -3
- package/dist/memory/scheduler.js +5 -2
- package/dist/memory/sidecar-worker.js +1 -1
- package/dist/memory/transcript.js +1 -1
- package/dist/{agent/model-fallback.d.ts → models/fallback.d.ts} +6 -6
- package/dist/{agent/model-fallback.js → models/fallback.js} +15 -28
- package/dist/models/login-identity.d.ts +2 -0
- package/dist/models/login-identity.js +83 -0
- package/dist/models/provider-login.d.ts +3 -1
- package/dist/models/provider-login.js +8 -2
- package/dist/models/reference.d.ts +20 -0
- package/dist/models/{utils.js → reference.js} +0 -48
- package/dist/models/{utils.d.ts → runtime.d.ts} +1 -16
- package/dist/models/runtime.js +52 -0
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +9 -0
- package/dist/playbooks/agent-delegation.md +2 -2
- package/dist/playbooks/catalog.d.ts +6 -2
- package/dist/playbooks/catalog.js +9 -6
- package/dist/runtime/bootstrap.d.ts +7 -17
- package/dist/runtime/bootstrap.js +70 -659
- package/dist/runtime/durable-dispatch.d.ts +43 -4
- package/dist/runtime/durable-dispatch.js +153 -3
- package/dist/runtime/inbound-images.d.ts +18 -0
- package/dist/runtime/inbound-images.js +51 -0
- package/dist/runtime/shutdown.d.ts +39 -0
- package/dist/runtime/shutdown.js +120 -0
- package/dist/runtime/stop-watchdog.d.ts +16 -0
- package/dist/runtime/stop-watchdog.js +32 -0
- package/dist/runtime/task-driver.d.ts +6 -4
- package/dist/runtime/task-driver.js +58 -23
- package/dist/runtime/task-migration.js +25 -8
- package/dist/runtime/task-spawn.d.ts +1 -1
- package/dist/runtime/task-spawn.js +13 -6
- package/dist/runtime/turn-handler.d.ts +47 -0
- package/dist/runtime/turn-handler.js +318 -0
- package/dist/runtime/turn-run.d.ts +52 -0
- package/dist/runtime/turn-run.js +318 -0
- package/dist/runtime/wake-coalescing.d.ts +18 -0
- package/dist/runtime/wake-coalescing.js +29 -0
- package/dist/security/block-message.d.ts +22 -1
- package/dist/security/block-message.js +66 -1
- package/dist/security/command-guard.js +4 -0
- package/dist/security/network.d.ts +2 -1
- package/dist/security/network.js +7 -2
- package/dist/security/path-guard-check.js +2 -2
- package/dist/security/path-guard.js +4 -0
- package/dist/security/types.d.ts +1 -2
- package/dist/security/types.js +1 -2
- package/dist/shared/exact-keys.d.ts +1 -1
- package/dist/shared/format.d.ts +12 -0
- package/dist/shared/format.js +37 -0
- package/dist/shared/host-process.js +16 -4
- package/dist/shared/wake-claim.d.ts +1 -1
- package/dist/shared/with-timeout.d.ts +3 -2
- package/dist/shared/with-timeout.js +14 -3
- package/dist/{runtime/skill-commands.d.ts → skills/commands.d.ts} +2 -2
- package/dist/{runtime/skill-commands.js → skills/commands.js} +18 -11
- package/dist/{agent/workspace-resources.js → skills/loader.js} +1 -1
- package/dist/{tools/skill-security.js → skills/validation.js} +4 -0
- package/dist/skills/workspace.d.ts +33 -0
- package/dist/skills/workspace.js +116 -0
- package/dist/{runtime/subagent-commands.d.ts → subagents/commands.d.ts} +9 -7
- package/dist/{runtime/subagent-commands.js → subagents/commands.js} +116 -77
- package/dist/subagents/completion-wake.d.ts +17 -0
- package/dist/subagents/completion-wake.js +76 -0
- package/dist/subagents/detached-discovery.js +1 -1
- package/dist/subagents/discovery.d.ts +1 -1
- package/dist/subagents/discovery.js +2 -2
- package/dist/subagents/dispatch.d.ts +33 -0
- package/dist/subagents/dispatch.js +190 -0
- package/dist/subagents/external/claude-code.js +23 -1
- package/dist/subagents/external/dispatch.d.ts +25 -0
- package/dist/subagents/external/dispatch.js +90 -0
- package/dist/subagents/external/harness.d.ts +1 -1
- package/dist/subagents/external/progress-tail.d.ts +18 -1
- package/dist/subagents/external/progress-tail.js +64 -17
- package/dist/subagents/external/run.d.ts +5 -1
- package/dist/subagents/external/run.js +23 -9
- package/dist/subagents/external/settlement.d.ts +4 -1
- package/dist/subagents/external/settlement.js +1 -1
- package/dist/subagents/format.d.ts +1 -1
- package/dist/subagents/grace.d.ts +24 -0
- package/dist/subagents/grace.js +57 -0
- package/dist/subagents/internal/outcome.d.ts +24 -0
- package/dist/subagents/internal/outcome.js +149 -0
- package/dist/subagents/internal/provider-retry.d.ts +19 -0
- package/dist/subagents/internal/provider-retry.js +83 -0
- package/dist/subagents/internal/run.d.ts +31 -0
- package/dist/subagents/internal/run.js +240 -0
- package/dist/subagents/internal/state.d.ts +43 -0
- package/dist/subagents/internal/state.js +48 -0
- package/dist/subagents/internal/worker.d.ts +51 -0
- package/dist/subagents/internal/worker.js +167 -0
- package/dist/subagents/result.d.ts +62 -0
- package/dist/subagents/result.js +103 -0
- package/dist/subagents/run-record.d.ts +222 -0
- package/dist/subagents/run-record.js +101 -0
- package/dist/subagents/run-registry.d.ts +9 -0
- package/dist/subagents/run-registry.js +125 -0
- package/dist/subagents/runs.d.ts +16 -232
- package/dist/subagents/runs.js +132 -310
- package/dist/subagents/task-envelope.d.ts +36 -0
- package/dist/subagents/task-envelope.js +168 -0
- package/dist/subagents/types.d.ts +154 -0
- package/dist/subagents/types.js +1 -0
- package/dist/subagents/verification-outcome.d.ts +1 -1
- package/dist/subagents/workspace-summary.d.ts +16 -4
- package/dist/subagents/workspace-summary.js +74 -18
- package/dist/tasks/board.d.ts +10 -3
- package/dist/tasks/board.js +38 -3
- package/dist/tasks/{work-log.d.ts → bound-work.d.ts} +1 -1
- package/dist/tasks/{work-log.js → bound-work.js} +1 -1
- package/dist/tasks/brief.js +1 -1
- package/dist/{runtime/task-commands.d.ts → tasks/commands.d.ts} +1 -1
- package/dist/{runtime/task-commands.js → tasks/commands.js} +117 -67
- package/dist/tasks/contract-input.d.ts +1 -1
- package/dist/tasks/contract-input.js +1 -1
- package/dist/tasks/create.js +1 -1
- package/dist/tasks/frontmatter.d.ts +5 -0
- package/dist/tasks/frontmatter.js +8 -0
- package/dist/tasks/{log.d.ts → loop-log.d.ts} +11 -1
- package/dist/tasks/{log.js → loop-log.js} +59 -3
- package/dist/tasks/mutation-lock.js +1 -1
- package/dist/tasks/session-path.js +1 -1
- package/dist/tasks/steer.js +1 -1
- package/dist/tasks/store.js +6 -4
- package/dist/tasks/ticket.d.ts +3 -1
- package/dist/tasks/ticket.js +19 -1
- package/dist/tools/bash.d.ts +1 -1
- package/dist/tools/bash.js +2 -2
- package/dist/tools/{tool-details.d.ts → contract/details.d.ts} +11 -3
- package/dist/tools/{tool-details.js → contract/details.js} +42 -5
- package/dist/tools/{presentation.js → contract/presentation.js} +3 -3
- package/dist/tools/event-manage.d.ts +1 -1
- package/dist/tools/event-manage.js +4 -4
- package/dist/tools/index.d.ts +5 -3
- package/dist/tools/index.js +8 -6
- package/dist/tools/job.d.ts +1 -1
- package/dist/tools/memory-manage.js +4 -1
- package/dist/tools/registry.d.ts +7 -7
- package/dist/tools/registry.js +6 -6
- package/dist/tools/session-search.d.ts +1 -1
- package/dist/tools/skill.d.ts +2 -34
- package/dist/tools/skill.js +8 -116
- package/dist/tools/subagent-manage.d.ts +1 -1
- package/dist/tools/subagent-manage.js +19 -13
- package/dist/tools/subagent.d.ts +46 -0
- package/dist/tools/subagent.js +127 -0
- package/dist/tools/{task-manage.d.ts → task-manage/factory.d.ts} +7 -3
- package/dist/tools/{task-manage.js → task-manage/factory.js} +7 -7
- package/dist/tools/task-manage/lifecycle.js +2 -2
- package/dist/tools/task-manage/log-view.js +2 -2
- package/dist/tools/task-manage/shared.js +3 -3
- package/dist/tools/task-manage/step-end.js +7 -4
- package/dist/tools/task-manage/types.d.ts +1 -1
- package/dist/tools/web-fetch.d.ts +1 -1
- package/dist/tools/web-search.d.ts +1 -1
- package/dist/tui/app.d.ts +1 -1
- package/dist/tui/app.js +6 -6
- package/dist/tui/cli.d.ts +1 -1
- package/dist/tui/cli.js +3 -3
- package/dist/tui/commands.js +4 -4
- package/dist/tui/frontend.d.ts +44 -0
- package/dist/tui/frontend.js +13 -0
- package/dist/tui/pitui-frontend.d.ts +1 -1
- package/dist/tui/pitui-frontend.js +1 -1
- package/dist/tui/plain-frontend.d.ts +1 -1
- package/dist/tui/renderer.d.ts +3 -42
- package/dist/tui/renderer.js +3 -2
- package/dist/tui/terminal-context.d.ts +2 -2
- package/dist/tui/terminal-media-sender.d.ts +1 -1
- package/dist/tui/turn-controller.d.ts +3 -1
- package/dist/tui/turn-controller.js +36 -21
- package/dist/usage/ledger.js +7 -1
- package/dist/usage/render.js +3 -1
- package/dist/{shared/types.d.ts → usage/totals.d.ts} +3 -0
- package/dist/web/client.d.ts +5 -1
- package/dist/web/client.js +4 -0
- package/dist/web/config.d.ts +1 -1
- package/dist/web/fetch.d.ts +1 -1
- package/dist/web/search-providers.d.ts +1 -1
- package/dist/web/search.d.ts +1 -1
- package/package.json +9 -7
- package/dist/agent/session-adapter.js +0 -77
- package/dist/events/events.d.ts +0 -159
- package/dist/runtime/dingtalk.d.ts +0 -272
- package/dist/runtime/dingtalk.js +0 -1416
- package/dist/subagents/tool.d.ts +0 -206
- package/dist/subagents/tool.js +0 -1088
- /package/dist/{runtime → agent/prompt}/workspace-templates.d.ts +0 -0
- /package/dist/{runtime → agent/prompt}/workspace-templates.js +0 -0
- /package/dist/agent/{session-resource-gate.d.ts → session/session-resource-gate.d.ts} +0 -0
- /package/dist/agent/{context-budget.d.ts → turn/context-budget.d.ts} +0 -0
- /package/dist/agent/{progress-formatter.js → turn/progress-formatter.js} +0 -0
- /package/dist/{memory → agent/turn}/task-digest.d.ts +0 -0
- /package/dist/agent/{turn-recovery.d.ts → turn/turn-recovery.d.ts} +0 -0
- /package/dist/agent/{turn-state.js → turn/turn-state.js} +0 -0
- /package/dist/{runtime → app}/proxy.d.ts +0 -0
- /package/dist/{runtime → dingtalk}/channel-queue.d.ts +0 -0
- /package/dist/{runtime → dingtalk}/inbound-media.d.ts +0 -0
- /package/dist/{runtime → dingtalk}/inbound-media.js +0 -0
- /package/dist/events/{event-commands.d.ts → commands.d.ts} +0 -0
- /package/dist/{agent/workspace-resources.d.ts → skills/loader.d.ts} +0 -0
- /package/dist/{tools/skill-security.d.ts → skills/validation.d.ts} +0 -0
- /package/dist/tasks/{ledger.d.ts → contract.d.ts} +0 -0
- /package/dist/tasks/{ledger.js → contract.js} +0 -0
- /package/dist/tools/{subagent-tool-names.d.ts → contract/names.d.ts} +0 -0
- /package/dist/tools/{subagent-tool-names.js → contract/names.js} +0 -0
- /package/dist/tools/{presentation.d.ts → contract/presentation.d.ts} +0 -0
- /package/dist/{shared/types.js → usage/totals.js} +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `subagent` and `subagent_inline` tools (spec 046 D2.1): parameter schemas, validation that
|
|
3
|
+
* the model can recover from, and the two tool factories. Resolution of the role or inline spec
|
|
4
|
+
* happens here; dispatch and execution live in `subagents/dispatch.ts`.
|
|
5
|
+
*/
|
|
6
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
7
|
+
import { Type } from "typebox";
|
|
8
|
+
import type { SubAgentToolFields, SubAgentToolOptions } from "../subagents/types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Role-based delegation (spec 046, D2.1): the common path. No override fields beyond routing
|
|
11
|
+
* ones — tools, model, effort, context, thinkingLevel and mutates all live in the role file, so
|
|
12
|
+
* a call naming an external role cannot pass any of them (there is nowhere for it to put them).
|
|
13
|
+
*/
|
|
14
|
+
declare const subagentSchema: Type.TObject<{
|
|
15
|
+
agent: Type.TString;
|
|
16
|
+
task: Type.TString;
|
|
17
|
+
workingDirectory: Type.TOptional<Type.TString>;
|
|
18
|
+
purpose: Type.TOptional<Type.TUnion<[Type.TLiteral<"work">, Type.TLiteral<"verify">]>>;
|
|
19
|
+
taskId: Type.TOptional<Type.TString>;
|
|
20
|
+
item: Type.TOptional<Type.TString>;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Inline delegation (spec 046, D2.1): a one-off executor for when no configured role fits.
|
|
24
|
+
* Carries every field a role file would otherwise supply.
|
|
25
|
+
*/
|
|
26
|
+
declare const subagentInlineSchema: Type.TObject<{
|
|
27
|
+
task: Type.TString;
|
|
28
|
+
systemPrompt: Type.TString;
|
|
29
|
+
tools: Type.TOptional<Type.TArray<Type.TString>>;
|
|
30
|
+
model: Type.TOptional<Type.TString>;
|
|
31
|
+
effort: Type.TOptional<Type.TUnion<[Type.TLiteral<"quick">, Type.TLiteral<"standard">, Type.TLiteral<"deep">]>>;
|
|
32
|
+
context: Type.TOptional<Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"index">]>>;
|
|
33
|
+
thinkingLevel: Type.TOptional<Type.TUnion<[Type.TLiteral<"off">, Type.TLiteral<"minimal">, Type.TLiteral<"low">, Type.TLiteral<"medium">, Type.TLiteral<"high">, Type.TLiteral<"xhigh">, Type.TLiteral<"max">]>>;
|
|
34
|
+
mutates: Type.TOptional<Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"write">]>>;
|
|
35
|
+
workingDirectory: Type.TOptional<Type.TString>;
|
|
36
|
+
purpose: Type.TOptional<Type.TUnion<[Type.TLiteral<"work">, Type.TLiteral<"verify">]>>;
|
|
37
|
+
taskId: Type.TOptional<Type.TString>;
|
|
38
|
+
item: Type.TOptional<Type.TString>;
|
|
39
|
+
}>;
|
|
40
|
+
/** The shape consumers read post-wrap, once `withToolDetails` has stamped `kind`. */
|
|
41
|
+
export type SubAgentToolDetails = SubAgentToolFields & {
|
|
42
|
+
kind: "subagent" | "subagent_inline";
|
|
43
|
+
};
|
|
44
|
+
export declare function createSubAgentTool(options: SubAgentToolOptions): AgentTool<typeof subagentSchema, SubAgentToolFields>;
|
|
45
|
+
export declare function createSubAgentInlineTool(options: SubAgentToolOptions): AgentTool<typeof subagentInlineSchema, SubAgentToolFields>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
3
|
+
import { formatSubAgentList, resolveConfiguredRole, resolveInlineAgent, validateSubAgentTask, } from "../subagents/discovery.js";
|
|
4
|
+
import { dispatchSubAgentRun } from "../subagents/dispatch.js";
|
|
5
|
+
/** Shared by both invocation surfaces (spec 046, D2.1). */
|
|
6
|
+
const workingDirectoryField = Type.Optional(Type.String({
|
|
7
|
+
description: "Optional existing directory to run the sub-agent in (its shell cwd and relative-path root). Use it to work on another checkout — e.g. a `git worktree add`ed one. Defaults to this runtime's own working directory.",
|
|
8
|
+
}));
|
|
9
|
+
const purposeField = Type.Optional(Type.Union([Type.Literal("work"), Type.Literal("verify")], {
|
|
10
|
+
description: 'Use "verify" for an independent check: the sub-agent is given the checker protocol and ends with VERDICT: PASS|FAIL. The verdict is information for you to weigh, not a gate.',
|
|
11
|
+
}));
|
|
12
|
+
const taskIdField = Type.Optional(Type.String({
|
|
13
|
+
description: "Persistent task this work belongs to. Inside a task session it is bound automatically — omit it. In chat, pass it to have the result recorded on that task's board.",
|
|
14
|
+
}));
|
|
15
|
+
const itemField = Type.Optional(Type.String({
|
|
16
|
+
description: 'The task\'s Work Item this delegation is for, e.g. "W2". Requires a task (bound automatically in a task session).',
|
|
17
|
+
}));
|
|
18
|
+
/**
|
|
19
|
+
* Role-based delegation (spec 046, D2.1): the common path. No override fields beyond routing
|
|
20
|
+
* ones — tools, model, effort, context, thinkingLevel and mutates all live in the role file, so
|
|
21
|
+
* a call naming an external role cannot pass any of them (there is nowhere for it to put them).
|
|
22
|
+
*/
|
|
23
|
+
const subagentSchema = Type.Object({
|
|
24
|
+
agent: Type.String({ description: "Name of a configured sub-agent from workspaceDir/sub-agents/" }),
|
|
25
|
+
task: Type.String({ description: "Complete task description for the sub-agent" }),
|
|
26
|
+
workingDirectory: workingDirectoryField,
|
|
27
|
+
purpose: purposeField,
|
|
28
|
+
taskId: taskIdField,
|
|
29
|
+
item: itemField,
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Inline delegation (spec 046, D2.1): a one-off executor for when no configured role fits.
|
|
33
|
+
* Carries every field a role file would otherwise supply.
|
|
34
|
+
*/
|
|
35
|
+
const subagentInlineSchema = Type.Object({
|
|
36
|
+
task: Type.String({ description: "Complete task description for the sub-agent" }),
|
|
37
|
+
systemPrompt: Type.String({ description: "System prompt defining this one-off sub-agent's identity and task." }),
|
|
38
|
+
tools: Type.Optional(Type.Array(Type.String(), { description: "Optional tool whitelist for the sub-agent" })),
|
|
39
|
+
model: Type.Optional(Type.String({ description: "Optional exact model reference. Defaults to the parent's current model." })),
|
|
40
|
+
effort: Type.Optional(Type.Union([Type.Literal("quick"), Type.Literal("standard"), Type.Literal("deep")], {
|
|
41
|
+
description: 'Execution budget preset (turns, tool calls, wall time). "standard" is the default; "quick" for narrow lookups, "deep" for long analyses.',
|
|
42
|
+
})),
|
|
43
|
+
context: Type.Optional(Type.Union([Type.Literal("none"), Type.Literal("index")], {
|
|
44
|
+
description: 'What context to inject. "none" (default) runs fully isolated; "index" adds the workspace background, the channel memory index, and today\'s journal tail.',
|
|
45
|
+
})),
|
|
46
|
+
thinkingLevel: Type.Optional(Type.Union([
|
|
47
|
+
Type.Literal("off"),
|
|
48
|
+
Type.Literal("minimal"),
|
|
49
|
+
Type.Literal("low"),
|
|
50
|
+
Type.Literal("medium"),
|
|
51
|
+
Type.Literal("high"),
|
|
52
|
+
Type.Literal("xhigh"),
|
|
53
|
+
Type.Literal("max"),
|
|
54
|
+
], {
|
|
55
|
+
description: "Optional reasoning effort for the sub-agent.",
|
|
56
|
+
})),
|
|
57
|
+
mutates: Type.Optional(Type.Union([Type.Literal("read"), Type.Literal("write")], {
|
|
58
|
+
description: 'Whether this delegation will modify the working directory. Declare "write" whenever the sub-agent may write ' +
|
|
59
|
+
"files (including through bash) so it takes the exclusive workspace write lease.",
|
|
60
|
+
})),
|
|
61
|
+
workingDirectory: workingDirectoryField,
|
|
62
|
+
purpose: purposeField,
|
|
63
|
+
taskId: taskIdField,
|
|
64
|
+
item: itemField,
|
|
65
|
+
});
|
|
66
|
+
export function createSubAgentTool(options) {
|
|
67
|
+
return {
|
|
68
|
+
name: "subagent",
|
|
69
|
+
label: "subagent",
|
|
70
|
+
description: "Delegate a task to a configured sub-agent (see the Sub-Agents directory in the system prompt). Prefer this over `subagent_inline` whenever a role fits — its tools, model, budget and context policy all come from the role file. Sub-agents never receive the subagent tool, so they cannot create nested agents.",
|
|
71
|
+
parameters: subagentSchema,
|
|
72
|
+
execute: async (_toolCallId, params, signal, onUpdate) => {
|
|
73
|
+
if (signal?.aborted) {
|
|
74
|
+
throw new Error("Sub-agent aborted");
|
|
75
|
+
}
|
|
76
|
+
const availableModels = options.getAvailableModels();
|
|
77
|
+
const discovery = options.getSubAgentDiscovery?.() ?? {
|
|
78
|
+
directory: `${options.workspaceDir}/sub-agents`,
|
|
79
|
+
agents: [],
|
|
80
|
+
warnings: [],
|
|
81
|
+
};
|
|
82
|
+
const currentModel = options.getCurrentModel();
|
|
83
|
+
const taskLengthError = validateSubAgentTask(params.task);
|
|
84
|
+
if (taskLengthError) {
|
|
85
|
+
throw new RecoverableToolError(taskLengthError);
|
|
86
|
+
}
|
|
87
|
+
const invocation = resolveConfiguredRole(availableModels, currentModel, discovery.agents, { agent: params.agent, purpose: params.purpose }, options.getSubAgentModelReference?.() ?? undefined);
|
|
88
|
+
if (!invocation.config) {
|
|
89
|
+
throw new RecoverableToolError(`${invocation.error}\n\nAvailable configured sub-agents:\n${formatSubAgentList(discovery.agents)}`);
|
|
90
|
+
}
|
|
91
|
+
return dispatchSubAgentRun(options, currentModel, invocation.config, undefined, params, signal, onUpdate);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export function createSubAgentInlineTool(options) {
|
|
96
|
+
return {
|
|
97
|
+
name: "subagent_inline",
|
|
98
|
+
label: "subagent_inline",
|
|
99
|
+
description: "Advanced fallback only, not the default: use `subagent` first whenever any configured role in the workspace `sub-agents/` can do the work. `subagent` is the normal role-based path: pass its `agent` and complete `task`; the role file supplies the tools, model, budget and context policy. Use `subagent_inline` only when no configured role is suitable. It is a raw one-shot meta-executor, not a shorthand for `subagent`: there is no role file to supply those settings. Build a complete valid inline call yourself — `task` and `systemPrompt` are required; choose valid values for any needed `tools`, `model`, `effort`, `context`, `thinkingLevel`, `mutates`, `workingDirectory`, `purpose` and `taskId` fields. Do not send a partial role-style payload or choose this tool just because it is available. Sub-agents never receive the subagent tool, so they cannot create nested agents.",
|
|
100
|
+
parameters: subagentInlineSchema,
|
|
101
|
+
execute: async (_toolCallId, params, signal, onUpdate) => {
|
|
102
|
+
if (signal?.aborted) {
|
|
103
|
+
throw new Error("Sub-agent aborted");
|
|
104
|
+
}
|
|
105
|
+
const availableModels = options.getAvailableModels();
|
|
106
|
+
const currentModel = options.getCurrentModel();
|
|
107
|
+
const taskLengthError = validateSubAgentTask(params.task);
|
|
108
|
+
if (taskLengthError) {
|
|
109
|
+
throw new RecoverableToolError(taskLengthError);
|
|
110
|
+
}
|
|
111
|
+
const invocation = resolveInlineAgent(availableModels, currentModel, {
|
|
112
|
+
systemPrompt: params.systemPrompt,
|
|
113
|
+
tools: params.tools,
|
|
114
|
+
model: params.model,
|
|
115
|
+
effort: params.effort,
|
|
116
|
+
context: params.context,
|
|
117
|
+
thinkingLevel: params.thinkingLevel,
|
|
118
|
+
mutates: params.mutates,
|
|
119
|
+
purpose: params.purpose,
|
|
120
|
+
}, options.getSubAgentModelReference?.() ?? undefined);
|
|
121
|
+
if (!invocation.config) {
|
|
122
|
+
throw new RecoverableToolError(invocation.error ?? "Unable to resolve inline sub-agent.");
|
|
123
|
+
}
|
|
124
|
+
return dispatchSubAgentRun(options, currentModel, invocation.config, invocation.warning, params, signal, onUpdate);
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The task tool factories (`task_list`, `task_create`, `task_update`, `task_close`, `task_log`,
|
|
3
|
+
* `task_step_end`): each wires only its own schema and the per-task serial lock.
|
|
4
|
+
*/
|
|
1
5
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { taskCloseSchema, taskCreateSchema, taskListSchema, taskLogSchema, taskStepEndSchema, taskUpdateSchema } from "./
|
|
3
|
-
import type { TaskManageToolOptions } from "./
|
|
4
|
-
export type { TaskCloseRequest, TaskCreateRequest, TaskLogRequest, TaskManageResult, TaskManageToolOptions, TaskStepEndRequest, TaskUpdateRequest, } from "./
|
|
6
|
+
import { taskCloseSchema, taskCreateSchema, taskListSchema, taskLogSchema, taskStepEndSchema, taskUpdateSchema } from "./schema.js";
|
|
7
|
+
import type { TaskManageToolOptions } from "./types.js";
|
|
8
|
+
export type { TaskCloseRequest, TaskCreateRequest, TaskLogRequest, TaskManageResult, TaskManageToolOptions, TaskStepEndRequest, TaskUpdateRequest, } from "./types.js";
|
|
5
9
|
export declare function createTaskListTool(options: TaskManageToolOptions): AgentTool<typeof taskListSchema>;
|
|
6
10
|
export declare function createTaskCreateTool(options: TaskManageToolOptions): AgentTool<typeof taskCreateSchema>;
|
|
7
11
|
export declare function createTaskUpdateTool(options: TaskManageToolOptions): AgentTool<typeof taskUpdateSchema>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { normalizeTaskId } from "
|
|
2
|
-
import { withTaskMutation } from "
|
|
3
|
-
import { createTask } from "./
|
|
4
|
-
import { closeTask, listTasks, updateTask } from "./
|
|
5
|
-
import { readTaskLogTool } from "./
|
|
6
|
-
import { taskCloseSchema, taskCreateSchema, taskListSchema, taskLogSchema, taskStepEndSchema, taskUpdateSchema, } from "./
|
|
7
|
-
import { endTaskStep } from "./
|
|
1
|
+
import { normalizeTaskId } from "../../tasks/contract.js";
|
|
2
|
+
import { withTaskMutation } from "../../tasks/mutation-lock.js";
|
|
3
|
+
import { createTask } from "./create.js";
|
|
4
|
+
import { closeTask, listTasks, updateTask } from "./lifecycle.js";
|
|
5
|
+
import { readTaskLogTool } from "./log-view.js";
|
|
6
|
+
import { taskCloseSchema, taskCreateSchema, taskListSchema, taskLogSchema, taskStepEndSchema, taskUpdateSchema, } from "./schema.js";
|
|
7
|
+
import { endTaskStep } from "./step-end.js";
|
|
8
8
|
/**
|
|
9
9
|
* One tool per payload shape (spec 046, D3.1). Each factory wires only its own schema and, for
|
|
10
10
|
* the ones that carry an `id`, the same per-task serial lock (spec 029, D7): a task file write
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { mkdir } from "node:fs/promises";
|
|
2
|
+
import { applyTaskItemsPatch, normalizeTaskId, readActiveTasks } from "../../tasks/contract.js";
|
|
2
3
|
import { normalizeTaskBudget } from "../../tasks/contract-input.js";
|
|
3
|
-
import { applyTaskItemsPatch, normalizeTaskId, readActiveTasks } from "../../tasks/ledger.js";
|
|
4
4
|
import { readStoredTask, writeStoredTask } from "../../tasks/store.js";
|
|
5
5
|
import { describeTicket } from "../../tasks/ticket.js";
|
|
6
|
-
import { RecoverableToolError } from "../
|
|
6
|
+
import { RecoverableToolError } from "../contract/details.js";
|
|
7
7
|
import { closeTaskDocument, describeTaskState, requiredField, tasksDir } from "./shared.js";
|
|
8
8
|
async function requireTask(options, id) {
|
|
9
9
|
const document = await readStoredTask(options.channelDir, id);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { normalizeTaskId } from "../../tasks/
|
|
2
|
-
import { readTaskLog, renderTaskLogLine, taskLogIsArchived } from "../../tasks/log.js";
|
|
1
|
+
import { normalizeTaskId } from "../../tasks/contract.js";
|
|
2
|
+
import { readTaskLog, renderTaskLogLine, taskLogIsArchived } from "../../tasks/loop-log.js";
|
|
3
3
|
const DEFAULT_LIMIT = 20;
|
|
4
4
|
const MAX_LIMIT = 100;
|
|
5
5
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { uncheckedTaskAcceptanceItems } from "../../tasks/
|
|
3
|
-
import { appendTaskLog } from "../../tasks/log.js";
|
|
2
|
+
import { uncheckedTaskAcceptanceItems } from "../../tasks/contract.js";
|
|
3
|
+
import { appendTaskLog } from "../../tasks/loop-log.js";
|
|
4
4
|
import { archiveTask, writeStoredTask } from "../../tasks/store.js";
|
|
5
5
|
import { describeTicket } from "../../tasks/ticket.js";
|
|
6
|
-
import { RecoverableToolError } from "../
|
|
6
|
+
import { RecoverableToolError } from "../contract/details.js";
|
|
7
7
|
export function tasksDir(options) {
|
|
8
8
|
return join(options.channelDir, "tasks");
|
|
9
9
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { applyTaskItemsPatch, normalizeTaskId } from "../../tasks/
|
|
2
|
-
import { appendTaskLog } from "../../tasks/log.js";
|
|
1
|
+
import { applyTaskItemsPatch, normalizeTaskId } from "../../tasks/contract.js";
|
|
2
|
+
import { appendTaskLog } from "../../tasks/loop-log.js";
|
|
3
3
|
import { queueTaskNotice } from "../../tasks/steer.js";
|
|
4
4
|
import { readStoredTask, writeStoredTask } from "../../tasks/store.js";
|
|
5
5
|
import { describeTicket, resolveTicket } from "../../tasks/ticket.js";
|
|
6
|
-
import { RecoverableToolError } from "../
|
|
6
|
+
import { RecoverableToolError } from "../contract/details.js";
|
|
7
7
|
import { buildTicketContext, closeTaskDocument, requiredField } from "./shared.js";
|
|
8
8
|
/**
|
|
9
9
|
* `task_step_end` — the loop's only closing move (spec 051, D4/§12.4; narrowed by spec 052, D7).
|
|
@@ -101,7 +101,10 @@ export async function endTaskStep(options, request) {
|
|
|
101
101
|
// A task waiting on the user that says nothing is the same silent dead end tickets exist to
|
|
102
102
|
// prevent, so an `ask` park always speaks.
|
|
103
103
|
if (ticket.kind === "ask") {
|
|
104
|
-
pendingNotice = [
|
|
104
|
+
pendingNotice = [
|
|
105
|
+
report,
|
|
106
|
+
`⚠️ 任务 \`${id}\` 需要你的决定:${ticket.asked}\n用 \`/tasks reply ${id} <内容>\` 回答。`,
|
|
107
|
+
]
|
|
105
108
|
.filter(Boolean)
|
|
106
109
|
.join("\n\n");
|
|
107
110
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Static } from "typebox";
|
|
2
|
-
import type { ChannelJobManager } from "../../
|
|
2
|
+
import type { ChannelJobManager } from "../../jobs/manager.js";
|
|
3
3
|
import type { SubAgentRunManager } from "../../subagents/runs.js";
|
|
4
4
|
import type { taskCloseSchema, taskCreateSchema, taskLogSchema, taskStepEndSchema, taskUpdateSchema } from "./schema.js";
|
|
5
5
|
export interface TaskManageResult {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
+
import type { PipiclawWebToolsConfig } from "../config/tools.js";
|
|
3
4
|
import type { SecurityConfig } from "../security/types.js";
|
|
4
|
-
import type { PipiclawWebToolsConfig } from "./config.js";
|
|
5
5
|
declare const webFetchSchema: Type.TObject<{
|
|
6
6
|
url: Type.TString;
|
|
7
7
|
extractMode: Type.TOptional<Type.TUnion<[Type.TLiteral<"markdown">, Type.TLiteral<"text">]>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
+
import type { PipiclawWebToolsConfig } from "../config/tools.js";
|
|
3
4
|
import type { SecurityConfig } from "../security/types.js";
|
|
4
|
-
import type { PipiclawWebToolsConfig } from "./config.js";
|
|
5
5
|
declare const webSearchSchema: Type.TObject<{
|
|
6
6
|
query: Type.TString;
|
|
7
7
|
count: Type.TOptional<Type.TInteger>;
|
package/dist/tui/app.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BootstrapIO, type BootstrapPaths } from "../
|
|
1
|
+
import { type BootstrapIO, type BootstrapPaths } from "../app/home.js";
|
|
2
2
|
export interface TuiAppOptions {
|
|
3
3
|
channel?: string;
|
|
4
4
|
/** One-shot, non-interactive run: process a single prompt then exit. */
|
package/dist/tui/app.js
CHANGED
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
* preparation shares `prepareAppServices` with the DingTalk path.
|
|
8
8
|
*/
|
|
9
9
|
import { userInfo } from "node:os";
|
|
10
|
-
import { createJobRuntime } from "../agent/job-manager.js";
|
|
11
10
|
import { createRunner } from "../agent/runner-factory.js";
|
|
12
|
-
import {
|
|
11
|
+
import { BootstrapExitError, bootstrapAppHome, DEFAULT_BOOTSTRAP_PATHS, printBootstrapSummary, readCliVersion, } from "../app/home.js";
|
|
12
|
+
import { prepareAppServices } from "../app/services.js";
|
|
13
|
+
import { finalDeliveryOf, progressStyleOf } from "../channel/channel-context.js";
|
|
13
14
|
import { ensureChannelDir } from "../channel/channel-paths.js";
|
|
14
15
|
import { ChannelStore } from "../channel/store.js";
|
|
15
16
|
import { renderBuiltInHelp } from "../commands/catalog.js";
|
|
17
|
+
import { runReportCommand } from "../commands/router.js";
|
|
16
18
|
import { createExecutor } from "../executor.js";
|
|
19
|
+
import { createJobRuntime } from "../jobs/manager.js";
|
|
17
20
|
import * as log from "../log.js";
|
|
18
|
-
import { BootstrapExitError, bootstrapAppHome, DEFAULT_BOOTSTRAP_PATHS, printBootstrapSummary, readCliVersion, } from "../runtime/app-home.js";
|
|
19
|
-
import { finalDeliveryOf, progressStyleOf } from "../runtime/dingtalk.js";
|
|
20
|
-
import { runReportCommand } from "../runtime/report-commands.js";
|
|
21
21
|
import { flushSecurityLogs } from "../security/logger.js";
|
|
22
|
-
import { createSubAgentRuntime } from "../subagents/
|
|
22
|
+
import { createSubAgentRuntime } from "../subagents/run-registry.js";
|
|
23
23
|
import { getUsageLedger } from "../usage/ledger.js";
|
|
24
24
|
import { TUI_SLASH_COMMANDS } from "./commands.js";
|
|
25
25
|
import { createFrontend } from "./renderer.js";
|
package/dist/tui/cli.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `pipiclaw tui` CLI: argument parsing and entry. Parsing is a pure function
|
|
3
3
|
* (`parseTuiArgs`) so it can be unit-tested; `runTui` wires it to `runTuiApp`.
|
|
4
4
|
*/
|
|
5
|
-
import { type BootstrapIO } from "../
|
|
5
|
+
import { type BootstrapIO } from "../app/home.js";
|
|
6
6
|
export type ParsedTui = {
|
|
7
7
|
kind: "run";
|
|
8
8
|
channel?: string;
|
package/dist/tui/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `pipiclaw tui` CLI: argument parsing and entry. Parsing is a pure function
|
|
3
3
|
* (`parseTuiArgs`) so it can be unit-tested; `runTui` wires it to `runTuiApp`.
|
|
4
4
|
*/
|
|
5
|
-
import { BootstrapExitError, readCliVersion } from "../
|
|
5
|
+
import { BootstrapExitError, readCliVersion } from "../app/home.js";
|
|
6
6
|
import { runTuiApp } from "./app.js";
|
|
7
7
|
/** Parse `pipiclaw tui` arguments (everything after the `tui` subcommand). */
|
|
8
8
|
export function parseTuiArgs(args) {
|
|
@@ -61,8 +61,8 @@ function printTuiHelp(io) {
|
|
|
61
61
|
io.log(" --channel <id> Channel to attach to (default: tui_local).");
|
|
62
62
|
io.log(" Use dm_<staffId> to share a DingTalk conversation's memory.");
|
|
63
63
|
io.log(" --print, -p One-shot: run [prompt] (or stdin), print the answer, exit");
|
|
64
|
-
io.log(" --
|
|
65
|
-
io.log(" --
|
|
64
|
+
io.log(" --plain Use the line-based frontend instead of the full-screen UI");
|
|
65
|
+
io.log(" --quiet, -q Print only the final answer, no progress (implies --plain)");
|
|
66
66
|
io.log(" --version Print the version and exit");
|
|
67
67
|
io.log("");
|
|
68
68
|
io.log("Note: do not attach --channel to a DingTalk conversation the daemon is actively serving.");
|
package/dist/tui/commands.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* depend on whether a turn is running, which only the app knows — so those come
|
|
14
14
|
* back as intents rather than being applied here.
|
|
15
15
|
*/
|
|
16
|
-
import { BUILT_IN_COMMANDS, parseBuiltInCommand, SESSION_COMMANDS, } from "../commands/catalog.js";
|
|
16
|
+
import { BUILT_IN_COMMANDS, formatMissingQueueMessage, parseBuiltInCommand, SESSION_COMMANDS, } from "../commands/catalog.js";
|
|
17
17
|
export async function dispatch(input, deps) {
|
|
18
18
|
const trimmed = input.trim();
|
|
19
19
|
if (!trimmed)
|
|
@@ -43,11 +43,11 @@ export async function dispatch(input, deps) {
|
|
|
43
43
|
case "steer":
|
|
44
44
|
return command.args.trim()
|
|
45
45
|
? { kind: "steer", text: command.args }
|
|
46
|
-
: { kind: "noop", text: "
|
|
46
|
+
: { kind: "noop", text: formatMissingQueueMessage("steer") };
|
|
47
47
|
case "followup":
|
|
48
48
|
return command.args.trim()
|
|
49
49
|
? { kind: "followup", text: command.args }
|
|
50
|
-
: { kind: "noop", text: "
|
|
50
|
+
: { kind: "noop", text: formatMissingQueueMessage("followup") };
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
function toAutocompleteEntry(spec) {
|
|
@@ -60,5 +60,5 @@ function toAutocompleteEntry(spec) {
|
|
|
60
60
|
export const TUI_SLASH_COMMANDS = [
|
|
61
61
|
...BUILT_IN_COMMANDS.map(toAutocompleteEntry),
|
|
62
62
|
...SESSION_COMMANDS.map(toAutocompleteEntry),
|
|
63
|
-
{ name: "exit", description: "
|
|
63
|
+
{ name: "exit", description: "退出终端界面" },
|
|
64
64
|
];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering + input contracts for the terminal TUI.
|
|
3
|
+
*
|
|
4
|
+
* `TranscriptRenderer` is the output-only surface the delivery controller
|
|
5
|
+
* (`terminal-context.ts`) writes to — progress, final answers, notices. It is
|
|
6
|
+
* deliberately small so it is trivial to fake in tests.
|
|
7
|
+
*
|
|
8
|
+
* `Frontend` is the full interactive shell the app drives: a `TranscriptRenderer`
|
|
9
|
+
* plus input events and lifecycle. Two implementations exist — a pi-tui rich UI
|
|
10
|
+
* (`pitui-frontend.ts`) and a plain stdout/readline fallback (`plain-frontend.ts`)
|
|
11
|
+
* for non-TTY / piped / `--print` use; `renderer.ts` picks between them.
|
|
12
|
+
*/
|
|
13
|
+
export interface TranscriptRenderer {
|
|
14
|
+
/** A streamed progress line (tool call, thinking, assistant increment, error). */
|
|
15
|
+
appendProgress(text: string): void;
|
|
16
|
+
/** The final answer for a turn, rendered prominently (Markdown where supported). */
|
|
17
|
+
showFinal(markdown: string): void;
|
|
18
|
+
/** A side notice (skill change, model fallback), rendered subtly. */
|
|
19
|
+
showNotice(text: string): void;
|
|
20
|
+
/** Collapse the current turn's progress region (used before a replacing final / silence). */
|
|
21
|
+
clearProgress(): void;
|
|
22
|
+
/** Toggle the working indicator (spinner). */
|
|
23
|
+
setWorking(on: boolean): void;
|
|
24
|
+
}
|
|
25
|
+
export interface FrontendCallbacks {
|
|
26
|
+
/** User submitted a line of input. */
|
|
27
|
+
onSubmit(text: string): void;
|
|
28
|
+
/** User pressed the interrupt key (Ctrl-C). Two-stage policy lives in the app. */
|
|
29
|
+
onInterrupt(): void;
|
|
30
|
+
/** End of input (Ctrl-D on an empty line, or stdin closed). */
|
|
31
|
+
onEof(): void;
|
|
32
|
+
}
|
|
33
|
+
export interface Frontend extends TranscriptRenderer {
|
|
34
|
+
/** Begin surfacing input events. Non-blocking. */
|
|
35
|
+
start(callbacks: FrontendCallbacks): void;
|
|
36
|
+
/** Update the status line (model, context %, hints). */
|
|
37
|
+
setStatus(text: string): void;
|
|
38
|
+
/** Mark a turn in-flight: disable input echo of a new turn and show the spinner. */
|
|
39
|
+
setBusy(busy: boolean): void;
|
|
40
|
+
/** Show a one-time welcome banner at startup. */
|
|
41
|
+
showBanner(text: string): void;
|
|
42
|
+
/** Tear down: restore the terminal, stop reading input. */
|
|
43
|
+
stop(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering + input contracts for the terminal TUI.
|
|
3
|
+
*
|
|
4
|
+
* `TranscriptRenderer` is the output-only surface the delivery controller
|
|
5
|
+
* (`terminal-context.ts`) writes to — progress, final answers, notices. It is
|
|
6
|
+
* deliberately small so it is trivial to fake in tests.
|
|
7
|
+
*
|
|
8
|
+
* `Frontend` is the full interactive shell the app drives: a `TranscriptRenderer`
|
|
9
|
+
* plus input events and lifecycle. Two implementations exist — a pi-tui rich UI
|
|
10
|
+
* (`pitui-frontend.ts`) and a plain stdout/readline fallback (`plain-frontend.ts`)
|
|
11
|
+
* for non-TTY / piped / `--print` use; `renderer.ts` picks between them.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* surface the events.
|
|
11
11
|
*/
|
|
12
12
|
import { type SlashCommand } from "@earendil-works/pi-tui";
|
|
13
|
-
import type { Frontend, FrontendCallbacks } from "./
|
|
13
|
+
import type { Frontend, FrontendCallbacks } from "./frontend.js";
|
|
14
14
|
export interface PiTuiFrontendOptions {
|
|
15
15
|
/** Slash commands to offer in editor autocomplete. */
|
|
16
16
|
commands?: SlashCommand[];
|
|
@@ -47,7 +47,7 @@ export class PiTuiFrontend {
|
|
|
47
47
|
this.spinnerShown = false;
|
|
48
48
|
this.ui = new TuiMainScreen(new ProcessTerminal(), true);
|
|
49
49
|
this.editor = new Editor(this.ui, EDITOR_THEME, { paddingX: 1 });
|
|
50
|
-
this.loader = new Loader(this.ui, (s) => cyan(s), (s) => gray(s), "
|
|
50
|
+
this.loader = new Loader(this.ui, (s) => cyan(s), (s) => gray(s), "处理中…");
|
|
51
51
|
if (options.commands?.length) {
|
|
52
52
|
this.editor.setAutocompleteProvider(new CombinedAutocompleteProvider(options.commands, options.basePath ?? process.cwd(), null));
|
|
53
53
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Frontend, FrontendCallbacks } from "./
|
|
1
|
+
import type { Frontend, FrontendCallbacks } from "./frontend.js";
|
|
2
2
|
export interface PlainFrontendOptions {
|
|
3
3
|
/** Suppress progress/notice output on stderr; only the final answer is printed. */
|
|
4
4
|
quiet?: boolean;
|
package/dist/tui/renderer.d.ts
CHANGED
|
@@ -1,48 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* `TranscriptRenderer` is the output-only surface the delivery controller
|
|
5
|
-
* (`terminal-context.ts`) writes to — progress, final answers, notices. It is
|
|
6
|
-
* deliberately small so it is trivial to fake in tests.
|
|
7
|
-
*
|
|
8
|
-
* `Frontend` is the full interactive shell the app drives: a `TranscriptRenderer`
|
|
9
|
-
* plus input events and lifecycle. Two implementations exist — a pi-tui rich UI
|
|
10
|
-
* (`pitui-frontend.ts`) and a plain stdout/readline fallback (`plain-frontend.ts`)
|
|
11
|
-
* for non-TTY / piped / `--print` use.
|
|
2
|
+
* Frontend selection for the terminal TUI: the rich pi-tui UI on a TTY, else the plain stream.
|
|
3
|
+
* The contracts themselves (`TranscriptRenderer`, `Frontend`) live in `frontend.ts`.
|
|
12
4
|
*/
|
|
13
5
|
import type { SlashCommand } from "@earendil-works/pi-tui";
|
|
14
|
-
|
|
15
|
-
/** A streamed progress line (tool call, thinking, assistant increment, error). */
|
|
16
|
-
appendProgress(text: string): void;
|
|
17
|
-
/** The final answer for a turn, rendered prominently (Markdown where supported). */
|
|
18
|
-
showFinal(markdown: string): void;
|
|
19
|
-
/** A side notice (skill change, model fallback), rendered subtly. */
|
|
20
|
-
showNotice(text: string): void;
|
|
21
|
-
/** Collapse the current turn's progress region (used before a replacing final / silence). */
|
|
22
|
-
clearProgress(): void;
|
|
23
|
-
/** Toggle the working indicator (spinner). */
|
|
24
|
-
setWorking(on: boolean): void;
|
|
25
|
-
}
|
|
26
|
-
export interface FrontendCallbacks {
|
|
27
|
-
/** User submitted a line of input. */
|
|
28
|
-
onSubmit(text: string): void;
|
|
29
|
-
/** User pressed the interrupt key (Ctrl-C). Two-stage policy lives in the app. */
|
|
30
|
-
onInterrupt(): void;
|
|
31
|
-
/** End of input (Ctrl-D on an empty line, or stdin closed). */
|
|
32
|
-
onEof(): void;
|
|
33
|
-
}
|
|
34
|
-
export interface Frontend extends TranscriptRenderer {
|
|
35
|
-
/** Begin surfacing input events. Non-blocking. */
|
|
36
|
-
start(callbacks: FrontendCallbacks): void;
|
|
37
|
-
/** Update the status line (model, context %, hints). */
|
|
38
|
-
setStatus(text: string): void;
|
|
39
|
-
/** Mark a turn in-flight: disable input echo of a new turn and show the spinner. */
|
|
40
|
-
setBusy(busy: boolean): void;
|
|
41
|
-
/** Show a one-time welcome banner at startup. */
|
|
42
|
-
showBanner(text: string): void;
|
|
43
|
-
/** Tear down: restore the terminal, stop reading input. */
|
|
44
|
-
stop(): void;
|
|
45
|
-
}
|
|
6
|
+
import type { Frontend } from "./frontend.js";
|
|
46
7
|
export interface FrontendOptions {
|
|
47
8
|
/** Force the plain frontend even on a TTY. */
|
|
48
9
|
plain?: boolean;
|
package/dist/tui/renderer.js
CHANGED
|
@@ -8,8 +8,9 @@ export function createFrontend(options = {}) {
|
|
|
8
8
|
const isTty = process.stdout.isTTY === true && process.stdin.isTTY === true;
|
|
9
9
|
// `--print`/one-shot (interactive === false) must use the plain stream even on a
|
|
10
10
|
// TTY, or the answer is trapped in a full-screen pi-tui frame and never reaches a
|
|
11
|
-
// clean stdout.
|
|
12
|
-
|
|
11
|
+
// clean stdout. `--quiet` is about how much is printed, and only the plain stream can print
|
|
12
|
+
// less, so it implies `--plain` rather than being silently ignored by the full-screen UI.
|
|
13
|
+
if (options.plain || options.quiet || !isTty || options.interactive === false) {
|
|
13
14
|
return new PlainFrontend({ quiet: options.quiet, interactive: options.interactive });
|
|
14
15
|
}
|
|
15
16
|
return new PiTuiFrontend({ commands: options.commands, basePath: options.basePath });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Terminal implementation of the `ChannelContext` delivery contract.
|
|
3
3
|
*
|
|
4
|
-
* The DingTalk delivery controller (`
|
|
4
|
+
* The DingTalk delivery controller (`dingtalk/delivery.ts`) drives AI Card
|
|
5
5
|
* streaming; the terminal has none of that protocol, so this controller is a
|
|
6
6
|
* thin mapping from the contract onto a `TranscriptRenderer`. Archiving
|
|
7
7
|
* semantics mirror `delivery.ts` so a channel produces the same conversation log
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import type { ChannelContext, FinalDelivery, ProgressStyle } from "../channel/channel-context.js";
|
|
13
13
|
import type { ChannelStore } from "../channel/store.js";
|
|
14
|
-
import type { TranscriptRenderer } from "./
|
|
14
|
+
import type { TranscriptRenderer } from "./frontend.js";
|
|
15
15
|
/** The minimal per-turn input the terminal context needs (no DingTalk types). */
|
|
16
16
|
export interface TurnInput {
|
|
17
17
|
text: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { BootstrapIO } from "../app/home.js";
|
|
1
2
|
import type { MediaSender } from "../channel/channel-context.js";
|
|
2
|
-
import type { BootstrapIO } from "../runtime/app-home.js";
|
|
3
3
|
/**
|
|
4
4
|
* Terminal implementation of the `MediaSender` port. There is no chat surface to
|
|
5
5
|
* push a file to, and the bytes already came from a local file, so "sending" here
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import type { AgentRunner } from "../agent/types.js";
|
|
10
10
|
import type { ChannelStore } from "../channel/store.js";
|
|
11
11
|
import { type DispatchDeps } from "./commands.js";
|
|
12
|
-
import type { Frontend } from "./
|
|
12
|
+
import type { Frontend } from "./frontend.js";
|
|
13
13
|
import { type DeliveryTraits } from "./terminal-context.js";
|
|
14
14
|
export interface TurnControllerDeps {
|
|
15
15
|
runner: AgentRunner;
|
|
@@ -57,6 +57,8 @@ export declare class TurnController {
|
|
|
57
57
|
private handleInterrupt;
|
|
58
58
|
private requestExit;
|
|
59
59
|
private buildWelcome;
|
|
60
|
+
/** One word per state; `idle` and `ready` used to name the same one. */
|
|
61
|
+
private runStateLabel;
|
|
60
62
|
private updateStatus;
|
|
61
63
|
private shutdown;
|
|
62
64
|
}
|