agentfootprint 9.28.0 → 9.30.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 +3 -2
- package/dist/adapters/google/aiPlatform.js +23 -1
- package/dist/adapters/google/aiPlatform.js.map +1 -1
- package/dist/adapters/hosting/googleAgentEngine.js +180 -61
- package/dist/adapters/hosting/googleAgentEngine.js.map +1 -1
- package/dist/adapters/identity/google.js +18 -4
- package/dist/adapters/identity/google.js.map +1 -1
- package/dist/adapters/llm/GeminiProvider.js +198 -36
- package/dist/adapters/llm/GeminiProvider.js.map +1 -1
- package/dist/adapters/llm/OpenAIProvider.js +66 -2
- package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/adapters/llm/googleGenAI.js +155 -8
- package/dist/adapters/llm/googleGenAI.js.map +1 -1
- package/dist/adapters/memory/memoryBank.js +250 -6
- package/dist/adapters/memory/memoryBank.js.map +1 -1
- package/dist/adapters/types.js.map +1 -1
- package/dist/artifacts/gcsArtifacts.js +21 -5
- package/dist/artifacts/gcsArtifacts.js.map +1 -1
- package/dist/embedders/index.js +8 -6
- package/dist/embedders/index.js.map +1 -1
- package/dist/esm/adapters/google/aiPlatform.d.ts +44 -0
- package/dist/esm/adapters/google/aiPlatform.js +23 -1
- package/dist/esm/adapters/google/aiPlatform.js.map +1 -1
- package/dist/esm/adapters/hosting/googleAgentEngine.d.ts +104 -18
- package/dist/esm/adapters/hosting/googleAgentEngine.js +179 -60
- package/dist/esm/adapters/hosting/googleAgentEngine.js.map +1 -1
- package/dist/esm/adapters/identity/google.d.ts +18 -4
- package/dist/esm/adapters/identity/google.js +18 -4
- package/dist/esm/adapters/identity/google.js.map +1 -1
- package/dist/esm/adapters/llm/GeminiProvider.d.ts +96 -15
- package/dist/esm/adapters/llm/GeminiProvider.js +199 -37
- package/dist/esm/adapters/llm/GeminiProvider.js.map +1 -1
- package/dist/esm/adapters/llm/OpenAIProvider.d.ts +34 -2
- package/dist/esm/adapters/llm/OpenAIProvider.js +66 -2
- package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
- package/dist/esm/adapters/llm/googleGenAI.d.ts +105 -4
- package/dist/esm/adapters/llm/googleGenAI.js +152 -7
- package/dist/esm/adapters/llm/googleGenAI.js.map +1 -1
- package/dist/esm/adapters/memory/memoryBank.d.ts +42 -3
- package/dist/esm/adapters/memory/memoryBank.js +249 -5
- package/dist/esm/adapters/memory/memoryBank.js.map +1 -1
- package/dist/esm/adapters/types.d.ts +27 -0
- package/dist/esm/adapters/types.js.map +1 -1
- package/dist/esm/artifacts/gcsArtifacts.d.ts +21 -5
- package/dist/esm/artifacts/gcsArtifacts.js +21 -5
- package/dist/esm/artifacts/gcsArtifacts.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +1 -0
- package/dist/esm/embedders/index.js +9 -7
- package/dist/esm/embedders/index.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +22 -0
- package/dist/esm/hosting-providers.d.ts +4 -2
- package/dist/esm/hosting-providers.js +4 -2
- package/dist/esm/hosting-providers.js.map +1 -1
- package/dist/esm/memory-providers.d.ts +1 -1
- package/dist/esm/memory-providers.js +4 -2
- package/dist/esm/memory-providers.js.map +1 -1
- package/dist/esm/providers.js.map +1 -1
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.js +5 -1
- package/dist/esm/recorders/observability/AgentThinkingTraceRecorder.js.map +1 -1
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.js +44 -3
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
- package/dist/hosting-providers.js +5 -2
- package/dist/hosting-providers.js.map +1 -1
- package/dist/memory-providers.js +5 -2
- package/dist/memory-providers.js.map +1 -1
- package/dist/providers.js.map +1 -1
- package/dist/recorders/observability/AgentThinkingTraceRecorder.js +5 -1
- package/dist/recorders/observability/AgentThinkingTraceRecorder.js.map +1 -1
- package/dist/recorders/observability/commentary/commentaryTemplates.js +44 -3
- package/dist/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
- package/dist/types/adapters/google/aiPlatform.d.ts +44 -0
- package/dist/types/adapters/google/aiPlatform.d.ts.map +1 -1
- package/dist/types/adapters/hosting/googleAgentEngine.d.ts +104 -18
- package/dist/types/adapters/hosting/googleAgentEngine.d.ts.map +1 -1
- package/dist/types/adapters/identity/google.d.ts +18 -4
- package/dist/types/adapters/identity/google.d.ts.map +1 -1
- package/dist/types/adapters/llm/GeminiProvider.d.ts +96 -15
- package/dist/types/adapters/llm/GeminiProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/OpenAIProvider.d.ts +34 -2
- package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
- package/dist/types/adapters/llm/googleGenAI.d.ts +105 -4
- package/dist/types/adapters/llm/googleGenAI.d.ts.map +1 -1
- package/dist/types/adapters/memory/memoryBank.d.ts +42 -3
- package/dist/types/adapters/memory/memoryBank.d.ts.map +1 -1
- package/dist/types/adapters/types.d.ts +27 -0
- package/dist/types/adapters/types.d.ts.map +1 -1
- package/dist/types/artifacts/gcsArtifacts.d.ts +21 -5
- package/dist/types/artifacts/gcsArtifacts.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +1 -0
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/embedders/index.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +22 -0
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/hosting-providers.d.ts +4 -2
- package/dist/types/hosting-providers.d.ts.map +1 -1
- package/dist/types/memory-providers.d.ts +1 -1
- package/dist/types/memory-providers.d.ts.map +1 -1
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/recorders/observability/AgentThinkingTraceRecorder.d.ts.map +1 -1
- package/dist/types/recorders/observability/commentary/commentaryTemplates.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,7 +103,7 @@ const result = await agent.run({ message: 'Weather in Paris?' });
|
|
|
103
103
|
console.log(result); // → "I checked: it is 72°F and sunny."
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
For production, import a real provider from `agentfootprint/providers` and swap it in — `anthropic(...)` / `openai(...)` / `bedrock(...)` / `ollama(...)`. Only the import line changes; the agent code stays the same. (The vendor-SDK providers live on the `agentfootprint/providers` subpath so the main `agentfootprint` barrel stays free of optional peer-dep requires; `mock`, `browserAnthropic`, and `browserOpenai` are on the main barrel.)
|
|
106
|
+
For production, import a real provider from `agentfootprint/providers` and swap it in — `anthropic(...)` / `openai(...)` / `bedrock(...)` / `gemini(...)` / `ollama(...)`. Only the import line changes; the agent code stays the same. (The vendor-SDK providers live on the `agentfootprint/providers` subpath so the main `agentfootprint` barrel stays free of optional peer-dep requires; `mock`, `browserAnthropic`, and `browserOpenai` are on the main barrel.)
|
|
107
107
|
|
|
108
108
|
### Run against a local model — the free rung between the mock and the bill
|
|
109
109
|
|
|
@@ -860,13 +860,14 @@ The flowchart, recorders, and tests don't change between dev and prod.
|
|
|
860
860
|
- 1 reliability gate — `.reliability({ preCheck, postDecide, providers, circuitBreaker, fallback })`
|
|
861
861
|
- 1 tool dispatch primitive — `ToolProvider` (sync OR async) — `staticTools` · `gatedTools` · `skillScopedTools` · or a custom `ToolProvider` that discovers over hubs / MCP / per-tenant catalogs
|
|
862
862
|
|
|
863
|
-
**LLM providers** (
|
|
863
|
+
**LLM providers** (8)
|
|
864
864
|
|
|
865
865
|
| Factory | Use for |
|
|
866
866
|
|---|---|
|
|
867
867
|
| `anthropic` | Claude (Sonnet, Opus, Haiku) via `@anthropic-ai/sdk` |
|
|
868
868
|
| `openai` | GPT-4o, GPT-4-turbo via `openai` SDK |
|
|
869
869
|
| `bedrock` | Claude / Titan / Mistral via AWS Bedrock runtime |
|
|
870
|
+
| `gemini` | Gemini via `@google/genai` — two doors, **Vertex** (project + ADC) or the Gemini API (one key). Not every door/model pair works: read the [door/model matrix](https://footprintjs.github.io/agentfootprint/docs/infrastructure/google-cloud/#the-doormodel-matrix) first |
|
|
870
871
|
| `ollama` | Local models, over Ollama's native API — no SDK, no key, real token counts, refusals that name `ollama serve` / `ollama pull` · `openai({ baseURL })` reaches llama.cpp, vLLM, and any other OpenAI-compatible endpoint |
|
|
871
872
|
| `browserAnthropic` | Browser-side Claude calls (no proxy server) |
|
|
872
873
|
| `browserOpenai` | Browser-side OpenAI calls (no proxy server) |
|
|
@@ -89,7 +89,18 @@ function resolveEngine(adapter, connection) {
|
|
|
89
89
|
if (connection.project !== undefined && connection.project !== project) {
|
|
90
90
|
throw new TypeError(`${adapter}: 'reasoningEngine' names project '${project}' but 'project' says ` +
|
|
91
91
|
`'${connection.project}'. Two spellings of one fact that disagree are refused rather ` +
|
|
92
|
-
`than arbitrated — drop one of them
|
|
92
|
+
`than arbitrated — drop one of them.\n` +
|
|
93
|
+
(looksLikeProjectNumber(project) && !looksLikeProjectNumber(connection.project)
|
|
94
|
+
? ` These may well be the SAME project: Google hands back canonical resource ` +
|
|
95
|
+
`names with the numeric project NUMBER, while you configured the textual project ` +
|
|
96
|
+
`ID. This adapter cannot tell one case from the other without a Resource Manager ` +
|
|
97
|
+
`lookup it deliberately does not make — resolving them as equal on a guess is how ` +
|
|
98
|
+
`one project's conversations end up in another's.\n` +
|
|
99
|
+
` Fix: pass the ENGINE ID alone ('${engineId}') beside your ` +
|
|
100
|
+
`project/location, or pass the full name Google gave you and drop 'project'.\n`
|
|
101
|
+
: '') +
|
|
102
|
+
` A field trial hit exactly this (2026-08-14) after copying an engine's canonical ` +
|
|
103
|
+
`name out of the console.`);
|
|
93
104
|
}
|
|
94
105
|
if (location !== undefined && location !== engineLocation) {
|
|
95
106
|
throw new TypeError(`${adapter}: 'reasoningEngine' names location '${engineLocation}' but 'location' says ` +
|
|
@@ -119,6 +130,17 @@ function resolveEngine(adapter, connection) {
|
|
|
119
130
|
};
|
|
120
131
|
}
|
|
121
132
|
exports.resolveEngine = resolveEngine;
|
|
133
|
+
/**
|
|
134
|
+
* Is this string the numeric project NUMBER rather than the textual project ID?
|
|
135
|
+
*
|
|
136
|
+
* Google accepts either in a resource name and answers with the number, so the
|
|
137
|
+
* two spellings of one project routinely disagree byte for byte. A project ID
|
|
138
|
+
* must start with a letter, so "all digits" separates them without ambiguity.
|
|
139
|
+
* Used only to make the refusal above teach; nothing resolves on it.
|
|
140
|
+
*/
|
|
141
|
+
function looksLikeProjectNumber(value) {
|
|
142
|
+
return /^\d+$/.test(value);
|
|
143
|
+
}
|
|
122
144
|
/** `process.env` without assuming `process` exists (browser bundles do not have one). */
|
|
123
145
|
function readEnv(name) {
|
|
124
146
|
return typeof process !== 'undefined' && process.env ? process.env[name] : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiPlatform.js","sourceRoot":"","sources":["../../../src/adapters/google/aiPlatform.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;;;AAEH,6DAAuD;
|
|
1
|
+
{"version":3,"file":"aiPlatform.js","sourceRoot":"","sources":["../../../src/adapters/google/aiPlatform.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;;;AAEH,6DAAuD;AAqOvD,wEAAwE;AAExE;;;;;;;;;GASG;AACU,QAAA,uBAAuB,GAAG,IAAa,CAAC;AAErD,0DAA0D;AAC7C,QAAA,oBAAoB,GAAG,gDAAgD,CAAC;AAqDrF,MAAM,WAAW,GAAG,oEAAoE,CAAC;AAEzF;;;;;;;;;GASG;AACH,SAAgB,aAAa,CAAC,OAAe,EAAE,UAAgC;IAC7E,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC;IACjD,IAAI,OAAO,eAAe,KAAK,QAAQ,IAAI,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACzE,MAAM,IAAI,SAAS,CACjB,GAAG,OAAO,2EAA2E;YACnF,0CAA0C;YAC1C,oFAAoF;YAC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,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC;QACpC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;AAC/D,CAAC;AATD,kCASC"}
|
|
@@ -15,32 +15,83 @@
|
|
|
15
15
|
* was designed under; where the product name and the API disagree, the API is
|
|
16
16
|
* the one that has not moved.
|
|
17
17
|
*
|
|
18
|
-
* ── The fit, and
|
|
18
|
+
* ── The fit, and the one thing it cost ──────────────────────────────────────
|
|
19
19
|
* `Session.sessionState` is an arbitrary JSON `Struct`. A `CheckpointEnvelope`
|
|
20
20
|
* is arbitrary JSON. So the envelope goes in whole, under one key, and comes
|
|
21
|
-
* back whole — no event log to fold, no blob encoding to get wrong
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* event blob comes back as somebody else's `toString()`.
|
|
21
|
+
* back whole — no event log to fold, no blob encoding to get wrong. What it
|
|
22
|
+
* cost is the WRITE VERB, and that took a field trial to learn: state goes in
|
|
23
|
+
* through an appended EVENT, never through a patch. See fact 2b below.
|
|
25
24
|
*
|
|
26
|
-
* ── The
|
|
25
|
+
* ── The five facts that shaped the code ─────────────────────────────────────
|
|
27
26
|
* 1. **`sessions.create` takes a caller-supplied `sessionId`.** So our session
|
|
28
27
|
* id IS the resource id and `hydrate` is one `get` by name. No mapping
|
|
29
28
|
* table, no listing to find a conversation.
|
|
30
29
|
* 2. **`create` and `delete` answer a long-running Operation; `get` and
|
|
31
|
-
* `
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
30
|
+
* `appendEvent` answer directly.** Every operation-shaped write here waits
|
|
31
|
+
* for `done` before it returns — a `persist` that returned early would make
|
|
32
|
+
* the very next `hydrate` a race whose failure mode is "no conversation",
|
|
33
|
+
* which nobody can tell from a new user.
|
|
34
|
+
*
|
|
35
|
+
* 2b. **`sessionState` CANNOT be patched. This one is field truth, and it cost
|
|
36
|
+
* a release.** 9.29.0 wrote the steady state as
|
|
37
|
+
* `sessions.patch({ updateMask: 'sessionState,ttl' })`, which every
|
|
38
|
+
* injected-client test accepted because a double will patch anything. An
|
|
39
|
+
* independent field trial ran it against the live service (2026-08-14) and
|
|
40
|
+
* found that turn one stored and **every later turn failed**:
|
|
41
|
+
*
|
|
42
|
+
* HTTP 400 — "Can't update the session state for session …, you can only
|
|
43
|
+
* update it by appending an event."
|
|
44
|
+
*
|
|
45
|
+
* A store that keeps the first turn of a conversation and refuses the
|
|
46
|
+
* second is not a session store, so the verb changed rather than the
|
|
47
|
+
* documentation: `persist` now appends a `SessionEvent` whose
|
|
48
|
+
* `actions.stateDelta` carries the envelope, which the same trial verified
|
|
49
|
+
* end to end (append accepted, `GET` returned the new state).
|
|
50
|
+
*
|
|
51
|
+
* Two consequences worth saying out loud, because they are the difference
|
|
52
|
+
* between this fix and a plausible-looking one:
|
|
53
|
+
*
|
|
54
|
+
* • **A state delta MERGES by top-level key.** This store writes exactly
|
|
55
|
+
* one key — {@link SESSION_STATE_KEY} — so "merge the delta" and
|
|
56
|
+
* "replace our key" are the same outcome for us, and another guest's
|
|
57
|
+
* keys under the same session are left alone either way.
|
|
58
|
+
* • **A conversation now has an event log behind it**, one event per
|
|
59
|
+
* persisted turn, because that is the only writing surface the service
|
|
60
|
+
* offers. Nothing here READS that log — `hydrate` still reads the one
|
|
61
|
+
* envelope out of `sessionState` — so the log is the service's audit
|
|
62
|
+
* trail of our writes and never a second copy of the truth. Sessions
|
|
63
|
+
* are per-conversation and events are small; if that growth matters to
|
|
64
|
+
* you, `forget()` deletes the session and its events together.
|
|
35
65
|
* 3. **`Session.userId` is required and immutable.** Our port's
|
|
36
66
|
* `persist(sessionId, envelope)` carries no user, so one has to be
|
|
37
67
|
* resolved — see {@link AgentEngineSessionsOptions.userId}. Immutable
|
|
38
|
-
* means the first write decides forever, which is
|
|
39
|
-
*
|
|
40
|
-
*
|
|
68
|
+
* means the first write decides forever, which is the same ownership rule
|
|
69
|
+
* this library enforces in its own stores.
|
|
70
|
+
*
|
|
71
|
+
* **It is metadata, not authorization, and a field trial proved it.** Two
|
|
72
|
+
* sessions were created under `alice` and `bob`; the project's ordinary ADC
|
|
73
|
+
* principal then read BOTH by name, presenting neither end-user identity
|
|
74
|
+
* (FINDINGS "Native Agent Runtime Sessions"). `userId` is what a listing
|
|
75
|
+
* filters on and what a first write pins — it is not a check the service
|
|
76
|
+
* performs on a read. So the sentence "here the service enforces it for us"
|
|
77
|
+
* would be false: anyone who can call the API with your project's
|
|
78
|
+
* credentials and can guess a session id can read that conversation.
|
|
79
|
+
*
|
|
80
|
+
* Where the check belongs is above this port, and this library already has
|
|
81
|
+
* it: `envelopeOwner` records who a conversation belongs to, and the
|
|
82
|
+
* host/gateway is what must compare that to the authenticated caller
|
|
83
|
+
* before handing a session id down here. This adapter is a STORE. Nothing
|
|
84
|
+
* that only stores can tell an impostor from an owner.
|
|
41
85
|
* 4. **`ttl` is input-only with a 24-hour floor**, and `expireTime` always
|
|
42
|
-
* comes back.
|
|
43
|
-
*
|
|
86
|
+
* comes back. An hour-long TTL is not available at any price.
|
|
87
|
+
*
|
|
88
|
+
* **Sliding expiry is NOT claimed here**, and that changed with fact 2b. A
|
|
89
|
+
* `ttl` is sent on `create`, where the service takes it; later turns append
|
|
90
|
+
* an event, and whether an appended event renews the expiry is a service
|
|
91
|
+
* behaviour nothing in this repository has measured. Rather than send an
|
|
92
|
+
* unverified second call per turn to "refresh" it — a write whose only
|
|
93
|
+
* evidence would be that it did not error — the adapter sends the ttl once
|
|
94
|
+
* and says so. See {@link AgentEngineSessionsOptions.ttl}.
|
|
44
95
|
*
|
|
45
96
|
* ── The laws it inherits rather than re-implements ──────────────────────────
|
|
46
97
|
* `checkEnvelope` runs on the way OUT and on the way IN, so an envelope whose
|
|
@@ -51,7 +102,7 @@
|
|
|
51
102
|
* indistinguishable, from the outside, from a brand-new user.
|
|
52
103
|
*/
|
|
53
104
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.agentEngineSessions = exports.DEFAULT_USER_ID = exports.SESSION_STATE_KEY = void 0;
|
|
105
|
+
exports.agentEngineSessions = exports.SESSION_EVENT_AUTHOR = exports.DEFAULT_USER_ID = exports.SESSION_STATE_KEY = void 0;
|
|
55
106
|
const envelope_js_1 = require("../../hosting/envelope.js");
|
|
56
107
|
const errors_js_1 = require("../../hosting/errors.js");
|
|
57
108
|
const aiPlatform_js_1 = require("../google/aiPlatform.js");
|
|
@@ -68,13 +119,33 @@ const ADAPTER = 'agentEngineSessions';
|
|
|
68
119
|
exports.SESSION_STATE_KEY = 'agentfootprint.envelope';
|
|
69
120
|
/** What a conversation that named nobody is stored under. */
|
|
70
121
|
exports.DEFAULT_USER_ID = 'agentfootprint-anonymous';
|
|
122
|
+
/**
|
|
123
|
+
* The `author` on every event this store appends, unless
|
|
124
|
+
* {@link AgentEngineSessionsOptions.eventAuthor} names another.
|
|
125
|
+
*
|
|
126
|
+
* The service requires the field and treats it as free text. This name says
|
|
127
|
+
* which library wrote the turn, which is the useful thing to see in the console
|
|
128
|
+
* beside somebody else's agent writing to the same engine.
|
|
129
|
+
*/
|
|
130
|
+
exports.SESSION_EVENT_AUTHOR = 'agentfootprint';
|
|
71
131
|
/**
|
|
72
132
|
* Conversations in Vertex AI's session service — the store that survives a
|
|
73
133
|
* fleet, not just a restart.
|
|
74
134
|
*
|
|
75
|
-
* **Status:
|
|
76
|
-
*
|
|
77
|
-
*
|
|
135
|
+
* **Status: field-validated except the write verb, which is field-CORRECTED.**
|
|
136
|
+
* An independent trial ran this adapter against a live Agent Runtime engine
|
|
137
|
+
* (2026-08-14) and everything below answered a real request from Google:
|
|
138
|
+
* creating first-turn sessions from real envelopes, hydrating them through a
|
|
139
|
+
* fresh instance, owners preserved, paged `listByUser` filtering, `ownerOf`,
|
|
140
|
+
* an unknown envelope format refused before storage, and idempotent `forget`.
|
|
141
|
+
*
|
|
142
|
+
* The one thing that FAILED was the second write to an existing session — the
|
|
143
|
+
* core job — because 9.29.0 patched `sessionState` and the service refuses
|
|
144
|
+
* that. The trial recovered the service's own words and verified the repair
|
|
145
|
+
* path (`appendEvent` with `actions.stateDelta`, then a `GET` showing the new
|
|
146
|
+
* state) with a raw diagnostic. This adapter now uses that verb; the repair is
|
|
147
|
+
* built on measured service behaviour and tested here, but the corrected write
|
|
148
|
+
* has not itself been re-run through this adapter in a live project.
|
|
78
149
|
*
|
|
79
150
|
* @example A standing agent whose conversations are shared across instances
|
|
80
151
|
* import { standingAgent, nodeHost } from 'agentfootprint/hosting';
|
|
@@ -105,6 +176,60 @@ function agentEngineSessions(options) {
|
|
|
105
176
|
`bug rather than surface it. Build a new store if you need one after closing this.`);
|
|
106
177
|
};
|
|
107
178
|
const nameOf = (sessionId) => `${scope.parent}/sessions/${(0, aiPlatform_js_1.safeResourceId)(sessionId)}`;
|
|
179
|
+
/**
|
|
180
|
+
* Does a session by this name exist? Asked ONLY to tell "there is nothing to
|
|
181
|
+
* append to" apart from "the append itself was refused".
|
|
182
|
+
*
|
|
183
|
+
* The live trial proved the two ends of the write path — `create` stores a
|
|
184
|
+
* new conversation, `appendEvent` updates an existing one — and left the
|
|
185
|
+
* middle unmeasured: what the service answers when you append to a session
|
|
186
|
+
* that is not there. Branching on an assumed 404 would put the FIRST turn of
|
|
187
|
+
* every conversation on a guess. So a failed append asks the resource itself,
|
|
188
|
+
* which is a fact rather than a convention, and costs one call on the one
|
|
189
|
+
* turn where the append was never going to work anyway.
|
|
190
|
+
*/
|
|
191
|
+
const missing = async (name) => {
|
|
192
|
+
try {
|
|
193
|
+
await sessions.get({ name });
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
catch (err) {
|
|
197
|
+
// Anything that is not a clean "no such session" leaves the append's own
|
|
198
|
+
// failure standing — it is the one that says what went wrong.
|
|
199
|
+
return (0, aiPlatform_js_1.isNotFound)(err);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Write the envelope onto an EXISTING session, as one appended event.
|
|
204
|
+
*
|
|
205
|
+
* Answers `false` — rather than raising — for the one case the caller has a
|
|
206
|
+
* repair for: there is no session here yet, so it has to be created.
|
|
207
|
+
*/
|
|
208
|
+
const append = async (name, stateDelta) => {
|
|
209
|
+
try {
|
|
210
|
+
await sessions.appendEvent({
|
|
211
|
+
name,
|
|
212
|
+
requestBody: {
|
|
213
|
+
author: options.eventAuthor ?? exports.SESSION_EVENT_AUTHOR,
|
|
214
|
+
// Required, and one per persisted turn. It groups the events of one
|
|
215
|
+
// invocation on the service's side; this store writes exactly one
|
|
216
|
+
// event per turn, so a fresh id per call is the honest grouping.
|
|
217
|
+
invocationId: newInvocationId(),
|
|
218
|
+
timestamp: new Date().toISOString(),
|
|
219
|
+
// ONE top-level key — see the module header. A state delta merges by
|
|
220
|
+
// top-level key, so this replaces our envelope and touches nothing
|
|
221
|
+
// else in the struct.
|
|
222
|
+
actions: { stateDelta },
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
catch (err) {
|
|
228
|
+
if ((0, aiPlatform_js_1.isNotFound)(err) || (await missing(name)))
|
|
229
|
+
return false;
|
|
230
|
+
throw (0, aiPlatform_js_1.googleSdkFailure)(ADAPTER, 'sessions.appendEvent', err);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
108
233
|
return {
|
|
109
234
|
parent: scope.parent,
|
|
110
235
|
async hydrate(sessionId) {
|
|
@@ -147,54 +272,42 @@ function agentEngineSessions(options) {
|
|
|
147
272
|
// read back is one it has no business writing.
|
|
148
273
|
const checked = (0, envelope_js_1.checkEnvelope)(envelope, sessionId);
|
|
149
274
|
const name = nameOf(sessionId);
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
...(options.ttl !== undefined && { ttl: options.ttl }),
|
|
153
|
-
};
|
|
154
|
-
// PATCH first, CREATE on 404 — rather than the other way round.
|
|
275
|
+
const state = { [exports.SESSION_STATE_KEY]: checked };
|
|
276
|
+
// APPEND first, CREATE when there is no session to append to.
|
|
155
277
|
//
|
|
156
|
-
// The steady state of a conversation is "it already exists":
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
// Only the fields we own. Without a mask a patch is a REPLACE, and a
|
|
165
|
-
// replace would drop `userId` — which is immutable, so the service
|
|
166
|
-
// would refuse the write and a conversation would stop persisting.
|
|
167
|
-
updateMask: maskFor(body),
|
|
168
|
-
requestBody: body,
|
|
169
|
-
});
|
|
278
|
+
// The steady state of a conversation is "it already exists": created
|
|
279
|
+
// once, written on every turn after that. So the ordinary turn costs one
|
|
280
|
+
// call, and the extra call is paid on turn one only.
|
|
281
|
+
//
|
|
282
|
+
// Appending — not patching. `sessions.patch` with a `sessionState` mask is
|
|
283
|
+
// refused by the live service (module header, fact 2b); it is the verb
|
|
284
|
+
// 9.29.0 used and the reason a second turn could not be stored.
|
|
285
|
+
if (await append(name, state))
|
|
170
286
|
return;
|
|
171
|
-
}
|
|
172
|
-
catch (err) {
|
|
173
|
-
if (!(0, aiPlatform_js_1.isNotFound)(err))
|
|
174
|
-
throw (0, aiPlatform_js_1.googleSdkFailure)(ADAPTER, 'sessions.patch', err);
|
|
175
|
-
}
|
|
176
287
|
const userId = resolveUserId(sessionId, checked);
|
|
177
288
|
let created;
|
|
178
289
|
try {
|
|
179
290
|
created = await sessions.create({
|
|
180
291
|
parent: scope.parent,
|
|
181
292
|
sessionId: (0, aiPlatform_js_1.safeResourceId)(sessionId),
|
|
182
|
-
requestBody: {
|
|
293
|
+
requestBody: {
|
|
294
|
+
sessionState: state,
|
|
295
|
+
...(options.ttl !== undefined && { ttl: options.ttl }),
|
|
296
|
+
userId,
|
|
297
|
+
},
|
|
183
298
|
});
|
|
184
299
|
}
|
|
185
300
|
catch (err) {
|
|
186
301
|
// Two writers opened the same conversation at once and the other one
|
|
187
302
|
// won. That is not a failure: the session exists now, which is all
|
|
188
|
-
// this call wanted, so
|
|
303
|
+
// this call wanted, so our state goes on with the same appended event.
|
|
189
304
|
if (!(0, aiPlatform_js_1.isAlreadyExists)(err))
|
|
190
305
|
throw (0, aiPlatform_js_1.googleSdkFailure)(ADAPTER, 'sessions.create', err);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
return;
|
|
306
|
+
if (await append(name, state))
|
|
307
|
+
return;
|
|
308
|
+
// Created by somebody and gone again before we could write to it.
|
|
309
|
+
// Nothing here can say this turn landed, so it does not say it.
|
|
310
|
+
throw (0, aiPlatform_js_1.googleSdkFailure)(ADAPTER, 'sessions.create', err);
|
|
198
311
|
}
|
|
199
312
|
// OUTSIDE the try on purpose: this refusal is already sanitized and
|
|
200
313
|
// already says what to do, and re-wrapping it would replace a precise
|
|
@@ -338,17 +451,23 @@ function userIdResolver(option) {
|
|
|
338
451
|
return (_sessionId, envelope) => (0, envelope_js_1.envelopeOwner)(envelope) ?? exports.DEFAULT_USER_ID;
|
|
339
452
|
}
|
|
340
453
|
/**
|
|
341
|
-
*
|
|
454
|
+
* A fresh `invocationId` for one appended event.
|
|
455
|
+
*
|
|
456
|
+
* The field is required and groups the events of one invocation on the
|
|
457
|
+
* service's side. This store writes exactly one event per persisted turn, so a
|
|
458
|
+
* new id per call is what that grouping honestly is — reusing one across turns
|
|
459
|
+
* would tell the console that a whole conversation was a single invocation.
|
|
342
460
|
*
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
461
|
+
* `randomUUID` where the runtime has it, and a time-plus-random id where it
|
|
462
|
+
* does not: this is a correlation label, not a security value, and an adapter
|
|
463
|
+
* that threw on an old runtime because a label could not be minted would be
|
|
464
|
+
* failing a conversation over nothing.
|
|
346
465
|
*/
|
|
347
|
-
function
|
|
348
|
-
const
|
|
349
|
-
if (
|
|
350
|
-
|
|
351
|
-
return
|
|
466
|
+
function newInvocationId() {
|
|
467
|
+
const uuid = globalThis.crypto?.randomUUID;
|
|
468
|
+
if (typeof uuid === 'function')
|
|
469
|
+
return `af-${uuid.call(globalThis.crypto)}`;
|
|
470
|
+
return `af-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
352
471
|
}
|
|
353
472
|
/** The id out of a resource name, which is everything after the last `/`. */
|
|
354
473
|
function lastSegment(name) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"googleAgentEngine.js","sourceRoot":"","sources":["../../../src/adapters/hosting/googleAgentEngine.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"googleAgentEngine.js","sourceRoot":"","sources":["../../../src/adapters/hosting/googleAgentEngine.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqGG;;;AAEH,2DAA6F;AAC7F,uDAAkE;AAOlE,2DAciC;AAEjC,MAAM,OAAO,GAAG,qBAAqB,CAAC;AAEtC;;;;;;;;GAQG;AACU,QAAA,iBAAiB,GAAG,yBAAyB,CAAC;AA+D3D,6DAA6D;AAChD,QAAA,eAAe,GAAG,0BAA0B,CAAC;AAE1D;;;;;;;GAOG;AACU,QAAA,oBAAoB,GAAG,gBAAgB,CAAC;AA0BrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,mBAAmB,CAAC,OAAmC;IACrE,MAAM,KAAK,GAAgB,IAAA,6BAAa,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAyB,IAAA,q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CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,6EAA6E;AAC7E,SAAS,QAAQ,CAAC,MAAe;IAC/B,MAAM,MAAM,GAAI,MAA2C,EAAE,MAAM,CAAC;IACpE,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC"}
|
|
@@ -65,10 +65,24 @@ exports.CLOUD_PLATFORM_SCOPE = 'https://www.googleapis.com/auth/cloud-platform';
|
|
|
65
65
|
/**
|
|
66
66
|
* Vend Google access tokens from whatever credential this environment has.
|
|
67
67
|
*
|
|
68
|
-
* **Status:
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
68
|
+
* **Status: field-validated for machine identity; refresh bounded.** An
|
|
69
|
+
* independent trial ran this adapter on live Google Cloud (2026-08-14):
|
|
70
|
+
* `googleIdentity({ services: ['aiplatform'] })` vended a real bearer
|
|
71
|
+
* credential from Application Default Credentials, and that credential
|
|
72
|
+
* authorized a Vertex AI request with HTTP 200. The same run proved the
|
|
73
|
+
* `bearer` kind, an expiry about 3,599 seconds out, a second vend without
|
|
74
|
+
* reconstruction, `mode: 'user'` failing CLOSED rather than quietly handing
|
|
75
|
+
* back machine access, a disallowed service failing closed, and
|
|
76
|
+
* `JSON.stringify(credential)` yielding `{"kind":"bearer"}` — no token, no
|
|
77
|
+
* Authorization header.
|
|
78
|
+
*
|
|
79
|
+
* **What is NOT proven:** an expiry-triggered refresh. The trial called the
|
|
80
|
+
* provider twice minutes apart and checked a future expiry; it did not wait an
|
|
81
|
+
* hour. Google's own auth client is what refreshes (this adapter caches the
|
|
82
|
+
* CLIENT, never a token — see {@link CachedGoogleClient}), and that refresh was
|
|
83
|
+
* field-proved on a different door (`gemini({ googleAuthOptions })`). A soak or
|
|
84
|
+
* a controlled expiring-credential double is still owed before anyone claims
|
|
85
|
+
* long-duration production proof for THIS provider.
|
|
72
86
|
*
|
|
73
87
|
* @throws when `mode: 'user'` is requested — Google's per-user token vault has
|
|
74
88
|
* no Node surface, and a machine token returned in its place would be a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.js","sourceRoot":"","sources":["../../../src/adapters/identity/google.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;;;AAEH,6DAAuD;AACvD,sDAAiD;AAOjD,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAEjC,2DAA2D;AAC9C,QAAA,oBAAoB,GAAG,gDAAgD,CAAC;AAwGrF
|
|
1
|
+
{"version":3,"file":"google.js","sourceRoot":"","sources":["../../../src/adapters/identity/google.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;;;AAEH,6DAAuD;AACvD,sDAAiD;AAOjD,MAAM,OAAO,GAAG,gBAAgB,CAAC;AAEjC,2DAA2D;AAC9C,QAAA,oBAAoB,GAAG,gDAAgD,CAAC;AAwGrF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,SAAgB,cAAc,CAAC,UAAiC,EAAE;IAChE,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,4BAAoB,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvF,MAAM,KAAK,GAAuB,EAAE,CAAC;IAErC,MAAM,SAAS,GAAG,CAAC,MAAyB,EAAiC,EAAE;QAC7E,+DAA+D;QAC/D,2EAA2E;QAC3E,0EAA0E;QAC1E,2DAA2D;QAC3D,IAAI,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC;YACtC,OAAO,CAAC,KAAK,CAA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