@invarn/cli 0.2.2 → 0.2.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/README.md +4 -0
- package/dist/invarn.cjs +7 -7
- package/dist/sdk.mjs +45 -11
- package/package.json +1 -1
package/dist/sdk.mjs
CHANGED
|
@@ -7091,17 +7091,19 @@ async function getAgentBuildResult(sessionToken, buildId, { wait } = {}) {
|
|
|
7091
7091
|
}
|
|
7092
7092
|
return res.json();
|
|
7093
7093
|
}
|
|
7094
|
-
async function listSecrets({ pipelineId, kind } = {}) {
|
|
7094
|
+
async function listSecrets({ pipelineId, agentId, kind } = {}) {
|
|
7095
7095
|
const url = new URL("/secrets", "http://placeholder");
|
|
7096
7096
|
if (pipelineId) url.searchParams.set("pipeline", pipelineId);
|
|
7097
|
+
if (agentId) url.searchParams.set("agent", agentId);
|
|
7097
7098
|
if (kind) url.searchParams.set("kind", kind);
|
|
7098
7099
|
const res = await request(`${url.pathname}${url.search}`);
|
|
7099
7100
|
const body = await res.json();
|
|
7100
7101
|
return body.entries || [];
|
|
7101
7102
|
}
|
|
7102
|
-
async function createSecret({ scope, pipelineId, kind, key, value }) {
|
|
7103
|
+
async function createSecret({ scope, pipelineId, agentId, kind, key, value }) {
|
|
7103
7104
|
const body = { scope, kind, key, value };
|
|
7104
7105
|
if (pipelineId) body.pipelineId = pipelineId;
|
|
7106
|
+
if (agentId) body.agentId = agentId;
|
|
7105
7107
|
const res = await request("/secrets", {
|
|
7106
7108
|
method: "POST",
|
|
7107
7109
|
body: JSON.stringify(body)
|
|
@@ -8971,12 +8973,19 @@ ${lines.join("\n")}`;
|
|
|
8971
8973
|
}
|
|
8972
8974
|
async function handleSecretsList(args) {
|
|
8973
8975
|
try {
|
|
8976
|
+
if (args.pipeline_id && args.agent_id) {
|
|
8977
|
+
return {
|
|
8978
|
+
content: [{ type: "text", text: "Error: pass either pipeline_id or agent_id, not both." }],
|
|
8979
|
+
isError: true
|
|
8980
|
+
};
|
|
8981
|
+
}
|
|
8974
8982
|
const entries = await listSecrets({
|
|
8975
8983
|
pipelineId: args.pipeline_id || void 0,
|
|
8984
|
+
agentId: args.agent_id || void 0,
|
|
8976
8985
|
kind: args.kind
|
|
8977
8986
|
});
|
|
8978
8987
|
if (entries.length === 0) {
|
|
8979
|
-
const scope = args.pipeline_id ? "pipeline" : "org";
|
|
8988
|
+
const scope = args.pipeline_id || args.agent_id ? "pipeline" : "org";
|
|
8980
8989
|
return {
|
|
8981
8990
|
content: [
|
|
8982
8991
|
{ type: "text", text: `No ${args.kind?.toLowerCase() ?? "entries"} at ${scope} scope.` }
|
|
@@ -8996,12 +9005,19 @@ ${lines.join("\n")}` }] };
|
|
|
8996
9005
|
}
|
|
8997
9006
|
async function handleSecretsSet(args) {
|
|
8998
9007
|
try {
|
|
9008
|
+
if (args.pipeline_id && args.agent_id) {
|
|
9009
|
+
return {
|
|
9010
|
+
content: [{ type: "text", text: "Error: pass either pipeline_id or agent_id, not both." }],
|
|
9011
|
+
isError: true
|
|
9012
|
+
};
|
|
9013
|
+
}
|
|
8999
9014
|
const kind = args.kind === "VARIABLE" ? "VARIABLE" : "SECRET";
|
|
9000
|
-
const scope = args.pipeline_id ? "PIPELINE" : "ORG";
|
|
9015
|
+
const scope = args.pipeline_id || args.agent_id ? "PIPELINE" : "ORG";
|
|
9001
9016
|
try {
|
|
9002
9017
|
await createSecret({
|
|
9003
9018
|
scope,
|
|
9004
9019
|
pipelineId: args.pipeline_id,
|
|
9020
|
+
agentId: args.agent_id,
|
|
9005
9021
|
kind,
|
|
9006
9022
|
key: args.key,
|
|
9007
9023
|
value: args.value
|
|
@@ -9016,7 +9032,11 @@ async function handleSecretsSet(args) {
|
|
|
9016
9032
|
};
|
|
9017
9033
|
} catch (err) {
|
|
9018
9034
|
if (err.statusCode !== 409) throw err;
|
|
9019
|
-
const existing = (await listSecrets({
|
|
9035
|
+
const existing = (await listSecrets({
|
|
9036
|
+
pipelineId: args.pipeline_id,
|
|
9037
|
+
agentId: args.agent_id,
|
|
9038
|
+
kind
|
|
9039
|
+
})).find((e) => e.key === args.key);
|
|
9020
9040
|
if (!existing) throw err;
|
|
9021
9041
|
await updateSecretValue(existing.id, args.value);
|
|
9022
9042
|
return {
|
|
@@ -9191,16 +9211,17 @@ var TOOL_SPECS = [
|
|
|
9191
9211
|
},
|
|
9192
9212
|
{
|
|
9193
9213
|
name: "invarn_secrets_list",
|
|
9194
|
-
description: "List secret and variable metadata for the organization or a specific pipeline. Returns keys, kinds, scopes, and timestamps \u2014 NEVER values. Use this to check whether a secret exists before calling invarn_agent_run.",
|
|
9214
|
+
description: "List secret and variable metadata for the organization or a specific pipeline. Returns keys, kinds, scopes, and timestamps \u2014 NEVER values. Use this to check whether a secret exists before calling invarn_agent_run. To scope to an agent's pipeline, pass agent_id \u2014 simpler than looking up pipeline_id.",
|
|
9195
9215
|
inputSchema: {
|
|
9196
|
-
pipeline_id: z2.string().optional().describe("Pipeline ID. Omit for org-scoped entries."),
|
|
9216
|
+
pipeline_id: z2.string().optional().describe("Pipeline ID. Omit for org-scoped entries. Mutually exclusive with agent_id."),
|
|
9217
|
+
agent_id: z2.string().optional().describe("Agent ID \u2014 resolves to the agent's owned pipeline server-side. Mutually exclusive with pipeline_id."),
|
|
9197
9218
|
kind: z2.enum(["SECRET", "VARIABLE"]).optional().describe("Filter to a specific kind.")
|
|
9198
9219
|
},
|
|
9199
9220
|
handler: async (args) => handleSecretsList(args ?? {})
|
|
9200
9221
|
},
|
|
9201
9222
|
{
|
|
9202
9223
|
name: "invarn_secrets_set",
|
|
9203
|
-
description: "Create or update a secret or variable. Idempotent \u2014 if the key already exists at this scope, the value is replaced. Requires a human (inv_human_\u2026) token with OWNER or ADMIN role in the org; agent tokens receive 403. There is no read tool \u2014 values cannot be retrieved via MCP.",
|
|
9224
|
+
description: "Create or update a secret or variable. Idempotent \u2014 if the key already exists at this scope, the value is replaced. Requires a human (inv_human_\u2026) token with OWNER or ADMIN role in the org; agent tokens receive 403. There is no read tool \u2014 values cannot be retrieved via MCP. To target an agent's pipeline, pass agent_id instead of pipeline_id.",
|
|
9204
9225
|
inputSchema: {
|
|
9205
9226
|
key: z2.string().describe(
|
|
9206
9227
|
"Uppercase env-var-safe key (/^[A-Z_][A-Z0-9_]{0,63}$/, not starting with INVARN_)."
|
|
@@ -9209,7 +9230,8 @@ var TOOL_SPECS = [
|
|
|
9209
9230
|
kind: z2.enum(["SECRET", "VARIABLE"]).describe(
|
|
9210
9231
|
"SECRET: encrypted at rest, redacted from build logs. VARIABLE: plaintext, visible in dashboard and logs when echoed."
|
|
9211
9232
|
),
|
|
9212
|
-
pipeline_id: z2.string().optional().describe("Pipeline ID for a pipeline-scoped entry. Omit for org scope.")
|
|
9233
|
+
pipeline_id: z2.string().optional().describe("Pipeline ID for a pipeline-scoped entry. Omit for org scope. Mutually exclusive with agent_id."),
|
|
9234
|
+
agent_id: z2.string().optional().describe("Agent ID \u2014 resolves to the agent's owned pipeline server-side. Mutually exclusive with pipeline_id. Omit both for org scope.")
|
|
9213
9235
|
},
|
|
9214
9236
|
handler: async (args) => handleSecretsSet(args)
|
|
9215
9237
|
}
|
|
@@ -9319,19 +9341,27 @@ function buildHandlers(ctx, getSession) {
|
|
|
9319
9341
|
return result;
|
|
9320
9342
|
},
|
|
9321
9343
|
invarn_secrets_list: async (args) => {
|
|
9344
|
+
if (args.pipeline_id && args.agent_id) {
|
|
9345
|
+
throw new Error("pass either pipeline_id or agent_id, not both");
|
|
9346
|
+
}
|
|
9322
9347
|
const entries = await listSecrets({
|
|
9323
9348
|
pipelineId: args.pipeline_id || void 0,
|
|
9349
|
+
agentId: args.agent_id || void 0,
|
|
9324
9350
|
kind: args.kind
|
|
9325
9351
|
});
|
|
9326
9352
|
return { entries };
|
|
9327
9353
|
},
|
|
9328
9354
|
invarn_secrets_set: async (args) => {
|
|
9355
|
+
if (args.pipeline_id && args.agent_id) {
|
|
9356
|
+
throw new Error("pass either pipeline_id or agent_id, not both");
|
|
9357
|
+
}
|
|
9329
9358
|
const kind = args.kind === "VARIABLE" ? "VARIABLE" : "SECRET";
|
|
9330
|
-
const scope = args.pipeline_id ? "PIPELINE" : "ORG";
|
|
9359
|
+
const scope = args.pipeline_id || args.agent_id ? "PIPELINE" : "ORG";
|
|
9331
9360
|
try {
|
|
9332
9361
|
await createSecret({
|
|
9333
9362
|
scope,
|
|
9334
9363
|
pipelineId: args.pipeline_id,
|
|
9364
|
+
agentId: args.agent_id,
|
|
9335
9365
|
kind,
|
|
9336
9366
|
key: args.key,
|
|
9337
9367
|
value: args.value
|
|
@@ -9339,7 +9369,11 @@ function buildHandlers(ctx, getSession) {
|
|
|
9339
9369
|
return { action: "created", key: args.key, kind, scope: scope.toLowerCase() };
|
|
9340
9370
|
} catch (err) {
|
|
9341
9371
|
if (err.statusCode !== 409) throw err;
|
|
9342
|
-
const existing = (await listSecrets({
|
|
9372
|
+
const existing = (await listSecrets({
|
|
9373
|
+
pipelineId: args.pipeline_id,
|
|
9374
|
+
agentId: args.agent_id,
|
|
9375
|
+
kind
|
|
9376
|
+
})).find((e) => e.key === args.key);
|
|
9343
9377
|
if (!existing) throw err;
|
|
9344
9378
|
await updateSecretValue(existing.id, args.value);
|
|
9345
9379
|
return { action: "updated", key: args.key, kind, scope: scope.toLowerCase() };
|