@lace-cloud/canvas 0.27.0 → 0.29.0

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/README.md CHANGED
@@ -147,10 +147,10 @@ const { ports, close } = await openEngineSession(caller, { root: '/path/to/autho
147
147
  cancelling the command's remote effects. An `Invoke` stream that stops
148
148
  before the command's exit, by an end or an error, rejects `events` with
149
149
  `CommandDetachedError` when the consumer's `signal` aborted; otherwise
150
- with `CommandUnobservedError` once the engine sent `started` (it
151
- accepted the request and runs the command, so the command ran and its
152
- outcome never arrived), and with the call's own error before it (the
153
- command never ran).
150
+ with `CommandUnobservedError`, which names the command's `path`, once
151
+ the engine sent `started` (it accepted the request and runs the
152
+ command, so the command ran and its outcome never arrived), and with the
153
+ call's own error before it (the command never ran).
154
154
  - `openEngineCommands(caller, { cwd })` is the commands mapping:
155
155
  `Initialize` once, `Invoke` per command, no session and no Subscribe.
156
156
  - Both mappings name the protocol version this package speaks
@@ -175,7 +175,10 @@ const { ports, close } = await openEngineSession(caller, { root: '/path/to/autho
175
175
  dashboards): it fetches one Bundle snapshot and never changes —
176
176
  `unsaved`/`ungenerated`/`sourceRefused` are always false, `conflict` is
177
177
  always `null`, `diagnostics` is always empty, since a RunSnapshot has no live
178
- validator and the run's own certification already vouched for it.
178
+ validator and the run's own certification already vouched for it. A fetch
179
+ the server answers with a failure ends the stream `failed` with a
180
+ `SnapshotFetchError`, whose `status` is the answer's HTTP status: a host
181
+ words the failure by it, never by the message.
179
182
 
180
183
  ```ts
181
184
  import { snapshotSource } from '@lace-cloud/canvas';
@@ -10500,10 +10500,9 @@ var CommandDetachedError = class extends Error {
10500
10500
  }
10501
10501
  };
10502
10502
  var CommandUnobservedError = class extends Error {
10503
- constructor() {
10504
- super(
10505
- "the engine's stream ended before the command exited: the command ran and may have made changes, but its outcome is unknown"
10506
- );
10503
+ constructor(path) {
10504
+ super(`the engine's stream ended before \`lace ${path}\` exited`);
10505
+ this.path = path;
10507
10506
  }
10508
10507
  };
10509
10508
 
@@ -10948,6 +10947,7 @@ var COMMANDS = {
10948
10947
  "type": "string"
10949
10948
  }
10950
10949
  },
10950
+ "effect": "write",
10951
10951
  "hidden": false,
10952
10952
  "yes": false
10953
10953
  },
@@ -10974,6 +10974,7 @@ var COMMANDS = {
10974
10974
  "type": "string"
10975
10975
  }
10976
10976
  },
10977
+ "effect": "read",
10977
10978
  "hidden": false,
10978
10979
  "yes": false
10979
10980
  },
@@ -10998,6 +10999,7 @@ var COMMANDS = {
10998
10999
  "type": "string"
10999
11000
  }
11000
11001
  },
11002
+ "effect": "read",
11001
11003
  "hidden": false,
11002
11004
  "yes": false
11003
11005
  },
@@ -11012,6 +11014,7 @@ var COMMANDS = {
11012
11014
  "type": "string"
11013
11015
  }
11014
11016
  },
11017
+ "effect": "write",
11015
11018
  "hidden": false,
11016
11019
  "yes": false
11017
11020
  },
@@ -11023,6 +11026,7 @@ var COMMANDS = {
11023
11026
  "type": "string"
11024
11027
  }
11025
11028
  },
11029
+ "effect": "write",
11026
11030
  "hidden": false,
11027
11031
  "yes": false
11028
11032
  },
@@ -11034,6 +11038,7 @@ var COMMANDS = {
11034
11038
  "type": "bool"
11035
11039
  }
11036
11040
  },
11041
+ "effect": "read",
11037
11042
  "hidden": false,
11038
11043
  "yes": false
11039
11044
  },
@@ -11061,6 +11066,7 @@ var COMMANDS = {
11061
11066
  "type": "string"
11062
11067
  }
11063
11068
  },
11069
+ "effect": "write",
11064
11070
  "hidden": false,
11065
11071
  "yes": false
11066
11072
  },
@@ -11076,6 +11082,7 @@ var COMMANDS = {
11076
11082
  ]
11077
11083
  }
11078
11084
  },
11085
+ "effect": "write",
11079
11086
  "hidden": false,
11080
11087
  "yes": false
11081
11088
  },
@@ -11094,6 +11101,7 @@ var COMMANDS = {
11094
11101
  "type": "string"
11095
11102
  }
11096
11103
  },
11104
+ "effect": "rewrite",
11097
11105
  "hidden": false,
11098
11106
  "yes": false
11099
11107
  },
@@ -11117,6 +11125,7 @@ var COMMANDS = {
11117
11125
  "type": "string"
11118
11126
  }
11119
11127
  },
11128
+ "effect": "write",
11120
11129
  "hidden": false,
11121
11130
  "yes": false
11122
11131
  },
@@ -11144,6 +11153,33 @@ var COMMANDS = {
11144
11153
  "type": "bool"
11145
11154
  }
11146
11155
  },
11156
+ "effect": "rewrite",
11157
+ "hidden": false,
11158
+ "yes": false
11159
+ },
11160
+ "module lock": {
11161
+ "path": "module lock",
11162
+ "positionals": [],
11163
+ "flags": {
11164
+ "org": {
11165
+ "type": "string"
11166
+ },
11167
+ "output": {
11168
+ "type": "string",
11169
+ "values": [
11170
+ "table",
11171
+ "json"
11172
+ ]
11173
+ },
11174
+ "path": {
11175
+ "type": "string"
11176
+ },
11177
+ "upgrade": {
11178
+ "type": "stringArray",
11179
+ "repeated": true
11180
+ }
11181
+ },
11182
+ "effect": "write",
11147
11183
  "hidden": false,
11148
11184
  "yes": false
11149
11185
  },
@@ -11178,6 +11214,7 @@ var COMMANDS = {
11178
11214
  "type": "bool"
11179
11215
  }
11180
11216
  },
11217
+ "effect": "read",
11181
11218
  "hidden": false,
11182
11219
  "yes": false
11183
11220
  },
@@ -11206,6 +11243,7 @@ var COMMANDS = {
11206
11243
  ]
11207
11244
  }
11208
11245
  },
11246
+ "effect": "write",
11209
11247
  "hidden": false,
11210
11248
  "yes": false
11211
11249
  },
@@ -11221,6 +11259,7 @@ var COMMANDS = {
11221
11259
  ]
11222
11260
  }
11223
11261
  },
11262
+ "effect": "read",
11224
11263
  "hidden": false,
11225
11264
  "yes": false
11226
11265
  },
@@ -11236,6 +11275,7 @@ var COMMANDS = {
11236
11275
  ]
11237
11276
  }
11238
11277
  },
11278
+ "effect": "read",
11239
11279
  "hidden": false,
11240
11280
  "yes": false
11241
11281
  },
@@ -11256,6 +11296,7 @@ var COMMANDS = {
11256
11296
  ]
11257
11297
  }
11258
11298
  },
11299
+ "effect": "write",
11259
11300
  "hidden": false,
11260
11301
  "yes": false
11261
11302
  },
@@ -11282,6 +11323,7 @@ var COMMANDS = {
11282
11323
  "type": "string"
11283
11324
  }
11284
11325
  },
11326
+ "effect": "read",
11285
11327
  "hidden": false,
11286
11328
  "yes": false
11287
11329
  },
@@ -11306,6 +11348,7 @@ var COMMANDS = {
11306
11348
  "type": "string"
11307
11349
  }
11308
11350
  },
11351
+ "effect": "read",
11309
11352
  "hidden": false,
11310
11353
  "yes": false
11311
11354
  },
@@ -11332,6 +11375,7 @@ var COMMANDS = {
11332
11375
  "type": "string"
11333
11376
  }
11334
11377
  },
11378
+ "effect": "read",
11335
11379
  "hidden": false,
11336
11380
  "yes": false
11337
11381
  },
@@ -11361,6 +11405,7 @@ var COMMANDS = {
11361
11405
  ]
11362
11406
  }
11363
11407
  },
11408
+ "effect": "read",
11364
11409
  "hidden": false,
11365
11410
  "yes": false
11366
11411
  },
@@ -11403,6 +11448,7 @@ var COMMANDS = {
11403
11448
  "type": "string"
11404
11449
  }
11405
11450
  },
11451
+ "effect": "read",
11406
11452
  "hidden": false,
11407
11453
  "yes": false
11408
11454
  },
@@ -11435,6 +11481,7 @@ var COMMANDS = {
11435
11481
  "type": "string"
11436
11482
  }
11437
11483
  },
11484
+ "effect": "read",
11438
11485
  "hidden": false,
11439
11486
  "yes": false
11440
11487
  },
@@ -11460,6 +11507,7 @@ var COMMANDS = {
11460
11507
  "type": "string"
11461
11508
  }
11462
11509
  },
11510
+ "effect": "read",
11463
11511
  "hidden": false,
11464
11512
  "yes": false
11465
11513
  },
@@ -11489,6 +11537,7 @@ var COMMANDS = {
11489
11537
  "type": "string"
11490
11538
  }
11491
11539
  },
11540
+ "effect": "write",
11492
11541
  "hidden": false,
11493
11542
  "yes": false
11494
11543
  },
@@ -11518,6 +11567,7 @@ var COMMANDS = {
11518
11567
  "type": "string"
11519
11568
  }
11520
11569
  },
11570
+ "effect": "read",
11521
11571
  "hidden": false,
11522
11572
  "yes": false
11523
11573
  },
@@ -11560,6 +11610,7 @@ var COMMANDS = {
11560
11610
  "type": "string"
11561
11611
  }
11562
11612
  },
11613
+ "effect": "read",
11563
11614
  "hidden": false,
11564
11615
  "yes": false
11565
11616
  },
@@ -11589,6 +11640,7 @@ var COMMANDS = {
11589
11640
  "type": "string"
11590
11641
  }
11591
11642
  },
11643
+ "effect": "read",
11592
11644
  "hidden": false,
11593
11645
  "yes": false
11594
11646
  },
@@ -11615,6 +11667,7 @@ var COMMANDS = {
11615
11667
  "type": "string"
11616
11668
  }
11617
11669
  },
11670
+ "effect": "read",
11618
11671
  "hidden": false,
11619
11672
  "yes": false
11620
11673
  },
@@ -11661,6 +11714,7 @@ var COMMANDS = {
11661
11714
  "repeated": true
11662
11715
  }
11663
11716
  },
11717
+ "effect": "write",
11664
11718
  "hidden": false,
11665
11719
  "yes": false
11666
11720
  },
@@ -11709,6 +11763,7 @@ var COMMANDS = {
11709
11763
  "type": "string"
11710
11764
  }
11711
11765
  },
11766
+ "effect": "write",
11712
11767
  "hidden": false,
11713
11768
  "yes": false
11714
11769
  },
@@ -11738,6 +11793,7 @@ var COMMANDS = {
11738
11793
  "type": "bool"
11739
11794
  }
11740
11795
  },
11796
+ "effect": "write",
11741
11797
  "hidden": false,
11742
11798
  "yes": true
11743
11799
  },
@@ -11770,6 +11826,7 @@ var COMMANDS = {
11770
11826
  "type": "string"
11771
11827
  }
11772
11828
  },
11829
+ "effect": "read",
11773
11830
  "hidden": false,
11774
11831
  "yes": false
11775
11832
  },
@@ -11822,6 +11879,7 @@ var COMMANDS = {
11822
11879
  "type": "bool"
11823
11880
  }
11824
11881
  },
11882
+ "effect": "write",
11825
11883
  "hidden": false,
11826
11884
  "yes": true
11827
11885
  },
@@ -11851,6 +11909,7 @@ var COMMANDS = {
11851
11909
  "type": "string"
11852
11910
  }
11853
11911
  },
11912
+ "effect": "read",
11854
11913
  "hidden": false,
11855
11914
  "yes": false
11856
11915
  },
@@ -11887,6 +11946,7 @@ var COMMANDS = {
11887
11946
  "type": "string"
11888
11947
  }
11889
11948
  },
11949
+ "effect": "rewrite",
11890
11950
  "hidden": false,
11891
11951
  "yes": false
11892
11952
  },
@@ -11920,6 +11980,7 @@ var COMMANDS = {
11920
11980
  "type": "string"
11921
11981
  }
11922
11982
  },
11983
+ "effect": "read",
11923
11984
  "hidden": false,
11924
11985
  "yes": false
11925
11986
  },
@@ -11954,6 +12015,7 @@ var COMMANDS = {
11954
12015
  "repeated": true
11955
12016
  }
11956
12017
  },
12018
+ "effect": "write",
11957
12019
  "hidden": false,
11958
12020
  "yes": false
11959
12021
  },
@@ -11989,6 +12051,7 @@ var COMMANDS = {
11989
12051
  "type": "duration"
11990
12052
  }
11991
12053
  },
12054
+ "effect": "write",
11992
12055
  "hidden": false,
11993
12056
  "yes": false
11994
12057
  },
@@ -12030,6 +12093,7 @@ var COMMANDS = {
12030
12093
  "type": "string"
12031
12094
  }
12032
12095
  },
12096
+ "effect": "write",
12033
12097
  "hidden": false,
12034
12098
  "yes": false
12035
12099
  },
@@ -12048,6 +12112,7 @@ var COMMANDS = {
12048
12112
  ]
12049
12113
  }
12050
12114
  },
12115
+ "effect": "read",
12051
12116
  "hidden": false,
12052
12117
  "yes": false
12053
12118
  },
@@ -12072,6 +12137,7 @@ var COMMANDS = {
12072
12137
  ]
12073
12138
  }
12074
12139
  },
12140
+ "effect": "read",
12075
12141
  "hidden": false,
12076
12142
  "yes": false
12077
12143
  },
@@ -12095,6 +12161,7 @@ var COMMANDS = {
12095
12161
  ]
12096
12162
  }
12097
12163
  },
12164
+ "effect": "write",
12098
12165
  "hidden": false,
12099
12166
  "yes": false
12100
12167
  },
@@ -12110,6 +12177,7 @@ var COMMANDS = {
12110
12177
  ]
12111
12178
  }
12112
12179
  },
12180
+ "effect": "read",
12113
12181
  "hidden": false,
12114
12182
  "yes": false
12115
12183
  },
@@ -12125,6 +12193,7 @@ var COMMANDS = {
12125
12193
  ]
12126
12194
  }
12127
12195
  },
12196
+ "effect": "read",
12128
12197
  "hidden": false,
12129
12198
  "yes": false
12130
12199
  }
@@ -12260,10 +12329,18 @@ var moduleValidateResultSchema = z.object({
12260
12329
  failure: commandFailureSchema.optional(),
12261
12330
  diagnostics: z.array(commandDiagnosticSchema)
12262
12331
  });
12332
+ var moduleLockResultSchema = z.object({
12333
+ path: z.string(),
12334
+ lockfile: z.string(),
12335
+ providers: z.array(
12336
+ z.object({ address: z.string(), version: z.string(), platforms: z.array(z.string()) })
12337
+ )
12338
+ });
12263
12339
  var moduleConvertResultSchema = z.object({
12264
12340
  changed: z.boolean(),
12265
12341
  written: z.array(z.string()),
12266
12342
  removed: z.array(z.string()),
12343
+ lock: moduleLockResultSchema.nullable(),
12267
12344
  validate: moduleValidateResultSchema,
12268
12345
  diagnostics: z.array(commandDiagnosticSchema)
12269
12346
  });
@@ -12343,6 +12420,12 @@ var moduleFmtResultSchema = z.object({ changed: z.array(z.string()) });
12343
12420
  var moduleDocsResultSchema = z.object({ markdown: z.string() });
12344
12421
  var moduleScanResultSchema = z.object({
12345
12422
  treeHash: z.string(),
12423
+ tool: z.object({
12424
+ name: z.string(),
12425
+ version: z.string().nullable(),
12426
+ path: z.string(),
12427
+ source: z.enum(["env", "path", "cache"])
12428
+ }),
12346
12429
  diagnostics: z.array(commandDiagnosticSchema)
12347
12430
  });
12348
12431
  var registryDescribeSchema = z.object({
@@ -12496,6 +12579,22 @@ var runSchema = z.object({
12496
12579
  // a portal mount reading the API body sees it absent — optional so both
12497
12580
  // bodies parse. A host opens this link and never composes a portal route.
12498
12581
  url: z.string().optional(),
12582
+ // The provider versions the Run's lockfile pins, each with the
12583
+ // organization's admission it ran under when the version is one admitted
12584
+ // outside the curated range. A single-run read carries it; a list does
12585
+ // not, and the CLI omits an empty one.
12586
+ providers: z.array(
12587
+ z.object({
12588
+ address: z.string(),
12589
+ version: z.string(),
12590
+ admission: z.object({
12591
+ id: z.string(),
12592
+ admittedBy: z.string(),
12593
+ admittedByName: z.string().nullable(),
12594
+ admittedAt: z.string()
12595
+ }).optional()
12596
+ })
12597
+ ).optional(),
12499
12598
  // The CLI's own `api.Run` decode struct (apps/cli/internal/api/runs.go) has no
12500
12599
  // json tag for these, so every CLI JSON golden omits them; the API always sends
12501
12600
  // them (apps/api/src/openapi/schemas/runs.ts) — optional so both bodies parse.
@@ -12715,16 +12814,22 @@ var currentSelectionSchema = z.union([
12715
12814
  z.object({ slug: z.null(), source: z.null() })
12716
12815
  ]);
12717
12816
  var loginUserSchema = z.object({ id: z.string(), email: z.string(), name: z.string() });
12718
- var logoutSchema = z.object({ loggedOut: z.boolean() });
12817
+ var keyRevocationSchema = z.object({
12818
+ revocation: z.enum(["revoked", "refused", "unreachable", "unreadable", "none"]),
12819
+ detail: z.string().optional(),
12820
+ portalUrl: z.string().optional()
12821
+ });
12822
+ var logoutSchema = keyRevocationSchema.extend({ loggedOut: z.boolean() });
12719
12823
  var loginEventSchema = z.discriminatedUnion("type", [
12720
12824
  z.object({ type: z.literal("code"), code: z.string(), verificationUrl: z.string().optional() }),
12721
12825
  z.object({ type: z.literal("url"), url: z.string() }),
12722
12826
  z.object({ type: z.literal("email_sent"), email: z.string() }),
12723
- z.object({ type: z.literal("result"), user: loginUserSchema })
12827
+ z.object({ type: z.literal("result"), user: loginUserSchema, replacedKey: keyRevocationSchema })
12724
12828
  ]);
12725
12829
  var SCHEMAS = {
12726
12830
  "module validate": moduleValidateResultSchema,
12727
12831
  "module convert": moduleConvertResultSchema,
12832
+ "module lock": moduleLockResultSchema,
12728
12833
  "module fmt": moduleFmtResultSchema,
12729
12834
  "module docs": moduleDocsResultSchema,
12730
12835
  "module scan": moduleScanResultSchema,
@@ -13059,7 +13164,7 @@ function commandsPort(caller, commandPaths, ownCwd) {
13059
13164
  let started = false;
13060
13165
  const stopped = (error) => {
13061
13166
  if (signal.aborted) return new CommandDetachedError();
13062
- if (started) return new CommandUnobservedError();
13167
+ if (started) return new CommandUnobservedError(path);
13063
13168
  return error;
13064
13169
  };
13065
13170
  try {
@@ -13277,6 +13382,13 @@ function liveSlots(slots, current) {
13277
13382
  report: liveReport(report, current)
13278
13383
  };
13279
13384
  }
13385
+ function commandUnderWay({
13386
+ run,
13387
+ preview: preview2,
13388
+ running
13389
+ }) {
13390
+ return run?.outcome.kind === "running" || preview2?.outcome.kind === "running" || running.size > 0;
13391
+ }
13280
13392
  function withPhase(phases, name) {
13281
13393
  return [...phases.map((p) => ({ ...p, status: "done" })), { name, status: "current" }];
13282
13394
  }
@@ -13322,18 +13434,19 @@ function runningFor(slot, token) {
13322
13434
  if (slot?.token !== token) return false;
13323
13435
  return "done" in slot ? !slot.done : slot.outcome.kind === "running";
13324
13436
  }
13325
- function failureSays(error, command) {
13437
+ function failureSays(error) {
13326
13438
  if (error instanceof CommandExitError) {
13327
13439
  if (error.failure) return { message: error.failure.message, failure: error.failure };
13328
13440
  const stderr = error.stderrTail.trim();
13329
13441
  return { message: stderr || `the command exited with code ${error.code} and wrote nothing` };
13330
13442
  }
13331
- if (error instanceof CommandUnobservedError && command.kind === "read") {
13332
- return { message: `the stream ended before \`lace ${command.path}\` finished; run it again` };
13443
+ if (error instanceof CommandUnobservedError) {
13444
+ return {
13445
+ message: COMMANDS[error.path].effect === "read" ? `${error.message}; run it again` : `${error.message}: it ran and may have made changes, but its outcome is unknown`
13446
+ };
13333
13447
  }
13334
13448
  return { message: error instanceof Error ? error.message : String(error) };
13335
13449
  }
13336
- var RUN = { kind: "write" };
13337
13450
  function settleRun(prev, token, error) {
13338
13451
  const carried = prev && prev.token === token ? prev : null;
13339
13452
  const lastLog = carried?.lastLog ?? null;
@@ -13349,7 +13462,7 @@ function settleRun(prev, token, error) {
13349
13462
  if (error.code === 7)
13350
13463
  return {
13351
13464
  token,
13352
- outcome: { kind: "blocked", ...failureSays(error, RUN) },
13465
+ outcome: { kind: "blocked", ...failureSays(error) },
13353
13466
  lastLog,
13354
13467
  submitted,
13355
13468
  phases
@@ -13357,7 +13470,7 @@ function settleRun(prev, token, error) {
13357
13470
  }
13358
13471
  return {
13359
13472
  token,
13360
- outcome: { kind: "failed", ...failureSays(error, RUN) },
13473
+ outcome: { kind: "failed", ...failureSays(error) },
13361
13474
  lastLog,
13362
13475
  submitted,
13363
13476
  phases
@@ -13526,10 +13639,7 @@ function defineCommand(binding) {
13526
13639
  } catch (err) {
13527
13640
  const settledByDocument = rendered && binding.result.kind === "notify" && (err instanceof CommandExitError || err instanceof CommandUnobservedError);
13528
13641
  if (!rt.fail(err) && !(err instanceof CommandDetachedError) && !settledByDocument) {
13529
- const { message, failure } = failureSays(
13530
- err,
13531
- binding.result.kind === "preview" || binding.result.kind === "follow" ? { kind: "read", path: binding.path } : { kind: "write" }
13532
- );
13642
+ const { message, failure } = failureSays(err);
13533
13643
  rt.ports.presenter.notify("error", message, ...failure ? [failure] : []);
13534
13644
  }
13535
13645
  if (binding.invalidates) rt.tick();
@@ -14428,6 +14538,7 @@ export {
14428
14538
  diagnosticsOfDocument,
14429
14539
  reportDiagnostics,
14430
14540
  liveSlots,
14541
+ commandUnderWay,
14431
14542
  reduceRun,
14432
14543
  failureSays,
14433
14544
  settleRun,
@@ -14447,4 +14558,4 @@ export {
14447
14558
  AutosaveEndedError,
14448
14559
  autosave
14449
14560
  };
14450
- //# sourceMappingURL=chunk-F3X6TTZ6.mjs.map
14561
+ //# sourceMappingURL=chunk-ASG36ZXQ.mjs.map