melchizedek-agents 1.0.0 → 1.0.1
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/CHANGELOG.md +16 -0
- package/package.json +2 -2
- package/dist/lib/adkPeer.d.ts +0 -63
- package/dist/lib/adkPeer.js +0 -240
- package/dist/lib/compileAdk.d.ts +0 -32
- package/dist/lib/compileAdk.js +0 -142
- package/dist/lib/models/adkGeminiAdapter.d.ts +0 -90
- package/dist/lib/models/adkGeminiAdapter.js +0 -369
- package/dist/lib/models/adkShim.d.ts +0 -111
- package/dist/lib/models/adkShim.js +0 -136
- package/dist/lib/models/claudeLlm.d.ts +0 -79
- package/dist/lib/models/claudeLlm.js +0 -87
- package/dist/lib/models/fallback.d.ts +0 -48
- package/dist/lib/models/fallback.js +0 -116
- package/dist/lib/models/gatewayLlm.d.ts +0 -36
- package/dist/lib/models/gatewayLlm.js +0 -44
- package/dist/lib/models/gptLlm.d.ts +0 -99
- package/dist/lib/models/gptLlm.js +0 -129
- package/dist/lib/models/grokLlm.d.ts +0 -50
- package/dist/lib/models/grokLlm.js +0 -56
- package/dist/lib/models/kimiLlm.d.ts +0 -31
- package/dist/lib/models/kimiLlm.js +0 -35
- package/dist/lib/models/ollamaLlm.d.ts +0 -37
- package/dist/lib/models/ollamaLlm.js +0 -42
- package/dist/lib/models/openAiCompatibleLlm.d.ts +0 -96
- package/dist/lib/models/openAiCompatibleLlm.js +0 -156
- package/dist/lib/models/tracedGemini.d.ts +0 -41
- package/dist/lib/models/tracedGemini.js +0 -98
- package/dist/lib/runtime/adkMemoryBridge.d.ts +0 -46
- package/dist/lib/runtime/adkMemoryBridge.js +0 -68
- package/dist/lib/runtime/adkSessionBridge.d.ts +0 -78
- package/dist/lib/runtime/adkSessionBridge.js +0 -176
- package/dist/lib/tools/adkTool.d.ts +0 -81
- package/dist/lib/tools/adkTool.js +0 -268
- package/dist/lib/tools/collectionsSearchTool.d.ts +0 -56
- package/dist/lib/tools/collectionsSearchTool.js +0 -71
- package/dist/lib/tools/urlContextTool.d.ts +0 -32
- package/dist/lib/tools/urlContextTool.js +0 -43
- package/dist/lib/tools/webSearchTool.d.ts +0 -51
- package/dist/lib/tools/webSearchTool.js +0 -82
- package/dist/lib/tools/xSearchTool.d.ts +0 -59
- package/dist/lib/tools/xSearchTool.js +0 -74
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,22 @@ the starter pack and the templates), not the repo's full history.
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
## 1.0.1 — 2026-10-08
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **The published package carries only this release's build.** `npm run
|
|
14
|
+
build` (which `npm pack` and `npm publish` run) now empties `dist/`
|
|
15
|
+
before compiling. 1.0.0 was packed from a checkout whose `dist/` still
|
|
16
|
+
held files from older builds, so its tarball carried 40 stale modules the
|
|
17
|
+
1.0.0 source no longer has (among them `models/adkShim`, the ADK
|
|
18
|
+
`*Llm` classes, `models/tracedGemini`, `models/fallback`,
|
|
19
|
+
`tools/adkTool`, `tools/webSearchTool`, `runtime/adkSessionBridge`).
|
|
20
|
+
The `./models/*` and `./tools/*` export patterns made them importable,
|
|
21
|
+
and they load `@google/adk`, which 1.0.0 removed. Everything 1.0.0
|
|
22
|
+
documents was built from its own source; only those extra files were
|
|
23
|
+
wrong. Use 1.0.1; 1.0.0 is deprecated.
|
|
24
|
+
|
|
9
25
|
## 1.0.0 — 2026-10-08
|
|
10
26
|
|
|
11
27
|
Release 1.0.0: Google ADK is gone (ADR 0107). Every turn runs on the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "melchizedek-agents",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "A multi-model, multi-agent orchestration framework — YAML-defined syndicates on the engine's own agent loop, Supabase or Postgres session persistence, pgvector long-term memory. Companion repo to the lyceumagents.com curriculum.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"skills"
|
|
73
73
|
],
|
|
74
74
|
"scripts": {
|
|
75
|
-
"build": "tsc -p tsconfig.build.json",
|
|
75
|
+
"build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json",
|
|
76
76
|
"prepack": "npm run build",
|
|
77
77
|
"prepare": "npm run build",
|
|
78
78
|
"prepublishOnly": "npm test",
|
package/dist/lib/adkPeer.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* lib/adkPeer.ts — @google/adk as an optional peer (ADR 0102).
|
|
3
|
-
*
|
|
4
|
-
* WHY this file exists:
|
|
5
|
-
* From 0.20.0 the native runtime is the default, and @google/adk is needed
|
|
6
|
-
* only for MELCHIZEDEK_RUNTIME=adk and the features only ADK runs. Until
|
|
7
|
-
* 1.0.0 removes ADK (ADR 0045), the engine's objects still carry an ADK
|
|
8
|
-
* face: the tool registry holds FunctionTools that carry their own Tool,
|
|
9
|
-
* the model shims are BaseLlm classes that carry their contract adapter,
|
|
10
|
-
* and the durable session stores are ADK BaseSessionServices as well as
|
|
11
|
-
* the engine's SessionService. Those classes extend ADK's at load time.
|
|
12
|
-
*
|
|
13
|
-
* This module is the one place the package loads ADK. It tries once, when
|
|
14
|
-
* it is first imported, and every other module takes ADK's values from
|
|
15
|
-
* here, never from '@google/adk' directly (a type-only import is fine):
|
|
16
|
-
* - When ADK is installed, each export below IS ADK's own value, so the
|
|
17
|
-
* ADK runtime, `instanceof` and ADK's registry behave exactly as before.
|
|
18
|
-
* - When it is not, the base classes are stand-ins: they construct as
|
|
19
|
-
* ADK's do (a tool's name, a model's id, a toolset's filter) and carry
|
|
20
|
-
* ADK's own Symbol.for marks, so the engine reads them as it reads ADK's,
|
|
21
|
-
* and every method only ADK calls throws AdkNotInstalledError, which
|
|
22
|
-
* names the package. Everything else (`Runner`, `LlmAgent`, the plugins)
|
|
23
|
-
* is reached through requireAdk(feature), which throws the same error.
|
|
24
|
-
*
|
|
25
|
-
* A package that is installed but fails to load for another reason (a
|
|
26
|
-
* missing dependency of its own, a syntax error) is not "absent": that
|
|
27
|
-
* error is rethrown, so nothing hides a broken install.
|
|
28
|
-
*
|
|
29
|
-
* The load is a top-level await of a dynamic import: an ES module cannot
|
|
30
|
-
* load another synchronously, and the exported classes must exist before
|
|
31
|
-
* any subclass is defined.
|
|
32
|
-
*/
|
|
33
|
-
import type * as AdkModule from '@google/adk';
|
|
34
|
-
/** The package this module loads. */
|
|
35
|
-
export declare const ADK_PACKAGE = "@google/adk";
|
|
36
|
-
/** @google/adk's module namespace, as its types describe it. */
|
|
37
|
-
export type Adk = typeof AdkModule;
|
|
38
|
-
/** ADK's module when it is installed, else undefined. */
|
|
39
|
-
export declare const adk: Adk | undefined;
|
|
40
|
-
/** Whether @google/adk is installed and loaded. */
|
|
41
|
-
export declare function adkInstalled(): boolean;
|
|
42
|
-
/** The installed @google/adk version, read from its package.json, or undefined when it is not installed. */
|
|
43
|
-
export declare function adkVersion(): Promise<string | undefined>;
|
|
44
|
-
/** A feature only ADK runs was used without @google/adk installed. */
|
|
45
|
-
export declare class AdkNotInstalledError extends Error {
|
|
46
|
-
readonly feature: string;
|
|
47
|
-
constructor(feature: string);
|
|
48
|
-
}
|
|
49
|
-
/** ADK's module, or AdkNotInstalledError naming `feature` when it is not installed. */
|
|
50
|
-
export declare function requireAdk(feature: string): Adk;
|
|
51
|
-
export declare const BaseTool: Adk['BaseTool'];
|
|
52
|
-
export type BaseTool = AdkModule.BaseTool;
|
|
53
|
-
export declare const FunctionTool: Adk['FunctionTool'];
|
|
54
|
-
export type FunctionTool<TParameters extends AdkModule.ToolInputParameters = undefined> = AdkModule.FunctionTool<TParameters>;
|
|
55
|
-
export declare const BaseToolset: Adk['BaseToolset'];
|
|
56
|
-
export type BaseToolset = AdkModule.BaseToolset;
|
|
57
|
-
export declare const BaseLlm: Adk['BaseLlm'];
|
|
58
|
-
export type BaseLlm = AdkModule.BaseLlm;
|
|
59
|
-
export declare const Gemini: Adk['Gemini'];
|
|
60
|
-
export type Gemini = AdkModule.Gemini;
|
|
61
|
-
export declare const BaseSessionService: Adk['BaseSessionService'];
|
|
62
|
-
export type BaseSessionService = AdkModule.BaseSessionService;
|
|
63
|
-
export declare const GOOGLE_SEARCH: Adk['GOOGLE_SEARCH'];
|
package/dist/lib/adkPeer.js
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* lib/adkPeer.ts — @google/adk as an optional peer (ADR 0102).
|
|
3
|
-
*
|
|
4
|
-
* WHY this file exists:
|
|
5
|
-
* From 0.20.0 the native runtime is the default, and @google/adk is needed
|
|
6
|
-
* only for MELCHIZEDEK_RUNTIME=adk and the features only ADK runs. Until
|
|
7
|
-
* 1.0.0 removes ADK (ADR 0045), the engine's objects still carry an ADK
|
|
8
|
-
* face: the tool registry holds FunctionTools that carry their own Tool,
|
|
9
|
-
* the model shims are BaseLlm classes that carry their contract adapter,
|
|
10
|
-
* and the durable session stores are ADK BaseSessionServices as well as
|
|
11
|
-
* the engine's SessionService. Those classes extend ADK's at load time.
|
|
12
|
-
*
|
|
13
|
-
* This module is the one place the package loads ADK. It tries once, when
|
|
14
|
-
* it is first imported, and every other module takes ADK's values from
|
|
15
|
-
* here, never from '@google/adk' directly (a type-only import is fine):
|
|
16
|
-
* - When ADK is installed, each export below IS ADK's own value, so the
|
|
17
|
-
* ADK runtime, `instanceof` and ADK's registry behave exactly as before.
|
|
18
|
-
* - When it is not, the base classes are stand-ins: they construct as
|
|
19
|
-
* ADK's do (a tool's name, a model's id, a toolset's filter) and carry
|
|
20
|
-
* ADK's own Symbol.for marks, so the engine reads them as it reads ADK's,
|
|
21
|
-
* and every method only ADK calls throws AdkNotInstalledError, which
|
|
22
|
-
* names the package. Everything else (`Runner`, `LlmAgent`, the plugins)
|
|
23
|
-
* is reached through requireAdk(feature), which throws the same error.
|
|
24
|
-
*
|
|
25
|
-
* A package that is installed but fails to load for another reason (a
|
|
26
|
-
* missing dependency of its own, a syntax error) is not "absent": that
|
|
27
|
-
* error is rethrown, so nothing hides a broken install.
|
|
28
|
-
*
|
|
29
|
-
* The load is a top-level await of a dynamic import: an ES module cannot
|
|
30
|
-
* load another synchronously, and the exported classes must exist before
|
|
31
|
-
* any subclass is defined.
|
|
32
|
-
*/
|
|
33
|
-
/** The package this module loads. */
|
|
34
|
-
export const ADK_PACKAGE = '@google/adk';
|
|
35
|
-
/** Whether `err` says the package itself could not be found (and not a module it imports). */
|
|
36
|
-
function isMissingPackage(err) {
|
|
37
|
-
const e = err;
|
|
38
|
-
if (!e || typeof e !== 'object')
|
|
39
|
-
return false;
|
|
40
|
-
if (e.code !== 'ERR_MODULE_NOT_FOUND' && e.code !== 'MODULE_NOT_FOUND')
|
|
41
|
-
return false;
|
|
42
|
-
return typeof e.message === 'string' && e.message.includes(`'${ADK_PACKAGE}'`);
|
|
43
|
-
}
|
|
44
|
-
let loaded;
|
|
45
|
-
try {
|
|
46
|
-
loaded = await import('@google/adk');
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
if (!isMissingPackage(err))
|
|
50
|
-
throw err;
|
|
51
|
-
}
|
|
52
|
-
/** ADK's module when it is installed, else undefined. */
|
|
53
|
-
export const adk = loaded;
|
|
54
|
-
/** Whether @google/adk is installed and loaded. */
|
|
55
|
-
export function adkInstalled() {
|
|
56
|
-
return loaded !== undefined;
|
|
57
|
-
}
|
|
58
|
-
/** The installed @google/adk version, read from its package.json, or undefined when it is not installed. */
|
|
59
|
-
export async function adkVersion() {
|
|
60
|
-
if (!loaded)
|
|
61
|
-
return undefined;
|
|
62
|
-
try {
|
|
63
|
-
const { createRequire } = await import('node:module');
|
|
64
|
-
const require = createRequire(import.meta.url);
|
|
65
|
-
const fs = await import('node:fs');
|
|
66
|
-
const path = await import('node:path');
|
|
67
|
-
// The package's exports map hides package.json, so walk up from its entry.
|
|
68
|
-
let dir = path.dirname(require.resolve(ADK_PACKAGE));
|
|
69
|
-
for (let i = 0; i < 6; i++) {
|
|
70
|
-
const file = path.join(dir, 'package.json');
|
|
71
|
-
if (fs.existsSync(file)) {
|
|
72
|
-
const pkg = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
73
|
-
if (pkg.name === ADK_PACKAGE)
|
|
74
|
-
return pkg.version;
|
|
75
|
-
}
|
|
76
|
-
dir = path.dirname(dir);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
// Unreadable: the version is unknown, not the package absent.
|
|
81
|
-
}
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
/** A feature only ADK runs was used without @google/adk installed. */
|
|
85
|
-
export class AdkNotInstalledError extends Error {
|
|
86
|
-
feature;
|
|
87
|
-
constructor(feature) {
|
|
88
|
-
super(`${feature} needs ${ADK_PACKAGE}, which is not installed. ` +
|
|
89
|
-
`Install it beside melchizedek-agents (npm install ${ADK_PACKAGE}@~2.2.0), ` +
|
|
90
|
-
`or run on the native runtime (the default; unset MELCHIZEDEK_RUNTIME or set it to native).`);
|
|
91
|
-
this.name = 'AdkNotInstalledError';
|
|
92
|
-
this.feature = feature;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/** ADK's module, or AdkNotInstalledError naming `feature` when it is not installed. */
|
|
96
|
-
export function requireAdk(feature) {
|
|
97
|
-
if (!loaded)
|
|
98
|
-
throw new AdkNotInstalledError(feature);
|
|
99
|
-
return loaded;
|
|
100
|
-
}
|
|
101
|
-
// ── Stand-ins for ADK's base classes ─────────────────────────────────────────
|
|
102
|
-
//
|
|
103
|
-
// Each matches the ADK constructor's effect on the instance and ADK's
|
|
104
|
-
// Symbol.for mark, nothing more. They exist only when ADK is not installed.
|
|
105
|
-
const BASE_TOOL = Symbol.for('google.adk.baseTool');
|
|
106
|
-
const IN_MODEL_TOOL = Symbol.for('google.adk.inModelTool');
|
|
107
|
-
const FUNCTION_TOOL = Symbol.for('google.adk.functionTool');
|
|
108
|
-
const BASE_TOOLSET = Symbol.for('google.adk.baseToolset');
|
|
109
|
-
const BASE_MODEL = Symbol.for('google.adk.baseModel');
|
|
110
|
-
const GEMINI_MODEL = Symbol.for('google.adk.geminiModel');
|
|
111
|
-
function adkOnly(what) {
|
|
112
|
-
throw new AdkNotInstalledError(what);
|
|
113
|
-
}
|
|
114
|
-
class MissingBaseTool {
|
|
115
|
-
[BASE_TOOL] = true;
|
|
116
|
-
name;
|
|
117
|
-
description;
|
|
118
|
-
isLongRunning;
|
|
119
|
-
constructor(params) {
|
|
120
|
-
this.name = params.name;
|
|
121
|
-
this.description = params.description;
|
|
122
|
-
this.isLongRunning = params.isLongRunning ?? false;
|
|
123
|
-
}
|
|
124
|
-
_getDeclaration() {
|
|
125
|
-
return undefined;
|
|
126
|
-
}
|
|
127
|
-
async checkRequireConfirmation() {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
async processLlmRequest(_request) {
|
|
131
|
-
adkOnly(`The ADK face of the tool '${this.name}'`);
|
|
132
|
-
}
|
|
133
|
-
async runAsync(_request) {
|
|
134
|
-
return adkOnly(`The ADK face of the tool '${this.name}'`);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
class MissingFunctionTool extends MissingBaseTool {
|
|
138
|
-
[FUNCTION_TOOL] = true;
|
|
139
|
-
execute;
|
|
140
|
-
parameters;
|
|
141
|
-
requireConfirmation;
|
|
142
|
-
constructor(options) {
|
|
143
|
-
const name = options.name ?? options.execute.name;
|
|
144
|
-
if (!name)
|
|
145
|
-
throw new Error('Tool name cannot be empty. Either name the `execute` function or provide a `name`.');
|
|
146
|
-
super({ name, description: options.description, isLongRunning: options.isLongRunning });
|
|
147
|
-
this.execute = options.execute;
|
|
148
|
-
this.parameters = options.parameters;
|
|
149
|
-
this.requireConfirmation = options.requireConfirmation ?? false;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
class MissingBaseToolset {
|
|
153
|
-
[BASE_TOOLSET] = true;
|
|
154
|
-
toolFilter;
|
|
155
|
-
prefix;
|
|
156
|
-
constructor(toolFilter, prefix) {
|
|
157
|
-
this.toolFilter = toolFilter;
|
|
158
|
-
this.prefix = prefix;
|
|
159
|
-
}
|
|
160
|
-
async getTools() {
|
|
161
|
-
return adkOnly('An ADK toolset');
|
|
162
|
-
}
|
|
163
|
-
async close() { }
|
|
164
|
-
}
|
|
165
|
-
class MissingBaseLlm {
|
|
166
|
-
[BASE_MODEL] = true;
|
|
167
|
-
model;
|
|
168
|
-
static supportedModels = [];
|
|
169
|
-
constructor({ model }) {
|
|
170
|
-
this.model = model;
|
|
171
|
-
}
|
|
172
|
-
generateContentAsync() {
|
|
173
|
-
return adkOnly(`The ADK face of the model '${this.model}'`);
|
|
174
|
-
}
|
|
175
|
-
async connect() {
|
|
176
|
-
return adkOnly(`The ADK face of the model '${this.model}'`);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* ADK's Gemini, absent: it holds what a caller gave it (the model, a key,
|
|
181
|
-
* Vertex AI's settings), as ADK's does, so the native runtime reads it as it
|
|
182
|
-
* reads TracedGemini (lib/compileNative.ts). Calling it throws.
|
|
183
|
-
*/
|
|
184
|
-
class MissingGemini extends MissingBaseLlm {
|
|
185
|
-
[GEMINI_MODEL] = true;
|
|
186
|
-
apiKey;
|
|
187
|
-
vertexai;
|
|
188
|
-
project;
|
|
189
|
-
location;
|
|
190
|
-
headers;
|
|
191
|
-
constructor(params) {
|
|
192
|
-
super({ model: params.model ?? 'gemini-2.5-flash' });
|
|
193
|
-
if (params.apiKey !== undefined)
|
|
194
|
-
this.apiKey = params.apiKey;
|
|
195
|
-
if (params.vertexai !== undefined)
|
|
196
|
-
this.vertexai = params.vertexai;
|
|
197
|
-
if (params.project !== undefined)
|
|
198
|
-
this.project = params.project;
|
|
199
|
-
if (params.location !== undefined)
|
|
200
|
-
this.location = params.location;
|
|
201
|
-
if (params.headers !== undefined)
|
|
202
|
-
this.headers = params.headers;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* ADK's session service base, absent. A store that extends it is still the
|
|
207
|
-
* engine's SessionService; only the ADK face (the base's appendEvent, which
|
|
208
|
-
* ADK's Runner reaches) needs ADK.
|
|
209
|
-
*/
|
|
210
|
-
class MissingBaseSessionService {
|
|
211
|
-
async appendEvent(_request) {
|
|
212
|
-
return adkOnly('The ADK face of a session store');
|
|
213
|
-
}
|
|
214
|
-
/** ADK's own: the session when it exists, else a new one, through the store's methods. */
|
|
215
|
-
async getOrCreateSession(request) {
|
|
216
|
-
const self = this;
|
|
217
|
-
if (!request.sessionId)
|
|
218
|
-
return self.createSession(request);
|
|
219
|
-
const session = await self.getSession({ appName: request.appName, userId: request.userId, sessionId: request.sessionId });
|
|
220
|
-
return session ?? self.createSession(request);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
/** ADK's GOOGLE_SEARCH, absent: an in-model tool named google_search, which the engine reads by ADK's mark. */
|
|
224
|
-
class MissingGoogleSearchTool extends MissingBaseTool {
|
|
225
|
-
[IN_MODEL_TOOL] = true;
|
|
226
|
-
constructor() {
|
|
227
|
-
super({ name: 'google_search', description: 'Google Search Tool' });
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
// ── The values every other module imports ────────────────────────────────────
|
|
231
|
-
//
|
|
232
|
-
// A type of the same name sits beside each value, so `import { BaseTool }`
|
|
233
|
-
// from here serves as both, as it did from '@google/adk'.
|
|
234
|
-
export const BaseTool = loaded?.BaseTool ?? MissingBaseTool;
|
|
235
|
-
export const FunctionTool = loaded?.FunctionTool ?? MissingFunctionTool;
|
|
236
|
-
export const BaseToolset = loaded?.BaseToolset ?? MissingBaseToolset;
|
|
237
|
-
export const BaseLlm = loaded?.BaseLlm ?? MissingBaseLlm;
|
|
238
|
-
export const Gemini = loaded?.Gemini ?? MissingGemini;
|
|
239
|
-
export const BaseSessionService = loaded?.BaseSessionService ?? MissingBaseSessionService;
|
|
240
|
-
export const GOOGLE_SEARCH = loaded?.GOOGLE_SEARCH ?? new MissingGoogleSearchTool();
|
package/dist/lib/compileAdk.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* lib/compileAdk.ts — an AgentSpec as the ADK runtime runs it: today's
|
|
3
|
-
* LlmAgent (ADR 0045, ADR 0073).
|
|
4
|
-
*
|
|
5
|
-
* WHY this file exists:
|
|
6
|
-
* lib/compile.ts turns a YAML agent into a runtime-neutral AgentSpec: its
|
|
7
|
-
* tools resolved and gated, its instruction with the skills index, its
|
|
8
|
-
* model resolved once and its generateContentConfig built for that model.
|
|
9
|
-
* This file adds what only ADK's LlmAgent takes: the model wrapped in a
|
|
10
|
-
* FallbackLlm for `fallback_model:`, each delegated subagent as an
|
|
11
|
-
* AgentTool (a nested workflow's whole Workflow too; a remote one as its
|
|
12
|
-
* A2A tool), Gemini's code executor, the
|
|
13
|
-
* context compactor, task mode and a workflow node's settings. Every field
|
|
14
|
-
* reaches LlmAgent as compileGraph and compileSubagent always passed it, so
|
|
15
|
-
* the ADK runtime runs the agent it ran before the split.
|
|
16
|
-
* lib/compileNative.ts builds the native loop's agent from the same spec.
|
|
17
|
-
*
|
|
18
|
-
* Imports from lib/compile.ts are types only. A nested workflow's Workflow
|
|
19
|
-
* comes from lib/workflow.ts (assembleWorkflow, ADR 0098), which imports
|
|
20
|
-
* lib/compile.ts; every use of either is inside a function, so the modules
|
|
21
|
-
* load in any order.
|
|
22
|
-
*/
|
|
23
|
-
import type { LlmAgent } from '@google/adk';
|
|
24
|
-
import type { AgentSpec, CompileOptions } from './compile.ts';
|
|
25
|
-
import { DEFAULT_KEEP_RECENT_EVENTS } from './runtime/native/compaction.ts';
|
|
26
|
-
/** Events kept verbatim after a compaction summary when `context:` names none: the native compactor's default. */
|
|
27
|
-
export { DEFAULT_KEEP_RECENT_EVENTS };
|
|
28
|
-
/**
|
|
29
|
-
* The LlmAgent for `spec`. `extra` is spread last: a workflow node's
|
|
30
|
-
* settings (CompileOptions.nodeConfig), which compileSubagent passes.
|
|
31
|
-
*/
|
|
32
|
-
export declare function compileAdk(spec: AgentSpec, opts?: CompileOptions, extra?: Record<string, unknown>): LlmAgent;
|
package/dist/lib/compileAdk.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* lib/compileAdk.ts — an AgentSpec as the ADK runtime runs it: today's
|
|
3
|
-
* LlmAgent (ADR 0045, ADR 0073).
|
|
4
|
-
*
|
|
5
|
-
* WHY this file exists:
|
|
6
|
-
* lib/compile.ts turns a YAML agent into a runtime-neutral AgentSpec: its
|
|
7
|
-
* tools resolved and gated, its instruction with the skills index, its
|
|
8
|
-
* model resolved once and its generateContentConfig built for that model.
|
|
9
|
-
* This file adds what only ADK's LlmAgent takes: the model wrapped in a
|
|
10
|
-
* FallbackLlm for `fallback_model:`, each delegated subagent as an
|
|
11
|
-
* AgentTool (a nested workflow's whole Workflow too; a remote one as its
|
|
12
|
-
* A2A tool), Gemini's code executor, the
|
|
13
|
-
* context compactor, task mode and a workflow node's settings. Every field
|
|
14
|
-
* reaches LlmAgent as compileGraph and compileSubagent always passed it, so
|
|
15
|
-
* the ADK runtime runs the agent it ran before the split.
|
|
16
|
-
* lib/compileNative.ts builds the native loop's agent from the same spec.
|
|
17
|
-
*
|
|
18
|
-
* Imports from lib/compile.ts are types only. A nested workflow's Workflow
|
|
19
|
-
* comes from lib/workflow.ts (assembleWorkflow, ADR 0098), which imports
|
|
20
|
-
* lib/compile.ts; every use of either is inside a function, so the modules
|
|
21
|
-
* load in any order.
|
|
22
|
-
*/
|
|
23
|
-
import { BaseLlm, adk, requireAdk } from './adkPeer.js';
|
|
24
|
-
import { remoteAgentTool } from './a2a/remoteAgent.js';
|
|
25
|
-
import { assembleWorkflow } from './workflow.js';
|
|
26
|
-
import { FallbackLlm } from './models/fallback.js';
|
|
27
|
-
import { resolveModel as resolveRegistryModel } from './models/registry.js';
|
|
28
|
-
import { onLogLevel } from './runtime/logging.js';
|
|
29
|
-
import { DEFAULT_KEEP_RECENT_EVENTS } from './runtime/native/compaction.js';
|
|
30
|
-
/**
|
|
31
|
-
* ADK's logger follows the engine's level (lib/runtime/logging.ts, ADR
|
|
32
|
-
* 0080), so a surface sets one level and never names ADK to quiet it.
|
|
33
|
-
*/
|
|
34
|
-
if (adk) {
|
|
35
|
-
const { LogLevel: Level, setLogLevel } = adk;
|
|
36
|
-
const levels = { debug: Level.DEBUG, info: Level.INFO, warn: Level.WARN, error: Level.ERROR };
|
|
37
|
-
onLogLevel((level) => setLogLevel(levels[level]));
|
|
38
|
-
}
|
|
39
|
-
/** What compileAdk builds needs @google/adk; without it, this names the package (ADR 0102). */
|
|
40
|
-
const FEATURE = 'Compiling an agent for the ADK runtime (MELCHIZEDEK_RUNTIME=adk, compileGraph, compileSubagent)';
|
|
41
|
-
/** Events kept verbatim after a compaction summary when `context:` names none: the native compactor's default. */
|
|
42
|
-
export { DEFAULT_KEEP_RECENT_EVENTS };
|
|
43
|
-
/**
|
|
44
|
-
* The LlmAgent fields a YAML agent may set beyond model, instruction, tools
|
|
45
|
-
* and schemas. The schema reference (config/agents/syndicateSchema.yaml)
|
|
46
|
-
* documents each as mapping 1:1 to its ADK counterpart. Only fields the YAML
|
|
47
|
-
* sets are passed, so ADK's defaults stay in force otherwise.
|
|
48
|
-
*/
|
|
49
|
-
function passthroughFields(spec) {
|
|
50
|
-
const out = {};
|
|
51
|
-
if (spec.includeContents !== undefined)
|
|
52
|
-
out.includeContents = spec.includeContents;
|
|
53
|
-
if (spec.outputKey !== undefined)
|
|
54
|
-
out.outputKey = spec.outputKey;
|
|
55
|
-
if (spec.globalInstruction !== undefined)
|
|
56
|
-
out.globalInstruction = spec.globalInstruction;
|
|
57
|
-
if (spec.disallowTransferToParent !== undefined)
|
|
58
|
-
out.disallowTransferToParent = spec.disallowTransferToParent;
|
|
59
|
-
if (spec.disallowTransferToPeers !== undefined)
|
|
60
|
-
out.disallowTransferToPeers = spec.disallowTransferToPeers;
|
|
61
|
-
return out;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* The LlmAgent fields the engine builds from YAML rather than passing
|
|
65
|
-
* through (ADR 0033): `code_execution: gemini` (Gemini's server-side
|
|
66
|
-
* sandbox runs the model's Python; nothing runs on this host), `context:`
|
|
67
|
-
* (ADK's token-based compactor with an LLM summarizer, so a long
|
|
68
|
-
* conversation is summarized instead of overflowing the window), and
|
|
69
|
-
* `mode: task` (the agent works until it calls finish_task; on a workflow
|
|
70
|
-
* node, its arguments become the node's output).
|
|
71
|
-
*/
|
|
72
|
-
function executionFields(cfg, opts) {
|
|
73
|
-
const { BuiltInCodeExecutor, LLMRegistry, LlmSummarizer, TokenBasedContextCompactor } = requireAdk(FEATURE);
|
|
74
|
-
const out = {};
|
|
75
|
-
if (cfg.codeExecution === 'gemini')
|
|
76
|
-
out.codeExecutor = new BuiltInCodeExecutor();
|
|
77
|
-
if (cfg.mode)
|
|
78
|
-
out.mode = cfg.mode;
|
|
79
|
-
if (cfg.context) {
|
|
80
|
-
const resolve = opts.resolveModel ?? ((m) => m);
|
|
81
|
-
const summaryModel = resolve(cfg.context.summary_model ?? cfg.model);
|
|
82
|
-
const llm = typeof summaryModel === 'string' || !summaryModel ? LLMRegistry.newLlm(String(summaryModel ?? cfg.model)) : summaryModel;
|
|
83
|
-
out.contextCompactors = [
|
|
84
|
-
new TokenBasedContextCompactor({
|
|
85
|
-
tokenThreshold: cfg.context.compact_after_tokens,
|
|
86
|
-
eventRetentionSize: cfg.context.keep_recent_events ?? DEFAULT_KEEP_RECENT_EVENTS,
|
|
87
|
-
summarizer: new LlmSummarizer({ llm }),
|
|
88
|
-
}),
|
|
89
|
-
];
|
|
90
|
-
}
|
|
91
|
-
return out;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* An agent with `fallback_model:` gets its model wrapped (lib/models/fallback.ts):
|
|
95
|
-
* the fallback answers a provider-side failure, and a provider that keeps
|
|
96
|
-
* failing is skipped for a cooldown. A model id string is resolved to its
|
|
97
|
-
* adapter first, so the wrapper always holds two adapters.
|
|
98
|
-
*/
|
|
99
|
-
function withFallback(primary, fallbackId, opts) {
|
|
100
|
-
if (!fallbackId)
|
|
101
|
-
return primary;
|
|
102
|
-
const resolve = opts.resolveModel ?? ((m) => m);
|
|
103
|
-
const asLlm = (m) => (m instanceof BaseLlm ? m : resolveRegistryModel(String(m)));
|
|
104
|
-
return new FallbackLlm(asLlm(primary), asLlm(resolve(fallbackId)), opts.log ?? ((m) => console.warn(m)));
|
|
105
|
-
}
|
|
106
|
-
/** The spec's tools as LlmAgent takes them: a delegated subagent (a nested workflow's Workflow included) as an AgentTool, a remote one as its A2A tool. */
|
|
107
|
-
function adkTools(spec, opts) {
|
|
108
|
-
const { AgentTool } = requireAdk(FEATURE);
|
|
109
|
-
return spec.tools.map((entry) => {
|
|
110
|
-
switch (entry.kind) {
|
|
111
|
-
case 'tool':
|
|
112
|
-
return entry.tool;
|
|
113
|
-
case 'agent':
|
|
114
|
-
return new AgentTool({ agent: compileAdk(entry.agent, opts) });
|
|
115
|
-
case 'remote':
|
|
116
|
-
return remoteAgentTool({ name: entry.name, description: entry.description, url: entry.url });
|
|
117
|
-
case 'workflow':
|
|
118
|
-
// ADK's AgentTool runs any node its Runner takes, a Workflow included: the whole graph, its last event's text the answer (ADR 0098).
|
|
119
|
-
return new AgentTool({ agent: assembleWorkflow(entry.workflow, opts).workflow });
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* The LlmAgent for `spec`. `extra` is spread last: a workflow node's
|
|
125
|
-
* settings (CompileOptions.nodeConfig), which compileSubagent passes.
|
|
126
|
-
*/
|
|
127
|
-
export function compileAdk(spec, opts = {}, extra = {}) {
|
|
128
|
-
const { LlmAgent } = requireAdk(FEATURE);
|
|
129
|
-
const tools = adkTools(spec, opts);
|
|
130
|
-
return new LlmAgent({
|
|
131
|
-
name: spec.name,
|
|
132
|
-
description: spec.description,
|
|
133
|
-
model: withFallback(spec.resolvedModel, spec.fallbackModel, opts),
|
|
134
|
-
instruction: spec.instruction,
|
|
135
|
-
tools: tools.length > 0 ? tools : undefined,
|
|
136
|
-
outputSchema: spec.outputSchema,
|
|
137
|
-
generateContentConfig: spec.generateContentConfig,
|
|
138
|
-
...passthroughFields(spec),
|
|
139
|
-
...executionFields(spec, opts),
|
|
140
|
-
...extra,
|
|
141
|
-
});
|
|
142
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* lib/models/adkGeminiAdapter.ts — TEMPORARY: Gemini as a contract
|
|
3
|
-
* ModelAdapter (ADR 0048) over ADK's own Gemini, the TracedGemini path of
|
|
4
|
-
* lib/models/tracedGemini.ts, through the genai mapping (lib/models/genaiMapping.ts).
|
|
5
|
-
*
|
|
6
|
-
* WHY this file exists:
|
|
7
|
-
* The native loop (ADR 0045) calls ModelAdapters only. The engine's own
|
|
8
|
-
* Gemini adapter (lib/models/geminiAdapter.ts) calls @google/genai with no
|
|
9
|
-
* ADK, and waits for its live parity run at gate G3. Until it passes,
|
|
10
|
-
* Gemini on the native runtime goes through ADK's proven Gemini, wrapped
|
|
11
|
-
* here, so every provider has a contract adapter before gate G1. Delete
|
|
12
|
-
* this file once G3 is signed and GeminiAdapter serves every Gemini id
|
|
13
|
-
* (the plan's G3 risk: "The WS1-8 wrapper over ADK's Gemini stays until
|
|
14
|
-
* the cells pass"). resolveAdapter (lib/models/registry.ts) returns it for Gemini ids.
|
|
15
|
-
*
|
|
16
|
-
* THE CALL:
|
|
17
|
-
* 1. The ModelRequest becomes an LlmRequest (modelRequestToLlmRequest),
|
|
18
|
-
* and then what ADK's path does to one before its Gemini sees it:
|
|
19
|
-
* - system messages joined onto the system prompt, in order, since
|
|
20
|
-
* Gemini takes no `system` content;
|
|
21
|
-
* - `adk-` call ids taken off calls and results, as ADK's flow does
|
|
22
|
-
* before every model call (ids the mapping minted are already off);
|
|
23
|
-
* - `includeServerSideToolInvocations`, which the compiler sends on
|
|
24
|
-
* every Gemini agent (lib/compile.ts);
|
|
25
|
-
* - `includeThoughts` under any reasoning but `none`, the contract's
|
|
26
|
-
* Gemini table, as GeminiAdapter sends it;
|
|
27
|
-
* - the platform's wire model (GEMINI_MODEL_MAP), as TracedGemini's own.
|
|
28
|
-
* The request is copied where ADK writes to it (a blob's display name),
|
|
29
|
-
* so the caller's history is never changed.
|
|
30
|
-
* 2. TracedGemini.generateWithRetries runs it: ADK's Gemini with the
|
|
31
|
-
* shared retries, tagging the span that is open around this adapter
|
|
32
|
-
* (llm.web_search.native, llm.retries, llm.http_status), as it tags its
|
|
33
|
-
* own. `llm.capability.dropped` marks native tools Gemini has none for.
|
|
34
|
-
* 3. Each LlmResponse comes back through llmResponseToModelResponse,
|
|
35
|
-
* folded into the contract's stream. A thought signature becomes
|
|
36
|
-
* providerState naming the request's model. A call Gemini returns
|
|
37
|
-
* without an id gets the mapping's `genai-noid-<position>-<part>`, or,
|
|
38
|
-
* streamed, ADK's own `adk-` id; neither goes back on the wire.
|
|
39
|
-
*
|
|
40
|
-
* REPLAY: every Gemini signature in the history goes back on its part, as
|
|
41
|
-
* ADK sends a stored session's, whichever turn or model wrote it.
|
|
42
|
-
* GeminiAdapter replays only the current turn's, for its own model.
|
|
43
|
-
*
|
|
44
|
-
* THE SPAN AND THE CHARGE are the caller's (ADR 0053): this adapter opens no
|
|
45
|
-
* llm.request span and never charges the turn. Behind the ADK shim
|
|
46
|
-
* (lib/models/adkShim.ts) it records the span TracedGemini records today for
|
|
47
|
-
* the same exchange, but for a failed call's code (tests/telemetryLedger.test.ts).
|
|
48
|
-
*
|
|
49
|
-
* THE ADAPTER RULES (contract.ts header) as this adapter keeps them:
|
|
50
|
-
* - Partials: a streamed call's text and thinking deltas, as ADK's stream
|
|
51
|
-
* aggregator yields them. A call that does not stream yields its
|
|
52
|
-
* thinking as one partial before the final.
|
|
53
|
-
* - One final: every non-partial response ADK yields for the call (its
|
|
54
|
-
* aggregator flushes the text before each tool call) folds into it, with
|
|
55
|
-
* the last usage, grounding and finish reason.
|
|
56
|
-
* - Errors are finals, never throws. ADK's Gemini throws on a failed call:
|
|
57
|
-
* that is GEMINI_ERROR, `retryable` from lib/models/retry.ts's
|
|
58
|
-
* classifyError, `status` when the error had one. An error code ADK
|
|
59
|
-
* yields (a finish or block reason) is the code, not retryable; ADK's
|
|
60
|
-
* `STOP` is no error. Setup failures are MISSING_API_KEY and
|
|
61
|
-
* ENDPOINT_MISCONFIGURED, as GeminiAdapter's.
|
|
62
|
-
* - The abort: `request.signal` (the shim aborts it when the turn stops)
|
|
63
|
-
* goes on the request config. An aborted call is GEMINI_ERROR, never
|
|
64
|
-
* retryable, and the iteration ends at once whatever the transport does;
|
|
65
|
-
* a signal aborted before the call sends nothing.
|
|
66
|
-
* - Retries: TracedGemini's, only before the first chunk.
|
|
67
|
-
* - Messages never carry the key in use or anything shaped like a key.
|
|
68
|
-
*/
|
|
69
|
-
import type { ModelAdapter, ModelRequest, ModelResponse } from './contract.ts';
|
|
70
|
-
import type { ProviderEndpoint } from './endpoints.ts';
|
|
71
|
-
export interface AdkGeminiAdapterOptions {
|
|
72
|
-
/** The model id as the YAML names it. */
|
|
73
|
-
model: string;
|
|
74
|
-
/**
|
|
75
|
-
* A Gemini API (AI Studio) key: a caller's own, or one the credentials plug
|
|
76
|
-
* point returned. It wins over the endpoint's and the environment's, and is
|
|
77
|
-
* never sent to Vertex AI.
|
|
78
|
-
*/
|
|
79
|
-
apiKey?: string;
|
|
80
|
-
/** Where requests go (ADR 0023). Default: `endpointFromEnv('gemini')`, read on the first call. */
|
|
81
|
-
endpoint?: ProviderEndpoint;
|
|
82
|
-
}
|
|
83
|
-
/** Temporary: ADK's Gemini behind the model contract, until GeminiAdapter passes gate G3. */
|
|
84
|
-
export declare class AdkGeminiAdapter implements ModelAdapter {
|
|
85
|
-
#private;
|
|
86
|
-
readonly provider = "gemini";
|
|
87
|
-
readonly model: string;
|
|
88
|
-
constructor(options: AdkGeminiAdapterOptions);
|
|
89
|
-
generate(request: ModelRequest): AsyncGenerator<ModelResponse, void>;
|
|
90
|
-
}
|