@arnilo/prism 0.4.0 → 0.5.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/CHANGELOG.md +41 -1
- package/README.md +23 -20
- package/dist/agent-run-state.d.ts +1 -2
- package/dist/agent-run-state.js +0 -3
- package/dist/agent-session/session/assemble.d.ts +6 -0
- package/dist/agent-session/session/assemble.js +391 -0
- package/dist/agent-session/session/persist.d.ts +28 -0
- package/dist/agent-session/session/persist.js +166 -0
- package/dist/agent-session/session/provider-round.d.ts +6 -0
- package/dist/agent-session/session/provider-round.js +231 -0
- package/dist/agent-session/session/tool-round.d.ts +31 -0
- package/dist/agent-session/session/tool-round.js +473 -0
- package/dist/agent-session/session/types.d.ts +115 -0
- package/dist/agent-session/session/types.js +5 -0
- package/dist/agent-session/session.d.ts +49 -43
- package/dist/agent-session/session.js +24 -1180
- package/dist/capture.d.ts +63 -0
- package/dist/capture.js +67 -0
- package/dist/cli-init.d.ts +18 -2
- package/dist/cli-init.js +2 -7
- package/dist/cli-runner.d.ts +2 -2
- package/dist/cli-runner.js +45 -9
- package/dist/content.d.ts +3 -3
- package/dist/content.js +3 -1
- package/dist/contracts-core/agent.d.ts +4 -0
- package/dist/contracts-core/batch.d.ts +97 -0
- package/dist/contracts-core/batch.js +65 -0
- package/dist/contracts-core/content.d.ts +72 -1
- package/dist/contracts-core/embeddings.d.ts +30 -0
- package/dist/contracts-core/embeddings.js +17 -0
- package/dist/contracts-core/images.d.ts +60 -0
- package/dist/contracts-core/images.js +17 -0
- package/dist/contracts-core/moderation.d.ts +46 -0
- package/dist/contracts-core/moderation.js +34 -0
- package/dist/contracts-core/speech.d.ts +39 -0
- package/dist/contracts-core/speech.js +17 -0
- package/dist/contracts-core/transcription.d.ts +48 -0
- package/dist/contracts-core/transcription.js +17 -0
- package/dist/contracts-core/video.d.ts +61 -0
- package/dist/contracts-core/video.js +17 -0
- package/dist/contracts-core.d.ts +7 -0
- package/dist/contracts-core.js +7 -0
- package/dist/contracts-protocol.d.ts +2 -0
- package/dist/index.d.ts +7 -5
- package/dist/index.js +5 -4
- package/dist/input.js +3 -2
- package/dist/node/agent-definitions.d.ts +1 -8
- package/dist/node/agent-definitions.js +0 -34
- package/dist/node/settings.d.ts +0 -1
- package/dist/node/settings.js +0 -5
- package/dist/pinned-fetch.js +29 -3
- package/dist/provider-events.js +3 -4
- package/dist/provider-request-policy.d.ts +15 -0
- package/dist/provider-request-policy.js +52 -0
- package/dist/providers/media.d.ts +1 -2
- package/dist/providers/media.js +1 -4
- package/dist/rpc.d.ts +1 -1
- package/dist/rpc.js +4 -4
- package/dist/testing/provider-conformance.d.ts +114 -5
- package/dist/testing/provider-conformance.js +342 -0
- package/dist/testing/tool-effect-store-conformance.d.ts +0 -1
- package/dist/testing/tool-effect-store-conformance.js +0 -3
- package/dist/thinking.d.ts +48 -9
- package/dist/thinking.js +134 -8
- package/docs/0.1.0-readiness.md +3 -3
- package/docs/a2a.md +2 -2
- package/docs/acp.md +3 -3
- package/docs/ag-ui-adoption.md +1 -1
- package/docs/ag-ui.md +1 -2
- package/docs/agent-definitions.md +1 -1
- package/docs/agent-events.md +5 -5
- package/docs/agent-identity.md +13 -2
- package/docs/agent-session-runtime.md +2 -1
- package/docs/audit-export.md +3 -3
- package/docs/batch-jobs.md +120 -0
- package/docs/cli-rpc.md +20 -9
- package/docs/coding-agent-tools.md +19 -19
- package/docs/coding-review-and-diagnostics.md +2 -2
- package/docs/coding-security.md +4 -4
- package/docs/coding-workspaces.md +2 -2
- package/docs/compaction-llm.md +2 -0
- package/docs/compaction-observational-memory.md +3 -0
- package/docs/computer-use-linux.md +13 -2
- package/docs/context-and-skills.md +1 -1
- package/docs/conversations.md +4 -4
- package/docs/credential-storage.md +11 -7
- package/docs/credentials-and-redaction.md +1 -1
- package/docs/data-classification.md +1 -1
- package/docs/database-persistence.md +4 -4
- package/docs/dev-inspector.md +6 -6
- package/docs/device-adapters.md +2 -2
- package/docs/diagrams.md +1 -1
- package/docs/document-reader.md +6 -6
- package/docs/documents.md +5 -4
- package/docs/embeddings.md +112 -0
- package/docs/enterprise-postgres-state.md +7 -7
- package/docs/evaluations.md +8 -8
- package/docs/extensions.md +3 -3
- package/docs/forge-integration.md +3 -3
- package/docs/graft.md +2 -2
- package/docs/guardrails.md +1 -1
- package/docs/host-security.md +15 -15
- package/docs/image-generation.md +129 -0
- package/docs/impeccable.md +5 -3
- package/docs/index.md +64 -36
- package/docs/indexed-code-search.md +2 -2
- package/docs/input-and-prompt-assembly.md +1 -1
- package/docs/language-intelligence.md +4 -4
- package/docs/live-testing.md +126 -0
- package/docs/mcp-tools.md +43 -12
- package/docs/middleware-hooks.md +1 -1
- package/docs/migrate-to-0.4.md +3 -3
- package/docs/migrate-to-0.5.md +144 -0
- package/docs/migration.md +33 -1
- package/docs/model-registry.md +38 -0
- package/docs/model-routing.md +5 -5
- package/docs/moderation.md +117 -0
- package/docs/multi-agent-patterns.md +4 -4
- package/docs/multimodal-content.md +26 -2
- package/docs/obscura.md +2 -2
- package/docs/observability.md +32 -7
- package/docs/openapi-tools.md +13 -3
- package/docs/operations.md +11 -0
- package/docs/performance.md +7 -7
- package/docs/persistence-credentials-multimodality-primitives.md +6 -6
- package/docs/policy-and-audit.md +17 -7
- package/docs/ponytail.md +1 -1
- package/docs/postgres-persistence.md +5 -5
- package/docs/process-sessions.md +2 -2
- package/docs/prompt-registry.md +7 -7
- package/docs/provider-caching.md +8 -2
- package/docs/provider-conformance.md +23 -1
- package/docs/provider-packages.md +49 -17
- package/docs/provider-primitives.md +1 -1
- package/docs/provider-request-policies.md +19 -6
- package/docs/providers/ai-sdk.md +27 -3
- package/docs/providers/alibaba.md +17 -1
- package/docs/providers/anthropic.md +16 -0
- package/docs/providers/azure.md +29 -1
- package/docs/providers/bedrock.md +27 -0
- package/docs/providers/clinepass.md +16 -0
- package/docs/providers/commandcode.md +265 -0
- package/docs/providers/deepseek.md +16 -0
- package/docs/providers/google.md +16 -0
- package/docs/providers/hyper.md +296 -0
- package/docs/providers/kimi.md +16 -0
- package/docs/providers/neuralwatt.md +16 -0
- package/docs/providers/ollama.md +27 -0
- package/docs/providers/openai-compatible.md +16 -0
- package/docs/providers/openai.md +16 -0
- package/docs/providers/opencode-go.md +16 -0
- package/docs/providers/openrouter.md +17 -1
- package/docs/providers/vertex.md +28 -0
- package/docs/providers/xai.md +16 -0
- package/docs/providers/zai.md +16 -0
- package/docs/public-contracts.md +1 -1
- package/docs/rag.md +26 -4
- package/docs/release-and-install.md +103 -46
- package/docs/resource-loading.md +1 -1
- package/docs/runs-and-usage.md +14 -2
- package/docs/server.md +5 -5
- package/docs/settings-auth-trust-security.md +7 -5
- package/docs/sheets.md +2 -2
- package/docs/speech.md +126 -0
- package/docs/sqlite-persistence.md +4 -4
- package/docs/supervisors.md +3 -3
- package/docs/thinking-and-reasoning.md +99 -61
- package/docs/tool-conformance.md +1 -1
- package/docs/tool-execution-primitives.md +8 -8
- package/docs/tools.md +4 -4
- package/docs/use-case-model-selection.md +1 -1
- package/docs/web-tools.md +1 -1
- package/docs/wiki.md +1 -1
- package/docs/work-artifacts-and-review.md +17 -6
- package/docs/work-connectors.md +4 -4
- package/docs/work-tools.md +5 -5
- package/docs/workflow-orchestration-primitives.md +11 -11
- package/docs/workflows.md +5 -5
- package/package.json +11 -8
- package/templates/init/providers.json +24 -8
- package/docs/antigravity-agent.md +0 -207
package/dist/node/settings.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { homedir } from "node:os";
|
|
2
|
-
import { join } from "node:path";
|
|
3
1
|
import { mergeConfigLayers } from "../config.js";
|
|
4
2
|
import { createStaticSettingsProvider } from "../settings.js";
|
|
5
3
|
import { isNodeErrorCode, readConfigFile } from "./config.js";
|
|
6
|
-
export function defaultUserSettingsPath(appName = "prism") {
|
|
7
|
-
return join(homedir(), ".config", appName, "settings.json");
|
|
8
|
-
}
|
|
9
4
|
export function readSettingsFile(path) {
|
|
10
5
|
return readConfigFile(path);
|
|
11
6
|
}
|
package/dist/pinned-fetch.js
CHANGED
|
@@ -99,7 +99,11 @@ export async function requestPinned(url, address, init, errorPrefix = "Request")
|
|
|
99
99
|
const nodeRequest = request(url, {
|
|
100
100
|
method,
|
|
101
101
|
headers: Object.fromEntries(headers.entries()),
|
|
102
|
-
|
|
102
|
+
// NOTE: the caller signal is NOT passed as the http.request `signal` option:
|
|
103
|
+
// Node's internal abort wiring destroys the (possibly keep-alive, already
|
|
104
|
+
// completed) socket with the abort reason, surfacing it as an unhandled
|
|
105
|
+
// socket 'error' when the response resolved and nothing listens anymore.
|
|
106
|
+
// Abort is handled manually below with a reason-less destroy.
|
|
103
107
|
lookup: ((_hostname, options, callback) => {
|
|
104
108
|
if (options.all)
|
|
105
109
|
callback(null, [{ address: address.address, family: address.family }]);
|
|
@@ -132,8 +136,13 @@ export async function requestPinned(url, address, init, errorPrefix = "Request")
|
|
|
132
136
|
controller.error(error);
|
|
133
137
|
}
|
|
134
138
|
},
|
|
135
|
-
cancel(
|
|
136
|
-
|
|
139
|
+
cancel() {
|
|
140
|
+
// Destroy WITHOUT the abort reason: once the response resolved,
|
|
141
|
+
// nothing listens on the socket, and propagate-destroy(reason)
|
|
142
|
+
// surfaces the DOMException as an unhandled socket 'error'
|
|
143
|
+
// (SDK transports abort their controller on close()). Readers
|
|
144
|
+
// that still pull observe EOF via the iterator.
|
|
145
|
+
incoming.destroy();
|
|
137
146
|
},
|
|
138
147
|
});
|
|
139
148
|
resolve(new Response(stream, {
|
|
@@ -143,12 +152,29 @@ export async function requestPinned(url, address, init, errorPrefix = "Request")
|
|
|
143
152
|
}));
|
|
144
153
|
});
|
|
145
154
|
nodeRequest.on("error", reject);
|
|
155
|
+
if (init?.signal) {
|
|
156
|
+
const signal = init.signal;
|
|
157
|
+
if (signal.aborted) {
|
|
158
|
+
reject(abortReason(signal));
|
|
159
|
+
nodeRequest.destroy();
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
signal.addEventListener("abort", () => {
|
|
163
|
+
nodeRequest.destroy();
|
|
164
|
+
reject(abortReason(signal));
|
|
165
|
+
}, { once: true });
|
|
166
|
+
}
|
|
167
|
+
}
|
|
146
168
|
if (body)
|
|
147
169
|
nodeRequest.end(body);
|
|
148
170
|
else
|
|
149
171
|
nodeRequest.end();
|
|
150
172
|
});
|
|
151
173
|
}
|
|
174
|
+
function abortReason(signal) {
|
|
175
|
+
const reason = signal.reason;
|
|
176
|
+
return reason instanceof Error ? reason : new Error(String(reason));
|
|
177
|
+
}
|
|
152
178
|
async function requestBody(body, errorPrefix) {
|
|
153
179
|
if (body === undefined || body === null)
|
|
154
180
|
return undefined;
|
package/dist/provider-events.js
CHANGED
|
@@ -27,10 +27,9 @@ export function reconstructToolCallDeltas(events) {
|
|
|
27
27
|
if (event.type !== "tool_call_delta")
|
|
28
28
|
continue;
|
|
29
29
|
const partial = partials.get(event.index) ?? { argumentsText: "" };
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
partial.name = event.name;
|
|
30
|
+
// Conformant OpenAI-compatible providers repeat identity as null on continuation chunks; coalesce like openai-compatible.js instead of clobbering.
|
|
31
|
+
partial.id = event.id ?? partial.id;
|
|
32
|
+
partial.name = event.name ?? partial.name;
|
|
34
33
|
if (event.argumentsText !== undefined)
|
|
35
34
|
partial.argumentsText += event.argumentsText;
|
|
36
35
|
partials.set(event.index, partial);
|
|
@@ -3,6 +3,21 @@ export interface SessionCachePolicyOptions {
|
|
|
3
3
|
readonly retention?: CacheRetention;
|
|
4
4
|
readonly cacheKey?: string;
|
|
5
5
|
}
|
|
6
|
+
export interface ApplyDefaultProviderRequestOptionsContext {
|
|
7
|
+
readonly sessionId?: string;
|
|
8
|
+
readonly thinkingLevel?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class ProviderRequirementError extends Error {
|
|
11
|
+
readonly code: "ERR_PRISM_PROVIDER_REQUIREMENT";
|
|
12
|
+
readonly requirement: string;
|
|
13
|
+
readonly providerId?: string;
|
|
14
|
+
constructor(message: string, options: {
|
|
15
|
+
readonly requirement: string;
|
|
16
|
+
readonly providerId?: string;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/** Fill-if-missing `sessionId` / `cacheKey` / cache defaults from `model.cache`. Host values win. Thinking intent patches after. */
|
|
20
|
+
export declare function applyDefaultProviderRequestOptions(request: ProviderRequest, ctx?: ApplyDefaultProviderRequestOptionsContext): ProviderRequest;
|
|
6
21
|
export declare function createProviderRequestPolicyChain(policies: readonly ProviderRequestPolicy[]): ProviderRequestPolicy;
|
|
7
22
|
export declare function createSessionCachePolicy(options?: SessionCachePolicyOptions): ProviderRequestPolicy;
|
|
8
23
|
export declare function mergeProviderRequestOptions(base: ProviderRequestOptions | undefined, patch: ProviderRequestOptions | undefined): ProviderRequestOptions | undefined;
|
|
@@ -1,3 +1,55 @@
|
|
|
1
|
+
import { applyThinkingLevelForModel } from "./thinking.js";
|
|
2
|
+
export class ProviderRequirementError extends Error {
|
|
3
|
+
code = "ERR_PRISM_PROVIDER_REQUIREMENT";
|
|
4
|
+
requirement;
|
|
5
|
+
providerId;
|
|
6
|
+
constructor(message, options) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "ProviderRequirementError";
|
|
9
|
+
this.requirement = options.requirement;
|
|
10
|
+
this.providerId = options.providerId;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function present(value) {
|
|
14
|
+
return value ? value : undefined;
|
|
15
|
+
}
|
|
16
|
+
const DEFAULT_CACHE_BREAKPOINTS = [
|
|
17
|
+
{ location: "system_prompt" },
|
|
18
|
+
{ location: "last_stable_message" },
|
|
19
|
+
];
|
|
20
|
+
function defaultCacheOptions(request) {
|
|
21
|
+
const cache = request.model.cache;
|
|
22
|
+
if (!cache || (cache.kind !== "cache_control" && cache.explicitBreakpoints !== true))
|
|
23
|
+
return undefined;
|
|
24
|
+
const options = request.options;
|
|
25
|
+
if (options?.cache?.mode === "off" || options?.cacheRetention === "none" || options?.cache?.breakpoints?.length) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
...(options?.cacheRetention ? {} : { cacheRetention: "short" }),
|
|
30
|
+
cache: { breakpoints: DEFAULT_CACHE_BREAKPOINTS },
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Fill-if-missing `sessionId` / `cacheKey` / cache defaults from `model.cache`. Host values win. Thinking intent patches after. */
|
|
34
|
+
export function applyDefaultProviderRequestOptions(request, ctx = {}) {
|
|
35
|
+
const sessionId = present(request.options?.sessionId) ?? present(ctx.sessionId);
|
|
36
|
+
const cacheKey = present(request.options?.cacheKey) ?? sessionId;
|
|
37
|
+
const cachePatch = defaultCacheOptions(request);
|
|
38
|
+
const thinkingLevel = present(ctx.thinkingLevel);
|
|
39
|
+
if (sessionId === present(request.options?.sessionId) &&
|
|
40
|
+
cacheKey === present(request.options?.cacheKey) &&
|
|
41
|
+
!cachePatch &&
|
|
42
|
+
!thinkingLevel) {
|
|
43
|
+
return request;
|
|
44
|
+
}
|
|
45
|
+
const merged = mergeProviderRequestOptions(request.options, {
|
|
46
|
+
...(sessionId !== undefined ? { sessionId } : {}),
|
|
47
|
+
...(cacheKey !== undefined ? { cacheKey } : {}),
|
|
48
|
+
...cachePatch,
|
|
49
|
+
});
|
|
50
|
+
const options = thinkingLevel ? applyThinkingLevelForModel(merged, thinkingLevel, request.model) : merged;
|
|
51
|
+
return { ...request, options };
|
|
52
|
+
}
|
|
1
53
|
export function createProviderRequestPolicyChain(policies) {
|
|
2
54
|
return {
|
|
3
55
|
name: "provider-request-policy-chain",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MediaContentBlock, type ModelInputCapability, type ResolvedMediaContent, type ResolveMediaContentOptions } from "../content.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ContentBlock, JsonObject, Message, ModelCapabilities, ModelConfig } from "../contracts.js";
|
|
3
3
|
/** Default upload-cache entry cap per provider media session. */
|
|
4
4
|
export declare const DEFAULT_PROVIDER_UPLOAD_CACHE_ENTRIES = 32;
|
|
5
5
|
/** Inline OpenAI file_data ceiling before preferring Files API upload. */
|
|
@@ -37,7 +37,6 @@ export declare function serializePdfDocumentWireBlock(options: {
|
|
|
37
37
|
readonly data: string;
|
|
38
38
|
readonly title?: string;
|
|
39
39
|
}): JsonObject;
|
|
40
|
-
export declare function resolveProviderMediaBlock(block: AudioContent | FileContent | DocumentContent, options?: ResolveMediaContentOptions): Promise<ResolvedMediaContent>;
|
|
41
40
|
/** Resolve every media block once and enforce aggregate request bounds before provider I/O. */
|
|
42
41
|
export declare function resolveProviderMediaMessages(messages: readonly Message[], model: ModelConfig, options?: ResolveMediaContentOptions): Promise<ReadonlyMap<MediaContentBlock, ResolvedMediaContent>>;
|
|
43
42
|
export declare function defaultProviderFilename(block: MediaContentBlock, fallback: string): string;
|
package/dist/providers/media.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { assertMessagesSupportModelCapabilities, contentBlockInputModality, DEFAULT_MAX_MEDIA_ITEM_BYTES,
|
|
2
|
+
import { assertMessagesSupportModelCapabilities, contentBlockInputModality, DEFAULT_MAX_MEDIA_ITEM_BYTES, resolveMediaContentBlocks, UnsupportedModalityError, } from "../content.js";
|
|
3
3
|
/** Default upload-cache entry cap per provider media session. */
|
|
4
4
|
export const DEFAULT_PROVIDER_UPLOAD_CACHE_ENTRIES = 32;
|
|
5
5
|
/** Inline OpenAI file_data ceiling before preferring Files API upload. */
|
|
@@ -93,9 +93,6 @@ export function serializePdfDocumentWireBlock(options) {
|
|
|
93
93
|
...(options.title ? { title: options.title } : {}),
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
export async function resolveProviderMediaBlock(block, options = {}) {
|
|
97
|
-
return resolveMediaContentBlock(block, options);
|
|
98
|
-
}
|
|
99
96
|
/** Resolve every media block once and enforce aggregate request bounds before provider I/O. */
|
|
100
97
|
export async function resolveProviderMediaMessages(messages, model, options = {}) {
|
|
101
98
|
assertMessagesSupportModelCapabilities(model, messages);
|
package/dist/rpc.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface RpcRequest {
|
|
|
8
8
|
readonly params?: Record<string, unknown>;
|
|
9
9
|
}
|
|
10
10
|
export interface RpcSessionFactory {
|
|
11
|
-
createSession(id?: string): AgentSession
|
|
11
|
+
createSession(id?: string): AgentSession | Promise<AgentSession>;
|
|
12
12
|
readonly commands?: readonly CommandDefinition[];
|
|
13
13
|
/** Host-opt-in driver capabilities forwarded to contributed commands on the
|
|
14
14
|
* `command` execution context. Absent ⇒ context shape unchanged. */
|
package/dist/rpc.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createInterface } from "node:readline";
|
|
|
2
2
|
import { resolveInstructionInjectors } from "./instruction-injection.js";
|
|
3
3
|
import { errorToErrorInfo } from "./redaction.js";
|
|
4
4
|
export async function runRpcServer(options) {
|
|
5
|
-
const first = options.createSession();
|
|
5
|
+
const first = await options.createSession();
|
|
6
6
|
const state = {
|
|
7
7
|
current: first,
|
|
8
8
|
currentHandleId: first.id,
|
|
@@ -140,7 +140,7 @@ async function handleRequest(request, state, stdout, activeRuns) {
|
|
|
140
140
|
const handleId = stringParam(request.params, "handleId") ?? stringParam(request.params, "sessionId") ?? stringParam(request.params, "id");
|
|
141
141
|
if (!handleId)
|
|
142
142
|
throw new Error("switchSession requires params.handleId (or sessionId)");
|
|
143
|
-
const session = state.sessions.get(handleId) ?? makeSession(state, handleId);
|
|
143
|
+
const session = state.sessions.get(handleId) ?? (await makeSession(state, handleId));
|
|
144
144
|
state.current = session;
|
|
145
145
|
state.currentHandleId = handleId;
|
|
146
146
|
write(stdout, { id: request.id, ok: true, result: { sessionId: session.id, leafId: session.leafId, handleId } });
|
|
@@ -220,8 +220,8 @@ function registerSession(state, session, preferredHandleId) {
|
|
|
220
220
|
state.sessions.set(handleId, session);
|
|
221
221
|
return handleId;
|
|
222
222
|
}
|
|
223
|
-
function makeSession(state, id) {
|
|
224
|
-
const session = state.createSession(id);
|
|
223
|
+
async function makeSession(state, id) {
|
|
224
|
+
const session = await state.createSession(id);
|
|
225
225
|
state.sessions.set(session.id, session);
|
|
226
226
|
return session;
|
|
227
227
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AIProvider, ContentBlock, JsonObject, ProviderEvent, ProviderRequest, ToolCallContent, Usage } from "../contracts.js";
|
|
1
|
+
import type { AIProvider, BatchJobsProvider, BatchRequestItem, ContentBlock, EmbeddingsProvider, EmbeddingsResult, ImageGenerationProvider, ImageGenerationResult, JsonObject, ModerationProvider, ModerationResult, ProviderEvent, ProviderRequest, SpeechProvider, SpeechResult, ToolCallContent, TranscriptionProvider, TranscriptionResult, Usage, VideoGenerationJob, VideoGenerationProvider } from "../contracts.js";
|
|
2
2
|
export interface ProviderStreamConformanceOptions {
|
|
3
3
|
readonly provider: AIProvider;
|
|
4
4
|
readonly request: ProviderRequest;
|
|
@@ -29,10 +29,6 @@ export interface ProviderHeaderOwnershipConformanceOptions {
|
|
|
29
29
|
/** Caller-supplied headers, including attempts to override owned names and non-owned additions. */
|
|
30
30
|
readonly caller: Readonly<Record<string, string>>;
|
|
31
31
|
}
|
|
32
|
-
export interface ProviderSecretLeakConformanceOptions {
|
|
33
|
-
readonly events: readonly ProviderEvent[];
|
|
34
|
-
readonly secrets: readonly string[];
|
|
35
|
-
}
|
|
36
32
|
export declare function collectProviderEvents(provider: AIProvider, request: ProviderRequest): Promise<readonly ProviderEvent[]>;
|
|
37
33
|
export declare function assertProviderStreamConforms(options: ProviderStreamConformanceOptions): Promise<readonly ProviderEvent[]>;
|
|
38
34
|
export declare function assertAbortIsObserved(options: ProviderAbortConformanceOptions): Promise<void>;
|
|
@@ -51,3 +47,116 @@ export declare function assertNoForeignCacheFields(body: unknown, allowed?: read
|
|
|
51
47
|
/** Provider construction and setup must perform zero network calls; discovery and streams are caller-gated. */
|
|
52
48
|
export declare function assertNoFetches(calls: readonly unknown[]): void;
|
|
53
49
|
export declare function assertUsageAccounting(events: readonly ProviderEvent[], expected: Usage): Usage;
|
|
50
|
+
export interface EmbeddingsConformanceOptions {
|
|
51
|
+
readonly provider: EmbeddingsProvider;
|
|
52
|
+
readonly model: string;
|
|
53
|
+
/** When set, an oversized batch must fail with `EmbeddingsError("batch_too_large")`. */
|
|
54
|
+
readonly maxBatchSize?: number;
|
|
55
|
+
/** Happy-path mapping probe: inputs to embed and the expected vector count/dimensions. */
|
|
56
|
+
readonly sample?: {
|
|
57
|
+
readonly inputs: readonly string[];
|
|
58
|
+
readonly dimensions?: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Offline conformance for any `EmbeddingsProvider` (plan 061): typed empty-input
|
|
62
|
+
* error, typed oversized-batch error, and input-order vector mapping with finite
|
|
63
|
+
* coordinates. No network — the caller supplies the provider (real adapter with a
|
|
64
|
+
* fake transport, or a fake provider). */
|
|
65
|
+
export declare function runEmbeddingsConformance(options: EmbeddingsConformanceOptions): Promise<EmbeddingsResult | undefined>;
|
|
66
|
+
export interface SpeechConformanceOptions {
|
|
67
|
+
readonly provider: SpeechProvider;
|
|
68
|
+
readonly model: string;
|
|
69
|
+
/** When set, an oversized input must fail with `SpeechError("input_too_large")`. */
|
|
70
|
+
readonly maxInputChars?: number;
|
|
71
|
+
/** Happy-path probe: text to synthesize, optional voice/format. */
|
|
72
|
+
readonly sample?: {
|
|
73
|
+
readonly input?: string;
|
|
74
|
+
readonly voice?: string;
|
|
75
|
+
readonly format?: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Offline conformance for any `SpeechProvider` (plan 061): typed empty-input and
|
|
79
|
+
* oversized-input errors, byte results, and stream ordering — the stream must emit
|
|
80
|
+
* at least one chunk before closing. Asserts event order, never wall clock. */
|
|
81
|
+
export declare function runSpeechConformance(options: SpeechConformanceOptions): Promise<SpeechResult | undefined>;
|
|
82
|
+
export interface TranscriptionConformanceOptions {
|
|
83
|
+
readonly provider: TranscriptionProvider;
|
|
84
|
+
readonly model: string;
|
|
85
|
+
/** When set, oversized audio must fail with `TranscriptionError("audio_too_large")`. */
|
|
86
|
+
readonly maxAudioBytes?: number;
|
|
87
|
+
/** Happy-path probe: audio bytes and the expected transcript prefix. */
|
|
88
|
+
readonly sample?: {
|
|
89
|
+
readonly audio?: Uint8Array;
|
|
90
|
+
readonly format?: string;
|
|
91
|
+
readonly textIncludes?: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** Offline conformance for any `TranscriptionProvider` (plan 061): typed empty-audio
|
|
95
|
+
* and oversized-audio errors, one-shot text, and stream ordering — at least one
|
|
96
|
+
* `transcript_delta` partial, then exactly one `done` terminal event. */
|
|
97
|
+
export declare function runTranscriptionConformance(options: TranscriptionConformanceOptions): Promise<TranscriptionResult | undefined>;
|
|
98
|
+
export interface ImageGenerationConformanceOptions {
|
|
99
|
+
readonly provider: ImageGenerationProvider;
|
|
100
|
+
readonly model: string;
|
|
101
|
+
/** When set, an oversized prompt must fail with `ImageGenerationError("input_too_large")`. */
|
|
102
|
+
readonly maxPromptChars?: number;
|
|
103
|
+
/** Happy-path probe: prompt, requested image count, expected provenance. */
|
|
104
|
+
readonly sample?: {
|
|
105
|
+
readonly prompt?: string;
|
|
106
|
+
readonly size?: string;
|
|
107
|
+
readonly count?: number;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** Offline conformance for any `ImageGenerationProvider` (plan 061): typed empty-input
|
|
111
|
+
* and oversized-prompt errors, plus image shape — non-empty bytes, an `image/*` mime
|
|
112
|
+
* type, and preserved provenance (`provider`/`model`) on every image. */
|
|
113
|
+
export declare function runImageGenerationConformance(options: ImageGenerationConformanceOptions): Promise<ImageGenerationResult | undefined>;
|
|
114
|
+
export interface VideoGenerationConformanceOptions {
|
|
115
|
+
readonly provider: VideoGenerationProvider;
|
|
116
|
+
readonly model: string;
|
|
117
|
+
/** When set, an oversized prompt must fail with `VideoGenerationError("input_too_large")`. */
|
|
118
|
+
readonly maxPromptChars?: number;
|
|
119
|
+
/** Happy-path lifecycle probe: submit, poll to terminal state, assert result shape. */
|
|
120
|
+
readonly sample?: {
|
|
121
|
+
readonly prompt?: string;
|
|
122
|
+
readonly maxPolls?: number;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** Offline conformance for any `VideoGenerationProvider` (plan 061): typed
|
|
126
|
+
* empty-input and oversized-prompt errors, plus the submit→status lifecycle —
|
|
127
|
+
* a job id is returned, polling reaches a terminal state, and succeeded jobs
|
|
128
|
+
* carry a video with provenance (`provider`/`model`) and at least one source
|
|
129
|
+
* (`bytes` or `url`). */
|
|
130
|
+
export declare function runVideoGenerationConformance(options: VideoGenerationConformanceOptions): Promise<VideoGenerationJob | undefined>;
|
|
131
|
+
export interface ModerationConformanceOptions {
|
|
132
|
+
readonly provider: ModerationProvider;
|
|
133
|
+
readonly model: string;
|
|
134
|
+
/** When set, an oversized input must fail with `ModerationError("input_too_large")`. */
|
|
135
|
+
readonly maxInputChars?: number;
|
|
136
|
+
/** Happy-path probe: a benign string classification. */
|
|
137
|
+
readonly sample?: {
|
|
138
|
+
readonly input?: string;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/** Offline conformance for any `ModerationProvider` (plan 061): typed empty-input
|
|
142
|
+
* and oversized-input errors, plus a classification probe — every category
|
|
143
|
+
* verdict carries a numeric score in [0,1], a boolean `flagged`, and the
|
|
144
|
+
* top-level `flagged` boolean is present. Scores are provider output; conformance
|
|
145
|
+
* asserts no local policy decisions are baked in. */
|
|
146
|
+
export declare function runModerationConformance(options: ModerationConformanceOptions): Promise<ModerationResult | undefined>;
|
|
147
|
+
export interface BatchJobsConformanceOptions {
|
|
148
|
+
readonly provider: BatchJobsProvider;
|
|
149
|
+
/** Sample lifecycle driver: submitted via `submit` and expected to reach `completed`. */
|
|
150
|
+
readonly sample?: {
|
|
151
|
+
readonly model: string;
|
|
152
|
+
readonly requests: readonly BatchRequestItem[];
|
|
153
|
+
};
|
|
154
|
+
/** When set, a submit over this count must fail with `BatchJobsError("too_many_requests")`. */
|
|
155
|
+
readonly maxRequests?: number;
|
|
156
|
+
}
|
|
157
|
+
/** Offline conformance for any `BatchJobsProvider` (plan 061): typed empty/oversized
|
|
158
|
+
* submit errors, opaque job ids, status returning members of the neutral state
|
|
159
|
+
* union, terminal resolution via `pollBatch` (plain utility), and paged results
|
|
160
|
+
* that walk to exhaustion with cursor continuity. Failure/cancel terminal
|
|
161
|
+
* transitions are covered by provider fakes in adapter test suites. */
|
|
162
|
+
export declare function runBatchJobsConformance(options: BatchJobsConformanceOptions): Promise<void>;
|