@arnilo/prism 0.0.11 → 0.0.13
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 +24 -0
- package/dist/agent-run-lifecycle.d.ts +5 -1
- package/dist/agent-run-lifecycle.js +17 -1
- package/dist/agents.d.ts +3 -1
- package/dist/agents.js +98 -20
- package/dist/contracts.d.ts +29 -1
- package/dist/extensions.d.ts +11 -0
- package/dist/extensions.js +15 -0
- package/dist/identity.d.ts +92 -0
- package/dist/identity.js +257 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.js +4 -2
- package/dist/persistence-lifecycle.d.ts +103 -0
- package/dist/persistence-lifecycle.js +204 -0
- package/dist/providers/openai-compatible.d.ts +5 -1
- package/dist/providers/openai-compatible.js +15 -6
- package/dist/secure-agent.js +7 -1
- package/dist/testing/persistence-schema.d.ts +2 -2
- package/dist/testing/persistence-schema.js +35 -2
- package/dist/tools.d.ts +2 -0
- package/dist/tools.js +6 -0
- package/docs/a2a.md +3 -0
- package/docs/ag-ui.md +123 -0
- package/docs/agent-events.md +2 -1
- package/docs/agent-identity.md +111 -0
- package/docs/agent-session-runtime.md +5 -1
- package/docs/coding-agent-tools.md +2 -0
- package/docs/compaction-and-retry.md +2 -1
- package/docs/compaction-llm.md +20 -1
- package/docs/credential-storage.md +5 -1
- package/docs/credentials-and-redaction.md +8 -0
- package/docs/database-persistence.md +18 -7
- package/docs/extensions.md +1 -0
- package/docs/guardrails.md +3 -0
- package/docs/host-security.md +7 -1
- package/docs/index.md +25 -14
- package/docs/mcp-tools.md +2 -0
- package/docs/migration.md +43 -0
- package/docs/model-routing.md +102 -0
- package/docs/observability.md +2 -0
- package/docs/performance.md +38 -0
- package/docs/policy-and-audit.md +127 -0
- package/docs/postgres-persistence.md +1 -1
- package/docs/provider-packages.md +17 -0
- package/docs/provider-request-policies.md +2 -0
- package/docs/providers/anthropic.md +3 -2
- package/docs/providers/azure.md +74 -0
- package/docs/providers/bedrock.md +72 -0
- package/docs/providers/google.md +4 -2
- package/docs/providers/openai-compatible.md +3 -1
- package/docs/providers/openai.md +2 -2
- package/docs/providers/openrouter.md +2 -0
- package/docs/providers/vertex.md +71 -0
- package/docs/public-contracts.md +5 -1
- package/docs/release-and-install.md +167 -17
- package/docs/review-coverage-2026-07-22-phase-7.md +173 -0
- package/docs/review-coverage-2026-07-23-phase-8.md +245 -0
- package/docs/runs-and-usage.md +3 -0
- package/docs/server.md +34 -4
- package/docs/sqlite-persistence.md +1 -1
- package/docs/supervisors.md +2 -0
- package/docs/work-connectors.md +28 -0
- package/docs/work-tools.md +114 -0
- package/package.json +5 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Policy and audit
|
|
2
|
+
|
|
3
|
+
## What it does
|
|
4
|
+
|
|
5
|
+
`@arnilo/prism-policy` records redacted allow/deny/modify/approval decisions with policy version, actor refs from verified `AgentIdentity`, target, reason, expiry, and evidence references. Hosts export cursor-paginated pages to append-only/WORM sinks. The package does not embed a mandatory global policy engine, KMS, or cloud WORM SDK.
|
|
6
|
+
|
|
7
|
+
## When to use it
|
|
8
|
+
|
|
9
|
+
Use it when enterprise hosts need an attributable audit trail alongside existing guardrails, permission checks, and tool-approval interruptions. Skip it for single-tenant apps that only need `RunLedger` / guardrail events.
|
|
10
|
+
|
|
11
|
+
Do not store unrestricted prompts, tool argument bodies, JWTs, or credential secrets on decision records. Do not treat the reference memory/file adapters as production WORM.
|
|
12
|
+
|
|
13
|
+
## Inputs / request
|
|
14
|
+
|
|
15
|
+
| API / field | Meaning |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `createPolicyEvaluator({ policyId, policyVersion, evaluate })` | Host rule callback stamped with immutable id/version |
|
|
18
|
+
| `PolicyEvaluateRequest` | Verified `identity`, `action`, `resource`, optional evaluator-only `context` (never persisted) |
|
|
19
|
+
| `AppendPolicyDecisionInput` | Decision fields + verified identity; ownership from identity or explicit scope |
|
|
20
|
+
| `createMemoryPolicyDecisionStore` / `createFilePolicyDecisionStore` | Append-only reference ledgers |
|
|
21
|
+
| `exportPolicyDecisions({ store, ownership, cursor, limit, sink? })` | Cursor pages; optional host WORM sink |
|
|
22
|
+
| `recordGuardrailDecision` / `recordPermissionDecision` / `recordToolApprovalDecision` | Optional bridges from existing decision points |
|
|
23
|
+
|
|
24
|
+
Frozen caps (default / hard): decision `8 KiB / 64 KiB`, reason or evidence ref `1 KiB / 8 KiB`, export page `100 / 500`.
|
|
25
|
+
|
|
26
|
+
## Outputs / response / events
|
|
27
|
+
|
|
28
|
+
- `PolicyDecisionRecord` — frozen redacted row (`actor` refs, `evidenceRefs`, no payload blob).
|
|
29
|
+
- `evaluateAndAppend` — evaluate then append in one call.
|
|
30
|
+
- Policy version mismatch (`requirePolicyVersion`) and unrestricted payload keys fail closed (`ERR_PRISM_POLICY_VERSION` / `ERR_PRISM_POLICY_PAYLOAD`).
|
|
31
|
+
- Missing/expired/unverified identity fails via core `assertIdentityActive` before append.
|
|
32
|
+
|
|
33
|
+
## Request/response example
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"id": "dec-1",
|
|
38
|
+
"policyId": "mail",
|
|
39
|
+
"policyVersion": "2026-07-23",
|
|
40
|
+
"outcome": "approval",
|
|
41
|
+
"actor": {
|
|
42
|
+
"tenantId": "tenant-1",
|
|
43
|
+
"userId": "user-1",
|
|
44
|
+
"principalId": "agent-42",
|
|
45
|
+
"principalKind": "agent",
|
|
46
|
+
"sponsorId": "sponsor-7"
|
|
47
|
+
},
|
|
48
|
+
"target": { "kind": "draft", "id": "d1" },
|
|
49
|
+
"reason": "external send",
|
|
50
|
+
"evidenceRefs": ["rule:external"],
|
|
51
|
+
"createdAt": "2026-07-23T12:00:00.000Z",
|
|
52
|
+
"tenantId": "tenant-1",
|
|
53
|
+
"userId": "user-1"
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Implementation example
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { type AgentIdentity } from "@arnilo/prism";
|
|
61
|
+
import {
|
|
62
|
+
createFilePolicyDecisionStore,
|
|
63
|
+
createPolicyEvaluator,
|
|
64
|
+
evaluateAndAppend,
|
|
65
|
+
exportPolicyDecisions,
|
|
66
|
+
recordToolApprovalDecision,
|
|
67
|
+
} from "@arnilo/prism-policy";
|
|
68
|
+
|
|
69
|
+
const evaluator = createPolicyEvaluator({
|
|
70
|
+
policyId: "mail",
|
|
71
|
+
policyVersion: "2026-07-23",
|
|
72
|
+
evaluate: ({ action }) =>
|
|
73
|
+
action === "mail.send"
|
|
74
|
+
? { outcome: "approval", reason: "external send", evidenceRefs: ["rule:external"] }
|
|
75
|
+
: { outcome: "allow" },
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const store = createFilePolicyDecisionStore({
|
|
79
|
+
path: "/var/prism/policy-decisions.jsonl",
|
|
80
|
+
requirePolicyVersion: "2026-07-23",
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
await evaluateAndAppend(
|
|
84
|
+
{ identity, action: "mail.send", resource: { kind: "draft", id: "d1" } },
|
|
85
|
+
{ store, evaluator, id: crypto.randomUUID() },
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
await recordToolApprovalDecision({
|
|
89
|
+
store,
|
|
90
|
+
evaluator,
|
|
91
|
+
id: crypto.randomUUID(),
|
|
92
|
+
identity,
|
|
93
|
+
toolName: "mail.send",
|
|
94
|
+
toolCallId: "call-1",
|
|
95
|
+
evidenceRef: "run:abc/tool:call-1",
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
for await (const page of exportPolicyDecisions({
|
|
99
|
+
store,
|
|
100
|
+
tenantId: identity.tenantId,
|
|
101
|
+
userId: identity.userId,
|
|
102
|
+
sink: { async write(records) { await worm.append(records); } },
|
|
103
|
+
})) {
|
|
104
|
+
void page;
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Extension and configuration notes
|
|
109
|
+
|
|
110
|
+
Policy is optional. Hosts wire `record*` helpers or `evaluateAndAppend` at permission/guardrail/tool-approval/router/connector boundaries. Model-router and work-connector packages (later Phase 8 tasks) may call the same store when configured. Replace file/memory adapters with host WORM/KMS without changing record shape.
|
|
111
|
+
|
|
112
|
+
## Security and performance notes
|
|
113
|
+
|
|
114
|
+
- Approvals require verified `AgentIdentity`; actor fields are refs only.
|
|
115
|
+
- Policy version pin fails closed on mismatch.
|
|
116
|
+
- Unrestricted payload field names (`prompt`, `body`, `toolArguments`, …) are rejected before append.
|
|
117
|
+
- Evaluate/append are O(fields) and network-free in-package; remote WORM I/O stays in the host sink/adapter.
|
|
118
|
+
- Export never full-scans: page size is capped; raise hard caps only with Phase 8 freeze + tests + docs updates.
|
|
119
|
+
|
|
120
|
+
## Related APIs
|
|
121
|
+
|
|
122
|
+
- [Model routing](model-routing.md)
|
|
123
|
+
- [Agent identity](agent-identity.md)
|
|
124
|
+
- [Guardrails](guardrails.md)
|
|
125
|
+
- [Runs and usage ledger](runs-and-usage.md)
|
|
126
|
+
- [Host security](host-security.md)
|
|
127
|
+
- Package README: [`@arnilo/prism-policy`](../packages/policy/README.md)
|
|
@@ -116,7 +116,7 @@ PRISM_TEST_POSTGRES_URL="$DATABASE_URL" npm run test:postgres --workspace @arnil
|
|
|
116
116
|
- The package is optional and workspace-local; `@arnilo/prism` core has no PostgreSQL dependency.
|
|
117
117
|
- Schema names must match `^[a-zA-Z_][a-zA-Z0-9_]*$`; the adapter quotes them and never interpolates user values into identifier positions.
|
|
118
118
|
- `SessionAppendOptions` idempotency rows are durable in `prism_session_append_idempotency` and survive reopen.
|
|
119
|
-
- Schema version **
|
|
119
|
+
- Schema version **5** applies `001_init`, `002_usage_scope`, `003_run_feedback`, `004_session_search`, and `005_lifecycle_hold_quota`. Migration 003 adds immutable `prism_run_feedback` rows with run FK/cascade deletion and owner/run/trace cursor indexes. Migration 004 adds session search FTS (Postgres `tsvector` FTS table dual-written on append) plus `prism_sessions(updated_at, id)` cursor index; existing entries are backfilled once. `persistence.feedback` validates exact run ownership, bounds/redacts through optional `feedbackRedactor`, queries bounded pages, and deletes only exact-owned IDs. Search hits never include credentials; ownership filters apply when present. SQLite shares the same model with dialect-local DDL.
|
|
120
120
|
- Pass an existing `pg` `Pool` when your host already manages pooling, TLS, and credential rotation.
|
|
121
121
|
|
|
122
122
|
## Security and performance notes
|
|
@@ -18,6 +18,19 @@ Use provider packages when a host wants to bundle model metadata, provider adapt
|
|
|
18
18
|
|
|
19
19
|
Do not use provider packages as a package manager, credential store, env loader, provider-specific cache implementation, or live integration runner.
|
|
20
20
|
|
|
21
|
+
### Subscription OAuth support matrix
|
|
22
|
+
|
|
23
|
+
| Package | 0.0.12 auth registration | Subscription OAuth boundary |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| `@arnilo/prism-provider-openai` | `api_key` for `openai`; `oauth` for `openai-codex` | Existing host-invoked OpenAI Codex PKCE/device-code flow only. |
|
|
26
|
+
| `@arnilo/prism-provider-anthropic` | `api_key` only | No Claude Code/Claude.ai subscription OAuth, credential-file/setup-token import, or routing. [Anthropic requires product developers to use API keys or supported cloud providers](https://docs.anthropic.com/en/docs/claude-code/legal-and-compliance). |
|
|
27
|
+
| `@arnilo/prism-provider-google` | `api_key` only | No Gemini CLI OAuth or credential/token import. [Gemini CLI prohibits third-party OAuth piggybacking](https://github.com/google-gemini/gemini-cli/blob/main/docs/resources/tos-privacy.md); use Google AI Studio API keys. Vertex/ADC uses separate [`@arnilo/prism-provider-vertex`](providers/vertex.md). |
|
|
28
|
+
| `@arnilo/prism-provider-azure` | host Entra token or Azure resource key | Workload identity via `credential` callback; endpoint host preserved ([docs](providers/azure.md)). |
|
|
29
|
+
| `@arnilo/prism-provider-bedrock` | host IAM/IRSA credentials | SigV4 over OpenAI-compatible Bedrock Runtime; region/PrivateLink preserved ([docs](providers/bedrock.md)). |
|
|
30
|
+
| `@arnilo/prism-provider-vertex` | host ADC / workload token | OpenAPI-compatible Vertex endpoint; separate from consumer Google package ([docs](providers/vertex.md)). |
|
|
31
|
+
|
|
32
|
+
A future provider-local OAuth package must first have explicit third-party permission and documented authorize/token/refresh flow. Before it registers an OAuth descriptor, it must add bounded request/response, abort, PKCE/state where required, expiry/refresh, secret-redaction, durable-store round-trip, and offline protocol tests. Do not add a generic OAuth framework, CLI credential scanner, automatic refresh timer, or success stub.
|
|
33
|
+
|
|
21
34
|
## Inputs / request
|
|
22
35
|
|
|
23
36
|
```ts
|
|
@@ -258,6 +271,8 @@ await kernel.load([pkg]);
|
|
|
258
271
|
- Provider-specific behavior belongs in provider packages, not Prism core.
|
|
259
272
|
- Adapter serializers should preserve Prism content blocks (text, thinking, tool_call, tool_result, and image when the model declares image input) in provider-native request shape, or fail explicitly when a block is unsupported.
|
|
260
273
|
- Adapter header merging must put caller-supplied `ProviderRequest.options.headers` first and provider-owned headers last. Caller headers may add non-owned headers, but cannot replace resolved credentials, content type, session/cache/security headers, or provider attribution headers.
|
|
274
|
+
- For allow-list/residency/budget/circuit selection before resolve, use optional `@arnilo/prism-model-router` over `createProviderResolver` — do not fork provider packages for governance.
|
|
275
|
+
- Enterprise cloud adapters (`azure` / `bedrock` / `vertex`) stay separate from consumer Anthropic/Google packages and authenticate only through host credential callbacks.
|
|
261
276
|
|
|
262
277
|
## Manifest declarations
|
|
263
278
|
|
|
@@ -281,6 +296,8 @@ Manifest declarations are inert. The host must later resolve them through regist
|
|
|
281
296
|
|
|
282
297
|
## Related APIs
|
|
283
298
|
|
|
299
|
+
- [Model routing](model-routing.md): optional governance router over `ProviderResolver`.
|
|
300
|
+
- [Azure OpenAI / Foundry](providers/azure.md) / [Amazon Bedrock](providers/bedrock.md) / [Google Vertex AI](providers/vertex.md): enterprise workload-identity packages.
|
|
284
301
|
- [Provider layer](provider-layer.md): provider/model registries and provider events.
|
|
285
302
|
- [Provider conformance](provider-conformance.md): reusable network-free checks for provider adapters.
|
|
286
303
|
- [Contribution registries](contribution-registries.md): registry bundle and extension contribution points.
|
|
@@ -104,9 +104,11 @@ Policy output should stay generic: use `ProviderRequestOptions.cache`, `headers`
|
|
|
104
104
|
- Cache keys must never be credentials.
|
|
105
105
|
- Policy chains are O(number of policies) plus option merge cost.
|
|
106
106
|
- Policies should be pure and synchronous unless the host explicitly accepts async work.
|
|
107
|
+
- Optional `@arnilo/prism-model-router` returns a `ProviderRequestPolicy` that strips `openRouterRouting` unless governance allows it — chain it with other policies.
|
|
107
108
|
|
|
108
109
|
## Related APIs
|
|
109
110
|
|
|
111
|
+
- [Model routing](model-routing.md): governance facade that emits a chainable OpenRouter routing gate policy.
|
|
110
112
|
- [Provider caching](provider-caching.md): structured cache hints and helpers.
|
|
111
113
|
- [Provider packages](provider-packages.md): registering policies from extension packages.
|
|
112
114
|
- [Provider layer](provider-layer.md): provider request flow and `AIProvider.generate()`.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
Use for native Claude Messages (tools, `cache_control`, thinking/reasoning, media, usage, abort). Prefer this over the AI SDK escape hatch when Anthropic is a primary coding host.
|
|
10
10
|
|
|
11
|
-
Do **not** use for OpenCode Go Anthropic *route* hosting (`@arnilo/prism-provider-opencode-go`)
|
|
11
|
+
Do **not** use for OpenCode Go Anthropic *route* hosting (`@arnilo/prism-provider-opencode-go`), automatic credential discovery, Claude Code credential-file/setup-token import, or Claude.ai subscription login/routing. This package is API-key-only.
|
|
12
12
|
|
|
13
13
|
## Inputs / request
|
|
14
14
|
|
|
@@ -43,7 +43,7 @@ Featured offline aliases: `claude-opus-4-8`, `claude-sonnet-5`, `claude-haiku-4-
|
|
|
43
43
|
| Stream | Prism text, thinking deltas, tool-call delta/final, usage (incl. cache read/create when present), `done`, redacted `error`. |
|
|
44
44
|
| Cache | Featured models use `cache.kind: "cache_control"`; markers on selected breakpoints (`long` → `ttl: "1h"`). |
|
|
45
45
|
| Thinking | Model-family aware (`adaptive` vs `enabled`+`budget_tokens`); helpers `anthropicThinking` / `anthropicEffort` / `anthropicPreserveThinking`. |
|
|
46
|
-
| Auth | `api_key` for provider id; provider-owned `content-type`, `x-api-key`, `anthropic-version` win over caller headers. |
|
|
46
|
+
| Auth | `api_key` for provider id; provider-owned `content-type`, `x-api-key`, `anthropic-version` win over caller headers. No OAuth descriptor or subscription adapter is registered. |
|
|
47
47
|
|
|
48
48
|
## Request/response example
|
|
49
49
|
|
|
@@ -75,6 +75,7 @@ api.registerProviderPackage(createAnthropicProviderPackage({ apiKey: hostKey, mo
|
|
|
75
75
|
- Register via `defineProviderPackage` / host registries; no package auto-discovery.
|
|
76
76
|
- AI SDK (`@arnilo/prism-provider-ai-sdk`) remains an escape hatch, not the primary Anthropic path.
|
|
77
77
|
- Live smoke: `PRISM_LIVE_PROVIDER_TESTS=1` + `ANTHROPIC_API_KEY`.
|
|
78
|
+
- Anthropic says OAuth is for purchasers' ordinary Claude Code/native-app use; developers building products must use Claude Console API keys or a supported cloud provider and may not offer Claude.ai login or route Free/Pro/Max credentials ([legal and compliance](https://docs.anthropic.com/en/docs/claude-code/legal-and-compliance)). Prism therefore has no Anthropic subscription OAuth API or token-import shortcut.
|
|
78
79
|
|
|
79
80
|
## Security and performance notes
|
|
80
81
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Azure OpenAI / Foundry
|
|
2
|
+
|
|
3
|
+
## What it does
|
|
4
|
+
|
|
5
|
+
`@arnilo/prism-provider-azure` registers an Azure OpenAI / Foundry Chat Completions provider that uses host-supplied Entra workload identity (Bearer) or Azure resource keys (`api-key`). Deployment URLs keep the configured endpoint host (custom subdomain, private endpoint, or VNet FQDN).
|
|
6
|
+
|
|
7
|
+
## When to use it
|
|
8
|
+
|
|
9
|
+
Use it for enterprise Azure OpenAI / Foundry deployments with Managed Identity or host token providers. Do not fold this into consumer OpenAI packages. Do not embed static keys in fixtures.
|
|
10
|
+
|
|
11
|
+
## Inputs / request
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createAzureOpenAIProviderPackage } from "@arnilo/prism-provider-azure";
|
|
15
|
+
|
|
16
|
+
createAzureOpenAIProviderPackage({
|
|
17
|
+
endpoint: "https://my-resource.openai.azure.com",
|
|
18
|
+
deployment: "gpt-4o",
|
|
19
|
+
apiVersion: "2024-10-21",
|
|
20
|
+
credential: hostEntraToken, // late-bound
|
|
21
|
+
authStyle: "bearer",
|
|
22
|
+
models: [{ provider: "azure", model: "gpt-4o" }],
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
| Field | Meaning |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| `endpoint` | Absolute https resource URL; host preserved |
|
|
29
|
+
| `deployment` | Deployment name (defaults to `model.model`) |
|
|
30
|
+
| `apiVersion` | Query `api-version` (default `2024-10-21`) |
|
|
31
|
+
| `credential` | `CredentialValueSource` — Entra token or resource key |
|
|
32
|
+
| `authStyle` | `bearer` (default) or `api-key` |
|
|
33
|
+
|
|
34
|
+
## Outputs / response / events
|
|
35
|
+
|
|
36
|
+
Reuses `@arnilo/prism/providers/openai-compatible` streaming events (text, tool deltas, usage, done, redacted errors). Missing credentials fail closed before `fetch`.
|
|
37
|
+
|
|
38
|
+
## Request/response example
|
|
39
|
+
|
|
40
|
+
```http
|
|
41
|
+
POST https://my-resource.privatelink.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-10-21
|
|
42
|
+
Authorization: Bearer <entra-token>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Implementation example
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
const provider = createAzureOpenAIProvider({
|
|
49
|
+
endpoint: process.env.AZURE_OPENAI_ENDPOINT!,
|
|
50
|
+
deployment: "gpt-4o",
|
|
51
|
+
credential: () => entra.getToken("https://cognitiveservices.azure.com/.default").then((t) => t.token),
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Opt-in live canaries: inject real `fetch` + host credential behind host CI secrets — no secrets in repo.
|
|
56
|
+
|
|
57
|
+
## Extension and configuration notes
|
|
58
|
+
|
|
59
|
+
Register via `createExtensionKernel().load([createAzureOpenAIProviderPackage(...)])`. Pair with `@arnilo/prism-model-router` for residency allow-lists on Azure regions/endpoints.
|
|
60
|
+
|
|
61
|
+
## Security and performance notes
|
|
62
|
+
|
|
63
|
+
- No credential prefetch at import; resolve per request.
|
|
64
|
+
- Endpoint host is never rewritten to public DNS.
|
|
65
|
+
- Errors redact credential values via shared transport helpers.
|
|
66
|
+
- No Azure SDK dependency.
|
|
67
|
+
|
|
68
|
+
## Related APIs
|
|
69
|
+
|
|
70
|
+
- [OpenAI-compatible provider](openai-compatible.md)
|
|
71
|
+
- [Provider packages](../provider-packages.md)
|
|
72
|
+
- [Model routing](../model-routing.md)
|
|
73
|
+
- [Credential storage](../credential-storage.md)
|
|
74
|
+
- Package README: [`@arnilo/prism-provider-azure`](../../packages/provider-azure/README.md)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Amazon Bedrock
|
|
2
|
+
|
|
3
|
+
## What it does
|
|
4
|
+
|
|
5
|
+
`@arnilo/prism-provider-bedrock` registers an Amazon Bedrock Runtime OpenAI-compatible Chat Completions provider. Hosts supply IAM/IRSA/assumed-role credentials; the package signs requests with SigV4 (no AWS SDK). Region and optional PrivateLink endpoint URLs are preserved.
|
|
6
|
+
|
|
7
|
+
## When to use it
|
|
8
|
+
|
|
9
|
+
Use it for enterprise Bedrock access under workload identity. Do not embed long-lived keys in fixtures. Use model-router residency policy to deny disallowed regions.
|
|
10
|
+
|
|
11
|
+
## Inputs / request
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createBedrockProviderPackage } from "@arnilo/prism-provider-bedrock";
|
|
15
|
+
|
|
16
|
+
createBedrockProviderPackage({
|
|
17
|
+
region: "eu-west-1",
|
|
18
|
+
// endpoint: "https://vpce-….bedrock-runtime.eu-west-1.vpce.amazonaws.com",
|
|
19
|
+
credential: () => hostAwsCredentials(),
|
|
20
|
+
models: [{ provider: "bedrock", model: "anthropic.claude-3-haiku-20240307-v1:0" }],
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
| Field | Meaning |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| `region` | AWS region for signing + default endpoint |
|
|
27
|
+
| `endpoint` | Optional https PrivateLink / VPC interface base URL |
|
|
28
|
+
| `credential` | `{ accessKeyId, secretAccessKey, sessionToken? }` or async callback |
|
|
29
|
+
| `signRequest` | Optional host SigV4 override |
|
|
30
|
+
|
|
31
|
+
Default public base: `https://bedrock-runtime.{region}.amazonaws.com` → `/openai/v1/chat/completions`.
|
|
32
|
+
|
|
33
|
+
## Outputs / response / events
|
|
34
|
+
|
|
35
|
+
OpenAI-compatible SSE mapped to Prism provider events. Missing credentials fail closed before network I/O.
|
|
36
|
+
|
|
37
|
+
## Request/response example
|
|
38
|
+
|
|
39
|
+
```http
|
|
40
|
+
POST https://bedrock-runtime.eu-west-1.amazonaws.com/openai/v1/chat/completions
|
|
41
|
+
Authorization: AWS4-HMAC-SHA256 Credential=…/eu-west-1/bedrock/aws4_request, …
|
|
42
|
+
X-Amz-Security-Token: …
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Implementation example
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
const provider = createBedrockProvider({
|
|
49
|
+
region: "us-east-1",
|
|
50
|
+
credential: async () => fromNodeProviderChain()(),
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Live canaries stay opt-in behind host credentials; default tests are network-free.
|
|
55
|
+
|
|
56
|
+
## Extension and configuration notes
|
|
57
|
+
|
|
58
|
+
Uses Bedrock’s OpenAI-compatible runtime route (not Converse eventstream). Hosts needing Converse-only models should supply a custom provider or AI SDK bridge.
|
|
59
|
+
|
|
60
|
+
## Security and performance notes
|
|
61
|
+
|
|
62
|
+
- No AWS SDK; package-local SigV4 only for `bedrock` service.
|
|
63
|
+
- Private endpoint hosts are not rewritten to public DNS.
|
|
64
|
+
- Credential secrets are redacted from provider errors.
|
|
65
|
+
- No credential prefetch at import.
|
|
66
|
+
|
|
67
|
+
## Related APIs
|
|
68
|
+
|
|
69
|
+
- [OpenAI-compatible provider](openai-compatible.md)
|
|
70
|
+
- [Model routing](../model-routing.md)
|
|
71
|
+
- [Provider packages](../provider-packages.md)
|
|
72
|
+
- Package README: [`@arnilo/prism-provider-bedrock`](../../packages/provider-bedrock/README.md)
|
package/docs/providers/google.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
Use for first-party Gemini Developer API coding-host semantics (function calling, multimodal `inlineData`, thinking, usage, abort). Prefer this over the AI SDK escape hatch when Gemini is a primary host.
|
|
10
10
|
|
|
11
|
-
Do **not** use for Vertex enterprise identity (deferred to 0.0.13+)
|
|
11
|
+
Do **not** use for Vertex enterprise identity (deferred to 0.0.13+), as a substitute for Anthropic Messages, or Gemini CLI OAuth/credential-file/token import. This package is API-key-only.
|
|
12
12
|
|
|
13
13
|
## Inputs / request
|
|
14
14
|
|
|
@@ -43,7 +43,7 @@ Featured offline aliases include `gemini-2.5-pro`, `gemini-2.5-flash`, `gemini-2
|
|
|
43
43
|
| Stream | Prism text, thinking when present, **complete** `tool_call` events (Gemini does not stream argument deltas), usage, `done`, redacted `error`. |
|
|
44
44
|
| Cache | No Anthropic-style `cache_control`; Gemini implicit caching is not exposed as Prism breakpoints in 0.0.11. |
|
|
45
45
|
| Multimodal | `inlineData` parts with MIME + base64; capability checks fail closed for unsupported modalities. |
|
|
46
|
-
| Auth | `api_key`; provider-owned `content-type` + `x-goog-api-key` win over caller headers. |
|
|
46
|
+
| Auth | `api_key`; provider-owned `content-type` + `x-goog-api-key` win over caller headers. No OAuth descriptor or Gemini CLI subscription adapter is registered. |
|
|
47
47
|
|
|
48
48
|
## Request/response example
|
|
49
49
|
|
|
@@ -71,6 +71,7 @@ api.registerProviderPackage(createGoogleProviderPackage({ apiKey: hostKey, model
|
|
|
71
71
|
- AI SDK remains an escape hatch, not the primary Google path.
|
|
72
72
|
- Live smoke: `PRISM_LIVE_PROVIDER_TESTS=1` + `GOOGLE_API_KEY` or `GEMINI_API_KEY`.
|
|
73
73
|
- Vertex / enterprise identity stays out of 0.0.11.
|
|
74
|
+
- Gemini CLI says third-party software accessing its backend through Gemini CLI OAuth violates applicable terms, and its FAQ directs third-party coding agents to Vertex AI or Google AI Studio API keys ([terms](https://github.com/google-gemini/gemini-cli/blob/main/docs/resources/tos-privacy.md), [FAQ](https://github.com/google-gemini/gemini-cli/blob/main/docs/resources/faq.md)). Prism therefore has no Gemini CLI OAuth API or token-import shortcut.
|
|
74
75
|
|
|
75
76
|
## Security and performance notes
|
|
76
77
|
|
|
@@ -81,6 +82,7 @@ api.registerProviderPackage(createGoogleProviderPackage({ apiKey: hostKey, model
|
|
|
81
82
|
|
|
82
83
|
## Related APIs
|
|
83
84
|
|
|
85
|
+
- [Google Vertex AI](vertex.md): enterprise ADC/workload-identity package (separate from this consumer API-key package).
|
|
84
86
|
- [Provider packages](../provider-packages.md): package setup + discovery contract.
|
|
85
87
|
- [Thinking and reasoning](../thinking-and-reasoning.md): portable thinking helpers.
|
|
86
88
|
- [Provider conformance](../provider-conformance.md): network-free assertions.
|
|
@@ -27,9 +27,11 @@ Options:
|
|
|
27
27
|
| Field | Type | Purpose |
|
|
28
28
|
| --- | --- | --- |
|
|
29
29
|
| `id` | `string` | Optional provider id. Defaults to `openai-compatible`. |
|
|
30
|
-
| `baseUrl` | `string` | Base API URL; `/chat/completions` is appended. |
|
|
30
|
+
| `baseUrl` | `string` | Base API URL; `/chat/completions` is appended unless `chatCompletionsUrl` is set. |
|
|
31
31
|
| `apiKey` | `CredentialValueSource` | Optional direct/callback/resolver credential source. |
|
|
32
32
|
| `fetch` | `typeof fetch` | Optional fetch implementation for tests or custom hosts. |
|
|
33
|
+
| `chatCompletionsUrl` | `string \| ((request) => string)` | Optional full chat-completions URL override (Azure deployment paths). |
|
|
34
|
+
| `authStyle` | `"bearer" \| "api-key" \| "none"` | Auth header style. Default `bearer`. |
|
|
33
35
|
|
|
34
36
|
Provider requests use the standard `ProviderRequest` shape: `model`, `messages`, optional `tools`, `metadata`, and `signal`.
|
|
35
37
|
|
package/docs/providers/openai.md
CHANGED
|
@@ -52,7 +52,7 @@ uses official Responses `reasoning: { effort, summary? }` via
|
|
|
52
52
|
| --- | --- |
|
|
53
53
|
| Provider stream | Prism text, thinking (downgraded to text), `tool_call` deltas/finals, `usage`, `done`, redacted `error` events. |
|
|
54
54
|
| Block preservation | User/system text → `input_text`; assistant text → `output_text`; assistant `tool_call` → top-level `function_call` with `call_id`; `tool_result` → top-level `function_call_output`; images/files/audio when declared on the model. Bare thinking without an encrypted Responses reasoning item is omitted on replay. |
|
|
55
|
-
| Auth methods | `api_key` for `openai`; `oauth` for `openai-codex`. |
|
|
55
|
+
| Auth methods | `api_key` for `openai`; host-invoked subscription `oauth` for `openai-codex`. This is Prism's only first-party subscription OAuth flow in 0.0.12. |
|
|
56
56
|
|
|
57
57
|
Unsupported block placements or unclaimed images fail before `fetch`.
|
|
58
58
|
|
|
@@ -120,7 +120,7 @@ const challenge = computeS256Challenge(verifier);
|
|
|
120
120
|
- Hosts/apps control model selection, credential resolution, and cache policy per
|
|
121
121
|
run/model through `RunOptions` and `ModelConfig.compat`.
|
|
122
122
|
- OAuth browser/device-code flows run only when the caller explicitly invokes the
|
|
123
|
-
OAuth provider.
|
|
123
|
+
OAuth provider. Login UI and optional durable token storage remain host-owned; no ambient credential discovery or refresh timer is installed.
|
|
124
124
|
- Device-code login polls the token endpoint with server-directed `interval` and
|
|
125
125
|
`expires_in`, honors RFC 8628 `authorization_pending` / `slow_down`, and stops
|
|
126
126
|
on terminal errors or expiry. Pass `signal` on `OAuthLoginCallbacks` to abort
|
|
@@ -188,9 +188,11 @@ cache-read pricing exists), and seeds `compat.reasoning.effort` from
|
|
|
188
188
|
hidden app identity.
|
|
189
189
|
- Live tests stay opt-in behind `PRISM_LIVE_PROVIDER_TESTS=1` plus fake-safe
|
|
190
190
|
provider-specific env names; default tests are network-free.
|
|
191
|
+
- Enterprise hosts that must gate `compat.openRouterRouting` should wrap selection with `@arnilo/prism-model-router` (`allowOpenRouterRouting`); the OpenRouter adapter itself still passthroughs routing when present on the request.
|
|
191
192
|
|
|
192
193
|
## Related APIs
|
|
193
194
|
|
|
195
|
+
- [Model routing](../model-routing.md): optional allow-list/residency/budget/circuit facade and OpenRouter routing gate.
|
|
194
196
|
- [Provider packages](../provider-packages.md): `defineProviderPackage`,
|
|
195
197
|
`ModelConfig`/`compat`, cache policy, caller-gated discovery.
|
|
196
198
|
- [Thinking and reasoning](../thinking-and-reasoning.md): `applyThinkingLevel`
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Google Vertex AI
|
|
2
|
+
|
|
3
|
+
## What it does
|
|
4
|
+
|
|
5
|
+
`@arnilo/prism-provider-vertex` registers a Vertex AI OpenAPI-compatible Chat Completions provider authenticated with host ADC / workload identity tokens. It is intentionally separate from `@arnilo/prism-provider-google` (consumer Gemini API keys).
|
|
6
|
+
|
|
7
|
+
## When to use it
|
|
8
|
+
|
|
9
|
+
Use it for GCP enterprise Vertex deployments with Application Default Credentials or workload identity federation. Do not use the consumer Google package for Vertex auth semantics.
|
|
10
|
+
|
|
11
|
+
## Inputs / request
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createVertexProviderPackage } from "@arnilo/prism-provider-vertex";
|
|
15
|
+
|
|
16
|
+
createVertexProviderPackage({
|
|
17
|
+
projectId: "my-gcp-project",
|
|
18
|
+
location: "europe-west1",
|
|
19
|
+
credential: () => hostAdcAccessToken(),
|
|
20
|
+
models: [{ provider: "vertex", model: "google/gemini-2.0-flash-001" }],
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
| Field | Meaning |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| `projectId` | GCP project |
|
|
27
|
+
| `location` | Vertex location / region |
|
|
28
|
+
| `endpoint` | Optional full https OpenAPI base (private/custom); otherwise location-scoped default |
|
|
29
|
+
| `credential` | Bearer access token source (ADC / WIF) |
|
|
30
|
+
|
|
31
|
+
Default base: `https://{location}-aiplatform.googleapis.com/v1/projects/{project}/locations/{location}/endpoints/openapi`.
|
|
32
|
+
|
|
33
|
+
## Outputs / response / events
|
|
34
|
+
|
|
35
|
+
OpenAI-compatible SSE → Prism provider events. Missing ADC token fails closed before `fetch`.
|
|
36
|
+
|
|
37
|
+
## Request/response example
|
|
38
|
+
|
|
39
|
+
```http
|
|
40
|
+
POST https://europe-west1-aiplatform.googleapis.com/v1/projects/my-gcp-project/locations/europe-west1/endpoints/openapi/chat/completions
|
|
41
|
+
Authorization: Bearer <adc-token>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Implementation example
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
const provider = createVertexProvider({
|
|
48
|
+
projectId: "my-gcp-project",
|
|
49
|
+
location: "us-central1",
|
|
50
|
+
credential: async () => (await GoogleAuth.getAccessToken()),
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Extension and configuration notes
|
|
55
|
+
|
|
56
|
+
`@arnilo/prism-provider-google` remains API-key Gemini (`generativelanguage.googleapis.com`) and must not register Vertex OAuth/ADC. Load this package explicitly for Vertex.
|
|
57
|
+
|
|
58
|
+
## Security and performance notes
|
|
59
|
+
|
|
60
|
+
- No Google Cloud SDK dependency in the package.
|
|
61
|
+
- Custom/private endpoint hosts are preserved.
|
|
62
|
+
- Tokens redacted from errors; no import-time credential prefetch.
|
|
63
|
+
- Pair with model-router residency allow-lists on `location`.
|
|
64
|
+
|
|
65
|
+
## Related APIs
|
|
66
|
+
|
|
67
|
+
- [Google Gemini (consumer)](google.md)
|
|
68
|
+
- [OpenAI-compatible provider](openai-compatible.md)
|
|
69
|
+
- [Provider packages](../provider-packages.md)
|
|
70
|
+
- [Model routing](../model-routing.md)
|
|
71
|
+
- Package README: [`@arnilo/prism-provider-vertex`](../../packages/provider-vertex/README.md)
|
package/docs/public-contracts.md
CHANGED
|
@@ -15,7 +15,8 @@ Current contract groups:
|
|
|
15
15
|
- Extensions/middleware: `ExtensionLifecycleEventName`, `ExtensionEvent`, `Extension`, `ExtensionAPI`, `MiddlewareHookName`, `Middleware`, `MiddlewareNext`, `MiddlewareRegistry`
|
|
16
16
|
- Configuration/manifests: `ConfigProvider`, `ConfigLayer`, `ConfigLoadContext`, `PrismManifest`, `ManifestContributionDeclaration`, `ManifestResourceDeclaration`, `ManifestContributionKind`
|
|
17
17
|
- Stores/resources/settings/credentials/compaction/retry/cache helpers: `SessionEntry`, `SessionStore`, `StoreFactory`, `Resource`, `ResourceLoader`, `ResourceLoadContext`, `SettingsProvider`, `CredentialRequest`, `Credential`, `CredentialResolver`, `CompactionStrategy`, `CompactionContext`, `CompactionResult`, `CompactionOptions`, `CompactionMiddlewarePayload`, `CompactionEntryData`, `DefaultCompactionStrategyOptions`, `RetryPolicy`, `RetryContext`, `RetryDecision`, `RetryOptions`, `RetryMiddlewarePayload`, `DefaultRetryPolicyOptions`, `CacheUsageReport`, `sanitizeCacheKey`, `mapCacheRetention`, `applyCacheControl`, `cacheHitRate`, `cacheSavings`, `cacheUsageReport`
|
|
18
|
-
- Production persistence (adapter-facing): `ProductionPersistenceStore
|
|
18
|
+
- Production persistence (adapter-facing): `ProductionPersistenceStore` (optional `lifecycle`), `CheckpointStore`, `CheckpointKey`, `CheckpointSaveInput`, `CheckpointRecord`, `CheckpointQuery`, `LeaseStore`, `LeaseKey`, `LeaseAcquireInput`, `LeaseClaimInput`, `LeaseRecord`, `PersistencePage`, `PersistenceQuery`, `OwnershipScope`, `SessionRecord`, `SessionQuery`, `BranchRecord`, `BranchQuery`, `SessionEntryQuery`, `RunRecord`, `RunQuery`, `RunFeedbackRecord`, `RunFeedbackStore`, `RunFeedbackQuery`, `AgentEventRecord`, `AgentEventQuery`, `ToolCallRecord`, `ToolCallQuery`, `UsageRecord`, `UsageQuery`, `AgentDefinitionRecord`, `AgentDefinitionQuery`, `RetentionPolicy`, `RetentionPolicyQuery`, `MigrationRecord`, `MigrationQuery`, `PersistenceLifecycleStore`, `LegalHoldRecord`, `TenantQuota`
|
|
19
|
+
- Identity: `Principal`, `AgentIdentity`, `IdentityVerifier`, `assertIdentityActive`, `narrowIdentity`, `ownershipFromIdentity`, `assertIdentityMatchesOwnership`, `assertIdentityPropagation`, `identityTelemetryAttributes`, `resolveRunIdentity`, `IdentityError`, identity limit constants
|
|
19
20
|
|
|
20
21
|
## When to use it
|
|
21
22
|
|
|
@@ -132,6 +133,7 @@ Important request shapes:
|
|
|
132
133
|
| `AgentSessionConfig` | Session creation input: optional id, agent, store, leaf id, and metadata. |
|
|
133
134
|
| `RunOptions` | Per-run overrides: optional abort signal, model, input layout, max tool rounds, provider options/request policies, system prompt layers, compaction, retry, metadata, skill selection, validate, redactor, and loop. |
|
|
134
135
|
| `SubscribeOptions` / `SubscriberOverflowPolicy` | Live `AgentEvent` subscriber queue limit and overflow policy: `maxQueuedEvents`, `overflow: "close" \| "drop_oldest" \| "drop_newest"`. |
|
|
136
|
+
| `resumeAgentRunStream` / `AgentRunResumeStreamOptions` | One durable-run event stream: existing checkpoint/resume options plus `signal` and bounded subscriber options. `AgentRunLifecycle.resumeStream()` adds host capability resolution; no protocol types enter core. |
|
|
135
137
|
| `AgentConfig.loop` / `RunOptions.loop` | Replaceable per-run control loop: `singleShotLoop` default, `generate-validate-revise` options, or a custom `AgentLoopStrategy`. `RunOptions.loop` wins. See [Agent loops](agent-loops.md). |
|
|
136
138
|
| `AgentLoopStrategy` | `{ name; run(ctx: LoopContext): Promise<Usage \| undefined> }` — orchestrates shared runtime primitives via `LoopContext`. |
|
|
137
139
|
| `LoopContext` | Loop-facing surface: run ids, signal, live `history`, `input`/`inputMessages`/`maxToolRounds`, and bound `assemble`/`generate`/`dispatchToolCall`/`appendMessage`/`emit` primitives. |
|
|
@@ -164,6 +166,7 @@ Important request shapes:
|
|
|
164
166
|
| `CacheUsageReport` | Numeric cache diagnostics from normalized `Usage`: read/write tokens, hit rate, estimated savings, and optional currency. |
|
|
165
167
|
| `AgentDefinitionRecord` / `AgentDefinitionQuery` | Versioned agent-definition snapshot and filters. Does not store credentials or provider instances. |
|
|
166
168
|
| `RetentionPolicy` / `RetentionPolicyQuery` | Retention policy and filters: age, entry count, byte limits, archive store, applied kinds. |
|
|
169
|
+
| `PersistenceLifecycleStore` / `LegalHoldRecord` / `TenantQuota` | Optional hold/retention apply/export/quota capability on `ProductionPersistenceStore.lifecycle`. |
|
|
167
170
|
| `MigrationRecord` / `MigrationQuery` | Applied migration record and filters. |
|
|
168
171
|
|
|
169
172
|
## Outputs / response / events
|
|
@@ -447,6 +450,7 @@ void credentials;
|
|
|
447
450
|
- [Agent/session runtime](agent-session-runtime.md): `createAgent()` / `createAgentSession()` runtime, `AgentSession.compact()`, and auto-compaction config built on these contracts.
|
|
448
451
|
- [Agent loops](agent-loops.md): `singleShotLoop` default, `generateValidateReviseLoop`, `resolveLoop`, and the `Artifact*`/`AgentLoop*`/`LoopContext` contracts.
|
|
449
452
|
- [Agent events](agent-events.md): the `AgentEvent` union including `artifact_*` variants and event ordering.
|
|
453
|
+
- [Frontend interoperability (AG-UI and ACP)](ag-ui.md): optional protocol package consuming `AgentEvent`, `AgentRunLifecycle`, `OwnershipScope`, and `AgentEventRecord`; AG-UI/ACP protocol types do not enter root contracts.
|
|
450
454
|
- [Structured output](structured-output.md): the `ArtifactParser<T>`/`ArtifactValidator<T>`/`ArtifactRepairer<T>` seam — the only typed-output path from a loop.
|
|
451
455
|
- [Session stores](session-stores.md): `SessionStore` contract, branch-aware `SessionEntry` helpers, context rebuild, and store responsibilities.
|
|
452
456
|
- [Database persistence](database-persistence.md): production persistence contracts, paginated query shapes, reference schema, indexes, retention, migrations, and NoSQL mapping.
|