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.
- package/esm/_dnt.polyfills.d.ts +99 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +127 -1
- package/esm/_dnt.shims.d.ts +6 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +61 -0
- package/esm/src/config.d.ts +14 -7
- package/esm/src/config.d.ts.map +1 -1
- package/esm/src/config.js +103 -30
- package/esm/src/index.d.ts.map +1 -1
- package/esm/src/index.js +12 -6
- package/esm/src/services/client.d.ts +15 -30
- package/esm/src/services/client.d.ts.map +1 -1
- package/esm/src/services/client.js +86 -126
- package/esm/src/services/connection-manager.d.ts +97 -0
- package/esm/src/services/connection-manager.d.ts.map +1 -0
- package/esm/src/services/connection-manager.js +535 -0
- package/esm/src/services/logger.d.ts +2 -0
- package/esm/src/services/logger.d.ts.map +1 -1
- package/esm/src/services/logger.js +29 -3
- package/esm/src/utils.d.ts.map +1 -1
- package/esm/src/utils.js +10 -2
- package/package.json +2 -2
- package/script/_dnt.polyfills.d.ts +99 -0
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +128 -0
- package/script/_dnt.shims.d.ts +6 -0
- package/script/_dnt.shims.d.ts.map +1 -0
- package/script/_dnt.shims.js +65 -0
- package/script/src/config.d.ts +14 -7
- package/script/src/config.d.ts.map +1 -1
- package/script/src/config.js +106 -63
- package/script/src/index.d.ts.map +1 -1
- package/script/src/index.js +12 -6
- package/script/src/services/client.d.ts +15 -30
- package/script/src/services/client.d.ts.map +1 -1
- package/script/src/services/client.js +86 -129
- package/script/src/services/connection-manager.d.ts +97 -0
- package/script/src/services/connection-manager.d.ts.map +1 -0
- package/script/src/services/connection-manager.js +549 -0
- package/script/src/services/logger.d.ts +2 -0
- package/script/src/services/logger.d.ts.map +1 -1
- package/script/src/services/logger.js +65 -7
- package/script/src/utils.d.ts.map +1 -1
- package/script/src/utils.js +10 -2
package/esm/_dnt.polyfills.d.ts
CHANGED
|
@@ -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;;;;;;;;WAQG;QACH,QAAQ,CAAC,CAAC,SAAS,CAAC,EAClB,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC,EACxE,OAAO,CAAC,EAAE,GAAG,GACZ,CAAC,GAAG,SAAS,CAAC;QACjB,QAAQ,CACN,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,OAAO,EACzD,OAAO,CAAC,EAAE,GAAG,GACZ,CAAC,GAAG,SAAS,CAAC;QAEjB;;;;;;;;WAQG;QACH,aAAa,CACX,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAA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GAAG,MAAM,CAAC;QACtE;;;;;;;;WAQG;QACH,IAAI,EAAE,OAAO,CAAC;QAEd;;;;;;;;;;;;WAYG;QACH,QAAQ,EAAE,MAAM,CAAC;QAEjB;;;;;;;;;;;;WAYG;QACH,OAAO,EAAE,MAAM,CAAC;KACjB;CACF;AAED,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,KAAK,UAAU,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACnD,UAAU,0BAA0B;IAClC,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CACxD;AACD,UAAU,0BAA0B;IAClC,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;CACtC;AACD,UAAU,kBACR,SAAQ,0BAA0B,EAAE,0BAA0B;CAC/D;AAiBD,eAAO,IAAI,6BAA6B,EA2BnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,6BAA6B,EA4DnC,0BAA0B,CAAC;AAMhC,eAAO,IAAI,oBAAoB,EAoB1B,kBAAkB,CAAC"}
|
package/esm/_dnt.polyfills.js
CHANGED
|
@@ -34,4 +34,130 @@ if (!Uint8Array.prototype.findLast) {
|
|
|
34
34
|
return findLast(this, callbackfn, that);
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
|
|
39
|
+
* but instead of using npm to install additional dependencies,
|
|
40
|
+
* this approach manually consolidates cjs/mjs/d.ts into a single file.
|
|
41
|
+
*
|
|
42
|
+
* Note that this code might be imported multiple times
|
|
43
|
+
* (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
|
|
44
|
+
* or Node.js might dynamically clear the cache and then force a require).
|
|
45
|
+
* Therefore, it's important to avoid redundant writes to global objects.
|
|
46
|
+
* Additionally, consider that commonjs is used alongside esm,
|
|
47
|
+
* so the two ponyfill functions are stored independently in two separate global objects.
|
|
48
|
+
*/
|
|
49
|
+
//@ts-ignore
|
|
50
|
+
import { createRequire } from "node:module";
|
|
51
|
+
//@ts-ignore
|
|
52
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
53
|
+
//@ts-ignore
|
|
54
|
+
import { dirname } from "node:path";
|
|
55
|
+
const defineGlobalPonyfill = (symbolFor, fn) => {
|
|
56
|
+
if (!Reflect.has(globalThis, Symbol.for(symbolFor))) {
|
|
57
|
+
Object.defineProperty(globalThis, Symbol.for(symbolFor), {
|
|
58
|
+
configurable: true,
|
|
59
|
+
get() {
|
|
60
|
+
return fn;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
export let import_meta_ponyfill_commonjs = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-commonjs")) ??
|
|
66
|
+
(() => {
|
|
67
|
+
const moduleImportMetaWM = new WeakMap();
|
|
68
|
+
return (require, module) => {
|
|
69
|
+
let importMetaCache = moduleImportMetaWM.get(module);
|
|
70
|
+
if (importMetaCache == null) {
|
|
71
|
+
const importMeta = Object.assign(Object.create(null), {
|
|
72
|
+
url: pathToFileURL(module.filename).href,
|
|
73
|
+
main: require.main == module,
|
|
74
|
+
resolve: (specifier, parentURL = importMeta.url) => {
|
|
75
|
+
return pathToFileURL((importMeta.url === parentURL
|
|
76
|
+
? require
|
|
77
|
+
: createRequire(parentURL))
|
|
78
|
+
.resolve(specifier)).href;
|
|
79
|
+
},
|
|
80
|
+
filename: module.filename,
|
|
81
|
+
dirname: module.path,
|
|
82
|
+
});
|
|
83
|
+
moduleImportMetaWM.set(module, importMeta);
|
|
84
|
+
importMetaCache = importMeta;
|
|
85
|
+
}
|
|
86
|
+
return importMetaCache;
|
|
87
|
+
};
|
|
88
|
+
})());
|
|
89
|
+
defineGlobalPonyfill("import-meta-ponyfill-commonjs", import_meta_ponyfill_commonjs);
|
|
90
|
+
export let import_meta_ponyfill_esmodule = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-esmodule")) ??
|
|
91
|
+
((importMeta) => {
|
|
92
|
+
const resolveFunStr = String(importMeta.resolve);
|
|
93
|
+
const shimWs = new WeakSet();
|
|
94
|
+
//@ts-ignore
|
|
95
|
+
const mainUrl = ("file:///" + process.argv[1].replace(/\\/g, "/"))
|
|
96
|
+
.replace(/\/{3,}/, "///");
|
|
97
|
+
const commonShim = (importMeta) => {
|
|
98
|
+
if (typeof importMeta.main !== "boolean") {
|
|
99
|
+
importMeta.main = importMeta.url === mainUrl;
|
|
100
|
+
}
|
|
101
|
+
if (typeof importMeta.filename !== "string") {
|
|
102
|
+
importMeta.filename = fileURLToPath(importMeta.url);
|
|
103
|
+
importMeta.dirname = dirname(importMeta.filename);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
if (
|
|
107
|
+
// v16.2.0+, v14.18.0+: Add support for WHATWG URL object to parentURL parameter.
|
|
108
|
+
resolveFunStr === "undefined" ||
|
|
109
|
+
// v20.0.0+, v18.19.0+"" This API now returns a string synchronously instead of a Promise.
|
|
110
|
+
resolveFunStr.startsWith("async")
|
|
111
|
+
// enable by --experimental-import-meta-resolve flag
|
|
112
|
+
) {
|
|
113
|
+
import_meta_ponyfill_esmodule = (importMeta) => {
|
|
114
|
+
if (!shimWs.has(importMeta)) {
|
|
115
|
+
shimWs.add(importMeta);
|
|
116
|
+
const importMetaUrlRequire = {
|
|
117
|
+
url: importMeta.url,
|
|
118
|
+
require: createRequire(importMeta.url),
|
|
119
|
+
};
|
|
120
|
+
importMeta.resolve = function resolve(specifier, parentURL = importMeta.url) {
|
|
121
|
+
return pathToFileURL((importMetaUrlRequire.url === parentURL
|
|
122
|
+
? importMetaUrlRequire.require
|
|
123
|
+
: createRequire(parentURL)).resolve(specifier)).href;
|
|
124
|
+
};
|
|
125
|
+
commonShim(importMeta);
|
|
126
|
+
}
|
|
127
|
+
return importMeta;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
/// native support
|
|
132
|
+
import_meta_ponyfill_esmodule = (importMeta) => {
|
|
133
|
+
if (!shimWs.has(importMeta)) {
|
|
134
|
+
shimWs.add(importMeta);
|
|
135
|
+
commonShim(importMeta);
|
|
136
|
+
}
|
|
137
|
+
return importMeta;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return import_meta_ponyfill_esmodule(importMeta);
|
|
141
|
+
}));
|
|
142
|
+
defineGlobalPonyfill("import-meta-ponyfill-esmodule", import_meta_ponyfill_esmodule);
|
|
143
|
+
export let import_meta_ponyfill = ((...args) => {
|
|
144
|
+
const _MODULE = (() => {
|
|
145
|
+
if (typeof require === "function" && typeof module === "object") {
|
|
146
|
+
return "commonjs";
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// eval("typeof import.meta");
|
|
150
|
+
return "esmodule";
|
|
151
|
+
}
|
|
152
|
+
})();
|
|
153
|
+
if (_MODULE === "commonjs") {
|
|
154
|
+
//@ts-ignore
|
|
155
|
+
import_meta_ponyfill = (r, m) => import_meta_ponyfill_commonjs(r, m);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
//@ts-ignore
|
|
159
|
+
import_meta_ponyfill = (im) => import_meta_ponyfill_esmodule(im);
|
|
160
|
+
}
|
|
161
|
+
//@ts-ignore
|
|
162
|
+
return import_meta_ponyfill(...args);
|
|
163
|
+
});
|
|
@@ -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,61 @@
|
|
|
1
|
+
import { Deno } from "@deno/shim-deno";
|
|
2
|
+
export { Deno } from "@deno/shim-deno";
|
|
3
|
+
const dntGlobals = {
|
|
4
|
+
Deno,
|
|
5
|
+
};
|
|
6
|
+
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
7
|
+
function createMergeProxy(baseObj, extObj) {
|
|
8
|
+
return new Proxy(baseObj, {
|
|
9
|
+
get(_target, prop, _receiver) {
|
|
10
|
+
if (prop in extObj) {
|
|
11
|
+
return extObj[prop];
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return baseObj[prop];
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
set(_target, prop, value) {
|
|
18
|
+
if (prop in extObj) {
|
|
19
|
+
delete extObj[prop];
|
|
20
|
+
}
|
|
21
|
+
baseObj[prop] = value;
|
|
22
|
+
return true;
|
|
23
|
+
},
|
|
24
|
+
deleteProperty(_target, prop) {
|
|
25
|
+
let success = false;
|
|
26
|
+
if (prop in extObj) {
|
|
27
|
+
delete extObj[prop];
|
|
28
|
+
success = true;
|
|
29
|
+
}
|
|
30
|
+
if (prop in baseObj) {
|
|
31
|
+
delete baseObj[prop];
|
|
32
|
+
success = true;
|
|
33
|
+
}
|
|
34
|
+
return success;
|
|
35
|
+
},
|
|
36
|
+
ownKeys(_target) {
|
|
37
|
+
const baseKeys = Reflect.ownKeys(baseObj);
|
|
38
|
+
const extKeys = Reflect.ownKeys(extObj);
|
|
39
|
+
const extKeysSet = new Set(extKeys);
|
|
40
|
+
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
|
41
|
+
},
|
|
42
|
+
defineProperty(_target, prop, desc) {
|
|
43
|
+
if (prop in extObj) {
|
|
44
|
+
delete extObj[prop];
|
|
45
|
+
}
|
|
46
|
+
Reflect.defineProperty(baseObj, prop, desc);
|
|
47
|
+
return true;
|
|
48
|
+
},
|
|
49
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
50
|
+
if (prop in extObj) {
|
|
51
|
+
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
has(_target, prop) {
|
|
58
|
+
return prop in extObj || prop in baseObj;
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
package/esm/src/config.d.ts
CHANGED
|
@@ -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
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
package/esm/src/config.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|
package/esm/src/config.js
CHANGED
|
@@ -1,43 +1,116 @@
|
|
|
1
|
-
import { cosmiconfigSync } from "cosmiconfig";
|
|
2
1
|
import os from "node:os";
|
|
3
|
-
import
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { join } from "node:path";
|
|
4
4
|
const DEFAULT_CONFIG = {
|
|
5
5
|
endpoint: "http://localhost:8000/mcp",
|
|
6
6
|
groupIdPrefix: "opencode",
|
|
7
7
|
driftThreshold: 0.5,
|
|
8
8
|
factStaleDays: 30,
|
|
9
9
|
};
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
10
|
+
const require = createRequire(globalThis[Symbol.for("import-meta-ponyfill-esmodule")](import.meta).url);
|
|
11
|
+
const isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
12
|
+
const normalizeConfig = (value) => {
|
|
13
|
+
if (!isRecord(value))
|
|
14
|
+
return {};
|
|
15
|
+
const config = {};
|
|
16
|
+
if (typeof value.endpoint === "string")
|
|
17
|
+
config.endpoint = value.endpoint;
|
|
18
|
+
if (typeof value.groupIdPrefix === "string") {
|
|
19
|
+
config.groupIdPrefix = value.groupIdPrefix;
|
|
20
|
+
}
|
|
21
|
+
if (typeof value.driftThreshold === "number") {
|
|
22
|
+
config.driftThreshold = value.driftThreshold;
|
|
23
|
+
}
|
|
24
|
+
if (typeof value.factStaleDays === "number") {
|
|
25
|
+
config.factStaleDays = value.factStaleDays;
|
|
26
|
+
}
|
|
27
|
+
return config;
|
|
28
|
+
};
|
|
29
|
+
const createCosmiconfigAdapter = () => {
|
|
30
|
+
const { cosmiconfigSync } = require("cosmiconfig");
|
|
31
|
+
const explorer = cosmiconfigSync("graphiti", { searchStrategy: "global" });
|
|
32
|
+
return {
|
|
33
|
+
search(from) {
|
|
34
|
+
return explorer.search(from);
|
|
35
|
+
},
|
|
36
|
+
load(filePath) {
|
|
37
|
+
return explorer.load(filePath);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
let configExplorerFactory = createCosmiconfigAdapter;
|
|
42
|
+
export const setConfigExplorerAdapterForTesting = (factory) => {
|
|
43
|
+
configExplorerFactory = factory;
|
|
44
|
+
};
|
|
45
|
+
export const resetConfigExplorerAdapterForTesting = () => {
|
|
46
|
+
configExplorerFactory = createCosmiconfigAdapter;
|
|
47
|
+
};
|
|
48
|
+
const getConfigExplorerAdapter = () => {
|
|
49
|
+
try {
|
|
50
|
+
return configExplorerFactory();
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const loadConfigFile = (adapter, filePath) => {
|
|
57
|
+
try {
|
|
58
|
+
const loaded = adapter?.load(filePath);
|
|
59
|
+
return loaded ? normalizeConfig(loaded.config) : null;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const getHomeDir = () => {
|
|
66
|
+
try {
|
|
67
|
+
return os.homedir();
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const getSearchStartDir = (directory) => {
|
|
74
|
+
try {
|
|
75
|
+
return directory === undefined ? undefined : directory;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const searchConfig = (adapter, directory) => {
|
|
82
|
+
try {
|
|
83
|
+
const loaded = adapter.search(getSearchStartDir(directory));
|
|
84
|
+
return {
|
|
85
|
+
ok: true,
|
|
86
|
+
config: loaded ? normalizeConfig(loaded.config) : null,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return { ok: false };
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const loadLegacyConfig = (adapter) => {
|
|
94
|
+
const homeDir = getHomeDir();
|
|
95
|
+
if (!homeDir)
|
|
96
|
+
return null;
|
|
97
|
+
return loadConfigFile(adapter, join(homeDir, ".config", "opencode", ".graphitirc"));
|
|
98
|
+
};
|
|
16
99
|
/**
|
|
17
|
-
* Load Graphiti configuration
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* upward traversal past it) so that a project-local `.graphitirc` or
|
|
21
|
-
* `package.json#graphiti` key takes precedence over any global/home config.
|
|
22
|
-
* If no config is found in the project directory the search falls back to a
|
|
23
|
-
* global search (home directory and OS-level config locations).
|
|
100
|
+
* Load Graphiti configuration via cosmiconfig discovery, with a legacy fallback
|
|
101
|
+
* to `~/.config/opencode/.graphitirc` only when discovery succeeds and returns
|
|
102
|
+
* no result.
|
|
24
103
|
*/
|
|
25
104
|
export function loadConfig(directory) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const merged = {
|
|
105
|
+
const adapter = getConfigExplorerAdapter();
|
|
106
|
+
if (!adapter)
|
|
107
|
+
return { ...DEFAULT_CONFIG };
|
|
108
|
+
const searched = searchConfig(adapter, directory);
|
|
109
|
+
if (!searched.ok)
|
|
110
|
+
return { ...DEFAULT_CONFIG };
|
|
111
|
+
const loaded = searched.config ?? loadLegacyConfig(adapter);
|
|
112
|
+
return {
|
|
35
113
|
...DEFAULT_CONFIG,
|
|
36
|
-
...
|
|
114
|
+
...(loaded ?? {}),
|
|
37
115
|
};
|
|
38
|
-
const parsed = GraphitiConfigSchema.safeParse(merged);
|
|
39
|
-
if (parsed.success) {
|
|
40
|
-
return parsed.data;
|
|
41
|
-
}
|
|
42
|
-
return DEFAULT_CONFIG;
|
|
43
116
|
}
|
package/esm/src/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|
package/esm/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { createCompactingHandler } from "./handlers/compacting.js";
|
|
|
4
4
|
import { createEventHandler } from "./handlers/event.js";
|
|
5
5
|
import { createMessagesHandler } from "./handlers/messages.js";
|
|
6
6
|
import { GraphitiClient } from "./services/client.js";
|
|
7
|
+
import { GraphitiConnectionManager } from "./services/connection-manager.js";
|
|
7
8
|
import { logger } from "./services/logger.js";
|
|
8
9
|
import { SessionManager } from "./session.js";
|
|
9
10
|
import { makeGroupId, makeUserGroupId } from "./utils.js";
|
|
@@ -12,13 +13,18 @@ import { makeGroupId, makeUserGroupId } from "./utils.js";
|
|
|
12
13
|
*/
|
|
13
14
|
export const graphiti = async (input) => {
|
|
14
15
|
const config = loadConfig(input.directory);
|
|
15
|
-
const
|
|
16
|
+
const connectionManager = new GraphitiConnectionManager({
|
|
17
|
+
endpoint: config.endpoint,
|
|
18
|
+
});
|
|
19
|
+
connectionManager.start();
|
|
20
|
+
void connectionManager.ready().then((connected) => {
|
|
21
|
+
if (!connected) {
|
|
22
|
+
logger.warn("Could not connect to Graphiti MCP server at", config.endpoint);
|
|
23
|
+
logger.warn("Memory features will be unavailable until connection is established");
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const client = new GraphitiClient(connectionManager);
|
|
16
27
|
const sdkClient = input.client;
|
|
17
|
-
const connected = await client.connect();
|
|
18
|
-
if (!connected) {
|
|
19
|
-
logger.warn("Could not connect to Graphiti MCP server at", config.endpoint);
|
|
20
|
-
logger.warn("Memory features will be unavailable until connection is established");
|
|
21
|
-
}
|
|
22
28
|
const defaultGroupId = makeGroupId(config.groupIdPrefix, input.directory);
|
|
23
29
|
const defaultUserGroupId = makeUserGroupId(config.groupIdPrefix, input.directory);
|
|
24
30
|
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
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/src/services/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EAIxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,YAAY,EACb,MAAM,mBAAmB,CAAC;AAI3B;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;gBAEpC,iBAAiB,EAAE,MAAM,GAAG,kBAAkB;IAU1D,KAAK,IAAI,IAAI;IAIP,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIrB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAK3B,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIjD;;;OAGG;IACH,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO;IAyBzC;;;;;OAKG;IACH,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,IAAI;IAYrE;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAA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