@reminix/cli 1.0.0-rc.13 → 1.0.0-rc.16

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/reminix.mjs CHANGED
@@ -23,6 +23,16 @@ var brand_default = {
23
23
  labs: ["lab"],
24
24
  statusPage: true,
25
25
  discordInvite: "https://discord.gg/UU9NbEcNQj",
26
+ shortLinks: {
27
+ "/li": { source: "linkedin", medium: "social" },
28
+ "/yt": { source: "youtube", medium: "video" },
29
+ "/pycoders": { source: "pycoders", medium: "newsletter" },
30
+ "/nodeweekly": { source: "nodeweekly", medium: "newsletter" },
31
+ "/mcp": { source: "mcp-registry", medium: "directory" },
32
+ "/plugins": { source: "claude-plugins", medium: "directory" },
33
+ "/gh": { source: "github", medium: "referral" },
34
+ "/dc": { source: "discord", medium: "community" }
35
+ },
26
36
  profiles: { x: "reminixhq", github: "reminixhq" },
27
37
  summary: "Reminix turns your scripts into internal tools. Upload a Python, shell or Node script, and Reminix runs it from a form, the API, the CLI or your AI agents, on a schedule or from a webhook. Keys stay out of the code, and every run is on record.",
28
38
  expectedAssets: [
@@ -80,7 +90,12 @@ var brand_default = {
80
90
  providerOrder: ["github", "google"],
81
91
  emailSignUp: "button"
82
92
  },
83
- devPortOffset: 200
93
+ devPortOffset: 200,
94
+ appShortcuts: [
95
+ { name: "Approvals", url: "/runs?status=awaiting_approval" },
96
+ { name: "Notifications", url: "/account/notifications" }
97
+ ],
98
+ tagline: "Internal tools from your scripts"
84
99
  };
85
100
 
86
101
  // src/brand/index.ts
@@ -142,6 +157,8 @@ var brand = {
142
157
  ].filter(Boolean),
143
158
  /** One sentence: what the product is — llms.txt and the agent skill lead with it. */
144
159
  summary: optional.summary ?? `${brand_default.productName} documentation and API.`,
160
+ /** A short line under the logo in the site's footer (the home page's headline); none without it. */
161
+ tagline: optional.tagline,
145
162
  /** Where vulnerability reports go — /.well-known/security.txt and /security publish it. Defaults to security@<domain>. */
146
163
  securityContact: optional.securityContact ?? `security@${brand_default.domain}`,
147
164
  /** Where the Contact form's help topics go (Question, Bug, Billing). Never shown on a page. Defaults to support@<domain>. */
@@ -204,21 +221,21 @@ var signInOptions = {
204
221
  emailSignUp: optional.signIn?.emailSignUp ?? "form"
205
222
  };
206
223
  function resolveProductEnvironments(environments, defaultEnvironment, docs) {
207
- const list = (environments ?? []).map((env) => ({
224
+ const list2 = (environments ?? []).map((env) => ({
208
225
  name: env.name,
209
226
  keyPrefix: env.keyPrefix,
210
227
  readOnlyWorkspace: env.readOnlyWorkspace ?? false,
211
228
  description: env.description ?? "",
212
229
  agentLabel: env.agentLabel ?? env.description ?? ""
213
230
  }));
214
- const names = new Set(list.map((env) => env.name));
215
- const prefixes = new Set(list.map((env) => env.keyPrefix));
216
- if (names.size !== list.length || prefixes.size !== list.length) {
231
+ const names = new Set(list2.map((env) => env.name));
232
+ const prefixes = new Set(list2.map((env) => env.keyPrefix));
233
+ if (names.size !== list2.length || prefixes.size !== list2.length) {
217
234
  throw new Error(
218
235
  "brand.json environments: each needs its own name and keyPrefix"
219
236
  );
220
237
  }
221
- for (const env of list) {
238
+ for (const env of list2) {
222
239
  if (!/^[a-z][a-z0-9-]*$/.test(env.name)) {
223
240
  throw new Error(`brand.json environment name "${env.name}" is invalid`);
224
241
  }
@@ -239,9 +256,9 @@ function resolveProductEnvironments(environments, defaultEnvironment, docs) {
239
256
  );
240
257
  }
241
258
  return {
242
- list,
243
- default: defaultEnvironment ?? list[0]?.name ?? null,
244
- docs: list.length > 0 ? docs ?? null : null
259
+ list: list2,
260
+ default: defaultEnvironment ?? list2[0]?.name ?? null,
261
+ docs: list2.length > 0 ? docs ?? null : null
245
262
  };
246
263
  }
247
264
  var productEnvironments = resolveProductEnvironments(
@@ -735,21 +752,114 @@ function removeTrailingSlash(url) {
735
752
  }
736
753
 
737
754
  // node_modules/@reminix/sdk/dist/errors.js
738
- var ApiError = class extends Error {
755
+ var BASE_ERROR_NAME = `${brand2.name.split(/[-_]/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join("")}Error`;
756
+ var SdkError = class _SdkError extends Error {
757
+ constructor(message, options) {
758
+ super(message, options);
759
+ this.name = new.target === _SdkError ? BASE_ERROR_NAME : new.target.name;
760
+ }
761
+ };
762
+ var APIConnectionError = class extends SdkError {
763
+ constructor(options = {}) {
764
+ super(options.message ?? "Could not connect to the API", {
765
+ cause: options.cause
766
+ });
767
+ }
768
+ };
769
+ var APITimeoutError = class extends APIConnectionError {
770
+ constructor(options = {}) {
771
+ super({ message: "The request timed out", cause: options.cause });
772
+ }
773
+ };
774
+ var APIError = class extends SdkError {
775
+ /** The HTTP status code. */
739
776
  status;
777
+ /** The error's code, to branch on (`not_found`, `rate_limited`, …). */
740
778
  code;
779
+ /** The request's id: quote it to support. */
741
780
  requestId;
742
- constructor(status, code2, message, requestId) {
743
- super(message);
744
- this.name = "ApiError";
745
- this.status = status;
746
- this.code = code2;
747
- this.requestId = requestId;
781
+ /**
782
+ * The response's headers (Retry-After, Server-Timing, the rate-limit
783
+ * ones): empty when the error was not built from a response.
784
+ */
785
+ headers;
786
+ /** What is wrong with each field, when the API refused the input. */
787
+ details;
788
+ /** A link to the error's entry in the docs. */
789
+ docs;
790
+ constructor(init) {
791
+ super(init.message);
792
+ this.status = init.status;
793
+ this.code = init.code;
794
+ this.requestId = init.requestId;
795
+ this.headers = init.headers ?? new Headers();
796
+ this.details = init.details;
797
+ this.docs = init.docs;
748
798
  }
749
799
  };
800
+ var BadRequestError = class extends APIError {
801
+ };
802
+ var AuthenticationError = class extends APIError {
803
+ };
804
+ var PlanLimitError = class extends APIError {
805
+ };
806
+ var PermissionDeniedError = class extends APIError {
807
+ };
808
+ var NotFoundError = class extends APIError {
809
+ };
810
+ var ConflictError = class extends APIError {
811
+ };
812
+ var UnprocessableEntityError = class extends APIError {
813
+ };
814
+ var RateLimitError = class extends APIError {
815
+ };
816
+ var InternalServerError = class extends APIError {
817
+ };
818
+ var BY_STATUS = {
819
+ 400: BadRequestError,
820
+ 401: AuthenticationError,
821
+ 402: PlanLimitError,
822
+ 403: PermissionDeniedError,
823
+ 404: NotFoundError,
824
+ 409: ConflictError,
825
+ 422: UnprocessableEntityError,
826
+ 429: RateLimitError
827
+ };
828
+ function errorClassFor(status) {
829
+ return BY_STATUS[status] ?? (status >= 500 ? InternalServerError : APIError);
830
+ }
750
831
  function apiErrorFrom(error, response) {
751
- const envelope = error ?? {};
752
- return new ApiError(response.status, envelope.error?.code ?? "http_error", envelope.error?.message ?? `HTTP ${response.status}`, envelope.error?.requestId);
832
+ const envelope = error !== null && typeof error === "object" ? error : {};
833
+ const body = envelope.error ?? {};
834
+ const ErrorClass = errorClassFor(response.status);
835
+ return new ErrorClass({
836
+ status: response.status,
837
+ code: body.code ?? "http_error",
838
+ message: body.message ?? `HTTP ${response.status}`,
839
+ requestId: body.requestId ?? response.headers.get("x-request-id") ?? void 0,
840
+ headers: response.headers,
841
+ ...Array.isArray(body.details) ? { details: body.details } : {},
842
+ ...typeof body.docs === "string" ? { docs: body.docs } : {}
843
+ });
844
+ }
845
+ function connectionErrorFrom(error, signal) {
846
+ if (signal?.aborted)
847
+ return signal.reason;
848
+ if (error instanceof SdkError)
849
+ return error;
850
+ if (error instanceof Error && error.name === "TimeoutError") {
851
+ return new APITimeoutError({ cause: error });
852
+ }
853
+ return new APIConnectionError({ cause: error });
854
+ }
855
+ function withConnectionErrors(fetch2) {
856
+ return async (request) => {
857
+ try {
858
+ return await fetch2(request);
859
+ } catch (error) {
860
+ throw connectionErrorFrom(error, request.signal);
861
+ }
862
+ };
753
863
  }
754
864
 
755
865
  // node_modules/@reminix/sdk/dist/product/index.js
@@ -767,35 +877,40 @@ async function uploadFile(client, file, options = {}) {
767
877
  const body = file.data instanceof Blob ? file.data : new Blob([file.data], {
768
878
  type: file.mediaType ?? "application/octet-stream"
769
879
  });
770
- return unwrap(await client.POST("/files", {
771
- params: { query: { name: file.name } },
772
- body,
773
- bodySerializer: (value) => value,
880
+ return await client.files.upload(body, { name: file.name }, {
881
+ ...options,
774
882
  headers: {
775
- "content-type": file.mediaType ?? (body.type || "application/octet-stream"),
776
- ...options.idempotencyKey ? { "idempotency-key": options.idempotencyKey } : {}
883
+ ...file.mediaType ? { "content-type": file.mediaType } : {},
884
+ ...options.headers
777
885
  }
778
- }));
886
+ });
779
887
  }
780
888
 
781
889
  // node_modules/@reminix/sdk/dist/product/run.js
782
- var RunError = class extends Error {
890
+ var perRequest = ({ signal, headers, timeout }) => ({
891
+ ...signal ? { signal } : {},
892
+ ...headers ? { headers } : {},
893
+ ...timeout === void 0 ? {} : { timeout }
894
+ });
895
+ var RunError = class extends SdkError {
783
896
  run;
784
897
  constructor(run3) {
785
898
  super(run3.status === "cancelled" ? `Run ${run3.id} was cancelled: ${run3.error ?? "no reason given"}` : `Run ${run3.id} failed: ${run3.error ?? "no error message"}`);
786
- this.name = "RunError";
787
899
  this.run = run3;
788
900
  }
789
901
  };
790
902
  var ENDED = /* @__PURE__ */ new Set(["succeeded", "failed", "cancelled"]);
791
903
  var isUpload = (value) => typeof Blob !== "undefined" && value instanceof Blob || typeof value === "object" && value !== null && "name" in value && "data" in value;
792
- async function withFileIds(client, inputs, idempotencyKey) {
904
+ async function withFileIds(client, inputs, idempotencyKey, options) {
793
905
  let uploaded = 0;
794
906
  const upload = async (value) => (await uploadFile(client, value instanceof Blob ? {
795
907
  name: "name" in value ? String(value.name) : "upload",
796
908
  mediaType: value.type,
797
909
  data: value
798
- } : value, idempotencyKey ? { idempotencyKey: `${idempotencyKey}:file-${++uploaded}` } : {})).id;
910
+ } : value, {
911
+ ...idempotencyKey ? { idempotencyKey: `${idempotencyKey}:file-${++uploaded}` } : {},
912
+ ...perRequest(options)
913
+ })).id;
799
914
  const out = {};
800
915
  for (const [name, value] of Object.entries(inputs)) {
801
916
  if (isUpload(value))
@@ -821,10 +936,11 @@ var pause = (ms, signal) => new Promise((resolve4, reject) => {
821
936
  }, { once: true });
822
937
  });
823
938
  async function waitForRun(client, run3, options = {}) {
824
- let current = run3;
939
+ const each = perRequest(options);
940
+ let current = typeof run3 === "string" ? await client.runs.get(run3, each) : run3;
825
941
  while (!ENDED.has(current.status)) {
826
- await pause(options.pollMs ?? 2e3, options.signal);
827
- current = await client.runs.get(current.id);
942
+ await pause(options.pollInterval ?? 2e3, options.signal);
943
+ current = await client.runs.get(current.id, each);
828
944
  }
829
945
  if (current.status !== "succeeded")
830
946
  throw new RunError(current);
@@ -832,9 +948,12 @@ async function waitForRun(client, run3, options = {}) {
832
948
  }
833
949
  async function run(client, slug, inputs = {}, options = {}) {
834
950
  const body = {
835
- inputs: await withFileIds(client, inputs, options.idempotencyKey)
951
+ inputs: await withFileIds(client, inputs, options.idempotencyKey, options)
952
+ };
953
+ const keyed = {
954
+ ...options.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {},
955
+ ...perRequest(options)
836
956
  };
837
- const keyed = options.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {};
838
957
  const started = options.version === void 0 ? await client.runs.create(slug, body, keyed) : await client.scriptVersions.testRun(slug, options.version, body, keyed);
839
958
  if (started.status === "awaiting_approval") {
840
959
  options.onApproval?.(started.approval?.approveUrl ?? null);
@@ -848,11 +967,77 @@ async function run(client, slug, inputs = {}, options = {}) {
848
967
  var productMethods = (client) => ({
849
968
  /** Runs a script and answers with the finished run (./run.ts). */
850
969
  run: (slug, inputs, options) => run(client, slug, inputs, options),
970
+ /** Follows a run until it ends; throws RunError if it didn't succeed. */
971
+ waitForRun: (started, options) => waitForRun(client, started, options),
851
972
  /** Uploads a file to give a run as an input; returns it, with its id. */
852
- uploadFile: (file) => uploadFile(client, file)
973
+ uploadFile: (file, options) => uploadFile(client, file, options)
853
974
  });
854
975
 
976
+ // node_modules/@reminix/sdk/dist/pagination.js
977
+ var Page = class {
978
+ /** This page's items. */
979
+ items;
980
+ /** The cursor for the next page; null on the last one. */
981
+ nextCursor;
982
+ #next;
983
+ constructor(body, next) {
984
+ Object.assign(this, body);
985
+ this.items = body.items;
986
+ this.nextCursor = body.nextCursor ?? null;
987
+ this.#next = next;
988
+ }
989
+ /** Whether another page follows this one. */
990
+ hasNextPage() {
991
+ return this.#next !== null && typeof this.nextCursor === "string";
992
+ }
993
+ /** The next page; throws when this is the last one (see hasNextPage). */
994
+ getNextPage() {
995
+ if (!this.hasNextPage()) {
996
+ return Promise.reject(new Error("No next page: check hasNextPage() first"));
997
+ }
998
+ return this.#next(this.nextCursor);
999
+ }
1000
+ /** This page and every page after it. */
1001
+ async *iterPages() {
1002
+ yield this;
1003
+ let page = this.hasNextPage() ? await this.getNextPage() : null;
1004
+ while (page) {
1005
+ yield page;
1006
+ page = page.hasNextPage() ? await page.getNextPage() : null;
1007
+ }
1008
+ }
1009
+ /** Every item, from this page on, fetching each next page as it goes. */
1010
+ async *[Symbol.asyncIterator]() {
1011
+ for await (const page of this.iterPages())
1012
+ yield* page.items;
1013
+ }
1014
+ };
1015
+ var PagePromise = class {
1016
+ #page;
1017
+ [Symbol.toStringTag] = "PagePromise";
1018
+ constructor(page) {
1019
+ this.#page = page;
1020
+ }
1021
+ then(onFulfilled, onRejected) {
1022
+ return this.#page.then(onFulfilled, onRejected);
1023
+ }
1024
+ catch(onRejected) {
1025
+ return this.#page.catch(onRejected);
1026
+ }
1027
+ finally(onFinally) {
1028
+ return this.#page.finally(onFinally);
1029
+ }
1030
+ async *[Symbol.asyncIterator]() {
1031
+ yield* await this.#page;
1032
+ }
1033
+ };
1034
+ function pages(fetch2, paged) {
1035
+ const load = (cursor) => new PagePromise(fetch2(cursor).then((body) => new Page(body, paged ? load : null)));
1036
+ return load(void 0);
1037
+ }
1038
+
855
1039
  // node_modules/@reminix/sdk/dist/resources.js
1040
+ var TIMEOUT_HEADER = "x-sdk-timeout";
856
1041
  async function call(client, op, pathParams, input, options = {}, content) {
857
1042
  const query = {};
858
1043
  const body = {};
@@ -863,7 +1048,8 @@ async function call(client, op, pathParams, input, options = {}, content) {
863
1048
  }
864
1049
  const headers = {
865
1050
  ...options.headers,
866
- ...options.idempotencyKey ? { "idempotency-key": options.idempotencyKey } : {}
1051
+ ...options.idempotencyKey ? { "idempotency-key": options.idempotencyKey } : {},
1052
+ ...options.timeout === void 0 ? {} : { [TIMEOUT_HEADER]: String(options.timeout) }
867
1053
  };
868
1054
  const request = client.request;
869
1055
  const raw = op.rawBody ? content instanceof Blob ? content : new Blob([content]) : void 0;
@@ -875,13 +1061,17 @@ async function call(client, op, pathParams, input, options = {}, content) {
875
1061
  bodySerializer: (value) => value,
876
1062
  headers: { "content-type": raw.type || op.rawBody, ...headers }
877
1063
  } : { headers },
878
- ...op.rawResponse ? { parseAs: "blob" } : {}
1064
+ ...op.rawResponse ? { parseAs: "blob" } : {},
1065
+ signal: options.signal
879
1066
  });
880
1067
  if (error !== void 0 || !response.ok) {
881
1068
  throw apiErrorFrom(error, response);
882
1069
  }
883
1070
  return data;
884
1071
  }
1072
+ function list(client, op, pathParams, input, options = {}, paged = true) {
1073
+ return pages((cursor) => call(client, op, pathParams, cursor === void 0 ? input : { ...input, cursor }, options), paged);
1074
+ }
885
1075
 
886
1076
  // node_modules/@reminix/sdk/dist/resources.gen.js
887
1077
  function resources(client) {
@@ -893,25 +1083,25 @@ function resources(client) {
893
1083
  ),
894
1084
  delete: (
895
1085
  /** Delete an environment */
896
- (environment2, options) => call(client, { "method": "delete", "path": "/environments/{environment}", "query": [], "hasBody": false }, { "environment": environment2 }, void 0, options)
1086
+ (environment3, options) => call(client, { "method": "delete", "path": "/environments/{environment}", "query": [], "hasBody": false }, { "environment": environment3 }, void 0, options)
897
1087
  ),
898
1088
  get: (
899
1089
  /** Get an environment */
900
- (environment2, options) => call(client, { "method": "get", "path": "/environments/{environment}", "query": [], "hasBody": false }, { "environment": environment2 }, void 0, options)
1090
+ (environment3, options) => call(client, { "method": "get", "path": "/environments/{environment}", "query": [], "hasBody": false }, { "environment": environment3 }, void 0, options)
901
1091
  ),
902
1092
  list: (
903
1093
  /** List environments */
904
- (options) => call(client, { "method": "get", "path": "/environments", "query": [], "hasBody": false }, {}, void 0, options)
1094
+ (input, options) => list(client, { "method": "get", "path": "/environments", "query": ["limit", "cursor"], "hasBody": false }, {}, input, options, true)
905
1095
  ),
906
1096
  update: (
907
1097
  /** Change an environment */
908
- (environment2, input, options) => call(client, { "method": "patch", "path": "/environments/{environment}", "query": [], "hasBody": true }, { "environment": environment2 }, input, options)
1098
+ (environment3, input, options) => call(client, { "method": "patch", "path": "/environments/{environment}", "query": [], "hasBody": true }, { "environment": environment3 }, input, options)
909
1099
  )
910
1100
  },
911
1101
  files: {
912
- download: (
913
- /** Download a file */
914
- (fileId, options) => call(client, { "method": "get", "path": "/files/{fileId}/download", "query": [], "hasBody": false, "rawResponse": "application/octet-stream" }, { "fileId": fileId }, void 0, options)
1102
+ content: (
1103
+ /** Get a file's content */
1104
+ (fileId, options) => call(client, { "method": "get", "path": "/files/{fileId}/content", "query": [], "hasBody": false, "rawResponse": "application/octet-stream" }, { "fileId": fileId }, void 0, options)
915
1105
  ),
916
1106
  get: (
917
1107
  /** Get a file */
@@ -919,7 +1109,7 @@ function resources(client) {
919
1109
  ),
920
1110
  list: (
921
1111
  /** List files */
922
- (input, options) => call(client, { "method": "get", "path": "/files", "query": ["limit", "cursor", "before", "script", "origin", "name"], "hasBody": false }, {}, input, options)
1112
+ (input, options) => list(client, { "method": "get", "path": "/files", "query": ["limit", "cursor", "before", "script", "origin", "name"], "hasBody": false }, {}, input, options, true)
923
1113
  ),
924
1114
  upload: (
925
1115
  /** Upload a file */
@@ -941,7 +1131,7 @@ function resources(client) {
941
1131
  ),
942
1132
  list: (
943
1133
  /** List runs */
944
- (input, options) => call(client, { "method": "get", "path": "/runs", "query": ["limit", "cursor", "before", "script", "status"], "hasBody": false }, {}, input, options)
1134
+ (input, options) => list(client, { "method": "get", "path": "/runs", "query": ["limit", "cursor", "before", "script", "status"], "hasBody": false }, {}, input, options, true)
945
1135
  ),
946
1136
  log: (
947
1137
  /** Get a run's log */
@@ -957,9 +1147,13 @@ function resources(client) {
957
1147
  /** Delete a schedule */
958
1148
  (slug, scheduleId, options) => call(client, { "method": "delete", "path": "/scripts/{slug}/schedules/{scheduleId}", "query": [], "hasBody": false }, { "slug": slug, "scheduleId": scheduleId }, void 0, options)
959
1149
  ),
1150
+ get: (
1151
+ /** Get a schedule */
1152
+ (slug, scheduleId, options) => call(client, { "method": "get", "path": "/scripts/{slug}/schedules/{scheduleId}", "query": [], "hasBody": false }, { "slug": slug, "scheduleId": scheduleId }, void 0, options)
1153
+ ),
960
1154
  list: (
961
1155
  /** List a script's schedules */
962
- (slug, options) => call(client, { "method": "get", "path": "/scripts/{slug}/schedules", "query": [], "hasBody": false }, { "slug": slug }, void 0, options)
1156
+ (slug, input, options) => list(client, { "method": "get", "path": "/scripts/{slug}/schedules", "query": ["limit", "cursor"], "hasBody": false }, { "slug": slug }, input, options, true)
963
1157
  ),
964
1158
  update: (
965
1159
  /** Change a schedule */
@@ -981,7 +1175,7 @@ function resources(client) {
981
1175
  ),
982
1176
  list: (
983
1177
  /** List scripts */
984
- (input, options) => call(client, { "method": "get", "path": "/scripts", "query": ["limit", "cursor", "q", "tag", "owner", "published", "archived"], "hasBody": false }, {}, input, options)
1178
+ (input, options) => list(client, { "method": "get", "path": "/scripts", "query": ["limit", "cursor", "q", "tag", "owner", "published", "archived"], "hasBody": false }, {}, input, options, true)
985
1179
  ),
986
1180
  restore: (
987
1181
  /** Restore an archived script */
@@ -1003,9 +1197,13 @@ function resources(client) {
1003
1197
  )
1004
1198
  },
1005
1199
  scriptVersions: {
1200
+ get: (
1201
+ /** Get a version */
1202
+ (slug, version, options) => call(client, { "method": "get", "path": "/scripts/{slug}/versions/{version}", "query": [], "hasBody": false }, { "slug": slug, "version": version }, void 0, options)
1203
+ ),
1006
1204
  list: (
1007
1205
  /** List a script's versions */
1008
- (slug, options) => call(client, { "method": "get", "path": "/scripts/{slug}/versions", "query": [], "hasBody": false }, { "slug": slug }, void 0, options)
1206
+ (slug, input, options) => list(client, { "method": "get", "path": "/scripts/{slug}/versions", "query": ["limit", "cursor"], "hasBody": false }, { "slug": slug }, input, options, true)
1009
1207
  ),
1010
1208
  publish: (
1011
1209
  /** Publish a version */
@@ -1025,26 +1223,36 @@ function resources(client) {
1025
1223
  /** Delete a secret */
1026
1224
  (name, options) => call(client, { "method": "delete", "path": "/secrets/{name}", "query": [], "hasBody": false }, { "name": name }, void 0, options)
1027
1225
  ),
1226
+ get: (
1227
+ /** Get a secret */
1228
+ (name, options) => call(client, { "method": "get", "path": "/secrets/{name}", "query": [], "hasBody": false }, { "name": name }, void 0, options)
1229
+ ),
1028
1230
  list: (
1029
1231
  /** List secrets */
1030
- (options) => call(client, { "method": "get", "path": "/secrets", "query": [], "hasBody": false }, {}, void 0, options)
1232
+ (input, options) => list(client, { "method": "get", "path": "/secrets", "query": ["limit", "cursor"], "hasBody": false }, {}, input, options, true)
1031
1233
  ),
1032
- set: (
1033
- /** Save a secret */
1034
- (name, input, options) => call(client, { "method": "put", "path": "/secrets/{name}", "query": [], "hasBody": true }, { "name": name }, input, options)
1234
+ update: (
1235
+ /** Update a secret */
1236
+ (name, input, options) => call(client, { "method": "patch", "path": "/secrets/{name}", "query": [], "hasBody": true }, { "name": name }, input, options)
1035
1237
  )
1036
1238
  },
1037
1239
  secretValues: {
1038
1240
  delete: (
1039
1241
  /** Remove a secret's value from an environment */
1040
- (name, environment2, options) => call(client, { "method": "delete", "path": "/secrets/{name}/values/{environment}", "query": [], "hasBody": false }, { "name": name, "environment": environment2 }, void 0, options)
1242
+ (name, environment3, options) => call(client, { "method": "delete", "path": "/secrets/{name}/values/{environment}", "query": [], "hasBody": false }, { "name": name, "environment": environment3 }, void 0, options)
1243
+ ),
1244
+ set: (
1245
+ /** Save a secret's value */
1246
+ (name, environment3, input, options) => call(client, { "method": "put", "path": "/secrets/{name}/values/{environment}", "query": [], "hasBody": true }, { "name": name, "environment": environment3 }, input, options)
1041
1247
  )
1042
1248
  },
1043
- triggers: {
1044
- calls: (
1249
+ triggerCalls: {
1250
+ list: (
1045
1251
  /** List a webhook trigger's calls */
1046
- (slug, triggerId, options) => call(client, { "method": "get", "path": "/scripts/{slug}/triggers/{triggerId}/calls", "query": [], "hasBody": false }, { "slug": slug, "triggerId": triggerId }, void 0, options)
1047
- ),
1252
+ (slug, triggerId, input, options) => list(client, { "method": "get", "path": "/scripts/{slug}/triggers/{triggerId}/calls", "query": ["limit", "cursor"], "hasBody": false }, { "slug": slug, "triggerId": triggerId }, input, options, true)
1253
+ )
1254
+ },
1255
+ triggers: {
1048
1256
  create: (
1049
1257
  /** Run a script when something happens */
1050
1258
  (slug, input, options) => call(client, { "method": "post", "path": "/scripts/{slug}/triggers", "query": [], "hasBody": true }, { "slug": slug }, input, options)
@@ -1053,9 +1261,13 @@ function resources(client) {
1053
1261
  /** Delete a trigger */
1054
1262
  (slug, triggerId, options) => call(client, { "method": "delete", "path": "/scripts/{slug}/triggers/{triggerId}", "query": [], "hasBody": false }, { "slug": slug, "triggerId": triggerId }, void 0, options)
1055
1263
  ),
1264
+ get: (
1265
+ /** Get a trigger */
1266
+ (slug, triggerId, options) => call(client, { "method": "get", "path": "/scripts/{slug}/triggers/{triggerId}", "query": [], "hasBody": false }, { "slug": slug, "triggerId": triggerId }, void 0, options)
1267
+ ),
1056
1268
  list: (
1057
1269
  /** List a script's triggers */
1058
- (slug, options) => call(client, { "method": "get", "path": "/scripts/{slug}/triggers", "query": [], "hasBody": false }, { "slug": slug }, void 0, options)
1270
+ (slug, input, options) => list(client, { "method": "get", "path": "/scripts/{slug}/triggers", "query": ["limit", "cursor"], "hasBody": false }, { "slug": slug }, input, options, true)
1059
1271
  ),
1060
1272
  rotateSecret: (
1061
1273
  /** Rotate a webhook trigger's secret */
@@ -1080,7 +1292,7 @@ function resources(client) {
1080
1292
  approvalActions: {
1081
1293
  list: (
1082
1294
  /** List the actions you can ask approval for */
1083
- (options) => call(client, { "method": "get", "path": "/workspace/approval-actions", "query": [], "hasBody": false }, {}, void 0, options)
1295
+ (options) => list(client, { "method": "get", "path": "/workspace/approval-actions", "query": [], "hasBody": false }, {}, void 0, options, false)
1084
1296
  )
1085
1297
  },
1086
1298
  approvalRequests: {
@@ -1090,23 +1302,23 @@ function resources(client) {
1090
1302
  ),
1091
1303
  get: (
1092
1304
  /** Check an approval request */
1093
- (requestId, options) => call(client, { "method": "get", "path": "/workspace/approval-requests/{requestId}", "query": [], "hasBody": false }, { "requestId": requestId }, void 0, options)
1305
+ (approvalRequestId, options) => call(client, { "method": "get", "path": "/workspace/approval-requests/{approvalRequestId}", "query": [], "hasBody": false }, { "approvalRequestId": approvalRequestId }, void 0, options)
1094
1306
  ),
1095
1307
  redeem: (
1096
1308
  /** Redeem an approved request */
1097
- (requestId, options) => call(client, { "method": "post", "path": "/workspace/approval-requests/{requestId}/redeem", "query": [], "hasBody": false }, { "requestId": requestId }, void 0, options)
1309
+ (approvalRequestId, options) => call(client, { "method": "post", "path": "/workspace/approval-requests/{approvalRequestId}/redeem", "query": [], "hasBody": false }, { "approvalRequestId": approvalRequestId }, void 0, options)
1098
1310
  )
1099
1311
  },
1100
1312
  auditEvents: {
1101
1313
  list: (
1102
1314
  /** List workspace audit events */
1103
- (input, options) => call(client, { "method": "get", "path": "/workspace/audit-events", "query": ["limit", "cursor", "before", "action", "actor"], "hasBody": false }, {}, input, options)
1315
+ (input, options) => list(client, { "method": "get", "path": "/workspace/audit-events", "query": ["limit", "cursor", "before", "action", "actor"], "hasBody": false }, {}, input, options, true)
1104
1316
  )
1105
1317
  },
1106
1318
  eventTypes: {
1107
1319
  list: (
1108
1320
  /** List event types */
1109
- (options) => call(client, { "method": "get", "path": "/workspace/event-types", "query": [], "hasBody": false }, {}, void 0, options)
1321
+ (options) => list(client, { "method": "get", "path": "/workspace/event-types", "query": [], "hasBody": false }, {}, void 0, options, false)
1110
1322
  )
1111
1323
  },
1112
1324
  get: (
@@ -1116,29 +1328,31 @@ function resources(client) {
1116
1328
  invitations: {
1117
1329
  list: (
1118
1330
  /** List pending invitations */
1119
- (input, options) => call(client, { "method": "get", "path": "/workspace/invitations", "query": ["limit", "cursor"], "hasBody": false }, {}, input, options)
1331
+ (input, options) => list(client, { "method": "get", "path": "/workspace/invitations", "query": ["limit", "cursor"], "hasBody": false }, {}, input, options, true)
1120
1332
  )
1121
1333
  },
1122
1334
  members: {
1123
1335
  list: (
1124
1336
  /** List workspace members */
1125
- (input, options) => call(client, { "method": "get", "path": "/workspace/members", "query": ["limit", "cursor"], "hasBody": false }, {}, input, options)
1337
+ (input, options) => list(client, { "method": "get", "path": "/workspace/members", "query": ["limit", "cursor"], "hasBody": false }, {}, input, options, true)
1338
+ )
1339
+ },
1340
+ planUsage: {
1341
+ get: (
1342
+ /** Get your plan's usage this period */
1343
+ (options) => call(client, { "method": "get", "path": "/workspace/plan-usage", "query": [], "hasBody": false }, {}, void 0, options)
1126
1344
  )
1127
1345
  },
1128
1346
  teams: {
1129
1347
  list: (
1130
1348
  /** List teams */
1131
- (input, options) => call(client, { "method": "get", "path": "/workspace/teams", "query": ["limit", "cursor"], "hasBody": false }, {}, input, options)
1349
+ (input, options) => list(client, { "method": "get", "path": "/workspace/teams", "query": ["limit", "cursor"], "hasBody": false }, {}, input, options, true)
1132
1350
  )
1133
1351
  },
1134
- usage: (
1135
- /** Get your plan's usage this period */
1136
- (options) => call(client, { "method": "get", "path": "/workspace/usage", "query": [], "hasBody": false }, {}, void 0, options)
1137
- ),
1138
1352
  webhookDeliveries: {
1139
1353
  list: (
1140
1354
  /** List an endpoint's deliveries */
1141
- (endpointId, input, options) => call(client, { "method": "get", "path": "/workspace/webhook-endpoints/{endpointId}/deliveries", "query": ["limit", "cursor", "before", "status"], "hasBody": false }, { "endpointId": endpointId }, input, options)
1355
+ (endpointId, input, options) => list(client, { "method": "get", "path": "/workspace/webhook-endpoints/{endpointId}/deliveries", "query": ["limit", "cursor", "before", "status"], "hasBody": false }, { "endpointId": endpointId }, input, options, true)
1142
1356
  ),
1143
1357
  redeliver: (
1144
1358
  /** Redeliver an event */
@@ -1164,7 +1378,7 @@ function resources(client) {
1164
1378
  ),
1165
1379
  list: (
1166
1380
  /** List webhook endpoints */
1167
- (options) => call(client, { "method": "get", "path": "/workspace/webhook-endpoints", "query": [], "hasBody": false }, {}, void 0, options)
1381
+ (options) => list(client, { "method": "get", "path": "/workspace/webhook-endpoints", "query": [], "hasBody": false }, {}, void 0, options, false)
1168
1382
  ),
1169
1383
  test: (
1170
1384
  /** Send a test event */
@@ -1183,11 +1397,45 @@ function resources(client) {
1183
1397
  var WRITES = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
1184
1398
  var RETRY_STATUSES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
1185
1399
  var DEFAULT_MAX_RETRIES = 2;
1186
- var MAX_WAIT_MS = 2e4;
1400
+ var MAX_WAIT_MS = 6e4;
1187
1401
  var MAX_BASE_KEY = 200;
1188
1402
  var PRODUCT_RETRY_HEADER = "x-sdk-product-retry";
1403
+ var DEFAULT_TIMEOUT_MS = 6e4;
1404
+ function withAttemptTimeout(fetch2, ms) {
1405
+ return (request) => {
1406
+ const asked = Number(request.headers.get(TIMEOUT_HEADER));
1407
+ const limit = asked > 0 ? asked : ms;
1408
+ const headers = new Headers(request.headers);
1409
+ headers.delete(TIMEOUT_HEADER);
1410
+ return fetch2(new Request(request, {
1411
+ headers,
1412
+ signal: AbortSignal.any([
1413
+ request.signal,
1414
+ AbortSignal.timeout(Math.max(1, Math.round(limit)))
1415
+ ])
1416
+ }));
1417
+ };
1418
+ }
1189
1419
  var productRetry = () => "productRetry" in product_exports ? Reflect.get(product_exports, "productRetry") ?? null : null;
1190
1420
  var wait = (ms) => new Promise((done) => setTimeout(done, ms));
1421
+ function pause2(sleep, ms, signal) {
1422
+ if (signal.aborted)
1423
+ return Promise.reject(signal.reason);
1424
+ return new Promise((done, fail) => {
1425
+ const abort = () => fail(signal.reason);
1426
+ signal.addEventListener("abort", abort, { once: true });
1427
+ sleep(ms).then(() => {
1428
+ signal.removeEventListener("abort", abort);
1429
+ if (signal.aborted)
1430
+ fail(signal.reason);
1431
+ else
1432
+ done();
1433
+ }, (error) => {
1434
+ signal.removeEventListener("abort", abort);
1435
+ fail(error);
1436
+ });
1437
+ });
1438
+ }
1191
1439
  function backoff(attempt) {
1192
1440
  const base = Math.min(500 * 2 ** attempt, 8e3);
1193
1441
  return base * (0.75 + Math.random() * 0.25);
@@ -1250,7 +1498,7 @@ function withRetries(fetch2, options = {}) {
1250
1498
  } catch (error) {
1251
1499
  if (last || request.signal.aborted)
1252
1500
  throw error;
1253
- await sleep(backoff(attempt));
1501
+ await pause2(sleep, backoff(attempt), request.signal);
1254
1502
  continue;
1255
1503
  }
1256
1504
  const laterMs = later ? await later.wait(response, laterTries) : null;
@@ -1261,7 +1509,7 @@ function withRetries(fetch2, options = {}) {
1261
1509
  laterTries++;
1262
1510
  laterWaited += laterMs;
1263
1511
  await response.body?.cancel();
1264
- await sleep(laterMs);
1512
+ await pause2(sleep, laterMs, request.signal);
1265
1513
  attempt--;
1266
1514
  continue;
1267
1515
  }
@@ -1271,7 +1519,7 @@ function withRetries(fetch2, options = {}) {
1271
1519
  if (delay > MAX_WAIT_MS)
1272
1520
  return response;
1273
1521
  await response.body?.cancel();
1274
- await sleep(delay);
1522
+ await pause2(sleep, delay, request.signal);
1275
1523
  }
1276
1524
  };
1277
1525
  }
@@ -1295,11 +1543,13 @@ function keysFrom(base) {
1295
1543
  };
1296
1544
  }
1297
1545
 
1546
+ // node_modules/@reminix/sdk/dist/version.js
1547
+ var VERSION = "1.0.0-rc.14";
1548
+
1298
1549
  // node_modules/@reminix/sdk/dist/webhooks.js
1299
- var WebhookVerificationError = class extends Error {
1550
+ var WebhookVerificationError = class extends SdkError {
1300
1551
  constructor(message) {
1301
1552
  super(message);
1302
- this.name = "WebhookVerificationError";
1303
1553
  }
1304
1554
  };
1305
1555
  function header(headers, name) {
@@ -1367,7 +1617,8 @@ async function verifyWebhook(body, headers, secret, options = {}) {
1367
1617
  // node_modules/@reminix/sdk/dist/index.js
1368
1618
  var API_KEY_ENV = `${brand2.identifier.toUpperCase()}_API_KEY`;
1369
1619
  var TOKEN_ENV = `${brand2.identifier.toUpperCase()}_TOKEN`;
1370
- var DEFAULT_API = `https://api.${brand2.domain}`;
1620
+ var BASE_URL_ENV = `${brand2.identifier.toUpperCase()}_BASE_URL`;
1621
+ var DEFAULT_BASE_URL = `https://api.${brand2.domain}`;
1371
1622
  function createClient2(options = {}) {
1372
1623
  const client = createBaseClient(options);
1373
1624
  const extend = Reflect.get(product_exports, "productMethods");
@@ -1389,14 +1640,22 @@ function createBaseClient(options) {
1389
1640
  if (!token) {
1390
1641
  throw new Error(`${brand2.productName}: no API key. Pass { apiKey } or set ${API_KEY_ENV}.`);
1391
1642
  }
1392
- const origin = withoutTrailingSlashes(options.api ?? DEFAULT_API);
1393
- const send = options.fetch ?? ((request) => fetch(request));
1643
+ const origin = withoutTrailingSlashes(options.baseURL || environment()?.[BASE_URL_ENV] || DEFAULT_BASE_URL);
1644
+ const send2 = withAttemptTimeout(options.fetch ?? ((request) => fetch(request)), options.timeout ?? DEFAULT_TIMEOUT_MS);
1645
+ const sending = options.maxRetries === 0 ? withoutProductRetryHeader(send2) : withRetries(send2, { maxRetries: options.maxRetries });
1394
1646
  const client = createClient({
1395
1647
  baseUrl: `${origin}/v1`,
1396
- fetch: options.maxRetries === 0 ? withoutProductRetryHeader(send) : withRetries(send, { maxRetries: options.maxRetries })
1648
+ fetch: withConnectionErrors(sending)
1397
1649
  });
1398
1650
  client.use({
1399
1651
  onRequest({ request }) {
1652
+ for (const [name, value] of Object.entries(options.defaultHeaders ?? {})) {
1653
+ if (!request.headers.has(name))
1654
+ request.headers.set(name, value);
1655
+ }
1656
+ if (!("document" in globalThis) && !request.headers.has("user-agent")) {
1657
+ request.headers.set("user-agent", USER_AGENT);
1658
+ }
1400
1659
  request.headers.set("authorization", `Bearer ${token}`);
1401
1660
  if (options.workspace && !request.headers.has("x-workspace")) {
1402
1661
  request.headers.set("x-workspace", options.workspace);
@@ -1411,9 +1670,13 @@ function createBaseClient(options) {
1411
1670
  webhooks: { verify: verifyWebhook }
1412
1671
  });
1413
1672
  }
1414
- function credentialFromEnvironment() {
1673
+ var USER_AGENT = `${brand2.name}-node/${VERSION}`;
1674
+ function environment() {
1415
1675
  const runtime = globalThis;
1416
- const env = runtime.process?.env;
1676
+ return runtime.process?.env;
1677
+ }
1678
+ function credentialFromEnvironment() {
1679
+ const env = environment();
1417
1680
  return env?.[API_KEY_ENV] || env?.[TOKEN_ENV] || void 0;
1418
1681
  }
1419
1682
  function unwrap(result) {
@@ -1437,12 +1700,12 @@ var CommanderError = class extends Error {
1437
1700
  * @param {string} code an id string representing the error
1438
1701
  * @param {string} message human-readable description of the error
1439
1702
  */
1440
- constructor(exitCode, code2, message) {
1703
+ constructor(exitCode2, code2, message) {
1441
1704
  super(message);
1442
1705
  Error.captureStackTrace(this, this.constructor);
1443
1706
  this.name = this.constructor.name;
1444
1707
  this.code = code2;
1445
- this.exitCode = exitCode;
1708
+ this.exitCode = exitCode2;
1446
1709
  this.nestedError = void 0;
1447
1710
  }
1448
1711
  };
@@ -2998,11 +3261,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
2998
3261
  * @return never
2999
3262
  * @private
3000
3263
  */
3001
- _exit(exitCode, code2, message) {
3264
+ _exit(exitCode2, code2, message) {
3002
3265
  if (this._exitCallback) {
3003
- this._exitCallback(new CommanderError(exitCode, code2, message));
3266
+ this._exitCallback(new CommanderError(exitCode2, code2, message));
3004
3267
  }
3005
- process2.exit(exitCode);
3268
+ process2.exit(exitCode2);
3006
3269
  }
3007
3270
  /**
3008
3271
  * Register callback `fn` for the command.
@@ -4153,9 +4416,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
4153
4416
  this.outputHelp({ error: true });
4154
4417
  }
4155
4418
  const config2 = errorOptions || {};
4156
- const exitCode = config2.exitCode || 1;
4419
+ const exitCode2 = config2.exitCode || 1;
4157
4420
  const code2 = config2.code || "commander.error";
4158
- this._exit(exitCode, code2, message);
4421
+ this._exit(exitCode2, code2, message);
4159
4422
  }
4160
4423
  /**
4161
4424
  * Apply any option related environment variables, if option does
@@ -4274,10 +4537,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
4274
4537
  * @param {string} flag
4275
4538
  * @private
4276
4539
  */
4277
- unknownOption(flag2) {
4540
+ unknownOption(flag) {
4278
4541
  if (this._allowUnknownOption) return;
4279
4542
  let suggestion = "";
4280
- if (flag2.startsWith("--") && this._showSuggestionAfterError) {
4543
+ if (flag.startsWith("--") && this._showSuggestionAfterError) {
4281
4544
  let candidateFlags = [];
4282
4545
  let command = this;
4283
4546
  do {
@@ -4285,9 +4548,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
4285
4548
  candidateFlags = candidateFlags.concat(moreFlags);
4286
4549
  command = command.parent;
4287
4550
  } while (command && !command._enablePositionalOptions);
4288
- suggestion = suggestSimilar(flag2, candidateFlags);
4551
+ suggestion = suggestSimilar(flag, candidateFlags);
4289
4552
  }
4290
- const message = `error: unknown option '${flag2}'${suggestion}`;
4553
+ const message = `error: unknown option '${flag}'${suggestion}`;
4291
4554
  this.error(message, { code: "commander.unknownOption" });
4292
4555
  }
4293
4556
  /**
@@ -4697,11 +4960,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
4697
4960
  */
4698
4961
  help(contextOptions) {
4699
4962
  this.outputHelp(contextOptions);
4700
- let exitCode = Number(process2.exitCode ?? 0);
4701
- if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
4702
- exitCode = 1;
4963
+ let exitCode2 = Number(process2.exitCode ?? 0);
4964
+ if (exitCode2 === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
4965
+ exitCode2 = 1;
4703
4966
  }
4704
- this._exit(exitCode, "commander.help", "(outputHelp)");
4967
+ this._exit(exitCode2, "commander.help", "(outputHelp)");
4705
4968
  }
4706
4969
  /**
4707
4970
  * // Do a little typing to coordinate emit and listener for the help text events.
@@ -4847,13 +5110,13 @@ function browserLogin(options) {
4847
5110
  return;
4848
5111
  }
4849
5112
  const fields = url.searchParams;
4850
- const send = (status, title, text) => res.writeHead(status, {
5113
+ const send2 = (status, title, text) => res.writeHead(status, {
4851
5114
  "content-type": "text/html; charset=utf-8",
4852
5115
  "cache-control": "no-store",
4853
5116
  "referrer-policy": "no-referrer"
4854
5117
  }).end(PAGE(title, text));
4855
5118
  if (fields.get("state") !== state) {
4856
- send(
5119
+ send2(
4857
5120
  400,
4858
5121
  "Not this login",
4859
5122
  "This sign-in did not come from the terminal that is waiting. Run login again."
@@ -4861,16 +5124,16 @@ function browserLogin(options) {
4861
5124
  return;
4862
5125
  }
4863
5126
  if (fields.get("error")) {
4864
- send(200, "Sign-in cancelled", "You can close this tab.");
5127
+ send2(200, "Sign-in cancelled", "You can close this tab.");
4865
5128
  finish(() => reject(new Error("sign-in was denied in the browser")));
4866
5129
  return;
4867
5130
  }
4868
5131
  const token = decrypt(fields.get("token") ?? "");
4869
5132
  if (!token) {
4870
- send(400, "Something went wrong", "Run login again.");
5133
+ send2(400, "Something went wrong", "Run login again.");
4871
5134
  return;
4872
5135
  }
4873
- send(
5136
+ send2(
4874
5137
  200,
4875
5138
  "You are signed in",
4876
5139
  "Return to your terminal. You can close this tab."
@@ -4922,6 +5185,9 @@ import {
4922
5185
  writeFileSync
4923
5186
  } from "node:fs";
4924
5187
  import { join } from "node:path";
5188
+ function baseURLEnvVar() {
5189
+ return BASE_URL_ENV;
5190
+ }
4925
5191
  function environmentEnvVar() {
4926
5192
  return `${brand.identifier.toUpperCase()}_ENVIRONMENT`;
4927
5193
  }
@@ -4949,12 +5215,13 @@ function writeConfig(homeDir, config2) {
4949
5215
  }
4950
5216
  function resolveSettings(env, homeDir, flags = {}) {
4951
5217
  const config2 = readConfig(homeDir);
4952
- const environment2 = flags.environment ? { environment: flags.environment, environmentSource: "flag" } : env[environmentEnvVar()] ? { environment: env[environmentEnvVar()], environmentSource: "env" } : config2.environment ? { environment: config2.environment, environmentSource: "config" } : { environment: void 0, environmentSource: null };
5218
+ const environment3 = flags.environment ? { environment: flags.environment, environmentSource: "flag" } : env[environmentEnvVar()] ? { environment: env[environmentEnvVar()], environmentSource: "env" } : config2.environment ? { environment: config2.environment, environmentSource: "config" } : { environment: void 0, environmentSource: null };
4953
5219
  return {
4954
- ...environment2,
4955
- api: withoutTrailingSlashes2(
4956
- env[`${brand.identifier.toUpperCase()}_API`] ?? config2.api ?? DEFAULT_API
5220
+ ...environment3,
5221
+ baseURL: withoutTrailingSlashes2(
5222
+ flags.baseUrl || env[BASE_URL_ENV] || config2.baseURL || DEFAULT_BASE_URL
4957
5223
  ),
5224
+ baseURLSource: flags.baseUrl ? "flag" : env[BASE_URL_ENV] ? "env" : config2.baseURL ? "config" : null,
4958
5225
  token: env[tokenEnvVar()] ?? config2.token,
4959
5226
  workspace: env[`${brand.identifier.toUpperCase()}_WORKSPACE`] ?? config2.workspace
4960
5227
  };
@@ -4965,6 +5232,28 @@ function withoutTrailingSlashes2(url) {
4965
5232
  return url.slice(0, end);
4966
5233
  }
4967
5234
 
5235
+ // src/errors.ts
5236
+ var EXIT = {
5237
+ ok: 0,
5238
+ failure: 1,
5239
+ usage: 2,
5240
+ auth: 4
5241
+ };
5242
+ var UsageError = class extends Error {
5243
+ exitCode = EXIT.usage;
5244
+ constructor(message) {
5245
+ super(message);
5246
+ this.name = "UsageError";
5247
+ }
5248
+ };
5249
+ var NotLoggedInError = class extends Error {
5250
+ exitCode = EXIT.auth;
5251
+ constructor(message) {
5252
+ super(message);
5253
+ this.name = "NotLoggedInError";
5254
+ }
5255
+ };
5256
+
4968
5257
  // src/http.ts
4969
5258
  async function rawRequest(ctx, options) {
4970
5259
  const needsWorkspace = !options.path.startsWith("/v1/user");
@@ -4973,7 +5262,7 @@ async function rawRequest(ctx, options) {
4973
5262
  return unwrap(
4974
5263
  await client.request(options.method, options.path, {
4975
5264
  // The client's base URL ends in /v1; the path given here is absolute.
4976
- baseUrl: ctx.credentials({ workspace: workspace2 }).api,
5265
+ baseUrl: ctx.credentials({ workspace: workspace2 }).baseURL,
4977
5266
  body: options.body
4978
5267
  })
4979
5268
  );
@@ -5072,9 +5361,10 @@ var approvals = (program3, ctx) => {
5072
5361
  // src/usage.ts
5073
5362
  var usage = (program3, ctx) => {
5074
5363
  const workspace2 = program3.commands.find((c) => c.name() === "workspace") ?? program3.command("workspace");
5075
- workspace2.command("usage").description("Show your plan's usage this period").option("--workspace <slug>", "act in this workspace for one call").option("--json", "machine-readable output").action(async (options) => {
5364
+ const planUsage = workspace2.commands.find((c) => c.name() === "plan-usage") ?? workspace2.command("plan-usage").description("Your plan's usage this period");
5365
+ planUsage.command("get").description("Show your plan's usage this period").option("--workspace <slug>", "act in this workspace for one call").option("--json", "machine-readable output").action(async (options) => {
5076
5366
  const result = unwrap(
5077
- await ctx.client({ workspace: options.workspace }).GET("/workspace/usage")
5367
+ await ctx.client({ workspace: options.workspace }).GET("/workspace/plan-usage")
5078
5368
  );
5079
5369
  if (options.json) {
5080
5370
  ctx.io.stdout(json(result));
@@ -5106,13 +5396,14 @@ function usageLines(usage2) {
5106
5396
  async function me(ctx) {
5107
5397
  return unwrap(await ctx.client({ workspace: false }).GET("/user/me"));
5108
5398
  }
5109
- async function saveToken(ctx, token, api2) {
5399
+ async function saveToken(ctx, token) {
5400
+ const { baseURL, baseURLSource } = ctx.settings();
5110
5401
  if (!token.startsWith(`pat_${brand.identifier}_`)) {
5111
5402
  throw new Error(`that is not a ${brand.productName} personal access token`);
5112
5403
  }
5113
5404
  const previous = readConfig(ctx.io.homeDir);
5114
5405
  const config2 = { ...previous, token };
5115
- if (api2) config2.api = api2;
5406
+ if (baseURLSource === "flag") config2.baseURL = baseURL;
5116
5407
  writeConfig(ctx.io.homeDir, config2);
5117
5408
  let user;
5118
5409
  try {
@@ -5142,24 +5433,28 @@ async function saveToken(ctx, token, api2) {
5142
5433
  var login = (program3, ctx) => {
5143
5434
  program3.command("login").description(
5144
5435
  "Sign in through the browser, or store a personal access token with --token"
5145
- ).option("--token <pat>", "a personal access token (CI, servers)").option("--api <origin>", `API origin (default ${DEFAULT_API})`).option("--web <origin>", "web app origin for the browser sign-in").action(async (options) => {
5436
+ ).option("--token <pat>", "a personal access token (CI, servers)").option("--web <origin>", "web app origin for the browser sign-in").addHelpText(
5437
+ "after",
5438
+ `
5439
+ The global --base-url signs in to another API (default ${DEFAULT_BASE_URL}), and is saved for later commands.`
5440
+ ).action(async (options) => {
5146
5441
  if (!productFeatures.personalTokens) {
5147
5442
  throw new Error(
5148
5443
  `${brand.productName} has no personal access tokens, so this command line cannot sign in.`
5149
5444
  );
5150
5445
  }
5151
5446
  if (options.token) {
5152
- await saveToken(ctx, options.token, options.api);
5447
+ await saveToken(ctx, options.token);
5153
5448
  return;
5154
5449
  }
5155
5450
  if (!ctx.io.interactive) {
5156
5451
  ctx.io.stderr(
5157
5452
  `Paste a personal access token (Account \u2192 Personal access tokens in ${brand.productName}), then Enter:`
5158
5453
  );
5159
- await saveToken(ctx, (await ctx.io.stdin()).trim(), options.api);
5454
+ await saveToken(ctx, (await ctx.io.stdin()).trim());
5160
5455
  return;
5161
5456
  }
5162
- const api2 = options.api ?? ctx.settings().api;
5457
+ const api2 = ctx.settings().baseURL;
5163
5458
  const webOrigin = options.web ?? webOriginFor(api2);
5164
5459
  if (!webOrigin) {
5165
5460
  throw new Error(
@@ -5175,15 +5470,15 @@ var login = (program3, ctx) => {
5175
5470
  ${url}`
5176
5471
  )
5177
5472
  });
5178
- await saveToken(ctx, token, options.api);
5473
+ await saveToken(ctx, token);
5179
5474
  });
5180
5475
  };
5181
5476
  var logout = (program3, ctx) => {
5182
5477
  program3.command("logout").description("Revoke the stored token and forget it").action(async () => {
5183
5478
  const config2 = readConfig(ctx.io.homeDir);
5184
5479
  if (config2.token) {
5185
- const revoked = await ctx.io.fetch(
5186
- new Request(`${ctx.settings().api}/v1/user/token`, {
5480
+ const revoked = await ctx.fetch(
5481
+ new Request(`${ctx.settings().baseURL}/v1/user/token`, {
5187
5482
  method: "DELETE",
5188
5483
  headers: { authorization: `Bearer ${config2.token}` }
5189
5484
  })
@@ -5241,7 +5536,7 @@ var workspace = (program3, ctx) => {
5241
5536
  ctx.io.stdout(`Default workspace: ${slug}`);
5242
5537
  });
5243
5538
  };
5244
- var environment = (program3, ctx) => {
5539
+ var environment2 = (program3, ctx) => {
5245
5540
  const group = program3.command("environment").description("Choose the environment commands act in");
5246
5541
  group.command("list", { isDefault: true }).description("Show the environment commands act in").action(() => {
5247
5542
  const { environment: current, environmentSource } = ctx.settings();
@@ -5284,9 +5579,16 @@ var api = (program3, ctx) => {
5284
5579
  program3.command("api <method> <path>").description("Call any API endpoint directly, in the selected workspace").option("--data <json>", "JSON request body").option("--workspace <slug>", "act in this workspace for one call").action(
5285
5580
  async (method, path2, options) => {
5286
5581
  if (!path2.startsWith("/")) {
5287
- throw new Error("usage: api <method> </v1/...> [--data '<json>']");
5582
+ throw new UsageError(
5583
+ "usage: api <method> </v1/...> [--data '<json>']"
5584
+ );
5585
+ }
5586
+ let body;
5587
+ try {
5588
+ body = options.data === void 0 ? void 0 : JSON.parse(options.data);
5589
+ } catch {
5590
+ throw new UsageError("--data must be JSON");
5288
5591
  }
5289
- const body = options.data === void 0 ? void 0 : JSON.parse(options.data);
5290
5592
  ctx.io.stdout(
5291
5593
  json(
5292
5594
  await rawRequest(ctx, {
@@ -5305,8 +5607,8 @@ var config = (program3, ctx) => {
5305
5607
  const settings = ctx.settings();
5306
5608
  ctx.io.stdout(
5307
5609
  json({
5308
- api: settings.api,
5309
- apiDefault: DEFAULT_API,
5610
+ baseURL: settings.baseURL,
5611
+ baseURLDefault: DEFAULT_BASE_URL,
5310
5612
  token: settings.token ? `${settings.token.slice(0, 12)}\u2026` : null,
5311
5613
  tokenSource: ctx.io.env[tokenEnvVar()] ? tokenEnvVar() : settings.token ? "config" : null,
5312
5614
  workspace: settings.workspace ?? null,
@@ -5322,7 +5624,7 @@ var platformCommands = [
5322
5624
  logout,
5323
5625
  whoami,
5324
5626
  workspace,
5325
- environment,
5627
+ environment2,
5326
5628
  api,
5327
5629
  config,
5328
5630
  approvals,
@@ -5377,7 +5679,7 @@ var OPERATIONS = [
5377
5679
  "exposed": false,
5378
5680
  "reason": "Environments hold secret values and rules. A person sets them up, and an agent asks a person to."
5379
5681
  },
5380
- "description": "Adds an environment with no secret values yet. To save its values, call secrets.set with X-Environment set to the new environment. Workspace owners, admins and API keys can add an environment.",
5682
+ "description": "Adds an environment with no secret values yet. To save its values, call secretValues.set with the new environment in the path. Workspace owners, admins and API keys can add an environment.",
5381
5683
  "fields": [
5382
5684
  {
5383
5685
  "name": "name",
@@ -5522,8 +5824,36 @@ var OPERATIONS = [
5522
5824
  }
5523
5825
  },
5524
5826
  "description": "Lists the workspace's environments, oldest first, and shows which one is the default. To act in an environment, name it in the X-Environment header.",
5525
- "fields": [],
5827
+ "fields": [
5828
+ {
5829
+ "name": "limit",
5830
+ "in": "query",
5831
+ "type": "number",
5832
+ "required": false,
5833
+ "description": "Items per page, 1\u2013100 (default 25).",
5834
+ "example": 25,
5835
+ "schema": {
5836
+ "type": "integer",
5837
+ "minimum": 1,
5838
+ "maximum": 100,
5839
+ "default": 25,
5840
+ "description": "Items per page, 1\u2013100 (default 25)."
5841
+ }
5842
+ },
5843
+ {
5844
+ "name": "cursor",
5845
+ "in": "query",
5846
+ "type": "string",
5847
+ "required": false,
5848
+ "description": "Opaque token from a previous page's nextCursor.",
5849
+ "schema": {
5850
+ "type": "string",
5851
+ "description": "Opaque token from a previous page's nextCursor."
5852
+ }
5853
+ }
5854
+ ],
5526
5855
  "hasBody": false,
5856
+ "paginated": true,
5527
5857
  "workspace": true,
5528
5858
  "acceptsApiKey": true,
5529
5859
  "scope": "environments:read"
@@ -5618,10 +5948,10 @@ var OPERATIONS = [
5618
5948
  "scope": "environments:write"
5619
5949
  },
5620
5950
  {
5621
- "operationId": "files.download",
5951
+ "operationId": "files.content",
5622
5952
  "method": "get",
5623
- "path": "/files/{fileId}/download",
5624
- "summary": "Download a file",
5953
+ "path": "/files/{fileId}/content",
5954
+ "summary": "Get a file's content",
5625
5955
  "cli": {
5626
5956
  "command": "files download",
5627
5957
  "args": [
@@ -5641,7 +5971,7 @@ var OPERATIONS = [
5641
5971
  "type": "string",
5642
5972
  "required": true,
5643
5973
  "description": "The file's ID.",
5644
- "example": "file_4c1e\u2026",
5974
+ "example": "file_36d59242-1144-4fcb-851f-20f4c444d538",
5645
5975
  "schema": {
5646
5976
  "type": "string",
5647
5977
  "description": "The file's ID."
@@ -5683,7 +6013,7 @@ var OPERATIONS = [
5683
6013
  "type": "string",
5684
6014
  "required": true,
5685
6015
  "description": "The file's ID.",
5686
- "example": "file_4c1e\u2026",
6016
+ "example": "file_36d59242-1144-4fcb-851f-20f4c444d538",
5687
6017
  "schema": {
5688
6018
  "type": "string",
5689
6019
  "description": "The file's ID."
@@ -5799,6 +6129,7 @@ var OPERATIONS = [
5799
6129
  }
5800
6130
  ],
5801
6131
  "hasBody": false,
6132
+ "paginated": true,
5802
6133
  "workspace": true,
5803
6134
  "acceptsApiKey": true,
5804
6135
  "scope": "runs:read"
@@ -5818,7 +6149,7 @@ var OPERATIONS = [
5818
6149
  "exposed": false,
5819
6150
  "reason": "Takes raw bytes, which an agent's tool call can't carry; agents pass an https link as the file input instead."
5820
6151
  },
5821
- "description": 'Uploads a file that a run can take as a file input. Send the file\'s bytes as the request body, with `Content-Type` and `Content-Length` headers, and its name as `?name=`. Then pass the returned id as the file input\'s value (`{ "adjustments": "file_4c1e\u2026" }`). You can give each upload to only one run. If no run uses an upload within a day, Reminix deletes it. Your plan sets the largest file you can upload. Reminix refuses a file over 1,000 MB on every plan.',
6152
+ "description": 'Uploads a file that a run can take as a file input. Send the file\'s bytes as the request body, with `Content-Type` and `Content-Length` headers, and its name as `?name=`. Then pass the returned id as the file input\'s value (`{ "adjustments": "file_36d59242-1144-4fcb-851f-20f4c444d538" }`). You can give each upload to only one run. If no run uses an upload within a day, Reminix deletes it. Your plan sets the largest file you can upload. Reminix refuses a file over 1,000 MB on every plan.',
5822
6153
  "fields": [
5823
6154
  {
5824
6155
  "name": "name",
@@ -5870,7 +6201,7 @@ var OPERATIONS = [
5870
6201
  "type": "string",
5871
6202
  "required": true,
5872
6203
  "description": "The run's ID.",
5873
- "example": "run_7b1a\u2026",
6204
+ "example": "run_620f14ad-32e8-4f5e-89fd-1c80de7e9124",
5874
6205
  "schema": {
5875
6206
  "type": "string",
5876
6207
  "description": "The run's ID."
@@ -5904,7 +6235,7 @@ var OPERATIONS = [
5904
6235
  "idempotentHint": false
5905
6236
  }
5906
6237
  },
5907
- "description": "Runs the script's published version with these inputs, and returns the run when it finishes, with its output or error. Reminix first checks the inputs against the version's input schema. If they don't match, the request returns 400 with one `details` entry per field. For a file input, pass a file id or an https link that Reminix fetches. The id can be a file you uploaded with files.upload, or a file another run saved. The script runs on its own fresh machine and can reach only the hosts its version declares. A run can last up to its version's `timeoutSeconds`, at most 30, counted from when its code starts. Getting a machine can take up to 2 minutes first. If the run is still in progress after 60 seconds, the request returns 202 with status `running`, and you follow the run with runs.get. If the version's `timeoutSeconds` is over 30, the run is a long run. A long run runs durably, and the request returns 202 at once. Every run counts toward the workspace's `runs` usage.",
6238
+ "description": "Runs the script's published version with these inputs, and returns the run when it finishes (201), with its output or error. Reminix first checks the inputs against the version's input schema. If they don't match, the request returns 400 with one `details` entry per field. For a file input, pass a file id or an https link that Reminix fetches. The id can be a file you uploaded with files.upload, or a file another run saved. The script runs on its own fresh machine and can reach only the hosts its version declares. A run can last up to its version's `timeoutSeconds`, at most 30, counted from when its code starts. Getting a machine can take up to 2 minutes first. If the run is still in progress after 60 seconds, the request returns 202 with status `running`, and you follow the run with runs.get. If the version's `timeoutSeconds` is over 30, the run is a long run. A long run runs durably, and the request returns 202 at once. Every run counts toward the workspace's `runs` usage.",
5908
6239
  "fields": [
5909
6240
  {
5910
6241
  "name": "slug",
@@ -5984,7 +6315,7 @@ var OPERATIONS = [
5984
6315
  "type": "string",
5985
6316
  "required": true,
5986
6317
  "description": "The run's ID.",
5987
- "example": "run_7b1a\u2026",
6318
+ "example": "run_620f14ad-32e8-4f5e-89fd-1c80de7e9124",
5988
6319
  "schema": {
5989
6320
  "type": "string",
5990
6321
  "description": "The run's ID."
@@ -6090,6 +6421,7 @@ var OPERATIONS = [
6090
6421
  }
6091
6422
  ],
6092
6423
  "hasBody": false,
6424
+ "paginated": true,
6093
6425
  "workspace": true,
6094
6426
  "acceptsApiKey": true,
6095
6427
  "scope": "runs:read"
@@ -6123,7 +6455,7 @@ var OPERATIONS = [
6123
6455
  "type": "string",
6124
6456
  "required": true,
6125
6457
  "description": "The run's ID.",
6126
- "example": "run_7b1a\u2026",
6458
+ "example": "run_620f14ad-32e8-4f5e-89fd-1c80de7e9124",
6127
6459
  "schema": {
6128
6460
  "type": "string",
6129
6461
  "description": "The run's ID."
@@ -6271,7 +6603,7 @@ var OPERATIONS = [
6271
6603
  "type": "string",
6272
6604
  "required": true,
6273
6605
  "description": "The schedule's ID.",
6274
- "example": "sch_2b9f\u2026",
6606
+ "example": "sch_037f4852-dc5e-40c8-82a9-852a44410c85",
6275
6607
  "schema": {
6276
6608
  "type": "string",
6277
6609
  "description": "The schedule's ID."
@@ -6283,6 +6615,60 @@ var OPERATIONS = [
6283
6615
  "acceptsApiKey": true,
6284
6616
  "scope": "scripts:write"
6285
6617
  },
6618
+ {
6619
+ "operationId": "schedules.get",
6620
+ "method": "get",
6621
+ "path": "/scripts/{slug}/schedules/{scheduleId}",
6622
+ "summary": "Get a schedule",
6623
+ "cli": {
6624
+ "command": "schedules get",
6625
+ "args": [
6626
+ "slug",
6627
+ "scheduleId"
6628
+ ],
6629
+ "confirm": false
6630
+ },
6631
+ "mcp": {
6632
+ "exposed": true,
6633
+ "name": "schedules_get",
6634
+ "hints": {
6635
+ "readOnlyHint": true,
6636
+ "destructiveHint": false,
6637
+ "idempotentHint": true
6638
+ }
6639
+ },
6640
+ "description": "Returns one of a script's schedules, with when it runs next.",
6641
+ "fields": [
6642
+ {
6643
+ "name": "slug",
6644
+ "in": "path",
6645
+ "type": "string",
6646
+ "required": true,
6647
+ "description": "The slug's ID.",
6648
+ "example": "monthly-report",
6649
+ "schema": {
6650
+ "type": "string",
6651
+ "description": "The slug's ID."
6652
+ }
6653
+ },
6654
+ {
6655
+ "name": "scheduleId",
6656
+ "in": "path",
6657
+ "type": "string",
6658
+ "required": true,
6659
+ "description": "The schedule's ID.",
6660
+ "example": "sch_037f4852-dc5e-40c8-82a9-852a44410c85",
6661
+ "schema": {
6662
+ "type": "string",
6663
+ "description": "The schedule's ID."
6664
+ }
6665
+ }
6666
+ ],
6667
+ "hasBody": false,
6668
+ "workspace": true,
6669
+ "acceptsApiKey": true,
6670
+ "scope": "scripts:read"
6671
+ },
6286
6672
  {
6287
6673
  "operationId": "schedules.list",
6288
6674
  "method": "get",
@@ -6317,9 +6703,36 @@ var OPERATIONS = [
6317
6703
  "type": "string",
6318
6704
  "description": "The slug's ID."
6319
6705
  }
6706
+ },
6707
+ {
6708
+ "name": "limit",
6709
+ "in": "query",
6710
+ "type": "number",
6711
+ "required": false,
6712
+ "description": "Items per page, 1\u2013100 (default 25).",
6713
+ "example": 25,
6714
+ "schema": {
6715
+ "type": "integer",
6716
+ "minimum": 1,
6717
+ "maximum": 100,
6718
+ "default": 25,
6719
+ "description": "Items per page, 1\u2013100 (default 25)."
6720
+ }
6721
+ },
6722
+ {
6723
+ "name": "cursor",
6724
+ "in": "query",
6725
+ "type": "string",
6726
+ "required": false,
6727
+ "description": "Opaque token from a previous page's nextCursor.",
6728
+ "schema": {
6729
+ "type": "string",
6730
+ "description": "Opaque token from a previous page's nextCursor."
6731
+ }
6320
6732
  }
6321
6733
  ],
6322
6734
  "hasBody": false,
6735
+ "paginated": true,
6323
6736
  "workspace": true,
6324
6737
  "acceptsApiKey": true,
6325
6738
  "scope": "scripts:read"
@@ -6361,7 +6774,7 @@ var OPERATIONS = [
6361
6774
  "type": "string",
6362
6775
  "required": true,
6363
6776
  "description": "The schedule's ID.",
6364
- "example": "sch_2b9f\u2026",
6777
+ "example": "sch_037f4852-dc5e-40c8-82a9-852a44410c85",
6365
6778
  "schema": {
6366
6779
  "type": "string",
6367
6780
  "description": "The schedule's ID."
@@ -6703,6 +7116,7 @@ var OPERATIONS = [
6703
7116
  }
6704
7117
  ],
6705
7118
  "hasBody": false,
7119
+ "paginated": true,
6706
7120
  "workspace": true,
6707
7121
  "acceptsApiKey": true,
6708
7122
  "scope": "scripts:read"
@@ -6764,7 +7178,7 @@ var OPERATIONS = [
6764
7178
  "idempotentHint": false
6765
7179
  }
6766
7180
  },
6767
- "description": "Changes a script's name, description or tags, who can see and run it, and which runs need a person's approval. The script owner, a workspace owner or admin, or a workspace API key can change a script. An agent can't change `access`, `teamIds` or `approvalPolicy`.",
7181
+ "description": "Changes a script's name, description or tags, who can see and run it, and which runs need a person's approval. The script owner, a workspace owner or admin, or a workspace API key can change a script. An agent can't change `access`, `teamIds` or `approvalPolicy`. A name, description or tags that the script's reminix.json sets (listed in `setInFile`) can't change here, and the request returns 409.",
6768
7182
  "fields": [
6769
7183
  {
6770
7184
  "name": "slug",
@@ -6935,27 +7349,28 @@ var OPERATIONS = [
6935
7349
  "scope": "scripts:write"
6936
7350
  },
6937
7351
  {
6938
- "operationId": "scriptVersions.list",
7352
+ "operationId": "scriptVersions.get",
6939
7353
  "method": "get",
6940
- "path": "/scripts/{slug}/versions",
6941
- "summary": "List a script's versions",
7354
+ "path": "/scripts/{slug}/versions/{version}",
7355
+ "summary": "Get a version",
6942
7356
  "cli": {
6943
- "command": "script-versions list",
7357
+ "command": "script-versions get",
6944
7358
  "args": [
6945
- "slug"
7359
+ "slug",
7360
+ "version"
6946
7361
  ],
6947
7362
  "confirm": false
6948
7363
  },
6949
7364
  "mcp": {
6950
7365
  "exposed": true,
6951
- "name": "script_versions_list",
7366
+ "name": "script_versions_get",
6952
7367
  "hints": {
6953
7368
  "readOnlyHint": true,
6954
7369
  "destructiveHint": false,
6955
7370
  "idempotentHint": true
6956
7371
  }
6957
7372
  },
6958
- "description": "Lists every version of a script, newest first, and marks the published one.",
7373
+ "description": "Returns one version of a script, and whether it's the published one.",
6959
7374
  "fields": [
6960
7375
  {
6961
7376
  "name": "slug",
@@ -6968,6 +7383,19 @@ var OPERATIONS = [
6968
7383
  "type": "string",
6969
7384
  "description": "The slug's ID."
6970
7385
  }
7386
+ },
7387
+ {
7388
+ "name": "version",
7389
+ "in": "path",
7390
+ "type": "number",
7391
+ "required": true,
7392
+ "description": "The version's ID.",
7393
+ "example": 3,
7394
+ "schema": {
7395
+ "type": "integer",
7396
+ "minimum": 1,
7397
+ "description": "The version's ID."
7398
+ }
6971
7399
  }
6972
7400
  ],
6973
7401
  "hasBody": false,
@@ -6976,28 +7404,27 @@ var OPERATIONS = [
6976
7404
  "scope": "scripts:read"
6977
7405
  },
6978
7406
  {
6979
- "operationId": "scriptVersions.publish",
6980
- "method": "post",
6981
- "path": "/scripts/{slug}/versions/{version}/publish",
6982
- "summary": "Publish a version",
7407
+ "operationId": "scriptVersions.list",
7408
+ "method": "get",
7409
+ "path": "/scripts/{slug}/versions",
7410
+ "summary": "List a script's versions",
6983
7411
  "cli": {
6984
- "command": "script-versions publish",
7412
+ "command": "script-versions list",
6985
7413
  "args": [
6986
- "slug",
6987
- "version"
7414
+ "slug"
6988
7415
  ],
6989
7416
  "confirm": false
6990
7417
  },
6991
7418
  "mcp": {
6992
7419
  "exposed": true,
6993
- "name": "script_versions_publish",
7420
+ "name": "script_versions_list",
6994
7421
  "hints": {
6995
- "readOnlyHint": false,
7422
+ "readOnlyHint": true,
6996
7423
  "destructiveHint": false,
6997
- "idempotentHint": false
7424
+ "idempotentHint": true
6998
7425
  }
6999
7426
  },
7000
- "description": "Makes a version the one every run of the script uses, however the run starts. Publishing an older version again rolls the script back. The script owner or a workspace owner or admin can publish. When an agent connected through MCP publishes, it becomes a request that a person approves, and the call returns 202. If the workspace requires a second person to publish, everyone's publish becomes a request like this.",
7427
+ "description": "Lists a script's versions, newest first, and marks the published one. Paginate with the opaque `nextCursor` token.",
7001
7428
  "fields": [
7002
7429
  {
7003
7430
  "name": "slug",
@@ -7012,16 +7439,85 @@ var OPERATIONS = [
7012
7439
  }
7013
7440
  },
7014
7441
  {
7015
- "name": "version",
7016
- "in": "path",
7442
+ "name": "limit",
7443
+ "in": "query",
7017
7444
  "type": "number",
7018
- "required": true,
7019
- "description": "The version's ID.",
7020
- "example": 3,
7445
+ "required": false,
7446
+ "description": "Items per page, 1\u2013100 (default 25).",
7447
+ "example": 25,
7021
7448
  "schema": {
7022
7449
  "type": "integer",
7023
7450
  "minimum": 1,
7024
- "description": "The version's ID."
7451
+ "maximum": 100,
7452
+ "default": 25,
7453
+ "description": "Items per page, 1\u2013100 (default 25)."
7454
+ }
7455
+ },
7456
+ {
7457
+ "name": "cursor",
7458
+ "in": "query",
7459
+ "type": "string",
7460
+ "required": false,
7461
+ "description": "Opaque token from a previous page's nextCursor.",
7462
+ "schema": {
7463
+ "type": "string",
7464
+ "description": "Opaque token from a previous page's nextCursor."
7465
+ }
7466
+ }
7467
+ ],
7468
+ "hasBody": false,
7469
+ "paginated": true,
7470
+ "workspace": true,
7471
+ "acceptsApiKey": true,
7472
+ "scope": "scripts:read"
7473
+ },
7474
+ {
7475
+ "operationId": "scriptVersions.publish",
7476
+ "method": "post",
7477
+ "path": "/scripts/{slug}/versions/{version}/publish",
7478
+ "summary": "Publish a version",
7479
+ "cli": {
7480
+ "command": "script-versions publish",
7481
+ "args": [
7482
+ "slug",
7483
+ "version"
7484
+ ],
7485
+ "confirm": false
7486
+ },
7487
+ "mcp": {
7488
+ "exposed": true,
7489
+ "name": "script_versions_publish",
7490
+ "hints": {
7491
+ "readOnlyHint": false,
7492
+ "destructiveHint": false,
7493
+ "idempotentHint": false
7494
+ }
7495
+ },
7496
+ "description": "Makes a version the one every run of the script uses, however the run starts. Publishing an older version again rolls the script back. The script owner or a workspace owner or admin can publish. When an agent connected through MCP publishes, it becomes a request that a person approves, and the call returns 202. If the workspace requires a second person to publish, everyone's publish becomes a request like this.",
7497
+ "fields": [
7498
+ {
7499
+ "name": "slug",
7500
+ "in": "path",
7501
+ "type": "string",
7502
+ "required": true,
7503
+ "description": "The slug's ID.",
7504
+ "example": "unlock-account",
7505
+ "schema": {
7506
+ "type": "string",
7507
+ "description": "The slug's ID."
7508
+ }
7509
+ },
7510
+ {
7511
+ "name": "version",
7512
+ "in": "path",
7513
+ "type": "number",
7514
+ "required": true,
7515
+ "description": "The version's ID.",
7516
+ "example": 3,
7517
+ "schema": {
7518
+ "type": "integer",
7519
+ "minimum": 1,
7520
+ "description": "The version's ID."
7025
7521
  }
7026
7522
  }
7027
7523
  ],
@@ -7186,11 +7682,11 @@ var OPERATIONS = [
7186
7682
  "in": "body",
7187
7683
  "type": "json",
7188
7684
  "required": false,
7189
- "description": "The inputs, as JSON Schema. If you leave it out, each `{name}` in the command becomes a required text input, or an optional one inside `[ \u2026 ]`.",
7685
+ "description": 'The inputs, as JSON Schema. If you leave it out, each `{name}` in the command becomes a required text input, or an optional one inside `[ \u2026 ]`. A text input with `"format": "multiline"` gets a box of several lines in the run form.',
7190
7686
  "schema": {
7191
7687
  "type": "object",
7192
7688
  "additionalProperties": {},
7193
- "description": "The inputs, as JSON Schema. If you leave it out, each `{name}` in the command becomes a required text input, or an optional one inside `[ \u2026 ]`."
7689
+ "description": 'The inputs, as JSON Schema. If you leave it out, each `{name}` in the command becomes a required text input, or an optional one inside `[ \u2026 ]`. A text input with `"format": "multiline"` gets a box of several lines in the run form.'
7194
7690
  }
7195
7691
  },
7196
7692
  {
@@ -7449,6 +7945,47 @@ var OPERATIONS = [
7449
7945
  "acceptsApiKey": true,
7450
7946
  "scope": "secrets:write"
7451
7947
  },
7948
+ {
7949
+ "operationId": "secrets.get",
7950
+ "method": "get",
7951
+ "path": "/secrets/{name}",
7952
+ "summary": "Get a secret",
7953
+ "cli": {
7954
+ "command": "secrets get",
7955
+ "args": [
7956
+ "name"
7957
+ ],
7958
+ "confirm": false
7959
+ },
7960
+ "mcp": {
7961
+ "exposed": true,
7962
+ "name": "secrets_get",
7963
+ "hints": {
7964
+ "readOnlyHint": true,
7965
+ "destructiveHint": false,
7966
+ "idempotentHint": true
7967
+ }
7968
+ },
7969
+ "description": "Returns one secret by its name, with the environments that have a value and the hosts each value may go to. It never includes the values themselves.",
7970
+ "fields": [
7971
+ {
7972
+ "name": "name",
7973
+ "in": "path",
7974
+ "type": "string",
7975
+ "required": true,
7976
+ "description": "The secret's name, in UPPER_SNAKE_CASE. It starts with a letter and has at most 64 characters.",
7977
+ "example": "ADMIN_KEY",
7978
+ "schema": {
7979
+ "type": "string",
7980
+ "description": "The secret's name, in UPPER_SNAKE_CASE. It starts with a letter and has at most 64 characters."
7981
+ }
7982
+ }
7983
+ ],
7984
+ "hasBody": false,
7985
+ "workspace": true,
7986
+ "acceptsApiKey": true,
7987
+ "scope": "secrets:read"
7988
+ },
7452
7989
  {
7453
7990
  "operationId": "secrets.list",
7454
7991
  "method": "get",
@@ -7469,30 +8006,57 @@ var OPERATIONS = [
7469
8006
  }
7470
8007
  },
7471
8008
  "description": "Lists the workspace's secrets by name, with the environments that have a value and the hosts each value may go to. The list never includes the values themselves.",
7472
- "fields": [],
8009
+ "fields": [
8010
+ {
8011
+ "name": "limit",
8012
+ "in": "query",
8013
+ "type": "number",
8014
+ "required": false,
8015
+ "description": "Items per page, 1\u2013100 (default 25).",
8016
+ "example": 25,
8017
+ "schema": {
8018
+ "type": "integer",
8019
+ "minimum": 1,
8020
+ "maximum": 100,
8021
+ "default": 25,
8022
+ "description": "Items per page, 1\u2013100 (default 25)."
8023
+ }
8024
+ },
8025
+ {
8026
+ "name": "cursor",
8027
+ "in": "query",
8028
+ "type": "string",
8029
+ "required": false,
8030
+ "description": "Opaque token from a previous page's nextCursor.",
8031
+ "schema": {
8032
+ "type": "string",
8033
+ "description": "Opaque token from a previous page's nextCursor."
8034
+ }
8035
+ }
8036
+ ],
7473
8037
  "hasBody": false,
8038
+ "paginated": true,
7474
8039
  "workspace": true,
7475
8040
  "acceptsApiKey": true,
7476
8041
  "scope": "secrets:read"
7477
8042
  },
7478
8043
  {
7479
- "operationId": "secrets.set",
7480
- "method": "put",
8044
+ "operationId": "secrets.update",
8045
+ "method": "patch",
7481
8046
  "path": "/secrets/{name}",
7482
- "summary": "Save a secret",
8047
+ "summary": "Update a secret",
7483
8048
  "cli": {
7484
- "command": "secrets set",
8049
+ "command": "secrets update",
7485
8050
  "args": [
7486
8051
  "name"
7487
8052
  ],
7488
- "confirm": false,
7489
- "sample": 'printf %s "$ADMIN_KEY" | \\\n reminix secrets set ADMIN_KEY \\\n --hosts api.yourapp.com'
8053
+ "confirm": false
7490
8054
  },
7491
8055
  "mcp": {
7492
8056
  "exposed": false,
7493
8057
  "reason": "Secret values are a person's to handle; an agent asks the person to add the secret"
7494
8058
  },
7495
- "description": "Saves a secret's value in the request's environment. Saving creates the secret if it's new, or replaces the value and its hosts to rotate it. Reminix encrypts the value, and no call ever returns it. Reminix sends the value only to the hosts in `hosts`. Workspace owners, admins and API keys can save a secret.",
8059
+ "description": "Changes what applies to a secret in every environment. Its values are saved one environment at a time, with Save a secret's value. Workspace owners, admins and API keys can change a secret.",
7496
8060
  "fields": [
7497
8061
  {
7498
8062
  "name": "name",
@@ -7506,44 +8070,15 @@ var OPERATIONS = [
7506
8070
  "description": "The secret's name, in UPPER_SNAKE_CASE. It starts with a letter and has at most 64 characters."
7507
8071
  }
7508
8072
  },
7509
- {
7510
- "name": "value",
7511
- "in": "body",
7512
- "type": "string",
7513
- "required": true,
7514
- "description": "The secret itself, at most 16,384 bytes.",
7515
- "example": "ak_live_\u2026",
7516
- "schema": {
7517
- "type": "string",
7518
- "description": "The secret itself, at most 16,384 bytes."
7519
- }
7520
- },
7521
- {
7522
- "name": "hosts",
7523
- "in": "body",
7524
- "type": "json",
7525
- "required": true,
7526
- "description": "The only hosts Reminix sends this value to, such as `api.stripe.com`.",
7527
- "example": [
7528
- "api.yourapp.com"
7529
- ],
7530
- "schema": {
7531
- "type": "array",
7532
- "items": {
7533
- "type": "string"
7534
- },
7535
- "description": "The only hosts Reminix sends this value to, such as `api.stripe.com`."
7536
- }
7537
- },
7538
8073
  {
7539
8074
  "name": "allowEnvVar",
7540
8075
  "in": "body",
7541
8076
  "type": "boolean",
7542
8077
  "required": false,
7543
- "description": "Whether scripts can read the secret as an environment variable. The default is false, so Reminix only attaches it to requests.",
8078
+ "description": "Whether scripts can read the secret as an environment variable. A new secret starts with false, so Reminix only attaches it to requests.",
7544
8079
  "schema": {
7545
8080
  "type": "boolean",
7546
- "description": "Whether scripts can read the secret as an environment variable. The default is false, so Reminix only attaches it to requests."
8081
+ "description": "Whether scripts can read the secret as an environment variable. A new secret starts with false, so Reminix only attaches it to requests."
7547
8082
  }
7548
8083
  }
7549
8084
  ],
@@ -7588,11 +8123,11 @@ var OPERATIONS = [
7588
8123
  "in": "path",
7589
8124
  "type": "string",
7590
8125
  "required": true,
7591
- "description": "The environment's ID.",
7592
- "example": "staging",
8126
+ "description": "The environment's name.",
8127
+ "example": "production",
7593
8128
  "schema": {
7594
8129
  "type": "string",
7595
- "description": "The environment's ID."
8130
+ "description": "The environment's name."
7596
8131
  }
7597
8132
  }
7598
8133
  ],
@@ -7602,12 +8137,91 @@ var OPERATIONS = [
7602
8137
  "scope": "secrets:write"
7603
8138
  },
7604
8139
  {
7605
- "operationId": "triggers.calls",
8140
+ "operationId": "secretValues.set",
8141
+ "method": "put",
8142
+ "path": "/secrets/{name}/values/{environment}",
8143
+ "summary": "Save a secret's value",
8144
+ "cli": {
8145
+ "command": "secrets set",
8146
+ "args": [
8147
+ "name",
8148
+ "environment"
8149
+ ],
8150
+ "confirm": false,
8151
+ "sample": 'printf %s "$ADMIN_KEY" | \\\n reminix secrets set ADMIN_KEY \\\n --hosts api.yourapp.com'
8152
+ },
8153
+ "mcp": {
8154
+ "exposed": false,
8155
+ "reason": "Secret values are a person's to handle; an agent asks the person to add the secret"
8156
+ },
8157
+ "description": "Saves a secret's value in one environment. Saving creates the secret if it's new, or replaces the value and its hosts to rotate it. Reminix encrypts the value, and no call ever returns it. Reminix sends the value only to the hosts in `hosts`. Workspace owners, admins and API keys can save a secret.",
8158
+ "fields": [
8159
+ {
8160
+ "name": "name",
8161
+ "in": "path",
8162
+ "type": "string",
8163
+ "required": true,
8164
+ "description": "The secret's name, in UPPER_SNAKE_CASE. It starts with a letter and has at most 64 characters.",
8165
+ "example": "ADMIN_KEY",
8166
+ "schema": {
8167
+ "type": "string",
8168
+ "description": "The secret's name, in UPPER_SNAKE_CASE. It starts with a letter and has at most 64 characters."
8169
+ }
8170
+ },
8171
+ {
8172
+ "name": "environment",
8173
+ "in": "path",
8174
+ "type": "string",
8175
+ "required": true,
8176
+ "description": "The environment's name.",
8177
+ "example": "production",
8178
+ "schema": {
8179
+ "type": "string",
8180
+ "description": "The environment's name."
8181
+ }
8182
+ },
8183
+ {
8184
+ "name": "value",
8185
+ "in": "body",
8186
+ "type": "string",
8187
+ "required": true,
8188
+ "description": "The secret itself, at most 16,384 bytes.",
8189
+ "example": "ak_live_\u2026",
8190
+ "schema": {
8191
+ "type": "string",
8192
+ "description": "The secret itself, at most 16,384 bytes."
8193
+ }
8194
+ },
8195
+ {
8196
+ "name": "hosts",
8197
+ "in": "body",
8198
+ "type": "json",
8199
+ "required": true,
8200
+ "description": "The only hosts Reminix sends this value to, such as `api.stripe.com`.",
8201
+ "example": [
8202
+ "api.yourapp.com"
8203
+ ],
8204
+ "schema": {
8205
+ "type": "array",
8206
+ "items": {
8207
+ "type": "string"
8208
+ },
8209
+ "description": "The only hosts Reminix sends this value to, such as `api.stripe.com`."
8210
+ }
8211
+ }
8212
+ ],
8213
+ "hasBody": true,
8214
+ "workspace": true,
8215
+ "acceptsApiKey": true,
8216
+ "scope": "secrets:write"
8217
+ },
8218
+ {
8219
+ "operationId": "triggerCalls.list",
7606
8220
  "method": "get",
7607
8221
  "path": "/scripts/{slug}/triggers/{triggerId}/calls",
7608
8222
  "summary": "List a webhook trigger's calls",
7609
8223
  "cli": {
7610
- "command": "triggers calls",
8224
+ "command": "trigger-calls list",
7611
8225
  "args": [
7612
8226
  "slug",
7613
8227
  "triggerId"
@@ -7616,14 +8230,14 @@ var OPERATIONS = [
7616
8230
  },
7617
8231
  "mcp": {
7618
8232
  "exposed": true,
7619
- "name": "triggers_calls",
8233
+ "name": "trigger_calls_list",
7620
8234
  "hints": {
7621
8235
  "readOnlyHint": true,
7622
8236
  "destructiveHint": false,
7623
8237
  "idempotentHint": true
7624
8238
  }
7625
8239
  },
7626
- "description": "Returns a webhook trigger's last 20 calls, newest first: when each came, whether it started a run or repeated an earlier call, why Reminix refused it, and the run. Reminix keeps calls for 30 days.",
8240
+ "description": "Lists a webhook trigger's calls, newest first: when each came, whether it started a run or repeated an earlier call, why Reminix refused it, and the run. Reminix keeps calls for 30 days.",
7627
8241
  "fields": [
7628
8242
  {
7629
8243
  "name": "slug",
@@ -7643,14 +8257,41 @@ var OPERATIONS = [
7643
8257
  "type": "string",
7644
8258
  "required": true,
7645
8259
  "description": "The trigger's ID.",
7646
- "example": "trg_6e4a\u2026",
8260
+ "example": "trg_6a2e4a00-bdcf-4035-85b7-544eab30f470",
8261
+ "schema": {
8262
+ "type": "string",
8263
+ "description": "The trigger's ID."
8264
+ }
8265
+ },
8266
+ {
8267
+ "name": "limit",
8268
+ "in": "query",
8269
+ "type": "number",
8270
+ "required": false,
8271
+ "description": "Items per page, 1\u2013100 (default 25).",
8272
+ "example": 25,
8273
+ "schema": {
8274
+ "type": "integer",
8275
+ "minimum": 1,
8276
+ "maximum": 100,
8277
+ "default": 25,
8278
+ "description": "Items per page, 1\u2013100 (default 25)."
8279
+ }
8280
+ },
8281
+ {
8282
+ "name": "cursor",
8283
+ "in": "query",
8284
+ "type": "string",
8285
+ "required": false,
8286
+ "description": "Opaque token from a previous page's nextCursor.",
7647
8287
  "schema": {
7648
8288
  "type": "string",
7649
- "description": "The trigger's ID."
8289
+ "description": "Opaque token from a previous page's nextCursor."
7650
8290
  }
7651
8291
  }
7652
8292
  ],
7653
8293
  "hasBody": false,
8294
+ "paginated": true,
7654
8295
  "workspace": true,
7655
8296
  "acceptsApiKey": true,
7656
8297
  "scope": "scripts:read"
@@ -7669,7 +8310,7 @@ var OPERATIONS = [
7669
8310
  },
7670
8311
  "mcp": {
7671
8312
  "exposed": false,
7672
- "reason": "Schedules and triggers run as the person who created them. Only a person can create one. An agent can ask for a webhook trigger: POST /v1/workspace/approval-requests with action trigger.webhook.create, which a workspace owner approves."
8313
+ "reason": "Schedules and triggers run as the person who created them. Only a person can create one. An agent can ask for a webhook trigger: POST /v1/workspace/approval-requests with action trigger.webhook.create, which a workspace owner or admin approves."
7673
8314
  },
7674
8315
  "description": "Creates a trigger that starts a run of the script, as you. With the type `event`, a run starts when an event of `event` happens in the workspace and its data matches `filter`. GET /v1/workspace/event-types lists the event types. The run starts within about a minute of the event, and a chain of triggered runs stops after 3. With the type `webhook`, a run starts when someone calls the trigger's URL with its secret. The response carries the URL and the secret once. Only the script's owner, or a workspace owner or admin, can create a webhook trigger, and its runs wait for approval where an agent's would. For an event trigger, if every run of the script or of the environment needs approval, only workspace owners and admins can create it.",
7675
8316
  "fields": [
@@ -7889,7 +8530,7 @@ var OPERATIONS = [
7889
8530
  "type": "string",
7890
8531
  "required": true,
7891
8532
  "description": "The trigger's ID.",
7892
- "example": "trg_6e4a\u2026",
8533
+ "example": "trg_6a2e4a00-bdcf-4035-85b7-544eab30f470",
7893
8534
  "schema": {
7894
8535
  "type": "string",
7895
8536
  "description": "The trigger's ID."
@@ -7901,6 +8542,60 @@ var OPERATIONS = [
7901
8542
  "acceptsApiKey": true,
7902
8543
  "scope": "scripts:write"
7903
8544
  },
8545
+ {
8546
+ "operationId": "triggers.get",
8547
+ "method": "get",
8548
+ "path": "/scripts/{slug}/triggers/{triggerId}",
8549
+ "summary": "Get a trigger",
8550
+ "cli": {
8551
+ "command": "triggers get",
8552
+ "args": [
8553
+ "slug",
8554
+ "triggerId"
8555
+ ],
8556
+ "confirm": false
8557
+ },
8558
+ "mcp": {
8559
+ "exposed": true,
8560
+ "name": "triggers_get",
8561
+ "hints": {
8562
+ "readOnlyHint": true,
8563
+ "destructiveHint": false,
8564
+ "idempotentHint": true
8565
+ }
8566
+ },
8567
+ "description": "Returns one of a script's triggers. A webhook trigger's secret is never returned again after it is made or rotated.",
8568
+ "fields": [
8569
+ {
8570
+ "name": "slug",
8571
+ "in": "path",
8572
+ "type": "string",
8573
+ "required": true,
8574
+ "description": "The slug's ID.",
8575
+ "example": "alert-on-failure",
8576
+ "schema": {
8577
+ "type": "string",
8578
+ "description": "The slug's ID."
8579
+ }
8580
+ },
8581
+ {
8582
+ "name": "triggerId",
8583
+ "in": "path",
8584
+ "type": "string",
8585
+ "required": true,
8586
+ "description": "The trigger's ID.",
8587
+ "example": "trg_6a2e4a00-bdcf-4035-85b7-544eab30f470",
8588
+ "schema": {
8589
+ "type": "string",
8590
+ "description": "The trigger's ID."
8591
+ }
8592
+ }
8593
+ ],
8594
+ "hasBody": false,
8595
+ "workspace": true,
8596
+ "acceptsApiKey": true,
8597
+ "scope": "scripts:read"
8598
+ },
7904
8599
  {
7905
8600
  "operationId": "triggers.list",
7906
8601
  "method": "get",
@@ -7935,9 +8630,36 @@ var OPERATIONS = [
7935
8630
  "type": "string",
7936
8631
  "description": "The slug's ID."
7937
8632
  }
8633
+ },
8634
+ {
8635
+ "name": "limit",
8636
+ "in": "query",
8637
+ "type": "number",
8638
+ "required": false,
8639
+ "description": "Items per page, 1\u2013100 (default 25).",
8640
+ "example": 25,
8641
+ "schema": {
8642
+ "type": "integer",
8643
+ "minimum": 1,
8644
+ "maximum": 100,
8645
+ "default": 25,
8646
+ "description": "Items per page, 1\u2013100 (default 25)."
8647
+ }
8648
+ },
8649
+ {
8650
+ "name": "cursor",
8651
+ "in": "query",
8652
+ "type": "string",
8653
+ "required": false,
8654
+ "description": "Opaque token from a previous page's nextCursor.",
8655
+ "schema": {
8656
+ "type": "string",
8657
+ "description": "Opaque token from a previous page's nextCursor."
8658
+ }
7938
8659
  }
7939
8660
  ],
7940
8661
  "hasBody": false,
8662
+ "paginated": true,
7941
8663
  "workspace": true,
7942
8664
  "acceptsApiKey": true,
7943
8665
  "scope": "scripts:read"
@@ -7957,7 +8679,7 @@ var OPERATIONS = [
7957
8679
  },
7958
8680
  "mcp": {
7959
8681
  "exposed": false,
7960
- "reason": "Only a person can rotate a webhook trigger's secret. An agent can ask: POST /v1/workspace/approval-requests with action trigger.webhook.rotateSecret, which a workspace owner approves."
8682
+ "reason": "An agent can't rotate a webhook trigger's secret itself. It can ask: POST /v1/workspace/approval-requests with action trigger.webhook.rotateSecret, which a workspace owner or admin approves."
7961
8683
  },
7962
8684
  "description": "Gives a webhook trigger a new secret and returns its new URL, this once. The old URL stops working at once. If Reminix disabled the trigger, such as after repeated refused calls, rotating enables it again. The script's owner, a workspace owner or admin, or a workspace API key can rotate it.",
7963
8685
  "fields": [
@@ -7979,7 +8701,7 @@ var OPERATIONS = [
7979
8701
  "type": "string",
7980
8702
  "required": true,
7981
8703
  "description": "The trigger's ID.",
7982
- "example": "trg_6e4a\u2026",
8704
+ "example": "trg_6a2e4a00-bdcf-4035-85b7-544eab30f470",
7983
8705
  "schema": {
7984
8706
  "type": "string",
7985
8707
  "description": "The trigger's ID."
@@ -8028,7 +8750,7 @@ var OPERATIONS = [
8028
8750
  "type": "string",
8029
8751
  "required": true,
8030
8752
  "description": "The trigger's ID.",
8031
- "example": "trg_6e4a\u2026",
8753
+ "example": "trg_6a2e4a00-bdcf-4035-85b7-544eab30f470",
8032
8754
  "schema": {
8033
8755
  "type": "string",
8034
8756
  "description": "The trigger's ID."
@@ -8223,9 +8945,10 @@ var OPERATIONS = [
8223
8945
  "idempotentHint": true
8224
8946
  }
8225
8947
  },
8226
- "description": "Lists the actions a credential can't take itself but can ask a person to approve. Each action comes with its input as a JSON Schema, who can approve it and whether it creates a secret.",
8948
+ "description": "Lists the actions a credential can't take itself but can ask a person to approve. Each action comes with its input as a JSON Schema (`inputSchema`), who can approve it and whether it creates a secret. Every action fits on one page, so `nextCursor` is null.",
8227
8949
  "fields": [],
8228
8950
  "hasBody": false,
8951
+ "paginated": true,
8229
8952
  "workspace": true,
8230
8953
  "acceptsApiKey": true,
8231
8954
  "scope": "workspace.approvals:read"
@@ -8304,12 +9027,12 @@ var OPERATIONS = [
8304
9027
  {
8305
9028
  "operationId": "workspace.approvalRequests.get",
8306
9029
  "method": "get",
8307
- "path": "/workspace/approval-requests/{requestId}",
9030
+ "path": "/workspace/approval-requests/{approvalRequestId}",
8308
9031
  "summary": "Check an approval request",
8309
9032
  "cli": {
8310
9033
  "command": "workspace approval-requests get",
8311
9034
  "args": [
8312
- "requestId"
9035
+ "approvalRequestId"
8313
9036
  ],
8314
9037
  "confirm": false
8315
9038
  },
@@ -8325,15 +9048,15 @@ var OPERATIONS = [
8325
9048
  "description": "Returns an approval request you created, with its status. A `pending` request is waiting for a person to decide. A `completed` request's action ran, and `result` holds the outcome. An `approved` request is waiting for the CLI to redeem it. A request can also be `denied`, `failed` or `expired`.",
8326
9049
  "fields": [
8327
9050
  {
8328
- "name": "requestId",
9051
+ "name": "approvalRequestId",
8329
9052
  "in": "path",
8330
9053
  "type": "string",
8331
9054
  "required": true,
8332
- "description": "The request's id.",
8333
- "example": "apr_7c2e\u2026",
9055
+ "description": "The approval request's id.",
9056
+ "example": "apr_7c2e9b4d-1f3a-4e5b-8c6d-7e8f9a0b1c2d",
8334
9057
  "schema": {
8335
9058
  "type": "string",
8336
- "description": "The request's id."
9059
+ "description": "The approval request's id."
8337
9060
  }
8338
9061
  }
8339
9062
  ],
@@ -8345,12 +9068,12 @@ var OPERATIONS = [
8345
9068
  {
8346
9069
  "operationId": "workspace.approvalRequests.redeem",
8347
9070
  "method": "post",
8348
- "path": "/workspace/approval-requests/{requestId}/redeem",
9071
+ "path": "/workspace/approval-requests/{approvalRequestId}/redeem",
8349
9072
  "summary": "Redeem an approved request",
8350
9073
  "cli": {
8351
9074
  "command": "workspace approval-requests redeem",
8352
9075
  "args": [
8353
- "requestId"
9076
+ "approvalRequestId"
8354
9077
  ],
8355
9078
  "confirm": false
8356
9079
  },
@@ -8361,15 +9084,15 @@ var OPERATIONS = [
8361
9084
  "description": "Runs an approved action that creates a secret, and returns the secret. The action runs only once. Only the personal access token that asked can redeem it. The CLI writes the secret to a file without printing it.",
8362
9085
  "fields": [
8363
9086
  {
8364
- "name": "requestId",
9087
+ "name": "approvalRequestId",
8365
9088
  "in": "path",
8366
9089
  "type": "string",
8367
9090
  "required": true,
8368
- "description": "The request's id.",
8369
- "example": "apr_7c2e\u2026",
9091
+ "description": "The approval request's id.",
9092
+ "example": "apr_7c2e9b4d-1f3a-4e5b-8c6d-7e8f9a0b1c2d",
8370
9093
  "schema": {
8371
9094
  "type": "string",
8372
- "description": "The request's id."
9095
+ "description": "The approval request's id."
8373
9096
  }
8374
9097
  }
8375
9098
  ],
@@ -8397,7 +9120,7 @@ var OPERATIONS = [
8397
9120
  "idempotentHint": true
8398
9121
  }
8399
9122
  },
8400
- "description": "Lists the workspace's audit events, newest first. Paginate with the opaque `nextCursor` token. `limit` takes 1 to 100 and defaults to 25. `before` starts from a moment. `action` keeps one kind of event, and `actor` what one person, key or token did. With a personal access token, only workspace owners can call this, as with the audit page in the app. A workspace API key always can, because it acts as the workspace itself.",
9123
+ "description": "Lists the workspace's audit events, newest first. Paginate with the opaque `nextCursor` token. `limit` takes 1 to 100 and defaults to 25. `before` starts from a moment. `action` keeps one kind of event, and `actor` what one person, key or token did. With a personal access token, only workspace owners and admins can call this, as with the audit page in the app. A workspace API key always can, because it acts as the workspace itself.",
8401
9124
  "fields": [
8402
9125
  {
8403
9126
  "name": "limit",
@@ -8444,7 +9167,7 @@ var OPERATIONS = [
8444
9167
  "type": "string",
8445
9168
  "required": false,
8446
9169
  "description": "Only events of this action.",
8447
- "example": "workspace.member_invited",
9170
+ "example": "workspace.member.invited",
8448
9171
  "schema": {
8449
9172
  "type": "string",
8450
9173
  "maxLength": 100,
@@ -8457,7 +9180,7 @@ var OPERATIONS = [
8457
9180
  "type": "string",
8458
9181
  "required": false,
8459
9182
  "description": "Only what one person did (`user:` and the item's `actor.id`), or one key or token (`credential:` and the item's `credential.id`).",
8460
- "example": "user:usr_k3TAiF2ZP5sQ",
9183
+ "example": "user:usr_4f8a2c1e-7b3d-4e9f-a6c5-2d1b0e9f8a7c",
8461
9184
  "schema": {
8462
9185
  "type": "string",
8463
9186
  "pattern": "^(user|credential):[\\w-]+$",
@@ -8466,6 +9189,7 @@ var OPERATIONS = [
8466
9189
  }
8467
9190
  ],
8468
9191
  "hasBody": false,
9192
+ "paginated": true,
8469
9193
  "workspace": true,
8470
9194
  "acceptsApiKey": true,
8471
9195
  "scope": "workspace.audit:read"
@@ -8489,9 +9213,10 @@ var OPERATIONS = [
8489
9213
  "idempotentHint": true
8490
9214
  }
8491
9215
  },
8492
- "description": "Lists every workspace event a webhook endpoint can subscribe to, and what each one means. Pass some as `eventTypes` when you add an endpoint. An endpoint without a list receives every event.",
9216
+ "description": "Lists every workspace event a webhook endpoint can subscribe to, and what each one means. Pass some as `eventTypes` when you add an endpoint. An endpoint without a list receives every event. Every type fits on one page, so `nextCursor` is null.",
8493
9217
  "fields": [],
8494
9218
  "hasBody": false,
9219
+ "paginated": true,
8495
9220
  "workspace": true,
8496
9221
  "acceptsApiKey": true,
8497
9222
  "scope": "workspace.webhooks:read"
@@ -8571,6 +9296,7 @@ var OPERATIONS = [
8571
9296
  }
8572
9297
  ],
8573
9298
  "hasBody": false,
9299
+ "paginated": true,
8574
9300
  "workspace": true,
8575
9301
  "acceptsApiKey": true,
8576
9302
  "scope": "workspace.members:read"
@@ -8624,10 +9350,37 @@ var OPERATIONS = [
8624
9350
  }
8625
9351
  ],
8626
9352
  "hasBody": false,
9353
+ "paginated": true,
8627
9354
  "workspace": true,
8628
9355
  "acceptsApiKey": true,
8629
9356
  "scope": "workspace.members:read"
8630
9357
  },
9358
+ {
9359
+ "operationId": "workspace.planUsage.get",
9360
+ "method": "get",
9361
+ "path": "/workspace/plan-usage",
9362
+ "summary": "Get your plan's usage this period",
9363
+ "cli": {
9364
+ "command": "workspace plan-usage get",
9365
+ "args": [],
9366
+ "confirm": false
9367
+ },
9368
+ "mcp": {
9369
+ "exposed": true,
9370
+ "name": "workspace_plan_usage_get",
9371
+ "hints": {
9372
+ "readOnlyHint": true,
9373
+ "destructiveHint": false,
9374
+ "idempotentHint": true
9375
+ }
9376
+ },
9377
+ "description": "Returns what the workspace used this period, with one entry for each thing its plan counts. Each entry has the plan's limit, or null when there is no limit. Each entry also says where it stands and where we start refusing new use. A period is one month from the workspace's billing date. That date comes from its subscription or, without one, from the day you created the workspace. On an annual plan, the counts still reset every month from the subscription's start.",
9378
+ "fields": [],
9379
+ "hasBody": false,
9380
+ "workspace": true,
9381
+ "acceptsApiKey": true,
9382
+ "scope": "workspace:read"
9383
+ },
8631
9384
  {
8632
9385
  "operationId": "workspace.teams.list",
8633
9386
  "method": "get",
@@ -8677,36 +9430,11 @@ var OPERATIONS = [
8677
9430
  }
8678
9431
  ],
8679
9432
  "hasBody": false,
9433
+ "paginated": true,
8680
9434
  "workspace": true,
8681
9435
  "acceptsApiKey": true,
8682
9436
  "scope": "workspace.teams:read"
8683
9437
  },
8684
- {
8685
- "operationId": "workspace.usage",
8686
- "method": "get",
8687
- "path": "/workspace/usage",
8688
- "summary": "Get your plan's usage this period",
8689
- "cli": {
8690
- "command": "workspace usage",
8691
- "args": [],
8692
- "confirm": false
8693
- },
8694
- "mcp": {
8695
- "exposed": true,
8696
- "name": "workspace_usage",
8697
- "hints": {
8698
- "readOnlyHint": true,
8699
- "destructiveHint": false,
8700
- "idempotentHint": true
8701
- }
8702
- },
8703
- "description": "Returns what the workspace used this period, with one entry for each thing its plan counts. Each entry has the plan's limit, or null when there is no limit. Each entry also says where it stands and where we start refusing new use. A period is one month from the workspace's billing date. That date comes from its subscription or, without one, from the day you created the workspace. On an annual plan, the counts still reset every month from the subscription's start.",
8704
- "fields": [],
8705
- "hasBody": false,
8706
- "workspace": true,
8707
- "acceptsApiKey": true,
8708
- "scope": "workspace:read"
8709
- },
8710
9438
  {
8711
9439
  "operationId": "workspace.webhookDeliveries.list",
8712
9440
  "method": "get",
@@ -8728,7 +9456,7 @@ var OPERATIONS = [
8728
9456
  "idempotentHint": true
8729
9457
  }
8730
9458
  },
8731
- "description": "Lists one endpoint's delivery history, newest first. Each entry shows the event's status, attempts and last HTTP status. Payloads aren't included. We keep the history for 30 days. Paginate with the opaque `nextCursor`. `before` starts from a moment, and `status` keeps one kind of delivery. With a personal access token, only the workspace owner can call this. A workspace API key with this scope can.",
9459
+ "description": "Lists one endpoint's delivery history, newest first. Each entry shows the delivery's state, its attempts and the last HTTP status code. Payloads aren't included. We keep the history for 30 days. Paginate with the opaque `nextCursor`. `before` starts from a moment, and `status` keeps one kind of delivery. With a personal access token, the workspace's owners and admins can call this, and members on the test side. A workspace API key with this scope can.",
8732
9460
  "fields": [
8733
9461
  {
8734
9462
  "name": "endpointId",
@@ -8736,7 +9464,7 @@ var OPERATIONS = [
8736
9464
  "type": "string",
8737
9465
  "required": true,
8738
9466
  "description": "The endpoint's ID.",
8739
- "example": "we_3f0c\u2026",
9467
+ "example": "we_3f0c1a2e-4b5d-4c6e-8f70-1a2b3c4d5e6f",
8740
9468
  "schema": {
8741
9469
  "type": "string",
8742
9470
  "description": "The endpoint's ID."
@@ -8800,6 +9528,7 @@ var OPERATIONS = [
8800
9528
  }
8801
9529
  ],
8802
9530
  "hasBody": false,
9531
+ "paginated": true,
8803
9532
  "workspace": true,
8804
9533
  "acceptsApiKey": true,
8805
9534
  "scope": "workspace.webhooks:read"
@@ -8826,7 +9555,7 @@ var OPERATIONS = [
8826
9555
  "idempotentHint": false
8827
9556
  }
8828
9557
  },
8829
- "description": "Sends a recorded delivery's event again, as a new delivery. The new delivery gets its own history entry. The event id stays the same, so receivers can deduplicate. Redelivery only works on an enabled endpoint. With a personal access token, only the workspace owner can call this. A workspace API key with this scope can.",
9558
+ "description": "Sends a recorded delivery's event again, as a new delivery. The new delivery gets its own history entry. The event id stays the same, so receivers can deduplicate. Redelivery only works on an enabled endpoint. It answers 200 when we attempted the delivery right away, with the endpoint's answer, and 202 when it went to the queue. With a personal access token, the workspace's owners and admins can call this, and members on the test side. A workspace API key with this scope can.",
8830
9559
  "fields": [
8831
9560
  {
8832
9561
  "name": "endpointId",
@@ -8834,7 +9563,7 @@ var OPERATIONS = [
8834
9563
  "type": "string",
8835
9564
  "required": true,
8836
9565
  "description": "The endpoint's ID.",
8837
- "example": "we_3f0c\u2026",
9566
+ "example": "we_3f0c1a2e-4b5d-4c6e-8f70-1a2b3c4d5e6f",
8838
9567
  "schema": {
8839
9568
  "type": "string",
8840
9569
  "description": "The endpoint's ID."
@@ -8846,7 +9575,7 @@ var OPERATIONS = [
8846
9575
  "type": "string",
8847
9576
  "required": true,
8848
9577
  "description": "The delivery's ID.",
8849
- "example": "del_8a1b\u2026",
9578
+ "example": "del_8a1b2c3d-4e5f-4a6b-9c7d-8e9f0a1b2c3d",
8850
9579
  "schema": {
8851
9580
  "type": "string",
8852
9581
  "description": "The delivery's ID."
@@ -8872,7 +9601,7 @@ var OPERATIONS = [
8872
9601
  "exposed": false,
8873
9602
  "reason": "Changes where workspace data is sent. A person configures webhook endpoints (Settings \u2192 Developers in the app)."
8874
9603
  },
8875
- "description": "Registers an HTTPS URL to receive the workspace's events. Deliveries use the same signature format as Svix. The response includes the endpoint's signing secret (`whsec_\u2026`). You see it only once, so store it to verify deliveries. The API refuses private hosts and hosts without HTTPS. A workspace can have at most 10 endpoints. With a personal access token, only the workspace owner can call this. A workspace API key with this scope can.",
9604
+ "description": "Registers an HTTPS URL to receive the workspace's events. Deliveries use the same signature format as Svix. The response is the new endpoint with its signing secret (`whsec_\u2026`) in `secret`. You see it only once, so store it to verify deliveries. The API refuses private hosts and hosts without HTTPS. A workspace can have at most 10 endpoints. With a personal access token, the workspace's owners and admins can call this, and members on the test side. A workspace API key with this scope can.",
8876
9605
  "fields": [
8877
9606
  {
8878
9607
  "name": "url",
@@ -8940,7 +9669,7 @@ var OPERATIONS = [
8940
9669
  "exposed": false,
8941
9670
  "reason": "Changes where workspace data is sent. A person configures webhook endpoints (Settings \u2192 Developers in the app)."
8942
9671
  },
8943
- "description": "Deletes the endpoint and its signing secret. All deliveries to the endpoint stop. Its delivery history goes with it. With a personal access token, only the workspace owner can call this. A workspace API key with this scope can.",
9672
+ "description": "Deletes the endpoint and its signing secret. All deliveries to the endpoint stop. Its delivery history goes with it. With a personal access token, the workspace's owners and admins can call this, and members on the test side. A workspace API key with this scope can.",
8944
9673
  "fields": [
8945
9674
  {
8946
9675
  "name": "endpointId",
@@ -8948,7 +9677,7 @@ var OPERATIONS = [
8948
9677
  "type": "string",
8949
9678
  "required": true,
8950
9679
  "description": "The endpoint's ID.",
8951
- "example": "we_3f0c\u2026",
9680
+ "example": "we_3f0c1a2e-4b5d-4c6e-8f70-1a2b3c4d5e6f",
8952
9681
  "schema": {
8953
9682
  "type": "string",
8954
9683
  "description": "The endpoint's ID."
@@ -8976,7 +9705,7 @@ var OPERATIONS = [
8976
9705
  "exposed": false,
8977
9706
  "reason": "Changes where workspace data is sent. A person configures webhook endpoints (Settings \u2192 Developers in the app)."
8978
9707
  },
8979
- "description": "Resumes deliveries to an endpoint that stopped after repeated failures. The endpoint keeps its signing secret. Its failure count resets. With a personal access token, only the workspace owner can call this. A workspace API key with this scope can.",
9708
+ "description": "Resumes deliveries to an endpoint that stopped after repeated failures. The endpoint keeps its signing secret. Its failure count resets. With a personal access token, the workspace's owners and admins can call this, and members on the test side. A workspace API key with this scope can.",
8980
9709
  "fields": [
8981
9710
  {
8982
9711
  "name": "endpointId",
@@ -8984,7 +9713,7 @@ var OPERATIONS = [
8984
9713
  "type": "string",
8985
9714
  "required": true,
8986
9715
  "description": "The endpoint's ID.",
8987
- "example": "we_3f0c\u2026",
9716
+ "example": "we_3f0c1a2e-4b5d-4c6e-8f70-1a2b3c4d5e6f",
8988
9717
  "schema": {
8989
9718
  "type": "string",
8990
9719
  "description": "The endpoint's ID."
@@ -9017,7 +9746,7 @@ var OPERATIONS = [
9017
9746
  "idempotentHint": true
9018
9747
  }
9019
9748
  },
9020
- "description": "Returns one endpoint without its signing secret. It shows whether the endpoint is on, its consecutive failures and its last delivery status. With a personal access token, only the workspace owner can call this. A workspace API key with this scope can.",
9749
+ "description": "Returns one endpoint without its signing secret. It shows whether the endpoint is on, its consecutive failures and its last delivery status. With a personal access token, the workspace's owners and admins can call this, and members on the test side. A workspace API key with this scope can.",
9021
9750
  "fields": [
9022
9751
  {
9023
9752
  "name": "endpointId",
@@ -9025,7 +9754,7 @@ var OPERATIONS = [
9025
9754
  "type": "string",
9026
9755
  "required": true,
9027
9756
  "description": "The endpoint's ID.",
9028
- "example": "we_3f0c\u2026",
9757
+ "example": "we_3f0c1a2e-4b5d-4c6e-8f70-1a2b3c4d5e6f",
9029
9758
  "schema": {
9030
9759
  "type": "string",
9031
9760
  "description": "The endpoint's ID."
@@ -9056,9 +9785,10 @@ var OPERATIONS = [
9056
9785
  "idempotentHint": true
9057
9786
  }
9058
9787
  },
9059
- "description": "Lists the workspace's outgoing webhook endpoints, newest first. The list leaves out their signing secrets. A workspace has at most 10 endpoints, so the list is a single page. Its `nextCursor` is null. With a personal access token, only the workspace owner can call this. A workspace API key with this scope can.",
9788
+ "description": "Lists the workspace's outgoing webhook endpoints, newest first. The list leaves out their signing secrets. A workspace has at most 10 endpoints, so the list is a single page. Its `nextCursor` is null. With a personal access token, the workspace's owners and admins can call this, and members on the test side. A workspace API key with this scope can.",
9060
9789
  "fields": [],
9061
9790
  "hasBody": false,
9791
+ "paginated": true,
9062
9792
  "workspace": true,
9063
9793
  "acceptsApiKey": true,
9064
9794
  "scope": "workspace.webhooks:read"
@@ -9084,7 +9814,7 @@ var OPERATIONS = [
9084
9814
  "idempotentHint": false
9085
9815
  }
9086
9816
  },
9087
- "description": "Sends a `ping` event to the endpoint, signed like every delivery. Use it to check that an integration verifies and accepts deliveries. With a personal access token, only the workspace owner can call this. A workspace API key with this scope can.",
9817
+ "description": "Sends a `ping` event to the endpoint, signed like every delivery. Use it to check that an integration verifies and accepts deliveries. It answers 200 when we attempted the delivery right away, with the endpoint's answer, and 202 when it went to the queue. With a personal access token, the workspace's owners and admins can call this, and members on the test side. A workspace API key with this scope can.",
9088
9818
  "fields": [
9089
9819
  {
9090
9820
  "name": "endpointId",
@@ -9092,7 +9822,7 @@ var OPERATIONS = [
9092
9822
  "type": "string",
9093
9823
  "required": true,
9094
9824
  "description": "The endpoint's ID.",
9095
- "example": "we_3f0c\u2026",
9825
+ "example": "we_3f0c1a2e-4b5d-4c6e-8f70-1a2b3c4d5e6f",
9096
9826
  "schema": {
9097
9827
  "type": "string",
9098
9828
  "description": "The endpoint's ID."
@@ -9120,7 +9850,7 @@ var OPERATIONS = [
9120
9850
  "exposed": false,
9121
9851
  "reason": "Changes where workspace data is sent. A person configures webhook endpoints (Settings \u2192 Developers in the app)."
9122
9852
  },
9123
- "description": "Changes an endpoint's URL, description or event types in place. Only the fields you send change. The endpoint keeps its signing secret, so receivers keep verifying deliveries. A new URL must pass the same checks as on create. It must use HTTPS and can't be a private host. With a personal access token, only the workspace owner can call this. A workspace API key with this scope can.",
9853
+ "description": "Changes an endpoint's URL, description or event types in place. Only the fields you send change. The endpoint keeps its signing secret, so receivers keep verifying deliveries. A new URL must pass the same checks as on create. It must use HTTPS and can't be a private host. With a personal access token, the workspace's owners and admins can call this, and members on the test side. A workspace API key with this scope can.",
9124
9854
  "fields": [
9125
9855
  {
9126
9856
  "name": "endpointId",
@@ -9128,7 +9858,7 @@ var OPERATIONS = [
9128
9858
  "type": "string",
9129
9859
  "required": true,
9130
9860
  "description": "The endpoint's ID.",
9131
- "example": "we_3f0c\u2026",
9861
+ "example": "we_3f0c1a2e-4b5d-4c6e-8f70-1a2b3c4d5e6f",
9132
9862
  "schema": {
9133
9863
  "type": "string",
9134
9864
  "description": "The endpoint's ID."
@@ -9213,6 +9943,56 @@ function coveredOperations(program3) {
9213
9943
  return covered;
9214
9944
  }
9215
9945
 
9946
+ // src/flags.ts
9947
+ function kebab(name) {
9948
+ return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
9949
+ }
9950
+ function optionKey(flagName) {
9951
+ return flagName.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
9952
+ }
9953
+ function singular(word) {
9954
+ if (/[^aeiou]ies$/.test(word)) return `${word.slice(0, -3)}y`;
9955
+ if (/(ss|us|is)$/.test(word)) return word;
9956
+ if (/(x|ch|sh|ss)es$/.test(word)) return word.slice(0, -2);
9957
+ if (word.endsWith("s")) return word.slice(0, -1);
9958
+ return word;
9959
+ }
9960
+ function types(schema) {
9961
+ if (!schema) return [];
9962
+ const own = Array.isArray(schema.type) ? schema.type : schema.type ? [schema.type] : [];
9963
+ const variants = [...schema.anyOf ?? [], ...schema.oneOf ?? []];
9964
+ return [
9965
+ ...own,
9966
+ ...variants.flatMap(types),
9967
+ ...schema.nullable ? ["null"] : []
9968
+ ];
9969
+ }
9970
+ function nullable(field) {
9971
+ return types(field.schema).includes("null");
9972
+ }
9973
+ function fieldFlag(field, taken = /* @__PURE__ */ new Set()) {
9974
+ const schema = field.schema;
9975
+ const name = kebab(field.name);
9976
+ const clear = field.in === "body" && nullable(field) ? name : void 0;
9977
+ const base = { ...clear ? { clear } : {} };
9978
+ if (field.type === "boolean") return { name, kind: "boolean", ...base };
9979
+ const all = types(schema);
9980
+ const items = schema.items ?? [...schema.anyOf ?? []].find((s) => s.items)?.items;
9981
+ const itemTypes = types(items);
9982
+ const scalar = itemTypes.length > 0 && itemTypes.every((t) => ["string", "number", "integer"].includes(t));
9983
+ if (all.includes("array") && (scalar || Array.isArray(items?.enum))) {
9984
+ const words = name.split("-");
9985
+ const one = [...words.slice(0, -1), singular(words.at(-1))].join("-");
9986
+ return {
9987
+ name: one !== name && taken.has(one) ? name : one,
9988
+ kind: "list",
9989
+ ...itemTypes.every((t) => t === "number" || t === "integer") ? { numbers: true } : {},
9990
+ ...base
9991
+ };
9992
+ }
9993
+ return { name, kind: field.type === "json" ? "json" : "value", ...base };
9994
+ }
9995
+
9216
9996
  // src/generated.ts
9217
9997
  var generatedCommands = (program3, ctx) => {
9218
9998
  const groups = /* @__PURE__ */ new Set();
@@ -9228,12 +10008,10 @@ var generatedCommands = (program3, ctx) => {
9228
10008
  }
9229
10009
  };
9230
10010
  var RESERVED = /* @__PURE__ */ new Set(["json", "yes", "workspace", "data", "environment"]);
9231
- function flag(name) {
9232
- return name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
9233
- }
9234
- function optionKey(name) {
9235
- return flag(name).replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
9236
- }
10011
+ var collect = (value, previous) => [
10012
+ ...previous ?? [],
10013
+ ...value.split(",").map((part) => part.trim()).filter(Boolean)
10014
+ ];
9237
10015
  function register(program3, ctx, op, groups, hidden) {
9238
10016
  const words = op.cli.command.split(" ");
9239
10017
  const action = words.pop();
@@ -9252,22 +10030,41 @@ function register(program3, ctx, op, groups, hidden) {
9252
10030
  return;
9253
10031
  }
9254
10032
  const positional = new Set(op.cli.args);
9255
- const flags = op.fields.filter(
10033
+ const fields = op.fields.filter(
9256
10034
  (field) => !positional.has(field.name) && !RESERVED.has(field.name)
9257
10035
  );
10036
+ const names = new Set(fields.map((field) => kebab(field.name)));
10037
+ const flags = fields.map((field) => ({
10038
+ field,
10039
+ spec: fieldFlag(field, names)
10040
+ }));
9258
10041
  const command = parent.command(action, { hidden }).description(op.summary).addHelpText("after", `
9259
10042
  ${op.description}`);
9260
10043
  markOperation(command, op.operationId);
9261
- for (const arg of op.cli.args) command.argument(`<${flag(arg)}>`);
9262
- for (const field of flags) {
10044
+ for (const arg of op.cli.args) command.argument(`<${kebab(arg)}>`);
10045
+ for (const { field, spec } of flags) {
9263
10046
  const description = [
9264
10047
  field.description ?? `${field.in} field`,
10048
+ spec.kind === "list" ? "Repeat it for each value." : "",
9265
10049
  field.required ? "(required)" : ""
9266
10050
  ].filter(Boolean).join(" ");
9267
- command.option(
9268
- field.type === "boolean" ? `--${flag(field.name)}` : `--${flag(field.name)} <${field.type === "json" ? "json" : "value"}>`,
9269
- description
9270
- );
10051
+ if (spec.kind === "boolean") {
10052
+ command.option(`--${spec.name}`, description);
10053
+ command.option(`--no-${spec.name}`, `turn --${spec.name} off`);
10054
+ } else if (spec.kind === "list") {
10055
+ command.option(`--${spec.name} <value>`, description, collect);
10056
+ } else {
10057
+ command.option(
10058
+ `--${spec.name} <${spec.kind === "json" ? "json" : "value"}>`,
10059
+ description
10060
+ );
10061
+ }
10062
+ if (spec.clear) {
10063
+ command.option(`--clear-${spec.clear}`, `set ${field.name} to null`);
10064
+ }
10065
+ }
10066
+ if (op.paginated) {
10067
+ command.option("--all", "every page, not just the first");
9271
10068
  }
9272
10069
  if (op.hasBody) command.option("--data <json>", "the whole JSON body");
9273
10070
  if (op.rawBody) command.requiredOption("--file <path>", "the file to send");
@@ -9284,7 +10081,7 @@ ${op.description}`);
9284
10081
  const values = input.slice(0, op.cli.args.length);
9285
10082
  const options = input[op.cli.args.length];
9286
10083
  if (op.cli.confirm && !options.yes) {
9287
- throw new Error(
10084
+ throw new UsageError(
9288
10085
  `${op.summary} cannot be undone. Run it again with --yes to confirm.`
9289
10086
  );
9290
10087
  }
@@ -9302,62 +10099,111 @@ ${op.description}`);
9302
10099
  print(ctx, result, options.json === true);
9303
10100
  });
9304
10101
  }
9305
- function coerce(field, raw) {
9306
- if (field.type === "number") {
9307
- const n = Number(raw);
9308
- if (Number.isNaN(n))
9309
- throw new Error(`--${flag(field.name)} must be a number`);
9310
- return n;
10102
+ function number2(name, raw) {
10103
+ const n = Number(raw);
10104
+ if (raw === "" || Number.isNaN(n)) {
10105
+ throw new UsageError(`--${name} must be a number`);
10106
+ }
10107
+ return n;
10108
+ }
10109
+ function coerce({ field, spec }, raw) {
10110
+ if (spec.kind === "list") {
10111
+ const values = raw;
10112
+ return spec.numbers ? values.map((v) => number2(spec.name, v)) : values;
9311
10113
  }
10114
+ if (spec.kind === "boolean") return raw === true;
10115
+ if (field.type === "number") return number2(spec.name, raw);
9312
10116
  if (field.type === "json") {
9313
10117
  try {
9314
10118
  return JSON.parse(String(raw));
9315
10119
  } catch {
9316
- throw new Error(`--${flag(field.name)} must be JSON`);
10120
+ throw new UsageError(`--${spec.name} must be JSON`);
9317
10121
  }
9318
10122
  }
9319
10123
  return raw;
9320
10124
  }
9321
10125
  async function call2(ctx, op, args, options, flags) {
9322
- const { api: api2, token, workspace: workspace2, environment: environment2 } = ctx.credentials({
9323
- workspace: op.workspace ? options.workspace ?? void 0 : false
9324
- });
9325
- const values = (field) => field.in === "path" || op.cli.args.includes(field.name) ? args[field.name] : options[optionKey(field.name)];
9326
10126
  let whole = {};
9327
10127
  if (op.hasBody && options.data) {
9328
10128
  try {
9329
10129
  whole = JSON.parse(String(options.data));
9330
10130
  } catch {
9331
- throw new Error("--data must be a JSON object");
10131
+ throw new UsageError("--data must be a JSON object");
9332
10132
  }
9333
10133
  }
9334
10134
  const input = {};
9335
10135
  for (const field of op.fields) {
9336
- const raw2 = values(field);
9337
- if (raw2 === void 0) continue;
9338
- input[field.name] = field.in === "body" ? coerce(field, raw2) : raw2;
10136
+ if (field.in === "path" || op.cli.args.includes(field.name)) {
10137
+ if (args[field.name] !== void 0) input[field.name] = args[field.name];
10138
+ }
10139
+ }
10140
+ for (const flagged of flags) {
10141
+ const { field, spec } = flagged;
10142
+ const raw = options[optionKey(spec.name)];
10143
+ const clear = spec.clear && options[optionKey(`clear-${spec.clear}`)];
10144
+ if (clear && raw !== void 0) {
10145
+ throw new UsageError(
10146
+ `pass --${spec.name} or --clear-${spec.clear}, not both`
10147
+ );
10148
+ }
10149
+ if (clear) input[field.name] = null;
10150
+ else if (raw !== void 0) {
10151
+ input[field.name] = field.in === "body" || spec.kind !== "value" ? coerce(flagged, raw) : raw;
10152
+ }
9339
10153
  }
9340
10154
  const missing = flags.filter(
9341
- (field) => field.required && input[field.name] === void 0 && (field.in !== "body" || whole[field.name] === void 0)
10155
+ ({ field }) => field.required && input[field.name] === void 0 && (field.in !== "body" || whole[field.name] === void 0)
9342
10156
  );
9343
10157
  if (missing.length > 0) {
9344
- throw new Error(
9345
- `missing ${missing.map((f) => `--${flag(f.name)}`).join(", ")}`
10158
+ throw new UsageError(
10159
+ `missing ${missing.map(({ spec }) => `--${spec.name}`).join(", ")}`
9346
10160
  );
9347
10161
  }
9348
10162
  const problem = variantProblem(op, input, whole);
9349
- if (problem) throw new Error(problem);
9350
- const request = operationRequest(op, input, whole);
10163
+ if (problem) throw new UsageError(problem);
10164
+ const credentials = ctx.credentials({
10165
+ workspace: op.workspace ? options.workspace ?? void 0 : false
10166
+ });
10167
+ if (op.paginated && options.all === true) {
10168
+ const paged = op.fields.some(
10169
+ (f) => f.in === "query" && f.name === "cursor"
10170
+ );
10171
+ const items = [];
10172
+ let cursor = input.cursor;
10173
+ for (; ; ) {
10174
+ const page = await send(
10175
+ ctx,
10176
+ op,
10177
+ credentials,
10178
+ operationRequest(op, { ...input, cursor }, whole),
10179
+ options
10180
+ );
10181
+ items.push(...page.items);
10182
+ if (!paged || typeof page.nextCursor !== "string") break;
10183
+ cursor = page.nextCursor;
10184
+ }
10185
+ return { items, nextCursor: null };
10186
+ }
10187
+ return send(
10188
+ ctx,
10189
+ op,
10190
+ credentials,
10191
+ operationRequest(op, input, whole),
10192
+ options
10193
+ );
10194
+ }
10195
+ async function send(ctx, op, credentials, request, options) {
10196
+ const { baseURL, token, workspace: workspace2, environment: environment3 } = credentials;
9351
10197
  const headers = {
9352
10198
  authorization: `Bearer ${token}`
9353
10199
  };
9354
10200
  if (workspace2) headers["x-workspace"] = workspace2;
9355
- if (environment2) headers["x-environment"] = environment2;
10201
+ if (environment3) headers["x-environment"] = environment3;
9356
10202
  if (request.body) headers["content-type"] = "application/json";
9357
10203
  const raw = op.rawBody ? readFileSync3(String(options.file)) : void 0;
9358
10204
  if (op.rawBody) headers["content-type"] = op.rawBody;
9359
10205
  const response = await ctx.fetch(
9360
- new Request(`${api2}/v1${request.path}`, {
10206
+ new Request(`${baseURL}/v1${request.path}`, {
9361
10207
  method: request.method,
9362
10208
  headers,
9363
10209
  ...request.body ? { body: JSON.stringify(request.body) } : {},
@@ -9368,16 +10214,13 @@ async function call2(ctx, op, args, options, flags) {
9368
10214
  return new Uint8Array(await response.arrayBuffer());
9369
10215
  }
9370
10216
  const text = await response.text();
9371
- const data = text ? JSON.parse(text) : null;
9372
- if (!response.ok) {
9373
- const error = data?.error;
9374
- throw new ApiError(
9375
- response.status,
9376
- error?.code ?? "internal_error",
9377
- error?.message ?? `HTTP ${response.status}`,
9378
- error?.requestId
9379
- );
10217
+ let data = null;
10218
+ try {
10219
+ data = text ? JSON.parse(text) : null;
10220
+ } catch {
10221
+ if (response.ok) throw new Error("the API's answer is not JSON");
9380
10222
  }
10223
+ if (!response.ok) throw apiErrorFrom(data, response);
9381
10224
  return data;
9382
10225
  }
9383
10226
  function scalarColumns(rows) {
@@ -9402,7 +10245,9 @@ function print(ctx, data, asJson) {
9402
10245
  rows.length === 0 ? "No results." : table(rows, scalarColumns(rows))
9403
10246
  );
9404
10247
  if (typeof page.nextCursor === "string") {
9405
- ctx.io.stdout(`More: --cursor ${page.nextCursor}`);
10248
+ ctx.io.stdout(
10249
+ `More: --cursor ${page.nextCursor}, or --all for every page`
10250
+ );
9406
10251
  }
9407
10252
  return;
9408
10253
  }
@@ -9424,14 +10269,21 @@ function variantProblem(op, input, whole) {
9424
10269
  const chosen = String(input[key] ?? whole[key]);
9425
10270
  const needs = op.variants.required[chosen];
9426
10271
  if (!needs) {
9427
- return `--${flag(key)} must be one of ${Object.keys(op.variants.required).join(", ")}`;
10272
+ return `--${kebab(key)} must be one of ${Object.keys(op.variants.required).join(", ")}`;
9428
10273
  }
9429
10274
  const absent = needs.filter(
9430
10275
  (name) => input[name] === void 0 && whole[name] === void 0
9431
10276
  );
9432
- return absent.length > 0 ? `missing ${absent.map((name) => `--${flag(name)}`).join(", ")} (needed with --${flag(key)} ${chosen})` : void 0;
10277
+ return absent.length > 0 ? `missing ${absent.map((name) => `--${kebab(name)}`).join(", ")} (needed with --${kebab(key)} ${chosen})` : void 0;
9433
10278
  }
9434
10279
 
10280
+ // src/product/index.ts
10281
+ var product_exports2 = {};
10282
+ __export(product_exports2, {
10283
+ productCommands: () => productCommands,
10284
+ productErrorHint: () => productErrorHint
10285
+ });
10286
+
9435
10287
  // src/product/files.ts
9436
10288
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
9437
10289
  import { basename, dirname, join as join2, resolve, sep } from "node:path";
@@ -9451,7 +10303,7 @@ async function uploadPath(ctx, path2, workspace2) {
9451
10303
  });
9452
10304
  }
9453
10305
  async function downloadBytes(ctx, id, workspace2) {
9454
- const result = await ctx.client({ workspace: workspace2 }).GET("/files/{fileId}/download", {
10306
+ const result = await ctx.client({ workspace: workspace2 }).GET("/files/{fileId}/content", {
9455
10307
  params: { path: { fileId: id } },
9456
10308
  parseAs: "arrayBuffer"
9457
10309
  });
@@ -10287,7 +11139,16 @@ function parse(toml, options = {}) {
10287
11139
  var HAS_WELLFORMED = !!"".isWellFormed;
10288
11140
 
10289
11141
  // src/internal/domain/product/detect.ts
11142
+ var READS_ARGUMENTS = {
11143
+ python: /\bsys\.argv\b|\bargparse\b|^\s*(?:import|from)\s+(?:click|typer)\b/m,
11144
+ node: /\bprocess\.argv\b|\bparseArgs\b/,
11145
+ shell: /\$\{?[1-9@*#]|\bgetopts\b/
11146
+ };
11147
+ function readsArguments(kind, code2) {
11148
+ return READS_ARGUMENTS[kind].test(code2);
11149
+ }
10290
11150
  var SCRIPT = /\.(py|js|mjs|cjs|ts|mts|sh)$/i;
11151
+ var isScriptFile = (path2) => SCRIPT.test(path2);
10291
11152
  var NOT_A_SCRIPT = /(\.config\.|^setup\.py$|^conftest\.py$|\.d\.ts$|\.test\.|_test\.py$|^test_)/i;
10292
11153
  var HELP = 'Pass --command "\u2026" (for example --command "python report.py {month}"), add a reminix.json, or ask your agent to write one.';
10293
11154
  function slugOf(name) {
@@ -10721,7 +11582,7 @@ Nothing was uploaded (--dry-run).`
10721
11582
  if (options.number !== void 0) {
10722
11583
  const version2 = Number(options.number);
10723
11584
  if (!Number.isInteger(version2) || version2 < 1) {
10724
- throw new Error("--number: a version's number, like --number 3");
11585
+ throw new UsageError("--number: a version's number, like --number 3");
10725
11586
  }
10726
11587
  const script2 = await call3(
10727
11588
  "POST",
@@ -10732,7 +11593,7 @@ Nothing was uploaded (--dry-run).`
10732
11593
  slug: manifest.slug,
10733
11594
  version: { version: version2 },
10734
11595
  script: script2,
10735
- line: approveUrl2 ? `Publishing ${manifest.slug} version ${version2} waits for a person's approval: ${approveUrl2}` : `Published ${manifest.slug} version ${version2}.`
11596
+ line: approveUrl2 ? `Publishing ${manifest.slug} version ${version2} waits for a person's approval: ${approveUrl2}` : published(ctx, manifest.slug, version2)
10736
11597
  };
10737
11598
  }
10738
11599
  const version = await call3("POST", `/v1/scripts/${slug}/versions`, {
@@ -10753,10 +11614,37 @@ Nothing was uploaded (--dry-run).`
10753
11614
  });
10754
11615
  const script = null;
10755
11616
  const approveUrl = version.approval?.approveUrl ?? null;
10756
- const line = approveUrl ? `Uploaded ${manifest.slug} version ${version.version}; publishing waits for a person's approval: ${approveUrl}` : mode === "upload" ? `Uploaded ${manifest.slug} version ${version.version} as a draft. Test it with \`${brand.name} run ${manifest.slug} --number ${version.version}\`, then publish it in the app or with \`${brand.name} publish --number ${version.version}\`.` : `Published ${manifest.slug} version ${version.version}.`;
11617
+ const line = approveUrl ? `Uploaded ${manifest.slug} version ${version.version}; publishing waits for a person's approval: ${approveUrl}` : mode === "upload" ? `Uploaded ${manifest.slug} version ${version.version} as a draft. Test it with \`${brand.name} run ${manifest.slug} --number ${version.version}\`, then publish it in the app or with \`${brand.name} publish --number ${version.version}\`.` : published(ctx, manifest.slug, version.version);
10757
11618
  const found = detected ? `${describeDetected(manifest, detected)}
10758
11619
  ` : "";
10759
- return { slug: manifest.slug, version, script, line: `${found}${line}` };
11620
+ const hint = inputsHint(dir, manifest, detected);
11621
+ return {
11622
+ slug: manifest.slug,
11623
+ version,
11624
+ script,
11625
+ line: `${found}${line}${hint ? `
11626
+ ${hint}` : ""}`
11627
+ };
11628
+ }
11629
+ function inputsHint(dir, manifest, detected) {
11630
+ if (!detected || manifest.inputSchema !== void 0) return null;
11631
+ if (detected.command.includes("{") || !isScriptFile(detected.source)) {
11632
+ return null;
11633
+ }
11634
+ const code2 = localFolder(dir, [detected.source]).read(detected.source);
11635
+ if (code2 === null || !readsArguments(detected.kind, code2)) return null;
11636
+ return [
11637
+ "",
11638
+ `${detected.source} reads command-line arguments, but this script has no inputs yet, so its form has no fields.`,
11639
+ `To add a field, put its name in braces at the end of the command, then publish again:`,
11640
+ ` ${brand.name} init "${detected.command} {input}"`,
11641
+ ` ${brand.name} publish`,
11642
+ `Inputs: https://${brand.domain}/docs/scripts/#customizing-with-reminixjson`
11643
+ ].join("\n");
11644
+ }
11645
+ function published(ctx, slug, version) {
11646
+ const web = webOriginFor(ctx.settings().baseURL);
11647
+ return web ? `Published ${slug} version ${version}: ${web}/scripts/${encodeURIComponent(slug)}` : `Published ${slug} version ${version}.`;
10760
11648
  }
10761
11649
  var definePublish = (mode) => (command, ctx) => defineFolderOptions(
10762
11650
  mode === "publish" ? covers(
@@ -10794,7 +11682,9 @@ subfolder that is one: \`${brand.name} ${mode} scripts/\` does them all.`
10794
11682
  if (!options.json) ctx.io.stderr(`Skipped ${dir}: no script in it`);
10795
11683
  }
10796
11684
  if (options.number !== void 0 && folders.length + missing.length !== 1) {
10797
- throw new Error("--number publishes one script: name one folder");
11685
+ throw new UsageError(
11686
+ "--number publishes one script: name one folder"
11687
+ );
10798
11688
  }
10799
11689
  if (folders.length === 1 && missing.length === 0) {
10800
11690
  const result = await publishFolder(ctx, folders[0], options, mode);
@@ -10834,11 +11724,29 @@ subfolder that is one: \`${brand.name} ${mode} scripts/\` does them all.`
10834
11724
  }
10835
11725
  }
10836
11726
  );
10837
- var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions.testRun").option("--input <json>", "the inputs, as a JSON object", "{}").option(
11727
+ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions.testRun").option(
11728
+ "-f, --raw-field <name=value>",
11729
+ "an input, as a string (repeat it for several)",
11730
+ (value, all) => [...all, value],
11731
+ []
11732
+ ).option(
11733
+ "-F, --field <name=value>",
11734
+ "an input, typed: a number, true, false, null or JSON (repeat it for several)",
11735
+ (value, all) => [...all, value],
11736
+ []
11737
+ ).option(
11738
+ "--input-file <path>",
11739
+ "the inputs as a JSON object, from a file (- reads standard input)"
11740
+ ).option(
10838
11741
  "--file <input=path>",
10839
11742
  "upload a file as a file input (repeat it for several)",
10840
11743
  (value, all) => [...all, value],
10841
11744
  []
11745
+ ).option(
11746
+ "--text <input=path>",
11747
+ "set a text input to a file's contents, lines and all (- reads standard input)",
11748
+ (value, all) => [...all, value],
11749
+ []
10842
11750
  ).option(
10843
11751
  "--out <dir>",
10844
11752
  "download the files the run saves into this folder (else their links are printed)"
@@ -10850,21 +11758,16 @@ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions
10850
11758
  "answer at once with a run awaiting approval or still running, instead of following it"
10851
11759
  ).option("--workspace <slug>", "act in this workspace for one call").option("--json", "print the whole run, not just its output").action(
10852
11760
  async (slug, options) => {
10853
- let inputs;
10854
- try {
10855
- inputs = JSON.parse(options.input);
10856
- } catch (error) {
10857
- throw new Error(
10858
- `--input: not valid JSON (${error.message})`,
10859
- {
10860
- cause: error
10861
- }
10862
- );
10863
- }
10864
- if (inputs === null || typeof inputs !== "object" || Array.isArray(inputs)) {
10865
- throw new Error(
10866
- `--input: must be a JSON object, e.g. '{"orderId":"o_1"}'`
10867
- );
11761
+ const inputs = await inputsOf(ctx, options);
11762
+ for (const spec of options.text) {
11763
+ const at = spec.indexOf("=");
11764
+ if (at <= 0 || at === spec.length - 1) {
11765
+ throw new UsageError(
11766
+ `--text: input=path, e.g. --text message=./reply.txt (got "${spec}")`
11767
+ );
11768
+ }
11769
+ const path2 = spec.slice(at + 1);
11770
+ inputs[spec.slice(0, at)] = path2 === "-" ? await ctx.io.stdin() : readFileSync5(path2, "utf8");
10868
11771
  }
10869
11772
  const call3 = (method, path2, body) => rawRequest(ctx, { method, path: path2, body, workspace: options.workspace });
10870
11773
  if (options.file.length > 0) {
@@ -10872,7 +11775,7 @@ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions
10872
11775
  for (const spec of options.file) {
10873
11776
  const at = spec.indexOf("=");
10874
11777
  if (at <= 0 || at === spec.length - 1) {
10875
- throw new Error(
11778
+ throw new UsageError(
10876
11779
  `--file: input=path, e.g. --file statement=./sept.pdf (got "${spec}")`
10877
11780
  );
10878
11781
  }
@@ -10891,7 +11794,7 @@ var defineRun = (command, ctx) => covers(command, "runs.create", "scriptVersions
10891
11794
  }
10892
11795
  }
10893
11796
  if (options.number !== void 0 && !/^[1-9]\d*$/.test(options.number)) {
10894
- throw new Error("--number: a version's number, like --number 2");
11797
+ throw new UsageError("--number: a version's number, like --number 2");
10895
11798
  }
10896
11799
  let run3 = await call3(
10897
11800
  "POST",
@@ -10985,6 +11888,51 @@ var scriptCommands = (program3, ctx) => {
10985
11888
  `Run a script and print its output. Use --number to test a draft. Short for ${brand.name} scripts run`
10986
11889
  );
10987
11890
  };
11891
+ async function inputsOf(ctx, options) {
11892
+ let inputs = {};
11893
+ if (options.inputFile !== void 0) {
11894
+ const text = options.inputFile === "-" ? await ctx.io.stdin() : readFileSync5(options.inputFile, "utf8");
11895
+ let parsed;
11896
+ try {
11897
+ parsed = JSON.parse(text);
11898
+ } catch (error) {
11899
+ throw new UsageError(
11900
+ `--input-file: not valid JSON (${error.message})`
11901
+ );
11902
+ }
11903
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
11904
+ throw new UsageError(
11905
+ '--input-file: must hold a JSON object, e.g. {"orderId": "o_1"}'
11906
+ );
11907
+ }
11908
+ inputs = parsed;
11909
+ }
11910
+ const split = (flag, spec) => {
11911
+ const at = spec.indexOf("=");
11912
+ if (at <= 0) {
11913
+ throw new UsageError(
11914
+ `${flag}: name=value, e.g. ${flag} orderId=o_1 (got "${spec}")`
11915
+ );
11916
+ }
11917
+ return [spec.slice(0, at), spec.slice(at + 1)];
11918
+ };
11919
+ for (const spec of options.field) {
11920
+ const [name, value] = split("-F", spec);
11921
+ inputs[name] = typed(value);
11922
+ }
11923
+ for (const spec of options.rawField) {
11924
+ const [name, value] = split("-f", spec);
11925
+ inputs[name] = value;
11926
+ }
11927
+ return inputs;
11928
+ }
11929
+ function typed(value) {
11930
+ try {
11931
+ return JSON.parse(value);
11932
+ } catch {
11933
+ return value;
11934
+ }
11935
+ }
10988
11936
 
10989
11937
  // src/product/init.ts
10990
11938
  import { closeSync as closeSync2, openSync as openSync2, unlinkSync, writeFileSync as writeFileSync5 } from "node:fs";
@@ -11096,34 +12044,81 @@ var initCommand = (program3, ctx) => {
11096
12044
  // src/product/secrets.ts
11097
12045
  var secretCommands = (program3, ctx) => {
11098
12046
  const group = program3.commands.find((c) => c.name() === "secrets") ?? program3.command("secrets").description("secrets commands");
11099
- group.command("set <name>").description("Save a secret's value, read from stdin").requiredOption(
11100
- "--hosts <hosts>",
11101
- "the hosts it may be sent to, comma-separated (e.g. api.stripe.com)"
11102
- ).option(
11103
- "--allow-env-var",
11104
- "let scripts read the value as an environment variable (off by default)"
11105
- ).option("--workspace <slug>", "act in this workspace for one call").option("--json", "machine-readable output").action(
12047
+ covers(
12048
+ group.command("set <name>").description("Save a secret's value, read from stdin").requiredOption(
12049
+ "--hosts <hosts>",
12050
+ "the hosts it may be sent to, comma-separated (e.g. api.stripe.com)"
12051
+ ).option(
12052
+ "--allow-env-var",
12053
+ "let scripts read the value as an environment variable (off for a new secret)"
12054
+ ).option(
12055
+ "--no-allow-env-var",
12056
+ "attach the value to requests only, never as an environment variable"
12057
+ ).option("--workspace <slug>", "act in this workspace for one call").option("--json", "machine-readable output"),
12058
+ "secretValues.set",
12059
+ "secrets.update"
12060
+ ).action(
11106
12061
  async (name, options) => {
11107
- const value = (await ctx.io.stdin()).replace(/\r?\n$/, "");
11108
- if (!value) {
11109
- throw new Error(
11110
- `Pipe the value in, e.g. printf %s "$VALUE" | ${brand.name} secrets set ${name} --hosts \u2026`
11111
- );
12062
+ const value = await readValue(ctx, name);
12063
+ const environment3 = await environmentOf(ctx, options.workspace);
12064
+ let secret = await saveValue(ctx, name, environment3, value, options);
12065
+ if (options.allowEnvVar !== void 0) {
12066
+ secret = await rawRequest(ctx, {
12067
+ method: "PATCH",
12068
+ path: `/v1/secrets/${encodeURIComponent(name)}`,
12069
+ body: { allowEnvVar: options.allowEnvVar },
12070
+ workspace: options.workspace
12071
+ });
11112
12072
  }
11113
- const secret = await rawRequest(ctx, {
11114
- method: "PUT",
11115
- path: `/v1/secrets/${encodeURIComponent(name)}`,
11116
- body: {
11117
- value,
11118
- hosts: options.hosts.split(",").map((h) => h.trim()).filter(Boolean),
11119
- allowEnvVar: options.allowEnvVar ?? false
11120
- },
11121
- workspace: options.workspace
11122
- });
11123
- ctx.io.stdout(options.json ? json(secret) : `Saved ${name}.`);
12073
+ ctx.io.stdout(
12074
+ options.json ? json(secret) : `Saved ${name} in ${environment3}.`
12075
+ );
11124
12076
  }
11125
12077
  );
11126
12078
  };
12079
+ async function readValue(ctx, name) {
12080
+ const value = (await ctx.io.stdin()).replace(/\r?\n$/, "");
12081
+ if (!value) {
12082
+ throw new Error(
12083
+ `Pipe the value in, e.g. printf %s "$VALUE" | ${brand.name} secrets set ${name} --hosts \u2026`
12084
+ );
12085
+ }
12086
+ return value;
12087
+ }
12088
+ async function saveValue(ctx, name, environment3, value, options) {
12089
+ return rawRequest(ctx, {
12090
+ method: "PUT",
12091
+ path: `/v1/secrets/${encodeURIComponent(name)}/values/${encodeURIComponent(environment3)}`,
12092
+ body: {
12093
+ value,
12094
+ hosts: options.hosts.split(",").map((h) => h.trim()).filter(Boolean)
12095
+ },
12096
+ workspace: options.workspace
12097
+ });
12098
+ }
12099
+ async function environmentOf(ctx, workspace2) {
12100
+ const chosen = ctx.credentials({ workspace: workspace2 }).environment;
12101
+ if (chosen) return chosen;
12102
+ const environments = await rawRequest(ctx, {
12103
+ method: "GET",
12104
+ path: "/v1/environments?limit=100",
12105
+ workspace: workspace2
12106
+ });
12107
+ const fallback = environments.items.find((e) => e.isDefault);
12108
+ if (!fallback) throw new Error("This workspace has no default environment.");
12109
+ return fallback.name;
12110
+ }
12111
+
12112
+ // src/product/access.ts
12113
+ function productErrorHint(error) {
12114
+ if (error.code !== "forbidden") return null;
12115
+ const scope = /not granted the ([a-z_]+:[a-z]+) scope/.exec(
12116
+ error.message
12117
+ )?.[1];
12118
+ if (!scope) return null;
12119
+ const choice = /^(scripts|runs):/.test(scope) ? "Publish and run scripts" : "Full access";
12120
+ return `Sign in again with \`${brand.name} login\` and choose ${choice}.`;
12121
+ }
11127
12122
 
11128
12123
  // src/product/index.ts
11129
12124
  var productCommands = [
@@ -11144,15 +12139,18 @@ var commands = [
11144
12139
  function tokenEnvVar() {
11145
12140
  return `${brand.identifier.toUpperCase()}_TOKEN`;
11146
12141
  }
12142
+ var VERSION2 = "1.0.0-rc.16";
11147
12143
  function build(io) {
11148
12144
  let actedIn = null;
11149
12145
  let sending;
11150
- const program3 = new Command().name(brand.name).description(`The ${brand.productName} CLI`).version("1.0.0-rc.13").addHelpText(
12146
+ const program3 = new Command().name(brand.name).description(`The ${brand.productName} CLI`).version(VERSION2).addHelpText(
11151
12147
  "after",
11152
12148
  `
11153
12149
  Token: \`${brand.name} login\` stores it in ~/.config/${brand.name}/; ${tokenEnvVar()} overrides.
11154
- Environment: --environment, else ${environmentEnvVar()}, else \`${brand.name} environment use\`, else the default.`
11155
- ).option(
12150
+ Environment: --environment, else ${environmentEnvVar()}, else \`${brand.name} environment use\`, else the default.
12151
+ API: --base-url, else ${baseURLEnvVar()}, else the one \`${brand.name} login --base-url\` saved.
12152
+ Exit codes: 0 success, 1 failure, 2 wrong usage, 4 not logged in.`
12153
+ ).option("--base-url <url>", "the API's origin, without /v1").option(
11156
12154
  "--environment <name>",
11157
12155
  "act in this environment (where the product has them)"
11158
12156
  ).option(
@@ -11164,13 +12162,15 @@ Environment: --environment, else ${environmentEnvVar()}, else \`${brand.name} en
11164
12162
  }).showHelpAfterError();
11165
12163
  const ctx = {
11166
12164
  io,
11167
- settings: () => resolveSettings(io.env, io.homeDir, {
11168
- environment: program3.opts().environment
11169
- }),
12165
+ settings: () => resolveSettings(
12166
+ io.env,
12167
+ io.homeDir,
12168
+ program3.opts()
12169
+ ),
11170
12170
  credentials: (options = {}) => {
11171
12171
  const settings = ctx.settings();
11172
12172
  if (!settings.token) {
11173
- throw new Error(
12173
+ throw new NotLoggedInError(
11174
12174
  `not logged in. Run \`${brand.name} login\` or set ${tokenEnvVar()}.`
11175
12175
  );
11176
12176
  }
@@ -11181,7 +12181,7 @@ Environment: --environment, else ${environmentEnvVar()}, else \`${brand.name} en
11181
12181
  );
11182
12182
  }
11183
12183
  return {
11184
- api: settings.api,
12184
+ baseURL: settings.baseURL,
11185
12185
  token: settings.token,
11186
12186
  workspace: void 0,
11187
12187
  environment: settings.environment
@@ -11194,7 +12194,7 @@ Environment: --environment, else ${environmentEnvVar()}, else \`${brand.name} en
11194
12194
  );
11195
12195
  }
11196
12196
  return {
11197
- api: settings.api,
12197
+ baseURL: settings.baseURL,
11198
12198
  token: settings.token,
11199
12199
  workspace: workspace2,
11200
12200
  environment: settings.environment
@@ -11208,7 +12208,7 @@ Environment: --environment, else ${environmentEnvVar()}, else \`${brand.name} en
11208
12208
  maxRetries: 0
11209
12209
  })
11210
12210
  ),
11211
- fetch: (request) => {
12211
+ fetch: async (request) => {
11212
12212
  sending ??= withRetries(
11213
12213
  async (attempt) => {
11214
12214
  const response = await io.fetch(attempt);
@@ -11221,7 +12221,14 @@ Environment: --environment, else ${environmentEnvVar()}, else \`${brand.name} en
11221
12221
  )
11222
12222
  }
11223
12223
  );
11224
- return sending(request);
12224
+ const headers = new Headers(request.headers);
12225
+ headers.set("user-agent", `${brand.name}-cli/${VERSION2}`);
12226
+ const named = new Request(request, { headers });
12227
+ try {
12228
+ return await sending(named);
12229
+ } catch (error) {
12230
+ throw connectionErrorFrom(error, request.signal);
12231
+ }
11225
12232
  }
11226
12233
  };
11227
12234
  for (const register2 of commands) register2(program3, ctx);
@@ -11231,35 +12238,67 @@ async function run2(argv, io) {
11231
12238
  const { program: program3, actedIn } = build(io);
11232
12239
  try {
11233
12240
  await program3.parseAsync(argv, { from: "user" });
11234
- const environment2 = actedIn();
11235
- if (environment2) io.stderr(`Environment: ${environment2}`);
11236
- return 0;
12241
+ const environment3 = actedIn();
12242
+ if (environment3) io.stderr(`Environment: ${environment3}`);
12243
+ return EXIT.ok;
11237
12244
  } catch (error) {
11238
- const environment2 = actedIn();
11239
- if (error instanceof CommanderError) return error.exitCode;
12245
+ const environment3 = actedIn();
12246
+ if (error instanceof CommanderError) {
12247
+ return error.exitCode === 0 ? EXIT.ok : EXIT.usage;
12248
+ }
12249
+ const code2 = exitCode(error);
11240
12250
  if (argv.includes("--json")) {
11241
12251
  io.stderr(
11242
12252
  JSON.stringify({
11243
- error: error instanceof ApiError ? {
12253
+ error: error instanceof APIError ? {
11244
12254
  code: error.code,
11245
12255
  message: error.message,
11246
12256
  status: error.status,
11247
- ...error.requestId ? { requestId: error.requestId } : {}
11248
- } : { code: "cli_error", message: error.message },
11249
- ...environment2 ? { environment: environment2 } : {}
12257
+ ...error.requestId ? { requestId: error.requestId } : {},
12258
+ ...error.docs ? { docs: error.docs } : {},
12259
+ ...error.details ? { details: error.details } : {}
12260
+ } : {
12261
+ code: code2 === EXIT.usage ? "usage_error" : code2 === EXIT.auth ? "not_logged_in" : "cli_error",
12262
+ message: error.message
12263
+ },
12264
+ ...environment3 ? { environment: environment3 } : {}
11250
12265
  })
11251
12266
  );
11252
- return 1;
12267
+ return code2;
11253
12268
  }
11254
- if (error instanceof ApiError) {
12269
+ if (error instanceof APIError) {
11255
12270
  const requestId = error.requestId ? ` [request ${error.requestId}]` : "";
11256
12271
  io.stderr(`${brand.name}: ${error.message} (${error.code})${requestId}`);
12272
+ for (const detail of error.details ?? []) {
12273
+ io.stderr(
12274
+ ` ${detail.path ? `${detail.path}: ` : ""}${detail.message}`
12275
+ );
12276
+ }
12277
+ const hint = scopeHint(error);
12278
+ if (hint) io.stderr(hint);
12279
+ if (error.docs) io.stderr(`See ${error.docs}`);
11257
12280
  } else {
11258
- io.stderr(`${brand.name}: ${error.message}`);
12281
+ const cause = error instanceof APIConnectionError && error.cause instanceof Error ? ` (${error.cause.message})` : "";
12282
+ io.stderr(`${brand.name}: ${error.message}${cause}`);
11259
12283
  }
11260
- if (environment2) io.stderr(`Environment: ${environment2}`);
11261
- return 1;
12284
+ if (environment3) io.stderr(`Environment: ${environment3}`);
12285
+ return code2;
12286
+ }
12287
+ }
12288
+ function exitCode(error) {
12289
+ if (error instanceof AuthenticationError || error?.cause instanceof AuthenticationError) {
12290
+ return EXIT.auth;
11262
12291
  }
12292
+ const own = error?.exitCode;
12293
+ return typeof own === "number" && !(error instanceof APIError) ? own : EXIT.failure;
12294
+ }
12295
+ function scopeHint(error) {
12296
+ const own = Reflect.get(product_exports2, "productErrorHint");
12297
+ const mine = own?.(error);
12298
+ if (mine) return mine;
12299
+ const scope = /not granted the ([\w.:-]+) scope/.exec(error.message)?.[1];
12300
+ if (error.code !== "forbidden" || !scope) return null;
12301
+ return `Sign in again with \`${brand.name} login\` and choose access that includes ${scope}.`;
11263
12302
  }
11264
12303
 
11265
12304
  // src/main.ts