melchizedek-agents 0.20.0 → 1.0.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/.env.example +4 -5
- package/AGENT_SETUP.md +3 -3
- package/CHANGELOG.md +240 -0
- package/DOCUMENTATION.md +142 -150
- package/QUICKSTART.md +12 -11
- package/README.md +11 -11
- package/config/agents/examples/image_production.yaml +2 -2
- package/config/agents/syndicateSchema.yaml +52 -26
- package/dist/lib/a2a/app.d.ts +17 -12
- package/dist/lib/a2a/app.js +16 -6
- package/dist/lib/a2a/executor.d.ts +10 -14
- package/dist/lib/a2a/executor.js +10 -18
- package/dist/lib/a2a/remoteAgent.d.ts +5 -12
- package/dist/lib/a2a/remoteAgent.js +5 -12
- package/dist/lib/compile.d.ts +76 -86
- package/dist/lib/compile.js +100 -116
- package/dist/lib/compileNative.d.ts +44 -56
- package/dist/lib/compileNative.js +91 -89
- package/dist/lib/config.d.ts +6 -6
- package/dist/lib/config.js +6 -6
- package/dist/lib/doctor.d.ts +8 -14
- package/dist/lib/doctor.js +10 -46
- package/dist/lib/index.d.ts +12 -9
- package/dist/lib/index.js +10 -11
- package/dist/lib/loadSyndicate.d.ts +3 -3
- package/dist/lib/loadSyndicate.js +2 -2
- package/dist/lib/memory/erase.d.ts +1 -1
- package/dist/lib/memory/erase.js +1 -1
- package/dist/lib/memory/namespace.d.ts +12 -14
- package/dist/lib/memory/namespace.js +13 -14
- package/dist/lib/memory/providers.d.ts +4 -5
- package/dist/lib/memory/providers.js +12 -6
- package/dist/lib/memory/supabaseMemoryService.d.ts +9 -30
- package/dist/lib/memory/supabaseMemoryService.js +8 -30
- package/dist/lib/model.d.ts +6 -12
- package/dist/lib/model.js +6 -12
- package/dist/lib/models/adapterResolver.d.ts +21 -40
- package/dist/lib/models/adapterResolver.js +32 -40
- package/dist/lib/models/chatCompletionsAdapter.d.ts +12 -33
- package/dist/lib/models/chatCompletionsAdapter.js +13 -18
- package/dist/lib/models/circuitBreaker.d.ts +5 -5
- package/dist/lib/models/circuitBreaker.js +5 -5
- package/dist/lib/models/claudeAdapter.d.ts +9 -26
- package/dist/lib/models/claudeAdapter.js +11 -15
- package/dist/lib/models/claudeModels.d.ts +4 -4
- package/dist/lib/models/claudeModels.js +4 -4
- package/dist/lib/models/contract.d.ts +11 -11
- package/dist/lib/models/contract.js +6 -6
- package/dist/lib/models/errorResponse.d.ts +13 -20
- package/dist/lib/models/errorResponse.js +0 -12
- package/dist/lib/models/fallbackAdapter.d.ts +7 -8
- package/dist/lib/models/gatewayAdapter.d.ts +1 -1
- package/dist/lib/models/gatewayAdapter.js +1 -1
- package/dist/lib/models/geminiAdapter.d.ts +5 -6
- package/dist/lib/models/geminiAdapter.js +9 -10
- package/dist/lib/models/geminiState.d.ts +8 -8
- package/dist/lib/models/geminiState.js +8 -8
- package/dist/lib/models/genaiMapping.d.ts +82 -36
- package/dist/lib/models/genaiMapping.js +41 -41
- package/dist/lib/models/gptAdapter.d.ts +11 -11
- package/dist/lib/models/gptAdapter.js +13 -13
- package/dist/lib/models/kimiAdapter.d.ts +6 -7
- package/dist/lib/models/kimiAdapter.js +6 -9
- package/dist/lib/models/ollamaAdapter.d.ts +3 -3
- package/dist/lib/models/ollamaAdapter.js +3 -3
- package/dist/lib/models/providerMap.d.ts +6 -5
- package/dist/lib/models/providerMap.js +6 -5
- package/dist/lib/models/providerState.d.ts +3 -2
- package/dist/lib/models/providerState.js +3 -2
- package/dist/lib/models/reasoning.d.ts +1 -1
- package/dist/lib/models/registry.d.ts +26 -73
- package/dist/lib/models/registry.js +31 -144
- package/dist/lib/models/retry.d.ts +2 -2
- package/dist/lib/models/retry.js +2 -2
- package/dist/lib/models/schemaNormalize.d.ts +25 -55
- package/dist/lib/models/schemaNormalize.js +30 -100
- package/dist/lib/observability/lineage.d.ts +3 -3
- package/dist/lib/observability/lineage.js +10 -10
- package/dist/lib/observability/supabaseSpanExporter.js +1 -1
- package/dist/lib/observability/tracer.d.ts +25 -23
- package/dist/lib/observability/tracer.js +26 -63
- package/dist/lib/persistence/supabaseProvider.d.ts +4 -3
- package/dist/lib/runtime/approvals.d.ts +1 -1
- package/dist/lib/runtime/credentials.d.ts +1 -1
- package/dist/lib/runtime/events.d.ts +3 -4
- package/dist/lib/runtime/events.js +3 -4
- package/dist/lib/runtime/logging.d.ts +3 -8
- package/dist/lib/runtime/logging.js +3 -8
- package/dist/lib/runtime/memoryService.d.ts +4 -6
- package/dist/lib/runtime/memoryService.js +3 -5
- package/dist/lib/runtime/native/agentLoop.d.ts +18 -16
- package/dist/lib/runtime/native/agentLoop.js +38 -26
- package/dist/lib/runtime/native/compaction.d.ts +10 -11
- package/dist/lib/runtime/native/compaction.js +10 -11
- package/dist/lib/runtime/native/delegate.d.ts +13 -14
- package/dist/lib/runtime/native/delegate.js +11 -18
- package/dist/lib/runtime/native/history.d.ts +5 -6
- package/dist/lib/runtime/native/history.js +5 -6
- package/dist/lib/runtime/native/interrupts.d.ts +6 -6
- package/dist/lib/runtime/native/interrupts.js +6 -6
- package/dist/lib/runtime/native/request.d.ts +24 -24
- package/dist/lib/runtime/native/request.js +35 -24
- package/dist/lib/runtime/native/selfCorrection.d.ts +32 -32
- package/dist/lib/runtime/native/selfCorrection.js +34 -34
- package/dist/lib/runtime/native/step.d.ts +23 -23
- package/dist/lib/runtime/native/step.js +49 -27
- package/dist/lib/runtime/native/taskMode.d.ts +8 -8
- package/dist/lib/runtime/native/taskMode.js +8 -8
- package/dist/lib/runtime/native/telemetry.d.ts +11 -11
- package/dist/lib/runtime/native/telemetry.js +11 -11
- package/dist/lib/runtime/native/tempState.d.ts +4 -4
- package/dist/lib/runtime/native/tempState.js +4 -4
- package/dist/lib/runtime/nativeTurn.d.ts +29 -32
- package/dist/lib/runtime/nativeTurn.js +30 -41
- package/dist/lib/runtime/questions.d.ts +8 -9
- package/dist/lib/runtime/questions.js +1 -2
- package/dist/lib/runtime/runtimeFlag.d.ts +28 -14
- package/dist/lib/runtime/runtimeFlag.js +38 -16
- package/dist/lib/runtime/sessions.d.ts +10 -12
- package/dist/lib/runtime/sessions.js +10 -12
- package/dist/lib/runtime/syndicateTurn.d.ts +44 -45
- package/dist/lib/runtime/syndicateTurn.js +163 -158
- package/dist/lib/runtime/turnControl.d.ts +8 -8
- package/dist/lib/runtime/turnControl.js +8 -8
- package/dist/lib/session/supabaseSessionService.d.ts +7 -21
- package/dist/lib/session/supabaseSessionService.js +7 -43
- package/dist/lib/session/transcript.d.ts +16 -26
- package/dist/lib/session/transcript.js +17 -57
- package/dist/lib/storage/postgres/sessionService.d.ts +6 -20
- package/dist/lib/storage/postgres/sessionService.js +6 -39
- package/dist/lib/syndicateSchema.js +7 -6
- package/dist/lib/toolRegistry.d.ts +9 -14
- package/dist/lib/toolRegistry.js +36 -33
- package/dist/lib/tools/auth.d.ts +1 -1
- package/dist/lib/tools/auth.js +1 -1
- package/dist/lib/tools/examples.d.ts +2 -4
- package/dist/lib/tools/examples.js +2 -4
- package/dist/lib/tools/generateImageTool.d.ts +3 -3
- package/dist/lib/tools/generateImageTool.js +4 -5
- package/dist/lib/tools/inspectImageTool.d.ts +2 -2
- package/dist/lib/tools/inspectImageTool.js +3 -4
- package/dist/lib/tools/mcpToolFactory.d.ts +4 -24
- package/dist/lib/tools/mcpToolFactory.js +19 -9
- package/dist/lib/tools/memoryTools.d.ts +5 -6
- package/dist/lib/tools/memoryTools.js +5 -6
- package/dist/lib/tools/nativeTools.d.ts +9 -14
- package/dist/lib/tools/nativeTools.js +9 -14
- package/dist/lib/tools/openapiTools.d.ts +5 -7
- package/dist/lib/tools/openapiTools.js +6 -13
- package/dist/lib/tools/scienceTools.d.ts +3 -3
- package/dist/lib/tools/scienceTools.js +8 -10
- package/dist/lib/tools/skillToolset.d.ts +1 -2
- package/dist/lib/tools/skillToolset.js +1 -2
- package/dist/lib/tools/skills/executor.d.ts +1 -1
- package/dist/lib/tools/skills/executor.js +1 -1
- package/dist/lib/tools/skills/frontmatter.d.ts +2 -2
- package/dist/lib/tools/skills/frontmatter.js +2 -2
- package/dist/lib/tools/skills/tools.d.ts +8 -10
- package/dist/lib/tools/skills/tools.js +9 -11
- package/dist/lib/tools/tool.d.ts +24 -40
- package/dist/lib/tools/tool.js +24 -56
- package/dist/lib/tools/toolContract.d.ts +8 -13
- package/dist/lib/tools/toolContract.js +6 -17
- package/dist/lib/tools/webExtractTool.d.ts +2 -2
- package/dist/lib/tools/webExtractTool.js +3 -4
- package/dist/lib/tools/wikiTools.d.ts +2 -2
- package/dist/lib/tools/wikiTools.js +5 -6
- package/dist/lib/tools/xApiSearchTool.d.ts +2 -2
- package/dist/lib/tools/xApiSearchTool.js +3 -4
- package/dist/lib/tools/xaiSearchParams.d.ts +2 -5
- package/dist/lib/tools/xaiSearchParams.js +2 -5
- package/dist/lib/wiki/agentRun.d.ts +10 -11
- package/dist/lib/wiki/agentRun.js +24 -42
- package/dist/lib/workflow/agentNode.d.ts +10 -1
- package/dist/lib/workflow/agentNode.js +5 -3
- package/dist/lib/workflow/graph.d.ts +8 -9
- package/dist/lib/workflow/graph.js +12 -12
- package/dist/lib/workflow/nodeEvents.d.ts +5 -5
- package/dist/lib/workflow/nodeEvents.js +5 -5
- package/dist/lib/workflow/pause.d.ts +5 -4
- package/dist/lib/workflow/pause.js +5 -4
- package/dist/lib/workflow/resume.d.ts +4 -4
- package/dist/lib/workflow/resume.js +4 -4
- package/dist/lib/workflow/route.d.ts +7 -7
- package/dist/lib/workflow/route.js +8 -8
- package/dist/lib/workflow/scheduler.d.ts +44 -2
- package/dist/lib/workflow/scheduler.js +60 -6
- package/dist/lib/workflow/toolNode.d.ts +18 -29
- package/dist/lib/workflow/toolNode.js +29 -35
- package/dist/lib/workflow/turn.d.ts +29 -20
- package/dist/lib/workflow/turn.js +111 -24
- package/dist/lib/workflow.d.ts +34 -60
- package/dist/lib/workflow.js +34 -168
- package/dist/lib/workflowConfig.d.ts +2 -10
- package/dist/lib/workflowConfig.js +2 -31
- package/dist/scripts/a2a_server.js +1 -2
- package/dist/scripts/assistant_worker.d.ts +2 -2
- package/dist/scripts/assistant_worker.js +8 -7
- package/dist/scripts/doctor.d.ts +2 -2
- package/dist/scripts/doctor.js +2 -2
- package/dist/scripts/syndicate_chat.js +14 -24
- package/package.json +3 -9
- package/skills/briefs/_shared.md +2 -2
- package/skills/briefs/melchizedek-author.md +2 -2
- package/skills/briefs/melchizedek-models.md +6 -6
- package/skills/melchizedek-author/SKILL.md +2 -2
- package/skills/melchizedek-models/SKILL.md +5 -5
package/dist/lib/doctor.js
CHANGED
|
@@ -19,9 +19,8 @@
|
|
|
19
19
|
* come from lib/models/gateway.ts and lib/models/capabilities.ts, the same
|
|
20
20
|
* modules the registry and the A2A server use, so the report cannot
|
|
21
21
|
* disagree with what a run would do. The runtime line comes from
|
|
22
|
-
* lib/runtime/runtimeFlag.ts, which a turn reads (ADR
|
|
23
|
-
*
|
|
24
|
-
* loads ADK to answer it.
|
|
22
|
+
* lib/runtime/runtimeFlag.ts, which a turn reads (ADR 0107): a leftover
|
|
23
|
+
* MELCHIZEDEK_RUNTIME=adk is a problem.
|
|
25
24
|
*/
|
|
26
25
|
import fs from 'node:fs';
|
|
27
26
|
import path from 'node:path';
|
|
@@ -43,51 +42,19 @@ function resolvable(module) {
|
|
|
43
42
|
return false;
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
|
-
/** The installed version of a package that resolves from here, read from its package.json (its exports map may hide it). */
|
|
47
|
-
function installedVersion(module) {
|
|
48
|
-
try {
|
|
49
|
-
let dir = path.dirname(createRequire(import.meta.url).resolve(module));
|
|
50
|
-
for (let i = 0; i < 8; i++) {
|
|
51
|
-
const file = path.join(dir, 'package.json');
|
|
52
|
-
if (fs.existsSync(file)) {
|
|
53
|
-
const pkg = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
54
|
-
if (pkg.name === module)
|
|
55
|
-
return pkg.version;
|
|
56
|
-
}
|
|
57
|
-
const up = path.dirname(dir);
|
|
58
|
-
if (up === dir)
|
|
59
|
-
break;
|
|
60
|
-
dir = up;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
// Not resolvable, or unreadable: no version to report.
|
|
65
|
-
}
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
/** The ADK peer, as an install command names it. */
|
|
69
|
-
const ADK_PEER = '@google/adk';
|
|
70
45
|
/**
|
|
71
46
|
* The runtime a turn would run on under this environment (lib/runtime/
|
|
72
|
-
* runtimeFlag.ts), where that came from
|
|
73
|
-
*
|
|
47
|
+
* runtimeFlag.ts), and where that came from. MELCHIZEDEK_RUNTIME=adk is a
|
|
48
|
+
* problem: every turn, and the server's startup, would fail
|
|
49
|
+
* (RuntimeRemovedError, ADR 0107).
|
|
74
50
|
*/
|
|
75
|
-
export function runtimeReport(env = process.env
|
|
76
|
-
const installed = adkResolvable(ADK_PEER);
|
|
77
|
-
const adk = { installed, ...(installed && installedVersion(ADK_PEER) ? { version: installedVersion(ADK_PEER) } : {}) };
|
|
78
|
-
let chosen;
|
|
51
|
+
export function runtimeReport(env = process.env) {
|
|
79
52
|
try {
|
|
80
|
-
|
|
53
|
+
return describeRuntime(undefined, env);
|
|
81
54
|
}
|
|
82
55
|
catch (err) {
|
|
83
|
-
return {
|
|
56
|
+
return { problem: err instanceof Error ? err.message : String(err) };
|
|
84
57
|
}
|
|
85
|
-
const needed = chosen.runtime === 'adk';
|
|
86
|
-
return {
|
|
87
|
-
...chosen,
|
|
88
|
-
adk: { ...adk, needed },
|
|
89
|
-
...(needed && !installed ? { problem: `MELCHIZEDEK_RUNTIME=adk needs ${ADK_PEER}, which is not installed: npm install ${ADK_PEER}@~2.2.0, or unset MELCHIZEDEK_RUNTIME to run on native` } : {}),
|
|
90
|
-
};
|
|
91
58
|
}
|
|
92
59
|
/** One row per provider that is not on its vendor's public API with an env key. */
|
|
93
60
|
export function endpointRows() {
|
|
@@ -467,16 +434,13 @@ export function renderDoctor(result, opts = {}) {
|
|
|
467
434
|
: `${c.green}${text}${c.reset}`;
|
|
468
435
|
lines.push(`${c.bold}melchizedek doctor${c.reset} ${c.dim}· ${result.agentsDir}${c.reset}`);
|
|
469
436
|
lines.push('');
|
|
470
|
-
// The runtime a turn would run on, where that came from
|
|
437
|
+
// The runtime a turn would run on, and where that came from (ADR 0107).
|
|
471
438
|
if (result.runtime) {
|
|
472
439
|
const rt = result.runtime;
|
|
473
|
-
const adk = rt.adk.installed
|
|
474
|
-
? `${ADK_PEER} ${rt.adk.version ?? ''}`.trimEnd() + ' installed'
|
|
475
|
-
: `${ADK_PEER} not installed${rt.adk.needed ? '' : ' (needed only for MELCHIZEDEK_RUNTIME=adk)'}`;
|
|
476
440
|
const source = rt.source === 'default' ? 'the default' : rt.source;
|
|
477
441
|
lines.push(rt.problem
|
|
478
442
|
? `runtime ${c.red}✗${c.reset} ${rt.runtime ? `${rt.runtime} ${c.dim}(${source})${c.reset} · ` : ''}${c.red}${rt.problem}${c.reset}`
|
|
479
|
-
: `runtime ${c.green}✓${c.reset} ${rt.runtime} ${c.dim}(${source})${c.reset}
|
|
443
|
+
: `runtime ${c.green}✓${c.reset} ${rt.runtime} ${c.dim}(${source})${c.reset}`);
|
|
480
444
|
}
|
|
481
445
|
// Provider line: what is funded, and how. Each provider is probed with an
|
|
482
446
|
// id of its own prefix, so the line names ITS key (a fallthrough once put
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -8,23 +8,26 @@
|
|
|
8
8
|
* modules directly.
|
|
9
9
|
*
|
|
10
10
|
* The run API is plain data in, plain data out: a YAML config and text
|
|
11
|
-
* parts go in, a SyndicateTurnResult comes out.
|
|
12
|
-
*
|
|
11
|
+
* parts go in, a SyndicateTurnResult comes out. The engine runs every turn
|
|
12
|
+
* on its own agent loop; sessions and memory are its own interfaces
|
|
13
|
+
* (SessionService, MemoryService), and nothing here names Google ADK
|
|
14
|
+
* (ADR 0107).
|
|
13
15
|
*/
|
|
14
16
|
export { loadSyndicate, loadSyndicateFromRegistry, parseCliBindings, validateRegistryConfig, } from './loadSyndicate.ts';
|
|
15
17
|
export type { AgentYamlConfig, LoadSyndicateOptions, SubagentYamlConfig, SyndicateYamlConfig, VariableMap, } from './loadSyndicate.ts';
|
|
16
18
|
export { runSyndicateTurn, ingestTurnMemory } from './runtime/syndicateTurn.ts';
|
|
17
|
-
export { DEFAULT_RUNTIME, describeRuntime,
|
|
19
|
+
export { DEFAULT_RUNTIME, describeRuntime, RuntimeRemovedError, UnsupportedOnRuntimeError } from './runtime/syndicateTurn.ts';
|
|
18
20
|
export type { RuntimeName, RuntimeSource } from './runtime/syndicateTurn.ts';
|
|
19
21
|
export { InProcessSessionService } from './runtime/sessions.ts';
|
|
20
|
-
export {
|
|
22
|
+
export type { Session, SessionKey, SessionService } from './runtime/sessions.ts';
|
|
23
|
+
export type { MemoryEntry, MemoryIngestOptions, MemorySearchRequest, MemorySearchResult, MemoryService } from './runtime/memoryService.ts';
|
|
24
|
+
export type { TurnEvent } from './runtime/events.ts';
|
|
21
25
|
export { approvalResponsePart, pendingApproval, APPROVAL_REQUEST } from './runtime/approvals.ts';
|
|
22
26
|
export type { PendingApproval } from './runtime/approvals.ts';
|
|
23
27
|
export type { DrainedRun, MessagePart, TurnUsage, RouteDecision, SyndicateTurnOptions, SyndicateTurnResult, TraceOptions, TurnEvents, TurnStage, } from './runtime/syndicateTurn.ts';
|
|
24
|
-
export { compileGraph, compileSubagent } from './compile.ts';
|
|
25
28
|
export type { CompileOptions } from './compile.ts';
|
|
26
|
-
export {
|
|
27
|
-
export type { WorkflowConfig, WorkflowNodeYaml, EdgeElement, PendingInput
|
|
29
|
+
export { isWorkflowSyndicate, describeInput } from './workflow.ts';
|
|
30
|
+
export type { WorkflowConfig, WorkflowNodeYaml, EdgeElement, PendingInput } from './workflow.ts';
|
|
28
31
|
export { createA2AApp, compileAgentCard, currentRequestContext } from './a2a/app.ts';
|
|
29
32
|
export type { A2AApp, A2AAppOptions, RequestIdentity } from './a2a/app.ts';
|
|
30
33
|
export type { A2AContext } from './a2a/executor.ts';
|
|
@@ -42,7 +45,7 @@ export { resolveTools, registerTool, registeredToolNames } from './toolRegistry.
|
|
|
42
45
|
export { registerGuard, resolveGuards } from './guards/index.ts';
|
|
43
46
|
export type { Guard, GuardResult } from './guards/index.ts';
|
|
44
47
|
export { defineTool } from './tools/toolContract.ts';
|
|
45
|
-
export {
|
|
48
|
+
export type { Tool, ToolContext } from './tools/tool.ts';
|
|
46
49
|
export { modelExtractor, geminiEmbedder, openAiCompatibleEmbedder, memoryProvidersFromEnv, } from './memory/providers.ts';
|
|
47
50
|
export type { Embedder, MemoryExtractor } from './memory/providers.ts';
|
|
48
51
|
export { eraseScope } from './memory/erase.ts';
|
|
@@ -52,5 +55,5 @@ export { postgresStorage, PostgresSessionService, PostgresTaskStore } from './st
|
|
|
52
55
|
export type { PostgresStorage, PostgresStorageOptions } from './storage/postgres/index.ts';
|
|
53
56
|
export type { MemoryStore } from './memory/store.ts';
|
|
54
57
|
export { validateSyndicateConfig, syndicateJsonSchema, SyndicateValidationError } from './syndicateSchema.ts';
|
|
55
|
-
export { PROVIDERS, providerForModel, providerKeyPresent, providerStatuses,
|
|
58
|
+
export { PROVIDERS, providerForModel, providerKeyPresent, providerStatuses, logProviderStatuses, resolveModel, describeCapabilities, capabilitySummary, planTransport, gatewayConfig, gatewayProblem, gatewayUsable, GATEWAYS, } from './models/registry.ts';
|
|
56
59
|
export { loadEnv } from './loadEnv.ts';
|
package/dist/lib/index.js
CHANGED
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
* modules directly.
|
|
9
9
|
*
|
|
10
10
|
* The run API is plain data in, plain data out: a YAML config and text
|
|
11
|
-
* parts go in, a SyndicateTurnResult comes out.
|
|
12
|
-
*
|
|
11
|
+
* parts go in, a SyndicateTurnResult comes out. The engine runs every turn
|
|
12
|
+
* on its own agent loop; sessions and memory are its own interfaces
|
|
13
|
+
* (SessionService, MemoryService), and nothing here names Google ADK
|
|
14
|
+
* (ADR 0107).
|
|
13
15
|
*/
|
|
14
16
|
// ── Load a syndicate ────────────────────────────────────────────────────────
|
|
15
17
|
export { loadSyndicate, loadSyndicateFromRegistry, parseCliBindings, validateRegistryConfig, } from './loadSyndicate.js';
|
|
16
18
|
// ── Run it ──────────────────────────────────────────────────────────────────
|
|
17
19
|
export { runSyndicateTurn, ingestTurnMemory } from './runtime/syndicateTurn.js';
|
|
18
|
-
// The runtime in use
|
|
19
|
-
export { DEFAULT_RUNTIME, describeRuntime,
|
|
20
|
-
//
|
|
20
|
+
// The runtime in use: native, the only one since 1.0.0 (ADR 0107).
|
|
21
|
+
export { DEFAULT_RUNTIME, describeRuntime, RuntimeRemovedError, UnsupportedOnRuntimeError } from './runtime/syndicateTurn.js';
|
|
22
|
+
// The engine's session and memory interfaces, and the in-process store (ADR 0107).
|
|
21
23
|
export { InProcessSessionService } from './runtime/sessions.js';
|
|
22
|
-
export { asAdkSessionService, asSessionService } from './runtime/adkSessionBridge.js';
|
|
23
24
|
export { approvalResponsePart, pendingApproval, APPROVAL_REQUEST } from './runtime/approvals.js';
|
|
24
|
-
export {
|
|
25
|
-
export { compileWorkflow, isWorkflowSyndicate, describeInput } from './workflow.js';
|
|
25
|
+
export { isWorkflowSyndicate, describeInput } from './workflow.js';
|
|
26
26
|
// ── Serve it over A2A, or call a remote A2A agent ───────────────────────────
|
|
27
27
|
export { createA2AApp, compileAgentCard, currentRequestContext } from './a2a/app.js';
|
|
28
28
|
export { callerTokens, firstOf, hashCallerToken, jwtIdentity, parseCallers, scopeSegment, sharedSecret, trustedHeader, } from './a2a/identity.js';
|
|
@@ -34,7 +34,6 @@ export { RemoteA2AAgent, remoteAgentTool } from './a2a/remoteAgent.js';
|
|
|
34
34
|
export { resolveTools, registerTool, registeredToolNames } from './toolRegistry.js';
|
|
35
35
|
export { registerGuard, resolveGuards } from './guards/index.js';
|
|
36
36
|
export { defineTool } from './tools/toolContract.js';
|
|
37
|
-
export { toFunctionTool } from './tools/adkTool.js';
|
|
38
37
|
// ── Memory ──────────────────────────────────────────────────────────────────
|
|
39
38
|
export { modelExtractor, geminiEmbedder, openAiCompatibleEmbedder, memoryProvidersFromEnv, } from './memory/providers.js';
|
|
40
39
|
export { eraseScope } from './memory/erase.js';
|
|
@@ -44,8 +43,8 @@ export { postgresStorage, PostgresSessionService, PostgresTaskStore } from './st
|
|
|
44
43
|
// ── Validation ──────────────────────────────────────────────────────────────
|
|
45
44
|
export { validateSyndicateConfig, syndicateJsonSchema, SyndicateValidationError } from './syndicateSchema.js';
|
|
46
45
|
// ── Models ──────────────────────────────────────────────────────────────────
|
|
47
|
-
export { PROVIDERS, providerForModel, providerKeyPresent, providerStatuses,
|
|
46
|
+
export { PROVIDERS, providerForModel, providerKeyPresent, providerStatuses, logProviderStatuses, resolveModel,
|
|
48
47
|
// Listed as root exports in the 0.12.0 changelog but shipped only as a
|
|
49
48
|
// subpath until 0.16.0.
|
|
50
|
-
describeCapabilities, capabilitySummary, planTransport, gatewayConfig, gatewayProblem, gatewayUsable, GATEWAYS,
|
|
49
|
+
describeCapabilities, capabilitySummary, planTransport, gatewayConfig, gatewayProblem, gatewayUsable, GATEWAYS, } from './models/registry.js';
|
|
51
50
|
export { loadEnv } from './loadEnv.js';
|
|
@@ -50,7 +50,7 @@ export interface GenerateContentConfig {
|
|
|
50
50
|
reasoningEffort?: string;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Mirrors LlmAgentConfig (+ BaseAgentConfig) from Google ADK 2.2, whose names the YAML keeps.
|
|
54
54
|
*/
|
|
55
55
|
export interface AgentYamlConfig {
|
|
56
56
|
/** Unique agent name. Must be a valid JS identifier. Cannot be "user". */
|
|
@@ -214,7 +214,7 @@ export interface SyndicateYamlConfig {
|
|
|
214
214
|
memory_extraction_model?: string;
|
|
215
215
|
/** Days facts in this syndicate's namespace are kept (needs memory_namespace). */
|
|
216
216
|
memory_retention_days?: number;
|
|
217
|
-
/** Optional hard
|
|
217
|
+
/** Optional hard limit on the turn's model calls, subagents included (LLM -> Tool cycles). */
|
|
218
218
|
max_steps?: number;
|
|
219
219
|
/**
|
|
220
220
|
* The nested `yaml_reference:` syndicates this one reaches, raw, keyed by
|
|
@@ -286,7 +286,7 @@ export declare function parseCliBindings(argv: string[]): VariableMap;
|
|
|
286
286
|
* The A2A server used to read `config.guards` directly, which meant guards were
|
|
287
287
|
* honoured on exactly ONE composition: a top-level syndicate. Compose the same
|
|
288
288
|
* syndicate as a sub-agent — `yaml_reference:`, the repo's own idiom, already
|
|
289
|
-
* used across the shipped templates — and
|
|
289
|
+
* used across the shipped templates — and the compiler loads the nested config but never
|
|
290
290
|
* looks at `guards`, and the server only ever consults the PARENT's list. The
|
|
291
291
|
* nested syndicate's `guards: [science]` was dropped with no warning, because
|
|
292
292
|
* `resolveGuards`' unknown-name path cannot fire on a list nobody read.
|
|
@@ -197,7 +197,7 @@ const SHIPPED_DIRS = ['examples', 'templates'];
|
|
|
197
197
|
* The A2A server used to read `config.guards` directly, which meant guards were
|
|
198
198
|
* honoured on exactly ONE composition: a top-level syndicate. Compose the same
|
|
199
199
|
* syndicate as a sub-agent — `yaml_reference:`, the repo's own idiom, already
|
|
200
|
-
* used across the shipped templates — and
|
|
200
|
+
* used across the shipped templates — and the compiler loads the nested config but never
|
|
201
201
|
* looks at `guards`, and the server only ever consults the PARENT's list. The
|
|
202
202
|
* nested syndicate's `guards: [science]` was dropped with no warning, because
|
|
203
203
|
* `resolveGuards`' unknown-name path cannot fire on a list nobody read.
|
|
@@ -345,7 +345,7 @@ export function validateRegistryConfig(config) {
|
|
|
345
345
|
// A nested (yaml_reference) or remote (a2a_agent_url) agent brings its own
|
|
346
346
|
// model and instruction.
|
|
347
347
|
if (!config.name || (!config.yaml_reference && !config.a2a_agent_url && (!config.model || !config.instruction))) {
|
|
348
|
-
throw new Error(`[Validation Error] Configuration fails validation against
|
|
348
|
+
throw new Error(`[Validation Error] Configuration fails validation against the syndicate schema: an agent needs a name, and a model and an instruction unless it is a yaml_reference or an a2a_agent_url.`);
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* lib/memory/erase.ts — erase a scope from every store (ADR 0020 item 7).
|
|
3
3
|
*
|
|
4
4
|
* One call to `melchizedek_erase_scope` (db/migrations/0002_erase_scope.sql),
|
|
5
|
-
* which deletes memory facts, sessions (with the per-subagent rows
|
|
5
|
+
* which deletes memory facts, sessions (with the per-subagent rows kept
|
|
6
6
|
* beside them), the ledger's turns, spans, payloads, verdicts and labels, the
|
|
7
7
|
* scope's durable A2A tasks for those conversations, its memory ingestion
|
|
8
8
|
* markers, (without a namespace) its task tools' list and jobs
|
package/dist/lib/memory/erase.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* lib/memory/erase.ts — erase a scope from every store (ADR 0020 item 7).
|
|
3
3
|
*
|
|
4
4
|
* One call to `melchizedek_erase_scope` (db/migrations/0002_erase_scope.sql),
|
|
5
|
-
* which deletes memory facts, sessions (with the per-subagent rows
|
|
5
|
+
* which deletes memory facts, sessions (with the per-subagent rows kept
|
|
6
6
|
* beside them), the ledger's turns, spans, payloads, verdicts and labels, the
|
|
7
7
|
* scope's durable A2A tasks for those conversations, its memory ingestion
|
|
8
8
|
* markers, (without a namespace) its task tools' list and jobs
|
|
@@ -2,24 +2,22 @@
|
|
|
2
2
|
* lib/memory/namespace.ts — memory always resolves to the ROOT syndicate's
|
|
3
3
|
* namespace (ADR 0020 item 3).
|
|
4
4
|
*
|
|
5
|
-
* WHY:
|
|
6
|
-
* `appName = <the subagent's name>`, and its memory tools search with
|
|
7
|
-
* name. Facts are written under the root syndicate's
|
|
8
|
-
* `load_memory` declared on a subagent
|
|
9
|
-
* nothing, and
|
|
10
|
-
*
|
|
11
|
-
* name the caller carries.
|
|
5
|
+
* WHY: a DELEGATE subagent runs on its own session row under
|
|
6
|
+
* `appName = <the subagent's name>`, and its memory tools search with the
|
|
7
|
+
* session's app name. Facts are written under the root syndicate's
|
|
8
|
+
* namespace, so a `load_memory` declared on a subagent would search
|
|
9
|
+
* `<SubAgent>/<user>`, find nothing, and say so without error. Wrapping the
|
|
10
|
+
* service the runtime receives pins every search and ingestion to one
|
|
11
|
+
* namespace, whatever app name the caller carries.
|
|
12
12
|
*
|
|
13
|
-
* The pin covers
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* their key or namespace themselves.
|
|
13
|
+
* The pin covers the engine's MemoryService (`search`, `ingest`,
|
|
14
|
+
* lib/runtime/memoryService.ts, ADR 0059). Every other member, erase and
|
|
15
|
+
* retention included, passes through unchanged: they name their key or
|
|
16
|
+
* namespace themselves.
|
|
18
17
|
*/
|
|
19
|
-
import type { BaseMemoryService } from '@google/adk';
|
|
20
18
|
import type { MemoryService } from '../runtime/memoryService.ts';
|
|
21
19
|
/** A memory service whose every read and write uses `namespace` as the app name. */
|
|
22
|
-
export declare function namespacedMemoryService<T extends
|
|
20
|
+
export declare function namespacedMemoryService<T extends MemoryService>(base: T, namespace: string): T;
|
|
23
21
|
/** The server-wide name memory falls back to when a syndicate declares none. */
|
|
24
22
|
export declare const LEGACY_MEMORY_APP_NAME = "melchizedek-a2a";
|
|
25
23
|
/**
|
|
@@ -2,25 +2,24 @@
|
|
|
2
2
|
* lib/memory/namespace.ts — memory always resolves to the ROOT syndicate's
|
|
3
3
|
* namespace (ADR 0020 item 3).
|
|
4
4
|
*
|
|
5
|
-
* WHY:
|
|
6
|
-
* `appName = <the subagent's name>`, and its memory tools search with
|
|
7
|
-
* name. Facts are written under the root syndicate's
|
|
8
|
-
* `load_memory` declared on a subagent
|
|
9
|
-
* nothing, and
|
|
10
|
-
*
|
|
11
|
-
* name the caller carries.
|
|
5
|
+
* WHY: a DELEGATE subagent runs on its own session row under
|
|
6
|
+
* `appName = <the subagent's name>`, and its memory tools search with the
|
|
7
|
+
* session's app name. Facts are written under the root syndicate's
|
|
8
|
+
* namespace, so a `load_memory` declared on a subagent would search
|
|
9
|
+
* `<SubAgent>/<user>`, find nothing, and say so without error. Wrapping the
|
|
10
|
+
* service the runtime receives pins every search and ingestion to one
|
|
11
|
+
* namespace, whatever app name the caller carries.
|
|
12
12
|
*
|
|
13
|
-
* The pin covers
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* their key or namespace themselves.
|
|
13
|
+
* The pin covers the engine's MemoryService (`search`, `ingest`,
|
|
14
|
+
* lib/runtime/memoryService.ts, ADR 0059). Every other member, erase and
|
|
15
|
+
* retention included, passes through unchanged: they name their key or
|
|
16
|
+
* namespace themselves.
|
|
18
17
|
*/
|
|
19
18
|
import { randomBytes } from 'node:crypto';
|
|
20
19
|
import fs from 'node:fs';
|
|
21
20
|
import path from 'node:path';
|
|
22
|
-
/** The
|
|
23
|
-
const PINNED = new Set(['
|
|
21
|
+
/** The methods whose first argument carries the app name the pin replaces. */
|
|
22
|
+
const PINNED = new Set(['search', 'ingest']);
|
|
24
23
|
/** A memory service whose every read and write uses `namespace` as the app name. */
|
|
25
24
|
export function namespacedMemoryService(base, namespace) {
|
|
26
25
|
if (!namespace)
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* dimension needs a re-embed, not just a new variable.
|
|
30
30
|
*/
|
|
31
31
|
import type { ProviderEndpoint } from '../models/endpoints.ts';
|
|
32
|
-
import type {
|
|
32
|
+
import type { ModelAdapter } from '../models/contract.ts';
|
|
33
33
|
export interface MemoryExtractor {
|
|
34
34
|
/** The model id, for logs and the ledger. */
|
|
35
35
|
readonly model: string;
|
|
@@ -51,14 +51,13 @@ export interface ModelExtractorOptions {
|
|
|
51
51
|
temperature?: number;
|
|
52
52
|
maxOutputTokens?: number;
|
|
53
53
|
/** Test seam: produce the adapter. Default lib/models/registry.ts resolveModel. */
|
|
54
|
-
resolve?: (model: string, apiKey?: string) =>
|
|
55
|
-
generateContentAsync(req: LlmRequest, stream?: boolean): AsyncGenerator<LlmResponse, void>;
|
|
56
|
-
};
|
|
54
|
+
resolve?: (model: string, apiKey?: string) => ModelAdapter;
|
|
57
55
|
}
|
|
58
56
|
/**
|
|
59
57
|
* Extraction on any model id. The key passed here reaches only a model of
|
|
60
58
|
* the matching provider (resolveModel's BYOK rule); other providers read
|
|
61
|
-
* their own key from the environment, exactly like an agent would.
|
|
59
|
+
* their own key from the environment, exactly like an agent would. The call
|
|
60
|
+
* is traced as one `llm.request` (traceLlmGeneration), as every model call is.
|
|
62
61
|
*/
|
|
63
62
|
export declare function modelExtractor(opts?: ModelExtractorOptions): MemoryExtractor;
|
|
64
63
|
export declare function geminiEmbedder(opts: {
|
|
@@ -31,15 +31,17 @@
|
|
|
31
31
|
import { endpointFromEnv } from '../models/endpoints.js';
|
|
32
32
|
import { GoogleGenAI } from '@google/genai';
|
|
33
33
|
import { trace, SpanStatusCode } from '@opentelemetry/api';
|
|
34
|
+
import { llmRequestToModelRequest, modelResponseToLlmResponse } from '../models/genaiMapping.js';
|
|
34
35
|
import { EMBEDDING_DIMENSIONS, EMBEDDING_MODEL, MEMORY_EXTRACTION_MODEL } from '../config.js';
|
|
35
36
|
import { providerForModel } from '../models/providerMap.js';
|
|
36
37
|
import { resolveModel } from '../models/registry.js';
|
|
37
|
-
import { initializeTracing } from '../observability/tracer.js';
|
|
38
|
+
import { initializeTracing, traceLlmGeneration } from '../observability/tracer.js';
|
|
38
39
|
import { trimTrailingSlashes } from '../models/urls.js';
|
|
39
40
|
/**
|
|
40
41
|
* Extraction on any model id. The key passed here reaches only a model of
|
|
41
42
|
* the matching provider (resolveModel's BYOK rule); other providers read
|
|
42
|
-
* their own key from the environment, exactly like an agent would.
|
|
43
|
+
* their own key from the environment, exactly like an agent would. The call
|
|
44
|
+
* is traced as one `llm.request` (traceLlmGeneration), as every model call is.
|
|
43
45
|
*/
|
|
44
46
|
export function modelExtractor(opts = {}) {
|
|
45
47
|
const model = opts.model ?? MEMORY_EXTRACTION_MODEL;
|
|
@@ -48,16 +50,20 @@ export function modelExtractor(opts = {}) {
|
|
|
48
50
|
return {
|
|
49
51
|
model,
|
|
50
52
|
async extract(prompt) {
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
+
const adapter = resolve(model, opts.apiKey);
|
|
54
|
+
const llmRequest = {
|
|
53
55
|
model,
|
|
54
56
|
contents: [{ role: 'user', parts: [{ text: prompt }] }],
|
|
55
57
|
config: { temperature: opts.temperature ?? 0.1, maxOutputTokens: opts.maxOutputTokens ?? 4096 },
|
|
56
|
-
liveConnectConfig: {},
|
|
57
58
|
toolsDict: {},
|
|
58
59
|
};
|
|
60
|
+
const request = llmRequestToModelRequest(llmRequest, { model, stream: false });
|
|
61
|
+
async function* inner() {
|
|
62
|
+
for await (const response of adapter.generate(request))
|
|
63
|
+
yield modelResponseToLlmResponse(response);
|
|
64
|
+
}
|
|
59
65
|
let text = '';
|
|
60
|
-
for await (const response of
|
|
66
|
+
for await (const response of traceLlmGeneration({ provider: adapter.provider, model, request }, inner())) {
|
|
61
67
|
if (response.errorCode) {
|
|
62
68
|
throw new Error(`${model}: ${response.errorCode}${response.errorMessage ? ` — ${response.errorMessage}` : ''}`);
|
|
63
69
|
}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* lib/memory/supabaseMemoryService.ts — long-term memory over pgvector
|
|
3
|
-
* (ADR 0020), on the engine's own interface
|
|
3
|
+
* (ADR 0020), on the engine's own interface (ADR 0107).
|
|
4
4
|
*
|
|
5
5
|
* The class implements the engine's MemoryService (lib/runtime/memoryService.ts:
|
|
6
6
|
* `ingest`, `search`, and the optional `deleteUserMemory`, `pruneExpired`
|
|
7
|
-
* and `verifyEmbeddingDimensions`, ADR 0052), which the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `searchMemory` the ADK runtime's Runner, the turn runner's ingestion
|
|
11
|
-
* (ingestTurnMemory) and the A2A server call: each is one line that hands
|
|
12
|
-
* its arguments to `ingest` or `search`, so both runtimes reach the same
|
|
13
|
-
* logic and the same silos (ADR 0059).
|
|
7
|
+
* and `verifyEmbeddingDimensions`, ADR 0052), which the runtime, the turn
|
|
8
|
+
* runner's ingestion (ingestTurnMemory), the A2A server and the engine's
|
|
9
|
+
* memory tools (lib/tools/memoryTools.ts) call (ADR 0059).
|
|
14
10
|
*/
|
|
15
|
-
import type { BaseMemoryService, SearchMemoryRequest, SearchMemoryResponse, Session as AdkSession } from '@google/adk';
|
|
16
11
|
import type { SupabaseClient } from '@supabase/supabase-js';
|
|
17
12
|
import type { MemoryIngestOptions, MemorySearchRequest, MemorySearchResult, MemoryService } from '../runtime/memoryService.ts';
|
|
18
13
|
import type { Session } from '../runtime/sessions.ts';
|
|
@@ -45,7 +40,7 @@ export declare const MEMORY_DEDUP_SIMILARITY = 0.93;
|
|
|
45
40
|
/**
|
|
46
41
|
* Which of a session's events still need ingesting.
|
|
47
42
|
*
|
|
48
|
-
* The A2A server is stateless, so `
|
|
43
|
+
* The A2A server is stateless, so `ingest` runs after EVERY task
|
|
49
44
|
* with the WHOLE session — an N-turn conversation was being extracted N times
|
|
50
45
|
* over a growing transcript. That produced 13 EPISODE records narrating the
|
|
51
46
|
* same session and one balance stored six ways. A high-water mark per session
|
|
@@ -67,7 +62,7 @@ export declare function isSemanticDuplicate(candidate: {
|
|
|
67
62
|
status: string | null;
|
|
68
63
|
similarity: number;
|
|
69
64
|
}>, threshold?: number): boolean;
|
|
70
|
-
export declare class SupabaseVectorMemoryService implements MemoryService
|
|
65
|
+
export declare class SupabaseVectorMemoryService implements MemoryService {
|
|
71
66
|
private extractor;
|
|
72
67
|
private embedder;
|
|
73
68
|
private store;
|
|
@@ -105,24 +100,14 @@ export declare class SupabaseVectorMemoryService implements MemoryService, BaseM
|
|
|
105
100
|
/** Builds the extractor for a syndicate's memory_extraction_model. Default: modelExtractor. */
|
|
106
101
|
extractorFor?: (model: string) => MemoryExtractor;
|
|
107
102
|
}, backend: SupabaseClient | MemoryStore);
|
|
108
|
-
/**
|
|
109
|
-
* ADK's name for `ingest`, which the ADK runtime and the A2A server call.
|
|
110
|
-
*
|
|
111
|
-
* @param extractionRules Optional domain rules appended to the shared
|
|
112
|
-
* extraction prompt for THIS consumer only. The prompt is global (the
|
|
113
|
-
* patient advocate uses the same one), so anything domain-specific —
|
|
114
|
-
* "never store a market quote" — arrives here rather than being edited
|
|
115
|
-
* into it. Declared as `memory_extraction_rules` on the served syndicate.
|
|
116
|
-
*/
|
|
117
|
-
addSessionToMemory(session: AdkSession, extractionRules?: string, options?: {
|
|
118
|
-
extractionModel?: string;
|
|
119
|
-
}): Promise<void>;
|
|
120
103
|
/**
|
|
121
104
|
* Distils the session's events not yet ingested into facts filed under
|
|
122
105
|
* `<appName>/<userId>`. Throws when a step fails, leaving those events
|
|
123
106
|
* pending for the next ingestion (ADR 0020 item 6).
|
|
124
107
|
*
|
|
125
|
-
* @param options.extractionRules The syndicate's `memory_extraction_rules
|
|
108
|
+
* @param options.extractionRules The syndicate's `memory_extraction_rules`:
|
|
109
|
+
* domain rules appended to the shared extraction prompt for this
|
|
110
|
+
* syndicate only ("never store a market quote").
|
|
126
111
|
* @param options.extractionModel The syndicate's `memory_extraction_model`.
|
|
127
112
|
*/
|
|
128
113
|
ingest(session: Session, options?: MemoryIngestOptions): Promise<void>;
|
|
@@ -136,12 +121,6 @@ export declare class SupabaseVectorMemoryService implements MemoryService, BaseM
|
|
|
136
121
|
* `adk_sessions` and must be cleared separately if full erasure is needed.
|
|
137
122
|
*/
|
|
138
123
|
deleteUserMemory(userKey: string): Promise<number>;
|
|
139
|
-
/**
|
|
140
|
-
* ADK's name for `search`, which ADK's Context.searchMemory calls. The
|
|
141
|
-
* entries are the same JSON as ADK's MemoryEntry; only genai's types name
|
|
142
|
-
* a few part fields as enums, hence the cast.
|
|
143
|
-
*/
|
|
144
|
-
searchMemory(request: SearchMemoryRequest): Promise<SearchMemoryResponse>;
|
|
145
124
|
/** The facts most relevant to the query, from the `<appName>/<userId>` silo only. */
|
|
146
125
|
search(request: MemorySearchRequest): Promise<MemorySearchResult>;
|
|
147
126
|
/**
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* lib/memory/supabaseMemoryService.ts — long-term memory over pgvector
|
|
3
|
-
* (ADR 0020), on the engine's own interface
|
|
3
|
+
* (ADR 0020), on the engine's own interface (ADR 0107).
|
|
4
4
|
*
|
|
5
5
|
* The class implements the engine's MemoryService (lib/runtime/memoryService.ts:
|
|
6
6
|
* `ingest`, `search`, and the optional `deleteUserMemory`, `pruneExpired`
|
|
7
|
-
* and `verifyEmbeddingDimensions`, ADR 0052), which the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `searchMemory` the ADK runtime's Runner, the turn runner's ingestion
|
|
11
|
-
* (ingestTurnMemory) and the A2A server call: each is one line that hands
|
|
12
|
-
* its arguments to `ingest` or `search`, so both runtimes reach the same
|
|
13
|
-
* logic and the same silos (ADR 0059).
|
|
7
|
+
* and `verifyEmbeddingDimensions`, ADR 0052), which the runtime, the turn
|
|
8
|
+
* runner's ingestion (ingestTurnMemory), the A2A server and the engine's
|
|
9
|
+
* memory tools (lib/tools/memoryTools.ts) call (ADR 0059).
|
|
14
10
|
*/
|
|
15
11
|
import { memoryProvidersFromEnv, modelExtractor } from './providers.js';
|
|
16
12
|
import { providerForModel } from '../models/providerMap.js';
|
|
@@ -91,7 +87,7 @@ export const MEMORY_DEDUP_SIMILARITY = 0.93;
|
|
|
91
87
|
/**
|
|
92
88
|
* Which of a session's events still need ingesting.
|
|
93
89
|
*
|
|
94
|
-
* The A2A server is stateless, so `
|
|
90
|
+
* The A2A server is stateless, so `ingest` runs after EVERY task
|
|
95
91
|
* with the WHOLE session — an N-turn conversation was being extracted N times
|
|
96
92
|
* over a growing transcript. That produced 13 EPISODE records narrating the
|
|
97
93
|
* same session and one balance stored six ways. A high-water mark per session
|
|
@@ -162,24 +158,14 @@ export class SupabaseVectorMemoryService {
|
|
|
162
158
|
console.log(`[MemoryService] Initialized — backend: Supabase Vector Search (pgvector), structured records; `
|
|
163
159
|
+ `extraction ${this.extractor.model}, embeddings ${this.embedder.provider}/${this.embedder.model} (${this.embedder.dimensions}d)`);
|
|
164
160
|
}
|
|
165
|
-
/**
|
|
166
|
-
* ADK's name for `ingest`, which the ADK runtime and the A2A server call.
|
|
167
|
-
*
|
|
168
|
-
* @param extractionRules Optional domain rules appended to the shared
|
|
169
|
-
* extraction prompt for THIS consumer only. The prompt is global (the
|
|
170
|
-
* patient advocate uses the same one), so anything domain-specific —
|
|
171
|
-
* "never store a market quote" — arrives here rather than being edited
|
|
172
|
-
* into it. Declared as `memory_extraction_rules` on the served syndicate.
|
|
173
|
-
*/
|
|
174
|
-
async addSessionToMemory(session, extractionRules, options = {}) {
|
|
175
|
-
return this.ingest(session, { extractionRules, extractionModel: options.extractionModel });
|
|
176
|
-
}
|
|
177
161
|
/**
|
|
178
162
|
* Distils the session's events not yet ingested into facts filed under
|
|
179
163
|
* `<appName>/<userId>`. Throws when a step fails, leaving those events
|
|
180
164
|
* pending for the next ingestion (ADR 0020 item 6).
|
|
181
165
|
*
|
|
182
|
-
* @param options.extractionRules The syndicate's `memory_extraction_rules
|
|
166
|
+
* @param options.extractionRules The syndicate's `memory_extraction_rules`:
|
|
167
|
+
* domain rules appended to the shared extraction prompt for this
|
|
168
|
+
* syndicate only ("never store a market quote").
|
|
183
169
|
* @param options.extractionModel The syndicate's `memory_extraction_model`.
|
|
184
170
|
*/
|
|
185
171
|
async ingest(session, options = {}) {
|
|
@@ -268,14 +254,6 @@ export class SupabaseVectorMemoryService {
|
|
|
268
254
|
console.log(`[MemoryService] Deleted ${count} fact(s) for user key: ${userKey}`);
|
|
269
255
|
return count;
|
|
270
256
|
}
|
|
271
|
-
/**
|
|
272
|
-
* ADK's name for `search`, which ADK's Context.searchMemory calls. The
|
|
273
|
-
* entries are the same JSON as ADK's MemoryEntry; only genai's types name
|
|
274
|
-
* a few part fields as enums, hence the cast.
|
|
275
|
-
*/
|
|
276
|
-
async searchMemory(request) {
|
|
277
|
-
return (await this.search(request));
|
|
278
|
-
}
|
|
279
257
|
/** The facts most relevant to the query, from the `<appName>/<userId>` silo only. */
|
|
280
258
|
async search(request) {
|
|
281
259
|
const query = stripHarnessBlocks(request.query) || request.query;
|
package/dist/lib/model.d.ts
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* lib/model.ts — the `melchizedek-agents/model` entry: the engine's model
|
|
3
|
-
* layer on its own
|
|
3
|
+
* layer on its own (ADR 0068).
|
|
4
4
|
*
|
|
5
5
|
* What it holds: the model contract's types (ADR 0048), every provider's
|
|
6
6
|
* contract adapter, resolveAdapter and resolveAdapterWithFallback over the
|
|
7
7
|
* one prefix table (ADR 0060), FallbackAdapter and the circuit breaker's
|
|
8
8
|
* helpers (ADR 0044). A consumer can call any model through it without
|
|
9
|
-
*
|
|
9
|
+
* loading the compiler or the runtime.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* registerAvailableProviders. They stay at `melchizedek-agents/models/*`.
|
|
11
|
+
* Gemini: resolveAdapter returns the engine's GeminiAdapter for a Gemini id;
|
|
12
|
+
* GEMINI_ADAPTER=adk throws, naming 1.0.0 (ADR 0107).
|
|
14
13
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* names `melchizedek-agents/models/registry`, whose resolveAdapter keeps
|
|
18
|
-
* ADR 0060's default until gate G3.
|
|
19
|
-
*
|
|
20
|
-
* tests/packageSurface.test.ts walks this module's runtime import graph and
|
|
21
|
-
* fails if any module in it names @google/adk.
|
|
14
|
+
* tests/packageSurface.test.ts walks this module's runtime import graph:
|
|
15
|
+
* @google/* appears in it only in the Gemini adapter and the genai mapping.
|
|
22
16
|
*/
|
|
23
17
|
export type * from './models/contract.ts';
|
|
24
18
|
export { resolveAdapter, resolveAdapterWithFallback, geminiAdapterSetting } from './models/adapterResolver.ts';
|