lodestar-ai-sdk 0.2.0 → 0.2.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/index.d.ts +71 -1
- package/dist/index.js +24 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export interface OnAbortRule {
|
|
|
66
66
|
action: OnAbortAction;
|
|
67
67
|
/** Required when `action` is `"retry_with_patch"`. */
|
|
68
68
|
patches?: string[];
|
|
69
|
-
/** Required when `action` is `"fallback_model"` (e.g. `"lodestar-s1-precise"` or BYOK `"gpt-
|
|
69
|
+
/** Required when `action` is `"fallback_model"` (e.g. `"lodestar-s1-precise"` or BYOK `"gpt-6.2-astra"` / `"claude-sonnet-5-5"` / `"gemini-4-carbon"`). */
|
|
70
70
|
model?: string;
|
|
71
71
|
/** Optional provider override for BYOK fallback: `"lodestar" | "openai" | "anthropic" | "gemini" | "custom"`. */
|
|
72
72
|
provider?: "lodestar" | "openai" | "anthropic" | "gemini" | "custom";
|
|
@@ -102,6 +102,7 @@ export interface ChatCreateParams {
|
|
|
102
102
|
onAbort?: OnAbortConfig;
|
|
103
103
|
patches?: string[];
|
|
104
104
|
memoryModel?: string;
|
|
105
|
+
customerId?: string;
|
|
105
106
|
zdr?: boolean;
|
|
106
107
|
max_tokens?: number;
|
|
107
108
|
temperature?: number;
|
|
@@ -112,6 +113,8 @@ export interface AppliedLessonTelemetry {
|
|
|
112
113
|
version: number;
|
|
113
114
|
kind: "guard" | "policy" | "skill" | string;
|
|
114
115
|
delivery_mode: "guard" | "episodic" | "hybrid" | "weight" | string;
|
|
116
|
+
scope?: "shared" | "customer" | string;
|
|
117
|
+
customer_id?: string | null;
|
|
115
118
|
score: number;
|
|
116
119
|
threshold: number;
|
|
117
120
|
view: "full_context" | "last_turn" | string;
|
|
@@ -129,6 +132,7 @@ export interface LodestarMetadata {
|
|
|
129
132
|
model_version?: number;
|
|
130
133
|
lessons_evaluated?: number;
|
|
131
134
|
lessons_applied?: AppliedLessonTelemetry[];
|
|
135
|
+
customer_id?: string | null;
|
|
132
136
|
remediation?: LodestarRemediationMetadata;
|
|
133
137
|
}
|
|
134
138
|
export interface ContinualModelUpstream {
|
|
@@ -145,7 +149,9 @@ export interface ContinualModelCreateParams {
|
|
|
145
149
|
export interface ContinualTeachParams {
|
|
146
150
|
model: string;
|
|
147
151
|
correction?: string;
|
|
152
|
+
customerId?: string;
|
|
148
153
|
traceId?: string;
|
|
154
|
+
traceIds?: string[];
|
|
149
155
|
messages?: ChatMessage[];
|
|
150
156
|
badOutput?: string;
|
|
151
157
|
goodOutput?: string;
|
|
@@ -176,6 +182,8 @@ export interface ContinualLessonResponse {
|
|
|
176
182
|
status: string;
|
|
177
183
|
kind: string;
|
|
178
184
|
delivery_mode: string;
|
|
185
|
+
scope?: "shared" | "customer" | string;
|
|
186
|
+
customer_id?: string | null;
|
|
179
187
|
canary_pct: number;
|
|
180
188
|
consolidation_status: string;
|
|
181
189
|
superseded_by: string | null;
|
|
@@ -195,6 +203,62 @@ export interface ContinualLessonResponse {
|
|
|
195
203
|
created_at: string;
|
|
196
204
|
updated_at: string;
|
|
197
205
|
}
|
|
206
|
+
export interface ContinualRouteParams {
|
|
207
|
+
model: string;
|
|
208
|
+
messages?: ChatMessage[];
|
|
209
|
+
prompt?: string;
|
|
210
|
+
customerId?: string;
|
|
211
|
+
sessionId?: string;
|
|
212
|
+
zdr?: boolean;
|
|
213
|
+
}
|
|
214
|
+
export interface ContinualRouteRule {
|
|
215
|
+
id: string;
|
|
216
|
+
version: number;
|
|
217
|
+
kind: string;
|
|
218
|
+
delivery_mode: string;
|
|
219
|
+
scope: "shared" | "customer" | string;
|
|
220
|
+
customer_id: string | null;
|
|
221
|
+
rule: string;
|
|
222
|
+
score: number;
|
|
223
|
+
threshold: number;
|
|
224
|
+
view: string;
|
|
225
|
+
verified: boolean;
|
|
226
|
+
guard_action?: Record<string, unknown>;
|
|
227
|
+
}
|
|
228
|
+
export interface ContinualRouteResponse {
|
|
229
|
+
object: "lodestar.route";
|
|
230
|
+
id: string;
|
|
231
|
+
model: string;
|
|
232
|
+
model_version: number;
|
|
233
|
+
customer_id: string | null;
|
|
234
|
+
blocked: boolean;
|
|
235
|
+
guard: {
|
|
236
|
+
lesson_id: string;
|
|
237
|
+
version: number;
|
|
238
|
+
scope: string;
|
|
239
|
+
customer_id: string | null;
|
|
240
|
+
rule: string;
|
|
241
|
+
message: string;
|
|
242
|
+
score: number;
|
|
243
|
+
threshold: number;
|
|
244
|
+
} | null;
|
|
245
|
+
lessons_evaluated: number;
|
|
246
|
+
rules: ContinualRouteRule[];
|
|
247
|
+
system_patch: string;
|
|
248
|
+
route_ms: number;
|
|
249
|
+
verifier_used: boolean;
|
|
250
|
+
top_scores: Array<{
|
|
251
|
+
id: string;
|
|
252
|
+
score: number;
|
|
253
|
+
threshold: number;
|
|
254
|
+
view: string;
|
|
255
|
+
}>;
|
|
256
|
+
}
|
|
257
|
+
export interface ContinualCustomerSummary {
|
|
258
|
+
customer_id: string;
|
|
259
|
+
active_lessons: number;
|
|
260
|
+
total_lessons: number;
|
|
261
|
+
}
|
|
198
262
|
export interface ContinualRevertParams {
|
|
199
263
|
model: string;
|
|
200
264
|
lessonId?: string;
|
|
@@ -342,9 +406,15 @@ export declare class Lodestar {
|
|
|
342
406
|
get: (model: string) => Promise<Record<string, unknown>>;
|
|
343
407
|
create: (params: ContinualModelCreateParams) => Promise<Record<string, unknown>>;
|
|
344
408
|
teach: (params: ContinualTeachParams) => Promise<ContinualLessonResponse>;
|
|
409
|
+
route: (params: ContinualRouteParams) => Promise<ContinualRouteResponse>;
|
|
410
|
+
customers: (model: string, opts?: {
|
|
411
|
+
limit?: number;
|
|
412
|
+
}) => Promise<ContinualCustomerSummary[]>;
|
|
345
413
|
revert: (params: ContinualRevertParams) => Promise<ContinualRevertResponse>;
|
|
346
414
|
lessons: (model: string, opts?: {
|
|
347
415
|
status?: string;
|
|
416
|
+
customerId?: string;
|
|
417
|
+
includeShared?: boolean;
|
|
348
418
|
limit?: number;
|
|
349
419
|
}) => Promise<ContinualLessonResponse[]>;
|
|
350
420
|
getLesson: (model: string, lessonId: string) => Promise<ContinualLessonResponse>;
|
package/dist/index.js
CHANGED
|
@@ -83,7 +83,7 @@ export class Lodestar {
|
|
|
83
83
|
export: (probeId) => this.request("GET", `/probes/${encodeURIComponent(probeId)}/export`),
|
|
84
84
|
};
|
|
85
85
|
_chatCreate = (params) => {
|
|
86
|
-
const { probes, abortIf, onAbort, patches, memoryModel, zdr, model, ...rest } = params;
|
|
86
|
+
const { probes, abortIf, onAbort, patches, memoryModel, customerId, zdr, model, ...rest } = params;
|
|
87
87
|
const lodestar = {};
|
|
88
88
|
if (probes?.length)
|
|
89
89
|
lodestar.probes = probes;
|
|
@@ -95,6 +95,8 @@ export class Lodestar {
|
|
|
95
95
|
lodestar.patches = patches;
|
|
96
96
|
if (memoryModel)
|
|
97
97
|
lodestar.memory_model = memoryModel;
|
|
98
|
+
if (customerId)
|
|
99
|
+
lodestar.customer_id = customerId;
|
|
98
100
|
if (zdr !== undefined)
|
|
99
101
|
lodestar.zdr = zdr;
|
|
100
102
|
return this.request("POST", "/chat/completions", {
|
|
@@ -105,7 +107,7 @@ export class Lodestar {
|
|
|
105
107
|
});
|
|
106
108
|
};
|
|
107
109
|
_chatStream = async function* (params) {
|
|
108
|
-
const { probes, abortIf, onAbort, patches, memoryModel, zdr, model, ...rest } = params;
|
|
110
|
+
const { probes, abortIf, onAbort, patches, memoryModel, customerId, zdr, model, ...rest } = params;
|
|
109
111
|
const lodestar = {};
|
|
110
112
|
if (probes?.length)
|
|
111
113
|
lodestar.probes = probes;
|
|
@@ -117,6 +119,8 @@ export class Lodestar {
|
|
|
117
119
|
lodestar.patches = patches;
|
|
118
120
|
if (memoryModel)
|
|
119
121
|
lodestar.memory_model = memoryModel;
|
|
122
|
+
if (customerId)
|
|
123
|
+
lodestar.customer_id = customerId;
|
|
120
124
|
if (zdr !== undefined)
|
|
121
125
|
lodestar.zdr = zdr;
|
|
122
126
|
const res = await this._fetch(`${this.baseUrl}/chat/completions`, {
|
|
@@ -235,7 +239,9 @@ export class Lodestar {
|
|
|
235
239
|
}),
|
|
236
240
|
teach: (params) => this.request("POST", `/models/${encodeURIComponent(params.model)}/teach`, {
|
|
237
241
|
...(params.correction !== undefined ? { correction: params.correction } : {}),
|
|
242
|
+
...(params.customerId !== undefined ? { customer_id: params.customerId } : {}),
|
|
238
243
|
...(params.traceId !== undefined ? { trace_id: params.traceId } : {}),
|
|
244
|
+
...(params.traceIds !== undefined ? { trace_ids: params.traceIds } : {}),
|
|
239
245
|
...(params.messages !== undefined ? { messages: params.messages } : {}),
|
|
240
246
|
...(params.badOutput !== undefined ? { bad_output: params.badOutput } : {}),
|
|
241
247
|
...(params.goodOutput !== undefined ? { good_output: params.goodOutput } : {}),
|
|
@@ -254,6 +260,18 @@ export class Lodestar {
|
|
|
254
260
|
...(params.upstream !== undefined ? { upstream: params.upstream } : {}),
|
|
255
261
|
...(params.zdr !== undefined ? { zdr: params.zdr } : {}),
|
|
256
262
|
}),
|
|
263
|
+
route: (params) => this.request("POST", `/models/${encodeURIComponent(params.model)}/route`, {
|
|
264
|
+
...(params.messages !== undefined ? { messages: params.messages } : {}),
|
|
265
|
+
...(params.prompt !== undefined ? { prompt: params.prompt } : {}),
|
|
266
|
+
...(params.customerId !== undefined ? { customer_id: params.customerId } : {}),
|
|
267
|
+
...(params.sessionId !== undefined ? { session_id: params.sessionId } : {}),
|
|
268
|
+
...(params.zdr !== undefined ? { zdr: params.zdr } : {}),
|
|
269
|
+
}),
|
|
270
|
+
customers: async (model, opts) => {
|
|
271
|
+
const q = opts?.limit ? `?limit=${encodeURIComponent(String(opts.limit))}` : "";
|
|
272
|
+
const out = await this.request("GET", `/models/${encodeURIComponent(model)}/customers${q}`);
|
|
273
|
+
return out.data;
|
|
274
|
+
},
|
|
257
275
|
revert: (params) => this.request("POST", `/models/${encodeURIComponent(params.model)}/revert`, {
|
|
258
276
|
...(params.lessonId !== undefined ? { lesson_id: params.lessonId } : {}),
|
|
259
277
|
...(params.toVersion !== undefined ? { to_version: params.toVersion } : {}),
|
|
@@ -262,6 +280,10 @@ export class Lodestar {
|
|
|
262
280
|
const qs = new URLSearchParams();
|
|
263
281
|
if (opts?.status)
|
|
264
282
|
qs.set("status", opts.status);
|
|
283
|
+
if (opts?.customerId !== undefined)
|
|
284
|
+
qs.set("customer_id", opts.customerId);
|
|
285
|
+
if (opts?.includeShared)
|
|
286
|
+
qs.set("include_shared", "true");
|
|
265
287
|
if (opts?.limit)
|
|
266
288
|
qs.set("limit", String(opts.limit));
|
|
267
289
|
const q = qs.toString();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lodestar-ai-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Zero-dependency TypeScript/JavaScript SDK for Lodestar Glass-Box Inference & Open System-One Probes (api.lodestar.so/v1)",
|
|
5
5
|
"homepage": "https://lodestar.so/docs",
|
|
6
6
|
"repository": {
|