@lace-cloud/canvas 0.25.0 → 0.27.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 +7 -5
- package/dist/{chunk-YLJWYH7B.mjs → chunk-F3X6TTZ6.mjs} +790 -577
- package/dist/chunk-F3X6TTZ6.mjs.map +1 -0
- package/dist/engine/index.cjs +736 -534
- package/dist/engine/index.cjs.map +1 -1
- package/dist/engine/index.d.mts +2 -2
- package/dist/engine/index.d.ts +2 -2
- package/dist/engine/index.mjs +3 -1
- package/dist/index.cjs +3747 -3448
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +331 -242
- package/dist/index.mjs.map +1 -1
- package/dist/{registry-CdHLt_qh.d.mts → registry-D7G7pqU4.d.mts} +71 -8
- package/dist/{registry-CdHLt_qh.d.ts → registry-D7G7pqU4.d.ts} +71 -8
- package/package.json +3 -3
- package/dist/chunk-YLJWYH7B.mjs.map +0 -1
package/dist/engine/index.cjs
CHANGED
|
@@ -43,6 +43,7 @@ __export(engine_exports, {
|
|
|
43
43
|
defineCommand: () => defineCommand,
|
|
44
44
|
diagnosticsOf: () => diagnosticsOf,
|
|
45
45
|
diagnosticsOfDocument: () => diagnosticsOfDocument,
|
|
46
|
+
failureSays: () => failureSays,
|
|
46
47
|
foldReport: () => foldReport,
|
|
47
48
|
isBoundPath: () => isBoundPath,
|
|
48
49
|
liveSlots: () => liveSlots,
|
|
@@ -3607,7 +3608,7 @@ function conflictChoiceToJSON(object) {
|
|
|
3607
3608
|
}
|
|
3608
3609
|
}
|
|
3609
3610
|
function createBaseReasonDetail() {
|
|
3610
|
-
return { reason: 0, api_code: "" };
|
|
3611
|
+
return { reason: 0, api_code: "", request_id: "" };
|
|
3611
3612
|
}
|
|
3612
3613
|
var ReasonDetail = {
|
|
3613
3614
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
@@ -3617,6 +3618,9 @@ var ReasonDetail = {
|
|
|
3617
3618
|
if (message.api_code !== "") {
|
|
3618
3619
|
writer.uint32(18).string(message.api_code);
|
|
3619
3620
|
}
|
|
3621
|
+
if (message.request_id !== "") {
|
|
3622
|
+
writer.uint32(26).string(message.request_id);
|
|
3623
|
+
}
|
|
3620
3624
|
return writer;
|
|
3621
3625
|
},
|
|
3622
3626
|
decode(input, length) {
|
|
@@ -3640,6 +3644,13 @@ var ReasonDetail = {
|
|
|
3640
3644
|
message.api_code = reader.string();
|
|
3641
3645
|
continue;
|
|
3642
3646
|
}
|
|
3647
|
+
case 3: {
|
|
3648
|
+
if (tag !== 26) {
|
|
3649
|
+
break;
|
|
3650
|
+
}
|
|
3651
|
+
message.request_id = reader.string();
|
|
3652
|
+
continue;
|
|
3653
|
+
}
|
|
3643
3654
|
}
|
|
3644
3655
|
if ((tag & 7) === 4 || tag === 0) {
|
|
3645
3656
|
break;
|
|
@@ -3651,7 +3662,8 @@ var ReasonDetail = {
|
|
|
3651
3662
|
fromJSON(object) {
|
|
3652
3663
|
return {
|
|
3653
3664
|
reason: isSet3(object.reason) ? reasonFromJSON(object.reason) : 0,
|
|
3654
|
-
api_code: isSet3(object.apiCode) ? globalThis.String(object.apiCode) : isSet3(object.api_code) ? globalThis.String(object.api_code) : ""
|
|
3665
|
+
api_code: isSet3(object.apiCode) ? globalThis.String(object.apiCode) : isSet3(object.api_code) ? globalThis.String(object.api_code) : "",
|
|
3666
|
+
request_id: isSet3(object.requestId) ? globalThis.String(object.requestId) : isSet3(object.request_id) ? globalThis.String(object.request_id) : ""
|
|
3655
3667
|
};
|
|
3656
3668
|
},
|
|
3657
3669
|
toJSON(message) {
|
|
@@ -3662,6 +3674,9 @@ var ReasonDetail = {
|
|
|
3662
3674
|
if (message.api_code !== "") {
|
|
3663
3675
|
obj.apiCode = message.api_code;
|
|
3664
3676
|
}
|
|
3677
|
+
if (message.request_id !== "") {
|
|
3678
|
+
obj.requestId = message.request_id;
|
|
3679
|
+
}
|
|
3665
3680
|
return obj;
|
|
3666
3681
|
},
|
|
3667
3682
|
create(base) {
|
|
@@ -3671,6 +3686,7 @@ var ReasonDetail = {
|
|
|
3671
3686
|
const message = createBaseReasonDetail();
|
|
3672
3687
|
message.reason = object.reason ?? 0;
|
|
3673
3688
|
message.api_code = object.api_code ?? "";
|
|
3689
|
+
message.request_id = object.request_id ?? "";
|
|
3674
3690
|
return message;
|
|
3675
3691
|
}
|
|
3676
3692
|
};
|
|
@@ -8029,7 +8045,7 @@ var InvokeRequest = {
|
|
|
8029
8045
|
}
|
|
8030
8046
|
};
|
|
8031
8047
|
function createBaseInvokeEvent() {
|
|
8032
|
-
return { json: void 0, exit: void 0 };
|
|
8048
|
+
return { json: void 0, exit: void 0, started: void 0 };
|
|
8033
8049
|
}
|
|
8034
8050
|
var InvokeEvent = {
|
|
8035
8051
|
encode(message, writer = new import_wire4.BinaryWriter()) {
|
|
@@ -8039,6 +8055,9 @@ var InvokeEvent = {
|
|
|
8039
8055
|
if (message.exit !== void 0) {
|
|
8040
8056
|
InvokeExit.encode(message.exit, writer.uint32(18).fork()).join();
|
|
8041
8057
|
}
|
|
8058
|
+
if (message.started !== void 0) {
|
|
8059
|
+
InvokeStarted.encode(message.started, writer.uint32(26).fork()).join();
|
|
8060
|
+
}
|
|
8042
8061
|
return writer;
|
|
8043
8062
|
},
|
|
8044
8063
|
decode(input, length) {
|
|
@@ -8062,6 +8081,13 @@ var InvokeEvent = {
|
|
|
8062
8081
|
message.exit = InvokeExit.decode(reader, reader.uint32());
|
|
8063
8082
|
continue;
|
|
8064
8083
|
}
|
|
8084
|
+
case 3: {
|
|
8085
|
+
if (tag !== 26) {
|
|
8086
|
+
break;
|
|
8087
|
+
}
|
|
8088
|
+
message.started = InvokeStarted.decode(reader, reader.uint32());
|
|
8089
|
+
continue;
|
|
8090
|
+
}
|
|
8065
8091
|
}
|
|
8066
8092
|
if ((tag & 7) === 4 || tag === 0) {
|
|
8067
8093
|
break;
|
|
@@ -8073,7 +8099,8 @@ var InvokeEvent = {
|
|
|
8073
8099
|
fromJSON(object) {
|
|
8074
8100
|
return {
|
|
8075
8101
|
json: isSet3(object.json) ? globalThis.String(object.json) : void 0,
|
|
8076
|
-
exit: isSet3(object.exit) ? InvokeExit.fromJSON(object.exit) : void 0
|
|
8102
|
+
exit: isSet3(object.exit) ? InvokeExit.fromJSON(object.exit) : void 0,
|
|
8103
|
+
started: isSet3(object.started) ? InvokeStarted.fromJSON(object.started) : void 0
|
|
8077
8104
|
};
|
|
8078
8105
|
},
|
|
8079
8106
|
toJSON(message) {
|
|
@@ -8084,6 +8111,9 @@ var InvokeEvent = {
|
|
|
8084
8111
|
if (message.exit !== void 0) {
|
|
8085
8112
|
obj.exit = InvokeExit.toJSON(message.exit);
|
|
8086
8113
|
}
|
|
8114
|
+
if (message.started !== void 0) {
|
|
8115
|
+
obj.started = InvokeStarted.toJSON(message.started);
|
|
8116
|
+
}
|
|
8087
8117
|
return obj;
|
|
8088
8118
|
},
|
|
8089
8119
|
create(base) {
|
|
@@ -8093,6 +8123,44 @@ var InvokeEvent = {
|
|
|
8093
8123
|
const message = createBaseInvokeEvent();
|
|
8094
8124
|
message.json = object.json ?? void 0;
|
|
8095
8125
|
message.exit = object.exit !== void 0 && object.exit !== null ? InvokeExit.fromPartial(object.exit) : void 0;
|
|
8126
|
+
message.started = object.started !== void 0 && object.started !== null ? InvokeStarted.fromPartial(object.started) : void 0;
|
|
8127
|
+
return message;
|
|
8128
|
+
}
|
|
8129
|
+
};
|
|
8130
|
+
function createBaseInvokeStarted() {
|
|
8131
|
+
return {};
|
|
8132
|
+
}
|
|
8133
|
+
var InvokeStarted = {
|
|
8134
|
+
encode(_, writer = new import_wire4.BinaryWriter()) {
|
|
8135
|
+
return writer;
|
|
8136
|
+
},
|
|
8137
|
+
decode(input, length) {
|
|
8138
|
+
const reader = input instanceof import_wire4.BinaryReader ? input : new import_wire4.BinaryReader(input);
|
|
8139
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
8140
|
+
const message = createBaseInvokeStarted();
|
|
8141
|
+
while (reader.pos < end) {
|
|
8142
|
+
const tag = reader.uint32();
|
|
8143
|
+
switch (tag >>> 3) {
|
|
8144
|
+
}
|
|
8145
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
8146
|
+
break;
|
|
8147
|
+
}
|
|
8148
|
+
reader.skip(tag & 7);
|
|
8149
|
+
}
|
|
8150
|
+
return message;
|
|
8151
|
+
},
|
|
8152
|
+
fromJSON(_) {
|
|
8153
|
+
return {};
|
|
8154
|
+
},
|
|
8155
|
+
toJSON(_) {
|
|
8156
|
+
const obj = {};
|
|
8157
|
+
return obj;
|
|
8158
|
+
},
|
|
8159
|
+
create(base) {
|
|
8160
|
+
return InvokeStarted.fromPartial(base ?? {});
|
|
8161
|
+
},
|
|
8162
|
+
fromPartial(_) {
|
|
8163
|
+
const message = createBaseInvokeStarted();
|
|
8096
8164
|
return message;
|
|
8097
8165
|
}
|
|
8098
8166
|
};
|
|
@@ -10371,8 +10439,9 @@ var LaceEngineDefinition = {
|
|
|
10371
10439
|
options: {}
|
|
10372
10440
|
},
|
|
10373
10441
|
/**
|
|
10374
|
-
* Runs one CLI command in-process against a fresh command tree.
|
|
10375
|
-
*
|
|
10442
|
+
* Runs one CLI command in-process against a fresh command tree. `started` is first, once the engine has accepted
|
|
10443
|
+
* the request and before the command runs; the command's `-o json` output follows: each top-level JSON value on
|
|
10444
|
+
* stdout is one `json` event; `exit` is always last.
|
|
10376
10445
|
*/
|
|
10377
10446
|
invoke: {
|
|
10378
10447
|
name: "Invoke",
|
|
@@ -10447,6 +10516,7 @@ function isSet3(value) {
|
|
|
10447
10516
|
}
|
|
10448
10517
|
|
|
10449
10518
|
// src/ports.ts
|
|
10519
|
+
var import_proto = require("@lace-cloud/proto");
|
|
10450
10520
|
var ApplyUnobservedError = class extends Error {
|
|
10451
10521
|
constructor(end) {
|
|
10452
10522
|
super(`unobserved: the source stopped (${end.kind}) before the frame that carries the write`);
|
|
@@ -10466,7 +10536,9 @@ var ConnectError = class extends Error {
|
|
|
10466
10536
|
super(`[${code}] ${message}`);
|
|
10467
10537
|
this.code = code;
|
|
10468
10538
|
this.reason = detail.reason;
|
|
10469
|
-
|
|
10539
|
+
const { apiCode, requestId } = (0, import_proto.apiFields)(detail);
|
|
10540
|
+
this.apiCode = apiCode;
|
|
10541
|
+
this.requestId = requestId;
|
|
10470
10542
|
this.name = "ConnectError";
|
|
10471
10543
|
}
|
|
10472
10544
|
};
|
|
@@ -10743,7 +10815,8 @@ function parseBridgeResponse(raw) {
|
|
|
10743
10815
|
return null;
|
|
10744
10816
|
}
|
|
10745
10817
|
const apiCode = "apiCode" in raw && typeof raw.apiCode === "string" ? raw.apiCode : void 0;
|
|
10746
|
-
|
|
10818
|
+
const requestId = "requestId" in raw && typeof raw.requestId === "string" ? raw.requestId : void 0;
|
|
10819
|
+
return { kind, id, code, message, reason, apiCode, requestId };
|
|
10747
10820
|
}
|
|
10748
10821
|
return null;
|
|
10749
10822
|
}
|
|
@@ -10751,7 +10824,11 @@ function frameError(frame) {
|
|
|
10751
10824
|
return new ConnectError(
|
|
10752
10825
|
frame.code,
|
|
10753
10826
|
frame.message,
|
|
10754
|
-
ReasonDetail.fromJSON({
|
|
10827
|
+
ReasonDetail.fromJSON({
|
|
10828
|
+
reason: frame.reason,
|
|
10829
|
+
api_code: frame.apiCode,
|
|
10830
|
+
request_id: frame.requestId
|
|
10831
|
+
})
|
|
10755
10832
|
);
|
|
10756
10833
|
}
|
|
10757
10834
|
function bridgeCaller(bridge) {
|
|
@@ -10836,7 +10913,7 @@ function bridgeCaller(bridge) {
|
|
|
10836
10913
|
}
|
|
10837
10914
|
|
|
10838
10915
|
// src/adapters/engine/mapping.ts
|
|
10839
|
-
var
|
|
10916
|
+
var import_proto2 = require("@lace-cloud/proto");
|
|
10840
10917
|
|
|
10841
10918
|
// src/contracts/commands.gen.ts
|
|
10842
10919
|
var COMMANDS = {
|
|
@@ -12172,7 +12249,8 @@ var commandFailureSchema = import_zod.z.strictObject({
|
|
|
12172
12249
|
tool: import_zod.z.string().optional(),
|
|
12173
12250
|
importResiduals: import_zod.z.array(importResidualSchema).optional(),
|
|
12174
12251
|
addresses: import_zod.z.array(import_zod.z.string()).optional(),
|
|
12175
|
-
apiCode: import_zod.z.string().optional()
|
|
12252
|
+
apiCode: import_zod.z.string().optional(),
|
|
12253
|
+
requestId: import_zod.z.string().optional()
|
|
12176
12254
|
});
|
|
12177
12255
|
var moduleValidateDeviationSchema = import_zod.z.object({
|
|
12178
12256
|
notCompositional: import_zod.z.boolean(),
|
|
@@ -12611,6 +12689,7 @@ var stackScanSchema = import_zod.z.object({
|
|
|
12611
12689
|
driftCount: import_zod.z.number(),
|
|
12612
12690
|
scannedAt: import_zod.z.string(),
|
|
12613
12691
|
undeterminedReason: import_zod.z.string().nullable(),
|
|
12692
|
+
undeterminedMessage: import_zod.z.string().nullable(),
|
|
12614
12693
|
standingDriftFindings: import_zod.z.number(),
|
|
12615
12694
|
footprintDestroyed: import_zod.z.boolean(),
|
|
12616
12695
|
drift: driftSchema
|
|
@@ -12781,9 +12860,9 @@ function isolated(report) {
|
|
|
12781
12860
|
async function initialize(caller) {
|
|
12782
12861
|
const initialize2 = await caller.unary("Initialize", {
|
|
12783
12862
|
client_version: "@lace-cloud/canvas",
|
|
12784
|
-
protocol_version:
|
|
12863
|
+
protocol_version: import_proto2.ENGINE_PROTOCOL_VERSION
|
|
12785
12864
|
});
|
|
12786
|
-
(0,
|
|
12865
|
+
(0, import_proto2.checkEngineProtocol)(initialize2.server_version, initialize2.protocol_version);
|
|
12787
12866
|
return new Set(initialize2.command_paths);
|
|
12788
12867
|
}
|
|
12789
12868
|
async function openEngineCommands(caller, { cwd }) {
|
|
@@ -12808,7 +12887,7 @@ async function openEngineSession(caller, target, options = {}) {
|
|
|
12808
12887
|
let stopped = null;
|
|
12809
12888
|
const revisionWaiters = /* @__PURE__ */ new Set();
|
|
12810
12889
|
function adopt(state) {
|
|
12811
|
-
const published = state.bundle ??
|
|
12890
|
+
const published = state.bundle ?? import_proto2.EMPTY_BUNDLE;
|
|
12812
12891
|
const bundle = currentSource && deepEqual(currentSource.bundle, published) ? currentSource.bundle : published;
|
|
12813
12892
|
sessionGenerating = state.generating;
|
|
12814
12893
|
currentSource = {
|
|
@@ -12820,7 +12899,7 @@ async function openEngineSession(caller, target, options = {}) {
|
|
|
12820
12899
|
conflict: state.conflict ? { baseTreeHash: state.conflict.base_tree_hash, treeHash: state.conflict.tree_hash } : null,
|
|
12821
12900
|
sourceRefused: state.source_refused,
|
|
12822
12901
|
generating: generating(),
|
|
12823
|
-
diagnostics: state.diagnostics.map(
|
|
12902
|
+
diagnostics: state.diagnostics.map(import_proto2.convertDiagnostic),
|
|
12824
12903
|
treeHash: state.tree_hash
|
|
12825
12904
|
};
|
|
12826
12905
|
for (const listener of sourceListeners) deliver(listener, currentSource);
|
|
@@ -13003,7 +13082,7 @@ function commandsPort(caller, commandPaths, ownCwd) {
|
|
|
13003
13082
|
working_directory: cwd
|
|
13004
13083
|
};
|
|
13005
13084
|
async function* run() {
|
|
13006
|
-
for await (const event of
|
|
13085
|
+
for await (const event of untilExit()) {
|
|
13007
13086
|
if (event.json !== void 0) {
|
|
13008
13087
|
const data = JSON.parse(event.json);
|
|
13009
13088
|
if (carriesFailure(data)) continue;
|
|
@@ -13021,8 +13100,28 @@ function commandsPort(caller, commandPaths, ownCwd) {
|
|
|
13021
13100
|
return;
|
|
13022
13101
|
}
|
|
13023
13102
|
}
|
|
13024
|
-
|
|
13025
|
-
|
|
13103
|
+
}
|
|
13104
|
+
async function* untilExit() {
|
|
13105
|
+
let started = false;
|
|
13106
|
+
const stopped = (error) => {
|
|
13107
|
+
if (signal.aborted) return new CommandDetachedError();
|
|
13108
|
+
if (started) return new CommandUnobservedError();
|
|
13109
|
+
return error;
|
|
13110
|
+
};
|
|
13111
|
+
try {
|
|
13112
|
+
for await (const event of caller.stream("Invoke", request, signal)) {
|
|
13113
|
+
started || (started = event.started !== void 0);
|
|
13114
|
+
yield event;
|
|
13115
|
+
}
|
|
13116
|
+
} catch (error) {
|
|
13117
|
+
throw stopped(error);
|
|
13118
|
+
}
|
|
13119
|
+
throw stopped(
|
|
13120
|
+
new ConnectError(
|
|
13121
|
+
"internal",
|
|
13122
|
+
"the engine ended the Invoke stream before it started the command"
|
|
13123
|
+
)
|
|
13124
|
+
);
|
|
13026
13125
|
}
|
|
13027
13126
|
return {
|
|
13028
13127
|
events: run(),
|
|
@@ -13096,407 +13195,71 @@ function convertCreatedRef(r) {
|
|
|
13096
13195
|
return { scope: r.scope, id: r.id, moduleKey: r.module_key, sourceId: r.source_id };
|
|
13097
13196
|
}
|
|
13098
13197
|
|
|
13099
|
-
// src/core/
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
}
|
|
13104
|
-
if (err instanceof Error) return [err.message];
|
|
13105
|
-
return [String(err)];
|
|
13198
|
+
// src/core/diagnostics.ts
|
|
13199
|
+
var NOT_LACE_SHAPE = "not_lace_shape";
|
|
13200
|
+
function holdsLaceShapeRefusal(diagnostics) {
|
|
13201
|
+
return diagnostics.some((d) => d.code === NOT_LACE_SHAPE);
|
|
13106
13202
|
}
|
|
13107
|
-
function
|
|
13108
|
-
return
|
|
13109
|
-
|
|
13110
|
-
|
|
13111
|
-
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
confirmSpec(ctx, target, formArgs) {
|
|
13118
|
-
if (!binding.confirm) return void 0;
|
|
13119
|
-
const merged = completeArgs(binding.path, { ...binding.args(ctx, target), ...formArgs });
|
|
13120
|
-
if (!merged.ok) return void 0;
|
|
13121
|
-
return binding.confirm(ctx, merged.args, target);
|
|
13122
|
-
},
|
|
13123
|
-
async start(rt, ctx, target, formArgs, signal) {
|
|
13124
|
-
const merged = completeArgs(binding.path, { ...binding.args(ctx, target), ...formArgs });
|
|
13125
|
-
if (!merged.ok) return null;
|
|
13126
|
-
const commands = rt.ports.commands;
|
|
13127
|
-
if (!commands) return null;
|
|
13128
|
-
const invocation = commands.invoke(binding.path, merged.args, signal, rt.cwd);
|
|
13129
|
-
rt.begin();
|
|
13130
|
-
if (binding.invalidates === "start+settle") rt.tick();
|
|
13131
|
-
void (async () => {
|
|
13132
|
-
try {
|
|
13133
|
-
for await (const event of invocation.events) {
|
|
13134
|
-
binding.result.consume(rt, event);
|
|
13135
|
-
}
|
|
13136
|
-
if (binding.invalidates) rt.tick();
|
|
13137
|
-
} catch (err) {
|
|
13138
|
-
if (!rt.fail(err) && !(err instanceof CommandDetachedError)) {
|
|
13139
|
-
rt.ports.presenter.notify("error", ...errorNotice(err));
|
|
13140
|
-
}
|
|
13141
|
-
if (binding.invalidates) rt.tick();
|
|
13142
|
-
} finally {
|
|
13143
|
-
rt.settled?.();
|
|
13144
|
-
}
|
|
13145
|
-
})();
|
|
13146
|
-
return { cancel: () => invocation.cancel() };
|
|
13147
|
-
}
|
|
13148
|
-
};
|
|
13203
|
+
function findingKey(d) {
|
|
13204
|
+
return JSON.stringify([
|
|
13205
|
+
d.file,
|
|
13206
|
+
d.line,
|
|
13207
|
+
d.message,
|
|
13208
|
+
d.module_key,
|
|
13209
|
+
d.instance_id,
|
|
13210
|
+
d.input_name,
|
|
13211
|
+
d.address
|
|
13212
|
+
]);
|
|
13149
13213
|
}
|
|
13150
|
-
|
|
13151
|
-
|
|
13152
|
-
|
|
13153
|
-
|
|
13214
|
+
function uniqueDiagnostics(diagnostics) {
|
|
13215
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13216
|
+
return diagnostics.filter((d) => {
|
|
13217
|
+
const key = findingKey(d);
|
|
13218
|
+
if (seen.has(key)) return false;
|
|
13219
|
+
seen.add(key);
|
|
13220
|
+
return true;
|
|
13221
|
+
});
|
|
13154
13222
|
}
|
|
13155
|
-
|
|
13156
|
-
|
|
13157
|
-
path: "stack apply",
|
|
13158
|
-
args: (ctx) => ({ stack: ctx.stack?.id }),
|
|
13159
|
-
// The run sink ticks at both start and settle, so a read keyed on the
|
|
13160
|
-
// tick (a host's run list, the describe overlay) sees the in-flight run
|
|
13161
|
-
// as soon as it starts, not only once it ends.
|
|
13162
|
-
invalidates: "start+settle",
|
|
13163
|
-
result: slotSink("run")
|
|
13164
|
-
});
|
|
13165
|
-
var destroy = defineCommand({
|
|
13166
|
-
kind: "command",
|
|
13167
|
-
path: "stack destroy",
|
|
13168
|
-
args: (ctx) => ({ stack: ctx.stack?.id, yes: true }),
|
|
13169
|
-
// The typed confirmation is the stack's slug — the human-facing name a
|
|
13170
|
-
// user actually reads off the host's stack list — never its id, which
|
|
13171
|
-
// `args.stack` carries for the command itself but nobody types from
|
|
13172
|
-
// memory.
|
|
13173
|
-
confirm: (ctx) => ({
|
|
13174
|
-
text: `Destroy ${ctx.stack?.slug}? This runs terraform destroy on the runner.`,
|
|
13175
|
-
typed: ctx.stack?.slug
|
|
13176
|
-
}),
|
|
13177
|
-
invalidates: "start+settle",
|
|
13178
|
-
result: slotSink("run")
|
|
13179
|
-
});
|
|
13180
|
-
function scanNotice(e) {
|
|
13181
|
-
const { slug } = e.stack;
|
|
13182
|
-
const settled = e.settled;
|
|
13183
|
-
if (!settled) {
|
|
13184
|
-
return e.triggered ? `Drift scan triggered for stack ${slug} (${e.stack.id}).` : `Drift scan already in progress for stack ${slug}.`;
|
|
13185
|
-
}
|
|
13186
|
-
if (settled.undeterminedReason !== null) return void 0;
|
|
13187
|
-
if (settled.footprintDestroyed) {
|
|
13188
|
-
return `Drift scan complete for stack ${slug}: IN_SYNC (0 drifted) \u2014 its resources were destroyed, so there was nothing to compare.`;
|
|
13189
|
-
}
|
|
13190
|
-
if (settled.standingDriftFindings > 0) {
|
|
13191
|
-
return `Drift scan complete for stack ${slug}: the scan observed no drift, but ${settled.standingDriftFindings} drift finding(s) from earlier scans still stand \u2014 the stack remains DRIFTED.`;
|
|
13192
|
-
}
|
|
13193
|
-
return `Drift scan complete for stack ${slug}: ${settled.driftStatus} (${settled.driftCount} drifted).`;
|
|
13223
|
+
function diagnosticsOf(sourceDiagnostics, reportFindings) {
|
|
13224
|
+
return uniqueDiagnostics([...sourceDiagnostics, ...reportFindings]);
|
|
13194
13225
|
}
|
|
13195
|
-
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
|
|
13204
|
-
|
|
13205
|
-
}
|
|
13226
|
+
|
|
13227
|
+
// src/core/report-fold.ts
|
|
13228
|
+
var REPORT_PATHS = ["module validate", "module convert", "module scan"];
|
|
13229
|
+
var FOLDS_AS = new Map([
|
|
13230
|
+
...REPORT_PATHS.map((path) => [path, path]),
|
|
13231
|
+
["stack import", "module convert"]
|
|
13232
|
+
]);
|
|
13233
|
+
var EMPTY_REPORT_FOLD = /* @__PURE__ */ new Map();
|
|
13234
|
+
function readEntry(path, exitCode, data) {
|
|
13235
|
+
if (carriesFailure(data)) {
|
|
13236
|
+
return { kind: "failure", path, exitCode, failure: parseCommandFailure(data) };
|
|
13206
13237
|
}
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
kind: "notify",
|
|
13215
|
-
consume: (rt, e) => rt.ports.presenter.notify("info", `Created stack ${e.slug}`)
|
|
13238
|
+
switch (path) {
|
|
13239
|
+
case "module validate":
|
|
13240
|
+
return { kind: "result", path, exitCode, document: parseBound(path, data) };
|
|
13241
|
+
case "module convert":
|
|
13242
|
+
return { kind: "result", path, exitCode, document: parseBound(path, data) };
|
|
13243
|
+
case "module scan":
|
|
13244
|
+
return { kind: "result", path, exitCode, document: parseBound(path, data) };
|
|
13216
13245
|
}
|
|
13217
|
-
});
|
|
13218
|
-
function residualAddresses(residuals) {
|
|
13219
|
-
return residuals.map((r) => r.address).join(", ");
|
|
13220
13246
|
}
|
|
13221
|
-
function
|
|
13222
|
-
|
|
13223
|
-
|
|
13224
|
-
|
|
13225
|
-
|
|
13247
|
+
function foldReport(prev, result) {
|
|
13248
|
+
const path = FOLDS_AS.get(result.path);
|
|
13249
|
+
if (path === void 0) return prev;
|
|
13250
|
+
const next = new Map(prev);
|
|
13251
|
+
if (result.document === "") next.delete(path);
|
|
13252
|
+
else next.set(path, readEntry(path, result.exitCode, JSON.parse(result.document)));
|
|
13253
|
+
return next;
|
|
13226
13254
|
}
|
|
13227
|
-
function
|
|
13228
|
-
|
|
13229
|
-
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
|
|
13233
|
-
|
|
13234
|
-
|
|
13235
|
-
const adopt = e.changed ? ` Review the change in git, commit it, then apply ${slug} to adopt them.` : "";
|
|
13236
|
-
if (e.importResiduals.length === 0) return ["info", `${imported}${adopt}`];
|
|
13237
|
-
return [
|
|
13238
|
-
"warn",
|
|
13239
|
-
`${imported}${adopt} Not adopted: ${residualAddresses(e.importResiduals)}; supply their import ids before applying, or the apply creates them anew.`
|
|
13240
|
-
];
|
|
13241
|
-
}
|
|
13242
|
-
var importResult = {
|
|
13243
|
-
kind: "notify",
|
|
13244
|
-
consume: (rt, e) => rt.ports.presenter.notify(...importNotice(e))
|
|
13245
|
-
};
|
|
13246
|
-
var importStack = defineCommand({
|
|
13247
|
-
kind: "command",
|
|
13248
|
-
path: "stack import",
|
|
13249
|
-
args: (ctx) => ({ stack: ctx.stack?.id }),
|
|
13250
|
-
invalidates: true,
|
|
13251
|
-
result: importResult
|
|
13252
|
-
});
|
|
13253
|
-
var importPartial = defineCommand({
|
|
13254
|
-
kind: "command",
|
|
13255
|
-
path: "stack import",
|
|
13256
|
-
args: (ctx) => ({ stack: ctx.stack?.id, allowPartial: true }),
|
|
13257
|
-
confirm: (ctx, _args, target) => ({
|
|
13258
|
-
text: `Import into ${ctx.stack?.slug} without adopting ${residualAddresses(target.failure?.importResiduals ?? [])}? Lace writes no import block for them, so the stack's apply creates them anew beside the live ones.`
|
|
13259
|
-
}),
|
|
13260
|
-
invalidates: true,
|
|
13261
|
-
result: importResult
|
|
13262
|
-
});
|
|
13263
|
-
var validate = defineCommand({
|
|
13264
|
-
kind: "command",
|
|
13265
|
-
path: "module validate",
|
|
13266
|
-
args: () => ({}),
|
|
13267
|
-
result: {
|
|
13268
|
-
kind: "notify",
|
|
13269
|
-
consume: (rt, e) => {
|
|
13270
|
-
if (e.exitClass === "ok") rt.ports.presenter.notify("info", `Valid for Lace \u2014 ${e.verdict}`);
|
|
13271
|
-
}
|
|
13272
|
-
}
|
|
13273
|
-
});
|
|
13274
|
-
var convert = defineCommand({
|
|
13275
|
-
kind: "command",
|
|
13276
|
-
path: "module convert",
|
|
13277
|
-
args: () => ({}),
|
|
13278
|
-
result: {
|
|
13279
|
-
kind: "notify",
|
|
13280
|
-
consume: (rt, e) => rt.ports.presenter.notify(
|
|
13281
|
-
"info",
|
|
13282
|
-
e.changed ? `Converted \u2014 ${e.written.length} file(s) written` : "Already lace-style \u2014 nothing to write"
|
|
13283
|
-
)
|
|
13284
|
-
}
|
|
13285
|
-
});
|
|
13286
|
-
var preview = defineCommand({
|
|
13287
|
-
kind: "command",
|
|
13288
|
-
path: "stack preview",
|
|
13289
|
-
args: (ctx) => ({ stack: ctx.stack?.id }),
|
|
13290
|
-
result: slotSink("preview")
|
|
13291
|
-
});
|
|
13292
|
-
var runCancel = defineCommand({
|
|
13293
|
-
kind: "command",
|
|
13294
|
-
path: "run cancel",
|
|
13295
|
-
args: (_ctx, target) => ({ run: target.runId }),
|
|
13296
|
-
invalidates: true,
|
|
13297
|
-
result: {
|
|
13298
|
-
kind: "notify",
|
|
13299
|
-
consume: (rt, e) => rt.ports.presenter.notify("info", `Run ${e.id} ${e.status}`)
|
|
13300
|
-
}
|
|
13301
|
-
});
|
|
13302
|
-
var followLogs = defineCommand({
|
|
13303
|
-
kind: "command",
|
|
13304
|
-
path: "run logs",
|
|
13305
|
-
args: (_ctx, target) => ({ run: target.runId, follow: true }),
|
|
13306
|
-
result: slotSink("follow")
|
|
13307
|
-
});
|
|
13308
|
-
var MODULE_COMMAND_ACTIONS = [
|
|
13309
|
-
{
|
|
13310
|
-
id: "validate",
|
|
13311
|
-
label: "Validate",
|
|
13312
|
-
icon: "validate",
|
|
13313
|
-
section: "check",
|
|
13314
|
-
placement: "toolbar",
|
|
13315
|
-
requiredPorts: ["commands"],
|
|
13316
|
-
requiredContext: ["root"],
|
|
13317
|
-
binding: validate
|
|
13318
|
-
},
|
|
13319
|
-
{
|
|
13320
|
-
id: "convert",
|
|
13321
|
-
label: "Convert",
|
|
13322
|
-
icon: "convert",
|
|
13323
|
-
section: "check",
|
|
13324
|
-
placement: "toolbar",
|
|
13325
|
-
requiredPorts: ["commands"],
|
|
13326
|
-
requiredContext: ["root"],
|
|
13327
|
-
binding: convert
|
|
13328
|
-
},
|
|
13329
|
-
// Convert on the source-refused banner while the tree is out of lace
|
|
13330
|
-
// shape: the same `module convert` the toolbar runs, and the choice the
|
|
13331
|
-
// banner says of it. The engine re-derives the tree it writes, which
|
|
13332
|
-
// accepts it and lifts the lock.
|
|
13333
|
-
{
|
|
13334
|
-
id: "convert-refused",
|
|
13335
|
-
label: "Convert",
|
|
13336
|
-
choice: "Convert restructures it in place; a stack's apply creates only what its state does not hold yet.",
|
|
13337
|
-
icon: "convert",
|
|
13338
|
-
placement: { row: "source-refused" },
|
|
13339
|
-
requiredPorts: ["commands"],
|
|
13340
|
-
requiredContext: ["root", "needsConversion"],
|
|
13341
|
-
binding: convert
|
|
13342
|
-
}
|
|
13343
|
-
];
|
|
13344
|
-
var STACK_COMMAND_ACTIONS = [
|
|
13345
|
-
{
|
|
13346
|
-
id: "apply",
|
|
13347
|
-
label: "Apply",
|
|
13348
|
-
placement: "toolbar",
|
|
13349
|
-
requiredPorts: ["commands"],
|
|
13350
|
-
// `stack apply` gates on the tf and certification of the directory it
|
|
13351
|
-
// runs in (submit.Prepare(env.Root)) before it ever reaches the
|
|
13352
|
-
// runner, so a mount with no root can't run it even with a stack
|
|
13353
|
-
// chosen — the same root gate `validate`/`convert` need. It ships
|
|
13354
|
-
// whatever tf is on disk, not the canvas's own working IR.
|
|
13355
|
-
requiredContext: ["root", "stack"],
|
|
13356
|
-
binding: apply
|
|
13357
|
-
},
|
|
13358
|
-
{
|
|
13359
|
-
id: "destroy",
|
|
13360
|
-
label: "Destroy",
|
|
13361
|
-
placement: "toolbar",
|
|
13362
|
-
requiredPorts: ["commands"],
|
|
13363
|
-
// `stack destroy` shares the CLI's `executeRun` with `stack apply` and
|
|
13364
|
-
// runs under `env.Root`, so it needs the identical context tuple.
|
|
13365
|
-
requiredContext: ["root", "stack"],
|
|
13366
|
-
binding: destroy
|
|
13367
|
-
},
|
|
13368
|
-
{
|
|
13369
|
-
id: "scan",
|
|
13370
|
-
label: "Scan for drift",
|
|
13371
|
-
placement: "toolbar",
|
|
13372
|
-
requiredPorts: ["commands"],
|
|
13373
|
-
requiredContext: ["stack"],
|
|
13374
|
-
binding: scan
|
|
13375
|
-
},
|
|
13376
|
-
{
|
|
13377
|
-
id: "create",
|
|
13378
|
-
label: "Create stack",
|
|
13379
|
-
placement: "toolbar",
|
|
13380
|
-
requiredPorts: ["commands"],
|
|
13381
|
-
requiredContext: ["root"],
|
|
13382
|
-
binding: create
|
|
13383
|
-
},
|
|
13384
|
-
{
|
|
13385
|
-
id: "import",
|
|
13386
|
-
label: "Import existing resources",
|
|
13387
|
-
placement: "toolbar",
|
|
13388
|
-
requiredPorts: ["commands"],
|
|
13389
|
-
// `stack import` writes the directory it runs in, the same way
|
|
13390
|
-
// Convert does.
|
|
13391
|
-
requiredContext: ["root", "stack"],
|
|
13392
|
-
binding: importStack
|
|
13393
|
-
},
|
|
13394
|
-
{
|
|
13395
|
-
id: "import-partial",
|
|
13396
|
-
label: "Import the rest",
|
|
13397
|
-
placement: { row: "failure" },
|
|
13398
|
-
requiredPorts: ["commands"],
|
|
13399
|
-
requiredContext: ["root", "stack"],
|
|
13400
|
-
answers: ["import_residual"],
|
|
13401
|
-
binding: importPartial
|
|
13402
|
-
},
|
|
13403
|
-
{
|
|
13404
|
-
id: "preview",
|
|
13405
|
-
label: "Preview",
|
|
13406
|
-
placement: "toolbar",
|
|
13407
|
-
requiredPorts: ["commands"],
|
|
13408
|
-
// `stack preview` plans the tf of the directory it runs in — a stack
|
|
13409
|
-
// alone isn't enough, the mount needs the root too.
|
|
13410
|
-
requiredContext: ["root", "stack"],
|
|
13411
|
-
binding: preview
|
|
13412
|
-
},
|
|
13413
|
-
{
|
|
13414
|
-
id: "run-cancel",
|
|
13415
|
-
label: "Cancel",
|
|
13416
|
-
placement: { row: "runs" },
|
|
13417
|
-
requiredPorts: ["commands"],
|
|
13418
|
-
requiredTarget: ["runId"],
|
|
13419
|
-
binding: runCancel
|
|
13420
|
-
},
|
|
13421
|
-
{
|
|
13422
|
-
id: "follow-logs",
|
|
13423
|
-
label: "Follow logs",
|
|
13424
|
-
placement: { row: "runs" },
|
|
13425
|
-
requiredPorts: ["commands"],
|
|
13426
|
-
requiredTarget: ["runId"],
|
|
13427
|
-
binding: followLogs
|
|
13428
|
-
}
|
|
13429
|
-
];
|
|
13430
|
-
var CORE_COMMAND_ACTIONS = [
|
|
13431
|
-
...STACK_COMMAND_ACTIONS,
|
|
13432
|
-
...MODULE_COMMAND_ACTIONS
|
|
13433
|
-
];
|
|
13434
|
-
|
|
13435
|
-
// src/core/diagnostics.ts
|
|
13436
|
-
var NOT_LACE_SHAPE = "not_lace_shape";
|
|
13437
|
-
function holdsLaceShapeRefusal(diagnostics) {
|
|
13438
|
-
return diagnostics.some((d) => d.code === NOT_LACE_SHAPE);
|
|
13439
|
-
}
|
|
13440
|
-
function findingKey(d) {
|
|
13441
|
-
return JSON.stringify([
|
|
13442
|
-
d.file,
|
|
13443
|
-
d.line,
|
|
13444
|
-
d.message,
|
|
13445
|
-
d.module_key,
|
|
13446
|
-
d.instance_id,
|
|
13447
|
-
d.input_name,
|
|
13448
|
-
d.address
|
|
13449
|
-
]);
|
|
13450
|
-
}
|
|
13451
|
-
function uniqueDiagnostics(diagnostics) {
|
|
13452
|
-
const seen = /* @__PURE__ */ new Set();
|
|
13453
|
-
return diagnostics.filter((d) => {
|
|
13454
|
-
const key = findingKey(d);
|
|
13455
|
-
if (seen.has(key)) return false;
|
|
13456
|
-
seen.add(key);
|
|
13457
|
-
return true;
|
|
13458
|
-
});
|
|
13459
|
-
}
|
|
13460
|
-
function diagnosticsOf(sourceDiagnostics, reportFindings) {
|
|
13461
|
-
return uniqueDiagnostics([...sourceDiagnostics, ...reportFindings]);
|
|
13462
|
-
}
|
|
13463
|
-
|
|
13464
|
-
// src/core/report-fold.ts
|
|
13465
|
-
var REPORT_PATHS = ["module validate", "module convert", "module scan"];
|
|
13466
|
-
var FOLDS_AS = new Map([
|
|
13467
|
-
...REPORT_PATHS.map((path) => [path, path]),
|
|
13468
|
-
["stack import", "module convert"]
|
|
13469
|
-
]);
|
|
13470
|
-
var EMPTY_REPORT_FOLD = /* @__PURE__ */ new Map();
|
|
13471
|
-
function readEntry(path, exitCode, data) {
|
|
13472
|
-
if (carriesFailure(data)) {
|
|
13473
|
-
return { kind: "failure", path, exitCode, failure: parseCommandFailure(data) };
|
|
13474
|
-
}
|
|
13475
|
-
switch (path) {
|
|
13476
|
-
case "module validate":
|
|
13477
|
-
return { kind: "result", path, exitCode, document: parseBound(path, data) };
|
|
13478
|
-
case "module convert":
|
|
13479
|
-
return { kind: "result", path, exitCode, document: parseBound(path, data) };
|
|
13480
|
-
case "module scan":
|
|
13481
|
-
return { kind: "result", path, exitCode, document: parseBound(path, data) };
|
|
13482
|
-
}
|
|
13483
|
-
}
|
|
13484
|
-
function foldReport(prev, result) {
|
|
13485
|
-
const path = FOLDS_AS.get(result.path);
|
|
13486
|
-
if (path === void 0) return prev;
|
|
13487
|
-
const next = new Map(prev);
|
|
13488
|
-
if (result.document === "") next.delete(path);
|
|
13489
|
-
else next.set(path, readEntry(path, result.exitCode, JSON.parse(result.document)));
|
|
13490
|
-
return next;
|
|
13491
|
-
}
|
|
13492
|
-
function treeHashOf(entry) {
|
|
13493
|
-
if (entry.kind === "failure") return void 0;
|
|
13494
|
-
switch (entry.path) {
|
|
13495
|
-
case "module validate":
|
|
13496
|
-
case "module scan":
|
|
13497
|
-
return entry.document.treeHash;
|
|
13498
|
-
case "module convert":
|
|
13499
|
-
return entry.document.validate.treeHash;
|
|
13255
|
+
function treeHashOf(entry) {
|
|
13256
|
+
if (entry.kind === "failure") return void 0;
|
|
13257
|
+
switch (entry.path) {
|
|
13258
|
+
case "module validate":
|
|
13259
|
+
case "module scan":
|
|
13260
|
+
return entry.document.treeHash;
|
|
13261
|
+
case "module convert":
|
|
13262
|
+
return entry.document.validate.treeHash;
|
|
13500
13263
|
}
|
|
13501
13264
|
}
|
|
13502
13265
|
function currentReport(fold, treeHash) {
|
|
@@ -13590,27 +13353,33 @@ function reduceRun(prev, token, event) {
|
|
|
13590
13353
|
phases
|
|
13591
13354
|
};
|
|
13592
13355
|
}
|
|
13593
|
-
if (event.error)
|
|
13356
|
+
if (!event.error)
|
|
13594
13357
|
return {
|
|
13595
13358
|
token,
|
|
13596
|
-
outcome: { kind: "
|
|
13359
|
+
outcome: { kind: "succeeded" },
|
|
13597
13360
|
lastLog,
|
|
13598
13361
|
submitted,
|
|
13599
13362
|
phases: closePhases(phases)
|
|
13600
13363
|
};
|
|
13601
|
-
return {
|
|
13602
|
-
token,
|
|
13603
|
-
outcome: { kind: "succeeded" },
|
|
13604
|
-
lastLog,
|
|
13605
|
-
submitted,
|
|
13606
|
-
phases: closePhases(phases)
|
|
13607
|
-
};
|
|
13608
13364
|
}
|
|
13609
13365
|
return { token, outcome: { kind: "running" }, lastLog, submitted, phases };
|
|
13610
13366
|
}
|
|
13611
|
-
function
|
|
13612
|
-
|
|
13367
|
+
function runningFor(slot, token) {
|
|
13368
|
+
if (slot?.token !== token) return false;
|
|
13369
|
+
return "done" in slot ? !slot.done : slot.outcome.kind === "running";
|
|
13370
|
+
}
|
|
13371
|
+
function failureSays(error, command) {
|
|
13372
|
+
if (error instanceof CommandExitError) {
|
|
13373
|
+
if (error.failure) return { message: error.failure.message, failure: error.failure };
|
|
13374
|
+
const stderr = error.stderrTail.trim();
|
|
13375
|
+
return { message: stderr || `the command exited with code ${error.code} and wrote nothing` };
|
|
13376
|
+
}
|
|
13377
|
+
if (error instanceof CommandUnobservedError && command.kind === "read") {
|
|
13378
|
+
return { message: `the stream ended before \`lace ${command.path}\` finished; run it again` };
|
|
13379
|
+
}
|
|
13380
|
+
return { message: error instanceof Error ? error.message : String(error) };
|
|
13613
13381
|
}
|
|
13382
|
+
var RUN = { kind: "write" };
|
|
13614
13383
|
function settleRun(prev, token, error) {
|
|
13615
13384
|
const carried = prev && prev.token === token ? prev : null;
|
|
13616
13385
|
const lastLog = carried?.lastLog ?? null;
|
|
@@ -13626,29 +13395,22 @@ function settleRun(prev, token, error) {
|
|
|
13626
13395
|
if (error.code === 7)
|
|
13627
13396
|
return {
|
|
13628
13397
|
token,
|
|
13629
|
-
outcome: { kind: "blocked", ...
|
|
13398
|
+
outcome: { kind: "blocked", ...failureSays(error, RUN) },
|
|
13630
13399
|
lastLog,
|
|
13631
13400
|
submitted,
|
|
13632
13401
|
phases
|
|
13633
13402
|
};
|
|
13634
|
-
return {
|
|
13635
|
-
token,
|
|
13636
|
-
outcome: { kind: "failed", ...exitSays(error) },
|
|
13637
|
-
lastLog,
|
|
13638
|
-
submitted,
|
|
13639
|
-
phases
|
|
13640
|
-
};
|
|
13641
13403
|
}
|
|
13642
13404
|
return {
|
|
13643
13405
|
token,
|
|
13644
|
-
outcome: { kind: "failed",
|
|
13406
|
+
outcome: { kind: "failed", ...failureSays(error, RUN) },
|
|
13645
13407
|
lastLog,
|
|
13646
13408
|
submitted,
|
|
13647
13409
|
phases
|
|
13648
13410
|
};
|
|
13649
13411
|
}
|
|
13650
13412
|
function reducePreview(_prev, token, event) {
|
|
13651
|
-
return { token, data: event };
|
|
13413
|
+
return { token, outcome: { kind: "succeeded", data: event } };
|
|
13652
13414
|
}
|
|
13653
13415
|
function reduceReport(prev, session, result) {
|
|
13654
13416
|
const fold = foldReport(prev?.sessions.get(session) ?? EMPTY_REPORT_FOLD, result);
|
|
@@ -13661,93 +13423,482 @@ function reduceFollow(prev, token, event) {
|
|
|
13661
13423
|
if (event.type === "log") return { token, runId, lines: [...lines, event.text], done: false };
|
|
13662
13424
|
return { token, runId, lines, done: true };
|
|
13663
13425
|
}
|
|
13664
|
-
function
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
|
|
13682
|
-
|
|
13683
|
-
|
|
13684
|
-
|
|
13685
|
-
|
|
13686
|
-
|
|
13687
|
-
|
|
13688
|
-
|
|
13689
|
-
|
|
13690
|
-
|
|
13691
|
-
|
|
13692
|
-
|
|
13693
|
-
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13703
|
-
|
|
13704
|
-
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
|
|
13733
|
-
|
|
13734
|
-
|
|
13735
|
-
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
|
|
13739
|
-
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13426
|
+
function endStream(current, kind, token, error) {
|
|
13427
|
+
const { run, preview: preview2, follow } = current;
|
|
13428
|
+
if (kind === "run" && runningFor(run, token))
|
|
13429
|
+
return { ...current, run: stamp(settleRun(run, token, error), run.readOver) };
|
|
13430
|
+
if (kind === "preview" && runningFor(preview2, token)) return { ...current, preview: null };
|
|
13431
|
+
if (kind === "follow" && runningFor(follow, token))
|
|
13432
|
+
return { ...current, follow: { ...follow, done: true } };
|
|
13433
|
+
return current;
|
|
13434
|
+
}
|
|
13435
|
+
function createResultStore() {
|
|
13436
|
+
let slots = {
|
|
13437
|
+
run: null,
|
|
13438
|
+
preview: null,
|
|
13439
|
+
report: null,
|
|
13440
|
+
follow: null,
|
|
13441
|
+
running: /* @__PURE__ */ new Map()
|
|
13442
|
+
};
|
|
13443
|
+
let tick = 0;
|
|
13444
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
13445
|
+
const notify = () => {
|
|
13446
|
+
for (const listener of listeners) listener();
|
|
13447
|
+
};
|
|
13448
|
+
const retiredTokens = /* @__PURE__ */ new WeakSet();
|
|
13449
|
+
return {
|
|
13450
|
+
getSnapshot() {
|
|
13451
|
+
return slots;
|
|
13452
|
+
},
|
|
13453
|
+
getTick() {
|
|
13454
|
+
return tick;
|
|
13455
|
+
},
|
|
13456
|
+
subscribe(listener) {
|
|
13457
|
+
listeners.add(listener);
|
|
13458
|
+
return () => listeners.delete(listener);
|
|
13459
|
+
},
|
|
13460
|
+
write(kind, token, value, readOver) {
|
|
13461
|
+
if (retiredTokens.has(token)) return;
|
|
13462
|
+
slots = { ...slots, [kind]: applySlot(kind, slots[kind], token, value, readOver) };
|
|
13463
|
+
notify();
|
|
13464
|
+
},
|
|
13465
|
+
fail(kind, token, error) {
|
|
13466
|
+
const rendered = kind === "run";
|
|
13467
|
+
if (retiredTokens.has(token)) return rendered;
|
|
13468
|
+
const next = endStream(slots, kind, token, error);
|
|
13469
|
+
if (next !== slots) {
|
|
13470
|
+
slots = next;
|
|
13471
|
+
notify();
|
|
13472
|
+
}
|
|
13473
|
+
return rendered;
|
|
13474
|
+
},
|
|
13475
|
+
begin(kind, token, readOver, started) {
|
|
13476
|
+
if (kind === "run") {
|
|
13477
|
+
slots = {
|
|
13478
|
+
...slots,
|
|
13479
|
+
run: {
|
|
13480
|
+
token,
|
|
13481
|
+
outcome: { kind: "running" },
|
|
13482
|
+
lastLog: null,
|
|
13483
|
+
submitted: false,
|
|
13484
|
+
phases: [],
|
|
13485
|
+
readOver
|
|
13486
|
+
}
|
|
13487
|
+
};
|
|
13488
|
+
} else if (kind === "preview") {
|
|
13489
|
+
slots = { ...slots, preview: { token, outcome: { kind: "running" }, readOver } };
|
|
13490
|
+
} else if (kind === "follow") {
|
|
13491
|
+
slots = {
|
|
13492
|
+
...slots,
|
|
13493
|
+
follow: { token, runId: started.target.runId ?? "", lines: [], done: false, readOver }
|
|
13494
|
+
};
|
|
13495
|
+
} else if (kind === "notify") {
|
|
13496
|
+
const { on, path, label } = started;
|
|
13497
|
+
slots = { ...slots, running: new Map(slots.running).set(on, { token, path, label }) };
|
|
13498
|
+
} else {
|
|
13499
|
+
return;
|
|
13500
|
+
}
|
|
13501
|
+
notify();
|
|
13502
|
+
},
|
|
13503
|
+
detach(kind, token) {
|
|
13504
|
+
let next = endStream(slots, kind, token, new CommandDetachedError());
|
|
13505
|
+
if (kind === "follow" && next.follow?.token === token) {
|
|
13506
|
+
next = { ...next, follow: null };
|
|
13507
|
+
} else if (kind === "report" && next.report?.sessions.has(token)) {
|
|
13508
|
+
const sessions = new Map(next.report.sessions);
|
|
13509
|
+
sessions.delete(token);
|
|
13510
|
+
next = {
|
|
13511
|
+
...next,
|
|
13512
|
+
report: sessions.size > 0 ? { sessions, readOver: next.report.readOver } : null
|
|
13513
|
+
};
|
|
13514
|
+
} else if (kind === "notify") {
|
|
13515
|
+
const running = new Map([...next.running].filter(([, mark]) => mark.token !== token));
|
|
13516
|
+
if (running.size !== next.running.size) next = { ...next, running };
|
|
13517
|
+
}
|
|
13518
|
+
if (next !== slots) {
|
|
13519
|
+
slots = next;
|
|
13520
|
+
notify();
|
|
13521
|
+
}
|
|
13522
|
+
retiredTokens.add(token);
|
|
13523
|
+
},
|
|
13524
|
+
busy(kind, on) {
|
|
13525
|
+
if (kind === "run") {
|
|
13526
|
+
return slots.run?.outcome.kind === "running" ? { kind: "run" } : void 0;
|
|
13527
|
+
}
|
|
13528
|
+
if (kind !== "notify") return void 0;
|
|
13529
|
+
const running = slots.running.get(on);
|
|
13530
|
+
return running ? { kind: "notify", running } : void 0;
|
|
13531
|
+
},
|
|
13532
|
+
bumpTick() {
|
|
13533
|
+
tick += 1;
|
|
13534
|
+
notify();
|
|
13535
|
+
}
|
|
13536
|
+
};
|
|
13537
|
+
}
|
|
13538
|
+
|
|
13539
|
+
// src/core/define-command.ts
|
|
13540
|
+
function defineCommand(binding) {
|
|
13541
|
+
return {
|
|
13542
|
+
kind: "command",
|
|
13543
|
+
path: binding.path,
|
|
13544
|
+
confirms: binding.confirm !== void 0,
|
|
13545
|
+
resultKind: binding.result.kind,
|
|
13546
|
+
invalidates: binding.invalidates,
|
|
13547
|
+
partialArgs(ctx, target) {
|
|
13548
|
+
return binding.args(ctx, target);
|
|
13549
|
+
},
|
|
13550
|
+
confirmSpec(ctx, target, formArgs) {
|
|
13551
|
+
if (!binding.confirm) return void 0;
|
|
13552
|
+
const merged = completeArgs(binding.path, { ...binding.args(ctx, target), ...formArgs });
|
|
13553
|
+
if (!merged.ok) return void 0;
|
|
13554
|
+
return binding.confirm(ctx, merged.args, target);
|
|
13555
|
+
},
|
|
13556
|
+
async start(rt, ctx, target, formArgs, signal) {
|
|
13557
|
+
const merged = completeArgs(binding.path, { ...binding.args(ctx, target), ...formArgs });
|
|
13558
|
+
if (!merged.ok) return null;
|
|
13559
|
+
const commands = rt.ports.commands;
|
|
13560
|
+
if (!commands) return null;
|
|
13561
|
+
const invocation = commands.invoke(binding.path, merged.args, signal, rt.cwd);
|
|
13562
|
+
rt.begin();
|
|
13563
|
+
if (binding.invalidates === "start+settle") rt.tick();
|
|
13564
|
+
void (async () => {
|
|
13565
|
+
let rendered = false;
|
|
13566
|
+
try {
|
|
13567
|
+
for await (const event of invocation.events) {
|
|
13568
|
+
rendered = true;
|
|
13569
|
+
binding.result.consume(rt, event);
|
|
13570
|
+
}
|
|
13571
|
+
if (binding.invalidates) rt.tick();
|
|
13572
|
+
} catch (err) {
|
|
13573
|
+
const settledByDocument = rendered && binding.result.kind === "notify" && (err instanceof CommandExitError || err instanceof CommandUnobservedError);
|
|
13574
|
+
if (!rt.fail(err) && !(err instanceof CommandDetachedError) && !settledByDocument) {
|
|
13575
|
+
const { message, failure } = failureSays(
|
|
13576
|
+
err,
|
|
13577
|
+
binding.result.kind === "preview" || binding.result.kind === "follow" ? { kind: "read", path: binding.path } : { kind: "write" }
|
|
13578
|
+
);
|
|
13579
|
+
rt.ports.presenter.notify("error", message, ...failure ? [failure] : []);
|
|
13580
|
+
}
|
|
13581
|
+
if (binding.invalidates) rt.tick();
|
|
13582
|
+
} finally {
|
|
13583
|
+
rt.settled?.();
|
|
13584
|
+
}
|
|
13585
|
+
})();
|
|
13586
|
+
return { cancel: () => invocation.cancel() };
|
|
13587
|
+
}
|
|
13588
|
+
};
|
|
13589
|
+
}
|
|
13590
|
+
|
|
13591
|
+
// src/core/actions.ts
|
|
13592
|
+
function whyNotValid(v) {
|
|
13593
|
+
if (v.failure) return v.failure.message;
|
|
13594
|
+
const errors = v.diagnostics.filter((d) => d.severity === "error");
|
|
13595
|
+
if (errors.length === 0) return void 0;
|
|
13596
|
+
return `${errors[0].message} (${errors.length} ${errors.length === 1 ? "error" : "errors"})`;
|
|
13597
|
+
}
|
|
13598
|
+
function didNotValidate(v) {
|
|
13599
|
+
const why = whyNotValid(v);
|
|
13600
|
+
return why === void 0 ? "The tree did not validate: fix it before you commit it." : `The tree did not validate: ${why}. Fix it before you commit it.`;
|
|
13601
|
+
}
|
|
13602
|
+
function beside(v) {
|
|
13603
|
+
return v.failure ? [v.failure] : [];
|
|
13604
|
+
}
|
|
13605
|
+
function slotSink(kind) {
|
|
13606
|
+
return { kind, consume: (rt, e) => rt.write(kind, rt.token, e) };
|
|
13607
|
+
}
|
|
13608
|
+
var apply = defineCommand({
|
|
13609
|
+
kind: "command",
|
|
13610
|
+
path: "stack apply",
|
|
13611
|
+
args: (ctx) => ({ stack: ctx.stack?.id }),
|
|
13612
|
+
// The run sink ticks at both start and settle, so a read keyed on the
|
|
13613
|
+
// tick (a host's run list, the describe overlay) sees the in-flight run
|
|
13614
|
+
// as soon as it starts, not only once it ends.
|
|
13615
|
+
invalidates: "start+settle",
|
|
13616
|
+
result: slotSink("run")
|
|
13617
|
+
});
|
|
13618
|
+
var destroy = defineCommand({
|
|
13619
|
+
kind: "command",
|
|
13620
|
+
path: "stack destroy",
|
|
13621
|
+
args: (ctx) => ({ stack: ctx.stack?.id, yes: true }),
|
|
13622
|
+
// The typed confirmation is the stack's slug — the human-facing name a
|
|
13623
|
+
// user actually reads off the host's stack list — never its id, which
|
|
13624
|
+
// `args.stack` carries for the command itself but nobody types from
|
|
13625
|
+
// memory.
|
|
13626
|
+
confirm: (ctx) => ({
|
|
13627
|
+
text: `Destroy ${ctx.stack?.slug}? This runs terraform destroy on the runner.`,
|
|
13628
|
+
typed: ctx.stack?.slug
|
|
13629
|
+
}),
|
|
13630
|
+
invalidates: "start+settle",
|
|
13631
|
+
result: slotSink("run")
|
|
13632
|
+
});
|
|
13633
|
+
function scanNotice(e) {
|
|
13634
|
+
const { slug } = e.stack;
|
|
13635
|
+
const settled = e.settled;
|
|
13636
|
+
if (!settled) {
|
|
13637
|
+
return [
|
|
13638
|
+
"info",
|
|
13639
|
+
e.triggered ? `Drift scan triggered for stack ${slug} (${e.stack.id}).` : `Drift scan already in progress for stack ${slug}.`
|
|
13640
|
+
];
|
|
13641
|
+
}
|
|
13642
|
+
if (settled.undeterminedMessage !== null) return ["warn", settled.undeterminedMessage];
|
|
13643
|
+
if (settled.footprintDestroyed) {
|
|
13644
|
+
return [
|
|
13645
|
+
"info",
|
|
13646
|
+
`Drift scan complete for stack ${slug}: IN_SYNC (0 drifted) \u2014 its resources were destroyed, so there was nothing to compare.`
|
|
13647
|
+
];
|
|
13648
|
+
}
|
|
13649
|
+
if (settled.standingDriftFindings > 0) {
|
|
13650
|
+
return [
|
|
13651
|
+
"info",
|
|
13652
|
+
`Drift scan complete for stack ${slug}: the scan observed no drift, but ${settled.standingDriftFindings} drift finding(s) from earlier scans still stand \u2014 the stack remains DRIFTED.`
|
|
13653
|
+
];
|
|
13654
|
+
}
|
|
13655
|
+
return [
|
|
13656
|
+
"info",
|
|
13657
|
+
`Drift scan complete for stack ${slug}: ${settled.driftStatus} (${settled.driftCount} drifted).`
|
|
13658
|
+
];
|
|
13659
|
+
}
|
|
13660
|
+
var scan = defineCommand({
|
|
13661
|
+
kind: "command",
|
|
13662
|
+
path: "stack scan",
|
|
13663
|
+
args: (ctx) => ({ stack: ctx.stack?.id, wait: true }),
|
|
13664
|
+
invalidates: true,
|
|
13665
|
+
result: {
|
|
13666
|
+
kind: "notify",
|
|
13667
|
+
consume: (rt, e) => rt.ports.presenter.notify(...scanNotice(e))
|
|
13668
|
+
}
|
|
13669
|
+
});
|
|
13670
|
+
var create = defineCommand({
|
|
13671
|
+
kind: "command",
|
|
13672
|
+
path: "stack create",
|
|
13673
|
+
args: (ctx) => ({ source: ctx.root }),
|
|
13674
|
+
invalidates: true,
|
|
13675
|
+
result: {
|
|
13676
|
+
kind: "notify",
|
|
13677
|
+
consume: (rt, e) => rt.ports.presenter.notify("info", `Created stack ${e.slug}`)
|
|
13678
|
+
}
|
|
13679
|
+
});
|
|
13680
|
+
function residualAddresses(residuals) {
|
|
13681
|
+
return residuals.map((r) => r.address).join(", ");
|
|
13682
|
+
}
|
|
13683
|
+
function treeChanges(e) {
|
|
13684
|
+
return [
|
|
13685
|
+
...e.written.length === 0 ? [] : [`rewriting ${e.written.join(", ")} in place`],
|
|
13686
|
+
...e.removed.length === 0 ? [] : [`removing ${e.removed.join(", ")}`]
|
|
13687
|
+
];
|
|
13688
|
+
}
|
|
13689
|
+
function importNotice(e) {
|
|
13690
|
+
const { slug } = e.stack;
|
|
13691
|
+
const changes = treeChanges(e);
|
|
13692
|
+
const files = changes.length > 0 ? `, ${changes.join(" and ")}` : "";
|
|
13693
|
+
const imported = `Imported ${e.importBlocks} resource(s) into ${slug}${files}.`;
|
|
13694
|
+
if (e.validate.exitClass !== "ok") {
|
|
13695
|
+
return ["warn", `${imported} ${didNotValidate(e.validate)}`, ...beside(e.validate)];
|
|
13696
|
+
}
|
|
13697
|
+
const adopt = e.changed ? ` Review the change in git, commit it, then apply ${slug} to adopt them.` : "";
|
|
13698
|
+
if (e.importResiduals.length === 0) return ["info", `${imported}${adopt}`];
|
|
13699
|
+
return [
|
|
13700
|
+
"warn",
|
|
13701
|
+
`${imported}${adopt} Not adopted: ${residualAddresses(e.importResiduals)}; supply their import ids before applying, or the apply creates them anew.`
|
|
13702
|
+
];
|
|
13703
|
+
}
|
|
13704
|
+
var importResult = {
|
|
13705
|
+
kind: "notify",
|
|
13706
|
+
consume: (rt, e) => rt.ports.presenter.notify(...importNotice(e))
|
|
13707
|
+
};
|
|
13708
|
+
var importStack = defineCommand({
|
|
13709
|
+
kind: "command",
|
|
13710
|
+
path: "stack import",
|
|
13711
|
+
args: (ctx) => ({ stack: ctx.stack?.id }),
|
|
13712
|
+
invalidates: true,
|
|
13713
|
+
result: importResult
|
|
13714
|
+
});
|
|
13715
|
+
var importPartial = defineCommand({
|
|
13716
|
+
kind: "command",
|
|
13717
|
+
path: "stack import",
|
|
13718
|
+
args: (ctx) => ({ stack: ctx.stack?.id, allowPartial: true }),
|
|
13719
|
+
confirm: (ctx, _args, target) => ({
|
|
13720
|
+
text: `Import into ${ctx.stack?.slug} without adopting ${residualAddresses(target.failure?.importResiduals ?? [])}? Lace writes no import block for them, so the stack's apply creates them anew beside the live ones.`
|
|
13721
|
+
}),
|
|
13722
|
+
invalidates: true,
|
|
13723
|
+
result: importResult
|
|
13724
|
+
});
|
|
13725
|
+
function validateNotice(v) {
|
|
13726
|
+
if (v.exitClass === "ok") return ["info", `Valid for Lace \u2014 ${v.verdict}`];
|
|
13727
|
+
if (v.failure) return ["error", v.failure.message, v.failure];
|
|
13728
|
+
const why = whyNotValid(v);
|
|
13729
|
+
return ["warn", why === void 0 ? "Not valid for Lace" : `Not valid: ${why}`];
|
|
13730
|
+
}
|
|
13731
|
+
function convertNotice(e) {
|
|
13732
|
+
const converted = e.changed ? `Converted \u2014 ${e.written.length} file(s) written` : "Already lace-style \u2014 nothing to write";
|
|
13733
|
+
if (e.validate.exitClass === "ok") return ["info", converted];
|
|
13734
|
+
return ["warn", `${converted}. ${didNotValidate(e.validate)}`, ...beside(e.validate)];
|
|
13750
13735
|
}
|
|
13736
|
+
var validate = defineCommand({
|
|
13737
|
+
kind: "command",
|
|
13738
|
+
path: "module validate",
|
|
13739
|
+
args: () => ({}),
|
|
13740
|
+
result: {
|
|
13741
|
+
kind: "notify",
|
|
13742
|
+
consume: (rt, e) => rt.ports.presenter.notify(...validateNotice(e))
|
|
13743
|
+
}
|
|
13744
|
+
});
|
|
13745
|
+
var convert = defineCommand({
|
|
13746
|
+
kind: "command",
|
|
13747
|
+
path: "module convert",
|
|
13748
|
+
args: () => ({}),
|
|
13749
|
+
result: {
|
|
13750
|
+
kind: "notify",
|
|
13751
|
+
consume: (rt, e) => rt.ports.presenter.notify(...convertNotice(e))
|
|
13752
|
+
}
|
|
13753
|
+
});
|
|
13754
|
+
var preview = defineCommand({
|
|
13755
|
+
kind: "command",
|
|
13756
|
+
path: "stack preview",
|
|
13757
|
+
args: (ctx) => ({ stack: ctx.stack?.id }),
|
|
13758
|
+
result: slotSink("preview")
|
|
13759
|
+
});
|
|
13760
|
+
var runCancel = defineCommand({
|
|
13761
|
+
kind: "command",
|
|
13762
|
+
path: "run cancel",
|
|
13763
|
+
args: (_ctx, target) => ({ run: target.runId }),
|
|
13764
|
+
invalidates: true,
|
|
13765
|
+
result: {
|
|
13766
|
+
kind: "notify",
|
|
13767
|
+
consume: (rt, e) => rt.ports.presenter.notify("info", `Run ${e.id} ${e.status}`)
|
|
13768
|
+
}
|
|
13769
|
+
});
|
|
13770
|
+
var followLogs = defineCommand({
|
|
13771
|
+
kind: "command",
|
|
13772
|
+
path: "run logs",
|
|
13773
|
+
args: (_ctx, target) => ({ run: target.runId, follow: true }),
|
|
13774
|
+
result: slotSink("follow")
|
|
13775
|
+
});
|
|
13776
|
+
var MODULE_COMMAND_ACTIONS = [
|
|
13777
|
+
{
|
|
13778
|
+
id: "validate",
|
|
13779
|
+
label: "Validate",
|
|
13780
|
+
icon: "validate",
|
|
13781
|
+
section: "check",
|
|
13782
|
+
placement: "toolbar",
|
|
13783
|
+
requiredPorts: ["commands"],
|
|
13784
|
+
requiredContext: ["root"],
|
|
13785
|
+
binding: validate
|
|
13786
|
+
},
|
|
13787
|
+
{
|
|
13788
|
+
id: "convert",
|
|
13789
|
+
label: "Convert",
|
|
13790
|
+
icon: "convert",
|
|
13791
|
+
section: "check",
|
|
13792
|
+
placement: "toolbar",
|
|
13793
|
+
requiredPorts: ["commands"],
|
|
13794
|
+
requiredContext: ["root"],
|
|
13795
|
+
binding: convert
|
|
13796
|
+
},
|
|
13797
|
+
// Convert on the source-refused banner while the tree is out of lace
|
|
13798
|
+
// shape: the same `module convert` the toolbar runs, and the choice the
|
|
13799
|
+
// banner says of it. The engine re-derives the tree it writes, which
|
|
13800
|
+
// accepts it and lifts the lock.
|
|
13801
|
+
{
|
|
13802
|
+
id: "convert-refused",
|
|
13803
|
+
label: "Convert",
|
|
13804
|
+
choice: "Convert restructures it in place; a stack's apply creates only what its state does not hold yet.",
|
|
13805
|
+
icon: "convert",
|
|
13806
|
+
placement: { row: "source-refused" },
|
|
13807
|
+
requiredPorts: ["commands"],
|
|
13808
|
+
requiredContext: ["root", "needsConversion"],
|
|
13809
|
+
binding: convert
|
|
13810
|
+
}
|
|
13811
|
+
];
|
|
13812
|
+
var STACK_COMMAND_ACTIONS = [
|
|
13813
|
+
{
|
|
13814
|
+
id: "apply",
|
|
13815
|
+
label: "Apply",
|
|
13816
|
+
placement: "toolbar",
|
|
13817
|
+
requiredPorts: ["commands"],
|
|
13818
|
+
// `stack apply` gates on the tf and certification of the directory it
|
|
13819
|
+
// runs in (submit.Prepare(env.Root)) before it ever reaches the
|
|
13820
|
+
// runner, so a mount with no root can't run it even with a stack
|
|
13821
|
+
// chosen — the same root gate `validate`/`convert` need. It ships
|
|
13822
|
+
// whatever tf is on disk, not the canvas's own working IR.
|
|
13823
|
+
requiredContext: ["root", "stack"],
|
|
13824
|
+
binding: apply
|
|
13825
|
+
},
|
|
13826
|
+
{
|
|
13827
|
+
id: "destroy",
|
|
13828
|
+
label: "Destroy",
|
|
13829
|
+
placement: "toolbar",
|
|
13830
|
+
requiredPorts: ["commands"],
|
|
13831
|
+
// `stack destroy` shares the CLI's `executeRun` with `stack apply` and
|
|
13832
|
+
// runs under `env.Root`, so it needs the identical context tuple.
|
|
13833
|
+
requiredContext: ["root", "stack"],
|
|
13834
|
+
binding: destroy
|
|
13835
|
+
},
|
|
13836
|
+
{
|
|
13837
|
+
id: "scan",
|
|
13838
|
+
label: "Scan for drift",
|
|
13839
|
+
placement: "toolbar",
|
|
13840
|
+
requiredPorts: ["commands"],
|
|
13841
|
+
requiredContext: ["stack"],
|
|
13842
|
+
binding: scan
|
|
13843
|
+
},
|
|
13844
|
+
{
|
|
13845
|
+
id: "create",
|
|
13846
|
+
label: "Create stack",
|
|
13847
|
+
placement: "toolbar",
|
|
13848
|
+
requiredPorts: ["commands"],
|
|
13849
|
+
requiredContext: ["root"],
|
|
13850
|
+
binding: create
|
|
13851
|
+
},
|
|
13852
|
+
{
|
|
13853
|
+
id: "import",
|
|
13854
|
+
label: "Import existing resources",
|
|
13855
|
+
placement: "toolbar",
|
|
13856
|
+
requiredPorts: ["commands"],
|
|
13857
|
+
// `stack import` writes the directory it runs in, the same way
|
|
13858
|
+
// Convert does.
|
|
13859
|
+
requiredContext: ["root", "stack"],
|
|
13860
|
+
binding: importStack
|
|
13861
|
+
},
|
|
13862
|
+
{
|
|
13863
|
+
id: "import-partial",
|
|
13864
|
+
label: "Import the rest",
|
|
13865
|
+
placement: { row: "failure" },
|
|
13866
|
+
requiredPorts: ["commands"],
|
|
13867
|
+
requiredContext: ["root", "stack"],
|
|
13868
|
+
answers: ["import_residual"],
|
|
13869
|
+
binding: importPartial
|
|
13870
|
+
},
|
|
13871
|
+
{
|
|
13872
|
+
id: "preview",
|
|
13873
|
+
label: "Preview",
|
|
13874
|
+
placement: "toolbar",
|
|
13875
|
+
requiredPorts: ["commands"],
|
|
13876
|
+
// `stack preview` plans the tf of the directory it runs in — a stack
|
|
13877
|
+
// alone isn't enough, the mount needs the root too.
|
|
13878
|
+
requiredContext: ["root", "stack"],
|
|
13879
|
+
binding: preview
|
|
13880
|
+
},
|
|
13881
|
+
{
|
|
13882
|
+
id: "run-cancel",
|
|
13883
|
+
label: "Cancel",
|
|
13884
|
+
placement: { row: "runs" },
|
|
13885
|
+
requiredPorts: ["commands"],
|
|
13886
|
+
requiredTarget: ["runId"],
|
|
13887
|
+
binding: runCancel
|
|
13888
|
+
},
|
|
13889
|
+
{
|
|
13890
|
+
id: "follow-logs",
|
|
13891
|
+
label: "Follow logs",
|
|
13892
|
+
placement: { row: "runs" },
|
|
13893
|
+
requiredPorts: ["commands"],
|
|
13894
|
+
requiredTarget: ["runId"],
|
|
13895
|
+
binding: followLogs
|
|
13896
|
+
}
|
|
13897
|
+
];
|
|
13898
|
+
var CORE_COMMAND_ACTIONS = [
|
|
13899
|
+
...STACK_COMMAND_ACTIONS,
|
|
13900
|
+
...MODULE_COMMAND_ACTIONS
|
|
13901
|
+
];
|
|
13751
13902
|
|
|
13752
13903
|
// src/registry.ts
|
|
13753
13904
|
var CONTEXT_NEEDS = {
|
|
@@ -13778,7 +13929,16 @@ var TARGET_NEEDS = {
|
|
|
13778
13929
|
runId: "a run",
|
|
13779
13930
|
failure: "a failed command"
|
|
13780
13931
|
};
|
|
13781
|
-
|
|
13932
|
+
function busyReason(busy) {
|
|
13933
|
+
return busy.kind === "run" ? "A run is in progress" : `${busy.running.label} is running`;
|
|
13934
|
+
}
|
|
13935
|
+
function runsOn(action, ctx, target) {
|
|
13936
|
+
if (action.requiredTarget?.includes("runId")) return `run:${target.runId}`;
|
|
13937
|
+
const required = action.requiredContext ?? [];
|
|
13938
|
+
if (required.includes("stack")) return `stack:${ctx.stack?.id}`;
|
|
13939
|
+
if (required.includes("root")) return `root:${ctx.root}`;
|
|
13940
|
+
return "";
|
|
13941
|
+
}
|
|
13782
13942
|
function keySatisfied(ctx, key) {
|
|
13783
13943
|
if (key === "editable") return ctx.editable === true;
|
|
13784
13944
|
if (key === "saved") return ctx.view?.unsaved === false;
|
|
@@ -13800,8 +13960,8 @@ function keySatisfied(ctx, key) {
|
|
|
13800
13960
|
if (key === "redoable") return ctx.view?.can_redo === true;
|
|
13801
13961
|
return ctx[key] !== void 0;
|
|
13802
13962
|
}
|
|
13803
|
-
function disabledReason(action, ctx,
|
|
13804
|
-
if (
|
|
13963
|
+
function disabledReason(action, ctx, busy) {
|
|
13964
|
+
if (busy) return busyReason(busy);
|
|
13805
13965
|
for (const { key, reason } of action.enabledWhen ?? []) {
|
|
13806
13966
|
if (!keySatisfied(ctx, key)) return reason;
|
|
13807
13967
|
}
|
|
@@ -13876,7 +14036,19 @@ function createActionRunner(ports, store, options = {}) {
|
|
|
13876
14036
|
const handles = /* @__PURE__ */ new Map();
|
|
13877
14037
|
const tokens = /* @__PURE__ */ new Map();
|
|
13878
14038
|
const clipboard = createClipboardStore();
|
|
13879
|
-
const notifyControllers = /* @__PURE__ */ new
|
|
14039
|
+
const notifyControllers = /* @__PURE__ */ new Map();
|
|
14040
|
+
let edits = 0;
|
|
14041
|
+
const editingListeners = /* @__PURE__ */ new Set();
|
|
14042
|
+
async function asEdit(edit) {
|
|
14043
|
+
edits += 1;
|
|
14044
|
+
if (edits === 1) for (const listener of editingListeners) listener(true);
|
|
14045
|
+
try {
|
|
14046
|
+
return await edit();
|
|
14047
|
+
} finally {
|
|
14048
|
+
edits -= 1;
|
|
14049
|
+
if (edits === 0) for (const listener of editingListeners) listener(false);
|
|
14050
|
+
}
|
|
14051
|
+
}
|
|
13880
14052
|
async function applyWith(editor, actions) {
|
|
13881
14053
|
let result;
|
|
13882
14054
|
try {
|
|
@@ -13916,13 +14088,14 @@ function createActionRunner(ports, store, options = {}) {
|
|
|
13916
14088
|
async function applyActions(actions) {
|
|
13917
14089
|
const editor = ports.editor;
|
|
13918
14090
|
if (!editor) return;
|
|
13919
|
-
return applyWith(editor, actions);
|
|
14091
|
+
return asEdit(() => applyWith(editor, actions));
|
|
13920
14092
|
}
|
|
13921
14093
|
function askConfirm(spec) {
|
|
13922
14094
|
const confirm = ports.presenter.confirm;
|
|
13923
14095
|
return confirm ? confirm(spec) : Promise.resolve(false);
|
|
13924
14096
|
}
|
|
13925
|
-
function runtimeFor(token, readOver, cwd,
|
|
14097
|
+
function runtimeFor(token, readOver, cwd, command, onSettle) {
|
|
14098
|
+
const run = command?.run;
|
|
13926
14099
|
return {
|
|
13927
14100
|
ports,
|
|
13928
14101
|
token,
|
|
@@ -13933,7 +14106,7 @@ function createActionRunner(ports, store, options = {}) {
|
|
|
13933
14106
|
if (run && line !== void 0) options.onRunLog?.(line, run);
|
|
13934
14107
|
},
|
|
13935
14108
|
begin: () => {
|
|
13936
|
-
if (
|
|
14109
|
+
if (command) store.begin(command.run.resultKind, token, readOver, command.started);
|
|
13937
14110
|
},
|
|
13938
14111
|
fail: (error) => run ? store.fail(run.resultKind, token, error) : false,
|
|
13939
14112
|
detach: (kind, tok) => store.detach(kind, tok),
|
|
@@ -13944,6 +14117,15 @@ function createActionRunner(ports, store, options = {}) {
|
|
|
13944
14117
|
function readOverOf(ctx) {
|
|
13945
14118
|
return { stack: ctx.stack?.id };
|
|
13946
14119
|
}
|
|
14120
|
+
function busyOn(resultKind, action, ctx, target) {
|
|
14121
|
+
const on = runsOn(action, ctx, target);
|
|
14122
|
+
return { on, busy: store.busy(resultKind, on) };
|
|
14123
|
+
}
|
|
14124
|
+
function busyOf(action, ctx, target) {
|
|
14125
|
+
const binding = action.binding;
|
|
14126
|
+
if (binding.kind !== "command") return void 0;
|
|
14127
|
+
return busyOn(binding.resultKind, action, ctx, target).busy;
|
|
14128
|
+
}
|
|
13947
14129
|
function cwdOf(action, ctx) {
|
|
13948
14130
|
return (action.requiredContext ?? []).includes("root") ? ctx.root : void 0;
|
|
13949
14131
|
}
|
|
@@ -13965,19 +14147,24 @@ function createActionRunner(ports, store, options = {}) {
|
|
|
13965
14147
|
if (binding.kind !== "command") return;
|
|
13966
14148
|
const spec = binding.confirmSpec(ctx, target, formArgs);
|
|
13967
14149
|
if (spec && !await askConfirm(spec)) return;
|
|
13968
|
-
|
|
13969
|
-
|
|
14150
|
+
const { on, busy } = busyOn(binding.resultKind, action, ctx, target);
|
|
14151
|
+
if (busy) {
|
|
14152
|
+
ports.presenter.notify("warn", busyReason(busy));
|
|
13970
14153
|
return;
|
|
13971
14154
|
}
|
|
13972
14155
|
const readOver = readOverOf(ctx);
|
|
13973
14156
|
const cwd = cwdOf(action, ctx);
|
|
13974
14157
|
const token = {};
|
|
13975
14158
|
const run = { token, path: binding.path, resultKind: binding.resultKind, ctx, target };
|
|
14159
|
+
const started = { target, on, path: binding.path, label: action.label };
|
|
13976
14160
|
const controller = new AbortController();
|
|
13977
14161
|
if (binding.resultKind === "notify") {
|
|
13978
|
-
notifyControllers.
|
|
14162
|
+
notifyControllers.set(controller, token);
|
|
13979
14163
|
await binding.start(
|
|
13980
|
-
runtimeFor(token, readOver, cwd, run, () =>
|
|
14164
|
+
runtimeFor(token, readOver, cwd, { run, started }, () => {
|
|
14165
|
+
notifyControllers.delete(controller);
|
|
14166
|
+
store.detach("notify", token);
|
|
14167
|
+
}),
|
|
13981
14168
|
ctx,
|
|
13982
14169
|
target,
|
|
13983
14170
|
formArgs,
|
|
@@ -13989,7 +14176,7 @@ function createActionRunner(ports, store, options = {}) {
|
|
|
13989
14176
|
controllers.set(binding.resultKind, controller);
|
|
13990
14177
|
tokens.set(binding.resultKind, token);
|
|
13991
14178
|
const handle = await binding.start(
|
|
13992
|
-
runtimeFor(token, readOver, cwd, run),
|
|
14179
|
+
runtimeFor(token, readOver, cwd, { run, started }),
|
|
13993
14180
|
ctx,
|
|
13994
14181
|
target,
|
|
13995
14182
|
formArgs,
|
|
@@ -14038,7 +14225,7 @@ function createActionRunner(ports, store, options = {}) {
|
|
|
14038
14225
|
...envExtras
|
|
14039
14226
|
};
|
|
14040
14227
|
if (binding.result === "apply") {
|
|
14041
|
-
return binding.run(env);
|
|
14228
|
+
return asEdit(() => binding.run(env));
|
|
14042
14229
|
}
|
|
14043
14230
|
if (binding.result === "generate") {
|
|
14044
14231
|
for await (const event of binding.run(env)) {
|
|
@@ -14066,8 +14253,7 @@ function createActionRunner(ports, store, options = {}) {
|
|
|
14066
14253
|
ports.presenter.notify("warn", unmet);
|
|
14067
14254
|
return;
|
|
14068
14255
|
}
|
|
14069
|
-
const
|
|
14070
|
-
const reason = disabledReason(action, ctx, isBusy);
|
|
14256
|
+
const reason = disabledReason(action, ctx, busyOf(action, ctx, target));
|
|
14071
14257
|
if (reason !== void 0) {
|
|
14072
14258
|
ports.presenter.notify("warn", reason);
|
|
14073
14259
|
return;
|
|
@@ -14094,6 +14280,18 @@ function createActionRunner(ports, store, options = {}) {
|
|
|
14094
14280
|
apply(actions) {
|
|
14095
14281
|
return applyActions(actions);
|
|
14096
14282
|
},
|
|
14283
|
+
editing() {
|
|
14284
|
+
return edits > 0;
|
|
14285
|
+
},
|
|
14286
|
+
onEditingChange(listener) {
|
|
14287
|
+
editingListeners.add(listener);
|
|
14288
|
+
return () => {
|
|
14289
|
+
editingListeners.delete(listener);
|
|
14290
|
+
};
|
|
14291
|
+
},
|
|
14292
|
+
busy(action, ctx, target) {
|
|
14293
|
+
return busyOf(action, ctx, target);
|
|
14294
|
+
},
|
|
14097
14295
|
async cancel(kind) {
|
|
14098
14296
|
const handle = handles.get(kind);
|
|
14099
14297
|
if (!handle) return;
|
|
@@ -14105,7 +14303,10 @@ function createActionRunner(ports, store, options = {}) {
|
|
|
14105
14303
|
},
|
|
14106
14304
|
dispose() {
|
|
14107
14305
|
for (const kind of [...controllers.keys()]) detachSlot(kind);
|
|
14108
|
-
for (const controller of notifyControllers)
|
|
14306
|
+
for (const [controller, token] of notifyControllers) {
|
|
14307
|
+
controller.abort();
|
|
14308
|
+
store.detach("notify", token);
|
|
14309
|
+
}
|
|
14109
14310
|
notifyControllers.clear();
|
|
14110
14311
|
}
|
|
14111
14312
|
};
|
|
@@ -14222,6 +14423,7 @@ function autosave(source, save, policy, report) {
|
|
|
14222
14423
|
defineCommand,
|
|
14223
14424
|
diagnosticsOf,
|
|
14224
14425
|
diagnosticsOfDocument,
|
|
14426
|
+
failureSays,
|
|
14225
14427
|
foldReport,
|
|
14226
14428
|
isBoundPath,
|
|
14227
14429
|
liveSlots,
|