@lace-cloud/chat-core 0.35.0 → 0.37.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/dist/index.cjs CHANGED
@@ -49,7 +49,7 @@ function createToolRegistry() {
49
49
  }
50
50
 
51
51
  // src/surfaces/canvas/canvas-tools.ts
52
- var import_engine4 = require("@lace-cloud/canvas/engine");
52
+ var import_engine5 = require("@lace-cloud/canvas/engine");
53
53
 
54
54
  // src/contract/cancel.ts
55
55
  var Cancelled = class extends Error {
@@ -77,12 +77,13 @@ function cancellable(start, signal) {
77
77
  }
78
78
 
79
79
  // src/surfaces/canvas/change.ts
80
- var import_engine3 = require("@lace-cloud/canvas/engine");
80
+ var import_engine4 = require("@lace-cloud/canvas/engine");
81
81
 
82
82
  // src/surfaces/canvas/commands.ts
83
- var import_engine2 = require("@lace-cloud/canvas/engine");
83
+ var import_engine3 = require("@lace-cloud/canvas/engine");
84
84
 
85
85
  // src/surfaces/canvas/enumerate.ts
86
+ var import_engine = require("@lace-cloud/canvas/engine");
86
87
  var import_proto = require("@lace-cloud/proto");
87
88
  function readCanvas(source) {
88
89
  const { bundle } = source;
@@ -138,6 +139,9 @@ function pinRef(instance, pin) {
138
139
  function connectionId(from, to) {
139
140
  return `${from} \u2192 ${to}`;
140
141
  }
142
+ function wireText(wire) {
143
+ return connectionId((0, import_engine.wireEndText)(wire, "source", pinRef), (0, import_engine.wireEndText)(wire, "target", pinRef));
144
+ }
141
145
  function pairListing(source, target, scored, pin) {
142
146
  return scored.filter((pair) => pair.sourceInstance === source.name && pair.targetInstance === target.name).filter((pair) => pin.output === void 0 || pair.output === pin.output).filter((pair) => pin.input === void 0 || pair.input === pin.input).map(
143
147
  (pair) => `${connectionId(pinRef(source.id, pair.output), pinRef(target.id, pair.input))} (score ${pair.score})`
@@ -145,17 +149,17 @@ function pairListing(source, target, scored, pin) {
145
149
  }
146
150
 
147
151
  // src/surfaces/canvas/registration.ts
148
- var import_engine = require("@lace-cloud/canvas/engine");
152
+ var import_engine2 = require("@lace-cloud/canvas/engine");
149
153
  var InvalidInput = class extends Error {
150
154
  };
151
155
  function reasonText(reason) {
152
- return `reason ${(0, import_engine.reasonWire)(reason)}`;
156
+ return `reason ${(0, import_engine2.reasonWire)(reason)}`;
153
157
  }
154
158
  function refusalReason(error) {
155
- return error.apiCode ?? (0, import_engine.reasonWire)(error.reason);
159
+ return error.apiCode ?? (0, import_engine2.reasonWire)(error.reason);
156
160
  }
157
161
  function errorText(error) {
158
- if (error instanceof import_engine.ConnectError) return `${error.message} (reason ${refusalReason(error)})`;
162
+ if (error instanceof import_engine2.ConnectError) return `${error.message} (reason ${refusalReason(error)})`;
159
163
  return error instanceof Error ? error.message : String(error);
160
164
  }
161
165
  function registration(schema, run) {
@@ -175,13 +179,13 @@ var NO_INPUT = { type: "object", properties: {}, additionalProperties: false };
175
179
 
176
180
  // src/surfaces/canvas/commands.ts
177
181
  function commandEnd(path, error) {
178
- const { message, failure } = (0, import_engine2.failureSays)(error);
182
+ const { message, failure } = (0, import_engine3.failureSays)(error);
179
183
  const failed = (why, see = "") => `lace ${path} failed (reason ${why}): ${message}${see}`;
180
184
  if (failure !== void 0) {
181
185
  const see = failure.url === void 0 ? "" : `; see ${failure.url}`;
182
186
  return { text: failed(failure.apiCode ?? failure.reason, see), failure };
183
187
  }
184
- if (error instanceof import_engine2.ConnectError) return { text: failed(refusalReason(error)) };
188
+ if (error instanceof import_engine3.ConnectError) return { text: failed(refusalReason(error)) };
185
189
  return { text: `lace ${path} did not finish cleanly (${message})` };
186
190
  }
187
191
  async function runCommand(commands, path, args, signal = new AbortController().signal) {
@@ -205,6 +209,7 @@ function trimValidate(report) {
205
209
  return {
206
210
  verdict: report.verdict,
207
211
  exitClass: report.exitClass,
212
+ failure: report.failure,
208
213
  diagnostics: report.diagnostics,
209
214
  residuals: report.residuals?.map(({ construct, subject, file, line, guidance }) => ({
210
215
  construct,
@@ -226,7 +231,8 @@ function trimRegistryList(list) {
226
231
  system: row.system,
227
232
  categories: row.categories
228
233
  })),
229
- truncated: list.truncated
234
+ truncated: list.truncated,
235
+ ...list.scopeNotice && { scopeNotice: list.scopeNotice }
230
236
  };
231
237
  }
232
238
  function trimRegistryDescribe(described) {
@@ -496,12 +502,7 @@ var place = {
496
502
  }
497
503
  };
498
504
  function autoConnect(canvas, source, target, ends, note) {
499
- const between = (reading) => reading.wires.filter((wire) => wire.source === source.id && wire.target === target.id).map(
500
- (wire) => connectionId(
501
- pinRef(wire.source, wire.source_output),
502
- pinRef(wire.target, wire.target_input)
503
- )
504
- );
505
+ const between = (reading) => reading.wires.filter((wire) => wire.source === source.id && wire.target === target.id).map(wireText);
505
506
  const before = new Set(between(canvas));
506
507
  return {
507
508
  action: { auto_connect: ends },
@@ -607,7 +608,7 @@ var set = {
607
608
  const { instance, input } = pickInput(resolving, EVERY_MODE, (of) => `input of ${of.id}`);
608
609
  const shown = input.sensitive ? "(sensitive, value withheld)" : `= ${JSON.stringify(value)}`;
609
610
  return {
610
- action: updateInput(instance, input, { mode: import_engine3.InputMode.INPUT_MODE_LITERAL, value }),
611
+ action: updateInput(instance, input, { mode: import_engine4.InputMode.INPUT_MODE_LITERAL, value }),
611
612
  summary: () => `set ${pinRef(instance.id, input.name)} ${shown}`
612
613
  };
613
614
  }
@@ -621,7 +622,7 @@ var bind = {
621
622
  const variable = variableName(givenName(resolving.change, "the variable's name"));
622
623
  const { instance, input } = pickInput(resolving, EVERY_MODE, (of) => `input of ${of.id}`);
623
624
  return {
624
- action: updateInput(instance, input, { mode: import_engine3.InputMode.INPUT_MODE_VARIABLE, variable }),
625
+ action: updateInput(instance, input, { mode: import_engine4.InputMode.INPUT_MODE_VARIABLE, variable }),
625
626
  summary: () => `bound ${pinRef(instance.id, input.name)} to var.${variable}`
626
627
  };
627
628
  }
@@ -638,7 +639,7 @@ var clear = {
638
639
  (of) => `input of ${of.id} that holds a value`
639
640
  );
640
641
  return {
641
- action: updateInput(instance, input, { mode: import_engine3.InputMode.INPUT_MODE_EMPTY }),
642
+ action: updateInput(instance, input, { mode: import_engine4.InputMode.INPUT_MODE_EMPTY }),
642
643
  summary: () => `cleared ${pinRef(instance.id, input.name)}`
643
644
  };
644
645
  }
@@ -772,7 +773,7 @@ async function runChange(ports, change, signal, note) {
772
773
  try {
773
774
  return await resolveAndApply(ports, change, signal, note);
774
775
  } catch (error) {
775
- if (error instanceof import_engine3.ApplyUnobservedError) {
776
+ if (error instanceof import_engine4.ApplyUnobservedError) {
776
777
  return { kind: "unobserved", end: withhold(endText(error.end), change.value) };
777
778
  }
778
779
  if (error instanceof Cancelled) return CANCELLED;
@@ -811,7 +812,6 @@ async function applyChanges(ports, changes, signal) {
811
812
  }
812
813
 
813
814
  // src/surfaces/canvas/render.ts
814
- var import_proto2 = require("@lace-cloud/proto");
815
815
  function inputText(input) {
816
816
  if (input.mode === "empty") {
817
817
  return `${input.name} (${input.required ? "required, " : ""}not set)`;
@@ -859,12 +859,7 @@ function renderCanvas(source) {
859
859
  ...canvas.instances.flatMap(instanceLines),
860
860
  ...section(
861
861
  "Wires",
862
- canvas.wires.map(
863
- (wire) => `- ${connectionId(
864
- wire.source_output ? pinRef(wire.source, wire.source_output) : (0, import_proto2.callText)(wire.source),
865
- pinRef(wire.target, wire.target_input)
866
- )}`
867
- )
862
+ canvas.wires.map((wire) => `- ${wireText(wire)}`)
868
863
  ),
869
864
  ...section("Required inputs not set", canvas.instances.flatMap(unsetRequired)),
870
865
  ...section(
@@ -955,7 +950,7 @@ var SAVE = {
955
950
  var GENERATE = {
956
951
  name: "lace_generate_module_terraform",
957
952
  title: "Generate module Terraform",
958
- description: "Writes the Terraform for a Lace module canvas: the saved canvas rendered to the module's .tf files. Returns the files it changed and removed, or why Lace did not generate. Call it only when the developer asks to generate.",
953
+ description: "Writes the Terraform for a Lace module canvas: the saved canvas rendered to the module's .tf files. Returns the files it changed and removed, or why Lace did not generate; a generate can succeed with a validate that did not pass, and then says why. Call it only when the developer asks to generate.",
959
954
  inputSchema: NO_INPUT
960
955
  };
961
956
  var canvasToolSchemas = [
@@ -965,7 +960,7 @@ var canvasToolSchemas = [
965
960
  GENERATE
966
961
  ];
967
962
  function writtenText(success) {
968
- const { changed, removed, unchanged } = (0, import_engine4.generatedTree)(success);
963
+ const { changed, removed, unchanged } = (0, import_engine5.generatedTree)(success);
969
964
  const said2 = [
970
965
  changed.length > 0 ? `Changed ${changed.join(", ")}` : "Changed no file",
971
966
  ...removed.length > 0 ? [`removed ${removed.join(", ")}`] : [],
@@ -997,7 +992,7 @@ function generateSaid(event) {
997
992
  }
998
993
  }
999
994
  function unobserved(error) {
1000
- if (!(error instanceof import_engine4.ApplyUnobservedError)) throw error;
995
+ if (!(error instanceof import_engine5.ApplyUnobservedError)) throw error;
1001
996
  return {
1002
997
  text: `The session's stream ended (${endText(error.end)}) before the canvas showed this, so the canvas below is from before it.`,
1003
998
  isError: false