@hyperscale0/cli 1.0.0-beta.8 → 1.0.0-beta.9
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/hyperscale.js +33 -33
- package/package.json +1 -1
package/hyperscale.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{spawn as
|
|
2
|
+
import{spawn as Se}from"node:child_process";import{createHash as Je}from"node:crypto";import{createServer as Be}from"node:http";import{createInterface as Ke}from"node:readline/promises";import{chmod as G,mkdir as Ye,readdir as Fe,readFile as F,rename as qe,unlink as Me,writeFile as ze}from"node:fs/promises";import{homedir as Ve}from"node:os";import{basename as We,dirname as ee,join as q}from"node:path";var ce="https://hyperscale0.ai",ue="sandbox",de="hyperscale-cli-session",Ge="/v1/personal-access-tokens/current",te=process.platform==="darwin"?"/usr/bin/security":null,Xe="config.json",ne="https://hyperscale0.ai/desk/security/tokens",N="https://hyperscale0.ai/request-access",O=`Mint a founder PAT in the portal at ${ne}. Open Security, then Personal access tokens.`,Qe=`Not logged in. Run "hyperscale auth login" to open portal sign-in. In a headless environment, ${O} Then set HYPERSCALE_TOKEN or pass --token. Unapproved founders can request access at ${N}.`,Ze=`Run "hyperscale auth login". For headless use, ${O} Unapproved founders can request access at ${N}.`,oe=3e4,et=2e3,tt=120*1e3,nt=/^prd_(sandbox|live)_[a-z0-9]{8,64}$/,ot=`hyperscale <command> [options]
|
|
3
3
|
|
|
4
4
|
Commands:
|
|
5
5
|
start Create a Product and run its first published journey step
|
|
@@ -33,8 +33,8 @@ Options:
|
|
|
33
33
|
--revoke Revoke the active founder PAT during auth logout
|
|
34
34
|
--no-browser Skip browser login and print the founder PAT path
|
|
35
35
|
--api-key <key> Product API key (default: $HYPERSCALE_API_KEY)
|
|
36
|
-
--base-url <url> API origin (default: $HYPERSCALE_BASE_URL, else ${
|
|
37
|
-
--environment <name> sandbox or live (default: $HYPERSCALE_ENVIRONMENT, else ${
|
|
36
|
+
--base-url <url> API origin (default: $HYPERSCALE_BASE_URL, else ${ce})
|
|
37
|
+
--environment <name> sandbox or live (default: $HYPERSCALE_ENVIRONMENT, else ${ue})
|
|
38
38
|
--email <email> Email for team invite
|
|
39
39
|
--role <role> Seeded role name or custom role id for team invite
|
|
40
40
|
--blueprint <slug> Blueprint for non-interactive start or product create
|
|
@@ -65,8 +65,8 @@ key. The explicit flag wins over its environment variable. Founder logins use
|
|
|
65
65
|
macOS Keychain when available. Set HYPERSCALE_CREDENTIAL_STORE=file to keep the
|
|
66
66
|
founder PAT in the owner-only CLI profile instead and skip Keychain access.
|
|
67
67
|
|
|
68
|
-
${
|
|
69
|
-
Request access at ${
|
|
68
|
+
${O}
|
|
69
|
+
Request access at ${N}.
|
|
70
70
|
|
|
71
71
|
Examples:
|
|
72
72
|
hyperscale start
|
|
@@ -91,36 +91,36 @@ Examples:
|
|
|
91
91
|
hyperscale call account.list --input-file input.json
|
|
92
92
|
printf '{"limit":5}' | hyperscale call account.list
|
|
93
93
|
hyperscale call account.retrieve --input '{"accountId":"acct_sandbox_..."}'
|
|
94
|
-
`,ge={start:{usage:"start [--blueprint <slug>] [--name <name>] [--json]",summary:"Choose a catalog company, create its Product, and run its first published runnable journey step.",options:["--blueprint <slug> Skip the prompt and choose this catalog Blueprint.","--name <name> Product name. Defaults to the selected Blueprint name.","--json Print one machine document, including the one-time API key under shown_once."],notes:["The command requires an active founder login.","Without --blueprint, start requires an interactive terminal and asks which company to build.","Scripts and agents must pass --blueprint <slug>.","Machine output returns the Product API key only under shown_once.","A Blueprint without a published runnable journey stops after composition and names the next command."],example:"hyperscale start --blueprint vehicle-escrow-marketplace --json"},"auth login":{usage:"auth login [--no-browser] [--token <pat>]",summary:"Sign in through the portal callback or save a founder PAT.",options:["--no-browser Skip the portal callback. Print where to mint a PAT when no token is set.","--token <pat> Founder PAT. Defaults to HYPERSCALE_TOKEN.","--json Print the saved session summary as one JSON document."],notes:["Without a PAT, the CLI opens portal sign-in and accepts one localhost callback.","Headless environments should pass --no-browser and set HYPERSCALE_TOKEN or --token to a portal-minted founder PAT.","Set HYPERSCALE_CREDENTIAL_STORE=file to use the 0600 profile file instead of macOS Keychain."],example:"hyperscale auth login --no-browser"},"auth status":{usage:"auth status [--json]",summary:"Verify and show the active founder PAT and selected Product.",options:["--json Print machine-readable JSON."],example:"hyperscale auth status --json"},"auth logout":{usage:"auth logout [--revoke] [--json]",summary:"Forget the local founder PAT. Optionally revoke it first.",options:["--revoke Revoke the PAT before deleting local state.","--json Print machine-readable JSON."],example:"hyperscale auth logout --revoke"},"blueprint list":{usage:"blueprint list [--json]",summary:"List public Blueprints without authentication.",options:["--json Print the complete collection as JSON."],example:"hyperscale blueprint list"},"blueprint show":{usage:"blueprint show <id> [--json]",summary:"Show one public Blueprint.",options:["--json Print the complete Blueprint as JSON."],example:"hyperscale blueprint show luxury-goods-consignment-escrow"},"product create":{usage:"product create --blueprint <id> --name <name> [--json]",summary:"Create and select a Product. The command refuses a duplicate name.",options:["--blueprint <id> Required Blueprint id.","--name <name> Required Product name.","--json Print the creation summary as JSON."],example:'hyperscale product create --blueprint luxury-goods-consignment-escrow --name "Luxury Consignment"'},"product list":{usage:"product list [--json]",summary:"List Products in the signed-in company.",options:["--json Print the complete collection as JSON."],example:"hyperscale product list"},"product show":{usage:"product show [id] [--json]",summary:"Show a Product summary, or the complete Product document as JSON.",options:["--json Print the complete Product document."],example:"hyperscale product show prd_sandbox_..."},"product select":{usage:"product select <id> [--json]",summary:"Verify a Product and save it as the default for later commands.",options:["--token <pat> Founder PAT. Defaults to HYPERSCALE_TOKEN or the stored login.","--base-url <url> API origin. Defaults to the active founder profile.","--environment <name> sandbox or live. Defaults to the active founder profile.","--json Print the selected Product id as JSON."],notes:["The CLI stores the selection in the active founder profile.","Product show, compose plan/apply, and key commands use it when --product is absent.","Product create and start select the Product they create."],example:"hyperscale product select prd_sandbox_..."},"product actions":{usage:"product actions [operation-id] [--product <id>] [--json]",summary:"List frozen public actions or show one action's full schemas.",options:["--product <id> Product to inspect. Defaults to the selected Product.","--api-key <key> Product API key. Defaults to HYPERSCALE_API_KEY.","--json Print machine-readable JSON."],notes:["Setup operation details include the public input schema used by hyperscale call.","When that schema has no required fields, omit --input or pass {}."],example:"hyperscale product actions escrow_order.placeBuyerHold --json"},"product run":{usage:"product run <operation-id> [--input <json> | --input-file <path>] [--idempotency-key <key>] [--json]",summary:"Run one frozen public action with a Product API key.",options:["--input <json> JSON input object. Stdin is used when piped.","--input-file <path> Read the JSON input object from a file.","--product <id> Product to call. Defaults to the selected Product.","--api-key <key> Product API key. Defaults to HYPERSCALE_API_KEY.","--idempotency-key <key> Send this exact Idempotency-Key header. The default is a generated UUID.","--json Print the key, receipt ids, and output as JSON."],notes:["Reuse an Idempotency-Key only with the same operation and input.",'If a bounded validation value appears as "[Truncated]", run "hyperscale product actions <operation-id>" for the full input schema.'],example:`hyperscale product run escrow_order.placeBuyerHold --input '{"escrowOrderId":"eord_sandbox_..."}' --idempotency-key hold-001`},"compose check":{usage:"compose check <file.hsx> [--catalog-revision <id>] [--json]",summary:"Ask the server to compile and check an HSX program.",options:["--catalog-revision <id> Compile against this immutable tenant catalog revision.","--json Print diagnostics and the verdict as JSON."],example:"hyperscale compose check product.hsx"},"compose plan":{usage:"compose plan <file.hsx> [--product <id>] [--catalog-revision <id>] [--json]",summary:"Diff an HSX program against a Product.",options:["--product <id> Product to compare. Defaults to the selected Product.","--catalog-revision <id> Compile against this immutable tenant catalog revision.","--json Print the plan as JSON."],example:"hyperscale compose plan product.hsx --json"},"compose apply":{usage:"compose apply <file.hsx> (--confirm | --yes) [--product <id>] [--catalog-revision <id>] [--json]",summary:"Recompose a Product from checked HSX.",options:["--confirm Confirm the mutation for a person.","--yes Confirm the mutation without a prompt for an agent.","--product <id> Product to recompose. Defaults to the selected Product.","--catalog-revision <id> Compile and persist against this immutable tenant catalog revision.","--json Print the result as JSON."],example:"hyperscale compose apply product.hsx --yes"},"key create":{usage:"key create [--name <name>] [--product <id>] [--json]",summary:"Create a sandbox Product API key.",options:["--name <name> Key name. Defaults to Founder CLI.","--product <id> Product for the key. Defaults to the selected Product.","--json Print the one-time secret and key metadata as JSON."],example:'hyperscale key create --name "Founder laptop"'},"key list":{usage:"key list [--product <id>] [--json]",summary:"List keys for one Product.",options:["--product <id> Product to inspect. Defaults to the selected Product.","--json Print the collection as JSON."],example:"hyperscale key list --json"},"key revoke":{usage:"key revoke <id> [--product <id>] [--json]",summary:"Revoke one Product API key.",options:["--product <id> Product that owns the key. Defaults to the selected Product.","--json Print the result as JSON."],example:"hyperscale key revoke key_sandbox_..."},"team list":{usage:"team list [--json]",summary:"List company members and pending invitations.",options:["--json Print machine-readable JSON."],example:"hyperscale team list"},"team invite":{usage:"team invite --email <email> --role <role> [--json]",summary:"Invite a company member.",options:["--email <email> Required invitee email.","--role <role> Required seeded role or custom role id.","--json Print the invitation and one-time token as JSON."],example:"hyperscale team invite --email developer@example.com --role developer"},"activity list":{usage:"activity list [--json]",summary:"List company activity with timestamps and resource targets.",options:["--json Print the complete collection as JSON."],example:"hyperscale activity list"},whoami:{usage:"whoami [--json]",summary:"Show the user and company the founder PAT resolves to.",options:["--json Print machine-readable JSON."],example:"hyperscale whoami --json"},"ops list":{usage:"ops list [filter] [--product <id>] [--json]",summary:"List callable operations from the Product machine document.",options:["--product <id> Product to inspect. The Product API key must belong to it.","--api-key <key> Product API key. Defaults to HYPERSCALE_API_KEY.","--json Print matching operations as JSON."],example:"hyperscale ops list account"},call:{usage:"call <operation> [--input <json> | --input-file <path>] [--idempotency-key <key>] [--product <id>]",summary:"Call one operation from the Product machine document.",options:["--input <json> JSON input object. Stdin is used when piped.","--input-file <path> Read the JSON input object from a file.","--product <id> Product to call. The Product API key must belong to it.","--api-key <key> Product API key. Defaults to HYPERSCALE_API_KEY.","--idempotency-key <key> Send this exact Idempotency-Key header for a mutation. The default is a generated UUID."],notes:["Reuse an Idempotency-Key only with the same operation and input."],example:`hyperscale call account.create --input '{"currency":"SAR"}'`}};function ft(e){let n=Object.keys(ge).sort((o,i)=>i.split(" ").length-o.split(" ").length).find(o=>o.split(" ").every((s,u)=>e[u]===s));if(!n)throw new c(`No help for ${e.join(" ")}. Run "hyperscale --help" to list commands.`);let r=ge[n];return[`Usage: hyperscale ${r.usage}`,"",r.summary,"","Options:",...r.options.map(o=>` ${o}`),...r.notes?["","Notes:",...r.notes.map(o=>` ${o}`)]:[],"","Example:",` ${r.example}`,""].join(`
|
|
95
|
-
`)}var c=class extends Error{constructor(t,n={}){super(t),typeof n.code=="string"&&(this.code=n.code),n.details!==void 0&&(this.details=n.details),Number.isInteger(n.exitCode)&&(this.exitCode=n.exitCode),typeof n.fix=="string"&&(this.fix=n.fix)}},C=class extends c{constructor(t,{requestId:n,status:r}){super(t),this.requestId=n,this.status=r}};function
|
|
96
|
-
`)}function
|
|
97
|
-
`)})}async function
|
|
98
|
-
`),"file"}async function
|
|
99
|
-
`),{keychainDeleted:!0};if(
|
|
100
|
-
`),{keychainDeleted:!1};let r=await W(["delete-generic-password","-a",n,"-s",
|
|
101
|
-
`),{keychainDeleted:!1}):(await
|
|
102
|
-
\r`.includes(t)?t:"")}function
|
|
103
|
-
Request id: ${o}`:""}`,{requestId:o,status:e.status})}function
|
|
94
|
+
`,we={start:{usage:"start [--blueprint <slug>] [--name <name>] [--json]",summary:"Choose a catalog company, create its Product, and run its first published runnable journey step.",options:["--blueprint <slug> Skip the prompt and choose this catalog Blueprint.","--name <name> Product name. Defaults to the selected Blueprint name.","--json Print one machine document, including the one-time API key under shown_once."],notes:["The command requires an active founder login.","Without --blueprint, start requires an interactive terminal and asks which company to build.","Scripts and agents must pass --blueprint <slug>.","Machine output returns the Product API key only under shown_once.","A Blueprint without a published runnable journey stops after composition and names the next command."],example:"hyperscale start --blueprint vehicle-escrow-marketplace --json"},"auth login":{usage:"auth login [--no-browser] [--token <pat>]",summary:"Sign in through the portal callback or save a founder PAT.",options:["--no-browser Skip the portal callback. Print where to mint a PAT when no token is set.","--token <pat> Founder PAT. Defaults to HYPERSCALE_TOKEN.","--json Print the saved session summary as one JSON document."],notes:["Without a PAT, the CLI opens portal sign-in and accepts one localhost callback.","Headless environments should pass --no-browser and set HYPERSCALE_TOKEN or --token to a portal-minted founder PAT.","Set HYPERSCALE_CREDENTIAL_STORE=file to use the 0600 profile file instead of macOS Keychain."],example:"hyperscale auth login --no-browser"},"auth status":{usage:"auth status [--json]",summary:"Verify and show the active founder PAT and selected Product.",options:["--json Print machine-readable JSON."],example:"hyperscale auth status --json"},"auth logout":{usage:"auth logout [--revoke] [--json]",summary:"Forget the local founder PAT. Optionally revoke it first.",options:["--revoke Revoke the PAT before deleting local state.","--json Print machine-readable JSON."],example:"hyperscale auth logout --revoke"},"blueprint list":{usage:"blueprint list [--json]",summary:"List public Blueprints without authentication.",options:["--json Print the complete collection as JSON."],example:"hyperscale blueprint list"},"blueprint show":{usage:"blueprint show <id> [--json]",summary:"Show one public Blueprint.",options:["--json Print the complete Blueprint as JSON."],example:"hyperscale blueprint show luxury-goods-consignment-escrow"},"product create":{usage:"product create --blueprint <id> --name <name> [--json]",summary:"Create and select a Product. The command refuses a duplicate name.",options:["--blueprint <id> Required Blueprint id.","--name <name> Required Product name.","--json Print the creation summary as JSON."],example:'hyperscale product create --blueprint luxury-goods-consignment-escrow --name "Luxury Consignment"'},"product list":{usage:"product list [--json]",summary:"List Products in the signed-in company.",options:["--json Print the complete collection as JSON."],example:"hyperscale product list"},"product show":{usage:"product show [id] [--json]",summary:"Show a Product summary, or the complete Product document as JSON.",options:["--json Print the complete Product document."],example:"hyperscale product show prd_sandbox_..."},"product select":{usage:"product select <id> [--json]",summary:"Verify a Product and save it as the default for later commands.",options:["--token <pat> Founder PAT. Defaults to HYPERSCALE_TOKEN or the stored login.","--base-url <url> API origin. Defaults to the active founder profile.","--environment <name> sandbox or live. Defaults to the active founder profile.","--json Print the selected Product id as JSON."],notes:["The CLI stores the selection in the active founder profile.","Product show, compose plan/apply, and key commands use it when --product is absent.","Product create and start select the Product they create."],example:"hyperscale product select prd_sandbox_..."},"product actions":{usage:"product actions [operation-id] [--product <id>] [--json]",summary:"List frozen public actions or show one action's full schemas.",options:["--product <id> Product to inspect. Defaults to the selected Product.","--api-key <key> Product API key. Defaults to HYPERSCALE_API_KEY.","--json Print machine-readable JSON."],notes:["Setup operation details include the public input schema used by hyperscale call.","When that schema has no required fields, omit --input or pass {}."],example:"hyperscale product actions escrow_order.placeBuyerHold --json"},"product run":{usage:"product run <operation-id> [--input <json> | --input-file <path>] [--idempotency-key <key>] [--json]",summary:"Run one frozen public action with a Product API key.",options:["--input <json> JSON input object. Stdin is used when piped.","--input-file <path> Read the JSON input object from a file.","--product <id> Product to call. Defaults to the selected Product.","--api-key <key> Product API key. Defaults to HYPERSCALE_API_KEY.","--idempotency-key <key> Send this exact Idempotency-Key header. The default is a generated UUID.","--json Print the key, receipt ids, and output as JSON."],notes:["Reuse an Idempotency-Key only with the same operation and input.",'If a bounded validation value appears as "[Truncated]", run "hyperscale product actions <operation-id>" for the full input schema.'],example:`hyperscale product run escrow_order.placeBuyerHold --input '{"escrowOrderId":"eord_sandbox_..."}' --idempotency-key hold-001`},"compose check":{usage:"compose check <file.hsx> [--catalog-revision <id>] [--json]",summary:"Ask the server to compile and check an HSX program.",options:["--catalog-revision <id> Compile against this immutable tenant catalog revision.","--json Print diagnostics and the verdict as JSON."],example:"hyperscale compose check product.hsx"},"compose plan":{usage:"compose plan <file.hsx> [--product <id>] [--catalog-revision <id>] [--json]",summary:"Diff an HSX program against a Product.",options:["--product <id> Product to compare. Defaults to the selected Product.","--catalog-revision <id> Compile against this immutable tenant catalog revision.","--json Print the plan as JSON."],example:"hyperscale compose plan product.hsx --json"},"compose apply":{usage:"compose apply <file.hsx> (--confirm | --yes) [--product <id>] [--catalog-revision <id>] [--json]",summary:"Recompose a Product from checked HSX.",options:["--confirm Confirm the mutation for a person.","--yes Confirm the mutation without a prompt for an agent.","--product <id> Product to recompose. Defaults to the selected Product.","--catalog-revision <id> Compile and persist against this immutable tenant catalog revision.","--json Print the result as JSON."],example:"hyperscale compose apply product.hsx --yes"},"key create":{usage:"key create [--name <name>] [--product <id>] [--json]",summary:"Create a sandbox Product API key.",options:["--name <name> Key name. Defaults to Founder CLI.","--product <id> Product for the key. Defaults to the selected Product.","--json Print the one-time secret and key metadata as JSON."],example:'hyperscale key create --name "Founder laptop"'},"key list":{usage:"key list [--product <id>] [--json]",summary:"List keys for one Product.",options:["--product <id> Product to inspect. Defaults to the selected Product.","--json Print the collection as JSON."],example:"hyperscale key list --json"},"key revoke":{usage:"key revoke <id> [--product <id>] [--json]",summary:"Revoke one Product API key.",options:["--product <id> Product that owns the key. Defaults to the selected Product.","--json Print the result as JSON."],example:"hyperscale key revoke key_sandbox_..."},"team list":{usage:"team list [--json]",summary:"List company members and pending invitations.",options:["--json Print machine-readable JSON."],example:"hyperscale team list"},"team invite":{usage:"team invite --email <email> --role <role> [--json]",summary:"Invite a company member.",options:["--email <email> Required invitee email.","--role <role> Required seeded role or custom role id.","--json Print the invitation and one-time token as JSON."],example:"hyperscale team invite --email developer@example.com --role developer"},"activity list":{usage:"activity list [--json]",summary:"List company activity with timestamps and resource targets.",options:["--json Print the complete collection as JSON."],example:"hyperscale activity list"},whoami:{usage:"whoami [--json]",summary:"Show the user and company the founder PAT resolves to.",options:["--json Print machine-readable JSON."],example:"hyperscale whoami --json"},"ops list":{usage:"ops list [filter] [--product <id>] [--json]",summary:"List callable operations from the Product machine document.",options:["--product <id> Product to inspect. The Product API key must belong to it.","--api-key <key> Product API key. Defaults to HYPERSCALE_API_KEY.","--json Print matching operations as JSON."],example:"hyperscale ops list account"},call:{usage:"call <operation> [--input <json> | --input-file <path>] [--idempotency-key <key>] [--product <id>]",summary:"Call one operation from the Product machine document.",options:["--input <json> JSON input object. Stdin is used when piped.","--input-file <path> Read the JSON input object from a file.","--product <id> Product to call. The Product API key must belong to it.","--api-key <key> Product API key. Defaults to HYPERSCALE_API_KEY.","--idempotency-key <key> Send this exact Idempotency-Key header for a mutation. The default is a generated UUID."],notes:["Reuse an Idempotency-Key only with the same operation and input."],example:`hyperscale call account.create --input '{"currency":"SAR"}'`}};function rt(e){let n=Object.keys(we).sort((o,a)=>a.split(" ").length-o.split(" ").length).find(o=>o.split(" ").every((s,u)=>e[u]===s));if(!n)throw new c(`No help for ${e.join(" ")}. Run "hyperscale --help" to list commands.`);let r=we[n];return[`Usage: hyperscale ${r.usage}`,"",r.summary,"","Options:",...r.options.map(o=>` ${o}`),...r.notes?["","Notes:",...r.notes.map(o=>` ${o}`)]:[],"","Example:",` ${r.example}`,""].join(`
|
|
95
|
+
`)}var c=class extends Error{constructor(t,n={}){super(t),typeof n.code=="string"&&(this.code=n.code),n.details!==void 0&&(this.details=n.details),Number.isInteger(n.exitCode)&&(this.exitCode=n.exitCode),typeof n.fix=="string"&&(this.fix=n.fix)}},C=class extends c{constructor(t,{requestId:n,status:r}){super(t),this.requestId=n,this.status=r}};function X(){return new c(Qe,{fix:Ze})}function Ae(e){let t=e??"<id>";return new c(`This command needs a Product API key. Create one with "hyperscale key create --name 'Founder CLI' --product ${t}", then set HYPERSCALE_API_KEY or pass --api-key.`)}var J=class extends c{constructor(t,n){super(t),this.code="check_failed",this.details=n,this.exitCode=2}},at=new Set(["--api-key","--base-url","--blueprint","--catalog-revision","--environment","--email","--idempotency-key","--input","--input-file","--name","--product","--role","--token"]);function it(e){let t=[],n={};for(let r=0;r<e.length;r+=1){let o=e[r];if(!o.startsWith("--")){t.push(o);continue}if(at.has(o)){let a=e[r+1];if(a===void 0)throw new c(`${o} needs a value`);n[o]=a,r+=1;continue}if(o==="--help"||o==="--version"||o==="--json"||o==="--confirm"||o==="--yes"||o==="--no-browser"||o==="--passkey"||o==="--revoke"){n[o]=!0;continue}throw new c(`Unknown option: ${o}`)}return{flags:n,positional:t}}function ge(e,t){let n=e["--api-key"]??t.HYPERSCALE_API_KEY;if(!n)throw Ae();let r=e["--environment"]??t.HYPERSCALE_ENVIRONMENT??ue;if(r!=="sandbox"&&r!=="live")throw new c(`Unknown environment: ${r}. Use sandbox or live.`);let o=(e["--base-url"]??t.HYPERSCALE_BASE_URL??ce).replace(/\/+$/,"");return{apiKey:n,baseUrl:o,environment:r}}function R(e,t,n={}){let r=e["--environment"]??t.HYPERSCALE_ENVIRONMENT??n.environment??ue;if(r!=="sandbox"&&r!=="live")throw new c(`Unknown environment: ${r}. Use sandbox or live.`);let o=(e["--base-url"]??t.HYPERSCALE_BASE_URL??n.baseUrl??ce).replace(/\/+$/,""),a;try{a=new URL(o)}catch{a=null}let s=a?.origin??null;if(!s||s!==o)throw new c(`Invalid API origin: ${o}. Use an origin such as https://hyperscale0.ai.`);let u=["localhost","127.0.0.1","[::1]","::1"].includes(a.hostname);if(a.protocol!=="https:"&&!(a.protocol==="http:"&&u))throw new c(`Refusing cleartext API origin ${o}. Use HTTPS unless the API runs on loopback.`);return{baseUrl:o,environment:r}}function ve(e){return e.HYPERSCALE_CONFIG_DIR??q(Ve(),".config","hyperscale")}function xe(e){return q(ve(e),Xe)}function P(e,t){return q(ve(t),`session-${j(e)}.json`)}function M(e){let t=e.HYPERSCALE_CREDENTIAL_STORE??"auto";if(t==="auto"||t==="file")return t;throw new c(`Unknown HYPERSCALE_CREDENTIAL_STORE value: ${t}. Use auto or file.`)}async function le(e,t){let n=P(e,t),r=`${We(n)}.`,o;try{o=await Fe(ee(n),{withFileTypes:!0})}catch(a){if(a&&a.code==="ENOENT")return;throw a}for(let a of o){if(!a.isFile()||!a.name.startsWith(r))continue;let s=a.name.slice(r.length);/^\d+\.[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.tmp$/.test(s)&&await _(q(ee(n),a.name))}}async function st(e){try{return JSON.parse(await F(e,"utf8"))}catch(t){if(t&&t.code==="ENOENT")return null;throw t instanceof SyntaxError?new c(`${e} is not valid JSON`):t}}async function E(e,t){let n=ct(e);await Ye(n,{mode:448,recursive:!0}),await G(n,448);let r=`${e}.${process.pid}.${globalThis.crypto.randomUUID()}.tmp`;await ze(r,t,{flag:"wx",mode:384}),await G(r,384);try{await qe(r,e),await G(e,384)}catch(o){throw await _(r),o}}function ct(e){return ee(e)}async function _(e){try{await Me(e)}catch(t){if(!t||t.code!=="ENOENT")throw t}}function ut(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new c(`${t} does not contain a CLI profile`);let{baseUrl:n,email:r,environment:o,selectedProduct:a}=e;if(typeof n!="string"||typeof r!="string"||o!=="sandbox"&&o!=="live"||!(a===null||typeof a=="string"))throw new c(`${t} does not contain a valid CLI profile`);return{baseUrl:n,email:r,environment:o,selectedProduct:a}}async function z(e){let t=xe(e),n=await st(t);return n===null?null:ut(n,t)}async function V(e,t){let n={email:t.email,baseUrl:t.baseUrl,environment:t.environment,selectedProduct:t.selectedProduct??null};await E(xe(e),`${JSON.stringify(n,null,2)}
|
|
96
|
+
`)}function j(e){return Je("sha256").update(`${e.baseUrl}\0${e.environment}\0${e.email}`).digest("hex")}async function W(e,t){return te===null?{error:null,status:null,stdout:"",unavailable:!0}:await new Promise(n=>{let r={...process.env};delete r.HYPERSCALE_API_KEY,delete r.HYPERSCALE_TOKEN;let o=Se(te,e,{env:r,stdio:["pipe","pipe","pipe"]}),a=[],s=!1,u=l=>{s||(s=!0,clearTimeout(d),n(l))},d=setTimeout(()=>{o.kill("SIGKILL"),u({error:null,status:null,stdout:"",unavailable:!0})},et);o.stdout.on("data",l=>a.push(l)),o.stderr.on("data",()=>{}),o.stdin.on("error",()=>{}),o.once("error",l=>u({error:l,status:null,stdout:"",unavailable:!0})),o.once("close",l=>u({error:null,status:l,stdout:Buffer.concat(a).toString("utf8"),unavailable:!1})),t===void 0?o.stdin.end():o.stdin.end(`${t}
|
|
97
|
+
`)})}async function pe(){return(await W(["show-keychain-info"])).status===0}function Te(e){try{let t=typeof e=="string"?JSON.parse(e):e;if(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.token=="string"&&typeof t.tenantId=="string"&&(t.personalAccessTokenId===void 0||typeof t.personalAccessTokenId=="string")&&(t.tokenName===void 0||typeof t.tokenName=="string"))return{token:t.token,tenantId:t.tenantId,...t.personalAccessTokenId?{personalAccessTokenId:t.personalAccessTokenId}:{},...t.tokenName?{tokenName:t.tokenName}:{}}}catch{}return null}async function dt(e,t,n){await le(e,n);let r=j(e);if(M(n)==="auto"&&await pe()){let o=JSON.stringify(t),a=["add-generic-password","-a",r,"-s",de,"-U","-X",Buffer.from(o,"utf8").toString("hex")].join(" ");if((await W(["-i"],a)).status===0)return await _(P(e,n)),"keychain"}return await E(P(e,n),`${JSON.stringify({account:r,activeStore:"file",credential:t})}
|
|
98
|
+
`),"file"}async function lt(e,t){let n=j(e);try{let r=JSON.parse(await F(P(e,t),"utf8"));if(!r||typeof r!="object"||Array.isArray(r)||r.account!==n)return{state:"invalid"};if(r.revoked===!0)return{state:"revoked"};let o=Te(r.credential);return o?{activeStore:r.activeStore==="file"?"file":null,credential:o,state:"valid"}:{state:"invalid"}}catch(r){return r&&r.code==="ENOENT"?{state:"missing"}:{state:"invalid"}}}async function Ee(e,t){await le(e,t);let n=M(t),r=await lt(e,t);if(r.state==="revoked")return null;if(r.state==="valid"&&(r.activeStore==="file"||n==="file"))return r.credential;if(n==="file")return null;let o=null;if(await pe()){let a=await W(["find-generic-password","-a",j(e),"-s",de,"-w"]);a.status===0&&(o=Te(a.stdout.trim()))}return o||(r.state==="valid"?r.credential:null)}async function Ne(e,t){await le(e,t);let n=j(e);if(M(t)==="file")return await E(P(e,t),`${JSON.stringify({account:n,revoked:!0})}
|
|
99
|
+
`),{keychainDeleted:!0};if(te===null)return await _(P(e,t)),{keychainDeleted:!0};if(!await pe())return await E(P(e,t),`${JSON.stringify({account:n,revoked:!0})}
|
|
100
|
+
`),{keychainDeleted:!1};let r=await W(["delete-generic-password","-a",n,"-s",de]);return r.status!==0&&r.status!==44?(await E(P(e,t),`${JSON.stringify({account:n,revoked:!0})}
|
|
101
|
+
`),{keychainDeleted:!1}):(await _(P(e,t)),{keychainDeleted:!0})}function Oe(e,t){return e["--token"]!==void 0?e["--token"]:t.HYPERSCALE_TOKEN||void 0}async function k(e,t,n=!1){let r=await z(t),o=Oe(e,t);if(o!==void 0){if(!o)throw X();let u=R(e,t,r??{}),d=await A(u,o),l=r?.baseUrl===u.baseUrl&&r.environment===u.environment&&r.email===d.email;return{...u,email:d.email,identity:d,personalAccessTokenId:d.personalAccessTokenId,selectedProduct:l?r.selectedProduct:null,tenantId:d.tenantId,token:o,tokenName:d.name}}if(!r){if(n)return null;throw X()}let a=R(e,t,r);if(a.baseUrl!==r.baseUrl||a.environment!==r.environment)throw new c(`The active founder login belongs to ${r.baseUrl} (${r.environment}). Log in again to change it.`);let s=await Ee(r,t);if(!s){if(n)return null;throw X()}return{...r,...s}}function B(e){return e.replace(new RegExp("\\p{Cc}","gu"),t=>`
|
|
102
|
+
\r`.includes(t)?t:"")}function K(e){try{return new URL(e).origin}catch{return null}}function S(e,t){let n=e;for(let r of t)typeof r=="string"&&r.length>0&&(n=n.replaceAll(r,"[redacted]"));return n}async function Ce(e,t,n={},r){let o=`${e.baseUrl}${t}`,a=K(e.baseUrl);if(K(o)!==a)throw new c(`The requested path ${t} leaves the ${a} origin; refusing the request.`);try{let s=await fetch(o,{...n,headers:{accept:"application/json",...r?{authorization:`Bearer ${r}`}:{},"x-hyperscale-environment":e.environment,...n.headers},signal:AbortSignal.timeout(oe),redirect:"manual"});if(s.status>=300&&s.status<400)throw new c(`${o} redirected, so no credential was sent on. Point --base-url at the origin the API answers on.`);return{response:s,text:B(await s.text())}}catch(s){throw s instanceof c?s:new c(`Could not reach ${o}: ${s.message}`)}}async function g(e,t,n={},r,o=[]){let{response:a,text:s}=await Ce(e,t,n,r);if(!a.ok)throw U(a,s,o);try{return JSON.parse(s)}catch{throw new c(`HTTP ${a.status} returned invalid JSON`)}}function I(e,t=globalThis.crypto.randomUUID()){return{body:JSON.stringify(e),headers:{"content-type":"application/json","idempotency-key":t},method:"POST"}}async function pt(){let e=[];for await(let t of process.stdin)e.push(Buffer.from(t));return Buffer.concat(e).toString("utf8")}async function L(e,t,n={},r){let o=`${e.baseUrl}${t}`,a=K(e.baseUrl);if(K(o)!==a)throw new c(`The product document puts ${t} on another origin than the ${a} you configured; refusing to send the key there.`);try{let s=await fetch(o,{...n,headers:{accept:"application/json",authorization:`Bearer ${e.apiKey}`,"x-hyperscale-environment":e.environment,...n.headers},signal:AbortSignal.timeout(oe),redirect:"manual"});if(s.status>=300&&s.status<400)throw new c(`${o} redirected, so the key was not sent on. Point --base-url at the origin the API answers on; the usual cause is http:// where it serves https://.`);return{response:s,text:B(await s.text())}}catch(s){throw s instanceof c?s:r&&(s?.name==="TimeoutError"||s?.name==="AbortError")?new c(`product run ${r} timed out after ${oe/1e3} seconds.`):new c(`Could not reach ${o}: ${s.message}`)}}async function Re(e){let{response:t,text:n}=await L(e,"/v1/product.json");if(!t.ok)throw U(t,n,[e.apiKey]);let r=mt(n);if(!r)throw new Error("The product document is not in the expected format; upgrade the CLI.");let o=r.operations.map(a=>{if(typeof a.summary!="string"||typeof a.description!="string")throw new c(`The product document carries no prose for ${a.operationId}. The server descriptor predates operation prose. Redeploy the platform, then recompose the Product.`);return{description:a.description,idempotency:a.idempotency,method:a.method,name:a.name,operationId:a.operationId,path:a.path,summary:a.summary}});return{compositionId:r.composition.id,operations:o,packageName:r.sdk?r.sdk.packageName.trim():null,title:r.title.trim()}}function mt(e){let t;try{t=JSON.parse(e)}catch{return null}let n=re(t),r=o=>typeof o=="string";if(!T(n)||n.schemaVersion!==1||!r(n.title)||!T(n.composition)||!r(n.composition.id)||!Array.isArray(n.operations))return null;for(let o of n.operations)if(!T(o)||!r(o.method)||!r(o.path)||!r(o.name)||!r(o.operationId)||!r(o.idempotency))return null;return n.sdk!==void 0&&(!T(n.sdk)||!r(n.sdk.packageName))?null:n}function T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function re(e){return typeof e=="string"?B(e):Array.isArray(e)?e.map(re):T(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[B(t),re(n)])):e}function U(e,t,n=[]){let r=S(t.trim(),n),o=e.headers.get("x-request-id")??void 0;try{let a=JSON.parse(t);a&&a.error&&typeof a.error.message=="string"&&(r=S(`${a.error.code}: ${a.error.message}`,n)),!o&&typeof a?.requestId=="string"&&(o=a.requestId)}catch{}return new C(`HTTP ${e.status}${r?` \xB7 ${r}`:""}${o?`
|
|
103
|
+
Request id: ${o}`:""}`,{requestId:o,status:e.status})}function me(e,t){return{authenticated:!0,baseUrl:e.baseUrl,email:t.email,environment:e.environment,expiresAt:t.expiresAt,personalAccessTokenId:t.personalAccessTokenId,role:t.role,scopes:t.scopes,selectedProduct:e.selectedProduct,teamId:t.teamId,tenantId:t.tenantId,tokenName:t.name,userId:t.userId}}function ft(e){if(!e||typeof e!="object"||typeof e.userId!="string"||typeof e.email!="string"||typeof e.tenantId!="string"||typeof e.teamId!="string"||typeof e.role!="string"||typeof e.personalAccessTokenId!="string"||typeof e.name!="string"||!Array.isArray(e.scopes)||e.scopes.some(t=>typeof t!="string")||typeof e.expiresAt!="string"||e.status!=="active")throw new c("personal_access_token.current returned invalid data");return e}async function A(e,t){try{return ft(await g(e,Ge,{},t,[t]))}catch(n){throw!(n instanceof C)||n.status!==401?n:new c(`That founder PAT was not accepted (HTTP 401). ${O}${n.requestId?` Request id: ${n.requestId}.`:""}`,{code:"founder_pat_rejected",fix:O})}}function ht(e,t){return e.HYPERSCALE_CLI_BROWSER?{command:e.HYPERSCALE_CLI_BROWSER,args:[t]}:e.HYPERSCALE_NO_BROWSER==="1"||e.CI==="1"||e.CI==="true"||process.platform==="linux"&&!e.DISPLAY&&!e.WAYLAND_DISPLAY?null:process.platform==="darwin"?{command:"/usr/bin/open",args:[t]}:process.platform==="win32"?{command:"rundll32.exe",args:["url.dll,FileProtocolHandler",t]}:{command:"xdg-open",args:[t]}}async function yt(e,t){let n=ht(e,t);return n?new Promise(r=>{let o=Se(n.command,n.args,{detached:!0,stdio:"ignore"});o.once("error",()=>r(!1)),o.once("spawn",()=>{o.unref(),r(!0)})}):!1}function Q(e){return new Promise(t=>{if(!e.listening){t();return}e.close(()=>t())})}async function wt(e,t){let n=globalThis.crypto.randomUUID(),r=!1,o,a=new Promise(($,h)=>{o={reject:h,resolve:$}}),s=Be(($,h)=>{let w=new URL($.url??"/","http://127.0.0.1");if($.method!=="GET"||w.pathname!=="/callback"){h.writeHead(404,{"content-type":"text/plain; charset=utf-8"}),h.end(`Not found.
|
|
104
104
|
`);return}if(r){h.writeHead(409,{"content-type":"text/plain; charset=utf-8"}),h.end(`Login callback was already received.
|
|
105
|
-
`);return}if(
|
|
106
|
-
`);return}if(
|
|
107
|
-
`),o.reject(new c("Portal login was declined. Run hyperscale auth login to start again.",{code:"auth_callback_denied"}));return}let
|
|
105
|
+
`);return}if(w.searchParams.get("state")!==n){h.writeHead(400,{"content-type":"text/plain; charset=utf-8"}),h.end(`Login state did not match. Return to the terminal.
|
|
106
|
+
`);return}if(w.searchParams.get("error")!==null){r=!0,h.writeHead(200,{"content-type":"text/plain; charset=utf-8"}),h.end(`Login declined. Return to the terminal.
|
|
107
|
+
`),o.reject(new c("Portal login was declined. Run hyperscale auth login to start again.",{code:"auth_callback_denied"}));return}let H=w.searchParams.get("grant"),ye=w.searchParams.get("tenantId");if(!H||!ye){h.writeHead(400,{"content-type":"text/plain; charset=utf-8"}),h.end(`Login callback is missing its grant or tenant.
|
|
108
108
|
`);return}r=!0,h.writeHead(200,{"content-type":"text/plain; charset=utf-8"}),h.end(`Login received. Return to the terminal.
|
|
109
|
-
`),o.resolve({grant:
|
|
110
|
-
`);let
|
|
111
|
-
`)}let d=
|
|
112
|
-
`)}function
|
|
113
|
-
${be(o.hsxStructured.source," ")}`),o.hsxStructured.document&&
|
|
114
|
-
${be(JSON.stringify(o.hsxStructured.document,null,2)," ")}`)),
|
|
109
|
+
`),o.resolve({grant:H,tenantId:ye})});await new Promise(($,h)=>{let w=H=>h(H);s.once("error",w),s.listen(0,"127.0.0.1",()=>{s.off("error",w),$()})}),s.once("error",$=>o.reject($));let u=s.address();if(!u||typeof u=="string")throw await Q(s),new c("Could not bind the localhost login callback");let d=`http://127.0.0.1:${u.port}/callback`,l=new URL("/auth/cli",e.baseUrl);l.searchParams.set("callback",d),l.searchParams.set("state",n);let m=new URL("/signin",e.baseUrl);m.searchParams.set("returnTo",`${l.pathname}${l.search}`);let p=m.toString();if(!await yt(t,p))return await Q(s),null;process.stderr.write(`Opening portal sign-in: ${p}
|
|
110
|
+
`);let b=setTimeout(()=>{o.reject(new c("Portal login timed out. Run hyperscale auth login to start a new callback.",{code:"auth_callback_timeout"}))},tt);try{return await a}finally{clearTimeout(b),await Q(s)}}function ke(e){let t={authenticated:!1,browserOpened:!1,next:["export HYPERSCALE_TOKEN=hyperscale_pat_...","hyperscale auth login --no-browser"],patMintUrl:ne,requestAccessUrl:N};if(e["--json"]){f(t);return}i("No browser detected. Mint a founder PAT in the portal, then run:");for(let n of t.next)i(` ${n}`);i(`PAT desk: ${ne}`),i(`No access yet: ${N}`)}async function $e(e,t,n,r,o){let a=await z(o),s={email:t.email,...e,selectedProduct:a&&a.email===t.email&&a.baseUrl===e.baseUrl&&a.environment===e.environment?a.selectedProduct:null},u=await dt(s,{personalAccessTokenId:t.personalAccessTokenId,token:n,tokenName:t.name,tenantId:t.tenantId},o);try{await V(o,s)}catch(l){throw await Ne(s,o),l}if(u==="file"){let l=M(o)==="file"?"Founder PAT file storage is active.":"macOS Keychain is unavailable.";process.stderr.write(`${l} The founder PAT is in ${P(s,o)} with mode 0600.
|
|
111
|
+
`)}let d=me(s,t);r["--json"]?f(d):i(`Logged in as ${t.email} with PAT ${t.name}.`)}async function gt(e,t){let n=R(e,t),r=Oe(e,t);if(r){if(!r.startsWith("hyperscale_pat_"))throw new c("Founder PATs start with hyperscale_pat_. Product API keys belong in HYPERSCALE_API_KEY.");let d=await A(n,r);await $e(n,d,r,e,t);return}if(e["--no-browser"]){ke(e);return}let o=await wt(n,t);if(!o){ke(e);return}let a=await g(n,"/v1/personal-access-token-login-grants/exchange",I({tenantId:o.tenantId,grant:o.grant}),void 0,[o.grant]),s=a?.secret;if(typeof s!="string"||!s.startsWith("hyperscale_pat_")||a?.tenantId!==o.tenantId)throw new c("CLI login grant exchange returned an invalid PAT");let u=await A(n,s);await $e(n,u,s,e,t)}async function kt(e,t){let n=await k(e,t),r=n.identity??await A(n,n.token),o=me(n,r);if(e["--json"]){f(o);return}i(`User: ${r.email}`),i(`Tenant: ${r.tenantId}`),i(`Role: ${r.role}`),i(`Token: ${r.name}`),i(`Scopes: ${r.scopes.join(", ")}`),i(`Expires: ${r.expiresAt}`),i(`API: ${n.baseUrl}`),i(`Environment: ${n.environment}`),i(`Product: ${n.selectedProduct??"not selected"}`)}async function $t(e,t){let n=await z(t);if(!n){e["--json"]?f({status:"signed_out"}):i("Already logged out.");return}let r=await Ee(n,t);if(e["--revoke"]&&!r)throw new c("The local founder PAT is missing, so the CLI cannot revoke it.");let o=r?.personalAccessTokenId,a=r?.tokenName;if(e["--revoke"]&&r){if(!o||!a){let d=await A(n,r.token);o=d.personalAccessTokenId,a=d.name}await g(n,`/v1/personal-access-tokens/${encodeURIComponent(o)}/revoke`,I({tenantId:r.tenantId,personalAccessTokenId:o}),r.token,[r.token])}let s=await Ne(n,t),u=e["--revoke"]===!0;bt(e,{cleanup:s,personalAccessTokenId:o,revoked:u,status:"signed_out",tokenName:a})}function bt(e,t){let n=t.cleanup.keychainDeleted?"complete":"tombstoned";if(e["--json"])f({credentialCleanup:n,...t.personalAccessTokenId?{personalAccessTokenId:t.personalAccessTokenId}:{},...t.revoked===void 0?{}:{revoked:t.revoked},status:t.status,...t.tokenName?{tokenName:t.tokenName}:{},...t.revoked===!1?{tokenStillValid:!0}:{}});else{let r=t.tokenName&&t.personalAccessTokenId?`${t.tokenName} (${t.personalAccessTokenId})`:"with unavailable local metadata";t.revoked?i(`Revoked founder PAT ${r} and forgot local state.`):(i(`Forgot local founder PAT ${r}.`),i("The PAT stays valid until expiry; revoke at /desk/security/tokens."))}t.cleanup.keychainDeleted||process.stderr.write(`Keychain cleanup failed. A 0600 profile tombstone blocks the stale founder PAT.
|
|
112
|
+
`)}function v(e,t){if(!e||typeof e!="object"||!Array.isArray(e.items))throw new c(`${t} returned an invalid collection`);return e.items}async function x(e,t,n,r,o,a=[]){let s=[],u=new Set,d,l;for(;;){let b=new URLSearchParams(n);d&&b.set("cursor",d);let $=b.size>0?`?${b}`:"",h=await g(e,`${t}${$}`,{},o,a);l===void 0&&(l=h),s.push(...v(h,r));let w=h.nextCursor;if(typeof w!="string"||w.length===0)break;if(u.has(w))throw new c(`${r} repeated cursor ${w}`);u.add(w),d=w}let{items:m,nextCursor:p,...y}=l;return{...y,items:s}}async function Pt(e,t){let n=await x(e,"/v1/blueprints",{},"blueprint.list"),r=v(n,"blueprint.list");if(t["--json"]){f(n);return}i("ID Name Summary");for(let o of r)i(`${o.id} ${o.name}${o.summary?` ${o.summary}`:""}`);i("Next:"),i(" hyperscale blueprint show <id>"),i(" hyperscale product create --blueprint <id> --name <name>")}async function It(e,t,n){if(!n)throw new c("blueprint show needs a Blueprint id");let r=await g(e,`/v1/blueprints/${encodeURIComponent(n)}`),o=St(r,e.baseUrl);if(t["--json"]){f(o);return}i(`${o.name} (${o.id})`),i(o.summary),i(o.description),i("Nouns:");for(let a of o.customInstruments??[])i(` ${a.name} (${a.id}): ${a.summary}`);for(let a of o.instruments??[])i(` ${a.title} (${a.id}): ${a.summary}`);i("Verbs:");for(let a of o.verbs??[])i(` ${a.alias} -> ${a.operation}: ${a.summary}`);i("Parties:");for(let a of o.parties??[])i(` ${a.instrumentId}.${a.role} -> ${a.accountField}`);i("Money flows:");for(let a of o.moneyFlows??[]){let s=a.sourceAccount??"action input",u=a.destinationAccount??"action input",d=a.amountPath??"action input";i(` ${a.action} [${a.kind}]: ${s} -> ${u}; amount ${d}`)}i("Fee forms:");for(let a of o.feeForms??[]){let s=a.bps?`${a.bps} bps`:a.amountSar?`SAR ${a.amountSar}`:a.includedQuantity?`${a.includedQuantity} included`:a.kind;i(` ${a.id}: ${s} per ${a.unit}. ${a.summary}`)}o.priceEstimate&&(i("Price estimate:"),i(` monthlySar: SAR ${Number(o.priceEstimate.monthlySar).toLocaleString("en-US")}`),i(` setupSar: SAR ${Number(o.priceEstimate.setupSar).toLocaleString("en-US")}`),i(` complexityScore: ${o.priceEstimate.complexityScore}`)),i("Dials:");for(let a of o.dials??[])i(` ${a.instrumentId}.${a.key} (${a.kind}): ${a.summary}`);i("Journeys:");for(let a of o.journeys??[])i(` ${a.title} (${a.id}): ${a.summary}`),i(` ${a.steps.join(" -> ")}`);o.hsxStructured&&(i("HSX:"),i(` Source:
|
|
113
|
+
${be(o.hsxStructured.source," ")}`),o.hsxStructured.document&&i(` Structured document:
|
|
114
|
+
${be(JSON.stringify(o.hsxStructured.document,null,2)," ")}`)),i("Terms:");for(let[a,s]of Object.entries(o.terminology))i(` ${a}: ${s.definition}`),i(` ${s.href}`);i("Next:"),i(` hyperscale product create --blueprint ${o.id} --name <name>`)}function St(e,t){let n=At(e?.hsx);return{...e,...n?{hsxStructured:n}:{},terminology:{firedBy:{definition:"Who invokes an action: tenant through the Product surface, operator through a console session, or machine when a due condition arrives.",href:`${t}/glossary#action-caller`},publicIntents:{definition:"The retired name for publicActions. publicActions contains the canonical action IDs frozen into a composed Product.",href:`${t}/glossary#public-actions`},trustFile:{definition:"The evidence attached to a business record for later review, such as inspection, authentication, delivery, or proof-of-work records.",href:`${t}/glossary#trust-file`}}}}function At(e){if(typeof e!="string"||e.length===0)return;try{let n=JSON.parse(e);if(n&&typeof n=="object"&&!Array.isArray(n))return{document:n,language:"hsx-json",source:e,verdict:"valid"}}catch{}let t=compile(e);return{diagnostics:t.diagnostics,...t.artifacts?{document:t.artifacts.document,frame:t.artifacts.frame}:{},language:"hsx-text",source:e,verdict:t.verdict}}function be(e,t){return e.split(`
|
|
115
115
|
`).map(n=>`${t}${n}`).join(`
|
|
116
|
-
`)}function
|
|
117
|
-
`);for(let[
|
|
118
|
-
`)}let i=Qe({input:process.stdin,output:process.stderr,terminal:!0}),s=new AbortController,u=()=>s.abort();process.stdin.once("end",u),process.stdin.readableEnded&&s.abort();let d;try{try{d=(await i.question("Choose a number or Blueprint slug: ",{signal:s.signal})).trim()}catch(m){throw m?.name!=="AbortError"&&m?.code!=="ABORT_ERR"?m:new c("Start cancelled before a Blueprint was chosen.",{code:"start_cancelled"})}}finally{process.stdin.off("end",u),i.close()}let l=Number(d),p=Number.isInteger(l)?r[l-1]:r.find(({id:m})=>m===d);if(p)return p;throw new c(`No Blueprint matches ${JSON.stringify(d)}.`,{fix:"Run hyperscale start again and choose a listed number or slug."})}function Bt(e){if(!(!e||typeof e!="object")&&Array.isArray(e.journeys))for(let t of e.journeys){if(!t||typeof t!="object"||!Array.isArray(t.steps))continue;let n=t.steps[0];if(n?.status==="runnable"&&typeof n.operationId=="string"&&n.request&&typeof n.request=="object"&&Array.isArray(n.request.body)&&Array.isArray(n.request.path)&&Array.isArray(n.request.query)&&n.request.literals&&typeof n.request.literals=="object"&&!Array.isArray(n.request.literals)&&typeof t.id=="string")return{id:t.id,step:n}}}function Ht(e,t,n){if(e==="tenantId")return t.tenantId;if(e==="productId")return t.productId;if(e==="customerId")return t.fixtureProfileId;if(e==="currency")return t.fixtureCurrency;if(e==="subject"||e==="subjectId")return t.fixtureSubjects?.[0]?.subjectId;if(e.endsWith("AccountId")){let r=n.distinctPartyAccountFields?.indexOf(e);return r>=0&&(e==="buyerAccountId"||e==="claimantAccountId"||e==="policyholderAccountId")?t.fixtureCounterpartyAccountId:r>=0&&(e==="insurerAccountId"||e==="sellerAccountId")?t.fixtureAccountId:r>0?t.fixtureCounterpartyAccountId:t.fixtureAccountId}}var Kt=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2})$/,Yt=6e4;function Ue(e){if(typeof e!="string"||!Kt.test(e))return;let t=Date.parse(e);return Number.isFinite(t)?t:void 0}function ie(e,t){let n=Ue(e);if(n!==void 0){t.push(n);return}if(Array.isArray(e)){for(let r of e)ie(r,t);return}if(!(!e||typeof e!="object"))for(let r of Object.values(e))ie(r,t)}function ae(e,t){let n=Ue(e);return n!==void 0?new Date(n+t).toISOString():Array.isArray(e)?e.map(r=>ae(r,t)):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([r,o])=>[r,ae(o,t)]))}function Ft(e,t=Date.now()){let n=[];ie(e,n);let r=Math.min(...n);return!Number.isFinite(r)||r>t?e:ae(e,t+Yt-r)}function qt(e,t){let n={...Ft(e.request.literals)},r=[...e.request.path,...e.request.query,...e.request.body];for(let o of r){if(typeof o!="string"||Object.hasOwn(n,o))continue;let i=Ht(o,t,e);if(i===void 0)throw new c(`The frozen journey needs ${o}, but composition did not return a matching sandbox fixture.`,{code:"start_fixture_unavailable"});n[o]=i}return n}async function Mt(e,t,n){let r=await fe(e),o=qe(r.operations,t.operationId),i=qt(t,n),{path:s,remaining:u}=Ye(o,i),d={method:o.method},l=s,p;o.method==="GET"?l+=Fe(u):(p=globalThis.crypto.randomUUID(),d.body=JSON.stringify(u),d.headers={"content-type":"application/json",...o.idempotency==="not_required"?{}:{"idempotency-key":p}});let m=await v(e,l,d);if(!m.response.ok)throw G(m.response,m.text,[e.apiKey],{action:t.operationId});return{...p?{idempotencyKey:p}:{},input:i,operationId:t.operationId,output:Y(Ke(m.text),[e.apiKey]),receipt:Le(m.response)}}async function Se(e,t){Ut(e);let n={};try{await zt(e,t,n)}catch(r){throw typeof n.apiKey!="string"?r:Lt(r,n.apiKey)}}async function zt(e,t,n){let r=await I(e,t),o=await x(r,r.token),i=await Jt(e,r),s=e["--name"]??i.name;e["--json"]||a(`Authenticated: ${o.email}`);let u=await Re(r,"/v1/products/blueprint-compose",P({blueprintId:i.id,name:s,tenantId:r.tenantId}),r.token),d=Rt(u.response,u.text,[r.token]);if(typeof d?.productId!="string"||!pt.test(d.productId)||typeof d?.productBuildId!="string"||d?.blueprintId!==i.id)throw new c("product.blueprint.compose returned an invalid start Product");let l=d?.shown_once;if(typeof l!="string"||l.length===0)throw new c("The composed Product did not return its one-time API key. Choose a new Product name and run hyperscale start again.",{code:"start_api_key_unavailable"});n.apiKey=l;let p=Le(u.response);await V(t,{...r,selectedProduct:d.productId}),e["--json"]||(a(`Product: ${d.productId}`),a(`Blueprint: ${d.blueprintId}`),Pe("Compose",p));let m={baseUrl:r.baseUrl,environment:r.environment,apiKey:l,productId:d.productId},w=await v(m,`/v1/products/${encodeURIComponent(d.productId)}/operation-set`);if(!w.response.ok)throw G(w.response,w.text,[l]);let $=Be(w.text,w.response.status);if($.status!=="frozen"||$.productBuildId!==d.productBuildId)throw new c("The composed Product did not return its frozen build operation set.",{code:"start_build_unavailable"});let g=[`hyperscale compose plan product.hsx --product ${d.productId}`],h=Bt($.goldenPath);if(!h){let A=`Blueprint ${i.id} has no published runnable journeys. Composition completed only.`,Ve={blueprintId:d.blueprintId,composeOnly:!0,nextCommands:g,notice:A,productBuildId:d.productBuildId,productId:d.productId,receipts:[{stage:"product.blueprint.compose",...p}],...typeof d.startKeyId=="string"?{startKeyId:d.startKeyId}:{},shown_once:l};if(e["--json"]){f(Ve);return}a(A),a(`Shown once Product API key: ${l}`),a("Next:");for(let We of g)a(` ${We}`);return}let y=await Mt(m,h.step,d);e["--json"]||Pe("First journey step",y.receipt);let E={blueprintId:d.blueprintId,journey:{id:h.id,firstStep:y},nextCommands:g,productBuildId:d.productBuildId,productId:d.productId,receipts:[{stage:"product.blueprint.compose",...p},{stage:h.step.operationId,...y.receipt}],...typeof d.startKeyId=="string"?{startKeyId:d.startKeyId}:{},shown_once:l};if(e["--json"]){f(E);return}y.output!==null&&a(JSON.stringify(y.output,null,2)),a(`Shown once Product API key: ${l}`),a("Next:");for(let A of g)a(` ${A}`)}async function Vt(e,t){let n=e["--blueprint"],r=e["--name"];if(!n)throw new c("product create needs --blueprint <id>");if(!r)throw new c("product create needs --name <name>");let o=await I(e,t),i;try{i=await O(o,"/v1/products",{tenantId:o.tenantId},"product.list",o.token,[o.token])}catch(m){if(!(m instanceof C)||m.status!==403)throw m}let s=r.trim().toLocaleLowerCase("en-US"),u=(i?T(i,"product.list"):[]).find(m=>{let w=m?.displayName??m?.name;return typeof w=="string"&&w.trim().toLocaleLowerCase("en-US")===s});if(u){let m=u.productId??u.id??"<id>";throw new c(`A Product named ${JSON.stringify(r.trim())} already exists as ${m}.`,{code:"duplicate_product_name",fix:`Use "hyperscale product select ${m}" or choose another --name.`})}let d=await k(o,"/v1/products/blueprint-compose",P({blueprintId:n,name:r,tenantId:o.tenantId}),o.token,[o.token]);if(typeof d?.productId!="string"||typeof d?.blueprintId!="string"||typeof d?.productBuildId!="string")throw new c("product.blueprint.compose returned an invalid Product");await V(t,{...o,selectedProduct:d.productId});let l=typeof d?.shown_once=="string"&&d.shown_once.length>0?d.shown_once:void 0,p={blueprintId:d.blueprintId,nextSteps:[`hyperscale product show ${d.productId}`,...l?[]:['hyperscale key create --name "Founder CLI"']],productBuildId:d.productBuildId,productId:d.productId,selectedProduct:d.productId,...typeof d.startKeyId=="string"?{startKeyId:d.startKeyId}:{},...l?{shown_once:l}:{}};if(e["--json"]){f(p);return}a(`Product: ${p.productId}`),a(`Blueprint: ${p.blueprintId}`),a(`Build: ${p.productBuildId}`),a(`Selected: ${p.selectedProduct}`),p.shown_once&&a(`Shown once Product API key: ${p.shown_once}`),a("Next:");for(let m of p.nextSteps)a(` ${m}`)}function ye(e){return new URLSearchParams({tenantId:e}).toString()}async function Wt(e,t){let n=await I(e,t),r=await O(n,"/v1/products",{tenantId:n.tenantId},"product.list",n.token,[n.token]),o=T(r,"product.list");if(e["--json"]){f(r);return}if(o.length===0){a('No Products yet. Run "hyperscale blueprint list", then "hyperscale product create --blueprint <id> --name <name>".');return}a("ID Name Status");for(let i of o){let s=i.productId??i.id??"unknown",u=i.displayName??i.name??"unnamed";a(`${s} ${u}${i.status?` ${i.status}`:""}`)}}async function Gt(e,t,n){let r=await I(e,t),o=n??r.selectedProduct;if(!o)throw new c("product show needs an id because no Product is selected. Create a Product first.");let i=await k(r,`/v1/products/${encodeURIComponent(o)}?${ye(r.tenantId)}`,{},r.token,[r.token]);if(e["--json"]){f(i);return}Xt(i,o)}function Xt(e,t){let n=e?.displayName??e?.name??"unnamed",r=e?.status??"unknown",o=e?.blueprint,i=o?.id?`${o.name??o.id}${o.name?` (${o.id})`:""}`:"custom composition",s=e?.cost?.currency??"SAR",u=e?.plan?.monthlySar??e?.cost?.platformMonthlySar,d=e?.plan?.setupSar??e?.cost?.platformSetupSar,l=[...Array.isArray(e?.readiness?.outstandingLiveRequirements)?e.readiness.outstandingLiveRequirements:[],...Array.isArray(e?.readiness?.liveUnavailableCapabilities)?e.readiness.liveUnavailableCapabilities.map(p=>`unavailable:${p}`):[],...Array.isArray(e?.cost?.blockers)?e.cost.blockers.map(p=>p?.code??"pricing"):[]];a(`Name: ${n}`),a(`Product: ${e?.productId??t}`),a(`Status: ${r}`),a(`Blueprint: ${i}`),a(`Monthly: ${u==null?"not returned":`${s} ${u}`}`),a(`Setup: ${d==null?"not returned":`${s} ${d}`}`),a(`Live: ${e?.readiness?.live===!0?"active":"not active"}`),a(`Live blockers: ${l.length>0?l.join(", "):"none"}`);for(let[p,m]of[["openapi","OpenAPI"],["mcp","MCP"],["sdk","SDK"],["graphql","GraphQL"]]){let w=e?.surfaces?.[p];w?.url&&a(`${m}: ${w.url}`)}a("Next:"),a(` hyperscale key create --name "Founder CLI" --product ${e?.productId??t}`)}async function Qt(e,t,n){if(!n)throw new c("product select needs a Product id");let r=await I(e,t),o=await k(r,`/v1/products/${encodeURIComponent(n)}?${ye(r.tenantId)}`,{},r.token,[r.token]);if(o?.productId!==n)throw new c("product.retrieve returned the wrong Product");await V(t,{...r,selectedProduct:n});let i={productId:n,selected:!0};e["--json"]?f(i):a(`Selected Product: ${o.displayName??n} (${n})`)}function Zt(e){return e.map(t=>`${t.path}: error [composer] ${t.code}: ${t.message}`)}async function en(e){if(!e)throw new c("compose needs a .hsx file");if(!e.endsWith(".hsx"))throw new c(`compose reads a .hsx file, got ${e}`);let t;try{t=await F(e,"utf8")}catch(n){throw new c(`Could not read ${e}: ${n.message}`)}return{file:e,source:t}}function tn(e){if(!e||typeof e!="object"||typeof e.ok!="boolean"||!Array.isArray(e.issues))throw new c("composer.check returned an invalid result");return{issues:e.issues.map(n=>{if(!n||typeof n!="object"||typeof n.code!="string"||typeof n.message!="string"||typeof n.path!="string")throw new c("composer.check returned an invalid issue");return{code:n.code,message:n.message,path:n.path}}),ok:e.ok}}async function we(e,t,n,r){let o=await en(n),i=await I(e,t),s=r?J(i,e):void 0,u=tn(await k(i,"/v1/composer/check",P({tenantId:i.tenantId,document:o.source,...e["--catalog-revision"]?{catalogRevisionId:e["--catalog-revision"]}:{}}),i.token,[i.token]));if(!u.ok)throw new B(["composer.check refused the program.",...Zt(u.issues)].join(`
|
|
119
|
-
`),{file:n,issues:u.issues});return{check:u,context:
|
|
120
|
-
`),{actions:r,file:t,productId:e.productId});return n}async function
|
|
121
|
-
`),{code:s,...
|
|
122
|
-
`)}function f(e){
|
|
116
|
+
`)}function vt(e){return{operationId:e.headers.get("hyperscale-operation-id")??"not returned",receiptId:e.headers.get("hyperscale-receipt-id")??"not returned"}}function xt(e,t,n=[]){if(!e.ok)throw U(e,t,n);try{return JSON.parse(t)}catch{throw new c(`HTTP ${e.status} returned invalid JSON`)}}function Tt(e,t){i(`${e} operation: ${t.operationId}`),i(`${e} receipt: ${t.receiptId}`)}function Et(e,t){let n=e instanceof c?e:new c("hyperscale start failed after the Product was created",{code:"start_failed_after_compose"});return n.shownOnce=t,n}function Nt(e){if(!e["--blueprint"]&&!(process.stdin.isTTY&&process.stderr.isTTY))throw new c("hyperscale start needs an interactive terminal to choose a company. Pass --blueprint <slug> in scripts and non-interactive environments.",{code:"start_blueprint_required",fix:'Run "hyperscale blueprint list", then pass --blueprint <slug>.'})}function Ot(e){return v(e,"blueprint.list").map(t=>{if(typeof t?.id!="string"||t.id.length===0||typeof t?.name!="string"||t.name.length===0)throw new c("blueprint.list returned an invalid start choice");return{id:t.id,name:t.name,summary:typeof t.summary=="string"?t.summary:""}})}async function Ct(e,t){let n=await x(t,"/v1/blueprints",{},"blueprint.list"),r=Ot(n);if(r.length===0)throw new c("The Blueprint catalog has no companies to build.");let o=e["--blueprint"];if(o){let p=r.find(({id:y})=>y===o);if(p)return p;throw new c(`Unknown Blueprint: ${o}`,{fix:'Run "hyperscale blueprint list" and pass one listed slug to --blueprint.'})}process.stderr.write(`Which company do you want to build?
|
|
117
|
+
`);for(let[p,y]of r.entries()){let b=y.summary.replace(/\s+/g," ").trim();process.stderr.write(` ${p+1}. ${y.name} (${y.id})${b?`: ${b}`:""}
|
|
118
|
+
`)}let a=Ke({input:process.stdin,output:process.stderr,terminal:!0}),s=new AbortController,u=()=>s.abort();process.stdin.once("end",u),process.stdin.readableEnded&&s.abort();let d;try{try{d=(await a.question("Choose a number or Blueprint slug: ",{signal:s.signal})).trim()}catch(p){throw p?.name!=="AbortError"&&p?.code!=="ABORT_ERR"?p:new c("Start cancelled before a Blueprint was chosen.",{code:"start_cancelled"})}}finally{process.stdin.off("end",u),a.close()}let l=Number(d),m=Number.isInteger(l)?r[l-1]:r.find(({id:p})=>p===d);if(m)return m;throw new c(`No Blueprint matches ${JSON.stringify(d)}.`,{fix:"Run hyperscale start again and choose a listed number or slug."})}async function Pe(e,t){Nt(e);let n={};try{await Rt(e,t,n)}catch(r){throw typeof n.apiKey!="string"?r:Et(r,n.apiKey)}}async function Rt(e,t,n){let r=await k(e,t),o=await A(r,r.token),a=await Ct(e,r),s=e["--name"]??a.name;e["--json"]||i(`Authenticated: ${o.email}`);let u=await Ce(r,"/v1/products/blueprint-compose",I({blueprintId:a.id,name:s,tenantId:r.tenantId}),r.token),d=xt(u.response,u.text,[r.token]);if(typeof d?.productId!="string"||!nt.test(d.productId)||typeof d?.productBuildId!="string"||d?.blueprintId!==a.id)throw new c("product.blueprint.compose returned an invalid start Product");let l=d?.shown_once;if(typeof l!="string"||l.length===0)throw new c("The composed Product did not return its one-time API key. Choose a new Product name and run hyperscale start again.",{code:"start_api_key_unavailable"});n.apiKey=l;let m=vt(u.response);await V(t,{...r,selectedProduct:d.productId}),e["--json"]||(i(`Product: ${d.productId}`),i(`Blueprint: ${d.blueprintId}`),Tt("Compose",m));let p=[`hyperscale compose plan product.hsx --product ${d.productId}`],y="Composition completed. Run SDK journeys against your Product.",b={blueprintId:d.blueprintId,composeOnly:!0,nextCommands:p,notice:y,productBuildId:d.productBuildId,productId:d.productId,receipts:[{stage:"product.blueprint.compose",...m}],...typeof d.startKeyId=="string"?{startKeyId:d.startKeyId}:{},shown_once:l};if(e["--json"]){f(b);return}i(y),i(`Shown once Product API key: ${l}`),i("Next:");for(let $ of p)i(` ${$}`);i(" Run journeys with the Hyperscale SDK using the Product API key above.")}async function _t(e,t){let n=e["--blueprint"],r=e["--name"];if(!n)throw new c("product create needs --blueprint <id>");if(!r)throw new c("product create needs --name <name>");let o=await k(e,t),a;try{a=await x(o,"/v1/products",{tenantId:o.tenantId},"product.list",o.token,[o.token])}catch(p){if(!(p instanceof C)||p.status!==403)throw p}let s=r.trim().toLocaleLowerCase("en-US"),u=(a?v(a,"product.list"):[]).find(p=>{let y=p?.displayName??p?.name;return typeof y=="string"&&y.trim().toLocaleLowerCase("en-US")===s});if(u){let p=u.productId??u.id??"<id>";throw new c(`A Product named ${JSON.stringify(r.trim())} already exists as ${p}.`,{code:"duplicate_product_name",fix:`Use "hyperscale product select ${p}" or choose another --name.`})}let d=await g(o,"/v1/products/blueprint-compose",I({blueprintId:n,name:r,tenantId:o.tenantId}),o.token,[o.token]);if(typeof d?.productId!="string"||typeof d?.blueprintId!="string"||typeof d?.productBuildId!="string")throw new c("product.blueprint.compose returned an invalid Product");await V(t,{...o,selectedProduct:d.productId});let l=typeof d?.shown_once=="string"&&d.shown_once.length>0?d.shown_once:void 0,m={blueprintId:d.blueprintId,nextSteps:[`hyperscale product show ${d.productId}`,...l?[]:['hyperscale key create --name "Founder CLI"']],productBuildId:d.productBuildId,productId:d.productId,selectedProduct:d.productId,...typeof d.startKeyId=="string"?{startKeyId:d.startKeyId}:{},...l?{shown_once:l}:{}};if(e["--json"]){f(m);return}i(`Product: ${m.productId}`),i(`Blueprint: ${m.blueprintId}`),i(`Build: ${m.productBuildId}`),i(`Selected: ${m.selectedProduct}`),m.shown_once&&i(`Shown once Product API key: ${m.shown_once}`),i("Next:");for(let p of m.nextSteps)i(` ${p}`)}function fe(e){return new URLSearchParams({tenantId:e}).toString()}async function jt(e,t){let n=await k(e,t),r=await x(n,"/v1/products",{tenantId:n.tenantId},"product.list",n.token,[n.token]),o=v(r,"product.list");if(e["--json"]){f(r);return}if(o.length===0){i('No Products yet. Run "hyperscale blueprint list", then "hyperscale product create --blueprint <id> --name <name>".');return}i("ID Name Status");for(let a of o){let s=a.productId??a.id??"unknown",u=a.displayName??a.name??"unnamed";i(`${s} ${u}${a.status?` ${a.status}`:""}`)}}async function Lt(e,t,n){let r=await k(e,t),o=n??r.selectedProduct;if(!o)throw new c("product show needs an id because no Product is selected. Create a Product first.");let a=await g(r,`/v1/products/${encodeURIComponent(o)}?${fe(r.tenantId)}`,{},r.token,[r.token]);if(e["--json"]){f(a);return}Ut(a,o)}function Ut(e,t){let n=e?.displayName??e?.name??"unnamed",r=e?.status??"unknown",o=e?.blueprint,a=o?.id?`${o.name??o.id}${o.name?` (${o.id})`:""}`:"custom composition",s=e?.cost?.currency??"SAR",u=e?.plan?.monthlySar??e?.cost?.platformMonthlySar,d=e?.plan?.setupSar??e?.cost?.platformSetupSar,l=[...Array.isArray(e?.readiness?.outstandingLiveRequirements)?e.readiness.outstandingLiveRequirements:[],...Array.isArray(e?.readiness?.liveUnavailableCapabilities)?e.readiness.liveUnavailableCapabilities.map(m=>`unavailable:${m}`):[],...Array.isArray(e?.cost?.blockers)?e.cost.blockers.map(m=>m?.code??"pricing"):[]];i(`Name: ${n}`),i(`Product: ${e?.productId??t}`),i(`Status: ${r}`),i(`Blueprint: ${a}`),i(`Monthly: ${u==null?"not returned":`${s} ${u}`}`),i(`Setup: ${d==null?"not returned":`${s} ${d}`}`),i(`Live: ${e?.readiness?.live===!0?"active":"not active"}`),i(`Live blockers: ${l.length>0?l.join(", "):"none"}`);for(let[m,p]of[["openapi","OpenAPI"],["mcp","MCP"],["sdk","SDK"],["graphql","GraphQL"]]){let y=e?.surfaces?.[m];y?.url&&i(`${p}: ${y.url}`)}i("Next:"),i(` hyperscale key create --name "Founder CLI" --product ${e?.productId??t}`)}async function Dt(e,t,n){if(!n)throw new c("product select needs a Product id");let r=await k(e,t),o=await g(r,`/v1/products/${encodeURIComponent(n)}?${fe(r.tenantId)}`,{},r.token,[r.token]);if(o?.productId!==n)throw new c("product.retrieve returned the wrong Product");await V(t,{...r,selectedProduct:n});let a={productId:n,selected:!0};e["--json"]?f(a):i(`Selected Product: ${o.displayName??n} (${n})`)}function Ht(e){return e.map(t=>`${t.path}: error [composer] ${t.code}: ${t.message}`)}async function Jt(e){if(!e)throw new c("compose needs a .hsx file");if(!e.endsWith(".hsx"))throw new c(`compose reads a .hsx file, got ${e}`);let t;try{t=await F(e,"utf8")}catch(n){throw new c(`Could not read ${e}: ${n.message}`)}return{file:e,source:t}}function Bt(e){if(!e||typeof e!="object"||typeof e.ok!="boolean"||!Array.isArray(e.issues))throw new c("composer.check returned an invalid result");return{issues:e.issues.map(n=>{if(!n||typeof n!="object"||typeof n.code!="string"||typeof n.message!="string"||typeof n.path!="string")throw new c("composer.check returned an invalid issue");return{code:n.code,message:n.message,path:n.path}}),ok:e.ok}}async function he(e,t,n,r){let o=await Jt(n),a=await k(e,t),s=r?D(a,e):void 0,u=Bt(await g(a,"/v1/composer/check",I({tenantId:a.tenantId,document:o.source,...e["--catalog-revision"]?{catalogRevisionId:e["--catalog-revision"]}:{}}),a.token,[a.token]));if(!u.ok)throw new J(["composer.check refused the program.",...Ht(u.issues)].join(`
|
|
119
|
+
`),{file:n,issues:u.issues});return{check:u,context:a,productId:s,program:o,catalogRevisionId:e["--catalog-revision"]}}async function Kt(e,t,n){let r=await he(e,t,n,!1);if(e["--json"]){f({command:"composer.check",file:n,issues:r.check.issues,ok:!0});return}i(`Check passed: ${n}`)}async function _e(e,t){let n=await g(e.context,"/v1/composer/plan",I({document:e.program.source,tenantId:e.context.tenantId,productId:e.productId,...e.catalogRevisionId?{catalogRevisionId:e.catalogRevisionId}:{}}),e.context.token,[e.context.token]);if(!n||typeof n!="object"||typeof n.summary!="string"||!Array.isArray(n.actions)||!n.pricing||typeof n.pricing!="object")throw new c("composer.plan returned an invalid result");let r=n.actions.filter(o=>!o||typeof o!="object"||o.kind!=="configure_product");if(r.length>0)throw new J([n.summary,...r.map(o=>o&&typeof o=="object"?`${o.kind??"unknown"} ${o.target??"unknown"} ${o.detail??"Composer refused this action."}`:"unknown unknown Composer returned an invalid refusal action.")].join(`
|
|
120
|
+
`),{actions:r,file:t,productId:e.productId});return n}async function Yt(e,t,n){let r=await he(e,t,n,!0),o=await _e(r,n);if(e["--json"]){f({command:"composer.plan",file:n,plan:o,productId:r.productId});return}i(o.summary);for(let a of o.actions)i(`${a.kind} ${a.target} ${a.detail}`);i(`Monthly: SAR ${o.pricing.monthlySar}`),i(`Activation: SAR ${o.pricing.activationSar}`)}async function Ft(e,t,n){if(!e["--confirm"]&&!e["--yes"])throw new c("compose apply changes the selected Product. Pass --confirm, or --yes for an agent.");let r=await he(e,t,n,!0);await _e(r,n);let o=await g(r.context,"/v1/products/recompose",I({program:{source:r.program.source},...r.catalogRevisionId?{catalogRevisionId:r.catalogRevisionId}:{},tenantId:r.context.tenantId,productId:r.productId},e["--idempotency-key"]),r.context.token,[r.context.token]);if(!o||typeof o.productBuildId!="string")throw new c("product.recompose returned no new build identity");if(e["--json"]){f({command:"product.recompose",file:n,output:o});return}i(`Product: ${o.productId??r.productId}`),i(`Build: ${o.productBuildId}`),o.buildDigest&&i(`Digest: ${o.buildDigest}`)}function D(e,t){let n=t["--product"]??e.selectedProduct;if(!n)throw new c("No Product selected. Pass --product <id> or create a Product first.");return n}async function Y(e,t,n){let r=await z(t),o=D(r??{},e),a=R(e,t,r??{});if(r&&(a.baseUrl!==r.baseUrl||a.environment!==r.environment))throw new c(`The selected Product belongs to ${r.baseUrl} (${r.environment}). Select a Product at the configured API origin first.`);let s=e["--api-key"]??t.HYPERSCALE_API_KEY;if(!s)throw Ae(o);let u={...a,apiKey:s,productId:o};return await qt(u,o,n),u}async function qt(e,t,n){let r=`/v1/products/${encodeURIComponent(t)}/operation-set`,{response:o,text:a}=await L(e,r,{},n);if(o.ok)return;let s;try{s=JSON.parse(a)?.error?.message}catch{s=void 0}throw typeof s=="string"&&s.includes("does not match API key Product")?new c(`${s} Or set HYPERSCALE_API_KEY to a key for ${t}, or pass that key with --api-key.`):U(o,a,[e.apiKey])}async function je(e,t){let n=`/v1/products/${encodeURIComponent(e.productId)}/operation-set`,{response:r,text:o}=await L(e,n,{},t);if(!r.ok)throw Ue(r,o,[e.apiKey]);return Vt(o,r.status)}async function Mt(e,t,n){let r=await Y(e,t),o=await je(r);if(n){zt(o,n,e);return}if(e["--json"]){f(o);return}if(o.status==="legacy"){i("This Product uses a legacy surface. It has no frozen public actions yet."),i(`Build: ${o.productBuildId}`);return}if(o.publicActions.length===0)i("No public actions");else{i("Operation ID Input Kind");for(let a of o.publicActions){let s=a.idempotencyPolicy?.mode==="not_required"?"read-only":"mutation";i(`${a.instrument}.${a.name} ${Xt(a.inputSchema)} ${s}`)}}if(o.setupOperations.length>0){i("Setup operations (run with hyperscale call)");for(let a of o.setupOperations)i(a.operationName)}if(o.readOperationIds.length>0){i("Reads (run with hyperscale call)");for(let a of o.readOperationIds)i(Gt(a))}i(`Digest: ${o.tenantOperationSetDigest}`),i(`Setup digest: ${o.tenantSetupOperationSetDigest}`),i(`Read digest: ${o.tenantReadOperationSetDigest}`),i(`Build: ${o.productBuildId}`),i(`Surface version: ${o.tenantSurfaceVersion}`)}function zt(e,t,n){if(e.status==="legacy")throw new c(`This Product uses a legacy surface and has no frozen public action named ${t}. Run "hyperscale product actions" after rebuilding the Product.`);let r=e.publicActions.find(u=>u&&`${u.instrument}.${u.name}`===t),o=Wt(t),a=e.setupOperations.find(u=>u&&(u.operationId===t||u.operationId===o||u.operationName===t));if(a){let{inputSchema:u,operationId:d,operationName:l}=a,m={status:e.status,productBuildId:e.productBuildId,tenantSurfaceVersion:e.tenantSurfaceVersion,tenantSetupOperationSetDigest:e.tenantSetupOperationSetDigest,setupOperationId:d,operationName:l,command:`hyperscale call ${l}`,inputSchema:u};if(n["--json"]){f(m);return}i(`Operation ID: ${d}`),i(`Operation name: ${l}`),i(`Run: hyperscale call ${l}`),i(`Input schema: ${JSON.stringify(u,null,2)}`),(!Array.isArray(u.required)||u.required.length===0)&&i("Input: omit --input or pass {}."),i(`Setup digest: ${e.tenantSetupOperationSetDigest}`),i(`Build: ${e.productBuildId}`),i(`Surface version: ${e.tenantSurfaceVersion}`);return}if(!r)throw new c(`Unknown frozen public action: ${t}. Run "hyperscale product actions" to list exact names.`);let s={status:e.status,productBuildId:e.productBuildId,tenantSurfaceVersion:e.tenantSurfaceVersion,tenantOperationSetDigest:e.tenantOperationSetDigest,publicAction:r};if(n["--json"]){f(s);return}i(`Operation ID: ${r.instrument}.${r.name}`),i(`Instrument: ${r.instrument}`),i(`Input schema: ${JSON.stringify(r.inputSchema,null,2)}`),i(`Output schema: ${JSON.stringify(r.outputSchema,null,2)}`),i(`Actor policy: ${JSON.stringify(r.actorPolicy,null,2)}`),i(`Port policy: ${JSON.stringify(r.portPolicy,null,2)}`),i(`Idempotency policy: ${JSON.stringify(r.idempotencyPolicy,null,2)}`),i(`Receipt policy: ${JSON.stringify(r.receiptPolicy,null,2)}`),i(`Receipt evidence: ${JSON.stringify(r.receiptEvidence,null,2)}`),i(`Digest: ${e.tenantOperationSetDigest}`),i(`Build: ${e.productBuildId}`),i(`Surface version: ${e.tenantSurfaceVersion}`)}function Vt(e,t){let n;try{n=JSON.parse(e)}catch{throw new c(`HTTP ${t} returned invalid JSON`)}if(!n||typeof n!="object"||n.status!=="legacy"&&n.status!=="frozen"||typeof n.productBuildId!="string")throw new c("The Product operation set is not in the expected format. Upgrade the CLI.");if(n.status==="legacy")return n;if(typeof n.tenantSurfaceVersion!="number"||typeof n.tenantOperationSetDigest!="string"||typeof n.tenantReadOperationSetDigest!="string"||typeof n.tenantSetupOperationSetDigest!="string"||!Array.isArray(n.publicActions)||!Array.isArray(n.readOperationIds)||!Array.isArray(n.setupOperationIds)||!Array.isArray(n.setupOperations))throw new c("The Product operation set is not in the expected format. Upgrade the CLI.");return n}function Wt(e){return e.replaceAll(".","_")}function Gt(e){for(let t of["create","list","retrieve"]){let n=`_${t}`;if(e.endsWith(n))return`${e.slice(0,-n.length)}.${t}`}return e}function Xt(e){if(!e||typeof e!="object")return"input schema unavailable";let t=e.properties&&typeof e.properties=="object"&&!Array.isArray(e.properties)?e.properties:{},n=new Set(Array.isArray(e.required)?e.required.filter(o=>typeof o=="string"):[]),r=Object.entries(t).map(([o,a])=>`${o}${n.has(o)?"":"?"}: ${Le(a)}`);return r.length===0?"no input":r.join(", ")}function Le(e){return!e||typeof e!="object"?"value":Array.isArray(e.enum)&&e.enum.length>0?e.enum.map(t=>String(t)).join(" | "):e.type==="array"?`${Le(e.items)}[]`:typeof e.type=="string"?typeof e.format=="string"?`${e.type} (${e.format})`:e.type:"value"}async function Qt(e,t,n){if(!n)throw new c("product run needs a public action");let r=await Y(e,t,n),o=await je(r,n);Zt(o,n);let a=await De(e),s=e["--idempotency-key"]??globalThis.crypto.randomUUID(),{response:u,text:d}=await L(r,`/v1/operations/${encodeURIComponent(n)}`,{body:JSON.stringify(a),headers:{"content-type":"application/json","idempotency-key":s},method:"POST"},n);if(!u.ok)throw Ue(u,d,[r.apiKey],{action:n});let l=u.headers.get("hyperscale-operation-id"),m=u.headers.get("hyperscale-receipt-id");if(e["--json"]){f({idempotencyKey:s,operationId:l,receiptId:m,output:en(d)});return}i(`Operation: ${l??"not returned"}`),i(`Receipt: ${m??"not returned"}`),i(`Idempotency key: ${s}`);let p=He(d);p&&i(p)}function Zt(e,t){if(e.status==="legacy")throw new c(`This Product uses a legacy surface and has no frozen public action named ${t}. Run "hyperscale product actions" after rebuilding the Product.`);let n=e.publicActions.find(o=>o&&`${o.instrument}.${o.name}`===t);if(n)return n;let r=e.publicActions.map(o=>`${o.instrument}.${o.name}`).map(o=>({candidate:o,distance:se(t,o)})).sort((o,a)=>o.distance-a.distance||o.candidate.localeCompare(a.candidate)).slice(0,3).map(({candidate:o})=>o);throw new c(`Unknown frozen public action: ${t}. Closest valid names: ${r.join(", ")}. Run "hyperscale product actions" to list exact names.`)}function en(e){if(e.trim()==="")return null;try{return JSON.parse(e)}catch{return e}}function Ue(e,t,n=[],r={}){let o=S(t.trim(),n),a;try{a=JSON.parse(t)}catch{return new c(`HTTP ${e.status}${o?` \xB7 ${o}`:""}`)}if(!a?.error||typeof a.error.message!="string")return new c(`HTTP ${e.status}`);let s=typeof a.error.code=="string"?a.error.code:"user_error",u=s==="user_error"?"":`${s}: `,d=S(`HTTP ${e.status} \xB7 ${u}${a.error.message}`,n),l=tn(a.error.details,n),m;return s==="idempotency_conflict"?m="Reuse the same key only with the same operation and input. Use a new unique key for a different request.":[a.error.message,...l].some(p=>typeof p=="string"&&p.includes("[Truncated]"))&&r.action&&(m=`Run "hyperscale product actions ${r.action}" to read the full input schema and allowed values.`),new c([d,...l].join(`
|
|
121
|
+
`),{code:s,...a.error.details?{details:ae(a.error.details,n)}:{},...m?{fix:m}:{}})}function ae(e,t){return typeof e=="string"?S(e,t):Array.isArray(e)?e.map(n=>ae(n,t)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([n,r])=>[S(n,t),ae(r,t)])):e}function tn(e,t){if(!e||typeof e!="object")return[];if(Array.isArray(e.issues))return e.issues.flatMap(r=>{if(!r||typeof r!="object")return[];let a=(Array.isArray(r.path)?r.path.join("."):"input")||"input";return typeof r.message=="string"?[`${a}: ${S(r.message,t)}`]:[]});let n=[];return ie(e,"",n,t),n}function ie(e,t,n,r){if(Array.isArray(e)){if(e.every(o=>o===null||typeof o!="object")){n.push(`${Ie(t)}: ${S(e.join(", "),r)}`);return}e.forEach((o,a)=>ie(o,`${t}[${a}]`,n,r));return}if(e&&typeof e=="object"){for(let[o,a]of Object.entries(e))ie(a,t?`${t}.${o}`:o,n,r);return}t&&n.push(`${Ie(t)}: ${S(String(e),r)}`)}function Ie(e){let t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replaceAll("."," ");return t.charAt(0).toUpperCase()+t.slice(1)}async function nn(e,t){let n=await k(e,t),r=D(n,e),o=await g(n,"/v1/sandbox-api-keys",I({name:e["--name"]??"Founder CLI",tenantId:n.tenantId,productId:r}),n.token,[n.token]);if(e["--json"]){f(o);return}i(`Key: ${o.apiKeyId??"unknown"}`),i(`Product: ${o.productId??r}`),i(`Status: ${o.status??"unknown"}`),o.secret?(i(`Secret: ${o.secret}`),i("Store it now. Hyperscale will not return it again."),i("Next:"),i(` export HYPERSCALE_API_KEY=${on(o.secret)}`),i(` hyperscale product actions --product ${r}`)):i("The key already existed, so the one-time secret is unavailable.")}function on(e){return`'${String(e).replaceAll("'",`'"'"'`)}'`}async function rn(e,t){let n=await k(e,t),r=D(n,e),o=await x(n,"/v1/api-keys",{tenantId:n.tenantId},"api_key.list",n.token,[n.token]),a=v(o,"api_key.list").filter(u=>u.productId===r),s={...o,items:a};if(e["--json"]){f(s);return}for(let u of a)i(`${u.apiKeyId} ${u.name??"unnamed"} ${u.status??"unknown"}`)}async function an(e,t,n){if(!n)throw new c("key revoke needs an API key id");let r=await k(e,t),o=D(r,e),a=await g(r,`/v1/api-keys/${encodeURIComponent(n)}/revoke`,I({tenantId:r.tenantId,productId:o}),r.token,[r.token]);e["--json"]?f(a):i(`Key ${a.apiKeyId??n}: ${a.status??"revoked"}`)}async function sn(e,t){let n=await k(e,t),r=n.identity??await A(n,n.token),o=me(n,r);if(e["--json"]){f(o);return}i(`User: ${r.email}`),i(`Tenant: ${r.tenantId}`),i(`Role: ${r.role}`),i(`Token: ${r.name}`),i(`Expires: ${r.expiresAt}`)}async function cn(e,t,n){let r=await Re(e),o=n?n.toLowerCase():null,a=o?r.operations.filter(u=>u.name.toLowerCase().includes(o)||u.path.toLowerCase().includes(o)):r.operations;if(t["--json"]){i(JSON.stringify(a,null,2));return}if(a.length===0){i(n?`No operation matches ${n}`:"No operations");return}let s=Math.max(...a.map(u=>u.name.length));for(let u of a)i(`${u.name.padEnd(s)} ${u.method.padEnd(6)}${u.path}`)}async function un(e,t){let n=await k(e,t),r=await g(n,`/v1/team/members?${fe(n.tenantId)}`,{},n.token,[n.token]);if(!r||typeof r!="object"||!Array.isArray(r.members)||!Array.isArray(r.invitations))throw new c("team.member.list returned invalid data");if(e["--json"]){f(r);return}for(let o of r.members)i(`${o.email??"unknown"} ${o.role??"unknown"} ${o.status??"unknown"}`);for(let o of r.invitations)i(`${o.email??"unknown"} ${o.role??"unknown"} pending invitation`)}async function dn(e,t){let n=e["--email"],r=e["--role"];if(!n)throw new c("team invite needs --email <email>");if(!r)throw new c("team invite needs --role <role>");let o=await k(e,t),a=await g(o,"/v1/team/members/invite",I({email:n,role:r,tenantId:o.tenantId}),o.token,[o.token]);if(e["--json"]){f(a);return}i(`Invitation: ${a.invitationId??"unknown"}`),i(`Email: ${a.email??n}`),i(`Role: ${a.role??r}`),i(`Expires: ${a.expiresAt??"unknown"}`),a.inviteToken&&(i(`Invite token: ${a.inviteToken}`),i("Share it now. Hyperscale will not return it again."))}async function ln(e,t){let n=await k(e,t),r=await x(n,"/v1/activity",{tenantId:n.tenantId},"activity.list",n.token,[n.token]),o=v(r,"activity.list");if(e["--json"]){f(r);return}i("Time Activity Target Status");for(let a of o){let s=a.operation??a.auditEvent??"activity",u=a.resourceKind&&a.resourceId?`${a.resourceKind}:${a.resourceId}`:a.resourceKind??a.resourceId??"-";i(`${a.occurredAt??"unknown"} ${s} ${u} ${a.status??"recorded"}`)}}function pn(e,t){let n={...t},r=[],o=e.path.replace(/\{([^}]+)\}/g,(a,s)=>{let u=n[s];return u==null?(r.push(s),""):(delete n[s],encodeURIComponent(String(u)))});if(r.length>0)throw new c(`${e.name} needs ${r.join(", ")} in --input`);return{path:o,remaining:n}}function mn(e){let t=new URLSearchParams;for(let[r,o]of Object.entries(e))o!=null&&t.set(r,typeof o=="string"?o:JSON.stringify(o));let n=t.toString();return n?`?${n}`:""}function se(e,t){let n=Array.from({length:t.length+1},(r,o)=>o);for(let r=1;r<=e.length;r+=1){let o=[r];for(let a=1;a<=t.length;a+=1)o[a]=Math.min(o[a-1]+1,n[a]+1,n[a-1]+(e[r-1]===t[a-1]?0:1));n.splice(0,n.length,...o)}return n[t.length]}function fn(e,t){let n=e.find(a=>a.name===t);if(n)return n;let r=e.filter(a=>a.operationId===t);if(r.length===1)return r[0];if(r.length>1)throw new c(`${t} matches more than one operation. Use one of: ${r.map(a=>a.name).join(", ")}.`);let o=e.map(a=>({candidate:a,distance:Math.min(se(t,a.name),se(t,a.operationId))})).sort((a,s)=>a.distance-s.distance||a.candidate.name.localeCompare(s.candidate.name)).slice(0,3).flatMap(({candidate:a})=>[a.name,a.operationId]);throw new c(`${t} is not an operation in the selected Product's machine document. Closest valid names: ${o.join(", ")}.`)}async function hn(e,t,n){if(!n)throw new c("call needs an operation name");let r=await Re(e),o=fn(r.operations,n),a=await De(t),{path:s,remaining:u}=pn(o,a),d={method:o.method},l=s;o.method==="GET"?l+=mn(u):(d.body=JSON.stringify(u),d.headers={"content-type":"application/json",...o.idempotency==="not_required"?{}:{"idempotency-key":t["--idempotency-key"]??globalThis.crypto.randomUUID()}});let{response:m,text:p}=await L(e,l,d);if(!m.ok)throw U(m,p,[e.apiKey]);i(He(p))}async function De(e){if(e["--input"]!==void 0&&e["--input-file"]!==void 0)throw new c("Use only one of --input and --input-file");if(e["--input"]!==void 0)return Z(e["--input"],"--input");if(e["--input-file"]!==void 0){let t;try{t=await F(e["--input-file"],"utf8")}catch(n){throw new c(`Could not read ${e["--input-file"]}: ${n.message}`)}return Z(t,"--input-file")}if(!process.stdin.isTTY){let t=await pt();if(t.trim()!=="")return Z(t,"stdin")}return{}}function Z(e,t="--input"){if(e===void 0)return{};let n;try{n=JSON.parse(e)}catch(r){throw new c(`${t} is not valid JSON: ${r.message}`)}if(n===null||typeof n!="object"||Array.isArray(n))throw new c(`${t} must be a JSON object`);return n}function He(e){if(e.trim()==="")return"";try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function i(e){process.stdout.write(`${e}
|
|
122
|
+
`)}function f(e){i(JSON.stringify(e,null,2))}function yn(e,t){let n=e instanceof c&&typeof e.shownOnce=="string"?e.shownOnce:void 0;if(!t.includes("--json")){let a=e instanceof c?e.message:e.stack??String(e),s=e instanceof c&&typeof e.fix=="string"?`
|
|
123
123
|
Fix: ${e.fix}`:"",u=n?`
|
|
124
|
-
Shown once Product API key: ${n}`:"";process.stderr.write(`${
|
|
124
|
+
Shown once Product API key: ${n}`:"";process.stderr.write(`${a}${s}${u}
|
|
125
125
|
`);return}let r=e instanceof c,o=r&&typeof e.code=="string"?e.code:r?"user_error":"internal_error";process.stderr.write(`${JSON.stringify({error:{code:o,message:r?e.message:"The command failed unexpectedly.",...r&&e.details?{details:e.details}:{},fix:r?e.fix??'Follow the message, or run "hyperscale --help" for command usage.':"Report the failure without including credentials."},...n?{shown_once:n}:{}})}
|
|
126
|
-
`)}async function
|
|
126
|
+
`)}async function wn(){let{readFileSync:e}=await import("node:fs");return JSON.parse(e(new URL("./package.json",import.meta.url),"utf8")).version}async function gn(e,t){let{flags:n,positional:r}=it(e);if(n["--version"])return i(await wn()),0;if(n["--help"]&&r.length>0)return process.stdout.write(rt(r)),0;if(r.length===0&&!n["--help"]){if(n["--json"])throw new c('No command. Run "hyperscale --help" to list commands.');return process.stdin.isTTY&&process.stderr.isTTY?(await Pe(n,t),0):(i('Build your first Product with "hyperscale start".'),i('Run "hyperscale --help" for every command.'),0)}if(n["--help"])return process.stdout.write(ot),0;let[o,...a]=r;if(o==="start")return await Pe(n,t),0;if(o==="auth"){if(a[0]==="login")await gt(n,t);else if(a[0]==="status")await kt(n,t);else if(a[0]==="logout")await $t(n,t);else throw new c('Auth subcommands are "login", "status", and "logout"');return 0}if(o==="blueprint"){let s=R(n,t);if(a[0]==="list")await Pt(s,n);else if(a[0]==="show")await It(s,n,a[1]);else throw new c('Blueprint subcommands are "list" and "show"');return 0}if(o==="product"){if(a[0]==="create")await _t(n,t);else if(a[0]==="list")await jt(n,t);else if(a[0]==="show")await Lt(n,t,a[1]);else if(a[0]==="select")await Dt(n,t,a[1]);else if(a[0]==="actions")await Mt(n,t,a[1]);else if(a[0]==="run")await Qt(n,t,a[1]);else throw new c('Product subcommands are "create", "list", "show", "select", "actions", and "run"');return 0}if(o==="compose"){if(a[0]==="check")await Kt(n,t,a[1]);else if(a[0]==="plan")await Yt(n,t,a[1]);else if(a[0]==="apply")await Ft(n,t,a[1]);else throw new c('Compose subcommands are "check", "plan", and "apply"');return 0}if(o==="key"){if(a[0]==="create")await nn(n,t);else if(a[0]==="list")await rn(n,t);else if(a[0]==="revoke")await an(n,t,a[1]);else throw new c('Key subcommands are "create", "list", and "revoke"');return 0}if(o==="whoami")return await sn(n,t),0;if(o==="team"){if(a[0]==="list")await un(n,t);else if(a[0]==="invite")await dn(n,t);else throw new c('Team subcommands are "list" and "invite"');return 0}if(o==="activity"){if(a[0]!=="list")throw new c('The only activity subcommand is "list"');return await ln(n,t),0}if(o==="ops"){if(a[0]!=="list")throw new c('The only ops subcommand is "list"');let s=n["--product"]?await Y(n,t):ge(n,t);return await cn(s,n,a[1]),0}if(o==="call"){let s=n["--product"]?await Y(n,t):ge(n,t);return await hn(s,n,a[0]),0}throw new c(`Unknown command: ${o}`)}gn(process.argv.slice(2),process.env).then(e=>{process.exitCode=e},e=>{yn(e,process.argv.slice(2)),process.exitCode=e instanceof c&&Number.isInteger(e.exitCode)?e.exitCode:1});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperscale0/cli",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.9",
|
|
4
4
|
"description": "The Hyperscale founder command line: compose Products, manage keys, and call Product operations.",
|
|
5
5
|
"license": "LicenseRef-Hyperscale-Proprietary",
|
|
6
6
|
"author": "Hyperscale LLC",
|