@uru-intelligence/cli 0.4.19 → 0.5.1

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/uru.mjs CHANGED
@@ -233,6 +233,7 @@ function buildGemOperations(op) {
233
233
  op("gem.git_source_import", "gems", "Import an inspected exact Git commit as a Git-backed Gem.", "gem_control_plane", "git_source_import", "write"),
234
234
  op("gem.git_source_status", "gems", "Read Git source binding, policy, import, preview, and allowed-action state for a Gem.", "gem_query", "git_source_status", "read"),
235
235
  op("gem.git_source_command", "gems", "Apply a bounded Git source command such as refresh, retry, policy change, publish, or preview approval.", "gem_control_plane", "git_source_command", "write"),
236
+ op("gem.git_source_copy", "gems", "Make a new, unlinked, editable Gem from a GitHub-linked Gem's latest saved Version. The copy carries no Links, secrets, tool grants, schedules or Git binding.", "gem_control_plane", "git_source_copy", "write"),
236
237
  op("gem.git_source_preview_inspect", "gems", "Inspect the exact preview head and resource policy before approval.", "gem_query", "git_source_preview_inspect", "read"),
237
238
  op("gem.git_source_preview_open", "gems", "Mint an authenticated URL for a ready Git source preview.", "gem_query", "git_source_preview_open", "read"),
238
239
  op("gem.inspect", "gems", "Inspect Gem release readiness, bindings, secrets, and setup checks. Thumbnail image bytes are omitted by default; pass include_thumbnail=true to include them.", "gem_query", "inspect", "read"),
@@ -259,10 +260,11 @@ function buildGemOperations(op) {
259
260
  op("gem.version_save", "gems", "Save Current as a frozen Version without changing Links.", "gem_control_plane", "version_save", "write"),
260
261
  op("gem.version_restore", "gems", "Restore one Version into Current as a new Edit without changing Links.", "gem_control_plane", "version_restore", "write"),
261
262
  op("gem.version_preview", "gems", "Open or provision an isolated preview for one Version without changing Links.", "gem_control_plane", "version_preview", "write"),
263
+ op("gem.version_retry", "gems", "Re-queue the build of a Version that failed and never sealed a Build, keeping the same Version identity and source snapshot. Available for every Gem, whether its source is Uru or GitHub. Only a failed Version qualifies, and a build already in flight is refused.", "gem_control_plane", "version_retry", "write"),
262
264
  op("gem.build_logs", "gems", "Read build diagnostics for a Gem build.", "gem_query", "build_logs", "read"),
263
265
  op("gem.build_job", "gems", "Read hosted compile status by hosted_job_id. Reports queued, pending, running, succeeded, failed, or expired, plus build_id when a durable Build was persisted, plus compact logs and failure_kind.", "gem_query", "build_job", "read"),
264
266
  op("gem.build_inspect", "gems", "Inspect a Gem runtime contract and release overview.", "gem_query", "build_inspect", "read"),
265
- op("gem.upsert_binding", "gems", "Bind a declared Gem need to an approved platform resource.", "gem_control_plane", "upsert_binding", "write"),
267
+ op("gem.upsert_binding", "gems", "Bind a declared Gem need to an approved platform resource. A generic tool target uses the exact unique visible wrapper and unchanged plain subtool as target_resource_ref. A tool role may also use the expected binding-set version and hash with a complete binding_choices map of opaque connection_ref values read from gem.inspect. A Gem has one set of tool bindings: its preview builds and its releases use it alike.", "gem_control_plane", "upsert_binding", "write"),
266
268
  op("gem.resolve_safe_bindings", "gems", "Resolve deterministic safe bindings for a ready Gem build.", "gem_control_plane", "resolve_safe_bindings", "write"),
267
269
  op("gem.store_secret", "gems", "Store a user-supplied Gem secret value server-side.", "gem_control_plane", "store_secret", "write"),
268
270
  op("gem.releases_list", "gems", "List logical hosted Releases.", "gem_query", "releases_list", "read"),
@@ -272,6 +274,7 @@ function buildGemOperations(op) {
272
274
  op("gem.status", "gems", "Read Gem deployment status, checks, runtime runs, and recent logs.", "gem_query", "deployment_status", "read"),
273
275
  op("gem.checks", "gems", "Inspect registered checks for a Gem deployment or immutable version.", "gem_query", "checks", "read"),
274
276
  op("gem.logs", "gems", "Read server-side Gem runtime logs with filters.", "gem_query", "logs", "read"),
277
+ op("gem.debug_token", "gems", "Mint a short-lived, single-deployment debug session for live Gem inspection.", "gem_control_plane", "debug_token", "write"),
275
278
  op("gem.browser_verify", "gems", "Run browser verification for a Gem deployment.", "gem_control_plane", "browser_verify", "write"),
276
279
  op("gem.security_scan", "gems", "Run a Gem security scan.", "gem_control_plane", "security_scan", "write"),
277
280
  op("gem.links_list", "gems", "List published links for a Gem.", "gem_query", "links_list", "read"),
@@ -296,6 +299,9 @@ function buildGemOperations(op) {
296
299
  op("gem.schedule_pause", "gems", "Pause one declared Gem job schedule.", "gem_control_plane", "schedule_pause", "write"),
297
300
  op("gem.schedule_resume", "gems", "Resume one declared Gem job schedule.", "gem_control_plane", "schedule_resume", "write"),
298
301
  op("gem.schedule_run_now", "gems", "Run one active Gem job schedule now.", "gem_control_plane", "schedule_run_now", "write"),
302
+ op("gem.event_targets_list", "gems", "List a Gem's event rules that start jobs from reported platform events.", "gem_query", "event_targets_list", "read"),
303
+ op("gem.event_target_update", "gems", "Update one Gem event rule's paused state or job input.", "gem_control_plane", "event_target_update", "write"),
304
+ op("gem.event_target_run_now", "gems", "Run one active Gem event rule now.", "gem_control_plane", "event_target_run_now", "write"),
299
305
  op("gem.analytics", "gems", "Read access-checked Link view summaries and run-ledger totals for a Gem without returning customer content.", "gem_query", "get_gem_analytics", "read"),
300
306
  op("gem.domains_set", "gems", "Attach or update a custom domain for a Gem. Pass the hostname only; " + "the current Release is resolved for you. Requires a ready Release.", "gem_control_plane", "domains_set", "write"),
301
307
  op("gem.domains_list", "gems", "List custom domains for a Gem.", "gem_query", "domains_list", "read"),
@@ -332,6 +338,18 @@ function buildOperationGroups(op) {
332
338
  op("library.empty_trash", "library", "Permanently empty Library trash.", "library_fs", "empty_trash", "destructive"),
333
339
  op("library.favorite", "library", "Add a visible Library item to the caller's favorites.", "library_fs", "favorite", "write"),
334
340
  op("library.unfavorite", "library", "Remove a visible Library item from the caller's favorites.", "library_fs", "unfavorite", "write"),
341
+ op("library.sources_list", "library", "List the caller’s connected Library sources.", "library_external_sources_query", "list", "read"),
342
+ op("library.sources_get", "library", "Inspect one connected Library source and its mirrored items.", "library_external_sources_query", "get", "read"),
343
+ op("library.sources_create", "library", "Connect Google Drive files or folders to the Library.", "library_external_sources", "create", "write"),
344
+ op("library.sources_edit", "library", "Change a connected Library source schedule or enable state.", "library_external_sources", "edit", "write"),
345
+ op("library.sources_pause", "library", "Pause a connected Library source.", "library_external_sources", "pause", "write"),
346
+ op("library.sources_resume", "library", "Resume a paused Library source.", "library_external_sources", "resume", "write"),
347
+ op("library.sources_run_now", "library", "Run a connected Library source sync now.", "library_external_sources", "run_now", "write"),
348
+ op("library.sources_cancel", "library", "Cancel the active sync for a connected Library source.", "library_external_sources", "cancel", "write"),
349
+ op("library.sources_reconnect", "library", "Reconnect a source after its Google Drive access expires.", "library_external_sources", "reconnect", "write"),
350
+ op("library.sources_remove", "library", "Remove a connected source and move confirmed mirrors to Library trash.", "library_external_sources", "remove", "destructive"),
351
+ op("library.history_list", "library", "List immutable history for an authorized Library resource.", "library_history", "list", "read"),
352
+ op("library.history_get", "library", "Read one immutable history revision for an authorized Library resource.", "library_history", "get", "read"),
335
353
  op("library.upload_preflight", "library", "Preflight a Library upload.", "library_upload", "preflight", "read"),
336
354
  op("library.upload_create_session", "library", "Create a direct Library upload session.", "library_upload", "create_session", "write"),
337
355
  op("library.upload_complete_session", "library", "Complete a direct Library upload session.", "library_upload", "complete_session", "write")
@@ -378,6 +396,10 @@ function buildOperationGroups(op) {
378
396
  op("dataset.create", "datasets", "Create a typed Dataset.", "dataset_manage", "create", "write"),
379
397
  op("dataset.update", "datasets", "Update Dataset metadata and schema.", "dataset_manage", "update", "write"),
380
398
  op("dataset.get", "datasets", "Read Dataset metadata and stable property identities.", "dataset_get", undefined, "read"),
399
+ op("dataset.external_source_get", "datasets", "Read the external source binding for a Dataset.", "dataset_external_source_get", undefined, "read"),
400
+ op("dataset.external_source_put", "datasets", "Create or update the external source binding for a Dataset.", "dataset_external_source_put", undefined, "write"),
401
+ op("dataset.external_source_test", "datasets", "Test a Dataset external source connection and query preview.", "dataset_external_source_test", undefined, "read"),
402
+ op("dataset.external_source_sync", "datasets", "Start a one-shot refresh from a Dataset external source.", "dataset_external_source_sync", undefined, "write"),
381
403
  op("dataset.query", "datasets", "Query Dataset rows with filters, search, sorting, pages, totals, and aggregates.", "dataset_query", undefined, "read"),
382
404
  op("dataset.history", "datasets", "List Dataset change history.", "dataset_history", undefined, "read"),
383
405
  op("dataset.rows_upsert", "datasets", "Insert or update Dataset rows.", "dataset_rows", "upsert", "write"),
@@ -858,6 +880,84 @@ var cliNativeOperationContracts = [
858
880
  function getCliNativeOperationContract(operationId) {
859
881
  return cliNativeOperationContracts.find((contract) => contract.operationId === operationId);
860
882
  }
883
+ // ../../packages/platform-operations/src/narrow_tool_input_schema.ts
884
+ function narrowToolInputSchemaToOperation(inputSchema, backendOp) {
885
+ if (backendOp === undefined) {
886
+ return inputSchema;
887
+ }
888
+ const union = unionBranchesOf(inputSchema);
889
+ if (union === undefined) {
890
+ return withoutOpKey(inputSchema);
891
+ }
892
+ const keptBranches = union.branches.filter((branch) => branchDeclaresOp(branch, backendOp)).map(withoutOpKey);
893
+ if (keptBranches.length === 0) {
894
+ return withoutOpKey(inputSchema);
895
+ }
896
+ if (keptBranches.length === 1) {
897
+ return withCarriedOverShape(keptBranches[0], inputSchema);
898
+ }
899
+ return { type: "object", oneOf: keptBranches };
900
+ }
901
+ function isSchemaObject(value) {
902
+ return typeof value === "object" && value !== null && !Array.isArray(value);
903
+ }
904
+ function unionBranchesOf(schema) {
905
+ for (const key of ["oneOf", "anyOf"]) {
906
+ const candidate = schema[key];
907
+ if (Array.isArray(candidate)) {
908
+ return { branches: candidate.filter(isSchemaObject) };
909
+ }
910
+ }
911
+ return;
912
+ }
913
+ function branchDeclaresOp(branch, backendOp) {
914
+ const properties = branch["properties"];
915
+ if (!isSchemaObject(properties)) {
916
+ return false;
917
+ }
918
+ const opSchema = properties["op"];
919
+ if (!isSchemaObject(opSchema)) {
920
+ return false;
921
+ }
922
+ if (opSchema["const"] === backendOp) {
923
+ return true;
924
+ }
925
+ const enumValues = opSchema["enum"];
926
+ return Array.isArray(enumValues) && enumValues.includes(backendOp);
927
+ }
928
+ function withoutOpKey(schema) {
929
+ const properties = schema["properties"];
930
+ const required = schema["required"];
931
+ const hasOpProperty = isSchemaObject(properties) && "op" in properties;
932
+ const hasOpRequired = Array.isArray(required) && required.includes("op");
933
+ if (!hasOpProperty && !hasOpRequired) {
934
+ return schema;
935
+ }
936
+ const next = { ...schema };
937
+ if (hasOpProperty) {
938
+ const { op: _op, ...restProperties } = properties;
939
+ next["properties"] = restProperties;
940
+ }
941
+ if (hasOpRequired) {
942
+ next["required"] = required.filter((value) => value !== "op");
943
+ }
944
+ return next;
945
+ }
946
+ function withCarriedOverShape(branch, unionSchema) {
947
+ const missingType = branch["type"] === undefined;
948
+ const missingDescription = branch["description"] === undefined && unionSchema["description"] !== undefined;
949
+ if (!missingType && !missingDescription) {
950
+ return branch;
951
+ }
952
+ const next = { ...branch };
953
+ if (missingType) {
954
+ next["type"] = unionSchema["type"] ?? "object";
955
+ }
956
+ if (missingDescription) {
957
+ next["description"] = unionSchema["description"];
958
+ }
959
+ return next;
960
+ }
861
961
  // ../../packages/platform-operations/src/internal_tool_ids.ts
862
962
  var internalOnlyPlatformToolIds = new Set([
863
963
  "CFO_NEWSLETTER_SQL",
@@ -1722,6 +1822,7 @@ var cliCommandPathSpecs = [
1722
1822
  pathSpec(["gems", "runs"], "gems"),
1723
1823
  pathSpec(["gems", "capabilities"], "gems"),
1724
1824
  pathSpec(["gems", "schedules"], "gems"),
1825
+ pathSpec(["gems", "events"], "gems"),
1725
1826
  pathSpec(["gems", "bindings"], "gems"),
1726
1827
  pathSpec(["gems", "api"], "gems"),
1727
1828
  pathSpec(["gems", "components"], "gems"),
@@ -1739,7 +1840,7 @@ function datasetPathSpecs() {
1739
1840
  const datasetId = [required("dataset-id")];
1740
1841
  const pageFlags = [valueFlag("--limit"), valueFlag("--cursor")];
1741
1842
  return [
1742
- pathSpec(["datasets"], "datasets", [optional("operation")], [paramsJsonFlag()], { dynamicFamily: "datasets" }),
1843
+ pathSpec(["datasets"], "datasets", [optional("operation")], [paramsJsonFlag(), booleanFlag("--get-schema")], { dynamicFamily: "datasets" }),
1743
1844
  pathSpec(["datasets", "create"], "datasets", [], [paramsJsonFlag()]),
1744
1845
  pathSpec(["datasets", "update"], "datasets", [], [paramsJsonFlag()]),
1745
1846
  pathSpec(["datasets", "rows"], "datasets", [], [paramsJsonFlag()]),
@@ -1755,6 +1856,36 @@ function datasetPathSpecs() {
1755
1856
  valueFlag("--version-id")
1756
1857
  ]),
1757
1858
  pathSpec(["datasets", "jobs"], "datasets", datasetId, pageFlags),
1859
+ pathSpec(["datasets", "jobs", "get"], "datasets", [
1860
+ required("dataset-id"),
1861
+ required("job-id")
1862
+ ]),
1863
+ pathSpec(["datasets", "jobs", "cancel"], "datasets", [
1864
+ required("dataset-id"),
1865
+ required("job-id")
1866
+ ]),
1867
+ pathSpec(["datasets", "source"], "datasets", [optional("operation")], [
1868
+ paramsJsonFlag(),
1869
+ valueFlag("--idempotency-key")
1870
+ ]),
1871
+ pathSpec(["datasets", "source", "get"], "datasets", datasetId, [], {
1872
+ aliases: [["datasets", "source", "inspect"]]
1873
+ }),
1874
+ pathSpec(["datasets", "source", "put"], "datasets", datasetId, [paramsJsonFlag()], {
1875
+ aliases: [
1876
+ ["datasets", "source", "edit"],
1877
+ ["datasets", "source", "connect"],
1878
+ ["datasets", "source", "create"],
1879
+ ["datasets", "source", "reconnect"]
1880
+ ]
1881
+ }),
1882
+ pathSpec(["datasets", "source", "test"], "datasets", datasetId, [paramsJsonFlag()]),
1883
+ pathSpec(["datasets", "source", "pause"], "datasets", datasetId),
1884
+ pathSpec(["datasets", "source", "resume"], "datasets", datasetId),
1885
+ pathSpec(["datasets", "source", "sync"], "datasets", datasetId, [
1886
+ paramsJsonFlag(),
1887
+ valueFlag("--idempotency-key")
1888
+ ], { aliases: [["datasets", "source", "run-now"]] }),
1758
1889
  pathSpec(["datasets", "query"], "datasets", datasetId, [
1759
1890
  paramsJsonFlag(),
1760
1891
  ...pageFlags,
@@ -1777,7 +1908,7 @@ function distributionPathSpecs() {
1777
1908
  paramsJsonFlag()
1778
1909
  ];
1779
1910
  return [
1780
- pathSpec(["distribution"], "distribution", [optional("operation")], [paramsJsonFlag()], { dynamicFamily: "distribution" }),
1911
+ pathSpec(["distribution"], "distribution", [optional("operation")], [paramsJsonFlag(), booleanFlag("--get-schema")], { dynamicFamily: "distribution" }),
1781
1912
  pathSpec(["distribution", "list"], "distribution", [], pageFlags, {
1782
1913
  aliases: [["distribution", "ls"]]
1783
1914
  }),
@@ -1826,6 +1957,58 @@ function distributionPathSpecs() {
1826
1957
  }
1827
1958
  function libraryPathSpecs() {
1828
1959
  return [
1960
+ pathSpec(["library", "source"], "library", [optional("operation")], [paramsJsonFlag(), valueFlag("--limit"), valueFlag("--cursor"), booleanFlag("--yes")], { aliases: [["library", "sources"]] }),
1961
+ pathSpec(["library", "source", "list"], "library", [], [], { aliases: [["library", "source", "ls"], ["library", "sources", "list"], ["library", "sources", "ls"]] }),
1962
+ pathSpec(["library", "source", "get"], "library", [required("source-id")], [], {
1963
+ aliases: [
1964
+ ["library", "source", "inspect"],
1965
+ ["library", "sources", "get"],
1966
+ ["library", "sources", "inspect"]
1967
+ ]
1968
+ }),
1969
+ pathSpec(["library", "source", "create"], "library", [], [paramsJsonFlag()], {
1970
+ aliases: [
1971
+ ["library", "source", "connect"],
1972
+ ["library", "sources", "create"],
1973
+ ["library", "sources", "connect"]
1974
+ ]
1975
+ }),
1976
+ pathSpec(["library", "source", "edit"], "library", [required("source-id")], [paramsJsonFlag()], {
1977
+ aliases: [
1978
+ ["library", "source", "set"],
1979
+ ["library", "sources", "edit"],
1980
+ ["library", "sources", "set"]
1981
+ ]
1982
+ }),
1983
+ pathSpec(["library", "source", "pause"], "library", [required("source-id")], [], { aliases: [["library", "sources", "pause"]] }),
1984
+ pathSpec(["library", "source", "resume"], "library", [required("source-id")], [], { aliases: [["library", "sources", "resume"]] }),
1985
+ pathSpec(["library", "source", "run-now"], "library", [required("source-id")], [], {
1986
+ aliases: [
1987
+ ["library", "source", "run"],
1988
+ ["library", "source", "sync"],
1989
+ ["library", "sources", "run-now"],
1990
+ ["library", "sources", "run"],
1991
+ ["library", "sources", "sync"]
1992
+ ]
1993
+ }),
1994
+ pathSpec(["library", "source", "cancel"], "library", [required("source-id")], [], { aliases: [["library", "sources", "cancel"]] }),
1995
+ pathSpec(["library", "source", "reconnect"], "library", [required("source-id")], [paramsJsonFlag()], { aliases: [["library", "sources", "reconnect"]] }),
1996
+ pathSpec(["library", "source", "remove"], "library", [required("source-id")], [booleanFlag("--yes")], {
1997
+ aliases: [
1998
+ ["library", "source", "rm"],
1999
+ ["library", "source", "delete"],
2000
+ ["library", "sources", "remove"],
2001
+ ["library", "sources", "rm"],
2002
+ ["library", "sources", "delete"]
2003
+ ]
2004
+ }),
2005
+ pathSpec(["library", "history"], "library", [required("resource-type"), required("resource-id")], [valueFlag("--limit"), valueFlag("--cursor")]),
2006
+ pathSpec(["library", "history", "get"], "library", [required("resource-type"), required("resource-id"), required("revision")], [], {
2007
+ aliases: [
2008
+ ["library", "history", "inspect"],
2009
+ ["library", "history", "show"]
2010
+ ]
2011
+ }),
1829
2012
  pathSpec(["library", "ls"], "library", [optional("path")], [valueFlag("--limit"), valueFlag("--offset")]),
1830
2013
  pathSpec(["library", "stat"], "library", [required("path")]),
1831
2014
  pathSpec(["library", "search"], "library", [required("query")], [valueFlag("--limit"), valueFlag("--offset")]),
@@ -1973,15 +2156,19 @@ function topLevelPathSpecs() {
1973
2156
  pathSpec(["diff"], "diff", [optional("gem-path")], [valueFlag("--gem"), valueFlag("--mode"), valueFlag("--path")]),
1974
2157
  pathSpec(["push"], "push", [optional("gem-path")], [booleanFlag("--force"), ...gemRefFlags]),
1975
2158
  pathSpec(["logs"], "logs", [optional("gem-path")], [
2159
+ valueFlag("--cursor"),
2160
+ valueFlag("--export"),
1976
2161
  valueFlag("--follow-duration-ms"),
1977
2162
  booleanFlag("--follow"),
1978
2163
  valueFlag("--gem"),
1979
2164
  valueFlag("--level"),
1980
2165
  valueFlag("--limit"),
1981
2166
  valueFlag("--path"),
1982
- valueFlag("--poll-interval-ms"),
1983
2167
  valueFlag("--release"),
1984
- valueFlag("--run")
2168
+ valueFlag("--run"),
2169
+ valueFlag("--request-id"),
2170
+ valueFlag("--since"),
2171
+ valueFlag("--until")
1985
2172
  ]),
1986
2173
  pathSpec(["open"], "open", [optional("gem-path")], [valueFlag("--gem"), valueFlag("--link"), valueFlag("--path")]),
1987
2174
  pathSpec(["gems"], "gems"),
@@ -2113,14 +2300,23 @@ function gemPathSpecs() {
2113
2300
  enumFlag("--checks", ["quick", "full"])
2114
2301
  ]),
2115
2302
  pathSpec(["gems", "checks"], "gems", [required("version"), optional("gem")], gemRefFlags),
2303
+ pathSpec(["gems", "debug-token"], "gems", [optional("gem")], [
2304
+ valueFlag("--deployment"),
2305
+ valueFlag("--ttl-seconds"),
2306
+ ...gemRefFlags
2307
+ ]),
2116
2308
  pathSpec(["gems", "logs"], "gems", [optional("gem")], [
2309
+ valueFlag("--cursor"),
2310
+ valueFlag("--export"),
2117
2311
  valueFlag("--follow-duration-ms"),
2118
2312
  booleanFlag("--follow"),
2119
2313
  valueFlag("--level"),
2120
2314
  valueFlag("--release"),
2121
2315
  valueFlag("--run"),
2316
+ valueFlag("--request-id"),
2317
+ valueFlag("--since"),
2318
+ valueFlag("--until"),
2122
2319
  valueFlag("--limit"),
2123
- valueFlag("--poll-interval-ms"),
2124
2320
  ...gemRefFlags
2125
2321
  ]),
2126
2322
  pathSpec(["gems", "status"], "gems", [optional("gem")], gemRefFlags),
@@ -2163,6 +2359,7 @@ function gemPathSpecs() {
2163
2359
  pathSpec(["gems", "versions", "diff"], "gems", [required("from-version"), required("to-version"), optional("gem")], gemRefFlags),
2164
2360
  pathSpec(["gems", "versions", "restore"], "gems", [required("version"), optional("gem")], gemRefFlags),
2165
2361
  pathSpec(["gems", "versions", "preview"], "gems", [required("version"), optional("gem")], gemRefFlags),
2362
+ pathSpec(["gems", "versions", "retry"], "gems", [required("version"), optional("gem")], gemRefFlags),
2166
2363
  pathSpec(["gems", "edits", "list"], "gems", [optional("gem")], [
2167
2364
  valueFlag("--cursor"),
2168
2365
  valueFlag("--gem"),
@@ -2211,10 +2408,12 @@ function gemPathSpecs() {
2211
2408
  pathSpec(["gems", "links", "revoke"], "gems", [required("link"), optional("gem")], [...gemRefFlags, valueFlag("--idempotency-key")]),
2212
2409
  pathSpec(["gems", "runs", "list"], "gems", [optional("gem")], [
2213
2410
  valueFlag("--cursor"),
2411
+ valueFlag("--environment"),
2214
2412
  valueFlag("--gem"),
2215
2413
  valueFlag("--limit"),
2216
2414
  valueFlag("--path"),
2217
- valueFlag("--status")
2415
+ valueFlag("--status"),
2416
+ valueFlag("--version")
2218
2417
  ]),
2219
2418
  pathSpec(["gems", "runs", "show"], "gems", [required("run"), optional("gem")], gemRefFlags),
2220
2419
  pathSpec(["gems", "runs", "cancel"], "gems", [required("run"), optional("gem")], [...gemRefFlags, booleanFlag("--yes")]),
@@ -2236,6 +2435,12 @@ function gemPathSpecs() {
2236
2435
  pathSpec(["gems", "schedules", "pause"], "gems", [required("capability"), optional("gem")], gemRefFlags),
2237
2436
  pathSpec(["gems", "schedules", "resume"], "gems", [required("capability"), optional("gem")], gemRefFlags),
2238
2437
  pathSpec(["gems", "schedules", "run"], "gems", [required("capability"), optional("gem")], [...gemRefFlags, valueFlag("--idempotency-key")]),
2438
+ pathSpec(["gems", "events", "list"], "gems", [optional("gem")], gemRefFlags),
2439
+ pathSpec(["gems", "events", "update"], "gems", [required("target-id"), optional("gem")], [...gemRefFlags, valueFlag("--state"), valueFlag("--input-json")]),
2440
+ pathSpec(["gems", "events", "pause"], "gems", [required("target-id"), optional("gem")], gemRefFlags),
2441
+ pathSpec(["gems", "events", "resume"], "gems", [required("target-id"), optional("gem")], gemRefFlags),
2442
+ pathSpec(["gems", "events", "run"], "gems", [required("target-id"), optional("gem")], [...gemRefFlags, valueFlag("--idempotency-key")]),
2443
+ pathSpec(["gems", "events", "run-now"], "gems", [required("target-id"), optional("gem")], [...gemRefFlags, valueFlag("--idempotency-key")]),
2239
2444
  pathSpec(["gems", "domains", "list"], "gems", [optional("gem")], [...gemRefFlags, valueFlag("--limit")]),
2240
2445
  pathSpec(["gems", "domains", "set"], "gems", [required("hostname"), optional("gem")], gemRefFlags),
2241
2446
  pathSpec(["gems", "domains", "check"], "gems", [required("domain-id"), optional("gem")], gemRefFlags),
@@ -2278,11 +2483,11 @@ function gemPathSpecs() {
2278
2483
  valueFlag("--target-resource-type"),
2279
2484
  valueFlag("--target-resource-id"),
2280
2485
  valueFlag("--target-resource-ref"),
2281
- valueFlag("--tool-connection-id"),
2282
- valueFlag("--tool-capability-id"),
2283
- valueFlag("--environment-key"),
2284
2486
  valueFlag("--binding-status"),
2285
- valueFlag("--policy-level")
2487
+ valueFlag("--policy-level"),
2488
+ valueFlag("--binding-choices"),
2489
+ valueFlag("--expected-binding-set-version"),
2490
+ valueFlag("--expected-binding-set-hash")
2286
2491
  ]),
2287
2492
  pathSpec(["gems", "bindings", "resolve"], "gems", [optional("gem")], [...gemRefFlags, valueFlag("--build")]),
2288
2493
  pathSpec(["gems", "api", "describe"], "gems", [optional("gem")], [...gemRefFlags, valueFlag("--build"), valueFlag("--deployment")]),
@@ -2372,21 +2577,12 @@ function tokenEnvSecretPathSpecs() {
2372
2577
  }
2373
2578
  function registryFamilyPathSpecs() {
2374
2579
  return [
2375
- pathSpec(["workspace"], "workspace", [optional("operation")], [paramsJsonFlag()], { dynamicFamily: "workspace" }),
2376
- pathSpec(["sharing"], "sharing", [optional("operation")], [paramsJsonFlag()], {
2377
- dynamicFamily: "sharing"
2378
- }),
2379
- pathSpec(["web"], "web", [optional("operation")], [paramsJsonFlag()], {
2380
- dynamicFamily: "web"
2381
- }),
2382
- pathSpec(["files"], "files", [optional("operation")], [paramsJsonFlag()], {
2383
- aliases: [["file"]],
2384
- dynamicFamily: "files"
2385
- }),
2386
- pathSpec(["home"], "home", [optional("operation")], [paramsJsonFlag()], {
2387
- dynamicFamily: "home"
2388
- }),
2389
- pathSpec(["business-sql"], "business_sql", [optional("operation")], [paramsJsonFlag()], { aliases: [["business_sql"]], dynamicFamily: "business_sql" })
2580
+ pathSpec(["workspace"], "workspace", [optional("operation")], [paramsJsonFlag(), booleanFlag("--get-schema")], { dynamicFamily: "workspace" }),
2581
+ pathSpec(["sharing"], "sharing", [optional("operation")], [paramsJsonFlag(), booleanFlag("--get-schema")], { dynamicFamily: "sharing" }),
2582
+ pathSpec(["web"], "web", [optional("operation")], [paramsJsonFlag(), booleanFlag("--get-schema")], { dynamicFamily: "web" }),
2583
+ pathSpec(["files"], "files", [optional("operation")], [paramsJsonFlag(), booleanFlag("--get-schema")], { aliases: [["file"]], dynamicFamily: "files" }),
2584
+ pathSpec(["home"], "home", [optional("operation")], [paramsJsonFlag(), booleanFlag("--get-schema")], { dynamicFamily: "home" }),
2585
+ pathSpec(["business-sql"], "business_sql", [optional("operation")], [paramsJsonFlag(), booleanFlag("--get-schema")], { aliases: [["business_sql"]], dynamicFamily: "business_sql" })
2390
2586
  ];
2391
2587
  }
2392
2588
  var commandPathSpecsByPath = new Map;
@@ -2646,7 +2842,7 @@ var cliRootHelpGroups = [
2646
2842
  {
2647
2843
  command: "logs",
2648
2844
  lines: [
2649
- " uru logs [library/name.gem] [--limit 100] [--follow]",
2845
+ " uru logs [library/name.gem] [--limit 100] [--follow] [--export <file>]",
2650
2846
  " Runtime logs"
2651
2847
  ]
2652
2848
  },
@@ -2671,18 +2867,19 @@ var cliRootHelpGroups = [
2671
2867
  " uru gems edits list|show [library/name.gem]",
2672
2868
  ' uru gems versions save|upload [library/name.gem] [--name "..."] [--message "..."]',
2673
2869
  " uru gems versions deploy [library/name.gem] <version>",
2674
- " uru gems versions list|show|diff|restore|preview [library/name.gem]",
2870
+ " uru gems versions list|show|diff|restore|preview|retry [library/name.gem]",
2675
2871
  " uru gems releases list|show|create|retry [library/name.gem]",
2676
2872
  " create takes a positional <version>, not --version",
2677
2873
  " uru gems links list|create|set-version|promote|rollback|set-access|set-notifications|rotate|revoke",
2678
2874
  " uru gems runs list|show|cancel [library/name.gem]",
2679
2875
  " uru gems capabilities list|enable|disable [library/name.gem]",
2680
2876
  " uru gems schedules list|arm|pause|resume|run [library/name.gem]",
2877
+ " uru gems events list|update|pause|resume|run [library/name.gem]",
2681
2878
  " uru gems api describe|query|action|job [library/name.gem]",
2682
2879
  " uru gems domains list|set|check|delete [library/name.gem]",
2683
2880
  " uru gems analytics [library/name.gem] [--link <id>] [--limit <n>]",
2684
2881
  " uru gems power stop|start|restart [library/name.gem]",
2685
- " uru gems logs [library/name.gem] [--release <id>|--run <id>]",
2882
+ " uru gems logs [library/name.gem] [--release <id>|--run <id>] [--follow] [--export <file>]",
2686
2883
  " uru gems read <library/name.gem> <file>",
2687
2884
  " uru gems write <library/name.gem> <file> --file ./local.html"
2688
2885
  ]
@@ -2698,6 +2895,12 @@ var cliRootHelpGroups = [
2698
2895
  " uru library ls [path] List Library items",
2699
2896
  " uru library stat <path> Read Library item metadata",
2700
2897
  " uru library search <query> Search Library items",
2898
+ " uru library source list|get|inspect Manage connected Library sources",
2899
+ " uru library source create --params-json Create a source",
2900
+ " uru library source edit <id> --params-json Edit a source",
2901
+ " uru library source pause|resume|run-now|cancel <id>",
2902
+ " uru library source reconnect <id> --params-json Restore Drive access",
2903
+ " uru library history <type> <id> Read Library history",
2701
2904
  " uru library mkdir <path> Create a Library folder",
2702
2905
  " uru library read <path> Print a text-backed Library resource",
2703
2906
  " uru library write <path> --file ./note.md --create [--folder-id <id>]",
@@ -2717,6 +2920,10 @@ var cliRootHelpGroups = [
2717
2920
  lines: [
2718
2921
  " uru datasets ls [path] List Datasets in the Library",
2719
2922
  " uru datasets get|inspect|history|jobs|query <dataset-id>",
2923
+ " uru datasets source get|inspect <dataset-id> Inspect the source binding",
2924
+ " uru datasets source put|edit|connect|create|reconnect|test <dataset-id> --params-json {...}",
2925
+ " uru datasets source pause|resume|sync|run-now <dataset-id>",
2926
+ " uru datasets jobs get|cancel <dataset-id> <job-id>",
2720
2927
  " uru datasets create|update|rows|restore|sql|sql-write --params-json {...}",
2721
2928
  " Use the canonical Dataset tools"
2722
2929
  ]
@@ -2854,7 +3061,7 @@ function spec(id, summary, auth, workspace, safety, outputModes, cancellation =
2854
3061
  // package.json
2855
3062
  var package_default = {
2856
3063
  name: "@uru-intelligence/cli",
2857
- version: "0.4.19",
3064
+ version: "0.5.1",
2858
3065
  private: false,
2859
3066
  description: "Uru full-platform command line interface",
2860
3067
  repository: {
@@ -8960,6 +9167,17 @@ var zAppJobRun = object({
8960
9167
  inputSummary: record(string2(), unknown()).nullish(),
8961
9168
  jobKey: string2().nullish(),
8962
9169
  lastStatusAt: string2().nullish(),
9170
+ latestAttempt: object({
9171
+ attemptNumber: number2(),
9172
+ error: record(string2(), unknown()),
9173
+ hasCheckpoint: boolean2(),
9174
+ id: string2(),
9175
+ progress: record(string2(), unknown()),
9176
+ startedAt: string2(),
9177
+ status: string2(),
9178
+ stoppedAt: string2().nullable(),
9179
+ updatedAt: string2()
9180
+ }).nullish(),
8963
9181
  maxAttempts: number2().nullish(),
8964
9182
  metadata: record(string2(), unknown()).nullish(),
8965
9183
  nextRetryAt: string2().nullish(),
@@ -8998,6 +9216,10 @@ var zAppLogRecord = object({
8998
9216
  status: string2().nullish(),
8999
9217
  workspaceId: string2()
9000
9218
  });
9219
+ var zAppLogPage = object({
9220
+ logs: array(zAppLogRecord),
9221
+ nextCursor: string2().nullable()
9222
+ });
9001
9223
  var zAppPublishCheck = object({
9002
9224
  artifactId: string2(),
9003
9225
  checkKey: string2().nullish(),
@@ -9078,9 +9300,7 @@ var zAppResourceBindingUpsertRequest = object({
9078
9300
  "job",
9079
9301
  "endpoint",
9080
9302
  "storage"
9081
- ]),
9082
- toolCapabilityId: uuid2().nullish(),
9083
- toolConnectionId: string2().nullish()
9303
+ ])
9084
9304
  });
9085
9305
  var zAppRouteManifestRecord = object({
9086
9306
  accessPolicy: string2(),
@@ -9133,6 +9353,10 @@ var zAppRuntimeInvocationResponse = object({
9133
9353
  state: string2(),
9134
9354
  status: string2()
9135
9355
  });
9356
+ var zAppRuntimeLogStoreStatus = object({
9357
+ availability: _enum(["available", "not_configured", "unavailable"]),
9358
+ code: string2().nullish()
9359
+ });
9136
9360
  var zAppRuntimePowerAction = _enum(["stop", "start", "restart"]);
9137
9361
  var zAppRuntimePowerRequest = object({
9138
9362
  action: zAppRuntimePowerAction
@@ -9210,6 +9434,7 @@ var zAppReleaseOverview = object({
9210
9434
  environments: array(zAppEnvironment),
9211
9435
  jobRuns: array(zAppJobRun).optional(),
9212
9436
  linkTargets: array(zAppReleaseLinkTarget).optional(),
9437
+ logStoreStatus: zAppRuntimeLogStoreStatus.optional(),
9213
9438
  logs: array(zAppLogRecord),
9214
9439
  providerDeployments: array(zAppRuntimeProviderDeployment).optional(),
9215
9440
  providerReadiness: record(string2(), zAppRuntimeProviderReadinessReport).nullish(),
@@ -9218,8 +9443,7 @@ var zAppReleaseOverview = object({
9218
9443
  runtimeProfile: record(string2(), unknown()).nullable()
9219
9444
  });
9220
9445
  var zAppSafeBindingResolveRequest = object({
9221
- buildId: string2().min(1),
9222
- environmentKey: _enum(["preview", "release"]).optional().default("release")
9446
+ buildId: string2().min(1)
9223
9447
  });
9224
9448
  var zAppSafeBindingResolveResponse = object({
9225
9449
  artifactId: string2(),
@@ -9246,7 +9470,6 @@ var zAppSecretMetadata = object({
9246
9470
  workspaceId: string2()
9247
9471
  });
9248
9472
  var zAppSecretValueUpsertRequest = object({
9249
- environmentKey: _enum(["preview", "release"]).optional().default("release"),
9250
9473
  metadata: record(string2(), unknown()).optional().default({}),
9251
9474
  secretName: string2().min(1).max(128),
9252
9475
  secretValue: string2().min(1)
@@ -9335,6 +9558,38 @@ var zAppSupportBundleResponse = object({
9335
9558
  bundle: record(string2(), unknown()),
9336
9559
  record: zAppSupportBundleRecord
9337
9560
  });
9561
+ var zAppUploadCompleteResponse = object({
9562
+ cleanupFailed: boolean2(),
9563
+ contentType: string2(),
9564
+ filename: string2(),
9565
+ outcome: _enum([
9566
+ "verified",
9567
+ "pending",
9568
+ "absent",
9569
+ "expired",
9570
+ "unverifiable",
9571
+ "size_mismatch",
9572
+ "type_mismatch"
9573
+ ]),
9574
+ sizeBytes: number2().nullable(),
9575
+ state: _enum(["granted", "verified", "rejected", "expired"]),
9576
+ uploadId: string2()
9577
+ });
9578
+ var zAppUploadGrantRequest = strictObject({
9579
+ contentType: string2().min(3).max(255),
9580
+ filename: string2().min(1).max(255),
9581
+ sizeBytes: int().gte(1).lte(104857600)
9582
+ });
9583
+ var zAppUploadGrantResponse = object({
9584
+ contentType: string2(),
9585
+ expiresAt: string2(),
9586
+ filename: string2(),
9587
+ method: _enum(["PUT"]),
9588
+ requiredHeaders: record(string2(), string2()),
9589
+ sizeBytes: number2(),
9590
+ uploadId: string2(),
9591
+ uploadUrl: string2()
9592
+ });
9338
9593
  var zArtifactAiMessage = object({
9339
9594
  content: union([
9340
9595
  record(string2(), unknown()),
@@ -9378,6 +9633,15 @@ var zArtifactBuildDiagnostic = object({
9378
9633
  rawDiagnosticId: string2().nullish(),
9379
9634
  relatedLocations: array(zArtifactBuildDiagnosticLocation).optional().default([])
9380
9635
  });
9636
+ var zArtifactBuildJob = object({
9637
+ attempts: int().optional().default(0),
9638
+ createdAt: string2().nullish(),
9639
+ id: string2(),
9640
+ lastError: string2().nullish(),
9641
+ leaseExpiresAt: string2().nullish(),
9642
+ status: string2(),
9643
+ updatedAt: string2().nullish()
9644
+ }).nullable();
9381
9645
  var zArtifactBuildRequest = object({
9382
9646
  content: string2().nullish(),
9383
9647
  currentSourceRevisionId: string2().nullish(),
@@ -9588,6 +9852,7 @@ var zArtifactBuildDescriptor = object({
9588
9852
  assets: record(string2(), zArtifactFileDescriptor).optional(),
9589
9853
  buildDiagnostics: array(zArtifactBuildDiagnostic).optional().default([]),
9590
9854
  buildErrors: array(string2()).optional().default([]),
9855
+ buildJob: zArtifactBuildJob.optional(),
9591
9856
  buildPipelineVersion: string2().nullish(),
9592
9857
  buildStatus: string2().nullish(),
9593
9858
  bundleStatus: string2().nullish(),
@@ -10128,6 +10393,9 @@ var zClientIdMetadataDocument = object({
10128
10393
  scope: string2().min(1),
10129
10394
  token_endpoint_auth_method: _enum(["none"])
10130
10395
  });
10396
+ var zCloneArtifactRequest = object({
10397
+ sourceRevisionId: uuid2().optional()
10398
+ });
10131
10399
  var zCollectionGateAccessResponse = object({
10132
10400
  accessToken: string2(),
10133
10401
  expiresAt: string2(),
@@ -10658,6 +10926,13 @@ var zDebugEntityResponse = object({
10658
10926
  entityId: string2(),
10659
10927
  userId: string2()
10660
10928
  });
10929
+ var zDeleteGemVersionResponse = strictObject({
10930
+ deleted: literal(true),
10931
+ linksChanged: literal(false),
10932
+ sourceRevisionId: string2(),
10933
+ versionId: string2(),
10934
+ versionNumber: int()
10935
+ });
10661
10936
  var zDeleteNotificationsRequest = object({
10662
10937
  notificationIds: array(uuid2())
10663
10938
  });
@@ -10957,11 +11232,16 @@ var zGemEditsPage = strictObject({
10957
11232
  edits: array(zGemEdit),
10958
11233
  nextCursor: string2().nullable()
10959
11234
  });
11235
+ var zGemGitSourceBindingError = strictObject({
11236
+ at: exports_iso.datetime({ offset: true }),
11237
+ code: string2().min(1).max(128),
11238
+ message: string2().min(1).max(512)
11239
+ }).nullable();
10960
11240
  var zGemGitSourceCallbackRequest = strictObject({
10961
11241
  code: string2().min(1).max(2048).optional(),
10962
- installationId: string2().regex(/^[1-9][0-9]{0,19}$\/u/).optional(),
11242
+ installationId: string2().regex(/^[1-9][0-9]{0,19}$/).optional(),
10963
11243
  setupAction: _enum(["install", "update", "request"]).optional(),
10964
- state: string2().regex(/^[A-Za-z0-9_-]{43}$\/u/)
11244
+ state: string2().regex(/^[A-Za-z0-9_-]{43}$/)
10965
11245
  });
10966
11246
  var zGemGitSourceCommand = union([
10967
11247
  strictObject({
@@ -10969,7 +11249,7 @@ var zGemGitSourceCommand = union([
10969
11249
  }),
10970
11250
  strictObject({
10971
11251
  action: _enum(["retry"]),
10972
- idempotencyKey: string2().min(1).max(200).regex(/^[A-Za-z0-9._:-]+$\/u/),
11252
+ idempotencyKey: string2().min(1).max(200).regex(/^[A-Za-z0-9._:-]+$/),
10973
11253
  importId: uuid2()
10974
11254
  }),
10975
11255
  strictObject({
@@ -10989,14 +11269,14 @@ var zGemGitSourceCommand = union([
10989
11269
  }),
10990
11270
  strictObject({
10991
11271
  action: _enum(["create_branch_preview"]),
10992
- commitSha: string2().regex(/^[0-9a-f]{40}$\/iu/),
11272
+ commitSha: string2().regex(/^[0-9a-fA-F]{40}$/),
10993
11273
  ref: string2().min(1).max(512)
10994
11274
  }),
10995
11275
  strictObject({
10996
11276
  action: _enum(["approve_preview"]),
10997
- headSha: string2().regex(/^[0-9a-f]{40}$\/iu/),
11277
+ headSha: string2().regex(/^[0-9a-fA-F]{40}$/),
10998
11278
  previewId: uuid2(),
10999
- resourcePolicyHash: string2().regex(/^[0-9a-f]{64}$\/iu/)
11279
+ resourcePolicyHash: string2().regex(/^[0-9a-fA-F]{64}$/)
11000
11280
  }),
11001
11281
  strictObject({
11002
11282
  action: _enum(["expire_preview"]),
@@ -11013,7 +11293,7 @@ var zGemGitSourceCommand = union([
11013
11293
  strictObject({
11014
11294
  action: _enum(["change_source"]),
11015
11295
  appDirectory: string2().max(240),
11016
- commitSha: string2().regex(/^[0-9a-f]{40}$\/iu/),
11296
+ commitSha: string2().regex(/^[0-9a-fA-F]{40}$/),
11017
11297
  expectedRevision: int().gt(0),
11018
11298
  ref: string2().min(1).max(512)
11019
11299
  })
@@ -11021,13 +11301,23 @@ var zGemGitSourceCommand = union([
11021
11301
  var zGemGitSourceConnectRequest = strictObject({
11022
11302
  appDirectory: string2().max(240),
11023
11303
  automaticPublishing: boolean2(),
11024
- commitSha: string2().regex(/^[0-9a-f]{40}$\/iu/),
11304
+ commitSha: string2().regex(/^[0-9a-fA-F]{40}$/),
11025
11305
  connectionId: uuid2(),
11026
11306
  folderId: uuid2().nullish(),
11027
- idempotencyKey: string2().min(1).max(200).regex(/^[A-Za-z0-9._:-]+$\/u/),
11307
+ idempotencyKey: string2().min(1).max(200).regex(/^[A-Za-z0-9._:-]+$/),
11028
11308
  previewsEnabled: boolean2(),
11029
11309
  ref: string2().min(1).max(512),
11030
- repositoryId: string2().regex(/^[1-9][0-9]{0,19}$\/u/),
11310
+ repositoryId: string2().regex(/^[1-9][0-9]{0,19}$/),
11311
+ title: string2().min(1).max(256)
11312
+ });
11313
+ var zGemGitSourceCopyResult = strictObject({
11314
+ artifactId: uuid2(),
11315
+ copiedFromArtifactId: uuid2(),
11316
+ copiedFromCommitSha: string2().regex(/^[0-9a-fA-F]{40}$/),
11317
+ copiedFromVersionId: uuid2(),
11318
+ copiedFromVersionNumber: int().gte(1),
11319
+ libraryItemId: uuid2().nullable(),
11320
+ slug: string2().min(1).max(256),
11031
11321
  title: string2().min(1).max(256)
11032
11322
  });
11033
11323
  var zGemGitSourceImportError = strictObject({
@@ -11038,7 +11328,7 @@ var zGemGitSourceImport = strictObject({
11038
11328
  attempt: int().gte(0),
11039
11329
  buildId: uuid2().nullable(),
11040
11330
  commitMessage: string2().max(16384),
11041
- commitSha: string2().regex(/^[0-9a-f]{40}$\/iu/),
11331
+ commitSha: string2().regex(/^[0-9a-fA-F]{40}$/),
11042
11332
  completedAt: exports_iso.datetime({ offset: true }).nullable(),
11043
11333
  createdAt: exports_iso.datetime({ offset: true }),
11044
11334
  error: zGemGitSourceImportError,
@@ -11058,13 +11348,11 @@ var zGemGitSourceImport = strictObject({
11058
11348
  "queued",
11059
11349
  "fetching",
11060
11350
  "validating",
11061
- "needs_version",
11062
11351
  "preparing",
11063
11352
  "ready",
11064
11353
  "needs_access",
11065
11354
  "needs_configuration",
11066
11355
  "needs_resource_grant",
11067
- "budget_blocked",
11068
11356
  "failed",
11069
11357
  "canceled",
11070
11358
  "superseded"
@@ -11076,7 +11364,7 @@ var zGemGitSourceInspectRequest = strictObject({
11076
11364
  appDirectory: string2().max(240),
11077
11365
  connectionId: uuid2(),
11078
11366
  ref: string2().min(1).max(512),
11079
- repositoryId: string2().regex(/^[1-9][0-9]{0,19}$\/u/)
11367
+ repositoryId: string2().regex(/^[1-9][0-9]{0,19}$/)
11080
11368
  });
11081
11369
  var zGemGitSourceInspectionDiagnostic = strictObject({
11082
11370
  code: string2().min(1).max(128),
@@ -11087,14 +11375,14 @@ var zGemGitSourceInspection = strictObject({
11087
11375
  appDirectory: string2().max(240),
11088
11376
  candidateDirectories: array(string2().max(240)).max(5000),
11089
11377
  commitMessage: string2().max(16384),
11090
- commitSha: string2().regex(/^[0-9a-f]{40}$\/iu/),
11378
+ commitSha: string2().regex(/^[0-9a-fA-F]{40}$/),
11091
11379
  connectionId: uuid2(),
11092
11380
  diagnostics: array(zGemGitSourceInspectionDiagnostic).max(100),
11093
11381
  fileCount: int().gte(0).lte(5000),
11094
11382
  framework: string2().max(128).nullable(),
11095
11383
  proposedConfiguration: string2().max(65536).nullable(),
11096
11384
  ref: string2().min(1).max(512),
11097
- repositoryId: string2().regex(/^[1-9][0-9]{0,19}$\/u/),
11385
+ repositoryId: string2().regex(/^[1-9][0-9]{0,19}$/),
11098
11386
  resourceNeeds: array(object({
11099
11387
  kind: string2().min(1).max(128),
11100
11388
  name: string2().min(1).max(512)
@@ -11103,12 +11391,12 @@ var zGemGitSourceInspection = strictObject({
11103
11391
  totalBytes: int().gte(0).lte(25165824)
11104
11392
  });
11105
11393
  var zGemGitSourcePreview = strictObject({
11106
- approvedHeadSha: string2().regex(/^[0-9a-f]{40}$\/iu/).nullable(),
11394
+ approvedHeadSha: string2().regex(/^[0-9a-fA-F]{40}$/).nullable(),
11107
11395
  canOpen: boolean2(),
11108
11396
  error: zGemGitSourceImportError,
11109
11397
  expiresAt: exports_iso.datetime({ offset: true }),
11110
11398
  fork: boolean2(),
11111
- headSha: string2().regex(/^[0-9a-f]{40}$\/iu/),
11399
+ headSha: string2().regex(/^[0-9a-fA-F]{40}$/),
11112
11400
  id: uuid2(),
11113
11401
  pullRequestNumber: int().gt(0).nullable(),
11114
11402
  ref: string2().min(1).max(512),
@@ -11123,12 +11411,12 @@ var zGemGitSourcePreview = strictObject({
11123
11411
  title: string2().max(16384)
11124
11412
  });
11125
11413
  var zGemGitSourcePreviewInspectRequest = strictObject({
11126
- headSha: string2().regex(/^[0-9a-f]{40}$\/iu/)
11414
+ headSha: string2().regex(/^[0-9a-fA-F]{40}$/)
11127
11415
  });
11128
11416
  var zGemGitSourcePreviewInspection = strictObject({
11129
11417
  appDirectory: string2().max(240),
11130
11418
  diagnostics: array(zGemGitSourceInspectionDiagnostic).max(100),
11131
- headSha: string2().regex(/^[0-9a-f]{40}$\/iu/),
11419
+ headSha: string2().regex(/^[0-9a-fA-F]{40}$/),
11132
11420
  previewId: uuid2(),
11133
11421
  proposedConfiguration: string2().max(65536).nullable(),
11134
11422
  ref: string2().min(1).max(512),
@@ -11136,26 +11424,33 @@ var zGemGitSourcePreviewInspection = strictObject({
11136
11424
  kind: string2().min(1).max(128),
11137
11425
  name: string2().min(1).max(512)
11138
11426
  })).max(100),
11139
- resourcePolicyHash: string2().regex(/^[0-9a-f]{64}$\/iu/).nullable(),
11427
+ resourcePolicyHash: string2().regex(/^[0-9a-fA-F]{64}$/).nullable(),
11140
11428
  state: _enum(["ready", "needs_configuration", "rejected"])
11141
11429
  });
11142
- var zGemGitSourceRefs = array(object({
11430
+ var zGemGitSourceRef = strictObject({
11143
11431
  kind: _enum(["branch", "tag"]),
11144
11432
  name: string2().min(1).max(512),
11145
11433
  ref: string2().min(1).max(512)
11146
- })).max(2000);
11434
+ });
11435
+ var zGemGitSourceRefs = strictObject({
11436
+ defaultBranch: zGemGitSourceRef,
11437
+ nextPage: int().gte(2).lte(100).nullable(),
11438
+ refs: array(zGemGitSourceRef).max(300)
11439
+ });
11147
11440
  var zGemGitSourceRefsRequest = strictObject({
11148
11441
  connectionId: uuid2(),
11149
- repositoryId: string2().regex(/^[1-9][0-9]{0,19}$\/u/)
11442
+ page: int().gte(1).lte(100).optional(),
11443
+ query: string2().max(512).optional(),
11444
+ repositoryId: string2().regex(/^[1-9][0-9]{0,19}$/)
11150
11445
  });
11151
11446
  var zGemGitSourceRepository = strictObject({
11152
11447
  connectionId: uuid2(),
11153
11448
  defaultBranch: string2().min(1).max(512),
11154
- installationId: string2().regex(/^[1-9][0-9]{0,19}$\/u/),
11449
+ installationId: string2().regex(/^[1-9][0-9]{0,19}$/),
11155
11450
  name: string2().min(1).max(255),
11156
11451
  owner: string2().min(1).max(255),
11157
11452
  private: boolean2(),
11158
- repositoryId: string2().regex(/^[1-9][0-9]{0,19}$\/u/),
11453
+ repositoryId: string2().regex(/^[1-9][0-9]{0,19}$/),
11159
11454
  url: url().max(2048)
11160
11455
  });
11161
11456
  var zGemGitSourceConnection = strictObject({
@@ -11196,11 +11491,12 @@ var zGemGitSourceState = strictObject({
11196
11491
  access: _enum(["active", "suspended", "revoked", "needs_access"]),
11197
11492
  active: boolean2(),
11198
11493
  appDirectory: string2().max(240),
11199
- currentCommitSha: string2().regex(/^[0-9a-f]{40}$\/iu/).nullable(),
11200
- desiredCommitSha: string2().regex(/^[0-9a-f]{40}$\/iu/).nullable(),
11494
+ currentCommitSha: string2().regex(/^[0-9a-fA-F]{40}$/).nullable(),
11495
+ desiredCommitSha: string2().regex(/^[0-9a-fA-F]{40}$/).nullable(),
11201
11496
  generation: int().gte(0),
11202
11497
  id: uuid2(),
11203
- lastBuiltCommitSha: string2().regex(/^[0-9a-f]{40}$\/iu/).nullable(),
11498
+ lastBuiltCommitSha: string2().regex(/^[0-9a-fA-F]{40}$/).nullable(),
11499
+ lastError: zGemGitSourceBindingError,
11204
11500
  ref: string2().min(1).max(512),
11205
11501
  repository: zGemGitSourceRepository
11206
11502
  }).nullable(),
@@ -12019,6 +12315,7 @@ var zLibraryExternalSourceStatus = _enum([
12019
12315
  "pending",
12020
12316
  "ready",
12021
12317
  "syncing",
12318
+ "deleting",
12022
12319
  "error",
12023
12320
  "rebind_required"
12024
12321
  ]);
@@ -12814,6 +13111,24 @@ var zModelRelayForwardRequest = strictObject({
12814
13111
  opaqueToken: string2().min(1),
12815
13112
  provider: string2().min(1)
12816
13113
  });
13114
+ var zModelRelayImageRequest = strictObject({
13115
+ opaqueToken: string2().min(1),
13116
+ outputFormat: _enum(["png", "jpeg", "webp"]).optional().default("png"),
13117
+ prompt: string2().min(1).max(4000),
13118
+ quality: _enum(["low", "medium", "high", "auto"]).optional().default("auto"),
13119
+ size: _enum(["1024x1024", "1536x1024", "1024x1536", "auto"]).optional().default("auto")
13120
+ });
13121
+ var zModelRelayImageResponse = object({
13122
+ costUsd: string2(),
13123
+ imageBase64: string2(),
13124
+ mimeType: string2(),
13125
+ model: string2(),
13126
+ usage: object({
13127
+ imageOutputTokens: int().gte(0),
13128
+ inputTokens: int().gte(0),
13129
+ textOutputTokens: int().gte(0)
13130
+ })
13131
+ });
12817
13132
  var zModelRelayKillSwitchEngageRequest = object({
12818
13133
  reason: string2().min(1)
12819
13134
  });
@@ -13284,6 +13599,15 @@ var zProtectedResourceMetadata = object({
13284
13599
  });
13285
13600
  var zProviderAppRuntimePanelLogsResponse = object({
13286
13601
  deploymentId: string2(),
13602
+ logStatus: object({
13603
+ code: string2().nullable(),
13604
+ historicalComplete: boolean2(),
13605
+ sink: object({
13606
+ availability: _enum(["available", "not_configured", "unavailable"]),
13607
+ code: string2().nullable()
13608
+ }),
13609
+ state: _enum(["complete", "partial", "delayed", "lost"])
13610
+ }),
13287
13611
  logs: array(object({
13288
13612
  capabilityName: string2().nullable(),
13289
13613
  durationMs: number2().nullable(),
@@ -13293,7 +13617,7 @@ var zProviderAppRuntimePanelLogsResponse = object({
13293
13617
  message: string2().nullable(),
13294
13618
  metadata: record(string2(), unknown()),
13295
13619
  requestId: string2().nullable(),
13296
- source: _enum(["app_logs", "tenant_tail"]),
13620
+ source: _enum(["app_logs", "tenant_tail", "tenant_loki"]),
13297
13621
  status: string2().nullable(),
13298
13622
  timestamp: string2()
13299
13623
  })),
@@ -13625,6 +13949,10 @@ var zRestoreGemVersionResponse = strictObject({
13625
13949
  var zRetryGemReleaseRequest = strictObject({
13626
13950
  idempotencyKey: string2().min(1).max(128)
13627
13951
  });
13952
+ var zRetryGemVersionResponse = strictObject({
13953
+ linksChanged: literal(false),
13954
+ version: zGemVersion
13955
+ });
13628
13956
  var zRevokeCrossWorkspaceShareRequest = object({
13629
13957
  reason: string2().nullish(),
13630
13958
  shareId: uuid2()
@@ -13914,6 +14242,7 @@ var zPersonaIntegrationResponse = object({
13914
14242
  data: zPersonaIntegration
13915
14243
  });
13916
14244
  var zSupabaseExternalDatasetWebhookRequest = object({
14245
+ eventId: string2().min(1).max(64).optional(),
13917
14246
  schema: string2().nullish(),
13918
14247
  table: string2().nullish()
13919
14248
  });
@@ -14839,6 +15168,7 @@ var zThreadMessagePart = union([
14839
15168
  "provider_content_filtered",
14840
15169
  "context_window_exceeded",
14841
15170
  "compaction_loop_exceeded",
15171
+ "compaction_refused",
14842
15172
  "automation_turn_budget_exceeded",
14843
15173
  "output_length_limit_reached",
14844
15174
  "out_of_usage",
@@ -15293,6 +15623,10 @@ var zUpdateConnectionLabelResponse = object({
15293
15623
  var zUpdateExternalPermissionsRequest = object({
15294
15624
  permissions: zExternalPermissions
15295
15625
  });
15626
+ var zUpdateLibraryExternalSourceRequest = object({
15627
+ enabled: boolean2().optional(),
15628
+ syncIntervalMinutes: int().gte(1).lte(10080).optional()
15629
+ });
15296
15630
  var zUpdatePersonaIdentity = object({
15297
15631
  avatarUrl: string2().nullish(),
15298
15632
  departments: array(string2()).nullish(),
@@ -15346,7 +15680,7 @@ var zUpdatePersonaRequest = object({
15346
15680
  var zUpdatePublishedPageLinkGateRequest = object({
15347
15681
  emailAllowlist: array(string2()).nullish(),
15348
15682
  emailGateEnabled: boolean2().nullish(),
15349
- expiresAt: string2().nullish(),
15683
+ expiresAt: exports_iso.datetime({ offset: true }).nullish(),
15350
15684
  gateType: _enum(["none", "passcode", "email_otp", "passcode_email_otp"]).nullish(),
15351
15685
  passcode: string2().max(128).nullish(),
15352
15686
  searchIndexingDisabled: boolean2().nullish(),
@@ -15924,7 +16258,13 @@ var zGetToolAccessMatrixApiAccessControlToolsToolMatrixGetPath = object({
15924
16258
  });
15925
16259
  var zGetAdminAuditLogApiAdminAuditLogGetQuery = object({
15926
16260
  limit: int().gte(1).lte(100).optional().default(50),
15927
- offset: int().gte(0).nullish().default(0)
16261
+ offset: int().gte(0).nullish().default(0),
16262
+ actorUserId: string2().optional(),
16263
+ action: string2().min(1).max(120).optional(),
16264
+ targetType: string2().min(1).max(80).optional(),
16265
+ targetId: string2().min(1).max(200).optional(),
16266
+ since: exports_iso.datetime({ offset: true }).optional(),
16267
+ until: exports_iso.datetime({ offset: true }).optional()
15928
16268
  });
15929
16269
  var zAdminListInvitationsApiAdminInvitationsGetQuery = object({
15930
16270
  limit: int().gte(1).lte(100).optional().default(50),
@@ -16914,9 +17254,25 @@ var zGetAvailableModelsApiModelsAvailableGetQuery = object({
16914
17254
  });
16915
17255
  var zExportActivityLogsApiMonitoringActivityExportGetQuery = object({
16916
17256
  dateRange: string2().optional().default("7d"),
16917
- format: string2().optional().default("json")
17257
+ format: string2().optional().default("json"),
17258
+ action: string2().nullish(),
17259
+ resourceType: string2().nullish(),
17260
+ actorUserId: string2().nullish()
16918
17261
  });
16919
17262
  var zExportActivityLogsApiMonitoringActivityExportGetResponse = record(string2(), unknown());
17263
+ var zListAuditLedgerApiMonitoringActivityLedgersLedgerGetPath = object({
17264
+ ledger: _enum([
17265
+ "rubric_events",
17266
+ "webhook_credential_events",
17267
+ "dataset_sql_writes"
17268
+ ])
17269
+ });
17270
+ var zListAuditLedgerApiMonitoringActivityLedgersLedgerGetQuery = object({
17271
+ page: int().gte(1).optional().default(1),
17272
+ pageSize: int().gte(1).lte(200).optional().default(50),
17273
+ dateRange: string2().optional().default("7d")
17274
+ });
17275
+ var zListAuditLedgerApiMonitoringActivityLedgersLedgerGetResponse = record(string2(), unknown());
16920
17276
  var zGetRecentActivityApiMonitoringActivityRecentGetQuery = object({
16921
17277
  limit: int().gte(1).lte(500).optional().default(100)
16922
17278
  });
@@ -17373,11 +17729,14 @@ var zListAppLogsApiPlatformArtifactsArtifactSlugAppLogsGetPath = object({
17373
17729
  var zListAppLogsApiPlatformArtifactsArtifactSlugAppLogsGetQuery = object({
17374
17730
  limit: int().gte(1).lte(500).optional().default(100),
17375
17731
  deploymentId: string2().nullish(),
17732
+ releaseId: string2().nullish(),
17376
17733
  runtimeRunId: string2().nullish(),
17377
17734
  level: string2().nullish(),
17378
- requestId: string2().nullish()
17735
+ requestId: string2().nullish(),
17736
+ cursor: string2().nullish(),
17737
+ since: string2().nullish(),
17738
+ until: string2().nullish()
17379
17739
  });
17380
- var zListAppLogsApiPlatformArtifactsArtifactSlugAppLogsGetResponse = array(zAppLogRecord);
17381
17740
  var zStreamAppLogsApiPlatformArtifactsArtifactSlugAppLogsStreamGetPath = object({
17382
17741
  artifactSlug: string2()
17383
17742
  });
@@ -17388,7 +17747,9 @@ var zStreamAppLogsApiPlatformArtifactsArtifactSlugAppLogsStreamGetQuery = object
17388
17747
  releaseId: string2().nullish(),
17389
17748
  runtimeRunId: string2().nullish(),
17390
17749
  level: string2().nullish(),
17391
- requestId: string2().nullish()
17750
+ requestId: string2().nullish(),
17751
+ since: string2().nullish(),
17752
+ until: string2().nullish()
17392
17753
  });
17393
17754
  var zStreamAppLogsApiPlatformArtifactsArtifactSlugAppLogsStreamGetResponse = string2();
17394
17755
  var zGetAppReleaseOverviewApiPlatformArtifactsArtifactSlugAppReleaseOverviewGetPath = object({
@@ -18154,6 +18515,8 @@ var zDatasetExternalSourceGetResponse = object({
18154
18515
  relationName: string2().nullable(),
18155
18516
  relationSchema: string2().nullable(),
18156
18517
  supabaseRef: string2(),
18518
+ syncIntervalSeconds: int(),
18519
+ syncMode: _enum(["manual", "scheduled"]),
18157
18520
  workspaceId: string2().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
18158
18521
  writeEnabled: boolean2().nullable()
18159
18522
  }).nullable();
@@ -18176,6 +18539,8 @@ var zDatasetExternalSourcePutBody = object({
18176
18539
  relationName: string2().nullish().default(null),
18177
18540
  relationSchema: string2().nullish().default(null),
18178
18541
  supabaseRef: string2().min(1),
18542
+ syncIntervalSeconds: int().gte(60).lte(86400).optional().default(1800),
18543
+ syncMode: _enum(["manual", "scheduled"]).optional().default("manual"),
18179
18544
  writeEnabled: boolean2().nullish().default(null)
18180
18545
  });
18181
18546
  var zDatasetExternalSourcePutPath = object({
@@ -18204,9 +18569,38 @@ var zDatasetExternalSourcePutResponse = object({
18204
18569
  relationName: string2().nullable(),
18205
18570
  relationSchema: string2().nullable(),
18206
18571
  supabaseRef: string2(),
18572
+ syncIntervalSeconds: int(),
18573
+ syncMode: _enum(["manual", "scheduled"]),
18207
18574
  workspaceId: string2().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
18208
18575
  writeEnabled: boolean2().nullable()
18209
18576
  });
18577
+ var zDatasetExternalSourceSyncBody = strictObject({
18578
+ expectedDatasetRevision: string2().regex(/^(0|[1-9][0-9]{0,19})$/),
18579
+ expectedSchemaRevision: string2().regex(/^(0|[1-9][0-9]{0,19})$/),
18580
+ idempotencyKey: string2().min(1).max(128)
18581
+ });
18582
+ var zDatasetExternalSourceSyncPath = object({
18583
+ datasetId: string2().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/)
18584
+ });
18585
+ var zDatasetExternalSourceSyncResponse = object({
18586
+ commandId: string2().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
18587
+ currentDatasetRevision: string2().regex(/^(0|[1-9][0-9]{0,19})$/),
18588
+ currentSchemaRevision: string2().regex(/^(0|[1-9][0-9]{0,19})$/),
18589
+ datasetId: string2().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
18590
+ jobId: string2().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/),
18591
+ operation: _enum(["external_source"]),
18592
+ replayed: boolean2(),
18593
+ state: _enum([
18594
+ "queued",
18595
+ "claimed",
18596
+ "running",
18597
+ "cancelRequested",
18598
+ "finalizing",
18599
+ "succeeded",
18600
+ "failed",
18601
+ "cancelled"
18602
+ ])
18603
+ });
18210
18604
  var zDatasetExternalSourceTestBody = object({
18211
18605
  allowedColumns: array(string2().min(1)).nullish().default(null),
18212
18606
  allowedWriteColumns: array(string2()).nullish().default(null),
@@ -18226,6 +18620,8 @@ var zDatasetExternalSourceTestBody = object({
18226
18620
  relationName: string2().nullish().default(null),
18227
18621
  relationSchema: string2().nullish().default(null),
18228
18622
  supabaseRef: string2().min(1),
18623
+ syncIntervalSeconds: int().gte(60).lte(86400).optional().default(1800),
18624
+ syncMode: _enum(["manual", "scheduled"]).optional().default("manual"),
18229
18625
  writeEnabled: boolean2().nullish().default(null)
18230
18626
  });
18231
18627
  var zDatasetExternalSourceTestPath = object({
@@ -18972,6 +19368,9 @@ var zGetFrictionReportCleanupResponse = object({
18972
19368
  severity: string2(),
18973
19369
  status: string2()
18974
19370
  });
19371
+ var zDeleteGemLinkHeaders = object({
19372
+ "idempotency-key": string2().min(1).max(200)
19373
+ });
18975
19374
  var zDeleteGemLinkPath = object({
18976
19375
  linkId: string2()
18977
19376
  });
@@ -18983,10 +19382,16 @@ var zUpdateGemLinkAccessResponse = record(string2(), unknown());
18983
19382
  var zCreateGemLinkEmailCaptureDatasetPath = object({
18984
19383
  linkId: string2()
18985
19384
  });
19385
+ var zRevokeGemLinkHeaders = object({
19386
+ "idempotency-key": string2().min(1).max(200)
19387
+ });
18986
19388
  var zRevokeGemLinkPath = object({
18987
19389
  linkId: string2()
18988
19390
  });
18989
19391
  var zRevokeGemLinkResponse = record(string2(), unknown());
19392
+ var zRotateGemLinkHeaders = object({
19393
+ "idempotency-key": string2().min(1).max(200)
19394
+ });
18990
19395
  var zRotateGemLinkPath = object({
18991
19396
  linkId: string2()
18992
19397
  });
@@ -19092,6 +19497,10 @@ var zDiffGemVersionsQuery = object({
19092
19497
  fromVersion: string2().min(1),
19093
19498
  toVersion: string2().min(1)
19094
19499
  });
19500
+ var zDeleteGemVersionPath = object({
19501
+ gemRef: string2().min(1),
19502
+ resourceId: string2().min(1)
19503
+ });
19095
19504
  var zGetGemVersionPath = object({
19096
19505
  gemRef: string2().min(1),
19097
19506
  resourceId: string2().min(1)
@@ -19104,6 +19513,10 @@ var zRestoreGemVersionPath = object({
19104
19513
  gemRef: string2().min(1),
19105
19514
  resourceId: string2().min(1)
19106
19515
  });
19516
+ var zRetryGemVersionPath = object({
19517
+ gemRef: string2().min(1),
19518
+ resourceId: string2().min(1)
19519
+ });
19107
19520
  var zGetAvailableLibrariesApiPlatformLibrariesAvailableGetResponse = record(string2(), unknown());
19108
19521
  var zGetAvailableIconsApiPlatformLibrariesIconsGetResponse = record(string2(), unknown());
19109
19522
  var zGetLibrariesManifestApiPlatformLibrariesManifestGetResponse = record(string2(), unknown());
@@ -19128,9 +19541,24 @@ var zDeleteLibraryExternalSourceApiPlatformLibraryExternalSourcesSourceIdDeleteP
19128
19541
  var zGetLibraryExternalSourceApiPlatformLibraryExternalSourcesSourceIdGetPath = object({
19129
19542
  sourceId: string2()
19130
19543
  });
19544
+ var zUpdateLibraryExternalSourceApiPlatformLibraryExternalSourcesSourceIdPatchPath = object({
19545
+ sourceId: string2()
19546
+ });
19547
+ var zCancelLibraryExternalSourceApiPlatformLibraryExternalSourcesSourceIdCancelPostPath = object({
19548
+ sourceId: string2()
19549
+ });
19550
+ var zPauseLibraryExternalSourceApiPlatformLibraryExternalSourcesSourceIdPausePostPath = object({
19551
+ sourceId: string2()
19552
+ });
19131
19553
  var zRebindLibraryExternalSourceApiPlatformLibraryExternalSourcesSourceIdRebindPostPath = object({
19132
19554
  sourceId: string2()
19133
19555
  });
19556
+ var zResumeLibraryExternalSourceApiPlatformLibraryExternalSourcesSourceIdResumePostPath = object({
19557
+ sourceId: string2()
19558
+ });
19559
+ var zRunNowLibraryExternalSourceApiPlatformLibraryExternalSourcesSourceIdRunNowPostPath = object({
19560
+ sourceId: string2()
19561
+ });
19134
19562
  var zSyncLibraryExternalSourceApiPlatformLibraryExternalSourcesSourceIdSyncPostPath = object({
19135
19563
  sourceId: string2()
19136
19564
  });
@@ -19750,8 +20178,9 @@ var zGetPublishedPagePreviewImageApiPublicPagesSlugPreviewImagePublicPreviewRout
19750
20178
  var zPublicArtifactToolProxyExecuteApiPublicPagesSlugToolProxyExecutePostBody = strictObject({
19751
20179
  forceRefresh: boolean2().optional().default(false),
19752
20180
  idempotencyKey: string2().max(128).nullish(),
19753
- operation: string2().min(1).max(256).regex(/^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$/),
20181
+ operation: string2().min(1).max(256),
19754
20182
  parameters: record(string2(), unknown()).optional().default({}),
20183
+ requestId: string2().regex(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/).optional(),
19755
20184
  role: string2().min(1).max(64).regex(/^[a-z][a-z0-9_]{0,63}$/),
19756
20185
  timeoutMs: int().gte(1000).lte(60000).optional().default(25000)
19757
20186
  });
@@ -19840,6 +20269,13 @@ var zInvokeAppQueryApiRuntimeAppsDeploymentIdQueryCapabilityNamePostPath = objec
19840
20269
  var zAppRuntimeStorageExecutePath = object({
19841
20270
  deploymentId: uuid2()
19842
20271
  });
20272
+ var zAppRuntimeUploadGrantCreatePath = object({
20273
+ deploymentId: uuid2()
20274
+ });
20275
+ var zAppRuntimeUploadGrantCompletePath = object({
20276
+ deploymentId: uuid2(),
20277
+ uploadId: uuid2()
20278
+ });
19843
20279
  var zProviderInvokeAppActionApiRuntimeProviderAppsDeploymentIdActionCapabilityNamePostPath = object({
19844
20280
  deploymentId: string2(),
19845
20281
  capabilityName: string2()
@@ -19874,6 +20310,14 @@ var zCspViolationReportApiSecurityCspViolationReportPostBody = string2().default
19874
20310
  var zThreadShareReadPath = object({
19875
20311
  shareId: string2().min(1).max(128)
19876
20312
  });
20313
+ var zThreadShareFileContentHeaders = object({
20314
+ Range: string2().optional()
20315
+ });
20316
+ var zThreadShareFileContentPath = object({
20317
+ shareId: string2().min(1).max(128),
20318
+ fileId: string2().min(1).max(200)
20319
+ });
20320
+ var zThreadShareFileContentResponse = string2();
19877
20321
  var zBackfillSharedContentMetadataApiSharingBackfillMetadataPostResponse = record(string2(), string2());
19878
20322
  var zDeleteNotificationsApiSharingNotificationsDeleteResponse = record(string2(), unknown());
19879
20323
  var zGetNotificationsApiSharingNotificationsGetQuery = object({
@@ -20308,6 +20752,9 @@ var zGetGemGitSourcePath = object({
20308
20752
  var zCommandGemGitSourcePath = object({
20309
20753
  artifactId: uuid2()
20310
20754
  });
20755
+ var zCopyGemGitSourcePath = object({
20756
+ artifactId: uuid2()
20757
+ });
20311
20758
  var zInspectGemGitPreviewPath = object({
20312
20759
  artifactId: uuid2(),
20313
20760
  previewId: uuid2()
@@ -20369,6 +20816,17 @@ var zRobotsTxtRobotsTxtGetResponse = string2();
20369
20816
 
20370
20817
  // ../../packages/types/src/mcp/gemResult.ts
20371
20818
  var GEM_RESULT_SCHEMA_V1 = "uru.gem.result.v1";
20819
+ // src/terminal-safety.ts
20820
+ function stripTerminalControl(value) {
20821
+ let out = "";
20822
+ for (const ch of value) {
20823
+ const code = ch.codePointAt(0) ?? 0;
20824
+ const isControl = code < 32 && code !== 10 && code !== 9 || code === 127 || code >= 128 && code <= 159;
20825
+ out += isControl ? "�" : ch;
20826
+ }
20827
+ return out;
20828
+ }
20829
+
20372
20830
  // src/json.ts
20373
20831
  function isRecord(value) {
20374
20832
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -20413,17 +20871,6 @@ function pickString(record2, keys) {
20413
20871
  return;
20414
20872
  }
20415
20873
 
20416
- // src/gem-panel-client.ts
20417
- function stripTerminalControl(value) {
20418
- let out = "";
20419
- for (const ch of value) {
20420
- const code = ch.codePointAt(0) ?? 0;
20421
- const isControl = code < 32 && code !== 10 && code !== 9 || code === 127 || code >= 128 && code <= 159;
20422
- out += isControl ? "�" : ch;
20423
- }
20424
- return out;
20425
- }
20426
-
20427
20874
  // src/gem-result.ts
20428
20875
  function gemEnvelope(body, operation) {
20429
20876
  if (!isRecord(body) || body["schema"] !== GEM_RESULT_SCHEMA_V1) {
@@ -21772,7 +22219,7 @@ function formatWorkspaces(workspaces, style = PLAIN_VISUAL, currentWorkspaceId)
21772
22219
  currentId !== undefined && workspace.id === currentId ? "current" : ""
21773
22220
  ]));
21774
22221
  }
21775
- function formatOperationContract(contract) {
22222
+ function formatOperationContract(contract, options = {}) {
21776
22223
  const id = typeof contract["id"] === "string" ? contract["id"] : "unknown";
21777
22224
  const family = typeof contract["family"] === "string" ? contract["family"] : "unknown";
21778
22225
  const summary = typeof contract["summary"] === "string" ? contract["summary"] : "";
@@ -21789,8 +22236,19 @@ function formatOperationContract(contract) {
21789
22236
  if (safety !== "") {
21790
22237
  lines.push(`Safety: ${safety}`);
21791
22238
  }
21792
- lines.push("Input schema:");
21793
- lines.push(JSON.stringify(contract["inputSchema"] ?? {}, null, 2));
22239
+ const inputSchema = contract["inputSchema"];
22240
+ if (inputSchema !== undefined) {
22241
+ lines.push("Input schema:");
22242
+ lines.push(JSON.stringify(inputSchema, null, 2));
22243
+ } else {
22244
+ const pointer = options.inputSchemaNote ?? (backend === "" ? "not loaded" : `not loaded — run \`uru tools schema ${backend}\``);
22245
+ lines.push(`Input schema: ${pointer}`);
22246
+ }
22247
+ const examples = contract["examples"];
22248
+ if (Array.isArray(examples) && examples.length > 0) {
22249
+ lines.push("Examples:");
22250
+ lines.push(JSON.stringify(examples, null, 2));
22251
+ }
21794
22252
  return lines.join(`
21795
22253
  `);
21796
22254
  }
@@ -21992,19 +22450,24 @@ Upload local Gem source with source-version CAS. Without a matching lock, push
21992
22450
  fails instead of silently overwriting remote edits. Generated directories,
21993
22451
  node_modules, VCS metadata, and local env files are excluded.
21994
22452
  `,
21995
- logs: `Usage: uru logs [library/name.gem] [--release <id>|--run <id>] [--limit 100] [--follow]
22453
+ logs: `Usage: uru logs [library/name.gem] [--release <id>|--run <id>] [--since <time>] [--until <time>] [--request-id <id>] [--limit 100] [--cursor <cursor>] [--follow] [--export <file>]
21996
22454
 
21997
- Print bounded runtime logs for the Gem, one logical Release, or one Run. With --follow,
21998
- the CLI streams runtime logs for up to 30 minutes and polls if the stream is unavailable;
21999
- text status goes to stderr and log lines go to stdout. Use global --output stream-json
22000
- or --output-format stream-json before the command to emit NDJSON events.
22455
+ Print bounded runtime logs for the Gem, one logical Release, or one Run. Filter by
22456
+ ISO time, request, release, run, or level. With --request-id, the lines are
22457
+ grouped into one ordered waterfall per request, each step placed against that
22458
+ request's own start; --json keeps the raw page. With --follow, the CLI streams
22459
+ runtime logs for up to 30 minutes over the same server-sent stream the web
22460
+ Activity tab uses, after one bounded read of the recent page. Use --export to
22461
+ write a JSON array of the returned lines. Text status goes to stderr and log lines
22462
+ go to stdout. Use global --output stream-json or --output-format stream-json before
22463
+ the command to emit NDJSON events.
22001
22464
  `,
22002
22465
  open: `Usage: uru open [library/name.gem] [--link <link-id-or-name>]
22003
22466
 
22004
22467
  Print one explicit active Link URL. When a Gem has more than one active Link,
22005
22468
  use --link to choose the Link rather than guessing which URL you mean.
22006
22469
  `,
22007
- gems: `Usage: uru gems <inspect|validate|build|deploy|verify|fs|status|source|read|write|edits|versions|releases|links|runs|capabilities|schedules|bindings|components|delegations|api|domains|analytics|power|logs> [...]
22470
+ gems: `Usage: uru gems <inspect|validate|build|deploy|verify|fs|status|source|read|write|edits|versions|releases|links|runs|capabilities|schedules|events|bindings|components|delegations|api|domains|analytics|power|logs|debug-token> [...]
22008
22471
  uru gems validate [library/name.gem] [--wait] [--timeout-ms 600000] [--poll-interval-ms 2000]
22009
22472
  uru gems build [library/name.gem] [--force] [--wait] [--timeout-ms 600000] [--poll-interval-ms 2000]
22010
22473
 
@@ -22012,7 +22475,11 @@ Dedicated Gem lifecycle and filesystem commands. These are adapters over the
22012
22475
  same platform operations used by MCP and the web UI.
22013
22476
 
22014
22477
  validate and build return a hosted_job_id immediately. Pass --wait to poll
22015
- gem.build_job until the compile is succeeded, failed, or expired.
22478
+ gem.build_job until the compile is succeeded, failed, or expired. Gem logs accept
22479
+ the same time, request, release, run, follow, and export flags as uru logs.
22480
+ uru gems debug-token mints a read-only debug session for ONE deployment, good
22481
+ for at most 15 minutes. Use it to inspect a running Gem; it authorizes the
22482
+ deployment's log route and nothing else.
22016
22483
  `,
22017
22484
  "gems fs": `Usage: uru gems fs ls [library/name.gem] [path] [--recursive]
22018
22485
  uru gems fs read [library/name.gem] <file>
@@ -22062,9 +22529,11 @@ operation for this grant.
22062
22529
  uru gems versions diff [library/name.gem] <from-version> <to-version>
22063
22530
  uru gems versions restore [library/name.gem] <version>
22064
22531
  uru gems versions preview [library/name.gem] <version>
22532
+ uru gems versions retry [library/name.gem] <version>
22065
22533
 
22066
22534
  Save and inspect frozen Gem checkpoints. Name and message are optional. Saving,
22067
- restoring, previewing, and comparing Versions do not change any Link.
22535
+ restoring, previewing, and comparing Versions do not change any Link. Retry
22536
+ builds a Version that failed again, keeping the same Version number.
22068
22537
  `,
22069
22538
  "gems edits": `Usage: uru gems edits list [library/name.gem]
22070
22539
  uru gems edits show [library/name.gem] <edit>
@@ -22095,12 +22564,14 @@ Version instead. --version on its own is refused, because a following Link would
22095
22564
  discard it and publish something else. Changing one Link does not move any other
22096
22565
  Link.
22097
22566
  `,
22098
- "gems runs": `Usage: uru gems runs list [library/name.gem] [--cursor <cursor>] [--limit <n>] [--status <status>]
22567
+ "gems runs": `Usage: uru gems runs list [library/name.gem] [--cursor <cursor>] [--environment <environment>] [--limit <n>] [--status <status>] [--version <version-id>]
22099
22568
  uru gems runs show [library/name.gem] <run>
22100
22569
  uru gems runs cancel [library/name.gem] <run>
22101
22570
 
22102
- Inspect and control bounded Gem executions. Builds and Release attempts are not
22103
- Runs. Gems without a bounded execution capability do not have Runs.
22571
+ Inspect and control bounded Gem executions. Use --environment and --version to
22572
+ filter runs from one published environment or Version. Builds and Release
22573
+ attempts are not Runs. Gems without a bounded execution capability do not have
22574
+ Runs.
22104
22575
  `,
22105
22576
  "gems capabilities": `Usage: uru gems capabilities list [library/name.gem]
22106
22577
  uru gems capabilities enable|disable [library/name.gem] <capability> --kind <query|action|job>
@@ -22114,24 +22585,38 @@ required when changing a capability because names are not globally unique.
22114
22585
 
22115
22586
  Inspect and control declared Gem job schedules. Run now requires an explicit
22116
22587
  idempotency key so a retry cannot start a second job.
22588
+ `,
22589
+ "gems events": `Usage: uru gems events list [library/name.gem]
22590
+ uru gems events update [library/name.gem] <target-id> [--state active|paused] [--input-json '{...}']
22591
+ uru gems events pause|resume [library/name.gem] <target-id>
22592
+ uru gems events run [library/name.gem] <target-id> --idempotency-key <key>
22593
+
22594
+ Inspect and control Gem event rules that start jobs. Run now requires an
22595
+ explicit idempotency key so a retry cannot start a second job.
22117
22596
  `,
22118
22597
  "gems bindings": `Usage: uru gems bindings list [library/name.gem]
22119
22598
  uru gems bindings upsert [library/name.gem] --source-ref-type <type> --source-ref <ref> --target-resource-type <type>
22599
+ uru gems bindings upsert [library/name.gem] --binding-choices '{"role":"connection_ref"}' --expected-binding-set-version <n> --expected-binding-set-hash <hash>
22120
22600
  uru gems bindings resolve [library/name.gem] --build <build-id>
22121
22601
 
22122
22602
  List declared Gem needs, bind a need to an approved connection or resource, or
22123
22603
  resolve deterministic safe bindings for a ready Build. Source names a logical
22124
- role. Bindings attach the live connection. Do not put connection ids in Gem
22125
- source.
22604
+ role. A tool role binds only through \`--binding-choices\`: read the current
22605
+ version, hash and connection_ref values from \`bindings list\`, then submit the
22606
+ complete role map back. Every other declared need (a dataset, a persona, a
22607
+ query) binds with the plain \`--source-ref-type\` form. Do not put connection
22608
+ ids in Gem source.
22126
22609
  `,
22127
22610
  "gems api": `Usage: uru gems api describe [library/name.gem]
22128
- uru gems api query [library/name.gem] <capability> [--input-json '{...}']
22129
- uru gems api action [library/name.gem] <capability> --idempotency-key <key> [--input-json '{...}']
22130
- uru gems api job [library/name.gem] <capability> --idempotency-key <key> [--input-json '{...}']
22611
+ uru gems api query [library/name.gem] <capability> [--deployment <id>] [--input-json '{...}']
22612
+ uru gems api action [library/name.gem] <capability> --idempotency-key <key> [--deployment <id>] [--input-json '{...}']
22613
+ uru gems api job [library/name.gem] <capability> --idempotency-key <key> [--deployment <id>] [--input-json '{...}']
22131
22614
 
22132
22615
  Describe what a published Gem offers, then run one declared query, action, or
22133
- job. Call describe before query, action, or job. Actions and jobs require an
22134
- idempotency key.
22616
+ job. A job can run a declared tool or a program handler. Call describe before
22617
+ query, action, or job. Actions and jobs require an idempotency key. Save the
22618
+ request, run, and execution ids returned by a job before you inspect or cancel
22619
+ it.
22135
22620
  `,
22136
22621
  "gems domains": `Usage: uru gems domains list [library/name.gem] [--limit <n>]
22137
22622
  uru gems domains set [library/name.gem] <hostname>
@@ -22152,6 +22637,13 @@ requests and need --yes. The runtime alias uses the same operations.
22152
22637
  library: `Usage: uru library ls [path]
22153
22638
  uru library stat <path>
22154
22639
  uru library search <query>
22640
+ uru library source list|get|inspect
22641
+ uru library source create|edit <source-id> --params-json '{...}'
22642
+ uru library source pause|resume|run-now|cancel <source-id>
22643
+ uru library source reconnect <source-id> --params-json '{...}'
22644
+ uru library source remove <source-id> --yes
22645
+ uru library history <resource-type> <resource-id> [--limit 20] [--cursor <cursor>]
22646
+ uru library history get <resource-type> <resource-id> <revision>
22155
22647
  uru library mkdir <path>
22156
22648
  uru library read <path>
22157
22649
  uru library write <path> (--file <local-path>|--content <text>|--stdin) [--create] [--folder-id <id>]
@@ -22175,7 +22667,8 @@ known. Patch and patch-preview take a Codex envelope, not a full file
22175
22667
  replacement. For binary files, use \`uru library upload\`
22176
22668
  (\`library.upload_preflight\`, \`library.upload_create_session\`,
22177
22669
  \`library.upload_complete_session\`); for Gem child source files, use
22178
- \`uru gems read|write\`.
22670
+ \`uru gems read|write\`. Source controls use the same library.sources_* operations
22671
+ as MCP. History reads immutable Library revisions.
22179
22672
  `,
22180
22673
  "library upload": `Usage: uru library upload [path] --file <local-path> [--folder-id <id>] [--conflict replace|keep_both|skip]
22181
22674
  uru library upload preflight [path] [--filename <name>] [--folder-id <id>]
@@ -22190,6 +22683,10 @@ creates a session. PUT the bytes to the returned endpoint, then complete.
22190
22683
  uru datasets get|inspect <dataset-id>
22191
22684
  uru datasets history <dataset-id> [--limit 100] [--cursor <cursor>] [--version-id <id>]
22192
22685
  uru datasets jobs <dataset-id> [--limit 100] [--cursor <cursor>]
22686
+ uru datasets jobs get|cancel <dataset-id> <job-id>
22687
+ uru datasets source get|inspect <dataset-id>
22688
+ uru datasets source put|edit|connect|create|reconnect|test <dataset-id> --params-json '{...}'
22689
+ uru datasets source pause|resume|sync|run-now <dataset-id>
22193
22690
  uru datasets query <dataset-id> [--limit 100] [--cursor <cursor>] [--filter-json '{...}'] [--select name,status]
22194
22691
  uru datasets create|update|rows|restore|sql|sql-write --params-json '{...}'
22195
22692
 
@@ -23638,6 +24135,7 @@ class UruSdkError extends Error {
23638
24135
  }
23639
24136
 
23640
24137
  // src/local-commands.ts
24138
+ import { randomUUID } from "node:crypto";
23641
24139
  import { readFile as readFile3, stat } from "node:fs/promises";
23642
24140
  import { basename, resolve as resolve2 } from "node:path";
23643
24141
  import { setTimeout as sleep } from "node:timers/promises";
@@ -24053,6 +24551,47 @@ function operationForJson(operation) {
24053
24551
  }
24054
24552
  };
24055
24553
  }
24554
+ async function operationContractForInspect(ctx, operation) {
24555
+ const baseContract = operationForJson(operation);
24556
+ if (getCliNativeOperationContract(operation.id) !== undefined) {
24557
+ return { contract: baseContract, text: formatOperationContract(baseContract) };
24558
+ }
24559
+ if (ctx.token === undefined || ctx.token.trim() === "") {
24560
+ return {
24561
+ contract: baseContract,
24562
+ text: formatOperationContract(baseContract, {
24563
+ inputSchemaNote: `not loaded (not logged in) — run \`uru login\`, or \`uru tools schema ${operation.backendToolName}\``
24564
+ })
24565
+ };
24566
+ }
24567
+ try {
24568
+ await withWorkspace(ctx);
24569
+ } catch {
24570
+ return { contract: baseContract, text: formatOperationContract(baseContract) };
24571
+ }
24572
+ const enrichedContract = await withLiveInputSchema(ctx, operation, baseContract);
24573
+ return { contract: enrichedContract, text: formatOperationContract(enrichedContract) };
24574
+ }
24575
+ async function withLiveInputSchema(ctx, operation, baseContract) {
24576
+ let rawSchema;
24577
+ try {
24578
+ rawSchema = await client(ctx).getToolSchema(operation.backendToolName);
24579
+ } catch {
24580
+ return baseContract;
24581
+ }
24582
+ if (!isJsonObject2(rawSchema)) {
24583
+ return baseContract;
24584
+ }
24585
+ const rawInputSchema = rawSchema["inputSchema"];
24586
+ const inputSchema = isJsonObject2(rawInputSchema) ? narrowToolInputSchemaToOperation(rawInputSchema, operation.backendOp) : undefined;
24587
+ const rawExamples = rawSchema["examples"];
24588
+ const examples = Array.isArray(rawExamples) ? rawExamples.filter((example) => operation.backendOp === undefined || isJsonObject2(example) && isJsonObject2(example["parameters"]) && example["parameters"]["op"] === operation.backendOp) : undefined;
24589
+ return {
24590
+ ...baseContract,
24591
+ ...inputSchema === undefined ? {} : { inputSchema },
24592
+ ...examples !== undefined && examples.length > 0 ? { examples } : {}
24593
+ };
24594
+ }
24056
24595
  async function dispatchOperations(ctx, sub, args) {
24057
24596
  if (sub === "ls" || sub === "list") {
24058
24597
  const flags = parseLocalFlags(args, ["operations", "ls"]);
@@ -24073,8 +24612,8 @@ async function dispatchOperations(ctx, sub, args) {
24073
24612
  if (operation === undefined) {
24074
24613
  throw new CliError(`Unknown operation: ${operationId}. Run \`uru operations ls\`.`);
24075
24614
  }
24076
- const contract = operationForJson(operation);
24077
- emitValue(ctx, contract, formatOperationContract(contract));
24615
+ const { contract, text } = await operationContractForInspect(ctx, operation);
24616
+ emitValue(ctx, contract, text);
24078
24617
  return;
24079
24618
  }
24080
24619
  if (sub === "run") {
@@ -24091,7 +24630,13 @@ async function dispatchRegistryFamily(ctx, family, sub, args) {
24091
24630
  if (operation === undefined) {
24092
24631
  throw new CliError(`Unknown ${family} operation: ${verb}. Run \`uru operations ls --family ${family}\`.`);
24093
24632
  }
24094
- await emitTool(ctx, operation.id, adaptRegistryFamilyParams(await paramsJson(args, [family.replace("_", "-")], paramsJsonOptions(ctx))));
24633
+ const commandPath = [family.replace("_", "-")];
24634
+ if (parseLocalFlags(args, commandPath).booleans.has("--get-schema")) {
24635
+ const { contract, text } = await operationContractForInspect(ctx, operation);
24636
+ emitValue(ctx, contract, text);
24637
+ return;
24638
+ }
24639
+ await emitTool(ctx, operation.id, adaptRegistryFamilyParams(await paramsJson(args, commandPath, paramsJsonOptions(ctx))));
24095
24640
  }
24096
24641
  function adaptRegistryFamilyParams(params) {
24097
24642
  const adapted = {};
@@ -24111,7 +24656,14 @@ var REGISTRY_FAMILY_SNAKE_CASE_ALIASES = new Set([
24111
24656
  "item_id",
24112
24657
  "label_id",
24113
24658
  "label_value",
24114
- "max_results"
24659
+ "max_results",
24660
+ "source_id",
24661
+ "connection_id",
24662
+ "target_folder_id",
24663
+ "drive_id",
24664
+ "file_ids",
24665
+ "folder_ids",
24666
+ "sync_interval_minutes"
24115
24667
  ]);
24116
24668
  function canonicalCliFieldToToolProtocol(key) {
24117
24669
  if (REGISTRY_FAMILY_SNAKE_CASE_ALIASES.has(key)) {
@@ -24161,6 +24713,14 @@ async function dispatchLibrary(ctx, sub, args) {
24161
24713
  }, { textExtractor: extractLibraryTextContent });
24162
24714
  return;
24163
24715
  }
24716
+ if (sub === "source" || sub === "sources") {
24717
+ await dispatchLibrarySource(ctx, args[0], args.slice(1));
24718
+ return;
24719
+ }
24720
+ if (sub === "history") {
24721
+ await dispatchLibraryHistory(ctx, args);
24722
+ return;
24723
+ }
24164
24724
  if (sub === "write") {
24165
24725
  const flags = parseLocalFlags(args, ["library", "write"]);
24166
24726
  const path = requireCommandValue(flags.positionals[0], "Usage: uru library write <path> (--file <local-path>|--content <text>|--stdin) [--create] [--folder-id <id>]");
@@ -24244,7 +24804,96 @@ async function dispatchLibrary(ctx, sub, args) {
24244
24804
  await emitTool(ctx, "library.empty_trash", {});
24245
24805
  return;
24246
24806
  }
24247
- throw new CliError("Usage: uru library ls|stat|search|mkdir|read|write|patch|patch-preview|favorite|unfavorite|upload|cp|mv|rm|restore|empty-trash");
24807
+ throw new CliError("Usage: uru library ls|stat|search|mkdir|read|write|patch|patch-preview|favorite|unfavorite|source|history|upload|cp|mv|rm|restore|empty-trash");
24808
+ }
24809
+ async function dispatchLibrarySource(ctx, verb, args) {
24810
+ const normalizedVerb = verb === undefined || verb === "ls" || verb === "list" ? "list" : verb === "inspect" ? "get" : verb === "edit" || verb === "set" ? "edit" : verb === "connect" ? "create" : verb === "run" || verb === "sync" || verb === "run-now" ? "run-now" : verb === "delete" || verb === "rm" ? "remove" : verb;
24811
+ if (normalizedVerb === "list") {
24812
+ await emitTool(ctx, "library.sources_list", {});
24813
+ return;
24814
+ }
24815
+ if (normalizedVerb === "create") {
24816
+ const params = adaptRegistryFamilyParams(await paramsJson(args, ["library", "source", "create"], paramsJsonOptions(ctx)));
24817
+ await emitTool(ctx, "library.sources_create", params);
24818
+ return;
24819
+ }
24820
+ if (normalizedVerb === "edit") {
24821
+ const flags = parseLocalFlags(args, ["library", "source", "edit"]);
24822
+ const sourceId = requireCommandValue(flags.positionals[0], "Usage: uru library source edit <source-id> --params-json '{...}'");
24823
+ const params = adaptRegistryFamilyParams(await paramsJson(args, ["library", "source", "edit"], paramsJsonOptions(ctx)));
24824
+ params["source_id"] = sourceId;
24825
+ await emitTool(ctx, "library.sources_edit", params);
24826
+ return;
24827
+ }
24828
+ if (normalizedVerb === "get" || normalizedVerb === "pause" || normalizedVerb === "resume" || normalizedVerb === "run-now" || normalizedVerb === "cancel" || normalizedVerb === "remove") {
24829
+ const flags = parseLocalFlags(args, ["library", "source", normalizedVerb]);
24830
+ const sourceId = requireCommandValue(flags.positionals[0], `Usage: uru library source ${normalizedVerb} <source-id>`);
24831
+ const operationByVerb = {
24832
+ get: "library.sources_get",
24833
+ pause: "library.sources_pause",
24834
+ resume: "library.sources_resume",
24835
+ "run-now": "library.sources_run_now",
24836
+ cancel: "library.sources_cancel",
24837
+ remove: "library.sources_remove"
24838
+ };
24839
+ await emitTool(ctx, operationByVerb[normalizedVerb], {
24840
+ source_id: sourceId
24841
+ });
24842
+ return;
24843
+ }
24844
+ if (normalizedVerb === "reconnect") {
24845
+ const flags = parseLocalFlags(args, ["library", "source", "reconnect"]);
24846
+ const sourceId = requireCommandValue(flags.positionals[0], "Usage: uru library source reconnect <source-id> --params-json '{...}'");
24847
+ const params = adaptRegistryFamilyParams(await paramsJson(args, ["library", "source", "reconnect"], paramsJsonOptions(ctx)));
24848
+ params["source_id"] = sourceId;
24849
+ await emitTool(ctx, "library.sources_reconnect", params);
24850
+ return;
24851
+ }
24852
+ throw new CliError("Usage: uru library source list|get|inspect|create|edit|pause|resume|run-now|cancel|reconnect|remove <source-id>");
24853
+ }
24854
+ var LIBRARY_HISTORY_RESOURCE_TYPES = new Set([
24855
+ "prompt",
24856
+ "context",
24857
+ "persona",
24858
+ "automation",
24859
+ "file",
24860
+ "folder",
24861
+ "collection",
24862
+ "shortcut"
24863
+ ]);
24864
+ async function dispatchLibraryHistory(ctx, args) {
24865
+ const flags = parseLocalFlags(args, ["library", "history"]);
24866
+ const firstVerb = flags.positionals[0];
24867
+ const isDetail = firstVerb === "get" || firstVerb === "inspect" || firstVerb === "show";
24868
+ const values = isDetail ? flags.positionals.slice(1) : flags.positionals;
24869
+ const resourceType = requireCommandValue(values[0], "Usage: uru library history <resource-type> <resource-id> [--limit <n>] [--cursor <cursor>]");
24870
+ if (!LIBRARY_HISTORY_RESOURCE_TYPES.has(resourceType)) {
24871
+ throw new CliError(`Unknown Library history resource type ${JSON.stringify(resourceType)}`);
24872
+ }
24873
+ const resourceId = requireCommandValue(values[1], isDetail ? "Usage: uru library history get <resource-type> <resource-id> <revision>" : "Usage: uru library history <resource-type> <resource-id> [--limit <n>] [--cursor <cursor>]");
24874
+ if (isDetail) {
24875
+ const revision = requireCommandValue(values[2], "Usage: uru library history get <resource-type> <resource-id> <revision>");
24876
+ if (!/^[1-9][0-9]{0,19}$/u.test(revision)) {
24877
+ throw new CliError("Library history revision must be a positive integer.");
24878
+ }
24879
+ await emitTool(ctx, "library.history_get", {
24880
+ op: "get",
24881
+ resource_type: resourceType,
24882
+ resource_id: resourceId,
24883
+ revision
24884
+ });
24885
+ return;
24886
+ }
24887
+ const params = {
24888
+ op: "list",
24889
+ resource_type: resourceType,
24890
+ resource_id: resourceId,
24891
+ first: boundedIntegerFlag(flags, "--limit", 20, 100)
24892
+ };
24893
+ const cursor = flags.values["--cursor"];
24894
+ if (cursor !== undefined)
24895
+ params["after"] = cursor;
24896
+ await emitTool(ctx, "library.history_list", params);
24248
24897
  }
24249
24898
  var LIBRARY_UPLOAD_PREFLIGHT_VERBS = new Set([
24250
24899
  "preflight",
@@ -24425,9 +25074,17 @@ async function dispatchDatasets(ctx, sub, args) {
24425
25074
  return;
24426
25075
  }
24427
25076
  if (sub === "get" || sub === "inspect" || sub === "query" || sub === "history" || sub === "jobs") {
25077
+ if (sub === "jobs" && (args[0] === "get" || args[0] === "cancel")) {
25078
+ await dispatchDatasetJobCommand(ctx, args[0], args.slice(1));
25079
+ return;
25080
+ }
24428
25081
  await dispatchDatasetCommand(ctx, sub, args);
24429
25082
  return;
24430
25083
  }
25084
+ if (sub === "source") {
25085
+ await dispatchDatasetSourceCommand(ctx, args[0], args.slice(1));
25086
+ return;
25087
+ }
24431
25088
  await dispatchRegistryFamily(ctx, "datasets", sub, args);
24432
25089
  }
24433
25090
  async function dispatchDatasetCommand(ctx, sub, args) {
@@ -24496,6 +25153,108 @@ async function dispatchDatasetCommand(ctx, sub, args) {
24496
25153
  return;
24497
25154
  }
24498
25155
  }
25156
+ async function dispatchDatasetJobCommand(ctx, verb, args) {
25157
+ const flags = parseLocalFlags(args, ["datasets", "jobs", verb]);
25158
+ const datasetId = requireCommandValue(flags.positionals[0], `Usage: uru datasets jobs ${verb} <dataset-id> <job-id>`);
25159
+ const jobId = requireCommandValue(flags.positionals[1], `Usage: uru datasets jobs ${verb} <dataset-id> <job-id>`);
25160
+ await emitTool(ctx, verb === "get" ? "dataset.job_get" : "dataset.job_cancel", {
25161
+ dataset_id: datasetId,
25162
+ job_id: jobId
25163
+ });
25164
+ }
25165
+ function sourceParam(source, camelCase, snakeCase) {
25166
+ const value = source[camelCase] ?? source[snakeCase];
25167
+ return value === undefined ? undefined : value;
25168
+ }
25169
+ function sourceParamsFromResult(value) {
25170
+ const source = unwrapToolResult(value);
25171
+ if (!isJsonObject2(source)) {
25172
+ throw new CliError("Dataset has no external source to update.");
25173
+ }
25174
+ const params = {};
25175
+ const fields = [
25176
+ ["composioConnectionId", "composio_connection_id"],
25177
+ ["capabilityId", "capability_id"],
25178
+ ["supabaseRef", "supabase_ref"],
25179
+ ["baseQuery", "base_query"],
25180
+ ["idColumn", "id_column"],
25181
+ ["cursorColumn", "cursor_column"],
25182
+ ["allowedColumns", "allowed_columns"],
25183
+ ["cacheTtlSeconds", "cache_ttl_seconds"],
25184
+ ["enabled", "enabled"],
25185
+ ["ownerUserId", "owner_user_id"],
25186
+ ["relationSchema", "relation_schema"],
25187
+ ["relationName", "relation_name"],
25188
+ ["relationKind", "relation_kind"],
25189
+ ["pkColumns", "pk_columns"],
25190
+ ["idStrategy", "id_strategy"],
25191
+ ["cursorStrategy", "cursor_strategy"],
25192
+ ["writeEnabled", "write_enabled"],
25193
+ ["allowedWriteColumns", "allowed_write_columns"],
25194
+ ["optimisticConcurrencyColumn", "optimistic_concurrency_column"],
25195
+ ["syncMode", "sync_mode"],
25196
+ ["syncIntervalSeconds", "sync_interval_seconds"]
25197
+ ];
25198
+ for (const [camelCase, snakeCase] of fields) {
25199
+ const valueForField = sourceParam(source, camelCase, snakeCase);
25200
+ if (valueForField !== undefined) {
25201
+ params[snakeCase] = valueForField;
25202
+ }
25203
+ }
25204
+ return params;
25205
+ }
25206
+ async function dispatchDatasetSourceCommand(ctx, verb, args) {
25207
+ const normalizedVerb = verb === "inspect" ? "get" : verb === "edit" || verb === "connect" || verb === "create" || verb === "reconnect" ? "put" : verb === "run-now" ? "sync" : verb;
25208
+ if (normalizedVerb === "get") {
25209
+ const flags = parseLocalFlags(args, ["datasets", "source", "get"]);
25210
+ await emitTool(ctx, "dataset.external_source_get", {
25211
+ dataset_id: requireCommandValue(flags.positionals[0], "Usage: uru datasets source get|inspect <dataset-id>")
25212
+ });
25213
+ return;
25214
+ }
25215
+ if (normalizedVerb === "put" || normalizedVerb === "test") {
25216
+ const flags = parseLocalFlags(args, ["datasets", "source", normalizedVerb]);
25217
+ const datasetId = requireCommandValue(flags.positionals[0], `Usage: uru datasets source ${normalizedVerb} <dataset-id> --params-json '{...}'`);
25218
+ const params = adaptRegistryFamilyParams(await paramsJson(args, ["datasets", "source", normalizedVerb], paramsJsonOptions(ctx)));
25219
+ params["dataset_id"] ??= datasetId;
25220
+ await emitTool(ctx, normalizedVerb === "put" ? "dataset.external_source_put" : "dataset.external_source_test", params);
25221
+ return;
25222
+ }
25223
+ if (normalizedVerb === "pause" || normalizedVerb === "resume") {
25224
+ const flags = parseLocalFlags(args, ["datasets", "source", normalizedVerb]);
25225
+ const datasetId = requireCommandValue(flags.positionals[0], `Usage: uru datasets source ${normalizedVerb} <dataset-id>`);
25226
+ const current = await executeOperation(ctx, "dataset.external_source_get", {
25227
+ dataset_id: datasetId
25228
+ });
25229
+ const params = sourceParamsFromResult(current);
25230
+ params["dataset_id"] = datasetId;
25231
+ params["enabled"] = normalizedVerb === "resume";
25232
+ await emitTool(ctx, "dataset.external_source_put", params);
25233
+ return;
25234
+ }
25235
+ if (normalizedVerb === "sync") {
25236
+ const flags = parseLocalFlags(args, ["datasets", "source", "sync"]);
25237
+ const datasetId = requireCommandValue(flags.positionals[0], "Usage: uru datasets source sync|run-now <dataset-id> [--params-json '{...}']");
25238
+ const explicitParams = flags.values["--params-json"];
25239
+ const params = explicitParams === undefined ? {} : adaptRegistryFamilyParams(parseParamsJson(await readParamsJsonSource(explicitParams, paramsJsonOptions(ctx)), "--params-json"));
25240
+ params["dataset_id"] = datasetId;
25241
+ params["idempotency_key"] ??= flags.values["--idempotency-key"] ?? randomUUID();
25242
+ if (params["expected_dataset_revision"] === undefined || params["expected_schema_revision"] === undefined) {
25243
+ const dataset = unwrapToolResult(await executeOperation(ctx, "dataset.get", { dataset_id: datasetId }));
25244
+ if (!isJsonObject2(dataset)) {
25245
+ throw new CliError("Dataset metadata did not include revision values.");
25246
+ }
25247
+ params["expected_dataset_revision"] ??= dataset["revision"] ?? dataset["datasetRevision"] ?? null;
25248
+ params["expected_schema_revision"] ??= dataset["schemaRevision"] ?? dataset["schema_revision"] ?? null;
25249
+ }
25250
+ if (typeof params["expected_dataset_revision"] !== "string" || typeof params["expected_schema_revision"] !== "string") {
25251
+ throw new CliError("Dataset metadata did not include revision values.");
25252
+ }
25253
+ await emitTool(ctx, "dataset.external_source_sync", params);
25254
+ return;
25255
+ }
25256
+ throw new CliError("Usage: uru datasets source get|put|connect|create|reconnect|test|pause|resume|sync <dataset-id>");
25257
+ }
24499
25258
  async function dispatchAutomations(ctx, sub, args) {
24500
25259
  if (sub === "ls" || sub === "list") {
24501
25260
  const flags = parseLocalFlags(args, ["automations", "ls"]);
@@ -25709,6 +26468,121 @@ import { mkdir as mkdir4, readFile as readFile8, writeFile as writeFile3 } from
25709
26468
  import { join as join3, resolve as resolve6 } from "node:path";
25710
26469
  import { setTimeout as sleep2 } from "node:timers/promises";
25711
26470
 
26471
+ // ../../packages/types/src/artifacts/gemRequestWaterfall.ts
26472
+ var LEVEL_SEVERITY = {
26473
+ critical: 5,
26474
+ fatal: 5,
26475
+ error: 4,
26476
+ warn: 3,
26477
+ warning: 3,
26478
+ info: 2,
26479
+ debug: 1,
26480
+ trace: 0
26481
+ };
26482
+ var normalizedLevel = (value) => {
26483
+ const trimmed = (value ?? "").trim().toLowerCase();
26484
+ return trimmed === "" ? "info" : trimmed;
26485
+ };
26486
+ var timeOf = (line) => {
26487
+ const parsed = Date.parse(line.createdAt ?? "");
26488
+ return Number.isFinite(parsed) ? parsed : null;
26489
+ };
26490
+ var stepDuration = (line) => {
26491
+ const value = line.durationMs;
26492
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
26493
+ };
26494
+ var requestKey = (line) => {
26495
+ const trimmed = (line.requestId ?? "").trim();
26496
+ return trimmed === "" ? null : trimmed;
26497
+ };
26498
+ function worstLevel(lines) {
26499
+ let worst = "info";
26500
+ let severity = -1;
26501
+ for (const line of lines) {
26502
+ const level = normalizedLevel(line.level);
26503
+ const rank = LEVEL_SEVERITY[level] ?? 2;
26504
+ if (rank > severity) {
26505
+ severity = rank;
26506
+ worst = level;
26507
+ }
26508
+ }
26509
+ return worst;
26510
+ }
26511
+ function buildWaterfall(requestId, lines) {
26512
+ const ordered = [...lines].sort((left, right) => {
26513
+ const leftTime = timeOf(left);
26514
+ const rightTime = timeOf(right);
26515
+ if (leftTime === null && rightTime === null) {
26516
+ return 0;
26517
+ }
26518
+ if (leftTime === null) {
26519
+ return 1;
26520
+ }
26521
+ if (rightTime === null) {
26522
+ return -1;
26523
+ }
26524
+ return leftTime - rightTime;
26525
+ });
26526
+ const startTime = ordered.map(timeOf).find((value) => value !== null) ?? null;
26527
+ const steps = ordered.map((line) => {
26528
+ const time3 = timeOf(line);
26529
+ return {
26530
+ durationMs: stepDuration(line),
26531
+ line,
26532
+ offsetMs: time3 === null || startTime === null ? null : time3 - startTime
26533
+ };
26534
+ });
26535
+ const ends = steps.map((step) => step.offsetMs === null ? null : step.offsetMs + (step.durationMs ?? 0)).filter((value) => value !== null);
26536
+ const longestStep = steps.map((step) => step.durationMs).filter((value) => value !== null);
26537
+ const totalMs = ends.length > 0 ? Math.max(...ends) : longestStep.length > 0 ? Math.max(...longestStep) : null;
26538
+ const startedAt = ordered.find((line) => timeOf(line) !== null)?.createdAt ?? null;
26539
+ return {
26540
+ level: worstLevel(ordered),
26541
+ requestId,
26542
+ startedAt,
26543
+ steps,
26544
+ totalMs
26545
+ };
26546
+ }
26547
+ function gemRequestWaterfalls(lines) {
26548
+ const byRequest = new Map;
26549
+ const looseLines = [];
26550
+ const order = [];
26551
+ for (const line of lines) {
26552
+ const key = requestKey(line);
26553
+ if (key === null) {
26554
+ looseLines.push(line);
26555
+ continue;
26556
+ }
26557
+ const existing = byRequest.get(key);
26558
+ if (existing === undefined) {
26559
+ byRequest.set(key, [line]);
26560
+ order.push(key);
26561
+ continue;
26562
+ }
26563
+ existing.push(line);
26564
+ }
26565
+ return {
26566
+ looseLines,
26567
+ requests: order.map((key) => buildWaterfall(key, byRequest.get(key) ?? []))
26568
+ };
26569
+ }
26570
+ function formatGemRequestDuration(durationMs) {
26571
+ if (durationMs === null) {
26572
+ return "—";
26573
+ }
26574
+ if (durationMs < 1000) {
26575
+ return `${String(Math.round(durationMs))} ms`;
26576
+ }
26577
+ const seconds = durationMs / 1000;
26578
+ if (seconds < 60) {
26579
+ return `${seconds.toFixed(1)} s`;
26580
+ }
26581
+ const minutes = Math.floor(seconds / 60);
26582
+ const rest = Math.round(seconds - minutes * 60);
26583
+ return `${String(minutes)} m ${String(rest).padStart(2, "0")} s`;
26584
+ }
26585
+
25712
26586
  // src/gem-fs-commands.ts
25713
26587
  import { readFile as readFile6 } from "node:fs/promises";
25714
26588
  import { resolve as resolve5 } from "node:path";
@@ -25868,7 +26742,7 @@ async function dispatchGemFs(ctx, verb, args, linkedProject) {
25868
26742
  }
25869
26743
 
25870
26744
  // src/gem-git-source-commands.ts
25871
- import { randomUUID } from "node:crypto";
26745
+ import { randomUUID as randomUUID2 } from "node:crypto";
25872
26746
  var GIT_SOURCE_PATH = "/api/v1/artifacts";
25873
26747
  async function dispatchGemGitSource(ctx, verb, args, linkedProject) {
25874
26748
  if (verb === undefined || verb === "help") {
@@ -25884,8 +26758,8 @@ async function dispatchGemGitSource(ctx, verb, args, linkedProject) {
25884
26758
  const flags = parseLocalFlags(args, ["gems", "source", verb]);
25885
26759
  const reference = await resolveArtifactReference(ctx, flags, linkedProject);
25886
26760
  if (verb === "copy") {
25887
- const result2 = await client(ctx).api(`/api/platform/artifacts/${encodeURIComponent(reference.slug)}/clone`, { method: "POST" });
25888
- emitValue(ctx, result2, formatCloneResult(result2));
26761
+ const result2 = await client(ctx).api(`${GIT_SOURCE_PATH}/${encodeURIComponent(reference.artifactId)}/git-source/copy`, { method: "POST" });
26762
+ emitValue(ctx, result2, formatCopyResult(result2));
25889
26763
  return;
25890
26764
  }
25891
26765
  if (verb === "status") {
@@ -25905,7 +26779,7 @@ function commandFromFlags(verb, flags) {
25905
26779
  return toJsonCommand({
25906
26780
  action: "retry",
25907
26781
  importId: requiredImportId(flags, "retry"),
25908
- idempotencyKey: flags.values["--idempotency-key"]?.trim() || randomUUID()
26782
+ idempotencyKey: flags.values["--idempotency-key"]?.trim() || randomUUID2()
25909
26783
  });
25910
26784
  case "cancel":
25911
26785
  return toJsonCommand({
@@ -25947,10 +26821,7 @@ async function resolveArtifactReference(ctx, flags, linkedProject) {
25947
26821
  if (artifactId === undefined) {
25948
26822
  throw new CliError(`Gem inspection did not return an artifact id for ${reference}.`);
25949
26823
  }
25950
- return {
25951
- artifactId,
25952
- slug: findArtifactSlug(inspected) ?? artifactId
25953
- };
26824
+ return { artifactId };
25954
26825
  }
25955
26826
  function findArtifactId(value) {
25956
26827
  if (isJsonObject2(value)) {
@@ -25984,34 +26855,6 @@ function findArtifactId(value) {
25984
26855
  function isUuid(value) {
25985
26856
  return /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(value);
25986
26857
  }
25987
- function findArtifactSlug(value) {
25988
- if (isJsonObject2(value)) {
25989
- const slug = stringField2(value, [
25990
- "artifact_slug",
25991
- "artifactSlug",
25992
- "slug"
25993
- ]);
25994
- if (slug !== undefined && !slug.includes("/")) {
25995
- return slug;
25996
- }
25997
- for (const nested of Object.values(value)) {
25998
- const found = findArtifactSlug(nested);
25999
- if (found !== undefined) {
26000
- return found;
26001
- }
26002
- }
26003
- return;
26004
- }
26005
- if (Array.isArray(value)) {
26006
- for (const nested of value) {
26007
- const found = findArtifactSlug(nested);
26008
- if (found !== undefined) {
26009
- return found;
26010
- }
26011
- }
26012
- }
26013
- return;
26014
- }
26015
26858
  function requiredImportId(flags, verb) {
26016
26859
  const importId = flags.values["--import-id"]?.trim();
26017
26860
  if (!importId) {
@@ -26119,23 +26962,25 @@ function formatGitSourceState(value) {
26119
26962
  return lines.length === 0 ? JSON.stringify(value, null, 2) : lines.join(`
26120
26963
  `);
26121
26964
  }
26122
- function formatCloneResult(value) {
26965
+ function formatCopyResult(value) {
26123
26966
  const record2 = isJsonObject2(value) ? value : undefined;
26124
- const artifactId = record2 === undefined ? undefined : stringField2(record2, ["id", "artifactId", "artifact_id"]);
26967
+ const artifactId = record2 === undefined ? undefined : stringField2(record2, ["artifactId", "artifact_id", "id"]);
26125
26968
  const title = record2 === undefined ? undefined : stringField2(record2, ["title"]);
26969
+ const commitSha = record2 === undefined ? undefined : stringField2(record2, ["copiedFromCommitSha", "copied_from_commit_sha"]);
26126
26970
  if (artifactId === undefined && title === undefined) {
26127
26971
  return JSON.stringify(value, null, 2);
26128
26972
  }
26129
26973
  return [
26130
- "Gem copied.",
26131
- artifactId === undefined ? undefined : `Artifact: ${artifactId}`,
26132
- title === undefined ? undefined : `Title: ${title}`
26974
+ "Made an editable copy. It is not linked to the repository.",
26975
+ artifactId === undefined ? undefined : `Gem: ${artifactId}`,
26976
+ title === undefined ? undefined : `Title: ${title}`,
26977
+ commitSha === undefined ? undefined : `From commit: ${commitSha.slice(0, 7)}`
26133
26978
  ].filter((line) => line !== undefined).join(`
26134
26979
  `);
26135
26980
  }
26136
26981
 
26137
26982
  // src/held-idempotency-keys.ts
26138
- import { createHash as createHash3, randomUUID as randomUUID2 } from "node:crypto";
26983
+ import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
26139
26984
  import { constants } from "node:fs";
26140
26985
  import { chmod, link, mkdir as mkdir3, open, readFile as readFile7, rename, rm as rm2 } from "node:fs/promises";
26141
26986
  import { dirname as dirname4, join as join2 } from "node:path";
@@ -26150,7 +26995,7 @@ async function holdIdempotencyKey(io, stateHome, intent, now = new Date) {
26150
26995
  return withHeldEntriesLock(path, async () => {
26151
26996
  const stored = await readHeldEntries(path);
26152
26997
  const existing = stored[fingerprint];
26153
- const owner = `${process.pid}:${randomUUID2()}`;
26998
+ const owner = `${process.pid}:${randomUUID3()}`;
26154
26999
  if (existing !== undefined) {
26155
27000
  const updated = {
26156
27001
  ...existing,
@@ -26162,7 +27007,7 @@ async function holdIdempotencyKey(io, stateHome, intent, now = new Date) {
26162
27007
  release: () => releaseHold(io, path, fingerprint, existing.key, owner)
26163
27008
  };
26164
27009
  }
26165
- const key = randomUUID2();
27010
+ const key = randomUUID3();
26166
27011
  await writeHeldEntries(path, {
26167
27012
  ...stored,
26168
27013
  [fingerprint]: { key, heldAt: now.toISOString(), owners: [owner] }
@@ -26272,7 +27117,7 @@ async function withHeldEntriesLock(path, action) {
26272
27117
  continue;
26273
27118
  }
26274
27119
  try {
26275
- const lockToken = randomUUID2();
27120
+ const lockToken = randomUUID3();
26276
27121
  const contents = `${process.pid}
26277
27122
  ${lockToken}
26278
27123
  `;
@@ -26355,7 +27200,7 @@ async function tryCreateHeldLock(path) {
26355
27200
  }
26356
27201
  try {
26357
27202
  const contents = `${process.pid}
26358
- ${randomUUID2()}
27203
+ ${randomUUID3()}
26359
27204
  `;
26360
27205
  await handle.writeFile(contents, "utf8");
26361
27206
  await handle.sync();
@@ -26414,7 +27259,7 @@ async function readHeldLockObservation(path) {
26414
27259
  }
26415
27260
  }
26416
27261
  async function removeHeldLockIfMatches(path, expected) {
26417
- const quarantinePath = `${path}.${process.pid}.${randomUUID2()}.quarantine`;
27262
+ const quarantinePath = `${path}.${process.pid}.${randomUUID3()}.quarantine`;
26418
27263
  try {
26419
27264
  await rename(path, quarantinePath);
26420
27265
  await syncParentDirectory(path);
@@ -26474,7 +27319,7 @@ async function writeHeldEntries(path, entries) {
26474
27319
  }
26475
27320
  const body = `${JSON.stringify(entries, null, 2)}
26476
27321
  `;
26477
- const temporaryPath = `${path}.${process.pid}.${randomUUID2()}.tmp`;
27322
+ const temporaryPath = `${path}.${process.pid}.${randomUUID3()}.tmp`;
26478
27323
  let handle = null;
26479
27324
  try {
26480
27325
  handle = await open(temporaryPath, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY, constants.S_IRUSR | constants.S_IWUSR);
@@ -26594,6 +27439,10 @@ async function dispatchGemLifecycleResourceCommand(ctx, sub, args, linkedProject
26594
27439
  await dispatchGemSchedules(ctx, args, linkedProject);
26595
27440
  return true;
26596
27441
  }
27442
+ if (sub === "events") {
27443
+ await dispatchGemEvents(ctx, args, linkedProject);
27444
+ return true;
27445
+ }
26597
27446
  if (sub === "bindings") {
26598
27447
  await dispatchGemBindings(ctx, args, linkedProject);
26599
27448
  return true;
@@ -26650,11 +27499,11 @@ async function dispatchGemVersions(ctx, args, linkedProject) {
26650
27499
  });
26651
27500
  return;
26652
27501
  }
26653
- if (verb === "show" || verb === "restore" || verb === "preview") {
27502
+ if (verb === "show" || verb === "restore" || verb === "preview" || verb === "retry") {
26654
27503
  const flags = parseLocalFlags(rest, ["gems", "versions", verb]);
26655
27504
  const version2 = lifecycleResourceArg(flags, `Usage: uru gems versions ${verb} <gem> <version>`);
26656
27505
  const path = gemPathFromArgs(flags, linkedProject);
26657
- await emitGemTool(ctx, verb === "show" ? "gem.version_get" : verb === "restore" ? "gem.version_restore" : "gem.version_preview", { path, version_id: version2 }, verb === "restore" ? { textExtractor: extractVersionRestoreSummary } : undefined);
27506
+ await emitGemTool(ctx, verb === "show" ? "gem.version_get" : verb === "restore" ? "gem.version_restore" : verb === "retry" ? "gem.version_retry" : "gem.version_preview", { path, version_id: version2 }, verb === "restore" ? { textExtractor: extractVersionRestoreSummary } : verb === "retry" ? { textExtractor: extractVersionRetrySummary } : undefined);
26658
27507
  return;
26659
27508
  }
26660
27509
  if (verb === "diff") {
@@ -26667,7 +27516,7 @@ async function dispatchGemVersions(ctx, args, linkedProject) {
26667
27516
  });
26668
27517
  return;
26669
27518
  }
26670
- throw new CliError("Usage: uru gems versions list <gem> | save|upload <gem> [--name ...] [--message ...] | deploy <gem> <version> | show <gem> <version> | diff <gem> <from> <to> | restore <gem> <version> | preview <gem> <version>");
27519
+ throw new CliError("Usage: uru gems versions list <gem> | save|upload <gem> [--name ...] [--message ...] | deploy <gem> <version> | show <gem> <version> | diff <gem> <from> <to> | restore <gem> <version> | preview <gem> <version> | retry <gem> <version>");
26671
27520
  }
26672
27521
  async function gemVersionSave(ctx, args, linkedProject, commandPath = ["gems", "versions", "save"]) {
26673
27522
  const flags = parseLocalFlags(args, commandPath);
@@ -26873,6 +27722,8 @@ async function dispatchGemRuns(ctx, args, linkedProject) {
26873
27722
  };
26874
27723
  copyStringFlag(flags, params, "--cursor", "cursor");
26875
27724
  copyStringFlag(flags, params, "--status", "status");
27725
+ copyStringFlag(flags, params, "--environment", "environment");
27726
+ copyStringFlag(flags, params, "--version", "version_id");
26876
27727
  copyOptionalIntegerFlag(flags, params, "--limit", "limit");
26877
27728
  await emitGemTool(ctx, "gem.runs_list", params, {
26878
27729
  textExtractor: (value) => formatGemResourceList("runs", value)
@@ -26946,6 +27797,59 @@ async function dispatchGemSchedules(ctx, args, linkedProject) {
26946
27797
  }
26947
27798
  throw new CliError("Usage: uru gems schedules list <gem> | arm|pause|resume <gem> <capability> | run <gem> <capability> --idempotency-key <key>");
26948
27799
  }
27800
+ async function dispatchGemEvents(ctx, args, linkedProject) {
27801
+ const [verb, ...rest] = args;
27802
+ if (verb === "list") {
27803
+ const flags = parseLocalFlags(rest, ["gems", "events", "list"]);
27804
+ await emitGemTool(ctx, "gem.event_targets_list", {
27805
+ path: gemPathFromArgs(flags, linkedProject)
27806
+ });
27807
+ return;
27808
+ }
27809
+ if (verb === "pause" || verb === "resume") {
27810
+ const flags = parseLocalFlags(rest, ["gems", "events", verb]);
27811
+ const targetId = lifecycleResourceArg(flags, `Usage: uru gems events ${verb} <gem> <target-id>`);
27812
+ await emitGemTool(ctx, "gem.event_target_update", {
27813
+ path: gemPathFromArgs(flags, linkedProject),
27814
+ target_id: targetId,
27815
+ state: verb === "pause" ? "paused" : "active"
27816
+ });
27817
+ return;
27818
+ }
27819
+ if (verb === "update") {
27820
+ const flags = parseLocalFlags(rest, ["gems", "events", "update"]);
27821
+ const targetId = lifecycleResourceArg(flags, "Usage: uru gems events update <gem> <target-id> [--state active|paused] [--input-json '{...}']");
27822
+ const state = flags.values["--state"];
27823
+ const inputJson = flags.values["--input-json"];
27824
+ if (state === undefined && inputJson === undefined) {
27825
+ throw new CliError("Usage: uru gems events update <gem> <target-id> [--state active|paused] [--input-json '{...}']");
27826
+ }
27827
+ if (state !== undefined && state !== "active" && state !== "paused") {
27828
+ throw new CliError("--state must be active or paused");
27829
+ }
27830
+ const params = {
27831
+ path: gemPathFromArgs(flags, linkedProject),
27832
+ target_id: targetId,
27833
+ ...state === undefined ? {} : { state }
27834
+ };
27835
+ if (inputJson !== undefined) {
27836
+ params["input"] = parseParamsJson(inputJson, "--input-json");
27837
+ }
27838
+ await emitGemTool(ctx, "gem.event_target_update", params);
27839
+ return;
27840
+ }
27841
+ if (verb === "run" || verb === "run-now") {
27842
+ const flags = parseLocalFlags(rest, ["gems", "events", verb]);
27843
+ const targetId = lifecycleResourceArg(flags, `Usage: uru gems events ${verb} <gem> <target-id> --idempotency-key <key>`);
27844
+ await emitGemTool(ctx, "gem.event_target_run_now", {
27845
+ path: gemPathFromArgs(flags, linkedProject),
27846
+ target_id: targetId,
27847
+ idempotency_key: requireCommandValue(flags.values["--idempotency-key"], `Usage: uru gems events ${verb} <gem> <target-id> --idempotency-key <key>`)
27848
+ });
27849
+ return;
27850
+ }
27851
+ throw new CliError("Usage: uru gems events list <gem> | update <gem> <target-id> [--state active|paused] [--input-json '{...}'] | pause|resume <gem> <target-id> | run <gem> <target-id> --idempotency-key <key>");
27852
+ }
26949
27853
  async function gemDeployRelease(ctx, args, linkedProject) {
26950
27854
  const flags = parseLocalFlags(args, ["gems", "deploy"]);
26951
27855
  const versionId = lifecycleResourceArg(flags, "Usage: uru gems deploy <version> [library/name.gem] [--link <name>] [--pin]");
@@ -27013,6 +27917,20 @@ async function dispatchGemBuildDiagnostics(ctx, verb, args, linkedProject) {
27013
27917
  path: gemPathFromArgs(flags, linkedProject)
27014
27918
  });
27015
27919
  }
27920
+ async function bindingChoicesUpsert(ctx, flags, path) {
27921
+ const usage = `Usage: uru gems bindings upsert [library/name.gem] --binding-choices '{"role":"connection_ref"}' --expected-binding-set-version <n> --expected-binding-set-hash <hash>`;
27922
+ const bindingChoices = parseParamsJson(requireCommandValue(flags.values["--binding-choices"], usage), "--binding-choices");
27923
+ const version2 = Number.parseInt(requireCommandValue(flags.values["--expected-binding-set-version"], usage), 10);
27924
+ if (!Number.isInteger(version2) || version2 < 1) {
27925
+ throw new CliError("--expected-binding-set-version must be a positive integer");
27926
+ }
27927
+ await emitGemTool(ctx, "gem.upsert_binding", {
27928
+ path,
27929
+ binding_choices: bindingChoices,
27930
+ expected_binding_set_version: version2,
27931
+ expected_binding_set_hash: requireCommandValue(flags.values["--expected-binding-set-hash"], usage)
27932
+ });
27933
+ }
27016
27934
  async function dispatchGemBindings(ctx, args, linkedProject) {
27017
27935
  const [verb, ...rest] = args;
27018
27936
  if (verb === "list") {
@@ -27024,18 +27942,20 @@ async function dispatchGemBindings(ctx, args, linkedProject) {
27024
27942
  }
27025
27943
  if (verb === "upsert") {
27026
27944
  const flags = parseLocalFlags(rest, ["gems", "bindings", "upsert"]);
27945
+ const path = gemPathFromArgs(flags, linkedProject);
27946
+ if (flags.values["--binding-choices"] !== undefined) {
27947
+ await bindingChoicesUpsert(ctx, flags, path);
27948
+ return;
27949
+ }
27027
27950
  const usage = "Usage: uru gems bindings upsert [library/name.gem] --source-ref-type <type> --source-ref <ref> --target-resource-type <type>";
27028
27951
  const params = {
27029
- path: gemPathFromArgs(flags, linkedProject),
27952
+ path,
27030
27953
  source_ref_type: requireCommandValue(flags.values["--source-ref-type"], usage),
27031
27954
  source_ref: requireCommandValue(flags.values["--source-ref"], usage),
27032
27955
  target_resource_type: requireCommandValue(flags.values["--target-resource-type"], usage)
27033
27956
  };
27034
27957
  copyStringFlag(flags, params, "--target-resource-id", "target_resource_id");
27035
27958
  copyStringFlag(flags, params, "--target-resource-ref", "target_resource_ref");
27036
- copyStringFlag(flags, params, "--tool-connection-id", "tool_connection_id");
27037
- copyStringFlag(flags, params, "--tool-capability-id", "tool_capability_id");
27038
- copyStringFlag(flags, params, "--environment-key", "environment_key");
27039
27959
  copyStringFlag(flags, params, "--binding-status", "binding_status");
27040
27960
  copyStringFlag(flags, params, "--policy-level", "policy_level");
27041
27961
  await emitGemTool(ctx, "gem.upsert_binding", params);
@@ -27170,6 +28090,10 @@ function extractVersionRestoreSummary(value) {
27170
28090
  const version2 = versionLabel(value, "version");
27171
28091
  return `Restored Version${version2 === null ? "" : ` ${version2}`} to Draft. No Links changed.`;
27172
28092
  }
28093
+ function extractVersionRetrySummary(value) {
28094
+ const version2 = versionLabel(value, "version");
28095
+ return `Building Version${version2 === null ? "" : ` ${version2}`} again. Read it with uru gems versions show until build_id is set. No Links changed.`;
28096
+ }
27173
28097
  function extractReleaseSummary(value) {
27174
28098
  const release = directResultObject(value, "release");
27175
28099
  const version2 = versionLabelFromObject(release?.["version"] ?? release);
@@ -27342,6 +28266,10 @@ async function dispatchGems(ctx, sub, args, linkedProject) {
27342
28266
  await gemLogs(ctx, args, linkedProject, ["gems", "logs"]);
27343
28267
  return;
27344
28268
  }
28269
+ if (sub === "debug-token") {
28270
+ await gemDebugToken(ctx, args, linkedProject);
28271
+ return;
28272
+ }
27345
28273
  if (sub === "status") {
27346
28274
  const flags = parseLocalFlags(args, ["gems", "status"]);
27347
28275
  await emitGemTool(ctx, "gem.status", {
@@ -27361,7 +28289,7 @@ async function dispatchGems(ctx, sub, args, linkedProject) {
27361
28289
  await gemWrite(ctx, args);
27362
28290
  return;
27363
28291
  }
27364
- throw new CliError("Usage: uru gems inspect|validate|build|deploy|verify|fs|edits|versions|releases|links|runs|capabilities|schedules|bindings|components|delegations|api|domains|analytics|power|checks|status|source|read|write");
28292
+ throw new CliError("Usage: uru gems inspect|validate|build|deploy|verify|fs|edits|versions|releases|links|runs|capabilities|schedules|events|bindings|components|delegations|api|domains|analytics|power|checks|status|source|read|write|logs|debug-token");
27365
28293
  }
27366
28294
  async function dispatchGemOperationalResourceCommand(ctx, sub, args, linkedProject) {
27367
28295
  if (sub === "domains") {
@@ -27546,9 +28474,13 @@ async function gemValidate(ctx, args, linkedProject) {
27546
28474
  async function gemBuild(ctx, args, linkedProject, commandPath = ["build"]) {
27547
28475
  const flags = parseLocalFlags(args, commandPath);
27548
28476
  const outdir = flags.values["--outdir"];
28477
+ const dryRun = flags.booleans.has("--dry-run");
28478
+ if (dryRun && flags.booleans.has("--force")) {
28479
+ throw new CliError("--force cannot be combined with --dry-run. A dry run only validates a build plan; it never rebuilds or persists.");
28480
+ }
27549
28481
  await enqueueGemHostedJob(ctx, flags, linkedProject, {
27550
- operationId: "gem.build",
27551
- force: true,
28482
+ operationId: dryRun ? "gem.validate" : "gem.build",
28483
+ force: !dryRun,
27552
28484
  ...outdir === undefined ? {} : { outdir }
27553
28485
  });
27554
28486
  }
@@ -27567,9 +28499,6 @@ async function enqueueGemHostedJob(ctx, flags, linkedProject, options) {
27567
28499
  if (options.force && flags.booleans.has("--force")) {
27568
28500
  params["force"] = true;
27569
28501
  }
27570
- if (flags.booleans.has("--dry-run")) {
27571
- params["dry_run"] = true;
27572
- }
27573
28502
  copyStringFlag(flags, params, "--source-revision-id", "source_revision_id");
27574
28503
  if (ctx.outputFormat === "stream-json") {
27575
28504
  writeStreamJson(ctx.io, "started", {
@@ -27675,6 +28604,15 @@ function emitGemHostedJobSync(ctx, job) {
27675
28604
  }
27676
28605
  writeText(ctx.io, status === "" ? `hosted_job_id ${hostedJobId}` : `hosted_job_id ${hostedJobId} status ${status}`);
27677
28606
  }
28607
+ async function gemDebugToken(ctx, args, linkedProject) {
28608
+ const flags = parseLocalFlags(args, ["gems", "debug-token"]);
28609
+ const params = {
28610
+ path: gemPathFromArgs(flags, linkedProject)
28611
+ };
28612
+ copyStringFlag(flags, params, "--deployment", "deployment_id");
28613
+ copyOptionalPositiveIntegerFlag(flags, params, "--ttl-seconds", "ttl_seconds");
28614
+ await emitGemTool(ctx, "gem.debug_token", params);
28615
+ }
27678
28616
  async function gemLogs(ctx, args, linkedProject, commandPath = ["logs"]) {
27679
28617
  const flags = parseLocalFlags(args, commandPath);
27680
28618
  const params = {
@@ -27684,28 +28622,71 @@ async function gemLogs(ctx, args, linkedProject, commandPath = ["logs"]) {
27684
28622
  copyStringFlag(flags, params, "--level", "level");
27685
28623
  copyStringFlag(flags, params, "--release", "release_id");
27686
28624
  copyStringFlag(flags, params, "--run", "run_id");
28625
+ copyStringFlag(flags, params, "--request-id", "request_id");
28626
+ copyStringFlag(flags, params, "--since", "since");
28627
+ copyStringFlag(flags, params, "--until", "until");
28628
+ copyStringFlag(flags, params, "--cursor", "cursor");
28629
+ const exportPath = flags.values["--export"];
27687
28630
  if (flags.booleans.has("--follow")) {
27688
28631
  await followGemLogs(ctx, params, {
27689
28632
  durationMs: boundedIntegerFlag(flags, "--follow-duration-ms", DEFAULT_LOG_FOLLOW_DURATION_MS, MAX_LOG_FOLLOW_DURATION_MS),
27690
- pollIntervalMs: boundedIntegerFlag(flags, "--poll-interval-ms", DEFAULT_LOG_FOLLOW_POLL_INTERVAL_MS, MAX_LOG_FOLLOW_POLL_INTERVAL_MS)
28633
+ ...exportPath === undefined ? {} : { exportPath }
27691
28634
  });
27692
28635
  return;
27693
28636
  }
27694
- await emitGemTool(ctx, "gem.logs", params);
28637
+ if (flags.values["--request-id"] !== undefined && !ctx.json && ctx.outputFormat === "text") {
28638
+ const unwrapped = unwrapToolResult(await executeOperation(ctx, "gem.logs", params));
28639
+ const entries = normalizeLogEntries(unwrapped).map((entry) => entry.value);
28640
+ writeText(ctx.io, formatRequestWaterfalls(entries));
28641
+ if (exportPath !== undefined) {
28642
+ await exportLogEntries(ctx, exportPath, entries);
28643
+ }
28644
+ return;
28645
+ }
28646
+ const payload = await emitGemTool(ctx, "gem.logs", params);
28647
+ if (exportPath !== undefined) {
28648
+ await exportLogEntries(ctx, exportPath, normalizeLogEntries(payload ?? null).map((entry) => entry.value));
28649
+ }
28650
+ }
28651
+ function waterfallLine(entry, index) {
28652
+ const durationRaw = entry["duration_ms"] ?? entry["durationMs"];
28653
+ return {
28654
+ createdAt: stringJsonField(entry, ["created_at", "createdAt", "timestamp"]) ?? null,
28655
+ durationMs: typeof durationRaw === "number" ? durationRaw : null,
28656
+ entry,
28657
+ id: stringJsonField(entry, ["id", "log_id"]) ?? `index:${String(index)}`,
28658
+ level: stringJsonField(entry, ["level"]) ?? null,
28659
+ requestId: stringJsonField(entry, ["request_id", "requestId"]) ?? null
28660
+ };
28661
+ }
28662
+ function formatRequestWaterfalls(entries) {
28663
+ const { looseLines, requests } = gemRequestWaterfalls(entries.map((entry, index) => waterfallLine(entry, index)));
28664
+ if (requests.length === 0 && looseLines.length === 0) {
28665
+ return "No log lines for that request.";
28666
+ }
28667
+ const blocks = requests.map((request) => {
28668
+ const head = stripTerminalControl(`${request.requestId} ${request.startedAt ?? "not recorded"} ${formatGemRequestDuration(request.totalMs)} ${request.level.toUpperCase()}`);
28669
+ const steps = request.steps.map((step) => {
28670
+ const offset = step.offsetMs === null ? " —" : `+${formatGemRequestDuration(step.offsetMs)}`;
28671
+ const took = step.durationMs === null ? "" : ` (${formatGemRequestDuration(step.durationMs)})`;
28672
+ return ` ${offset.padStart(10)}${took.padEnd(10)} ${formatLogEntry(step.line.entry)}`;
28673
+ });
28674
+ return [head, ...steps].join(`
28675
+ `);
28676
+ });
28677
+ const loose = looseLines.map((entry) => formatLogEntry(entry.entry));
28678
+ return [...blocks, ...loose].join(`
28679
+ `);
27695
28680
  }
27696
28681
  var DEFAULT_LOG_FOLLOW_DURATION_MS = 30 * 60 * 1000;
27697
28682
  var MAX_LOG_FOLLOW_DURATION_MS = 30 * 60 * 1000;
27698
- var DEFAULT_LOG_FOLLOW_POLL_INTERVAL_MS = 1000;
27699
- var MAX_LOG_FOLLOW_POLL_INTERVAL_MS = 30000;
27700
- var MIN_LOG_FOLLOW_POLLS = 2;
27701
28683
  async function followGemLogs(ctx, params, options) {
27702
28684
  const path = typeof params["path"] === "string" ? params["path"] : undefined;
27703
28685
  if (ctx.outputFormat === "stream-json") {
27704
28686
  writeStreamJson(ctx.io, "started", {
27705
28687
  operation: "gem.logs.follow",
27706
28688
  ...path === undefined ? {} : { path },
27707
- duration_ms: options.durationMs,
27708
- poll_interval_ms: options.pollIntervalMs
28689
+ duration_ms: options.durationMs
27709
28690
  });
27710
28691
  } else {
27711
28692
  ctx.io.stderr.write(`Following Gem logs for up to ${Math.ceil(options.durationMs / 1000)}s. Press Ctrl-C to stop.
@@ -27713,66 +28694,46 @@ async function followGemLogs(ctx, params, options) {
27713
28694
  }
27714
28695
  const seen = new Set;
27715
28696
  const deadline = Date.now() + options.durationMs;
27716
- let pollCount = 0;
27717
28697
  let resumeCursor = null;
27718
- let attemptedStream = false;
27719
- while (true) {
27720
- pollCount += 1;
27721
- emitLogFollowPhase(ctx, "polling", pollCount);
27722
- const result = await executeOperation(ctx, "gem.logs", params);
27723
- const unwrapped = unwrapToolResult(result);
27724
- for (const entry of normalizeLogEntries(unwrapped)) {
27725
- if (seen.has(entry.key)) {
27726
- continue;
27727
- }
27728
- seen.add(entry.key);
27729
- emitFollowLogEntry(ctx, entry.value);
27730
- resumeCursor = newerLogCursor(resumeCursor, entry.value);
27731
- }
27732
- if (!attemptedStream) {
27733
- attemptedStream = true;
27734
- const remainingMs2 = deadline - Date.now();
27735
- const slug = resolveLogStreamArtifactSlug(params, unwrapped);
27736
- if (slug !== null && remainingMs2 > 0) {
27737
- const outcome = await followRuntimeLogSse(ctx, {
27738
- slug,
27739
- params,
27740
- resumeCursor,
27741
- seen,
27742
- remainingMs: remainingMs2
27743
- });
27744
- if (outcome.kind === "ended") {
27745
- emitFollowStreamEnded(ctx, seen.size);
27746
- return;
27747
- }
27748
- if (outcome.kind === "timeout") {
27749
- emitFollowTimeout(ctx, options.durationMs, pollCount, seen.size);
27750
- return;
27751
- }
27752
- resumeCursor = outcome.resumeCursor;
27753
- }
27754
- }
27755
- const remainingMs = deadline - Date.now();
27756
- if (remainingMs <= 0) {
27757
- if (pollCount >= MIN_LOG_FOLLOW_POLLS) {
27758
- break;
27759
- }
27760
- if (ctx.abortSignal.aborted) {
27761
- throw new CliError("Cancelled.", {
27762
- code: ExitCode.Cancelled,
27763
- cause: ctx.abortSignal.reason
27764
- });
27765
- }
28698
+ const exported = [];
28699
+ emitLogFollowPhase(ctx, "history");
28700
+ const unwrapped = unwrapToolResult(await executeOperation(ctx, "gem.logs", params));
28701
+ for (const entry of normalizeLogEntries(unwrapped)) {
28702
+ if (seen.has(entry.key)) {
27766
28703
  continue;
27767
28704
  }
27768
- await sleep2(Math.min(options.pollIntervalMs, remainingMs), undefined, {
27769
- signal: ctx.abortSignal
27770
- });
28705
+ seen.add(entry.key);
28706
+ emitFollowLogEntry(ctx, entry.value);
28707
+ if (options.exportPath !== undefined) {
28708
+ exported.push(entry.value);
28709
+ }
28710
+ resumeCursor = newerLogCursor(resumeCursor, entry.value);
28711
+ }
28712
+ const slug = resolveLogStreamArtifactSlug(params, unwrapped);
28713
+ if (slug === null) {
28714
+ await finishLogExport(ctx, options.exportPath, exported);
28715
+ throw new CliError("Gem logs --follow needs the Gem id. Pass --gem <gem-id> or run inside a linked Gem project.", { errorCode: "gem_logs_follow_gem_unresolved" });
28716
+ }
28717
+ const outcome = await followRuntimeLogSse(ctx, {
28718
+ slug,
28719
+ params,
28720
+ resumeCursor,
28721
+ seen,
28722
+ exported,
28723
+ remainingMs: Math.max(deadline - Date.now(), 0)
28724
+ });
28725
+ await finishLogExport(ctx, options.exportPath, exported);
28726
+ if (outcome.kind === "not_found") {
28727
+ throw new CliError(`Gem ${slug} has no runtime log stream. Create a Release, then follow its logs.`, { errorCode: "gem_logs_stream_unavailable" });
27771
28728
  }
27772
- emitFollowTimeout(ctx, options.durationMs, pollCount, seen.size);
28729
+ if (outcome.kind === "timeout") {
28730
+ emitFollowTimeout(ctx, options.durationMs, seen.size);
28731
+ return;
28732
+ }
28733
+ emitFollowStreamEnded(ctx, seen.size);
27773
28734
  }
27774
28735
  async function followRuntimeLogSse(ctx, args) {
27775
- emitLogFollowPhase(ctx, "streaming", 0);
28736
+ emitLogFollowPhase(ctx, "streaming");
27776
28737
  const timeout = AbortSignal.timeout(args.remainingMs);
27777
28738
  let resumeCursor = args.resumeCursor;
27778
28739
  try {
@@ -27782,14 +28743,17 @@ async function followRuntimeLogSse(ctx, args) {
27782
28743
  ...typeof args.params["limit"] === "number" ? { limit: args.params["limit"] } : {},
27783
28744
  ...typeof args.params["level"] === "string" ? { level: args.params["level"] } : {},
27784
28745
  ...typeof args.params["release_id"] === "string" ? { releaseId: args.params["release_id"] } : {},
27785
- ...typeof args.params["run_id"] === "string" ? { runtimeRunId: args.params["run_id"] } : {}
28746
+ ...typeof args.params["run_id"] === "string" ? { runtimeRunId: args.params["run_id"] } : {},
28747
+ ...typeof args.params["request_id"] === "string" ? { requestId: args.params["request_id"] } : {},
28748
+ ...typeof args.params["since"] === "string" ? { since: args.params["since"] } : {},
28749
+ ...typeof args.params["until"] === "string" ? { until: args.params["until"] } : {}
27786
28750
  },
27787
28751
  ...resumeCursor === null ? {} : { lastEventId: resumeCursor },
27788
28752
  signal: timeout,
27789
28753
  cliOperation: "gem.logs.follow"
27790
28754
  });
27791
28755
  if (streamed.notFound === true || streamed.stream === undefined) {
27792
- return { kind: "not_found", resumeCursor };
28756
+ return { kind: "not_found" };
27793
28757
  }
27794
28758
  for await (const event of parseSseEventStream(streamed.stream)) {
27795
28759
  const payload = sseLogPayload(event.data);
@@ -27802,6 +28766,9 @@ async function followRuntimeLogSse(ctx, args) {
27802
28766
  }
27803
28767
  args.seen.add(key);
27804
28768
  emitFollowLogEntry(ctx, payload);
28769
+ if (args.exported !== undefined) {
28770
+ args.exported.push(payload);
28771
+ }
27805
28772
  resumeCursor = newerLogCursor(resumeCursor, payload);
27806
28773
  }
27807
28774
  return { kind: "ended" };
@@ -27818,6 +28785,21 @@ async function followRuntimeLogSse(ctx, args) {
27818
28785
  throw error2;
27819
28786
  }
27820
28787
  }
28788
+ async function finishLogExport(ctx, exportPath, entries) {
28789
+ if (exportPath === undefined) {
28790
+ return;
28791
+ }
28792
+ await exportLogEntries(ctx, exportPath, entries);
28793
+ }
28794
+ async function exportLogEntries(ctx, exportPath, entries) {
28795
+ const targetPath = resolve6(ctx.cwd, exportPath);
28796
+ await writeFile3(targetPath, `${JSON.stringify(entries, null, 2)}
28797
+ `, "utf8");
28798
+ if (ctx.outputFormat === "text") {
28799
+ ctx.io.stderr.write(`Exported ${entries.length} loaded log lines to ${targetPath}.
28800
+ `);
28801
+ }
28802
+ }
27821
28803
  function sseLogPayload(data) {
27822
28804
  let parsed;
27823
28805
  try {
@@ -27876,13 +28858,12 @@ function isGemUuid(value) {
27876
28858
  function isAbortError2(error2) {
27877
28859
  return error2 instanceof Error && error2.name === "AbortError" || error2 instanceof Error && error2.name === "TimeoutError";
27878
28860
  }
27879
- function emitFollowTimeout(ctx, durationMs, pollCount, emitted) {
28861
+ function emitFollowTimeout(ctx, durationMs, emitted) {
27880
28862
  if (ctx.outputFormat === "stream-json") {
27881
28863
  writeStreamJson(ctx.io, "timeout", {
27882
28864
  operation: "gem.logs.follow",
27883
28865
  reason: "bounded_follow_cap_reached",
27884
28866
  duration_ms: durationMs,
27885
- polls: pollCount,
27886
28867
  emitted
27887
28868
  });
27888
28869
  writeStreamJson(ctx.io, "done", { operation: "gem.logs.follow" });
@@ -27903,20 +28884,17 @@ function emitFollowStreamEnded(ctx, emitted) {
27903
28884
  ctx.io.stderr.write(`Stopped following Gem logs (${emitted} line${emitted === 1 ? "" : "s"} emitted).
27904
28885
  `);
27905
28886
  }
27906
- function emitLogFollowPhase(ctx, phase, pollCount) {
28887
+ function emitLogFollowPhase(ctx, phase) {
27907
28888
  if (ctx.outputFormat === "stream-json") {
27908
28889
  writeStreamJson(ctx.io, "phase", {
27909
28890
  operation: "gem.logs.follow",
27910
- phase,
27911
- poll: pollCount
28891
+ phase
27912
28892
  });
27913
- } else if (phase === "streaming") {
27914
- ctx.io.stderr.write(`Streaming Gem logs...
27915
- `);
27916
- } else {
27917
- ctx.io.stderr.write(`Polling Gem logs (${pollCount})...
27918
- `);
28893
+ return;
27919
28894
  }
28895
+ ctx.io.stderr.write(phase === "streaming" ? `Streaming Gem logs...
28896
+ ` : `Reading recent Gem logs...
28897
+ `);
27920
28898
  }
27921
28899
  function emitFollowLogEntry(ctx, entry) {
27922
28900
  if (ctx.outputFormat === "stream-json") {
@@ -27927,7 +28905,7 @@ function emitFollowLogEntry(ctx, entry) {
27927
28905
  }
27928
28906
  function normalizeLogEntries(value) {
27929
28907
  const root = jsonObjectOrNull2(value);
27930
- const candidate = root === null ? value : root["logs"];
28908
+ const candidate = root === null ? [] : root["logs"];
27931
28909
  if (!Array.isArray(candidate)) {
27932
28910
  return [];
27933
28911
  }
@@ -28493,10 +29471,20 @@ Run \`uru status\` to inspect them, save or push your changes, or re-run \`uru p
28493
29471
  ${preview}${moreLine}`;
28494
29472
  }
28495
29473
  async function remoteSourceOperation(ctx, operationId, params) {
28496
- return {
28497
- available: true,
28498
- result: await executeOperation(ctx, operationId, params)
28499
- };
29474
+ try {
29475
+ return {
29476
+ available: true,
29477
+ result: await executeOperation(ctx, operationId, params)
29478
+ };
29479
+ } catch (error2) {
29480
+ if (ctx.abortSignal.aborted) {
29481
+ throw error2;
29482
+ }
29483
+ return {
29484
+ available: false,
29485
+ error: normalizeError(error2).message
29486
+ };
29487
+ }
28500
29488
  }
28501
29489
  function formatRemoteSummary(remote) {
28502
29490
  if (!remote.available) {
@@ -30408,7 +31396,7 @@ async function dispatchRegistryFamilyCommand({
30408
31396
  // src/config.ts
30409
31397
  import { chmod as chmod3, mkdir as mkdir7, open as open2, readFile as readFile10, rename as rename3, rm as rm4 } from "node:fs/promises";
30410
31398
  import { constants as constants2 } from "node:fs";
30411
- import { randomUUID as randomUUID3 } from "node:crypto";
31399
+ import { randomUUID as randomUUID4 } from "node:crypto";
30412
31400
  import { homedir as homedir2 } from "node:os";
30413
31401
  import { dirname as dirname7, join as join5 } from "node:path";
30414
31402
  function resolveConfigHome(env = process.env) {
@@ -30444,7 +31432,7 @@ function createConfigStore(path = configPath()) {
30444
31432
  await mkdir7(dirname7(path), { recursive: true });
30445
31433
  const body = `${JSON.stringify(sanitizeConfig(config2), null, 2)}
30446
31434
  `;
30447
- const temporaryPath = `${path}.${process.pid}.${randomUUID3()}.tmp`;
31435
+ const temporaryPath = `${path}.${process.pid}.${randomUUID4()}.tmp`;
30448
31436
  let handle = null;
30449
31437
  try {
30450
31438
  handle = await open2(temporaryPath, constants2.O_CREAT | constants2.O_EXCL | constants2.O_WRONLY, constants2.S_IRUSR | constants2.S_IWUSR);