@odla-ai/ai 0.2.1 → 0.3.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 +21 -0
- package/README.md +68 -11
- package/dist/{anthropic-JXDXR7O7.js → anthropic-2NPMHJZT.js} +67 -51
- package/dist/anthropic-2NPMHJZT.js.map +1 -0
- package/dist/chunk-OX4TA4ZH.js +16 -0
- package/dist/chunk-OX4TA4ZH.js.map +1 -0
- package/dist/{chunk-LANGYP65.js → chunk-PXXCN2EU.js} +65 -46
- package/dist/chunk-PXXCN2EU.js.map +1 -0
- package/dist/chunk-U7F6VJCV.js +9 -0
- package/dist/chunk-U7F6VJCV.js.map +1 -0
- package/dist/{google-3TFOFIQO.js → google-3XV2VWVB.js} +50 -31
- package/dist/google-3XV2VWVB.js.map +1 -0
- package/dist/index.cjs +867 -132
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +194 -74
- package/dist/index.d.ts +194 -74
- package/dist/index.js +578 -57
- package/dist/index.js.map +1 -1
- package/dist/{openai-XZRXMKCC.js → openai-NTQCF577.js} +54 -36
- package/dist/openai-NTQCF577.js.map +1 -0
- package/llms.txt +35 -12
- package/package.json +12 -5
- package/dist/anthropic-JXDXR7O7.js.map +0 -1
- package/dist/chunk-LANGYP65.js.map +0 -1
- package/dist/google-3TFOFIQO.js.map +0 -1
- package/dist/openai-XZRXMKCC.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -83,6 +83,18 @@ interface OracleMessage {
|
|
|
83
83
|
* multi-modal / tool turns. */
|
|
84
84
|
content: string | OracleContentBlock[];
|
|
85
85
|
}
|
|
86
|
+
|
|
87
|
+
interface OracleUsage {
|
|
88
|
+
inputTokens: number;
|
|
89
|
+
outputTokens: number;
|
|
90
|
+
cacheCreationTokens?: number;
|
|
91
|
+
cacheReadTokens?: number;
|
|
92
|
+
}
|
|
93
|
+
/** A fresh zeroed usage tally (0 input/output tokens, no cache fields) — the seed for accumulation. */
|
|
94
|
+
declare function emptyUsage(): OracleUsage;
|
|
95
|
+
/** Accumulate `more` into `into`, in place. Cache fields sum when present. */
|
|
96
|
+
declare function addUsage(into: OracleUsage, more: OracleUsage): void;
|
|
97
|
+
|
|
86
98
|
interface OracleTool {
|
|
87
99
|
name: string;
|
|
88
100
|
description: string;
|
|
@@ -129,16 +141,13 @@ interface OracleRequest {
|
|
|
129
141
|
/** Provider-specific escape hatch, passed through opaquely. Using it gives up
|
|
130
142
|
* portability across providers. */
|
|
131
143
|
providerExtras?: Record<string, unknown>;
|
|
144
|
+
/** Cancel the provider request. Adapters pass this to the vendor SDK rather
|
|
145
|
+
* than limiting cancellation to local tool handlers. */
|
|
146
|
+
signal?: AbortSignal;
|
|
147
|
+
/** Absolute Unix timestamp in milliseconds. The SDK combines this deadline
|
|
148
|
+
* with `signal`; whichever fires first cancels the provider request. */
|
|
149
|
+
deadline?: number;
|
|
132
150
|
}
|
|
133
|
-
interface OracleUsage {
|
|
134
|
-
inputTokens: number;
|
|
135
|
-
outputTokens: number;
|
|
136
|
-
cacheCreationTokens?: number;
|
|
137
|
-
cacheReadTokens?: number;
|
|
138
|
-
}
|
|
139
|
-
declare function emptyUsage(): OracleUsage;
|
|
140
|
-
/** Accumulate `more` into `into`, in place. Cache fields sum when present. */
|
|
141
|
-
declare function addUsage(into: OracleUsage, more: OracleUsage): void;
|
|
142
151
|
type OracleStopReason = "end_turn" | "max_tokens" | "stop_sequence" | "tool_use" | "pause_turn" | "refusal" | "error";
|
|
143
152
|
interface OracleResponse {
|
|
144
153
|
id: string;
|
|
@@ -150,62 +159,10 @@ interface OracleResponse {
|
|
|
150
159
|
stopReason: OracleStopReason;
|
|
151
160
|
usage: OracleUsage;
|
|
152
161
|
}
|
|
153
|
-
|
|
154
|
-
* provider. The anthropic adapter passes these through nearly 1:1; the openai
|
|
155
|
-
* and google adapters map their native streams onto this shape. */
|
|
156
|
-
type OracleEvent = MessageStartEvent | ContentBlockStartEvent | ContentBlockDeltaEvent | ContentBlockStopEvent | MessageDeltaEvent | MessageStopEvent | OracleErrorEvent;
|
|
157
|
-
interface MessageStartEvent {
|
|
158
|
-
type: "message_start";
|
|
159
|
-
message: {
|
|
160
|
-
id: string;
|
|
161
|
-
model: string;
|
|
162
|
-
provider: ProviderId;
|
|
163
|
-
role: "assistant";
|
|
164
|
-
content: [];
|
|
165
|
-
usage: OracleUsage;
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
interface ContentBlockStartEvent {
|
|
169
|
-
type: "content_block_start";
|
|
170
|
-
index: number;
|
|
171
|
-
contentBlock: OracleContentBlock;
|
|
172
|
-
}
|
|
173
|
-
type ContentBlockDelta = {
|
|
174
|
-
type: "text_delta";
|
|
175
|
-
text: string;
|
|
176
|
-
} | {
|
|
177
|
-
type: "thinking_delta";
|
|
178
|
-
thinking: string;
|
|
179
|
-
} | {
|
|
180
|
-
type: "input_json_delta";
|
|
181
|
-
partialJson: string;
|
|
182
|
-
};
|
|
183
|
-
interface ContentBlockDeltaEvent {
|
|
184
|
-
type: "content_block_delta";
|
|
185
|
-
index: number;
|
|
186
|
-
delta: ContentBlockDelta;
|
|
187
|
-
}
|
|
188
|
-
interface ContentBlockStopEvent {
|
|
189
|
-
type: "content_block_stop";
|
|
190
|
-
index: number;
|
|
191
|
-
}
|
|
192
|
-
interface MessageDeltaEvent {
|
|
193
|
-
type: "message_delta";
|
|
194
|
-
delta: {
|
|
195
|
-
stopReason?: OracleStopReason;
|
|
196
|
-
};
|
|
197
|
-
usage: OracleUsage;
|
|
198
|
-
}
|
|
199
|
-
interface MessageStopEvent {
|
|
200
|
-
type: "message_stop";
|
|
201
|
-
}
|
|
202
|
-
interface OracleErrorEvent {
|
|
203
|
-
type: "error";
|
|
204
|
-
error: OracleErrorShape;
|
|
205
|
-
}
|
|
162
|
+
|
|
206
163
|
/** The closed taxonomy of normalized error codes carried by every OdlaAIError
|
|
207
164
|
* and by the streaming `error` event. */
|
|
208
|
-
type OracleErrorType = "invalid_request" | "auth" | "rate_limit" | "context_window" | "tool_input_invalid" | "capability_unsupported" | "config" | "provider_error";
|
|
165
|
+
type OracleErrorType = "invalid_request" | "auth" | "rate_limit" | "context_window" | "cancelled" | "deadline_exceeded" | "tool_input_invalid" | "capability_unsupported" | "config" | "provider_error";
|
|
209
166
|
/** The plain-data error shape used inside the streaming `error` event. */
|
|
210
167
|
interface OracleErrorShape {
|
|
211
168
|
code: OracleErrorType;
|
|
@@ -269,6 +226,29 @@ declare class InvalidRequestError extends OdlaAIError {
|
|
|
269
226
|
cause?: unknown;
|
|
270
227
|
});
|
|
271
228
|
}
|
|
229
|
+
/** A provider returned tool arguments that are malformed or do not satisfy the
|
|
230
|
+
* declared JSON Schema. Tool handlers are never invoked for this error. */
|
|
231
|
+
declare class ToolInputError extends OdlaAIError {
|
|
232
|
+
readonly tool?: string;
|
|
233
|
+
constructor(message: string, opts?: {
|
|
234
|
+
tool?: string;
|
|
235
|
+
cause?: unknown;
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/** The caller cancelled a request. This is not an upstream failure and should
|
|
239
|
+
* not be retried unless the caller explicitly starts a new operation. */
|
|
240
|
+
declare class CancelledError extends OdlaAIError {
|
|
241
|
+
constructor(message?: string, opts?: {
|
|
242
|
+
cause?: unknown;
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/** The request's absolute deadline elapsed. Callers may choose a new deadline,
|
|
246
|
+
* but should not classify this as a provider outage. */
|
|
247
|
+
declare class DeadlineExceededError extends OdlaAIError {
|
|
248
|
+
constructor(message?: string, opts?: {
|
|
249
|
+
cause?: unknown;
|
|
250
|
+
});
|
|
251
|
+
}
|
|
272
252
|
/** Any other upstream provider failure (5xx, transport, unexpected shape). */
|
|
273
253
|
declare class ProviderError extends OdlaAIError {
|
|
274
254
|
constructor(message: string, opts?: {
|
|
@@ -276,12 +256,74 @@ declare class ProviderError extends OdlaAIError {
|
|
|
276
256
|
cause?: unknown;
|
|
277
257
|
});
|
|
278
258
|
}
|
|
259
|
+
|
|
260
|
+
/** A discriminated union of SSE events with the same vocabulary regardless of
|
|
261
|
+
* provider. The anthropic adapter passes these through nearly 1:1; the openai
|
|
262
|
+
* and google adapters map their native streams onto this shape. */
|
|
263
|
+
type OracleEvent = MessageStartEvent | ContentBlockStartEvent | ContentBlockDeltaEvent | ContentBlockStopEvent | MessageDeltaEvent | MessageStopEvent | OracleErrorEvent;
|
|
264
|
+
interface MessageStartEvent {
|
|
265
|
+
type: "message_start";
|
|
266
|
+
message: {
|
|
267
|
+
id: string;
|
|
268
|
+
model: string;
|
|
269
|
+
provider: ProviderId;
|
|
270
|
+
role: "assistant";
|
|
271
|
+
content: [];
|
|
272
|
+
usage: OracleUsage;
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
interface ContentBlockStartEvent {
|
|
276
|
+
type: "content_block_start";
|
|
277
|
+
index: number;
|
|
278
|
+
contentBlock: OracleContentBlock;
|
|
279
|
+
}
|
|
280
|
+
type ContentBlockDelta = {
|
|
281
|
+
type: "text_delta";
|
|
282
|
+
text: string;
|
|
283
|
+
} | {
|
|
284
|
+
type: "thinking_delta";
|
|
285
|
+
thinking: string;
|
|
286
|
+
} | {
|
|
287
|
+
type: "input_json_delta";
|
|
288
|
+
partialJson: string;
|
|
289
|
+
};
|
|
290
|
+
interface ContentBlockDeltaEvent {
|
|
291
|
+
type: "content_block_delta";
|
|
292
|
+
index: number;
|
|
293
|
+
delta: ContentBlockDelta;
|
|
294
|
+
}
|
|
295
|
+
interface ContentBlockStopEvent {
|
|
296
|
+
type: "content_block_stop";
|
|
297
|
+
index: number;
|
|
298
|
+
}
|
|
299
|
+
interface MessageDeltaEvent {
|
|
300
|
+
type: "message_delta";
|
|
301
|
+
delta: {
|
|
302
|
+
stopReason?: OracleStopReason;
|
|
303
|
+
};
|
|
304
|
+
usage: OracleUsage;
|
|
305
|
+
}
|
|
306
|
+
interface MessageStopEvent {
|
|
307
|
+
type: "message_stop";
|
|
308
|
+
}
|
|
309
|
+
interface OracleErrorEvent {
|
|
310
|
+
type: "error";
|
|
311
|
+
error: OracleErrorShape;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** Type guard: narrows a content block to a `TextBlock` (`type: "text"`). */
|
|
279
315
|
declare function isTextBlock(b: OracleContentBlock): b is TextBlock;
|
|
316
|
+
/** Type guard: narrows a content block to an `ImageBlock` (`type: "image"`). */
|
|
280
317
|
declare function isImageBlock(b: OracleContentBlock): b is ImageBlock;
|
|
318
|
+
/** Type guard: narrows a content block to an `AudioBlock` (`type: "audio"`). */
|
|
281
319
|
declare function isAudioBlock(b: OracleContentBlock): b is AudioBlock;
|
|
320
|
+
/** Type guard: narrows a content block to a `DocumentBlock` (`type: "document"`). */
|
|
282
321
|
declare function isDocumentBlock(b: OracleContentBlock): b is DocumentBlock;
|
|
322
|
+
/** Type guard: narrows a content block to a `ToolUseBlock` (`type: "tool_use"`). */
|
|
283
323
|
declare function isToolUseBlock(b: OracleContentBlock): b is ToolUseBlock;
|
|
324
|
+
/** Type guard: narrows a content block to a `ToolResultBlock` (`type: "tool_result"`). */
|
|
284
325
|
declare function isToolResultBlock(b: OracleContentBlock): b is ToolResultBlock;
|
|
326
|
+
/** Type guard: narrows a content block to a `ThinkingBlock` (`type: "thinking"`). */
|
|
285
327
|
declare function isThinkingBlock(b: OracleContentBlock): b is ThinkingBlock;
|
|
286
328
|
/** Normalize a message's `content` (string shorthand or block array) to blocks. */
|
|
287
329
|
declare function blocksOf(content: string | OracleContentBlock[]): OracleContentBlock[];
|
|
@@ -290,6 +332,20 @@ declare function extractText(content: OracleContentBlock[]): string;
|
|
|
290
332
|
/** Collect every tool_use block from response or message content. */
|
|
291
333
|
declare function extractToolUses(content: OracleContentBlock[]): ToolUseBlock[];
|
|
292
334
|
|
|
335
|
+
/** One deterministic validation failure at a JSONPath-like location. */
|
|
336
|
+
interface JsonSchemaIssue {
|
|
337
|
+
path: string;
|
|
338
|
+
message: string;
|
|
339
|
+
}
|
|
340
|
+
/** Complete supported-subset schema validation result; unknown keywords fail validation. */
|
|
341
|
+
interface JsonSchemaValidation {
|
|
342
|
+
valid: boolean;
|
|
343
|
+
issues: JsonSchemaIssue[];
|
|
344
|
+
}
|
|
345
|
+
/** Validate a JSON-compatible value against the supported JSON Schema subset.
|
|
346
|
+
* Unknown or unsupported keywords are validation failures, not ignored hints. */
|
|
347
|
+
declare function validateJsonSchema(schema: unknown, value: unknown): JsonSchemaValidation;
|
|
348
|
+
|
|
293
349
|
/** The kind of model — chat/multimodal is the v1 focus; the others are modeled
|
|
294
350
|
* so embeddings, transcription, TTS, and image generation slot in later. */
|
|
295
351
|
type ModelKind = "chat" | "embed" | "transcribe" | "tts" | "image";
|
|
@@ -337,10 +393,13 @@ declare function chatCapabilities(overrides?: Partial<Capabilities>): Capabiliti
|
|
|
337
393
|
*/
|
|
338
394
|
declare function validateRequest(spec: ModelSpec, req: OracleRequest): void;
|
|
339
395
|
|
|
396
|
+
/** Built-in Anthropic (Claude) catalog: one `ModelSpec` per model (canonical id, native id, capabilities, limits). */
|
|
340
397
|
declare const ANTHROPIC_MODELS: ModelSpec[];
|
|
341
398
|
|
|
399
|
+
/** Built-in OpenAI catalog: one `ModelSpec` per model (canonical id == native id, capabilities, context window). */
|
|
342
400
|
declare const OPENAI_MODELS: ModelSpec[];
|
|
343
401
|
|
|
402
|
+
/** Built-in Google (Gemini) catalog: one `ModelSpec` per model (canonical id == native id, capabilities, context window). */
|
|
344
403
|
declare const GOOGLE_MODELS: ModelSpec[];
|
|
345
404
|
|
|
346
405
|
/** Canonical id → spec. */
|
|
@@ -412,6 +471,8 @@ interface ExtractCall {
|
|
|
412
471
|
user: string | OracleContentBlock[];
|
|
413
472
|
tool: ExtractTool;
|
|
414
473
|
maxTokens?: number;
|
|
474
|
+
signal?: AbortSignal;
|
|
475
|
+
deadline?: number;
|
|
415
476
|
}
|
|
416
477
|
/** A web-search-enabled call: the model searches and returns prose. */
|
|
417
478
|
interface SearchCall {
|
|
@@ -419,6 +480,8 @@ interface SearchCall {
|
|
|
419
480
|
system?: string | TextBlock[];
|
|
420
481
|
user: string | OracleContentBlock[];
|
|
421
482
|
maxTokens?: number;
|
|
483
|
+
signal?: AbortSignal;
|
|
484
|
+
deadline?: number;
|
|
422
485
|
}
|
|
423
486
|
interface Ai {
|
|
424
487
|
/** The active model catalog. */
|
|
@@ -440,11 +503,23 @@ interface Ai {
|
|
|
440
503
|
}
|
|
441
504
|
/** The minimal inference surface the agent loop and eval harness depend on. */
|
|
442
505
|
type Inference = Pick<Ai, "chat" | "stream" | "catalog">;
|
|
506
|
+
/**
|
|
507
|
+
* Build the `Ai` facade (bring-your-own-keys). Resolves a canonical model id to
|
|
508
|
+
* its provider, supplies keys statically (`keys`) or dynamically (`resolveKey`),
|
|
509
|
+
* validates each request against the model's capabilities, and exposes
|
|
510
|
+
* `chat`/`stream`/`extract`/`search` plus the active `catalog`. Only the SDK of a
|
|
511
|
+
* provider you actually call is loaded (via the lazy provider registry).
|
|
512
|
+
*/
|
|
443
513
|
declare function init(opts?: InitOptions): Ai;
|
|
444
514
|
|
|
445
515
|
/** Generate the `llms.txt` context document for a given model catalog. */
|
|
446
516
|
declare function generateLlmsTxt(catalog?: Catalog): string;
|
|
447
517
|
|
|
518
|
+
/**
|
|
519
|
+
* Resolve the adapter for a provider, lazy-`import()`ing its module (and only
|
|
520
|
+
* that provider's SDK) on first use and caching the instance per (provider, key)
|
|
521
|
+
* so repeated calls reuse one SDK client.
|
|
522
|
+
*/
|
|
448
523
|
declare function getProvider(id: ProviderId, apiKey: string): Promise<Provider>;
|
|
449
524
|
/** Test seam: register a provider instance directly (used to inject mocks). */
|
|
450
525
|
declare function registerProvider(id: ProviderId, apiKey: string, provider: Provider): void;
|
|
@@ -453,10 +528,11 @@ declare function clearProviderCache(): void;
|
|
|
453
528
|
|
|
454
529
|
/** Map any provider error to an OdlaAIError, returning it (does not throw).
|
|
455
530
|
* Re-returns an OdlaAIError unchanged (already normalized). */
|
|
456
|
-
declare function normalizeError(err: unknown, provider: ProviderId): OdlaAIError;
|
|
531
|
+
declare function normalizeError(err: unknown, provider: ProviderId, signal?: AbortSignal): OdlaAIError;
|
|
457
532
|
|
|
458
533
|
type TaintLabel = "web_untrusted" | "operator_pasted_untrusted" | "llm_inherited" | `tool_untrusted:${string}`;
|
|
459
534
|
type TaintSet = Set<TaintLabel>;
|
|
535
|
+
/** Build a `TaintSet` from labels — the CaMeL-style taint carried through a run and checked against each tool's allowlist. */
|
|
460
536
|
declare function taint(...labels: TaintLabel[]): TaintSet;
|
|
461
537
|
/** Raised when a tool's taint allowlist doesn't cover the conversation's taint. */
|
|
462
538
|
declare class TaintError extends OdlaAIError {
|
|
@@ -567,8 +643,20 @@ interface AgentRunInput {
|
|
|
567
643
|
/** Or an explicit list of messages (takes precedence when both are given). */
|
|
568
644
|
messages?: OracleMessage[];
|
|
569
645
|
signal?: AbortSignal;
|
|
570
|
-
|
|
571
|
-
|
|
646
|
+
/** Absolute Unix timestamp in milliseconds for model requests and tools. */
|
|
647
|
+
deadline?: number;
|
|
648
|
+
/** Run-wide limits. Token limits are evaluated after each provider response;
|
|
649
|
+
* output allowance also caps the next request's maxTokens. */
|
|
650
|
+
budget?: AgentRunBudget;
|
|
651
|
+
}
|
|
652
|
+
/** Run-wide limits: tool calls stop before effects; token usage stops later turns after provider reporting. */
|
|
653
|
+
interface AgentRunBudget {
|
|
654
|
+
maxInputTokens?: number;
|
|
655
|
+
maxOutputTokens?: number;
|
|
656
|
+
maxTotalTokens?: number;
|
|
657
|
+
maxToolCalls?: number;
|
|
658
|
+
}
|
|
659
|
+
type StoppedReason = "end_turn" | "max_steps" | "refusal" | "budget_exhausted";
|
|
572
660
|
interface AgentRun {
|
|
573
661
|
/** Concatenated text of the final assistant turn. */
|
|
574
662
|
finalText: string;
|
|
@@ -584,6 +672,14 @@ interface AgentRun {
|
|
|
584
672
|
toolCalls: ToolCallRecord[];
|
|
585
673
|
stoppedReason: StoppedReason;
|
|
586
674
|
}
|
|
675
|
+
/**
|
|
676
|
+
* Run the tool-use agent loop: model turn → execute requested tools → model turn,
|
|
677
|
+
* until the model stops asking for tools (`end_turn`), refuses (`refusal`), or
|
|
678
|
+
* `persona.maxSteps` (default 8) is hit (`max_steps`). Composes the persona's
|
|
679
|
+
* skills into its tools/system prompt, enforces per-tool taint allowlists, and
|
|
680
|
+
* loads/appends `persona.memory` when set. Returns `{ finalText, response,
|
|
681
|
+
* messages, usage, steps, toolCalls, stoppedReason }`.
|
|
682
|
+
*/
|
|
587
683
|
declare function runAgent(inference: Inference, persona: Persona, input: AgentRunInput): Promise<AgentRun>;
|
|
588
684
|
|
|
589
685
|
/** One evaluation case — an input plus whatever the grader needs to judge it. */
|
|
@@ -638,6 +734,12 @@ interface EvaluateOptions {
|
|
|
638
734
|
/** Max cases run concurrently (default 5). */
|
|
639
735
|
concurrency?: number;
|
|
640
736
|
}
|
|
737
|
+
/**
|
|
738
|
+
* Eval harness: run each case through a `persona` (agent loop) or a plain `model`
|
|
739
|
+
* chat, grade it with `grader`, and return an `EvalReport` (per-case results,
|
|
740
|
+
* pass/fail counts, passRate, summed usage). Cases run concurrently up to
|
|
741
|
+
* `concurrency` (default 5); throws if neither `persona` nor `model` is given.
|
|
742
|
+
*/
|
|
641
743
|
declare function evaluate(opts: EvaluateOptions): Promise<EvalReport>;
|
|
642
744
|
|
|
643
745
|
/** Pass when trimmed output equals `case.expected` (stringified). */
|
|
@@ -854,10 +956,15 @@ type OdlaOp = {
|
|
|
854
956
|
type OdlaQuery = Record<string, unknown>;
|
|
855
957
|
/** The subset of the odla-db Admin client odla-ai uses. */
|
|
856
958
|
interface OdlaDbClient {
|
|
857
|
-
/** Apply ops atomically; a stable `mutationId` gives exactly-once replay.
|
|
959
|
+
/** Apply ops atomically; a stable `mutationId` gives exactly-once replay.
|
|
960
|
+
* Mirrors odla-db 0.5's AdminDb: `duplicate` means the mutationId was
|
|
961
|
+
* already applied and the ops did not re-run. */
|
|
858
962
|
transact(ops: OdlaOp[], opts?: {
|
|
859
963
|
mutationId?: string;
|
|
860
|
-
}): Promise<
|
|
964
|
+
}): Promise<{
|
|
965
|
+
txId: number;
|
|
966
|
+
duplicate: boolean;
|
|
967
|
+
}>;
|
|
861
968
|
/** Run an InstaQL query; returns namespace → rows. */
|
|
862
969
|
query(query: OdlaQuery): Promise<Record<string, Record<string, unknown>[]>>;
|
|
863
970
|
/** Read one of this app's secrets by name (app-key credential; read-only). */
|
|
@@ -878,6 +985,12 @@ interface OdlaDbMemoryOptions {
|
|
|
878
985
|
conversation?: string;
|
|
879
986
|
};
|
|
880
987
|
}
|
|
988
|
+
/**
|
|
989
|
+
* A `MemoryScope` backed by odla-db. `load()` replays a session's prior turns
|
|
990
|
+
* (ordered by `seq`); `append()` upserts new turns by natural key under a
|
|
991
|
+
* deterministic `mutationId`, so a retried run never duplicates. Takes an
|
|
992
|
+
* injected odla-db client — odla-ai keeps zero runtime dependency on @odla-ai/db.
|
|
993
|
+
*/
|
|
881
994
|
declare class OdlaDbMemory implements MemoryScope {
|
|
882
995
|
private readonly db;
|
|
883
996
|
private readonly sessionId;
|
|
@@ -918,6 +1031,12 @@ interface OdlaDbKeyResolverOptions {
|
|
|
918
1031
|
secretName?: (provider: ProviderId) => string;
|
|
919
1032
|
/** Cache resolved keys in memory (default true). */
|
|
920
1033
|
cache?: boolean;
|
|
1034
|
+
/** Maximum age for a cached secret (default 60 seconds; 0 disables caching).
|
|
1035
|
+
* This bounds provider-key rotation propagation in warm isolates. */
|
|
1036
|
+
ttlMs?: number;
|
|
1037
|
+
/** Version included in the cache key. Change it to invalidate a known key
|
|
1038
|
+
* generation immediately without waiting for the TTL. */
|
|
1039
|
+
cacheVersion?: string | ((provider: ProviderId) => string);
|
|
921
1040
|
}
|
|
922
1041
|
/** Build a KeyResolver that reads provider keys from odla-db secrets. A missing
|
|
923
1042
|
* secret resolves to `undefined` (→ that provider is simply unavailable, and
|
|
@@ -941,6 +1060,8 @@ interface InitFromPlatformOptions {
|
|
|
941
1060
|
* owned by this helper; `defaultModel` is used only when the platform
|
|
942
1061
|
* config sets no model. */
|
|
943
1062
|
initOptions?: Omit<InitOptions, "resolveKey">;
|
|
1063
|
+
/** Secret resolver cache controls. Defaults to a finite 60-second TTL. */
|
|
1064
|
+
keyResolverOptions?: OdlaDbKeyResolverOptions;
|
|
944
1065
|
}
|
|
945
1066
|
interface PlatformAi {
|
|
946
1067
|
ai: Ai;
|
|
@@ -950,15 +1071,14 @@ interface PlatformAi {
|
|
|
950
1071
|
/** Drop all cached platform configs (tests, or to force an immediate refetch). */
|
|
951
1072
|
declare function clearPlatformAiCache(): void;
|
|
952
1073
|
/** Build an `Ai` from the app's platform registration: provider/model from
|
|
953
|
-
*
|
|
954
|
-
*
|
|
955
|
-
*
|
|
956
|
-
* `db`/`initOptions` are captured for the cache entry's lifetime. */
|
|
1074
|
+
* public-config (cached ~60s), API key from the supplied tenant's odla-db
|
|
1075
|
+
* secrets at call time. Only public config is shared globally; every call
|
|
1076
|
+
* builds a facade bound to its own `db` and init options. */
|
|
957
1077
|
declare function initFromPlatform(opts: InitFromPlatformOptions): Promise<PlatformAi>;
|
|
958
1078
|
|
|
959
1079
|
type FetchLike = typeof fetch;
|
|
960
1080
|
interface ProvisionContext {
|
|
961
|
-
/**
|
|
1081
|
+
/** Platform origin exposing the proxied db operator routes, normally https://odla.ai. */
|
|
962
1082
|
endpoint: string;
|
|
963
1083
|
/** Operator `ADMIN_SECRET` or an `odla_dev_...` developer token (owns the app). */
|
|
964
1084
|
token: string;
|
|
@@ -1040,4 +1160,4 @@ interface EntityCrudSkillOptions {
|
|
|
1040
1160
|
/** Build a CRUD Skill for one odla-db entity. */
|
|
1041
1161
|
declare function entityCrudSkill(opts: EntityCrudSkillOptions): Skill;
|
|
1042
1162
|
|
|
1043
|
-
export { AGENT_SCHEMA, ANTHROPIC_MODELS, type AgentRun, type AgentRunInput, type Ai, type AudioBlock, type AudioMediaType, type AudioSource, AuthError, type Capabilities, CapabilityError, type Catalog, type ChatInput, type ComposedPersona, ConfigError, type ContentBlockDelta, type ContentBlockDeltaEvent, type ContentBlockStartEvent, type ContentBlockStopEvent, ContextWindowError, DEFAULT_CATALOG, DEFAULT_SECRET_NAMES, type DocumentBlock, type DocumentSource, type Effort, type EntityCrudSkillOptions, type EvalCase, type EvalReport, type EvalResult, type EvaluateOptions, type ExtractCall, type ExtractTool, GOOGLE_MODELS, type GradeContext, type GradeResult, type Grader, type ImageBlock, type ImageMediaType, type ImageSource, InMemoryScope, type Inference, type InitFromPlatformOptions, type InitOptions, InvalidRequestError, type KeyMap, type KeyOptions, type KeyResolver, type MemoryScope, type MessageDeltaEvent, type MessageStartEvent, type MessageStopEvent, type ModelKind, type ModelSpec, NS, OPENAI_MODELS, OdlaAIError, type OdlaDbClient, type OdlaDbKeyResolverOptions, OdlaDbMemory, type OdlaDbMemoryOptions, type OdlaEntityRef, type OdlaLookup, type OdlaOp, type OdlaQuery, type OdlaScalar, type OracleContentBlock, type OracleErrorEvent, type OracleErrorShape, type OracleErrorType, type OracleEvent, type OracleMessage, type OracleRequest, type OracleResponse, type OracleRole, type OracleStopReason, type OracleTool, type OracleUsage, type PersistRunOptions, type Persona, type PlatformAi, type Provider, ProviderError, type ProviderFactory, type ProviderId, type ProvisionAgentAppOptions, type ProvisionContext, type ProvisionedApp, type QueryRunsOptions, RateLimitError, type ResponseFormat, type SearchCall, type Skill, type StoppedReason, TaintError, type TaintLabel, type TaintSet, type TextBlock, type ThinkingBlock, type ThinkingMode, type ToolCallRecord, type ToolChoice, type ToolContext, type ToolDef, type ToolHandler, type ToolOutput, type ToolResultBlock, type ToolUseBlock, addUsage, assertSinkAcceptsTaint, blocksOf, buildCatalog, chatCapabilities, clearPlatformAiCache, clearProviderCache, composeSkills, createApp, emptyUsage, entityCrudSkill, evaluate, exactMatch, extractText, extractToolUses, generateLlmsTxt, getProvider, includes, init, initFromPlatform, isAudioBlock, isDocumentBlock, isImageBlock, isTextBlock, isThinkingBlock, isToolResultBlock, isToolUseBlock, llmJudge, looksLikeKey, mintAppKey, normalizeError, odlaDbKeyResolver, persistRun, providersInCatalog, provisionAgentApp, pushAgentSchema, putSecret, queryRuns, redact, registerProvider, resolveModel, runAgent, structuredMatch, taint, toOracleTool, validateRequest };
|
|
1163
|
+
export { AGENT_SCHEMA, ANTHROPIC_MODELS, type AgentRun, type AgentRunBudget, type AgentRunInput, type Ai, type AudioBlock, type AudioMediaType, type AudioSource, AuthError, CancelledError, type Capabilities, CapabilityError, type Catalog, type ChatInput, type ComposedPersona, ConfigError, type ContentBlockDelta, type ContentBlockDeltaEvent, type ContentBlockStartEvent, type ContentBlockStopEvent, ContextWindowError, DEFAULT_CATALOG, DEFAULT_SECRET_NAMES, DeadlineExceededError, type DocumentBlock, type DocumentSource, type Effort, type EntityCrudSkillOptions, type EvalCase, type EvalReport, type EvalResult, type EvaluateOptions, type ExtractCall, type ExtractTool, GOOGLE_MODELS, type GradeContext, type GradeResult, type Grader, type ImageBlock, type ImageMediaType, type ImageSource, InMemoryScope, type Inference, type InitFromPlatformOptions, type InitOptions, InvalidRequestError, type JsonSchemaIssue, type JsonSchemaValidation, type KeyMap, type KeyOptions, type KeyResolver, type MemoryScope, type MessageDeltaEvent, type MessageStartEvent, type MessageStopEvent, type ModelKind, type ModelSpec, NS, OPENAI_MODELS, OdlaAIError, type OdlaDbClient, type OdlaDbKeyResolverOptions, OdlaDbMemory, type OdlaDbMemoryOptions, type OdlaEntityRef, type OdlaLookup, type OdlaOp, type OdlaQuery, type OdlaScalar, type OracleContentBlock, type OracleErrorEvent, type OracleErrorShape, type OracleErrorType, type OracleEvent, type OracleMessage, type OracleRequest, type OracleResponse, type OracleRole, type OracleStopReason, type OracleTool, type OracleUsage, type PersistRunOptions, type Persona, type PlatformAi, type Provider, ProviderError, type ProviderFactory, type ProviderId, type ProvisionAgentAppOptions, type ProvisionContext, type ProvisionedApp, type QueryRunsOptions, RateLimitError, type ResponseFormat, type SearchCall, type Skill, type StoppedReason, TaintError, type TaintLabel, type TaintSet, type TextBlock, type ThinkingBlock, type ThinkingMode, type ToolCallRecord, type ToolChoice, type ToolContext, type ToolDef, type ToolHandler, ToolInputError, type ToolOutput, type ToolResultBlock, type ToolUseBlock, addUsage, assertSinkAcceptsTaint, blocksOf, buildCatalog, chatCapabilities, clearPlatformAiCache, clearProviderCache, composeSkills, createApp, emptyUsage, entityCrudSkill, evaluate, exactMatch, extractText, extractToolUses, generateLlmsTxt, getProvider, includes, init, initFromPlatform, isAudioBlock, isDocumentBlock, isImageBlock, isTextBlock, isThinkingBlock, isToolResultBlock, isToolUseBlock, llmJudge, looksLikeKey, mintAppKey, normalizeError, odlaDbKeyResolver, persistRun, providersInCatalog, provisionAgentApp, pushAgentSchema, putSecret, queryRuns, redact, registerProvider, resolveModel, runAgent, structuredMatch, taint, toOracleTool, validateJsonSchema, validateRequest };
|