@posthog/agent 2.0.2 → 2.0.3
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/{agent-DBQY1BfC.d.ts → agent-kRbaLUfe.d.ts} +3 -0
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +60 -3
- package/dist/agent.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +72 -3
- package/dist/index.js.map +1 -1
- package/dist/server/agent-server.js +60 -3
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/{bin.js → bin.cjs} +283 -242
- package/dist/server/bin.cjs.map +1 -0
- package/package.json +4 -4
- package/src/sagas/resume-saga.test.ts +144 -0
- package/src/sagas/resume-saga.ts +23 -0
- package/src/sagas/test-fixtures.ts +9 -0
- package/src/session-log-writer.ts +81 -1
- package/dist/server/bin.d.ts +0 -1
- package/dist/server/bin.js.map +0 -1
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var
|
|
9
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
-
}) : x)(function(x) {
|
|
11
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
-
});
|
|
14
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
15
10
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
11
|
};
|
|
17
12
|
var __copyProps = (to, from, except, desc) => {
|
|
@@ -33,7 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
33
28
|
|
|
34
29
|
// ../../node_modules/ms/index.js
|
|
35
30
|
var require_ms = __commonJS({
|
|
36
|
-
"../../node_modules/ms/index.js"(
|
|
31
|
+
"../../node_modules/ms/index.js"(exports2, module2) {
|
|
37
32
|
"use strict";
|
|
38
33
|
var s = 1e3;
|
|
39
34
|
var m = s * 60;
|
|
@@ -41,7 +36,7 @@ var require_ms = __commonJS({
|
|
|
41
36
|
var d = h * 24;
|
|
42
37
|
var w = d * 7;
|
|
43
38
|
var y = d * 365.25;
|
|
44
|
-
|
|
39
|
+
module2.exports = function(val, options) {
|
|
45
40
|
options = options || {};
|
|
46
41
|
var type = typeof val;
|
|
47
42
|
if (type === "string" && val.length > 0) {
|
|
@@ -150,7 +145,7 @@ var require_ms = __commonJS({
|
|
|
150
145
|
|
|
151
146
|
// ../../node_modules/debug/src/common.js
|
|
152
147
|
var require_common = __commonJS({
|
|
153
|
-
"../../node_modules/debug/src/common.js"(
|
|
148
|
+
"../../node_modules/debug/src/common.js"(exports2, module2) {
|
|
154
149
|
"use strict";
|
|
155
150
|
function setup(env) {
|
|
156
151
|
createDebug.debug = createDebug;
|
|
@@ -322,20 +317,20 @@ var require_common = __commonJS({
|
|
|
322
317
|
createDebug.enable(createDebug.load());
|
|
323
318
|
return createDebug;
|
|
324
319
|
}
|
|
325
|
-
|
|
320
|
+
module2.exports = setup;
|
|
326
321
|
}
|
|
327
322
|
});
|
|
328
323
|
|
|
329
324
|
// ../../node_modules/debug/src/browser.js
|
|
330
325
|
var require_browser = __commonJS({
|
|
331
|
-
"../../node_modules/debug/src/browser.js"(
|
|
326
|
+
"../../node_modules/debug/src/browser.js"(exports2, module2) {
|
|
332
327
|
"use strict";
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
328
|
+
exports2.formatArgs = formatArgs;
|
|
329
|
+
exports2.save = save;
|
|
330
|
+
exports2.load = load;
|
|
331
|
+
exports2.useColors = useColors;
|
|
332
|
+
exports2.storage = localstorage();
|
|
333
|
+
exports2.destroy = /* @__PURE__ */ (() => {
|
|
339
334
|
let warned = false;
|
|
340
335
|
return () => {
|
|
341
336
|
if (!warned) {
|
|
@@ -344,7 +339,7 @@ var require_browser = __commonJS({
|
|
|
344
339
|
}
|
|
345
340
|
};
|
|
346
341
|
})();
|
|
347
|
-
|
|
342
|
+
exports2.colors = [
|
|
348
343
|
"#0000CC",
|
|
349
344
|
"#0000FF",
|
|
350
345
|
"#0033CC",
|
|
@@ -437,7 +432,7 @@ var require_browser = __commonJS({
|
|
|
437
432
|
typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
438
433
|
}
|
|
439
434
|
function formatArgs(args) {
|
|
440
|
-
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" +
|
|
435
|
+
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module2.exports.humanize(this.diff);
|
|
441
436
|
if (!this.useColors) {
|
|
442
437
|
return;
|
|
443
438
|
}
|
|
@@ -456,14 +451,14 @@ var require_browser = __commonJS({
|
|
|
456
451
|
});
|
|
457
452
|
args.splice(lastC, 0, c);
|
|
458
453
|
}
|
|
459
|
-
|
|
454
|
+
exports2.log = console.debug || console.log || (() => {
|
|
460
455
|
});
|
|
461
456
|
function save(namespaces) {
|
|
462
457
|
try {
|
|
463
458
|
if (namespaces) {
|
|
464
|
-
|
|
459
|
+
exports2.storage.setItem("debug", namespaces);
|
|
465
460
|
} else {
|
|
466
|
-
|
|
461
|
+
exports2.storage.removeItem("debug");
|
|
467
462
|
}
|
|
468
463
|
} catch (error) {
|
|
469
464
|
}
|
|
@@ -471,7 +466,7 @@ var require_browser = __commonJS({
|
|
|
471
466
|
function load() {
|
|
472
467
|
let r;
|
|
473
468
|
try {
|
|
474
|
-
r =
|
|
469
|
+
r = exports2.storage.getItem("debug") || exports2.storage.getItem("DEBUG");
|
|
475
470
|
} catch (error) {
|
|
476
471
|
}
|
|
477
472
|
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
@@ -485,8 +480,8 @@ var require_browser = __commonJS({
|
|
|
485
480
|
} catch (error) {
|
|
486
481
|
}
|
|
487
482
|
}
|
|
488
|
-
|
|
489
|
-
var { formatters } =
|
|
483
|
+
module2.exports = require_common()(exports2);
|
|
484
|
+
var { formatters } = module2.exports;
|
|
490
485
|
formatters.j = function(v) {
|
|
491
486
|
try {
|
|
492
487
|
return JSON.stringify(v);
|
|
@@ -499,9 +494,9 @@ var require_browser = __commonJS({
|
|
|
499
494
|
|
|
500
495
|
// ../../node_modules/has-flag/index.js
|
|
501
496
|
var require_has_flag = __commonJS({
|
|
502
|
-
"../../node_modules/has-flag/index.js"(
|
|
497
|
+
"../../node_modules/has-flag/index.js"(exports2, module2) {
|
|
503
498
|
"use strict";
|
|
504
|
-
|
|
499
|
+
module2.exports = (flag, argv = process.argv) => {
|
|
505
500
|
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
506
501
|
const position = argv.indexOf(prefix + flag);
|
|
507
502
|
const terminatorPosition = argv.indexOf("--");
|
|
@@ -512,10 +507,10 @@ var require_has_flag = __commonJS({
|
|
|
512
507
|
|
|
513
508
|
// ../../node_modules/supports-color/index.js
|
|
514
509
|
var require_supports_color = __commonJS({
|
|
515
|
-
"../../node_modules/supports-color/index.js"(
|
|
510
|
+
"../../node_modules/supports-color/index.js"(exports2, module2) {
|
|
516
511
|
"use strict";
|
|
517
|
-
var os4 =
|
|
518
|
-
var tty =
|
|
512
|
+
var os4 = require("os");
|
|
513
|
+
var tty = require("tty");
|
|
519
514
|
var hasFlag = require_has_flag();
|
|
520
515
|
var { env } = process;
|
|
521
516
|
var forceColor;
|
|
@@ -604,7 +599,7 @@ var require_supports_color = __commonJS({
|
|
|
604
599
|
const level = supportsColor(stream, stream && stream.isTTY);
|
|
605
600
|
return translateLevel(level);
|
|
606
601
|
}
|
|
607
|
-
|
|
602
|
+
module2.exports = {
|
|
608
603
|
supportsColor: getSupportLevel,
|
|
609
604
|
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
610
605
|
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
@@ -614,26 +609,26 @@ var require_supports_color = __commonJS({
|
|
|
614
609
|
|
|
615
610
|
// ../../node_modules/debug/src/node.js
|
|
616
611
|
var require_node = __commonJS({
|
|
617
|
-
"../../node_modules/debug/src/node.js"(
|
|
612
|
+
"../../node_modules/debug/src/node.js"(exports2, module2) {
|
|
618
613
|
"use strict";
|
|
619
|
-
var tty =
|
|
620
|
-
var util =
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
614
|
+
var tty = require("tty");
|
|
615
|
+
var util = require("util");
|
|
616
|
+
exports2.init = init;
|
|
617
|
+
exports2.log = log;
|
|
618
|
+
exports2.formatArgs = formatArgs;
|
|
619
|
+
exports2.save = save;
|
|
620
|
+
exports2.load = load;
|
|
621
|
+
exports2.useColors = useColors;
|
|
622
|
+
exports2.destroy = util.deprecate(
|
|
628
623
|
() => {
|
|
629
624
|
},
|
|
630
625
|
"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."
|
|
631
626
|
);
|
|
632
|
-
|
|
627
|
+
exports2.colors = [6, 2, 3, 4, 5, 1];
|
|
633
628
|
try {
|
|
634
629
|
const supportsColor = require_supports_color();
|
|
635
630
|
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
636
|
-
|
|
631
|
+
exports2.colors = [
|
|
637
632
|
20,
|
|
638
633
|
21,
|
|
639
634
|
26,
|
|
@@ -714,7 +709,7 @@ var require_node = __commonJS({
|
|
|
714
709
|
}
|
|
715
710
|
} catch (error) {
|
|
716
711
|
}
|
|
717
|
-
|
|
712
|
+
exports2.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
718
713
|
return /^debug_/i.test(key);
|
|
719
714
|
}).reduce((obj, key) => {
|
|
720
715
|
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
|
@@ -734,7 +729,7 @@ var require_node = __commonJS({
|
|
|
734
729
|
return obj;
|
|
735
730
|
}, {});
|
|
736
731
|
function useColors() {
|
|
737
|
-
return "colors" in
|
|
732
|
+
return "colors" in exports2.inspectOpts ? Boolean(exports2.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
738
733
|
}
|
|
739
734
|
function formatArgs(args) {
|
|
740
735
|
const { namespace: name, useColors: useColors2 } = this;
|
|
@@ -743,19 +738,19 @@ var require_node = __commonJS({
|
|
|
743
738
|
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
744
739
|
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
745
740
|
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
|
746
|
-
args.push(colorCode + "m+" +
|
|
741
|
+
args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m");
|
|
747
742
|
} else {
|
|
748
743
|
args[0] = getDate() + name + " " + args[0];
|
|
749
744
|
}
|
|
750
745
|
}
|
|
751
746
|
function getDate() {
|
|
752
|
-
if (
|
|
747
|
+
if (exports2.inspectOpts.hideDate) {
|
|
753
748
|
return "";
|
|
754
749
|
}
|
|
755
750
|
return (/* @__PURE__ */ new Date()).toISOString() + " ";
|
|
756
751
|
}
|
|
757
752
|
function log(...args) {
|
|
758
|
-
return process.stderr.write(util.formatWithOptions(
|
|
753
|
+
return process.stderr.write(util.formatWithOptions(exports2.inspectOpts, ...args) + "\n");
|
|
759
754
|
}
|
|
760
755
|
function save(namespaces) {
|
|
761
756
|
if (namespaces) {
|
|
@@ -769,13 +764,13 @@ var require_node = __commonJS({
|
|
|
769
764
|
}
|
|
770
765
|
function init(debug2) {
|
|
771
766
|
debug2.inspectOpts = {};
|
|
772
|
-
const keys = Object.keys(
|
|
767
|
+
const keys = Object.keys(exports2.inspectOpts);
|
|
773
768
|
for (let i = 0; i < keys.length; i++) {
|
|
774
|
-
debug2.inspectOpts[keys[i]] =
|
|
769
|
+
debug2.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]];
|
|
775
770
|
}
|
|
776
771
|
}
|
|
777
|
-
|
|
778
|
-
var { formatters } =
|
|
772
|
+
module2.exports = require_common()(exports2);
|
|
773
|
+
var { formatters } = module2.exports;
|
|
779
774
|
formatters.o = function(v) {
|
|
780
775
|
this.inspectOpts.colors = this.useColors;
|
|
781
776
|
return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
|
|
@@ -789,25 +784,25 @@ var require_node = __commonJS({
|
|
|
789
784
|
|
|
790
785
|
// ../../node_modules/debug/src/index.js
|
|
791
786
|
var require_src = __commonJS({
|
|
792
|
-
"../../node_modules/debug/src/index.js"(
|
|
787
|
+
"../../node_modules/debug/src/index.js"(exports2, module2) {
|
|
793
788
|
"use strict";
|
|
794
789
|
if (typeof process === "undefined" || process.type === "renderer" || process.browser === true || process.__nwjs) {
|
|
795
|
-
|
|
790
|
+
module2.exports = require_browser();
|
|
796
791
|
} else {
|
|
797
|
-
|
|
792
|
+
module2.exports = require_node();
|
|
798
793
|
}
|
|
799
794
|
}
|
|
800
795
|
});
|
|
801
796
|
|
|
802
797
|
// ../../node_modules/@kwsites/file-exists/dist/src/index.js
|
|
803
798
|
var require_src2 = __commonJS({
|
|
804
|
-
"../../node_modules/@kwsites/file-exists/dist/src/index.js"(
|
|
799
|
+
"../../node_modules/@kwsites/file-exists/dist/src/index.js"(exports2) {
|
|
805
800
|
"use strict";
|
|
806
|
-
var __importDefault =
|
|
801
|
+
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
|
|
807
802
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
808
803
|
};
|
|
809
|
-
Object.defineProperty(
|
|
810
|
-
var fs_1 =
|
|
804
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
805
|
+
var fs_1 = require("fs");
|
|
811
806
|
var debug_1 = __importDefault(require_src());
|
|
812
807
|
var log = debug_1.default("@kwsites/file-exists");
|
|
813
808
|
function check(path7, isFile, isDirectory) {
|
|
@@ -833,34 +828,34 @@ var require_src2 = __commonJS({
|
|
|
833
828
|
throw e;
|
|
834
829
|
}
|
|
835
830
|
}
|
|
836
|
-
function exists2(path7, type =
|
|
837
|
-
return check(path7, (type &
|
|
831
|
+
function exists2(path7, type = exports2.READABLE) {
|
|
832
|
+
return check(path7, (type & exports2.FILE) > 0, (type & exports2.FOLDER) > 0);
|
|
838
833
|
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
834
|
+
exports2.exists = exists2;
|
|
835
|
+
exports2.FILE = 1;
|
|
836
|
+
exports2.FOLDER = 2;
|
|
837
|
+
exports2.READABLE = exports2.FILE + exports2.FOLDER;
|
|
843
838
|
}
|
|
844
839
|
});
|
|
845
840
|
|
|
846
841
|
// ../../node_modules/@kwsites/file-exists/dist/index.js
|
|
847
842
|
var require_dist = __commonJS({
|
|
848
|
-
"../../node_modules/@kwsites/file-exists/dist/index.js"(
|
|
843
|
+
"../../node_modules/@kwsites/file-exists/dist/index.js"(exports2) {
|
|
849
844
|
"use strict";
|
|
850
845
|
function __export2(m) {
|
|
851
|
-
for (var p in m) if (!
|
|
846
|
+
for (var p in m) if (!exports2.hasOwnProperty(p)) exports2[p] = m[p];
|
|
852
847
|
}
|
|
853
|
-
Object.defineProperty(
|
|
848
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
854
849
|
__export2(require_src2());
|
|
855
850
|
}
|
|
856
851
|
});
|
|
857
852
|
|
|
858
853
|
// ../../node_modules/@kwsites/promise-deferred/dist/index.js
|
|
859
854
|
var require_dist2 = __commonJS({
|
|
860
|
-
"../../node_modules/@kwsites/promise-deferred/dist/index.js"(
|
|
855
|
+
"../../node_modules/@kwsites/promise-deferred/dist/index.js"(exports2) {
|
|
861
856
|
"use strict";
|
|
862
|
-
Object.defineProperty(
|
|
863
|
-
|
|
857
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
858
|
+
exports2.createDeferred = exports2.deferred = void 0;
|
|
864
859
|
function deferred2() {
|
|
865
860
|
let done;
|
|
866
861
|
let fail;
|
|
@@ -891,24 +886,20 @@ var require_dist2 = __commonJS({
|
|
|
891
886
|
}
|
|
892
887
|
};
|
|
893
888
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
889
|
+
exports2.deferred = deferred2;
|
|
890
|
+
exports2.createDeferred = deferred2;
|
|
891
|
+
exports2.default = deferred2;
|
|
897
892
|
}
|
|
898
893
|
});
|
|
899
894
|
|
|
900
895
|
// src/server/bin.ts
|
|
901
|
-
|
|
902
|
-
|
|
896
|
+
var import_commander = require("commander");
|
|
897
|
+
var import_zod4 = require("zod");
|
|
903
898
|
|
|
904
899
|
// src/server/agent-server.ts
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
PROTOCOL_VERSION
|
|
909
|
-
} from "@agentclientprotocol/sdk";
|
|
910
|
-
import { serve } from "@hono/node-server";
|
|
911
|
-
import { Hono } from "hono";
|
|
900
|
+
var import_sdk4 = require("@agentclientprotocol/sdk");
|
|
901
|
+
var import_node_server = require("@hono/node-server");
|
|
902
|
+
var import_hono = require("hono");
|
|
912
903
|
|
|
913
904
|
// src/acp-extensions.ts
|
|
914
905
|
var POSTHOG_NOTIFICATIONS = {
|
|
@@ -945,7 +936,7 @@ var POSTHOG_NOTIFICATIONS = {
|
|
|
945
936
|
};
|
|
946
937
|
|
|
947
938
|
// src/adapters/acp-connection.ts
|
|
948
|
-
|
|
939
|
+
var import_sdk3 = require("@agentclientprotocol/sdk");
|
|
949
940
|
|
|
950
941
|
// src/utils/logger.ts
|
|
951
942
|
var Logger = class _Logger {
|
|
@@ -1001,7 +992,7 @@ var Logger = class _Logger {
|
|
|
1001
992
|
};
|
|
1002
993
|
|
|
1003
994
|
// src/utils/streams.ts
|
|
1004
|
-
|
|
995
|
+
var import_web = require("stream/web");
|
|
1005
996
|
var Pushable = class {
|
|
1006
997
|
queue = [];
|
|
1007
998
|
resolvers = [];
|
|
@@ -1043,7 +1034,7 @@ var Pushable = class {
|
|
|
1043
1034
|
};
|
|
1044
1035
|
function pushableToReadableStream(pushable) {
|
|
1045
1036
|
const iterator = pushable[Symbol.asyncIterator]();
|
|
1046
|
-
return new
|
|
1037
|
+
return new import_web.ReadableStream({
|
|
1047
1038
|
async pull(controller) {
|
|
1048
1039
|
const { value, done } = await iterator.next();
|
|
1049
1040
|
if (done) {
|
|
@@ -1059,7 +1050,7 @@ function createBidirectionalStreams() {
|
|
|
1059
1050
|
const agentToClientPushable = new Pushable();
|
|
1060
1051
|
const clientToAgentReadable = pushableToReadableStream(clientToAgentPushable);
|
|
1061
1052
|
const agentToClientReadable = pushableToReadableStream(agentToClientPushable);
|
|
1062
|
-
const clientToAgentWritable = new
|
|
1053
|
+
const clientToAgentWritable = new import_web.WritableStream({
|
|
1063
1054
|
write(chunk) {
|
|
1064
1055
|
clientToAgentPushable.push(chunk);
|
|
1065
1056
|
},
|
|
@@ -1067,7 +1058,7 @@ function createBidirectionalStreams() {
|
|
|
1067
1058
|
clientToAgentPushable.end();
|
|
1068
1059
|
}
|
|
1069
1060
|
});
|
|
1070
|
-
const agentToClientWritable = new
|
|
1061
|
+
const agentToClientWritable = new import_web.WritableStream({
|
|
1071
1062
|
write(chunk) {
|
|
1072
1063
|
agentToClientPushable.push(chunk);
|
|
1073
1064
|
},
|
|
@@ -1091,7 +1082,7 @@ function createTappedWritableStream(underlying, options) {
|
|
|
1091
1082
|
const decoder = new TextDecoder();
|
|
1092
1083
|
let buffer = "";
|
|
1093
1084
|
let _messageCount = 0;
|
|
1094
|
-
return new
|
|
1085
|
+
return new import_web.WritableStream({
|
|
1095
1086
|
async write(chunk) {
|
|
1096
1087
|
buffer += decoder.decode(chunk, { stream: true });
|
|
1097
1088
|
const lines = buffer.split("\n");
|
|
@@ -1129,7 +1120,7 @@ function createTappedWritableStream(underlying, options) {
|
|
|
1129
1120
|
});
|
|
1130
1121
|
}
|
|
1131
1122
|
function nodeReadableToWebReadable(nodeStream) {
|
|
1132
|
-
return new
|
|
1123
|
+
return new import_web.ReadableStream({
|
|
1133
1124
|
start(controller) {
|
|
1134
1125
|
nodeStream.on("data", (chunk) => {
|
|
1135
1126
|
controller.enqueue(new Uint8Array(chunk));
|
|
@@ -1147,7 +1138,7 @@ function nodeReadableToWebReadable(nodeStream) {
|
|
|
1147
1138
|
});
|
|
1148
1139
|
}
|
|
1149
1140
|
function nodeWritableToWebWritable(nodeStream) {
|
|
1150
|
-
return new
|
|
1141
|
+
return new import_web.WritableStream({
|
|
1151
1142
|
write(chunk) {
|
|
1152
1143
|
return new Promise((resolve4, reject) => {
|
|
1153
1144
|
const ok = nodeStream.write(Buffer.from(chunk), (err) => {
|
|
@@ -1174,21 +1165,17 @@ function nodeWritableToWebWritable(nodeStream) {
|
|
|
1174
1165
|
}
|
|
1175
1166
|
|
|
1176
1167
|
// src/adapters/claude/claude-agent.ts
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
import {
|
|
1184
|
-
query
|
|
1185
|
-
} from "@anthropic-ai/claude-agent-sdk";
|
|
1186
|
-
import { v7 as uuidv7 } from "uuid";
|
|
1168
|
+
var fs2 = __toESM(require("fs"), 1);
|
|
1169
|
+
var os3 = __toESM(require("os"), 1);
|
|
1170
|
+
var path3 = __toESM(require("path"), 1);
|
|
1171
|
+
var import_sdk2 = require("@agentclientprotocol/sdk");
|
|
1172
|
+
var import_claude_agent_sdk = require("@anthropic-ai/claude-agent-sdk");
|
|
1173
|
+
var import_uuid = require("uuid");
|
|
1187
1174
|
|
|
1188
1175
|
// package.json
|
|
1189
1176
|
var package_default = {
|
|
1190
1177
|
name: "@posthog/agent",
|
|
1191
|
-
version: "2.0.
|
|
1178
|
+
version: "2.0.3",
|
|
1192
1179
|
repository: "https://github.com/PostHog/twig",
|
|
1193
1180
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
1194
1181
|
exports: {
|
|
@@ -1234,7 +1221,7 @@ var package_default = {
|
|
|
1234
1221
|
}
|
|
1235
1222
|
},
|
|
1236
1223
|
bin: {
|
|
1237
|
-
"agent-server": "./dist/server/bin.
|
|
1224
|
+
"agent-server": "./dist/server/bin.cjs"
|
|
1238
1225
|
},
|
|
1239
1226
|
type: "module",
|
|
1240
1227
|
keywords: [
|
|
@@ -1529,7 +1516,7 @@ function promptToClaude(prompt) {
|
|
|
1529
1516
|
}
|
|
1530
1517
|
|
|
1531
1518
|
// src/adapters/claude/conversion/sdk-to-acp.ts
|
|
1532
|
-
|
|
1519
|
+
var import_sdk = require("@agentclientprotocol/sdk");
|
|
1533
1520
|
|
|
1534
1521
|
// src/utils/acp-content.ts
|
|
1535
1522
|
function text(value) {
|
|
@@ -2316,13 +2303,13 @@ function handleResultMessage(message, context) {
|
|
|
2316
2303
|
if (message.result.includes("Please run /login")) {
|
|
2317
2304
|
return {
|
|
2318
2305
|
shouldStop: true,
|
|
2319
|
-
error: RequestError.authRequired()
|
|
2306
|
+
error: import_sdk.RequestError.authRequired()
|
|
2320
2307
|
};
|
|
2321
2308
|
}
|
|
2322
2309
|
if (message.is_error) {
|
|
2323
2310
|
return {
|
|
2324
2311
|
shouldStop: true,
|
|
2325
|
-
error: RequestError.internalError(void 0, message.result)
|
|
2312
|
+
error: import_sdk.RequestError.internalError(void 0, message.result)
|
|
2326
2313
|
};
|
|
2327
2314
|
}
|
|
2328
2315
|
return { shouldStop: true, stopReason: "end_turn" };
|
|
@@ -2331,7 +2318,7 @@ function handleResultMessage(message, context) {
|
|
|
2331
2318
|
if (message.is_error) {
|
|
2332
2319
|
return {
|
|
2333
2320
|
shouldStop: true,
|
|
2334
|
-
error: RequestError.internalError(
|
|
2321
|
+
error: import_sdk.RequestError.internalError(
|
|
2335
2322
|
void 0,
|
|
2336
2323
|
message.errors.join(", ") || message.subtype
|
|
2337
2324
|
)
|
|
@@ -2344,7 +2331,7 @@ function handleResultMessage(message, context) {
|
|
|
2344
2331
|
if (message.is_error) {
|
|
2345
2332
|
return {
|
|
2346
2333
|
shouldStop: true,
|
|
2347
|
-
error: RequestError.internalError(
|
|
2334
|
+
error: import_sdk.RequestError.internalError(
|
|
2348
2335
|
void 0,
|
|
2349
2336
|
message.errors.join(", ") || message.subtype
|
|
2350
2337
|
)
|
|
@@ -2409,7 +2396,7 @@ async function handleUserAssistantMessage(message, context) {
|
|
|
2409
2396
|
if (shouldSkipUserAssistantMessage(message)) {
|
|
2410
2397
|
logSpecialMessages(message, logger);
|
|
2411
2398
|
if (isLoginRequiredMessage(message)) {
|
|
2412
|
-
return { shouldStop: true, error: RequestError.authRequired() };
|
|
2399
|
+
return { shouldStop: true, error: import_sdk.RequestError.authRequired() };
|
|
2413
2400
|
}
|
|
2414
2401
|
return {};
|
|
2415
2402
|
}
|
|
@@ -2431,8 +2418,8 @@ async function handleUserAssistantMessage(message, context) {
|
|
|
2431
2418
|
}
|
|
2432
2419
|
|
|
2433
2420
|
// src/adapters/claude/mcp/tool-metadata.ts
|
|
2434
|
-
|
|
2435
|
-
|
|
2421
|
+
var import_client = require("@modelcontextprotocol/sdk/client/index.js");
|
|
2422
|
+
var import_streamableHttp = require("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
2436
2423
|
var mcpToolMetadataCache = /* @__PURE__ */ new Map();
|
|
2437
2424
|
function buildToolKey(serverName, toolName) {
|
|
2438
2425
|
return `mcp__${serverName}__${toolName}`;
|
|
@@ -2441,12 +2428,12 @@ function isHttpMcpServer(config) {
|
|
|
2441
2428
|
return config.type === "http" && typeof config.url === "string";
|
|
2442
2429
|
}
|
|
2443
2430
|
async function fetchToolsFromHttpServer(_serverName, config) {
|
|
2444
|
-
const transport = new StreamableHTTPClientTransport(new URL(config.url), {
|
|
2431
|
+
const transport = new import_streamableHttp.StreamableHTTPClientTransport(new URL(config.url), {
|
|
2445
2432
|
requestInit: {
|
|
2446
2433
|
headers: config.headers || {}
|
|
2447
2434
|
}
|
|
2448
2435
|
});
|
|
2449
|
-
const client = new Client({
|
|
2436
|
+
const client = new import_client.Client({
|
|
2450
2437
|
name: "twig-metadata-fetcher",
|
|
2451
2438
|
version: "1.0.0"
|
|
2452
2439
|
});
|
|
@@ -2500,8 +2487,8 @@ function isMcpToolReadOnly(toolName) {
|
|
|
2500
2487
|
}
|
|
2501
2488
|
|
|
2502
2489
|
// src/adapters/claude/plan/utils.ts
|
|
2503
|
-
|
|
2504
|
-
|
|
2490
|
+
var os = __toESM(require("os"), 1);
|
|
2491
|
+
var path = __toESM(require("path"), 1);
|
|
2505
2492
|
function getClaudeConfigDir() {
|
|
2506
2493
|
return process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), ".claude");
|
|
2507
2494
|
}
|
|
@@ -2543,21 +2530,21 @@ function getLatestAssistantText(notifications) {
|
|
|
2543
2530
|
}
|
|
2544
2531
|
|
|
2545
2532
|
// src/adapters/claude/questions/utils.ts
|
|
2546
|
-
|
|
2533
|
+
var import_zod = require("zod");
|
|
2547
2534
|
var OPTION_PREFIX = "option_";
|
|
2548
|
-
var QuestionOptionSchema = z.object({
|
|
2549
|
-
label: z.string(),
|
|
2550
|
-
description: z.string().optional()
|
|
2535
|
+
var QuestionOptionSchema = import_zod.z.object({
|
|
2536
|
+
label: import_zod.z.string(),
|
|
2537
|
+
description: import_zod.z.string().optional()
|
|
2551
2538
|
});
|
|
2552
|
-
var QuestionItemSchema = z.object({
|
|
2553
|
-
question: z.string(),
|
|
2554
|
-
header: z.string().optional(),
|
|
2555
|
-
options: z.array(QuestionOptionSchema),
|
|
2556
|
-
multiSelect: z.boolean().optional(),
|
|
2557
|
-
completed: z.boolean().optional()
|
|
2539
|
+
var QuestionItemSchema = import_zod.z.object({
|
|
2540
|
+
question: import_zod.z.string(),
|
|
2541
|
+
header: import_zod.z.string().optional(),
|
|
2542
|
+
options: import_zod.z.array(QuestionOptionSchema),
|
|
2543
|
+
multiSelect: import_zod.z.boolean().optional(),
|
|
2544
|
+
completed: import_zod.z.boolean().optional()
|
|
2558
2545
|
});
|
|
2559
|
-
var QuestionMetaSchema = z.object({
|
|
2560
|
-
questions: z.array(QuestionItemSchema)
|
|
2546
|
+
var QuestionMetaSchema = import_zod.z.object({
|
|
2547
|
+
questions: import_zod.z.array(QuestionItemSchema)
|
|
2561
2548
|
});
|
|
2562
2549
|
function normalizeAskUserQuestionInput(input) {
|
|
2563
2550
|
if (input.questions && input.questions.length > 0) {
|
|
@@ -3079,10 +3066,10 @@ function toSdkModelId(modelId) {
|
|
|
3079
3066
|
}
|
|
3080
3067
|
|
|
3081
3068
|
// src/adapters/claude/session/options.ts
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3069
|
+
var import_node_child_process = require("child_process");
|
|
3070
|
+
var fs = __toESM(require("fs"), 1);
|
|
3071
|
+
var os2 = __toESM(require("os"), 1);
|
|
3072
|
+
var path2 = __toESM(require("path"), 1);
|
|
3086
3073
|
var BRANCH_NAMING_INSTRUCTIONS = `
|
|
3087
3074
|
# Branch Naming
|
|
3088
3075
|
|
|
@@ -3141,7 +3128,7 @@ function getAbortController(userProvidedController) {
|
|
|
3141
3128
|
}
|
|
3142
3129
|
function buildSpawnWrapper(sessionId, onProcessSpawned, onProcessExited) {
|
|
3143
3130
|
return (spawnOpts) => {
|
|
3144
|
-
const child = spawn(spawnOpts.command, spawnOpts.args, {
|
|
3131
|
+
const child = (0, import_node_child_process.spawn)(spawnOpts.command, spawnOpts.args, {
|
|
3145
3132
|
cwd: spawnOpts.cwd,
|
|
3146
3133
|
env: spawnOpts.env,
|
|
3147
3134
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -3299,7 +3286,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
3299
3286
|
async newSession(params) {
|
|
3300
3287
|
this.checkAuthStatus();
|
|
3301
3288
|
const meta = params._meta;
|
|
3302
|
-
const internalSessionId =
|
|
3289
|
+
const internalSessionId = (0, import_uuid.v7)();
|
|
3303
3290
|
const permissionMode = "default";
|
|
3304
3291
|
const mcpServers = parseMcpServers(params);
|
|
3305
3292
|
await fetchMcpToolMetadata(mcpServers, this.logger);
|
|
@@ -3316,7 +3303,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
3316
3303
|
onProcessExited: this.processCallbacks?.onProcessExited
|
|
3317
3304
|
});
|
|
3318
3305
|
const input = new Pushable();
|
|
3319
|
-
const q = query({ prompt: input, options });
|
|
3306
|
+
const q = (0, import_claude_agent_sdk.query)({ prompt: input, options });
|
|
3320
3307
|
const session = this.createSession(
|
|
3321
3308
|
internalSessionId,
|
|
3322
3309
|
q,
|
|
@@ -3419,7 +3406,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
3419
3406
|
}
|
|
3420
3407
|
};
|
|
3421
3408
|
}
|
|
3422
|
-
throw
|
|
3409
|
+
throw import_sdk2.RequestError.methodNotFound(method);
|
|
3423
3410
|
}
|
|
3424
3411
|
createSession(sessionId, q, input, permissionMode, cwd, abortController) {
|
|
3425
3412
|
const session = {
|
|
@@ -3451,7 +3438,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
3451
3438
|
onProcessSpawned: this.processCallbacks?.onProcessSpawned,
|
|
3452
3439
|
onProcessExited: this.processCallbacks?.onProcessExited
|
|
3453
3440
|
});
|
|
3454
|
-
const q = query({ prompt: input, options });
|
|
3441
|
+
const q = (0, import_claude_agent_sdk.query)({ prompt: input, options });
|
|
3455
3442
|
const abortController = options.abortController;
|
|
3456
3443
|
const session = this.createSession(
|
|
3457
3444
|
config.internalSessionId,
|
|
@@ -3537,7 +3524,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
3537
3524
|
path3.resolve(os3.homedir(), ".claude.json")
|
|
3538
3525
|
);
|
|
3539
3526
|
if (backupExists && !configExists) {
|
|
3540
|
-
throw
|
|
3527
|
+
throw import_sdk2.RequestError.authRequired();
|
|
3541
3528
|
}
|
|
3542
3529
|
}
|
|
3543
3530
|
async trySetModel(q, modelId) {
|
|
@@ -3656,8 +3643,8 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
3656
3643
|
};
|
|
3657
3644
|
|
|
3658
3645
|
// src/adapters/codex/spawn.ts
|
|
3659
|
-
|
|
3660
|
-
|
|
3646
|
+
var import_node_child_process2 = require("child_process");
|
|
3647
|
+
var import_node_fs = require("fs");
|
|
3661
3648
|
function buildConfigArgs(options) {
|
|
3662
3649
|
const args = [];
|
|
3663
3650
|
args.push("-c", `features.remote_models=false`);
|
|
@@ -3678,7 +3665,7 @@ function buildConfigArgs(options) {
|
|
|
3678
3665
|
}
|
|
3679
3666
|
function findCodexBinary(options) {
|
|
3680
3667
|
const configArgs = buildConfigArgs(options);
|
|
3681
|
-
if (options.binaryPath &&
|
|
3668
|
+
if (options.binaryPath && (0, import_node_fs.existsSync)(options.binaryPath)) {
|
|
3682
3669
|
return { command: options.binaryPath, args: configArgs };
|
|
3683
3670
|
}
|
|
3684
3671
|
return { command: "npx", args: ["@zed-industries/codex-acp", ...configArgs] };
|
|
@@ -3700,7 +3687,7 @@ function spawnCodexProcess(options) {
|
|
|
3700
3687
|
hasApiKey: !!options.apiKey,
|
|
3701
3688
|
binaryPath: options.binaryPath
|
|
3702
3689
|
});
|
|
3703
|
-
const child =
|
|
3690
|
+
const child = (0, import_node_child_process2.spawn)(command, args, {
|
|
3704
3691
|
cwd: options.cwd,
|
|
3705
3692
|
env,
|
|
3706
3693
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -3838,9 +3825,9 @@ function createClaudeConnection(config) {
|
|
|
3838
3825
|
hasLogWriter: !!logWriter
|
|
3839
3826
|
});
|
|
3840
3827
|
}
|
|
3841
|
-
const agentStream = ndJsonStream(agentWritable, streams.agent.readable);
|
|
3828
|
+
const agentStream = (0, import_sdk3.ndJsonStream)(agentWritable, streams.agent.readable);
|
|
3842
3829
|
let agent = null;
|
|
3843
|
-
const agentConnection = new AgentSideConnection((client) => {
|
|
3830
|
+
const agentConnection = new import_sdk3.AgentSideConnection((client) => {
|
|
3844
3831
|
agent = new ClaudeAcpAgent(client, logWriter, config.processCallbacks);
|
|
3845
3832
|
logger.info(`Created ${agent.adapterName} agent`);
|
|
3846
3833
|
return agent;
|
|
@@ -4256,29 +4243,26 @@ var PostHogAPIClient = class {
|
|
|
4256
4243
|
};
|
|
4257
4244
|
|
|
4258
4245
|
// src/otel-log-writer.ts
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
LoggerProvider
|
|
4265
|
-
} from "@opentelemetry/sdk-logs";
|
|
4266
|
-
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
4246
|
+
var import_api_logs = require("@opentelemetry/api-logs");
|
|
4247
|
+
var import_exporter_logs_otlp_http = require("@opentelemetry/exporter-logs-otlp-http");
|
|
4248
|
+
var import_resources = require("@opentelemetry/resources");
|
|
4249
|
+
var import_sdk_logs = require("@opentelemetry/sdk-logs");
|
|
4250
|
+
var import_semantic_conventions = require("@opentelemetry/semantic-conventions");
|
|
4267
4251
|
var OtelLogWriter = class {
|
|
4268
4252
|
loggerProvider;
|
|
4269
4253
|
logger;
|
|
4270
4254
|
constructor(config, sessionContext, _debugLogger) {
|
|
4271
4255
|
const logsPath = config.logsPath ?? "/i/v1/agent-logs";
|
|
4272
|
-
const exporter = new OTLPLogExporter({
|
|
4256
|
+
const exporter = new import_exporter_logs_otlp_http.OTLPLogExporter({
|
|
4273
4257
|
url: `${config.posthogHost}${logsPath}`,
|
|
4274
4258
|
headers: { Authorization: `Bearer ${config.apiKey}` }
|
|
4275
4259
|
});
|
|
4276
|
-
const processor = new BatchLogRecordProcessor(exporter, {
|
|
4260
|
+
const processor = new import_sdk_logs.BatchLogRecordProcessor(exporter, {
|
|
4277
4261
|
scheduledDelayMillis: config.flushIntervalMs ?? 500
|
|
4278
4262
|
});
|
|
4279
|
-
this.loggerProvider = new LoggerProvider({
|
|
4280
|
-
resource: resourceFromAttributes({
|
|
4281
|
-
[ATTR_SERVICE_NAME]: "twig-agent",
|
|
4263
|
+
this.loggerProvider = new import_sdk_logs.LoggerProvider({
|
|
4264
|
+
resource: (0, import_resources.resourceFromAttributes)({
|
|
4265
|
+
[import_semantic_conventions.ATTR_SERVICE_NAME]: "twig-agent",
|
|
4282
4266
|
run_id: sessionContext.runId,
|
|
4283
4267
|
task_id: sessionContext.taskId,
|
|
4284
4268
|
device_type: sessionContext.deviceType ?? "local"
|
|
@@ -4294,7 +4278,7 @@ var OtelLogWriter = class {
|
|
|
4294
4278
|
const { notification } = entry;
|
|
4295
4279
|
const eventType = notification.notification.method;
|
|
4296
4280
|
this.logger.emit({
|
|
4297
|
-
severityNumber: SeverityNumber.INFO,
|
|
4281
|
+
severityNumber: import_api_logs.SeverityNumber.INFO,
|
|
4298
4282
|
severityText: "INFO",
|
|
4299
4283
|
body: JSON.stringify(notification),
|
|
4300
4284
|
attributes: {
|
|
@@ -4354,9 +4338,22 @@ var SessionLogWriter = class {
|
|
|
4354
4338
|
}
|
|
4355
4339
|
try {
|
|
4356
4340
|
const message = JSON.parse(line);
|
|
4341
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
4342
|
+
if (this.isAgentMessageChunk(message)) {
|
|
4343
|
+
const text2 = this.extractChunkText(message);
|
|
4344
|
+
if (text2) {
|
|
4345
|
+
if (!session.chunkBuffer) {
|
|
4346
|
+
session.chunkBuffer = { text: text2, firstTimestamp: timestamp };
|
|
4347
|
+
} else {
|
|
4348
|
+
session.chunkBuffer.text += text2;
|
|
4349
|
+
}
|
|
4350
|
+
}
|
|
4351
|
+
return;
|
|
4352
|
+
}
|
|
4353
|
+
this.emitCoalescedMessage(sessionId, session);
|
|
4357
4354
|
const entry = {
|
|
4358
4355
|
type: "notification",
|
|
4359
|
-
timestamp
|
|
4356
|
+
timestamp,
|
|
4360
4357
|
notification: message
|
|
4361
4358
|
};
|
|
4362
4359
|
if (session.otelWriter) {
|
|
@@ -4378,6 +4375,7 @@ var SessionLogWriter = class {
|
|
|
4378
4375
|
async flush(sessionId) {
|
|
4379
4376
|
const session = this.sessions.get(sessionId);
|
|
4380
4377
|
if (!session) return;
|
|
4378
|
+
this.emitCoalescedMessage(sessionId, session);
|
|
4381
4379
|
if (session.otelWriter) {
|
|
4382
4380
|
await session.otelWriter.flush();
|
|
4383
4381
|
}
|
|
@@ -4399,6 +4397,49 @@ var SessionLogWriter = class {
|
|
|
4399
4397
|
this.logger.error("Failed to persist session logs:", error);
|
|
4400
4398
|
}
|
|
4401
4399
|
}
|
|
4400
|
+
isAgentMessageChunk(message) {
|
|
4401
|
+
if (message.method !== "session/update") return false;
|
|
4402
|
+
const params = message.params;
|
|
4403
|
+
const update = params?.update;
|
|
4404
|
+
return update?.sessionUpdate === "agent_message_chunk";
|
|
4405
|
+
}
|
|
4406
|
+
extractChunkText(message) {
|
|
4407
|
+
const params = message.params;
|
|
4408
|
+
const update = params?.update;
|
|
4409
|
+
const content = update?.content;
|
|
4410
|
+
if (content?.type === "text" && content.text) {
|
|
4411
|
+
return content.text;
|
|
4412
|
+
}
|
|
4413
|
+
return "";
|
|
4414
|
+
}
|
|
4415
|
+
emitCoalescedMessage(sessionId, session) {
|
|
4416
|
+
if (!session.chunkBuffer) return;
|
|
4417
|
+
const { text: text2, firstTimestamp } = session.chunkBuffer;
|
|
4418
|
+
session.chunkBuffer = void 0;
|
|
4419
|
+
const entry = {
|
|
4420
|
+
type: "notification",
|
|
4421
|
+
timestamp: firstTimestamp,
|
|
4422
|
+
notification: {
|
|
4423
|
+
jsonrpc: "2.0",
|
|
4424
|
+
method: "session/update",
|
|
4425
|
+
params: {
|
|
4426
|
+
update: {
|
|
4427
|
+
sessionUpdate: "agent_message",
|
|
4428
|
+
content: { type: "text", text: text2 }
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
};
|
|
4433
|
+
if (session.otelWriter) {
|
|
4434
|
+
session.otelWriter.emit({ notification: entry });
|
|
4435
|
+
}
|
|
4436
|
+
if (this.posthogAPI) {
|
|
4437
|
+
const pending = this.pendingEntries.get(sessionId) ?? [];
|
|
4438
|
+
pending.push(entry);
|
|
4439
|
+
this.pendingEntries.set(sessionId, pending);
|
|
4440
|
+
this.scheduleFlush(sessionId);
|
|
4441
|
+
}
|
|
4442
|
+
}
|
|
4402
4443
|
scheduleFlush(sessionId) {
|
|
4403
4444
|
const existing = this.flushTimeouts.get(sessionId);
|
|
4404
4445
|
if (existing) clearTimeout(existing);
|
|
@@ -4408,18 +4449,18 @@ var SessionLogWriter = class {
|
|
|
4408
4449
|
};
|
|
4409
4450
|
|
|
4410
4451
|
// ../git/dist/queries.js
|
|
4411
|
-
|
|
4412
|
-
|
|
4452
|
+
var fs4 = __toESM(require("fs/promises"), 1);
|
|
4453
|
+
var path5 = __toESM(require("path"), 1);
|
|
4413
4454
|
|
|
4414
4455
|
// ../../node_modules/simple-git/dist/esm/index.js
|
|
4456
|
+
var import_node_buffer = require("buffer");
|
|
4415
4457
|
var import_file_exists = __toESM(require_dist(), 1);
|
|
4416
4458
|
var import_debug = __toESM(require_src(), 1);
|
|
4459
|
+
var import_child_process = require("child_process");
|
|
4417
4460
|
var import_promise_deferred = __toESM(require_dist2(), 1);
|
|
4461
|
+
var import_node_path = require("path");
|
|
4418
4462
|
var import_promise_deferred2 = __toESM(require_dist2(), 1);
|
|
4419
|
-
|
|
4420
|
-
import { spawn as spawn3 } from "child_process";
|
|
4421
|
-
import { normalize } from "path";
|
|
4422
|
-
import { EventEmitter } from "events";
|
|
4463
|
+
var import_node_events = require("events");
|
|
4423
4464
|
var __defProp2 = Object.defineProperty;
|
|
4424
4465
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
4425
4466
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
@@ -4427,7 +4468,7 @@ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
|
4427
4468
|
var __esm = (fn, res) => function __init() {
|
|
4428
4469
|
return fn && (res = (0, fn[__getOwnPropNames2(fn)[0]])(fn = 0)), res;
|
|
4429
4470
|
};
|
|
4430
|
-
var __commonJS2 = (cb, mod) => function
|
|
4471
|
+
var __commonJS2 = (cb, mod) => function __require() {
|
|
4431
4472
|
return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4432
4473
|
};
|
|
4433
4474
|
var __export = (target, all) => {
|
|
@@ -4596,7 +4637,7 @@ function prefixedArray(input, prefix) {
|
|
|
4596
4637
|
return output;
|
|
4597
4638
|
}
|
|
4598
4639
|
function bufferToString(input) {
|
|
4599
|
-
return (Array.isArray(input) ?
|
|
4640
|
+
return (Array.isArray(input) ? import_node_buffer.Buffer.concat(input) : input).toString("utf-8");
|
|
4600
4641
|
}
|
|
4601
4642
|
function pick(source, properties) {
|
|
4602
4643
|
const out = {};
|
|
@@ -5805,7 +5846,7 @@ var init_git_executor_chain = __esm({
|
|
|
5805
5846
|
rejection = reason || rejection;
|
|
5806
5847
|
}
|
|
5807
5848
|
});
|
|
5808
|
-
const spawned =
|
|
5849
|
+
const spawned = (0, import_child_process.spawn)(command, args, spawnOptions);
|
|
5809
5850
|
spawned.stdout.on(
|
|
5810
5851
|
"data",
|
|
5811
5852
|
onDataReceived(stdOut, "stdOut", logger, outputLogger.step("stdOut"))
|
|
@@ -7725,7 +7766,7 @@ var init_branch = __esm({
|
|
|
7725
7766
|
});
|
|
7726
7767
|
function toPath(input) {
|
|
7727
7768
|
const path7 = input.trim().replace(/^["']|["']$/g, "");
|
|
7728
|
-
return path7 && normalize(path7);
|
|
7769
|
+
return path7 && (0, import_node_path.normalize)(path7);
|
|
7729
7770
|
}
|
|
7730
7771
|
var parseCheckIgnore;
|
|
7731
7772
|
var init_CheckIgnore = __esm({
|
|
@@ -8156,7 +8197,7 @@ var init_tag = __esm({
|
|
|
8156
8197
|
}
|
|
8157
8198
|
});
|
|
8158
8199
|
var require_git = __commonJS2({
|
|
8159
|
-
"src/git.js"(
|
|
8200
|
+
"src/git.js"(exports2, module2) {
|
|
8160
8201
|
"use strict";
|
|
8161
8202
|
var { GitExecutor: GitExecutor2 } = (init_git_executor(), __toCommonJS(git_executor_exports));
|
|
8162
8203
|
var { SimpleGitApi: SimpleGitApi2 } = (init_simple_git_api(), __toCommonJS(simple_git_api_exports));
|
|
@@ -8530,7 +8571,7 @@ var require_git = __commonJS2({
|
|
|
8530
8571
|
trailingFunctionArgument2(arguments)
|
|
8531
8572
|
);
|
|
8532
8573
|
};
|
|
8533
|
-
|
|
8574
|
+
module2.exports = Git2;
|
|
8534
8575
|
}
|
|
8535
8576
|
});
|
|
8536
8577
|
init_pathspec();
|
|
@@ -8785,7 +8826,7 @@ init_utils();
|
|
|
8785
8826
|
var PluginStore = class {
|
|
8786
8827
|
constructor() {
|
|
8787
8828
|
this.plugins = /* @__PURE__ */ new Set();
|
|
8788
|
-
this.events = new EventEmitter();
|
|
8829
|
+
this.events = new import_node_events.EventEmitter();
|
|
8789
8830
|
}
|
|
8790
8831
|
on(type, listener) {
|
|
8791
8832
|
this.events.on(type, listener);
|
|
@@ -8971,23 +9012,23 @@ function createGitClient(baseDir, options) {
|
|
|
8971
9012
|
}
|
|
8972
9013
|
|
|
8973
9014
|
// ../git/dist/lock-detector.js
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
var execFileAsync = promisify(execFile);
|
|
9015
|
+
var import_node_child_process3 = require("child_process");
|
|
9016
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
9017
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
9018
|
+
var import_node_util = require("util");
|
|
9019
|
+
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process3.execFile);
|
|
8979
9020
|
async function getIndexLockPath(repoPath) {
|
|
8980
9021
|
try {
|
|
8981
9022
|
const { stdout } = await execFileAsync("git", ["rev-parse", "--git-path", "index.lock"], { cwd: repoPath });
|
|
8982
|
-
return
|
|
9023
|
+
return import_node_path2.default.resolve(repoPath, stdout.trim());
|
|
8983
9024
|
} catch {
|
|
8984
|
-
return
|
|
9025
|
+
return import_node_path2.default.join(repoPath, ".git", "index.lock");
|
|
8985
9026
|
}
|
|
8986
9027
|
}
|
|
8987
9028
|
async function getLockInfo(repoPath) {
|
|
8988
9029
|
const lockPath = await getIndexLockPath(repoPath);
|
|
8989
9030
|
try {
|
|
8990
|
-
const stat = await
|
|
9031
|
+
const stat = await import_promises.default.stat(lockPath);
|
|
8991
9032
|
return {
|
|
8992
9033
|
path: lockPath,
|
|
8993
9034
|
ageMs: Date.now() - stat.mtimeMs
|
|
@@ -8998,7 +9039,7 @@ async function getLockInfo(repoPath) {
|
|
|
8998
9039
|
}
|
|
8999
9040
|
async function removeLock(repoPath) {
|
|
9000
9041
|
const lockPath = await getIndexLockPath(repoPath);
|
|
9001
|
-
await
|
|
9042
|
+
await import_promises.default.rm(lockPath, { force: true });
|
|
9002
9043
|
}
|
|
9003
9044
|
async function isLocked(repoPath) {
|
|
9004
9045
|
return await getLockInfo(repoPath) !== null;
|
|
@@ -9162,8 +9203,8 @@ async function getHeadSha(baseDir, options) {
|
|
|
9162
9203
|
}
|
|
9163
9204
|
|
|
9164
9205
|
// src/sagas/apply-snapshot-saga.ts
|
|
9165
|
-
|
|
9166
|
-
|
|
9206
|
+
var import_promises2 = require("fs/promises");
|
|
9207
|
+
var import_node_path3 = require("path");
|
|
9167
9208
|
|
|
9168
9209
|
// ../shared/dist/index.js
|
|
9169
9210
|
var consoleLogger = {
|
|
@@ -9293,10 +9334,10 @@ var Saga = class {
|
|
|
9293
9334
|
};
|
|
9294
9335
|
|
|
9295
9336
|
// ../git/dist/sagas/tree.js
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9337
|
+
var import_node_fs2 = require("fs");
|
|
9338
|
+
var fs5 = __toESM(require("fs/promises"), 1);
|
|
9339
|
+
var path6 = __toESM(require("path"), 1);
|
|
9340
|
+
var tar = __toESM(require("tar"), 1);
|
|
9300
9341
|
|
|
9301
9342
|
// ../git/dist/git-saga.js
|
|
9302
9343
|
var GitSaga = class extends Saga {
|
|
@@ -9383,7 +9424,7 @@ var CaptureTreeSaga = class extends GitSaga {
|
|
|
9383
9424
|
if (filesToArchive.length === 0) {
|
|
9384
9425
|
return void 0;
|
|
9385
9426
|
}
|
|
9386
|
-
const existingFiles = filesToArchive.filter((f) =>
|
|
9427
|
+
const existingFiles = filesToArchive.filter((f) => (0, import_node_fs2.existsSync)(path6.join(baseDir, f)));
|
|
9387
9428
|
if (existingFiles.length === 0) {
|
|
9388
9429
|
return void 0;
|
|
9389
9430
|
}
|
|
@@ -9575,17 +9616,17 @@ var ApplySnapshotSaga = class extends Saga {
|
|
|
9575
9616
|
archivePath = null;
|
|
9576
9617
|
async execute(input) {
|
|
9577
9618
|
const { snapshot, repositoryPath, apiClient, taskId, runId } = input;
|
|
9578
|
-
const tmpDir =
|
|
9619
|
+
const tmpDir = (0, import_node_path3.join)(repositoryPath, ".posthog", "tmp");
|
|
9579
9620
|
if (!snapshot.archiveUrl) {
|
|
9580
9621
|
throw new Error("Cannot apply snapshot: no archive URL");
|
|
9581
9622
|
}
|
|
9582
9623
|
await this.step({
|
|
9583
9624
|
name: "create_tmp_dir",
|
|
9584
|
-
execute: () =>
|
|
9625
|
+
execute: () => (0, import_promises2.mkdir)(tmpDir, { recursive: true }),
|
|
9585
9626
|
rollback: async () => {
|
|
9586
9627
|
}
|
|
9587
9628
|
});
|
|
9588
|
-
this.archivePath =
|
|
9629
|
+
this.archivePath = (0, import_node_path3.join)(tmpDir, `${snapshot.treeHash}.tar.gz`);
|
|
9589
9630
|
await this.step({
|
|
9590
9631
|
name: "download_archive",
|
|
9591
9632
|
execute: async () => {
|
|
@@ -9599,11 +9640,11 @@ var ApplySnapshotSaga = class extends Saga {
|
|
|
9599
9640
|
}
|
|
9600
9641
|
const base64Content = Buffer.from(arrayBuffer).toString("utf-8");
|
|
9601
9642
|
const binaryContent = Buffer.from(base64Content, "base64");
|
|
9602
|
-
await
|
|
9643
|
+
await (0, import_promises2.writeFile)(this.archivePath, binaryContent);
|
|
9603
9644
|
},
|
|
9604
9645
|
rollback: async () => {
|
|
9605
9646
|
if (this.archivePath) {
|
|
9606
|
-
await
|
|
9647
|
+
await (0, import_promises2.rm)(this.archivePath, { force: true }).catch(() => {
|
|
9607
9648
|
});
|
|
9608
9649
|
}
|
|
9609
9650
|
}
|
|
@@ -9619,7 +9660,7 @@ var ApplySnapshotSaga = class extends Saga {
|
|
|
9619
9660
|
if (!applyResult.success) {
|
|
9620
9661
|
throw new Error(`Failed to apply tree: ${applyResult.error}`);
|
|
9621
9662
|
}
|
|
9622
|
-
await
|
|
9663
|
+
await (0, import_promises2.rm)(this.archivePath, { force: true }).catch(() => {
|
|
9623
9664
|
});
|
|
9624
9665
|
this.log.info("Tree snapshot applied", {
|
|
9625
9666
|
treeHash: snapshot.treeHash,
|
|
@@ -9631,9 +9672,9 @@ var ApplySnapshotSaga = class extends Saga {
|
|
|
9631
9672
|
};
|
|
9632
9673
|
|
|
9633
9674
|
// src/sagas/capture-tree-saga.ts
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
|
|
9675
|
+
var import_node_fs3 = require("fs");
|
|
9676
|
+
var import_promises3 = require("fs/promises");
|
|
9677
|
+
var import_node_path4 = require("path");
|
|
9637
9678
|
var CaptureTreeSaga2 = class extends Saga {
|
|
9638
9679
|
async execute(input) {
|
|
9639
9680
|
const {
|
|
@@ -9644,14 +9685,14 @@ var CaptureTreeSaga2 = class extends Saga {
|
|
|
9644
9685
|
taskId,
|
|
9645
9686
|
runId
|
|
9646
9687
|
} = input;
|
|
9647
|
-
const tmpDir =
|
|
9648
|
-
if (
|
|
9688
|
+
const tmpDir = (0, import_node_path4.join)(repositoryPath, ".posthog", "tmp");
|
|
9689
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path4.join)(repositoryPath, ".gitmodules"))) {
|
|
9649
9690
|
this.log.warn(
|
|
9650
9691
|
"Repository has submodules - snapshot may not capture submodule state"
|
|
9651
9692
|
);
|
|
9652
9693
|
}
|
|
9653
9694
|
const shouldArchive = !!apiClient;
|
|
9654
|
-
const archivePath = shouldArchive ?
|
|
9695
|
+
const archivePath = shouldArchive ? (0, import_node_path4.join)(tmpDir, `tree-${Date.now()}.tar.gz`) : void 0;
|
|
9655
9696
|
const gitCaptureSaga = new CaptureTreeSaga(this.log);
|
|
9656
9697
|
const captureResult = await gitCaptureSaga.run({
|
|
9657
9698
|
baseDir: repositoryPath,
|
|
@@ -9681,7 +9722,7 @@ var CaptureTreeSaga2 = class extends Saga {
|
|
|
9681
9722
|
runId
|
|
9682
9723
|
);
|
|
9683
9724
|
} finally {
|
|
9684
|
-
await
|
|
9725
|
+
await (0, import_promises3.rm)(createdArchivePath, { force: true }).catch(() => {
|
|
9685
9726
|
});
|
|
9686
9727
|
}
|
|
9687
9728
|
}
|
|
@@ -9705,7 +9746,7 @@ var CaptureTreeSaga2 = class extends Saga {
|
|
|
9705
9746
|
const archiveUrl = await this.step({
|
|
9706
9747
|
name: "upload_archive",
|
|
9707
9748
|
execute: async () => {
|
|
9708
|
-
const archiveContent = await
|
|
9749
|
+
const archiveContent = await (0, import_promises3.readFile)(archivePath);
|
|
9709
9750
|
const base64Content = archiveContent.toString("base64");
|
|
9710
9751
|
const artifacts = await apiClient.uploadTaskArtifacts(taskId, runId, [
|
|
9711
9752
|
{
|
|
@@ -9725,7 +9766,7 @@ var CaptureTreeSaga2 = class extends Saga {
|
|
|
9725
9766
|
return void 0;
|
|
9726
9767
|
},
|
|
9727
9768
|
rollback: async () => {
|
|
9728
|
-
await
|
|
9769
|
+
await (0, import_promises3.rm)(archivePath, { force: true }).catch(() => {
|
|
9729
9770
|
});
|
|
9730
9771
|
}
|
|
9731
9772
|
});
|
|
@@ -9856,21 +9897,21 @@ var AsyncMutex = class {
|
|
|
9856
9897
|
};
|
|
9857
9898
|
|
|
9858
9899
|
// src/server/jwt.ts
|
|
9859
|
-
|
|
9860
|
-
|
|
9900
|
+
var import_jsonwebtoken = __toESM(require("jsonwebtoken"), 1);
|
|
9901
|
+
var import_zod2 = require("zod");
|
|
9861
9902
|
var SANDBOX_CONNECTION_AUDIENCE = "posthog:sandbox_connection";
|
|
9862
|
-
var userDataSchema =
|
|
9863
|
-
run_id:
|
|
9864
|
-
task_id:
|
|
9865
|
-
team_id:
|
|
9866
|
-
user_id:
|
|
9867
|
-
distinct_id:
|
|
9868
|
-
mode:
|
|
9903
|
+
var userDataSchema = import_zod2.z.object({
|
|
9904
|
+
run_id: import_zod2.z.string(),
|
|
9905
|
+
task_id: import_zod2.z.string(),
|
|
9906
|
+
team_id: import_zod2.z.number(),
|
|
9907
|
+
user_id: import_zod2.z.number(),
|
|
9908
|
+
distinct_id: import_zod2.z.string(),
|
|
9909
|
+
mode: import_zod2.z.enum(["interactive", "background"]).optional().default("interactive")
|
|
9869
9910
|
});
|
|
9870
9911
|
var jwtPayloadSchema = userDataSchema.extend({
|
|
9871
|
-
exp:
|
|
9872
|
-
iat:
|
|
9873
|
-
aud:
|
|
9912
|
+
exp: import_zod2.z.number(),
|
|
9913
|
+
iat: import_zod2.z.number().optional(),
|
|
9914
|
+
aud: import_zod2.z.string().optional()
|
|
9874
9915
|
});
|
|
9875
9916
|
var JwtValidationError = class extends Error {
|
|
9876
9917
|
constructor(message, code) {
|
|
@@ -9881,7 +9922,7 @@ var JwtValidationError = class extends Error {
|
|
|
9881
9922
|
};
|
|
9882
9923
|
function validateJwt(token, publicKey) {
|
|
9883
9924
|
try {
|
|
9884
|
-
const decoded =
|
|
9925
|
+
const decoded = import_jsonwebtoken.default.verify(token, publicKey, {
|
|
9885
9926
|
algorithms: ["RS256"],
|
|
9886
9927
|
audience: SANDBOX_CONNECTION_AUDIENCE
|
|
9887
9928
|
});
|
|
@@ -9897,10 +9938,10 @@ function validateJwt(token, publicKey) {
|
|
|
9897
9938
|
if (error instanceof JwtValidationError) {
|
|
9898
9939
|
throw error;
|
|
9899
9940
|
}
|
|
9900
|
-
if (error instanceof
|
|
9941
|
+
if (error instanceof import_jsonwebtoken.default.TokenExpiredError) {
|
|
9901
9942
|
throw new JwtValidationError("Token expired", "expired");
|
|
9902
9943
|
}
|
|
9903
|
-
if (error instanceof
|
|
9944
|
+
if (error instanceof import_jsonwebtoken.default.JsonWebTokenError) {
|
|
9904
9945
|
throw new JwtValidationError("Invalid signature", "invalid_signature");
|
|
9905
9946
|
}
|
|
9906
9947
|
throw new JwtValidationError("Invalid token", "invalid_token");
|
|
@@ -9908,23 +9949,23 @@ function validateJwt(token, publicKey) {
|
|
|
9908
9949
|
}
|
|
9909
9950
|
|
|
9910
9951
|
// src/server/schemas.ts
|
|
9911
|
-
|
|
9912
|
-
var jsonRpcRequestSchema =
|
|
9913
|
-
jsonrpc:
|
|
9914
|
-
method:
|
|
9915
|
-
params:
|
|
9916
|
-
id:
|
|
9952
|
+
var import_zod3 = require("zod");
|
|
9953
|
+
var jsonRpcRequestSchema = import_zod3.z.object({
|
|
9954
|
+
jsonrpc: import_zod3.z.literal("2.0"),
|
|
9955
|
+
method: import_zod3.z.string(),
|
|
9956
|
+
params: import_zod3.z.record(import_zod3.z.unknown()).optional(),
|
|
9957
|
+
id: import_zod3.z.union([import_zod3.z.string(), import_zod3.z.number()]).optional()
|
|
9917
9958
|
});
|
|
9918
|
-
var userMessageParamsSchema =
|
|
9919
|
-
content:
|
|
9959
|
+
var userMessageParamsSchema = import_zod3.z.object({
|
|
9960
|
+
content: import_zod3.z.string().min(1, "Content is required")
|
|
9920
9961
|
});
|
|
9921
9962
|
var commandParamsSchemas = {
|
|
9922
9963
|
user_message: userMessageParamsSchema,
|
|
9923
9964
|
"posthog/user_message": userMessageParamsSchema,
|
|
9924
|
-
cancel:
|
|
9925
|
-
"posthog/cancel":
|
|
9926
|
-
close:
|
|
9927
|
-
"posthog/close":
|
|
9965
|
+
cancel: import_zod3.z.object({}).optional(),
|
|
9966
|
+
"posthog/cancel": import_zod3.z.object({}).optional(),
|
|
9967
|
+
close: import_zod3.z.object({}).optional(),
|
|
9968
|
+
"posthog/close": import_zod3.z.object({}).optional()
|
|
9928
9969
|
};
|
|
9929
9970
|
function validateCommandParams(method, params) {
|
|
9930
9971
|
const schema = commandParamsSchemas[method] ?? commandParamsSchemas[method.replace("posthog/", "")];
|
|
@@ -10045,7 +10086,7 @@ var AgentServer = class {
|
|
|
10045
10086
|
return payload.mode ?? this.config.mode;
|
|
10046
10087
|
}
|
|
10047
10088
|
createApp() {
|
|
10048
|
-
const app = new Hono();
|
|
10089
|
+
const app = new import_hono.Hono();
|
|
10049
10090
|
app.get("/health", (c) => {
|
|
10050
10091
|
return c.json({ status: "ok", hasSession: !!this.session });
|
|
10051
10092
|
});
|
|
@@ -10178,7 +10219,7 @@ var AgentServer = class {
|
|
|
10178
10219
|
}
|
|
10179
10220
|
async start() {
|
|
10180
10221
|
await new Promise((resolve4) => {
|
|
10181
|
-
this.server = serve(
|
|
10222
|
+
this.server = (0, import_node_server.serve)(
|
|
10182
10223
|
{
|
|
10183
10224
|
fetch: this.app.fetch,
|
|
10184
10225
|
port: this.config.port
|
|
@@ -10323,13 +10364,13 @@ var AgentServer = class {
|
|
|
10323
10364
|
onAcpMessage,
|
|
10324
10365
|
this.logger
|
|
10325
10366
|
);
|
|
10326
|
-
const clientStream =
|
|
10327
|
-
const clientConnection = new ClientSideConnection(
|
|
10367
|
+
const clientStream = (0, import_sdk4.ndJsonStream)(tappedWritable, tappedReadable);
|
|
10368
|
+
const clientConnection = new import_sdk4.ClientSideConnection(
|
|
10328
10369
|
() => this.createCloudClient(payload),
|
|
10329
10370
|
clientStream
|
|
10330
10371
|
);
|
|
10331
10372
|
await clientConnection.initialize({
|
|
10332
|
-
protocolVersion: PROTOCOL_VERSION,
|
|
10373
|
+
protocolVersion: import_sdk4.PROTOCOL_VERSION,
|
|
10333
10374
|
clientCapabilities: {}
|
|
10334
10375
|
});
|
|
10335
10376
|
await clientConnection.newSession({
|
|
@@ -10504,21 +10545,21 @@ var AgentServer = class {
|
|
|
10504
10545
|
};
|
|
10505
10546
|
|
|
10506
10547
|
// src/server/bin.ts
|
|
10507
|
-
var envSchema =
|
|
10508
|
-
JWT_PUBLIC_KEY:
|
|
10548
|
+
var envSchema = import_zod4.z.object({
|
|
10549
|
+
JWT_PUBLIC_KEY: import_zod4.z.string({
|
|
10509
10550
|
required_error: "JWT_PUBLIC_KEY is required for authenticating client connections"
|
|
10510
10551
|
}).min(1, "JWT_PUBLIC_KEY cannot be empty"),
|
|
10511
|
-
POSTHOG_API_URL:
|
|
10552
|
+
POSTHOG_API_URL: import_zod4.z.string({
|
|
10512
10553
|
required_error: "POSTHOG_API_URL is required for LLM gateway communication"
|
|
10513
10554
|
}).url("POSTHOG_API_URL must be a valid URL"),
|
|
10514
|
-
POSTHOG_PERSONAL_API_KEY:
|
|
10555
|
+
POSTHOG_PERSONAL_API_KEY: import_zod4.z.string({
|
|
10515
10556
|
required_error: "POSTHOG_PERSONAL_API_KEY is required for authenticating with PostHog services"
|
|
10516
10557
|
}).min(1, "POSTHOG_PERSONAL_API_KEY cannot be empty"),
|
|
10517
|
-
POSTHOG_PROJECT_ID:
|
|
10558
|
+
POSTHOG_PROJECT_ID: import_zod4.z.string({
|
|
10518
10559
|
required_error: "POSTHOG_PROJECT_ID is required for routing requests to the correct project"
|
|
10519
10560
|
}).regex(/^\d+$/, "POSTHOG_PROJECT_ID must be a numeric string").transform((val) => parseInt(val, 10))
|
|
10520
10561
|
});
|
|
10521
|
-
var program = new Command();
|
|
10562
|
+
var program = new import_commander.Command();
|
|
10522
10563
|
program.name("agent-server").description("PostHog cloud agent server - runs in sandbox environments").option("--port <port>", "HTTP server port", "3001").option(
|
|
10523
10564
|
"--mode <mode>",
|
|
10524
10565
|
"Execution mode: interactive or background",
|
|
@@ -10555,4 +10596,4 @@ ${errors}`);
|
|
|
10555
10596
|
await server.start();
|
|
10556
10597
|
});
|
|
10557
10598
|
program.parse();
|
|
10558
|
-
//# sourceMappingURL=bin.
|
|
10599
|
+
//# sourceMappingURL=bin.cjs.map
|