@sylphx/flow 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/assets/slash-commands/context.md +112 -0
  2. package/dist/{chunk-f6y5vttn.js → chunk-13awccns.js} +3 -3
  3. package/dist/{chunk-f6y5vttn.js.map → chunk-13awccns.js.map} +1 -1
  4. package/dist/chunk-1qp4nx2f.js +76 -0
  5. package/dist/{chunk-878q8xdr.js.map → chunk-1qp4nx2f.js.map} +3 -14
  6. package/dist/{chunk-fxwaa2mg.js → chunk-40c8zeb0.js} +1 -1
  7. package/dist/{chunk-0h7sfwq3.js → chunk-4dhthe08.js} +3 -3
  8. package/dist/{chunk-0h7sfwq3.js.map → chunk-4dhthe08.js.map} +2 -2
  9. package/dist/{chunk-124wqbdb.js → chunk-5qb65n40.js} +3 -3
  10. package/dist/{chunk-124wqbdb.js.map → chunk-5qb65n40.js.map} +1 -1
  11. package/dist/{chunk-e966bjm5.js → chunk-689g5js2.js} +2 -2
  12. package/dist/{chunk-e966bjm5.js.map → chunk-689g5js2.js.map} +1 -1
  13. package/dist/{chunk-hshjnpm0.js → chunk-99z4z52k.js} +2 -2
  14. package/dist/{chunk-hshjnpm0.js.map → chunk-99z4z52k.js.map} +1 -1
  15. package/dist/{chunk-jxny6xft.js → chunk-9dbwckry.js} +2 -2
  16. package/dist/{chunk-jxny6xft.js.map → chunk-9dbwckry.js.map} +1 -1
  17. package/dist/chunk-9x8s5xdb.js +16 -0
  18. package/dist/chunk-9x8s5xdb.js.map +10 -0
  19. package/dist/{chunk-hs3nxzyz.js → chunk-jth5s5rd.js} +2 -2
  20. package/dist/{chunk-hs3nxzyz.js.map → chunk-jth5s5rd.js.map} +1 -1
  21. package/dist/{chunk-4p754rhd.js → chunk-mdc9ef4e.js} +2 -2
  22. package/dist/{chunk-4p754rhd.js.map → chunk-mdc9ef4e.js.map} +1 -1
  23. package/dist/{chunk-646h52kd.js → chunk-q3dv05ma.js} +3 -3
  24. package/dist/{chunk-646h52kd.js.map → chunk-q3dv05ma.js.map} +1 -1
  25. package/dist/chunk-qm7xz0bm.js +7 -0
  26. package/dist/{chunk-ygdr4fw7.js.map → chunk-qm7xz0bm.js.map} +2 -2
  27. package/dist/chunk-tv05bzde.js +107 -0
  28. package/dist/chunk-tv05bzde.js.map +66 -0
  29. package/dist/{chunk-5r4afhzp.js → chunk-tzar2j0k.js} +3 -3
  30. package/dist/{chunk-5r4afhzp.js.map → chunk-tzar2j0k.js.map} +1 -1
  31. package/dist/{chunk-bd11hvvz.js → chunk-vg15k2nk.js} +2 -2
  32. package/dist/{chunk-bd11hvvz.js.map → chunk-vg15k2nk.js.map} +1 -1
  33. package/dist/chunk-xhm04nkk.js +4 -0
  34. package/dist/{chunk-g9t3me0w.js.map → chunk-xhm04nkk.js.map} +2 -2
  35. package/dist/{chunk-qa8b725g.js → chunk-xwe9eaaf.js} +3 -3
  36. package/dist/{chunk-qa8b725g.js.map → chunk-xwe9eaaf.js.map} +1 -1
  37. package/dist/{chunk-wpe7rw5c.js → chunk-yj831xk5.js} +3 -3
  38. package/dist/{chunk-wpe7rw5c.js.map → chunk-yj831xk5.js.map} +1 -1
  39. package/dist/{chunk-78bfvh46.js → chunk-yredmasr.js} +2 -2
  40. package/dist/{chunk-78bfvh46.js.map → chunk-yredmasr.js.map} +1 -1
  41. package/dist/chunk-z30mabwt.js +14 -0
  42. package/dist/chunk-z30mabwt.js.map +20 -0
  43. package/dist/index.js +437 -453
  44. package/dist/index.js.map +270 -67
  45. package/package.json +2 -1
  46. package/dist/chunk-878q8xdr.js +0 -86
  47. package/dist/chunk-g9t3me0w.js +0 -4
  48. package/dist/chunk-ygdr4fw7.js +0 -7
  49. /package/dist/{chunk-fxwaa2mg.js.map → chunk-40c8zeb0.js.map} +0 -0
@@ -0,0 +1,112 @@
1
+ ---
2
+ description: Display current context window usage and token breakdown
3
+ ---
4
+
5
+ # Context Window Usage
6
+
7
+ Display detailed information about the current context window usage, including token counts for different components.
8
+
9
+ ## Your Task
10
+
11
+ Analyze and display the context window usage with the following sections:
12
+
13
+ ### 1. Model Information
14
+ Show the current model being used and its token limits.
15
+
16
+ ### 2. Visual Token Usage Bar
17
+ Create a visual bar chart (10 blocks wide) showing token usage breakdown using these Unicode characters:
18
+ - ⛁ (filled) - Used tokens
19
+ - ⛀ (half-filled) - Partially used blocks
20
+ - ⛶ (empty) - Reserved/System tokens
21
+ - ⛝ (light) - Free space/buffer
22
+
23
+ ### 3. Token Breakdown
24
+
25
+ Calculate and display tokens for each category:
26
+
27
+ #### System Prompt
28
+ - Count tokens in the system prompt
29
+ - Show: `⛁ System prompt: X.Xk tokens (X.X%)`
30
+
31
+ #### System Tools
32
+ - Count tokens for all built-in tool definitions (filesystem, shell, search, interaction tools)
33
+ - Show: `⛁ System tools: X.Xk tokens (X.X%)`
34
+
35
+ #### MCP Tools
36
+ - Count tokens for all MCP tool definitions
37
+ - List each MCP tool with its token count
38
+ - Show: `⛁ MCP tools: X.Xk tokens (X.X%)`
39
+
40
+ #### Custom Agents
41
+ - Count tokens for custom agent definitions (if any)
42
+ - List each agent with token count
43
+ - Show: `⛁ Custom agents: X tokens (X.X%)`
44
+
45
+ #### Messages
46
+ - Count tokens in all messages in the current session
47
+ - Show: `⛁ Messages: X tokens (X.X%)`
48
+
49
+ #### Free Space
50
+ - Calculate remaining available tokens
51
+ - Show: `⛶ Free space: XXXk (XX.X%)`
52
+
53
+ #### Autocompact Buffer
54
+ - Calculate reserved buffer space (typically 22.5% of total)
55
+ - Show: `⛝ Autocompact buffer: XX.Xk tokens (XX.X%)`
56
+
57
+ ### 4. Detailed Listings
58
+
59
+ Show expandable sections with details:
60
+
61
+ ```
62
+ MCP tools · /mcp
63
+ └ mcp__tool_name (server-name): XXX tokens
64
+ └ ...
65
+
66
+ Custom agents · /agents
67
+ └ agent-name (Project): XX tokens
68
+ └ ...
69
+
70
+ SlashCommand Tool · X commands
71
+ └ Total: XXX tokens
72
+ ```
73
+
74
+ ## Display Format
75
+
76
+ Use this exact format for the output:
77
+
78
+ ```
79
+ Context Usage
80
+ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛀ ⛁ ⛁ model-name · XXk/XXXk tokens (XX%)
81
+ ⛀ ⛀ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶
82
+ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: X.Xk tokens (X.X%)
83
+ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: XX.Xk tokens (X.X%)
84
+ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ MCP tools: X.Xk tokens (X.X%)
85
+ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Custom agents: XX tokens (X.X%)
86
+ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Messages: XXX tokens (X.X%)
87
+ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛝ ⛝ ⛝ ⛶ Free space: XXXk (XX.X%)
88
+ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ Autocompact buffer: XX.Xk tokens (XX.X%)
89
+ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝
90
+
91
+ MCP tools · /mcp
92
+ └ tool_name (server-name): XXX tokens
93
+ └ ...
94
+
95
+ Custom agents · /agents
96
+ └ agent-name (Project): XX tokens
97
+ └ ...
98
+
99
+ SlashCommand Tool · X commands
100
+ └ Total: XXX tokens
101
+ ```
102
+
103
+ ## Implementation Notes
104
+
105
+ 1. Use the `countTokens()` utility from `src/utils/token-counter.ts` with the current session model name
106
+ 2. Get current session from app store to access model name and messages
107
+ 3. Get system prompt from `src/core/ai-sdk.ts` (SYSTEM_PROMPT constant)
108
+ 4. Get tool definitions from `src/tools/registry.ts` (getAISDKTools())
109
+ 5. Calculate percentages based on the model's max token limit (e.g., 200k for Claude Sonnet 4.5)
110
+ 6. Round token counts appropriately (show decimals for k, no decimals for raw numbers)
111
+ 7. Ensure the bar chart accurately represents the proportions
112
+ 8. Use proper indentation and alignment for readability
@@ -1,4 +1,4 @@
1
- import{w as J}from"./chunk-wpe7rw5c.js";import{wa as C,ya as W}from"./chunk-hshjnpm0.js";var V=C((zq,u)=>{var{create:x,defineProperty:X,getOwnPropertyDescriptor:D,getOwnPropertyNames:S,getPrototypeOf:I}=Object,M=Object.prototype.hasOwnProperty,y=(q,z)=>{for(var B in z)X(q,B,{get:z[B],enumerable:!0})},w=(q,z,B,F)=>{if(z&&typeof z==="object"||typeof z==="function"){for(let G of S(z))if(!M.call(q,G)&&G!==B)X(q,G,{get:()=>z[G],enumerable:!(F=D(z,G))||F.enumerable})}return q},v=(q,z,B)=>(B=q!=null?x(I(q)):{},w(z||!q||!q.__esModule?X(B,"default",{value:q,enumerable:!0}):B,q)),g=(q)=>w(X({},"__esModule",{value:!0}),q),R={};y(R,{findRootDir:()=>l,getUserDataDir:()=>P});u.exports=g(R);var Q=v(W("path")),h=v(W("fs")),$=v(W("os")),b=J();function l(){try{let q=process.cwd();while(q!==Q.default.dirname(q)){let z=Q.default.join(q,".vercel");if(h.default.existsSync(z))return q;q=Q.default.dirname(q)}}catch(q){throw new b.VercelOidcTokenError("Token refresh only supported in node server environments")}throw new b.VercelOidcTokenError("Unable to find root directory")}function P(){if(process.env.XDG_DATA_HOME)return process.env.XDG_DATA_HOME;switch($.default.platform()){case"darwin":return Q.default.join($.default.homedir(),"Library/Application Support");case"linux":return Q.default.join($.default.homedir(),".local/share");case"win32":if(process.env.LOCALAPPDATA)return process.env.LOCALAPPDATA;return null;default:return null}}});var qq=C((Bq,j)=>{var{create:c,defineProperty:Y,getOwnPropertyDescriptor:f,getOwnPropertyNames:k,getPrototypeOf:i}=Object,s=Object.prototype.hasOwnProperty,n=(q,z)=>{for(var B in z)Y(q,B,{get:z[B],enumerable:!0})},N=(q,z,B,F)=>{if(z&&typeof z==="object"||typeof z==="function"){for(let G of k(z))if(!s.call(q,G)&&G!==B)Y(q,G,{get:()=>z[G],enumerable:!(F=f(z,G))||F.enumerable})}return q},E=(q,z,B)=>(B=q!=null?c(i(q)):{},N(z||!q||!q.__esModule?Y(B,"default",{value:q,enumerable:!0}):B,q)),p=(q)=>N(Y({},"__esModule",{value:!0}),q),O={};n(O,{assertVercelOidcTokenResponse:()=>A,findProjectInfo:()=>m,getTokenPayload:()=>t,getVercelCliToken:()=>d,getVercelDataDir:()=>T,getVercelOidcToken:()=>a,isExpired:()=>o,loadToken:()=>r,saveToken:()=>_});j.exports=p(O);var L=E(W("path")),H=E(W("fs")),K=J(),Z=V();function T(){let z=(0,Z.getUserDataDir)();if(!z)return null;return L.join(z,"com.vercel.cli")}function d(){let q=T();if(!q)return null;let z=L.join(q,"auth.json");if(!H.existsSync(z))return null;let B=H.readFileSync(z,"utf8");if(!B)return null;return JSON.parse(B).token}async function a(q,z,B){try{let F=`https://api.vercel.com/v1/projects/${z}/token?source=vercel-oidc-refresh${B?`&teamId=${B}`:""}`,G=await fetch(F,{method:"POST",headers:{Authorization:`Bearer ${q}`}});if(!G.ok)throw new K.VercelOidcTokenError(`Failed to refresh OIDC token: ${G.statusText}`);let U=await G.json();return A(U),U}catch(F){throw new K.VercelOidcTokenError("Failed to refresh OIDC token",F)}}function A(q){if(!q||typeof q!=="object")throw TypeError("Expected an object");if(!("token"in q)||typeof q.token!=="string")throw TypeError("Expected a string-valued token property")}function m(){let q=(0,Z.findRootDir)();if(!q)throw new K.VercelOidcTokenError("Unable to find root directory");try{let z=L.join(q,".vercel","project.json");if(!H.existsSync(z))throw new K.VercelOidcTokenError("project.json not found");let B=JSON.parse(H.readFileSync(z,"utf8"));if(typeof B.projectId!=="string"&&typeof B.orgId!=="string")throw TypeError("Expected a string-valued projectId property");return{projectId:B.projectId,teamId:B.orgId}}catch(z){throw new K.VercelOidcTokenError("Unable to find project ID",z)}}function _(q,z){try{let B=(0,Z.getUserDataDir)();if(!B)throw new K.VercelOidcTokenError("Unable to find user data directory");let F=L.join(B,"com.vercel.token",`${z}.json`),G=JSON.stringify(q);H.mkdirSync(L.dirname(F),{mode:432,recursive:!0}),H.writeFileSync(F,G),H.chmodSync(F,432);return}catch(B){throw new K.VercelOidcTokenError("Failed to save token",B)}}function r(q){try{let z=(0,Z.getUserDataDir)();if(!z)return null;let B=L.join(z,"com.vercel.token",`${q}.json`);if(!H.existsSync(B))return null;let F=JSON.parse(H.readFileSync(B,"utf8"));return A(F),F}catch(z){throw new K.VercelOidcTokenError("Failed to load token",z)}}function t(q){let z=q.split(".");if(z.length!==3)throw new K.VercelOidcTokenError("Invalid token");let B=z[1].replace(/-/g,"+").replace(/_/g,"/"),F=B.padEnd(B.length+(4-B.length%4)%4,"=");return JSON.parse(Buffer.from(F,"base64").toString("utf8"))}var e=900000;function o(q){return q.exp*1000<Date.now()+e}});export default qq();
2
- export{qq as v};
1
+ import{D as J}from"./chunk-yj831xk5.js";import{Sa as C,Ua as W}from"./chunk-99z4z52k.js";var V=C((zq,u)=>{var{create:x,defineProperty:X,getOwnPropertyDescriptor:D,getOwnPropertyNames:S,getPrototypeOf:I}=Object,M=Object.prototype.hasOwnProperty,y=(q,z)=>{for(var B in z)X(q,B,{get:z[B],enumerable:!0})},w=(q,z,B,F)=>{if(z&&typeof z==="object"||typeof z==="function"){for(let G of S(z))if(!M.call(q,G)&&G!==B)X(q,G,{get:()=>z[G],enumerable:!(F=D(z,G))||F.enumerable})}return q},v=(q,z,B)=>(B=q!=null?x(I(q)):{},w(z||!q||!q.__esModule?X(B,"default",{value:q,enumerable:!0}):B,q)),g=(q)=>w(X({},"__esModule",{value:!0}),q),R={};y(R,{findRootDir:()=>l,getUserDataDir:()=>P});u.exports=g(R);var Q=v(W("path")),h=v(W("fs")),$=v(W("os")),b=J();function l(){try{let q=process.cwd();while(q!==Q.default.dirname(q)){let z=Q.default.join(q,".vercel");if(h.default.existsSync(z))return q;q=Q.default.dirname(q)}}catch(q){throw new b.VercelOidcTokenError("Token refresh only supported in node server environments")}throw new b.VercelOidcTokenError("Unable to find root directory")}function P(){if(process.env.XDG_DATA_HOME)return process.env.XDG_DATA_HOME;switch($.default.platform()){case"darwin":return Q.default.join($.default.homedir(),"Library/Application Support");case"linux":return Q.default.join($.default.homedir(),".local/share");case"win32":if(process.env.LOCALAPPDATA)return process.env.LOCALAPPDATA;return null;default:return null}}});var qq=C((Bq,j)=>{var{create:c,defineProperty:Y,getOwnPropertyDescriptor:f,getOwnPropertyNames:k,getPrototypeOf:i}=Object,s=Object.prototype.hasOwnProperty,n=(q,z)=>{for(var B in z)Y(q,B,{get:z[B],enumerable:!0})},N=(q,z,B,F)=>{if(z&&typeof z==="object"||typeof z==="function"){for(let G of k(z))if(!s.call(q,G)&&G!==B)Y(q,G,{get:()=>z[G],enumerable:!(F=f(z,G))||F.enumerable})}return q},E=(q,z,B)=>(B=q!=null?c(i(q)):{},N(z||!q||!q.__esModule?Y(B,"default",{value:q,enumerable:!0}):B,q)),p=(q)=>N(Y({},"__esModule",{value:!0}),q),O={};n(O,{assertVercelOidcTokenResponse:()=>A,findProjectInfo:()=>m,getTokenPayload:()=>t,getVercelCliToken:()=>d,getVercelDataDir:()=>T,getVercelOidcToken:()=>a,isExpired:()=>o,loadToken:()=>r,saveToken:()=>_});j.exports=p(O);var L=E(W("path")),H=E(W("fs")),K=J(),Z=V();function T(){let z=(0,Z.getUserDataDir)();if(!z)return null;return L.join(z,"com.vercel.cli")}function d(){let q=T();if(!q)return null;let z=L.join(q,"auth.json");if(!H.existsSync(z))return null;let B=H.readFileSync(z,"utf8");if(!B)return null;return JSON.parse(B).token}async function a(q,z,B){try{let F=`https://api.vercel.com/v1/projects/${z}/token?source=vercel-oidc-refresh${B?`&teamId=${B}`:""}`,G=await fetch(F,{method:"POST",headers:{Authorization:`Bearer ${q}`}});if(!G.ok)throw new K.VercelOidcTokenError(`Failed to refresh OIDC token: ${G.statusText}`);let U=await G.json();return A(U),U}catch(F){throw new K.VercelOidcTokenError("Failed to refresh OIDC token",F)}}function A(q){if(!q||typeof q!=="object")throw TypeError("Expected an object");if(!("token"in q)||typeof q.token!=="string")throw TypeError("Expected a string-valued token property")}function m(){let q=(0,Z.findRootDir)();if(!q)throw new K.VercelOidcTokenError("Unable to find root directory");try{let z=L.join(q,".vercel","project.json");if(!H.existsSync(z))throw new K.VercelOidcTokenError("project.json not found");let B=JSON.parse(H.readFileSync(z,"utf8"));if(typeof B.projectId!=="string"&&typeof B.orgId!=="string")throw TypeError("Expected a string-valued projectId property");return{projectId:B.projectId,teamId:B.orgId}}catch(z){throw new K.VercelOidcTokenError("Unable to find project ID",z)}}function _(q,z){try{let B=(0,Z.getUserDataDir)();if(!B)throw new K.VercelOidcTokenError("Unable to find user data directory");let F=L.join(B,"com.vercel.token",`${z}.json`),G=JSON.stringify(q);H.mkdirSync(L.dirname(F),{mode:432,recursive:!0}),H.writeFileSync(F,G),H.chmodSync(F,432);return}catch(B){throw new K.VercelOidcTokenError("Failed to save token",B)}}function r(q){try{let z=(0,Z.getUserDataDir)();if(!z)return null;let B=L.join(z,"com.vercel.token",`${q}.json`);if(!H.existsSync(B))return null;let F=JSON.parse(H.readFileSync(B,"utf8"));return A(F),F}catch(z){throw new K.VercelOidcTokenError("Failed to load token",z)}}function t(q){let z=q.split(".");if(z.length!==3)throw new K.VercelOidcTokenError("Invalid token");let B=z[1].replace(/-/g,"+").replace(/_/g,"/"),F=B.padEnd(B.length+(4-B.length%4)%4,"=");return JSON.parse(Buffer.from(F,"base64").toString("utf8"))}var e=900000;function o(q){return q.exp*1000<Date.now()+e}});export default qq();
2
+ export{qq as C};
3
3
 
4
- //# debugId=F199DBDABF403A1F64756E2164756E21
4
+ //# debugId=E63C1B1CED90D38C64756E2164756E21
@@ -6,6 +6,6 @@
6
6
  "\"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: 432, 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}\nconst TIME_15_MINUTES_IN_MS = 15 * 60 * 1e3;\nfunction isExpired(token) {\n return token.exp * 1e3 < Date.now() + TIME_15_MINUTES_IN_MS;\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"
7
7
  ],
8
8
  "mappings": "gHACA,FAAsB,OAAlB,EACmB,eAAnB,EAC0B,yBAA1B,EAC2B,oBAA3B,EACsB,eAAtB,GAHY,O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