@perkos/perkos-a2a 0.8.10 → 0.8.11

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.js CHANGED
@@ -14079,11 +14079,11 @@ var require_mime_types = __commonJS({
14079
14079
  }
14080
14080
  return exts[0];
14081
14081
  }
14082
- function lookup(path2) {
14083
- if (!path2 || typeof path2 !== "string") {
14082
+ function lookup(path) {
14083
+ if (!path || typeof path !== "string") {
14084
14084
  return false;
14085
14085
  }
14086
- var extension2 = extname("x." + path2).toLowerCase().substr(1);
14086
+ var extension2 = extname("x." + path).toLowerCase().substr(1);
14087
14087
  if (!extension2) {
14088
14088
  return false;
14089
14089
  }
@@ -17598,7 +17598,7 @@ var require_path_to_regexp = __commonJS({
17598
17598
  "node_modules/path-to-regexp/index.js"(exports, module) {
17599
17599
  module.exports = pathToRegexp;
17600
17600
  var MATCHING_GROUP_REGEXP = /\\.|\((?:\?<(.*?)>)?(?!\?)/g;
17601
- function pathToRegexp(path2, keys, options) {
17601
+ function pathToRegexp(path, keys, options) {
17602
17602
  options = options || {};
17603
17603
  keys = keys || [];
17604
17604
  var strict = options.strict;
@@ -17612,8 +17612,8 @@ var require_path_to_regexp = __commonJS({
17612
17612
  var pos = 0;
17613
17613
  var backtrack = "";
17614
17614
  var m;
17615
- if (path2 instanceof RegExp) {
17616
- while (m = MATCHING_GROUP_REGEXP.exec(path2.source)) {
17615
+ if (path instanceof RegExp) {
17616
+ while (m = MATCHING_GROUP_REGEXP.exec(path.source)) {
17617
17617
  if (m[0][0] === "\\") continue;
17618
17618
  keys.push({
17619
17619
  name: m[1] || name++,
@@ -17621,18 +17621,18 @@ var require_path_to_regexp = __commonJS({
17621
17621
  offset: m.index
17622
17622
  });
17623
17623
  }
17624
- return path2;
17624
+ return path;
17625
17625
  }
17626
- if (Array.isArray(path2)) {
17627
- path2 = path2.map(function(value) {
17626
+ if (Array.isArray(path)) {
17627
+ path = path.map(function(value) {
17628
17628
  return pathToRegexp(value, keys, options).source;
17629
17629
  });
17630
- return new RegExp(path2.join("|"), flags);
17630
+ return new RegExp(path.join("|"), flags);
17631
17631
  }
17632
- if (typeof path2 !== "string") {
17632
+ if (typeof path !== "string") {
17633
17633
  throw new TypeError("path must be a string, array of strings, or regular expression");
17634
17634
  }
17635
- path2 = path2.replace(
17635
+ path = path.replace(
17636
17636
  /\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g,
17637
17637
  function(match, slash, format, key, capture, star, optional, offset) {
17638
17638
  if (match[0] === "\\") {
@@ -17649,7 +17649,7 @@ var require_path_to_regexp = __commonJS({
17649
17649
  if (slash || format) {
17650
17650
  backtrack = "";
17651
17651
  } else {
17652
- backtrack += path2.slice(pos, offset);
17652
+ backtrack += path.slice(pos, offset);
17653
17653
  }
17654
17654
  pos = offset + match.length;
17655
17655
  if (match === "*") {
@@ -17677,7 +17677,7 @@ var require_path_to_regexp = __commonJS({
17677
17677
  return result;
17678
17678
  }
17679
17679
  );
17680
- while (m = MATCHING_GROUP_REGEXP.exec(path2)) {
17680
+ while (m = MATCHING_GROUP_REGEXP.exec(path)) {
17681
17681
  if (m[0][0] === "\\") continue;
17682
17682
  if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) {
17683
17683
  keys.splice(keysOffset + i, 0, {
@@ -17689,13 +17689,13 @@ var require_path_to_regexp = __commonJS({
17689
17689
  }
17690
17690
  i++;
17691
17691
  }
17692
- path2 += strict ? "" : path2[path2.length - 1] === "/" ? "?" : "/?";
17692
+ path += strict ? "" : path[path.length - 1] === "/" ? "?" : "/?";
17693
17693
  if (end) {
17694
- path2 += "$";
17695
- } else if (path2[path2.length - 1] !== "/") {
17696
- path2 += lookahead ? "(?=/|$)" : "(?:/|$)";
17694
+ path += "$";
17695
+ } else if (path[path.length - 1] !== "/") {
17696
+ path += lookahead ? "(?=/|$)" : "(?:/|$)";
17697
17697
  }
17698
- return new RegExp("^" + path2, flags);
17698
+ return new RegExp("^" + path, flags);
17699
17699
  }
17700
17700
  }
17701
17701
  });
@@ -17708,19 +17708,19 @@ var require_layer = __commonJS({
17708
17708
  var debug = require_src()("express:router:layer");
17709
17709
  var hasOwnProperty = Object.prototype.hasOwnProperty;
17710
17710
  module.exports = Layer;
17711
- function Layer(path2, options, fn) {
17711
+ function Layer(path, options, fn) {
17712
17712
  if (!(this instanceof Layer)) {
17713
- return new Layer(path2, options, fn);
17713
+ return new Layer(path, options, fn);
17714
17714
  }
17715
- debug("new %o", path2);
17715
+ debug("new %o", path);
17716
17716
  var opts = options || {};
17717
17717
  this.handle = fn;
17718
17718
  this.name = fn.name || "<anonymous>";
17719
17719
  this.params = void 0;
17720
17720
  this.path = void 0;
17721
- this.regexp = pathRegexp(path2, this.keys = [], opts);
17722
- this.regexp.fast_star = path2 === "*";
17723
- this.regexp.fast_slash = path2 === "/" && opts.end === false;
17721
+ this.regexp = pathRegexp(path, this.keys = [], opts);
17722
+ this.regexp.fast_star = path === "*";
17723
+ this.regexp.fast_slash = path === "/" && opts.end === false;
17724
17724
  }
17725
17725
  Layer.prototype.handle_error = function handle_error(error, req, res, next) {
17726
17726
  var fn = this.handle;
@@ -17744,20 +17744,20 @@ var require_layer = __commonJS({
17744
17744
  next(err);
17745
17745
  }
17746
17746
  };
17747
- Layer.prototype.match = function match(path2) {
17747
+ Layer.prototype.match = function match(path) {
17748
17748
  var match2;
17749
- if (path2 != null) {
17749
+ if (path != null) {
17750
17750
  if (this.regexp.fast_slash) {
17751
17751
  this.params = {};
17752
17752
  this.path = "";
17753
17753
  return true;
17754
17754
  }
17755
17755
  if (this.regexp.fast_star) {
17756
- this.params = { "0": decode_param(path2) };
17757
- this.path = path2;
17756
+ this.params = { "0": decode_param(path) };
17757
+ this.path = path;
17758
17758
  return true;
17759
17759
  }
17760
- match2 = this.regexp.exec(path2);
17760
+ match2 = this.regexp.exec(path);
17761
17761
  }
17762
17762
  if (!match2) {
17763
17763
  this.params = void 0;
@@ -17850,10 +17850,10 @@ var require_route = __commonJS({
17850
17850
  var slice = Array.prototype.slice;
17851
17851
  var toString = Object.prototype.toString;
17852
17852
  module.exports = Route;
17853
- function Route(path2) {
17854
- this.path = path2;
17853
+ function Route(path) {
17854
+ this.path = path;
17855
17855
  this.stack = [];
17856
- debug("new %o", path2);
17856
+ debug("new %o", path);
17857
17857
  this.methods = {};
17858
17858
  }
17859
17859
  Route.prototype._handles_method = function _handles_method(method) {
@@ -18065,8 +18065,8 @@ var require_router = __commonJS({
18065
18065
  if (++sync > 100) {
18066
18066
  return setImmediate(next, err);
18067
18067
  }
18068
- var path2 = getPathname(req);
18069
- if (path2 == null) {
18068
+ var path = getPathname(req);
18069
+ if (path == null) {
18070
18070
  return done(layerError);
18071
18071
  }
18072
18072
  var layer;
@@ -18074,7 +18074,7 @@ var require_router = __commonJS({
18074
18074
  var route;
18075
18075
  while (match !== true && idx < stack.length) {
18076
18076
  layer = stack[idx++];
18077
- match = matchLayer(layer, path2);
18077
+ match = matchLayer(layer, path);
18078
18078
  route = layer.route;
18079
18079
  if (typeof match !== "boolean") {
18080
18080
  layerError = layerError || match;
@@ -18112,18 +18112,18 @@ var require_router = __commonJS({
18112
18112
  } else if (route) {
18113
18113
  layer.handle_request(req, res, next);
18114
18114
  } else {
18115
- trim_prefix(layer, layerError, layerPath, path2);
18115
+ trim_prefix(layer, layerError, layerPath, path);
18116
18116
  }
18117
18117
  sync = 0;
18118
18118
  });
18119
18119
  }
18120
- function trim_prefix(layer, layerError, layerPath, path2) {
18120
+ function trim_prefix(layer, layerError, layerPath, path) {
18121
18121
  if (layerPath.length !== 0) {
18122
- if (layerPath !== path2.slice(0, layerPath.length)) {
18122
+ if (layerPath !== path.slice(0, layerPath.length)) {
18123
18123
  next(layerError);
18124
18124
  return;
18125
18125
  }
18126
- var c = path2[layerPath.length];
18126
+ var c = path[layerPath.length];
18127
18127
  if (c && c !== "/" && c !== ".") return next(layerError);
18128
18128
  debug("trim prefix (%s) from url %s", layerPath, req.url);
18129
18129
  removed = layerPath;
@@ -18201,7 +18201,7 @@ var require_router = __commonJS({
18201
18201
  };
18202
18202
  proto.use = function use(fn) {
18203
18203
  var offset = 0;
18204
- var path2 = "/";
18204
+ var path = "/";
18205
18205
  if (typeof fn !== "function") {
18206
18206
  var arg = fn;
18207
18207
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -18209,7 +18209,7 @@ var require_router = __commonJS({
18209
18209
  }
18210
18210
  if (typeof arg !== "function") {
18211
18211
  offset = 1;
18212
- path2 = fn;
18212
+ path = fn;
18213
18213
  }
18214
18214
  }
18215
18215
  var callbacks = flatten(slice.call(arguments, offset));
@@ -18221,8 +18221,8 @@ var require_router = __commonJS({
18221
18221
  if (typeof fn !== "function") {
18222
18222
  throw new TypeError("Router.use() requires a middleware function but got a " + gettype(fn));
18223
18223
  }
18224
- debug("use %o %s", path2, fn.name || "<anonymous>");
18225
- var layer = new Layer(path2, {
18224
+ debug("use %o %s", path, fn.name || "<anonymous>");
18225
+ var layer = new Layer(path, {
18226
18226
  sensitive: this.caseSensitive,
18227
18227
  strict: false,
18228
18228
  end: false
@@ -18232,9 +18232,9 @@ var require_router = __commonJS({
18232
18232
  }
18233
18233
  return this;
18234
18234
  };
18235
- proto.route = function route(path2) {
18236
- var route2 = new Route(path2);
18237
- var layer = new Layer(path2, {
18235
+ proto.route = function route(path) {
18236
+ var route2 = new Route(path);
18237
+ var layer = new Layer(path, {
18238
18238
  sensitive: this.caseSensitive,
18239
18239
  strict: this.strict,
18240
18240
  end: true
@@ -18244,8 +18244,8 @@ var require_router = __commonJS({
18244
18244
  return route2;
18245
18245
  };
18246
18246
  methods.concat("all").forEach(function(method) {
18247
- proto[method] = function(path2) {
18248
- var route = this.route(path2);
18247
+ proto[method] = function(path) {
18248
+ var route = this.route(path);
18249
18249
  route[method].apply(route, slice.call(arguments, 1));
18250
18250
  return this;
18251
18251
  };
@@ -18281,9 +18281,9 @@ var require_router = __commonJS({
18281
18281
  }
18282
18282
  return toString.call(obj).replace(objectRegExp, "$1");
18283
18283
  }
18284
- function matchLayer(layer, path2) {
18284
+ function matchLayer(layer, path) {
18285
18285
  try {
18286
- return layer.match(path2);
18286
+ return layer.match(path);
18287
18287
  } catch (err) {
18288
18288
  return err;
18289
18289
  }
@@ -18401,13 +18401,13 @@ var require_view = __commonJS({
18401
18401
  "node_modules/express/lib/view.js"(exports, module) {
18402
18402
  "use strict";
18403
18403
  var debug = require_src()("express:view");
18404
- var path2 = __require("path");
18404
+ var path = __require("path");
18405
18405
  var fs = __require("fs");
18406
- var dirname = path2.dirname;
18407
- var basename = path2.basename;
18408
- var extname = path2.extname;
18409
- var join = path2.join;
18410
- var resolve = path2.resolve;
18406
+ var dirname = path.dirname;
18407
+ var basename = path.basename;
18408
+ var extname = path.extname;
18409
+ var join = path.join;
18410
+ var resolve = path.resolve;
18411
18411
  module.exports = View;
18412
18412
  function View(name, options) {
18413
18413
  var opts = options || {};
@@ -18436,17 +18436,17 @@ var require_view = __commonJS({
18436
18436
  this.path = this.lookup(fileName);
18437
18437
  }
18438
18438
  View.prototype.lookup = function lookup(name) {
18439
- var path3;
18439
+ var path2;
18440
18440
  var roots = [].concat(this.root);
18441
18441
  debug('lookup "%s"', name);
18442
- for (var i = 0; i < roots.length && !path3; i++) {
18442
+ for (var i = 0; i < roots.length && !path2; i++) {
18443
18443
  var root = roots[i];
18444
18444
  var loc = resolve(root, name);
18445
18445
  var dir = dirname(loc);
18446
18446
  var file = basename(loc);
18447
- path3 = this.resolve(dir, file);
18447
+ path2 = this.resolve(dir, file);
18448
18448
  }
18449
- return path3;
18449
+ return path2;
18450
18450
  };
18451
18451
  View.prototype.render = function render(options, callback) {
18452
18452
  debug('render "%s"', this.path);
@@ -18454,21 +18454,21 @@ var require_view = __commonJS({
18454
18454
  };
18455
18455
  View.prototype.resolve = function resolve2(dir, file) {
18456
18456
  var ext = this.ext;
18457
- var path3 = join(dir, file);
18458
- var stat = tryStat(path3);
18457
+ var path2 = join(dir, file);
18458
+ var stat = tryStat(path2);
18459
18459
  if (stat && stat.isFile()) {
18460
- return path3;
18460
+ return path2;
18461
18461
  }
18462
- path3 = join(dir, basename(file, ext), "index" + ext);
18463
- stat = tryStat(path3);
18462
+ path2 = join(dir, basename(file, ext), "index" + ext);
18463
+ stat = tryStat(path2);
18464
18464
  if (stat && stat.isFile()) {
18465
- return path3;
18465
+ return path2;
18466
18466
  }
18467
18467
  };
18468
- function tryStat(path3) {
18469
- debug('stat "%s"', path3);
18468
+ function tryStat(path2) {
18469
+ debug('stat "%s"', path2);
18470
18470
  try {
18471
- return fs.statSync(path3);
18471
+ return fs.statSync(path2);
18472
18472
  } catch (e) {
18473
18473
  return void 0;
18474
18474
  }
@@ -18822,7 +18822,7 @@ var require_types = __commonJS({
18822
18822
  // node_modules/mime/mime.js
18823
18823
  var require_mime = __commonJS({
18824
18824
  "node_modules/mime/mime.js"(exports, module) {
18825
- var path2 = __require("path");
18825
+ var path = __require("path");
18826
18826
  var fs = __require("fs");
18827
18827
  function Mime() {
18828
18828
  this.types = /* @__PURE__ */ Object.create(null);
@@ -18852,8 +18852,8 @@ var require_mime = __commonJS({
18852
18852
  this.define(map);
18853
18853
  this._loading = null;
18854
18854
  };
18855
- Mime.prototype.lookup = function(path3, fallback) {
18856
- var ext = path3.replace(/^.*[\.\/\\]/, "").toLowerCase();
18855
+ Mime.prototype.lookup = function(path2, fallback) {
18856
+ var ext = path2.replace(/^.*[\.\/\\]/, "").toLowerCase();
18857
18857
  return this.types[ext] || fallback || this.default_type;
18858
18858
  };
18859
18859
  Mime.prototype.extension = function(mimeType) {
@@ -19087,28 +19087,28 @@ var require_send = __commonJS({
19087
19087
  var ms = require_ms2();
19088
19088
  var onFinished = require_on_finished();
19089
19089
  var parseRange = require_range_parser();
19090
- var path2 = __require("path");
19090
+ var path = __require("path");
19091
19091
  var statuses = require_statuses();
19092
19092
  var Stream = __require("stream");
19093
19093
  var util = __require("util");
19094
- var extname = path2.extname;
19095
- var join = path2.join;
19096
- var normalize = path2.normalize;
19097
- var resolve = path2.resolve;
19098
- var sep = path2.sep;
19094
+ var extname = path.extname;
19095
+ var join = path.join;
19096
+ var normalize = path.normalize;
19097
+ var resolve = path.resolve;
19098
+ var sep = path.sep;
19099
19099
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
19100
19100
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
19101
19101
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
19102
19102
  module.exports = send;
19103
19103
  module.exports.mime = mime;
19104
- function send(req, path3, options) {
19105
- return new SendStream(req, path3, options);
19104
+ function send(req, path2, options) {
19105
+ return new SendStream(req, path2, options);
19106
19106
  }
19107
- function SendStream(req, path3, options) {
19107
+ function SendStream(req, path2, options) {
19108
19108
  Stream.call(this);
19109
19109
  var opts = options || {};
19110
19110
  this.options = opts;
19111
- this.path = path3;
19111
+ this.path = path2;
19112
19112
  this.req = req;
19113
19113
  this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
19114
19114
  this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
@@ -19154,8 +19154,8 @@ var require_send = __commonJS({
19154
19154
  this._index = index2;
19155
19155
  return this;
19156
19156
  }, "send.index: pass index as option");
19157
- SendStream.prototype.root = function root(path3) {
19158
- this._root = resolve(String(path3));
19157
+ SendStream.prototype.root = function root(path2) {
19158
+ this._root = resolve(String(path2));
19159
19159
  debug("root %s", this._root);
19160
19160
  return this;
19161
19161
  };
@@ -19268,10 +19268,10 @@ var require_send = __commonJS({
19268
19268
  var lastModified = this.res.getHeader("Last-Modified");
19269
19269
  return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
19270
19270
  };
19271
- SendStream.prototype.redirect = function redirect(path3) {
19271
+ SendStream.prototype.redirect = function redirect(path2) {
19272
19272
  var res = this.res;
19273
19273
  if (hasListeners(this, "directory")) {
19274
- this.emit("directory", res, path3);
19274
+ this.emit("directory", res, path2);
19275
19275
  return;
19276
19276
  }
19277
19277
  if (this.hasTrailingSlash()) {
@@ -19291,42 +19291,42 @@ var require_send = __commonJS({
19291
19291
  SendStream.prototype.pipe = function pipe(res) {
19292
19292
  var root = this._root;
19293
19293
  this.res = res;
19294
- var path3 = decode(this.path);
19295
- if (path3 === -1) {
19294
+ var path2 = decode(this.path);
19295
+ if (path2 === -1) {
19296
19296
  this.error(400);
19297
19297
  return res;
19298
19298
  }
19299
- if (~path3.indexOf("\0")) {
19299
+ if (~path2.indexOf("\0")) {
19300
19300
  this.error(400);
19301
19301
  return res;
19302
19302
  }
19303
19303
  var parts;
19304
19304
  if (root !== null) {
19305
- if (path3) {
19306
- path3 = normalize("." + sep + path3);
19305
+ if (path2) {
19306
+ path2 = normalize("." + sep + path2);
19307
19307
  }
19308
- if (UP_PATH_REGEXP.test(path3)) {
19309
- debug('malicious path "%s"', path3);
19308
+ if (UP_PATH_REGEXP.test(path2)) {
19309
+ debug('malicious path "%s"', path2);
19310
19310
  this.error(403);
19311
19311
  return res;
19312
19312
  }
19313
- parts = path3.split(sep);
19314
- path3 = normalize(join(root, path3));
19313
+ parts = path2.split(sep);
19314
+ path2 = normalize(join(root, path2));
19315
19315
  } else {
19316
- if (UP_PATH_REGEXP.test(path3)) {
19317
- debug('malicious path "%s"', path3);
19316
+ if (UP_PATH_REGEXP.test(path2)) {
19317
+ debug('malicious path "%s"', path2);
19318
19318
  this.error(403);
19319
19319
  return res;
19320
19320
  }
19321
- parts = normalize(path3).split(sep);
19322
- path3 = resolve(path3);
19321
+ parts = normalize(path2).split(sep);
19322
+ path2 = resolve(path2);
19323
19323
  }
19324
19324
  if (containsDotFile(parts)) {
19325
19325
  var access = this._dotfiles;
19326
19326
  if (access === void 0) {
19327
19327
  access = parts[parts.length - 1][0] === "." ? this._hidden ? "allow" : "ignore" : "allow";
19328
19328
  }
19329
- debug('%s dotfile "%s"', access, path3);
19329
+ debug('%s dotfile "%s"', access, path2);
19330
19330
  switch (access) {
19331
19331
  case "allow":
19332
19332
  break;
@@ -19340,13 +19340,13 @@ var require_send = __commonJS({
19340
19340
  }
19341
19341
  }
19342
19342
  if (this._index.length && this.hasTrailingSlash()) {
19343
- this.sendIndex(path3);
19343
+ this.sendIndex(path2);
19344
19344
  return res;
19345
19345
  }
19346
- this.sendFile(path3);
19346
+ this.sendFile(path2);
19347
19347
  return res;
19348
19348
  };
19349
- SendStream.prototype.send = function send2(path3, stat) {
19349
+ SendStream.prototype.send = function send2(path2, stat) {
19350
19350
  var len = stat.size;
19351
19351
  var options = this.options;
19352
19352
  var opts = {};
@@ -19358,9 +19358,9 @@ var require_send = __commonJS({
19358
19358
  this.headersAlreadySent();
19359
19359
  return;
19360
19360
  }
19361
- debug('pipe "%s"', path3);
19362
- this.setHeader(path3, stat);
19363
- this.type(path3);
19361
+ debug('pipe "%s"', path2);
19362
+ this.setHeader(path2, stat);
19363
+ this.type(path2);
19364
19364
  if (this.isConditionalGET()) {
19365
19365
  if (this.isPreconditionFailure()) {
19366
19366
  this.error(412);
@@ -19409,26 +19409,26 @@ var require_send = __commonJS({
19409
19409
  res.end();
19410
19410
  return;
19411
19411
  }
19412
- this.stream(path3, opts);
19412
+ this.stream(path2, opts);
19413
19413
  };
19414
- SendStream.prototype.sendFile = function sendFile(path3) {
19414
+ SendStream.prototype.sendFile = function sendFile(path2) {
19415
19415
  var i = 0;
19416
19416
  var self = this;
19417
- debug('stat "%s"', path3);
19418
- fs.stat(path3, function onstat(err, stat) {
19419
- if (err && err.code === "ENOENT" && !extname(path3) && path3[path3.length - 1] !== sep) {
19417
+ debug('stat "%s"', path2);
19418
+ fs.stat(path2, function onstat(err, stat) {
19419
+ if (err && err.code === "ENOENT" && !extname(path2) && path2[path2.length - 1] !== sep) {
19420
19420
  return next(err);
19421
19421
  }
19422
19422
  if (err) return self.onStatError(err);
19423
- if (stat.isDirectory()) return self.redirect(path3);
19424
- self.emit("file", path3, stat);
19425
- self.send(path3, stat);
19423
+ if (stat.isDirectory()) return self.redirect(path2);
19424
+ self.emit("file", path2, stat);
19425
+ self.send(path2, stat);
19426
19426
  });
19427
19427
  function next(err) {
19428
19428
  if (self._extensions.length <= i) {
19429
19429
  return err ? self.onStatError(err) : self.error(404);
19430
19430
  }
19431
- var p = path3 + "." + self._extensions[i++];
19431
+ var p = path2 + "." + self._extensions[i++];
19432
19432
  debug('stat "%s"', p);
19433
19433
  fs.stat(p, function(err2, stat) {
19434
19434
  if (err2) return next(err2);
@@ -19438,7 +19438,7 @@ var require_send = __commonJS({
19438
19438
  });
19439
19439
  }
19440
19440
  };
19441
- SendStream.prototype.sendIndex = function sendIndex(path3) {
19441
+ SendStream.prototype.sendIndex = function sendIndex(path2) {
19442
19442
  var i = -1;
19443
19443
  var self = this;
19444
19444
  function next(err) {
@@ -19446,7 +19446,7 @@ var require_send = __commonJS({
19446
19446
  if (err) return self.onStatError(err);
19447
19447
  return self.error(404);
19448
19448
  }
19449
- var p = join(path3, self._index[i]);
19449
+ var p = join(path2, self._index[i]);
19450
19450
  debug('stat "%s"', p);
19451
19451
  fs.stat(p, function(err2, stat) {
19452
19452
  if (err2) return next(err2);
@@ -19457,10 +19457,10 @@ var require_send = __commonJS({
19457
19457
  }
19458
19458
  next();
19459
19459
  };
19460
- SendStream.prototype.stream = function stream(path3, options) {
19460
+ SendStream.prototype.stream = function stream(path2, options) {
19461
19461
  var self = this;
19462
19462
  var res = this.res;
19463
- var stream2 = fs.createReadStream(path3, options);
19463
+ var stream2 = fs.createReadStream(path2, options);
19464
19464
  this.emit("stream", stream2);
19465
19465
  stream2.pipe(res);
19466
19466
  function cleanup() {
@@ -19475,10 +19475,10 @@ var require_send = __commonJS({
19475
19475
  self.emit("end");
19476
19476
  });
19477
19477
  };
19478
- SendStream.prototype.type = function type(path3) {
19478
+ SendStream.prototype.type = function type(path2) {
19479
19479
  var res = this.res;
19480
19480
  if (res.getHeader("Content-Type")) return;
19481
- var type2 = mime.lookup(path3);
19481
+ var type2 = mime.lookup(path2);
19482
19482
  if (!type2) {
19483
19483
  debug("no content-type");
19484
19484
  return;
@@ -19487,9 +19487,9 @@ var require_send = __commonJS({
19487
19487
  debug("content-type %s", type2);
19488
19488
  res.setHeader("Content-Type", type2 + (charset ? "; charset=" + charset : ""));
19489
19489
  };
19490
- SendStream.prototype.setHeader = function setHeader(path3, stat) {
19490
+ SendStream.prototype.setHeader = function setHeader(path2, stat) {
19491
19491
  var res = this.res;
19492
- this.emit("headers", res, path3, stat);
19492
+ this.emit("headers", res, path2, stat);
19493
19493
  if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
19494
19494
  debug("accept ranges");
19495
19495
  res.setHeader("Accept-Ranges", "bytes");
@@ -19548,9 +19548,9 @@ var require_send = __commonJS({
19548
19548
  }
19549
19549
  return err instanceof Error ? createError(status, err, { expose: false }) : createError(status, err);
19550
19550
  }
19551
- function decode(path3) {
19551
+ function decode(path2) {
19552
19552
  try {
19553
- return decodeURIComponent(path3);
19553
+ return decodeURIComponent(path2);
19554
19554
  } catch (err) {
19555
19555
  return -1;
19556
19556
  }
@@ -20459,10 +20459,10 @@ var require_utils2 = __commonJS({
20459
20459
  var querystring = __require("querystring");
20460
20460
  exports.etag = createETagGenerator({ weak: false });
20461
20461
  exports.wetag = createETagGenerator({ weak: true });
20462
- exports.isAbsolute = function(path2) {
20463
- if ("/" === path2[0]) return true;
20464
- if (":" === path2[1] && ("\\" === path2[2] || "/" === path2[2])) return true;
20465
- if ("\\\\" === path2.substring(0, 2)) return true;
20462
+ exports.isAbsolute = function(path) {
20463
+ if ("/" === path[0]) return true;
20464
+ if (":" === path[1] && ("\\" === path[2] || "/" === path[2])) return true;
20465
+ if ("\\\\" === path.substring(0, 2)) return true;
20466
20466
  };
20467
20467
  exports.flatten = deprecate.function(
20468
20468
  flatten,
@@ -20673,7 +20673,7 @@ var require_application = __commonJS({
20673
20673
  };
20674
20674
  app.use = function use(fn) {
20675
20675
  var offset = 0;
20676
- var path2 = "/";
20676
+ var path = "/";
20677
20677
  if (typeof fn !== "function") {
20678
20678
  var arg = fn;
20679
20679
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -20681,7 +20681,7 @@ var require_application = __commonJS({
20681
20681
  }
20682
20682
  if (typeof arg !== "function") {
20683
20683
  offset = 1;
20684
- path2 = fn;
20684
+ path = fn;
20685
20685
  }
20686
20686
  }
20687
20687
  var fns = flatten(slice.call(arguments, offset));
@@ -20692,12 +20692,12 @@ var require_application = __commonJS({
20692
20692
  var router = this._router;
20693
20693
  fns.forEach(function(fn2) {
20694
20694
  if (!fn2 || !fn2.handle || !fn2.set) {
20695
- return router.use(path2, fn2);
20695
+ return router.use(path, fn2);
20696
20696
  }
20697
- debug(".use app under %s", path2);
20698
- fn2.mountpath = path2;
20697
+ debug(".use app under %s", path);
20698
+ fn2.mountpath = path;
20699
20699
  fn2.parent = this;
20700
- router.use(path2, function mounted_app(req, res, next) {
20700
+ router.use(path, function mounted_app(req, res, next) {
20701
20701
  var orig = req.app;
20702
20702
  fn2.handle(req, res, function(err) {
20703
20703
  setPrototypeOf(req, orig.request);
@@ -20709,9 +20709,9 @@ var require_application = __commonJS({
20709
20709
  }, this);
20710
20710
  return this;
20711
20711
  };
20712
- app.route = function route(path2) {
20712
+ app.route = function route(path) {
20713
20713
  this.lazyrouter();
20714
- return this._router.route(path2);
20714
+ return this._router.route(path);
20715
20715
  };
20716
20716
  app.engine = function engine(ext, fn) {
20717
20717
  if (typeof fn !== "function") {
@@ -20762,7 +20762,7 @@ var require_application = __commonJS({
20762
20762
  }
20763
20763
  return this;
20764
20764
  };
20765
- app.path = function path2() {
20765
+ app.path = function path() {
20766
20766
  return this.parent ? this.parent.path() + this.mountpath : "";
20767
20767
  };
20768
20768
  app.enabled = function enabled(setting) {
@@ -20778,19 +20778,19 @@ var require_application = __commonJS({
20778
20778
  return this.set(setting, false);
20779
20779
  };
20780
20780
  methods.forEach(function(method) {
20781
- app[method] = function(path2) {
20781
+ app[method] = function(path) {
20782
20782
  if (method === "get" && arguments.length === 1) {
20783
- return this.set(path2);
20783
+ return this.set(path);
20784
20784
  }
20785
20785
  this.lazyrouter();
20786
- var route = this._router.route(path2);
20786
+ var route = this._router.route(path);
20787
20787
  route[method].apply(route, slice.call(arguments, 1));
20788
20788
  return this;
20789
20789
  };
20790
20790
  });
20791
- app.all = function all(path2) {
20791
+ app.all = function all(path) {
20792
20792
  this.lazyrouter();
20793
- var route = this._router.route(path2);
20793
+ var route = this._router.route(path);
20794
20794
  var args = slice.call(arguments, 1);
20795
20795
  for (var i = 0; i < methods.length; i++) {
20796
20796
  route[methods[i]].apply(route, args);
@@ -21549,7 +21549,7 @@ var require_request = __commonJS({
21549
21549
  var subdomains2 = !isIP(hostname) ? hostname.split(".").reverse() : [hostname];
21550
21550
  return subdomains2.slice(offset);
21551
21551
  });
21552
- defineGetter(req, "path", function path2() {
21552
+ defineGetter(req, "path", function path() {
21553
21553
  return parse(this).pathname;
21554
21554
  });
21555
21555
  defineGetter(req, "hostname", function hostname() {
@@ -21871,7 +21871,7 @@ var require_response = __commonJS({
21871
21871
  var http = __require("http");
21872
21872
  var isAbsolute = require_utils2().isAbsolute;
21873
21873
  var onFinished = require_on_finished();
21874
- var path2 = __require("path");
21874
+ var path = __require("path");
21875
21875
  var statuses = require_statuses();
21876
21876
  var merge = require_utils_merge();
21877
21877
  var sign = require_cookie_signature().sign;
@@ -21880,9 +21880,9 @@ var require_response = __commonJS({
21880
21880
  var setCharset = require_utils2().setCharset;
21881
21881
  var cookie = require_cookie();
21882
21882
  var send = require_send();
21883
- var extname = path2.extname;
21883
+ var extname = path.extname;
21884
21884
  var mime = send.mime;
21885
- var resolve = path2.resolve;
21885
+ var resolve = path.resolve;
21886
21886
  var vary = require_vary();
21887
21887
  var res = Object.create(http.ServerResponse.prototype);
21888
21888
  module.exports = res;
@@ -22059,26 +22059,26 @@ var require_response = __commonJS({
22059
22059
  this.type("txt");
22060
22060
  return this.send(body);
22061
22061
  };
22062
- res.sendFile = function sendFile(path3, options, callback) {
22062
+ res.sendFile = function sendFile(path2, options, callback) {
22063
22063
  var done = callback;
22064
22064
  var req = this.req;
22065
22065
  var res2 = this;
22066
22066
  var next = req.next;
22067
22067
  var opts = options || {};
22068
- if (!path3) {
22068
+ if (!path2) {
22069
22069
  throw new TypeError("path argument is required to res.sendFile");
22070
22070
  }
22071
- if (typeof path3 !== "string") {
22071
+ if (typeof path2 !== "string") {
22072
22072
  throw new TypeError("path must be a string to res.sendFile");
22073
22073
  }
22074
22074
  if (typeof options === "function") {
22075
22075
  done = options;
22076
22076
  opts = {};
22077
22077
  }
22078
- if (!opts.root && !isAbsolute(path3)) {
22078
+ if (!opts.root && !isAbsolute(path2)) {
22079
22079
  throw new TypeError("path must be absolute or specify root to res.sendFile");
22080
22080
  }
22081
- var pathname = encodeURI(path3);
22081
+ var pathname = encodeURI(path2);
22082
22082
  var file = send(req, pathname, opts);
22083
22083
  sendfile(res2, file, opts, function(err) {
22084
22084
  if (done) return done(err);
@@ -22088,7 +22088,7 @@ var require_response = __commonJS({
22088
22088
  }
22089
22089
  });
22090
22090
  };
22091
- res.sendfile = function(path3, options, callback) {
22091
+ res.sendfile = function(path2, options, callback) {
22092
22092
  var done = callback;
22093
22093
  var req = this.req;
22094
22094
  var res2 = this;
@@ -22098,7 +22098,7 @@ var require_response = __commonJS({
22098
22098
  done = options;
22099
22099
  opts = {};
22100
22100
  }
22101
- var file = send(req, path3, opts);
22101
+ var file = send(req, path2, opts);
22102
22102
  sendfile(res2, file, opts, function(err) {
22103
22103
  if (done) return done(err);
22104
22104
  if (err && err.code === "EISDIR") return next();
@@ -22111,7 +22111,7 @@ var require_response = __commonJS({
22111
22111
  res.sendfile,
22112
22112
  "res.sendfile: Use res.sendFile instead"
22113
22113
  );
22114
- res.download = function download(path3, filename, options, callback) {
22114
+ res.download = function download(path2, filename, options, callback) {
22115
22115
  var done = callback;
22116
22116
  var name = filename;
22117
22117
  var opts = options || null;
@@ -22128,7 +22128,7 @@ var require_response = __commonJS({
22128
22128
  opts = filename;
22129
22129
  }
22130
22130
  var headers = {
22131
- "Content-Disposition": contentDisposition(name || path3)
22131
+ "Content-Disposition": contentDisposition(name || path2)
22132
22132
  };
22133
22133
  if (opts && opts.headers) {
22134
22134
  var keys = Object.keys(opts.headers);
@@ -22141,7 +22141,7 @@ var require_response = __commonJS({
22141
22141
  }
22142
22142
  opts = Object.create(opts);
22143
22143
  opts.headers = headers;
22144
- var fullPath = !opts.root ? resolve(path3) : path3;
22144
+ var fullPath = !opts.root ? resolve(path2) : path2;
22145
22145
  return this.sendFile(fullPath, opts, done);
22146
22146
  };
22147
22147
  res.contentType = res.type = function contentType(type) {
@@ -22442,11 +22442,11 @@ var require_serve_static = __commonJS({
22442
22442
  }
22443
22443
  var forwardError = !fallthrough;
22444
22444
  var originalUrl = parseUrl.original(req);
22445
- var path2 = parseUrl(req).pathname;
22446
- if (path2 === "/" && originalUrl.pathname.substr(-1) !== "/") {
22447
- path2 = "";
22445
+ var path = parseUrl(req).pathname;
22446
+ if (path === "/" && originalUrl.pathname.substr(-1) !== "/") {
22447
+ path = "";
22448
22448
  }
22449
- var stream = send(req, path2, opts);
22449
+ var stream = send(req, path, opts);
22450
22450
  stream.on("directory", onDirectory);
22451
22451
  if (setHeaders) {
22452
22452
  stream.on("headers", setHeaders);
@@ -26736,6 +26736,9 @@ var A2AServer = class {
26736
26736
  setTaskFailureHandler(handler) {
26737
26737
  this.taskFailureHandler = handler;
26738
26738
  }
26739
+ getTasks() {
26740
+ return this.tasks.values();
26741
+ }
26739
26742
  isClientOnly() {
26740
26743
  return this.clientOnly;
26741
26744
  }
@@ -26830,7 +26833,8 @@ var A2AServer = class {
26830
26833
  artifacts: [],
26831
26834
  metadata: {
26832
26835
  fromAgent: message?.metadata?.fromAgent || "unknown"
26833
- }
26836
+ },
26837
+ sessionKeyHint: "agent:main"
26834
26838
  };
26835
26839
  this.tasks.set(taskId, task);
26836
26840
  this.logger.info(
@@ -27154,7 +27158,6 @@ var A2AServer = class {
27154
27158
 
27155
27159
  // src/index.ts
27156
27160
  import { randomUUID as randomUUID4 } from "crypto";
27157
- import path from "path";
27158
27161
  function wakeGatewayAgent(requestHeartbeatNow, reason, logger, sessionKey = "agent:main") {
27159
27162
  if (typeof requestHeartbeatNow === "function") {
27160
27163
  try {
@@ -27191,127 +27194,42 @@ function register(api) {
27191
27194
  logger.info("[perkos-a2a] runtime.system.requestHeartbeatNow unavailable \u2014 wake will rely on next agent turn");
27192
27195
  }
27193
27196
  server.setTaskResultHandler(async (task, text) => {
27197
+ const from = task.metadata?.fromAgent || "unknown";
27198
+ const marker = `[A2A_RESULT:${task.id}]`;
27199
+ const eventText = [
27200
+ marker,
27201
+ `From: ${from}`,
27202
+ `Task ID: ${task.id}`,
27203
+ `Context ID: ${task.contextId}`,
27204
+ "",
27205
+ "Execute the following request and include the final answer in your assistant reply.",
27206
+ `Your final answer must begin with exactly: ${marker}`,
27207
+ "Return the useful final answer after that marker.",
27208
+ "",
27209
+ text
27210
+ ].join("\n");
27211
+ task.status = {
27212
+ state: "working",
27213
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
27214
+ message: {
27215
+ role: "agent",
27216
+ parts: [{ kind: "text", text: "Task dispatched to supported system-event execution path." }]
27217
+ }
27218
+ };
27194
27219
  task.artifacts.push({
27195
27220
  kind: "artifact",
27196
27221
  artifactId: randomUUID4(),
27197
- parts: [{ kind: "text", text: "debug: entered task result handler" }]
27222
+ parts: [{ kind: "text", text: `debug: enqueued system event for ${marker}` }]
27198
27223
  });
27199
- try {
27200
- const cfg = await api.runtime?.config?.loadConfig?.();
27201
- task.artifacts.push({
27202
- kind: "artifact",
27203
- artifactId: randomUUID4(),
27204
- parts: [{ kind: "text", text: `debug: config loaded=${!!cfg}` }]
27205
- });
27206
- if (!api.runtime?.agent?.runEmbeddedAgent || !cfg) {
27207
- task.artifacts.push({
27208
- kind: "artifact",
27209
- artifactId: randomUUID4(),
27210
- parts: [{ kind: "text", text: "debug: embedded agent runtime unavailable" }]
27211
- });
27212
- task.status = {
27213
- state: "completed",
27214
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
27215
- message: {
27216
- role: "agent",
27217
- parts: [{ kind: "text", text: "Embedded agent runtime unavailable." }]
27218
- }
27219
- };
27220
- return;
27221
- }
27222
- const agentDir = api.runtime.agent.resolveAgentDir(cfg);
27223
- const workspaceDir = api.runtime.agent.resolveAgentWorkspaceDir(cfg);
27224
- await api.runtime.agent.ensureAgentWorkspace(cfg);
27225
- task.artifacts.push({
27226
- kind: "artifact",
27227
- artifactId: randomUUID4(),
27228
- parts: [{ kind: "text", text: "debug: agent workspace ensured" }]
27229
- });
27230
- const sessionId = `perkos-a2a:task:${task.id}`;
27231
- const prompt = [
27232
- `You are handling an incoming A2A task from agent ${task.metadata?.fromAgent || "unknown"}.`,
27233
- `Task ID: ${task.id}`,
27234
- `Context ID: ${task.contextId}`,
27235
- "",
27236
- "Execute the request below and return the actual final answer for the peer agent.",
27237
- "Do not describe internal steps unless the task explicitly asks for them.",
27238
- "Return only the useful final response.",
27239
- "",
27240
- text
27241
- ].join("\n");
27242
- task.artifacts.push({
27243
- kind: "artifact",
27244
- artifactId: randomUUID4(),
27245
- parts: [{ kind: "text", text: "debug: starting embedded run" }]
27246
- });
27247
- const result = await api.runtime.agent.runEmbeddedAgent({
27248
- sessionId,
27249
- runId: randomUUID4(),
27250
- sessionFile: path.join(agentDir, "sessions", `perkos-a2a-task-${task.id}.jsonl`),
27251
- workspaceDir,
27252
- prompt,
27253
- timeoutMs: api.runtime.agent.resolveAgentTimeoutMs(cfg)
27254
- });
27255
- const payloadText = result?.payloads?.map((p) => p?.text).filter(Boolean).join("\n\n") || "";
27256
- const finalText = (result?.meta?.finalAssistantVisibleText || payloadText || "").trim();
27257
- task.artifacts.push({
27258
- kind: "artifact",
27259
- artifactId: randomUUID4(),
27260
- parts: [{
27261
- kind: "text",
27262
- text: JSON.stringify({
27263
- debug: "embedded-run-result",
27264
- stopReason: result?.meta?.stopReason || null,
27265
- finalAssistantVisibleText: result?.meta?.finalAssistantVisibleText || null,
27266
- payloadText: payloadText || null,
27267
- didSendViaMessagingTool: result?.didSendViaMessagingTool || false,
27268
- payloadCount: Array.isArray(result?.payloads) ? result.payloads.length : 0
27269
- }, null, 2)
27270
- }]
27271
- });
27272
- if (finalText) {
27273
- task.artifacts.push({
27274
- kind: "artifact",
27275
- artifactId: randomUUID4(),
27276
- parts: [{ kind: "text", text: finalText }]
27277
- });
27278
- task.status = {
27279
- state: "completed",
27280
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
27281
- message: {
27282
- role: "agent",
27283
- parts: [{ kind: "text", text: finalText }]
27284
- }
27285
- };
27286
- logger.info(`[perkos-a2a] Task ${task.id} final result captured from embedded agent`);
27287
- } else {
27288
- task.status = {
27289
- state: "completed",
27290
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
27291
- message: {
27292
- role: "agent",
27293
- parts: [{ kind: "text", text: "Task executed but no final visible text was captured." }]
27294
- }
27295
- };
27296
- logger.info(`[perkos-a2a] Task ${task.id} executed, but no final visible text was captured`);
27297
- }
27298
- } catch (err) {
27299
- const msg = err instanceof Error ? err.stack || err.message : String(err);
27300
- task.artifacts.push({
27301
- kind: "artifact",
27302
- artifactId: randomUUID4(),
27303
- parts: [{ kind: "text", text: `debug: result handler threw: ${msg}` }]
27304
- });
27305
- task.status = {
27306
- state: "failed",
27307
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
27308
- message: {
27309
- role: "agent",
27310
- parts: [{ kind: "text", text: msg }]
27311
- }
27312
- };
27313
- throw err;
27224
+ if (enqueueSystemEvent) {
27225
+ enqueueSystemEvent(eventText, { sessionKey: "agent:main:main" });
27314
27226
  }
27227
+ wakeGatewayAgent(
27228
+ requestHeartbeatNow,
27229
+ `[A2A] Process queued task ${task.id}`,
27230
+ logger,
27231
+ "agent:main"
27232
+ );
27315
27233
  });
27316
27234
  server.setTaskFailureHandler(async (task, errorText) => {
27317
27235
  task.status = {
@@ -27356,7 +27274,7 @@ function register(api) {
27356
27274
  const tasks = pendingTasks.splice(0, pendingTasks.length);
27357
27275
  const lines = [
27358
27276
  `[A2A OBSERVABILITY] ${tasks.length} inbound task(s) were received by perkos-a2a.`,
27359
- "These notes are for visibility only. The actual task execution happens in dedicated embedded runs.",
27277
+ "These notes are for visibility only. The actual task execution uses supported system-event processing.",
27360
27278
  ""
27361
27279
  ];
27362
27280
  for (const t of tasks) {
@@ -27367,6 +27285,31 @@ function register(api) {
27367
27285
  logger.info(`[perkos-a2a] Injecting ${tasks.length} observability note(s) into agent context via before_agent_start`);
27368
27286
  return { prependContext: lines.join("\n") };
27369
27287
  });
27288
+ api.runtime?.events?.onSessionTranscriptUpdate?.((update) => {
27289
+ const message = update?.message;
27290
+ const text = Array.isArray(message?.parts) ? message.parts.filter((p) => p?.kind === "text" && typeof p?.text === "string").map((p) => p.text).join("\n") : typeof message?.text === "string" ? message.text : "";
27291
+ if (!text) return;
27292
+ for (const task of server.getTasks()) {
27293
+ const marker = `[A2A_RESULT:${task.id}]`;
27294
+ if (!text.includes(marker)) continue;
27295
+ const finalText = text.slice(text.indexOf(marker) + marker.length).trim();
27296
+ if (!finalText) continue;
27297
+ task.artifacts.push({
27298
+ kind: "artifact",
27299
+ artifactId: randomUUID4(),
27300
+ parts: [{ kind: "text", text: finalText }]
27301
+ });
27302
+ task.status = {
27303
+ state: "completed",
27304
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
27305
+ message: {
27306
+ role: "agent",
27307
+ parts: [{ kind: "text", text: finalText }]
27308
+ }
27309
+ };
27310
+ logger.info(`[perkos-a2a] Task ${task.id} completed from transcript update`);
27311
+ }
27312
+ });
27370
27313
  api.registerService({
27371
27314
  id: "perkos-a2a",
27372
27315
  start: () => {