alice-and-bot 1.0.71 → 1.0.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,6 +6,7 @@ Alice&Bot is the open-source, end-to-end encrypted messaging layer built for
6
6
  that: free keypair identities, desktop + mobile app for humans, ChatGPT-style or
7
7
  side widgets for websites, signed webhooks, and an MCP server.
8
8
 
9
+ [![npm](https://img.shields.io/npm/v/alice-and-bot)](https://www.npmjs.com/package/alice-and-bot)
9
10
  [![JSR](https://jsr.io/badges/@alice-and-bot/core)](https://jsr.io/@alice-and-bot/core)
10
11
  [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
11
12
  [![Website](https://img.shields.io/badge/web-aliceandbot.com-181715)](https://aliceandbot.com)
@@ -31,25 +32,27 @@ Read the [manifesto](https://aliceandbot.com/manifesto), browse the
31
32
 
32
33
  ## Installation
33
34
 
34
- Works in **Deno**, **Node.js**, **Bun**, **Cloudflare Workers**, and
35
+ Works in **Node.js**, **Deno**, **Bun**, **Cloudflare Workers**, and
35
36
  **browsers**.
36
37
 
37
- ### Deno
38
+ ### npm (Node.js / Bun)
38
39
 
39
40
  ```sh
40
- deno add jsr:@alice-and-bot/core
41
+ npm install alice-and-bot
41
42
  ```
42
43
 
43
- ### Node.js / npm
44
-
45
- ```sh
46
- npx jsr add @alice-and-bot/core
44
+ ```ts
45
+ import { createIdentity, sendMessage } from "alice-and-bot";
47
46
  ```
48
47
 
49
- ### Bun
48
+ ### Deno (JSR)
50
49
 
51
50
  ```sh
52
- bunx jsr add @alice-and-bot/core
51
+ deno add jsr:@alice-and-bot/core
52
+ ```
53
+
54
+ ```ts
55
+ import { createIdentity, sendMessage } from "@alice-and-bot/core";
53
56
  ```
54
57
 
55
58
  ### Quick start (30 seconds)
@@ -694,25 +697,23 @@ any client that supports MCP.
694
697
 
695
698
  ### Quick start
696
699
 
697
- 1. Install the binary:
698
-
699
- ```bash
700
- curl -fsSL https://storage.googleapis.com/alice-and-bot/cli/install.sh | sh
701
- ```
702
-
703
- 2. Add to your MCP client config (e.g. `mcp.json` or VS Code settings):
700
+ 1. Add `alice-and-bot-mcp` to your MCP client config (e.g. `mcp.json`):
704
701
 
705
702
  ```json
706
703
  {
707
704
  "mcpServers": {
708
705
  "aliceandbot": {
709
- "command": "alice-and-bot-mcp"
706
+ "command": "npx",
707
+ "args": ["-y", "alice-and-bot-mcp"]
710
708
  }
711
709
  }
712
710
  }
713
711
  ```
714
712
 
715
- 3. Tell your agent to "set up Alice&Bot". Scan the QR code with your phone and
713
+ _(Or install the standalone binary:
714
+ `curl -fsSL https://storage.googleapis.com/alice-and-bot/cli/install.sh | sh`)_
715
+
716
+ 2. Tell your agent to "set up Alice&Bot". Scan the QR code with your phone and
716
717
  send the pairing code to start messaging.
717
718
 
718
719
  See [`mcp/README.md`](mcp/README.md) or the
package/canvas/server.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  validateView,
14
14
  viewText,
15
15
  writeCanvas
16
- } from "../chunk-BULAQ7LV.js";
16
+ } from "../chunk-EZGHQY37.js";
17
17
  import "../chunk-DSOID4QM.js";
18
18
  export {
19
19
  actOnCanvas,
@@ -587,7 +587,7 @@ var viewText = (node) => {
587
587
  return `${own}${kids}`;
588
588
  };
589
589
 
590
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/manifest.ts
590
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/manifest.ts
591
591
  var makeManifest = (tags, resources, hosts, emits, emitsShape) => {
592
592
  return {
593
593
  tags: new Set(tags),
@@ -602,7 +602,7 @@ var makeManifest = (tags, resources, hosts, emits, emitsShape) => {
602
602
  };
603
603
  };
604
604
 
605
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/op.ts
605
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/op.ts
606
606
  var op = ({ input, output, tags, resources, run, hosts, emits, emitsShape }) => ({
607
607
  _tag: "dag-op",
608
608
  inputSchema: input,
@@ -611,7 +611,7 @@ var op = ({ input, output, tags, resources, run, hosts, emits, emitsShape }) =>
611
611
  run
612
612
  });
613
613
 
614
- // ../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/external.js
614
+ // ../../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/external.js
615
615
  var external_exports = {};
616
616
  __export(external_exports, {
617
617
  BRAND: () => BRAND,
@@ -723,7 +723,7 @@ __export(external_exports, {
723
723
  void: () => voidType
724
724
  });
725
725
 
726
- // ../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/helpers/util.js
726
+ // ../../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/helpers/util.js
727
727
  var util;
728
728
  (function(util2) {
729
729
  util2.assertEqual = (_) => {
@@ -855,7 +855,7 @@ var getParsedType = (data) => {
855
855
  }
856
856
  };
857
857
 
858
- // ../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/ZodError.js
858
+ // ../../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/ZodError.js
859
859
  var ZodIssueCode = util.arrayToEnum([
860
860
  "invalid_type",
861
861
  "invalid_literal",
@@ -987,7 +987,7 @@ ZodError.create = (issues) => {
987
987
  return error;
988
988
  };
989
989
 
990
- // ../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/locales/en.js
990
+ // ../../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/locales/en.js
991
991
  var errorMap = (issue, _ctx) => {
992
992
  let message;
993
993
  switch (issue.code) {
@@ -1079,7 +1079,7 @@ var errorMap = (issue, _ctx) => {
1079
1079
  };
1080
1080
  var en_default = errorMap;
1081
1081
 
1082
- // ../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/errors.js
1082
+ // ../../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/errors.js
1083
1083
  var overrideErrorMap = en_default;
1084
1084
  function setErrorMap(map) {
1085
1085
  overrideErrorMap = map;
@@ -1088,7 +1088,7 @@ function getErrorMap() {
1088
1088
  return overrideErrorMap;
1089
1089
  }
1090
1090
 
1091
- // ../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/helpers/parseUtil.js
1091
+ // ../../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/helpers/parseUtil.js
1092
1092
  var makeIssue = (params) => {
1093
1093
  const { data, path, errorMaps, issueData } = params;
1094
1094
  const fullPath = [
@@ -1204,7 +1204,7 @@ var isDirty = (x) => x.status === "dirty";
1204
1204
  var isValid = (x) => x.status === "valid";
1205
1205
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
1206
1206
 
1207
- // ../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/helpers/errorUtil.js
1207
+ // ../../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/helpers/errorUtil.js
1208
1208
  var errorUtil;
1209
1209
  (function(errorUtil2) {
1210
1210
  errorUtil2.errToObj = (message) => typeof message === "string" ? {
@@ -1213,7 +1213,7 @@ var errorUtil;
1213
1213
  errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
1214
1214
  })(errorUtil || (errorUtil = {}));
1215
1215
 
1216
- // ../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/types.js
1216
+ // ../../../.cache/deno/npm/registry.npmjs.org/zod/3.25.57/dist/esm/v3/types.js
1217
1217
  var ParseInputLazyPath = class {
1218
1218
  constructor(parent, value, path, key) {
1219
1219
  this._cachedPath = [];
@@ -4914,7 +4914,7 @@ var coerce = {
4914
4914
  };
4915
4915
  var NEVER = INVALID;
4916
4916
 
4917
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/context.ts
4917
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/context.ts
4918
4918
  var stackRunner = /* @__PURE__ */ (() => {
4919
4919
  const box = {
4920
4920
  current: void 0
@@ -4958,7 +4958,7 @@ var getContext = () => {
4958
4958
  };
4959
4959
  var runWithContext = (ctx, fn) => runnerBox.current.run(ctx, fn);
4960
4960
 
4961
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/ops/pure.ts
4961
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/ops/pure.ts
4962
4962
  var MAX_STRING_LENGTH = 8 * 1024 * 1024;
4963
4963
  var MAX_ARRAY_LENGTH = 1e5;
4964
4964
  var MAX_REGEX_PATTERN_LENGTH = 1e3;
@@ -5163,6 +5163,12 @@ var validateSafeRegex = (pattern, text) => {
5163
5163
  };
5164
5164
  var isValidJsonEscape = (seq) => seq === '\\"' || seq === "\\\\" || seq === "\\/" || seq === "\\b" || seq === "\\f" || seq === "\\n" || seq === "\\r" || seq === "\\t" || /^\\u[\da-fA-F]{4}$/.test(seq);
5165
5165
  var repairJson = (text) => text.replace(/\\(?:u[\da-fA-F]{4}|.|$)/gs, (match) => isValidJsonEscape(match) ? match : "\\" + match);
5166
+ var maxJsonParseErrorPreviewLength = 200;
5167
+ var formatJsonParseError = (text) => {
5168
+ const normalized = text.replace(/\s+/g, " ").trim();
5169
+ const preview = normalized.length > maxJsonParseErrorPreviewLength ? `${normalized.slice(0, maxJsonParseErrorPreviewLength)}...` : normalized;
5170
+ return normalized.startsWith("REQUEST_TIMEOUT:") ? new Error(`jsonParse failed on timed-out HTTP response (${preview}). Check res.status == 200 before calling jsonParse(res.body).`) : new Error(`jsonParse failed \u2014 input is not valid JSON: "${preview}". If parsing an httpRequest response, check res.status == 200 before calling jsonParse(res.body).`);
5171
+ };
5166
5172
  var safeJsonParse = (text) => {
5167
5173
  if (text.length > MAX_STRING_LENGTH) {
5168
5174
  throw new Error(`jsonParse input exceeds maximum string length (${MAX_STRING_LENGTH})`);
@@ -5170,7 +5176,11 @@ var safeJsonParse = (text) => {
5170
5176
  try {
5171
5177
  return JSON.parse(text);
5172
5178
  } catch {
5173
- return JSON.parse(repairJson(text));
5179
+ try {
5180
+ return JSON.parse(repairJson(text));
5181
+ } catch {
5182
+ throw formatJsonParseError(text);
5183
+ }
5174
5184
  }
5175
5185
  };
5176
5186
  var jsonParse = op({
@@ -5936,7 +5946,7 @@ var arrayConcat = op({
5936
5946
  }
5937
5947
  });
5938
5948
 
5939
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/ops/crypto.ts
5949
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/ops/crypto.ts
5940
5950
  var base64urlEncodeBytes = (bytes) => {
5941
5951
  const chunkSize = 8192;
5942
5952
  const chunks = [];
@@ -6254,7 +6264,7 @@ var x25519DeriveKey = op({
6254
6264
  }
6255
6265
  });
6256
6266
 
6257
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/ops/io.ts
6267
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/ops/io.ts
6258
6268
  var defaultUserAgent = "Safescript/1.0";
6259
6269
  var HOST_RE = /^[a-z0-9-]+(\.[a-z0-9-]+)*(:\d+)?$/i;
6260
6270
  var SUBDOMAIN_RE = /^[a-z0-9-]+(\.[a-z0-9-]+)*$/i;
@@ -6399,7 +6409,7 @@ var httpRequest = (declaredHost) => {
6399
6409
  });
6400
6410
  };
6401
6411
 
6402
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/ops/source.ts
6412
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/ops/source.ts
6403
6413
  var MAX_RANDOM_BYTES = 65536;
6404
6414
  var bytesToBase64Url2 = (bytes) => {
6405
6415
  const chunkSize = 8192;
@@ -6452,7 +6462,7 @@ var randomBytes = op({
6452
6462
  }
6453
6463
  });
6454
6464
 
6455
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/lang/lexer.ts
6465
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/lang/lexer.ts
6456
6466
  var isWhitespace = (ch) => ch === " " || ch === " " || ch === "\n" || ch === "\r";
6457
6467
  var isDigit = (ch) => ch >= "0" && ch <= "9";
6458
6468
  var isIdentStart = (ch) => ch >= "a" && ch <= "z" || ch >= "A" && ch <= "Z" || ch === "_";
@@ -6891,6 +6901,8 @@ var tokenize = (source) => {
6891
6901
  tokens.push(tok("&&", "&&", startLine, startCol));
6892
6902
  } else if (ch === "|" && peekAt(1) === "|") {
6893
6903
  tokens.push(tok("||", "||", startLine, startCol));
6904
+ } else if (ch === "?" && peekAt(1) === "?") {
6905
+ tokens.push(tok("??", "??", startLine, startCol));
6894
6906
  } else if (ch === "=" && peekAt(1) === ">") {
6895
6907
  tokens.push(tok("=>", "=>", startLine, startCol));
6896
6908
  } else if (ch === "=" && peekAt(1) === "=") {
@@ -6925,7 +6937,7 @@ var tokenize = (source) => {
6925
6937
  return tokens;
6926
6938
  };
6927
6939
 
6928
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/lang/parser.ts
6940
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/lang/parser.ts
6929
6941
  var MAX_TOKENS = 2e5;
6930
6942
  var MAX_PARSE_DEPTH = 256;
6931
6943
  var RESERVED_IDENTIFIERS = /* @__PURE__ */ new Set([
@@ -7158,7 +7170,7 @@ var parseParams = (s) => {
7158
7170
  };
7159
7171
  var parseExpr = (s) => withDepth(s, () => parseTernary(s));
7160
7172
  var parseTernary = (s) => {
7161
- const condition = parseLogicalOr(s);
7173
+ const condition = parseNullishCoalesce(s);
7162
7174
  if (peek(s).kind !== "?") return condition;
7163
7175
  advance(s);
7164
7176
  const then = parseExpr(s);
@@ -7171,6 +7183,20 @@ var parseTernary = (s) => {
7171
7183
  else: elseVal
7172
7184
  };
7173
7185
  };
7186
+ var parseNullishCoalesce = (s) => {
7187
+ let left = parseLogicalOr(s);
7188
+ while (peek(s).kind === "??") {
7189
+ advance(s);
7190
+ const right = parseLogicalOr(s);
7191
+ left = {
7192
+ kind: "binary_op",
7193
+ op: "??",
7194
+ left,
7195
+ right
7196
+ };
7197
+ }
7198
+ return left;
7199
+ };
7174
7200
  var parseLogicalOr = (s) => {
7175
7201
  let left = parseLogicalAnd(s);
7176
7202
  while (peek(s).kind === "||") {
@@ -7383,21 +7409,25 @@ var parseMethodOrNamespaceCall = (s, base, field, line, col) => {
7383
7409
  if (field === "split") {
7384
7410
  const args = parseCallArgsList(s);
7385
7411
  return {
7386
- kind: "call",
7387
- op: "stringSplit",
7388
- args: [
7389
- {
7390
- key: "text",
7391
- value: base
7392
- },
7393
- {
7394
- key: "delimiter",
7395
- value: args[0] ?? {
7396
- kind: "string",
7397
- value: ""
7412
+ kind: "dot_access",
7413
+ base: {
7414
+ kind: "call",
7415
+ op: "stringSplit",
7416
+ args: [
7417
+ {
7418
+ key: "text",
7419
+ value: base
7420
+ },
7421
+ {
7422
+ key: "delimiter",
7423
+ value: args[0] ?? {
7424
+ kind: "string",
7425
+ value: ""
7426
+ }
7398
7427
  }
7399
- }
7400
- ]
7428
+ ]
7429
+ },
7430
+ field: "parts"
7401
7431
  };
7402
7432
  }
7403
7433
  if (field === "includes") {
@@ -7959,40 +7989,20 @@ var isArrowFunctionStart = (s) => {
7959
7989
  if (tok.kind === "ident" && s.tokens[s.pos + 1]?.kind === "=>") {
7960
7990
  return true;
7961
7991
  }
7962
- if (tok.kind === "(") {
7963
- let parenDepth = 0;
7964
- let braceDepth = 0;
7965
- let idx = s.pos;
7966
- while (idx < s.tokens.length) {
7967
- const k = s.tokens[idx].kind;
7968
- if (k === "(") {
7969
- parenDepth++;
7970
- } else if (k === ")") {
7971
- parenDepth--;
7972
- if (parenDepth === 0) {
7973
- idx++;
7974
- break;
7975
- }
7976
- } else if (k === "{") {
7977
- braceDepth++;
7978
- } else if (k === "}") {
7979
- braceDepth--;
7980
- } else if (k === "eof" || k === ";" && braceDepth === 0) {
7981
- return false;
7982
- }
7983
- idx++;
7984
- }
7985
- if (parenDepth !== 0 || idx >= s.tokens.length) return false;
7986
- if (s.tokens[idx]?.kind === "=>") return true;
7987
- if (s.tokens[idx]?.kind === ":") {
7988
- idx++;
7989
- while (idx < s.tokens.length && s.tokens[idx].kind !== "=>" && s.tokens[idx].kind !== "{" && s.tokens[idx].kind !== ";" && s.tokens[idx].kind !== "eof") {
7990
- idx++;
7991
- }
7992
- if (s.tokens[idx]?.kind === "=>") return true;
7992
+ if (tok.kind !== "(") return false;
7993
+ const savedPos = s.pos;
7994
+ try {
7995
+ parseParams(s);
7996
+ if (peek(s).kind === ":") {
7997
+ advance(s);
7998
+ parseType(s);
7993
7999
  }
8000
+ return peek(s).kind === "=>";
8001
+ } catch {
8002
+ return false;
8003
+ } finally {
8004
+ s.pos = savedPos;
7994
8005
  }
7995
- return false;
7996
8006
  };
7997
8007
  var parseLambda = (s) => {
7998
8008
  const lambdaName = `__lambda_${s.lambdaCounter++}`;
@@ -8655,7 +8665,7 @@ var parsePrimary = (s) => {
8655
8665
  if (parsedFields !== null) {
8656
8666
  expect(s, ")");
8657
8667
  const args = parsedFields;
8658
- if ((tok.value === "jsonStringify" || tok.value === "stringStringify" || tok.value === "typeOf" || tok.value === "typeof" || tok.value === "len") && !args.some((a) => a.key === "value")) {
8668
+ if ((tok.value === "jsonStringify" || tok.value === "stringStringify" || tok.value === "typeOf" || tok.value === "typeof" || tok.value === "len") && !(args.length === 1 && args[0].key === "value")) {
8659
8669
  return {
8660
8670
  kind: "call",
8661
8671
  op: tok.value,
@@ -8670,7 +8680,7 @@ var parsePrimary = (s) => {
8670
8680
  ]
8671
8681
  };
8672
8682
  }
8673
- if ((tok.value === "objectKeys" || tok.value === "keys") && !args.some((a) => a.key === "obj" || a.key === "value")) {
8683
+ if ((tok.value === "objectKeys" || tok.value === "keys") && !(args.length === 1 && (args[0].key === "obj" || args[0].key === "value"))) {
8674
8684
  return {
8675
8685
  kind: "call",
8676
8686
  op: tok.value,
@@ -8701,10 +8711,10 @@ var parsePrimary = (s) => {
8701
8711
  args: []
8702
8712
  };
8703
8713
  }
8704
- const posFieldNames = BUILTIN_POSITIONAL_FIELDS[tok.value];
8714
+ const posFieldNames = Object.hasOwn(BUILTIN_POSITIONAL_FIELDS, tok.value) ? BUILTIN_POSITIONAL_FIELDS[tok.value] : void 0;
8705
8715
  if (posFieldNames) {
8706
8716
  const posArgs = parseCallArgsList(s);
8707
- return {
8717
+ const call = {
8708
8718
  kind: "call",
8709
8719
  op: tok.value,
8710
8720
  args: posArgs.slice(0, posFieldNames.length).map((value2, idx) => ({
@@ -8712,6 +8722,14 @@ var parsePrimary = (s) => {
8712
8722
  value: value2
8713
8723
  }))
8714
8724
  };
8725
+ if (tok.value === "split" || tok.value === "stringSplit") {
8726
+ return {
8727
+ kind: "dot_access",
8728
+ base: call,
8729
+ field: "parts"
8730
+ };
8731
+ }
8732
+ return call;
8715
8733
  }
8716
8734
  const fieldName = s.unaryFields.get(tok.value);
8717
8735
  if (!fieldName) {
@@ -8964,6 +8982,15 @@ var hasReturnInBlock = (stmts) => {
8964
8982
  }
8965
8983
  return false;
8966
8984
  };
8985
+ var alwaysReturns = (stmts) => {
8986
+ for (const stmt of stmts) {
8987
+ if (stmt.kind === "return") return true;
8988
+ if (stmt.kind === "if_else" && alwaysReturns(stmt.then) && stmt.else !== null && alwaysReturns(stmt.else)) {
8989
+ return true;
8990
+ }
8991
+ }
8992
+ return false;
8993
+ };
8967
8994
  var transformStatements = (stmts, returnVar) => {
8968
8995
  const result = [];
8969
8996
  for (let i = 0; i < stmts.length; i++) {
@@ -8977,31 +9004,36 @@ var transformStatements = (stmts, returnVar) => {
8977
9004
  break;
8978
9005
  }
8979
9006
  if (stmt.kind === "if_else") {
8980
- const transformedThen = transformStatements(stmt.then, returnVar);
8981
- if (hasReturnInBlock(stmt.then)) {
8982
- const remaining = stmts.slice(i + 1);
9007
+ const remaining = stmts.slice(i + 1);
9008
+ const branchHasReturn = hasReturnInBlock(stmt.then) || stmt.else !== null && hasReturnInBlock(stmt.else);
9009
+ if (branchHasReturn && remaining.length > 0) {
9010
+ const combinedThen = alwaysReturns(stmt.then) ? stmt.then : [
9011
+ ...stmt.then,
9012
+ ...remaining
9013
+ ];
8983
9014
  const origElse = stmt.else ?? [];
8984
- const combinedElse = [
9015
+ const combinedElse = alwaysReturns(origElse) ? origElse : [
8985
9016
  ...origElse,
8986
9017
  ...remaining
8987
9018
  ];
8988
- const transformedElse = transformStatements(combinedElse, returnVar);
9019
+ const transformedThen2 = transformStatements(combinedThen, returnVar);
9020
+ const transformedElse2 = transformStatements(combinedElse, returnVar);
8989
9021
  result.push({
8990
9022
  kind: "if_else",
8991
9023
  condition: stmt.condition,
8992
- then: transformedThen,
8993
- else: transformedElse.length > 0 ? transformedElse : null
9024
+ then: transformedThen2,
9025
+ else: transformedElse2.length > 0 ? transformedElse2 : null
8994
9026
  });
8995
9027
  break;
8996
- } else {
8997
- const transformedElse = stmt.else ? transformStatements(stmt.else, returnVar) : null;
8998
- result.push({
8999
- kind: "if_else",
9000
- condition: stmt.condition,
9001
- then: transformedThen,
9002
- else: transformedElse
9003
- });
9004
9028
  }
9029
+ const transformedThen = transformStatements(stmt.then, returnVar);
9030
+ const transformedElse = stmt.else ? transformStatements(stmt.else, returnVar) : null;
9031
+ result.push({
9032
+ kind: "if_else",
9033
+ condition: stmt.condition,
9034
+ then: transformedThen,
9035
+ else: transformedElse
9036
+ });
9005
9037
  } else {
9006
9038
  result.push(stmt);
9007
9039
  }
@@ -10144,14 +10176,12 @@ var inferTypes = (program) => {
10144
10176
  kind: "primitive",
10145
10177
  name: "boolean"
10146
10178
  });
10147
- constrain(expr.left, {
10148
- kind: "primitive",
10149
- name: "number"
10150
- }, locals);
10151
- constrain(expr.right, {
10179
+ const opType = {
10152
10180
  kind: "primitive",
10153
- name: "number"
10154
- }, locals);
10181
+ name: "inferred"
10182
+ };
10183
+ constrain(expr.left, opType, locals);
10184
+ constrain(expr.right, opType, locals);
10155
10185
  } else if ([
10156
10186
  "==",
10157
10187
  "!="
@@ -10182,6 +10212,9 @@ var inferTypes = (program) => {
10182
10212
  kind: "primitive",
10183
10213
  name: "boolean"
10184
10214
  }, locals);
10215
+ } else if (expr.op === "??") {
10216
+ constrain(expr.left, expectedType, locals);
10217
+ constrain(expr.right, expectedType, locals);
10185
10218
  }
10186
10219
  break;
10187
10220
  case "ternary":
@@ -10226,7 +10259,7 @@ var inferTypes = (program) => {
10226
10259
  break;
10227
10260
  }
10228
10261
  case "call": {
10229
- const sig = BUILTIN_SIGNATURES[expr.op];
10262
+ const sig = Object.hasOwn(BUILTIN_SIGNATURES, expr.op) ? BUILTIN_SIGNATURES[expr.op] : void 0;
10230
10263
  if (sig) {
10231
10264
  unify(expectedType, sig.returnType);
10232
10265
  for (const arg of expr.args) {
@@ -10288,7 +10321,7 @@ var inferTypes = (program) => {
10288
10321
  }
10289
10322
  }
10290
10323
  } else {
10291
- const sig = BUILTIN_SIGNATURES[expr.target];
10324
+ const sig = Object.hasOwn(BUILTIN_SIGNATURES, expr.target) ? BUILTIN_SIGNATURES[expr.target] : void 0;
10292
10325
  if (sig) {
10293
10326
  for (const r of expr.replacements) {
10294
10327
  const replFn = fnsMap.get(r.value);
@@ -10664,7 +10697,7 @@ var validateProgramSemantics = (program, roots) => {
10664
10697
  }
10665
10698
  };
10666
10699
 
10667
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/lang/registry.ts
10700
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/lang/registry.ts
10668
10701
  var direct = (dagOp, unaryField = null) => ({
10669
10702
  staticFields: /* @__PURE__ */ new Set(),
10670
10703
  unaryField,
@@ -10959,7 +10992,7 @@ var builtinUnaryFields = new Map([
10959
10992
  entry.unaryField
10960
10993
  ]));
10961
10994
 
10962
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/lang/graph.ts
10995
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/lang/graph.ts
10963
10996
  var genuineDags = /* @__PURE__ */ new WeakSet();
10964
10997
  var isGenuineDag = (value) => typeof value === "object" && value !== null && genuineDags.has(value);
10965
10998
  var replacementsKey = (r) => [
@@ -11408,7 +11441,7 @@ var buildDagInternal = (fn, fns, reps, cache, building) => {
11408
11441
  };
11409
11442
  var buildDag = (fn, fns, reps, cache) => buildDagInternal(fn, fns, reps, cache, /* @__PURE__ */ new Set());
11410
11443
 
11411
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/lang/graphExec.ts
11444
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/lang/graphExec.ts
11412
11445
  var MAX_EXECUTION_STEPS = 1e5;
11413
11446
  var MAX_CALL_DEPTH = 64;
11414
11447
  var FORBIDDEN_KEYS = /* @__PURE__ */ new Set([
@@ -11553,6 +11586,11 @@ var computeNode = async (node, dag, cache, env, registry, exec) => {
11553
11586
  if (l2) return l2;
11554
11587
  return await evalNode(node.right, dag, cache, env, registry, exec);
11555
11588
  }
11589
+ if (node.op === "??") {
11590
+ const l2 = await evalNode(node.left, dag, cache, env, registry, exec);
11591
+ if (!isNullish(l2)) return l2;
11592
+ return await evalNode(node.right, dag, cache, env, registry, exec);
11593
+ }
11556
11594
  const l = await evalNode(node.left, dag, cache, env, registry, exec);
11557
11595
  const r = await evalNode(node.right, dag, cache, env, registry, exec);
11558
11596
  return evalBinary(node.op, l, r);
@@ -11766,6 +11804,12 @@ var evalBinary = (op2, left, right) => {
11766
11804
  const eq = isNullish(left) && isNullish(right) || left === right;
11767
11805
  return op2 === "==" ? eq : !eq;
11768
11806
  }
11807
+ if (typeof left === "string" && typeof right === "string") {
11808
+ if (op2 === "<") return left < right;
11809
+ if (op2 === ">") return left > right;
11810
+ if (op2 === "<=") return left <= right;
11811
+ if (op2 === ">=") return left >= right;
11812
+ }
11769
11813
  if (typeof left !== "number" || typeof right !== "number") {
11770
11814
  if (op2 === "&&") {
11771
11815
  return Boolean(left) && Boolean(right);
@@ -11773,6 +11817,9 @@ var evalBinary = (op2, left, right) => {
11773
11817
  if (op2 === "||") {
11774
11818
  return Boolean(left) || Boolean(right);
11775
11819
  }
11820
+ if (op2 === "??") {
11821
+ return isNullish(left) ? right : left;
11822
+ }
11776
11823
  throw new Error(`Cannot apply '${op2}' to ${typeof left} and ${typeof right}`);
11777
11824
  }
11778
11825
  switch (op2) {
@@ -11871,7 +11918,7 @@ var executeDag = (dag, args, registry, options) => executeDagInternal(dag, args,
11871
11918
  depth: options?.depth ?? 0
11872
11919
  });
11873
11920
 
11874
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/lang/interpreter.ts
11921
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/lang/interpreter.ts
11875
11922
  var interpret = (program, functionName, args, ctx, registry = builtinRegistry, _sourcePath = "") => {
11876
11923
  const entry = program.functions.find((f) => f.name === functionName);
11877
11924
  if (!entry) throw new Error(`Function '${functionName}' not found`);
@@ -11904,7 +11951,7 @@ var interpret = (program, functionName, args, ctx, registry = builtinRegistry, _
11904
11951
  }));
11905
11952
  };
11906
11953
 
11907
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/lang/complexity.ts
11954
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/lang/complexity.ts
11908
11955
  var canonicalTerm = (t) => ({
11909
11956
  coeff: t.coeff,
11910
11957
  vars: [
@@ -11978,7 +12025,7 @@ var multiply = (a, b) => {
11978
12025
  };
11979
12026
  var maxExpr = (a, b) => add(a, b);
11980
12027
 
11981
- // deno:https://jsr.io/@uri/safescript/0.1.50/src/lang/signature.ts
12028
+ // deno:https://jsr.io/@uri/safescript/0.1.55/src/lang/signature.ts
11982
12029
  var emptyShape = {
11983
12030
  kind: "leaf",
11984
12031
  sources: /* @__PURE__ */ new Set()
package/components.js CHANGED
@@ -49,7 +49,7 @@ import {
49
49
  isRenderableTag,
50
50
  renderCanvas,
51
51
  sanitizeViewUrl
52
- } from "./chunk-BULAQ7LV.js";
52
+ } from "./chunk-EZGHQY37.js";
53
53
  import {
54
54
  __commonJS,
55
55
  __toESM,
@@ -67,9 +67,9 @@ import {
67
67
  unique
68
68
  } from "./chunk-DSOID4QM.js";
69
69
 
70
- // ../../.cache/deno/npm/registry.npmjs.org/levenshtein-search/0.1.2/utils.js
70
+ // ../../../.cache/deno/npm/registry.npmjs.org/levenshtein-search/0.1.2/utils.js
71
71
  var require_utils = __commonJS({
72
- "../../.cache/deno/npm/registry.npmjs.org/levenshtein-search/0.1.2/utils.js"(exports, module) {
72
+ "../../../.cache/deno/npm/registry.npmjs.org/levenshtein-search/0.1.2/utils.js"(exports, module) {
73
73
  function* searchExact(needle, haystack, startIndex = 0, endIndex = null) {
74
74
  const needleLen = needle.length;
75
75
  if (needleLen === 0) return;
@@ -93,9 +93,9 @@ var require_utils = __commonJS({
93
93
  }
94
94
  });
95
95
 
96
- // ../../.cache/deno/npm/registry.npmjs.org/levenshtein-search/0.1.2/levenshtein-search.js
96
+ // ../../../.cache/deno/npm/registry.npmjs.org/levenshtein-search/0.1.2/levenshtein-search.js
97
97
  var require_levenshtein_search = __commonJS({
98
- "../../.cache/deno/npm/registry.npmjs.org/levenshtein-search/0.1.2/levenshtein-search.js"(exports, module) {
98
+ "../../../.cache/deno/npm/registry.npmjs.org/levenshtein-search/0.1.2/levenshtein-search.js"(exports, module) {
99
99
  var { searchExact, reverse: reverse2 } = require_utils();
100
100
  function isEditDistanceNoGreaterThan(a, b, maxDist) {
101
101
  if (a.length > b.length) {
@@ -421,9 +421,9 @@ var require_levenshtein_search = __commonJS({
421
421
  }
422
422
  });
423
423
 
424
- // ../../.cache/deno/npm/registry.npmjs.org/levenshtein-search/0.1.2/index.js
424
+ // ../../../.cache/deno/npm/registry.npmjs.org/levenshtein-search/0.1.2/index.js
425
425
  var require__ = __commonJS({
426
- "../../.cache/deno/npm/registry.npmjs.org/levenshtein-search/0.1.2/index.js"(exports, module) {
426
+ "../../../.cache/deno/npm/registry.npmjs.org/levenshtein-search/0.1.2/index.js"(exports, module) {
427
427
  var { editDistance, fuzzySearch, isEditDistanceNoGreaterThan } = require_levenshtein_search();
428
428
  module.exports = {
429
429
  editDistance,
@@ -2670,10 +2670,10 @@ if (!customElements.get("chat-avatar")) {
2670
2670
  // lit/components/markdown.ts
2671
2671
  import { Marked } from "marked";
2672
2672
 
2673
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/promise.js
2673
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/promise.js
2674
2674
  var isPromise = (x) => typeof x?.then === "function" && typeof x?.catch === "function" && typeof x?.finally === "function";
2675
2675
 
2676
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/array.js
2676
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/array.js
2677
2677
  var join = (str) => (x) => x.join(str);
2678
2678
  var length = (array) => array.length;
2679
2679
  var reverse = (array) => array.slice().reverse();
@@ -2704,11 +2704,11 @@ var range = (start, end) => {
2704
2704
  };
2705
2705
  var includedIn = (array) => (x) => array.includes(x);
2706
2706
 
2707
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/operator.js
2707
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/operator.js
2708
2708
  var letIn = (value, constructor) => constructor(value);
2709
2709
  var not = (x) => !x;
2710
2710
 
2711
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/reduce.js
2711
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/reduce.js
2712
2712
  var reduceHelper = (reducer, s, xs, firstIndex) => {
2713
2713
  let current = s;
2714
2714
  for (let i = firstIndex; i < xs.length; i++) {
@@ -2721,7 +2721,7 @@ var reduceHelper = (reducer, s, xs, firstIndex) => {
2721
2721
  };
2722
2722
  var reduce = (reducer, initial) => (xs) => reduceHelper(reducer, initial(), xs, 0);
2723
2723
 
2724
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/trace.js
2724
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/trace.js
2725
2725
  var frameToString = ({ line, file, column }) => `${file}:${line}:${column}`;
2726
2726
  var parseStackLine = (stackLine) => {
2727
2727
  const matches = /\s+at\s+(.+\s)?\(?(.+):(\d+):(\d+)\)?/.exec(stackLine) || /(.+)@(.+):(\d+):(\d+)/g.exec(stackLine);
@@ -2739,7 +2739,7 @@ var currentLocation = (depth) => {
2739
2739
  return x ? frameToString(x) : "stack line could not be parsed";
2740
2740
  };
2741
2741
 
2742
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/composition.js
2742
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/composition.js
2743
2743
  var pipeWithoutStack = (...fs2) => (...x) => reduce((v, f) => f(v), () => fs2[0](...x))(fs2.slice(1));
2744
2744
  var augmentAndRethrowException = (location) => (e) => {
2745
2745
  if (e === void 0) {
@@ -2774,7 +2774,7 @@ var complement = (f) => (
2774
2774
  );
2775
2775
  var identity = (x) => x;
2776
2776
 
2777
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/map.js
2777
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/map.js
2778
2778
  var mapWithoutStack = (f) => (xs) => {
2779
2779
  const results = [];
2780
2780
  for (const x of xs) {
@@ -2784,7 +2784,7 @@ var mapWithoutStack = (f) => (xs) => {
2784
2784
  };
2785
2785
  var map2 = (...fs2) => errorBoundry(mapWithoutStack(...fs2));
2786
2786
 
2787
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/juxt.js
2787
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/juxt.js
2788
2788
  var juxt = (...fs2) => (...x) => {
2789
2789
  const result = [];
2790
2790
  let anyAsync = false;
@@ -2796,7 +2796,7 @@ var juxt = (...fs2) => (...x) => {
2796
2796
  };
2797
2797
  var pairRight = (f) => juxt(identity, f);
2798
2798
 
2799
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/filter.js
2799
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/filter.js
2800
2800
  var filter = (f) => (
2801
2801
  // @ts-expect-error typing head is hard.
2802
2802
  pipe(map2(pairRight(f)), (array) => array.filter(second), map2(head))
@@ -2806,7 +2806,7 @@ var remove = (f) => (
2806
2806
  filter(complement(f))
2807
2807
  );
2808
2808
 
2809
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/debug.js
2809
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/debug.js
2810
2810
  var tryCatch = (
2811
2811
  // deno-lint-ignore no-explicit-any
2812
2812
  (fallback) => (
@@ -2823,16 +2823,16 @@ var tryCatch = (
2823
2823
  );
2824
2824
  var catchWithNull = tryCatch(() => null);
2825
2825
 
2826
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/deps/jsr.io/@noble/hashes/1.7.2/src/crypto.js
2826
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/deps/jsr.io/@noble/hashes/1.7.2/src/crypto.js
2827
2827
  var crypto2 = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
2828
2828
 
2829
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/deps/jsr.io/@noble/hashes/1.7.2/src/utils.js
2829
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/deps/jsr.io/@noble/hashes/1.7.2/src/utils.js
2830
2830
  var hasHexBuiltin = (
2831
2831
  // @ts-ignore
2832
2832
  typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
2833
2833
  );
2834
2834
 
2835
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/deps/jsr.io/@noble/hashes/1.7.2/src/_u64.js
2835
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/deps/jsr.io/@noble/hashes/1.7.2/src/_u64.js
2836
2836
  var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
2837
2837
  var _32n = /* @__PURE__ */ BigInt(32);
2838
2838
  function fromBig(n, le = false) {
@@ -2912,7 +2912,7 @@ var u64 = {
2912
2912
  };
2913
2913
  var u64_default = u64;
2914
2914
 
2915
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/deps/jsr.io/@noble/hashes/1.7.2/src/sha512.js
2915
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/deps/jsr.io/@noble/hashes/1.7.2/src/sha512.js
2916
2916
  var [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64_default.split([
2917
2917
  "0x428a2f98d728ae22",
2918
2918
  "0x7137449123ef65cd",
@@ -2996,19 +2996,19 @@ var [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64_default.split([
2996
2996
  "0x6c44198c4a475817"
2997
2997
  ].map((n) => BigInt(n))))();
2998
2998
 
2999
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/deps/jsr.io/@std/encoding/1.0.9/_common16.js
2999
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/deps/jsr.io/@std/encoding/1.0.9/_common16.js
3000
3000
  var alphabet = new TextEncoder().encode("0123456789abcdef");
3001
3001
  var rAlphabet = new Uint8Array(128).fill(16);
3002
3002
  alphabet.forEach((byte, i) => rAlphabet[byte] = i);
3003
3003
  new TextEncoder().encode("ABCDEF").forEach((byte, i) => rAlphabet[byte] = i + 10);
3004
3004
 
3005
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/deps/jsr.io/@std/encoding/1.0.9/hex.js
3005
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/deps/jsr.io/@std/encoding/1.0.9/hex.js
3006
3006
  var alphabet2 = new TextEncoder().encode("0123456789abcdef");
3007
3007
  var rAlphabet2 = new Uint8Array(128).fill(16);
3008
3008
  alphabet2.forEach((byte, i) => rAlphabet2[byte] = i);
3009
3009
  new TextEncoder().encode("ABCDEF").forEach((byte, i) => rAlphabet2[byte] = i + 10);
3010
3010
 
3011
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/mapping.js
3011
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/mapping.js
3012
3012
  var groupByManyReduce = (keys, reducer, initial) => (it) => {
3013
3013
  const result = {};
3014
3014
  for (const x of it) {
@@ -3042,7 +3042,7 @@ var onEntries = (transformation) => (
3042
3042
  var entryMap = pipe(map2, onEntries);
3043
3043
  var entryFilter = pipe(filter, onEntries);
3044
3044
 
3045
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/io.js
3045
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/io.js
3046
3046
  var timeoutHelper = (error) => (ms, f) => (
3047
3047
  // @ts-expect-error ts cannot infer
3048
3048
  (...args) => new Promise((resolve, reject) => {
@@ -3063,11 +3063,11 @@ var timeoutHelper = (error) => (ms, f) => (
3063
3063
  );
3064
3064
  var timeout = timeoutHelper(new Error("Timed out"));
3065
3065
 
3066
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/math.js
3066
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/math.js
3067
3067
  var addition = (a, b) => a + b;
3068
3068
  var sum = reduce(addition, () => 0);
3069
3069
 
3070
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/matrix.js
3070
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/matrix.js
3071
3071
  var product = reduce((a, b) => a.flatMap((x) => b.map((y) => [
3072
3072
  ...x,
3073
3073
  y
@@ -3075,7 +3075,7 @@ var product = reduce((a, b) => a.flatMap((x) => b.map((y) => [
3075
3075
  []
3076
3076
  ]);
3077
3077
 
3078
- // ../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/string.js
3078
+ // ../../../.cache/deno/npm/registry.npmjs.org/gamla/124.0.0/esm/src/string.js
3079
3079
  var split2 = (x) => (s) => s.split(x);
3080
3080
  var lowercase = (s) => s.toLocaleLowerCase();
3081
3081
  var replace = (target, replacement) => (s) => s.replace(target, replacement);
@@ -3093,10 +3093,10 @@ var trim = (characters) => (str) => {
3093
3093
  return str.substring(start, end + 1);
3094
3094
  };
3095
3095
 
3096
- // deno:https://jsr.io/@uri/silly-nlp/0.2.13/src/index.ts
3096
+ // deno:https://jsr.io/@uri/silly-nlp/0.2.15/src/index.ts
3097
3097
  var import_npm_levenshtein_search_0_1 = __toESM(require__());
3098
3098
 
3099
- // deno:https://jsr.io/@uri/silly-nlp/0.2.13/src/stopWords.ts
3099
+ // deno:https://jsr.io/@uri/silly-nlp/0.2.15/src/stopWords.ts
3100
3100
  var stopWords = [
3101
3101
  "i",
3102
3102
  "me",
@@ -3229,7 +3229,7 @@ var stopWords = [
3229
3229
  "now"
3230
3230
  ];
3231
3231
 
3232
- // deno:https://jsr.io/@uri/silly-nlp/0.2.13/src/index.ts
3232
+ // deno:https://jsr.io/@uri/silly-nlp/0.2.15/src/index.ts
3233
3233
  var regExpLocations = (pattern, input) => {
3234
3234
  const locations = [];
3235
3235
  let match;
@@ -3386,16 +3386,37 @@ var commonWebTerms = /* @__PURE__ */ new Set([
3386
3386
  "site"
3387
3387
  ]);
3388
3388
  var isWordLike = (s) => s.length >= 2 && /^[A-Z]?[a-z]+$/.test(s) && /[aeiouy]/i.test(s) && !/[bcdfghjklmnpqrstvwxz]{6,}/i.test(s);
3389
+ var isAllCapsWord = (s) => /^[A-Z]{2,5}$/.test(s) || s.length >= 2 && s.length <= 12 && /^[A-Z]+$/.test(s) && /[AEIOUY]/.test(s) && !/[BCDFGHJKLMNPQRSTVWXZ]{5,}/.test(s);
3389
3390
  var isKnownWord = (word) => commonWebTerms.has(word.toLowerCase()) || isWordLike(word);
3391
+ var isPureCamelWord = (p) => /^[A-Z]{2,5}$/.test(p) || isWordLike(p);
3392
+ var isAuxCamelPart = (p) => /^[AEIOU]$/.test(p) || /^[A-Za-z]{1,6}\d{1,3}$/.test(p);
3390
3393
  var isCamelCaseIdentifier = (token) => {
3391
- if (!/^[a-zA-Z]+$/.test(token)) return false;
3392
- const parts = token.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(" ");
3393
- return parts.length >= 2 && parts.every((p) => /^[A-Z]{2,5}$/.test(p) || isWordLike(p));
3394
+ if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(token)) return false;
3395
+ const parts = token.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(" ");
3396
+ if (parts.length < 2) return false;
3397
+ if (parts.every(isPureCamelWord)) return true;
3398
+ if (!parts.every((p) => isPureCamelWord(p) || isAuxCamelPart(p))) {
3399
+ return false;
3400
+ }
3401
+ const pureCount = parts.filter(isPureCamelWord).length;
3402
+ const longWordCount = parts.filter((p) => p.length >= 3 && isWordLike(p)).length;
3403
+ return longWordCount >= 2 && pureCount >= parts.length - 2;
3394
3404
  };
3405
+ var isSlugWord = (s) => isKnownWord(s) || isAllCapsWord(s) || isCamelCaseIdentifier(s);
3406
+ var isNumericSegment = (s) => /^\d+$/.test(s);
3407
+ var isUuid = (token) => /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(token);
3408
+ var isLongRandomSegment = (s) => s.length >= 12 && (characterClasses(s) >= 2 || /^[0-9a-f]{12,}$/i.test(s));
3395
3409
  var dictionarySlug = (token) => {
3396
- if (token.includes("+")) return false;
3410
+ if (token.includes("+") || isUuid(token)) return false;
3397
3411
  if (isKnownWord(token) || isCamelCaseIdentifier(token)) return true;
3398
- return letIn(token.split(/[-_.:/]+/).filter((s) => s.length > 0), (segments) => segments.length >= 2 && letIn(segments.filter((s) => isKnownWord(s) || isCamelCaseIdentifier(s)).length, (wordCount) => segments.length === 2 ? wordCount === 2 : wordCount >= segments.length - 1));
3412
+ return letIn(token.split(/[-_.:/]+/).filter((s) => s.length > 0), (segments) => {
3413
+ if (segments.length < 2) return false;
3414
+ const wordCount = segments.filter(isSlugWord).length;
3415
+ if (wordCount === 0) return false;
3416
+ const nonWordOrNumeric = segments.filter((s) => !isSlugWord(s) && !isNumericSegment(s));
3417
+ if (nonWordOrNumeric.length === 0) return true;
3418
+ return wordCount >= 2 && nonWordOrNumeric.length === 1 && !isLongRandomSegment(nonWordOrNumeric[0]);
3419
+ });
3399
3420
  };
3400
3421
  var shannonEntropy = (token) => {
3401
3422
  const counts = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alice-and-bot",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "description": "A chat network for agents. Open-source, end-to-end encrypted messaging SDK, React chat UI, and embeddable widgets for AI agents and humans.",
5
5
  "license": "MIT",
6
6
  "type": "module",