@oyasmi/pipiclaw 0.9.3-beta.3 → 0.9.3-beta.5
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 +12 -12
- package/README.md +12 -12
- package/dist/agent/channel-runner.d.ts +4 -18
- package/dist/agent/channel-runner.js +26 -121
- package/dist/agent/context-budget.js +1 -1
- package/dist/agent/job-manager.d.ts +11 -17
- package/dist/agent/job-manager.js +77 -67
- package/dist/agent/prompt/builder.js +1 -17
- package/dist/agent/prompt/manifest.d.ts +0 -1
- package/dist/agent/prompt/manifest.js +2 -2
- package/dist/agent/prompt/sections.js +0 -9
- package/dist/agent/prompt/types.d.ts +2 -18
- package/dist/agent/prompt/types.js +1 -1
- package/dist/agent/runner-factory.d.ts +4 -0
- package/dist/agent/session-adapter.d.ts +19 -0
- package/dist/agent/session-adapter.js +77 -0
- package/dist/app-services.d.ts +18 -0
- package/dist/app-services.js +43 -0
- package/dist/channel/channel-context.d.ts +2 -2
- package/dist/channel/channel-context.js +2 -2
- package/dist/channel/channel-event.d.ts +3 -3
- package/dist/{runtime → events}/events.d.ts +1 -1
- package/dist/memory/journal.js +1 -1
- package/dist/memory/maintenance-gates.d.ts +0 -3
- package/dist/memory/maintenance-gates.js +2 -2
- package/dist/memory/maintenance-migration.d.ts +5 -0
- package/dist/memory/maintenance-migration.js +91 -0
- package/dist/memory/maintenance-state.js +5 -44
- package/dist/memory/migrate.js +1 -1
- package/dist/memory/reflect-job.d.ts +1 -9
- package/dist/memory/reflect-job.js +1 -3
- package/dist/memory/reflect.js +1 -1
- package/dist/memory/session-corpus.js +1 -1
- package/dist/memory/store.js +1 -1
- package/dist/models/auth-cli.js +1 -1
- package/dist/playbooks/agent-delegation.md +15 -11
- package/dist/playbooks/background-jobs.md +1 -1
- package/dist/playbooks/runtime-orientation.md +2 -0
- package/dist/playbooks/task-loop.md +1 -1
- package/dist/runtime/bootstrap.d.ts +5 -15
- package/dist/runtime/bootstrap.js +44 -65
- package/dist/runtime/delivery.d.ts +1 -2
- package/dist/runtime/delivery.js +57 -62
- package/dist/runtime/dingtalk.d.ts +15 -8
- package/dist/runtime/dingtalk.js +101 -35
- package/dist/runtime/subagent-commands.d.ts +2 -1
- package/dist/runtime/subagent-commands.js +10 -12
- package/dist/runtime/task-wake.d.ts +4 -5
- package/dist/runtime/task-wake.js +2 -12
- package/dist/security/types.d.ts +7 -0
- package/dist/security/types.js +16 -1
- package/dist/settings.d.ts +8 -0
- package/dist/settings.js +24 -1
- package/dist/shared/exact-keys.d.ts +13 -0
- package/dist/shared/exact-keys.js +1 -0
- package/dist/shared/format.d.ts +20 -0
- package/dist/shared/format.js +64 -0
- package/dist/shared/{fs-utils.d.ts → os.d.ts} +6 -0
- package/dist/shared/{fs-utils.js → os.js} +8 -0
- package/dist/subagents/discovery.d.ts +16 -3
- package/dist/subagents/discovery.js +13 -9
- package/dist/subagents/external/claude-code.js +3 -1
- package/dist/subagents/external/harness.d.ts +4 -2
- package/dist/subagents/external/run.d.ts +2 -1
- package/dist/subagents/external/run.js +13 -5
- package/dist/subagents/external/settlement.js +10 -5
- package/dist/subagents/format.d.ts +1 -1
- package/dist/subagents/format.js +1 -1
- package/dist/subagents/runs.d.ts +13 -12
- package/dist/subagents/runs.js +109 -91
- package/dist/subagents/tool.d.ts +7 -7
- package/dist/subagents/tool.js +11 -11
- package/dist/tasks/brief.js +1 -0
- package/dist/tools/command-optimizer.js +1 -1
- package/dist/tools/config.d.ts +7 -0
- package/dist/tools/config.js +16 -1
- package/dist/tools/event-manage.d.ts +1 -1
- package/dist/tools/event-manage.js +3 -3
- package/dist/tools/grep.js +1 -1
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.js +4 -2
- package/dist/tools/job.js +1 -1
- package/dist/tools/read.js +1 -1
- package/dist/tools/registry.d.ts +3 -3
- package/dist/tools/registry.js +18 -56
- package/dist/tools/skill.js +1 -1
- package/dist/tools/subagent-manage.d.ts +2 -0
- package/dist/tools/subagent-manage.js +7 -7
- package/dist/tools/subagent-tool-names.d.ts +2 -2
- package/dist/tools/subagent-tool-names.js +2 -2
- package/dist/tools/task-manage/shared.js +4 -9
- package/dist/tools/task-manage/types.d.ts +4 -0
- package/dist/tui/app.js +22 -7
- package/dist/web/config.js +1 -1
- package/examples/sub-agents/README.md +65 -81
- package/examples/sub-agents/agents/claude-high.md +23 -0
- package/examples/sub-agents/agents/claude-main.md +23 -0
- package/examples/sub-agents/agents/codex-flash.md +23 -0
- package/examples/sub-agents/agents/codex-high.md +23 -0
- package/examples/sub-agents/agents/codex-main.md +23 -0
- package/examples/sub-agents/agents/glm-flash.md +23 -0
- package/examples/sub-agents/agents/glm-high.md +23 -0
- package/package.json +2 -1
- package/dist/shared/duration.d.ts +0 -2
- package/dist/shared/duration.js +0 -7
- package/dist/shared/file-stamp.d.ts +0 -10
- package/dist/shared/file-stamp.js +0 -19
- package/dist/shared/numeric.d.ts +0 -7
- package/dist/shared/numeric.js +0 -19
- package/dist/shared/shell-escape.d.ts +0 -5
- package/dist/shared/shell-escape.js +0 -7
- package/dist/shared/token-estimate.d.ts +0 -1
- package/dist/shared/token-estimate.js +0 -19
- /package/dist/{runtime → events}/event-commands.d.ts +0 -0
- /package/dist/{runtime → events}/event-commands.js +0 -0
- /package/dist/{runtime → events}/event-validation.d.ts +0 -0
- /package/dist/{runtime → events}/event-validation.js +0 -0
- /package/dist/{runtime → events}/events.js +0 -0
- /package/examples/sub-agents/{builder-hard.md → roles/builder-hard.md} +0 -0
- /package/examples/sub-agents/{builder.md → roles/builder.md} +0 -0
- /package/examples/sub-agents/{explorer.md → roles/explorer.md} +0 -0
- /package/examples/sub-agents/{git-committer.md → roles/git-committer.md} +0 -0
- /package/examples/sub-agents/{planner.md → roles/planner.md} +0 -0
- /package/examples/sub-agents/{reviewer.md → roles/reviewer.md} +0 -0
- /package/examples/sub-agents/{verifier.md → roles/verifier.md} +0 -0
- /package/examples/sub-agents/{worker.md → roles/worker.md} +0 -0
package/dist/subagents/tool.js
CHANGED
|
@@ -26,7 +26,7 @@ import { describeToolCall } from "../tools/presentation.js";
|
|
|
26
26
|
import { buildToolSet } from "../tools/registry.js";
|
|
27
27
|
import { DEFAULT_THINKING_LEVEL, externalRoleFingerprint, formatSubAgentList, resolveConfiguredRole, resolveInlineAgent, validateSubAgentTask, withSubAgentsDirWriteDeny, } from "./discovery.js";
|
|
28
28
|
import { launchExternalRun } from "./external/run.js";
|
|
29
|
-
import {
|
|
29
|
+
import { resolveSyncGraceMs } from "./runs.js";
|
|
30
30
|
import { resolveVerificationOutcome } from "./verification-outcome.js";
|
|
31
31
|
import { acquireWorkspaceLease, findWorkspaceLeaseHolder, formatWorkspaceLeaseConflict, releaseWorkspaceLease, } from "./workspace-lease.js";
|
|
32
32
|
/** Shared by both invocation surfaces (spec 046, D2.1). */
|
|
@@ -312,8 +312,8 @@ function withSubagentMemoryWriteDeny(securityConfig, channelDir, workspaceDir) {
|
|
|
312
312
|
}, workspaceDir);
|
|
313
313
|
}
|
|
314
314
|
/**
|
|
315
|
-
* Build a sub-agent's tool set from the shared tool registry, filtered
|
|
316
|
-
*
|
|
315
|
+
* Build a sub-agent's tool set from the shared tool registry, filtered by the shared
|
|
316
|
+
* sub-agent whitelist (files + web). Sub-agents run with their own security context
|
|
317
317
|
* (rooted at the sub-agent workspace) and their own per-invocation bash timeout.
|
|
318
318
|
*/
|
|
319
319
|
function buildSubagentTools(executor, bashTimeoutSec, options, runContext) {
|
|
@@ -452,7 +452,10 @@ function createDetails(input) {
|
|
|
452
452
|
return {
|
|
453
453
|
agent: input.config.name,
|
|
454
454
|
source: input.config.source,
|
|
455
|
-
model: input.modelOverride ??
|
|
455
|
+
model: input.modelOverride ??
|
|
456
|
+
(input.config.runtime === "external"
|
|
457
|
+
? (input.config.externalModelRef ?? "default")
|
|
458
|
+
: formatModelReference(input.config.model)),
|
|
456
459
|
tools: input.toolsOverride ?? [...input.config.tools],
|
|
457
460
|
turns: input.turns,
|
|
458
461
|
toolCalls: input.toolCalls,
|
|
@@ -492,7 +495,7 @@ async function dispatchSubAgentRun(options, currentModel, config, warning, param
|
|
|
492
495
|
// Only ever set for an inline (internal) delegation with `bash` in `tools` and no explicit
|
|
493
496
|
// `mutates` — surfaced to the model, not just a log, since it has no role file to fix.
|
|
494
497
|
const mutatesNote = warning ? `Note: ${warning}\n\n` : "";
|
|
495
|
-
const runManager =
|
|
498
|
+
const runManager = options.getRunManager(options.runtimeContext.channelId);
|
|
496
499
|
// A short, human-typeable id (spec 041) — never the dispatching tool call's own id, which
|
|
497
500
|
// on some providers is a long `call_<id>|fc_<id>` composite unreadable in a chat UI.
|
|
498
501
|
const runContext = await prepareRunContext(runManager.mintRunId(), params, options);
|
|
@@ -516,7 +519,7 @@ async function dispatchSubAgentRun(options, currentModel, config, warning, param
|
|
|
516
519
|
leaseKey = lease.leaseKey;
|
|
517
520
|
}
|
|
518
521
|
if (config.runtime === "external") {
|
|
519
|
-
return dispatchExternalRun({ options, currentModel, config, runLabel, runContext, leaseKey, params });
|
|
522
|
+
return dispatchExternalRun({ options, currentModel, config, runLabel, runContext, leaseKey, params, runManager });
|
|
520
523
|
}
|
|
521
524
|
return dispatchInternalRun({
|
|
522
525
|
options,
|
|
@@ -538,10 +541,6 @@ async function dispatchSubAgentRun(options, currentModel, config, warning, param
|
|
|
538
541
|
*/
|
|
539
542
|
async function dispatchExternalRun(input) {
|
|
540
543
|
const { options, config, runLabel, runContext, leaseKey, params } = input;
|
|
541
|
-
if (!config.harness) {
|
|
542
|
-
releaseWorkspaceLease(leaseKey, runContext.runId);
|
|
543
|
-
throw new Error(`Sub-agent "${config.name}" has runtime: external but no harness configured.`);
|
|
544
|
-
}
|
|
545
544
|
let launchResult;
|
|
546
545
|
try {
|
|
547
546
|
// D9/T5: external roles get the same task envelope internal workers do — runtime
|
|
@@ -550,6 +549,7 @@ async function dispatchExternalRun(input) {
|
|
|
550
549
|
const contextualBlocks = await resolveContextualBlocks(config, options);
|
|
551
550
|
const envelopedTask = buildSubAgentTask(params.task, config, options.runtimeContext, contextualBlocks, runContext);
|
|
552
551
|
launchResult = await launchExternalRun({
|
|
552
|
+
runManager: input.runManager,
|
|
553
553
|
runId: runContext.runId,
|
|
554
554
|
channelId: options.runtimeContext.channelId,
|
|
555
555
|
channelDir: options.channelDir,
|
|
@@ -557,7 +557,7 @@ async function dispatchExternalRun(input) {
|
|
|
557
557
|
agent: config.name,
|
|
558
558
|
source: config.source,
|
|
559
559
|
harness: config.harness,
|
|
560
|
-
command: config.command
|
|
560
|
+
command: config.command,
|
|
561
561
|
shell: config.shell,
|
|
562
562
|
env: config.env,
|
|
563
563
|
externalModelRef: config.externalModelRef,
|
package/dist/tasks/brief.js
CHANGED
|
@@ -43,6 +43,7 @@ export async function buildTaskStepBrief(input) {
|
|
|
43
43
|
blocks.push(`<task_state>\n${renderState(document.fields)}\n</task_state>`);
|
|
44
44
|
blocks.push("推进这个任务的下一个具体步骤,然后必须调用 task_step_end 收尾:" +
|
|
45
45
|
"continue(还能继续)/ park(等一个真实来源)/ done(本周期完成)/ blocked(需要用户决定)。" +
|
|
46
|
+
`派发 run/job 时,首个调用就必须带 taskId=${input.taskId};达成 DoD 后先用 edit 勾选对应验收项,再调用 done。` +
|
|
46
47
|
"默认不向用户发言;契约要求交付、告知、汇报或回复时,必须把实际内容放进 notify,note 不会发送给用户。");
|
|
47
48
|
return blocks.join("\n\n");
|
|
48
49
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { shellEscape } from "../shared/
|
|
1
|
+
import { shellEscape } from "../shared/os.js";
|
|
2
2
|
/**
|
|
3
3
|
* Optional "outbound command transform" for the bash tool. When enabled, a command is
|
|
4
4
|
* handed to the `rtk` binary (https://github.com/rtk-ai/rtk) which rewrites known
|
package/dist/tools/config.d.ts
CHANGED
|
@@ -51,6 +51,13 @@ export interface LoadedToolsConfig {
|
|
|
51
51
|
config: PipiclawToolsConfig;
|
|
52
52
|
diagnostics: ConfigDiagnostic[];
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Every `tools.<key>` section in `tools.json`, read by `test/config-reference-coverage.test.ts`
|
|
56
|
+
* to check that `docs/configuration-reference.md` still mentions each one. Kept in sync with
|
|
57
|
+
* `PipiclawToolsConfig["tools"]` by `satisfies` (rejects an extra/misspelled entry) and
|
|
58
|
+
* `AssertNoMissingKeys` (rejects a section with no entry here) — both at `npm run typecheck`.
|
|
59
|
+
*/
|
|
60
|
+
export declare const TOOLS_CONFIG_SECTION_KEYS: readonly ["web", "tasks", "bashInterceptor", "rtk", "subagentInline"];
|
|
54
61
|
export declare const DEFAULT_TOOLS_CONFIG: PipiclawToolsConfig;
|
|
55
62
|
export declare function getToolsConfigPath(appHomeDir?: string): string;
|
|
56
63
|
export declare function loadToolsConfigWithDiagnostics(appHomeDir?: string): LoadedToolsConfig;
|
package/dist/tools/config.js
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { APP_HOME_DIR } from "../paths.js";
|
|
3
3
|
import { loadJsonConfig, pushConfigWarning } from "../shared/config-diagnostic.js";
|
|
4
|
-
import { clampInteger } from "../shared/
|
|
4
|
+
import { clampInteger } from "../shared/format.js";
|
|
5
5
|
import { isRecord } from "../shared/type-guards.js";
|
|
6
|
+
/**
|
|
7
|
+
* Every `tools.<key>` section in `tools.json`, read by `test/config-reference-coverage.test.ts`
|
|
8
|
+
* to check that `docs/configuration-reference.md` still mentions each one. Kept in sync with
|
|
9
|
+
* `PipiclawToolsConfig["tools"]` by `satisfies` (rejects an extra/misspelled entry) and
|
|
10
|
+
* `AssertNoMissingKeys` (rejects a section with no entry here) — both at `npm run typecheck`.
|
|
11
|
+
*/
|
|
12
|
+
export const TOOLS_CONFIG_SECTION_KEYS = [
|
|
13
|
+
"web",
|
|
14
|
+
"tasks",
|
|
15
|
+
"bashInterceptor",
|
|
16
|
+
"rtk",
|
|
17
|
+
"subagentInline",
|
|
18
|
+
];
|
|
19
|
+
const _toolsConfigKeysComplete = true;
|
|
20
|
+
void _toolsConfigKeysComplete;
|
|
6
21
|
const WEB_SEARCH_PROVIDERS = ["brave", "tavily", "jina", "searxng", "duckduckgo"];
|
|
7
22
|
export const DEFAULT_TOOLS_CONFIG = {
|
|
8
23
|
tools: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
-
import { type ScheduledEvent } from "../
|
|
3
|
+
import { type ScheduledEvent } from "../events/events.js";
|
|
4
4
|
import type { SecurityConfig } from "../security/types.js";
|
|
5
5
|
declare const eventManageSchema: Type.TObject<{
|
|
6
6
|
action: Type.TUnion<[Type.TLiteral<"list">, Type.TLiteral<"show">, Type.TLiteral<"create">, Type.TLiteral<"update">, Type.TLiteral<"delete">]>;
|
|
@@ -2,9 +2,9 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { readdir, readFile, unlink } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { Type } from "typebox";
|
|
5
|
-
import { resolveEventPath } from "../
|
|
6
|
-
import { EventValidationError, MAX_EVENT_FILES, validateScheduledEvent } from "../
|
|
7
|
-
import { parseScheduledEventContent } from "../
|
|
5
|
+
import { resolveEventPath } from "../events/event-commands.js";
|
|
6
|
+
import { EventValidationError, MAX_EVENT_FILES, validateScheduledEvent } from "../events/event-validation.js";
|
|
7
|
+
import { parseScheduledEventContent } from "../events/events.js";
|
|
8
8
|
import { writeFileAtomically } from "../shared/atomic-file.js";
|
|
9
9
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
10
10
|
import { clipText, errorMessage } from "../shared/text-utils.js";
|
package/dist/tools/grep.js
CHANGED
|
@@ -3,8 +3,8 @@ import { Type } from "typebox";
|
|
|
3
3
|
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
4
4
|
import { checkPathGuard } from "../security/path-guard-check.js";
|
|
5
5
|
import { partitionByReadGuard, readGuardAllows } from "../security/path-guard-filter.js";
|
|
6
|
+
import { shellEscape } from "../shared/os.js";
|
|
6
7
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
7
|
-
import { shellEscape } from "../shared/shell-escape.js";
|
|
8
8
|
import { IGNORED_DIR_SEGMENTS } from "./ignore-dirs.js";
|
|
9
9
|
import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
|
|
10
10
|
/**
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import type { Api, Model } from "@earendil-works/pi-ai";
|
|
3
|
+
import type { ChannelJobManager } from "../agent/job-manager.js";
|
|
3
4
|
import type { MediaSender } from "../channel/channel-context.js";
|
|
4
5
|
import type { Executor } from "../executor.js";
|
|
5
6
|
import type { FileStore } from "../file-store.js";
|
|
@@ -7,8 +8,11 @@ import type { ProjectScope } from "../security/project-scope.js";
|
|
|
7
8
|
import type { SecurityConfig } from "../security/types.js";
|
|
8
9
|
import type { PipiclawSessionSearchSettings } from "../settings.js";
|
|
9
10
|
import { type SubAgentDiscoveryResult } from "../subagents/discovery.js";
|
|
11
|
+
import type { SubAgentRunManager } from "../subagents/runs.js";
|
|
10
12
|
import type { PipiclawToolsConfig } from "./config.js";
|
|
11
13
|
export interface CreatePipiclawToolsOptions {
|
|
14
|
+
jobManager: ChannelJobManager;
|
|
15
|
+
runManager: SubAgentRunManager;
|
|
12
16
|
executor: Executor;
|
|
13
17
|
/** File-content port for the generic file tools (spec 044, D1); `Executor` stays command-only. */
|
|
14
18
|
fileStore: FileStore;
|
package/dist/tools/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getChannelJobManager } from "../agent/job-manager.js";
|
|
2
1
|
import { APP_HOME_DIR } from "../paths.js";
|
|
3
2
|
import { loadSecurityConfig } from "../security/config.js";
|
|
4
3
|
import { withSubAgentsDirWriteDeny } from "../subagents/discovery.js";
|
|
@@ -37,7 +36,8 @@ export function createPipiclawTools(options) {
|
|
|
37
36
|
webConfig: toolsConfig.tools.web,
|
|
38
37
|
toolsConfig,
|
|
39
38
|
rtkEnabled: toolsConfig.tools.rtk.enabled,
|
|
40
|
-
jobManager:
|
|
39
|
+
jobManager: options.jobManager,
|
|
40
|
+
runManager: options.runManager,
|
|
41
41
|
getCurrentModel: options.getCurrentModel,
|
|
42
42
|
getAvailableModels: options.getAvailableModels,
|
|
43
43
|
resolveApiKey: options.resolveApiKey,
|
|
@@ -47,6 +47,7 @@ export function createPipiclawTools(options) {
|
|
|
47
47
|
getToolsUsed: options.getToolsUsed,
|
|
48
48
|
});
|
|
49
49
|
const subAgentToolOptions = {
|
|
50
|
+
getRunManager: () => options.runManager,
|
|
50
51
|
executor: options.executor,
|
|
51
52
|
fileStore: options.fileStore,
|
|
52
53
|
getCurrentModel: options.getCurrentModel,
|
|
@@ -69,6 +70,7 @@ export function createPipiclawTools(options) {
|
|
|
69
70
|
},
|
|
70
71
|
};
|
|
71
72
|
const subAgentManageOptions = {
|
|
73
|
+
runManager: options.runManager,
|
|
72
74
|
channelId: options.channelId,
|
|
73
75
|
channelDir: options.channelDir,
|
|
74
76
|
getSubAgentDiscovery: options.getSubAgentDiscovery,
|
package/dist/tools/job.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Type } from "typebox";
|
|
2
|
-
import { formatDuration } from "../shared/
|
|
2
|
+
import { formatDuration } from "../shared/format.js";
|
|
3
3
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
4
4
|
import { truncateTail } from "./truncate.js";
|
|
5
5
|
const jobSchema = Type.Object({
|
package/dist/tools/read.js
CHANGED
|
@@ -2,8 +2,8 @@ import { extname } from "path";
|
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
4
4
|
import { checkPathGuard } from "../security/path-guard-check.js";
|
|
5
|
+
import { shellEscape } from "../shared/os.js";
|
|
5
6
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
6
|
-
import { shellEscape } from "../shared/shell-escape.js";
|
|
7
7
|
import { resolveLineOffset } from "./line-index.js";
|
|
8
8
|
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, MAX_INLINE_BINARY_BYTES, truncateHead, } from "./truncate.js";
|
|
9
9
|
/**
|
package/dist/tools/registry.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { Executor } from "../executor.js";
|
|
|
6
6
|
import type { FileStore } from "../file-store.js";
|
|
7
7
|
import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
|
|
8
8
|
import type { PipiclawSessionSearchSettings } from "../settings.js";
|
|
9
|
+
import type { SubAgentRunManager } from "../subagents/runs.js";
|
|
9
10
|
import type { PipiclawToolsConfig, PipiclawWebToolsConfig } from "./config.js";
|
|
10
11
|
import { type ToolDetailsKind } from "./tool-details.js";
|
|
11
12
|
/**
|
|
@@ -45,6 +46,7 @@ export interface ToolBuildContext {
|
|
|
45
46
|
* The sub-agent set never supplies it, so sub-agents get neither.
|
|
46
47
|
*/
|
|
47
48
|
jobManager?: ChannelJobManager;
|
|
49
|
+
runManager?: SubAgentRunManager;
|
|
48
50
|
getCurrentModel?: () => Model<Api>;
|
|
49
51
|
getAvailableModels?: () => Model<Api>[];
|
|
50
52
|
resolveApiKey?: (model: Model<Api>) => Promise<string>;
|
|
@@ -69,8 +71,6 @@ export interface ToolBuildContext {
|
|
|
69
71
|
export interface ToolRegistration {
|
|
70
72
|
/** Also the tool's `details.kind`: the name is the authoritative discriminator. */
|
|
71
73
|
name: ToolDetailsKind;
|
|
72
|
-
/** Whether this tool is included in a sub-agent's tool set. */
|
|
73
|
-
availableToSubagents: boolean;
|
|
74
74
|
/** Config gate; when omitted the tool is always enabled. */
|
|
75
75
|
enabledBy?: (ctx: ToolBuildContext) => boolean;
|
|
76
76
|
create: (ctx: ToolBuildContext) => AgentTool<any>;
|
|
@@ -95,7 +95,7 @@ export declare const TOOL_REGISTRY: ToolRegistration[];
|
|
|
95
95
|
*/
|
|
96
96
|
export declare const TOOL_NAMES: ReadonlySet<string>;
|
|
97
97
|
export interface BuildToolSetOptions {
|
|
98
|
-
/** When true, include only tools
|
|
98
|
+
/** When true, include only tools in the sub-agent whitelist. */
|
|
99
99
|
forSubagent?: boolean;
|
|
100
100
|
}
|
|
101
101
|
/**
|
package/dist/tools/registry.js
CHANGED
|
@@ -9,6 +9,7 @@ import { createReadTool } from "./read.js";
|
|
|
9
9
|
import { createSendMediaTool } from "./send-media.js";
|
|
10
10
|
import { createSessionSearchTool } from "./session-search.js";
|
|
11
11
|
import { createSkillTool } from "./skill.js";
|
|
12
|
+
import { SUBAGENT_TOOL_NAMES } from "./subagent-tool-names.js";
|
|
12
13
|
import { createTaskCloseTool, createTaskCreateTool, createTaskListTool, createTaskLogTool, createTaskStepEndTool, createTaskUpdateTool, } from "./task-manage.js";
|
|
13
14
|
import { withToolDetails } from "./tool-details.js";
|
|
14
15
|
import { createWebFetchTool } from "./web-fetch.js";
|
|
@@ -34,6 +35,16 @@ function memoryToolOptions(ctx) {
|
|
|
34
35
|
workspaceDir: ctx.workspaceDir,
|
|
35
36
|
};
|
|
36
37
|
}
|
|
38
|
+
function taskToolOptions(ctx) {
|
|
39
|
+
return {
|
|
40
|
+
jobManager: req(ctx.jobManager, "jobManager"),
|
|
41
|
+
runManager: req(ctx.runManager, "runManager"),
|
|
42
|
+
workspaceDir: ctx.workspaceDir,
|
|
43
|
+
channelDir: ctx.channelDir,
|
|
44
|
+
channelId: ctx.channelId,
|
|
45
|
+
workingDirectory: ctx.securityContext.projectRoot,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
37
48
|
function webEnabled(ctx) {
|
|
38
49
|
return ctx.webConfig != null && ctx.webConfig.enable !== false;
|
|
39
50
|
}
|
|
@@ -46,12 +57,10 @@ function webEnabled(ctx) {
|
|
|
46
57
|
export const TOOL_REGISTRY = [
|
|
47
58
|
{
|
|
48
59
|
name: "read",
|
|
49
|
-
availableToSubagents: true,
|
|
50
60
|
create: (ctx) => createReadTool(ctx.executor, ctx.fileStore, fileToolOptions(ctx)),
|
|
51
61
|
},
|
|
52
62
|
{
|
|
53
63
|
name: "bash",
|
|
54
|
-
availableToSubagents: true,
|
|
55
64
|
create: (ctx) => createBashTool(ctx.executor, {
|
|
56
65
|
...fileToolOptions(ctx),
|
|
57
66
|
rtkEnabled: ctx.rtkEnabled === true,
|
|
@@ -67,27 +76,22 @@ export const TOOL_REGISTRY = [
|
|
|
67
76
|
},
|
|
68
77
|
{
|
|
69
78
|
name: "edit",
|
|
70
|
-
availableToSubagents: true,
|
|
71
79
|
create: (ctx) => createEditTool(ctx.fileStore, fileToolOptions(ctx)),
|
|
72
80
|
},
|
|
73
81
|
{
|
|
74
82
|
name: "grep",
|
|
75
|
-
availableToSubagents: true,
|
|
76
83
|
create: (ctx) => createGrepTool(ctx.executor, fileToolOptions(ctx)),
|
|
77
84
|
},
|
|
78
85
|
{
|
|
79
86
|
name: "glob",
|
|
80
|
-
availableToSubagents: true,
|
|
81
87
|
create: (ctx) => createGlobTool(ctx.fileStore, fileToolOptions(ctx)),
|
|
82
88
|
},
|
|
83
89
|
{
|
|
84
90
|
name: "write",
|
|
85
|
-
availableToSubagents: true,
|
|
86
91
|
create: (ctx) => createWriteTool(ctx.fileStore, fileToolOptions(ctx)),
|
|
87
92
|
},
|
|
88
93
|
{
|
|
89
94
|
name: "web_search",
|
|
90
|
-
availableToSubagents: true,
|
|
91
95
|
enabledBy: webEnabled,
|
|
92
96
|
create: (ctx) => createWebSearchTool({
|
|
93
97
|
webConfig: req(ctx.webConfig, "webConfig"),
|
|
@@ -98,7 +102,6 @@ export const TOOL_REGISTRY = [
|
|
|
98
102
|
},
|
|
99
103
|
{
|
|
100
104
|
name: "web_fetch",
|
|
101
|
-
availableToSubagents: true,
|
|
102
105
|
enabledBy: webEnabled,
|
|
103
106
|
create: (ctx) => createWebFetchTool({
|
|
104
107
|
webConfig: req(ctx.webConfig, "webConfig"),
|
|
@@ -110,7 +113,6 @@ export const TOOL_REGISTRY = [
|
|
|
110
113
|
},
|
|
111
114
|
{
|
|
112
115
|
name: "send_media",
|
|
113
|
-
availableToSubagents: false,
|
|
114
116
|
// Enabled only when the driving transport supplied a media sender (the DingTalk
|
|
115
117
|
// bot, or the terminal). Absent it, the tool is not built or advertised.
|
|
116
118
|
enabledBy: (ctx) => ctx.mediaSender != null,
|
|
@@ -123,7 +125,6 @@ export const TOOL_REGISTRY = [
|
|
|
123
125
|
},
|
|
124
126
|
{
|
|
125
127
|
name: "session_search",
|
|
126
|
-
availableToSubagents: false,
|
|
127
128
|
create: (ctx) => createSessionSearchTool({
|
|
128
129
|
channelId: ctx.channelId,
|
|
129
130
|
channelDir: ctx.channelDir,
|
|
@@ -135,27 +136,22 @@ export const TOOL_REGISTRY = [
|
|
|
135
136
|
// Spec 047, P4: one tool per payload shape. All three share the same build options.
|
|
136
137
|
{
|
|
137
138
|
name: "memory_save",
|
|
138
|
-
availableToSubagents: false,
|
|
139
139
|
create: (ctx) => createMemorySaveTool(memoryToolOptions(ctx)),
|
|
140
140
|
},
|
|
141
141
|
{
|
|
142
142
|
name: "memory_search",
|
|
143
|
-
availableToSubagents: false,
|
|
144
143
|
create: (ctx) => createMemorySearchTool(memoryToolOptions(ctx)),
|
|
145
144
|
},
|
|
146
145
|
{
|
|
147
146
|
name: "memory_forget",
|
|
148
|
-
availableToSubagents: false,
|
|
149
147
|
create: (ctx) => createMemoryForgetTool(memoryToolOptions(ctx)),
|
|
150
148
|
},
|
|
151
149
|
{
|
|
152
150
|
name: "skill",
|
|
153
|
-
availableToSubagents: false,
|
|
154
151
|
create: (ctx) => createSkillTool({ workspaceDir: ctx.workspaceDir, ...fileToolOptions(ctx) }),
|
|
155
152
|
},
|
|
156
153
|
{
|
|
157
154
|
name: "event_manage",
|
|
158
|
-
availableToSubagents: false,
|
|
159
155
|
create: (ctx) => createEventManageTool({
|
|
160
156
|
workspaceDir: ctx.workspaceDir,
|
|
161
157
|
channelId: ctx.channelId,
|
|
@@ -167,68 +163,35 @@ export const TOOL_REGISTRY = [
|
|
|
167
163
|
// shape (spec 046, D3.1) — all share it, since none is meaningful without the others.
|
|
168
164
|
{
|
|
169
165
|
name: "task_list",
|
|
170
|
-
availableToSubagents: false,
|
|
171
166
|
enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false,
|
|
172
|
-
create: (ctx) => createTaskListTool(
|
|
173
|
-
workspaceDir: ctx.workspaceDir,
|
|
174
|
-
channelDir: ctx.channelDir,
|
|
175
|
-
channelId: ctx.channelId,
|
|
176
|
-
workingDirectory: ctx.securityContext.projectRoot,
|
|
177
|
-
}),
|
|
167
|
+
create: (ctx) => createTaskListTool(taskToolOptions(ctx)),
|
|
178
168
|
},
|
|
179
169
|
{
|
|
180
170
|
name: "task_create",
|
|
181
|
-
availableToSubagents: false,
|
|
182
171
|
enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false,
|
|
183
|
-
create: (ctx) => createTaskCreateTool(
|
|
184
|
-
workspaceDir: ctx.workspaceDir,
|
|
185
|
-
channelDir: ctx.channelDir,
|
|
186
|
-
channelId: ctx.channelId,
|
|
187
|
-
workingDirectory: ctx.securityContext.projectRoot,
|
|
188
|
-
}),
|
|
172
|
+
create: (ctx) => createTaskCreateTool(taskToolOptions(ctx)),
|
|
189
173
|
},
|
|
190
174
|
{
|
|
191
175
|
name: "task_update",
|
|
192
|
-
availableToSubagents: false,
|
|
193
176
|
enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false,
|
|
194
|
-
create: (ctx) => createTaskUpdateTool(
|
|
195
|
-
workspaceDir: ctx.workspaceDir,
|
|
196
|
-
channelDir: ctx.channelDir,
|
|
197
|
-
channelId: ctx.channelId,
|
|
198
|
-
workingDirectory: ctx.securityContext.projectRoot,
|
|
199
|
-
}),
|
|
177
|
+
create: (ctx) => createTaskUpdateTool(taskToolOptions(ctx)),
|
|
200
178
|
},
|
|
201
179
|
{
|
|
202
180
|
name: "task_close",
|
|
203
|
-
availableToSubagents: false,
|
|
204
181
|
enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false,
|
|
205
|
-
create: (ctx) => createTaskCloseTool(
|
|
206
|
-
workspaceDir: ctx.workspaceDir,
|
|
207
|
-
channelDir: ctx.channelDir,
|
|
208
|
-
channelId: ctx.channelId,
|
|
209
|
-
workingDirectory: ctx.securityContext.projectRoot,
|
|
210
|
-
}),
|
|
182
|
+
create: (ctx) => createTaskCloseTool(taskToolOptions(ctx)),
|
|
211
183
|
},
|
|
212
184
|
{
|
|
213
185
|
name: "task_log",
|
|
214
|
-
availableToSubagents: false,
|
|
215
186
|
enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false,
|
|
216
|
-
create: (ctx) => createTaskLogTool(
|
|
217
|
-
workspaceDir: ctx.workspaceDir,
|
|
218
|
-
channelDir: ctx.channelDir,
|
|
219
|
-
channelId: ctx.channelId,
|
|
220
|
-
}),
|
|
187
|
+
create: (ctx) => createTaskLogTool(taskToolOptions(ctx)),
|
|
221
188
|
},
|
|
222
189
|
{
|
|
223
190
|
name: "task_step_end",
|
|
224
|
-
availableToSubagents: false,
|
|
225
191
|
// Only inside a task session: it is the loop's closing move, not a chat action.
|
|
226
192
|
enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false && ctx.taskLoop !== undefined,
|
|
227
193
|
create: (ctx) => createTaskStepEndTool({
|
|
228
|
-
|
|
229
|
-
channelDir: ctx.channelDir,
|
|
230
|
-
channelId: ctx.channelId,
|
|
231
|
-
workingDirectory: ctx.securityContext.projectRoot,
|
|
194
|
+
...taskToolOptions(ctx),
|
|
232
195
|
taskId: ctx.taskLoop?.taskId,
|
|
233
196
|
cycleId: ctx.taskLoop?.cycleId,
|
|
234
197
|
getToolsUsed: ctx.getToolsUsed,
|
|
@@ -236,7 +199,6 @@ export const TOOL_REGISTRY = [
|
|
|
236
199
|
},
|
|
237
200
|
{
|
|
238
201
|
name: "job",
|
|
239
|
-
availableToSubagents: false,
|
|
240
202
|
// Present only when a job manager was supplied (always on the main path,
|
|
241
203
|
// never for sub-agents).
|
|
242
204
|
enabledBy: (ctx) => ctx.jobManager !== undefined,
|
|
@@ -272,7 +234,7 @@ export const TOOL_NAMES = new Set([
|
|
|
272
234
|
export function buildToolSet(ctx, options = {}) {
|
|
273
235
|
const result = [];
|
|
274
236
|
for (const registration of TOOL_REGISTRY) {
|
|
275
|
-
if (options.forSubagent && !registration.
|
|
237
|
+
if (options.forSubagent && !SUBAGENT_TOOL_NAMES.some((name) => name === registration.name)) {
|
|
276
238
|
continue;
|
|
277
239
|
}
|
|
278
240
|
if (registration.enabledBy && !registration.enabledBy(ctx)) {
|
package/dist/tools/skill.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Type } from "typebox";
|
|
|
5
5
|
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
6
6
|
import { checkPathGuard } from "../security/path-guard-check.js";
|
|
7
7
|
import { readGuardAllows } from "../security/path-guard-filter.js";
|
|
8
|
-
import { isNodeError } from "../shared/
|
|
8
|
+
import { isNodeError } from "../shared/os.js";
|
|
9
9
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
10
10
|
import { resolveSkillPath, scanSkillContent, validateSkillFrontmatter, validateSkillName } from "./skill-security.js";
|
|
11
11
|
import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
|
|
@@ -2,6 +2,7 @@ import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
import type { SecurityConfig } from "../security/types.js";
|
|
4
4
|
import { type SubAgentDiscoveryResult } from "../subagents/discovery.js";
|
|
5
|
+
import type { SubAgentRunManager } from "../subagents/runs.js";
|
|
5
6
|
declare const subagentListSchema: Type.TObject<{}>;
|
|
6
7
|
declare const subagentRunSchema: Type.TObject<{
|
|
7
8
|
op: Type.TUnion<[Type.TLiteral<"show">, Type.TLiteral<"cancel">, Type.TLiteral<"follow_up">]>;
|
|
@@ -9,6 +10,7 @@ declare const subagentRunSchema: Type.TObject<{
|
|
|
9
10
|
task: Type.TOptional<Type.TString>;
|
|
10
11
|
}>;
|
|
11
12
|
export interface SubAgentManageToolOptions {
|
|
13
|
+
runManager: SubAgentRunManager;
|
|
12
14
|
channelId: string;
|
|
13
15
|
/**
|
|
14
16
|
* Spec 042 D7: required, not defaulted. `follow_up` dispatches a new external process through
|
|
@@ -6,7 +6,6 @@ import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
|
6
6
|
import { externalRoleFingerprint, validateSubAgentTask } from "../subagents/discovery.js";
|
|
7
7
|
import { launchExternalRun } from "../subagents/external/run.js";
|
|
8
8
|
import { formatCost, formatRunDuration, harnessLabel } from "../subagents/format.js";
|
|
9
|
-
import { getSubAgentRunManager } from "../subagents/runs.js";
|
|
10
9
|
import { assertVerifyAdmissible, assertWithinProjectBoundary, buildContextualBlocks, buildSubAgentTask, } from "../subagents/tool.js";
|
|
11
10
|
import { acquireWorkspaceLease, formatWorkspaceLeaseConflict, releaseWorkspaceLease, } from "../subagents/workspace-lease.js";
|
|
12
11
|
// Spec 047, P3: `subagent_list` is zero-argument and shape-independent (like `task_list`); the
|
|
@@ -91,7 +90,7 @@ function resumableHarnessOf(record) {
|
|
|
91
90
|
return record.harness === "codex-cli" || record.harness === "claude-code" ? record.harness : undefined;
|
|
92
91
|
}
|
|
93
92
|
export function createSubAgentListTool(options) {
|
|
94
|
-
const manager =
|
|
93
|
+
const manager = options.runManager;
|
|
95
94
|
return {
|
|
96
95
|
name: "subagent_list",
|
|
97
96
|
label: "subagent_list",
|
|
@@ -102,7 +101,7 @@ export function createSubAgentListTool(options) {
|
|
|
102
101
|
// text and `details.runs` — a long-lived channel could dump thousands of historical
|
|
103
102
|
// records into a single tool result. Running runs (the ones a decision might depend
|
|
104
103
|
// on) are never dropped; only the terminal tail is capped, newest first.
|
|
105
|
-
const allRuns = manager
|
|
104
|
+
const allRuns = manager.list();
|
|
106
105
|
const running = allRuns.filter((record) => record.status === "running");
|
|
107
106
|
const terminal = allRuns
|
|
108
107
|
.filter((record) => record.status !== "running")
|
|
@@ -121,7 +120,7 @@ export function createSubAgentListTool(options) {
|
|
|
121
120
|
};
|
|
122
121
|
}
|
|
123
122
|
export function createSubAgentRunTool(options) {
|
|
124
|
-
const manager =
|
|
123
|
+
const manager = options.runManager;
|
|
125
124
|
return {
|
|
126
125
|
name: "subagent_run",
|
|
127
126
|
label: "subagent_run",
|
|
@@ -129,7 +128,7 @@ export function createSubAgentRunTool(options) {
|
|
|
129
128
|
"(no wake — your decision, not a failure). follow_up: continue a resumable run with a new instruction (new runId).",
|
|
130
129
|
parameters: subagentRunSchema,
|
|
131
130
|
execute: async (_toolCallId, { op, runId, task }) => {
|
|
132
|
-
const resolution = manager
|
|
131
|
+
const resolution = manager.resolveRef(runId);
|
|
133
132
|
if (resolution.kind === "ambiguous") {
|
|
134
133
|
throw new RecoverableToolError(`"${runId}" matches multiple runs on this channel: ${resolution.candidates.map((candidate) => candidate.runId).join(", ")}. Use the full runId.`);
|
|
135
134
|
}
|
|
@@ -145,7 +144,7 @@ export function createSubAgentRunTool(options) {
|
|
|
145
144
|
};
|
|
146
145
|
}
|
|
147
146
|
if (op === "cancel") {
|
|
148
|
-
const status = await manager
|
|
147
|
+
const status = await manager.cancel(resolvedRunId);
|
|
149
148
|
return {
|
|
150
149
|
content: [{ type: "text", text: `Cancel requested for run ${resolvedRunId}: ${status}` }],
|
|
151
150
|
details: { op, runId: resolvedRunId, status },
|
|
@@ -213,7 +212,7 @@ export function createSubAgentRunTool(options) {
|
|
|
213
212
|
}
|
|
214
213
|
// A short, human-typeable id (spec 041) — the follow-up gets a fresh identity, not the
|
|
215
214
|
// dispatching tool call's own id.
|
|
216
|
-
const newRunId = manager
|
|
215
|
+
const newRunId = manager.mintRunId();
|
|
217
216
|
let leaseKey;
|
|
218
217
|
if (role.mutates === "write") {
|
|
219
218
|
const lease = acquireWorkspaceLease({
|
|
@@ -250,6 +249,7 @@ export function createSubAgentRunTool(options) {
|
|
|
250
249
|
});
|
|
251
250
|
const envelopedTask = buildSubAgentTask(task, role, { workspaceDir: options.workspaceDir, channelId: options.channelId }, contextualBlocks, runContext);
|
|
252
251
|
launchResult = await launchExternalRun({
|
|
252
|
+
runManager: manager,
|
|
253
253
|
runId: newRunId,
|
|
254
254
|
channelId: options.channelId,
|
|
255
255
|
channelDir: options.channelDir,
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* The single source of truth for which tools a sub-agent role may request.
|
|
3
3
|
*
|
|
4
4
|
* This is a leaf module with no imports so both ends can read it without pulling in a cycle:
|
|
5
|
-
* `registry.ts`
|
|
5
|
+
* `registry.ts` filters the sub-agent tool set through it, and
|
|
6
6
|
* `subagents/discovery.ts` validates a role file's `tools:` list against it. They used to be two
|
|
7
7
|
* hand-maintained lists and had already drifted (`glob` was build-available but validation-rejected).
|
|
8
|
-
* A test
|
|
8
|
+
* A test checks that every allowed name has a registered implementation.
|
|
9
9
|
*/
|
|
10
10
|
export declare const SUBAGENT_TOOL_NAMES: readonly ["read", "grep", "glob", "bash", "edit", "write", "web_search", "web_fetch"];
|
|
11
11
|
export type SubAgentToolName = (typeof SUBAGENT_TOOL_NAMES)[number];
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* The single source of truth for which tools a sub-agent role may request.
|
|
3
3
|
*
|
|
4
4
|
* This is a leaf module with no imports so both ends can read it without pulling in a cycle:
|
|
5
|
-
* `registry.ts`
|
|
5
|
+
* `registry.ts` filters the sub-agent tool set through it, and
|
|
6
6
|
* `subagents/discovery.ts` validates a role file's `tools:` list against it. They used to be two
|
|
7
7
|
* hand-maintained lists and had already drifted (`glob` was build-available but validation-rejected).
|
|
8
|
-
* A test
|
|
8
|
+
* A test checks that every allowed name has a registered implementation.
|
|
9
9
|
*/
|
|
10
10
|
export const SUBAGENT_TOOL_NAMES = [
|
|
11
11
|
"read",
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { readdir, readFile, unlink } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import {
|
|
5
|
-
import { createExecutor } from "../../executor.js";
|
|
4
|
+
import { parseScheduledEventContent } from "../../events/events.js";
|
|
6
5
|
import * as log from "../../log.js";
|
|
7
|
-
import { parseScheduledEventContent } from "../../runtime/events.js";
|
|
8
6
|
import { parseLocalTime } from "../../shared/local-time.js";
|
|
9
7
|
import { errorMessage } from "../../shared/text-utils.js";
|
|
10
|
-
import { getSubAgentRunManager } from "../../subagents/runs.js";
|
|
11
8
|
import { createCycle, nextCycleId } from "../../tasks/cycle.js";
|
|
12
9
|
import { renderStandardTaskBody, renderTaskDocument } from "../../tasks/ledger.js";
|
|
13
10
|
import { parseTaskEventName } from "../../tasks/task-events.js";
|
|
@@ -128,10 +125,8 @@ export function describeTaskState(fields) {
|
|
|
128
125
|
* validation matrix unit-testable against plain fakes.
|
|
129
126
|
*/
|
|
130
127
|
export async function buildTicketContext(options, taskId, schedule, now = new Date()) {
|
|
131
|
-
const runManager =
|
|
132
|
-
const jobs = await
|
|
133
|
-
.list()
|
|
134
|
-
.catch(() => []);
|
|
128
|
+
const runManager = options.runManager;
|
|
129
|
+
const jobs = await options.jobManager.list().catch(() => []);
|
|
135
130
|
const events = await readChannelEvents(options);
|
|
136
131
|
return {
|
|
137
132
|
now,
|
|
@@ -216,7 +211,7 @@ export async function cleanupTaskEvents(options, id) {
|
|
|
216
211
|
export async function assertVerificationHoldsForClose(options, document, id) {
|
|
217
212
|
if (document.fields.verify !== "required")
|
|
218
213
|
return;
|
|
219
|
-
const runManager =
|
|
214
|
+
const runManager = options.runManager;
|
|
220
215
|
const reason = await completionVerificationBlockReason({
|
|
221
216
|
channelDir: options.channelDir,
|
|
222
217
|
taskId: id,
|