@eidetic-labs/stigmem-ts 0.9.0-alpha.1
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/dist/client.d.ts +48 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +242 -0
- package/dist/client.js.map +1 -0
- package/dist/generated.d.ts +5049 -0
- package/dist/generated.d.ts.map +1 -0
- package/dist/generated.js +7 -0
- package/dist/generated.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +215 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +22 -0
- package/dist/types.js.map +1 -0
- package/package.json +51 -0
- package/src/client.ts +317 -0
- package/src/generated.ts +5049 -0
- package/src/index.ts +72 -0
- package/src/types.ts +269 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* stigmem-ts — TypeScript client SDK for Stigmem.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { StigmemClient, sv, tv } from "@eidetic-labs/stigmem-ts";
|
|
7
|
+
*
|
|
8
|
+
* const client = new StigmemClient({ url: "http://localhost:8765", apiKey: "sk-..." });
|
|
9
|
+
* const fact = await client.assertFact("user:alice", "memory:role", sv("CEO"), "agent:cto");
|
|
10
|
+
* const result = await client.recall("Alice's current role", { token_budget: 500 });
|
|
11
|
+
* const card = await client.getCard("user:alice");
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
StigmemClient,
|
|
17
|
+
StigmemError,
|
|
18
|
+
StigmemHTTPError,
|
|
19
|
+
StigmemAuthError,
|
|
20
|
+
StigmemNotFoundError,
|
|
21
|
+
StigmemConflictError,
|
|
22
|
+
} from "./client.js";
|
|
23
|
+
|
|
24
|
+
export type {
|
|
25
|
+
AssertOptions,
|
|
26
|
+
BooleanValue,
|
|
27
|
+
CardOptions,
|
|
28
|
+
Conflict,
|
|
29
|
+
ConflictListOptions,
|
|
30
|
+
ConflictPage,
|
|
31
|
+
ConflictResolution,
|
|
32
|
+
ConflictStatus,
|
|
33
|
+
DatetimeValue,
|
|
34
|
+
Fact,
|
|
35
|
+
FactPage,
|
|
36
|
+
FactScope,
|
|
37
|
+
FactValue,
|
|
38
|
+
FederationEndpoints,
|
|
39
|
+
LintCheck,
|
|
40
|
+
LintFinding,
|
|
41
|
+
LintOptions,
|
|
42
|
+
LintResult,
|
|
43
|
+
LintSeverity,
|
|
44
|
+
MemoryCard,
|
|
45
|
+
NodeInfo,
|
|
46
|
+
NullValue,
|
|
47
|
+
NumberValue,
|
|
48
|
+
Peer,
|
|
49
|
+
PeerPage,
|
|
50
|
+
PeerStatus,
|
|
51
|
+
QueryOptions,
|
|
52
|
+
RecallOptions,
|
|
53
|
+
RecallResponse,
|
|
54
|
+
RecallWeights,
|
|
55
|
+
RefValue,
|
|
56
|
+
ResolveOptions,
|
|
57
|
+
ScoreBreakdown,
|
|
58
|
+
ScoredFact,
|
|
59
|
+
StringValue,
|
|
60
|
+
SubscribeOptions,
|
|
61
|
+
TextValue,
|
|
62
|
+
} from "./types.js";
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
sv,
|
|
66
|
+
tv,
|
|
67
|
+
nv,
|
|
68
|
+
bv,
|
|
69
|
+
dtv,
|
|
70
|
+
rv,
|
|
71
|
+
nullv,
|
|
72
|
+
} from "./types.js";
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stigmem TypeScript SDK — type definitions (spec v0.4/v0.5).
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// FactValue
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
export interface StringValue { type: "string"; v: string }
|
|
10
|
+
export interface TextValue { type: "text"; v: string }
|
|
11
|
+
export interface NumberValue { type: "number"; v: number }
|
|
12
|
+
export interface BooleanValue { type: "boolean"; v: boolean }
|
|
13
|
+
export interface DatetimeValue{ type: "datetime"; v: string } // ISO 8601
|
|
14
|
+
export interface RefValue { type: "ref"; v: string } // URI
|
|
15
|
+
export interface NullValue { type: "null" }
|
|
16
|
+
|
|
17
|
+
export type FactValue =
|
|
18
|
+
| StringValue
|
|
19
|
+
| TextValue
|
|
20
|
+
| NumberValue
|
|
21
|
+
| BooleanValue
|
|
22
|
+
| DatetimeValue
|
|
23
|
+
| RefValue
|
|
24
|
+
| NullValue;
|
|
25
|
+
|
|
26
|
+
export type FactScope = "local" | "team" | "company" | "public";
|
|
27
|
+
|
|
28
|
+
// Value constructors
|
|
29
|
+
export const sv = (v: string): StringValue => ({ type: "string", v });
|
|
30
|
+
export const tv = (v: string): TextValue => ({ type: "text", v });
|
|
31
|
+
export const nv = (v: number): NumberValue => ({ type: "number", v });
|
|
32
|
+
export const bv = (v: boolean): BooleanValue => ({ type: "boolean", v });
|
|
33
|
+
export const dtv = (v: string): DatetimeValue => ({ type: "datetime", v });
|
|
34
|
+
export const rv = (v: string): RefValue => ({ type: "ref", v });
|
|
35
|
+
export const nullv = (): NullValue => ({ type: "null" });
|
|
36
|
+
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Fact
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
export interface Fact {
|
|
42
|
+
id: string;
|
|
43
|
+
entity: string;
|
|
44
|
+
relation: string;
|
|
45
|
+
value: FactValue;
|
|
46
|
+
source: string;
|
|
47
|
+
timestamp: string;
|
|
48
|
+
hlc?: string;
|
|
49
|
+
valid_until?: string;
|
|
50
|
+
confidence: number;
|
|
51
|
+
scope: FactScope;
|
|
52
|
+
contradicted: boolean;
|
|
53
|
+
received_from?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface FactPage {
|
|
57
|
+
facts: Fact[];
|
|
58
|
+
total: number;
|
|
59
|
+
cursor?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
// Peer / Federation
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
export type PeerStatus = "pending_verification" | "active" | "rejected" | "revoked";
|
|
67
|
+
|
|
68
|
+
export interface Peer {
|
|
69
|
+
peer_id: string;
|
|
70
|
+
node_id: string;
|
|
71
|
+
node_url: string;
|
|
72
|
+
status: PeerStatus;
|
|
73
|
+
allowed_scopes: FactScope[];
|
|
74
|
+
established_at?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface PeerPage {
|
|
78
|
+
peers: Peer[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// ---------------------------------------------------------------------------
|
|
82
|
+
// Node info
|
|
83
|
+
// ---------------------------------------------------------------------------
|
|
84
|
+
|
|
85
|
+
export interface FederationEndpoints {
|
|
86
|
+
peers: string;
|
|
87
|
+
facts: string;
|
|
88
|
+
push?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface NodeInfo {
|
|
92
|
+
version: string;
|
|
93
|
+
node_id: string;
|
|
94
|
+
node_url: string;
|
|
95
|
+
auth: "none" | "required";
|
|
96
|
+
federation: "disabled" | "enabled";
|
|
97
|
+
federation_pubkey?: string;
|
|
98
|
+
federation_version?: string;
|
|
99
|
+
federation_endpoints?: FederationEndpoints;
|
|
100
|
+
namespaces: string[];
|
|
101
|
+
spec?: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ---------------------------------------------------------------------------
|
|
105
|
+
// Conflicts
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
export type ConflictStatus = "unresolved" | "resolved";
|
|
109
|
+
|
|
110
|
+
export interface Conflict {
|
|
111
|
+
conflict_id: string;
|
|
112
|
+
fact_a: Fact;
|
|
113
|
+
fact_b: Fact;
|
|
114
|
+
status: ConflictStatus;
|
|
115
|
+
resolved_by?: string;
|
|
116
|
+
detected_at: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface ConflictPage {
|
|
120
|
+
conflicts: Conflict[];
|
|
121
|
+
cursor?: string;
|
|
122
|
+
has_more: boolean;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface ConflictResolution {
|
|
126
|
+
resolution_fact_id: string;
|
|
127
|
+
conflict_status: "resolved";
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ---------------------------------------------------------------------------
|
|
131
|
+
// Request / option shapes
|
|
132
|
+
// ---------------------------------------------------------------------------
|
|
133
|
+
|
|
134
|
+
export interface AssertOptions {
|
|
135
|
+
confidence?: number;
|
|
136
|
+
scope?: FactScope;
|
|
137
|
+
valid_until?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface QueryOptions {
|
|
141
|
+
entity?: string;
|
|
142
|
+
relation?: string;
|
|
143
|
+
source?: string;
|
|
144
|
+
scope?: FactScope;
|
|
145
|
+
min_confidence?: number;
|
|
146
|
+
include_contradicted?: boolean;
|
|
147
|
+
include_expired?: boolean;
|
|
148
|
+
cursor?: string;
|
|
149
|
+
after?: string;
|
|
150
|
+
limit?: number;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface ResolveOptions {
|
|
154
|
+
winning_fact_id?: string;
|
|
155
|
+
resolution_note?: string;
|
|
156
|
+
new_value?: FactValue;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface ConflictListOptions {
|
|
160
|
+
status?: ConflictStatus;
|
|
161
|
+
cursor?: string;
|
|
162
|
+
limit?: number;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface SubscribeOptions {
|
|
166
|
+
intervalMs?: number;
|
|
167
|
+
signal?: AbortSignal;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// ---------------------------------------------------------------------------
|
|
171
|
+
// Lint — v0.7 (spec §14)
|
|
172
|
+
// ---------------------------------------------------------------------------
|
|
173
|
+
|
|
174
|
+
export type LintCheck = "contradiction" | "stale" | "orphan" | "broken_ref";
|
|
175
|
+
export type LintSeverity = "error" | "warning" | "info";
|
|
176
|
+
|
|
177
|
+
export interface LintFinding {
|
|
178
|
+
check: LintCheck;
|
|
179
|
+
severity: LintSeverity;
|
|
180
|
+
entity: string;
|
|
181
|
+
relation: string | null;
|
|
182
|
+
fact_ids: string[];
|
|
183
|
+
detail: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface LintResult {
|
|
187
|
+
findings: LintFinding[];
|
|
188
|
+
checked_at: string;
|
|
189
|
+
scope: FactScope;
|
|
190
|
+
checks_run: LintCheck[];
|
|
191
|
+
fact_count: number;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface LintOptions {
|
|
195
|
+
checks?: LintCheck[];
|
|
196
|
+
entity?: string;
|
|
197
|
+
relation?: string;
|
|
198
|
+
stale_lookahead_s?: number;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ---------------------------------------------------------------------------
|
|
202
|
+
// Recall (Phase 9 — spec §20)
|
|
203
|
+
// ---------------------------------------------------------------------------
|
|
204
|
+
|
|
205
|
+
export interface RecallWeights {
|
|
206
|
+
lexical?: number;
|
|
207
|
+
semantic?: number;
|
|
208
|
+
graph?: number;
|
|
209
|
+
source_trust?: number;
|
|
210
|
+
recency?: number;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface RecallOptions {
|
|
214
|
+
scope?: FactScope;
|
|
215
|
+
token_budget?: number;
|
|
216
|
+
depth?: number;
|
|
217
|
+
weights?: RecallWeights;
|
|
218
|
+
min_confidence?: number;
|
|
219
|
+
include_neighbors?: boolean;
|
|
220
|
+
limit?: number;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface ScoreBreakdown {
|
|
224
|
+
lexical: number;
|
|
225
|
+
semantic: number;
|
|
226
|
+
graph: number;
|
|
227
|
+
source_trust: number;
|
|
228
|
+
recency: number;
|
|
229
|
+
weighted_total: number;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface ScoredFact {
|
|
233
|
+
fact: Fact;
|
|
234
|
+
score: number;
|
|
235
|
+
score_breakdown: ScoreBreakdown;
|
|
236
|
+
hop_distance: number;
|
|
237
|
+
token_estimate: number;
|
|
238
|
+
from_card?: boolean;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface RecallResponse {
|
|
242
|
+
recall_id: string;
|
|
243
|
+
query_hash: string;
|
|
244
|
+
facts: ScoredFact[];
|
|
245
|
+
total_scored: number;
|
|
246
|
+
token_budget: number;
|
|
247
|
+
tokens_used: number;
|
|
248
|
+
truncated: boolean;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
// Memory cards (Phase 9 — spec §20)
|
|
253
|
+
// ---------------------------------------------------------------------------
|
|
254
|
+
|
|
255
|
+
export interface MemoryCard {
|
|
256
|
+
entity_uri: string;
|
|
257
|
+
scope: string;
|
|
258
|
+
summary: string;
|
|
259
|
+
fact_hashes: string[];
|
|
260
|
+
avg_confidence: number;
|
|
261
|
+
refreshed_at?: string;
|
|
262
|
+
is_stale: boolean;
|
|
263
|
+
has_contradictions: boolean;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface CardOptions {
|
|
267
|
+
scope?: FactScope;
|
|
268
|
+
refresh?: boolean;
|
|
269
|
+
}
|