melchizedek-agents 0.18.0 → 0.20.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 +12 -0
- package/CHANGELOG.md +1001 -0
- package/DOCUMENTATION.md +252 -65
- package/QUICKSTART.md +9 -6
- package/README.md +42 -4
- package/config/agents/examples/harness.yaml +3 -1
- package/config/agents/examples/model_zoo.yaml +10 -9
- package/config/agents/syndicateSchema.yaml +53 -16
- package/config/agents/templates/account_memory.yaml +2 -6
- package/config/agents/templates/case_desk.yaml +3 -9
- package/config/agents/templates/draft_review.yaml +3 -9
- package/config/agents/templates/intake_extractor.yaml +1 -3
- package/config/agents/templates/research_brief.yaml +3 -9
- package/config/agents/templates/research_desk.yaml +3 -9
- package/config/agents/templates/review_panel.yaml +4 -12
- package/config/agents/templates/support_triage.yaml +4 -12
- package/config/agents/templates/systems_operator.yaml +2 -6
- package/db/hardening.sql +7 -1
- package/db/migrations/0013_tool_credentials.sql +260 -0
- package/dist/lib/a2a/app.d.ts +70 -6
- package/dist/lib/a2a/app.js +107 -2
- package/dist/lib/a2a/executor.d.ts +20 -3
- package/dist/lib/a2a/executor.js +66 -7
- package/dist/lib/a2a/remoteAgent.d.ts +24 -9
- package/dist/lib/a2a/remoteAgent.js +31 -14
- package/dist/lib/adkPeer.d.ts +63 -0
- package/dist/lib/adkPeer.js +240 -0
- package/dist/lib/compile.d.ts +159 -30
- package/dist/lib/compile.js +215 -134
- package/dist/lib/compileAdk.d.ts +32 -0
- package/dist/lib/compileAdk.js +142 -0
- package/dist/lib/compileNative.d.ts +111 -0
- package/dist/lib/compileNative.js +278 -0
- package/dist/lib/config.d.ts +6 -5
- package/dist/lib/config.js +6 -5
- package/dist/lib/doctor.d.ts +28 -1
- package/dist/lib/doctor.js +64 -2
- package/dist/lib/index.d.ts +6 -1
- package/dist/lib/index.js +7 -1
- package/dist/lib/loadSyndicate.d.ts +18 -0
- package/dist/lib/memory/erase.d.ts +5 -3
- package/dist/lib/memory/erase.js +5 -2
- package/dist/lib/memory/namespace.d.ts +8 -1
- package/dist/lib/memory/namespace.js +12 -6
- package/dist/lib/memory/providers.js +2 -1
- package/dist/lib/memory/supabaseMemoryService.d.ts +37 -3
- package/dist/lib/memory/supabaseMemoryService.js +42 -2
- package/dist/lib/model.d.ts +47 -0
- package/dist/lib/model.js +37 -0
- package/dist/lib/models/adapterResolver.d.ts +115 -0
- package/dist/lib/models/adapterResolver.js +137 -0
- package/dist/lib/models/adkGeminiAdapter.d.ts +90 -0
- package/dist/lib/models/adkGeminiAdapter.js +369 -0
- package/dist/lib/models/adkShim.d.ts +111 -0
- package/dist/lib/models/adkShim.js +136 -0
- package/dist/lib/models/capabilities.d.ts +3 -0
- package/dist/lib/models/capabilities.js +33 -23
- package/dist/lib/models/chatCompletionsAdapter.d.ts +279 -0
- package/dist/lib/models/chatCompletionsAdapter.js +854 -0
- package/dist/lib/models/circuitBreaker.d.ts +42 -0
- package/dist/lib/models/circuitBreaker.js +70 -0
- package/dist/lib/models/claudeAdapter.d.ts +103 -0
- package/dist/lib/models/claudeAdapter.js +669 -0
- package/dist/lib/models/claudeLlm.d.ts +39 -62
- package/dist/lib/models/claudeLlm.js +45 -350
- package/dist/lib/models/claudeModels.d.ts +127 -0
- package/dist/lib/models/claudeModels.js +237 -0
- package/dist/lib/models/contract.d.ts +395 -0
- package/dist/lib/models/contract.js +39 -0
- package/dist/lib/models/endpoints.js +2 -1
- package/dist/lib/models/errorResponse.d.ts +50 -0
- package/dist/lib/models/errorResponse.js +48 -0
- package/dist/lib/models/fallback.d.ts +18 -11
- package/dist/lib/models/fallback.js +54 -43
- package/dist/lib/models/fallbackAdapter.d.ts +55 -0
- package/dist/lib/models/fallbackAdapter.js +62 -0
- package/dist/lib/models/gateway.js +2 -1
- package/dist/lib/models/gatewayAdapter.d.ts +51 -0
- package/dist/lib/models/gatewayAdapter.js +81 -0
- package/dist/lib/models/gatewayLlm.d.ts +12 -33
- package/dist/lib/models/gatewayLlm.js +16 -77
- package/dist/lib/models/geminiAdapter.d.ts +125 -0
- package/dist/lib/models/geminiAdapter.js +854 -0
- package/dist/lib/models/geminiState.d.ts +46 -0
- package/dist/lib/models/geminiState.js +51 -0
- package/dist/lib/models/genaiMapping.d.ts +283 -0
- package/dist/lib/models/genaiMapping.js +965 -0
- package/dist/lib/models/gptAdapter.d.ts +240 -0
- package/dist/lib/models/gptAdapter.js +804 -0
- package/dist/lib/models/gptLlm.d.ts +63 -123
- package/dist/lib/models/gptLlm.js +89 -603
- package/dist/lib/models/grokAdapter.d.ts +86 -0
- package/dist/lib/models/grokAdapter.js +142 -0
- package/dist/lib/models/grokLlm.d.ts +22 -45
- package/dist/lib/models/grokLlm.js +24 -69
- package/dist/lib/models/kimiAdapter.d.ts +157 -0
- package/dist/lib/models/kimiAdapter.js +203 -0
- package/dist/lib/models/kimiLlm.d.ts +15 -107
- package/dist/lib/models/kimiLlm.js +19 -155
- package/dist/lib/models/ollamaAdapter.d.ts +125 -0
- package/dist/lib/models/ollamaAdapter.js +155 -0
- package/dist/lib/models/ollamaLlm.d.ts +11 -107
- package/dist/lib/models/ollamaLlm.js +15 -153
- package/dist/lib/models/openAiCompatibleLlm.d.ts +73 -216
- package/dist/lib/models/openAiCompatibleLlm.js +109 -671
- package/dist/lib/models/providerState.d.ts +63 -0
- package/dist/lib/models/providerState.js +61 -0
- package/dist/lib/models/reasoning.d.ts +26 -0
- package/dist/lib/models/reasoning.js +59 -0
- package/dist/lib/models/registry.d.ts +62 -35
- package/dist/lib/models/registry.js +100 -124
- package/dist/lib/models/retry.d.ts +2 -1
- package/dist/lib/models/retry.js +3 -2
- package/dist/lib/models/schemaNormalize.d.ts +98 -0
- package/dist/lib/models/schemaNormalize.js +321 -1
- package/dist/lib/models/tracedGemini.d.ts +41 -0
- package/dist/lib/models/tracedGemini.js +98 -0
- package/dist/lib/models/urls.d.ts +11 -0
- package/dist/lib/models/urls.js +16 -0
- package/dist/lib/net/redirects.d.ts +21 -2
- package/dist/lib/net/redirects.js +11 -34
- package/dist/lib/observability/audit.d.ts +5 -1
- package/dist/lib/observability/lineage.d.ts +14 -0
- package/dist/lib/observability/lineage.js +33 -0
- package/dist/lib/observability/supabaseSpanExporter.d.ts +10 -4
- package/dist/lib/observability/supabaseSpanExporter.js +17 -9
- package/dist/lib/observability/tracer.d.ts +26 -8
- package/dist/lib/observability/tracer.js +43 -18
- package/dist/lib/runtime/adkMemoryBridge.d.ts +46 -0
- package/dist/lib/runtime/adkMemoryBridge.js +68 -0
- package/dist/lib/runtime/adkSessionBridge.d.ts +78 -0
- package/dist/lib/runtime/adkSessionBridge.js +176 -0
- package/dist/lib/runtime/approvals.d.ts +5 -0
- package/dist/lib/runtime/approvals.js +39 -8
- package/dist/lib/runtime/credentials.d.ts +61 -0
- package/dist/lib/runtime/credentials.js +67 -0
- package/dist/lib/runtime/events.d.ts +229 -0
- package/dist/lib/runtime/events.js +274 -0
- package/dist/lib/runtime/logging.d.ts +32 -0
- package/dist/lib/runtime/logging.js +55 -0
- package/dist/lib/runtime/memoryService.d.ts +72 -0
- package/dist/lib/runtime/memoryService.js +25 -0
- package/dist/lib/runtime/native/agentLoop.d.ts +209 -0
- package/dist/lib/runtime/native/agentLoop.js +705 -0
- package/dist/lib/runtime/native/compaction.d.ts +103 -0
- package/dist/lib/runtime/native/compaction.js +191 -0
- package/dist/lib/runtime/native/delegate.d.ts +151 -0
- package/dist/lib/runtime/native/delegate.js +256 -0
- package/dist/lib/runtime/native/history.d.ts +83 -0
- package/dist/lib/runtime/native/history.js +312 -0
- package/dist/lib/runtime/native/interrupts.d.ts +129 -0
- package/dist/lib/runtime/native/interrupts.js +310 -0
- package/dist/lib/runtime/native/request.d.ts +215 -0
- package/dist/lib/runtime/native/request.js +585 -0
- package/dist/lib/runtime/native/selfCorrection.d.ts +164 -0
- package/dist/lib/runtime/native/selfCorrection.js +327 -0
- package/dist/lib/runtime/native/step.d.ts +156 -0
- package/dist/lib/runtime/native/step.js +263 -0
- package/dist/lib/runtime/native/taskMode.d.ts +64 -0
- package/dist/lib/runtime/native/taskMode.js +126 -0
- package/dist/lib/runtime/native/telemetry.d.ts +75 -0
- package/dist/lib/runtime/native/telemetry.js +299 -0
- package/dist/lib/runtime/native/tempState.d.ts +31 -0
- package/dist/lib/runtime/native/tempState.js +56 -0
- package/dist/lib/runtime/nativeTurn.d.ts +86 -0
- package/dist/lib/runtime/nativeTurn.js +107 -0
- package/dist/lib/runtime/questions.d.ts +29 -7
- package/dist/lib/runtime/questions.js +47 -32
- package/dist/lib/runtime/runtimeFlag.d.ts +38 -0
- package/dist/lib/runtime/runtimeFlag.js +58 -0
- package/dist/lib/runtime/sessions.d.ts +166 -0
- package/dist/lib/runtime/sessions.js +201 -0
- package/dist/lib/runtime/syndicateTurn.d.ts +46 -5
- package/dist/lib/runtime/syndicateTurn.js +233 -36
- package/dist/lib/runtime/valueDepth.d.ts +23 -0
- package/dist/lib/runtime/valueDepth.js +41 -0
- package/dist/lib/session/supabaseSessionService.d.ts +65 -18
- package/dist/lib/session/supabaseSessionService.js +148 -105
- package/dist/lib/session/transcript.d.ts +69 -23
- package/dist/lib/session/transcript.js +105 -29
- package/dist/lib/skills.js +33 -7
- package/dist/lib/storage/postgres/credentialStore.d.ts +20 -0
- package/dist/lib/storage/postgres/credentialStore.js +82 -0
- package/dist/lib/storage/postgres/index.d.ts +12 -0
- package/dist/lib/storage/postgres/index.js +6 -1
- package/dist/lib/storage/postgres/sessionService.d.ts +44 -16
- package/dist/lib/storage/postgres/sessionService.js +128 -66
- package/dist/lib/syndicateSchema.d.ts +49 -0
- package/dist/lib/syndicateSchema.js +99 -9
- package/dist/lib/toolRegistry.d.ts +26 -2
- package/dist/lib/toolRegistry.js +73 -17
- package/dist/lib/tools/adkTool.d.ts +81 -0
- package/dist/lib/tools/adkTool.js +268 -0
- package/dist/lib/tools/auth.d.ts +118 -0
- package/dist/lib/tools/auth.js +89 -0
- package/dist/lib/tools/collectionsSearchTool.d.ts +8 -7
- package/dist/lib/tools/collectionsSearchTool.js +12 -27
- package/dist/lib/tools/credentialCipher.d.ts +58 -0
- package/dist/lib/tools/credentialCipher.js +116 -0
- package/dist/lib/tools/credentialStore.d.ts +77 -0
- package/dist/lib/tools/credentialStore.js +246 -0
- package/dist/lib/tools/examples.d.ts +43 -0
- package/dist/lib/tools/examples.js +62 -0
- package/dist/lib/tools/generateImageTool.d.ts +15 -6
- package/dist/lib/tools/generateImageTool.js +19 -29
- package/dist/lib/tools/inspectImageTool.d.ts +9 -6
- package/dist/lib/tools/inspectImageTool.js +13 -17
- package/dist/lib/tools/mcpToolFactory.d.ts +42 -1
- package/dist/lib/tools/mcpToolFactory.js +46 -47
- package/dist/lib/tools/memoryTools.d.ts +61 -0
- package/dist/lib/tools/memoryTools.js +119 -0
- package/dist/lib/tools/nativeTools.d.ts +38 -0
- package/dist/lib/tools/nativeTools.js +43 -0
- package/dist/lib/tools/oauthConsent.d.ts +181 -0
- package/dist/lib/tools/oauthConsent.js +330 -0
- package/dist/lib/tools/openapi/call.d.ts +108 -0
- package/dist/lib/tools/openapi/call.js +295 -0
- package/dist/lib/tools/openapi/parse.d.ts +147 -0
- package/dist/lib/tools/openapi/parse.js +570 -0
- package/dist/lib/tools/openapiTools.d.ts +25 -17
- package/dist/lib/tools/openapiTools.js +124 -121
- package/dist/lib/tools/scienceTools.d.ts +14 -14
- package/dist/lib/tools/skillToolset.d.ts +58 -87
- package/dist/lib/tools/skillToolset.js +61 -142
- package/dist/lib/tools/skills/env.d.ts +58 -0
- package/dist/lib/tools/skills/env.js +165 -0
- package/dist/lib/tools/skills/executor.d.ts +114 -0
- package/dist/lib/tools/skills/executor.js +331 -0
- package/dist/lib/tools/skills/frontmatter.d.ts +79 -0
- package/dist/lib/tools/skills/frontmatter.js +215 -0
- package/dist/lib/tools/skills/loader.d.ts +91 -0
- package/dist/lib/tools/skills/loader.js +257 -0
- package/dist/lib/tools/skills/tools.d.ts +187 -0
- package/dist/lib/tools/skills/tools.js +386 -0
- package/dist/lib/tools/taskTools.d.ts +15 -15
- package/dist/lib/tools/tool.d.ts +354 -0
- package/dist/lib/tools/tool.js +304 -0
- package/dist/lib/tools/toolContract.d.ts +89 -33
- package/dist/lib/tools/toolContract.js +104 -82
- package/dist/lib/tools/urlContextTool.d.ts +4 -1
- package/dist/lib/tools/urlContextTool.js +6 -2
- package/dist/lib/tools/webExtractTool.d.ts +3 -3
- package/dist/lib/tools/webExtractTool.js +2 -1
- package/dist/lib/tools/webSearchTool.d.ts +7 -10
- package/dist/lib/tools/webSearchTool.js +15 -60
- package/dist/lib/tools/wikiTools.d.ts +19 -19
- package/dist/lib/tools/wikiTools.js +13 -9
- package/dist/lib/tools/xApiSearchTool.d.ts +3 -3
- package/dist/lib/tools/xApiSearchTool.js +2 -1
- package/dist/lib/tools/xSearchTool.d.ts +8 -10
- package/dist/lib/tools/xSearchTool.js +12 -63
- package/dist/lib/tools/xaiSearchParams.d.ts +41 -0
- package/dist/lib/tools/xaiSearchParams.js +126 -0
- package/dist/lib/wiki/agentRun.d.ts +12 -0
- package/dist/lib/wiki/agentRun.js +74 -35
- package/dist/lib/wiki/entities.d.ts +12 -0
- package/dist/lib/wiki/entities.js +45 -3
- package/dist/lib/workflow/agentNode.d.ts +153 -0
- package/dist/lib/workflow/agentNode.js +365 -0
- package/dist/lib/workflow/graph.d.ts +178 -0
- package/dist/lib/workflow/graph.js +468 -0
- package/dist/lib/workflow/nodeEvents.d.ts +50 -0
- package/dist/lib/workflow/nodeEvents.js +101 -0
- package/dist/lib/workflow/pause.d.ts +122 -0
- package/dist/lib/workflow/pause.js +180 -0
- package/dist/lib/workflow/resume.d.ts +166 -0
- package/dist/lib/workflow/resume.js +441 -0
- package/dist/lib/workflow/route.d.ts +58 -0
- package/dist/lib/workflow/route.js +69 -0
- package/dist/lib/workflow/scheduler.d.ts +418 -0
- package/dist/lib/workflow/scheduler.js +756 -0
- package/dist/lib/workflow/toolNode.d.ts +127 -0
- package/dist/lib/workflow/toolNode.js +236 -0
- package/dist/lib/workflow/turn.d.ts +118 -0
- package/dist/lib/workflow/turn.js +216 -0
- package/dist/lib/workflow.d.ts +33 -11
- package/dist/lib/workflow.js +49 -27
- package/dist/lib/workflowConfig.d.ts +7 -2
- package/dist/lib/workflowConfig.js +7 -12
- package/dist/scripts/a2a_server.js +4 -3
- package/dist/scripts/assistant_worker.d.ts +2 -1
- package/dist/scripts/assistant_worker.js +9 -4
- package/dist/scripts/doctor.d.ts +3 -1
- package/dist/scripts/doctor.js +4 -2
- package/dist/scripts/syndicate_chat.js +19 -10
- package/package.json +9 -3
- package/skills/briefs/melchizedek-author.md +3 -2
- package/skills/briefs/melchizedek-models.md +13 -9
- package/skills/briefs/melchizedek.md +3 -3
- package/skills/melchizedek/SKILL.md +2 -1
- package/skills/melchizedek-author/SKILL.md +2 -1
- package/skills/melchizedek-author/assets/minimal.yaml +2 -0
- package/skills/melchizedek-models/SKILL.md +23 -6
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lib/runtime/native/compaction.ts — context compaction on the native loop:
|
|
3
|
+
* the YAML's `context:` block, run as ADK runs it (ADR 0033, ADR 0045).
|
|
4
|
+
*
|
|
5
|
+
* WHY this file exists:
|
|
6
|
+
* On the ADK runtime `context:` compiles to ADK's TokenBasedContextCompactor
|
|
7
|
+
* with an LlmSummarizer (lib/compile.ts), which ADK's
|
|
8
|
+
* ContextCompactorRequestProcessor runs before every model step of the
|
|
9
|
+
* agent. A session either runtime wrote must be one the other continues,
|
|
10
|
+
* so this is that compactor and that summarizer, rule for rule
|
|
11
|
+
* (context/token_based_context_compactor.js, context/compaction_utils.js
|
|
12
|
+
* and context/summarizers/llm_summarizer.js in @google/adk 2.2), and the
|
|
13
|
+
* event it stores is the one ADK stores:
|
|
14
|
+
*
|
|
15
|
+
* - WHEN. Before each model step, over the session's active events (the
|
|
16
|
+
* latest compaction and what follows it, in the run's isolation scope).
|
|
17
|
+
* The raw events (compactions aside) must number more than
|
|
18
|
+
* `keep_recent_events`, and the cut must leave something to summarize:
|
|
19
|
+
* the cut starts `keep_recent_events` from the end and moves back while
|
|
20
|
+
* it would separate a call from its answer. Then the prompt size must
|
|
21
|
+
* pass `compact_after_tokens`: the latest active event's
|
|
22
|
+
* usageMetadata.promptTokenCount, or, when no event carries one, the
|
|
23
|
+
* characters of the agent's projected history (text, and each call and
|
|
24
|
+
* answer as JSON) divided by 4, rounded up.
|
|
25
|
+
* - WHAT IS SUMMARIZED. The raw events before the cut, after the active
|
|
26
|
+
* compaction when there is one, so a later summary folds the earlier in.
|
|
27
|
+
* - THE CALL. One user message: ADK's default prompt, a blank line, then
|
|
28
|
+
* per event `[Event i - Author: <author>]`, its text (thoughts aside) and
|
|
29
|
+
* a blank line. No system prompt, no tools, not streamed. It goes to
|
|
30
|
+
* `summary_model` (default the agent's own model), as a leaf adapter
|
|
31
|
+
* with no fallback, through traceLlmGeneration as the shim calls it: the
|
|
32
|
+
* llm.request span, under the agent span and outside any model.call,
|
|
33
|
+
* and the turn's charge (ADR 0053, ADR 0076). The summary is the first
|
|
34
|
+
* response's first part's text and each later response's; a first
|
|
35
|
+
* response with no text throws "LLM failed to return a valid summary.",
|
|
36
|
+
* as ADK does, and the turn fails.
|
|
37
|
+
* - THE EVENT. author `system`, no invocation id, content `{ role: model,
|
|
38
|
+
* parts: [{ text: summary }] }`, `isCompacted: true`, `startTime` and
|
|
39
|
+
* `endTime` (the first and last summarized events' timestamps),
|
|
40
|
+
* `compactedContent`, and the run's isolation scope. The loop appends it
|
|
41
|
+
* before the step, so the step's request already reads it: the history
|
|
42
|
+
* builder (lib/runtime/native/history.ts) puts
|
|
43
|
+
* "[Previous Context Summary]:\n<summary>" in place of the events up to
|
|
44
|
+
* `endTime`. The full history stays stored.
|
|
45
|
+
*
|
|
46
|
+
* NOT PORTED: ADK's before/after context-compaction plugin hooks. No plugin
|
|
47
|
+
* the engine installs implements them.
|
|
48
|
+
*/
|
|
49
|
+
import type { ModelAdapter, ModelRequest } from '../../models/contract.ts';
|
|
50
|
+
import type { TurnEvent } from '../events.ts';
|
|
51
|
+
import type { Session } from '../sessions.ts';
|
|
52
|
+
import type { CompactedEvent } from './history.ts';
|
|
53
|
+
/** An agent's `context:` block, in the YAML's spelling (ADR 0033). */
|
|
54
|
+
export interface ContextConfig {
|
|
55
|
+
/** Compact when the last request's prompt passed this many tokens. */
|
|
56
|
+
compact_after_tokens: number;
|
|
57
|
+
/** Events kept verbatim after the summary. Default 6. */
|
|
58
|
+
keep_recent_events?: number;
|
|
59
|
+
/** The model that writes the summary. Default: the agent's own. */
|
|
60
|
+
summary_model?: string;
|
|
61
|
+
}
|
|
62
|
+
export declare const DEFAULT_KEEP_RECENT_EVENTS = 6;
|
|
63
|
+
/** ADK's LlmSummarizer default prompt, which compile's summarizer uses. */
|
|
64
|
+
export declare const SUMMARY_PROMPT = "The following is a conversation history between a user and an AI agent. Please summarize the conversation, focusing on key information and decisions made, as well as any unresolved questions or tasks. The summary should be concise and capture the essence of the interaction.";
|
|
65
|
+
/** ADK's message when the summarizer's first response has no text. */
|
|
66
|
+
export declare const SUMMARY_FAILED = "LLM failed to return a valid summary.";
|
|
67
|
+
/** Where the agent stands when it compacts. */
|
|
68
|
+
export interface CompactionScope {
|
|
69
|
+
agentName: string;
|
|
70
|
+
session: Session;
|
|
71
|
+
branch?: string;
|
|
72
|
+
isolationScope?: string;
|
|
73
|
+
}
|
|
74
|
+
/** Where the verbatim tail starts: `keep` from the end, moved back so no answer loses its call. */
|
|
75
|
+
export declare function retainStartIndex(raw: readonly TurnEvent[], keep: number): number;
|
|
76
|
+
/**
|
|
77
|
+
* The events a compaction would summarize now (the active compaction first,
|
|
78
|
+
* when there is one), or undefined when the agent should not compact.
|
|
79
|
+
*/
|
|
80
|
+
export declare function eventsToCompact(config: ContextConfig, scope: CompactionScope): TurnEvent[] | undefined;
|
|
81
|
+
/** The one request the summarizer sends, as the shim maps ADK's LlmRequest for it. */
|
|
82
|
+
export declare function summaryRequest(events: readonly TurnEvent[], model: string, signal?: AbortSignal): ModelRequest;
|
|
83
|
+
/**
|
|
84
|
+
* Summarizes `events` with `adapter` under `model` and returns the
|
|
85
|
+
* compacted event (not stored). Charged and traced as one model call.
|
|
86
|
+
* Throws SUMMARY_FAILED when the first response carries no text.
|
|
87
|
+
*/
|
|
88
|
+
export declare function summarize(events: readonly TurnEvent[], adapter: ModelAdapter, model: string, options?: {
|
|
89
|
+
signal?: AbortSignal;
|
|
90
|
+
isolationScope?: string;
|
|
91
|
+
}): Promise<CompactedEvent>;
|
|
92
|
+
/**
|
|
93
|
+
* Before a model step: the compacted event when the agent's `context:` says
|
|
94
|
+
* to compact now, else undefined. The caller stores it before the step.
|
|
95
|
+
*/
|
|
96
|
+
export declare function compactBeforeStep(agent: {
|
|
97
|
+
name: string;
|
|
98
|
+
model: string;
|
|
99
|
+
context?: ContextConfig;
|
|
100
|
+
}, scope: Omit<CompactionScope, 'agentName'> & {
|
|
101
|
+
adapterFor: (model: string) => ModelAdapter;
|
|
102
|
+
signal?: AbortSignal;
|
|
103
|
+
}): Promise<CompactedEvent | undefined>;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lib/runtime/native/compaction.ts — context compaction on the native loop:
|
|
3
|
+
* the YAML's `context:` block, run as ADK runs it (ADR 0033, ADR 0045).
|
|
4
|
+
*
|
|
5
|
+
* WHY this file exists:
|
|
6
|
+
* On the ADK runtime `context:` compiles to ADK's TokenBasedContextCompactor
|
|
7
|
+
* with an LlmSummarizer (lib/compile.ts), which ADK's
|
|
8
|
+
* ContextCompactorRequestProcessor runs before every model step of the
|
|
9
|
+
* agent. A session either runtime wrote must be one the other continues,
|
|
10
|
+
* so this is that compactor and that summarizer, rule for rule
|
|
11
|
+
* (context/token_based_context_compactor.js, context/compaction_utils.js
|
|
12
|
+
* and context/summarizers/llm_summarizer.js in @google/adk 2.2), and the
|
|
13
|
+
* event it stores is the one ADK stores:
|
|
14
|
+
*
|
|
15
|
+
* - WHEN. Before each model step, over the session's active events (the
|
|
16
|
+
* latest compaction and what follows it, in the run's isolation scope).
|
|
17
|
+
* The raw events (compactions aside) must number more than
|
|
18
|
+
* `keep_recent_events`, and the cut must leave something to summarize:
|
|
19
|
+
* the cut starts `keep_recent_events` from the end and moves back while
|
|
20
|
+
* it would separate a call from its answer. Then the prompt size must
|
|
21
|
+
* pass `compact_after_tokens`: the latest active event's
|
|
22
|
+
* usageMetadata.promptTokenCount, or, when no event carries one, the
|
|
23
|
+
* characters of the agent's projected history (text, and each call and
|
|
24
|
+
* answer as JSON) divided by 4, rounded up.
|
|
25
|
+
* - WHAT IS SUMMARIZED. The raw events before the cut, after the active
|
|
26
|
+
* compaction when there is one, so a later summary folds the earlier in.
|
|
27
|
+
* - THE CALL. One user message: ADK's default prompt, a blank line, then
|
|
28
|
+
* per event `[Event i - Author: <author>]`, its text (thoughts aside) and
|
|
29
|
+
* a blank line. No system prompt, no tools, not streamed. It goes to
|
|
30
|
+
* `summary_model` (default the agent's own model), as a leaf adapter
|
|
31
|
+
* with no fallback, through traceLlmGeneration as the shim calls it: the
|
|
32
|
+
* llm.request span, under the agent span and outside any model.call,
|
|
33
|
+
* and the turn's charge (ADR 0053, ADR 0076). The summary is the first
|
|
34
|
+
* response's first part's text and each later response's; a first
|
|
35
|
+
* response with no text throws "LLM failed to return a valid summary.",
|
|
36
|
+
* as ADK does, and the turn fails.
|
|
37
|
+
* - THE EVENT. author `system`, no invocation id, content `{ role: model,
|
|
38
|
+
* parts: [{ text: summary }] }`, `isCompacted: true`, `startTime` and
|
|
39
|
+
* `endTime` (the first and last summarized events' timestamps),
|
|
40
|
+
* `compactedContent`, and the run's isolation scope. The loop appends it
|
|
41
|
+
* before the step, so the step's request already reads it: the history
|
|
42
|
+
* builder (lib/runtime/native/history.ts) puts
|
|
43
|
+
* "[Previous Context Summary]:\n<summary>" in place of the events up to
|
|
44
|
+
* `endTime`. The full history stays stored.
|
|
45
|
+
*
|
|
46
|
+
* NOT PORTED: ADK's before/after context-compaction plugin hooks. No plugin
|
|
47
|
+
* the engine installs implements them.
|
|
48
|
+
*/
|
|
49
|
+
import { llmRequestToModelRequest, modelResponseToLlmResponse } from '../../models/genaiMapping.js';
|
|
50
|
+
import { traceLlmGeneration } from '../../observability/tracer.js';
|
|
51
|
+
import { createTurnEvent, getFunctionCalls, getFunctionResponses } from '../events.js';
|
|
52
|
+
import { activeEvents, contentsOf, isCompacted } from './history.js';
|
|
53
|
+
export const DEFAULT_KEEP_RECENT_EVENTS = 6;
|
|
54
|
+
/** ADK's LlmSummarizer default prompt, which compile's summarizer uses. */
|
|
55
|
+
export const SUMMARY_PROMPT = 'The following is a conversation history between a user and an AI agent. Please summarize the conversation, focusing on key information and decisions made, as well as any unresolved questions or tasks. The summary should be concise and capture the essence of the interaction.';
|
|
56
|
+
/** ADK's message when the summarizer's first response has no text. */
|
|
57
|
+
export const SUMMARY_FAILED = 'LLM failed to return a valid summary.';
|
|
58
|
+
const CHARS_PER_TOKEN = 4;
|
|
59
|
+
// ── When (ADK's shouldCompact) ───────────────────────────────────────────────
|
|
60
|
+
/** Where the verbatim tail starts: `keep` from the end, moved back so no answer loses its call. */
|
|
61
|
+
export function retainStartIndex(raw, keep) {
|
|
62
|
+
let start = Math.max(0, raw.length - keep);
|
|
63
|
+
while (start > 0) {
|
|
64
|
+
if (getFunctionResponses(raw[start]).length > 0 && getFunctionCalls(raw[start - 1]).length > 0)
|
|
65
|
+
start--;
|
|
66
|
+
else
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
return start;
|
|
70
|
+
}
|
|
71
|
+
/** The latest prompt token count an active event carries, else the estimate from the projected history. */
|
|
72
|
+
function promptTokens(active, scope) {
|
|
73
|
+
for (let i = active.length - 1; i >= 0; i--) {
|
|
74
|
+
const count = active[i]?.usageMetadata?.promptTokenCount;
|
|
75
|
+
if (count !== undefined)
|
|
76
|
+
return count;
|
|
77
|
+
}
|
|
78
|
+
// ADK estimates from getContents with no isolation scope: scoped events count for nothing here.
|
|
79
|
+
let chars = 0;
|
|
80
|
+
for (const content of contentsOf(active, scope.agentName, scope.branch, undefined)) {
|
|
81
|
+
for (const part of content.parts ?? []) {
|
|
82
|
+
if (part.text)
|
|
83
|
+
chars += part.text.length;
|
|
84
|
+
if (part.functionCall)
|
|
85
|
+
chars += JSON.stringify(part.functionCall).length;
|
|
86
|
+
if (part.functionResponse)
|
|
87
|
+
chars += JSON.stringify(part.functionResponse).length;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return chars <= 0 ? undefined : Math.ceil(chars / CHARS_PER_TOKEN);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The events a compaction would summarize now (the active compaction first,
|
|
94
|
+
* when there is one), or undefined when the agent should not compact.
|
|
95
|
+
*/
|
|
96
|
+
export function eventsToCompact(config, scope) {
|
|
97
|
+
const keep = config.keep_recent_events ?? DEFAULT_KEEP_RECENT_EVENTS;
|
|
98
|
+
const active = activeEvents(scope.session.events, scope.isolationScope);
|
|
99
|
+
const raw = active.filter((e) => !isCompacted(e));
|
|
100
|
+
if (raw.length <= keep)
|
|
101
|
+
return undefined;
|
|
102
|
+
const start = retainStartIndex(raw, keep);
|
|
103
|
+
if (start === 0)
|
|
104
|
+
return undefined;
|
|
105
|
+
const tokens = promptTokens(active, scope);
|
|
106
|
+
if (tokens === undefined || tokens <= config.compact_after_tokens)
|
|
107
|
+
return undefined;
|
|
108
|
+
const present = active.find(isCompacted);
|
|
109
|
+
const cut = raw.slice(0, start);
|
|
110
|
+
return present ? [present, ...cut] : cut;
|
|
111
|
+
}
|
|
112
|
+
// ── The summary (ADK's LlmSummarizer) ────────────────────────────────────────
|
|
113
|
+
/** An event's text, thoughts aside (ADK's stringifyContent). */
|
|
114
|
+
function textOf(event) {
|
|
115
|
+
const parts = event.content?.parts;
|
|
116
|
+
if (!parts)
|
|
117
|
+
return '';
|
|
118
|
+
return parts
|
|
119
|
+
.filter((p) => !p.thought)
|
|
120
|
+
.map((p) => p.text ?? '')
|
|
121
|
+
.join('');
|
|
122
|
+
}
|
|
123
|
+
/** The one request the summarizer sends, as the shim maps ADK's LlmRequest for it. */
|
|
124
|
+
export function summaryRequest(events, model, signal) {
|
|
125
|
+
let formatted = '';
|
|
126
|
+
events.forEach((event, i) => {
|
|
127
|
+
formatted += `[Event ${i + 1} - Author: ${event.author}]\n`;
|
|
128
|
+
formatted += `${textOf(event)}\n\n`;
|
|
129
|
+
});
|
|
130
|
+
const llmRequest = {
|
|
131
|
+
contents: [{ role: 'user', parts: [{ text: `${SUMMARY_PROMPT}\n\n${formatted}` }] }],
|
|
132
|
+
toolsDict: {},
|
|
133
|
+
liveConnectConfig: {},
|
|
134
|
+
};
|
|
135
|
+
return llmRequestToModelRequest(llmRequest, { model, stream: false, ...(signal ? { signal } : {}) });
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Summarizes `events` with `adapter` under `model` and returns the
|
|
139
|
+
* compacted event (not stored). Charged and traced as one model call.
|
|
140
|
+
* Throws SUMMARY_FAILED when the first response carries no text.
|
|
141
|
+
*/
|
|
142
|
+
export async function summarize(events, adapter, model, options = {}) {
|
|
143
|
+
if (events.length === 0)
|
|
144
|
+
throw new Error('Cannot summarize an empty list of events.');
|
|
145
|
+
const startTime = events[0].timestamp;
|
|
146
|
+
const endTime = events[events.length - 1].timestamp;
|
|
147
|
+
const request = summaryRequest(events, model, options.signal);
|
|
148
|
+
async function* inner() {
|
|
149
|
+
for await (const response of adapter.generate(request))
|
|
150
|
+
yield modelResponseToLlmResponse(response);
|
|
151
|
+
}
|
|
152
|
+
const responses = traceLlmGeneration({ provider: adapter.provider, model, request }, inner());
|
|
153
|
+
// As ADK: the first response must carry text; nothing after a failure is read.
|
|
154
|
+
const first = await responses.next();
|
|
155
|
+
const head = first.done ? undefined : first.value.content?.parts?.[0]?.text;
|
|
156
|
+
if (!head)
|
|
157
|
+
throw new Error(SUMMARY_FAILED);
|
|
158
|
+
let summary = head;
|
|
159
|
+
for await (const chunk of responses) {
|
|
160
|
+
const text = chunk.content?.parts?.[0]?.text;
|
|
161
|
+
if (text)
|
|
162
|
+
summary += text;
|
|
163
|
+
}
|
|
164
|
+
const event = {
|
|
165
|
+
...createTurnEvent({ author: 'system', content: { role: 'model', parts: [{ text: summary }] } }),
|
|
166
|
+
isCompacted: true,
|
|
167
|
+
startTime,
|
|
168
|
+
endTime,
|
|
169
|
+
compactedContent: summary,
|
|
170
|
+
};
|
|
171
|
+
if (options.isolationScope !== undefined)
|
|
172
|
+
event.isolationScope = options.isolationScope;
|
|
173
|
+
return event;
|
|
174
|
+
}
|
|
175
|
+
// ── The loop's hook ──────────────────────────────────────────────────────────
|
|
176
|
+
/**
|
|
177
|
+
* Before a model step: the compacted event when the agent's `context:` says
|
|
178
|
+
* to compact now, else undefined. The caller stores it before the step.
|
|
179
|
+
*/
|
|
180
|
+
export async function compactBeforeStep(agent, scope) {
|
|
181
|
+
if (!agent.context)
|
|
182
|
+
return undefined;
|
|
183
|
+
const events = eventsToCompact(agent.context, { ...scope, agentName: agent.name });
|
|
184
|
+
if (!events)
|
|
185
|
+
return undefined;
|
|
186
|
+
const model = agent.context.summary_model ?? agent.model;
|
|
187
|
+
return summarize(events, scope.adapterFor(model), model, {
|
|
188
|
+
...(scope.signal ? { signal: scope.signal } : {}),
|
|
189
|
+
...(scope.isolationScope !== undefined ? { isolationScope: scope.isolationScope } : {}),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lib/runtime/native/delegate.ts — delegation on the native loop: a
|
|
3
|
+
* subagent runs as a tool, with its own child loop (WS2-6, ADR 0074).
|
|
4
|
+
*
|
|
5
|
+
* WHY this file exists:
|
|
6
|
+
* A DELEGATE syndicate (lib/compile.ts) lists each subagent on its
|
|
7
|
+
* orchestrator as ADK's AgentTool. The native loop (agentLoop.ts) runs
|
|
8
|
+
* the same delegation without ADK, and a session either runtime wrote must
|
|
9
|
+
* be one the other continues, so a delegated call stores what ADK's
|
|
10
|
+
* AgentTool stores, ids and times aside. tests/nativeDelegate.test.ts runs
|
|
11
|
+
* the boundary suite's delegation cases, a nested syndicate and the
|
|
12
|
+
* council example both ways and compares every session.
|
|
13
|
+
*
|
|
14
|
+
* ONE CALL, AS ADK'S AgentTool RUNS IT:
|
|
15
|
+
* 1. The message: `{ role: 'user', parts: [{ text: args.request }] }`.
|
|
16
|
+
* 2. The subagent's session: the one under the subagent's own name as the
|
|
17
|
+
* app name, with the caller's user id and session id. It is created on
|
|
18
|
+
* the first call, with the caller's state as it stands (the session's,
|
|
19
|
+
* then this call's writes; `temp:` keys dropped), and kept: a later
|
|
20
|
+
* call, in this turn or another, continues it. This is not a branch of
|
|
21
|
+
* the caller's session; ADK's AgentTool runs a Runner of its own.
|
|
22
|
+
* 3. A turn already stopped answers an empty text, before or after the
|
|
23
|
+
* message is stored.
|
|
24
|
+
* 4. The message is stored as a user event under a fresh invocation id
|
|
25
|
+
* (`e-<uuid>`), and the subagent runs on runAgentLoop as the root of
|
|
26
|
+
* its run: not streamed, under the turn's controls and signal (its
|
|
27
|
+
* calls count toward max_steps), with the caller's memory.
|
|
28
|
+
* 5. Each event the child stores has its stateDelta, `temp:` keys aside,
|
|
29
|
+
* written into the call's own state delta, so it lands on the caller's
|
|
30
|
+
* response event. Once the turn has stopped, ADK's Runner yields no
|
|
31
|
+
* more events: the answer is read from the last one it yielded.
|
|
32
|
+
* 6. The answer is the last event's text: its non-thought text parts
|
|
33
|
+
* joined by a newline, or '' when it has no parts. With an output
|
|
34
|
+
* schema it is parsed as JSON; text that does not parse fails the call
|
|
35
|
+
* with the parser's message, as on ADK.
|
|
36
|
+
*
|
|
37
|
+
* A PAUSE INSIDE A SUBAGENT (an ask_user call, an approval request) cannot
|
|
38
|
+
* reach the caller, exactly as under ADK (ADR 0028): the child run ends
|
|
39
|
+
* paused, its last event carries no text, the call answers '', and the gated
|
|
40
|
+
* tool never runs. WS6-2a lifts this.
|
|
41
|
+
*
|
|
42
|
+
* Calls to subagents in one step run one after another, in call order, as
|
|
43
|
+
* ADK runs them; running them concurrently is WS6.
|
|
44
|
+
*
|
|
45
|
+
* NESTED SYNDICATES: a `yaml_reference` subagent is the nested syndicate's
|
|
46
|
+
* orchestrator, named as the entry, listing its own subagent tools. It runs
|
|
47
|
+
* here like any subagent, and its own delegations open sessions under their
|
|
48
|
+
* own names, as on ADK.
|
|
49
|
+
*
|
|
50
|
+
* A NESTED WORKFLOW (ADR 0098): a `yaml_reference` to a workflow syndicate
|
|
51
|
+
* is a workflowSubagentTool, holding the whole graph as a WorkflowSubagent.
|
|
52
|
+
* A call runs as steps 1 to 6 say, with the walk in place of the loop: the
|
|
53
|
+
* graph's walk (lib/workflow/turn.ts, runNativeWorkflow, which
|
|
54
|
+
* lib/compileNative.ts hands over) stores the message itself and yields the
|
|
55
|
+
* events ADK's Runner yields for a Workflow root, node input turns aside;
|
|
56
|
+
* the answer is the last of them's text, as ADK's AgentTool reads it from a
|
|
57
|
+
* Workflow (never parsed: a Workflow has no output schema). A node that
|
|
58
|
+
* gave up fails the call with its error. The walk is not imported here, so
|
|
59
|
+
* this module stays below lib/workflow/ in the import graph.
|
|
60
|
+
*
|
|
61
|
+
* The DELEGATE relay fallback (an orchestrator that echoes a tool name or
|
|
62
|
+
* says nothing) stays in lib/runtime/syndicateTurn.ts: it reads the drained
|
|
63
|
+
* run, whichever runtime produced it.
|
|
64
|
+
*
|
|
65
|
+
* ADK stays out of this file: an ADK AgentTool is recognized by ADK's global
|
|
66
|
+
* symbol only to refuse it, with a message naming what to list instead.
|
|
67
|
+
*/
|
|
68
|
+
import type { ModelAdapter } from '../../models/contract.ts';
|
|
69
|
+
import type { Tool, ToolContext } from '../../tools/tool.ts';
|
|
70
|
+
import type { TurnEvent } from '../events.ts';
|
|
71
|
+
import type { SessionService } from '../sessions.ts';
|
|
72
|
+
import type { AgentLoopContext, AgentLoopEnd } from './agentLoop.ts';
|
|
73
|
+
import type { NativeAgent } from './request.ts';
|
|
74
|
+
import { SelfCorrection } from './selfCorrection.ts';
|
|
75
|
+
/** Where a subagent tool keeps the agent it runs. A global symbol, so a second copy of this module still finds it. */
|
|
76
|
+
export declare const SUBAGENT: unique symbol;
|
|
77
|
+
/** Where a workflow subagent tool keeps the graph it runs. */
|
|
78
|
+
export declare const WORKFLOW_SUBAGENT: unique symbol;
|
|
79
|
+
/** A subagent listed on its caller as a tool: the declaration ADK's AgentTool gives it, and the agent the call runs. */
|
|
80
|
+
export interface SubagentTool extends Tool {
|
|
81
|
+
readonly [SUBAGENT]: NativeAgent;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* `agent` as a tool its caller lists, as lib/compile.ts lists a subagent as
|
|
85
|
+
* an AgentTool: named for the agent, described by its description, taking
|
|
86
|
+
* one string `request`. Only the native loop runs it.
|
|
87
|
+
*/
|
|
88
|
+
export declare function subagentTool(agent: NativeAgent): SubagentTool;
|
|
89
|
+
/** One call's walk of a nested workflow, on the child session (WorkflowSubagent.walk). */
|
|
90
|
+
export interface WorkflowSubagentRun {
|
|
91
|
+
sessions: SessionService;
|
|
92
|
+
appName: string;
|
|
93
|
+
userId: string;
|
|
94
|
+
sessionId: string;
|
|
95
|
+
/** The message's parts: the call's request as one text part. */
|
|
96
|
+
userParts: unknown[];
|
|
97
|
+
signal?: AbortSignal;
|
|
98
|
+
adapterFor: (model: string) => ModelAdapter;
|
|
99
|
+
memory?: AgentLoopContext['memory'];
|
|
100
|
+
log?: (message: string) => void;
|
|
101
|
+
selfCorrection: SelfCorrection;
|
|
102
|
+
credentials?: AgentLoopContext['credentials'];
|
|
103
|
+
}
|
|
104
|
+
/** A workflow syndicate delegated to as a subagent (ADR 0098): its name and description, and the walk one call runs. */
|
|
105
|
+
export interface WorkflowSubagent {
|
|
106
|
+
name: string;
|
|
107
|
+
description?: string;
|
|
108
|
+
/** Stores the message on the child session and walks the whole graph, yielding each event ADK's Runner yields. Throws what a node gave up with. */
|
|
109
|
+
walk(run: WorkflowSubagentRun): AsyncGenerator<TurnEvent, unknown>;
|
|
110
|
+
}
|
|
111
|
+
/** A nested workflow listed on its caller as a tool: the declaration ADK's AgentTool gives a Workflow, and the graph the call walks. */
|
|
112
|
+
export interface WorkflowSubagentTool extends Tool {
|
|
113
|
+
readonly [WORKFLOW_SUBAGENT]: WorkflowSubagent;
|
|
114
|
+
}
|
|
115
|
+
/** `workflow` as a tool its caller lists, as lib/compileAdk.ts lists a nested Workflow as an AgentTool: one string `request`. Only the native loop runs it. */
|
|
116
|
+
export declare function workflowSubagentTool(workflow: WorkflowSubagent): WorkflowSubagentTool;
|
|
117
|
+
/** The nested workflow a delegated call walks: the one a workflow subagent tool holds, else undefined. */
|
|
118
|
+
export declare function workflowSubagentOf(tool: unknown): WorkflowSubagent | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* The agent a delegated call runs: the one a subagent tool (or anything
|
|
121
|
+
* carrying SUBAGENT) holds, else undefined. Throws for an ADK AgentTool that
|
|
122
|
+
* carries none: its LlmAgent cannot run on the native loop.
|
|
123
|
+
*/
|
|
124
|
+
export declare function subagentOf(tool: unknown): NativeAgent | undefined;
|
|
125
|
+
/** What a delegated call needs from its caller's step. */
|
|
126
|
+
export interface DelegationScope {
|
|
127
|
+
/** The caller's loop context: its session, store, adapters, memory, signal. */
|
|
128
|
+
ctx: AgentLoopContext;
|
|
129
|
+
/** The caller's session state as the step left it. */
|
|
130
|
+
stateBase: Readonly<Record<string, unknown>>;
|
|
131
|
+
/** The turn's signal, as the step sent it. */
|
|
132
|
+
signal?: AbortSignal;
|
|
133
|
+
/** The loop the child runs on (agentLoop.ts passes its own runAgentLoop). */
|
|
134
|
+
runLoop: (agent: NativeAgent, ctx: AgentLoopContext) => AsyncGenerator<TurnEvent, AgentLoopEnd>;
|
|
135
|
+
/** Calls sharing this key run one after another (agentLoop.ts passes the step's scope). */
|
|
136
|
+
queue: object;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Runs one delegated call: `agent` on its own session with the call's
|
|
140
|
+
* `request` as its message, the child's state writes recorded in `context`.
|
|
141
|
+
* Resolves to the call's result: the subagent's answer, '' for none. Throws what the child run
|
|
142
|
+
* throws, and for an output-schema answer that does not parse.
|
|
143
|
+
*/
|
|
144
|
+
export declare function runSubagent(agent: NativeAgent, args: Record<string, unknown>, context: ToolContext, scope: DelegationScope): Promise<unknown>;
|
|
145
|
+
/**
|
|
146
|
+
* Runs one delegated call to a nested workflow (ADR 0098): the whole graph
|
|
147
|
+
* walked on the child session with the call's `request` as its message,
|
|
148
|
+
* the walk's state writes recorded in `context`. Resolves to the last
|
|
149
|
+
* yielded event's text, '' for none. Throws what the walk throws.
|
|
150
|
+
*/
|
|
151
|
+
export declare function runWorkflowSubagent(workflow: WorkflowSubagent, args: Record<string, unknown>, context: ToolContext, scope: DelegationScope): Promise<unknown>;
|