comisai 1.0.19 → 1.0.22
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/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 +0 -0
- 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/package.json +1 -1
- package/node_modules/@comis/gateway/package.json +1 -1
- 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/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,125 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-tool output schemas (Phase 568: SCHEMA-01 through SCHEMA-05).
|
|
3
|
-
*
|
|
4
|
-
* Registers outputSchema for 6 priority tools to describe their actual output
|
|
5
|
-
* format. Schemas are informational only -- delivered to the LLM via JIT guide
|
|
6
|
-
* injection to help predict result structure. Never validated at runtime.
|
|
7
|
-
*
|
|
8
|
-
* - grep, find: Text output (type: "string") -- NOT JSON
|
|
9
|
-
* - exec, memory_search, web_search, sessions_list: JSON output (type: "object")
|
|
10
|
-
*
|
|
11
|
-
* Import this module for side effects only -- it runs registerToolMetadata()
|
|
12
|
-
* calls at module scope. Imported from tool-bridge.ts to ensure schemas are
|
|
13
|
-
* registered before assembleToolPipeline() runs.
|
|
14
|
-
*
|
|
15
|
-
* @module
|
|
16
|
-
*/
|
|
17
|
-
import { registerToolMetadata } from "@comis/core";
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
// Text-output tools (pi-coding-agent, post-processed wrappers)
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
|
-
registerToolMetadata("grep", {
|
|
22
|
-
outputSchema: {
|
|
23
|
-
type: "string",
|
|
24
|
-
description: "Text output (not JSON). Default mode: `filepath:linenum: content` per line. " +
|
|
25
|
-
"files_with_matches mode: one filepath per line. " +
|
|
26
|
-
"count mode: `filepath: N matches` per line, sorted descending. " +
|
|
27
|
-
"Trailing `[...]` notices indicate truncation or limits.",
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
registerToolMetadata("find", {
|
|
31
|
-
outputSchema: {
|
|
32
|
-
type: "string",
|
|
33
|
-
description: "Text output (not JSON). Newline-separated file paths sorted by modification time (most recent first). " +
|
|
34
|
-
"Paths relative to workspace root. Trailing `[...]` notices for truncation.",
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
// ---------------------------------------------------------------------------
|
|
38
|
-
// JSON-output tools (jsonResult() or JSON.stringify)
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
40
|
-
registerToolMetadata("exec", {
|
|
41
|
-
outputSchema: {
|
|
42
|
-
type: "object",
|
|
43
|
-
description: "Shell command execution result",
|
|
44
|
-
properties: {
|
|
45
|
-
exitCode: { type: "number", description: "0 = success, 124 = timeout" },
|
|
46
|
-
stdout: { type: "string", description: "Standard output" },
|
|
47
|
-
stderr: { type: "string", description: "Standard error" },
|
|
48
|
-
description: { type: "string", description: "User-provided command label" },
|
|
49
|
-
truncated: { type: "boolean", description: "True when output exceeded buffer" },
|
|
50
|
-
fullOutputPath: { type: "string", description: "Path to full output on disk" },
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
registerToolMetadata("memory_search", {
|
|
55
|
-
outputSchema: {
|
|
56
|
-
type: "object",
|
|
57
|
-
description: "Memory search results",
|
|
58
|
-
properties: {
|
|
59
|
-
results: {
|
|
60
|
-
type: "array",
|
|
61
|
-
description: "Matching entries (content max 500 chars each)",
|
|
62
|
-
items: {
|
|
63
|
-
type: "object",
|
|
64
|
-
properties: {
|
|
65
|
-
id: { type: "string" },
|
|
66
|
-
content: { type: "string" },
|
|
67
|
-
score: { type: "number" },
|
|
68
|
-
tags: { type: "array", items: { type: "string" } },
|
|
69
|
-
createdAt: { type: "number", description: "Epoch ms" },
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
registerToolMetadata("web_search", {
|
|
77
|
-
outputSchema: {
|
|
78
|
-
type: "object",
|
|
79
|
-
description: "Web search results. List-based providers (Brave/Tavily) return results[]. " +
|
|
80
|
-
"Perplexity/Grok return { content, citations } instead.",
|
|
81
|
-
properties: {
|
|
82
|
-
query: { type: "string" },
|
|
83
|
-
provider: { type: "string" },
|
|
84
|
-
tookMs: { type: "number" },
|
|
85
|
-
results: {
|
|
86
|
-
type: "array",
|
|
87
|
-
description: "List-based provider results",
|
|
88
|
-
items: {
|
|
89
|
-
type: "object",
|
|
90
|
-
properties: {
|
|
91
|
-
title: { type: "string" },
|
|
92
|
-
url: { type: "string" },
|
|
93
|
-
description: { type: "string" },
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
registerToolMetadata("sessions_list", {
|
|
101
|
-
outputSchema: {
|
|
102
|
-
type: "object",
|
|
103
|
-
description: "Active sessions listing",
|
|
104
|
-
properties: {
|
|
105
|
-
sessions: {
|
|
106
|
-
type: "array",
|
|
107
|
-
items: {
|
|
108
|
-
type: "object",
|
|
109
|
-
properties: {
|
|
110
|
-
sessionKey: { type: "string" },
|
|
111
|
-
agentId: { type: "string" },
|
|
112
|
-
userId: { type: "string" },
|
|
113
|
-
channelId: { type: "string" },
|
|
114
|
-
kind: { type: "string" },
|
|
115
|
-
messageCount: { type: "number" },
|
|
116
|
-
totalTokens: { type: "number" },
|
|
117
|
-
updatedAt: { type: "number" },
|
|
118
|
-
createdAt: { type: "number" },
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
total: { type: "number", description: "Total session count" },
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-tool parallelism metadata (Phase 565: PAR-04).
|
|
3
|
-
*
|
|
4
|
-
* Registers isReadOnly and isConcurrencySafe for all 51 built-in tools.
|
|
5
|
-
* Uses merge semantics so Phase 564 maxResultSizeChars entries are preserved
|
|
6
|
-
* when this module registers additional fields for the same tools.
|
|
7
|
-
*
|
|
8
|
-
* Import this module for side effects only -- it runs registerToolMetadata()
|
|
9
|
-
* calls at module scope. Imported from tool-bridge.ts to ensure parallelism
|
|
10
|
-
* metadata is registered before assembleToolPipeline() runs.
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
|
-
export {};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-tool parallelism metadata (Phase 565: PAR-04).
|
|
3
|
-
*
|
|
4
|
-
* Registers isReadOnly and isConcurrencySafe for all 51 built-in tools.
|
|
5
|
-
* Uses merge semantics so Phase 564 maxResultSizeChars entries are preserved
|
|
6
|
-
* when this module registers additional fields for the same tools.
|
|
7
|
-
*
|
|
8
|
-
* Import this module for side effects only -- it runs registerToolMetadata()
|
|
9
|
-
* calls at module scope. Imported from tool-bridge.ts to ensure parallelism
|
|
10
|
-
* metadata is registered before assembleToolPipeline() runs.
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
|
-
import { registerToolMetadata } from "@comis/core";
|
|
15
|
-
// ===========================================================================
|
|
16
|
-
// Read-only tools (25) -- { isReadOnly: true }
|
|
17
|
-
// Safe for optimistic parallel execution with other read-only tools.
|
|
18
|
-
// ===========================================================================
|
|
19
|
-
// --- File system reads ---
|
|
20
|
-
registerToolMetadata("read", { isReadOnly: true });
|
|
21
|
-
registerToolMetadata("grep", { isReadOnly: true, searchHint: "search file contents with regex pattern ripgrep" });
|
|
22
|
-
registerToolMetadata("find", { isReadOnly: true });
|
|
23
|
-
registerToolMetadata("ls", { isReadOnly: true });
|
|
24
|
-
// --- Web reads ---
|
|
25
|
-
registerToolMetadata("web_search", { isReadOnly: true });
|
|
26
|
-
registerToolMetadata("web_fetch", { isReadOnly: true });
|
|
27
|
-
registerToolMetadata("browser", { isReadOnly: true });
|
|
28
|
-
// --- Memory/session reads ---
|
|
29
|
-
registerToolMetadata("memory_search", { isReadOnly: true });
|
|
30
|
-
registerToolMetadata("memory_get", { isReadOnly: true });
|
|
31
|
-
registerToolMetadata("session_search", { isReadOnly: true });
|
|
32
|
-
// --- Session reads ---
|
|
33
|
-
registerToolMetadata("sessions_list", { isReadOnly: true });
|
|
34
|
-
registerToolMetadata("session_status", { isReadOnly: true });
|
|
35
|
-
registerToolMetadata("sessions_history", { isReadOnly: true });
|
|
36
|
-
registerToolMetadata("agents_list", { isReadOnly: true });
|
|
37
|
-
// --- Context reads ---
|
|
38
|
-
registerToolMetadata("ctx_search", { isReadOnly: true });
|
|
39
|
-
registerToolMetadata("ctx_inspect", { isReadOnly: true });
|
|
40
|
-
registerToolMetadata("ctx_expand", { isReadOnly: true });
|
|
41
|
-
registerToolMetadata("ctx_recall", { isReadOnly: true });
|
|
42
|
-
// --- Media analysis ---
|
|
43
|
-
registerToolMetadata("image_analyze", { isReadOnly: true });
|
|
44
|
-
registerToolMetadata("describe_video", { isReadOnly: true });
|
|
45
|
-
registerToolMetadata("extract_document", { isReadOnly: true });
|
|
46
|
-
registerToolMetadata("transcribe_audio", { isReadOnly: true });
|
|
47
|
-
// --- Platform reads ---
|
|
48
|
-
registerToolMetadata("obs_query", { isReadOnly: true });
|
|
49
|
-
registerToolMetadata("models_manage", { isReadOnly: true });
|
|
50
|
-
// --- Discovery ---
|
|
51
|
-
registerToolMetadata("discover_tools", { isReadOnly: true });
|
|
52
|
-
// ===========================================================================
|
|
53
|
-
// Mutating tools (25) -- { isReadOnly: false }
|
|
54
|
-
// Must not be executed in parallel with other mutating tools.
|
|
55
|
-
// ===========================================================================
|
|
56
|
-
// --- File writes ---
|
|
57
|
-
registerToolMetadata("edit", { isReadOnly: false });
|
|
58
|
-
registerToolMetadata("write", { isReadOnly: false });
|
|
59
|
-
registerToolMetadata("apply_patch", { isReadOnly: false });
|
|
60
|
-
// --- Exec/process ---
|
|
61
|
-
registerToolMetadata("exec", { isReadOnly: false });
|
|
62
|
-
registerToolMetadata("process", { isReadOnly: false });
|
|
63
|
-
// --- Memory writes ---
|
|
64
|
-
registerToolMetadata("memory_store", { isReadOnly: false });
|
|
65
|
-
registerToolMetadata("memory_manage", { isReadOnly: false });
|
|
66
|
-
// --- Session management ---
|
|
67
|
-
registerToolMetadata("sessions_manage", { isReadOnly: false });
|
|
68
|
-
registerToolMetadata("sessions_send", { isReadOnly: false });
|
|
69
|
-
registerToolMetadata("sessions_spawn", { isReadOnly: false });
|
|
70
|
-
registerToolMetadata("subagents", { isReadOnly: false });
|
|
71
|
-
// --- Platform management ---
|
|
72
|
-
registerToolMetadata("pipeline", { isReadOnly: false });
|
|
73
|
-
registerToolMetadata("cron", { isReadOnly: false });
|
|
74
|
-
registerToolMetadata("gateway", { isReadOnly: false });
|
|
75
|
-
registerToolMetadata("heartbeat_manage", { isReadOnly: false });
|
|
76
|
-
registerToolMetadata("channels_manage", { isReadOnly: false });
|
|
77
|
-
registerToolMetadata("tokens_manage", { isReadOnly: false });
|
|
78
|
-
registerToolMetadata("skills_manage", { isReadOnly: false });
|
|
79
|
-
registerToolMetadata("mcp_manage", { isReadOnly: false });
|
|
80
|
-
registerToolMetadata("agents_manage", { isReadOnly: false });
|
|
81
|
-
// --- Channel actions ---
|
|
82
|
-
registerToolMetadata("whatsapp_action", { isReadOnly: false });
|
|
83
|
-
registerToolMetadata("discord_action", { isReadOnly: false });
|
|
84
|
-
registerToolMetadata("telegram_action", { isReadOnly: false });
|
|
85
|
-
registerToolMetadata("slack_action", { isReadOnly: false });
|
|
86
|
-
// --- Media generation ---
|
|
87
|
-
registerToolMetadata("tts_synthesize", { isReadOnly: false });
|
|
88
|
-
// ===========================================================================
|
|
89
|
-
// Concurrency-safe mutating tool (1) -- { isReadOnly: false, isConcurrencySafe: true }
|
|
90
|
-
// Sends to independent channels with no ordering dependencies.
|
|
91
|
-
// ===========================================================================
|
|
92
|
-
registerToolMetadata("message", { isReadOnly: false, isConcurrencySafe: true });
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-tool result size caps (Phase 564: TRUNC-02).
|
|
3
|
-
*
|
|
4
|
-
* Registers maxResultSizeChars for tools that can produce large text output.
|
|
5
|
-
* Values are calibrated per TRUNC-03 to avoid triple truncation stacking
|
|
6
|
-
* with the per-tool bouncer (default 50K) and turn budget (200K aggregate).
|
|
7
|
-
*
|
|
8
|
-
* Import this module for side effects only -- it runs registerToolMetadata()
|
|
9
|
-
* calls at module scope. Imported from tool-bridge.ts to ensure caps are
|
|
10
|
-
* registered before assembleToolPipeline() runs.
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Per-tool result size caps (Phase 564: TRUNC-02).
|
|
3
|
-
*
|
|
4
|
-
* Registers maxResultSizeChars for tools that can produce large text output.
|
|
5
|
-
* Values are calibrated per TRUNC-03 to avoid triple truncation stacking
|
|
6
|
-
* with the per-tool bouncer (default 50K) and turn budget (200K aggregate).
|
|
7
|
-
*
|
|
8
|
-
* Import this module for side effects only -- it runs registerToolMetadata()
|
|
9
|
-
* calls at module scope. Imported from tool-bridge.ts to ensure caps are
|
|
10
|
-
* registered before assembleToolPipeline() runs.
|
|
11
|
-
*
|
|
12
|
-
* @module
|
|
13
|
-
*/
|
|
14
|
-
import { registerToolMetadata } from "@comis/core";
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// File tools (from @mariozechner/pi-coding-agent via createComisFileTools)
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
registerToolMetadata("grep", { maxResultSizeChars: 100_000 });
|
|
19
|
-
registerToolMetadata("read", { maxResultSizeChars: 200_000 });
|
|
20
|
-
registerToolMetadata("find", { maxResultSizeChars: 50_000 });
|
|
21
|
-
registerToolMetadata("ls", { maxResultSizeChars: 20_000 });
|
|
22
|
-
// ---------------------------------------------------------------------------
|
|
23
|
-
// Exec tool
|
|
24
|
-
// ---------------------------------------------------------------------------
|
|
25
|
-
registerToolMetadata("exec", { maxResultSizeChars: 100_000 });
|
|
26
|
-
// ---------------------------------------------------------------------------
|
|
27
|
-
// Web tools
|
|
28
|
-
// ---------------------------------------------------------------------------
|
|
29
|
-
registerToolMetadata("web_fetch", { maxResultSizeChars: 150_000 });
|
|
30
|
-
registerToolMetadata("web_search", { maxResultSizeChars: 50_000 });
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
// Platform tools (RPC-based, created in daemon wiring)
|
|
33
|
-
// ---------------------------------------------------------------------------
|
|
34
|
-
registerToolMetadata("sessions_history", { maxResultSizeChars: 100_000 });
|
|
35
|
-
registerToolMetadata("obs_query", { maxResultSizeChars: 100_000 });
|
|
36
|
-
registerToolMetadata("memory_search", { maxResultSizeChars: 50_000 });
|
|
@@ -1,15 +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
|
-
export {};
|
|
@@ -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>;
|