@papr/memory 1.19.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.
Files changed (130) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/LICENSE +1 -1
  3. package/README.md +13 -1
  4. package/client.d.mts +38 -10
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +38 -10
  7. package/client.d.ts.map +1 -1
  8. package/client.js +17 -2
  9. package/client.js.map +1 -1
  10. package/client.mjs +17 -2
  11. package/client.mjs.map +1 -1
  12. package/internal/parse.d.mts.map +1 -1
  13. package/internal/parse.d.ts.map +1 -1
  14. package/internal/parse.js +5 -0
  15. package/internal/parse.js.map +1 -1
  16. package/internal/parse.mjs +5 -0
  17. package/internal/parse.mjs.map +1 -1
  18. package/internal/tslib.js +22 -22
  19. package/package.json +1 -1
  20. package/resources/document.d.mts +16 -3
  21. package/resources/document.d.mts.map +1 -1
  22. package/resources/document.d.ts +16 -3
  23. package/resources/document.d.ts.map +1 -1
  24. package/resources/index.d.mts +6 -3
  25. package/resources/index.d.mts.map +1 -1
  26. package/resources/index.d.ts +6 -3
  27. package/resources/index.d.ts.map +1 -1
  28. package/resources/index.js +7 -1
  29. package/resources/index.js.map +1 -1
  30. package/resources/index.mjs +3 -0
  31. package/resources/index.mjs.map +1 -1
  32. package/resources/memory.d.mts +527 -95
  33. package/resources/memory.d.mts.map +1 -1
  34. package/resources/memory.d.ts +527 -95
  35. package/resources/memory.d.ts.map +1 -1
  36. package/resources/memory.js +21 -6
  37. package/resources/memory.js.map +1 -1
  38. package/resources/memory.mjs +21 -6
  39. package/resources/memory.mjs.map +1 -1
  40. package/resources/messages/index.d.mts +3 -0
  41. package/resources/messages/index.d.mts.map +1 -0
  42. package/resources/messages/index.d.ts +3 -0
  43. package/resources/messages/index.d.ts.map +1 -0
  44. package/resources/messages/index.js +9 -0
  45. package/resources/messages/index.js.map +1 -0
  46. package/resources/messages/index.mjs +4 -0
  47. package/resources/messages/index.mjs.map +1 -0
  48. package/resources/messages/messages.d.mts +160 -0
  49. package/resources/messages/messages.d.mts.map +1 -0
  50. package/resources/messages/messages.d.ts +160 -0
  51. package/resources/messages/messages.d.ts.map +1 -0
  52. package/resources/messages/messages.js +54 -0
  53. package/resources/messages/messages.js.map +1 -0
  54. package/resources/messages/messages.mjs +49 -0
  55. package/resources/messages/messages.mjs.map +1 -0
  56. package/resources/messages/sessions.d.mts +262 -0
  57. package/resources/messages/sessions.d.mts.map +1 -0
  58. package/resources/messages/sessions.d.ts +262 -0
  59. package/resources/messages/sessions.d.ts.map +1 -0
  60. package/resources/messages/sessions.js +122 -0
  61. package/resources/messages/sessions.js.map +1 -0
  62. package/resources/messages/sessions.mjs +118 -0
  63. package/resources/messages/sessions.mjs.map +1 -0
  64. package/resources/messages.d.mts +2 -0
  65. package/resources/messages.d.mts.map +1 -0
  66. package/resources/messages.d.ts +2 -0
  67. package/resources/messages.d.ts.map +1 -0
  68. package/resources/messages.js +6 -0
  69. package/resources/messages.js.map +1 -0
  70. package/resources/messages.mjs +3 -0
  71. package/resources/messages.mjs.map +1 -0
  72. package/resources/omo.d.mts +98 -0
  73. package/resources/omo.d.mts.map +1 -0
  74. package/resources/omo.d.ts +98 -0
  75. package/resources/omo.d.ts.map +1 -0
  76. package/resources/omo.js +36 -0
  77. package/resources/omo.js.map +1 -0
  78. package/resources/omo.mjs +32 -0
  79. package/resources/omo.mjs.map +1 -0
  80. package/resources/schemas.d.mts +712 -92
  81. package/resources/schemas.d.mts.map +1 -1
  82. package/resources/schemas.d.ts +712 -92
  83. package/resources/schemas.d.ts.map +1 -1
  84. package/resources/schemas.js +23 -10
  85. package/resources/schemas.js.map +1 -1
  86. package/resources/schemas.mjs +23 -10
  87. package/resources/schemas.mjs.map +1 -1
  88. package/resources/shared.d.mts +671 -0
  89. package/resources/shared.d.mts.map +1 -1
  90. package/resources/shared.d.ts +671 -0
  91. package/resources/shared.d.ts.map +1 -1
  92. package/resources/sync.d.mts +142 -0
  93. package/resources/sync.d.mts.map +1 -0
  94. package/resources/sync.d.ts +142 -0
  95. package/resources/sync.d.ts.map +1 -0
  96. package/resources/sync.js +36 -0
  97. package/resources/sync.js.map +1 -0
  98. package/resources/sync.mjs +32 -0
  99. package/resources/sync.mjs.map +1 -0
  100. package/resources/user.d.mts +18 -1
  101. package/resources/user.d.mts.map +1 -1
  102. package/resources/user.d.ts +18 -1
  103. package/resources/user.d.ts.map +1 -1
  104. package/resources/user.js +11 -0
  105. package/resources/user.js.map +1 -1
  106. package/resources/user.mjs +11 -0
  107. package/resources/user.mjs.map +1 -1
  108. package/src/client.ts +81 -9
  109. package/src/internal/parse.ts +6 -0
  110. package/src/resources/document.ts +17 -4
  111. package/src/resources/index.ts +21 -0
  112. package/src/resources/memory.ts +586 -134
  113. package/src/resources/messages/index.ts +11 -0
  114. package/src/resources/messages/messages.ts +193 -0
  115. package/src/resources/messages/sessions.ts +315 -0
  116. package/src/resources/messages.ts +3 -0
  117. package/src/resources/omo.ts +132 -0
  118. package/src/resources/schemas.ts +740 -111
  119. package/src/resources/shared.ts +752 -0
  120. package/src/resources/sync.ts +179 -0
  121. package/src/resources/user.ts +23 -0
  122. package/src/version.ts +1 -1
  123. package/version.d.mts +1 -1
  124. package/version.d.mts.map +1 -1
  125. package/version.d.ts +1 -1
  126. package/version.d.ts.map +1 -1
  127. package/version.js +1 -1
  128. package/version.js.map +1 -1
  129. package/version.mjs +1 -1
  130. package/version.mjs.map +1 -1
@@ -1,4 +1,6 @@
1
1
  import { APIResource } from "../core/resource.js";
2
+ import * as SchemasAPI from "./schemas.js";
3
+ import * as Shared from "./shared.js";
2
4
  import { APIPromise } from "../core/api-promise.js";
3
5
  import { RequestOptions } from "../internal/request-options.js";
4
6
  export declare class Schemas extends APIResource {
@@ -12,9 +14,16 @@ export declare class Schemas extends APIResource {
12
14
  * - Define custom node types with properties and validation rules
13
15
  * - Define custom relationship types with constraints
14
16
  * - Automatic validation against system schemas
15
- * - Support for different scopes (personal, workspace, organization)
16
- * - **Enum support**: Use `enum_values` to restrict property values to a predefined list (max 10 values)
17
- * - **Auto-indexing**: Required properties are automatically indexed in Neo4j for optimal query performance
17
+ * - Support for different scopes (personal, workspace, namespace, organization)
18
+ * - **Status control**: Set `status` to "active" to immediately activate the schema, or "draft" to save as draft (default)
19
+ * - **Enum support**: Use `enum_values` to restrict property values to a predefined list (max 15 values)
20
+ * - **Auto-indexing**: Required properties are automatically indexed in Neo4j when schema becomes active
21
+ *
22
+ * **Schema Limits (optimized for LLM performance):**
23
+ * - **Maximum 10 node types** per schema
24
+ * - **Maximum 20 relationship types** per schema
25
+ * - **Maximum 10 properties** per node type
26
+ * - **Maximum 15 enum values** per property
18
27
  *
19
28
  * **Property Types & Validation:**
20
29
  * - `string`: Text values with optional `enum_values`, `min_length`, `max_length`, `pattern`
@@ -27,18 +36,18 @@ export declare class Schemas extends APIResource {
27
36
  *
28
37
  * **Enum Values:**
29
38
  * - Add `enum_values` to any string property to restrict values to a predefined list
30
- * - Maximum 10 enum values allowed per property
39
+ * - Maximum 15 enum values allowed per property
31
40
  * - Use with `default` to set a default enum value
32
41
  * - Example: `"enum_values": ["small", "medium", "large"]`
33
42
  *
34
43
  * **When to Use Enums:**
35
- * - Limited, well-defined options (≤10 values): sizes, statuses, categories, priorities
44
+ * - Limited, well-defined options (≤15 values): sizes, statuses, categories, priorities
36
45
  * - Controlled vocabularies: "active/inactive", "high/medium/low", "bronze/silver/gold"
37
46
  * - When you want exact matching and no variations
38
47
  *
39
48
  * **When to Avoid Enums:**
40
49
  * - Open-ended text fields: names, titles, descriptions, addresses
41
- * - Large sets of options (>10): countries, cities, product models
50
+ * - Large sets of options (>15): countries, cities, product models
42
51
  * - When you want semantic similarity matching for entity resolution
43
52
  * - Dynamic or frequently changing value sets
44
53
  *
@@ -48,8 +57,8 @@ export declare class Schemas extends APIResource {
48
57
  * - **Without enum_values**: Semantic similarity matching is used - entities with similar meanings are automatically merged
49
58
  * - Example: A "name" unique_identifier without enums will merge "Apple Inc" and "Apple Inc." as the same entity
50
59
  * - Example: A "sku" unique_identifier with enums will only merge entities with exactly matching SKU codes
51
- * - Use enums for unique_identifiers when you have a limited, predefined set of values (≤10 options)
52
- * - Avoid enums for unique_identifiers when you have broad, open-ended values or >10 possible options
60
+ * - Use enums for unique_identifiers when you have a limited, predefined set of values (≤15 options)
61
+ * - Avoid enums for unique_identifiers when you have broad, open-ended values or >15 possible options
53
62
  * - **Best practices**: Use enums for controlled vocabularies (status codes, categories), avoid for open text (company names, product titles)
54
63
  * - **In the example above**: "name" uses semantic similarity (open-ended), "sku" uses exact matching (controlled set)
55
64
  *
@@ -80,9 +89,14 @@ export declare class Schemas extends APIResource {
80
89
  /**
81
90
  * Update an existing schema.
82
91
  *
83
- * Allows modification of schema properties, node types, and relationship types.
92
+ * Allows modification of schema properties, node types, relationship types, and status.
84
93
  * User must have write access to the schema. Updates create a new version
85
94
  * while preserving the existing data.
95
+ *
96
+ * **Status Management:**
97
+ * - Set `status` to "active" to activate the schema and trigger Neo4j index creation
98
+ * - Set `status` to "draft" to deactivate the schema
99
+ * - Set `status` to "archived" to soft-delete the schema
86
100
  */
87
101
  update(schemaID: string, params: SchemaUpdateParams, options?: RequestOptions): APIPromise<SchemaUpdateResponse>;
88
102
  /**
@@ -90,7 +104,8 @@ export declare class Schemas extends APIResource {
90
104
  *
91
105
  * Returns schemas that the user owns or has read access to, including:
92
106
  * - Personal schemas created by the user
93
- * - Workspace schemas shared within the user's workspace
107
+ * - Workspace schemas shared within the user's workspace (legacy)
108
+ * - Namespace schemas shared within the user's namespace
94
109
  * - Organization schemas available to the user's organization
95
110
  *
96
111
  * **Authentication Required**:
@@ -109,6 +124,113 @@ export declare class Schemas extends APIResource {
109
124
  */
110
125
  delete(schemaID: string, options?: RequestOptions): APIPromise<unknown>;
111
126
  }
127
+ /**
128
+ * Property definition for nodes/relationships
129
+ */
130
+ export interface PropertyDefinition {
131
+ type: 'string' | 'integer' | 'float' | 'boolean' | 'array' | 'datetime' | 'object';
132
+ default?: unknown;
133
+ description?: string | null;
134
+ /**
135
+ * List of allowed enum values (max 15)
136
+ */
137
+ enum_values?: Array<string> | null;
138
+ max_length?: number | null;
139
+ max_value?: number | null;
140
+ min_length?: number | null;
141
+ min_value?: number | null;
142
+ pattern?: string | null;
143
+ required?: boolean;
144
+ }
145
+ /**
146
+ * Configuration for finding/selecting existing nodes.
147
+ *
148
+ * Defines which properties to match on and how, in priority order. The first
149
+ * matching property wins.
150
+ *
151
+ * **String Shorthand** (simple cases - converts to exact match):
152
+ * SearchConfig(properties=["id", "email"]) # Equivalent to:
153
+ * SearchConfig(properties=[PropertyMatch.exact("id"),
154
+ * PropertyMatch.exact("email")])
155
+ *
156
+ * **Mixed Form** (combine strings and PropertyMatch): SearchConfig(properties=[
157
+ * "id", # String -> exact match PropertyMatch.semantic("title", 0.9) # Full
158
+ * control ])
159
+ *
160
+ * **Full Form** (maximum control): SearchConfig(properties=[
161
+ * PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
162
+ * mode="semantic", threshold=0.85) ])
163
+ *
164
+ * **To select a specific node by ID**:
165
+ * SearchConfig(properties=[PropertyMatch.exact("id", "TASK-123")])
166
+ */
167
+ export interface SearchConfigOutput {
168
+ /**
169
+ * Default search mode when property doesn't specify one. 'semantic' (vector
170
+ * similarity), 'exact' (property match), 'fuzzy' (partial match).
171
+ */
172
+ mode?: 'semantic' | 'exact' | 'fuzzy';
173
+ /**
174
+ * Properties to match on, in priority order (first match wins). Accepts strings
175
+ * (converted to exact match) or PropertyMatch objects. Use PropertyMatch with
176
+ * 'value' field for specific node selection.
177
+ */
178
+ properties?: Array<SearchConfigOutput.Property> | null;
179
+ /**
180
+ * Default similarity threshold for semantic/fuzzy matching (0.0-1.0). Used when
181
+ * property doesn't specify its own threshold.
182
+ */
183
+ threshold?: number;
184
+ /**
185
+ * Search for nodes via their relationships. Example: Find tasks assigned to a
186
+ * specific person. Each RelationshipMatch specifies edge_type, target_type, and
187
+ * target_search. Multiple relationship matches are ANDed together.
188
+ */
189
+ via_relationship?: Array<unknown> | null;
190
+ }
191
+ export declare namespace SearchConfigOutput {
192
+ /**
193
+ * Property matching configuration.
194
+ *
195
+ * Defines which property to match on and how. When listed in search.properties,
196
+ * this property becomes a unique identifier.
197
+ *
198
+ * **Shorthand Helpers** (recommended for common cases):
199
+ * PropertyMatch.exact("id") # Exact match on id PropertyMatch.exact("id",
200
+ * "TASK-123") # Exact match with specific value PropertyMatch.semantic("title") #
201
+ * Semantic match with default threshold PropertyMatch.semantic("title", 0.9) #
202
+ * Semantic match with custom threshold PropertyMatch.semantic("title",
203
+ * value="bug") # Semantic search for "bug" PropertyMatch.fuzzy("name", 0.8) #
204
+ * Fuzzy match
205
+ *
206
+ * **Full Form** (when you need all options): PropertyMatch(name="title",
207
+ * mode="semantic", threshold=0.9, value="auth bug")
208
+ *
209
+ * **String Shorthand** (in SearchConfig.properties): properties=["id", "email"] #
210
+ * Equivalent to [PropertyMatch.exact("id"), PropertyMatch.exact("email")]
211
+ */
212
+ interface Property {
213
+ /**
214
+ * Property name to match on (e.g., 'id', 'email', 'title')
215
+ */
216
+ name: string;
217
+ /**
218
+ * Matching mode: 'exact' (string match), 'semantic' (embedding similarity),
219
+ * 'fuzzy' (Levenshtein distance)
220
+ */
221
+ mode?: 'semantic' | 'exact' | 'fuzzy';
222
+ /**
223
+ * Similarity threshold for semantic/fuzzy modes (0.0-1.0). Ignored for exact mode.
224
+ */
225
+ threshold?: number;
226
+ /**
227
+ * Runtime value override. If set, use this value for matching instead of
228
+ * extracting from content. Useful for memory-level overrides when you know the
229
+ * exact value to search for.
230
+ */
231
+ value?: unknown;
232
+ }
233
+ }
112
234
  /**
113
235
  * Complete user-defined graph schema
114
236
  */
@@ -119,11 +241,40 @@ export interface UserGraphSchemaOutput {
119
241
  description?: string | null;
120
242
  last_used_at?: string | null;
121
243
  /**
122
- * Custom node types (max 15 per schema)
244
+ * Default memory policy for memories using this schema. Includes mode ('auto',
245
+ * 'manual'), node_constraints (applied in auto mode when present), and OMO safety
246
+ * settings (consent, risk). Memory-level policies override schema-level.
247
+ */
248
+ memory_policy?: {
249
+ [key: string]: unknown;
250
+ } | null;
251
+ /**
252
+ * @deprecated DEPRECATED: Use 'namespace_id' instead. Accepts Parse pointer or
253
+ * objectId.
254
+ */
255
+ namespace?: string | {
256
+ [key: string]: unknown;
257
+ } | null;
258
+ /**
259
+ * Namespace ID this schema belongs to. Accepts legacy 'namespace' alias.
260
+ */
261
+ namespace_id?: string | null;
262
+ /**
263
+ * Custom node types (max 10 per schema)
123
264
  */
124
265
  node_types?: {
125
266
  [key: string]: UserGraphSchemaOutput.NodeTypes;
126
267
  };
268
+ /**
269
+ * @deprecated DEPRECATED: Use 'organization_id' instead. Accepts Parse pointer or
270
+ * objectId.
271
+ */
272
+ organization?: string | {
273
+ [key: string]: unknown;
274
+ } | null;
275
+ /**
276
+ * Organization ID this schema belongs to. Accepts legacy 'organization' alias.
277
+ */
127
278
  organization_id?: string | null;
128
279
  read_access?: Array<string>;
129
280
  /**
@@ -132,7 +283,10 @@ export interface UserGraphSchemaOutput {
132
283
  relationship_types?: {
133
284
  [key: string]: UserGraphSchemaOutput.RelationshipTypes;
134
285
  };
135
- scope?: 'personal' | 'workspace' | 'organization';
286
+ /**
287
+ * Schema scopes available through the API
288
+ */
289
+ scope?: 'personal' | 'workspace' | 'namespace' | 'organization';
136
290
  status?: 'draft' | 'active' | 'deprecated' | 'archived';
137
291
  updated_at?: string | null;
138
292
  usage_count?: number;
@@ -147,49 +301,229 @@ export interface UserGraphSchemaOutput {
147
301
  }
148
302
  export declare namespace UserGraphSchemaOutput {
149
303
  /**
150
- * User-defined node type
304
+ * User-defined node type with optional inline constraint.
305
+ *
306
+ * The `constraint` field allows defining default matching/creation behavior
307
+ * directly within the node type definition. This replaces the need to put
308
+ * constraints only in memory_policy.node_constraints.
309
+ *
310
+ * Schema-level constraints:
311
+ *
312
+ * - `node_type` is implicit (taken from parent UserNodeType.name)
313
+ * - Defines default matching strategy via `search.properties`
314
+ * - Can be overridden per-memory via memory_policy.node_constraints
315
+ *
316
+ * Example: UserNodeType( name="Task", label="Task", properties={ "id":
317
+ * PropertyDefinition(type="string"), "title": PropertyDefinition(type="string",
318
+ * required=True) }, constraint=NodeConstraint( search=SearchConfig(properties=[
319
+ * PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
320
+ * mode="semantic", threshold=0.85) ]), create="auto" ) )
151
321
  */
152
322
  interface NodeTypes {
153
323
  label: string;
154
324
  name: string;
155
325
  color?: string | null;
326
+ /**
327
+ * Policy for how nodes of a specific type should be handled.
328
+ *
329
+ * Used in two places:
330
+ *
331
+ * 1. **Schema level**: Inside `UserNodeType.constraint` - `node_type` is implicit
332
+ * from parent
333
+ * 2. **Memory level**: In `memory_policy.node_constraints[]` - `node_type` is
334
+ * required
335
+ *
336
+ * Node constraints allow developers to control:
337
+ *
338
+ * - Which node types can be created vs. linked
339
+ * - How to find/select existing nodes (via `search`)
340
+ * - What property values to set (exact or auto-extracted)
341
+ * - When to apply the constraint (conditional with logical operators)
342
+ *
343
+ * **The `search` field** handles node selection:
344
+ *
345
+ * - Uses PropertyMatch list to define unique identifiers and matching strategy
346
+ * - Example:
347
+ * `{"properties": [{"name": "id", "mode": "exact"}, {"name": "title", "mode": "semantic"}]}`
348
+ * - For direct selection, use PropertyMatch with value:
349
+ * `{"name": "id", "mode": "exact", "value": "proj_123"}`
350
+ *
351
+ * **The `set` field** controls property values:
352
+ *
353
+ * - Exact value: `{"status": "done"}` - sets exact value
354
+ * - Auto-extract: `{"status": {"mode": "auto"}}` - LLM extracts from content
355
+ *
356
+ * **The `when` field** supports logical operators:
357
+ *
358
+ * - Simple: `{"priority": "high"}`
359
+ * - AND: `{"_and": [{"priority": "high"}, {"status": "active"}]}`
360
+ * - OR: `{"_or": [{"status": "active"}, {"status": "pending"}]}`
361
+ * - NOT: `{"_not": {"status": "completed"}}`
362
+ * - Complex:
363
+ * `{"_and": [{"priority": "high"}, {"_or": [{"status": "active"}, {"urgent": true}]}]}`
364
+ */
365
+ constraint?: NodeTypes.Constraint | null;
156
366
  description?: string | null;
157
367
  icon?: string | null;
158
368
  /**
159
- * Node properties (max 15 per node type)
369
+ * DEPRECATED: Use resolution_policy='lookup' instead. Shorthand for constraint
370
+ * with create='lookup'. When True, only links to existing nodes (controlled
371
+ * vocabulary). Equivalent to @lookup decorator. If constraint is also provided,
372
+ * link_only=True will override constraint.create to 'lookup'.
373
+ */
374
+ link_only?: boolean;
375
+ /**
376
+ * Node properties (max 10 per node type)
160
377
  */
161
378
  properties?: {
162
- [key: string]: NodeTypes.Properties;
379
+ [key: string]: SchemasAPI.PropertyDefinition;
163
380
  };
164
381
  required_properties?: Array<string>;
165
382
  /**
166
- * Properties that uniquely identify this node type. Used for MERGE operations to
167
- * avoid duplicates. Example: ['name', 'email'] for Customer nodes.
383
+ * Shorthand for constraint.create. 'upsert': Create if not found (default).
384
+ * 'lookup': Only link to existing nodes (controlled vocabulary). Equivalent to
385
+ * @upsert/@lookup decorators. If constraint is also provided, resolution_policy
386
+ * will set constraint.create accordingly.
387
+ */
388
+ resolution_policy?: 'upsert' | 'lookup';
389
+ /**
390
+ * DEPRECATED: Use 'constraint.search.properties' instead. Properties that uniquely
391
+ * identify this node type. Example: ['name', 'email'] for Customer nodes.
168
392
  */
169
393
  unique_identifiers?: Array<string>;
170
394
  }
171
395
  namespace NodeTypes {
172
396
  /**
173
- * Property definition for nodes/relationships
397
+ * Policy for how nodes of a specific type should be handled.
398
+ *
399
+ * Used in two places:
400
+ *
401
+ * 1. **Schema level**: Inside `UserNodeType.constraint` - `node_type` is implicit
402
+ * from parent
403
+ * 2. **Memory level**: In `memory_policy.node_constraints[]` - `node_type` is
404
+ * required
405
+ *
406
+ * Node constraints allow developers to control:
407
+ *
408
+ * - Which node types can be created vs. linked
409
+ * - How to find/select existing nodes (via `search`)
410
+ * - What property values to set (exact or auto-extracted)
411
+ * - When to apply the constraint (conditional with logical operators)
412
+ *
413
+ * **The `search` field** handles node selection:
414
+ *
415
+ * - Uses PropertyMatch list to define unique identifiers and matching strategy
416
+ * - Example:
417
+ * `{"properties": [{"name": "id", "mode": "exact"}, {"name": "title", "mode": "semantic"}]}`
418
+ * - For direct selection, use PropertyMatch with value:
419
+ * `{"name": "id", "mode": "exact", "value": "proj_123"}`
420
+ *
421
+ * **The `set` field** controls property values:
422
+ *
423
+ * - Exact value: `{"status": "done"}` - sets exact value
424
+ * - Auto-extract: `{"status": {"mode": "auto"}}` - LLM extracts from content
425
+ *
426
+ * **The `when` field** supports logical operators:
427
+ *
428
+ * - Simple: `{"priority": "high"}`
429
+ * - AND: `{"_and": [{"priority": "high"}, {"status": "active"}]}`
430
+ * - OR: `{"_or": [{"status": "active"}, {"status": "pending"}]}`
431
+ * - NOT: `{"_not": {"status": "completed"}}`
432
+ * - Complex:
433
+ * `{"_and": [{"priority": "high"}, {"_or": [{"status": "active"}, {"urgent": true}]}]}`
174
434
  */
175
- interface Properties {
176
- type: 'string' | 'integer' | 'float' | 'boolean' | 'array' | 'datetime' | 'object';
177
- default?: unknown;
178
- description?: string | null;
435
+ interface Constraint {
436
+ /**
437
+ * 'upsert': Create if not found via search (default). 'lookup': Only link to
438
+ * existing nodes (controlled vocabulary). Deprecated aliases: 'auto' -> 'upsert',
439
+ * 'never' -> 'lookup'.
440
+ */
441
+ create?: 'upsert' | 'lookup' | 'auto' | 'never';
442
+ /**
443
+ * DEPRECATED: Use create='lookup' instead. Shorthand for create='lookup'. When
444
+ * True, only links to existing nodes (controlled vocabulary). Equivalent to
445
+ * @lookup decorator in schema definitions.
446
+ */
447
+ link_only?: boolean;
448
+ /**
449
+ * Node type this constraint applies to (e.g., 'Task', 'Project', 'Person').
450
+ * Optional at schema level (implicit from parent UserNodeType), required at memory
451
+ * level (in memory_policy.node_constraints).
452
+ */
453
+ node_type?: string | null;
454
+ /**
455
+ * Explicit behavior when no match found via search. 'create': create new node
456
+ * (same as upsert). 'ignore': skip node creation (same as lookup). 'error': raise
457
+ * error if node not found. If specified, overrides 'create' field.
458
+ */
459
+ on_miss?: 'create' | 'ignore' | 'error' | null;
460
+ /**
461
+ * Configuration for finding/selecting existing nodes.
462
+ *
463
+ * Defines which properties to match on and how, in priority order. The first
464
+ * matching property wins.
465
+ *
466
+ * **String Shorthand** (simple cases - converts to exact match):
467
+ * SearchConfig(properties=["id", "email"]) # Equivalent to:
468
+ * SearchConfig(properties=[PropertyMatch.exact("id"),
469
+ * PropertyMatch.exact("email")])
470
+ *
471
+ * **Mixed Form** (combine strings and PropertyMatch): SearchConfig(properties=[
472
+ * "id", # String -> exact match PropertyMatch.semantic("title", 0.9) # Full
473
+ * control ])
474
+ *
475
+ * **Full Form** (maximum control): SearchConfig(properties=[
476
+ * PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
477
+ * mode="semantic", threshold=0.85) ])
478
+ *
479
+ * **To select a specific node by ID**:
480
+ * SearchConfig(properties=[PropertyMatch.exact("id", "TASK-123")])
481
+ */
482
+ search?: SchemasAPI.SearchConfigOutput | null;
483
+ /**
484
+ * Set property values on nodes. Supports: 1. Exact value: {'status': 'done'} -
485
+ * sets exact value. 2. Auto-extract: {'status': {'mode': 'auto'}} - LLM extracts
486
+ * from content. 3. Text mode: {'summary': {'mode': 'auto', 'text_mode':
487
+ * 'merge'}} - controls text updates. For text properties, text_mode can be
488
+ * 'replace', 'append', or 'merge'.
489
+ */
490
+ set?: {
491
+ [key: string]: string | number | boolean | Array<unknown> | {
492
+ [key: string]: unknown;
493
+ } | Shared.PropertyValue;
494
+ } | null;
179
495
  /**
180
- * List of allowed enum values (max 10)
496
+ * Condition for when this constraint applies. Supports logical operators: '\_and',
497
+ * '\_or', '\_not'. Examples: Simple: {'priority': 'high'} - matches when priority
498
+ * equals 'high'. AND: {'\_and': [{'priority': 'high'}, {'status': 'active'}]} -
499
+ * all must match. OR: {'\_or': [{'status': 'active'}, {'status': 'pending'}]} -
500
+ * any must match. NOT: {'\_not': {'status': 'completed'}} - negation. Complex:
501
+ * {'\_and': [{'priority': 'high'}, {'\_or': [{'status': 'active'}, {'urgent':
502
+ * true}]}]}
181
503
  */
182
- enum_values?: Array<string> | null;
183
- max_length?: number | null;
184
- max_value?: number | null;
185
- min_length?: number | null;
186
- min_value?: number | null;
187
- pattern?: string | null;
188
- required?: boolean;
504
+ when?: {
505
+ [key: string]: unknown;
506
+ } | null;
189
507
  }
190
508
  }
191
509
  /**
192
- * User-defined relationship type
510
+ * User-defined relationship type with optional inline constraint.
511
+ *
512
+ * The `constraint` field allows defining default matching/creation behavior
513
+ * directly within the relationship type definition. This mirrors the pattern used
514
+ * in UserNodeType.constraint for nodes.
515
+ *
516
+ * Schema-level edge constraints:
517
+ *
518
+ * - `edge_type` is implicit (taken from parent UserRelationshipType.name)
519
+ * - Defines default target node matching strategy via `search.properties`
520
+ * - Can be overridden per-memory via memory_policy.edge_constraints
521
+ *
522
+ * Example: UserRelationshipType( name="MITIGATES", label="Mitigates",
523
+ * allowed_source_types=["SecurityBehavior"], allowed_target_types=["TacticDef"],
524
+ * constraint=EdgeConstraint( search=SearchConfig(properties=[
525
+ * PropertyMatch(name="name", mode="semantic", threshold=0.90) ]), create="never" #
526
+ * Controlled vocabulary - only link to existing targets ) )
193
527
  */
194
528
  interface RelationshipTypes {
195
529
  allowed_source_types: Array<string>;
@@ -198,29 +532,186 @@ export declare namespace UserGraphSchemaOutput {
198
532
  name: string;
199
533
  cardinality?: 'one-to-one' | 'one-to-many' | 'many-to-many';
200
534
  color?: string | null;
535
+ /**
536
+ * Policy for how edges/relationships of a specific type should be handled.
537
+ *
538
+ * Used in two places:
539
+ *
540
+ * 1. **Schema level**: Inside `UserRelationshipType.constraint` - `edge_type` is
541
+ * implicit from parent
542
+ * 2. **Memory level**: In `memory_policy.edge_constraints[]` - `edge_type` is
543
+ * required
544
+ *
545
+ * Edge constraints allow developers to control:
546
+ *
547
+ * - Which edge types can be created vs. linked to existing targets
548
+ * - How to find/select target nodes (via `search`)
549
+ * - What edge property values to set (exact or auto-extracted)
550
+ * - When to apply the constraint (conditional with logical operators)
551
+ * - Filter by source/target node types
552
+ *
553
+ * **The `search` field** handles target node selection:
554
+ *
555
+ * - Uses SearchConfig to define how to find existing target nodes
556
+ * - Example: `{"properties": [{"name": "name", "mode": "semantic"}]}`
557
+ * - For controlled vocabulary: find existing target, don't create new
558
+ *
559
+ * **The `set` field** controls edge property values:
560
+ *
561
+ * - Exact value: `{"weight": 1.0}` - sets exact value
562
+ * - Auto-extract: `{"reason": {"mode": "auto"}}` - LLM extracts from content
563
+ *
564
+ * **The `when` field** supports logical operators (same as NodeConstraint):
565
+ *
566
+ * - Simple: `{"severity": "high"}`
567
+ * - AND: `{"_and": [{"severity": "high"}, {"confirmed": true}]}`
568
+ * - OR: `{"_or": [{"type": "MITIGATES"}, {"type": "PREVENTS"}]}`
569
+ * - NOT: `{"_not": {"status": "deprecated"}}`
570
+ */
571
+ constraint?: RelationshipTypes.Constraint | null;
201
572
  description?: string | null;
573
+ /**
574
+ * DEPRECATED: Use resolution_policy='lookup' instead. Shorthand for constraint
575
+ * with create='lookup'. When True, only links to existing target nodes (controlled
576
+ * vocabulary). Equivalent to @lookup decorator. If constraint is also provided,
577
+ * link_only=True will override constraint.create to 'lookup'.
578
+ */
579
+ link_only?: boolean;
202
580
  properties?: {
203
- [key: string]: RelationshipTypes.Properties;
581
+ [key: string]: SchemasAPI.PropertyDefinition;
204
582
  };
583
+ /**
584
+ * Shorthand for constraint.create. 'upsert': Create target if not found (default).
585
+ * 'lookup': Only link to existing targets (controlled vocabulary). Equivalent to
586
+ * @upsert/@lookup decorators. If constraint is also provided, resolution_policy
587
+ * will set constraint.create accordingly.
588
+ */
589
+ resolution_policy?: 'upsert' | 'lookup';
205
590
  }
206
591
  namespace RelationshipTypes {
207
592
  /**
208
- * Property definition for nodes/relationships
593
+ * Policy for how edges/relationships of a specific type should be handled.
594
+ *
595
+ * Used in two places:
596
+ *
597
+ * 1. **Schema level**: Inside `UserRelationshipType.constraint` - `edge_type` is
598
+ * implicit from parent
599
+ * 2. **Memory level**: In `memory_policy.edge_constraints[]` - `edge_type` is
600
+ * required
601
+ *
602
+ * Edge constraints allow developers to control:
603
+ *
604
+ * - Which edge types can be created vs. linked to existing targets
605
+ * - How to find/select target nodes (via `search`)
606
+ * - What edge property values to set (exact or auto-extracted)
607
+ * - When to apply the constraint (conditional with logical operators)
608
+ * - Filter by source/target node types
609
+ *
610
+ * **The `search` field** handles target node selection:
611
+ *
612
+ * - Uses SearchConfig to define how to find existing target nodes
613
+ * - Example: `{"properties": [{"name": "name", "mode": "semantic"}]}`
614
+ * - For controlled vocabulary: find existing target, don't create new
615
+ *
616
+ * **The `set` field** controls edge property values:
617
+ *
618
+ * - Exact value: `{"weight": 1.0}` - sets exact value
619
+ * - Auto-extract: `{"reason": {"mode": "auto"}}` - LLM extracts from content
620
+ *
621
+ * **The `when` field** supports logical operators (same as NodeConstraint):
622
+ *
623
+ * - Simple: `{"severity": "high"}`
624
+ * - AND: `{"_and": [{"severity": "high"}, {"confirmed": true}]}`
625
+ * - OR: `{"_or": [{"type": "MITIGATES"}, {"type": "PREVENTS"}]}`
626
+ * - NOT: `{"_not": {"status": "deprecated"}}`
209
627
  */
210
- interface Properties {
211
- type: 'string' | 'integer' | 'float' | 'boolean' | 'array' | 'datetime' | 'object';
212
- default?: unknown;
213
- description?: string | null;
628
+ interface Constraint {
629
+ /**
630
+ * 'upsert': Create target node if not found via search (default). 'lookup': Only
631
+ * link to existing target nodes (controlled vocabulary). When 'lookup', edges to
632
+ * non-existing targets are skipped. Deprecated aliases: 'auto' -> 'upsert',
633
+ * 'never' -> 'lookup'.
634
+ */
635
+ create?: 'upsert' | 'lookup' | 'auto' | 'never';
636
+ /**
637
+ * Direction of edges this constraint applies to. 'outgoing': edges where current
638
+ * node is source (default). 'incoming': edges where current node is target.
639
+ * 'both': applies in either direction.
640
+ */
641
+ direction?: 'outgoing' | 'incoming' | 'both';
642
+ /**
643
+ * Edge/relationship type this constraint applies to (e.g., 'MITIGATES',
644
+ * 'ASSIGNED_TO'). Optional at schema level (implicit from parent
645
+ * UserRelationshipType), required at memory level (in
646
+ * memory_policy.edge_constraints).
647
+ */
648
+ edge_type?: string | null;
649
+ /**
650
+ * DEPRECATED: Use create='lookup' instead. Shorthand for create='lookup'. When
651
+ * True, only links to existing target nodes. Equivalent to @lookup decorator in
652
+ * schema definitions.
653
+ */
654
+ link_only?: boolean;
214
655
  /**
215
- * List of allowed enum values (max 10)
656
+ * Explicit behavior when no target match found via search. 'create': create new
657
+ * target node (same as upsert). 'ignore': skip edge creation (same as lookup).
658
+ * 'error': raise error if target not found. If specified, overrides 'create'
659
+ * field.
216
660
  */
217
- enum_values?: Array<string> | null;
218
- max_length?: number | null;
219
- max_value?: number | null;
220
- min_length?: number | null;
221
- min_value?: number | null;
222
- pattern?: string | null;
223
- required?: boolean;
661
+ on_miss?: 'create' | 'ignore' | 'error' | null;
662
+ /**
663
+ * Configuration for finding/selecting existing nodes.
664
+ *
665
+ * Defines which properties to match on and how, in priority order. The first
666
+ * matching property wins.
667
+ *
668
+ * **String Shorthand** (simple cases - converts to exact match):
669
+ * SearchConfig(properties=["id", "email"]) # Equivalent to:
670
+ * SearchConfig(properties=[PropertyMatch.exact("id"),
671
+ * PropertyMatch.exact("email")])
672
+ *
673
+ * **Mixed Form** (combine strings and PropertyMatch): SearchConfig(properties=[
674
+ * "id", # String -> exact match PropertyMatch.semantic("title", 0.9) # Full
675
+ * control ])
676
+ *
677
+ * **Full Form** (maximum control): SearchConfig(properties=[
678
+ * PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
679
+ * mode="semantic", threshold=0.85) ])
680
+ *
681
+ * **To select a specific node by ID**:
682
+ * SearchConfig(properties=[PropertyMatch.exact("id", "TASK-123")])
683
+ */
684
+ search?: SchemasAPI.SearchConfigOutput | null;
685
+ /**
686
+ * Set property values on edges. Supports: 1. Exact value: {'weight': 1.0} - sets
687
+ * exact value. 2. Auto-extract: {'reason': {'mode': 'auto'}} - LLM extracts from
688
+ * content. Edge properties are useful for relationship metadata (weight,
689
+ * timestamp, reason, etc.).
690
+ */
691
+ set?: {
692
+ [key: string]: string | number | boolean | Array<unknown> | {
693
+ [key: string]: unknown;
694
+ } | Shared.PropertyValue;
695
+ } | null;
696
+ /**
697
+ * Filter: only apply when source node is of this type. Example:
698
+ * source_type='SecurityBehavior' - only applies to edges from SecurityBehavior
699
+ * nodes.
700
+ */
701
+ source_type?: string | null;
702
+ /**
703
+ * Filter: only apply when target node is of this type. Example:
704
+ * target_type='TacticDef' - only applies to edges targeting TacticDef nodes.
705
+ */
706
+ target_type?: string | null;
707
+ /**
708
+ * Condition for when this constraint applies. Supports logical operators: '\_and',
709
+ * '\_or', '\_not'. Applied to edge properties or context. Example: {'\_and':
710
+ * [{'severity': 'high'}, {'_not': {'status': 'deprecated'}}]}
711
+ */
712
+ when?: {
713
+ [key: string]: unknown;
714
+ } | null;
224
715
  }
225
716
  }
226
717
  }
@@ -278,11 +769,40 @@ export interface SchemaCreateParams {
278
769
  description?: string | null;
279
770
  last_used_at?: string | null;
280
771
  /**
281
- * Custom node types (max 15 per schema)
772
+ * Default memory policy for memories using this schema. Includes mode ('auto',
773
+ * 'manual'), node_constraints (applied in auto mode when present), and OMO safety
774
+ * settings (consent, risk). Memory-level policies override schema-level.
775
+ */
776
+ memory_policy?: {
777
+ [key: string]: unknown;
778
+ } | null;
779
+ /**
780
+ * @deprecated DEPRECATED: Use 'namespace_id' instead. Accepts Parse pointer or
781
+ * objectId.
782
+ */
783
+ namespace?: string | {
784
+ [key: string]: unknown;
785
+ } | null;
786
+ /**
787
+ * Namespace ID this schema belongs to. Accepts legacy 'namespace' alias.
788
+ */
789
+ namespace_id?: string | null;
790
+ /**
791
+ * Custom node types (max 10 per schema)
282
792
  */
283
793
  node_types?: {
284
794
  [key: string]: SchemaCreateParams.NodeTypes;
285
795
  };
796
+ /**
797
+ * @deprecated DEPRECATED: Use 'organization_id' instead. Accepts Parse pointer or
798
+ * objectId.
799
+ */
800
+ organization?: string | {
801
+ [key: string]: unknown;
802
+ } | null;
803
+ /**
804
+ * Organization ID this schema belongs to. Accepts legacy 'organization' alias.
805
+ */
286
806
  organization_id?: string | null;
287
807
  read_access?: Array<string>;
288
808
  /**
@@ -291,7 +811,10 @@ export interface SchemaCreateParams {
291
811
  relationship_types?: {
292
812
  [key: string]: SchemaCreateParams.RelationshipTypes;
293
813
  };
294
- scope?: 'personal' | 'workspace' | 'organization';
814
+ /**
815
+ * Schema scopes available through the API
816
+ */
817
+ scope?: 'personal' | 'workspace' | 'namespace' | 'organization';
295
818
  status?: 'draft' | 'active' | 'deprecated' | 'archived';
296
819
  updated_at?: string | null;
297
820
  usage_count?: number;
@@ -306,49 +829,115 @@ export interface SchemaCreateParams {
306
829
  }
307
830
  export declare namespace SchemaCreateParams {
308
831
  /**
309
- * User-defined node type
832
+ * User-defined node type with optional inline constraint.
833
+ *
834
+ * The `constraint` field allows defining default matching/creation behavior
835
+ * directly within the node type definition. This replaces the need to put
836
+ * constraints only in memory_policy.node_constraints.
837
+ *
838
+ * Schema-level constraints:
839
+ *
840
+ * - `node_type` is implicit (taken from parent UserNodeType.name)
841
+ * - Defines default matching strategy via `search.properties`
842
+ * - Can be overridden per-memory via memory_policy.node_constraints
843
+ *
844
+ * Example: UserNodeType( name="Task", label="Task", properties={ "id":
845
+ * PropertyDefinition(type="string"), "title": PropertyDefinition(type="string",
846
+ * required=True) }, constraint=NodeConstraint( search=SearchConfig(properties=[
847
+ * PropertyMatch(name="id", mode="exact"), PropertyMatch(name="title",
848
+ * mode="semantic", threshold=0.85) ]), create="auto" ) )
310
849
  */
311
850
  interface NodeTypes {
312
851
  label: string;
313
852
  name: string;
314
853
  color?: string | null;
854
+ /**
855
+ * Policy for how nodes of a specific type should be handled.
856
+ *
857
+ * Used in two places:
858
+ *
859
+ * 1. **Schema level**: Inside `UserNodeType.constraint` - `node_type` is implicit
860
+ * from parent
861
+ * 2. **Memory level**: In `memory_policy.node_constraints[]` - `node_type` is
862
+ * required
863
+ *
864
+ * Node constraints allow developers to control:
865
+ *
866
+ * - Which node types can be created vs. linked
867
+ * - How to find/select existing nodes (via `search`)
868
+ * - What property values to set (exact or auto-extracted)
869
+ * - When to apply the constraint (conditional with logical operators)
870
+ *
871
+ * **The `search` field** handles node selection:
872
+ *
873
+ * - Uses PropertyMatch list to define unique identifiers and matching strategy
874
+ * - Example:
875
+ * `{"properties": [{"name": "id", "mode": "exact"}, {"name": "title", "mode": "semantic"}]}`
876
+ * - For direct selection, use PropertyMatch with value:
877
+ * `{"name": "id", "mode": "exact", "value": "proj_123"}`
878
+ *
879
+ * **The `set` field** controls property values:
880
+ *
881
+ * - Exact value: `{"status": "done"}` - sets exact value
882
+ * - Auto-extract: `{"status": {"mode": "auto"}}` - LLM extracts from content
883
+ *
884
+ * **The `when` field** supports logical operators:
885
+ *
886
+ * - Simple: `{"priority": "high"}`
887
+ * - AND: `{"_and": [{"priority": "high"}, {"status": "active"}]}`
888
+ * - OR: `{"_or": [{"status": "active"}, {"status": "pending"}]}`
889
+ * - NOT: `{"_not": {"status": "completed"}}`
890
+ * - Complex:
891
+ * `{"_and": [{"priority": "high"}, {"_or": [{"status": "active"}, {"urgent": true}]}]}`
892
+ */
893
+ constraint?: Shared.NodeConstraintInput | null;
315
894
  description?: string | null;
316
895
  icon?: string | null;
317
896
  /**
318
- * Node properties (max 15 per node type)
897
+ * DEPRECATED: Use resolution_policy='lookup' instead. Shorthand for constraint
898
+ * with create='lookup'. When True, only links to existing nodes (controlled
899
+ * vocabulary). Equivalent to @lookup decorator. If constraint is also provided,
900
+ * link_only=True will override constraint.create to 'lookup'.
901
+ */
902
+ link_only?: boolean;
903
+ /**
904
+ * Node properties (max 10 per node type)
319
905
  */
320
906
  properties?: {
321
- [key: string]: NodeTypes.Properties;
907
+ [key: string]: SchemasAPI.PropertyDefinition;
322
908
  };
323
909
  required_properties?: Array<string>;
324
910
  /**
325
- * Properties that uniquely identify this node type. Used for MERGE operations to
326
- * avoid duplicates. Example: ['name', 'email'] for Customer nodes.
911
+ * Shorthand for constraint.create. 'upsert': Create if not found (default).
912
+ * 'lookup': Only link to existing nodes (controlled vocabulary). Equivalent to
913
+ * @upsert/@lookup decorators. If constraint is also provided, resolution_policy
914
+ * will set constraint.create accordingly.
327
915
  */
328
- unique_identifiers?: Array<string>;
329
- }
330
- namespace NodeTypes {
916
+ resolution_policy?: 'upsert' | 'lookup';
331
917
  /**
332
- * Property definition for nodes/relationships
918
+ * DEPRECATED: Use 'constraint.search.properties' instead. Properties that uniquely
919
+ * identify this node type. Example: ['name', 'email'] for Customer nodes.
333
920
  */
334
- interface Properties {
335
- type: 'string' | 'integer' | 'float' | 'boolean' | 'array' | 'datetime' | 'object';
336
- default?: unknown;
337
- description?: string | null;
338
- /**
339
- * List of allowed enum values (max 10)
340
- */
341
- enum_values?: Array<string> | null;
342
- max_length?: number | null;
343
- max_value?: number | null;
344
- min_length?: number | null;
345
- min_value?: number | null;
346
- pattern?: string | null;
347
- required?: boolean;
348
- }
921
+ unique_identifiers?: Array<string>;
349
922
  }
350
923
  /**
351
- * User-defined relationship type
924
+ * User-defined relationship type with optional inline constraint.
925
+ *
926
+ * The `constraint` field allows defining default matching/creation behavior
927
+ * directly within the relationship type definition. This mirrors the pattern used
928
+ * in UserNodeType.constraint for nodes.
929
+ *
930
+ * Schema-level edge constraints:
931
+ *
932
+ * - `edge_type` is implicit (taken from parent UserRelationshipType.name)
933
+ * - Defines default target node matching strategy via `search.properties`
934
+ * - Can be overridden per-memory via memory_policy.edge_constraints
935
+ *
936
+ * Example: UserRelationshipType( name="MITIGATES", label="Mitigates",
937
+ * allowed_source_types=["SecurityBehavior"], allowed_target_types=["TacticDef"],
938
+ * constraint=EdgeConstraint( search=SearchConfig(properties=[
939
+ * PropertyMatch(name="name", mode="semantic", threshold=0.90) ]), create="never" #
940
+ * Controlled vocabulary - only link to existing targets ) )
352
941
  */
353
942
  interface RelationshipTypes {
354
943
  allowed_source_types: Array<string>;
@@ -357,30 +946,61 @@ export declare namespace SchemaCreateParams {
357
946
  name: string;
358
947
  cardinality?: 'one-to-one' | 'one-to-many' | 'many-to-many';
359
948
  color?: string | null;
949
+ /**
950
+ * Policy for how edges/relationships of a specific type should be handled.
951
+ *
952
+ * Used in two places:
953
+ *
954
+ * 1. **Schema level**: Inside `UserRelationshipType.constraint` - `edge_type` is
955
+ * implicit from parent
956
+ * 2. **Memory level**: In `memory_policy.edge_constraints[]` - `edge_type` is
957
+ * required
958
+ *
959
+ * Edge constraints allow developers to control:
960
+ *
961
+ * - Which edge types can be created vs. linked to existing targets
962
+ * - How to find/select target nodes (via `search`)
963
+ * - What edge property values to set (exact or auto-extracted)
964
+ * - When to apply the constraint (conditional with logical operators)
965
+ * - Filter by source/target node types
966
+ *
967
+ * **The `search` field** handles target node selection:
968
+ *
969
+ * - Uses SearchConfig to define how to find existing target nodes
970
+ * - Example: `{"properties": [{"name": "name", "mode": "semantic"}]}`
971
+ * - For controlled vocabulary: find existing target, don't create new
972
+ *
973
+ * **The `set` field** controls edge property values:
974
+ *
975
+ * - Exact value: `{"weight": 1.0}` - sets exact value
976
+ * - Auto-extract: `{"reason": {"mode": "auto"}}` - LLM extracts from content
977
+ *
978
+ * **The `when` field** supports logical operators (same as NodeConstraint):
979
+ *
980
+ * - Simple: `{"severity": "high"}`
981
+ * - AND: `{"_and": [{"severity": "high"}, {"confirmed": true}]}`
982
+ * - OR: `{"_or": [{"type": "MITIGATES"}, {"type": "PREVENTS"}]}`
983
+ * - NOT: `{"_not": {"status": "deprecated"}}`
984
+ */
985
+ constraint?: Shared.EdgeConstraintInput | null;
360
986
  description?: string | null;
987
+ /**
988
+ * DEPRECATED: Use resolution_policy='lookup' instead. Shorthand for constraint
989
+ * with create='lookup'. When True, only links to existing target nodes (controlled
990
+ * vocabulary). Equivalent to @lookup decorator. If constraint is also provided,
991
+ * link_only=True will override constraint.create to 'lookup'.
992
+ */
993
+ link_only?: boolean;
361
994
  properties?: {
362
- [key: string]: RelationshipTypes.Properties;
995
+ [key: string]: SchemasAPI.PropertyDefinition;
363
996
  };
364
- }
365
- namespace RelationshipTypes {
366
997
  /**
367
- * Property definition for nodes/relationships
998
+ * Shorthand for constraint.create. 'upsert': Create target if not found (default).
999
+ * 'lookup': Only link to existing targets (controlled vocabulary). Equivalent to
1000
+ * @upsert/@lookup decorators. If constraint is also provided, resolution_policy
1001
+ * will set constraint.create accordingly.
368
1002
  */
369
- interface Properties {
370
- type: 'string' | 'integer' | 'float' | 'boolean' | 'array' | 'datetime' | 'object';
371
- default?: unknown;
372
- description?: string | null;
373
- /**
374
- * List of allowed enum values (max 10)
375
- */
376
- enum_values?: Array<string> | null;
377
- max_length?: number | null;
378
- max_value?: number | null;
379
- min_length?: number | null;
380
- min_value?: number | null;
381
- pattern?: string | null;
382
- required?: boolean;
383
- }
1003
+ resolution_policy?: 'upsert' | 'lookup';
384
1004
  }
385
1005
  }
386
1006
  export interface SchemaUpdateParams {
@@ -399,6 +1019,6 @@ export interface SchemaListParams {
399
1019
  workspace_id?: string | null;
400
1020
  }
401
1021
  export declare namespace Schemas {
402
- export { type UserGraphSchemaOutput as UserGraphSchemaOutput, type SchemaCreateResponse as SchemaCreateResponse, type SchemaRetrieveResponse as SchemaRetrieveResponse, type SchemaUpdateResponse as SchemaUpdateResponse, type SchemaListResponse as SchemaListResponse, type SchemaDeleteResponse as SchemaDeleteResponse, type SchemaCreateParams as SchemaCreateParams, type SchemaUpdateParams as SchemaUpdateParams, type SchemaListParams as SchemaListParams, };
1022
+ export { type PropertyDefinition as PropertyDefinition, type SearchConfigOutput as SearchConfigOutput, type UserGraphSchemaOutput as UserGraphSchemaOutput, type SchemaCreateResponse as SchemaCreateResponse, type SchemaRetrieveResponse as SchemaRetrieveResponse, type SchemaUpdateResponse as SchemaUpdateResponse, type SchemaListResponse as SchemaListResponse, type SchemaDeleteResponse as SchemaDeleteResponse, type SchemaCreateParams as SchemaCreateParams, type SchemaUpdateParams as SchemaUpdateParams, type SchemaListParams as SchemaListParams, };
403
1023
  }
404
1024
  //# sourceMappingURL=schemas.d.ts.map