@work-shape/catalyst-cli 0.8.0-rc.34 → 0.8.0-rc.36

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/index.js CHANGED
@@ -639,6 +639,7 @@ var KNOWLEDGE_EMBEDDING_STATES = [
639
639
  ];
640
640
  var KNOWLEDGE_DOCUMENT_STATES = ["pending", "indexed", "failed"];
641
641
  var KNOWLEDGE_FILE_MAX_BYTES = 25 * 1024 * 1024;
642
+ var KNOWLEDGE_FILE_MAX_BYTES_CEILING = 256 * 1024 * 1024;
642
643
  var KNOWLEDGE_DOCUMENT_FAILURE_CODES = [
643
644
  // The extractor does not read the file's format.
644
645
  "knowledge_file_format_unsupported",
@@ -1431,17 +1432,27 @@ var knowledgeIngestOutputSchema = operationBatchResultSchema.extend({
1431
1432
  });
1432
1433
  var knowledgeWithdrawInputSchema = z3.strictObject({ itemIds: z3.array(id).min(1) });
1433
1434
  var knowledgeWithdrawOutputSchema = z3.strictObject({ withdrawn: count });
1435
+ var KNOWLEDGE_PENDING_MAX_LIMIT = 1e3;
1434
1436
  var knowledgePendingInputSchema = z3.strictObject({
1435
1437
  type: id.optional(),
1438
+ /** Only documents whose `changedAt` is after this time. */
1436
1439
  since: z3.iso.datetime({ offset: true }).optional(),
1437
- limit: z3.number().int().positive()
1440
+ limit: z3.number().int().positive().max(KNOWLEDGE_PENDING_MAX_LIMIT)
1438
1441
  });
1439
1442
  var knowledgePendingRowSchema = z3.strictObject({
1440
1443
  id,
1441
1444
  type: id,
1442
1445
  contentHash: hash,
1446
+ source: z3.string().min(1).nullable(),
1447
+ path: z3.string().startsWith("/"),
1448
+ name: z3.string().min(1),
1449
+ changedAt: z3.iso.datetime({ offset: true }),
1443
1450
  pages: workflowDatasetReferenceSchema
1444
1451
  });
1452
+ var knowledgePendingPageRowSchema = z3.strictObject({
1453
+ page: z3.number().int().positive(),
1454
+ text: z3.string()
1455
+ });
1445
1456
  var knowledgePendingOutputSchema = z3.strictObject({
1446
1457
  documents: workflowDatasetReferenceSchema
1447
1458
  });
@@ -2838,7 +2849,7 @@ import { z as z68 } from "zod";
2838
2849
  // ../api-contract/package.json
2839
2850
  var package_default = {
2840
2851
  name: "@work-shape/catalyst-api-contract",
2841
- version: "0.8.0-rc.34",
2852
+ version: "0.8.0-rc.36",
2842
2853
  license: "MIT",
2843
2854
  repository: {
2844
2855
  type: "git",
@@ -3819,7 +3830,9 @@ var safeConfigSchema = z25.object({
3819
3830
  modelCallsPerDay: z25.number().optional(),
3820
3831
  tokensPerDay: z25.number().optional(),
3821
3832
  tokensPerMonth: z25.number().optional()
3822
- })
3833
+ }),
3834
+ /** The context indicator shows what the conversation has cost so far (LU-7). Absent before. */
3835
+ showConversationCost: z25.boolean().optional()
3823
3836
  }),
3824
3837
  /** What a generated view may load besides the instance's own view runtime. */
3825
3838
  views: z25.object({ allowedScriptSrc: z25.array(z25.string()) }).default(() => ({ allowedScriptSrc: [] })),
@@ -3841,6 +3854,11 @@ var safeConfigSchema = z25.object({
3841
3854
  * one made in the interface then starts with `[semantic, keyword]`, else with `[keyword]`.
3842
3855
  */
3843
3856
  knowledge: z25.object({ semanticSearch: z25.boolean() }).optional(),
3857
+ /**
3858
+ * Speech to text in the composer (STT-1): on where release config has a transcription
3859
+ * binding. Absent in the answer of an API from before it; the interface reads that as off.
3860
+ */
3861
+ transcription: z25.object({ enabled: z25.boolean() }).optional(),
3844
3862
  /** Derived from `modules` for one transition release. */
3845
3863
  features: z25.object({
3846
3864
  attachments: z25.object({
@@ -4266,6 +4284,13 @@ var ownUsageSchema = z28.object({
4266
4284
  /** The instance; amounts only for admins. */
4267
4285
  instance: usageSpendLevelSchema
4268
4286
  });
4287
+ var conversationCostSchema = z28.object({
4288
+ scope: z28.enum(["own", "conversation"]),
4289
+ shared: z28.boolean(),
4290
+ currency: z28.string().optional(),
4291
+ costMicros: z28.number(),
4292
+ complete: z28.boolean()
4293
+ });
4269
4294
  var ownUsageQuerySchema = z28.object({
4270
4295
  workspaceId: z28.string().trim().min(1).max(200).optional()
4271
4296
  });
@@ -4769,6 +4794,14 @@ var assetSchema = z30.object({
4769
4794
  availability: agentAvailabilitySchema.optional(),
4770
4795
  dependencyAvailability: dependencyAvailabilitySchema.optional(),
4771
4796
  canSetAvailability: z30.boolean().optional(),
4797
+ /**
4798
+ * Only on skill reads, for a caller who may delete the skill: the agents it may read that
4799
+ * list it, in their draft, their live revision or their pending shared draft, sorted by name.
4800
+ * Its delete is refused while any agent does (SKILL-DEL-1). Absent where none does.
4801
+ */
4802
+ listedBy: z30.array(z30.object({ name: z30.string(), title: z30.string() })).optional(),
4803
+ /** Of those agents, how many the caller may not read: counted, never named. */
4804
+ listedByUnread: z30.number().int().positive().optional(),
4772
4805
  /** Only on agent reads: who uses the agent where it is available (AGENT-USE-1). */
4773
4806
  agentUse: agentUseSchema.optional(),
4774
4807
  /** Only on agent reads. The stored config stays intact; these references cannot run. */
@@ -6583,6 +6616,16 @@ var cancelRunRequestSchema = z33.object({
6583
6616
  var cancelRunResponseSchema = z33.object({
6584
6617
  run: agentRunSchema
6585
6618
  });
6619
+ var transcriptionQuerySchema = z33.object({
6620
+ language: z33.string().regex(/^[a-z]{2,3}$/u).optional(),
6621
+ conversationId: z33.string().min(1).optional(),
6622
+ projectId: z33.string().min(1).optional(),
6623
+ workspaceId: z33.string().min(1).optional()
6624
+ });
6625
+ var transcriptionResponseSchema = z33.object({
6626
+ text: z33.string(),
6627
+ durationSeconds: z33.number().nonnegative()
6628
+ });
6586
6629
 
6587
6630
  // ../api-contract/src/agent-proposals.ts
6588
6631
  var revisionNumberSchema2 = z34.number().int().positive();
@@ -8197,7 +8240,9 @@ var memberBundleSchema = z39.object({
8197
8240
  */
8198
8241
  change: z39.enum(MEMBER_BUNDLE_CHANGES).optional(),
8199
8242
  /** The pending request, while one is open. */
8200
- requestId: z39.string().optional()
8243
+ requestId: z39.string().optional(),
8244
+ /** For `inherited`: the roles that give it, where roles alone do. */
8245
+ coveredBy: z39.array(accessOriginRoleSchema).optional()
8201
8246
  });
8202
8247
  var workspaceMemberBundlesSchema = z39.object({
8203
8248
  userId: z39.string(),
@@ -10650,6 +10695,20 @@ var conversationOperations = {
10650
10695
  errors: ["NOT_FOUND"],
10651
10696
  rateClass: "read"
10652
10697
  }),
10698
+ "conversations.cost.get": defineOperation({
10699
+ id: "conversations.cost.get",
10700
+ method: "GET",
10701
+ path: "/api/v1/conversations/:conversationId/cost",
10702
+ summary: "Read the settled cost of a conversation so far: the caller's own calls, or the whole chat for a holder of usage.view in a chat more people read",
10703
+ tag: "Conversations",
10704
+ auth: "user",
10705
+ scope: "conversation:read",
10706
+ requires: [],
10707
+ effect: "reading",
10708
+ response: json(conversationCostSchema),
10709
+ errors: ["NOT_FOUND"],
10710
+ rateClass: "read"
10711
+ }),
10653
10712
  "conversations.structured_data.get": defineOperation({
10654
10713
  id: "conversations.structured_data.get",
10655
10714
  method: "GET",
@@ -10745,6 +10804,24 @@ var conversationOperations = {
10745
10804
  errors: ["NOT_FOUND", "CONFLICT", "GUARDRAIL_BLOCKED"],
10746
10805
  rateClass: "write"
10747
10806
  }),
10807
+ "transcriptions.create": defineOperation({
10808
+ id: "transcriptions.create",
10809
+ method: "POST",
10810
+ path: "/api/v1/transcriptions",
10811
+ summary: "Turn a recording from the composer into text, which is not stored",
10812
+ tag: "Conversations",
10813
+ auth: "user",
10814
+ scope: "conversation:write",
10815
+ requires: [],
10816
+ // It changes nothing: the recording and its text are not stored. The provider call is
10817
+ // metered as every model call is.
10818
+ effect: "reading",
10819
+ multipart: true,
10820
+ query: transcriptionQuerySchema,
10821
+ response: json(transcriptionResponseSchema),
10822
+ errors: ["NOT_FOUND", "TIMEOUT"],
10823
+ rateClass: "write"
10824
+ }),
10748
10825
  "conversations.runs.create": defineOperation({
10749
10826
  id: "conversations.runs.create",
10750
10827
  method: "POST",
@@ -11465,7 +11542,7 @@ var shippedGuardrailSchema = z52.object({
11465
11542
  * admin set it to ask on every publish. Absent on a guardrail without that setting.
11466
11543
  */
11467
11544
  alwaysAsk: z52.boolean().optional(),
11468
- /** Who switched it last and when. Absent while nobody has: it is on as the release ships it. */
11545
+ /** Who switched it last and when. Absent while nobody has: it is as the release ships it. */
11469
11546
  switchedBy: z52.object({ id: z52.string(), label: z52.string() }).optional(),
11470
11547
  switchedAt: timestampSchema.optional(),
11471
11548
  /** The caller holds `guardrail.publish` at instance scope and may switch it. */
@@ -11932,6 +12009,11 @@ var knowledgeStateResponseSchema = z57.object({
11932
12009
  * `markdown`, with document processing also `pdf`, `docx`, `xlsx` and `pptx`. Omitted for a structured one.
11933
12010
  */
11934
12011
  documentFormats: z57.array(z57.string()).optional(),
12012
+ /**
12013
+ * The largest file in bytes such a Knowledge Base takes on this instance, as
12014
+ * `knowledge.maxFileBytes` sets it. Omitted for a structured one.
12015
+ */
12016
+ maxFileBytes: z57.number().int().optional(),
11935
12017
  /** The id of the Knowledge Base's asset. */
11936
12018
  id: z57.string(),
11937
12019
  /** The id operations and routes name the Knowledge Base by. */
@@ -12070,6 +12152,11 @@ var knowledgeSearchResponseSchema = z57.object({
12070
12152
  /** Reciprocal rank fusion of the lists in `signals`: compare it only within one Knowledge Base. */
12071
12153
  score: z57.number(),
12072
12154
  originLink: z57.string().optional(),
12155
+ /**
12156
+ * The path of a synced or Workflow-fed document below its source's boundary, folders and
12157
+ * file name, such as `/Projekte/Nord/Angebot.pdf`. None for a file added by hand.
12158
+ */
12159
+ path: z57.string().optional(),
12073
12160
  /**
12074
12161
  * The date a synced document states of its own version, such as the "Stand" of a web
12075
12162
  * page. An ISO date-time in UTC; none where the document states no date.
@@ -12580,7 +12667,11 @@ var connectCodeSchema = z59.object({
12580
12667
  var confirmConnectCodeRequestSchema = keyFieldsSchema;
12581
12668
 
12582
12669
  // ../api-contract/src/operations/personal-api-keys.ts
12583
- var confirmedConnectCodeSchema = z60.object({ confirmed: z60.literal(true) });
12670
+ var confirmedConnectCodeSchema = z60.object({
12671
+ confirmed: z60.literal(true),
12672
+ scopes: z60.array(z60.string()).optional(),
12673
+ leftOutScopes: z60.array(z60.string()).optional()
12674
+ });
12584
12675
  var personalApiKeyOperations = {
12585
12676
  "me.api_keys.list": defineOperation({
12586
12677
  id: "me.api_keys.list",
@@ -16860,10 +16951,18 @@ ${error.issues.map((issue) => `- ${issue.file}${issue.path ? ` (${issue.path})`
16860
16951
  if (error.status === 404 && reason === UNKNOWN_OPERATION_REASON) {
16861
16952
  return "This instance does not serve the asset operations this CLI uses. Upgrade the instance, or use the CLI of its release.";
16862
16953
  }
16863
- return `${error.code ? `${error.code}: ` : ""}${error.message}`;
16954
+ const hint = keyScopeHint(error);
16955
+ return `${error.code ? `${error.code}: ` : ""}${error.message}${hint ? `
16956
+ ${hint}` : ""}`;
16864
16957
  }
16865
16958
  return error instanceof Error ? error.message : String(error);
16866
16959
  }
16960
+ function keyScopeHint(error) {
16961
+ const details = isRecord(error.details) ? error.details : void 0;
16962
+ if (error.status !== 403 || details?.reason !== "outside_key_scope") return void 0;
16963
+ const right = typeof details.action === "string" ? ` '${details.action}'` : "";
16964
+ return `Your account holds the right${right}, but this API key does not carry it: a key carries only the rights ticked when it was issued, so a right you were given after that is missing from it. Run 'catalyst login' and confirm a new key with the right ticked; it replaces the saved key. Where CATALYST_API_KEY is set, create a new key in Settings > API keys and set that instead.`;
16965
+ }
16867
16966
  function writeOutput(options, text2) {
16868
16967
  (options.stdout ?? ((value) => process.stdout.write(value)))(`${text2}
16869
16968
  `);
@@ -17102,33 +17201,6 @@ import { parseArgs as parseArgs2 } from "util";
17102
17201
  import { resolve as resolve5 } from "path";
17103
17202
  import yaml6 from "js-yaml";
17104
17203
 
17105
- // src/publish-file-changes.ts
17106
- function publishFileChanges(next, live) {
17107
- const after = filesOf(next);
17108
- const before = filesOf(live);
17109
- return [.../* @__PURE__ */ new Set([...after.keys(), ...before.keys()])].sort().flatMap((path) => {
17110
- if (after.get(path) === before.get(path)) return [];
17111
- return [`${path} (${!before.has(path) ? "added" : !after.has(path) ? "removed" : "changed"})`];
17112
- });
17113
- }
17114
- function filesOf(asset) {
17115
- if (asset?.files) return new Map(asset.files.map((file) => [file.path, file.sha256]));
17116
- const result = /* @__PURE__ */ new Map();
17117
- const config = asset?.config;
17118
- if (!isRecord(config)) return result;
17119
- if (Array.isArray(config.files)) {
17120
- for (const file of config.files) {
17121
- if (isRecord(file) && typeof file.path === "string" && typeof file.content === "string") {
17122
- result.set(file.path, file.content);
17123
- }
17124
- }
17125
- }
17126
- if (asset?.kind === "workflow" && config.manifest !== void 0) {
17127
- result.set("workflow.yaml", JSON.stringify(config.manifest));
17128
- }
17129
- return result;
17130
- }
17131
-
17132
17204
  // src/app-publish-data.ts
17133
17205
  async function appPublishData(api, app, candidate, audienceLabel) {
17134
17206
  const config = candidate.config;
@@ -17462,7 +17534,8 @@ function formatWarnings(warnings) {
17462
17534
  }
17463
17535
  function formatRefusal(error) {
17464
17536
  const head = `Refused by the instance (HTTP ${error.status}${error.code ? ` ${error.code}` : ""}): ${error.message}`;
17465
- return [head, ...detailLines(error.details)].join("\n");
17537
+ const hint = keyScopeHint(error);
17538
+ return [head, ...detailLines(error.details), ...hint ? [hint] : []].join("\n");
17466
17539
  }
17467
17540
  function detailLines(details) {
17468
17541
  if (!isRecord(details)) return [];
@@ -17527,28 +17600,6 @@ function formatDryRun(name2, answer) {
17527
17600
  }
17528
17601
 
17529
17602
  // src/publish-question.ts
17530
- async function askBeforePublish(options, publish2) {
17531
- const { kind, command, name: name2, revision } = publish2;
17532
- if (publish2.yes) return "unattended";
17533
- if (!options.prompt) {
17534
- writeError(
17535
- options,
17536
- `Publishing ${/^[aeiou]/u.test(kind) ? "an" : "a"} ${kind} needs your answer here, so a run without a terminal to ask publishes nothing. Run 'catalyst ${command} publish ${name2} --revision ${revision}' in a terminal and answer its question, add --yes to confirm it in your Inbox, or publish it in the interface.`
17537
- );
17538
- return "refused";
17539
- }
17540
- let answer;
17541
- do {
17542
- answer = await options.prompt(
17543
- `Publish revision ${revision} of ${kind} '${name2}'? If approval is required, this files a request in the Inbox. ${publish2.details ? "[y/N; d=Details]" : "[y/N]"} `
17544
- );
17545
- if (/^d(?:etails)?$/iu.test(answer.trim()) && publish2.details) await publish2.details();
17546
- else break;
17547
- } while (true);
17548
- if (/^y(?:es)?$/iu.test(answer.trim())) return "answered";
17549
- writeError(options, "Nothing was published.");
17550
- return "refused";
17551
- }
17552
17603
  var OVERTAKEN_LINE = "If another version goes live before it is decided, this request is settled as superseded: it can do nothing then and never overwrites that version.";
17553
17604
  function isAlreadyLive(error) {
17554
17605
  return error instanceof ConfigApiError && error.status === 409 && isRecord(error.details) && error.details.reason === "already_live";
@@ -17566,7 +17617,8 @@ function waitingPublishLine(run, approvalHint, note) {
17566
17617
  function agentPublishRefusalHint(error) {
17567
17618
  if (!(error instanceof ConfigApiError) || error.status !== 403) return void 0;
17568
17619
  const reason = isRecord(error.details) ? error.details.reason : void 0;
17569
- const keyRefused = reason === "user_only" || reason === "outside_key_scope" || error.message.includes(`'${PUBLISH_SCOPE}'`);
17620
+ if (reason === "outside_key_scope") return void 0;
17621
+ const keyRefused = reason === "user_only" || error.message.includes(`'${PUBLISH_SCOPE}'`);
17570
17622
  return keyRefused ? `This key publishes no agent. A service principal's key, such as the release key of an operated instance, writes agent drafts and publishes none (AP-10); a personal key publishes only with the publish right, scope ${PUBLISH_SCOPE}. Publish the draft with such a personal key or on the agent page.` : "Publishing an agent needs the right agent.publish on it, which an instance admin holds.";
17571
17623
  }
17572
17624
  var PUBLISH_SCOPE = "config_assets:publish";
@@ -17587,7 +17639,7 @@ var APP_VERBS = {
17587
17639
  },
17588
17640
  publish: {
17589
17641
  usage: "publish <app> [--revision <n>] [--audience self|workspace|instance] [--yes]",
17590
- summary: "Choose who may use the App, show what the revision makes live, then ask before publishing it (assets.publish). A publish that hands a source's data to people who may not use the source waits in the Inbox until a person who may change the source approves it"
17642
+ summary: "Choose who may use the App, show what the revision makes live, and publish it at once (assets.publish); --yes changes nothing. A publish that hands a source's data to people who may not use the source waits in the Inbox until a person who may change the source approves it"
17591
17643
  },
17592
17644
  status: {
17593
17645
  usage: "status <app> [dir]",
@@ -17824,14 +17876,13 @@ async function publish(app, values, options) {
17824
17876
  if (values.revision !== void 0) revisionNumber(values.revision);
17825
17877
  const target = await openRepository(options, values, void 0, REPOSITORY_KINDS.app);
17826
17878
  let audience = readAudience(values.audience);
17827
- const get = (revision, files = false) => target.api.read(
17879
+ const get = (revision) => target.api.read(
17828
17880
  (client) => client.assets.get({
17829
17881
  params: { kind: APP_KIND, name: app },
17830
17882
  query: {
17831
17883
  workspaceId: target.workspaceId,
17832
17884
  ...audience ? { audience } : {},
17833
- revision,
17834
- ...files ? { files: "true" } : {}
17885
+ revision
17835
17886
  }
17836
17887
  })
17837
17888
  );
@@ -17883,31 +17934,10 @@ async function publish(app, values, options) {
17883
17934
  const together = number === (candidate.draftRevision ?? candidate.revision) && (startsWorkflows(candidate.config) || dataStoresOf(manifestOf(candidate.config)).length > 0) ? await appPublishTogether(target.api, app) : { workflows: [], dataStores: [], lines: [] };
17884
17935
  const question = [formatReview(app, review), storedData, together.lines.join("\n")].filter(Boolean).join("\n");
17885
17936
  const say = (text2) => values.json ? writeErr(options, text2) : writeOut(options, text2);
17886
- const narrative = values.yes ? void 0 : candidate.publishNarrative;
17937
+ const narrative = candidate.publishNarrative;
17887
17938
  say(
17888
17939
  narrative ? [narrative.summary, ...narrative.warnings, ...together.lines].join("\n") : question
17889
17940
  );
17890
- const answer = await askBeforePublish(options, {
17891
- kind: APP_KIND,
17892
- command: APP_KIND,
17893
- name: app,
17894
- revision: number,
17895
- yes: values.yes,
17896
- ...narrative ? {
17897
- details: async () => {
17898
- const detailed = await get(String(number), true);
17899
- const before = candidate.publishedRevision === void 0 ? void 0 : await get(String(candidate.publishedRevision), true);
17900
- say(
17901
- [
17902
- question,
17903
- ...publishFileChanges(detailed, before),
17904
- ...detailed.filesOmitted || before?.filesOmitted ? ["Some files are omitted from this review."] : []
17905
- ].join("\n")
17906
- );
17907
- }
17908
- } : {}
17909
- });
17910
- if (answer === "refused") return EXIT.refused;
17911
17941
  const outcome = await target.api.change(
17912
17942
  (client, idempotencyKey2) => client.assets.publish({
17913
17943
  params: { kind: APP_KIND, name: app },
@@ -17918,8 +17948,7 @@ async function publish(app, values, options) {
17918
17948
  ...together.workflows.length > 0 ? { workflows: together.workflows } : {},
17919
17949
  ...together.dataStores.length > 0 ? { dataStores: together.dataStores } : {}
17920
17950
  },
17921
- idempotencyKey: idempotencyKey2,
17922
- ...answer === "unattended" ? { unattended: true } : {}
17951
+ idempotencyKey: idempotencyKey2
17923
17952
  }),
17924
17953
  `It may have been applied: run 'catalyst app status ${app}' before sending it again.`
17925
17954
  );
@@ -18277,7 +18306,7 @@ A Workflow as a folder (workflow.yaml at its root, scripts in steps/):
18277
18306
  catalyst workflow pull <workflow> [dir] [--published | --revision <n>] Write a revision into a folder (assets.get)
18278
18307
  catalyst workflow push [dir] Send a changed folder as the next draft, or create the Workflow (assets.put)
18279
18308
  catalyst workflow status <workflow> [dir] Show draft, published revision and local changes
18280
- catalyst workflow publish <workflow> --revision <n> [--yes] Review and ask before publishing (assets.publish)
18309
+ catalyst workflow publish <workflow> --revision <n> Review and publish at once (assets.publish)
18281
18310
  catalyst workflow history <workflow> List revisions (assets.revisions.list)
18282
18311
  catalyst workflow revert <workflow> --to <n> --if-revision <n> Restore a revision (assets.revert)
18283
18312
 
@@ -18293,8 +18322,8 @@ Options:
18293
18322
 
18294
18323
  The instance decides every right and every check, and a refusal is printed as it gave it.
18295
18324
  A write names the revision it was made against: read it with 'show' or 'history'.
18296
- A publish of an App or a Workflow asks you first and needs your answer in a terminal; --yes
18297
- publishes nothing. If you may not approve it yourself, it then waits for an approver.
18325
+ A publish is your own and goes live at once; it asks nothing, and --yes changes nothing. Where
18326
+ a guardrail of the instance asks for an approval, it waits for an approver instead.
18298
18327
  A publish, an availability change or a move that hands a source's data to people who may not
18299
18328
  use the source waits in the Inbox until a person who may change the source approves it. A key
18300
18329
  never confirms that hand-over, whatever rights it holds.
@@ -18306,7 +18335,8 @@ agent asks first and then waits in the Inbox for a holder of agent.approve, and
18306
18335
  publish offers it in its workspace. A workspace's agent made by someone without agent.approve
18307
18336
  starts offered nowhere; 'catalyst agent publish <name> --revision 1' publishes it as made,
18308
18337
  without a draft. A service principal's key publishes no agent. 'catalyst agent discard
18309
- <name> --revision <n>' drops the draft.
18338
+ <name> --revision <n>' drops the draft. 'catalyst agent show <name> --revision draft' prints the
18339
+ draft; --revision published prints the live revision, and a number one of its history.
18310
18340
  A skill has no draft: a put, a push or a revert is live. A skill of the instance or of a Shared
18311
18341
  Workspace asks for skill.publish on a person's account or key with config_assets:publish;
18312
18342
  without it the write files a request a holder of skill.approve decides in the Inbox, says so
@@ -18324,19 +18354,17 @@ import { resolve as resolve6 } from "path";
18324
18354
 
18325
18355
  // src/push-guardrail-preflight.ts
18326
18356
  async function preflightGuardrails(api, input) {
18357
+ const stale = [];
18327
18358
  for (const asset of [...input.puts, ...input.deletes]) {
18328
18359
  const base = input.baseOf(asset.key);
18329
18360
  const current = input.listing.get(asset.key);
18330
18361
  const revision = current?.revision ?? (base === void 0 ? void 0 : (await api.getLatestRevision(asset.kind, asset.name))?.revision);
18331
18362
  if ((revision ?? null) !== (base?.revision ?? null)) {
18332
- writeError(
18333
- input.options,
18334
- `Push refused; nothing was applied. ${asset.key} changed since the last pull. Run 'catalyst config pull --only ${asset.key}'.`
18335
- );
18336
- return false;
18363
+ stale.push({ kind: asset.kind, name: asset.name, currentRevision: revision ?? null });
18337
18364
  }
18338
18365
  }
18339
- for (const asset of input.puts) {
18366
+ const staleKeys = new Set(stale.map((asset) => `${asset.kind}:${asset.name}`));
18367
+ for (const asset of input.puts.filter((put) => !staleKeys.has(put.key))) {
18340
18368
  const checked = await api.read(
18341
18369
  (client) => client.assets.validate({
18342
18370
  params: { kind: asset.kind },
@@ -18352,14 +18380,27 @@ async function preflightGuardrails(api, input) {
18352
18380
  input.options,
18353
18381
  `Validation failed for ${asset.key}: ${checked.issues.length} ${checked.issues.length === 1 ? "issue" : "issues"}${paths.length ? ` (${paths.join(", ")})` : ""}; nothing was applied.`
18354
18382
  );
18355
- return false;
18383
+ return void 0;
18356
18384
  }
18357
18385
  }
18358
- return true;
18386
+ return { stale };
18359
18387
  }
18360
18388
 
18361
18389
  // src/push.ts
18362
18390
  async function pushConfig(options) {
18391
+ const skipped = { conflicts: [], defaultAgent: false };
18392
+ const code = await pushChanges(options, skipped);
18393
+ if (skipped.conflicts.length === 0 && !skipped.defaultAgent) return code;
18394
+ writeError(
18395
+ options,
18396
+ formatPushConflict(skipped.conflicts, skipped.defaultAgent, options, SKIPPED_HEADER)
18397
+ );
18398
+ return code === 0 || code === 3 ? 1 : code;
18399
+ }
18400
+ var SKIPPED_HEADER = "Skipped; these changed on the instance since the last pull and were not written:";
18401
+ async function pushChanges(options, skipped) {
18402
+ const skip = (conflicts) => skipped.conflicts.push(...conflicts);
18403
+ const isSkipped = (key2) => skipped.conflicts.some((conflict) => `${conflict.kind}:${conflict.name}` === key2);
18363
18404
  const workingDir = resolveWorkingDir(options);
18364
18405
  const manifest = await readManifest(workingDir);
18365
18406
  const instance = await resolveInstance(manifest, options);
@@ -18423,7 +18464,7 @@ async function pushConfig(options) {
18423
18464
  }
18424
18465
  const touchedKeys = new Set(touched.map((asset) => asset.key));
18425
18466
  const localKeys = new Set(assetEntries(local).map((asset) => asset.key));
18426
- const deleteAssets = options.prune ? [...listing.values()].filter((asset) => !localKeys.has(asset.key)) : [];
18467
+ const pruned = options.prune ? [...listing.values()].filter((asset) => !localKeys.has(asset.key)) : [];
18427
18468
  const changesDefault = holdsWholeInstance(instance) && selectors.length === 0 && (bundle.defaultAgentName ?? null) !== baseline.defaultAgentName;
18428
18469
  if (changesDefault && baseline.defaultAgentName === void 0) {
18429
18470
  throw new Error(
@@ -18440,24 +18481,14 @@ async function pushConfig(options) {
18440
18481
  touched.filter((asset) => asset.kind === "guardrail").map((asset) => asset.key)
18441
18482
  )
18442
18483
  );
18443
- if (!touched.length && !deleteAssets.length && !changesDefault) {
18484
+ if (!touched.length && !pruned.length && !changesDefault) {
18444
18485
  writeOutput(options, "No local changes to push.");
18445
18486
  return 0;
18446
18487
  }
18447
- const unseen = deleteAssets.filter((asset) => baselineAssets[asset.key] === void 0);
18448
- if (unseen.length > 0) {
18449
- writeError(
18450
- options,
18451
- formatPushConflict(
18452
- unseen.map((asset) => ({ ...asset, currentRevision: asset.revision })),
18453
- false,
18454
- options
18455
- )
18456
- );
18457
- return 1;
18458
- }
18459
- const written = [...touched, ...deleteAssets];
18460
- const foreign = written.flatMap((asset) => {
18488
+ skip(
18489
+ pruned.filter((asset) => baselineAssets[asset.key] === void 0).map((asset) => ({ kind: asset.kind, name: asset.name, currentRevision: asset.revision }))
18490
+ );
18491
+ const foreign = [...touched, ...pruned].flatMap((asset) => {
18461
18492
  const base = baseOf(asset.key);
18462
18493
  if (base === void 0) return [];
18463
18494
  const address = { kind: asset.kind, name: asset.name };
@@ -18465,16 +18496,25 @@ async function pushConfig(options) {
18465
18496
  const remote = listing.get(asset.key);
18466
18497
  return remote !== void 0 && remote.id !== base.id ? [{ ...address, baseline: "replaced" }] : [];
18467
18498
  });
18468
- if (foreign.length > 0) {
18469
- writeError(options, formatPushConflict(foreign, false, options));
18470
- return 1;
18471
- }
18499
+ skip(foreign);
18472
18500
  const isGuardrail = (asset) => asset.kind === "guardrail";
18473
- const fileSkills = touched.flatMap(
18501
+ const guardrailCheck = await preflightGuardrails(api, {
18502
+ puts: touched.filter((asset) => isGuardrail(asset) && !isSkipped(asset.key)),
18503
+ deletes: pruned.filter((asset) => isGuardrail(asset) && !isSkipped(asset.key)),
18504
+ listing,
18505
+ baseOf,
18506
+ ...instance.workspace === void 0 ? {} : { workspaceId: instance.workspace },
18507
+ options
18508
+ });
18509
+ if (guardrailCheck === void 0) return 1;
18510
+ skip(await describeStale(api, guardrailCheck.stale));
18511
+ const writable = touched.filter((asset) => !isSkipped(asset.key));
18512
+ const deleteAssets = pruned.filter((asset) => !isSkipped(asset.key));
18513
+ const fileSkillCandidates = writable.flatMap(
18474
18514
  (asset) => asset.kind === "skill" && asset.folderFiles !== void 0 && JSON.stringify(extraHashes(folderHashes(asset.folderFiles))) !== JSON.stringify(extraHashes(baselineAssets[asset.key]?.files)) ? [{ ...asset, folderFiles: asset.folderFiles }] : []
18475
18515
  );
18476
- const fileSkillKeys = new Set(fileSkills.map((asset) => asset.key));
18477
- const syncTouched = touched.filter(
18516
+ const fileSkillKeys = new Set(fileSkillCandidates.map((asset) => asset.key));
18517
+ const syncTouched = writable.filter(
18478
18518
  (asset) => !isGuardrail(asset) && !fileSkillKeys.has(asset.key)
18479
18519
  );
18480
18520
  const syncDeletes = deleteAssets.filter((asset) => !isGuardrail(asset));
@@ -18513,30 +18553,20 @@ async function pushConfig(options) {
18513
18553
  `This push changes ${items.length} assets, and one push holds at most ${ASSET_RELEASE_SYNC_MAX_ITEMS}. Push in parts with --only.`
18514
18554
  );
18515
18555
  }
18516
- if (!await preflightGuardrails(api, {
18517
- puts: touched.filter(isGuardrail),
18518
- deletes: deleteAssets.filter(isGuardrail),
18519
- listing,
18520
- baseOf,
18521
- ...instance.workspace === void 0 ? {} : { workspaceId: instance.workspace },
18522
- options
18523
- }))
18524
- return 1;
18525
- for (const asset of fileSkills) {
18556
+ const fileSkills = [];
18557
+ for (const asset of fileSkillCandidates) {
18526
18558
  const current = listing.get(asset.key);
18527
18559
  const base = baseOf(asset.key);
18528
18560
  const revision = current?.revision ?? (base === void 0 ? void 0 : (await api.getLatestRevision("skill", asset.name))?.revision);
18529
18561
  if ((revision ?? null) !== (base?.revision ?? null)) {
18530
- writeError(
18531
- options,
18532
- formatPushConflict(
18533
- [{ kind: "skill", name: asset.name, currentRevision: current?.revision ?? null }],
18534
- false,
18535
- options
18536
- )
18562
+ skip(
18563
+ await describeStale(api, [
18564
+ { kind: "skill", name: asset.name, currentRevision: revision ?? null }
18565
+ ])
18537
18566
  );
18538
- return 1;
18567
+ continue;
18539
18568
  }
18569
+ fileSkills.push(asset);
18540
18570
  const checked = await api.read(
18541
18571
  (client) => client.assets.validate({
18542
18572
  params: { kind: "skill" },
@@ -18553,19 +18583,25 @@ async function pushConfig(options) {
18553
18583
  }
18554
18584
  const drafted = [];
18555
18585
  const filed = [];
18556
- if (items.length > 0 || changesDefault) {
18557
- const batch = {
18586
+ const synced = items.length > 0 || changesDefault ? await syncBatch(
18587
+ api,
18588
+ {
18558
18589
  ...batchScope(instance),
18559
18590
  items,
18560
18591
  ...changesDefault ? {
18561
18592
  defaultAgentName: bundle.defaultAgentName ?? null,
18562
18593
  expectedDefaultAgentName: baseline.defaultAgentName ?? null
18563
18594
  } : {}
18564
- };
18565
- const synced = await syncBatch(api, batch, options);
18566
- if (synced === void 0) {
18567
- return 1;
18568
- }
18595
+ },
18596
+ options,
18597
+ skipped
18598
+ ) : "empty";
18599
+ if (synced === void 0) {
18600
+ return 1;
18601
+ }
18602
+ const defaultWritten = changesDefault && !skipped.defaultAgent;
18603
+ const batchWritten = synced !== "empty";
18604
+ if (synced !== "empty") {
18569
18605
  const result = synced;
18570
18606
  const revisions = {};
18571
18607
  const filedInSync = /* @__PURE__ */ new Set();
@@ -18597,7 +18633,9 @@ async function pushConfig(options) {
18597
18633
  });
18598
18634
  }
18599
18635
  }
18600
- const pushed = bundleOf(syncTouched.filter((asset) => !filedInSync.has(asset.key)));
18636
+ const pushed = bundleOf(
18637
+ syncTouched.filter((asset) => !filedInSync.has(asset.key) && !isSkipped(asset.key))
18638
+ );
18601
18639
  await recordBaseline(
18602
18640
  workingDir,
18603
18641
  instance.key,
@@ -18605,7 +18643,7 @@ async function pushConfig(options) {
18605
18643
  pushed,
18606
18644
  revisions,
18607
18645
  false,
18608
- changesDefault ? bundle.defaultAgentName ?? null : baseline.defaultAgentName,
18646
+ defaultWritten ? bundle.defaultAgentName ?? null : baseline.defaultAgentName,
18609
18647
  Object.fromEntries(
18610
18648
  result.items.flatMap(
18611
18649
  (item) => item.status === "applied" && item.type === "delete" ? [[`${item.kind}:${item.name}`, { id: item.id, revision: item.revision }]] : []
@@ -18652,11 +18690,7 @@ async function pushConfig(options) {
18652
18690
  if (outcome.status === "pending_approval") {
18653
18691
  writeError(
18654
18692
  options,
18655
- waitingGuardrail(
18656
- asset.key,
18657
- outcome.run.id,
18658
- skillsWritten || items.length > 0 || changesDefault
18659
- )
18693
+ waitingGuardrail(asset.key, outcome.run.id, skillsWritten || batchWritten)
18660
18694
  );
18661
18695
  return 1;
18662
18696
  }
@@ -18711,21 +18745,14 @@ async function pushConfig(options) {
18711
18745
  if (!(error instanceof ConfigApiError)) throw error;
18712
18746
  const draftConflict = readDraftConflict(error);
18713
18747
  const conflicts = draftConflict ? [{ ...draftConflict, kind: "skill", name: asset.name }] : error.code === "REVISION_CONFLICT" || error.code === "CONFLICT" ? readConflicts(error.details) : [];
18714
- if (conflicts.length)
18715
- writeError(
18716
- options,
18717
- formatPushConflict(
18718
- conflicts,
18719
- false,
18720
- options,
18721
- skillsWritten || items.length > 0 || changesDefault
18722
- )
18723
- );
18724
- else
18725
- writeError(
18726
- options,
18727
- `${asset.key}: ${error.code ?? "refused"}: ${error.message}. ${skillsWritten || items.length > 0 || changesDefault ? "What is reported above was applied; nothing after it." : "Nothing was applied."}`
18728
- );
18748
+ if (conflicts.length > 0 || error.code === "REVISION_CONFLICT") {
18749
+ skip(conflicts.length > 0 ? conflicts : [{ kind: "skill", name: asset.name }]);
18750
+ continue;
18751
+ }
18752
+ writeError(
18753
+ options,
18754
+ `${asset.key}: ${error.code ?? "refused"}: ${error.message}. ${skillsWritten || batchWritten ? "What is reported above was applied; nothing after it." : "Nothing was applied."}`
18755
+ );
18729
18756
  return 1;
18730
18757
  }
18731
18758
  }
@@ -18733,11 +18760,12 @@ async function pushConfig(options) {
18733
18760
  workingDir,
18734
18761
  instanceKey: instance.key,
18735
18762
  version: baseline.lastPulledVersion,
18736
- puts: touched.filter(isGuardrail),
18763
+ puts: writable.filter(isGuardrail),
18737
18764
  deletes: deleteAssets.filter(isGuardrail),
18738
18765
  baseOf,
18739
18766
  listing,
18740
- afterSync: items.length > 0 || changesDefault || skillsWritten,
18767
+ skip,
18768
+ afterSync: batchWritten || skillsWritten,
18741
18769
  ...instance.workspace === void 0 ? {} : { workspaceId: instance.workspace },
18742
18770
  options
18743
18771
  });
@@ -18767,19 +18795,6 @@ async function publishDrafts(api, drafts, input) {
18767
18795
  }
18768
18796
  };
18769
18797
  for (const [index, draft] of drafts.entries()) {
18770
- if (input.workspaceId !== void 0 && draft.kind === "agent") {
18771
- const answer = await askBeforePublish(options, {
18772
- kind: "agent",
18773
- command: "agent",
18774
- name: draft.name,
18775
- revision: draft.draftRevision,
18776
- yes: false
18777
- });
18778
- if (answer !== "answered") {
18779
- unpublished(index);
18780
- return 1;
18781
- }
18782
- }
18783
18798
  let outcome;
18784
18799
  try {
18785
18800
  outcome = await api.change(
@@ -18836,53 +18851,75 @@ function publishRefusal(draft, error) {
18836
18851
  ...hint === void 0 ? [] : [hint]
18837
18852
  ].join("\n");
18838
18853
  }
18839
- async function syncBatch(api, batch, options) {
18840
- try {
18841
- const checked = await checkSyncOnThisRelease(api, batch);
18842
- const outcome = await api.syncAssets(batch);
18843
- if (outcome.status === "pending_approval") {
18844
- writeError(
18845
- options,
18846
- `The push waits for an approval on the instance and nothing was applied yet (Operation Run ${outcome.operationRunId}). When it is approved, run 'catalyst config pull' to record the new revisions.`
18847
- );
18848
- return void 0;
18849
- }
18850
- const warnings = [...checked.warnings ?? [], ...outcome.output.warnings];
18851
- return {
18852
- ...outcome.output,
18853
- warnings: warnings.filter(
18854
- (warning, index) => warnings.findIndex(
18855
- (other) => other.code === warning.code && other.message === warning.message
18856
- ) === index
18857
- )
18858
- };
18859
- } catch (error) {
18860
- const draftConflict = error instanceof ConfigApiError ? readDraftConflict(error) : void 0;
18861
- if (draftConflict) {
18862
- writeError(options, formatPushConflict([draftConflict], false, options));
18863
- return void 0;
18864
- }
18865
- const refusal = error instanceof ConfigApiError ? readRefusedBatch(error) : void 0;
18866
- if (!refusal) {
18867
- throw error;
18868
- }
18869
- if (refusal.conflicts.length > 0 || refusal.defaultAgentConflict) {
18854
+ async function syncBatch(api, initial, options, skipped) {
18855
+ let batch = initial;
18856
+ for (; ; ) {
18857
+ if (batch.items.length === 0 && batch.defaultAgentName === void 0) return "empty";
18858
+ try {
18859
+ const checked = await checkSyncOnThisRelease(api, batch);
18860
+ const outcome = await api.syncAssets(batch);
18861
+ if (outcome.status === "pending_approval") {
18862
+ writeError(
18863
+ options,
18864
+ `The push waits for an approval on the instance and nothing was applied yet (Operation Run ${outcome.operationRunId}). When it is approved, run 'catalyst config pull' to record the new revisions.`
18865
+ );
18866
+ return void 0;
18867
+ }
18868
+ const warnings = [...checked.warnings ?? [], ...outcome.output.warnings];
18869
+ return {
18870
+ ...outcome.output,
18871
+ warnings: warnings.filter(
18872
+ (warning, index) => warnings.findIndex(
18873
+ (other) => other.code === warning.code && other.message === warning.message
18874
+ ) === index
18875
+ )
18876
+ };
18877
+ } catch (error) {
18878
+ if (!(error instanceof ConfigApiError)) throw error;
18879
+ const draftConflict = readDraftConflict(error);
18880
+ const refusal = draftConflict ? void 0 : readRefusedBatch(error);
18881
+ const conflicts = draftConflict ? [draftConflict] : refusal?.conflicts ?? [];
18882
+ const defaultAgentConflict = refusal?.defaultAgentConflict === true;
18883
+ const rest = withoutConflicts(batch, conflicts, defaultAgentConflict, skipped);
18884
+ if (rest !== void 0) {
18885
+ batch = rest;
18886
+ continue;
18887
+ }
18888
+ if (conflicts.length > 0 || defaultAgentConflict) {
18889
+ writeError(
18890
+ options,
18891
+ formatPushConflict(conflicts, defaultAgentConflict, options, NOTHING_APPLIED_HEADER)
18892
+ );
18893
+ return void 0;
18894
+ }
18895
+ if (!refusal) throw error;
18870
18896
  writeError(
18871
18897
  options,
18872
- formatPushConflict(refusal.conflicts, refusal.defaultAgentConflict, options)
18898
+ formatRefusal2(
18899
+ refusal.validation ? "Validation failed" : "Push refused; nothing was applied",
18900
+ refusal
18901
+ )
18873
18902
  );
18874
18903
  return void 0;
18875
18904
  }
18876
- writeError(
18877
- options,
18878
- formatRefusal2(
18879
- refusal.validation ? "Validation failed" : "Push refused; nothing was applied",
18880
- refusal
18881
- )
18882
- );
18883
- return void 0;
18884
18905
  }
18885
18906
  }
18907
+ function withoutConflicts(batch, conflicts, defaultAgentConflict, skipped) {
18908
+ const named = new Map(
18909
+ conflicts.map((conflict) => [`${conflict.kind}:${conflict.name}`, conflict])
18910
+ );
18911
+ const keyOf2 = (item) => `${item.kind}:${item.type === "put" ? String(item.config.name) : item.name}`;
18912
+ const left = batch.items.filter((item) => !named.has(keyOf2(item)));
18913
+ const dropsDefault = defaultAgentConflict && batch.defaultAgentName !== void 0;
18914
+ if (left.length === batch.items.length && !dropsDefault) return void 0;
18915
+ skipped.conflicts.push(...batch.items.flatMap((item) => named.get(keyOf2(item)) ?? []));
18916
+ if (!dropsDefault) return { ...batch, items: left };
18917
+ skipped.defaultAgent = true;
18918
+ return {
18919
+ ...batch.workspaceId === void 0 ? {} : { workspaceId: batch.workspaceId },
18920
+ items: left
18921
+ };
18922
+ }
18886
18923
  async function writeGuardrails(api, input) {
18887
18924
  const { options } = input;
18888
18925
  const owner = input.workspaceId === void 0 ? {} : { workspaceId: input.workspaceId };
@@ -18897,21 +18934,33 @@ async function writeGuardrails(api, input) {
18897
18934
  void 0,
18898
18935
  tombstones
18899
18936
  );
18937
+ const skipped = (error, asset) => {
18938
+ if (!(error instanceof ConfigApiError) || error.code !== "REVISION_CONFLICT") return false;
18939
+ const conflicts = readConflicts(error.details);
18940
+ input.skip(conflicts.length > 0 ? conflicts : [{ kind: asset.kind, name: asset.name }]);
18941
+ return true;
18942
+ };
18900
18943
  try {
18901
18944
  for (const asset of input.puts) {
18902
18945
  const base = input.baseOf(asset.key);
18903
- const outcome = await api.change(
18904
- (client, idempotencyKey2) => client.assets.put({
18905
- params: { kind: asset.kind, name: asset.name },
18906
- body: {
18907
- config: { ...asset.config },
18908
- expectedRevision: base?.revision ?? null,
18909
- ...owner
18910
- },
18911
- idempotencyKey: idempotencyKey2
18912
- }),
18913
- "It may have been written: run 'catalyst config diff' before pushing again."
18914
- );
18946
+ let outcome;
18947
+ try {
18948
+ outcome = await api.change(
18949
+ (client, idempotencyKey2) => client.assets.put({
18950
+ params: { kind: asset.kind, name: asset.name },
18951
+ body: {
18952
+ config: { ...asset.config },
18953
+ expectedRevision: base?.revision ?? null,
18954
+ ...owner
18955
+ },
18956
+ idempotencyKey: idempotencyKey2
18957
+ }),
18958
+ "It may have been written: run 'catalyst config diff' before pushing again."
18959
+ );
18960
+ } catch (error) {
18961
+ if (skipped(error, asset)) continue;
18962
+ throw error;
18963
+ }
18915
18964
  if (outcome.status === "pending_approval") {
18916
18965
  writeError(options, waitingGuardrail(asset.key, outcome.run.id, written));
18917
18966
  return 1;
@@ -18929,14 +18978,20 @@ async function writeGuardrails(api, input) {
18929
18978
  for (const asset of input.deletes) {
18930
18979
  const base = input.baseOf(asset.key);
18931
18980
  if (base === void 0) continue;
18932
- const outcome = await api.change(
18933
- (client, idempotencyKey2) => client.assets.delete({
18934
- params: { kind: asset.kind, name: asset.name },
18935
- body: { expectedRevision: base.revision, ...owner },
18936
- idempotencyKey: idempotencyKey2
18937
- }),
18938
- "It may have been applied: run 'catalyst config diff' before pushing again."
18939
- );
18981
+ let outcome;
18982
+ try {
18983
+ outcome = await api.change(
18984
+ (client, idempotencyKey2) => client.assets.delete({
18985
+ params: { kind: asset.kind, name: asset.name },
18986
+ body: { expectedRevision: base.revision, ...owner },
18987
+ idempotencyKey: idempotencyKey2
18988
+ }),
18989
+ "It may have been applied: run 'catalyst config diff' before pushing again."
18990
+ );
18991
+ } catch (error) {
18992
+ if (skipped(error, asset)) continue;
18993
+ throw error;
18994
+ }
18940
18995
  if (outcome.status === "pending_approval") {
18941
18996
  writeError(options, waitingGuardrail(asset.key, outcome.run.id, written));
18942
18997
  return 1;
@@ -18953,11 +19008,6 @@ async function writeGuardrails(api, input) {
18953
19008
  return 0;
18954
19009
  } catch (error) {
18955
19010
  if (!(error instanceof ConfigApiError)) throw error;
18956
- const conflicts = error.code === "REVISION_CONFLICT" ? readConflicts(error.details) : [];
18957
- if (conflicts.length > 0) {
18958
- writeError(options, formatPushConflict(conflicts, false, options, written));
18959
- return 1;
18960
- }
18961
19011
  const refusal = readRefusedBatch(error);
18962
19012
  if (!refusal) throw error;
18963
19013
  writeError(
@@ -19129,8 +19179,12 @@ function formatRefusal2(title, refusal) {
19129
19179
  return `${title}:
19130
19180
  ${refusal.lines.map((line) => `- ${line}`).join("\n")}`;
19131
19181
  }
19132
- function formatPushConflict(conflicts, defaultAgentConflict, options, applied = false) {
19133
- const selectors = conflicts.map((asset) => `${asset.kind}:${asset.name}`);
19182
+ var NOTHING_APPLIED_HEADER = "Push conflict; nothing was applied.";
19183
+ function formatPushConflict(conflicts, defaultAgentConflict, options, header) {
19184
+ const sorted = [...conflicts].sort(
19185
+ (left, right) => `${left.kind}:${left.name}`.localeCompare(`${right.kind}:${right.name}`)
19186
+ );
19187
+ const selectors = sorted.map((asset) => `${asset.kind}:${asset.name}`);
19134
19188
  const argumentsList = [
19135
19189
  "catalyst config pull",
19136
19190
  ...options.dir ? ["--dir", shellQuote(options.dir)] : [],
@@ -19139,14 +19193,27 @@ function formatPushConflict(conflicts, defaultAgentConflict, options, applied =
19139
19193
  ...defaultAgentConflict ? [] : selectors.flatMap((selector) => ["--only", shellQuote(selector)])
19140
19194
  ];
19141
19195
  return [
19142
- applied ? "Push conflict; what is reported above was applied, nothing after it." : "Push conflict; nothing was applied.",
19143
- ...conflicts.map((asset) => `- ${asset.kind}:${asset.name}: ${describeConflict(asset)}`),
19196
+ header,
19197
+ ...sorted.map((asset) => `- ${asset.kind}:${asset.name}: ${describeConflict(asset)}`),
19144
19198
  ...defaultAgentConflict ? ["- default agent changed on the instance; a full pull is required."] : [],
19145
19199
  defaultAgentConflict ? "Commit or stash local edits in git first: a full pull overwrites the local working copy." : "Commit or stash local edits in git first: pull overwrites the local files for these assets.",
19146
19200
  argumentsList.join(" "),
19147
- "Review with 'catalyst config diff', re-apply local edits, and push again."
19201
+ "Merge your edits into the pulled files, review with 'catalyst config diff', and push again."
19148
19202
  ].join("\n");
19149
19203
  }
19204
+ async function describeStale(api, stale) {
19205
+ return mapConcurrently(stale, async (asset) => {
19206
+ const latest = await api.getLatestRevision(asset.kind, asset.name).catch(() => void 0);
19207
+ return {
19208
+ kind: asset.kind,
19209
+ name: asset.name,
19210
+ currentRevision: latest?.revision ?? asset.currentRevision,
19211
+ ...latest?.operation === "delete" ? { deleted: true } : {},
19212
+ ...latest?.actor ? { changedBy: latest.actor.displayLabel } : {},
19213
+ ...latest ? { changedAt: latest.createdAt } : {}
19214
+ };
19215
+ });
19216
+ }
19150
19217
  function describeConflict(asset) {
19151
19218
  if (asset.draft !== void 0) {
19152
19219
  return asset.draft.revision === null ? "the draft this working copy last saw was published or discarded since" : `its draft changed since the last pull: draft revision ${asset.draft.revision}, written by ${asset.changedBy ?? "unknown actor"} at ${asset.changedAt ?? "unknown time"}. A pull records it, and the push after it writes over that draft`;
@@ -19675,13 +19742,12 @@ var putVerb = {
19675
19742
  // src/workflow-publish-review.ts
19676
19743
  async function workflowPublishReview(input) {
19677
19744
  const { api, options, scope, name: name2, revision, json: json2 } = input;
19678
- const get = (selected) => api.read(
19745
+ const asset = await api.read(
19679
19746
  (client) => client.assets.get({
19680
19747
  params: { kind: "workflow", name: name2 },
19681
- query: { revision: selected, ...scope }
19748
+ query: { revision: String(revision), ...scope }
19682
19749
  })
19683
19750
  );
19684
- const asset = await get(String(revision));
19685
19751
  if ((asset.contentRevision ?? asset.revision) !== revision) {
19686
19752
  throw new Error("The publish review does not describe this revision. Nothing was published.");
19687
19753
  }
@@ -19691,27 +19757,14 @@ async function workflowPublishReview(input) {
19691
19757
  "Publishes together: the Data Stores and their migrations first, then the Workflow, or neither:",
19692
19758
  ...stores.map(dataStoreLine)
19693
19759
  ];
19694
- const narrative = input.yes ? void 0 : asset.publishNarrative;
19760
+ const narrative = asset.publishNarrative;
19695
19761
  const lead = narrative ? [narrative.summary, ...narrative.warnings, ...together] : [...together, ...asset.publishQuestion ?? []];
19696
19762
  if (lead.length > 0) say(lead.join("\n"));
19697
- const dataStores = stores.map(({ name: store, revision: draft }) => ({
19698
- name: store,
19699
- revision: draft
19700
- }));
19701
- if (!narrative) return { dataStores };
19702
19763
  return {
19703
- dataStores,
19704
- details: async () => {
19705
- const live = asset.publishedRevision === void 0 ? void 0 : await get(String(asset.publishedRevision));
19706
- say(
19707
- [
19708
- "Details",
19709
- ...publishFileChanges(asset, live),
19710
- ...asset.filesOmitted || live?.filesOmitted ? ["Some files are omitted from this review."] : [],
19711
- ...asset.publishQuestion ?? []
19712
- ].join("\n")
19713
- );
19714
- }
19764
+ dataStores: stores.map(({ name: store, revision: draft }) => ({
19765
+ name: store,
19766
+ revision: draft
19767
+ }))
19715
19768
  };
19716
19769
  }
19717
19770
 
@@ -19770,7 +19823,7 @@ async function guardrailDryRunBeforePublish(session2, name2, revision) {
19770
19823
  var ALREADY_LIVE = /* @__PURE__ */ Symbol("already live");
19771
19824
  var publishVerb = {
19772
19825
  usage: "publish <name> --revision <n> [--yes] [--confirm <blocked>]",
19773
- summary: "Make one revision the one its users are served (assets.publish). A guardrail shows its dry run first; an App, a Workflow or a workspace's agent asks you first. A publish that hands a source's data to people who may not use the source waits in the Inbox until a person who may change the source approves it",
19826
+ summary: "Make one revision the one its users are served (assets.publish), live at once. A guardrail shows its dry run first; --yes is accepted and changes nothing. A guardrail of the instance can hold a publish for an approval, and a publish that hands a source's data to people who may not use the source waits in the Inbox until a person who may change the source approves it",
19774
19827
  named: true,
19775
19828
  options: {
19776
19829
  revision: { type: "string" },
@@ -19795,41 +19848,16 @@ var publishVerb = {
19795
19848
  );
19796
19849
  for (const line of asset.publishQuestion ?? []) writeOutput(session2.options, line);
19797
19850
  }
19798
- let unattended = false;
19799
- let dataStores = [];
19851
+ const review = session2.kind.kind === "workflow" ? await workflowPublishReview({
19852
+ api: session2.api,
19853
+ options: session2.options,
19854
+ scope: session2.scope,
19855
+ name: name2,
19856
+ revision,
19857
+ json: values.json
19858
+ }) : void 0;
19859
+ const dataStores = review?.dataStores ?? [];
19800
19860
  const agent = session2.kind.kind === AGENT_KIND;
19801
- const asks = agent ? session2.scope.workspaceId !== void 0 : session2.kind.actions.approve !== void 0;
19802
- if (asks) {
19803
- const review = session2.kind.kind === "workflow" && (values.yes || session2.options.prompt) ? await workflowPublishReview({
19804
- api: session2.api,
19805
- options: session2.options,
19806
- scope: session2.scope,
19807
- name: name2,
19808
- revision,
19809
- json: values.json,
19810
- yes: values.yes
19811
- }) : void 0;
19812
- dataStores = review?.dataStores ?? [];
19813
- const asked = {
19814
- kind: session2.kind.kind,
19815
- command: kindNoun(session2.kind),
19816
- name: name2,
19817
- revision
19818
- };
19819
- const answer = await askBeforePublish(session2.options, {
19820
- ...asked,
19821
- yes: values.yes,
19822
- ...review?.details ? { details: review.details } : {}
19823
- });
19824
- if (answer === "refused") return EXIT3.refused;
19825
- unattended = answer === "unattended";
19826
- } else if (values.yes && session2.kind.kind === "data_store") {
19827
- unattended = true;
19828
- } else if (values.yes) {
19829
- throw new UsageError(
19830
- agent ? "An instance's own agent is published without a question; --yes answers none." : `A ${session2.kind.kind} is published without a question; --yes answers none.`
19831
- );
19832
- }
19833
19861
  const outcome = await session2.api.change(
19834
19862
  (client, idempotencyKey2) => client.assets.publish({
19835
19863
  params: { kind: session2.kind.kind, name: name2 },
@@ -19839,8 +19867,7 @@ var publishVerb = {
19839
19867
  ...dataStores.length > 0 ? { dataStores } : {},
19840
19868
  ...session2.kind.kind === "knowledge_base" && values.confirm ? { confirmProcessing: values.confirm } : {}
19841
19869
  },
19842
- idempotencyKey: idempotencyKey2,
19843
- ...unattended ? { unattended } : {}
19870
+ idempotencyKey: idempotencyKey2
19844
19871
  }),
19845
19872
  "It may have been applied: run 'show' before sending it again."
19846
19873
  ).catch((error) => {
@@ -19870,7 +19897,7 @@ var publishVerb = {
19870
19897
  // An agent's first version without a draft replaces nothing: it is offered as made.
19871
19898
  output.replacedRevision !== void 0 && (agent || session2.kind.kind === "skill") ? `Published draft revision ${output.draftRevision} of ${session2.kind.kind} '${name2}' as live revision ${output.publishedRevision}${output.replacedRevision === void 0 ? "" : ` in place of revision ${output.replacedRevision}`}.` : `Published revision ${output.publishedRevision} of ${session2.kind.kind} '${name2}'${output.replacedRevision === void 0 ? "" : ` in place of revision ${output.replacedRevision}`}.`
19872
19899
  ],
19873
- asks ? "If you are an instance approver, you can approve it in the Inbox." : void 0,
19900
+ session2.kind.actions.approve !== void 0 || agent ? "If you are an instance approver, you can approve it in the Inbox." : void 0,
19874
19901
  OVERTAKEN_LINE
19875
19902
  );
19876
19903
  };
@@ -22758,6 +22785,11 @@ var PROVIDER_KINDS = {
22758
22785
  flag: "label",
22759
22786
  question: "Name people read for the model, such as Claude Sonnet 4.6",
22760
22787
  required: true
22788
+ },
22789
+ {
22790
+ flag: "cache-write-price",
22791
+ question: "Price of a million input tokens written to the prompt cache",
22792
+ required: false
22761
22793
  }
22762
22794
  ],
22763
22795
  entry: (values) => ({
@@ -23155,6 +23187,8 @@ Options of add:
23155
23187
  --region eu The only region this command writes
23156
23188
  --input-price <n> Price of a million uncached input tokens
23157
23189
  --cached-input-price <n> Price of a million cached input tokens
23190
+ --cache-write-price <n> bedrock: price of a million input tokens written to the prompt
23191
+ cache (default: the input price)
23158
23192
  --output-price <n> Price of a million output tokens
23159
23193
  --currency <ABC> The rate card's currency where the config has none yet (EUR)
23160
23194
 
@@ -23199,6 +23233,7 @@ async function runModelsCommand(argv, base) {
23199
23233
  region: { type: "string" },
23200
23234
  "input-price": { type: "string" },
23201
23235
  "cached-input-price": { type: "string" },
23236
+ "cache-write-price": { type: "string" },
23202
23237
  "output-price": { type: "string" },
23203
23238
  currency: { type: "string" },
23204
23239
  config: { type: "string" },
@@ -23350,6 +23385,7 @@ async function addProvider(kind, flags, options) {
23350
23385
  model,
23351
23386
  uncachedInputPricePerMillionTokens: Number(values["input-price"]),
23352
23387
  cachedInputPricePerMillionTokens: Number(values["cached-input-price"]),
23388
+ ...values["cache-write-price"] === void 0 ? {} : { cacheWriteInputPricePerMillionTokens: Number(values["cache-write-price"]) },
23353
23389
  outputPricePerMillionTokens: Number(values["output-price"])
23354
23390
  };
23355
23391
  const prices = valueAt(config.merged, PRICES);
@@ -23398,7 +23434,7 @@ async function addProvider(kind, flags, options) {
23398
23434
  ],
23399
23435
  [
23400
23436
  PRICES.join("."),
23401
- `${price.uncachedInputPricePerMillionTokens} input, ${price.cachedInputPricePerMillionTokens} cached input, ${price.outputPricePerMillionTokens} output per million tokens (${currency})`
23437
+ `${price.uncachedInputPricePerMillionTokens} input, ${price.cachedInputPricePerMillionTokens} cached input, ${price.cacheWriteInputPricePerMillionTokens === void 0 ? "" : `${price.cacheWriteInputPricePerMillionTokens} cache write, `}${price.outputPricePerMillionTokens} output per million tokens (${currency})`
23402
23438
  ]
23403
23439
  ];
23404
23440
  const width = Math.max(...written.map(([where]) => where.length));
@@ -23427,8 +23463,8 @@ function fallbackRefusal(fallbackId, bindings, models) {
23427
23463
  const fallback = Array.isArray(bindings) ? bindings.find((binding) => isRecord(binding) && binding.id === fallbackId) : void 0;
23428
23464
  if (!isRecord(fallback))
23429
23465
  return `The release config has no model binding '${fallbackId}' to fall back to. Name one of its chat bindings with --fallback.`;
23430
- if (fallback.kind === "embedding")
23431
- return `'${fallbackId}' is an embedding binding; a fallback answers chat calls. Name a chat binding with --fallback.`;
23466
+ if (fallback.kind === "embedding" || fallback.kind === "transcription")
23467
+ return `'${fallbackId}' is ${fallback.kind === "embedding" ? "an embedding" : "a transcription"} binding; a fallback answers chat calls. Name a chat binding with --fallback.`;
23432
23468
  const entry = isPlainConfigObject(models) && typeof fallback.providerId === "string" ? models[fallback.providerId] : void 0;
23433
23469
  const region = isPlainConfigObject(entry) ? entry.region : void 0;
23434
23470
  if (region !== "eu")