@dbx-tools/shared-graphiti 0.9.43
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/LICENSE +202 -0
- package/README.md +64 -0
- package/exports.ts +8 -0
- package/index.ts +10 -0
- package/lib/exports.d.ts +1 -0
- package/lib/exports.js +2 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +9 -0
- package/lib/src/options.d.ts +151 -0
- package/lib/src/options.js +141 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +72 -0
- package/src/options.ts +186 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @dbx-tools/shared-graphiti
|
|
2
|
+
|
|
3
|
+
Use the browser-safe Graphiti option contract from Node, AppKit, browser tools,
|
|
4
|
+
or generated language bindings. This package owns defaults, validation,
|
|
5
|
+
environment parsing, and model-gateway ownership rules so every runtime accepts
|
|
6
|
+
the same configuration.
|
|
7
|
+
|
|
8
|
+
## Resolve Runtime Options
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { resolveGraphitiOptions } from "@dbx-tools/shared-graphiti/options";
|
|
12
|
+
|
|
13
|
+
const options = resolveGraphitiOptions({
|
|
14
|
+
profile: "MY-PROFILE",
|
|
15
|
+
model: "gpt 5",
|
|
16
|
+
embedderModel: "gte large",
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The result includes stable listener, model, embedding, gateway, and structured
|
|
21
|
+
output defaults. Supplying `modelGatewayUrl` selects an existing gateway unless
|
|
22
|
+
`manageModelGateway` explicitly opts back into local ownership.
|
|
23
|
+
|
|
24
|
+
## Serialize A Child Runtime
|
|
25
|
+
|
|
26
|
+
Use the shared serializer when a Node host starts the Python Graphiti runtime:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import {
|
|
30
|
+
GRAPHITI_OPTIONS_ENV,
|
|
31
|
+
serializeGraphitiOptions,
|
|
32
|
+
} from "@dbx-tools/shared-graphiti/options";
|
|
33
|
+
|
|
34
|
+
const environment = {
|
|
35
|
+
[GRAPHITI_OPTIONS_ENV]: serializeGraphitiOptions({
|
|
36
|
+
profile: "MY-PROFILE",
|
|
37
|
+
falkorDataDir: "/var/lib/agent-memory",
|
|
38
|
+
}),
|
|
39
|
+
};
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The Python binding consumes this exact validated record. Do not add parallel
|
|
43
|
+
environment parsing or option types in a CLI, AppKit plugin, or language
|
|
44
|
+
runtime.
|
|
45
|
+
|
|
46
|
+
## Build Provider Environment
|
|
47
|
+
|
|
48
|
+
Use `graphitiEnvironment` to derive the OpenAI-compatible variables expected by
|
|
49
|
+
Graphiti without duplicating model, embedding, key, or structured-output
|
|
50
|
+
mapping:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { graphitiEnvironment } from "@dbx-tools/shared-graphiti/options";
|
|
54
|
+
|
|
55
|
+
const environment = graphitiEnvironment({
|
|
56
|
+
modelGatewayUrl: "http://127.0.0.1:4000/v1",
|
|
57
|
+
manageModelGateway: false,
|
|
58
|
+
model: "databricks-gpt-5",
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Zod schemas own runtime validation and inferred input/output types. Process
|
|
63
|
+
launching, Databricks authentication, model discovery, and service lifecycle
|
|
64
|
+
remain with their Node and CLI owners.
|
package/exports.ts
ADDED
package/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// GENERATED by projen watch - DO NOT EDIT.
|
|
2
|
+
// Regenerated from the exporting modules in ./src.
|
|
3
|
+
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
|
+
|
|
5
|
+
export const PACKAGE_IDENTIFIER = "@dbx-tools/shared-graphiti";
|
|
6
|
+
export const PACKAGE_VERSION = "0.9.43";
|
|
7
|
+
export * as options from "./src/options.ts";
|
|
8
|
+
export { GRAPHITI_OPTIONS_ENV, GraphitiOptionsSchema, GraphitiCliOptionsSchema, GRAPHITI_DEFAULTS, ResolvedGraphitiOptionsSchema } from "./src/options.ts";
|
|
9
|
+
export type { GraphitiOptions, ResolvedGraphitiOptions } from "./src/options.ts";
|
|
10
|
+
export * from "./exports.ts";
|
package/lib/exports.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { graphitiEnvironment, graphitiGatewayHealthUrl, graphitiOptionOverrides, graphitiOptionsFromEnvironment, resolveGraphitiOptions, serializeGraphitiOptions, } from "./src/options.ts";
|
package/lib/exports.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { graphitiEnvironment, graphitiGatewayHealthUrl, graphitiOptionOverrides, graphitiOptionsFromEnvironment, resolveGraphitiOptions, serializeGraphitiOptions, } from "./src/options.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhwb3J0cy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL2V4cG9ydHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUNMLG1CQUFtQixFQUNuQix3QkFBd0IsRUFDeEIsdUJBQXVCLEVBQ3ZCLDhCQUE4QixFQUM5QixzQkFBc0IsRUFDdEIsd0JBQXdCLEdBQ3pCLE1BQU0sa0JBQWtCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQge1xuICBncmFwaGl0aUVudmlyb25tZW50LFxuICBncmFwaGl0aUdhdGV3YXlIZWFsdGhVcmwsXG4gIGdyYXBoaXRpT3B0aW9uT3ZlcnJpZGVzLFxuICBncmFwaGl0aU9wdGlvbnNGcm9tRW52aXJvbm1lbnQsXG4gIHJlc29sdmVHcmFwaGl0aU9wdGlvbnMsXG4gIHNlcmlhbGl6ZUdyYXBoaXRpT3B0aW9ucyxcbn0gZnJvbSBcIi4vc3JjL29wdGlvbnMudHNcIjtcbiJdfQ==
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const PACKAGE_IDENTIFIER = "@dbx-tools/shared-graphiti";
|
|
2
|
+
export declare const PACKAGE_VERSION = "0.9.43";
|
|
3
|
+
export * as options from "./src/options.ts";
|
|
4
|
+
export { GRAPHITI_OPTIONS_ENV, GraphitiOptionsSchema, GraphitiCliOptionsSchema, GRAPHITI_DEFAULTS, ResolvedGraphitiOptionsSchema } from "./src/options.ts";
|
|
5
|
+
export type { GraphitiOptions, ResolvedGraphitiOptions } from "./src/options.ts";
|
|
6
|
+
export * from "./exports.ts";
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// GENERATED by projen watch - DO NOT EDIT.
|
|
2
|
+
// Regenerated from the exporting modules in ./src.
|
|
3
|
+
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
|
+
export const PACKAGE_IDENTIFIER = "@dbx-tools/shared-graphiti";
|
|
5
|
+
export const PACKAGE_VERSION = "0.9.43";
|
|
6
|
+
export * as options from "./src/options.js";
|
|
7
|
+
export { GRAPHITI_OPTIONS_ENV, GraphitiOptionsSchema, GraphitiCliOptionsSchema, GRAPHITI_DEFAULTS, ResolvedGraphitiOptionsSchema } from "./src/options.js";
|
|
8
|
+
export * from "./exports.js";
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc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NjaGVtYSB9IGZyb20gXCIuL3NyYy9vcHRpb25zLnRzXCI7XG5leHBvcnQgdHlwZSB7IEdyYXBoaXRpT3B0aW9ucywgUmVzb2x2ZWRHcmFwaGl0aU9wdGlvbnMgfSBmcm9tIFwiLi9zcmMvb3B0aW9ucy50c1wiO1xuZXhwb3J0ICogZnJvbSBcIi4vZXhwb3J0cy50c1wiO1xuIl19
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe Graphiti configuration shared by every runtime.
|
|
3
|
+
*
|
|
4
|
+
* This module owns the Graphiti option schema, defaults, environment mapping,
|
|
5
|
+
* and derived gateway settings. CLIs, AppKit integrations, and generated
|
|
6
|
+
* bindings should pass this configuration through rather than recreating it.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
/** Environment variable carrying one serialized {@link GraphitiOptions} object. */
|
|
12
|
+
export declare const GRAPHITI_OPTIONS_ENV = "DBX_GRAPHITI_OPTIONS";
|
|
13
|
+
export declare const GraphitiOptionsSchema: z.ZodObject<{
|
|
14
|
+
python: z.ZodDefault<z.ZodString>;
|
|
15
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
16
|
+
graphitiHome: z.ZodOptional<z.ZodString>;
|
|
17
|
+
model: z.ZodDefault<z.ZodString>;
|
|
18
|
+
embedderModel: z.ZodDefault<z.ZodString>;
|
|
19
|
+
embedderDimensions: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
20
|
+
modelGatewayUrl: z.ZodOptional<z.ZodString>;
|
|
21
|
+
modelGatewayHost: z.ZodDefault<z.ZodString>;
|
|
22
|
+
modelGatewayPort: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
23
|
+
modelGatewayCommand: z.ZodOptional<z.ZodString>;
|
|
24
|
+
manageModelGateway: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
openAiApiKey: z.ZodOptional<z.ZodString>;
|
|
26
|
+
structuredOutputMode: z.ZodDefault<z.ZodString>;
|
|
27
|
+
graphitiHost: z.ZodDefault<z.ZodString>;
|
|
28
|
+
graphitiPort: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
29
|
+
falkorDataDir: z.ZodOptional<z.ZodString>;
|
|
30
|
+
falkorSnapshotSeconds: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
31
|
+
falkorSnapshotMinChanges: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
32
|
+
graphitiArgs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
33
|
+
}, z.core.$strict>;
|
|
34
|
+
/** Graphiti options represented as Commander flags rather than positional arguments. */
|
|
35
|
+
export declare const GraphitiCliOptionsSchema: z.ZodObject<{
|
|
36
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
37
|
+
python: z.ZodDefault<z.ZodString>;
|
|
38
|
+
graphitiHome: z.ZodOptional<z.ZodString>;
|
|
39
|
+
model: z.ZodDefault<z.ZodString>;
|
|
40
|
+
embedderModel: z.ZodDefault<z.ZodString>;
|
|
41
|
+
embedderDimensions: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
42
|
+
modelGatewayUrl: z.ZodOptional<z.ZodString>;
|
|
43
|
+
modelGatewayHost: z.ZodDefault<z.ZodString>;
|
|
44
|
+
modelGatewayPort: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
45
|
+
modelGatewayCommand: z.ZodOptional<z.ZodString>;
|
|
46
|
+
manageModelGateway: z.ZodOptional<z.ZodBoolean>;
|
|
47
|
+
openAiApiKey: z.ZodOptional<z.ZodString>;
|
|
48
|
+
structuredOutputMode: z.ZodDefault<z.ZodString>;
|
|
49
|
+
graphitiHost: z.ZodDefault<z.ZodString>;
|
|
50
|
+
graphitiPort: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
51
|
+
falkorDataDir: z.ZodOptional<z.ZodString>;
|
|
52
|
+
falkorSnapshotSeconds: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
53
|
+
falkorSnapshotMinChanges: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
export type GraphitiOptions = z.input<typeof GraphitiOptionsSchema>;
|
|
56
|
+
/** Defaults derived from the owning schema rather than maintained separately. */
|
|
57
|
+
export declare const GRAPHITI_DEFAULTS: Readonly<{
|
|
58
|
+
python: string;
|
|
59
|
+
model: string;
|
|
60
|
+
embedderModel: string;
|
|
61
|
+
embedderDimensions: number;
|
|
62
|
+
modelGatewayHost: string;
|
|
63
|
+
modelGatewayPort: number;
|
|
64
|
+
structuredOutputMode: string;
|
|
65
|
+
graphitiHost: string;
|
|
66
|
+
graphitiPort: number;
|
|
67
|
+
falkorSnapshotSeconds: number;
|
|
68
|
+
falkorSnapshotMinChanges: number;
|
|
69
|
+
graphitiArgs: string[];
|
|
70
|
+
profile?: string | undefined;
|
|
71
|
+
graphitiHome?: string | undefined;
|
|
72
|
+
modelGatewayUrl?: string | undefined;
|
|
73
|
+
modelGatewayCommand?: string | undefined;
|
|
74
|
+
manageModelGateway?: boolean | undefined;
|
|
75
|
+
openAiApiKey?: string | undefined;
|
|
76
|
+
falkorDataDir?: string | undefined;
|
|
77
|
+
}>;
|
|
78
|
+
/** Keep only explicitly supplied Graphiti fields and validate their values. */
|
|
79
|
+
export declare function graphitiOptionOverrides(value: unknown): GraphitiOptions;
|
|
80
|
+
export declare const ResolvedGraphitiOptionsSchema: z.ZodPipe<z.ZodObject<{
|
|
81
|
+
python: z.ZodDefault<z.ZodString>;
|
|
82
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
83
|
+
graphitiHome: z.ZodOptional<z.ZodString>;
|
|
84
|
+
model: z.ZodDefault<z.ZodString>;
|
|
85
|
+
embedderModel: z.ZodDefault<z.ZodString>;
|
|
86
|
+
embedderDimensions: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
87
|
+
modelGatewayUrl: z.ZodOptional<z.ZodString>;
|
|
88
|
+
modelGatewayHost: z.ZodDefault<z.ZodString>;
|
|
89
|
+
modelGatewayPort: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
90
|
+
modelGatewayCommand: z.ZodOptional<z.ZodString>;
|
|
91
|
+
manageModelGateway: z.ZodOptional<z.ZodBoolean>;
|
|
92
|
+
openAiApiKey: z.ZodOptional<z.ZodString>;
|
|
93
|
+
structuredOutputMode: z.ZodDefault<z.ZodString>;
|
|
94
|
+
graphitiHost: z.ZodDefault<z.ZodString>;
|
|
95
|
+
graphitiPort: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
96
|
+
falkorDataDir: z.ZodOptional<z.ZodString>;
|
|
97
|
+
falkorSnapshotSeconds: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
98
|
+
falkorSnapshotMinChanges: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
99
|
+
graphitiArgs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
100
|
+
}, z.core.$strict>, z.ZodTransform<{
|
|
101
|
+
modelGatewayUrl: string;
|
|
102
|
+
manageModelGateway: boolean;
|
|
103
|
+
openAiApiKey: string;
|
|
104
|
+
python: string;
|
|
105
|
+
model: string;
|
|
106
|
+
embedderModel: string;
|
|
107
|
+
embedderDimensions: number;
|
|
108
|
+
modelGatewayHost: string;
|
|
109
|
+
modelGatewayPort: number;
|
|
110
|
+
structuredOutputMode: string;
|
|
111
|
+
graphitiHost: string;
|
|
112
|
+
graphitiPort: number;
|
|
113
|
+
falkorSnapshotSeconds: number;
|
|
114
|
+
falkorSnapshotMinChanges: number;
|
|
115
|
+
graphitiArgs: string[];
|
|
116
|
+
profile?: string | undefined;
|
|
117
|
+
graphitiHome?: string | undefined;
|
|
118
|
+
modelGatewayCommand?: string | undefined;
|
|
119
|
+
falkorDataDir?: string | undefined;
|
|
120
|
+
}, {
|
|
121
|
+
python: string;
|
|
122
|
+
model: string;
|
|
123
|
+
embedderModel: string;
|
|
124
|
+
embedderDimensions: number;
|
|
125
|
+
modelGatewayHost: string;
|
|
126
|
+
modelGatewayPort: number;
|
|
127
|
+
structuredOutputMode: string;
|
|
128
|
+
graphitiHost: string;
|
|
129
|
+
graphitiPort: number;
|
|
130
|
+
falkorSnapshotSeconds: number;
|
|
131
|
+
falkorSnapshotMinChanges: number;
|
|
132
|
+
graphitiArgs: string[];
|
|
133
|
+
profile?: string | undefined;
|
|
134
|
+
graphitiHome?: string | undefined;
|
|
135
|
+
modelGatewayUrl?: string | undefined;
|
|
136
|
+
modelGatewayCommand?: string | undefined;
|
|
137
|
+
manageModelGateway?: boolean | undefined;
|
|
138
|
+
openAiApiKey?: string | undefined;
|
|
139
|
+
falkorDataDir?: string | undefined;
|
|
140
|
+
}>>;
|
|
141
|
+
export type ResolvedGraphitiOptions = z.output<typeof ResolvedGraphitiOptionsSchema>;
|
|
142
|
+
/** Apply shared defaults and validate cross-runtime invariants. */
|
|
143
|
+
export declare function resolveGraphitiOptions(options?: GraphitiOptions): ResolvedGraphitiOptions;
|
|
144
|
+
/** Serialize resolved options for the internal Python runtime boundary. */
|
|
145
|
+
export declare function serializeGraphitiOptions(options?: GraphitiOptions): string;
|
|
146
|
+
/** Parse Graphiti option overrides from an explicit environment record. */
|
|
147
|
+
export declare function graphitiOptionsFromEnvironment(environment: Readonly<Record<string, string | undefined>>): GraphitiOptions;
|
|
148
|
+
/** Return the managed model gateway health endpoint. */
|
|
149
|
+
export declare function graphitiGatewayHealthUrl(options?: GraphitiOptions): string;
|
|
150
|
+
/** Return Graphiti provider environment variables from resolved shared options. */
|
|
151
|
+
export declare function graphitiEnvironment(options?: GraphitiOptions): Record<string, string>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe Graphiti configuration shared by every runtime.
|
|
3
|
+
*
|
|
4
|
+
* This module owns the Graphiti option schema, defaults, environment mapping,
|
|
5
|
+
* and derived gateway settings. CLIs, AppKit integrations, and generated
|
|
6
|
+
* bindings should pass this configuration through rather than recreating it.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { options } from "@dbx-tools/shared-core";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
/** Environment variable carrying one serialized {@link GraphitiOptions} object. */
|
|
13
|
+
export const GRAPHITI_OPTIONS_ENV = "DBX_GRAPHITI_OPTIONS";
|
|
14
|
+
const graphitiText = (description) => z.string().trim().min(1).describe(description);
|
|
15
|
+
const graphitiPort = (description) => options.tcpPortOrZeroSchema.describe(description);
|
|
16
|
+
export const GraphitiOptionsSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
python: graphitiText("Python executable used to run the matching Graphiti package.").default("python3"),
|
|
19
|
+
profile: options.DatabricksOptionsSchema.shape.profile.describe("Databricks profile used for model discovery and authentication."),
|
|
20
|
+
graphitiHome: graphitiText("Application-owned Graphiti runtime directory.").optional(),
|
|
21
|
+
model: graphitiText("Fuzzy chat-model name or endpoint identifier.")
|
|
22
|
+
.default("databricks-gpt-5-nano")
|
|
23
|
+
.meta({ env: "MODEL_NAME" }),
|
|
24
|
+
embedderModel: graphitiText("Fuzzy embedding-model name or endpoint identifier.").default("databricks-gte-large-en"),
|
|
25
|
+
embedderDimensions: z.coerce
|
|
26
|
+
.number()
|
|
27
|
+
.int()
|
|
28
|
+
.positive()
|
|
29
|
+
.default(1024)
|
|
30
|
+
.describe("Embedding vector dimensions expected by Graphiti."),
|
|
31
|
+
modelGatewayUrl: options.normalizedUrlSchema
|
|
32
|
+
.optional()
|
|
33
|
+
.describe("Existing OpenAI-compatible model gateway base URL, including /v1.")
|
|
34
|
+
.meta({ env: ["MODEL_GATEWAY_URL", "OPENAI_API_URL"] }),
|
|
35
|
+
modelGatewayHost: graphitiText("Listener host for a locally managed model gateway.").default("127.0.0.1"),
|
|
36
|
+
modelGatewayPort: graphitiPort("Listener port for a locally managed model gateway.").default(4400),
|
|
37
|
+
modelGatewayCommand: graphitiText("Command used to start a locally managed model gateway.").optional(),
|
|
38
|
+
manageModelGateway: z
|
|
39
|
+
.boolean()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Whether Graphiti starts and stops a local model gateway."),
|
|
42
|
+
openAiApiKey: graphitiText("API key used only with an externally managed OpenAI-compatible endpoint.")
|
|
43
|
+
.optional()
|
|
44
|
+
.meta({ env: "OPENAI_API_KEY" }),
|
|
45
|
+
structuredOutputMode: graphitiText("Structured-output mode forwarded to Graphiti's OpenAI provider.")
|
|
46
|
+
.default("json_object")
|
|
47
|
+
.meta({ env: "LLM_STRUCTURED_OUTPUT_MODE" }),
|
|
48
|
+
graphitiHost: graphitiText("Graphiti MCP listener host.").default("127.0.0.1"),
|
|
49
|
+
graphitiPort: graphitiPort("Graphiti MCP listener port.").default(8000),
|
|
50
|
+
falkorDataDir: graphitiText("Local directory containing the active FalkorDB RDB.")
|
|
51
|
+
.optional()
|
|
52
|
+
.meta({ env: "FALKORDB_DATA_DIR" }),
|
|
53
|
+
falkorSnapshotSeconds: z.coerce
|
|
54
|
+
.number()
|
|
55
|
+
.int()
|
|
56
|
+
.positive()
|
|
57
|
+
.default(300)
|
|
58
|
+
.describe("Seconds between change-aware FalkorDB snapshot checks."),
|
|
59
|
+
falkorSnapshotMinChanges: z.coerce
|
|
60
|
+
.number()
|
|
61
|
+
.int()
|
|
62
|
+
.positive()
|
|
63
|
+
.default(1)
|
|
64
|
+
.describe("Minimum writes required before FalkorDB creates an RDB snapshot."),
|
|
65
|
+
graphitiArgs: z
|
|
66
|
+
.array(z.string())
|
|
67
|
+
.default([])
|
|
68
|
+
.describe("Arguments forwarded to the pinned upstream Graphiti MCP server."),
|
|
69
|
+
})
|
|
70
|
+
.strict()
|
|
71
|
+
.describe("Graphiti options accepted by JavaScript, Python, and generated bindings.");
|
|
72
|
+
/** Graphiti options represented as Commander flags rather than positional arguments. */
|
|
73
|
+
export const GraphitiCliOptionsSchema = GraphitiOptionsSchema.omit({ graphitiArgs: true }).describe("Graphiti options represented as Commander flags rather than positional arguments.");
|
|
74
|
+
/** Defaults derived from the owning schema rather than maintained separately. */
|
|
75
|
+
export const GRAPHITI_DEFAULTS = Object.freeze(GraphitiOptionsSchema.parse({}));
|
|
76
|
+
const graphitiOptionKeys = Object.keys(GraphitiOptionsSchema.shape);
|
|
77
|
+
/** Keep only explicitly supplied Graphiti fields and validate their values. */
|
|
78
|
+
export function graphitiOptionOverrides(value) {
|
|
79
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
80
|
+
throw new Error("Graphiti options must be an object");
|
|
81
|
+
}
|
|
82
|
+
const source = value;
|
|
83
|
+
const keys = graphitiOptionKeys.filter((key) => source[key] !== undefined);
|
|
84
|
+
const parsed = GraphitiOptionsSchema.parse(Object.fromEntries(keys.map((key) => [key, source[key]])));
|
|
85
|
+
return Object.fromEntries(keys.map((key) => [key, parsed[key]]));
|
|
86
|
+
}
|
|
87
|
+
export const ResolvedGraphitiOptionsSchema = GraphitiOptionsSchema.transform((options, context) => {
|
|
88
|
+
const manageModelGateway = options.manageModelGateway ?? options.modelGatewayUrl === undefined;
|
|
89
|
+
const modelGatewayUrl = (options.modelGatewayUrl ?? `http://${options.modelGatewayHost}:${options.modelGatewayPort}/v1`).replace(/\/$/, "");
|
|
90
|
+
if (options.manageModelGateway !== false &&
|
|
91
|
+
options.graphitiPort &&
|
|
92
|
+
options.modelGatewayPort &&
|
|
93
|
+
options.graphitiPort === options.modelGatewayPort) {
|
|
94
|
+
context.addIssue({
|
|
95
|
+
code: "custom",
|
|
96
|
+
message: "graphitiPort and modelGatewayPort must be distinct",
|
|
97
|
+
path: ["modelGatewayPort"],
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
...options,
|
|
102
|
+
modelGatewayUrl,
|
|
103
|
+
manageModelGateway,
|
|
104
|
+
openAiApiKey: options.openAiApiKey ?? "not-required",
|
|
105
|
+
};
|
|
106
|
+
}).describe("Graphiti options after defaults and gateway ownership are resolved.");
|
|
107
|
+
/** Apply shared defaults and validate cross-runtime invariants. */
|
|
108
|
+
export function resolveGraphitiOptions(options = {}) {
|
|
109
|
+
return ResolvedGraphitiOptionsSchema.parse(options);
|
|
110
|
+
}
|
|
111
|
+
/** Serialize resolved options for the internal Python runtime boundary. */
|
|
112
|
+
export function serializeGraphitiOptions(options = {}) {
|
|
113
|
+
return JSON.stringify(resolveGraphitiOptions(options));
|
|
114
|
+
}
|
|
115
|
+
/** Parse Graphiti option overrides from an explicit environment record. */
|
|
116
|
+
export function graphitiOptionsFromEnvironment(environment) {
|
|
117
|
+
return options.parseOpts(GraphitiOptionsSchema, null, environment);
|
|
118
|
+
}
|
|
119
|
+
/** Return the managed model gateway health endpoint. */
|
|
120
|
+
export function graphitiGatewayHealthUrl(options = {}) {
|
|
121
|
+
return `${resolveGraphitiOptions(options).modelGatewayUrl.replace(/\/v1$/, "")}/api/healthz`;
|
|
122
|
+
}
|
|
123
|
+
/** Return Graphiti provider environment variables from resolved shared options. */
|
|
124
|
+
export function graphitiEnvironment(options = {}) {
|
|
125
|
+
const resolved = resolveGraphitiOptions(options);
|
|
126
|
+
return {
|
|
127
|
+
OPENAI_API_URL: resolved.modelGatewayUrl,
|
|
128
|
+
OPENAI_API_KEY: resolved.openAiApiKey,
|
|
129
|
+
LLM__PROVIDERS__OPENAI__API_URL: resolved.modelGatewayUrl,
|
|
130
|
+
LLM__PROVIDERS__OPENAI__API_KEY: resolved.openAiApiKey,
|
|
131
|
+
MODEL_NAME: resolved.model,
|
|
132
|
+
EMBEDDER_MODEL: resolved.embedderModel,
|
|
133
|
+
EMBEDDER__PROVIDERS__OPENAI__API_URL: resolved.modelGatewayUrl,
|
|
134
|
+
EMBEDDER__PROVIDERS__OPENAI__API_KEY: resolved.openAiApiKey,
|
|
135
|
+
EMBEDDER_DIMENSIONS: String(resolved.embedderDimensions),
|
|
136
|
+
EMBEDDER__DIMENSIONS: String(resolved.embedderDimensions),
|
|
137
|
+
EMBEDDING_DIM: String(resolved.embedderDimensions),
|
|
138
|
+
LLM_STRUCTURED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QUlfX0FQSV9LRVk6IHJlc29sdmVkLm9wZW5BaUFwaUtleSxcbiAgICBNT0RFTF9OQU1FOiByZXNvbHZlZC5tb2RlbCxcbiAgICBFTUJFRERFUl9NT0RFTDogcmVzb2x2ZWQuZW1iZWRkZXJNb2RlbCxcbiAgICBFTUJFRERFUl9fUFJPVklERVJTX19PUEVOQUlfX0FQSV9VUkw6IHJlc29sdmVkLm1vZGVsR2F0ZXdheVVybCxcbiAgICBFTUJFRERFUl9fUFJPVklERVJTX19PUEVOQUlfX0FQSV9LRVk6IHJlc29sdmVkLm9wZW5BaUFwaUtleSxcbiAgICBFTUJFRERFUl9ESU1FTlNJT05TOiBTdHJpbmcocmVzb2x2ZWQuZW1iZWRkZXJEaW1lbnNpb25zKSxcbiAgICBFTUJFRERFUl9fRElNRU5TSU9OUzogU3RyaW5nKHJlc29sdmVkLmVtYmVkZGVyRGltZW5zaW9ucyksXG4gICAgRU1CRURESU5HX0RJTTogU3RyaW5nKHJlc29sdmVkLmVtYmVkZGVyRGltZW5zaW9ucyksXG4gICAgTExNX1NUUlVDVFVSRURfT1VUUFVUX01PREU6IHJlc29sdmVkLnN0cnVjdHVyZWRPdXRwdXRNb2RlLFxuICB9O1xufVxuIl19
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/options.ts","../index.ts"],"version":"5.9.3"}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dbx-tools/shared-graphiti",
|
|
3
|
+
"description": "Browser-safe Graphiti options, defaults, and runtime configuration",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/reggie-db/dbx-tools.git",
|
|
7
|
+
"directory": "packages/js/shared/graphiti"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "projen build",
|
|
11
|
+
"compile": "projen compile",
|
|
12
|
+
"default": "projen default",
|
|
13
|
+
"package": "projen package",
|
|
14
|
+
"post-compile": "projen post-compile",
|
|
15
|
+
"pre-compile": "projen pre-compile",
|
|
16
|
+
"prepack": "projen prepack",
|
|
17
|
+
"test": "projen test",
|
|
18
|
+
"watch": "projen watch",
|
|
19
|
+
"projen": "projen"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"typescript": "^5.9.3"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@dbx-tools/shared-core": "^0.9.43",
|
|
26
|
+
"zod": "4.3.6"
|
|
27
|
+
},
|
|
28
|
+
"main": "./lib/index.js",
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"main": "./lib/index.js",
|
|
33
|
+
"types": "./lib/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./lib/index.d.ts",
|
|
37
|
+
"default": "./lib/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./options": {
|
|
40
|
+
"types": "./lib/src/options.d.ts",
|
|
41
|
+
"default": "./lib/src/options.js"
|
|
42
|
+
},
|
|
43
|
+
"./package.json": "./package.json"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"version": "0.9.43",
|
|
47
|
+
"types": "./lib/index.d.ts",
|
|
48
|
+
"dbxToolsConfig": {
|
|
49
|
+
"tags": [
|
|
50
|
+
"shared"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"type": "module",
|
|
54
|
+
"exports": {
|
|
55
|
+
".": {
|
|
56
|
+
"types": "./lib/index.d.ts",
|
|
57
|
+
"default": "./lib/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./options": {
|
|
60
|
+
"types": "./lib/src/options.d.ts",
|
|
61
|
+
"default": "./lib/src/options.js"
|
|
62
|
+
},
|
|
63
|
+
"./package.json": "./package.json"
|
|
64
|
+
},
|
|
65
|
+
"files": [
|
|
66
|
+
"index.ts",
|
|
67
|
+
"src",
|
|
68
|
+
"exports.ts",
|
|
69
|
+
"lib"
|
|
70
|
+
],
|
|
71
|
+
"//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"bunx projen\"."
|
|
72
|
+
}
|
package/src/options.ts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe Graphiti configuration shared by every runtime.
|
|
3
|
+
*
|
|
4
|
+
* This module owns the Graphiti option schema, defaults, environment mapping,
|
|
5
|
+
* and derived gateway settings. CLIs, AppKit integrations, and generated
|
|
6
|
+
* bindings should pass this configuration through rather than recreating it.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { options } from "@dbx-tools/shared-core";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
|
|
14
|
+
/** Environment variable carrying one serialized {@link GraphitiOptions} object. */
|
|
15
|
+
export const GRAPHITI_OPTIONS_ENV = "DBX_GRAPHITI_OPTIONS";
|
|
16
|
+
|
|
17
|
+
const graphitiText = (description: string) => z.string().trim().min(1).describe(description);
|
|
18
|
+
const graphitiPort = (description: string) => options.tcpPortOrZeroSchema.describe(description);
|
|
19
|
+
|
|
20
|
+
export const GraphitiOptionsSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
python: graphitiText("Python executable used to run the matching Graphiti package.").default(
|
|
23
|
+
"python3",
|
|
24
|
+
),
|
|
25
|
+
profile: options.DatabricksOptionsSchema.shape.profile.describe(
|
|
26
|
+
"Databricks profile used for model discovery and authentication.",
|
|
27
|
+
),
|
|
28
|
+
graphitiHome: graphitiText("Application-owned Graphiti runtime directory.").optional(),
|
|
29
|
+
model: graphitiText("Fuzzy chat-model name or endpoint identifier.")
|
|
30
|
+
.default("databricks-gpt-5-nano")
|
|
31
|
+
.meta({ env: "MODEL_NAME" }),
|
|
32
|
+
embedderModel: graphitiText("Fuzzy embedding-model name or endpoint identifier.").default(
|
|
33
|
+
"databricks-gte-large-en",
|
|
34
|
+
),
|
|
35
|
+
embedderDimensions: z.coerce
|
|
36
|
+
.number<number>()
|
|
37
|
+
.int()
|
|
38
|
+
.positive()
|
|
39
|
+
.default(1024)
|
|
40
|
+
.describe("Embedding vector dimensions expected by Graphiti."),
|
|
41
|
+
modelGatewayUrl: options.normalizedUrlSchema
|
|
42
|
+
.optional()
|
|
43
|
+
.describe("Existing OpenAI-compatible model gateway base URL, including /v1.")
|
|
44
|
+
.meta({ env: ["MODEL_GATEWAY_URL", "OPENAI_API_URL"] }),
|
|
45
|
+
modelGatewayHost: graphitiText("Listener host for a locally managed model gateway.").default(
|
|
46
|
+
"127.0.0.1",
|
|
47
|
+
),
|
|
48
|
+
modelGatewayPort: graphitiPort("Listener port for a locally managed model gateway.").default(
|
|
49
|
+
4400,
|
|
50
|
+
),
|
|
51
|
+
modelGatewayCommand: graphitiText(
|
|
52
|
+
"Command used to start a locally managed model gateway.",
|
|
53
|
+
).optional(),
|
|
54
|
+
manageModelGateway: z
|
|
55
|
+
.boolean()
|
|
56
|
+
.optional()
|
|
57
|
+
.describe("Whether Graphiti starts and stops a local model gateway."),
|
|
58
|
+
openAiApiKey: graphitiText(
|
|
59
|
+
"API key used only with an externally managed OpenAI-compatible endpoint.",
|
|
60
|
+
)
|
|
61
|
+
.optional()
|
|
62
|
+
.meta({ env: "OPENAI_API_KEY" }),
|
|
63
|
+
structuredOutputMode: graphitiText(
|
|
64
|
+
"Structured-output mode forwarded to Graphiti's OpenAI provider.",
|
|
65
|
+
)
|
|
66
|
+
.default("json_object")
|
|
67
|
+
.meta({ env: "LLM_STRUCTURED_OUTPUT_MODE" }),
|
|
68
|
+
graphitiHost: graphitiText("Graphiti MCP listener host.").default("127.0.0.1"),
|
|
69
|
+
graphitiPort: graphitiPort("Graphiti MCP listener port.").default(8000),
|
|
70
|
+
falkorDataDir: graphitiText("Local directory containing the active FalkorDB RDB.")
|
|
71
|
+
.optional()
|
|
72
|
+
.meta({ env: "FALKORDB_DATA_DIR" }),
|
|
73
|
+
falkorSnapshotSeconds: z.coerce
|
|
74
|
+
.number<number>()
|
|
75
|
+
.int()
|
|
76
|
+
.positive()
|
|
77
|
+
.default(300)
|
|
78
|
+
.describe("Seconds between change-aware FalkorDB snapshot checks."),
|
|
79
|
+
falkorSnapshotMinChanges: z.coerce
|
|
80
|
+
.number<number>()
|
|
81
|
+
.int()
|
|
82
|
+
.positive()
|
|
83
|
+
.default(1)
|
|
84
|
+
.describe("Minimum writes required before FalkorDB creates an RDB snapshot."),
|
|
85
|
+
graphitiArgs: z
|
|
86
|
+
.array(z.string())
|
|
87
|
+
.default([])
|
|
88
|
+
.describe("Arguments forwarded to the pinned upstream Graphiti MCP server."),
|
|
89
|
+
})
|
|
90
|
+
.strict()
|
|
91
|
+
.describe("Graphiti options accepted by JavaScript, Python, and generated bindings.");
|
|
92
|
+
|
|
93
|
+
/** Graphiti options represented as Commander flags rather than positional arguments. */
|
|
94
|
+
export const GraphitiCliOptionsSchema = GraphitiOptionsSchema.omit({ graphitiArgs: true }).describe(
|
|
95
|
+
"Graphiti options represented as Commander flags rather than positional arguments.",
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
export type GraphitiOptions = z.input<typeof GraphitiOptionsSchema>;
|
|
99
|
+
|
|
100
|
+
/** Defaults derived from the owning schema rather than maintained separately. */
|
|
101
|
+
export const GRAPHITI_DEFAULTS = Object.freeze(GraphitiOptionsSchema.parse({}));
|
|
102
|
+
|
|
103
|
+
const graphitiOptionKeys = Object.keys(GraphitiOptionsSchema.shape) as Array<
|
|
104
|
+
keyof typeof GRAPHITI_DEFAULTS
|
|
105
|
+
>;
|
|
106
|
+
|
|
107
|
+
/** Keep only explicitly supplied Graphiti fields and validate their values. */
|
|
108
|
+
export function graphitiOptionOverrides(value: unknown): GraphitiOptions {
|
|
109
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
110
|
+
throw new Error("Graphiti options must be an object");
|
|
111
|
+
}
|
|
112
|
+
const source = value as Readonly<Record<string, unknown>>;
|
|
113
|
+
const keys = graphitiOptionKeys.filter((key) => source[key] !== undefined);
|
|
114
|
+
const parsed = GraphitiOptionsSchema.parse(
|
|
115
|
+
Object.fromEntries(keys.map((key) => [key, source[key]])),
|
|
116
|
+
);
|
|
117
|
+
return Object.fromEntries(keys.map((key) => [key, parsed[key]])) as GraphitiOptions;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const ResolvedGraphitiOptionsSchema = GraphitiOptionsSchema.transform((options, context) => {
|
|
121
|
+
const manageModelGateway = options.manageModelGateway ?? options.modelGatewayUrl === undefined;
|
|
122
|
+
const modelGatewayUrl = (
|
|
123
|
+
options.modelGatewayUrl ?? `http://${options.modelGatewayHost}:${options.modelGatewayPort}/v1`
|
|
124
|
+
).replace(/\/$/, "");
|
|
125
|
+
if (
|
|
126
|
+
options.manageModelGateway !== false &&
|
|
127
|
+
options.graphitiPort &&
|
|
128
|
+
options.modelGatewayPort &&
|
|
129
|
+
options.graphitiPort === options.modelGatewayPort
|
|
130
|
+
) {
|
|
131
|
+
context.addIssue({
|
|
132
|
+
code: "custom",
|
|
133
|
+
message: "graphitiPort and modelGatewayPort must be distinct",
|
|
134
|
+
path: ["modelGatewayPort"],
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
...options,
|
|
139
|
+
modelGatewayUrl,
|
|
140
|
+
manageModelGateway,
|
|
141
|
+
openAiApiKey: options.openAiApiKey ?? "not-required",
|
|
142
|
+
};
|
|
143
|
+
}).describe("Graphiti options after defaults and gateway ownership are resolved.");
|
|
144
|
+
|
|
145
|
+
export type ResolvedGraphitiOptions = z.output<typeof ResolvedGraphitiOptionsSchema>;
|
|
146
|
+
|
|
147
|
+
/** Apply shared defaults and validate cross-runtime invariants. */
|
|
148
|
+
export function resolveGraphitiOptions(options: GraphitiOptions = {}): ResolvedGraphitiOptions {
|
|
149
|
+
return ResolvedGraphitiOptionsSchema.parse(options);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Serialize resolved options for the internal Python runtime boundary. */
|
|
153
|
+
export function serializeGraphitiOptions(options: GraphitiOptions = {}): string {
|
|
154
|
+
return JSON.stringify(resolveGraphitiOptions(options));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Parse Graphiti option overrides from an explicit environment record. */
|
|
158
|
+
export function graphitiOptionsFromEnvironment(
|
|
159
|
+
environment: Readonly<Record<string, string | undefined>>,
|
|
160
|
+
): GraphitiOptions {
|
|
161
|
+
return options.parseOpts(GraphitiOptionsSchema, null, environment);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Return the managed model gateway health endpoint. */
|
|
165
|
+
export function graphitiGatewayHealthUrl(options: GraphitiOptions = {}): string {
|
|
166
|
+
return `${resolveGraphitiOptions(options).modelGatewayUrl.replace(/\/v1$/, "")}/api/healthz`;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Return Graphiti provider environment variables from resolved shared options. */
|
|
170
|
+
export function graphitiEnvironment(options: GraphitiOptions = {}): Record<string, string> {
|
|
171
|
+
const resolved = resolveGraphitiOptions(options);
|
|
172
|
+
return {
|
|
173
|
+
OPENAI_API_URL: resolved.modelGatewayUrl,
|
|
174
|
+
OPENAI_API_KEY: resolved.openAiApiKey,
|
|
175
|
+
LLM__PROVIDERS__OPENAI__API_URL: resolved.modelGatewayUrl,
|
|
176
|
+
LLM__PROVIDERS__OPENAI__API_KEY: resolved.openAiApiKey,
|
|
177
|
+
MODEL_NAME: resolved.model,
|
|
178
|
+
EMBEDDER_MODEL: resolved.embedderModel,
|
|
179
|
+
EMBEDDER__PROVIDERS__OPENAI__API_URL: resolved.modelGatewayUrl,
|
|
180
|
+
EMBEDDER__PROVIDERS__OPENAI__API_KEY: resolved.openAiApiKey,
|
|
181
|
+
EMBEDDER_DIMENSIONS: String(resolved.embedderDimensions),
|
|
182
|
+
EMBEDDER__DIMENSIONS: String(resolved.embedderDimensions),
|
|
183
|
+
EMBEDDING_DIM: String(resolved.embedderDimensions),
|
|
184
|
+
LLM_STRUCTURED_OUTPUT_MODE: resolved.structuredOutputMode,
|
|
185
|
+
};
|
|
186
|
+
}
|