@agentmark-ai/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/README.md +1 -0
  2. package/dist/.next/BUILD_ID +1 -0
  3. package/dist/.next/app-build-manifest.json +66 -0
  4. package/dist/.next/app-path-routes-manifest.json +7 -0
  5. package/dist/.next/build-manifest.json +33 -0
  6. package/dist/.next/cache/.previewinfo +1 -0
  7. package/dist/.next/cache/.rscinfo +1 -0
  8. package/dist/.next/cache/.tsbuildinfo +1 -0
  9. package/dist/.next/cache/config.json +7 -0
  10. package/dist/.next/cache/webpack/client-production/0.pack +0 -0
  11. package/dist/.next/cache/webpack/client-production/index.pack +0 -0
  12. package/dist/.next/cache/webpack/edge-server-production/0.pack +0 -0
  13. package/dist/.next/cache/webpack/edge-server-production/index.pack +0 -0
  14. package/dist/.next/cache/webpack/server-production/0.pack +0 -0
  15. package/dist/.next/cache/webpack/server-production/index.pack +0 -0
  16. package/dist/.next/diagnostics/build-diagnostics.json +6 -0
  17. package/dist/.next/diagnostics/framework.json +1 -0
  18. package/dist/.next/export-marker.json +6 -0
  19. package/dist/.next/images-manifest.json +57 -0
  20. package/dist/.next/next-minimal-server.js.nft.json +1 -0
  21. package/dist/.next/next-server.js.nft.json +1 -0
  22. package/dist/.next/package.json +1 -0
  23. package/dist/.next/prerender-manifest.json +133 -0
  24. package/dist/.next/react-loadable-manifest.json +1 -0
  25. package/dist/.next/required-server-files.json +325 -0
  26. package/dist/.next/routes-manifest.json +77 -0
  27. package/dist/.next/server/app/_not-found/page.js +2 -0
  28. package/dist/.next/server/app/_not-found/page.js.nft.json +1 -0
  29. package/dist/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
  30. package/dist/.next/server/app/_not-found.html +1 -0
  31. package/dist/.next/server/app/_not-found.meta +8 -0
  32. package/dist/.next/server/app/_not-found.rsc +19 -0
  33. package/dist/.next/server/app/index.html +1 -0
  34. package/dist/.next/server/app/index.meta +7 -0
  35. package/dist/.next/server/app/index.rsc +20 -0
  36. package/dist/.next/server/app/page.js +2 -0
  37. package/dist/.next/server/app/page.js.nft.json +1 -0
  38. package/dist/.next/server/app/page_client-reference-manifest.js +1 -0
  39. package/dist/.next/server/app/requests/page.js +2 -0
  40. package/dist/.next/server/app/requests/page.js.nft.json +1 -0
  41. package/dist/.next/server/app/requests/page_client-reference-manifest.js +1 -0
  42. package/dist/.next/server/app/requests.html +1 -0
  43. package/dist/.next/server/app/requests.meta +7 -0
  44. package/dist/.next/server/app/requests.rsc +25 -0
  45. package/dist/.next/server/app/sessions/page.js +2 -0
  46. package/dist/.next/server/app/sessions/page.js.nft.json +1 -0
  47. package/dist/.next/server/app/sessions/page_client-reference-manifest.js +1 -0
  48. package/dist/.next/server/app/sessions.html +1 -0
  49. package/dist/.next/server/app/sessions.meta +7 -0
  50. package/dist/.next/server/app/sessions.rsc +25 -0
  51. package/dist/.next/server/app/traces/page.js +2 -0
  52. package/dist/.next/server/app/traces/page.js.nft.json +1 -0
  53. package/dist/.next/server/app/traces/page_client-reference-manifest.js +1 -0
  54. package/dist/.next/server/app/traces.html +1 -0
  55. package/dist/.next/server/app/traces.meta +7 -0
  56. package/dist/.next/server/app/traces.rsc +25 -0
  57. package/dist/.next/server/app-paths-manifest.json +7 -0
  58. package/dist/.next/server/chunks/18.js +198 -0
  59. package/dist/.next/server/chunks/383.js +6 -0
  60. package/dist/.next/server/chunks/478.js +22 -0
  61. package/dist/.next/server/chunks/547.js +1 -0
  62. package/dist/.next/server/chunks/84.js +138 -0
  63. package/dist/.next/server/functions-config-manifest.json +4 -0
  64. package/dist/.next/server/interception-route-rewrite-manifest.js +1 -0
  65. package/dist/.next/server/middleware-build-manifest.js +1 -0
  66. package/dist/.next/server/middleware-manifest.json +6 -0
  67. package/dist/.next/server/middleware-react-loadable-manifest.js +1 -0
  68. package/dist/.next/server/next-font-manifest.js +1 -0
  69. package/dist/.next/server/next-font-manifest.json +1 -0
  70. package/dist/.next/server/pages/404.html +1 -0
  71. package/dist/.next/server/pages/500.html +1 -0
  72. package/dist/.next/server/pages/_app.js +1 -0
  73. package/dist/.next/server/pages/_app.js.nft.json +1 -0
  74. package/dist/.next/server/pages/_document.js +1 -0
  75. package/dist/.next/server/pages/_document.js.nft.json +1 -0
  76. package/dist/.next/server/pages/_error.js +19 -0
  77. package/dist/.next/server/pages/_error.js.nft.json +1 -0
  78. package/dist/.next/server/pages-manifest.json +6 -0
  79. package/dist/.next/server/server-reference-manifest.js +1 -0
  80. package/dist/.next/server/server-reference-manifest.json +1 -0
  81. package/dist/.next/server/webpack-runtime.js +1 -0
  82. package/dist/.next/static/WXGM4V1PBw_hLKICZoZaB/_buildManifest.js +1 -0
  83. package/dist/.next/static/WXGM4V1PBw_hLKICZoZaB/_ssgManifest.js +1 -0
  84. package/dist/.next/static/chunks/18-57c2d8d3aff89bcb.js +1 -0
  85. package/dist/.next/static/chunks/248-9028c24b6529c0c7.js +77 -0
  86. package/dist/.next/static/chunks/41-1291c1f5f295280d.js +1 -0
  87. package/dist/.next/static/chunks/602-7e76e1ee986e97d5.js +28 -0
  88. package/dist/.next/static/chunks/6b3bb038-67c653ff0a93a5bd.js +1 -0
  89. package/dist/.next/static/chunks/87c73c54-09e1ba5c70e60a51.js +1 -0
  90. package/dist/.next/static/chunks/902-50df3a419e9a9cef.js +1 -0
  91. package/dist/.next/static/chunks/app/_not-found/page-6711055aaf38bfb8.js +1 -0
  92. package/dist/.next/static/chunks/app/layout-eaddb6da201ab019.js +1 -0
  93. package/dist/.next/static/chunks/app/page-93d2401dc395548b.js +1 -0
  94. package/dist/.next/static/chunks/app/requests/page-20818b6519923653.js +1 -0
  95. package/dist/.next/static/chunks/app/sessions/page-cff6cd4b8819d0e5.js +1 -0
  96. package/dist/.next/static/chunks/app/traces/page-e556a466332fc75b.js +1 -0
  97. package/dist/.next/static/chunks/baeaa4ff-0a317ff4d32584cd.js +1 -0
  98. package/dist/.next/static/chunks/framework-3c3dfe0642f415ba.js +1 -0
  99. package/dist/.next/static/chunks/main-314a36b6249f35e5.js +1 -0
  100. package/dist/.next/static/chunks/main-app-0b5725cb98f081b4.js +1 -0
  101. package/dist/.next/static/chunks/pages/_app-d6f6b3bbc3d81ee1.js +1 -0
  102. package/dist/.next/static/chunks/pages/_error-75a96cf1997cc3b9.js +1 -0
  103. package/dist/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  104. package/dist/.next/static/chunks/webpack-f10b0ea54196b48e.js +1 -0
  105. package/dist/.next/static/css/a00826fc162bd22d.css +31 -0
  106. package/dist/.next/trace +51 -0
  107. package/dist/.next/types/app/layout.ts +84 -0
  108. package/dist/.next/types/app/page.ts +84 -0
  109. package/dist/.next/types/app/requests/page.ts +84 -0
  110. package/dist/.next/types/app/sessions/page.ts +84 -0
  111. package/dist/.next/types/app/traces/page.ts +84 -0
  112. package/dist/.next/types/cache-life.d.ts +141 -0
  113. package/dist/.next/types/package.json +1 -0
  114. package/dist/.next/types/routes.d.ts +60 -0
  115. package/dist/.next/types/validator.ts +88 -0
  116. package/dist/api-server.d.ts +1 -0
  117. package/dist/api-server.js +545 -0
  118. package/dist/api-server.js.map +1 -0
  119. package/dist/commands/build.d.ts +9 -0
  120. package/dist/commands/build.js +206 -0
  121. package/dist/commands/build.js.map +1 -0
  122. package/dist/commands/dev.d.ts +7 -0
  123. package/dist/commands/dev.js +406 -0
  124. package/dist/commands/dev.js.map +1 -0
  125. package/dist/commands/generate-types.d.ts +7 -0
  126. package/dist/commands/generate-types.js +31 -0
  127. package/dist/commands/generate-types.js.map +1 -0
  128. package/dist/commands/pull-models.d.ts +2 -0
  129. package/dist/commands/pull-models.js +105 -0
  130. package/dist/commands/pull-models.js.map +1 -0
  131. package/dist/commands/run-experiment.d.ts +7 -0
  132. package/dist/commands/run-experiment.js +579 -0
  133. package/dist/commands/run-experiment.js.map +1 -0
  134. package/dist/commands/run-prompt.d.ts +8 -0
  135. package/dist/commands/run-prompt.js +397 -0
  136. package/dist/commands/run-prompt.js.map +1 -0
  137. package/dist/config.d.ts +23 -0
  138. package/dist/config.js +170 -0
  139. package/dist/config.js.map +1 -0
  140. package/dist/cost-mapping/cost-mapping.d.ts +7 -0
  141. package/dist/cost-mapping/cost-mapping.js +36 -0
  142. package/dist/cost-mapping/cost-mapping.js.map +1 -0
  143. package/dist/index.d.ts +2 -0
  144. package/dist/index.js +127 -0
  145. package/dist/index.js.map +1 -0
  146. package/dist/runner-server/core.d.ts +15 -0
  147. package/dist/runner-server/core.js +180 -0
  148. package/dist/runner-server/core.js.map +1 -0
  149. package/dist/runner-server/middleware/signature-verification.d.ts +37 -0
  150. package/dist/runner-server/middleware/signature-verification.js +55 -0
  151. package/dist/runner-server/middleware/signature-verification.js.map +1 -0
  152. package/dist/runner-server/types.d.ts +67 -0
  153. package/dist/runner-server/types.js +7 -0
  154. package/dist/runner-server/types.js.map +1 -0
  155. package/dist/runner-server.d.ts +32 -0
  156. package/dist/runner-server.js +376 -0
  157. package/dist/runner-server.js.map +1 -0
  158. package/dist/server/database/index.d.ts +3 -0
  159. package/dist/server/database/index.js +97 -0
  160. package/dist/server/database/index.js.map +1 -0
  161. package/dist/server/routes/scores/index.d.ts +14 -0
  162. package/dist/server/routes/scores/index.js +60 -0
  163. package/dist/server/routes/scores/index.js.map +1 -0
  164. package/dist/server/routes/traces/index.d.ts +50 -0
  165. package/dist/server/routes/traces/index.js +614 -0
  166. package/dist/server/routes/traces/index.js.map +1 -0
  167. package/dist/tunnel.d.ts +19 -0
  168. package/dist/tunnel.js +134 -0
  169. package/dist/tunnel.js.map +1 -0
  170. package/dist/utils/prompt-detection.d.ts +8 -0
  171. package/dist/utils/prompt-detection.js +24 -0
  172. package/dist/utils/prompt-detection.js.map +1 -0
  173. package/dist/utils/providers.d.ts +38 -0
  174. package/dist/utils/providers.js +82 -0
  175. package/dist/utils/providers.js.map +1 -0
  176. package/next.config.ts +18 -0
  177. package/package.json +90 -0
  178. package/public/favicon.ico +0 -0
  179. package/public/file.svg +1 -0
  180. package/public/logo.svg +1 -0
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getCostFormula = exports.getModelCostMappings = void 0;
13
+ let prices = {};
14
+ const pricesUrl = "https://raw.githubusercontent.com/agentmark-ai/agentmark/refs/heads/main/packages/cli/cli-src/cost-mapping/pricing.json";
15
+ const getModelCostMappings = () => __awaiter(void 0, void 0, void 0, function* () {
16
+ if (Object.keys(prices).length > 0) {
17
+ return prices;
18
+ }
19
+ // If no prices URL configured, return empty mappings
20
+ if (!pricesUrl) {
21
+ return prices;
22
+ }
23
+ const res = yield fetch(pricesUrl);
24
+ const data = yield res.json();
25
+ prices = data;
26
+ return prices;
27
+ });
28
+ exports.getModelCostMappings = getModelCostMappings;
29
+ const getCostFormula = (inputCost, outputCost, unitScale) => {
30
+ return (inputTokens, outputTokens) => {
31
+ const cost = inputCost * inputTokens + outputCost * outputTokens;
32
+ return cost / unitScale;
33
+ };
34
+ };
35
+ exports.getCostFormula = getCostFormula;
36
+ //# sourceMappingURL=cost-mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cost-mapping.js","sourceRoot":"","sources":["../../cli-src/cost-mapping/cost-mapping.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,IAAI,MAAM,GAAqE,EAAE,CAAC;AAElF,MAAM,SAAS,GAAG,yHAAyH,CAAA;AACpI,MAAM,oBAAoB,GAAG,GAEjC,EAAE;IACH,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnC,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,qDAAqD;IACrD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,CAAA;IAClC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;IAC7B,MAAM,GAAG,IAAI,CAAA;IACb,OAAO,MAAM,CAAA;AACf,CAAC,CAAA,CAAA;AAdY,QAAA,oBAAoB,wBAchC;AAEM,MAAM,cAAc,GAAG,CAC5B,SAAiB,EACjB,UAAkB,EAClB,SAAiB,EACjB,EAAE;IACF,OAAO,CAAC,WAAmB,EAAE,YAAoB,EAAE,EAAE;QACnD,MAAM,IAAI,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,CAAC;QACjE,OAAO,IAAI,GAAG,SAAS,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,cAAc,kBASzB"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ // Load .env file from current working directory
17
+ const dotenv_1 = require("dotenv");
18
+ (0, dotenv_1.config)();
19
+ const commander_1 = require("commander");
20
+ const fs_1 = require("fs");
21
+ const path_1 = require("path");
22
+ const dev_1 = __importDefault(require("./commands/dev"));
23
+ const generate_types_1 = __importDefault(require("./commands/generate-types"));
24
+ const pull_models_1 = __importDefault(require("./commands/pull-models"));
25
+ const run_prompt_1 = __importDefault(require("./commands/run-prompt"));
26
+ const run_experiment_1 = __importDefault(require("./commands/run-experiment"));
27
+ const build_1 = __importDefault(require("./commands/build"));
28
+ // Read version from package.json
29
+ const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../package.json'), 'utf-8'));
30
+ commander_1.program
31
+ .version(packageJson.version, '-v, --version', 'Output the current version')
32
+ .name('agentmark')
33
+ .description('AgentMark CLI - Build, test, and deploy AI agents');
34
+ commander_1.program
35
+ .command("dev")
36
+ .option("--api-port <number>", "API server port (default: 9418)")
37
+ .option("--webhook-port <number>", "Webhook server port (default: 9417)")
38
+ .option("--app-port <number>", "AgentMark UI app port (default: 3000)")
39
+ .option("-t, --tunnel", "Expose webhook server publicly via tunnel")
40
+ .description("Start development servers (API server + webhook + UI app)")
41
+ .action((options) => __awaiter(void 0, void 0, void 0, function* () {
42
+ yield dev_1.default({
43
+ apiPort: options.apiPort ? parseInt(options.apiPort, 10) : undefined,
44
+ webhookPort: options.webhookPort ? parseInt(options.webhookPort, 10) : undefined,
45
+ appPort: options.appPort ? parseInt(options.appPort, 10) : undefined,
46
+ tunnel: options.tunnel || false
47
+ });
48
+ }));
49
+ commander_1.program
50
+ .command('generate-types')
51
+ .option('-l, --language <language>', 'Language to generate types for', 'typescript')
52
+ .option('--local <port>', 'Local server port number')
53
+ .option('--root-dir <path>', 'Root directory containing agentmark files')
54
+ .action((options) => __awaiter(void 0, void 0, void 0, function* () {
55
+ const localPort = options.local ? parseInt(options.local, 10) : undefined;
56
+ yield generate_types_1.default({
57
+ language: options.language,
58
+ local: localPort,
59
+ rootDir: options.rootDir
60
+ });
61
+ }));
62
+ commander_1.program
63
+ .command("pull-models")
64
+ .description('Pull models from a provider')
65
+ .action(() => __awaiter(void 0, void 0, void 0, function* () {
66
+ try {
67
+ yield pull_models_1.default();
68
+ }
69
+ catch (error) {
70
+ commander_1.program.error(error.message);
71
+ }
72
+ }));
73
+ commander_1.program
74
+ .command("run-prompt <filepath>")
75
+ .description('Run a prompt with test props')
76
+ .option('--server <url>', 'URL of an AgentMark webhook server (e.g., http://localhost:9417)')
77
+ .option('--props <json>', 'Props as JSON string (e.g., \'{"key": "value"}\')')
78
+ .option('--props-file <path>', 'Path to JSON or YAML file containing props')
79
+ .action((filepath, options) => __awaiter(void 0, void 0, void 0, function* () {
80
+ try {
81
+ yield run_prompt_1.default(filepath, options);
82
+ }
83
+ catch (error) {
84
+ commander_1.program.error(error.message);
85
+ }
86
+ }));
87
+ commander_1.program
88
+ .command("run-experiment <filepath>")
89
+ .description('Run an experiment against its dataset, with evals by default')
90
+ .option('--server <url>', 'URL of an AgentMark webhook server (e.g., http://localhost:9417)')
91
+ .option('--skip-eval', 'Skip running evals even if they exist')
92
+ .option('--format <format>', 'Output format: table, csv, json, or jsonl (default: table)')
93
+ .option('--threshold <percent>', 'Fail if pass percentage is below threshold (0-100)', (v) => {
94
+ const n = parseInt(v, 10);
95
+ if (!Number.isFinite(n))
96
+ throw new Error('Threshold must be a number');
97
+ if (n < 0 || n > 100)
98
+ throw new Error('Threshold must be between 0 and 100');
99
+ return n;
100
+ })
101
+ .action((filepath, options) => __awaiter(void 0, void 0, void 0, function* () {
102
+ try {
103
+ const format = options.format || 'table';
104
+ if (!['table', 'csv', 'json', 'jsonl'].includes(format)) {
105
+ throw new Error('Format must be one of: table, csv, json, jsonl');
106
+ }
107
+ const thresholdPercent = typeof options.threshold === 'number' ? options.threshold : undefined;
108
+ yield run_experiment_1.default(filepath, { skipEval: !!options.skipEval, format, thresholdPercent, server: options.server });
109
+ }
110
+ catch (error) {
111
+ commander_1.program.error(error.message);
112
+ }
113
+ }));
114
+ commander_1.program
115
+ .command("build")
116
+ .description('Build prompts and datasets into pre-compiled JSON files for static loading')
117
+ .option('-o, --out <directory>', 'Output directory (default: dist/agentmark)')
118
+ .action((options) => __awaiter(void 0, void 0, void 0, function* () {
119
+ try {
120
+ yield build_1.default({ outDir: options.out });
121
+ }
122
+ catch (error) {
123
+ commander_1.program.error(error.message);
124
+ }
125
+ }));
126
+ commander_1.program.parse(process.argv);
127
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../cli-src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,gDAAgD;AAChD,mCAAgC;AAChC,IAAA,eAAM,GAAE,CAAC;AAET,yCAAoC;AACpC,2BAAkC;AAClC,+BAA4B;AAC5B,yDAAiC;AACjC,+EAAsD;AACtD,yEAAgD;AAChD,uEAA8C;AAC9C,+EAAsD;AACtD,6DAAqC;AAErC,iCAAiC;AACjC,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAE1F,mBAAO;KACJ,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,eAAe,EAAE,4BAA4B,CAAC;KAC3E,IAAI,CAAC,WAAW,CAAC;KACjB,WAAW,CAAC,mDAAmD,CAAC,CAAC;AAEpE,mBAAO;KACJ,OAAO,CAAC,KAAK,CAAC;KACd,MAAM,CAAC,qBAAqB,EAAE,iCAAiC,CAAC;KAChE,MAAM,CAAC,yBAAyB,EAAE,qCAAqC,CAAC;KACxE,MAAM,CAAC,qBAAqB,EAAE,uCAAuC,CAAC;KACtE,MAAM,CAAC,cAAc,EAAE,2C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AACH,CAAC,CAAA,CAAC,CAAC;AAEL,mBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Core platform-agnostic handler for AgentMark webhook requests.
3
+ * This handler processes requests from any platform adapter and returns
4
+ * a standardized response that adapters can translate to platform-specific formats.
5
+ */
6
+ import type { WebhookHandler, WebhookRequest, WebhookResponse } from './types';
7
+ /**
8
+ * Handles a webhook request and returns a platform-agnostic response.
9
+ * This is the core business logic that all platform adapters use.
10
+ *
11
+ * @param request - The standardized webhook request
12
+ * @param handler - The webhook handler instance (e.g., VercelAdapterWebhookHandler)
13
+ * @returns A standardized response that adapters translate to platform formats
14
+ */
15
+ export declare function handleWebhookRequest(request: WebhookRequest, handler: WebhookHandler): Promise<WebhookResponse>;
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ /**
3
+ * Core platform-agnostic handler for AgentMark webhook requests.
4
+ * This handler processes requests from any platform adapter and returns
5
+ * a standardized response that adapters can translate to platform-specific formats.
6
+ */
7
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
+ return new (P || (P = Promise))(function (resolve, reject) {
10
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
14
+ });
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.handleWebhookRequest = handleWebhookRequest;
18
+ /**
19
+ * Handles a webhook request and returns a platform-agnostic response.
20
+ * This is the core business logic that all platform adapters use.
21
+ *
22
+ * @param request - The standardized webhook request
23
+ * @param handler - The webhook handler instance (e.g., VercelAdapterWebhookHandler)
24
+ * @returns A standardized response that adapters translate to platform formats
25
+ */
26
+ function handleWebhookRequest(request, handler) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ var _a, _b;
29
+ try {
30
+ const { type, data } = request;
31
+ // Log the event type with more detail
32
+ if (!type) {
33
+ console.log(` ⚠️ Event: missing 'type' field`);
34
+ // Check for common mistakes
35
+ const anyRequest = request;
36
+ if (anyRequest.event) {
37
+ console.log(` 💡 Found nested 'event' wrapper`);
38
+ console.log(` ❌ Incorrect: { "event": { "type": "...", "data": {...} } }`);
39
+ console.log(` ✅ Correct: { "type": "...", "data": {...} }`);
40
+ }
41
+ else {
42
+ console.log(` 📦 Request body:`, JSON.stringify(request, null, 2));
43
+ }
44
+ return {
45
+ type: 'error',
46
+ error: 'Missing event type',
47
+ details: 'Request must include a "type" field at the top level: {"type": "prompt-run", "data": {...}}',
48
+ status: 400
49
+ };
50
+ }
51
+ console.log(` 📝 Event: ${type}`);
52
+ // Validate known event types
53
+ if (type !== 'prompt-run' && type !== 'dataset-run') {
54
+ console.log(` ⚠️ Unknown event type: ${type}`);
55
+ console.log(` Valid types: "prompt-run", "dataset-run"`);
56
+ return {
57
+ type: 'error',
58
+ error: 'Unknown event type',
59
+ details: `Expected event.type to be 'prompt-run' or 'dataset-run', got: ${type}`,
60
+ status: 400
61
+ };
62
+ }
63
+ // Validate request structure
64
+ if (!data) {
65
+ console.log(` ⚠️ Missing 'data' field in request`);
66
+ return {
67
+ type: 'error',
68
+ error: 'Missing data object',
69
+ details: 'Request must include a "data" object with the prompt AST and options',
70
+ status: 400
71
+ };
72
+ }
73
+ // Validate AST field
74
+ if (!data.ast) {
75
+ console.log(` ⚠️ Missing 'data.ast' field`);
76
+ console.log(` 📦 Available fields in data:`, Object.keys(data).join(', '));
77
+ // Check for common mistakes
78
+ const anyData = data;
79
+ if (anyData.prompt) {
80
+ console.log(` 💡 Found 'data.prompt' but expected 'data.ast'`);
81
+ console.log(` ❌ Incorrect: { "data": { "prompt": {...} } }`);
82
+ console.log(` ✅ Correct: { "data": { "ast": {...} } }`);
83
+ }
84
+ return {
85
+ type: 'error',
86
+ error: 'Missing AST object',
87
+ details: 'The request must include the prompt AST in data.ast (not data.prompt)',
88
+ status: 400
89
+ };
90
+ }
91
+ if (typeof data.ast !== 'object') {
92
+ console.log(` ⚠️ Invalid AST type: ${typeof data.ast} (expected object)`);
93
+ return {
94
+ type: 'error',
95
+ error: 'Invalid AST type',
96
+ details: `The AST must be an object, got ${typeof data.ast}`,
97
+ status: 400
98
+ };
99
+ }
100
+ // Handle prompt execution
101
+ if (type === 'prompt-run') {
102
+ console.log(' 🤖 Executing prompt...');
103
+ const options = {
104
+ shouldStream: (_a = data.options) === null || _a === void 0 ? void 0 : _a.shouldStream,
105
+ customProps: data.customProps,
106
+ };
107
+ const response = yield handler.runPrompt(data.ast, options);
108
+ // Handle streaming response
109
+ if (response.type === 'stream') {
110
+ console.log(' ✓ Prompt executed successfully (streaming)');
111
+ return {
112
+ type: 'stream',
113
+ stream: response.stream,
114
+ headers: response.streamHeader || { 'AgentMark-Streaming': 'true' },
115
+ traceId: response.traceId
116
+ };
117
+ }
118
+ // Handle regular JSON response (text, object, image, speech)
119
+ console.log(' ✓ Prompt executed successfully');
120
+ return {
121
+ type: 'json',
122
+ data: response,
123
+ status: 200
124
+ };
125
+ }
126
+ // Handle dataset/experiment execution
127
+ if (type === 'dataset-run') {
128
+ console.log(' 🧪 Running experiment with dataset...');
129
+ const experimentId = (_b = data.experimentId) !== null && _b !== void 0 ? _b : 'local-experiment';
130
+ let response;
131
+ try {
132
+ response = yield handler.runExperiment(data.ast, experimentId, data.datasetPath);
133
+ }
134
+ catch (e) {
135
+ const errorMessage = (e === null || e === void 0 ? void 0 : e.message) || String(e);
136
+ console.log(` ❌ Experiment failed: ${errorMessage}`);
137
+ return {
138
+ type: 'error',
139
+ error: errorMessage,
140
+ details: 'An error occurred while running the experiment. Check that your prompt and dataset are valid.',
141
+ status: 500
142
+ };
143
+ }
144
+ // Dataset runs always return streams
145
+ if (response === null || response === void 0 ? void 0 : response.stream) {
146
+ console.log(' ✓ Experiment started successfully (streaming)');
147
+ return {
148
+ type: 'stream',
149
+ stream: response.stream,
150
+ headers: response.streamHeaders || { 'AgentMark-Streaming': 'true' }
151
+ };
152
+ }
153
+ console.log(' ❌ Experiment failed: No stream returned');
154
+ return {
155
+ type: 'error',
156
+ error: 'Expected stream from dataset-run',
157
+ details: 'Dataset execution should return a streaming response',
158
+ status: 500
159
+ };
160
+ }
161
+ // Unknown event type
162
+ return {
163
+ type: 'error',
164
+ error: 'Unknown event type',
165
+ details: `Expected event.type to be 'prompt-run' or 'dataset-run', got: ${type || 'undefined'}`,
166
+ status: 400
167
+ };
168
+ }
169
+ catch (e) {
170
+ const errorMessage = (e === null || e === void 0 ? void 0 : e.message) || String(e);
171
+ return {
172
+ type: 'error',
173
+ error: 'Webhook handler error',
174
+ details: errorMessage,
175
+ status: 500
176
+ };
177
+ }
178
+ });
179
+ }
180
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../cli-src/runner-server/core.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;AAYH,oDA4KC;AApLD;;;;;;;GAOG;AACH,SAAsB,oBAAoB,CACxC,OAAuB,EACvB,OAAuB;;;QAEvB,IAAI,CAAC;YACH,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;YAE/B,sCAAsC;YACtC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;gBAElD,4BAA4B;gBAC5B,MAAM,UAAU,GAAG,OAAc,CAAC;gBAClC,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;oBACrB,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;oBAClD,OAAO,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;oBAC7E,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CA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AE,QAAQ,CAAC,MAAM;wBACvB,OAAO,EAAE,QAAQ,CAAC,aAAa,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE;qBACrE,CAAC;gBACJ,CAAC;gBAED,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;gBAC1D,OAAO;oBACL,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,kCAAkC;oBACzC,OAAO,EAAE,sDAAsD;oBAC/D,MAAM,EAAE,GAAG;iBACZ,CAAC;YACJ,CAAC;YAED,qBAAqB;YACrB,OAAO;gBACL,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,oBAAoB;gBAC3B,OAAO,EAAE,iEAAiE,IAAI,IAAI,WAAW,EAAE;gBAC/F,MAAM,EAAE,GAAG;aACZ,CAAC;QAEJ,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,YAAY,GAAG,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,OAAO,KAAI,MAAM,CAAC,CAAC,CAAC,CAAC;YAE7C,OAAO;gBACL,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,uBAAuB;gBAC9B,OAAO,EAAE,YAAY;gBACrB,MAAM,EAAE,GAAG;aACZ,CAAC;QACJ,CAAC;IACH,CAAC;CAAA"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Webhook signature verification middleware for securing webhook endpoints.
3
+ * Uses HMAC-SHA256 signatures to verify requests are from trusted sources.
4
+ */
5
+ export interface SignatureVerificationOptions {
6
+ /**
7
+ * The secret key used to verify webhook signatures.
8
+ * Should match the secret used by the sender to create the signature.
9
+ */
10
+ secret: string;
11
+ /**
12
+ * The name of the header containing the signature.
13
+ * Defaults to 'x-agentmark-signature-256'
14
+ */
15
+ headerName?: string;
16
+ /**
17
+ * Whether to skip verification (useful for local development).
18
+ * Defaults to false.
19
+ */
20
+ skipVerification?: boolean;
21
+ }
22
+ /**
23
+ * Verifies the webhook signature from the request.
24
+ *
25
+ * @param body - The request body as a string
26
+ * @param signature - The signature from the request header
27
+ * @param secret - The webhook secret
28
+ * @returns True if signature is valid, false otherwise
29
+ */
30
+ export declare function verifyWebhookSignature(body: string, signature: string, secret: string): Promise<boolean>;
31
+ /**
32
+ * Checks if signature verification should be enforced based on environment.
33
+ *
34
+ * @param options - Signature verification options
35
+ * @returns True if verification should be skipped
36
+ */
37
+ export declare function shouldSkipVerification(options: SignatureVerificationOptions): boolean;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ /**
3
+ * Webhook signature verification middleware for securing webhook endpoints.
4
+ * Uses HMAC-SHA256 signatures to verify requests are from trusted sources.
5
+ */
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.verifyWebhookSignature = verifyWebhookSignature;
17
+ exports.shouldSkipVerification = shouldSkipVerification;
18
+ const shared_utils_1 = require("@agentmark-ai/shared-utils");
19
+ /**
20
+ * Verifies the webhook signature from the request.
21
+ *
22
+ * @param body - The request body as a string
23
+ * @param signature - The signature from the request header
24
+ * @param secret - The webhook secret
25
+ * @returns True if signature is valid, false otherwise
26
+ */
27
+ function verifyWebhookSignature(body, signature, secret) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ try {
30
+ return yield (0, shared_utils_1.verifySignature)(secret, signature, body);
31
+ }
32
+ catch (error) {
33
+ console.error('Signature verification error:', error);
34
+ return false;
35
+ }
36
+ });
37
+ }
38
+ /**
39
+ * Checks if signature verification should be enforced based on environment.
40
+ *
41
+ * @param options - Signature verification options
42
+ * @returns True if verification should be skipped
43
+ */
44
+ function shouldSkipVerification(options) {
45
+ // Skip if explicitly disabled
46
+ if (options.skipVerification) {
47
+ return true;
48
+ }
49
+ // Skip if no secret is provided (local dev without secret)
50
+ if (!options.secret || options.secret === 'DEFAULT') {
51
+ return true;
52
+ }
53
+ return false;
54
+ }
55
+ //# sourceMappingURL=signature-verification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature-verification.js","sourceRoot":"","sources":["../../../cli-src/runner-server/middleware/signature-verification.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;AAgCH,wDAWC;AAQD,wDAYC;AA7DD,6DAA6D;AAsB7D;;;;;;;GAOG;AACH,SAAsB,sBAAsB,CAC1C,IAAY,EACZ,SAAiB,EACjB,MAAc;;QAEd,IAAI,CAAC;YACH,OAAO,MAAM,IAAA,8BAAe,EAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;QACxD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;YACtD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CAAA;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,OAAqC;IAC1E,8BAA8B;IAC9B,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,2DAA2D;IAC3D,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Platform-agnostic types for the AgentMark webhook server.
3
+ * These types are used by the core handler and all platform adapters.
4
+ */
5
+ import type { WebhookPromptResponse, WebhookDatasetResponse } from '@agentmark-ai/prompt-core';
6
+ /**
7
+ * Telemetry options for tracking prompt execution.
8
+ */
9
+ export interface TelemetryOptions {
10
+ isEnabled: boolean;
11
+ metadata?: {
12
+ traceId?: string;
13
+ traceName?: string;
14
+ sessionId?: string;
15
+ sessionName?: string;
16
+ [key: string]: any;
17
+ };
18
+ }
19
+ /**
20
+ * Generic webhook handler interface that any adapter can implement.
21
+ * This is the contract that adapters (e.g., VercelAdapterWebhookHandler) must fulfill.
22
+ */
23
+ export interface WebhookHandler {
24
+ runPrompt(promptAst: any, options?: {
25
+ shouldStream?: boolean;
26
+ customProps?: Record<string, any>;
27
+ telemetry?: TelemetryOptions;
28
+ }): Promise<WebhookPromptResponse>;
29
+ runExperiment(promptAst: any, datasetRunName: string, datasetPath?: string): Promise<WebhookDatasetResponse>;
30
+ }
31
+ /**
32
+ * Standardized request format for all platform adapters.
33
+ * Platform adapters translate their specific request formats into this structure.
34
+ */
35
+ export interface WebhookRequest {
36
+ type: 'prompt-run' | 'dataset-run';
37
+ data: {
38
+ ast: any;
39
+ customProps?: Record<string, any>;
40
+ options?: {
41
+ shouldStream?: boolean;
42
+ };
43
+ experimentId?: string;
44
+ datasetPath?: string;
45
+ promptPath?: string;
46
+ };
47
+ }
48
+ /**
49
+ * Standardized response format from the core handler.
50
+ * Platform adapters translate this into their specific response formats.
51
+ */
52
+ export type WebhookResponse = {
53
+ type: 'json';
54
+ data: any;
55
+ status?: number;
56
+ } | {
57
+ type: 'stream';
58
+ stream: ReadableStream;
59
+ headers: Record<string, string>;
60
+ traceId?: string;
61
+ } | {
62
+ type: 'error';
63
+ error: string;
64
+ details?: string;
65
+ status: number;
66
+ };
67
+ export type { WebhookPromptResponse, WebhookDatasetResponse } from '@agentmark-ai/prompt-core';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Platform-agnostic types for the AgentMark webhook server.
4
+ * These types are used by the core handler and all platform adapters.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../cli-src/runner-server/types.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * AgentMark Webhook Server
3
+ *
4
+ * This file provides the webhook server for local development,
5
+ * used to execute prompts and experiments via Express.
6
+ */
7
+ import { Server } from 'node:http';
8
+ import type { WebhookHandler } from './runner-server/types';
9
+ import { type SignatureVerificationOptions } from './runner-server/middleware/signature-verification';
10
+ export type { WebhookHandler } from './runner-server/types';
11
+ export interface WebhookServerOptions {
12
+ port?: number;
13
+ handler: WebhookHandler;
14
+ apiServerUrl?: string;
15
+ templatesDirectory?: string;
16
+ /**
17
+ * Webhook signature verification options.
18
+ * If not provided, will check AGENTMARK_WEBHOOK_SECRET env var.
19
+ */
20
+ signatureVerification?: SignatureVerificationOptions;
21
+ }
22
+ /**
23
+ * Creates an HTTP server that wraps a webhook handler instance.
24
+ * This server provides endpoints for executing prompts and experiments via HTTP.
25
+ * Used by the CLI and local development workflows.
26
+ *
27
+ * @param options - Server configuration options
28
+ * @returns HTTP server instance
29
+ */
30
+ export declare function createWebhookServer(options: WebhookServerOptions): Promise<Server>;
31
+ export { handleWebhookRequest } from './runner-server/core';
32
+ export type { WebhookRequest, WebhookResponse } from './runner-server/types';