@oyasmi/pipiclaw 0.9.5 → 0.9.6-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/README.en.md +300 -142
- package/README.md +295 -140
- package/dist/agent/builtin-commands.d.ts +1 -1
- package/dist/agent/builtin-commands.js +1 -1
- package/dist/agent/channel-runner.d.ts +4 -3
- package/dist/agent/channel-runner.js +17 -28
- package/dist/agent/maintenance-context.js +2 -2
- package/dist/agent/prompt/builder.d.ts +1 -1
- package/dist/agent/prompt/builder.js +1 -1
- package/dist/agent/prompt/extension.d.ts +1 -1
- package/dist/agent/prompt/extension.js +1 -1
- package/dist/agent/prompt/manifest.d.ts +6 -1
- package/dist/agent/prompt/manifest.js +12 -5
- package/dist/agent/prompt/resources.d.ts +0 -3
- package/dist/agent/prompt/resources.js +0 -6
- package/dist/agent/prompt/sections.d.ts +2 -2
- package/dist/agent/prompt/sections.js +36 -26
- package/dist/agent/prompt/types.d.ts +3 -2
- package/dist/agent/runner-factory.js +1 -1
- package/dist/agent/session/command-extension.js +3 -1
- package/dist/agent/session/compaction-summary.js +3 -6
- package/dist/agent/session/compaction.d.ts +2 -0
- package/dist/agent/session/compaction.js +22 -14
- package/dist/agent/session/event-guards.d.ts +2 -1
- package/dist/agent/session/event-guards.js +6 -0
- package/dist/agent/session/model-selection.d.ts +2 -1
- package/dist/agent/session/model-selection.js +5 -5
- package/dist/agent/session/session-events.js +31 -4
- package/dist/agent/session/session-host.d.ts +5 -3
- package/dist/agent/session/session-host.js +20 -16
- package/dist/agent/status-render.js +3 -0
- package/dist/agent/stop-watchdog.js +5 -1
- package/dist/agent/turn/task-digest.d.ts +2 -5
- package/dist/agent/turn/task-digest.js +25 -45
- package/dist/agent/turn/turn-context.js +4 -6
- package/dist/agent/turn/turn-error.d.ts +1 -1
- package/dist/agent/turn/turn-error.js +9 -0
- package/dist/agent/turn/turn-pipeline.d.ts +10 -5
- package/dist/agent/turn/turn-pipeline.js +36 -7
- package/dist/agent/turn/turn-prompt.d.ts +2 -0
- package/dist/agent/turn/turn-prompt.js +2 -1
- package/dist/agent/turn/turn-recovery.js +4 -1
- package/dist/agent/turn/turn-state.d.ts +2 -0
- package/dist/agent/turn/turn-state.js +2 -1
- package/dist/agent/types.d.ts +23 -3
- package/dist/agent/types.js +2 -0
- package/dist/app/auth-command.d.ts +25 -0
- package/dist/app/auth-command.js +200 -67
- package/dist/app/home.d.ts +7 -8
- package/dist/app/home.js +143 -56
- package/dist/channel/attachments.d.ts +4 -0
- package/dist/channel/attachments.js +4 -0
- package/dist/channel/channel-context.d.ts +6 -0
- package/dist/channel/config.d.ts +3 -0
- package/dist/channel/config.js +11 -5
- package/dist/channel/store.d.ts +1 -1
- package/dist/commands/catalog.js +42 -10
- package/dist/commands/router.js +5 -1
- package/dist/desk/commands.d.ts +44 -5
- package/dist/desk/commands.js +162 -28
- package/dist/desk/paths.d.ts +6 -0
- package/dist/desk/paths.js +21 -1
- package/dist/desk/registry.d.ts +17 -2
- package/dist/desk/registry.js +122 -12
- package/dist/desk/types.d.ts +83 -1
- package/dist/dingtalk/bot.d.ts +1 -1
- package/dist/dingtalk/bot.js +4 -3
- package/dist/dingtalk/config.js +10 -10
- package/dist/dingtalk/delivery.js +15 -8
- package/dist/dingtalk/inbound-media.d.ts +36 -14
- package/dist/dingtalk/inbound-media.js +71 -12
- package/dist/dingtalk/inbound.d.ts +9 -2
- package/dist/dingtalk/inbound.js +17 -2
- package/dist/dingtalk/media.d.ts +4 -10
- package/dist/dingtalk/media.js +58 -32
- package/dist/events/commands.d.ts +2 -0
- package/dist/events/commands.js +13 -8
- package/dist/events/history.d.ts +9 -0
- package/dist/events/history.js +66 -0
- package/dist/events/parse.js +7 -3
- package/dist/events/types.d.ts +3 -0
- package/dist/events/watcher.d.ts +4 -8
- package/dist/events/watcher.js +53 -58
- package/dist/jobs/kill.d.ts +23 -0
- package/dist/jobs/kill.js +65 -0
- package/dist/jobs/manager.d.ts +19 -18
- package/dist/jobs/manager.js +36 -103
- package/dist/main.js +15 -3
- package/dist/memory/boundary-work.d.ts +2 -1
- package/dist/memory/boundary-work.js +1 -1
- package/dist/memory/lifecycle.d.ts +2 -1
- package/dist/memory/lifecycle.js +2 -2
- package/dist/memory/reflect-job.d.ts +2 -1
- package/dist/memory/reflect-job.js +1 -1
- package/dist/memory/reflect.d.ts +2 -1
- package/dist/memory/reflect.js +25 -4
- package/dist/memory/scheduler.d.ts +2 -1
- package/dist/memory/scheduler.js +1 -1
- package/dist/memory/session-corpus.d.ts +1 -1
- package/dist/memory/session-corpus.js +76 -1
- package/dist/memory/session-search.d.ts +2 -1
- package/dist/memory/session-search.js +14 -12
- package/dist/memory/sidecar-worker.d.ts +2 -1
- package/dist/memory/sidecar-worker.js +2 -4
- package/dist/memory/store.d.ts +2 -0
- package/dist/memory/store.js +19 -9
- package/dist/models/credential-work.d.ts +7 -0
- package/dist/models/credential-work.js +36 -0
- package/dist/models/login-ui.js +4 -4
- package/dist/models/provider-login.js +7 -6
- package/dist/models/requests.d.ts +8 -0
- package/dist/models/requests.js +69 -0
- package/dist/models/runtime.d.ts +3 -1
- package/dist/models/runtime.js +9 -2
- package/dist/playbooks/agent-delegation.md +20 -45
- package/dist/playbooks/background-jobs.md +1 -1
- package/dist/playbooks/catalog.js +1 -1
- package/dist/playbooks/delegation-inline.md +25 -0
- package/dist/playbooks/delegation-recovery.md +28 -0
- package/dist/playbooks/event-scheduling.md +18 -37
- package/dist/playbooks/event-sensors.md +26 -0
- package/dist/playbooks/event-task-template.md +22 -0
- package/dist/playbooks/learning-and-skills.md +26 -0
- package/dist/playbooks/memory-operations.md +36 -0
- package/dist/playbooks/outbound-media.md +2 -2
- package/dist/playbooks/runtime-files.md +29 -0
- package/dist/playbooks/runtime-operations.md +25 -0
- package/dist/playbooks/runtime-orientation.md +18 -53
- package/dist/playbooks/task-lead.md +22 -68
- package/dist/playbooks/task-manage.md +38 -0
- package/dist/playbooks/task-recovery.md +24 -0
- package/dist/playbooks/task-verify.md +22 -0
- package/dist/runtime/bootstrap.d.ts +10 -0
- package/dist/runtime/bootstrap.js +93 -29
- package/dist/runtime/daemon-lock.js +3 -3
- package/dist/runtime/desk-runtime.d.ts +40 -7
- package/dist/runtime/desk-runtime.js +330 -44
- package/dist/runtime/durable-dispatch.d.ts +14 -2
- package/dist/runtime/durable-dispatch.js +207 -65
- package/dist/runtime/ingress-busy.js +17 -8
- package/dist/runtime/ingress-commands.js +24 -4
- package/dist/runtime/ingress-deps.d.ts +4 -1
- package/dist/runtime/ingress.js +6 -1
- package/dist/runtime/request-execution.js +7 -6
- package/dist/runtime/shutdown.d.ts +4 -1
- package/dist/runtime/shutdown.js +88 -35
- package/dist/runtime/task-close.d.ts +1 -1
- package/dist/runtime/task-close.js +6 -3
- package/dist/runtime/task-control.d.ts +2 -3
- package/dist/runtime/task-control.js +38 -11
- package/dist/runtime/task-input.js +1 -1
- package/dist/runtime/task-lane-types.d.ts +12 -2
- package/dist/runtime/task-lane-types.js +9 -0
- package/dist/runtime/task-lane.d.ts +2 -0
- package/dist/runtime/task-lane.js +38 -20
- package/dist/runtime/task-step.d.ts +3 -3
- package/dist/runtime/task-step.js +34 -16
- package/dist/runtime/transports.js +6 -5
- package/dist/runtime/turn-run.js +103 -66
- package/dist/security/command-guard.d.ts +1 -1
- package/dist/security/command-guard.js +259 -314
- package/dist/security/path-guard.js +48 -7
- package/dist/security/shell-parse.d.ts +10 -0
- package/dist/security/shell-parse.js +224 -0
- package/dist/security/types.d.ts +2 -0
- package/dist/subagents/commands.d.ts +1 -1
- package/dist/subagents/commands.js +14 -5
- package/dist/subagents/completion-wake.js +6 -0
- package/dist/subagents/detached-discovery.d.ts +1 -1
- package/dist/subagents/discovery.d.ts +18 -199
- package/dist/subagents/discovery.js +35 -289
- package/dist/subagents/dispatch.d.ts +1 -2
- package/dist/subagents/dispatch.js +50 -29
- package/dist/subagents/external/antigravity-cli.d.ts +2 -0
- package/dist/subagents/external/antigravity-cli.js +517 -0
- package/dist/subagents/external/claude-code.js +8 -17
- package/dist/subagents/external/codex-cli.js +8 -18
- package/dist/subagents/external/cursor-cli.js +34 -31
- package/dist/subagents/external/dispatch.d.ts +21 -7
- package/dist/subagents/external/dispatch.js +146 -12
- package/dist/subagents/external/exec.js +3 -0
- package/dist/subagents/external/harness.d.ts +57 -33
- package/dist/subagents/external/harness.js +69 -40
- package/dist/subagents/external/reconciliation.js +1 -0
- package/dist/subagents/external/registry.js +4 -1
- package/dist/subagents/external/role-warnings.d.ts +4 -13
- package/dist/subagents/external/role-warnings.js +4 -28
- package/dist/subagents/external/run.d.ts +1 -2
- package/dist/subagents/external/run.js +16 -26
- package/dist/subagents/external/settlement.d.ts +2 -0
- package/dist/subagents/external/settlement.js +13 -3
- package/dist/subagents/format.d.ts +1 -1
- package/dist/subagents/format.js +1 -1
- package/dist/subagents/internal/outcome.d.ts +1 -2
- package/dist/subagents/internal/outcome.js +19 -12
- package/dist/subagents/internal/provider-retry.d.ts +1 -2
- package/dist/subagents/internal/provider-retry.js +2 -4
- package/dist/subagents/internal/run.d.ts +2 -3
- package/dist/subagents/internal/run.js +27 -4
- package/dist/subagents/internal/state.d.ts +2 -5
- package/dist/subagents/internal/state.js +1 -2
- package/dist/subagents/internal/worker.d.ts +1 -2
- package/dist/subagents/internal/worker.js +20 -10
- package/dist/subagents/resolve.d.ts +56 -0
- package/dist/subagents/resolve.js +202 -0
- package/dist/subagents/result.d.ts +6 -4
- package/dist/subagents/result.js +39 -6
- package/dist/subagents/run-record.d.ts +54 -2
- package/dist/subagents/run-record.js +7 -0
- package/dist/subagents/runs.d.ts +6 -31
- package/dist/subagents/runs.js +26 -31
- package/dist/subagents/task-envelope.d.ts +1 -2
- package/dist/subagents/task-envelope.js +13 -4
- package/dist/subagents/task-settlement.js +1 -0
- package/dist/subagents/types.d.ts +105 -6
- package/dist/subagents/types.js +16 -1
- package/dist/subagents/workspace-lease.d.ts +41 -24
- package/dist/subagents/workspace-lease.js +159 -24
- package/dist/subagents/worktree.d.ts +52 -0
- package/dist/subagents/worktree.js +363 -0
- package/dist/tasks/archive.js +4 -0
- package/dist/tasks/brief.d.ts +5 -1
- package/dist/tasks/brief.js +19 -5
- package/dist/tasks/commands.d.ts +6 -1
- package/dist/tasks/commands.js +32 -7
- package/dist/tasks/control.d.ts +11 -0
- package/dist/tasks/delivery.d.ts +2 -0
- package/dist/tasks/delivery.js +141 -21
- package/dist/tasks/loop-log.d.ts +12 -0
- package/dist/tasks/loop-log.js +10 -1
- package/dist/tasks/receipts.d.ts +7 -3
- package/dist/tasks/receipts.js +34 -5
- package/dist/tools/bash.d.ts +3 -0
- package/dist/tools/bash.js +29 -15
- package/dist/tools/contract/presentation.js +7 -5
- package/dist/tools/edit-diff.d.ts +11 -0
- package/dist/tools/edit-diff.js +148 -0
- package/dist/tools/edit-match.d.ts +18 -0
- package/dist/tools/edit-match.js +242 -0
- package/dist/tools/edit.d.ts +10 -2
- package/dist/tools/edit.js +91 -361
- package/dist/tools/event-manage.d.ts +2 -1
- package/dist/tools/event-manage.js +46 -39
- package/dist/tools/file-observations.d.ts +9 -0
- package/dist/tools/file-observations.js +50 -0
- package/dist/tools/glob-match.d.ts +3 -1
- package/dist/tools/glob-match.js +40 -17
- package/dist/tools/glob.d.ts +1 -0
- package/dist/tools/glob.js +39 -19
- package/dist/tools/grep-command.d.ts +13 -0
- package/dist/tools/grep-command.js +77 -0
- package/dist/tools/grep.js +96 -201
- package/dist/tools/index.d.ts +6 -2
- package/dist/tools/index.js +9 -4
- package/dist/tools/job.js +12 -11
- package/dist/tools/read.d.ts +2 -0
- package/dist/tools/read.js +10 -2
- package/dist/tools/registry.d.ts +16 -11
- package/dist/tools/registry.js +32 -12
- package/dist/tools/send-media.js +9 -5
- package/dist/tools/session-search.d.ts +2 -1
- package/dist/tools/session-search.js +15 -5
- package/dist/tools/skill.js +13 -12
- package/dist/tools/subagent-manage.d.ts +1 -1
- package/dist/tools/subagent-manage.js +25 -152
- package/dist/tools/subagent.d.ts +24 -2
- package/dist/tools/subagent.js +24 -18
- package/dist/tools/task-manage/control-tools.js +1 -1
- package/dist/tools/task-manage/factory.d.ts +2 -2
- package/dist/tools/task-manage/factory.js +40 -4
- package/dist/tools/task-manage/lifecycle.d.ts +3 -3
- package/dist/tools/task-manage/lifecycle.js +56 -13
- package/dist/tools/task-manage/schema.d.ts +4 -1
- package/dist/tools/task-manage/schema.js +4 -1
- package/dist/tools/task-manage/shared.d.ts +1 -1
- package/dist/tools/task-manage/types.d.ts +5 -1
- package/dist/tools/write-content.d.ts +7 -1
- package/dist/tools/write-content.js +18 -6
- package/dist/tools/write.d.ts +3 -0
- package/dist/tools/write.js +6 -2
- package/dist/tui/cli.d.ts +6 -6
- package/dist/tui/cli.js +120 -28
- package/dist/tui/client.d.ts +7 -0
- package/dist/tui/client.js +67 -16
- package/dist/tui/frontend.d.ts +2 -0
- package/dist/tui/pitui-frontend.d.ts +4 -0
- package/dist/tui/pitui-frontend.js +27 -0
- package/dist/tui/render.d.ts +1 -0
- package/dist/tui/render.js +5 -0
- package/dist/tui/session.js +6 -0
- package/dist/usage/ledger.d.ts +1 -1
- package/dist/usage/render.js +1 -1
- package/dist/web/client.d.ts +1 -0
- package/dist/web/client.js +11 -0
- package/dist/web/fetch.js +6 -3
- package/dist/webapi/auth.d.ts +0 -3
- package/dist/webapi/auth.js +3 -7
- package/dist/webapi/config.js +17 -14
- package/dist/webapi/key-command.js +41 -41
- package/dist/webapi/response-state.d.ts +7 -1
- package/dist/webapi/response-state.js +166 -3
- package/dist/webapi/routes/websocket.js +24 -1
- package/dist/webapi/server.d.ts +3 -1
- package/dist/webapi/server.js +32 -1
- package/dist/webapi/service.js +8 -0
- package/dist/webapi/transport.d.ts +2 -0
- package/dist/webapi/transport.js +11 -1
- package/examples/sub-agents/README.md +43 -75
- package/examples/sub-agents/agy-main.md +21 -0
- package/examples/sub-agents/claude-high.md +21 -0
- package/examples/sub-agents/claude-main.md +21 -0
- package/examples/sub-agents/codex-flash.md +21 -0
- package/examples/sub-agents/codex-high.md +21 -0
- package/examples/sub-agents/codex-main.md +21 -0
- package/examples/sub-agents/codex-review.md +20 -0
- package/examples/sub-agents/cursor-high.md +20 -0
- package/examples/sub-agents/cursor-main.md +20 -0
- package/examples/sub-agents/glm-flash.md +21 -0
- package/examples/sub-agents/glm-high.md +21 -0
- package/examples/sub-agents/pi-scout.md +20 -0
- package/package.json +11 -12
- package/dist/agent/session/request-tools.d.ts +0 -3
- package/dist/agent/session/request-tools.js +0 -20
- package/dist/models/api-keys.d.ts +0 -11
- package/dist/models/api-keys.js +0 -22
- package/dist/playbooks/memory-and-learning.md +0 -55
- package/examples/sub-agents/agents/claude-high.md +0 -23
- package/examples/sub-agents/agents/claude-main.md +0 -23
- package/examples/sub-agents/agents/codex-flash.md +0 -23
- package/examples/sub-agents/agents/codex-high.md +0 -23
- package/examples/sub-agents/agents/codex-main.md +0 -23
- package/examples/sub-agents/agents/codex-review.md +0 -23
- package/examples/sub-agents/agents/cursor-high.md +0 -22
- package/examples/sub-agents/agents/cursor-main.md +0 -22
- package/examples/sub-agents/agents/glm-flash.md +0 -23
- package/examples/sub-agents/agents/glm-high.md +0 -23
- package/examples/sub-agents/agents/scout.md +0 -30
- package/examples/sub-agents/roles/builder-hard.md +0 -34
- package/examples/sub-agents/roles/builder.md +0 -34
- package/examples/sub-agents/roles/explorer.md +0 -39
- package/examples/sub-agents/roles/git-committer.md +0 -43
- package/examples/sub-agents/roles/planner.md +0 -33
- package/examples/sub-agents/roles/reviewer.md +0 -33
- package/examples/sub-agents/roles/verifier.md +0 -35
- package/examples/sub-agents/roles/worker.md +0 -34
package/dist/app/home.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export interface BootstrapIO {
|
|
|
17
17
|
export interface BootstrapResult {
|
|
18
18
|
created: string[];
|
|
19
19
|
channelTemplateCreated: boolean;
|
|
20
|
+
/** Generated once when `channel.json` is first created; only its SHA-256 hash is written to disk. */
|
|
21
|
+
initialWebApiKey?: string;
|
|
20
22
|
}
|
|
21
23
|
export declare const DEFAULT_BOOTSTRAP_PATHS: BootstrapPaths;
|
|
22
24
|
export declare class BootstrapExitError extends Error {
|
|
@@ -27,16 +29,13 @@ export declare function isBootstrapExitError(error: unknown): error is Bootstrap
|
|
|
27
29
|
export declare function readCliVersion(): string;
|
|
28
30
|
export declare function bootstrapAppHome(paths?: BootstrapPaths): BootstrapResult;
|
|
29
31
|
export declare function printBootstrapSummary(result: BootstrapResult, io?: BootstrapIO, paths?: BootstrapPaths): void;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
export declare function printFirstRunGuide(io?: BootstrapIO, paths?: BootstrapPaths): void;
|
|
32
|
+
export declare function printStartupReadySummary(io: BootstrapIO, paths: BootstrapPaths, transportNames: readonly string[], modelStatus?: {
|
|
33
|
+
ready: boolean;
|
|
34
|
+
activeModelRef: string;
|
|
35
|
+
}): void;
|
|
36
36
|
/**
|
|
37
37
|
* The one place that lists `pipiclaw`'s top-level subcommands. `parseArgs`'s own `--help` uses it;
|
|
38
|
-
* `main.ts`'s unknown-subcommand branch
|
|
39
|
-
* 2026-08-24 §1.10) — it now calls this instead, so the two can't drift apart again.
|
|
38
|
+
* `main.ts`'s unknown-subcommand branch calls this too so the two cannot drift apart.
|
|
40
39
|
*/
|
|
41
40
|
export declare function formatCliCommandsHelp(appName: string): string[];
|
|
42
41
|
export declare function parseArgs(argv: string[], paths?: BootstrapPaths, io?: BootstrapIO): void;
|
package/dist/app/home.js
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
|
|
8
8
|
import { join } from "path";
|
|
9
9
|
import { DEFAULT_AGENTS, DEFAULT_SOUL } from "../agent/prompt/workspace-templates.js";
|
|
10
|
+
import { generateWebApiKey, hashWebApiKey } from "../channel/config.js";
|
|
10
11
|
import { initializeDefaultDesk } from "../desk/default.js";
|
|
11
12
|
import * as log from "../log.js";
|
|
12
|
-
import { APP_HOME_DIR, APP_NAME, AUTH_CONFIG_PATH, CHANNEL_CONFIG_PATH,
|
|
13
|
+
import { APP_HOME_DIR, APP_NAME, AUTH_CONFIG_PATH, CHANNEL_CONFIG_PATH, EVENT_HISTORY_PATH, MODELS_CONFIG_PATH, SECURITY_CONFIG_PATH, SETTINGS_CONFIG_PATH, TOOLS_CONFIG_PATH, WORKSPACE_DIR, } from "../paths.js";
|
|
13
14
|
import { errorMessage } from "../shared/text-utils.js";
|
|
14
15
|
const DEFAULT_MEMORY = `# Workspace Memory
|
|
15
16
|
|
|
@@ -52,26 +53,71 @@ This file records durable environment facts and notable machine-level changes.
|
|
|
52
53
|
|
|
53
54
|
<!-- Record important config or environment changes that affect future work. -->
|
|
54
55
|
`;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
56
|
+
function createChannelConfigTemplate() {
|
|
57
|
+
const initialWebApiKey = generateWebApiKey();
|
|
58
|
+
return {
|
|
59
|
+
initialWebApiKey,
|
|
60
|
+
config: {
|
|
61
|
+
dingtalk: {
|
|
62
|
+
enabled: false,
|
|
63
|
+
clientId: "your-dingtalk-client-id",
|
|
64
|
+
clientSecret: "your-dingtalk-client-secret",
|
|
65
|
+
robotCode: "",
|
|
66
|
+
cardTemplateId: "",
|
|
67
|
+
cardTemplateKey: "content",
|
|
68
|
+
allowFrom: [],
|
|
69
|
+
busyMessageDefault: "steer",
|
|
70
|
+
responseMode: "full_progress_then_plain_final",
|
|
71
|
+
cardAutoLayout: true,
|
|
72
|
+
},
|
|
73
|
+
webapi: {
|
|
74
|
+
enabled: true,
|
|
75
|
+
socket: true,
|
|
76
|
+
tcp: "127.0.0.1:8787",
|
|
77
|
+
tls: null,
|
|
78
|
+
keys: [
|
|
79
|
+
{
|
|
80
|
+
name: "default",
|
|
81
|
+
sha256: hashWebApiKey(initialWebApiKey),
|
|
82
|
+
desks: ["default"],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const MODELS_CONFIG_TEMPLATE = {
|
|
90
|
+
providers: {},
|
|
91
|
+
_examples: {
|
|
92
|
+
"my-gateway": {
|
|
93
|
+
baseUrl: "https://api.deepseek.com/v1",
|
|
94
|
+
api: "openai-completions",
|
|
95
|
+
apiKey: "DEEPSEEK_API_KEY",
|
|
96
|
+
compat: {
|
|
97
|
+
supportsDeveloperRole: false,
|
|
98
|
+
supportsReasoningEffort: false,
|
|
99
|
+
},
|
|
100
|
+
models: [{ id: "deepseek-chat" }],
|
|
101
|
+
},
|
|
72
102
|
},
|
|
103
|
+
_notes: [
|
|
104
|
+
"将 _examples 中的条目复制到 providers 下,即可接入 OpenAI 兼容网关、DeepSeek、通义或本地 Ollama。",
|
|
105
|
+
"apiKey 可直接填写密钥字符串、环境变量名(如 DEEPSEEK_API_KEY),或 !command。",
|
|
106
|
+
"配置后可在 settings.json 中补充 defaultProvider 与 defaultModel 指定默认模型。",
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
const SETTINGS_CONFIG_TEMPLATE = {
|
|
110
|
+
defaultThinkingLevel: "medium",
|
|
111
|
+
fallbackModel: null,
|
|
112
|
+
subagentModel: null,
|
|
113
|
+
compaction: { enabled: true },
|
|
114
|
+
retry: { enabled: true },
|
|
115
|
+
memoryMaintenance: { enabled: true },
|
|
116
|
+
sessionSearch: { summarizeWithModel: false },
|
|
117
|
+
logging: { level: "info", file: { enabled: true } },
|
|
118
|
+
tui: { responseMode: "full_progress_then_plain_final" },
|
|
119
|
+
delegation: { notices: "live" },
|
|
73
120
|
};
|
|
74
|
-
const MODELS_CONFIG_TEMPLATE = { providers: {} };
|
|
75
121
|
const TOOLS_CONFIG_TEMPLATE = {
|
|
76
122
|
tools: {
|
|
77
123
|
web: {
|
|
@@ -91,10 +137,10 @@ const TOOLS_CONFIG_TEMPLATE = {
|
|
|
91
137
|
proxy: "http://127.0.0.1:7890",
|
|
92
138
|
},
|
|
93
139
|
_notes: [
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"tools.tasks.enabled
|
|
140
|
+
"将 tools.web.enable 设为 true 可启用联网搜索(web_search)与网页读取(web_fetch)。",
|
|
141
|
+
"默认搜索源 duckduckgo 无需 API Key;也可切换为 tavily、jina 或 searxng。",
|
|
142
|
+
"如需为网页工具单独配置代理,可将 _examples.proxy 填入 tools.web.proxy。",
|
|
143
|
+
"tools.tasks.enabled 是后台长程任务的总开关。",
|
|
98
144
|
],
|
|
99
145
|
};
|
|
100
146
|
const SECURITY_CONFIG_TEMPLATE = {
|
|
@@ -205,55 +251,96 @@ export function bootstrapAppHome(paths = DEFAULT_BOOTSTRAP_PATHS) {
|
|
|
205
251
|
paths.toolsConfigPath,
|
|
206
252
|
paths.securityConfigPath,
|
|
207
253
|
];
|
|
208
|
-
|
|
254
|
+
let channelTemplateCreated = false;
|
|
255
|
+
let initialWebApiKey;
|
|
256
|
+
if (!existsSync(paths.channelConfigPath)) {
|
|
257
|
+
const generated = createChannelConfigTemplate();
|
|
258
|
+
channelTemplateCreated = writeJsonFileIfMissing(paths.channelConfigPath, generated.config, "channel.json", created, SECRET_FILE_MODE);
|
|
259
|
+
if (channelTemplateCreated)
|
|
260
|
+
initialWebApiKey = generated.initialWebApiKey;
|
|
261
|
+
}
|
|
209
262
|
writeJsonFileIfMissing(paths.authConfigPath, {}, "auth.json", created, SECRET_FILE_MODE);
|
|
210
263
|
writeJsonFileIfMissing(paths.modelsConfigPath, MODELS_CONFIG_TEMPLATE, "models.json", created, SECRET_FILE_MODE);
|
|
211
|
-
writeJsonFileIfMissing(paths.settingsConfigPath,
|
|
264
|
+
writeJsonFileIfMissing(paths.settingsConfigPath, SETTINGS_CONFIG_TEMPLATE, "settings.json", created, SECRET_FILE_MODE);
|
|
212
265
|
writeJsonFileIfMissing(paths.toolsConfigPath, TOOLS_CONFIG_TEMPLATE, "tools.json", created, SECRET_FILE_MODE);
|
|
213
266
|
writeJsonFileIfMissing(paths.securityConfigPath, SECURITY_CONFIG_TEMPLATE, "security.json", created, SECRET_FILE_MODE);
|
|
214
267
|
// Tighten any pre-existing config that predates owner-only creation.
|
|
215
268
|
for (const secretPath of secretConfigPaths) {
|
|
216
269
|
hardenExistingSecretFile(secretPath);
|
|
217
270
|
}
|
|
218
|
-
return {
|
|
271
|
+
return {
|
|
272
|
+
created,
|
|
273
|
+
channelTemplateCreated,
|
|
274
|
+
...(initialWebApiKey ? { initialWebApiKey } : {}),
|
|
275
|
+
};
|
|
219
276
|
}
|
|
220
277
|
export function printBootstrapSummary(result, io = console, paths = DEFAULT_BOOTSTRAP_PATHS) {
|
|
221
278
|
if (result.created.length === 0) {
|
|
222
279
|
return;
|
|
223
280
|
}
|
|
224
|
-
io.log(
|
|
281
|
+
io.log(`已初始化 ${paths.appName} 配置目录(${paths.appHomeDir}):`);
|
|
225
282
|
for (const item of result.created) {
|
|
226
283
|
io.log(` - ${item}`);
|
|
227
284
|
}
|
|
228
285
|
io.log("");
|
|
286
|
+
if (result.initialWebApiKey) {
|
|
287
|
+
io.log("==================================================================");
|
|
288
|
+
io.log("🔑 已自动生成本机 Web API 默认密钥(名称:default,授权工位:default)");
|
|
289
|
+
io.log(" 明文密钥仅展示这一次,请立即妥善保存(配置文件仅保存其 SHA-256):");
|
|
290
|
+
io.log("");
|
|
291
|
+
io.log(` ${result.initialWebApiKey}`);
|
|
292
|
+
io.log("");
|
|
293
|
+
io.log(" 本机 HTTP 接口:http://127.0.0.1:8787/v1 (Authorization: Bearer <密钥>)");
|
|
294
|
+
io.log(` 若遗忘可执行 \`${paths.appName} webapi key remove default && ${paths.appName} webapi key add default\` 重新生成。`);
|
|
295
|
+
io.log("==================================================================");
|
|
296
|
+
io.log("");
|
|
297
|
+
}
|
|
229
298
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
299
|
+
export function printStartupReadySummary(io, paths, transportNames, modelStatus) {
|
|
300
|
+
let tcpAddress;
|
|
301
|
+
let tlsEnabled = false;
|
|
302
|
+
if (transportNames.includes("webapi")) {
|
|
303
|
+
try {
|
|
304
|
+
const raw = JSON.parse(readFileSync(paths.channelConfigPath, "utf-8"));
|
|
305
|
+
if (typeof raw.webapi?.tcp === "string" && raw.webapi.tcp.trim()) {
|
|
306
|
+
tcpAddress = raw.webapi.tcp.trim();
|
|
307
|
+
}
|
|
308
|
+
tlsEnabled = Boolean(raw.webapi?.tls);
|
|
309
|
+
}
|
|
310
|
+
catch {
|
|
311
|
+
// Best-effort summary only; actual config was already validated by loadTransports.
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
io.log("");
|
|
315
|
+
io.log(`🚀 ${paths.appName} 服务已启动(配置目录:${paths.appHomeDir})`);
|
|
316
|
+
if (transportNames.includes("webapi")) {
|
|
317
|
+
const scheme = tlsEnabled ? "https" : "http";
|
|
318
|
+
io.log(` - Web API:已启用${tcpAddress ? `(本机接口 ${scheme}://${tcpAddress}/v1 + 本机 Socket)` : "(本机 Socket)"}`);
|
|
319
|
+
}
|
|
320
|
+
if (transportNames.includes("dingtalk")) {
|
|
321
|
+
io.log(" - 钉钉渠道:已启用(可在钉钉私聊或群内 @机器人 对话)");
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
io.log(` - 钉钉渠道:未启用(如需接入,编辑 ${paths.channelConfigPath} 中 dingtalk 段即可)`);
|
|
325
|
+
}
|
|
326
|
+
if (modelStatus) {
|
|
327
|
+
io.log(modelStatus.ready
|
|
328
|
+
? ` - 默认模型:${modelStatus.activeModelRef}(已就绪)`
|
|
329
|
+
: ` - 模型状态:⚠️ 尚未检测到凭据(请执行 \`${paths.appName} auth login\` 或配置 ${paths.modelsConfigPath})`);
|
|
330
|
+
}
|
|
331
|
+
io.log(` - 立即对话:打开新终端运行 \`${paths.appName} tui\`(在项目目录下可加 \`--cwd .\`)`);
|
|
332
|
+
io.log("");
|
|
245
333
|
}
|
|
246
334
|
/**
|
|
247
335
|
* The one place that lists `pipiclaw`'s top-level subcommands. `parseArgs`'s own `--help` uses it;
|
|
248
|
-
* `main.ts`'s unknown-subcommand branch
|
|
249
|
-
* 2026-08-24 §1.10) — it now calls this instead, so the two can't drift apart again.
|
|
336
|
+
* `main.ts`'s unknown-subcommand branch calls this too so the two cannot drift apart.
|
|
250
337
|
*/
|
|
251
338
|
export function formatCliCommandsHelp(appName) {
|
|
252
339
|
return [
|
|
253
|
-
` ${appName} [run] [options]
|
|
254
|
-
` ${appName} tui [options] [prompt]
|
|
255
|
-
` ${appName} auth status|login|logout
|
|
256
|
-
` ${appName} webapi key add|list|remove
|
|
340
|
+
` ${appName} [run] [options] 启动后台常驻服务(默认开启本机 Web API,按需开启钉钉)`,
|
|
341
|
+
` ${appName} tui [options] [prompt] 在终端与助手交互对话(自动连接常驻服务或内嵌运行)`,
|
|
342
|
+
` ${appName} auth status|login|logout 管理模型供应商登录凭据(订阅 OAuth / API Key)`,
|
|
343
|
+
` ${appName} webapi key add|list|remove 管理 Web API 访问密钥`,
|
|
257
344
|
];
|
|
258
345
|
}
|
|
259
346
|
export function parseArgs(argv, paths = DEFAULT_BOOTSTRAP_PATHS, io = console) {
|
|
@@ -265,16 +352,16 @@ export function parseArgs(argv, paths = DEFAULT_BOOTSTRAP_PATHS, io = console) {
|
|
|
265
352
|
continue;
|
|
266
353
|
}
|
|
267
354
|
if (arg === "--help" || arg === "-h") {
|
|
268
|
-
io.log(
|
|
355
|
+
io.log("用法:");
|
|
269
356
|
for (const line of formatCliCommandsHelp(paths.appName))
|
|
270
357
|
io.log(line);
|
|
271
358
|
io.log("");
|
|
272
|
-
io.log("
|
|
273
|
-
io.log(" --version
|
|
274
|
-
io.log(" --help, -h
|
|
359
|
+
io.log("选项:");
|
|
360
|
+
io.log(" --version 输出当前版本号并退出");
|
|
361
|
+
io.log(" --help, -h 显示帮助信息并退出");
|
|
275
362
|
io.log("");
|
|
276
|
-
io.log(
|
|
277
|
-
io.log(
|
|
363
|
+
io.log(`渠道配置:${paths.channelConfigPath}`);
|
|
364
|
+
io.log(`工作空间:${paths.workspaceDir}`);
|
|
278
365
|
throw new BootstrapExitError(0);
|
|
279
366
|
}
|
|
280
367
|
else if (arg === "--version") {
|
|
@@ -282,8 +369,8 @@ export function parseArgs(argv, paths = DEFAULT_BOOTSTRAP_PATHS, io = console) {
|
|
|
282
369
|
throw new BootstrapExitError(0);
|
|
283
370
|
}
|
|
284
371
|
else {
|
|
285
|
-
io.error(
|
|
286
|
-
io.error(
|
|
372
|
+
io.error(`未知参数:${arg}`);
|
|
373
|
+
io.error(`运行 \`${paths.appName} --help\` 查看用法。`);
|
|
287
374
|
throw new BootstrapExitError(1);
|
|
288
375
|
}
|
|
289
376
|
}
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
export declare const MAX_INBOUND_IMAGE_BYTES: number;
|
|
15
15
|
/** Defensive hard cap on how many images one inbound message can carry. */
|
|
16
16
|
export declare const MAX_INBOUND_IMAGES_PER_MESSAGE = 10;
|
|
17
|
+
/** Inbound file attachment cap (matches DingTalk's 20MB robot file limit). */
|
|
18
|
+
export declare const MAX_INBOUND_FILE_BYTES: number;
|
|
19
|
+
/** Defensive hard cap on how many non-image file attachments one inbound message can carry. */
|
|
20
|
+
export declare const MAX_INBOUND_FILES_PER_MESSAGE = 4;
|
|
17
21
|
/**
|
|
18
22
|
* Identify a downloaded file's real format from its magic bytes rather than trusting the
|
|
19
23
|
* `Content-Type` DingTalk's CDN happens to answer with (spec 049 D8) — the four formats `read`
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
export const MAX_INBOUND_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
15
15
|
/** Defensive hard cap on how many images one inbound message can carry. */
|
|
16
16
|
export const MAX_INBOUND_IMAGES_PER_MESSAGE = 10;
|
|
17
|
+
/** Inbound file attachment cap (matches DingTalk's 20MB robot file limit). */
|
|
18
|
+
export const MAX_INBOUND_FILE_BYTES = 20 * 1024 * 1024;
|
|
19
|
+
/** Defensive hard cap on how many non-image file attachments one inbound message can carry. */
|
|
20
|
+
export const MAX_INBOUND_FILES_PER_MESSAGE = 4;
|
|
17
21
|
/**
|
|
18
22
|
* Identify a downloaded file's real format from its magic bytes rather than trusting the
|
|
19
23
|
* `Content-Type` DingTalk's CDN happens to answer with (spec 049 D8) — the four formats `read`
|
|
@@ -35,9 +35,15 @@ export type TurnEvent = {
|
|
|
35
35
|
ok: boolean;
|
|
36
36
|
output: string;
|
|
37
37
|
failure?: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: "reasoning.delta";
|
|
40
|
+
delta: string;
|
|
38
41
|
} | {
|
|
39
42
|
type: "reasoning";
|
|
40
43
|
text: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: "text.delta";
|
|
46
|
+
delta: string;
|
|
41
47
|
}
|
|
42
48
|
/**
|
|
43
49
|
* A line of the turn's narrative that is not the answer. Without a `level` it is the model's
|
package/dist/channel/config.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ export declare const CHANNEL_SECTION_NAMES: readonly ["dingtalk", "webapi"];
|
|
|
2
2
|
export type ChannelSectionName = (typeof CHANNEL_SECTION_NAMES)[number];
|
|
3
3
|
/** The raw content of every section that is switched on. */
|
|
4
4
|
export type EnabledChannelSections = Partial<Record<ChannelSectionName, unknown>>;
|
|
5
|
+
export declare const hashWebApiKey: (key: string) => string;
|
|
6
|
+
/** A new Web API bearer key: `pk_` and 256 random bits. Shown once; only its SHA-256 hash is persisted. */
|
|
7
|
+
export declare function generateWebApiKey(): string;
|
|
5
8
|
/** `channel.json` (or one of its sections) cannot be used; `issues` say what to fix. */
|
|
6
9
|
export declare class ChannelConfigError extends Error {
|
|
7
10
|
readonly issues: string[];
|
package/dist/channel/config.js
CHANGED
|
@@ -4,10 +4,16 @@
|
|
|
4
4
|
* that transport's own business, and a section that is off is never looked at beyond its switch,
|
|
5
5
|
* so credentials can stay in the file while a transport is disabled.
|
|
6
6
|
*/
|
|
7
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
7
8
|
import { docsUrl } from "../paths.js";
|
|
8
9
|
import { errorMessage } from "../shared/text-utils.js";
|
|
9
10
|
import { isPlainObject } from "../shared/type-guards.js";
|
|
10
11
|
export const CHANNEL_SECTION_NAMES = ["dingtalk", "webapi"];
|
|
12
|
+
export const hashWebApiKey = (key) => createHash("sha256").update(key).digest("hex");
|
|
13
|
+
/** A new Web API bearer key: `pk_` and 256 random bits. Shown once; only its SHA-256 hash is persisted. */
|
|
14
|
+
export function generateWebApiKey() {
|
|
15
|
+
return `pk_${randomBytes(32).toString("base64url")}`;
|
|
16
|
+
}
|
|
11
17
|
/** `channel.json` (or one of its sections) cannot be used; `issues` say what to fix. */
|
|
12
18
|
export class ChannelConfigError extends Error {
|
|
13
19
|
constructor(issues) {
|
|
@@ -22,15 +28,15 @@ export function parseChannelConfig(text) {
|
|
|
22
28
|
parsed = JSON.parse(text);
|
|
23
29
|
}
|
|
24
30
|
catch (error) {
|
|
25
|
-
throw new ChannelConfigError([`
|
|
31
|
+
throw new ChannelConfigError([`JSON 格式无效:${errorMessage(error)}`]);
|
|
26
32
|
}
|
|
27
33
|
if (!isPlainObject(parsed)) {
|
|
28
|
-
throw new ChannelConfigError(["
|
|
34
|
+
throw new ChannelConfigError(["顶层必须是包含 `dingtalk` 和/或 `webapi` 段的 JSON 对象。"]);
|
|
29
35
|
}
|
|
30
36
|
const issues = [];
|
|
31
37
|
for (const key of Object.keys(parsed)) {
|
|
32
38
|
if (!CHANNEL_SECTION_NAMES.includes(key)) {
|
|
33
|
-
issues.push(
|
|
39
|
+
issues.push(`未知的顶层配置项 \`${key}\`。channel.json 按渠道分段(${CHANNEL_SECTION_NAMES.map((name) => `\`${name}\``).join("、")}),请将渠道参数移入对应分段中(${docsUrl("configuration.md")})。`);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
36
42
|
const enabled = {};
|
|
@@ -39,11 +45,11 @@ export function parseChannelConfig(text) {
|
|
|
39
45
|
if (section === undefined)
|
|
40
46
|
continue;
|
|
41
47
|
if (!isPlainObject(section)) {
|
|
42
|
-
issues.push(`\`${name}\`
|
|
48
|
+
issues.push(`\`${name}\` 段必须是 JSON 对象。`);
|
|
43
49
|
continue;
|
|
44
50
|
}
|
|
45
51
|
if (typeof section.enabled !== "boolean") {
|
|
46
|
-
issues.push(`\`${name}.enabled\`
|
|
52
|
+
issues.push(`\`${name}.enabled\` 必须是布尔值(true 或 false)。`);
|
|
47
53
|
continue;
|
|
48
54
|
}
|
|
49
55
|
if (section.enabled)
|
package/dist/channel/store.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export interface LoggedSubAgentRun {
|
|
|
41
41
|
/** Spec 040, D7: the run this entry archives, and its lifecycle context. Only set on terminal archiving. */
|
|
42
42
|
runId?: string;
|
|
43
43
|
runtime?: "internal" | "external";
|
|
44
|
-
harness?:
|
|
44
|
+
harness?: string;
|
|
45
45
|
status?: "completed" | "failed" | "cancelled" | "lost";
|
|
46
46
|
taskId?: string;
|
|
47
47
|
artifactDir?: string;
|
package/dist/commands/catalog.js
CHANGED
|
@@ -50,19 +50,46 @@ export const BUILT_IN_COMMANDS = [
|
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
name: "desk",
|
|
53
|
-
argumentHint: "[list|new
|
|
54
|
-
description: "
|
|
55
|
-
// list/new answer mid-turn; bind refuses by itself while this channel is busy (spec 058, D5).
|
|
53
|
+
argumentHint: "[list|new <名字> [目录]|bind <名字>|cwd [目录|--reset]|archive <名字>|unarchive <名字>]",
|
|
54
|
+
description: "进阶:创建工位、配置仓库目录、切换绑定,或归档闲置工位",
|
|
55
|
+
// list/new/cwd/archive/unarchive answer mid-turn; bind refuses by itself while this channel is busy (spec 058, D5).
|
|
56
56
|
availableWhileBusy: true,
|
|
57
57
|
subcommands: [
|
|
58
|
-
{
|
|
59
|
-
|
|
58
|
+
{
|
|
59
|
+
name: "list",
|
|
60
|
+
description: "列出所有工位、工作目录、后台状态和绑定的频道(默认动作,可省略)",
|
|
61
|
+
example: "/desk",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "new",
|
|
65
|
+
args: "<名字> [目录绝对路径]",
|
|
66
|
+
description: "创建一个空工位(可选指定代码仓库绝对路径),不绑定任何频道",
|
|
67
|
+
example: "/desk new research",
|
|
68
|
+
},
|
|
60
69
|
{
|
|
61
70
|
name: "bind",
|
|
62
71
|
args: "<名字>",
|
|
63
|
-
description: "
|
|
72
|
+
description: "把本频道绑定到这个工位(已归档工位会自动恢复);回合进行中不能执行",
|
|
64
73
|
example: "/desk bind research",
|
|
65
74
|
},
|
|
75
|
+
{
|
|
76
|
+
name: "cwd",
|
|
77
|
+
args: "[目录绝对路径|--reset]",
|
|
78
|
+
description: "查看或设置当前工位的工作目录(状态仍保存在工位目录中)",
|
|
79
|
+
example: "/desk cwd /srv/repo",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "archive",
|
|
83
|
+
args: "<名字>",
|
|
84
|
+
description: "归档闲置工位:停止定时事件并清理残留终端绑定(默认工位不可归档)",
|
|
85
|
+
example: "/desk archive research",
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "unarchive",
|
|
89
|
+
args: "<名字>",
|
|
90
|
+
description: "恢复已归档的工位,不改变当前频道绑定",
|
|
91
|
+
example: "/desk unarchive research",
|
|
92
|
+
},
|
|
66
93
|
],
|
|
67
94
|
},
|
|
68
95
|
{
|
|
@@ -89,8 +116,8 @@ export const BUILT_IN_COMMANDS = [
|
|
|
89
116
|
},
|
|
90
117
|
{
|
|
91
118
|
name: "tasks",
|
|
92
|
-
argumentHint: "[show <id>|log <id>|msg <id> <内容>|pause <id>|resume <id> [+steps N|+usd X]|cancel <id>|archive|doctor]",
|
|
93
|
-
description: "
|
|
119
|
+
argumentHint: "[show <id>|log <id>|msg <id> <内容>|adopt <id>|pause <id>|resume <id> [+steps N|+usd X]|cancel <id>|archive|doctor]",
|
|
120
|
+
description: "查看、对话、接管、暂停与取消本工位在后台执行的长程任务;任务与聊天互不占用",
|
|
94
121
|
availableWhileBusy: true,
|
|
95
122
|
subcommands: [
|
|
96
123
|
{ name: "list", description: "列出本工位进行中的任务(默认动作,可省略)", example: "/tasks" },
|
|
@@ -106,13 +133,18 @@ export const BUILT_IN_COMMANDS = [
|
|
|
106
133
|
description: "查看该任务的记录(含每次委派的开始与结束)",
|
|
107
134
|
example: "/tasks log weekly-report",
|
|
108
135
|
},
|
|
109
|
-
{ name: "archive", description: "列出已归档(已关闭)的任务", example: "/tasks archive" },
|
|
110
136
|
{
|
|
111
137
|
name: "msg",
|
|
112
138
|
args: "<id> <内容>",
|
|
113
139
|
description: "对任务说话:步骤执行中直接送进当前步骤,否则排给下一步;也是回答任务提问的方式",
|
|
114
140
|
example: "/tasks msg weekly-report 先跑一遍 npm run check",
|
|
115
141
|
},
|
|
142
|
+
{
|
|
143
|
+
name: "adopt",
|
|
144
|
+
args: "<id>",
|
|
145
|
+
description: "把任务的汇报频道改到当前频道,立即接收暂存汇报并继续交互",
|
|
146
|
+
example: "/tasks adopt weekly-report",
|
|
147
|
+
},
|
|
116
148
|
{
|
|
117
149
|
name: "pause",
|
|
118
150
|
args: "<id>",
|
|
@@ -194,7 +226,7 @@ export const BUILT_IN_COMMANDS = [
|
|
|
194
226
|
name: "roles",
|
|
195
227
|
args: "[name]",
|
|
196
228
|
description: "角色目录;带 name 时查看单个角色的详情",
|
|
197
|
-
example: "/subagents roles
|
|
229
|
+
example: "/subagents roles codex-high",
|
|
198
230
|
},
|
|
199
231
|
],
|
|
200
232
|
},
|
package/dist/commands/router.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { renderStatus } from "../agent/status-render.js";
|
|
2
2
|
import { handleDeskCommand } from "../desk/commands.js";
|
|
3
3
|
import { handleEventsCommand } from "../events/commands.js";
|
|
4
|
+
import { loadSecurityConfigWithDiagnostics } from "../security/config.js";
|
|
4
5
|
import { handleSkillsCommand } from "../skills/commands.js";
|
|
5
6
|
import { handleSubagentsCommand } from "../subagents/commands.js";
|
|
6
7
|
import { loadDetachedSubAgentDiscovery } from "../subagents/detached-discovery.js";
|
|
@@ -15,14 +16,17 @@ export async function runReportCommand(context, name, args) {
|
|
|
15
16
|
const { conversation, paths } = context;
|
|
16
17
|
const { channelId, desk, deskDir } = conversation;
|
|
17
18
|
switch (name) {
|
|
18
|
-
case "events":
|
|
19
|
+
case "events": {
|
|
20
|
+
const security = loadSecurityConfigWithDiagnostics(paths.appHomeDir).config;
|
|
19
21
|
return handleEventsCommand({
|
|
20
22
|
args,
|
|
21
23
|
desk,
|
|
22
24
|
deskDir,
|
|
23
25
|
historyPath: paths.eventHistoryPath,
|
|
26
|
+
commandGuardConfig: security.enabled ? security.commandGuard : undefined,
|
|
24
27
|
describeChannel: context.describeChannel,
|
|
25
28
|
});
|
|
29
|
+
}
|
|
26
30
|
case "tasks":
|
|
27
31
|
return handleTasksCommand({
|
|
28
32
|
args,
|
package/dist/desk/commands.d.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import type { BindingsFile, CreateDeskOutcome, DeskAvailability, DeskSummary } from "./types.js";
|
|
1
|
+
import type { ArchiveDeskOutcome, BindingsFile, CreateDeskOutcome, DeskAvailability, DeskCwdOutcome, DeskSummary, UnarchiveDeskOutcome } from "./types.js";
|
|
2
2
|
type DeskCommand = {
|
|
3
3
|
action: "list";
|
|
4
4
|
} | {
|
|
5
5
|
action: "new";
|
|
6
6
|
name: string;
|
|
7
|
+
cwd?: string;
|
|
7
8
|
} | {
|
|
8
9
|
action: "bind";
|
|
9
10
|
name: string;
|
|
11
|
+
} | {
|
|
12
|
+
action: "cwd";
|
|
13
|
+
cwd?: string;
|
|
14
|
+
reset?: boolean;
|
|
15
|
+
} | {
|
|
16
|
+
action: "archive";
|
|
17
|
+
name: string;
|
|
18
|
+
} | {
|
|
19
|
+
action: "unarchive";
|
|
20
|
+
name: string;
|
|
10
21
|
};
|
|
11
22
|
/** One channel bound to a desk, as `/desk list` shows it. */
|
|
12
23
|
export interface DeskListChannel {
|
|
@@ -14,20 +25,39 @@ export interface DeskListChannel {
|
|
|
14
25
|
/** Rendered by the caller (`channel/channel-id.ts`'s `formatChannelLabel`); desk never parses channel ids. */
|
|
15
26
|
label: string;
|
|
16
27
|
}
|
|
28
|
+
export interface DeskRuntimeActivity {
|
|
29
|
+
/** Open runnable/waiting tasks in this desk. */
|
|
30
|
+
activeTasks: number;
|
|
31
|
+
/** Outbound task reports/receipts queued in `.delivery/` waiting for a channel. */
|
|
32
|
+
pendingDeliveries: number;
|
|
33
|
+
/** Whether the desk is currently active in `DeskRuntime` (e.g. background tasks or task-spawning events). */
|
|
34
|
+
active: boolean;
|
|
35
|
+
}
|
|
17
36
|
export interface DeskListItem {
|
|
18
37
|
name: string;
|
|
19
38
|
availability: DeskAvailability;
|
|
20
39
|
channels: DeskListChannel[];
|
|
21
40
|
/** The desk the asking channel is bound to (or, in the TUI, the desk it opened). */
|
|
22
41
|
current: boolean;
|
|
42
|
+
/** Custom working directory when `desk.json` overrides `deskDir`. */
|
|
43
|
+
cwd?: string;
|
|
44
|
+
/** Set when `desk.json` carries `archivedAt`. */
|
|
45
|
+
archived?: boolean;
|
|
46
|
+
activeTasks?: number;
|
|
47
|
+
pendingDeliveries?: number;
|
|
48
|
+
backgroundActive?: boolean;
|
|
23
49
|
}
|
|
24
50
|
export type BindOutcome = {
|
|
25
51
|
kind: "bound";
|
|
26
52
|
desk: string;
|
|
53
|
+
/** Set when binding to an archived desk automatically restored it. */
|
|
54
|
+
unarchived?: boolean;
|
|
27
55
|
previousDesk?: string;
|
|
28
|
-
/** The previous desk lost its last binding and went dormant. */
|
|
56
|
+
/** The previous desk lost its last binding and has no background work, so it went dormant. */
|
|
29
57
|
previousDeskDormant?: boolean;
|
|
30
|
-
/** Open tasks
|
|
58
|
+
/** Open tasks in the previous desk that keep running in the background (deliveries held until rebound). */
|
|
59
|
+
backgroundTasks?: number;
|
|
60
|
+
/** Open tasks / chat events in the previous desk that deliver to this channel and are suspended. */
|
|
31
61
|
suspendedTasks?: number;
|
|
32
62
|
suspendedEvents?: number;
|
|
33
63
|
} | {
|
|
@@ -54,14 +84,23 @@ export type BindOutcome = {
|
|
|
54
84
|
* (shown missing, D4), each with the channels bound to it. `label` names a channel (the caller
|
|
55
85
|
* owns channel ids); `current` is the asking channel's desk.
|
|
56
86
|
*/
|
|
57
|
-
export declare function buildDeskList(desks: readonly DeskSummary[], bindings: BindingsFile["bindings"], current: string | undefined, label: (channelId: string) => string): DeskListItem[];
|
|
87
|
+
export declare function buildDeskList(desks: readonly DeskSummary[], bindings: BindingsFile["bindings"], current: string | undefined, label: (channelId: string) => string, activity?: ReadonlyMap<string, DeskRuntimeActivity>): DeskListItem[];
|
|
58
88
|
export interface DeskCommandPort {
|
|
59
89
|
list(): Promise<DeskListItem[]>;
|
|
60
90
|
/** Absolute path of `CHANNELS.md`, where a truncated `/desk list` sends the reader. */
|
|
61
91
|
channelIndexPath: string;
|
|
62
|
-
create(name: string): Promise<CreateDeskOutcome>;
|
|
92
|
+
create(name: string, cwd?: string): Promise<CreateDeskOutcome>;
|
|
63
93
|
/** Absent in the TUI, which never writes bindings (D18). */
|
|
64
94
|
bind?(name: string): Promise<BindOutcome>;
|
|
95
|
+
/** Inspect or update the current desk's working directory (`desk.json` `cwd`). */
|
|
96
|
+
cwd?(input: {
|
|
97
|
+
cwd?: string;
|
|
98
|
+
reset?: boolean;
|
|
99
|
+
}): Promise<DeskCwdOutcome>;
|
|
100
|
+
/** Archive an idle desk (`desk.json` `archivedAt`, stopping events and dropping stale TUI bindings). */
|
|
101
|
+
archive?(name: string): Promise<ArchiveDeskOutcome>;
|
|
102
|
+
/** Restore an archived desk without changing channel bindings. */
|
|
103
|
+
unarchive?(name: string): Promise<UnarchiveDeskOutcome>;
|
|
65
104
|
}
|
|
66
105
|
/** Exported so `test/commands-subcommands.test.ts` can feed every broadcast example back through it. */
|
|
67
106
|
export declare function parseDeskCommand(args: string): DeskCommand;
|