@chude/memory 4.0.0
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/README.md +294 -0
- package/dist/application/index.d.ts +6 -0
- package/dist/application/services/ambient-context-service.d.ts +90 -0
- package/dist/application/services/backfill-service.d.ts +71 -0
- package/dist/application/services/budget-allocator.d.ts +57 -0
- package/dist/application/services/embedding-service.d.ts +131 -0
- package/dist/application/services/export-service.d.ts +225 -0
- package/dist/application/services/extraction-pipeline.d.ts +50 -0
- package/dist/application/services/friction-service.d.ts +148 -0
- package/dist/application/services/fts-sanitizer.d.ts +25 -0
- package/dist/application/services/index.d.ts +34 -0
- package/dist/application/services/llm-extractor.d.ts +96 -0
- package/dist/application/services/memory-file-sync-service.d.ts +58 -0
- package/dist/application/services/pattern-extractor.d.ts +95 -0
- package/dist/application/services/recovery-service.d.ts +81 -0
- package/dist/application/services/rrf-fusion.d.ts +53 -0
- package/dist/application/services/smart-context-service.d.ts +126 -0
- package/dist/application/services/sync-service.d.ts +157 -0
- package/dist/application/services/temporal-decay.d.ts +62 -0
- package/dist/domain/entities/backfill-state.d.ts +56 -0
- package/dist/domain/entities/entity.d.ts +131 -0
- package/dist/domain/entities/extraction-state.d.ts +128 -0
- package/dist/domain/entities/fact.d.ts +59 -0
- package/dist/domain/entities/friction-entry.d.ts +84 -0
- package/dist/domain/entities/index.d.ts +15 -0
- package/dist/domain/entities/link.d.ts +74 -0
- package/dist/domain/entities/memory-file.d.ts +78 -0
- package/dist/domain/entities/message.d.ts +70 -0
- package/dist/domain/entities/session.d.ts +93 -0
- package/dist/domain/entities/tool-use.d.ts +85 -0
- package/dist/domain/errors/error-codes.d.ts +37 -0
- package/dist/domain/errors/index.d.ts +8 -0
- package/dist/domain/errors/memory-error.d.ts +52 -0
- package/dist/domain/errors/unknown-error.d.ts +9 -0
- package/dist/domain/index.d.ts +11 -0
- package/dist/domain/ports/embedding.d.ts +96 -0
- package/dist/domain/ports/extraction.d.ts +13 -0
- package/dist/domain/ports/index.d.ts +14 -0
- package/dist/domain/ports/redactor.d.ts +17 -0
- package/dist/domain/ports/repositories.d.ts +658 -0
- package/dist/domain/ports/services.d.ts +180 -0
- package/dist/domain/ports/signals.d.ts +82 -0
- package/dist/domain/ports/sources.d.ts +122 -0
- package/dist/domain/ports/types.d.ts +150 -0
- package/dist/domain/services/content-extractor.d.ts +61 -0
- package/dist/domain/services/index.d.ts +8 -0
- package/dist/domain/services/path-decoder.d.ts +56 -0
- package/dist/domain/services/query-parser.d.ts +47 -0
- package/dist/domain/value-objects/embedding-config.d.ts +56 -0
- package/dist/domain/value-objects/embedding-result.d.ts +46 -0
- package/dist/domain/value-objects/index.d.ts +10 -0
- package/dist/domain/value-objects/project-path.d.ts +92 -0
- package/dist/domain/value-objects/search-query.d.ts +30 -0
- package/dist/domain/value-objects/search-result.d.ts +92 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +1548 -0
- package/dist/infrastructure/database/connection.d.ts +161 -0
- package/dist/infrastructure/database/event-log.d.ts +22 -0
- package/dist/infrastructure/database/health-checker.d.ts +248 -0
- package/dist/infrastructure/database/index.d.ts +11 -0
- package/dist/infrastructure/database/repositories/backfill-state-repository.d.ts +19 -0
- package/dist/infrastructure/database/repositories/embedding-repository.d.ts +121 -0
- package/dist/infrastructure/database/repositories/entity-repository.d.ts +73 -0
- package/dist/infrastructure/database/repositories/extraction-log-repository.d.ts +17 -0
- package/dist/infrastructure/database/repositories/extraction-state-repository.d.ts +52 -0
- package/dist/infrastructure/database/repositories/fact-repository.d.ts +25 -0
- package/dist/infrastructure/database/repositories/friction-repository.d.ts +41 -0
- package/dist/infrastructure/database/repositories/index.d.ts +17 -0
- package/dist/infrastructure/database/repositories/link-repository.d.ts +64 -0
- package/dist/infrastructure/database/repositories/memory-file-repository.d.ts +28 -0
- package/dist/infrastructure/database/repositories/message-repository.d.ts +87 -0
- package/dist/infrastructure/database/repositories/session-repository.d.ts +125 -0
- package/dist/infrastructure/database/repositories/tool-use-repository.d.ts +72 -0
- package/dist/infrastructure/database/schema.d.ts +203 -0
- package/dist/infrastructure/database/services/context-service.d.ts +93 -0
- package/dist/infrastructure/database/services/hybrid-search-service.d.ts +156 -0
- package/dist/infrastructure/database/services/index.d.ts +10 -0
- package/dist/infrastructure/database/services/search-service.d.ts +57 -0
- package/dist/infrastructure/database/services/stats-service.d.ts +36 -0
- package/dist/infrastructure/embedding/background-embedder.d.ts +125 -0
- package/dist/infrastructure/embedding/embedding-provider-factory.d.ts +44 -0
- package/dist/infrastructure/embedding/index.d.ts +5 -0
- package/dist/infrastructure/embedding/ollama-provider.d.ts +41 -0
- package/dist/infrastructure/embedding/openai-provider.d.ts +38 -0
- package/dist/infrastructure/embedding/transformers-js-provider.d.ts +34 -0
- package/dist/infrastructure/external/index.d.ts +7 -0
- package/dist/infrastructure/external/qmd-runner.d.ts +36 -0
- package/dist/infrastructure/hooks/auto-memory-writer.d.ts +52 -0
- package/dist/infrastructure/hooks/config-manager.d.ts +237 -0
- package/dist/infrastructure/hooks/git-syncer.d.ts +44 -0
- package/dist/infrastructure/hooks/hook-runner.d.ts +126 -0
- package/dist/infrastructure/hooks/index.d.ts +12 -0
- package/dist/infrastructure/hooks/log-writer.d.ts +106 -0
- package/dist/infrastructure/hooks/settings-manager.d.ts +163 -0
- package/dist/infrastructure/hooks/sync-hook-script.d.ts +83 -0
- package/dist/infrastructure/hooks/sync-logger-adapter.d.ts +17 -0
- package/dist/infrastructure/index.d.ts +11 -0
- package/dist/infrastructure/llm/anthropic-extractor.d.ts +20 -0
- package/dist/infrastructure/llm/claude-cli-extractor.d.ts +14 -0
- package/dist/infrastructure/llm/claude-summary-generator.d.ts +14 -0
- package/dist/infrastructure/llm/extraction-helper.d.ts +16 -0
- package/dist/infrastructure/llm/ollama-extractor.d.ts +20 -0
- package/dist/infrastructure/llm/openai-extractor.d.ts +23 -0
- package/dist/infrastructure/migration.d.ts +103 -0
- package/dist/infrastructure/parsers/event-classifier.d.ts +111 -0
- package/dist/infrastructure/parsers/index.d.ts +8 -0
- package/dist/infrastructure/parsers/jsonl-parser.d.ts +25 -0
- package/dist/infrastructure/parsers/timestamp.d.ts +18 -0
- package/dist/infrastructure/paths.d.ts +129 -0
- package/dist/infrastructure/providers/provider-defaults.d.ts +11 -0
- package/dist/infrastructure/providers/provider-registry.d.ts +28 -0
- package/dist/infrastructure/security/pattern-redactor.d.ts +6 -0
- package/dist/infrastructure/signals/adapters.d.ts +27 -0
- package/dist/infrastructure/signals/checkpoint-manager.d.ts +83 -0
- package/dist/infrastructure/signals/index.d.ts +8 -0
- package/dist/infrastructure/signals/signal-handler.d.ts +113 -0
- package/dist/infrastructure/sources/index.d.ts +8 -0
- package/dist/infrastructure/sources/memory-file-scanner.d.ts +23 -0
- package/dist/infrastructure/sources/project-name-resolver.d.ts +67 -0
- package/dist/infrastructure/sources/session-source.d.ts +70 -0
- package/dist/presentation/cli/command-result.d.ts +10 -0
- package/dist/presentation/cli/commands/_helpers/capture-json.d.ts +36 -0
- package/dist/presentation/cli/commands/_helpers/deprecation-warning.d.ts +41 -0
- package/dist/presentation/cli/commands/backfill.d.ts +56 -0
- package/dist/presentation/cli/commands/browse.d.ts +55 -0
- package/dist/presentation/cli/commands/completion.d.ts +61 -0
- package/dist/presentation/cli/commands/context.d.ts +53 -0
- package/dist/presentation/cli/commands/doctor.d.ts +55 -0
- package/dist/presentation/cli/commands/export.d.ts +36 -0
- package/dist/presentation/cli/commands/extract.d.ts +40 -0
- package/dist/presentation/cli/commands/facts.d.ts +17 -0
- package/dist/presentation/cli/commands/friction/dashboard.d.ts +18 -0
- package/dist/presentation/cli/commands/friction/index.d.ts +12 -0
- package/dist/presentation/cli/commands/friction/list.d.ts +12 -0
- package/dist/presentation/cli/commands/friction/log.d.ts +12 -0
- package/dist/presentation/cli/commands/friction/purge.d.ts +12 -0
- package/dist/presentation/cli/commands/friction/resolve.d.ts +12 -0
- package/dist/presentation/cli/commands/friction/types.d.ts +86 -0
- package/dist/presentation/cli/commands/friction/wontfix.d.ts +12 -0
- package/dist/presentation/cli/commands/import.d.ts +38 -0
- package/dist/presentation/cli/commands/index.d.ts +51 -0
- package/dist/presentation/cli/commands/install.d.ts +67 -0
- package/dist/presentation/cli/commands/list.d.ts +61 -0
- package/dist/presentation/cli/commands/migrate.d.ts +36 -0
- package/dist/presentation/cli/commands/purge.d.ts +100 -0
- package/dist/presentation/cli/commands/query.d.ts +51 -0
- package/dist/presentation/cli/commands/related.d.ts +47 -0
- package/dist/presentation/cli/commands/remote.d.ts +36 -0
- package/dist/presentation/cli/commands/search.d.ts +100 -0
- package/dist/presentation/cli/commands/show.d.ts +51 -0
- package/dist/presentation/cli/commands/stats.d.ts +38 -0
- package/dist/presentation/cli/commands/status.d.ts +152 -0
- package/dist/presentation/cli/commands/sync/ambient.d.ts +22 -0
- package/dist/presentation/cli/commands/sync/background.d.ts +23 -0
- package/dist/presentation/cli/commands/sync/embedding-pass.d.ts +32 -0
- package/dist/presentation/cli/commands/sync/helpers.d.ts +25 -0
- package/dist/presentation/cli/commands/sync/index.d.ts +17 -0
- package/dist/presentation/cli/commands/sync/memory-files.d.ts +26 -0
- package/dist/presentation/cli/commands/sync/types.d.ts +163 -0
- package/dist/presentation/cli/commands/uninstall.d.ts +44 -0
- package/dist/presentation/cli/db-startup.d.ts +61 -0
- package/dist/presentation/cli/formatters/ai-formatter.d.ts +38 -0
- package/dist/presentation/cli/formatters/color.d.ts +82 -0
- package/dist/presentation/cli/formatters/context-formatter.d.ts +55 -0
- package/dist/presentation/cli/formatters/dto-helpers.d.ts +176 -0
- package/dist/presentation/cli/formatters/envelope.d.ts +136 -0
- package/dist/presentation/cli/formatters/error-formatter.d.ts +41 -0
- package/dist/presentation/cli/formatters/friction-dashboard.d.ts +46 -0
- package/dist/presentation/cli/formatters/index.d.ts +17 -0
- package/dist/presentation/cli/formatters/list-formatter.d.ts +48 -0
- package/dist/presentation/cli/formatters/output-formatter.d.ts +98 -0
- package/dist/presentation/cli/formatters/related-formatter.d.ts +57 -0
- package/dist/presentation/cli/formatters/show-formatter.d.ts +63 -0
- package/dist/presentation/cli/formatters/stats-formatter.d.ts +54 -0
- package/dist/presentation/cli/formatters/text-width.d.ts +37 -0
- package/dist/presentation/cli/formatters/timestamp-formatter.d.ts +38 -0
- package/dist/presentation/cli/index.d.ts +10 -0
- package/dist/presentation/cli/index.js +1664 -0
- package/dist/presentation/cli/parsers/date-parser.d.ts +28 -0
- package/dist/presentation/cli/parsers/index.d.ts +6 -0
- package/dist/presentation/cli/pickers/index.d.ts +6 -0
- package/dist/presentation/cli/pickers/session-picker.d.ts +59 -0
- package/dist/presentation/cli/progress-reporter.d.ts +199 -0
- package/package.json +94 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Entity
|
|
3
|
+
*
|
|
4
|
+
* Represents a Claude Code session - a collection of messages
|
|
5
|
+
* exchanged within a project directory over a period of time.
|
|
6
|
+
*
|
|
7
|
+
* Entity properties:
|
|
8
|
+
* - Has unique identity (id)
|
|
9
|
+
* - Immutable after construction (mutations return new instances)
|
|
10
|
+
* - Aggregates Message entities
|
|
11
|
+
*/
|
|
12
|
+
import type { ProjectPath } from "../value-objects/project-path.js";
|
|
13
|
+
import type { Message } from "./message.js";
|
|
14
|
+
interface SessionParams {
|
|
15
|
+
id: string;
|
|
16
|
+
projectPath: ProjectPath;
|
|
17
|
+
startTime: Date;
|
|
18
|
+
endTime?: Date | undefined;
|
|
19
|
+
messages?: readonly Message[] | undefined;
|
|
20
|
+
summary?: string | undefined;
|
|
21
|
+
messageCount?: number | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare class Session {
|
|
24
|
+
private readonly _id;
|
|
25
|
+
private readonly _projectPath;
|
|
26
|
+
private readonly _startTime;
|
|
27
|
+
private readonly _endTime?;
|
|
28
|
+
private readonly _messages;
|
|
29
|
+
private readonly _summary?;
|
|
30
|
+
private readonly _messageCount?;
|
|
31
|
+
private constructor();
|
|
32
|
+
/**
|
|
33
|
+
* Create a Session entity.
|
|
34
|
+
* @throws Error if id is empty or endTime is before startTime
|
|
35
|
+
*/
|
|
36
|
+
static create(params: SessionParams): Session;
|
|
37
|
+
/**
|
|
38
|
+
* The unique session identifier.
|
|
39
|
+
*/
|
|
40
|
+
get id(): string;
|
|
41
|
+
/**
|
|
42
|
+
* The project directory this session belongs to.
|
|
43
|
+
*/
|
|
44
|
+
get projectPath(): ProjectPath;
|
|
45
|
+
/**
|
|
46
|
+
* When the session started.
|
|
47
|
+
*/
|
|
48
|
+
get startTime(): Date;
|
|
49
|
+
/**
|
|
50
|
+
* When the session ended (undefined if still active).
|
|
51
|
+
*/
|
|
52
|
+
get endTime(): Date | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* All messages in this session.
|
|
55
|
+
*/
|
|
56
|
+
get messages(): Message[];
|
|
57
|
+
/**
|
|
58
|
+
* LLM-generated summary of this session (undefined if not extracted).
|
|
59
|
+
*/
|
|
60
|
+
get summary(): string | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Number of messages in this session.
|
|
63
|
+
* Returns explicit messageCount if set, otherwise falls back to messages.length.
|
|
64
|
+
* This allows displaying accurate counts from the database without loading all messages.
|
|
65
|
+
*/
|
|
66
|
+
get messageCount(): number;
|
|
67
|
+
/**
|
|
68
|
+
* Session duration in milliseconds (undefined if not complete).
|
|
69
|
+
*/
|
|
70
|
+
get durationMs(): number | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Check equality with another Session (based on id).
|
|
73
|
+
*/
|
|
74
|
+
equals(other: Session): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Add a message to this session.
|
|
77
|
+
* Returns a new Session instance (immutability).
|
|
78
|
+
* Note: When adding messages, messageCount is no longer used (falls back to messages.length).
|
|
79
|
+
*/
|
|
80
|
+
addMessage(message: Message): Session;
|
|
81
|
+
/**
|
|
82
|
+
* Mark this session as complete.
|
|
83
|
+
* Returns a new Session instance (immutability).
|
|
84
|
+
* @throws Error if endTime is before startTime
|
|
85
|
+
*/
|
|
86
|
+
complete(endTime: Date): Session;
|
|
87
|
+
/**
|
|
88
|
+
* Set the summary for this session.
|
|
89
|
+
* Returns a new Session instance (immutability).
|
|
90
|
+
*/
|
|
91
|
+
withSummary(summary: string): Session;
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolUse Entity
|
|
3
|
+
*
|
|
4
|
+
* Represents a single tool invocation within a Claude Code session.
|
|
5
|
+
* Tracks the tool name, input parameters, result, and execution status.
|
|
6
|
+
*
|
|
7
|
+
* Entity properties:
|
|
8
|
+
* - Has unique identity (id)
|
|
9
|
+
* - Immutable after construction (status updates return new instances)
|
|
10
|
+
* - Tracks execution lifecycle (pending -> success/error)
|
|
11
|
+
*/
|
|
12
|
+
export type ToolUseStatus = "pending" | "success" | "error";
|
|
13
|
+
interface ToolUseParams {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
input: Record<string, unknown>;
|
|
17
|
+
timestamp: Date;
|
|
18
|
+
status?: ToolUseStatus | undefined;
|
|
19
|
+
result?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
export declare class ToolUse {
|
|
22
|
+
private readonly _id;
|
|
23
|
+
private readonly _name;
|
|
24
|
+
private readonly _input;
|
|
25
|
+
private readonly _timestamp;
|
|
26
|
+
private readonly _status;
|
|
27
|
+
private readonly _result?;
|
|
28
|
+
private constructor();
|
|
29
|
+
/**
|
|
30
|
+
* Create a ToolUse entity.
|
|
31
|
+
* @throws Error if id or name is empty, or status is invalid
|
|
32
|
+
*/
|
|
33
|
+
static create(params: ToolUseParams): ToolUse;
|
|
34
|
+
/**
|
|
35
|
+
* The unique tool use identifier.
|
|
36
|
+
*/
|
|
37
|
+
get id(): string;
|
|
38
|
+
/**
|
|
39
|
+
* The name of the tool that was invoked.
|
|
40
|
+
*/
|
|
41
|
+
get name(): string;
|
|
42
|
+
/**
|
|
43
|
+
* The input parameters passed to the tool.
|
|
44
|
+
*/
|
|
45
|
+
get input(): Record<string, unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* When the tool was invoked.
|
|
48
|
+
*/
|
|
49
|
+
get timestamp(): Date;
|
|
50
|
+
/**
|
|
51
|
+
* The execution status (pending, success, or error).
|
|
52
|
+
*/
|
|
53
|
+
get status(): ToolUseStatus;
|
|
54
|
+
/**
|
|
55
|
+
* The result of the tool execution (output or error message).
|
|
56
|
+
*/
|
|
57
|
+
get result(): string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the tool execution is still pending.
|
|
60
|
+
*/
|
|
61
|
+
get isPending(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the tool execution completed successfully.
|
|
64
|
+
*/
|
|
65
|
+
get isSuccess(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Whether the tool execution failed.
|
|
68
|
+
*/
|
|
69
|
+
get isError(): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Check equality with another ToolUse (based on id).
|
|
72
|
+
*/
|
|
73
|
+
equals(other: ToolUse): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Mark this tool use as successfully completed.
|
|
76
|
+
* Returns a new ToolUse instance (immutability).
|
|
77
|
+
*/
|
|
78
|
+
completeSuccess(result: string): ToolUse;
|
|
79
|
+
/**
|
|
80
|
+
* Mark this tool use as failed.
|
|
81
|
+
* Returns a new ToolUse instance (immutability).
|
|
82
|
+
*/
|
|
83
|
+
completeError(errorMessage: string): ToolUse;
|
|
84
|
+
}
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Codes
|
|
3
|
+
*
|
|
4
|
+
* Stable error codes for programmatic handling.
|
|
5
|
+
* These codes are used in JSON error responses and for scripting.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Error code constant object.
|
|
9
|
+
* All error types with stable string identifiers.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ErrorCode: {
|
|
12
|
+
readonly DB_CONNECTION_FAILED: "DB_CONNECTION_FAILED";
|
|
13
|
+
readonly DB_CORRUPTED: "DB_CORRUPTED";
|
|
14
|
+
readonly DB_LOCKED: "DB_LOCKED";
|
|
15
|
+
readonly INVALID_SESSION_ID: "INVALID_SESSION_ID";
|
|
16
|
+
readonly SESSION_NOT_FOUND: "SESSION_NOT_FOUND";
|
|
17
|
+
readonly SOURCE_INACCESSIBLE: "SOURCE_INACCESSIBLE";
|
|
18
|
+
readonly DISK_FULL: "DISK_FULL";
|
|
19
|
+
readonly INVALID_JSON: "INVALID_JSON";
|
|
20
|
+
readonly UNKNOWN_FORMAT: "UNKNOWN_FORMAT";
|
|
21
|
+
readonly SYNC_INTERRUPTED: "SYNC_INTERRUPTED";
|
|
22
|
+
readonly SYNC_FAILED: "SYNC_FAILED";
|
|
23
|
+
readonly INVALID_ARGUMENT: "INVALID_ARGUMENT";
|
|
24
|
+
readonly MISSING_ARGUMENT: "MISSING_ARGUMENT";
|
|
25
|
+
readonly VECTOR_UNAVAILABLE: "VECTOR_UNAVAILABLE";
|
|
26
|
+
readonly PROVIDER_TIMEOUT: "PROVIDER_TIMEOUT";
|
|
27
|
+
readonly PROVIDER_CONFIG_INVALID: "PROVIDER_CONFIG_INVALID";
|
|
28
|
+
readonly EMBEDDING_DIMENSION_MISMATCH: "EMBEDDING_DIMENSION_MISMATCH";
|
|
29
|
+
readonly MODEL_CORRUPTED: "MODEL_CORRUPTED";
|
|
30
|
+
readonly NOT_FOUND: "NOT_FOUND";
|
|
31
|
+
readonly INVALID_STATE: "INVALID_STATE";
|
|
32
|
+
readonly UNKNOWN: "UNKNOWN";
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Union type of all error codes.
|
|
36
|
+
*/
|
|
37
|
+
export type ErrorCodeType = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Errors Barrel Export
|
|
3
|
+
*
|
|
4
|
+
* Error codes and base error class for structured error handling.
|
|
5
|
+
*/
|
|
6
|
+
export { ErrorCode, type ErrorCodeType } from "./error-codes.js";
|
|
7
|
+
export { MemoryError, type ErrorContext, type ErrorJson, } from "./memory-error.js";
|
|
8
|
+
export { unknownErrorMessage } from "./unknown-error.js";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Error
|
|
3
|
+
*
|
|
4
|
+
* Base error class with structured JSON output for programmatic handling.
|
|
5
|
+
*/
|
|
6
|
+
import type { ErrorCodeType } from "./error-codes.js";
|
|
7
|
+
/**
|
|
8
|
+
* Context for error details.
|
|
9
|
+
*/
|
|
10
|
+
export type ErrorContext = Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* JSON representation of a MemoryError.
|
|
13
|
+
*/
|
|
14
|
+
export interface ErrorJson {
|
|
15
|
+
error: {
|
|
16
|
+
code: ErrorCodeType;
|
|
17
|
+
message: string;
|
|
18
|
+
context?: ErrorContext;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Base error class for memory.
|
|
23
|
+
*
|
|
24
|
+
* Provides structured error information with:
|
|
25
|
+
* - Stable error codes for programmatic handling
|
|
26
|
+
* - Contextual information (file paths, line numbers, etc.)
|
|
27
|
+
* - JSON serialization for machine-readable output
|
|
28
|
+
*/
|
|
29
|
+
export declare class MemoryError extends Error {
|
|
30
|
+
/**
|
|
31
|
+
* Stable error code for programmatic handling.
|
|
32
|
+
*/
|
|
33
|
+
readonly code: ErrorCodeType;
|
|
34
|
+
/**
|
|
35
|
+
* Optional context with additional error details.
|
|
36
|
+
*/
|
|
37
|
+
readonly context?: ErrorContext | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Create a new MemoryError.
|
|
40
|
+
*
|
|
41
|
+
* @param code Stable error code for programmatic handling
|
|
42
|
+
* @param message Human-readable error message
|
|
43
|
+
* @param context Optional additional context (file paths, line numbers, etc.)
|
|
44
|
+
*/
|
|
45
|
+
constructor(code: ErrorCodeType, message: string, context?: ErrorContext | undefined);
|
|
46
|
+
/**
|
|
47
|
+
* Convert error to JSON representation.
|
|
48
|
+
*
|
|
49
|
+
* @returns Structured error object for JSON output
|
|
50
|
+
*/
|
|
51
|
+
toJSON(): ErrorJson;
|
|
52
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize unknown throwables for user-facing messages and diagnostics.
|
|
3
|
+
*
|
|
4
|
+
* JavaScript allows throwing any value. Keeping this branch in one tested
|
|
5
|
+
* domain helper prevents every catch block from growing its own subtly
|
|
6
|
+
* different fallback.
|
|
7
|
+
*/
|
|
8
|
+
export declare function unknownErrorMessage(error: unknown): string;
|
|
9
|
+
export declare function unknownToError(error: unknown): Error;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Layer
|
|
3
|
+
*
|
|
4
|
+
* Pure business logic with zero external dependencies.
|
|
5
|
+
* Contains entities, value objects, and domain services.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./entities/index.js";
|
|
8
|
+
export * from "./value-objects/index.js";
|
|
9
|
+
export * from "./services/index.js";
|
|
10
|
+
export * from "./errors/index.js";
|
|
11
|
+
export * from "./ports/index.js";
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embedding Provider Port
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for embedding providers that generate vector
|
|
5
|
+
* representations of text. Implementations live in the infrastructure
|
|
6
|
+
* layer (e.g., TransformersJsProvider, OpenAiProvider, OllamaProvider).
|
|
7
|
+
*
|
|
8
|
+
* This port has ZERO external dependencies -- it uses only domain
|
|
9
|
+
* value objects and primitive types.
|
|
10
|
+
*/
|
|
11
|
+
import type { EmbeddingResult } from "../value-objects/embedding-result.js";
|
|
12
|
+
/**
|
|
13
|
+
* Progress update during model download or initialization.
|
|
14
|
+
*/
|
|
15
|
+
export interface DownloadProgress {
|
|
16
|
+
/** Current status of the download/initialization */
|
|
17
|
+
status: "downloading" | "ready";
|
|
18
|
+
/** Name of the file being downloaded */
|
|
19
|
+
file: string;
|
|
20
|
+
/** Bytes loaded so far */
|
|
21
|
+
loaded: number;
|
|
22
|
+
/** Total bytes expected */
|
|
23
|
+
total: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Metadata describing an embedding model.
|
|
27
|
+
*/
|
|
28
|
+
export interface EmbeddingModelInfo {
|
|
29
|
+
/** Model identifier (e.g., "all-MiniLM-L6-v2") */
|
|
30
|
+
name: string;
|
|
31
|
+
/** Number of dimensions in the embedding vector */
|
|
32
|
+
dimensions: number;
|
|
33
|
+
/** Model file size in bytes */
|
|
34
|
+
sizeBytes: number;
|
|
35
|
+
/** Human-readable description of the model */
|
|
36
|
+
description?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Port interface for embedding providers.
|
|
40
|
+
*
|
|
41
|
+
* Embedding providers transform text into dense vector representations
|
|
42
|
+
* (embeddings) that capture semantic meaning. These embeddings enable
|
|
43
|
+
* similarity search via cosine distance.
|
|
44
|
+
*
|
|
45
|
+
* Lifecycle: initialize() -> embed()/embedBatch() -> dispose()
|
|
46
|
+
*
|
|
47
|
+
* Implementations must:
|
|
48
|
+
* - Return Float32Array embeddings with consistent dimensions
|
|
49
|
+
* - Support lazy initialization (ONNX runtime loads only when needed)
|
|
50
|
+
* - Clean up resources via dispose()
|
|
51
|
+
* - Report download progress during first-time model setup
|
|
52
|
+
*/
|
|
53
|
+
export interface IEmbeddingProvider {
|
|
54
|
+
/** Provider identifier (e.g., "transformers-js", "openai", "ollama") */
|
|
55
|
+
readonly name: string;
|
|
56
|
+
/** Number of dimensions in the embedding vectors */
|
|
57
|
+
readonly dimensions: number;
|
|
58
|
+
/** Model identifier currently in use */
|
|
59
|
+
readonly model: string;
|
|
60
|
+
/**
|
|
61
|
+
* Generate an embedding for a single text.
|
|
62
|
+
*
|
|
63
|
+
* @param text The text to embed
|
|
64
|
+
* @returns The embedding result with vector, model, and dimensions
|
|
65
|
+
*/
|
|
66
|
+
embed(text: string): Promise<EmbeddingResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Generate embeddings for multiple texts in a single batch.
|
|
69
|
+
*
|
|
70
|
+
* Batch processing is more efficient than calling embed() repeatedly
|
|
71
|
+
* because it reduces ONNX runtime overhead.
|
|
72
|
+
*
|
|
73
|
+
* @param texts Array of texts to embed
|
|
74
|
+
* @returns Array of embedding results in the same order as input
|
|
75
|
+
*/
|
|
76
|
+
embedBatch(texts: string[]): Promise<EmbeddingResult[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Check whether the provider is initialized and ready to embed.
|
|
79
|
+
*
|
|
80
|
+
* @returns true if embed() can be called, false if initialize() is needed
|
|
81
|
+
*/
|
|
82
|
+
isReady(): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Initialize the provider (download model, load ONNX runtime, etc.).
|
|
85
|
+
*
|
|
86
|
+
* First-time initialization may download model files. The optional
|
|
87
|
+
* onProgress callback reports download progress for UI display.
|
|
88
|
+
*
|
|
89
|
+
* @param onProgress Optional callback for download progress updates
|
|
90
|
+
*/
|
|
91
|
+
initialize(onProgress?: (progress: DownloadProgress) => void): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Release resources held by the provider (ONNX session, model cache, etc.).
|
|
94
|
+
*/
|
|
95
|
+
dispose(): Promise<void>;
|
|
96
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extraction Provider Port
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for LLM adapters that extract facts
|
|
5
|
+
* from developer interaction messages.
|
|
6
|
+
*/
|
|
7
|
+
import { Message } from "../entities/message.js";
|
|
8
|
+
import { CandidateFact } from "../entities/fact.js";
|
|
9
|
+
export interface IExtractionProvider {
|
|
10
|
+
readonly providerId: string;
|
|
11
|
+
readonly modelName: string;
|
|
12
|
+
extract(messages: Message[]): Promise<CandidateFact[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Ports
|
|
3
|
+
*
|
|
4
|
+
* Interfaces defining how the domain interacts with the outside world.
|
|
5
|
+
* Implemented by infrastructure adapters.
|
|
6
|
+
*/
|
|
7
|
+
export type { ISessionRepository, IMessageRepository, IToolUseRepository, ILinkRepository, IExtractionStateRepository, IEmbeddingRepository, IMemoryFileRepository, IFrictionRepository, IBackfillStateRepository, BackfillStatusCounts, FrictionStats, UnembeddedMessage, EmbeddingBatchItem, EmbeddingServiceConfig, IFactRepository, IExtractionLogRepository, ExtractionLogEntry, } from "./repositories.js";
|
|
8
|
+
export type { IEmbeddingProvider, DownloadProgress, EmbeddingModelInfo, } from "./embedding.js";
|
|
9
|
+
export type { IExtractionProvider, } from "./extraction.js";
|
|
10
|
+
export type { IRedactor, JsonRedactionResult, RedactionFinding, RedactionKind, RedactionResult, } from "./redactor.js";
|
|
11
|
+
export type { ISearchService, SearchOptions, SearchMode, HybridSearchOptions, IStatsService, StatsResult, ProjectStats, ISummaryGenerator, QmdSearchResult, QmdHealthInfo, IExternalSearchProvider, IAmbientContextWriter, } from "./services.js";
|
|
12
|
+
export type { ISessionSource, IEventParser, IProjectNameResolver, IMemoryFileScanner, SessionFileInfo, MemoryFileInfo, } from "./sources.js";
|
|
13
|
+
export type { SyncCheckpoint, ISyncAbortSignal, ICheckpointManager, ISyncLogger, } from "./signals.js";
|
|
14
|
+
export type { ParsedEvent, UserEventData, AssistantEventData, ToolUseEventData, ToolResultEventData, SummaryEventData, SystemEventData, ContentBlock, } from "./types.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type RedactionKind = "api_key" | "aws_access_key" | "bearer_token" | "env_secret" | "jwt" | "private_key";
|
|
2
|
+
export interface RedactionFinding {
|
|
3
|
+
kind: RedactionKind;
|
|
4
|
+
placeholder: string;
|
|
5
|
+
}
|
|
6
|
+
export interface RedactionResult {
|
|
7
|
+
text: string;
|
|
8
|
+
findings: RedactionFinding[];
|
|
9
|
+
}
|
|
10
|
+
export interface JsonRedactionResult<T> {
|
|
11
|
+
value: T;
|
|
12
|
+
findings: RedactionFinding[];
|
|
13
|
+
}
|
|
14
|
+
export interface IRedactor {
|
|
15
|
+
redactText(input: string): RedactionResult;
|
|
16
|
+
redactJson<T>(input: T): JsonRedactionResult<T>;
|
|
17
|
+
}
|