@work-shape/catalyst-cli 0.8.0-rc.12 → 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);
@@ -1198,6 +1205,12 @@ var workflowDatasetReferenceSchema = z2.strictObject({
1198
1205
  /** Absolute offset in the parent; rowCount bounds the view. No rows are copied. */
1199
1206
  offset: z2.number().int().nonnegative().optional()
1200
1207
  });
1208
+ var workflowFileReferenceSchema = z2.strictObject({
1209
+ $file: z2.string().min(1),
1210
+ name: z2.string().min(1).max(200),
1211
+ mimeType: z2.string().min(1).max(200),
1212
+ bytes: z2.number().int().positive()
1213
+ });
1201
1214
  var operationBatchFailureSchema = z2.strictObject({
1202
1215
  item: z2.json(),
1203
1216
  code: z2.string().min(1),
@@ -2467,7 +2480,7 @@ import { z as z58 } from "zod";
2467
2480
  // ../api-contract/package.json
2468
2481
  var package_default = {
2469
2482
  name: "@work-shape/catalyst-api-contract",
2470
- version: "0.8.0-rc.12",
2483
+ version: "0.8.0-rc.14",
2471
2484
  license: "MIT",
2472
2485
  repository: {
2473
2486
  type: "git",
@@ -3599,7 +3612,10 @@ var configAssetRevisionSchema = z22.object({
3599
3612
  operation: z22.enum(CONFIG_ASSET_CHANGE_OPERATIONS),
3600
3613
  config: configAssetConfigSchema.nullable(),
3601
3614
  actor: auditActorSchema.nullable(),
3602
- /** 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
+ */
3603
3619
  origin: z22.discriminatedUnion("kind", [
3604
3620
  z22.object({ kind: z22.literal("approval_request"), requestId: z22.string(), summary: z22.string() }),
3605
3621
  z22.object({
@@ -3607,12 +3623,24 @@ var configAssetRevisionSchema = z22.object({
3607
3623
  conversationId: z22.string(),
3608
3624
  pageId: z22.string(),
3609
3625
  /** The number of the Page revision the files were copied from. */
3610
- fileSetNumber: z22.number().int().positive()
3611
- })
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() })
3612
3631
  ]).optional(),
3613
3632
  globalVersion: z22.number().int().positive(),
3614
3633
  createdAt: timestampSchema
3615
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
+ });
3616
3644
  var toolGroupSchema = z22.enum(TOOL_GROUPS);
3617
3645
  var toolTextSchema = z22.object({ en: z22.string(), de: z22.string() });
3618
3646
  var agentToolReferenceSchema = z22.object({
@@ -3663,8 +3691,6 @@ var configAssetReferencesSchema = z22.object({
3663
3691
  * still names one shows it as unavailable, so it can be removed.
3664
3692
  */
3665
3693
  unavailableTools: z22.array(unavailableToolSchema).optional(),
3666
- /** @deprecated Use unavailableTools. Kept for existing agent editors. */
3667
- moduleOffTools: z22.array(z22.object({ name: z22.string(), module: z22.string() })).optional(),
3668
3694
  /**
3669
3695
  * What the platform tells every agent before its own instructions, read-only: the rules
3670
3696
  * every agent gets, and the orientation an agent gets whose tools name one of `toolNames`.
@@ -4005,6 +4031,7 @@ var assetScopeSchema = z26.discriminatedUnion("kind", [
4005
4031
  ]);
4006
4032
  var revisionNumberSchema = z26.number().int().positive();
4007
4033
  var APP_PUBLISH_WORKFLOWS_MAX = 20;
4034
+ var APP_PUBLISH_DATA_STORES_MAX = 100;
4008
4035
  var expectedRevisionSchema = revisionNumberSchema.optional();
4009
4036
  var expectedRevisionOrNewSchema = revisionNumberSchema.nullable().optional();
4010
4037
  var NUL = "\0";
@@ -4124,8 +4151,18 @@ var workflowStepFactSchema = workflowOperationFactSchema.partial().extend({
4124
4151
  tools: z26.array(workflowOperationFactSchema.extend({ name: z26.string() })).optional()
4125
4152
  });
4126
4153
  var assetSchema = z26.object({
4127
- /** The retained publish event for the live revision, for a reader of an App draft. */
4128
- 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(),
4129
4166
  id: z26.string(),
4130
4167
  kind: z26.string(),
4131
4168
  name: z26.string(),
@@ -4331,7 +4368,15 @@ var publishAssetRequestSchema = z26.object({
4331
4368
  * a Workflow the App's revision reaches, directly or as a child. They are published children
4332
4369
  * first and then the App, in one transaction: a refusal of any publishes none of them.
4333
4370
  */
4334
- 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()
4335
4380
  });
4336
4381
  var discardAssetDraftRequestSchema = z26.object({
4337
4382
  /** The draft revision the caller last read. Required. */
@@ -4343,10 +4388,13 @@ var assetPointersResponseSchema = z26.object({
4343
4388
  publishedRevision: revisionNumberSchema,
4344
4389
  /** The revision that was published before a publish, left out on the first one. */
4345
4390
  replacedRevision: revisionNumberSchema.optional(),
4346
- /** 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
+ */
4347
4395
  publishedWith: z26.array(
4348
4396
  z26.object({
4349
- kind: z26.literal("workflow"),
4397
+ kind: z26.enum(["data_store", "workflow"]),
4350
4398
  name: z26.string(),
4351
4399
  publishedRevision: revisionNumberSchema,
4352
4400
  replacedRevision: revisionNumberSchema.optional()
@@ -4405,6 +4453,27 @@ var setAssetDefaultResponseSchema = z26.object({
4405
4453
  /** The version of the instance's whole asset set after the change. */
4406
4454
  version: z26.number().int().positive()
4407
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
+ });
4408
4477
  var setAssetAvailabilityRequestSchema = z26.object({
4409
4478
  /** Required with dependency consent: refuse a definition changed since it was reviewed. */
4410
4479
  expectedRevision: revisionNumberSchema.optional(),
@@ -5828,6 +5897,8 @@ var appPublishReviewItemSchema = z30.object({
5828
5897
  narrative: publishNarrativeSchema.optional(),
5829
5898
  /** Who wrote the draft revision, as people read their name. */
5830
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(),
5831
5902
  refusals: z30.array(appPublishRefusalSchema)
5832
5903
  });
5833
5904
  var appPublishReviewSchema = z30.object({
@@ -5840,6 +5911,23 @@ var appPublishReviewSchema = z30.object({
5840
5911
  lastTestRun: z30.object({ runId: z30.string(), status: z30.enum(WORKFLOW_RUN_STATUSES), at: z30.string() }).optional()
5841
5912
  })
5842
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([]),
5843
5931
  /**
5844
5932
  * One Publish of the App also publishes the pending Workflow drafts it reaches, when the
5845
5933
  * publish names them in `workflows` (DP-3). Where false, each pending Workflow is published
@@ -6063,7 +6151,7 @@ var appOperations = {
6063
6151
  id: "apps.publish_review",
6064
6152
  method: "GET",
6065
6153
  path: "/api/v1/apps/:app/publish-review",
6066
- 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",
6067
6155
  tag: "Apps",
6068
6156
  auth: "user",
6069
6157
  scope: "config_assets:read",
@@ -6400,6 +6488,24 @@ var assetOperations = {
6400
6488
  errors: ["CONFLICT"],
6401
6489
  rateClass: "write"
6402
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
+ }),
6403
6509
  "assets.validate": defineRegisteredOperation({
6404
6510
  id: "assets.validate",
6405
6511
  method: "POST",
@@ -6578,6 +6684,21 @@ var assetOperations = {
6578
6684
  errors: ["NOT_FOUND"],
6579
6685
  rateClass: "read"
6580
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
+ }),
6581
6702
  "assets.revert": defineRegisteredOperation({
6582
6703
  id: "assets.revert",
6583
6704
  method: "POST",
@@ -8005,7 +8126,7 @@ var dataStoreStateResponseSchema = z38.object({
8005
8126
  }),
8006
8127
  /**
8007
8128
  * What the server leaves open around the store, each with what an operator does about it.
8008
- * Empty for a reader without `system.view`.
8129
+ * Empty for a reader without `system.view` and for personal API keys.
8009
8130
  */
8010
8131
  conditions: z38.array(z38.object({ code: z38.enum(DATA_STORE_CONDITIONS), message: z38.string() })),
8011
8132
  /** How the last attempt to bring the store to its published revision ended. */
@@ -9520,6 +9641,7 @@ var instanceOperations = {
9520
9641
  tag: "Instance",
9521
9642
  auth: "user",
9522
9643
  scope: "user_admin:read",
9644
+ personalKeyScope: "infrastructure:check",
9523
9645
  requires: ["system.view"],
9524
9646
  effect: "reading",
9525
9647
  response: json(infrastructureSchema),
@@ -10469,6 +10591,15 @@ var platformAssetKindSchema = z53.object({
10469
10591
  principalActions: z53.array(z53.string()).optional(),
10470
10592
  /** The file of a `files` kind that holds its manifest. */
10471
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(),
10472
10603
  /** What a write of a `files` kind is held to, by the names of the limits. */
10473
10604
  limits: z53.object({
10474
10605
  FILE_SET_MAX_FILES: z53.number().int().positive(),
@@ -11576,6 +11707,11 @@ var apiOperations = allOperations;
11576
11707
  var RELEASE_VERSION = package_default.version;
11577
11708
  var API_ERROR_CODE_ORDER = appErrorCodeSchema.options;
11578
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
+
11579
11715
  // src/instance-output.ts
11580
11716
  function versionParts(version) {
11581
11717
  const number = "(?:0|[1-9][0-9]*)";
@@ -11636,6 +11772,7 @@ ${pages.join("\n")}`).join("\n\n");
11636
11772
  import { parseArgs } from "util";
11637
11773
 
11638
11774
  // src/api.ts
11775
+ import { setTimeout as defaultSleep } from "timers/promises";
11639
11776
  import { randomUUID } from "crypto";
11640
11777
 
11641
11778
  // ../api-client/src/errors.ts
@@ -12029,7 +12166,7 @@ async function createConfigApi(options) {
12029
12166
  };
12030
12167
  return {
12031
12168
  /** Any reading operation of the instance. A refusal throws as `ConfigApiError`. */
12032
- read: (request) => read(sleep, () => request(client)),
12169
+ read: (request, onRateLimitWait) => read(sleep, () => request(client), onRateLimitWait),
12033
12170
  change,
12034
12171
  /** The version of the instance's asset set and the name of its default agent. */
12035
12172
  getOverview: async () => {
@@ -12103,10 +12240,7 @@ var CHANGE_ATTEMPTS = 3;
12103
12240
  var CHANGE_RETRY_DELAY_MS = 500;
12104
12241
  var READ_ATTEMPTS = 5;
12105
12242
  var MAX_RATE_LIMIT_WAIT_SECONDS = 60;
12106
- function defaultSleep(milliseconds) {
12107
- return new Promise((resolveSleep) => setTimeout(resolveSleep, milliseconds));
12108
- }
12109
- async function read(sleep, request) {
12243
+ async function read(sleep, request, onRateLimitWait) {
12110
12244
  for (let attempt = 1; ; attempt += 1) {
12111
12245
  try {
12112
12246
  return await request();
@@ -12115,6 +12249,7 @@ async function read(sleep, request) {
12115
12249
  if (wait === void 0 || wait > MAX_RATE_LIMIT_WAIT_SECONDS || attempt >= READ_ATTEMPTS) {
12116
12250
  throw toConfigApiError(error);
12117
12251
  }
12252
+ onRateLimitWait?.(wait);
12118
12253
  await sleep(wait * 1e3);
12119
12254
  }
12120
12255
  }
@@ -12196,9 +12331,6 @@ function readApiError(payload) {
12196
12331
  ...payload.error.details === void 0 ? {} : { details: payload.error.details }
12197
12332
  };
12198
12333
  }
12199
- function isRecord(value) {
12200
- return typeof value === "object" && value !== null && !Array.isArray(value);
12201
- }
12202
12334
  function redactSecret(message, secret) {
12203
12335
  return secret ? message.split(secret).join("[redacted]") : message;
12204
12336
  }
@@ -12207,13 +12339,17 @@ function redactSecret(message, secret) {
12207
12339
  import { resolve as resolve5 } from "path";
12208
12340
  import yaml6 from "js-yaml";
12209
12341
 
12342
+ // src/sha256.ts
12343
+ import { createHash } from "crypto";
12344
+ function sha256Hex(value) {
12345
+ return createHash("sha256").update(value).digest("hex");
12346
+ }
12347
+
12210
12348
  // src/command-support.ts
12211
- import { createHash as createHash2 } from "crypto";
12212
12349
  import { mkdir as mkdir4, mkdtemp as mkdtemp2, rename as rename4, rm as rm3, writeFile as writeFile4 } from "fs/promises";
12213
12350
  import { basename as basename3, dirname as dirname4, isAbsolute as isAbsolute2, relative as relative2, resolve as resolve4, sep as sep3 } from "path";
12214
12351
 
12215
12352
  // src/asset-folder.ts
12216
- import { createHash } from "crypto";
12217
12353
  import {
12218
12354
  lstat,
12219
12355
  mkdir,
@@ -12226,9 +12362,6 @@ import {
12226
12362
  writeFile
12227
12363
  } from "fs/promises";
12228
12364
  import { basename, dirname, join, resolve, sep } from "path";
12229
- function sha256(bytes) {
12230
- return createHash("sha256").update(bytes).digest("hex");
12231
- }
12232
12365
  async function readFolderState(directory, filename, kind) {
12233
12366
  let contents;
12234
12367
  try {
@@ -12238,7 +12371,7 @@ async function readFolderState(directory, filename, kind) {
12238
12371
  throw error;
12239
12372
  }
12240
12373
  const parsed = JSON.parse(contents);
12241
- 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")
12242
12375
  throw new Error(
12243
12376
  `'${join(directory, filename)}' is not the state of a pulled ${kind}. Pull into an empty folder again.`
12244
12377
  );
@@ -12291,7 +12424,7 @@ async function localChanges(directory, state, filename, ignoreUntracked = false)
12291
12424
  else {
12292
12425
  if (ignoreUntracked && !entry.isFile()) continue;
12293
12426
  if (!entry.isFile()) throw new Error(`'${path}' is not a regular file.`);
12294
- now[path] = sha256(await readFile(join(folder, entry.name)));
12427
+ now[path] = sha256Hex(await readFile(join(folder, entry.name)));
12295
12428
  }
12296
12429
  }
12297
12430
  };
@@ -12312,7 +12445,7 @@ async function writeFolderFiles(directory, files, previous) {
12312
12445
  const target = safeTarget(directory, file.path);
12313
12446
  if (basename(file.path) === ".DS_Store") continue;
12314
12447
  const bytes = file.base64 !== void 0 ? Buffer.from(file.base64, "base64") : Buffer.from(file.text ?? "", "utf8");
12315
- const hash2 = sha256(bytes);
12448
+ const hash2 = sha256Hex(bytes);
12316
12449
  if (hash2 !== file.sha256)
12317
12450
  throw new Error(
12318
12451
  `The file '${file.path}' did not arrive as the instance holds it (its SHA-256 differs). Pull again.`
@@ -12385,9 +12518,6 @@ function safeTarget(directory, path) {
12385
12518
  }
12386
12519
  return target;
12387
12520
  }
12388
- function isRecord2(value) {
12389
- return typeof value === "object" && value !== null && !Array.isArray(value);
12390
- }
12391
12521
  function isNodeError(error) {
12392
12522
  return error instanceof Error && "code" in error;
12393
12523
  }
@@ -12396,9 +12526,6 @@ function isNodeError(error) {
12396
12526
  import { lstat as lstat2, readFile as readFile2, readdir as readdir2 } from "fs/promises";
12397
12527
  import { basename as basename2, join as join2 } from "path";
12398
12528
  var SKILL_STATE_FILES = [".catalyst-skill.json", ".catalyst-state.json"];
12399
- var FILE_MAX_BYTES = 2 * 1024 * 1024;
12400
- var FOLDER_MAX_BYTES = 8 * 1024 * 1024;
12401
- var MAX_FILES = 500;
12402
12529
  var TEXT_EXTENSIONS = /\.(py|js|mjs|ts|sh|rb|md|txt|json|yaml|yml|xml|html|css|csv)$/iu;
12403
12530
  var EXECUTABLE_PREFIXES = [
12404
12531
  [127, 69, 76, 70],
@@ -12423,7 +12550,7 @@ function resourceMediaType(path) {
12423
12550
  return path.startsWith("scripts/") ? void 0 : skillResourceMediaTypeForPath(path);
12424
12551
  }
12425
12552
  function folderHashes(files) {
12426
- return Object.fromEntries(files.map((file) => [file.path, sha256(fileBytes(file))]));
12553
+ return Object.fromEntries(files.map((file) => [file.path, sha256Hex(fileBytes(file))]));
12427
12554
  }
12428
12555
  function extraHashes(hashes = {}) {
12429
12556
  return Object.fromEntries(
@@ -12453,11 +12580,11 @@ async function readSkillFolder(directory) {
12453
12580
  if (path.toLowerCase().endsWith("/skill.md"))
12454
12581
  refuse("skill_path_invalid", path, "SKILL.md belongs at the root");
12455
12582
  const { size } = await lstat2(join2(directory, path));
12456
- if (size > FILE_MAX_BYTES)
12457
- 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`);
12458
12585
  paths.push({ path, size });
12459
- if (paths.length > MAX_FILES)
12460
- 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`);
12461
12588
  }
12462
12589
  }
12463
12590
  };
@@ -12471,11 +12598,11 @@ async function readSkillFolder(directory) {
12471
12598
  refuse("skill_path_duplicate", path, "paths differing only in case count as one");
12472
12599
  seen.add(path.toLowerCase());
12473
12600
  const bytes = await readFile2(join2(directory, path));
12474
- if (bytes.length > FILE_MAX_BYTES)
12475
- 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`);
12476
12603
  total += bytes.length;
12477
- if (total > FOLDER_MAX_BYTES)
12478
- 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`);
12479
12606
  const peAt = bytes.length >= 64 ? bytes.readUInt32LE(60) : bytes.length;
12480
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]));
12481
12608
  if (pe || EXECUTABLE_PREFIXES.some((prefix) => prefix.every((byte, index) => bytes[index] === byte)))
@@ -12591,7 +12718,7 @@ var yamlDumpOptions = {
12591
12718
  var KEY_ORDER = ["name", "displayName", "description", "on", "filter", "check", "outcome"];
12592
12719
  function serializeGuardrailFiles(definition2) {
12593
12720
  const { origin: _origin, ...rest } = definition2;
12594
- const check = isRecord3(rest.check) ? rest.check : void 0;
12721
+ const check = isRecord(rest.check) ? rest.check : void 0;
12595
12722
  const instruction = check?.kind === "model_judge" && typeof check.instruction === "string" ? check.instruction : void 0;
12596
12723
  const ordered = {};
12597
12724
  for (const key2 of [...KEY_ORDER, ...Object.keys(rest).sort()]) {
@@ -12612,12 +12739,12 @@ function serializeGuardrailFiles(definition2) {
12612
12739
  }
12613
12740
  function parseGuardrailFiles(input) {
12614
12741
  const data = loadYamlData(input.yaml, input.source);
12615
- if (!isRecord3(data) || typeof data.name !== "string") {
12742
+ if (!isRecord(data) || typeof data.name !== "string") {
12616
12743
  throw new Error(`${input.source} must hold a mapping with a 'name'.`);
12617
12744
  }
12618
12745
  if (input.checkMd === void 0) return { ...data, name: data.name };
12619
12746
  const check = data.check;
12620
- if (!isRecord3(check) || check.kind !== "model_judge") {
12747
+ if (!isRecord(check) || check.kind !== "model_judge") {
12621
12748
  throw new Error(
12622
12749
  `${input.source}: a ${GUARDRAIL_CHECK_FILE} holds the instruction of a 'model_judge' check, and this check is none.`
12623
12750
  );
@@ -12643,9 +12770,6 @@ async function readGuardrailFolder(directory) {
12643
12770
  source: yamlPath
12644
12771
  });
12645
12772
  }
12646
- function isRecord3(value) {
12647
- return typeof value === "object" && value !== null && !Array.isArray(value);
12648
- }
12649
12773
 
12650
12774
  // src/serialization.ts
12651
12775
  import yaml3 from "js-yaml";
@@ -12747,16 +12871,16 @@ var WorkingCopyValidationError = class extends Error {
12747
12871
  };
12748
12872
  function parseManifest(contents, source = MANIFEST_FILENAME) {
12749
12873
  const input = loadYamlData(contents, source);
12750
- if (!isRecord4(input)) {
12874
+ if (!isRecord(input)) {
12751
12875
  throw new Error(`${source} must contain a YAML object`);
12752
12876
  }
12753
12877
  const instancesInput = input.instances;
12754
- if (!isRecord4(instancesInput)) {
12878
+ if (!isRecord(instancesInput)) {
12755
12879
  throw new Error(`${source} must define an instances mapping`);
12756
12880
  }
12757
12881
  const instances = {};
12758
12882
  for (const [name2, value] of Object.entries(instancesInput)) {
12759
- if (!isRecord4(value) || typeof value.url !== "string" || value.url.length === 0) {
12883
+ if (!isRecord(value) || typeof value.url !== "string" || value.url.length === 0) {
12760
12884
  throw new Error(`${source} instance '${name2}' must define a url`);
12761
12885
  }
12762
12886
  const workspace = readOptionalString(value, "workspace", `${source} instance '${name2}'`);
@@ -12827,22 +12951,22 @@ async function readStateFile(path) {
12827
12951
  throw error;
12828
12952
  }
12829
12953
  const input = JSON.parse(contents);
12830
- if (!isRecord4(input) || !isRecord4(input.instances)) {
12954
+ if (!isRecord(input) || !isRecord(input.instances)) {
12831
12955
  throw new Error(`${path} must contain an instances object`);
12832
12956
  }
12833
12957
  const instances = {};
12834
12958
  for (const [name2, value] of Object.entries(input.instances)) {
12835
- 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) {
12836
12960
  throw new Error(`${path} has an invalid lastPulledVersion for '${name2}'`);
12837
12961
  }
12838
12962
  const baseline = { lastPulledVersion: value.lastPulledVersion };
12839
12963
  if (value.assets !== void 0) {
12840
- if (!isRecord4(value.assets)) {
12964
+ if (!isRecord(value.assets)) {
12841
12965
  throw new Error(`${path} has invalid asset baselines for '${name2}'`);
12842
12966
  }
12843
12967
  baseline.assets = {};
12844
12968
  for (const [key2, asset] of Object.entries(value.assets)) {
12845
- 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(
12846
12970
  (hash2) => typeof hash2 !== "string" || !/^[a-f0-9]{64}$/u.test(hash2)
12847
12971
  )) || asset.draftPushed !== void 0 && asset.draftPushed !== true) {
12848
12972
  throw new Error(`${path} has an invalid asset baseline for '${key2}'`);
@@ -12859,13 +12983,13 @@ async function readStateFile(path) {
12859
12983
  }
12860
12984
  }
12861
12985
  if (value.deleted !== void 0) {
12862
- if (!isRecord4(value.deleted)) {
12986
+ if (!isRecord(value.deleted)) {
12863
12987
  throw new Error(`${path} has invalid deleted-asset baselines for '${name2}'`);
12864
12988
  }
12865
12989
  baseline.deleted = {};
12866
12990
  for (const [key2, entry] of Object.entries(value.deleted)) {
12867
12991
  const deleted = typeof entry === "number" ? { revision: entry } : entry;
12868
- 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") {
12869
12993
  throw new Error(`${path} has an invalid deleted-asset baseline for '${key2}'`);
12870
12994
  }
12871
12995
  baseline.deleted[key2] = {
@@ -12885,7 +13009,7 @@ async function readStateFile(path) {
12885
13009
  return { instances };
12886
13010
  }
12887
13011
  function readBaselineHashes(input) {
12888
- if (!isRecord4(input)) throw new Error("Invalid skill file hashes");
13012
+ if (!isRecord(input)) throw new Error("Invalid skill file hashes");
12889
13013
  return Object.fromEntries(
12890
13014
  Object.entries(input).map(([path, hash2]) => {
12891
13015
  if (typeof hash2 !== "string") throw new Error(`Invalid skill file hash: ${path}`);
@@ -12932,7 +13056,7 @@ async function readWorkingCopy(workingDir, manifest) {
12932
13056
  const parsedMarkdown = parseSkillMarkdown(contents, file, toPosixPath(path));
12933
13057
  const { resources, files } = await readSkillFolder(dirname3(path));
12934
13058
  const parsed = skillConfigSchema.safeParse(
12935
- isRecord4(parsedMarkdown) ? { ...parsedMarkdown, ...resources.length ? { resources } : {} } : parsedMarkdown
13059
+ isRecord(parsedMarkdown) ? { ...parsedMarkdown, ...resources.length ? { resources } : {} } : parsedMarkdown
12936
13060
  );
12937
13061
  if (parsed.success) {
12938
13062
  skills.push(parsed.data);
@@ -13175,11 +13299,11 @@ function schemaIssues(file, issues) {
13175
13299
  }));
13176
13300
  }
13177
13301
  function extractErrorIssues(file, error) {
13178
- if (!isRecord4(error) || !isRecord4(error.details) || !Array.isArray(error.details.issues)) {
13302
+ if (!isRecord(error) || !isRecord(error.details) || !Array.isArray(error.details.issues)) {
13179
13303
  return [];
13180
13304
  }
13181
13305
  return error.details.issues.flatMap((issue) => {
13182
- if (!isRecord4(issue) || typeof issue.message !== "string") {
13306
+ if (!isRecord(issue) || typeof issue.message !== "string") {
13183
13307
  return [];
13184
13308
  }
13185
13309
  const path = Array.isArray(issue.path) ? issue.path.map(String).join(".") : void 0;
@@ -13192,9 +13316,6 @@ function toRelativePath(root, path) {
13192
13316
  function toPosixPath(path) {
13193
13317
  return path.split(sep2).join("/");
13194
13318
  }
13195
- function isRecord4(value) {
13196
- return typeof value === "object" && value !== null && !Array.isArray(value);
13197
- }
13198
13319
  function isNodeError2(error) {
13199
13320
  return error instanceof Error && "code" in error;
13200
13321
  }
@@ -13280,7 +13401,7 @@ async function fetchRemoteAsset(api, kind, name2) {
13280
13401
  throw new Error(`The skill '${name2}' cannot be read with all its files.`);
13281
13402
  for (const file of asset.files) {
13282
13403
  const bytes = file.base64 === void 0 ? Buffer.from(file.text ?? "", "utf8") : Buffer.from(file.base64, "base64");
13283
- if (sha256(bytes) !== file.sha256)
13404
+ if (sha256Hex(bytes) !== file.sha256)
13284
13405
  throw new Error(
13285
13406
  `The file '${file.path}' did not arrive as the instance holds it (its SHA-256 differs). Pull again.`
13286
13407
  );
@@ -13310,7 +13431,7 @@ function readDefinition(remote, config) {
13310
13431
  }
13311
13432
  }
13312
13433
  function guardrailAsFiles(config, source) {
13313
- if (!isRecord5(config) || typeof config.name !== "string") {
13434
+ if (!isRecord(config) || typeof config.name !== "string") {
13314
13435
  throw new Error(`The instance answered no guardrail definition for ${source}.`);
13315
13436
  }
13316
13437
  const files = serializeGuardrailFiles(config);
@@ -13449,7 +13570,7 @@ function skillExtraHashes(asset) {
13449
13570
  }
13450
13571
  function sortKeys2(value) {
13451
13572
  if (Array.isArray(value)) return value.map(sortKeys2);
13452
- if (!isRecord5(value)) return value;
13573
+ if (!isRecord(value)) return value;
13453
13574
  return Object.fromEntries(
13454
13575
  Object.keys(value).sort().map((key2) => [key2, sortKeys2(value[key2])])
13455
13576
  );
@@ -13468,7 +13589,7 @@ async function replaceSkillPackage(skillFilePath, skill, provenance, files) {
13468
13589
  directory,
13469
13590
  files.map((file) => ({
13470
13591
  ...file,
13471
- sha256: sha256(fileBytes(file)),
13592
+ sha256: sha256Hex(fileBytes(file)),
13472
13593
  bytes: fileBytes(file).length,
13473
13594
  contentType: "application/octet-stream"
13474
13595
  }))
@@ -13582,9 +13703,6 @@ async function openInstance(options) {
13582
13703
  url: instance.url
13583
13704
  };
13584
13705
  }
13585
- function assetHash(contents) {
13586
- return createHash2("sha256").update(contents).digest("hex");
13587
- }
13588
13706
  async function recordBaseline(workingDir, instanceKey, version, bundle, revisions, fullPull, defaultAgentName, tombstones = {}) {
13589
13707
  const path = resolve4(workingDir, STATE_FILENAME);
13590
13708
  const state = await readStateFile(path);
@@ -13601,7 +13719,7 @@ async function recordBaseline(workingDir, instanceKey, version, bundle, revision
13601
13719
  baseline.assets[asset.key] = {
13602
13720
  ...written,
13603
13721
  canonicalFormVersion: CANONICAL_FORM_VERSION,
13604
- hash: assetHash(asset.contents),
13722
+ hash: sha256Hex(asset.contents),
13605
13723
  ...asset.folderFiles === void 0 ? {} : { files: folderHashes(asset.folderFiles) }
13606
13724
  };
13607
13725
  }
@@ -13655,7 +13773,7 @@ function formatCommandError(error) {
13655
13773
  ${error.issues.map((issue) => `- ${issue.file}${issue.path ? ` (${issue.path})` : ""}: ${issue.message}`).join("\n")}`;
13656
13774
  }
13657
13775
  if (error instanceof ConfigApiError) {
13658
- const reason = isRecord5(error.details) ? error.details.reason : void 0;
13776
+ const reason = isRecord(error.details) ? error.details.reason : void 0;
13659
13777
  if (reason === BODY_TOO_LARGE_REASON) {
13660
13778
  return "The request is larger than the instance accepts in one call. Push in parts with --only.";
13661
13779
  }
@@ -13666,9 +13784,6 @@ ${error.issues.map((issue) => `- ${issue.file}${issue.path ? ` (${issue.path})`
13666
13784
  }
13667
13785
  return error instanceof Error ? error.message : String(error);
13668
13786
  }
13669
- function isRecord5(value) {
13670
- return typeof value === "object" && value !== null && !Array.isArray(value);
13671
- }
13672
13787
  function writeOutput(options, text2) {
13673
13788
  (options.stdout ?? ((value) => process.stdout.write(value)))(`${text2}
13674
13789
  `);
@@ -13691,10 +13806,10 @@ function filesOf(asset) {
13691
13806
  if (asset?.files) return new Map(asset.files.map((file) => [file.path, file.sha256]));
13692
13807
  const result = /* @__PURE__ */ new Map();
13693
13808
  const config = asset?.config;
13694
- if (!isRecord5(config)) return result;
13809
+ if (!isRecord(config)) return result;
13695
13810
  if (Array.isArray(config.files)) {
13696
13811
  for (const file of config.files) {
13697
- if (isRecord5(file) && typeof file.path === "string" && typeof file.content === "string") {
13812
+ if (isRecord(file) && typeof file.path === "string" && typeof file.content === "string") {
13698
13813
  result.set(file.path, file.content);
13699
13814
  }
13700
13815
  }
@@ -13708,9 +13823,9 @@ function filesOf(asset) {
13708
13823
  // src/app-publish-data.ts
13709
13824
  async function appPublishData(api, app, candidate, audienceLabel) {
13710
13825
  const config = candidate.config;
13711
- const manifest = isRecord5(config) && isRecord5(config.manifest) ? config.manifest : void 0;
13826
+ const manifest = isRecord(config) && isRecord(config.manifest) ? config.manifest : void 0;
13712
13827
  const reads = Array.isArray(manifest?.actions) && manifest.actions.some(
13713
- (action) => isRecord5(action) && action.kind === "sql" && action.effect === "reading"
13828
+ (action) => isRecord(action) && action.kind === "sql" && action.effect === "reading"
13714
13829
  );
13715
13830
  if (!reads) return "";
13716
13831
  const revision = candidate.contentRevision ?? candidate.revision;
@@ -13750,7 +13865,8 @@ function formatStoredData(data, audienceLabel) {
13750
13865
  }
13751
13866
 
13752
13867
  // src/app-publish-together.ts
13753
- var NONE = { workflows: [], lines: [] };
13868
+ var NONE = { workflows: [], dataStores: [], lines: [] };
13869
+ var migrationCount = (count3) => `${count3} migration${count3 === 1 ? "" : "s"}`;
13754
13870
  async function appPublishTogether(api, app) {
13755
13871
  let review;
13756
13872
  try {
@@ -13760,17 +13876,28 @@ async function appPublishTogether(api, app) {
13760
13876
  throw error;
13761
13877
  }
13762
13878
  const pending = review.workflows.filter((workflow) => workflow.pending);
13763
- 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
+ );
13764
13884
  const named = pending.map(
13765
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"}`
13766
13886
  );
13767
- const refusals = pending.flatMap(
13768
- (workflow) => workflow.refusals.map((refusal) => ` Workflow '${workflow.name}': ${refusal.message}`)
13769
- );
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
+ ];
13770
13895
  return {
13771
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 })),
13772
13898
  lines: [
13773
- "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,
13774
13901
  ...named,
13775
13902
  ` App '${review.app.title}' (${app})`,
13776
13903
  ...refusals.length > 0 ? ["Would refuse it now:", ...refusals] : []
@@ -13783,39 +13910,57 @@ import { lstat as lstat3, readFile as readFile6, readdir as readdir4 } from "fs/
13783
13910
  import { join as join5, relative as relative3, sep as sep4 } from "path";
13784
13911
  var APP_STATE_FILE = ".catalyst-app.json";
13785
13912
  var IGNORED_FOLDERS = /* @__PURE__ */ new Set(["node_modules"]);
13786
- async function readAppState(directory) {
13787
- 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);
13788
13925
  if (state === void 0) return void 0;
13789
- const { name: name2, ...base } = state;
13790
- return { ...base, app: name2 };
13791
- }
13792
- async function writeAppState(directory, state) {
13793
- 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
+ });
13794
13937
  }
13795
- async function readAppFolder(directory, limits, tracked) {
13938
+ async function readRepositoryFolder(directory, limits, tracked, kind) {
13796
13939
  const stats = await lstat3(directory).catch(() => void 0);
13797
13940
  if (!stats?.isDirectory()) {
13798
- 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
+ );
13799
13944
  }
13800
13945
  const found = [];
13801
13946
  const leftOut = [];
13802
13947
  await walk(directory, directory, tracked, found, leftOut);
13803
- if (!found.some((file) => file.path === "app.yaml")) {
13948
+ if (!found.some((file) => file.path === kind.manifest)) {
13804
13949
  throw new Error(
13805
- `'${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.`
13806
13951
  );
13807
13952
  }
13808
13953
  if (limits) {
13809
13954
  if (found.length > limits.FILE_SET_MAX_FILES) {
13810
13955
  throw new Error(
13811
- `'${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}.`
13812
13957
  );
13813
13958
  }
13814
13959
  const large = found.filter((file) => file.bytes > limits.FILE_SET_MAX_FILE_BYTES);
13815
13960
  if (large.length > 0) {
13816
13961
  throw new Error(
13817
13962
  [
13818
- `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:`,
13819
13964
  ...large.map((file) => `- ${file.path}: ${formatBytes(file.bytes)}`)
13820
13965
  ].join("\n")
13821
13966
  );
@@ -13824,7 +13969,7 @@ async function readAppFolder(directory, limits, tracked) {
13824
13969
  const cap = Math.min(limits.FILE_SET_MAX_TOTAL_BYTES, limits.ASSET_PUT_FILES_MAX_BYTES);
13825
13970
  if (total > cap) {
13826
13971
  throw new Error(
13827
- `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)}.`
13828
13973
  );
13829
13974
  }
13830
13975
  }
@@ -13832,7 +13977,7 @@ async function readAppFolder(directory, limits, tracked) {
13832
13977
  const hashes = {};
13833
13978
  for (const file of found.sort((left, right) => compare(left.path, right.path))) {
13834
13979
  const bytes = await readFile6(file.absolute);
13835
- hashes[file.path] = sha256(bytes);
13980
+ hashes[file.path] = sha256Hex(bytes);
13836
13981
  const text2 = utf8Text2(bytes);
13837
13982
  files.push(
13838
13983
  text2 === void 0 ? { path: file.path, base64: Buffer.from(bytes).toString("base64") } : { path: file.path, text: text2 }
@@ -13994,7 +14139,7 @@ function formatRefusal(error) {
13994
14139
  return [head, ...detailLines(error.details)].join("\n");
13995
14140
  }
13996
14141
  function detailLines(details) {
13997
- if (!isRecord6(details)) return [];
14142
+ if (!isRecord(details)) return [];
13998
14143
  const lines = [];
13999
14144
  for (const issue of records(details.issues)) {
14000
14145
  lines.push(`- ${issueLocation(issue)}${String(issue.message)}`);
@@ -14008,7 +14153,7 @@ function detailLines(details) {
14008
14153
  lines.push(`- ${String(asset.kind)} '${String(asset.name)}' names no revision`);
14009
14154
  }
14010
14155
  for (const item of records(details.items)) {
14011
- if (isRecord6(item.error)) {
14156
+ if (isRecord(item.error)) {
14012
14157
  lines.push(
14013
14158
  `- ${String(item.kind)} '${String(item.name ?? item.index)}': ${String(item.error.message)}`
14014
14159
  );
@@ -14041,10 +14186,7 @@ function table(head, rows) {
14041
14186
  ).join("\n");
14042
14187
  }
14043
14188
  function records(value) {
14044
- return Array.isArray(value) ? value.filter(isRecord6) : [];
14045
- }
14046
- function isRecord6(value) {
14047
- return typeof value === "object" && value !== null && !Array.isArray(value);
14189
+ return Array.isArray(value) ? value.filter(isRecord) : [];
14048
14190
  }
14049
14191
  function formatDryRun(name2, answer) {
14050
14192
  const people = (count3) => `${count3.actions} action${count3.actions === 1 ? "" : "s"} by ${count3.people} ${count3.people === 1 ? "person" : "people"}`;
@@ -14090,7 +14232,7 @@ function waitingPublishLine(run, approvalHint) {
14090
14232
  }
14091
14233
  function agentPublishRefusalHint(error) {
14092
14234
  if (!(error instanceof ConfigApiError) || error.status !== 403) return void 0;
14093
- const reason = isRecord5(error.details) ? error.details.reason : void 0;
14235
+ const reason = isRecord(error.details) ? error.details.reason : void 0;
14094
14236
  const keyRefused = reason === "user_only" || reason === "outside_key_scope" || error.message.includes(`'${PUBLISH_SCOPE}'`);
14095
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.";
14096
14238
  }
@@ -14099,7 +14241,7 @@ var PUBLISH_SCOPE = "config_assets:publish";
14099
14241
  // src/app-commands.ts
14100
14242
  var EXIT = { done: 0, refused: 1, usage: 2, pending: 3 };
14101
14243
  var APP_KIND = "app";
14102
- var AppUsageError = class extends Error {
14244
+ var RepositoryUsageError = class extends Error {
14103
14245
  };
14104
14246
  var APP_VERBS = {
14105
14247
  pull: {
@@ -14119,39 +14261,45 @@ var APP_VERBS = {
14119
14261
  summary: "The draft and the published revision, and what a pulled folder changed"
14120
14262
  }
14121
14263
  };
14122
- function isAppVerb(value) {
14264
+ function isRepositoryVerb(value) {
14123
14265
  return Object.hasOwn(APP_VERBS, value);
14124
14266
  }
14125
- async function runAppCommand(verb, positionals, values, options) {
14267
+ async function runRepositoryCommand(verb, positionals, values, options, kind) {
14126
14268
  switch (verb) {
14127
14269
  case "pull": {
14128
14270
  const [app, dir, ...extra] = positionals;
14129
- 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
+ );
14130
14275
  refuseExtra(extra);
14131
14276
  if (values.published && values.revision !== void 0) {
14132
- throw new AppUsageError("Pass --published or --revision, not both.");
14277
+ throw new RepositoryUsageError("Pass --published or --revision, not both.");
14133
14278
  }
14134
- return pull(app, resolve5(options.cwd, dir ?? app), values, options);
14279
+ return pull(app, resolve5(options.cwd, dir ?? app), values, options, kind);
14135
14280
  }
14136
14281
  case "push": {
14137
14282
  const [dir, ...extra] = positionals;
14138
14283
  refuseExtra(extra);
14139
14284
  refuseRevisionFlags(values, "push");
14140
- return push(resolve5(options.cwd, dir ?? "."), values, options);
14285
+ return push(resolve5(options.cwd, dir ?? "."), values, options, kind);
14141
14286
  }
14142
14287
  case "publish": {
14143
14288
  const [app, ...extra] = positionals;
14144
14289
  if (app === void 0) {
14145
- throw new AppUsageError(`Usage: catalyst app ${APP_VERBS.publish.usage}`);
14290
+ throw new RepositoryUsageError(`Usage: catalyst app ${APP_VERBS.publish.usage}`);
14146
14291
  }
14147
14292
  refuseExtra(extra);
14148
- 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'.");
14149
14295
  return publish(app, values, options);
14150
14296
  }
14151
14297
  case "status": {
14152
14298
  const [app, dir, ...extra] = positionals;
14153
14299
  if (app === void 0) {
14154
- 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
+ );
14155
14303
  }
14156
14304
  refuseExtra(extra);
14157
14305
  refuseRevisionFlags(values, "status");
@@ -14159,26 +14307,29 @@ async function runAppCommand(verb, positionals, values, options) {
14159
14307
  app,
14160
14308
  dir === void 0 ? void 0 : resolve5(options.cwd, dir),
14161
14309
  values,
14162
- options
14310
+ options,
14311
+ kind
14163
14312
  );
14164
14313
  }
14165
14314
  }
14166
14315
  }
14167
- async function pull(app, directory, values, options) {
14168
- const previous = await readAppState(directory);
14316
+ async function pull(app, directory, values, options, kind) {
14317
+ const previous = await readRepositoryState(directory, kind);
14169
14318
  if (previous === void 0 && !await folderIsEmpty(directory)) {
14170
- throw new AppUsageError(
14171
- `'${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.`
14172
14321
  );
14173
14322
  }
14174
- if (previous !== void 0 && previous.app !== app) {
14175
- 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
+ );
14176
14327
  }
14177
14328
  if (previous !== void 0) {
14178
14329
  const changes = await localChanges2(directory, previous);
14179
14330
  const touched = [...changes.changed, ...changes.added, ...changes.removed];
14180
14331
  if (touched.length > 0) {
14181
- throw new AppUsageError(
14332
+ throw new RepositoryUsageError(
14182
14333
  [
14183
14334
  `'${directory}' has local changes a pull would overwrite. Push them, or pull into another folder to compare:`,
14184
14335
  ...touched.sort().map((path) => `- ${path}`)
@@ -14187,11 +14338,11 @@ async function pull(app, directory, values, options) {
14187
14338
  }
14188
14339
  }
14189
14340
  if (values.revision !== void 0) revisionNumber(values.revision);
14190
- const target = await openApp(options, values, previous);
14341
+ const target = await openRepository(options, values, previous, kind);
14191
14342
  const revision = values.published ? "published" : values.revision ?? "draft";
14192
14343
  const asset = await target.api.read(
14193
14344
  (client) => client.assets.get({
14194
- params: { kind: APP_KIND, name: app },
14345
+ params: { kind: kind.kind, name: app },
14195
14346
  query: { workspaceId: target.workspaceId, revision, files: "true" }
14196
14347
  })
14197
14348
  );
@@ -14202,61 +14353,94 @@ async function pull(app, directory, values, options) {
14202
14353
  }
14203
14354
  const contentRevision = asset.contentRevision ?? asset.revision;
14204
14355
  const hashes = await writeFolderFiles(directory, asset.files, previous);
14205
- await writeAppState(directory, {
14206
- instance: target.url,
14207
- workspaceId: target.workspaceId,
14208
- app,
14209
- assetId: asset.id,
14210
- revision: contentRevision,
14211
- files: hashes
14212
- });
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
+ );
14213
14368
  const which = contentRevision === asset.draftRevision ? "the draft" : contentRevision === asset.publishedRevision ? "the published revision" : "revision";
14214
14369
  writeOut(
14215
14370
  options,
14216
- 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.` : ""}`
14217
14376
  );
14218
14377
  return EXIT.done;
14219
14378
  }
14220
- async function push(directory, values, options) {
14221
- const state = await readAppState(directory);
14222
- const target = await openApp(options, values, state);
14223
- const kind = target.kinds.find((candidate) => candidate.kind === APP_KIND);
14224
- if (kind === void 0) {
14225
- 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
+ );
14226
14387
  }
14227
- const read2 = await readAppFolder(
14388
+ const read2 = await readRepositoryFolder(
14228
14389
  directory,
14229
- kind.limits,
14230
- new Set(Object.keys(state?.files ?? {}))
14390
+ registered.limits,
14391
+ new Set(Object.keys(state?.files ?? {})),
14392
+ kind
14231
14393
  );
14232
- const name2 = state?.app ?? appIdOf(read2.files);
14394
+ const name2 = state?.name ?? repositoryIdOf(read2.files, kind);
14233
14395
  if (state === void 0 && name2 === void 0) {
14234
- throw new AppUsageError(
14235
- "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}.`
14236
14398
  );
14237
14399
  }
14238
14400
  const app = name2 ?? "";
14239
- const declared = state === void 0 ? void 0 : declaredIdOf(read2.files);
14240
- if (state !== void 0 && declared !== void 0 && declared !== state.app) {
14241
- throw new AppUsageError(
14242
- `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}'.`
14243
14405
  );
14244
14406
  }
14245
14407
  const expectedRevision = state?.revision ?? null;
14246
14408
  if (state !== void 0 && state.workspaceId !== target.workspaceId) {
14247
- throw new AppUsageError(
14409
+ throw new RepositoryUsageError(
14248
14410
  `'${directory}' was pulled from workspace ${state.workspaceId}, and the command names ${target.workspaceId}.`
14249
14411
  );
14250
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
+ }
14251
14435
  let outcome;
14252
14436
  try {
14253
14437
  outcome = await target.api.change(
14254
14438
  (client, idempotencyKey2) => client.assets.put({
14255
- params: { kind: APP_KIND, name: app },
14439
+ params: { kind: kind.kind, name: app },
14256
14440
  body: { files: read2.files, expectedRevision, workspaceId: target.workspaceId },
14257
14441
  idempotencyKey: idempotencyKey2
14258
14442
  }),
14259
- `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.`
14260
14444
  );
14261
14445
  } catch (error) {
14262
14446
  if (error instanceof ConfigApiError && (error.status === 412 || error.status === 409 && expectedRevision === null)) {
@@ -14264,7 +14448,7 @@ async function push(directory, values, options) {
14264
14448
  options,
14265
14449
  [
14266
14450
  formatRefusal(error),
14267
- 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.`
14268
14452
  ].join("\n")
14269
14453
  );
14270
14454
  return EXIT.refused;
@@ -14277,22 +14461,26 @@ async function push(directory, values, options) {
14277
14461
  const output = outcome.output;
14278
14462
  const asset = await target.api.read(
14279
14463
  (client) => client.assets.get({
14280
- params: { kind: APP_KIND, name: app },
14464
+ params: { kind: kind.kind, name: app },
14281
14465
  query: { workspaceId: target.workspaceId }
14282
14466
  })
14283
14467
  );
14284
- await writeAppState(directory, {
14285
- instance: target.url,
14286
- workspaceId: target.workspaceId,
14287
- app,
14288
- assetId: asset.id,
14289
- revision: output.revision,
14290
- files: read2.hashes
14291
- });
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
+ );
14292
14480
  writeOut(
14293
14481
  options,
14294
14482
  values.json ? JSON.stringify({ ...output, leftOut: read2.leftOut }, null, 2) : [
14295
- `${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}`}'.`,
14296
14484
  ...read2.leftOut.length === 0 ? [] : [`Left out: ${read2.leftOut.join(", ")}`],
14297
14485
  ...formatWarnings(output.warnings)
14298
14486
  ].join("\n")
@@ -14301,7 +14489,7 @@ async function push(directory, values, options) {
14301
14489
  }
14302
14490
  async function publish(app, values, options) {
14303
14491
  if (values.revision !== void 0) revisionNumber(values.revision);
14304
- const target = await openApp(options, values, void 0);
14492
+ const target = await openRepository(options, values, void 0, REPOSITORY_KINDS.app);
14305
14493
  let audience = readAudience(values.audience);
14306
14494
  const get = (revision, files = false) => target.api.read(
14307
14495
  (client) => client.assets.get({
@@ -14318,7 +14506,7 @@ async function publish(app, values, options) {
14318
14506
  const offered = candidate.appAudience;
14319
14507
  if (!audience) {
14320
14508
  if (values.yes || !options.prompt)
14321
- throw new AppUsageError(
14509
+ throw new RepositoryUsageError(
14322
14510
  "Choose who may use the App with --audience self|workspace|instance. Nothing was published."
14323
14511
  );
14324
14512
  const choices = offered?.choices ?? ["self", "workspace"];
@@ -14327,11 +14515,11 @@ async function publish(app, values, options) {
14327
14515
  );
14328
14516
  audience = readAudience(await options.prompt(`For whom? ${labels.join("; ")}: `));
14329
14517
  if (!audience || !choices.includes(audience))
14330
- 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.");
14331
14519
  candidate = await get(values.revision ?? "draft");
14332
14520
  }
14333
14521
  if (offered && !offered.choices.includes(audience))
14334
- 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.");
14335
14523
  const number = candidate.contentRevision ?? candidate.revision;
14336
14524
  if (values.revision !== void 0 && number !== revisionNumber(values.revision)) {
14337
14525
  throw new Error(`The instance answered revision ${number} for --revision ${values.revision}.`);
@@ -14359,7 +14547,7 @@ async function publish(app, values, options) {
14359
14547
  candidate,
14360
14548
  candidate.appAudience ? `${candidate.appAudience.label}${candidate.appAudience.people === void 0 ? "" : ` (${candidate.appAudience.people} people)`}` : void 0
14361
14549
  );
14362
- 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: [] };
14363
14551
  const question = [formatReview(app, review), storedData, together.lines.join("\n")].filter(Boolean).join("\n");
14364
14552
  const say = (text2) => values.json ? writeErr(options, text2) : writeOut(options, text2);
14365
14553
  const narrative = values.yes ? void 0 : candidate.publishNarrative;
@@ -14394,7 +14582,8 @@ async function publish(app, values, options) {
14394
14582
  revision: number,
14395
14583
  workspaceId: target.workspaceId,
14396
14584
  audience,
14397
- ...together.workflows.length > 0 ? { workflows: together.workflows } : {}
14585
+ ...together.workflows.length > 0 ? { workflows: together.workflows } : {},
14586
+ ...together.dataStores.length > 0 ? { dataStores: together.dataStores } : {}
14398
14587
  },
14399
14588
  idempotencyKey: idempotencyKey2,
14400
14589
  ...answer === "unattended" ? { unattended: true } : {}
@@ -14413,7 +14602,7 @@ async function publish(app, values, options) {
14413
14602
  options,
14414
14603
  values.json ? JSON.stringify(outcome.output, null, 2) : [
14415
14604
  ...(outcome.output.publishedWith ?? []).map(
14416
- (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}'.`
14417
14606
  ),
14418
14607
  `Published revision ${outcome.output.publishedRevision} of App '${app}'${outcome.output.replacedRevision === void 0 ? "" : ` in place of revision ${outcome.output.replacedRevision}`}.`
14419
14608
  ].join("\n")
@@ -14421,21 +14610,25 @@ async function publish(app, values, options) {
14421
14610
  return EXIT.done;
14422
14611
  }
14423
14612
  function startsWorkflows(config) {
14424
- const manifest = isRecord7(config) && isRecord7(config.manifest) ? config.manifest : void 0;
14425
- 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");
14426
14615
  }
14427
- async function status(app, directory, values, options) {
14428
- 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);
14429
14618
  if (directory !== void 0 && state === void 0) {
14430
- 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
+ );
14431
14622
  }
14432
- if (state !== void 0 && state.app !== app) {
14433
- 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
+ );
14434
14627
  }
14435
- const target = await openApp(options, values, state);
14628
+ const target = await openRepository(options, values, state, kind);
14436
14629
  const asset = await target.api.read(
14437
14630
  (client) => client.assets.get({
14438
- params: { kind: APP_KIND, name: app },
14631
+ params: { kind: kind.kind, name: app },
14439
14632
  query: { workspaceId: target.workspaceId }
14440
14633
  })
14441
14634
  );
@@ -14444,16 +14637,17 @@ async function status(app, directory, values, options) {
14444
14637
  target.api,
14445
14638
  app,
14446
14639
  target.workspaceId,
14447
- asset.publishedRevision ?? draft
14640
+ asset.publishedRevision ?? draft,
14641
+ kind
14448
14642
  );
14449
14643
  const by = (revision) => revisions.find((entry) => entry.revision === revision);
14450
14644
  const local = directory === void 0 || state === void 0 ? void 0 : { directory, base: state.revision, ...await localChanges2(directory, state) };
14451
14645
  const report = {
14452
- app,
14646
+ [kind.kind]: app,
14453
14647
  workspaceId: target.workspaceId,
14454
14648
  draftRevision: draft,
14455
14649
  publishedRevision: asset.publishedRevision ?? null,
14456
- kit: kitOf(asset.config),
14650
+ ...kind.kind === "app" ? { kit: kitOf(asset.config) } : {},
14457
14651
  ...local === void 0 ? {} : { local }
14458
14652
  };
14459
14653
  if (values.json) {
@@ -14462,12 +14656,14 @@ async function status(app, directory, values, options) {
14462
14656
  }
14463
14657
  const line = (revision) => revision === void 0 ? "" : ` (${revision.operation} by ${revision.actor?.displayLabel ?? "unknown"}, ${revision.createdAt})`;
14464
14658
  const lines = [
14465
- `App '${app}' in workspace ${target.workspaceId}`,
14659
+ `${kind.label} '${app}' in workspace ${target.workspaceId}`,
14466
14660
  `Draft: revision ${draft}${line(by(draft))}`,
14467
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"}`,
14468
14662
  // A revision exists only once its files built: a push that does not build writes none and
14469
14663
  // prints its errors itself.
14470
- `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
+ ] : []
14471
14667
  ];
14472
14668
  if (local !== void 0) {
14473
14669
  const touched = [
@@ -14483,13 +14679,13 @@ async function status(app, directory, values, options) {
14483
14679
  writeOut(options, lines.join("\n"));
14484
14680
  return EXIT.done;
14485
14681
  }
14486
- async function revisionsDownTo(api, app, workspaceId, oldest) {
14682
+ async function revisionsDownTo(api, app, workspaceId, oldest, kind) {
14487
14683
  const revisions = [];
14488
14684
  let cursor;
14489
14685
  do {
14490
14686
  const page2 = await api.read(
14491
14687
  (client) => client.assets.revisions.list({
14492
- params: { kind: APP_KIND, name: app },
14688
+ params: { kind: kind.kind, name: app },
14493
14689
  query: { limit: MAX_LIST_LIMIT, workspaceId, ...cursor === void 0 ? {} : { cursor } }
14494
14690
  })
14495
14691
  );
@@ -14547,7 +14743,7 @@ function formatReview(app, review) {
14547
14743
  )
14548
14744
  ].join("\n");
14549
14745
  }
14550
- async function openApp(options, values, state) {
14746
+ async function openRepository(options, values, state, kind) {
14551
14747
  const manifest = await readManifestIfPresent(resolveWorkingDir(options));
14552
14748
  const instance = await resolveInstance(manifest, {
14553
14749
  ...options,
@@ -14555,42 +14751,42 @@ async function openApp(options, values, state) {
14555
14751
  });
14556
14752
  const { url } = instance;
14557
14753
  if (state !== void 0 && state.instance !== url) {
14558
- throw new AppUsageError(
14754
+ throw new RepositoryUsageError(
14559
14755
  `The folder was pulled from ${state.instance}, and the command names ${url}. A folder belongs to one instance.`
14560
14756
  );
14561
14757
  }
14562
14758
  const workspaceId = values.workspace ?? state?.workspaceId ?? instance.workspace;
14563
14759
  if (workspaceId === void 0) {
14564
- throw new AppUsageError(
14565
- "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.`
14566
14762
  );
14567
14763
  }
14568
14764
  const api = await connectApi(url, options);
14569
14765
  const context = await api.read((client) => client.platform.context.get());
14570
14766
  return { api, url, workspaceId, kinds: context.kinds };
14571
14767
  }
14572
- function appIdOf(files) {
14573
- const manifest = files.find((file) => file.path === "app.yaml");
14768
+ function repositoryIdOf(files, kind) {
14769
+ const manifest = files.find((file) => file.path === kind.manifest);
14574
14770
  if (manifest?.text === void 0) return void 0;
14575
14771
  let parsed;
14576
14772
  try {
14577
14773
  parsed = yaml6.load(manifest.text);
14578
14774
  } catch (error) {
14579
- throw new AppUsageError(
14580
- `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)}`
14581
14777
  );
14582
14778
  }
14583
- return isRecord7(parsed) && typeof parsed.id === "string" ? parsed.id : void 0;
14779
+ return isRecord(parsed) && typeof parsed.id === "string" ? parsed.id : void 0;
14584
14780
  }
14585
- function declaredIdOf(files) {
14781
+ function declaredIdOf(files, kind) {
14586
14782
  try {
14587
- return appIdOf(files);
14783
+ return repositoryIdOf(files, kind);
14588
14784
  } catch {
14589
14785
  return void 0;
14590
14786
  }
14591
14787
  }
14592
14788
  function manifestOf(config) {
14593
- return isRecord7(config) && isRecord7(config.manifest) ? config.manifest : void 0;
14789
+ return isRecord(config) && isRecord(config.manifest) ? config.manifest : void 0;
14594
14790
  }
14595
14791
  function kitOf(config) {
14596
14792
  const kit = manifestOf(config)?.kit;
@@ -14599,13 +14795,13 @@ function kitOf(config) {
14599
14795
  function actionsOf(manifest) {
14600
14796
  const actions = manifest?.actions;
14601
14797
  return (Array.isArray(actions) ? actions : []).flatMap(
14602
- (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) }] : []
14603
14799
  );
14604
14800
  }
14605
14801
  function dataStoresOf(manifest) {
14606
14802
  const stores = manifest?.dataStores;
14607
14803
  return (Array.isArray(stores) ? stores : []).flatMap(
14608
- (store) => isRecord7(store) && typeof store.name === "string" ? [
14804
+ (store) => isRecord(store) && typeof store.name === "string" ? [
14609
14805
  {
14610
14806
  name: store.name,
14611
14807
  ...typeof store.minSchema === "number" ? { minSchema: store.minSchema } : {}
@@ -14615,7 +14811,7 @@ function dataStoresOf(manifest) {
14615
14811
  }
14616
14812
  function canonicalJson(value) {
14617
14813
  if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
14618
- if (isRecord7(value)) {
14814
+ if (isRecord(value)) {
14619
14815
  return `{${Object.keys(value).sort().map((key2) => `${JSON.stringify(key2)}:${canonicalJson(value[key2])}`).join(",")}}`;
14620
14816
  }
14621
14817
  return JSON.stringify(value) ?? "null";
@@ -14624,21 +14820,20 @@ function texts(value) {
14624
14820
  return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
14625
14821
  }
14626
14822
  function revisionNumber(value) {
14627
- 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.`);
14628
14825
  return Number(value);
14629
14826
  }
14630
14827
  function refuseExtra(extra) {
14631
- if (extra.length > 0) throw new AppUsageError(`Unexpected argument '${extra[0]}'.`);
14828
+ if (extra.length > 0) throw new RepositoryUsageError(`Unexpected argument '${extra[0]}'.`);
14632
14829
  }
14633
14830
  function refuseRevisionFlags(values, verb) {
14634
- 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}'.`);
14635
14833
  if (values.revision !== void 0) {
14636
- throw new AppUsageError(`--revision is not an option of '${verb}'.`);
14834
+ throw new RepositoryUsageError(`--revision is not an option of '${verb}'.`);
14637
14835
  }
14638
14836
  }
14639
- function isRecord7(value) {
14640
- return typeof value === "object" && value !== null && !Array.isArray(value);
14641
- }
14642
14837
  function writeOut(target, text2) {
14643
14838
  (target.stdout ?? ((value) => process.stdout.write(value)))(`${text2}
14644
14839
  `);
@@ -14655,7 +14850,9 @@ function pendingApproval(run, json2, options, hint) {
14655
14850
  function readAudience(value) {
14656
14851
  if (value === void 0) return void 0;
14657
14852
  if (value === "self" || value === "workspace" || value === "instance") return value;
14658
- 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
+ );
14659
14856
  }
14660
14857
 
14661
14858
  // src/follow-commands.ts
@@ -14730,14 +14927,19 @@ Instance:
14730
14927
  requests [--withdraw <id>] List your requests, or withdraw one of them
14731
14928
 
14732
14929
  Assets, for every kind the instance registers (agent, skill, app, workflow, data-store, ...):
14733
- catalyst skill pull <name> <folder>
14734
- Write every file of one skill locally; refresh only a clean earlier pull
14735
- ${verbs.map((verb) => ` catalyst <kind> ${verb.usage}
14736
- ${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")}
14737
14932
 
14738
14933
  An App as a folder (its draft is built on push; publish shows what goes live and asks):
14739
- ${Object.values(APP_VERBS).map((verb) => ` catalyst app ${verb.usage}
14740
- ${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)
14741
14943
 
14742
14944
  Options:
14743
14945
  --instance <name-or-url> An instance of catalyst.yaml, or its URL. Left out: the
@@ -14844,7 +15046,7 @@ async function pushConfig(options) {
14844
15046
  );
14845
15047
  }
14846
15048
  const touched = assetEntries(bundle).filter(
14847
- (asset) => baselineAssets[asset.key]?.hash !== assetHash(asset.contents)
15049
+ (asset) => baselineAssets[asset.key]?.hash !== sha256Hex(asset.contents)
14848
15050
  );
14849
15051
  const undrafted = touched.filter(
14850
15052
  (asset) => asset.kind === "agent" && baselineAssets[asset.key]?.draftRevision === void 0
@@ -15376,7 +15578,7 @@ async function createPushPlan(api, local, remote, touchedKeys, baseline) {
15376
15578
  }
15377
15579
  const base = baseline?.assets?.[asset.key];
15378
15580
  if (base?.revision === remoteAsset.revision && base.id === remoteAsset.id) {
15379
- return base.hash !== assetHash(asset.contents);
15581
+ return base.hash !== sha256Hex(asset.contents);
15380
15582
  }
15381
15583
  const fetched = await fetchRemoteAsset(api, remoteAsset.kind, remoteAsset.name);
15382
15584
  return fetched === void 0 || assetContents(fetched) !== asset.contents;
@@ -15430,9 +15632,9 @@ function formatPushPlan(plan, prune, guardrailPuts) {
15430
15632
  }
15431
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.";
15432
15634
  function readDraftConflict(error) {
15433
- const details = isRecord5(error.details) ? error.details : void 0;
15635
+ const details = isRecord(error.details) ? error.details : void 0;
15434
15636
  if (error.code !== "REVISION_CONFLICT" || details?.reason !== "draft_changed") return void 0;
15435
- const author = isRecord5(details.author) ? details.author : void 0;
15637
+ const author = isRecord(details.author) ? details.author : void 0;
15436
15638
  const revision = typeof details.currentDraftRevision === "number" ? details.currentDraftRevision : null;
15437
15639
  return {
15438
15640
  kind: typeof details.kind === "string" ? details.kind : "agent",
@@ -15458,9 +15660,9 @@ async function readTombstones(api, keys) {
15458
15660
  return Object.fromEntries(keys.map((key2, index) => [key2, revisions[index]]));
15459
15661
  }
15460
15662
  function readConflicts(details) {
15461
- const conflicts = isRecord5(details) && Array.isArray(details.conflicts) ? details.conflicts : [];
15663
+ const conflicts = isRecord(details) && Array.isArray(details.conflicts) ? details.conflicts : [];
15462
15664
  return conflicts.flatMap(
15463
- (conflict) => isRecord5(conflict) && typeof conflict.kind === "string" && typeof conflict.name === "string" ? [
15665
+ (conflict) => isRecord(conflict) && typeof conflict.kind === "string" && typeof conflict.name === "string" ? [
15464
15666
  {
15465
15667
  kind: conflict.kind,
15466
15668
  name: conflict.name,
@@ -15473,17 +15675,17 @@ function readConflicts(details) {
15473
15675
  );
15474
15676
  }
15475
15677
  function readRefusedBatch(error) {
15476
- const details = isRecord5(error.details) ? error.details : {};
15678
+ const details = isRecord(error.details) ? error.details : {};
15477
15679
  const defaultAgentConflict = error.code === "CONFLICT" && details.reason === "default_agent_changed";
15478
15680
  if (details.reason !== "sync_refused" && !defaultAgentConflict && error.status !== 422) {
15479
15681
  return void 0;
15480
15682
  }
15481
15683
  const refused = (Array.isArray(details.items) ? details.items : []).flatMap(
15482
- (item) => isRecord5(item) && isRecord5(item.error) ? [{ item, refusal: item.error }] : []
15684
+ (item) => isRecord(item) && isRecord(item.error) ? [{ item, refusal: item.error }] : []
15483
15685
  );
15484
15686
  const label = (item) => `${String(item.kind)}${typeof item.name === "string" ? ` '${item.name}'` : typeof item.index === "number" ? ` #${item.index + 1}` : ""}`;
15485
15687
  const issues = (Array.isArray(details.issues) ? details.issues : []).flatMap(
15486
- (issue) => isRecord5(issue) && typeof issue.message === "string" ? [issue] : []
15688
+ (issue) => isRecord(issue) && typeof issue.message === "string" ? [issue] : []
15487
15689
  );
15488
15690
  return {
15489
15691
  message: error.message,
@@ -15513,7 +15715,7 @@ async function checkSyncOnThisRelease(api, batch) {
15513
15715
  }
15514
15716
  }
15515
15717
  function isMissingCheck(error) {
15516
- 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");
15517
15719
  }
15518
15720
  function formatRefusal2(title, refusal) {
15519
15721
  if (refusal.lines.length === 0) {
@@ -15787,7 +15989,7 @@ var pullVerb = {
15787
15989
  options: {},
15788
15990
  prepare: (_values, name2, cwd, noun, folder) => {
15789
15991
  if (noun !== "skill" && noun !== "skills")
15790
- 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.");
15791
15993
  if (!folder) throw new UsageError("Usage: catalyst skill pull <name> <folder>");
15792
15994
  const directory = resolve8(cwd, folder);
15793
15995
  return async (session2) => {
@@ -16563,6 +16765,67 @@ var setDefaultVerb = {
16563
16765
  }
16564
16766
  };
16565
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
+
16566
16829
  // src/asset-verbs/index.ts
16567
16830
  var VERBS = {
16568
16831
  list: listVerb,
@@ -16581,7 +16844,8 @@ var VERBS = {
16581
16844
  delete: deleteVerb,
16582
16845
  revert: revertVerb,
16583
16846
  "set-availability": setAvailabilityVerb,
16584
- "set-default": setDefaultVerb
16847
+ "set-default": setDefaultVerb,
16848
+ adopt: adoptVerb
16585
16849
  };
16586
16850
 
16587
16851
  // src/asset-commands.ts
@@ -16609,7 +16873,13 @@ function parseCommandLine(args) {
16609
16873
  const parsed = parseArgs({ args, options: OPTIONS, allowPositionals: true, strict: true });
16610
16874
  return {
16611
16875
  ...parsed,
16612
- 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
+ }
16613
16883
  };
16614
16884
  }
16615
16885
  var APP_FLAGS = {
@@ -16696,15 +16966,24 @@ ${assetHelpText}`);
16696
16966
  instanceCommand === "docs" ? verbName : name2
16697
16967
  );
16698
16968
  }
16699
- 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")) {
16700
16973
  refuseFlags(values, [...COMMON_FLAGS, ...APP_FLAGS[verbName]], verbName);
16701
- 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
+ );
16702
16981
  }
16703
16982
  const verb = VERBS[verbName];
16704
16983
  if (verb === void 0) throw new UsageError(`Unknown command '${noun} ${verbName}'.`);
16705
16984
  refuseFlags(values, [...COMMON_FLAGS, ...Object.keys(verb.options)], verbName);
16706
16985
  if (verb.named && name2 === "") throw new UsageError(`Usage: catalyst ${noun} ${verb.usage}`);
16707
- 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 !== "") {
16708
16987
  throw new UsageError(`Unexpected argument '${extra[0] ?? name2}'.`);
16709
16988
  }
16710
16989
  const call3 = verb.prepare(values, name2, options.cwd, noun, extra[0]);
@@ -16720,7 +16999,7 @@ ${assetHelpText}`);
16720
16999
  options
16721
17000
  });
16722
17001
  } catch (error) {
16723
- if (error instanceof UsageError || error instanceof AppUsageError) {
17002
+ if (error instanceof UsageError || error instanceof RepositoryUsageError) {
16724
17003
  writeError(options, error.message);
16725
17004
  return EXIT3.usage;
16726
17005
  }
@@ -16812,7 +17091,9 @@ var assetsGroup = {
16812
17091
  "requests",
16813
17092
  ...Object.keys(VERBS).filter((name2) => name2 !== "pull").map((name2) => `<kind> ${name2}`),
16814
17093
  "skill pull",
16815
- ...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
+ )
16816
17097
  ],
16817
17098
  matches: () => true,
16818
17099
  help: assetHelpText,
@@ -16833,6 +17114,7 @@ var assetsGroup = {
16833
17114
  import { parseArgs as parseArgs2 } from "util";
16834
17115
 
16835
17116
  // src/login.ts
17117
+ import { setTimeout as defaultSleep2 } from "timers/promises";
16836
17118
  import { hostname } from "os";
16837
17119
  async function loginCommand(options) {
16838
17120
  try {
@@ -16941,12 +17223,8 @@ async function call(request) {
16941
17223
  function formatTime(iso) {
16942
17224
  return new Date(iso).toLocaleString();
16943
17225
  }
16944
- function defaultSleep2(milliseconds) {
16945
- return new Promise((resolveSleep) => setTimeout(resolveSleep, milliseconds));
16946
- }
16947
17226
 
16948
17227
  // src/setup.ts
16949
- import { createHash as createHash3 } from "crypto";
16950
17228
  import { lstat as lstat4, mkdir as mkdir5, readFile as readFile9, rename as rename5, rm as rm4, writeFile as writeFile5 } from "fs/promises";
16951
17229
  import { homedir as homedir2, hostname as hostname2 } from "os";
16952
17230
  import { dirname as dirname6, join as join8 } from "path";
@@ -16976,18 +17254,15 @@ function isLocalAgentTool(value) {
16976
17254
  var SETUP_USAGE = "Usage: catalyst setup <claude-code|codex|other> --instance <url> [--force]";
16977
17255
  var SHIPPED_SKILL = new URL("../skills/catalyst/SKILL.md", import.meta.url);
16978
17256
  var MARK = /\n<!-- Written by catalyst setup \(@work-shape\/catalyst-cli [^,]+, sha256 ([0-9a-f]{64})\)\. -->\n$/u;
16979
- function sha2562(text2) {
16980
- return createHash3("sha256").update(text2).digest("hex");
16981
- }
16982
17257
  async function renderCatalystSkill() {
16983
17258
  const body = await readFile9(SHIPPED_SKILL, "utf8");
16984
17259
  return `${body}
16985
- <!-- 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)}). -->
16986
17261
  `;
16987
17262
  }
16988
17263
  function writtenBySetup(contents) {
16989
17264
  const mark2 = MARK.exec(contents);
16990
- return mark2 !== null && sha2562(contents.slice(0, mark2.index)) === mark2[1];
17265
+ return mark2 !== null && sha256Hex(contents.slice(0, mark2.index)) === mark2[1];
16991
17266
  }
16992
17267
  function catalystSkillPath(tool, env) {
16993
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);
@@ -17007,7 +17282,8 @@ async function setupCommand(options) {
17007
17282
  url,
17008
17283
  `${tool.label} on ${hostname2()}`,
17009
17284
  options.openUrl ?? openInstanceAddress(url),
17010
- // 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.
17011
17287
  true
17012
17288
  );
17013
17289
  if (key2 === void 0) {
@@ -17312,7 +17588,7 @@ function createSkillFileDiff(name2, oldFiles, newFiles) {
17312
17588
  const output = [];
17313
17589
  for (const path of [.../* @__PURE__ */ new Set([...before.keys(), ...after.keys()])].sort()) {
17314
17590
  const oldBytes = before.get(path), newBytes = after.get(path);
17315
- if (oldBytes && newBytes && sha256(oldBytes) === sha256(newBytes)) continue;
17591
+ if (oldBytes && newBytes && sha256Hex(oldBytes) === sha256Hex(newBytes)) continue;
17316
17592
  const oldText = oldBytes === void 0 ? void 0 : utf8Text(oldBytes);
17317
17593
  const newText = newBytes === void 0 ? void 0 : utf8Text(newBytes);
17318
17594
  const fullPath = `skills/${name2}/${path}`;
@@ -17371,7 +17647,7 @@ async function pullConfig(options) {
17371
17647
  const mine = local.get(remote.key);
17372
17648
  if (base && mine && base.canonicalFormVersion === CANONICAL_FORM_VERSION && // The same asset, not only the same number: after a database was replaced another
17373
17649
  // asset of the name can be at the revision the last pull recorded.
17374
- 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.
17375
17651
  base.draftPushed !== true) {
17376
17652
  return { ...readDefinition(remote, mine.config), folderFiles: mine.folderFiles };
17377
17653
  }
@@ -17571,7 +17847,7 @@ async function diffConfig(options) {
17571
17847
  const localAsset = localAssets.get(key2);
17572
17848
  const remoteAsset = remoteAssets.get(key2);
17573
17849
  const base = baseline.assets[key2];
17574
- const localChanged = localAsset ? assetHash(localAsset.contents) !== base?.hash : base !== void 0;
17850
+ const localChanged = localAsset ? sha256Hex(localAsset.contents) !== base?.hash : base !== void 0;
17575
17851
  const remoteChanged = (remoteAsset?.revision ?? null) !== (base?.revision ?? null) || // Another asset under the name, whatever its number.
17576
17852
  remoteAsset !== void 0 && base !== void 0 && remoteAsset.id !== base.id;
17577
17853
  const pushedDraft = base?.draftPushed === true && localAsset !== void 0;
@@ -17922,6 +18198,7 @@ import { parseArgs as parseArgs4 } from "util";
17922
18198
  import { z as z60 } from "zod";
17923
18199
 
17924
18200
  // src/connection-sign-in.ts
18201
+ import { setTimeout as defaultSleep3 } from "timers/promises";
17925
18202
  var READ_EVERY_MS = 2e3;
17926
18203
  var SETTLE_READS = 16;
17927
18204
  async function connectConnection(api, name2, options) {
@@ -17944,7 +18221,7 @@ async function connectConnection(api, name2, options) {
17944
18221
  ].join("\n")
17945
18222
  );
17946
18223
  if (options.openBrowser) (options.openUrl ?? openProviderPage)(start.authorizationUrl);
17947
- const sleep = options.sleep ?? ((milliseconds) => new Promise((resolve15) => setTimeout(resolve15, milliseconds)));
18224
+ const sleep = options.sleep ?? defaultSleep3;
17948
18225
  const until = Date.parse(start.expiresAt);
17949
18226
  let readsSinceEnded = 0;
17950
18227
  for (; ; ) {
@@ -18101,7 +18378,7 @@ async function runOperationCommand(argv, base) {
18101
18378
  "Input must be JSON with params, query, body, or file (an upload path)."
18102
18379
  );
18103
18380
  }
18104
- 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")
18105
18382
  secret = input.body.value;
18106
18383
  const { file, ...request } = input;
18107
18384
  const upload = file === void 0 ? void 0 : new File([await readFile10(resolve11(base.cwd, file))], basename5(file));
@@ -18186,7 +18463,7 @@ async function call2(api, operation, input) {
18186
18463
  const invoke = (client, idempotencyKey2) => {
18187
18464
  let method = client;
18188
18465
  for (const segment of operation.id.split("."))
18189
- method = isRecord5(method) ? method[segment] : void 0;
18466
+ method = isRecord(method) ? method[segment] : void 0;
18190
18467
  if (!isMethod(method))
18191
18468
  throw new Error("The API client has no method for this catalog operation.");
18192
18469
  return method({ ...input, ...idempotencyKey2 === void 0 ? {} : { idempotencyKey: idempotencyKey2 } });
@@ -18201,12 +18478,12 @@ function isMethod(value) {
18201
18478
  }
18202
18479
  async function printCall(options, operation, result, format) {
18203
18480
  const render = format ?? ((value) => JSON.stringify(value, null, 2));
18204
- if (isRecord5(result) && operation.accepted) {
18481
+ if (isRecord(result) && operation.accepted) {
18205
18482
  if (result.status === "pending_approval") {
18206
18483
  if (format === void 0) {
18207
18484
  writeOutput(options, render({ status: result.status, run: result.run }));
18208
18485
  } else {
18209
- const id3 = isRecord5(result.run) ? result.run.id : "unknown";
18486
+ const id3 = isRecord(result.run) ? result.run.id : "unknown";
18210
18487
  writeError(
18211
18488
  options,
18212
18489
  `Waits for an approval on the instance; nothing has changed yet (Operation Run ${id3}).`
@@ -18483,7 +18760,7 @@ function definition(entry, part, name2) {
18483
18760
  const last = keys.pop();
18484
18761
  for (const key2 of keys) {
18485
18762
  const value = Object.hasOwn(target, key2) ? target[key2] : void 0;
18486
- const child = isRecord5(value) ? value : {};
18763
+ const child = isRecord(value) ? value : {};
18487
18764
  Object.defineProperty(target, key2, {
18488
18765
  value: child,
18489
18766
  enumerable: true,
@@ -18782,10 +19059,10 @@ async function runKnowledgeCommand(argv, base) {
18782
19059
  });
18783
19060
  }
18784
19061
  let exit = 0;
18785
- if (isRecord5(result) && isRecord5(result.run)) {
19062
+ if (isRecord(result) && isRecord(result.run)) {
18786
19063
  exit = result.run.status === "running" || result.run.status === "done" ? 0 : 3;
18787
19064
  result = result.run;
18788
- } else if (isRecord5(result) && result.status === "done") result = result.output;
19065
+ } else if (isRecord(result) && result.status === "done") result = result.output;
18789
19066
  writeOutput(
18790
19067
  options,
18791
19068
  values.json ? JSON.stringify(result, null, 2) : yaml10.dump(result, { lineWidth: -1, noRefs: true }).trimEnd()
@@ -18811,7 +19088,7 @@ async function reindex(api, name2, confirm, options, json2) {
18811
19088
  body: confirm ? { confirm } : {}
18812
19089
  });
18813
19090
  const answer = reindexAnswerSchema.parse(
18814
- isRecord5(raw) && raw.status === "done" && "output" in raw ? raw.output : raw
19091
+ isRecord(raw) && raw.status === "done" && "output" in raw ? raw.output : raw
18815
19092
  );
18816
19093
  const waits = !answer.started && answer.statement !== void 0;
18817
19094
  if (json2) {
@@ -19355,7 +19632,7 @@ Commands:
19355
19632
  Check the provider on a running instance, where its key is (instance.infrastructure.check)
19356
19633
  catalyst models list
19357
19634
  The model providers of the release config; with --instance, also what the instance
19358
- reports for each (instance.infrastructure.get)
19635
+ reports for each (instance.infrastructure.check)
19359
19636
 
19360
19637
  Options of add:
19361
19638
  --id <id> The provider's id (azure: azure-eu, vertex: vertex-eu,
@@ -19546,7 +19823,7 @@ async function addProvider(kind, flags, options) {
19546
19823
  `The release config already has a model provider '${id3}'. Choose another --id.`
19547
19824
  );
19548
19825
  const bindings = valueAt(config.merged, BINDINGS);
19549
- 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))
19550
19827
  throw new ReleaseConfigError(
19551
19828
  `The release config already has a model binding '${bindingId}'. Choose another --binding.`
19552
19829
  );
@@ -19576,7 +19853,7 @@ async function addProvider(kind, flags, options) {
19576
19853
  outputPricePerMillionTokens: Number(values["output-price"])
19577
19854
  };
19578
19855
  const prices = valueAt(config.merged, PRICES);
19579
- 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))
19580
19857
  throw new ReleaseConfigError(
19581
19858
  `The rate card already prices '${model}' of provider '${id3}'. Remove that row, or choose another --id.`
19582
19859
  );
@@ -19647,8 +19924,8 @@ async function addProvider(kind, flags, options) {
19647
19924
  return 0;
19648
19925
  }
19649
19926
  function fallbackRefusal(fallbackId, bindings, models) {
19650
- const fallback = Array.isArray(bindings) ? bindings.find((binding) => isRecord5(binding) && binding.id === fallbackId) : void 0;
19651
- if (!isRecord5(fallback))
19927
+ const fallback = Array.isArray(bindings) ? bindings.find((binding) => isRecord(binding) && binding.id === fallbackId) : void 0;
19928
+ if (!isRecord(fallback))
19652
19929
  return `The release config has no model binding '${fallbackId}' to fall back to. Name one of its chat bindings with --fallback.`;
19653
19930
  if (fallback.kind === "embedding")
19654
19931
  return `'${fallbackId}' is an embedding binding; a fallback answers chat calls. Name a chat binding with --fallback.`;
@@ -19663,7 +19940,7 @@ function defaultSecret(kind, id3, config) {
19663
19940
  const models = valueAt(config.merged, ["infrastructure", "models"]);
19664
19941
  const taken = new Set(
19665
19942
  isPlainConfigObject(models) ? Object.values(models).flatMap(
19666
- (entry) => isRecord5(entry) && typeof entry.credentialSecret === "string" ? [entry.credentialSecret] : []
19943
+ (entry) => isRecord(entry) && typeof entry.credentialSecret === "string" ? [entry.credentialSecret] : []
19667
19944
  ) : []
19668
19945
  );
19669
19946
  if (spec.defaultSecret !== void 0 && !taken.has(spec.defaultSecret)) return spec.defaultSecret;
@@ -19675,8 +19952,7 @@ function rateCardId(config) {
19675
19952
  return typeof instance === "string" && instance !== "" ? instance : "rate-card";
19676
19953
  }
19677
19954
  async function checkProvider(id3, json2, options) {
19678
- const { api } = await openInstance(options);
19679
- const answer = await api.read((client) => client.instance.infrastructure.check());
19955
+ const answer = await checkInfrastructure(options);
19680
19956
  const item = answer.items.find(
19681
19957
  (candidate) => candidate.class === "models" && candidate.name === id3
19682
19958
  );
@@ -19689,14 +19965,38 @@ async function checkProvider(id3, json2, options) {
19689
19965
  return 1;
19690
19966
  }
19691
19967
  if (json2) {
19692
- writeOutput(options, JSON.stringify(item, null, 2));
19968
+ writeOutput(options, JSON.stringify({ ...item, id: item.name }, null, 2));
19693
19969
  return item.check.status === "ok" ? 0 : 1;
19694
19970
  }
19695
19971
  for (const line of describeCheck(item)) writeOutput(options, line);
19696
19972
  return item.check.status === "ok" ? 0 : 1;
19697
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
+ }
19698
19998
  function describeCheck(item) {
19699
- 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}` : ""}`;
19700
20000
  const lines = [head];
19701
20001
  for (const secret of item.secrets) {
19702
20002
  lines.push(
@@ -19736,9 +20036,9 @@ async function listProviders(configFlag, json2, options) {
19736
20036
  const prices = valueAt(config.merged, PRICES);
19737
20037
  const listed = Object.entries(isPlainConfigObject(models) ? models : {}).map(
19738
20038
  ([id3, entry]) => {
19739
- const record = isRecord5(entry) ? entry : {};
20039
+ const record = isRecord(entry) ? entry : {};
19740
20040
  const ownBindings = (Array.isArray(bindings) ? bindings : []).filter(
19741
- (binding) => isRecord5(binding) && binding.providerId === id3
20041
+ (binding) => isRecord(binding) && binding.providerId === id3
19742
20042
  );
19743
20043
  const billed = [record.model, ...ownBindings.map((binding) => binding.model)].filter(
19744
20044
  (model) => typeof model === "string"
@@ -19752,15 +20052,14 @@ async function listProviders(configFlag, json2, options) {
19752
20052
  bindings: ownBindings.map((binding) => String(binding.id)),
19753
20053
  priced: billed.length > 0 && billed.every(
19754
20054
  (model) => (Array.isArray(prices) ? prices : []).some(
19755
- (row) => isRecord5(row) && row.providerId === id3 && row.model === model
20055
+ (row) => isRecord(row) && row.providerId === id3 && row.model === model
19756
20056
  )
19757
20057
  )
19758
20058
  };
19759
20059
  }
19760
20060
  );
19761
20061
  if (options.instance !== void 0) {
19762
- const { api } = await openInstance(options);
19763
- const answer = await api.read((client) => client.instance.infrastructure.get());
20062
+ const answer = await checkInfrastructure(options);
19764
20063
  for (const provider of listed) {
19765
20064
  const item = answer.items.find(
19766
20065
  (candidate) => candidate.class === "models" && candidate.name === provider.id
@@ -19942,7 +20241,7 @@ ${command.operation.summary}
19942
20241
  params,
19943
20242
  query: { ...query, limit: MAX_LIST_LIMIT, ...cursor === void 0 ? {} : { cursor } }
19944
20243
  });
19945
- if (!isRecord5(page2) || !Array.isArray(page2[listField]))
20244
+ if (!isRecord(page2) || !Array.isArray(page2[listField]))
19946
20245
  throw new Error("Invalid list response.");
19947
20246
  items.push(...page2[listField]);
19948
20247
  cursor = typeof page2.nextCursor === "string" ? page2.nextCursor : void 0;