@oyasmi/pipiclaw 0.9.4-beta.1 → 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 +148 -1245
- package/dist/agent/maintenance-context.d.ts +1 -1
- package/dist/agent/maintenance-context.js +1 -1
- package/dist/agent/prompt/resources.d.ts +3 -0
- package/dist/agent/prompt/resources.js +7 -1
- 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} +5 -5
- 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-adapter.js → session/session-adapter.js} +83 -1
- package/dist/agent/{session-events.d.ts → session/session-events.d.ts} +9 -5
- package/dist/agent/{session-events.js → session/session-events.js} +10 -10
- 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} +2 -2
- 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} +3 -3
- 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-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} +11 -8
- package/dist/{runtime/app-home.d.ts → app/home.d.ts} +0 -2
- package/dist/{runtime/app-home.js → app/home.js} +4 -75
- package/dist/{app-services.d.ts → app/services.d.ts} +5 -5
- package/dist/{app-services.js → app/services.js} +10 -10
- 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/{runtime/project-commands.d.ts → channel/commands.d.ts} +1 -1
- package/dist/{runtime/project-commands.js → channel/commands.js} +1 -1
- package/dist/channel/store.js +4 -0
- package/dist/commands/catalog.d.ts +3 -3
- package/dist/commands/catalog.js +3 -3
- package/dist/{runtime/report-commands.d.ts → commands/router.d.ts} +10 -3
- package/dist/{runtime/report-commands.js → commands/router.js} +5 -5
- package/dist/{settings.d.ts → config/settings.d.ts} +7 -8
- package/dist/{settings.js → config/settings.js} +7 -10
- 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 +3 -0
- 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/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} +6 -2
- 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} +1 -1
- package/dist/events/watcher.d.ts +67 -0
- package/dist/events/{events.js → watcher.js} +6 -109
- 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} +3 -146
- package/dist/jobs/record.d.ts +55 -0
- package/dist/jobs/record.js +36 -0
- package/dist/main.js +2 -2
- package/dist/memory/maintenance-gates.d.ts +2 -2
- 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 +2 -1
- 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/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 +37 -755
- package/dist/runtime/durable-dispatch.d.ts +17 -4
- package/dist/runtime/durable-dispatch.js +60 -18
- 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 +2 -2
- package/dist/runtime/task-driver.js +3 -3
- package/dist/runtime/task-migration.js +2 -2
- package/dist/runtime/task-spawn.d.ts +1 -1
- package/dist/runtime/task-spawn.js +1 -1
- 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/security/command-guard.js +4 -0
- package/dist/security/network.js +4 -0
- 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/host-process.js +1 -1
- package/dist/shared/wake-claim.d.ts +1 -1
- package/dist/{runtime/skill-commands.d.ts → skills/commands.d.ts} +2 -2
- package/dist/{runtime/skill-commands.js → skills/commands.js} +1 -1
- 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} +4 -3
- package/dist/{runtime/subagent-commands.js → subagents/commands.js} +2 -2
- 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/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 +1 -1
- package/dist/subagents/external/run.d.ts +2 -1
- package/dist/subagents/external/run.js +2 -2
- package/dist/subagents/external/settlement.d.ts +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 +7 -243
- package/dist/subagents/runs.js +8 -291
- 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/tasks/board.d.ts +2 -2
- package/dist/tasks/board.js +2 -2
- 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} +12 -8
- 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/{log.js → loop-log.js} +1 -1
- 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 +2 -2
- package/dist/tools/bash.d.ts +1 -1
- package/dist/tools/{tool-details.d.ts → contract/details.d.ts} +2 -2
- package/dist/tools/{tool-details.js → contract/details.js} +4 -4
- 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 +3 -3
- package/dist/tools/index.js +7 -6
- package/dist/tools/job.d.ts +1 -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.js +4 -3
- 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 +3 -3
- 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 +1 -1
- 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/plain-frontend.d.ts +1 -1
- package/dist/tui/renderer.d.ts +3 -42
- 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 +1 -1
- package/dist/usage/ledger.js +4 -0
- 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/events/events.d.ts +0 -159
- package/dist/runtime/dingtalk.d.ts +0 -272
- package/dist/runtime/dingtalk.js +0 -1470
- package/dist/subagents/tool.d.ts +0 -213
- package/dist/subagents/tool.js +0 -1282
- /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-error.d.ts → turn/turn-error.d.ts} +0 -0
- /package/dist/agent/{turn-error.js → turn/turn-error.js} +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 → app}/proxy.js +0 -0
- /package/dist/{runtime → dingtalk}/channel-queue.d.ts +0 -0
- /package/dist/{runtime → dingtalk}/delivery.js +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/events/{event-validation.js → validation.js} +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/tasks/{log.d.ts → loop-log.d.ts} +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,5 +1,5 @@
|
|
|
1
|
+
import type { PipiclawSettingsManager } from "../config/settings.js";
|
|
1
2
|
import type { MemoryMaintenanceRuntimeContext } from "../memory/scheduler.js";
|
|
2
|
-
import type { PipiclawSettingsManager } from "../settings.js";
|
|
3
3
|
export interface DetachedMaintenanceContextOptions {
|
|
4
4
|
channelId: string;
|
|
5
5
|
channelDir: string;
|
|
@@ -2,7 +2,7 @@ import { statSync } from "node:fs";
|
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { SessionManager } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { getApiKeyForModel } from "../models/api-keys.js";
|
|
5
|
-
import { createModelRuntime, resolveInitialModel, wrapModelRegistry } from "../models/
|
|
5
|
+
import { createModelRuntime, resolveInitialModel, wrapModelRegistry } from "../models/runtime.js";
|
|
6
6
|
// The maintenance scheduler visits idle channels every tick; re-parsing an
|
|
7
7
|
// unchanged context.jsonl each time would be pure I/O waste for long-dead
|
|
8
8
|
// channels. Keyed by channelDir, replaced whenever the file changes.
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* the runtime catalog, or with skills for space; only a genuinely oversized file is
|
|
12
12
|
* head/tail clipped.
|
|
13
13
|
*/
|
|
14
|
+
import { type RuntimePlaybookMetadata } from "../../playbooks/catalog.js";
|
|
14
15
|
import type { LoadedPromptResource, PromptDiagnostic } from "./types.js";
|
|
15
16
|
/** SOUL.md is identity and voice: normally short, so a tight independent budget (spec 026 §5.2). */
|
|
16
17
|
export declare const SOUL_BUDGET_UNITS = 3000;
|
|
@@ -23,5 +24,7 @@ export interface WorkspacePromptResources {
|
|
|
23
24
|
agents?: LoadedPromptResource;
|
|
24
25
|
diagnostics: PromptDiagnostic[];
|
|
25
26
|
}
|
|
27
|
+
/** The bundled runtime playbooks that apply to the tools this runner actually has. */
|
|
28
|
+
export declare function loadPlaybooks(toolNames: readonly string[]): RuntimePlaybookMetadata[];
|
|
26
29
|
/** Read SOUL.md and AGENTS.md from the workspace root, budgeted and template-aware. */
|
|
27
30
|
export declare function loadWorkspacePromptResources(workspaceDir: string): WorkspacePromptResources;
|
|
@@ -14,14 +14,20 @@
|
|
|
14
14
|
import { existsSync, readFileSync } from "node:fs";
|
|
15
15
|
import { join } from "node:path";
|
|
16
16
|
import * as log from "../../log.js";
|
|
17
|
-
import {
|
|
17
|
+
import { loadRuntimePlaybookCatalog, selectRuntimePlaybooks, } from "../../playbooks/catalog.js";
|
|
18
18
|
import { clipTextByPromptUnits, countPromptUnits } from "../../shared/prompt-units.js";
|
|
19
|
+
import { TOOL_NAMES } from "../../tools/registry.js";
|
|
20
|
+
import { DEFAULT_AGENTS, DEFAULT_SOUL, isDefaultWorkspaceTemplate } from "./workspace-templates.js";
|
|
19
21
|
/** SOUL.md is identity and voice: normally short, so a tight independent budget (spec 026 §5.2). */
|
|
20
22
|
export const SOUL_BUDGET_UNITS = 3_000;
|
|
21
23
|
export const SOUL_BUDGET_CHARS = 24_000;
|
|
22
24
|
/** AGENTS.md carries team procedure and is allowed to be larger (spec 026 §5.2). */
|
|
23
25
|
export const AGENTS_BUDGET_UNITS = 6_000;
|
|
24
26
|
export const AGENTS_BUDGET_CHARS = 48_000;
|
|
27
|
+
/** The bundled runtime playbooks that apply to the tools this runner actually has. */
|
|
28
|
+
export function loadPlaybooks(toolNames) {
|
|
29
|
+
return selectRuntimePlaybooks(loadRuntimePlaybookCatalog(TOOL_NAMES), toolNames);
|
|
30
|
+
}
|
|
25
31
|
function readWorkspaceFile(path) {
|
|
26
32
|
if (!existsSync(path)) {
|
|
27
33
|
return "";
|
|
@@ -1,46 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type Executor } from "../executor.js";
|
|
3
|
-
import { type FileStore } from "../file-store.js";
|
|
4
|
-
import { type LoadedSecurityConfig } from "../security/config.js";
|
|
5
|
-
import type { PipiclawSettingsManager } from "../settings.js";
|
|
6
|
-
import type { SubAgentRunManager } from "../subagents/runs.js";
|
|
7
|
-
import type { ChannelJobManager } from "./job-manager.js";
|
|
8
|
-
import type { AgentRunner } from "./types.js";
|
|
9
|
-
export interface RunnerFactoryPaths {
|
|
10
|
-
jobManager: ChannelJobManager;
|
|
11
|
-
runManager: SubAgentRunManager;
|
|
12
|
-
appHomeDir: string;
|
|
13
|
-
authConfigPath: string;
|
|
14
|
-
modelsConfigPath: string;
|
|
15
|
-
/**
|
|
16
|
-
* The single app-level settings manager (from `prepareAppServices`), shared across every
|
|
17
|
-
* channel's runner rather than each constructing its own. Keeps `drainErrors()`/diagnostics
|
|
18
|
-
* ordering and `reload()`'s file-stamp guard meaningful instead of racing N independent copies.
|
|
19
|
-
*/
|
|
20
|
-
settingsManager: PipiclawSettingsManager;
|
|
21
|
-
/** Optional, side-effect-free observer used by the behavior-eval harness. */
|
|
22
|
-
onSessionEvent?: (event: unknown, channelId: string) => void;
|
|
23
|
-
/**
|
|
24
|
-
* Transport that can deliver file attachments (the DingTalk bot, or the terminal).
|
|
25
|
-
* Present enables the `send_media` tool; absent, the tool is not built.
|
|
26
|
-
*/
|
|
27
|
-
mediaSender?: MediaSender;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* The collaborators a runner uses but does not build. Composing them here rather than inside
|
|
31
|
-
* `ChannelRunner`'s constructor keeps the "which implementation" decision at the one place that
|
|
32
|
-
* already owns wiring, and is what makes `Executor`/`FileStore` real ports (a remote executor is
|
|
33
|
-
* a different value passed in, not a different branch inside the runner).
|
|
34
|
-
*/
|
|
35
|
-
export interface RunnerDeps {
|
|
36
|
-
executor: Executor;
|
|
37
|
-
fileStore: FileStore;
|
|
38
|
-
/**
|
|
39
|
-
* Called per use, not resolved once: the runner re-reads security policy on every tool rebuild
|
|
40
|
-
* so an edited `security.json` takes effect without restarting the daemon.
|
|
41
|
-
*/
|
|
42
|
-
loadSecurityConfig: () => LoadedSecurityConfig;
|
|
43
|
-
}
|
|
1
|
+
import type { AgentRunner, RunnerFactoryPaths } from "./types.js";
|
|
44
2
|
/**
|
|
45
3
|
* Stateless: always constructs a fresh runner. The daemon (`runtime/bootstrap.ts`) and the TUI
|
|
46
4
|
* (`tui/app.ts`) are the only two callers, and each already owns exactly one cache appropriate to
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SDK extension that serves the session slash commands (`/model`, `/thinking`, `/session`,
|
|
3
|
+
* `/compact`, `/memory`, `/new`) inside the agent session, backed by callbacks from the session host.
|
|
4
|
+
*/
|
|
1
5
|
import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
2
6
|
import type { Api, Model } from "@earendil-works/pi-ai";
|
|
3
7
|
import type { ExtensionFactory, SessionStats } from "@earendil-works/pi-coding-agent";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { basename } from "path";
|
|
2
|
-
import { formatNewSessionReply, sessionCommandDescription } from "
|
|
3
|
-
import { capReply } from "
|
|
4
|
-
import { findModelReferenceMatch, formatModelList, formatModelReference } from "
|
|
5
|
-
import { estimateTokens } from "
|
|
6
|
-
import { truncate } from "
|
|
2
|
+
import { formatNewSessionReply, sessionCommandDescription } from "../../commands/catalog.js";
|
|
3
|
+
import { capReply } from "../../commands/reply-limits.js";
|
|
4
|
+
import { findModelReferenceMatch, formatModelList, formatModelReference } from "../../models/reference.js";
|
|
5
|
+
import { estimateTokens } from "../../shared/format.js";
|
|
6
|
+
import { truncate } from "../../shared/text-utils.js";
|
|
7
7
|
export const COMMAND_RESULT_CUSTOM_TYPE = "pipiclaw.command_result";
|
|
8
8
|
function buildSessionText(stats, currentModel, thinkingLevel, lastResponseModel) {
|
|
9
9
|
const configuredRef = currentModel ? formatModelReference(currentModel) : null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SubAgentToolDetails } from "
|
|
2
|
-
import type { AssistantContentPart, AssistantEventMessage, AssistantUsageMessage, AutoCompactionEndEvent, AutoCompactionStartEvent, AutoRetryStartEvent, MessageEndEvent, MessageStartEvent, ToolExecutionEndEvent, ToolExecutionStartEvent, ToolExecutionUpdateEvent, TurnEndEvent } from "
|
|
1
|
+
import type { SubAgentToolDetails } from "../../tools/subagent.js";
|
|
2
|
+
import type { AssistantContentPart, AssistantEventMessage, AssistantUsageMessage, AutoCompactionEndEvent, AutoCompactionStartEvent, AutoRetryStartEvent, MessageEndEvent, MessageStartEvent, ToolExecutionEndEvent, ToolExecutionStartEvent, ToolExecutionUpdateEvent, TurnEndEvent } from "../types.js";
|
|
3
3
|
export declare function isAssistantEventMessage(value: unknown): value is AssistantEventMessage;
|
|
4
4
|
export declare function isAssistantUsageMessage(value: unknown): value is AssistantUsageMessage;
|
|
5
5
|
export declare function getLastAssistantUsage(messages: readonly unknown[]): AssistantUsageMessage | null;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Type guards for the SDK's loosely typed session and message events, so event handlers can narrow
|
|
3
|
+
* them without casts.
|
|
4
|
+
*/
|
|
5
|
+
import { isRecord } from "../../shared/type-guards.js";
|
|
2
6
|
import { COMMAND_RESULT_CUSTOM_TYPE } from "./command-extension.js";
|
|
3
7
|
function isMessageWithRole(value) {
|
|
4
8
|
return isRecord(value) && typeof value.role === "string";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which model a channel is on: the preferred (active) model, the backup-model switch and its
|
|
3
|
+
* cooldown, resolving the configured backup, and the thinking-level handling that has to stay in
|
|
4
|
+
* step with a model change. Reads the live session through callbacks, since the session is rebuilt
|
|
5
|
+
* on `/new`, fork and task binding.
|
|
6
|
+
*/
|
|
7
|
+
import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
8
|
+
import type { Api, Model } from "@earendil-works/pi-ai";
|
|
9
|
+
import type { AgentSession, ModelRegistry, SettingsManager as SDKSettingsManager } from "@earendil-works/pi-coding-agent";
|
|
10
|
+
import type { PipiclawSettingsManager } from "../../config/settings.js";
|
|
11
|
+
export interface ModelSelectionDeps {
|
|
12
|
+
channelId: string;
|
|
13
|
+
settingsManager: PipiclawSettingsManager;
|
|
14
|
+
getSession: () => AgentSession;
|
|
15
|
+
getSessionSettingsManager: () => SDKSettingsManager;
|
|
16
|
+
getModelRegistry: () => ModelRegistry;
|
|
17
|
+
}
|
|
18
|
+
export declare class ModelSelection {
|
|
19
|
+
private deps;
|
|
20
|
+
/** The preferred model. Replaced from settings once the model registry exists, and by `/model`. */
|
|
21
|
+
activeModel: Model<Api>;
|
|
22
|
+
/** When the primary model last failed and we switched to the backup. null = on primary. */
|
|
23
|
+
private primaryFailedAt;
|
|
24
|
+
constructor(deps: ModelSelectionDeps);
|
|
25
|
+
markPrimaryFailed(): void;
|
|
26
|
+
/** A manual `/model` switch redefines the preferred model and clears fallback state. */
|
|
27
|
+
clearFallbackState(): void;
|
|
28
|
+
/** Set while running on the backup model: what the primary is and when it may be retried. */
|
|
29
|
+
fallbackStatus(current: Model<Api>): {
|
|
30
|
+
primary: string;
|
|
31
|
+
cooldownUntilMs: number;
|
|
32
|
+
} | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* At turn start, if a fallback is active and the primary's cooldown has elapsed,
|
|
35
|
+
* switch back to the preferred model. Silent — no user notice on recovery.
|
|
36
|
+
*/
|
|
37
|
+
maybeRestorePrimaryModel(): Promise<void>;
|
|
38
|
+
setModelWithThinkingPreservation(model: Model<Api>): Promise<void>;
|
|
39
|
+
setThinkingLevelCompat(level: ThinkingLevel): void;
|
|
40
|
+
cycleThinkingLevelCompat(): ThinkingLevel | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve the configured backup model reference against available models.
|
|
43
|
+
* Returns null when unset, unresolvable/ambiguous, or missing an API key —
|
|
44
|
+
* each case logs a warning and disables fallback for this turn.
|
|
45
|
+
*/
|
|
46
|
+
resolveFallbackModel(): Promise<Model<Api> | null>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as log from "../../log.js";
|
|
2
|
+
import { getApiKeyForModel } from "../../models/api-keys.js";
|
|
3
|
+
import { PRIMARY_COOLDOWN_MS, shouldRestorePrimary } from "../../models/fallback.js";
|
|
4
|
+
import { findExactModelReferenceMatch, formatModelReference } from "../../models/reference.js";
|
|
5
|
+
import { defaultModel } from "../../models/runtime.js";
|
|
6
|
+
import { errorMessage } from "../../shared/text-utils.js";
|
|
7
|
+
import { cycleThinkingLevelWithConditionalPersist, setModelWithThinkingPreservation, setThinkingLevelWithConditionalPersist, } from "./session-adapter.js";
|
|
8
|
+
export class ModelSelection {
|
|
9
|
+
constructor(deps) {
|
|
10
|
+
this.deps = deps;
|
|
11
|
+
/** The preferred model. Replaced from settings once the model registry exists, and by `/model`. */
|
|
12
|
+
this.activeModel = defaultModel;
|
|
13
|
+
/** When the primary model last failed and we switched to the backup. null = on primary. */
|
|
14
|
+
this.primaryFailedAt = null;
|
|
15
|
+
}
|
|
16
|
+
markPrimaryFailed() {
|
|
17
|
+
this.primaryFailedAt = Date.now();
|
|
18
|
+
}
|
|
19
|
+
/** A manual `/model` switch redefines the preferred model and clears fallback state. */
|
|
20
|
+
clearFallbackState() {
|
|
21
|
+
this.primaryFailedAt = null;
|
|
22
|
+
}
|
|
23
|
+
/** Set while running on the backup model: what the primary is and when it may be retried. */
|
|
24
|
+
fallbackStatus(current) {
|
|
25
|
+
if (formatModelReference(current) === formatModelReference(this.activeModel))
|
|
26
|
+
return undefined;
|
|
27
|
+
return {
|
|
28
|
+
primary: formatModelReference(this.activeModel),
|
|
29
|
+
cooldownUntilMs: (this.primaryFailedAt ?? Date.now()) + PRIMARY_COOLDOWN_MS,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* At turn start, if a fallback is active and the primary's cooldown has elapsed,
|
|
34
|
+
* switch back to the preferred model. Silent — no user notice on recovery.
|
|
35
|
+
*/
|
|
36
|
+
async maybeRestorePrimaryModel() {
|
|
37
|
+
const current = this.deps.getSession().model;
|
|
38
|
+
if (!current || formatModelReference(current) === formatModelReference(this.activeModel)) {
|
|
39
|
+
this.primaryFailedAt = null;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!shouldRestorePrimary(this.primaryFailedAt, Date.now())) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
await this.setModelWithThinkingPreservation(this.activeModel);
|
|
47
|
+
this.primaryFailedAt = null;
|
|
48
|
+
log.logInfo(`[${this.deps.channelId}] Restored primary model ${formatModelReference(this.activeModel)}`);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
log.logWarn("agent.model.restore_failed", "Primary model restore failed", {
|
|
52
|
+
channelId: this.deps.channelId,
|
|
53
|
+
reason: errorMessage(err),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async setModelWithThinkingPreservation(model) {
|
|
58
|
+
await setModelWithThinkingPreservation(this.deps.getSession(), this.deps.getSessionSettingsManager(), model);
|
|
59
|
+
}
|
|
60
|
+
setThinkingLevelCompat(level) {
|
|
61
|
+
setThinkingLevelWithConditionalPersist(this.deps.getSession(), level);
|
|
62
|
+
}
|
|
63
|
+
cycleThinkingLevelCompat() {
|
|
64
|
+
return cycleThinkingLevelWithConditionalPersist(this.deps.getSession());
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolve the configured backup model reference against available models.
|
|
68
|
+
* Returns null when unset, unresolvable/ambiguous, or missing an API key —
|
|
69
|
+
* each case logs a warning and disables fallback for this turn.
|
|
70
|
+
*/
|
|
71
|
+
async resolveFallbackModel() {
|
|
72
|
+
const reference = this.deps.settingsManager.getFallbackModelReference();
|
|
73
|
+
if (!reference) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const modelRegistry = this.deps.getModelRegistry();
|
|
77
|
+
await modelRegistry.refresh();
|
|
78
|
+
const available = modelRegistry.getAvailable();
|
|
79
|
+
const { match, ambiguous } = findExactModelReferenceMatch(reference, available);
|
|
80
|
+
if (!match) {
|
|
81
|
+
log.logWarn("agent.model.fallback_unresolved", "Fallback model skipped", {
|
|
82
|
+
channelId: this.deps.channelId,
|
|
83
|
+
fields: { reference, problem: ambiguous ? "ambiguous" : "not found" },
|
|
84
|
+
});
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
try {
|
|
88
|
+
await getApiKeyForModel(modelRegistry, match);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
log.logWarn("agent.model.fallback_unresolved", "Fallback model skipped", {
|
|
92
|
+
channelId: this.deps.channelId,
|
|
93
|
+
fields: { reference, problem: "no API key" },
|
|
94
|
+
});
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return match;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapters over the SDK session where Pipiclaw needs compatibility behaviour: the settings-manager
|
|
3
|
+
* shim and thinking-level preservation when a model changes.
|
|
4
|
+
*/
|
|
1
5
|
import type { Agent, AgentTool, ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
2
6
|
import type { Api, Model } from "@earendil-works/pi-ai";
|
|
3
7
|
import { type AgentSession, SettingsManager as SDKSettingsManager, type SessionManager } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import type { PipiclawSettingsManager } from "
|
|
8
|
+
import type { PipiclawSettingsManager } from "../../config/settings.js";
|
|
5
9
|
export declare function asSdkSettingsManager(manager: PipiclawSettingsManager): SDKSettingsManager;
|
|
6
10
|
export declare const DEFAULT_MAIN_THINKING_LEVEL: ThinkingLevel;
|
|
7
11
|
/** Apply the pi 0.83 source-model thinking compatibility branch to one real AgentSession. */
|
|
@@ -17,3 +21,19 @@ export declare function initializeThinkingLevelCompat(agent: Agent, model: Model
|
|
|
17
21
|
* silently leaving stale tools in place. Replace with a public setter once upstream adds one.
|
|
18
22
|
*/
|
|
19
23
|
export declare function setSessionBaseToolsOverride(session: AgentSession, tools: AgentTool<any>[], channelId: string): void;
|
|
24
|
+
/** One prompt's origin. Raw entries establish safety; projection only decides what still needs omission. */
|
|
25
|
+
export declare class SessionRetryAttempt<T extends Pick<AgentSession, "sessionManager" | "refreshContext"> = AgentSession> {
|
|
26
|
+
readonly session: T;
|
|
27
|
+
private readonly manager;
|
|
28
|
+
private readonly sessionId;
|
|
29
|
+
private readonly prefix;
|
|
30
|
+
private retryBranch;
|
|
31
|
+
constructor(session: T);
|
|
32
|
+
classify(): {
|
|
33
|
+
kind: "unsubmitted" | "failed-turn";
|
|
34
|
+
targets: string[];
|
|
35
|
+
} | null;
|
|
36
|
+
prepare(): ReturnType<SessionRetryAttempt<T>["classify"]>;
|
|
37
|
+
/** Caller holds the host resource window and must quarantine this session on any exception. */
|
|
38
|
+
omitFailedContext(): boolean;
|
|
39
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { clampThinkingLevel } from "@earendil-works/pi-ai/compat";
|
|
2
2
|
import { SettingsManager as SDKSettingsManager, } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import * as log from "
|
|
3
|
+
import * as log from "../../log.js";
|
|
4
4
|
export function asSdkSettingsManager(manager) {
|
|
5
5
|
// The upstream session needs its broad interactive SettingsManager surface, while
|
|
6
6
|
// Pipiclaw deliberately owns a small runtime-specific settings contract. Build a
|
|
@@ -75,3 +75,85 @@ export function setSessionBaseToolsOverride(session, tools, channelId) {
|
|
|
75
75
|
}
|
|
76
76
|
target._baseToolsOverride = Object.fromEntries(tools.map((tool) => [tool.name, tool]));
|
|
77
77
|
}
|
|
78
|
+
/** One prompt's origin. Raw entries establish safety; projection only decides what still needs omission. */
|
|
79
|
+
export class SessionRetryAttempt {
|
|
80
|
+
constructor(session) {
|
|
81
|
+
this.session = session;
|
|
82
|
+
this.manager = session.sessionManager;
|
|
83
|
+
this.sessionId = session.sessionManager.getSessionId();
|
|
84
|
+
this.prefix = session.sessionManager.getBranch().map((entry) => entry.id);
|
|
85
|
+
}
|
|
86
|
+
classify() {
|
|
87
|
+
const manager = this.session.sessionManager;
|
|
88
|
+
if (manager !== this.manager || manager.getSessionId() !== this.sessionId)
|
|
89
|
+
return null;
|
|
90
|
+
const branch = manager.getBranch();
|
|
91
|
+
if (this.prefix.some((id, index) => branch[index]?.id !== id))
|
|
92
|
+
return null;
|
|
93
|
+
if (this.retryBranch) {
|
|
94
|
+
if (this.retryBranch.some((id, index) => branch[index]?.id !== id))
|
|
95
|
+
return null;
|
|
96
|
+
// Once prepared, a new interaction or rewinding the failed branch invalidates the plan.
|
|
97
|
+
if (branch
|
|
98
|
+
.slice(this.retryBranch.length)
|
|
99
|
+
.some((entry) => entry.type === "message" && entry.message.role !== "system"))
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const delta = branch.slice(this.prefix.length);
|
|
103
|
+
const users = [];
|
|
104
|
+
const errors = [];
|
|
105
|
+
for (const entry of delta) {
|
|
106
|
+
if (entry.type === "message") {
|
|
107
|
+
const message = entry.message;
|
|
108
|
+
if (message.role === "system")
|
|
109
|
+
continue;
|
|
110
|
+
if (message.role === "user" && errors.length === 0)
|
|
111
|
+
users.push(entry.id);
|
|
112
|
+
else if (message.role === "assistant" && users.length === 1 && message.stopReason === "error") {
|
|
113
|
+
if (message.content.some((part) => part.type === "toolCall" || (part.type === "text" && part.text.trim()))) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
errors.push(entry.id);
|
|
117
|
+
}
|
|
118
|
+
else
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
else if (entry.type === "context_edit") {
|
|
122
|
+
// Only omissions of this attempt's failed messages are understood (including SDK retries).
|
|
123
|
+
if (entry.replacement !== null || ![...users, ...errors].includes(entry.targetId))
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
else if (!["model_change", "thinking_level_change", "usage"].includes(entry.type))
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
if (users.length === 0 && errors.length === 0)
|
|
130
|
+
return { kind: "unsubmitted", targets: [] };
|
|
131
|
+
if (users.length !== 1 || errors.length === 0)
|
|
132
|
+
return null;
|
|
133
|
+
const targets = [...users, ...errors];
|
|
134
|
+
const projection = manager.buildSessionProjection();
|
|
135
|
+
// Even an already omitted entry must have identifiable provenance.
|
|
136
|
+
if (targets.some((id) => !projection.entries.some((entry) => entry.sourceEntry.id === id)))
|
|
137
|
+
return null;
|
|
138
|
+
return {
|
|
139
|
+
kind: "failed-turn",
|
|
140
|
+
targets: targets.filter((id) => projection.entries.some((entry) => entry.sourceEntry.id === id && entry.messages.length)),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
prepare() {
|
|
144
|
+
const plan = this.classify();
|
|
145
|
+
if (plan)
|
|
146
|
+
this.retryBranch ??= this.manager.getBranch().map((entry) => entry.id);
|
|
147
|
+
return plan;
|
|
148
|
+
}
|
|
149
|
+
/** Caller holds the host resource window and must quarantine this session on any exception. */
|
|
150
|
+
omitFailedContext() {
|
|
151
|
+
const plan = this.prepare();
|
|
152
|
+
if (!plan)
|
|
153
|
+
return false;
|
|
154
|
+
for (const id of plan.targets)
|
|
155
|
+
this.session.sessionManager.appendContextEdit(id, null);
|
|
156
|
+
this.session.refreshContext();
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import type {
|
|
1
|
+
/**
|
|
2
|
+
* Translates SDK session events into progress and AI-Card updates, usage accounting and memory
|
|
3
|
+
* activity for the current turn.
|
|
4
|
+
*/
|
|
5
|
+
import type { ChannelContext } from "../../channel/channel-context.js";
|
|
6
|
+
import type { ChannelStore } from "../../channel/store.js";
|
|
7
|
+
import type { MemoryLifecycle } from "../../memory/lifecycle.js";
|
|
8
|
+
import type { UsageLedger } from "../../usage/ledger.js";
|
|
9
|
+
import type { PendingTool, RunLogContext, RunQueue, RunState } from "../types.js";
|
|
6
10
|
export interface SessionEventHandlerContext {
|
|
7
11
|
ctx: ChannelContext;
|
|
8
12
|
logCtx: RunLogContext;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import * as log from "
|
|
2
|
-
import { renderGuardBlockForUser } from "
|
|
3
|
-
import { truncate } from "
|
|
4
|
-
import { isRecord } from "
|
|
5
|
-
import {
|
|
6
|
-
import { describeToolCall } from "
|
|
7
|
-
import {
|
|
8
|
-
import { extractToolResultText, formatProgressEntry } from "
|
|
9
|
-
import { renderCompactionFailure } from "
|
|
10
|
-
import { extractCustomCommandResultText, isAssistantEventMessage, isAutoCompactionEndEvent, isAutoCompactionStartEvent, isAutoRetryStartEvent, isMessageEndEvent, isMessageStartEvent, isSubAgentToolDetails, isTextPart, isThinkingPart, isToolExecutionEndEvent, isToolExecutionStartEvent, isToolExecutionUpdateEvent, isTurnEndEvent, } from "./
|
|
1
|
+
import * as log from "../../log.js";
|
|
2
|
+
import { renderGuardBlockForUser } from "../../security/block-message.js";
|
|
3
|
+
import { truncate } from "../../shared/text-utils.js";
|
|
4
|
+
import { isRecord } from "../../shared/type-guards.js";
|
|
5
|
+
import { isArgumentValidationFailure, isRecoverableRejection, takeGuardBlock, toolResultDetails, } from "../../tools/contract/details.js";
|
|
6
|
+
import { describeToolCall } from "../../tools/contract/presentation.js";
|
|
7
|
+
import { addUsage } from "../../usage/totals.js";
|
|
8
|
+
import { extractToolResultText, formatProgressEntry } from "../turn/progress-formatter.js";
|
|
9
|
+
import { renderCompactionFailure } from "../turn/turn-error.js";
|
|
10
|
+
import { extractCustomCommandResultText, isAssistantEventMessage, isAutoCompactionEndEvent, isAutoCompactionStartEvent, isAutoRetryStartEvent, isMessageEndEvent, isMessageStartEvent, isSubAgentToolDetails, isTextPart, isThinkingPart, isToolExecutionEndEvent, isToolExecutionStartEvent, isToolExecutionUpdateEvent, isTurnEndEvent, } from "./event-guards.js";
|
|
11
11
|
/**
|
|
12
12
|
* A `write`/`edit` result whose resolved target landed inside the workspace `skills/` tree. The
|
|
13
13
|
* `skill` tool is read-only (spec 045); authoring a workspace skill goes through the generic file
|