@dam-agents/cli 0.2.14-rc1 → 0.2.15-rc1
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/bin.js +236 -51
- package/package.json +3 -3
package/dist/bin.js
CHANGED
|
@@ -26787,6 +26787,8 @@ var scanFailureCodes = [
|
|
|
26787
26787
|
"needs_sandbox",
|
|
26788
26788
|
"repo_unreachable",
|
|
26789
26789
|
"agent_unreachable",
|
|
26790
|
+
"source_path_not_found",
|
|
26791
|
+
"source_path_empty",
|
|
26790
26792
|
"other"
|
|
26791
26793
|
];
|
|
26792
26794
|
var scanFailureSchema = external_exports.object({
|
|
@@ -26991,6 +26993,7 @@ var templateSpecSchema = external_exports.object({
|
|
|
26991
26993
|
category: templateCategorySchema,
|
|
26992
26994
|
tags: external_exports.array(external_exports.string()).optional(),
|
|
26993
26995
|
docsUrl: external_exports.string().optional(),
|
|
26996
|
+
releaseNotesUrl: external_exports.string().optional(),
|
|
26994
26997
|
setupNote: external_exports.object({ title: external_exports.string(), body: external_exports.string() }).optional(),
|
|
26995
26998
|
experimental: external_exports.boolean().optional(),
|
|
26996
26999
|
mounts: external_exports.array(mountSchema).optional(),
|
|
@@ -27042,7 +27045,8 @@ var spawnInvocationResponseSchema = external_exports.object({
|
|
|
27042
27045
|
});
|
|
27043
27046
|
var invocationViewSchema = external_exports.object({
|
|
27044
27047
|
status: external_exports.enum(["running", "done", "failed"]),
|
|
27045
|
-
result: external_exports.unknown()
|
|
27048
|
+
result: external_exports.unknown(),
|
|
27049
|
+
errorReason: external_exports.string().optional()
|
|
27046
27050
|
});
|
|
27047
27051
|
|
|
27048
27052
|
// ../agent-runtime-api/src/modules/files/schemas.ts
|
|
@@ -27126,6 +27130,10 @@ var skillWriteLocalInputSchema = external_exports.object({
|
|
|
27126
27130
|
).min(1).max(50)
|
|
27127
27131
|
});
|
|
27128
27132
|
|
|
27133
|
+
// ../agent-runtime-api/src/modules/workspace/paths.ts
|
|
27134
|
+
var AGENT_HOME_DIR = "/home/agent";
|
|
27135
|
+
var AGENT_WORK_DIR = `${AGENT_HOME_DIR}/work`;
|
|
27136
|
+
|
|
27129
27137
|
// ../agent-runtime-api/src/modules/ssh/schemas.ts
|
|
27130
27138
|
var sshAuthorizeKeyInputSchema = external_exports.object({
|
|
27131
27139
|
publicKey: external_exports.string().min(1).max(8192).refine((s) => !/[\r\n]/.test(s), "must be a single line")
|
|
@@ -27433,6 +27441,9 @@ var egressRuleUpdateInputSchema = external_exports.object({
|
|
|
27433
27441
|
pathPattern: external_exports.string().min(1).optional(),
|
|
27434
27442
|
verdict: ruleVerdictSchema.optional()
|
|
27435
27443
|
});
|
|
27444
|
+
var egressRuleGetInputSchema = external_exports.object({
|
|
27445
|
+
id: external_exports.string().min(1)
|
|
27446
|
+
});
|
|
27436
27447
|
var egressRuleRevokeInputSchema = external_exports.object({
|
|
27437
27448
|
id: external_exports.string().min(1)
|
|
27438
27449
|
});
|
|
@@ -27529,6 +27540,7 @@ var quietWindowSchema = external_exports.object({
|
|
|
27529
27540
|
}).refine((w3) => w3.startTime !== w3.endTime, {
|
|
27530
27541
|
message: "startTime and endTime must differ"
|
|
27531
27542
|
});
|
|
27543
|
+
var scheduleListForOwnerInputSchema = external_exports.object({ limit: external_exports.number().int().positive().max(200).optional() }).optional();
|
|
27532
27544
|
var scheduleListInputSchema = external_exports.object({
|
|
27533
27545
|
agentId: external_exports.string().min(1)
|
|
27534
27546
|
});
|
|
@@ -27616,13 +27628,15 @@ var skeletonSchema = external_exports.object({
|
|
|
27616
27628
|
stages: external_exports.array(
|
|
27617
27629
|
external_exports.object({
|
|
27618
27630
|
id: stageIdSchema,
|
|
27619
|
-
after: external_exports.array(stageIdSchema).max(20).default([])
|
|
27631
|
+
after: external_exports.array(stageIdSchema).max(20).default([]),
|
|
27632
|
+
description: external_exports.string().trim().min(1).max(300).optional()
|
|
27620
27633
|
})
|
|
27621
27634
|
).max(50).default([]),
|
|
27622
27635
|
loops: external_exports.array(
|
|
27623
27636
|
external_exports.object({
|
|
27624
27637
|
id: stageIdSchema,
|
|
27625
|
-
stages: external_exports.array(stageIdSchema).min(1).max(50)
|
|
27638
|
+
stages: external_exports.array(stageIdSchema).min(1).max(50),
|
|
27639
|
+
description: external_exports.string().trim().min(1).max(300).optional()
|
|
27626
27640
|
})
|
|
27627
27641
|
).max(10).default([])
|
|
27628
27642
|
});
|
|
@@ -27735,7 +27749,8 @@ var artifactKindSchema = external_exports.enum([
|
|
|
27735
27749
|
"binary"
|
|
27736
27750
|
]);
|
|
27737
27751
|
var artifactVisibilitySchema = external_exports.enum(["private", "public"]);
|
|
27738
|
-
var
|
|
27752
|
+
var ARTIFACT_TITLE_MAX_LENGTH = 300;
|
|
27753
|
+
var titleSchema = external_exports.string().trim().min(1, "title is required").max(ARTIFACT_TITLE_MAX_LENGTH);
|
|
27739
27754
|
var fileNameSchema = external_exports.string().trim().min(1).max(255);
|
|
27740
27755
|
var expiresInHoursSchema = external_exports.number().int().positive().max(24 * 365 * 10);
|
|
27741
27756
|
var artifactIdInputSchema = external_exports.object({ id: external_exports.string().min(1) });
|
|
@@ -31379,7 +31394,7 @@ function describeApprovalPayload(payload) {
|
|
|
31379
31394
|
// ../api-server-api/src/modules/egress-rules/format.ts
|
|
31380
31395
|
function formatEgressRuleSource(source) {
|
|
31381
31396
|
if (source === "manual") return "manual";
|
|
31382
|
-
if (source === "inbox") return "from
|
|
31397
|
+
if (source === "inbox") return "from an approval";
|
|
31383
31398
|
if (source === "preset:trusted") return "preset: trusted";
|
|
31384
31399
|
if (source === "preset:all") return "preset: all";
|
|
31385
31400
|
if (source.startsWith("connection:")) {
|
|
@@ -31405,6 +31420,32 @@ function stripTrailingSlashes(s) {
|
|
|
31405
31420
|
return s.slice(0, end);
|
|
31406
31421
|
}
|
|
31407
31422
|
|
|
31423
|
+
// ../api-server-api/src/modules/egress-rules/promotion.ts
|
|
31424
|
+
function needsL7Promotion(method, pathPattern, port) {
|
|
31425
|
+
return method !== "*" || pathPattern !== "*" || port != null;
|
|
31426
|
+
}
|
|
31427
|
+
function promotedHosts(rules) {
|
|
31428
|
+
const hosts = rules.filter((r) => r.host !== "*").filter((r) => !r.source.startsWith("connection:")).filter((r) => needsL7Promotion(r.method, r.pathPattern, r.port)).map((r) => r.host);
|
|
31429
|
+
return [...new Set(hosts)].sort();
|
|
31430
|
+
}
|
|
31431
|
+
function gatewayRestartImpact(input) {
|
|
31432
|
+
const removed = new Set(input.removeIds ?? []);
|
|
31433
|
+
const before = promotedHosts(input.current);
|
|
31434
|
+
const after = promotedHosts([
|
|
31435
|
+
...input.current.filter((r) => !removed.has(r.id)),
|
|
31436
|
+
...input.adds ?? []
|
|
31437
|
+
]);
|
|
31438
|
+
const beforeSet = new Set(before);
|
|
31439
|
+
const afterSet = new Set(after);
|
|
31440
|
+
const promoted = after.filter((h2) => !beforeSet.has(h2));
|
|
31441
|
+
const demoted = before.filter((h2) => !afterSet.has(h2));
|
|
31442
|
+
return {
|
|
31443
|
+
promoted,
|
|
31444
|
+
demoted,
|
|
31445
|
+
willRestart: promoted.length > 0 || demoted.length > 0
|
|
31446
|
+
};
|
|
31447
|
+
}
|
|
31448
|
+
|
|
31408
31449
|
// ../api-server-api/src/modules/acp/types.ts
|
|
31409
31450
|
var platformTurnEndedParamsSchema = external_exports.object({
|
|
31410
31451
|
sessionId: external_exports.string().min(1)
|
|
@@ -31414,6 +31455,9 @@ var platformTurnEndedNotificationSchema = external_exports.object({
|
|
|
31414
31455
|
method: external_exports.literal("platform/turnEnded"),
|
|
31415
31456
|
params: platformTurnEndedParamsSchema
|
|
31416
31457
|
});
|
|
31458
|
+
var platformClippedReplayMetaSchema = external_exports.object({
|
|
31459
|
+
older: external_exports.string().min(1).optional()
|
|
31460
|
+
});
|
|
31417
31461
|
var platformPromptAcceptedParamsSchema = external_exports.object({
|
|
31418
31462
|
sessionId: external_exports.string().min(1),
|
|
31419
31463
|
promptId: external_exports.string().min(1),
|
|
@@ -31439,6 +31483,7 @@ var brandSchema = external_exports.object({
|
|
|
31439
31483
|
name: external_exports.string(),
|
|
31440
31484
|
short: external_exports.string(),
|
|
31441
31485
|
title: external_exports.string(),
|
|
31486
|
+
vendor: external_exports.string(),
|
|
31442
31487
|
theme: external_exports.object({
|
|
31443
31488
|
light: external_exports.object({
|
|
31444
31489
|
accent: external_exports.string(),
|
|
@@ -31453,6 +31498,16 @@ var brandSchema = external_exports.object({
|
|
|
31453
31498
|
})
|
|
31454
31499
|
});
|
|
31455
31500
|
|
|
31501
|
+
// ../api-server-api/src/modules/agents/public-agent.ts
|
|
31502
|
+
var publicAgentViewSchema = external_exports.object({
|
|
31503
|
+
agentId: external_exports.string(),
|
|
31504
|
+
name: external_exports.string(),
|
|
31505
|
+
ownerName: external_exports.string().nullable()
|
|
31506
|
+
});
|
|
31507
|
+
var publicAgentResponseSchema = external_exports.object({
|
|
31508
|
+
agent: publicAgentViewSchema.nullable()
|
|
31509
|
+
});
|
|
31510
|
+
|
|
31456
31511
|
// ../api-server-api/src/modules/terms/schemas.ts
|
|
31457
31512
|
var termsCurrentSchema = external_exports.object({
|
|
31458
31513
|
version: external_exports.string().min(1),
|
|
@@ -31477,6 +31532,16 @@ var termsLatestAcceptanceSchema = external_exports.object({
|
|
|
31477
31532
|
acceptedAt: external_exports.date()
|
|
31478
31533
|
}).nullable();
|
|
31479
31534
|
|
|
31535
|
+
// ../api-server-api/src/modules/usage/schemas.ts
|
|
31536
|
+
var entryPointChoiceSchema = external_exports.enum([
|
|
31537
|
+
"sandbox",
|
|
31538
|
+
"experiment",
|
|
31539
|
+
"knowledge-base"
|
|
31540
|
+
]);
|
|
31541
|
+
var entryPointChosenInputSchema = external_exports.object({
|
|
31542
|
+
choice: entryPointChoiceSchema
|
|
31543
|
+
});
|
|
31544
|
+
|
|
31480
31545
|
// ../api-server-api/src/modules/auth/types.ts
|
|
31481
31546
|
var authConfigSchema = external_exports.object({
|
|
31482
31547
|
issuer: external_exports.string().url(),
|
|
@@ -37639,7 +37704,7 @@ function buildSlackConnectCommand(deps) {
|
|
|
37639
37704
|
if (!res.ok) {
|
|
37640
37705
|
if (res.error.kind === "channel-conflict") {
|
|
37641
37706
|
process.stderr.write(
|
|
37642
|
-
"error:
|
|
37707
|
+
"error: this agent is already connected to that Slack channel\n"
|
|
37643
37708
|
);
|
|
37644
37709
|
process.exit(EXIT_INVALID_INPUT);
|
|
37645
37710
|
}
|
|
@@ -37672,7 +37737,7 @@ function buildSlackConnectCommand(deps) {
|
|
|
37672
37737
|
);
|
|
37673
37738
|
if (opts.ambient) {
|
|
37674
37739
|
process.stderr.write(
|
|
37675
|
-
"note: the agent reads along in this channel and may chime in without being mentioned;
|
|
37740
|
+
"note: the agent reads along in this channel and may chime in without being mentioned; ambient is per agent, so others connected here are unaffected\n"
|
|
37676
37741
|
);
|
|
37677
37742
|
}
|
|
37678
37743
|
process.stderr.write(
|
|
@@ -40345,7 +40410,7 @@ function createProcessEnvReader() {
|
|
|
40345
40410
|
|
|
40346
40411
|
// src/modules/cli/infrastructure/package-version.ts
|
|
40347
40412
|
function readPackageVersion() {
|
|
40348
|
-
return true ? "0.2.
|
|
40413
|
+
return true ? "0.2.15-rc1" : DEV_VERSION;
|
|
40349
40414
|
}
|
|
40350
40415
|
|
|
40351
40416
|
// src/modules/cli/infrastructure/version-probe.ts
|
|
@@ -41838,6 +41903,17 @@ function buildApplyPresetCommand(deps) {
|
|
|
41838
41903
|
);
|
|
41839
41904
|
}
|
|
41840
41905
|
|
|
41906
|
+
// src/modules/egress/domain/restart-notice.ts
|
|
41907
|
+
function gatewayRestartNotice(impact) {
|
|
41908
|
+
const clauses = [
|
|
41909
|
+
impact.promoted.length > 0 && `start inspecting requests to ${impact.promoted.join(", ")}`,
|
|
41910
|
+
impact.demoted.length > 0 && `stop inspecting requests to ${impact.demoted.join(", ")}`
|
|
41911
|
+
].filter((c2) => c2 !== false);
|
|
41912
|
+
return `The network gateway will restart (~5\u201315s) to ${clauses.join(" and ")}.
|
|
41913
|
+
The sandbox keeps running \u2014 its outbound requests are briefly interrupted.
|
|
41914
|
+
`;
|
|
41915
|
+
}
|
|
41916
|
+
|
|
41841
41917
|
// src/modules/egress/commands/create.ts
|
|
41842
41918
|
function buildCreateCommand2(deps) {
|
|
41843
41919
|
return new Command("create").description("Add a network access rule to an Agent").argument("<agent>", "Agent Ref \u2014 name or 'agent-\u2026' ID").requiredOption("--host <h>", "host the rule applies to").option("--method <m>", "HTTP method; default '*'", "*").option("--path <p>", "path pattern; default '*'", "*").addOption(
|
|
@@ -41845,7 +41921,7 @@ function buildCreateCommand2(deps) {
|
|
|
41845
41921
|
).option(
|
|
41846
41922
|
"--server <url>",
|
|
41847
41923
|
"override the configured server URL for this call"
|
|
41848
|
-
).option("-y, --yes", "skip the
|
|
41924
|
+
).option("-y, --yes", "skip the gateway restart confirmation").option("--json", "emit the created rule as JSON").addHelpText(
|
|
41849
41925
|
"after",
|
|
41850
41926
|
"\nExamples:\n dam network create my-agent --host api.example.com\n dam network create my-agent --host api.example.com --method GET --path /v1/* --yes\n"
|
|
41851
41927
|
).action(
|
|
@@ -41865,20 +41941,36 @@ function buildCreateCommand2(deps) {
|
|
|
41865
41941
|
printResolveError(resolved.error, host);
|
|
41866
41942
|
process.exit(exitCodeForResolveError(resolved.error));
|
|
41867
41943
|
}
|
|
41868
|
-
const
|
|
41869
|
-
if (
|
|
41870
|
-
|
|
41871
|
-
|
|
41872
|
-
|
|
41873
|
-
);
|
|
41874
|
-
|
|
41944
|
+
const egress = deps.createEgressService(host);
|
|
41945
|
+
if (!opts.yes) {
|
|
41946
|
+
const existing = await egress.listForAgent(resolved.value.id);
|
|
41947
|
+
if (!existing.ok) {
|
|
41948
|
+
printServiceError(existing.error, host);
|
|
41949
|
+
process.exit(EXIT_RUNTIME_FAILURE);
|
|
41950
|
+
}
|
|
41951
|
+
const impact = gatewayRestartImpact({
|
|
41952
|
+
current: existing.value,
|
|
41953
|
+
adds: [
|
|
41954
|
+
{
|
|
41955
|
+
host: opts.host,
|
|
41956
|
+
method: opts.method,
|
|
41957
|
+
pathPattern: opts.path,
|
|
41958
|
+
source: "manual"
|
|
41959
|
+
}
|
|
41960
|
+
]
|
|
41961
|
+
});
|
|
41962
|
+
if (impact.willRestart) {
|
|
41963
|
+
if (!process.stdin.isTTY) {
|
|
41964
|
+
process.stderr.write(
|
|
41965
|
+
"error: this rule restarts the network gateway; pass --yes on non-interactive stdin\n"
|
|
41966
|
+
);
|
|
41967
|
+
process.exit(EXIT_INVALID_INPUT);
|
|
41968
|
+
}
|
|
41969
|
+
process.stderr.write(gatewayRestartNotice(impact));
|
|
41970
|
+
if (!await confirm("Continue?")) exitCancelled(opts);
|
|
41875
41971
|
}
|
|
41876
|
-
process.stderr.write(
|
|
41877
|
-
"This rule requires path-level enforcement (non-wildcard method/path) and will restart the agent (~5\u201315s).\n"
|
|
41878
|
-
);
|
|
41879
|
-
if (!await confirm("Continue?")) exitCancelled(opts);
|
|
41880
41972
|
}
|
|
41881
|
-
const result = await
|
|
41973
|
+
const result = await egress.create({
|
|
41882
41974
|
agentId: resolved.value.id,
|
|
41883
41975
|
host: opts.host,
|
|
41884
41976
|
method: opts.method,
|
|
@@ -42017,31 +42109,72 @@ function buildRevokeCommand2(deps) {
|
|
|
42017
42109
|
).argument("<rule-id>", "Rule UUID (copy from `dam network list`)").option(
|
|
42018
42110
|
"--server <url>",
|
|
42019
42111
|
"override the configured server URL for this call"
|
|
42020
|
-
).option("--json", "emit { ok, id } as JSON").addHelpText(
|
|
42112
|
+
).option("-y, --yes", "skip the gateway restart confirmation").option("--json", "emit { ok, id } as JSON").addHelpText(
|
|
42021
42113
|
"after",
|
|
42022
42114
|
"\nExamples:\n dam network revoke 3f2a8c0e-2b91-4d6a-9c1b-7e8a1f0a2b3c\n"
|
|
42023
|
-
).action(
|
|
42024
|
-
|
|
42025
|
-
|
|
42026
|
-
|
|
42027
|
-
|
|
42028
|
-
|
|
42115
|
+
).action(
|
|
42116
|
+
async (id, opts) => {
|
|
42117
|
+
const host = await resolveActiveHost(deps, {
|
|
42118
|
+
flag: opts.server ? { server: opts.server } : void 0,
|
|
42119
|
+
exitCodes: {
|
|
42120
|
+
runtimeFailure: EXIT_RUNTIME_FAILURE,
|
|
42121
|
+
belowFloor: EXIT_BELOW_FLOOR
|
|
42122
|
+
}
|
|
42123
|
+
});
|
|
42124
|
+
const egress = deps.createEgressService(host);
|
|
42125
|
+
const current = await egress.get(id);
|
|
42126
|
+
if (!current.ok) {
|
|
42127
|
+
const failure = current.error;
|
|
42128
|
+
if (failure.kind === "rule-lookup-unsupported") {
|
|
42129
|
+
if (!opts.yes) {
|
|
42130
|
+
process.stderr.write(
|
|
42131
|
+
"error: this server is too old to report whether revoking restarts the network gateway; re-run with --yes to revoke anyway\n"
|
|
42132
|
+
);
|
|
42133
|
+
process.exit(EXIT_INVALID_INPUT);
|
|
42134
|
+
}
|
|
42135
|
+
} else if (failure.kind !== "rule-not-found") {
|
|
42136
|
+
printServiceError(failure, host);
|
|
42137
|
+
process.exit(EXIT_RUNTIME_FAILURE);
|
|
42138
|
+
}
|
|
42029
42139
|
}
|
|
42030
|
-
|
|
42031
|
-
|
|
42032
|
-
|
|
42033
|
-
|
|
42034
|
-
|
|
42035
|
-
|
|
42036
|
-
|
|
42037
|
-
|
|
42140
|
+
if (current.ok && !opts.yes) {
|
|
42141
|
+
const siblings = await egress.listForAgent(current.value.agentId);
|
|
42142
|
+
if (!siblings.ok) {
|
|
42143
|
+
process.stderr.write(
|
|
42144
|
+
"error: could not read the sandbox's rules to tell whether revoking restarts the network gateway; re-run with --yes to revoke anyway\n"
|
|
42145
|
+
);
|
|
42146
|
+
process.exit(EXIT_INVALID_INPUT);
|
|
42147
|
+
}
|
|
42148
|
+
const impact = gatewayRestartImpact({
|
|
42149
|
+
current: siblings.value,
|
|
42150
|
+
removeIds: [id]
|
|
42151
|
+
});
|
|
42152
|
+
if (impact.willRestart) {
|
|
42153
|
+
if (!process.stdin.isTTY) {
|
|
42154
|
+
process.stderr.write(
|
|
42155
|
+
"error: this revoke restarts the network gateway; pass --yes on non-interactive stdin\n"
|
|
42156
|
+
);
|
|
42157
|
+
process.exit(EXIT_INVALID_INPUT);
|
|
42158
|
+
}
|
|
42159
|
+
process.stderr.write(gatewayRestartNotice(impact));
|
|
42160
|
+
if (!await confirm("Continue?")) exitCancelled(opts);
|
|
42161
|
+
}
|
|
42162
|
+
}
|
|
42163
|
+
const result = await egress.revoke(id);
|
|
42164
|
+
if (!result.ok) {
|
|
42165
|
+
printServiceError(result.error, host);
|
|
42166
|
+
process.exit(EXIT_RUNTIME_FAILURE);
|
|
42167
|
+
}
|
|
42168
|
+
if (opts.json) {
|
|
42169
|
+
process.stdout.write(`${JSON.stringify({ ok: true, id })}
|
|
42038
42170
|
`);
|
|
42039
|
-
|
|
42040
|
-
|
|
42171
|
+
} else {
|
|
42172
|
+
process.stdout.write(`\u2713 Revoked rule ${id}.
|
|
42041
42173
|
`);
|
|
42174
|
+
}
|
|
42175
|
+
process.exit(EXIT_SUCCESS);
|
|
42042
42176
|
}
|
|
42043
|
-
|
|
42044
|
-
});
|
|
42177
|
+
);
|
|
42045
42178
|
}
|
|
42046
42179
|
|
|
42047
42180
|
// src/modules/egress/commands/trusted-hosts.ts
|
|
@@ -42081,7 +42214,7 @@ function buildUpdateCommand2(deps) {
|
|
|
42081
42214
|
).option(
|
|
42082
42215
|
"--server <url>",
|
|
42083
42216
|
"override the configured server URL for this call"
|
|
42084
|
-
).option("-y, --yes", "skip the
|
|
42217
|
+
).option("-y, --yes", "skip the gateway restart confirmation").option("--json", "emit the updated rule as JSON").addHelpText(
|
|
42085
42218
|
"after",
|
|
42086
42219
|
"\nExamples:\n dam network update 3f2a8c0e-... --verdict deny\n dam network update 3f2a8c0e-... --method GET --path /v1/* --yes\n"
|
|
42087
42220
|
).action(
|
|
@@ -42099,20 +42232,60 @@ function buildUpdateCommand2(deps) {
|
|
|
42099
42232
|
belowFloor: EXIT_BELOW_FLOOR
|
|
42100
42233
|
}
|
|
42101
42234
|
});
|
|
42102
|
-
const
|
|
42103
|
-
|
|
42104
|
-
|
|
42235
|
+
const egress = deps.createEgressService(host);
|
|
42236
|
+
const current = await egress.get(id);
|
|
42237
|
+
if (!current.ok) {
|
|
42238
|
+
const failure = current.error;
|
|
42239
|
+
if (failure.kind === "rule-not-found") {
|
|
42105
42240
|
process.stderr.write(
|
|
42106
|
-
|
|
42241
|
+
`error: network access rule not found: ${failure.id}
|
|
42242
|
+
`
|
|
42107
42243
|
);
|
|
42108
|
-
process.exit(
|
|
42244
|
+
process.exit(EXIT_RULE_NOT_FOUND);
|
|
42245
|
+
} else if (failure.kind === "rule-lookup-unsupported") {
|
|
42246
|
+
if (!opts.yes) {
|
|
42247
|
+
process.stderr.write(
|
|
42248
|
+
"error: this server is too old to report whether this change restarts the network gateway; re-run with --yes to apply it anyway\n"
|
|
42249
|
+
);
|
|
42250
|
+
process.exit(EXIT_INVALID_INPUT);
|
|
42251
|
+
}
|
|
42252
|
+
} else {
|
|
42253
|
+
printServiceError(failure, host);
|
|
42254
|
+
process.exit(EXIT_RUNTIME_FAILURE);
|
|
42255
|
+
}
|
|
42256
|
+
}
|
|
42257
|
+
if (current.ok) {
|
|
42258
|
+
const rule = current.value;
|
|
42259
|
+
const siblings = await egress.listForAgent(rule.agentId);
|
|
42260
|
+
if (!siblings.ok) {
|
|
42261
|
+
printServiceError(siblings.error, host);
|
|
42262
|
+
process.exit(EXIT_RUNTIME_FAILURE);
|
|
42263
|
+
}
|
|
42264
|
+
const impact = gatewayRestartImpact({
|
|
42265
|
+
current: siblings.value,
|
|
42266
|
+
removeIds: [id],
|
|
42267
|
+
adds: [
|
|
42268
|
+
{
|
|
42269
|
+
host: rule.host,
|
|
42270
|
+
...rule.port ? { port: rule.port } : {},
|
|
42271
|
+
method: opts.method ?? rule.method,
|
|
42272
|
+
pathPattern: opts.path ?? rule.pathPattern,
|
|
42273
|
+
source: "manual"
|
|
42274
|
+
}
|
|
42275
|
+
]
|
|
42276
|
+
});
|
|
42277
|
+
if (impact.willRestart && !opts.yes) {
|
|
42278
|
+
if (!process.stdin.isTTY) {
|
|
42279
|
+
process.stderr.write(
|
|
42280
|
+
"error: this change restarts the network gateway; pass --yes on non-interactive stdin\n"
|
|
42281
|
+
);
|
|
42282
|
+
process.exit(EXIT_INVALID_INPUT);
|
|
42283
|
+
}
|
|
42284
|
+
process.stderr.write(gatewayRestartNotice(impact));
|
|
42285
|
+
if (!await confirm("Continue?")) exitCancelled(opts);
|
|
42109
42286
|
}
|
|
42110
|
-
process.stderr.write(
|
|
42111
|
-
"This rule requires path-level enforcement (non-wildcard method/path) and will restart the agent (~5\u201315s).\n"
|
|
42112
|
-
);
|
|
42113
|
-
if (!await confirm("Continue?")) exitCancelled(opts);
|
|
42114
42287
|
}
|
|
42115
|
-
const result = await
|
|
42288
|
+
const result = await egress.update({
|
|
42116
42289
|
id,
|
|
42117
42290
|
method: opts.method,
|
|
42118
42291
|
pathPattern: opts.path,
|
|
@@ -42151,6 +42324,18 @@ function createEgressService(deps) {
|
|
|
42151
42324
|
() => deps.trpc.egressRules.listForAgent.query({ agentId })
|
|
42152
42325
|
);
|
|
42153
42326
|
},
|
|
42327
|
+
async get(id) {
|
|
42328
|
+
try {
|
|
42329
|
+
const view = await deps.trpc.egressRules.get.query({ id });
|
|
42330
|
+
return ok2(view);
|
|
42331
|
+
} catch (e2) {
|
|
42332
|
+
if (e2?.data?.code === "NOT_FOUND") {
|
|
42333
|
+
const reason = e2 instanceof Error ? e2.message : String(e2);
|
|
42334
|
+
return /egress rule not found/i.test(reason) ? err2({ kind: "rule-not-found", id }) : err2({ kind: "rule-lookup-unsupported", reason });
|
|
42335
|
+
}
|
|
42336
|
+
return classifyTrpcError(e2);
|
|
42337
|
+
}
|
|
42338
|
+
},
|
|
42154
42339
|
async currentPreset(agentId) {
|
|
42155
42340
|
return trpcCall(
|
|
42156
42341
|
() => deps.trpc.egressRules.currentPreset.query({ agentId })
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dam-agents/cli",
|
|
3
3
|
"author": "IBM Corp.",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.15-rc1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"homepage": "https://github.com/dam-agents/dam/tree/main/packages/cli#readme",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"vitest": "^4.1.3",
|
|
44
44
|
"ws": "^8.20.0",
|
|
45
45
|
"zod": "^4.4.3",
|
|
46
|
-
"
|
|
46
|
+
"agent-runtime-api": "0.0.1",
|
|
47
47
|
"dev-config": "0.0.1",
|
|
48
|
-
"
|
|
48
|
+
"api-server-api": "0.0.1"
|
|
49
49
|
}
|
|
50
50
|
}
|