comisai 1.0.19 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-entry.js +0 -0
- package/node_modules/@comis/agent/dist/context-engine/context-engine.js +43 -2
- package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.d.ts +51 -0
- package/node_modules/@comis/agent/dist/context-engine/signature-replay-scrubber.js +110 -0
- package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.d.ts +54 -0
- package/node_modules/@comis/agent/dist/context-engine/signature-surrogate-guard.js +145 -0
- package/node_modules/@comis/agent/dist/context-engine/types-core.d.ts +17 -0
- package/node_modules/@comis/agent/dist/executor/error-classifier.d.ts +11 -1
- package/node_modules/@comis/agent/dist/executor/error-classifier.js +13 -0
- package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.d.ts +1 -0
- package/node_modules/@comis/agent/dist/executor/executor-context-engine-setup.js +55 -0
- package/node_modules/@comis/agent/dist/executor/executor-prompt-runner.js +106 -5
- package/node_modules/@comis/agent/dist/executor/executor-tool-assembly.js +1 -0
- package/node_modules/@comis/agent/dist/executor/pi-executor.d.ts +1 -4
- package/node_modules/@comis/agent/dist/executor/pi-executor.js +30 -3
- package/node_modules/@comis/agent/dist/executor/replay-drift-detector.d.ts +85 -0
- package/node_modules/@comis/agent/dist/executor/replay-drift-detector.js +92 -0
- package/node_modules/@comis/agent/dist/executor/signature-block-scrubber.d.ts +34 -0
- package/node_modules/@comis/agent/dist/executor/signature-block-scrubber.js +69 -0
- package/node_modules/@comis/agent/dist/executor/signed-replay-detector.d.ts +39 -0
- package/node_modules/@comis/agent/dist/executor/signed-replay-detector.js +72 -0
- package/node_modules/@comis/agent/package.json +1 -1
- package/node_modules/@comis/channels/package.json +1 -1
- package/node_modules/@comis/cli/dist/cli.js +0 -0
- package/node_modules/@comis/cli/package.json +1 -1
- package/node_modules/@comis/core/dist/config/git-manager.js +10 -4
- package/node_modules/@comis/core/dist/config/index.d.ts +1 -0
- package/node_modules/@comis/core/dist/config/index.js +2 -0
- package/node_modules/@comis/core/dist/config/managed-sections.d.ts +67 -0
- package/node_modules/@comis/core/dist/config/managed-sections.js +124 -0
- package/node_modules/@comis/core/dist/config/schema-agent.d.ts +28 -10
- package/node_modules/@comis/core/dist/config/schema-agent.js +6 -0
- package/node_modules/@comis/core/dist/config/schema-gateway.d.ts +2 -2
- package/node_modules/@comis/core/dist/config/schema.d.ts +65 -64
- package/node_modules/@comis/core/dist/event-bus/events-messaging.d.ts +16 -0
- package/node_modules/@comis/core/dist/exports/config.d.ts +1 -1
- package/node_modules/@comis/core/dist/exports/config.js +1 -1
- package/node_modules/@comis/core/package.json +1 -1
- package/node_modules/@comis/daemon/bundled-skills/skill-creator/scripts/init-skill.py +0 -0
- package/node_modules/@comis/daemon/bundled-skills/skill-creator/scripts/validate-skill.py +0 -0
- package/node_modules/@comis/daemon/dist/daemon.js +11 -4
- package/node_modules/@comis/daemon/dist/rpc/config-handlers.js +20 -7
- package/node_modules/@comis/daemon/dist/rpc/session-handlers.js +27 -1
- package/node_modules/@comis/daemon/dist/wiring/setup-gateway.d.ts +22 -0
- package/node_modules/@comis/daemon/dist/wiring/setup-gateway.js +34 -8
- package/node_modules/@comis/daemon/dist/wiring/setup-tools.js +14 -1
- package/node_modules/@comis/daemon/package.json +1 -1
- package/node_modules/@comis/gateway/package.json +1 -1
- package/node_modules/@comis/infra/dist/logging/log-fields.d.ts +2 -2
- package/node_modules/@comis/infra/package.json +1 -1
- package/node_modules/@comis/memory/package.json +1 -1
- package/node_modules/@comis/scheduler/package.json +1 -1
- package/node_modules/@comis/shared/package.json +1 -1
- package/node_modules/@comis/skills/dist/bridge/tool-metadata-registry.js +23 -8
- package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.d.ts +1 -1
- package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.js +18 -14
- package/node_modules/@comis/skills/dist/builtin/platform/unified-session-tool.js +1 -1
- package/node_modules/@comis/skills/dist/builtin/sandbox/detect-provider.d.ts +1 -0
- package/node_modules/@comis/skills/dist/builtin/sandbox/detect-provider.js +78 -5
- package/node_modules/@comis/skills/package.json +1 -1
- package/node_modules/@comis/web/package.json +1 -1
- package/package.json +24 -26
- package/node_modules/@comis/agent/dist/provider/response/strip-minimax-xml.d.ts +0 -9
- package/node_modules/@comis/agent/dist/provider/response/strip-minimax-xml.js +0 -17
- package/node_modules/@comis/agent/dist/provider/response/strip-model-tokens.d.ts +0 -13
- package/node_modules/@comis/agent/dist/provider/response/strip-model-tokens.js +0 -19
- package/node_modules/@comis/agent/dist/provider/response/strip-tool-text.d.ts +0 -11
- package/node_modules/@comis/agent/dist/provider/response/strip-tool-text.js +0 -32
- package/node_modules/@comis/agent/dist/safety/follow-through-detector.d.ts +0 -46
- package/node_modules/@comis/agent/dist/safety/follow-through-detector.js +0 -76
- package/node_modules/@comis/agent/dist/safety/post-compaction-safety.d.ts +0 -30
- package/node_modules/@comis/agent/dist/safety/post-compaction-safety.js +0 -51
- package/node_modules/@comis/agent/dist/safety/schema-normalizer.d.ts +0 -37
- package/node_modules/@comis/agent/dist/safety/schema-normalizer.js +0 -137
- package/node_modules/@comis/agent/dist/safety/schema-pruning.d.ts +0 -50
- package/node_modules/@comis/agent/dist/safety/schema-pruning.js +0 -112
- package/node_modules/@comis/agent/dist/safety/tool-image-sanitizer.d.ts +0 -43
- package/node_modules/@comis/agent/dist/safety/tool-image-sanitizer.js +0 -96
- package/node_modules/@comis/agent/dist/safety/tool-sanitizer.d.ts +0 -44
- package/node_modules/@comis/agent/dist/safety/tool-sanitizer.js +0 -94
- package/node_modules/@comis/channels/dist/shared/thinking-tag-filter.d.ts +0 -28
- package/node_modules/@comis/channels/dist/shared/thinking-tag-filter.js +0 -206
- package/node_modules/@comis/cli/dist/wizard/config-writer.d.ts +0 -25
- package/node_modules/@comis/cli/dist/wizard/config-writer.js +0 -144
- package/node_modules/@comis/cli/dist/wizard/flow-types.d.ts +0 -48
- package/node_modules/@comis/cli/dist/wizard/flow-types.js +0 -70
- package/node_modules/@comis/cli/dist/wizard/manual-flow.d.ts +0 -21
- package/node_modules/@comis/cli/dist/wizard/manual-flow.js +0 -345
- package/node_modules/@comis/cli/dist/wizard/quickstart-flow.d.ts +0 -21
- package/node_modules/@comis/cli/dist/wizard/quickstart-flow.js +0 -116
- package/node_modules/@comis/core/dist/config/schema-agent-model.d.ts +0 -135
- package/node_modules/@comis/core/dist/config/schema-agent-model.js +0 -114
- package/node_modules/@comis/core/dist/config/schema-agent-session.d.ts +0 -177
- package/node_modules/@comis/core/dist/config/schema-agent-session.js +0 -116
- package/node_modules/@comis/core/dist/config/schema-context-engine.d.ts +0 -92
- package/node_modules/@comis/core/dist/config/schema-context-engine.js +0 -92
- package/node_modules/@comis/core/dist/config/schema-context-guard.d.ts +0 -34
- package/node_modules/@comis/core/dist/config/schema-context-guard.js +0 -32
- package/node_modules/@comis/core/dist/config/schema-delivery-mirror.d.ts +0 -27
- package/node_modules/@comis/core/dist/config/schema-delivery-mirror.js +0 -26
- package/node_modules/@comis/core/dist/config/schema-delivery-queue.d.ts +0 -31
- package/node_modules/@comis/core/dist/config/schema-delivery-queue.js +0 -30
- package/node_modules/@comis/core/dist/config/schema-delivery-timing.d.ts +0 -41
- package/node_modules/@comis/core/dist/config/schema-delivery-timing.js +0 -31
- package/node_modules/@comis/core/dist/config/schema-monitoring.d.ts +0 -105
- package/node_modules/@comis/core/dist/config/schema-monitoring.js +0 -67
- package/node_modules/@comis/core/dist/ports/media-ports.d.ts +0 -278
- package/node_modules/@comis/core/dist/ports/media-ports.js +0 -1
- package/node_modules/@comis/core/dist/security/input-guard.d.ts +0 -46
- package/node_modules/@comis/core/dist/security/input-guard.js +0 -166
- package/node_modules/@comis/core/dist/security/scoped-secret-manager.d.ts +0 -38
- package/node_modules/@comis/core/dist/security/scoped-secret-manager.js +0 -94
- package/node_modules/@comis/daemon/dist/observability/delivery-context.d.ts +0 -37
- package/node_modules/@comis/daemon/dist/observability/delivery-context.js +0 -1
- package/node_modules/@comis/daemon/dist/observability/log-level-manager.d.ts +0 -23
- package/node_modules/@comis/daemon/dist/observability/log-level-manager.js +0 -34
- package/node_modules/@comis/daemon/dist/observability/log-transport.d.ts +0 -44
- package/node_modules/@comis/daemon/dist/observability/log-transport.js +0 -74
- package/node_modules/@comis/daemon/dist/observability/obs-write-buffer.d.ts +0 -53
- package/node_modules/@comis/daemon/dist/observability/obs-write-buffer.js +0 -68
- package/node_modules/@comis/daemon/dist/observability/types.d.ts +0 -6
- package/node_modules/@comis/daemon/dist/observability/types.js +0 -1
- package/node_modules/@comis/daemon/dist/wiring/seed-bundled-skills.d.ts +0 -41
- package/node_modules/@comis/daemon/dist/wiring/seed-bundled-skills.js +0 -84
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery-mirror.d.ts +0 -24
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery-mirror.js +0 -88
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery-queue.d.ts +0 -31
- package/node_modules/@comis/daemon/dist/wiring/setup-delivery-queue.js +0 -132
- package/node_modules/@comis/daemon/dist/wiring/setup-monitoring.d.ts +0 -38
- package/node_modules/@comis/daemon/dist/wiring/setup-monitoring.js +0 -100
- package/node_modules/@comis/daemon/dist/wiring/setup-rpc-bridge.d.ts +0 -34
- package/node_modules/@comis/daemon/dist/wiring/setup-rpc-bridge.js +0 -52
- package/node_modules/@comis/daemon/dist/wiring/setup-task-extraction.d.ts +0 -41
- package/node_modules/@comis/daemon/dist/wiring/setup-task-extraction.js +0 -86
- package/node_modules/@comis/memory/dist/embedding-cache.d.ts +0 -36
- package/node_modules/@comis/memory/dist/embedding-cache.js +0 -94
- package/node_modules/@comis/skills/dist/bridge/tool-output-schemas.d.ts +0 -17
- package/node_modules/@comis/skills/dist/bridge/tool-output-schemas.js +0 -125
- package/node_modules/@comis/skills/dist/bridge/tool-parallelism-metadata.d.ts +0 -14
- package/node_modules/@comis/skills/dist/bridge/tool-parallelism-metadata.js +0 -92
- package/node_modules/@comis/skills/dist/bridge/tool-result-caps.d.ts +0 -14
- package/node_modules/@comis/skills/dist/bridge/tool-result-caps.js +0 -36
- package/node_modules/@comis/skills/dist/bridge/tool-search-hints.d.ts +0 -15
- package/node_modules/@comis/skills/dist/bridge/tool-search-hints.js +0 -68
- package/node_modules/@comis/skills/dist/bridge/tool-validators.d.ts +0 -11
- package/node_modules/@comis/skills/dist/bridge/tool-validators.js +0 -105
- package/node_modules/@comis/skills/dist/builtin/file/find-sort-wrapper.d.ts +0 -22
- package/node_modules/@comis/skills/dist/builtin/file/find-sort-wrapper.js +0 -95
- package/node_modules/@comis/skills/dist/builtin/file/grep-output-mode-wrapper.d.ts +0 -24
- package/node_modules/@comis/skills/dist/builtin/file/grep-output-mode-wrapper.js +0 -167
- package/node_modules/@comis/skills/dist/builtin/task-plan-tool.d.ts +0 -25
- package/node_modules/@comis/skills/dist/builtin/task-plan-tool.js +0 -67
- package/node_modules/@comis/skills/dist/integrations/mcp-tool-bridge.d.ts +0 -75
- package/node_modules/@comis/skills/dist/integrations/mcp-tool-bridge.js +0 -235
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delivery mirror configuration schema.
|
|
3
|
-
*
|
|
4
|
-
* Defines settings for the session mirroring persistence layer:
|
|
5
|
-
* enable/disable, retention, pruning, and injection limits.
|
|
6
|
-
*
|
|
7
|
-
* Phase 502: Session Mirroring.
|
|
8
|
-
*/
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
/**
|
|
11
|
-
* DeliveryMirrorConfigSchema -- validated configuration for the delivery mirror.
|
|
12
|
-
*
|
|
13
|
-
* All fields have sensible defaults so an empty object produces a valid config.
|
|
14
|
-
*/
|
|
15
|
-
export declare const DeliveryMirrorConfigSchema: z.ZodObject<{
|
|
16
|
-
/** Whether the delivery mirror is enabled. When false, no entries are recorded. */
|
|
17
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
-
/** Maximum age in milliseconds before mirror entries are pruned (24 hours). */
|
|
19
|
-
retentionMs: z.ZodDefault<z.ZodNumber>;
|
|
20
|
-
/** Interval in milliseconds between automatic prune sweeps (5 minutes). */
|
|
21
|
-
pruneIntervalMs: z.ZodDefault<z.ZodNumber>;
|
|
22
|
-
/** Maximum number of mirror entries injected per prompt turn. */
|
|
23
|
-
maxEntriesPerInjection: z.ZodDefault<z.ZodNumber>;
|
|
24
|
-
/** Maximum total characters of mirror text injected per prompt turn. */
|
|
25
|
-
maxCharsPerInjection: z.ZodDefault<z.ZodNumber>;
|
|
26
|
-
}, z.core.$strict>;
|
|
27
|
-
export type DeliveryMirrorConfig = z.infer<typeof DeliveryMirrorConfigSchema>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delivery mirror configuration schema.
|
|
3
|
-
*
|
|
4
|
-
* Defines settings for the session mirroring persistence layer:
|
|
5
|
-
* enable/disable, retention, pruning, and injection limits.
|
|
6
|
-
*
|
|
7
|
-
* Phase 502: Session Mirroring.
|
|
8
|
-
*/
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
/**
|
|
11
|
-
* DeliveryMirrorConfigSchema -- validated configuration for the delivery mirror.
|
|
12
|
-
*
|
|
13
|
-
* All fields have sensible defaults so an empty object produces a valid config.
|
|
14
|
-
*/
|
|
15
|
-
export const DeliveryMirrorConfigSchema = z.strictObject({
|
|
16
|
-
/** Whether the delivery mirror is enabled. When false, no entries are recorded. */
|
|
17
|
-
enabled: z.boolean().default(true),
|
|
18
|
-
/** Maximum age in milliseconds before mirror entries are pruned (24 hours). */
|
|
19
|
-
retentionMs: z.number().int().positive().default(86_400_000),
|
|
20
|
-
/** Interval in milliseconds between automatic prune sweeps (5 minutes). */
|
|
21
|
-
pruneIntervalMs: z.number().int().positive().default(300_000),
|
|
22
|
-
/** Maximum number of mirror entries injected per prompt turn. */
|
|
23
|
-
maxEntriesPerInjection: z.number().int().positive().default(10),
|
|
24
|
-
/** Maximum total characters of mirror text injected per prompt turn. */
|
|
25
|
-
maxCharsPerInjection: z.number().int().positive().default(4000),
|
|
26
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delivery queue configuration schema.
|
|
3
|
-
*
|
|
4
|
-
* Defines settings for the crash-safe outbound delivery queue:
|
|
5
|
-
* enable/disable, depth limits, retry policy, drain behavior, and pruning.
|
|
6
|
-
*
|
|
7
|
-
* Phase 499: Crash-Safe Delivery Queue.
|
|
8
|
-
*/
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
/**
|
|
11
|
-
* DeliveryQueueConfigSchema -- validated configuration for the delivery queue.
|
|
12
|
-
*
|
|
13
|
-
* All fields have sensible defaults so an empty object produces a valid config.
|
|
14
|
-
*/
|
|
15
|
-
export declare const DeliveryQueueConfigSchema: z.ZodObject<{
|
|
16
|
-
/** Whether the delivery queue is enabled. When false, messages bypass persistence. */
|
|
17
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
-
/** Maximum number of entries allowed in the queue. Enqueue rejects when full. */
|
|
19
|
-
maxQueueDepth: z.ZodDefault<z.ZodNumber>;
|
|
20
|
-
/** Default maximum delivery attempts before marking an entry as failed. */
|
|
21
|
-
defaultMaxAttempts: z.ZodDefault<z.ZodNumber>;
|
|
22
|
-
/** Default time-to-live in milliseconds before an entry expires (1 hour). */
|
|
23
|
-
defaultExpireMs: z.ZodDefault<z.ZodNumber>;
|
|
24
|
-
/** Whether to drain pending entries on daemon startup (crash recovery). */
|
|
25
|
-
drainOnStartup: z.ZodDefault<z.ZodBoolean>;
|
|
26
|
-
/** Maximum time in milliseconds allowed for startup drain before continuing. */
|
|
27
|
-
drainBudgetMs: z.ZodDefault<z.ZodNumber>;
|
|
28
|
-
/** Interval in milliseconds between automatic prune sweeps for expired entries. */
|
|
29
|
-
pruneIntervalMs: z.ZodDefault<z.ZodNumber>;
|
|
30
|
-
}, z.core.$strict>;
|
|
31
|
-
export type DeliveryQueueConfig = z.infer<typeof DeliveryQueueConfigSchema>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delivery queue configuration schema.
|
|
3
|
-
*
|
|
4
|
-
* Defines settings for the crash-safe outbound delivery queue:
|
|
5
|
-
* enable/disable, depth limits, retry policy, drain behavior, and pruning.
|
|
6
|
-
*
|
|
7
|
-
* Phase 499: Crash-Safe Delivery Queue.
|
|
8
|
-
*/
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
/**
|
|
11
|
-
* DeliveryQueueConfigSchema -- validated configuration for the delivery queue.
|
|
12
|
-
*
|
|
13
|
-
* All fields have sensible defaults so an empty object produces a valid config.
|
|
14
|
-
*/
|
|
15
|
-
export const DeliveryQueueConfigSchema = z.strictObject({
|
|
16
|
-
/** Whether the delivery queue is enabled. When false, messages bypass persistence. */
|
|
17
|
-
enabled: z.boolean().default(true),
|
|
18
|
-
/** Maximum number of entries allowed in the queue. Enqueue rejects when full. */
|
|
19
|
-
maxQueueDepth: z.number().int().positive().default(10_000),
|
|
20
|
-
/** Default maximum delivery attempts before marking an entry as failed. */
|
|
21
|
-
defaultMaxAttempts: z.number().int().positive().default(5),
|
|
22
|
-
/** Default time-to-live in milliseconds before an entry expires (1 hour). */
|
|
23
|
-
defaultExpireMs: z.number().int().positive().default(3_600_000),
|
|
24
|
-
/** Whether to drain pending entries on daemon startup (crash recovery). */
|
|
25
|
-
drainOnStartup: z.boolean().default(true),
|
|
26
|
-
/** Maximum time in milliseconds allowed for startup drain before continuing. */
|
|
27
|
-
drainBudgetMs: z.number().int().positive().default(60_000),
|
|
28
|
-
/** Interval in milliseconds between automatic prune sweeps for expired entries. */
|
|
29
|
-
pruneIntervalMs: z.number().int().positive().default(300_000),
|
|
30
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* Delivery timing mode determines how inter-block delays are calculated.
|
|
4
|
-
*
|
|
5
|
-
* - `off`: No delay between blocks (instant delivery)
|
|
6
|
-
* - `natural`: Human-like typing delay based on block length
|
|
7
|
-
* - `custom`: Fixed delay range (minMs..maxMs + jitter)
|
|
8
|
-
* - `adaptive`: Adjusts delay based on conversation pace and block complexity
|
|
9
|
-
*/
|
|
10
|
-
export declare const DeliveryTimingModeSchema: z.ZodDefault<z.ZodEnum<{
|
|
11
|
-
off: "off";
|
|
12
|
-
custom: "custom";
|
|
13
|
-
natural: "natural";
|
|
14
|
-
adaptive: "adaptive";
|
|
15
|
-
}>>;
|
|
16
|
-
/**
|
|
17
|
-
* Delivery timing configuration schema.
|
|
18
|
-
*
|
|
19
|
-
* Controls the pacing of block-by-block message delivery to simulate
|
|
20
|
-
* natural typing rhythm. Applies after the coalescer flushes a block
|
|
21
|
-
* and before the channel adapter sends it.
|
|
22
|
-
*/
|
|
23
|
-
export declare const DeliveryTimingConfigSchema: z.ZodObject<{
|
|
24
|
-
/** Timing mode: off, natural, custom, or adaptive */
|
|
25
|
-
mode: z.ZodDefault<z.ZodEnum<{
|
|
26
|
-
off: "off";
|
|
27
|
-
custom: "custom";
|
|
28
|
-
natural: "natural";
|
|
29
|
-
adaptive: "adaptive";
|
|
30
|
-
}>>;
|
|
31
|
-
/** Minimum delay (ms) between block deliveries */
|
|
32
|
-
minMs: z.ZodDefault<z.ZodNumber>;
|
|
33
|
-
/** Maximum delay (ms) between block deliveries */
|
|
34
|
-
maxMs: z.ZodDefault<z.ZodNumber>;
|
|
35
|
-
/** Random jitter (ms) added to each delay for natural feel */
|
|
36
|
-
jitterMs: z.ZodDefault<z.ZodNumber>;
|
|
37
|
-
/** Extra delay (ms) before delivering the first block of a response */
|
|
38
|
-
firstBlockDelayMs: z.ZodDefault<z.ZodNumber>;
|
|
39
|
-
}, z.core.$strict>;
|
|
40
|
-
export type DeliveryTimingConfig = z.infer<typeof DeliveryTimingConfigSchema>;
|
|
41
|
-
export type DeliveryTimingMode = z.infer<typeof DeliveryTimingModeSchema>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* Delivery timing mode determines how inter-block delays are calculated.
|
|
4
|
-
*
|
|
5
|
-
* - `off`: No delay between blocks (instant delivery)
|
|
6
|
-
* - `natural`: Human-like typing delay based on block length
|
|
7
|
-
* - `custom`: Fixed delay range (minMs..maxMs + jitter)
|
|
8
|
-
* - `adaptive`: Adjusts delay based on conversation pace and block complexity
|
|
9
|
-
*/
|
|
10
|
-
export const DeliveryTimingModeSchema = z
|
|
11
|
-
.enum(["off", "natural", "custom", "adaptive"])
|
|
12
|
-
.default("natural");
|
|
13
|
-
/**
|
|
14
|
-
* Delivery timing configuration schema.
|
|
15
|
-
*
|
|
16
|
-
* Controls the pacing of block-by-block message delivery to simulate
|
|
17
|
-
* natural typing rhythm. Applies after the coalescer flushes a block
|
|
18
|
-
* and before the channel adapter sends it.
|
|
19
|
-
*/
|
|
20
|
-
export const DeliveryTimingConfigSchema = z.strictObject({
|
|
21
|
-
/** Timing mode: off, natural, custom, or adaptive */
|
|
22
|
-
mode: DeliveryTimingModeSchema,
|
|
23
|
-
/** Minimum delay (ms) between block deliveries */
|
|
24
|
-
minMs: z.number().int().nonnegative().default(800),
|
|
25
|
-
/** Maximum delay (ms) between block deliveries */
|
|
26
|
-
maxMs: z.number().int().nonnegative().default(2500),
|
|
27
|
-
/** Random jitter (ms) added to each delay for natural feel */
|
|
28
|
-
jitterMs: z.number().int().nonnegative().default(200),
|
|
29
|
-
/** Extra delay (ms) before delivering the first block of a response */
|
|
30
|
-
firstBlockDelayMs: z.number().int().nonnegative().default(0),
|
|
31
|
-
});
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* Monitoring configuration schemas.
|
|
4
|
-
*
|
|
5
|
-
* Defines thresholds and settings for system monitoring heartbeat sources:
|
|
6
|
-
* disk space, CPU/memory resources, systemd services, security updates,
|
|
7
|
-
* and git repository watching.
|
|
8
|
-
*
|
|
9
|
-
* MON-01: Disk space monitoring
|
|
10
|
-
* MON-02: Resource utilization monitoring
|
|
11
|
-
* MON-03: Service health monitoring
|
|
12
|
-
* MON-04: Security update and git repo monitoring
|
|
13
|
-
*/
|
|
14
|
-
declare const DiskMonitorSchema: z.ZodObject<{
|
|
15
|
-
/** Whether disk space monitoring is enabled. */
|
|
16
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
17
|
-
/** Filesystem paths to monitor. */
|
|
18
|
-
paths: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
19
|
-
/** Alert when usage exceeds this percentage. */
|
|
20
|
-
thresholdPercent: z.ZodDefault<z.ZodNumber>;
|
|
21
|
-
}, z.core.$strict>;
|
|
22
|
-
declare const ResourceMonitorSchema: z.ZodObject<{
|
|
23
|
-
/** Whether CPU/memory monitoring is enabled. */
|
|
24
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
25
|
-
/** Alert when CPU usage exceeds this percentage. */
|
|
26
|
-
cpuThresholdPercent: z.ZodDefault<z.ZodNumber>;
|
|
27
|
-
/** Alert when memory usage exceeds this percentage. */
|
|
28
|
-
memoryThresholdPercent: z.ZodDefault<z.ZodNumber>;
|
|
29
|
-
}, z.core.$strict>;
|
|
30
|
-
declare const SystemdMonitorSchema: z.ZodObject<{
|
|
31
|
-
/** Whether systemd service monitoring is enabled. */
|
|
32
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
33
|
-
/** Specific services to monitor (empty = check all failed). */
|
|
34
|
-
services: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
35
|
-
}, z.core.$strict>;
|
|
36
|
-
declare const SecurityUpdateMonitorSchema: z.ZodObject<{
|
|
37
|
-
/** Whether security update monitoring is enabled. */
|
|
38
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
39
|
-
/** Only check for security updates (not all updates). */
|
|
40
|
-
securityOnly: z.ZodDefault<z.ZodBoolean>;
|
|
41
|
-
}, z.core.$strict>;
|
|
42
|
-
declare const GitMonitorSchema: z.ZodObject<{
|
|
43
|
-
/** Whether git repository monitoring is enabled (default: off). */
|
|
44
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
45
|
-
/** Absolute paths to git repositories to monitor. */
|
|
46
|
-
repositories: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
47
|
-
/** Check remote for unpushed commits. */
|
|
48
|
-
checkRemote: z.ZodDefault<z.ZodBoolean>;
|
|
49
|
-
}, z.core.$strict>;
|
|
50
|
-
/**
|
|
51
|
-
* Root monitoring configuration schema.
|
|
52
|
-
*
|
|
53
|
-
* Each sub-section has sensible defaults so an empty object
|
|
54
|
-
* produces a valid MonitoringConfig.
|
|
55
|
-
*/
|
|
56
|
-
export declare const MonitoringConfigSchema: z.ZodObject<{
|
|
57
|
-
/** Disk space monitoring. */
|
|
58
|
-
disk: z.ZodDefault<z.ZodObject<{
|
|
59
|
-
/** Whether disk space monitoring is enabled. */
|
|
60
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
61
|
-
/** Filesystem paths to monitor. */
|
|
62
|
-
paths: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
63
|
-
/** Alert when usage exceeds this percentage. */
|
|
64
|
-
thresholdPercent: z.ZodDefault<z.ZodNumber>;
|
|
65
|
-
}, z.core.$strict>>;
|
|
66
|
-
/** CPU and memory monitoring. */
|
|
67
|
-
resources: z.ZodDefault<z.ZodObject<{
|
|
68
|
-
/** Whether CPU/memory monitoring is enabled. */
|
|
69
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
70
|
-
/** Alert when CPU usage exceeds this percentage. */
|
|
71
|
-
cpuThresholdPercent: z.ZodDefault<z.ZodNumber>;
|
|
72
|
-
/** Alert when memory usage exceeds this percentage. */
|
|
73
|
-
memoryThresholdPercent: z.ZodDefault<z.ZodNumber>;
|
|
74
|
-
}, z.core.$strict>>;
|
|
75
|
-
/** systemd service health monitoring. */
|
|
76
|
-
systemd: z.ZodDefault<z.ZodObject<{
|
|
77
|
-
/** Whether systemd service monitoring is enabled. */
|
|
78
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
79
|
-
/** Specific services to monitor (empty = check all failed). */
|
|
80
|
-
services: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
81
|
-
}, z.core.$strict>>;
|
|
82
|
-
/** Security update monitoring. */
|
|
83
|
-
securityUpdates: z.ZodDefault<z.ZodObject<{
|
|
84
|
-
/** Whether security update monitoring is enabled. */
|
|
85
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
86
|
-
/** Only check for security updates (not all updates). */
|
|
87
|
-
securityOnly: z.ZodDefault<z.ZodBoolean>;
|
|
88
|
-
}, z.core.$strict>>;
|
|
89
|
-
/** Git repository monitoring. */
|
|
90
|
-
git: z.ZodDefault<z.ZodObject<{
|
|
91
|
-
/** Whether git repository monitoring is enabled (default: off). */
|
|
92
|
-
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
93
|
-
/** Absolute paths to git repositories to monitor. */
|
|
94
|
-
repositories: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
95
|
-
/** Check remote for unpushed commits. */
|
|
96
|
-
checkRemote: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
-
}, z.core.$strict>>;
|
|
98
|
-
}, z.core.$strict>;
|
|
99
|
-
export type MonitoringConfig = z.infer<typeof MonitoringConfigSchema>;
|
|
100
|
-
export type DiskMonitorConfig = z.infer<typeof DiskMonitorSchema>;
|
|
101
|
-
export type ResourceMonitorConfig = z.infer<typeof ResourceMonitorSchema>;
|
|
102
|
-
export type SystemdMonitorConfig = z.infer<typeof SystemdMonitorSchema>;
|
|
103
|
-
export type SecurityUpdateMonitorConfig = z.infer<typeof SecurityUpdateMonitorSchema>;
|
|
104
|
-
export type GitMonitorConfig = z.infer<typeof GitMonitorSchema>;
|
|
105
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/**
|
|
3
|
-
* Monitoring configuration schemas.
|
|
4
|
-
*
|
|
5
|
-
* Defines thresholds and settings for system monitoring heartbeat sources:
|
|
6
|
-
* disk space, CPU/memory resources, systemd services, security updates,
|
|
7
|
-
* and git repository watching.
|
|
8
|
-
*
|
|
9
|
-
* MON-01: Disk space monitoring
|
|
10
|
-
* MON-02: Resource utilization monitoring
|
|
11
|
-
* MON-03: Service health monitoring
|
|
12
|
-
* MON-04: Security update and git repo monitoring
|
|
13
|
-
*/
|
|
14
|
-
const DiskMonitorSchema = z.strictObject({
|
|
15
|
-
/** Whether disk space monitoring is enabled. */
|
|
16
|
-
enabled: z.boolean().default(true),
|
|
17
|
-
/** Filesystem paths to monitor. */
|
|
18
|
-
paths: z.array(z.string()).default(["/"]),
|
|
19
|
-
/** Alert when usage exceeds this percentage. */
|
|
20
|
-
thresholdPercent: z.number().min(0).max(100).default(90),
|
|
21
|
-
});
|
|
22
|
-
const ResourceMonitorSchema = z.strictObject({
|
|
23
|
-
/** Whether CPU/memory monitoring is enabled. */
|
|
24
|
-
enabled: z.boolean().default(true),
|
|
25
|
-
/** Alert when CPU usage exceeds this percentage. */
|
|
26
|
-
cpuThresholdPercent: z.number().min(0).max(100).default(85),
|
|
27
|
-
/** Alert when memory usage exceeds this percentage. */
|
|
28
|
-
memoryThresholdPercent: z.number().min(0).max(100).default(90),
|
|
29
|
-
});
|
|
30
|
-
const SystemdMonitorSchema = z.strictObject({
|
|
31
|
-
/** Whether systemd service monitoring is enabled. */
|
|
32
|
-
enabled: z.boolean().default(true),
|
|
33
|
-
/** Specific services to monitor (empty = check all failed). */
|
|
34
|
-
services: z.array(z.string()).default([]),
|
|
35
|
-
});
|
|
36
|
-
const SecurityUpdateMonitorSchema = z.strictObject({
|
|
37
|
-
/** Whether security update monitoring is enabled. */
|
|
38
|
-
enabled: z.boolean().default(true),
|
|
39
|
-
/** Only check for security updates (not all updates). */
|
|
40
|
-
securityOnly: z.boolean().default(true),
|
|
41
|
-
});
|
|
42
|
-
const GitMonitorSchema = z.strictObject({
|
|
43
|
-
/** Whether git repository monitoring is enabled (default: off). */
|
|
44
|
-
enabled: z.boolean().default(false),
|
|
45
|
-
/** Absolute paths to git repositories to monitor. */
|
|
46
|
-
repositories: z.array(z.string()).default([]),
|
|
47
|
-
/** Check remote for unpushed commits. */
|
|
48
|
-
checkRemote: z.boolean().default(true),
|
|
49
|
-
});
|
|
50
|
-
/**
|
|
51
|
-
* Root monitoring configuration schema.
|
|
52
|
-
*
|
|
53
|
-
* Each sub-section has sensible defaults so an empty object
|
|
54
|
-
* produces a valid MonitoringConfig.
|
|
55
|
-
*/
|
|
56
|
-
export const MonitoringConfigSchema = z.strictObject({
|
|
57
|
-
/** Disk space monitoring. */
|
|
58
|
-
disk: DiskMonitorSchema.default(() => DiskMonitorSchema.parse({})),
|
|
59
|
-
/** CPU and memory monitoring. */
|
|
60
|
-
resources: ResourceMonitorSchema.default(() => ResourceMonitorSchema.parse({})),
|
|
61
|
-
/** systemd service health monitoring. */
|
|
62
|
-
systemd: SystemdMonitorSchema.default(() => SystemdMonitorSchema.parse({})),
|
|
63
|
-
/** Security update monitoring. */
|
|
64
|
-
securityUpdates: SecurityUpdateMonitorSchema.default(() => SecurityUpdateMonitorSchema.parse({})),
|
|
65
|
-
/** Git repository monitoring. */
|
|
66
|
-
git: GitMonitorSchema.default(() => GitMonitorSchema.parse({})),
|
|
67
|
-
});
|
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import type { Result } from "@comis/shared";
|
|
2
|
-
import type { Attachment } from "../domain/normalized-message.js";
|
|
3
|
-
/**
|
|
4
|
-
* Options for audio transcription.
|
|
5
|
-
*/
|
|
6
|
-
export interface TranscriptionOptions {
|
|
7
|
-
/** MIME type of the audio buffer (e.g. "audio/ogg", "audio/mp3") */
|
|
8
|
-
readonly mimeType: string;
|
|
9
|
-
/** BCP-47 language hint (e.g. "en", "es"). Provider may auto-detect if omitted. */
|
|
10
|
-
readonly language?: string;
|
|
11
|
-
/** Optional prompt/context to guide transcription accuracy. */
|
|
12
|
-
readonly prompt?: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Result of a successful transcription.
|
|
16
|
-
*/
|
|
17
|
-
export interface TranscriptionResult {
|
|
18
|
-
/** Transcribed text. */
|
|
19
|
-
readonly text: string;
|
|
20
|
-
/** Detected or confirmed language (BCP-47). */
|
|
21
|
-
readonly language?: string;
|
|
22
|
-
/** Duration of the audio in milliseconds. */
|
|
23
|
-
readonly durationMs?: number;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* TranscriptionPort: Hexagonal boundary for speech-to-text services.
|
|
27
|
-
*
|
|
28
|
-
* Adapters (OpenAI Whisper, local whisper.cpp, etc.) implement this
|
|
29
|
-
* interface to convert audio buffers into text.
|
|
30
|
-
*/
|
|
31
|
-
export interface TranscriptionPort {
|
|
32
|
-
/**
|
|
33
|
-
* Transcribe an audio buffer to text.
|
|
34
|
-
*
|
|
35
|
-
* @param audio - Raw audio data
|
|
36
|
-
* @param options - MIME type, language hint, optional prompt
|
|
37
|
-
* @returns Transcription result or an error (e.g. file too large, API failure)
|
|
38
|
-
*/
|
|
39
|
-
transcribe(audio: Buffer, options: TranscriptionOptions): Promise<Result<TranscriptionResult, Error>>;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Options for text-to-speech synthesis.
|
|
43
|
-
*/
|
|
44
|
-
export interface TTSOptions {
|
|
45
|
-
/** Voice identifier (provider-specific, e.g. "alloy", "nova"). */
|
|
46
|
-
readonly voice?: string;
|
|
47
|
-
/** Output audio format (e.g. "mp3", "opus", "aac", "flac"). */
|
|
48
|
-
readonly format?: string;
|
|
49
|
-
/** Playback speed multiplier (0.25 to 4.0). */
|
|
50
|
-
readonly speed?: number;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Result of a successful TTS synthesis.
|
|
54
|
-
*/
|
|
55
|
-
export interface TTSResult {
|
|
56
|
-
/** Raw audio data. */
|
|
57
|
-
readonly audio: Buffer;
|
|
58
|
-
/** MIME type of the audio (e.g. "audio/mpeg", "audio/opus"). */
|
|
59
|
-
readonly mimeType: string;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* TTSPort: Hexagonal boundary for text-to-speech services.
|
|
63
|
-
*
|
|
64
|
-
* Adapters (OpenAI TTS, ElevenLabs, local Piper, etc.) implement this
|
|
65
|
-
* interface to synthesize audio from text.
|
|
66
|
-
*/
|
|
67
|
-
export interface TTSPort {
|
|
68
|
-
/**
|
|
69
|
-
* Synthesize text into audio.
|
|
70
|
-
*
|
|
71
|
-
* @param text - Text content to convert to speech
|
|
72
|
-
* @param options - Voice, format, and speed configuration
|
|
73
|
-
* @returns Audio buffer with MIME type, or an error
|
|
74
|
-
*/
|
|
75
|
-
synthesize(text: string, options?: TTSOptions): Promise<Result<TTSResult, Error>>;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Options for image analysis.
|
|
79
|
-
*/
|
|
80
|
-
export interface ImageAnalysisOptions {
|
|
81
|
-
/** MIME type of the image buffer (e.g. "image/png", "image/jpeg"). */
|
|
82
|
-
readonly mimeType: string;
|
|
83
|
-
/** Maximum tokens in the analysis response. */
|
|
84
|
-
readonly maxTokens?: number;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* ImageAnalysisPort: Hexagonal boundary for multimodal image analysis.
|
|
88
|
-
*
|
|
89
|
-
* Adapters (Anthropic Claude, OpenAI GPT-4o, etc.) implement this
|
|
90
|
-
* interface to analyze images using vision-capable LLMs.
|
|
91
|
-
*/
|
|
92
|
-
export interface ImageAnalysisPort {
|
|
93
|
-
/**
|
|
94
|
-
* Analyze an image given a prompt.
|
|
95
|
-
*
|
|
96
|
-
* @param image - Raw image data
|
|
97
|
-
* @param prompt - Question or instruction about the image
|
|
98
|
-
* @param options - MIME type and response length configuration
|
|
99
|
-
* @returns Analysis text or an error (e.g. file too large, unsupported format)
|
|
100
|
-
*/
|
|
101
|
-
analyze(image: Buffer, prompt: string, options: ImageAnalysisOptions): Promise<Result<string, Error>>;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Request payload for image vision analysis.
|
|
105
|
-
*/
|
|
106
|
-
export interface VisionRequest {
|
|
107
|
-
/** Raw image data. */
|
|
108
|
-
readonly image: Buffer;
|
|
109
|
-
/** Question or instruction about the image. */
|
|
110
|
-
readonly prompt: string;
|
|
111
|
-
/** MIME type of the image (e.g. "image/png", "image/jpeg"). */
|
|
112
|
-
readonly mimeType: string;
|
|
113
|
-
/** Maximum tokens in the response. */
|
|
114
|
-
readonly maxTokens?: number;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Request payload for video vision analysis.
|
|
118
|
-
*/
|
|
119
|
-
export interface VideoRequest {
|
|
120
|
-
/** Raw video data. */
|
|
121
|
-
readonly video: Buffer;
|
|
122
|
-
/** Question or instruction about the video. */
|
|
123
|
-
readonly prompt: string;
|
|
124
|
-
/** MIME type of the video (e.g. "video/mp4", "video/webm"). */
|
|
125
|
-
readonly mimeType: string;
|
|
126
|
-
/** Maximum tokens in the response. */
|
|
127
|
-
readonly maxTokens?: number;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Result of a vision analysis (image or video).
|
|
131
|
-
*/
|
|
132
|
-
export interface VisionResult {
|
|
133
|
-
/** Analysis text. */
|
|
134
|
-
readonly text: string;
|
|
135
|
-
/** Provider that produced the result (e.g. "openai", "anthropic", "google"). */
|
|
136
|
-
readonly provider: string;
|
|
137
|
-
/** Model used for analysis. */
|
|
138
|
-
readonly model: string;
|
|
139
|
-
/** Tokens used (if available from the provider). */
|
|
140
|
-
readonly tokensUsed?: number;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* VisionProvider: Multi-capability vision analysis provider.
|
|
144
|
-
*
|
|
145
|
-
* Each provider declares which media types it supports (image, video, or both).
|
|
146
|
-
* The registry uses capabilities to route requests to the right provider.
|
|
147
|
-
*/
|
|
148
|
-
export interface VisionProvider {
|
|
149
|
-
/** Unique provider identifier (e.g. "openai", "anthropic", "google"). */
|
|
150
|
-
readonly id: string;
|
|
151
|
-
/** Media types this provider can analyze. */
|
|
152
|
-
readonly capabilities: ReadonlyArray<"image" | "video">;
|
|
153
|
-
/** Analyze an image. */
|
|
154
|
-
describeImage(req: VisionRequest): Promise<Result<VisionResult, Error>>;
|
|
155
|
-
/** Analyze a video (optional — only providers with "video" capability). */
|
|
156
|
-
describeVideo?(req: VideoRequest): Promise<Result<VisionResult, Error>>;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Result of resolving a media attachment to a buffer.
|
|
160
|
-
*/
|
|
161
|
-
export interface ResolvedMedia {
|
|
162
|
-
/** Downloaded file content. */
|
|
163
|
-
readonly buffer: Buffer;
|
|
164
|
-
/** Verified MIME type (sniffed, not declared). */
|
|
165
|
-
readonly mimeType: string;
|
|
166
|
-
/** File size in bytes. */
|
|
167
|
-
readonly sizeBytes: number;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* MediaResolverPort: Hexagonal boundary for media resolution.
|
|
171
|
-
*
|
|
172
|
-
* Per-platform adapters implement this interface to download attachments
|
|
173
|
-
* from platform-specific URLs (e.g., tg-file:// for Telegram, https://
|
|
174
|
-
* for public URLs). The resolver registry routes to the correct adapter
|
|
175
|
-
* based on the URI scheme.
|
|
176
|
-
*/
|
|
177
|
-
export interface MediaResolverPort {
|
|
178
|
-
/** URI schemes this resolver handles (e.g., ["tg-file", "https"]). */
|
|
179
|
-
readonly schemes: ReadonlyArray<string>;
|
|
180
|
-
/**
|
|
181
|
-
* Resolve an attachment URL to a downloaded buffer.
|
|
182
|
-
*
|
|
183
|
-
* Implementations MUST validate URLs through validateUrl() from
|
|
184
|
-
* @comis/core/security before any HTTP request to prevent SSRF.
|
|
185
|
-
* Private, loopback, link-local, and cloud-metadata IPs are blocked.
|
|
186
|
-
* DNS rebinding protection is mandatory: resolve hostname to IP,
|
|
187
|
-
* check blocklist, then connect using pinned IP.
|
|
188
|
-
*
|
|
189
|
-
* Implementations MUST check Content-Length against the configured
|
|
190
|
-
* maxRemoteFetchBytes limit and abort before streaming the body
|
|
191
|
-
* if exceeded.
|
|
192
|
-
*
|
|
193
|
-
* @param attachment - The attachment to resolve
|
|
194
|
-
* @returns Resolved media buffer with MIME type and size, or an error
|
|
195
|
-
*/
|
|
196
|
-
resolve(attachment: Attachment): Promise<Result<ResolvedMedia, Error>>;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Classification of a file based on its MIME type.
|
|
200
|
-
*
|
|
201
|
-
* - `"document"`: Extractable text content in the MIME whitelist (PDF, plain text, CSV, etc.)
|
|
202
|
-
* - `"binary"`: Known binary format (images, audio, video, archives) — not text-extractable
|
|
203
|
-
* - `"unknown"`: Unrecognized MIME type — classification cannot be determined
|
|
204
|
-
*/
|
|
205
|
-
export type FileClassification = "document" | "binary" | "unknown";
|
|
206
|
-
/**
|
|
207
|
-
* Error categories for file extraction failures.
|
|
208
|
-
*/
|
|
209
|
-
export type FileExtractionErrorKind = "timeout" | "encrypted" | "size_exceeded" | "unsupported_mime" | "encoding_error" | "corrupt" | "download_failed" | "internal";
|
|
210
|
-
/**
|
|
211
|
-
* Structured error returned by FileExtractionPort on failure.
|
|
212
|
-
*/
|
|
213
|
-
export interface FileExtractionError {
|
|
214
|
-
readonly kind: FileExtractionErrorKind;
|
|
215
|
-
readonly message: string;
|
|
216
|
-
readonly mimeType?: string;
|
|
217
|
-
readonly fileName?: string;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Input for file extraction. Discriminated union on the `source` field.
|
|
221
|
-
*
|
|
222
|
-
* - `"buffer"`: Extract from an in-memory buffer (mimeType required).
|
|
223
|
-
* - `"url"`: Extract from a remote URL (mimeType optional, may need detection).
|
|
224
|
-
*/
|
|
225
|
-
export type FileExtractionInput = {
|
|
226
|
-
readonly source: "buffer";
|
|
227
|
-
readonly buffer: Buffer;
|
|
228
|
-
readonly mimeType: string;
|
|
229
|
-
readonly fileName?: string;
|
|
230
|
-
readonly sizeBytes?: number;
|
|
231
|
-
} | {
|
|
232
|
-
readonly source: "url";
|
|
233
|
-
readonly url: string;
|
|
234
|
-
readonly mimeType?: string;
|
|
235
|
-
readonly fileName?: string;
|
|
236
|
-
readonly sizeBytes?: number;
|
|
237
|
-
};
|
|
238
|
-
/**
|
|
239
|
-
* Result of a successful file extraction.
|
|
240
|
-
*/
|
|
241
|
-
export interface FileExtractionResult {
|
|
242
|
-
/** Extracted text content. */
|
|
243
|
-
readonly text: string;
|
|
244
|
-
/** File name (original or detected). */
|
|
245
|
-
readonly fileName: string;
|
|
246
|
-
/** MIME type of the source file. */
|
|
247
|
-
readonly mimeType: string;
|
|
248
|
-
/** Number of characters in the extracted text. */
|
|
249
|
-
readonly extractedChars: number;
|
|
250
|
-
/** Whether the text was truncated to fit maxChars. */
|
|
251
|
-
readonly truncated: boolean;
|
|
252
|
-
/** Time taken for extraction in milliseconds. */
|
|
253
|
-
readonly durationMs: number;
|
|
254
|
-
/** Original file buffer for downstream re-use. */
|
|
255
|
-
readonly buffer: Buffer;
|
|
256
|
-
/** Number of pages extracted (for paginated formats like PDF). */
|
|
257
|
-
readonly pageCount?: number;
|
|
258
|
-
/** Total pages in the document (may differ from pageCount if maxPages limit applied). */
|
|
259
|
-
readonly totalPages?: number;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* FileExtractionPort: Hexagonal boundary for document text extraction services.
|
|
263
|
-
*
|
|
264
|
-
* Adapters implement this interface to extract text content from document files
|
|
265
|
-
* (PDF, plain text, CSV, etc.). The port accepts both in-memory buffers and
|
|
266
|
-
* remote URLs as input sources.
|
|
267
|
-
*/
|
|
268
|
-
export interface FileExtractionPort {
|
|
269
|
-
/**
|
|
270
|
-
* Extract text content from a document file.
|
|
271
|
-
*
|
|
272
|
-
* @param input - File source (buffer or URL) with metadata
|
|
273
|
-
* @returns Extraction result with text and metrics, or a structured error
|
|
274
|
-
*/
|
|
275
|
-
extract(input: FileExtractionInput): Promise<Result<FileExtractionResult, FileExtractionError>>;
|
|
276
|
-
/** MIME types this adapter can extract text from. */
|
|
277
|
-
readonly supportedMimes: ReadonlyArray<string>;
|
|
278
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|