agentfootprint 9.1.0 → 9.3.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/README.md +15 -0
- package/dist/adapters/memory/pgVector.js +731 -0
- package/dist/adapters/memory/pgVector.js.map +1 -0
- package/dist/adapters/memory/s3Vectors.js +628 -0
- package/dist/adapters/memory/s3Vectors.js.map +1 -0
- package/dist/adapters/memory/sqliteVector.js +16 -79
- package/dist/adapters/memory/sqliteVector.js.map +1 -1
- package/dist/core/Agent.js +344 -18
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/LLMCall.js +17 -0
- package/dist/core/LLMCall.js.map +1 -1
- package/dist/core/RunnerBase.js +22 -6
- package/dist/core/RunnerBase.js.map +1 -1
- package/dist/core/agent/AgentBuilder.js +20 -0
- package/dist/core/agent/AgentBuilder.js.map +1 -1
- package/dist/core/conversation.js +139 -0
- package/dist/core/conversation.js.map +1 -0
- package/dist/core/runCheckpoint.js +60 -2
- package/dist/core/runCheckpoint.js.map +1 -1
- package/dist/embedders/index.js +240 -76
- package/dist/embedders/index.js.map +1 -1
- package/dist/esm/adapters/memory/pgVector.d.ts +243 -0
- package/dist/esm/adapters/memory/pgVector.js +726 -0
- package/dist/esm/adapters/memory/pgVector.js.map +1 -0
- package/dist/esm/adapters/memory/s3Vectors.d.ts +208 -0
- package/dist/esm/adapters/memory/s3Vectors.js +624 -0
- package/dist/esm/adapters/memory/s3Vectors.js.map +1 -0
- package/dist/esm/adapters/memory/sqliteVector.d.ts +5 -27
- package/dist/esm/adapters/memory/sqliteVector.js +10 -73
- package/dist/esm/adapters/memory/sqliteVector.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +218 -3
- package/dist/esm/core/Agent.js +345 -19
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/LLMCall.d.ts +9 -0
- package/dist/esm/core/LLMCall.js +17 -0
- package/dist/esm/core/LLMCall.js.map +1 -1
- package/dist/esm/core/RunnerBase.d.ts +22 -6
- package/dist/esm/core/RunnerBase.js +22 -6
- package/dist/esm/core/RunnerBase.js.map +1 -1
- package/dist/esm/core/agent/AgentBuilder.d.ts +5 -0
- package/dist/esm/core/agent/AgentBuilder.js +20 -0
- package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +45 -3
- package/dist/esm/core/conversation.d.ts +96 -0
- package/dist/esm/core/conversation.js +133 -0
- package/dist/esm/core/conversation.js.map +1 -0
- package/dist/esm/core/runCheckpoint.d.ts +85 -1
- package/dist/esm/core/runCheckpoint.js +57 -1
- package/dist/esm/core/runCheckpoint.js.map +1 -1
- package/dist/esm/embedders/index.d.ts +99 -19
- package/dist/esm/embedders/index.js +240 -76
- package/dist/esm/embedders/index.js.map +1 -1
- package/dist/esm/hosting/standingAgent.d.ts +6 -2
- package/dist/esm/hosting/standingAgent.js +36 -27
- package/dist/esm/hosting/standingAgent.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/embedderMismatch.d.ts +67 -0
- package/dist/esm/lib/embedderMismatch.js +96 -0
- package/dist/esm/lib/embedderMismatch.js.map +1 -0
- package/dist/esm/lib/rag/defineRAG.d.ts +28 -6
- package/dist/esm/lib/rag/defineRAG.js +39 -5
- package/dist/esm/lib/rag/defineRAG.js.map +1 -1
- package/dist/esm/memory/define.js +31 -1
- package/dist/esm/memory/define.js.map +1 -1
- package/dist/esm/memory/define.types.d.ts +13 -2
- package/dist/esm/memory/define.types.js.map +1 -1
- package/dist/esm/memory/embedding/loadRelevant.d.ts +10 -2
- package/dist/esm/memory/embedding/loadRelevant.js +36 -18
- package/dist/esm/memory/embedding/loadRelevant.js.map +1 -1
- package/dist/esm/memory/pipeline/semantic.d.ts +13 -2
- package/dist/esm/memory/pipeline/semantic.js +11 -5
- package/dist/esm/memory/pipeline/semantic.js.map +1 -1
- package/dist/esm/memory/store/capability.d.ts +25 -6
- package/dist/esm/memory/store/capability.js +68 -3
- package/dist/esm/memory/store/capability.js.map +1 -1
- package/dist/esm/memory/store/index.d.ts +1 -0
- package/dist/esm/memory/store/index.js +4 -0
- package/dist/esm/memory/store/index.js.map +1 -1
- package/dist/esm/memory/store/types.d.ts +40 -0
- package/dist/esm/memory-providers.d.ts +7 -4
- package/dist/esm/memory-providers.js +18 -4
- package/dist/esm/memory-providers.js.map +1 -1
- package/dist/hosting/standingAgent.js +36 -27
- package/dist/hosting/standingAgent.js.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/embedderMismatch.js +103 -0
- package/dist/lib/embedderMismatch.js.map +1 -0
- package/dist/lib/rag/defineRAG.js +39 -5
- package/dist/lib/rag/defineRAG.js.map +1 -1
- package/dist/memory/define.js +31 -1
- package/dist/memory/define.js.map +1 -1
- package/dist/memory/define.types.js.map +1 -1
- package/dist/memory/embedding/loadRelevant.js +36 -18
- package/dist/memory/embedding/loadRelevant.js.map +1 -1
- package/dist/memory/pipeline/semantic.js +11 -5
- package/dist/memory/pipeline/semantic.js.map +1 -1
- package/dist/memory/store/capability.js +70 -4
- package/dist/memory/store/capability.js.map +1 -1
- package/dist/memory/store/index.js +7 -1
- package/dist/memory/store/index.js.map +1 -1
- package/dist/memory-providers.js +22 -5
- package/dist/memory-providers.js.map +1 -1
- package/dist/types/adapters/memory/pgVector.d.ts +244 -0
- package/dist/types/adapters/memory/pgVector.d.ts.map +1 -0
- package/dist/types/adapters/memory/s3Vectors.d.ts +209 -0
- package/dist/types/adapters/memory/s3Vectors.d.ts.map +1 -0
- package/dist/types/adapters/memory/sqliteVector.d.ts +5 -27
- package/dist/types/adapters/memory/sqliteVector.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +218 -3
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/LLMCall.d.ts +9 -0
- package/dist/types/core/LLMCall.d.ts.map +1 -1
- package/dist/types/core/RunnerBase.d.ts +22 -6
- package/dist/types/core/RunnerBase.d.ts.map +1 -1
- package/dist/types/core/agent/AgentBuilder.d.ts +5 -0
- package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +45 -3
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/conversation.d.ts +97 -0
- package/dist/types/core/conversation.d.ts.map +1 -0
- package/dist/types/core/runCheckpoint.d.ts +85 -1
- package/dist/types/core/runCheckpoint.d.ts.map +1 -1
- package/dist/types/embedders/index.d.ts +99 -19
- package/dist/types/embedders/index.d.ts.map +1 -1
- package/dist/types/hosting/standingAgent.d.ts +6 -2
- package/dist/types/hosting/standingAgent.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/embedderMismatch.d.ts +68 -0
- package/dist/types/lib/embedderMismatch.d.ts.map +1 -0
- package/dist/types/lib/rag/defineRAG.d.ts +28 -6
- package/dist/types/lib/rag/defineRAG.d.ts.map +1 -1
- package/dist/types/memory/define.d.ts.map +1 -1
- package/dist/types/memory/define.types.d.ts +13 -2
- package/dist/types/memory/define.types.d.ts.map +1 -1
- package/dist/types/memory/embedding/loadRelevant.d.ts +10 -2
- package/dist/types/memory/embedding/loadRelevant.d.ts.map +1 -1
- package/dist/types/memory/pipeline/semantic.d.ts +13 -2
- package/dist/types/memory/pipeline/semantic.d.ts.map +1 -1
- package/dist/types/memory/store/capability.d.ts +25 -6
- package/dist/types/memory/store/capability.d.ts.map +1 -1
- package/dist/types/memory/store/index.d.ts +1 -0
- package/dist/types/memory/store/index.d.ts.map +1 -1
- package/dist/types/memory/store/types.d.ts +40 -0
- package/dist/types/memory/store/types.d.ts.map +1 -1
- package/dist/types/memory-providers.d.ts +7 -4
- package/dist/types/memory-providers.d.ts.map +1 -1
- package/package.json +9 -1
|
@@ -51,18 +51,25 @@ export declare abstract class RunnerBase<TIn = unknown, TOut = unknown> implemen
|
|
|
51
51
|
*/
|
|
52
52
|
private chart;
|
|
53
53
|
/**
|
|
54
|
-
* Returns the footprintjs snapshot from the most recent run
|
|
55
|
-
*
|
|
56
|
-
*
|
|
54
|
+
* Returns the footprintjs snapshot from the most recent run. The snapshot is
|
|
55
|
+
* the CANONICAL STRUCTURE: nodes, edges, executionTree, runtimeStageId,
|
|
56
|
+
* commitLog.
|
|
57
57
|
*
|
|
58
58
|
* Domain consumers (Lens, Trace, dashboards) read this for shape
|
|
59
59
|
* and join their own per-stage payload by `runtimeStageId`. They
|
|
60
60
|
* MUST NOT re-derive structure from typed events — that's the
|
|
61
61
|
* design footprintjs's CLAUDE.md Convention 1 explicitly forbids.
|
|
62
62
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
63
|
+
* `undefined` before the first `run()` has STARTED. After that it is the
|
|
64
|
+
* most recent run's snapshot, including across multi-turn reuse of the same
|
|
65
|
+
* runner instance.
|
|
66
|
+
*
|
|
67
|
+
* **Live during a run.** The executor is assigned at run start, so a caller
|
|
68
|
+
* reading this from inside a run — an event listener, a tool, a recorder —
|
|
69
|
+
* gets the IN-FLIGHT snapshot, partially filled, not the last completed one.
|
|
70
|
+
* {@link RunnerBase.getSnapshot} is the same value under the name that says
|
|
71
|
+
* so. Anything that must describe a FINISHED run has to capture at the
|
|
72
|
+
* terminal flush instead of polling this.
|
|
66
73
|
*/
|
|
67
74
|
getLastSnapshot(): ReturnType<FlowChartExecutor['getSnapshot']> | undefined;
|
|
68
75
|
/**
|
|
@@ -257,6 +264,15 @@ export declare abstract class RunnerBase<TIn = unknown, TOut = unknown> implemen
|
|
|
257
264
|
* duplicates won't double-fire — but the runner-side array still
|
|
258
265
|
* grows.) Attaching in a per-run loop without detaching is the classic
|
|
259
266
|
* server leak; attach once, or detach per-run.
|
|
267
|
+
*
|
|
268
|
+
* WHEN it starts observing: the NEXT run. Recorders are handed to the
|
|
269
|
+
* executor when the executor is built, at run start, so one attached WHILE
|
|
270
|
+
* a run is in flight sees nothing of that run and everything of the one
|
|
271
|
+
* after — it is not dropped, it is early. Between runs (or before the
|
|
272
|
+
* first) is the ordinary case and works exactly as it reads. Event
|
|
273
|
+
* listeners are the opposite: `on()` takes effect immediately, but only for
|
|
274
|
+
* events emitted after it, so a listener added mid-run sees the rest of
|
|
275
|
+
* that run and none of its beginning.
|
|
260
276
|
*/
|
|
261
277
|
attach(recorder: CombinedRecorder): Unsubscribe;
|
|
262
278
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RunnerBase.d.ts","sourceRoot":"","sources":["../../../src/core/RunnerBase.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,KAAK,EAAiB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEpE,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAGV,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAkBpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAI3D;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,8BAAsB,UAAU,CAAC,GAAG,GAAG,OAAO,EAAE,IAAI,GAAG,OAAO,CAAE,YAAW,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC;IAC1F,SAAS,CAAC,QAAQ,CAAC,UAAU,kBAAyB;IACtD,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,CAAM;IAE9D;;;;;OAKG;IACH,SAAS,CAAC,YAAY,EAA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,CAA4B;IAEpD;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAgC3B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,QAAQ,CAAC,OAAO,GAAE;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBxE,QAAQ,CAAC,MAAM,EAAE,eAAe,CAoC9B;IAIF;;;;;;;OAOG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAa1D;;;OAGG;IACH,SAAS,CAAC,WAAW,IAAI,SAAS;IAYlC;;;OAGG;IACH,SAAS,CAAC,eAAe,IAAI,SAAS,MAAM,EAAE;IAI9C;;;;OAIG;IACH,SAAS,CAAC,aAAa,IAAI,eAAe;CAG3C"}
|
|
@@ -32,6 +32,11 @@ import { type ActOptions } from './act.js';
|
|
|
32
32
|
export declare class AgentBuilder {
|
|
33
33
|
private readonly opts;
|
|
34
34
|
private systemPromptValue;
|
|
35
|
+
/** Whether `.system()` has been called. Separate from the VALUE, because
|
|
36
|
+
* `.system('')` is a legitimate call (an agent with no instructions) and
|
|
37
|
+
* `''` is also the default — only a flag can tell the two apart, and the
|
|
38
|
+
* refusal has to fire on the second call regardless of what was passed. */
|
|
39
|
+
private systemPromptSet;
|
|
35
40
|
/**
|
|
36
41
|
* Cache policy for the base system prompt. Set via the optional
|
|
37
42
|
* 2nd argument to `.system(text, { cache })`. Default `'always'` —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/AgentBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EAExB,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAGL,KAAK,qBAAqB,EAE3B,MAAM,sBAAs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MAAM,EAAE,iBAAiB,GAAG,IAAI;IAU5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI;IAUtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,QAAQ,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAiBxC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDG;IACH,cAAc,CAAC,GAAG,UAAU,EAAE,SAAS,cAAc,EAAE,GAAG,IAAI;IAM9D;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAqB5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuCG;IACH,iBAAiB,CAAC,GAAG,UAAU,EAAE,SAAS,iBAAiB,EAAE,GAAG,IAAI;IAMpE;mEAC+D;IAC/D,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,IAAI,GAAE,qBAA0B,GAAG,IAAI;IAQ/C,WAAW,CAAC,IAAI,GAAE,kBAAuB,GAAG,IAAI;IAmBhD;;;;;;;OAOG;IACH,OAAO,CAAC,wBAAwB;IAgEhC,KAAK,IAAI,KAAK;CAkJf"}
|
|
@@ -23,6 +23,7 @@ import type { FoldedSpan, WindowRecord } from './window/types.js';
|
|
|
23
23
|
import type { MessagesDelivery } from './delivery/types.js';
|
|
24
24
|
import type { MiddlewareDecision } from './middleware/types.js';
|
|
25
25
|
import type { OutputAttempt } from './outputEnforcement.js';
|
|
26
|
+
import type { AgentRunCheckpoint } from '../runCheckpoint.js';
|
|
26
27
|
/**
|
|
27
28
|
* Dials for the deferred observer queue (RFC-001) — only meaningful with
|
|
28
29
|
* `observerDelivery: 'deferred'` (passing them without it throws at
|
|
@@ -372,14 +373,55 @@ export type RunConfigFn = (ctx: RunConfigContext) => RunConfig | undefined;
|
|
|
372
373
|
export interface AgentInput {
|
|
373
374
|
readonly message: string;
|
|
374
375
|
/**
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
376
|
+
* WHO this run is for — the scoping tuple, not a session handle.
|
|
377
|
+
*
|
|
378
|
+
* Committed to `scope.runIdentity` at seed and read by five consumers:
|
|
379
|
+
* memory + RAG namespacing (`.memory()` / `.rag()` isolate reads and
|
|
380
|
+
* writes per tenant + principal + conversation), `PermissionChecker.check`,
|
|
381
|
+
* the `.toolMiddleware()` / `.messageMiddleware()` chains,
|
|
382
|
+
* `ToolProvider.list(ctx)`, and the credential provider. It does NOT reach
|
|
383
|
+
* `tool.execute` — `ToolExecutionContext` carries no identity field.
|
|
378
384
|
*
|
|
379
385
|
* Defaults to `{ conversationId: '<runId>' }` when omitted, so agents
|
|
380
386
|
* without memory work unchanged.
|
|
387
|
+
*
|
|
388
|
+
* **`conversationId` is a namespace key, not a conversation.** Passing the
|
|
389
|
+
* same `conversationId` to two `run()` calls does NOT continue the first
|
|
390
|
+
* one: `run()` is one turn and seeds `history` from this call's message
|
|
391
|
+
* alone. What continues a conversation is {@link AgentInput.continueFrom}
|
|
392
|
+
* (or `agent.followUp(message)`); what makes prior turns *recallable* under
|
|
393
|
+
* this key is a registered memory, and that recall arrives in the
|
|
394
|
+
* system-prompt slot as a `<memory>` block rather than as message turns.
|
|
381
395
|
*/
|
|
382
396
|
readonly identity?: MemoryIdentity;
|
|
397
|
+
/**
|
|
398
|
+
* The conversation this turn continues — an `AgentRunCheckpoint` from
|
|
399
|
+
* `agent.checkpoint()`, persisted anywhere and handed back here.
|
|
400
|
+
*
|
|
401
|
+
* This is THE conversation door, and the reason it has to be asked for:
|
|
402
|
+
* `run()` is **one turn**. Without `continueFrom` the run seeds its history
|
|
403
|
+
* from this call's `message` alone, so a second `run()` on the same agent
|
|
404
|
+
* starts a new conversation and the model will honestly say it has not
|
|
405
|
+
* spoken to you before.
|
|
406
|
+
*
|
|
407
|
+
* The stored history is restored, this call's `message` is appended to it as
|
|
408
|
+
* the next user turn, and the run proceeds. `identity` and the conversation's
|
|
409
|
+
* folded spans ride along from the checkpoint unless this call overrides
|
|
410
|
+
* them — a continued turn that silently re-namespaced its own memory would
|
|
411
|
+
* write turn two somewhere turn one cannot be read from.
|
|
412
|
+
*
|
|
413
|
+
* `agent.followUp(message)` is the same thing for the common case, reading
|
|
414
|
+
* the conversation off this agent's own last completed run.
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```ts
|
|
418
|
+
* await agent.run({ message: 'Book me a table for two.' });
|
|
419
|
+
* const conversation = agent.checkpoint(); // persist anywhere
|
|
420
|
+
* // …a restart later, on a fresh Agent:
|
|
421
|
+
* await agent.run({ message: 'Make it three.', continueFrom: conversation });
|
|
422
|
+
* ```
|
|
423
|
+
*/
|
|
424
|
+
readonly continueFrom?: AgentRunCheckpoint;
|
|
383
425
|
}
|
|
384
426
|
export type AgentOutput = string;
|
|
385
427
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,YAAY,EACb,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,KAAK,EAAE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;;0CAIsC;IACtC,cAAc,EAAE,SAAS,aAAa,EAAE,CAAC;IAGzC;;;;;;iFAM6E;IAC7E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sBAAsB,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACzD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;kEAC8D;IAC9D,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* conversation — the refusals that guard a runner's per-instance state.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: teaching refusal at a boundary (the shape `runInput` uses for a
|
|
5
|
+
* caller's message, applied to a caller's TIMING).
|
|
6
|
+
* Role: core/ layer. An `Agent` keeps the last run's executor, run context,
|
|
7
|
+
* answer and pause on ITSELF — that is what makes `checkpoint()`,
|
|
8
|
+
* `getLastSnapshot()` and `followUp()` possible at all. Those fields
|
|
9
|
+
* have exactly one owner at a time, and until 9.2.0 nothing said so.
|
|
10
|
+
* Emits: N/A — these fire before a run starts.
|
|
11
|
+
*
|
|
12
|
+
* ## Why these are refusals and not warnings
|
|
13
|
+
*
|
|
14
|
+
* Both shapes below used to SUCCEED, which is the entire problem. Two `run()`
|
|
15
|
+
* calls overlapping on one Agent both resolved with plausible answers, and the
|
|
16
|
+
* per-instance state afterwards belonged to whichever finished last: the
|
|
17
|
+
* conversation `checkpoint()` handed back was the other run's, the snapshot
|
|
18
|
+
* `getLastSnapshot()` served was the other run's, and every event carried the
|
|
19
|
+
* other run's meta. That is not concurrency, it is corruption — and nothing in
|
|
20
|
+
* the recording said so, because each run's own trace looked perfect.
|
|
21
|
+
*
|
|
22
|
+
* A message sent while a person still owes the agent an answer used to start a
|
|
23
|
+
* fresh run and silently abandon the pending question. A consent gate that can
|
|
24
|
+
* be walked around by sending another message is not a consent gate.
|
|
25
|
+
*
|
|
26
|
+
* Neither refusal is new policy. `standingAgent` has refused both since it
|
|
27
|
+
* existed (it serializes runs globally and calls that "a correctness
|
|
28
|
+
* requirement rather than a tuning choice", and answers a message that arrives
|
|
29
|
+
* mid-question with `AwaitingDecisionError`), and `recordedChat.send` refuses
|
|
30
|
+
* an overlapping turn in the same words. 9.2.0 moves the guarantee from the
|
|
31
|
+
* compositions down to the primitive, so it holds however you drive it.
|
|
32
|
+
*
|
|
33
|
+
* The names are deliberately NOT the hosting ones. `hosting/errors.ts` already
|
|
34
|
+
* owns `ConcurrentRunError` and `AwaitingDecisionError`, both of which carry a
|
|
35
|
+
* `sessionId` and speak about a session; core has no sessions, and two classes
|
|
36
|
+
* sharing one name across two doors is the duplicate-type hazard this codebase
|
|
37
|
+
* has fixed before.
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Thrown when `run()` / `resume()` is called on a runner that is already
|
|
41
|
+
* running.
|
|
42
|
+
*
|
|
43
|
+
* One instance answers one turn at a time. To run two turns at once, build two
|
|
44
|
+
* agents — a chart is built once per instance and instances are cheap — or put
|
|
45
|
+
* the turns behind `standingAgent({ onConcurrentInvoke: 'enqueue' })`, which
|
|
46
|
+
* queues them.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* // Refused: both would write the same instance's last-run state.
|
|
51
|
+
* await Promise.all([agent.run({ message: 'a' }), agent.run({ message: 'b' })]);
|
|
52
|
+
*
|
|
53
|
+
* // Fine: two instances, two sets of state.
|
|
54
|
+
* await Promise.all([agentA.run({ message: 'a' }), agentB.run({ message: 'b' })]);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare class RunInFlightError extends Error {
|
|
58
|
+
readonly code: "ERR_RUN_IN_FLIGHT";
|
|
59
|
+
/** The runner that is busy, by its configured id. */
|
|
60
|
+
readonly agentId: string;
|
|
61
|
+
/** The run already in flight, so a log line can be joined to its trace. */
|
|
62
|
+
readonly activeRunId: string;
|
|
63
|
+
constructor(door: string, agentId: string, activeRunId: string);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Thrown when a new message is sent to an agent whose last run PAUSED to ask a
|
|
67
|
+
* person something, and that question has not been answered.
|
|
68
|
+
*
|
|
69
|
+
* The pause is not a failure and not a stale flag — it is unfinished work with
|
|
70
|
+
* a person on the other end. Answer it with `resume(checkpoint, decision)`, or
|
|
71
|
+
* say plainly that it is being dropped with `abandonPause()`; both are visible
|
|
72
|
+
* in the record, and silently starting a fresh run was not.
|
|
73
|
+
*/
|
|
74
|
+
export declare class PendingQuestionError extends Error {
|
|
75
|
+
readonly code: "ERR_PENDING_QUESTION";
|
|
76
|
+
/** The tool that asked, when the pause named one. */
|
|
77
|
+
readonly toolName?: string;
|
|
78
|
+
/** The id of the tool call that asked, for joining back to the trace. */
|
|
79
|
+
readonly toolCallId?: string;
|
|
80
|
+
constructor(door: string, pending: {
|
|
81
|
+
toolName?: string;
|
|
82
|
+
toolCallId?: string;
|
|
83
|
+
question?: string;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Thrown by `followUp()` when there is no conversation to follow up on.
|
|
88
|
+
*
|
|
89
|
+
* `followUp()` continues THIS agent's own last completed run. Before the first
|
|
90
|
+
* one there is nothing to continue, and a "follow-up" that quietly became a
|
|
91
|
+
* first turn would be the very confusion the door exists to remove.
|
|
92
|
+
*/
|
|
93
|
+
export declare class NoConversationError extends Error {
|
|
94
|
+
readonly code: "ERR_NO_CONVERSATION";
|
|
95
|
+
constructor(door: string, reason: 'never-run' | 'last-run-unfinished');
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../src/core/conversation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,sBAAgC;IAC7C,qDAAqD;IACrD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAEjB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;CAe/D;AAED;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,yBAAmC;IAChD,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,yEAAyE;IACzE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAG3B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;CAmBzE;AAED;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,wBAAkC;gBAEnC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,qBAAqB;CAetE"}
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
* DFS stage).
|
|
55
55
|
*/
|
|
56
56
|
import type { LLMMessage } from '../adapters/types.js';
|
|
57
|
+
import type { MemoryIdentity } from '../memory/identity/types.js';
|
|
57
58
|
import type { FoldedSpan } from './agent/window/types.js';
|
|
58
59
|
/**
|
|
59
60
|
* JSON-serializable checkpoint of an in-progress agent run. Persist
|
|
@@ -109,6 +110,50 @@ export interface AgentRunCheckpoint {
|
|
|
109
110
|
* the opposite of what the version field is for.
|
|
110
111
|
*/
|
|
111
112
|
readonly folded?: readonly FoldedSpan[];
|
|
113
|
+
/**
|
|
114
|
+
* WHO this conversation belongs to — the `identity` the stored run was
|
|
115
|
+
* given, carried so that continuing it lands in the same namespace it
|
|
116
|
+
* started in (9.2.0).
|
|
117
|
+
*
|
|
118
|
+
* Before this field, continuing a conversation re-seeded identity from the
|
|
119
|
+
* resuming run's own id: every continued turn wrote its memory under a
|
|
120
|
+
* FRESH `conversationId`, so turn two's facts were stored somewhere turn
|
|
121
|
+
* three could not read them. Nothing threw, and the only symptom was an
|
|
122
|
+
* agent that kept forgetting — the same class of failure as a store that
|
|
123
|
+
* silently forgot everything looking exactly like a new user.
|
|
124
|
+
*
|
|
125
|
+
* Absent on a conversation stored before 9.2.0, and absent when the run
|
|
126
|
+
* never got an explicit identity (the default is derived from a runId, and
|
|
127
|
+
* carrying THAT forward would pin a whole conversation to one run's id).
|
|
128
|
+
* An explicit `identity` on the continuing call always wins.
|
|
129
|
+
*
|
|
130
|
+
* **Version 1 still**, on the same reasoning as {@link folded}: an optional
|
|
131
|
+
* field is not a format change, and a runtime that has never heard of it
|
|
132
|
+
* continues the conversation correctly.
|
|
133
|
+
*/
|
|
134
|
+
readonly identity?: MemoryIdentity;
|
|
135
|
+
/**
|
|
136
|
+
* WHICH agent recorded this conversation — present only when that agent was
|
|
137
|
+
* given an explicit `Agent.create({ id })` (9.2.0).
|
|
138
|
+
*
|
|
139
|
+
* A conversation is a transcript, and a transcript can be replayed on any
|
|
140
|
+
* agent. Usually that is the point: a deploy that adds a tool or edits a
|
|
141
|
+
* prompt must still be able to continue yesterday's conversations, so the
|
|
142
|
+
* runtime cannot refuse on "the agent changed". But replaying the BILLING
|
|
143
|
+
* agent's conversation on the SUPPORT agent is a different mistake, and it
|
|
144
|
+
* used to be accepted in silence.
|
|
145
|
+
*
|
|
146
|
+
* The rule is the one the embedder fingerprint already uses: **ids decide
|
|
147
|
+
* only when BOTH sides named themselves.** A default id (`'agent'`) is not
|
|
148
|
+
* naming yourself, so the majority of callers — who never pass one — are
|
|
149
|
+
* never refused. Two sides that both chose a name and chose different ones
|
|
150
|
+
* are refused, by name.
|
|
151
|
+
*
|
|
152
|
+
* Version 1 still, for the same reason as the two fields above.
|
|
153
|
+
*/
|
|
154
|
+
readonly agent?: {
|
|
155
|
+
readonly id: string;
|
|
156
|
+
};
|
|
112
157
|
/** Where the failure happened. Diagnostic — surfaces in oncall
|
|
113
158
|
* triage so you can tell "LLM 500 mid-iteration" from "tool
|
|
114
159
|
* threw" from "validation kept failing". */
|
|
@@ -166,6 +211,35 @@ export declare class RunCheckpointError extends Error {
|
|
|
166
211
|
readonly checkpoint: AgentRunCheckpoint;
|
|
167
212
|
constructor(cause: Error, checkpoint: AgentRunCheckpoint);
|
|
168
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Thrown when a stored conversation is handed to an agent that is provably
|
|
216
|
+
* not the one that recorded it (9.2.0).
|
|
217
|
+
*
|
|
218
|
+
* Raised only when BOTH sides named themselves with an explicit
|
|
219
|
+
* `Agent.create({ id })` and the two names differ — see
|
|
220
|
+
* {@link AgentRunCheckpoint.agent} for why that is the whole of the rule.
|
|
221
|
+
* An agent that gained a tool, changed its prompt or moved to a new model
|
|
222
|
+
* since the conversation was stored is NOT this error; continuing across a
|
|
223
|
+
* deploy is the ordinary case and must keep working.
|
|
224
|
+
*/
|
|
225
|
+
export declare class ConversationMismatchError extends Error {
|
|
226
|
+
readonly code: "ERR_CONVERSATION_MISMATCH";
|
|
227
|
+
/** The id stamped on the stored conversation. */
|
|
228
|
+
readonly storedAgentId: string;
|
|
229
|
+
/** The id of the agent it was handed to. */
|
|
230
|
+
readonly agentId: string;
|
|
231
|
+
constructor(door: string, storedAgentId: string, agentId: string);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Refuse a stored conversation that provably belongs to a different agent.
|
|
235
|
+
*
|
|
236
|
+
* Both-sides-named-themselves, or nothing happens. `storedId` is absent on
|
|
237
|
+
* every conversation written before 9.2.0 and on every agent that never chose
|
|
238
|
+
* an id; `agentId` is undefined for the same reason on the reading side.
|
|
239
|
+
*
|
|
240
|
+
* @internal
|
|
241
|
+
*/
|
|
242
|
+
export declare function assertContinuable(checkpoint: AgentRunCheckpoint, agentId: string | undefined, door: string): void;
|
|
169
243
|
/**
|
|
170
244
|
* Mutable state the Agent maintains during a run for checkpoint
|
|
171
245
|
* capture. Keyed by `runId` so multiple in-flight runs don't
|
|
@@ -215,7 +289,17 @@ export declare function buildCheckpoint(tracker: RunCheckpointTracker, failurePo
|
|
|
215
289
|
* and a fold's span is committed state — and because the same reader then
|
|
216
290
|
* serves both checkpoint carriers, so neither can lose what the other keeps.
|
|
217
291
|
*/
|
|
218
|
-
folded?: readonly FoldedSpan[]
|
|
292
|
+
folded?: readonly FoldedSpan[],
|
|
293
|
+
/**
|
|
294
|
+
* Who the run was for and which agent ran it — the two fields that make a
|
|
295
|
+
* stored conversation continuable rather than merely readable (9.2.0).
|
|
296
|
+
* Both are absent unless the caller chose them explicitly; see
|
|
297
|
+
* {@link AgentRunCheckpoint.identity} and {@link AgentRunCheckpoint.agent}.
|
|
298
|
+
*/
|
|
299
|
+
owner?: {
|
|
300
|
+
readonly identity?: MemoryIdentity;
|
|
301
|
+
readonly agentId?: string;
|
|
302
|
+
}): AgentRunCheckpoint;
|
|
219
303
|
/**
|
|
220
304
|
* Validate a checkpoint at deserialization time. Catches forward-
|
|
221
305
|
* incompatible payloads (someone tries to resume a v3 checkpoint on
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runCheckpoint.d.ts","sourceRoot":"","sources":["../../../src/core/runCheckpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAI1D;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE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ays dependency-free.
|
|
9
9
|
*
|
|
10
10
|
* openaiEmbedder() — hosted; needs OPENAI_API_KEY; no extra install (fetch).
|
|
11
|
-
* bedrockEmbedder() — hosted on AWS; Titan Text Embeddings
|
|
11
|
+
* bedrockEmbedder() — hosted on AWS; Titan Text Embeddings and Cohere Embed
|
|
12
|
+
* v3 (the model id picks the body shape); credentials
|
|
12
13
|
* come from the AWS chain, so no key option at all.
|
|
13
14
|
* peer dep: @aws-sdk/client-bedrock-runtime.
|
|
14
15
|
* localEmbedder() — on-device sentence-transformer; no key; offline after a
|
|
@@ -111,25 +112,85 @@ export interface BedrockRuntimeSdkModule {
|
|
|
111
112
|
}) => BedrockRuntimeLikeClient;
|
|
112
113
|
readonly InvokeModelCommand?: new (input: unknown) => unknown;
|
|
113
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* The request/response SHAPE a Bedrock embedding model speaks (9.3.0).
|
|
117
|
+
*
|
|
118
|
+
* `InvokeModel` is one operation with a vendor-specific body on both sides:
|
|
119
|
+
* Titan takes `{ inputText }` and answers `{ embedding }`, Cohere takes
|
|
120
|
+
* `{ texts, input_type }` and answers `{ embeddings }`. One model id therefore
|
|
121
|
+
* does not describe one call, and until 9.3.0 this factory sent Titan's body to
|
|
122
|
+
* everything — so a Cohere model id was accepted at construction (with
|
|
123
|
+
* `dimensions`) and failed at the first embed, against the real service, with a
|
|
124
|
+
* validation error from AWS rather than a sentence from here.
|
|
125
|
+
*/
|
|
126
|
+
export type BedrockEmbeddingFamily = 'titan' | 'cohere';
|
|
127
|
+
/**
|
|
128
|
+
* Cohere's `input_type`, which is a real parameter and not a hint: the v3
|
|
129
|
+
* models embed a QUERY and a DOCUMENT into deliberately different places, and
|
|
130
|
+
* the two are meant to be compared with each other. Sending one value for both
|
|
131
|
+
* halves is a measurable loss of retrieval quality, not a style choice — and
|
|
132
|
+
* Cohere requires the field, so there is no "unset" to fall back to.
|
|
133
|
+
*/
|
|
134
|
+
export type CohereInputType = 'search_document' | 'search_query';
|
|
114
135
|
export interface BedrockEmbedderOptions {
|
|
115
136
|
/**
|
|
116
137
|
* Bedrock model id. Default `'amazon.titan-embed-text-v2:0'`.
|
|
117
138
|
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
139
|
+
* Four are known by name — Titan V2, Titan V1, and Cohere Embed English /
|
|
140
|
+
* Multilingual v3 (see {@link BEDROCK_EMBEDDING_MODELS}) — and each brings
|
|
141
|
+
* its own body shape, vector length and input window. An id that WRAPS one of
|
|
142
|
+
* those (a cross-region inference profile `us.amazon.titan-embed-text-v2:0`,
|
|
143
|
+
* or an ARN ending in the model id) is resolved to the model it names.
|
|
144
|
+
*
|
|
145
|
+
* Anything else is a model this library has never met: pass `dimensions`
|
|
146
|
+
* with it (its vector length is not something this can know) and `family` if
|
|
147
|
+
* it is not Titan-shaped.
|
|
122
148
|
*/
|
|
123
149
|
readonly model?: string;
|
|
124
150
|
/**
|
|
125
|
-
* Vector length to request.
|
|
151
|
+
* Vector length to request.
|
|
152
|
+
*
|
|
153
|
+
* Titan V2 is the one CONFIGURABLE model — 1024 (default), 512 or 256 — and
|
|
126
154
|
* the value is SENT to the model AND reported as `.dimensions`, so the two
|
|
127
|
-
* can never disagree.
|
|
155
|
+
* can never disagree. Every other known model has ONE size, and asking for a
|
|
156
|
+
* different one is refused rather than reported: `.dimensions` is what a
|
|
157
|
+
* vector store fingerprints on, and a wrong one corrupts it silently.
|
|
128
158
|
*
|
|
129
|
-
* Required for a model outside {@link
|
|
130
|
-
* `.dimensions` silently corrupts a vector store.
|
|
159
|
+
* Required for a model outside {@link BEDROCK_EMBEDDING_MODELS}.
|
|
131
160
|
*/
|
|
132
161
|
readonly dimensions?: number;
|
|
162
|
+
/**
|
|
163
|
+
* The body shape to speak, when the model id does not say (9.3.0).
|
|
164
|
+
*
|
|
165
|
+
* Inferred for every known model and for anything that wraps one, so this is
|
|
166
|
+
* only for a model id this library has never met — a provisioned-throughput
|
|
167
|
+
* ARN, a custom deployment. Unknown and unstated, the body is **Titan's**,
|
|
168
|
+
* which is the shape every release before 9.3.0 sent to everything.
|
|
169
|
+
*
|
|
170
|
+
* Stating a family that contradicts a known model id is refused by name.
|
|
171
|
+
*/
|
|
172
|
+
readonly family?: BedrockEmbeddingFamily;
|
|
173
|
+
/**
|
|
174
|
+
* Pin Cohere's `input_type` instead of deriving it from the call (9.3.0).
|
|
175
|
+
*
|
|
176
|
+
* Unset — the default — `embed()` sends `'search_query'` and `embedBatch()`
|
|
177
|
+
* sends `'search_document'`, because that is what this library's own two
|
|
178
|
+
* call sites are: retrieval embeds ONE question (`loadRelevant`), indexing
|
|
179
|
+
* embeds MANY passages (`indexDocuments`, `embedMessages`). Pin it when your
|
|
180
|
+
* own code uses the two calls differently — embedding a single document, say,
|
|
181
|
+
* or scoring a batch of queries.
|
|
182
|
+
*
|
|
183
|
+
* Ignored by Titan, which has no such parameter.
|
|
184
|
+
*/
|
|
185
|
+
readonly inputType?: CohereInputType;
|
|
186
|
+
/**
|
|
187
|
+
* The longest input this model reads whole, in CHARACTERS
|
|
188
|
+
* ({@link Embedder.maxInputChars}). Declared for every known model from its
|
|
189
|
+
* documented token window; this option is how a model this library does not
|
|
190
|
+
* know states its own, rather than declaring none and leaving the indexer's
|
|
191
|
+
* conservative default in place. An explicit value always wins.
|
|
192
|
+
*/
|
|
193
|
+
readonly maxInputChars?: number;
|
|
133
194
|
/** AWS region. Passed to the SDK client when this factory builds one. */
|
|
134
195
|
readonly region?: string;
|
|
135
196
|
/** A pre-built Bedrock runtime client, so one SDK config serves the whole app. */
|
|
@@ -167,19 +228,31 @@ export interface BedrockEmbedderOptions {
|
|
|
167
228
|
* q8 and an fp32 build of one model are near-identical spaces, and "near" is
|
|
168
229
|
* exactly the difference that surfaces as a mysteriously worse ranking.)
|
|
169
230
|
*
|
|
231
|
+
* ── One operation, two body shapes (9.3.0) ───────────────────────────────
|
|
232
|
+
* `InvokeModel` is a single API over vendor-specific JSON. Titan takes
|
|
233
|
+
* `{ inputText }` and answers `{ embedding }`; Cohere takes
|
|
234
|
+
* `{ texts, input_type }` and answers `{ embeddings }`, embeds up to
|
|
235
|
+
* {@link COHERE_MAX_TEXTS_PER_CALL} of them per call, and distinguishes a
|
|
236
|
+
* QUERY from a DOCUMENT. So the model id selects a FAMILY
|
|
237
|
+
* ({@link BedrockEmbeddingFamily}), and the family owns the request, the
|
|
238
|
+
* response and the batching. Before this, one shape was sent to everything —
|
|
239
|
+
* a Cohere id constructed fine and failed at the first embed.
|
|
240
|
+
*
|
|
170
241
|
* ── The input ceiling (9.1.0) ────────────────────────────────────────────
|
|
171
|
-
* `.maxInputChars`
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
* the indexer's own default, which was measured on an on-device model
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
242
|
+
* `.maxInputChars` is per MODEL, from its documented token window converted at
|
|
243
|
+
* the stated {@link CHARS_PER_TOKEN} assumption of 4 characters per token:
|
|
244
|
+
* **32,000** for both Titan text-embedding models (8,192 tokens — sixteen
|
|
245
|
+
* times the indexer's own default, which was measured on an on-device model),
|
|
246
|
+
* and **2,000** for Cohere Embed v3 (512 tokens). Those two numbers are why the
|
|
247
|
+
* ceiling cannot be a per-vendor constant: the same 2,500-character chunk is
|
|
248
|
+
* read whole by Titan and truncated by Cohere. Dense text (code, tables, CJK)
|
|
249
|
+
* tokenises tighter than the assumption; pass an explicit `maxChunkChars` for
|
|
250
|
+
* such a corpus, and it wins over this number.
|
|
179
251
|
*
|
|
180
252
|
* @throws if `model` is unknown and `dimensions` was not supplied; if
|
|
181
|
-
* `dimensions` is
|
|
182
|
-
*
|
|
253
|
+
* `dimensions` is a size the model does not produce; if `family`
|
|
254
|
+
* contradicts a known model id; or if the SDK is missing and no
|
|
255
|
+
* `client` / `_client` / `_sdk` was passed.
|
|
183
256
|
*
|
|
184
257
|
* @example
|
|
185
258
|
* ```ts
|
|
@@ -190,6 +263,13 @@ export interface BedrockEmbedderOptions {
|
|
|
190
263
|
* const embedder = bedrockEmbedder({ region: 'us-east-1', dimensions: 512 });
|
|
191
264
|
* await indexFolder('./docs', { to: sqliteVectorStore({ file: './corpus.db' }), embedder });
|
|
192
265
|
* ```
|
|
266
|
+
*
|
|
267
|
+
* @example A Cohere embedding model on the same runtime
|
|
268
|
+
* ```ts
|
|
269
|
+
* // Body shape, response field, batch size and 512-token window all follow
|
|
270
|
+
* // from the model id — nothing else changes at the call site.
|
|
271
|
+
* const embedder = bedrockEmbedder({ model: 'cohere.embed-english-v3' });
|
|
272
|
+
* ```
|
|
193
273
|
*/
|
|
194
274
|
export declare function bedrockEmbedder(options?: BedrockEmbedderOptions): Embedder;
|
|
195
275
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/embedders/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/embedders/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,YAAY,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAO7D,MAAM,WAAW,qBAAqB;IACpC,2CAA2C;IAC3C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,yCAAyC;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,gEAAgE;IAChE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AA4DD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,QAAQ,CAwD5E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