@mutagent/cli 0.2.123 → 0.2.125

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.
Files changed (2) hide show
  1. package/dist/bin/cli.js +93 -10
  2. package/package.json +1 -1
package/dist/bin/cli.js CHANGED
@@ -22127,7 +22127,10 @@ before the first use.
22127
22127
  name, targets, components) and wait for the user's yes. Never run \`factory add\`
22128
22128
  without it. Then register:
22129
22129
  \`mutagent factory add <agentspec-file> --json\`. The file's git remote, path and
22130
- HEAD commit are read from its checkout and recorded as v1.
22130
+ HEAD commit are read from its checkout and recorded as v1. When the spec sets
22131
+ \`spec.traceSource\` (a trace-source id from \`mutagent integrations sources list\`),
22132
+ the entry's trace source is set to it; \`traceSourceUpdate\` reports the outcome, and
22133
+ a refusal there (its \`code\`) leaves the entry registered: tell the user the code.
22131
22134
  4. **Show the result.** Render \`_directive.renderedCard\` verbatim, then
22132
22135
  \`mutagent factory show <id> --json\` to show the targets and the spec version.
22133
22136
  5. **Record the spec stage**: \`mutagent factory stage record --stage spec --state succeeded --spec-version <n> --json\`
@@ -22260,7 +22263,10 @@ the version this checkout last wrote (\`spec get --out\`) or pushed. Read
22260
22263
  2. **Validate.** \`mutagent factory spec push <id> <file> --dry-run --json\`.
22261
22264
  3. **Confirm with the user**, then push with a reason:
22262
22265
  \`mutagent factory spec push <id> <file> --message "<why>" --json\`.
22263
- The git commit defaults to HEAD when the file is tracked and unmodified.
22266
+ The git commit defaults to HEAD when the file is tracked and unmodified. A
22267
+ \`spec.traceSource\` that differs from the entry's is then set on the entry
22268
+ (\`traceSourceUpdate\`); if that step is refused (in a sandbox: \`PERMISSION_DENIED\`),
22269
+ the push still stands: report the code, do not push again.
22264
22270
  4. Show \`_directive.renderedCard\` verbatim: it names the new version.
22265
22271
 
22266
22272
  Targets and components update from the spec; there is no separate update command.
@@ -27418,6 +27424,7 @@ import { factoryListFactoryEntries } from "@mutagent/sdk/funcs/factory-list-fact
27418
27424
  import { factoryListFactorySpecVersions } from "@mutagent/sdk/funcs/factory-list-factory-spec-versions.js";
27419
27425
  import { factoryListFactoryStageRuns } from "@mutagent/sdk/funcs/factory-list-factory-stage-runs.js";
27420
27426
  import { factoryPushFactorySpec } from "@mutagent/sdk/funcs/factory-push-factory-spec.js";
27427
+ import { factorySetFactoryEntryTraceSource } from "@mutagent/sdk/funcs/factory-set-factory-entry-trace-source.js";
27421
27428
 
27422
27429
  // src/lib/platform-sdk.ts
27423
27430
  import { HTTPClient as HTTPClient3, Mutagent as Mutagent3 } from "@mutagent/sdk";
@@ -27661,6 +27668,7 @@ var factoryApi = {
27661
27668
  specVersions: (c, id, query, help) => sdkJson(c, (sdk) => factoryListFactorySpecVersions(sdk, { id, ...query }), help),
27662
27669
  specVersion: (c, id, version, help) => sdkJson(c, (sdk) => factoryGetFactorySpecVersion(sdk, { id, version, raw: true }), help),
27663
27670
  pushSpec: (c, id, body, ifMatch, help) => sdkJson(c, (sdk) => factoryPushFactorySpec(sdk, { id, ...ifMatch === undefined ? {} : { ifMatch }, body }), help),
27671
+ setTraceSource: (c, id, traceSource, help) => sdkJson(c, (sdk) => factorySetFactoryEntryTraceSource(sdk, { id, body: { traceSource } }), help),
27664
27672
  sync: (c, id, query, help) => sdkJson(c, (sdk) => factoryGetFactorySyncState(sdk, { id, ...query }), help),
27665
27673
  createStageRun: (c, id, body, help) => sdkJson(c, (sdk) => factoryCreateFactoryStageRun(sdk, { id, body: stageRunBody(body) }), help),
27666
27674
  listStageRuns: (c, id, query, help) => sdkJson(c, (sdk) => factoryListFactoryStageRuns(sdk, { id, ...query }), help),
@@ -36788,6 +36796,56 @@ import { Command as Command30 } from "commander";
36788
36796
  import chalk66 from "chalk";
36789
36797
  init_errors();
36790
36798
 
36799
+ // src/lib/factory-trace-source.ts
36800
+ init_errors();
36801
+ function specTraceSource(spec) {
36802
+ const value = spec.parsed.spec?.traceSource;
36803
+ return typeof value === "string" ? value : undefined;
36804
+ }
36805
+ async function applySpecTraceSource(conn, entryId, wanted, current, opts) {
36806
+ if (wanted === undefined)
36807
+ return;
36808
+ let previous;
36809
+ try {
36810
+ previous = await current();
36811
+ if (previous === wanted)
36812
+ return { state: "unchanged", traceSource: wanted, previous };
36813
+ if (opts.dryRun)
36814
+ return { state: "would-set", traceSource: wanted, previous };
36815
+ const answer = await factoryApi.setTraceSource(conn, entryId, wanted, opts.help);
36816
+ return { state: "set", traceSource: answer.traceSource ?? wanted, previous };
36817
+ } catch (error) {
36818
+ if (!(error instanceof MutagentError))
36819
+ throw error;
36820
+ return {
36821
+ state: "refused",
36822
+ traceSource: wanted,
36823
+ ...previous === undefined ? {} : { previous },
36824
+ code: error.code,
36825
+ error: error.message,
36826
+ ...error.suggestion === undefined ? {} : { suggestedAction: error.suggestion }
36827
+ };
36828
+ }
36829
+ }
36830
+ function describeTraceSourceUpdate(update, written) {
36831
+ const was = update.previous === undefined ? "" : ` (was ${update.previous ?? "the Mutagent store"})`;
36832
+ switch (update.state) {
36833
+ case "set":
36834
+ return { warn: false, text: `Trace source set to ${update.traceSource}${was}` };
36835
+ case "unchanged":
36836
+ return { warn: false, text: `Trace source is already ${update.traceSource}` };
36837
+ case "would-set":
36838
+ return { warn: false, text: `Would set the trace source to ${update.traceSource}${was}; nothing was sent` };
36839
+ case "refused":
36840
+ return { warn: true, text: `${written} stands; setting the trace source to ${update.traceSource} was refused: ${update.code ?? "ERROR"}: ${update.error ?? ""}` };
36841
+ }
36842
+ }
36843
+ function traceSourceTips(update) {
36844
+ if (update?.state !== "refused")
36845
+ return [];
36846
+ return [`Trace source not set (${update.code ?? "ERROR"}); the spec write stands.${update.suggestedAction === undefined ? "" : ` ${update.suggestedAction}`}`];
36847
+ }
36848
+
36791
36849
  // src/lib/factory-local.ts
36792
36850
  init_dist();
36793
36851
  init_errors();
@@ -37742,7 +37800,8 @@ var SpecSchema = closed({
37742
37800
  workflow: Type.Optional(WorkflowBodySchema),
37743
37801
  targets: Type.Array(TargetSchema),
37744
37802
  evaluation: EvaluationSchema,
37745
- decisionsRef: Type.Optional(Str())
37803
+ decisionsRef: Type.Optional(Str()),
37804
+ traceSource: Type.Optional(Str())
37746
37805
  });
37747
37806
  var agentSpecRootProps = {
37748
37807
  apiVersion: Type.Literal(AGENTSPEC_API_VERSION),
@@ -38497,7 +38556,8 @@ function registerAdd2(factory) {
38497
38556
  "The spec is validated here (AgentSpec 0.3.0) before anything is sent. A system's",
38498
38557
  "spec.multiAgent.members[].specRef files are read for their metadata.id, resolved from",
38499
38558
  "the spec file's folder (stdin and --spec: the working directory). The git remote, path",
38500
- "and HEAD commit are read from the file's checkout."
38559
+ "and HEAD commit are read from the file's checkout. spec.traceSource, when set, is then set on",
38560
+ "the entry; a refusal of that step is reported in traceSourceUpdate by its code, and the entry stays."
38501
38561
  ],
38502
38562
  examples: [
38503
38563
  "mutagent factory add agents/invoice-pricing/agentspec.yaml --json",
@@ -38529,17 +38589,27 @@ function registerAdd2(factory) {
38529
38589
  const id = result.entry.id;
38530
38590
  if (!result.dryRun && result.entry.specVersion !== null)
38531
38591
  writeBase(checkoutRoot(spec.input.file), id, result.entry.specVersion.id, spec.input.file);
38592
+ const traceSourceUpdate = await applySpecTraceSource(conn, id, specTraceSource(spec), () => Promise.resolve(result.entry.traceSource ?? null), { dryRun: result.dryRun, help: "mutagent factory add --help" });
38593
+ const entry = traceSourceUpdate?.state === "set" ? { ...result.entry, traceSource: traceSourceUpdate.traceSource } : result.entry;
38532
38594
  const links = factoryLinks(conn.endpoint, id);
38533
38595
  const tips = [
38534
38596
  `Next spec change: mutagent factory spec push ${arg(id)} <file>`,
38535
- `Record work on it: mutagent factory stage record ${arg(id)} --stage <s> --state <s>`
38597
+ `Record work on it: mutagent factory stage record ${arg(id)} --stage <s> --state <s>`,
38598
+ ...traceSourceTips(traceSourceUpdate)
38536
38599
  ];
38537
38600
  if (isJson) {
38538
- output.output({ success: true, dryRun: result.dryRun, entry: result.entry, _links: links, _directive: { tips } });
38601
+ output.output({ success: true, dryRun: result.dryRun, entry, ...traceSourceUpdate === undefined ? {} : { traceSourceUpdate }, _links: links, _directive: { tips } });
38539
38602
  return;
38540
38603
  }
38541
38604
  output.success(result.dryRun ? `Valid: would register ${id} (${result.entry.kind}); nothing was written` : `Registered ${id} (${result.entry.kind}), spec v${String(result.entry.specVersion?.id ?? 1)}`);
38542
38605
  console.log(` ${links.ui}`);
38606
+ if (traceSourceUpdate !== undefined) {
38607
+ const line = describeTraceSourceUpdate(traceSourceUpdate, `The registration of ${id}`);
38608
+ if (line.warn)
38609
+ output.warn(line.text);
38610
+ else
38611
+ output.info(line.text);
38612
+ }
38543
38613
  for (const tip of tips)
38544
38614
  output.info(tip);
38545
38615
  });
@@ -38805,7 +38875,11 @@ function registerStatus(spec) {
38805
38875
  }
38806
38876
  function registerPush(spec) {
38807
38877
  spec.command("push").description("Validate an agentspec and record it as the entry's next spec version").argument("[id]", "The entry id; must equal the file's metadata.id (in a sandbox with only the file: the bound entry)").argument("[agentspec-file]", "Path, or - for stdin (not with --spec)").option("--spec <yaml>", "Raw YAML text instead of a file").option("--base <n>", "The spec version this file was made from (default: the one recorded in this checkout)").option("--git-commit <sha>", "Commit the file came from (default: HEAD, when the file is tracked and unmodified)").option("--message <text>", "Why it changed").option("--dry-run", "Validate only; nothing is written").addHelpText("after", leafHelp({
38808
- notes: ["Components (spec.multiAgent.members[]), their pins and targets[] update from the spec; the git location comes from the checkout."],
38878
+ notes: [
38879
+ "Components (spec.multiAgent.members[]), their pins and targets[] update from the spec; the git location comes from the checkout.",
38880
+ "spec.traceSource, when it differs from the entry's, is then set on the entry; a refusal of that step",
38881
+ "(e.g. PERMISSION_DENIED in a sandbox) is reported in traceSourceUpdate by its code, and the push stands."
38882
+ ],
38809
38883
  examples: [
38810
38884
  'mutagent factory spec push support-triage agents/support-triage/agentspec.yaml --message "Add refund-agent v3" --json',
38811
38885
  "mutagent factory spec push invoice-pricing agentspec.yaml --base 6 --json",
@@ -38849,9 +38923,11 @@ function registerPush(spec) {
38849
38923
  const version = result.specVersion.id;
38850
38924
  if (!result.dryRun)
38851
38925
  writeBase(root, entryId, version, spec.input.file);
38852
- const tips = [`Stage runs and reports you record next resolve to v${String(version)}`];
38926
+ const help = "mutagent factory spec push --help";
38927
+ const traceSourceUpdate = await applySpecTraceSource(conn, entryId, specTraceSource(spec), async () => (await factoryApi.getEntry(conn, entryId, help)).traceSource, { dryRun: result.dryRun, help });
38928
+ const tips = [`Stage runs and reports you record next resolve to v${String(version)}`, ...traceSourceTips(traceSourceUpdate)];
38853
38929
  if (isJson) {
38854
- output.output({ success: true, ...result, sync: result.dryRun ? "unchanged" : "in-sync", _links: factoryLinks(conn.endpoint, entryId), _directive: { tips } });
38930
+ output.output({ success: true, ...result, sync: result.dryRun ? "unchanged" : "in-sync", ...traceSourceUpdate === undefined ? {} : { traceSourceUpdate }, _links: factoryLinks(conn.endpoint, entryId), _directive: { tips } });
38855
38931
  return;
38856
38932
  }
38857
38933
  if (result.dryRun)
@@ -38862,6 +38938,13 @@ function registerPush(spec) {
38862
38938
  output.success(`Pushed ${entryId} v${String(version)} (base v${String(base)})`);
38863
38939
  for (const change of result.components.changed)
38864
38940
  output.info(`Pin moved: ${change.id} v${String(change.pinned.from ?? "—")} → v${String(change.pinned.to)}`);
38941
+ if (traceSourceUpdate !== undefined) {
38942
+ const line = describeTraceSourceUpdate(traceSourceUpdate, `The push (v${String(version)})`);
38943
+ if (line.warn)
38944
+ output.warn(line.text);
38945
+ else
38946
+ output.info(line.text);
38947
+ }
38865
38948
  });
38866
38949
  });
38867
38950
  }
@@ -40495,4 +40578,4 @@ if (process.env.CLI_VERSION) {
40495
40578
  }
40496
40579
  runCli(process.argv.slice(2), cliVersion);
40497
40580
 
40498
- //# debugId=32FCAEC612A7F6F964756E2164756E21
40581
+ //# debugId=EC8D8A955FE754FB64756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mutagent/cli",
3
- "version": "0.2.123",
3
+ "version": "0.2.125",
4
4
  "description": "Bun-native CLI for the MutagenT AI platform - auth, provider config, and lifecycle-tool installer for AI-native workflows",
5
5
  "type": "module",
6
6
  "bin": {