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,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delivery queue wiring: adapter creation, startup drain, periodic prune.
|
|
3
|
-
*
|
|
4
|
-
* Two-phase lifecycle resolves the circular dependency between the queue and
|
|
5
|
-
* channel adapters:
|
|
6
|
-
* 1. setupDeliveryQueue() creates the adapter immediately (before setupChannels).
|
|
7
|
-
* 2. drainAndStartPrune() runs drain + starts prune timer AFTER setupChannels
|
|
8
|
-
* populates channelAdapters.
|
|
9
|
-
*
|
|
10
|
-
* Phase 499: Crash-Safe Delivery Queue.
|
|
11
|
-
* @module
|
|
12
|
-
*/
|
|
13
|
-
import { createNoOpDeliveryQueue } from "@comis/core";
|
|
14
|
-
import { createSqliteDeliveryQueue } from "@comis/memory";
|
|
15
|
-
import { isPermanentError, computeQueueBackoff } from "@comis/channels";
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
// Setup function
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
export async function setupDeliveryQueue(deps) {
|
|
20
|
-
const { db, config, eventBus, logger, channelAdapters } = deps;
|
|
21
|
-
const queueConfig = config.deliveryQueue;
|
|
22
|
-
// 1. Adapter creation: no-op when disabled
|
|
23
|
-
if (!queueConfig.enabled) {
|
|
24
|
-
logger.debug("Delivery queue disabled by config");
|
|
25
|
-
return {
|
|
26
|
-
deliveryQueue: createNoOpDeliveryQueue(),
|
|
27
|
-
drainAndStartPrune: async () => { },
|
|
28
|
-
shutdown: () => { },
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- db is better-sqlite3 Database; typed as unknown to avoid cross-package type dependency
|
|
32
|
-
const deliveryQueue = createSqliteDeliveryQueue(db);
|
|
33
|
-
logger.info({ maxQueueDepth: queueConfig.maxQueueDepth, defaultMaxAttempts: queueConfig.defaultMaxAttempts }, "Delivery queue enabled");
|
|
34
|
-
let pruneInterval;
|
|
35
|
-
// 2. Startup drain + 3. Periodic prune (deferred until channelAdapters populated)
|
|
36
|
-
const drainAndStartPrune = async () => {
|
|
37
|
-
// --- Drain ---
|
|
38
|
-
if (queueConfig.drainOnStartup) {
|
|
39
|
-
await drainDeliveryQueue({
|
|
40
|
-
deliveryQueue,
|
|
41
|
-
channelAdapters,
|
|
42
|
-
eventBus,
|
|
43
|
-
logger,
|
|
44
|
-
drainBudgetMs: queueConfig.drainBudgetMs,
|
|
45
|
-
defaultMaxAttempts: queueConfig.defaultMaxAttempts,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
// --- Prune timer ---
|
|
49
|
-
pruneInterval = setInterval(async () => {
|
|
50
|
-
const result = await deliveryQueue.pruneExpired();
|
|
51
|
-
if (result.ok && result.value > 0) {
|
|
52
|
-
logger.debug({ pruned: result.value }, "Delivery queue pruned");
|
|
53
|
-
}
|
|
54
|
-
}, queueConfig.pruneIntervalMs);
|
|
55
|
-
pruneInterval.unref();
|
|
56
|
-
};
|
|
57
|
-
const shutdown = () => {
|
|
58
|
-
if (pruneInterval) {
|
|
59
|
-
clearInterval(pruneInterval);
|
|
60
|
-
pruneInterval = undefined;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
return { deliveryQueue, drainAndStartPrune, shutdown };
|
|
64
|
-
}
|
|
65
|
-
// ---------------------------------------------------------------------------
|
|
66
|
-
// Drain implementation
|
|
67
|
-
// ---------------------------------------------------------------------------
|
|
68
|
-
async function drainDeliveryQueue(deps) {
|
|
69
|
-
const { deliveryQueue, channelAdapters, eventBus, logger, drainBudgetMs, defaultMaxAttempts } = deps;
|
|
70
|
-
const drainStart = Date.now();
|
|
71
|
-
const deadline = drainStart + drainBudgetMs;
|
|
72
|
-
const pendingResult = await deliveryQueue.pendingEntries();
|
|
73
|
-
if (!pendingResult.ok) {
|
|
74
|
-
logger.warn({ err: pendingResult.error, hint: "Could not fetch pending entries for drain cycle", errorKind: "internal" }, "Delivery queue drain: failed to fetch pending entries");
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const entries = pendingResult.value;
|
|
78
|
-
if (entries.length === 0) {
|
|
79
|
-
logger.debug("Delivery queue drain: no pending entries");
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
let attempted = 0;
|
|
83
|
-
let delivered = 0;
|
|
84
|
-
let failed = 0;
|
|
85
|
-
for (const entry of entries) {
|
|
86
|
-
// Budget exhaustion check
|
|
87
|
-
if (Date.now() > deadline) {
|
|
88
|
-
logger.info({ budgetMs: drainBudgetMs, attempted, remaining: entries.length - attempted }, "Delivery queue drain: budget exhausted");
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
attempted++;
|
|
92
|
-
const adapter = channelAdapters.get(entry.channelType);
|
|
93
|
-
if (!adapter) {
|
|
94
|
-
await deliveryQueue.fail(entry.id, `No adapter for channel type: ${entry.channelType}`);
|
|
95
|
-
failed++;
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
let options = {};
|
|
99
|
-
try {
|
|
100
|
-
options = JSON.parse(entry.optionsJson);
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
// Invalid JSON -- send without options
|
|
104
|
-
}
|
|
105
|
-
const sendResult = await adapter.sendMessage(entry.channelId, entry.text, options);
|
|
106
|
-
if (sendResult.ok) {
|
|
107
|
-
await deliveryQueue.ack(entry.id, sendResult.value);
|
|
108
|
-
delivered++;
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
const errorMsg = sendResult.error.message;
|
|
112
|
-
if (isPermanentError(errorMsg) || entry.attemptCount >= (entry.maxAttempts || defaultMaxAttempts)) {
|
|
113
|
-
await deliveryQueue.fail(entry.id, errorMsg);
|
|
114
|
-
failed++;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
const nextRetryAt = Date.now() + computeQueueBackoff(entry.attemptCount);
|
|
118
|
-
await deliveryQueue.nack(entry.id, errorMsg, nextRetryAt);
|
|
119
|
-
failed++;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
const durationMs = Date.now() - drainStart;
|
|
124
|
-
eventBus.emit("delivery:queue_drained", {
|
|
125
|
-
entriesAttempted: attempted,
|
|
126
|
-
entriesDelivered: delivered,
|
|
127
|
-
entriesFailed: failed,
|
|
128
|
-
durationMs,
|
|
129
|
-
timestamp: Date.now(),
|
|
130
|
-
});
|
|
131
|
-
logger.info({ entriesAttempted: attempted, entriesDelivered: delivered, entriesFailed: failed, durationMs }, "Delivery queue drained");
|
|
132
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Monitoring setup: heartbeat runner with configurable monitoring sources.
|
|
3
|
-
*
|
|
4
|
-
* Extracted from daemon.ts step 6.7 to isolate heartbeat/monitoring
|
|
5
|
-
* initialization from the main wiring sequence.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
import type { AppContainer, ChannelPort } from "@comis/core";
|
|
10
|
-
import type { ComisLogger } from "@comis/infra";
|
|
11
|
-
import { type HeartbeatRunner, type DuplicateDetector } from "@comis/scheduler";
|
|
12
|
-
/** Dependencies for monitoring setup. */
|
|
13
|
-
export interface MonitoringDeps {
|
|
14
|
-
/** Bootstrap output (config.monitoring, config.scheduler, eventBus). */
|
|
15
|
-
container: AppContainer;
|
|
16
|
-
/** Module-bound logger for scheduler subsystem. */
|
|
17
|
-
schedulerLogger: ComisLogger;
|
|
18
|
-
/** Root logger for notification callbacks. */
|
|
19
|
-
logger: ComisLogger;
|
|
20
|
-
/** Channel adapters for heartbeat delivery (optional -- delivery skipped if not provided). */
|
|
21
|
-
adaptersByType?: ReadonlyMap<string, ChannelPort>;
|
|
22
|
-
}
|
|
23
|
-
/** All services produced by the monitoring setup phase. */
|
|
24
|
-
export interface MonitoringResult {
|
|
25
|
-
/** Heartbeat runner for periodic health checks (optional). */
|
|
26
|
-
heartbeatRunner?: HeartbeatRunner;
|
|
27
|
-
/** Duplicate detector shared between global and per-agent heartbeat delivery. */
|
|
28
|
-
duplicateDetector?: DuplicateDetector;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Create monitoring heartbeat sources and runner based on config toggles.
|
|
32
|
-
*
|
|
33
|
-
* Synchronous setup -- creates sources array, builds runner if any are
|
|
34
|
-
* enabled, starts the runner, and returns the handle.
|
|
35
|
-
*
|
|
36
|
-
* @param deps - Monitoring dependencies
|
|
37
|
-
*/
|
|
38
|
-
export declare function setupMonitoring(deps: MonitoringDeps): MonitoringResult;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Monitoring setup: heartbeat runner with configurable monitoring sources.
|
|
3
|
-
*
|
|
4
|
-
* Extracted from daemon.ts step 6.7 to isolate heartbeat/monitoring
|
|
5
|
-
* initialization from the main wiring sequence.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
import { createHeartbeatRunner, createDuplicateDetector, deliverHeartbeatNotification, } from "@comis/scheduler";
|
|
10
|
-
import { createDiskSpaceSource, createSystemResourcesSource, createSystemdServiceSource, createSecurityUpdateSource, createGitWatcherSource, } from "../monitoring/index.js";
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
// Setup function
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
/**
|
|
15
|
-
* Create monitoring heartbeat sources and runner based on config toggles.
|
|
16
|
-
*
|
|
17
|
-
* Synchronous setup -- creates sources array, builds runner if any are
|
|
18
|
-
* enabled, starts the runner, and returns the handle.
|
|
19
|
-
*
|
|
20
|
-
* @param deps - Monitoring dependencies
|
|
21
|
-
*/
|
|
22
|
-
export function setupMonitoring(deps) {
|
|
23
|
-
const { container, schedulerLogger, logger, adaptersByType } = deps;
|
|
24
|
-
let heartbeatRunner;
|
|
25
|
-
const monitoringConfig = container.config.monitoring;
|
|
26
|
-
const schedulerConfig = container.config.scheduler;
|
|
27
|
-
const monitoringSources = [];
|
|
28
|
-
// Create shared duplicate detector for 24h dedup (DLVR-07)
|
|
29
|
-
const duplicateDetector = createDuplicateDetector();
|
|
30
|
-
if (monitoringConfig.disk.enabled) {
|
|
31
|
-
monitoringSources.push(createDiskSpaceSource(monitoringConfig.disk));
|
|
32
|
-
}
|
|
33
|
-
if (monitoringConfig.resources.enabled) {
|
|
34
|
-
monitoringSources.push(createSystemResourcesSource(monitoringConfig.resources));
|
|
35
|
-
}
|
|
36
|
-
if (monitoringConfig.systemd.enabled) {
|
|
37
|
-
monitoringSources.push(createSystemdServiceSource(monitoringConfig.systemd));
|
|
38
|
-
}
|
|
39
|
-
if (monitoringConfig.securityUpdates.enabled) {
|
|
40
|
-
monitoringSources.push(createSecurityUpdateSource(monitoringConfig.securityUpdates));
|
|
41
|
-
}
|
|
42
|
-
if (monitoringConfig.git.enabled) {
|
|
43
|
-
monitoringSources.push(createGitWatcherSource(monitoringConfig.git));
|
|
44
|
-
}
|
|
45
|
-
if (monitoringSources.length > 0) {
|
|
46
|
-
heartbeatRunner = createHeartbeatRunner({
|
|
47
|
-
sources: monitoringSources,
|
|
48
|
-
eventBus: container.eventBus,
|
|
49
|
-
logger: schedulerLogger,
|
|
50
|
-
config: {
|
|
51
|
-
intervalMs: schedulerConfig.heartbeat.intervalMs,
|
|
52
|
-
showOk: schedulerConfig.heartbeat.showOk,
|
|
53
|
-
showAlerts: schedulerConfig.heartbeat.showAlerts,
|
|
54
|
-
},
|
|
55
|
-
quietHoursConfig: schedulerConfig.quietHours,
|
|
56
|
-
criticalBypass: schedulerConfig.quietHours.criticalBypass,
|
|
57
|
-
onNotification: (notification) => {
|
|
58
|
-
const msg = `Monitoring: ${notification.text}`;
|
|
59
|
-
if (notification.level === "critical") {
|
|
60
|
-
logger.error({ sourceId: notification.sourceId, level: notification.level, hint: "Investigate the monitoring source for critical conditions", errorKind: "resource" }, msg);
|
|
61
|
-
}
|
|
62
|
-
else if (notification.level === "alert") {
|
|
63
|
-
logger.warn({ sourceId: notification.sourceId, level: notification.level, hint: "Review the monitoring source alert details", errorKind: "resource" }, msg);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
logger.info({ sourceId: notification.sourceId, level: notification.level }, msg);
|
|
67
|
-
}
|
|
68
|
-
// Deliver to configured target channel (fire-and-forget)
|
|
69
|
-
// Global heartbeat uses scheduler.heartbeat config -- per-agent delivery targets are wired in Phase 329.
|
|
70
|
-
if (adaptersByType && adaptersByType.size > 0) {
|
|
71
|
-
const globalTarget = resolveGlobalDeliveryTarget(container.config);
|
|
72
|
-
if (globalTarget) {
|
|
73
|
-
void deliverHeartbeatNotification({ adaptersByType, duplicateDetector, eventBus: container.eventBus, logger: schedulerLogger }, globalTarget, notification, { agentId: "system" }).catch((err) => {
|
|
74
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
75
|
-
schedulerLogger.warn({ err: errMsg, hint: "Heartbeat delivery failed unexpectedly", errorKind: "internal" }, "Heartbeat delivery error");
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
heartbeatRunner.start();
|
|
82
|
-
schedulerLogger.info({ sourceCount: monitoringSources.length }, "Monitoring heartbeat runner started");
|
|
83
|
-
}
|
|
84
|
-
return { heartbeatRunner, duplicateDetector };
|
|
85
|
-
}
|
|
86
|
-
// ---------------------------------------------------------------------------
|
|
87
|
-
// Helpers
|
|
88
|
-
// ---------------------------------------------------------------------------
|
|
89
|
-
/**
|
|
90
|
-
* Resolve global heartbeat delivery target from config.
|
|
91
|
-
*
|
|
92
|
-
* Currently returns undefined -- global system monitoring does not have a
|
|
93
|
-
* delivery target. Per-agent delivery is handled by PerAgentHeartbeatRunner
|
|
94
|
-
* (Phase 329). This function exists so that adding a global delivery target
|
|
95
|
-
* in a future phase is a one-line change.
|
|
96
|
-
*/
|
|
97
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
98
|
-
function resolveGlobalDeliveryTarget(_config) {
|
|
99
|
-
return undefined;
|
|
100
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RPC bridge setup: rpcCall outer wrapper with deferred dispatch wiring.
|
|
3
|
-
*
|
|
4
|
-
* Extracted from daemon.ts to isolate the rpcCall closure pattern (debug/error
|
|
5
|
-
* logging, classifyRpcError) and the deferred rpcCallInner assignment. The
|
|
6
|
-
* rpcCall function is needed by setupTools (early in the boot sequence), but
|
|
7
|
-
* rpcCallInner depends on heartbeatRunner from setupMonitoring (later in the
|
|
8
|
-
* sequence). This module encapsulates the deferred wiring via wireDispatch().
|
|
9
|
-
*
|
|
10
|
-
* @module
|
|
11
|
-
*/
|
|
12
|
-
import type { ComisLogger } from "@comis/infra";
|
|
13
|
-
import type { RpcCall } from "@comis/skills";
|
|
14
|
-
import type { RpcDispatchDeps } from "../rpc/rpc-dispatch.js";
|
|
15
|
-
/** All services produced by the RPC bridge setup phase. */
|
|
16
|
-
export interface RpcBridgeResult {
|
|
17
|
-
/** The rpcCall function usable immediately (delegates to inner dispatch once wired). */
|
|
18
|
-
rpcCall: RpcCall;
|
|
19
|
-
/** Call after setupMonitoring to wire the real dispatch with all deps including heartbeatRunner. */
|
|
20
|
-
wireDispatch: (deps: RpcDispatchDeps) => void;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Create the rpcCall wrapper and deferred dispatch mechanism.
|
|
24
|
-
*
|
|
25
|
-
* The returned rpcCall can be passed to setupTools immediately. After
|
|
26
|
-
* setupMonitoring resolves the heartbeatRunner TDZ, call wireDispatch()
|
|
27
|
-
* with the full RpcDispatchDeps to wire the real dispatch function.
|
|
28
|
-
*
|
|
29
|
-
* @param deps.gatewayLogger - Logger for RPC call tracing
|
|
30
|
-
* @returns rpcCall function and wireDispatch callback
|
|
31
|
-
*/
|
|
32
|
-
export declare function setupRpcBridge(deps: {
|
|
33
|
-
gatewayLogger: ComisLogger;
|
|
34
|
-
}): RpcBridgeResult;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RPC bridge setup: rpcCall outer wrapper with deferred dispatch wiring.
|
|
3
|
-
*
|
|
4
|
-
* Extracted from daemon.ts to isolate the rpcCall closure pattern (debug/error
|
|
5
|
-
* logging, classifyRpcError) and the deferred rpcCallInner assignment. The
|
|
6
|
-
* rpcCall function is needed by setupTools (early in the boot sequence), but
|
|
7
|
-
* rpcCallInner depends on heartbeatRunner from setupMonitoring (later in the
|
|
8
|
-
* sequence). This module encapsulates the deferred wiring via wireDispatch().
|
|
9
|
-
*
|
|
10
|
-
* @module
|
|
11
|
-
*/
|
|
12
|
-
import { createRpcDispatch, classifyRpcError } from "../rpc/rpc-dispatch.js";
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
// Setup function
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
/**
|
|
17
|
-
* Create the rpcCall wrapper and deferred dispatch mechanism.
|
|
18
|
-
*
|
|
19
|
-
* The returned rpcCall can be passed to setupTools immediately. After
|
|
20
|
-
* setupMonitoring resolves the heartbeatRunner TDZ, call wireDispatch()
|
|
21
|
-
* with the full RpcDispatchDeps to wire the real dispatch function.
|
|
22
|
-
*
|
|
23
|
-
* @param deps.gatewayLogger - Logger for RPC call tracing
|
|
24
|
-
* @returns rpcCall function and wireDispatch callback
|
|
25
|
-
*/
|
|
26
|
-
export function setupRpcBridge(deps) {
|
|
27
|
-
const { gatewayLogger } = deps;
|
|
28
|
-
// Deferred inner dispatch — assigned by wireDispatch() after all deps are ready
|
|
29
|
-
let rpcCallInner;
|
|
30
|
-
const rpcCall = async (method, params) => {
|
|
31
|
-
const rpcStartMs = Date.now();
|
|
32
|
-
try {
|
|
33
|
-
return await rpcCallInner(method, params);
|
|
34
|
-
}
|
|
35
|
-
catch (err) {
|
|
36
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
37
|
-
const classified = classifyRpcError(errMsg);
|
|
38
|
-
gatewayLogger.debug({
|
|
39
|
-
method,
|
|
40
|
-
err: errMsg,
|
|
41
|
-
durationMs: Date.now() - rpcStartMs,
|
|
42
|
-
hint: classified.hint,
|
|
43
|
-
errorKind: classified.errorKind,
|
|
44
|
-
}, "[rpcCall] failed");
|
|
45
|
-
throw err;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const wireDispatch = (dispatchDeps) => {
|
|
49
|
-
rpcCallInner = createRpcDispatch(dispatchDeps);
|
|
50
|
-
};
|
|
51
|
-
return { rpcCall, wireDispatch };
|
|
52
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Task extraction setup: per-agent task extractors with pluggable LLM extraction.
|
|
3
|
-
*
|
|
4
|
-
* Extracted as a wiring module following setup-monitoring.ts pattern.
|
|
5
|
-
* Task extraction runs AFTER successful agent execution, extracting
|
|
6
|
-
* commitments and follow-ups from conversation text.
|
|
7
|
-
*
|
|
8
|
-
* Feature-gated: config.scheduler.tasks.enabled (default: false).
|
|
9
|
-
*
|
|
10
|
-
* @module
|
|
11
|
-
*/
|
|
12
|
-
import type { AppContainer } from "@comis/core";
|
|
13
|
-
import type { ComisLogger } from "@comis/infra";
|
|
14
|
-
import { type TaskExtractor } from "@comis/scheduler";
|
|
15
|
-
/** Dependencies for task extraction setup. */
|
|
16
|
-
export interface TaskExtractionDeps {
|
|
17
|
-
/** Bootstrap output (config.scheduler.tasks, eventBus). */
|
|
18
|
-
container: AppContainer;
|
|
19
|
-
/** Per-agent workspace directories (from setupAgents result). */
|
|
20
|
-
workspaceDirs: Map<string, string>;
|
|
21
|
-
/** Module-bound logger for scheduler subsystem. */
|
|
22
|
-
schedulerLogger: ComisLogger;
|
|
23
|
-
}
|
|
24
|
-
/** All services produced by the task extraction setup phase. */
|
|
25
|
-
export interface TaskExtractionResult {
|
|
26
|
-
/** Per-agent task extractors (only for agents with tasks enabled). */
|
|
27
|
-
taskExtractors: Map<string, TaskExtractor>;
|
|
28
|
-
/**
|
|
29
|
-
* Callback for the execution pipeline. If task extraction is disabled
|
|
30
|
-
* for the given agent (or globally), this is a no-op.
|
|
31
|
-
*/
|
|
32
|
-
extractFromConversation: (conversationText: string, sessionKey: string, agentId: string) => Promise<void>;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create per-agent task extractors and return an extraction callback
|
|
36
|
-
* for the execution pipeline.
|
|
37
|
-
*
|
|
38
|
-
* The extraction callback is safe to call unconditionally -- it checks
|
|
39
|
-
* the feature gate internally and returns immediately if disabled.
|
|
40
|
-
*/
|
|
41
|
-
export declare function setupTaskExtraction(deps: TaskExtractionDeps): TaskExtractionResult;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Task extraction setup: per-agent task extractors with pluggable LLM extraction.
|
|
3
|
-
*
|
|
4
|
-
* Extracted as a wiring module following setup-monitoring.ts pattern.
|
|
5
|
-
* Task extraction runs AFTER successful agent execution, extracting
|
|
6
|
-
* commitments and follow-ups from conversation text.
|
|
7
|
-
*
|
|
8
|
-
* Feature-gated: config.scheduler.tasks.enabled (default: false).
|
|
9
|
-
*
|
|
10
|
-
* @module
|
|
11
|
-
*/
|
|
12
|
-
import { safePath } from "@comis/core";
|
|
13
|
-
import { createTaskExtractor, createTaskStore, } from "@comis/scheduler";
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
// Setup function
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
/**
|
|
18
|
-
* Create per-agent task extractors and return an extraction callback
|
|
19
|
-
* for the execution pipeline.
|
|
20
|
-
*
|
|
21
|
-
* The extraction callback is safe to call unconditionally -- it checks
|
|
22
|
-
* the feature gate internally and returns immediately if disabled.
|
|
23
|
-
*/
|
|
24
|
-
export function setupTaskExtraction(deps) {
|
|
25
|
-
const { container, workspaceDirs, schedulerLogger } = deps;
|
|
26
|
-
const tasksConfig = container.config.scheduler.tasks;
|
|
27
|
-
const agents = container.config.agents;
|
|
28
|
-
const taskExtractors = new Map();
|
|
29
|
-
if (!tasksConfig.enabled) {
|
|
30
|
-
schedulerLogger.debug("Task extraction disabled globally");
|
|
31
|
-
return {
|
|
32
|
-
taskExtractors,
|
|
33
|
-
extractFromConversation: async () => { },
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
for (const [agentId] of Object.entries(agents)) {
|
|
37
|
-
const agentWorkspace = workspaceDirs.get(agentId);
|
|
38
|
-
if (!agentWorkspace)
|
|
39
|
-
continue;
|
|
40
|
-
const storePath = safePath(agentWorkspace, ".scheduler", "tasks.json");
|
|
41
|
-
const store = createTaskStore(storePath);
|
|
42
|
-
// Pluggable extraction function -- in production this would wrap an LLM call.
|
|
43
|
-
// For now, create a placeholder that returns empty tasks. The daemon can
|
|
44
|
-
// override this with a real LLM-based extraction when the agent executor
|
|
45
|
-
// integration is fully wired (Phase TBD).
|
|
46
|
-
const extractFn = async () => {
|
|
47
|
-
// TODO: Wire to agent executor LLM call for real extraction
|
|
48
|
-
return { tasks: [], reasoning: "Extraction function not yet wired to LLM" };
|
|
49
|
-
};
|
|
50
|
-
const extractor = createTaskExtractor({
|
|
51
|
-
extractFn,
|
|
52
|
-
store,
|
|
53
|
-
logger: schedulerLogger.child({ agentId, component: "task-extractor" }),
|
|
54
|
-
config: {
|
|
55
|
-
enabled: tasksConfig.enabled,
|
|
56
|
-
confidenceThreshold: tasksConfig.confidenceThreshold,
|
|
57
|
-
},
|
|
58
|
-
eventBus: container.eventBus,
|
|
59
|
-
});
|
|
60
|
-
taskExtractors.set(agentId, extractor);
|
|
61
|
-
schedulerLogger.debug({ agentId }, "Task extractor created");
|
|
62
|
-
}
|
|
63
|
-
if (taskExtractors.size > 0) {
|
|
64
|
-
schedulerLogger.info({ extractorCount: taskExtractors.size }, "Task extraction enabled for agents");
|
|
65
|
-
}
|
|
66
|
-
async function extractFromConversation(conversationText, sessionKey, agentId) {
|
|
67
|
-
const extractor = taskExtractors.get(agentId);
|
|
68
|
-
if (!extractor)
|
|
69
|
-
return;
|
|
70
|
-
try {
|
|
71
|
-
const tasks = await extractor.extract(conversationText, sessionKey);
|
|
72
|
-
if (tasks.length > 0) {
|
|
73
|
-
schedulerLogger.info({ agentId, taskCount: tasks.length, sessionKey }, "Tasks extracted from conversation");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
catch (err) {
|
|
77
|
-
schedulerLogger.warn({
|
|
78
|
-
agentId,
|
|
79
|
-
err: err instanceof Error ? err.message : String(err),
|
|
80
|
-
hint: "Task extraction failed but does not block message processing",
|
|
81
|
-
errorKind: "internal",
|
|
82
|
-
}, "Task extraction error");
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return { taskExtractors, extractFromConversation };
|
|
86
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cached embedding port decorator (MEM-07).
|
|
3
|
-
*
|
|
4
|
-
* Wraps any EmbeddingPort with an LRU cache keyed by SHA-256 content
|
|
5
|
-
* hashes. Previously-seen text returns immediately without calling
|
|
6
|
-
* the inner provider. embedBatch splits texts into cache hits and
|
|
7
|
-
* misses, only calling the inner provider for misses.
|
|
8
|
-
*/
|
|
9
|
-
import type { EmbeddingPort } from "@comis/core";
|
|
10
|
-
export interface EmbeddingCacheOptions {
|
|
11
|
-
/** Maximum number of cached embeddings. Default: 10_000 */
|
|
12
|
-
maxEntries: number;
|
|
13
|
-
/** TTL in milliseconds. Default: undefined (no TTL, LRU only).
|
|
14
|
-
* Recommended: 86_400_000 (24 hours) for long-running daemons. */
|
|
15
|
-
ttlMs?: number;
|
|
16
|
-
}
|
|
17
|
-
/** Snapshot of embedding cache statistics (Phase 511). */
|
|
18
|
-
export interface EmbeddingCacheStats {
|
|
19
|
-
entries: number;
|
|
20
|
-
maxEntries: number;
|
|
21
|
-
hitRate: number;
|
|
22
|
-
hits: number;
|
|
23
|
-
misses: number;
|
|
24
|
-
provider: string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Create a cached EmbeddingPort decorator that wraps the given inner
|
|
28
|
-
* provider with an LRU content-hash cache.
|
|
29
|
-
*
|
|
30
|
-
* @param inner - The underlying EmbeddingPort to delegate cache misses to
|
|
31
|
-
* @param options - Cache configuration (maxEntries)
|
|
32
|
-
* @returns An EmbeddingPort with transparent caching
|
|
33
|
-
*/
|
|
34
|
-
export declare function createCachedEmbeddingPort(inner: EmbeddingPort, options: EmbeddingCacheOptions): EmbeddingPort & {
|
|
35
|
-
getCacheStats(): EmbeddingCacheStats;
|
|
36
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cached embedding port decorator (MEM-07).
|
|
3
|
-
*
|
|
4
|
-
* Wraps any EmbeddingPort with an LRU cache keyed by SHA-256 content
|
|
5
|
-
* hashes. Previously-seen text returns immediately without calling
|
|
6
|
-
* the inner provider. embedBatch splits texts into cache hits and
|
|
7
|
-
* misses, only calling the inner provider for misses.
|
|
8
|
-
*/
|
|
9
|
-
import { ok } from "@comis/shared";
|
|
10
|
-
import { createHash } from "node:crypto";
|
|
11
|
-
import { LRUCache } from "lru-cache";
|
|
12
|
-
/**
|
|
13
|
-
* Create a cached EmbeddingPort decorator that wraps the given inner
|
|
14
|
-
* provider with an LRU content-hash cache.
|
|
15
|
-
*
|
|
16
|
-
* @param inner - The underlying EmbeddingPort to delegate cache misses to
|
|
17
|
-
* @param options - Cache configuration (maxEntries)
|
|
18
|
-
* @returns An EmbeddingPort with transparent caching
|
|
19
|
-
*/
|
|
20
|
-
export function createCachedEmbeddingPort(inner, options) {
|
|
21
|
-
const cache = new LRUCache({
|
|
22
|
-
max: options.maxEntries,
|
|
23
|
-
...(options.ttlMs ? { ttl: options.ttlMs } : {}),
|
|
24
|
-
});
|
|
25
|
-
let hits = 0;
|
|
26
|
-
let misses = 0;
|
|
27
|
-
function hashText(text) {
|
|
28
|
-
return createHash("sha256").update(text).digest("hex");
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
provider: inner.provider,
|
|
32
|
-
dimensions: inner.dimensions,
|
|
33
|
-
modelId: inner.modelId,
|
|
34
|
-
async embed(text) {
|
|
35
|
-
const key = hashText(text);
|
|
36
|
-
const cached = cache.get(key);
|
|
37
|
-
if (cached) {
|
|
38
|
-
hits++;
|
|
39
|
-
return ok(cached);
|
|
40
|
-
}
|
|
41
|
-
misses++;
|
|
42
|
-
const result = await inner.embed(text);
|
|
43
|
-
if (result.ok)
|
|
44
|
-
cache.set(key, result.value);
|
|
45
|
-
return result;
|
|
46
|
-
},
|
|
47
|
-
async embedBatch(texts) {
|
|
48
|
-
// Split into hits and misses
|
|
49
|
-
const results = [];
|
|
50
|
-
const missIndices = [];
|
|
51
|
-
const missTexts = [];
|
|
52
|
-
for (let i = 0; i < texts.length; i++) {
|
|
53
|
-
const key = hashText(texts[i]);
|
|
54
|
-
const cached = cache.get(key);
|
|
55
|
-
if (cached) {
|
|
56
|
-
hits++;
|
|
57
|
-
results.push(cached);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
misses++;
|
|
61
|
-
results.push(null);
|
|
62
|
-
missIndices.push(i);
|
|
63
|
-
missTexts.push(texts[i]);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
// If all cached, return immediately
|
|
67
|
-
if (missTexts.length === 0) {
|
|
68
|
-
return ok(results);
|
|
69
|
-
}
|
|
70
|
-
// Embed misses in a single batch
|
|
71
|
-
const batchResult = await inner.embedBatch(missTexts);
|
|
72
|
-
if (!batchResult.ok)
|
|
73
|
-
return batchResult;
|
|
74
|
-
// Merge: fill in misses and cache them
|
|
75
|
-
for (let j = 0; j < missIndices.length; j++) {
|
|
76
|
-
const idx = missIndices[j];
|
|
77
|
-
results[idx] = batchResult.value[j];
|
|
78
|
-
cache.set(hashText(missTexts[j]), batchResult.value[j]);
|
|
79
|
-
}
|
|
80
|
-
return ok(results);
|
|
81
|
-
},
|
|
82
|
-
getCacheStats() {
|
|
83
|
-
const total = hits + misses;
|
|
84
|
-
return {
|
|
85
|
-
entries: cache.size,
|
|
86
|
-
maxEntries: cache.max,
|
|
87
|
-
hitRate: total > 0 ? hits / total : 0,
|
|
88
|
-
hits,
|
|
89
|
-
misses,
|
|
90
|
-
provider: inner.provider,
|
|
91
|
-
};
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
}
|
|
@@ -1,17 +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
|
-
export {};
|