comisai 1.0.19 → 1.0.23
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/cli-entry.js +0 -0
- package/node_modules/@comis/agent/dist/context-engine/context-engine.js +43 -2
- package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.d.ts +51 -0
- package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.js +110 -0
- package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.d.ts +54 -0
- package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.js +145 -0
- package/node_modules/@comis/agent/dist/context-engine/types-core.d.ts +17 -0
- package/node_modules/@comis/agent/dist/executor/error-classifier.d.ts +11 -1
- package/node_modules/@comis/agent/dist/executor/error-classifier.js +13 -0
- package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.d.ts +1 -0
- package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.js +55 -0
- package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.js +106 -5
- package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.js +1 -0
- package/node_modules/@comis/agent/dist/executor/pi-executor.d.ts +1 -4
- package/node_modules/@comis/agent/dist/executor/pi-executor.js +30 -3
- package/node_modules/@comis/agent/dist/executor/replay-drift-detector.d.ts +85 -0
- package/node_modules/@comis/agent/dist/executor/replay-drift-detector.js +92 -0
- package/node_modules/@comis/agent/dist/executor/signature-block-scrubber.d.ts +34 -0
- package/node_modules/@comis/agent/dist/executor/signature-block-scrubber.js +69 -0
- package/node_modules/@comis/agent/dist/executor/signed-replay-detector.d.ts +39 -0
- package/node_modules/@comis/agent/dist/executor/signed-replay-detector.js +72 -0
- package/node_modules/@comis/agent/package.json +1 -1
- package/node_modules/@comis/channels/package.json +1 -1
- package/node_modules/@comis/cli/dist/cli.js +0 -0
- package/node_modules/@comis/cli/package.json +1 -1
- package/node_modules/@comis/core/dist/config/git-manager.js +10 -4
- package/node_modules/@comis/core/dist/config/index.d.ts +1 -0
- package/node_modules/@comis/core/dist/config/index.js +2 -0
- package/node_modules/@comis/core/dist/config/managed-sections.d.ts +67 -0
- package/node_modules/@comis/core/dist/config/managed-sections.js +124 -0
- package/node_modules/@comis/core/dist/config/schema-agent.d.ts +28 -10
- package/node_modules/@comis/core/dist/config/schema-agent.js +6 -0
- package/node_modules/@comis/core/dist/config/schema-gateway.d.ts +2 -2
- package/node_modules/@comis/core/dist/config/schema.d.ts +65 -64
- package/node_modules/@comis/core/dist/event-bus/events-messaging.d.ts +16 -0
- package/node_modules/@comis/core/dist/exports/config.d.ts +1 -1
- package/node_modules/@comis/core/dist/exports/config.js +1 -1
- package/node_modules/@comis/core/package.json +1 -1
- package/node_modules/@comis/daemon/bundled-skills/skill-creator/scripts/init-skill.py +0 -0
- package/node_modules/@comis/daemon/bundled-skills/skill-creator/scripts/validate-skill.py +0 -0
- package/node_modules/@comis/daemon/dist/daemon.js +11 -4
- package/node_modules/@comis/daemon/dist/rpc/config-handlers.js +20 -7
- package/node_modules/@comis/daemon/dist/rpc/session-handlers.js +27 -1
- package/node_modules/@comis/daemon/dist/wiring/setup-gateway.d.ts +22 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-gateway.js +34 -8
- package/node_modules/@comis/daemon/dist/wiring/setup-tools.js +14 -1
- package/node_modules/@comis/daemon/package.json +1 -1
- package/node_modules/@comis/gateway/package.json +1 -1
- package/node_modules/@comis/infra/dist/logging/log-fields.d.ts +2 -2
- package/node_modules/@comis/infra/package.json +1 -1
- package/node_modules/@comis/memory/package.json +1 -1
- package/node_modules/@comis/scheduler/package.json +1 -1
- package/node_modules/@comis/shared/package.json +1 -1
- package/node_modules/@comis/skills/dist/bridge/tool-metadata-registry.js +23 -8
- package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.d.ts +1 -1
- package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.js +18 -14
- package/node_modules/@comis/skills/dist/builtin/platform/unified-session-tool.js +1 -1
- package/node_modules/@comis/skills/dist/builtin/sandbox/detect-provider.d.ts +1 -0
- package/node_modules/@comis/skills/dist/builtin/sandbox/detect-provider.js +78 -5
- package/node_modules/@comis/skills/package.json +1 -1
- package/node_modules/@comis/web/package.json +1 -1
- package/package.json +24 -26
- package/node_modules/@comis/agent/dist/provider/response/strip-minimax-xml.d.ts +0 -9
- package/node_modules/@comis/agent/dist/provider/response/strip-minimax-xml.js +0 -17
- package/node_modules/@comis/agent/dist/provider/response/strip-model-tokens.d.ts +0 -13
- package/node_modules/@comis/agent/dist/provider/response/strip-model-tokens.js +0 -19
- package/node_modules/@comis/agent/dist/provider/response/strip-tool-text.d.ts +0 -11
- package/node_modules/@comis/agent/dist/provider/response/strip-tool-text.js +0 -32
- package/node_modules/@comis/agent/dist/safety/follow-through-detector.d.ts +0 -46
- package/node_modules/@comis/agent/dist/safety/follow-through-detector.js +0 -76
- package/node_modules/@comis/agent/dist/safety/post-compaction-safety.d.ts +0 -30
- package/node_modules/@comis/agent/dist/safety/post-compaction-safety.js +0 -51
- package/node_modules/@comis/agent/dist/safety/schema-normalizer.d.ts +0 -37
- package/node_modules/@comis/agent/dist/safety/schema-normalizer.js +0 -137
- package/node_modules/@comis/agent/dist/safety/schema-pruning.d.ts +0 -50
- package/node_modules/@comis/agent/dist/safety/schema-pruning.js +0 -112
- package/node_modules/@comis/agent/dist/safety/tool-image-sanitizer.d.ts +0 -43
- package/node_modules/@comis/agent/dist/safety/tool-image-sanitizer.js +0 -96
- package/node_modules/@comis/agent/dist/safety/tool-sanitizer.d.ts +0 -44
- package/node_modules/@comis/agent/dist/safety/tool-sanitizer.js +0 -94
- package/node_modules/@comis/channels/dist/shared/thinking-tag-filter.d.ts +0 -28
- package/node_modules/@comis/channels/dist/shared/thinking-tag-filter.js +0 -206
- package/node_modules/@comis/cli/dist/wizard/config-writer.d.ts +0 -25
- package/node_modules/@comis/cli/dist/wizard/config-writer.js +0 -144
- package/node_modules/@comis/cli/dist/wizard/flow-types.d.ts +0 -48
- package/node_modules/@comis/cli/dist/wizard/flow-types.js +0 -70
- package/node_modules/@comis/cli/dist/wizard/manual-flow.d.ts +0 -21
- package/node_modules/@comis/cli/dist/wizard/manual-flow.js +0 -345
- package/node_modules/@comis/cli/dist/wizard/quickstart-flow.d.ts +0 -21
- package/node_modules/@comis/cli/dist/wizard/quickstart-flow.js +0 -116
- package/node_modules/@comis/core/dist/config/schema-agent-model.d.ts +0 -135
- package/node_modules/@comis/core/dist/config/schema-agent-model.js +0 -114
- package/node_modules/@comis/core/dist/config/schema-agent-session.d.ts +0 -177
- package/node_modules/@comis/core/dist/config/schema-agent-session.js +0 -116
- package/node_modules/@comis/core/dist/config/schema-context-engine.d.ts +0 -92
- package/node_modules/@comis/core/dist/config/schema-context-engine.js +0 -92
- package/node_modules/@comis/core/dist/config/schema-context-guard.d.ts +0 -34
- package/node_modules/@comis/core/dist/config/schema-context-guard.js +0 -32
- package/node_modules/@comis/core/dist/config/schema-delivery-mirror.d.ts +0 -27
- package/node_modules/@comis/core/dist/config/schema-delivery-mirror.js +0 -26
- package/node_modules/@comis/core/dist/config/schema-delivery-queue.d.ts +0 -31
- package/node_modules/@comis/core/dist/config/schema-delivery-queue.js +0 -30
- package/node_modules/@comis/core/dist/config/schema-delivery-timing.d.ts +0 -41
- package/node_modules/@comis/core/dist/config/schema-delivery-timing.js +0 -31
- package/node_modules/@comis/core/dist/config/schema-monitoring.d.ts +0 -105
- package/node_modules/@comis/core/dist/config/schema-monitoring.js +0 -67
- package/node_modules/@comis/core/dist/ports/media-ports.d.ts +0 -278
- package/node_modules/@comis/core/dist/ports/media-ports.js +0 -1
- package/node_modules/@comis/core/dist/security/input-guard.d.ts +0 -46
- package/node_modules/@comis/core/dist/security/input-guard.js +0 -166
- package/node_modules/@comis/core/dist/security/scoped-secret-manager.d.ts +0 -38
- package/node_modules/@comis/core/dist/security/scoped-secret-manager.js +0 -94
- package/node_modules/@comis/daemon/dist/observability/delivery-context.d.ts +0 -37
- package/node_modules/@comis/daemon/dist/observability/delivery-context.js +0 -1
- package/node_modules/@comis/daemon/dist/observability/log-level-manager.d.ts +0 -23
- package/node_modules/@comis/daemon/dist/observability/log-level-manager.js +0 -34
- package/node_modules/@comis/daemon/dist/observability/log-transport.d.ts +0 -44
- package/node_modules/@comis/daemon/dist/observability/log-transport.js +0 -74
- package/node_modules/@comis/daemon/dist/observability/obs-write-buffer.d.ts +0 -53
- package/node_modules/@comis/daemon/dist/observability/obs-write-buffer.js +0 -68
- package/node_modules/@comis/daemon/dist/observability/types.d.ts +0 -6
- package/node_modules/@comis/daemon/dist/observability/types.js +0 -1
- package/node_modules/@comis/daemon/dist/wiring/seed-bundled-skills.d.ts +0 -41
- package/node_modules/@comis/daemon/dist/wiring/seed-bundled-skills.js +0 -84
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery-mirror.d.ts +0 -24
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery-mirror.js +0 -88
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery-queue.d.ts +0 -31
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery-queue.js +0 -132
- package/node_modules/@comis/daemon/dist/wiring/setup-monitoring.d.ts +0 -38
- package/node_modules/@comis/daemon/dist/wiring/setup-monitoring.js +0 -100
- package/node_modules/@comis/daemon/dist/wiring/setup-rpc-bridge.d.ts +0 -34
- package/node_modules/@comis/daemon/dist/wiring/setup-rpc-bridge.js +0 -52
- package/node_modules/@comis/daemon/dist/wiring/setup-task-extraction.d.ts +0 -41
- package/node_modules/@comis/daemon/dist/wiring/setup-task-extraction.js +0 -86
- package/node_modules/@comis/memory/dist/embedding-cache.d.ts +0 -36
- package/node_modules/@comis/memory/dist/embedding-cache.js +0 -94
- package/node_modules/@comis/skills/dist/bridge/tool-output-schemas.d.ts +0 -17
- package/node_modules/@comis/skills/dist/bridge/tool-output-schemas.js +0 -125
- package/node_modules/@comis/skills/dist/bridge/tool-parallelism-metadata.d.ts +0 -14
- package/node_modules/@comis/skills/dist/bridge/tool-parallelism-metadata.js +0 -92
- package/node_modules/@comis/skills/dist/bridge/tool-result-caps.d.ts +0 -14
- package/node_modules/@comis/skills/dist/bridge/tool-result-caps.js +0 -36
- package/node_modules/@comis/skills/dist/bridge/tool-search-hints.d.ts +0 -15
- package/node_modules/@comis/skills/dist/bridge/tool-search-hints.js +0 -68
- package/node_modules/@comis/skills/dist/bridge/tool-validators.d.ts +0 -11
- package/node_modules/@comis/skills/dist/bridge/tool-validators.js +0 -105
- package/node_modules/@comis/skills/dist/builtin/file/find-sort-wrapper.d.ts +0 -22
- package/node_modules/@comis/skills/dist/builtin/file/find-sort-wrapper.js +0 -95
- package/node_modules/@comis/skills/dist/builtin/file/grep-output-mode-wrapper.d.ts +0 -24
- package/node_modules/@comis/skills/dist/builtin/file/grep-output-mode-wrapper.js +0 -167
- package/node_modules/@comis/skills/dist/builtin/task-plan-tool.d.ts +0 -25
- package/node_modules/@comis/skills/dist/builtin/task-plan-tool.js +0 -67
- package/node_modules/@comis/skills/dist/integrations/mcp-tool-bridge.d.ts +0 -75
- package/node_modules/@comis/skills/dist/integrations/mcp-tool-bridge.js +0 -235
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-tool search hints for deferred tool discovery (Phase 569: DISC-01, DISC-03).
|
|
3
|
-
*
|
|
4
|
-
* Registers searchHint for all 35 deferrable tools. Each hint is max 80 chars,
|
|
5
|
-
* lowercase, space-separated keyword synonyms that enrich BM25 matching in
|
|
6
|
-
* discover_tools. Uses merge semantics so existing metadata (isReadOnly,
|
|
7
|
-
* maxResultSizeChars, outputSchema, etc.) is preserved.
|
|
8
|
-
*
|
|
9
|
-
* Import this module for side effects only -- it runs registerToolMetadata()
|
|
10
|
-
* calls at module scope. Imported from tool-bridge.ts to ensure hints are
|
|
11
|
-
* registered before discover_tools execute() reads them.
|
|
12
|
-
*
|
|
13
|
-
* @module
|
|
14
|
-
*/
|
|
15
|
-
import { registerToolMetadata } from "@comis/core";
|
|
16
|
-
// ===========================================================================
|
|
17
|
-
// Session tools (9)
|
|
18
|
-
// ===========================================================================
|
|
19
|
-
registerToolMetadata("sessions_list", { searchHint: "active sessions connections users online list enumerate" });
|
|
20
|
-
registerToolMetadata("sessions_history", { searchHint: "chat log transcript conversation history messages past" });
|
|
21
|
-
registerToolMetadata("sessions_send", { searchHint: "send reply respond direct message channel session inject" });
|
|
22
|
-
registerToolMetadata("sessions_spawn", { searchHint: "delegate subagent background async child worker spawn" });
|
|
23
|
-
registerToolMetadata("subagents", { searchHint: "parallel fan-out concurrent multi-agent batch delegate" });
|
|
24
|
-
registerToolMetadata("pipeline", { searchHint: "workflow dag graph orchestrate chain multi-step sequential" });
|
|
25
|
-
registerToolMetadata("session_status", { searchHint: "session state alive running progress heartbeat check" });
|
|
26
|
-
registerToolMetadata("session_search", { searchHint: "find session lookup filter match query user channel" });
|
|
27
|
-
registerToolMetadata("agents_list", { searchHint: "bots agents roster fleet inventory configured available" });
|
|
28
|
-
// ===========================================================================
|
|
29
|
-
// Platform tools (6)
|
|
30
|
-
// ===========================================================================
|
|
31
|
-
registerToolMetadata("cron", { searchHint: "schedule timer reminder recurring job automation crontab interval" });
|
|
32
|
-
registerToolMetadata("gateway", { searchHint: "config restart patch status settings yaml update system admin" });
|
|
33
|
-
registerToolMetadata("image_analyze", { searchHint: "vision ocr describe photo picture identify detect recognize" });
|
|
34
|
-
registerToolMetadata("tts_synthesize", { searchHint: "speech voice audio speak narrate text-to-speech vocalize" });
|
|
35
|
-
registerToolMetadata("transcribe_audio", { searchHint: "stt speech-to-text whisper dictation voice recording audio" });
|
|
36
|
-
registerToolMetadata("describe_video", { searchHint: "video clip movie mp4 mov webm scene describe motion visual" });
|
|
37
|
-
// ===========================================================================
|
|
38
|
-
// Document and browser tools (2)
|
|
39
|
-
// ===========================================================================
|
|
40
|
-
registerToolMetadata("extract_document", { searchHint: "pdf csv docx xlsx parse text content extract spreadsheet" });
|
|
41
|
-
registerToolMetadata("browser", { searchHint: "chrome headless puppeteer navigate click screenshot scrape" });
|
|
42
|
-
// ===========================================================================
|
|
43
|
-
// Context tools (4)
|
|
44
|
-
// ===========================================================================
|
|
45
|
-
registerToolMetadata("ctx_search", { searchHint: "rag context knowledge semantic embedding retrieve similar" });
|
|
46
|
-
registerToolMetadata("ctx_inspect", { searchHint: "context detail metadata source provenance inspect entry" });
|
|
47
|
-
registerToolMetadata("ctx_expand", { searchHint: "context expand elaborate detail follow-up deeper related" });
|
|
48
|
-
registerToolMetadata("ctx_recall", { searchHint: "memory recall remember fact previous mentioned earlier" });
|
|
49
|
-
// ===========================================================================
|
|
50
|
-
// Platform channel actions (4)
|
|
51
|
-
// ===========================================================================
|
|
52
|
-
registerToolMetadata("discord_action", { searchHint: "pin kick ban roles threads channels guild server discord" });
|
|
53
|
-
registerToolMetadata("telegram_action", { searchHint: "pin poll sticker admin topics group supergroup telegram" });
|
|
54
|
-
registerToolMetadata("slack_action", { searchHint: "pin react thread channel topic archive bookmark slack" });
|
|
55
|
-
registerToolMetadata("whatsapp_action", { searchHint: "status group admin label broadcast forward whatsapp" });
|
|
56
|
-
// ===========================================================================
|
|
57
|
-
// Privileged management tools (10)
|
|
58
|
-
// ===========================================================================
|
|
59
|
-
registerToolMetadata("agents_manage", { searchHint: "fleet create delete suspend resume agent configure workspace" });
|
|
60
|
-
registerToolMetadata("obs_query", { searchHint: "diagnostics monitoring metrics billing traces logs health" });
|
|
61
|
-
registerToolMetadata("sessions_manage", { searchHint: "delete reset export compact session lifecycle cleanup admin" });
|
|
62
|
-
registerToolMetadata("memory_manage", { searchHint: "delete flush export browse stats storage cleanup purge" });
|
|
63
|
-
registerToolMetadata("channels_manage", { searchHint: "enable disable restart channel adapter platform connection" });
|
|
64
|
-
registerToolMetadata("tokens_manage", { searchHint: "api key token rotate revoke generate auth credential" });
|
|
65
|
-
registerToolMetadata("models_manage", { searchHint: "llm provider model switch configure cost tier pricing" });
|
|
66
|
-
registerToolMetadata("skills_manage", { searchHint: "skill plugin capability register unregister enable toggle" });
|
|
67
|
-
registerToolMetadata("mcp_manage", { searchHint: "mcp server protocol connect disconnect tool external" });
|
|
68
|
-
registerToolMetadata("heartbeat_manage", { searchHint: "heartbeat keepalive watchdog health probe interval alive" });
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-tool input validators (Phase 566).
|
|
3
|
-
*
|
|
4
|
-
* Registers validateInput metadata for tools that benefit from pre-flight
|
|
5
|
-
* input validation. Validators run before execute() in the enforcement
|
|
6
|
-
* wrapper, saving tool budget when inputs are invalid.
|
|
7
|
-
*
|
|
8
|
-
* Import this module for side effects only.
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
export {};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-tool input validators (Phase 566).
|
|
3
|
-
*
|
|
4
|
-
* Registers validateInput metadata for tools that benefit from pre-flight
|
|
5
|
-
* input validation. Validators run before execute() in the enforcement
|
|
6
|
-
* wrapper, saving tool budget when inputs are invalid.
|
|
7
|
-
*
|
|
8
|
-
* Import this module for side effects only.
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
import { registerToolMetadata, isImmutableConfigPath } from "@comis/core";
|
|
12
|
-
import { validateCommand, validateEnvVars } from "../builtin/exec-tool.js";
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
// VAL-04: Exec tool -- command denylist + env var denylist check
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
registerToolMetadata("exec", {
|
|
17
|
-
validateInput: (params) => {
|
|
18
|
-
const command = typeof params.command === "string" ? params.command : undefined;
|
|
19
|
-
if (!command || command.trim() === "") {
|
|
20
|
-
return "Missing required parameter: command";
|
|
21
|
-
}
|
|
22
|
-
// Dangerous command denylist check (re-uses exec-tool.ts patterns)
|
|
23
|
-
const cmdError = validateCommand(command);
|
|
24
|
-
if (cmdError)
|
|
25
|
-
return cmdError;
|
|
26
|
-
// Dangerous env var denylist check
|
|
27
|
-
if (params.env && typeof params.env === "object") {
|
|
28
|
-
const envError = validateEnvVars(params.env);
|
|
29
|
-
if (envError)
|
|
30
|
-
return envError;
|
|
31
|
-
}
|
|
32
|
-
return undefined;
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
// ---------------------------------------------------------------------------
|
|
36
|
-
// VAL-05: Cron tool -- action enum + per-action required param validation
|
|
37
|
-
// ---------------------------------------------------------------------------
|
|
38
|
-
const VALID_CRON_ACTIONS = ["add", "list", "update", "remove", "status", "runs", "run", "wake"];
|
|
39
|
-
const VALID_SCHEDULE_KINDS = ["cron", "every", "at"];
|
|
40
|
-
registerToolMetadata("cron", {
|
|
41
|
-
validateInput: (params) => {
|
|
42
|
-
const action = typeof params.action === "string" ? params.action : undefined;
|
|
43
|
-
if (!action || !VALID_CRON_ACTIONS.includes(action)) {
|
|
44
|
-
return `Invalid action: "${action ?? ""}". Valid: ${VALID_CRON_ACTIONS.join(", ")}`;
|
|
45
|
-
}
|
|
46
|
-
if (action === "add") {
|
|
47
|
-
if (!params.payload_kind)
|
|
48
|
-
return "Missing required parameter: payload_kind (for add)";
|
|
49
|
-
if (!params.payload_text)
|
|
50
|
-
return "Missing required parameter: payload_text (for add)";
|
|
51
|
-
if (params.schedule_kind && typeof params.schedule_kind === "string") {
|
|
52
|
-
if (!VALID_SCHEDULE_KINDS.includes(params.schedule_kind)) {
|
|
53
|
-
return `Invalid schedule_kind: "${params.schedule_kind}". Valid: ${VALID_SCHEDULE_KINDS.join(", ")}`;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (["update", "remove", "runs", "run"].includes(action)) {
|
|
58
|
-
if (!params.job_name)
|
|
59
|
-
return `Missing required parameter: job_name (for ${action})`;
|
|
60
|
-
}
|
|
61
|
-
return undefined;
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
// ---------------------------------------------------------------------------
|
|
65
|
-
// VAL-06: Message tool -- action enum + channel_type/channel_id presence
|
|
66
|
-
// ---------------------------------------------------------------------------
|
|
67
|
-
const VALID_MESSAGE_ACTIONS = ["send", "reply", "react", "edit", "delete", "fetch", "attach"];
|
|
68
|
-
registerToolMetadata("message", {
|
|
69
|
-
validateInput: (params) => {
|
|
70
|
-
const action = typeof params.action === "string" ? params.action : undefined;
|
|
71
|
-
if (!action || !VALID_MESSAGE_ACTIONS.includes(action)) {
|
|
72
|
-
return `Invalid action: "${action ?? ""}". Valid: ${VALID_MESSAGE_ACTIONS.join(", ")}`;
|
|
73
|
-
}
|
|
74
|
-
if (!params.channel_type || typeof params.channel_type !== "string") {
|
|
75
|
-
return "Missing required parameter: channel_type";
|
|
76
|
-
}
|
|
77
|
-
if (!params.channel_id || typeof params.channel_id !== "string") {
|
|
78
|
-
return "Missing required parameter: channel_id";
|
|
79
|
-
}
|
|
80
|
-
return undefined;
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
// ---------------------------------------------------------------------------
|
|
84
|
-
// VAL-07: Gateway tool -- action enum + immutable path rejection for patch
|
|
85
|
-
// ---------------------------------------------------------------------------
|
|
86
|
-
const VALID_GATEWAY_ACTIONS = [
|
|
87
|
-
"read", "patch", "apply", "restart", "schema", "status", "history", "diff", "rollback", "env_set",
|
|
88
|
-
];
|
|
89
|
-
registerToolMetadata("gateway", {
|
|
90
|
-
validateInput: (params) => {
|
|
91
|
-
const action = typeof params.action === "string" ? params.action : undefined;
|
|
92
|
-
if (!action || !VALID_GATEWAY_ACTIONS.includes(action)) {
|
|
93
|
-
return `Invalid action: "${action ?? ""}". Valid: ${VALID_GATEWAY_ACTIONS.join(", ")}`;
|
|
94
|
-
}
|
|
95
|
-
// Only check immutability for patch action (Pitfall 3: reads must succeed on immutable paths)
|
|
96
|
-
if (action === "patch") {
|
|
97
|
-
const section = typeof params.section === "string" ? params.section : undefined;
|
|
98
|
-
const key = typeof params.key === "string" ? params.key : undefined;
|
|
99
|
-
if (section && isImmutableConfigPath(section, key)) {
|
|
100
|
-
return `Cannot patch immutable config path: ${section}${key ? "." + key : ""}`;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return undefined;
|
|
104
|
-
},
|
|
105
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find tool mtime sort wrapper.
|
|
3
|
-
*
|
|
4
|
-
* Post-processes find tool results to sort file paths by modification time
|
|
5
|
-
* (most recently modified first). Preserves trailing notices (truncation,
|
|
6
|
-
* result limit) from the upstream SDK output.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
11
|
-
/**
|
|
12
|
-
* Wrap the find tool to sort results by modification time (most recent first).
|
|
13
|
-
*
|
|
14
|
-
* Delegates to the original find tool's execute, then post-processes the text
|
|
15
|
-
* content: parses newline-separated file paths, stats each for mtime, sorts
|
|
16
|
-
* descending, and preserves any trailing notice lines (lines starting with `[`).
|
|
17
|
-
*
|
|
18
|
-
* @param tool - The find tool (already wrapped with safePath)
|
|
19
|
-
* @param workspacePath - Workspace root for path resolution
|
|
20
|
-
* @returns A new AgentTool with mtime-sorted output
|
|
21
|
-
*/
|
|
22
|
-
export declare function wrapFindWithMtimeSort(tool: AgentTool<any>, workspacePath: string): AgentTool<any>;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Find tool mtime sort wrapper.
|
|
3
|
-
*
|
|
4
|
-
* Post-processes find tool results to sort file paths by modification time
|
|
5
|
-
* (most recently modified first). Preserves trailing notices (truncation,
|
|
6
|
-
* result limit) from the upstream SDK output.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
import * as fs from "node:fs/promises";
|
|
11
|
-
import * as nodePath from "node:path";
|
|
12
|
-
import { safePath } from "@comis/core";
|
|
13
|
-
/** No-match sentinel from pi-coding-agent find tool. */
|
|
14
|
-
const NO_FILES_FOUND = "No files found matching pattern";
|
|
15
|
-
/**
|
|
16
|
-
* Wrap the find tool to sort results by modification time (most recent first).
|
|
17
|
-
*
|
|
18
|
-
* Delegates to the original find tool's execute, then post-processes the text
|
|
19
|
-
* content: parses newline-separated file paths, stats each for mtime, sorts
|
|
20
|
-
* descending, and preserves any trailing notice lines (lines starting with `[`).
|
|
21
|
-
*
|
|
22
|
-
* @param tool - The find tool (already wrapped with safePath)
|
|
23
|
-
* @param workspacePath - Workspace root for path resolution
|
|
24
|
-
* @returns A new AgentTool with mtime-sorted output
|
|
25
|
-
*/
|
|
26
|
-
export function wrapFindWithMtimeSort(
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- AgentTool generic requires `any` per pi-agent-core API
|
|
28
|
-
tool, workspacePath) {
|
|
29
|
-
return {
|
|
30
|
-
...tool,
|
|
31
|
-
async execute(toolCallId, params, signal, onUpdate) {
|
|
32
|
-
// Delegate to the original find tool
|
|
33
|
-
const result = await tool.execute(toolCallId, params, signal, onUpdate);
|
|
34
|
-
// Extract text content from result
|
|
35
|
-
const textParts = result.content
|
|
36
|
-
.filter((c) => c.type === "text")
|
|
37
|
-
.map((c) => c.text);
|
|
38
|
-
const fullText = textParts.join("");
|
|
39
|
-
// Passthrough: no files found
|
|
40
|
-
if (fullText.trim() === NO_FILES_FOUND || fullText.trim() === "") {
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
// Split into lines and separate file paths from trailing notices
|
|
44
|
-
const lines = fullText.split("\n").filter((l) => l.length > 0);
|
|
45
|
-
const filePaths = [];
|
|
46
|
-
const notices = [];
|
|
47
|
-
for (const line of lines) {
|
|
48
|
-
if (line.startsWith("[")) {
|
|
49
|
-
notices.push(line);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
filePaths.push(line);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (filePaths.length === 0) {
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
|
-
// Resolve search base: use the `path` param if provided, else workspace
|
|
59
|
-
const searchBase = typeof params.path === "string" ? params.path : workspacePath;
|
|
60
|
-
const resolvedBase = nodePath.isAbsolute(searchBase)
|
|
61
|
-
? searchBase
|
|
62
|
-
: safePath(workspacePath, searchBase);
|
|
63
|
-
// Stat each file and collect mtime
|
|
64
|
-
const entries = [];
|
|
65
|
-
const failedEntries = [];
|
|
66
|
-
const statPromises = filePaths.map(async (fp) => {
|
|
67
|
-
const absolutePath = nodePath.isAbsolute(fp)
|
|
68
|
-
? fp
|
|
69
|
-
: nodePath.resolve(resolvedBase, fp);
|
|
70
|
-
try {
|
|
71
|
-
const stat = await fs.stat(absolutePath);
|
|
72
|
-
entries.push({ path: fp, mtimeMs: stat.mtimeMs });
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
// File disappeared between find and sort -- put at end
|
|
76
|
-
failedEntries.push(fp);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
await Promise.all(statPromises);
|
|
80
|
-
// Sort by mtime descending (most recent first)
|
|
81
|
-
entries.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
82
|
-
// Reassemble: sorted paths + failed paths + notices
|
|
83
|
-
const sortedLines = [
|
|
84
|
-
...entries.map((e) => e.path),
|
|
85
|
-
...failedEntries,
|
|
86
|
-
...notices,
|
|
87
|
-
];
|
|
88
|
-
const sortedText = sortedLines.join("\n");
|
|
89
|
-
return {
|
|
90
|
-
...result,
|
|
91
|
-
content: [{ type: "text", text: sortedText }],
|
|
92
|
-
};
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Grep tool output mode wrapper.
|
|
3
|
-
*
|
|
4
|
-
* Post-processes grep tool results based on an `output_mode` parameter added
|
|
5
|
-
* at the Comis layer. The upstream SDK grep always returns full match output
|
|
6
|
-
* (file:line: content). This wrapper provides additional output formats:
|
|
7
|
-
* - `content` (default): unchanged upstream output
|
|
8
|
-
* - `files_with_matches`: deduplicated file paths only
|
|
9
|
-
* - `count`: per-file match counts, sorted by count descending
|
|
10
|
-
*
|
|
11
|
-
* @module
|
|
12
|
-
*/
|
|
13
|
-
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
14
|
-
/**
|
|
15
|
-
* Wrap the grep tool to support `output_mode` parameter.
|
|
16
|
-
*
|
|
17
|
-
* Extends the tool's parameter schema to add `output_mode`, strips it
|
|
18
|
-
* before delegating to the original tool, then post-processes the result
|
|
19
|
-
* based on the requested output mode.
|
|
20
|
-
*
|
|
21
|
-
* @param tool - The grep tool (already wrapped with safePath)
|
|
22
|
-
* @returns A new AgentTool with output_mode support
|
|
23
|
-
*/
|
|
24
|
-
export declare function wrapGrepWithOutputMode(tool: AgentTool<any>): AgentTool<any>;
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Grep tool output mode wrapper.
|
|
3
|
-
*
|
|
4
|
-
* Post-processes grep tool results based on an `output_mode` parameter added
|
|
5
|
-
* at the Comis layer. The upstream SDK grep always returns full match output
|
|
6
|
-
* (file:line: content). This wrapper provides additional output formats:
|
|
7
|
-
* - `content` (default): unchanged upstream output
|
|
8
|
-
* - `files_with_matches`: deduplicated file paths only
|
|
9
|
-
* - `count`: per-file match counts, sorted by count descending
|
|
10
|
-
*
|
|
11
|
-
* @module
|
|
12
|
-
*/
|
|
13
|
-
import { Type } from "@sinclair/typebox";
|
|
14
|
-
/**
|
|
15
|
-
* Regex to extract file path and line number from grep output lines.
|
|
16
|
-
*
|
|
17
|
-
* Match lines: `filepath:linenum: content`
|
|
18
|
-
* Context lines: `filepath-linenum- content`
|
|
19
|
-
*
|
|
20
|
-
* The file path is everything before the first `:linenum:` or `-linenum-`.
|
|
21
|
-
*/
|
|
22
|
-
const MATCH_LINE_RE = /^(.+?):(\d+): /;
|
|
23
|
-
const CONTEXT_LINE_RE = /^(.+?)-(\d+)- /;
|
|
24
|
-
/** Sentinel for no-match output from pi-coding-agent grep. */
|
|
25
|
-
const NO_MATCHES = "No matches found";
|
|
26
|
-
/**
|
|
27
|
-
* Extract trailing notice lines (starting with `[`) from the output.
|
|
28
|
-
* Notices appear after a blank line at the end of grep output.
|
|
29
|
-
*/
|
|
30
|
-
function splitNotices(text) {
|
|
31
|
-
const lines = text.split("\n");
|
|
32
|
-
const notices = [];
|
|
33
|
-
// Walk backwards to find trailing notice lines
|
|
34
|
-
let i = lines.length - 1;
|
|
35
|
-
while (i >= 0 && (lines[i].startsWith("[") || lines[i].trim() === "")) {
|
|
36
|
-
if (lines[i].startsWith("[")) {
|
|
37
|
-
notices.unshift(lines[i]);
|
|
38
|
-
}
|
|
39
|
-
i--;
|
|
40
|
-
}
|
|
41
|
-
const body = lines.slice(0, i + 1).join("\n");
|
|
42
|
-
return { body, notices };
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Parse grep output into file-path-keyed match counts.
|
|
46
|
-
* Only counts actual match lines (`:linenum: `), not context lines (`-linenum- `).
|
|
47
|
-
*/
|
|
48
|
-
function countMatchesByFile(body) {
|
|
49
|
-
const counts = new Map();
|
|
50
|
-
for (const line of body.split("\n")) {
|
|
51
|
-
const match = MATCH_LINE_RE.exec(line);
|
|
52
|
-
if (match) {
|
|
53
|
-
const filePath = match[1];
|
|
54
|
-
counts.set(filePath, (counts.get(filePath) ?? 0) + 1);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return counts;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Extract unique file paths from grep output (both match and context lines).
|
|
61
|
-
*/
|
|
62
|
-
function extractUniquePaths(body) {
|
|
63
|
-
const seen = new Set();
|
|
64
|
-
const paths = [];
|
|
65
|
-
for (const line of body.split("\n")) {
|
|
66
|
-
const matchResult = MATCH_LINE_RE.exec(line) ?? CONTEXT_LINE_RE.exec(line);
|
|
67
|
-
if (matchResult) {
|
|
68
|
-
const filePath = matchResult[1];
|
|
69
|
-
if (!seen.has(filePath)) {
|
|
70
|
-
seen.add(filePath);
|
|
71
|
-
paths.push(filePath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return paths;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Wrap the grep tool to support `output_mode` parameter.
|
|
79
|
-
*
|
|
80
|
-
* Extends the tool's parameter schema to add `output_mode`, strips it
|
|
81
|
-
* before delegating to the original tool, then post-processes the result
|
|
82
|
-
* based on the requested output mode.
|
|
83
|
-
*
|
|
84
|
-
* @param tool - The grep tool (already wrapped with safePath)
|
|
85
|
-
* @returns A new AgentTool with output_mode support
|
|
86
|
-
*/
|
|
87
|
-
export function wrapGrepWithOutputMode(
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- AgentTool generic requires `any` per pi-agent-core API
|
|
89
|
-
tool) {
|
|
90
|
-
// Extend parameter schema with output_mode
|
|
91
|
-
const originalParams = tool.parameters;
|
|
92
|
-
const extendedParams = Type.Object({
|
|
93
|
-
...originalParams.properties,
|
|
94
|
-
output_mode: Type.Optional(Type.Union([
|
|
95
|
-
Type.Literal("content"),
|
|
96
|
-
Type.Literal("files_with_matches"),
|
|
97
|
-
Type.Literal("count"),
|
|
98
|
-
], {
|
|
99
|
-
description: "Output format: 'content' (default, full match lines), 'files_with_matches' (file paths only), or 'count' (match counts per file)",
|
|
100
|
-
})),
|
|
101
|
-
offset: Type.Optional(Type.Number({
|
|
102
|
-
description: "Skip the first N result entries (lines for content mode, file paths for files_with_matches, count entries for count mode). Default: 0.",
|
|
103
|
-
})),
|
|
104
|
-
});
|
|
105
|
-
return {
|
|
106
|
-
...tool,
|
|
107
|
-
parameters: extendedParams,
|
|
108
|
-
async execute(toolCallId, params, signal, onUpdate) {
|
|
109
|
-
// Extract and strip output_mode + offset before delegating to upstream
|
|
110
|
-
const outputMode = params.output_mode ?? "content";
|
|
111
|
-
const offset = params.offset ?? 0;
|
|
112
|
-
const upstreamParams = { ...params };
|
|
113
|
-
delete upstreamParams.output_mode;
|
|
114
|
-
delete upstreamParams.offset;
|
|
115
|
-
// Delegate to original grep tool
|
|
116
|
-
const result = await tool.execute(toolCallId, upstreamParams, signal, onUpdate);
|
|
117
|
-
// Extract text content from result
|
|
118
|
-
const textParts = result.content
|
|
119
|
-
.filter((c) => c.type === "text")
|
|
120
|
-
.map((c) => c.text);
|
|
121
|
-
const fullText = textParts.join("");
|
|
122
|
-
// Passthrough for empty or no-match results
|
|
123
|
-
if (fullText.trim() === "" || fullText.trim() === NO_MATCHES) {
|
|
124
|
-
return result;
|
|
125
|
-
}
|
|
126
|
-
// For default/content mode, apply offset if needed then return
|
|
127
|
-
if (outputMode === "content") {
|
|
128
|
-
if (offset <= 0) {
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
const { body, notices } = splitNotices(fullText);
|
|
132
|
-
const lines = body.split("\n").slice(offset);
|
|
133
|
-
let transformedText = lines.join("\n");
|
|
134
|
-
if (notices.length > 0) {
|
|
135
|
-
transformedText += (transformedText ? "\n\n" : "") + notices.join("\n");
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
...result,
|
|
139
|
-
content: [{ type: "text", text: transformedText }],
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
// Separate output body from trailing notices
|
|
143
|
-
const { body, notices } = splitNotices(fullText);
|
|
144
|
-
let transformedText;
|
|
145
|
-
if (outputMode === "files_with_matches") {
|
|
146
|
-
const paths = extractUniquePaths(body).slice(offset);
|
|
147
|
-
transformedText = paths.join("\n");
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
// count mode
|
|
151
|
-
const counts = countMatchesByFile(body);
|
|
152
|
-
const sorted = [...counts.entries()].sort((a, b) => b[1] - a[1]).slice(offset);
|
|
153
|
-
transformedText = sorted
|
|
154
|
-
.map(([filePath, count]) => `${filePath}: ${count} ${count === 1 ? "match" : "matches"}`)
|
|
155
|
-
.join("\n");
|
|
156
|
-
}
|
|
157
|
-
// Append notices if present
|
|
158
|
-
if (notices.length > 0) {
|
|
159
|
-
transformedText += (transformedText ? "\n\n" : "") + notices.join("\n");
|
|
160
|
-
}
|
|
161
|
-
return {
|
|
162
|
-
...result,
|
|
163
|
-
content: [{ type: "text", text: transformedText }],
|
|
164
|
-
};
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Task plan tool: stateless formatter for multi-step work plans.
|
|
3
|
-
*
|
|
4
|
-
* Agents use this tool to structure and communicate multi-step plans
|
|
5
|
-
* visible in conversation history. Pure formatting -- no persistence,
|
|
6
|
-
* no side effects, no state.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
11
|
-
declare const TaskPlanParams: import("@sinclair/typebox").TObject<{
|
|
12
|
-
tasks: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
13
|
-
id: import("@sinclair/typebox").TString;
|
|
14
|
-
description: import("@sinclair/typebox").TString;
|
|
15
|
-
status: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"pending">, import("@sinclair/typebox").TLiteral<"in-progress">, import("@sinclair/typebox").TLiteral<"done">, import("@sinclair/typebox").TLiteral<"skipped">]>;
|
|
16
|
-
}>>;
|
|
17
|
-
title: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
18
|
-
}>;
|
|
19
|
-
/**
|
|
20
|
-
* Create a stateless task_plan tool for structuring multi-step work plans.
|
|
21
|
-
*
|
|
22
|
-
* @returns AgentTool that formats task lists into readable plan text
|
|
23
|
-
*/
|
|
24
|
-
export declare function createTaskPlanTool(): AgentTool<typeof TaskPlanParams>;
|
|
25
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Task plan tool: stateless formatter for multi-step work plans.
|
|
3
|
-
*
|
|
4
|
-
* Agents use this tool to structure and communicate multi-step plans
|
|
5
|
-
* visible in conversation history. Pure formatting -- no persistence,
|
|
6
|
-
* no side effects, no state.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
import { Type } from "@sinclair/typebox";
|
|
11
|
-
import { jsonResult } from "./platform/tool-helpers.js";
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
// Parameter schema
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
const TaskPlanParams = Type.Object({
|
|
16
|
-
tasks: Type.Array(Type.Object({
|
|
17
|
-
id: Type.String({ description: "Unique task identifier" }),
|
|
18
|
-
description: Type.String({ description: "What needs to be done" }),
|
|
19
|
-
status: Type.Union([
|
|
20
|
-
Type.Literal("pending"),
|
|
21
|
-
Type.Literal("in-progress"),
|
|
22
|
-
Type.Literal("done"),
|
|
23
|
-
Type.Literal("skipped"),
|
|
24
|
-
], { description: "Current task status" }),
|
|
25
|
-
}), { description: "List of tasks in the plan" }),
|
|
26
|
-
title: Type.Optional(Type.String({ description: "Optional plan title (defaults to 'Task Plan')" })),
|
|
27
|
-
});
|
|
28
|
-
// ---------------------------------------------------------------------------
|
|
29
|
-
// Status icon mapping
|
|
30
|
-
// ---------------------------------------------------------------------------
|
|
31
|
-
const STATUS_ICONS = {
|
|
32
|
-
pending: "[ ]",
|
|
33
|
-
"in-progress": "[~]",
|
|
34
|
-
done: "[x]",
|
|
35
|
-
skipped: "[-]",
|
|
36
|
-
};
|
|
37
|
-
// ---------------------------------------------------------------------------
|
|
38
|
-
// Factory
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
40
|
-
/**
|
|
41
|
-
* Create a stateless task_plan tool for structuring multi-step work plans.
|
|
42
|
-
*
|
|
43
|
-
* @returns AgentTool that formats task lists into readable plan text
|
|
44
|
-
*/
|
|
45
|
-
export function createTaskPlanTool() {
|
|
46
|
-
return {
|
|
47
|
-
name: "task_plan",
|
|
48
|
-
label: "Task Plan",
|
|
49
|
-
description: "Structure and display a multi-step task plan. Returns a formatted summary. " +
|
|
50
|
-
"Stateless -- use this to organize your work and communicate progress.",
|
|
51
|
-
parameters: TaskPlanParams,
|
|
52
|
-
async execute(_toolCallId, params) {
|
|
53
|
-
const p = params;
|
|
54
|
-
const title = p.title ?? "Task Plan";
|
|
55
|
-
const tasks = p.tasks ?? [];
|
|
56
|
-
// Format each task line
|
|
57
|
-
const lines = tasks.map((t) => `${STATUS_ICONS[t.status]} ${t.id}: ${t.description}`);
|
|
58
|
-
// Count completed
|
|
59
|
-
const doneCount = tasks.filter((t) => t.status === "done").length;
|
|
60
|
-
const totalCount = tasks.length;
|
|
61
|
-
const summary = `${doneCount}/${totalCount} tasks completed`;
|
|
62
|
-
// Build plan text
|
|
63
|
-
const plan = [title, "", ...lines, "", summary].join("\n");
|
|
64
|
-
return jsonResult({ plan, summary, tasks });
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Tool Bridge: Converts MCP tool definitions to AgentTool instances.
|
|
3
|
-
*
|
|
4
|
-
* Follows the pattern established by skill-tool-bridge.ts for converting
|
|
5
|
-
* external tool definitions into the AgentTool format expected by the
|
|
6
|
-
* agent executor (pi-agent-core).
|
|
7
|
-
*
|
|
8
|
-
* Key functions:
|
|
9
|
-
* - mcpToolsToAgentTools: Batch convert MCP tools to AgentTool[]
|
|
10
|
-
* - jsonSchemaToTypeBox: Basic JSON Schema -> TypeBox conversion
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
|
-
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
15
|
-
import { type TSchema } from "@sinclair/typebox";
|
|
16
|
-
import { type ToolSourceProfile } from "../builtin/tool-source-profiles.js";
|
|
17
|
-
import type { McpToolDefinition, McpClientManager } from "./mcp-client.js";
|
|
18
|
-
/**
|
|
19
|
-
* Extract the MCP server name from a sanitized tool name.
|
|
20
|
-
*
|
|
21
|
-
* Sanitized MCP tool names use the format `mcp__serverName--toolName`.
|
|
22
|
-
* Returns `undefined` for non-MCP tools or malformed names.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* extractMcpServerName("mcp__context7--resolve-library-id") // "context7"
|
|
26
|
-
* extractMcpServerName("mcp__srv__v2--ns--tool") // "srv__v2"
|
|
27
|
-
* extractMcpServerName("bash") // undefined
|
|
28
|
-
*/
|
|
29
|
-
export declare function extractMcpServerName(toolName: string): string | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Classify an MCP error message into a category for observability.
|
|
32
|
-
*
|
|
33
|
-
* Returns one of: "timeout", "connection", "tool_error", "transport", "unknown".
|
|
34
|
-
*/
|
|
35
|
-
export declare function classifyMcpErrorType(errorText: string | undefined): string;
|
|
36
|
-
/**
|
|
37
|
-
* Convert a basic JSON Schema definition to a TypeBox TSchema.
|
|
38
|
-
*
|
|
39
|
-
* Handles primitive types, arrays, and objects. Complex schema features
|
|
40
|
-
* (oneOf, allOf, $ref, etc.) fall back to Type.Any().
|
|
41
|
-
*
|
|
42
|
-
* This is intentionally simple -- MCP tool schemas are typically flat
|
|
43
|
-
* objects with primitive properties. Complex schemas still work but
|
|
44
|
-
* lose TypeBox-level validation detail.
|
|
45
|
-
*/
|
|
46
|
-
export declare function jsonSchemaToTypeBox(schema: Record<string, unknown>): TSchema;
|
|
47
|
-
/** Maximum characters for LLM-facing MCP tool descriptions. */
|
|
48
|
-
export declare const MAX_LLM_DESCRIPTION_CHARS = 2048;
|
|
49
|
-
/**
|
|
50
|
-
* Sanitize a qualified MCP tool name for use as an LLM API tool name.
|
|
51
|
-
*
|
|
52
|
-
* LLM APIs (Anthropic, OpenAI) require tool names to match `^[a-zA-Z0-9_-]{1,128}$`.
|
|
53
|
-
* Qualified names like "mcp:context7/resolve-library-id" contain invalid characters
|
|
54
|
-
* (`:`, `/`). This function replaces them: "mcp:" -> "mcp__", "/" -> "--".
|
|
55
|
-
*
|
|
56
|
-
* Example: "mcp:context7/resolve-library-id" -> "mcp__context7--resolve-library-id"
|
|
57
|
-
*/
|
|
58
|
-
export declare function sanitizeMcpToolName(qualifiedName: string): string;
|
|
59
|
-
/**
|
|
60
|
-
* Convert an array of MCP tool definitions to AgentTool instances.
|
|
61
|
-
*
|
|
62
|
-
* Each AgentTool's execute() delegates to the provided callTool function,
|
|
63
|
-
* which dispatches to the correct MCP server connection. Error results
|
|
64
|
-
* from the MCP server are returned as text content (not thrown), matching
|
|
65
|
-
* the AgentTool contract.
|
|
66
|
-
*
|
|
67
|
-
* Successful results are capped to the resolved source profile's maxChars
|
|
68
|
-
* limit, preventing oversized MCP responses from consuming agent context.
|
|
69
|
-
*
|
|
70
|
-
* @param tools - MCP tool definitions from McpClientManager.getTools()
|
|
71
|
-
* @param callTool - McpClientManager.callTool bound function
|
|
72
|
-
* @param toolSourceProfiles - Optional per-tool overrides for source profiles
|
|
73
|
-
* @returns AgentTool instances ready for the agent executor
|
|
74
|
-
*/
|
|
75
|
-
export declare function mcpToolsToAgentTools(tools: McpToolDefinition[], callTool: McpClientManager["callTool"], toolSourceProfiles?: Record<string, Partial<ToolSourceProfile>>): AgentTool<any>[];
|