comisai 1.0.36 → 1.0.37
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/node_modules/@comis/agent/dist/background/auto-background-middleware.js +9 -0
- package/node_modules/@comis/agent/dist/background/background-task-manager.d.ts +22 -2
- package/node_modules/@comis/agent/dist/background/background-task-manager.js +48 -41
- package/node_modules/@comis/agent/dist/background/background-task-persistence.js +28 -5
- package/node_modules/@comis/agent/dist/background/background-task-types.d.ts +49 -0
- package/node_modules/@comis/agent/dist/background/completion-dispatcher.d.ts +130 -0
- package/node_modules/@comis/agent/dist/background/completion-dispatcher.js +215 -0
- package/node_modules/@comis/agent/dist/background/completion-runner.d.ts +10 -1
- package/node_modules/@comis/agent/dist/background/completion-runner.js +98 -15
- package/node_modules/@comis/agent/dist/background/index.d.ts +6 -1
- package/node_modules/@comis/agent/dist/background/index.js +2 -0
- package/node_modules/@comis/agent/dist/background/session-resolver.d.ts +85 -0
- package/node_modules/@comis/agent/dist/background/session-resolver.js +78 -0
- package/node_modules/@comis/agent/dist/bootstrap/sections/messaging-sections.js +1 -0
- package/node_modules/@comis/agent/dist/bootstrap/sections/tool-descriptions.js +3 -3
- package/node_modules/@comis/agent/dist/bootstrap/sections/tooling-sections.d.ts +30 -2
- package/node_modules/@comis/agent/dist/bootstrap/sections/tooling-sections.js +51 -2
- package/node_modules/@comis/agent/dist/bootstrap/system-prompt-assembler.d.ts +22 -0
- package/node_modules/@comis/agent/dist/bootstrap/system-prompt-assembler.js +2 -2
- package/node_modules/@comis/agent/dist/bridge/bridge-event-handlers.d.ts +1 -5
- package/node_modules/@comis/agent/dist/bridge/bridge-event-handlers.js +2 -14
- package/node_modules/@comis/agent/dist/bridge/bridge-metrics.d.ts +26 -0
- package/node_modules/@comis/agent/dist/bridge/bridge-metrics.js +3 -0
- package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.d.ts +9 -0
- package/node_modules/@comis/agent/dist/bridge/pi-event-bridge.js +73 -2
- package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.d.ts +10 -10
- package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.js +14 -14
- package/node_modules/@comis/agent/dist/context-engine/thinking-block-cleaner.d.ts +11 -13
- package/node_modules/@comis/agent/dist/context-engine/thinking-block-cleaner.js +14 -15
- package/node_modules/@comis/agent/dist/executor/capability-index-context.d.ts +72 -0
- package/node_modules/@comis/agent/dist/executor/capability-index-context.js +329 -0
- package/node_modules/@comis/agent/dist/executor/drain-helper.d.ts +122 -0
- package/node_modules/@comis/agent/dist/executor/drain-helper.js +173 -0
- package/node_modules/@comis/agent/dist/executor/error-classifier.js +2 -2
- package/node_modules/@comis/agent/dist/executor/executor-post-execution.d.ts +48 -4
- package/node_modules/@comis/agent/dist/executor/executor-post-execution.js +134 -31
- package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.d.ts +7 -0
- package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.js +25 -4
- package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.d.ts +18 -1
- package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.js +19 -16
- package/node_modules/@comis/agent/dist/executor/jit-guide-injector.d.ts +11 -2
- package/node_modules/@comis/agent/dist/executor/jit-guide-injector.js +16 -2
- package/node_modules/@comis/agent/dist/executor/pi-executor.d.ts +8 -2
- package/node_modules/@comis/agent/dist/executor/pi-executor.js +25 -12
- package/node_modules/@comis/agent/dist/executor/prompt-assembly.d.ts +9 -1
- package/node_modules/@comis/agent/dist/executor/prompt-assembly.js +15 -1
- package/node_modules/@comis/agent/dist/executor/tool-deferral.d.ts +18 -27
- package/node_modules/@comis/agent/dist/executor/tool-deferral.js +29 -38
- package/node_modules/@comis/agent/dist/model/model-registry-adapter.js +1 -1
- package/node_modules/@comis/agent/dist/model/model-scanner.js +1 -1
- package/node_modules/@comis/agent/dist/safety/tool-retry-breaker.d.ts +11 -1
- package/node_modules/@comis/agent/dist/safety/tool-retry-breaker.js +19 -22
- package/node_modules/@comis/agent/dist/session/comis-session-manager.d.ts +16 -2
- package/node_modules/@comis/agent/dist/spawn/pi-mono-adapters.d.ts +1 -1
- package/node_modules/@comis/agent/dist/spawn/pi-mono-adapters.js +5 -5
- package/node_modules/@comis/agent/dist/workspace/data-env.d.ts +38 -0
- package/node_modules/@comis/agent/dist/workspace/data-env.js +56 -0
- package/node_modules/@comis/agent/dist/workspace/index.d.ts +1 -0
- package/node_modules/@comis/agent/dist/workspace/index.js +1 -0
- package/node_modules/@comis/agent/dist/workspace/templates.js +5 -1
- package/node_modules/@comis/agent/package.json +1 -1
- package/node_modules/@comis/channels/dist/index.d.ts +1 -1
- package/node_modules/@comis/channels/dist/index.js +1 -1
- package/node_modules/@comis/channels/dist/shared/channel-manager.d.ts +9 -3
- package/node_modules/@comis/channels/dist/shared/inbound-gate.d.ts +1 -1
- package/node_modules/@comis/channels/dist/shared/inbound-gate.js +22 -7
- package/node_modules/@comis/channels/dist/shared/inbound-pipeline.d.ts +10 -3
- package/node_modules/@comis/channels/dist/shared/inbound-route.d.ts +1 -1
- package/node_modules/@comis/channels/dist/shared/inbound-route.js +13 -2
- package/node_modules/@comis/channels/dist/shared/response-filter.d.ts +11 -24
- package/node_modules/@comis/channels/dist/shared/response-filter.js +25 -53
- package/node_modules/@comis/channels/package.json +1 -1
- package/node_modules/@comis/cli/dist/commands/providers.d.ts +1 -2
- package/node_modules/@comis/cli/dist/commands/providers.js +5 -6
- package/node_modules/@comis/cli/package.json +1 -1
- package/node_modules/@comis/core/dist/config/field-metadata.js +2 -0
- package/node_modules/@comis/core/dist/config/immutable-keys.js +4 -1
- package/node_modules/@comis/core/dist/config/index.d.ts +4 -0
- package/node_modules/@comis/core/dist/config/index.js +2 -0
- package/node_modules/@comis/core/dist/config/schema-agent.d.ts +0 -792
- package/node_modules/@comis/core/dist/config/schema-approvals.d.ts +0 -14
- package/node_modules/@comis/core/dist/config/schema-auto-reply-engine.d.ts +0 -6
- package/node_modules/@comis/core/dist/config/schema-background-tasks.d.ts +0 -12
- package/node_modules/@comis/core/dist/config/schema-browser.d.ts +0 -18
- package/node_modules/@comis/core/dist/config/schema-channel.d.ts +0 -158
- package/node_modules/@comis/core/dist/config/schema-coalescer.d.ts +0 -5
- package/node_modules/@comis/core/dist/config/schema-daemon.d.ts +0 -32
- package/node_modules/@comis/core/dist/config/schema-delivery.d.ts +0 -18
- package/node_modules/@comis/core/dist/config/schema-documentation.d.ts +0 -12
- package/node_modules/@comis/core/dist/config/schema-embedding.d.ts +0 -20
- package/node_modules/@comis/core/dist/config/schema-envelope.d.ts +0 -15
- package/node_modules/@comis/core/dist/config/schema-gateway.d.ts +0 -37
- package/node_modules/@comis/core/dist/config/schema-gemini-cache.d.ts +0 -2
- package/node_modules/@comis/core/dist/config/schema-integrations.d.ts +0 -318
- package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.d.ts +0 -18
- package/node_modules/@comis/core/dist/config/schema-memory-review.d.ts +0 -7
- package/node_modules/@comis/core/dist/config/schema-memory.d.ts +0 -16
- package/node_modules/@comis/core/dist/config/schema-messages.d.ts +0 -8
- package/node_modules/@comis/core/dist/config/schema-models.d.ts +0 -15
- package/node_modules/@comis/core/dist/config/schema-notification.d.ts +0 -5
- package/node_modules/@comis/core/dist/config/schema-oauth.d.ts +0 -5
- package/node_modules/@comis/core/dist/config/schema-observability.d.ts +0 -38
- package/node_modules/@comis/core/dist/config/schema-output-retention.d.ts +34 -0
- package/node_modules/@comis/core/dist/config/schema-output-retention.js +48 -0
- package/node_modules/@comis/core/dist/config/schema-plugins.d.ts +0 -8
- package/node_modules/@comis/core/dist/config/schema-providers.d.ts +0 -64
- package/node_modules/@comis/core/dist/config/schema-queue.d.ts +0 -58
- package/node_modules/@comis/core/dist/config/schema-response-prefix.d.ts +0 -2
- package/node_modules/@comis/core/dist/config/schema-retry.d.ts +0 -6
- package/node_modules/@comis/core/dist/config/schema-scheduler.d.ts +0 -39
- package/node_modules/@comis/core/dist/config/schema-secrets.d.ts +0 -3
- package/node_modules/@comis/core/dist/config/schema-security.d.ts +0 -18
- package/node_modules/@comis/core/dist/config/schema-send-policy.d.ts +0 -13
- package/node_modules/@comis/core/dist/config/schema-sender-trust-display.d.ts +0 -5
- package/node_modules/@comis/core/dist/config/schema-serializer.js +2 -0
- package/node_modules/@comis/core/dist/config/schema-skills.d.ts +0 -61
- package/node_modules/@comis/core/dist/config/schema-streaming.d.ts +0 -38
- package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.d.ts +0 -3
- package/node_modules/@comis/core/dist/config/schema-tooling.d.ts +87 -0
- package/node_modules/@comis/core/dist/config/schema-tooling.js +152 -0
- package/node_modules/@comis/core/dist/config/schema-verbosity.d.ts +0 -12
- package/node_modules/@comis/core/dist/config/schema-webhooks.d.ts +0 -40
- package/node_modules/@comis/core/dist/config/schema.d.ts +41 -38
- package/node_modules/@comis/core/dist/config/schema.js +6 -0
- package/node_modules/@comis/core/dist/context/context.d.ts +0 -4
- package/node_modules/@comis/core/dist/domain/approval-request.d.ts +0 -17
- package/node_modules/@comis/core/dist/domain/background-task-origin.d.ts +0 -10
- package/node_modules/@comis/core/dist/domain/delivery-origin.d.ts +0 -5
- package/node_modules/@comis/core/dist/domain/execution-graph.d.ts +0 -48
- package/node_modules/@comis/core/dist/domain/memory-entry.d.ts +0 -3
- package/node_modules/@comis/core/dist/domain/model-compat.d.ts +0 -4
- package/node_modules/@comis/core/dist/domain/normalized-message.d.ts +0 -15
- package/node_modules/@comis/core/dist/domain/provider-capabilities.d.ts +0 -6
- package/node_modules/@comis/core/dist/domain/rich-message.d.ts +0 -14
- package/node_modules/@comis/core/dist/domain/subagent-context-config.d.ts +0 -22
- package/node_modules/@comis/core/dist/domain/subagent-context-types.d.ts +0 -8
- package/node_modules/@comis/core/dist/event-bus/events-agent.d.ts +31 -0
- package/node_modules/@comis/core/dist/event-bus/events-infra.d.ts +5 -0
- package/node_modules/@comis/core/dist/exports/config.d.ts +2 -2
- package/node_modules/@comis/core/dist/exports/config.js +3 -1
- package/node_modules/@comis/core/dist/exports/hooks.d.ts +1 -1
- package/node_modules/@comis/core/dist/exports/ports.d.ts +2 -2
- package/node_modules/@comis/core/dist/exports/ports.js +1 -1
- package/node_modules/@comis/core/dist/ports/channel-plugin.d.ts +0 -13
- package/node_modules/@comis/core/dist/ports/index.d.ts +2 -0
- package/node_modules/@comis/core/dist/ports/index.js +4 -0
- package/node_modules/@comis/core/dist/ports/no-op-tool-capability.d.ts +30 -0
- package/node_modules/@comis/core/dist/ports/no-op-tool-capability.js +47 -0
- package/node_modules/@comis/core/dist/ports/tool-capability.d.ts +165 -0
- package/node_modules/@comis/core/dist/ports/tool-capability.js +15 -0
- package/node_modules/@comis/core/dist/security/audit.d.ts +0 -11
- package/node_modules/@comis/core/dist/tool-metadata.d.ts +21 -1
- package/node_modules/@comis/core/dist/tool-metadata.js +1 -1
- package/node_modules/@comis/core/package.json +1 -1
- package/node_modules/@comis/daemon/bundled-skills/skill-creator/scripts/validate-skill.py +1 -1
- package/node_modules/@comis/daemon/dist/daemon.js +89 -14
- package/node_modules/@comis/daemon/dist/rpc/agent-inline-workspace.d.ts +1 -1
- package/node_modules/@comis/daemon/dist/rpc/agent-inline-workspace.js +1 -1
- package/node_modules/@comis/daemon/dist/rpc/builtin-provider-guard.js +2 -2
- package/node_modules/@comis/daemon/dist/rpc/credential-resolver.js +1 -1
- package/node_modules/@comis/daemon/dist/rpc/model-handlers.d.ts +1 -1
- package/node_modules/@comis/daemon/dist/rpc/model-handlers.js +2 -2
- package/node_modules/@comis/daemon/dist/sub-agent-runner.d.ts +18 -0
- package/node_modules/@comis/daemon/dist/sub-agent-runner.js +41 -9
- package/node_modules/@comis/daemon/dist/wiring/index.d.ts +2 -0
- package/node_modules/@comis/daemon/dist/wiring/index.js +1 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-agents.d.ts +36 -2
- package/node_modules/@comis/daemon/dist/wiring/setup-agents.js +45 -8
- package/node_modules/@comis/daemon/dist/wiring/setup-background-completion-runner.d.ts +28 -9
- package/node_modules/@comis/daemon/dist/wiring/setup-background-completion-runner.js +36 -9
- package/node_modules/@comis/daemon/dist/wiring/setup-background-tasks.js +2 -2
- package/node_modules/@comis/daemon/dist/wiring/setup-channels.d.ts +9 -2
- package/node_modules/@comis/daemon/dist/wiring/setup-channels.js +15 -9
- package/node_modules/@comis/daemon/dist/wiring/setup-cross-session.d.ts +20 -5
- package/node_modules/@comis/daemon/dist/wiring/setup-cross-session.js +20 -15
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery.js +14 -2
- package/node_modules/@comis/daemon/dist/wiring/setup-gateway.d.ts +4 -6
- package/node_modules/@comis/daemon/dist/wiring/setup-gateway.js +3 -5
- package/node_modules/@comis/daemon/dist/wiring/setup-heartbeat.d.ts +20 -5
- package/node_modules/@comis/daemon/dist/wiring/setup-heartbeat.js +11 -2
- package/node_modules/@comis/daemon/dist/wiring/setup-output-retention.d.ts +89 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-output-retention.js +212 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-tools.d.ts +18 -4
- package/node_modules/@comis/daemon/dist/wiring/setup-tools.js +29 -10
- package/node_modules/@comis/daemon/dist/wiring/tool-capability-adapter.d.ts +75 -0
- package/node_modules/@comis/daemon/dist/wiring/tool-capability-adapter.js +253 -0
- package/node_modules/@comis/daemon/package.json +1 -1
- package/node_modules/@comis/gateway/dist/webhook/webhook-endpoint.d.ts +0 -4
- 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/dist/cron/cron-types.d.ts +0 -42
- package/node_modules/@comis/scheduler/dist/heartbeat/agent-heartbeat-source.d.ts +29 -8
- package/node_modules/@comis/scheduler/dist/heartbeat/agent-heartbeat-source.js +19 -7
- package/node_modules/@comis/scheduler/dist/system-events/system-event-types.d.ts +0 -3
- package/node_modules/@comis/scheduler/dist/tasks/task-types.d.ts +0 -17
- package/node_modules/@comis/scheduler/package.json +1 -1
- package/node_modules/@comis/shared/dist/index.d.ts +3 -0
- package/node_modules/@comis/shared/dist/index.js +4 -0
- package/node_modules/@comis/shared/dist/mcp-tool-name.d.ts +78 -0
- package/node_modules/@comis/shared/dist/mcp-tool-name.js +92 -0
- package/node_modules/@comis/shared/dist/silent-tokens.d.ts +38 -0
- package/node_modules/@comis/shared/dist/silent-tokens.js +51 -0
- package/node_modules/@comis/shared/dist/visible-delivery.d.ts +28 -0
- package/node_modules/@comis/shared/dist/visible-delivery.js +16 -0
- package/node_modules/@comis/shared/package.json +1 -1
- package/node_modules/@comis/skills/dist/bridge/mcp-tool-bridge.d.ts +2 -13
- package/node_modules/@comis/skills/dist/bridge/mcp-tool-bridge.js +3 -21
- package/node_modules/@comis/skills/dist/bridge/tool-metadata-enforcement.js +1 -1
- package/node_modules/@comis/skills/dist/bridge/tool-metadata-registry.js +4 -4
- package/node_modules/@comis/skills/dist/builtin/exec-tool.d.ts +55 -9
- package/node_modules/@comis/skills/dist/builtin/exec-tool.js +383 -19
- package/node_modules/@comis/skills/dist/builtin/install-detour.d.ts +67 -0
- package/node_modules/@comis/skills/dist/builtin/install-detour.js +342 -0
- package/node_modules/@comis/skills/dist/builtin/platform/admin-manage-factory.js +5 -5
- package/node_modules/@comis/skills/dist/builtin/platform/agents-manage-tool.d.ts +2 -2
- package/node_modules/@comis/skills/dist/builtin/platform/agents-manage-tool.js +2 -2
- package/node_modules/@comis/skills/dist/builtin/platform/message-tool.js +18 -0
- package/node_modules/@comis/skills/dist/builtin/platform/messaging-factory.d.ts +18 -1
- package/node_modules/@comis/skills/dist/builtin/platform/messaging-factory.js +18 -2
- package/node_modules/@comis/skills/dist/builtin/platform/models-manage-tool.js +3 -3
- package/node_modules/@comis/skills/dist/builtin/process-registry.d.ts +14 -0
- package/node_modules/@comis/skills/dist/builtin/process-tool.d.ts +24 -4
- package/node_modules/@comis/skills/dist/builtin/process-tool.js +25 -7
- package/node_modules/@comis/skills/dist/builtin/sandbox/bwrap-provider.d.ts +1 -1
- package/node_modules/@comis/skills/dist/builtin/sandbox/bwrap-provider.js +9 -0
- package/node_modules/@comis/skills/dist/index.d.ts +4 -1
- package/node_modules/@comis/skills/dist/index.js +3 -1
- package/node_modules/@comis/skills/dist/manifest/capability-parser.d.ts +44 -0
- package/node_modules/@comis/skills/dist/manifest/capability-parser.js +68 -0
- package/node_modules/@comis/skills/dist/manifest/schema.d.ts +44 -37
- package/node_modules/@comis/skills/dist/manifest/schema.js +35 -0
- package/node_modules/@comis/skills/dist/registry/discovery.d.ts +8 -0
- package/node_modules/@comis/skills/dist/registry/discovery.js +10 -3
- package/node_modules/@comis/skills/dist/registry/skill-registry.d.ts +45 -1
- package/node_modules/@comis/skills/dist/registry/skill-registry.js +70 -7
- package/node_modules/@comis/skills/package.json +1 -1
- package/node_modules/@comis/web/package.json +1 -1
- package/package.json +21 -21
|
@@ -41,15 +41,18 @@ export function resolveHeartbeatModel(perAgentHeartbeatModel, globalHeartbeatMod
|
|
|
41
41
|
return perAgentHeartbeatModel ?? globalHeartbeatModel ?? agentDefaultModel;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Check if a session is actively running an agent turn.
|
|
44
|
+
* Check if a session is actively running an agent turn (R3, B36).
|
|
45
45
|
*
|
|
46
|
-
*
|
|
46
|
+
* Uses the composite-key resolver: `(agentId, channelType, channelId)`
|
|
47
|
+
* uniquely identifies a session across multi-agent / multi-channel
|
|
48
|
+
* deployments (the previous single-arg `formattedKey` collapsed those
|
|
49
|
+
* dimensions). Returns false when no resolver is provided (heartbeat
|
|
47
50
|
* operates in isolation without collision detection).
|
|
48
51
|
*/
|
|
49
|
-
export function isQueueBusy(
|
|
50
|
-
if (!
|
|
52
|
+
export function isQueueBusy(sessionResolver, composite) {
|
|
53
|
+
if (!sessionResolver)
|
|
51
54
|
return false;
|
|
52
|
-
return
|
|
55
|
+
return sessionResolver.hasActiveSession(composite);
|
|
53
56
|
}
|
|
54
57
|
/**
|
|
55
58
|
* Resolve the SessionKey for a heartbeat tick.
|
|
@@ -99,8 +102,17 @@ export function createAgentHeartbeatSource(deps) {
|
|
|
99
102
|
return;
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
|
-
// 5. Queue-busy check
|
|
103
|
-
|
|
105
|
+
// 5. Queue-busy check (R3, B36): composite-key lookup distinguishes
|
|
106
|
+
// multi-agent / multi-channel collisions. The msg.channelType is the
|
|
107
|
+
// configured target's channelType (defaulting to "heartbeat" when no
|
|
108
|
+
// delivery target is wired). channelId is sessionKey.channelId
|
|
109
|
+
// (matches resolveHeartbeatSessionKey above).
|
|
110
|
+
const heartbeatChannelType = config.target?.channelType ?? "heartbeat";
|
|
111
|
+
if (isQueueBusy(deps.sessionResolver, {
|
|
112
|
+
agentId,
|
|
113
|
+
channelType: heartbeatChannelType,
|
|
114
|
+
channelId: sessionKey.channelId,
|
|
115
|
+
})) {
|
|
104
116
|
logger.debug({ agentId, formattedKey }, "Heartbeat skipped: session queue busy");
|
|
105
117
|
return;
|
|
106
118
|
}
|
|
@@ -4,11 +4,8 @@ import { z } from "zod";
|
|
|
4
4
|
* Events are produced by subsystems (cron, exec) and consumed by the heartbeat cycle.
|
|
5
5
|
*/
|
|
6
6
|
export declare const SystemEventEntrySchema: z.ZodObject<{
|
|
7
|
-
/** Event text content (e.g., "Check disk space", "Command completed: git pull") */
|
|
8
7
|
text: z.ZodString;
|
|
9
|
-
/** Classification key for filtering (e.g., "cron:job-abc", "exec:cmd-123") */
|
|
10
8
|
contextKey: z.ZodString;
|
|
11
|
-
/** Timestamp when the event was enqueued (ms since epoch) */
|
|
12
9
|
enqueuedAt: z.ZodNumber;
|
|
13
10
|
}, z.core.$strict>;
|
|
14
11
|
export type SystemEventEntry = z.infer<typeof SystemEventEntrySchema>;
|
|
@@ -23,40 +23,28 @@ export type TaskStatus = z.infer<typeof TaskStatusSchema>;
|
|
|
23
23
|
* A task extracted from conversation by the LLM.
|
|
24
24
|
*/
|
|
25
25
|
export declare const ExtractedTaskSchema: z.ZodObject<{
|
|
26
|
-
/** Unique task identifier */
|
|
27
26
|
id: z.ZodString;
|
|
28
|
-
/** Short title for the task */
|
|
29
27
|
title: z.ZodString;
|
|
30
|
-
/** Detailed description */
|
|
31
28
|
description: z.ZodDefault<z.ZodString>;
|
|
32
|
-
/** Optional due date (ISO 8601) */
|
|
33
29
|
dueDate: z.ZodOptional<z.ZodString>;
|
|
34
|
-
/** Task priority */
|
|
35
30
|
priority: z.ZodEnum<{
|
|
36
31
|
low: "low";
|
|
37
32
|
medium: "medium";
|
|
38
33
|
high: "high";
|
|
39
34
|
critical: "critical";
|
|
40
35
|
}>;
|
|
41
|
-
/** Source provenance */
|
|
42
36
|
source: z.ZodObject<{
|
|
43
|
-
/** Session key where task was extracted */
|
|
44
37
|
sessionKey: z.ZodString;
|
|
45
|
-
/** Message index within the session */
|
|
46
38
|
messageIndex: z.ZodNumber;
|
|
47
|
-
/** Timestamp when extraction occurred (ms since epoch) */
|
|
48
39
|
extractedAt: z.ZodNumber;
|
|
49
40
|
}, z.core.$strict>;
|
|
50
|
-
/** Confidence score from the LLM extraction (0-1) */
|
|
51
41
|
confidence: z.ZodNumber;
|
|
52
|
-
/** Task lifecycle status */
|
|
53
42
|
status: z.ZodDefault<z.ZodEnum<{
|
|
54
43
|
completed: "completed";
|
|
55
44
|
pending: "pending";
|
|
56
45
|
cancelled: "cancelled";
|
|
57
46
|
scheduled: "scheduled";
|
|
58
47
|
}>>;
|
|
59
|
-
/** Task creation timestamp (ms since epoch) */
|
|
60
48
|
createdAtMs: z.ZodNumber;
|
|
61
49
|
}, z.core.$strict>;
|
|
62
50
|
export type ExtractedTask = z.infer<typeof ExtractedTaskSchema>;
|
|
@@ -65,7 +53,6 @@ export type ExtractedTask = z.infer<typeof ExtractedTaskSchema>;
|
|
|
65
53
|
* Tasks here lack id, createdAtMs, and status (assigned by the system).
|
|
66
54
|
*/
|
|
67
55
|
export declare const TaskExtractionResultSchema: z.ZodObject<{
|
|
68
|
-
/** Extracted tasks (without system-assigned fields) */
|
|
69
56
|
tasks: z.ZodArray<z.ZodObject<{
|
|
70
57
|
priority: z.ZodEnum<{
|
|
71
58
|
low: "low";
|
|
@@ -77,16 +64,12 @@ export declare const TaskExtractionResultSchema: z.ZodObject<{
|
|
|
77
64
|
description: z.ZodDefault<z.ZodString>;
|
|
78
65
|
dueDate: z.ZodOptional<z.ZodString>;
|
|
79
66
|
source: z.ZodObject<{
|
|
80
|
-
/** Session key where task was extracted */
|
|
81
67
|
sessionKey: z.ZodString;
|
|
82
|
-
/** Message index within the session */
|
|
83
68
|
messageIndex: z.ZodNumber;
|
|
84
|
-
/** Timestamp when extraction occurred (ms since epoch) */
|
|
85
69
|
extractedAt: z.ZodNumber;
|
|
86
70
|
}, z.core.$strict>;
|
|
87
71
|
confidence: z.ZodNumber;
|
|
88
72
|
}, z.core.$strict>>;
|
|
89
|
-
/** Optional reasoning from the LLM about extraction */
|
|
90
73
|
reasoning: z.ZodOptional<z.ZodString>;
|
|
91
74
|
}, z.core.$strict>;
|
|
92
75
|
export type TaskExtractionResult = z.infer<typeof TaskExtractionResultSchema>;
|
|
@@ -5,3 +5,6 @@ export { withTimeout, TimeoutError } from "./timeout.js";
|
|
|
5
5
|
export { checkAborted } from "./abort.js";
|
|
6
6
|
export { createTTLCache } from "./ttl-cache.js";
|
|
7
7
|
export type { TTLCache, TTLCacheOptions } from "./ttl-cache.js";
|
|
8
|
+
export { stripReplyTags, isSilentResponse, NO_REPLY_TOKEN, HEARTBEAT_OK_TOKEN, SILENT_PREFIX, } from "./silent-tokens.js";
|
|
9
|
+
export type { VisibleDeliveryKind, VisibleDeliveryRecord } from "./visible-delivery.js";
|
|
10
|
+
export { extractMcpServerName, parseSanitizedMcpToolName } from "./mcp-tool-name.js";
|
|
@@ -5,3 +5,7 @@ export { suppressError } from "./suppress-error.js";
|
|
|
5
5
|
export { withTimeout, TimeoutError } from "./timeout.js";
|
|
6
6
|
export { checkAborted } from "./abort.js";
|
|
7
7
|
export { createTTLCache } from "./ttl-cache.js";
|
|
8
|
+
// Silent-token detection for agent responses.
|
|
9
|
+
export { stripReplyTags, isSilentResponse, NO_REPLY_TOKEN, HEARTBEAT_OK_TOKEN, SILENT_PREFIX, } from "./silent-tokens.js";
|
|
10
|
+
// Canonical sanitized MCP tool name parsers.
|
|
11
|
+
export { extractMcpServerName, parseSanitizedMcpToolName } from "./mcp-tool-name.js";
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical sanitized MCP tool name parsers.
|
|
3
|
+
*
|
|
4
|
+
* Sanitized MCP tool names use the format `mcp__serverName--toolName`,
|
|
5
|
+
* produced by `sanitizeMcpToolName` in @comis/skills' mcp-tool-bridge
|
|
6
|
+
* (replaces `:` with `__`, `/` with `--` to satisfy LLM API constraints
|
|
7
|
+
* that tool names match `^[a-zA-Z0-9_-]{1,128}$`).
|
|
8
|
+
*
|
|
9
|
+
* Both parsers split on the FIRST `--` after the `mcp__` prefix, which:
|
|
10
|
+
* - Correctly handles hyphenated server names (`mcp__foo-bar--baz`
|
|
11
|
+
* -> server="foo-bar", tool="baz")
|
|
12
|
+
* - Correctly handles underscored server names (`mcp__srv__v2--ns--tool`
|
|
13
|
+
* -> server="srv__v2", tool="ns--tool")
|
|
14
|
+
* - Returns undefined for non-MCP tools (`Read`) and malformed names
|
|
15
|
+
* (`mcp__`, `mcp__foo`, `mcp__--baz`)
|
|
16
|
+
*
|
|
17
|
+
* Asymmetry between the two functions is intentional:
|
|
18
|
+
* - `extractMcpServerName("mcp__foo--")` returns "foo" — callers that
|
|
19
|
+
* only need to GROUP by server (e.g., DeferredToolEntry grouping in
|
|
20
|
+
* tool-deferral.ts) tolerate empty tool names.
|
|
21
|
+
* - `parseSanitizedMcpToolName("mcp__foo--")` returns undefined —
|
|
22
|
+
* callers that need a complete (server, tool) pair require both
|
|
23
|
+
* halves to be non-empty.
|
|
24
|
+
*
|
|
25
|
+
* Used by:
|
|
26
|
+
* - `packages/skills/src/bridge/mcp-tool-bridge.ts` — re-exports for
|
|
27
|
+
* public API surface (`packages/skills/src/index.ts:174`).
|
|
28
|
+
* - `packages/agent/src/bridge/bridge-event-handlers.ts` — re-exports
|
|
29
|
+
* for in-package callers (`pi-event-bridge.ts:42`,
|
|
30
|
+
* `tool-deferral.ts:23`).
|
|
31
|
+
* - `packages/agent/src/bridge/pi-event-bridge.ts:347` — log decoration
|
|
32
|
+
* when an MCP tool errors at the event-bus boundary.
|
|
33
|
+
* - `packages/agent/src/executor/tool-deferral.ts:293,912,917` —
|
|
34
|
+
* grouping `DeferredToolEntry[]` by server name.
|
|
35
|
+
* - Future install-detour parser will consume `parseSanitizedMcpToolName`
|
|
36
|
+
* for `{server, tool}` pair-matching.
|
|
37
|
+
*
|
|
38
|
+
* @module
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Extract the MCP server name from a sanitized tool name.
|
|
42
|
+
*
|
|
43
|
+
* Sanitized MCP tool names use the format `mcp__serverName--toolName`.
|
|
44
|
+
* Returns `undefined` for non-MCP tools, malformed names with no
|
|
45
|
+
* `--` separator, or names with an empty server (`mcp__--baz`).
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* extractMcpServerName("mcp__context7--resolve-library-id") // "context7"
|
|
49
|
+
* extractMcpServerName("mcp__foo-bar--baz") // "foo-bar"
|
|
50
|
+
* extractMcpServerName("mcp__srv__v2--ns--tool") // "srv__v2"
|
|
51
|
+
* extractMcpServerName("Read") // undefined
|
|
52
|
+
* extractMcpServerName("mcp__") // undefined
|
|
53
|
+
* extractMcpServerName("mcp__foo") // undefined
|
|
54
|
+
* extractMcpServerName("mcp__--baz") // undefined
|
|
55
|
+
*/
|
|
56
|
+
export declare function extractMcpServerName(toolName: string): string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Parse a sanitized MCP tool name into its server and tool components.
|
|
59
|
+
*
|
|
60
|
+
* Returns `undefined` for non-MCP tools, malformed names, or names where
|
|
61
|
+
* either the server or tool component would be empty.
|
|
62
|
+
*
|
|
63
|
+
* Stricter than `extractMcpServerName`: this function ALSO rejects names
|
|
64
|
+
* with an empty tool (`mcp__foo--` returns `undefined` here, but
|
|
65
|
+
* `extractMcpServerName` returns `"foo"`).
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* parseSanitizedMcpToolName("mcp__context7--resolve-library-id")
|
|
69
|
+
* // { server: "context7", tool: "resolve-library-id" }
|
|
70
|
+
* parseSanitizedMcpToolName("mcp__foo--bar--baz")
|
|
71
|
+
* // { server: "foo", tool: "bar--baz" } // splits on FIRST "--"
|
|
72
|
+
* parseSanitizedMcpToolName("mcp__foo--") // undefined
|
|
73
|
+
* parseSanitizedMcpToolName("Read") // undefined
|
|
74
|
+
*/
|
|
75
|
+
export declare function parseSanitizedMcpToolName(toolName: string): {
|
|
76
|
+
server: string;
|
|
77
|
+
tool: string;
|
|
78
|
+
} | undefined;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Canonical sanitized MCP tool name parsers.
|
|
4
|
+
*
|
|
5
|
+
* Sanitized MCP tool names use the format `mcp__serverName--toolName`,
|
|
6
|
+
* produced by `sanitizeMcpToolName` in @comis/skills' mcp-tool-bridge
|
|
7
|
+
* (replaces `:` with `__`, `/` with `--` to satisfy LLM API constraints
|
|
8
|
+
* that tool names match `^[a-zA-Z0-9_-]{1,128}$`).
|
|
9
|
+
*
|
|
10
|
+
* Both parsers split on the FIRST `--` after the `mcp__` prefix, which:
|
|
11
|
+
* - Correctly handles hyphenated server names (`mcp__foo-bar--baz`
|
|
12
|
+
* -> server="foo-bar", tool="baz")
|
|
13
|
+
* - Correctly handles underscored server names (`mcp__srv__v2--ns--tool`
|
|
14
|
+
* -> server="srv__v2", tool="ns--tool")
|
|
15
|
+
* - Returns undefined for non-MCP tools (`Read`) and malformed names
|
|
16
|
+
* (`mcp__`, `mcp__foo`, `mcp__--baz`)
|
|
17
|
+
*
|
|
18
|
+
* Asymmetry between the two functions is intentional:
|
|
19
|
+
* - `extractMcpServerName("mcp__foo--")` returns "foo" — callers that
|
|
20
|
+
* only need to GROUP by server (e.g., DeferredToolEntry grouping in
|
|
21
|
+
* tool-deferral.ts) tolerate empty tool names.
|
|
22
|
+
* - `parseSanitizedMcpToolName("mcp__foo--")` returns undefined —
|
|
23
|
+
* callers that need a complete (server, tool) pair require both
|
|
24
|
+
* halves to be non-empty.
|
|
25
|
+
*
|
|
26
|
+
* Used by:
|
|
27
|
+
* - `packages/skills/src/bridge/mcp-tool-bridge.ts` — re-exports for
|
|
28
|
+
* public API surface (`packages/skills/src/index.ts:174`).
|
|
29
|
+
* - `packages/agent/src/bridge/bridge-event-handlers.ts` — re-exports
|
|
30
|
+
* for in-package callers (`pi-event-bridge.ts:42`,
|
|
31
|
+
* `tool-deferral.ts:23`).
|
|
32
|
+
* - `packages/agent/src/bridge/pi-event-bridge.ts:347` — log decoration
|
|
33
|
+
* when an MCP tool errors at the event-bus boundary.
|
|
34
|
+
* - `packages/agent/src/executor/tool-deferral.ts:293,912,917` —
|
|
35
|
+
* grouping `DeferredToolEntry[]` by server name.
|
|
36
|
+
* - Future install-detour parser will consume `parseSanitizedMcpToolName`
|
|
37
|
+
* for `{server, tool}` pair-matching.
|
|
38
|
+
*
|
|
39
|
+
* @module
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* Extract the MCP server name from a sanitized tool name.
|
|
43
|
+
*
|
|
44
|
+
* Sanitized MCP tool names use the format `mcp__serverName--toolName`.
|
|
45
|
+
* Returns `undefined` for non-MCP tools, malformed names with no
|
|
46
|
+
* `--` separator, or names with an empty server (`mcp__--baz`).
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* extractMcpServerName("mcp__context7--resolve-library-id") // "context7"
|
|
50
|
+
* extractMcpServerName("mcp__foo-bar--baz") // "foo-bar"
|
|
51
|
+
* extractMcpServerName("mcp__srv__v2--ns--tool") // "srv__v2"
|
|
52
|
+
* extractMcpServerName("Read") // undefined
|
|
53
|
+
* extractMcpServerName("mcp__") // undefined
|
|
54
|
+
* extractMcpServerName("mcp__foo") // undefined
|
|
55
|
+
* extractMcpServerName("mcp__--baz") // undefined
|
|
56
|
+
*/
|
|
57
|
+
export function extractMcpServerName(toolName) {
|
|
58
|
+
if (!toolName.startsWith("mcp__"))
|
|
59
|
+
return undefined;
|
|
60
|
+
const rest = toolName.slice(5);
|
|
61
|
+
const sepIdx = rest.indexOf("--");
|
|
62
|
+
if (sepIdx <= 0)
|
|
63
|
+
return undefined;
|
|
64
|
+
return rest.slice(0, sepIdx);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Parse a sanitized MCP tool name into its server and tool components.
|
|
68
|
+
*
|
|
69
|
+
* Returns `undefined` for non-MCP tools, malformed names, or names where
|
|
70
|
+
* either the server or tool component would be empty.
|
|
71
|
+
*
|
|
72
|
+
* Stricter than `extractMcpServerName`: this function ALSO rejects names
|
|
73
|
+
* with an empty tool (`mcp__foo--` returns `undefined` here, but
|
|
74
|
+
* `extractMcpServerName` returns `"foo"`).
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* parseSanitizedMcpToolName("mcp__context7--resolve-library-id")
|
|
78
|
+
* // { server: "context7", tool: "resolve-library-id" }
|
|
79
|
+
* parseSanitizedMcpToolName("mcp__foo--bar--baz")
|
|
80
|
+
* // { server: "foo", tool: "bar--baz" } // splits on FIRST "--"
|
|
81
|
+
* parseSanitizedMcpToolName("mcp__foo--") // undefined
|
|
82
|
+
* parseSanitizedMcpToolName("Read") // undefined
|
|
83
|
+
*/
|
|
84
|
+
export function parseSanitizedMcpToolName(toolName) {
|
|
85
|
+
if (!toolName.startsWith("mcp__"))
|
|
86
|
+
return undefined;
|
|
87
|
+
const rest = toolName.slice(5);
|
|
88
|
+
const sepIdx = rest.indexOf("--");
|
|
89
|
+
if (sepIdx <= 0 || sepIdx >= rest.length - 2)
|
|
90
|
+
return undefined;
|
|
91
|
+
return { server: rest.slice(0, sepIdx), tool: rest.slice(sepIdx + 2) };
|
|
92
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Silent-token detection for agent responses.
|
|
3
|
+
*
|
|
4
|
+
* Symbols + helpers that detect "silent" agent responses — exact-match
|
|
5
|
+
* sentinels (`NO_REPLY`, `HEARTBEAT_OK`) and a `[SILENT]`-prefix marker —
|
|
6
|
+
* after stripping `<reply>` / `</reply>` XML tags and trimming whitespace.
|
|
7
|
+
*
|
|
8
|
+
* Used by:
|
|
9
|
+
* - `packages/agent/src/executor/executor-post-execution.ts` — silent-sentinel
|
|
10
|
+
* pre-gate before paired-memory persistence.
|
|
11
|
+
* - `packages/channels/src/shared/response-filter.ts` — channel-delivery
|
|
12
|
+
* suppression (helper-delegating).
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
export declare const NO_REPLY_TOKEN = "NO_REPLY";
|
|
17
|
+
export declare const HEARTBEAT_OK_TOKEN = "HEARTBEAT_OK";
|
|
18
|
+
export declare const SILENT_PREFIX = "[SILENT]";
|
|
19
|
+
/**
|
|
20
|
+
* Strip `<reply>` / `<reply to="...">` opening tags and `</reply>` closing
|
|
21
|
+
* tags from a response, then trim whitespace.
|
|
22
|
+
*/
|
|
23
|
+
export declare function stripReplyTags(s: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Returns true iff the response, after stripping `<reply>` / `</reply>` tags
|
|
26
|
+
* and trimming whitespace, is exactly a silent sentinel (`NO_REPLY`,
|
|
27
|
+
* `HEARTBEAT_OK`, `[SILENT]`-prefix) or empty.
|
|
28
|
+
*
|
|
29
|
+
* **Contract:** idempotent under `stripReplyTags + trim`. For all
|
|
30
|
+
* inputs, `isSilentResponse(response) === isSilentResponse(stripReplyTags(response))`.
|
|
31
|
+
* Callers may pass raw or pre-stripped input; the helper does the strip+trim
|
|
32
|
+
* internally as defense-in-depth.
|
|
33
|
+
*
|
|
34
|
+
* Behavior matches the legacy `filterResponse` in
|
|
35
|
+
* `packages/channels/src/shared/response-filter.ts` byte-for-byte (this
|
|
36
|
+
* helper is the canonical home; `filterResponse` delegates to it).
|
|
37
|
+
*/
|
|
38
|
+
export declare function isSilentResponse(response: string | undefined): boolean;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Silent-token detection for agent responses.
|
|
4
|
+
*
|
|
5
|
+
* Symbols + helpers that detect "silent" agent responses — exact-match
|
|
6
|
+
* sentinels (`NO_REPLY`, `HEARTBEAT_OK`) and a `[SILENT]`-prefix marker —
|
|
7
|
+
* after stripping `<reply>` / `</reply>` XML tags and trimming whitespace.
|
|
8
|
+
*
|
|
9
|
+
* Used by:
|
|
10
|
+
* - `packages/agent/src/executor/executor-post-execution.ts` — silent-sentinel
|
|
11
|
+
* pre-gate before paired-memory persistence.
|
|
12
|
+
* - `packages/channels/src/shared/response-filter.ts` — channel-delivery
|
|
13
|
+
* suppression (helper-delegating).
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
export const NO_REPLY_TOKEN = "NO_REPLY";
|
|
18
|
+
export const HEARTBEAT_OK_TOKEN = "HEARTBEAT_OK";
|
|
19
|
+
export const SILENT_PREFIX = "[SILENT]";
|
|
20
|
+
const REPLY_TAG_RE = /<\/?reply(?:\s[^>]*)?>|<reply>/gi;
|
|
21
|
+
/**
|
|
22
|
+
* Strip `<reply>` / `<reply to="...">` opening tags and `</reply>` closing
|
|
23
|
+
* tags from a response, then trim whitespace.
|
|
24
|
+
*/
|
|
25
|
+
export function stripReplyTags(s) {
|
|
26
|
+
return s.replace(REPLY_TAG_RE, "").trim();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns true iff the response, after stripping `<reply>` / `</reply>` tags
|
|
30
|
+
* and trimming whitespace, is exactly a silent sentinel (`NO_REPLY`,
|
|
31
|
+
* `HEARTBEAT_OK`, `[SILENT]`-prefix) or empty.
|
|
32
|
+
*
|
|
33
|
+
* **Contract:** idempotent under `stripReplyTags + trim`. For all
|
|
34
|
+
* inputs, `isSilentResponse(response) === isSilentResponse(stripReplyTags(response))`.
|
|
35
|
+
* Callers may pass raw or pre-stripped input; the helper does the strip+trim
|
|
36
|
+
* internally as defense-in-depth.
|
|
37
|
+
*
|
|
38
|
+
* Behavior matches the legacy `filterResponse` in
|
|
39
|
+
* `packages/channels/src/shared/response-filter.ts` byte-for-byte (this
|
|
40
|
+
* helper is the canonical home; `filterResponse` delegates to it).
|
|
41
|
+
*/
|
|
42
|
+
export function isSilentResponse(response) {
|
|
43
|
+
if (!response)
|
|
44
|
+
return true;
|
|
45
|
+
const trimmed = stripReplyTags(response);
|
|
46
|
+
if (!trimmed)
|
|
47
|
+
return true;
|
|
48
|
+
if (trimmed.toUpperCase().startsWith(SILENT_PREFIX))
|
|
49
|
+
return true;
|
|
50
|
+
return trimmed === NO_REPLY_TOKEN || trimmed === HEARTBEAT_OK_TOKEN;
|
|
51
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VisibleDeliveryRecord: structured metadata for outbound channel deliveries
|
|
3
|
+
* captured in JSONL `details` for offline analysis (output retention housekeeper consumes this).
|
|
4
|
+
*
|
|
5
|
+
* Persisted in `details.visibleDelivery` on `message(action='attach')` toolResult
|
|
6
|
+
* entries; visible to operators inspecting JSONL but NOT injected back into the
|
|
7
|
+
* model's context window across turns.
|
|
8
|
+
*
|
|
9
|
+
* Plain TypeScript interface (no Zod) per AGENTS §2.3 KISS — `@comis/shared`
|
|
10
|
+
* has zero runtime deps, and this type is JSONL-persisted only (no port-bus
|
|
11
|
+
* payload validation needed).
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/** Kind of visible delivery captured. Open-ended union for forward extensibility. */
|
|
16
|
+
export type VisibleDeliveryKind = "attachment" | "text" | "reaction";
|
|
17
|
+
export interface VisibleDeliveryRecord {
|
|
18
|
+
/** What kind of delivery this records. */
|
|
19
|
+
kind: VisibleDeliveryKind;
|
|
20
|
+
/** Channel adapter that delivered (e.g., "telegram"). */
|
|
21
|
+
channelType: string;
|
|
22
|
+
/** Channel-specific identifier (e.g., user/group/peer id). */
|
|
23
|
+
channelId: string;
|
|
24
|
+
/** Human-readable caption for attachments; brief text for text/reaction. */
|
|
25
|
+
caption?: string;
|
|
26
|
+
/** Wall-clock millis when delivery completed (Date.now()). */
|
|
27
|
+
deliveredAt: number;
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* VisibleDeliveryRecord: structured metadata for outbound channel deliveries
|
|
4
|
+
* captured in JSONL `details` for offline analysis (output retention housekeeper consumes this).
|
|
5
|
+
*
|
|
6
|
+
* Persisted in `details.visibleDelivery` on `message(action='attach')` toolResult
|
|
7
|
+
* entries; visible to operators inspecting JSONL but NOT injected back into the
|
|
8
|
+
* model's context window across turns.
|
|
9
|
+
*
|
|
10
|
+
* Plain TypeScript interface (no Zod) per AGENTS §2.3 KISS — `@comis/shared`
|
|
11
|
+
* has zero runtime deps, and this type is JSONL-persisted only (no port-bus
|
|
12
|
+
* payload validation needed).
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -13,24 +13,14 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
15
15
|
import { type TSchema } from "typebox";
|
|
16
|
+
import { extractMcpServerName } from "@comis/shared";
|
|
17
|
+
export { extractMcpServerName };
|
|
16
18
|
import { type ToolSourceProfile } from "../builtin/tool-source-profiles.js";
|
|
17
19
|
import type { McpToolDefinition, McpClientManager } from "../integrations/mcp-client.js";
|
|
18
20
|
/** Minimal pino-compatible logger for MCP bridge diagnostic logging. */
|
|
19
21
|
interface McpBridgeLogger {
|
|
20
22
|
debug(obj: Record<string, unknown>, msg: string): void;
|
|
21
23
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Extract the MCP server name from a sanitized tool name.
|
|
24
|
-
*
|
|
25
|
-
* Sanitized MCP tool names use the format `mcp__serverName--toolName`.
|
|
26
|
-
* Returns `undefined` for non-MCP tools or malformed names.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* extractMcpServerName("mcp__context7--resolve-library-id") // "context7"
|
|
30
|
-
* extractMcpServerName("mcp__srv__v2--ns--tool") // "srv__v2"
|
|
31
|
-
* extractMcpServerName("bash") // undefined
|
|
32
|
-
*/
|
|
33
|
-
export declare function extractMcpServerName(toolName: string): string | undefined;
|
|
34
24
|
/**
|
|
35
25
|
* Classify an MCP error message into a category for observability.
|
|
36
26
|
*
|
|
@@ -78,4 +68,3 @@ export declare function sanitizeMcpToolName(qualifiedName: string): string;
|
|
|
78
68
|
* @returns AgentTool instances ready for the agent executor
|
|
79
69
|
*/
|
|
80
70
|
export declare function mcpToolsToAgentTools(tools: McpToolDefinition[], callTool: McpClientManager["callTool"], toolSourceProfiles?: Record<string, Partial<ToolSourceProfile>>, logger?: McpBridgeLogger): AgentTool<any>[];
|
|
81
|
-
export {};
|
|
@@ -14,32 +14,14 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { Type } from "typebox";
|
|
16
16
|
import { registerToolMetadata } from "@comis/core";
|
|
17
|
+
import { extractMcpServerName } from "@comis/shared";
|
|
18
|
+
export { extractMcpServerName };
|
|
17
19
|
import { resolveSourceProfile } from "../builtin/tool-source-profiles.js";
|
|
18
20
|
import { sanitizeMcpToolResult } from "../integrations/mcp-result-sanitizer.js";
|
|
19
21
|
import { truncateJsonAware } from "./json-truncate.js";
|
|
20
22
|
// ---------------------------------------------------------------------------
|
|
21
|
-
// MCP
|
|
23
|
+
// MCP error classification
|
|
22
24
|
// ---------------------------------------------------------------------------
|
|
23
|
-
/**
|
|
24
|
-
* Extract the MCP server name from a sanitized tool name.
|
|
25
|
-
*
|
|
26
|
-
* Sanitized MCP tool names use the format `mcp__serverName--toolName`.
|
|
27
|
-
* Returns `undefined` for non-MCP tools or malformed names.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* extractMcpServerName("mcp__context7--resolve-library-id") // "context7"
|
|
31
|
-
* extractMcpServerName("mcp__srv__v2--ns--tool") // "srv__v2"
|
|
32
|
-
* extractMcpServerName("bash") // undefined
|
|
33
|
-
*/
|
|
34
|
-
export function extractMcpServerName(toolName) {
|
|
35
|
-
if (!toolName.startsWith("mcp__"))
|
|
36
|
-
return undefined;
|
|
37
|
-
const rest = toolName.slice(5); // strip "mcp__"
|
|
38
|
-
const sepIdx = rest.indexOf("--");
|
|
39
|
-
if (sepIdx <= 0)
|
|
40
|
-
return undefined; // no separator or empty server name
|
|
41
|
-
return rest.slice(0, sepIdx);
|
|
42
|
-
}
|
|
43
25
|
/**
|
|
44
26
|
* Classify an MCP error message into a category for observability.
|
|
45
27
|
*
|
|
@@ -61,7 +61,7 @@ export function wrapWithMetadataEnforcement(tool) {
|
|
|
61
61
|
...tool,
|
|
62
62
|
async execute(toolCallId, params, signal, onUpdate) {
|
|
63
63
|
const meta = getToolMetadata(tool.name);
|
|
64
|
-
// Generic tool-entry schema validation
|
|
64
|
+
// Generic tool-entry schema validation.
|
|
65
65
|
// Runs BEFORE per-tool validateInput so action-shape errors short-circuit
|
|
66
66
|
// before tool-specific business rules. Skips silently when the tool has
|
|
67
67
|
// not registered validActions / validKeys / requiredByAction.
|
|
@@ -150,11 +150,11 @@ export function registerAllToolMetadata() {
|
|
|
150
150
|
});
|
|
151
151
|
// Gateway tool -- action enum + immutable path rejection for patch and apply.
|
|
152
152
|
// Whitelist is derived from the tool's exported GATEWAY_ACTIONS tuple so
|
|
153
|
-
// bridge + handler cannot drift
|
|
153
|
+
// bridge + handler cannot drift.
|
|
154
154
|
// When the rejected section has a dedicated *_manage tool, the message
|
|
155
155
|
// includes a parameter-correct redirect via formatRedirectHint() so any
|
|
156
156
|
// LLM (Opus/Sonnet/Haiku, GPT-5, Gemini, Mistral, etc.) can self-recover
|
|
157
|
-
// without model-specific prompting
|
|
157
|
+
// without model-specific prompting.
|
|
158
158
|
registerToolMetadata("gateway", {
|
|
159
159
|
validateInput: (params) => {
|
|
160
160
|
const action = typeof params.action === "string" ? params.action : undefined;
|
|
@@ -188,7 +188,7 @@ export function registerAllToolMetadata() {
|
|
|
188
188
|
},
|
|
189
189
|
});
|
|
190
190
|
// =========================================================================
|
|
191
|
-
// Tool-Entry Schema
|
|
191
|
+
// Tool-Entry Schema
|
|
192
192
|
//
|
|
193
193
|
// Generic action enum + valid keys + per-action required fields. Consumed
|
|
194
194
|
// by validateToolEntry() in ./schema-validator.ts via
|
|
@@ -485,7 +485,7 @@ export function registerAllToolMetadata() {
|
|
|
485
485
|
registerToolMetadata("mcp_manage", { searchHint: "mcp server protocol connect disconnect tool external" });
|
|
486
486
|
registerToolMetadata("heartbeat_manage", { searchHint: "heartbeat keepalive watchdog health probe interval alive" });
|
|
487
487
|
// =========================================================================
|
|
488
|
-
// Co-discovery Relationships
|
|
488
|
+
// Co-discovery Relationships
|
|
489
489
|
// =========================================================================
|
|
490
490
|
// Model switching requires both models_manage (catalog) and agents_manage (apply model to agent)
|
|
491
491
|
registerToolMetadata("models_manage", { coDiscoverWith: ["agents_manage"] });
|