@epilot/cli 0.1.194 → 0.1.196

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +89 -1
  2. package/dist/{access-token-3XCBQDFI.js → access-token-7DZIIHDK.js} +4 -4
  3. package/dist/{add-component-GTIUBZP6.js → add-component-M2NRQPLH.js} +4 -4
  4. package/dist/{add-function-5RIKXAEC.js → add-function-ZA7DR3NM.js} +4 -4
  5. package/dist/{address-ACXTZTLB.js → address-OEHR5MKW.js} +4 -4
  6. package/dist/{address-suggestions-MIUHAFVV.js → address-suggestions-SF3YNSJN.js} +4 -4
  7. package/dist/agent-auth-GV2T4GET.js +42 -0
  8. package/dist/{ai-agents-OWQRQK5A.js → ai-agents-3SI3KJ5H.js} +4 -4
  9. package/dist/{api-PQZEGSUV.js → api-7HGTYTZV.js} +4 -4
  10. package/dist/app-JLV2WOYK.js +26 -0
  11. package/dist/{audit-logs-3DVFWVWL.js → audit-logs-I2MPPQ3V.js} +4 -4
  12. package/dist/auth-6NBJQ6NB.js +235 -0
  13. package/dist/auth-login-7D6YJLCA.js +34 -0
  14. package/dist/{auth-token-APXLIQAO.js → auth-token-CI5L3CCJ.js} +2 -2
  15. package/dist/{automation-NHRRP6J4.js → automation-GTVLSKXA.js} +4 -4
  16. package/dist/{billing-PCSW2TQP.js → billing-TNGDZAJ2.js} +4 -4
  17. package/dist/bin/epilot.js +84 -60
  18. package/dist/{blueprint-manifest-BPWLPHIU.js → blueprint-manifest-KNZRON75.js} +4 -4
  19. package/dist/{calendar-Y6AGKVWR.js → calendar-4RMKSNHL.js} +4 -4
  20. package/dist/{chat-567O35XV.js → chat-3AKMQXQG.js} +4 -4
  21. package/dist/{chunk-5KHD2F3J.js → chunk-BIOWN64A.js} +3 -3
  22. package/dist/chunk-G6KI5Z7X.js +606 -0
  23. package/dist/{chunk-KTCBDUL2.js → chunk-JQW3WOJB.js} +1 -1
  24. package/dist/{auth-login-3AY5U4JU.js → chunk-OI6GYEIX.js} +378 -11
  25. package/dist/{chunk-YHQA2AVG.js → chunk-QPUCHKXS.js} +1 -0
  26. package/dist/{chunk-M3M3C5WH.js → chunk-SQ55BTMV.js} +17 -3
  27. package/dist/{chunk-WWO5RPHF.js → chunk-Y4B3K4IO.js} +7 -7
  28. package/dist/{config-DGZIMLZK.js → config-PJWYWLQH.js} +1 -1
  29. package/dist/{configuration-hub-YPOS6ELC.js → configuration-hub-6HKPZL7E.js} +4 -4
  30. package/dist/{consent-SFI4EUGQ.js → consent-3TMN7LZO.js} +4 -4
  31. package/dist/{customer-portal-UUKBB67Z.js → customer-portal-HS3PVMHL.js} +4 -4
  32. package/dist/{dashboard-GERIZIZV.js → dashboard-WL7NVOF5.js} +4 -4
  33. package/dist/{data-governance-XVJWDVER.js → data-governance-VVEJZIN3.js} +4 -4
  34. package/dist/{deduplication-JJ46Y2CW.js → deduplication-WXROVSZU.js} +4 -4
  35. package/dist/{deploy-GZMQOG6O.js → deploy-Y2EQYBAB.js} +4 -4
  36. package/dist/{design-LYYI4DLQ.js → design-YWSM4GN6.js} +4 -4
  37. package/dist/{dev-HDXS3UPB.js → dev-OFEMDQSS.js} +4 -4
  38. package/dist/{document-5MD75ESX.js → document-HAUPZTDG.js} +4 -4
  39. package/dist/{email-settings-UKM5LYDQ.js → email-settings-47SYOOPL.js} +4 -4
  40. package/dist/{email-template-KT7YPDBF.js → email-template-JN3H6VFT.js} +4 -4
  41. package/dist/{entity-AG73SZKS.js → entity-5T4F2PEC.js} +4 -4
  42. package/dist/{entity-mapping-6MIHNIDB.js → entity-mapping-3L52T4IU.js} +4 -4
  43. package/dist/{environments-W7LRHBDB.js → environments-MKFLKYTI.js} +4 -4
  44. package/dist/{event-catalog-NCAHETDE.js → event-catalog-PZ4SFMRO.js} +4 -4
  45. package/dist/{export-2B5BAXHF.js → export-RNPPIDBT.js} +4 -4
  46. package/dist/{external-values-NHZ2EZMQ.js → external-values-FZHZGV2J.js} +4 -4
  47. package/dist/{file-Y6B2UFNC.js → file-AIIKVSDS.js} +4 -4
  48. package/dist/{iban-33N4BJUC.js → iban-2SDYV2Q6.js} +4 -4
  49. package/dist/{identity-GQ5VOASS.js → identity-CQXELR2Y.js} +4 -4
  50. package/dist/{init-5C4IJDPX.js → init-5PYFSAQA.js} +4 -4
  51. package/dist/{integration-toolkit-KTUXC24K.js → integration-toolkit-CTRGST6J.js} +4 -4
  52. package/dist/{journey-3X6BQOOO.js → journey-3CVYG5KT.js} +4 -4
  53. package/dist/{kanban-F7PRPBGV.js → kanban-2J3VBDUG.js} +4 -4
  54. package/dist/{message-K4ZMKQJE.js → message-PGJ5XXDI.js} +4 -4
  55. package/dist/{metering-ZK6VMFZ7.js → metering-DA5HJTIB.js} +4 -4
  56. package/dist/{notes-6Z42UHWN.js → notes-CUCXKOK6.js} +4 -4
  57. package/dist/{notification-NPY7FMPG.js → notification-3BE3GJLR.js} +4 -4
  58. package/dist/org-YNGJNLKY.js +427 -0
  59. package/dist/{organization-NK3CCP7F.js → organization-5MKK22PI.js} +4 -4
  60. package/dist/{partner-directory-WSFRXNTY.js → partner-directory-4CI3UQXB.js} +4 -4
  61. package/dist/{permissions-Q36SZHXQ.js → permissions-XNFMEENQ.js} +4 -4
  62. package/dist/{pricing-JSFN62BD.js → pricing-3C6LGOLN.js} +4 -4
  63. package/dist/{pricing-tier-XURRWW25.js → pricing-tier-I67ZQHPI.js} +4 -4
  64. package/dist/{profile-OZJL5ZPT.js → profile-G2FH3DXR.js} +1 -1
  65. package/dist/{purpose-GKPVUTBK.js → purpose-BSPOIU7I.js} +4 -4
  66. package/dist/{query-JZUAVWPY.js → query-5KMRWBMY.js} +4 -4
  67. package/dist/{remove-component-KLWF3QZO.js → remove-component-W2E6ZA2E.js} +4 -4
  68. package/dist/{review-L4QLVEXC.js → review-Y5RBCWJX.js} +4 -4
  69. package/dist/{sandbox-EKAOWJSR.js → sandbox-SUR4RZFD.js} +4 -4
  70. package/dist/{sharing-TKHVDJ5B.js → sharing-UZ4QWKBD.js} +4 -4
  71. package/dist/{snapshot-A2FU3NYU.js → snapshot-UAZZXLQF.js} +4 -4
  72. package/dist/{submission-NTQTZ2MG.js → submission-2ISK6IJV.js} +4 -4
  73. package/dist/{targeting-7HCCTEIJ.js → targeting-4RDTQAXT.js} +4 -4
  74. package/dist/{template-variables-ABHPJ6QR.js → template-variables-4Z3MZEGG.js} +4 -4
  75. package/dist/{upgrade-YRZHOL6I.js → upgrade-FPJAHNOK.js} +1 -1
  76. package/dist/{user-WEW5SBST.js → user-YTQDFHMV.js} +4 -4
  77. package/dist/{validate-SX4DIEWH.js → validate-7TSPYKFI.js} +4 -4
  78. package/dist/{validation-rules-PNUE7RIC.js → validation-rules-BCXYX5QO.js} +4 -4
  79. package/dist/{versions-D5NPDKRX.js → versions-LBLHNSOL.js} +4 -4
  80. package/dist/{webhooks-ECQT77EA.js → webhooks-KHULCU4Z.js} +4 -4
  81. package/dist/{workflow-JOZVUSX2.js → workflow-Q74OHJKH.js} +4 -4
  82. package/dist/{workflow-definition-GPBXEKKH.js → workflow-definition-GWMKIEUE.js} +4 -4
  83. package/package.json +3 -2
  84. package/dist/app-EJONBOTI.js +0 -26
  85. package/dist/auth-WMXFMPWE.js +0 -119
package/README.md CHANGED
@@ -29,7 +29,7 @@ npm install -g @epilot/cli
29
29
 
30
30
  <!-- usage-help -->
31
31
  ```
32
- epilot v0.1.194 — CLI for epilot APIs
32
+ epilot v0.1.196 — CLI for epilot APIs
33
33
 
34
34
  USAGE
35
35
  epilot <api> <operationId> [params...] [flags]
@@ -60,6 +60,13 @@ COMMANDS
60
60
  profile Manage named profiles
61
61
  completion Generate shell completion scripts
62
62
 
63
+ AGENT MODE (optional)
64
+ auth login --agent Register this CLI as an Agent Auth agent (org switching, silent token refresh, scoped access profiles)
65
+ org list List your organizations and this CLI's access
66
+ org use <id> Switch the active organization
67
+ org request <id> Request access (--access <profile> --reason "…")
68
+ org current Show the active organization
69
+
63
70
  APIs
64
71
  access-token Access Token API
65
72
  address Address API
@@ -123,6 +130,8 @@ EXAMPLES
123
130
  $ epilot entity searchEntities -d '{"q":"*"}'
124
131
  $ epilot entity searchEntities --jsonata 'results[0]._title'
125
132
  $ echo '{"q":"*"}' | epilot entity searchEntities
133
+ $ epilot auth login --agent --org 739224 # agent mode (optional)
134
+ $ epilot org request 739224 --access config:write --reason "Fix the PV journey mapping"
126
135
 
127
136
  Run epilot <api> to list available operations.
128
137
  Run epilot <api> <operationId> --help for operation details.
@@ -158,6 +167,82 @@ Token resolution order:
158
167
  4. Stored credentials (`~/.config/epilot/credentials.json`)
159
168
  5. Interactive prompt (if TTY)
160
169
 
170
+ ### Agent mode (optional)
171
+
172
+ `epilot auth login --agent` registers the CLI through the
173
+ [Agent Auth Protocol](https://agentauthprotocol.com/specification/v1.0-draft) (via
174
+ [`@epilot/agent-auth`](../agent-auth)): your machine is a **host**, the CLI is an **agent** you approve once in the
175
+ browser, and short-lived epilot tokens are issued per organization and refreshed silently. In return you get
176
+ organization switching, scoped **access profiles** and sessions that outlive a single token. Plain logins are not
177
+ affected: a profile without an agent behaves exactly as before.
178
+
179
+ ```bash
180
+ # Register the CLI as an agent and approve it in the browser (read access, your login organization)
181
+ epilot auth login --agent
182
+
183
+ # A specific organization, an access profile and the purpose shown to the approving user
184
+ epilot auth login --agent --org 739224 --access config:write --reason "Fix the PV registration journey mapping"
185
+
186
+ # Non-interactive (CI / agents): requires --org; prints the approval URL and polls until approved
187
+ epilot auth login --agent --org 739224 --no-interactive --json
188
+
189
+ # Status shows the agent, its grants (profile, expiry, reason); logout revokes the agent
190
+ epilot auth status
191
+ epilot auth logout
192
+ ```
193
+
194
+ Access profiles scope what the issued tokens may do. `read` is the default and lives as long as the agent; every
195
+ other profile is an escalation that requires a `--reason` (10–200 characters, prompted for in a TTY) and expires.
196
+ The flag is `--access` because `--profile` already selects a [named CLI profile](#profiles):
197
+
198
+ | `--access` | Meaning | Read-only | Expires after |
199
+ | --- | --- | --- | --- |
200
+ | `read` | Read everything you can see | yes | never (agent lifetime) |
201
+ | `config:read` | Read configuration (journeys, automations, workflows, schemas, portals, designs) | yes | 7 days |
202
+ | `config:write` | Change configuration | no | 24 hours |
203
+ | `data:read` | Read business data (contacts, opportunities, orders, files, messages) | yes | 7 days |
204
+ | `data:write` | Change business data | no | 24 hours |
205
+ | `full` | Everything your account can do | no | 24 hours |
206
+
207
+ Anonymization is a read-only property: `--anonymize` (and `org request` without `--full-pii`) only applies to read
208
+ profiles. Combining `--anonymize` with a write profile is an error ("anonymize is only available with read
209
+ profiles"), because an agent must never write masked data back. `--readonly` with a write profile downgrades it to
210
+ its read sibling (`config:write` → `config:read`, `full` → `read`). On the approval page the user can only narrow what
211
+ the CLI asked for; the CLI then issues tokens for the profile that was actually granted.
212
+
213
+ #### Organizations
214
+
215
+ One approval grants access to one organization. Switching or adding organizations goes through `epilot org`
216
+ (agent mode only — without an agent the commands exit 1 with "This profile has no agent identity. Run
217
+ `epilot auth login --agent` first.", or `{"error":"agent_required"}` with `--json`):
218
+
219
+ ```bash
220
+ epilot org list # organizations with access (profile, anonymized, "expires in 23h", pending)
221
+ epilot org current # the active organization and its profile
222
+ epilot org use 911210 # switch: issues a token under the most permissive grant (asks for access otherwise)
223
+ epilot org use 911210 --access data:read # ...or under a specific granted profile
224
+ epilot org request 911210 # ask for read, anonymized access (approved in the browser)
225
+ epilot org request 911210 --full-pii # read access with unmasked personal data
226
+ epilot org request 911210 --access data:write --reason "Import meter readings from the portal export"
227
+ epilot org request 911210 --access full --reason "…" --no-interactive --json # prints the approval, exits 0 (pending)
228
+ ```
229
+
230
+ `--write` is a deprecated alias for `--access full`. Write profiles always get full personal data (`--full-pii` is
231
+ implied). After an approval that happened outside the CLI (e.g. from a `--no-interactive` request),
232
+ `epilot org use <id>` completes the switch; `auth status` lists every grant with its profile, expiry and reason.
233
+
234
+ #### Silent refresh
235
+
236
+ Issued tokens are short-lived. Whenever a command runs and the stored token of an agent-mode profile is missing or
237
+ expires within two minutes, the CLI issues a fresh one through the agent (same organization and profile) and stores
238
+ it — you stay logged in for as long as the agent and its grant are active. If the agent was revoked or expired, run
239
+ `epilot auth login --agent` again. A plain `epilot auth login` (or `--token`) on the same profile revokes that
240
+ profile's agent, so plain tokens are never replaced.
241
+
242
+ Local state lives in `~/.config/epilot/agent-auth/` (`host.json` for the machine key, `agents/<profile>.json` for
243
+ the per-profile agent; both mode 0600). `EPILOT_AGENT_AUTH_ISSUER` overrides the Agent Auth server URL (defaults per
244
+ stage: `--use-dev`, `--use-staging`).
245
+
161
246
  ## Profiles
162
247
 
163
248
  Manage multiple environments, similar to AWS CLI profiles:
@@ -383,6 +468,9 @@ Full documentation with sample calls and responses for all APIs:
383
468
  # Install dependencies
384
469
  pnpm install
385
470
 
471
+ # Build the workspace dependency once (bundled into the CLI by tsup; also needed by tests and `pnpm dev`)
472
+ pnpm --filter @epilot/agent-auth build
473
+
386
474
  # Generate API commands + definitions + docs from client specs
387
475
  pnpm generate
388
476
 
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  callApi
4
- } from "./chunk-WWO5RPHF.js";
4
+ } from "./chunk-Y4B3K4IO.js";
5
+ import "./chunk-JQW3WOJB.js";
5
6
  import "./chunk-IOLKUHUB.js";
6
- import "./chunk-KTCBDUL2.js";
7
- import "./chunk-M3M3C5WH.js";
8
- import "./chunk-YHQA2AVG.js";
7
+ import "./chunk-SQ55BTMV.js";
8
+ import "./chunk-QPUCHKXS.js";
9
9
  import "./chunk-7ZQ666ZQ.js";
10
10
 
11
11
  // src/commands/apis/access-token.ts
@@ -3,10 +3,10 @@ import {
3
3
  log,
4
4
  readManifest,
5
5
  writeManifest
6
- } from "./chunk-5KHD2F3J.js";
7
- import "./chunk-KTCBDUL2.js";
8
- import "./chunk-M3M3C5WH.js";
9
- import "./chunk-YHQA2AVG.js";
6
+ } from "./chunk-BIOWN64A.js";
7
+ import "./chunk-JQW3WOJB.js";
8
+ import "./chunk-SQ55BTMV.js";
9
+ import "./chunk-QPUCHKXS.js";
10
10
  import "./chunk-7ZQ666ZQ.js";
11
11
 
12
12
  // src/commands/app/add-component.ts
@@ -4,10 +4,10 @@ import {
4
4
  readManifest,
5
5
  validateScheduleExpression,
6
6
  writeManifest
7
- } from "./chunk-5KHD2F3J.js";
8
- import "./chunk-KTCBDUL2.js";
9
- import "./chunk-M3M3C5WH.js";
10
- import "./chunk-YHQA2AVG.js";
7
+ } from "./chunk-BIOWN64A.js";
8
+ import "./chunk-JQW3WOJB.js";
9
+ import "./chunk-SQ55BTMV.js";
10
+ import "./chunk-QPUCHKXS.js";
11
11
  import "./chunk-7ZQ666ZQ.js";
12
12
 
13
13
  // src/commands/app/add-function.ts
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  callApi
4
- } from "./chunk-WWO5RPHF.js";
4
+ } from "./chunk-Y4B3K4IO.js";
5
+ import "./chunk-JQW3WOJB.js";
5
6
  import "./chunk-IOLKUHUB.js";
6
- import "./chunk-KTCBDUL2.js";
7
- import "./chunk-M3M3C5WH.js";
8
- import "./chunk-YHQA2AVG.js";
7
+ import "./chunk-SQ55BTMV.js";
8
+ import "./chunk-QPUCHKXS.js";
9
9
  import "./chunk-7ZQ666ZQ.js";
10
10
 
11
11
  // src/commands/apis/address.ts
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  callApi
4
- } from "./chunk-WWO5RPHF.js";
4
+ } from "./chunk-Y4B3K4IO.js";
5
+ import "./chunk-JQW3WOJB.js";
5
6
  import "./chunk-IOLKUHUB.js";
6
- import "./chunk-KTCBDUL2.js";
7
- import "./chunk-M3M3C5WH.js";
8
- import "./chunk-YHQA2AVG.js";
7
+ import "./chunk-SQ55BTMV.js";
8
+ import "./chunk-QPUCHKXS.js";
9
9
  import "./chunk-7ZQ666ZQ.js";
10
10
 
11
11
  // src/commands/apis/address-suggestions.ts
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ REFRESH_WINDOW_MS,
4
+ agentPath,
5
+ agentProfileKey,
6
+ deleteAgentRecord,
7
+ ensureHostKey,
8
+ forgetAgentForProfile,
9
+ formatExpiresIn,
10
+ getAgentAuthClient,
11
+ isAgentGoneError,
12
+ issueTokenForOrg,
13
+ loadAgentIdentity,
14
+ loadAgentRecord,
15
+ loadHostKey,
16
+ printLoginAgainHint,
17
+ refreshTokenIfNeeded,
18
+ resolveAgentAuthIssuer,
19
+ saveAgentRecord
20
+ } from "./chunk-G6KI5Z7X.js";
21
+ import "./chunk-SQ55BTMV.js";
22
+ import "./chunk-QPUCHKXS.js";
23
+ import "./chunk-7ZQ666ZQ.js";
24
+ export {
25
+ REFRESH_WINDOW_MS,
26
+ agentPath,
27
+ agentProfileKey,
28
+ deleteAgentRecord,
29
+ ensureHostKey,
30
+ forgetAgentForProfile,
31
+ formatExpiresIn,
32
+ getAgentAuthClient,
33
+ isAgentGoneError,
34
+ issueTokenForOrg,
35
+ loadAgentIdentity,
36
+ loadAgentRecord,
37
+ loadHostKey,
38
+ printLoginAgainHint,
39
+ refreshTokenIfNeeded,
40
+ resolveAgentAuthIssuer,
41
+ saveAgentRecord
42
+ };
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  callApi
4
- } from "./chunk-WWO5RPHF.js";
4
+ } from "./chunk-Y4B3K4IO.js";
5
+ import "./chunk-JQW3WOJB.js";
5
6
  import "./chunk-IOLKUHUB.js";
6
- import "./chunk-KTCBDUL2.js";
7
- import "./chunk-M3M3C5WH.js";
8
- import "./chunk-YHQA2AVG.js";
7
+ import "./chunk-SQ55BTMV.js";
8
+ import "./chunk-QPUCHKXS.js";
9
9
  import "./chunk-7ZQ666ZQ.js";
10
10
 
11
11
  // src/commands/apis/ai-agents.ts
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  callApi
4
- } from "./chunk-WWO5RPHF.js";
4
+ } from "./chunk-Y4B3K4IO.js";
5
+ import "./chunk-JQW3WOJB.js";
5
6
  import "./chunk-IOLKUHUB.js";
6
- import "./chunk-KTCBDUL2.js";
7
- import "./chunk-M3M3C5WH.js";
8
- import "./chunk-YHQA2AVG.js";
7
+ import "./chunk-SQ55BTMV.js";
8
+ import "./chunk-QPUCHKXS.js";
9
9
  import "./chunk-7ZQ666ZQ.js";
10
10
 
11
11
  // src/commands/app/api.ts
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/commands/app/index.ts
4
+ import { defineCommand } from "citty";
5
+ var app_default = defineCommand({
6
+ meta: {
7
+ name: "app",
8
+ description: "Manage epilot Apps \u2014 create, deploy, and manage app manifests"
9
+ },
10
+ subCommands: {
11
+ init: () => import("./init-5PYFSAQA.js").then((m) => m.default),
12
+ "add-component": () => import("./add-component-M2NRQPLH.js").then((m) => m.default),
13
+ "remove-component": () => import("./remove-component-W2E6ZA2E.js").then((m) => m.default),
14
+ "add-function": () => import("./add-function-ZA7DR3NM.js").then((m) => m.default),
15
+ validate: () => import("./validate-7TSPYKFI.js").then((m) => m.default),
16
+ deploy: () => import("./deploy-Y2EQYBAB.js").then((m) => m.default),
17
+ dev: () => import("./dev-OFEMDQSS.js").then((m) => m.default),
18
+ export: () => import("./export-RNPPIDBT.js").then((m) => m.default),
19
+ versions: () => import("./versions-LBLHNSOL.js").then((m) => m.default),
20
+ review: () => import("./review-Y5RBCWJX.js").then((m) => m.default),
21
+ api: () => import("./api-7HGTYTZV.js").then((m) => m.default)
22
+ }
23
+ });
24
+ export {
25
+ app_default as default
26
+ };
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  callApi
4
- } from "./chunk-WWO5RPHF.js";
4
+ } from "./chunk-Y4B3K4IO.js";
5
+ import "./chunk-JQW3WOJB.js";
5
6
  import "./chunk-IOLKUHUB.js";
6
- import "./chunk-KTCBDUL2.js";
7
- import "./chunk-M3M3C5WH.js";
8
- import "./chunk-YHQA2AVG.js";
7
+ import "./chunk-SQ55BTMV.js";
8
+ import "./chunk-QPUCHKXS.js";
9
9
  import "./chunk-7ZQ666ZQ.js";
10
10
 
11
11
  // src/commands/apis/audit-logs.ts
@@ -0,0 +1,235 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ ACCESS_PROFILE_INFO,
4
+ AgentAuthError,
5
+ deleteAgentRecord,
6
+ formatExpiresIn,
7
+ isAccessProfile,
8
+ loadAgentIdentity,
9
+ organizationGrants
10
+ } from "./chunk-G6KI5Z7X.js";
11
+ import {
12
+ loadCredentials,
13
+ removeCredentials
14
+ } from "./chunk-SQ55BTMV.js";
15
+ import {
16
+ getResolvedProfile,
17
+ resolveProfileName,
18
+ upsertProfile
19
+ } from "./chunk-QPUCHKXS.js";
20
+ import {
21
+ BOLD,
22
+ DIM,
23
+ GREEN,
24
+ RED,
25
+ RESET,
26
+ YELLOW
27
+ } from "./chunk-7ZQ666ZQ.js";
28
+
29
+ // src/commands/auth.ts
30
+ import { defineCommand } from "citty";
31
+ var auth_default = defineCommand({
32
+ meta: {
33
+ name: "auth",
34
+ description: "Manage authentication"
35
+ },
36
+ subCommands: {
37
+ login: () => import("./auth-login-7D6YJLCA.js").then((m) => m.default),
38
+ token: () => import("./auth-token-CI5L3CCJ.js").then((m) => m.default),
39
+ logout: defineCommand({
40
+ meta: { name: "logout", description: "Remove stored credentials" },
41
+ args: {
42
+ profile: { type: "string", description: "Profile to log out (or EPILOT_PROFILE env)" }
43
+ },
44
+ run: async ({ args }) => {
45
+ const profileName = args.profile || process.env.EPILOT_PROFILE;
46
+ const loaded = loadAgentIdentity(profileName);
47
+ if (loaded) {
48
+ try {
49
+ await loaded.client.revokeAgent(loaded.identity.hostKey, loaded.identity.agentId);
50
+ process.stdout.write(`${DIM}Agent ${loaded.record.agent_id} revoked.${RESET}
51
+ `);
52
+ } catch (error) {
53
+ const reason = error instanceof AgentAuthError ? error.code : "error";
54
+ process.stdout.write(
55
+ `${DIM}Could not revoke agent ${loaded.record.agent_id} (${reason}); removing it locally.${RESET}
56
+ `
57
+ );
58
+ }
59
+ deleteAgentRecord(profileName);
60
+ const resolvedName = resolveProfileName(profileName);
61
+ if (resolvedName && getResolvedProfile(profileName)?.token) {
62
+ upsertProfile(resolvedName, {
63
+ token: void 0,
64
+ org_id: void 0,
65
+ user_id: void 0,
66
+ expires_at: void 0,
67
+ access_profile: void 0
68
+ });
69
+ }
70
+ }
71
+ const removed = removeCredentials();
72
+ if (removed || loaded) {
73
+ process.stdout.write(`${GREEN}Logged out successfully.${RESET}
74
+ `);
75
+ } else {
76
+ process.stdout.write(`No stored credentials found.
77
+ `);
78
+ }
79
+ }
80
+ }),
81
+ status: defineCommand({
82
+ meta: { name: "status", description: "Show authentication status" },
83
+ args: {
84
+ profile: { type: "string", description: "Profile to inspect (or EPILOT_PROFILE env)" }
85
+ },
86
+ run: async ({ args }) => {
87
+ const profileName = args.profile || process.env.EPILOT_PROFILE;
88
+ const loaded = loadAgentIdentity(profileName);
89
+ if (!loaded) {
90
+ const plain = loadCredentials();
91
+ if (!plain) {
92
+ process.stdout.write(`${YELLOW}Not authenticated.${RESET}
93
+ `);
94
+ process.stdout.write(`Run ${BOLD}epilot auth login${RESET} to authenticate.
95
+ `);
96
+ return;
97
+ }
98
+ printTokenStatus(plain, { agent: false });
99
+ return;
100
+ }
101
+ const creds = loadCredentials() ?? profileCredentials(profileName);
102
+ if (creds) {
103
+ printTokenStatus(creds, { agent: true });
104
+ } else {
105
+ process.stdout.write(`${YELLOW}No valid token stored${RESET} ${DIM}(issued on next API call)${RESET}
106
+ `);
107
+ }
108
+ process.stdout.write(`
109
+ ${BOLD}Agent Auth${RESET}
110
+ `);
111
+ process.stdout.write(` Agent: ${loaded.record.agent_id} ${DIM}(${loaded.record.name})${RESET}
112
+ `);
113
+ process.stdout.write(` Host: ${loaded.record.host_id}
114
+ `);
115
+ process.stdout.write(` Issuer: ${loaded.record.issuer}
116
+ `);
117
+ try {
118
+ const status = await loaded.client.getAgentStatus(loaded.identity.hostKey, loaded.identity.agentId);
119
+ const color = status.status === "active" ? GREEN : status.status === "pending" ? YELLOW : RED;
120
+ process.stdout.write(` Status: ${color}${status.status}${RESET}`);
121
+ if (status.expires_at) process.stdout.write(` ${DIM}(expires ${status.expires_at})${RESET}`);
122
+ process.stdout.write("\n");
123
+ const grants = organizationGrants(status.agent_capability_grants);
124
+ if (grants.length) {
125
+ process.stdout.write(` Grants:
126
+ `);
127
+ for (const g of grants) {
128
+ const expiry = formatExpiresIn(g.expiresAt);
129
+ const expired = expiry === "expired";
130
+ const level = [g.profile, g.anonymized ? "anonymized" : "", expiry ?? ""].filter(Boolean);
131
+ const statusColor = g.grant.status === "active" && !expired ? GREEN : g.grant.status === "pending" ? YELLOW : RED;
132
+ const active = g.organizationId && g.organizationId === creds?.org_id && g.profile === (creds?.access_profile ?? "read") ? ` ${DIM}(active)${RESET}` : "";
133
+ const reason = g.reason ? ` ${DIM}\u2014 "${g.reason}"${RESET}` : "";
134
+ process.stdout.write(
135
+ ` ${(g.organizationId ?? "login organization").padEnd(12)} ${statusColor}${expired ? "expired" : g.grant.status}${RESET} ${DIM}${level.join(", ")}${RESET}${active}${reason}
136
+ `
137
+ );
138
+ }
139
+ }
140
+ } catch (error) {
141
+ const reason = error instanceof AgentAuthError ? `${error.message} (${error.code})` : String(error);
142
+ process.stdout.write(` Status: ${RED}unavailable${RESET} ${DIM}${reason}${RESET}
143
+ `);
144
+ }
145
+ }
146
+ })
147
+ }
148
+ });
149
+ var profileCredentials = (profileName) => {
150
+ const profile = getResolvedProfile(profileName);
151
+ if (!profile?.token) return null;
152
+ if (profile.expires_at && new Date(profile.expires_at) < /* @__PURE__ */ new Date()) return null;
153
+ return {
154
+ token: profile.token,
155
+ org_id: profile.org_id,
156
+ user_id: profile.user_id,
157
+ expires_at: profile.expires_at,
158
+ access_profile: profile.access_profile
159
+ };
160
+ };
161
+ var printTokenStatus = (creds, { agent }) => {
162
+ const claims = parseJwtPayload(creds.token);
163
+ const isApiToken = claims?.token_type === "api";
164
+ const isCognitoToken = typeof claims?.iss === "string" && claims.iss.includes("cognito-idp");
165
+ const tokenType = isApiToken ? "API Token" : isCognitoToken ? "User Token" : "Token";
166
+ process.stdout.write(`${GREEN}${BOLD}Authenticated${RESET} ${DIM}(${tokenType})${RESET}
167
+ `);
168
+ const name = claims?.token_name || claims?.email || claims?.["cognito:username"] || creds.name;
169
+ const orgId = claims?.org_id || claims?.["custom:ivy_org_id"] || creds.org_id;
170
+ const userId = claims?.user_id || claims?.["custom:ivy_user_id"] || creds.user_id;
171
+ const tokenId = claims?.token_id;
172
+ const adminEmail = claims?.admin_email;
173
+ const tokenUse = claims?.token_use;
174
+ const roles = claims?.assume_roles;
175
+ const readOnly = claims?.read_only === true;
176
+ const anonymize = claims?.anonymize === true;
177
+ if (name) process.stdout.write(` Name: ${name}
178
+ `);
179
+ if (adminEmail && adminEmail !== name) process.stdout.write(` Email: ${adminEmail}
180
+ `);
181
+ if (orgId) process.stdout.write(` Org: ${orgId}
182
+ `);
183
+ if (userId) process.stdout.write(` User: ${userId}
184
+ `);
185
+ if (tokenId && tokenId !== userId) process.stdout.write(` Token ID: ${tokenId}
186
+ `);
187
+ if (tokenUse) process.stdout.write(` Use: ${tokenUse}
188
+ `);
189
+ if (roles?.length) process.stdout.write(` Roles: ${roles.join(", ")}
190
+ `);
191
+ process.stdout.write(` Access: ${readOnly ? `${YELLOW}read-only${RESET}` : `${GREEN}read-write${RESET}`}
192
+ `);
193
+ if (isAccessProfile(creds.access_profile)) {
194
+ process.stdout.write(
195
+ ` Profile: ${creds.access_profile} ${DIM}(${ACCESS_PROFILE_INFO[creds.access_profile].title})${RESET}
196
+ `
197
+ );
198
+ }
199
+ if (anonymize) process.stdout.write(` Data: ${YELLOW}anonymized${RESET}
200
+ `);
201
+ if (creds.expires_at) {
202
+ const expiry = new Date(creds.expires_at);
203
+ const now = /* @__PURE__ */ new Date();
204
+ const diffMs = expiry.getTime() - now.getTime();
205
+ const label = agent ? diffMs < 864e5 ? `${Math.floor(diffMs / 36e5)}h ${Math.floor(diffMs % 36e5 / 6e4)}m` : `${Math.floor(diffMs / 864e5)} days` : `${Math.floor(diffMs / (1e3 * 60 * 60 * 24))} days`;
206
+ process.stdout.write(` Expires: ${creds.expires_at} ${DIM}(${label})${RESET}
207
+ `);
208
+ } else if (claims?.exp) {
209
+ const expiry = new Date(claims.exp * 1e3);
210
+ const now = /* @__PURE__ */ new Date();
211
+ const diffMs = expiry.getTime() - now.getTime();
212
+ const label = diffMs < 0 ? `${RED}expired${RESET}` : diffMs < 864e5 ? `${Math.floor(diffMs / 36e5)}h ${Math.floor(diffMs % 36e5 / 6e4)}m` : `${Math.floor(diffMs / 864e5)} days`;
213
+ process.stdout.write(` Expires: ${expiry.toISOString()} ${DIM}(${label})${RESET}
214
+ `);
215
+ } else if (claims?.iat && !claims?.exp) {
216
+ const issued = new Date(claims.iat * 1e3);
217
+ process.stdout.write(` Issued: ${issued.toISOString()} ${DIM}(no expiry)${RESET}
218
+ `);
219
+ }
220
+ process.stdout.write(` Token: ${creds.token.substring(0, 20)}...${RESET}
221
+ `);
222
+ };
223
+ var parseJwtPayload = (token) => {
224
+ try {
225
+ const parts = token.split(".");
226
+ if (parts.length !== 3) return null;
227
+ const payload = Buffer.from(parts[1], "base64url").toString("utf-8");
228
+ return JSON.parse(payload);
229
+ } catch {
230
+ return null;
231
+ }
232
+ };
233
+ export {
234
+ auth_default as default
235
+ };
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ AGENT_FLAG_DESCRIPTION,
4
+ agentLogin,
5
+ auth_login_default,
6
+ browserLogin,
7
+ chooseOrganization,
8
+ describeAccess,
9
+ openBrowser,
10
+ parseAccessProfile,
11
+ printApproval,
12
+ readOnlySibling,
13
+ resolveLoginProfile,
14
+ resolveReason
15
+ } from "./chunk-OI6GYEIX.js";
16
+ import "./chunk-IOLKUHUB.js";
17
+ import "./chunk-G6KI5Z7X.js";
18
+ import "./chunk-SQ55BTMV.js";
19
+ import "./chunk-QPUCHKXS.js";
20
+ import "./chunk-7ZQ666ZQ.js";
21
+ export {
22
+ AGENT_FLAG_DESCRIPTION,
23
+ agentLogin,
24
+ browserLogin,
25
+ chooseOrganization,
26
+ auth_login_default as default,
27
+ describeAccess,
28
+ openBrowser,
29
+ parseAccessProfile,
30
+ printApproval,
31
+ readOnlySibling,
32
+ resolveLoginProfile,
33
+ resolveReason
34
+ };
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  saveCredentials
4
- } from "./chunk-M3M3C5WH.js";
5
- import "./chunk-YHQA2AVG.js";
4
+ } from "./chunk-SQ55BTMV.js";
5
+ import "./chunk-QPUCHKXS.js";
6
6
  import {
7
7
  BOLD,
8
8
  GREEN,
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  callApi
4
- } from "./chunk-WWO5RPHF.js";
4
+ } from "./chunk-Y4B3K4IO.js";
5
+ import "./chunk-JQW3WOJB.js";
5
6
  import "./chunk-IOLKUHUB.js";
6
- import "./chunk-KTCBDUL2.js";
7
- import "./chunk-M3M3C5WH.js";
8
- import "./chunk-YHQA2AVG.js";
7
+ import "./chunk-SQ55BTMV.js";
8
+ import "./chunk-QPUCHKXS.js";
9
9
  import "./chunk-7ZQ666ZQ.js";
10
10
 
11
11
  // src/commands/apis/automation.ts
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  callApi
4
- } from "./chunk-WWO5RPHF.js";
4
+ } from "./chunk-Y4B3K4IO.js";
5
+ import "./chunk-JQW3WOJB.js";
5
6
  import "./chunk-IOLKUHUB.js";
6
- import "./chunk-KTCBDUL2.js";
7
- import "./chunk-M3M3C5WH.js";
8
- import "./chunk-YHQA2AVG.js";
7
+ import "./chunk-SQ55BTMV.js";
8
+ import "./chunk-QPUCHKXS.js";
9
9
  import "./chunk-7ZQ666ZQ.js";
10
10
 
11
11
  // src/commands/apis/billing.ts