dsh-tdai-memory 0.3.4 → 0.3.6

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.
Files changed (66) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +13 -4
  3. package/README.zh.md +13 -4
  4. package/THIRD-PARTY-NOTICES.md +20 -20
  5. package/cordis.patch.yml +8 -8
  6. package/index.js +13 -13
  7. package/package.json +9 -6
  8. package/recall-inject.js +86 -86
  9. package/vendor/tdai/adapters/index.js +15 -15
  10. package/vendor/tdai/adapters/openclaw/host-adapter.js +83 -83
  11. package/vendor/tdai/adapters/openclaw/index.js +5 -5
  12. package/vendor/tdai/adapters/openclaw/llm-runner.js +69 -69
  13. package/vendor/tdai/adapters/standalone/host-adapter.js +58 -58
  14. package/vendor/tdai/adapters/standalone/index.js +5 -5
  15. package/vendor/tdai/core/conversation/l0-recorder.js +420 -420
  16. package/vendor/tdai/core/hooks/auto-capture.js +236 -236
  17. package/vendor/tdai/core/hooks/auto-recall.js +640 -640
  18. package/vendor/tdai/core/index.js +8 -8
  19. package/vendor/tdai/core/persona/persona-generator.js +184 -184
  20. package/vendor/tdai/core/persona/persona-trigger.js +94 -94
  21. package/vendor/tdai/core/profile/profile-sync.js +200 -200
  22. package/vendor/tdai/core/prompts/l1-dedup.js +72 -72
  23. package/vendor/tdai/core/prompts/l1-extraction.js +34 -34
  24. package/vendor/tdai/core/prompts/persona-generation.js +35 -35
  25. package/vendor/tdai/core/prompts/scene-extraction.js +45 -45
  26. package/vendor/tdai/core/record/l1-dedup.js +318 -318
  27. package/vendor/tdai/core/record/l1-extractor.js +379 -379
  28. package/vendor/tdai/core/record/l1-reader.js +178 -178
  29. package/vendor/tdai/core/record/l1-writer.js +141 -141
  30. package/vendor/tdai/core/report/reporter.js +86 -86
  31. package/vendor/tdai/core/scene/filename-normalizer.js +161 -161
  32. package/vendor/tdai/core/scene/scene-extractor.js +410 -410
  33. package/vendor/tdai/core/scene/scene-format.js +53 -53
  34. package/vendor/tdai/core/scene/scene-index.js +82 -82
  35. package/vendor/tdai/core/scene/scene-navigation.js +57 -57
  36. package/vendor/tdai/core/seed/input.js +404 -404
  37. package/vendor/tdai/core/seed/types.js +9 -9
  38. package/vendor/tdai/core/store/bm25-client.js +117 -117
  39. package/vendor/tdai/core/store/bm25-local.js +68 -68
  40. package/vendor/tdai/core/store/embedding.js +632 -632
  41. package/vendor/tdai/core/store/factory.js +95 -95
  42. package/vendor/tdai/core/store/search-utils.js +54 -54
  43. package/vendor/tdai/core/store/sqlite.js +1632 -1632
  44. package/vendor/tdai/core/store/tcvdb-client.js +221 -221
  45. package/vendor/tdai/core/store/tcvdb.js +1047 -1047
  46. package/vendor/tdai/core/store/types.js +17 -17
  47. package/vendor/tdai/core/tools/conversation-search.js +199 -199
  48. package/vendor/tdai/core/tools/memory-search.js +207 -207
  49. package/vendor/tdai/core/types.js +12 -12
  50. package/vendor/tdai/utils/backup.js +189 -189
  51. package/vendor/tdai/utils/checkpoint.js +360 -360
  52. package/vendor/tdai/utils/clean-context-runner.js +472 -472
  53. package/vendor/tdai/utils/ensure-hook-policy.js +213 -213
  54. package/vendor/tdai/utils/env.js +13 -13
  55. package/vendor/tdai/utils/managed-timer.js +127 -127
  56. package/vendor/tdai/utils/manifest.js +91 -91
  57. package/vendor/tdai/utils/memory-cleaner.js +300 -300
  58. package/vendor/tdai/utils/no-think-fetch.js +109 -109
  59. package/vendor/tdai/utils/openclaw-state-dir.js +26 -26
  60. package/vendor/tdai/utils/pipeline-factory.js +517 -517
  61. package/vendor/tdai/utils/pipeline-manager.js +892 -892
  62. package/vendor/tdai/utils/sanitize.js +360 -360
  63. package/vendor/tdai/utils/serial-queue.js +103 -103
  64. package/vendor/tdai/utils/session-filter.js +88 -88
  65. package/vendor/tdai/utils/text-utils.js +29 -29
  66. package/vendor/tdai/utils/time.js +252 -252
@@ -1,69 +1,69 @@
1
- /**
2
- * OpenClawLLMRunner — wraps the existing CleanContextRunner as a host-neutral LLMRunner.
3
- *
4
- * This is a compatibility bridge: TDAI Core modules (L1 extractor, L2 scene extractor,
5
- * L3 persona generator, L1 dedup) can depend on the `LLMRunner` interface, while
6
- * OpenClaw continues to use its native `runEmbeddedPiAgent` mechanism under the hood.
7
- *
8
- * Usage:
9
- * const factory = new OpenClawLLMRunnerFactory({ config, agentRuntime, logger });
10
- * const runner = factory.createRunner({ modelRef: "openai/gpt-4o", enableTools: true });
11
- * const result = await runner.run({ prompt: "...", taskId: "l1-extraction" });
12
- */
13
- import { CleanContextRunner } from "../../utils/clean-context-runner.js";
14
- const TAG = "[memory-tdai] [openclaw-runner]";
15
- // ============================
16
- // OpenClawLLMRunner
17
- // ============================
18
- /**
19
- * LLMRunner implementation backed by CleanContextRunner.
20
- *
21
- * Each instance is configured with a fixed model + tools setting.
22
- * Create via `OpenClawLLMRunnerFactory.createRunner()`.
23
- */
24
- export class OpenClawLLMRunner {
25
- runner;
26
- constructor(runner) {
27
- this.runner = runner;
28
- }
29
- async run(params) {
30
- return this.runner.run({
31
- prompt: params.prompt,
32
- systemPrompt: params.systemPrompt,
33
- taskId: params.taskId,
34
- timeoutMs: params.timeoutMs,
35
- maxTokens: params.maxTokens,
36
- workspaceDir: params.workspaceDir,
37
- instanceId: params.instanceId,
38
- });
39
- }
40
- }
41
- /**
42
- * Factory that creates OpenClawLLMRunner instances.
43
- *
44
- * Encapsulates the OpenClaw-specific dependencies (config, agentRuntime)
45
- * so that callers only need to specify model + tools.
46
- */
47
- export class OpenClawLLMRunnerFactory {
48
- config;
49
- agentRuntime;
50
- logger;
51
- constructor(opts) {
52
- this.config = opts.config;
53
- this.agentRuntime = opts.agentRuntime;
54
- this.logger = opts.logger;
55
- }
56
- createRunner(opts) {
57
- const enableTools = opts?.enableTools ?? false;
58
- const modelRef = opts?.modelRef;
59
- this.logger?.debug?.(`${TAG} Creating OpenClawLLMRunner: model=${modelRef ?? "(default)"}, tools=${enableTools}`);
60
- const cleanRunner = new CleanContextRunner({
61
- config: this.config,
62
- modelRef,
63
- enableTools,
64
- agentRuntime: this.agentRuntime,
65
- logger: this.logger,
66
- });
67
- return new OpenClawLLMRunner(cleanRunner);
68
- }
69
- }
1
+ /**
2
+ * OpenClawLLMRunner — wraps the existing CleanContextRunner as a host-neutral LLMRunner.
3
+ *
4
+ * This is a compatibility bridge: TDAI Core modules (L1 extractor, L2 scene extractor,
5
+ * L3 persona generator, L1 dedup) can depend on the `LLMRunner` interface, while
6
+ * OpenClaw continues to use its native `runEmbeddedPiAgent` mechanism under the hood.
7
+ *
8
+ * Usage:
9
+ * const factory = new OpenClawLLMRunnerFactory({ config, agentRuntime, logger });
10
+ * const runner = factory.createRunner({ modelRef: "openai/gpt-4o", enableTools: true });
11
+ * const result = await runner.run({ prompt: "...", taskId: "l1-extraction" });
12
+ */
13
+ import { CleanContextRunner } from "../../utils/clean-context-runner.js";
14
+ const TAG = "[memory-tdai] [openclaw-runner]";
15
+ // ============================
16
+ // OpenClawLLMRunner
17
+ // ============================
18
+ /**
19
+ * LLMRunner implementation backed by CleanContextRunner.
20
+ *
21
+ * Each instance is configured with a fixed model + tools setting.
22
+ * Create via `OpenClawLLMRunnerFactory.createRunner()`.
23
+ */
24
+ export class OpenClawLLMRunner {
25
+ runner;
26
+ constructor(runner) {
27
+ this.runner = runner;
28
+ }
29
+ async run(params) {
30
+ return this.runner.run({
31
+ prompt: params.prompt,
32
+ systemPrompt: params.systemPrompt,
33
+ taskId: params.taskId,
34
+ timeoutMs: params.timeoutMs,
35
+ maxTokens: params.maxTokens,
36
+ workspaceDir: params.workspaceDir,
37
+ instanceId: params.instanceId,
38
+ });
39
+ }
40
+ }
41
+ /**
42
+ * Factory that creates OpenClawLLMRunner instances.
43
+ *
44
+ * Encapsulates the OpenClaw-specific dependencies (config, agentRuntime)
45
+ * so that callers only need to specify model + tools.
46
+ */
47
+ export class OpenClawLLMRunnerFactory {
48
+ config;
49
+ agentRuntime;
50
+ logger;
51
+ constructor(opts) {
52
+ this.config = opts.config;
53
+ this.agentRuntime = opts.agentRuntime;
54
+ this.logger = opts.logger;
55
+ }
56
+ createRunner(opts) {
57
+ const enableTools = opts?.enableTools ?? false;
58
+ const modelRef = opts?.modelRef;
59
+ this.logger?.debug?.(`${TAG} Creating OpenClawLLMRunner: model=${modelRef ?? "(default)"}, tools=${enableTools}`);
60
+ const cleanRunner = new CleanContextRunner({
61
+ config: this.config,
62
+ modelRef,
63
+ enableTools,
64
+ agentRuntime: this.agentRuntime,
65
+ logger: this.logger,
66
+ });
67
+ return new OpenClawLLMRunner(cleanRunner);
68
+ }
69
+ }
@@ -1,58 +1,58 @@
1
- /**
2
- * StandaloneHostAdapter — HostAdapter for the TDAI Gateway (Hermes sidecar).
3
- *
4
- * Does NOT depend on OpenClaw. Context is constructed from Gateway config
5
- * and per-request parameters (session_id, user_id, etc.).
6
- */
7
- import { StandaloneLLMRunnerFactory } from "./llm-runner.js";
8
- // ============================
9
- // StandaloneHostAdapter
10
- // ============================
11
- export class StandaloneHostAdapter {
12
- hostType = "standalone";
13
- dataDir;
14
- logger;
15
- runnerFactory;
16
- defaultUserId;
17
- platform;
18
- constructor(opts) {
19
- this.dataDir = opts.dataDir;
20
- this.logger = opts.logger;
21
- this.defaultUserId = opts.defaultUserId ?? "default_user";
22
- this.platform = opts.platform ?? "gateway";
23
- this.runnerFactory = new StandaloneLLMRunnerFactory({
24
- config: opts.llmConfig,
25
- logger: opts.logger,
26
- });
27
- }
28
- getRuntimeContext() {
29
- return {
30
- userId: this.defaultUserId,
31
- sessionId: "",
32
- sessionKey: "",
33
- platform: this.platform,
34
- workspaceDir: this.dataDir,
35
- dataDir: this.dataDir,
36
- };
37
- }
38
- /**
39
- * Build a RuntimeContext for a specific request.
40
- * Used by Gateway route handlers to scope each request to the correct user/session.
41
- */
42
- buildRuntimeContextForRequest(params) {
43
- return {
44
- userId: params.userId ?? this.defaultUserId,
45
- sessionId: params.sessionId ?? "",
46
- sessionKey: params.sessionKey ?? params.sessionId ?? "",
47
- platform: params.platform ?? this.platform,
48
- workspaceDir: this.dataDir,
49
- dataDir: this.dataDir,
50
- };
51
- }
52
- getLogger() {
53
- return this.logger;
54
- }
55
- getLLMRunnerFactory() {
56
- return this.runnerFactory;
57
- }
58
- }
1
+ /**
2
+ * StandaloneHostAdapter — HostAdapter for the TDAI Gateway (Hermes sidecar).
3
+ *
4
+ * Does NOT depend on OpenClaw. Context is constructed from Gateway config
5
+ * and per-request parameters (session_id, user_id, etc.).
6
+ */
7
+ import { StandaloneLLMRunnerFactory } from "./llm-runner.js";
8
+ // ============================
9
+ // StandaloneHostAdapter
10
+ // ============================
11
+ export class StandaloneHostAdapter {
12
+ hostType = "standalone";
13
+ dataDir;
14
+ logger;
15
+ runnerFactory;
16
+ defaultUserId;
17
+ platform;
18
+ constructor(opts) {
19
+ this.dataDir = opts.dataDir;
20
+ this.logger = opts.logger;
21
+ this.defaultUserId = opts.defaultUserId ?? "default_user";
22
+ this.platform = opts.platform ?? "gateway";
23
+ this.runnerFactory = new StandaloneLLMRunnerFactory({
24
+ config: opts.llmConfig,
25
+ logger: opts.logger,
26
+ });
27
+ }
28
+ getRuntimeContext() {
29
+ return {
30
+ userId: this.defaultUserId,
31
+ sessionId: "",
32
+ sessionKey: "",
33
+ platform: this.platform,
34
+ workspaceDir: this.dataDir,
35
+ dataDir: this.dataDir,
36
+ };
37
+ }
38
+ /**
39
+ * Build a RuntimeContext for a specific request.
40
+ * Used by Gateway route handlers to scope each request to the correct user/session.
41
+ */
42
+ buildRuntimeContextForRequest(params) {
43
+ return {
44
+ userId: params.userId ?? this.defaultUserId,
45
+ sessionId: params.sessionId ?? "",
46
+ sessionKey: params.sessionKey ?? params.sessionId ?? "",
47
+ platform: params.platform ?? this.platform,
48
+ workspaceDir: this.dataDir,
49
+ dataDir: this.dataDir,
50
+ };
51
+ }
52
+ getLogger() {
53
+ return this.logger;
54
+ }
55
+ getLLMRunnerFactory() {
56
+ return this.runnerFactory;
57
+ }
58
+ }
@@ -1,5 +1,5 @@
1
- /**
2
- * Standalone adapter — barrel exports.
3
- */
4
- export { StandaloneHostAdapter } from "./host-adapter.js";
5
- export { StandaloneLLMRunner, StandaloneLLMRunnerFactory } from "./llm-runner.js";
1
+ /**
2
+ * Standalone adapter — barrel exports.
3
+ */
4
+ export { StandaloneHostAdapter } from "./host-adapter.js";
5
+ export { StandaloneLLMRunner, StandaloneLLMRunnerFactory } from "./llm-runner.js";