@work-shape/catalyst-cli 0.8.0-rc.13 → 0.8.0-rc.14

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
@@ -220,6 +220,8 @@ var FIRST_PARTY_AUTH_SCOPES = [
220
220
  "governance:write",
221
221
  "user_admin:read",
222
222
  "user_admin:write",
223
+ // A personal key can check providers without reaching other user administration routes.
224
+ "infrastructure:check",
223
225
  "api_access:read",
224
226
  "api_access:write",
225
227
  "config_assets:read",
@@ -641,7 +643,7 @@ var WORKFLOW_RESERVED_STEP_TYPES = [
641
643
  "condition",
642
644
  "parallel"
643
645
  ];
644
- var WORKFLOW_TRIGGER_KINDS = ["manual", "schedule", "parent"];
646
+ var WORKFLOW_TRIGGER_KINDS = ["manual", "schedule", "parent", "outside"];
645
647
  var WORKFLOW_STEP_SOURCE_KINDS = [
646
648
  "connection",
647
649
  "data_store",
@@ -727,6 +729,11 @@ var PUBLISHED_DATA_CONSUMER_KINDS = ["app", "workflow", "knowledge_base"];
727
729
  var SCHEDULED_START_STATES = ["active", "paused"];
728
730
  var AGENT_PREVIEW_SOURCES = ["draft", "live"];
729
731
 
732
+ // ../asset-schemas/src/is-record.ts
733
+ function isRecord(value) {
734
+ return typeof value === "object" && value !== null && !Array.isArray(value);
735
+ }
736
+
730
737
  // ../asset-schemas/src/schemas.ts
731
738
  import { z } from "zod";
732
739
 
@@ -988,7 +995,7 @@ function isSecretNameWord(word2) {
988
995
  import yaml from "js-yaml";
989
996
 
990
997
  // ../asset-schemas/src/yaml-data.ts
991
- import { JSON_SCHEMA, YAMLException, load } from "js-yaml";
998
+ import { JSON_SCHEMA, YAMLException, dump, load } from "js-yaml";
992
999
  var YAML_DATA_MAX_VALUES = 1e5;
993
1000
  function isStorableText(text2) {
994
1001
  return !text2.includes("\0") && !/\p{Surrogate}/u.test(text2);
@@ -2473,7 +2480,7 @@ import { z as z58 } from "zod";
2473
2480
  // ../api-contract/package.json
2474
2481
  var package_default = {
2475
2482
  name: "@work-shape/catalyst-api-contract",
2476
- version: "0.8.0-rc.13",
2483
+ version: "0.8.0-rc.14",
2477
2484
  license: "MIT",
2478
2485
  repository: {
2479
2486
  type: "git",
@@ -3605,7 +3612,10 @@ var configAssetRevisionSchema = z22.object({
3605
3612
  operation: z22.enum(CONFIG_ASSET_CHANGE_OPERATIONS),
3606
3613
  config: configAssetConfigSchema.nullable(),
3607
3614
  actor: auditActorSchema.nullable(),
3608
- /** Where the revision came from: the approval that applied it, or the Page it copies. */
3615
+ /**
3616
+ * Where the revision came from: the approval that applied it, the Page it copies, or the
3617
+ * agent of a conversation that wrote it for the person in `actor`.
3618
+ */
3609
3619
  origin: z22.discriminatedUnion("kind", [
3610
3620
  z22.object({ kind: z22.literal("approval_request"), requestId: z22.string(), summary: z22.string() }),
3611
3621
  z22.object({
@@ -3613,12 +3623,24 @@ var configAssetRevisionSchema = z22.object({
3613
3623
  conversationId: z22.string(),
3614
3624
  pageId: z22.string(),
3615
3625
  /** The number of the Page revision the files were copied from. */
3616
- fileSetNumber: z22.number().int().positive()
3617
- })
3626
+ fileSetNumber: z22.number().int().positive(),
3627
+ /** The conversation's agent saved the Page, not a person from its preview. */
3628
+ byAgent: z22.literal(true).optional()
3629
+ }),
3630
+ z22.object({ kind: z22.literal("agent_run"), conversationId: z22.string() })
3618
3631
  ]).optional(),
3619
3632
  globalVersion: z22.number().int().positive(),
3620
3633
  createdAt: timestampSchema
3621
3634
  });
3635
+ var configAssetPublicationSchema = z22.object({
3636
+ number: z22.number().int().positive(),
3637
+ /** The revision the publish made live. */
3638
+ revision: z22.number().int().positive(),
3639
+ /** Null where it is not known, as for a publish from before the versions were recorded. */
3640
+ actor: auditActorSchema.nullable(),
3641
+ publishedAt: timestampSchema,
3642
+ note: z22.string().optional()
3643
+ });
3622
3644
  var toolGroupSchema = z22.enum(TOOL_GROUPS);
3623
3645
  var toolTextSchema = z22.object({ en: z22.string(), de: z22.string() });
3624
3646
  var agentToolReferenceSchema = z22.object({
@@ -3669,8 +3691,6 @@ var configAssetReferencesSchema = z22.object({
3669
3691
  * still names one shows it as unavailable, so it can be removed.
3670
3692
  */
3671
3693
  unavailableTools: z22.array(unavailableToolSchema).optional(),
3672
- /** @deprecated Use unavailableTools. Kept for existing agent editors. */
3673
- moduleOffTools: z22.array(z22.object({ name: z22.string(), module: z22.string() })).optional(),
3674
3694
  /**
3675
3695
  * What the platform tells every agent before its own instructions, read-only: the rules
3676
3696
  * every agent gets, and the orientation an agent gets whose tools name one of `toolNames`.
@@ -4011,6 +4031,7 @@ var assetScopeSchema = z26.discriminatedUnion("kind", [
4011
4031
  ]);
4012
4032
  var revisionNumberSchema = z26.number().int().positive();
4013
4033
  var APP_PUBLISH_WORKFLOWS_MAX = 20;
4034
+ var APP_PUBLISH_DATA_STORES_MAX = 100;
4014
4035
  var expectedRevisionSchema = revisionNumberSchema.optional();
4015
4036
  var expectedRevisionOrNewSchema = revisionNumberSchema.nullable().optional();
4016
4037
  var NUL = "\0";
@@ -4130,8 +4151,18 @@ var workflowStepFactSchema = workflowOperationFactSchema.partial().extend({
4130
4151
  tools: z26.array(workflowOperationFactSchema.extend({ name: z26.string() })).optional()
4131
4152
  });
4132
4153
  var assetSchema = z26.object({
4133
- /** The retained publish event for the live revision, for a reader of an App draft. */
4134
- publication: z26.object({ at: z26.string().datetime(), by: z26.string().optional() }).optional(),
4154
+ /**
4155
+ * Of a live App, for a reader of its draft: its version, the number of the publish that made
4156
+ * it live, when and by whom. Members read this number, never a revision's.
4157
+ */
4158
+ liveVersion: z26.object({
4159
+ number: z26.number().int().positive(),
4160
+ publishedAt: timestampSchema,
4161
+ /** The name of who published, as the account is now; empty for one that is gone. */
4162
+ by: z26.string().optional()
4163
+ }).optional(),
4164
+ /** Of a live App, for a reader of its draft: whether the draft is another revision than the live one. */
4165
+ draftChangedSinceLive: z26.boolean().optional(),
4135
4166
  id: z26.string(),
4136
4167
  kind: z26.string(),
4137
4168
  name: z26.string(),
@@ -4337,7 +4368,15 @@ var publishAssetRequestSchema = z26.object({
4337
4368
  * a Workflow the App's revision reaches, directly or as a child. They are published children
4338
4369
  * first and then the App, in one transaction: a refusal of any publishes none of them.
4339
4370
  */
4340
- workflows: z26.array(z26.object({ name: z26.string().min(1), revision: revisionNumberSchema }).strict()).max(APP_PUBLISH_WORKFLOWS_MAX).optional()
4371
+ workflows: z26.array(z26.object({ name: z26.string().min(1), revision: revisionNumberSchema }).strict()).max(APP_PUBLISH_WORKFLOWS_MAX).optional(),
4372
+ /**
4373
+ * Of an App only: the Data Store drafts this publish makes live with it (GOLIVE-1), each
4374
+ * with the revision the person reviewed, as `apps.publish_review` lists them. Each must be
4375
+ * a store the App's revision binds under `dataStores`. Each store is published first, in
4376
+ * its own transaction, and its migrations applied; the App and its Workflows go live only
4377
+ * once every store reached its level, and none of them where a migration fails.
4378
+ */
4379
+ dataStores: z26.array(z26.object({ name: z26.string().min(1), revision: revisionNumberSchema }).strict()).max(APP_PUBLISH_DATA_STORES_MAX).optional()
4341
4380
  });
4342
4381
  var discardAssetDraftRequestSchema = z26.object({
4343
4382
  /** The draft revision the caller last read. Required. */
@@ -4349,10 +4388,13 @@ var assetPointersResponseSchema = z26.object({
4349
4388
  publishedRevision: revisionNumberSchema,
4350
4389
  /** The revision that was published before a publish, left out on the first one. */
4351
4390
  replacedRevision: revisionNumberSchema.optional(),
4352
- /** The Workflows a publish of an App made live with it, in the order they were published. */
4391
+ /**
4392
+ * The Data Stores and Workflows a publish of an App made live with it, in the order they
4393
+ * were published: the stores first.
4394
+ */
4353
4395
  publishedWith: z26.array(
4354
4396
  z26.object({
4355
- kind: z26.literal("workflow"),
4397
+ kind: z26.enum(["data_store", "workflow"]),
4356
4398
  name: z26.string(),
4357
4399
  publishedRevision: revisionNumberSchema,
4358
4400
  replacedRevision: revisionNumberSchema.optional()
@@ -4411,6 +4453,27 @@ var setAssetDefaultResponseSchema = z26.object({
4411
4453
  /** The version of the instance's whole asset set after the change. */
4412
4454
  version: z26.number().int().positive()
4413
4455
  });
4456
+ var adoptAssetRepositoryRequestSchema = z26.object({
4457
+ /** Only the asset of this name. Left out, every asset of the kind. */
4458
+ name: nameText(z26.string().min(1)).optional(),
4459
+ /** The `after` of the answer before, to go on where it stopped. */
4460
+ after: z26.string().min(1).optional()
4461
+ });
4462
+ var adoptAssetRepositoryResponseSchema = z26.object({
4463
+ /** Assets whose every revision names a commit now. */
4464
+ adopted: z26.number().int().nonnegative(),
4465
+ /** Revisions this call gave a commit, a deletion's included. */
4466
+ revisions: z26.number().int().nonnegative(),
4467
+ /** Commits this call made. */
4468
+ commits: z26.number().int().nonnegative(),
4469
+ /** Assets left as they were, or part of the way, because a revision cannot be committed. */
4470
+ refused: z26.number().int().nonnegative(),
4471
+ adoptedAssetIds: z26.array(z26.string()),
4472
+ refusedAssetIds: z26.array(z26.string()),
4473
+ done: z26.boolean(),
4474
+ /** Where the next call goes on. Absent while it starts at the beginning again. */
4475
+ after: z26.string().optional()
4476
+ });
4414
4477
  var setAssetAvailabilityRequestSchema = z26.object({
4415
4478
  /** Required with dependency consent: refuse a definition changed since it was reviewed. */
4416
4479
  expectedRevision: revisionNumberSchema.optional(),
@@ -5834,6 +5897,8 @@ var appPublishReviewItemSchema = z30.object({
5834
5897
  narrative: publishNarrativeSchema.optional(),
5835
5898
  /** Who wrote the draft revision, as people read their name. */
5836
5899
  lastChangedBy: z30.string().optional(),
5900
+ /** The path of the page where the person works on it. Only on an entry the reader may read. */
5901
+ href: z30.string().optional(),
5837
5902
  refusals: z30.array(appPublishRefusalSchema)
5838
5903
  });
5839
5904
  var appPublishReviewSchema = z30.object({
@@ -5846,6 +5911,23 @@ var appPublishReviewSchema = z30.object({
5846
5911
  lastTestRun: z30.object({ runId: z30.string(), status: z30.enum(WORKFLOW_RUN_STATUSES), at: z30.string() }).optional()
5847
5912
  })
5848
5913
  ),
5914
+ /**
5915
+ * The Data Stores the App's draft binds whose draft is not published (GOLIVE-1): one Publish
5916
+ * of the App publishes each it names in `dataStores` first and applies its migrations. Each
5917
+ * says the level the store is at, the level the App needs and the migrations it would apply.
5918
+ * A store that is live and still applying migrations the App needs is listed with `pending`
5919
+ * false: it is not named, and the Publish waits for it.
5920
+ */
5921
+ dataStores: z30.array(
5922
+ appPublishReviewItemSchema.extend({
5923
+ /** The number of the last migration the store has applied. Zero before the first. */
5924
+ liveLevel: z30.number().int().nonnegative(),
5925
+ /** The level the App's manifest asks of the store, where it asks one. */
5926
+ minSchema: z30.number().int().positive().optional(),
5927
+ /** The names of the draft's migrations above the live level, in the order they apply. */
5928
+ pendingMigrations: z30.array(z30.string())
5929
+ })
5930
+ ).default([]),
5849
5931
  /**
5850
5932
  * One Publish of the App also publishes the pending Workflow drafts it reaches, when the
5851
5933
  * publish names them in `workflows` (DP-3). Where false, each pending Workflow is published
@@ -6069,7 +6151,7 @@ var appOperations = {
6069
6151
  id: "apps.publish_review",
6070
6152
  method: "GET",
6071
6153
  path: "/api/v1/apps/:app/publish-review",
6072
- summary: "Read what publishing an App's draft comes to: the App and the Workflows it calls, their pending drafts, publish questions and what would refuse them",
6154
+ summary: "Read what publishing an App's draft comes to: the App, the Workflows it calls and the Data Stores it binds, their pending drafts and migrations, publish questions and what would refuse them",
6073
6155
  tag: "Apps",
6074
6156
  auth: "user",
6075
6157
  scope: "config_assets:read",
@@ -6406,6 +6488,24 @@ var assetOperations = {
6406
6488
  errors: ["CONFLICT"],
6407
6489
  rateClass: "write"
6408
6490
  }),
6491
+ // An operator's deploy step (WF-GIT-2), with the release right on the instance: the assets
6492
+ // of a kind whose content is a repository, written before the kind had one, get one commit
6493
+ // per revision. Never run at startup.
6494
+ "assets.adopt_repository": defineRegisteredOperation({
6495
+ id: "assets.adopt_repository",
6496
+ method: "POST",
6497
+ path: "/api/v1/assets/:kind/adopt-repository",
6498
+ summary: "Give every revision of the assets of one kind written before it had a repository its commit",
6499
+ tag: "Assets",
6500
+ auth: "principal",
6501
+ scope: "config_assets:release",
6502
+ requires: ["assets.release"],
6503
+ effect: "changing",
6504
+ body: adoptAssetRepositoryRequestSchema,
6505
+ response: json(adoptAssetRepositoryResponseSchema),
6506
+ errors: ["VALIDATION_FAILED", "CONFLICT", "TIMEOUT"],
6507
+ rateClass: "write"
6508
+ }),
6409
6509
  "assets.validate": defineRegisteredOperation({
6410
6510
  id: "assets.validate",
6411
6511
  method: "POST",
@@ -6584,6 +6684,21 @@ var assetOperations = {
6584
6684
  errors: ["NOT_FOUND"],
6585
6685
  rateClass: "read"
6586
6686
  }),
6687
+ "assets.publications.list": defineRegisteredOperation({
6688
+ id: "assets.publications.list",
6689
+ method: "GET",
6690
+ path: "/api/v1/assets/:kind/:name/publications",
6691
+ summary: "List the publications of one asset with a draft, newest first",
6692
+ tag: "Assets",
6693
+ auth: "principal",
6694
+ scope: "config_assets:read",
6695
+ requires: [],
6696
+ effect: "reading",
6697
+ query: listQuerySchema.extend(assetScopeQuerySchema.shape),
6698
+ response: page(configAssetPublicationSchema, ["number"], true),
6699
+ errors: ["NOT_FOUND"],
6700
+ rateClass: "read"
6701
+ }),
6587
6702
  "assets.revert": defineRegisteredOperation({
6588
6703
  id: "assets.revert",
6589
6704
  method: "POST",
@@ -8011,7 +8126,7 @@ var dataStoreStateResponseSchema = z38.object({
8011
8126
  }),
8012
8127
  /**
8013
8128
  * What the server leaves open around the store, each with what an operator does about it.
8014
- * Empty for a reader without `system.view`.
8129
+ * Empty for a reader without `system.view` and for personal API keys.
8015
8130
  */
8016
8131
  conditions: z38.array(z38.object({ code: z38.enum(DATA_STORE_CONDITIONS), message: z38.string() })),
8017
8132
  /** How the last attempt to bring the store to its published revision ended. */
@@ -9526,6 +9641,7 @@ var instanceOperations = {
9526
9641
  tag: "Instance",
9527
9642
  auth: "user",
9528
9643
  scope: "user_admin:read",
9644
+ personalKeyScope: "infrastructure:check",
9529
9645
  requires: ["system.view"],
9530
9646
  effect: "reading",
9531
9647
  response: json(infrastructureSchema),
@@ -10475,6 +10591,15 @@ var platformAssetKindSchema = z53.object({
10475
10591
  principalActions: z53.array(z53.string()).optional(),
10476
10592
  /** The file of a `files` kind that holds its manifest. */
10477
10593
  manifestFile: z53.string().optional(),
10594
+ /** Operator source bounds for Workflows; the names are release settings. */
10595
+ source: z53.object({
10596
+ fileBytes: z53.number().int().positive(),
10597
+ files: z53.number().int().positive(),
10598
+ treeBytes: z53.number().int().positive(),
10599
+ historyBytes: z53.number().int().positive(),
10600
+ cacheBytes: z53.number().int().positive()
10601
+ }).optional(),
10602
+ repository: z53.boolean().optional(),
10478
10603
  /** What a write of a `files` kind is held to, by the names of the limits. */
10479
10604
  limits: z53.object({
10480
10605
  FILE_SET_MAX_FILES: z53.number().int().positive(),
@@ -11582,6 +11707,11 @@ var apiOperations = allOperations;
11582
11707
  var RELEASE_VERSION = package_default.version;
11583
11708
  var API_ERROR_CODE_ORDER = appErrorCodeSchema.options;
11584
11709
 
11710
+ // ../api-contract/src/skill-limits.ts
11711
+ var SKILL_FILE_MAX_BYTES = 2 * 1024 * 1024;
11712
+ var SKILL_MAX_FILES = 500;
11713
+ var SKILL_MAX_BYTES = 8 * 1024 * 1024;
11714
+
11585
11715
  // src/instance-output.ts
11586
11716
  function versionParts(version) {
11587
11717
  const number = "(?:0|[1-9][0-9]*)";
@@ -11642,6 +11772,7 @@ ${pages.join("\n")}`).join("\n\n");
11642
11772
  import { parseArgs } from "util";
11643
11773
 
11644
11774
  // src/api.ts
11775
+ import { setTimeout as defaultSleep } from "timers/promises";
11645
11776
  import { randomUUID } from "crypto";
11646
11777
 
11647
11778
  // ../api-client/src/errors.ts
@@ -12035,7 +12166,7 @@ async function createConfigApi(options) {
12035
12166
  };
12036
12167
  return {
12037
12168
  /** Any reading operation of the instance. A refusal throws as `ConfigApiError`. */
12038
- read: (request) => read(sleep, () => request(client)),
12169
+ read: (request, onRateLimitWait) => read(sleep, () => request(client), onRateLimitWait),
12039
12170
  change,
12040
12171
  /** The version of the instance's asset set and the name of its default agent. */
12041
12172
  getOverview: async () => {
@@ -12109,10 +12240,7 @@ var CHANGE_ATTEMPTS = 3;
12109
12240
  var CHANGE_RETRY_DELAY_MS = 500;
12110
12241
  var READ_ATTEMPTS = 5;
12111
12242
  var MAX_RATE_LIMIT_WAIT_SECONDS = 60;
12112
- function defaultSleep(milliseconds) {
12113
- return new Promise((resolveSleep) => setTimeout(resolveSleep, milliseconds));
12114
- }
12115
- async function read(sleep, request) {
12243
+ async function read(sleep, request, onRateLimitWait) {
12116
12244
  for (let attempt = 1; ; attempt += 1) {
12117
12245
  try {
12118
12246
  return await request();
@@ -12121,6 +12249,7 @@ async function read(sleep, request) {
12121
12249
  if (wait === void 0 || wait > MAX_RATE_LIMIT_WAIT_SECONDS || attempt >= READ_ATTEMPTS) {
12122
12250
  throw toConfigApiError(error);
12123
12251
  }
12252
+ onRateLimitWait?.(wait);
12124
12253
  await sleep(wait * 1e3);
12125
12254
  }
12126
12255
  }
@@ -12202,9 +12331,6 @@ function readApiError(payload) {
12202
12331
  ...payload.error.details === void 0 ? {} : { details: payload.error.details }
12203
12332
  };
12204
12333
  }
12205
- function isRecord(value) {
12206
- return typeof value === "object" && value !== null && !Array.isArray(value);
12207
- }
12208
12334
  function redactSecret(message, secret) {
12209
12335
  return secret ? message.split(secret).join("[redacted]") : message;
12210
12336
  }
@@ -12213,13 +12339,17 @@ function redactSecret(message, secret) {
12213
12339
  import { resolve as resolve5 } from "path";
12214
12340
  import yaml6 from "js-yaml";
12215
12341
 
12342
+ // src/sha256.ts
12343
+ import { createHash } from "crypto";
12344
+ function sha256Hex(value) {
12345
+ return createHash("sha256").update(value).digest("hex");
12346
+ }
12347
+
12216
12348
  // src/command-support.ts
12217
- import { createHash as createHash2 } from "crypto";
12218
12349
  import { mkdir as mkdir4, mkdtemp as mkdtemp2, rename as rename4, rm as rm3, writeFile as writeFile4 } from "fs/promises";
12219
12350
  import { basename as basename3, dirname as dirname4, isAbsolute as isAbsolute2, relative as relative2, resolve as resolve4, sep as sep3 } from "path";
12220
12351
 
12221
12352
  // src/asset-folder.ts
12222
- import { createHash } from "crypto";
12223
12353
  import {
12224
12354
  lstat,
12225
12355
  mkdir,
@@ -12232,9 +12362,6 @@ import {
12232
12362
  writeFile
12233
12363
  } from "fs/promises";
12234
12364
  import { basename, dirname, join, resolve, sep } from "path";
12235
- function sha256(bytes) {
12236
- return createHash("sha256").update(bytes).digest("hex");
12237
- }
12238
12365
  async function readFolderState(directory, filename, kind) {
12239
12366
  let contents;
12240
12367
  try {
@@ -12244,7 +12371,7 @@ async function readFolderState(directory, filename, kind) {
12244
12371
  throw error;
12245
12372
  }
12246
12373
  const parsed = JSON.parse(contents);
12247
- if (!isRecord2(parsed) || typeof parsed.instance !== "string" || typeof parsed.workspaceId !== "string" || typeof parsed.assetId !== "string" || typeof parsed.revision !== "number" || !Number.isInteger(parsed.revision) || parsed.revision < 1 || !isRecord2(parsed.files) || typeof parsed[kind] !== "string")
12374
+ if (!isRecord(parsed) || typeof parsed.instance !== "string" || typeof parsed.workspaceId !== "string" || typeof parsed.assetId !== "string" || typeof parsed.revision !== "number" || !Number.isInteger(parsed.revision) || parsed.revision < 1 || !isRecord(parsed.files) || typeof parsed[kind] !== "string")
12248
12375
  throw new Error(
12249
12376
  `'${join(directory, filename)}' is not the state of a pulled ${kind}. Pull into an empty folder again.`
12250
12377
  );
@@ -12297,7 +12424,7 @@ async function localChanges(directory, state, filename, ignoreUntracked = false)
12297
12424
  else {
12298
12425
  if (ignoreUntracked && !entry.isFile()) continue;
12299
12426
  if (!entry.isFile()) throw new Error(`'${path}' is not a regular file.`);
12300
- now[path] = sha256(await readFile(join(folder, entry.name)));
12427
+ now[path] = sha256Hex(await readFile(join(folder, entry.name)));
12301
12428
  }
12302
12429
  }
12303
12430
  };
@@ -12318,7 +12445,7 @@ async function writeFolderFiles(directory, files, previous) {
12318
12445
  const target = safeTarget(directory, file.path);
12319
12446
  if (basename(file.path) === ".DS_Store") continue;
12320
12447
  const bytes = file.base64 !== void 0 ? Buffer.from(file.base64, "base64") : Buffer.from(file.text ?? "", "utf8");
12321
- const hash2 = sha256(bytes);
12448
+ const hash2 = sha256Hex(bytes);
12322
12449
  if (hash2 !== file.sha256)
12323
12450
  throw new Error(
12324
12451
  `The file '${file.path}' did not arrive as the instance holds it (its SHA-256 differs). Pull again.`
@@ -12391,9 +12518,6 @@ function safeTarget(directory, path) {
12391
12518
  }
12392
12519
  return target;
12393
12520
  }
12394
- function isRecord2(value) {
12395
- return typeof value === "object" && value !== null && !Array.isArray(value);
12396
- }
12397
12521
  function isNodeError(error) {
12398
12522
  return error instanceof Error && "code" in error;
12399
12523
  }
@@ -12402,9 +12526,6 @@ function isNodeError(error) {
12402
12526
  import { lstat as lstat2, readFile as readFile2, readdir as readdir2 } from "fs/promises";
12403
12527
  import { basename as basename2, join as join2 } from "path";
12404
12528
  var SKILL_STATE_FILES = [".catalyst-skill.json", ".catalyst-state.json"];
12405
- var FILE_MAX_BYTES = 2 * 1024 * 1024;
12406
- var FOLDER_MAX_BYTES = 8 * 1024 * 1024;
12407
- var MAX_FILES = 500;
12408
12529
  var TEXT_EXTENSIONS = /\.(py|js|mjs|ts|sh|rb|md|txt|json|yaml|yml|xml|html|css|csv)$/iu;
12409
12530
  var EXECUTABLE_PREFIXES = [
12410
12531
  [127, 69, 76, 70],
@@ -12429,7 +12550,7 @@ function resourceMediaType(path) {
12429
12550
  return path.startsWith("scripts/") ? void 0 : skillResourceMediaTypeForPath(path);
12430
12551
  }
12431
12552
  function folderHashes(files) {
12432
- return Object.fromEntries(files.map((file) => [file.path, sha256(fileBytes(file))]));
12553
+ return Object.fromEntries(files.map((file) => [file.path, sha256Hex(fileBytes(file))]));
12433
12554
  }
12434
12555
  function extraHashes(hashes = {}) {
12435
12556
  return Object.fromEntries(
@@ -12459,11 +12580,11 @@ async function readSkillFolder(directory) {
12459
12580
  if (path.toLowerCase().endsWith("/skill.md"))
12460
12581
  refuse("skill_path_invalid", path, "SKILL.md belongs at the root");
12461
12582
  const { size } = await lstat2(join2(directory, path));
12462
- if (size > FILE_MAX_BYTES)
12463
- refuse("skill_file_too_large", path, `at most ${FILE_MAX_BYTES} bytes`);
12583
+ if (size > SKILL_FILE_MAX_BYTES)
12584
+ refuse("skill_file_too_large", path, `at most ${SKILL_FILE_MAX_BYTES} bytes`);
12464
12585
  paths.push({ path, size });
12465
- if (paths.length > MAX_FILES)
12466
- refuse("skill_too_many_files", path, `at most ${MAX_FILES} files`);
12586
+ if (paths.length > SKILL_MAX_FILES)
12587
+ refuse("skill_too_many_files", path, `at most ${SKILL_MAX_FILES} files`);
12467
12588
  }
12468
12589
  }
12469
12590
  };
@@ -12477,11 +12598,11 @@ async function readSkillFolder(directory) {
12477
12598
  refuse("skill_path_duplicate", path, "paths differing only in case count as one");
12478
12599
  seen.add(path.toLowerCase());
12479
12600
  const bytes = await readFile2(join2(directory, path));
12480
- if (bytes.length > FILE_MAX_BYTES)
12481
- refuse("skill_file_too_large", path, `at most ${FILE_MAX_BYTES} bytes`);
12601
+ if (bytes.length > SKILL_FILE_MAX_BYTES)
12602
+ refuse("skill_file_too_large", path, `at most ${SKILL_FILE_MAX_BYTES} bytes`);
12482
12603
  total += bytes.length;
12483
- if (total > FOLDER_MAX_BYTES)
12484
- refuse("skill_too_large", path, `at most ${FOLDER_MAX_BYTES} bytes per skill`);
12604
+ if (total > SKILL_MAX_BYTES)
12605
+ refuse("skill_too_large", path, `at most ${SKILL_MAX_BYTES} bytes per skill`);
12485
12606
  const peAt = bytes.length >= 64 ? bytes.readUInt32LE(60) : bytes.length;
12486
12607
  const pe = bytes[0] === 77 && bytes[1] === 90 && peAt + 4 <= bytes.length && bytes.subarray(peAt, peAt + 4).equals(Buffer.from([80, 69, 0, 0]));
12487
12608
  if (pe || EXECUTABLE_PREFIXES.some((prefix) => prefix.every((byte, index) => bytes[index] === byte)))
@@ -12597,7 +12718,7 @@ var yamlDumpOptions = {
12597
12718
  var KEY_ORDER = ["name", "displayName", "description", "on", "filter", "check", "outcome"];
12598
12719
  function serializeGuardrailFiles(definition2) {
12599
12720
  const { origin: _origin, ...rest } = definition2;
12600
- const check = isRecord3(rest.check) ? rest.check : void 0;
12721
+ const check = isRecord(rest.check) ? rest.check : void 0;
12601
12722
  const instruction = check?.kind === "model_judge" && typeof check.instruction === "string" ? check.instruction : void 0;
12602
12723
  const ordered = {};
12603
12724
  for (const key2 of [...KEY_ORDER, ...Object.keys(rest).sort()]) {
@@ -12618,12 +12739,12 @@ function serializeGuardrailFiles(definition2) {
12618
12739
  }
12619
12740
  function parseGuardrailFiles(input) {
12620
12741
  const data = loadYamlData(input.yaml, input.source);
12621
- if (!isRecord3(data) || typeof data.name !== "string") {
12742
+ if (!isRecord(data) || typeof data.name !== "string") {
12622
12743
  throw new Error(`${input.source} must hold a mapping with a 'name'.`);
12623
12744
  }
12624
12745
  if (input.checkMd === void 0) return { ...data, name: data.name };
12625
12746
  const check = data.check;
12626
- if (!isRecord3(check) || check.kind !== "model_judge") {
12747
+ if (!isRecord(check) || check.kind !== "model_judge") {
12627
12748
  throw new Error(
12628
12749
  `${input.source}: a ${GUARDRAIL_CHECK_FILE} holds the instruction of a 'model_judge' check, and this check is none.`
12629
12750
  );
@@ -12649,9 +12770,6 @@ async function readGuardrailFolder(directory) {
12649
12770
  source: yamlPath
12650
12771
  });
12651
12772
  }
12652
- function isRecord3(value) {
12653
- return typeof value === "object" && value !== null && !Array.isArray(value);
12654
- }
12655
12773
 
12656
12774
  // src/serialization.ts
12657
12775
  import yaml3 from "js-yaml";
@@ -12753,16 +12871,16 @@ var WorkingCopyValidationError = class extends Error {
12753
12871
  };
12754
12872
  function parseManifest(contents, source = MANIFEST_FILENAME) {
12755
12873
  const input = loadYamlData(contents, source);
12756
- if (!isRecord4(input)) {
12874
+ if (!isRecord(input)) {
12757
12875
  throw new Error(`${source} must contain a YAML object`);
12758
12876
  }
12759
12877
  const instancesInput = input.instances;
12760
- if (!isRecord4(instancesInput)) {
12878
+ if (!isRecord(instancesInput)) {
12761
12879
  throw new Error(`${source} must define an instances mapping`);
12762
12880
  }
12763
12881
  const instances = {};
12764
12882
  for (const [name2, value] of Object.entries(instancesInput)) {
12765
- if (!isRecord4(value) || typeof value.url !== "string" || value.url.length === 0) {
12883
+ if (!isRecord(value) || typeof value.url !== "string" || value.url.length === 0) {
12766
12884
  throw new Error(`${source} instance '${name2}' must define a url`);
12767
12885
  }
12768
12886
  const workspace = readOptionalString(value, "workspace", `${source} instance '${name2}'`);
@@ -12833,22 +12951,22 @@ async function readStateFile(path) {
12833
12951
  throw error;
12834
12952
  }
12835
12953
  const input = JSON.parse(contents);
12836
- if (!isRecord4(input) || !isRecord4(input.instances)) {
12954
+ if (!isRecord(input) || !isRecord(input.instances)) {
12837
12955
  throw new Error(`${path} must contain an instances object`);
12838
12956
  }
12839
12957
  const instances = {};
12840
12958
  for (const [name2, value] of Object.entries(input.instances)) {
12841
- if (!isRecord4(value) || typeof value.lastPulledVersion !== "number" || !Number.isInteger(value.lastPulledVersion) || value.lastPulledVersion < 0) {
12959
+ if (!isRecord(value) || typeof value.lastPulledVersion !== "number" || !Number.isInteger(value.lastPulledVersion) || value.lastPulledVersion < 0) {
12842
12960
  throw new Error(`${path} has an invalid lastPulledVersion for '${name2}'`);
12843
12961
  }
12844
12962
  const baseline = { lastPulledVersion: value.lastPulledVersion };
12845
12963
  if (value.assets !== void 0) {
12846
- if (!isRecord4(value.assets)) {
12964
+ if (!isRecord(value.assets)) {
12847
12965
  throw new Error(`${path} has invalid asset baselines for '${name2}'`);
12848
12966
  }
12849
12967
  baseline.assets = {};
12850
12968
  for (const [key2, asset] of Object.entries(value.assets)) {
12851
- if (!ASSET_KEY_PATTERN.test(key2) || !isRecord4(asset) || typeof asset.revision !== "number" || !Number.isInteger(asset.revision) || asset.revision < 1 || typeof asset.hash !== "string" || !/^[a-f0-9]{64}$/u.test(asset.hash) || asset.canonicalFormVersion !== void 0 && (typeof asset.canonicalFormVersion !== "number" || !Number.isInteger(asset.canonicalFormVersion) || asset.canonicalFormVersion < 1) || asset.id !== void 0 && typeof asset.id !== "string" || !(asset.draftRevision === void 0 || asset.draftRevision === null || typeof asset.draftRevision === "number" && Number.isInteger(asset.draftRevision) && asset.draftRevision >= 1) || asset.files !== void 0 && (!isRecord4(asset.files) || Object.values(asset.files).some(
12969
+ if (!ASSET_KEY_PATTERN.test(key2) || !isRecord(asset) || typeof asset.revision !== "number" || !Number.isInteger(asset.revision) || asset.revision < 1 || typeof asset.hash !== "string" || !/^[a-f0-9]{64}$/u.test(asset.hash) || asset.canonicalFormVersion !== void 0 && (typeof asset.canonicalFormVersion !== "number" || !Number.isInteger(asset.canonicalFormVersion) || asset.canonicalFormVersion < 1) || asset.id !== void 0 && typeof asset.id !== "string" || !(asset.draftRevision === void 0 || asset.draftRevision === null || typeof asset.draftRevision === "number" && Number.isInteger(asset.draftRevision) && asset.draftRevision >= 1) || asset.files !== void 0 && (!isRecord(asset.files) || Object.values(asset.files).some(
12852
12970
  (hash2) => typeof hash2 !== "string" || !/^[a-f0-9]{64}$/u.test(hash2)
12853
12971
  )) || asset.draftPushed !== void 0 && asset.draftPushed !== true) {
12854
12972
  throw new Error(`${path} has an invalid asset baseline for '${key2}'`);
@@ -12865,13 +12983,13 @@ async function readStateFile(path) {
12865
12983
  }
12866
12984
  }
12867
12985
  if (value.deleted !== void 0) {
12868
- if (!isRecord4(value.deleted)) {
12986
+ if (!isRecord(value.deleted)) {
12869
12987
  throw new Error(`${path} has invalid deleted-asset baselines for '${name2}'`);
12870
12988
  }
12871
12989
  baseline.deleted = {};
12872
12990
  for (const [key2, entry] of Object.entries(value.deleted)) {
12873
12991
  const deleted = typeof entry === "number" ? { revision: entry } : entry;
12874
- if (!ASSET_KEY_PATTERN.test(key2) || !isRecord4(deleted) || typeof deleted.revision !== "number" || !Number.isInteger(deleted.revision) || deleted.revision < 1 || deleted.id !== void 0 && typeof deleted.id !== "string") {
12992
+ if (!ASSET_KEY_PATTERN.test(key2) || !isRecord(deleted) || typeof deleted.revision !== "number" || !Number.isInteger(deleted.revision) || deleted.revision < 1 || deleted.id !== void 0 && typeof deleted.id !== "string") {
12875
12993
  throw new Error(`${path} has an invalid deleted-asset baseline for '${key2}'`);
12876
12994
  }
12877
12995
  baseline.deleted[key2] = {
@@ -12891,7 +13009,7 @@ async function readStateFile(path) {
12891
13009
  return { instances };
12892
13010
  }
12893
13011
  function readBaselineHashes(input) {
12894
- if (!isRecord4(input)) throw new Error("Invalid skill file hashes");
13012
+ if (!isRecord(input)) throw new Error("Invalid skill file hashes");
12895
13013
  return Object.fromEntries(
12896
13014
  Object.entries(input).map(([path, hash2]) => {
12897
13015
  if (typeof hash2 !== "string") throw new Error(`Invalid skill file hash: ${path}`);
@@ -12938,7 +13056,7 @@ async function readWorkingCopy(workingDir, manifest) {
12938
13056
  const parsedMarkdown = parseSkillMarkdown(contents, file, toPosixPath(path));
12939
13057
  const { resources, files } = await readSkillFolder(dirname3(path));
12940
13058
  const parsed = skillConfigSchema.safeParse(
12941
- isRecord4(parsedMarkdown) ? { ...parsedMarkdown, ...resources.length ? { resources } : {} } : parsedMarkdown
13059
+ isRecord(parsedMarkdown) ? { ...parsedMarkdown, ...resources.length ? { resources } : {} } : parsedMarkdown
12942
13060
  );
12943
13061
  if (parsed.success) {
12944
13062
  skills.push(parsed.data);
@@ -13181,11 +13299,11 @@ function schemaIssues(file, issues) {
13181
13299
  }));
13182
13300
  }
13183
13301
  function extractErrorIssues(file, error) {
13184
- if (!isRecord4(error) || !isRecord4(error.details) || !Array.isArray(error.details.issues)) {
13302
+ if (!isRecord(error) || !isRecord(error.details) || !Array.isArray(error.details.issues)) {
13185
13303
  return [];
13186
13304
  }
13187
13305
  return error.details.issues.flatMap((issue) => {
13188
- if (!isRecord4(issue) || typeof issue.message !== "string") {
13306
+ if (!isRecord(issue) || typeof issue.message !== "string") {
13189
13307
  return [];
13190
13308
  }
13191
13309
  const path = Array.isArray(issue.path) ? issue.path.map(String).join(".") : void 0;
@@ -13198,9 +13316,6 @@ function toRelativePath(root, path) {
13198
13316
  function toPosixPath(path) {
13199
13317
  return path.split(sep2).join("/");
13200
13318
  }
13201
- function isRecord4(value) {
13202
- return typeof value === "object" && value !== null && !Array.isArray(value);
13203
- }
13204
13319
  function isNodeError2(error) {
13205
13320
  return error instanceof Error && "code" in error;
13206
13321
  }
@@ -13286,7 +13401,7 @@ async function fetchRemoteAsset(api, kind, name2) {
13286
13401
  throw new Error(`The skill '${name2}' cannot be read with all its files.`);
13287
13402
  for (const file of asset.files) {
13288
13403
  const bytes = file.base64 === void 0 ? Buffer.from(file.text ?? "", "utf8") : Buffer.from(file.base64, "base64");
13289
- if (sha256(bytes) !== file.sha256)
13404
+ if (sha256Hex(bytes) !== file.sha256)
13290
13405
  throw new Error(
13291
13406
  `The file '${file.path}' did not arrive as the instance holds it (its SHA-256 differs). Pull again.`
13292
13407
  );
@@ -13316,7 +13431,7 @@ function readDefinition(remote, config) {
13316
13431
  }
13317
13432
  }
13318
13433
  function guardrailAsFiles(config, source) {
13319
- if (!isRecord5(config) || typeof config.name !== "string") {
13434
+ if (!isRecord(config) || typeof config.name !== "string") {
13320
13435
  throw new Error(`The instance answered no guardrail definition for ${source}.`);
13321
13436
  }
13322
13437
  const files = serializeGuardrailFiles(config);
@@ -13455,7 +13570,7 @@ function skillExtraHashes(asset) {
13455
13570
  }
13456
13571
  function sortKeys2(value) {
13457
13572
  if (Array.isArray(value)) return value.map(sortKeys2);
13458
- if (!isRecord5(value)) return value;
13573
+ if (!isRecord(value)) return value;
13459
13574
  return Object.fromEntries(
13460
13575
  Object.keys(value).sort().map((key2) => [key2, sortKeys2(value[key2])])
13461
13576
  );
@@ -13474,7 +13589,7 @@ async function replaceSkillPackage(skillFilePath, skill, provenance, files) {
13474
13589
  directory,
13475
13590
  files.map((file) => ({
13476
13591
  ...file,
13477
- sha256: sha256(fileBytes(file)),
13592
+ sha256: sha256Hex(fileBytes(file)),
13478
13593
  bytes: fileBytes(file).length,
13479
13594
  contentType: "application/octet-stream"
13480
13595
  }))
@@ -13588,9 +13703,6 @@ async function openInstance(options) {
13588
13703
  url: instance.url
13589
13704
  };
13590
13705
  }
13591
- function assetHash(contents) {
13592
- return createHash2("sha256").update(contents).digest("hex");
13593
- }
13594
13706
  async function recordBaseline(workingDir, instanceKey, version, bundle, revisions, fullPull, defaultAgentName, tombstones = {}) {
13595
13707
  const path = resolve4(workingDir, STATE_FILENAME);
13596
13708
  const state = await readStateFile(path);
@@ -13607,7 +13719,7 @@ async function recordBaseline(workingDir, instanceKey, version, bundle, revision
13607
13719
  baseline.assets[asset.key] = {
13608
13720
  ...written,
13609
13721
  canonicalFormVersion: CANONICAL_FORM_VERSION,
13610
- hash: assetHash(asset.contents),
13722
+ hash: sha256Hex(asset.contents),
13611
13723
  ...asset.folderFiles === void 0 ? {} : { files: folderHashes(asset.folderFiles) }
13612
13724
  };
13613
13725
  }
@@ -13661,7 +13773,7 @@ function formatCommandError(error) {
13661
13773
  ${error.issues.map((issue) => `- ${issue.file}${issue.path ? ` (${issue.path})` : ""}: ${issue.message}`).join("\n")}`;
13662
13774
  }
13663
13775
  if (error instanceof ConfigApiError) {
13664
- const reason = isRecord5(error.details) ? error.details.reason : void 0;
13776
+ const reason = isRecord(error.details) ? error.details.reason : void 0;
13665
13777
  if (reason === BODY_TOO_LARGE_REASON) {
13666
13778
  return "The request is larger than the instance accepts in one call. Push in parts with --only.";
13667
13779
  }
@@ -13672,9 +13784,6 @@ ${error.issues.map((issue) => `- ${issue.file}${issue.path ? ` (${issue.path})`
13672
13784
  }
13673
13785
  return error instanceof Error ? error.message : String(error);
13674
13786
  }
13675
- function isRecord5(value) {
13676
- return typeof value === "object" && value !== null && !Array.isArray(value);
13677
- }
13678
13787
  function writeOutput(options, text2) {
13679
13788
  (options.stdout ?? ((value) => process.stdout.write(value)))(`${text2}
13680
13789
  `);
@@ -13697,10 +13806,10 @@ function filesOf(asset) {
13697
13806
  if (asset?.files) return new Map(asset.files.map((file) => [file.path, file.sha256]));
13698
13807
  const result = /* @__PURE__ */ new Map();
13699
13808
  const config = asset?.config;
13700
- if (!isRecord5(config)) return result;
13809
+ if (!isRecord(config)) return result;
13701
13810
  if (Array.isArray(config.files)) {
13702
13811
  for (const file of config.files) {
13703
- if (isRecord5(file) && typeof file.path === "string" && typeof file.content === "string") {
13812
+ if (isRecord(file) && typeof file.path === "string" && typeof file.content === "string") {
13704
13813
  result.set(file.path, file.content);
13705
13814
  }
13706
13815
  }
@@ -13714,9 +13823,9 @@ function filesOf(asset) {
13714
13823
  // src/app-publish-data.ts
13715
13824
  async function appPublishData(api, app, candidate, audienceLabel) {
13716
13825
  const config = candidate.config;
13717
- const manifest = isRecord5(config) && isRecord5(config.manifest) ? config.manifest : void 0;
13826
+ const manifest = isRecord(config) && isRecord(config.manifest) ? config.manifest : void 0;
13718
13827
  const reads = Array.isArray(manifest?.actions) && manifest.actions.some(
13719
- (action) => isRecord5(action) && action.kind === "sql" && action.effect === "reading"
13828
+ (action) => isRecord(action) && action.kind === "sql" && action.effect === "reading"
13720
13829
  );
13721
13830
  if (!reads) return "";
13722
13831
  const revision = candidate.contentRevision ?? candidate.revision;
@@ -13756,7 +13865,8 @@ function formatStoredData(data, audienceLabel) {
13756
13865
  }
13757
13866
 
13758
13867
  // src/app-publish-together.ts
13759
- var NONE = { workflows: [], lines: [] };
13868
+ var NONE = { workflows: [], dataStores: [], lines: [] };
13869
+ var migrationCount = (count3) => `${count3} migration${count3 === 1 ? "" : "s"}`;
13760
13870
  async function appPublishTogether(api, app) {
13761
13871
  let review;
13762
13872
  try {
@@ -13766,17 +13876,28 @@ async function appPublishTogether(api, app) {
13766
13876
  throw error;
13767
13877
  }
13768
13878
  const pending = review.workflows.filter((workflow) => workflow.pending);
13769
- if (pending.length === 0) return NONE;
13879
+ const stores = review.dataStores;
13880
+ if (pending.length === 0 && stores.length === 0) return NONE;
13881
+ const storeLines = stores.map(
13882
+ (store) => ` Data Store '${store.title}' (${store.name}): ${!store.pending ? `live at revision ${store.draftRevision}, still applying migrations: the publish waits for it` : store.publishedRevision === void 0 ? `new, revision ${store.draftRevision}` : `revision ${store.draftRevision} in place of ${store.publishedRevision}`}, at level ${store.liveLevel}${store.pendingMigrations.length > 0 ? `, applies ${migrationCount(store.pendingMigrations.length)}: ${store.pendingMigrations.join(", ")}` : ""}`
13883
+ );
13770
13884
  const named = pending.map(
13771
13885
  (workflow) => ` Workflow '${workflow.title}' (${workflow.name}): ${workflow.publishedRevision === void 0 ? `new, revision ${workflow.draftRevision}` : `revision ${workflow.draftRevision} in place of ${workflow.publishedRevision}`}${workflow.lastChangedBy ? `, last changed by ${workflow.lastChangedBy}` : ""}${workflow.lastTestRun ? `, last test run ${workflow.lastTestRun.status}` : ", not tested"}`
13772
13886
  );
13773
- const refusals = pending.flatMap(
13774
- (workflow) => workflow.refusals.map((refusal) => ` Workflow '${workflow.name}': ${refusal.message}`)
13775
- );
13887
+ const refusals = [
13888
+ ...stores.flatMap(
13889
+ (store) => store.refusals.map((refusal) => ` Data Store '${store.name}': ${refusal.message}`)
13890
+ ),
13891
+ ...pending.flatMap(
13892
+ (workflow) => workflow.refusals.map((refusal) => ` Workflow '${workflow.name}': ${refusal.message}`)
13893
+ )
13894
+ ];
13776
13895
  return {
13777
13896
  workflows: pending.map(({ name: name2, draftRevision }) => ({ name: name2, revision: draftRevision })),
13897
+ dataStores: stores.filter((store) => store.pending).map(({ name: name2, draftRevision }) => ({ name: name2, revision: draftRevision })),
13778
13898
  lines: [
13779
- "Publishes together, Workflows first and the App last, or none of them:",
13899
+ stores.length > 0 ? "Publishes together: the Data Stores and their migrations first, then the Workflows and the App, or neither the App nor its Workflows:" : "Publishes together, Workflows first and the App last, or none of them:",
13900
+ ...storeLines,
13780
13901
  ...named,
13781
13902
  ` App '${review.app.title}' (${app})`,
13782
13903
  ...refusals.length > 0 ? ["Would refuse it now:", ...refusals] : []
@@ -13789,39 +13910,57 @@ import { lstat as lstat3, readFile as readFile6, readdir as readdir4 } from "fs/
13789
13910
  import { join as join5, relative as relative3, sep as sep4 } from "path";
13790
13911
  var APP_STATE_FILE = ".catalyst-app.json";
13791
13912
  var IGNORED_FOLDERS = /* @__PURE__ */ new Set(["node_modules"]);
13792
- async function readAppState(directory) {
13793
- const state = await readFolderState(directory, APP_STATE_FILE, "app");
13913
+ var REPOSITORY_KINDS = {
13914
+ app: { kind: "app", label: "App", plural: "Apps", article: "An", manifest: "app.yaml" },
13915
+ workflow: {
13916
+ kind: "workflow",
13917
+ label: "Workflow",
13918
+ plural: "Workflows",
13919
+ article: "A",
13920
+ manifest: "workflow.yaml"
13921
+ }
13922
+ };
13923
+ async function readRepositoryState(directory, kind) {
13924
+ const state = await readFolderState(directory, APP_STATE_FILE, kind.kind);
13794
13925
  if (state === void 0) return void 0;
13795
- const { name: name2, ...base } = state;
13796
- return { ...base, app: name2 };
13797
- }
13798
- async function writeAppState(directory, state) {
13799
- await writeFolderState(directory, APP_STATE_FILE, state);
13926
+ return state;
13927
+ }
13928
+ async function writeRepositoryState(directory, state, kind) {
13929
+ await writeFolderState(directory, APP_STATE_FILE, {
13930
+ instance: state.instance,
13931
+ workspaceId: state.workspaceId,
13932
+ [kind.kind]: state.name,
13933
+ assetId: state.assetId,
13934
+ revision: state.revision,
13935
+ files: state.files
13936
+ });
13800
13937
  }
13801
- async function readAppFolder(directory, limits, tracked) {
13938
+ async function readRepositoryFolder(directory, limits, tracked, kind) {
13802
13939
  const stats = await lstat3(directory).catch(() => void 0);
13803
13940
  if (!stats?.isDirectory()) {
13804
- throw new Error(`'${directory}' is not a folder. An App is pushed from its folder.`);
13941
+ throw new Error(
13942
+ `'${directory}' is not a folder. ${kind.article} ${kind.label} is pushed from its folder.`
13943
+ );
13805
13944
  }
13806
13945
  const found = [];
13807
13946
  const leftOut = [];
13808
13947
  await walk(directory, directory, tracked, found, leftOut);
13809
- if (!found.some((file) => file.path === "app.yaml")) {
13948
+ if (!found.some((file) => file.path === kind.manifest)) {
13810
13949
  throw new Error(
13811
- `'${directory}' holds no app.yaml at its root. An App's folder starts with it.`
13950
+ `'${directory}' holds no ${kind.manifest} at its root. ${kind.article} ${kind.label}'s folder starts with it.`
13812
13951
  );
13813
13952
  }
13814
13953
  if (limits) {
13815
13954
  if (found.length > limits.FILE_SET_MAX_FILES) {
13816
13955
  throw new Error(
13817
- `'${directory}' holds ${found.length} files to send, and an App holds at most ${limits.FILE_SET_MAX_FILES}.`
13956
+ `'${directory}' holds ${found.length} files to send, and ${kind.article.toLowerCase()} ${kind.label} holds at most ${limits.FILE_SET_MAX_FILES}.`
13818
13957
  );
13819
13958
  }
13820
13959
  const large = found.filter((file) => file.bytes > limits.FILE_SET_MAX_FILE_BYTES);
13821
13960
  if (large.length > 0) {
13822
13961
  throw new Error(
13823
13962
  [
13824
- `A file of an App holds at most ${formatBytes(limits.FILE_SET_MAX_FILE_BYTES)}. Keep larger media as Managed Files. Too large:`,
13963
+ `A file of ${kind.article.toLowerCase()} ${kind.label} holds at most ${formatBytes(limits.FILE_SET_MAX_FILE_BYTES)}. Keep larger media as Managed Files. Too large:`,
13825
13964
  ...large.map((file) => `- ${file.path}: ${formatBytes(file.bytes)}`)
13826
13965
  ].join("\n")
13827
13966
  );
@@ -13830,7 +13969,7 @@ async function readAppFolder(directory, limits, tracked) {
13830
13969
  const cap = Math.min(limits.FILE_SET_MAX_TOTAL_BYTES, limits.ASSET_PUT_FILES_MAX_BYTES);
13831
13970
  if (total > cap) {
13832
13971
  throw new Error(
13833
- `The files to send hold ${formatBytes(total)} together, and one push of an App carries at most ${formatBytes(cap)}.`
13972
+ `The files to send hold ${formatBytes(total)} together, and one push of ${kind.article.toLowerCase()} ${kind.label} carries at most ${formatBytes(cap)}.`
13834
13973
  );
13835
13974
  }
13836
13975
  }
@@ -13838,7 +13977,7 @@ async function readAppFolder(directory, limits, tracked) {
13838
13977
  const hashes = {};
13839
13978
  for (const file of found.sort((left, right) => compare(left.path, right.path))) {
13840
13979
  const bytes = await readFile6(file.absolute);
13841
- hashes[file.path] = sha256(bytes);
13980
+ hashes[file.path] = sha256Hex(bytes);
13842
13981
  const text2 = utf8Text2(bytes);
13843
13982
  files.push(
13844
13983
  text2 === void 0 ? { path: file.path, base64: Buffer.from(bytes).toString("base64") } : { path: file.path, text: text2 }
@@ -14000,7 +14139,7 @@ function formatRefusal(error) {
14000
14139
  return [head, ...detailLines(error.details)].join("\n");
14001
14140
  }
14002
14141
  function detailLines(details) {
14003
- if (!isRecord6(details)) return [];
14142
+ if (!isRecord(details)) return [];
14004
14143
  const lines = [];
14005
14144
  for (const issue of records(details.issues)) {
14006
14145
  lines.push(`- ${issueLocation(issue)}${String(issue.message)}`);
@@ -14014,7 +14153,7 @@ function detailLines(details) {
14014
14153
  lines.push(`- ${String(asset.kind)} '${String(asset.name)}' names no revision`);
14015
14154
  }
14016
14155
  for (const item of records(details.items)) {
14017
- if (isRecord6(item.error)) {
14156
+ if (isRecord(item.error)) {
14018
14157
  lines.push(
14019
14158
  `- ${String(item.kind)} '${String(item.name ?? item.index)}': ${String(item.error.message)}`
14020
14159
  );
@@ -14047,10 +14186,7 @@ function table(head, rows) {
14047
14186
  ).join("\n");
14048
14187
  }
14049
14188
  function records(value) {
14050
- return Array.isArray(value) ? value.filter(isRecord6) : [];
14051
- }
14052
- function isRecord6(value) {
14053
- return typeof value === "object" && value !== null && !Array.isArray(value);
14189
+ return Array.isArray(value) ? value.filter(isRecord) : [];
14054
14190
  }
14055
14191
  function formatDryRun(name2, answer) {
14056
14192
  const people = (count3) => `${count3.actions} action${count3.actions === 1 ? "" : "s"} by ${count3.people} ${count3.people === 1 ? "person" : "people"}`;
@@ -14096,7 +14232,7 @@ function waitingPublishLine(run, approvalHint) {
14096
14232
  }
14097
14233
  function agentPublishRefusalHint(error) {
14098
14234
  if (!(error instanceof ConfigApiError) || error.status !== 403) return void 0;
14099
- const reason = isRecord5(error.details) ? error.details.reason : void 0;
14235
+ const reason = isRecord(error.details) ? error.details.reason : void 0;
14100
14236
  const keyRefused = reason === "user_only" || reason === "outside_key_scope" || error.message.includes(`'${PUBLISH_SCOPE}'`);
14101
14237
  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.";
14102
14238
  }
@@ -14105,7 +14241,7 @@ var PUBLISH_SCOPE = "config_assets:publish";
14105
14241
  // src/app-commands.ts
14106
14242
  var EXIT = { done: 0, refused: 1, usage: 2, pending: 3 };
14107
14243
  var APP_KIND = "app";
14108
- var AppUsageError = class extends Error {
14244
+ var RepositoryUsageError = class extends Error {
14109
14245
  };
14110
14246
  var APP_VERBS = {
14111
14247
  pull: {
@@ -14125,39 +14261,45 @@ var APP_VERBS = {
14125
14261
  summary: "The draft and the published revision, and what a pulled folder changed"
14126
14262
  }
14127
14263
  };
14128
- function isAppVerb(value) {
14264
+ function isRepositoryVerb(value) {
14129
14265
  return Object.hasOwn(APP_VERBS, value);
14130
14266
  }
14131
- async function runAppCommand(verb, positionals, values, options) {
14267
+ async function runRepositoryCommand(verb, positionals, values, options, kind) {
14132
14268
  switch (verb) {
14133
14269
  case "pull": {
14134
14270
  const [app, dir, ...extra] = positionals;
14135
- if (app === void 0) throw new AppUsageError(`Usage: catalyst app ${APP_VERBS.pull.usage}`);
14271
+ if (app === void 0)
14272
+ throw new RepositoryUsageError(
14273
+ `Usage: catalyst ${kind.kind} ${APP_VERBS.pull.usage.replace("<app>", `<${kind.kind}>`)}`
14274
+ );
14136
14275
  refuseExtra(extra);
14137
14276
  if (values.published && values.revision !== void 0) {
14138
- throw new AppUsageError("Pass --published or --revision, not both.");
14277
+ throw new RepositoryUsageError("Pass --published or --revision, not both.");
14139
14278
  }
14140
- return pull(app, resolve5(options.cwd, dir ?? app), values, options);
14279
+ return pull(app, resolve5(options.cwd, dir ?? app), values, options, kind);
14141
14280
  }
14142
14281
  case "push": {
14143
14282
  const [dir, ...extra] = positionals;
14144
14283
  refuseExtra(extra);
14145
14284
  refuseRevisionFlags(values, "push");
14146
- return push(resolve5(options.cwd, dir ?? "."), values, options);
14285
+ return push(resolve5(options.cwd, dir ?? "."), values, options, kind);
14147
14286
  }
14148
14287
  case "publish": {
14149
14288
  const [app, ...extra] = positionals;
14150
14289
  if (app === void 0) {
14151
- throw new AppUsageError(`Usage: catalyst app ${APP_VERBS.publish.usage}`);
14290
+ throw new RepositoryUsageError(`Usage: catalyst app ${APP_VERBS.publish.usage}`);
14152
14291
  }
14153
14292
  refuseExtra(extra);
14154
- if (values.published) throw new AppUsageError("--published is not an option of 'publish'.");
14293
+ if (values.published)
14294
+ throw new RepositoryUsageError("--published is not an option of 'publish'.");
14155
14295
  return publish(app, values, options);
14156
14296
  }
14157
14297
  case "status": {
14158
14298
  const [app, dir, ...extra] = positionals;
14159
14299
  if (app === void 0) {
14160
- throw new AppUsageError(`Usage: catalyst app ${APP_VERBS.status.usage}`);
14300
+ throw new RepositoryUsageError(
14301
+ `Usage: catalyst ${kind.kind} ${APP_VERBS.status.usage.replace("<app>", `<${kind.kind}>`)}`
14302
+ );
14161
14303
  }
14162
14304
  refuseExtra(extra);
14163
14305
  refuseRevisionFlags(values, "status");
@@ -14165,26 +14307,29 @@ async function runAppCommand(verb, positionals, values, options) {
14165
14307
  app,
14166
14308
  dir === void 0 ? void 0 : resolve5(options.cwd, dir),
14167
14309
  values,
14168
- options
14310
+ options,
14311
+ kind
14169
14312
  );
14170
14313
  }
14171
14314
  }
14172
14315
  }
14173
- async function pull(app, directory, values, options) {
14174
- const previous = await readAppState(directory);
14316
+ async function pull(app, directory, values, options, kind) {
14317
+ const previous = await readRepositoryState(directory, kind);
14175
14318
  if (previous === void 0 && !await folderIsEmpty(directory)) {
14176
- throw new AppUsageError(
14177
- `'${directory}' holds files and no pulled App. Pull into an empty or new folder.`
14319
+ throw new RepositoryUsageError(
14320
+ `'${directory}' holds files and no pulled ${kind.label}. Pull into an empty or new folder.`
14178
14321
  );
14179
14322
  }
14180
- if (previous !== void 0 && previous.app !== app) {
14181
- throw new AppUsageError(`'${directory}' holds the App '${previous.app}', not '${app}'.`);
14323
+ if (previous !== void 0 && previous.name !== app) {
14324
+ throw new RepositoryUsageError(
14325
+ `'${directory}' holds the ${kind.label} '${previous.name}', not '${app}'.`
14326
+ );
14182
14327
  }
14183
14328
  if (previous !== void 0) {
14184
14329
  const changes = await localChanges2(directory, previous);
14185
14330
  const touched = [...changes.changed, ...changes.added, ...changes.removed];
14186
14331
  if (touched.length > 0) {
14187
- throw new AppUsageError(
14332
+ throw new RepositoryUsageError(
14188
14333
  [
14189
14334
  `'${directory}' has local changes a pull would overwrite. Push them, or pull into another folder to compare:`,
14190
14335
  ...touched.sort().map((path) => `- ${path}`)
@@ -14193,11 +14338,11 @@ async function pull(app, directory, values, options) {
14193
14338
  }
14194
14339
  }
14195
14340
  if (values.revision !== void 0) revisionNumber(values.revision);
14196
- const target = await openApp(options, values, previous);
14341
+ const target = await openRepository(options, values, previous, kind);
14197
14342
  const revision = values.published ? "published" : values.revision ?? "draft";
14198
14343
  const asset = await target.api.read(
14199
14344
  (client) => client.assets.get({
14200
- params: { kind: APP_KIND, name: app },
14345
+ params: { kind: kind.kind, name: app },
14201
14346
  query: { workspaceId: target.workspaceId, revision, files: "true" }
14202
14347
  })
14203
14348
  );
@@ -14208,61 +14353,94 @@ async function pull(app, directory, values, options) {
14208
14353
  }
14209
14354
  const contentRevision = asset.contentRevision ?? asset.revision;
14210
14355
  const hashes = await writeFolderFiles(directory, asset.files, previous);
14211
- await writeAppState(directory, {
14212
- instance: target.url,
14213
- workspaceId: target.workspaceId,
14214
- app,
14215
- assetId: asset.id,
14216
- revision: contentRevision,
14217
- files: hashes
14218
- });
14356
+ await writeRepositoryState(
14357
+ directory,
14358
+ {
14359
+ instance: target.url,
14360
+ workspaceId: target.workspaceId,
14361
+ name: app,
14362
+ assetId: asset.id,
14363
+ revision: contentRevision,
14364
+ files: hashes
14365
+ },
14366
+ kind
14367
+ );
14219
14368
  const which = contentRevision === asset.draftRevision ? "the draft" : contentRevision === asset.publishedRevision ? "the published revision" : "revision";
14220
14369
  writeOut(
14221
14370
  options,
14222
- values.json ? JSON.stringify({ app, revision: contentRevision, directory, files: hashes }, null, 2) : `Pulled ${which} ${contentRevision} of App '${app}' into ${directory} (${asset.files.length} files).${contentRevision !== asset.draftRevision ? ` The draft is revision ${asset.draftRevision ?? asset.revision}; a push from this folder is refused until it is pulled from the draft.` : ""}`
14371
+ values.json ? JSON.stringify(
14372
+ { [kind.kind]: app, revision: contentRevision, directory, files: hashes },
14373
+ null,
14374
+ 2
14375
+ ) : `Pulled ${which} ${contentRevision} of ${kind.label} '${app}' into ${directory} (${asset.files.length} files).${contentRevision !== asset.draftRevision ? ` The draft is revision ${asset.draftRevision ?? asset.revision}; a push from this folder is refused until it is pulled from the draft.` : ""}`
14223
14376
  );
14224
14377
  return EXIT.done;
14225
14378
  }
14226
- async function push(directory, values, options) {
14227
- const state = await readAppState(directory);
14228
- const target = await openApp(options, values, state);
14229
- const kind = target.kinds.find((candidate) => candidate.kind === APP_KIND);
14230
- if (kind === void 0) {
14231
- throw new Error("The instance has no Apps you can reach: its kinds do not include 'app'.");
14379
+ async function push(directory, values, options, kind) {
14380
+ const state = await readRepositoryState(directory, kind);
14381
+ const target = await openRepository(options, values, state, kind);
14382
+ const registered = target.kinds.find((candidate) => candidate.kind === kind.kind);
14383
+ if (registered === void 0) {
14384
+ throw new Error(
14385
+ `The instance has no ${kind.plural} you can reach: its kinds do not include '${kind.kind}'.`
14386
+ );
14232
14387
  }
14233
- const read2 = await readAppFolder(
14388
+ const read2 = await readRepositoryFolder(
14234
14389
  directory,
14235
- kind.limits,
14236
- new Set(Object.keys(state?.files ?? {}))
14390
+ registered.limits,
14391
+ new Set(Object.keys(state?.files ?? {})),
14392
+ kind
14237
14393
  );
14238
- const name2 = state?.app ?? appIdOf(read2.files);
14394
+ const name2 = state?.name ?? repositoryIdOf(read2.files, kind);
14239
14395
  if (state === void 0 && name2 === void 0) {
14240
- throw new AppUsageError(
14241
- "app.yaml names no `id`. The id is the App's name on the instance: add `id: <name>` to app.yaml."
14396
+ throw new RepositoryUsageError(
14397
+ `${kind.manifest} names no \`id\`. The id is the ${kind.label}'s name on the instance: add \`id: <name>\` to ${kind.manifest}.`
14242
14398
  );
14243
14399
  }
14244
14400
  const app = name2 ?? "";
14245
- const declared = state === void 0 ? void 0 : declaredIdOf(read2.files);
14246
- if (state !== void 0 && declared !== void 0 && declared !== state.app) {
14247
- throw new AppUsageError(
14248
- `app.yaml names the id '${declared}', and '${directory}' holds the App '${state.app}'. An App keeps its id: set \`id: ${state.app}\` again, or copy the files without ${APP_STATE_FILE} into a new folder to create the App '${declared}'.`
14401
+ const declared = state === void 0 ? void 0 : declaredIdOf(read2.files, kind);
14402
+ if (state !== void 0 && declared !== void 0 && declared !== state.name) {
14403
+ throw new RepositoryUsageError(
14404
+ `${kind.manifest} names the id '${declared}', and '${directory}' holds the ${kind.label} '${state.name}'. ${kind.article} ${kind.label} keeps its id: set \`id: ${state.name}\` again, or copy the files without ${APP_STATE_FILE} into a new folder to create the ${kind.label} '${declared}'.`
14249
14405
  );
14250
14406
  }
14251
14407
  const expectedRevision = state?.revision ?? null;
14252
14408
  if (state !== void 0 && state.workspaceId !== target.workspaceId) {
14253
- throw new AppUsageError(
14409
+ throw new RepositoryUsageError(
14254
14410
  `'${directory}' was pulled from workspace ${state.workspaceId}, and the command names ${target.workspaceId}.`
14255
14411
  );
14256
14412
  }
14413
+ if (kind.kind === "workflow" && state !== void 0 && Object.keys(read2.hashes).length === Object.keys(state.files).length && Object.entries(read2.hashes).every(([path, hash2]) => state.files[path] === hash2)) {
14414
+ const current = await target.api.read(
14415
+ (client) => client.assets.get({
14416
+ params: { kind: kind.kind, name: app },
14417
+ query: { workspaceId: target.workspaceId }
14418
+ })
14419
+ );
14420
+ if ((current.draftRevision ?? current.revision) === state.revision) {
14421
+ writeOut(
14422
+ options,
14423
+ values.json ? JSON.stringify(
14424
+ { revision: state.revision, unchanged: true, leftOut: read2.leftOut },
14425
+ null,
14426
+ 2
14427
+ ) : [
14428
+ `Unchanged ${kind.label} '${app}' at draft revision ${state.revision}.`,
14429
+ ...read2.leftOut.length === 0 ? [] : [`Left out: ${read2.leftOut.join(", ")}`]
14430
+ ].join("\n")
14431
+ );
14432
+ return EXIT.done;
14433
+ }
14434
+ }
14257
14435
  let outcome;
14258
14436
  try {
14259
14437
  outcome = await target.api.change(
14260
14438
  (client, idempotencyKey2) => client.assets.put({
14261
- params: { kind: APP_KIND, name: app },
14439
+ params: { kind: kind.kind, name: app },
14262
14440
  body: { files: read2.files, expectedRevision, workspaceId: target.workspaceId },
14263
14441
  idempotencyKey: idempotencyKey2
14264
14442
  }),
14265
- `It may have been written: run 'catalyst app status ${app}' before pushing again.`
14443
+ `It may have been written: run 'catalyst ${kind.kind} status ${app}' before pushing again.`
14266
14444
  );
14267
14445
  } catch (error) {
14268
14446
  if (error instanceof ConfigApiError && (error.status === 412 || error.status === 409 && expectedRevision === null)) {
@@ -14270,7 +14448,7 @@ async function push(directory, values, options) {
14270
14448
  options,
14271
14449
  [
14272
14450
  formatRefusal(error),
14273
- expectedRevision === null ? `An App named '${app}' exists already. If it is yours, pull it into an empty folder and copy your files there.` : `The draft moved since revision ${expectedRevision} was pulled. Nothing was written. Pull the App into another folder, carry your changes over, and push from there.`
14451
+ expectedRevision === null ? `${kind.article} ${kind.label} named '${app}' exists already. If it is yours, pull it into an empty folder and copy your files there.` : `The draft moved since revision ${expectedRevision} was pulled. Nothing was written. Pull the ${kind.label} into another folder, carry your changes over, and push from there.`
14274
14452
  ].join("\n")
14275
14453
  );
14276
14454
  return EXIT.refused;
@@ -14283,22 +14461,26 @@ async function push(directory, values, options) {
14283
14461
  const output = outcome.output;
14284
14462
  const asset = await target.api.read(
14285
14463
  (client) => client.assets.get({
14286
- params: { kind: APP_KIND, name: app },
14464
+ params: { kind: kind.kind, name: app },
14287
14465
  query: { workspaceId: target.workspaceId }
14288
14466
  })
14289
14467
  );
14290
- await writeAppState(directory, {
14291
- instance: target.url,
14292
- workspaceId: target.workspaceId,
14293
- app,
14294
- assetId: asset.id,
14295
- revision: output.revision,
14296
- files: read2.hashes
14297
- });
14468
+ await writeRepositoryState(
14469
+ directory,
14470
+ {
14471
+ instance: target.url,
14472
+ workspaceId: target.workspaceId,
14473
+ name: app,
14474
+ assetId: asset.id,
14475
+ revision: output.revision,
14476
+ files: read2.hashes
14477
+ },
14478
+ kind
14479
+ );
14298
14480
  writeOut(
14299
14481
  options,
14300
14482
  values.json ? JSON.stringify({ ...output, leftOut: read2.leftOut }, null, 2) : [
14301
- `${expectedRevision === null ? "Created" : "Pushed"} App '${app}' at draft revision ${output.revision} (${read2.files.length} files, built). Publish it with 'catalyst app publish ${app}'.`,
14483
+ `${expectedRevision === null ? "Created" : "Pushed"} ${kind.label} '${app}' at draft revision ${output.revision} (${read2.files.length} files${kind.kind === "app" ? ", built" : ""}). Publish it with 'catalyst ${kind.kind} publish ${app}${kind.kind === "app" ? "" : ` --revision ${output.revision}`}'.`,
14302
14484
  ...read2.leftOut.length === 0 ? [] : [`Left out: ${read2.leftOut.join(", ")}`],
14303
14485
  ...formatWarnings(output.warnings)
14304
14486
  ].join("\n")
@@ -14307,7 +14489,7 @@ async function push(directory, values, options) {
14307
14489
  }
14308
14490
  async function publish(app, values, options) {
14309
14491
  if (values.revision !== void 0) revisionNumber(values.revision);
14310
- const target = await openApp(options, values, void 0);
14492
+ const target = await openRepository(options, values, void 0, REPOSITORY_KINDS.app);
14311
14493
  let audience = readAudience(values.audience);
14312
14494
  const get = (revision, files = false) => target.api.read(
14313
14495
  (client) => client.assets.get({
@@ -14324,7 +14506,7 @@ async function publish(app, values, options) {
14324
14506
  const offered = candidate.appAudience;
14325
14507
  if (!audience) {
14326
14508
  if (values.yes || !options.prompt)
14327
- throw new AppUsageError(
14509
+ throw new RepositoryUsageError(
14328
14510
  "Choose who may use the App with --audience self|workspace|instance. Nothing was published."
14329
14511
  );
14330
14512
  const choices = offered?.choices ?? ["self", "workspace"];
@@ -14333,11 +14515,11 @@ async function publish(app, values, options) {
14333
14515
  );
14334
14516
  audience = readAudience(await options.prompt(`For whom? ${labels.join("; ")}: `));
14335
14517
  if (!audience || !choices.includes(audience))
14336
- throw new AppUsageError("Choose one of the offered audiences. Nothing was published.");
14518
+ throw new RepositoryUsageError("Choose one of the offered audiences. Nothing was published.");
14337
14519
  candidate = await get(values.revision ?? "draft");
14338
14520
  }
14339
14521
  if (offered && !offered.choices.includes(audience))
14340
- throw new AppUsageError("You may not publish to that audience. Nothing was published.");
14522
+ throw new RepositoryUsageError("You may not publish to that audience. Nothing was published.");
14341
14523
  const number = candidate.contentRevision ?? candidate.revision;
14342
14524
  if (values.revision !== void 0 && number !== revisionNumber(values.revision)) {
14343
14525
  throw new Error(`The instance answered revision ${number} for --revision ${values.revision}.`);
@@ -14365,7 +14547,7 @@ async function publish(app, values, options) {
14365
14547
  candidate,
14366
14548
  candidate.appAudience ? `${candidate.appAudience.label}${candidate.appAudience.people === void 0 ? "" : ` (${candidate.appAudience.people} people)`}` : void 0
14367
14549
  );
14368
- const together = number === (candidate.draftRevision ?? candidate.revision) && startsWorkflows(candidate.config) ? await appPublishTogether(target.api, app) : { workflows: [], lines: [] };
14550
+ const together = number === (candidate.draftRevision ?? candidate.revision) && (startsWorkflows(candidate.config) || dataStoresOf(manifestOf(candidate.config)).length > 0) ? await appPublishTogether(target.api, app) : { workflows: [], dataStores: [], lines: [] };
14369
14551
  const question = [formatReview(app, review), storedData, together.lines.join("\n")].filter(Boolean).join("\n");
14370
14552
  const say = (text2) => values.json ? writeErr(options, text2) : writeOut(options, text2);
14371
14553
  const narrative = values.yes ? void 0 : candidate.publishNarrative;
@@ -14400,7 +14582,8 @@ async function publish(app, values, options) {
14400
14582
  revision: number,
14401
14583
  workspaceId: target.workspaceId,
14402
14584
  audience,
14403
- ...together.workflows.length > 0 ? { workflows: together.workflows } : {}
14585
+ ...together.workflows.length > 0 ? { workflows: together.workflows } : {},
14586
+ ...together.dataStores.length > 0 ? { dataStores: together.dataStores } : {}
14404
14587
  },
14405
14588
  idempotencyKey: idempotencyKey2,
14406
14589
  ...answer === "unattended" ? { unattended: true } : {}
@@ -14419,7 +14602,7 @@ async function publish(app, values, options) {
14419
14602
  options,
14420
14603
  values.json ? JSON.stringify(outcome.output, null, 2) : [
14421
14604
  ...(outcome.output.publishedWith ?? []).map(
14422
- (workflow) => `Published revision ${workflow.publishedRevision} of Workflow '${workflow.name}'.`
14605
+ (member) => `Published revision ${member.publishedRevision} of ${member.kind === "data_store" ? "Data Store" : "Workflow"} '${member.name}'.`
14423
14606
  ),
14424
14607
  `Published revision ${outcome.output.publishedRevision} of App '${app}'${outcome.output.replacedRevision === void 0 ? "" : ` in place of revision ${outcome.output.replacedRevision}`}.`
14425
14608
  ].join("\n")
@@ -14427,21 +14610,25 @@ async function publish(app, values, options) {
14427
14610
  return EXIT.done;
14428
14611
  }
14429
14612
  function startsWorkflows(config) {
14430
- const manifest = isRecord7(config) && isRecord7(config.manifest) ? config.manifest : void 0;
14431
- return Array.isArray(manifest?.actions) && manifest.actions.some((action) => isRecord7(action) && action.kind === "workflow");
14613
+ const manifest = isRecord(config) && isRecord(config.manifest) ? config.manifest : void 0;
14614
+ return Array.isArray(manifest?.actions) && manifest.actions.some((action) => isRecord(action) && action.kind === "workflow");
14432
14615
  }
14433
- async function status(app, directory, values, options) {
14434
- const state = directory === void 0 ? void 0 : await readAppState(directory);
14616
+ async function status(app, directory, values, options, kind) {
14617
+ const state = directory === void 0 ? void 0 : await readRepositoryState(directory, kind);
14435
14618
  if (directory !== void 0 && state === void 0) {
14436
- throw new AppUsageError(`'${directory}' holds no pulled App (no ${APP_STATE_FILE}).`);
14619
+ throw new RepositoryUsageError(
14620
+ `'${directory}' holds no pulled ${kind.label} (no ${APP_STATE_FILE}).`
14621
+ );
14437
14622
  }
14438
- if (state !== void 0 && state.app !== app) {
14439
- throw new AppUsageError(`'${directory}' holds the App '${state.app}', not '${app}'.`);
14623
+ if (state !== void 0 && state.name !== app) {
14624
+ throw new RepositoryUsageError(
14625
+ `'${directory}' holds the ${kind.label} '${state.name}', not '${app}'.`
14626
+ );
14440
14627
  }
14441
- const target = await openApp(options, values, state);
14628
+ const target = await openRepository(options, values, state, kind);
14442
14629
  const asset = await target.api.read(
14443
14630
  (client) => client.assets.get({
14444
- params: { kind: APP_KIND, name: app },
14631
+ params: { kind: kind.kind, name: app },
14445
14632
  query: { workspaceId: target.workspaceId }
14446
14633
  })
14447
14634
  );
@@ -14450,16 +14637,17 @@ async function status(app, directory, values, options) {
14450
14637
  target.api,
14451
14638
  app,
14452
14639
  target.workspaceId,
14453
- asset.publishedRevision ?? draft
14640
+ asset.publishedRevision ?? draft,
14641
+ kind
14454
14642
  );
14455
14643
  const by = (revision) => revisions.find((entry) => entry.revision === revision);
14456
14644
  const local = directory === void 0 || state === void 0 ? void 0 : { directory, base: state.revision, ...await localChanges2(directory, state) };
14457
14645
  const report = {
14458
- app,
14646
+ [kind.kind]: app,
14459
14647
  workspaceId: target.workspaceId,
14460
14648
  draftRevision: draft,
14461
14649
  publishedRevision: asset.publishedRevision ?? null,
14462
- kit: kitOf(asset.config),
14650
+ ...kind.kind === "app" ? { kit: kitOf(asset.config) } : {},
14463
14651
  ...local === void 0 ? {} : { local }
14464
14652
  };
14465
14653
  if (values.json) {
@@ -14468,12 +14656,14 @@ async function status(app, directory, values, options) {
14468
14656
  }
14469
14657
  const line = (revision) => revision === void 0 ? "" : ` (${revision.operation} by ${revision.actor?.displayLabel ?? "unknown"}, ${revision.createdAt})`;
14470
14658
  const lines = [
14471
- `App '${app}' in workspace ${target.workspaceId}`,
14659
+ `${kind.label} '${app}' in workspace ${target.workspaceId}`,
14472
14660
  `Draft: revision ${draft}${line(by(draft))}`,
14473
14661
  asset.publishedRevision === void 0 ? "Published: not published yet" : `Published: revision ${asset.publishedRevision}${line(by(asset.publishedRevision))}${asset.publishedRevision === draft ? "; the draft is published" : "; the draft has unpublished changes"}`,
14474
14662
  // A revision exists only once its files built: a push that does not build writes none and
14475
14663
  // prints its errors itself.
14476
- `Build: draft revision ${draft} built${report.kit === void 0 ? "" : ` with kit ${report.kit}`}`
14664
+ ...kind.kind === "app" ? [
14665
+ `Build: draft revision ${draft} built${report.kit === void 0 ? "" : ` with kit ${report.kit}`}`
14666
+ ] : []
14477
14667
  ];
14478
14668
  if (local !== void 0) {
14479
14669
  const touched = [
@@ -14489,13 +14679,13 @@ async function status(app, directory, values, options) {
14489
14679
  writeOut(options, lines.join("\n"));
14490
14680
  return EXIT.done;
14491
14681
  }
14492
- async function revisionsDownTo(api, app, workspaceId, oldest) {
14682
+ async function revisionsDownTo(api, app, workspaceId, oldest, kind) {
14493
14683
  const revisions = [];
14494
14684
  let cursor;
14495
14685
  do {
14496
14686
  const page2 = await api.read(
14497
14687
  (client) => client.assets.revisions.list({
14498
- params: { kind: APP_KIND, name: app },
14688
+ params: { kind: kind.kind, name: app },
14499
14689
  query: { limit: MAX_LIST_LIMIT, workspaceId, ...cursor === void 0 ? {} : { cursor } }
14500
14690
  })
14501
14691
  );
@@ -14553,7 +14743,7 @@ function formatReview(app, review) {
14553
14743
  )
14554
14744
  ].join("\n");
14555
14745
  }
14556
- async function openApp(options, values, state) {
14746
+ async function openRepository(options, values, state, kind) {
14557
14747
  const manifest = await readManifestIfPresent(resolveWorkingDir(options));
14558
14748
  const instance = await resolveInstance(manifest, {
14559
14749
  ...options,
@@ -14561,42 +14751,42 @@ async function openApp(options, values, state) {
14561
14751
  });
14562
14752
  const { url } = instance;
14563
14753
  if (state !== void 0 && state.instance !== url) {
14564
- throw new AppUsageError(
14754
+ throw new RepositoryUsageError(
14565
14755
  `The folder was pulled from ${state.instance}, and the command names ${url}. A folder belongs to one instance.`
14566
14756
  );
14567
14757
  }
14568
14758
  const workspaceId = values.workspace ?? state?.workspaceId ?? instance.workspace;
14569
14759
  if (workspaceId === void 0) {
14570
- throw new AppUsageError(
14571
- "Name the workspace the App belongs to: --workspace <id>, or `workspace: <id>` in catalyst.yaml."
14760
+ throw new RepositoryUsageError(
14761
+ `Name the workspace the ${kind.label} belongs to: --workspace <id>, or \`workspace: <id>\` in catalyst.yaml.`
14572
14762
  );
14573
14763
  }
14574
14764
  const api = await connectApi(url, options);
14575
14765
  const context = await api.read((client) => client.platform.context.get());
14576
14766
  return { api, url, workspaceId, kinds: context.kinds };
14577
14767
  }
14578
- function appIdOf(files) {
14579
- const manifest = files.find((file) => file.path === "app.yaml");
14768
+ function repositoryIdOf(files, kind) {
14769
+ const manifest = files.find((file) => file.path === kind.manifest);
14580
14770
  if (manifest?.text === void 0) return void 0;
14581
14771
  let parsed;
14582
14772
  try {
14583
14773
  parsed = yaml6.load(manifest.text);
14584
14774
  } catch (error) {
14585
- throw new AppUsageError(
14586
- `app.yaml cannot be read: ${error instanceof Error ? error.message : String(error)}`
14775
+ throw new RepositoryUsageError(
14776
+ `${kind.manifest} cannot be read: ${error instanceof Error ? error.message : String(error)}`
14587
14777
  );
14588
14778
  }
14589
- return isRecord7(parsed) && typeof parsed.id === "string" ? parsed.id : void 0;
14779
+ return isRecord(parsed) && typeof parsed.id === "string" ? parsed.id : void 0;
14590
14780
  }
14591
- function declaredIdOf(files) {
14781
+ function declaredIdOf(files, kind) {
14592
14782
  try {
14593
- return appIdOf(files);
14783
+ return repositoryIdOf(files, kind);
14594
14784
  } catch {
14595
14785
  return void 0;
14596
14786
  }
14597
14787
  }
14598
14788
  function manifestOf(config) {
14599
- return isRecord7(config) && isRecord7(config.manifest) ? config.manifest : void 0;
14789
+ return isRecord(config) && isRecord(config.manifest) ? config.manifest : void 0;
14600
14790
  }
14601
14791
  function kitOf(config) {
14602
14792
  const kit = manifestOf(config)?.kit;
@@ -14605,13 +14795,13 @@ function kitOf(config) {
14605
14795
  function actionsOf(manifest) {
14606
14796
  const actions = manifest?.actions;
14607
14797
  return (Array.isArray(actions) ? actions : []).flatMap(
14608
- (action) => isRecord7(action) && typeof action.name === "string" ? [{ name: action.name, effect: action.effect, canonical: canonicalJson(action) }] : []
14798
+ (action) => isRecord(action) && typeof action.name === "string" ? [{ name: action.name, effect: action.effect, canonical: canonicalJson(action) }] : []
14609
14799
  );
14610
14800
  }
14611
14801
  function dataStoresOf(manifest) {
14612
14802
  const stores = manifest?.dataStores;
14613
14803
  return (Array.isArray(stores) ? stores : []).flatMap(
14614
- (store) => isRecord7(store) && typeof store.name === "string" ? [
14804
+ (store) => isRecord(store) && typeof store.name === "string" ? [
14615
14805
  {
14616
14806
  name: store.name,
14617
14807
  ...typeof store.minSchema === "number" ? { minSchema: store.minSchema } : {}
@@ -14621,7 +14811,7 @@ function dataStoresOf(manifest) {
14621
14811
  }
14622
14812
  function canonicalJson(value) {
14623
14813
  if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
14624
- if (isRecord7(value)) {
14814
+ if (isRecord(value)) {
14625
14815
  return `{${Object.keys(value).sort().map((key2) => `${JSON.stringify(key2)}:${canonicalJson(value[key2])}`).join(",")}}`;
14626
14816
  }
14627
14817
  return JSON.stringify(value) ?? "null";
@@ -14630,21 +14820,20 @@ function texts(value) {
14630
14820
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
14631
14821
  }
14632
14822
  function revisionNumber(value) {
14633
- if (!/^[1-9]\d{0,8}$/u.test(value)) throw new AppUsageError(`'${value}' is no revision number.`);
14823
+ if (!/^[1-9]\d{0,8}$/u.test(value))
14824
+ throw new RepositoryUsageError(`'${value}' is no revision number.`);
14634
14825
  return Number(value);
14635
14826
  }
14636
14827
  function refuseExtra(extra) {
14637
- if (extra.length > 0) throw new AppUsageError(`Unexpected argument '${extra[0]}'.`);
14828
+ if (extra.length > 0) throw new RepositoryUsageError(`Unexpected argument '${extra[0]}'.`);
14638
14829
  }
14639
14830
  function refuseRevisionFlags(values, verb) {
14640
- if (values.published) throw new AppUsageError(`--published is not an option of '${verb}'.`);
14831
+ if (values.published)
14832
+ throw new RepositoryUsageError(`--published is not an option of '${verb}'.`);
14641
14833
  if (values.revision !== void 0) {
14642
- throw new AppUsageError(`--revision is not an option of '${verb}'.`);
14834
+ throw new RepositoryUsageError(`--revision is not an option of '${verb}'.`);
14643
14835
  }
14644
14836
  }
14645
- function isRecord7(value) {
14646
- return typeof value === "object" && value !== null && !Array.isArray(value);
14647
- }
14648
14837
  function writeOut(target, text2) {
14649
14838
  (target.stdout ?? ((value) => process.stdout.write(value)))(`${text2}
14650
14839
  `);
@@ -14661,7 +14850,9 @@ function pendingApproval(run, json2, options, hint) {
14661
14850
  function readAudience(value) {
14662
14851
  if (value === void 0) return void 0;
14663
14852
  if (value === "self" || value === "workspace" || value === "instance") return value;
14664
- throw new AppUsageError("--audience must be self, workspace or instance. Nothing was published.");
14853
+ throw new RepositoryUsageError(
14854
+ "--audience must be self, workspace or instance. Nothing was published."
14855
+ );
14665
14856
  }
14666
14857
 
14667
14858
  // src/follow-commands.ts
@@ -14736,14 +14927,19 @@ Instance:
14736
14927
  requests [--withdraw <id>] List your requests, or withdraw one of them
14737
14928
 
14738
14929
  Assets, for every kind the instance registers (agent, skill, app, workflow, data-store, ...):
14739
- catalyst skill pull <name> <folder>
14740
- Write every file of one skill locally; refresh only a clean earlier pull
14741
- ${verbs.map((verb) => ` catalyst <kind> ${verb.usage}
14742
- ${verb.summary}`).join("\n")}
14930
+ catalyst skill pull <name> <folder> Write every file of one skill locally; refresh only a clean earlier pull
14931
+ ${verbs.map((verb) => ` catalyst <kind> ${verb.usage} ${verb.summary}`).join("\n")}
14743
14932
 
14744
14933
  An App as a folder (its draft is built on push; publish shows what goes live and asks):
14745
- ${Object.values(APP_VERBS).map((verb) => ` catalyst app ${verb.usage}
14746
- ${verb.summary}`).join("\n")}
14934
+ ${Object.values(APP_VERBS).map((verb) => ` catalyst app ${verb.usage} ${verb.summary}`).join("\n")}
14935
+
14936
+ A Workflow as a folder (workflow.yaml at its root, scripts in steps/):
14937
+ catalyst workflow pull <workflow> [dir] [--published | --revision <n>] Write a revision into a folder (assets.get)
14938
+ catalyst workflow push [dir] Send a changed folder as the next draft, or create the Workflow (assets.put)
14939
+ catalyst workflow status <workflow> [dir] Show draft, published revision and local changes
14940
+ catalyst workflow publish <workflow> --revision <n> [--yes] Review and ask before publishing (assets.publish)
14941
+ catalyst workflow history <workflow> List revisions (assets.revisions.list)
14942
+ catalyst workflow revert <workflow> --to <n> --if-revision <n> Restore a revision (assets.revert)
14747
14943
 
14748
14944
  Options:
14749
14945
  --instance <name-or-url> An instance of catalyst.yaml, or its URL. Left out: the
@@ -14850,7 +15046,7 @@ async function pushConfig(options) {
14850
15046
  );
14851
15047
  }
14852
15048
  const touched = assetEntries(bundle).filter(
14853
- (asset) => baselineAssets[asset.key]?.hash !== assetHash(asset.contents)
15049
+ (asset) => baselineAssets[asset.key]?.hash !== sha256Hex(asset.contents)
14854
15050
  );
14855
15051
  const undrafted = touched.filter(
14856
15052
  (asset) => asset.kind === "agent" && baselineAssets[asset.key]?.draftRevision === void 0
@@ -15382,7 +15578,7 @@ async function createPushPlan(api, local, remote, touchedKeys, baseline) {
15382
15578
  }
15383
15579
  const base = baseline?.assets?.[asset.key];
15384
15580
  if (base?.revision === remoteAsset.revision && base.id === remoteAsset.id) {
15385
- return base.hash !== assetHash(asset.contents);
15581
+ return base.hash !== sha256Hex(asset.contents);
15386
15582
  }
15387
15583
  const fetched = await fetchRemoteAsset(api, remoteAsset.kind, remoteAsset.name);
15388
15584
  return fetched === void 0 || assetContents(fetched) !== asset.contents;
@@ -15436,9 +15632,9 @@ function formatPushPlan(plan, prune, guardrailPuts) {
15436
15632
  }
15437
15633
  var FORCE_REFUSED_MESSAGE = "'catalyst config push --force' no longer exists: a push names the revision each asset was pulled at and never overwrites a change it did not read. Where a push reports a conflict, commit or stash local edits, run 'catalyst config pull --only <kind>:<name>' for the assets it names, review with 'catalyst config diff', re-apply the edits and push again.";
15438
15634
  function readDraftConflict(error) {
15439
- const details = isRecord5(error.details) ? error.details : void 0;
15635
+ const details = isRecord(error.details) ? error.details : void 0;
15440
15636
  if (error.code !== "REVISION_CONFLICT" || details?.reason !== "draft_changed") return void 0;
15441
- const author = isRecord5(details.author) ? details.author : void 0;
15637
+ const author = isRecord(details.author) ? details.author : void 0;
15442
15638
  const revision = typeof details.currentDraftRevision === "number" ? details.currentDraftRevision : null;
15443
15639
  return {
15444
15640
  kind: typeof details.kind === "string" ? details.kind : "agent",
@@ -15464,9 +15660,9 @@ async function readTombstones(api, keys) {
15464
15660
  return Object.fromEntries(keys.map((key2, index) => [key2, revisions[index]]));
15465
15661
  }
15466
15662
  function readConflicts(details) {
15467
- const conflicts = isRecord5(details) && Array.isArray(details.conflicts) ? details.conflicts : [];
15663
+ const conflicts = isRecord(details) && Array.isArray(details.conflicts) ? details.conflicts : [];
15468
15664
  return conflicts.flatMap(
15469
- (conflict) => isRecord5(conflict) && typeof conflict.kind === "string" && typeof conflict.name === "string" ? [
15665
+ (conflict) => isRecord(conflict) && typeof conflict.kind === "string" && typeof conflict.name === "string" ? [
15470
15666
  {
15471
15667
  kind: conflict.kind,
15472
15668
  name: conflict.name,
@@ -15479,17 +15675,17 @@ function readConflicts(details) {
15479
15675
  );
15480
15676
  }
15481
15677
  function readRefusedBatch(error) {
15482
- const details = isRecord5(error.details) ? error.details : {};
15678
+ const details = isRecord(error.details) ? error.details : {};
15483
15679
  const defaultAgentConflict = error.code === "CONFLICT" && details.reason === "default_agent_changed";
15484
15680
  if (details.reason !== "sync_refused" && !defaultAgentConflict && error.status !== 422) {
15485
15681
  return void 0;
15486
15682
  }
15487
15683
  const refused = (Array.isArray(details.items) ? details.items : []).flatMap(
15488
- (item) => isRecord5(item) && isRecord5(item.error) ? [{ item, refusal: item.error }] : []
15684
+ (item) => isRecord(item) && isRecord(item.error) ? [{ item, refusal: item.error }] : []
15489
15685
  );
15490
15686
  const label = (item) => `${String(item.kind)}${typeof item.name === "string" ? ` '${item.name}'` : typeof item.index === "number" ? ` #${item.index + 1}` : ""}`;
15491
15687
  const issues = (Array.isArray(details.issues) ? details.issues : []).flatMap(
15492
- (issue) => isRecord5(issue) && typeof issue.message === "string" ? [issue] : []
15688
+ (issue) => isRecord(issue) && typeof issue.message === "string" ? [issue] : []
15493
15689
  );
15494
15690
  return {
15495
15691
  message: error.message,
@@ -15519,7 +15715,7 @@ async function checkSyncOnThisRelease(api, batch) {
15519
15715
  }
15520
15716
  }
15521
15717
  function isMissingCheck(error) {
15522
- return error.status === 404 && !(isRecord5(error.details) && error.details.reason === "sync_refused");
15718
+ return error.status === 404 && !(isRecord(error.details) && error.details.reason === "sync_refused");
15523
15719
  }
15524
15720
  function formatRefusal2(title, refusal) {
15525
15721
  if (refusal.lines.length === 0) {
@@ -15793,7 +15989,7 @@ var pullVerb = {
15793
15989
  options: {},
15794
15990
  prepare: (_values, name2, cwd, noun, folder) => {
15795
15991
  if (noun !== "skill" && noun !== "skills")
15796
- throw new UsageError("'pull' is a command of skills and Apps only.");
15992
+ throw new UsageError("'pull' is a command of skills, Apps and Workflows only.");
15797
15993
  if (!folder) throw new UsageError("Usage: catalyst skill pull <name> <folder>");
15798
15994
  const directory = resolve8(cwd, folder);
15799
15995
  return async (session2) => {
@@ -16569,6 +16765,67 @@ var setDefaultVerb = {
16569
16765
  }
16570
16766
  };
16571
16767
 
16768
+ // src/asset-verbs/adopt.ts
16769
+ var adoptVerb = {
16770
+ usage: "adopt <name> | adopt --all",
16771
+ summary: "Give every revision written before the kind had a repository its commit, with the release key (assets.adopt_repository)",
16772
+ named: false,
16773
+ options: { all: { type: "boolean", default: false } },
16774
+ prepare: (values, name2) => {
16775
+ if (values.all === (name2 !== "")) {
16776
+ throw new UsageError("Name the asset, or pass --all to adopt every one of the kind.");
16777
+ }
16778
+ return async (session2) => {
16779
+ const { kind } = session2.kind;
16780
+ const totals = {
16781
+ adopted: 0,
16782
+ revisions: 0,
16783
+ commits: 0,
16784
+ refused: 0,
16785
+ adoptedAssetIds: [],
16786
+ refusedAssetIds: []
16787
+ };
16788
+ let after;
16789
+ for (; ; ) {
16790
+ const body = {
16791
+ ...name2 === "" ? {} : { name: name2 },
16792
+ ...after === void 0 ? {} : { after }
16793
+ };
16794
+ const outcome = await session2.api.change(
16795
+ (client, idempotencyKey2) => client.assets.adopt_repository({ params: { kind }, body, idempotencyKey: idempotencyKey2 }),
16796
+ "Nothing is lost: run the same command again, and it goes on where it stopped."
16797
+ );
16798
+ if (outcome.status !== "done") return settle(session2, outcome, () => []);
16799
+ const { done, after: next, ...step } = outcome.output;
16800
+ totals.adopted += step.adopted;
16801
+ totals.revisions += step.revisions;
16802
+ totals.commits += step.commits;
16803
+ totals.refused += step.refused;
16804
+ totals.adoptedAssetIds.push(...step.adoptedAssetIds);
16805
+ totals.refusedAssetIds.push(...step.refusedAssetIds);
16806
+ writeError(
16807
+ session2.options,
16808
+ `${totals.adopted} adopted, ${totals.refused} refused, ${totals.commits} commits${done ? "" : " so far"}`
16809
+ );
16810
+ if (done) break;
16811
+ after = next;
16812
+ }
16813
+ print(
16814
+ session2,
16815
+ totals,
16816
+ () => [
16817
+ `Adopted ${totals.adopted} ${kind}${totals.adopted === 1 ? "" : "s"}: ${totals.revisions} revisions, ${totals.commits} commits.`,
16818
+ ...totals.adoptedAssetIds.map((id3) => ` adopted ${id3}`),
16819
+ ...totals.refusedAssetIds.map(
16820
+ (id3) => ` refused ${id3}: the instance's log names the revision and why`
16821
+ )
16822
+ ].join("\n")
16823
+ );
16824
+ return totals.refused > 0 ? EXIT3.refused : EXIT3.done;
16825
+ };
16826
+ }
16827
+ };
16828
+
16572
16829
  // src/asset-verbs/index.ts
16573
16830
  var VERBS = {
16574
16831
  list: listVerb,
@@ -16587,7 +16844,8 @@ var VERBS = {
16587
16844
  delete: deleteVerb,
16588
16845
  revert: revertVerb,
16589
16846
  "set-availability": setAvailabilityVerb,
16590
- "set-default": setDefaultVerb
16847
+ "set-default": setDefaultVerb,
16848
+ adopt: adoptVerb
16591
16849
  };
16592
16850
 
16593
16851
  // src/asset-commands.ts
@@ -16615,7 +16873,13 @@ function parseCommandLine(args) {
16615
16873
  const parsed = parseArgs({ args, options: OPTIONS, allowPositionals: true, strict: true });
16616
16874
  return {
16617
16875
  ...parsed,
16618
- values: { files: false, personal: false, none: false, ...parsed.values }
16876
+ values: {
16877
+ files: false,
16878
+ personal: false,
16879
+ none: false,
16880
+ all: false,
16881
+ ...parsed.values
16882
+ }
16619
16883
  };
16620
16884
  }
16621
16885
  var APP_FLAGS = {
@@ -16702,15 +16966,24 @@ ${assetHelpText}`);
16702
16966
  instanceCommand === "docs" ? verbName : name2
16703
16967
  );
16704
16968
  }
16705
- if ((noun === "app" || noun === "apps") && isAppVerb(verbName)) {
16969
+ const repository = Object.values(REPOSITORY_KINDS).find(
16970
+ (kind) => noun === kind.kind || noun === `${kind.kind}s`
16971
+ );
16972
+ if (repository && isRepositoryVerb(verbName) && (verbName !== "publish" || repository.kind === "app")) {
16706
16973
  refuseFlags(values, [...COMMON_FLAGS, ...APP_FLAGS[verbName]], verbName);
16707
- return await runAppCommand(verbName, positionals.slice(1), values, options);
16974
+ return await runRepositoryCommand(
16975
+ verbName,
16976
+ positionals.slice(1),
16977
+ values,
16978
+ options,
16979
+ repository
16980
+ );
16708
16981
  }
16709
16982
  const verb = VERBS[verbName];
16710
16983
  if (verb === void 0) throw new UsageError(`Unknown command '${noun} ${verbName}'.`);
16711
16984
  refuseFlags(values, [...COMMON_FLAGS, ...Object.keys(verb.options)], verbName);
16712
16985
  if (verb.named && name2 === "") throw new UsageError(`Usage: catalyst ${noun} ${verb.usage}`);
16713
- if (extra.length > (verbName === "pull" ? 1 : 0) || !verb.named && verbName !== "set-default" && name2 !== "") {
16986
+ if (extra.length > (verbName === "pull" ? 1 : 0) || !verb.named && verbName !== "set-default" && verbName !== "adopt" && name2 !== "") {
16714
16987
  throw new UsageError(`Unexpected argument '${extra[0] ?? name2}'.`);
16715
16988
  }
16716
16989
  const call3 = verb.prepare(values, name2, options.cwd, noun, extra[0]);
@@ -16726,7 +16999,7 @@ ${assetHelpText}`);
16726
16999
  options
16727
17000
  });
16728
17001
  } catch (error) {
16729
- if (error instanceof UsageError || error instanceof AppUsageError) {
17002
+ if (error instanceof UsageError || error instanceof RepositoryUsageError) {
16730
17003
  writeError(options, error.message);
16731
17004
  return EXIT3.usage;
16732
17005
  }
@@ -16818,7 +17091,9 @@ var assetsGroup = {
16818
17091
  "requests",
16819
17092
  ...Object.keys(VERBS).filter((name2) => name2 !== "pull").map((name2) => `<kind> ${name2}`),
16820
17093
  "skill pull",
16821
- ...Object.keys(APP_VERBS).map((name2) => `app ${name2}`)
17094
+ ...Object.values(REPOSITORY_KINDS).flatMap(
17095
+ (kind) => Object.keys(APP_VERBS).filter((name2) => name2 !== "publish" || kind.kind === "app").map((name2) => `${kind.kind} ${name2}`)
17096
+ )
16822
17097
  ],
16823
17098
  matches: () => true,
16824
17099
  help: assetHelpText,
@@ -16839,6 +17114,7 @@ var assetsGroup = {
16839
17114
  import { parseArgs as parseArgs2 } from "util";
16840
17115
 
16841
17116
  // src/login.ts
17117
+ import { setTimeout as defaultSleep2 } from "timers/promises";
16842
17118
  import { hostname } from "os";
16843
17119
  async function loginCommand(options) {
16844
17120
  try {
@@ -16947,12 +17223,8 @@ async function call(request) {
16947
17223
  function formatTime(iso) {
16948
17224
  return new Date(iso).toLocaleString();
16949
17225
  }
16950
- function defaultSleep2(milliseconds) {
16951
- return new Promise((resolveSleep) => setTimeout(resolveSleep, milliseconds));
16952
- }
16953
17226
 
16954
17227
  // src/setup.ts
16955
- import { createHash as createHash3 } from "crypto";
16956
17228
  import { lstat as lstat4, mkdir as mkdir5, readFile as readFile9, rename as rename5, rm as rm4, writeFile as writeFile5 } from "fs/promises";
16957
17229
  import { homedir as homedir2, hostname as hostname2 } from "os";
16958
17230
  import { dirname as dirname6, join as join8 } from "path";
@@ -16982,18 +17254,15 @@ function isLocalAgentTool(value) {
16982
17254
  var SETUP_USAGE = "Usage: catalyst setup <claude-code|codex|other> --instance <url> [--force]";
16983
17255
  var SHIPPED_SKILL = new URL("../skills/catalyst/SKILL.md", import.meta.url);
16984
17256
  var MARK = /\n<!-- Written by catalyst setup \(@work-shape\/catalyst-cli [^,]+, sha256 ([0-9a-f]{64})\)\. -->\n$/u;
16985
- function sha2562(text2) {
16986
- return createHash3("sha256").update(text2).digest("hex");
16987
- }
16988
17257
  async function renderCatalystSkill() {
16989
17258
  const body = await readFile9(SHIPPED_SKILL, "utf8");
16990
17259
  return `${body}
16991
- <!-- Written by catalyst setup (@work-shape/catalyst-cli ${RELEASE_VERSION}, sha256 ${sha2562(body)}). -->
17260
+ <!-- Written by catalyst setup (@work-shape/catalyst-cli ${RELEASE_VERSION}, sha256 ${sha256Hex(body)}). -->
16992
17261
  `;
16993
17262
  }
16994
17263
  function writtenBySetup(contents) {
16995
17264
  const mark2 = MARK.exec(contents);
16996
- return mark2 !== null && sha2562(contents.slice(0, mark2.index)) === mark2[1];
17265
+ return mark2 !== null && sha256Hex(contents.slice(0, mark2.index)) === mark2[1];
16997
17266
  }
16998
17267
  function catalystSkillPath(tool, env) {
16999
17268
  const folder = tool === "claude-code" && env.CLAUDE_CONFIG_DIR ? join8(env.CLAUDE_CONFIG_DIR, "skills") : join8(env.HOME || homedir2(), ...LOCAL_AGENT_TOOLS[tool].skillsFolder);
@@ -17013,7 +17282,8 @@ async function setupCommand(options) {
17013
17282
  url,
17014
17283
  `${tool.label} on ${hostname2()}`,
17015
17284
  options.openUrl ?? openInstanceAddress(url),
17016
- // The key a local agent gets publishes what its person may publish (CLI-PUBLISH-USE).
17285
+ // The key a local agent gets publishes what its person may publish (CLI-PUBLISH-USE);
17286
+ // connection.use, which copies Connection results to this computer, is ticked by hand.
17017
17287
  true
17018
17288
  );
17019
17289
  if (key2 === void 0) {
@@ -17318,7 +17588,7 @@ function createSkillFileDiff(name2, oldFiles, newFiles) {
17318
17588
  const output = [];
17319
17589
  for (const path of [.../* @__PURE__ */ new Set([...before.keys(), ...after.keys()])].sort()) {
17320
17590
  const oldBytes = before.get(path), newBytes = after.get(path);
17321
- if (oldBytes && newBytes && sha256(oldBytes) === sha256(newBytes)) continue;
17591
+ if (oldBytes && newBytes && sha256Hex(oldBytes) === sha256Hex(newBytes)) continue;
17322
17592
  const oldText = oldBytes === void 0 ? void 0 : utf8Text(oldBytes);
17323
17593
  const newText = newBytes === void 0 ? void 0 : utf8Text(newBytes);
17324
17594
  const fullPath = `skills/${name2}/${path}`;
@@ -17377,7 +17647,7 @@ async function pullConfig(options) {
17377
17647
  const mine = local.get(remote.key);
17378
17648
  if (base && mine && base.canonicalFormVersion === CANONICAL_FORM_VERSION && // The same asset, not only the same number: after a database was replaced another
17379
17649
  // asset of the name can be at the revision the last pull recorded.
17380
- base.id === remote.id && base.revision === remote.revision && assetHash(mine.contents) === base.hash && // What this working copy pushed as an agent's draft is not its live revision.
17650
+ base.id === remote.id && base.revision === remote.revision && sha256Hex(mine.contents) === base.hash && // What this working copy pushed as an agent's draft is not its live revision.
17381
17651
  base.draftPushed !== true) {
17382
17652
  return { ...readDefinition(remote, mine.config), folderFiles: mine.folderFiles };
17383
17653
  }
@@ -17577,7 +17847,7 @@ async function diffConfig(options) {
17577
17847
  const localAsset = localAssets.get(key2);
17578
17848
  const remoteAsset = remoteAssets.get(key2);
17579
17849
  const base = baseline.assets[key2];
17580
- const localChanged = localAsset ? assetHash(localAsset.contents) !== base?.hash : base !== void 0;
17850
+ const localChanged = localAsset ? sha256Hex(localAsset.contents) !== base?.hash : base !== void 0;
17581
17851
  const remoteChanged = (remoteAsset?.revision ?? null) !== (base?.revision ?? null) || // Another asset under the name, whatever its number.
17582
17852
  remoteAsset !== void 0 && base !== void 0 && remoteAsset.id !== base.id;
17583
17853
  const pushedDraft = base?.draftPushed === true && localAsset !== void 0;
@@ -17928,6 +18198,7 @@ import { parseArgs as parseArgs4 } from "util";
17928
18198
  import { z as z60 } from "zod";
17929
18199
 
17930
18200
  // src/connection-sign-in.ts
18201
+ import { setTimeout as defaultSleep3 } from "timers/promises";
17931
18202
  var READ_EVERY_MS = 2e3;
17932
18203
  var SETTLE_READS = 16;
17933
18204
  async function connectConnection(api, name2, options) {
@@ -17950,7 +18221,7 @@ async function connectConnection(api, name2, options) {
17950
18221
  ].join("\n")
17951
18222
  );
17952
18223
  if (options.openBrowser) (options.openUrl ?? openProviderPage)(start.authorizationUrl);
17953
- const sleep = options.sleep ?? ((milliseconds) => new Promise((resolve15) => setTimeout(resolve15, milliseconds)));
18224
+ const sleep = options.sleep ?? defaultSleep3;
17954
18225
  const until = Date.parse(start.expiresAt);
17955
18226
  let readsSinceEnded = 0;
17956
18227
  for (; ; ) {
@@ -18107,7 +18378,7 @@ async function runOperationCommand(argv, base) {
18107
18378
  "Input must be JSON with params, query, body, or file (an upload path)."
18108
18379
  );
18109
18380
  }
18110
- if (operation2.id === "connections.set_secret" && isRecord5(input.body) && typeof input.body.value === "string")
18381
+ if (operation2.id === "connections.set_secret" && isRecord(input.body) && typeof input.body.value === "string")
18111
18382
  secret = input.body.value;
18112
18383
  const { file, ...request } = input;
18113
18384
  const upload = file === void 0 ? void 0 : new File([await readFile10(resolve11(base.cwd, file))], basename5(file));
@@ -18192,7 +18463,7 @@ async function call2(api, operation, input) {
18192
18463
  const invoke = (client, idempotencyKey2) => {
18193
18464
  let method = client;
18194
18465
  for (const segment of operation.id.split("."))
18195
- method = isRecord5(method) ? method[segment] : void 0;
18466
+ method = isRecord(method) ? method[segment] : void 0;
18196
18467
  if (!isMethod(method))
18197
18468
  throw new Error("The API client has no method for this catalog operation.");
18198
18469
  return method({ ...input, ...idempotencyKey2 === void 0 ? {} : { idempotencyKey: idempotencyKey2 } });
@@ -18207,12 +18478,12 @@ function isMethod(value) {
18207
18478
  }
18208
18479
  async function printCall(options, operation, result, format) {
18209
18480
  const render = format ?? ((value) => JSON.stringify(value, null, 2));
18210
- if (isRecord5(result) && operation.accepted) {
18481
+ if (isRecord(result) && operation.accepted) {
18211
18482
  if (result.status === "pending_approval") {
18212
18483
  if (format === void 0) {
18213
18484
  writeOutput(options, render({ status: result.status, run: result.run }));
18214
18485
  } else {
18215
- const id3 = isRecord5(result.run) ? result.run.id : "unknown";
18486
+ const id3 = isRecord(result.run) ? result.run.id : "unknown";
18216
18487
  writeError(
18217
18488
  options,
18218
18489
  `Waits for an approval on the instance; nothing has changed yet (Operation Run ${id3}).`
@@ -18489,7 +18760,7 @@ function definition(entry, part, name2) {
18489
18760
  const last = keys.pop();
18490
18761
  for (const key2 of keys) {
18491
18762
  const value = Object.hasOwn(target, key2) ? target[key2] : void 0;
18492
- const child = isRecord5(value) ? value : {};
18763
+ const child = isRecord(value) ? value : {};
18493
18764
  Object.defineProperty(target, key2, {
18494
18765
  value: child,
18495
18766
  enumerable: true,
@@ -18788,10 +19059,10 @@ async function runKnowledgeCommand(argv, base) {
18788
19059
  });
18789
19060
  }
18790
19061
  let exit = 0;
18791
- if (isRecord5(result) && isRecord5(result.run)) {
19062
+ if (isRecord(result) && isRecord(result.run)) {
18792
19063
  exit = result.run.status === "running" || result.run.status === "done" ? 0 : 3;
18793
19064
  result = result.run;
18794
- } else if (isRecord5(result) && result.status === "done") result = result.output;
19065
+ } else if (isRecord(result) && result.status === "done") result = result.output;
18795
19066
  writeOutput(
18796
19067
  options,
18797
19068
  values.json ? JSON.stringify(result, null, 2) : yaml10.dump(result, { lineWidth: -1, noRefs: true }).trimEnd()
@@ -18817,7 +19088,7 @@ async function reindex(api, name2, confirm, options, json2) {
18817
19088
  body: confirm ? { confirm } : {}
18818
19089
  });
18819
19090
  const answer = reindexAnswerSchema.parse(
18820
- isRecord5(raw) && raw.status === "done" && "output" in raw ? raw.output : raw
19091
+ isRecord(raw) && raw.status === "done" && "output" in raw ? raw.output : raw
18821
19092
  );
18822
19093
  const waits = !answer.started && answer.statement !== void 0;
18823
19094
  if (json2) {
@@ -19361,7 +19632,7 @@ Commands:
19361
19632
  Check the provider on a running instance, where its key is (instance.infrastructure.check)
19362
19633
  catalyst models list
19363
19634
  The model providers of the release config; with --instance, also what the instance
19364
- reports for each (instance.infrastructure.get)
19635
+ reports for each (instance.infrastructure.check)
19365
19636
 
19366
19637
  Options of add:
19367
19638
  --id <id> The provider's id (azure: azure-eu, vertex: vertex-eu,
@@ -19552,7 +19823,7 @@ async function addProvider(kind, flags, options) {
19552
19823
  `The release config already has a model provider '${id3}'. Choose another --id.`
19553
19824
  );
19554
19825
  const bindings = valueAt(config.merged, BINDINGS);
19555
- if (Array.isArray(bindings) && bindings.some((binding2) => isRecord5(binding2) && binding2.id === bindingId))
19826
+ if (Array.isArray(bindings) && bindings.some((binding2) => isRecord(binding2) && binding2.id === bindingId))
19556
19827
  throw new ReleaseConfigError(
19557
19828
  `The release config already has a model binding '${bindingId}'. Choose another --binding.`
19558
19829
  );
@@ -19582,7 +19853,7 @@ async function addProvider(kind, flags, options) {
19582
19853
  outputPricePerMillionTokens: Number(values["output-price"])
19583
19854
  };
19584
19855
  const prices = valueAt(config.merged, PRICES);
19585
- if (Array.isArray(prices) && prices.some((row) => isRecord5(row) && row.providerId === id3 && row.model === model))
19856
+ if (Array.isArray(prices) && prices.some((row) => isRecord(row) && row.providerId === id3 && row.model === model))
19586
19857
  throw new ReleaseConfigError(
19587
19858
  `The rate card already prices '${model}' of provider '${id3}'. Remove that row, or choose another --id.`
19588
19859
  );
@@ -19653,8 +19924,8 @@ async function addProvider(kind, flags, options) {
19653
19924
  return 0;
19654
19925
  }
19655
19926
  function fallbackRefusal(fallbackId, bindings, models) {
19656
- const fallback = Array.isArray(bindings) ? bindings.find((binding) => isRecord5(binding) && binding.id === fallbackId) : void 0;
19657
- if (!isRecord5(fallback))
19927
+ const fallback = Array.isArray(bindings) ? bindings.find((binding) => isRecord(binding) && binding.id === fallbackId) : void 0;
19928
+ if (!isRecord(fallback))
19658
19929
  return `The release config has no model binding '${fallbackId}' to fall back to. Name one of its chat bindings with --fallback.`;
19659
19930
  if (fallback.kind === "embedding")
19660
19931
  return `'${fallbackId}' is an embedding binding; a fallback answers chat calls. Name a chat binding with --fallback.`;
@@ -19669,7 +19940,7 @@ function defaultSecret(kind, id3, config) {
19669
19940
  const models = valueAt(config.merged, ["infrastructure", "models"]);
19670
19941
  const taken = new Set(
19671
19942
  isPlainConfigObject(models) ? Object.values(models).flatMap(
19672
- (entry) => isRecord5(entry) && typeof entry.credentialSecret === "string" ? [entry.credentialSecret] : []
19943
+ (entry) => isRecord(entry) && typeof entry.credentialSecret === "string" ? [entry.credentialSecret] : []
19673
19944
  ) : []
19674
19945
  );
19675
19946
  if (spec.defaultSecret !== void 0 && !taken.has(spec.defaultSecret)) return spec.defaultSecret;
@@ -19681,8 +19952,7 @@ function rateCardId(config) {
19681
19952
  return typeof instance === "string" && instance !== "" ? instance : "rate-card";
19682
19953
  }
19683
19954
  async function checkProvider(id3, json2, options) {
19684
- const { api } = await openInstance(options);
19685
- const answer = await api.read((client) => client.instance.infrastructure.check());
19955
+ const answer = await checkInfrastructure(options);
19686
19956
  const item = answer.items.find(
19687
19957
  (candidate) => candidate.class === "models" && candidate.name === id3
19688
19958
  );
@@ -19695,14 +19965,38 @@ async function checkProvider(id3, json2, options) {
19695
19965
  return 1;
19696
19966
  }
19697
19967
  if (json2) {
19698
- writeOutput(options, JSON.stringify(item, null, 2));
19968
+ writeOutput(options, JSON.stringify({ ...item, id: item.name }, null, 2));
19699
19969
  return item.check.status === "ok" ? 0 : 1;
19700
19970
  }
19701
19971
  for (const line of describeCheck(item)) writeOutput(options, line);
19702
19972
  return item.check.status === "ok" ? 0 : 1;
19703
19973
  }
19974
+ async function checkInfrastructure(options) {
19975
+ const { api } = await openInstance(options);
19976
+ try {
19977
+ return await api.read(
19978
+ (client) => client.instance.infrastructure.check(),
19979
+ (seconds) => writeError(
19980
+ options,
19981
+ `The instance checks at most once a minute. Waiting ${seconds}s, then checking again.`
19982
+ )
19983
+ );
19984
+ } catch (error) {
19985
+ const converted = toConfigApiError(error);
19986
+ if (converted instanceof ConfigApiError && converted.status === 403 && (isRecord(converted.details) && converted.details.action === "system.view" || converted.message === "Missing auth scope 'infrastructure:check'" || converted.message === "Service principals cannot access user-scoped routes")) {
19987
+ throw new ConfigApiError(403, {
19988
+ error: {
19989
+ code: "FORBIDDEN",
19990
+ message: "The model check needs the 'system.view' right and a personal API key with the 'system.view' scope. Service keys cannot run this check.",
19991
+ correlationId: converted.correlationId
19992
+ }
19993
+ });
19994
+ }
19995
+ throw converted;
19996
+ }
19997
+ }
19704
19998
  function describeCheck(item) {
19705
- const head = `${item.check.status === "ok" ? "ok" : item.check.status === "failed" ? "failed" : item.check.status.replace("_", " ")} ${item.id} ${item.type}${item.region ? `, region ${item.region}` : ""}${item.endpointHost ? `, ${item.endpointHost}` : ""}`;
19999
+ const head = `${item.check.status === "ok" ? "ok" : item.check.status === "failed" ? "failed" : item.check.status.replace("_", " ")} ${item.name} ${item.type}${item.region ? `, region ${item.region}` : ""}${item.endpointHost ? `, ${item.endpointHost}` : ""}`;
19706
20000
  const lines = [head];
19707
20001
  for (const secret of item.secrets) {
19708
20002
  lines.push(
@@ -19742,9 +20036,9 @@ async function listProviders(configFlag, json2, options) {
19742
20036
  const prices = valueAt(config.merged, PRICES);
19743
20037
  const listed = Object.entries(isPlainConfigObject(models) ? models : {}).map(
19744
20038
  ([id3, entry]) => {
19745
- const record = isRecord5(entry) ? entry : {};
20039
+ const record = isRecord(entry) ? entry : {};
19746
20040
  const ownBindings = (Array.isArray(bindings) ? bindings : []).filter(
19747
- (binding) => isRecord5(binding) && binding.providerId === id3
20041
+ (binding) => isRecord(binding) && binding.providerId === id3
19748
20042
  );
19749
20043
  const billed = [record.model, ...ownBindings.map((binding) => binding.model)].filter(
19750
20044
  (model) => typeof model === "string"
@@ -19758,15 +20052,14 @@ async function listProviders(configFlag, json2, options) {
19758
20052
  bindings: ownBindings.map((binding) => String(binding.id)),
19759
20053
  priced: billed.length > 0 && billed.every(
19760
20054
  (model) => (Array.isArray(prices) ? prices : []).some(
19761
- (row) => isRecord5(row) && row.providerId === id3 && row.model === model
20055
+ (row) => isRecord(row) && row.providerId === id3 && row.model === model
19762
20056
  )
19763
20057
  )
19764
20058
  };
19765
20059
  }
19766
20060
  );
19767
20061
  if (options.instance !== void 0) {
19768
- const { api } = await openInstance(options);
19769
- const answer = await api.read((client) => client.instance.infrastructure.get());
20062
+ const answer = await checkInfrastructure(options);
19770
20063
  for (const provider of listed) {
19771
20064
  const item = answer.items.find(
19772
20065
  (candidate) => candidate.class === "models" && candidate.name === provider.id
@@ -19948,7 +20241,7 @@ ${command.operation.summary}
19948
20241
  params,
19949
20242
  query: { ...query, limit: MAX_LIST_LIMIT, ...cursor === void 0 ? {} : { cursor } }
19950
20243
  });
19951
- if (!isRecord5(page2) || !Array.isArray(page2[listField]))
20244
+ if (!isRecord(page2) || !Array.isArray(page2[listField]))
19952
20245
  throw new Error("Invalid list response.");
19953
20246
  items.push(...page2[listField]);
19954
20247
  cursor = typeof page2.nextCursor === "string" ? page2.nextCursor : void 0;