@lace-cloud/chat-core 0.36.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) {
@@ -498,12 +502,7 @@ var place = {
498
502
  }
499
503
  };
500
504
  function autoConnect(canvas, source, target, ends, note) {
501
- const between = (reading) => reading.wires.filter((wire) => wire.source === source.id && wire.target === target.id).map(
502
- (wire) => connectionId(
503
- pinRef(wire.source, wire.source_output),
504
- pinRef(wire.target, wire.target_input)
505
- )
506
- );
505
+ const between = (reading) => reading.wires.filter((wire) => wire.source === source.id && wire.target === target.id).map(wireText);
507
506
  const before = new Set(between(canvas));
508
507
  return {
509
508
  action: { auto_connect: ends },
@@ -609,7 +608,7 @@ var set = {
609
608
  const { instance, input } = pickInput(resolving, EVERY_MODE, (of) => `input of ${of.id}`);
610
609
  const shown = input.sensitive ? "(sensitive, value withheld)" : `= ${JSON.stringify(value)}`;
611
610
  return {
612
- 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 }),
613
612
  summary: () => `set ${pinRef(instance.id, input.name)} ${shown}`
614
613
  };
615
614
  }
@@ -623,7 +622,7 @@ var bind = {
623
622
  const variable = variableName(givenName(resolving.change, "the variable's name"));
624
623
  const { instance, input } = pickInput(resolving, EVERY_MODE, (of) => `input of ${of.id}`);
625
624
  return {
626
- 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 }),
627
626
  summary: () => `bound ${pinRef(instance.id, input.name)} to var.${variable}`
628
627
  };
629
628
  }
@@ -640,7 +639,7 @@ var clear = {
640
639
  (of) => `input of ${of.id} that holds a value`
641
640
  );
642
641
  return {
643
- action: updateInput(instance, input, { mode: import_engine3.InputMode.INPUT_MODE_EMPTY }),
642
+ action: updateInput(instance, input, { mode: import_engine4.InputMode.INPUT_MODE_EMPTY }),
644
643
  summary: () => `cleared ${pinRef(instance.id, input.name)}`
645
644
  };
646
645
  }
@@ -774,7 +773,7 @@ async function runChange(ports, change, signal, note) {
774
773
  try {
775
774
  return await resolveAndApply(ports, change, signal, note);
776
775
  } catch (error) {
777
- if (error instanceof import_engine3.ApplyUnobservedError) {
776
+ if (error instanceof import_engine4.ApplyUnobservedError) {
778
777
  return { kind: "unobserved", end: withhold(endText(error.end), change.value) };
779
778
  }
780
779
  if (error instanceof Cancelled) return CANCELLED;
@@ -813,7 +812,6 @@ async function applyChanges(ports, changes, signal) {
813
812
  }
814
813
 
815
814
  // src/surfaces/canvas/render.ts
816
- var import_proto2 = require("@lace-cloud/proto");
817
815
  function inputText(input) {
818
816
  if (input.mode === "empty") {
819
817
  return `${input.name} (${input.required ? "required, " : ""}not set)`;
@@ -861,12 +859,7 @@ function renderCanvas(source) {
861
859
  ...canvas.instances.flatMap(instanceLines),
862
860
  ...section(
863
861
  "Wires",
864
- canvas.wires.map(
865
- (wire) => `- ${connectionId(
866
- wire.source_output ? pinRef(wire.source, wire.source_output) : (0, import_proto2.callText)(wire.source),
867
- pinRef(wire.target, wire.target_input)
868
- )}`
869
- )
862
+ canvas.wires.map((wire) => `- ${wireText(wire)}`)
870
863
  ),
871
864
  ...section("Required inputs not set", canvas.instances.flatMap(unsetRequired)),
872
865
  ...section(
@@ -967,7 +960,7 @@ var canvasToolSchemas = [
967
960
  GENERATE
968
961
  ];
969
962
  function writtenText(success) {
970
- const { changed, removed, unchanged } = (0, import_engine4.generatedTree)(success);
963
+ const { changed, removed, unchanged } = (0, import_engine5.generatedTree)(success);
971
964
  const said2 = [
972
965
  changed.length > 0 ? `Changed ${changed.join(", ")}` : "Changed no file",
973
966
  ...removed.length > 0 ? [`removed ${removed.join(", ")}`] : [],
@@ -999,7 +992,7 @@ function generateSaid(event) {
999
992
  }
1000
993
  }
1001
994
  function unobserved(error) {
1002
- if (!(error instanceof import_engine4.ApplyUnobservedError)) throw error;
995
+ if (!(error instanceof import_engine5.ApplyUnobservedError)) throw error;
1003
996
  return {
1004
997
  text: `The session's stream ended (${endText(error.end)}) before the canvas showed this, so the canvas below is from before it.`,
1005
998
  isError: false