@hugomrdias/fil 0.0.0-stage → 0.0.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.
- package/LICENSE +21 -0
- package/README.md +136 -2
- package/bin/fil.js +7 -0
- package/dist/chunks/_esm-BBXTTBLC.js +9 -0
- package/dist/chunks/_esm-BBXTTBLC.js.map +7 -0
- package/dist/chunks/ccip-TGFMQFIR.js +3 -0
- package/dist/chunks/ccip-TGFMQFIR.js.map +7 -0
- package/dist/chunks/chunk-2KPBBDBJ.js +3 -0
- package/dist/chunks/chunk-2KPBBDBJ.js.map +7 -0
- package/dist/chunks/chunk-35V77X3C.js +12 -0
- package/dist/chunks/chunk-35V77X3C.js.map +7 -0
- package/dist/chunks/chunk-46FBFEBX.js +3 -0
- package/dist/chunks/chunk-46FBFEBX.js.map +7 -0
- package/dist/chunks/chunk-4BBXH7CB.js +6 -0
- package/dist/chunks/chunk-4BBXH7CB.js.map +7 -0
- package/dist/chunks/chunk-4DUACCJB.js +186 -0
- package/dist/chunks/chunk-4DUACCJB.js.map +7 -0
- package/dist/chunks/chunk-5EYSPKTK.js +3 -0
- package/dist/chunks/chunk-5EYSPKTK.js.map +7 -0
- package/dist/chunks/chunk-7MEK5RQ7.js +11 -0
- package/dist/chunks/chunk-7MEK5RQ7.js.map +7 -0
- package/dist/chunks/chunk-7WN6TT5U.js +4 -0
- package/dist/chunks/chunk-7WN6TT5U.js.map +7 -0
- package/dist/chunks/chunk-CU3SGKNA.js +3 -0
- package/dist/chunks/chunk-CU3SGKNA.js.map +7 -0
- package/dist/chunks/chunk-EDF5XCIN.js +4 -0
- package/dist/chunks/chunk-EDF5XCIN.js.map +7 -0
- package/dist/chunks/chunk-GVAFHRPJ.js +124 -0
- package/dist/chunks/chunk-GVAFHRPJ.js.map +7 -0
- package/dist/chunks/chunk-IJ2NNDTJ.js +3 -0
- package/dist/chunks/chunk-IJ2NNDTJ.js.map +7 -0
- package/dist/chunks/chunk-ISML2NA2.js +3 -0
- package/dist/chunks/chunk-ISML2NA2.js.map +7 -0
- package/dist/chunks/chunk-KAQPCD23.js +4 -0
- package/dist/chunks/chunk-KAQPCD23.js.map +7 -0
- package/dist/chunks/chunk-LOTWVNDB.js +3 -0
- package/dist/chunks/chunk-LOTWVNDB.js.map +7 -0
- package/dist/chunks/chunk-NPYAGWD6.js +4 -0
- package/dist/chunks/chunk-NPYAGWD6.js.map +7 -0
- package/dist/chunks/chunk-QYPR6473.js +3 -0
- package/dist/chunks/chunk-QYPR6473.js.map +7 -0
- package/dist/chunks/chunk-RK6JJQZL.js +41 -0
- package/dist/chunks/chunk-RK6JJQZL.js.map +7 -0
- package/dist/chunks/chunk-UJQDDRQD.js +59 -0
- package/dist/chunks/chunk-UJQDDRQD.js.map +7 -0
- package/dist/chunks/chunk-UVXTIEPU.js +4 -0
- package/dist/chunks/chunk-UVXTIEPU.js.map +7 -0
- package/dist/chunks/chunk-VTR7BON5.js +4 -0
- package/dist/chunks/chunk-VTR7BON5.js.map +7 -0
- package/dist/chunks/chunk-XQRC2SUG.js +4 -0
- package/dist/chunks/chunk-XQRC2SUG.js.map +7 -0
- package/dist/chunks/chunk-YIAP3JO3.js +3 -0
- package/dist/chunks/chunk-YIAP3JO3.js.map +7 -0
- package/dist/chunks/chunk-ZD6MKB4J.js +5 -0
- package/dist/chunks/chunk-ZD6MKB4J.js.map +7 -0
- package/dist/chunks/delete-XVYLEMHB.js +3 -0
- package/dist/chunks/delete-XVYLEMHB.js.map +7 -0
- package/dist/chunks/doctor-2W65SQJS.js +3 -0
- package/dist/chunks/doctor-2W65SQJS.js.map +7 -0
- package/dist/chunks/get-ZP66WVWT.js +3 -0
- package/dist/chunks/get-ZP66WVWT.js.map +7 -0
- package/dist/chunks/inspect-HV2SQPTB.js +3 -0
- package/dist/chunks/inspect-HV2SQPTB.js.map +7 -0
- package/dist/chunks/inspect-PQCV7LQT.js +3 -0
- package/dist/chunks/inspect-PQCV7LQT.js.map +7 -0
- package/dist/chunks/login-GQ4PM7SA.js +4 -0
- package/dist/chunks/login-GQ4PM7SA.js.map +7 -0
- package/dist/chunks/logout-7N23QWWM.js +3 -0
- package/dist/chunks/logout-7N23QWWM.js.map +7 -0
- package/dist/chunks/ls-7XYH5VPL.js +3 -0
- package/dist/chunks/ls-7XYH5VPL.js.map +7 -0
- package/dist/chunks/ls-ARM57VNR.js +3 -0
- package/dist/chunks/ls-ARM57VNR.js.map +7 -0
- package/dist/chunks/map-error-7POTPJ7R.js +3 -0
- package/dist/chunks/map-error-7POTPJ7R.js.map +7 -0
- package/dist/chunks/put-EHRNCZHT.js +3 -0
- package/dist/chunks/put-EHRNCZHT.js.map +7 -0
- package/dist/chunks/resume-RLZB7L3C.js +3 -0
- package/dist/chunks/resume-RLZB7L3C.js.map +7 -0
- package/dist/chunks/secp256k1-2OHXXNYZ.js +3 -0
- package/dist/chunks/secp256k1-2OHXXNYZ.js.map +7 -0
- package/dist/chunks/skills.run-IDY347MW.js +5 -0
- package/dist/chunks/skills.run-IDY347MW.js.map +7 -0
- package/dist/chunks/status-D4CXVYRA.js +3 -0
- package/dist/chunks/status-D4CXVYRA.js.map +7 -0
- package/dist/main.js +3 -0
- package/dist/main.js.map +7 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +52 -3
- package/skills/fil/SKILL.md +28 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as r,b as a,c,f as i,g as u,i as d,k as t,u as p,v as l,x as m,y as b}from"./chunk-UJQDDRQD.js";import{d as n}from"./chunk-4BBXH7CB.js";var C=n({name:"inspect",description:"Show a managed resource and its retrieval URLs",examples:["fil inspect res_abc123","fil inspect res_abc123 --check"],input:u({ref:r().describe("Resource ref (res_\u2026)"),check:c().default(!1).describe("Probe the piece URL with a HEAD request"),...p}),positionals:["ref"],env:l,secrets:["sessionKey"],output:i({resource:m,urls:b,retrieval:i({url:r(),state:d(["ready","unavailable"]),status:a().int().describe("HTTP status; 0 when unreachable"),checkedAt:r()}).optional()}),errors:[t.authRequired,t.loginPending,t.notFound],readOnly:!0,human:({resource:e,urls:o,retrieval:s})=>[`${e.ref} ${e.kind} ${e.name} (${e.status})`,`pieceCid: ${e.pieceCid}`,...e.rootCid?[`rootCid: ${e.rootCid}`]:[],`piece: ${o.piece}`,`browser: ${o.browser}`,...s?[`retrieval: ${s.state} (HTTP ${s.status})`]:[]].join(`
|
|
3
|
+
`),handler:()=>import("./inspect-HV2SQPTB.js")});export{C as a};
|
|
4
|
+
//# sourceMappingURL=chunk-UVXTIEPU.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/inspect.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineCommand } from 'clipact'\nimport * as z from 'zod'\nimport { ErrorCodes } from '../errors.ts'\nimport { account, accountEnv, resource, urls } from './shared.ts'\n\n/** `fil inspect <ref>`: show a resource and its retrieval URLs. */\nexport const inspect = defineCommand({\n name: 'inspect',\n description: 'Show a managed resource and its retrieval URLs',\n examples: ['fil inspect res_abc123', 'fil inspect res_abc123 --check'],\n input: z.strictObject({\n ref: z.string().describe('Resource ref (res_\u2026)'),\n check: z\n .boolean()\n .default(false)\n .describe('Probe the piece URL with a HEAD request'),\n ...account,\n }),\n positionals: ['ref'],\n env: accountEnv,\n secrets: ['sessionKey'],\n output: z.object({\n resource,\n urls,\n retrieval: z\n .object({\n url: z.string(),\n state: z.enum(['ready', 'unavailable']),\n status: z.number().int().describe('HTTP status; 0 when unreachable'),\n checkedAt: z.string(),\n })\n .optional(),\n }),\n errors: [\n ErrorCodes.authRequired,\n ErrorCodes.loginPending,\n ErrorCodes.notFound,\n ],\n readOnly: true,\n human: ({ resource: r, urls: u, retrieval }) =>\n [\n `${r.ref} ${r.kind} ${r.name} (${r.status})`,\n `pieceCid: ${r.pieceCid}`,\n ...(r.rootCid ? [`rootCid: ${r.rootCid}`] : []),\n `piece: ${u.piece}`,\n `browser: ${u.browser}`,\n ...(retrieval\n ? [`retrieval: ${retrieval.state} (HTTP ${retrieval.status})`]\n : []),\n ].join('\\n'),\n handler: () => import('../handlers/inspect.ts'),\n})\n"],
|
|
5
|
+
"mappings": ";iJAMO,IAAMA,EAAUC,EAAc,CACnC,KAAM,UACN,YAAa,iDACb,SAAU,CAAC,yBAA0B,gCAAgC,EACrE,MAASC,EAAa,CACpB,IAAOC,EAAO,EAAE,SAAS,2BAAsB,EAC/C,MACGC,EAAQ,EACR,QAAQ,EAAK,EACb,SAAS,yCAAyC,EACrD,GAAGC,CACL,CAAC,EACD,YAAa,CAAC,KAAK,EACnB,IAAKC,EACL,QAAS,CAAC,YAAY,EACtB,OAAUC,EAAO,CACf,SAAAC,EACA,KAAAC,EACA,UACGF,EAAO,CACN,IAAOJ,EAAO,EACd,MAASO,EAAK,CAAC,QAAS,aAAa,CAAC,EACtC,OAAUC,EAAO,EAAE,IAAI,EAAE,SAAS,iCAAiC,EACnE,UAAaR,EAAO,CACtB,CAAC,EACA,SAAS,CACd,CAAC,EACD,OAAQ,CACNS,EAAW,aACXA,EAAW,aACXA,EAAW,QACb,EACA,SAAU,GACV,MAAO,CAAC,CAAE,SAAUC,EAAG,KAAMC,EAAG,UAAAC,CAAU,IACxC,CACE,GAAGF,EAAE,GAAG,IAAIA,EAAE,IAAI,IAAIA,EAAE,IAAI,KAAKA,EAAE,MAAM,IACzC,aAAaA,EAAE,QAAQ,GACvB,GAAIA,EAAE,QAAU,CAAC,YAAYA,EAAE,OAAO,EAAE,EAAI,CAAC,EAC7C,UAAUC,EAAE,KAAK,GACjB,YAAYA,EAAE,OAAO,GACrB,GAAIC,EACA,CAAC,cAAcA,EAAU,KAAK,UAAUA,EAAU,MAAM,GAAG,EAC3D,CAAC,CACP,EAAE,KAAK;AAAA,CAAI,EACb,QAAS,IAAM,OAAO,uBAAwB,CAChD,CAAC",
|
|
6
|
+
"names": ["inspect", "defineCommand", "strictObject", "string", "boolean", "account", "accountEnv", "object", "resource", "urls", "_enum", "number", "ErrorCodes", "r", "u", "retrieval"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{C as z,a as e,b as a,c as l,e as u,f as n,g as m,i as t,k as o,u as c,v as d,w as p}from"./chunk-UJQDDRQD.js";import{d as i}from"./chunk-4BBXH7CB.js";var v=i({name:"ls",description:"List managed resources, newest first",examples:["fil ls","fil ls --all --limit 50"],input:m({...p,all:l().default(!1).describe("Include resources pending removal"),...c}),env:d,secrets:["sessionKey"],output:n({network:e(),resources:u(n({ref:e(),kind:t(["file","folder"]),name:e(),size:a().int(),status:t(["active","removal_pending"]),url:e().describe("fil-api link a browser renders"),createdAt:e()})),nextCursor:e().optional()}),errors:[o.authRequired,o.loginPending],readOnly:!0,human:s=>s.resources.length===0?`No resources on ${s.network}.`:[...s.resources.map(r=>`${r.ref} ${r.kind.padEnd(8)} ${z(r.size).padStart(10)} ${r.name}${r.status==="active"?"":` (${r.status})`}`),...s.nextCursor?[`more: --cursor ${s.nextCursor}`]:[]].join(`
|
|
3
|
+
`),handler:()=>import("./ls-7XYH5VPL.js")});export{v as a};
|
|
4
|
+
//# sourceMappingURL=chunk-VTR7BON5.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/ls.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineCommand } from 'clipact'\nimport * as z from 'zod'\nimport { ErrorCodes } from '../errors.ts'\nimport { account, accountEnv, formatBytes, paging } from './shared.ts'\n\n/** `fil ls`: list managed resources, newest first, one page at a time. */\nexport const ls = defineCommand({\n name: 'ls',\n description: 'List managed resources, newest first',\n examples: ['fil ls', 'fil ls --all --limit 50'],\n input: z.strictObject({\n ...paging,\n all: z\n .boolean()\n .default(false)\n .describe('Include resources pending removal'),\n ...account,\n }),\n env: accountEnv,\n secrets: ['sessionKey'],\n output: z.object({\n network: z.string(),\n resources: z.array(\n z.object({\n ref: z.string(),\n kind: z.enum(['file', 'folder']),\n name: z.string(),\n size: z.number().int(),\n status: z.enum(['active', 'removal_pending']),\n url: z.string().describe('fil-api link a browser renders'),\n createdAt: z.string(),\n })\n ),\n nextCursor: z.string().optional(),\n }),\n errors: [ErrorCodes.authRequired, ErrorCodes.loginPending],\n readOnly: true,\n human: (data) =>\n data.resources.length === 0\n ? `No resources on ${data.network}.`\n : [\n ...data.resources.map(\n (r) =>\n `${r.ref} ${r.kind.padEnd(8)} ${formatBytes(r.size).padStart(10)} ${r.name}${r.status === 'active' ? '' : ` (${r.status})`}`\n ),\n ...(data.nextCursor ? [`more: --cursor ${data.nextCursor}`] : []),\n ].join('\\n'),\n handler: () => import('../handlers/ls.ts'),\n})\n"],
|
|
5
|
+
"mappings": ";6JAMO,IAAMA,EAAKC,EAAc,CAC9B,KAAM,KACN,YAAa,uCACb,SAAU,CAAC,SAAU,yBAAyB,EAC9C,MAASC,EAAa,CACpB,GAAGC,EACH,IACGC,EAAQ,EACR,QAAQ,EAAK,EACb,SAAS,mCAAmC,EAC/C,GAAGC,CACL,CAAC,EACD,IAAKC,EACL,QAAS,CAAC,YAAY,EACtB,OAAUC,EAAO,CACf,QAAWC,EAAO,EAClB,UAAaC,EACTF,EAAO,CACP,IAAOC,EAAO,EACd,KAAQE,EAAK,CAAC,OAAQ,QAAQ,CAAC,EAC/B,KAAQF,EAAO,EACf,KAAQG,EAAO,EAAE,IAAI,EACrB,OAAUD,EAAK,CAAC,SAAU,iBAAiB,CAAC,EAC5C,IAAOF,EAAO,EAAE,SAAS,gCAAgC,EACzD,UAAaA,EAAO,CACtB,CAAC,CACH,EACA,WAAcA,EAAO,EAAE,SAAS,CAClC,CAAC,EACD,OAAQ,CAACI,EAAW,aAAcA,EAAW,YAAY,EACzD,SAAU,GACV,MAAQC,GACNA,EAAK,UAAU,SAAW,EACtB,mBAAmBA,EAAK,OAAO,IAC/B,CACE,GAAGA,EAAK,UAAU,IACf,GACC,GAAG,EAAE,GAAG,KAAK,EAAE,KAAK,OAAO,CAAC,CAAC,IAAIC,EAAY,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,EAAE,SAAW,SAAW,GAAK,KAAK,EAAE,MAAM,GAAG,EAChI,EACA,GAAID,EAAK,WAAa,CAAC,kBAAkBA,EAAK,UAAU,EAAE,EAAI,CAAC,CACjE,EAAE,KAAK;AAAA,CAAI,EACjB,QAAS,IAAM,OAAO,kBAAmB,CAC3C,CAAC",
|
|
6
|
+
"names": ["ls", "defineCommand", "strictObject", "paging", "boolean", "account", "accountEnv", "object", "string", "array", "_enum", "number", "ErrorCodes", "data", "formatBytes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as e,c as s,f as r,g as d,h as p,i,j as l,u,v as f}from"./chunk-UJQDDRQD.js";import{d as a}from"./chunk-4BBXH7CB.js";var y=a({name:"status",description:"Show the session, scope expiries, and funding readiness",examples:["fil status","fil status --network mainnet"],input:d(u),env:f,secrets:["sessionKey"],output:r({network:e(),session:r({state:i(["none","pending","active"]),source:i(["env","config"]).optional(),address:e().optional(),rootAddress:e().optional(),url:e().optional().describe("Approval link of a pending login"),scopes:p(e(),e()).optional().describe('Expiry per scope, or "expired" or "not granted"')}),account:r({token:l("USDFC"),funds:e(),availableFunds:e(),debt:e(),ready:s().describe("Ready to pay for a new 1 MiB upload"),needsApproval:s(),depositNeeded:e(),fundingUrl:e().optional()}).optional()}),readOnly:!0,human:({network:z,session:n,account:t})=>{let o=[`network: ${z}`,`session: ${n.state}`];n.url&&o.push(`approve at: ${n.url}`),n.rootAddress&&o.push(`wallet: ${n.rootAddress}`);for(let[g,c]of Object.entries(n.scopes??{}))o.push(` ${g}: ${c}`);return t&&(o.push(`funds: ${t.availableFunds} of ${t.funds} USDFC available`,`ready: ${t.ready?"yes":"no"}`),t.fundingUrl&&o.push(`fund at: ${t.fundingUrl}`)),o.join(`
|
|
3
|
+
`)},handler:()=>import("./status-D4CXVYRA.js")});export{y as a};
|
|
4
|
+
//# sourceMappingURL=chunk-XQRC2SUG.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/status.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineCommand } from 'clipact'\nimport * as z from 'zod'\nimport { account, accountEnv } from './shared.ts'\n\n/** `fil status`: session, scope expiries, and funding readiness. */\nexport const status = defineCommand({\n name: 'status',\n description: 'Show the session, scope expiries, and funding readiness',\n examples: ['fil status', 'fil status --network mainnet'],\n input: z.strictObject(account),\n env: accountEnv,\n secrets: ['sessionKey'],\n output: z.object({\n network: z.string(),\n session: z.object({\n state: z.enum(['none', 'pending', 'active']),\n source: z.enum(['env', 'config']).optional(),\n address: z.string().optional(),\n rootAddress: z.string().optional(),\n url: z.string().optional().describe('Approval link of a pending login'),\n scopes: z\n .record(z.string(), z.string())\n .optional()\n .describe('Expiry per scope, or \"expired\" or \"not granted\"'),\n }),\n account: z\n .object({\n token: z.literal('USDFC'),\n funds: z.string(),\n availableFunds: z.string(),\n debt: z.string(),\n ready: z.boolean().describe('Ready to pay for a new 1 MiB upload'),\n needsApproval: z.boolean(),\n depositNeeded: z.string(),\n fundingUrl: z.string().optional(),\n })\n .optional(),\n }),\n readOnly: true,\n human: ({ network, session, account }) => {\n const lines = [`network: ${network}`, `session: ${session.state}`]\n if (session.url) lines.push(`approve at: ${session.url}`)\n if (session.rootAddress) lines.push(`wallet: ${session.rootAddress}`)\n for (const [scope, expiry] of Object.entries(session.scopes ?? {})) {\n lines.push(` ${scope}: ${expiry}`)\n }\n if (account) {\n lines.push(\n `funds: ${account.availableFunds} of ${account.funds} USDFC available`,\n `ready: ${account.ready ? 'yes' : 'no'}`\n )\n if (account.fundingUrl) lines.push(`fund at: ${account.fundingUrl}`)\n }\n return lines.join('\\n')\n },\n handler: () => import('../handlers/status.ts'),\n})\n"],
|
|
5
|
+
"mappings": ";8HAKO,IAAMA,EAASC,EAAc,CAClC,KAAM,SACN,YAAa,0DACb,SAAU,CAAC,aAAc,8BAA8B,EACvD,MAASC,EAAaC,CAAO,EAC7B,IAAKC,EACL,QAAS,CAAC,YAAY,EACtB,OAAUC,EAAO,CACf,QAAWC,EAAO,EAClB,QAAWD,EAAO,CAChB,MAASE,EAAK,CAAC,OAAQ,UAAW,QAAQ,CAAC,EAC3C,OAAUA,EAAK,CAAC,MAAO,QAAQ,CAAC,EAAE,SAAS,EAC3C,QAAWD,EAAO,EAAE,SAAS,EAC7B,YAAeA,EAAO,EAAE,SAAS,EACjC,IAAOA,EAAO,EAAE,SAAS,EAAE,SAAS,kCAAkC,EACtE,OACGE,EAASF,EAAO,EAAKA,EAAO,CAAC,EAC7B,SAAS,EACT,SAAS,iDAAiD,CAC/D,CAAC,EACD,QACGD,EAAO,CACN,MAASI,EAAQ,OAAO,EACxB,MAASH,EAAO,EAChB,eAAkBA,EAAO,EACzB,KAAQA,EAAO,EACf,MAASI,EAAQ,EAAE,SAAS,qCAAqC,EACjE,cAAiBA,EAAQ,EACzB,cAAiBJ,EAAO,EACxB,WAAcA,EAAO,EAAE,SAAS,CAClC,CAAC,EACA,SAAS,CACd,CAAC,EACD,SAAU,GACV,MAAO,CAAC,CAAE,QAAAK,EAAS,QAAAC,EAAS,QAAAT,CAAQ,IAAM,CACxC,IAAMU,EAAQ,CAAC,YAAYF,CAAO,GAAI,YAAYC,EAAQ,KAAK,EAAE,EAC7DA,EAAQ,KAAKC,EAAM,KAAK,eAAeD,EAAQ,GAAG,EAAE,EACpDA,EAAQ,aAAaC,EAAM,KAAK,WAAWD,EAAQ,WAAW,EAAE,EACpE,OAAW,CAACE,EAAOC,CAAM,IAAK,OAAO,QAAQH,EAAQ,QAAU,CAAC,CAAC,EAC/DC,EAAM,KAAK,KAAKC,CAAK,KAAKC,CAAM,EAAE,EAEpC,OAAIZ,IACFU,EAAM,KACJ,UAAUV,EAAQ,cAAc,OAAOA,EAAQ,KAAK,mBACpD,UAAUA,EAAQ,MAAQ,MAAQ,IAAI,EACxC,EACIA,EAAQ,YAAYU,EAAM,KAAK,YAAYV,EAAQ,UAAU,EAAE,GAE9DU,EAAM,KAAK;AAAA,CAAI,CACxB,EACA,QAAS,IAAM,OAAO,sBAAuB,CAC/C,CAAC",
|
|
6
|
+
"names": ["status", "defineCommand", "strictObject", "account", "accountEnv", "object", "string", "_enum", "record", "literal", "boolean", "network", "session", "lines", "scope", "expiry"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
var g=Object.create;var e=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var n=(a,b)=>()=>{try{return b||a((b={exports:{}}).exports,b),b.exports}catch(c){throw b=0,c}},o=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0})},l=(a,b,c,f)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of i(b))!k.call(a,d)&&d!==c&&e(a,d,{get:()=>b[d],enumerable:!(f=h(b,d))||f.enumerable});return a};var p=(a,b,c)=>(c=a!=null?g(j(a)):{},l(b||!a||!a.__esModule?e(c,"default",{value:a,enumerable:!0}):c,a));export{m as a,n as b,o as c,p as d};
|
|
3
|
+
//# sourceMappingURL=chunk-YIAP3JO3.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{C as h,a as e,b as s,c as i,e as c,f as r,g as l,i as a,j as d,m as u,u as z,v as m,x as f,y as g}from"./chunk-UJQDDRQD.js";import{d as p}from"./chunk-4BBXH7CB.js";var b=r({kind:a(["file","folder"]),name:e(),size:s().int().describe("Bytes to store: the file, or the packed CAR"),files:s().int(),rootCid:e().optional(),network:e(),authorization:a(["ready","login_required","login_pending","scopes_missing"]).describe("Whether the session key can sign this put"),missingScopes:c(e()).optional(),provider:r({id:e(),serviceURL:e(),dataSetId:e().optional().describe("Existing data set to add to")}).optional(),cost:r({token:d("USDFC"),ready:i().describe("The payer can cover it now"),depositNeeded:e(),needsApproval:i(),ratePerMonth:e(),lockup:e(),fundingUrl:e().optional()}).optional(),checkedAt:e()}),k=p({name:"put",description:"Store a file (raw piece) or directory (UnixFS CAR) with one copy",examples:["fil put ./report.pdf","fil put ./site --name docs","fil publish ./site --dry-run"],input:l({path:e().describe("File or directory to store"),name:e().min(1).optional().describe("Display name (default: basename)"),provider:e().regex(/^\d+$/,"Expected a decimal provider ID").optional().describe("Storage provider ID (default: automatic)"),...z}),positionals:["path"],env:m,secrets:["sessionKey"],output:r({dryRun:i(),operationId:e().optional().describe("Set when dryRun is false"),state:d("ready").optional(),resource:f.optional(),urls:g.optional(),estimate:b.optional().describe("Set when dryRun is true")}),errors:u,dryRun:!0,human:o=>{if(o.estimate){let t=o.estimate,n=[`Would store ${t.kind} ${t.name}: ${h(t.size)}, ${t.files} file(s) on ${t.network}`,`authorization: ${t.authorization}`];return t.provider&&n.push(`provider: ${t.provider.id} (${t.provider.serviceURL})`),t.cost&&n.push(`cost: ${t.cost.ratePerMonth} USDFC/month, lockup ${t.cost.lockup} USDFC, ${t.cost.ready?"funded":`deposit ${t.cost.depositNeeded} USDFC first`}`),n.join(`
|
|
3
|
+
`)}return`Stored ${o.resource?.name} (${o.resource?.ref})
|
|
4
|
+
${o.urls?.browser}`},handler:()=>import("./put-EHRNCZHT.js")});export{k as a};
|
|
5
|
+
//# sourceMappingURL=chunk-ZD6MKB4J.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/put.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineCommand } from 'clipact'\nimport * as z from 'zod'\nimport { JOB_ERRORS } from '../errors.ts'\nimport { account, accountEnv, formatBytes, resource, urls } from './shared.ts'\n\n/** What `put --dry-run` reports instead of storing anything. */\nconst estimate = z.object({\n kind: z.enum(['file', 'folder']),\n name: z.string(),\n size: z\n .number()\n .int()\n .describe('Bytes to store: the file, or the packed CAR'),\n files: z.number().int(),\n rootCid: z.string().optional(),\n network: z.string(),\n authorization: z\n .enum(['ready', 'login_required', 'login_pending', 'scopes_missing'])\n .describe('Whether the session key can sign this put'),\n missingScopes: z.array(z.string()).optional(),\n provider: z\n .object({\n id: z.string(),\n serviceURL: z.string(),\n dataSetId: z.string().optional().describe('Existing data set to add to'),\n })\n .optional(),\n cost: z\n .object({\n token: z.literal('USDFC'),\n ready: z.boolean().describe('The payer can cover it now'),\n depositNeeded: z.string(),\n needsApproval: z.boolean(),\n ratePerMonth: z.string(),\n lockup: z.string(),\n fundingUrl: z.string().optional(),\n })\n .optional(),\n checkedAt: z.string(),\n})\n\n/**\n * `fil put <path>` (alias `publish`): store a file as exact bytes, or a\n * directory as a UnixFS CAR served at `/ipfs/<rootCid>/`, with one copy.\n */\nexport const put = defineCommand({\n name: 'put',\n description:\n 'Store a file (raw piece) or directory (UnixFS CAR) with one copy',\n examples: [\n 'fil put ./report.pdf',\n 'fil put ./site --name docs',\n 'fil publish ./site --dry-run',\n ],\n input: z.strictObject({\n path: z.string().describe('File or directory to store'),\n name: z\n .string()\n .min(1)\n .optional()\n .describe('Display name (default: basename)'),\n provider: z\n .string()\n .regex(/^\\d+$/, 'Expected a decimal provider ID')\n .optional()\n .describe('Storage provider ID (default: automatic)'),\n ...account,\n }),\n positionals: ['path'],\n env: accountEnv,\n secrets: ['sessionKey'],\n output: z.object({\n dryRun: z.boolean(),\n operationId: z.string().optional().describe('Set when dryRun is false'),\n state: z.literal('ready').optional(),\n resource: resource.optional(),\n urls: urls.optional(),\n estimate: estimate.optional().describe('Set when dryRun is true'),\n }),\n errors: JOB_ERRORS,\n dryRun: true,\n human: (data) => {\n if (data.estimate) {\n const e = data.estimate\n const lines = [\n `Would store ${e.kind} ${e.name}: ${formatBytes(e.size)}, ${e.files} file(s) on ${e.network}`,\n `authorization: ${e.authorization}`,\n ]\n if (e.provider)\n lines.push(`provider: ${e.provider.id} (${e.provider.serviceURL})`)\n if (e.cost) {\n lines.push(\n `cost: ${e.cost.ratePerMonth} USDFC/month, lockup ${e.cost.lockup} USDFC, ${e.cost.ready ? 'funded' : `deposit ${e.cost.depositNeeded} USDFC first`}`\n )\n }\n return lines.join('\\n')\n }\n return `Stored ${data.resource?.name} (${data.resource?.ref})\\n${data.urls?.browser}`\n },\n handler: () => import('../handlers/put.ts'),\n})\n"],
|
|
5
|
+
"mappings": ";2KAMA,IAAMA,EAAaC,EAAO,CACxB,KAAQC,EAAK,CAAC,OAAQ,QAAQ,CAAC,EAC/B,KAAQC,EAAO,EACf,KACGC,EAAO,EACP,IAAI,EACJ,SAAS,6CAA6C,EACzD,MAASA,EAAO,EAAE,IAAI,EACtB,QAAWD,EAAO,EAAE,SAAS,EAC7B,QAAWA,EAAO,EAClB,cACGD,EAAK,CAAC,QAAS,iBAAkB,gBAAiB,gBAAgB,CAAC,EACnE,SAAS,2CAA2C,EACvD,cAAiBG,EAAQF,EAAO,CAAC,EAAE,SAAS,EAC5C,SACGF,EAAO,CACN,GAAME,EAAO,EACb,WAAcA,EAAO,EACrB,UAAaA,EAAO,EAAE,SAAS,EAAE,SAAS,6BAA6B,CACzE,CAAC,EACA,SAAS,EACZ,KACGF,EAAO,CACN,MAASK,EAAQ,OAAO,EACxB,MAASC,E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,EAAE,KAAK,MAAQ,SAAW,WAAWA,EAAE,KAAK,aAAa,cAAc,EACrJ,EAEKC,EAAM,KAAK;AAAA,CAAI,CACxB,CACA,MAAO,UAAUF,EAAK,UAAU,IAAI,KAAKA,EAAK,UAAU,GAAG;AAAA,EAAMA,EAAK,MAAM,OAAO,EACrF,EACA,QAAS,IAAM,OAAO,mBAAoB,CAC5C,CAAC",
|
|
6
|
+
"names": ["estimate", "object", "_enum", "string", "number", "array", "literal", "boolean", "put", "defineCommand", "strictObject", "account", "accountEnv", "resource", "urls", "JOB_ERRORS", "data", "e", "lines", "formatBytes"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{e}from"./chunk-IJ2NNDTJ.js";import"./chunk-ISML2NA2.js";import"./chunk-5EYSPKTK.js";import{a}from"./chunk-LOTWVNDB.js";import{ja as m,l as t,la as p}from"./chunk-4DUACCJB.js";import"./chunk-UJQDDRQD.js";import"./chunk-35V77X3C.js";import"./chunk-RK6JJQZL.js";import"./chunk-7MEK5RQ7.js";import"./chunk-GVAFHRPJ.js";import{j as r}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";var j=r(a,async o=>{let i=m(o),n=await p(i,t,o),f=await e(n,o.input.ref);return o.ok(f)});export{j as default};
|
|
3
|
+
//# sourceMappingURL=delete-XVYLEMHB.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/handlers/delete.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineHandler } from 'clipact'\nimport { RM_SCOPES } from '../auth/scopes.ts'\nimport { remove } from '../commands/delete.ts'\nimport { startRemove } from '../storage/jobs.ts'\nimport { appFor, jobContext } from './context.ts'\n\n/** Schedule removal of a managed resource's stored copy. */\nexport default defineHandler(remove, async (ctx) => {\n const app = appFor(ctx)\n const job = await jobContext(app, RM_SCOPES, ctx)\n const result = await startRemove(job, ctx.input.ref)\n return ctx.ok(result)\n})\n"],
|
|
5
|
+
"mappings": ";sYAOA,IAAOA,EAAQC,EAAcC,EAAQ,MAAOC,GAAQ,CAClD,IAAMC,EAAMC,EAAOF,CAAG,EAChBG,EAAM,MAAMC,EAAWH,EAAKI,EAAWL,CAAG,EAC1CM,EAAS,MAAMC,EAAYJ,EAAKH,EAAI,MAAM,GAAG,EACnD,OAAOA,EAAI,GAAGM,CAAM,CACtB,CAAC",
|
|
6
|
+
"names": ["delete_default", "defineHandler", "remove", "ctx", "app", "appFor", "job", "jobContext", "RM_SCOPES", "result", "startRemove"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as g}from"./chunk-NPYAGWD6.js";import{J as m,aa as p,b as l,ja as u}from"./chunk-4DUACCJB.js";import{r as c}from"./chunk-UJQDDRQD.js";import"./chunk-35V77X3C.js";import"./chunk-RK6JJQZL.js";import"./chunk-7MEK5RQ7.js";import{a as f}from"./chunk-KAQPCD23.js";import"./chunk-GVAFHRPJ.js";import{j as s,p as i}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";var d=1e4,I=s(g,async t=>{let r=u(t),o=r.env,n=[],a="none";try{a=p(r)?.source??"none"}catch(e){if(!i(e))throw e;a=e.code==="invalid_input"?"env":"pending",n.push({name:"credentials",ok:!1,message:e.message})}try{r.db(),n.push({name:"state",ok:!0,message:"Database opened and migrated"})}catch(e){n.push({name:"state",ok:!1,message:e instanceof Error?e.message:String(e)})}try{let e=await c(l(r.client,{cacheTime:0}),AbortSignal.timeout(d));n.push({name:"rpc",ok:!0,message:`Chain ${r.chain.id} at block ${e}`})}catch(e){if(t.signal.aborted)throw e;n.push({name:"rpc",ok:!1,message:e instanceof DOMException&&e.name==="TimeoutError"?`No answer within ${d/1e3} s`:e instanceof Error?f(e):String(e)})}let h=o.FIL_RPC_URL??r.chain.rpcUrls.default.http[0]??"";return t.ok({network:{value:r.network,source:t.input.network?"input":r.config.get("network")?"config":"default"},rpcUrl:{value:h,source:o.FIL_RPC_URL?"env":"default"},consoleUrl:{value:r.consoleUrl,source:o.FIL_CONSOLE_URL?"env":"default"},apiUrl:{value:r.apiUrl,source:o.FIL_API_URL?"env":"default"},configFile:r.config.path,stateDir:{value:m(o),source:o.FIL_STATE_DIR?"env":"default"},credentials:a,checks:n})});export{I as default};
|
|
3
|
+
//# sourceMappingURL=doctor-2W65SQJS.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/handlers/doctor.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineHandler, isCliError } from 'clipact'\nimport { getBlockNumber } from 'viem/actions'\nimport { resolveCredentials } from '../auth/session.ts'\nimport { doctor } from '../commands/doctor.ts'\nimport { abortable } from '../errors.ts'\nimport { firstLine } from '../map-error.ts'\nimport { stateDir } from '../state/db.ts'\nimport { appFor } from './context.ts'\n\n/** Milliseconds to wait for the RPC check. */\nconst RPC_TIMEOUT = 10_000\n\n/**\n * Report resolved settings with their sources, then check that the state\n * database opens and the RPC endpoint answers on the expected chain. Never\n * prints the session key.\n */\nexport default defineHandler(doctor, async (ctx) => {\n const app = appFor(ctx)\n const env = app.env\n const checks: { name: string; ok: boolean; message: string }[] = []\n\n let credentials: 'env' | 'config' | 'pending' | 'none' = 'none'\n try {\n credentials = resolveCredentials(app)?.source ?? 'none'\n } catch (error) {\n if (!isCliError(error)) throw error\n credentials = error.code === 'invalid_input' ? 'env' : 'pending'\n checks.push({ name: 'credentials', ok: false, message: error.message })\n }\n\n try {\n app.db()\n checks.push({\n name: 'state',\n ok: true,\n message: 'Database opened and migrated',\n })\n } catch (error) {\n checks.push({\n name: 'state',\n ok: false,\n message: error instanceof Error ? error.message : String(error),\n })\n }\n\n try {\n // The app's transport already stops on ctx.signal; this adds a deadline.\n const block = await abortable(\n getBlockNumber(app.client, { cacheTime: 0 }),\n AbortSignal.timeout(RPC_TIMEOUT)\n )\n checks.push({\n name: 'rpc',\n ok: true,\n message: `Chain ${app.chain.id} at block ${block}`,\n })\n } catch (error) {\n if (ctx.signal.aborted) throw error\n checks.push({\n name: 'rpc',\n ok: false,\n message:\n error instanceof DOMException && error.name === 'TimeoutError'\n ? `No answer within ${RPC_TIMEOUT / 1000} s`\n : error instanceof Error\n ? firstLine(error)\n : String(error),\n })\n }\n\n const rpcUrl = env.FIL_RPC_URL ?? app.chain.rpcUrls.default.http[0] ?? ''\n return ctx.ok({\n network: {\n value: app.network,\n source: ctx.input.network\n ? 'input'\n : app.config.get('network')\n ? 'config'\n : 'default',\n },\n rpcUrl: { value: rpcUrl, source: env.FIL_RPC_URL ? 'env' : 'default' },\n consoleUrl: {\n value: app.consoleUrl,\n source: env.FIL_CONSOLE_URL ? 'env' : 'default',\n },\n apiUrl: {\n value: app.apiUrl,\n source: env.FIL_API_URL ? 'env' : 'default',\n },\n configFile: app.config.path,\n stateDir: {\n value: stateDir(env),\n source: env.FIL_STATE_DIR ? 'env' : 'default',\n },\n credentials,\n checks,\n })\n})\n"],
|
|
5
|
+
"mappings": ";kXAUA,IAAMA,EAAc,IAObC,EAAQC,EAAcC,EAAQ,MAAOC,GAAQ,CAClD,IAAMC,EAAMC,EAAOF,CAAG,EAChBG,EAAMF,EAAI,IACVG,EAA2D,CAAC,EAE9DC,EAAqD,OACzD,GAAI,CACFA,EAAcC,EAAmBL,CAAG,GAAG,QAAU,MACnD,OAASM,EAAO,CACd,GAAI,CAACC,EAAWD,CAAK,EAAG,MAAMA,EAC9BF,EAAcE,EAAM,OAAS,gBAAkB,MAAQ,UACvDH,EAAO,KAAK,CAAE,KAAM,cAAe,GAAI,GAAO,QAASG,EAAM,OAAQ,CAAC,CACxE,CAEA,GAAI,CACFN,EAAI,GAAG,EACPG,EAAO,KAAK,CACV,KAAM,QACN,GAAI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appFor", "env", "checks", "credentials", "resolveCredentials", "error", "isCliError", "block", "abortable", "getBlockNumber", "firstLine", "rpcUrl", "stateDir"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as R}from"./chunk-2KPBBDBJ.js";import{b as k}from"./chunk-ISML2NA2.js";import{c as F}from"./chunk-5EYSPKTK.js";import{C as y,F as v,I as P,U as $,ja as x,ka as g,ma as z}from"./chunk-4DUACCJB.js";import{k as f,q as u}from"./chunk-UJQDDRQD.js";import"./chunk-35V77X3C.js";import"./chunk-RK6JJQZL.js";import"./chunk-7MEK5RQ7.js";import"./chunk-GVAFHRPJ.js";import{j as b,o as d}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";import{stat as q}from"node:fs/promises";import{resolve as A}from"node:path";import{createWriteStream as N}from"node:fs";import{mkdir as U,rename as S,rm as p,stat as B}from"node:fs/promises";import{dirname as T,join as H,resolve as D}from"node:path";import{Readable as j,Transform as I}from"node:stream";import{pipeline as L}from"node:stream/promises";async function m(e){let r=await(e.fetch??globalThis.fetch)(e.url,{signal:e.signal}).catch(o=>{throw e.signal?.aborted?o:new d({code:"service_unavailable",message:`Could not reach ${e.url}.`,cause:o})});if(r.status===404)throw await r.body?.cancel(),u(`The provider does not have ${e.pieceCid}.`);if(!(r.ok&&r.body))throw await r.body?.cancel(),new d({code:"service_unavailable",message:`Retrieval from ${e.url} failed with HTTP ${r.status}.`});let i=D(e.output);await U(T(i),{recursive:!0});let t=`${i}.fil-partial`,n=y(),s=new I({transform(o,l,c){n.write(o),c(null,o)}});try{await L(j.fromWeb(r.body),s,N(t));let o=n.finalize().toString();if(o!==e.pieceCid)throw new d({code:f.verificationFailed,message:`Downloaded bytes hash to ${o}, expected ${e.pieceCid}.`});return await S(t,i),{size:Number(n.count())}}catch(o){throw await p(t,{force:!0}),o}}async function E(e){let a=D(e.output);if(await B(a).catch(()=>{}))throw h(e.output);let i=H(T(a),`.${e.pieceCid}.car`);try{let{size:t}=await m({...e,output:i}),n=`${a}.fil-partial`;await p(n,{recursive:!0,force:!0});let{rootCid:s,files:o}=await k(i,n,{verifyBlocks:!1});if(s.toString()!==e.rootCid)throw await p(n,{recursive:!0,force:!0}),new d({code:f.verificationFailed,message:`CAR root is ${s}, expected ${e.rootCid}.`});return await S(n,a),{size:t,files:o}}finally{await p(i,{force:!0})}}function h(e){return new d({code:f.outputExists,message:`${e} already exists.`,next:[{by:"agent",description:"Choose another path with --output, or pass --force for a file"}]})}async function O(e,a){if(!a&&await q(e).catch(()=>{}))throw h(e)}var de=b(R,async e=>{let{input:a}=e,r=x(e),{target:i}=a,t;if(i.startsWith("res_")?t=z(r,i):t=$(r.db(),g(r),i)[0],!t){let l=v(i);if(!l)throw u(`No managed resource or PieceCID ${i}.`,{by:"agent",command:"fil ls",description:"List managed resources"});let c=await P({client:r.client,address:g(r).payer,pieceCid:l,signal:e.signal}).catch(C=>{throw e.signal.aborted?C:u(`No provider serves ${i}: ${String(C)}`)}),w=A(a.output??i);await O(w,a.force);let{size:W}=await m({url:c,pieceCid:i,output:w,signal:e.signal});return e.ok({kind:"file",pieceCid:i,output:w,size:W,url:c})}let n=F(t),s=A(a.output??t.name);if(t.kind==="folder"&&t.rootCid){let{size:l,files:c}=await E({url:n,pieceCid:t.pieceCid,rootCid:t.rootCid,output:s,signal:e.signal});return e.ok({kind:t.kind,ref:t.ref,pieceCid:t.pieceCid,output:s,size:l,files:c,url:n})}await O(s,a.force);let{size:o}=await m({url:n,pieceCid:t.pieceCid,output:s,signal:e.signal});return e.ok({kind:t.kind,ref:t.ref,pieceCid:t.pieceCid,output:s,size:o,url:n})});export{de as default};
|
|
3
|
+
//# sourceMappingURL=get-ZP66WVWT.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/handlers/get.ts", "../../src/storage/get.ts"],
|
|
4
|
+
"sourcesContent": ["import { stat } from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport * as Piece from '@filoz/synapse-core/piece'\nimport { defineHandler } from 'clipact'\nimport { get } from '../commands/get.ts'\nimport { notFound } from '../errors.ts'\nimport { findResourcesByCid, type Resource } from '../state/resources.ts'\nimport { downloadFolder, downloadPiece, outputExists } from '../storage/get.ts'\nimport { providerPieceUrl } from '../storage/urls.ts'\nimport { accountScope, appFor, findResource } from './context.ts'\n\n/** Refuse to overwrite an existing file unless forced. */\nasync function assertWritable(path: string, force: boolean): Promise<void> {\n if (force) return\n if (await stat(path).catch(() => undefined)) throw outputExists(path)\n}\n\n/**\n * Retrieve a managed resource by ref (or a PieceCID or root CID) from Curio\n * and verify it. Files are written as-is; folders are extracted to a\n * directory. An unmanaged PieceCID is located through the payer's data sets.\n */\nexport default defineHandler(get, async (ctx) => {\n const { input } = ctx\n const app = appFor(ctx)\n const { target } = input\n let resource: Resource | undefined\n if (target.startsWith('res_')) {\n resource = findResource(app, target)\n } else {\n resource = findResourcesByCid(app.db(), accountScope(app), target)[0]\n }\n\n if (!resource) {\n const pieceCid = Piece.tryFrom(target)\n if (!pieceCid) {\n throw notFound(`No managed resource or PieceCID ${target}.`, {\n by: 'agent',\n command: 'fil ls',\n description: 'List managed resources',\n })\n }\n const url = await Piece.resolvePieceUrl({\n client: app.client,\n address: accountScope(app).payer as `0x${string}`,\n pieceCid,\n signal: ctx.signal,\n }).catch((error: unknown) => {\n if (ctx.signal.aborted) throw error\n throw notFound(`No provider serves ${target}: ${String(error)}`)\n })\n const output = resolve(input.output ?? target)\n await assertWritable(output, input.force)\n const { size } = await downloadPiece({\n url,\n pieceCid: target,\n output,\n signal: ctx.signal,\n })\n return ctx.ok({ kind: 'file', pieceCid: target, output, size, url })\n }\n\n const url = providerPieceUrl(resource)\n const output = resolve(input.output ?? resource.name)\n if (resource.kind === 'folder' && resource.rootCid) {\n const { size, files } = await downloadFolder({\n url,\n pieceCid: resource.pieceCid,\n rootCid: resource.rootCid,\n output,\n signal: ctx.signal,\n })\n return ctx.ok({\n kind: resource.kind,\n ref: resource.ref,\n pieceCid: resource.pieceCid,\n output,\n size,\n files,\n url,\n })\n }\n await assertWritable(output, input.force)\n const { size } = await downloadPiece({\n url,\n pieceCid: resource.pieceCid,\n output,\n signal: ctx.signal,\n })\n return ctx.ok({\n kind: resource.kind,\n ref: resource.ref,\n pieceCid: resource.pieceCid,\n output,\n size,\n url,\n })\n})\n", "import { createWriteStream } from 'node:fs'\nimport { mkdir, rename, rm, stat } from 'node:fs/promises'\nimport { dirname, join, resolve } from 'node:path'\nimport { Readable, Transform } from 'node:stream'\nimport { pipeline } from 'node:stream/promises'\nimport * as Piece from '@filoz/synapse-core/piece'\nimport { CliError } from 'clipact'\nimport { ErrorCodes, notFound } from '../errors.ts'\nimport { extractCar } from './pack.ts'\n\n/** Options for {@link downloadPiece}. */\nexport type DownloadPieceOptions = {\n url: string\n pieceCid: string\n /** Final file path; written only after the PieceCID matches. */\n output: string\n fetch?: typeof globalThis.fetch\n signal?: AbortSignal\n}\n\n/**\n * Stream a piece to `output` while hashing it, and keep the file only when\n * the bytes match the expected PieceCID. Unlike synapse-core's\n * `downloadAndValidate`, this never buffers the whole piece in memory.\n */\nexport async function downloadPiece(\n options: DownloadPieceOptions\n): Promise<{ size: number }> {\n const fetchFn = options.fetch ?? globalThis.fetch\n const response = await fetchFn(options.url, { signal: options.signal }).catch(\n (error: unknown) => {\n if (options.signal?.aborted) throw error\n throw new CliError({\n code: 'service_unavailable',\n message: `Could not reach ${options.url}.`,\n cause: error,\n })\n }\n )\n if (response.status === 404) {\n await response.body?.cancel()\n throw notFound(`The provider does not have ${options.pieceCid}.`)\n }\n if (!(response.ok && response.body)) {\n await response.body?.cancel()\n throw new CliError({\n code: 'service_unavailable',\n message: `Retrieval from ${options.url} failed with HTTP ${response.status}.`,\n })\n }\n const output = resolve(options.output)\n await mkdir(dirname(output), { recursive: true })\n const tmp = `${output}.fil-partial`\n const hasher = Piece.hasher()\n const hash = new Transform({\n transform(chunk: Uint8Array, _encoding, callback) {\n hasher.write(chunk)\n callback(null, chunk)\n },\n })\n try {\n await pipeline(\n Readable.fromWeb(response.body as never),\n hash,\n createWriteStream(tmp)\n )\n const actual = hasher.finalize().toString()\n if (actual !== options.pieceCid) {\n throw new CliError({\n code: ErrorCodes.verificationFailed,\n message: `Downloaded bytes hash to ${actual}, expected ${options.pieceCid}.`,\n })\n }\n await rename(tmp, output)\n return { size: Number(hasher.count()) }\n } catch (error) {\n await rm(tmp, { force: true })\n throw error\n }\n}\n\n/** Options for {@link downloadFolder}. */\nexport type DownloadFolderOptions = {\n url: string\n pieceCid: string\n rootCid: string\n /** Directory to extract into; must be empty or absent. */\n output: string\n fetch?: typeof globalThis.fetch\n signal?: AbortSignal\n}\n\n/**\n * Download a folder's CAR through its exact piece, verify it against the\n * PieceCID and root CID, and extract the file tree into `output`. The\n * PieceCID check covers every byte, so blocks are not hashed again.\n */\nexport async function downloadFolder(\n options: DownloadFolderOptions\n): Promise<{ size: number; files: number }> {\n const output = resolve(options.output)\n const existing = await stat(output).catch(() => undefined)\n if (existing) throw outputExists(options.output)\n const carPath = join(dirname(output), `.${options.pieceCid}.car`)\n try {\n const { size } = await downloadPiece({ ...options, output: carPath })\n const tmp = `${output}.fil-partial`\n await rm(tmp, { recursive: true, force: true })\n const { rootCid, files } = await extractCar(carPath, tmp, {\n verifyBlocks: false,\n })\n if (rootCid.toString() !== options.rootCid) {\n await rm(tmp, { recursive: true, force: true })\n throw new CliError({\n code: ErrorCodes.verificationFailed,\n message: `CAR root is ${rootCid}, expected ${options.rootCid}.`,\n })\n }\n await rename(tmp, output)\n return { size, files }\n } finally {\n await rm(carPath, { force: true })\n }\n}\n\n/** Error returned when `get` would overwrite an existing path. */\nexport function outputExists(path: string): CliError {\n return new CliError({\n code: ErrorCodes.outputExists,\n message: `${path} already exists.`,\n next: [\n {\n by: 'agent',\n description:\n 'Choose another path with --output, or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AAW,EACA,OAAQf,EAAI,MACd,CAAC,EACD,OAAOA,EAAI,GAAG,CAAE,KAAM,OAAQ,SAAUI,EAAQ,OAAAW,EAAQ,KAAAE,EAAM,IAAAL,CAAI,CAAC,CACrE,CAEA,IAAMA,EAAMO,EAAiBd,CAAQ,EAC/BU,EAASC,EAAQf,EAAM,QAAUI,EAAS,IAAI,EACpD,GAAIA,EAAS,OAAS,UAAYA,EAAS,QAAS,CAClD,GAAM,CAAE,KAAAY,EAAM,MAAAG,CAAM,EAAI,MAAMC,EAAe,CAC3C,IAAAT,EACA,SAAUP,EAAS,SACnB,QAASA,EAAS,QAClB,OAAAU,EACA,OAAQf,EAAI,MACd,CAAC,EACD,OAAOA,EAAI,GAAG,CACZ,KAAMK,EAAS,KACf,IAAKA,EAAS,IACd,SAAUA,EAAS,SACnB,OAAAU,EACA,KAAAE,EACA,MAAAG,EACA,IAAAR,CACF,CAAC,CACH,CACA,MAAMpB,EAAeuB,EAAQd,EAAM,KAAK,EACxC,GAAM,CAAE,KAAAgB,CAAK,EAAI,MAAMC,EAAc,CACnC,IAAAN,EACA,SAAUP,EAAS,SACnB,OAAAU,EACA,OAAQf,EAAI,MACd,CAAC,EACD,OAAOA,EAAI,GAAG,CACZ,KAAMK,EAAS,KACf,IAAKA,EAAS,IACd,SAAUA,EAAS,SACnB,OAAAU,EACA,KAAAE,EACA,IAAAL,CACF,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["stat", "resolve", "createWriteStream", "mkdir", "rename", "rm", "stat", "dirname", "join", "resolve", "Readable", "Transform", "pipeline", "downloadPiece", "options", "response", "error", "CliError", "notFound", "output", "resolve", "mkdir", "dirname", "tmp", "hasher", "hash", "Transform", "chunk", "_encoding", "callback", "pipeline", "Readable", "createWriteStream", "actual", "ErrorCodes", "rename", "rm", "downloadFolder", "stat", "outputExists", "carPath", "join", "size", "rootCid", "files", "extractCar", "path", "assertWritable", "path", "force", "stat", "outputExists", "get_default", "defineHandler", "get", "ctx", "input", "app", "appFor", "target", "resource", "findResource", "findResourcesByCid", "accountScope", "pieceCid", "tryFrom", "notFound", "url", "resolvePieceUrl", "error", "output", "resolve", "size", "downloadPiece", "providerPieceUrl", "files", "downloadFolder"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as l}from"./chunk-UVXTIEPU.js";import{b as s}from"./chunk-5EYSPKTK.js";import{ja as u,ma as p}from"./chunk-4DUACCJB.js";import"./chunk-UJQDDRQD.js";import"./chunk-35V77X3C.js";import"./chunk-RK6JJQZL.js";import"./chunk-7MEK5RQ7.js";import"./chunk-GVAFHRPJ.js";import{j as i}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";var f=15e3,k=i(l,async e=>{let o=u(e),r=p(o,e.input.ref),t=s(r,o.apiUrl);if(!e.input.check)return e.ok({resource:r,urls:t});let n=t.piece,a=await fetch(n,{method:"HEAD",signal:AbortSignal.any([e.signal,AbortSignal.timeout(f)])}).catch(c=>{if(e.signal.aborted)throw c});return e.ok({resource:r,urls:t,retrieval:{url:n,state:a?.ok?"ready":"unavailable",status:a?.status??0,checkedAt:new Date().toISOString()}})});export{k as default};
|
|
3
|
+
//# sourceMappingURL=inspect-HV2SQPTB.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/handlers/inspect.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineHandler } from 'clipact'\nimport { inspect } from '../commands/inspect.ts'\nimport { resourceUrls } from '../storage/urls.ts'\nimport { appFor, findResource } from './context.ts'\n\n/** Milliseconds to wait for the retrieval probe. */\nconst PROBE_TIMEOUT = 15_000\n\n/**\n * Show a managed resource with its fil-api URLs. With `--check`, send a HEAD\n * request to the piece URL and follow fil-api's redirect to the provider, so\n * the check fails until fil-api's indexer has the piece. The browser URL of\n * a folder always redirects to inbrowser.link, so probing it proves nothing.\n */\nexport default defineHandler(inspect, async (ctx) => {\n const app = appFor(ctx)\n const resource = findResource(app, ctx.input.ref)\n const urls = resourceUrls(resource, app.apiUrl)\n if (!ctx.input.check) return ctx.ok({ resource, urls })\n const probe = urls.piece\n const response = await fetch(probe, {\n method: 'HEAD',\n signal: AbortSignal.any([ctx.signal, AbortSignal.timeout(PROBE_TIMEOUT)]),\n }).catch((error: unknown) => {\n if (ctx.signal.aborted) throw error\n return undefined\n })\n return ctx.ok({\n resource,\n urls,\n retrieval: {\n url: probe,\n state: response?.ok ? 'ready' : 'unavailable',\n status: response?.status ?? 0,\n checkedAt: new Date().toISOString(),\n },\n })\n})\n"],
|
|
5
|
+
"mappings": ";iVAMA,IAAMA,EAAgB,KAQfC,EAAQC,EAAcC,EAAS,MAAOC,GAAQ,CACnD,IAAMC,EAAMC,EAAOF,CAAG,EAChBG,EAAWC,EAAaH,EAAKD,EAAI,MAAM,GAAG,EAC1CK,EAAOC,EAAaH,EAAUF,EAAI,MAAM,EAC9C,GAAI,CAACD,EAAI,MAAM,MAAO,OAAOA,EAAI,GAAG,CAAE,SAAAG,EAAU,KAAAE,CAAK,CAAC,EACtD,IAAME,EAAQF,EAAK,MACbG,EAAW,MAAM,MAAMD,EAAO,CAClC,OAAQ,OACR,OAAQ,YAAY,IAAI,CAACP,EAAI,OAAQ,YAAY,QAAQJ,CAAa,CAAC,CAAC,CAC1E,CAAC,EAAE,MAAOa,GAAmB,CAC3B,GAAIT,EAAI,OAAO,QAAS,MAAMS,CAEhC,CAAC,EACD,OAAOT,EAAI,GAAG,CACZ,SAAAG,EACA,KAAAE,EACA,UAAW,CACT,IAAKE,EACL,MAAOC,GAAU,GAAK,QAAU,cAChC,OAAQA,GAAU,QAAU,EAC5B,UAAW,IAAI,KAAK,EAAE,YAAY,CACpC,CACF,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["PROBE_TIMEOUT", "inspect_default", "defineHandler", "inspect", "ctx", "app", "appFor", "resource", "findResource", "urls", "resourceUrls", "probe", "response", "error"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as p}from"./chunk-QYPR6473.js";import{ja as c,na as i}from"./chunk-4DUACCJB.js";import"./chunk-UJQDDRQD.js";import"./chunk-35V77X3C.js";import"./chunk-RK6JJQZL.js";import"./chunk-7MEK5RQ7.js";import"./chunk-GVAFHRPJ.js";import{j as n}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";var l=n(p,e=>{let r=c(e),o=i(r,e.input.id),{commit:t,...a}=o.checkpoint;return e.ok({...o,checkpoint:{...a,...t?{commit:{created:t.created,nonce:t.nonce,...t.clientDataSetId?{clientDataSetId:t.clientDataSetId}:{}}}:{}}})});export{l as default};
|
|
3
|
+
//# sourceMappingURL=inspect-PQCV7LQT.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/handlers/operations/inspect.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineHandler } from 'clipact'\nimport { inspect } from '../../commands/operations/inspect.ts'\nimport { appFor, findOperation } from '../context.ts'\n\n/**\n * Show a saved operation with its input and checkpoint. The signed commit's\n * `extraData` is left out: it is long and only useful to `resume`.\n */\nexport default defineHandler(inspect, (ctx) => {\n const app = appFor(ctx)\n const op = findOperation(app, ctx.input.id)\n const { commit, ...checkpoint } = op.checkpoint\n return ctx.ok({\n ...op,\n checkpoint: {\n ...checkpoint,\n ...(commit\n ? {\n commit: {\n created: commit.created,\n nonce: commit.nonce,\n ...(commit.clientDataSetId\n ? { clientDataSetId: commit.clientDataSetId }\n : {}),\n },\n }\n : {}),\n },\n })\n})\n"],
|
|
5
|
+
"mappings": ";ySAQA,IAAOA,EAAQC,EAAcC,EAAUC,GAAQ,CAC7C,IAAMC,EAAMC,EAAOF,CAAG,EAChBG,EAAKC,EAAcH,EAAKD,EAAI,MAAM,EAAE,EACpC,CAAE,OAAAK,EAAQ,GAAGC,CAAW,EAAIH,EAAG,WACrC,OAAOH,EAAI,GAAG,CACZ,GAAGG,EACH,WAAY,CACV,GAAGG,EACH,GAAID,EACA,CACE,OAAQ,CACN,QAASA,EAAO,QAChB,MAAOA,EAAO,MACd,GAAIA,EAAO,gBACP,CAAE,gBAAiBA,EAAO,eAAgB,EAC1C,CAAC,CACP,CACF,EACA,CAAC,CACP,CACF,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["inspect_default", "defineHandler", "inspect", "ctx", "app", "appFor", "op", "findOperation", "commit", "checkpoint"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as b}from"./chunk-46FBFEBX.js";import{$ as F,X as B,Z as I,_ as K,b as y,ba as p,h as S,i as k,ja as L}from"./chunk-4DUACCJB.js";import{E as v,F as E,k as h,p as A}from"./chunk-UJQDDRQD.js";import"./chunk-35V77X3C.js";import{H as d}from"./chunk-RK6JJQZL.js";import"./chunk-7MEK5RQ7.js";import"./chunk-GVAFHRPJ.js";import{j as u,o as w}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";import{spawn as N}from"node:child_process";function D(o){let[s,e]=process.platform==="darwin"?["open",[o]]:process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",o]]:["xdg-open",[o]];try{let r=N(s,e,{detached:!0,stdio:"ignore"});r.on("error",()=>{}),r.unref()}catch{}}function c(o,s,e){let r=e.expiresAt?.toString();if(o.config.set(`sessions.${o.network}`,{...s,rootAddress:e.root,...r?{expiresAt:r}:{}}),e.missing.length>0)throw new w({code:h.permissionDenied,message:`The wallet owner did not grant: ${e.missing.join(", ")}.`,details:{missing:e.missing},next:[{by:"user",command:"fil login --fresh",description:"Start a new login and approve every requested scope"}]});return{network:o.network,address:s.address,rootAddress:e.root,scopes:e.granted,...r?{expiresAt:new Date(Number(r)*1e3).toISOString()}:{}}}var Q=u(b,async o=>{let{input:s}=o;if(s.sessionKey)throw A("FIL_SESSION_KEY is set; unset it to log in with fil-app.","sessionKey");let e=L(o),r=s.scopes??v,m=o.mode.interactive&&o.mode.agent===!1,T=s.wait??m,l=`sessions.${e.network}`,t=e.config.get(l);if(t?.rootAddress&&!s.fresh){let n=await I({client:e.client,root:d(t.rootAddress),signer:d(t.address),scopes:r});if(n.missing.length===0)return o.ok(c(e,t,{root:d(t.rootAddress),...n}));t=void 0}let U=t!=null&&t.scopes.length===r.length&&r.every(n=>t?.scopes.includes(n));if(!t||t.rootAddress||s.fresh||!U){let n=S(),_=await y(e.client,{cacheTime:0});t={privateKey:n,address:k(n).address,scopes:r,fromBlock:_.toString(),createdAt:new Date().toISOString()}}let i={...t,name:s.name??t.name??E,...s.days==null?{}:{days:s.days}};e.config.set(l,i);let a=B({consoleUrl:e.consoleUrl,address:i.address,scopes:r,network:e.network,name:i.name,days:i.days}),g={client:e.client,signer:d(i.address),scopes:r,fromBlock:BigInt(i.fromBlock)};if(!T){let n=await K(g);if(n.status==="pending")throw p(a);return o.ok(c(e,i,n))}o.log(`Approve the session key in your browser:
|
|
3
|
+
${a}`),s.open&&m&&D(a),o.progress({phase:"login",message:"Waiting for approval on chain"});let f=await F({...g,timeoutMs:s.timeout*1e3,signal:o.signal});if(f.status==="pending")throw p(a);return o.ok(c(e,i,f))});export{Q as default};
|
|
4
|
+
//# sourceMappingURL=login-GQ4PM7SA.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/auth/open-browser.ts", "../../src/handlers/login.ts"],
|
|
4
|
+
"sourcesContent": ["import { spawn } from 'node:child_process'\n\n/**\n * Open `url` in the default browser without waiting for it. Opening is best\n * effort; callers always print the URL as well.\n */\nexport function openBrowser(url: string): void {\n const [command, args] =\n process.platform === 'darwin'\n ? ['open', [url]]\n : process.platform === 'win32'\n ? ['rundll32', ['url.dll,FileProtocolHandler', url]]\n : ['xdg-open', [url]]\n try {\n const child = spawn(command, args, { detached: true, stdio: 'ignore' })\n child.on('error', () => {\n // Opening is best effort; the URL is always printed as well.\n })\n child.unref()\n } catch {\n // Same as a failed spawn: the printed URL is the fallback.\n }\n}\n", "import { CliError, defineHandler } from 'clipact'\nimport { type Address, getAddress } from 'viem'\nimport { generatePrivateKey, privateKeyToAccount } from 'viem/accounts'\nimport { getBlockNumber } from 'viem/actions'\nimport type { App } from '../app.ts'\nimport {\n buildAuthorizeUrl,\n checkAuthorization,\n readScopes,\n type ScopeGrants,\n waitForAuthorization,\n} from '../auth/login.ts'\nimport { openBrowser } from '../auth/open-browser.ts'\nimport { DEFAULT_KEY_NAME } from '../auth/scope-ids.ts'\nimport { DEFAULT_SCOPES, type ScopeId } from '../auth/scopes.ts'\nimport { loginPending } from '../auth/session.ts'\nimport { login } from '../commands/login.ts'\nimport type { StoredSession } from '../config.ts'\nimport { ErrorCodes, invalidInput } from '../errors.ts'\nimport { appFor } from './context.ts'\n\n/** Result of a completed login. */\ntype LoginResult = {\n network: string\n address: string\n rootAddress: string\n scopes: ScopeId[]\n expiresAt?: string\n}\n\n/**\n * Save an approved session. Returns the result when every requested scope\n * was granted; throws `permission_denied` with the missing scopes when some\n * were not.\n */\nfunction finishLogin(\n app: App,\n session: StoredSession,\n grants: ScopeGrants & { root: Address }\n): LoginResult {\n const expiresAt = grants.expiresAt?.toString()\n app.config.set(`sessions.${app.network}`, {\n ...session,\n rootAddress: grants.root,\n ...(expiresAt ? { expiresAt } : {}),\n })\n if (grants.missing.length > 0) {\n throw new CliError({\n code: ErrorCodes.permissionDenied,\n message: `The wallet owner did not grant: ${grants.missing.join(', ')}.`,\n details: { missing: grants.missing },\n next: [\n {\n by: 'user',\n command: 'fil login --fresh',\n description: 'Start a new login and approve every requested scope',\n },\n ],\n })\n }\n return {\n network: app.network,\n address: session.address,\n rootAddress: grants.root,\n scopes: grants.granted,\n ...(expiresAt\n ? { expiresAt: new Date(Number(expiresAt) * 1000).toISOString() }\n : {}),\n }\n}\n\n/**\n * Authorize a session key through the fil-app dashboard.\n *\n * The key is generated and saved locally before anything is opened, so an\n * interrupted login resumes with the same key. Only its address leaves this\n * machine: the owner reviews a prefilled setup page and signs the approval\n * with their wallet. The CLI finds the approval on chain, so nothing is\n * copied back. Agents and pipes never wait or open a browser: they get the\n * approval link as a `login_pending` error and run `fil login` again to\n * check.\n *\n * @see ../../../../apps/fil-app/src/routes/dashboard/setup.tsx\n */\nexport default defineHandler(login, async (ctx) => {\n const { input } = ctx\n if (input.sessionKey) {\n throw invalidInput(\n 'FIL_SESSION_KEY is set; unset it to log in with fil-app.',\n 'sessionKey'\n )\n }\n const app = appFor(ctx)\n const scopes = input.scopes ?? DEFAULT_SCOPES\n const human = ctx.mode.interactive && ctx.mode.agent === false\n const wait = input.wait ?? human\n const key = `sessions.${app.network}` as const\n let session = app.config.get(key)\n\n // Reuse a valid session that already has every requested scope.\n if (session?.rootAddress && !input.fresh) {\n const grants = await readScopes({\n client: app.client,\n root: getAddress(session.rootAddress),\n signer: getAddress(session.address),\n scopes,\n })\n if (grants.missing.length === 0) {\n return ctx.ok(\n finishLogin(app, session, {\n root: getAddress(session.rootAddress),\n ...grants,\n })\n )\n }\n session = undefined\n }\n\n // Resume a pending login for the same scopes, or start a new one.\n const sameScopes =\n session != null &&\n session.scopes.length === scopes.length &&\n scopes.every((scope) => session?.scopes.includes(scope))\n if (!session || session.rootAddress || input.fresh || !sameScopes) {\n const privateKey = generatePrivateKey()\n const fromBlock = await getBlockNumber(app.client, { cacheTime: 0 })\n session = {\n privateKey,\n address: privateKeyToAccount(privateKey).address,\n scopes,\n fromBlock: fromBlock.toString(),\n createdAt: new Date().toISOString(),\n }\n }\n\n // A resumed login keeps its name and expiry unless the input changes them.\n const pending: StoredSession = {\n ...session,\n name: input.name ?? session.name ?? DEFAULT_KEY_NAME,\n ...(input.days == null ? {} : { days: input.days }),\n }\n app.config.set(key, pending)\n const url = buildAuthorizeUrl({\n consoleUrl: app.consoleUrl,\n address: pending.address as Address,\n scopes,\n network: app.network,\n name: pending.name,\n days: pending.days,\n })\n const check = {\n client: app.client,\n signer: getAddress(pending.address),\n scopes,\n fromBlock: BigInt(pending.fromBlock),\n }\n\n if (!wait) {\n const state = await checkAuthorization(check)\n if (state.status === 'pending') throw loginPending(url)\n return ctx.ok(finishLogin(app, pending, state))\n }\n\n ctx.log(`Approve the session key in your browser:\\n ${url}`)\n if (input.open && human) openBrowser(url)\n ctx.progress({ phase: 'login', message: 'Waiting for approval on chain' })\n const state = await waitForAuthorization({\n ...check,\n timeoutMs: input.timeout * 1000,\n signal: ctx.signal,\n })\n if (state.status === 'pending') throw loginPending(url)\n return ctx.ok(finishLogin(app, pending, state))\n})\n"],
|
|
5
|
+
"mappings": ";8YAAA,OAAS,SAAAA,MAAa,qBAMf,SAASC,EAAYC,EAAmB,CAC7C,GAAM,CAACC,EAASC,CAAI,EAClB,QAAQ,WAAa,SACjB,CAAC,OAAQ,CAACF,CAAG,CAAC,EACd,QAAQ,WAAa,QACnB,CAAC,WAAY,CAAC,8BAA+BA,CAAG,CAAC,EACjD,CAAC,WAAY,CAACA,CAAG,CAAC,EAC1B,GAAI,CACF,IAAMG,EAAQL,EAAMG,EAASC,EAAM,CAAE,SAAU,GAAM,MAAO,QAAS,CAAC,EACtEC,EAAM,GAAG,QAAS,IAAM,CAExB,CAAC,EACDA,EAAM,MAAM,CACd,MAAQ,CAER,CACF,CCaA,SAASC,EACPC,EACAC,EACAC,EACa,CACb,IAAMC,EAAYD,EAAO,WAAW,SAAS,EAM7C,GALAF,EAAI,OAAO,IAAI,YAAYA,EAAI,OAAO,GAAI,CACxC,GAAGC,EACH,YAAaC,EAAO,KACpB,GAAIC,EAAY,CAAE,UAAAA,CAAU,EAAI,CAAC,CACnC,CAAC,EACGD,EAAO,QAAQ,OAAS,EAC1B,MAAM,IAAIE,EAA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,CAAG,EACtD,OAAOpB,EAAI,GAAGV,EAAYC,EAAK2B,EAASK,CAAK,CAAC,CAChD,CAAC",
|
|
6
|
+
"names": ["spawn", "openBrowser", "url", "command", "args", "child", "finishLogin", "app", "session", "grants", "expiresAt", "CliError", "ErrorCodes", "login_default", "defineHandler", "login", "ctx", "input", "invalidInput", "appFor", "scopes", "DEFAULT_SCOPES", "human", "wait", "key", "readScopes", "getAddress", "sameScopes", "scope", "privateKey", "generatePrivateKey", "fromBlock", "getBlockNumber", "privateKeyToAccount", "pending", "DEFAULT_KEY_NAME", "url", "buildAuthorizeUrl", "check", "state", "checkAuthorization", "loginPending", "openBrowser", "waitForAuthorization"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as d}from"./chunk-CU3SGKNA.js";import{ja as t}from"./chunk-4DUACCJB.js";import"./chunk-UJQDDRQD.js";import"./chunk-35V77X3C.js";import"./chunk-RK6JJQZL.js";import"./chunk-7MEK5RQ7.js";import"./chunk-GVAFHRPJ.js";import{j as n}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";var a=n(d,r=>{let o=t(r),s=`sessions.${o.network}`,e=o.config.get(s);return e&&o.config.delete(s),r.ok({network:o.network,removed:e!=null,...e?{address:e.address}:{}})});export{a as default};
|
|
3
|
+
//# sourceMappingURL=logout-7N23QWWM.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/handlers/logout.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineHandler } from 'clipact'\nimport { logout } from '../commands/logout.ts'\nimport { appFor } from './context.ts'\n\n/** Forget the saved session key for the network. */\nexport default defineHandler(logout, (ctx) => {\n const app = appFor(ctx)\n const key = `sessions.${app.network}` as const\n const session = app.config.get(key)\n if (session) app.config.delete(key)\n return ctx.ok({\n network: app.network,\n removed: session != null,\n ...(session ? { address: session.address } : {}),\n })\n})\n"],
|
|
5
|
+
"mappings": ";iSAKA,IAAOA,EAAQC,EAAcC,EAASC,GAAQ,CAC5C,IAAMC,EAAMC,EAAOF,CAAG,EAChBG,EAAM,YAAYF,EAAI,OAAO,GAC7BG,EAAUH,EAAI,OAAO,IAAIE,CAAG,EAClC,OAAIC,GAASH,EAAI,OAAO,OAAOE,CAAG,EAC3BH,EAAI,GAAG,CACZ,QAASC,EAAI,QACb,QAASG,GAAW,KACpB,GAAIA,EAAU,CAAE,QAASA,EAAQ,OAAQ,EAAI,CAAC,CAChD,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["logout_default", "defineHandler", "logout", "ctx", "app", "appFor", "key", "session"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as m}from"./chunk-VTR7BON5.js";import{b as p}from"./chunk-5EYSPKTK.js";import{V as n,ja as s,ka as a}from"./chunk-4DUACCJB.js";import"./chunk-UJQDDRQD.js";import"./chunk-35V77X3C.js";import"./chunk-RK6JJQZL.js";import"./chunk-7MEK5RQ7.js";import"./chunk-GVAFHRPJ.js";import{j as e}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";var w=e(m,t=>{let o=s(t),i=n(o.db(),{...a(o),limit:t.input.limit,cursor:t.input.cursor,all:t.input.all});return t.ok({network:o.network,resources:i.items.map(r=>({ref:r.ref,kind:r.kind,name:r.name,size:r.size,status:r.status,url:p(r,o.apiUrl).browser,createdAt:r.createdAt})),...i.nextCursor?{nextCursor:i.nextCursor}:{}})});export{w as default};
|
|
3
|
+
//# sourceMappingURL=ls-7XYH5VPL.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/handlers/ls.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineHandler } from 'clipact'\nimport { ls } from '../commands/ls.ts'\nimport { listResources } from '../state/resources.ts'\nimport { resourceUrls } from '../storage/urls.ts'\nimport { accountScope, appFor } from './context.ts'\n\n/** List managed resources, newest first, one page at a time. */\nexport default defineHandler(ls, (ctx) => {\n const app = appFor(ctx)\n const page = listResources(app.db(), {\n ...accountScope(app),\n limit: ctx.input.limit,\n cursor: ctx.input.cursor,\n all: ctx.input.all,\n })\n return ctx.ok({\n network: app.network,\n resources: page.items.map((resource) => ({\n ref: resource.ref,\n kind: resource.kind,\n name: resource.name,\n size: resource.size,\n status: resource.status,\n url: resourceUrls(resource, app.apiUrl).browser,\n createdAt: resource.createdAt,\n })),\n ...(page.nextCursor ? { nextCursor: page.nextCursor } : {}),\n })\n})\n"],
|
|
5
|
+
"mappings": ";wVAOA,IAAOA,EAAQC,EAAcC,EAAKC,GAAQ,CACxC,IAAMC,EAAMC,EAAOF,CAAG,EAChBG,EAAOC,EAAcH,EAAI,GAAG,EAAG,CACnC,GAAGI,EAAaJ,CAAG,EACnB,MAAOD,EAAI,MAAM,MACjB,OAAQA,EAAI,MAAM,OAClB,IAAKA,EAAI,MAAM,GACjB,CAAC,EACD,OAAOA,EAAI,GAAG,CACZ,QAASC,EAAI,QACb,UAAWE,EAAK,MAAM,IAAKG,IAAc,CACvC,IAAKA,EAAS,IACd,KAAMA,EAAS,KACf,KAAMA,EAAS,KACf,KAAMA,EAAS,KACf,OAAQA,EAAS,OACjB,IAAKC,EAAaD,EAAUL,EAAI,MAAM,EAAE,QACxC,UAAWK,EAAS,SACtB,EAAE,EACF,GAAIH,EAAK,WAAa,CAAE,WAAYA,EAAK,UAAW,EAAI,CAAC,CAC3D,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["ls_default", "defineHandler", "ls", "ctx", "app", "appFor", "page", "listResources", "accountScope", "resource", "resourceUrls"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a}from"./chunk-EDF5XCIN.js";import{O as n,ja as u,ka as s}from"./chunk-4DUACCJB.js";import"./chunk-UJQDDRQD.js";import"./chunk-35V77X3C.js";import"./chunk-RK6JJQZL.js";import"./chunk-7MEK5RQ7.js";import"./chunk-GVAFHRPJ.js";import{j as i}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";var f=i(a,e=>{let t=u(e),o=n(t.db(),{...s(t),limit:e.input.limit,cursor:e.input.cursor,incomplete:e.input.incomplete});return e.ok({network:t.network,operations:o.items.map(r=>({id:r.id,action:r.action,resourceRef:r.resourceRef,phase:r.phase,executionStatus:r.executionStatus,updatedAt:r.updatedAt,...r.error?{error:r.error}:{}})),...o.nextCursor?{nextCursor:o.nextCursor}:{}})});export{f as default};
|
|
3
|
+
//# sourceMappingURL=ls-ARM57VNR.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/handlers/operations/ls.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineHandler } from 'clipact'\nimport { ls } from '../../commands/operations/ls.ts'\nimport { listOperations } from '../../state/operations.ts'\nimport { accountScope, appFor } from '../context.ts'\n\n/** List operations, most recently updated first, one page at a time. */\nexport default defineHandler(ls, (ctx) => {\n const app = appFor(ctx)\n const page = listOperations(app.db(), {\n ...accountScope(app),\n limit: ctx.input.limit,\n cursor: ctx.input.cursor,\n incomplete: ctx.input.incomplete,\n })\n return ctx.ok({\n network: app.network,\n operations: page.items.map((op) => ({\n id: op.id,\n action: op.action,\n resourceRef: op.resourceRef,\n phase: op.phase,\n executionStatus: op.executionStatus,\n updatedAt: op.updatedAt,\n ...(op.error ? { error: op.error } : {}),\n })),\n ...(page.nextCursor ? { nextCursor: page.nextCursor } : {}),\n })\n})\n"],
|
|
5
|
+
"mappings": ";2SAMA,IAAOA,EAAQC,EAAcC,EAAKC,GAAQ,CACxC,IAAMC,EAAMC,EAAOF,CAAG,EAChBG,EAAOC,EAAeH,EAAI,GAAG,EAAG,CACpC,GAAGI,EAAaJ,CAAG,EACnB,MAAOD,EAAI,MAAM,MACjB,OAAQA,EAAI,MAAM,OAClB,WAAYA,EAAI,MAAM,UACxB,CAAC,EACD,OAAOA,EAAI,GAAG,CACZ,QAASC,EAAI,QACb,WAAYE,EAAK,MAAM,IAAKG,IAAQ,CAClC,GAAIA,EAAG,GACP,OAAQA,EAAG,OACX,YAAaA,EAAG,YAChB,MAAOA,EAAG,MACV,gBAAiBA,EAAG,gBACpB,UAAWA,EAAG,UACd,GAAIA,EAAG,MAAQ,CAAE,MAAOA,EAAG,KAAM,EAAI,CAAC,CACxC,EAAE,EACF,GAAIH,EAAK,WAAa,CAAE,WAAYA,EAAK,UAAW,EAAI,CAAC,CAC3D,CAAC,CACH,CAAC",
|
|
6
|
+
"names": ["ls_default", "defineHandler", "ls", "ctx", "app", "appFor", "page", "listOperations", "accountScope", "op"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a,b}from"./chunk-KAQPCD23.js";import"./chunk-GVAFHRPJ.js";import"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";export{b as default,a as firstLine};
|
|
3
|
+
//# sourceMappingURL=map-error-7POTPJ7R.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as I}from"./chunk-ZD6MKB4J.js";import{a as y,b as k}from"./chunk-IJ2NNDTJ.js";import"./chunk-ISML2NA2.js";import"./chunk-5EYSPKTK.js";import{W as p,ca as S,da as w,ia as v,ja as C,k as l,la as U}from"./chunk-4DUACCJB.js";import{k as m}from"./chunk-UJQDDRQD.js";import"./chunk-35V77X3C.js";import"./chunk-RK6JJQZL.js";import"./chunk-7MEK5RQ7.js";import"./chunk-GVAFHRPJ.js";import{j as g,p as h}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";var L=g(I,async r=>{let{input:n}=r,d=C(r),f={path:n.path,name:n.name,providerId:n.provider==null?void 0:BigInt(n.provider)};if(r.dryRun){let u,s="ready",a;try{let t=S(d);a=await w(t,l),a.length>0&&(s="scopes_missing"),u=v(d,t)}catch(t){if(!h(t))throw t;if(t.code===m.authRequired)s="login_required";else if(t.code===m.loginPending)s="login_pending";else throw t}let o=await k({...f,backend:u}),{placement:i,quote:e}=o;return r.ok({dryRun:!0,estimate:{kind:o.kind,name:o.name,size:o.size,files:o.files,...o.rootCid?{rootCid:o.rootCid}:{},network:d.network,authorization:s,...a?.length?{missingScopes:a}:{},...i?{provider:{id:i.providerId.toString(),serviceURL:i.serviceURL,...i.dataSetId==null?{}:{dataSetId:i.dataSetId.toString()}}}:{},...e?{cost:{token:"USDFC",ready:e.ready,depositNeeded:p(e.depositNeeded),needsApproval:e.needsApproval,ratePerMonth:p(e.ratePerMonth),lockup:p(e.lockup),...e.ready?{}:{fundingUrl:e.fundingUrl}}}:{},checkedAt:new Date().toISOString()}})}let P=await U(d,l,r),c=await y(P,f);return r.ok({dryRun:!1,...c,state:"ready"},{next:[{by:"agent",command:`fil get ${c.resource.ref}`,description:"Download and verify the stored content"},{by:"agent",command:`fil inspect ${c.resource.ref} --check`,description:"Check that the piece URL answers"}]})});export{L as default};
|
|
3
|
+
//# sourceMappingURL=put-EHRNCZHT.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/handlers/put.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineHandler, isCliError } from 'clipact'\nimport { PUT_SCOPES } from '../auth/scopes.ts'\nimport { missingScopes, openSession } from '../auth/session.ts'\nimport { put } from '../commands/put.ts'\nimport { ErrorCodes } from '../errors.ts'\nimport { estimatePut, startPut } from '../storage/jobs.ts'\nimport { createSynapseBackend } from '../storage/synapse.ts'\nimport type { StorageBackend } from '../storage/types.ts'\nimport { formatUsdfc } from '../usdfc.ts'\nimport { appFor, jobContext } from './context.ts'\n\n/** How ready the session key is to sign a put. */\ntype Authorization =\n | 'ready'\n | 'login_required'\n | 'login_pending'\n | 'scopes_missing'\n\n/**\n * Store a file as a raw piece, or a directory as a UnixFS CAR, with one copy\n * on one provider. With `--dry-run`, report what would be stored, where, and\n * at what cost, without signing, uploading, or creating anything.\n */\nexport default defineHandler(put, async (ctx) => {\n const { input } = ctx\n const app = appFor(ctx)\n const options = {\n path: input.path,\n name: input.name,\n providerId: input.provider == null ? undefined : BigInt(input.provider),\n }\n\n if (ctx.dryRun) {\n let backend: StorageBackend | undefined\n let authorization: Authorization = 'ready'\n let missing: string[] | undefined\n try {\n const sessionKey = openSession(app)\n missing = await missingScopes(sessionKey, PUT_SCOPES)\n if (missing.length > 0) authorization = 'scopes_missing'\n backend = createSynapseBackend(app, sessionKey)\n } catch (error) {\n if (!isCliError(error)) throw error\n if (error.code === ErrorCodes.authRequired)\n authorization = 'login_required'\n else if (error.code === ErrorCodes.loginPending)\n authorization = 'login_pending'\n else throw error\n }\n const estimate = await estimatePut({ ...options, backend })\n const { placement, quote } = estimate\n return ctx.ok({\n dryRun: true,\n estimate: {\n kind: estimate.kind,\n name: estimate.name,\n size: estimate.size,\n files: estimate.files,\n ...(estimate.rootCid ? { rootCid: estimate.rootCid } : {}),\n network: app.network,\n authorization,\n ...(missing?.length ? { missingScopes: missing } : {}),\n ...(placement\n ? {\n provider: {\n id: placement.providerId.toString(),\n serviceURL: placement.serviceURL,\n ...(placement.dataSetId == null\n ? {}\n : { dataSetId: placement.dataSetId.toString() }),\n },\n }\n : {}),\n ...(quote\n ? {\n cost: {\n token: 'USDFC' as const,\n ready: quote.ready,\n depositNeeded: formatUsdfc(quote.depositNeeded),\n needsApproval: quote.needsApproval,\n ratePerMonth: formatUsdfc(quote.ratePerMonth),\n lockup: formatUsdfc(quote.lockup),\n ...(quote.ready ? {} : { fundingUrl: quote.fundingUrl }),\n },\n }\n : {}),\n checkedAt: new Date().toISOString(),\n },\n })\n }\n\n const job = await jobContext(app, PUT_SCOPES, ctx)\n const result = await startPut(job, options)\n return ctx.ok(\n { dryRun: false, ...result, state: 'ready' },\n {\n next: [\n {\n by: 'agent',\n command: `fil get ${result.resource.ref}`,\n description: 'Download and verify the stored content',\n },\n {\n by: 'agent',\n command: `fil inspect ${result.resource.ref} --check`,\n description: 'Check that the piece URL answers',\n },\n ],\n }\n )\n})\n"],
|
|
5
|
+
"mappings": ";ycAuBA,IAAOA,EAAQC,EAAcC,EAAK,MAAOC,GAAQ,CAC/C,GAAM,CAAE,MAAAC,CAAM,EAAID,EACZE,EAAMC,EAAOH,CAAG,EAChBI,EAAU,CACd,KAAMH,EAAM,KACZ,KAAMA,EAAM,KACZ,WAAYA,EAAM,UAAY,KAAO,OAAY,OAAOA,EAAM,QAAQ,CACxE,EAEA,GAAID,EAAI,OAAQ,CACd,IAAIK,EACAC,EAA+B,QAC/BC,EACJ,GAAI,CACF,IAAMC,EAAaC,EAAYP,CAAG,EAClCK,EAAU,MAAMG,EAAcF,EAAYG,CAAU,EAChDJ,EAAQ,OAAS,IAAGD,EAAgB,kBACxCD,EAAUO,EAAqBV,EAAKM,CAAU,CAChD,OAASK,EAAO,CACd,GAAI,CAACC,EAAWD,CAAK,EAAG,MAAMA,EAC9B,GAAIA,EAAM,OAASE,EAAW,aAC5BT,EAAgB,yBACTO,EAAM,OAASE,EAAW,aACjCT,EAAgB,oBACb,OAAMO,CACb,CACA,IAAMG,EAAW,MAAMC,EAAY,CAAE,GAAGb,EAAS,QAAAC,CAAQ,CAAC,EACpD,CAAE,UAAAa,EAAW,MAAAC,CAAM,EAAIH,EAC7B,OAAOhB,EAAI,GAAG,CACZ,OAAQ,GACR,SAAU,CACR,KAAMgB,EAAS,KACf,KAAMA,EAAS,KACf,KAAMA,EAAS,KACf,MAAOA,EAAS,MAChB,GAAIA,EAAS,QAAU,CAAE,QAASA,EAAS,OAAQ,EAAI,CAAC,EACxD,QAASd,EAAI,QACb,cAAAI,EACA,GAAIC,GAAS,OAAS,CAAE,cAAeA,CAAQ,EAAI,CAAC,EACpD,GAAIW,EACA,CACE,SAAU,CACR,GAAIA,EAAU,WAAW,SAAS,EAClC,WAAYA,EAAU,WACtB,GAAIA,EAAU,WAAa,KACvB,CAAC,EACD,CAAE,UAAWA,EAAU,UAAU,SAAS,CAAE,CAClD,CACF,EACA,CAAC,EACL,GAAIC,EACA,CACE,KAAM,CACJ,MAAO,QACP,MAAOA,EAAM,MACb,cAAeC,EAAYD,EAAM,aAAa,EAC9C,cAAeA,EAAM,cACrB,aAAcC,EAAYD,EAAM,YAAY,EAC5C,OAAQC,EAAYD,EAAM,MAAM,EAChC,GAAIA,EAAM,MAAQ,CAAC,EAAI,CAAE,WAAYA,EAAM,UAAW,CACxD,CACF,EACA,CAAC,EACL,UAAW,IAAI,KAAK,EAAE,YAAY,CACpC,CACF,CAAC,CACH,CAEA,IAAME,EAAM,MAAMC,EAAWpB,EAAKS,EAAYX,CAAG,EAC3CuB,EAAS,MAAMC,EAASH,EAAKjB,CAAO,EAC1C,OAAOJ,EAAI,GACT,CAAE,OAAQ,GAAO,GAAGuB,EAAQ,MAAO,OAAQ,EAC3C,CACE,KAAM,CACJ,CACE,GAAI,QACJ,QAAS,WAAWA,EAAO,SAAS,GAAG,GACvC,YAAa,wCACf,EACA,CACE,GAAI,QACJ,QAAS,eAAeA,EAAO,SAAS,GAAG,WAC3C,YAAa,kCACf,CACF,CACF,CACF,CACF,CAAC",
|
|
6
|
+
"names": ["put_default", "defineHandler", "put", "ctx", "input", "app", "appFor", "options", "backend", "authorization", "missing", "sessionKey", "openSession", "missingScopes", "PUT_SCOPES", "createSynapseBackend", "error", "isCliError", "ErrorCodes", "estimate", "estimatePut", "placement", "quote", "formatUsdfc", "job", "jobContext", "result", "startPut"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as u}from"./chunk-7WN6TT5U.js";import{c as n,d as a}from"./chunk-IJ2NNDTJ.js";import"./chunk-ISML2NA2.js";import"./chunk-5EYSPKTK.js";import{ja as m,k as i,l as p,la as d,na as s}from"./chunk-4DUACCJB.js";import"./chunk-UJQDDRQD.js";import"./chunk-35V77X3C.js";import"./chunk-RK6JJQZL.js";import"./chunk-7MEK5RQ7.js";import"./chunk-GVAFHRPJ.js";import{j as e}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";var P=e(u,async o=>{let r=m(o),t=s(r,o.input.id);if(t.executionStatus==="completed")return o.ok(a({db:r.db(),apiUrl:r.apiUrl},t));let f=t.action==="put"?i:p,c=await d(r,f,o);return o.ok(await n(c,t.id))});export{P as default};
|
|
3
|
+
//# sourceMappingURL=resume-RLZB7L3C.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/handlers/operations/resume.ts"],
|
|
4
|
+
"sourcesContent": ["import { defineHandler } from 'clipact'\nimport { PUT_SCOPES, RM_SCOPES } from '../../auth/scopes.ts'\nimport { resume } from '../../commands/operations/resume.ts'\nimport { runOperation, savedOutcome } from '../../storage/jobs.ts'\nimport { appFor, findOperation, jobContext } from '../context.ts'\n\n/**\n * Continue an unfinished operation with its saved input. A completed one\n * returns its saved outcome without loading the session key.\n */\nexport default defineHandler(resume, async (ctx) => {\n const app = appFor(ctx)\n const op = findOperation(app, ctx.input.id)\n if (op.executionStatus === 'completed') {\n return ctx.ok(savedOutcome({ db: app.db(), apiUrl: app.apiUrl }, op))\n }\n const scopes = op.action === 'put' ? PUT_SCOPES : RM_SCOPES\n const job = await jobContext(app, scopes, ctx)\n return ctx.ok(await runOperation(job, op.id))\n})\n"],
|
|
5
|
+
"mappings": ";saAUA,IAAOA,EAAQC,EAAcC,EAAQ,MAAOC,GAAQ,CAClD,IAAMC,EAAMC,EAAOF,CAAG,EAChBG,EAAKC,EAAcH,EAAKD,EAAI,MAAM,EAAE,EAC1C,GAAIG,EAAG,kBAAoB,YACzB,OAAOH,EAAI,GAAGK,EAAa,CAAE,GAAIJ,EAAI,GAAG,EAAG,OAAQA,EAAI,MAAO,EAAGE,CAAE,CAAC,EAEtE,IAAMG,EAASH,EAAG,SAAW,MAAQI,EAAaC,EAC5CC,EAAM,MAAMC,EAAWT,EAAKK,EAAQN,CAAG,EAC7C,OAAOA,EAAI,GAAG,MAAMW,EAAaF,EAAKN,EAAG,EAAE,CAAC,CAC9C,CAAC",
|
|
6
|
+
"names": ["resume_default", "defineHandler", "resume", "ctx", "app", "appFor", "op", "findOperation", "savedOutcome", "scopes", "PUT_SCOPES", "RM_SCOPES", "job", "jobContext", "runOperation"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{b as a,c as b,d as c,e as d,f as e}from"./chunk-35V77X3C.js";import"./chunk-7MEK5RQ7.js";import"./chunk-YIAP3JO3.js";export{e as encodeToCurve,d as hashToCurve,b as schnorr,a as secp256k1,c as secp256k1_hasher};
|
|
3
|
+
//# sourceMappingURL=secp256k1-2OHXXNYZ.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{j as y,o as L,r as p}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";import{access as Q,chmod as V,mkdir as X,readdir as T,readFile as M,realpath as N,rm as O,rmdir as A,stat as Y,writeFile as R}from"node:fs/promises";import{homedir as Z}from"node:os";import{basename as ee,dirname as v,join as m,relative as te,sep as S}from"node:path";var g=".clipact.json";function E(e){return e==="global"?Z():process.cwd()}function ne(e){return e==="global"?"home directory":"current directory"}function P(e,t){return m(E(e),`.${t}`,"skills")}function B(e){return e.code==="ENOENT"}function $(e){return t=>{if(B(t))return e;throw t}}function F(e){return{name:e.name,target:e.target,path:e.path}}function x(e){let{createHash:t}=process.getBuiltinModule("node:crypto");return t("sha256").update(e).digest("hex")}function C(e){return M(e).then(x,$(void 0))}async function z(e){let t=await T(e,{recursive:!0,withFileTypes:!0}).catch($([])),s=n=>t.filter(n).map(i=>te(e,m(i.parentPath,i.name)).split(S).join("/")).sort();return{files:s(n=>n.isFile()),links:s(n=>n.isSymbolicLink())}}async function H(e){try{return await N(e)}catch(t){if(!B(t))throw t;let s=v(e);return s===e?e:m(await H(s),ee(e))}}function se(e,t){return t===e||t.startsWith(`${e}${S}`)}function ie(e){return e!==g&&!/[\\\0]/.test(e)&&e.split("/").every(t=>t!==""&&t!=="."&&t!=="..")}async function I(e){let t=await T(e,{withFileTypes:!0});return(await Promise.all(t.filter(n=>n.isDirectory()).map(({name:n})=>Q(m(e,n,"SKILL.md")).then(()=>n,()=>{})))).filter(n=>n!==void 0).sort()}async function J(e){let t=await I(e);if(t.length===0)throw new Error(`No skills with a SKILL.md found in ${e}`);return await Promise.all(t.map(async s=>{let n=m(e,s),i=(await z(n)).files.filter(a=>a!==g),r=await Promise.all(i.map(async a=>{let[l,c]=await Promise.all([M(m(n,a)),Y(m(n,a))]);return[a,{content:l,mode:c.mode&511,hash:x(l)}]}));return{name:s,files:new Map(r)}}))}async function K(e,t){let s=await M(m(e,g),"utf8").catch($(void 0));if(s!==void 0)try{let n=JSON.parse(s),i=n?.files;return n.cli===t&&typeof n.version=="string"&&typeof i=="object"&&i!==null&&!Array.isArray(i)&&Object.entries(i).every(([r,a])=>ie(r)&&typeof a=="string")?n:void 0}catch{return}}async function W(e,t){let[s,n]=await Promise.all([z(t),H(t)]);return{files:s.files,links:s.links.map(i=>m(t,i)),resolvesTo:se(e,n)?void 0:n}}function j(e){return e.links.length>0||e.resolvesTo!==void 0}async function ae(e,t,s,n,i){let r=m(P(t,n),i),a=await W(s,r),l=j(a)?void 0:await K(r,e.name),c=Object.entries(l?.files??{}),o=await Promise.all(c.map(([u])=>C(m(r,u)))),d=c.filter(([,u],f)=>o[f]!==u).map(([u])=>u);return{name:i,target:n,path:r,...a,manifest:l,edited:d}}async function D(e,t,s,n){let i=await N(E(t));return await Promise.all(p.filter(r=>s.includes(r)).flatMap(r=>n.map(a=>ae(e,t,i,r,a))))}async function G(e,t,s,n){let i=new Map(n.map(a=>[a.name,a]));return(await D(e,t,s,[...i.keys()])).map(a=>({bundle:i.get(a.name),copy:a}))}function U(e,t,s){if(j(t))return"symlink";if(!t.manifest)return t.files.length>0?"unmanaged":"missing";if(t.edited.length>0)return"edited";let n=t.manifest.files;return t.manifest.version===e.version&&Object.keys(n).length===s.files.size&&[...s.files].every(([r,{hash:a}])=>n[r]===a)?"current":"stale"}async function re(e,t){let s=e.manifest?.files??{},n=e.files.filter(r=>!(r in s)&&t.files.has(r)),i=await Promise.all(n.map(r=>C(m(e.path,r))));return n.filter((r,a)=>i[a]!==t.files.get(r)?.hash)}async function oe(e,t,s,n){let i=F(e);if(s==="symlink")return{...i,reason:"symlink",...e.resolvesTo?{files:[e.path,...e.links],resolvesTo:e.resolvesTo}:{files:e.links}};if(n||s==="missing")return;if(s==="unmanaged")return{...i,reason:"unmanaged"};let r=[...e.edited,...await re(e,t)].sort();return r.length>0?{...i,reason:"edited",files:r}:void 0}async function _(e,t){await O(m(e,t),{force:!0});let s=v(m(e,t));for(;s.startsWith(`${e}${S}`);){try{await A(s)}catch{return}s=v(s)}}async function le(e,t,s){let n=[...s.files.keys()].map(a=>m(t.path,a));await Promise.all([...new Set(n.map(a=>v(a)))].map(a=>X(a,{recursive:!0}))),await Promise.all([...s.files.values()].map(async({content:a,mode:l},c)=>{let o=n[c];await O(o,{force:!0}),await R(o,a),await V(o,l)}));let i=Object.fromEntries([...s.files].map(([a,{hash:l}])=>[a,l]));for(let a of Object.keys(t.manifest?.files??{}))s.files.has(a)||t.edited.includes(a)||await _(t.path,a);let r={cli:e.name,version:e.version,files:i};await R(m(t.path,g),`${JSON.stringify(r,null,2)}
|
|
3
|
+
`)}function b(e,t,s){let n=[...t==="global"?["--scope global"]:[],...s.length===p.length?[]:s.map(i=>`--target ${i}`)];return[e.name,"skills","install",...n].join(" ")}function pe(e,t,s){return y(s,async n=>{let{scope:i,target:r,force:a}=n.input,l=await J(t),c=(await G(e,i,r,l)).map(({bundle:u,copy:f})=>({bundle:u,copy:f,state:U(e,f,u)})),o=(await Promise.all(c.map(({bundle:u,copy:f,state:w})=>oe(f,u,w,a)))).filter(u=>u!==void 0);if(o.length>0){let u=[],f=o.filter(h=>h.resolvesTo),w=ne(i);if(c.some(({copy:h})=>h.links.length>0)&&u.push({by:"user",description:"Remove the symbolic links inside these skill directories; install never writes through them"}),f.length>0){let h=i==="global"?"project":"global";u.push({by:"user",description:`Copy the skills by hand from ${t}, or replace the linked directory with a real one; install never writes outside the ${w}`},{by:"user",command:b(e,h,r),description:`Install into the ${h} scope instead`})}o.some(h=>h.reason!=="symlink")&&u.push({by:"user",command:`${b(e,i,r)} --force`,description:"Replace them, discarding local changes"});let k=o.map(h=>h.path).join(", "),q=f.map(h=>` ${h.path} resolves to ${h.resolvesTo}, outside the ${w}.`).join("");throw new L({code:"skill_conflict",message:`Not replacing skill directories with local changes, symbolic links, or files not installed by ${e.name}: ${k}.${q}`,retryable:!1,details:o,next:u})}let d=[];for(let{bundle:u,copy:f,state:w}of c){let k=w==="missing"?"installed":w==="current"?"unchanged":"updated";k!=="unchanged"&&!n.dryRun&&await le(e,f,u),d.push({...F(f),action:k})}return n.ok({scope:i,skills:d})})}function we(e,t,s){return y(s,async n=>{let{scope:i,target:r}=n.input,a=await I(t),l=[];for(let c of await D(e,i,r,a)){let o=F(c);if(!c.manifest){let f="unmanaged";c.files.length===0&&c.links.length===0?f="missing":j(c)&&(f="symlink"),l.push({...o,action:f});continue}let d=Object.keys(c.manifest.files).filter(f=>!c.edited.includes(f)),u=c.files.filter(f=>f!==g&&!d.includes(f));if(!n.dryRun){for(let f of d)await _(c.path,f);await O(m(c.path,g),{force:!0}),await A(c.path).catch(()=>{})}l.push({...o,action:"removed",...u.length>0?{kept:u}:{}})}return n.ok({scope:i,skills:l})})}function ge(e,t,s){return y(s,async n=>{let i=n.input.scope?[n.input.scope]:["project","global"],r=await J(t),a=await Promise.all(i.map(o=>G(e,o,p,r))),l=i.flatMap((o,d)=>(a[d]??[]).map(({bundle:u,copy:f})=>({name:f.name,scope:o,target:f.target,path:f.path,status:U(e,f,u),...f.manifest?{version:f.manifest.version}:{}}))),c=[];for(let o of i)l.some(d=>d.scope===o&&d.status==="stale")&&c.push({by:"agent",command:b(e,o,p),description:`Update the ${o} skills to this version`});if(l.every(o=>o.status==="missing")){let o=n.input.scope??"project";c.push({by:"agent",command:b(e,o,p),description:o==="global"?"Install the skills for every project":"Install the skills for this project"})}return n.ok({version:e.version,skills:l},{next:c})})}async function ke(e,t){let s=await Promise.all(p.map(l=>T(P("project",l)).catch($([]))));if(s.every(l=>l.length===0))return;let[n,i]=await Promise.all([I(t).then(l=>new Set(l)),N(E("project"))]),r=await Promise.all(p.flatMap((l,c)=>(s[c]??[]).filter(o=>n.has(o)).map(async o=>{let d=m(P("project",l),o),u=await K(d,e.name);if(!(!u||u.version===e.version||j(await W(i,d))))return[o,u.version]}))),a=new Map(r.filter(l=>l!==void 0));if(a.size!==0)return[...a].map(([l,c])=>`${e.name}: the installed "${l}" skill is from version ${c}; run "${e.name} skills install" to update it.`).join(`
|
|
4
|
+
`)}export{g as MANIFEST,pe as install,ke as staleNotice,ge as status,we as uninstall};
|
|
5
|
+
//# sourceMappingURL=skills.run-IDY347MW.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../clipact/src/skills.run.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n access,\n chmod,\n mkdir,\n readdir,\n readFile,\n realpath,\n rm,\n rmdir,\n stat,\n writeFile,\n} from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { basename, dirname, join, relative, sep } from 'node:path'\nimport { type CliOptions, defineHandler, type Handler } from './define.ts'\nimport { CliError, type Next } from './errors.ts'\nimport {\n type CopyStatus,\n type InstallCommand,\n type InstalledCopy,\n type RemovedCopy,\n type Scope,\n type StatusCommand,\n TARGETS,\n type Target,\n type UninstallCommand,\n} from './skills.ts'\n\n/** The file in each installed skill directory that records what the CLI wrote. */\nexport const MANIFEST = '.clipact.json'\n\n/** Contents of {@link MANIFEST}. */\ninterface Manifest {\n cli: string\n version: string\n /** SHA-256 of each installed file, by `/`-separated relative path. */\n files: Record<string, string>\n}\n\n/** A file shipped in a skill directory. */\ninterface BundleFile {\n content: Buffer\n /** Permission bits, so shipped scripts stay executable. */\n mode: number\n hash: string\n}\n\n/** A skill directory shipped with the CLI. */\ninterface Bundle {\n name: string\n files: Map<string, BundleFile>\n}\n\n/** What is on disk at a copy's path, without reading its contents. */\ninterface Location {\n /** Regular files on disk, as `/`-separated relative paths. */\n files: string[]\n /** Symbolic links inside the copy. The CLI never writes through them. */\n links: string[]\n /** Where the copy's path resolves when that is outside its scope's base directory. */\n resolvesTo: string | undefined\n}\n\n/** An installed copy of a skill, as found on disk. */\ninterface Copy extends Location {\n name: string\n target: Target\n path: string\n /** Present only when this CLI installed the copy and it is not {@link isLinked}. */\n manifest: Manifest | undefined\n /** Installed files that were changed or deleted since. */\n edited: string[]\n}\n\n/** What a copy is relative to the bundle it would be installed from. */\ntype State = CopyStatus['status']\n\n/** Why `install` will not write a copy. */\ninterface Conflict {\n name: string\n target: Target\n path: string\n reason: 'edited' | 'unmanaged' | 'symlink'\n files?: string[]\n /** Where the copy's path resolves, for a linked `.claude` or `.agents` outside the scope. */\n resolvesTo?: string\n}\n\n/** Returns the directory a scope installs under: the current or home directory. */\nfunction scopeBase(scope: Scope): string {\n return scope === 'global' ? homedir() : process.cwd()\n}\n\n/** Names a scope's base directory for messages. */\nfunction scopeBaseName(scope: Scope): string {\n return scope === 'global' ? 'home directory' : 'current directory'\n}\n\n/** Returns the skills directory of a scope and target, such as `./.claude/skills`. */\nfunction skillsRoot(scope: Scope, target: Target): string {\n return join(scopeBase(scope), `.${target}`, 'skills')\n}\n\n/** Returns `true` for a missing-file error. */\nfunction isMissing(error: unknown): boolean {\n return (error as NodeJS.ErrnoException).code === 'ENOENT'\n}\n\n/** Creates a rejection handler that returns `fallback` for a missing file and rethrows anything else. */\nfunction unlessMissing<T>(fallback: T): (error: unknown) => T {\n return (error) => {\n if (isMissing(error)) {\n return fallback\n }\n throw error\n }\n}\n\n/** Returns the identity of a copy as reported by every command. */\nfunction where(copy: Copy): Pick<Copy, 'name' | 'target' | 'path'> {\n return { name: copy.name, target: copy.target, path: copy.path }\n}\n\n/**\n * Returns the SHA-256 of a file's content. Loads `node:crypto` on first use,\n * so the stale-skill notice never pays for it.\n */\nfunction hash(content: Buffer): string {\n const { createHash } = process.getBuiltinModule('node:crypto')\n return createHash('sha256').update(content).digest('hex')\n}\n\n/** Returns the SHA-256 of a file, or `undefined` when it does not exist. */\nfunction hashFile(path: string): Promise<string | undefined> {\n return readFile(path).then(hash, unlessMissing(undefined))\n}\n\n/**\n * Lists the regular files and symbolic links below `dir` as sorted\n * `/`-separated paths, without following links; empty when it does not exist.\n */\nasync function scan(\n dir: string\n): Promise<{ files: string[]; links: string[] }> {\n const entries = await readdir(dir, {\n recursive: true,\n withFileTypes: true,\n }).catch(unlessMissing([]))\n const paths = (keep: (entry: (typeof entries)[number]) => boolean) =>\n entries\n .filter(keep)\n .map((entry) =>\n relative(dir, join(entry.parentPath, entry.name)).split(sep).join('/')\n )\n .sort()\n return {\n files: paths((entry) => entry.isFile()),\n links: paths((entry) => entry.isSymbolicLink()),\n }\n}\n\n/**\n * Resolves the symbolic links in `path`, or in its nearest existing ancestor\n * followed by the segments that do not exist yet.\n */\nasync function resolveExisting(path: string): Promise<string> {\n try {\n return await realpath(path)\n } catch (error) {\n if (!isMissing(error)) {\n throw error\n }\n const parent = dirname(path)\n return parent === path\n ? path\n : join(await resolveExisting(parent), basename(path))\n }\n}\n\n/** Returns `true` when `path`, an already resolved path, is `root` or below it. */\nfunction isInside(root: string, path: string): boolean {\n return path === root || path.startsWith(`${root}${sep}`)\n}\n\n/**\n * Returns `true` for a manifest entry that names a file inside its copy: a\n * relative `/`-separated path without empty, `.`, or `..` segments.\n */\nfunction isSafePath(file: string): boolean {\n return (\n file !== MANIFEST &&\n !/[\\\\\\0]/.test(file) &&\n file\n .split('/')\n .every((part) => part !== '' && part !== '.' && part !== '..')\n )\n}\n\n/** Lists the names of the directories in `source` that contain a `SKILL.md`. */\nasync function bundleNames(source: string): Promise<string[]> {\n const entries = await readdir(source, { withFileTypes: true })\n const names = await Promise.all(\n entries\n .filter((entry) => entry.isDirectory())\n .map(({ name }) =>\n access(join(source, name, 'SKILL.md')).then(\n () => name,\n () => undefined\n )\n )\n )\n return names.filter((name) => name !== undefined).sort()\n}\n\n/** Reads every skill directory in `source` that contains a `SKILL.md`. */\nasync function readBundles(source: string): Promise<Bundle[]> {\n const names = await bundleNames(source)\n if (names.length === 0) {\n throw new Error(`No skills with a SKILL.md found in ${source}`)\n }\n return await Promise.all(\n names.map(async (name) => {\n const dir = join(source, name)\n const paths = (await scan(dir)).files.filter((path) => path !== MANIFEST)\n const files = await Promise.all(\n paths.map(async (path): Promise<[string, BundleFile]> => {\n const [content, info] = await Promise.all([\n readFile(join(dir, path)),\n stat(join(dir, path)),\n ])\n return [\n path,\n { content, mode: info.mode & 0o777, hash: hash(content) },\n ]\n })\n )\n return { name, files: new Map(files) }\n })\n )\n}\n\n/**\n * Reads a copy's manifest; `undefined` when absent, invalid, written by\n * another CLI, or listing a path outside the copy.\n */\nasync function readManifest(\n path: string,\n cli: string\n): Promise<Manifest | undefined> {\n const text = await readFile(join(path, MANIFEST), 'utf8').catch(\n unlessMissing(undefined)\n )\n if (text === undefined) {\n return undefined\n }\n try {\n const manifest = JSON.parse(text) as Manifest\n const files: unknown = manifest?.files\n return manifest.cli === cli &&\n typeof manifest.version === 'string' &&\n typeof files === 'object' &&\n files !== null &&\n !Array.isArray(files) &&\n Object.entries(files).every(\n ([file, digest]) => isSafePath(file) && typeof digest === 'string'\n )\n ? manifest\n : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * Lists a copy's files and links, and where it resolves when that is outside\n * `base`, the scope's resolved directory, such as through a linked `.claude`.\n */\nasync function locate(base: string, path: string): Promise<Location> {\n const [found, real] = await Promise.all([scan(path), resolveExisting(path)])\n return {\n files: found.files,\n links: found.links.map((link) => join(path, link)),\n resolvesTo: isInside(base, real) ? undefined : real,\n }\n}\n\n/**\n * Returns `true` when writing a copy would follow a symbolic link: one inside\n * it, or a linked directory that resolves outside its scope. `install` never\n * writes such a copy, even with `--force`.\n */\nfunction isLinked(location: Location): boolean {\n return location.links.length > 0 || location.resolvesTo !== undefined\n}\n\n/** Inspects the copy of a skill in one skills directory; `base` is the scope's resolved directory. */\nasync function inspect(\n cli: CliOptions,\n scope: Scope,\n base: string,\n target: Target,\n name: string\n): Promise<Copy> {\n const path = join(skillsRoot(scope, target), name)\n const location = await locate(base, path)\n const manifest = isLinked(location)\n ? undefined\n : await readManifest(path, cli.name)\n const listed = Object.entries(manifest?.files ?? {})\n const hashes = await Promise.all(\n listed.map(([file]) => hashFile(join(path, file)))\n )\n const edited = listed\n .filter(([, expected], index) => hashes[index] !== expected)\n .map(([file]) => file)\n return { name, target, path, ...location, manifest, edited }\n}\n\n/** Inspects each named skill in each selected skills directory, in installation order. */\nasync function inspectAll(\n cli: CliOptions,\n scope: Scope,\n targets: readonly Target[],\n names: readonly string[]\n): Promise<Copy[]> {\n const base = await realpath(scopeBase(scope))\n return await Promise.all(\n TARGETS.filter((target) => targets.includes(target)).flatMap((target) =>\n names.map((name) => inspect(cli, scope, base, target, name))\n )\n )\n}\n\n/** Inspects the copies of each bundle, paired with the bundle. */\nasync function inspectBundles(\n cli: CliOptions,\n scope: Scope,\n targets: readonly Target[],\n bundles: readonly Bundle[]\n): Promise<{ bundle: Bundle; copy: Copy }[]> {\n const byName = new Map(bundles.map((bundle) => [bundle.name, bundle]))\n const copies = await inspectAll(cli, scope, targets, [...byName.keys()])\n return copies.map((copy) => ({\n bundle: byName.get(copy.name) as Bundle,\n copy,\n }))\n}\n\n/** Classifies a copy against the bundle it would be installed from. */\nfunction stateOf(cli: CliOptions, copy: Copy, bundle: Bundle): State {\n if (isLinked(copy)) {\n return 'symlink'\n }\n if (!copy.manifest) {\n return copy.files.length > 0 ? 'unmanaged' : 'missing'\n }\n if (copy.edited.length > 0) {\n return 'edited'\n }\n const installed = copy.manifest.files\n const current =\n copy.manifest.version === cli.version &&\n Object.keys(installed).length === bundle.files.size &&\n [...bundle.files].every(([file, { hash }]) => installed[file] === hash)\n return current ? 'current' : 'stale'\n}\n\n/** Lists files the manifest does not list that the bundle would replace with different content. */\nasync function overwrites(copy: Copy, bundle: Bundle): Promise<string[]> {\n const listed = copy.manifest?.files ?? {}\n const local = copy.files.filter(\n (file) => !(file in listed) && bundle.files.has(file)\n )\n const hashes = await Promise.all(\n local.map((file) => hashFile(join(copy.path, file)))\n )\n return local.filter(\n (file, index) => hashes[index] !== bundle.files.get(file)?.hash\n )\n}\n\n/**\n * Returns why `install` must not write a copy: symbolic links always; without\n * `--force`, a copy this CLI did not install, edited files, or local files\n * the bundle would overwrite.\n */\nasync function conflictOf(\n copy: Copy,\n bundle: Bundle,\n state: State,\n force: boolean\n): Promise<Conflict | undefined> {\n const base = where(copy)\n if (state === 'symlink') {\n return {\n ...base,\n reason: 'symlink',\n ...(copy.resolvesTo\n ? { files: [copy.path, ...copy.links], resolvesTo: copy.resolvesTo }\n : { files: copy.links }),\n }\n }\n if (force || state === 'missing') {\n return undefined\n }\n if (state === 'unmanaged') {\n return { ...base, reason: 'unmanaged' }\n }\n const files = [...copy.edited, ...(await overwrites(copy, bundle))].sort()\n return files.length > 0 ? { ...base, reason: 'edited', files } : undefined\n}\n\n/** Removes a file, then any directories it leaves empty below `root`. */\nasync function removeFile(root: string, file: string): Promise<void> {\n await rm(join(root, file), { force: true })\n let dir = dirname(join(root, file))\n while (dir.startsWith(`${root}${sep}`)) {\n try {\n await rmdir(dir)\n } catch {\n return\n }\n dir = dirname(dir)\n }\n}\n\n/**\n * Writes a bundle into a copy with its file modes, removes unedited files the\n * previous version installed, and records the manifest.\n */\nasync function write(cli: CliOptions, copy: Copy, bundle: Bundle) {\n const paths = [...bundle.files.keys()].map((file) => join(copy.path, file))\n await Promise.all(\n [...new Set(paths.map((path) => dirname(path)))].map((dir) =>\n mkdir(dir, { recursive: true })\n )\n )\n await Promise.all(\n [...bundle.files.values()].map(async ({ content, mode }, index) => {\n const path = paths[index] as string\n // Replace rather than overwrite: a previous copy of a read-only file\n // cannot be opened for writing.\n await rm(path, { force: true })\n await writeFile(path, content)\n await chmod(path, mode)\n })\n )\n const files = Object.fromEntries(\n [...bundle.files].map(([file, { hash }]) => [file, hash])\n )\n for (const file of Object.keys(copy.manifest?.files ?? {})) {\n if (!(bundle.files.has(file) || copy.edited.includes(file))) {\n await removeFile(copy.path, file)\n }\n }\n const manifest: Manifest = { cli: cli.name, version: cli.version, files }\n await writeFile(\n join(copy.path, MANIFEST),\n `${JSON.stringify(manifest, null, 2)}\\n`\n )\n}\n\n/** Returns the `skills install` command line for a scope and target selection. */\nfunction installCommand(\n cli: CliOptions,\n scope: Scope,\n targets: readonly Target[]\n): string {\n const flags = [\n ...(scope === 'global' ? ['--scope global'] : []),\n ...(targets.length === TARGETS.length\n ? []\n : targets.map((target) => `--target ${target}`)),\n ]\n return [cli.name, 'skills', 'install', ...flags].join(' ')\n}\n\n/**\n * Creates the `skills install` handler: copies each bundled skill into the\n * selected skills directories, refusing to replace edited or unmanaged\n * copies without `--force`.\n */\nexport function install(\n cli: CliOptions,\n source: string,\n command: InstallCommand\n): Handler {\n return defineHandler(command, async (ctx) => {\n const { scope, target: targets, force } = ctx.input\n const bundles = await readBundles(source)\n const copies = (await inspectBundles(cli, scope, targets, bundles)).map(\n ({ bundle, copy }) => ({\n bundle,\n copy,\n state: stateOf(cli, copy, bundle),\n })\n )\n const conflicts = (\n await Promise.all(\n copies.map(({ bundle, copy, state }) =>\n conflictOf(copy, bundle, state, force)\n )\n )\n ).filter((conflict) => conflict !== undefined)\n if (conflicts.length > 0) {\n const next: Next[] = []\n const outside = conflicts.filter((conflict) => conflict.resolvesTo)\n const base = scopeBaseName(scope)\n if (copies.some(({ copy }) => copy.links.length > 0)) {\n next.push({\n by: 'user',\n description:\n 'Remove the symbolic links inside these skill directories; install never writes through them',\n })\n }\n if (outside.length > 0) {\n const other: Scope = scope === 'global' ? 'project' : 'global'\n next.push(\n {\n by: 'user',\n description: `Copy the skills by hand from ${source}, or replace the linked directory with a real one; install never writes outside the ${base}`,\n },\n {\n by: 'user',\n command: installCommand(cli, other, targets),\n description: `Install into the ${other} scope instead`,\n }\n )\n }\n if (conflicts.some((conflict) => conflict.reason !== 'symlink')) {\n next.push({\n by: 'user',\n command: `${installCommand(cli, scope, targets)} --force`,\n description: 'Replace them, discarding local changes',\n })\n }\n const paths = conflicts.map((conflict) => conflict.path).join(', ')\n const resolved = outside\n .map(\n (conflict) =>\n ` ${conflict.path} resolves to ${conflict.resolvesTo}, outside the ${base}.`\n )\n .join('')\n throw new CliError({\n code: 'skill_conflict',\n message: `Not replacing skill directories with local changes, symbolic links, or files not installed by ${cli.name}: ${paths}.${resolved}`,\n retryable: false,\n details: conflicts,\n next,\n })\n }\n const skills: InstalledCopy[] = []\n for (const { bundle, copy, state } of copies) {\n const action =\n state === 'missing'\n ? 'installed'\n : state === 'current'\n ? 'unchanged'\n : 'updated'\n if (action !== 'unchanged' && !ctx.dryRun) {\n await write(cli, copy, bundle)\n }\n skills.push({ ...where(copy), action })\n }\n return ctx.ok({ scope, skills })\n })\n}\n\n/**\n * Creates the `skills uninstall` handler: removes the files this CLI\n * installed and nobody edited, and keeps everything else.\n */\nexport function uninstall(\n cli: CliOptions,\n source: string,\n command: UninstallCommand\n): Handler {\n return defineHandler(command, async (ctx) => {\n const { scope, target: targets } = ctx.input\n const names = await bundleNames(source)\n const skills: RemovedCopy[] = []\n for (const copy of await inspectAll(cli, scope, targets, names)) {\n const base = where(copy)\n if (!copy.manifest) {\n let action: RemovedCopy['action'] = 'unmanaged'\n if (copy.files.length === 0 && copy.links.length === 0) {\n action = 'missing'\n } else if (isLinked(copy)) {\n action = 'symlink'\n }\n skills.push({ ...base, action })\n continue\n }\n const remove = Object.keys(copy.manifest.files).filter(\n (file) => !copy.edited.includes(file)\n )\n const kept = copy.files.filter(\n (file) => file !== MANIFEST && !remove.includes(file)\n )\n if (!ctx.dryRun) {\n for (const file of remove) {\n await removeFile(copy.path, file)\n }\n await rm(join(copy.path, MANIFEST), { force: true })\n await rmdir(copy.path).catch(() => undefined)\n }\n skills.push({\n ...base,\n action: 'removed',\n ...(kept.length > 0 ? { kept } : {}),\n })\n }\n return ctx.ok({ scope, skills })\n })\n}\n\n/**\n * Creates the `skills status` handler: reports each copy of each bundled\n * skill in both scopes, or the requested one.\n */\nexport function status(\n cli: CliOptions,\n source: string,\n command: StatusCommand\n): Handler {\n return defineHandler(command, async (ctx) => {\n const scopes: Scope[] = ctx.input.scope\n ? [ctx.input.scope]\n : ['project', 'global']\n const bundles = await readBundles(source)\n const inspected = await Promise.all(\n scopes.map((scope) => inspectBundles(cli, scope, TARGETS, bundles))\n )\n const skills: CopyStatus[] = scopes.flatMap((scope, index) =>\n (inspected[index] ?? []).map(({ bundle, copy }) => ({\n name: copy.name,\n scope,\n target: copy.target,\n path: copy.path,\n status: stateOf(cli, copy, bundle),\n ...(copy.manifest ? { version: copy.manifest.version } : {}),\n }))\n )\n const next: Next[] = []\n for (const scope of scopes) {\n if (\n skills.some((copy) => copy.scope === scope && copy.status === 'stale')\n ) {\n next.push({\n by: 'agent',\n command: installCommand(cli, scope, TARGETS),\n description: `Update the ${scope} skills to this version`,\n })\n }\n }\n if (skills.every((copy) => copy.status === 'missing')) {\n const scope = ctx.input.scope ?? 'project'\n next.push({\n by: 'agent',\n command: installCommand(cli, scope, TARGETS),\n description:\n scope === 'global'\n ? 'Install the skills for every project'\n : 'Install the skills for this project',\n })\n }\n return ctx.ok({ version: cli.version, skills }, { next })\n })\n}\n\n/**\n * Returns a notice for project skills installed by another CLI version, or\n * `undefined`. Reads only the manifests of installed directories named like\n * a bundled skill, so it stays cheap enough to run after every human-mode\n * command, and skips {@link isLinked} copies, which `install` never writes.\n */\nexport async function staleNotice(\n cli: CliOptions,\n source: string\n): Promise<string | undefined> {\n const installed = await Promise.all(\n TARGETS.map((target) =>\n readdir(skillsRoot('project', target)).catch(unlessMissing([]))\n )\n )\n // Most projects have none of this CLI's skills; skip reading the bundle then.\n if (installed.every((entries) => entries.length === 0)) {\n return undefined\n }\n const [shipped, base] = await Promise.all([\n bundleNames(source).then((names) => new Set(names)),\n realpath(scopeBase('project')),\n ])\n const found = await Promise.all(\n TARGETS.flatMap((target, index) =>\n (installed[index] ?? [])\n .filter((name) => shipped.has(name))\n .map(async (name): Promise<[string, string] | undefined> => {\n const path = join(skillsRoot('project', target), name)\n const manifest = await readManifest(path, cli.name)\n if (\n !manifest ||\n manifest.version === cli.version ||\n isLinked(await locate(base, path))\n ) {\n return undefined\n }\n return [name, manifest.version]\n })\n )\n )\n const stale = new Map(found.filter((entry) => entry !== undefined))\n if (stale.size === 0) {\n return undefined\n }\n return [...stale]\n .map(\n ([name, version]) =>\n `${cli.name}: the installed \"${name}\" skill is from version ${version}; run \"${cli.name} skills install\" to update it.`\n )\n .join('\\n')\n}\n"],
|
|
5
|
+
"mappings": ";kFAAA,OACE,UAAAA,EACA,SAAAC,EACA,SAAAC,EACA,WAAAC,EACA,YAAAC,EACA,YAAAC,EACA,MAAAC,EACA,SAAAC,EACA,QAAAC,EACA,aAAAC,MACK,mBACP,OAAS,WAAAC,MAAe,UACxB,OAAS,YAAAC,GAAU,WAAAC,EAAS,QAAAC,EAAM,YAAAC,GAAU,OAAAC,MAAW,YAg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AS,EAGnB,MAAO,CAAC,GAAGA,CAAK,EACb,IACC,CAAC,CAACvE,EAAMwE,CAAO,IACb,GAAGhE,EAAI,IAAI,oBAAoBR,CAAI,2BAA2BwE,CAAO,UAAUhE,EAAI,IAAI,gCAAgC,EAE1H,KAAK;CAAI,CACd",
|
|
6
|
+
"names": ["access", "chmod", "mkdir", "readdir", "readFile", "realpath", "rm", "rmdir", "stat", "writeFile", "homedir", "basename", "dirname", "join", "relative", "sep", "MANIFEST", "scopeBase", "scope", "homedir", "scopeBaseName", "skillsRoot", "target", "join", "isMissing", "error", "unlessMissing", "fallback", "where", "copy", "hash", "content", "createHash", "hashFile", "path", "readFile", "scan", "dir", "entries", "readdir", "paths", "keep", "entry", "relative", "sep", "resolveExisting", "realpath", "parent", "dirname", "basename", "isInside", "root", "isSafePath", "file", "part", "bundleNames", "source", "name", "access", "readBundles", "names", "files", "info", "stat", "readManifest", "cli", "text", "manifest", "digest", "locate", "base", "found", "real", "link", "isLinked", "location", "inspect", "listed", "hashes", "edited", "expected", "index", "inspectAll", "targets", "TARGETS", "inspectBundles", "bundles", "byName", "bundle", "stateOf", "installed", "overwrites", "local", "conflictOf", "state", "force", "removeFile", "rm", "rmdir", "write", "mkdir", "mode", "writeFile", "chmod", "installCommand", "flags", "install", "command", "defineHandler", "ctx", "copies", "conflicts", "conflict", "next", "outside", "other", "resolved", "CliError", "skills", "action", "uninstall", "remove", "kept", "status", "scopes", "inspected", "staleNotice", "shipped", "stale", "version"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import{a as D}from"./chunk-XQRC2SUG.js";import{D as F,G as S,H as E,W as u,Y as v,a as P,aa as I,b as C,c as R,ea as T,f,fa as N,g as b,ga as L,ha as O,i as x,j as y,ja as U}from"./chunk-4DUACCJB.js";import{k as w}from"./chunk-UJQDDRQD.js";import"./chunk-35V77X3C.js";import"./chunk-RK6JJQZL.js";import"./chunk-7MEK5RQ7.js";import"./chunk-GVAFHRPJ.js";import{j as A,p as h}from"./chunk-4BBXH7CB.js";import"./chunk-YIAP3JO3.js";function H(t){let e=f(t.chain);return{abi:e.contracts.filecoinPay.abi,address:t.contractAddress??e.contracts.filecoinPay.address,functionName:"getRail",args:[t.railId]}}async function M(t,e){let{cursor:o,limit:a}=S(e,100n),s=await P(t,W({chain:t.chain,payer:e.payer,token:e.token,offset:o,limit:a,contractAddress:e.contractAddress}));return z(s)}function W(t){let e=f(t.chain),o=t.token??e.contracts.usdfc.address;return{abi:e.contracts.filecoinPay.abi,address:t.contractAddress??e.contracts.filecoinPay.address,functionName:"getRailsForPayerAndToken",args:[t.payer,o,t.offset,t.limit]}}function z(t){return{items:t[0].map(e=>({railId:e.railId,isTerminated:e.isTerminated,endEpoch:e.endEpoch})),...t[1]<t[2]?{nextCursor:t[1]}:{},total:t[2]}}async function B(t,e){let o=0n,a=[],s=async()=>{if(a.length>0){let c=await R(t,{allowFailure:!1,contracts:a.map(r=>H({chain:t.chain,railId:r.railId,contractAddress:e.contractAddress}))});for(let r of c)o+=r.lockupFixed}a=[]};for await(let c of E(({cursor:r})=>M(t,{payer:e.address,token:e.token,contractAddress:e.contractAddress,cursor:r,limit:100n})))a.push(c),a.length===100&&await s();return await s(),{totalFixedLockup:o}}async function _(t,e){let{address:o,token:a,epoch:s,contractAddress:c}=e,[r,i,m]=await Promise.all([N(t,{address:o,token:a,contractAddress:c,blockNumber:s}),B(t,{address:o,token:a,contractAddress:c}),s??C(t,{cacheTime:0})]),p={funds:r.funds,lockupCurrent:r.lockupCurrent,lockupRate:r.lockupRate,lockupLastSettledAt:r.lockupLastSettledAt,currentEpoch:m},{availableFunds:n,runwayInEpochs:l,grossCoverageInEpochs:d}=L(p),j=T(p),k=r.funds>n?r.funds-n:0n,{totalFixedLockup:g}=i,K=k>g?k-g:0n;return{funds:r.funds,availableFunds:n,debt:j,lockupRatePerEpoch:r.lockupRate,lockupRatePerMonth:r.lockupRate*F.EPOCHS_PER_MONTH,totalLockup:k,totalFixedLockup:g,totalRateBasedLockup:K,runwayInEpochs:l,grossCoverageInEpochs:d,epoch:m}}var G=1n<<20n,Ce=A(D,async t=>{let e=U(t),o;try{o=I(e)}catch(n){if(h(n)&&n.code===w.loginPending){let l=e.config.get(`sessions.${e.network}`),{url:d}=n.details;return t.ok({network:e.network,session:{state:"pending",...l?{address:l.address}:{},url:d}})}throw n}if(!o)return t.ok({network:e.network,session:{state:"none"}});let a=o.rootAddress,s=x(o.privateKey).address,[c,r,i]=await Promise.all([b(e.client,{address:a,sessionKeyAddress:s,permissions:Object.values(y)}),_(e.client,{address:a}),O(e.client,{clientAddress:a,pieceSizes:[G],isNewDataSet:!0})]),m=BigInt(Math.floor(Date.now()/1e3)),p=Object.fromEntries(Object.entries(y).map(([n,l])=>{let d=c[l]??0n;return[n,d>m?new Date(Number(d)*1e3).toISOString():d>0n?"expired":"not granted"]}));return t.ok({network:e.network,session:{state:"active",source:o.source,address:s,rootAddress:a,scopes:p},account:{token:"USDFC",funds:u(r.funds),availableFunds:u(r.availableFunds),debt:u(r.debt),ready:i.ready,needsApproval:i.needsFwssMaxApproval,depositNeeded:u(i.depositNeeded),...i.ready?{}:{fundingUrl:v({consoleUrl:e.consoleUrl,network:e.network,deposit:i.depositNeeded})}}})});export{Ce as default};
|
|
3
|
+
//# sourceMappingURL=status-D4CXVYRA.js.map
|