@retinue/agentkit 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 +22 -0
- package/README.md +310 -0
- package/dist/adapters/bullmq/consumer.d.ts +33 -0
- package/dist/adapters/bullmq/consumer.js +41 -0
- package/dist/adapters/bullmq/dispatcher.d.ts +74 -0
- package/dist/adapters/bullmq/dispatcher.js +160 -0
- package/dist/adapters/bullmq/export.d.ts +31 -0
- package/dist/adapters/bullmq/export.js +53 -0
- package/dist/adapters/bullmq/extraction.d.ts +42 -0
- package/dist/adapters/bullmq/extraction.js +63 -0
- package/dist/adapters/bullmq/index.d.ts +13 -0
- package/dist/adapters/bullmq/index.js +13 -0
- package/dist/adapters/bullmq/lock.d.ts +77 -0
- package/dist/adapters/bullmq/lock.js +126 -0
- package/dist/adapters/bullmq/queue.d.ts +50 -0
- package/dist/adapters/bullmq/queue.js +81 -0
- package/dist/adapters/memory/artifact-exports.d.ts +11 -0
- package/dist/adapters/memory/artifact-exports.js +102 -0
- package/dist/adapters/memory/artifacts.d.ts +15 -0
- package/dist/adapters/memory/artifacts.js +134 -0
- package/dist/adapters/memory/blobs.d.ts +7 -0
- package/dist/adapters/memory/blobs.js +27 -0
- package/dist/adapters/memory/evaluation.d.ts +18 -0
- package/dist/adapters/memory/evaluation.js +148 -0
- package/dist/adapters/memory/files.d.ts +27 -0
- package/dist/adapters/memory/files.js +0 -0
- package/dist/adapters/memory/flows.d.ts +16 -0
- package/dist/adapters/memory/flows.js +117 -0
- package/dist/adapters/memory/hitl.d.ts +9 -0
- package/dist/adapters/memory/hitl.js +130 -0
- package/dist/adapters/memory/idempotency.d.ts +13 -0
- package/dist/adapters/memory/idempotency.js +32 -0
- package/dist/adapters/memory/index.d.ts +39 -0
- package/dist/adapters/memory/index.js +107 -0
- package/dist/adapters/memory/knowledge.d.ts +43 -0
- package/dist/adapters/memory/knowledge.js +248 -0
- package/dist/adapters/memory/mcp.d.ts +9 -0
- package/dist/adapters/memory/mcp.js +37 -0
- package/dist/adapters/memory/message-store.d.ts +17 -0
- package/dist/adapters/memory/message-store.js +70 -0
- package/dist/adapters/memory/principal-memory.d.ts +7 -0
- package/dist/adapters/memory/principal-memory.js +83 -0
- package/dist/adapters/memory/runtime.d.ts +29 -0
- package/dist/adapters/memory/runtime.js +0 -0
- package/dist/adapters/memory/sessions.d.ts +29 -0
- package/dist/adapters/memory/sessions.js +0 -0
- package/dist/adapters/memory/skills.d.ts +10 -0
- package/dist/adapters/memory/skills.js +41 -0
- package/dist/adapters/memory/thread-summary.d.ts +7 -0
- package/dist/adapters/memory/thread-summary.js +29 -0
- package/dist/adapters/memory/usage-limits.d.ts +13 -0
- package/dist/adapters/memory/usage-limits.js +72 -0
- package/dist/adapters/memory/usage.d.ts +16 -0
- package/dist/adapters/memory/usage.js +279 -0
- package/dist/adapters/otel/index.d.ts +111 -0
- package/dist/adapters/otel/index.js +133 -0
- package/dist/adapters/postgres/artifact-exports.d.ts +12 -0
- package/dist/adapters/postgres/artifact-exports.js +117 -0
- package/dist/adapters/postgres/artifacts.d.ts +16 -0
- package/dist/adapters/postgres/artifacts.js +172 -0
- package/dist/adapters/postgres/checkpoint-store.d.ts +16 -0
- package/dist/adapters/postgres/checkpoint-store.js +34 -0
- package/dist/adapters/postgres/config.d.ts +15 -0
- package/dist/adapters/postgres/config.js +187 -0
- package/dist/adapters/postgres/conversation-store.d.ts +4 -0
- package/dist/adapters/postgres/conversation-store.js +82 -0
- package/dist/adapters/postgres/evaluation.d.ts +17 -0
- package/dist/adapters/postgres/evaluation.js +193 -0
- package/dist/adapters/postgres/file-content.d.ts +30 -0
- package/dist/adapters/postgres/file-content.js +111 -0
- package/dist/adapters/postgres/files.d.ts +19 -0
- package/dist/adapters/postgres/files.js +209 -0
- package/dist/adapters/postgres/flows.d.ts +20 -0
- package/dist/adapters/postgres/flows.js +206 -0
- package/dist/adapters/postgres/hitl.d.ts +5 -0
- package/dist/adapters/postgres/hitl.js +247 -0
- package/dist/adapters/postgres/index.d.ts +35 -0
- package/dist/adapters/postgres/index.js +35 -0
- package/dist/adapters/postgres/knowledge.d.ts +48 -0
- package/dist/adapters/postgres/knowledge.js +255 -0
- package/dist/adapters/postgres/memory.d.ts +14 -0
- package/dist/adapters/postgres/memory.js +194 -0
- package/dist/adapters/postgres/message-store.d.ts +11 -0
- package/dist/adapters/postgres/message-store.js +145 -0
- package/dist/adapters/postgres/migrations.d.ts +69 -0
- package/dist/adapters/postgres/migrations.js +1594 -0
- package/dist/adapters/postgres/pg-executor.d.ts +19 -0
- package/dist/adapters/postgres/pg-executor.js +32 -0
- package/dist/adapters/postgres/retention.d.ts +26 -0
- package/dist/adapters/postgres/retention.js +59 -0
- package/dist/adapters/postgres/rollups.d.ts +17 -0
- package/dist/adapters/postgres/rollups.js +267 -0
- package/dist/adapters/postgres/run-coordinator.d.ts +5 -0
- package/dist/adapters/postgres/run-coordinator.js +98 -0
- package/dist/adapters/postgres/run-event-log.d.ts +26 -0
- package/dist/adapters/postgres/run-event-log.js +30 -0
- package/dist/adapters/postgres/run-store.d.ts +4 -0
- package/dist/adapters/postgres/run-store.js +199 -0
- package/dist/adapters/postgres/schema.d.ts +39 -0
- package/dist/adapters/postgres/schema.js +70 -0
- package/dist/adapters/postgres/session-state.d.ts +7 -0
- package/dist/adapters/postgres/session-state.js +99 -0
- package/dist/adapters/postgres/sql.d.ts +8 -0
- package/dist/adapters/postgres/sql.js +2 -0
- package/dist/adapters/postgres/transaction.d.ts +37 -0
- package/dist/adapters/postgres/transaction.js +93 -0
- package/dist/adapters/postgres/unit-of-work.d.ts +18 -0
- package/dist/adapters/postgres/unit-of-work.js +8 -0
- package/dist/adapters/postgres/usage-limits.d.ts +15 -0
- package/dist/adapters/postgres/usage-limits.js +136 -0
- package/dist/adapters/postgres/usage.d.ts +15 -0
- package/dist/adapters/postgres/usage.js +226 -0
- package/dist/adapters/redis/index.d.ts +9 -0
- package/dist/adapters/redis/index.js +9 -0
- package/dist/adapters/redis/realtime.d.ts +74 -0
- package/dist/adapters/redis/realtime.js +112 -0
- package/dist/adapters/supabase/index.d.ts +88 -0
- package/dist/adapters/supabase/index.js +84 -0
- package/dist/adapters/supabase/realtime.d.ts +30 -0
- package/dist/adapters/supabase/realtime.js +53 -0
- package/dist/adapters/supabase/rls.d.ts +99 -0
- package/dist/adapters/supabase/rls.js +216 -0
- package/dist/adapters/supabase/storage.d.ts +50 -0
- package/dist/adapters/supabase/storage.js +207 -0
- package/dist/agents/agent.d.ts +66 -0
- package/dist/agents/agent.js +209 -0
- package/dist/agents/define.d.ts +21 -0
- package/dist/agents/define.js +63 -0
- package/dist/agents/engine.d.ts +98 -0
- package/dist/agents/engine.js +462 -0
- package/dist/agents/index.d.ts +50 -0
- package/dist/agents/index.js +17 -0
- package/dist/artifacts/index.d.ts +114 -0
- package/dist/artifacts/index.js +219 -0
- package/dist/authorization/index.d.ts +76 -0
- package/dist/authorization/index.js +76 -0
- package/dist/capabilities/index.d.ts +120 -0
- package/dist/capabilities/index.js +167 -0
- package/dist/capabilities/runtime.d.ts +89 -0
- package/dist/capabilities/runtime.js +84 -0
- package/dist/citations/index.d.ts +161 -0
- package/dist/citations/index.js +182 -0
- package/dist/context/assembler.d.ts +82 -0
- package/dist/context/assembler.js +129 -0
- package/dist/context/compaction.d.ts +45 -0
- package/dist/context/compaction.js +55 -0
- package/dist/context/index.d.ts +75 -0
- package/dist/context/index.js +17 -0
- package/dist/core/content-parts.d.ts +194 -0
- package/dist/core/content-parts.js +23 -0
- package/dist/core/context.d.ts +51 -0
- package/dist/core/context.js +9 -0
- package/dist/core/env.d.ts +25 -0
- package/dist/core/env.js +41 -0
- package/dist/core/errors.d.ts +30 -0
- package/dist/core/errors.js +65 -0
- package/dist/core/events.d.ts +139 -0
- package/dist/core/events.js +99 -0
- package/dist/core/ids.d.ts +52 -0
- package/dist/core/ids.js +13 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.js +9 -0
- package/dist/core/tokens.d.ts +22 -0
- package/dist/core/tokens.js +22 -0
- package/dist/core/validation.d.ts +34 -0
- package/dist/core/validation.js +176 -0
- package/dist/documents/extraction.d.ts +121 -0
- package/dist/documents/extraction.js +293 -0
- package/dist/documents/index.d.ts +199 -0
- package/dist/documents/index.js +65 -0
- package/dist/documents/parsers/pdf.d.ts +47 -0
- package/dist/documents/parsers/pdf.js +508 -0
- package/dist/documents/parsers/text.d.ts +59 -0
- package/dist/documents/parsers/text.js +325 -0
- package/dist/documents/read-tool.d.ts +52 -0
- package/dist/documents/read-tool.js +109 -0
- package/dist/documents/render.d.ts +29 -0
- package/dist/documents/render.js +59 -0
- package/dist/documents/vision.d.ts +159 -0
- package/dist/documents/vision.js +214 -0
- package/dist/entries/adapters-bullmq.d.ts +8 -0
- package/dist/entries/adapters-bullmq.js +8 -0
- package/dist/entries/adapters-otel.d.ts +13 -0
- package/dist/entries/adapters-otel.js +13 -0
- package/dist/entries/adapters-postgres.d.ts +10 -0
- package/dist/entries/adapters-postgres.js +10 -0
- package/dist/entries/adapters-redis.d.ts +3 -0
- package/dist/entries/adapters-redis.js +3 -0
- package/dist/entries/context.d.ts +20 -0
- package/dist/entries/context.js +20 -0
- package/dist/entries/flows.d.ts +15 -0
- package/dist/entries/flows.js +15 -0
- package/dist/entries/hitl.d.ts +10 -0
- package/dist/entries/hitl.js +10 -0
- package/dist/entries/knowledge.d.ts +18 -0
- package/dist/entries/knowledge.js +19 -0
- package/dist/entries/mcp.d.ts +10 -0
- package/dist/entries/mcp.js +10 -0
- package/dist/entries/observability.d.ts +14 -0
- package/dist/entries/observability.js +16 -0
- package/dist/entries/persistence.d.ts +11 -0
- package/dist/entries/persistence.js +11 -0
- package/dist/entries/providers.d.ts +14 -0
- package/dist/entries/providers.js +14 -0
- package/dist/entries/runtime.d.ts +13 -0
- package/dist/entries/runtime.js +13 -0
- package/dist/entries/server.d.ts +24 -0
- package/dist/entries/server.js +24 -0
- package/dist/entries/tools.d.ts +21 -0
- package/dist/entries/tools.js +21 -0
- package/dist/entries/usage.d.ts +10 -0
- package/dist/entries/usage.js +10 -0
- package/dist/evaluation/gate.d.ts +168 -0
- package/dist/evaluation/gate.js +180 -0
- package/dist/evaluation/graders.d.ts +125 -0
- package/dist/evaluation/graders.js +203 -0
- package/dist/evaluation/index.d.ts +120 -0
- package/dist/evaluation/index.js +183 -0
- package/dist/evaluation/judge.d.ts +75 -0
- package/dist/evaluation/judge.js +111 -0
- package/dist/export/index.d.ts +162 -0
- package/dist/export/index.js +363 -0
- package/dist/export/markdown.d.ts +19 -0
- package/dist/export/markdown.js +29 -0
- package/dist/export/pdf.d.ts +73 -0
- package/dist/export/pdf.js +407 -0
- package/dist/files/context.d.ts +97 -0
- package/dist/files/context.js +185 -0
- package/dist/files/index.d.ts +210 -0
- package/dist/files/index.js +338 -0
- package/dist/files/read-tool.d.ts +81 -0
- package/dist/files/read-tool.js +163 -0
- package/dist/files/turn-parts.d.ts +96 -0
- package/dist/files/turn-parts.js +171 -0
- package/dist/flows/index.d.ts +270 -0
- package/dist/flows/index.js +62 -0
- package/dist/flows/interpreter.d.ts +146 -0
- package/dist/flows/interpreter.js +426 -0
- package/dist/flows/runner.d.ts +145 -0
- package/dist/flows/runner.js +270 -0
- package/dist/graphql/index.d.ts +8 -0
- package/dist/graphql/index.js +8 -0
- package/dist/graphql/resolvers.d.ts +237 -0
- package/dist/graphql/resolvers.js +253 -0
- package/dist/graphql/schema.d.ts +11 -0
- package/dist/graphql/schema.js +258 -0
- package/dist/graphql/sse.d.ts +77 -0
- package/dist/graphql/sse.js +100 -0
- package/dist/hitl/approved-execution.d.ts +127 -0
- package/dist/hitl/approved-execution.js +177 -0
- package/dist/hitl/index.d.ts +79 -0
- package/dist/hitl/index.js +12 -0
- package/dist/hitl/service.d.ts +221 -0
- package/dist/hitl/service.js +268 -0
- package/dist/idempotency/index.d.ts +70 -0
- package/dist/idempotency/index.js +59 -0
- package/dist/index.d.ts +103 -0
- package/dist/index.js +60 -0
- package/dist/knowledge/chunking.d.ts +57 -0
- package/dist/knowledge/chunking.js +158 -0
- package/dist/knowledge/index.d.ts +119 -0
- package/dist/knowledge/index.js +166 -0
- package/dist/knowledge/retrieval.d.ts +146 -0
- package/dist/knowledge/retrieval.js +170 -0
- package/dist/loadtest/harness.d.ts +168 -0
- package/dist/loadtest/harness.js +507 -0
- package/dist/loadtest/index.d.ts +13 -0
- package/dist/loadtest/index.js +13 -0
- package/dist/loadtest/injection.d.ts +89 -0
- package/dist/loadtest/injection.js +147 -0
- package/dist/loadtest/metrics.d.ts +197 -0
- package/dist/loadtest/metrics.js +160 -0
- package/dist/loadtest/runbooks.d.ts +28 -0
- package/dist/loadtest/runbooks.js +159 -0
- package/dist/loadtest/scenario.d.ts +104 -0
- package/dist/loadtest/scenario.js +208 -0
- package/dist/mcp/egress.d.ts +53 -0
- package/dist/mcp/egress.js +115 -0
- package/dist/mcp/index.d.ts +93 -0
- package/dist/mcp/index.js +33 -0
- package/dist/mcp/provider.d.ts +62 -0
- package/dist/mcp/provider.js +0 -0
- package/dist/models/index.d.ts +98 -0
- package/dist/models/index.js +74 -0
- package/dist/models/pricing.d.ts +24 -0
- package/dist/models/pricing.js +37 -0
- package/dist/models/provider-factory.d.ts +31 -0
- package/dist/models/provider-factory.js +67 -0
- package/dist/models/streaming.d.ts +145 -0
- package/dist/models/streaming.js +272 -0
- package/dist/models/vision.d.ts +38 -0
- package/dist/models/vision.js +62 -0
- package/dist/persistence/index.d.ts +1654 -0
- package/dist/persistence/index.js +226 -0
- package/dist/principal-memory/index.d.ts +106 -0
- package/dist/principal-memory/index.js +89 -0
- package/dist/retention/index.d.ts +89 -0
- package/dist/retention/index.js +70 -0
- package/dist/runtime/checkpoint.d.ts +37 -0
- package/dist/runtime/checkpoint.js +22 -0
- package/dist/runtime/index.d.ts +118 -0
- package/dist/runtime/index.js +69 -0
- package/dist/runtime/retry.d.ts +95 -0
- package/dist/runtime/retry.js +126 -0
- package/dist/runtime/serialization.d.ts +85 -0
- package/dist/runtime/serialization.js +95 -0
- package/dist/runtime/streaming.d.ts +54 -0
- package/dist/runtime/streaming.js +115 -0
- package/dist/runtime/worker.d.ts +130 -0
- package/dist/runtime/worker.js +405 -0
- package/dist/security/checklist.d.ts +53 -0
- package/dist/security/checklist.js +204 -0
- package/dist/security/findings.d.ts +56 -0
- package/dist/security/findings.js +168 -0
- package/dist/security/index.d.ts +14 -0
- package/dist/security/index.js +14 -0
- package/dist/security/prompt-safety.d.ts +100 -0
- package/dist/security/prompt-safety.js +133 -0
- package/dist/server/boot.d.ts +32 -0
- package/dist/server/boot.js +36 -0
- package/dist/server/cli-worker.d.ts +37 -0
- package/dist/server/cli-worker.js +151 -0
- package/dist/server/cli.d.ts +27 -0
- package/dist/server/cli.js +74 -0
- package/dist/server/config.d.ts +42 -0
- package/dist/server/config.js +127 -0
- package/dist/server/health.d.ts +59 -0
- package/dist/server/health.js +90 -0
- package/dist/server/host.d.ts +39 -0
- package/dist/server/host.js +124 -0
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.js +15 -0
- package/dist/server/main.d.ts +16 -0
- package/dist/server/main.js +31 -0
- package/dist/server/sse-route.d.ts +21 -0
- package/dist/server/sse-route.js +282 -0
- package/dist/skills/index.d.ts +67 -0
- package/dist/skills/index.js +31 -0
- package/dist/skills/resolver.d.ts +54 -0
- package/dist/skills/resolver.js +121 -0
- package/dist/teams/index.d.ts +93 -0
- package/dist/teams/index.js +207 -0
- package/dist/telemetry/index.d.ts +157 -0
- package/dist/telemetry/index.js +71 -0
- package/dist/telemetry/instrument.d.ts +108 -0
- package/dist/telemetry/instrument.js +232 -0
- package/dist/telemetry/log-events.d.ts +17 -0
- package/dist/telemetry/log-events.js +58 -0
- package/dist/telemetry/metrics.d.ts +123 -0
- package/dist/telemetry/metrics.js +135 -0
- package/dist/telemetry/noop.d.ts +39 -0
- package/dist/telemetry/noop.js +143 -0
- package/dist/telemetry/redaction.d.ts +64 -0
- package/dist/telemetry/redaction.js +153 -0
- package/dist/telemetry/spans.d.ts +56 -0
- package/dist/telemetry/spans.js +78 -0
- package/dist/telemetry/trace-context.d.ts +55 -0
- package/dist/telemetry/trace-context.js +60 -0
- package/dist/toolkit/compute.d.ts +53 -0
- package/dist/toolkit/compute.js +152 -0
- package/dist/toolkit/data.d.ts +98 -0
- package/dist/toolkit/data.js +235 -0
- package/dist/toolkit/http.d.ts +113 -0
- package/dist/toolkit/http.js +205 -0
- package/dist/toolkit/index.d.ts +21 -0
- package/dist/toolkit/index.js +17 -0
- package/dist/toolkit/web.d.ts +107 -0
- package/dist/toolkit/web.js +147 -0
- package/dist/tools/define.d.ts +25 -0
- package/dist/tools/define.js +45 -0
- package/dist/tools/delegating.d.ts +132 -0
- package/dist/tools/delegating.js +211 -0
- package/dist/tools/index.d.ts +129 -0
- package/dist/tools/index.js +33 -0
- package/dist/tools/library/compute.d.ts +11 -0
- package/dist/tools/library/compute.js +46 -0
- package/dist/tools/library/data.d.ts +16 -0
- package/dist/tools/library/data.js +92 -0
- package/dist/tools/library/http.d.ts +28 -0
- package/dist/tools/library/http.js +71 -0
- package/dist/tools/library/index.d.ts +97 -0
- package/dist/tools/library/index.js +134 -0
- package/dist/tools/library/knowledge.d.ts +39 -0
- package/dist/tools/library/knowledge.js +58 -0
- package/dist/tools/library/web.d.ts +19 -0
- package/dist/tools/library/web.js +65 -0
- package/dist/tools/meta-tools.d.ts +19 -0
- package/dist/tools/meta-tools.js +36 -0
- package/dist/tools/registry.d.ts +146 -0
- package/dist/tools/registry.js +291 -0
- package/dist/usage/index.d.ts +105 -0
- package/dist/usage/index.js +20 -0
- package/dist/usage/quota.d.ts +258 -0
- package/dist/usage/quota.js +510 -0
- package/dist/usage/recorder.d.ts +29 -0
- package/dist/usage/recorder.js +96 -0
- package/dist/usage/rollups.d.ts +121 -0
- package/dist/usage/rollups.js +157 -0
- package/dist/worker/export.d.ts +57 -0
- package/dist/worker/export.js +81 -0
- package/dist/worker/extraction.d.ts +57 -0
- package/dist/worker/extraction.js +84 -0
- package/dist/worker/main.d.ts +103 -0
- package/dist/worker/main.js +159 -0
- package/package.json +187 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory message + agent stores — used by the embedded `createAgent` facade and for tests.
|
|
3
|
+
* Tenant-partitioned. `append` is on the port as of #157 — it used to be a "test-only affordance", which meant
|
|
4
|
+
* every host had to reach past the port to record what a user said. AgentStore serves manifests by version.
|
|
5
|
+
*/
|
|
6
|
+
import type { AgentManifest } from "../../agents/index.js";
|
|
7
|
+
import type { AgentStore, MessageStore } from "../../persistence/index.js";
|
|
8
|
+
export declare const createMemoryMessageStore: () => MessageStore;
|
|
9
|
+
/** A manifest and the tenant that owns it. Manifests carry no `tenantId`, so ownership is explicit here. */
|
|
10
|
+
export type AgentStoreEntry = {
|
|
11
|
+
readonly tenantId: string;
|
|
12
|
+
readonly manifest: AgentManifest;
|
|
13
|
+
};
|
|
14
|
+
export declare const createMemoryAgentStore: (entries?: readonly AgentStoreEntry[]) => AgentStore & {
|
|
15
|
+
put(tenantId: string, manifest: AgentManifest): void;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=message-store.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory message + agent stores — used by the embedded `createAgent` facade and for tests.
|
|
3
|
+
* Tenant-partitioned. `append` is on the port as of #157 — it used to be a "test-only affordance", which meant
|
|
4
|
+
* every host had to reach past the port to record what a user said. AgentStore serves manifests by version.
|
|
5
|
+
*/
|
|
6
|
+
export const createMemoryMessageStore = () => {
|
|
7
|
+
const byTenant = new Map();
|
|
8
|
+
const list = (t) => {
|
|
9
|
+
let m = byTenant.get(t);
|
|
10
|
+
if (!m)
|
|
11
|
+
byTenant.set(t, (m = []));
|
|
12
|
+
return m;
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
async append({ tenantId, message }) {
|
|
16
|
+
// Idempotent on the id, matching the Postgres adapter's `ON CONFLICT DO NOTHING`. The reference adapter
|
|
17
|
+
// silently diverging on a retry is exactly the class of difference the conformance suite exists to catch.
|
|
18
|
+
const messages = list(tenantId);
|
|
19
|
+
if (messages.some((m) => m.id === message.id))
|
|
20
|
+
return;
|
|
21
|
+
messages.push(message);
|
|
22
|
+
},
|
|
23
|
+
async findById({ tenantId, id }) {
|
|
24
|
+
return list(tenantId).find((m) => m.id === id) ?? null;
|
|
25
|
+
},
|
|
26
|
+
async listByConversation({ tenantId, conversationId, limit, cursor, newestFirst }) {
|
|
27
|
+
/**
|
|
28
|
+
* Ordered by `(createdAt, id)`, like the SQL adapter — not by insertion order.
|
|
29
|
+
*
|
|
30
|
+
* It used to page the array as stored, which agreed with the SQL adapter only because every seed happened
|
|
31
|
+
* to insert in timestamp order. A host that appended an older message — a backfill, a replayed event —
|
|
32
|
+
* would have got a different order from each adapter, and the conformance suite could not see it because
|
|
33
|
+
* its own fixtures were ordered too.
|
|
34
|
+
*/
|
|
35
|
+
const all = list(tenantId)
|
|
36
|
+
.filter((m) => m.conversationId === conversationId)
|
|
37
|
+
.sort((a, b) => a.createdAt === b.createdAt ? a.id.localeCompare(b.id) : a.createdAt.localeCompare(b.createdAt));
|
|
38
|
+
// #167: the same page read from the other end.
|
|
39
|
+
const ordered = newestFirst === true ? [...all].reverse() : all;
|
|
40
|
+
const start = cursor ? ordered.findIndex((m) => m.id === cursor) + 1 : 0;
|
|
41
|
+
const items = ordered.slice(start, start + limit);
|
|
42
|
+
const nextCursor = start + limit < ordered.length ? items[items.length - 1]?.id : undefined;
|
|
43
|
+
const page = nextCursor === undefined ? { items } : { items, nextCursor };
|
|
44
|
+
return page;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export const createMemoryAgentStore = (entries = []) => {
|
|
49
|
+
// tenantId → (id@version → manifest). Partitioning by tenant makes cross-tenant reads
|
|
50
|
+
// structurally impossible, matching every sibling store in this package. Keying only by
|
|
51
|
+
// `id@version` let one tenant resolve another's manifest — the leak the #91 harness surfaced.
|
|
52
|
+
const byTenant = new Map();
|
|
53
|
+
const tenant = (t) => {
|
|
54
|
+
let m = byTenant.get(t);
|
|
55
|
+
if (!m)
|
|
56
|
+
byTenant.set(t, (m = new Map()));
|
|
57
|
+
return m;
|
|
58
|
+
};
|
|
59
|
+
const key = (id, v) => `${id}@${v}`;
|
|
60
|
+
const put = (tenantId, manifest) => void tenant(tenantId).set(key(manifest.id, manifest.version), manifest);
|
|
61
|
+
for (const entry of entries)
|
|
62
|
+
put(entry.tenantId, entry.manifest);
|
|
63
|
+
return {
|
|
64
|
+
put,
|
|
65
|
+
async findByVersion({ tenantId, agentId, version }) {
|
|
66
|
+
return byTenant.get(tenantId)?.get(key(agentId, version)) ?? null;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=message-store.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory principal memory store — `docs/15`. Partitioned by (tenant, principal) so a query can
|
|
3
|
+
* never reach another principal's or tenant's memory. Versioned; hard-delete cannot resurface.
|
|
4
|
+
*/
|
|
5
|
+
import type { PrincipalMemoryStore } from "../../principal-memory/index.js";
|
|
6
|
+
export declare const createMemoryPrincipalMemoryStore: (clock?: () => string) => PrincipalMemoryStore;
|
|
7
|
+
//# sourceMappingURL=principal-memory.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory principal memory store — `docs/15`. Partitioned by (tenant, principal) so a query can
|
|
3
|
+
* never reach another principal's or tenant's memory. Versioned; hard-delete cannot resurface.
|
|
4
|
+
*/
|
|
5
|
+
import { AgentPlatformError } from "../../core/errors.js";
|
|
6
|
+
const conflict = (m) => new AgentPlatformError({ code: "conflict", message: m, retryable: false });
|
|
7
|
+
const notFound = (id) => new AgentPlatformError({ code: "not_found", message: `Memory ${id} not found`, retryable: false });
|
|
8
|
+
export const createMemoryPrincipalMemoryStore = (clock = () => new Date().toISOString()) => {
|
|
9
|
+
const byKey = new Map();
|
|
10
|
+
let counter = 0;
|
|
11
|
+
const key = (t, p) => `${t} ${p}`;
|
|
12
|
+
const bucket = (t, p) => {
|
|
13
|
+
const k = key(t, p);
|
|
14
|
+
let m = byKey.get(k);
|
|
15
|
+
if (!m)
|
|
16
|
+
byKey.set(k, (m = new Map()));
|
|
17
|
+
return m;
|
|
18
|
+
};
|
|
19
|
+
const active = (e) => e.disabledAt === undefined;
|
|
20
|
+
return {
|
|
21
|
+
async put({ tenantId, principalId, id, text, tags, salience }) {
|
|
22
|
+
const rows = bucket(tenantId, principalId);
|
|
23
|
+
const entryId = id ?? `mem-${(counter += 1)}`;
|
|
24
|
+
const now = clock();
|
|
25
|
+
const existing = rows.get(entryId);
|
|
26
|
+
const entry = {
|
|
27
|
+
id: entryId,
|
|
28
|
+
tenantId,
|
|
29
|
+
principalId,
|
|
30
|
+
text,
|
|
31
|
+
tags: tags ?? [],
|
|
32
|
+
salience: salience ?? 1,
|
|
33
|
+
version: existing ? existing.version + 1 : 1,
|
|
34
|
+
createdAt: existing?.createdAt ?? now,
|
|
35
|
+
updatedAt: now,
|
|
36
|
+
};
|
|
37
|
+
rows.set(entryId, entry);
|
|
38
|
+
return entry;
|
|
39
|
+
},
|
|
40
|
+
async get({ tenantId, principalId, id }) {
|
|
41
|
+
return bucket(tenantId, principalId).get(id) ?? null;
|
|
42
|
+
},
|
|
43
|
+
async list({ tenantId, principalId, limit, cursor }) {
|
|
44
|
+
const all = [...bucket(tenantId, principalId).values()].sort((a, b) => a.createdAt < b.createdAt ? -1 : a.createdAt > b.createdAt ? 1 : a.id < b.id ? -1 : 1);
|
|
45
|
+
const start = cursor ? all.findIndex((e) => e.id === cursor) + 1 : 0;
|
|
46
|
+
const items = all.slice(start, start + limit);
|
|
47
|
+
const nextCursor = start + limit < all.length ? items[items.length - 1]?.id : undefined;
|
|
48
|
+
const page = nextCursor === undefined ? { items } : { items, nextCursor };
|
|
49
|
+
return page;
|
|
50
|
+
},
|
|
51
|
+
async update({ tenantId, principalId, id, expectedVersion, patch }) {
|
|
52
|
+
const rows = bucket(tenantId, principalId);
|
|
53
|
+
const row = rows.get(id);
|
|
54
|
+
if (!row)
|
|
55
|
+
throw notFound(id);
|
|
56
|
+
if (row.version !== expectedVersion)
|
|
57
|
+
throw conflict(`Memory ${id} version ${expectedVersion} is stale (current ${row.version})`);
|
|
58
|
+
const next = {
|
|
59
|
+
...row,
|
|
60
|
+
...(patch.text === undefined ? {} : { text: patch.text }),
|
|
61
|
+
...(patch.tags === undefined ? {} : { tags: patch.tags }),
|
|
62
|
+
...(patch.salience === undefined ? {} : { salience: patch.salience }),
|
|
63
|
+
...(patch.disabled === undefined ? {} : patch.disabled ? { disabledAt: clock() } : { disabledAt: undefined }),
|
|
64
|
+
version: row.version + 1,
|
|
65
|
+
updatedAt: clock(),
|
|
66
|
+
};
|
|
67
|
+
rows.set(id, next);
|
|
68
|
+
return next;
|
|
69
|
+
},
|
|
70
|
+
async delete({ tenantId, principalId, id }) {
|
|
71
|
+
bucket(tenantId, principalId).delete(id); // hard delete — cannot resurface
|
|
72
|
+
},
|
|
73
|
+
async retrieve({ tenantId, principalId, query, limit }) {
|
|
74
|
+
const q = query?.trim().toLowerCase();
|
|
75
|
+
return [...bucket(tenantId, principalId).values()]
|
|
76
|
+
.filter(active)
|
|
77
|
+
.filter((e) => !q || e.text.toLowerCase().includes(q) || e.tags.some((t) => t.toLowerCase().includes(q)))
|
|
78
|
+
.sort((a, b) => b.salience - a.salience)
|
|
79
|
+
.slice(0, limit);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=principal-memory.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory runtime adapters — `docs/04-durable-runtime-and-hitl.md`.
|
|
3
|
+
*
|
|
4
|
+
* Reference `RunStore`, `CheckpointStore`, `JobDispatcher` and `DistributedLockStore` for tests and
|
|
5
|
+
* dev. The `RunStore` models real lease semantics (atomic claim, expiry, guarded transitions) so the
|
|
6
|
+
* durable-worker guarantees can be proven without Redis/Postgres. Verified by `runStoreConformance`.
|
|
7
|
+
*/
|
|
8
|
+
import type { RunId, TenantId } from "../../core/ids.js";
|
|
9
|
+
import type { RunEventLog } from "../../core/events.js";
|
|
10
|
+
import type { CheckpointStore, RunStore } from "../../persistence/index.js";
|
|
11
|
+
import { type DistributedLockStore, type JobDispatcher } from "../../runtime/index.js";
|
|
12
|
+
export declare const createMemoryRunStore: () => RunStore;
|
|
13
|
+
export declare const createMemoryCheckpointStore: () => CheckpointStore;
|
|
14
|
+
/** Append-only in-memory `RunEventLog` — the durable catch-up half of reconnect, for tests/dev. */
|
|
15
|
+
export declare const createMemoryRunEventLog: () => RunEventLog;
|
|
16
|
+
/**
|
|
17
|
+
* Synchronous in-memory job dispatcher. Enqueue records the job; `drain` runs each pending job
|
|
18
|
+
* through the provided processor. Mirrors Twenty's `SyncDriver` — inline execution for tests.
|
|
19
|
+
*/
|
|
20
|
+
export declare const createMemoryJobDispatcher: (process: (job: {
|
|
21
|
+
tenantId: TenantId;
|
|
22
|
+
runId: RunId;
|
|
23
|
+
}) => Promise<unknown>) => JobDispatcher & {
|
|
24
|
+
pending: () => number;
|
|
25
|
+
drain: () => Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
/** In-memory lock with TTL expiry. `now` is injectable for deterministic tests. */
|
|
28
|
+
export declare const createMemoryLockStore: (now?: () => number) => DistributedLockStore;
|
|
29
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
Binary file
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory session/thread adapters — `docs/13-sessions-and-threads.md`.
|
|
3
|
+
*
|
|
4
|
+
* Reference `SessionStateStore`, `ConversationRunCoordinator`, `ConversationBindingStore` and a
|
|
5
|
+
* rollback-capable `UnitOfWork` for tests and dev. They model the real semantics the runtime relies
|
|
6
|
+
* on: optimistic concurrency + size bounds on session state, single-flight + FIFO run ordering per
|
|
7
|
+
* conversation, deterministic agent binding, and all-or-nothing turn commit.
|
|
8
|
+
*/
|
|
9
|
+
import type { ConversationBindingStore, ConversationRunCoordinator, SessionStateStore, UnitOfWork } from "../../persistence/index.js";
|
|
10
|
+
export declare const createMemorySessionStateStore: (options?: {
|
|
11
|
+
maxBytes?: number;
|
|
12
|
+
clock?: () => string;
|
|
13
|
+
}) => SessionStateStore;
|
|
14
|
+
export declare const createMemoryConversationBindingStore: () => ConversationBindingStore;
|
|
15
|
+
export declare const createMemoryConversationRunCoordinator: () => ConversationRunCoordinator;
|
|
16
|
+
/** Rollback hook a transactional body registers compensating actions on. */
|
|
17
|
+
export interface RollbackContext {
|
|
18
|
+
onRollback(compensate: () => void | Promise<void>): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Memory `UnitOfWork` with explicit compensation: the body registers rollbacks; if it throws, they
|
|
22
|
+
* run in reverse. Real Postgres uses an actual transaction — this gives the reference adapter the
|
|
23
|
+
* same all-or-nothing guarantee (session-state write and run finalization commit together or not
|
|
24
|
+
* at all). Use `runTx` to receive the rollback context; `run` satisfies the bare port.
|
|
25
|
+
*/
|
|
26
|
+
export declare const createMemoryUnitOfWork: () => UnitOfWork & {
|
|
27
|
+
runTx<T>(fn: (tx: RollbackContext) => Promise<T>): Promise<T>;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=sessions.d.ts.map
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory skill store — `docs/03` → Skills. Holds tenant-authored skill versions for the resolver.
|
|
3
|
+
* Tenant-partitioned; validated on the way in against SKILL_LIMITS via `validateSkillInput`.
|
|
4
|
+
*/
|
|
5
|
+
import type { SkillStore } from "../../persistence/index.js";
|
|
6
|
+
import type { SkillVersion } from "../../skills/index.js";
|
|
7
|
+
export declare const createMemorySkillStore: (seed?: readonly SkillVersion[]) => SkillStore & {
|
|
8
|
+
add(tenantId: string, skill: SkillVersion): void;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory skill store — `docs/03` → Skills. Holds tenant-authored skill versions for the resolver.
|
|
3
|
+
* Tenant-partitioned; validated on the way in against SKILL_LIMITS via `validateSkillInput`.
|
|
4
|
+
*/
|
|
5
|
+
import { validateSkillInput } from "../../skills/resolver.js";
|
|
6
|
+
export const createMemorySkillStore = (seed = []) => {
|
|
7
|
+
// tenantId -> `${name}@${version}` -> SkillVersion
|
|
8
|
+
const byTenant = new Map();
|
|
9
|
+
const tenant = (t) => {
|
|
10
|
+
let m = byTenant.get(t);
|
|
11
|
+
if (!m)
|
|
12
|
+
byTenant.set(t, (m = new Map()));
|
|
13
|
+
return m;
|
|
14
|
+
};
|
|
15
|
+
const add = (tenantId, skill) => {
|
|
16
|
+
validateSkillInput(skill);
|
|
17
|
+
tenant(tenantId).set(`${skill.name}@${skill.version}`, skill);
|
|
18
|
+
};
|
|
19
|
+
for (const s of seed)
|
|
20
|
+
if (s.tenantId)
|
|
21
|
+
add(s.tenantId, s);
|
|
22
|
+
return {
|
|
23
|
+
add,
|
|
24
|
+
async listCatalog({ tenantId }) {
|
|
25
|
+
// Latest version per name, active only.
|
|
26
|
+
const latest = new Map();
|
|
27
|
+
for (const s of tenant(tenantId).values()) {
|
|
28
|
+
if (s.status !== "active")
|
|
29
|
+
continue;
|
|
30
|
+
const prev = latest.get(s.name);
|
|
31
|
+
if (!prev || s.version > prev.version)
|
|
32
|
+
latest.set(s.name, s);
|
|
33
|
+
}
|
|
34
|
+
return [...latest.values()].map((s) => ({ id: s.id, name: s.name, description: s.description, source: s.source, version: s.version }));
|
|
35
|
+
},
|
|
36
|
+
async findVersion({ tenantId, name, version }) {
|
|
37
|
+
return tenant(tenantId).get(`${name}@${version}`) ?? null;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=skills.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory thread summary store — `docs/13` → Long-thread compaction. Versioned, append-only
|
|
3
|
+
* compacted history; `latest` returns the newest summary. Tenant/conversation-partitioned.
|
|
4
|
+
*/
|
|
5
|
+
import type { ThreadSummaryStore } from "../../persistence/index.js";
|
|
6
|
+
export declare const createMemoryThreadSummaryStore: (clock?: () => string) => ThreadSummaryStore;
|
|
7
|
+
//# sourceMappingURL=thread-summary.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory thread summary store — `docs/13` → Long-thread compaction. Versioned, append-only
|
|
3
|
+
* compacted history; `latest` returns the newest summary. Tenant/conversation-partitioned.
|
|
4
|
+
*/
|
|
5
|
+
export const createMemoryThreadSummaryStore = (clock = () => new Date().toISOString()) => {
|
|
6
|
+
const byKey = new Map();
|
|
7
|
+
const key = (tenantId, conversationId) => `${tenantId} ${conversationId}`;
|
|
8
|
+
return {
|
|
9
|
+
async latest({ tenantId, conversationId }) {
|
|
10
|
+
const list = byKey.get(key(tenantId, conversationId));
|
|
11
|
+
return list && list.length > 0 ? list[list.length - 1] : null;
|
|
12
|
+
},
|
|
13
|
+
async append({ tenantId, conversationId, summary, coversUpToMessageId }) {
|
|
14
|
+
const k = key(tenantId, conversationId);
|
|
15
|
+
const list = byKey.get(k) ?? [];
|
|
16
|
+
const next = {
|
|
17
|
+
conversationId,
|
|
18
|
+
version: list.length + 1,
|
|
19
|
+
summary,
|
|
20
|
+
coversUpToMessageId,
|
|
21
|
+
createdAt: clock(),
|
|
22
|
+
};
|
|
23
|
+
list.push(next);
|
|
24
|
+
byKey.set(k, list);
|
|
25
|
+
return next;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=thread-summary.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory `UsageLimitStore` — the reference implementation (#175).
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the SQL adapter's resolution rule exactly, including the part that is easy to get subtly different:
|
|
5
|
+
* **most specific wins**, and a tenant default is the fallback rather than something to merge with. A store that
|
|
6
|
+
* merged the two — taking the principal's cost limit and the tenant's token limit — would be a third behaviour
|
|
7
|
+
* neither adapter documents, and the conformance suite exists to stop precisely that.
|
|
8
|
+
*/
|
|
9
|
+
import type { UsageLimitStore } from "../../persistence/index.js";
|
|
10
|
+
export declare const createMemoryUsageLimitStore: (config?: {
|
|
11
|
+
readonly clock?: () => string;
|
|
12
|
+
}) => UsageLimitStore;
|
|
13
|
+
//# sourceMappingURL=usage-limits.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory `UsageLimitStore` — the reference implementation (#175).
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the SQL adapter's resolution rule exactly, including the part that is easy to get subtly different:
|
|
5
|
+
* **most specific wins**, and a tenant default is the fallback rather than something to merge with. A store that
|
|
6
|
+
* merged the two — taking the principal's cost limit and the tenant's token limit — would be a third behaviour
|
|
7
|
+
* neither adapter documents, and the conformance suite exists to stop precisely that.
|
|
8
|
+
*/
|
|
9
|
+
import { windowKey } from "../../persistence/index.js";
|
|
10
|
+
/**
|
|
11
|
+
* Keyed by grain, with the tenant default under an empty principal segment — same shape as the SQL indexes.
|
|
12
|
+
*
|
|
13
|
+
* The window half goes through `windowKey`, the same function the SQL adapter stores, so the two adapters cannot
|
|
14
|
+
* key a rolling window differently. Spelling it `${minutes}` here and `rolling:${minutes}` there would leave both
|
|
15
|
+
* stores self-consistent and mutually unreadable, which conformance would not catch.
|
|
16
|
+
*/
|
|
17
|
+
const keyOf = (principalId, modelId, window) =>
|
|
18
|
+
// Three segments with an explicit empty for "absent", matching the SQL index's `COALESCE(col, '')`. Neither id
|
|
19
|
+
// can legitimately be empty, so the marker cannot collide with a real value.
|
|
20
|
+
`${principalId ?? ""} ${modelId ?? ""} ${windowKey(window)}`;
|
|
21
|
+
export const createMemoryUsageLimitStore = (config = {}) => {
|
|
22
|
+
const clock = config.clock ?? (() => new Date().toISOString());
|
|
23
|
+
const byTenant = new Map();
|
|
24
|
+
const tenant = (t) => {
|
|
25
|
+
let m = byTenant.get(t);
|
|
26
|
+
if (!m)
|
|
27
|
+
byTenant.set(t, (m = new Map()));
|
|
28
|
+
return m;
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
async put({ tenantId, limit }) {
|
|
32
|
+
const stored = { ...limit, tenantId: tenantId, updatedAt: clock() };
|
|
33
|
+
tenant(tenantId).set(keyOf(limit.principalId, limit.modelId, limit.window), stored);
|
|
34
|
+
return stored;
|
|
35
|
+
},
|
|
36
|
+
async resolve({ tenantId, principalId, modelId, window }) {
|
|
37
|
+
const rows = tenant(tenantId);
|
|
38
|
+
// The principal's own row, else the tenant default, else unbounded. A fallback, never a merge: a partial
|
|
39
|
+
// override that inherited the rest would be a third set of limits nobody configured.
|
|
40
|
+
return (rows.get(keyOf(principalId, modelId, window)) ?? rows.get(keyOf(undefined, modelId, window)) ?? null);
|
|
41
|
+
},
|
|
42
|
+
async applicable({ tenantId, principalId, modelId }) {
|
|
43
|
+
// Override within a scope, coexist across scopes — #182. One row per `(window, model)`, the principal's
|
|
44
|
+
// beating the tenant's for that same scope only.
|
|
45
|
+
const bestByScope = new Map();
|
|
46
|
+
for (const record of tenant(tenantId).values()) {
|
|
47
|
+
// A row for somebody else never applies; a model-scoped row applies only to that model, and not at all
|
|
48
|
+
// when the caller has no model to check.
|
|
49
|
+
if (record.principalId !== undefined && record.principalId !== principalId)
|
|
50
|
+
continue;
|
|
51
|
+
if (record.modelId !== undefined && record.modelId !== modelId)
|
|
52
|
+
continue;
|
|
53
|
+
const scope = `${record.modelId ?? ""} ${windowKey(record.window)}`;
|
|
54
|
+
const held = bestByScope.get(scope);
|
|
55
|
+
// A principal's row wins the scope. Where both are the tenant's or both the principal's there is only
|
|
56
|
+
// one row, since that is exactly what the key is.
|
|
57
|
+
if (held === undefined || (held.principalId === undefined && record.principalId !== undefined))
|
|
58
|
+
bestByScope.set(scope, record);
|
|
59
|
+
}
|
|
60
|
+
return [...bestByScope.values()];
|
|
61
|
+
},
|
|
62
|
+
async list({ tenantId }) {
|
|
63
|
+
return [...tenant(tenantId).values()].sort((a, b) => (a.principalId ?? "").localeCompare(b.principalId ?? "") ||
|
|
64
|
+
(a.modelId ?? "").localeCompare(b.modelId ?? "") ||
|
|
65
|
+
windowKey(a.window).localeCompare(windowKey(b.window)));
|
|
66
|
+
},
|
|
67
|
+
async remove({ tenantId, principalId, modelId, window }) {
|
|
68
|
+
tenant(tenantId).delete(keyOf(principalId, modelId, window));
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=usage-limits.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { UsageRollupStore, UsageStore } from "../../persistence/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The ledger and its rollups over one set of rows (#139).
|
|
4
|
+
*
|
|
5
|
+
* One backend, because a rollup is *derived* from the ledger and nothing else — deriving it from a second copy
|
|
6
|
+
* of the events would make the two able to disagree, which is the one thing a spend figure must not do.
|
|
7
|
+
*/
|
|
8
|
+
export declare const createMemoryUsageBackend: (options?: {
|
|
9
|
+
readonly clock?: () => string;
|
|
10
|
+
}) => {
|
|
11
|
+
usage: UsageStore;
|
|
12
|
+
rollups: UsageRollupStore;
|
|
13
|
+
};
|
|
14
|
+
export declare const createMemoryUsageStore: () => UsageStore;
|
|
15
|
+
export declare const createMemoryUsageRollupStore: () => UsageRollupStore;
|
|
16
|
+
//# sourceMappingURL=usage.d.ts.map
|