agent-contracts-runtime 0.36.16 → 0.36.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -65
- package/cli-contract.yaml +3 -3
- package/dist/adapters/claude-agent-sdk.d.ts +2 -0
- package/dist/adapters/claude-agent-sdk.js +21 -7
- package/dist/adapters/claude-agent-sdk.js.map +1 -1
- package/dist/adapters/mock.js +3 -37
- package/dist/adapters/mock.js.map +1 -1
- package/dist/agent-runtime.bundle.mjs +523 -725
- package/dist/agent-runtime.bundle.mjs.map +4 -4
- package/dist/{bound-resolver-I7WLYGC6.js → bound-resolver-RPJYAOCW.js} +4 -4
- package/dist/{chunk-S7MTKPBF.js → chunk-CFOEW6XJ.js} +4 -25
- package/dist/chunk-CFOEW6XJ.js.map +1 -0
- package/dist/chunk-KB4VDAAQ.js +740 -0
- package/dist/chunk-KB4VDAAQ.js.map +1 -0
- package/dist/chunk-L5OAGF7D.js +42 -0
- package/dist/chunk-L5OAGF7D.js.map +1 -0
- package/dist/{chunk-6JVGBBP3.js → chunk-UHHKLLA3.js} +375 -58
- package/dist/chunk-UHHKLLA3.js.map +1 -0
- package/dist/cli/index.js +40 -57
- package/dist/cli/index.js.map +1 -1
- package/dist/generator/index.js +2 -2
- package/dist/{guardrail-hooks-CFd3a8tQ.d.ts → guardrail-hooks-BiLI9u9-.d.ts} +12 -6
- package/dist/index.d.ts +13 -6
- package/dist/index.js +17 -21
- package/dist/{task-runner-CD8nnKpn.d.ts → task-runner-Ba4kLv7O.d.ts} +5 -4
- package/docs/cli-reference.md +1 -1
- package/docs/sdk-options-bridge-spec.md +4 -3
- package/dsl/agents/llm-feature-implementer.yaml +2 -4
- package/dsl/tasks.yaml +1 -5
- package/package.json +5 -20
- package/templates/implement-reference-templates.md +3 -17
- package/templates/implement-reference.md +3 -3
- package/dist/adapters/adk-sdk.d.ts +0 -129
- package/dist/adapters/adk-sdk.js +0 -185
- package/dist/adapters/adk-sdk.js.map +0 -1
- package/dist/chunk-2E2LWE6C.js +0 -171
- package/dist/chunk-2E2LWE6C.js.map +0 -1
- package/dist/chunk-6JVGBBP3.js.map +0 -1
- package/dist/chunk-D2QTXQB2.js +0 -266
- package/dist/chunk-D2QTXQB2.js.map +0 -1
- package/dist/chunk-KKJW4TE5.js +0 -302
- package/dist/chunk-KKJW4TE5.js.map +0 -1
- package/dist/chunk-M57HVYUU.js +0 -325
- package/dist/chunk-M57HVYUU.js.map +0 -1
- package/dist/chunk-S7MTKPBF.js.map +0 -1
- package/dist/dsl-context-LACANPO4.js +0 -13
- package/dist/dsl-context-LACANPO4.js.map +0 -1
- /package/dist/{bound-resolver-I7WLYGC6.js.map → bound-resolver-RPJYAOCW.js.map} +0 -0
package/dist/generator/index.js
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
generate,
|
|
6
6
|
loadConfig,
|
|
7
7
|
loadProjectConfig
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-CFOEW6XJ.js";
|
|
9
9
|
import {
|
|
10
10
|
buildContractContext,
|
|
11
11
|
buildGuardrailContext
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-KB4VDAAQ.js";
|
|
13
13
|
export {
|
|
14
14
|
DEFAULT_CONFIG_PATH,
|
|
15
15
|
ProjectConfigSchema,
|
|
@@ -46,13 +46,18 @@ interface GuardrailHooks {
|
|
|
46
46
|
beforeShellExecution: (input: {
|
|
47
47
|
command?: string;
|
|
48
48
|
}) => HookResponse;
|
|
49
|
+
/**
|
|
50
|
+
* `root` is the directory the rule patterns are written against (the agent's
|
|
51
|
+
* working directory); it defaults to process.cwd().
|
|
52
|
+
*/
|
|
49
53
|
preToolUse: (input: {
|
|
50
54
|
tool_name?: string;
|
|
51
55
|
tool_input?: {
|
|
52
56
|
file_path?: string;
|
|
53
57
|
path?: string;
|
|
58
|
+
content?: string;
|
|
54
59
|
};
|
|
55
|
-
}) => HookResponse;
|
|
60
|
+
}, root?: string) => HookResponse;
|
|
56
61
|
afterFileEdit: (input: {
|
|
57
62
|
file_path?: string;
|
|
58
63
|
content?: string;
|
|
@@ -70,15 +75,16 @@ declare function hasBlockingViolation(results: GuardrailCheckResult[]): boolean;
|
|
|
70
75
|
* plus a generic runChecks() for programmatic use.
|
|
71
76
|
*/
|
|
72
77
|
declare function createGuardrailHooks(checks: GuardrailCheckFunctions): GuardrailHooks;
|
|
73
|
-
/**
|
|
74
|
-
* Create SDK hook functions from embedded guardrail rule data.
|
|
75
|
-
*/
|
|
76
78
|
/**
|
|
77
79
|
* Create SDK hooks scoped to a single agent from a per-agent guardrail map.
|
|
78
|
-
*
|
|
80
|
+
* An agent without rules in the map gets hooks that evaluate plugin guardrails only.
|
|
79
81
|
*/
|
|
80
82
|
declare function createGuardrailHooksForAgent(agentId: string, perAgent: Map<string, GuardrailRuleData>): GuardrailHooks;
|
|
81
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Create SDK hook functions from embedded guardrail rule data. Without rules
|
|
85
|
+
* the hooks still evaluate the plugin-registered guardrails.
|
|
86
|
+
*/
|
|
87
|
+
declare function createGuardrailHooksFromRules(rules: GuardrailRuleData | undefined): GuardrailHooks;
|
|
82
88
|
|
|
83
89
|
export { createGuardrailHooks as f, createGuardrailHooksForAgent as g, createGuardrailHooksFromRules as h, getBlockingViolations as i, getWarnings as j, hasBlockingViolation as k };
|
|
84
90
|
export type { GuardrailHooks as G, HookContext as H, GuardrailRuleData as a, GuardrailCheckFunctions as b, GuardrailCheckResult as c, GuardrailRule as d, HookResponse as e };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as SdkAdapter, T as TaskOutcome, b as TaskContractLike, c as AgentContractLike, d as TaskContext, P as PromptBuilderOptions, e as TaskRunResult } from './task-runner-
|
|
2
|
-
export { A as AdapterSendOptions, a as AgentExecutionRequest, f as AgentProgressEvent, C as CacheConfig, g as CandidateAgent, I as InMemoryStore, M as MemoryRef, h as MemoryStore, R as RetryDecision, i as SplitPrompt, j as TaskRunOptions, k as buildCandidateAgents, l as buildRetryFollowUp, m as buildSplitTaskPrompt, n as buildTaskPrompt, o as extractStructuredResult, r as renderAgentSystemPrompt, p as runTask, z as zodSchemaToPromptDescription, q as zodSchemaToYamlExample } from './task-runner-
|
|
1
|
+
import { S as SdkAdapter, T as TaskOutcome, b as TaskContractLike, c as AgentContractLike, d as TaskContext, P as PromptBuilderOptions, e as TaskRunResult } from './task-runner-Ba4kLv7O.js';
|
|
2
|
+
export { A as AdapterSendOptions, a as AgentExecutionRequest, f as AgentProgressEvent, C as CacheConfig, g as CandidateAgent, I as InMemoryStore, M as MemoryRef, h as MemoryStore, R as RetryDecision, i as SplitPrompt, j as TaskRunOptions, k as buildCandidateAgents, l as buildRetryFollowUp, m as buildSplitTaskPrompt, n as buildTaskPrompt, o as extractStructuredResult, r as renderAgentSystemPrompt, p as runTask, z as zodSchemaToPromptDescription, q as zodSchemaToYamlExample } from './task-runner-Ba4kLv7O.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { a as GuardrailRuleData, G as GuardrailHooks } from './guardrail-hooks-
|
|
5
|
-
export { b as GuardrailCheckFunctions, c as GuardrailCheckResult, d as GuardrailRule, H as HookContext, e as HookResponse, f as createGuardrailHooks, g as createGuardrailHooksForAgent, h as createGuardrailHooksFromRules, i as getBlockingViolations, j as getWarnings, k as hasBlockingViolation } from './guardrail-hooks-
|
|
4
|
+
import { a as GuardrailRuleData, G as GuardrailHooks } from './guardrail-hooks-BiLI9u9-.js';
|
|
5
|
+
export { b as GuardrailCheckFunctions, c as GuardrailCheckResult, d as GuardrailRule, H as HookContext, e as HookResponse, f as createGuardrailHooks, g as createGuardrailHooksForAgent, h as createGuardrailHooksFromRules, i as getBlockingViolations, j as getWarnings, k as hasBlockingViolation } from './guardrail-hooks-BiLI9u9-.js';
|
|
6
6
|
import { G as GuardrailContext } from './context-BEisfYPn.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -118,6 +118,10 @@ interface WorkflowRunOptions {
|
|
|
118
118
|
progressOutput?: {
|
|
119
119
|
write(chunk: string): unknown;
|
|
120
120
|
};
|
|
121
|
+
/** Run every step with read-only tools. */
|
|
122
|
+
readonly?: boolean;
|
|
123
|
+
/** Simulate the workflow with the mock adapter instead of the given adapter. */
|
|
124
|
+
dryRun?: boolean;
|
|
121
125
|
}
|
|
122
126
|
/** Typed handoff envelope for workflow input. */
|
|
123
127
|
interface HandoffInput<TType extends string = string, TPayload = unknown> {
|
|
@@ -319,7 +323,10 @@ interface ResolvedComponent {
|
|
|
319
323
|
}>;
|
|
320
324
|
}
|
|
321
325
|
/**
|
|
322
|
-
* Effective guardrail IDs for an agent: entity-side bindings ∪ scope-side
|
|
326
|
+
* Effective guardrail IDs for an agent: entity-side bindings ∪ scope-side
|
|
327
|
+
* bindings ∪ the guardrails attributed to no agent. A guardrail without
|
|
328
|
+
* `scope.agents` that no `agents[].guardrails` references applies to every
|
|
329
|
+
* agent run in-process, as it does on every other route.
|
|
323
330
|
*/
|
|
324
331
|
declare function getEffectiveGuardrailIds(dsl: Record<string, unknown>, agentId: string): Set<string>;
|
|
325
332
|
declare function guardrailContextToRuleData(ctx: GuardrailContext, effectiveIds?: Set<string>): GuardrailRuleData;
|
|
@@ -539,7 +546,7 @@ interface CreateAdapterOptions {
|
|
|
539
546
|
/**
|
|
540
547
|
* Create an SDK adapter instance by name.
|
|
541
548
|
*
|
|
542
|
-
* @param name - One of: "mock", "claude", "openai"
|
|
549
|
+
* @param name - One of: "mock", "claude", "openai"
|
|
543
550
|
* @param options - Adapter-specific configuration
|
|
544
551
|
*/
|
|
545
552
|
declare function createAdapter(name: string, options?: CreateAdapterOptions): Promise<SdkAdapter>;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
InMemoryStore,
|
|
3
|
+
PluginRegistry,
|
|
3
4
|
WorkflowBuilder,
|
|
4
5
|
buildCandidateAgents,
|
|
5
6
|
buildGateEvaluationPrompt,
|
|
@@ -7,49 +8,44 @@ import {
|
|
|
7
8
|
buildSplitTaskPrompt,
|
|
8
9
|
buildTaskPrompt,
|
|
9
10
|
createAdapter,
|
|
11
|
+
createGuardrailHooks,
|
|
12
|
+
createGuardrailHooksForAgent,
|
|
13
|
+
createGuardrailHooksFromRules,
|
|
10
14
|
createProgressSink,
|
|
11
15
|
createRuntime,
|
|
12
16
|
executeTask,
|
|
13
17
|
executeWorkflow,
|
|
14
18
|
extractStructuredResult,
|
|
19
|
+
getBlockingViolations,
|
|
20
|
+
getWarnings,
|
|
21
|
+
hasBlockingViolation,
|
|
15
22
|
loadPlugins,
|
|
16
23
|
loadPluginsFromDirectory,
|
|
17
24
|
loadPluginsFromPaths,
|
|
18
25
|
parseGateEvaluationResponse,
|
|
26
|
+
pluginRegistry,
|
|
19
27
|
renderAgentSystemPrompt,
|
|
20
28
|
runTask,
|
|
21
29
|
runWorkflow,
|
|
22
30
|
zodSchemaToPromptDescription,
|
|
23
31
|
zodSchemaToYamlExample
|
|
24
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-UHHKLLA3.js";
|
|
33
|
+
import "./chunk-L5OAGF7D.js";
|
|
25
34
|
import {
|
|
26
35
|
BoundResolver,
|
|
36
|
+
DslValidationError,
|
|
37
|
+
buildGuardrailRulesFromDsl,
|
|
27
38
|
buildPerAgentGuardrails,
|
|
39
|
+
buildRegistriesFromDsl,
|
|
28
40
|
getEffectiveGuardrailIds,
|
|
29
41
|
getGuardrailRulesForAgent,
|
|
30
|
-
guardrailContextToRuleData
|
|
31
|
-
|
|
42
|
+
guardrailContextToRuleData,
|
|
43
|
+
jsonSchemaToZod,
|
|
44
|
+
loadDslContext
|
|
45
|
+
} from "./chunk-KB4VDAAQ.js";
|
|
32
46
|
import {
|
|
33
47
|
createModelResolver
|
|
34
48
|
} from "./chunk-AWBHN3LI.js";
|
|
35
|
-
import {
|
|
36
|
-
PluginRegistry,
|
|
37
|
-
createGuardrailHooks,
|
|
38
|
-
createGuardrailHooksForAgent,
|
|
39
|
-
createGuardrailHooksFromRules,
|
|
40
|
-
getBlockingViolations,
|
|
41
|
-
getWarnings,
|
|
42
|
-
hasBlockingViolation,
|
|
43
|
-
pluginRegistry
|
|
44
|
-
} from "./chunk-M57HVYUU.js";
|
|
45
|
-
import "./chunk-KKJW4TE5.js";
|
|
46
|
-
import {
|
|
47
|
-
DslValidationError,
|
|
48
|
-
buildGuardrailRulesFromDsl,
|
|
49
|
-
buildRegistriesFromDsl,
|
|
50
|
-
jsonSchemaToZod,
|
|
51
|
-
loadDslContext
|
|
52
|
-
} from "./chunk-D2QTXQB2.js";
|
|
53
49
|
export {
|
|
54
50
|
BoundResolver,
|
|
55
51
|
DslValidationError,
|
|
@@ -21,9 +21,9 @@ interface MemoryRef {
|
|
|
21
21
|
/**
|
|
22
22
|
* Pluggable store for memory content that backs MemoryRef pointers.
|
|
23
23
|
*
|
|
24
|
-
* Adapters that use server-side state (OpenAI
|
|
24
|
+
* Adapters that use server-side state (OpenAI) may not need
|
|
25
25
|
* the store — the ref ID alone is sufficient for resume. Adapters
|
|
26
|
-
* with local state (Claude transcript
|
|
26
|
+
* with local state (Claude transcript) use the
|
|
27
27
|
* store to persist and retrieve content.
|
|
28
28
|
*/
|
|
29
29
|
interface MemoryStore {
|
|
@@ -50,7 +50,6 @@ declare class InMemoryStore implements MemoryStore {
|
|
|
50
50
|
*
|
|
51
51
|
* - Claude `Options.agents: Record<string, AgentDefinition>`
|
|
52
52
|
* - OpenAI `Agent.handoffs: Agent[]`
|
|
53
|
-
* - ADK `LlmAgent.subAgents: BaseAgent[]`
|
|
54
53
|
*
|
|
55
54
|
* `CandidateAgent` is the common, SDK-independent contract. Each adapter maps it
|
|
56
55
|
* onto its provider's native shape. The selection rule (which agents become
|
|
@@ -215,7 +214,7 @@ interface AdapterSendOptions {
|
|
|
215
214
|
/**
|
|
216
215
|
* Candidate sub-agents the entry agent's LLM may delegate to (model B,
|
|
217
216
|
* LLM-internal routing). Adapters register these via their native subagent
|
|
218
|
-
* mechanism (Claude `agents`, OpenAI `handoffs
|
|
217
|
+
* mechanism (Claude `agents`, OpenAI `handoffs`). When
|
|
219
218
|
* omitted or empty, adapters behave exactly as before (single agent).
|
|
220
219
|
*/
|
|
221
220
|
agents?: CandidateAgent[];
|
|
@@ -346,6 +345,8 @@ interface TaskRunOptions {
|
|
|
346
345
|
progressOutput?: {
|
|
347
346
|
write(chunk: string): unknown;
|
|
348
347
|
};
|
|
348
|
+
/** Run the task with read-only tools even when the agent is read-write. */
|
|
349
|
+
readonly?: boolean;
|
|
349
350
|
}
|
|
350
351
|
interface TaskRunResult {
|
|
351
352
|
outcome: TaskOutcome;
|
package/docs/cli-reference.md
CHANGED
|
@@ -181,13 +181,14 @@ runtime が事前にエージェントを 1 つ選んで `systemPrompt` に入
|
|
|
181
181
|
|
|
182
182
|
### 判断(確定)
|
|
183
183
|
|
|
184
|
-
- **採用 backend は Claude(要 `settingSources:[]`)/ OpenAI
|
|
184
|
+
- **採用 backend は Claude(要 `settingSources:[]`)/ OpenAI の 2 つ**。いずれも
|
|
185
185
|
ネイティブ subagent + in-code 注入でモデル B・隔離要件を満たす。
|
|
186
186
|
- **生 `@google/genai` アダプタは不採用・廃止**。primitive 不足でモデル B を満たせず、runtime 自前合成は
|
|
187
|
-
|
|
187
|
+
保持価値がない。
|
|
188
188
|
- **Gemini CLI** はローカル markdown 定義依存(`~/.gemini/agents`)→ 非隔離。採用外。
|
|
189
189
|
- **Cursor は サポート廃止**。理由は ①`@cursor/sdk` が依存関係 audit を通らない、
|
|
190
190
|
②候補 subagent を in-code 登録する機構が SDK に無くモデル B 不適、の 2 点。
|
|
191
|
+
- **Gemini-ADK(`@google/adk`)は サポート廃止**。`@google/adk` の全版が、推移的な依存の uuid の既知の脆弱性(GHSA-w5hq-g745-h8pq)を利用者の依存の木に導入し、範囲内に該当しない版が無いため。`adk-sdk.ts` と `@google/adk` を撤去。
|
|
191
192
|
`src/adapters/cursor-sdk.ts` と `@cursor/sdk`(optional peer dep)を撤去する。
|
|
192
193
|
- → ブリッジは採用 3 backend に対し、共通の最小契約(候補 AgentDefinition 群)を各機構
|
|
193
194
|
(Claude `agents` / OpenAI `handoffs` / ADK `sub_agents`)へ写像する。
|
|
@@ -206,6 +207,6 @@ runtime が事前にエージェントを 1 つ選んで `systemPrompt` に入
|
|
|
206
207
|
> **確定事項**:
|
|
207
208
|
> - ルーティングは **LLM 内部ルーティング(モデル B)一択**。候補登録(`agents`/`handoffs`/`sub_agents`)は必須。
|
|
208
209
|
> - 外部ルーティング(systemPrompt 丸投げ)は不採用。
|
|
209
|
-
> - **採用 backend = Claude / OpenAI
|
|
210
|
+
> - **採用 backend = Claude / OpenAI**。生 `@google/genai` アダプタと Gemini-ADK アダプタは廃止。
|
|
210
211
|
> - **Cursor サポート廃止**(依存 audit 不通過+in-code subagent 機構なし)。`cursor-sdk.ts` と `@cursor/sdk` を撤去。Gemini CLI は採用外(非隔離)。
|
|
211
212
|
> - **skills は in-code 合成**(subagent or TS ハンドラ tool)。ネイティブ `skills` ディスク discovery は不使用 → `settingSources:[]` 隔離を維持。skill と agent は同じ subagent 登録機構に統合。
|
|
@@ -123,7 +123,6 @@ llm-feature-implementer:
|
|
|
123
123
|
NEVER create custom adapter classes. Import from agent-contracts-runtime:
|
|
124
124
|
ClaudeAgentSdkAdapter from agent-contracts-runtime/adapters/claude-agent-sdk,
|
|
125
125
|
OpenAIAgentsSdkAdapter from agent-contracts-runtime/adapters/openai-agents-sdk,
|
|
126
|
-
GeminiSdkAdapter from agent-contracts-runtime/adapters/gemini-sdk,
|
|
127
126
|
MockAdapter from agent-contracts-runtime/adapters/mock.
|
|
128
127
|
|
|
129
128
|
- >-
|
|
@@ -152,7 +151,7 @@ llm-feature-implementer:
|
|
|
152
151
|
|
|
153
152
|
- >-
|
|
154
153
|
Standard LLM command options (all must be present):
|
|
155
|
-
--adapter <name> (mock|claude|openai
|
|
154
|
+
--adapter <name> (mock|claude|openai, default varies),
|
|
156
155
|
--model <name> (optional override),
|
|
157
156
|
--show-prompt (output prompt without LLM call),
|
|
158
157
|
--fail-on <level> (warning|error|critical, default error),
|
|
@@ -211,8 +210,7 @@ llm-feature-implementer:
|
|
|
211
210
|
Adapter constructors:
|
|
212
211
|
MockAdapter({responses?, defaultLatencyMs?}),
|
|
213
212
|
ClaudeAgentSdkAdapter({cwd?, model?, tools?, permissionMode?, maxTurns?, guardrailHooks?}),
|
|
214
|
-
OpenAIAgentsSdkAdapter({model?, maxTurns?, guardrailHooks?, tools?, agentName?, signal?})
|
|
215
|
-
GeminiSdkAdapter({apiKey?, model?, systemInstruction?, temperature?, maxOutputTokens?, guardrailHooks?}).
|
|
213
|
+
OpenAIAgentsSdkAdapter({model?, maxTurns?, guardrailHooks?, tools?, agentName?, signal?}).
|
|
216
214
|
|
|
217
215
|
- >-
|
|
218
216
|
Generated contract imports: import { agentRegistry, taskRegistry,
|
package/dsl/tasks.yaml
CHANGED
|
@@ -236,10 +236,6 @@ implement-llm-feature:
|
|
|
236
236
|
const m = await import(`${pkg}/adapters/openai-agents-sdk`);
|
|
237
237
|
return new m.OpenAIAgentsSdkAdapter({ model: config.model });
|
|
238
238
|
}
|
|
239
|
-
case "gemini": {
|
|
240
|
-
const m = await import(`${pkg}/adapters/gemini-sdk`);
|
|
241
|
-
return new m.GeminiSdkAdapter({ apiKey: process.env.GEMINI_API_KEY, model: config.model });
|
|
242
|
-
}
|
|
243
239
|
}
|
|
244
240
|
}
|
|
245
241
|
|
|
@@ -346,7 +342,7 @@ implement-llm-feature:
|
|
|
346
342
|
arguments: [...]
|
|
347
343
|
options:
|
|
348
344
|
- name: adapter
|
|
349
|
-
schema: { type: string, enum: [mock, claude, openai
|
|
345
|
+
schema: { type: string, enum: [mock, claude, openai] }
|
|
350
346
|
- name: model
|
|
351
347
|
schema: { type: string }
|
|
352
348
|
- name: show-prompt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-contracts-runtime",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.18",
|
|
4
4
|
"description": "Runtime bridge for executing agent-contracts workflows on Agent SDKs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -21,10 +21,6 @@
|
|
|
21
21
|
"types": "./dist/adapters/openai-agents-sdk.d.ts",
|
|
22
22
|
"import": "./dist/adapters/openai-agents-sdk.js"
|
|
23
23
|
},
|
|
24
|
-
"./adapters/adk-sdk": {
|
|
25
|
-
"types": "./dist/adapters/adk-sdk.d.ts",
|
|
26
|
-
"import": "./dist/adapters/adk-sdk.js"
|
|
27
|
-
},
|
|
28
24
|
"./adapters/mock": {
|
|
29
25
|
"types": "./dist/adapters/mock.d.ts",
|
|
30
26
|
"import": "./dist/adapters/mock.js"
|
|
@@ -57,7 +53,8 @@
|
|
|
57
53
|
"prepublishOnly": "npm run build && npm run bundle:min",
|
|
58
54
|
"test:ci": "vitest run",
|
|
59
55
|
"bundle": "node esbuild.bundle.mjs",
|
|
60
|
-
"bundle:min": "node esbuild.bundle.mjs --minify"
|
|
56
|
+
"bundle:min": "node esbuild.bundle.mjs --minify",
|
|
57
|
+
"audit:signatures": "npx --yes npm@11.19.1 audit signatures"
|
|
61
58
|
},
|
|
62
59
|
"keywords": [
|
|
63
60
|
"agent-contracts",
|
|
@@ -88,9 +85,8 @@
|
|
|
88
85
|
"node": ">=22.0.0"
|
|
89
86
|
},
|
|
90
87
|
"dependencies": {
|
|
91
|
-
"agent-contracts": "^0.
|
|
88
|
+
"agent-contracts": "^0.35.13",
|
|
92
89
|
"commander": "^12.1.0",
|
|
93
|
-
"dotenv": "^17.4.2",
|
|
94
90
|
"handlebars": "^4.7.10",
|
|
95
91
|
"tsx": "^4.22.0",
|
|
96
92
|
"yaml": "^2.8.3",
|
|
@@ -98,7 +94,6 @@
|
|
|
98
94
|
},
|
|
99
95
|
"devDependencies": {
|
|
100
96
|
"@anthropic-ai/claude-agent-sdk": "^0.3.323",
|
|
101
|
-
"@google/adk": "^2.5.0",
|
|
102
97
|
"@openai/agents": "^0.22.0",
|
|
103
98
|
"@types/node": "^26.6.6",
|
|
104
99
|
"cli-contracts": "^0.34.12",
|
|
@@ -109,13 +104,9 @@
|
|
|
109
104
|
},
|
|
110
105
|
"peerDependencies": {
|
|
111
106
|
"@anthropic-ai/claude-agent-sdk": ">=0.2.0",
|
|
112
|
-
"@google/adk": ">=2.2.0",
|
|
113
107
|
"@openai/agents": ">=0.10.0"
|
|
114
108
|
},
|
|
115
109
|
"peerDependenciesMeta": {
|
|
116
|
-
"@google/adk": {
|
|
117
|
-
"optional": true
|
|
118
|
-
},
|
|
119
110
|
"@anthropic-ai/claude-agent-sdk": {
|
|
120
111
|
"optional": true
|
|
121
112
|
},
|
|
@@ -124,12 +115,6 @@
|
|
|
124
115
|
}
|
|
125
116
|
},
|
|
126
117
|
"overrides": {
|
|
127
|
-
"
|
|
128
|
-
"@opentelemetry/core": "^2.8.0",
|
|
129
|
-
"adm-zip": "^0.6.0",
|
|
130
|
-
"esbuild": "$esbuild",
|
|
131
|
-
"gcp-metadata@^8": {
|
|
132
|
-
"gaxios": "^7.3.1"
|
|
133
|
-
}
|
|
118
|
+
"esbuild": "$esbuild"
|
|
134
119
|
}
|
|
135
120
|
}
|
|
@@ -431,24 +431,10 @@ async function createAdapter(runtimePkg: string, name: string, config: AgentConf
|
|
|
431
431
|
const mod = await import(`${runtimePkg}/adapters/mock`);
|
|
432
432
|
return new mod.MockAdapter();
|
|
433
433
|
}
|
|
434
|
-
case "cursor": {
|
|
435
|
-
const mod = await import(`${runtimePkg}/adapters/cursor-sdk`);
|
|
436
|
-
const apiKey = process.env.CURSOR_API_KEY;
|
|
437
|
-
if (!apiKey) throw new Error("CURSOR_API_KEY environment variable is required");
|
|
438
|
-
return mod.CursorSdkAdapter.create({ apiKey, model: config.model });
|
|
439
|
-
}
|
|
440
434
|
case "openai": {
|
|
441
435
|
const mod = await import(`${runtimePkg}/adapters/openai-agents-sdk`);
|
|
442
436
|
return new mod.OpenAIAgentsSdkAdapter({ model: config.model, maxTurns: 1 });
|
|
443
437
|
}
|
|
444
|
-
case "gemini": {
|
|
445
|
-
const mod = await import(`${runtimePkg}/adapters/gemini-sdk`);
|
|
446
|
-
return new mod.GeminiSdkAdapter({
|
|
447
|
-
apiKey: process.env.GEMINI_API_KEY,
|
|
448
|
-
model: config.model,
|
|
449
|
-
temperature: config.temperature,
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
438
|
case "claude": {
|
|
453
439
|
const mod = await import(`${runtimePkg}/adapters/claude-agent-sdk`);
|
|
454
440
|
return new mod.ClaudeAgentSdkAdapter({
|
|
@@ -458,7 +444,7 @@ async function createAdapter(runtimePkg: string, name: string, config: AgentConf
|
|
|
458
444
|
});
|
|
459
445
|
}
|
|
460
446
|
default:
|
|
461
|
-
throw new Error(`Unsupported adapter: "${name}". Available: mock,
|
|
447
|
+
throw new Error(`Unsupported adapter: "${name}". Available: mock, openai, claude.`);
|
|
462
448
|
}
|
|
463
449
|
}
|
|
464
450
|
|
|
@@ -591,7 +577,7 @@ import { Command } from "commander";
|
|
|
591
577
|
const audit = new Command("audit")
|
|
592
578
|
.description("Semantic safety audit via LLM")
|
|
593
579
|
.argument("[target]", "file or directory to audit")
|
|
594
|
-
.option("--adapter <name>", "LLM adapter (
|
|
580
|
+
.option("--adapter <name>", "LLM adapter (openai, claude, mock)", "mock")
|
|
595
581
|
.option("--model <name>", "Model name to pass to the adapter")
|
|
596
582
|
.option("--show-prompt", "Output the constructed prompt without calling the LLM API")
|
|
597
583
|
.option("--fail-on <level>", "Minimum severity for non-zero exit", "error")
|
|
@@ -624,7 +610,7 @@ commands:
|
|
|
624
610
|
valueName: name
|
|
625
611
|
schema:
|
|
626
612
|
type: string
|
|
627
|
-
enum: [mock,
|
|
613
|
+
enum: [mock, claude, openai]
|
|
628
614
|
|
|
629
615
|
- name: model
|
|
630
616
|
description: Model name to pass to the adapter.
|
|
@@ -46,7 +46,7 @@ For each command, decide:
|
|
|
46
46
|
```bash
|
|
47
47
|
npm install --save-dev agent-contracts
|
|
48
48
|
npm install --save-dev agent-contracts-runtime zod
|
|
49
|
-
npm install --save-dev @openai/agents
|
|
49
|
+
npm install --save-dev @openai/agents # adapter SDKs
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
### Phase 3: Create DSL definitions
|
|
@@ -104,7 +104,7 @@ Critical implementation details:
|
|
|
104
104
|
|
|
105
105
|
**orchestrator.ts**:
|
|
106
106
|
- Dynamic-import `agent-contracts-runtime` so the tool works without it installed (graceful degradation)
|
|
107
|
-
- Dynamic-import adapter packages (`/adapters/
|
|
107
|
+
- Dynamic-import adapter packages (`/adapters/openai-agents-sdk`, `/adapters/claude-agent-sdk`, etc.)
|
|
108
108
|
- Import generated DSL registries (including `workflowRegistry`) and pass to `runWorkflow()` — NEVER use `runTask()` (low-level internal API)
|
|
109
109
|
- Support `--show-prompt` by returning the prompt without calling the LLM
|
|
110
110
|
- Use exit codes: 0 = success, 1 = error, 10 = findings, 11 = runtime missing, 12 = adapter error
|
|
@@ -135,7 +135,7 @@ export async function command{Name}(config, target, opts) {
|
|
|
135
135
|
```
|
|
136
136
|
|
|
137
137
|
Register in CLI with the **cli-contracts standard LLM command options**:
|
|
138
|
-
- `--adapter <name>` — LLM adapter (
|
|
138
|
+
- `--adapter <name>` — LLM adapter (openai, claude, mock)
|
|
139
139
|
- `--model <name>` — Model name to pass to the adapter
|
|
140
140
|
- `--show-prompt` — Output the constructed prompt without calling the LLM API
|
|
141
141
|
- `--fail-on <level>` — Minimum severity that causes a non-zero exit (warning, error, critical)
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { SdkAdapter, CacheConfig, AdapterSendOptions, AgentExecutionRequest, MemoryRef } from '../index.js';
|
|
2
|
-
import { GuardrailHooks } from '../index.js';
|
|
3
|
-
import 'zod';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Google ADK Adapter — implements SdkAdapter for @google/adk (ADK-TS / adk-js)
|
|
7
|
-
*
|
|
8
|
-
* Replaces the raw @google/genai adapter. ADK provides a native subagent
|
|
9
|
-
* mechanism (`LlmAgent.subAgents` + description-based agent transfer), which is
|
|
10
|
-
* required for model B (LLM-internal routing): the entry agent's LLM delegates
|
|
11
|
-
* to candidate sub-agents registered in the agent tree.
|
|
12
|
-
*
|
|
13
|
-
* Supports:
|
|
14
|
-
* - send() — build a root LlmAgent (+ candidate subAgents), run once,
|
|
15
|
-
* return the final response text
|
|
16
|
-
* - sendExecution() — rich path using full contract context
|
|
17
|
-
*
|
|
18
|
-
* No followUp(): ADK's InMemoryRunner uses ephemeral sessions, so the runtime's
|
|
19
|
-
* recovery loop falls back to a fresh send() with reconstructed context.
|
|
20
|
-
*
|
|
21
|
-
* API used (verified against the installed package's type definitions under
|
|
22
|
-
* node_modules/@google/adk/dist/types):
|
|
23
|
-
* - class LlmAgent (agents/llm_agent.d.ts): constructor(config) where config
|
|
24
|
-
* extends BaseAgentConfig { name; description?; subAgents?: BaseAgent[] }
|
|
25
|
-
* and adds { model?: string | BaseLlm; instruction?: string; tools? }.
|
|
26
|
-
* - class InMemoryRunner (runner/in_memory_runner.d.ts): constructor({ agent,
|
|
27
|
-
* appName? }); inherits runEphemeral({ userId, newMessage: Content })
|
|
28
|
-
* returning AsyncGenerator<Event> (runner/runner.d.ts).
|
|
29
|
-
* - isFinalResponse(event) / stringifyContent(event) (events/event.d.ts).
|
|
30
|
-
* - class Gemini (models/google_llm.d.ts): constructor({ model, apiKey })
|
|
31
|
-
* — used to inject an explicit API key; otherwise ADK reads
|
|
32
|
-
* GOOGLE_GENAI_API_KEY / GEMINI_API_KEY from the environment.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
type AdkContentPart = {
|
|
36
|
-
text?: string;
|
|
37
|
-
functionCall?: {
|
|
38
|
-
name?: string;
|
|
39
|
-
args?: Record<string, unknown>;
|
|
40
|
-
};
|
|
41
|
-
functionResponse?: {
|
|
42
|
-
name?: string;
|
|
43
|
-
response?: unknown;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
type AdkContent = {
|
|
47
|
-
role?: string;
|
|
48
|
-
parts?: AdkContentPart[];
|
|
49
|
-
};
|
|
50
|
-
type AdkEvent = {
|
|
51
|
-
author?: string;
|
|
52
|
-
content?: AdkContent;
|
|
53
|
-
[key: string]: unknown;
|
|
54
|
-
};
|
|
55
|
-
type LlmAgentConfig = {
|
|
56
|
-
name: string;
|
|
57
|
-
description?: string;
|
|
58
|
-
model?: string | object;
|
|
59
|
-
instruction?: string;
|
|
60
|
-
tools?: unknown[];
|
|
61
|
-
subAgents?: unknown[];
|
|
62
|
-
};
|
|
63
|
-
type LlmAgentInstance = object;
|
|
64
|
-
type LlmAgentConstructor = new (config: LlmAgentConfig) => LlmAgentInstance;
|
|
65
|
-
type RunnerInstance = {
|
|
66
|
-
runEphemeral(params: {
|
|
67
|
-
userId: string;
|
|
68
|
-
newMessage: AdkContent;
|
|
69
|
-
stateDelta?: Record<string, unknown>;
|
|
70
|
-
}): AsyncGenerator<AdkEvent, void, unknown>;
|
|
71
|
-
};
|
|
72
|
-
type InMemoryRunnerConstructor = new (params: {
|
|
73
|
-
agent: LlmAgentInstance;
|
|
74
|
-
appName?: string;
|
|
75
|
-
}) => RunnerInstance;
|
|
76
|
-
type GeminiConstructor = new (params: {
|
|
77
|
-
model?: string;
|
|
78
|
-
apiKey?: string;
|
|
79
|
-
}) => object;
|
|
80
|
-
interface AdkSdk {
|
|
81
|
-
LlmAgent: LlmAgentConstructor;
|
|
82
|
-
InMemoryRunner: InMemoryRunnerConstructor;
|
|
83
|
-
isFinalResponse: (event: AdkEvent) => boolean;
|
|
84
|
-
stringifyContent: (event: AdkEvent) => string;
|
|
85
|
-
Gemini: GeminiConstructor;
|
|
86
|
-
}
|
|
87
|
-
interface AdkSdkAdapterConfig {
|
|
88
|
-
/** API key for the Gemini API. Falls back to GOOGLE_GENAI_API_KEY / GEMINI_API_KEY env. */
|
|
89
|
-
apiKey?: string;
|
|
90
|
-
/** Gemini model identifier (e.g. "gemini-2.5-flash", "gemini-2.5-pro"). */
|
|
91
|
-
model?: string;
|
|
92
|
-
/** Root agent name (must be a JS identifier). Defaults to "root_agent". */
|
|
93
|
-
rootAgentName?: string;
|
|
94
|
-
/** Runtime guardrail hooks. Applied as input-level checks before agent execution. */
|
|
95
|
-
guardrailHooks?: GuardrailHooks;
|
|
96
|
-
/** Prompt caching configuration. Enabled by default. */
|
|
97
|
-
cacheConfig?: CacheConfig;
|
|
98
|
-
}
|
|
99
|
-
declare class AdkSdkAdapter implements SdkAdapter {
|
|
100
|
-
private apiKey;
|
|
101
|
-
private model;
|
|
102
|
-
private rootAgentName;
|
|
103
|
-
private guardrailHooks;
|
|
104
|
-
private cacheConfig;
|
|
105
|
-
private lastMemoryRef;
|
|
106
|
-
private runCounter;
|
|
107
|
-
private sdk;
|
|
108
|
-
constructor(config?: AdkSdkAdapterConfig);
|
|
109
|
-
private resolveSdk;
|
|
110
|
-
/** Resolve the `model` field for LlmAgent — a Gemini instance when an explicit
|
|
111
|
-
* API key is supplied, otherwise the bare model id (ADK reads env keys). */
|
|
112
|
-
private resolveModel;
|
|
113
|
-
/** Build the root LlmAgent with candidate sub-agents registered for transfer. */
|
|
114
|
-
private buildRootAgent;
|
|
115
|
-
private runAgent;
|
|
116
|
-
private nextMemoryRef;
|
|
117
|
-
send(prompt: string, options: AdapterSendOptions): Promise<string>;
|
|
118
|
-
sendExecution(request: AgentExecutionRequest): Promise<string>;
|
|
119
|
-
getLastMemoryRef(): MemoryRef | null;
|
|
120
|
-
isCompatible(compat: string): boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Inject the resolved ADK SDK surface for testing.
|
|
123
|
-
* Bypasses the dynamic import of @google/adk and the API key requirement.
|
|
124
|
-
*/
|
|
125
|
-
static withSdk(sdk: AdkSdk, config?: AdkSdkAdapterConfig): AdkSdkAdapter;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export { AdkSdkAdapter };
|
|
129
|
-
export type { AdkSdkAdapterConfig };
|