@subcortex-ai/sdk 0.1.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/LICENSE +191 -0
- package/README.md +259 -0
- package/dist/index.cjs +1694 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1447 -0
- package/dist/index.d.ts +1447 -0
- package/dist/index.js +1622 -0
- package/dist/index.js.map +1 -0
- package/package.json +66 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1447 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Transport Layer
|
|
3
|
+
*
|
|
4
|
+
* Handles fetch calls, auth headers, retry with backoff,
|
|
5
|
+
* timeout, request IDs, and snake_case ↔ camelCase mapping.
|
|
6
|
+
*
|
|
7
|
+
* This module is internal — consumers use SubCortexClient, not HttpTransport.
|
|
8
|
+
*/
|
|
9
|
+
interface RetryConfig {
|
|
10
|
+
maxRetries: number;
|
|
11
|
+
baseDelayMs: number;
|
|
12
|
+
maxDelayMs: number;
|
|
13
|
+
}
|
|
14
|
+
interface HttpTransportOptions {
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
tenantId: string;
|
|
17
|
+
apiKey?: string;
|
|
18
|
+
token?: string;
|
|
19
|
+
retry: RetryConfig;
|
|
20
|
+
timeoutMs: number;
|
|
21
|
+
fetchImpl: typeof fetch;
|
|
22
|
+
headers: Record<string, string>;
|
|
23
|
+
signal?: AbortSignal;
|
|
24
|
+
}
|
|
25
|
+
declare class HttpTransport {
|
|
26
|
+
private readonly opts;
|
|
27
|
+
constructor(options: HttpTransportOptions);
|
|
28
|
+
/** GET request with retry and typed response. */
|
|
29
|
+
get<T>(path: string, tenantId?: string): Promise<T>;
|
|
30
|
+
/** POST request with retry and typed response. */
|
|
31
|
+
post<T>(path: string, body: unknown, tenantId?: string): Promise<T>;
|
|
32
|
+
/** PUT request with retry and typed response. */
|
|
33
|
+
put<T>(path: string, body: unknown, tenantId?: string): Promise<T>;
|
|
34
|
+
/** DELETE request with retry and typed response. */
|
|
35
|
+
delete<T>(path: string, tenantId?: string): Promise<T>;
|
|
36
|
+
/** Core request method with retry loop. */
|
|
37
|
+
private request;
|
|
38
|
+
/** Fetch with AbortController timeout. */
|
|
39
|
+
private fetchWithTimeout;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Shared types used across the Cortex SDK.
|
|
44
|
+
*/
|
|
45
|
+
/** Paginated response wrapper. */
|
|
46
|
+
interface PaginatedResponse<T> {
|
|
47
|
+
data: T[];
|
|
48
|
+
nextPageToken?: string;
|
|
49
|
+
totalCount?: number;
|
|
50
|
+
}
|
|
51
|
+
/** Result of a batch operation. */
|
|
52
|
+
interface BatchResult<T> {
|
|
53
|
+
succeeded: T[];
|
|
54
|
+
errors: Array<{
|
|
55
|
+
index: number;
|
|
56
|
+
message: string;
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
59
|
+
/** Confidence score for an assertion or relationship. */
|
|
60
|
+
interface ConfidenceScore {
|
|
61
|
+
value: number;
|
|
62
|
+
method?: 'EXPLICIT' | 'SOURCE_DEFAULT' | 'CONSENSUS' | 'MODEL_REPORTED' | 'TEMPORAL_DECAY';
|
|
63
|
+
modelConfidence?: number;
|
|
64
|
+
}
|
|
65
|
+
/** Bi-temporal bounds: when a fact is true vs when it was recorded. */
|
|
66
|
+
interface TemporalBounds {
|
|
67
|
+
validFrom: string;
|
|
68
|
+
validUntil?: string;
|
|
69
|
+
transactionTime: string;
|
|
70
|
+
}
|
|
71
|
+
/** Provenance — where an assertion came from. */
|
|
72
|
+
interface Provenance {
|
|
73
|
+
sourceId: string;
|
|
74
|
+
sourceType: 'HUMAN' | 'SYSTEM' | 'AI_AGENT' | 'IMPORT' | 'DERIVED' | 'SENSOR';
|
|
75
|
+
sourceLabel: string;
|
|
76
|
+
sourceTimestamp: string;
|
|
77
|
+
derivedFrom: string[];
|
|
78
|
+
derivationMethod?: string;
|
|
79
|
+
metadata: Record<string, string>;
|
|
80
|
+
}
|
|
81
|
+
/** Health check response. */
|
|
82
|
+
interface HealthResponse {
|
|
83
|
+
status: string;
|
|
84
|
+
version: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* SubCortex Built-in Schema
|
|
89
|
+
*
|
|
90
|
+
* These are the foundational types, predicates, relationship types,
|
|
91
|
+
* and confidence levels that SubCortex supports natively. They are
|
|
92
|
+
* NOT exhaustive — tenants can extend them. But these cover the
|
|
93
|
+
* universal patterns every agent-user interaction needs.
|
|
94
|
+
*
|
|
95
|
+
* Consumer systems import these instead of using raw strings.
|
|
96
|
+
*/
|
|
97
|
+
/**
|
|
98
|
+
* Well-known subject prefixes. SubCortex recognizes these and
|
|
99
|
+
* provides specialized behavior for each.
|
|
100
|
+
*/
|
|
101
|
+
declare enum SubjectPrefix {
|
|
102
|
+
/** The authenticated user interacting with the agent */
|
|
103
|
+
USER = "user",
|
|
104
|
+
/** A person mentioned by the user (not the user themselves) */
|
|
105
|
+
PERSON = "person",
|
|
106
|
+
/** A job role or position */
|
|
107
|
+
ROLE = "role",
|
|
108
|
+
/** A business entity / data model (e.g., Project, Invoice) */
|
|
109
|
+
ENTITY = "entity",
|
|
110
|
+
/** A property/field on an entity */
|
|
111
|
+
PROPERTY = "property",
|
|
112
|
+
/** A project, initiative, or ongoing effort */
|
|
113
|
+
PROJECT = "project",
|
|
114
|
+
/** An event, meeting, or milestone */
|
|
115
|
+
EVENT = "event",
|
|
116
|
+
/** An agent using SubCortex */
|
|
117
|
+
AGENT = "agent"
|
|
118
|
+
}
|
|
119
|
+
declare function subject(prefix: SubjectPrefix | string, identifier: string): string;
|
|
120
|
+
/**
|
|
121
|
+
* Built-in predicates for user/person identity and profile.
|
|
122
|
+
*/
|
|
123
|
+
declare enum IdentityPredicate {
|
|
124
|
+
NAME = "name",
|
|
125
|
+
FULL_NAME = "full_name",
|
|
126
|
+
ROLE = "role",
|
|
127
|
+
TITLE = "title",
|
|
128
|
+
DEPARTMENT = "department",
|
|
129
|
+
TEAM = "team",
|
|
130
|
+
START_DATE = "start_date",
|
|
131
|
+
EMAIL = "email"
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Built-in predicates for work context.
|
|
135
|
+
* NOTE: Org relationships (reports_to, manages, etc.) are NOT predicates.
|
|
136
|
+
* They are relationship types — connections between two subjects.
|
|
137
|
+
* See OrgRelationship enum.
|
|
138
|
+
*/
|
|
139
|
+
declare enum WorkPredicate {
|
|
140
|
+
EXPERTISE = "expertise",
|
|
141
|
+
CURRENT_PROJECT = "current_project",
|
|
142
|
+
PAIN_POINT = "pain_point"
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Built-in predicates for events and status tracking.
|
|
146
|
+
*/
|
|
147
|
+
declare enum EventPredicate {
|
|
148
|
+
STATUS = "status",
|
|
149
|
+
STATUS_CHANGE = "status_change",
|
|
150
|
+
EVENT = "event",
|
|
151
|
+
DECISION = "decision",
|
|
152
|
+
OUTCOME = "outcome"
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Built-in predicates for emotional/rapport tracking.
|
|
156
|
+
*/
|
|
157
|
+
declare enum RapportPredicate {
|
|
158
|
+
SENTIMENT = "sentiment",
|
|
159
|
+
FRUSTRATION = "frustration",
|
|
160
|
+
EXCITEMENT = "excitement",
|
|
161
|
+
CONCERN = "concern",
|
|
162
|
+
GOAL = "goal",
|
|
163
|
+
ASPIRATION = "aspiration",
|
|
164
|
+
PREFERENCE = "preference",
|
|
165
|
+
PAIN_POINT = "pain_point",
|
|
166
|
+
INTEREST = "interest",
|
|
167
|
+
COMMUNICATION_STYLE = "communication_style"
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Built-in predicates for agent memory management.
|
|
171
|
+
*/
|
|
172
|
+
declare enum MemoryPredicate {
|
|
173
|
+
REMINDER = "reminder",
|
|
174
|
+
CONTEXT = "context",
|
|
175
|
+
CONTEXT_TASK = "context:task",
|
|
176
|
+
CURRENT_PROJECT = "current_project"
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Built-in predicates for entity/schema definition.
|
|
180
|
+
*/
|
|
181
|
+
declare enum EntityPredicate {
|
|
182
|
+
TYPE = "type",
|
|
183
|
+
DESCRIPTION = "description",
|
|
184
|
+
FIELD_TYPE = "field_type",
|
|
185
|
+
REQUIRED = "required",
|
|
186
|
+
WORKFLOW = "workflow"
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* All built-in predicates combined.
|
|
190
|
+
* Consumer systems should use these instead of raw strings.
|
|
191
|
+
*/
|
|
192
|
+
declare const Predicates: {
|
|
193
|
+
readonly TYPE: EntityPredicate.TYPE;
|
|
194
|
+
readonly DESCRIPTION: EntityPredicate.DESCRIPTION;
|
|
195
|
+
readonly FIELD_TYPE: EntityPredicate.FIELD_TYPE;
|
|
196
|
+
readonly REQUIRED: EntityPredicate.REQUIRED;
|
|
197
|
+
readonly WORKFLOW: EntityPredicate.WORKFLOW;
|
|
198
|
+
readonly REMINDER: MemoryPredicate.REMINDER;
|
|
199
|
+
readonly CONTEXT: MemoryPredicate.CONTEXT;
|
|
200
|
+
readonly CONTEXT_TASK: MemoryPredicate.CONTEXT_TASK;
|
|
201
|
+
readonly CURRENT_PROJECT: MemoryPredicate.CURRENT_PROJECT;
|
|
202
|
+
readonly SENTIMENT: RapportPredicate.SENTIMENT;
|
|
203
|
+
readonly FRUSTRATION: RapportPredicate.FRUSTRATION;
|
|
204
|
+
readonly EXCITEMENT: RapportPredicate.EXCITEMENT;
|
|
205
|
+
readonly CONCERN: RapportPredicate.CONCERN;
|
|
206
|
+
readonly GOAL: RapportPredicate.GOAL;
|
|
207
|
+
readonly ASPIRATION: RapportPredicate.ASPIRATION;
|
|
208
|
+
readonly PREFERENCE: RapportPredicate.PREFERENCE;
|
|
209
|
+
readonly PAIN_POINT: RapportPredicate.PAIN_POINT;
|
|
210
|
+
readonly INTEREST: RapportPredicate.INTEREST;
|
|
211
|
+
readonly COMMUNICATION_STYLE: RapportPredicate.COMMUNICATION_STYLE;
|
|
212
|
+
readonly STATUS: EventPredicate.STATUS;
|
|
213
|
+
readonly STATUS_CHANGE: EventPredicate.STATUS_CHANGE;
|
|
214
|
+
readonly EVENT: EventPredicate.EVENT;
|
|
215
|
+
readonly DECISION: EventPredicate.DECISION;
|
|
216
|
+
readonly OUTCOME: EventPredicate.OUTCOME;
|
|
217
|
+
readonly EXPERTISE: WorkPredicate.EXPERTISE;
|
|
218
|
+
readonly NAME: IdentityPredicate.NAME;
|
|
219
|
+
readonly FULL_NAME: IdentityPredicate.FULL_NAME;
|
|
220
|
+
readonly ROLE: IdentityPredicate.ROLE;
|
|
221
|
+
readonly TITLE: IdentityPredicate.TITLE;
|
|
222
|
+
readonly DEPARTMENT: IdentityPredicate.DEPARTMENT;
|
|
223
|
+
readonly TEAM: IdentityPredicate.TEAM;
|
|
224
|
+
readonly START_DATE: IdentityPredicate.START_DATE;
|
|
225
|
+
readonly EMAIL: IdentityPredicate.EMAIL;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Built-in relationship types for organizational structure.
|
|
229
|
+
*
|
|
230
|
+
* Each relationship is directional. Many have a natural reverse:
|
|
231
|
+
* reports_to ↔ manages
|
|
232
|
+
* mentored_by ↔ mentors
|
|
233
|
+
* member_of ↔ has_member
|
|
234
|
+
*/
|
|
235
|
+
declare enum OrgRelationship {
|
|
236
|
+
/** Person reports to user/manager */
|
|
237
|
+
REPORTS_TO = "reports_to",
|
|
238
|
+
/** User/manager manages person */
|
|
239
|
+
MANAGES = "manages",
|
|
240
|
+
/** Person is member of team/project */
|
|
241
|
+
MEMBER_OF = "member_of",
|
|
242
|
+
/** Team/project has this person as member */
|
|
243
|
+
HAS_MEMBER = "has_member",
|
|
244
|
+
/** Person holds a specific role */
|
|
245
|
+
HOLDS_ROLE = "holds_role",
|
|
246
|
+
/** Person is a candidate for a role */
|
|
247
|
+
CANDIDATE_FOR = "candidate_for",
|
|
248
|
+
/** Person collaborates with another person */
|
|
249
|
+
COLLABORATES_WITH = "collaborates_with",
|
|
250
|
+
/** Person mentors another person */
|
|
251
|
+
MENTORS = "mentors",
|
|
252
|
+
/** Person is mentored by another person */
|
|
253
|
+
MENTORED_BY = "mentored_by",
|
|
254
|
+
/** Person is a stakeholder in something */
|
|
255
|
+
STAKEHOLDER_IN = "stakeholder_in"
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Built-in relationship types for entity/schema structure.
|
|
259
|
+
*/
|
|
260
|
+
declare enum EntityRelationship {
|
|
261
|
+
HAS_PROPERTY = "has_property",
|
|
262
|
+
BELONGS_TO = "belongs_to",
|
|
263
|
+
HAS_MANY = "has_many",
|
|
264
|
+
MANY_TO_MANY = "many_to_many",
|
|
265
|
+
DEPENDS_ON = "depends_on"
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* All built-in relationship types combined.
|
|
269
|
+
*/
|
|
270
|
+
declare const RelationshipTypes: {
|
|
271
|
+
readonly HAS_PROPERTY: EntityRelationship.HAS_PROPERTY;
|
|
272
|
+
readonly BELONGS_TO: EntityRelationship.BELONGS_TO;
|
|
273
|
+
readonly HAS_MANY: EntityRelationship.HAS_MANY;
|
|
274
|
+
readonly MANY_TO_MANY: EntityRelationship.MANY_TO_MANY;
|
|
275
|
+
readonly DEPENDS_ON: EntityRelationship.DEPENDS_ON;
|
|
276
|
+
/** Person reports to user/manager */
|
|
277
|
+
readonly REPORTS_TO: OrgRelationship.REPORTS_TO;
|
|
278
|
+
/** User/manager manages person */
|
|
279
|
+
readonly MANAGES: OrgRelationship.MANAGES;
|
|
280
|
+
/** Person is member of team/project */
|
|
281
|
+
readonly MEMBER_OF: OrgRelationship.MEMBER_OF;
|
|
282
|
+
/** Team/project has this person as member */
|
|
283
|
+
readonly HAS_MEMBER: OrgRelationship.HAS_MEMBER;
|
|
284
|
+
/** Person holds a specific role */
|
|
285
|
+
readonly HOLDS_ROLE: OrgRelationship.HOLDS_ROLE;
|
|
286
|
+
/** Person is a candidate for a role */
|
|
287
|
+
readonly CANDIDATE_FOR: OrgRelationship.CANDIDATE_FOR;
|
|
288
|
+
/** Person collaborates with another person */
|
|
289
|
+
readonly COLLABORATES_WITH: OrgRelationship.COLLABORATES_WITH;
|
|
290
|
+
/** Person mentors another person */
|
|
291
|
+
readonly MENTORS: OrgRelationship.MENTORS;
|
|
292
|
+
/** Person is mentored by another person */
|
|
293
|
+
readonly MENTORED_BY: OrgRelationship.MENTORED_BY;
|
|
294
|
+
/** Person is a stakeholder in something */
|
|
295
|
+
readonly STAKEHOLDER_IN: OrgRelationship.STAKEHOLDER_IN;
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Standard confidence levels with numeric values.
|
|
299
|
+
* The agent chooses the level; SubCortex maps to the score.
|
|
300
|
+
*/
|
|
301
|
+
declare enum ConfidenceLevel {
|
|
302
|
+
/** User stated it directly: "My name is Alice" */
|
|
303
|
+
CONFIRMED = "confirmed",
|
|
304
|
+
/** Strongly implied: "I've been managing the team" → manager */
|
|
305
|
+
HIGH = "high",
|
|
306
|
+
/** Reasonable inference from context */
|
|
307
|
+
MODERATE = "moderate",
|
|
308
|
+
/** Speculative — worth checking later */
|
|
309
|
+
LOW = "low"
|
|
310
|
+
}
|
|
311
|
+
/** Map confidence levels to numeric scores */
|
|
312
|
+
declare const ConfidenceScores: Record<ConfidenceLevel, number>;
|
|
313
|
+
/** Convert a confidence level label to a numeric score */
|
|
314
|
+
declare function confidenceToScore(level: ConfidenceLevel | string): number;
|
|
315
|
+
/** Convert a numeric score to the closest confidence level */
|
|
316
|
+
declare function scoreToConfidence(score: number): ConfidenceLevel;
|
|
317
|
+
/**
|
|
318
|
+
* Whether a predicate supports multiple values on the same subject.
|
|
319
|
+
* Multi-value predicates don't trigger conflict detection in the Thalamus.
|
|
320
|
+
*/
|
|
321
|
+
/**
|
|
322
|
+
* Predicates that can have multiple values on the same subject.
|
|
323
|
+
* These don't trigger conflict detection in the Thalamus.
|
|
324
|
+
*/
|
|
325
|
+
declare const MULTI_VALUE_PREDICATES: Set<string>;
|
|
326
|
+
/**
|
|
327
|
+
* Map from relationship type to its reverse.
|
|
328
|
+
* Used by brain.users.registerPerson() to create bidirectional edges.
|
|
329
|
+
*/
|
|
330
|
+
declare const REVERSE_RELATIONSHIPS: Record<string, string>;
|
|
331
|
+
/**
|
|
332
|
+
* Agent-facing labels for relationship types.
|
|
333
|
+
* Used in tool descriptions so the model knows what's available.
|
|
334
|
+
*/
|
|
335
|
+
declare const RELATIONSHIP_LABELS: Record<string, string>;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* SubCortex Signal Types
|
|
339
|
+
*
|
|
340
|
+
* Signals represent emotional and rapport-related data that attach to
|
|
341
|
+
* the knowledge they relate to. Unlike assertions, signals:
|
|
342
|
+
* - Compound (never conflict)
|
|
343
|
+
* - Decay over time (exponential, configurable half-life)
|
|
344
|
+
* - Have trajectory (warming/cooling/stable/neutral)
|
|
345
|
+
* - Can be resolved by interaction (not just time)
|
|
346
|
+
*
|
|
347
|
+
* Storage: Signals are assertions with `signal:{type}` predicates.
|
|
348
|
+
* The consumer-facing API treats them as a separate entity.
|
|
349
|
+
*/
|
|
350
|
+
/**
|
|
351
|
+
* SYSTEM signal types — available for all tenants.
|
|
352
|
+
* Tenant-specific types use `custom:{tenant}:{type}` convention.
|
|
353
|
+
*/
|
|
354
|
+
declare const SYSTEM_SIGNAL_TYPES: readonly ["frustration", "excitement", "concern", "satisfaction", "confusion", "gratitude", "tension", "sentiment"];
|
|
355
|
+
type SystemSignalType = typeof SYSTEM_SIGNAL_TYPES[number];
|
|
356
|
+
/** Any valid signal type — system or custom */
|
|
357
|
+
type SignalType = SystemSignalType | `custom:${string}`;
|
|
358
|
+
declare function isValidSignalType(type: string): type is SignalType;
|
|
359
|
+
/**
|
|
360
|
+
* Per-type decay half-life in hours.
|
|
361
|
+
* All start at 24h — structure supports per-type tuning.
|
|
362
|
+
*/
|
|
363
|
+
declare const SIGNAL_DECAY_CONFIG: Record<string, number>;
|
|
364
|
+
declare function getDecayHalfLife(signalType: string): number;
|
|
365
|
+
type Trajectory = 'warming' | 'cooling' | 'stable' | 'neutral';
|
|
366
|
+
/** A single recorded signal */
|
|
367
|
+
interface SignalEntry {
|
|
368
|
+
/** Assertion ID backing this signal */
|
|
369
|
+
id: string;
|
|
370
|
+
/** Signal type (e.g., 'frustration', 'excitement') */
|
|
371
|
+
type: string;
|
|
372
|
+
/** Human-readable content */
|
|
373
|
+
content: string;
|
|
374
|
+
/** Raw recorded intensity (0-1) */
|
|
375
|
+
intensity: number;
|
|
376
|
+
/** Time-decayed intensity */
|
|
377
|
+
decayedIntensity: number;
|
|
378
|
+
/** Age in hours since recorded */
|
|
379
|
+
ageHours: number;
|
|
380
|
+
/** Subject this signal is about (e.g., 'context:hiring', 'person:sarah') */
|
|
381
|
+
aboutSubject?: string;
|
|
382
|
+
/** If this signal was resolved by another signal */
|
|
383
|
+
resolvedBy?: string;
|
|
384
|
+
/** ISO timestamp when recorded */
|
|
385
|
+
timestamp: string;
|
|
386
|
+
}
|
|
387
|
+
/** Aggregated snapshot of all signals for a subject */
|
|
388
|
+
interface SignalSnapshot {
|
|
389
|
+
/** All signal entries within the query window */
|
|
390
|
+
signals: SignalEntry[];
|
|
391
|
+
/** Overall rapport trajectory */
|
|
392
|
+
trajectory: Trajectory;
|
|
393
|
+
/** Aggregate intensity across all active signals */
|
|
394
|
+
aggregateIntensity: number;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Signal types that indicate a positive emotional shift.
|
|
398
|
+
* When recorded with `resolveConflicting: true`, these automatically
|
|
399
|
+
* resolve recent negative signals on the same subject.
|
|
400
|
+
*/
|
|
401
|
+
declare const POSITIVE_SIGNALS: Set<string>;
|
|
402
|
+
/**
|
|
403
|
+
* Signal types that indicate a negative emotional state.
|
|
404
|
+
* These are candidates for resolution by a subsequent positive signal.
|
|
405
|
+
*/
|
|
406
|
+
declare const NEGATIVE_SIGNALS: Set<string>;
|
|
407
|
+
interface RecordSignalInput {
|
|
408
|
+
/** User ID the signal is about */
|
|
409
|
+
userId: string;
|
|
410
|
+
/** Signal type */
|
|
411
|
+
type: SignalType;
|
|
412
|
+
/** Human-readable description */
|
|
413
|
+
content: string;
|
|
414
|
+
/** Intensity 0-1 (default: 0.7) */
|
|
415
|
+
intensity?: number;
|
|
416
|
+
/** Subject this signal relates to (e.g., a project, person, topic) */
|
|
417
|
+
aboutSubject?: string;
|
|
418
|
+
/** Session ID for contextual binding */
|
|
419
|
+
sessionId?: string;
|
|
420
|
+
/**
|
|
421
|
+
* When true and the signal type is a positive signal (satisfaction, excitement, gratitude),
|
|
422
|
+
* automatically resolves recent negative signals on the same subject within the last 72 hours.
|
|
423
|
+
* Resolved signals decay 4x faster. Default: false.
|
|
424
|
+
*/
|
|
425
|
+
resolveConflicting?: boolean;
|
|
426
|
+
}
|
|
427
|
+
interface SignalQueryOptions {
|
|
428
|
+
/** Window in hours to look back (default: 72) */
|
|
429
|
+
windowHours?: number;
|
|
430
|
+
/** Filter to specific signal type */
|
|
431
|
+
type?: string;
|
|
432
|
+
}
|
|
433
|
+
interface ResolveSignalInput {
|
|
434
|
+
/** ID of the signal being resolved */
|
|
435
|
+
signalId: string;
|
|
436
|
+
/** ID of the signal that resolves it */
|
|
437
|
+
resolvedBySignalId: string;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* User-related types for SubCortex rapport building.
|
|
442
|
+
*
|
|
443
|
+
* These types define the inputs and outputs for the high-level
|
|
444
|
+
* user operations that SubCortex provides out of the box.
|
|
445
|
+
*/
|
|
446
|
+
|
|
447
|
+
/** Input for identifying/checking a user */
|
|
448
|
+
interface IdentifyUserInput {
|
|
449
|
+
/** The user's system ID (from the consumer platform) */
|
|
450
|
+
userId: string;
|
|
451
|
+
/** Display name from the system (used to seed if first encounter) */
|
|
452
|
+
displayName?: string;
|
|
453
|
+
/** Email from the system */
|
|
454
|
+
email?: string;
|
|
455
|
+
/** Agent ID — used to scope conflict detection to this agent's intake queue */
|
|
456
|
+
agentId?: string;
|
|
457
|
+
}
|
|
458
|
+
/** Result of user identification */
|
|
459
|
+
interface UserIdentification {
|
|
460
|
+
/** The user subject in SubCortex */
|
|
461
|
+
subject: string;
|
|
462
|
+
/** Whether SubCortex has met this user before */
|
|
463
|
+
isKnown: boolean;
|
|
464
|
+
/** The user's name (from assertions, or seeded from system) */
|
|
465
|
+
name: string | null;
|
|
466
|
+
/** All assertions about this user */
|
|
467
|
+
memories: UserMemory[];
|
|
468
|
+
/** People connected to this user via relationships */
|
|
469
|
+
connectedPeople: ConnectedPerson[];
|
|
470
|
+
/** Active reminders to surface */
|
|
471
|
+
reminders: UserMemory[];
|
|
472
|
+
/** Active context anchors (projects, initiatives) */
|
|
473
|
+
contexts: UserMemory[];
|
|
474
|
+
/** Unresolved Thalamus conflicts */
|
|
475
|
+
conflicts: ConflictItem[];
|
|
476
|
+
/** Emotional signals within the query window (decayed, with trajectory) */
|
|
477
|
+
signals: SignalEntry[];
|
|
478
|
+
/** Overall rapport trajectory (warming/cooling/stable/neutral) */
|
|
479
|
+
rapportTrajectory: Trajectory;
|
|
480
|
+
/** Human-readable summary for the agent */
|
|
481
|
+
summary: string;
|
|
482
|
+
}
|
|
483
|
+
/** A single memory/assertion about the user */
|
|
484
|
+
interface UserMemory {
|
|
485
|
+
id: string;
|
|
486
|
+
predicate: string;
|
|
487
|
+
value: unknown;
|
|
488
|
+
confidence: number;
|
|
489
|
+
createdAt: string;
|
|
490
|
+
}
|
|
491
|
+
/** A person connected to the user via relationship */
|
|
492
|
+
interface ConnectedPerson {
|
|
493
|
+
subject: string;
|
|
494
|
+
name: string;
|
|
495
|
+
relationship: string;
|
|
496
|
+
facts: Array<{
|
|
497
|
+
predicate: string;
|
|
498
|
+
value: unknown;
|
|
499
|
+
}>;
|
|
500
|
+
}
|
|
501
|
+
/** An unresolved conflict from the Thalamus */
|
|
502
|
+
interface ConflictItem {
|
|
503
|
+
id: string;
|
|
504
|
+
hint: string;
|
|
505
|
+
}
|
|
506
|
+
/** Input for registering a person the user mentions */
|
|
507
|
+
interface RegisterPersonInput {
|
|
508
|
+
/** Person's full name */
|
|
509
|
+
name: string;
|
|
510
|
+
/** The user ID (subject user — who mentioned this person) */
|
|
511
|
+
userId: string;
|
|
512
|
+
/** The relationship between the user and this person */
|
|
513
|
+
relationship: string;
|
|
514
|
+
/** The person's role/title (optional) */
|
|
515
|
+
role?: string;
|
|
516
|
+
/** Additional details */
|
|
517
|
+
details?: string;
|
|
518
|
+
/** Confidence level */
|
|
519
|
+
confidence?: ConfidenceLevel | number;
|
|
520
|
+
}
|
|
521
|
+
/** Result of person registration */
|
|
522
|
+
interface RegisterPersonResult {
|
|
523
|
+
/** The person subject created */
|
|
524
|
+
personSubject: string;
|
|
525
|
+
/** Assertions created */
|
|
526
|
+
assertionsCreated: number;
|
|
527
|
+
/** Relationships created */
|
|
528
|
+
relationshipsCreated: number;
|
|
529
|
+
/** Warnings (e.g., role conflicts) */
|
|
530
|
+
warnings: string[];
|
|
531
|
+
}
|
|
532
|
+
/** Input for recording an emotional state or rapport signal */
|
|
533
|
+
interface RecordRapportInput {
|
|
534
|
+
/** The user ID */
|
|
535
|
+
userId: string;
|
|
536
|
+
/** Type of rapport signal */
|
|
537
|
+
type: 'sentiment' | 'frustration' | 'excitement' | 'concern' | 'goal' | 'aspiration' | 'preference' | 'interest';
|
|
538
|
+
/** The content */
|
|
539
|
+
value: string;
|
|
540
|
+
/** Optional: person this emotion relates to */
|
|
541
|
+
aboutPerson?: string;
|
|
542
|
+
/** Confidence */
|
|
543
|
+
confidence?: ConfidenceLevel | number;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* SubCortex Users Namespace
|
|
548
|
+
*
|
|
549
|
+
* High-level operations for user rapport building.
|
|
550
|
+
* This is where orchestration logic lives — NOT in the consumer's proxy.
|
|
551
|
+
*
|
|
552
|
+
* The consumer agent calls brain.users.identify() and gets back
|
|
553
|
+
* a complete picture. One call, one round-trip, full context.
|
|
554
|
+
*/
|
|
555
|
+
|
|
556
|
+
declare class UsersNamespace {
|
|
557
|
+
private http;
|
|
558
|
+
private tenantId;
|
|
559
|
+
constructor(http: HttpTransport, tenantId: string);
|
|
560
|
+
/**
|
|
561
|
+
* Identify a user and retrieve their full context.
|
|
562
|
+
*
|
|
563
|
+
* This is the FIRST thing an agent should call at session start.
|
|
564
|
+
* Returns whether the user is known, their memories, connected
|
|
565
|
+
* people, reminders, conflicts, and a summary.
|
|
566
|
+
*
|
|
567
|
+
* @example
|
|
568
|
+
* ```typescript
|
|
569
|
+
* const user = await brain.users.identify({
|
|
570
|
+
* userId: 'cmk123...',
|
|
571
|
+
* displayName: 'Tom Santos',
|
|
572
|
+
* })
|
|
573
|
+
*
|
|
574
|
+
* if (!user.isKnown) {
|
|
575
|
+
* // First encounter — get to know them
|
|
576
|
+
* } else {
|
|
577
|
+
* // Returning user — reference what you know
|
|
578
|
+
* // user.reminders — bring these up
|
|
579
|
+
* // user.conflicts — address these
|
|
580
|
+
* // user.connectedPeople — context about their org
|
|
581
|
+
* }
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
identify(input: IdentifyUserInput): Promise<UserIdentification>;
|
|
585
|
+
/**
|
|
586
|
+
* Register a person that the user mentioned.
|
|
587
|
+
*
|
|
588
|
+
* Creates the person node, their role, and bidirectional
|
|
589
|
+
* relationships to the user. One call does everything.
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```typescript
|
|
593
|
+
* const result = await brain.users.registerPerson({
|
|
594
|
+
* name: 'John Smith',
|
|
595
|
+
* userId: 'cmk123...',
|
|
596
|
+
* relationship: 'direct_report',
|
|
597
|
+
* role: 'VP of Engineering',
|
|
598
|
+
* })
|
|
599
|
+
* ```
|
|
600
|
+
*/
|
|
601
|
+
registerPerson(input: RegisterPersonInput): Promise<RegisterPersonResult>;
|
|
602
|
+
/**
|
|
603
|
+
* Record an emotional state or rapport signal about the user.
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* ```typescript
|
|
607
|
+
* await brain.users.recordRapport({
|
|
608
|
+
* userId: 'cmk123...',
|
|
609
|
+
* type: 'frustration',
|
|
610
|
+
* value: 'Frustrated about losing the EA candidate',
|
|
611
|
+
* aboutPerson: 'Sarah Johnson',
|
|
612
|
+
* })
|
|
613
|
+
* ```
|
|
614
|
+
*/
|
|
615
|
+
recordRapport(input: RecordRapportInput): Promise<{
|
|
616
|
+
success: boolean;
|
|
617
|
+
}>;
|
|
618
|
+
/**
|
|
619
|
+
* Dismiss a reminder after the agent has surfaced it.
|
|
620
|
+
*/
|
|
621
|
+
dismissReminder(userId: string, reminderContent: string): Promise<{
|
|
622
|
+
success: boolean;
|
|
623
|
+
}>;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* SubCortex Signals Namespace
|
|
628
|
+
*
|
|
629
|
+
* Records and queries emotional/rapport signals. Signals attach to
|
|
630
|
+
* the knowledge they relate to and provide temporal decay + trajectory.
|
|
631
|
+
*
|
|
632
|
+
* Signals are stored as assertions with `signal:{type}` predicates.
|
|
633
|
+
* The consumer sees them as a separate entity via this namespace.
|
|
634
|
+
*/
|
|
635
|
+
|
|
636
|
+
declare class SignalsNamespace {
|
|
637
|
+
private http;
|
|
638
|
+
private tenantId;
|
|
639
|
+
constructor(http: HttpTransport, tenantId: string);
|
|
640
|
+
/**
|
|
641
|
+
* Record an emotional signal about a user.
|
|
642
|
+
*
|
|
643
|
+
* @example
|
|
644
|
+
* ```typescript
|
|
645
|
+
* await brain.signals.record({
|
|
646
|
+
* userId: 'cmk123',
|
|
647
|
+
* type: 'frustration',
|
|
648
|
+
* content: 'Frustrated about the hiring timeline',
|
|
649
|
+
* intensity: 0.85,
|
|
650
|
+
* aboutSubject: 'context:hiring-ea',
|
|
651
|
+
* })
|
|
652
|
+
* ```
|
|
653
|
+
*/
|
|
654
|
+
record(input: RecordSignalInput): Promise<{
|
|
655
|
+
id: string;
|
|
656
|
+
resolved?: number;
|
|
657
|
+
}>;
|
|
658
|
+
/**
|
|
659
|
+
* Query signals for a user with computed decay and trajectory.
|
|
660
|
+
* Delegates to the engine's signal query endpoint for server-side computation.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* ```typescript
|
|
664
|
+
* const snapshot = await brain.signals.query('user:cmk123', {
|
|
665
|
+
* windowHours: 72,
|
|
666
|
+
* type: 'frustration',
|
|
667
|
+
* })
|
|
668
|
+
* ```
|
|
669
|
+
*/
|
|
670
|
+
query(userSubject: string, options?: SignalQueryOptions): Promise<SignalSnapshot>;
|
|
671
|
+
/**
|
|
672
|
+
* Resolve a signal — mark it as resolved by a subsequent positive interaction.
|
|
673
|
+
* The resolved signal's effective intensity drops faster.
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* ```typescript
|
|
677
|
+
* await brain.signals.resolve({
|
|
678
|
+
* signalId: 'abc123',
|
|
679
|
+
* resolvedBySignalId: 'def456',
|
|
680
|
+
* })
|
|
681
|
+
* ```
|
|
682
|
+
*/
|
|
683
|
+
resolve(input: ResolveSignalInput): Promise<{
|
|
684
|
+
success: boolean;
|
|
685
|
+
}>;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* SubCortexClient — the main entry point for the SubCortex SDK.
|
|
690
|
+
*
|
|
691
|
+
* @example
|
|
692
|
+
* ```typescript
|
|
693
|
+
* import { SubCortexClient } from '@subcortex-ai/sdk'
|
|
694
|
+
*
|
|
695
|
+
* const subcortex = new SubCortexClient({
|
|
696
|
+
* endpoint: 'https://api.subcortex.example.com',
|
|
697
|
+
* tenantId: 'my-tenant',
|
|
698
|
+
* apiKey: 'scx_live_...',
|
|
699
|
+
* })
|
|
700
|
+
*
|
|
701
|
+
* // Create an assertion
|
|
702
|
+
* const assertion = await subcortex.assertions.create({
|
|
703
|
+
* subject: 'user:alice',
|
|
704
|
+
* predicate: 'name',
|
|
705
|
+
* value: 'Alice Smith',
|
|
706
|
+
* })
|
|
707
|
+
*
|
|
708
|
+
* // Query by subject
|
|
709
|
+
* const facts = await subcortex.assertions.query('user:alice')
|
|
710
|
+
*
|
|
711
|
+
* // Create a relationship
|
|
712
|
+
* const rel = await subcortex.relationships.create({
|
|
713
|
+
* fromSubject: 'user:alice',
|
|
714
|
+
* toSubject: 'team:engineering',
|
|
715
|
+
* relationshipType: 'belongs_to',
|
|
716
|
+
* })
|
|
717
|
+
* ```
|
|
718
|
+
*/
|
|
719
|
+
|
|
720
|
+
interface SubCortexClientOptions {
|
|
721
|
+
/** Base URL of the SubCortex REST API */
|
|
722
|
+
endpoint: string;
|
|
723
|
+
/** Tenant ID — required, used as default for all operations */
|
|
724
|
+
tenantId: string;
|
|
725
|
+
/** API key for authentication */
|
|
726
|
+
apiKey?: string;
|
|
727
|
+
/** JWT token for authentication (alternative to apiKey) */
|
|
728
|
+
token?: string;
|
|
729
|
+
/** Retry configuration */
|
|
730
|
+
retry?: Partial<RetryConfig>;
|
|
731
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
732
|
+
timeoutMs?: number;
|
|
733
|
+
/** Custom fetch implementation (for testing or Cloudflare Workers) */
|
|
734
|
+
fetch?: typeof fetch;
|
|
735
|
+
/** Custom headers added to every request */
|
|
736
|
+
headers?: Record<string, string>;
|
|
737
|
+
/** AbortSignal for cancelling all pending requests */
|
|
738
|
+
signal?: AbortSignal;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* An assertion — the atomic unit of knowledge in SubCortex.
|
|
742
|
+
*
|
|
743
|
+
* An assertion represents a single claim: "subject S has property P with value V."
|
|
744
|
+
* Assertions are content-addressable (same content = same ID), carry confidence
|
|
745
|
+
* scores, and have temporal bounds.
|
|
746
|
+
*
|
|
747
|
+
* @example
|
|
748
|
+
* ```typescript
|
|
749
|
+
* const fact = await subcortex.assertions.create({
|
|
750
|
+
* subject: 'user:alice',
|
|
751
|
+
* predicate: 'role',
|
|
752
|
+
* value: 'Engineering Manager',
|
|
753
|
+
* confidence: 0.99,
|
|
754
|
+
* })
|
|
755
|
+
* console.log(fact.id) // content-addressable BLAKE3 hash
|
|
756
|
+
* ```
|
|
757
|
+
*/
|
|
758
|
+
interface Assertion {
|
|
759
|
+
/** Content-addressable ID (BLAKE3 hash of subject + predicate + value + temporal bounds) */
|
|
760
|
+
id: string;
|
|
761
|
+
/** Tenant this assertion belongs to */
|
|
762
|
+
tenantId: string;
|
|
763
|
+
/** The subject this assertion is about (e.g., `"user:alice"`, `"entity:Project"`) */
|
|
764
|
+
subject: string;
|
|
765
|
+
/** The property being asserted (e.g., `"name"`, `"role"`, `"status"`) */
|
|
766
|
+
predicate: string;
|
|
767
|
+
/** The asserted value — can be a string, number, boolean, or object */
|
|
768
|
+
value: unknown;
|
|
769
|
+
/** Confidence score (0.0–1.0). Higher = more certain. */
|
|
770
|
+
confidence: number;
|
|
771
|
+
/** When this assertion became valid (ISO 8601) */
|
|
772
|
+
validFrom: string;
|
|
773
|
+
/** Whether this assertion has been superseded by a newer version */
|
|
774
|
+
isSuperseded: boolean;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Input for creating an assertion.
|
|
778
|
+
*
|
|
779
|
+
* @example
|
|
780
|
+
* ```typescript
|
|
781
|
+
* await subcortex.assertions.create({
|
|
782
|
+
* subject: 'user:alice',
|
|
783
|
+
* predicate: 'department',
|
|
784
|
+
* value: 'Engineering',
|
|
785
|
+
* confidence: 0.95,
|
|
786
|
+
* })
|
|
787
|
+
* ```
|
|
788
|
+
*/
|
|
789
|
+
interface CreateAssertionInput {
|
|
790
|
+
/** Subject of the assertion (e.g., `"user:alice"`, `"entity:Project"`) */
|
|
791
|
+
subject: string;
|
|
792
|
+
/** Predicate — what property is being asserted */
|
|
793
|
+
predicate: string;
|
|
794
|
+
/** The value being asserted */
|
|
795
|
+
value: unknown;
|
|
796
|
+
/** Confidence score 0.0–1.0 (default: server-side default, typically 0.95) */
|
|
797
|
+
confidence?: number;
|
|
798
|
+
/** Override the default tenant ID for this operation */
|
|
799
|
+
tenantId?: string;
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Input for superseding (updating) an existing assertion.
|
|
803
|
+
*
|
|
804
|
+
* SubCortex assertions are immutable. To "update" a fact, you supersede it:
|
|
805
|
+
* the old assertion is marked as superseded and a new one is created.
|
|
806
|
+
*
|
|
807
|
+
* @example
|
|
808
|
+
* ```typescript
|
|
809
|
+
* await subcortex.assertions.supersede({
|
|
810
|
+
* originalAssertionId: 'abc123...',
|
|
811
|
+
* subject: 'user:alice',
|
|
812
|
+
* predicate: 'role',
|
|
813
|
+
* value: 'VP Engineering', // was "Engineering Manager"
|
|
814
|
+
* })
|
|
815
|
+
* ```
|
|
816
|
+
*/
|
|
817
|
+
interface SupersedeAssertionInput {
|
|
818
|
+
/** ID of the assertion being superseded */
|
|
819
|
+
originalAssertionId: string;
|
|
820
|
+
/** Subject of the new assertion */
|
|
821
|
+
subject: string;
|
|
822
|
+
/** Predicate of the new assertion */
|
|
823
|
+
predicate: string;
|
|
824
|
+
/** Updated value */
|
|
825
|
+
value: unknown;
|
|
826
|
+
/** Confidence for the new assertion */
|
|
827
|
+
confidence?: number;
|
|
828
|
+
/** Override the default tenant ID */
|
|
829
|
+
tenantId?: string;
|
|
830
|
+
}
|
|
831
|
+
/** What the SDK returns for a relationship. */
|
|
832
|
+
interface Relationship {
|
|
833
|
+
id: string;
|
|
834
|
+
tenantId: string;
|
|
835
|
+
fromSubject: string;
|
|
836
|
+
toSubject: string;
|
|
837
|
+
relationshipType: string;
|
|
838
|
+
confidence: number;
|
|
839
|
+
validFrom: string;
|
|
840
|
+
weight: number | null;
|
|
841
|
+
properties: Record<string, string>;
|
|
842
|
+
}
|
|
843
|
+
/** Input for creating a relationship. */
|
|
844
|
+
interface CreateRelationshipInput {
|
|
845
|
+
fromSubject: string;
|
|
846
|
+
toSubject: string;
|
|
847
|
+
relationshipType: string;
|
|
848
|
+
confidence?: number;
|
|
849
|
+
weight?: number;
|
|
850
|
+
properties?: Record<string, string>;
|
|
851
|
+
tenantId?: string;
|
|
852
|
+
}
|
|
853
|
+
/** Operations on assertions — the atomic units of knowledge in SubCortex. */
|
|
854
|
+
declare class AssertionsNamespace {
|
|
855
|
+
private http;
|
|
856
|
+
private tenantId;
|
|
857
|
+
constructor(http: HttpTransport, tenantId: string);
|
|
858
|
+
/** Create an assertion in the knowledge graph. */
|
|
859
|
+
create(input: CreateAssertionInput): Promise<Assertion>;
|
|
860
|
+
/** Get an assertion by its content-addressable ID. */
|
|
861
|
+
get(assertionId: string, options?: {
|
|
862
|
+
tenantId?: string;
|
|
863
|
+
}): Promise<Assertion>;
|
|
864
|
+
/** Query assertions by subject. */
|
|
865
|
+
query(subject: string, options?: {
|
|
866
|
+
tenantId?: string;
|
|
867
|
+
}): Promise<Assertion[]>;
|
|
868
|
+
/** List all active assertions for the tenant. */
|
|
869
|
+
list(options?: {
|
|
870
|
+
tenantId?: string;
|
|
871
|
+
}): Promise<Assertion[]>;
|
|
872
|
+
/** Supersede an existing assertion with updated values. */
|
|
873
|
+
supersede(input: SupersedeAssertionInput): Promise<Assertion>;
|
|
874
|
+
/** Retract an assertion by closing its temporal bounds. */
|
|
875
|
+
retract(assertionId: string, options?: {
|
|
876
|
+
tenantId?: string;
|
|
877
|
+
}): Promise<Assertion>;
|
|
878
|
+
}
|
|
879
|
+
/** Operations on relationships — directional edges between subjects. */
|
|
880
|
+
declare class RelationshipsNamespace {
|
|
881
|
+
private http;
|
|
882
|
+
private tenantId;
|
|
883
|
+
constructor(http: HttpTransport, tenantId: string);
|
|
884
|
+
/** Create a relationship between two subjects. */
|
|
885
|
+
create(input: CreateRelationshipInput): Promise<Relationship>;
|
|
886
|
+
/** Get relationships for a subject. */
|
|
887
|
+
query(subject: string, options?: {
|
|
888
|
+
tenantId?: string;
|
|
889
|
+
}): Promise<Relationship[]>;
|
|
890
|
+
/** List all relationships for the tenant. */
|
|
891
|
+
list(options?: {
|
|
892
|
+
tenantId?: string;
|
|
893
|
+
}): Promise<Relationship[]>;
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Agent personality — defines how the agent communicates.
|
|
897
|
+
*
|
|
898
|
+
* @example
|
|
899
|
+
* ```typescript
|
|
900
|
+
* const personality: AgentPersonality = {
|
|
901
|
+
* voice: "Friendly cubicle neighbor who knows the business inside out",
|
|
902
|
+
* tone: "casual",
|
|
903
|
+
* traits: ["curious", "witty", "empathetic"],
|
|
904
|
+
* avoid: ["corporate speak", "jargon", "being verbose"],
|
|
905
|
+
* }
|
|
906
|
+
* ```
|
|
907
|
+
*/
|
|
908
|
+
interface AgentPersonality {
|
|
909
|
+
/** Overall personality description */
|
|
910
|
+
voice?: string;
|
|
911
|
+
/** Communication tone: `"casual"`, `"professional"`, `"playful"` */
|
|
912
|
+
tone?: string;
|
|
913
|
+
/** Personality traits */
|
|
914
|
+
traits?: string[];
|
|
915
|
+
/** Things the agent should avoid saying/doing */
|
|
916
|
+
avoid?: string[];
|
|
917
|
+
}
|
|
918
|
+
/**
|
|
919
|
+
* Composable instruction sections for an agent.
|
|
920
|
+
*
|
|
921
|
+
* Instructions are broken into sections so they can be independently
|
|
922
|
+
* configured. SubCortex assembles them into a single system prompt
|
|
923
|
+
* via {@link SubCortexClient.agents.getInstructions}.
|
|
924
|
+
*/
|
|
925
|
+
interface AgentInstructions {
|
|
926
|
+
/** How the agent speaks and presents itself */
|
|
927
|
+
personality?: string;
|
|
928
|
+
/** What to remember about users, how to categorize facts */
|
|
929
|
+
memoryGuidance?: string;
|
|
930
|
+
/** Domain-specific behavior rules (e.g., schema emergence) */
|
|
931
|
+
domainRules?: string;
|
|
932
|
+
/** Organization-specific additions */
|
|
933
|
+
custom?: string;
|
|
934
|
+
/** How to greet new vs returning users */
|
|
935
|
+
greetingRules?: string;
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* LLM model configuration for the agent.
|
|
939
|
+
*/
|
|
940
|
+
interface AgentModelConfig {
|
|
941
|
+
/** Provider: `"anthropic"`, `"openai"`, `"azure-openai"` */
|
|
942
|
+
provider?: string;
|
|
943
|
+
/** Model identifier (e.g., `"claude-opus-4-6"`, `"gpt-4-turbo"`) */
|
|
944
|
+
modelId?: string;
|
|
945
|
+
/** Inference temperature (0.0–2.0) */
|
|
946
|
+
temperature?: number;
|
|
947
|
+
/** Maximum response tokens */
|
|
948
|
+
maxTokens?: number;
|
|
949
|
+
/** Voice ID for voice agents (e.g., `"marin"`, `"echo"`) */
|
|
950
|
+
voiceId?: string;
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* A capability (tool/function) the agent can use.
|
|
954
|
+
*
|
|
955
|
+
* @example
|
|
956
|
+
* ```typescript
|
|
957
|
+
* const cap: AgentCapability = {
|
|
958
|
+
* name: "registerUserFact",
|
|
959
|
+
* description: "Store a learned fact about the user",
|
|
960
|
+
* enabled: true,
|
|
961
|
+
* }
|
|
962
|
+
* ```
|
|
963
|
+
*/
|
|
964
|
+
interface AgentCapability {
|
|
965
|
+
/** Tool/function name */
|
|
966
|
+
name: string;
|
|
967
|
+
/** What this capability does */
|
|
968
|
+
description?: string;
|
|
969
|
+
/** Whether this capability is active */
|
|
970
|
+
enabled?: boolean;
|
|
971
|
+
/** Tool parameter schema (JSON Schema) */
|
|
972
|
+
parameters?: unknown;
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Memory retention policy — controls how the agent manages its memories.
|
|
976
|
+
*/
|
|
977
|
+
interface AgentMemoryPolicy {
|
|
978
|
+
/** Max assertions per user subject (0 = unlimited) */
|
|
979
|
+
maxMemoriesPerUser?: number;
|
|
980
|
+
/** Auto-forget memories below this confidence (0.0 = keep everything) */
|
|
981
|
+
forgetConfidenceBelow?: number;
|
|
982
|
+
/** Days to retain memories (0 = forever) */
|
|
983
|
+
retainDays?: number;
|
|
984
|
+
/** Compress old memories into higher-level summaries */
|
|
985
|
+
autoSummarize?: boolean;
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Full agent configuration — the agent's identity in SubCortex.
|
|
989
|
+
*
|
|
990
|
+
* This is what an agent retrieves at session start to know who it is,
|
|
991
|
+
* how to behave, what tools it has, and how to manage its memory.
|
|
992
|
+
*
|
|
993
|
+
* @example
|
|
994
|
+
* ```typescript
|
|
995
|
+
* const agent = await cortex.agents.create({
|
|
996
|
+
* name: 'Aria',
|
|
997
|
+
* description: 'AI assistant for customer support',
|
|
998
|
+
* personality: { tone: 'casual', traits: ['curious', 'empathetic'] },
|
|
999
|
+
* instructions: {
|
|
1000
|
+
* personality: 'You are the user\'s best friend at work...',
|
|
1001
|
+
* memoryGuidance: 'Remember names, roles, and org structure...',
|
|
1002
|
+
* },
|
|
1003
|
+
* model: { provider: 'openai', modelId: 'gpt-realtime-1.5', voiceId: 'marin' },
|
|
1004
|
+
* })
|
|
1005
|
+
* ```
|
|
1006
|
+
*/
|
|
1007
|
+
interface AgentConfig {
|
|
1008
|
+
agentId: string;
|
|
1009
|
+
tenantId: string;
|
|
1010
|
+
name: string;
|
|
1011
|
+
description: string;
|
|
1012
|
+
personality: AgentPersonality;
|
|
1013
|
+
instructions: AgentInstructions;
|
|
1014
|
+
model: AgentModelConfig;
|
|
1015
|
+
capabilities: AgentCapability[];
|
|
1016
|
+
memoryPolicy: AgentMemoryPolicy;
|
|
1017
|
+
isActive: boolean;
|
|
1018
|
+
createdAt: string;
|
|
1019
|
+
updatedAt: string;
|
|
1020
|
+
}
|
|
1021
|
+
/** Input for creating an agent. */
|
|
1022
|
+
interface CreateAgentInput {
|
|
1023
|
+
name: string;
|
|
1024
|
+
description?: string;
|
|
1025
|
+
personality?: AgentPersonality;
|
|
1026
|
+
instructions?: AgentInstructions;
|
|
1027
|
+
model?: AgentModelConfig;
|
|
1028
|
+
capabilities?: AgentCapability[];
|
|
1029
|
+
memoryPolicy?: AgentMemoryPolicy;
|
|
1030
|
+
tenantId?: string;
|
|
1031
|
+
}
|
|
1032
|
+
/** Input for updating an agent. */
|
|
1033
|
+
interface UpdateAgentInput {
|
|
1034
|
+
name?: string;
|
|
1035
|
+
description?: string;
|
|
1036
|
+
personality?: AgentPersonality;
|
|
1037
|
+
instructions?: AgentInstructions;
|
|
1038
|
+
model?: AgentModelConfig;
|
|
1039
|
+
capabilities?: AgentCapability[];
|
|
1040
|
+
memoryPolicy?: AgentMemoryPolicy;
|
|
1041
|
+
isActive?: boolean;
|
|
1042
|
+
}
|
|
1043
|
+
/** Composed instructions response. */
|
|
1044
|
+
interface ComposedInstructions {
|
|
1045
|
+
composedInstructions: string;
|
|
1046
|
+
agentName: string;
|
|
1047
|
+
modelProvider: string;
|
|
1048
|
+
modelId: string;
|
|
1049
|
+
temperature: number;
|
|
1050
|
+
voiceId: string;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Operations on agent configurations — the identity layer.
|
|
1054
|
+
*
|
|
1055
|
+
* Create, update, and retrieve agent profiles that define who an agent is,
|
|
1056
|
+
* how it behaves, what tools it can use, and how it manages memory.
|
|
1057
|
+
*
|
|
1058
|
+
* @example
|
|
1059
|
+
* ```typescript
|
|
1060
|
+
* // Create an agent
|
|
1061
|
+
* const agent = await subcortex.agents.create({
|
|
1062
|
+
* name: 'Aria',
|
|
1063
|
+
* description: 'AI assistant for customer support',
|
|
1064
|
+
* personality: { tone: 'casual', traits: ['curious', 'witty'] },
|
|
1065
|
+
* })
|
|
1066
|
+
*
|
|
1067
|
+
* // Get composed system prompt at session start
|
|
1068
|
+
* const { composedInstructions } = await subcortex.agents.getInstructions(agent.agentId)
|
|
1069
|
+
* ```
|
|
1070
|
+
*/
|
|
1071
|
+
declare class AgentsNamespace {
|
|
1072
|
+
private http;
|
|
1073
|
+
private tenantId;
|
|
1074
|
+
constructor(http: HttpTransport, tenantId: string);
|
|
1075
|
+
/** Create a new agent. */
|
|
1076
|
+
create(input: CreateAgentInput): Promise<AgentConfig>;
|
|
1077
|
+
/** Get an agent by ID. */
|
|
1078
|
+
get(agentId: string, options?: {
|
|
1079
|
+
tenantId?: string;
|
|
1080
|
+
}): Promise<AgentConfig>;
|
|
1081
|
+
/** Update an agent. */
|
|
1082
|
+
update(agentId: string, input: UpdateAgentInput, options?: {
|
|
1083
|
+
tenantId?: string;
|
|
1084
|
+
}): Promise<AgentConfig>;
|
|
1085
|
+
/** Delete an agent. */
|
|
1086
|
+
delete(agentId: string, options?: {
|
|
1087
|
+
tenantId?: string;
|
|
1088
|
+
}): Promise<void>;
|
|
1089
|
+
/** List all agents for the tenant. */
|
|
1090
|
+
list(options?: {
|
|
1091
|
+
tenantId?: string;
|
|
1092
|
+
}): Promise<AgentConfig[]>;
|
|
1093
|
+
/** Get composed system instructions for an agent. */
|
|
1094
|
+
getInstructions(agentId: string, options?: {
|
|
1095
|
+
tenantId?: string;
|
|
1096
|
+
}): Promise<ComposedInstructions>;
|
|
1097
|
+
}
|
|
1098
|
+
/** Input for storing a memory. */
|
|
1099
|
+
interface StoreMemoryInput {
|
|
1100
|
+
subject: string;
|
|
1101
|
+
predicate: string;
|
|
1102
|
+
value: unknown;
|
|
1103
|
+
confidence?: number;
|
|
1104
|
+
tenantId?: string;
|
|
1105
|
+
/** Agent ID — required for Thalamus routing (used as agentId in intake submission) */
|
|
1106
|
+
agentId?: string;
|
|
1107
|
+
/** Person this fact relates to */
|
|
1108
|
+
personName?: string;
|
|
1109
|
+
/** Skip Thalamus processing — write directly to assertion store. For bulk imports, migrations. */
|
|
1110
|
+
raw?: boolean;
|
|
1111
|
+
/** Conversational context for deep encoding */
|
|
1112
|
+
context?: {
|
|
1113
|
+
topic?: string;
|
|
1114
|
+
emotionalState?: string;
|
|
1115
|
+
sessionId?: string;
|
|
1116
|
+
excerpt?: string;
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
/**
|
|
1120
|
+
* Agent memory operations.
|
|
1121
|
+
*
|
|
1122
|
+
* By default, `store()` routes through the Thalamus cognitive intake
|
|
1123
|
+
* pipeline for signal classification, contradiction detection, and
|
|
1124
|
+
* deduplication. Use `raw: true` to bypass for bulk imports.
|
|
1125
|
+
*
|
|
1126
|
+
* @example
|
|
1127
|
+
* ```typescript
|
|
1128
|
+
* // Store via Thalamus (default — validated, deduped, conflict-checked)
|
|
1129
|
+
* await subcortex.memory.store({
|
|
1130
|
+
* subject: 'user:alice',
|
|
1131
|
+
* predicate: 'role',
|
|
1132
|
+
* value: 'Engineering Manager',
|
|
1133
|
+
* confidence: 0.99,
|
|
1134
|
+
* agentId: 'agent_abc',
|
|
1135
|
+
* })
|
|
1136
|
+
*
|
|
1137
|
+
* // Store raw (bypass Thalamus — for imports/migrations)
|
|
1138
|
+
* await subcortex.memory.store({
|
|
1139
|
+
* subject: 'user:alice',
|
|
1140
|
+
* predicate: 'role',
|
|
1141
|
+
* value: 'Engineering Manager',
|
|
1142
|
+
* raw: true,
|
|
1143
|
+
* })
|
|
1144
|
+
*
|
|
1145
|
+
* // Recall everything about a user
|
|
1146
|
+
* const memories = await subcortex.memory.recall('user:alice')
|
|
1147
|
+
* ```
|
|
1148
|
+
*/
|
|
1149
|
+
declare class MemoryNamespace {
|
|
1150
|
+
private http;
|
|
1151
|
+
private tenantId;
|
|
1152
|
+
constructor(http: HttpTransport, tenantId: string);
|
|
1153
|
+
/**
|
|
1154
|
+
* Store a fact in the agent's memory.
|
|
1155
|
+
*
|
|
1156
|
+
* Routes through the Thalamus by default. The Thalamus will:
|
|
1157
|
+
* - Classify the signal (reject noise)
|
|
1158
|
+
* - Check for contradictions with existing assertions
|
|
1159
|
+
* - Detect duplicates and reinforce instead of creating new
|
|
1160
|
+
*
|
|
1161
|
+
* Pass `raw: true` to bypass Thalamus for system operations.
|
|
1162
|
+
*/
|
|
1163
|
+
store(input: StoreMemoryInput): Promise<Assertion | IntakeResult>;
|
|
1164
|
+
/** Recall all memories for a subject. */
|
|
1165
|
+
recall(subject: string, options?: {
|
|
1166
|
+
tenantId?: string;
|
|
1167
|
+
}): Promise<Assertion[]>;
|
|
1168
|
+
/** Forget a specific memory (retract the assertion). */
|
|
1169
|
+
forget(assertionId: string, options?: {
|
|
1170
|
+
tenantId?: string;
|
|
1171
|
+
}): Promise<Assertion>;
|
|
1172
|
+
}
|
|
1173
|
+
/** A candidate assertion submitted for Thalamus processing. */
|
|
1174
|
+
interface CandidateAssertion {
|
|
1175
|
+
subject: string;
|
|
1176
|
+
predicate: string;
|
|
1177
|
+
value: unknown;
|
|
1178
|
+
sourceConfidence: number;
|
|
1179
|
+
validFrom?: string;
|
|
1180
|
+
validUntil?: string | null;
|
|
1181
|
+
provenance: 'human' | 'agent' | 'import' | 'derived';
|
|
1182
|
+
personName?: string;
|
|
1183
|
+
}
|
|
1184
|
+
/** Full intake submission. */
|
|
1185
|
+
interface IntakeSubmission {
|
|
1186
|
+
correlationId: string;
|
|
1187
|
+
agentId: string;
|
|
1188
|
+
candidates: CandidateAssertion[];
|
|
1189
|
+
context?: {
|
|
1190
|
+
topic?: string;
|
|
1191
|
+
emotionalState?: string;
|
|
1192
|
+
sessionId?: string;
|
|
1193
|
+
excerpt?: string;
|
|
1194
|
+
};
|
|
1195
|
+
tenantId?: string;
|
|
1196
|
+
}
|
|
1197
|
+
/** Result of Thalamus processing. */
|
|
1198
|
+
interface IntakeResult {
|
|
1199
|
+
correlationId: string;
|
|
1200
|
+
processed: number;
|
|
1201
|
+
accepted: number;
|
|
1202
|
+
reinforced: number;
|
|
1203
|
+
conflicts: number;
|
|
1204
|
+
rejected: number;
|
|
1205
|
+
items: IntakeResponseItem[];
|
|
1206
|
+
}
|
|
1207
|
+
/** A single intake response queue item. */
|
|
1208
|
+
interface IntakeResponseItem {
|
|
1209
|
+
id: string;
|
|
1210
|
+
correlationId: string;
|
|
1211
|
+
agentId: string;
|
|
1212
|
+
tenantId: string;
|
|
1213
|
+
status: 'accepted' | 'reinforced' | 'conflict_detected' | 'needs_clarification' | 'rejected';
|
|
1214
|
+
priority: number;
|
|
1215
|
+
surfacingHint?: string;
|
|
1216
|
+
expiresAt: string;
|
|
1217
|
+
persistedAssertionIds: string[];
|
|
1218
|
+
inferredBondIds: string[];
|
|
1219
|
+
conflictingAssertionId?: string;
|
|
1220
|
+
clarificationQuestions: string[];
|
|
1221
|
+
rejectionReason?: string;
|
|
1222
|
+
signalCategory?: string;
|
|
1223
|
+
acknowledged: boolean;
|
|
1224
|
+
createdAt: string;
|
|
1225
|
+
}
|
|
1226
|
+
/** Intake processing stats. */
|
|
1227
|
+
interface IntakeStats {
|
|
1228
|
+
total: number;
|
|
1229
|
+
accepted: number;
|
|
1230
|
+
reinforced: number;
|
|
1231
|
+
conflicts: number;
|
|
1232
|
+
clarifications: number;
|
|
1233
|
+
rejected: number;
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Thalamus cognitive intake operations.
|
|
1237
|
+
*
|
|
1238
|
+
* Submit candidate assertions for processing through the Thalamus
|
|
1239
|
+
* pipeline. The pipeline validates, deduplicates, detects contradictions,
|
|
1240
|
+
* and enriches assertions before persisting them.
|
|
1241
|
+
*
|
|
1242
|
+
* @example
|
|
1243
|
+
* ```typescript
|
|
1244
|
+
* // Submit a fact for processing
|
|
1245
|
+
* const result = await subcortex.intake.submit({
|
|
1246
|
+
* correlationId: 'corr-123',
|
|
1247
|
+
* agentId: 'agent_abc',
|
|
1248
|
+
* candidates: [{
|
|
1249
|
+
* subject: 'user:tommy',
|
|
1250
|
+
* predicate: 'role',
|
|
1251
|
+
* value: 'CTO',
|
|
1252
|
+
* sourceConfidence: 0.99,
|
|
1253
|
+
* provenance: 'human',
|
|
1254
|
+
* }],
|
|
1255
|
+
* })
|
|
1256
|
+
*
|
|
1257
|
+
* // Check for conflicts or clarification requests
|
|
1258
|
+
* const pending = await subcortex.intake.pending('agent_abc')
|
|
1259
|
+
*
|
|
1260
|
+
* // Acknowledge after handling
|
|
1261
|
+
* await subcortex.intake.acknowledge(pending[0].id)
|
|
1262
|
+
* ```
|
|
1263
|
+
*/
|
|
1264
|
+
declare class IntakeNamespace {
|
|
1265
|
+
private http;
|
|
1266
|
+
private tenantId;
|
|
1267
|
+
constructor(http: HttpTransport, tenantId: string);
|
|
1268
|
+
/** Submit candidate assertions for Thalamus processing. */
|
|
1269
|
+
submit(input: IntakeSubmission): Promise<IntakeResult>;
|
|
1270
|
+
/** Get pending intake results for an agent. */
|
|
1271
|
+
pending(agentId: string, options?: {
|
|
1272
|
+
status?: string[];
|
|
1273
|
+
limit?: number;
|
|
1274
|
+
}): Promise<IntakeResponseItem[]>;
|
|
1275
|
+
/** Acknowledge an intake result (mark as consumed). */
|
|
1276
|
+
acknowledge(itemId: string): Promise<void>;
|
|
1277
|
+
/** Acknowledge all pending items for an agent. */
|
|
1278
|
+
acknowledgeAll(agentId: string): Promise<{
|
|
1279
|
+
acknowledged: number;
|
|
1280
|
+
}>;
|
|
1281
|
+
/** Get intake processing stats for an agent. */
|
|
1282
|
+
stats(agentId: string): Promise<IntakeStats>;
|
|
1283
|
+
}
|
|
1284
|
+
declare class SubCortexClient {
|
|
1285
|
+
/** Assertion operations (low-level knowledge primitives) */
|
|
1286
|
+
readonly assertions: AssertionsNamespace;
|
|
1287
|
+
/** Relationship operations */
|
|
1288
|
+
readonly relationships: RelationshipsNamespace;
|
|
1289
|
+
/** Agent identity & configuration */
|
|
1290
|
+
readonly agents: AgentsNamespace;
|
|
1291
|
+
/** Agent memory (semantic wrapper over assertions) */
|
|
1292
|
+
readonly memory: MemoryNamespace;
|
|
1293
|
+
/** Thalamus cognitive intake pipeline */
|
|
1294
|
+
readonly intake: IntakeNamespace;
|
|
1295
|
+
/** User rapport building operations */
|
|
1296
|
+
readonly users: UsersNamespace;
|
|
1297
|
+
/** Emotional signals — record, query, and resolve */
|
|
1298
|
+
readonly signals: SignalsNamespace;
|
|
1299
|
+
private readonly http;
|
|
1300
|
+
constructor(options: SubCortexClientOptions);
|
|
1301
|
+
/** Check SubCortex server health. */
|
|
1302
|
+
health(): Promise<HealthResponse>;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
/**
|
|
1306
|
+
* SubCortex Context Formatting — v1.0 Schema
|
|
1307
|
+
*
|
|
1308
|
+
* Transforms structured UserIdentification data into XML optimized
|
|
1309
|
+
* for model injection. Signals nest as children of the knowledge
|
|
1310
|
+
* they relate to, not as a separate section.
|
|
1311
|
+
*
|
|
1312
|
+
* Section order = priority order (transformer attention bias):
|
|
1313
|
+
* conflicts → reminders → contexts → identity → knowledge → relationships
|
|
1314
|
+
*
|
|
1315
|
+
* Why XML: Tag boundaries create hard attention delimiters for transformers.
|
|
1316
|
+
* See docs/context-format-rationale.md for full analysis.
|
|
1317
|
+
*/
|
|
1318
|
+
|
|
1319
|
+
declare const CONTEXT_SCHEMA_VERSION = "1.0";
|
|
1320
|
+
type ContextFormat = 'xml' | 'json' | 'summary';
|
|
1321
|
+
interface ContextFormatOptions {
|
|
1322
|
+
/** Output format. Default: 'xml' */
|
|
1323
|
+
format?: ContextFormat;
|
|
1324
|
+
/** Include memories section. Default: true */
|
|
1325
|
+
includeMemories?: boolean;
|
|
1326
|
+
/** Include connected people. Default: true */
|
|
1327
|
+
includeRelationships?: boolean;
|
|
1328
|
+
/** Include reminders. Default: true */
|
|
1329
|
+
includeReminders?: boolean;
|
|
1330
|
+
/** Include conflicts. Default: true */
|
|
1331
|
+
includeConflicts?: boolean;
|
|
1332
|
+
/** Include active contexts. Default: true */
|
|
1333
|
+
includeContexts?: boolean;
|
|
1334
|
+
/** Include emotional signals. Default: true */
|
|
1335
|
+
includeSignals?: boolean;
|
|
1336
|
+
/** Minimum confidence threshold to include (0-1). Default: 0 */
|
|
1337
|
+
minConfidence?: number;
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* Format a UserIdentification result for model injection.
|
|
1341
|
+
*/
|
|
1342
|
+
declare function formatContext(user: UserIdentification, options?: ContextFormatOptions): string;
|
|
1343
|
+
/**
|
|
1344
|
+
* Transform UserIdentification into versioned XML optimized for model attention.
|
|
1345
|
+
* Signals nest as children of the facts/contexts/people they relate to.
|
|
1346
|
+
*/
|
|
1347
|
+
declare function toContextXml(user: UserIdentification, options?: ContextFormatOptions): string;
|
|
1348
|
+
|
|
1349
|
+
/**
|
|
1350
|
+
* SubCortex SDK Error Hierarchy
|
|
1351
|
+
*
|
|
1352
|
+
* Typed error classes for programmatic error handling.
|
|
1353
|
+
* Consumers can catch specific error types:
|
|
1354
|
+
*
|
|
1355
|
+
* ```typescript
|
|
1356
|
+
* try {
|
|
1357
|
+
* await subcortex.assertions.create(...)
|
|
1358
|
+
* } catch (e) {
|
|
1359
|
+
* if (e instanceof SubCortexNotFoundError) { ... }
|
|
1360
|
+
* if (e instanceof SubCortexRateLimitError) { await sleep(e.retryAfter) }
|
|
1361
|
+
* }
|
|
1362
|
+
* ```
|
|
1363
|
+
*/
|
|
1364
|
+
/** Base error for all SubCortex SDK errors. */
|
|
1365
|
+
declare class SubCortexError extends Error {
|
|
1366
|
+
/** HTTP status code (0 for network errors) */
|
|
1367
|
+
readonly statusCode: number;
|
|
1368
|
+
/** Server-assigned request ID for debugging */
|
|
1369
|
+
readonly requestId?: string;
|
|
1370
|
+
/** Whether the request can be retried */
|
|
1371
|
+
readonly retryable: boolean;
|
|
1372
|
+
/** Raw response body */
|
|
1373
|
+
readonly body?: string;
|
|
1374
|
+
constructor(message: string, statusCode: number, options?: {
|
|
1375
|
+
requestId?: string;
|
|
1376
|
+
retryable?: boolean;
|
|
1377
|
+
body?: string;
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
/** 400 — Bad request, validation failure. */
|
|
1381
|
+
declare class SubCortexValidationError extends SubCortexError {
|
|
1382
|
+
/** Field-level validation errors if available */
|
|
1383
|
+
readonly details?: Record<string, string>;
|
|
1384
|
+
constructor(message: string, options?: {
|
|
1385
|
+
requestId?: string;
|
|
1386
|
+
body?: string;
|
|
1387
|
+
details?: Record<string, string>;
|
|
1388
|
+
});
|
|
1389
|
+
}
|
|
1390
|
+
/** 401 — Invalid or missing credentials. */
|
|
1391
|
+
declare class SubCortexAuthenticationError extends SubCortexError {
|
|
1392
|
+
constructor(message: string, options?: {
|
|
1393
|
+
requestId?: string;
|
|
1394
|
+
body?: string;
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
/** 403 — Valid credentials but insufficient permissions. */
|
|
1398
|
+
declare class SubCortexAuthorizationError extends SubCortexError {
|
|
1399
|
+
constructor(message: string, options?: {
|
|
1400
|
+
requestId?: string;
|
|
1401
|
+
body?: string;
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
/** 404 — Resource not found. */
|
|
1405
|
+
declare class SubCortexNotFoundError extends SubCortexError {
|
|
1406
|
+
constructor(message: string, options?: {
|
|
1407
|
+
requestId?: string;
|
|
1408
|
+
body?: string;
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
/** 409 — Conflict (e.g., duplicate assertion). */
|
|
1412
|
+
declare class SubCortexConflictError extends SubCortexError {
|
|
1413
|
+
constructor(message: string, options?: {
|
|
1414
|
+
requestId?: string;
|
|
1415
|
+
body?: string;
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
/** 429 — Rate limit exceeded. */
|
|
1419
|
+
declare class SubCortexRateLimitError extends SubCortexError {
|
|
1420
|
+
/** Seconds to wait before retrying */
|
|
1421
|
+
readonly retryAfter?: number;
|
|
1422
|
+
constructor(message: string, options?: {
|
|
1423
|
+
requestId?: string;
|
|
1424
|
+
body?: string;
|
|
1425
|
+
retryAfter?: number;
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
/** 5xx — Server-side error. */
|
|
1429
|
+
declare class SubCortexServerError extends SubCortexError {
|
|
1430
|
+
constructor(message: string, statusCode: number, options?: {
|
|
1431
|
+
requestId?: string;
|
|
1432
|
+
body?: string;
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
/** Network-level failure (DNS, timeout, connection refused). */
|
|
1436
|
+
declare class SubCortexNetworkError extends SubCortexError {
|
|
1437
|
+
readonly cause?: Error;
|
|
1438
|
+
constructor(message: string, options?: {
|
|
1439
|
+
cause?: Error;
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
/** Timeout — request exceeded the configured timeout. */
|
|
1443
|
+
declare class SubCortexTimeoutError extends SubCortexNetworkError {
|
|
1444
|
+
constructor(timeoutMs: number);
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
export { type AgentCapability, type AgentConfig, type AgentInstructions, type AgentMemoryPolicy, type AgentModelConfig, type AgentPersonality, AgentsNamespace, type Assertion, AssertionsNamespace, type BatchResult, CONTEXT_SCHEMA_VERSION, type CandidateAssertion, type ComposedInstructions, ConfidenceLevel, type ConfidenceScore, ConfidenceScores, type ConflictItem, type ConnectedPerson, type ContextFormat, type ContextFormatOptions, type CreateAgentInput, type CreateAssertionInput, type CreateRelationshipInput, EntityPredicate, EntityRelationship, EventPredicate, type HealthResponse, type IdentifyUserInput, IdentityPredicate, IntakeNamespace, type IntakeResponseItem, type IntakeResult, type IntakeStats, type IntakeSubmission, MULTI_VALUE_PREDICATES, MemoryNamespace, MemoryPredicate, NEGATIVE_SIGNALS, OrgRelationship, POSITIVE_SIGNALS, type PaginatedResponse, Predicates, type Provenance, RELATIONSHIP_LABELS, REVERSE_RELATIONSHIPS, RapportPredicate, type RecordRapportInput, type RecordSignalInput, type RegisterPersonInput, type RegisterPersonResult, type Relationship, RelationshipTypes, RelationshipsNamespace, type ResolveSignalInput, type RetryConfig, SIGNAL_DECAY_CONFIG, SYSTEM_SIGNAL_TYPES, type SignalEntry, type SignalQueryOptions, type SignalSnapshot, type SignalType, SignalsNamespace, type StoreMemoryInput, SubCortexAuthenticationError, SubCortexAuthorizationError, SubCortexClient, type SubCortexClientOptions, SubCortexConflictError, SubCortexError, SubCortexNetworkError, SubCortexNotFoundError, SubCortexRateLimitError, SubCortexServerError, SubCortexTimeoutError, SubCortexValidationError, SubjectPrefix, type SupersedeAssertionInput, type SystemSignalType, type TemporalBounds, type Trajectory, type UpdateAgentInput, type UserIdentification, type UserMemory, UsersNamespace, WorkPredicate, confidenceToScore, formatContext, getDecayHalfLife, isValidSignalType, scoreToConfidence, subject, toContextXml };
|