@segmentstream/ontology 0.105.0 → 0.106.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,20 +34,83 @@ const RECORD_OPERATIONS = new Set([
34
34
  const REQUEST_METHODS = new Set(["get", "post", "put", "patch", "delete", "head", "request"]);
35
35
  const COMBINATORS = new Set(["all", "allSettled", "any", "race"]);
36
36
  const EACH_METHODS = new Set(["map", "forEach", "flatMap"]);
37
+ const PROMISE_METHODS = new Set(["then", "catch", "finally"]);
38
+ /**
39
+ * Methods of built-in values that return a value, never a promise: a call to one that the code
40
+ * returns, as in `return lines.join("\n")`, is a value, not work the map would follow.
41
+ */
42
+ const VALUE_METHODS = new Set([
43
+ "at",
44
+ "concat",
45
+ "endsWith",
46
+ "entries",
47
+ "every",
48
+ "filter",
49
+ "find",
50
+ "findIndex",
51
+ "flat",
52
+ "includes",
53
+ "indexOf",
54
+ "join",
55
+ "keys",
56
+ "localeCompare",
57
+ "map",
58
+ "padEnd",
59
+ "padStart",
60
+ "reduce",
61
+ "replace",
62
+ "replaceAll",
63
+ "reverse",
64
+ "slice",
65
+ "some",
66
+ "sort",
67
+ "split",
68
+ "startsWith",
69
+ "toFixed",
70
+ "toISOString",
71
+ "toLowerCase",
72
+ "toString",
73
+ "toUpperCase",
74
+ "trim",
75
+ "trimEnd",
76
+ "trimStart",
77
+ "values",
78
+ ]);
79
+ /** Built-in namespaces whose functions return values, as in `return JSON.stringify(report)`. */
80
+ const VALUE_GLOBALS = new Set([
81
+ "Array",
82
+ "Boolean",
83
+ "Date",
84
+ "Intl",
85
+ "JSON",
86
+ "Math",
87
+ "Number",
88
+ "Object",
89
+ "String",
90
+ ]);
91
+ /** The kinds of node that run something, rather than hold other nodes. */
92
+ const RUNS = new Set([
93
+ "step",
94
+ "wait",
95
+ "agent",
96
+ "unknown",
97
+ "exit",
98
+ ]);
37
99
  /** Files the reading follows imports into: the project's own, not its packages. */
38
100
  const EXTENSIONS = [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".jsx"];
39
101
  const MAX_TEXT = 120;
40
102
  const MAX_DESCRIPTION = 600;
41
103
  const MAX_CALLS = 24;
42
104
  const MAX_DEPTH = 24;
43
- /** Collects one block's nodes, numbering them under the block's path. */
44
105
  class Emitter {
45
106
  prefix;
107
+ counter;
46
108
  nodes = [];
47
109
  #next = 0;
48
110
  #note;
49
- constructor(prefix) {
111
+ constructor(prefix, counter) {
50
112
  this.prefix = prefix;
113
+ this.counter = counter;
51
114
  }
52
115
  id() {
53
116
  return `${this.prefix}${this.#next++}`;
@@ -60,8 +123,14 @@ class Emitter {
60
123
  const note = this.#note;
61
124
  this.#note = undefined;
62
125
  this.nodes.push(note === undefined || node.note !== undefined ? node : { ...node, note });
126
+ if (RUNS.has(node.kind)) {
127
+ this.counter.count++;
128
+ }
63
129
  }
64
130
  }
131
+ function isAsync(ts, node) {
132
+ return (ts.getModifiers(node) ?? []).some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword);
133
+ }
65
134
  function collapse(text, max = MAX_TEXT) {
66
135
  const single = text.replace(/\s+/g, " ").trim();
67
136
  return single.length > max ? `${single.slice(0, max - 1)}…` : single;
@@ -418,10 +487,54 @@ class BodyReader {
418
487
  /** Hooks and webhooks the body created by name, which it waits for where it awaits them. */
419
488
  #handles = new Map();
420
489
  #awaited = new Set();
490
+ #counter = { count: 0 };
491
+ /** The helpers, callbacks, loops and `switch` clauses being read, innermost last. */
492
+ #frames = [];
421
493
  constructor(ts, reading) {
422
494
  this.#ts = ts;
423
495
  this.#reading = reading;
424
496
  }
497
+ /**
498
+ * Reads one helper, callback, loop or `switch` clause. An early exit skips what follows it there,
499
+ * which the map cannot draw, so the reading is incomplete when something that runs follows one.
500
+ */
501
+ #frame(kind, read) {
502
+ const frame = { kind };
503
+ this.#frames.push(frame);
504
+ try {
505
+ return read(frame);
506
+ }
507
+ finally {
508
+ this.#frames.pop();
509
+ const count = this.#counter.count;
510
+ if ((frame.exit !== undefined && count > frame.exit) ||
511
+ (frame.next !== undefined && (frame.body ?? count) > frame.next)) {
512
+ this.#reading.complete = false;
513
+ }
514
+ }
515
+ }
516
+ /**
517
+ * An early exit to the nearest frame of these kinds, a `continue` when `next`; none leaves the
518
+ * function it is in.
519
+ */
520
+ #exit(kinds, next = false) {
521
+ for (let index = this.#frames.length - 1; index >= 0; index--) {
522
+ const frame = this.#frames[index];
523
+ if (kinds.includes(frame.kind)) {
524
+ if (next) {
525
+ frame.next ??= this.#counter.count;
526
+ }
527
+ else {
528
+ frame.exit ??= this.#counter.count;
529
+ }
530
+ return;
531
+ }
532
+ if (frame.kind === "function") {
533
+ break;
534
+ }
535
+ }
536
+ this.#reading.complete = false;
537
+ }
425
538
  #text(context, node) {
426
539
  return collapse(node.getText(context.module.source));
427
540
  }
@@ -457,7 +570,7 @@ class BodyReader {
457
570
  }
458
571
  /** A block of statements; `tail` when nothing of the workflow runs after it. */
459
572
  block(context, statements, prefix, tail) {
460
- const out = new Emitter(prefix);
573
+ const out = new Emitter(prefix, this.#counter);
461
574
  this.statements(context, statements, out, tail);
462
575
  return out.nodes;
463
576
  }
@@ -499,15 +612,15 @@ class BodyReader {
499
612
  else if (ts.isReturnStatement(statement)) {
500
613
  // An async function's returned promise is awaited by its caller, as `return await` is.
501
614
  if (statement.expression !== undefined) {
502
- this.expression(context, statement.expression, out, true);
615
+ this.expression(context, statement.expression, out, "returned");
503
616
  }
504
617
  if (context.workflow && !tail) {
505
618
  out.push({ id: out.id(), kind: "exit", exit: "return" });
506
619
  }
507
620
  else if (!tail) {
508
621
  // An early return of a helper or callback skips what follows it there, which the
509
- // workflow's map cannot show as its own exit: the reading says it is not complete.
510
- this.#reading.complete = false;
622
+ // workflow's map cannot show as its own exit.
623
+ this.#exit(["function"]);
511
624
  }
512
625
  }
513
626
  else if (ts.isThrowStatement(statement)) {
@@ -565,9 +678,10 @@ class BodyReader {
565
678
  // Statements that fall through into the next clause: a path the map cannot draw.
566
679
  this.#reading.complete = false;
567
680
  }
681
+ const prefix = `${id}.${paths.length}.`;
568
682
  paths.push({
569
683
  when: labels.join(", "),
570
- body: this.block(context, statements, `${id}.${paths.length}.`, tail),
684
+ body: this.#frame("switch", () => this.block(context, statements, prefix, tail)),
571
685
  });
572
686
  labels = [];
573
687
  });
@@ -586,7 +700,7 @@ class BodyReader {
586
700
  else if (ts.isForOfStatement(statement) || ts.isForInStatement(statement)) {
587
701
  this.expression(context, statement.expression, out);
588
702
  const id = out.id();
589
- const inner = new Emitter(`${id}.`);
703
+ const inner = new Emitter(`${id}.`, this.#counter);
590
704
  // `for await (const delivery of webhook)`: each pass waits for the next call.
591
705
  const handle = ts.isForOfStatement(statement) &&
592
706
  statement.awaitModifier !== undefined &&
@@ -596,7 +710,7 @@ class BodyReader {
596
710
  if (handle !== undefined) {
597
711
  inner.push({ id: inner.id(), kind: "wait", wait: handle });
598
712
  }
599
- this.statement(context, statement.statement, inner, false);
713
+ this.#frame("loop", () => this.statement(context, statement.statement, inner, false));
600
714
  const body = inner.nodes;
601
715
  const word = ts.isForOfStatement(statement) ? "of" : "in";
602
716
  const declared = ts.isVariableDeclarationList(statement.initializer)
@@ -627,14 +741,17 @@ class BodyReader {
627
741
  }
628
742
  }
629
743
  const id = out.id();
630
- const inner = new Emitter(`${id}.`);
744
+ const inner = new Emitter(`${id}.`, this.#counter);
631
745
  if (statement.condition !== undefined) {
632
746
  this.expression(context, statement.condition, inner);
633
747
  }
634
- this.statement(context, statement.statement, inner, false);
635
- if (statement.incrementor !== undefined) {
636
- this.expression(context, statement.incrementor, inner);
637
- }
748
+ this.#frame("loop", (frame) => {
749
+ this.statement(context, statement.statement, inner, false);
750
+ frame.body = this.#counter.count;
751
+ if (statement.incrementor !== undefined) {
752
+ this.expression(context, statement.incrementor, inner);
753
+ }
754
+ });
638
755
  if (inner.nodes.length > 0) {
639
756
  out.push({
640
757
  id,
@@ -647,14 +764,17 @@ class BodyReader {
647
764
  }
648
765
  else if (ts.isWhileStatement(statement) || ts.isDoStatement(statement)) {
649
766
  const id = out.id();
650
- const inner = new Emitter(`${id}.`);
767
+ const inner = new Emitter(`${id}.`, this.#counter);
651
768
  if (ts.isWhileStatement(statement)) {
652
769
  this.expression(context, statement.expression, inner);
653
770
  }
654
- this.statement(context, statement.statement, inner, false);
655
- if (ts.isDoStatement(statement)) {
656
- this.expression(context, statement.expression, inner);
657
- }
771
+ this.#frame("loop", (frame) => {
772
+ this.statement(context, statement.statement, inner, false);
773
+ frame.body = this.#counter.count;
774
+ if (ts.isDoStatement(statement)) {
775
+ this.expression(context, statement.expression, inner);
776
+ }
777
+ });
658
778
  if (inner.nodes.length > 0) {
659
779
  out.push({
660
780
  id,
@@ -685,9 +805,19 @@ class BodyReader {
685
805
  }
686
806
  }
687
807
  else if (ts.isBreakStatement(statement) || ts.isContinueStatement(statement)) {
688
- // A `break` or `continue` skips what follows it in the loop, which the map cannot draw;
689
- // a `break` that ends a `switch` clause is read with its clause.
690
- this.#reading.complete = false;
808
+ // A `break` or `continue` skips what follows it in its loop or `switch` clause; a `break`
809
+ // that ends a clause is read with its clause, and a label may name an outer statement.
810
+ if (statement.label !== undefined) {
811
+ this.#reading.complete = false;
812
+ }
813
+ else {
814
+ if (ts.isBreakStatement(statement)) {
815
+ this.#exit(["loop", "switch"]);
816
+ }
817
+ else {
818
+ this.#exit(["loop"], true);
819
+ }
820
+ }
691
821
  }
692
822
  // Declarations of functions, classes and types and empty statements run nothing of their own.
693
823
  }
@@ -709,22 +839,28 @@ class BodyReader {
709
839
  return handle;
710
840
  }
711
841
  #nested(context, statement, prefix, tail) {
712
- const out = new Emitter(prefix);
842
+ const out = new Emitter(prefix, this.#counter);
713
843
  this.statement(context, statement, out, tail);
714
844
  return out.nodes;
715
845
  }
716
- /** A function given as a value: its body's nodes, read where the code runs it. */
717
- #callback(context, node, prefix) {
846
+ /**
847
+ * A function given as a value: its body's nodes, read where the code runs it. `returned` when
848
+ * what it returns is awaited, as a promise handler's or a `Promise.all` element's is.
849
+ */
850
+ #callback(context, node, prefix, returned = false) {
718
851
  const ts = this.#ts;
719
- const out = new Emitter(prefix);
852
+ const out = new Emitter(prefix, this.#counter);
720
853
  if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
721
- if (ts.isBlock(node.body)) {
722
- const inner = { ...context, scope: this.#scope(context, node.body), workflow: false };
723
- this.statements(inner, node.body.statements, out, true);
724
- }
725
- else {
726
- this.expression({ ...context, workflow: false }, node.body, out);
727
- }
854
+ const body = node.body;
855
+ this.#frame("function", () => {
856
+ if (ts.isBlock(body)) {
857
+ const inner = { ...context, scope: this.#scope(context, body), workflow: false };
858
+ this.statements(inner, body.statements, out, true);
859
+ }
860
+ else {
861
+ this.expression({ ...context, workflow: false }, body, out, returned && "returned");
862
+ }
863
+ });
728
864
  return out.nodes;
729
865
  }
730
866
  if (ts.isIdentifier(node)) {
@@ -734,7 +870,7 @@ class BodyReader {
734
870
  }
735
871
  else if (resolved.kind === "helper") {
736
872
  // A helper of the project given by name, as in `items.forEach(remindOne)`.
737
- this.#helper(resolved.declared, out, false);
873
+ this.#helper(resolved.declared, out, returned);
738
874
  }
739
875
  else if (context.module.imports.has(node.text)) {
740
876
  // A function of another package, as in `items.map(execute)`: what it runs is unread.
@@ -754,7 +890,7 @@ class BodyReader {
754
890
  if (owner === undefined || body === undefined || !this.#reading.enterHelper(declared)) {
755
891
  return;
756
892
  }
757
- const nested = new Emitter(`${out.id()}.`);
893
+ const nested = new Emitter(`${out.id()}.`, this.#counter);
758
894
  try {
759
895
  const inner = {
760
896
  module: owner,
@@ -763,12 +899,15 @@ class BodyReader {
763
899
  : new Map(),
764
900
  workflow: false,
765
901
  };
766
- if (ts.isBlock(body)) {
767
- this.statements(inner, body.statements, nested, true);
768
- }
769
- else {
770
- this.expression(inner, body, nested, awaited);
771
- }
902
+ this.#frame("function", () => {
903
+ if (ts.isBlock(body)) {
904
+ this.statements(inner, body.statements, nested, true);
905
+ }
906
+ else {
907
+ // An arrow helper's body is what it returns.
908
+ this.expression(inner, body, nested, awaited === false ? false : "returned");
909
+ }
910
+ });
772
911
  }
773
912
  finally {
774
913
  this.#reading.leaveHelper();
@@ -795,8 +934,8 @@ class BodyReader {
795
934
  else if (ts.isConditionalExpression(expression)) {
796
935
  this.expression(context, expression.condition, out);
797
936
  const id = out.id();
798
- const whenTrue = new Emitter(`${id}.0.`);
799
- const whenFalse = new Emitter(`${id}.1.`);
937
+ const whenTrue = new Emitter(`${id}.0.`, this.#counter);
938
+ const whenFalse = new Emitter(`${id}.1.`, this.#counter);
800
939
  this.expression(context, expression.whenTrue, whenTrue, awaited);
801
940
  this.expression(context, expression.whenFalse, whenFalse, awaited);
802
941
  if (whenTrue.nodes.length > 0 || whenFalse.nodes.length > 0) {
@@ -819,7 +958,7 @@ class BodyReader {
819
958
  ].includes(expression.operatorToken.kind)) {
820
959
  this.expression(context, expression.left, out);
821
960
  const id = out.id();
822
- const right = new Emitter(`${id}.0.`);
961
+ const right = new Emitter(`${id}.0.`, this.#counter);
823
962
  this.expression(context, expression.right, right, awaited);
824
963
  if (right.nodes.length > 0) {
825
964
  const operator = expression.operatorToken.kind;
@@ -894,6 +1033,118 @@ class BodyReader {
894
1033
  }
895
1034
  });
896
1035
  }
1036
+ /**
1037
+ * `promise.then(onFulfilled, onRejected)`, `.catch(onRejected)` and `.finally(onFinally)`: the
1038
+ * promise's own nodes, a `try` whose `catch` or `finally` is the handler, then what runs once it
1039
+ * has succeeded.
1040
+ */
1041
+ #settled(context, call, callee, out) {
1042
+ const ts = this.#ts;
1043
+ const method = callee.name.text;
1044
+ const handler = (index, prefix) => {
1045
+ const argument = call.arguments[index];
1046
+ if (argument === undefined) {
1047
+ return [];
1048
+ }
1049
+ const nodes = this.#callback(context, argument, prefix, true);
1050
+ if (nodes !== undefined) {
1051
+ return nodes;
1052
+ }
1053
+ this.expression(context, argument, out);
1054
+ const target = ts.isPropertyAccessExpression(argument) ? argument.expression : undefined;
1055
+ if (target !== undefined && ts.isIdentifier(target) && target.text === "console") {
1056
+ // `.catch(console.error)`: logging runs nothing the map shows.
1057
+ return [];
1058
+ }
1059
+ // A handler reached through a value, such as `handlers.retry`: what it runs is unread.
1060
+ const unread = new Emitter(prefix, this.#counter);
1061
+ this.#reading.complete = false;
1062
+ unread.push({ id: unread.id(), kind: "unknown", label: this.#text(context, argument) });
1063
+ return unread.nodes;
1064
+ };
1065
+ const then = () => {
1066
+ for (const node of handler(0, `${out.id()}.`)) {
1067
+ out.push(node);
1068
+ }
1069
+ };
1070
+ // `.catch()` or `.then(a, undefined)`: without a handler a failure goes on as it would anyway.
1071
+ const given = (index) => {
1072
+ const argument = call.arguments[index];
1073
+ return (argument !== undefined &&
1074
+ argument.kind !== ts.SyntaxKind.NullKeyword &&
1075
+ !(ts.isIdentifier(argument) && argument.text === "undefined"));
1076
+ };
1077
+ const guarded = method === "then" ? given(1) : given(0);
1078
+ // The handlers wait for the promise, so it is awaited however the chain itself is used.
1079
+ if (!guarded) {
1080
+ this.expression(context, callee.expression, out, true);
1081
+ then();
1082
+ return;
1083
+ }
1084
+ const id = out.id();
1085
+ const body = new Emitter(`${id}.0.`, this.#counter);
1086
+ let receiver = callee.expression;
1087
+ while (ts.isParenthesizedExpression(receiver) || ts.isNonNullExpression(receiver)) {
1088
+ receiver = receiver.expression;
1089
+ }
1090
+ if (ts.isCallExpression(receiver) && this.#plain(receiver)) {
1091
+ // `a(await b()).catch(…)`: the arguments run before the promise exists, so their failure
1092
+ // never reaches its handlers.
1093
+ this.#operands(context, receiver, out);
1094
+ const resolved = this.#reading.resolve(context.module, receiver.expression, context.scope);
1095
+ if (resolved.kind === "helper" && !isAsync(ts, resolved.declared.node)) {
1096
+ // A function that is not `async` may throw before it returns its promise, which the
1097
+ // handlers never see; the map cannot tell that throw from the promise's failure.
1098
+ this.#reading.complete = false;
1099
+ }
1100
+ this.#invoke(context, receiver, body, true);
1101
+ }
1102
+ else {
1103
+ this.expression(context, callee.expression, body, true);
1104
+ }
1105
+ const caught = method === "finally" ? undefined : handler(method === "then" ? 1 : 0, `${id}.1.`);
1106
+ const final = method === "finally" ? handler(0, `${id}.2.`) : undefined;
1107
+ if (method === "then") {
1108
+ // `then(onFulfilled, onRejected)` runs one handler or the other. The map has no place for
1109
+ // what runs only once the promise has succeeded but outside the `try`, so it follows the
1110
+ // promise inside, and the reading is not complete.
1111
+ const fulfilled = handler(0, `${body.id()}.`);
1112
+ for (const node of fulfilled) {
1113
+ body.push(node);
1114
+ }
1115
+ if (fulfilled.length > 0) {
1116
+ this.#reading.complete = false;
1117
+ }
1118
+ }
1119
+ if (body.nodes.length > 0 || (caught?.length ?? 0) > 0 || (final?.length ?? 0) > 0) {
1120
+ out.push({
1121
+ id,
1122
+ kind: "try",
1123
+ body: body.nodes,
1124
+ ...(caught === undefined ? {} : { catch: caught }),
1125
+ ...(final === undefined ? {} : { finally: final }),
1126
+ });
1127
+ }
1128
+ }
1129
+ /** A call read as one call: not `Promise.all(…)`, a promise handler or `items.map(…)`. */
1130
+ #plain(call) {
1131
+ const ts = this.#ts;
1132
+ const callee = call.expression;
1133
+ return (ts.isIdentifier(callee) ||
1134
+ (ts.isPropertyAccessExpression(callee) &&
1135
+ !PROMISE_METHODS.has(callee.name.text) &&
1136
+ !EACH_METHODS.has(callee.name.text) &&
1137
+ !(ts.isIdentifier(callee.expression) &&
1138
+ callee.expression.text === "Promise" &&
1139
+ COMBINATORS.has(callee.name.text))));
1140
+ }
1141
+ /** A call of a built-in that returns a value, never a promise; see {@link VALUE_METHODS}. */
1142
+ #value(callee) {
1143
+ const ts = this.#ts;
1144
+ return (ts.isPropertyAccessExpression(callee) &&
1145
+ (VALUE_METHODS.has(callee.name.text) ||
1146
+ (ts.isIdentifier(callee.expression) && VALUE_GLOBALS.has(callee.expression.text))));
1147
+ }
897
1148
  #call(context, call, out, awaited) {
898
1149
  const ts = this.#ts;
899
1150
  const callee = call.expression;
@@ -907,7 +1158,7 @@ class BodyReader {
907
1158
  const id = out.id();
908
1159
  if (argument !== undefined && ts.isArrayLiteralExpression(argument)) {
909
1160
  const branches = argument.elements.map((element, index) => {
910
- const branch = new Emitter(`${id}.${index}.`);
1161
+ const branch = new Emitter(`${id}.${index}.`, this.#counter);
911
1162
  this.expression(context, ts.isSpreadElement(element) ? element.expression : element, branch, true);
912
1163
  return branch.nodes;
913
1164
  });
@@ -922,7 +1173,7 @@ class BodyReader {
922
1173
  EACH_METHODS.has(argument.expression.name.text) &&
923
1174
  argument.arguments[0] !== undefined) {
924
1175
  this.expression(context, argument.expression.expression, out);
925
- const body = this.#callback(context, argument.arguments[0], `${id}.0.`);
1176
+ const body = this.#callback(context, argument.arguments[0], `${id}.0.`, true);
926
1177
  if (body === undefined) {
927
1178
  this.#reading.complete = false;
928
1179
  }
@@ -943,6 +1194,10 @@ class BodyReader {
943
1194
  }
944
1195
  return;
945
1196
  }
1197
+ if (ts.isPropertyAccessExpression(callee) && PROMISE_METHODS.has(callee.name.text)) {
1198
+ this.#settled(context, call, callee, out);
1199
+ return;
1200
+ }
946
1201
  // items.map(…), items.forEach(…): the callback once per element.
947
1202
  if (ts.isPropertyAccessExpression(callee) &&
948
1203
  EACH_METHODS.has(callee.name.text) &&
@@ -964,12 +1219,22 @@ class BodyReader {
964
1219
  }
965
1220
  return;
966
1221
  }
967
- if (!ts.isIdentifier(callee)) {
968
- this.expression(context, callee, out);
1222
+ this.#operands(context, call, out);
1223
+ this.#invoke(context, call, out, awaited);
1224
+ }
1225
+ /** What a call evaluates before it runs: the callee written as an expression and its arguments. */
1226
+ #operands(context, call, out) {
1227
+ if (!this.#ts.isIdentifier(call.expression)) {
1228
+ this.expression(context, call.expression, out);
969
1229
  }
970
1230
  for (const argument of call.arguments) {
971
1231
  this.expression(context, argument, out);
972
1232
  }
1233
+ }
1234
+ /** The call itself, once its operands are evaluated: a step, wait, agent task or helper. */
1235
+ #invoke(context, call, out, awaited) {
1236
+ const ts = this.#ts;
1237
+ const callee = call.expression;
973
1238
  const resolved = this.#reading.resolve(context.module, callee, context.scope);
974
1239
  switch (resolved.kind) {
975
1240
  case "step":
@@ -1002,7 +1267,7 @@ class BodyReader {
1002
1267
  this.#helper(resolved.declared, out, awaited);
1003
1268
  return;
1004
1269
  case "none":
1005
- if (awaited) {
1270
+ if (awaited === true || (awaited === "returned" && !this.#value(callee))) {
1006
1271
  this.#reading.complete = false;
1007
1272
  out.push({ id: out.id(), kind: "unknown", label: this.#text(context, callee) });
1008
1273
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.105.0",
3
+ "version": "0.106.1",
4
4
  "description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",
@@ -37,6 +37,10 @@
37
37
  "types": "./dist/whatsapp.d.ts",
38
38
  "import": "./dist/whatsapp.js"
39
39
  },
40
+ "./email": {
41
+ "types": "./dist/email.d.ts",
42
+ "import": "./dist/email.js"
43
+ },
40
44
  "./channel-session": {
41
45
  "types": "./dist/channel-session.d.ts",
42
46
  "import": "./dist/channel-session.js"