dna-sdk 0.7.0 → 0.9.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/dist/emit/bedrock.d.ts +47 -0
- package/dist/emit/bedrock.js +169 -0
- package/dist/emit/index.js +6 -3
- package/dist/emit/vertex.d.ts +19 -0
- package/dist/emit/vertex.js +155 -0
- package/dist/extensions/research.js +8 -0
- package/dist/extensions/sdlc.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DNA → **Amazon Bedrock Agent** emitter (TS twin of python
|
|
3
|
+
* `dna.emit.bedrock`). Materializes an {@link EmitContext} into an AWS
|
|
4
|
+
* **CloudFormation** template that declares an `AWS::Bedrock::Agent` resource —
|
|
5
|
+
* the managed, declarative Bedrock Agents service. The SECOND runtime the SAME
|
|
6
|
+
* DNA source emits to (the first is Microsoft agent-framework): the portability
|
|
7
|
+
* proof — author once, emit per runtime.
|
|
8
|
+
*
|
|
9
|
+
* Why Bedrock **Agents** (not Strands / AgentCore): only Bedrock Agents has a
|
|
10
|
+
* published *declarative* schema (`Instruction`, `FoundationModel`,
|
|
11
|
+
* `ActionGroups` with a `FunctionSchema`) that maps field-for-field from a DNA
|
|
12
|
+
* agent. Emitting a CloudFormation template gives a lintable, deployable artifact
|
|
13
|
+
* that needs no AWS credential to produce or validate structurally.
|
|
14
|
+
*
|
|
15
|
+
* The de-para (DNA field → CloudFormation `AWS::Bedrock::Agent` field):
|
|
16
|
+
* metadata.name -> Resources.<Camel>Agent.Properties.AgentName
|
|
17
|
+
* metadata.description -> Properties.Description (when present)
|
|
18
|
+
* Soul + guardrails + instruction -> Properties.Instruction (flat, BYTE-EQUAL)
|
|
19
|
+
* spec.model (or Genome default_llm)-> Properties.FoundationModel (provider token stripped)
|
|
20
|
+
* spec.tools[] (Tool Kind surfaces) -> Properties.ActionGroups[0].FunctionSchema.Functions[]
|
|
21
|
+
*
|
|
22
|
+
* `toTemplate` is the PURE de-para and is parity-critical: it must build the SAME
|
|
23
|
+
* object the Python `to_template` builds from the same context.
|
|
24
|
+
*/
|
|
25
|
+
import type { EmitContext, EmitResult, EmitterPort } from "./index.js";
|
|
26
|
+
/** `concierge-grounded` → `ConciergeGrounded` (a valid CFN logical id). */
|
|
27
|
+
export declare function camel(name: string): string;
|
|
28
|
+
/** Project a DNA model coordinate → a Bedrock `FoundationModel` id. Bedrock
|
|
29
|
+
* encodes the provider inside the id (`anthropic.claude-v2`), so a DNA
|
|
30
|
+
* `prov:model` / `prov/model` provider token is dropped; a bare coordinate
|
|
31
|
+
* passes through unchanged. */
|
|
32
|
+
export declare function bedrockModelId(model: string | null): string | null;
|
|
33
|
+
/** Project a Tool's input JSON Schema → Bedrock `Function.Parameters`
|
|
34
|
+
* (`{name: {Type, Description, Required}}`). Returns the map + whether any type
|
|
35
|
+
* was coerced (for the loss report). */
|
|
36
|
+
export declare function emitParameters(inputSchema: Record<string, unknown>): {
|
|
37
|
+
params: Record<string, unknown>;
|
|
38
|
+
coerced: boolean;
|
|
39
|
+
};
|
|
40
|
+
export declare class BedrockEmitter implements EmitterPort {
|
|
41
|
+
readonly target = "bedrock";
|
|
42
|
+
readonly fileExtension = "bedrock.json";
|
|
43
|
+
/** The PURE de-para: {@link EmitContext} → the CloudFormation object. Field
|
|
44
|
+
* order is intentional and preserved by JSON.stringify (insertion order). */
|
|
45
|
+
toTemplate(ctx: EmitContext): Record<string, unknown>;
|
|
46
|
+
emit(ctx: EmitContext): EmitResult;
|
|
47
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/** Bedrock `ParameterDetail.Type` allowed values. A JSON-Schema type outside
|
|
2
|
+
* this set (notably `object`) is coerced to `string` (the depth loss). */
|
|
3
|
+
const BEDROCK_PARAM_TYPES = new Set(["string", "number", "integer", "boolean", "array"]);
|
|
4
|
+
/** CloudFormation template format version — the stable, only value. */
|
|
5
|
+
const CFN_VERSION = "2010-09-09";
|
|
6
|
+
/** DNA provider tokens (the `prov:model` / `prov/model` prefixes DNA authors
|
|
7
|
+
* use). Stripped to expose the bare model id. Bedrock-native provider prefixes
|
|
8
|
+
* (anthropic./amazon./…) use a DOT and are NOT here, so a real Bedrock id (incl.
|
|
9
|
+
* a `:0` version suffix) passes through. */
|
|
10
|
+
const DNA_PROVIDER_TOKENS = new Set([
|
|
11
|
+
"azure", "azureopenai", "azure_openai", "openai", "foundry", "azureaifoundry",
|
|
12
|
+
"vertex", "google", "gemini",
|
|
13
|
+
]);
|
|
14
|
+
/** `concierge-grounded` → `ConciergeGrounded` (a valid CFN logical id). */
|
|
15
|
+
export function camel(name) {
|
|
16
|
+
return String(name)
|
|
17
|
+
.replace(/_/g, "-")
|
|
18
|
+
.split("-")
|
|
19
|
+
.filter(Boolean)
|
|
20
|
+
.map((p) => p.charAt(0).toUpperCase() + p.slice(1))
|
|
21
|
+
.join("");
|
|
22
|
+
}
|
|
23
|
+
/** Project a DNA model coordinate → a Bedrock `FoundationModel` id. Bedrock
|
|
24
|
+
* encodes the provider inside the id (`anthropic.claude-v2`), so a DNA
|
|
25
|
+
* `prov:model` / `prov/model` provider token is dropped; a bare coordinate
|
|
26
|
+
* passes through unchanged. */
|
|
27
|
+
export function bedrockModelId(model) {
|
|
28
|
+
if (!model)
|
|
29
|
+
return null;
|
|
30
|
+
const ident = model.trim();
|
|
31
|
+
if (ident.toLowerCase().startsWith("arn:"))
|
|
32
|
+
return ident; // ARN — never split.
|
|
33
|
+
const slash = ident.indexOf("/");
|
|
34
|
+
if (slash >= 0)
|
|
35
|
+
return ident.slice(slash + 1).trim(); // DNA slash coordinate.
|
|
36
|
+
const colon = ident.indexOf(":");
|
|
37
|
+
if (colon >= 0) {
|
|
38
|
+
const token = ident.slice(0, colon).trim().toLowerCase();
|
|
39
|
+
if (DNA_PROVIDER_TOKENS.has(token))
|
|
40
|
+
return ident.slice(colon + 1).trim();
|
|
41
|
+
}
|
|
42
|
+
return ident; // bare / Bedrock-native id (keeps any `:version`).
|
|
43
|
+
}
|
|
44
|
+
/** Project a Tool's input JSON Schema → Bedrock `Function.Parameters`
|
|
45
|
+
* (`{name: {Type, Description, Required}}`). Returns the map + whether any type
|
|
46
|
+
* was coerced (for the loss report). */
|
|
47
|
+
export function emitParameters(inputSchema) {
|
|
48
|
+
const props = inputSchema?.properties;
|
|
49
|
+
if (!props || typeof props !== "object" || Object.keys(props).length === 0) {
|
|
50
|
+
return { params: {}, coerced: false };
|
|
51
|
+
}
|
|
52
|
+
const required = Array.isArray(inputSchema.required) ? inputSchema.required : [];
|
|
53
|
+
const requiredSet = new Set(required);
|
|
54
|
+
const out = {};
|
|
55
|
+
let coerced = false;
|
|
56
|
+
for (const [pname, raw] of Object.entries(props)) {
|
|
57
|
+
const pschema = (raw && typeof raw === "object" ? raw : {});
|
|
58
|
+
const jtype = pschema.type ?? "string";
|
|
59
|
+
let btype;
|
|
60
|
+
if (BEDROCK_PARAM_TYPES.has(jtype)) {
|
|
61
|
+
btype = jtype;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
btype = "string"; // object / unknown → flatten to string (recorded loss)
|
|
65
|
+
coerced = true;
|
|
66
|
+
}
|
|
67
|
+
const detail = { Type: btype };
|
|
68
|
+
if (pschema.description)
|
|
69
|
+
detail.Description = pschema.description;
|
|
70
|
+
detail.Required = requiredSet.has(pname);
|
|
71
|
+
out[pname] = detail;
|
|
72
|
+
}
|
|
73
|
+
return { params: out, coerced };
|
|
74
|
+
}
|
|
75
|
+
/** Project the agent's tools → a single Bedrock action group. The executor is
|
|
76
|
+
* `CustomControl: RETURN_CONTROL` — Bedrock returns the tool call to the CALLER
|
|
77
|
+
* (the faithful mapping for DNA's client-side tools; no Lambda ARN needed). */
|
|
78
|
+
function emitActionGroups(ctx) {
|
|
79
|
+
const functions = [];
|
|
80
|
+
let anyCoerced = false;
|
|
81
|
+
for (const t of ctx.tools) {
|
|
82
|
+
const fn = { Name: t.name };
|
|
83
|
+
if (t.description)
|
|
84
|
+
fn.Description = t.description;
|
|
85
|
+
const { params, coerced } = emitParameters((t.parameters ?? {}));
|
|
86
|
+
anyCoerced = anyCoerced || coerced;
|
|
87
|
+
if (Object.keys(params).length > 0)
|
|
88
|
+
fn.Parameters = params;
|
|
89
|
+
functions.push(fn);
|
|
90
|
+
}
|
|
91
|
+
const group = {
|
|
92
|
+
ActionGroupName: `${ctx.name}-actions`,
|
|
93
|
+
Description: `DNA-emitted tools for agent ${ctx.name}`,
|
|
94
|
+
ActionGroupExecutor: { CustomControl: "RETURN_CONTROL" },
|
|
95
|
+
FunctionSchema: { Functions: functions },
|
|
96
|
+
};
|
|
97
|
+
return { groups: [group], coerced: anyCoerced };
|
|
98
|
+
}
|
|
99
|
+
export class BedrockEmitter {
|
|
100
|
+
target = "bedrock";
|
|
101
|
+
fileExtension = "bedrock.json";
|
|
102
|
+
/** The PURE de-para: {@link EmitContext} → the CloudFormation object. Field
|
|
103
|
+
* order is intentional and preserved by JSON.stringify (insertion order). */
|
|
104
|
+
toTemplate(ctx) {
|
|
105
|
+
const logicalId = `${camel(ctx.name)}Agent`;
|
|
106
|
+
const props = { AgentName: ctx.name };
|
|
107
|
+
if (ctx.description)
|
|
108
|
+
props.Description = ctx.description;
|
|
109
|
+
const modelId = bedrockModelId(ctx.model);
|
|
110
|
+
if (modelId)
|
|
111
|
+
props.FoundationModel = modelId;
|
|
112
|
+
props.Instruction = ctx.instructions; // verbatim — the byte-equal gate
|
|
113
|
+
if (ctx.tools.length > 0)
|
|
114
|
+
props.ActionGroups = emitActionGroups(ctx).groups;
|
|
115
|
+
props.AutoPrepare = true;
|
|
116
|
+
return {
|
|
117
|
+
AWSTemplateFormatVersion: CFN_VERSION,
|
|
118
|
+
Description: `DNA-emitted Amazon Bedrock Agent: ${ctx.name}`,
|
|
119
|
+
Resources: {
|
|
120
|
+
[logicalId]: { Type: "AWS::Bedrock::Agent", Properties: props },
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
emit(ctx) {
|
|
125
|
+
const template = this.toTemplate(ctx);
|
|
126
|
+
const artifact = JSON.stringify(template, null, 2) + "\n";
|
|
127
|
+
const losses = [
|
|
128
|
+
"composition structure — Soul reuse + wired Guardrails flatten to one " +
|
|
129
|
+
"`Instruction` string (Bedrock `GuardrailConfiguration` is an " +
|
|
130
|
+
"ID-referenced Bedrock Guardrail, not DNA's composed guardrails)",
|
|
131
|
+
"tenant overlay — a per-tenant persona without a fork has no Bedrock Agent field",
|
|
132
|
+
"eval-as-contract — prompt invariants (EvalCases) have no Bedrock slot",
|
|
133
|
+
];
|
|
134
|
+
if (ctx.tools.length > 0) {
|
|
135
|
+
losses.push("tool parameter depth — Bedrock `ParameterDetail` is a flat " +
|
|
136
|
+
"{Type, Description, Required} map (Type ∈ string|number|integer|" +
|
|
137
|
+
"boolean|array); JSON-Schema `default`, `enum`, nested object " +
|
|
138
|
+
"`properties`, and array `items` typing are dropped");
|
|
139
|
+
}
|
|
140
|
+
if (ctx.outputSchema) {
|
|
141
|
+
losses.push("output_schema — Bedrock Agent has no structured-response / " +
|
|
142
|
+
"output-schema field; the agent's typed output contract is dropped");
|
|
143
|
+
}
|
|
144
|
+
if (ctx.model === null) {
|
|
145
|
+
losses.push("model unbound in DNA and none supplied — emitted template has no " +
|
|
146
|
+
"`FoundationModel`; pass provider/model or set spec.model / Genome default_llm");
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
losses.push("model coordinate — a DNA `azure/openai` coordinate is not a Bedrock " +
|
|
150
|
+
"foundation-model id; `FoundationModel` needs a Bedrock model id or " +
|
|
151
|
+
"inference-profile ARN, plus an `AgentResourceRoleArn` at deploy");
|
|
152
|
+
}
|
|
153
|
+
const mapping = {
|
|
154
|
+
"metadata.name": "Resources.<id>Agent.Properties.AgentName",
|
|
155
|
+
"metadata.description": "Properties.Description",
|
|
156
|
+
"buildPrompt (Soul+guardrails+instruction)": "Properties.Instruction (byte-equal)",
|
|
157
|
+
"spec.model / Genome.default_llm": "Properties.FoundationModel",
|
|
158
|
+
"spec.tools[] (Tool Kind)": "Properties.ActionGroups[].FunctionSchema.Functions[]",
|
|
159
|
+
"Tool.input_schema.properties": "Function.Parameters{Type,Description,Required}",
|
|
160
|
+
};
|
|
161
|
+
return {
|
|
162
|
+
artifact,
|
|
163
|
+
target: this.target,
|
|
164
|
+
filename: `${ctx.name}.${this.fileExtension}`,
|
|
165
|
+
losses,
|
|
166
|
+
mapping,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
package/dist/emit/index.js
CHANGED
|
@@ -20,9 +20,12 @@ async function ensureBuiltins() {
|
|
|
20
20
|
return;
|
|
21
21
|
builtinsWired = true;
|
|
22
22
|
const { AgentFrameworkEmitter } = await import("./agentFramework.js");
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
const { BedrockEmitter } = await import("./bedrock.js");
|
|
24
|
+
const { VertexEmitter } = await import("./vertex.js");
|
|
25
|
+
for (const e of [new AgentFrameworkEmitter(), new BedrockEmitter(), new VertexEmitter()]) {
|
|
26
|
+
if (!EMITTER_REGISTRY.has(e.target))
|
|
27
|
+
EMITTER_REGISTRY.set(e.target, e);
|
|
28
|
+
}
|
|
26
29
|
}
|
|
27
30
|
/** Register an emitter under its `target` (last registration wins). */
|
|
28
31
|
export function registerEmitter(emitter) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { EmitContext, EmitResult, EmitterPort } from "./index.js";
|
|
2
|
+
/** `concierge-grounded` → `concierge_grounded` (a valid ADK agent name — ADK
|
|
3
|
+
* requires a Python identifier). Mirrors Bedrock's `camel` logical-id transform. */
|
|
4
|
+
export declare function snake(name: string): string;
|
|
5
|
+
/** Project a DNA model coordinate → an ADK `model` id. A known DNA provider token
|
|
6
|
+
* (`vertex/gemini-2.0-flash` → `gemini-2.0-flash`, `openai:gpt-4o` → `gpt-4o`) is
|
|
7
|
+
* stripped; a bare id passes through. */
|
|
8
|
+
export declare function vertexModelId(model: string | null): string | null;
|
|
9
|
+
/** Whether an emitted `model` id is a native Gemini id (else needs `model_code`). */
|
|
10
|
+
export declare function isGemini(modelId: string | null): boolean;
|
|
11
|
+
export declare class VertexEmitter implements EmitterPort {
|
|
12
|
+
readonly target = "vertex";
|
|
13
|
+
readonly fileExtension = "adk.yaml";
|
|
14
|
+
/** The PURE de-para: {@link EmitContext} → the ADK Agent Config object. Field
|
|
15
|
+
* order is intentional; the schema-header comment is prepended at serialization
|
|
16
|
+
* time, not part of this object. */
|
|
17
|
+
toAgentConfig(ctx: EmitContext): Record<string, unknown>;
|
|
18
|
+
emit(ctx: EmitContext): EmitResult;
|
|
19
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DNA → **Google ADK Agent Config** emitter (TS twin of python
|
|
3
|
+
* `dna.emit.vertex`). Materializes an {@link EmitContext} into a **Google Agent
|
|
4
|
+
* Development Kit (ADK) Agent Config** YAML — the declarative, code-free way to
|
|
5
|
+
* define an ADK `LlmAgent` (loaded with `config_agent_utils.from_config(...)`).
|
|
6
|
+
* The THIRD runtime the SAME DNA source emits to (after Microsoft agent-framework
|
|
7
|
+
* and Amazon Bedrock): the portability proof — author once, emit per runtime.
|
|
8
|
+
*
|
|
9
|
+
* Why the ADK **Agent Config** (not the code-first `LlmAgent` object or Vertex AI
|
|
10
|
+
* Agent Engine): only Agent Config has a published, field-for-field *declarative*
|
|
11
|
+
* schema (`agent_class`, `name`, `model`, `instruction`, `tools`, …), so it is the
|
|
12
|
+
* only honest de-para target. Emitting the YAML gives a lintable artifact that
|
|
13
|
+
* needs no GCP credential to produce or validate structurally (the
|
|
14
|
+
* `# yaml-language-server` header wires the real schema into any editor).
|
|
15
|
+
*
|
|
16
|
+
* The de-para (DNA field → ADK `LlmAgentConfig` field):
|
|
17
|
+
* (fixed) -> agent_class: LlmAgent
|
|
18
|
+
* metadata.name -> name (snake_cased — valid identifier)
|
|
19
|
+
* metadata.description -> description (when present)
|
|
20
|
+
* Soul + guardrails + instruction -> instruction (flat, BYTE-EQUAL)
|
|
21
|
+
* spec.model (or Genome default_llm)-> model (Gemini id; provider stripped)
|
|
22
|
+
* spec.tools[] (Tool Kind surfaces) -> tools[].name (a CODE reference — see loss)
|
|
23
|
+
*
|
|
24
|
+
* `toAgentConfig` is the PURE de-para and is parity-critical: it must build the
|
|
25
|
+
* SAME object the Python `to_agent_config` builds from the same context.
|
|
26
|
+
*/
|
|
27
|
+
import yaml from "js-yaml";
|
|
28
|
+
/** The published ADK Agent Config JSON Schema — emitted as a leading
|
|
29
|
+
* `# yaml-language-server` header so any editor / validator binds the artifact to
|
|
30
|
+
* the REAL schema (the credential-free structural-validation hook). */
|
|
31
|
+
const ADK_SCHEMA_URL = "https://raw.githubusercontent.com/google/adk-python/refs/heads/main/" +
|
|
32
|
+
"src/google/adk/agents/config_schemas/AgentConfig.json";
|
|
33
|
+
/** The ADK `agent_class` this emitter targets (the declarative LLM agent). */
|
|
34
|
+
const AGENT_CLASS = "LlmAgent";
|
|
35
|
+
/** DNA provider tokens (the `prov:model` / `prov/model` prefixes). Stripped to
|
|
36
|
+
* expose the bare model id; a bare Gemini id passes through unchanged. */
|
|
37
|
+
const DNA_PROVIDER_TOKENS = new Set([
|
|
38
|
+
"azure", "azureopenai", "azure_openai", "openai", "foundry", "azureaifoundry",
|
|
39
|
+
"vertex", "google", "gemini", "anthropic",
|
|
40
|
+
]);
|
|
41
|
+
/** `concierge-grounded` → `concierge_grounded` (a valid ADK agent name — ADK
|
|
42
|
+
* requires a Python identifier). Mirrors Bedrock's `camel` logical-id transform. */
|
|
43
|
+
export function snake(name) {
|
|
44
|
+
let ident = String(name)
|
|
45
|
+
.trim()
|
|
46
|
+
.split("")
|
|
47
|
+
.map((ch) => (/[a-zA-Z0-9_]/.test(ch) ? ch : "_"))
|
|
48
|
+
.join("")
|
|
49
|
+
.replace(/^_+|_+$/g, "")
|
|
50
|
+
.toLowerCase();
|
|
51
|
+
if (!ident)
|
|
52
|
+
ident = "agent";
|
|
53
|
+
if (/^[0-9]/.test(ident))
|
|
54
|
+
ident = `_${ident}`;
|
|
55
|
+
return ident;
|
|
56
|
+
}
|
|
57
|
+
/** Project a DNA model coordinate → an ADK `model` id. A known DNA provider token
|
|
58
|
+
* (`vertex/gemini-2.0-flash` → `gemini-2.0-flash`, `openai:gpt-4o` → `gpt-4o`) is
|
|
59
|
+
* stripped; a bare id passes through. */
|
|
60
|
+
export function vertexModelId(model) {
|
|
61
|
+
if (!model)
|
|
62
|
+
return null;
|
|
63
|
+
const ident = model.trim();
|
|
64
|
+
const slash = ident.indexOf("/");
|
|
65
|
+
if (slash >= 0) {
|
|
66
|
+
const token = ident.slice(0, slash).trim().toLowerCase();
|
|
67
|
+
if (DNA_PROVIDER_TOKENS.has(token))
|
|
68
|
+
return ident.slice(slash + 1).trim();
|
|
69
|
+
return ident;
|
|
70
|
+
}
|
|
71
|
+
const colon = ident.indexOf(":");
|
|
72
|
+
if (colon >= 0) {
|
|
73
|
+
const token = ident.slice(0, colon).trim().toLowerCase();
|
|
74
|
+
if (DNA_PROVIDER_TOKENS.has(token))
|
|
75
|
+
return ident.slice(colon + 1).trim();
|
|
76
|
+
}
|
|
77
|
+
return ident;
|
|
78
|
+
}
|
|
79
|
+
/** Whether an emitted `model` id is a native Gemini id (else needs `model_code`). */
|
|
80
|
+
export function isGemini(modelId) {
|
|
81
|
+
return !!modelId && modelId.trim().toLowerCase().startsWith("gemini");
|
|
82
|
+
}
|
|
83
|
+
/** Project neutral tool surfaces → ADK `tools` code references (`- name: <fqn>`).
|
|
84
|
+
* ADK has no inline function-schema slot (unlike agent-framework / Bedrock): it
|
|
85
|
+
* derives a tool's description + parameters from the referenced Python callable at
|
|
86
|
+
* load, so the faithful de-para carries the tool NAME as a placeholder reference. */
|
|
87
|
+
function emitTools(tools) {
|
|
88
|
+
return tools.map((t) => ({ name: t.name }));
|
|
89
|
+
}
|
|
90
|
+
export class VertexEmitter {
|
|
91
|
+
target = "vertex";
|
|
92
|
+
fileExtension = "adk.yaml";
|
|
93
|
+
/** The PURE de-para: {@link EmitContext} → the ADK Agent Config object. Field
|
|
94
|
+
* order is intentional; the schema-header comment is prepended at serialization
|
|
95
|
+
* time, not part of this object. */
|
|
96
|
+
toAgentConfig(ctx) {
|
|
97
|
+
const doc = { agent_class: AGENT_CLASS, name: snake(ctx.name) };
|
|
98
|
+
if (ctx.description)
|
|
99
|
+
doc.description = ctx.description;
|
|
100
|
+
const modelId = vertexModelId(ctx.model);
|
|
101
|
+
if (modelId)
|
|
102
|
+
doc.model = modelId;
|
|
103
|
+
doc.instruction = ctx.instructions; // verbatim — the byte-equal gate
|
|
104
|
+
if (ctx.tools.length > 0)
|
|
105
|
+
doc.tools = emitTools(ctx.tools);
|
|
106
|
+
return doc;
|
|
107
|
+
}
|
|
108
|
+
emit(ctx) {
|
|
109
|
+
const config = this.toAgentConfig(ctx);
|
|
110
|
+
const body = yaml.dump(config, { sortKeys: false, lineWidth: -1 });
|
|
111
|
+
const artifact = `# yaml-language-server: $schema=${ADK_SCHEMA_URL}\n${body}`;
|
|
112
|
+
const losses = [
|
|
113
|
+
"composition structure — Soul reuse + wired Guardrails flatten to one " +
|
|
114
|
+
"`instruction` string (Agent Config has no `soul:`/`guardrails:` slot)",
|
|
115
|
+
"tenant overlay — a per-tenant persona without a fork has no Agent Config field",
|
|
116
|
+
"eval-as-contract — prompt invariants (EvalCases) have no Agent Config slot",
|
|
117
|
+
];
|
|
118
|
+
if (ctx.tools.length > 0) {
|
|
119
|
+
losses.push("tool binding — ADK binds a tool by a CODE reference (a fully qualified " +
|
|
120
|
+
"Python path or a built-in name), not a declarative schema; a Tool's " +
|
|
121
|
+
"`description` and `parameters` (JSON Schema) have no Agent Config slot " +
|
|
122
|
+
"(ADK derives them from the Python callable at load). Each emitted `- name` " +
|
|
123
|
+
"is a placeholder to repoint to the tool's real FQN");
|
|
124
|
+
}
|
|
125
|
+
if (ctx.outputSchema) {
|
|
126
|
+
losses.push("output_schema — ADK `output_schema` is a `CodeConfig` (a reference to a " +
|
|
127
|
+
"Pydantic class by FQN), not an inline JSON Schema; DNA's inline " +
|
|
128
|
+
"`spec.output_schema` has no inline Agent Config slot");
|
|
129
|
+
}
|
|
130
|
+
const modelId = vertexModelId(ctx.model);
|
|
131
|
+
if (modelId === null) {
|
|
132
|
+
losses.push("model unbound in DNA and none supplied — emitted config has no `model`; " +
|
|
133
|
+
"ADK inherits the ancestor / system default (gemini)");
|
|
134
|
+
}
|
|
135
|
+
else if (!isGemini(modelId)) {
|
|
136
|
+
losses.push("model coordinate — ADK `model` natively accepts a Gemini id; a DNA " +
|
|
137
|
+
"`azure/openai` coordinate is not a Gemini id and needs `model_code` (a " +
|
|
138
|
+
"`LiteLlm` CodeConfig) at deploy, plus a GCP project/region");
|
|
139
|
+
}
|
|
140
|
+
const mapping = {
|
|
141
|
+
"metadata.name": "name (snake_case identifier)",
|
|
142
|
+
"metadata.description": "description",
|
|
143
|
+
"buildPrompt (Soul+guardrails+instruction)": "instruction (byte-equal)",
|
|
144
|
+
"spec.model / Genome.default_llm": "model (Gemini id; provider token stripped)",
|
|
145
|
+
"spec.tools[] (Tool Kind)": "tools[].name (code reference)",
|
|
146
|
+
};
|
|
147
|
+
return {
|
|
148
|
+
artifact,
|
|
149
|
+
target: this.target,
|
|
150
|
+
filename: `${ctx.name}.${this.fileExtension}`,
|
|
151
|
+
losses,
|
|
152
|
+
mapping,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -101,6 +101,14 @@ class ResearchKind extends KindBase {
|
|
|
101
101
|
items: { type: "string" },
|
|
102
102
|
default: [],
|
|
103
103
|
},
|
|
104
|
+
cited_by: {
|
|
105
|
+
type: "array",
|
|
106
|
+
items: { type: "string" },
|
|
107
|
+
default: [],
|
|
108
|
+
description: "Kind/name of docs that cite this Research as a grounding source. " +
|
|
109
|
+
"Auto-maintained by `dna sdlc cite Research/<name> --from <Kind>/<name>` " +
|
|
110
|
+
"— don't author by hand.",
|
|
111
|
+
},
|
|
104
112
|
findings: {
|
|
105
113
|
type: "array",
|
|
106
114
|
items: {
|
package/dist/extensions/sdlc.js
CHANGED
|
@@ -1357,6 +1357,9 @@ class HtmlArtifactKind extends KindBase {
|
|
|
1357
1357
|
title: aj.title ?? null,
|
|
1358
1358
|
source: aj.source ?? null,
|
|
1359
1359
|
created_at: aj.created_at ?? null,
|
|
1360
|
+
// published_url — canonical hosted location (e.g. claude.ai artifact
|
|
1361
|
+
// URL) so the gallery renders a clickable link. Lives in artifact_json.
|
|
1362
|
+
published_url: aj.published_url ?? null,
|
|
1360
1363
|
html_bytes: (spec.html ?? "").length,
|
|
1361
1364
|
};
|
|
1362
1365
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export type { ToolSurface } from "./tools.js";
|
|
|
29
29
|
export { emitAgent, buildEmitContext, registerEmitter, getEmitter, availableTargets, EmitError, UnknownTarget, } from "./emit/index.js";
|
|
30
30
|
export type { EmitContext, EmitResult, EmitTool, EmitterPort, BuildEmitContextOpts, } from "./emit/index.js";
|
|
31
31
|
export { AgentFrameworkEmitter } from "./emit/agentFramework.js";
|
|
32
|
+
export { BedrockEmitter } from "./emit/bedrock.js";
|
|
32
33
|
export type { LoadPromptsOptions } from "./prompts.js";
|
|
33
34
|
export { anchorScopesRoot, PackageScopeNotFound, DEFAULT_SUBPATH } from "./package-scope.js";
|
|
34
35
|
export { loadConfig, findConfig, CONFIG_FILENAME } from "./config.js";
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export { PromptLibrary, loadPrompts } from "./prompts.js";
|
|
|
32
32
|
export { ToolLibrary, loadTools } from "./tools.js";
|
|
33
33
|
export { emitAgent, buildEmitContext, registerEmitter, getEmitter, availableTargets, EmitError, UnknownTarget, } from "./emit/index.js";
|
|
34
34
|
export { AgentFrameworkEmitter } from "./emit/agentFramework.js";
|
|
35
|
+
export { BedrockEmitter } from "./emit/bedrock.js";
|
|
35
36
|
export { anchorScopesRoot, PackageScopeNotFound, DEFAULT_SUBPATH } from "./package-scope.js";
|
|
36
37
|
export { loadConfig, findConfig, CONFIG_FILENAME } from "./config.js";
|
|
37
38
|
export { sourceFromUrl, resolveDefaultFsUrl, UnsupportedSourceScheme } from "./adapters/source-url.js";
|