@arnilo/prism 0.3.2 → 0.5.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/CHANGELOG.md +50 -1
- package/README.md +42 -62
- package/dist/agent-run-lifecycle.js +4 -0
- package/dist/agent-run-state.d.ts +5 -2
- package/dist/agent-run-state.js +18 -8
- 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 +54 -41
- package/dist/agent-session/session.js +23 -1132
- package/dist/capture.d.ts +63 -0
- package/dist/capture.js +67 -0
- package/dist/cli-dev.d.ts +29 -0
- package/dist/cli-dev.js +52 -0
- package/dist/cli-init.d.ts +34 -3
- package/dist/cli-init.js +192 -24
- package/dist/cli-runner.d.ts +6 -2
- package/dist/cli-runner.js +57 -10
- package/dist/content.d.ts +3 -3
- package/dist/content.js +3 -1
- package/dist/contracts-core/agent.d.ts +8 -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 +18 -0
- package/dist/contracts-run-state.d.ts +1 -2
- package/dist/index.d.ts +7 -3
- package/dist/index.js +5 -3
- package/dist/input.d.ts +8 -0
- package/dist/input.js +4 -0
- 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/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/persistence-schema.d.ts +1 -1
- package/dist/testing/persistence-schema.js +32 -28
- package/dist/testing/provider-conformance.d.ts +114 -5
- package/dist/testing/provider-conformance.js +342 -0
- package/dist/testing/tool-conformance.d.ts +25 -0
- package/dist/testing/tool-conformance.js +128 -1
- 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/dist/tool-search.d.ts +76 -0
- package/dist/tool-search.js +199 -0
- package/docs/0.1.0-readiness.md +3 -3
- package/docs/a2a.md +2 -2
- package/docs/acp-agent.md +1 -1
- 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/audit-export.md +3 -3
- package/docs/batch-jobs.md +120 -0
- package/docs/browser-automation.md +5 -5
- package/docs/caveman.md +2 -2
- package/docs/cli-rpc.md +43 -9
- package/docs/coding-agent-tools.md +19 -19
- package/docs/coding-review-and-diagnostics.md +2 -2
- package/docs/coding-security.md +5 -5
- package/docs/coding-tools.md +82 -0
- package/docs/coding-workspaces.md +2 -2
- package/docs/compaction-and-retry.md +2 -2
- package/docs/compaction-llm.md +4 -4
- package/docs/compaction-observational-memory.md +3 -3
- package/docs/computer-use-linux.md +13 -2
- package/docs/context-and-skills.md +3 -1
- package/docs/conversations.md +4 -4
- package/docs/core.md +85 -0
- package/docs/credential-storage.md +12 -8
- package/docs/credentials-and-redaction.md +1 -1
- package/docs/data-classification.md +1 -1
- package/docs/database-persistence.md +7 -3
- package/docs/dev-inspector.md +103 -0
- package/docs/device-adapters.md +2 -2
- package/docs/diagrams.md +247 -0
- package/docs/document-reader.md +6 -6
- package/docs/documents.md +214 -0
- package/docs/embeddings.md +112 -0
- package/docs/enterprise-postgres-state.md +7 -7
- package/docs/evaluations.md +41 -7
- package/docs/extensions.md +3 -3
- package/docs/forge-integration.md +3 -3
- package/docs/graft.md +5 -5
- package/docs/guardrails.md +2 -2
- package/docs/host-security.md +16 -15
- package/docs/image-generation.md +129 -0
- package/docs/impeccable.md +7 -5
- package/docs/index.md +84 -46
- package/docs/indexed-code-search.md +2 -2
- package/docs/language-intelligence.md +4 -4
- package/docs/live-testing.md +126 -0
- package/docs/mcp-tools.md +44 -13
- package/docs/middleware-hooks.md +1 -1
- package/docs/migrate-to-0.4.md +312 -0
- package/docs/migrate-to-0.5.md +122 -0
- package/docs/migration.md +51 -1
- package/docs/model-registry.md +38 -0
- package/docs/model-routing.md +6 -6
- package/docs/moderation.md +117 -0
- package/docs/multi-agent-patterns.md +177 -0
- package/docs/multimodal-content.md +27 -3
- package/docs/obscura.md +12 -12
- package/docs/observability.md +32 -7
- package/docs/openapi-tools.md +14 -4
- package/docs/operations.md +11 -0
- package/docs/performance.md +30 -10
- package/docs/persistence-credentials-multimodality-primitives.md +7 -7
- package/docs/policy-and-audit.md +18 -8
- package/docs/ponytail.md +3 -3
- package/docs/postgres-persistence.md +5 -5
- package/docs/process-sessions.md +2 -2
- package/docs/prompt-registry.md +106 -0
- package/docs/provider-caching.md +36 -32
- package/docs/provider-conformance.md +24 -2
- package/docs/provider-packages.md +58 -22
- package/docs/provider-primitives.md +5 -5
- package/docs/provider-request-policies.md +1 -1
- package/docs/providers/ai-sdk.md +18 -6
- package/docs/providers/alibaba.md +10 -6
- package/docs/providers/anthropic.md +10 -6
- package/docs/providers/azure.md +20 -4
- package/docs/providers/bedrock.md +18 -3
- package/docs/providers/clinepass.md +7 -3
- package/docs/providers/commandcode.md +253 -0
- package/docs/providers/deepseek.md +7 -3
- package/docs/providers/google.md +8 -4
- package/docs/providers/hyper.md +284 -0
- package/docs/providers/kimi.md +7 -3
- package/docs/providers/neuralwatt.md +12 -8
- package/docs/providers/ollama.md +18 -3
- package/docs/providers/openai-compatible.md +5 -1
- package/docs/providers/openai.md +9 -5
- package/docs/providers/opencode-go.md +8 -4
- package/docs/providers/openrouter.md +8 -4
- package/docs/providers/vertex.md +21 -5
- package/docs/providers/xai.md +7 -3
- package/docs/providers/zai.md +7 -3
- package/docs/rag.md +31 -9
- package/docs/release-and-install.md +181 -76
- package/docs/resource-loading.md +1 -1
- package/docs/runs-and-usage.md +28 -3
- package/docs/server.md +94 -5
- package/docs/settings-auth-trust-security.md +7 -5
- package/docs/sheets.md +229 -0
- package/docs/speech.md +126 -0
- package/docs/sqlite-persistence.md +4 -4
- package/docs/supervisors.md +4 -3
- package/docs/thinking-and-reasoning.md +93 -60
- package/docs/tool-conformance.md +28 -3
- package/docs/tool-execution-primitives.md +8 -8
- package/docs/tools.md +32 -5
- package/docs/web-tools.md +3 -3
- package/docs/wiki.md +7 -7
- 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 +35 -11
- package/docs/workflows.md +74 -13
- package/docs/working-and-semantic-memory.md +53 -5
- package/package.json +14 -31
- package/templates/README.md +23 -0
- package/templates/deep-research/README.md.tmpl +47 -0
- package/templates/deep-research/env.example.tmpl +12 -0
- package/templates/deep-research/gitignore.tmpl +7 -0
- package/templates/deep-research/manifest.json +12 -0
- package/templates/deep-research/package.json.tmpl +23 -0
- package/templates/deep-research/src/agent.ts.tmpl +81 -0
- package/templates/deep-research/src/index.ts.tmpl +53 -0
- package/templates/deep-research/src/tests/research.test.ts.tmpl +114 -0
- package/templates/deep-research/src/tools.ts.tmpl +86 -0
- package/templates/deep-research/src/types.ts.tmpl +45 -0
- package/templates/deep-research/src/workflow.ts.tmpl +156 -0
- package/templates/deep-research/tsconfig.json.tmpl +15 -0
- package/templates/init/manifest.json +5 -0
- package/templates/init/package.json.tmpl +2 -1
- package/templates/init/providers.json +40 -24
- package/docs/antigravity-agent.md +0 -207
package/docs/providers/vertex.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## What it does
|
|
4
4
|
|
|
5
|
-
`@arnilo/prism-
|
|
5
|
+
`@arnilo/prism-providers/vertex` registers a Vertex AI OpenAPI-compatible Chat Completions provider authenticated with host ADC / workload identity tokens. It is intentionally separate from `@arnilo/prism-providers/google` (consumer Gemini API keys).
|
|
6
6
|
|
|
7
7
|
## When to use it
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ Use it for GCP enterprise Vertex deployments with Application Default Credential
|
|
|
11
11
|
## Inputs / request
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import { createVertexProviderPackage } from "@arnilo/prism-
|
|
14
|
+
import { createVertexProviderPackage } from "@arnilo/prism-providers/vertex";
|
|
15
15
|
|
|
16
16
|
createVertexProviderPackage({
|
|
17
17
|
projectId: "my-gcp-project",
|
|
@@ -53,20 +53,36 @@ const provider = createVertexProvider({
|
|
|
53
53
|
|
|
54
54
|
## Extension and configuration notes
|
|
55
55
|
|
|
56
|
-
`@arnilo/prism-
|
|
56
|
+
`@arnilo/prism-providers/google` remains API-key Gemini (`generativelanguage.googleapis.com`) and must not register Vertex OAuth/ADC. Load this package explicitly for Vertex.
|
|
57
57
|
|
|
58
58
|
## Security and performance notes
|
|
59
59
|
|
|
60
60
|
- No Google Cloud SDK dependency in the package.
|
|
61
61
|
- Custom/private endpoint hosts are preserved.
|
|
62
62
|
- Tokens redacted from errors; no import-time credential prefetch — the credential is resolved exactly once per request (a rotating `CredentialValueSource` is never consumed twice; the same resolved token drives the wrapper check and the inner auth header).
|
|
63
|
-
- Conformance-proven (Task 6): package `setup()` performs zero fetch and zero credential resolution; an already-aborted signal fails fast; a truncated SSE stream (no `data: [DONE]`) ends in an `error` event; native Vertex cached-content lifecycle is intentionally unsupported on the OpenAI-compatible route — no cache wire fields are emitted even when the request carries Prism cache hints (use `@arnilo/prism-
|
|
63
|
+
- Conformance-proven (Task 6): package `setup()` performs zero fetch and zero credential resolution; an already-aborted signal fails fast; a truncated SSE stream (no `data: [DONE]`) ends in an `error` event; native Vertex cached-content lifecycle is intentionally unsupported on the OpenAI-compatible route — no cache wire fields are emitted even when the request carries Prism cache hints (use `@arnilo/prism-providers/google`'s `extra.cachedContent` on that package, or manage cache resources host-side).
|
|
64
64
|
- Pair with model-router residency allow-lists on `location`.
|
|
65
65
|
|
|
66
|
+
## Live probe
|
|
67
|
+
|
|
68
|
+
Opt-in smoke against Vertex's OpenAI-compatible endpoint. The suite takes a pre-minted bearer token (host ADC/workload identity stays host-owned):
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
PRISM_LIVE_PROVIDER_TESTS=1 GOOGLE_VERTEX_PROJECT=my-project \
|
|
72
|
+
PRISM_VERTEX_ACCESS_TOKEN=$(gcloud auth print-access-token) \
|
|
73
|
+
node --test packages/prism-providers/dist/vertex/__tests__/live.test.js
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`GOOGLE_VERTEX_LOCATION` (default `us-central1`) and `PRISM_LIVE_VERTEX_MODEL` (default `gemini-2.5-flash`) are optional. Missing project or token → skip.
|
|
77
|
+
|
|
78
|
+
## Thinking and reasoning
|
|
79
|
+
|
|
80
|
+
Vertex AI OpenAI-compat chat uses the same sanitized thinking-compat forwarding as Azure: `reasoning_effort` (aliases `effort`/`reasoningEffort`) or a `reasoning` object, snapped to the model's declared levels (Gemini → `low/medium/high`). `reasoning_effort` and `extra_body.google.thinking_config` are mutually exclusive upstream — send one. See [Thinking and reasoning](../thinking-and-reasoning.md).
|
|
81
|
+
|
|
66
82
|
## Related APIs
|
|
67
83
|
|
|
68
84
|
- [Google Gemini (consumer)](google.md)
|
|
69
85
|
- [OpenAI-compatible provider](openai-compatible.md)
|
|
70
86
|
- [Provider packages](../provider-packages.md)
|
|
71
87
|
- [Model routing](../model-routing.md)
|
|
72
|
-
- Package README: [`@arnilo/prism-
|
|
88
|
+
- Package README: [`@arnilo/prism-providers` family README](../../packages/prism-providers/README.md)
|
package/docs/providers/xai.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## What it does
|
|
4
4
|
|
|
5
|
-
`@arnilo/prism-
|
|
5
|
+
`@arnilo/prism-providers/xai` provides explicit, side-effect-free setup for the
|
|
6
6
|
xAI Grok Chat Completions API (`POST https://api.x.ai/v1/chat/completions`)
|
|
7
7
|
with implicit prefix caching via a sanitized `x-grok-conv-id` header, reasoning
|
|
8
8
|
replay, and host-invoked SuperGrok / X Premium OAuth.
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
createXaiOAuthProvider,
|
|
26
26
|
createXaiProviderPackage,
|
|
27
27
|
listXaiModels,
|
|
28
|
-
} from "@arnilo/prism-
|
|
28
|
+
} from "@arnilo/prism-providers/xai";
|
|
29
29
|
|
|
30
30
|
createXaiProviderPackage(options: XaiProviderPackageOptions): ProviderPackage
|
|
31
31
|
createXaiOAuthProvider(options?: XaiOAuthOptions): OAuthProvider
|
|
@@ -84,7 +84,7 @@ Header: `x-grok-conv-id: sess-1`.
|
|
|
84
84
|
|
|
85
85
|
```ts
|
|
86
86
|
import { createExtensionKernel, refreshOAuthCredential } from "@arnilo/prism";
|
|
87
|
-
import { createXaiOAuthProvider, createXaiProviderPackage } from "@arnilo/prism-
|
|
87
|
+
import { createXaiOAuthProvider, createXaiProviderPackage } from "@arnilo/prism-providers/xai";
|
|
88
88
|
|
|
89
89
|
const kernel = createExtensionKernel();
|
|
90
90
|
await kernel.load([createXaiProviderPackage({ apiKey: "fake-xai-key" })]);
|
|
@@ -123,6 +123,10 @@ await kernel.load([
|
|
|
123
123
|
- Bounded OAuth and API error bodies. No retry loop. No refresh timer.
|
|
124
124
|
- Live API-key smoke: `PRISM_LIVE_PROVIDER_TESTS=1` + `XAI_API_KEY`. SuperGrok login is operator-only (`PRISM_LIVE_XAI_OAUTH=1`).
|
|
125
125
|
|
|
126
|
+
## Thinking and reasoning
|
|
127
|
+
|
|
128
|
+
Reasoning models now send `reasoning_effort` (task-065 change — previously dropped): grok-4.6 declares `low/medium/high/xhigh` (default `high`), grok-4.5 `low/medium/high`, grok-4.3 `none/low/medium/high`. Effort snaps to the declared set (nearest, ties up); `grok-build` declares nothing and passes `reasoning_effort` through verbatim. Reasoning models must still replay `reasoning_content` — Featured Completions flatten nothing. See [Thinking and reasoning](../thinking-and-reasoning.md).
|
|
129
|
+
|
|
126
130
|
## Related APIs
|
|
127
131
|
|
|
128
132
|
- [Provider packages](../provider-packages.md): OAuth support matrix.
|
package/docs/providers/zai.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## What it does
|
|
4
4
|
|
|
5
|
-
`@arnilo/prism-
|
|
5
|
+
`@arnilo/prism-providers/zai` provides explicit, side-effect-free setup for the Z.AI
|
|
6
6
|
GLM Chat Completions API (`POST /chat/completions`) with official deep-thinking,
|
|
7
7
|
reasoning-effort, and tool-stream request fields.
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
createZaiProviderPackage,
|
|
26
26
|
defineZaiModel,
|
|
27
27
|
listZaiModels,
|
|
28
|
-
} from "@arnilo/prism-
|
|
28
|
+
} from "@arnilo/prism-providers/zai";
|
|
29
29
|
|
|
30
30
|
createZaiProviderPackage(options: ZaiProviderPackageOptions): ProviderPackage
|
|
31
31
|
defineZaiModel(config: ZaiModelConfig): ModelConfig
|
|
@@ -87,7 +87,7 @@ Example request body (official Chat Completions shape):
|
|
|
87
87
|
|
|
88
88
|
```ts
|
|
89
89
|
import { createExtensionKernel } from "@arnilo/prism";
|
|
90
|
-
import { createZaiProviderPackage, listZaiModels } from "@arnilo/prism-
|
|
90
|
+
import { createZaiProviderPackage, listZaiModels } from "@arnilo/prism-providers/zai";
|
|
91
91
|
|
|
92
92
|
const kernel = createExtensionKernel();
|
|
93
93
|
await kernel.load([createZaiProviderPackage({ apiKey: "fake-zai-key" })]);
|
|
@@ -153,6 +153,10 @@ await session.prompt("Plan the refactor", {
|
|
|
153
153
|
- Live tests stay opt-in behind `PRISM_LIVE_PROVIDER_TESTS=1` plus `ZAI_API_KEY`;
|
|
154
154
|
default tests are network-free.
|
|
155
155
|
|
|
156
|
+
## Thinking and reasoning
|
|
157
|
+
|
|
158
|
+
Z.AI models are family-stamped by id. GLM-5.3/5.3-FLASH: `reasoning_effort` restricted to `low/high/max` (declared; other levels snap, e.g. `medium`→`high`), and thinking can never be disabled — `zaiThinking` forces thinking on and never emits `thinking.type: "disabled"` (upstream rejects it; live-pinned). GLM-5.2: declared `low`–`max`; `none`/`minimal` stop thinking (no effort field), `low`/`medium` snap up to `high`. GLM-4.x and older: `thinking_type` toggle only (`clear_thinking` package-local). See [Thinking and reasoning](../thinking-and-reasoning.md).
|
|
159
|
+
|
|
156
160
|
## Related APIs
|
|
157
161
|
|
|
158
162
|
- [Provider packages](../provider-packages.md): `defineProviderPackage`,
|
package/docs/rag.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## What it does
|
|
4
4
|
|
|
5
|
-
`@arnilo/prism-rag` is an optional
|
|
5
|
+
The `@arnilo/prism-memory/rag` subpath is an optional surface for deterministic text/Markdown chunking (with ATX heading-stack metadata), bounded embedding/vector indexing with embedder-identity drift guards, atomic scoped source replacement/deletion with content-hash skip and generation visibility, hybrid vector+lexical retrieval with reciprocal-rank fusion (one embed / one RRF / one rerank across one or many exact scopes), focused text/Markdown/HTML/PDF parsing, bounded reranking (host seam plus a TEI REST adapter), ingestion status, attributable citations, content-trust metadata, and explicit `ContextProvider` injection. It reuses `Embedder` and `VectorStore` from the memory root entry; Prism core input assembly is unchanged.
|
|
6
6
|
|
|
7
7
|
## When to use it
|
|
8
8
|
|
|
@@ -27,7 +27,7 @@ Document lifecycle:
|
|
|
27
27
|
| `replaceSource({ sourceId, chunks, store, scope, ... })` | Atomically replaces one source after all bounded embedding succeeds; the store must implement scoped `getBySource()` and `transaction()`. |
|
|
28
28
|
| `deleteSource({ sourceId, store, scope })` | Deletes only matching IDs under exact tenant/resource/corpus scope. |
|
|
29
29
|
| `replaceDocument({ uri, loader, parser, store, scope, ... })` | Loads through a host seam, parses, chunks, and atomically replaces. `sourceId` is required unless loader supplies one. |
|
|
30
|
-
| `DocumentLoader` / `Parser` | Small host-replaceable seams.
|
|
30
|
+
| `DocumentLoader` / `Parser` | Small host-replaceable seams. `@arnilo/prism-memory/rag/loaders` and `/rag/parsers` export reference adapters. |
|
|
31
31
|
| `textParser` / `markdownParser` / `htmlParser` / `pdfParser` | UTF-8 text, Markdown, script/style-stripping HTML, and uncompressed-text PDF parsers. |
|
|
32
32
|
|
|
33
33
|
Index/retrieve:
|
|
@@ -46,7 +46,7 @@ Index/retrieve:
|
|
|
46
46
|
| `statusStore` | no | `IngestionStatusStore` records per-source pending/indexed/failed/partial byte/chunk progress; use `listIngestionStatus()` for capped exact-scope pages. |
|
|
47
47
|
| `contentHash` | no | Host-computed document digest; stamped on records and enables unchanged-source skip in `replaceSource` (`skipIfUnchanged`, default true when present) |
|
|
48
48
|
| `reuseEmbeddings` | no | `ReadonlyMap<string, ReusableEmbedding>` — chunk id → `{ text, embedding }`; embeddings reused (no embed call) when texts match |
|
|
49
|
-
| `telemetry` / `telemetryParent` | no | `RagTelemetry` seam (e.g. `createRagTelemetry()` from `@arnilo/prism-observability
|
|
49
|
+
| `telemetry` / `telemetryParent` | no | `RagTelemetry` seam (e.g. `createRagTelemetry()` from `@arnilo/prism-core/governance/observability`); spans nest under `telemetryParent` |
|
|
50
50
|
| `redactor` / `secrets` | no | Redact before embedding, persistence, reranking, and injection |
|
|
51
51
|
| `signal` | no | Abort embedding, vector operations, reranking, and batch progression |
|
|
52
52
|
|
|
@@ -84,7 +84,7 @@ Default/hard ceilings include 1,000/16,384 chunk characters, 100/4,096 overlap,
|
|
|
84
84
|
```ts
|
|
85
85
|
import { createAgent, createMockProvider, providerDone, providerTextDelta } from "@arnilo/prism";
|
|
86
86
|
import { createHashEmbedder, createMemoryVectorStore } from "@arnilo/prism-memory";
|
|
87
|
-
import { chunkMarkdown, createMemoryIngestionStatusStore, createRagContextProvider, indexChunks, listIngestionStatus, retrieveContext } from "@arnilo/prism-rag";
|
|
87
|
+
import { chunkMarkdown, createMemoryIngestionStatusStore, createRagContextProvider, indexChunks, listIngestionStatus, retrieveContext } from "@arnilo/prism-memory/rag";
|
|
88
88
|
|
|
89
89
|
const embedder = createHashEmbedder(); // deterministic demo/test helper, not production semantic quality
|
|
90
90
|
const store = createMemoryVectorStore();
|
|
@@ -118,7 +118,7 @@ console.log(found.text, await agent.createSession().run("How do approvals work?"
|
|
|
118
118
|
Content-hash skip and hash validation:
|
|
119
119
|
|
|
120
120
|
```ts
|
|
121
|
-
import { isValidContentHash } from "@arnilo/prism-rag";
|
|
121
|
+
import { isValidContentHash } from "@arnilo/prism-memory/rag";
|
|
122
122
|
|
|
123
123
|
const digest = "ab12..."; // host-computed SHA-256 hex of the document
|
|
124
124
|
if (!isValidContentHash(digest)) throw new Error("invalid digest");
|
|
@@ -128,8 +128,8 @@ await replaceSource({ sourceId: "doc", chunks, embedder, store, scope, contentHa
|
|
|
128
128
|
Hybrid retrieval, TEI reranking, and telemetry:
|
|
129
129
|
|
|
130
130
|
```ts
|
|
131
|
-
import { createRagTelemetry } from "@arnilo/prism-observability
|
|
132
|
-
import { createTeiReranker } from "@arnilo/prism-rag";
|
|
131
|
+
import { createRagTelemetry } from "@arnilo/prism-core/governance/observability";
|
|
132
|
+
import { createTeiReranker } from "@arnilo/prism-memory/rag";
|
|
133
133
|
|
|
134
134
|
const telemetry = createRagTelemetry({ tracer, meter }); // @opentelemetry/api instruments
|
|
135
135
|
const org = { tenantId: "t1", resourceId: "docs", corpusId: "org" };
|
|
@@ -152,6 +152,8 @@ const found = await retrieveContext("leave balance", {
|
|
|
152
152
|
- Metadata filtering is package-local after a bounded candidate query so existing vector contracts/adapters remain unchanged. Increase `queryCandidates` only when selective filters measurably need it.
|
|
153
153
|
- `Reranker` is a host seam, not a provider integration. Return each redacted candidate ID exactly once; Prism retains canonical hit/provenance/trust fields and exposes `retrievalRank` for diagnostics. Add a hosted reranker only when a host owns its credentials, quota, and retry policy.
|
|
154
154
|
- `createTeiReranker({ baseUrl, model?, timeoutMs?, maxResponseBytes?, ssrf?, allowLoopback?, fetch? })` (`CreateTeiRerankerOptions`) adapts a Hugging Face TEI `POST <baseUrl>/rerank` endpoint (`{query, texts, raw_scores:false}` → `{results:[{index,score}]}`) into the `Reranker` seam. It returns a permutation-only reorder of the same hit objects, so provenance/trust move untouched. Response parsing is strict — short/duplicate/out-of-range indices, non-finite scores, HTTP errors, timeouts, and oversized bodies all fail closed; the `rerankHits` caps (`maxRerankBytes`, `maxRerankMs`, `rerankConcurrency`) still apply around it. The default transport is the core DNS-pinned `pinnedFetch` (redirect-free, byte-bounded to 65,536 by default); HTTPS is required unless `allowLoopback: true` (loopback dev/test) or the host supplies `ssrf`/`fetch` for cluster networking. The adapter validates URL shape only — SSRF policy enforcement stays host-side. No credentials are ever sent; there is no SaaS default URL.
|
|
155
|
+
- Hosted rerank adapters over the same seam (plan 062): `createOpenAiCompatibleReranker({ baseUrl, model?, apiKey?, timeoutMs?, maxResponseBytes?, ssrf?, allowLoopback?, fetch? })` speaks the OpenAI-compatible `POST <baseUrl>/rerank` route (`{model, query, documents}` → `{results:[{index,relevance_score}]}`; pass the version segment in `baseUrl`, e.g. `https://api.jina.ai/v1`), and `createVoyageReranker({ baseUrl, model?, apiKey, … })` adapts Voyage AI (`…/v1/rerank` → `{data:[{index,relevance_score}]}`; `apiKey` required). Both send one request per rerank — no adapter-side batching — never send `top_k` (the retrieval seam owns top-K), return the same permutation-only reorder, and fail closed on the same malformed-response/HTTP/timeout/byte-bound cases. `apiKey` rides as `Authorization: Bearer …` and is never logged; errors carry status/host only. No SaaS default URL — hosts own credentials, quota, and retry policy.
|
|
156
|
+
- `createFakeReranker()` is a network-free deterministic reranker (query-term-overlap scoring, stable ties) and `runRerankerConformance(createReranker)` is the shared network-free conformance for any `Reranker` implementation: empty input → `[]`, output is a permutation of the exact input references (provenance/trust untouched), repeated calls are deterministic.
|
|
155
157
|
- Hybrid retrieval: pass `lexical: "fts"` (or `"bm25"` when the store supports it) to `retrieveContext()`; the two legs are fused with reciprocal-rank fusion (`fusion: "rrf"`, `rrfK` 60 default; the pure helper `fuseReciprocalRank()` returns `FusedCandidate[]` for custom orchestration). Stores advertise support via `lexicalModes?: readonly LexicalMode[]` and `tokenizeLexical()` is the shared tokenizer. Each hit's provenance `retrieval` field reports `vector`/`lexical`/`hybrid`; fusion internals expose `RetrievalLeg`.
|
|
156
158
|
- Multi-scope retrieve: `scopes: RagScope[]` searches each exact scope against that scope's current generation, then runs **one** RRF over the union and **one** rerank. The query is embedded once. `queryCandidates` is per scope. Duplicate scopes are dropped. `HARD_RETRIEVE_SCOPE_CAP` is 8.
|
|
157
159
|
- Embedder identity/drift guard: `Embedder.id` (memory contract) is stamped onto every vector record as `embedderId`. `retrieveContext()` fails closed with `ERR_PRISM_RAG_EMBEDDER_MISMATCH` when a stored record's `embedderId` or dimensions differ from the active embedder (for example after a model change) — re-index the source before retrieving. Legacy records without an `embedderId` also fail closed, naming the re-index path.
|
|
@@ -161,7 +163,7 @@ const found = await retrieveContext("leave balance", {
|
|
|
161
163
|
- `createResourceDocumentLoader({ loader })` calls one host-owned `ResourceLoader`; it scans nothing and performs no filesystem or network I/O itself. Pass the host's permission/trust context to that loader.
|
|
162
164
|
- `createWebFetchDocumentLoader({ fetcher })` accepts an already-configured `@arnilo/prism-web-tools` fetch adapter. It never opens a socket, rejects file/local/private/IP-literal URLs, and carries normalized citation/trust metadata forward. The fetch adapter still owns DNS/SSRF policy.
|
|
163
165
|
- `pdfParser` is deliberately limited to bounded, uncompressed PDF text. Provide a host parser through `Parser` for compressed, scanned, or complex PDFs; do not silently index partial text.
|
|
164
|
-
- Package is available directly or
|
|
166
|
+
- Package is available directly or via the `@arnilo/prism-memory` family tarball; installation does not create an embedder, vector store, loader, parser, or context provider.
|
|
165
167
|
|
|
166
168
|
## Security and performance notes
|
|
167
169
|
|
|
@@ -175,12 +177,32 @@ const found = await retrieveContext("leave balance", {
|
|
|
175
177
|
- `replaceSource()` stages every bounded embedding before opening the store transaction. It requires a source-aware transactional store and fails closed rather than pretending generic upserts are atomic. `createMemoryVectorStore()` supplies the reference `getBySource()` / transaction capability; durable stores must implement equivalent exact-scope behavior.
|
|
176
178
|
- `deleteSource()` rechecks every returned record's tenant/resource/corpus and source metadata before delete. Same source IDs in another corpus remain untouched.
|
|
177
179
|
- Parsers enforce byte/page/time caps, abort before and after parsing, decode UTF-8 strictly, and strip HTML script/style content. Parsed and retrieved text remains untrusted inert context; it never gains tool authority.
|
|
178
|
-
- Rerankers receive redacted input under byte/time/concurrency caps. Timeout, abort, unknown/duplicate/missing IDs, oversized input, and reranker failures fail closed; returned objects cannot overwrite Prism provenance/trust fields. The TEI adapter adds fail-closed response parsing (permutation completeness, finite scores) and honors the 65,536-byte response ceiling; SSRF/URL policy is host-side (see Extension notes).
|
|
180
|
+
- Rerankers receive redacted input under byte/time/concurrency caps. Timeout, abort, unknown/duplicate/missing IDs, oversized input, and reranker failures fail closed; returned objects cannot overwrite Prism provenance/trust fields. The TEI adapter adds fail-closed response parsing (permutation completeness, finite scores) and honors the 65,536-byte response ceiling; SSRF/URL policy is host-side (see Extension notes). The hosted OpenAI-compatible and Voyage adapters carry the same guarantees and add Bearer credentials that are never logged and error messages that never contain document text or the API key.
|
|
179
181
|
- Telemetry is a host-owned seam: `RagTelemetry` adapter (`createRagTelemetry()`) drops anything outside a fixed span-name set and `rag.*`-shaped attribute keys, so raw chunk text never reaches the tracer unless the host's own `attributeFilter` opts it in; when the seam is absent, instrumentation costs nothing.
|
|
180
182
|
- Durable vector stores (PostgreSQL/pgvector path via `@arnilo/prism-memory`) run their DDL against the host's knowledge database — tables are created in a schema/table the host names (default `prism_memory.semantic_memory`), and hosts must own backup/retention of that database. See [Working and semantic memory](working-and-semantic-memory.md).
|
|
181
183
|
- Ingestion failure errors are redacted before status storage. Status reads reject foreign scope entries and page-limit violations; status itself creates no permission or tool authority.
|
|
182
184
|
- Filtering scans at most `queryCandidates` hits; rendering stops at top-K, UTF-8 result bytes, or estimated context-token ceiling.
|
|
183
185
|
|
|
186
|
+
## Live probe (plans/064 Task 6)
|
|
187
|
+
|
|
188
|
+
Reranker adapters are probed against operator-deployed endpoints — each leg skips (never fails) when its endpoint env var is unset:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
PRISM_TEST_TEI_RERANKER_URL=http://tei.svc:8080 \
|
|
192
|
+
node --test packages/memory/dist/rag/__tests__/live.test.js
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
| Env var | Purpose |
|
|
196
|
+
| --- | --- |
|
|
197
|
+
| `PRISM_TEST_TEI_RERANKER_URL` | TEI service base URL (`/rerank` is appended) |
|
|
198
|
+
| `PRISM_TEST_TEI_RERANKER_KEY` | optional gateway key for a TEI behind auth (rides the trusted-transport seam) |
|
|
199
|
+
| `PRISM_LIVE_TEI_RERANKER_MODEL` | optional TEI model name |
|
|
200
|
+
| `PRISM_TEST_HOSTED_RERANK_URL` | OpenAI-compatible rerank base URL (`/rerank` appended, include `/v1`) |
|
|
201
|
+
| `PRISM_TEST_HOSTED_RERANK_KEY` | Bearer credential for the hosted endpoint |
|
|
202
|
+
| `PRISM_LIVE_HOSTED_RERANK_MODEL` | optional hosted model name |
|
|
203
|
+
|
|
204
|
+
Probes send one non-sensitive rerank request per configured endpoint and assert the live response conforms (permutation-only reorder, scores non-increasing, credential never in error transcripts). Registered in `scripts/live-matrix.json` as `memory/rag-rerankers-live`.
|
|
205
|
+
|
|
184
206
|
## Related APIs
|
|
185
207
|
|
|
186
208
|
- [Working and semantic memory](working-and-semantic-memory.md): shared `Embedder`/`VectorStore` contracts and adapters.
|