@elizaos/server 1.4.3-alpha.0 → 1.4.3-alpha.2

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.
Files changed (2) hide show
  1. package/dist/index.js +131 -139
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
21
21
  // ../../node_modules/path-to-regexp/dist/index.js
22
22
  var require_dist = __commonJS((exports) => {
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.TokenData = undefined;
24
+ exports.PathError = exports.TokenData = undefined;
25
25
  exports.parse = parse;
26
26
  exports.compile = compile;
27
27
  exports.match = match;
@@ -31,7 +31,6 @@ var require_dist = __commonJS((exports) => {
31
31
  var NOOP_VALUE = (value) => value;
32
32
  var ID_START = /^[$_\p{ID_Start}]$/u;
33
33
  var ID_CONTINUE = /^[$\u200c\u200d\p{ID_Continue}]$/u;
34
- var DEBUG_URL = "https://git.new/pathToRegexpError";
35
34
  var SIMPLE_TOKENS = {
36
35
  "{": "{",
37
36
  "}": "}",
@@ -44,151 +43,125 @@ var require_dist = __commonJS((exports) => {
44
43
  "!": "!"
45
44
  };
46
45
  function escapeText(str) {
47
- return str.replace(/[{}()\[\]+?!:*]/g, "\\$&");
46
+ return str.replace(/[{}()\[\]+?!:*\\]/g, "\\$&");
48
47
  }
49
48
  function escape(str) {
50
49
  return str.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
51
50
  }
52
- function* lexer(str) {
51
+
52
+ class TokenData {
53
+ constructor(tokens, originalPath) {
54
+ this.tokens = tokens;
55
+ this.originalPath = originalPath;
56
+ }
57
+ }
58
+ exports.TokenData = TokenData;
59
+
60
+ class PathError extends TypeError {
61
+ constructor(message, originalPath) {
62
+ let text = message;
63
+ if (originalPath)
64
+ text += `: ${originalPath}`;
65
+ text += `; visit https://git.new/pathToRegexpError for info`;
66
+ super(text);
67
+ this.originalPath = originalPath;
68
+ }
69
+ }
70
+ exports.PathError = PathError;
71
+ function parse(str, options = {}) {
72
+ const { encodePath = NOOP_VALUE } = options;
53
73
  const chars = [...str];
54
- let i = 0;
74
+ const tokens = [];
75
+ let index = 0;
76
+ let pos = 0;
55
77
  function name() {
56
78
  let value = "";
57
- if (ID_START.test(chars[++i])) {
58
- value += chars[i];
59
- while (ID_CONTINUE.test(chars[++i])) {
60
- value += chars[i];
61
- }
62
- } else if (chars[i] === '"') {
63
- let pos = i;
64
- while (i < chars.length) {
65
- if (chars[++i] === '"') {
66
- i++;
67
- pos = 0;
79
+ if (ID_START.test(chars[index])) {
80
+ do {
81
+ value += chars[index++];
82
+ } while (ID_CONTINUE.test(chars[index]));
83
+ } else if (chars[index] === '"') {
84
+ let quoteStart = index;
85
+ while (index++ < chars.length) {
86
+ if (chars[index] === '"') {
87
+ index++;
88
+ quoteStart = 0;
68
89
  break;
69
90
  }
70
- if (chars[i] === "\\") {
71
- value += chars[++i];
72
- } else {
73
- value += chars[i];
74
- }
91
+ if (chars[index] === "\\")
92
+ index++;
93
+ value += chars[index];
75
94
  }
76
- if (pos) {
77
- throw new TypeError(`Unterminated quote at ${pos}: ${DEBUG_URL}`);
95
+ if (quoteStart) {
96
+ throw new PathError(`Unterminated quote at index ${quoteStart}`, str);
78
97
  }
79
98
  }
80
99
  if (!value) {
81
- throw new TypeError(`Missing parameter name at ${i}: ${DEBUG_URL}`);
100
+ throw new PathError(`Missing parameter name at index ${index}`, str);
82
101
  }
83
102
  return value;
84
103
  }
85
- while (i < chars.length) {
86
- const value = chars[i];
104
+ while (index < chars.length) {
105
+ const value = chars[index];
87
106
  const type = SIMPLE_TOKENS[value];
88
107
  if (type) {
89
- yield { type, index: i++, value };
108
+ tokens.push({ type, index: index++, value });
90
109
  } else if (value === "\\") {
91
- yield { type: "ESCAPED", index: i++, value: chars[i++] };
110
+ tokens.push({ type: "escape", index: index++, value: chars[index++] });
92
111
  } else if (value === ":") {
93
- const value2 = name();
94
- yield { type: "PARAM", index: i, value: value2 };
112
+ tokens.push({ type: "param", index: index++, value: name() });
95
113
  } else if (value === "*") {
96
- const value2 = name();
97
- yield { type: "WILDCARD", index: i, value: value2 };
114
+ tokens.push({ type: "wildcard", index: index++, value: name() });
98
115
  } else {
99
- yield { type: "CHAR", index: i, value: chars[i++] };
116
+ tokens.push({ type: "char", index: index++, value });
100
117
  }
101
118
  }
102
- return { type: "END", index: i, value: "" };
103
- }
104
-
105
- class Iter {
106
- constructor(tokens) {
107
- this.tokens = tokens;
108
- }
109
- peek() {
110
- if (!this._peek) {
111
- const next = this.tokens.next();
112
- this._peek = next.value;
113
- }
114
- return this._peek;
115
- }
116
- tryConsume(type) {
117
- const token = this.peek();
118
- if (token.type !== type)
119
- return;
120
- this._peek = undefined;
121
- return token.value;
122
- }
123
- consume(type) {
124
- const value = this.tryConsume(type);
125
- if (value !== undefined)
126
- return value;
127
- const { type: nextType, index } = this.peek();
128
- throw new TypeError(`Unexpected ${nextType} at ${index}, expected ${type}: ${DEBUG_URL}`);
129
- }
130
- text() {
131
- let result = "";
132
- let value;
133
- while (value = this.tryConsume("CHAR") || this.tryConsume("ESCAPED")) {
134
- result += value;
135
- }
136
- return result;
137
- }
138
- }
139
-
140
- class TokenData {
141
- constructor(tokens) {
142
- this.tokens = tokens;
143
- }
144
- }
145
- exports.TokenData = TokenData;
146
- function parse(str, options = {}) {
147
- const { encodePath = NOOP_VALUE } = options;
148
- const it = new Iter(lexer(str));
149
- function consume(endType) {
150
- const tokens2 = [];
119
+ tokens.push({ type: "end", index, value: "" });
120
+ function consumeUntil(endType) {
121
+ const output = [];
151
122
  while (true) {
152
- const path = it.text();
153
- if (path)
154
- tokens2.push({ type: "text", value: encodePath(path) });
155
- const param = it.tryConsume("PARAM");
156
- if (param) {
157
- tokens2.push({
158
- type: "param",
159
- name: param
123
+ const token = tokens[pos++];
124
+ if (token.type === endType)
125
+ break;
126
+ if (token.type === "char" || token.type === "escape") {
127
+ let path = token.value;
128
+ let cur = tokens[pos];
129
+ while (cur.type === "char" || cur.type === "escape") {
130
+ path += cur.value;
131
+ cur = tokens[++pos];
132
+ }
133
+ output.push({
134
+ type: "text",
135
+ value: encodePath(path)
160
136
  });
161
137
  continue;
162
138
  }
163
- const wildcard = it.tryConsume("WILDCARD");
164
- if (wildcard) {
165
- tokens2.push({
166
- type: "wildcard",
167
- name: wildcard
139
+ if (token.type === "param" || token.type === "wildcard") {
140
+ output.push({
141
+ type: token.type,
142
+ name: token.value
168
143
  });
169
144
  continue;
170
145
  }
171
- const open = it.tryConsume("{");
172
- if (open) {
173
- tokens2.push({
146
+ if (token.type === "{") {
147
+ output.push({
174
148
  type: "group",
175
- tokens: consume("}")
149
+ tokens: consumeUntil("}")
176
150
  });
177
151
  continue;
178
152
  }
179
- it.consume(endType);
180
- return tokens2;
153
+ throw new PathError(`Unexpected ${token.type} at index ${token.index}, expected ${endType}`, str);
181
154
  }
155
+ return output;
182
156
  }
183
- const tokens = consume("END");
184
- return new TokenData(tokens);
157
+ return new TokenData(consumeUntil("end"), str);
185
158
  }
186
159
  function compile(path, options = {}) {
187
160
  const { encode = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
188
- const data = path instanceof TokenData ? path : parse(path, options);
161
+ const data = typeof path === "object" ? path : parse(path, options);
189
162
  const fn = tokensToFunction(data.tokens, delimiter, encode);
190
- return function path(data2 = {}) {
191
- const [path2, ...missing] = fn(data2);
163
+ return function path(params = {}) {
164
+ const [path2, ...missing] = fn(params);
192
165
  if (missing.length) {
193
166
  throw new TypeError(`Missing parameters: ${missing.join(", ")}`);
194
167
  }
@@ -277,14 +250,12 @@ var require_dist = __commonJS((exports) => {
277
250
  function pathToRegexp(path, options = {}) {
278
251
  const { delimiter = DEFAULT_DELIMITER, end = true, sensitive = false, trailing = true } = options;
279
252
  const keys = [];
280
- const sources = [];
281
253
  const flags = sensitive ? "" : "i";
282
- const paths = Array.isArray(path) ? path : [path];
283
- const items = paths.map((path2) => path2 instanceof TokenData ? path2 : parse(path2, options));
284
- for (const { tokens } of items) {
285
- for (const seq of flatten(tokens, 0, [])) {
286
- const regexp2 = sequenceToRegExp(seq, delimiter, keys);
287
- sources.push(regexp2);
254
+ const sources = [];
255
+ for (const input of pathsToArray(path, [])) {
256
+ const data = typeof input === "object" ? input : parse(input, options);
257
+ for (const tokens of flatten(data.tokens, 0, [])) {
258
+ sources.push(toRegExpSource(tokens, delimiter, keys, data.originalPath));
288
259
  }
289
260
  }
290
261
  let pattern = `^(?:${sources.join("|")})`;
@@ -294,14 +265,22 @@ var require_dist = __commonJS((exports) => {
294
265
  const regexp = new RegExp(pattern, flags);
295
266
  return { regexp, keys };
296
267
  }
268
+ function pathsToArray(paths, init) {
269
+ if (Array.isArray(paths)) {
270
+ for (const p of paths)
271
+ pathsToArray(p, init);
272
+ } else {
273
+ init.push(paths);
274
+ }
275
+ return init;
276
+ }
297
277
  function* flatten(tokens, index, init) {
298
278
  if (index === tokens.length) {
299
279
  return yield init;
300
280
  }
301
281
  const token = tokens[index];
302
282
  if (token.type === "group") {
303
- const fork = init.slice();
304
- for (const seq of flatten(token.tokens, 0, fork)) {
283
+ for (const seq of flatten(token.tokens, 0, init.slice())) {
305
284
  yield* flatten(tokens, index + 1, seq);
306
285
  }
307
286
  } else {
@@ -309,12 +288,11 @@ var require_dist = __commonJS((exports) => {
309
288
  }
310
289
  yield* flatten(tokens, index + 1, init);
311
290
  }
312
- function sequenceToRegExp(tokens, delimiter, keys) {
291
+ function toRegExpSource(tokens, delimiter, keys, originalPath) {
313
292
  let result = "";
314
293
  let backtrack = "";
315
294
  let isSafeSegmentParam = true;
316
- for (let i = 0;i < tokens.length; i++) {
317
- const token = tokens[i];
295
+ for (const token of tokens) {
318
296
  if (token.type === "text") {
319
297
  result += escape(token.value);
320
298
  backtrack += token.value;
@@ -323,7 +301,7 @@ var require_dist = __commonJS((exports) => {
323
301
  }
324
302
  if (token.type === "param" || token.type === "wildcard") {
325
303
  if (!isSafeSegmentParam && !backtrack) {
326
- throw new TypeError(`Missing text after "${token.name}": ${DEBUG_URL}`);
304
+ throw new PathError(`Missing text before "${token.name}" ${token.type}`, originalPath);
327
305
  }
328
306
  if (token.type === "param") {
329
307
  result += `(${negate(delimiter, isSafeSegmentParam ? "" : backtrack)}+)`;
@@ -349,32 +327,46 @@ var require_dist = __commonJS((exports) => {
349
327
  }
350
328
  return `(?:(?!${escape(backtrack)}|${escape(delimiter)})[\\s\\S])`;
351
329
  }
352
- function stringify(data) {
353
- return data.tokens.map(function stringifyToken(token, index, tokens) {
354
- if (token.type === "text")
355
- return escapeText(token.value);
330
+ function stringifyTokens(tokens) {
331
+ let value = "";
332
+ let i = 0;
333
+ function name(value2) {
334
+ const isSafe = isNameSafe(value2) && isNextNameSafe(tokens[i]);
335
+ return isSafe ? value2 : JSON.stringify(value2);
336
+ }
337
+ while (i < tokens.length) {
338
+ const token = tokens[i++];
339
+ if (token.type === "text") {
340
+ value += escapeText(token.value);
341
+ continue;
342
+ }
356
343
  if (token.type === "group") {
357
- return `{${token.tokens.map(stringifyToken).join("")}}`;
344
+ value += `{${stringifyTokens(token.tokens)}}`;
345
+ continue;
346
+ }
347
+ if (token.type === "param") {
348
+ value += `:${name(token.name)}`;
349
+ continue;
358
350
  }
359
- const isSafe = isNameSafe(token.name) && isNextNameSafe(tokens[index + 1]);
360
- const key = isSafe ? token.name : JSON.stringify(token.name);
361
- if (token.type === "param")
362
- return `:${key}`;
363
- if (token.type === "wildcard")
364
- return `*${key}`;
365
- throw new TypeError(`Unexpected token: ${token}`);
366
- }).join("");
351
+ if (token.type === "wildcard") {
352
+ value += `*${name(token.name)}`;
353
+ continue;
354
+ }
355
+ throw new TypeError(`Unknown token type: ${token.type}`);
356
+ }
357
+ return value;
358
+ }
359
+ function stringify(data) {
360
+ return stringifyTokens(data.tokens);
367
361
  }
368
362
  function isNameSafe(name) {
369
363
  const [first, ...rest] = name;
370
- if (!ID_START.test(first))
371
- return false;
372
- return rest.every((char) => ID_CONTINUE.test(char));
364
+ return ID_START.test(first) && rest.every((char) => ID_CONTINUE.test(char));
373
365
  }
374
366
  function isNextNameSafe(token) {
375
- if ((token === null || token === undefined ? undefined : token.type) !== "text")
376
- return true;
377
- return !ID_CONTINUE.test(token.value[0]);
367
+ if (token && token.type === "text")
368
+ return !ID_CONTINUE.test(token.value[0]);
369
+ return true;
378
370
  }
379
371
  });
380
372
 
@@ -5834,7 +5826,7 @@ import express29 from "express";
5834
5826
  // package.json
5835
5827
  var package_default = {
5836
5828
  name: "@elizaos/server",
5837
- version: "1.4.2",
5829
+ version: "1.4.3-alpha.1",
5838
5830
  description: "ElizaOS Server - Core server infrastructure for ElizaOS agents",
5839
5831
  publishConfig: {
5840
5832
  access: "public",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elizaos/server",
3
- "version": "1.4.3-alpha.0",
3
+ "version": "1.4.3-alpha.2",
4
4
  "description": "ElizaOS Server - Core server infrastructure for ElizaOS agents",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -51,10 +51,10 @@
51
51
  "which": "^4.0.0",
52
52
  "ws": "^8.18.0"
53
53
  },
54
- "gitHead": "f2dd82949680a1e6fc61eb74683d2d95cf0173b6",
54
+ "gitHead": "fb236ff1b6b51541ea521489ac761e79fb51bf16",
55
55
  "dependencies": {
56
- "@elizaos/core": "1.4.3-alpha.0",
57
- "@elizaos/plugin-sql": "1.4.3-alpha.0",
56
+ "@elizaos/core": "1.4.3-alpha.2",
57
+ "@elizaos/plugin-sql": "1.4.3-alpha.2",
58
58
  "@types/express": "^5.0.2",
59
59
  "@types/helmet": "^4.0.0",
60
60
  "@types/multer": "^1.4.13",