@adonis-agora/agent 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/configure.d.ts +18 -0
- package/dist/configure.d.ts.map +1 -0
- package/dist/configure.js +29 -0
- package/dist/configure.js.map +1 -0
- package/dist/providers/agent_provider.d.ts +25 -0
- package/dist/providers/agent_provider.d.ts.map +1 -0
- package/dist/providers/agent_provider.js +511 -0
- package/dist/providers/agent_provider.js.map +1 -0
- package/dist/src/actor-resolver.d.ts +41 -0
- package/dist/src/actor-resolver.d.ts.map +1 -0
- package/dist/src/agent-deps-factory.d.ts +59 -0
- package/dist/src/agent-deps-factory.d.ts.map +1 -0
- package/dist/src/agent-deps-factory.js +111 -0
- package/dist/src/agent-deps-factory.js.map +1 -0
- package/dist/src/agent-deps.d.ts +42 -0
- package/dist/src/agent-deps.d.ts.map +1 -0
- package/dist/src/agent-deps.js +5 -0
- package/dist/src/agent-deps.js.map +1 -0
- package/dist/src/agent-loop.d.ts +101 -0
- package/dist/src/agent-loop.d.ts.map +1 -0
- package/dist/src/agent-loop.js +396 -0
- package/dist/src/agent-loop.js.map +1 -0
- package/dist/src/agent-registry.d.ts +10 -0
- package/dist/src/agent-registry.d.ts.map +1 -0
- package/dist/src/agent-service.d.ts +50 -0
- package/dist/src/agent-service.d.ts.map +1 -0
- package/dist/src/agent-service.js +82 -0
- package/dist/src/agent-service.js.map +1 -0
- package/dist/src/ai-sdk/ai-sdk-model.d.ts +17 -0
- package/dist/src/ai-sdk/ai-sdk-model.d.ts.map +1 -0
- package/dist/src/ai-sdk/ai-sdk-model.js +263 -0
- package/dist/src/ai-sdk/ai-sdk-model.js.map +1 -0
- package/dist/src/ai-sdk/index.d.ts +2 -0
- package/dist/src/ai-sdk/index.d.ts.map +1 -0
- package/dist/src/ai-tool-ref.d.ts +79 -0
- package/dist/src/ai-tool-ref.d.ts.map +1 -0
- package/dist/src/ai-tool-ref.js +81 -0
- package/dist/src/ai-tool-ref.js.map +1 -0
- package/dist/src/authorizer.d.ts +18 -0
- package/dist/src/authorizer.d.ts.map +1 -0
- package/dist/src/authz/authz-tool-authorizer.d.ts +85 -0
- package/dist/src/authz/authz-tool-authorizer.d.ts.map +1 -0
- package/dist/src/authz/authz-tool-authorizer.js +63 -0
- package/dist/src/authz/authz-tool-authorizer.js.map +1 -0
- package/dist/src/authz/index.d.ts +3 -0
- package/dist/src/authz/index.d.ts.map +1 -0
- package/dist/src/authz/index.js +2 -0
- package/dist/src/authz/index.js.map +1 -0
- package/dist/src/data/data-tool.d.ts +64 -0
- package/dist/src/data/data-tool.d.ts.map +1 -0
- package/dist/src/data/data-tool.js +146 -0
- package/dist/src/data/data-tool.js.map +1 -0
- package/dist/src/data/index.d.ts +7 -0
- package/dist/src/data/index.d.ts.map +1 -0
- package/dist/src/data/index.js +7 -0
- package/dist/src/data/index.js.map +1 -0
- package/dist/src/data/limit.d.ts +12 -0
- package/dist/src/data/limit.d.ts.map +1 -0
- package/dist/src/data/limit.js +29 -0
- package/dist/src/data/limit.js.map +1 -0
- package/dist/src/data/parser.d.ts +27 -0
- package/dist/src/data/parser.d.ts.map +1 -0
- package/dist/src/data/parser.js +18 -0
- package/dist/src/data/parser.js.map +1 -0
- package/dist/src/data/sql-validator.d.ts +37 -0
- package/dist/src/data/sql-validator.d.ts.map +1 -0
- package/dist/src/data/sql-validator.js +92 -0
- package/dist/src/data/sql-validator.js.map +1 -0
- package/dist/src/data/table-access.d.ts +40 -0
- package/dist/src/data/table-access.d.ts.map +1 -0
- package/dist/src/data/table-access.js +41 -0
- package/dist/src/data/table-access.js.map +1 -0
- package/dist/src/data/tenant-scope.d.ts +39 -0
- package/dist/src/data/tenant-scope.d.ts.map +1 -0
- package/dist/src/data/tenant-scope.js +126 -0
- package/dist/src/data/tenant-scope.js.map +1 -0
- package/dist/src/define_config.d.ts +153 -0
- package/dist/src/define_config.d.ts.map +1 -0
- package/dist/src/define_config.js +7 -0
- package/dist/src/define_config.js.map +1 -0
- package/dist/src/diagnostics.d.ts +82 -0
- package/dist/src/diagnostics.d.ts.map +1 -0
- package/dist/src/diagnostics.js +50 -0
- package/dist/src/diagnostics.js.map +1 -0
- package/dist/src/durable/agent-run-context.d.ts +24 -0
- package/dist/src/durable/agent-run-context.d.ts.map +1 -0
- package/dist/src/durable/agent-run-context.js +17 -0
- package/dist/src/durable/agent-run-context.js.map +1 -0
- package/dist/src/durable/agent-run-workflow.d.ts +37 -0
- package/dist/src/durable/agent-run-workflow.d.ts.map +1 -0
- package/dist/src/durable/agent-run-workflow.js +128 -0
- package/dist/src/durable/agent-run-workflow.js.map +1 -0
- package/dist/src/durable/durable-agent-runner.d.ts +25 -0
- package/dist/src/durable/durable-agent-runner.d.ts.map +1 -0
- package/dist/src/durable/durable-agent-runner.js +59 -0
- package/dist/src/durable/durable-agent-runner.js.map +1 -0
- package/dist/src/durable/index.d.ts +17 -0
- package/dist/src/durable/index.d.ts.map +1 -0
- package/dist/src/durable/index.js +20 -0
- package/dist/src/durable/index.js.map +1 -0
- package/dist/src/index.d.ts +55 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +45 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/personas.d.ts +7 -0
- package/dist/src/personas.d.ts.map +1 -0
- package/dist/src/rag/chunk.d.ts +14 -0
- package/dist/src/rag/chunk.d.ts.map +1 -0
- package/dist/src/rag/chunk.js +42 -0
- package/dist/src/rag/chunk.js.map +1 -0
- package/dist/src/rag/embedding-retriever.d.ts +15 -0
- package/dist/src/rag/embedding-retriever.d.ts.map +1 -0
- package/dist/src/rag/embedding-retriever.js +24 -0
- package/dist/src/rag/embedding-retriever.js.map +1 -0
- package/dist/src/rag/filter.d.ts +6 -0
- package/dist/src/rag/filter.d.ts.map +1 -0
- package/dist/src/rag/filter.js +11 -0
- package/dist/src/rag/filter.js.map +1 -0
- package/dist/src/rag/index.d.ts +8 -0
- package/dist/src/rag/index.d.ts.map +1 -0
- package/dist/src/rag/index.js +8 -0
- package/dist/src/rag/index.js.map +1 -0
- package/dist/src/rag/ingest.d.ts +33 -0
- package/dist/src/rag/ingest.d.ts.map +1 -0
- package/dist/src/rag/ingest.js +37 -0
- package/dist/src/rag/ingest.js.map +1 -0
- package/dist/src/rag/memory-vector-store.d.ts +16 -0
- package/dist/src/rag/memory-vector-store.d.ts.map +1 -0
- package/dist/src/rag/memory-vector-store.js +70 -0
- package/dist/src/rag/memory-vector-store.js.map +1 -0
- package/dist/src/rag/pg-vector-store.d.ts +84 -0
- package/dist/src/rag/pg-vector-store.d.ts.map +1 -0
- package/dist/src/rag/pg-vector-store.js +220 -0
- package/dist/src/rag/pg-vector-store.js.map +1 -0
- package/dist/src/rag/vector-store.d.ts +47 -0
- package/dist/src/rag/vector-store.d.ts.map +1 -0
- package/dist/src/rag/vector-store.js +5 -0
- package/dist/src/rag/vector-store.js.map +1 -0
- package/dist/src/rag-media/diagnostics.d.ts +43 -0
- package/dist/src/rag-media/diagnostics.d.ts.map +1 -0
- package/dist/src/rag-media/diagnostics.js +36 -0
- package/dist/src/rag-media/diagnostics.js.map +1 -0
- package/dist/src/rag-media/index.d.ts +5 -0
- package/dist/src/rag-media/index.d.ts.map +1 -0
- package/dist/src/rag-media/index.js +5 -0
- package/dist/src/rag-media/index.js.map +1 -0
- package/dist/src/rag-media/media-events.d.ts +23 -0
- package/dist/src/rag-media/media-events.d.ts.map +1 -0
- package/dist/src/rag-media/media-events.js +28 -0
- package/dist/src/rag-media/media-events.js.map +1 -0
- package/dist/src/rag-media/media-rag-ingestion.d.ts +155 -0
- package/dist/src/rag-media/media-rag-ingestion.d.ts.map +1 -0
- package/dist/src/rag-media/media-rag-ingestion.js +204 -0
- package/dist/src/rag-media/media-rag-ingestion.js.map +1 -0
- package/dist/src/rag-media/text-extractor.d.ts +46 -0
- package/dist/src/rag-media/text-extractor.d.ts.map +1 -0
- package/dist/src/rag-media/text-extractor.js +92 -0
- package/dist/src/rag-media/text-extractor.js.map +1 -0
- package/dist/src/redis-stream-client.d.ts +29 -0
- package/dist/src/redis-stream-client.d.ts.map +1 -0
- package/dist/src/redis-stream-client.js +2 -0
- package/dist/src/redis-stream-client.js.map +1 -0
- package/dist/src/redis-token-stream-sink.d.ts +36 -0
- package/dist/src/redis-token-stream-sink.d.ts.map +1 -0
- package/dist/src/redis-token-stream-sink.js +94 -0
- package/dist/src/redis-token-stream-sink.js.map +1 -0
- package/dist/src/runners/inline-agent-runner.d.ts +26 -0
- package/dist/src/runners/inline-agent-runner.d.ts.map +1 -0
- package/dist/src/runners/inline-agent-runner.js +85 -0
- package/dist/src/runners/inline-agent-runner.js.map +1 -0
- package/dist/src/spi/actor-directory.d.ts +23 -0
- package/dist/src/spi/actor-directory.d.ts.map +1 -0
- package/dist/src/spi/actor-directory.js +2 -0
- package/dist/src/spi/actor-directory.js.map +1 -0
- package/dist/src/spi/actor-resolver.d.ts +18 -0
- package/dist/src/spi/actor-resolver.d.ts.map +1 -0
- package/dist/src/spi/agent-runner.d.ts +20 -0
- package/dist/src/spi/agent-runner.d.ts.map +1 -0
- package/dist/src/spi/agent-store.d.ts +104 -0
- package/dist/src/spi/agent-store.d.ts.map +1 -0
- package/dist/src/spi/agent-store.js +2 -0
- package/dist/src/spi/agent-store.js.map +1 -0
- package/dist/src/spi/attachment-staging.d.ts +27 -0
- package/dist/src/spi/attachment-staging.d.ts.map +1 -0
- package/dist/src/spi/attachment-staging.js +2 -0
- package/dist/src/spi/attachment-staging.js.map +1 -0
- package/dist/src/spi/embedding-provider.d.ts +12 -0
- package/dist/src/spi/embedding-provider.d.ts.map +1 -0
- package/dist/src/spi/embedding-provider.js +2 -0
- package/dist/src/spi/embedding-provider.js.map +1 -0
- package/dist/src/spi/governance-queries.d.ts +215 -0
- package/dist/src/spi/governance-queries.d.ts.map +1 -0
- package/dist/src/spi/governance-queries.js +15 -0
- package/dist/src/spi/governance-queries.js.map +1 -0
- package/dist/src/spi/model-provider.d.ts +41 -0
- package/dist/src/spi/model-provider.d.ts.map +1 -0
- package/dist/src/spi/pricing-store.d.ts +45 -0
- package/dist/src/spi/pricing-store.d.ts.map +1 -0
- package/dist/src/spi/pricing-store.js +24 -0
- package/dist/src/spi/pricing-store.js.map +1 -0
- package/dist/src/spi/quota-store.d.ts +7 -0
- package/dist/src/spi/quota-store.d.ts.map +1 -0
- package/dist/src/spi/reranker.d.ts +17 -0
- package/dist/src/spi/reranker.d.ts.map +1 -0
- package/dist/src/spi/reranker.js +2 -0
- package/dist/src/spi/reranker.js.map +1 -0
- package/dist/src/spi/retriever.d.ts +28 -0
- package/dist/src/spi/retriever.d.ts.map +1 -0
- package/dist/src/spi/retriever.js +11 -0
- package/dist/src/spi/retriever.js.map +1 -0
- package/dist/src/spi/roles-policy.d.ts +11 -0
- package/dist/src/spi/roles-policy.d.ts.map +1 -0
- package/dist/src/spi/tool.d.ts +21 -0
- package/dist/src/spi/tool.d.ts.map +1 -0
- package/dist/src/stores/factory.d.ts +363 -0
- package/dist/src/stores/factory.d.ts.map +1 -0
- package/dist/src/stores/factory.js +341 -0
- package/dist/src/stores/factory.js.map +1 -0
- package/dist/src/stores/ledger-quota.d.ts +23 -0
- package/dist/src/stores/ledger-quota.d.ts.map +1 -0
- package/dist/src/stores/ledger-quota.js +32 -0
- package/dist/src/stores/ledger-quota.js.map +1 -0
- package/dist/src/stores/lucid-governance-queries.d.ts +73 -0
- package/dist/src/stores/lucid-governance-queries.d.ts.map +1 -0
- package/dist/src/stores/lucid-governance-queries.js +510 -0
- package/dist/src/stores/lucid-governance-queries.js.map +1 -0
- package/dist/src/stores/lucid-pricing.d.ts +20 -0
- package/dist/src/stores/lucid-pricing.d.ts.map +1 -0
- package/dist/src/stores/lucid-pricing.js +67 -0
- package/dist/src/stores/lucid-pricing.js.map +1 -0
- package/dist/src/stores/lucid-schema.d.ts +37 -0
- package/dist/src/stores/lucid-schema.d.ts.map +1 -0
- package/dist/src/stores/lucid-schema.js +139 -0
- package/dist/src/stores/lucid-schema.js.map +1 -0
- package/dist/src/stores/lucid.d.ts +73 -0
- package/dist/src/stores/lucid.d.ts.map +1 -0
- package/dist/src/stores/lucid.js +400 -0
- package/dist/src/stores/lucid.js.map +1 -0
- package/dist/src/telescope/dashboard.d.ts +21 -0
- package/dist/src/telescope/dashboard.d.ts.map +1 -0
- package/dist/src/telescope/dashboard.js +140 -0
- package/dist/src/telescope/dashboard.js.map +1 -0
- package/dist/src/telescope/data-providers.d.ts +39 -0
- package/dist/src/telescope/data-providers.d.ts.map +1 -0
- package/dist/src/telescope/data-providers.js +345 -0
- package/dist/src/telescope/data-providers.js.map +1 -0
- package/dist/src/telescope/extension.d.ts +27 -0
- package/dist/src/telescope/extension.d.ts.map +1 -0
- package/dist/src/telescope/extension.js +45 -0
- package/dist/src/telescope/extension.js.map +1 -0
- package/dist/src/telescope/index.d.ts +5 -0
- package/dist/src/telescope/index.d.ts.map +1 -0
- package/dist/src/telescope/index.js +4 -0
- package/dist/src/telescope/index.js.map +1 -0
- package/dist/src/telescope/telescope-sdk.d.ts +126 -0
- package/dist/src/telescope/telescope-sdk.d.ts.map +1 -0
- package/dist/src/telescope/telescope-sdk.js +15 -0
- package/dist/src/telescope/telescope-sdk.js.map +1 -0
- package/dist/src/testing/fake-embedding-provider.d.ts +37 -0
- package/dist/src/testing/fake-embedding-provider.d.ts.map +1 -0
- package/dist/src/testing/fake-embedding-provider.js +67 -0
- package/dist/src/testing/fake-embedding-provider.js.map +1 -0
- package/dist/src/testing/fake-media.d.ts +44 -0
- package/dist/src/testing/fake-media.d.ts.map +1 -0
- package/dist/src/testing/fake-media.js +69 -0
- package/dist/src/testing/fake-media.js.map +1 -0
- package/dist/src/testing/fake-model-provider.d.ts +29 -0
- package/dist/src/testing/fake-model-provider.d.ts.map +1 -0
- package/dist/src/testing/in-memory-actor-directory.d.ts +14 -0
- package/dist/src/testing/in-memory-actor-directory.d.ts.map +1 -0
- package/dist/src/testing/in-memory-actor-directory.js +27 -0
- package/dist/src/testing/in-memory-actor-directory.js.map +1 -0
- package/dist/src/testing/in-memory-attachment-staging.d.ts +22 -0
- package/dist/src/testing/in-memory-attachment-staging.d.ts.map +1 -0
- package/dist/src/testing/in-memory-attachment-staging.js +28 -0
- package/dist/src/testing/in-memory-attachment-staging.js.map +1 -0
- package/dist/src/testing/in-memory-governance-queries.d.ts +34 -0
- package/dist/src/testing/in-memory-governance-queries.d.ts.map +1 -0
- package/dist/src/testing/in-memory-governance-queries.js +373 -0
- package/dist/src/testing/in-memory-governance-queries.js.map +1 -0
- package/dist/src/testing/in-memory-pricing.d.ts +13 -0
- package/dist/src/testing/in-memory-pricing.d.ts.map +1 -0
- package/dist/src/testing/in-memory-pricing.js +27 -0
- package/dist/src/testing/in-memory-pricing.js.map +1 -0
- package/dist/src/testing/in-memory-quota.d.ts +11 -0
- package/dist/src/testing/in-memory-quota.d.ts.map +1 -0
- package/dist/src/testing/in-memory-sink.d.ts +14 -0
- package/dist/src/testing/in-memory-sink.d.ts.map +1 -0
- package/dist/src/testing/in-memory-store.d.ts +119 -0
- package/dist/src/testing/in-memory-store.d.ts.map +1 -0
- package/dist/src/testing/in-memory-store.js +317 -0
- package/dist/src/testing/in-memory-store.js.map +1 -0
- package/dist/src/testing/index.d.ts +11 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +11 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/tool-discovery.d.ts +35 -0
- package/dist/src/tool-discovery.d.ts.map +1 -0
- package/dist/src/tool-registry.d.ts +45 -0
- package/dist/src/tool-registry.d.ts.map +1 -0
- package/dist/src/tool-retry.d.ts +56 -0
- package/dist/src/tool-retry.d.ts.map +1 -0
- package/dist/src/tool-retry.js +95 -0
- package/dist/src/tool-retry.js.map +1 -0
- package/dist/src/types.d.ts +222 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/stubs/config/agent.stub +55 -0
- package/dist/stubs/database/migrations/create_agent_rag_chunks.stub +41 -0
- package/dist/stubs/database/migrations/create_agent_run_tracking.stub +80 -0
- package/dist/stubs/database/migrations/create_agent_tables.stub +113 -0
- package/package.json +174 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Actor, MessageAttachment } from '../types.js';
|
|
2
|
+
/** Input to {@link AttachmentStagingStore.stage} — the raw bytes plus who uploaded them. */
|
|
3
|
+
export interface StageAttachmentInput {
|
|
4
|
+
data: Buffer;
|
|
5
|
+
filename: string;
|
|
6
|
+
contentType: string;
|
|
7
|
+
sizeBytes: number;
|
|
8
|
+
actor: Actor;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Optional upload-side seam for message attachments (an image/PDF a user attaches to a chat message
|
|
12
|
+
* before the model ever sees it). The lib never fetches bytes itself — {@link MessageAttachment.url}
|
|
13
|
+
* must already be reachable by the model provider — so something has to turn an uploaded file into
|
|
14
|
+
* that URL first. A store adapter (or a thin wrapper over the host's own media pipeline) implements
|
|
15
|
+
* this and is wired via `defineConfig({ attachmentStaging })` — pass an instance, a lazy
|
|
16
|
+
* `attachmentStores.*()` factory, or omit it. When omitted the optional `POST /agent/attachments`
|
|
17
|
+
* upload route is never mounted, so a client sends already-staged {@link MessageAttachment}s directly.
|
|
18
|
+
*/
|
|
19
|
+
export interface AttachmentStagingStore {
|
|
20
|
+
/**
|
|
21
|
+
* Persist an uploaded file somewhere the model can later fetch (a presigned URL, a proxy, or a
|
|
22
|
+
* `data:` URI) and return the {@link MessageAttachment} to send with the next chat message. The lib
|
|
23
|
+
* never fetches bytes; the returned url must be reachable by the model provider.
|
|
24
|
+
*/
|
|
25
|
+
stage(input: StageAttachmentInput): Promise<MessageAttachment>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=attachment-staging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-staging.d.ts","sourceRoot":"","sources":["../../../src/spi/attachment-staging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE5D,4FAA4F;AAC5F,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAChE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-staging.js","sourceRoot":"","sources":["../../../src/spi/attachment-staging.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns text into embedding vectors — the retrieval-side sibling of {@link import('./model-provider.js').ModelProvider}.
|
|
3
|
+
* Batched (`texts` → one vector each, in the same order) so ingestion can embed many chunks per call.
|
|
4
|
+
* An adapter implements it (`aiSdkEmbedding` over the Vercel AI SDK `embedMany`, deferred this round);
|
|
5
|
+
* `@adonis-agora/agent/testing` ships a deterministic {@link import('../testing/fake-embedding-provider.js').FakeEmbeddingProvider}
|
|
6
|
+
* for offline tests. Mirrors the reference `EmbeddingProvider` contract exactly.
|
|
7
|
+
*/
|
|
8
|
+
export interface EmbeddingProvider {
|
|
9
|
+
/** Embed each input string; returns one vector per input, in the same order. */
|
|
10
|
+
embed(texts: string[]): Promise<number[][]>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=embedding-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding-provider.d.ts","sourceRoot":"","sources":["../../../src/spi/embedding-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,gFAAgF;IAChF,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embedding-provider.js","sourceRoot":"","sources":["../../../src/spi/embedding-provider.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A read-model over the persisted agent data (usage ⋈ pricing, tool calls, threads) for the
|
|
3
|
+
* governance surfaces — the standalone `-dashboard` SPA and the `-telescope` "Agent" tab both
|
|
4
|
+
* consume this ONE interface, so cost/usage aggregation lives in a single place.
|
|
5
|
+
*
|
|
6
|
+
* Separate from {@link AgentStore} on purpose: that SPI owns the write/thread path, this owns the
|
|
7
|
+
* read/analytics path. A store adapter implements both. Consumers inject via
|
|
8
|
+
* `AGENT_GOVERNANCE_QUERIES`.
|
|
9
|
+
*
|
|
10
|
+
* Live activity (in-flight runs, streaming tool calls, delegations, forbidden attempts) is NOT here
|
|
11
|
+
* — that comes off the `aviary:agent:*` diagnostics channel. This interface is the durable, restart-
|
|
12
|
+
* surviving history.
|
|
13
|
+
*/
|
|
14
|
+
/** Inclusive UTC day range, each `YYYY-MM-DD`. */
|
|
15
|
+
export interface GovernanceRange {
|
|
16
|
+
fromDay: string;
|
|
17
|
+
toDay: string;
|
|
18
|
+
}
|
|
19
|
+
/** Spend + token totals for one model over a range. */
|
|
20
|
+
export interface ModelSpendRow {
|
|
21
|
+
modelId: string;
|
|
22
|
+
requests: number;
|
|
23
|
+
inputTokens: number;
|
|
24
|
+
outputTokens: number;
|
|
25
|
+
costUsd: number;
|
|
26
|
+
}
|
|
27
|
+
/** Spend + token totals for one acting ref (user/tenant) over a range. */
|
|
28
|
+
export interface ActorSpendRow {
|
|
29
|
+
actorRef: string;
|
|
30
|
+
requests: number;
|
|
31
|
+
totalTokens: number;
|
|
32
|
+
costUsd: number;
|
|
33
|
+
}
|
|
34
|
+
/** One point on the daily usage/cost trend. */
|
|
35
|
+
export interface UsageTrendPoint {
|
|
36
|
+
day: string;
|
|
37
|
+
totalTokens: number;
|
|
38
|
+
costUsd: number;
|
|
39
|
+
}
|
|
40
|
+
/** A recent tool-call for the activity feed. */
|
|
41
|
+
export interface ToolCallActivityRow {
|
|
42
|
+
toolCallId: string;
|
|
43
|
+
toolName: string;
|
|
44
|
+
toolType: string;
|
|
45
|
+
status: string;
|
|
46
|
+
threadId: string;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
}
|
|
49
|
+
/** A recent thread with rolled-up activity. */
|
|
50
|
+
export interface ThreadActivityRow {
|
|
51
|
+
threadId: string;
|
|
52
|
+
title: string;
|
|
53
|
+
actorRef: string;
|
|
54
|
+
messageCount: number;
|
|
55
|
+
totalTokens: number;
|
|
56
|
+
lastActivityAt: string;
|
|
57
|
+
}
|
|
58
|
+
/** A run's lifecycle status as the read-model surfaces it. */
|
|
59
|
+
export type RunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
|
|
60
|
+
/** Filters + cursor for {@link AgentGovernanceQueries.listRuns}. All optional; absent = no constraint. */
|
|
61
|
+
export interface ListRunsFilter {
|
|
62
|
+
/** Exact `actor_ref`. */
|
|
63
|
+
actor?: string;
|
|
64
|
+
/** Exact `agent_name`. */
|
|
65
|
+
agent?: string;
|
|
66
|
+
status?: RunStatus;
|
|
67
|
+
/** Inclusive UTC-day lower bound on `started_at`, `YYYY-MM-DD`. */
|
|
68
|
+
from?: string;
|
|
69
|
+
/** Inclusive UTC-day upper bound on `started_at`, `YYYY-MM-DD`. */
|
|
70
|
+
to?: string;
|
|
71
|
+
/** Opaque cursor from a prior page's {@link ListRunsResult.nextCursor}; omit for the first page. */
|
|
72
|
+
cursor?: string;
|
|
73
|
+
/** Page size; defaults to 50, clamped to 200 by the adapter. */
|
|
74
|
+
limit?: number;
|
|
75
|
+
}
|
|
76
|
+
/** A run row for the governance list + detail. Newest-first in {@link ListRunsResult}. */
|
|
77
|
+
export interface RunSummaryRow {
|
|
78
|
+
runId: string;
|
|
79
|
+
threadId: string;
|
|
80
|
+
actorRef: string;
|
|
81
|
+
tenantRef: string | null;
|
|
82
|
+
agentName: string | null;
|
|
83
|
+
status: string;
|
|
84
|
+
/** ISO timestamp. */
|
|
85
|
+
startedAt: string;
|
|
86
|
+
/** ISO timestamp, `null` while still running. */
|
|
87
|
+
finishedAt: string | null;
|
|
88
|
+
/** `finishedAt - startedAt` in ms, `null` while still running. */
|
|
89
|
+
durationMs: number | null;
|
|
90
|
+
stepCount: number;
|
|
91
|
+
inputTokens: number;
|
|
92
|
+
outputTokens: number;
|
|
93
|
+
costUsd: number | null;
|
|
94
|
+
error: string | null;
|
|
95
|
+
durable: boolean;
|
|
96
|
+
}
|
|
97
|
+
/** One page of {@link AgentGovernanceQueries.listRuns}, newest-first, with an opaque forward cursor. */
|
|
98
|
+
export interface ListRunsResult {
|
|
99
|
+
runs: RunSummaryRow[];
|
|
100
|
+
/** Pass back as {@link ListRunsFilter.cursor} for the next page; `null` when the last page was returned. */
|
|
101
|
+
nextCursor: string | null;
|
|
102
|
+
}
|
|
103
|
+
/** A message belonging to a run, for {@link RunDetail}. */
|
|
104
|
+
export interface RunMessageRow {
|
|
105
|
+
id: string;
|
|
106
|
+
role: string;
|
|
107
|
+
content: string;
|
|
108
|
+
createdAt: string;
|
|
109
|
+
}
|
|
110
|
+
/** A tool call belonging to a run, for {@link RunDetail} (and the approvals subset). */
|
|
111
|
+
export interface RunToolCallRow {
|
|
112
|
+
toolCallId: string;
|
|
113
|
+
toolName: string;
|
|
114
|
+
toolType: string;
|
|
115
|
+
status: string;
|
|
116
|
+
input: unknown;
|
|
117
|
+
output: unknown;
|
|
118
|
+
error: string | null;
|
|
119
|
+
executionMs: number | null;
|
|
120
|
+
createdAt: string;
|
|
121
|
+
}
|
|
122
|
+
/** A usage ledger row belonging to a run, for {@link RunDetail}. */
|
|
123
|
+
export interface RunUsageRow {
|
|
124
|
+
modelId: string;
|
|
125
|
+
purpose: string;
|
|
126
|
+
inputTokens: number;
|
|
127
|
+
outputTokens: number;
|
|
128
|
+
costUsd: number | null;
|
|
129
|
+
createdAt: string;
|
|
130
|
+
}
|
|
131
|
+
/** The full trace of one run: the run row plus its messages, tool calls, pending approvals and usage. */
|
|
132
|
+
export interface RunDetail {
|
|
133
|
+
run: RunSummaryRow;
|
|
134
|
+
messages: RunMessageRow[];
|
|
135
|
+
toolCalls: RunToolCallRow[];
|
|
136
|
+
/** The subset of `toolCalls` still `pending_approval`. */
|
|
137
|
+
approvals: RunToolCallRow[];
|
|
138
|
+
usage: RunUsageRow[];
|
|
139
|
+
}
|
|
140
|
+
/** Filters for {@link AgentGovernanceQueries.pendingApprovals}. */
|
|
141
|
+
export interface PendingApprovalsFilter {
|
|
142
|
+
/** Restrict to a single acting ref (the owning run's `actor_ref`). */
|
|
143
|
+
actor?: string;
|
|
144
|
+
/** Cap the inbox; defaults to 50, clamped to 200 by the adapter. */
|
|
145
|
+
limit?: number;
|
|
146
|
+
}
|
|
147
|
+
/** One tool call awaiting a HITL decision, for the cross-thread approvals inbox (oldest first). */
|
|
148
|
+
export interface PendingApprovalRow {
|
|
149
|
+
toolCallId: string;
|
|
150
|
+
toolName: string;
|
|
151
|
+
input: unknown;
|
|
152
|
+
threadId: string;
|
|
153
|
+
/** The run this call belongs to, for a trace deep-link; `null` for a call recorded before run tracking. */
|
|
154
|
+
runId: string | null;
|
|
155
|
+
/** Who asked — the owning run's (or thread's) actor. */
|
|
156
|
+
actorRef: string;
|
|
157
|
+
/** ISO timestamp the call was recorded (requested). */
|
|
158
|
+
requestedAt: string;
|
|
159
|
+
}
|
|
160
|
+
/** Inclusive UTC-day range for the run/tool aggregates; each bound `YYYY-MM-DD`, both optional. */
|
|
161
|
+
export interface ToolStatsRange {
|
|
162
|
+
/** Lower bound on the row's `created_at`/`started_at`; omit for no lower bound. */
|
|
163
|
+
from?: string;
|
|
164
|
+
/** Upper bound; omit for no upper bound. */
|
|
165
|
+
to?: string;
|
|
166
|
+
}
|
|
167
|
+
/** Per-tool call/failure/rejection/latency rollup over a range, highest call count first. */
|
|
168
|
+
export interface PerToolStatRow {
|
|
169
|
+
toolName: string;
|
|
170
|
+
toolType: string;
|
|
171
|
+
calls: number;
|
|
172
|
+
failed: number;
|
|
173
|
+
rejected: number;
|
|
174
|
+
/** Mean `executionMs` across calls that recorded one; `null` when none did. */
|
|
175
|
+
avgDurationMs: number | null;
|
|
176
|
+
}
|
|
177
|
+
/** Aggregated run reliability over a range — success / failure / cancel rates. */
|
|
178
|
+
export interface RunReliability {
|
|
179
|
+
runs: number;
|
|
180
|
+
completed: number;
|
|
181
|
+
failed: number;
|
|
182
|
+
cancelled: number;
|
|
183
|
+
running: number;
|
|
184
|
+
/** completed / runs, 0 when runs = 0. */
|
|
185
|
+
successRate: number;
|
|
186
|
+
/** failed / runs, 0 when runs = 0. */
|
|
187
|
+
failureRate: number;
|
|
188
|
+
/** cancelled / runs, 0 when runs = 0. */
|
|
189
|
+
cancelRate: number;
|
|
190
|
+
/** Mean duration of settled (completed/failed/cancelled) runs in ms; `null` when none settled. */
|
|
191
|
+
avgDurationMs: number | null;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The governance read-model. Cost is `inputTokens/1e6 * inputPricePer1m + outputTokens/1e6 *
|
|
195
|
+
* outputPricePer1m` against the current pricing row per model; an unpriced model contributes 0 cost
|
|
196
|
+
* (its tokens still count).
|
|
197
|
+
*/
|
|
198
|
+
export interface AgentGovernanceQueries {
|
|
199
|
+
spendByModel(range: GovernanceRange): Promise<ModelSpendRow[]>;
|
|
200
|
+
spendByActor(range: GovernanceRange): Promise<ActorSpendRow[]>;
|
|
201
|
+
usageTrend(range: GovernanceRange): Promise<UsageTrendPoint[]>;
|
|
202
|
+
recentToolCalls(limit: number): Promise<ToolCallActivityRow[]>;
|
|
203
|
+
recentThreads(limit: number): Promise<ThreadActivityRow[]>;
|
|
204
|
+
/** Filterable, cursor-paginated run list, newest-first. */
|
|
205
|
+
listRuns(filter?: ListRunsFilter): Promise<ListRunsResult>;
|
|
206
|
+
/** The full trace of one run (run + messages + tool calls + approvals + usage), or `null` if unknown. */
|
|
207
|
+
runDetail(runId: string): Promise<RunDetail | null>;
|
|
208
|
+
/** Tool calls sitting `pending_approval`, oldest first (an inbox drains from the back). */
|
|
209
|
+
pendingApprovals(filter?: PendingApprovalsFilter): Promise<PendingApprovalRow[]>;
|
|
210
|
+
/** Per-tool call/failure/rejection/latency rollup over the range, highest call count first. */
|
|
211
|
+
perToolStats(range?: ToolStatsRange): Promise<PerToolStatRow[]>;
|
|
212
|
+
/** Success/failure/cancel rates + mean settled duration over the range. */
|
|
213
|
+
runReliability(range?: ToolStatsRange): Promise<RunReliability>;
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=governance-queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance-queries.d.ts","sourceRoot":"","sources":["../../../src/spi/governance-queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,0EAA0E;AAC1E,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAA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|
1
|
+
/**
|
|
2
|
+
* A read-model over the persisted agent data (usage ⋈ pricing, tool calls, threads) for the
|
|
3
|
+
* governance surfaces — the standalone `-dashboard` SPA and the `-telescope` "Agent" tab both
|
|
4
|
+
* consume this ONE interface, so cost/usage aggregation lives in a single place.
|
|
5
|
+
*
|
|
6
|
+
* Separate from {@link AgentStore} on purpose: that SPI owns the write/thread path, this owns the
|
|
7
|
+
* read/analytics path. A store adapter implements both. Consumers inject via
|
|
8
|
+
* `AGENT_GOVERNANCE_QUERIES`.
|
|
9
|
+
*
|
|
10
|
+
* Live activity (in-flight runs, streaming tool calls, delegations, forbidden attempts) is NOT here
|
|
11
|
+
* — that comes off the `aviary:agent:*` diagnostics channel. This interface is the durable, restart-
|
|
12
|
+
* surviving history.
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=governance-queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance-queries.js","sourceRoot":"","sources":["../../../src/spi/governance-queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { MessageUsage, ModelMessage, ToolCallRequest, ToolDefinition } from '../types.js';
|
|
2
|
+
import type { SinkWriter } from './token-stream-sink.js';
|
|
3
|
+
export interface ModelTurnArgs {
|
|
4
|
+
system: string;
|
|
5
|
+
messages: ModelMessage[];
|
|
6
|
+
tools: ToolDefinition[];
|
|
7
|
+
/** The model writes streamed text deltas here as it generates them. */
|
|
8
|
+
sink: SinkWriter;
|
|
9
|
+
abortSignal?: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
/** The outcome of ONE assistant turn. The loop — not the model — drives tool execution. */
|
|
12
|
+
export interface ModelTurnResult {
|
|
13
|
+
text: string;
|
|
14
|
+
toolCalls: ToolCallRequest[];
|
|
15
|
+
usage: MessageUsage;
|
|
16
|
+
/**
|
|
17
|
+
* The model actually used this turn (e.g. `anthropic.claude-...`), recorded with usage for
|
|
18
|
+
* cost accounting. When set it wins over the module's configured `modelId`, so the accounting
|
|
19
|
+
* label can't silently drift from the runtime. Omit if the provider can't report one.
|
|
20
|
+
*/
|
|
21
|
+
modelId?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The ACTUAL USD cost of this turn, when the provider knows it — a gateway (Vercel AI Gateway
|
|
24
|
+
* `providerMetadata.gateway.cost`, OpenRouter `total_cost`) reports real spend; a direct provider
|
|
25
|
+
* (Anthropic/OpenAI/Bedrock) reports only tokens and leaves this undefined. When set, the
|
|
26
|
+
* governance read-model uses it verbatim; otherwise it estimates from tokens × the pricing table.
|
|
27
|
+
*/
|
|
28
|
+
costUsd?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Thin wrapper over the actual LLM. The concrete impl (e.g. Vercel AI SDK `streamText`
|
|
32
|
+
* over Bedrock/Anthropic) lives in the host app or an adapter; core stays provider-free.
|
|
33
|
+
*
|
|
34
|
+
* Contract: `runTurn` performs exactly one model turn, streaming deltas to `args.sink`,
|
|
35
|
+
* and returns the assembled text + requested tool calls + usage. It MUST NOT execute
|
|
36
|
+
* tools — the agent loop runs each as a (durable) step for replay-safety.
|
|
37
|
+
*/
|
|
38
|
+
export interface ModelProvider {
|
|
39
|
+
runTurn(args: ModelTurnArgs): Promise<ModelTurnResult>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=model-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-provider.d.ts","sourceRoot":"","sources":["../../../src/spi/model-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC/F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,uEAAuE;IACvE,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,2FAA2F;AAC3F,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,KAAK,EAAE,YAAY,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACxD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { MessageUsage } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The WRITE side of the model pricing table the loop's cost fold prices token usage against. Cost is
|
|
4
|
+
* `null` (not `0`) for an unpriced model, so an app seeds its models' per-1M rates once (and
|
|
5
|
+
* re-`upsert`s when a provider changes prices). An adapter implements this — `LucidPricingStore`
|
|
6
|
+
* (production, over the `agent_model_pricing` table) and `InMemoryPricingStore` (testing) ship. Wire
|
|
7
|
+
* it in `config/agent.ts` via `pricingStore: pricingStores.lucid()`; use {@link seedModelPrices} for a
|
|
8
|
+
* one-shot batch. Mirrors the reference `AgentPricingStore` contract exactly.
|
|
9
|
+
*/
|
|
10
|
+
/** A per-1M-token price for one model. Cache rates fall back to the input rate when omitted. */
|
|
11
|
+
export interface ModelPriceInput {
|
|
12
|
+
modelId: string;
|
|
13
|
+
inputPricePer1m: number;
|
|
14
|
+
outputPricePer1m: number;
|
|
15
|
+
/** Per-1M price for cache-write (prompt-cache) input tokens. Omit → priced at the input rate. */
|
|
16
|
+
cacheWritePricePer1m?: number;
|
|
17
|
+
/** Per-1M price for cache-read (prompt-cache) input tokens. Omit → priced at the input rate. */
|
|
18
|
+
cacheReadPricePer1m?: number;
|
|
19
|
+
}
|
|
20
|
+
/** A current price row as read back, with the ISO timestamp it took effect. */
|
|
21
|
+
export interface CurrentModelPrice extends ModelPriceInput {
|
|
22
|
+
effectiveFrom: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AgentPricingStore {
|
|
25
|
+
/**
|
|
26
|
+
* Set the current price for a model. Atomic supersede: the model's prior `is_current` row (if any)
|
|
27
|
+
* is retired and this one is inserted as current, effective now — so the cost fold always joins to
|
|
28
|
+
* exactly one live price per model, with no window where two rows race for `is_current`.
|
|
29
|
+
*/
|
|
30
|
+
upsertModelPrice(input: ModelPriceInput): Promise<void>;
|
|
31
|
+
/** The current price row per model (`is_current`), fetched ONCE per run for the loop's cost fold. */
|
|
32
|
+
listCurrentPrices(): Promise<CurrentModelPrice[]>;
|
|
33
|
+
}
|
|
34
|
+
/** Seed (or refresh) a batch of model prices — one `upsertModelPrice` per row, in order. */
|
|
35
|
+
export declare function seedModelPrices(store: AgentPricingStore, prices: ModelPriceInput[]): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Token-ledger estimate for one turn against a pricing row: the uncached input at the input rate,
|
|
38
|
+
* cache-write/cache-read tokens at their own rates (falling back to the input rate when unpriced),
|
|
39
|
+
* plus output at the output rate. Reasoning tokens are a subset of output and are billed at the
|
|
40
|
+
* output rate, so they don't change the estimate. Cache token counts are subsets of `inputTokens`,
|
|
41
|
+
* so the uncached remainder is the difference. Pure — the SQL and in-memory adapters share it, so
|
|
42
|
+
* every surface reports identical numbers.
|
|
43
|
+
*/
|
|
44
|
+
export declare function estimateCost(usage: MessageUsage, price: CurrentModelPrice): number;
|
|
45
|
+
//# sourceMappingURL=pricing-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-store.d.ts","sourceRoot":"","sources":["../../../src/spi/pricing-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;GAOG;AAEH,gGAAgG;AAChG,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iGAAiG;IACjG,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gGAAgG;IAChG,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,+EAA+E;AAC/E,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,qGAAqG;IACrG,iBAAiB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;CACnD;AAED,4FAA4F;AAC5F,wBAAsB,eAAe,CACnC,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,eAAe,EAAE,GACxB,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAUlF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Seed (or refresh) a batch of model prices — one `upsertModelPrice` per row, in order. */
|
|
2
|
+
export async function seedModelPrices(store, prices) {
|
|
3
|
+
for (const price of prices) {
|
|
4
|
+
await store.upsertModelPrice(price);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Token-ledger estimate for one turn against a pricing row: the uncached input at the input rate,
|
|
9
|
+
* cache-write/cache-read tokens at their own rates (falling back to the input rate when unpriced),
|
|
10
|
+
* plus output at the output rate. Reasoning tokens are a subset of output and are billed at the
|
|
11
|
+
* output rate, so they don't change the estimate. Cache token counts are subsets of `inputTokens`,
|
|
12
|
+
* so the uncached remainder is the difference. Pure — the SQL and in-memory adapters share it, so
|
|
13
|
+
* every surface reports identical numbers.
|
|
14
|
+
*/
|
|
15
|
+
export function estimateCost(usage, price) {
|
|
16
|
+
const cacheWriteTokens = usage.cacheWriteTokens ?? 0;
|
|
17
|
+
const cacheReadTokens = usage.cacheReadTokens ?? 0;
|
|
18
|
+
const uncachedInputTokens = usage.inputTokens - cacheWriteTokens - cacheReadTokens;
|
|
19
|
+
return ((uncachedInputTokens / 1_000_000) * price.inputPricePer1m +
|
|
20
|
+
(cacheWriteTokens / 1_000_000) * (price.cacheWritePricePer1m ?? price.inputPricePer1m) +
|
|
21
|
+
(cacheReadTokens / 1_000_000) * (price.cacheReadPricePer1m ?? price.inputPricePer1m) +
|
|
22
|
+
(usage.outputTokens / 1_000_000) * price.outputPricePer1m);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=pricing-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing-store.js","sourceRoot":"","sources":["../../../src/spi/pricing-store.ts"],"names":[],"mappings":"AAsCA,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAwB,EACxB,MAAyB;IAEzB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAmB,EAAE,KAAwB;IACxE,MAAM,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,IAAI,CAAC,CAAC;IACrD,MAAM,eAAe,GAAG,KAAK,CAAC,eAAe,IAAI,CAAC,CAAC;IACnD,MAAM,mBAAmB,GAAG,KAAK,CAAC,WAAW,GAAG,gBAAgB,GAAG,eAAe,CAAC;IACnF,OAAO,CACL,CAAC,mBAAmB,GAAG,SAAS,CAAC,GAAG,KAAK,CAAC,eAAe;QACzD,CAAC,gBAAgB,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,IAAI,KAAK,CAAC,eAAe,CAAC;QACtF,CAAC,eAAe,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,IAAI,KAAK,CAAC,eAAe,CAAC;QACpF,CAAC,KAAK,CAAC,YAAY,GAAG,SAAS,CAAC,GAAG,KAAK,CAAC,gBAAgB,CAC1D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { QuotaState } from '../types.js';
|
|
2
|
+
/** Per-actor/day token budget. Default impl is in-memory; Redis impl ships in transport-redis. */
|
|
3
|
+
export interface QuotaStore {
|
|
4
|
+
check(actorRef: string, day: string): Promise<QuotaState>;
|
|
5
|
+
bump(actorRef: string, day: string, tokens: number): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=quota-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quota-store.d.ts","sourceRoot":"","sources":["../../../src/spi/quota-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,kGAAkG;AAClG,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1D,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Passage } from './retriever.js';
|
|
2
|
+
export interface RerankOptions {
|
|
3
|
+
/** Keep only the top N after reranking. Undefined → keep all, reordered. */
|
|
4
|
+
topK?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Re-scores retrieved passages against the query with a stronger (usually cross-encoder) model than
|
|
8
|
+
* the first-stage retriever — the standard precision boost for RAG. It's a black box like
|
|
9
|
+
* {@link import('./retriever.js').Retriever}: bring a Cohere/Voyage rerank endpoint or a local
|
|
10
|
+
* cross-encoder. Provider implementations are deferred this round (SPI only); the testing kit ships a
|
|
11
|
+
* trivial identity reranker. Mirrors the reference `Reranker` contract exactly.
|
|
12
|
+
*/
|
|
13
|
+
export interface Reranker {
|
|
14
|
+
/** Re-order `passages` by relevance to `query`, rewriting their `score`; may drop to `topK`. */
|
|
15
|
+
rerank(query: string, passages: Passage[], options?: RerankOptions): Promise<Passage[]>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=reranker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reranker.d.ts","sourceRoot":"","sources":["../../../src/spi/reranker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,gGAAgG;IAChG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CACzF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reranker.js","sourceRoot":"","sources":["../../../src/spi/reranker.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieval seam for RAG. A `Retriever` is a black box — the agent loop asks it for the passages most
|
|
3
|
+
* relevant to a query and never sees how (vector search, keyword, hybrid, a remote service). This
|
|
4
|
+
* package ships an {@link import('../rag/embedding-retriever.js').EmbeddingRetriever} (embed + vector
|
|
5
|
+
* store) built via the `retrievers` factory namespace, but any impl satisfying this SPI works. Wired
|
|
6
|
+
* on the config's `retriever` it drives always-on ("inject") retrieval: the loop retrieves once for
|
|
7
|
+
* the user message and folds the passages into the system prompt. Mirrors the reference `Retriever`
|
|
8
|
+
* contract exactly.
|
|
9
|
+
*/
|
|
10
|
+
/** One retrieved passage. `source` is a human/citation-facing origin; `score` is impl-defined relevance. */
|
|
11
|
+
export interface Passage {
|
|
12
|
+
id: string;
|
|
13
|
+
text: string;
|
|
14
|
+
score: number;
|
|
15
|
+
/** Where the passage came from (document title, URL, row id) — surfaced as a citation. */
|
|
16
|
+
source?: string;
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
export interface RetrieveOptions {
|
|
20
|
+
/** Max passages to return. The impl may cap it; the loop defaults to 5 when unset. */
|
|
21
|
+
topK?: number;
|
|
22
|
+
/** Impl-specific metadata filter (e.g. `{ tenantRef }`). Opaque to the runtime. */
|
|
23
|
+
filter?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
export interface Retriever {
|
|
26
|
+
retrieve(query: string, options?: RetrieveOptions): Promise<Passage[]>;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=retriever.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retriever.d.ts","sourceRoot":"","sources":["../../../src/spi/retriever.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,4GAA4G;AAC5G,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,eAAe;IAC9B,sFAAsF;IACtF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;CACxE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieval seam for RAG. A `Retriever` is a black box — the agent loop asks it for the passages most
|
|
3
|
+
* relevant to a query and never sees how (vector search, keyword, hybrid, a remote service). This
|
|
4
|
+
* package ships an {@link import('../rag/embedding-retriever.js').EmbeddingRetriever} (embed + vector
|
|
5
|
+
* store) built via the `retrievers` factory namespace, but any impl satisfying this SPI works. Wired
|
|
6
|
+
* on the config's `retriever` it drives always-on ("inject") retrieval: the loop retrieves once for
|
|
7
|
+
* the user message and folds the passages into the system prompt. Mirrors the reference `Retriever`
|
|
8
|
+
* contract exactly.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=retriever.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retriever.js","sourceRoot":"","sources":["../../../src/spi/retriever.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Actor, ToolSpec } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Decides whether an actor may invoke a tool. The default impl checks the actor's role
|
|
4
|
+
* against `spec.roles` (defaulting to an ADMIN-only set). Apps can plug `nestjs-authz`
|
|
5
|
+
* or any custom gate here.
|
|
6
|
+
*/
|
|
7
|
+
export interface RolesPolicy {
|
|
8
|
+
/** May return a promise — an authz Gate (`gate.forUser(actor).allows(...)`) is async. */
|
|
9
|
+
can(actor: Actor, tool: ToolSpec): boolean | Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=roles-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles-policy.d.ts","sourceRoot":"","sources":["../../../src/spi/roles-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,yFAAyF;IACzF,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Actor, PageContext, Persona } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Per-invocation context handed to a tool handler. Host-supplied bits are optional. Identity lives
|
|
4
|
+
* on {@link AiToolCtx.actor} — read `ctx.actor.id` / `ctx.actor.tenantRef` (single source of truth;
|
|
5
|
+
* no denormalized copies).
|
|
6
|
+
*/
|
|
7
|
+
export interface AiToolCtx {
|
|
8
|
+
actor: Actor;
|
|
9
|
+
threadId: string;
|
|
10
|
+
runId: string;
|
|
11
|
+
requestId: string;
|
|
12
|
+
persona?: Persona;
|
|
13
|
+
pageContext?: PageContext;
|
|
14
|
+
/** Optional host handle (e.g. an ORM EntityManager) the app threads through options. */
|
|
15
|
+
host?: unknown;
|
|
16
|
+
}
|
|
17
|
+
/** A tool implementation. `I` is the parsed (Zod-validated) input. */
|
|
18
|
+
export interface ToolHandler<I = unknown> {
|
|
19
|
+
execute(input: I, ctx: AiToolCtx): Promise<unknown>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/spi/tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE/D;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,wFAAwF;IACxF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,sEAAsE;AACtE,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD"}
|