melchizedek-agents 0.19.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 +492 -76
- package/DOCUMENTATION.md +153 -132
- package/QUICKSTART.md +14 -10
- package/README.md +12 -15
- package/config/agents/examples/image_production.yaml +2 -2
- package/config/agents/syndicateSchema.yaml +55 -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/adkPeer.d.ts +63 -0
- package/dist/lib/adkPeer.js +240 -0
- package/dist/lib/compile.d.ts +109 -81
- package/dist/lib/compile.js +163 -111
- package/dist/lib/compileAdk.d.ts +7 -4
- package/dist/lib/compileAdk.js +22 -12
- package/dist/lib/compileNative.d.ts +63 -49
- package/dist/lib/compileNative.js +136 -78
- package/dist/lib/config.d.ts +6 -6
- package/dist/lib/config.js +6 -6
- package/dist/lib/doctor.d.ts +22 -1
- package/dist/lib/doctor.js +27 -2
- package/dist/lib/index.d.ts +14 -7
- package/dist/lib/index.js +11 -7
- 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 -38
- package/dist/lib/models/adapterResolver.js +33 -40
- package/dist/lib/models/adkGeminiAdapter.js +2 -0
- package/dist/lib/models/adkShim.d.ts +1 -1
- package/dist/lib/models/adkShim.js +1 -1
- package/dist/lib/models/capabilities.js +13 -10
- 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/claudeLlm.js +2 -2
- 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/fallback.d.ts +1 -1
- package/dist/lib/models/fallback.js +1 -1
- 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/gatewayLlm.js +2 -2
- package/dist/lib/models/geminiAdapter.d.ts +11 -10
- package/dist/lib/models/geminiAdapter.js +37 -15
- package/dist/lib/models/geminiState.d.ts +29 -8
- package/dist/lib/models/geminiState.js +34 -8
- package/dist/lib/models/genaiMapping.d.ts +104 -38
- package/dist/lib/models/genaiMapping.js +146 -43
- package/dist/lib/models/gptAdapter.d.ts +11 -11
- package/dist/lib/models/gptAdapter.js +13 -13
- package/dist/lib/models/gptLlm.js +2 -2
- package/dist/lib/models/grokLlm.js +2 -2
- package/dist/lib/models/kimiAdapter.d.ts +6 -7
- package/dist/lib/models/kimiAdapter.js +6 -9
- package/dist/lib/models/kimiLlm.js +2 -2
- package/dist/lib/models/ollamaAdapter.d.ts +3 -3
- package/dist/lib/models/ollamaAdapter.js +3 -3
- package/dist/lib/models/ollamaLlm.js +2 -2
- 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 -69
- package/dist/lib/models/registry.js +32 -140
- 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/models/tracedGemini.d.ts +1 -1
- package/dist/lib/models/tracedGemini.js +1 -1
- 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/adkSessionBridge.d.ts +1 -1
- package/dist/lib/runtime/adkSessionBridge.js +1 -1
- package/dist/lib/runtime/approvals.d.ts +6 -1
- package/dist/lib/runtime/approvals.js +39 -8
- package/dist/lib/runtime/credentials.d.ts +4 -2
- package/dist/lib/runtime/credentials.js +6 -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 +24 -16
- package/dist/lib/runtime/native/agentLoop.js +67 -37
- 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 +64 -12
- package/dist/lib/runtime/native/delegate.js +101 -25
- 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 +12 -9
- package/dist/lib/runtime/native/interrupts.js +29 -10
- package/dist/lib/runtime/native/request.d.ts +25 -25
- package/dist/lib/runtime/native/request.js +36 -25
- package/dist/lib/runtime/native/selfCorrection.d.ts +75 -17
- package/dist/lib/runtime/native/selfCorrection.js +93 -19
- package/dist/lib/runtime/native/step.d.ts +34 -26
- package/dist/lib/runtime/native/step.js +78 -32
- 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 +35 -13
- package/dist/lib/runtime/runtimeFlag.js +46 -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 +46 -42
- package/dist/lib/runtime/syndicateTurn.js +182 -150
- package/dist/lib/runtime/turnControl.d.ts +8 -8
- package/dist/lib/runtime/turnControl.js +8 -8
- package/dist/lib/runtime/valueDepth.d.ts +23 -0
- package/dist/lib/runtime/valueDepth.js +41 -0
- 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 -55
- package/dist/lib/storage/postgres/sessionService.d.ts +6 -20
- package/dist/lib/storage/postgres/sessionService.js +6 -39
- package/dist/lib/syndicateSchema.d.ts +2 -0
- package/dist/lib/syndicateSchema.js +32 -10
- package/dist/lib/toolRegistry.d.ts +20 -14
- package/dist/lib/toolRegistry.js +76 -33
- package/dist/lib/tools/adkTool.d.ts +1 -1
- package/dist/lib/tools/adkTool.js +1 -1
- package/dist/lib/tools/auth.d.ts +1 -1
- package/dist/lib/tools/auth.js +1 -1
- package/dist/lib/tools/collectionsSearchTool.d.ts +1 -1
- package/dist/lib/tools/collectionsSearchTool.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/urlContextTool.d.ts +1 -1
- package/dist/lib/tools/urlContextTool.js +1 -1
- package/dist/lib/tools/webExtractTool.d.ts +2 -2
- package/dist/lib/tools/webExtractTool.js +3 -4
- package/dist/lib/tools/webSearchTool.d.ts +1 -1
- package/dist/lib/tools/webSearchTool.js +1 -1
- 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/xSearchTool.d.ts +1 -1
- package/dist/lib/tools/xSearchTool.js +1 -1
- 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 -41
- package/dist/lib/workflow/agentNode.d.ts +31 -5
- package/dist/lib/workflow/agentNode.js +101 -8
- package/dist/lib/workflow/graph.d.ts +13 -13
- package/dist/lib/workflow/graph.js +25 -15
- 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 +14 -13
- package/dist/lib/workflow/resume.js +17 -16
- package/dist/lib/workflow/route.d.ts +7 -7
- package/dist/lib/workflow/route.js +8 -8
- package/dist/lib/workflow/scheduler.d.ts +54 -9
- package/dist/lib/workflow/scheduler.js +75 -8
- 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 +38 -42
- package/dist/lib/workflow.js +38 -150
- package/dist/lib/workflowConfig.d.ts +6 -10
- package/dist/lib/workflowConfig.js +2 -27
- 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 +3 -1
- package/dist/scripts/doctor.js +4 -2
- package/dist/scripts/syndicate_chat.js +14 -24
- package/package.json +3 -6
- 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
|
@@ -1,84 +1,98 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* lib/compileNative.ts — an AgentSpec as the
|
|
3
|
-
* NativeAgent the agent loop takes (ADR 0045, ADR 0073).
|
|
2
|
+
* lib/compileNative.ts — an AgentSpec as the runtime runs it: the
|
|
3
|
+
* NativeAgent the agent loop takes (ADR 0045, ADR 0073, ADR 0107).
|
|
4
4
|
*
|
|
5
5
|
* WHY this file exists:
|
|
6
|
-
* lib/compile.ts turns a YAML agent into
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* NativeAgent), so both runtimes run the agent the YAML describes, with
|
|
10
|
-
* the same tools, instruction and config. tests/compile.test.ts compiles
|
|
11
|
-
* one spec both ways and requires the same first request.
|
|
6
|
+
* lib/compile.ts turns a YAML agent into an AgentSpec. This file builds
|
|
7
|
+
* the loop's agent from it (lib/runtime/native/request.ts, NativeAgent),
|
|
8
|
+
* with the tools, instruction and config the YAML describes.
|
|
12
9
|
*
|
|
13
|
-
* TOOLS: each resolved tool is handed to the loop as the own Tool
|
|
14
|
-
* InstructionTool
|
|
15
|
-
*
|
|
16
|
-
* runs
|
|
17
|
-
*
|
|
18
|
-
* a
|
|
19
|
-
*
|
|
20
|
-
* Tool the ADK runtime's FunctionTool wraps (lib/a2a/remoteAgent.ts).
|
|
10
|
+
* TOOLS: each resolved tool is handed to the loop as the own Tool,
|
|
11
|
+
* InstructionTool or Toolset it is (lib/tools/tool.ts). A delegated
|
|
12
|
+
* subagent becomes a subagentTool holding its own NativeAgent, which the
|
|
13
|
+
* loop runs as a child loop (lib/runtime/native/delegate.ts, ADR 0074), a
|
|
14
|
+
* nested syndicate as its orchestrator's agent, a nested workflow syndicate
|
|
15
|
+
* as a workflowSubagentTool whose call walks the whole graph (ADR 0098); a
|
|
16
|
+
* remote A2A subagent is its own Tool (lib/a2a/remoteAgent.ts).
|
|
21
17
|
*
|
|
22
|
-
* EVERY AGENT KEY COMPILES
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* question, a caller's agent transform) is refused by the turn runner
|
|
29
|
-
* (lib/runtime/nativeTurn.ts), which owns those choices.
|
|
18
|
+
* EVERY AGENT KEY COMPILES: `context:` is handed to the loop, which
|
|
19
|
+
* compacts (lib/runtime/native/compaction.ts); `mode: task` and
|
|
20
|
+
* `code_execution: gemini` pass through, the request declaring finish_task
|
|
21
|
+
* (lib/runtime/native/taskMode.ts) and asking Gemini for its
|
|
22
|
+
* code-execution tool (lib/runtime/native/request.ts). What the runtime
|
|
23
|
+
* does not run is refused by the turn runner (lib/runtime/nativeTurn.ts).
|
|
30
24
|
*
|
|
31
25
|
* THE MODEL: the loop calls a model through its contract adapter. A
|
|
32
|
-
* resolver
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* ADK classes are told apart by ADK's own Symbol.for marks, so
|
|
39
|
-
* imports nothing from ADK.
|
|
26
|
+
* resolver returns an id, a ModelAdapter or undefined. Anything else is
|
|
27
|
+
* refused with UnsupportedOnRuntimeError by compileNative and
|
|
28
|
+
* nativeAdapterFor before any model call, rather than run the registry's
|
|
29
|
+
* model for that id in its place (ADR 0088, ADR 0107): an ADK model class (a
|
|
30
|
+
* resolver written for 0.x) has no adapter behind it, and a plain
|
|
31
|
+
* `{ model, apiKey }` object would run on the operator's env key, not the
|
|
32
|
+
* caller's. ADK classes are told apart by ADK's own Symbol.for marks, so
|
|
33
|
+
* this file imports nothing from ADK.
|
|
40
34
|
*/
|
|
41
|
-
import type { AgentSpec, CompileOptions } from './compile.ts';
|
|
35
|
+
import type { AgentSpec, CompileOptions, WorkflowSpec } from './compile.ts';
|
|
42
36
|
import type { SubagentYamlConfig, SyndicateYamlConfig } from './loadSyndicate.ts';
|
|
43
37
|
import type { ModelAdapter } from './models/contract.ts';
|
|
38
|
+
import type { WorkflowSubagent } from './runtime/native/delegate.ts';
|
|
44
39
|
import type { NativeAgent } from './runtime/native/request.ts';
|
|
45
40
|
export { UnsupportedOnRuntimeError, unsupportedOnNative } from './runtime/runtimeFlag.ts';
|
|
41
|
+
import type { WorkflowGraph } from './workflow/graph.ts';
|
|
46
42
|
/**
|
|
47
|
-
* The class name of an ADK model the
|
|
48
|
-
*
|
|
49
|
-
* included) nor a shim carrying a contract adapter (lib/models/adkShim.ts).
|
|
43
|
+
* The class name of an ADK model the runtime cannot run, else undefined:
|
|
44
|
+
* any ADK BaseLlm (ADR 0107; the ADK runtime that ran one left in 1.0.0).
|
|
50
45
|
*/
|
|
51
46
|
export declare function unrunnableModelClass(resolved: unknown): string | undefined;
|
|
52
47
|
/**
|
|
53
48
|
* The NativeAgent for `spec`. Throws when no model id is known, and
|
|
54
|
-
* UnsupportedOnRuntimeError when the resolver returned
|
|
55
|
-
*
|
|
49
|
+
* UnsupportedOnRuntimeError when the resolver returned anything but an id,
|
|
50
|
+
* a ModelAdapter or undefined (see the header).
|
|
56
51
|
*/
|
|
57
52
|
export declare function compileNative(spec: AgentSpec): NativeAgent;
|
|
58
53
|
/**
|
|
59
|
-
* The model id a request is sent under
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* circuit breaker then see that id on both runtimes.
|
|
54
|
+
* The model id a request is sent under: the id of the adapter the resolver
|
|
55
|
+
* returned, else the id the resolver returned, else the spec's. A resolver
|
|
56
|
+
* may answer a YAML id with a model under another id (a gateway stand-in, a
|
|
57
|
+
* caller's alias); the adapter, the span and the circuit breaker then see
|
|
58
|
+
* that id.
|
|
65
59
|
*/
|
|
66
60
|
export declare function wireModelOf(spec: Pick<AgentSpec, 'modelId' | 'resolvedModel'>): string | undefined;
|
|
67
61
|
/** A syndicate's orchestrator for the native loop: compileSpec, then compileNative. */
|
|
68
62
|
export declare function compileNativeGraph(config: SyndicateYamlConfig, opts?: CompileOptions): Promise<NativeAgent>;
|
|
63
|
+
/** A workflow syndicate for the native walk (lib/workflow/turn.ts): its graph, every agent by YAML name, and the tool nodes' lookup. */
|
|
64
|
+
export interface NativeWorkflow {
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
graph: WorkflowGraph;
|
|
68
|
+
agents: Map<string, NativeAgent>;
|
|
69
|
+
resolveTool: (name: string) => unknown;
|
|
70
|
+
/** The nodes that are a nested workflow syndicate, each compiled the same way, by YAML name (ADR 0106). */
|
|
71
|
+
workflows: Map<string, NativeWorkflow>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A workflow spec for the walk: the graph, every agent compiled from its
|
|
75
|
+
* spec, and the registry's lookup for tool nodes. An unregistered or
|
|
76
|
+
* long-running tool node is refused here, before any model call.
|
|
77
|
+
*/
|
|
78
|
+
export declare function compileNativeWorkflow(spec: WorkflowSpec): NativeWorkflow;
|
|
79
|
+
/**
|
|
80
|
+
* A nested workflow as the delegated subagent the native loop calls (ADR
|
|
81
|
+
* 0098): one call walks the whole graph with runNativeWorkflow on the child
|
|
82
|
+
* session lib/runtime/native/delegate.ts opened.
|
|
83
|
+
*/
|
|
84
|
+
export declare function workflowSubagentOf(workflow: NativeWorkflow): WorkflowSubagent;
|
|
69
85
|
/** One subagent entry (a dispatch route) for the native loop: compileSubagentSpec, then compileNative. */
|
|
70
86
|
export declare function compileNativeSubagent(subCfg: SubagentYamlConfig, opts?: CompileOptions): Promise<NativeAgent>;
|
|
71
87
|
/** What nativeAdapterFor reads from a spec: its model resolution, the other ids it calls, and its delegated subagents. */
|
|
72
88
|
type NativeModelSpec = Pick<AgentSpec, 'modelId' | 'resolvedModel'> & Partial<Pick<AgentSpec, 'name' | 'fallbackModel' | 'context' | 'tools'>>;
|
|
73
89
|
/**
|
|
74
|
-
* The loop's `adapterFor
|
|
75
|
-
*
|
|
76
|
-
* (an ADK shim carries its contract adapter, so a caller's BYOK key on a
|
|
77
|
-
* shimmed provider reaches the call), else resolveAdapter for the id
|
|
90
|
+
* The loop's `adapterFor`: the adapter CompileOptions.resolveModel returns
|
|
91
|
+
* (so a caller's BYOK key reaches the call), else resolveAdapter for the id
|
|
78
92
|
* (lib/models/registry.ts). The spec's own resolution, and each delegated
|
|
79
93
|
* subagent's, is reused for the id its agent runs under (wireModelOf).
|
|
80
94
|
* Each agent's `fallback_model:` and compaction `summary_model` are
|
|
81
|
-
* resolved here,
|
|
95
|
+
* resolved here, at compile time, so a model
|
|
82
96
|
* class native cannot run is refused before any model call; any other id
|
|
83
97
|
* is resolved when first asked for. Each is kept.
|
|
84
98
|
*/
|
|
@@ -1,83 +1,104 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* lib/compileNative.ts — an AgentSpec as the
|
|
3
|
-
* NativeAgent the agent loop takes (ADR 0045, ADR 0073).
|
|
2
|
+
* lib/compileNative.ts — an AgentSpec as the runtime runs it: the
|
|
3
|
+
* NativeAgent the agent loop takes (ADR 0045, ADR 0073, ADR 0107).
|
|
4
4
|
*
|
|
5
5
|
* WHY this file exists:
|
|
6
|
-
* lib/compile.ts turns a YAML agent into
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* NativeAgent), so both runtimes run the agent the YAML describes, with
|
|
10
|
-
* the same tools, instruction and config. tests/compile.test.ts compiles
|
|
11
|
-
* one spec both ways and requires the same first request.
|
|
6
|
+
* lib/compile.ts turns a YAML agent into an AgentSpec. This file builds
|
|
7
|
+
* the loop's agent from it (lib/runtime/native/request.ts, NativeAgent),
|
|
8
|
+
* with the tools, instruction and config the YAML describes.
|
|
12
9
|
*
|
|
13
|
-
* TOOLS: each resolved tool is handed to the loop as the own Tool
|
|
14
|
-
* InstructionTool
|
|
15
|
-
*
|
|
16
|
-
* runs
|
|
17
|
-
*
|
|
18
|
-
* a
|
|
19
|
-
*
|
|
20
|
-
* Tool the ADK runtime's FunctionTool wraps (lib/a2a/remoteAgent.ts).
|
|
10
|
+
* TOOLS: each resolved tool is handed to the loop as the own Tool,
|
|
11
|
+
* InstructionTool or Toolset it is (lib/tools/tool.ts). A delegated
|
|
12
|
+
* subagent becomes a subagentTool holding its own NativeAgent, which the
|
|
13
|
+
* loop runs as a child loop (lib/runtime/native/delegate.ts, ADR 0074), a
|
|
14
|
+
* nested syndicate as its orchestrator's agent, a nested workflow syndicate
|
|
15
|
+
* as a workflowSubagentTool whose call walks the whole graph (ADR 0098); a
|
|
16
|
+
* remote A2A subagent is its own Tool (lib/a2a/remoteAgent.ts).
|
|
21
17
|
*
|
|
22
|
-
* EVERY AGENT KEY COMPILES
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* question, a caller's agent transform) is refused by the turn runner
|
|
29
|
-
* (lib/runtime/nativeTurn.ts), which owns those choices.
|
|
18
|
+
* EVERY AGENT KEY COMPILES: `context:` is handed to the loop, which
|
|
19
|
+
* compacts (lib/runtime/native/compaction.ts); `mode: task` and
|
|
20
|
+
* `code_execution: gemini` pass through, the request declaring finish_task
|
|
21
|
+
* (lib/runtime/native/taskMode.ts) and asking Gemini for its
|
|
22
|
+
* code-execution tool (lib/runtime/native/request.ts). What the runtime
|
|
23
|
+
* does not run is refused by the turn runner (lib/runtime/nativeTurn.ts).
|
|
30
24
|
*
|
|
31
25
|
* THE MODEL: the loop calls a model through its contract adapter. A
|
|
32
|
-
* resolver
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* ADK classes are told apart by ADK's own Symbol.for marks, so
|
|
39
|
-
* imports nothing from ADK.
|
|
26
|
+
* resolver returns an id, a ModelAdapter or undefined. Anything else is
|
|
27
|
+
* refused with UnsupportedOnRuntimeError by compileNative and
|
|
28
|
+
* nativeAdapterFor before any model call, rather than run the registry's
|
|
29
|
+
* model for that id in its place (ADR 0088, ADR 0107): an ADK model class (a
|
|
30
|
+
* resolver written for 0.x) has no adapter behind it, and a plain
|
|
31
|
+
* `{ model, apiKey }` object would run on the operator's env key, not the
|
|
32
|
+
* caller's. ADK classes are told apart by ADK's own Symbol.for marks, so
|
|
33
|
+
* this file imports nothing from ADK.
|
|
40
34
|
*/
|
|
41
35
|
import { remoteAgentOwnTool } from './a2a/remoteAgent.js';
|
|
42
|
-
import { compileSpec, compileSubagentSpec } from './compile.js';
|
|
43
|
-
import {
|
|
44
|
-
import { subagentTool } from './runtime/native/delegate.js';
|
|
36
|
+
import { compileSpec, compileSubagentSpec, workflowAgentSpecs } from './compile.js';
|
|
37
|
+
import { resolveAdapter } from './models/registry.js';
|
|
38
|
+
import { subagentTool, workflowSubagentTool } from './runtime/native/delegate.js';
|
|
45
39
|
import { unsupportedOnNative } from './runtime/runtimeFlag.js';
|
|
46
40
|
export { UnsupportedOnRuntimeError, unsupportedOnNative } from './runtime/runtimeFlag.js';
|
|
47
41
|
import { instructionToolOf, toolOf, toolsetOf } from './tools/tool.js';
|
|
48
|
-
|
|
42
|
+
import { buildWorkflowGraph } from './workflow/graph.js';
|
|
43
|
+
import { refuseUnrunnableNodes, runNativeWorkflow } from './workflow/turn.js';
|
|
44
|
+
/**
|
|
45
|
+
* A resolved tool as the loop holds it: the own Tool, InstructionTool or
|
|
46
|
+
* Toolset behind it, else the object itself. An ADK tool (anything with
|
|
47
|
+
* runAsync) is refused, naming 1.0.0 and defineTool, as registerTool
|
|
48
|
+
* refuses one.
|
|
49
|
+
*/
|
|
49
50
|
function nativeTool(tool) {
|
|
51
|
+
if (!!tool && typeof tool === 'object' && 'runAsync' in tool) {
|
|
52
|
+
const name = String(tool.name ?? '<unnamed>');
|
|
53
|
+
throw new Error(`compile: '${name}' is an ADK tool, which melchizedek-agents 1.0.0 no longer runs (ADR 0107); define it with defineTool (melchizedek-agents) instead`);
|
|
54
|
+
}
|
|
50
55
|
return toolOf(tool) ?? instructionToolOf(tool) ?? toolsetOf(tool) ?? tool;
|
|
51
56
|
}
|
|
52
|
-
/** ADK's own
|
|
57
|
+
/** ADK's own mark on its model classes, registered with Symbol.for so it holds across copies of ADK. */
|
|
53
58
|
const ADK_BASE_MODEL = Symbol.for('google.adk.baseModel');
|
|
54
|
-
const ADK_GEMINI_MODEL = Symbol.for('google.adk.geminiModel');
|
|
55
59
|
const marked = (value, mark) => !!value && typeof value === 'object' && value[mark] === true;
|
|
56
60
|
/**
|
|
57
|
-
* The class name of an ADK model the
|
|
58
|
-
*
|
|
59
|
-
* included) nor a shim carrying a contract adapter (lib/models/adkShim.ts).
|
|
61
|
+
* The class name of an ADK model the runtime cannot run, else undefined:
|
|
62
|
+
* any ADK BaseLlm (ADR 0107; the ADK runtime that ran one left in 1.0.0).
|
|
60
63
|
*/
|
|
61
64
|
export function unrunnableModelClass(resolved) {
|
|
62
|
-
if (!marked(resolved, ADK_BASE_MODEL)
|
|
63
|
-
return undefined;
|
|
64
|
-
if (isModelAdapter(resolved.adapter))
|
|
65
|
+
if (!marked(resolved, ADK_BASE_MODEL))
|
|
65
66
|
return undefined;
|
|
66
67
|
const name = resolved.constructor?.name;
|
|
67
68
|
return typeof name === 'string' && name ? name : 'BaseLlm';
|
|
68
69
|
}
|
|
69
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Throws UnsupportedOnRuntimeError when `resolved` is not a model id, a
|
|
72
|
+
* ModelAdapter or undefined: an ADK model class native cannot run, or any
|
|
73
|
+
* other value, such as a plain `{ model, apiKey }` object, which would
|
|
74
|
+
* otherwise run on the operator's env key in place of the caller's (see the
|
|
75
|
+
* header).
|
|
76
|
+
*/
|
|
70
77
|
function refuseModelClass(resolved, modelId, where) {
|
|
78
|
+
const forId = modelId ? ` for '${modelId}'` : '';
|
|
71
79
|
const name = unrunnableModelClass(resolved);
|
|
72
|
-
if (
|
|
80
|
+
if (name) {
|
|
81
|
+
throw unsupportedOnNative(`the ADK model class ${name} that resolveModel returned${forId}, which has no contract adapter behind it ` +
|
|
82
|
+
`(ADK model classes left in 1.0.0; return a model id or a ModelAdapter from melchizedek-agents/model)`, where);
|
|
83
|
+
}
|
|
84
|
+
if (resolved === undefined || typeof resolved === 'string' || isModelAdapter(resolved))
|
|
73
85
|
return;
|
|
74
|
-
throw unsupportedOnNative(`the
|
|
75
|
-
`
|
|
86
|
+
throw unsupportedOnNative(`the ${describeResolved(resolved)} that resolveModel returned${forId} (melchizedek-agents 1.0.0 accepts only a model id, a ModelAdapter or undefined; ` +
|
|
87
|
+
`return a model id or a ModelAdapter (e.g. new ClaudeAdapter({ model, apiKey })) from melchizedek-agents/model)`, where);
|
|
88
|
+
}
|
|
89
|
+
/** What a resolver returned, named for a refusal: its type, never its contents (a key may be among them). */
|
|
90
|
+
function describeResolved(value) {
|
|
91
|
+
if (value === null)
|
|
92
|
+
return 'null';
|
|
93
|
+
if (typeof value !== 'object')
|
|
94
|
+
return `${typeof value} value`;
|
|
95
|
+
const ctor = value.constructor?.name;
|
|
96
|
+
return typeof ctor === 'string' && ctor && ctor !== 'Object' ? `${ctor} instance` : 'plain object';
|
|
76
97
|
}
|
|
77
98
|
/**
|
|
78
99
|
* The NativeAgent for `spec`. Throws when no model id is known, and
|
|
79
|
-
* UnsupportedOnRuntimeError when the resolver returned
|
|
80
|
-
*
|
|
100
|
+
* UnsupportedOnRuntimeError when the resolver returned anything but an id,
|
|
101
|
+
* a ModelAdapter or undefined (see the header).
|
|
81
102
|
*/
|
|
82
103
|
export function compileNative(spec) {
|
|
83
104
|
refuseModelClass(spec.resolvedModel, spec.model ?? spec.modelId, spec.name);
|
|
@@ -85,6 +106,8 @@ export function compileNative(spec) {
|
|
|
85
106
|
for (const entry of spec.tools) {
|
|
86
107
|
if (entry.kind === 'agent')
|
|
87
108
|
tools.push(subagentTool(compileNative(entry.agent)));
|
|
109
|
+
else if (entry.kind === 'workflow')
|
|
110
|
+
tools.push(workflowSubagentTool(workflowSubagentOf(compileNativeWorkflow(entry.workflow))));
|
|
88
111
|
else if (entry.kind === 'remote')
|
|
89
112
|
tools.push(remoteAgentOwnTool({ name: entry.name, description: entry.description, url: entry.url }));
|
|
90
113
|
else
|
|
@@ -125,12 +148,11 @@ export function compileNative(spec) {
|
|
|
125
148
|
return agent;
|
|
126
149
|
}
|
|
127
150
|
/**
|
|
128
|
-
* The model id a request is sent under
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* circuit breaker then see that id on both runtimes.
|
|
151
|
+
* The model id a request is sent under: the id of the adapter the resolver
|
|
152
|
+
* returned, else the id the resolver returned, else the spec's. A resolver
|
|
153
|
+
* may answer a YAML id with a model under another id (a gateway stand-in, a
|
|
154
|
+
* caller's alias); the adapter, the span and the circuit breaker then see
|
|
155
|
+
* that id.
|
|
134
156
|
*/
|
|
135
157
|
export function wireModelOf(spec) {
|
|
136
158
|
const resolved = spec.resolvedModel;
|
|
@@ -145,6 +167,51 @@ export function wireModelOf(spec) {
|
|
|
145
167
|
export async function compileNativeGraph(config, opts = {}) {
|
|
146
168
|
return compileNative(await compileSpec(config, opts));
|
|
147
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* A workflow spec for the walk: the graph, every agent compiled from its
|
|
172
|
+
* spec, and the registry's lookup for tool nodes. An unregistered or
|
|
173
|
+
* long-running tool node is refused here, before any model call.
|
|
174
|
+
*/
|
|
175
|
+
export function compileNativeWorkflow(spec) {
|
|
176
|
+
const graph = buildWorkflowGraph(spec.config);
|
|
177
|
+
const agents = new Map();
|
|
178
|
+
for (const { yaml, spec: agentSpec } of spec.agents)
|
|
179
|
+
agents.set(yaml.name, compileNative(agentSpec));
|
|
180
|
+
const workflows = new Map();
|
|
181
|
+
for (const { yaml, workflow } of spec.workflows)
|
|
182
|
+
workflows.set(yaml.name, compileNativeWorkflow(workflow));
|
|
183
|
+
refuseUnrunnableNodes(graph, spec.resolveTool);
|
|
184
|
+
return { name: spec.name, description: spec.description, graph, agents, resolveTool: spec.resolveTool, workflows };
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* A nested workflow as the delegated subagent the native loop calls (ADR
|
|
188
|
+
* 0098): one call walks the whole graph with runNativeWorkflow on the child
|
|
189
|
+
* session lib/runtime/native/delegate.ts opened.
|
|
190
|
+
*/
|
|
191
|
+
export function workflowSubagentOf(workflow) {
|
|
192
|
+
return {
|
|
193
|
+
name: workflow.name,
|
|
194
|
+
...(workflow.description ? { description: workflow.description } : {}),
|
|
195
|
+
walk: (run) => runNativeWorkflow({
|
|
196
|
+
graph: workflow.graph,
|
|
197
|
+
agents: workflow.agents,
|
|
198
|
+
resolveTool: workflow.resolveTool,
|
|
199
|
+
workflows: workflow.workflows,
|
|
200
|
+
sessions: run.sessions,
|
|
201
|
+
appName: run.appName,
|
|
202
|
+
userId: run.userId,
|
|
203
|
+
sessionId: run.sessionId,
|
|
204
|
+
userParts: run.userParts,
|
|
205
|
+
adapterFor: run.adapterFor,
|
|
206
|
+
selfCorrection: run.selfCorrection,
|
|
207
|
+
stream: false,
|
|
208
|
+
...(run.signal ? { signal: run.signal } : {}),
|
|
209
|
+
...(run.memory ? { memory: run.memory } : {}),
|
|
210
|
+
...(run.log ? { log: run.log } : {}),
|
|
211
|
+
...(run.credentials ? { credentials: run.credentials } : {}),
|
|
212
|
+
}),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
148
215
|
/** One subagent entry (a dispatch route) for the native loop: compileSubagentSpec, then compileNative. */
|
|
149
216
|
export async function compileNativeSubagent(subCfg, opts = {}) {
|
|
150
217
|
return compileNative(await compileSubagentSpec(subCfg, opts));
|
|
@@ -153,37 +220,23 @@ function isModelAdapter(value) {
|
|
|
153
220
|
return !!value && typeof value === 'object' && typeof value.generate === 'function' && typeof value.model === 'string';
|
|
154
221
|
}
|
|
155
222
|
/**
|
|
156
|
-
* The contract adapter behind what a resolver returned:
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* BYOK key still pays for the call; else the registry's for the id.
|
|
223
|
+
* The contract adapter behind what a resolver returned: the adapter itself,
|
|
224
|
+
* else the registry's for the id (`model` when the resolver returned
|
|
225
|
+
* undefined or an empty id). Anything else is refused (refuseModelClass).
|
|
160
226
|
*/
|
|
161
227
|
function adapterOf(resolved, model) {
|
|
162
228
|
if (isModelAdapter(resolved))
|
|
163
229
|
return resolved;
|
|
164
230
|
refuseModelClass(resolved, model, 'the native runtime');
|
|
165
|
-
|
|
166
|
-
return resolveAdapter(resolved || model);
|
|
167
|
-
if (!resolved || typeof resolved !== 'object')
|
|
168
|
-
return resolveAdapter(model);
|
|
169
|
-
const held = resolved;
|
|
170
|
-
if (isModelAdapter(held.adapter))
|
|
171
|
-
return held.adapter;
|
|
172
|
-
// On Vertex AI the client authenticates with the platform's credentials, never a key (ADR 0023).
|
|
173
|
-
if (typeof held.apiKey === 'string' && held.apiKey && held.vertexai !== true) {
|
|
174
|
-
return resolveAdapter(model, { apiKey: held.apiKey, keyProvider: providerForModel(model) });
|
|
175
|
-
}
|
|
176
|
-
return resolveAdapter(model);
|
|
231
|
+
return resolveAdapter(resolved || model);
|
|
177
232
|
}
|
|
178
233
|
/**
|
|
179
|
-
* The loop's `adapterFor
|
|
180
|
-
*
|
|
181
|
-
* (an ADK shim carries its contract adapter, so a caller's BYOK key on a
|
|
182
|
-
* shimmed provider reaches the call), else resolveAdapter for the id
|
|
234
|
+
* The loop's `adapterFor`: the adapter CompileOptions.resolveModel returns
|
|
235
|
+
* (so a caller's BYOK key reaches the call), else resolveAdapter for the id
|
|
183
236
|
* (lib/models/registry.ts). The spec's own resolution, and each delegated
|
|
184
237
|
* subagent's, is reused for the id its agent runs under (wireModelOf).
|
|
185
238
|
* Each agent's `fallback_model:` and compaction `summary_model` are
|
|
186
|
-
* resolved here,
|
|
239
|
+
* resolved here, at compile time, so a model
|
|
187
240
|
* class native cannot run is refused before any model call; any other id
|
|
188
241
|
* is resolved when first asked for. Each is kept.
|
|
189
242
|
*/
|
|
@@ -203,9 +256,14 @@ export function nativeAdapterFor(opts = {}, spec) {
|
|
|
203
256
|
refuseModelClass(resolved, id, s.name ?? 'the native runtime');
|
|
204
257
|
known.set(id, resolved);
|
|
205
258
|
}
|
|
206
|
-
for (const entry of s.tools ?? [])
|
|
259
|
+
for (const entry of s.tools ?? []) {
|
|
207
260
|
if (entry.kind === 'agent')
|
|
208
261
|
learn(entry.agent);
|
|
262
|
+
// A nested workflow's agents run under the caller's lookup (ADR 0098).
|
|
263
|
+
else if (entry.kind === 'workflow')
|
|
264
|
+
for (const node of workflowAgentSpecs(entry.workflow))
|
|
265
|
+
learn(node);
|
|
266
|
+
}
|
|
209
267
|
};
|
|
210
268
|
// A workflow's agents share one lookup: every node's spec is learned.
|
|
211
269
|
for (const s of spec === undefined ? [] : Array.isArray(spec) ? spec : [spec])
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -33,20 +33,20 @@ export declare const DEFAULT_GEMINI_MODEL = "gemini-3.5-flash-lite";
|
|
|
33
33
|
* Default Claude model used by the A2A server when a claude-* model is
|
|
34
34
|
* requested but no specific identifier is provided.
|
|
35
35
|
*
|
|
36
|
-
* Requires ANTHROPIC_API_KEY to be set.
|
|
37
|
-
* lib/models/
|
|
36
|
+
* Requires ANTHROPIC_API_KEY to be set. A claude-* id resolves to
|
|
37
|
+
* ClaudeAdapter (lib/models/claudeAdapter.ts) through resolveAdapter.
|
|
38
38
|
*/
|
|
39
39
|
export declare const DEFAULT_CLAUDE_MODEL = "claude-sonnet-4-6";
|
|
40
40
|
/**
|
|
41
41
|
* Default OpenAI model used when a gpt-* model is requested but no specific
|
|
42
42
|
* identifier is provided. Requires OPENAI_API_KEY. gpt-5-mini is the
|
|
43
43
|
* lightweight reasoning tier — enough for subagent work, and it exposes
|
|
44
|
-
* reasoning summaries via the Responses API (lib/models/
|
|
44
|
+
* reasoning summaries via the Responses API (lib/models/gptAdapter.ts).
|
|
45
45
|
*/
|
|
46
46
|
export declare const DEFAULT_GPT_MODEL = "gpt-5-mini";
|
|
47
47
|
/**
|
|
48
48
|
* Default xAI model used when a grok-* model is requested but no specific
|
|
49
|
-
* identifier is provided. Requires XAI_API_KEY (lib/models/
|
|
49
|
+
* identifier is provided. Requires XAI_API_KEY (lib/models/grokAdapter.ts).
|
|
50
50
|
* grok-4.7 is a reasoning model (reasoning cannot be disabled); it returns
|
|
51
51
|
* reasoning summaries, which the adapter surfaces as thinking.
|
|
52
52
|
*/
|
|
@@ -63,7 +63,7 @@ export declare const DEFAULT_GROK_REASONING_EFFORT = "medium";
|
|
|
63
63
|
/**
|
|
64
64
|
* Default Moonshot model used when a kimi-* model is requested but no
|
|
65
65
|
* specific identifier is provided. Requires MOONSHOT_API_KEY
|
|
66
|
-
* (lib/models/
|
|
66
|
+
* (lib/models/kimiAdapter.ts). kimi-k3 is the flagship, priced like a mid-tier
|
|
67
67
|
* closed model ($3 / $15, Claude Sonnet 4.6's price; Sonnet 5.5 is cheaper);
|
|
68
68
|
* kimi-k2.6 is the general tier at a quarter of that (the family table and
|
|
69
69
|
* the cost note are in the adapter's header).
|
|
@@ -85,7 +85,7 @@ export declare const DEFAULT_KIMI_REASONING_EFFORT = "high";
|
|
|
85
85
|
*/
|
|
86
86
|
export declare const DEFAULT_MAX_STEPS = 50;
|
|
87
87
|
/**
|
|
88
|
-
* Default open-weight model, served locally by Ollama (lib/models/
|
|
88
|
+
* Default open-weight model, served locally by Ollama (lib/models/ollamaAdapter.ts).
|
|
89
89
|
* qwen3:8b is the smallest pulled model that supports tool calling — the
|
|
90
90
|
* floor capability for syndicate delegation. Vision work uses ollama/qwen3-vl:8b.
|
|
91
91
|
*/
|
package/dist/lib/config.js
CHANGED
|
@@ -34,20 +34,20 @@ export const DEFAULT_GEMINI_MODEL = 'gemini-3.5-flash-lite';
|
|
|
34
34
|
* Default Claude model used by the A2A server when a claude-* model is
|
|
35
35
|
* requested but no specific identifier is provided.
|
|
36
36
|
*
|
|
37
|
-
* Requires ANTHROPIC_API_KEY to be set.
|
|
38
|
-
* lib/models/
|
|
37
|
+
* Requires ANTHROPIC_API_KEY to be set. A claude-* id resolves to
|
|
38
|
+
* ClaudeAdapter (lib/models/claudeAdapter.ts) through resolveAdapter.
|
|
39
39
|
*/
|
|
40
40
|
export const DEFAULT_CLAUDE_MODEL = 'claude-sonnet-4-6';
|
|
41
41
|
/**
|
|
42
42
|
* Default OpenAI model used when a gpt-* model is requested but no specific
|
|
43
43
|
* identifier is provided. Requires OPENAI_API_KEY. gpt-5-mini is the
|
|
44
44
|
* lightweight reasoning tier — enough for subagent work, and it exposes
|
|
45
|
-
* reasoning summaries via the Responses API (lib/models/
|
|
45
|
+
* reasoning summaries via the Responses API (lib/models/gptAdapter.ts).
|
|
46
46
|
*/
|
|
47
47
|
export const DEFAULT_GPT_MODEL = 'gpt-5-mini';
|
|
48
48
|
/**
|
|
49
49
|
* Default xAI model used when a grok-* model is requested but no specific
|
|
50
|
-
* identifier is provided. Requires XAI_API_KEY (lib/models/
|
|
50
|
+
* identifier is provided. Requires XAI_API_KEY (lib/models/grokAdapter.ts).
|
|
51
51
|
* grok-4.7 is a reasoning model (reasoning cannot be disabled); it returns
|
|
52
52
|
* reasoning summaries, which the adapter surfaces as thinking.
|
|
53
53
|
*/
|
|
@@ -64,7 +64,7 @@ export const DEFAULT_GROK_REASONING_EFFORT = 'medium';
|
|
|
64
64
|
/**
|
|
65
65
|
* Default Moonshot model used when a kimi-* model is requested but no
|
|
66
66
|
* specific identifier is provided. Requires MOONSHOT_API_KEY
|
|
67
|
-
* (lib/models/
|
|
67
|
+
* (lib/models/kimiAdapter.ts). kimi-k3 is the flagship, priced like a mid-tier
|
|
68
68
|
* closed model ($3 / $15, Claude Sonnet 4.6's price; Sonnet 5.5 is cheaper);
|
|
69
69
|
* kimi-k2.6 is the general tier at a quarter of that (the family table and
|
|
70
70
|
* the cost note are in the adapter's header).
|
|
@@ -86,7 +86,7 @@ export const DEFAULT_KIMI_REASONING_EFFORT = 'high';
|
|
|
86
86
|
*/
|
|
87
87
|
export const DEFAULT_MAX_STEPS = 50;
|
|
88
88
|
/**
|
|
89
|
-
* Default open-weight model, served locally by Ollama (lib/models/
|
|
89
|
+
* Default open-weight model, served locally by Ollama (lib/models/ollamaAdapter.ts).
|
|
90
90
|
* qwen3:8b is the smallest pulled model that supports tool calling — the
|
|
91
91
|
* floor capability for syndicate delegation. Vision work uses ollama/qwen3-vl:8b.
|
|
92
92
|
*/
|
package/dist/lib/doctor.d.ts
CHANGED
|
@@ -18,11 +18,14 @@
|
|
|
18
18
|
* The routing and capability judgments are not re-implemented here: they
|
|
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
|
-
* disagree with what a run would do.
|
|
21
|
+
* disagree with what a run would do. The runtime line comes from
|
|
22
|
+
* lib/runtime/runtimeFlag.ts, which a turn reads (ADR 0107): a leftover
|
|
23
|
+
* MELCHIZEDEK_RUNTIME=adk is a problem.
|
|
22
24
|
*/
|
|
23
25
|
import type { Platform } from './models/endpoints.ts';
|
|
24
26
|
import type { CapabilityGap, CapabilityReport } from './models/capabilities.ts';
|
|
25
27
|
import type { ProviderId } from './models/providerMap.ts';
|
|
28
|
+
import type { RuntimeName, RuntimeSource } from './runtime/runtimeFlag.ts';
|
|
26
29
|
/**
|
|
27
30
|
* What a file costs to run: `keyless` (all Ollama), a single provider's id
|
|
28
31
|
* when every agent shares one (`gemini`, `anthropic`, `openai`, `xai` — one
|
|
@@ -81,8 +84,19 @@ export interface Unlock {
|
|
|
81
84
|
/** Syndicates this one variable would move from blocked to ready. */
|
|
82
85
|
syndicates: string[];
|
|
83
86
|
}
|
|
87
|
+
/** The runtime a turn would run on here, and where that came from (ADR 0107). */
|
|
88
|
+
export interface DoctorRuntime {
|
|
89
|
+
/** The runtime in use; undefined when MELCHIZEDEK_RUNTIME holds a value no turn accepts (`problem` says so). */
|
|
90
|
+
runtime?: RuntimeName;
|
|
91
|
+
/** Where it came from: MELCHIZEDEK_RUNTIME, or the default (a turn's own option is the caller's, not the environment's). */
|
|
92
|
+
source?: RuntimeSource;
|
|
93
|
+
/** Why no turn would run as configured, if none would. */
|
|
94
|
+
problem?: string;
|
|
95
|
+
}
|
|
84
96
|
export interface DoctorResult {
|
|
85
97
|
agentsDir: string;
|
|
98
|
+
/** The runtime in use. */
|
|
99
|
+
runtime: DoctorRuntime;
|
|
86
100
|
syndicates: DoctorSyndicate[];
|
|
87
101
|
unlocks: Unlock[];
|
|
88
102
|
gateway: {
|
|
@@ -110,6 +124,13 @@ export interface DoctorEndpoint {
|
|
|
110
124
|
/** Cloud platforms are tested against mocks only (ADR 0023). */
|
|
111
125
|
liveVerified: boolean;
|
|
112
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* The runtime a turn would run on under this environment (lib/runtime/
|
|
129
|
+
* runtimeFlag.ts), and where that came from. MELCHIZEDEK_RUNTIME=adk is a
|
|
130
|
+
* problem: every turn, and the server's startup, would fail
|
|
131
|
+
* (RuntimeRemovedError, ADR 0107).
|
|
132
|
+
*/
|
|
133
|
+
export declare function runtimeReport(env?: NodeJS.ProcessEnv): DoctorRuntime;
|
|
113
134
|
/** One row per provider that is not on its vendor's public API with an env key. */
|
|
114
135
|
export declare function endpointRows(): DoctorEndpoint[];
|
|
115
136
|
export declare const CONSOLE_URLS: Record<ProviderId, string>;
|