@oyasmi/pipiclaw 0.9.4-beta.1 → 0.9.4
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 +10 -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
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared shapes for delegation dispatch: the options the composition root hands in, the per-run
|
|
3
|
+
* context, the worker surface, and the details payload every dispatch returns. Types only, so the
|
|
4
|
+
* dispatch, envelope, internal and external modules can all import them without forming a cycle.
|
|
5
|
+
*/
|
|
6
|
+
import type { AgentEvent, AgentMessage, AgentState, AgentTool } from "@earendil-works/pi-agent-core";
|
|
7
|
+
import type { Api, Model } from "@earendil-works/pi-ai";
|
|
8
|
+
import type { PipiclawWebToolsConfig } from "../config/tools.js";
|
|
9
|
+
import type { Executor } from "../executor.js";
|
|
10
|
+
import type { FileStore } from "../file-store.js";
|
|
11
|
+
import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
|
|
12
|
+
import type { UsageTotals } from "../usage/totals.js";
|
|
13
|
+
import type { ResolvedInternalSubAgentConfig, SubAgentDiscoveryResult } from "./discovery.js";
|
|
14
|
+
import type { SubAgentRunManager } from "./runs.js";
|
|
15
|
+
/**
|
|
16
|
+
* Fields every delegation dispatch returns as its tool-result details. `kind` is not among them: `withToolDetails`
|
|
17
|
+
* stamps it from the registration name when the tool set is built (see `tools/contract/details.ts`; `tools/subagent.ts` exports the stamped `SubAgentToolDetails`).
|
|
18
|
+
*/
|
|
19
|
+
export interface SubAgentToolFields {
|
|
20
|
+
agent: string;
|
|
21
|
+
source: "predefined" | "inline";
|
|
22
|
+
model: string;
|
|
23
|
+
tools: string[];
|
|
24
|
+
turns: number;
|
|
25
|
+
toolCalls: number;
|
|
26
|
+
durationMs: number;
|
|
27
|
+
failed: boolean;
|
|
28
|
+
failureReason?: string;
|
|
29
|
+
usage: UsageTotals;
|
|
30
|
+
runId: string;
|
|
31
|
+
purpose: "work" | "verify";
|
|
32
|
+
taskId?: string;
|
|
33
|
+
verificationVerdict?: "pass" | "fail";
|
|
34
|
+
/** Always populated (spec 032 D4): the full output is saved to `${artifactDir}/output.md`. */
|
|
35
|
+
artifactDir: string;
|
|
36
|
+
/** True when the reply text was truncated against MAX_SUBAGENT_RESULT_UNITS; the full text is still on disk. */
|
|
37
|
+
resultTruncated: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* True only for the "still running" placeholder returned once the sync grace window elapses
|
|
40
|
+
* (spec 040, D2). The run keeps executing; its eventual result arrives as a completion wake,
|
|
41
|
+
* not as another tool result.
|
|
42
|
+
*/
|
|
43
|
+
dispatched?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** Exported for `subagent_run op=follow_up` (spec 042 D7), which constructs one of these for
|
|
46
|
+
* its own new run rather than a hand-rolled envelope. */
|
|
47
|
+
export interface SubAgentRunContext {
|
|
48
|
+
runId: string;
|
|
49
|
+
purpose: "work" | "verify";
|
|
50
|
+
taskId?: string;
|
|
51
|
+
item?: string;
|
|
52
|
+
workingDirectory: string;
|
|
53
|
+
artifactDir: string;
|
|
54
|
+
}
|
|
55
|
+
/** The delegation parameters both invocation surfaces share (`task` plus routing). */
|
|
56
|
+
export interface DelegationParams {
|
|
57
|
+
task: string;
|
|
58
|
+
workingDirectory?: string;
|
|
59
|
+
purpose?: "work" | "verify";
|
|
60
|
+
taskId?: string;
|
|
61
|
+
item?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface SubAgentWorker {
|
|
64
|
+
state: {
|
|
65
|
+
messages: AgentMessage[];
|
|
66
|
+
tools: AgentTool<any>[];
|
|
67
|
+
model?: Model<Api>;
|
|
68
|
+
thinkingLevel?: AgentState["thinkingLevel"];
|
|
69
|
+
};
|
|
70
|
+
subscribe(listener: (event: AgentEvent) => void): () => void;
|
|
71
|
+
abort(): void;
|
|
72
|
+
prompt(input: string): Promise<void>;
|
|
73
|
+
/** Resume from the current transcript (last message a user or tool result). Without it a
|
|
74
|
+
* provider error cannot be retried in place, so the run fails as before. */
|
|
75
|
+
continue?(): Promise<void>;
|
|
76
|
+
waitForIdle(): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Everything the tool registry needs to build one sub-agent's tool set. Declared here, not
|
|
80
|
+
* imported, so `subagents/` never depends on `tools/`: the composition root injects
|
|
81
|
+
* `buildWorkerTools` (spec 054 D9). Structurally a subset of `ToolBuildContext`.
|
|
82
|
+
*/
|
|
83
|
+
export interface WorkerToolRequest {
|
|
84
|
+
executor: Executor;
|
|
85
|
+
fileStore: FileStore;
|
|
86
|
+
securityConfig: SecurityConfig;
|
|
87
|
+
securityContext: SecurityRuntimeContext;
|
|
88
|
+
channelId: string;
|
|
89
|
+
channelDir: string;
|
|
90
|
+
workspaceDir: string;
|
|
91
|
+
webConfig?: PipiclawWebToolsConfig;
|
|
92
|
+
rtkEnabled?: boolean;
|
|
93
|
+
bashDefaultTimeoutSeconds: number;
|
|
94
|
+
}
|
|
95
|
+
/** Builds a sub-agent's scoped tool set from the shared registry; injected by `tools/index.ts`. */
|
|
96
|
+
export type BuildWorkerTools = (request: WorkerToolRequest) => AgentTool<any>[];
|
|
97
|
+
export interface SubAgentToolOptions {
|
|
98
|
+
/** Builds a sub-agent's scoped tool set from the shared registry; injected by `tools/index.ts`. */
|
|
99
|
+
buildWorkerTools: BuildWorkerTools;
|
|
100
|
+
executor: Executor;
|
|
101
|
+
fileStore: FileStore;
|
|
102
|
+
/** Host checkout used as the sub-agent's cwd. Defaults to process.cwd(). */
|
|
103
|
+
workingDirectory?: string;
|
|
104
|
+
/** Mirrors the parent channel's ProjectScope.boundary onto the sub-agent's own tool set (spec 043, D6.2). */
|
|
105
|
+
projectBoundary?: "project" | "unbounded";
|
|
106
|
+
getCurrentModel: () => Model<Api>;
|
|
107
|
+
getAvailableModels: () => Model<Api>[];
|
|
108
|
+
resolveApiKey: (model: Model<Api>) => Promise<string>;
|
|
109
|
+
workspaceDir: string;
|
|
110
|
+
channelDir: string;
|
|
111
|
+
getSubAgentDiscovery?: () => SubAgentDiscoveryResult;
|
|
112
|
+
/** `settings.subagentModel` (spec 032 D5); null/undefined means unset. */
|
|
113
|
+
getSubAgentModelReference?: () => string | null;
|
|
114
|
+
securityConfig?: SecurityConfig;
|
|
115
|
+
webConfig?: PipiclawWebToolsConfig;
|
|
116
|
+
rtkEnabled?: boolean;
|
|
117
|
+
runtimeContext: {
|
|
118
|
+
workspaceDir: string;
|
|
119
|
+
channelId: string;
|
|
120
|
+
};
|
|
121
|
+
createWorker?: (config: {
|
|
122
|
+
subAgent: ResolvedInternalSubAgentConfig;
|
|
123
|
+
apiKey: string;
|
|
124
|
+
tools: AgentTool<any>[];
|
|
125
|
+
}) => SubAgentWorker;
|
|
126
|
+
/** Test seam for failures while constructing the scoped tool set after durable registration. */
|
|
127
|
+
buildTools?: BuildSubagentTools;
|
|
128
|
+
/** Test-only override for the D6 convergence-turn wall clock; defaults to CONVERGENCE_WALL_CLOCK_MS. */
|
|
129
|
+
convergenceWallClockMs?: number;
|
|
130
|
+
/** Test-only override for the D2 sync grace window; defaults to SYNC_GRACE_MS. */
|
|
131
|
+
syncGraceMs?: number;
|
|
132
|
+
/** Test-only override for the transient-error retry backoff base; defaults to RETRY_BASE_DELAY_MS. */
|
|
133
|
+
retryBaseDelayMs?: number;
|
|
134
|
+
/**
|
|
135
|
+
* `settings.fallbackModel`, resolved the way the main agent resolves it (spec 017): `null` when
|
|
136
|
+
* unset, unresolvable or missing a key. An internal run that still fails after its transient
|
|
137
|
+
* retries switches to it once, like the main turn does.
|
|
138
|
+
*/
|
|
139
|
+
resolveFallbackModel?: () => Promise<Model<Api> | null>;
|
|
140
|
+
/** Channel manager owned by the application; also a seam for admission failures. */
|
|
141
|
+
getRunManager: (channelId: string) => SubAgentRunManager;
|
|
142
|
+
/** Present only inside a task session: every delegation is bound to this task automatically (spec 052, D4). */
|
|
143
|
+
boundTaskId?: string;
|
|
144
|
+
}
|
|
145
|
+
/** What a dispatch hands back to the tool wrapper: the text for the model plus the structured details. */
|
|
146
|
+
export interface DelegationResult {
|
|
147
|
+
content: Array<{
|
|
148
|
+
type: "text";
|
|
149
|
+
text: string;
|
|
150
|
+
}>;
|
|
151
|
+
details: SubAgentToolFields;
|
|
152
|
+
}
|
|
153
|
+
/** Builds the tool set one internal run's worker gets (default: `internal/worker.ts`'s `buildSubagentTools`). */
|
|
154
|
+
export type BuildSubagentTools = (executor: Executor, bashTimeoutSec: number, options: SubAgentToolOptions, runContext: SubAgentRunContext) => AgentTool<any>[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The `purpose=verify` verdict rule, shared by the internal verifier path (`
|
|
2
|
+
* The `purpose=verify` verdict rule, shared by the internal verifier path (`internal/outcome.ts`) and the
|
|
3
3
|
* external one (`external/settlement.ts`).
|
|
4
4
|
*
|
|
5
5
|
* Spec 052, D6: a verifier's verdict is information for the leader, not a gate the runtime
|
package/dist/tasks/board.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type TaskItem } from "./
|
|
2
|
-
import { type TaskSettleRecord } from "./log.js";
|
|
1
|
+
import { type TaskItem } from "./contract.js";
|
|
2
|
+
import { type TaskSettleRecord } from "./loop-log.js";
|
|
3
3
|
/**
|
|
4
4
|
* The team board (spec 052, D5): what the leader's delegations and jobs are doing right now.
|
|
5
5
|
*
|
package/dist/tasks/board.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { formatElapsedZh } from "../shared/format.js";
|
|
2
2
|
import { parseLocalTime } from "../shared/local-time.js";
|
|
3
3
|
import { truncate } from "../shared/text-utils.js";
|
|
4
|
-
import { parseTaskItems } from "./
|
|
5
|
-
import { describeSettlement, describeWorkRef, readTaskLog, } from "./log.js";
|
|
4
|
+
import { parseTaskItems } from "./contract.js";
|
|
5
|
+
import { describeSettlement, describeWorkRef, readTaskLog, } from "./loop-log.js";
|
|
6
6
|
/** Ref lines the board renders before folding old, already-seen results away. */
|
|
7
7
|
export const BOARD_REF_LINE_BUDGET = 12;
|
|
8
8
|
export async function buildTaskBoard(channelDir, taskId, body) {
|
package/dist/tasks/brief.js
CHANGED
|
@@ -5,7 +5,7 @@ import { PLAYBOOKS_DIR } from "../paths.js";
|
|
|
5
5
|
import { clipText } from "../shared/text-utils.js";
|
|
6
6
|
import { buildTaskBoard, renderNewResults, renderTaskBoard } from "./board.js";
|
|
7
7
|
import { effectiveBudget } from "./budget.js";
|
|
8
|
-
import { readTaskLog, renderTaskLogLine } from "./log.js";
|
|
8
|
+
import { readTaskLog, renderTaskLogLine } from "./loop-log.js";
|
|
9
9
|
import { consumeTaskSteer } from "./steer.js";
|
|
10
10
|
import { readStoredTask, tasksDir } from "./store.js";
|
|
11
11
|
import { describeTicket } from "./ticket.js";
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/tasks`: the user's control path for the channel's long-horizon tasks (list, show, log, pause,
|
|
3
|
+
* resume, run, reply, steer, archive, doctor).
|
|
4
|
+
*/
|
|
1
5
|
import { existsSync } from "node:fs";
|
|
2
6
|
import { readdir } from "node:fs/promises";
|
|
3
7
|
import { join } from "node:path";
|
|
@@ -7,14 +11,14 @@ import { docsUrl } from "../paths.js";
|
|
|
7
11
|
import { formatSpanZh } from "../shared/format.js";
|
|
8
12
|
import { parseLocalTime } from "../shared/local-time.js";
|
|
9
13
|
import { errorMessage } from "../shared/text-utils.js";
|
|
10
|
-
import { buildTaskBoard, renderTaskBoardForUser } from "
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { readTaskLog, renderTaskLogLineForUser, taskArchiveLogPath, taskLogIsArchived, taskLogPath, } from "
|
|
14
|
-
import { withTaskMutation } from "
|
|
15
|
-
import { hasTaskSteer, queueTaskSteer } from "
|
|
16
|
-
import { archivedTaskPath, pauseTask as pauseTaskDocument, readStoredTask, redeemTicket, resumeTask as resumeTaskDocument, taskPath, updateStoredTask, } from "
|
|
17
|
-
import { describeTicketForUser } from "
|
|
14
|
+
import { buildTaskBoard, renderTaskBoardForUser } from "./board.js";
|
|
15
|
+
import { normalizeTaskId, readActiveTasks } from "./contract.js";
|
|
16
|
+
import { taskStateLabel } from "./frontmatter.js";
|
|
17
|
+
import { readTaskLog, renderTaskLogLineForUser, taskArchiveLogPath, taskLogIsArchived, taskLogPath, } from "./loop-log.js";
|
|
18
|
+
import { withTaskMutation } from "./mutation-lock.js";
|
|
19
|
+
import { hasTaskSteer, queueTaskSteer } from "./steer.js";
|
|
20
|
+
import { archivedTaskPath, pauseTask as pauseTaskDocument, readStoredTask, redeemTicket, resumeTask as resumeTaskDocument, taskPath, updateStoredTask, } from "./store.js";
|
|
21
|
+
import { describeTicketForUser } from "./ticket.js";
|
|
18
22
|
/** `/tasks show <id>` contract excerpt; the full file is always readable at its own path. */
|
|
19
23
|
const TASK_SHOW_CONTRACT_CHARS = 500;
|
|
20
24
|
const SHOW_LOG_LINES = 5;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { type TaskContractInput } from "./contract.js";
|
|
1
2
|
import type { TaskBudget } from "./frontmatter.js";
|
|
2
|
-
import { type TaskContractInput } from "./ledger.js";
|
|
3
3
|
/**
|
|
4
4
|
* Everything a task is created from. `task_create` takes exactly this plus an `id`, and an event
|
|
5
5
|
* template (`task` in a scheduled event, spec 052, D2) is exactly this — one shape, one
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
2
2
|
import { isPlainObject } from "../shared/type-guards.js";
|
|
3
|
-
import { renderStandardTaskBody, uncheckedTaskAcceptanceItems } from "./
|
|
3
|
+
import { renderStandardTaskBody, uncheckedTaskAcceptanceItems } from "./contract.js";
|
|
4
4
|
function requiredText(value, field) {
|
|
5
5
|
if (typeof value !== "string" || !value.trim()) {
|
|
6
6
|
throw new RecoverableToolError(`task.${field} is required and must be a non-empty string.`);
|
package/dist/tasks/create.js
CHANGED
|
@@ -4,7 +4,7 @@ import { writeFileAtomically } from "../shared/atomic-file.js";
|
|
|
4
4
|
import { formatLocalTime } from "../shared/local-time.js";
|
|
5
5
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
6
6
|
import { createUsage } from "./budget.js";
|
|
7
|
-
import { normalizeTaskId, renderStandardTaskBody, renderTaskDocument } from "./
|
|
7
|
+
import { normalizeTaskId, renderStandardTaskBody, renderTaskDocument } from "./contract.js";
|
|
8
8
|
import { archivedTaskPath, taskPath, tasksDir } from "./store.js";
|
|
9
9
|
/**
|
|
10
10
|
* Write a new task file, `open`, with its usage clock started. Shared by `task_create` and the
|
|
@@ -5,7 +5,7 @@ import { createJsonlAppender } from "../shared/jsonl-appender.js";
|
|
|
5
5
|
import { formatLocalTime } from "../shared/local-time.js";
|
|
6
6
|
import { clipText, truncate } from "../shared/text-utils.js";
|
|
7
7
|
import { isPlainObject } from "../shared/type-guards.js";
|
|
8
|
-
import { normalizeTaskId } from "./
|
|
8
|
+
import { normalizeTaskId } from "./contract.js";
|
|
9
9
|
/** Same rotation shape as the channel archive: the log is working history, not an audit trail. */
|
|
10
10
|
const MAX_LOG_BYTES = 4 * 1024 * 1024;
|
|
11
11
|
const NOTE_MAX_CHARS = 4_000;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { createSerialQueue } from "../shared/serial-queue.js";
|
|
4
|
-
import { normalizeTaskId } from "./
|
|
4
|
+
import { normalizeTaskId } from "./contract.js";
|
|
5
5
|
const mutationQueue = createSerialQueue();
|
|
6
6
|
const heldKeys = new AsyncLocalStorage();
|
|
7
7
|
function taskMutationKey(channelDir, id) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { normalizeTaskId } from "./
|
|
2
|
+
import { normalizeTaskId } from "./contract.js";
|
|
3
3
|
/**
|
|
4
4
|
* Where a task's own agent session lives (spec 051, D3; one per task since spec 052, D1) —
|
|
5
5
|
* left behind when the task is archived. Kept out of `<channelDir>` root and under a dot-directory so
|
package/dist/tasks/steer.js
CHANGED
|
@@ -3,7 +3,7 @@ import { mkdir, readFile, rm } from "node:fs/promises";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { writeFileAtomically } from "../shared/atomic-file.js";
|
|
5
5
|
import { formatLocalTime } from "../shared/local-time.js";
|
|
6
|
-
import { normalizeTaskId } from "./
|
|
6
|
+
import { normalizeTaskId } from "./contract.js";
|
|
7
7
|
/**
|
|
8
8
|
* Out-of-band guidance for a running task loop (spec 051, D11) — `/tasks steer` and `/tasks reply`.
|
|
9
9
|
*
|
package/dist/tasks/store.js
CHANGED
|
@@ -6,9 +6,9 @@ import { writeFileAtomically } from "../shared/atomic-file.js";
|
|
|
6
6
|
import { formatLocalTime } from "../shared/local-time.js";
|
|
7
7
|
import { errorMessage } from "../shared/text-utils.js";
|
|
8
8
|
import { createUsage } from "./budget.js";
|
|
9
|
+
import { normalizeTaskId, renderTaskDocument, taskBody } from "./contract.js";
|
|
9
10
|
import { normalizeTaskFrontmatter, parseTaskFrontmatter, } from "./frontmatter.js";
|
|
10
|
-
import {
|
|
11
|
-
import { appendTaskLog, taskLogPath } from "./log.js";
|
|
11
|
+
import { appendTaskLog, taskLogPath } from "./loop-log.js";
|
|
12
12
|
import { withTaskMutation } from "./mutation-lock.js";
|
|
13
13
|
import { describeTicket, ticketExpired } from "./ticket.js";
|
|
14
14
|
/**
|
package/dist/tools/bash.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
-
import type { ChannelJobManager } from "../agent/job-manager.js";
|
|
4
3
|
import { type Executor } from "../executor.js";
|
|
4
|
+
import type { ChannelJobManager } from "../jobs/manager.js";
|
|
5
5
|
import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
|
|
6
6
|
/**
|
|
7
7
|
* Default wall-clock timeout for bash commands when the caller supplies neither a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { type GuardBlock } from "
|
|
2
|
+
import { type GuardBlock } from "../../security/block-message.js";
|
|
3
3
|
/**
|
|
4
4
|
* The `details` contract for tool results, and the recoverable-rejection mechanism
|
|
5
5
|
* built on it.
|
|
@@ -14,7 +14,7 @@ import { type GuardBlock } from "../security/block-message.js";
|
|
|
14
14
|
* conform by construction: a tool cannot forget it, and it cannot disagree with the name the
|
|
15
15
|
* tool is registered under.
|
|
16
16
|
*/
|
|
17
|
-
export { RecoverableToolError } from "
|
|
17
|
+
export { RecoverableToolError } from "../../shared/recoverable-error.js";
|
|
18
18
|
/**
|
|
19
19
|
* Every tool that can appear in a tool set. Equal to the registry's tool names plus
|
|
20
20
|
* `subagent`, which is registered separately (see the note on TOOL_REGISTRY).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { GuardBlockedError } from "
|
|
2
|
-
import { RecoverableToolError } from "
|
|
3
|
-
import { isRecord } from "
|
|
1
|
+
import { GuardBlockedError } from "../../security/block-message.js";
|
|
2
|
+
import { RecoverableToolError } from "../../shared/recoverable-error.js";
|
|
3
|
+
import { isRecord } from "../../shared/type-guards.js";
|
|
4
4
|
/**
|
|
5
5
|
* The `details` contract for tool results, and the recoverable-rejection mechanism
|
|
6
6
|
* built on it.
|
|
@@ -15,7 +15,7 @@ import { isRecord } from "../shared/type-guards.js";
|
|
|
15
15
|
* conform by construction: a tool cannot forget it, and it cannot disagree with the name the
|
|
16
16
|
* tool is registered under.
|
|
17
17
|
*/
|
|
18
|
-
export { RecoverableToolError } from "
|
|
18
|
+
export { RecoverableToolError } from "../../shared/recoverable-error.js";
|
|
19
19
|
/** Read the `details` off a tool result, if it carries a conforming one. */
|
|
20
20
|
export function toolResultDetails(result) {
|
|
21
21
|
if (!isRecord(result) || !("details" in result)) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { clipText } from "
|
|
2
|
-
import { isRecord } from "
|
|
1
|
+
import { clipText } from "../../shared/text-utils.js";
|
|
2
|
+
import { isRecord } from "../../shared/type-guards.js";
|
|
3
3
|
/**
|
|
4
4
|
* Runtime-side projection from a tool call's raw arguments to the one-line Chinese progress
|
|
5
|
-
* string shown while it runs (`src/agent/session-events.ts`). Replaces the old model-authored,
|
|
5
|
+
* string shown while it runs (`src/agent/session/session-events.ts`). Replaces the old model-authored,
|
|
6
6
|
* per-tool-required `label` argument (spec 045): the model no longer pays schema tokens or output
|
|
7
7
|
* tokens for a UI string on every single call, and the wording is deterministic instead of
|
|
8
8
|
* whatever the model happened to write.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
-
import {
|
|
3
|
+
import type { ScheduledEvent } from "../events/types.js";
|
|
4
4
|
import type { SecurityConfig } from "../security/types.js";
|
|
5
5
|
import type { TaskCreateInput } from "../tasks/contract-input.js";
|
|
6
6
|
declare const eventManageSchema: Type.TObject<{
|
|
@@ -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 "../events/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { resolveEventPath } from "../events/commands.js";
|
|
6
|
+
import { describeEventPayload, parseScheduledEventContent } from "../events/parse.js";
|
|
7
|
+
import { EventValidationError, MAX_EVENT_FILES, validateScheduledEvent } from "../events/validation.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";
|
|
@@ -94,7 +94,7 @@ async function listOwnedEvents(options) {
|
|
|
94
94
|
* preActions, and cross-channel channelIds. The returned event is what gets persisted, so
|
|
95
95
|
* the file on disk is exactly what was validated.
|
|
96
96
|
*
|
|
97
|
-
* The scheduling rules themselves live in `
|
|
97
|
+
* The scheduling rules themselves live in `events/validation.ts` and are re-applied by
|
|
98
98
|
* the watcher (spec 031, D4); this layer only adds tool-specific framing (channel ownership,
|
|
99
99
|
* and turning validation failures into recoverable tool errors the model can retry).
|
|
100
100
|
*/
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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";
|
|
4
3
|
import type { MediaSender } from "../channel/channel-context.js";
|
|
4
|
+
import type { PipiclawSessionSearchSettings } from "../config/settings.js";
|
|
5
|
+
import type { PipiclawToolsConfig } from "../config/tools.js";
|
|
5
6
|
import type { Executor } from "../executor.js";
|
|
6
7
|
import type { FileStore } from "../file-store.js";
|
|
8
|
+
import type { ChannelJobManager } from "../jobs/manager.js";
|
|
7
9
|
import type { ProjectScope } from "../security/project-scope.js";
|
|
8
10
|
import type { SecurityConfig } from "../security/types.js";
|
|
9
|
-
import type { PipiclawSessionSearchSettings } from "../settings.js";
|
|
10
11
|
import { type SubAgentDiscoveryResult } from "../subagents/discovery.js";
|
|
11
12
|
import type { SubAgentRunManager } from "../subagents/runs.js";
|
|
12
|
-
import type { PipiclawToolsConfig } from "./config.js";
|
|
13
13
|
import type { TaskStepCost } from "./task-manage/types.js";
|
|
14
14
|
export interface CreatePipiclawToolsOptions {
|
|
15
15
|
jobManager: ChannelJobManager;
|
package/dist/tools/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { withSubAgentsDirWriteDeny } from "../subagents/discovery.js";
|
|
2
|
-
import {
|
|
2
|
+
import { withToolDetails } from "./contract/details.js";
|
|
3
3
|
import { buildToolSet } from "./registry.js";
|
|
4
|
+
import { createSubAgentInlineTool, createSubAgentTool } from "./subagent.js";
|
|
4
5
|
import { createSubAgentListTool, createSubAgentRunTool } from "./subagent-manage.js";
|
|
5
|
-
import { withToolDetails } from "./tool-details.js";
|
|
6
6
|
export function createPipiclawTools(options) {
|
|
7
7
|
// Spec 040, D8.1: the main agent's own write/edit tools can write a self-authorizing
|
|
8
8
|
// `runtime: external` role file just as readily as a sub-agent's can; deny it here too.
|
|
@@ -20,7 +20,7 @@ export function createPipiclawTools(options) {
|
|
|
20
20
|
// The leaf tools (files, web, memory, skills) come from the single declarative
|
|
21
21
|
// registry so this set, the sub-agent set, and the prompt hints share one source.
|
|
22
22
|
// The `subagent` tool is appended separately: it is never available to sub-agents
|
|
23
|
-
// and
|
|
23
|
+
// and needs dispatch-time context the registry does not model.
|
|
24
24
|
const taskLoopExcluded = new Set(["task_create", "memory_save", "event_manage"]);
|
|
25
25
|
const leafTools = buildToolSet({
|
|
26
26
|
executor: options.executor,
|
|
@@ -45,6 +45,7 @@ export function createPipiclawTools(options) {
|
|
|
45
45
|
getStepCost: options.getStepCost,
|
|
46
46
|
});
|
|
47
47
|
const subAgentToolOptions = {
|
|
48
|
+
buildWorkerTools: (request) => buildToolSet(request, { forSubagent: true }),
|
|
48
49
|
getRunManager: () => options.runManager,
|
|
49
50
|
executor: options.executor,
|
|
50
51
|
fileStore: options.fileStore,
|
|
@@ -53,7 +54,7 @@ export function createPipiclawTools(options) {
|
|
|
53
54
|
resolveApiKey: options.resolveApiKey,
|
|
54
55
|
workspaceDir: options.workspaceDir,
|
|
55
56
|
// D6.2: an internal sub-agent defaults to the parent's ProjectRoot; a model-requested
|
|
56
|
-
// explicit workingDirectory is validated (in subagents/
|
|
57
|
+
// explicit workingDirectory is validated (in subagents/dispatch.ts) to stay within it.
|
|
57
58
|
workingDirectory: options.projectScope.projectRoot,
|
|
58
59
|
projectBoundary: options.projectScope.boundary,
|
|
59
60
|
channelDir: options.channelDir,
|
|
@@ -82,8 +83,8 @@ export function createPipiclawTools(options) {
|
|
|
82
83
|
};
|
|
83
84
|
const all = [
|
|
84
85
|
...leafTools,
|
|
85
|
-
// Bound to the same `details` contract as the registry's tools;
|
|
86
|
-
//
|
|
86
|
+
// Bound to the same `details` contract as the registry's tools; registered here rather than
|
|
87
|
+
// in TOOL_REGISTRY because it needs dispatch-time context the registry does not model.
|
|
87
88
|
withToolDetails(createSubAgentTool(subAgentToolOptions), "subagent"),
|
|
88
89
|
// Spec 046, D2.3: gated by `tools.json` (deployer decision, not a model-visible field) —
|
|
89
90
|
// omitted from the tool set entirely when off, not merely rejected at call time.
|
package/dist/tools/job.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
-
import type { ChannelJobManager } from "../
|
|
3
|
+
import type { ChannelJobManager } from "../jobs/manager.js";
|
|
4
4
|
declare const jobSchema: Type.TObject<{
|
|
5
5
|
op: Type.TUnion<[Type.TLiteral<"list">, Type.TLiteral<"poll">, Type.TLiteral<"cancel">]>;
|
|
6
6
|
ids: Type.TOptional<Type.TArray<Type.TString>>;
|
package/dist/tools/registry.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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";
|
|
4
3
|
import type { MediaSender } from "../channel/channel-context.js";
|
|
4
|
+
import type { PipiclawSessionSearchSettings } from "../config/settings.js";
|
|
5
|
+
import type { PipiclawToolsConfig, PipiclawWebToolsConfig } from "../config/tools.js";
|
|
5
6
|
import type { Executor } from "../executor.js";
|
|
6
7
|
import type { FileStore } from "../file-store.js";
|
|
8
|
+
import type { ChannelJobManager } from "../jobs/manager.js";
|
|
7
9
|
import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
|
|
8
|
-
import type { PipiclawSessionSearchSettings } from "../settings.js";
|
|
9
10
|
import type { SubAgentRunManager } from "../subagents/runs.js";
|
|
10
|
-
import
|
|
11
|
+
import { type ToolDetailsKind } from "./contract/details.js";
|
|
11
12
|
import type { TaskStepCost } from "./task-manage/types.js";
|
|
12
|
-
import { type ToolDetailsKind } from "./tool-details.js";
|
|
13
13
|
/**
|
|
14
14
|
* Unified build context passed to every tool's `create` closure. It carries the union
|
|
15
15
|
* of everything any registered tool might need; each closure reads only its own fields.
|
|
@@ -79,9 +79,9 @@ export interface ToolRegistration {
|
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
81
|
* Single source of truth for the agent's leaf tools. The `subagent` tool is intentionally
|
|
82
|
-
* NOT here: it is never available to sub-agents
|
|
83
|
-
*
|
|
84
|
-
*
|
|
82
|
+
* NOT here: it is never available to sub-agents and needs dispatch-time context (role
|
|
83
|
+
* discovery, model resolvers, the run manager) that `ToolBuildContext` does not model; see
|
|
84
|
+
* `tools/subagent.ts` and `tools/index.ts`.
|
|
85
85
|
*/
|
|
86
86
|
export declare const TOOL_REGISTRY: ToolRegistration[];
|
|
87
87
|
/**
|
package/dist/tools/registry.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createBashTool } from "./bash.js";
|
|
2
|
+
import { withToolDetails } from "./contract/details.js";
|
|
3
|
+
import { SUBAGENT_TOOL_NAMES } from "./contract/names.js";
|
|
2
4
|
import { createEditTool } from "./edit.js";
|
|
3
5
|
import { createEventManageTool } from "./event-manage.js";
|
|
4
6
|
import { createGlobTool } from "./glob.js";
|
|
@@ -9,9 +11,7 @@ import { createReadTool } from "./read.js";
|
|
|
9
11
|
import { createSendMediaTool } from "./send-media.js";
|
|
10
12
|
import { createSessionSearchTool } from "./session-search.js";
|
|
11
13
|
import { createSkillTool } from "./skill.js";
|
|
12
|
-
import {
|
|
13
|
-
import { createTaskCloseTool, createTaskCreateTool, createTaskListTool, createTaskLogTool, createTaskStepEndTool, createTaskUpdateTool, } from "./task-manage.js";
|
|
14
|
-
import { withToolDetails } from "./tool-details.js";
|
|
14
|
+
import { createTaskCloseTool, createTaskCreateTool, createTaskListTool, createTaskLogTool, createTaskStepEndTool, createTaskUpdateTool, } from "./task-manage/factory.js";
|
|
15
15
|
import { createWebFetchTool } from "./web-fetch.js";
|
|
16
16
|
import { createWebSearchTool } from "./web-search.js";
|
|
17
17
|
import { createWriteTool } from "./write.js";
|
|
@@ -47,9 +47,9 @@ function webEnabled(ctx) {
|
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Single source of truth for the agent's leaf tools. The `subagent` tool is intentionally
|
|
50
|
-
* NOT here: it is never available to sub-agents
|
|
51
|
-
*
|
|
52
|
-
*
|
|
50
|
+
* NOT here: it is never available to sub-agents and needs dispatch-time context (role
|
|
51
|
+
* discovery, model resolvers, the run manager) that `ToolBuildContext` does not model; see
|
|
52
|
+
* `tools/subagent.ts` and `tools/index.ts`.
|
|
53
53
|
*/
|
|
54
54
|
export const TOOL_REGISTRY = [
|
|
55
55
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import type { Api, Model } from "@earendil-works/pi-ai";
|
|
3
3
|
import { Type } from "typebox";
|
|
4
|
-
import type { PipiclawSessionSearchSettings } from "../settings.js";
|
|
4
|
+
import type { PipiclawSessionSearchSettings } from "../config/settings.js";
|
|
5
5
|
declare const sessionSearchSchema: Type.TObject<{
|
|
6
6
|
query: Type.TOptional<Type.TString>;
|
|
7
7
|
limit: Type.TOptional<Type.TInteger>;
|
package/dist/tools/skill.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
-
import
|
|
3
|
+
import { type WorkspaceSkillOptions } from "../skills/workspace.js";
|
|
4
4
|
/**
|
|
5
5
|
* `skill` is deliberately read-only. Authoring a workspace skill goes through the generic
|
|
6
6
|
* `write`/`edit` tools writing `workspace/skills/<name>/SKILL.md` directly — a low-frequency path
|
|
@@ -12,37 +12,5 @@ declare const skillSchema: Type.TObject<{
|
|
|
12
12
|
action: Type.TUnion<[Type.TLiteral<"list">, Type.TLiteral<"read">]>;
|
|
13
13
|
name: Type.TOptional<Type.TString>;
|
|
14
14
|
}>;
|
|
15
|
-
export
|
|
16
|
-
name: string;
|
|
17
|
-
description: string;
|
|
18
|
-
path: string;
|
|
19
|
-
warning?: string;
|
|
20
|
-
}
|
|
21
|
-
export interface SkillToolOptions {
|
|
22
|
-
workspaceDir: string;
|
|
23
|
-
securityConfig?: SecurityConfig;
|
|
24
|
-
securityContext?: SecurityRuntimeContext;
|
|
25
|
-
channelId?: string;
|
|
26
|
-
}
|
|
27
|
-
export declare function listWorkspaceSkills(options: {
|
|
28
|
-
workspaceDir: string;
|
|
29
|
-
securityConfig?: SecurityConfig;
|
|
30
|
-
securityContext?: SecurityRuntimeContext;
|
|
31
|
-
}): Promise<WorkspaceSkillSummary[]>;
|
|
32
|
-
export interface WorkspaceSkillFile {
|
|
33
|
-
name: string;
|
|
34
|
-
/** The guard-resolved path actually opened — never the raw pre-guard path. */
|
|
35
|
-
path: string;
|
|
36
|
-
content: string;
|
|
37
|
-
truncated: boolean;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Load one skill's `SKILL.md` bytes through the same path-guard every other file read goes
|
|
41
|
-
* through. Shared by the `skill` tool's `read` action and the `/skills show` runtime command
|
|
42
|
-
* (`src/runtime/skill-commands.ts`) — a `SKILL.md` that is itself a symlink pointing outside
|
|
43
|
-
* `workspace/skills/` (planted via `bash ln -s`, not via `name` -- `resolveSkillPath` already
|
|
44
|
-
* confines that) is caught here in both callers instead of being read verbatim.
|
|
45
|
-
*/
|
|
46
|
-
export declare function loadWorkspaceSkillFile(options: SkillToolOptions, name: string): Promise<WorkspaceSkillFile>;
|
|
47
|
-
export declare function createSkillTool(options: SkillToolOptions): AgentTool<typeof skillSchema>;
|
|
15
|
+
export declare function createSkillTool(options: WorkspaceSkillOptions): AgentTool<typeof skillSchema>;
|
|
48
16
|
export {};
|