opencode-graphiti 0.1.10 → 0.1.12

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 (45) hide show
  1. package/esm/_dnt.polyfills.d.ts +99 -0
  2. package/esm/_dnt.polyfills.d.ts.map +1 -1
  3. package/esm/_dnt.polyfills.js +127 -1
  4. package/esm/_dnt.shims.d.ts +6 -0
  5. package/esm/_dnt.shims.d.ts.map +1 -0
  6. package/esm/_dnt.shims.js +61 -0
  7. package/esm/src/config.d.ts +14 -7
  8. package/esm/src/config.d.ts.map +1 -1
  9. package/esm/src/config.js +103 -30
  10. package/esm/src/index.d.ts.map +1 -1
  11. package/esm/src/index.js +12 -6
  12. package/esm/src/services/client.d.ts +15 -30
  13. package/esm/src/services/client.d.ts.map +1 -1
  14. package/esm/src/services/client.js +86 -126
  15. package/esm/src/services/connection-manager.d.ts +97 -0
  16. package/esm/src/services/connection-manager.d.ts.map +1 -0
  17. package/esm/src/services/connection-manager.js +535 -0
  18. package/esm/src/services/logger.d.ts +2 -0
  19. package/esm/src/services/logger.d.ts.map +1 -1
  20. package/esm/src/services/logger.js +29 -3
  21. package/esm/src/utils.d.ts.map +1 -1
  22. package/esm/src/utils.js +10 -2
  23. package/package.json +2 -2
  24. package/script/_dnt.polyfills.d.ts +99 -0
  25. package/script/_dnt.polyfills.d.ts.map +1 -1
  26. package/script/_dnt.polyfills.js +128 -0
  27. package/script/_dnt.shims.d.ts +6 -0
  28. package/script/_dnt.shims.d.ts.map +1 -0
  29. package/script/_dnt.shims.js +65 -0
  30. package/script/src/config.d.ts +14 -7
  31. package/script/src/config.d.ts.map +1 -1
  32. package/script/src/config.js +106 -63
  33. package/script/src/index.d.ts.map +1 -1
  34. package/script/src/index.js +12 -6
  35. package/script/src/services/client.d.ts +15 -30
  36. package/script/src/services/client.d.ts.map +1 -1
  37. package/script/src/services/client.js +86 -129
  38. package/script/src/services/connection-manager.d.ts +97 -0
  39. package/script/src/services/connection-manager.d.ts.map +1 -0
  40. package/script/src/services/connection-manager.js +549 -0
  41. package/script/src/services/logger.d.ts +2 -0
  42. package/script/src/services/logger.d.ts.map +1 -1
  43. package/script/src/services/logger.js +65 -7
  44. package/script/src/utils.d.ts.map +1 -1
  45. package/script/src/utils.js +10 -2
@@ -47,4 +47,103 @@ declare global {
47
47
  }
48
48
  }
49
49
  export {};
50
+ /**
51
+ * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
52
+ * but instead of using npm to install additional dependencies,
53
+ * this approach manually consolidates cjs/mjs/d.ts into a single file.
54
+ *
55
+ * Note that this code might be imported multiple times
56
+ * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
57
+ * or Node.js might dynamically clear the cache and then force a require).
58
+ * Therefore, it's important to avoid redundant writes to global objects.
59
+ * Additionally, consider that commonjs is used alongside esm,
60
+ * so the two ponyfill functions are stored independently in two separate global objects.
61
+ */
62
+ import { createRequire } from "node:module";
63
+ import { type URL } from "node:url";
64
+ declare global {
65
+ interface ImportMeta {
66
+ /** A string representation of the fully qualified module URL. When the
67
+ * module is loaded locally, the value will be a file URL (e.g.
68
+ * `file:///path/module.ts`).
69
+ *
70
+ * You can also parse the string as a URL to determine more information about
71
+ * how the current module was loaded. For example to determine if a module was
72
+ * local or not:
73
+ *
74
+ * ```ts
75
+ * const url = new URL(import.meta.url);
76
+ * if (url.protocol === "file:") {
77
+ * console.log("this module was loaded locally");
78
+ * }
79
+ * ```
80
+ */
81
+ url: string;
82
+ /**
83
+ * A function that returns resolved specifier as if it would be imported
84
+ * using `import(specifier)`.
85
+ *
86
+ * ```ts
87
+ * console.log(import.meta.resolve("./foo.js"));
88
+ * // file:///dev/foo.js
89
+ * ```
90
+ *
91
+ * @param specifier The module specifier to resolve relative to `parent`.
92
+ * @param parent The absolute parent module URL to resolve from.
93
+ * @returns The absolute (`file:`) URL string for the resolved module.
94
+ */
95
+ resolve(specifier: string, parent?: string | URL | undefined): string;
96
+ /** A flag that indicates if the current module is the main module that was
97
+ * called when starting the program under Deno.
98
+ *
99
+ * ```ts
100
+ * if (import.meta.main) {
101
+ * // this was loaded as the main module, maybe do some bootstrapping
102
+ * }
103
+ * ```
104
+ */
105
+ main: boolean;
106
+ /** The absolute path of the current module.
107
+ *
108
+ * This property is only provided for local modules (ie. using `file://` URLs).
109
+ *
110
+ * Example:
111
+ * ```
112
+ * // Unix
113
+ * console.log(import.meta.filename); // /home/alice/my_module.ts
114
+ *
115
+ * // Windows
116
+ * console.log(import.meta.filename); // C:\alice\my_module.ts
117
+ * ```
118
+ */
119
+ filename: string;
120
+ /** The absolute path of the directory containing the current module.
121
+ *
122
+ * This property is only provided for local modules (ie. using `file://` URLs).
123
+ *
124
+ * * Example:
125
+ * ```
126
+ * // Unix
127
+ * console.log(import.meta.dirname); // /home/alice
128
+ *
129
+ * // Windows
130
+ * console.log(import.meta.dirname); // C:\alice
131
+ * ```
132
+ */
133
+ dirname: string;
134
+ }
135
+ }
136
+ type NodeRequest = ReturnType<typeof createRequire>;
137
+ type NodeModule = NonNullable<NodeRequest["main"]>;
138
+ interface ImportMetaPonyfillCommonjs {
139
+ (require: NodeRequest, module: NodeModule): ImportMeta;
140
+ }
141
+ interface ImportMetaPonyfillEsmodule {
142
+ (importMeta: ImportMeta): ImportMeta;
143
+ }
144
+ interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyfillEsmodule {
145
+ }
146
+ export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
147
+ export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
148
+ export declare let import_meta_ponyfill: ImportMetaPonyfill;
50
149
  //# sourceMappingURL=_dnt.polyfills.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,KAAK,CAAC,CAAC;QACf;;;;;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kBAAkB,CAAC"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.import_meta_ponyfill = exports.import_meta_ponyfill_esmodule = exports.import_meta_ponyfill_commonjs = void 0;
3
4
  function findLastIndex(self, callbackfn, that) {
4
5
  const boundFunc = that === undefined ? callbackfn : callbackfn.bind(that);
5
6
  let index = self.length - 1;
@@ -36,3 +37,130 @@ if (!Uint8Array.prototype.findLast) {
36
37
  return findLast(this, callbackfn, that);
37
38
  };
38
39
  }
40
+ /**
41
+ * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
42
+ * but instead of using npm to install additional dependencies,
43
+ * this approach manually consolidates cjs/mjs/d.ts into a single file.
44
+ *
45
+ * Note that this code might be imported multiple times
46
+ * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
47
+ * or Node.js might dynamically clear the cache and then force a require).
48
+ * Therefore, it's important to avoid redundant writes to global objects.
49
+ * Additionally, consider that commonjs is used alongside esm,
50
+ * so the two ponyfill functions are stored independently in two separate global objects.
51
+ */
52
+ //@ts-ignore
53
+ const node_module_1 = require("node:module");
54
+ //@ts-ignore
55
+ const node_url_1 = require("node:url");
56
+ //@ts-ignore
57
+ const node_path_1 = require("node:path");
58
+ const defineGlobalPonyfill = (symbolFor, fn) => {
59
+ if (!Reflect.has(globalThis, Symbol.for(symbolFor))) {
60
+ Object.defineProperty(globalThis, Symbol.for(symbolFor), {
61
+ configurable: true,
62
+ get() {
63
+ return fn;
64
+ },
65
+ });
66
+ }
67
+ };
68
+ exports.import_meta_ponyfill_commonjs = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-commonjs")) ??
69
+ (() => {
70
+ const moduleImportMetaWM = new WeakMap();
71
+ return (require, module) => {
72
+ let importMetaCache = moduleImportMetaWM.get(module);
73
+ if (importMetaCache == null) {
74
+ const importMeta = Object.assign(Object.create(null), {
75
+ url: (0, node_url_1.pathToFileURL)(module.filename).href,
76
+ main: require.main == module,
77
+ resolve: (specifier, parentURL = importMeta.url) => {
78
+ return (0, node_url_1.pathToFileURL)((importMeta.url === parentURL
79
+ ? require
80
+ : (0, node_module_1.createRequire)(parentURL))
81
+ .resolve(specifier)).href;
82
+ },
83
+ filename: module.filename,
84
+ dirname: module.path,
85
+ });
86
+ moduleImportMetaWM.set(module, importMeta);
87
+ importMetaCache = importMeta;
88
+ }
89
+ return importMetaCache;
90
+ };
91
+ })());
92
+ defineGlobalPonyfill("import-meta-ponyfill-commonjs", exports.import_meta_ponyfill_commonjs);
93
+ exports.import_meta_ponyfill_esmodule = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-esmodule")) ??
94
+ ((importMeta) => {
95
+ const resolveFunStr = String(importMeta.resolve);
96
+ const shimWs = new WeakSet();
97
+ //@ts-ignore
98
+ const mainUrl = ("file:///" + process.argv[1].replace(/\\/g, "/"))
99
+ .replace(/\/{3,}/, "///");
100
+ const commonShim = (importMeta) => {
101
+ if (typeof importMeta.main !== "boolean") {
102
+ importMeta.main = importMeta.url === mainUrl;
103
+ }
104
+ if (typeof importMeta.filename !== "string") {
105
+ importMeta.filename = (0, node_url_1.fileURLToPath)(importMeta.url);
106
+ importMeta.dirname = (0, node_path_1.dirname)(importMeta.filename);
107
+ }
108
+ };
109
+ if (
110
+ // v16.2.0+, v14.18.0+: Add support for WHATWG URL object to parentURL parameter.
111
+ resolveFunStr === "undefined" ||
112
+ // v20.0.0+, v18.19.0+"" This API now returns a string synchronously instead of a Promise.
113
+ resolveFunStr.startsWith("async")
114
+ // enable by --experimental-import-meta-resolve flag
115
+ ) {
116
+ exports.import_meta_ponyfill_esmodule = (importMeta) => {
117
+ if (!shimWs.has(importMeta)) {
118
+ shimWs.add(importMeta);
119
+ const importMetaUrlRequire = {
120
+ url: importMeta.url,
121
+ require: (0, node_module_1.createRequire)(importMeta.url),
122
+ };
123
+ importMeta.resolve = function resolve(specifier, parentURL = importMeta.url) {
124
+ return (0, node_url_1.pathToFileURL)((importMetaUrlRequire.url === parentURL
125
+ ? importMetaUrlRequire.require
126
+ : (0, node_module_1.createRequire)(parentURL)).resolve(specifier)).href;
127
+ };
128
+ commonShim(importMeta);
129
+ }
130
+ return importMeta;
131
+ };
132
+ }
133
+ else {
134
+ /// native support
135
+ exports.import_meta_ponyfill_esmodule = (importMeta) => {
136
+ if (!shimWs.has(importMeta)) {
137
+ shimWs.add(importMeta);
138
+ commonShim(importMeta);
139
+ }
140
+ return importMeta;
141
+ };
142
+ }
143
+ return (0, exports.import_meta_ponyfill_esmodule)(importMeta);
144
+ }));
145
+ defineGlobalPonyfill("import-meta-ponyfill-esmodule", exports.import_meta_ponyfill_esmodule);
146
+ exports.import_meta_ponyfill = ((...args) => {
147
+ const _MODULE = (() => {
148
+ if (typeof require === "function" && typeof module === "object") {
149
+ return "commonjs";
150
+ }
151
+ else {
152
+ // eval("typeof import.meta");
153
+ return "esmodule";
154
+ }
155
+ })();
156
+ if (_MODULE === "commonjs") {
157
+ //@ts-ignore
158
+ exports.import_meta_ponyfill = (r, m) => (0, exports.import_meta_ponyfill_commonjs)(r, m);
159
+ }
160
+ else {
161
+ //@ts-ignore
162
+ exports.import_meta_ponyfill = (im) => (0, exports.import_meta_ponyfill_esmodule)(im);
163
+ }
164
+ //@ts-ignore
165
+ return (0, exports.import_meta_ponyfill)(...args);
166
+ });
@@ -0,0 +1,6 @@
1
+ import { Deno } from "@deno/shim-deno";
2
+ export { Deno } from "@deno/shim-deno";
3
+ export declare const dntGlobalThis: Omit<typeof globalThis, "Deno"> & {
4
+ Deno: typeof Deno;
5
+ };
6
+ //# sourceMappingURL=_dnt.shims.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAKvC,eAAO,MAAM,aAAa;;CAA2C,CAAC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dntGlobalThis = exports.Deno = void 0;
4
+ const shim_deno_1 = require("@deno/shim-deno");
5
+ var shim_deno_2 = require("@deno/shim-deno");
6
+ Object.defineProperty(exports, "Deno", { enumerable: true, get: function () { return shim_deno_2.Deno; } });
7
+ const dntGlobals = {
8
+ Deno: shim_deno_1.Deno,
9
+ };
10
+ exports.dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
11
+ function createMergeProxy(baseObj, extObj) {
12
+ return new Proxy(baseObj, {
13
+ get(_target, prop, _receiver) {
14
+ if (prop in extObj) {
15
+ return extObj[prop];
16
+ }
17
+ else {
18
+ return baseObj[prop];
19
+ }
20
+ },
21
+ set(_target, prop, value) {
22
+ if (prop in extObj) {
23
+ delete extObj[prop];
24
+ }
25
+ baseObj[prop] = value;
26
+ return true;
27
+ },
28
+ deleteProperty(_target, prop) {
29
+ let success = false;
30
+ if (prop in extObj) {
31
+ delete extObj[prop];
32
+ success = true;
33
+ }
34
+ if (prop in baseObj) {
35
+ delete baseObj[prop];
36
+ success = true;
37
+ }
38
+ return success;
39
+ },
40
+ ownKeys(_target) {
41
+ const baseKeys = Reflect.ownKeys(baseObj);
42
+ const extKeys = Reflect.ownKeys(extObj);
43
+ const extKeysSet = new Set(extKeys);
44
+ return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
45
+ },
46
+ defineProperty(_target, prop, desc) {
47
+ if (prop in extObj) {
48
+ delete extObj[prop];
49
+ }
50
+ Reflect.defineProperty(baseObj, prop, desc);
51
+ return true;
52
+ },
53
+ getOwnPropertyDescriptor(_target, prop) {
54
+ if (prop in extObj) {
55
+ return Reflect.getOwnPropertyDescriptor(extObj, prop);
56
+ }
57
+ else {
58
+ return Reflect.getOwnPropertyDescriptor(baseObj, prop);
59
+ }
60
+ },
61
+ has(_target, prop) {
62
+ return prop in extObj || prop in baseObj;
63
+ },
64
+ });
65
+ }
@@ -1,12 +1,19 @@
1
1
  import type { GraphitiConfig } from "./types/index.js";
2
+ type ConfigLoadResult = {
3
+ config: unknown;
4
+ } | null;
5
+ export interface ConfigExplorerAdapter {
6
+ search(from?: string): ConfigLoadResult;
7
+ load(filePath: string): ConfigLoadResult;
8
+ }
9
+ type ConfigExplorerFactory = () => ConfigExplorerAdapter;
10
+ export declare const setConfigExplorerAdapterForTesting: (factory: ConfigExplorerFactory) => void;
11
+ export declare const resetConfigExplorerAdapterForTesting: () => void;
2
12
  /**
3
- * Load Graphiti configuration from JSONC files with defaults applied.
4
- *
5
- * When `directory` is provided, the search starts from that directory (no
6
- * upward traversal past it) so that a project-local `.graphitirc` or
7
- * `package.json#graphiti` key takes precedence over any global/home config.
8
- * If no config is found in the project directory the search falls back to a
9
- * global search (home directory and OS-level config locations).
13
+ * Load Graphiti configuration via cosmiconfig discovery, with a legacy fallback
14
+ * to `~/.config/opencode/.graphitirc` only when discovery succeeds and returns
15
+ * no result.
10
16
  */
11
17
  export declare function loadConfig(directory?: string): GraphitiConfig;
18
+ export {};
12
19
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/src/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAgBvD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,cAAc,CAoB7D"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/src/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAWvD,KAAK,gBAAgB,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC;AAMnD,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC;IACxC,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CAAC;CAC1C;AAED,KAAK,qBAAqB,GAAG,MAAM,qBAAqB,CAAC;AAgDzD,eAAO,MAAM,kCAAkC,GAC7C,SAAS,qBAAqB,KAC7B,IAEF,CAAC;AAEF,eAAO,MAAM,oCAAoC,QAAO,IAEvD,CAAC;AAiEF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,cAAc,CAa7D"}
@@ -1,82 +1,125 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.resetConfigExplorerAdapterForTesting = exports.setConfigExplorerAdapterForTesting = void 0;
39
7
  exports.loadConfig = loadConfig;
40
- const cosmiconfig_1 = require("cosmiconfig");
41
8
  const node_os_1 = __importDefault(require("node:os"));
42
- const z = __importStar(require("zod/mini"));
9
+ const node_module_1 = require("node:module");
10
+ const node_path_1 = require("node:path");
43
11
  const DEFAULT_CONFIG = {
44
12
  endpoint: "http://localhost:8000/mcp",
45
13
  groupIdPrefix: "opencode",
46
14
  driftThreshold: 0.5,
47
15
  factStaleDays: 30,
48
16
  };
49
- const GraphitiConfigSchema = z.object({
50
- endpoint: z.string(),
51
- groupIdPrefix: z.string(),
52
- driftThreshold: z.number(),
53
- factStaleDays: z.number(),
54
- });
17
+ const require = (0, node_module_1.createRequire)(globalThis[Symbol.for("import-meta-ponyfill-commonjs")](require, module).url);
18
+ const isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
19
+ const normalizeConfig = (value) => {
20
+ if (!isRecord(value))
21
+ return {};
22
+ const config = {};
23
+ if (typeof value.endpoint === "string")
24
+ config.endpoint = value.endpoint;
25
+ if (typeof value.groupIdPrefix === "string") {
26
+ config.groupIdPrefix = value.groupIdPrefix;
27
+ }
28
+ if (typeof value.driftThreshold === "number") {
29
+ config.driftThreshold = value.driftThreshold;
30
+ }
31
+ if (typeof value.factStaleDays === "number") {
32
+ config.factStaleDays = value.factStaleDays;
33
+ }
34
+ return config;
35
+ };
36
+ const createCosmiconfigAdapter = () => {
37
+ const { cosmiconfigSync } = require("cosmiconfig");
38
+ const explorer = cosmiconfigSync("graphiti", { searchStrategy: "global" });
39
+ return {
40
+ search(from) {
41
+ return explorer.search(from);
42
+ },
43
+ load(filePath) {
44
+ return explorer.load(filePath);
45
+ },
46
+ };
47
+ };
48
+ let configExplorerFactory = createCosmiconfigAdapter;
49
+ const setConfigExplorerAdapterForTesting = (factory) => {
50
+ configExplorerFactory = factory;
51
+ };
52
+ exports.setConfigExplorerAdapterForTesting = setConfigExplorerAdapterForTesting;
53
+ const resetConfigExplorerAdapterForTesting = () => {
54
+ configExplorerFactory = createCosmiconfigAdapter;
55
+ };
56
+ exports.resetConfigExplorerAdapterForTesting = resetConfigExplorerAdapterForTesting;
57
+ const getConfigExplorerAdapter = () => {
58
+ try {
59
+ return configExplorerFactory();
60
+ }
61
+ catch {
62
+ return null;
63
+ }
64
+ };
65
+ const loadConfigFile = (adapter, filePath) => {
66
+ try {
67
+ const loaded = adapter?.load(filePath);
68
+ return loaded ? normalizeConfig(loaded.config) : null;
69
+ }
70
+ catch {
71
+ return null;
72
+ }
73
+ };
74
+ const getHomeDir = () => {
75
+ try {
76
+ return node_os_1.default.homedir();
77
+ }
78
+ catch {
79
+ return undefined;
80
+ }
81
+ };
82
+ const getSearchStartDir = (directory) => {
83
+ try {
84
+ return directory === undefined ? undefined : directory;
85
+ }
86
+ catch {
87
+ return undefined;
88
+ }
89
+ };
90
+ const searchConfig = (adapter, directory) => {
91
+ try {
92
+ const loaded = adapter.search(getSearchStartDir(directory));
93
+ return {
94
+ ok: true,
95
+ config: loaded ? normalizeConfig(loaded.config) : null,
96
+ };
97
+ }
98
+ catch {
99
+ return { ok: false };
100
+ }
101
+ };
102
+ const loadLegacyConfig = (adapter) => {
103
+ const homeDir = getHomeDir();
104
+ if (!homeDir)
105
+ return null;
106
+ return loadConfigFile(adapter, (0, node_path_1.join)(homeDir, ".config", "opencode", ".graphitirc"));
107
+ };
55
108
  /**
56
- * Load Graphiti configuration from JSONC files with defaults applied.
57
- *
58
- * When `directory` is provided, the search starts from that directory (no
59
- * upward traversal past it) so that a project-local `.graphitirc` or
60
- * `package.json#graphiti` key takes precedence over any global/home config.
61
- * If no config is found in the project directory the search falls back to a
62
- * global search (home directory and OS-level config locations).
109
+ * Load Graphiti configuration via cosmiconfig discovery, with a legacy fallback
110
+ * to `~/.config/opencode/.graphitirc` only when discovery succeeds and returns
111
+ * no result.
63
112
  */
64
113
  function loadConfig(directory) {
65
- const result = (0, cosmiconfig_1.cosmiconfigSync)("graphiti", {
66
- stopDir: node_os_1.default.homedir(),
67
- mergeSearchPlaces: true,
68
- cache: false,
69
- }).search(directory) ??
70
- (0, cosmiconfig_1.cosmiconfigSync)("graphiti", {
71
- searchPlaces: [`${node_os_1.default.homedir()}/.graphitirc`],
72
- }).search();
73
- const merged = {
114
+ const adapter = getConfigExplorerAdapter();
115
+ if (!adapter)
116
+ return { ...DEFAULT_CONFIG };
117
+ const searched = searchConfig(adapter, directory);
118
+ if (!searched.ok)
119
+ return { ...DEFAULT_CONFIG };
120
+ const loaded = searched.config ?? loadLegacyConfig(adapter);
121
+ return {
74
122
  ...DEFAULT_CONFIG,
75
- ...result?.config,
123
+ ...(loaded ?? {}),
76
124
  };
77
- const parsed = GraphitiConfigSchema.safeParse(merged);
78
- if (parsed.success) {
79
- return parsed.data;
80
- }
81
- return DEFAULT_CONFIG;
82
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAW/D;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAuDtB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,qBAAqB,CAAC;AAY/D;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MA+DtB,CAAC"}
@@ -7,6 +7,7 @@ const compacting_js_1 = require("./handlers/compacting.js");
7
7
  const event_js_1 = require("./handlers/event.js");
8
8
  const messages_js_1 = require("./handlers/messages.js");
9
9
  const client_js_1 = require("./services/client.js");
10
+ const connection_manager_js_1 = require("./services/connection-manager.js");
10
11
  const logger_js_1 = require("./services/logger.js");
11
12
  const session_js_1 = require("./session.js");
12
13
  const utils_js_1 = require("./utils.js");
@@ -15,13 +16,18 @@ const utils_js_1 = require("./utils.js");
15
16
  */
16
17
  const graphiti = async (input) => {
17
18
  const config = (0, config_js_1.loadConfig)(input.directory);
18
- const client = new client_js_1.GraphitiClient(config.endpoint);
19
+ const connectionManager = new connection_manager_js_1.GraphitiConnectionManager({
20
+ endpoint: config.endpoint,
21
+ });
22
+ connectionManager.start();
23
+ void connectionManager.ready().then((connected) => {
24
+ if (!connected) {
25
+ logger_js_1.logger.warn("Could not connect to Graphiti MCP server at", config.endpoint);
26
+ logger_js_1.logger.warn("Memory features will be unavailable until connection is established");
27
+ }
28
+ });
29
+ const client = new client_js_1.GraphitiClient(connectionManager);
19
30
  const sdkClient = input.client;
20
- const connected = await client.connect();
21
- if (!connected) {
22
- logger_js_1.logger.warn("Could not connect to Graphiti MCP server at", config.endpoint);
23
- logger_js_1.logger.warn("Memory features will be unavailable until connection is established");
24
- }
25
31
  const defaultGroupId = (0, utils_js_1.makeGroupId)(config.groupIdPrefix, input.directory);
26
32
  const defaultUserGroupId = (0, utils_js_1.makeUserGroupId)(config.groupIdPrefix, input.directory);
27
33
  logger_js_1.logger.info("Plugin initialized. Group ID:", defaultGroupId);
@@ -1,36 +1,27 @@
1
+ import { type GraphitiToolCaller } from "./connection-manager.js";
1
2
  import type { GraphitiEpisode, GraphitiFact, GraphitiNode } from "../types/index.js";
2
3
  /**
3
- * Graphiti MCP client wrapper for connecting, querying,
4
- * and persisting episodes with basic reconnection handling.
4
+ * Graphiti domain adapter over the connection manager.
5
5
  */
6
6
  export declare class GraphitiClient {
7
- private client;
8
- private transport;
9
- private connected;
10
- private endpoint;
11
- /**
12
- * Create a Graphiti client bound to the given MCP endpoint URL.
13
- */
14
- constructor(endpoint: string);
15
- /** Create a fresh MCP Client and Transport pair. */
16
- private createClientAndTransport;
17
- /**
18
- * Establish a connection to the Graphiti MCP server.
19
- * Creates a fresh Client/Transport if a previous attempt failed.
20
- */
7
+ private readonly toolCaller;
8
+ constructor(endpointOrManager: string | GraphitiToolCaller);
9
+ start(): void;
10
+ stop(): Promise<void>;
21
11
  connect(): Promise<boolean>;
22
- /**
23
- * Close the underlying MCP client connection.
24
- */
25
- disconnect(): Promise<void>;
26
- private callTool;
27
- private isSessionExpired;
28
- private reconnect;
12
+ ready(timeoutMs?: number): Promise<boolean>;
29
13
  /**
30
14
  * Parse MCP tool results into JSON when possible.
31
15
  * Public for testing.
32
16
  */
33
17
  parseToolResult(result: unknown): unknown;
18
+ /**
19
+ * Extract an array from a tool result that may be a bare array or a
20
+ * wrapped-array response object (`{ [key]: T[] }`).
21
+ * Returns the array when found, otherwise `null`.
22
+ * Public for testing.
23
+ */
24
+ parseWrappedArray<T>(result: unknown, wrappedKey: string): T[] | null;
34
25
  /**
35
26
  * Add an episode to Graphiti memory.
36
27
  */
@@ -41,13 +32,6 @@ export declare class GraphitiClient {
41
32
  source?: "text" | "json" | "message";
42
33
  sourceDescription?: string;
43
34
  }): Promise<void>;
44
- /**
45
- * Extract an array from a tool result that may be a bare array or a
46
- * wrapped-array response object (`{ [key]: T[] }`).
47
- * Returns the array when found, otherwise `null`.
48
- * Public for testing.
49
- */
50
- parseWrappedArray<T>(result: unknown, wrappedKey: string): T[] | null;
51
35
  /**
52
36
  * Search Graphiti facts matching the provided query.
53
37
  */
@@ -75,5 +59,6 @@ export declare class GraphitiClient {
75
59
  * Check whether the Graphiti MCP server is reachable.
76
60
  */
77
61
  getStatus(): Promise<boolean>;
62
+ private callTool;
78
63
  }
79
64
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/src/services/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,YAAY,EACb,MAAM,mBAAmB,CAAC;AAI3B;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,SAAS,CAAS;IA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