@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,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a runtime does, declared — #198.
|
|
3
|
+
*
|
|
4
|
+
* ## Why a declaration exists at all
|
|
5
|
+
*
|
|
6
|
+
* Capabilities were already switchable: `usage?`, `messages?`, `quota?`, `approvals?`, `questions?`,
|
|
7
|
+
* `citations?` are all optional, and a host that wants a lean automation runtime passes fewer of them. The
|
|
8
|
+
* mechanism is right. The ergonomics are not, because **an unwired capability and a deliberately disabled one
|
|
9
|
+
* are indistinguishable**, and that ambiguity is this codebase's most repeated defect: #157, #159, #161, #163,
|
|
10
|
+
* #165 and #185 were each a capability that existed, passed its tests, and was wired to nothing.
|
|
11
|
+
* `check-reachability.mjs` exists because of it — and it can only ever check *this* repository, never a
|
|
12
|
+
* customer's.
|
|
13
|
+
*
|
|
14
|
+
* ## Why not just booleans
|
|
15
|
+
*
|
|
16
|
+
* A boolean cannot carry its dependency. `memory: true` still needs a store, so true-with-nothing-wired is a
|
|
17
|
+
* crash or a silent no-op — the same failure with a friendlier spelling. Twelve booleans is also 4,096
|
|
18
|
+
* combinations, almost none of them ever exercised.
|
|
19
|
+
*
|
|
20
|
+
* ## So: both, cross-checked
|
|
21
|
+
*
|
|
22
|
+
* The host declares, the host wires, and `resolveCapabilities` refuses to return a runtime whose declaration and
|
|
23
|
+
* wiring disagree — **in either direction**. Declared-on-but-unwired is the obvious one. Wired-but-undeclared
|
|
24
|
+
* matters just as much: it means the declaration has drifted into a lie, and the next reader trusts it.
|
|
25
|
+
*
|
|
26
|
+
* One error listing every mismatch, never the first one found. A caller fixing these one restart at a time is
|
|
27
|
+
* why configuration surfaces get abandoned.
|
|
28
|
+
*/
|
|
29
|
+
import { AgentPlatformError } from "../core/errors.js";
|
|
30
|
+
/**
|
|
31
|
+
* The switchable capabilities.
|
|
32
|
+
*
|
|
33
|
+
* Deliberately **not** including approvals or quota enforcement. An automation with no human is a legitimate
|
|
34
|
+
* case, and a flag that removes the enforcement is not the way to express it — that is an approval *policy*
|
|
35
|
+
* which auto-approves a stated set of effects, and is auditable afterwards where a flag leaves no record. The
|
|
36
|
+
* difference is between "nobody had to approve this" and "we cannot tell whether anyone should have".
|
|
37
|
+
*/
|
|
38
|
+
export const CAPABILITIES = [
|
|
39
|
+
"history",
|
|
40
|
+
"memory",
|
|
41
|
+
"compaction",
|
|
42
|
+
"citations",
|
|
43
|
+
"questions",
|
|
44
|
+
"skills",
|
|
45
|
+
"mcp",
|
|
46
|
+
"usage",
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* What each capability cannot work without, by the name a host wires it under.
|
|
50
|
+
*
|
|
51
|
+
* Names rather than types, because the check is about *presence*: the compiler already proves a supplied store
|
|
52
|
+
* is the right shape, and what it cannot prove is that one was supplied at all.
|
|
53
|
+
*/
|
|
54
|
+
export const CAPABILITY_REQUIRES = {
|
|
55
|
+
history: ["messages"],
|
|
56
|
+
memory: ["principalMemory"],
|
|
57
|
+
// Two, and both: a summariser with nowhere to put the summary compacts on every turn and never remembers
|
|
58
|
+
// having done it.
|
|
59
|
+
compaction: ["summaries", "summarizer"],
|
|
60
|
+
citations: ["citations"],
|
|
61
|
+
questions: ["interactions"],
|
|
62
|
+
skills: ["skills"],
|
|
63
|
+
mcp: ["mcpConnections", "mcpClient"],
|
|
64
|
+
usage: ["usage"],
|
|
65
|
+
};
|
|
66
|
+
const OFF = Object.freeze(Object.fromEntries(CAPABILITIES.map((c) => [c, "off"])));
|
|
67
|
+
/**
|
|
68
|
+
* Named starting points, so the two common shapes are one line.
|
|
69
|
+
*
|
|
70
|
+
* A profile is **only** a set of defaults and must be expressible by writing the capabilities out — otherwise it
|
|
71
|
+
* is a second configuration language, and the two drift. `profileToMap` and a test hold that.
|
|
72
|
+
*/
|
|
73
|
+
export const PROFILES = {
|
|
74
|
+
/** A chat assistant: everything a person interacts with, on. */
|
|
75
|
+
assistant: {
|
|
76
|
+
history: "on",
|
|
77
|
+
memory: "on",
|
|
78
|
+
compaction: "on",
|
|
79
|
+
citations: "on",
|
|
80
|
+
questions: "on",
|
|
81
|
+
skills: "on",
|
|
82
|
+
mcp: "off",
|
|
83
|
+
usage: "on",
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* A headless automation: no conversation, no person, no recall.
|
|
87
|
+
*
|
|
88
|
+
* `usage` stays on because an automation that runs unattended is precisely the one whose spend nobody is
|
|
89
|
+
* watching. Turning metering off by default there would be the expensive mistake.
|
|
90
|
+
*/
|
|
91
|
+
automation: {
|
|
92
|
+
history: "off",
|
|
93
|
+
memory: "off",
|
|
94
|
+
compaction: "off",
|
|
95
|
+
citations: "off",
|
|
96
|
+
questions: "off",
|
|
97
|
+
skills: "off",
|
|
98
|
+
mcp: "off",
|
|
99
|
+
usage: "on",
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
/** A profile as a plain map, so a caller can read a default before adopting it. */
|
|
103
|
+
export const profileToMap = (profile) => ({ ...PROFILES[profile] });
|
|
104
|
+
/**
|
|
105
|
+
* The effective capability map, or a refusal naming every disagreement.
|
|
106
|
+
*
|
|
107
|
+
* Absent from both profile and overrides means **off**. That direction is deliberate: a capability nobody
|
|
108
|
+
* mentioned is one nobody asked for, and defaulting to on would resurrect the problem this exists to solve — a
|
|
109
|
+
* feature quietly present, wired to nothing, until the day it matters.
|
|
110
|
+
*/
|
|
111
|
+
export const resolveCapabilities = (input) => {
|
|
112
|
+
const base = input.profile === undefined ? OFF : PROFILES[input.profile];
|
|
113
|
+
const effective = { ...base, ...(input.capabilities ?? {}) };
|
|
114
|
+
const unknown = Object.keys(input.capabilities ?? {}).filter((k) => !CAPABILITIES.includes(k));
|
|
115
|
+
const declaredNotWired = [];
|
|
116
|
+
const wiredNotDeclared = [];
|
|
117
|
+
for (const capability of CAPABILITIES) {
|
|
118
|
+
const needs = CAPABILITY_REQUIRES[capability];
|
|
119
|
+
const suppliedAll = needs.every((n) => input.wired.has(n));
|
|
120
|
+
const suppliedAny = needs.some((n) => input.wired.has(n));
|
|
121
|
+
if (effective[capability] === "on" && !suppliedAll) {
|
|
122
|
+
const missing = needs.filter((n) => !input.wired.has(n));
|
|
123
|
+
declaredNotWired.push(`${capability} is on but ${missing.join(" and ")} ${missing.length > 1 ? "were" : "was"} not supplied`);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* `suppliedAny`, not `suppliedAll`, for the reverse direction.
|
|
127
|
+
*
|
|
128
|
+
* A host that wired half of what a capability needs and declared it off has still told us two different
|
|
129
|
+
* things, and the half-wiring is the more likely mistake — it usually means they meant to turn it on.
|
|
130
|
+
*/
|
|
131
|
+
if (effective[capability] === "off" && suppliedAny) {
|
|
132
|
+
const supplied = needs.filter((n) => input.wired.has(n));
|
|
133
|
+
wiredNotDeclared.push(`${capability} is off but ${supplied.join(" and ")} ${supplied.length > 1 ? "were" : "was"} supplied`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const problems = [
|
|
137
|
+
...unknown.map((k) => `"${k}" is not a capability — the set is ${CAPABILITIES.join(", ")}`),
|
|
138
|
+
...declaredNotWired,
|
|
139
|
+
...wiredNotDeclared,
|
|
140
|
+
];
|
|
141
|
+
if (problems.length === 0)
|
|
142
|
+
return Object.freeze(effective);
|
|
143
|
+
throw new AgentPlatformError({
|
|
144
|
+
code: "invalid_input",
|
|
145
|
+
message: `this runtime's capability declaration does not match what was wired:\n` +
|
|
146
|
+
problems.map((p) => ` - ${p}`).join("\n") +
|
|
147
|
+
`\nEither supply what the capability needs, or declare it off. A capability that is present but ` +
|
|
148
|
+
`undeclared is the defect this check exists to prevent: it works until the day nobody remembers it is there.`,
|
|
149
|
+
retryable: false,
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* ## What is deliberately *not* here yet: a point-of-use gate
|
|
154
|
+
*
|
|
155
|
+
* The obvious companion to `resolveCapabilities` is a `requireCapability(map, cap, forWhat)` that a code path
|
|
156
|
+
* calls to refuse when its capability is off. It was written, tested, and **removed before shipping** — because
|
|
157
|
+
* nothing could call it.
|
|
158
|
+
*
|
|
159
|
+
* No runtime object holds a capability map today: a host wires `ResolverDeps` by hand, and the map produced here
|
|
160
|
+
* is consulted by nobody. So the gate would have been exported, covered by its own tests, and reachable from
|
|
161
|
+
* nothing — which is #157, #159, #161, #163, #165 and #185, in the module whose entire purpose is to stop that.
|
|
162
|
+
* Leaving it in because it "will be used soon" is precisely the reasoning that produced those six.
|
|
163
|
+
*
|
|
164
|
+
* It returns with #196, when the composition root exists and there is something to consult the map. The check
|
|
165
|
+
* that matters until then is the construction-time one above, and that one *is* called.
|
|
166
|
+
*/
|
|
167
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The composition root — #196.
|
|
3
|
+
*
|
|
4
|
+
* `resolveCapabilities` validates a declaration against a set of wired names. It works, and it left two gaps that
|
|
5
|
+
* only a composition root can close.
|
|
6
|
+
*
|
|
7
|
+
* **The `wired` set was hand-written.** A host passed `new Set(["messages", "principalMemory", …])` beside the
|
|
8
|
+
* stores it supplied, so the cross-check compared a declaration against *another declaration*. Two lists that
|
|
9
|
+
* must agree, neither derived from the thing they describe — which is the shape of the problem, not a fix for it.
|
|
10
|
+
* Here the set is derived from the objects actually supplied, so there is one statement of intent and one of
|
|
11
|
+
* fact.
|
|
12
|
+
*
|
|
13
|
+
* **A capability that is off was unenforced.** Nothing consulted the map, so "off" meant "the host did not wire
|
|
14
|
+
* it" and any code path that reached for it got `undefined`. `requireCapability` was written for this and
|
|
15
|
+
* removed in 684bb1d for having no caller — which was correct then and is fixable now.
|
|
16
|
+
*
|
|
17
|
+
* The fix is that **access is the gate**. `runtime.stores.messages` throws when `history` is off, naming the
|
|
18
|
+
* capability. Not a function a caller must remember to call first: the ones who forget are exactly the six
|
|
19
|
+
* defects this module exists for. Every consumer of a store goes through the same property.
|
|
20
|
+
*/
|
|
21
|
+
import type { RunEventLog } from "../core/events.js";
|
|
22
|
+
import type { InteractionStore, MessageStore, RunStore, SkillStore, ThreadSummaryStore, UsageStore } from "../persistence/index.js";
|
|
23
|
+
import type { PrincipalMemoryStore } from "../principal-memory/index.js";
|
|
24
|
+
import type { ThreadSummarizer } from "../context/compaction.js";
|
|
25
|
+
import type { CitationEmitter } from "../citations/index.js";
|
|
26
|
+
import type { McpClient, McpConnectionStore } from "../mcp/provider.js";
|
|
27
|
+
import { type Capability, type CapabilityMap, type ProfileName } from "./index.js";
|
|
28
|
+
/**
|
|
29
|
+
* What every runtime needs, capability or not.
|
|
30
|
+
*
|
|
31
|
+
* A run must be durable — that is the floor, not a feature, and a runtime without it is a library for calling a
|
|
32
|
+
* model. `eventLog` is separate and optional: a run without one still executes, it is simply unobservable while
|
|
33
|
+
* it does, which is a legitimate trade for a batch job nobody is watching.
|
|
34
|
+
*/
|
|
35
|
+
export type RuntimeFloor = {
|
|
36
|
+
readonly runs: RunStore;
|
|
37
|
+
readonly eventLog?: RunEventLog;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The capability-governed dependencies, keyed by the names `CAPABILITY_REQUIRES` uses.
|
|
41
|
+
*
|
|
42
|
+
* The key names are load-bearing: they are what the derived `wired` set is built from, so a key here and an
|
|
43
|
+
* entry in `CAPABILITY_REQUIRES` must spell the same thing. A test holds that, because a typo would silently
|
|
44
|
+
* mean "not wired" and the capability would be refused for a reason nobody could see.
|
|
45
|
+
*/
|
|
46
|
+
export type RuntimeStores = {
|
|
47
|
+
readonly messages?: MessageStore;
|
|
48
|
+
readonly principalMemory?: PrincipalMemoryStore;
|
|
49
|
+
readonly summaries?: ThreadSummaryStore;
|
|
50
|
+
readonly interactions?: InteractionStore;
|
|
51
|
+
readonly skills?: SkillStore;
|
|
52
|
+
readonly usage?: UsageStore;
|
|
53
|
+
readonly citations?: CitationEmitter;
|
|
54
|
+
readonly mcpConnections?: McpConnectionStore;
|
|
55
|
+
};
|
|
56
|
+
export type RuntimeServices = {
|
|
57
|
+
readonly summarizer?: ThreadSummarizer;
|
|
58
|
+
readonly mcpClient?: McpClient;
|
|
59
|
+
};
|
|
60
|
+
export type CreateRuntimeInput = {
|
|
61
|
+
readonly profile?: ProfileName;
|
|
62
|
+
readonly capabilities?: Partial<CapabilityMap>;
|
|
63
|
+
readonly floor: RuntimeFloor;
|
|
64
|
+
readonly stores?: RuntimeStores;
|
|
65
|
+
readonly services?: RuntimeServices;
|
|
66
|
+
};
|
|
67
|
+
export type Runtime = {
|
|
68
|
+
readonly capabilities: CapabilityMap;
|
|
69
|
+
/** The floor, always available. */
|
|
70
|
+
readonly floor: RuntimeFloor;
|
|
71
|
+
/**
|
|
72
|
+
* Capability-governed access. Reading a name whose capability is off **throws**, naming the capability.
|
|
73
|
+
*
|
|
74
|
+
* Reading, not calling — so a host cannot get a reference to a store it has turned off and use it later, which
|
|
75
|
+
* is the loophole a `require()`-style check leaves open.
|
|
76
|
+
*/
|
|
77
|
+
readonly stores: Required<RuntimeStores>;
|
|
78
|
+
readonly services: Required<RuntimeServices>;
|
|
79
|
+
/** True when the capability is on. For a host that wants to branch rather than be refused. */
|
|
80
|
+
enabled(capability: Capability): boolean;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Assemble a runtime, or refuse to.
|
|
84
|
+
*
|
|
85
|
+
* The declaration and the wiring are cross-checked here — every mismatch in one error — so a misconfigured
|
|
86
|
+
* runtime fails at construction rather than three hours into production.
|
|
87
|
+
*/
|
|
88
|
+
export declare const createRuntime: (input: CreateRuntimeInput) => Runtime;
|
|
89
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The composition root — #196.
|
|
3
|
+
*
|
|
4
|
+
* `resolveCapabilities` validates a declaration against a set of wired names. It works, and it left two gaps that
|
|
5
|
+
* only a composition root can close.
|
|
6
|
+
*
|
|
7
|
+
* **The `wired` set was hand-written.** A host passed `new Set(["messages", "principalMemory", …])` beside the
|
|
8
|
+
* stores it supplied, so the cross-check compared a declaration against *another declaration*. Two lists that
|
|
9
|
+
* must agree, neither derived from the thing they describe — which is the shape of the problem, not a fix for it.
|
|
10
|
+
* Here the set is derived from the objects actually supplied, so there is one statement of intent and one of
|
|
11
|
+
* fact.
|
|
12
|
+
*
|
|
13
|
+
* **A capability that is off was unenforced.** Nothing consulted the map, so "off" meant "the host did not wire
|
|
14
|
+
* it" and any code path that reached for it got `undefined`. `requireCapability` was written for this and
|
|
15
|
+
* removed in 684bb1d for having no caller — which was correct then and is fixable now.
|
|
16
|
+
*
|
|
17
|
+
* The fix is that **access is the gate**. `runtime.stores.messages` throws when `history` is off, naming the
|
|
18
|
+
* capability. Not a function a caller must remember to call first: the ones who forget are exactly the six
|
|
19
|
+
* defects this module exists for. Every consumer of a store goes through the same property.
|
|
20
|
+
*/
|
|
21
|
+
import { AgentPlatformError } from "../core/errors.js";
|
|
22
|
+
import { CAPABILITY_REQUIRES } from "./index.js";
|
|
23
|
+
import { resolveCapabilities } from "./index.js";
|
|
24
|
+
/** Which capability governs which supplied name — the inverse of `CAPABILITY_REQUIRES`. */
|
|
25
|
+
const GOVERNED_BY = Object.freeze(Object.fromEntries(Object.entries(CAPABILITY_REQUIRES).flatMap(([capability, needs]) => needs.map((name) => [name, capability]))));
|
|
26
|
+
const refuse = (name, capability) => {
|
|
27
|
+
throw new AgentPlatformError({
|
|
28
|
+
code: "invalid_input",
|
|
29
|
+
message: `this runtime has "${capability}" off, so ${name} is not available. Something reached for it anyway, ` +
|
|
30
|
+
`which means a code path is running that this configuration does not support — turn ${capability} on and ` +
|
|
31
|
+
`supply ${CAPABILITY_REQUIRES[capability].join(" and ")}, or do not take that path.`,
|
|
32
|
+
retryable: false,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A proxy rather than an object of getters.
|
|
37
|
+
*
|
|
38
|
+
* The same decision `lazyCoordinator` took, for the same reason: enumerating the keys means a dependency added
|
|
39
|
+
* later is silently absent from the gate, and silently-absent is the failure being designed against. One rule
|
|
40
|
+
* covers every name, present and future.
|
|
41
|
+
*/
|
|
42
|
+
const governed = (supplied, capabilities, label) => new Proxy(supplied, {
|
|
43
|
+
get(target, property) {
|
|
44
|
+
if (typeof property !== "string")
|
|
45
|
+
return Reflect.get(target, property);
|
|
46
|
+
const capability = GOVERNED_BY[property];
|
|
47
|
+
if (capability !== undefined && capabilities[capability] !== "on")
|
|
48
|
+
refuse(`${label}.${property}`, capability);
|
|
49
|
+
return Reflect.get(target, property);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Assemble a runtime, or refuse to.
|
|
54
|
+
*
|
|
55
|
+
* The declaration and the wiring are cross-checked here — every mismatch in one error — so a misconfigured
|
|
56
|
+
* runtime fails at construction rather than three hours into production.
|
|
57
|
+
*/
|
|
58
|
+
export const createRuntime = (input) => {
|
|
59
|
+
const stores = input.stores ?? {};
|
|
60
|
+
const services = input.services ?? {};
|
|
61
|
+
/**
|
|
62
|
+
* Derived, not declared.
|
|
63
|
+
*
|
|
64
|
+
* `Object.entries` over what was supplied, keeping only the defined values — because an explicit
|
|
65
|
+
* `messages: undefined` is how a spread of optional config produces a key that means nothing, and treating
|
|
66
|
+
* that as wired would refuse a runtime for a store that is not there.
|
|
67
|
+
*/
|
|
68
|
+
const wired = new Set([...Object.entries(stores), ...Object.entries(services)]
|
|
69
|
+
.filter(([, value]) => value !== undefined)
|
|
70
|
+
.map(([name]) => name));
|
|
71
|
+
const capabilities = resolveCapabilities({
|
|
72
|
+
...(input.profile === undefined ? {} : { profile: input.profile }),
|
|
73
|
+
...(input.capabilities === undefined ? {} : { capabilities: input.capabilities }),
|
|
74
|
+
wired,
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
capabilities,
|
|
78
|
+
floor: input.floor,
|
|
79
|
+
stores: governed(stores, capabilities, "stores"),
|
|
80
|
+
services: governed(services, capabilities, "services"),
|
|
81
|
+
enabled: (capability) => capabilities[capability] === "on",
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Citations and per-claim provenance — REQ-030 (#137).
|
|
3
|
+
*
|
|
4
|
+
* `research-and-citation` already says what should happen. This makes it structural, and the structure carries
|
|
5
|
+
* four decisions worth stating.
|
|
6
|
+
*
|
|
7
|
+
* **A citation is a snapshot, not a pointer.** `excerpt`, `title` and `retrievedAt` live on the part. AC-4
|
|
8
|
+
* requires an answer given months ago to stay auditable *after the source is gone* — a document deleted, a URL
|
|
9
|
+
* dead, a chunk re-indexed under a new id — and a citation that resolved by fetching would stop being evidence
|
|
10
|
+
* exactly when someone needs it. The duplication is the feature.
|
|
11
|
+
*
|
|
12
|
+
* **Groundedness is derived from the citation graph**, not flagged on the text. A text part is grounded exactly
|
|
13
|
+
* when some citation names it in `supports`. A boolean on the text part would be a second place for the same
|
|
14
|
+
* fact, and the two would drift the first time a citation was withheld — leaving a claim that says "grounded"
|
|
15
|
+
* with nothing behind it, which is worse than an honestly ungrounded one.
|
|
16
|
+
*
|
|
17
|
+
* **Permission is re-checked at citation time.** AC-5, and the reason is precise: retrieval and rendering are
|
|
18
|
+
* different moments, and a permission can change between them. A citation emitted on the strength of a
|
|
19
|
+
* retrieval check is a citation that can outlive the access that justified it.
|
|
20
|
+
*
|
|
21
|
+
* **One shape for retrieval and web research.** AC-6. Two part types would mean two renderers, two schemas and
|
|
22
|
+
* eventually two behaviours for "click the citation".
|
|
23
|
+
*/
|
|
24
|
+
import type { ExecutionContext } from "../core/context.js";
|
|
25
|
+
import type { MessagePartId } from "../core/ids.js";
|
|
26
|
+
import type { CitationOrigin, CitationPart, MessagePart } from "../core/content-parts.js";
|
|
27
|
+
import type { AuthorizationPolicy } from "../authorization/index.js";
|
|
28
|
+
import type { RetrievalHit } from "../knowledge/retrieval.js";
|
|
29
|
+
/** The current citation payload version. Bumped from 1 by #137, which added origin, excerpt and supports. */
|
|
30
|
+
export declare const CITATION_SCHEMA_VERSION = 2;
|
|
31
|
+
/**
|
|
32
|
+
* Trim an excerpt to the cap without cutting a word in half.
|
|
33
|
+
*
|
|
34
|
+
* A citation ending mid-word reads as corrupt, and a reader cannot tell whether the source said something else.
|
|
35
|
+
* The ellipsis is explicit so a truncated excerpt is visibly truncated rather than silently shorter than what
|
|
36
|
+
* was read.
|
|
37
|
+
*/
|
|
38
|
+
export declare const boundExcerpt: (text: string, max?: number) => string;
|
|
39
|
+
export type CitationCandidate = {
|
|
40
|
+
readonly origin: CitationOrigin;
|
|
41
|
+
readonly excerpt: string;
|
|
42
|
+
readonly retrievedAt: string;
|
|
43
|
+
readonly supports: readonly MessagePartId[];
|
|
44
|
+
readonly charRange?: {
|
|
45
|
+
readonly start: number;
|
|
46
|
+
readonly end: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The subject the reader must be entitled to.
|
|
50
|
+
*
|
|
51
|
+
* Required for a retrieval citation and absent for a web one — a public URL has no subject to check. Kept
|
|
52
|
+
* *outside* the part on purpose: it is an input to the emission decision, not something a stored citation
|
|
53
|
+
* should carry, because a stale subject on a durable part is a permission claim nobody re-evaluates.
|
|
54
|
+
*/
|
|
55
|
+
readonly authSubject?: string;
|
|
56
|
+
};
|
|
57
|
+
/** A citation built from a retrieval hit. The passage fields come from the hit, so they cannot disagree. */
|
|
58
|
+
export declare const citationFromRetrieval: (input: {
|
|
59
|
+
readonly hit: RetrievalHit;
|
|
60
|
+
readonly supports: readonly MessagePartId[];
|
|
61
|
+
readonly retrievedAt: string;
|
|
62
|
+
readonly charRange?: {
|
|
63
|
+
readonly start: number;
|
|
64
|
+
readonly end: number;
|
|
65
|
+
};
|
|
66
|
+
}) => CitationCandidate;
|
|
67
|
+
/**
|
|
68
|
+
* A citation built from a web passage.
|
|
69
|
+
*
|
|
70
|
+
* Shaped to accept ShareFlow's `SourcePassage` without adaptation — `url`, `retrievedAt`, `excerpt` — because
|
|
71
|
+
* AC-6 is only true if the two paths really do produce one thing rather than two things that look alike.
|
|
72
|
+
*/
|
|
73
|
+
export declare const citationFromWeb: (input: {
|
|
74
|
+
readonly passage: {
|
|
75
|
+
readonly url: string;
|
|
76
|
+
readonly retrievedAt: string;
|
|
77
|
+
readonly excerpt: string;
|
|
78
|
+
};
|
|
79
|
+
readonly title?: string;
|
|
80
|
+
readonly supports: readonly MessagePartId[];
|
|
81
|
+
}) => CitationCandidate;
|
|
82
|
+
export type EmittedCitations = {
|
|
83
|
+
readonly parts: readonly CitationPart[];
|
|
84
|
+
/**
|
|
85
|
+
* How many candidates were dropped for lack of access.
|
|
86
|
+
*
|
|
87
|
+
* Reported rather than silent. A withheld citation leaves its claim looking ungrounded, and a caller that
|
|
88
|
+
* cannot tell the difference between "nothing supported this" and "you may not see what supported this" will
|
|
89
|
+
* present the two identically — so the count is here for a caller that wants to drop the claim instead.
|
|
90
|
+
*/
|
|
91
|
+
readonly withheld: number;
|
|
92
|
+
};
|
|
93
|
+
export type CitationEmitterDeps = {
|
|
94
|
+
/**
|
|
95
|
+
* AC-5, enforced rather than asserted.
|
|
96
|
+
*
|
|
97
|
+
* **Required.** An emitter that would run without a policy is one someone constructs without one, at which
|
|
98
|
+
* point every citation is emitted regardless of access — and a citation carries an excerpt, so that leaks the
|
|
99
|
+
* text and not merely the existence of the source.
|
|
100
|
+
*/
|
|
101
|
+
readonly authorization: AuthorizationPolicy;
|
|
102
|
+
readonly clock?: () => string;
|
|
103
|
+
readonly partId?: () => string;
|
|
104
|
+
};
|
|
105
|
+
export declare const createCitationEmitter: (deps: CitationEmitterDeps) => {
|
|
106
|
+
/**
|
|
107
|
+
* Turn candidates into parts, dropping any the reader may not open.
|
|
108
|
+
*
|
|
109
|
+
* Checked here and not only at retrieval, because the two are different moments. A permission revoked in
|
|
110
|
+
* between is exactly the case the test steps name, and a citation emitted on a retrieval-time check would
|
|
111
|
+
* survive it.
|
|
112
|
+
*/
|
|
113
|
+
emit(context: ExecutionContext, candidates: readonly CitationCandidate[]): Promise<EmittedCitations>;
|
|
114
|
+
/**
|
|
115
|
+
* Whether this reader may be shown this citation.
|
|
116
|
+
*
|
|
117
|
+
* A web citation needs no check: its URL is public by construction, and asking a policy about it would be
|
|
118
|
+
* asking about a resource the policy has never heard of — which most policies answer by denying, silently
|
|
119
|
+
* suppressing every web citation.
|
|
120
|
+
*/
|
|
121
|
+
mayCite(context: ExecutionContext, candidate: CitationCandidate): Promise<boolean>;
|
|
122
|
+
};
|
|
123
|
+
export type CitationEmitter = ReturnType<typeof createCitationEmitter>;
|
|
124
|
+
/**
|
|
125
|
+
* The parts a message's citations ground — AC-3.
|
|
126
|
+
*
|
|
127
|
+
* Derived from the citation graph, so there is one source of truth. A caller renders a text part differently
|
|
128
|
+
* when its id is in this set; nothing has to inspect the prose.
|
|
129
|
+
*/
|
|
130
|
+
export declare const groundedPartIds: (parts: readonly MessagePart[]) => ReadonlySet<string>;
|
|
131
|
+
/** Citations that ground a given part, in the order they appear. For rendering markers next to a claim. */
|
|
132
|
+
export declare const citationsFor: (parts: readonly MessagePart[], partId: string) => readonly CitationPart[];
|
|
133
|
+
/**
|
|
134
|
+
* A citation that grounds nothing.
|
|
135
|
+
*
|
|
136
|
+
* Worth finding, because it is the shape a bug takes: a producer that emitted citations without wiring them to
|
|
137
|
+
* the claims they support leaves an answer that *looks* cited — markers in a list at the bottom — while no
|
|
138
|
+
* individual statement is traceable, which is the failure REQ-030 exists to prevent.
|
|
139
|
+
*/
|
|
140
|
+
export declare const danglingCitations: (parts: readonly MessagePart[]) => readonly CitationPart[];
|
|
141
|
+
/**
|
|
142
|
+
* What a citation resolves to — AC-2.
|
|
143
|
+
*
|
|
144
|
+
* Returned from the *stored part alone*, with no lookup, which is what makes AC-4 hold: an audit months later
|
|
145
|
+
* gets the same answer whether or not the source still exists. `live` says whether following it further is
|
|
146
|
+
* possible, so a reader is told "this is what was read, and the source is gone" rather than being handed a
|
|
147
|
+
* broken link.
|
|
148
|
+
*/
|
|
149
|
+
export type ResolvedCitation = {
|
|
150
|
+
readonly excerpt: string;
|
|
151
|
+
readonly retrievedAt: string;
|
|
152
|
+
/** Human-readable: a heading path, or a title, or the URL. What a reader sees next to the claim. */
|
|
153
|
+
readonly label: string;
|
|
154
|
+
/** Where to go, if anywhere. A chunk id for retrieval, the URL for web. */
|
|
155
|
+
readonly target: string;
|
|
156
|
+
readonly kind: CitationOrigin["kind"];
|
|
157
|
+
};
|
|
158
|
+
export declare const resolveCitation: (part: CitationPart) => ResolvedCitation;
|
|
159
|
+
/** Thrown when a producer tries to cite without an excerpt. A citation with no text is not evidence. */
|
|
160
|
+
export declare const assertCitable: (candidate: CitationCandidate) => void;
|
|
161
|
+
//# sourceMappingURL=index.d.ts.map
|