agentv 0.13.0 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -75,6 +75,10 @@ You are now ready to start development. The monorepo contains:
75
75
 
76
76
  ## Quick Start
77
77
 
78
+ You can use the following examples as a starting point.
79
+ - [Simple Example](docs/examples/simple/README.md): A minimal working example to help you get started fast.
80
+ - [Showcase](docs/examples/showcase/README.md): A collection of advanced use cases and real-world agent evaluation scenarios.
81
+
78
82
  ### Validating Eval Files
79
83
 
80
84
  Validate your eval and targets files before running them:
@@ -388,15 +392,11 @@ targets:
388
392
  - Respects abort signals for cancellation
389
393
  - If no retry config is specified, uses sensible defaults
390
394
 
391
- ## Resources
392
-
393
- - [Simple Example README](docs/examples/simple/README.md)
394
- - [Ax ACE Documentation](https://github.com/ax-llm/ax/blob/main/docs/ACE.md)
395
-
396
395
  ## Related Projects
397
396
 
398
397
  - [subagent](https://github.com/EntityProcess/subagent) - VS Code Copilot programmatic interface
399
- - [Ax](https://github.com/axflow/axflow) - TypeScript LLM framework
398
+ - [ai-sdk](https://github.com/vercel/ai) - Vercel AI SDK
399
+ - [Agentic Context Engineering (ACE)](https://github.com/ax-llm/ax/blob/main/docs/ACE.md)
400
400
 
401
401
  ## License
402
402
 
@@ -0,0 +1,86 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+
37
+ // ../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/token-error.js
38
+ var require_token_error = __commonJS({
39
+ "../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/token-error.js"(exports, module) {
40
+ "use strict";
41
+ var __defProp2 = Object.defineProperty;
42
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
43
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
44
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
45
+ var __export2 = (target, all) => {
46
+ for (var name in all)
47
+ __defProp2(target, name, { get: all[name], enumerable: true });
48
+ };
49
+ var __copyProps2 = (to, from, except, desc) => {
50
+ if (from && typeof from === "object" || typeof from === "function") {
51
+ for (let key of __getOwnPropNames2(from))
52
+ if (!__hasOwnProp2.call(to, key) && key !== except)
53
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
54
+ }
55
+ return to;
56
+ };
57
+ var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
58
+ var token_error_exports = {};
59
+ __export2(token_error_exports, {
60
+ VercelOidcTokenError: () => VercelOidcTokenError
61
+ });
62
+ module.exports = __toCommonJS(token_error_exports);
63
+ var VercelOidcTokenError = class extends Error {
64
+ constructor(message, cause) {
65
+ super(message);
66
+ this.name = "VercelOidcTokenError";
67
+ this.cause = cause;
68
+ }
69
+ toString() {
70
+ if (this.cause) {
71
+ return `${this.name}: ${this.message}: ${this.cause}`;
72
+ }
73
+ return `${this.name}: ${this.message}`;
74
+ }
75
+ };
76
+ }
77
+ });
78
+
79
+ export {
80
+ __require,
81
+ __commonJS,
82
+ __export,
83
+ __toESM,
84
+ require_token_error
85
+ };
86
+ //# sourceMappingURL=chunk-7XYYGJAC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/token-error.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar token_error_exports = {};\n__export(token_error_exports, {\n VercelOidcTokenError: () => VercelOidcTokenError\n});\nmodule.exports = __toCommonJS(token_error_exports);\nclass VercelOidcTokenError extends Error {\n constructor(message, cause) {\n super(message);\n this.name = \"VercelOidcTokenError\";\n this.cause = cause;\n }\n toString() {\n if (this.cause) {\n return `${this.name}: ${this.message}: ${this.cause}`;\n }\n return `${this.name}: ${this.message}`;\n }\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n VercelOidcTokenError\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AACA,QAAIA,aAAY,OAAO;AACvB,QAAIC,oBAAmB,OAAO;AAC9B,QAAIC,qBAAoB,OAAO;AAC/B,QAAIC,gBAAe,OAAO,UAAU;AACpC,QAAIC,YAAW,CAAC,QAAQ,QAAQ;AAC9B,eAAS,QAAQ;AACf,QAAAJ,WAAU,QAAQ,MAAM,EAAE,KAAK,IAAI,IAAI,GAAG,YAAY,KAAK,CAAC;AAAA,IAChE;AACA,QAAIK,eAAc,CAAC,IAAI,MAAM,QAAQ,SAAS;AAC5C,UAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;AAClE,iBAAS,OAAOH,mBAAkB,IAAI;AACpC,cAAI,CAACC,cAAa,KAAK,IAAI,GAAG,KAAK,QAAQ;AACzC,YAAAH,WAAU,IAAI,KAAK,EAAE,KAAK,MAAM,KAAK,GAAG,GAAG,YAAY,EAAE,OAAOC,kBAAiB,MAAM,GAAG,MAAM,KAAK,WAAW,CAAC;AAAA,MACvH;AACA,aAAO;AAAA,IACT;AACA,QAAI,eAAe,CAAC,QAAQI,aAAYL,WAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,QAAI,sBAAsB,CAAC;AAC3B,IAAAI,UAAS,qBAAqB;AAAA,MAC5B,sBAAsB,MAAM;AAAA,IAC9B,CAAC;AACD,WAAO,UAAU,aAAa,mBAAmB;AACjD,QAAM,uBAAN,cAAmC,MAAM;AAAA,MACvC,YAAY,SAAS,OAAO;AAC1B,cAAM,OAAO;AACb,aAAK,OAAO;AACZ,aAAK,QAAQ;AAAA,MACf;AAAA,MACA,WAAW;AACT,YAAI,KAAK,OAAO;AACd,iBAAO,GAAG,KAAK,IAAI,KAAK,KAAK,OAAO,KAAK,KAAK,KAAK;AAAA,QACrD;AACA,eAAO,GAAG,KAAK,IAAI,KAAK,KAAK,OAAO;AAAA,MACtC;AAAA,IACF;AAAA;AAAA;","names":["__defProp","__getOwnPropDesc","__getOwnPropNames","__hasOwnProp","__export","__copyProps"]}
@@ -0,0 +1,258 @@
1
+ import {
2
+ __commonJS,
3
+ __require,
4
+ require_token_error
5
+ } from "./chunk-7XYYGJAC.js";
6
+
7
+ // ../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/token-io.js
8
+ var require_token_io = __commonJS({
9
+ "../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/token-io.js"(exports, module) {
10
+ "use strict";
11
+ var __create = Object.create;
12
+ var __defProp = Object.defineProperty;
13
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
14
+ var __getOwnPropNames = Object.getOwnPropertyNames;
15
+ var __getProtoOf = Object.getPrototypeOf;
16
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
17
+ var __export = (target, all) => {
18
+ for (var name in all)
19
+ __defProp(target, name, { get: all[name], enumerable: true });
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (let key of __getOwnPropNames(from))
24
+ if (!__hasOwnProp.call(to, key) && key !== except)
25
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
26
+ }
27
+ return to;
28
+ };
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var token_io_exports = {};
39
+ __export(token_io_exports, {
40
+ findRootDir: () => findRootDir,
41
+ getUserDataDir: () => getUserDataDir
42
+ });
43
+ module.exports = __toCommonJS(token_io_exports);
44
+ var import_path = __toESM(__require("path"));
45
+ var import_fs = __toESM(__require("fs"));
46
+ var import_os = __toESM(__require("os"));
47
+ var import_token_error = require_token_error();
48
+ function findRootDir() {
49
+ try {
50
+ let dir = process.cwd();
51
+ while (dir !== import_path.default.dirname(dir)) {
52
+ const pkgPath = import_path.default.join(dir, ".vercel");
53
+ if (import_fs.default.existsSync(pkgPath)) {
54
+ return dir;
55
+ }
56
+ dir = import_path.default.dirname(dir);
57
+ }
58
+ } catch (e) {
59
+ throw new import_token_error.VercelOidcTokenError(
60
+ "Token refresh only supported in node server environments"
61
+ );
62
+ }
63
+ throw new import_token_error.VercelOidcTokenError("Unable to find root directory");
64
+ }
65
+ function getUserDataDir() {
66
+ if (process.env.XDG_DATA_HOME) {
67
+ return process.env.XDG_DATA_HOME;
68
+ }
69
+ switch (import_os.default.platform()) {
70
+ case "darwin":
71
+ return import_path.default.join(import_os.default.homedir(), "Library/Application Support");
72
+ case "linux":
73
+ return import_path.default.join(import_os.default.homedir(), ".local/share");
74
+ case "win32":
75
+ if (process.env.LOCALAPPDATA) {
76
+ return process.env.LOCALAPPDATA;
77
+ }
78
+ return null;
79
+ default:
80
+ return null;
81
+ }
82
+ }
83
+ }
84
+ });
85
+
86
+ // ../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/token-util.js
87
+ var require_token_util = __commonJS({
88
+ "../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/token-util.js"(exports, module) {
89
+ var __create = Object.create;
90
+ var __defProp = Object.defineProperty;
91
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
92
+ var __getOwnPropNames = Object.getOwnPropertyNames;
93
+ var __getProtoOf = Object.getPrototypeOf;
94
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
95
+ var __export = (target, all) => {
96
+ for (var name in all)
97
+ __defProp(target, name, { get: all[name], enumerable: true });
98
+ };
99
+ var __copyProps = (to, from, except, desc) => {
100
+ if (from && typeof from === "object" || typeof from === "function") {
101
+ for (let key of __getOwnPropNames(from))
102
+ if (!__hasOwnProp.call(to, key) && key !== except)
103
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
104
+ }
105
+ return to;
106
+ };
107
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
108
+ // If the importer is in node compatibility mode or this is not an ESM
109
+ // file that has been converted to a CommonJS file using a Babel-
110
+ // compatible transform (i.e. "__esModule" has not been set), then set
111
+ // "default" to the CommonJS "module.exports" for node compatibility.
112
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
113
+ mod
114
+ ));
115
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
116
+ var token_util_exports = {};
117
+ __export(token_util_exports, {
118
+ assertVercelOidcTokenResponse: () => assertVercelOidcTokenResponse,
119
+ findProjectInfo: () => findProjectInfo,
120
+ getTokenPayload: () => getTokenPayload,
121
+ getVercelCliToken: () => getVercelCliToken,
122
+ getVercelDataDir: () => getVercelDataDir,
123
+ getVercelOidcToken: () => getVercelOidcToken,
124
+ isExpired: () => isExpired,
125
+ loadToken: () => loadToken,
126
+ saveToken: () => saveToken
127
+ });
128
+ module.exports = __toCommonJS(token_util_exports);
129
+ var path = __toESM(__require("path"));
130
+ var fs = __toESM(__require("fs"));
131
+ var import_token_error = require_token_error();
132
+ var import_token_io = require_token_io();
133
+ function getVercelDataDir() {
134
+ const vercelFolder = "com.vercel.cli";
135
+ const dataDir = (0, import_token_io.getUserDataDir)();
136
+ if (!dataDir) {
137
+ return null;
138
+ }
139
+ return path.join(dataDir, vercelFolder);
140
+ }
141
+ function getVercelCliToken() {
142
+ const dataDir = getVercelDataDir();
143
+ if (!dataDir) {
144
+ return null;
145
+ }
146
+ const tokenPath = path.join(dataDir, "auth.json");
147
+ if (!fs.existsSync(tokenPath)) {
148
+ return null;
149
+ }
150
+ const token = fs.readFileSync(tokenPath, "utf8");
151
+ if (!token) {
152
+ return null;
153
+ }
154
+ return JSON.parse(token).token;
155
+ }
156
+ async function getVercelOidcToken(authToken, projectId, teamId) {
157
+ try {
158
+ const url = `https://api.vercel.com/v1/projects/${projectId}/token?source=vercel-oidc-refresh${teamId ? `&teamId=${teamId}` : ""}`;
159
+ const res = await fetch(url, {
160
+ method: "POST",
161
+ headers: {
162
+ Authorization: `Bearer ${authToken}`
163
+ }
164
+ });
165
+ if (!res.ok) {
166
+ throw new import_token_error.VercelOidcTokenError(
167
+ `Failed to refresh OIDC token: ${res.statusText}`
168
+ );
169
+ }
170
+ const tokenRes = await res.json();
171
+ assertVercelOidcTokenResponse(tokenRes);
172
+ return tokenRes;
173
+ } catch (e) {
174
+ throw new import_token_error.VercelOidcTokenError(`Failed to refresh OIDC token`, e);
175
+ }
176
+ }
177
+ function assertVercelOidcTokenResponse(res) {
178
+ if (!res || typeof res !== "object") {
179
+ throw new TypeError("Expected an object");
180
+ }
181
+ if (!("token" in res) || typeof res.token !== "string") {
182
+ throw new TypeError("Expected a string-valued token property");
183
+ }
184
+ }
185
+ function findProjectInfo() {
186
+ const dir = (0, import_token_io.findRootDir)();
187
+ if (!dir) {
188
+ throw new import_token_error.VercelOidcTokenError("Unable to find root directory");
189
+ }
190
+ try {
191
+ const prjPath = path.join(dir, ".vercel", "project.json");
192
+ if (!fs.existsSync(prjPath)) {
193
+ throw new import_token_error.VercelOidcTokenError("project.json not found");
194
+ }
195
+ const prj = JSON.parse(fs.readFileSync(prjPath, "utf8"));
196
+ if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
197
+ throw new TypeError("Expected a string-valued projectId property");
198
+ }
199
+ return { projectId: prj.projectId, teamId: prj.orgId };
200
+ } catch (e) {
201
+ throw new import_token_error.VercelOidcTokenError(`Unable to find project ID`, e);
202
+ }
203
+ }
204
+ function saveToken(token, projectId) {
205
+ try {
206
+ const dir = (0, import_token_io.getUserDataDir)();
207
+ if (!dir) {
208
+ throw new import_token_error.VercelOidcTokenError("Unable to find user data directory");
209
+ }
210
+ const tokenPath = path.join(dir, "com.vercel.token", `${projectId}.json`);
211
+ const tokenJson = JSON.stringify(token);
212
+ fs.mkdirSync(path.dirname(tokenPath), { mode: 504, recursive: true });
213
+ fs.writeFileSync(tokenPath, tokenJson);
214
+ fs.chmodSync(tokenPath, 432);
215
+ return;
216
+ } catch (e) {
217
+ throw new import_token_error.VercelOidcTokenError(`Failed to save token`, e);
218
+ }
219
+ }
220
+ function loadToken(projectId) {
221
+ try {
222
+ const dir = (0, import_token_io.getUserDataDir)();
223
+ if (!dir) {
224
+ return null;
225
+ }
226
+ const tokenPath = path.join(dir, "com.vercel.token", `${projectId}.json`);
227
+ if (!fs.existsSync(tokenPath)) {
228
+ return null;
229
+ }
230
+ const token = JSON.parse(fs.readFileSync(tokenPath, "utf8"));
231
+ assertVercelOidcTokenResponse(token);
232
+ return token;
233
+ } catch (e) {
234
+ throw new import_token_error.VercelOidcTokenError(`Failed to load token`, e);
235
+ }
236
+ }
237
+ function getTokenPayload(token) {
238
+ const tokenParts = token.split(".");
239
+ if (tokenParts.length !== 3) {
240
+ throw new import_token_error.VercelOidcTokenError("Invalid token");
241
+ }
242
+ const base64 = tokenParts[1].replace(/-/g, "+").replace(/_/g, "/");
243
+ const padded = base64.padEnd(
244
+ base64.length + (4 - base64.length % 4) % 4,
245
+ "="
246
+ );
247
+ return JSON.parse(Buffer.from(padded, "base64").toString("utf8"));
248
+ }
249
+ function isExpired(token) {
250
+ return token.exp * 1e3 < Date.now();
251
+ }
252
+ }
253
+ });
254
+
255
+ export {
256
+ require_token_util
257
+ };
258
+ //# sourceMappingURL=chunk-D44RV4HN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/token-io.js","../../../node_modules/.pnpm/@vercel+oidc@3.0.5/node_modules/@vercel/oidc/dist/token-util.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar token_io_exports = {};\n__export(token_io_exports, {\n findRootDir: () => findRootDir,\n getUserDataDir: () => getUserDataDir\n});\nmodule.exports = __toCommonJS(token_io_exports);\nvar import_path = __toESM(require(\"path\"));\nvar import_fs = __toESM(require(\"fs\"));\nvar import_os = __toESM(require(\"os\"));\nvar import_token_error = require(\"./token-error\");\nfunction findRootDir() {\n try {\n let dir = process.cwd();\n while (dir !== import_path.default.dirname(dir)) {\n const pkgPath = import_path.default.join(dir, \".vercel\");\n if (import_fs.default.existsSync(pkgPath)) {\n return dir;\n }\n dir = import_path.default.dirname(dir);\n }\n } catch (e) {\n throw new import_token_error.VercelOidcTokenError(\n \"Token refresh only supported in node server environments\"\n );\n }\n throw new import_token_error.VercelOidcTokenError(\"Unable to find root directory\");\n}\nfunction getUserDataDir() {\n if (process.env.XDG_DATA_HOME) {\n return process.env.XDG_DATA_HOME;\n }\n switch (import_os.default.platform()) {\n case \"darwin\":\n return import_path.default.join(import_os.default.homedir(), \"Library/Application Support\");\n case \"linux\":\n return import_path.default.join(import_os.default.homedir(), \".local/share\");\n case \"win32\":\n if (process.env.LOCALAPPDATA) {\n return process.env.LOCALAPPDATA;\n }\n return null;\n default:\n return null;\n }\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n findRootDir,\n getUserDataDir\n});\n","\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar token_util_exports = {};\n__export(token_util_exports, {\n assertVercelOidcTokenResponse: () => assertVercelOidcTokenResponse,\n findProjectInfo: () => findProjectInfo,\n getTokenPayload: () => getTokenPayload,\n getVercelCliToken: () => getVercelCliToken,\n getVercelDataDir: () => getVercelDataDir,\n getVercelOidcToken: () => getVercelOidcToken,\n isExpired: () => isExpired,\n loadToken: () => loadToken,\n saveToken: () => saveToken\n});\nmodule.exports = __toCommonJS(token_util_exports);\nvar path = __toESM(require(\"path\"));\nvar fs = __toESM(require(\"fs\"));\nvar import_token_error = require(\"./token-error\");\nvar import_token_io = require(\"./token-io\");\nfunction getVercelDataDir() {\n const vercelFolder = \"com.vercel.cli\";\n const dataDir = (0, import_token_io.getUserDataDir)();\n if (!dataDir) {\n return null;\n }\n return path.join(dataDir, vercelFolder);\n}\nfunction getVercelCliToken() {\n const dataDir = getVercelDataDir();\n if (!dataDir) {\n return null;\n }\n const tokenPath = path.join(dataDir, \"auth.json\");\n if (!fs.existsSync(tokenPath)) {\n return null;\n }\n const token = fs.readFileSync(tokenPath, \"utf8\");\n if (!token) {\n return null;\n }\n return JSON.parse(token).token;\n}\nasync function getVercelOidcToken(authToken, projectId, teamId) {\n try {\n const url = `https://api.vercel.com/v1/projects/${projectId}/token?source=vercel-oidc-refresh${teamId ? `&teamId=${teamId}` : \"\"}`;\n const res = await fetch(url, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${authToken}`\n }\n });\n if (!res.ok) {\n throw new import_token_error.VercelOidcTokenError(\n `Failed to refresh OIDC token: ${res.statusText}`\n );\n }\n const tokenRes = await res.json();\n assertVercelOidcTokenResponse(tokenRes);\n return tokenRes;\n } catch (e) {\n throw new import_token_error.VercelOidcTokenError(`Failed to refresh OIDC token`, e);\n }\n}\nfunction assertVercelOidcTokenResponse(res) {\n if (!res || typeof res !== \"object\") {\n throw new TypeError(\"Expected an object\");\n }\n if (!(\"token\" in res) || typeof res.token !== \"string\") {\n throw new TypeError(\"Expected a string-valued token property\");\n }\n}\nfunction findProjectInfo() {\n const dir = (0, import_token_io.findRootDir)();\n if (!dir) {\n throw new import_token_error.VercelOidcTokenError(\"Unable to find root directory\");\n }\n try {\n const prjPath = path.join(dir, \".vercel\", \"project.json\");\n if (!fs.existsSync(prjPath)) {\n throw new import_token_error.VercelOidcTokenError(\"project.json not found\");\n }\n const prj = JSON.parse(fs.readFileSync(prjPath, \"utf8\"));\n if (typeof prj.projectId !== \"string\" && typeof prj.orgId !== \"string\") {\n throw new TypeError(\"Expected a string-valued projectId property\");\n }\n return { projectId: prj.projectId, teamId: prj.orgId };\n } catch (e) {\n throw new import_token_error.VercelOidcTokenError(`Unable to find project ID`, e);\n }\n}\nfunction saveToken(token, projectId) {\n try {\n const dir = (0, import_token_io.getUserDataDir)();\n if (!dir) {\n throw new import_token_error.VercelOidcTokenError(\"Unable to find user data directory\");\n }\n const tokenPath = path.join(dir, \"com.vercel.token\", `${projectId}.json`);\n const tokenJson = JSON.stringify(token);\n fs.mkdirSync(path.dirname(tokenPath), { mode: 504, recursive: true });\n fs.writeFileSync(tokenPath, tokenJson);\n fs.chmodSync(tokenPath, 432);\n return;\n } catch (e) {\n throw new import_token_error.VercelOidcTokenError(`Failed to save token`, e);\n }\n}\nfunction loadToken(projectId) {\n try {\n const dir = (0, import_token_io.getUserDataDir)();\n if (!dir) {\n return null;\n }\n const tokenPath = path.join(dir, \"com.vercel.token\", `${projectId}.json`);\n if (!fs.existsSync(tokenPath)) {\n return null;\n }\n const token = JSON.parse(fs.readFileSync(tokenPath, \"utf8\"));\n assertVercelOidcTokenResponse(token);\n return token;\n } catch (e) {\n throw new import_token_error.VercelOidcTokenError(`Failed to load token`, e);\n }\n}\nfunction getTokenPayload(token) {\n const tokenParts = token.split(\".\");\n if (tokenParts.length !== 3) {\n throw new import_token_error.VercelOidcTokenError(\"Invalid token\");\n }\n const base64 = tokenParts[1].replace(/-/g, \"+\").replace(/_/g, \"/\");\n const padded = base64.padEnd(\n base64.length + (4 - base64.length % 4) % 4,\n \"=\"\n );\n return JSON.parse(Buffer.from(padded, \"base64\").toString(\"utf8\"));\n}\nfunction isExpired(token) {\n return token.exp * 1e3 < Date.now();\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n assertVercelOidcTokenResponse,\n findProjectInfo,\n getTokenPayload,\n getVercelCliToken,\n getVercelDataDir,\n getVercelOidcToken,\n isExpired,\n loadToken,\n saveToken\n});\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AACA,QAAI,WAAW,OAAO;AACtB,QAAI,YAAY,OAAO;AACvB,QAAI,mBAAmB,OAAO;AAC9B,QAAI,oBAAoB,OAAO;AAC/B,QAAI,eAAe,OAAO;AAC1B,QAAI,eAAe,OAAO,UAAU;AACpC,QAAI,WAAW,CAAC,QAAQ,QAAQ;AAC9B,eAAS,QAAQ;AACf,kBAAU,QAAQ,MAAM,EAAE,KAAK,IAAI,IAAI,GAAG,YAAY,KAAK,CAAC;AAAA,IAChE;AACA,QAAI,cAAc,CAAC,IAAI,MAAM,QAAQ,SAAS;AAC5C,UAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;AAClE,iBAAS,OAAO,kBAAkB,IAAI;AACpC,cAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ;AACzC,sBAAU,IAAI,KAAK,EAAE,KAAK,MAAM,KAAK,GAAG,GAAG,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK,WAAW,CAAC;AAAA,MACvH;AACA,aAAO;AAAA,IACT;AACA,QAAI,UAAU,CAAC,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa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