agentfootprint 9.9.0 → 9.11.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/CLAUDE.md +4 -1
- package/dist/adapters/memory/sqliteVector.js +10 -0
- package/dist/adapters/memory/sqliteVector.js.map +1 -1
- package/dist/adapters/observability/otel.js +15 -0
- package/dist/adapters/observability/otel.js.map +1 -1
- package/dist/adapters/types.js +16 -1
- package/dist/adapters/types.js.map +1 -1
- package/dist/bridge/eventMeta.js +5 -0
- package/dist/bridge/eventMeta.js.map +1 -1
- package/dist/core/Agent.js +142 -22
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/stages/seed.js +38 -6
- package/dist/core/agent/stages/seed.js.map +1 -1
- package/dist/core/agent/stages/toolCalls.js +164 -10
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/agent/toolResultCap.js +0 -0
- package/dist/core/agent/toolResultCap.js.map +1 -0
- package/dist/core/slots/buildToolsSlot.js +23 -1
- package/dist/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/core/tools.js +3 -0
- package/dist/core/tools.js.map +1 -1
- package/dist/esm/adapters/memory/sqliteVector.d.ts +10 -0
- package/dist/esm/adapters/memory/sqliteVector.js +10 -0
- package/dist/esm/adapters/memory/sqliteVector.js.map +1 -1
- package/dist/esm/adapters/observability/otel.js +15 -0
- package/dist/esm/adapters/observability/otel.js.map +1 -1
- package/dist/esm/adapters/types.d.ts +91 -1
- package/dist/esm/adapters/types.js +14 -0
- package/dist/esm/adapters/types.js.map +1 -1
- package/dist/esm/bridge/eventMeta.d.ts +7 -0
- package/dist/esm/bridge/eventMeta.js +5 -0
- package/dist/esm/bridge/eventMeta.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +57 -14
- package/dist/esm/core/Agent.js +142 -22
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/stages/seed.d.ts +11 -0
- package/dist/esm/core/agent/stages/seed.js +38 -6
- package/dist/esm/core/agent/stages/seed.js.map +1 -1
- package/dist/esm/core/agent/stages/toolCalls.d.ts +14 -2
- package/dist/esm/core/agent/stages/toolCalls.js +162 -8
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/agent/toolResultCap.d.ts +93 -0
- package/dist/esm/core/agent/toolResultCap.js +0 -0
- package/dist/esm/core/agent/toolResultCap.js.map +1 -0
- package/dist/esm/core/agent/types.d.ts +76 -4
- package/dist/esm/core/slots/buildToolsSlot.d.ts +20 -1
- package/dist/esm/core/slots/buildToolsSlot.js +23 -1
- package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/esm/core/tools.d.ts +35 -3
- package/dist/esm/core/tools.js +3 -0
- package/dist/esm/core/tools.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +5 -1
- package/dist/esm/events/types.d.ts +27 -0
- package/dist/esm/hosting/browserSession.d.ts +97 -0
- package/dist/esm/hosting/browserSession.js +171 -0
- package/dist/esm/hosting/browserSession.js.map +1 -0
- package/dist/esm/hosting/httpHost.d.ts +14 -0
- package/dist/esm/hosting/httpHost.js +34 -6
- package/dist/esm/hosting/httpHost.js.map +1 -1
- package/dist/esm/hosting/index.d.ts +9 -3
- package/dist/esm/hosting/index.js +13 -1
- package/dist/esm/hosting/index.js.map +1 -1
- package/dist/esm/hosting/nodeHost.d.ts +73 -2
- package/dist/esm/hosting/nodeHost.js +110 -35
- package/dist/esm/hosting/nodeHost.js.map +1 -1
- package/dist/esm/hosting/standingAgent.d.ts +58 -14
- package/dist/esm/hosting/standingAgent.js +361 -88
- package/dist/esm/hosting/standingAgent.js.map +1 -1
- package/dist/esm/hosting/types.d.ts +112 -9
- package/dist/esm/hosting/types.js +3 -1
- package/dist/esm/hosting/types.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/skillTools.d.ts +23 -2
- package/dist/esm/lib/injection-engine/skillTools.js +15 -1
- package/dist/esm/lib/injection-engine/skillTools.js.map +1 -1
- package/dist/esm/security/PermissionPolicy.d.ts +83 -5
- package/dist/esm/security/PermissionPolicy.js +90 -6
- package/dist/esm/security/PermissionPolicy.js.map +1 -1
- package/dist/esm/security/index.d.ts +4 -2
- package/dist/esm/security/index.js +7 -0
- package/dist/esm/security/index.js.map +1 -1
- package/dist/esm/security/skillTarget.d.ts +32 -0
- package/dist/esm/security/skillTarget.js +37 -0
- package/dist/esm/security/skillTarget.js.map +1 -0
- package/dist/hosting/browserSession.js +175 -0
- package/dist/hosting/browserSession.js.map +1 -0
- package/dist/hosting/httpHost.js +34 -6
- package/dist/hosting/httpHost.js.map +1 -1
- package/dist/hosting/index.js +16 -1
- package/dist/hosting/index.js.map +1 -1
- package/dist/hosting/nodeHost.js +112 -36
- package/dist/hosting/nodeHost.js.map +1 -1
- package/dist/hosting/standingAgent.js +361 -88
- package/dist/hosting/standingAgent.js.map +1 -1
- package/dist/hosting/types.js +4 -0
- package/dist/hosting/types.js.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/injection-engine/skillTools.js +15 -1
- package/dist/lib/injection-engine/skillTools.js.map +1 -1
- package/dist/security/PermissionPolicy.js +90 -6
- package/dist/security/PermissionPolicy.js.map +1 -1
- package/dist/security/index.js +12 -1
- package/dist/security/index.js.map +1 -1
- package/dist/security/skillTarget.js +42 -0
- package/dist/security/skillTarget.js.map +1 -0
- package/dist/types/adapters/memory/sqliteVector.d.ts +10 -0
- package/dist/types/adapters/memory/sqliteVector.d.ts.map +1 -1
- package/dist/types/adapters/observability/otel.d.ts.map +1 -1
- package/dist/types/adapters/types.d.ts +91 -1
- package/dist/types/adapters/types.d.ts.map +1 -1
- package/dist/types/bridge/eventMeta.d.ts +7 -0
- package/dist/types/bridge/eventMeta.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +57 -14
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/stages/seed.d.ts +11 -0
- package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
- package/dist/types/core/agent/stages/toolCalls.d.ts +14 -2
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/agent/toolResultCap.d.ts +94 -0
- package/dist/types/core/agent/toolResultCap.d.ts.map +1 -0
- package/dist/types/core/agent/types.d.ts +76 -4
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/slots/buildToolsSlot.d.ts +20 -1
- package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
- package/dist/types/core/tools.d.ts +35 -3
- package/dist/types/core/tools.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +5 -1
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/types.d.ts +27 -0
- package/dist/types/events/types.d.ts.map +1 -1
- package/dist/types/hosting/browserSession.d.ts +98 -0
- package/dist/types/hosting/browserSession.d.ts.map +1 -0
- package/dist/types/hosting/httpHost.d.ts +14 -0
- package/dist/types/hosting/httpHost.d.ts.map +1 -1
- package/dist/types/hosting/index.d.ts +9 -3
- package/dist/types/hosting/index.d.ts.map +1 -1
- package/dist/types/hosting/nodeHost.d.ts +73 -2
- package/dist/types/hosting/nodeHost.d.ts.map +1 -1
- package/dist/types/hosting/standingAgent.d.ts +58 -14
- package/dist/types/hosting/standingAgent.d.ts.map +1 -1
- package/dist/types/hosting/types.d.ts +112 -9
- package/dist/types/hosting/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/skillTools.d.ts +23 -2
- package/dist/types/lib/injection-engine/skillTools.d.ts.map +1 -1
- package/dist/types/security/PermissionPolicy.d.ts +83 -5
- package/dist/types/security/PermissionPolicy.d.ts.map +1 -1
- package/dist/types/security/index.d.ts +4 -2
- package/dist/types/security/index.d.ts.map +1 -1
- package/dist/types/security/skillTarget.d.ts +33 -0
- package/dist/types/security/skillTarget.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -139,6 +139,47 @@ export interface AgentOptions {
|
|
|
139
139
|
* are ignored, never false-rejecting.
|
|
140
140
|
*/
|
|
141
141
|
readonly toolArgValidation?: ToolArgValidationMode;
|
|
142
|
+
/**
|
|
143
|
+
* The ceiling on ONE tool result, in characters (9.11.0). **Opt-in — there
|
|
144
|
+
* is no default, and there will not be one.**
|
|
145
|
+
*
|
|
146
|
+
* Over the cap, the result is REPLACED by a marker that names the tool, the
|
|
147
|
+
* size, the cap, and the one action that helps — and carries the first
|
|
148
|
+
* characters of the real answer verbatim:
|
|
149
|
+
*
|
|
150
|
+
* ```json
|
|
151
|
+
* { "truncated": true,
|
|
152
|
+
* "reason": "orders_export returned 812431 chars, over the 20000-char cap. Narrow the request and call again.",
|
|
153
|
+
* "head": "id,customer,total\n1001,…" }
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* The marker IS the result. It is what the model reads on the `role: 'tool'`
|
|
157
|
+
* message AND what `agentfootprint.stream.tool_end` carries — so a run that
|
|
158
|
+
* capped a 800KB result does not then ship that same 800KB to an event sink,
|
|
159
|
+
* and a trace shows the truncation instead of hiding it. `head` gets whatever
|
|
160
|
+
* the cap has left after the sentence explaining it, so a bigger cap buys a
|
|
161
|
+
* proportionally bigger head.
|
|
162
|
+
*
|
|
163
|
+
* **Why no default.** A default would silently modify tool results: a tool
|
|
164
|
+
* that returns 200KB of rows is doing what somebody wrote it to do, and a
|
|
165
|
+
* framework that quietly replaced that the first time it ran would be lying
|
|
166
|
+
* to the app about its own tool. Omitted, results are never measured and
|
|
167
|
+
* never replaced — byte-identical to every earlier release.
|
|
168
|
+
*
|
|
169
|
+
* It composes with, and never replaces, what a tool already does: a tool with
|
|
170
|
+
* its own paging keeps it, `CodeResult.truncated` still means what it means,
|
|
171
|
+
* and an `onToolResult` middleware that summarizes runs FIRST — the cap
|
|
172
|
+
* measures what the chain produced. It is the last-resort net, not the plan.
|
|
173
|
+
* When big tool DATA is the norm rather than the accident, the answer is the
|
|
174
|
+
* `CodeRunner` port ("summarize prose, compute data"), not a bigger cap.
|
|
175
|
+
*
|
|
176
|
+
* Refused at construction for a non-positive or non-integer value: `0` is not
|
|
177
|
+
* "off" — omitting the option is.
|
|
178
|
+
*
|
|
179
|
+
* @example a support agent whose search tool can return a whole knowledge base
|
|
180
|
+
* Agent.create({ provider, model, maxToolResultChars: 20_000 })
|
|
181
|
+
*/
|
|
182
|
+
readonly maxToolResultChars?: number;
|
|
142
183
|
/**
|
|
143
184
|
* How long ONE tool teardown may take before the runner stops waiting
|
|
144
185
|
* (default 5000ms). See `ctx.onTeardown`.
|
|
@@ -401,10 +442,26 @@ export interface AgentInput {
|
|
|
401
442
|
* Since 9.7.0 it also reaches `tool.execute` as `ctx.identity` — but only
|
|
402
443
|
* when you PASSED one. The default `{ conversationId: '<runId>' }` below is
|
|
403
444
|
* synthesized, and a tool told about a conversation nobody named would key a
|
|
404
|
-
* session on a fiction, so `ctx.identity` is absent in that case.
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
445
|
+
* session on a fiction, so `ctx.identity` is absent in that case. A DERIVED
|
|
446
|
+
* identity (the session rule below) is synthesized too, and is absent there
|
|
447
|
+
* for the same reason.
|
|
448
|
+
*
|
|
449
|
+
* **When omitted, one of two defaults applies (9.10.0):**
|
|
450
|
+
*
|
|
451
|
+
* - the run carries a `sessionId` (`agent.run(input, { sessionId })`, which
|
|
452
|
+
* is what `standingAgent` passes from every served request) →
|
|
453
|
+
* `{ conversationId: sessionId }`. A hosting session IS a conversation, so
|
|
454
|
+
* a served session gets durable per-user memory with no configuration at
|
|
455
|
+
* all. Before 9.10.0 it got the per-run default below and a fresh runId
|
|
456
|
+
* every turn, which meant a registered `.memory()` recalled nothing across
|
|
457
|
+
* the turns of one session.
|
|
458
|
+
* - no session either → `{ conversationId: '<runId>' }`, unchanged, so
|
|
459
|
+
* agents without memory and scripts that name nobody work exactly as they
|
|
460
|
+
* did.
|
|
461
|
+
*
|
|
462
|
+
* An identity you pass ALWAYS wins over the derivation — including the one a
|
|
463
|
+
* continued conversation carries, so a turn cannot silently re-namespace the
|
|
464
|
+
* conversation it is continuing.
|
|
408
465
|
*
|
|
409
466
|
* **`conversationId` is a namespace key, not a conversation.** Passing the
|
|
410
467
|
* same `conversationId` to two `run()` calls does NOT continue the first
|
|
@@ -472,6 +529,21 @@ export interface AgentState {
|
|
|
472
529
|
totalOutputTokens: number;
|
|
473
530
|
turnStartMs: number;
|
|
474
531
|
runIdentity: MemoryIdentity;
|
|
532
|
+
/**
|
|
533
|
+
* Where `runIdentity` came from, when it came from somewhere other than the
|
|
534
|
+
* caller (9.10.0).
|
|
535
|
+
*
|
|
536
|
+
* Present ONLY as `'session'`, and only when the run carried a
|
|
537
|
+
* `sessionId` and no identity at all — the one derivation this library
|
|
538
|
+
* makes. Absent means the identity is either the caller's own or the
|
|
539
|
+
* per-run default, which is what every release before 9.10.0 committed, so
|
|
540
|
+
* a run that is not session-bound writes exactly the keys it always did.
|
|
541
|
+
*
|
|
542
|
+
* It is a fact about the RECORD, not a dial: nothing reads it to decide
|
|
543
|
+
* anything. It exists so a trace can be asked "did anyone actually name this
|
|
544
|
+
* namespace?" and answer honestly.
|
|
545
|
+
*/
|
|
546
|
+
runIdentitySource?: 'session';
|
|
475
547
|
newMessages: readonly LLMMessage[];
|
|
476
548
|
turnNumber: number;
|
|
477
549
|
contextTokensRemaining: number;
|
|
@@ -57,7 +57,26 @@ export interface ToolsSlotConfig {
|
|
|
57
57
|
* Substituted by NAME in Compose, so dispatch is untouched: the tool-calls handler
|
|
58
58
|
* resolves executables from `registryByName`, never from the schema list.
|
|
59
59
|
*/
|
|
60
|
-
readonly readSkillFor?: (
|
|
60
|
+
readonly readSkillFor?: (args: {
|
|
61
|
+
readonly currentSkillId?: string;
|
|
62
|
+
readonly hiddenSkillIds?: readonly string[];
|
|
63
|
+
}) => LLMToolSchema;
|
|
64
|
+
/**
|
|
65
|
+
* Which skills the caller's role may NOT see this run (9.11.0).
|
|
66
|
+
*
|
|
67
|
+
* Resolved in the async Discover stage and read by the sync Compose stage —
|
|
68
|
+
* the same shape `providerToolCache` uses, and for the same reason: a
|
|
69
|
+
* `PermissionChecker` may be async (a Redis lookup, a hub call) and Compose
|
|
70
|
+
* is pure. Set only when a checker declares it governs `'skill_read'`; then
|
|
71
|
+
* every hidden skill's row disappears from the `read_skill` menu, and the
|
|
72
|
+
* dispatch loop refuses the activation with the policy's own message.
|
|
73
|
+
*
|
|
74
|
+
* Its errors are NOT swallowed: a visibility resolver that throws leaves the
|
|
75
|
+
* iteration to the same reliability rules a failed `ToolProvider.list` does,
|
|
76
|
+
* because composing a menu from a policy that did not answer is exactly the
|
|
77
|
+
* fail-open this feature exists to prevent.
|
|
78
|
+
*/
|
|
79
|
+
readonly hiddenSkillIds?: () => Promise<readonly string[]> | readonly string[];
|
|
61
80
|
/** Budget cap (chars). Default: 2000. Set from the public door as
|
|
62
81
|
* `contextBudget.tools` on `AgentOptions`. */
|
|
63
82
|
readonly budgetCap?: number;
|
|
@@ -30,6 +30,16 @@ export function buildToolsSlot(config) {
|
|
|
30
30
|
const readSkillFor = config.readSkillFor;
|
|
31
31
|
const toolProvider = config.toolProvider;
|
|
32
32
|
const providerToolCache = config.providerToolCache;
|
|
33
|
+
const hiddenSkillIdsFor = config.hiddenSkillIds;
|
|
34
|
+
// Written by Discover (async), read by Compose (sync) — see the config note.
|
|
35
|
+
//
|
|
36
|
+
// Chart-scoped, and the chart is built ONCE at Agent construction — so this
|
|
37
|
+
// outlives a run. It is never stale at READ time because Discover always runs
|
|
38
|
+
// before Compose in the same slot and overwrites it every iteration; and it
|
|
39
|
+
// cannot cross callers because one Agent runs one turn at a time (and
|
|
40
|
+
// `standingAgent({ agentFactory })` gives each session its own instance, and
|
|
41
|
+
// therefore its own chart and its own closure).
|
|
42
|
+
let hiddenSkillIds = [];
|
|
33
43
|
// Dedup latch for the human-facing warning, scoped to THIS built chart:
|
|
34
44
|
// a 20-iteration ReAct loop must not print 20 identical warnings. The
|
|
35
45
|
// typed `context.budget_pressure` event still fires every iteration and
|
|
@@ -55,6 +65,13 @@ export function buildToolsSlot(config) {
|
|
|
55
65
|
// Sync providers still pay zero microtask overhead — the dynamic
|
|
56
66
|
// `instanceof Promise` check skips await for non-Promise returns.
|
|
57
67
|
const discoverStage = async (scope) => {
|
|
68
|
+
// Per-role skill visibility (9.11.0), resolved on the ONE stage in this
|
|
69
|
+
// slot that is allowed to await. Before the provider block so an agent
|
|
70
|
+
// with skills but no `toolProvider` still gets its filter.
|
|
71
|
+
if (hiddenSkillIdsFor) {
|
|
72
|
+
const asked = hiddenSkillIdsFor();
|
|
73
|
+
hiddenSkillIds = asked instanceof Promise ? await asked : asked;
|
|
74
|
+
}
|
|
58
75
|
if (!toolProvider)
|
|
59
76
|
return; // No-op fast path: keeps trace shape consistent.
|
|
60
77
|
const args = scope.$getArgs();
|
|
@@ -131,7 +148,12 @@ export function buildToolsSlot(config) {
|
|
|
131
148
|
// parent before this slot mounts — the same value the read_skill gate will read
|
|
132
149
|
// when the model answers. Substituted by name so nothing else in the list moves.
|
|
133
150
|
const tools = readSkillFor
|
|
134
|
-
? staticTools.map((t) =>
|
|
151
|
+
? staticTools.map((t) => t.name === 'read_skill'
|
|
152
|
+
? readSkillFor({
|
|
153
|
+
...(args.currentSkillId !== undefined && { currentSkillId: args.currentSkillId }),
|
|
154
|
+
...(hiddenSkillIds.length > 0 && { hiddenSkillIds }),
|
|
155
|
+
})
|
|
156
|
+
: t)
|
|
135
157
|
: staticTools;
|
|
136
158
|
const injections = tools.map((t, i) => {
|
|
137
159
|
const summary = `${t.name}: ${t.description}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildToolsSlot.js","sourceRoot":"","sources":["../../../../src/core/slots/buildToolsSlot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAA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E,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAClE,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACnC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;YAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YAClC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAAE,SAAS;YAC3C,+EAA+E;YAC/E,8EAA8E;YAC9E,+EAA+E;YAC/E,6EAA6E;YAC7E,SAAS,CAAC,KAAK,EAAE,+BAA+B,EAAE;gBAChD,QAAQ;gBACR,SAAS;gBACT,UAAU,EAAE,UAAU;gBACtB,GAAG,CAAC,UAAU,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;gBAC/C,UAAU,EAAE,OAAO;gBACnB,YAAY,EAAE,GAAG,CAAC,EAAE;aACrB,CAAC,CAAC;YACH,IAAI,CAAC,SAAS,EAAE,IAAI,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAAE,SAAS;YACzD,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC3B,sCAAsC;YACtC,OAAO,CAAC,IAAI,CACV,0BAA0B,QAAQ,yCAAyC;gBACzE,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,0BAA0B,GAAG,CAAC,EAAE,eAAe;gBACtF,gFAAgF;gBAChF,sFAAsF;gBACtF,uFAAuF,CAC1F,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/esm/core/tools.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Role: Consumer-facing shape. Agent.tool(...) accepts these.
|
|
7
7
|
* Emits: N/A (types only).
|
|
8
8
|
*/
|
|
9
|
-
import type { LLMToolSchema } from '../adapters/types.js';
|
|
9
|
+
import type { LLMToolSchema, ToolCapability } from '../adapters/types.js';
|
|
10
10
|
import type { Credential, CredentialNeed, CredentialProvider } from '../identity/types.js';
|
|
11
11
|
import type { MemoryIdentity } from '../memory/identity/types.js';
|
|
12
12
|
import type { CheckInDemand } from './checkin.js';
|
|
@@ -58,6 +58,32 @@ export interface Tool<TArgs = Record<string, unknown>, TResult = unknown> {
|
|
|
58
58
|
* when it is genuinely relaying another source's tool.
|
|
59
59
|
*/
|
|
60
60
|
readonly source?: string;
|
|
61
|
+
/**
|
|
62
|
+
* What this tool touches, DECLARED by whoever wrote it (9.11.0).
|
|
63
|
+
*
|
|
64
|
+
* The framework never infers this. A tool's capabilities are not knowable
|
|
65
|
+
* from its name, its schema or its description, and classifying them by guess
|
|
66
|
+
* would rest a policy decision on a heuristic — so a tool that says nothing
|
|
67
|
+
* gets nothing asked about it, exactly as before.
|
|
68
|
+
*
|
|
69
|
+
* **Enforced when both sides speak.** When a tool declares a capability AND
|
|
70
|
+
* the configured `PermissionChecker` declares it `governs` that capability,
|
|
71
|
+
* the dispatch loop asks once per declared capability, right after the
|
|
72
|
+
* `'tool_call'` check allows — `check({ capability: 'external_net', target:
|
|
73
|
+
* '<tool name>' })`. Either side silent → not asked, not refused. A denial
|
|
74
|
+
* lands like every other refusal in the loop: the tool does not run and the
|
|
75
|
+
* model reads a result it can adapt to.
|
|
76
|
+
*
|
|
77
|
+
* @example a tool the operator wants governed as a network egress
|
|
78
|
+
* defineTool({
|
|
79
|
+
* name: 'fetch_invoice',
|
|
80
|
+
* description: 'Fetch an invoice PDF from the billing service',
|
|
81
|
+
* capabilities: ['external_net', 'user_data'],
|
|
82
|
+
* inputSchema: { … },
|
|
83
|
+
* execute: async ({ id }) => …,
|
|
84
|
+
* });
|
|
85
|
+
*/
|
|
86
|
+
readonly capabilities?: readonly ToolCapability[];
|
|
61
87
|
execute(args: TArgs, ctx: ToolExecutionContext): Promise<TResult> | TResult;
|
|
62
88
|
}
|
|
63
89
|
/** Runtime context passed to tool.execute(). */
|
|
@@ -106,8 +132,11 @@ export interface ToolExecutionContext {
|
|
|
106
132
|
*
|
|
107
133
|
* **Absent when the caller passed none.** Deliberately NOT the run's internal
|
|
108
134
|
* `runIdentity`, which is always populated (it defaults to
|
|
109
|
-
* `{ conversationId: '<runId>' }
|
|
110
|
-
*
|
|
135
|
+
* `{ conversationId: '<runId>' }`, or to `{ conversationId: sessionId }` on a
|
|
136
|
+
* session-bound run since 9.10.0): handing either of those to a tool would
|
|
137
|
+
* publish a SYNTHESIZED conversation as if somebody had named one. A tool
|
|
138
|
+
* that wants the session has `ctx.sessionId` for it, which is the fact the
|
|
139
|
+
* transport actually delivered.
|
|
111
140
|
*/
|
|
112
141
|
readonly identity?: MemoryIdentity;
|
|
113
142
|
/**
|
|
@@ -166,6 +195,9 @@ export interface DefineToolOptions<TArgs, TResult> {
|
|
|
166
195
|
/** Demand a human check-in before this tool runs (see {@link Tool.checkIn}).
|
|
167
196
|
* `'always'` or a `(args, ctx) => boolean` predicate. */
|
|
168
197
|
readonly checkIn?: CheckInDemand<TArgs>;
|
|
198
|
+
/** Declare what this tool touches (see {@link Tool.capabilities}). Consulted
|
|
199
|
+
* only when the configured checker declares it governs them. */
|
|
200
|
+
readonly capabilities?: readonly ToolCapability[];
|
|
169
201
|
execute(args: TArgs, ctx: ToolExecutionContext): Promise<TResult> | TResult;
|
|
170
202
|
}
|
|
171
203
|
/**
|
package/dist/esm/core/tools.js
CHANGED
|
@@ -86,6 +86,9 @@ export function defineTool(options) {
|
|
|
86
86
|
// The call-site predicate is typed to TArgs; the stored Tool keeps the
|
|
87
87
|
// non-generic shape so it widens into `Tool[]` registries.
|
|
88
88
|
...(options.checkIn !== undefined && { checkIn: options.checkIn }),
|
|
89
|
+
// Copied verbatim, never inferred — an empty array is a tool that declared
|
|
90
|
+
// it touches nothing, which is a different statement from saying nothing.
|
|
91
|
+
...(options.capabilities !== undefined && { capabilities: options.capabilities }),
|
|
89
92
|
execute: options.execute,
|
|
90
93
|
};
|
|
91
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/core/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/core/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAoNxC;;;;;;;;;;;;;;;;;;GAkBG;AACH;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAa;IAC/C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CACb,yDAAyD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAClF,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,MAAM,MAAM,GACV,IAAI,CAAC,MAAM,GAAG,EAAE;YACd,CAAC,CAAC,SAAS,IAAI,CAAC,MAAM,iBAAiB;YACvC,CAAC,CAAC,mFAAmF,CAAC;QAC1F,MAAM,IAAI,KAAK,CACb,aAAa,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,MAAM,IAAI;YAC/C,sFAAsF;YACtF,wEAAwE;YACxE,0DAA0D,CAC7D,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAa;IACjD,IAAI,CAAC,SAAS,EAAE;QAAE,OAAO;IACzB,IAAI,CAAC;QACH,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,sCAAsC;QACtC,OAAO,CAAC,IAAI,CAAC,4BAA6B,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,OAA0C;IAE1C,qBAAqB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO;QACL,MAAM,EAAE;YACN,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;SACvE;QACD,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;QAC9C,uEAAuE;QACvE,2DAA2D;QAC3D,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAwB,EAAE,CAAC;QACnF,2EAA2E;QAC3E,0EAA0E;QAC1E,GAAG,CAAC,OAAO,CAAC,YAAY,KAAK,SAAS,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACjF,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;AACJ,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* Emits: (types only).
|
|
7
7
|
*/
|
|
8
8
|
import type { CompositionKind, ContextLifetime, ContextRecency, ContextRole, ContextSlot, ContextSource, LLMProviderName, ToolProtocol } from './types.js';
|
|
9
|
+
import type { PermissionCapability } from '../adapters/types.js';
|
|
9
10
|
import type { ThinkingBlock } from '../thinking/types.js';
|
|
10
11
|
import type { LoopMoment } from '../core/agent/moments.js';
|
|
11
12
|
export interface CompositionEnterPayload {
|
|
@@ -739,7 +740,10 @@ export interface SkillRejectedPayload {
|
|
|
739
740
|
readonly iteration: number;
|
|
740
741
|
}
|
|
741
742
|
export interface PermissionCheckPayload {
|
|
742
|
-
|
|
743
|
+
/** 9.11.0 — the shared vocabulary, so the event cannot drift from the
|
|
744
|
+
* request. `'skill_read'` joined it when skill activation became something
|
|
745
|
+
* a policy can refuse. */
|
|
746
|
+
readonly capability: PermissionCapability;
|
|
743
747
|
readonly actor: string;
|
|
744
748
|
readonly target?: string;
|
|
745
749
|
readonly result: 'allow' | 'deny' | 'halt' | 'gate_open';
|
|
@@ -78,6 +78,33 @@ export interface EventMeta {
|
|
|
78
78
|
* through; anyone else sets it with `run({ ... }, { sessionId })`.
|
|
79
79
|
*/
|
|
80
80
|
readonly sessionId?: string;
|
|
81
|
+
/**
|
|
82
|
+
* WHO this run is for — the principal the caller NAMED (9.11.0).
|
|
83
|
+
*
|
|
84
|
+
* This is the actor half of an audit record. The event stream has always
|
|
85
|
+
* carried *what* happened and *when*; `principal` and {@link tenant} are what
|
|
86
|
+
* make it a who→what→when wire, and they ride on the meta for the same reason
|
|
87
|
+
* `sessionId` does: nothing downstream can reconstruct them from the payloads.
|
|
88
|
+
*
|
|
89
|
+
* **Stamped ONLY from an explicit identity** — `agent.run(input, { identity })`
|
|
90
|
+
* or `run({ message, identity })`, the same tuple memory and the permission
|
|
91
|
+
* gate scope on. Never from the run's internal `runIdentity`, which is always
|
|
92
|
+
* populated and defaults to `{ conversationId: '<runId>' }` (or, on a
|
|
93
|
+
* session-bound run since 9.10.0, to `{ conversationId: sessionId }`).
|
|
94
|
+
*
|
|
95
|
+
* **A conversation id is not an actor.** Deriving a principal from a session
|
|
96
|
+
* would put a caller-supplied string — anyone who can reach the host can send
|
|
97
|
+
* any one — into the field an auditor reads as "who did this". Absent is the
|
|
98
|
+
* honest answer for an anonymous run, and absent is what it says.
|
|
99
|
+
*/
|
|
100
|
+
readonly principal?: string;
|
|
101
|
+
/**
|
|
102
|
+
* The organization / workspace / account boundary this run is for (9.11.0).
|
|
103
|
+
*
|
|
104
|
+
* Same rule as {@link principal} in every respect: explicit identity only,
|
|
105
|
+
* never synthesized, absent for a single-tenant or anonymous run.
|
|
106
|
+
*/
|
|
107
|
+
readonly tenant?: string;
|
|
81
108
|
}
|
|
82
109
|
/** Discriminated-union envelope every event implements. */
|
|
83
110
|
export interface AgentfootprintEventEnvelope<TType extends string, TPayload> {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hosting/browserSession — the client half of a session, for a page.
|
|
3
|
+
*
|
|
4
|
+
* A standing agent remembers a conversation per `sessionId`. Something has to
|
|
5
|
+
* decide what that id IS, and in a browser that is one line:
|
|
6
|
+
*
|
|
7
|
+
* const sessionId = browserSessionId();
|
|
8
|
+
* await fetch('/invoke', {
|
|
9
|
+
* method: 'POST',
|
|
10
|
+
* headers: { 'content-type': 'application/json', 'x-session-id': sessionId },
|
|
11
|
+
* body: JSON.stringify({ input: 'hello' }),
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* The server half is `nodeHost({ sessionHeader })` (default `'x-session-id'`,
|
|
15
|
+
* so the line above needs no server option at all) or
|
|
16
|
+
* `nodeHost({ sessionCookie })`, which does the same job without any client
|
|
17
|
+
* code — see those options for the trade.
|
|
18
|
+
*
|
|
19
|
+
* ── Why this file imports NOTHING ────────────────────────────────────────────
|
|
20
|
+
* It is the one piece of `hosting/` a browser bundle is meant to contain, and
|
|
21
|
+
* the rest of that folder is Node: `httpHost` dynamically imports `node:http`,
|
|
22
|
+
* `sqliteSessions` reaches `node:sqlite` through `createRequire`. So this file
|
|
23
|
+
* has no imports at all and is exported from the MAIN barrel
|
|
24
|
+
* (`import { browserSessionId } from 'agentfootprint'`) rather than from
|
|
25
|
+
* `agentfootprint/hosting`, which no browser bundle should have to pull in. It
|
|
26
|
+
* lives here, beside the server half it pairs with, so the two cannot drift
|
|
27
|
+
* about which header carries what.
|
|
28
|
+
*
|
|
29
|
+
* Pattern: a plain function. There is no state to own beyond the storage key.
|
|
30
|
+
*/
|
|
31
|
+
/** Options for {@link browserSessionId}. */
|
|
32
|
+
export interface BrowserSessionIdOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Where the id is kept. Default `'agentfootprint.sessionId'`.
|
|
35
|
+
*
|
|
36
|
+
* Change it when one origin serves two different agents that must not share a
|
|
37
|
+
* conversation — two keys, two sessions, one browser.
|
|
38
|
+
*/
|
|
39
|
+
readonly storageKey?: string;
|
|
40
|
+
}
|
|
41
|
+
/** The default `localStorage` key. Named, so a page can clear it deliberately. */
|
|
42
|
+
export declare const DEFAULT_SESSION_STORAGE_KEY = "agentfootprint.sessionId";
|
|
43
|
+
/**
|
|
44
|
+
* The conversation this browser is having with your agent: minted once, kept,
|
|
45
|
+
* and handed back on every later call.
|
|
46
|
+
*
|
|
47
|
+
* Pass it as `x-session-id` (or in the JSON body as `sessionId`) and a
|
|
48
|
+
* `standingAgent` will hydrate the same conversation on every turn — and, since
|
|
49
|
+
* 9.10.0, scope the agent's memory to it too, with no configuration.
|
|
50
|
+
*
|
|
51
|
+
* ── What it is, and the thing it is NOT ──────────────────────────────────────
|
|
52
|
+
* **A session id is not authentication.** It is a handle the browser carries,
|
|
53
|
+
* and anyone who can reach your host can send any string in its place. Nothing
|
|
54
|
+
* here signs it, and nothing on the server side checks it: authenticate the
|
|
55
|
+
* caller by your own means, then check that the authenticated principal is
|
|
56
|
+
* allowed the session they claimed. Storing anything sensitive under a session
|
|
57
|
+
* id alone is storing it under a value the client controls.
|
|
58
|
+
*
|
|
59
|
+
* ── Where it is kept, and what that costs ────────────────────────────────────
|
|
60
|
+
* `localStorage`, under {@link BrowserSessionIdOptions.storageKey}. That means
|
|
61
|
+
* it survives a reload and a closed tab, is scoped to the ORIGIN, and is
|
|
62
|
+
* readable by any script running on that origin — including one you did not
|
|
63
|
+
* write. It is per browser profile, so the same person on a phone and a laptop
|
|
64
|
+
* is two conversations, and a shared machine is one.
|
|
65
|
+
*
|
|
66
|
+
* When `localStorage` cannot be reached — private mode in some browsers throws
|
|
67
|
+
* on access, and there is no `window` at all during SSR — the id is kept in a
|
|
68
|
+
* module-level `Map` instead. Same id for the life of the page, gone on reload.
|
|
69
|
+
* This is a fallback and it is stated rather than hidden: a page that must
|
|
70
|
+
* survive a reload in private mode needs its own storage.
|
|
71
|
+
*
|
|
72
|
+
* ── How it is minted ─────────────────────────────────────────────────────────
|
|
73
|
+
* `crypto.randomUUID()` where it exists (every current browser, in a secure
|
|
74
|
+
* context), then `crypto.getRandomValues`. Both are unguessable. On a runtime
|
|
75
|
+
* that has NEITHER — an insecure-context page in an older browser — it falls
|
|
76
|
+
* back to `Math.random`, which is **not** unguessable, and that is survivable
|
|
77
|
+
* only because of the paragraph above: this id is a handle, never a credential.
|
|
78
|
+
*
|
|
79
|
+
* @example A chat page that remembers across reloads
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { browserSessionId } from 'agentfootprint';
|
|
82
|
+
*
|
|
83
|
+
* const sessionId = browserSessionId();
|
|
84
|
+
* const reply = await fetch('/invoke', {
|
|
85
|
+
* method: 'POST',
|
|
86
|
+
* headers: { 'content-type': 'application/json', 'x-session-id': sessionId },
|
|
87
|
+
* body: JSON.stringify({ input: message }),
|
|
88
|
+
* }).then((r) => r.json());
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @example Two agents on one origin, two conversations
|
|
92
|
+
* ```ts
|
|
93
|
+
* const support = browserSessionId({ storageKey: 'support.sessionId' });
|
|
94
|
+
* const billing = browserSessionId({ storageKey: 'billing.sessionId' });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function browserSessionId(options?: BrowserSessionIdOptions): string;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hosting/browserSession — the client half of a session, for a page.
|
|
3
|
+
*
|
|
4
|
+
* A standing agent remembers a conversation per `sessionId`. Something has to
|
|
5
|
+
* decide what that id IS, and in a browser that is one line:
|
|
6
|
+
*
|
|
7
|
+
* const sessionId = browserSessionId();
|
|
8
|
+
* await fetch('/invoke', {
|
|
9
|
+
* method: 'POST',
|
|
10
|
+
* headers: { 'content-type': 'application/json', 'x-session-id': sessionId },
|
|
11
|
+
* body: JSON.stringify({ input: 'hello' }),
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* The server half is `nodeHost({ sessionHeader })` (default `'x-session-id'`,
|
|
15
|
+
* so the line above needs no server option at all) or
|
|
16
|
+
* `nodeHost({ sessionCookie })`, which does the same job without any client
|
|
17
|
+
* code — see those options for the trade.
|
|
18
|
+
*
|
|
19
|
+
* ── Why this file imports NOTHING ────────────────────────────────────────────
|
|
20
|
+
* It is the one piece of `hosting/` a browser bundle is meant to contain, and
|
|
21
|
+
* the rest of that folder is Node: `httpHost` dynamically imports `node:http`,
|
|
22
|
+
* `sqliteSessions` reaches `node:sqlite` through `createRequire`. So this file
|
|
23
|
+
* has no imports at all and is exported from the MAIN barrel
|
|
24
|
+
* (`import { browserSessionId } from 'agentfootprint'`) rather than from
|
|
25
|
+
* `agentfootprint/hosting`, which no browser bundle should have to pull in. It
|
|
26
|
+
* lives here, beside the server half it pairs with, so the two cannot drift
|
|
27
|
+
* about which header carries what.
|
|
28
|
+
*
|
|
29
|
+
* Pattern: a plain function. There is no state to own beyond the storage key.
|
|
30
|
+
*/
|
|
31
|
+
/** The default `localStorage` key. Named, so a page can clear it deliberately. */
|
|
32
|
+
export const DEFAULT_SESSION_STORAGE_KEY = 'agentfootprint.sessionId';
|
|
33
|
+
/**
|
|
34
|
+
* Storage for the runs where `localStorage` is not there — a private-mode
|
|
35
|
+
* browser that throws on access, an SSR pass, a test. One `Map` for the module,
|
|
36
|
+
* so a second call in the same page still gets the same id back.
|
|
37
|
+
*/
|
|
38
|
+
const fallbackStore = new Map();
|
|
39
|
+
/**
|
|
40
|
+
* The conversation this browser is having with your agent: minted once, kept,
|
|
41
|
+
* and handed back on every later call.
|
|
42
|
+
*
|
|
43
|
+
* Pass it as `x-session-id` (or in the JSON body as `sessionId`) and a
|
|
44
|
+
* `standingAgent` will hydrate the same conversation on every turn — and, since
|
|
45
|
+
* 9.10.0, scope the agent's memory to it too, with no configuration.
|
|
46
|
+
*
|
|
47
|
+
* ── What it is, and the thing it is NOT ──────────────────────────────────────
|
|
48
|
+
* **A session id is not authentication.** It is a handle the browser carries,
|
|
49
|
+
* and anyone who can reach your host can send any string in its place. Nothing
|
|
50
|
+
* here signs it, and nothing on the server side checks it: authenticate the
|
|
51
|
+
* caller by your own means, then check that the authenticated principal is
|
|
52
|
+
* allowed the session they claimed. Storing anything sensitive under a session
|
|
53
|
+
* id alone is storing it under a value the client controls.
|
|
54
|
+
*
|
|
55
|
+
* ── Where it is kept, and what that costs ────────────────────────────────────
|
|
56
|
+
* `localStorage`, under {@link BrowserSessionIdOptions.storageKey}. That means
|
|
57
|
+
* it survives a reload and a closed tab, is scoped to the ORIGIN, and is
|
|
58
|
+
* readable by any script running on that origin — including one you did not
|
|
59
|
+
* write. It is per browser profile, so the same person on a phone and a laptop
|
|
60
|
+
* is two conversations, and a shared machine is one.
|
|
61
|
+
*
|
|
62
|
+
* When `localStorage` cannot be reached — private mode in some browsers throws
|
|
63
|
+
* on access, and there is no `window` at all during SSR — the id is kept in a
|
|
64
|
+
* module-level `Map` instead. Same id for the life of the page, gone on reload.
|
|
65
|
+
* This is a fallback and it is stated rather than hidden: a page that must
|
|
66
|
+
* survive a reload in private mode needs its own storage.
|
|
67
|
+
*
|
|
68
|
+
* ── How it is minted ─────────────────────────────────────────────────────────
|
|
69
|
+
* `crypto.randomUUID()` where it exists (every current browser, in a secure
|
|
70
|
+
* context), then `crypto.getRandomValues`. Both are unguessable. On a runtime
|
|
71
|
+
* that has NEITHER — an insecure-context page in an older browser — it falls
|
|
72
|
+
* back to `Math.random`, which is **not** unguessable, and that is survivable
|
|
73
|
+
* only because of the paragraph above: this id is a handle, never a credential.
|
|
74
|
+
*
|
|
75
|
+
* @example A chat page that remembers across reloads
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { browserSessionId } from 'agentfootprint';
|
|
78
|
+
*
|
|
79
|
+
* const sessionId = browserSessionId();
|
|
80
|
+
* const reply = await fetch('/invoke', {
|
|
81
|
+
* method: 'POST',
|
|
82
|
+
* headers: { 'content-type': 'application/json', 'x-session-id': sessionId },
|
|
83
|
+
* body: JSON.stringify({ input: message }),
|
|
84
|
+
* }).then((r) => r.json());
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @example Two agents on one origin, two conversations
|
|
88
|
+
* ```ts
|
|
89
|
+
* const support = browserSessionId({ storageKey: 'support.sessionId' });
|
|
90
|
+
* const billing = browserSessionId({ storageKey: 'billing.sessionId' });
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export function browserSessionId(options = {}) {
|
|
94
|
+
const key = options.storageKey ?? DEFAULT_SESSION_STORAGE_KEY;
|
|
95
|
+
const existing = readStored(key);
|
|
96
|
+
if (existing !== undefined && existing.length > 0)
|
|
97
|
+
return existing;
|
|
98
|
+
const minted = mintId();
|
|
99
|
+
writeStored(key, minted);
|
|
100
|
+
return minted;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* `localStorage` if it is both present and usable, otherwise `undefined`.
|
|
104
|
+
*
|
|
105
|
+
* Presence is not usability: Safari's private mode has historically THROWN on
|
|
106
|
+
* `localStorage` access rather than being absent, so the only honest test is to
|
|
107
|
+
* touch it inside a try.
|
|
108
|
+
*/
|
|
109
|
+
function storage() {
|
|
110
|
+
try {
|
|
111
|
+
const candidate = globalThis.localStorage;
|
|
112
|
+
if (candidate === undefined || candidate === null)
|
|
113
|
+
return undefined;
|
|
114
|
+
// A round trip, because a quota-exhausted or disabled store can be present
|
|
115
|
+
// and still refuse every write.
|
|
116
|
+
const probe = '__agentfootprint_probe__';
|
|
117
|
+
candidate.setItem(probe, '1');
|
|
118
|
+
candidate.removeItem(probe);
|
|
119
|
+
return candidate;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function readStored(key) {
|
|
126
|
+
const store = storage();
|
|
127
|
+
if (store === undefined)
|
|
128
|
+
return fallbackStore.get(key);
|
|
129
|
+
try {
|
|
130
|
+
return store.getItem(key) ?? undefined;
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
return fallbackStore.get(key);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function writeStored(key, value) {
|
|
137
|
+
// The in-memory copy is kept EITHER WAY. A `localStorage` that accepted the
|
|
138
|
+
// probe and then refused this write (quota, a policy change mid-page) would
|
|
139
|
+
// otherwise mint a new id on every call, and a conversation that starts over
|
|
140
|
+
// on every message is worse than one that ends at the reload.
|
|
141
|
+
fallbackStore.set(key, value);
|
|
142
|
+
const store = storage();
|
|
143
|
+
if (store === undefined)
|
|
144
|
+
return;
|
|
145
|
+
try {
|
|
146
|
+
store.setItem(key, value);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// Already kept above. Nothing here is worth failing a page over.
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/** An unguessable id where the platform offers one; see the caveat on the door. */
|
|
153
|
+
function mintId() {
|
|
154
|
+
const webcrypto = globalThis.crypto;
|
|
155
|
+
if (typeof webcrypto?.randomUUID === 'function')
|
|
156
|
+
return webcrypto.randomUUID();
|
|
157
|
+
if (typeof webcrypto?.getRandomValues === 'function') {
|
|
158
|
+
const bytes = webcrypto.getRandomValues(new Uint8Array(16));
|
|
159
|
+
// RFC 4122 version 4, laid out by hand because `randomUUID` is what is
|
|
160
|
+
// missing here, not the randomness.
|
|
161
|
+
bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;
|
|
162
|
+
bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;
|
|
163
|
+
const hex = [...bytes].map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
164
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
165
|
+
}
|
|
166
|
+
// No crypto at all. Not unguessable, and labelled so in the returned value
|
|
167
|
+
// itself rather than only in a doc nobody reads at three in the morning.
|
|
168
|
+
const random = () => Math.random().toString(36).slice(2, 10);
|
|
169
|
+
return `weak-${Date.now().toString(36)}-${random()}${random()}`;
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=browserSession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browserSession.js","sourceRoot":"","sources":["../../../src/hosting/browserSession.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAaH,kFAAkF;AAClF,MAAM,CAAC,MAAM,2BAA2B,GAAG,0BAA0B,CAAC;AAEtE;;;;GAIG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAmC,EAAE;IACpE,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,IAAI,2BAA2B,CAAC;IAC9D,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IACnE,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,OAAO;IACd,IAAI,CAAC;QACH,MAAM,SAAS,GAAI,UAAyC,CAAC,YAAY,CAAC;QAC1E,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,IAAI;YAAE,OAAO,SAAS,CAAC;QACpE,2EAA2E;QAC3E,gCAAgC;QAChC,MAAM,KAAK,GAAG,0BAA0B,CAAC;QACzC,SAAS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