@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
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* App-home scaffolding: create `~/.pipiclaw` (or `PIPICLAW_HOME`) on first run
|
|
3
|
-
* `channel.json
|
|
2
|
+
* App-home scaffolding: create `~/.pipiclaw` (or `PIPICLAW_HOME`) on first run (writing the
|
|
3
|
+
* `channel.json` template; `dingtalk/config.ts` loads and validates it), and parse CLI args
|
|
4
|
+
* shared by every entrypoint. Pure functions over explicit
|
|
4
5
|
* `paths`/`io` parameters — no dependency on the runtime wiring in `bootstrap.ts`.
|
|
5
6
|
*/
|
|
6
7
|
import { chmodSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
|
|
7
8
|
import { join } from "path";
|
|
9
|
+
import { DEFAULT_AGENTS, DEFAULT_SOUL } from "../agent/prompt/workspace-templates.js";
|
|
8
10
|
import * as log from "../log.js";
|
|
9
|
-
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";
|
|
11
|
+
import { APP_HOME_DIR, APP_NAME, AUTH_CONFIG_PATH, CHANNEL_CONFIG_PATH, docsUrl, EVENT_HISTORY_PATH, MODELS_CONFIG_PATH, SECURITY_CONFIG_PATH, SETTINGS_CONFIG_PATH, TOOLS_CONFIG_PATH, WORKSPACE_DIR, } from "../paths.js";
|
|
10
12
|
import { errorMessage } from "../shared/text-utils.js";
|
|
11
|
-
import { isBusyMessageDefaultConfig, isResponseModeConfig, normalizeBusyMessageDefault, normalizeResponseMode, } from "./dingtalk.js";
|
|
12
|
-
import { DEFAULT_AGENTS, DEFAULT_SOUL } from "./workspace-templates.js";
|
|
13
13
|
const DEFAULT_MEMORY = `# Workspace Memory
|
|
14
14
|
|
|
15
15
|
This file stores stable workspace-level memory.
|
|
@@ -158,7 +158,10 @@ function hardenExistingSecretFile(path) {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
catch (err) {
|
|
161
|
-
log.
|
|
161
|
+
log.logWarn("runtime.permissions.tighten_failed", "Config file permission tightening failed", {
|
|
162
|
+
reason: errorMessage(err),
|
|
163
|
+
fields: { path },
|
|
164
|
+
});
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
167
|
export function bootstrapAppHome(paths = DEFAULT_BOOTSTRAP_PATHS) {
|
|
@@ -202,46 +205,6 @@ export function bootstrapAppHome(paths = DEFAULT_BOOTSTRAP_PATHS) {
|
|
|
202
205
|
}
|
|
203
206
|
return { created, channelTemplateCreated };
|
|
204
207
|
}
|
|
205
|
-
function isPlaceholderString(value) {
|
|
206
|
-
return value.trim().startsWith("your-");
|
|
207
|
-
}
|
|
208
|
-
function listChannelConfigIssues(config) {
|
|
209
|
-
const issues = [];
|
|
210
|
-
if (!config.clientId) {
|
|
211
|
-
issues.push("Missing required field `clientId`.");
|
|
212
|
-
}
|
|
213
|
-
else if (isPlaceholderString(config.clientId)) {
|
|
214
|
-
issues.push("Replace placeholder value for `clientId`.");
|
|
215
|
-
}
|
|
216
|
-
if (!config.clientSecret) {
|
|
217
|
-
issues.push("Missing required field `clientSecret`.");
|
|
218
|
-
}
|
|
219
|
-
else if (isPlaceholderString(config.clientSecret)) {
|
|
220
|
-
issues.push("Replace placeholder value for `clientSecret`.");
|
|
221
|
-
}
|
|
222
|
-
if (config.robotCode && isPlaceholderString(config.robotCode)) {
|
|
223
|
-
issues.push("Replace placeholder value for `robotCode`, or set it to an empty string to reuse `clientId`.");
|
|
224
|
-
}
|
|
225
|
-
if (config.cardTemplateId && isPlaceholderString(config.cardTemplateId)) {
|
|
226
|
-
issues.push("Replace placeholder value for `cardTemplateId`, or set it to an empty string to disable AI Card streaming.");
|
|
227
|
-
}
|
|
228
|
-
if (Array.isArray(config.allowFrom) && config.allowFrom.some((value) => isPlaceholderString(value))) {
|
|
229
|
-
issues.push("Replace placeholder values in `allowFrom`, or set it to an empty array to allow all users.");
|
|
230
|
-
}
|
|
231
|
-
const busyMessageDefault = config.busyMessageDefault;
|
|
232
|
-
if (busyMessageDefault !== undefined && !isBusyMessageDefaultConfig(busyMessageDefault)) {
|
|
233
|
-
issues.push('Invalid `busyMessageDefault`: expected "steer", "followUp", or "followup".');
|
|
234
|
-
}
|
|
235
|
-
const responseMode = config.responseMode;
|
|
236
|
-
if (responseMode !== undefined && !isResponseModeConfig(responseMode)) {
|
|
237
|
-
issues.push('Invalid `responseMode`: expected "full_progress_then_plain_final", "rolling_progress_then_plain_final", or "final_card_only".');
|
|
238
|
-
}
|
|
239
|
-
const cardAutoLayout = config.cardAutoLayout;
|
|
240
|
-
if (cardAutoLayout !== undefined && typeof cardAutoLayout !== "boolean") {
|
|
241
|
-
issues.push("Invalid `cardAutoLayout`: expected boolean.");
|
|
242
|
-
}
|
|
243
|
-
return issues;
|
|
244
|
-
}
|
|
245
208
|
export function printBootstrapSummary(result, io = console, paths = DEFAULT_BOOTSTRAP_PATHS) {
|
|
246
209
|
if (result.created.length === 0) {
|
|
247
210
|
return;
|
|
@@ -252,35 +215,19 @@ export function printBootstrapSummary(result, io = console, paths = DEFAULT_BOOT
|
|
|
252
215
|
}
|
|
253
216
|
io.log("");
|
|
254
217
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
for (const issue of issues) {
|
|
269
|
-
io.error(` - ${issue}`);
|
|
270
|
-
}
|
|
271
|
-
io.error("");
|
|
272
|
-
io.error(`Fill in ${paths.channelConfigPath} and run \`${paths.appName}\` again.`);
|
|
273
|
-
throw new BootstrapExitError(1);
|
|
274
|
-
}
|
|
275
|
-
parsed.cardTemplateKey = parsed.cardTemplateKey || "content";
|
|
276
|
-
parsed.robotCode = parsed.robotCode?.trim() ? parsed.robotCode : parsed.clientId;
|
|
277
|
-
parsed.busyMessageDefault = normalizeBusyMessageDefault(parsed.busyMessageDefault);
|
|
278
|
-
parsed.responseMode = normalizeResponseMode(parsed.responseMode);
|
|
279
|
-
parsed.cardAutoLayout = parsed.cardAutoLayout ?? true;
|
|
280
|
-
if (Array.isArray(parsed.allowFrom)) {
|
|
281
|
-
parsed.allowFrom = parsed.allowFrom.filter((value) => value.trim().length > 0);
|
|
282
|
-
}
|
|
283
|
-
return parsed;
|
|
218
|
+
/**
|
|
219
|
+
* What a new deployer does after the very first run created the templates (spec 053, D11). A
|
|
220
|
+
* fresh template is not an error, so the caller exits 0 after this; it names the required fields,
|
|
221
|
+
* where they come from, and the model credential step the daemon cannot run without.
|
|
222
|
+
*/
|
|
223
|
+
export function printFirstRunGuide(io = console, paths = DEFAULT_BOOTSTRAP_PATHS) {
|
|
224
|
+
io.log("Next steps:");
|
|
225
|
+
io.log(` 1. Edit ${paths.channelConfigPath} — required: clientId, clientSecret`);
|
|
226
|
+
io.log(" (DingTalk Open Platform → your app → Credentials). Optional: cardTemplateId for AI Card");
|
|
227
|
+
io.log(" streaming; set it to an empty string to disable cards.");
|
|
228
|
+
io.log(` 2. Configure a model: run \`${paths.appName} auth login\`, or add a provider to ${paths.modelsConfigPath}.`);
|
|
229
|
+
io.log(` 3. Run \`${paths.appName}\` again.`);
|
|
230
|
+
io.log(`Docs: ${docsUrl("configuration.md")}`);
|
|
284
231
|
}
|
|
285
232
|
/**
|
|
286
233
|
* The one place that lists `pipiclaw`'s top-level subcommands. `parseArgs`'s own `--help` uses it;
|
|
@@ -41,11 +41,13 @@ export function installLlmProxy() {
|
|
|
41
41
|
parsed = new URL(explicitProxy);
|
|
42
42
|
}
|
|
43
43
|
catch {
|
|
44
|
-
log.
|
|
44
|
+
log.logWarn("runtime.proxy.invalid", "PIPICLAW_PROXY is not a valid URL; LLM requests connect directly", {
|
|
45
|
+
reason: explicitProxy,
|
|
46
|
+
});
|
|
45
47
|
return { installed: false, source: "none" };
|
|
46
48
|
}
|
|
47
49
|
if (!SUPPORTED_PROXY_PROTOCOLS.has(parsed.protocol)) {
|
|
48
|
-
log.
|
|
50
|
+
log.logWarn("runtime.proxy.unsupported", "PIPICLAW_PROXY protocol unsupported (http/https only, no SOCKS); LLM requests connect directly", { reason: explicitProxy, fields: { protocol: parsed.protocol } });
|
|
49
51
|
return { installed: false, source: "none" };
|
|
50
52
|
}
|
|
51
53
|
const noProxy = process.env.PIPICLAW_NO_PROXY?.trim();
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { PipiclawSettingsManager } from "../config/settings.js";
|
|
2
|
+
import { type BootstrapPaths } from "./home.js";
|
|
3
3
|
/**
|
|
4
4
|
* Transport-neutral app services shared by the DingTalk runtime, the terminal TUI, and the
|
|
5
5
|
* `pipiclaw auth` CLI: loads settings (surfacing load errors) and reports tool/security config
|
|
6
6
|
* diagnostics. Does NOT touch DingTalk config, so non-DingTalk entrypoints can call it without
|
|
7
7
|
* any DingTalk credentials.
|
|
8
8
|
*
|
|
9
|
-
* Lives
|
|
9
|
+
* Lives in `app/` rather than in `runtime/` on purpose: `app/auth-command.ts` needs it
|
|
10
10
|
* before a runner or channel exists, and `runtime/bootstrap.ts` separately depends on `models/`
|
|
11
11
|
* (for the default model reference) — parking this function inside `bootstrap.ts` made `models`
|
|
12
|
-
* and `runtime` depend on each other. Everything this function touches (`settings.ts`,
|
|
13
|
-
* `tools
|
|
12
|
+
* and `runtime` depend on each other. Everything this function touches (`config/settings.ts`,
|
|
13
|
+
* `config/tools.ts`, `security/config.ts`, `app/home.ts`, `app/proxy.ts`) has no
|
|
14
14
|
* import back to `models/`, so this file doesn't reintroduce the cycle it was extracted to break.
|
|
15
15
|
*/
|
|
16
16
|
export declare function prepareAppServices(paths?: BootstrapPaths): {
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { loadSecurityConfigWithDiagnostics } from "
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { PipiclawSettingsManager } from "../config/settings.js";
|
|
2
|
+
import { loadToolsConfigWithDiagnostics } from "../config/tools.js";
|
|
3
|
+
import * as log from "../log.js";
|
|
4
|
+
import { loadSecurityConfigWithDiagnostics } from "../security/config.js";
|
|
5
|
+
import { formatConfigDiagnostic } from "../shared/config-diagnostic.js";
|
|
6
|
+
import { DEFAULT_BOOTSTRAP_PATHS } from "./home.js";
|
|
7
|
+
import { installLlmProxy } from "./proxy.js";
|
|
8
8
|
/**
|
|
9
9
|
* Transport-neutral app services shared by the DingTalk runtime, the terminal TUI, and the
|
|
10
10
|
* `pipiclaw auth` CLI: loads settings (surfacing load errors) and reports tool/security config
|
|
11
11
|
* diagnostics. Does NOT touch DingTalk config, so non-DingTalk entrypoints can call it without
|
|
12
12
|
* any DingTalk credentials.
|
|
13
13
|
*
|
|
14
|
-
* Lives
|
|
14
|
+
* Lives in `app/` rather than in `runtime/` on purpose: `app/auth-command.ts` needs it
|
|
15
15
|
* before a runner or channel exists, and `runtime/bootstrap.ts` separately depends on `models/`
|
|
16
16
|
* (for the default model reference) — parking this function inside `bootstrap.ts` made `models`
|
|
17
|
-
* and `runtime` depend on each other. Everything this function touches (`settings.ts`,
|
|
18
|
-
* `tools
|
|
17
|
+
* and `runtime` depend on each other. Everything this function touches (`config/settings.ts`,
|
|
18
|
+
* `config/tools.ts`, `security/config.ts`, `app/home.ts`, `app/proxy.ts`) has no
|
|
19
19
|
* import back to `models/`, so this file doesn't reintroduce the cycle it was extracted to break.
|
|
20
20
|
*/
|
|
21
21
|
export function prepareAppServices(paths = DEFAULT_BOOTSTRAP_PATHS) {
|
|
@@ -24,20 +24,23 @@ export function prepareAppServices(paths = DEFAULT_BOOTSTRAP_PATHS) {
|
|
|
24
24
|
installLlmProxy();
|
|
25
25
|
const settingsManager = new PipiclawSettingsManager(paths.appHomeDir);
|
|
26
26
|
for (const { scope, error } of settingsManager.drainErrors()) {
|
|
27
|
-
log.
|
|
27
|
+
log.logWarn("config.settings.load_failed", "Settings load failed", {
|
|
28
|
+
reason: error.message,
|
|
29
|
+
fields: { scope, path: paths.settingsConfigPath },
|
|
30
|
+
});
|
|
28
31
|
}
|
|
29
32
|
// Errors already went out above with a richer message; this pass exists for the
|
|
30
33
|
// warnings, chiefly retired settings keys (spec 035 D3).
|
|
31
34
|
for (const diagnostic of settingsManager.getDiagnostics()) {
|
|
32
35
|
if (diagnostic.severity === "error")
|
|
33
36
|
continue;
|
|
34
|
-
log.
|
|
37
|
+
log.logWarn("config.diagnostic", formatConfigDiagnostic(diagnostic), { fields: { path: diagnostic.path } });
|
|
35
38
|
}
|
|
36
39
|
for (const diagnostic of loadToolsConfigWithDiagnostics(paths.appHomeDir).diagnostics) {
|
|
37
|
-
log.
|
|
40
|
+
log.logWarn("config.diagnostic", formatConfigDiagnostic(diagnostic), { fields: { path: diagnostic.path } });
|
|
38
41
|
}
|
|
39
42
|
for (const diagnostic of loadSecurityConfigWithDiagnostics(paths.appHomeDir).diagnostics) {
|
|
40
|
-
log.
|
|
43
|
+
log.logWarn("config.diagnostic", formatConfigDiagnostic(diagnostic), { fields: { path: diagnostic.path } });
|
|
41
44
|
}
|
|
42
45
|
return { settingsManager };
|
|
43
46
|
}
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `ChannelContext` is the surface a `ChannelRunner` turn writes to: progress
|
|
5
5
|
* updates, the final answer, side notices, and lifecycle hooks. The DingTalk
|
|
6
|
-
* transport implements it via AI Card streaming (`
|
|
6
|
+
* transport implements it via AI Card streaming (`dingtalk/delivery.ts`); the
|
|
7
7
|
* terminal TUI implements it by rendering to the console (`tui/`). The runner
|
|
8
8
|
* and `session-events` depend only on this interface, never on a concrete
|
|
9
9
|
* transport.
|
|
10
10
|
*
|
|
11
|
-
* These declarations previously lived in `
|
|
11
|
+
* These declarations previously lived in `dingtalk/bot.ts` under the name
|
|
12
12
|
* `DingTalkContext`; they were lifted out (and renamed) so a second transport
|
|
13
13
|
* can implement the contract without importing anything DingTalk-specific. They
|
|
14
14
|
* live in `src/channel/` rather than `src/runtime/` because a port belongs with
|
|
@@ -24,6 +24,16 @@ import type { InboundImage } from "./channel-event.js";
|
|
|
24
24
|
export type ProgressStyle = "full" | "rolling" | "none";
|
|
25
25
|
/** How the final answer is delivered. */
|
|
26
26
|
export type FinalDelivery = "plain" | "card";
|
|
27
|
+
/**
|
|
28
|
+
* User-facing delivery preset (`channel.json` `responseMode`, `settings.json` `tui.responseMode`).
|
|
29
|
+
* Transport-neutral on purpose: the DingTalk bot and the TUI both map it onto
|
|
30
|
+
* `ProgressStyle` / `FinalDelivery` and nothing else should branch on the raw strings.
|
|
31
|
+
*/
|
|
32
|
+
export type ResponseMode = "full_progress_then_plain_final" | "rolling_progress_then_plain_final" | "final_card_only";
|
|
33
|
+
export declare function progressStyleOf(mode: ResponseMode): ProgressStyle;
|
|
34
|
+
export declare function finalDeliveryOf(mode: ResponseMode): FinalDelivery;
|
|
35
|
+
export declare function isResponseModeConfig(value: unknown): value is ResponseMode;
|
|
36
|
+
export declare function normalizeResponseMode(value: unknown): ResponseMode;
|
|
27
37
|
/**
|
|
28
38
|
* A file the agent wants to push to a channel as a native attachment (image or
|
|
29
39
|
* downloadable file), as opposed to text/markdown in the transcript.
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `ChannelContext` is the surface a `ChannelRunner` turn writes to: progress
|
|
5
5
|
* updates, the final answer, side notices, and lifecycle hooks. The DingTalk
|
|
6
|
-
* transport implements it via AI Card streaming (`
|
|
6
|
+
* transport implements it via AI Card streaming (`dingtalk/delivery.ts`); the
|
|
7
7
|
* terminal TUI implements it by rendering to the console (`tui/`). The runner
|
|
8
8
|
* and `session-events` depend only on this interface, never on a concrete
|
|
9
9
|
* transport.
|
|
10
10
|
*
|
|
11
|
-
* These declarations previously lived in `
|
|
11
|
+
* These declarations previously lived in `dingtalk/bot.ts` under the name
|
|
12
12
|
* `DingTalkContext`; they were lifted out (and renamed) so a second transport
|
|
13
13
|
* can implement the contract without importing anything DingTalk-specific. They
|
|
14
14
|
* live in `src/channel/` rather than `src/runtime/` because a port belongs with
|
|
@@ -16,6 +16,33 @@
|
|
|
16
16
|
* `tui` all depend on this file, and none of them should be reading anything out
|
|
17
17
|
* of the DingTalk transport's directory to get it.
|
|
18
18
|
*/
|
|
19
|
+
const RESPONSE_MODE_VALUES = [
|
|
20
|
+
"full_progress_then_plain_final",
|
|
21
|
+
"rolling_progress_then_plain_final",
|
|
22
|
+
"final_card_only",
|
|
23
|
+
];
|
|
24
|
+
export function progressStyleOf(mode) {
|
|
25
|
+
if (mode === "final_card_only")
|
|
26
|
+
return "none";
|
|
27
|
+
if (mode === "rolling_progress_then_plain_final")
|
|
28
|
+
return "rolling";
|
|
29
|
+
return "full";
|
|
30
|
+
}
|
|
31
|
+
export function finalDeliveryOf(mode) {
|
|
32
|
+
return mode === "final_card_only" ? "card" : "plain";
|
|
33
|
+
}
|
|
34
|
+
export function isResponseModeConfig(value) {
|
|
35
|
+
return typeof value === "string" && RESPONSE_MODE_VALUES.includes(value);
|
|
36
|
+
}
|
|
37
|
+
export function normalizeResponseMode(value) {
|
|
38
|
+
if (value === undefined) {
|
|
39
|
+
return "full_progress_then_plain_final";
|
|
40
|
+
}
|
|
41
|
+
if (isResponseModeConfig(value)) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
throw new Error('Invalid `responseMode`: expected "full_progress_then_plain_final", "rolling_progress_then_plain_final", or "final_card_only".');
|
|
45
|
+
}
|
|
19
46
|
/**
|
|
20
47
|
* A context whose user-visible writes are dropped (spec 051, D3).
|
|
21
48
|
*
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `MAX_IMAGE_BYTES` mirrors the *send* limit); this instead mirrors `tools/truncate.ts`'s
|
|
4
4
|
* `MAX_INLINE_BINARY_BYTES` — the same ceiling `read` already applies to an on-disk image — so
|
|
5
5
|
* "a picture the user sent" and "a picture `read` loads from disk" behave identically for the
|
|
6
|
-
* model. Lives here, not in the DingTalk-specific `
|
|
6
|
+
* model. Lives here, not in the DingTalk-specific `dingtalk/inbound-media.ts`, because both the
|
|
7
7
|
* transport (rejecting an oversized download) and `agent/channel-runner.ts` (skipping an
|
|
8
8
|
* oversized file before base64-encoding it) need the same number, and `agent/` never imports
|
|
9
9
|
* from `runtime/` (spec 049).
|
|
@@ -39,7 +39,7 @@ export interface InboundImage {
|
|
|
39
39
|
* A message or wake, from any producer: a real inbound DingTalk message, a scheduled event, a
|
|
40
40
|
* task-driver wake, or a job/subagent completion. `conversationId` is the one field genuinely
|
|
41
41
|
* DingTalk-specific (needed to reply into the right conversation); every synthetic producer
|
|
42
|
-
* (
|
|
42
|
+
* (jobs/manager, task-driver, events, subagents/runs) leaves it unset rather than faking a value,
|
|
43
43
|
* since it has no DingTalk conversation to route into. `conversationType` is not DingTalk-specific
|
|
44
44
|
* in practice — every producer, real or synthetic, can derive "1"/"2" from the channelId prefix —
|
|
45
45
|
* so it stays required.
|
|
@@ -80,3 +80,11 @@ export interface ChannelEvent {
|
|
|
80
80
|
*/
|
|
81
81
|
presentation?: "awaited";
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* The one thing in-process producers (scheduled events, durable dispatch) need from a transport:
|
|
85
|
+
* hand it a synthetic event for its per-channel queue. `false` means the queue rejected it (full
|
|
86
|
+
* or stopped), so the caller keeps ownership and may retry. Implemented by `DingTalkBot`.
|
|
87
|
+
*/
|
|
88
|
+
export interface ChannelEventSink {
|
|
89
|
+
enqueueEvent(event: ChannelEvent): boolean;
|
|
90
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `MAX_IMAGE_BYTES` mirrors the *send* limit); this instead mirrors `tools/truncate.ts`'s
|
|
4
4
|
* `MAX_INLINE_BINARY_BYTES` — the same ceiling `read` already applies to an on-disk image — so
|
|
5
5
|
* "a picture the user sent" and "a picture `read` loads from disk" behave identically for the
|
|
6
|
-
* model. Lives here, not in the DingTalk-specific `
|
|
6
|
+
* model. Lives here, not in the DingTalk-specific `dingtalk/inbound-media.ts`, because both the
|
|
7
7
|
* transport (rejecting an oversized download) and `agent/channel-runner.ts` (skipping an
|
|
8
8
|
* oversized file before base64-encoding it) need the same number, and `agent/` never imports
|
|
9
9
|
* from `runtime/` (spec 049).
|
|
@@ -282,7 +282,10 @@ export function createChannelIndex(options) {
|
|
|
282
282
|
})
|
|
283
283
|
.catch((error) => {
|
|
284
284
|
dirty = true;
|
|
285
|
-
log.
|
|
285
|
+
log.logWarn("channel.index.write_failed", "Channel index update failed", {
|
|
286
|
+
reason: errorMessage(error),
|
|
287
|
+
fields: { file: CHANNELS_INDEX_FILENAME },
|
|
288
|
+
});
|
|
286
289
|
});
|
|
287
290
|
return pending;
|
|
288
291
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `/project` — the human control path for a channel's project scope (spec 043, D7). Mirrors
|
|
3
|
-
* `
|
|
3
|
+
* `tasks/commands.ts`/`subagents/commands.ts`'s shape: pure-ish functions returning markdown, no
|
|
4
4
|
* bot/event coupling. Mutations never reach the model.
|
|
5
5
|
*/
|
|
6
6
|
type ProjectCommand = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { commitProjectSelection, readProjectSelection } from "../channel/project-scope-store.js";
|
|
2
1
|
import { renderSubcommandUsage } from "../commands/catalog.js";
|
|
3
2
|
import { loadSecurityConfigWithDiagnostics } from "../security/config.js";
|
|
4
3
|
import { currentProjectSandboxStatus, isWithinAllowedRoots, resolveExistingDirectory, resolveProjectAccessPolicy, } from "../security/project-scope.js";
|
|
5
4
|
import { errorMessage } from "../shared/text-utils.js";
|
|
5
|
+
import { commitProjectSelection, readProjectSelection } from "./project-scope-store.js";
|
|
6
6
|
function usage() {
|
|
7
7
|
return renderSubcommandUsage("project");
|
|
8
8
|
}
|
|
@@ -22,33 +22,34 @@ export function parseProjectCommand(args) {
|
|
|
22
22
|
throw new Error("用法:/project reset");
|
|
23
23
|
return { action: "reset" };
|
|
24
24
|
}
|
|
25
|
-
throw new Error(
|
|
25
|
+
throw new Error(`未知子命令 \`${parts[0]}\`。`);
|
|
26
26
|
}
|
|
27
27
|
function formatShow(options) {
|
|
28
28
|
const securityLoad = loadSecurityConfigWithDiagnostics(options.appHomeDir);
|
|
29
29
|
const resolution = resolveProjectAccessPolicy(securityLoad.config, process.cwd());
|
|
30
30
|
const sandbox = currentProjectSandboxStatus();
|
|
31
31
|
const selection = readProjectSelection(options.channelDir);
|
|
32
|
-
const lines = ["
|
|
32
|
+
const lines = ["**项目目录**"];
|
|
33
33
|
if (!selection) {
|
|
34
|
-
lines.push(`-
|
|
34
|
+
lines.push(`- 当前:\`${resolution.policy.defaultRoot}\`(尚未选择过,下一条消息起采用默认目录)`);
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
|
|
37
|
+
const by = selection.updatedBy === "tui-command" ? "终端" : "钉钉";
|
|
38
|
+
lines.push(`- 当前:\`${selection.projectRoot}\`(${by}中设置,更新于 ${selection.updatedAt})`);
|
|
38
39
|
}
|
|
39
|
-
lines.push(`-
|
|
40
|
-
lines.push(`-
|
|
40
|
+
lines.push(`- 访问范围:${resolution.configured ? "仅限项目目录(project)" : "不限制(unbounded,沿用全局文件权限)"}`);
|
|
41
|
+
lines.push(`- 隔离级别:${sandbox.level}(${sandbox.summary})`);
|
|
41
42
|
if (!resolution.configured) {
|
|
42
|
-
lines.push(
|
|
43
|
+
lines.push("- `/project set` 不可用:请部署者在 `security.json` 中配置 `projectAccess` 后再用。");
|
|
43
44
|
}
|
|
44
45
|
else if (!resolution.mutable) {
|
|
45
|
-
lines.push("- projectAccess.defaultRoot
|
|
46
|
+
lines.push("- `projectAccess.defaultRoot` 配置有误,项目切换已被禁用;请部署者查看启动日志。");
|
|
46
47
|
}
|
|
47
48
|
else {
|
|
48
|
-
lines.push(`-
|
|
49
|
+
lines.push(`- 允许的根目录:${resolution.policy.allowedRoots.map((root) => `\`${root}\``).join("、")}`);
|
|
49
50
|
}
|
|
50
51
|
for (const diagnostic of resolution.diagnostics) {
|
|
51
|
-
lines.push(`-
|
|
52
|
+
lines.push(`- ⚠️ ${diagnostic.message}`);
|
|
52
53
|
}
|
|
53
54
|
return lines.join("\n");
|
|
54
55
|
}
|
|
@@ -56,22 +57,22 @@ async function applyScopeChange(options, requestedPath, label) {
|
|
|
56
57
|
const securityLoad = loadSecurityConfigWithDiagnostics(options.appHomeDir);
|
|
57
58
|
const resolution = resolveProjectAccessPolicy(securityLoad.config, process.cwd());
|
|
58
59
|
if (!resolution.configured) {
|
|
59
|
-
return
|
|
60
|
+
return "无法切换项目:未配置 `projectAccess`。请部署者在 `security.json` 中写入 `projectAccess`(`defaultRoot`、`allowedRoots`)后重试。";
|
|
60
61
|
}
|
|
61
62
|
if (!resolution.mutable) {
|
|
62
|
-
return
|
|
63
|
+
return "无法切换项目:`projectAccess.defaultRoot` 配置有误,修复前项目切换已被禁用;请部署者查看启动日志。";
|
|
63
64
|
}
|
|
64
65
|
const real = resolveExistingDirectory(requestedPath);
|
|
65
66
|
if (!real) {
|
|
66
67
|
return `无法切换项目:\`${requestedPath}\` 不是一个存在的绝对目录。`;
|
|
67
68
|
}
|
|
68
69
|
if (!isWithinAllowedRoots(real, resolution.policy)) {
|
|
69
|
-
return `无法切换项目:\`${real}\`
|
|
70
|
+
return `无法切换项目:\`${real}\` 不在允许的根目录内。允许的根目录:${resolution.policy.allowedRoots
|
|
70
71
|
.map((root) => `\`${root}\``)
|
|
71
72
|
.join("、")}。`;
|
|
72
73
|
}
|
|
73
74
|
if (options.isBusy()) {
|
|
74
|
-
return "
|
|
75
|
+
return "无法切换项目:当前频道有回合正在进行。等它结束后重试,或先用 `/stop` 停止。";
|
|
75
76
|
}
|
|
76
77
|
const blockers = await options.listActiveBlockers();
|
|
77
78
|
if (blockers.length > 0) {
|
|
@@ -79,7 +80,7 @@ async function applyScopeChange(options, requestedPath, label) {
|
|
|
79
80
|
}
|
|
80
81
|
await commitProjectSelection(options.channelDir, real, options.actor);
|
|
81
82
|
await options.onScopeChanged?.();
|
|
82
|
-
return `${label}:\`${real}
|
|
83
|
+
return `${label}:\`${real}\`。下一条消息起在新的项目目录下运行。`;
|
|
83
84
|
}
|
|
84
85
|
export async function handleProjectCommand(options) {
|
|
85
86
|
let command;
|
|
@@ -105,7 +105,7 @@ export function resolveProjectScope(channelDir, resolution) {
|
|
|
105
105
|
if (resolution.configured && !isWithinAllowedRoots(real, resolution.policy)) {
|
|
106
106
|
return {
|
|
107
107
|
kind: "blocked",
|
|
108
|
-
reason: `项目目录
|
|
108
|
+
reason: `项目目录 \`${real}\` 已不在允许的根目录内(security.json 的 projectAccess 已变更)。请在频道空闲时用 \`/project set <路径>\` 或 \`/project reset\` 重新选择。`,
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
return { kind: "ready", scope: { projectRoot: real, boundary, sandbox }, selection: existing };
|
package/dist/channel/store.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-channel message archive (`log.jsonl`): inbound messages, bot responses and delegation records,
|
|
3
|
+
* with de-duplication, size rotation and a debounced flush.
|
|
4
|
+
*/
|
|
1
5
|
import { existsSync, mkdirSync } from "fs";
|
|
2
6
|
import { writeFile } from "fs/promises";
|
|
3
7
|
import { basename, dirname, join } from "path";
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* `/skills`), the agent session (`/model`, `/compact`, `/new`) and memory (`/memory`) — and is read
|
|
8
8
|
* by all of them plus the TUI. Only the catalog and the reply shape are shared: each *handler*
|
|
9
9
|
* still lives in the layer that owns the state it touches (`runtime/*-commands.ts`,
|
|
10
|
-
* `memory/commands.ts`, `agent/command-extension.ts`). This file has no imports at all, so nothing
|
|
10
|
+
* `memory/commands.ts`, `agent/session/command-extension.ts`). This file has no imports at all, so nothing
|
|
11
11
|
* here can drag a layer into another one.
|
|
12
12
|
*
|
|
13
|
-
* The
|
|
13
|
+
* The user-facing copy conventions these commands follow are recorded in AGENTS.md; `reply-limits.ts`
|
|
14
14
|
* next to this file enforces rule 5 (the length budget).
|
|
15
15
|
*/
|
|
16
16
|
export type BuiltInCommandName = "help" | "steer" | "followup" | "stop" | "events" | "tasks" | "status" | "usage" | "context" | "subagents" | "project" | "skills";
|
|
@@ -42,7 +42,7 @@ export interface CommandSubSpec {
|
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Single source of truth for a slash command's metadata. `HELP_TEXT`, the TUI
|
|
45
|
-
* autocomplete list, the busy-time hint, and the known-command set are all
|
|
45
|
+
* autocomplete list, the busy-time hint (`formatBusyHint`), and the known-command set are all
|
|
46
46
|
* derived from these tables — do not hand-maintain those in parallel.
|
|
47
47
|
*
|
|
48
48
|
* `subcommands`, where present, is *also* the single source for that command's own `usage()`
|
|
@@ -70,6 +70,8 @@ export interface CommandSpec {
|
|
|
70
70
|
runnerHandled?: boolean;
|
|
71
71
|
/** Broadcast list of this command's subcommands, for commands with a `/<name> <action> ...` shape. */
|
|
72
72
|
subcommands?: CommandSubSpec[];
|
|
73
|
+
/** Extra paragraph shown only in `/help <name>`, for context too specific for the top-level list. */
|
|
74
|
+
note?: string;
|
|
73
75
|
}
|
|
74
76
|
/**
|
|
75
77
|
* Transport commands: handled directly by the runtime layer (never sent to the
|
|
@@ -89,11 +91,15 @@ export declare function isBuiltInCommandName(name: string): name is BuiltInComma
|
|
|
89
91
|
export declare function isSessionCommandName(name: string): boolean;
|
|
90
92
|
/** Narrow a parsed built-in to one `ChannelRunner.handleBuiltinCommand` accepts. */
|
|
91
93
|
export declare function isRunnerBuiltInCommand(command: BuiltInCommand): command is RunnerBuiltInCommand;
|
|
92
|
-
/** Comma-separated list of commands usable while a task is streaming (names only). */
|
|
93
|
-
export declare function formatBusyCommandList(): string;
|
|
94
94
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
95
|
+
* The reply to a slash command that cannot run mid-turn — one source for DingTalk and the TUI
|
|
96
|
+
* (spec 053, D8). Both lists are derived from `availableWhileBusy`, so a command whose busy
|
|
97
|
+
* behaviour changes moves between them on its own instead of a hand-kept list going stale.
|
|
98
|
+
*/
|
|
99
|
+
export declare function formatBusyHint(): string;
|
|
100
|
+
/**
|
|
101
|
+
* Renders a command's subcommand table as its `usage()` text — the single source `tasks/commands.ts`,
|
|
102
|
+
* `events/commands.ts`, `subagents/commands.ts`, `channel/commands.ts`, and `memory/commands.ts` call
|
|
97
103
|
* on a parse error, replacing five hand-written `usage()` bodies (review 2026-08-24 §3.1).
|
|
98
104
|
*/
|
|
99
105
|
export declare function renderSubcommandUsage(name: string): string;
|
|
@@ -113,6 +119,17 @@ export declare function slashCommandName(text: string): string | null;
|
|
|
113
119
|
* every `skill:` name rather than trusting it.
|
|
114
120
|
*/
|
|
115
121
|
export declare function isKnownCommandName(name: string, knownSkillNames?: Iterable<string>): boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Replies around queueing that DingTalk and the TUI both give (spec 053, D10). One wording per
|
|
124
|
+
* situation, so the two surfaces cannot drift into two languages again.
|
|
125
|
+
*/
|
|
126
|
+
export declare function formatMissingQueueMessage(name: "steer" | "followup"): string;
|
|
127
|
+
/** `explainFollowup`: a plain busy-time message was steered implicitly, so say how to defer it instead. */
|
|
128
|
+
export declare function formatSteerQueued(explainFollowup: boolean): string;
|
|
129
|
+
export declare function formatFollowupQueued(): string;
|
|
130
|
+
export declare function formatNoRunningTurn(name: "stop" | "steer" | "followup"): string;
|
|
131
|
+
/** The `/new` confirmation, shared by the DingTalk runtime path and the session-layer command. */
|
|
132
|
+
export declare function formatNewSessionReply(sessionId: string): string;
|
|
116
133
|
export declare function formatUnknownCommandMessage(name: string): string;
|
|
117
134
|
export declare function parseBuiltInCommand(text: string): BuiltInCommand | null;
|
|
118
135
|
/**
|