@domesystems/templates 0.4.2 → 0.4.3
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/package.json +1 -1
- package/src/generate.mjs +7 -6
- package/src/manifest.mjs +3 -3
package/package.json
CHANGED
package/src/generate.mjs
CHANGED
|
@@ -70,14 +70,14 @@ function managedModelReference(manifest, name) {
|
|
|
70
70
|
throw new Error(`Managed agent default_model ${name} must name a pool or model.`);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
function agentAttributes(agent) {
|
|
73
|
+
function agentAttributes(agent, managed) {
|
|
74
74
|
const lines = [];
|
|
75
75
|
if (agent.parent) lines.push(attr("parent", `dome_agent.${label(agent.parent)}.name`));
|
|
76
76
|
if (agent.metadata) lines.push(attr("metadata", `{ ${Object.entries(agent.metadata).map(([key, value]) => `${q(key)} = ${q(value)}`).join(", ")} }`));
|
|
77
|
-
for (const [key, resource] of [["allowed_pools", "dome_llm_pool"], ["allowed_models", "dome_llm_connection"], ["allowed_gateways", "dome_gateway"]]) {
|
|
77
|
+
for (const [key, resource] of [["allowed_pools", "dome_llm_pool"], ["allowed_models", "dome_llm_connection"], ...(!managed ? [["allowed_gateways", "dome_gateway"]] : [])]) {
|
|
78
78
|
if (agent[key] !== undefined) lines.push(attr(key, `[${agent[key].map((name) => `${resource}.${label(name)}.name`).join(", ")}]`));
|
|
79
79
|
}
|
|
80
|
-
if (agent.allowed_tools !== undefined) lines.push(attr("allowed_tools", `[${agent.allowed_tools.map(q).join(", ")}]`));
|
|
80
|
+
if (!managed && agent.allowed_tools !== undefined) lines.push(attr("allowed_tools", `[${agent.allowed_tools.map(q).join(", ")}]`));
|
|
81
81
|
for (const key of ["suspended", "token_ttl", "interactive_access", "secrets_version"]) if (agent[key] !== undefined) lines.push(attr(key, typeof agent[key] === "string" ? q(agent[key]) : String(agent[key])));
|
|
82
82
|
if (agent.act_as) {
|
|
83
83
|
const values = Object.entries(agent.act_as).filter(([key]) => !["hmac_secret"].includes(key)).map(([key, value]) => `${key} = ${typeof value === "string" ? q(value) : String(value)}`);
|
|
@@ -118,11 +118,12 @@ export function renderDomeTerraform(manifest) {
|
|
|
118
118
|
}
|
|
119
119
|
for (const agent of manifest.agents) {
|
|
120
120
|
const agentLabel = label(agent.name); const managed = agent.type === "managed"; const resourceType = managed ? "dome_managed_agent" : "dome_agent";
|
|
121
|
-
const lines = [attr("workspace_id", "var.workspace_id"), attr("name", q(agent.name)), ...agentAttributes(agent)];
|
|
121
|
+
const lines = [attr("workspace_id", "var.workspace_id"), attr("name", q(agent.name)), ...agentAttributes(agent, managed)];
|
|
122
122
|
if (managed) {
|
|
123
123
|
if (!agent.system_prompt?.content || !agent.default_model) throw new Error(`Managed agent ${agent.name} needs system_prompt and default_model.`);
|
|
124
|
-
|
|
125
|
-
if (
|
|
124
|
+
if (typeof agent.gateway !== "string" || !agent.gateway) throw new Error(`Managed agent ${agent.name} needs gateway.`);
|
|
125
|
+
if (!manifest.gateways.some((gateway) => gateway.name === agent.gateway)) throw new Error(`Managed agent ${agent.name} references unknown gateway ${agent.gateway}.`);
|
|
126
|
+
lines.push(attr("system_prompt", "<<-PROMPT"), ...agent.system_prompt.content.split("\n").map((line) => line.trimEnd()), "PROMPT", attr("default_model", managedModelReference(manifest, agent.default_model)), attr("gateway", `dome_gateway.${label(agent.gateway)}.name`));
|
|
126
127
|
}
|
|
127
128
|
blocks.push(block(resourceType, agentLabel, lines), ...rulesBlock(agent, resourceType, agentLabel));
|
|
128
129
|
if (!managed) for (const key of agent.keys ?? []) blocks.push(block("dome_agent_key", `${agentLabel}_${label(required(key, "name", `Agent ${agent.name} keys need a name.`))}`, [attr("workspace_id", "var.workspace_id"), attr("agent", `dome_agent.${agentLabel}.name`), attr("name", q(key.name))]));
|
package/src/manifest.mjs
CHANGED
|
@@ -109,10 +109,10 @@ export function readManifest(templateDirectory) {
|
|
|
109
109
|
return { ...cleanAgent, type };
|
|
110
110
|
});
|
|
111
111
|
const filters = normalizeFilterConfigs(root, expandFilters(root, manifest.filters));
|
|
112
|
-
if (manifest.triggers !== undefined) throw new Error("triggers is not a top-level template field; declare trigger_config on the managed agent it controls.");
|
|
113
112
|
for (const agent of agents) {
|
|
114
|
-
if (agent.type === "managed" && (!agent.system_prompt || !agent.default_model)) throw new Error(`Managed agent ${agent.name} needs system_prompt and
|
|
115
|
-
if (agent.type === "
|
|
113
|
+
if (agent.type === "managed" && (!agent.system_prompt || !agent.default_model || !agent.gateway)) throw new Error(`Managed agent ${agent.name} needs system_prompt, default_model, and gateway.`);
|
|
114
|
+
if (agent.type === "managed" && (agent.allowed_gateways !== undefined || agent.allowed_tools !== undefined || agent.trigger_config !== undefined)) throw new Error(`Managed agent ${agent.name} uses gateway; allowed_gateways, allowed_tools, and trigger_config are not supported.`);
|
|
115
|
+
if (agent.type === "external" && (agent.system_prompt !== undefined || agent.default_model !== undefined || agent.gateway !== undefined || agent.trigger_config !== undefined)) throw new Error(`External agent ${agent.name} cannot declare managed-agent loop fields.`);
|
|
116
116
|
}
|
|
117
117
|
named(agents, "agents"); named(manifest.gateways ?? [], "gateways"); named(manifest.tool_connections ?? [], "tool_connections"); named(manifest.models ?? [], "models"); named(manifest.pools ?? [], "pools"); named(filters, "filters");
|
|
118
118
|
return { ...manifest, variables: manifest.variables ?? {}, gateways: manifest.gateways ?? [], tool_connections: manifest.tool_connections ?? [], models: manifest.models ?? [], pools: manifest.pools ?? [], filters, quotas: manifest.quotas ?? [], agents };
|