@papr/memory 1.20.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/LICENSE +1 -1
- package/README.md +13 -1
- package/client.d.mts +37 -9
- package/client.d.mts.map +1 -1
- package/client.d.ts +37 -9
- package/client.d.ts.map +1 -1
- package/client.js +17 -2
- package/client.js.map +1 -1
- package/client.mjs +17 -2
- package/client.mjs.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/internal/tslib.js +22 -22
- package/package.json +1 -1
- package/resources/document.d.mts +16 -3
- package/resources/document.d.mts.map +1 -1
- package/resources/document.d.ts +16 -3
- package/resources/document.d.ts.map +1 -1
- package/resources/index.d.mts +6 -3
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +6 -3
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +7 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +3 -0
- package/resources/index.mjs.map +1 -1
- package/resources/memory.d.mts +498 -119
- package/resources/memory.d.mts.map +1 -1
- package/resources/memory.d.ts +498 -119
- package/resources/memory.d.ts.map +1 -1
- package/resources/memory.js +8 -4
- package/resources/memory.js.map +1 -1
- package/resources/memory.mjs +8 -4
- package/resources/memory.mjs.map +1 -1
- package/resources/messages/index.d.mts +3 -0
- package/resources/messages/index.d.mts.map +1 -0
- package/resources/messages/index.d.ts +3 -0
- package/resources/messages/index.d.ts.map +1 -0
- package/resources/messages/index.js +9 -0
- package/resources/messages/index.js.map +1 -0
- package/resources/messages/index.mjs +4 -0
- package/resources/messages/index.mjs.map +1 -0
- package/resources/messages/messages.d.mts +160 -0
- package/resources/messages/messages.d.mts.map +1 -0
- package/resources/messages/messages.d.ts +160 -0
- package/resources/messages/messages.d.ts.map +1 -0
- package/resources/messages/messages.js +54 -0
- package/resources/messages/messages.js.map +1 -0
- package/resources/messages/messages.mjs +49 -0
- package/resources/messages/messages.mjs.map +1 -0
- package/resources/messages/sessions.d.mts +262 -0
- package/resources/messages/sessions.d.mts.map +1 -0
- package/resources/messages/sessions.d.ts +262 -0
- package/resources/messages/sessions.d.ts.map +1 -0
- package/resources/messages/sessions.js +122 -0
- package/resources/messages/sessions.js.map +1 -0
- package/resources/messages/sessions.mjs +118 -0
- package/resources/messages/sessions.mjs.map +1 -0
- package/resources/messages.d.mts +2 -0
- package/resources/messages.d.mts.map +1 -0
- package/resources/messages.d.ts +2 -0
- package/resources/messages.d.ts.map +1 -0
- package/resources/messages.js +6 -0
- package/resources/messages.js.map +1 -0
- package/resources/messages.mjs +3 -0
- package/resources/messages.mjs.map +1 -0
- package/resources/omo.d.mts +98 -0
- package/resources/omo.d.mts.map +1 -0
- package/resources/omo.d.ts +98 -0
- package/resources/omo.d.ts.map +1 -0
- package/resources/omo.js +36 -0
- package/resources/omo.js.map +1 -0
- package/resources/omo.mjs +32 -0
- package/resources/omo.mjs.map +1 -0
- package/resources/schemas.d.mts +667 -76
- package/resources/schemas.d.mts.map +1 -1
- package/resources/schemas.d.ts +667 -76
- package/resources/schemas.d.ts.map +1 -1
- package/resources/schemas.js.map +1 -1
- package/resources/schemas.mjs.map +1 -1
- package/resources/shared.d.mts +671 -0
- package/resources/shared.d.mts.map +1 -1
- package/resources/shared.d.ts +671 -0
- package/resources/shared.d.ts.map +1 -1
- package/resources/sync.d.mts +142 -0
- package/resources/sync.d.mts.map +1 -0
- package/resources/sync.d.ts +142 -0
- package/resources/sync.d.ts.map +1 -0
- package/resources/sync.js +36 -0
- package/resources/sync.js.map +1 -0
- package/resources/sync.mjs +32 -0
- package/resources/sync.mjs.map +1 -0
- package/resources/user.d.mts +18 -1
- package/resources/user.d.mts.map +1 -1
- package/resources/user.d.ts +18 -1
- package/resources/user.d.ts.map +1 -1
- package/resources/user.js +11 -0
- package/resources/user.js.map +1 -1
- package/resources/user.mjs +11 -0
- package/resources/user.mjs.map +1 -1
- package/src/client.ts +80 -8
- package/src/internal/parse.ts +6 -0
- package/src/resources/document.ts +17 -4
- package/src/resources/index.ts +21 -0
- package/src/resources/memory.ts +548 -163
- package/src/resources/messages/index.ts +11 -0
- package/src/resources/messages/messages.ts +193 -0
- package/src/resources/messages/sessions.ts +315 -0
- package/src/resources/messages.ts +3 -0
- package/src/resources/omo.ts +132 -0
- package/src/resources/schemas.ts +701 -95
- package/src/resources/shared.ts +752 -0
- package/src/resources/sync.ts +179 -0
- package/src/resources/user.ts +23 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
package/src/resources/schemas.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../core/resource';
|
|
4
|
+
import * as SchemasAPI from './schemas';
|
|
5
|
+
import * as Shared from './shared';
|
|
4
6
|
import { APIPromise } from '../core/api-promise';
|
|
5
7
|
import { RequestOptions } from '../internal/request-options';
|
|
6
8
|
import { path } from '../internal/utils/path';
|
|
@@ -149,6 +151,131 @@ export class Schemas extends APIResource {
|
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Property definition for nodes/relationships
|
|
156
|
+
*/
|
|
157
|
+
export interface PropertyDefinition {
|
|
158
|
+
type: 'string' | 'integer' | 'float' | 'boolean' | 'array' | 'datetime' | 'object';
|
|
159
|
+
|
|
160
|
+
default?: unknown;
|
|
161
|
+
|
|
162
|
+
description?: string | null;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* List of allowed enum values (max 15)
|
|
166
|
+
*/
|
|
167
|
+
enum_values?: Array<string> | null;
|
|
168
|
+
|
|
169
|
+
max_length?: number | null;
|
|
170
|
+
|
|
171
|
+
max_value?: number | null;
|
|
172
|
+
|
|
173
|
+
min_length?: number | null;
|
|
174
|
+
|
|
175
|
+
min_value?: number | null;
|
|
176
|
+
|
|
177
|
+
pattern?: string | null;
|
|
178
|
+
|
|
179
|
+
required?: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Configuration for finding/selecting existing nodes.
|
|
184
|
+
*
|
|
185
|
+
* Defines which properties to match on and how, in priority order. The first
|
|
186
|
+
* matching property wins.
|
|
187
|
+
*
|
|
188
|
+
* **String Shorthand** (simple cases - converts to exact match):
|
|
189
|
+
* SearchConfig(properties=["id", "email"]) # Equivalent to:
|
|
190
|
+
* SearchConfig(properties=[PropertyMatch.exact("id"),
|
|
191
|
+
* PropertyMatch.exact("email")])
|
|
192
|
+
*
|
|
193
|
+
* **Mixed Form** (combine strings and PropertyMatch): SearchConfig(properties=[
|
|
194
|
+
* "id", # String -> exact match PropertyMatch.semantic("title", 0.9) # Full
|
|
195
|
+
* control ])
|
|
196
|
+
*
|
|
197
|
+
* **Full Form** (maximum control): SearchConfig(properties=[
|
|
198
|
+
* PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
|
|
199
|
+
* mode="semantic", threshold=0.85) ])
|
|
200
|
+
*
|
|
201
|
+
* **To select a specific node by ID**:
|
|
202
|
+
* SearchConfig(properties=[PropertyMatch.exact("id", "TASK-123")])
|
|
203
|
+
*/
|
|
204
|
+
export interface SearchConfigOutput {
|
|
205
|
+
/**
|
|
206
|
+
* Default search mode when property doesn't specify one. 'semantic' (vector
|
|
207
|
+
* similarity), 'exact' (property match), 'fuzzy' (partial match).
|
|
208
|
+
*/
|
|
209
|
+
mode?: 'semantic' | 'exact' | 'fuzzy';
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Properties to match on, in priority order (first match wins). Accepts strings
|
|
213
|
+
* (converted to exact match) or PropertyMatch objects. Use PropertyMatch with
|
|
214
|
+
* 'value' field for specific node selection.
|
|
215
|
+
*/
|
|
216
|
+
properties?: Array<SearchConfigOutput.Property> | null;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Default similarity threshold for semantic/fuzzy matching (0.0-1.0). Used when
|
|
220
|
+
* property doesn't specify its own threshold.
|
|
221
|
+
*/
|
|
222
|
+
threshold?: number;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Search for nodes via their relationships. Example: Find tasks assigned to a
|
|
226
|
+
* specific person. Each RelationshipMatch specifies edge_type, target_type, and
|
|
227
|
+
* target_search. Multiple relationship matches are ANDed together.
|
|
228
|
+
*/
|
|
229
|
+
via_relationship?: Array<unknown> | null;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export namespace SearchConfigOutput {
|
|
233
|
+
/**
|
|
234
|
+
* Property matching configuration.
|
|
235
|
+
*
|
|
236
|
+
* Defines which property to match on and how. When listed in search.properties,
|
|
237
|
+
* this property becomes a unique identifier.
|
|
238
|
+
*
|
|
239
|
+
* **Shorthand Helpers** (recommended for common cases):
|
|
240
|
+
* PropertyMatch.exact("id") # Exact match on id PropertyMatch.exact("id",
|
|
241
|
+
* "TASK-123") # Exact match with specific value PropertyMatch.semantic("title") #
|
|
242
|
+
* Semantic match with default threshold PropertyMatch.semantic("title", 0.9) #
|
|
243
|
+
* Semantic match with custom threshold PropertyMatch.semantic("title",
|
|
244
|
+
* value="bug") # Semantic search for "bug" PropertyMatch.fuzzy("name", 0.8) #
|
|
245
|
+
* Fuzzy match
|
|
246
|
+
*
|
|
247
|
+
* **Full Form** (when you need all options): PropertyMatch(name="title",
|
|
248
|
+
* mode="semantic", threshold=0.9, value="auth bug")
|
|
249
|
+
*
|
|
250
|
+
* **String Shorthand** (in SearchConfig.properties): properties=["id", "email"] #
|
|
251
|
+
* Equivalent to [PropertyMatch.exact("id"), PropertyMatch.exact("email")]
|
|
252
|
+
*/
|
|
253
|
+
export interface Property {
|
|
254
|
+
/**
|
|
255
|
+
* Property name to match on (e.g., 'id', 'email', 'title')
|
|
256
|
+
*/
|
|
257
|
+
name: string;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Matching mode: 'exact' (string match), 'semantic' (embedding similarity),
|
|
261
|
+
* 'fuzzy' (Levenshtein distance)
|
|
262
|
+
*/
|
|
263
|
+
mode?: 'semantic' | 'exact' | 'fuzzy';
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Similarity threshold for semantic/fuzzy modes (0.0-1.0). Ignored for exact mode.
|
|
267
|
+
*/
|
|
268
|
+
threshold?: number;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Runtime value override. If set, use this value for matching instead of
|
|
272
|
+
* extracting from content. Useful for memory-level overrides when you know the
|
|
273
|
+
* exact value to search for.
|
|
274
|
+
*/
|
|
275
|
+
value?: unknown;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
152
279
|
/**
|
|
153
280
|
* Complete user-defined graph schema
|
|
154
281
|
*/
|
|
@@ -163,15 +290,40 @@ export interface UserGraphSchemaOutput {
|
|
|
163
290
|
|
|
164
291
|
last_used_at?: string | null;
|
|
165
292
|
|
|
293
|
+
/**
|
|
294
|
+
* Default memory policy for memories using this schema. Includes mode ('auto',
|
|
295
|
+
* 'manual'), node_constraints (applied in auto mode when present), and OMO safety
|
|
296
|
+
* settings (consent, risk). Memory-level policies override schema-level.
|
|
297
|
+
*/
|
|
298
|
+
memory_policy?: { [key: string]: unknown } | null;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* @deprecated DEPRECATED: Use 'namespace_id' instead. Accepts Parse pointer or
|
|
302
|
+
* objectId.
|
|
303
|
+
*/
|
|
166
304
|
namespace?: string | { [key: string]: unknown } | null;
|
|
167
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Namespace ID this schema belongs to. Accepts legacy 'namespace' alias.
|
|
308
|
+
*/
|
|
309
|
+
namespace_id?: string | null;
|
|
310
|
+
|
|
168
311
|
/**
|
|
169
312
|
* Custom node types (max 10 per schema)
|
|
170
313
|
*/
|
|
171
314
|
node_types?: { [key: string]: UserGraphSchemaOutput.NodeTypes };
|
|
172
315
|
|
|
316
|
+
/**
|
|
317
|
+
* @deprecated DEPRECATED: Use 'organization_id' instead. Accepts Parse pointer or
|
|
318
|
+
* objectId.
|
|
319
|
+
*/
|
|
173
320
|
organization?: string | { [key: string]: unknown } | null;
|
|
174
321
|
|
|
322
|
+
/**
|
|
323
|
+
* Organization ID this schema belongs to. Accepts legacy 'organization' alias.
|
|
324
|
+
*/
|
|
325
|
+
organization_id?: string | null;
|
|
326
|
+
|
|
175
327
|
read_access?: Array<string>;
|
|
176
328
|
|
|
177
329
|
/**
|
|
@@ -201,7 +353,23 @@ export interface UserGraphSchemaOutput {
|
|
|
201
353
|
|
|
202
354
|
export namespace UserGraphSchemaOutput {
|
|
203
355
|
/**
|
|
204
|
-
* User-defined node type
|
|
356
|
+
* User-defined node type with optional inline constraint.
|
|
357
|
+
*
|
|
358
|
+
* The `constraint` field allows defining default matching/creation behavior
|
|
359
|
+
* directly within the node type definition. This replaces the need to put
|
|
360
|
+
* constraints only in memory_policy.node_constraints.
|
|
361
|
+
*
|
|
362
|
+
* Schema-level constraints:
|
|
363
|
+
*
|
|
364
|
+
* - `node_type` is implicit (taken from parent UserNodeType.name)
|
|
365
|
+
* - Defines default matching strategy via `search.properties`
|
|
366
|
+
* - Can be overridden per-memory via memory_policy.node_constraints
|
|
367
|
+
*
|
|
368
|
+
* Example: UserNodeType( name="Task", label="Task", properties={ "id":
|
|
369
|
+
* PropertyDefinition(type="string"), "title": PropertyDefinition(type="string",
|
|
370
|
+
* required=True) }, constraint=NodeConstraint( search=SearchConfig(properties=[
|
|
371
|
+
* PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
|
|
372
|
+
* mode="semantic", threshold=0.85) ]), create="auto" ) )
|
|
205
373
|
*/
|
|
206
374
|
export interface NodeTypes {
|
|
207
375
|
label: string;
|
|
@@ -210,56 +378,222 @@ export namespace UserGraphSchemaOutput {
|
|
|
210
378
|
|
|
211
379
|
color?: string | null;
|
|
212
380
|
|
|
381
|
+
/**
|
|
382
|
+
* Policy for how nodes of a specific type should be handled.
|
|
383
|
+
*
|
|
384
|
+
* Used in two places:
|
|
385
|
+
*
|
|
386
|
+
* 1. **Schema level**: Inside `UserNodeType.constraint` - `node_type` is implicit
|
|
387
|
+
* from parent
|
|
388
|
+
* 2. **Memory level**: In `memory_policy.node_constraints[]` - `node_type` is
|
|
389
|
+
* required
|
|
390
|
+
*
|
|
391
|
+
* Node constraints allow developers to control:
|
|
392
|
+
*
|
|
393
|
+
* - Which node types can be created vs. linked
|
|
394
|
+
* - How to find/select existing nodes (via `search`)
|
|
395
|
+
* - What property values to set (exact or auto-extracted)
|
|
396
|
+
* - When to apply the constraint (conditional with logical operators)
|
|
397
|
+
*
|
|
398
|
+
* **The `search` field** handles node selection:
|
|
399
|
+
*
|
|
400
|
+
* - Uses PropertyMatch list to define unique identifiers and matching strategy
|
|
401
|
+
* - Example:
|
|
402
|
+
* `{"properties": [{"name": "id", "mode": "exact"}, {"name": "title", "mode": "semantic"}]}`
|
|
403
|
+
* - For direct selection, use PropertyMatch with value:
|
|
404
|
+
* `{"name": "id", "mode": "exact", "value": "proj_123"}`
|
|
405
|
+
*
|
|
406
|
+
* **The `set` field** controls property values:
|
|
407
|
+
*
|
|
408
|
+
* - Exact value: `{"status": "done"}` - sets exact value
|
|
409
|
+
* - Auto-extract: `{"status": {"mode": "auto"}}` - LLM extracts from content
|
|
410
|
+
*
|
|
411
|
+
* **The `when` field** supports logical operators:
|
|
412
|
+
*
|
|
413
|
+
* - Simple: `{"priority": "high"}`
|
|
414
|
+
* - AND: `{"_and": [{"priority": "high"}, {"status": "active"}]}`
|
|
415
|
+
* - OR: `{"_or": [{"status": "active"}, {"status": "pending"}]}`
|
|
416
|
+
* - NOT: `{"_not": {"status": "completed"}}`
|
|
417
|
+
* - Complex:
|
|
418
|
+
* `{"_and": [{"priority": "high"}, {"_or": [{"status": "active"}, {"urgent": true}]}]}`
|
|
419
|
+
*/
|
|
420
|
+
constraint?: NodeTypes.Constraint | null;
|
|
421
|
+
|
|
213
422
|
description?: string | null;
|
|
214
423
|
|
|
215
424
|
icon?: string | null;
|
|
216
425
|
|
|
426
|
+
/**
|
|
427
|
+
* DEPRECATED: Use resolution_policy='lookup' instead. Shorthand for constraint
|
|
428
|
+
* with create='lookup'. When True, only links to existing nodes (controlled
|
|
429
|
+
* vocabulary). Equivalent to @lookup decorator. If constraint is also provided,
|
|
430
|
+
* link_only=True will override constraint.create to 'lookup'.
|
|
431
|
+
*/
|
|
432
|
+
link_only?: boolean;
|
|
433
|
+
|
|
217
434
|
/**
|
|
218
435
|
* Node properties (max 10 per node type)
|
|
219
436
|
*/
|
|
220
|
-
properties?: { [key: string]:
|
|
437
|
+
properties?: { [key: string]: SchemasAPI.PropertyDefinition };
|
|
221
438
|
|
|
222
439
|
required_properties?: Array<string>;
|
|
223
440
|
|
|
224
441
|
/**
|
|
225
|
-
*
|
|
226
|
-
*
|
|
442
|
+
* Shorthand for constraint.create. 'upsert': Create if not found (default).
|
|
443
|
+
* 'lookup': Only link to existing nodes (controlled vocabulary). Equivalent to
|
|
444
|
+
* @upsert/@lookup decorators. If constraint is also provided, resolution_policy
|
|
445
|
+
* will set constraint.create accordingly.
|
|
446
|
+
*/
|
|
447
|
+
resolution_policy?: 'upsert' | 'lookup';
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* DEPRECATED: Use 'constraint.search.properties' instead. Properties that uniquely
|
|
451
|
+
* identify this node type. Example: ['name', 'email'] for Customer nodes.
|
|
227
452
|
*/
|
|
228
453
|
unique_identifiers?: Array<string>;
|
|
229
454
|
}
|
|
230
455
|
|
|
231
456
|
export namespace NodeTypes {
|
|
232
457
|
/**
|
|
233
|
-
*
|
|
458
|
+
* Policy for how nodes of a specific type should be handled.
|
|
459
|
+
*
|
|
460
|
+
* Used in two places:
|
|
461
|
+
*
|
|
462
|
+
* 1. **Schema level**: Inside `UserNodeType.constraint` - `node_type` is implicit
|
|
463
|
+
* from parent
|
|
464
|
+
* 2. **Memory level**: In `memory_policy.node_constraints[]` - `node_type` is
|
|
465
|
+
* required
|
|
466
|
+
*
|
|
467
|
+
* Node constraints allow developers to control:
|
|
468
|
+
*
|
|
469
|
+
* - Which node types can be created vs. linked
|
|
470
|
+
* - How to find/select existing nodes (via `search`)
|
|
471
|
+
* - What property values to set (exact or auto-extracted)
|
|
472
|
+
* - When to apply the constraint (conditional with logical operators)
|
|
473
|
+
*
|
|
474
|
+
* **The `search` field** handles node selection:
|
|
475
|
+
*
|
|
476
|
+
* - Uses PropertyMatch list to define unique identifiers and matching strategy
|
|
477
|
+
* - Example:
|
|
478
|
+
* `{"properties": [{"name": "id", "mode": "exact"}, {"name": "title", "mode": "semantic"}]}`
|
|
479
|
+
* - For direct selection, use PropertyMatch with value:
|
|
480
|
+
* `{"name": "id", "mode": "exact", "value": "proj_123"}`
|
|
481
|
+
*
|
|
482
|
+
* **The `set` field** controls property values:
|
|
483
|
+
*
|
|
484
|
+
* - Exact value: `{"status": "done"}` - sets exact value
|
|
485
|
+
* - Auto-extract: `{"status": {"mode": "auto"}}` - LLM extracts from content
|
|
486
|
+
*
|
|
487
|
+
* **The `when` field** supports logical operators:
|
|
488
|
+
*
|
|
489
|
+
* - Simple: `{"priority": "high"}`
|
|
490
|
+
* - AND: `{"_and": [{"priority": "high"}, {"status": "active"}]}`
|
|
491
|
+
* - OR: `{"_or": [{"status": "active"}, {"status": "pending"}]}`
|
|
492
|
+
* - NOT: `{"_not": {"status": "completed"}}`
|
|
493
|
+
* - Complex:
|
|
494
|
+
* `{"_and": [{"priority": "high"}, {"_or": [{"status": "active"}, {"urgent": true}]}]}`
|
|
234
495
|
*/
|
|
235
|
-
export interface
|
|
236
|
-
type: 'string' | 'integer' | 'float' | 'boolean' | 'array' | 'datetime' | 'object';
|
|
237
|
-
|
|
238
|
-
default?: unknown;
|
|
239
|
-
|
|
240
|
-
description?: string | null;
|
|
241
|
-
|
|
496
|
+
export interface Constraint {
|
|
242
497
|
/**
|
|
243
|
-
*
|
|
498
|
+
* 'upsert': Create if not found via search (default). 'lookup': Only link to
|
|
499
|
+
* existing nodes (controlled vocabulary). Deprecated aliases: 'auto' -> 'upsert',
|
|
500
|
+
* 'never' -> 'lookup'.
|
|
244
501
|
*/
|
|
245
|
-
|
|
502
|
+
create?: 'upsert' | 'lookup' | 'auto' | 'never';
|
|
246
503
|
|
|
247
|
-
|
|
504
|
+
/**
|
|
505
|
+
* DEPRECATED: Use create='lookup' instead. Shorthand for create='lookup'. When
|
|
506
|
+
* True, only links to existing nodes (controlled vocabulary). Equivalent to
|
|
507
|
+
* @lookup decorator in schema definitions.
|
|
508
|
+
*/
|
|
509
|
+
link_only?: boolean;
|
|
248
510
|
|
|
249
|
-
|
|
511
|
+
/**
|
|
512
|
+
* Node type this constraint applies to (e.g., 'Task', 'Project', 'Person').
|
|
513
|
+
* Optional at schema level (implicit from parent UserNodeType), required at memory
|
|
514
|
+
* level (in memory_policy.node_constraints).
|
|
515
|
+
*/
|
|
516
|
+
node_type?: string | null;
|
|
250
517
|
|
|
251
|
-
|
|
518
|
+
/**
|
|
519
|
+
* Explicit behavior when no match found via search. 'create': create new node
|
|
520
|
+
* (same as upsert). 'ignore': skip node creation (same as lookup). 'error': raise
|
|
521
|
+
* error if node not found. If specified, overrides 'create' field.
|
|
522
|
+
*/
|
|
523
|
+
on_miss?: 'create' | 'ignore' | 'error' | null;
|
|
252
524
|
|
|
253
|
-
|
|
525
|
+
/**
|
|
526
|
+
* Configuration for finding/selecting existing nodes.
|
|
527
|
+
*
|
|
528
|
+
* Defines which properties to match on and how, in priority order. The first
|
|
529
|
+
* matching property wins.
|
|
530
|
+
*
|
|
531
|
+
* **String Shorthand** (simple cases - converts to exact match):
|
|
532
|
+
* SearchConfig(properties=["id", "email"]) # Equivalent to:
|
|
533
|
+
* SearchConfig(properties=[PropertyMatch.exact("id"),
|
|
534
|
+
* PropertyMatch.exact("email")])
|
|
535
|
+
*
|
|
536
|
+
* **Mixed Form** (combine strings and PropertyMatch): SearchConfig(properties=[
|
|
537
|
+
* "id", # String -> exact match PropertyMatch.semantic("title", 0.9) # Full
|
|
538
|
+
* control ])
|
|
539
|
+
*
|
|
540
|
+
* **Full Form** (maximum control): SearchConfig(properties=[
|
|
541
|
+
* PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
|
|
542
|
+
* mode="semantic", threshold=0.85) ])
|
|
543
|
+
*
|
|
544
|
+
* **To select a specific node by ID**:
|
|
545
|
+
* SearchConfig(properties=[PropertyMatch.exact("id", "TASK-123")])
|
|
546
|
+
*/
|
|
547
|
+
search?: SchemasAPI.SearchConfigOutput | null;
|
|
254
548
|
|
|
255
|
-
|
|
549
|
+
/**
|
|
550
|
+
* Set property values on nodes. Supports: 1. Exact value: {'status': 'done'} -
|
|
551
|
+
* sets exact value. 2. Auto-extract: {'status': {'mode': 'auto'}} - LLM extracts
|
|
552
|
+
* from content. 3. Text mode: {'summary': {'mode': 'auto', 'text_mode':
|
|
553
|
+
* 'merge'}} - controls text updates. For text properties, text_mode can be
|
|
554
|
+
* 'replace', 'append', or 'merge'.
|
|
555
|
+
*/
|
|
556
|
+
set?: {
|
|
557
|
+
[key: string]:
|
|
558
|
+
| string
|
|
559
|
+
| number
|
|
560
|
+
| boolean
|
|
561
|
+
| Array<unknown>
|
|
562
|
+
| { [key: string]: unknown }
|
|
563
|
+
| Shared.PropertyValue;
|
|
564
|
+
} | null;
|
|
256
565
|
|
|
257
|
-
|
|
566
|
+
/**
|
|
567
|
+
* Condition for when this constraint applies. Supports logical operators: '\_and',
|
|
568
|
+
* '\_or', '\_not'. Examples: Simple: {'priority': 'high'} - matches when priority
|
|
569
|
+
* equals 'high'. AND: {'\_and': [{'priority': 'high'}, {'status': 'active'}]} -
|
|
570
|
+
* all must match. OR: {'\_or': [{'status': 'active'}, {'status': 'pending'}]} -
|
|
571
|
+
* any must match. NOT: {'\_not': {'status': 'completed'}} - negation. Complex:
|
|
572
|
+
* {'\_and': [{'priority': 'high'}, {'\_or': [{'status': 'active'}, {'urgent':
|
|
573
|
+
* true}]}]}
|
|
574
|
+
*/
|
|
575
|
+
when?: { [key: string]: unknown } | null;
|
|
258
576
|
}
|
|
259
577
|
}
|
|
260
578
|
|
|
261
579
|
/**
|
|
262
|
-
* User-defined relationship type
|
|
580
|
+
* User-defined relationship type with optional inline constraint.
|
|
581
|
+
*
|
|
582
|
+
* The `constraint` field allows defining default matching/creation behavior
|
|
583
|
+
* directly within the relationship type definition. This mirrors the pattern used
|
|
584
|
+
* in UserNodeType.constraint for nodes.
|
|
585
|
+
*
|
|
586
|
+
* Schema-level edge constraints:
|
|
587
|
+
*
|
|
588
|
+
* - `edge_type` is implicit (taken from parent UserRelationshipType.name)
|
|
589
|
+
* - Defines default target node matching strategy via `search.properties`
|
|
590
|
+
* - Can be overridden per-memory via memory_policy.edge_constraints
|
|
591
|
+
*
|
|
592
|
+
* Example: UserRelationshipType( name="MITIGATES", label="Mitigates",
|
|
593
|
+
* allowed_source_types=["SecurityBehavior"], allowed_target_types=["TacticDef"],
|
|
594
|
+
* constraint=EdgeConstraint( search=SearchConfig(properties=[
|
|
595
|
+
* PropertyMatch(name="name", mode="semantic", threshold=0.90) ]), create="never" #
|
|
596
|
+
* Controlled vocabulary - only link to existing targets ) )
|
|
263
597
|
*/
|
|
264
598
|
export interface RelationshipTypes {
|
|
265
599
|
allowed_source_types: Array<string>;
|
|
@@ -274,38 +608,200 @@ export namespace UserGraphSchemaOutput {
|
|
|
274
608
|
|
|
275
609
|
color?: string | null;
|
|
276
610
|
|
|
611
|
+
/**
|
|
612
|
+
* Policy for how edges/relationships of a specific type should be handled.
|
|
613
|
+
*
|
|
614
|
+
* Used in two places:
|
|
615
|
+
*
|
|
616
|
+
* 1. **Schema level**: Inside `UserRelationshipType.constraint` - `edge_type` is
|
|
617
|
+
* implicit from parent
|
|
618
|
+
* 2. **Memory level**: In `memory_policy.edge_constraints[]` - `edge_type` is
|
|
619
|
+
* required
|
|
620
|
+
*
|
|
621
|
+
* Edge constraints allow developers to control:
|
|
622
|
+
*
|
|
623
|
+
* - Which edge types can be created vs. linked to existing targets
|
|
624
|
+
* - How to find/select target nodes (via `search`)
|
|
625
|
+
* - What edge property values to set (exact or auto-extracted)
|
|
626
|
+
* - When to apply the constraint (conditional with logical operators)
|
|
627
|
+
* - Filter by source/target node types
|
|
628
|
+
*
|
|
629
|
+
* **The `search` field** handles target node selection:
|
|
630
|
+
*
|
|
631
|
+
* - Uses SearchConfig to define how to find existing target nodes
|
|
632
|
+
* - Example: `{"properties": [{"name": "name", "mode": "semantic"}]}`
|
|
633
|
+
* - For controlled vocabulary: find existing target, don't create new
|
|
634
|
+
*
|
|
635
|
+
* **The `set` field** controls edge property values:
|
|
636
|
+
*
|
|
637
|
+
* - Exact value: `{"weight": 1.0}` - sets exact value
|
|
638
|
+
* - Auto-extract: `{"reason": {"mode": "auto"}}` - LLM extracts from content
|
|
639
|
+
*
|
|
640
|
+
* **The `when` field** supports logical operators (same as NodeConstraint):
|
|
641
|
+
*
|
|
642
|
+
* - Simple: `{"severity": "high"}`
|
|
643
|
+
* - AND: `{"_and": [{"severity": "high"}, {"confirmed": true}]}`
|
|
644
|
+
* - OR: `{"_or": [{"type": "MITIGATES"}, {"type": "PREVENTS"}]}`
|
|
645
|
+
* - NOT: `{"_not": {"status": "deprecated"}}`
|
|
646
|
+
*/
|
|
647
|
+
constraint?: RelationshipTypes.Constraint | null;
|
|
648
|
+
|
|
277
649
|
description?: string | null;
|
|
278
650
|
|
|
279
|
-
|
|
651
|
+
/**
|
|
652
|
+
* DEPRECATED: Use resolution_policy='lookup' instead. Shorthand for constraint
|
|
653
|
+
* with create='lookup'. When True, only links to existing target nodes (controlled
|
|
654
|
+
* vocabulary). Equivalent to @lookup decorator. If constraint is also provided,
|
|
655
|
+
* link_only=True will override constraint.create to 'lookup'.
|
|
656
|
+
*/
|
|
657
|
+
link_only?: boolean;
|
|
658
|
+
|
|
659
|
+
properties?: { [key: string]: SchemasAPI.PropertyDefinition };
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Shorthand for constraint.create. 'upsert': Create target if not found (default).
|
|
663
|
+
* 'lookup': Only link to existing targets (controlled vocabulary). Equivalent to
|
|
664
|
+
* @upsert/@lookup decorators. If constraint is also provided, resolution_policy
|
|
665
|
+
* will set constraint.create accordingly.
|
|
666
|
+
*/
|
|
667
|
+
resolution_policy?: 'upsert' | 'lookup';
|
|
280
668
|
}
|
|
281
669
|
|
|
282
670
|
export namespace RelationshipTypes {
|
|
283
671
|
/**
|
|
284
|
-
*
|
|
672
|
+
* Policy for how edges/relationships of a specific type should be handled.
|
|
673
|
+
*
|
|
674
|
+
* Used in two places:
|
|
675
|
+
*
|
|
676
|
+
* 1. **Schema level**: Inside `UserRelationshipType.constraint` - `edge_type` is
|
|
677
|
+
* implicit from parent
|
|
678
|
+
* 2. **Memory level**: In `memory_policy.edge_constraints[]` - `edge_type` is
|
|
679
|
+
* required
|
|
680
|
+
*
|
|
681
|
+
* Edge constraints allow developers to control:
|
|
682
|
+
*
|
|
683
|
+
* - Which edge types can be created vs. linked to existing targets
|
|
684
|
+
* - How to find/select target nodes (via `search`)
|
|
685
|
+
* - What edge property values to set (exact or auto-extracted)
|
|
686
|
+
* - When to apply the constraint (conditional with logical operators)
|
|
687
|
+
* - Filter by source/target node types
|
|
688
|
+
*
|
|
689
|
+
* **The `search` field** handles target node selection:
|
|
690
|
+
*
|
|
691
|
+
* - Uses SearchConfig to define how to find existing target nodes
|
|
692
|
+
* - Example: `{"properties": [{"name": "name", "mode": "semantic"}]}`
|
|
693
|
+
* - For controlled vocabulary: find existing target, don't create new
|
|
694
|
+
*
|
|
695
|
+
* **The `set` field** controls edge property values:
|
|
696
|
+
*
|
|
697
|
+
* - Exact value: `{"weight": 1.0}` - sets exact value
|
|
698
|
+
* - Auto-extract: `{"reason": {"mode": "auto"}}` - LLM extracts from content
|
|
699
|
+
*
|
|
700
|
+
* **The `when` field** supports logical operators (same as NodeConstraint):
|
|
701
|
+
*
|
|
702
|
+
* - Simple: `{"severity": "high"}`
|
|
703
|
+
* - AND: `{"_and": [{"severity": "high"}, {"confirmed": true}]}`
|
|
704
|
+
* - OR: `{"_or": [{"type": "MITIGATES"}, {"type": "PREVENTS"}]}`
|
|
705
|
+
* - NOT: `{"_not": {"status": "deprecated"}}`
|
|
285
706
|
*/
|
|
286
|
-
export interface
|
|
287
|
-
|
|
707
|
+
export interface Constraint {
|
|
708
|
+
/**
|
|
709
|
+
* 'upsert': Create target node if not found via search (default). 'lookup': Only
|
|
710
|
+
* link to existing target nodes (controlled vocabulary). When 'lookup', edges to
|
|
711
|
+
* non-existing targets are skipped. Deprecated aliases: 'auto' -> 'upsert',
|
|
712
|
+
* 'never' -> 'lookup'.
|
|
713
|
+
*/
|
|
714
|
+
create?: 'upsert' | 'lookup' | 'auto' | 'never';
|
|
288
715
|
|
|
289
|
-
|
|
716
|
+
/**
|
|
717
|
+
* Direction of edges this constraint applies to. 'outgoing': edges where current
|
|
718
|
+
* node is source (default). 'incoming': edges where current node is target.
|
|
719
|
+
* 'both': applies in either direction.
|
|
720
|
+
*/
|
|
721
|
+
direction?: 'outgoing' | 'incoming' | 'both';
|
|
290
722
|
|
|
291
|
-
|
|
723
|
+
/**
|
|
724
|
+
* Edge/relationship type this constraint applies to (e.g., 'MITIGATES',
|
|
725
|
+
* 'ASSIGNED_TO'). Optional at schema level (implicit from parent
|
|
726
|
+
* UserRelationshipType), required at memory level (in
|
|
727
|
+
* memory_policy.edge_constraints).
|
|
728
|
+
*/
|
|
729
|
+
edge_type?: string | null;
|
|
292
730
|
|
|
293
731
|
/**
|
|
294
|
-
*
|
|
732
|
+
* DEPRECATED: Use create='lookup' instead. Shorthand for create='lookup'. When
|
|
733
|
+
* True, only links to existing target nodes. Equivalent to @lookup decorator in
|
|
734
|
+
* schema definitions.
|
|
295
735
|
*/
|
|
296
|
-
|
|
736
|
+
link_only?: boolean;
|
|
297
737
|
|
|
298
|
-
|
|
738
|
+
/**
|
|
739
|
+
* Explicit behavior when no target match found via search. 'create': create new
|
|
740
|
+
* target node (same as upsert). 'ignore': skip edge creation (same as lookup).
|
|
741
|
+
* 'error': raise error if target not found. If specified, overrides 'create'
|
|
742
|
+
* field.
|
|
743
|
+
*/
|
|
744
|
+
on_miss?: 'create' | 'ignore' | 'error' | null;
|
|
299
745
|
|
|
300
|
-
|
|
746
|
+
/**
|
|
747
|
+
* Configuration for finding/selecting existing nodes.
|
|
748
|
+
*
|
|
749
|
+
* Defines which properties to match on and how, in priority order. The first
|
|
750
|
+
* matching property wins.
|
|
751
|
+
*
|
|
752
|
+
* **String Shorthand** (simple cases - converts to exact match):
|
|
753
|
+
* SearchConfig(properties=["id", "email"]) # Equivalent to:
|
|
754
|
+
* SearchConfig(properties=[PropertyMatch.exact("id"),
|
|
755
|
+
* PropertyMatch.exact("email")])
|
|
756
|
+
*
|
|
757
|
+
* **Mixed Form** (combine strings and PropertyMatch): SearchConfig(properties=[
|
|
758
|
+
* "id", # String -> exact match PropertyMatch.semantic("title", 0.9) # Full
|
|
759
|
+
* control ])
|
|
760
|
+
*
|
|
761
|
+
* **Full Form** (maximum control): SearchConfig(properties=[
|
|
762
|
+
* PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
|
|
763
|
+
* mode="semantic", threshold=0.85) ])
|
|
764
|
+
*
|
|
765
|
+
* **To select a specific node by ID**:
|
|
766
|
+
* SearchConfig(properties=[PropertyMatch.exact("id", "TASK-123")])
|
|
767
|
+
*/
|
|
768
|
+
search?: SchemasAPI.SearchConfigOutput | null;
|
|
301
769
|
|
|
302
|
-
|
|
770
|
+
/**
|
|
771
|
+
* Set property values on edges. Supports: 1. Exact value: {'weight': 1.0} - sets
|
|
772
|
+
* exact value. 2. Auto-extract: {'reason': {'mode': 'auto'}} - LLM extracts from
|
|
773
|
+
* content. Edge properties are useful for relationship metadata (weight,
|
|
774
|
+
* timestamp, reason, etc.).
|
|
775
|
+
*/
|
|
776
|
+
set?: {
|
|
777
|
+
[key: string]:
|
|
778
|
+
| string
|
|
779
|
+
| number
|
|
780
|
+
| boolean
|
|
781
|
+
| Array<unknown>
|
|
782
|
+
| { [key: string]: unknown }
|
|
783
|
+
| Shared.PropertyValue;
|
|
784
|
+
} | null;
|
|
303
785
|
|
|
304
|
-
|
|
786
|
+
/**
|
|
787
|
+
* Filter: only apply when source node is of this type. Example:
|
|
788
|
+
* source_type='SecurityBehavior' - only applies to edges from SecurityBehavior
|
|
789
|
+
* nodes.
|
|
790
|
+
*/
|
|
791
|
+
source_type?: string | null;
|
|
305
792
|
|
|
306
|
-
|
|
793
|
+
/**
|
|
794
|
+
* Filter: only apply when target node is of this type. Example:
|
|
795
|
+
* target_type='TacticDef' - only applies to edges targeting TacticDef nodes.
|
|
796
|
+
*/
|
|
797
|
+
target_type?: string | null;
|
|
307
798
|
|
|
308
|
-
|
|
799
|
+
/**
|
|
800
|
+
* Condition for when this constraint applies. Supports logical operators: '\_and',
|
|
801
|
+
* '\_or', '\_not'. Applied to edge properties or context. Example: {'\_and':
|
|
802
|
+
* [{'severity': 'high'}, {'_not': {'status': 'deprecated'}}]}
|
|
803
|
+
*/
|
|
804
|
+
when?: { [key: string]: unknown } | null;
|
|
309
805
|
}
|
|
310
806
|
}
|
|
311
807
|
}
|
|
@@ -386,15 +882,40 @@ export interface SchemaCreateParams {
|
|
|
386
882
|
|
|
387
883
|
last_used_at?: string | null;
|
|
388
884
|
|
|
885
|
+
/**
|
|
886
|
+
* Default memory policy for memories using this schema. Includes mode ('auto',
|
|
887
|
+
* 'manual'), node_constraints (applied in auto mode when present), and OMO safety
|
|
888
|
+
* settings (consent, risk). Memory-level policies override schema-level.
|
|
889
|
+
*/
|
|
890
|
+
memory_policy?: { [key: string]: unknown } | null;
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* @deprecated DEPRECATED: Use 'namespace_id' instead. Accepts Parse pointer or
|
|
894
|
+
* objectId.
|
|
895
|
+
*/
|
|
389
896
|
namespace?: string | { [key: string]: unknown } | null;
|
|
390
897
|
|
|
898
|
+
/**
|
|
899
|
+
* Namespace ID this schema belongs to. Accepts legacy 'namespace' alias.
|
|
900
|
+
*/
|
|
901
|
+
namespace_id?: string | null;
|
|
902
|
+
|
|
391
903
|
/**
|
|
392
904
|
* Custom node types (max 10 per schema)
|
|
393
905
|
*/
|
|
394
906
|
node_types?: { [key: string]: SchemaCreateParams.NodeTypes };
|
|
395
907
|
|
|
908
|
+
/**
|
|
909
|
+
* @deprecated DEPRECATED: Use 'organization_id' instead. Accepts Parse pointer or
|
|
910
|
+
* objectId.
|
|
911
|
+
*/
|
|
396
912
|
organization?: string | { [key: string]: unknown } | null;
|
|
397
913
|
|
|
914
|
+
/**
|
|
915
|
+
* Organization ID this schema belongs to. Accepts legacy 'organization' alias.
|
|
916
|
+
*/
|
|
917
|
+
organization_id?: string | null;
|
|
918
|
+
|
|
398
919
|
read_access?: Array<string>;
|
|
399
920
|
|
|
400
921
|
/**
|
|
@@ -424,7 +945,23 @@ export interface SchemaCreateParams {
|
|
|
424
945
|
|
|
425
946
|
export namespace SchemaCreateParams {
|
|
426
947
|
/**
|
|
427
|
-
* User-defined node type
|
|
948
|
+
* User-defined node type with optional inline constraint.
|
|
949
|
+
*
|
|
950
|
+
* The `constraint` field allows defining default matching/creation behavior
|
|
951
|
+
* directly within the node type definition. This replaces the need to put
|
|
952
|
+
* constraints only in memory_policy.node_constraints.
|
|
953
|
+
*
|
|
954
|
+
* Schema-level constraints:
|
|
955
|
+
*
|
|
956
|
+
* - `node_type` is implicit (taken from parent UserNodeType.name)
|
|
957
|
+
* - Defines default matching strategy via `search.properties`
|
|
958
|
+
* - Can be overridden per-memory via memory_policy.node_constraints
|
|
959
|
+
*
|
|
960
|
+
* Example: UserNodeType( name="Task", label="Task", properties={ "id":
|
|
961
|
+
* PropertyDefinition(type="string"), "title": PropertyDefinition(type="string",
|
|
962
|
+
* required=True) }, constraint=NodeConstraint( search=SearchConfig(properties=[
|
|
963
|
+
* PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
|
|
964
|
+
* mode="semantic", threshold=0.85) ]), create="auto" ) )
|
|
428
965
|
*/
|
|
429
966
|
export interface NodeTypes {
|
|
430
967
|
label: string;
|
|
@@ -433,56 +970,99 @@ export namespace SchemaCreateParams {
|
|
|
433
970
|
|
|
434
971
|
color?: string | null;
|
|
435
972
|
|
|
973
|
+
/**
|
|
974
|
+
* Policy for how nodes of a specific type should be handled.
|
|
975
|
+
*
|
|
976
|
+
* Used in two places:
|
|
977
|
+
*
|
|
978
|
+
* 1. **Schema level**: Inside `UserNodeType.constraint` - `node_type` is implicit
|
|
979
|
+
* from parent
|
|
980
|
+
* 2. **Memory level**: In `memory_policy.node_constraints[]` - `node_type` is
|
|
981
|
+
* required
|
|
982
|
+
*
|
|
983
|
+
* Node constraints allow developers to control:
|
|
984
|
+
*
|
|
985
|
+
* - Which node types can be created vs. linked
|
|
986
|
+
* - How to find/select existing nodes (via `search`)
|
|
987
|
+
* - What property values to set (exact or auto-extracted)
|
|
988
|
+
* - When to apply the constraint (conditional with logical operators)
|
|
989
|
+
*
|
|
990
|
+
* **The `search` field** handles node selection:
|
|
991
|
+
*
|
|
992
|
+
* - Uses PropertyMatch list to define unique identifiers and matching strategy
|
|
993
|
+
* - Example:
|
|
994
|
+
* `{"properties": [{"name": "id", "mode": "exact"}, {"name": "title", "mode": "semantic"}]}`
|
|
995
|
+
* - For direct selection, use PropertyMatch with value:
|
|
996
|
+
* `{"name": "id", "mode": "exact", "value": "proj_123"}`
|
|
997
|
+
*
|
|
998
|
+
* **The `set` field** controls property values:
|
|
999
|
+
*
|
|
1000
|
+
* - Exact value: `{"status": "done"}` - sets exact value
|
|
1001
|
+
* - Auto-extract: `{"status": {"mode": "auto"}}` - LLM extracts from content
|
|
1002
|
+
*
|
|
1003
|
+
* **The `when` field** supports logical operators:
|
|
1004
|
+
*
|
|
1005
|
+
* - Simple: `{"priority": "high"}`
|
|
1006
|
+
* - AND: `{"_and": [{"priority": "high"}, {"status": "active"}]}`
|
|
1007
|
+
* - OR: `{"_or": [{"status": "active"}, {"status": "pending"}]}`
|
|
1008
|
+
* - NOT: `{"_not": {"status": "completed"}}`
|
|
1009
|
+
* - Complex:
|
|
1010
|
+
* `{"_and": [{"priority": "high"}, {"_or": [{"status": "active"}, {"urgent": true}]}]}`
|
|
1011
|
+
*/
|
|
1012
|
+
constraint?: Shared.NodeConstraintInput | null;
|
|
1013
|
+
|
|
436
1014
|
description?: string | null;
|
|
437
1015
|
|
|
438
1016
|
icon?: string | null;
|
|
439
1017
|
|
|
1018
|
+
/**
|
|
1019
|
+
* DEPRECATED: Use resolution_policy='lookup' instead. Shorthand for constraint
|
|
1020
|
+
* with create='lookup'. When True, only links to existing nodes (controlled
|
|
1021
|
+
* vocabulary). Equivalent to @lookup decorator. If constraint is also provided,
|
|
1022
|
+
* link_only=True will override constraint.create to 'lookup'.
|
|
1023
|
+
*/
|
|
1024
|
+
link_only?: boolean;
|
|
1025
|
+
|
|
440
1026
|
/**
|
|
441
1027
|
* Node properties (max 10 per node type)
|
|
442
1028
|
*/
|
|
443
|
-
properties?: { [key: string]:
|
|
1029
|
+
properties?: { [key: string]: SchemasAPI.PropertyDefinition };
|
|
444
1030
|
|
|
445
1031
|
required_properties?: Array<string>;
|
|
446
1032
|
|
|
447
1033
|
/**
|
|
448
|
-
*
|
|
449
|
-
*
|
|
1034
|
+
* Shorthand for constraint.create. 'upsert': Create if not found (default).
|
|
1035
|
+
* 'lookup': Only link to existing nodes (controlled vocabulary). Equivalent to
|
|
1036
|
+
* @upsert/@lookup decorators. If constraint is also provided, resolution_policy
|
|
1037
|
+
* will set constraint.create accordingly.
|
|
450
1038
|
*/
|
|
451
|
-
|
|
452
|
-
}
|
|
1039
|
+
resolution_policy?: 'upsert' | 'lookup';
|
|
453
1040
|
|
|
454
|
-
export namespace NodeTypes {
|
|
455
1041
|
/**
|
|
456
|
-
*
|
|
1042
|
+
* DEPRECATED: Use 'constraint.search.properties' instead. Properties that uniquely
|
|
1043
|
+
* identify this node type. Example: ['name', 'email'] for Customer nodes.
|
|
457
1044
|
*/
|
|
458
|
-
|
|
459
|
-
type: 'string' | 'integer' | 'float' | 'boolean' | 'array' | 'datetime' | 'object';
|
|
460
|
-
|
|
461
|
-
default?: unknown;
|
|
462
|
-
|
|
463
|
-
description?: string | null;
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* List of allowed enum values (max 15)
|
|
467
|
-
*/
|
|
468
|
-
enum_values?: Array<string> | null;
|
|
469
|
-
|
|
470
|
-
max_length?: number | null;
|
|
471
|
-
|
|
472
|
-
max_value?: number | null;
|
|
473
|
-
|
|
474
|
-
min_length?: number | null;
|
|
475
|
-
|
|
476
|
-
min_value?: number | null;
|
|
477
|
-
|
|
478
|
-
pattern?: string | null;
|
|
479
|
-
|
|
480
|
-
required?: boolean;
|
|
481
|
-
}
|
|
1045
|
+
unique_identifiers?: Array<string>;
|
|
482
1046
|
}
|
|
483
1047
|
|
|
484
1048
|
/**
|
|
485
|
-
* User-defined relationship type
|
|
1049
|
+
* User-defined relationship type with optional inline constraint.
|
|
1050
|
+
*
|
|
1051
|
+
* The `constraint` field allows defining default matching/creation behavior
|
|
1052
|
+
* directly within the relationship type definition. This mirrors the pattern used
|
|
1053
|
+
* in UserNodeType.constraint for nodes.
|
|
1054
|
+
*
|
|
1055
|
+
* Schema-level edge constraints:
|
|
1056
|
+
*
|
|
1057
|
+
* - `edge_type` is implicit (taken from parent UserRelationshipType.name)
|
|
1058
|
+
* - Defines default target node matching strategy via `search.properties`
|
|
1059
|
+
* - Can be overridden per-memory via memory_policy.edge_constraints
|
|
1060
|
+
*
|
|
1061
|
+
* Example: UserRelationshipType( name="MITIGATES", label="Mitigates",
|
|
1062
|
+
* allowed_source_types=["SecurityBehavior"], allowed_target_types=["TacticDef"],
|
|
1063
|
+
* constraint=EdgeConstraint( search=SearchConfig(properties=[
|
|
1064
|
+
* PropertyMatch(name="name", mode="semantic", threshold=0.90) ]), create="never" #
|
|
1065
|
+
* Controlled vocabulary - only link to existing targets ) )
|
|
486
1066
|
*/
|
|
487
1067
|
export interface RelationshipTypes {
|
|
488
1068
|
allowed_source_types: Array<string>;
|
|
@@ -497,39 +1077,63 @@ export namespace SchemaCreateParams {
|
|
|
497
1077
|
|
|
498
1078
|
color?: string | null;
|
|
499
1079
|
|
|
500
|
-
description?: string | null;
|
|
501
|
-
|
|
502
|
-
properties?: { [key: string]: RelationshipTypes.Properties };
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
export namespace RelationshipTypes {
|
|
506
1080
|
/**
|
|
507
|
-
*
|
|
1081
|
+
* Policy for how edges/relationships of a specific type should be handled.
|
|
1082
|
+
*
|
|
1083
|
+
* Used in two places:
|
|
1084
|
+
*
|
|
1085
|
+
* 1. **Schema level**: Inside `UserRelationshipType.constraint` - `edge_type` is
|
|
1086
|
+
* implicit from parent
|
|
1087
|
+
* 2. **Memory level**: In `memory_policy.edge_constraints[]` - `edge_type` is
|
|
1088
|
+
* required
|
|
1089
|
+
*
|
|
1090
|
+
* Edge constraints allow developers to control:
|
|
1091
|
+
*
|
|
1092
|
+
* - Which edge types can be created vs. linked to existing targets
|
|
1093
|
+
* - How to find/select target nodes (via `search`)
|
|
1094
|
+
* - What edge property values to set (exact or auto-extracted)
|
|
1095
|
+
* - When to apply the constraint (conditional with logical operators)
|
|
1096
|
+
* - Filter by source/target node types
|
|
1097
|
+
*
|
|
1098
|
+
* **The `search` field** handles target node selection:
|
|
1099
|
+
*
|
|
1100
|
+
* - Uses SearchConfig to define how to find existing target nodes
|
|
1101
|
+
* - Example: `{"properties": [{"name": "name", "mode": "semantic"}]}`
|
|
1102
|
+
* - For controlled vocabulary: find existing target, don't create new
|
|
1103
|
+
*
|
|
1104
|
+
* **The `set` field** controls edge property values:
|
|
1105
|
+
*
|
|
1106
|
+
* - Exact value: `{"weight": 1.0}` - sets exact value
|
|
1107
|
+
* - Auto-extract: `{"reason": {"mode": "auto"}}` - LLM extracts from content
|
|
1108
|
+
*
|
|
1109
|
+
* **The `when` field** supports logical operators (same as NodeConstraint):
|
|
1110
|
+
*
|
|
1111
|
+
* - Simple: `{"severity": "high"}`
|
|
1112
|
+
* - AND: `{"_and": [{"severity": "high"}, {"confirmed": true}]}`
|
|
1113
|
+
* - OR: `{"_or": [{"type": "MITIGATES"}, {"type": "PREVENTS"}]}`
|
|
1114
|
+
* - NOT: `{"_not": {"status": "deprecated"}}`
|
|
508
1115
|
*/
|
|
509
|
-
|
|
510
|
-
type: 'string' | 'integer' | 'float' | 'boolean' | 'array' | 'datetime' | 'object';
|
|
511
|
-
|
|
512
|
-
default?: unknown;
|
|
513
|
-
|
|
514
|
-
description?: string | null;
|
|
1116
|
+
constraint?: Shared.EdgeConstraintInput | null;
|
|
515
1117
|
|
|
516
|
-
|
|
517
|
-
* List of allowed enum values (max 15)
|
|
518
|
-
*/
|
|
519
|
-
enum_values?: Array<string> | null;
|
|
520
|
-
|
|
521
|
-
max_length?: number | null;
|
|
522
|
-
|
|
523
|
-
max_value?: number | null;
|
|
524
|
-
|
|
525
|
-
min_length?: number | null;
|
|
1118
|
+
description?: string | null;
|
|
526
1119
|
|
|
527
|
-
|
|
1120
|
+
/**
|
|
1121
|
+
* DEPRECATED: Use resolution_policy='lookup' instead. Shorthand for constraint
|
|
1122
|
+
* with create='lookup'. When True, only links to existing target nodes (controlled
|
|
1123
|
+
* vocabulary). Equivalent to @lookup decorator. If constraint is also provided,
|
|
1124
|
+
* link_only=True will override constraint.create to 'lookup'.
|
|
1125
|
+
*/
|
|
1126
|
+
link_only?: boolean;
|
|
528
1127
|
|
|
529
|
-
|
|
1128
|
+
properties?: { [key: string]: SchemasAPI.PropertyDefinition };
|
|
530
1129
|
|
|
531
|
-
|
|
532
|
-
|
|
1130
|
+
/**
|
|
1131
|
+
* Shorthand for constraint.create. 'upsert': Create target if not found (default).
|
|
1132
|
+
* 'lookup': Only link to existing targets (controlled vocabulary). Equivalent to
|
|
1133
|
+
* @upsert/@lookup decorators. If constraint is also provided, resolution_policy
|
|
1134
|
+
* will set constraint.create accordingly.
|
|
1135
|
+
*/
|
|
1136
|
+
resolution_policy?: 'upsert' | 'lookup';
|
|
533
1137
|
}
|
|
534
1138
|
}
|
|
535
1139
|
|
|
@@ -551,6 +1155,8 @@ export interface SchemaListParams {
|
|
|
551
1155
|
|
|
552
1156
|
export declare namespace Schemas {
|
|
553
1157
|
export {
|
|
1158
|
+
type PropertyDefinition as PropertyDefinition,
|
|
1159
|
+
type SearchConfigOutput as SearchConfigOutput,
|
|
554
1160
|
type UserGraphSchemaOutput as UserGraphSchemaOutput,
|
|
555
1161
|
type SchemaCreateResponse as SchemaCreateResponse,
|
|
556
1162
|
type SchemaRetrieveResponse as SchemaRetrieveResponse,
|