@m8t-stack/cli 0.2.154 → 0.2.156

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/cli.js CHANGED
@@ -1464,7 +1464,7 @@ function installFoundryDnsShim() {
1464
1464
  }
1465
1465
 
1466
1466
  // src/lib/package-version.ts
1467
- var CLI_VERSION = "0.2.154";
1467
+ var CLI_VERSION = "0.2.156";
1468
1468
 
1469
1469
  // src/lib/render-error.ts
1470
1470
  init_errors();
@@ -21435,6 +21435,27 @@ function buildBicepParams(p) {
21435
21435
  hint: "Pass dreamerEnabled=1 to keep Dreamer on, dreamerEnabled=0 to keep it off, or omit it to use the deployment default."
21436
21436
  });
21437
21437
  }
21438
+ if (p.teachingEnabled !== void 0 && p.teachingEnabled !== "0" && p.teachingEnabled !== "1") {
21439
+ throw new LocalCliError({
21440
+ code: "PLATFORM_TEACHING_ENABLED_INVALID",
21441
+ message: `The Teaching gate must be '0' or '1', not '${p.teachingEnabled}'.`,
21442
+ hint: "Pass teachingEnabled=1 to keep Teaching on, teachingEnabled=0 to keep it off, or omit it to use the deployment default."
21443
+ });
21444
+ }
21445
+ if (p.teachingModel !== void 0 && !p.teachingModel.trim()) {
21446
+ throw new LocalCliError({
21447
+ code: "PLATFORM_TEACHING_MODEL_REQUIRED",
21448
+ message: "The Teaching model must be non-empty when provided.",
21449
+ hint: "Pass the existing Foundry deployment name, or omit teachingModel only when the Bicep default is intended."
21450
+ });
21451
+ }
21452
+ if (p.teachingRetentionDays !== void 0 && (!Number.isInteger(p.teachingRetentionDays) || p.teachingRetentionDays < 1 || p.teachingRetentionDays > 30)) {
21453
+ throw new LocalCliError({
21454
+ code: "PLATFORM_TEACHING_RETENTION_INVALID",
21455
+ message: `Teaching retention days must be an integer between 1 and 30, not '${String(p.teachingRetentionDays)}'.`,
21456
+ hint: "Pass the exact live M8T_TEACHING_RETENTION_DAYS value after verifying it is within 1\u201330."
21457
+ });
21458
+ }
21438
21459
  if (p.brainCodifyModel !== void 0 && !p.brainCodifyModel.trim()) {
21439
21460
  throw new LocalCliError({
21440
21461
  code: "PLATFORM_CODIFY_MODEL_REQUIRED",
@@ -21483,6 +21504,10 @@ function buildBicepParams(p) {
21483
21504
  if (p.brainCodifyModel !== void 0) params.push(`brainCodifyModel=${p.brainCodifyModel}`);
21484
21505
  if (p.brainCodifyEvalModel !== void 0) params.push(`brainCodifyEvalModel=${p.brainCodifyEvalModel}`);
21485
21506
  if (p.dreamerEnabled !== void 0) params.push(`dreamerEnabled=${p.dreamerEnabled}`);
21507
+ if (p.teachingEnabled !== void 0) params.push(`teachingEnabled=${p.teachingEnabled}`);
21508
+ if (p.teachingModel !== void 0) params.push(`teachingModel=${p.teachingModel}`);
21509
+ if (p.teachingServiceAppIds !== void 0) params.push(`teachingServiceAppIds=${p.teachingServiceAppIds}`);
21510
+ if (p.teachingRetentionDays !== void 0) params.push(`teachingRetentionDays=${p.teachingRetentionDays.toString()}`);
21486
21511
  if (p.voiceInternalSecret) params.push(`voiceInternalSecret=${p.voiceInternalSecret}`);
21487
21512
  if (p.gatewayCpu) params.push(`gatewayCpu=${p.gatewayCpu}`);
21488
21513
  if (p.gatewayMemory) params.push(`gatewayMemory=${p.gatewayMemory}`);
@@ -21865,18 +21890,28 @@ function legacyGatewayTopologyError(live, gatewayResourceId, expectedSubscriptio
21865
21890
  }
21866
21891
  return null;
21867
21892
  }
21893
+ function errorDetail(error) {
21894
+ return error instanceof Error ? error.message : String(error);
21895
+ }
21896
+ function isTransientGatewayReadFailure(error) {
21897
+ const detail = errorDetail(error);
21898
+ if (/AUTH_NOT_SIGNED_IN|AZ_NOT_INSTALLED|AuthorizationFailed|Unauthorized|Forbidden|InvalidAuthentication|InvalidSubscription|not logged in|please run.*az login/i.test(detail)) {
21899
+ return false;
21900
+ }
21901
+ return /TooManyRequests|ServiceUnavailable|InternalServerError|OperationCanceled|Conflict|ResourceNotFound|temporar|timed? ?out|status(?: code)?\s*[:=]?\s*(?:408|409|429|500|502|503|504)|\b(?:408|409|429|500|502|503|504)\b/i.test(detail);
21902
+ }
21868
21903
  async function readLiveGatewayDeployment(gatewayResourceId) {
21869
21904
  const { subscriptionId, resourceGroup, name } = parseContainerAppResourceId(gatewayResourceId);
21870
21905
  let raw;
21871
21906
  try {
21872
21907
  raw = await runAz(["containerapp", "show", "--subscription", subscriptionId, "-g", resourceGroup, "-n", name, "-o", "json"]);
21873
21908
  } catch (e) {
21874
- throw new LocalCliError({ code: "PLATFORM_GATEWAY_UNREADABLE", message: `Could not read gateway '${name}'.`, cause: e });
21909
+ throw new LocalCliError({ code: "PLATFORM_GATEWAY_UNREADABLE", message: `Could not read gateway '${name}': ${errorDetail(e)}`, cause: e });
21875
21910
  }
21876
21911
  try {
21877
21912
  return parseLiveGatewayDeployment(JSON.parse(raw));
21878
21913
  } catch (e) {
21879
- throw new LocalCliError({ code: "PLATFORM_GATEWAY_UNREADABLE", message: `Gateway '${name}' returned invalid JSON.`, cause: e });
21914
+ throw new LocalCliError({ code: "PLATFORM_GATEWAY_UNREADABLE", message: `Gateway '${name}' returned invalid JSON: ${errorDetail(e)}`, cause: e });
21880
21915
  }
21881
21916
  }
21882
21917
  async function resolveLegacyAcrDigest(live, subscriptionId) {
@@ -21973,13 +22008,24 @@ async function waitForAdoptedGatewayReady(args) {
21973
22008
  const attempts = args.pollAttempts ?? ACA_READINESS_OBSERVATIONS;
21974
22009
  const delayMs = args.pollDelayMs ?? ACA_READINESS_POLL_DELAY_MS;
21975
22010
  const sleep4 = args.sleep ?? ((ms) => new Promise((resolve6) => setTimeout(resolve6, ms)));
22011
+ let lastTransientReadError;
21976
22012
  for (let n = 0; n < attempts; n += 1) {
21977
- const live = await readLiveGatewayDeployment(args.gatewayResourceId);
22013
+ let live;
22014
+ try {
22015
+ live = await readLiveGatewayDeployment(args.gatewayResourceId);
22016
+ lastTransientReadError = void 0;
22017
+ } catch (error) {
22018
+ if (!isTransientGatewayReadFailure(error)) throw error;
22019
+ lastTransientReadError = error instanceof Error ? error : new Error(errorDetail(error));
22020
+ if (n + 1 < attempts) await sleep4(delayMs);
22021
+ continue;
22022
+ }
21978
22023
  const digest = await assertRecordedAdoptionState(live, args.adoption, args.subscriptionId, args.acrName);
21979
22024
  if (/^(failed|canceled)$/i.test(live.provisioningState)) return false;
21980
22025
  if (live.image === args.expectedImage && digest === args.expectedDigest && live.provisioningState === "Succeeded" && live.latestRevisionName !== "" && live.latestRevisionName === live.latestReadyRevisionName) return true;
21981
22026
  if (n + 1 < attempts) await sleep4(delayMs);
21982
22027
  }
22028
+ if (lastTransientReadError) throw lastTransientReadError;
21983
22029
  return false;
21984
22030
  }
21985
22031
  async function restorePendingAdoptedGateway(args) {
@@ -22594,7 +22640,11 @@ async function resolveBicepParamsForConverge(ctx, opts = {}) {
22594
22640
  ...opts.brainCodifyWorkflowRef !== void 0 ? { brainCodifyWorkflowRef: opts.brainCodifyWorkflowRef } : {},
22595
22641
  ...opts.brainCodifyModel !== void 0 ? { brainCodifyModel: opts.brainCodifyModel } : {},
22596
22642
  ...opts.brainCodifyEvalModel !== void 0 ? { brainCodifyEvalModel: opts.brainCodifyEvalModel } : {},
22597
- ...opts.dreamerEnabled !== void 0 ? { dreamerEnabled: opts.dreamerEnabled } : {}
22643
+ ...opts.dreamerEnabled !== void 0 ? { dreamerEnabled: opts.dreamerEnabled } : {},
22644
+ ...opts.teachingEnabled !== void 0 ? { teachingEnabled: opts.teachingEnabled } : {},
22645
+ ...opts.teachingModel !== void 0 ? { teachingModel: opts.teachingModel } : {},
22646
+ ...opts.teachingServiceAppIds !== void 0 ? { teachingServiceAppIds: opts.teachingServiceAppIds } : {},
22647
+ ...opts.teachingRetentionDays !== void 0 ? { teachingRetentionDays: opts.teachingRetentionDays } : {}
22598
22648
  };
22599
22649
  }
22600
22650
  function swapHostedImage(def, newImage) {
@@ -23478,6 +23528,7 @@ async function buildConvergeDeps(args) {
23478
23528
  }
23479
23529
  const loaderPath = path31.join(args.contentDir, "targets/foundry/brain-loader.md");
23480
23530
  return {
23531
+ resolveAgentName: (personaName) => discovered[personaName],
23481
23532
  async applyPersona(a, ctx) {
23482
23533
  const personaName = a.personaName;
23483
23534
  if (!personaName) {
@@ -23614,6 +23665,10 @@ async function buildConvergeDeps(args) {
23614
23665
  ...stamped.brainCodifyModel !== void 0 ? { brainCodifyModel: stamped.brainCodifyModel } : {},
23615
23666
  ...stamped.brainCodifyEvalModel !== void 0 ? { brainCodifyEvalModel: stamped.brainCodifyEvalModel } : {},
23616
23667
  ...stamped.dreamerEnabled !== void 0 ? { dreamerEnabled: stamped.dreamerEnabled } : {},
23668
+ ...stamped.teachingEnabled !== void 0 ? { teachingEnabled: stamped.teachingEnabled } : {},
23669
+ ...stamped.teachingModel !== void 0 ? { teachingModel: stamped.teachingModel } : {},
23670
+ ...stamped.teachingServiceAppIds !== void 0 ? { teachingServiceAppIds: stamped.teachingServiceAppIds } : {},
23671
+ ...stamped.teachingRetentionDays !== void 0 ? { teachingRetentionDays: stamped.teachingRetentionDays } : {},
23617
23672
  ...stamped.location ? { location: stamped.location } : {},
23618
23673
  ...voiceInternalSecret ? { voiceInternalSecret } : {}
23619
23674
  };
@@ -24104,7 +24159,14 @@ async function runGate(args, applied, budgetMs) {
24104
24159
  if (!args.gatewayUrl) continue;
24105
24160
  outcomes.push(await probeGateway(args.gatewayUrl, t.expected));
24106
24161
  } else {
24107
- const agentName = "persona" in t ? t.persona : hostedAgentName(t.component);
24162
+ let agentName;
24163
+ if ("persona" in t) {
24164
+ const resolved = args.deps.resolveAgentName?.(t.persona);
24165
+ if (args.deps.resolveAgentName && !resolved) continue;
24166
+ agentName = resolved ?? t.persona;
24167
+ } else {
24168
+ agentName = hostedAgentName(t.component);
24169
+ }
24108
24170
  outcomes.push(await probeAgent({ credential: args.credential, endpoint: args.endpoint, agentName }));
24109
24171
  }
24110
24172
  }
@@ -25596,6 +25658,18 @@ var PlatformEnableAutoUpdateCommand = class extends M8tCommand {
25596
25658
  dreamerEnabled = Option42.String("--dreamer-enabled", {
25597
25659
  description: "0 | 1. Persist the Dreamer scheduler posture across future converges. Omit to preserve the stamped value."
25598
25660
  });
25661
+ teachingEnabled = Option42.String("--teaching-enabled", {
25662
+ description: "0 | 1. Persist the Teaching gate across future converges. Omit to preserve the stamped value."
25663
+ });
25664
+ teachingModel = Option42.String("--teaching-model", {
25665
+ description: "Foundry deployment used by Teaching proposal jobs. Omit to preserve the stamped value."
25666
+ });
25667
+ teachingServiceAppIds = Option42.String("--teaching-service-app-ids", {
25668
+ description: "Comma-separated verified service app IDs allowed to call Teaching routes. Omit to preserve the stamped value; pass an empty string to clear it."
25669
+ });
25670
+ teachingRetentionDays = Option42.String("--teaching-retention-days", {
25671
+ description: "Teaching retention in days (1\u201330). Omit to preserve the stamped value."
25672
+ });
25599
25673
  endpoint = Option42.String("--endpoint", {
25600
25674
  description: "Foundry project endpoint URL. Disambiguates the project in a multi-project subscription."
25601
25675
  });
@@ -25706,6 +25780,9 @@ var PlatformEnableAutoUpdateCommand = class extends M8tCommand {
25706
25780
  // independently selected model deployments on an unrelated converge.
25707
25781
  // dreamerEnabled — dropping it re-applied the template's "0" default and
25708
25782
  // silently stopped a scheduler the founder had explicitly enabled.
25783
+ // teaching* — dropping any of the four durable Teaching values could
25784
+ // disable the gate, change the model/allowlist/retention policy, and
25785
+ // then replace the row with those defaults on an unrelated converge.
25709
25786
  //
25710
25787
  // The stamped value is re-validated rather than cast: the row is typed
25711
25788
  // `string` and JSON-parsed unchecked, so a bad value would otherwise reach
@@ -25760,6 +25837,23 @@ var PlatformEnableAutoUpdateCommand = class extends M8tCommand {
25760
25837
  ...(() => {
25761
25838
  const value = this.dreamerEnabled ?? stampedParams?.bicep.dreamerEnabled;
25762
25839
  return value !== void 0 ? { dreamerEnabled: value } : {};
25840
+ })(),
25841
+ ...(() => {
25842
+ const value = this.teachingEnabled ?? stampedParams?.bicep.teachingEnabled;
25843
+ return value !== void 0 ? { teachingEnabled: value } : {};
25844
+ })(),
25845
+ ...(() => {
25846
+ const value = this.teachingModel ?? stampedParams?.bicep.teachingModel;
25847
+ return value !== void 0 ? { teachingModel: value } : {};
25848
+ })(),
25849
+ ...(() => {
25850
+ const value = this.teachingServiceAppIds ?? stampedParams?.bicep.teachingServiceAppIds;
25851
+ return value !== void 0 ? { teachingServiceAppIds: value } : {};
25852
+ })(),
25853
+ ...(() => {
25854
+ const explicit = this.teachingRetentionDays;
25855
+ const value = explicit !== void 0 ? Number(explicit) : stampedParams?.bicep.teachingRetentionDays;
25856
+ return value !== void 0 ? { teachingRetentionDays: value } : {};
25763
25857
  })()
25764
25858
  };
25765
25859
  if (recoveredParams.brainCodifyModel && recoveredParams.brainCodifyEvalModel && recoveredParams.brainCodifyModel === recoveredParams.brainCodifyEvalModel) {