agentfootprint 9.3.0 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -1
- package/CLAUDE.md +3 -1
- package/dist/adapters/identity/agentcore.js +94 -26
- package/dist/adapters/identity/agentcore.js.map +1 -1
- package/dist/adapters/llm/BedrockProvider.js +34 -9
- package/dist/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/adapters/memory/s3Vectors.js +158 -6
- package/dist/adapters/memory/s3Vectors.js.map +1 -1
- package/dist/adapters/observability/cloudwatch.js +13 -8
- package/dist/adapters/observability/cloudwatch.js.map +1 -1
- package/dist/adapters/observability/xray.js +13 -8
- package/dist/adapters/observability/xray.js.map +1 -1
- package/dist/adapters/security/agentcore.js +0 -0
- package/dist/adapters/security/agentcore.js.map +1 -1
- package/dist/bridge/eventMeta.js +3 -0
- package/dist/bridge/eventMeta.js.map +1 -1
- package/dist/core/Agent.js +11 -0
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/stages/toolCalls.js +80 -7
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/doors/security.js +3 -2
- package/dist/doors/security.js.map +1 -1
- package/dist/esm/adapters/identity/agentcore.d.ts +39 -9
- package/dist/esm/adapters/identity/agentcore.js +94 -26
- package/dist/esm/adapters/identity/agentcore.js.map +1 -1
- package/dist/esm/adapters/llm/BedrockProvider.d.ts +24 -0
- package/dist/esm/adapters/llm/BedrockProvider.js +34 -9
- package/dist/esm/adapters/llm/BedrockProvider.js.map +1 -1
- package/dist/esm/adapters/memory/s3Vectors.d.ts +36 -4
- package/dist/esm/adapters/memory/s3Vectors.js +158 -6
- package/dist/esm/adapters/memory/s3Vectors.js.map +1 -1
- package/dist/esm/adapters/observability/cloudwatch.d.ts +20 -0
- package/dist/esm/adapters/observability/cloudwatch.js +13 -8
- package/dist/esm/adapters/observability/cloudwatch.js.map +1 -1
- package/dist/esm/adapters/observability/xray.d.ts +18 -0
- package/dist/esm/adapters/observability/xray.js +13 -8
- package/dist/esm/adapters/observability/xray.js.map +1 -1
- package/dist/esm/adapters/security/agentcore.d.ts +81 -107
- package/dist/esm/adapters/security/agentcore.js +0 -0
- package/dist/esm/adapters/security/agentcore.js.map +1 -1
- package/dist/esm/bridge/eventMeta.d.ts +3 -0
- package/dist/esm/bridge/eventMeta.js +3 -0
- package/dist/esm/bridge/eventMeta.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +16 -0
- package/dist/esm/core/Agent.js +11 -0
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/stages/toolCalls.js +80 -7
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/doors/security.d.ts +3 -2
- package/dist/esm/doors/security.js +3 -2
- package/dist/esm/doors/security.js.map +1 -1
- package/dist/esm/events/dispatcher.d.ts +1 -1
- package/dist/esm/events/dispatcher.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +23 -1
- package/dist/esm/events/types.d.ts +17 -0
- package/dist/esm/hosting/standingAgent.js +14 -1
- package/dist/esm/hosting/standingAgent.js.map +1 -1
- package/dist/esm/memory/define.d.ts +2 -1
- package/dist/esm/memory/define.js +45 -8
- package/dist/esm/memory/define.js.map +1 -1
- package/dist/esm/memory/define.types.d.ts +30 -4
- package/dist/esm/memory/define.types.js +6 -0
- package/dist/esm/memory/define.types.js.map +1 -1
- package/dist/esm/memory/index.d.ts +1 -0
- package/dist/esm/memory/index.js +3 -0
- package/dist/esm/memory/index.js.map +1 -1
- package/dist/esm/memory/pipeline/default.d.ts +16 -0
- package/dist/esm/memory/pipeline/default.js +8 -1
- package/dist/esm/memory/pipeline/default.js.map +1 -1
- package/dist/esm/memory/stages/filterByDecay.d.ts +67 -0
- package/dist/esm/memory/stages/filterByDecay.js +44 -0
- package/dist/esm/memory/stages/filterByDecay.js.map +1 -0
- package/dist/esm/memory/stages/index.d.ts +2 -0
- package/dist/esm/memory/stages/index.js +1 -0
- package/dist/esm/memory/stages/index.js.map +1 -1
- package/dist/esm/memory/strategies.d.ts +107 -0
- package/dist/esm/memory/strategies.js +232 -0
- package/dist/esm/memory/strategies.js.map +1 -0
- package/dist/esm/recorders/core/CredentialRecorder.d.ts +30 -0
- package/dist/esm/recorders/core/CredentialRecorder.js +35 -0
- package/dist/esm/recorders/core/CredentialRecorder.js.map +1 -0
- package/dist/esm/security/index.d.ts +7 -3
- package/dist/esm/security/index.js +12 -7
- package/dist/esm/security/index.js.map +1 -1
- package/dist/events/dispatcher.js.map +1 -1
- package/dist/hosting/standingAgent.js +14 -1
- package/dist/hosting/standingAgent.js.map +1 -1
- package/dist/memory/define.js +45 -8
- package/dist/memory/define.js.map +1 -1
- package/dist/memory/define.types.js +6 -0
- package/dist/memory/define.types.js.map +1 -1
- package/dist/memory/index.js +6 -1
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/pipeline/default.js +8 -1
- package/dist/memory/pipeline/default.js.map +1 -1
- package/dist/memory/stages/filterByDecay.js +48 -0
- package/dist/memory/stages/filterByDecay.js.map +1 -0
- package/dist/memory/stages/index.js +4 -1
- package/dist/memory/stages/index.js.map +1 -1
- package/dist/memory/strategies.js +238 -0
- package/dist/memory/strategies.js.map +1 -0
- package/dist/recorders/core/CredentialRecorder.js +39 -0
- package/dist/recorders/core/CredentialRecorder.js.map +1 -0
- package/dist/security/index.js +13 -7
- package/dist/security/index.js.map +1 -1
- package/dist/types/adapters/identity/agentcore.d.ts +39 -9
- package/dist/types/adapters/identity/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/llm/BedrockProvider.d.ts +24 -0
- package/dist/types/adapters/llm/BedrockProvider.d.ts.map +1 -1
- package/dist/types/adapters/memory/s3Vectors.d.ts +36 -4
- package/dist/types/adapters/memory/s3Vectors.d.ts.map +1 -1
- package/dist/types/adapters/observability/cloudwatch.d.ts +20 -0
- package/dist/types/adapters/observability/cloudwatch.d.ts.map +1 -1
- package/dist/types/adapters/observability/xray.d.ts +18 -0
- package/dist/types/adapters/observability/xray.d.ts.map +1 -1
- package/dist/types/adapters/security/agentcore.d.ts +81 -107
- package/dist/types/adapters/security/agentcore.d.ts.map +1 -1
- package/dist/types/bridge/eventMeta.d.ts +3 -0
- package/dist/types/bridge/eventMeta.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +16 -0
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/doors/security.d.ts +3 -2
- package/dist/types/doors/security.d.ts.map +1 -1
- package/dist/types/events/dispatcher.d.ts +1 -1
- package/dist/types/events/dispatcher.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +23 -1
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/types.d.ts +17 -0
- package/dist/types/events/types.d.ts.map +1 -1
- package/dist/types/hosting/standingAgent.d.ts.map +1 -1
- package/dist/types/memory/define.d.ts +2 -1
- package/dist/types/memory/define.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +30 -4
- package/dist/types/memory/define.types.d.ts.map +1 -1
- package/dist/types/memory/index.d.ts +1 -0
- package/dist/types/memory/index.d.ts.map +1 -1
- package/dist/types/memory/pipeline/default.d.ts +16 -0
- package/dist/types/memory/pipeline/default.d.ts.map +1 -1
- package/dist/types/memory/stages/filterByDecay.d.ts +68 -0
- package/dist/types/memory/stages/filterByDecay.d.ts.map +1 -0
- package/dist/types/memory/stages/index.d.ts +2 -0
- package/dist/types/memory/stages/index.d.ts.map +1 -1
- package/dist/types/memory/strategies.d.ts +108 -0
- package/dist/types/memory/strategies.d.ts.map +1 -0
- package/dist/types/recorders/core/CredentialRecorder.d.ts +31 -0
- package/dist/types/recorders/core/CredentialRecorder.d.ts.map +1 -0
- package/dist/types/security/index.d.ts +7 -3
- package/dist/types/security/index.d.ts.map +1 -1
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -545,7 +545,8 @@ One builder call mounts ONE skill that, when the user asks a why-question, unloc
|
|
|
545
545
|
| Remember last N turns of conversation | `defineMemory({ type: EPISODIC, strategy: WINDOW })` |
|
|
546
546
|
| Semantic recall via embeddings | `defineMemory({ type: SEMANTIC, strategy: TOP_K })` |
|
|
547
547
|
| Cross-run "why?" replay | `defineMemory({ type: CAUSAL, strategy: TOP_K })` ⭐ |
|
|
548
|
-
|
|
|
548
|
+
| Old memories should stop coming back | `defineMemory({ type: EPISODIC, strategy: DECAY, halfLifeMs })` |
|
|
549
|
+
| Long conversation overflows context | `.compaction({ summarizer, model })` on the Agent (memory's `SUMMARIZE` does not compress yet — `listMemoryStrategies()` says so) |
|
|
549
550
|
| Retrieve from a document corpus | `defineRAG({ store, embedder, topK, threshold })` |
|
|
550
551
|
| Use tools from an external MCP server | `mcpClient({ transport, ... })` + `agent.tools(await c.tools())` |
|
|
551
552
|
|
package/CLAUDE.md
CHANGED
|
@@ -37,7 +37,7 @@ Traps: `src/observability/` holds the finder IMPLEMENTATIONS (canonical home; `d
|
|
|
37
37
|
- **ToolProvider** (per-iteration visibility): `list(ctx): Tool[]` (tool-providers/types.ts:121); max ONE per agent (AgentBuilder.ts:238 throws on second); combinators staticTools/gatedTools/skillScopedTools chain decorator-style.
|
|
38
38
|
- **LLM provider**: `LLMProvider = {name, complete, stream?}` (adapters/types.ts:230) passed as `AgentOptions.provider`. `provider.name` keys THREE auto-resolutions: cache strategy (cache/strategyRegistry.ts:40), thinking handler (thinking/registry.ts:43), Lens labels.
|
|
39
39
|
- **Recorder, 3 layers**: (1) raw footprintjs CombinedRecorder via `agent.attach()` (RunnerBase.ts:474 — NOT idempotent); (2) typed stream `agent.on(type|'*')`; (3) new built-in = factory taking `{dispatcher, getRunContext}`, registered in the attach block inside `Agent.run()` (Agent.ts:807-845), barreled in src/observe.ts.
|
|
40
|
-
- **New typed event (3-step)**: payload interface in events/payloads.ts + entry in `AgentfootprintEventMap` (registry.ts:198) + append to `ALL_EVENT_TYPES` (registry.ts:488, count-asserted by tests). New DOMAIN also needs a bridge attach in Agent.createExecutor or emits never reach the dispatcher — AND a hand-edit to `DomainWildcard` (dispatcher.ts:67-
|
|
40
|
+
- **New typed event (3-step)**: payload interface in events/payloads.ts + entry in `AgentfootprintEventMap` (registry.ts:198) + append to `ALL_EVENT_TYPES` (registry.ts:488, count-asserted by tests). New DOMAIN also needs a bridge attach in Agent.createExecutor or emits never reach the dispatcher — AND a hand-edit to `DomainWildcard` (dispatcher.ts:67-90; still missing validation/reliability). **9.4.0 worked example of BOTH halves missing at once**: `credential.*` had payloads, registry entries and live emit sites since 6.11.0 with no bridge and no wildcard, so `agent.on('agentfootprint.credential.failed')` observed nothing for eight minors — the silence in which an identity adapter failed 100% of its calls. Fixed by `credentialRecorder` (recorders/core/CredentialRecorder.ts) + the wildcard arm.
|
|
41
41
|
- **Strategy (vendor sink)**: shapes in strategies/types.ts (Observability :130, Cost :169, LiveStatus :201, Lens :234); attach via `agent.enable.*` or `registerObservabilityStrategy` (strategies/registry.ts). New vendor = export from observability-providers.ts, NOT a new subpath.
|
|
42
42
|
- **Memory store**: implement `MemoryStore` (memory/store/types.ts:113; `search?` REQUIRED for causal memory); pass to `defineMemory({store})`. Memory TYPE/STRATEGY unions are CLOSED (define.types.ts:57/74 — new one edits defineMemory dispatch + a pipeline builder).
|
|
43
43
|
- **Document loader** (8.10.0): implement `DocumentLoader` (rag/types.ts) — `{name, extensions, load}`. `loadDocuments` routes by extension, caller-supplied loaders FIRST, so overriding a built-in is passing yours ahead of it rather than editing `DEFAULT_LOADERS`. A loader MUST NOT rewrite text after offsets are conceivable: the HTML stripper replaces tags with EQUAL-LENGTH whitespace for exactly this reason.
|
|
@@ -68,6 +68,8 @@ Traps: `src/observability/` holds the finder IMPLEMENTATIONS (canonical home; `d
|
|
|
68
68
|
- **The cursor resolver reports its own winning clause** (8.5.0) → `makeResolveCursor` returns `CursorMove {from,to,by}` and `graph.nextSkill` is its `.to` PROJECTION — never a second implementation. `graph.explainNextSkill` → Agent → `InjectionEngineConfig.explainNextSkill` → the Evaluate stage takes the cursor from `.to` (one consultation) and stamps `cursorMove` on `context.evaluated` → `routeRecorder` reads `.by`. Adding a `by` value means touching `CursorMoveCause`, `RouteOutcome`, `causeOf`'s switch and `formatRouteHop`'s switch (the last two are exhaustive, so the compiler flags them). `routing[]` is per-SKILL BUILD-TIME provenance and is NOT the hop cause — conflating them is the 8.5.0 bug.
|
|
69
69
|
- **Chart shape** (stage order/loop target) → trajectory.ts loop-head bucketing, selfExplain, FlowchartRecorder/RunStepRecorder step synthesis, milestoneFor, the `maxIterations * 2 + 10` engine headroom (Agent.ts:634).
|
|
70
70
|
- **RunnerBase** → all six runners + enable.* strategies + Agent's crash-checkpoint tracker (subscribes to its own dispatcher, Agent.ts:729-752).
|
|
71
|
+
- **Any AWS adapter** (9.4.0) → `test/adapters/aws/awsCommandPin.ts` is THE registry of the SDK command constructors each one dispatches, and its completeness test fails the build for any `src/**` file that LOADS an `@aws-sdk/*` package without a row. Adding/renaming a dispatched command = edit the row. The rule the registry exists to enforce: a bare `@aws-sdk/client-*` **Client is command-based** (`send`/`destroy` only) — per-operation METHOD shortcuts live on the aggregated client (`BedrockAgentCore`), so `client.someOperation(...)` is always wrong here. Three adapters shipped violating this (6.42.0 wrong-service commands, 9.4.0 `EvaluatePolicyCommand` which does not exist, 9.4.0 `agentCoreIdentity`'s method call). Every AWS adapter now has an `_sdk` seam for exactly this test; the AWS SDKs are deliberately NOT devDependencies (six adapters prove their missing-peer-dep refusals by real absence), so the real-module half runs only where they are installed.
|
|
72
|
+
- **`EventMeta`** → shape is copied in THREE places in lockstep: `events/types.ts` (the type), `bridge/eventMeta.ts` `RunContext` + `buildEventMeta` (the builder), and the per-runner run-context literal (Agent.createExecutor, LLMCall). A field added to the type alone silently never appears. `sessionId` (9.4.0) rides the `AgentRunOptions` → `currentRunContext` path that `correlationId`/`traceId` already use, and `standingAgent` is the only shipped caller that knows one.
|
|
71
73
|
|
|
72
74
|
## End-to-end trace (agent.run; 1 tool call then final answer; default reactMode 'dynamic')
|
|
73
75
|
build (once): Agent.create → AgentBuilder.build → Agent ctor → initChart(buildChart) (Agent.ts:429; RunnerBase throws on re-init :256) → buildAgentChart assembles: seed → sf-injection-engine → Context selector (`failFast: true`, selects the 3 slot subflows in parallel) → sf-cache → call-llm → route decider → branches tool-calls (pausable, `{loopTo}`) / [output-retry (7.26, conditional mount, SAME `{loopTo}`)] / final (PrepareFinal → memory writes → BreakFinal `$break`, `propagateBreak: true`).
|
|
@@ -34,41 +34,107 @@
|
|
|
34
34
|
* tenant isolation derives from the workload identity itself (per-tenant
|
|
35
35
|
* workloads), or encode it via `userIdFor` (e.g. `${tenant}:${principal}`).
|
|
36
36
|
*
|
|
37
|
+
* ── How this talks to the SDK (9.4.0 — read this before editing) ────────────
|
|
38
|
+
* Through **`client.send(new SomeCommand(input))`**, never through a method on
|
|
39
|
+
* the client. A bare `@aws-sdk/client-*` **Client** is command-based: its
|
|
40
|
+
* prototype carries `send` and `destroy` and NOTHING ELSE. The per-operation
|
|
41
|
+
* shortcuts (`getResourceOauth2Token(...)`) live on the AGGREGATED client
|
|
42
|
+
* (`BedrockAgentCore`), which is a different class.
|
|
43
|
+
*
|
|
44
|
+
* Until 9.4.0 this adapter built a `BedrockAgentCoreClient` and then duck-typed
|
|
45
|
+
* `client.getResourceOauth2Token` — a method that is never there — so the
|
|
46
|
+
* documented path failed 100% of the time on the very first call, with a
|
|
47
|
+
* message blaming the SDK version. Every test injected `_client` and so never
|
|
48
|
+
* touched the shim. The sibling memory adapter in this same package had the
|
|
49
|
+
* command form right all along; this one now matches it, and
|
|
50
|
+
* `test/adapters/aws/aws-command-pin.test.ts` pins the command names for both.
|
|
51
|
+
*
|
|
37
52
|
* Pattern: Adapter (GoF) + lazy peer-dep load — the AWS SDK is required only when
|
|
38
|
-
* `getCredential` first runs (or never, if you inject `_client`).
|
|
39
|
-
* the SDK command/field names against your installed
|
|
40
|
-
* `@aws-sdk/client-bedrock-agentcore` version — this adapter targets the
|
|
41
|
-
* `GetResourceOauth2Token` shape and is structured so the request→result mapping
|
|
42
|
-
* is unit-tested via the `_client` seam independent of the SDK.
|
|
53
|
+
* `getCredential` first runs (or never, if you inject `_client` / `_sdk`).
|
|
43
54
|
*/
|
|
44
55
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
56
|
exports.agentCoreIdentity = void 0;
|
|
46
57
|
const lazyRequire_js_1 = require("../../lib/lazyRequire.js");
|
|
47
58
|
const kinds_js_1 = require("../../identity/kinds.js");
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Map {@link AgentCoreIdentityClientLike} onto the real SDK commands.
|
|
61
|
+
*
|
|
62
|
+
* Two things this function owns, and nothing else does:
|
|
63
|
+
* 1. **The command form.** `send(new Command(input))` — see the module header
|
|
64
|
+
* for why a method on the Client is not an option.
|
|
65
|
+
* 2. **The wire field names.** `GetResourceOauth2Token` answers with
|
|
66
|
+
* `sessionUri`, not `sessionId`, and never reports an expiry. Reading
|
|
67
|
+
* `sessionId` off the response (as this adapter did through 9.3.0) yields
|
|
68
|
+
* `undefined` forever, which arrived at the consumer as an empty
|
|
69
|
+
* `sessionId` on every consent round-trip. An injected `_client` is
|
|
70
|
+
* somebody else's mapping and is left alone.
|
|
71
|
+
*/
|
|
72
|
+
function createIdentityClient(options) {
|
|
73
|
+
let mod;
|
|
74
|
+
if (options._sdk) {
|
|
75
|
+
mod = options._sdk;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
try {
|
|
79
|
+
// Lazy peer-dep: only loaded when no _client/_sdk is injected and getCredential runs.
|
|
80
|
+
mod = (0, lazyRequire_js_1.lazyRequire)('@aws-sdk/client-bedrock-agentcore');
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
throw new Error('agentCoreIdentity requires the `@aws-sdk/client-bedrock-agentcore` peer dependency.\n' +
|
|
84
|
+
' Install: npm install @aws-sdk/client-bedrock-agentcore\n' +
|
|
85
|
+
' Or pass `_client` for a pre-built or mock client.');
|
|
86
|
+
}
|
|
57
87
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
'@aws-sdk/client-bedrock-agentcore version, or pass `_client`.');
|
|
88
|
+
if (!mod.BedrockAgentCoreClient) {
|
|
89
|
+
throw new Error('agentCoreIdentity: `@aws-sdk/client-bedrock-agentcore` is installed but ' +
|
|
90
|
+
'`BedrockAgentCoreClient` was not found. Update the SDK.');
|
|
62
91
|
}
|
|
92
|
+
const sdk = new mod.BedrockAgentCoreClient({ ...(options.region && { region: options.region }) });
|
|
93
|
+
const send = async (Ctor, name, input) => {
|
|
94
|
+
if (!Ctor) {
|
|
95
|
+
throw new Error(`agentCoreIdentity: \`@aws-sdk/client-bedrock-agentcore\` is missing ${name}. ` +
|
|
96
|
+
'Upgrade the SDK, or pass `_client` with your own mapping.');
|
|
97
|
+
}
|
|
98
|
+
return sdk.send(new Ctor(input));
|
|
99
|
+
};
|
|
63
100
|
return {
|
|
64
|
-
getResourceOauth2Token
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
101
|
+
async getResourceOauth2Token(input) {
|
|
102
|
+
if (!input.workloadIdentityToken) {
|
|
103
|
+
// `workloadIdentityToken` is REQUIRED on GetResourceOauth2TokenRequest.
|
|
104
|
+
// Sending the call without one buys an opaque ValidationException from
|
|
105
|
+
// AWS; saying so here names the two ways to supply it instead.
|
|
106
|
+
throw new Error('agentCoreIdentity: GetResourceOauth2Token requires a workload identity token, and ' +
|
|
107
|
+
'none was available for this request.\n' +
|
|
108
|
+
' Inside AgentCore Runtime the container is given one — read it and pass it as ' +
|
|
109
|
+
'`workloadIdentityToken`.\n' +
|
|
110
|
+
' Elsewhere, configure `workloadName` so a per-user token is resolved via ' +
|
|
111
|
+
'GetWorkloadAccessTokenForUserId, or pass `workloadIdentityToken` yourself.');
|
|
112
|
+
}
|
|
113
|
+
const r = (await send(mod.GetResourceOauth2TokenCommand, 'GetResourceOauth2TokenCommand', input));
|
|
114
|
+
return {
|
|
115
|
+
...(r?.accessToken !== undefined && { accessToken: r.accessToken }),
|
|
116
|
+
...(r?.authorizationUrl !== undefined && { authorizationUrl: r.authorizationUrl }),
|
|
117
|
+
// The service's correlation handle for a 3LO round-trip is `sessionUri`.
|
|
118
|
+
...(r?.sessionUri !== undefined && { sessionId: r.sessionUri }),
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
async getWorkloadAccessTokenForUserId(input) {
|
|
122
|
+
const r = (await send(mod.GetWorkloadAccessTokenForUserIdCommand, 'GetWorkloadAccessTokenForUserIdCommand', input));
|
|
123
|
+
return {
|
|
124
|
+
...(r?.workloadAccessToken !== undefined && {
|
|
125
|
+
workloadAccessToken: r.workloadAccessToken,
|
|
126
|
+
}),
|
|
127
|
+
};
|
|
128
|
+
},
|
|
70
129
|
};
|
|
71
130
|
}
|
|
131
|
+
function resolveClient(options) {
|
|
132
|
+
// An injected client is used as-is — that seam is how a custom integration
|
|
133
|
+
// (or a test double) replaces the whole mapping.
|
|
134
|
+
if (options._client)
|
|
135
|
+
return options._client;
|
|
136
|
+
return createIdentityClient(options);
|
|
137
|
+
}
|
|
72
138
|
const defaultUserIdFor = (identity) => identity.principal;
|
|
73
139
|
/** Build a {@link CredentialProvider} backed by AWS Bedrock AgentCore Identity. */
|
|
74
140
|
function agentCoreIdentity(options = {}) {
|
|
@@ -88,9 +154,11 @@ function agentCoreIdentity(options = {}) {
|
|
|
88
154
|
const c = getClient();
|
|
89
155
|
if (typeof c.getWorkloadAccessTokenForUserId !== 'function') {
|
|
90
156
|
// Explicit config must not silently degrade to workload-level tokens.
|
|
157
|
+
// The SDK-backed client always implements this, so reaching here means an
|
|
158
|
+
// injected `_client` that does not.
|
|
91
159
|
throw new Error('agentCoreIdentity: `workloadName` is configured for per-user workload scoping, ' +
|
|
92
|
-
'but the
|
|
93
|
-
'
|
|
160
|
+
'but the injected `_client` has no getWorkloadAccessTokenForUserId. Implement it, ' +
|
|
161
|
+
'or drop `workloadName` to vend with the static `workloadIdentityToken`.');
|
|
94
162
|
}
|
|
95
163
|
const res = await c.getWorkloadAccessTokenForUserId({
|
|
96
164
|
workloadName: options.workloadName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../src/adapters/identity/agentcore.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../src/adapters/identity/agentcore.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;;;AAEH,6DAAuD;AAMvD,sDAAiD;AA4EjD;;;;;;;;;;;;GAYG;AACH,SAAS,oBAAoB,CAAC,OAAiC;IAC7D,IAAI,GAAsC,CAAC;IAC3C,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,IAAI,CAAC;YACH,sFAAsF;YACtF,GAAG,GAAG,IAAA,4BAAW,EAAoC,mCAAmC,CAAC,CAAC;QAC5F,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CACb,uFAAuF;gBACrF,6DAA6D;gBAC7D,qDAAqD,CACxD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,0EAA0E;YACxE,yDAAyD,CAC5D,CAAC;IACJ,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,sBAAsB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAElG,MAAM,IA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,CAAC;YACD,IAAI,GAAG,CAAC,gBAAgB,EAAE,CAAC;gBACzB,OAAO;oBACL,MAAM,EAAE,wBAAwB;oBAChC,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;oBACtC,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,EAAE;iBAC/B,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,KAAK,CACb,kDAAkD,GAAG,CAAC,OAAO,qBAAqB;gBAChF,2CAA2C,CAC9C,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAzED,8CAyEC"}
|
|
@@ -185,21 +185,46 @@ class BedrockProvider {
|
|
|
185
185
|
exports.BedrockProvider = BedrockProvider;
|
|
186
186
|
// ─── Internals ──────────────────────────────────────────────────────
|
|
187
187
|
function resolveClient(options) {
|
|
188
|
-
|
|
188
|
+
let mod;
|
|
189
|
+
if (options._sdk) {
|
|
190
|
+
mod = options._sdk;
|
|
191
|
+
}
|
|
192
|
+
else if (options._client && options._commands) {
|
|
189
193
|
return { client: options._client, Commands: options._commands };
|
|
190
194
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
195
|
+
else {
|
|
196
|
+
try {
|
|
197
|
+
mod = (0, lazyRequire_js_1.lazyRequire)('@aws-sdk/client-bedrock-runtime');
|
|
198
|
+
}
|
|
199
|
+
catch {
|
|
200
|
+
throw new Error('BedrockProvider requires `@aws-sdk/client-bedrock-runtime`.\n' +
|
|
201
|
+
' Install: npm install @aws-sdk/client-bedrock-runtime\n' +
|
|
202
|
+
' Or pass `_client` + `_commands` for test injection.');
|
|
203
|
+
}
|
|
194
204
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
205
|
+
// Named one at a time so a missing one is reported BY NAME. `Converse` and
|
|
206
|
+
// `ConverseStream` are the two operations this provider has; an SDK missing
|
|
207
|
+
// either is a different problem to an SDK that is not installed.
|
|
208
|
+
for (const name of ['ConverseCommand', 'ConverseStreamCommand']) {
|
|
209
|
+
if (typeof mod[name] !== 'function') {
|
|
210
|
+
throw new Error(`BedrockProvider: \`@aws-sdk/client-bedrock-runtime\` is missing ${name}. ` +
|
|
211
|
+
'Upgrade the SDK, or pass `_client` + `_commands` with your own mapping.');
|
|
212
|
+
}
|
|
199
213
|
}
|
|
214
|
+
const client = options._client ??
|
|
215
|
+
(() => {
|
|
216
|
+
if (typeof mod.BedrockRuntimeClient !== 'function') {
|
|
217
|
+
throw new Error('BedrockProvider: `@aws-sdk/client-bedrock-runtime` is installed but ' +
|
|
218
|
+
'`BedrockRuntimeClient` was not found. Update the SDK.');
|
|
219
|
+
}
|
|
220
|
+
return new mod.BedrockRuntimeClient({ region: options.region });
|
|
221
|
+
})();
|
|
200
222
|
return {
|
|
201
|
-
client
|
|
223
|
+
client,
|
|
224
|
+
// Both checked by name directly above.
|
|
225
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
202
226
|
Commands: { Converse: mod.ConverseCommand, ConverseStream: mod.ConverseStreamCommand },
|
|
227
|
+
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
|
203
228
|
};
|
|
204
229
|
}
|
|
205
230
|
function buildInput(req, defaultModel, defaultMaxTokens) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BedrockProvider.js","sourceRoot":"","sources":["../../../src/adapters/llm/BedrockProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AAYH,6DAAuD;AAyHvD;;;;;;;;GAQG;AACH,MAAM,mBAAmB,GAAwB,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;AAEtF,SAAgB,OAAO,CAAC,UAAkC,EAAE;IAC1D,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACpD,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,2CAA2C,CAAC;IACzF,MAAM,gBAA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UAAU;YACb,OAAO,UAAU,CAAC;QACpB,KAAK,YAAY;YACf,OAAO,YAAY,CAAC;QACtB,KAAK,eAAe;YAClB,OAAO,eAAe,CAAC;QACzB,KAAK,sBAAsB,CAAC;QAC5B,KAAK,kBAAkB;YACrB,OAAO,gBAAgB,CAAC;QAC1B;YACE,OAAO,GAAG,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,GAAY;IAC7B,yEAAyE;IACzE,wEAAwE;IACxE,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,sBAAsB;QAAE,OAAO,GAAG,CAAC;IAC5E,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,aAAa,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE;YAC1D,IAAI,EAAE,sBAAsB;YAC5B,KAAK,EAAE,GAAG;YACV,MAAM,EACH,GAAmD,CAAC,SAAS,EAAE,cAAc;gBAC7E,GAA2B,CAAC,MAAM;SACtC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,aAAa,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -69,6 +69,29 @@
|
|
|
69
69
|
* Only `ns` (the identity namespace) and `tier` are ever filtered on, and both
|
|
70
70
|
* are short strings.
|
|
71
71
|
*
|
|
72
|
+
* ── The preflight: this store now READS the index before trusting it (9.4.0) ─
|
|
73
|
+
* One `GetIndex`, lazily on first use and memoized for the life of the store.
|
|
74
|
+
* It checks the three things this adapter used to assume — and that a
|
|
75
|
+
* production deployment got wrong in all three ways at once:
|
|
76
|
+
*
|
|
77
|
+
* 1. the distance metric really is cosine (a euclidean index scored a
|
|
78
|
+
* self-query at 0.999…, where a true cosine is exactly 1.0);
|
|
79
|
+
* 2. `af` really is non-filterable, checked BEFORE the first write, so a
|
|
80
|
+
* misconfigured index fails at document 1 rather than at document 400
|
|
81
|
+
* with an AWS "Filterable metadata must have at most 2048 bytes";
|
|
82
|
+
* 3. the index dimension matches the vectors being written or searched.
|
|
83
|
+
*
|
|
84
|
+
* This is the discipline every sibling store already had at open —
|
|
85
|
+
* `sqliteVectorStore`'s schema identity, `pgVectorStore`'s schema check,
|
|
86
|
+
* `staticVectorStore`'s load-time fingerprint. This store had nothing to open,
|
|
87
|
+
* so it opened nothing.
|
|
88
|
+
*
|
|
89
|
+
* **IAM:** the caller now needs `s3vectors:GetIndex` alongside `PutVectors` /
|
|
90
|
+
* `QueryVectors` / `GetVectors` / `ListVectors` / `DeleteVectors`. A GetIndex
|
|
91
|
+
* that fails is refused by name, never passed through — an index this store
|
|
92
|
+
* cannot read is an index whose metric, layout and dimension it would be
|
|
93
|
+
* guessing at.
|
|
94
|
+
*
|
|
72
95
|
* ── Cosine only, said out loud ──────────────────────────────────────────────
|
|
73
96
|
* The port's score is a cosine similarity, and every threshold in this library
|
|
74
97
|
* — starting with `defineRAG`'s 0.7 default — is calibrated on that range. A
|
|
@@ -94,10 +117,16 @@
|
|
|
94
117
|
* one is what survives a restart: the first query after an embedder swap
|
|
95
118
|
* sees documents stamped by the old embedder and refuses by name, instead
|
|
96
119
|
* of returning a confident ranking of two incompatible spaces.
|
|
97
|
-
* -
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
120
|
+
* - Since 9.4.0 the index's OWN dimension is checked too, at the preflight —
|
|
121
|
+
* so a wrong-size embedder is caught on the first write and the first
|
|
122
|
+
* search of a fresh process, which the per-process fingerprint could not do
|
|
123
|
+
* (it has nothing to disagree with at boot).
|
|
124
|
+
* - What is still NOT caught: the first write of a fresh process into a
|
|
125
|
+
* namespace built by a different embedder OF THE SAME SIZE. Only the model
|
|
126
|
+
* id separates those, and it lives in the vectors rather than on the index.
|
|
127
|
+
* There is no cheap read that would catch it, and a full index scan on
|
|
128
|
+
* every boot is not one either. It is caught at the next search, before a
|
|
129
|
+
* single wrong answer is returned.
|
|
101
130
|
*
|
|
102
131
|
* ── Lazy peer dependency ────────────────────────────────────────────────────
|
|
103
132
|
* `@aws-sdk/client-s3vectors` is an OPTIONAL peer dependency, required at
|
|
@@ -186,6 +215,7 @@ function s3VectorsStore(options) {
|
|
|
186
215
|
const sdk = options._sdk;
|
|
187
216
|
connection = {
|
|
188
217
|
client: options._client,
|
|
218
|
+
GetIndex: sdk?.GetIndexCommand ?? shimCommand('GetIndex'),
|
|
189
219
|
Put: sdk?.PutVectorsCommand ?? shimCommand('PutVectors'),
|
|
190
220
|
Query: sdk?.QueryVectorsCommand ?? shimCommand('QueryVectors'),
|
|
191
221
|
Get: sdk?.GetVectorsCommand ?? shimCommand('GetVectors'),
|
|
@@ -197,6 +227,7 @@ function s3VectorsStore(options) {
|
|
|
197
227
|
}
|
|
198
228
|
const sdk = options._sdk ?? loadS3VectorsSdk();
|
|
199
229
|
const missing = [
|
|
230
|
+
'GetIndexCommand',
|
|
200
231
|
'PutVectorsCommand',
|
|
201
232
|
'QueryVectorsCommand',
|
|
202
233
|
'GetVectorsCommand',
|
|
@@ -217,8 +248,9 @@ function s3VectorsStore(options) {
|
|
|
217
248
|
// Checked directly above.
|
|
218
249
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
219
250
|
new sdk.S3VectorsClient({ ...(options.region && { region: options.region }) }),
|
|
220
|
-
// All
|
|
251
|
+
// All six checked directly above.
|
|
221
252
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
253
|
+
GetIndex: sdk.GetIndexCommand,
|
|
222
254
|
Put: sdk.PutVectorsCommand,
|
|
223
255
|
Query: sdk.QueryVectorsCommand,
|
|
224
256
|
Get: sdk.GetVectorsCommand,
|
|
@@ -229,12 +261,120 @@ function s3VectorsStore(options) {
|
|
|
229
261
|
};
|
|
230
262
|
return connection;
|
|
231
263
|
};
|
|
232
|
-
|
|
264
|
+
/** Send one command. Used by the preflight itself, so it does NOT preflight. */
|
|
265
|
+
const rawCall = async (build, signal) => {
|
|
233
266
|
const conn = connect();
|
|
234
267
|
const command = build(conn);
|
|
235
268
|
return signal ? conn.client.send(command, { abortSignal: signal }) : conn.client.send(command);
|
|
236
269
|
};
|
|
270
|
+
/** Send one command, after the index has been verified once. */
|
|
271
|
+
const call = async (build, signal) => {
|
|
272
|
+
await verifyIndex(signal);
|
|
273
|
+
return rawCall(build, signal);
|
|
274
|
+
};
|
|
237
275
|
const scope = { vectorBucketName: bucket, indexName: index };
|
|
276
|
+
let verification;
|
|
277
|
+
const readIndex = async (signal) => {
|
|
278
|
+
let raw;
|
|
279
|
+
try {
|
|
280
|
+
raw = await rawCall((c) => new c.GetIndex({ ...scope }), signal);
|
|
281
|
+
}
|
|
282
|
+
catch (err) {
|
|
283
|
+
// Never a silent pass-through: an index this store cannot READ is an
|
|
284
|
+
// index whose metric, layout and dimension it is guessing at, and it
|
|
285
|
+
// guessed wrong three times in the field.
|
|
286
|
+
throw new Error(`s3VectorsStore: could not read the index '${bucket}/${index}' to verify it.\n` +
|
|
287
|
+
` ${err instanceof Error ? err.message : String(err)}\n` +
|
|
288
|
+
` This store reads the index ONCE before its first call, to check the distance ` +
|
|
289
|
+
`metric, the metadata layout and the dimension — three things it used to assume, ` +
|
|
290
|
+
`and that a production deployment got wrong in all three ways at once.\n` +
|
|
291
|
+
` Check: the index exists in this region; the caller has the \`s3vectors:GetIndex\` ` +
|
|
292
|
+
`permission (PutVectors/QueryVectors alone are not enough since 9.4.0); the bucket ` +
|
|
293
|
+
`and index names are right.`);
|
|
294
|
+
}
|
|
295
|
+
const info = raw?.index ?? {};
|
|
296
|
+
const metadata = info['metadataConfiguration'];
|
|
297
|
+
const keys = Array.isArray(metadata?.nonFilterableMetadataKeys)
|
|
298
|
+
? (metadata?.nonFilterableMetadataKeys).map(String)
|
|
299
|
+
: [];
|
|
300
|
+
return {
|
|
301
|
+
...(typeof info['distanceMetric'] === 'string' && {
|
|
302
|
+
distanceMetric: info['distanceMetric'],
|
|
303
|
+
}),
|
|
304
|
+
...(typeof info['dimension'] === 'number' && { dimension: info['dimension'] }),
|
|
305
|
+
nonFilterableMetadataKeys: keys,
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Read the index once and refuse anything this store cannot serve honestly.
|
|
310
|
+
*
|
|
311
|
+
* Memoized on the PROMISE, so concurrent first calls share one GetIndex and
|
|
312
|
+
* one verdict. A refusal is memoized too — re-asking a broken index on every
|
|
313
|
+
* operation would turn one clear failure into a storm of them.
|
|
314
|
+
*/
|
|
315
|
+
const verifyIndex = async (signal) => {
|
|
316
|
+
verification ??= readIndex(signal).then((found) => {
|
|
317
|
+
// (1) The metric. `options.distanceMetric` was a declaration; this is the
|
|
318
|
+
// index. A declaration that disagrees with the index is worse than none,
|
|
319
|
+
// so the message says which said what.
|
|
320
|
+
if (found.distanceMetric !== undefined && found.distanceMetric.toLowerCase() !== 'cosine') {
|
|
321
|
+
throw new TypeError(`s3VectorsStore: the index '${bucket}/${index}' was created with distance metric ` +
|
|
322
|
+
`'${found.distanceMetric}', and this store reports COSINE similarity.\n` +
|
|
323
|
+
(options.distanceMetric !== undefined
|
|
324
|
+
? ` You declared '${options.distanceMetric}'. The index disagrees, and the index ` +
|
|
325
|
+
`is the one that ranks.\n`
|
|
326
|
+
: '') +
|
|
327
|
+
` A cosine distance converts exactly (score = 1 - distance). A euclidean one does ` +
|
|
328
|
+
`not: mapped into [-1, 1] it produces a number that READS like a cosine and is ` +
|
|
329
|
+
`not one — a self-query scores 0.999… where a real cosine is exactly 1.0, which ` +
|
|
330
|
+
`no threshold (starting with defineRAG's 0.7 default) can separate from a real ` +
|
|
331
|
+
`score.\n` +
|
|
332
|
+
` Fix: recreate the index with --distance-metric cosine, or rank euclidean ` +
|
|
333
|
+
`results in your own adapter where the units are yours to interpret.`);
|
|
334
|
+
}
|
|
335
|
+
return found;
|
|
336
|
+
});
|
|
337
|
+
return verification;
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* (2) The metadata layout, checked before the first byte is written.
|
|
341
|
+
*
|
|
342
|
+
* Separate from the metric because the failure it prevents is a WRITE
|
|
343
|
+
* failure: with `af` filterable, short entries go in and longer ones are
|
|
344
|
+
* refused by the service partway through an import — a corpus that is 60%
|
|
345
|
+
* indexed and reports success for the part that fit.
|
|
346
|
+
*/
|
|
347
|
+
const assertWritableLayout = (found) => {
|
|
348
|
+
if (found.nonFilterableMetadataKeys.includes(PAYLOAD_KEY))
|
|
349
|
+
return;
|
|
350
|
+
throw new TypeError(`s3VectorsStore: the index '${bucket}/${index}' does not declare '${PAYLOAD_KEY}' as ` +
|
|
351
|
+
`non-filterable metadata, so this store cannot write to it.\n` +
|
|
352
|
+
` It stores each entry — the passage the model will read, its provenance, its ` +
|
|
353
|
+
`timestamps — as JSON under the metadata key '${PAYLOAD_KEY}'. Filterable metadata ` +
|
|
354
|
+
`has a small per-vector budget (2048 bytes); non-filterable has the large one. ` +
|
|
355
|
+
`Without this, an import writes the short chunks, then fails on a longer one with ` +
|
|
356
|
+
`"Filterable metadata must have at most 2048 bytes" — partway through, having ` +
|
|
357
|
+
`already reported success for everything before it.\n` +
|
|
358
|
+
` The index declares: ${found.nonFilterableMetadataKeys.length === 0
|
|
359
|
+
? '(no non-filterable keys)'
|
|
360
|
+
: found.nonFilterableMetadataKeys.join(', ')}\n` +
|
|
361
|
+
` Fix: recreate the index with\n` +
|
|
362
|
+
` --metadata-configuration '{"nonFilterableMetadataKeys":["${PAYLOAD_KEY}"]}'\n` +
|
|
363
|
+
` This cannot be changed after creation, so the index has to be rebuilt.`);
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* (3) The dimension, against the embedder that is actually being used.
|
|
367
|
+
*
|
|
368
|
+
* Same rule `sqliteVectorStore` applies and for the same reason: DIMENSIONS
|
|
369
|
+
* ALWAYS DECIDE. The service would reject the vector anyway — one write at a
|
|
370
|
+
* time, saying nothing about which embedder is wrong — where this names both
|
|
371
|
+
* numbers and the two ways out.
|
|
372
|
+
*/
|
|
373
|
+
const assertDimension = (found, dims, operation) => {
|
|
374
|
+
if (found.dimension === undefined || found.dimension === dims)
|
|
375
|
+
return;
|
|
376
|
+
throw new embedderMismatch_js_1.EmbedderMismatchError(`${bucket}/${index}`, `the index@${found.dimension}`, `this embedder@${dims}`, 'dimensions', operation, 'point this store at an index whose dimension matches this embedder');
|
|
377
|
+
};
|
|
238
378
|
/** Fingerprints this process has seen, one per namespace. */
|
|
239
379
|
const fingerprints = new Map();
|
|
240
380
|
let closed = false;
|
|
@@ -301,6 +441,13 @@ function s3VectorsStore(options) {
|
|
|
301
441
|
if (entries.length === 0)
|
|
302
442
|
return;
|
|
303
443
|
const ns = (0, index_js_1.identityNamespace)(identity);
|
|
444
|
+
// Before a byte: the index really is cosine, and it really has room for a
|
|
445
|
+
// passage. Memoized, so this is one GetIndex for the life of the store —
|
|
446
|
+
// and it happens HERE rather than inside `call` below, because a layout
|
|
447
|
+
// that cannot hold an entry must stop the import at document 1, not at
|
|
448
|
+
// document 400 with 399 already written.
|
|
449
|
+
const found = await verifyIndex();
|
|
450
|
+
assertWritableLayout(found);
|
|
304
451
|
const vectors = entries.map((entry) => {
|
|
305
452
|
const embedding = entry.embedding;
|
|
306
453
|
if (!embedding || embedding.length === 0) {
|
|
@@ -315,6 +462,7 @@ function s3VectorsStore(options) {
|
|
|
315
462
|
...(entry.embeddingModel !== undefined && { id: entry.embeddingModel }),
|
|
316
463
|
dims: embedding.length,
|
|
317
464
|
};
|
|
465
|
+
assertDimension(found, embedding.length, 'write to');
|
|
318
466
|
reconcile(ns, fp, 'write to');
|
|
319
467
|
return {
|
|
320
468
|
key: vectorKey(ns, entry.id),
|
|
@@ -437,6 +585,10 @@ function s3VectorsStore(options) {
|
|
|
437
585
|
const k = Math.max(1, Math.floor(searchOptions?.k ?? 10));
|
|
438
586
|
if (query.length === 0)
|
|
439
587
|
return [];
|
|
588
|
+
// The index's own dimension, which outranks anything this process has
|
|
589
|
+
// merely SEEN: a fresh process searching an index built for another
|
|
590
|
+
// embedder has no stored fingerprint to disagree with.
|
|
591
|
+
assertDimension(await verifyIndex(), query.length, 'search');
|
|
440
592
|
// Refused BEFORE the call, against what this process has seen — and
|
|
441
593
|
// again below, against what actually comes back.
|
|
442
594
|
reconcile(ns, {
|