@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
package/dist/tools/skill.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { readdir, readFile, stat } from "node:fs/promises";
|
|
3
|
-
import { dirname, join } from "node:path";
|
|
1
|
+
import { dirname } from "node:path";
|
|
4
2
|
import { Type } from "typebox";
|
|
5
|
-
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
6
|
-
import { checkPathGuard } from "../security/path-guard-check.js";
|
|
7
|
-
import { readGuardAllows } from "../security/path-guard-filter.js";
|
|
8
|
-
import { isNodeError } from "../shared/os.js";
|
|
9
3
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
10
|
-
import {
|
|
4
|
+
import { listWorkspaceSkills, loadWorkspaceSkillFile } from "../skills/workspace.js";
|
|
11
5
|
import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
|
|
12
6
|
/**
|
|
13
7
|
* `skill` is deliberately read-only. Authoring a workspace skill goes through the generic
|
|
@@ -22,125 +16,23 @@ const skillSchema = Type.Object({
|
|
|
22
16
|
}),
|
|
23
17
|
name: Type.Optional(Type.String({ description: "Exact workspace skill name from the list (required for read)." })),
|
|
24
18
|
});
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
return "";
|
|
29
|
-
}
|
|
30
|
-
for (const line of (match[1] ?? "").split("\n")) {
|
|
31
|
-
const fieldMatch = line.match(/^description:\s*(.*)$/);
|
|
32
|
-
if (fieldMatch) {
|
|
33
|
-
return fieldMatch[1].replace(/^["']|["']$/g, "").trim();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return "";
|
|
37
|
-
}
|
|
38
|
-
export async function listWorkspaceSkills(options) {
|
|
39
|
-
const skillsDir = join(options.workspaceDir, "skills");
|
|
40
|
-
// `skill read` runs each SKILL.md through the path guard (`loadWorkspaceSkillFile`); `list`
|
|
41
|
-
// must apply the same guard so a skill whose SKILL.md is a symlink out of `workspace/skills/`
|
|
42
|
-
// is silently omitted here too, rather than being advertised and then refused on read.
|
|
43
|
-
const guardConfig = options.securityConfig ?? DEFAULT_SECURITY_CONFIG;
|
|
44
|
-
const guardContext = options.securityContext ?? {
|
|
45
|
-
agentWorkspaceDir: options.workspaceDir,
|
|
46
|
-
projectRoot: options.workspaceDir,
|
|
47
|
-
};
|
|
48
|
-
let names;
|
|
49
|
-
try {
|
|
50
|
-
names = await readdir(skillsDir);
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
if (isNodeError(error) && error.code === "ENOENT") {
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
56
|
-
throw error;
|
|
57
|
-
}
|
|
58
|
-
const summaries = [];
|
|
59
|
-
for (const name of names.sort()) {
|
|
60
|
-
const nameValidation = validateSkillName(name);
|
|
61
|
-
if (!nameValidation.ok) {
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
const skillDir = join(skillsDir, name);
|
|
65
|
-
const skillStats = await stat(skillDir).catch(() => null);
|
|
66
|
-
if (!skillStats?.isDirectory()) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
const skillPath = join(skillDir, "SKILL.md");
|
|
70
|
-
if (!readGuardAllows(skillPath, guardConfig, guardContext)) {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
let content;
|
|
74
|
-
try {
|
|
75
|
-
const skillFileStats = await stat(skillPath);
|
|
76
|
-
if (!skillFileStats.isFile()) {
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
content = await readFile(skillPath, "utf-8");
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
if (isNodeError(error) && error.code === "ENOENT") {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
throw error;
|
|
86
|
-
}
|
|
87
|
-
const validation = validateSkillFrontmatter(content, name);
|
|
88
|
-
const scan = validation.ok ? scanSkillContent(content) : validation;
|
|
89
|
-
summaries.push({
|
|
90
|
-
name,
|
|
91
|
-
description: extractDescription(content),
|
|
92
|
-
path: `${options.workspaceDir}/skills/${name}/SKILL.md`,
|
|
93
|
-
warning: scan.ok ? undefined : scan.error,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return summaries;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Load one skill's `SKILL.md` bytes through the same path-guard every other file read goes
|
|
100
|
-
* through. Shared by the `skill` tool's `read` action and the `/skills show` runtime command
|
|
101
|
-
* (`src/runtime/skill-commands.ts`) — a `SKILL.md` that is itself a symlink pointing outside
|
|
102
|
-
* `workspace/skills/` (planted via `bash ln -s`, not via `name` -- `resolveSkillPath` already
|
|
103
|
-
* confines that) is caught here in both callers instead of being read verbatim.
|
|
104
|
-
*/
|
|
105
|
-
export async function loadWorkspaceSkillFile(options, name) {
|
|
106
|
-
const nameValidation = validateSkillName(name);
|
|
107
|
-
if (!nameValidation.ok) {
|
|
108
|
-
throw new RecoverableToolError(nameValidation.error ?? `Invalid skill name "${name}".`);
|
|
109
|
-
}
|
|
110
|
-
const skillDir = resolveSkillPath(options.workspaceDir, name);
|
|
111
|
-
const rawPath = join(skillDir, "SKILL.md");
|
|
112
|
-
if (!existsSync(rawPath)) {
|
|
113
|
-
throw new RecoverableToolError(`Workspace skill "${name}" does not exist. Use action "list" to see what's available.`);
|
|
114
|
-
}
|
|
115
|
-
const securityConfig = options.securityConfig ?? DEFAULT_SECURITY_CONFIG;
|
|
116
|
-
const securityContext = options.securityContext ?? {
|
|
117
|
-
agentWorkspaceDir: options.workspaceDir,
|
|
118
|
-
projectRoot: options.workspaceDir,
|
|
119
|
-
};
|
|
120
|
-
const target = await checkPathGuard(rawPath, "read", securityConfig, securityContext, {
|
|
121
|
-
tool: "skill",
|
|
122
|
-
channelId: options.channelId,
|
|
123
|
-
});
|
|
124
|
-
const content = await readFile(target, "utf-8");
|
|
125
|
-
const truncation = truncateHead(content);
|
|
19
|
+
async function readWorkspaceSkill(options, name) {
|
|
20
|
+
const file = await loadWorkspaceSkillFile(options, name);
|
|
21
|
+
const truncation = truncateHead(file.content);
|
|
126
22
|
let body = truncation.content;
|
|
127
23
|
if (truncation.truncated) {
|
|
128
|
-
body += `\n\n[Truncated at ${formatSize(DEFAULT_MAX_BYTES)}. Use the read tool on ${
|
|
24
|
+
body += `\n\n[Truncated at ${formatSize(DEFAULT_MAX_BYTES)}. Use the read tool on ${file.path} to page through the rest.]`;
|
|
129
25
|
}
|
|
130
|
-
return { name, path: target, content: body, truncated: truncation.truncated };
|
|
131
|
-
}
|
|
132
|
-
async function readWorkspaceSkill(options, name) {
|
|
133
|
-
const file = await loadWorkspaceSkillFile(options, name);
|
|
134
26
|
// Mirrors the framing pi's own skill loader gives a model-invoked skill: the location and the
|
|
135
27
|
// relative-path rule are what let the model correctly `read` a skill's references/templates
|
|
136
28
|
// afterward, and are the whole reason `skill read` is worth more than a plain `read` call.
|
|
137
29
|
const envelope = `<skill name="${file.name}" location="${file.path}">\n` +
|
|
138
30
|
`References are relative to ${dirname(file.path)}.\n\n` +
|
|
139
|
-
`${
|
|
31
|
+
`${body}\n` +
|
|
140
32
|
`</skill>`;
|
|
141
33
|
return {
|
|
142
34
|
content: [{ type: "text", text: envelope }],
|
|
143
|
-
details: { action: "read", name: file.name, path: file.path, truncated:
|
|
35
|
+
details: { action: "read", name: file.name, path: file.path, truncated: truncation.truncated },
|
|
144
36
|
};
|
|
145
37
|
}
|
|
146
38
|
export function createSkillTool(options) {
|
|
@@ -4,10 +4,11 @@ import { Type } from "typebox";
|
|
|
4
4
|
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
5
5
|
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
6
6
|
import { externalRoleFingerprint, validateSubAgentTask } from "../subagents/discovery.js";
|
|
7
|
+
import { assertWithinProjectBoundary } from "../subagents/dispatch.js";
|
|
7
8
|
import { readLastOutputAt, STALL_THRESHOLD_MS } from "../subagents/external/progress-tail.js";
|
|
8
9
|
import { launchExternalRun } from "../subagents/external/run.js";
|
|
9
10
|
import { formatCost, formatRunDuration, harnessLabel } from "../subagents/format.js";
|
|
10
|
-
import { assertVerifyAdmissible,
|
|
11
|
+
import { assertVerifyAdmissible, buildFollowUpTask } from "../subagents/task-envelope.js";
|
|
11
12
|
import { acquireWorkspaceLease, formatWorkspaceLeaseConflict, releaseWorkspaceLease, } from "../subagents/workspace-lease.js";
|
|
12
13
|
import { snapshotWorkspace } from "../subagents/workspace-summary.js";
|
|
13
14
|
// Spec 047, P3: `subagent_list` is zero-argument and shape-independent (like `task_list`); the
|
|
@@ -23,7 +24,7 @@ const subagentRunSchema = Type.Object({
|
|
|
23
24
|
});
|
|
24
25
|
/** Spec 042 D9: cap on `op=list`'s output — see the call site for why running runs are exempt. */
|
|
25
26
|
const LIST_CAP = 50;
|
|
26
|
-
/** Matches `/subagents show`'s own cap (`
|
|
27
|
+
/** Matches `/subagents show`'s own cap (`subagents/commands.ts`) — enough to diagnose a
|
|
27
28
|
* failure without dumping an unbounded log into the model's context. */
|
|
28
29
|
const STDERR_TAIL_CHARS = 2_000;
|
|
29
30
|
function formatRunLine(record) {
|
|
@@ -38,7 +39,7 @@ function formatRunLine(record) {
|
|
|
38
39
|
return header;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
|
-
* The machine-readable subset of `/subagents show` (`
|
|
42
|
+
* The machine-readable subset of `/subagents show` (`subagents/commands.ts`'s `showRun`):
|
|
42
43
|
* argv, dispatch-time warnings, and the adapter/CLI version pair the model previously had no way
|
|
43
44
|
* to see at all — it could only guess at a failed external run's cause or re-dispatch blindly
|
|
44
45
|
* (review 2026-08-23 §3.4).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `subagent` and `subagent_inline` tools (spec 046 D2.1): parameter schemas, validation that
|
|
3
|
+
* the model can recover from, and the two tool factories. Resolution of the role or inline spec
|
|
4
|
+
* happens here; dispatch and execution live in `subagents/dispatch.ts`.
|
|
5
|
+
*/
|
|
6
|
+
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
7
|
+
import { Type } from "typebox";
|
|
8
|
+
import type { SubAgentToolFields, SubAgentToolOptions } from "../subagents/types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Role-based delegation (spec 046, D2.1): the common path. No override fields beyond routing
|
|
11
|
+
* ones — tools, model, effort, context, thinkingLevel and mutates all live in the role file, so
|
|
12
|
+
* a call naming an external role cannot pass any of them (there is nowhere for it to put them).
|
|
13
|
+
*/
|
|
14
|
+
declare const subagentSchema: Type.TObject<{
|
|
15
|
+
agent: Type.TString;
|
|
16
|
+
task: Type.TString;
|
|
17
|
+
workingDirectory: Type.TOptional<Type.TString>;
|
|
18
|
+
purpose: Type.TOptional<Type.TUnion<[Type.TLiteral<"work">, Type.TLiteral<"verify">]>>;
|
|
19
|
+
taskId: Type.TOptional<Type.TString>;
|
|
20
|
+
item: Type.TOptional<Type.TString>;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Inline delegation (spec 046, D2.1): a one-off executor for when no configured role fits.
|
|
24
|
+
* Carries every field a role file would otherwise supply.
|
|
25
|
+
*/
|
|
26
|
+
declare const subagentInlineSchema: Type.TObject<{
|
|
27
|
+
task: Type.TString;
|
|
28
|
+
systemPrompt: Type.TString;
|
|
29
|
+
tools: Type.TOptional<Type.TArray<Type.TString>>;
|
|
30
|
+
model: Type.TOptional<Type.TString>;
|
|
31
|
+
effort: Type.TOptional<Type.TUnion<[Type.TLiteral<"quick">, Type.TLiteral<"standard">, Type.TLiteral<"deep">]>>;
|
|
32
|
+
context: Type.TOptional<Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"index">]>>;
|
|
33
|
+
thinkingLevel: Type.TOptional<Type.TUnion<[Type.TLiteral<"off">, Type.TLiteral<"minimal">, Type.TLiteral<"low">, Type.TLiteral<"medium">, Type.TLiteral<"high">, Type.TLiteral<"xhigh">, Type.TLiteral<"max">]>>;
|
|
34
|
+
mutates: Type.TOptional<Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"write">]>>;
|
|
35
|
+
workingDirectory: Type.TOptional<Type.TString>;
|
|
36
|
+
purpose: Type.TOptional<Type.TUnion<[Type.TLiteral<"work">, Type.TLiteral<"verify">]>>;
|
|
37
|
+
taskId: Type.TOptional<Type.TString>;
|
|
38
|
+
item: Type.TOptional<Type.TString>;
|
|
39
|
+
}>;
|
|
40
|
+
/** The shape consumers read post-wrap, once `withToolDetails` has stamped `kind`. */
|
|
41
|
+
export type SubAgentToolDetails = SubAgentToolFields & {
|
|
42
|
+
kind: "subagent" | "subagent_inline";
|
|
43
|
+
};
|
|
44
|
+
export declare function createSubAgentTool(options: SubAgentToolOptions): AgentTool<typeof subagentSchema, SubAgentToolFields>;
|
|
45
|
+
export declare function createSubAgentInlineTool(options: SubAgentToolOptions): AgentTool<typeof subagentInlineSchema, SubAgentToolFields>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { RecoverableToolError } from "../shared/recoverable-error.js";
|
|
3
|
+
import { formatSubAgentList, resolveConfiguredRole, resolveInlineAgent, validateSubAgentTask, } from "../subagents/discovery.js";
|
|
4
|
+
import { dispatchSubAgentRun } from "../subagents/dispatch.js";
|
|
5
|
+
/** Shared by both invocation surfaces (spec 046, D2.1). */
|
|
6
|
+
const workingDirectoryField = Type.Optional(Type.String({
|
|
7
|
+
description: "Optional existing directory to run the sub-agent in (its shell cwd and relative-path root). Use it to work on another checkout — e.g. a `git worktree add`ed one. Defaults to this runtime's own working directory.",
|
|
8
|
+
}));
|
|
9
|
+
const purposeField = Type.Optional(Type.Union([Type.Literal("work"), Type.Literal("verify")], {
|
|
10
|
+
description: 'Use "verify" for an independent check: the sub-agent is given the checker protocol and ends with VERDICT: PASS|FAIL. The verdict is information for you to weigh, not a gate.',
|
|
11
|
+
}));
|
|
12
|
+
const taskIdField = Type.Optional(Type.String({
|
|
13
|
+
description: "Persistent task this work belongs to. Inside a task session it is bound automatically — omit it. In chat, pass it to have the result recorded on that task's board.",
|
|
14
|
+
}));
|
|
15
|
+
const itemField = Type.Optional(Type.String({
|
|
16
|
+
description: 'The task\'s Work Item this delegation is for, e.g. "W2". Requires a task (bound automatically in a task session).',
|
|
17
|
+
}));
|
|
18
|
+
/**
|
|
19
|
+
* Role-based delegation (spec 046, D2.1): the common path. No override fields beyond routing
|
|
20
|
+
* ones — tools, model, effort, context, thinkingLevel and mutates all live in the role file, so
|
|
21
|
+
* a call naming an external role cannot pass any of them (there is nowhere for it to put them).
|
|
22
|
+
*/
|
|
23
|
+
const subagentSchema = Type.Object({
|
|
24
|
+
agent: Type.String({ description: "Name of a configured sub-agent from workspaceDir/sub-agents/" }),
|
|
25
|
+
task: Type.String({ description: "Complete task description for the sub-agent" }),
|
|
26
|
+
workingDirectory: workingDirectoryField,
|
|
27
|
+
purpose: purposeField,
|
|
28
|
+
taskId: taskIdField,
|
|
29
|
+
item: itemField,
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Inline delegation (spec 046, D2.1): a one-off executor for when no configured role fits.
|
|
33
|
+
* Carries every field a role file would otherwise supply.
|
|
34
|
+
*/
|
|
35
|
+
const subagentInlineSchema = Type.Object({
|
|
36
|
+
task: Type.String({ description: "Complete task description for the sub-agent" }),
|
|
37
|
+
systemPrompt: Type.String({ description: "System prompt defining this one-off sub-agent's identity and task." }),
|
|
38
|
+
tools: Type.Optional(Type.Array(Type.String(), { description: "Optional tool whitelist for the sub-agent" })),
|
|
39
|
+
model: Type.Optional(Type.String({ description: "Optional exact model reference. Defaults to the parent's current model." })),
|
|
40
|
+
effort: Type.Optional(Type.Union([Type.Literal("quick"), Type.Literal("standard"), Type.Literal("deep")], {
|
|
41
|
+
description: 'Execution budget preset (turns, tool calls, wall time). "standard" is the default; "quick" for narrow lookups, "deep" for long analyses.',
|
|
42
|
+
})),
|
|
43
|
+
context: Type.Optional(Type.Union([Type.Literal("none"), Type.Literal("index")], {
|
|
44
|
+
description: 'What context to inject. "none" (default) runs fully isolated; "index" adds the workspace background, the channel memory index, and today\'s journal tail.',
|
|
45
|
+
})),
|
|
46
|
+
thinkingLevel: Type.Optional(Type.Union([
|
|
47
|
+
Type.Literal("off"),
|
|
48
|
+
Type.Literal("minimal"),
|
|
49
|
+
Type.Literal("low"),
|
|
50
|
+
Type.Literal("medium"),
|
|
51
|
+
Type.Literal("high"),
|
|
52
|
+
Type.Literal("xhigh"),
|
|
53
|
+
Type.Literal("max"),
|
|
54
|
+
], {
|
|
55
|
+
description: "Optional reasoning effort for the sub-agent.",
|
|
56
|
+
})),
|
|
57
|
+
mutates: Type.Optional(Type.Union([Type.Literal("read"), Type.Literal("write")], {
|
|
58
|
+
description: 'Whether this delegation will modify the working directory. Declare "write" whenever the sub-agent may write ' +
|
|
59
|
+
"files (including through bash) so it takes the exclusive workspace write lease.",
|
|
60
|
+
})),
|
|
61
|
+
workingDirectory: workingDirectoryField,
|
|
62
|
+
purpose: purposeField,
|
|
63
|
+
taskId: taskIdField,
|
|
64
|
+
item: itemField,
|
|
65
|
+
});
|
|
66
|
+
export function createSubAgentTool(options) {
|
|
67
|
+
return {
|
|
68
|
+
name: "subagent",
|
|
69
|
+
label: "subagent",
|
|
70
|
+
description: "Delegate a task to a configured sub-agent (see the Sub-Agents directory in the system prompt). Prefer this over `subagent_inline` whenever a role fits — its tools, model, budget and context policy all come from the role file. Sub-agents never receive the subagent tool, so they cannot create nested agents.",
|
|
71
|
+
parameters: subagentSchema,
|
|
72
|
+
execute: async (_toolCallId, params, signal, onUpdate) => {
|
|
73
|
+
if (signal?.aborted) {
|
|
74
|
+
throw new Error("Sub-agent aborted");
|
|
75
|
+
}
|
|
76
|
+
const availableModels = options.getAvailableModels();
|
|
77
|
+
const discovery = options.getSubAgentDiscovery?.() ?? {
|
|
78
|
+
directory: `${options.workspaceDir}/sub-agents`,
|
|
79
|
+
agents: [],
|
|
80
|
+
warnings: [],
|
|
81
|
+
};
|
|
82
|
+
const currentModel = options.getCurrentModel();
|
|
83
|
+
const taskLengthError = validateSubAgentTask(params.task);
|
|
84
|
+
if (taskLengthError) {
|
|
85
|
+
throw new RecoverableToolError(taskLengthError);
|
|
86
|
+
}
|
|
87
|
+
const invocation = resolveConfiguredRole(availableModels, currentModel, discovery.agents, { agent: params.agent, purpose: params.purpose }, options.getSubAgentModelReference?.() ?? undefined);
|
|
88
|
+
if (!invocation.config) {
|
|
89
|
+
throw new RecoverableToolError(`${invocation.error}\n\nAvailable configured sub-agents:\n${formatSubAgentList(discovery.agents)}`);
|
|
90
|
+
}
|
|
91
|
+
return dispatchSubAgentRun(options, currentModel, invocation.config, undefined, params, signal, onUpdate);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export function createSubAgentInlineTool(options) {
|
|
96
|
+
return {
|
|
97
|
+
name: "subagent_inline",
|
|
98
|
+
label: "subagent_inline",
|
|
99
|
+
description: "Advanced fallback only, not the default: use `subagent` first whenever any configured role in the workspace `sub-agents/` can do the work. `subagent` is the normal role-based path: pass its `agent` and complete `task`; the role file supplies the tools, model, budget and context policy. Use `subagent_inline` only when no configured role is suitable. It is a raw one-shot meta-executor, not a shorthand for `subagent`: there is no role file to supply those settings. Build a complete valid inline call yourself — `task` and `systemPrompt` are required; choose valid values for any needed `tools`, `model`, `effort`, `context`, `thinkingLevel`, `mutates`, `workingDirectory`, `purpose` and `taskId` fields. Do not send a partial role-style payload or choose this tool just because it is available. Sub-agents never receive the subagent tool, so they cannot create nested agents.",
|
|
100
|
+
parameters: subagentInlineSchema,
|
|
101
|
+
execute: async (_toolCallId, params, signal, onUpdate) => {
|
|
102
|
+
if (signal?.aborted) {
|
|
103
|
+
throw new Error("Sub-agent aborted");
|
|
104
|
+
}
|
|
105
|
+
const availableModels = options.getAvailableModels();
|
|
106
|
+
const currentModel = options.getCurrentModel();
|
|
107
|
+
const taskLengthError = validateSubAgentTask(params.task);
|
|
108
|
+
if (taskLengthError) {
|
|
109
|
+
throw new RecoverableToolError(taskLengthError);
|
|
110
|
+
}
|
|
111
|
+
const invocation = resolveInlineAgent(availableModels, currentModel, {
|
|
112
|
+
systemPrompt: params.systemPrompt,
|
|
113
|
+
tools: params.tools,
|
|
114
|
+
model: params.model,
|
|
115
|
+
effort: params.effort,
|
|
116
|
+
context: params.context,
|
|
117
|
+
thinkingLevel: params.thinkingLevel,
|
|
118
|
+
mutates: params.mutates,
|
|
119
|
+
purpose: params.purpose,
|
|
120
|
+
}, options.getSubAgentModelReference?.() ?? undefined);
|
|
121
|
+
if (!invocation.config) {
|
|
122
|
+
throw new RecoverableToolError(invocation.error ?? "Unable to resolve inline sub-agent.");
|
|
123
|
+
}
|
|
124
|
+
return dispatchSubAgentRun(options, currentModel, invocation.config, invocation.warning, params, signal, onUpdate);
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The task tool factories (`task_list`, `task_create`, `task_update`, `task_close`, `task_log`,
|
|
3
|
+
* `task_step_end`): each wires only its own schema and the per-task serial lock.
|
|
4
|
+
*/
|
|
1
5
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { taskCloseSchema, taskCreateSchema, taskListSchema, taskLogSchema, taskStepEndSchema, taskUpdateSchema } from "./
|
|
3
|
-
import type { TaskManageToolOptions } from "./
|
|
4
|
-
export type { TaskCloseRequest, TaskCreateRequest, TaskLogRequest, TaskManageResult, TaskManageToolOptions, TaskStepEndRequest, TaskUpdateRequest, } from "./
|
|
6
|
+
import { taskCloseSchema, taskCreateSchema, taskListSchema, taskLogSchema, taskStepEndSchema, taskUpdateSchema } from "./schema.js";
|
|
7
|
+
import type { TaskManageToolOptions } from "./types.js";
|
|
8
|
+
export type { TaskCloseRequest, TaskCreateRequest, TaskLogRequest, TaskManageResult, TaskManageToolOptions, TaskStepEndRequest, TaskUpdateRequest, } from "./types.js";
|
|
5
9
|
export declare function createTaskListTool(options: TaskManageToolOptions): AgentTool<typeof taskListSchema>;
|
|
6
10
|
export declare function createTaskCreateTool(options: TaskManageToolOptions): AgentTool<typeof taskCreateSchema>;
|
|
7
11
|
export declare function createTaskUpdateTool(options: TaskManageToolOptions): AgentTool<typeof taskUpdateSchema>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { normalizeTaskId } from "
|
|
2
|
-
import { withTaskMutation } from "
|
|
3
|
-
import { createTask } from "./
|
|
4
|
-
import { closeTask, listTasks, updateTask } from "./
|
|
5
|
-
import { readTaskLogTool } from "./
|
|
6
|
-
import { taskCloseSchema, taskCreateSchema, taskListSchema, taskLogSchema, taskStepEndSchema, taskUpdateSchema, } from "./
|
|
7
|
-
import { endTaskStep } from "./
|
|
1
|
+
import { normalizeTaskId } from "../../tasks/contract.js";
|
|
2
|
+
import { withTaskMutation } from "../../tasks/mutation-lock.js";
|
|
3
|
+
import { createTask } from "./create.js";
|
|
4
|
+
import { closeTask, listTasks, updateTask } from "./lifecycle.js";
|
|
5
|
+
import { readTaskLogTool } from "./log-view.js";
|
|
6
|
+
import { taskCloseSchema, taskCreateSchema, taskListSchema, taskLogSchema, taskStepEndSchema, taskUpdateSchema, } from "./schema.js";
|
|
7
|
+
import { endTaskStep } from "./step-end.js";
|
|
8
8
|
/**
|
|
9
9
|
* One tool per payload shape (spec 046, D3.1). Each factory wires only its own schema and, for
|
|
10
10
|
* the ones that carry an `id`, the same per-task serial lock (spec 029, D7): a task file write
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { mkdir } from "node:fs/promises";
|
|
2
|
+
import { applyTaskItemsPatch, normalizeTaskId, readActiveTasks } from "../../tasks/contract.js";
|
|
2
3
|
import { normalizeTaskBudget } from "../../tasks/contract-input.js";
|
|
3
|
-
import { applyTaskItemsPatch, normalizeTaskId, readActiveTasks } from "../../tasks/ledger.js";
|
|
4
4
|
import { readStoredTask, writeStoredTask } from "../../tasks/store.js";
|
|
5
5
|
import { describeTicket } from "../../tasks/ticket.js";
|
|
6
|
-
import { RecoverableToolError } from "../
|
|
6
|
+
import { RecoverableToolError } from "../contract/details.js";
|
|
7
7
|
import { closeTaskDocument, describeTaskState, requiredField, tasksDir } from "./shared.js";
|
|
8
8
|
async function requireTask(options, id) {
|
|
9
9
|
const document = await readStoredTask(options.channelDir, id);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { normalizeTaskId } from "../../tasks/
|
|
2
|
-
import { readTaskLog, renderTaskLogLine, taskLogIsArchived } from "../../tasks/log.js";
|
|
1
|
+
import { normalizeTaskId } from "../../tasks/contract.js";
|
|
2
|
+
import { readTaskLog, renderTaskLogLine, taskLogIsArchived } from "../../tasks/loop-log.js";
|
|
3
3
|
const DEFAULT_LIMIT = 20;
|
|
4
4
|
const MAX_LIMIT = 100;
|
|
5
5
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { uncheckedTaskAcceptanceItems } from "../../tasks/
|
|
3
|
-
import { appendTaskLog } from "../../tasks/log.js";
|
|
2
|
+
import { uncheckedTaskAcceptanceItems } from "../../tasks/contract.js";
|
|
3
|
+
import { appendTaskLog } from "../../tasks/loop-log.js";
|
|
4
4
|
import { archiveTask, writeStoredTask } from "../../tasks/store.js";
|
|
5
5
|
import { describeTicket } from "../../tasks/ticket.js";
|
|
6
|
-
import { RecoverableToolError } from "../
|
|
6
|
+
import { RecoverableToolError } from "../contract/details.js";
|
|
7
7
|
export function tasksDir(options) {
|
|
8
8
|
return join(options.channelDir, "tasks");
|
|
9
9
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { applyTaskItemsPatch, normalizeTaskId } from "../../tasks/
|
|
2
|
-
import { appendTaskLog } from "../../tasks/log.js";
|
|
1
|
+
import { applyTaskItemsPatch, normalizeTaskId } from "../../tasks/contract.js";
|
|
2
|
+
import { appendTaskLog } from "../../tasks/loop-log.js";
|
|
3
3
|
import { queueTaskNotice } from "../../tasks/steer.js";
|
|
4
4
|
import { readStoredTask, writeStoredTask } from "../../tasks/store.js";
|
|
5
5
|
import { describeTicket, resolveTicket } from "../../tasks/ticket.js";
|
|
6
|
-
import { RecoverableToolError } from "../
|
|
6
|
+
import { RecoverableToolError } from "../contract/details.js";
|
|
7
7
|
import { buildTicketContext, closeTaskDocument, requiredField } from "./shared.js";
|
|
8
8
|
/**
|
|
9
9
|
* `task_step_end` — the loop's only closing move (spec 051, D4/§12.4; narrowed by spec 052, D7).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Static } from "typebox";
|
|
2
|
-
import type { ChannelJobManager } from "../../
|
|
2
|
+
import type { ChannelJobManager } from "../../jobs/manager.js";
|
|
3
3
|
import type { SubAgentRunManager } from "../../subagents/runs.js";
|
|
4
4
|
import type { taskCloseSchema, taskCreateSchema, taskLogSchema, taskStepEndSchema, taskUpdateSchema } from "./schema.js";
|
|
5
5
|
export interface TaskManageResult {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
+
import type { PipiclawWebToolsConfig } from "../config/tools.js";
|
|
3
4
|
import type { SecurityConfig } from "../security/types.js";
|
|
4
|
-
import type { PipiclawWebToolsConfig } from "./config.js";
|
|
5
5
|
declare const webFetchSchema: Type.TObject<{
|
|
6
6
|
url: Type.TString;
|
|
7
7
|
extractMode: Type.TOptional<Type.TUnion<[Type.TLiteral<"markdown">, Type.TLiteral<"text">]>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
2
|
import { Type } from "typebox";
|
|
3
|
+
import type { PipiclawWebToolsConfig } from "../config/tools.js";
|
|
3
4
|
import type { SecurityConfig } from "../security/types.js";
|
|
4
|
-
import type { PipiclawWebToolsConfig } from "./config.js";
|
|
5
5
|
declare const webSearchSchema: Type.TObject<{
|
|
6
6
|
query: Type.TString;
|
|
7
7
|
count: Type.TOptional<Type.TInteger>;
|
package/dist/tui/app.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BootstrapIO, type BootstrapPaths } from "../
|
|
1
|
+
import { type BootstrapIO, type BootstrapPaths } from "../app/home.js";
|
|
2
2
|
export interface TuiAppOptions {
|
|
3
3
|
channel?: string;
|
|
4
4
|
/** One-shot, non-interactive run: process a single prompt then exit. */
|
package/dist/tui/app.js
CHANGED
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
* preparation shares `prepareAppServices` with the DingTalk path.
|
|
8
8
|
*/
|
|
9
9
|
import { userInfo } from "node:os";
|
|
10
|
-
import { createJobRuntime } from "../agent/job-manager.js";
|
|
11
10
|
import { createRunner } from "../agent/runner-factory.js";
|
|
12
|
-
import {
|
|
11
|
+
import { BootstrapExitError, bootstrapAppHome, DEFAULT_BOOTSTRAP_PATHS, printBootstrapSummary, readCliVersion, } from "../app/home.js";
|
|
12
|
+
import { prepareAppServices } from "../app/services.js";
|
|
13
|
+
import { finalDeliveryOf, progressStyleOf } from "../channel/channel-context.js";
|
|
13
14
|
import { ensureChannelDir } from "../channel/channel-paths.js";
|
|
14
15
|
import { ChannelStore } from "../channel/store.js";
|
|
15
16
|
import { renderBuiltInHelp } from "../commands/catalog.js";
|
|
17
|
+
import { runReportCommand } from "../commands/router.js";
|
|
16
18
|
import { createExecutor } from "../executor.js";
|
|
19
|
+
import { createJobRuntime } from "../jobs/manager.js";
|
|
17
20
|
import * as log from "../log.js";
|
|
18
|
-
import { BootstrapExitError, bootstrapAppHome, DEFAULT_BOOTSTRAP_PATHS, printBootstrapSummary, readCliVersion, } from "../runtime/app-home.js";
|
|
19
|
-
import { finalDeliveryOf, progressStyleOf } from "../runtime/dingtalk.js";
|
|
20
|
-
import { runReportCommand } from "../runtime/report-commands.js";
|
|
21
21
|
import { flushSecurityLogs } from "../security/logger.js";
|
|
22
|
-
import { createSubAgentRuntime } from "../subagents/
|
|
22
|
+
import { createSubAgentRuntime } from "../subagents/run-registry.js";
|
|
23
23
|
import { getUsageLedger } from "../usage/ledger.js";
|
|
24
24
|
import { TUI_SLASH_COMMANDS } from "./commands.js";
|
|
25
25
|
import { createFrontend } from "./renderer.js";
|
package/dist/tui/cli.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `pipiclaw tui` CLI: argument parsing and entry. Parsing is a pure function
|
|
3
3
|
* (`parseTuiArgs`) so it can be unit-tested; `runTui` wires it to `runTuiApp`.
|
|
4
4
|
*/
|
|
5
|
-
import { type BootstrapIO } from "../
|
|
5
|
+
import { type BootstrapIO } from "../app/home.js";
|
|
6
6
|
export type ParsedTui = {
|
|
7
7
|
kind: "run";
|
|
8
8
|
channel?: string;
|
package/dist/tui/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `pipiclaw tui` CLI: argument parsing and entry. Parsing is a pure function
|
|
3
3
|
* (`parseTuiArgs`) so it can be unit-tested; `runTui` wires it to `runTuiApp`.
|
|
4
4
|
*/
|
|
5
|
-
import { BootstrapExitError, readCliVersion } from "../
|
|
5
|
+
import { BootstrapExitError, readCliVersion } from "../app/home.js";
|
|
6
6
|
import { runTuiApp } from "./app.js";
|
|
7
7
|
/** Parse `pipiclaw tui` arguments (everything after the `tui` subcommand). */
|
|
8
8
|
export function parseTuiArgs(args) {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering + input contracts for the terminal TUI.
|
|
3
|
+
*
|
|
4
|
+
* `TranscriptRenderer` is the output-only surface the delivery controller
|
|
5
|
+
* (`terminal-context.ts`) writes to — progress, final answers, notices. It is
|
|
6
|
+
* deliberately small so it is trivial to fake in tests.
|
|
7
|
+
*
|
|
8
|
+
* `Frontend` is the full interactive shell the app drives: a `TranscriptRenderer`
|
|
9
|
+
* plus input events and lifecycle. Two implementations exist — a pi-tui rich UI
|
|
10
|
+
* (`pitui-frontend.ts`) and a plain stdout/readline fallback (`plain-frontend.ts`)
|
|
11
|
+
* for non-TTY / piped / `--print` use; `renderer.ts` picks between them.
|
|
12
|
+
*/
|
|
13
|
+
export interface TranscriptRenderer {
|
|
14
|
+
/** A streamed progress line (tool call, thinking, assistant increment, error). */
|
|
15
|
+
appendProgress(text: string): void;
|
|
16
|
+
/** The final answer for a turn, rendered prominently (Markdown where supported). */
|
|
17
|
+
showFinal(markdown: string): void;
|
|
18
|
+
/** A side notice (skill change, model fallback), rendered subtly. */
|
|
19
|
+
showNotice(text: string): void;
|
|
20
|
+
/** Collapse the current turn's progress region (used before a replacing final / silence). */
|
|
21
|
+
clearProgress(): void;
|
|
22
|
+
/** Toggle the working indicator (spinner). */
|
|
23
|
+
setWorking(on: boolean): void;
|
|
24
|
+
}
|
|
25
|
+
export interface FrontendCallbacks {
|
|
26
|
+
/** User submitted a line of input. */
|
|
27
|
+
onSubmit(text: string): void;
|
|
28
|
+
/** User pressed the interrupt key (Ctrl-C). Two-stage policy lives in the app. */
|
|
29
|
+
onInterrupt(): void;
|
|
30
|
+
/** End of input (Ctrl-D on an empty line, or stdin closed). */
|
|
31
|
+
onEof(): void;
|
|
32
|
+
}
|
|
33
|
+
export interface Frontend extends TranscriptRenderer {
|
|
34
|
+
/** Begin surfacing input events. Non-blocking. */
|
|
35
|
+
start(callbacks: FrontendCallbacks): void;
|
|
36
|
+
/** Update the status line (model, context %, hints). */
|
|
37
|
+
setStatus(text: string): void;
|
|
38
|
+
/** Mark a turn in-flight: disable input echo of a new turn and show the spinner. */
|
|
39
|
+
setBusy(busy: boolean): void;
|
|
40
|
+
/** Show a one-time welcome banner at startup. */
|
|
41
|
+
showBanner(text: string): void;
|
|
42
|
+
/** Tear down: restore the terminal, stop reading input. */
|
|
43
|
+
stop(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering + input contracts for the terminal TUI.
|
|
3
|
+
*
|
|
4
|
+
* `TranscriptRenderer` is the output-only surface the delivery controller
|
|
5
|
+
* (`terminal-context.ts`) writes to — progress, final answers, notices. It is
|
|
6
|
+
* deliberately small so it is trivial to fake in tests.
|
|
7
|
+
*
|
|
8
|
+
* `Frontend` is the full interactive shell the app drives: a `TranscriptRenderer`
|
|
9
|
+
* plus input events and lifecycle. Two implementations exist — a pi-tui rich UI
|
|
10
|
+
* (`pitui-frontend.ts`) and a plain stdout/readline fallback (`plain-frontend.ts`)
|
|
11
|
+
* for non-TTY / piped / `--print` use; `renderer.ts` picks between them.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* surface the events.
|
|
11
11
|
*/
|
|
12
12
|
import { type SlashCommand } from "@earendil-works/pi-tui";
|
|
13
|
-
import type { Frontend, FrontendCallbacks } from "./
|
|
13
|
+
import type { Frontend, FrontendCallbacks } from "./frontend.js";
|
|
14
14
|
export interface PiTuiFrontendOptions {
|
|
15
15
|
/** Slash commands to offer in editor autocomplete. */
|
|
16
16
|
commands?: SlashCommand[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Frontend, FrontendCallbacks } from "./
|
|
1
|
+
import type { Frontend, FrontendCallbacks } from "./frontend.js";
|
|
2
2
|
export interface PlainFrontendOptions {
|
|
3
3
|
/** Suppress progress/notice output on stderr; only the final answer is printed. */
|
|
4
4
|
quiet?: boolean;
|