@kodycodes/cli 3.34.5 → 3.34.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -80
- package/dist/{auth-DWGWWITD.js → auth-I4XH63PZ.js} +8 -8
- package/dist/auth-bootstrap.d.ts +9 -2
- package/dist/bin.js +11 -11
- package/dist/chunk-22AN66MM.js +170 -0
- package/dist/chunk-22AN66MM.js.map +6 -0
- package/dist/{chunk-FKRK4KX2.js → chunk-4QDPGKUS.js} +10 -5
- package/dist/chunk-4QDPGKUS.js.map +6 -0
- package/dist/{chunk-5SC7O2PH.js → chunk-5BNIKSOV.js} +6 -6
- package/dist/{chunk-3Y5ORFHI.js → chunk-7UV4RVJW.js} +2 -2
- package/dist/{chunk-KIE2IYSQ.js → chunk-B4OOCRLZ.js} +4 -4
- package/dist/{chunk-IQT3CSAH.js → chunk-B5DIPCOD.js} +3 -3
- package/dist/{chunk-6JZQOHFG.js → chunk-ENFBLA4M.js} +2 -17
- package/dist/{chunk-6JZQOHFG.js.map → chunk-ENFBLA4M.js.map} +1 -1
- package/dist/{chunk-DJD2F7UG.js → chunk-HBHIQDJI.js} +85 -104
- package/dist/chunk-HBHIQDJI.js.map +6 -0
- package/dist/{chunk-D6UGXUT4.js → chunk-KMEHILCP.js} +4 -4
- package/dist/chunk-KMEHILCP.js.map +6 -0
- package/dist/{chunk-XMSOSYDJ.js → chunk-KXK3O7O2.js} +3 -3
- package/dist/{chunk-PIQVCGBG.js → chunk-LGG77FR7.js} +4 -4
- package/dist/chunk-LGG77FR7.js.map +6 -0
- package/dist/{chunk-XJGR7USP.js → chunk-PGJ22SM7.js} +1 -1
- package/dist/{chunk-XJGR7USP.js.map → chunk-PGJ22SM7.js.map} +1 -1
- package/dist/{chunk-ONR2NQSZ.js → chunk-V3KIBQVH.js} +98 -158
- package/dist/chunk-V3KIBQVH.js.map +6 -0
- package/dist/{chunk-RHMKQBDF.js → chunk-W7JYNGNA.js} +6 -6
- package/dist/{chunk-WAGPHHLE.js → chunk-XQQYWLYQ.js} +4 -4
- package/dist/{chunk-UL7FYAAL.js → chunk-XRIUHO5Q.js} +2 -2
- package/dist/{chunk-GD7ZK2TS.js → chunk-Z7DR5UNN.js} +1 -1
- package/dist/{chunk-GD7ZK2TS.js.map → chunk-Z7DR5UNN.js.map} +1 -1
- package/dist/cli-credential.d.ts +24 -25
- package/dist/cli.d.ts +2 -2
- package/dist/cli.js +11 -11
- package/dist/{commands-5SON3UIU.js → commands-CX2FTGEB.js} +6 -6
- package/dist/{commands-5SON3UIU.js.map → commands-CX2FTGEB.js.map} +1 -1
- package/dist/{dev-command-C6KQGDDX.js → dev-command-WOSJFXY7.js} +20 -20
- package/dist/execution-context/host-command-state.d.ts +4 -0
- package/dist/execution-context/keystore.d.ts +6 -3
- package/dist/{git-credential-CJU5XPLS.js → git-credential-JUIVYMJM.js} +39 -52
- package/dist/git-credential-JUIVYMJM.js.map +6 -0
- package/dist/git-credential.d.ts +13 -15
- package/dist/keyring-entry.d.ts +5 -1
- package/dist/{local-execute-NDTHSGUJ.js → local-execute-DY6HZ3KQ.js} +10 -10
- package/dist/{local-package-graph-2O57E4YF.js → local-package-graph-FMCN2OY4.js} +7 -7
- package/dist/{local-package-run-D5D2MBEV.js → local-package-run-BUO3MVML.js} +12 -12
- package/dist/{local-secrets-6WYNC5RH.js → local-secrets-77VJOY4E.js} +7 -7
- package/dist/mock/mock-storage.d.ts +3 -2
- package/dist/{mock-dep-resolve-YOTBQODM.js → mock-dep-resolve-JA6IDQPE.js} +6 -6
- package/dist/{mock-local-deps-AE2JUMC3.js → mock-local-deps-QHMQCI5L.js} +9 -9
- package/dist/{mock-server-IAXWMMFJ.js → mock-server-IUHUKCGP.js} +2 -2
- package/dist/{open-api-client-6L6KSSK6.js → open-api-client-S26DL5MW.js} +7 -7
- package/dist/{org-JE67J3U4.js → org-VKSU4YVE.js} +2 -2
- package/dist/publish-builder.js +14 -2
- package/dist/{remote-execute-Z6NGBM3M.js → remote-execute-WTORQH3E.js} +7 -7
- package/dist/{run-executor-6GE3P4S4.js → run-executor-VFNRNXVE.js} +2 -2
- package/dist/{setup-git-4UECBTVV.js → setup-git-LSHM7DQM.js} +8 -8
- package/dist/setup-git.d.ts +8 -11
- package/dist/{store-XUB5AFUP.js → store-DGAP2AZS.js} +2 -2
- package/dist/store.d.ts +2 -0
- package/dist/{whoami-DVDBA3FV.js → whoami-3HCHZO2F.js} +8 -14
- package/dist/whoami-3HCHZO2F.js.map +6 -0
- package/package.json +1 -1
- package/dist/chunk-D6UGXUT4.js.map +0 -6
- package/dist/chunk-DJD2F7UG.js.map +0 -6
- package/dist/chunk-FKRK4KX2.js.map +0 -6
- package/dist/chunk-LZMFWQGZ.js +0 -175
- package/dist/chunk-LZMFWQGZ.js.map +0 -6
- package/dist/chunk-ONR2NQSZ.js.map +0 -6
- package/dist/chunk-PIQVCGBG.js.map +0 -6
- package/dist/git-credential-CJU5XPLS.js.map +0 -6
- package/dist/whoami-DVDBA3FV.js.map +0 -6
- /package/dist/{auth-DWGWWITD.js.map → auth-I4XH63PZ.js.map} +0 -0
- /package/dist/{chunk-5SC7O2PH.js.map → chunk-5BNIKSOV.js.map} +0 -0
- /package/dist/{chunk-3Y5ORFHI.js.map → chunk-7UV4RVJW.js.map} +0 -0
- /package/dist/{chunk-KIE2IYSQ.js.map → chunk-B4OOCRLZ.js.map} +0 -0
- /package/dist/{chunk-IQT3CSAH.js.map → chunk-B5DIPCOD.js.map} +0 -0
- /package/dist/{chunk-XMSOSYDJ.js.map → chunk-KXK3O7O2.js.map} +0 -0
- /package/dist/{chunk-RHMKQBDF.js.map → chunk-W7JYNGNA.js.map} +0 -0
- /package/dist/{chunk-WAGPHHLE.js.map → chunk-XQQYWLYQ.js.map} +0 -0
- /package/dist/{chunk-UL7FYAAL.js.map → chunk-XRIUHO5Q.js.map} +0 -0
- /package/dist/{dev-command-C6KQGDDX.js.map → dev-command-WOSJFXY7.js.map} +0 -0
- /package/dist/{local-execute-NDTHSGUJ.js.map → local-execute-DY6HZ3KQ.js.map} +0 -0
- /package/dist/{local-package-graph-2O57E4YF.js.map → local-package-graph-FMCN2OY4.js.map} +0 -0
- /package/dist/{local-package-run-D5D2MBEV.js.map → local-package-run-BUO3MVML.js.map} +0 -0
- /package/dist/{local-secrets-6WYNC5RH.js.map → local-secrets-77VJOY4E.js.map} +0 -0
- /package/dist/{mock-dep-resolve-YOTBQODM.js.map → mock-dep-resolve-JA6IDQPE.js.map} +0 -0
- /package/dist/{mock-local-deps-AE2JUMC3.js.map → mock-local-deps-QHMQCI5L.js.map} +0 -0
- /package/dist/{mock-server-IAXWMMFJ.js.map → mock-server-IUHUKCGP.js.map} +0 -0
- /package/dist/{open-api-client-6L6KSSK6.js.map → open-api-client-S26DL5MW.js.map} +0 -0
- /package/dist/{org-JE67J3U4.js.map → org-VKSU4YVE.js.map} +0 -0
- /package/dist/{remote-execute-Z6NGBM3M.js.map → remote-execute-WTORQH3E.js.map} +0 -0
- /package/dist/{run-executor-6GE3P4S4.js.map → run-executor-VFNRNXVE.js.map} +0 -0
- /package/dist/{setup-git-4UECBTVV.js.map → setup-git-LSHM7DQM.js.map} +0 -0
- /package/dist/{store-XUB5AFUP.js.map → store-DGAP2AZS.js.map} +0 -0
package/README.md
CHANGED
|
@@ -108,14 +108,14 @@ flags, and subcommands.
|
|
|
108
108
|
| `kody org use [<slug>]` | Switches the active org. With a slug (agents) switches directly; with no slug on a TTY opens a chooser; without a TTY pass a slug. |
|
|
109
109
|
| `kody logout` | Removes the active org login (or `--org <slug>` for one org) and clears a stored bootstrap/API token when appropriate. |
|
|
110
110
|
| `kody status` | Shows CLI login / stored API token state without printing secrets. |
|
|
111
|
-
| `kody auth bootstrap --code` | Redeems a one-shot `kody_bc_…` from MCP `cliCredentialBootstrap` and
|
|
112
|
-
| `kody auth bootstrap --scopes` |
|
|
111
|
+
| `kody auth bootstrap --code` | Redeems a one-shot `kody_bc_…` from MCP `cliCredentialBootstrap` and saves the same credential `kody login` saves (never prints the token). Every command, including git, uses that slot. |
|
|
112
|
+
| `kody auth bootstrap --scopes` | Saves a deliberately narrower credential (the list replaces the default): mints the code itself by passing `scopes` to `cliCredentialBootstrap` (with `--token`, else `KODY_API_TOKEN`, else the saved credential), then redeems and stores it. See [Narrower scopes](#narrower-scopes). |
|
|
113
113
|
| `kody auth setup-git` | Installs a Git credential helper for `https://kody.codes/@owner/name.git` (persistent `kody_at_…`, user-owned token with `package:read`/`package:write`). See [Git HTTPS](#git-https-setup-git). |
|
|
114
|
-
| `kody auth remove-git` | Inverse of `setup-git`: clears Kody HTTPS git helpers
|
|
114
|
+
| `kody auth remove-git` | Inverse of `setup-git`: clears Kody HTTPS git helpers and revokes any token left in the old API-token slot. Leaves the saved CLI credential alone. |
|
|
115
115
|
| `kody git-credential` | Credential helper invoked by Git after `setup-git` (`get` / `store` / `erase`). |
|
|
116
|
-
| `kody whoami` | Shows the credential commands will use (`--token`, `KODY_API_TOKEN`,
|
|
116
|
+
| `kody whoami` | Shows the credential commands will use (`--token`, `KODY_API_TOKEN`, or the saved CLI credential from `kody login` / `kody auth bootstrap`), its token id and scopes, and any other stored credential it outranks. See [Which credential a command uses](#which-credential-a-command-uses). |
|
|
117
117
|
| `kody search [query]` | Calls Kody `search` from the CLI (prefer the host MCP tool). Token-only auth uses Open API `GET /v1/search`. |
|
|
118
|
-
| `kody api <operationId>` | Thin Open API wrapper matching the MCP `api` tool: `operationId` + flat `--params` JSON. Auth: `--token`, `KODY_API_TOKEN`, the
|
|
118
|
+
| `kody api <operationId>` | Thin Open API wrapper matching the MCP `api` tool: `operationId` + flat `--params` JSON. Auth: `--token`, `KODY_API_TOKEN`, then the saved CLI credential (same pick `kody whoami` reports). The parsed `/openapi.json` route map is cached under the Kody cache dir keyed by the document's `ETag` and revalidated with `If-None-Match` on each run. |
|
|
119
119
|
| `kody secret get <name>` | Prints the value of a secret whose local reads a person turned on in Kody (raw by default; `--format env` or `--format json` for several). Refuses an interactive terminal unless `--reveal`; piped output is fine. A refused read prints a plain reason and, when local reads are off, a link to turn them on for that secret. Same auth as `kody api`. |
|
|
120
120
|
| `kody run --secret <name>[=ENV] -- <cmd>` | Reads every listed secret (or none), then runs the command with them in its environment. `databaseUrl` becomes `DATABASE_URL` unless named. Exits with the command's exit code. |
|
|
121
121
|
| `kody package publish` | Thin wrapper for `packagePublishExternalPush`. Optional positional `@owner/leaf`, bare leaf name, or package UUID (names are resolved to the package UUID via `packageList`); extra fields via `--params`. Same auth as `kody api`. Prints the API JSON. Exit **0** for `published`, `already_published` (including `artifacts_rebuilt: true`), and `dispatched` (poll `workflowRunList({ workflow_id })`). Exit **1** for refusal/rejection statuses (`checks_failed`, `locked`, `approval_required`, `not_fast_forward`) with the API `message` (or a checks summary) on stderr, like npm. Auth / permission / network failures also exit 1; `--json` adds `{ error, message, sent }` on stdout for network errors (`sent: false` = not sent; `sent: "unknown"` = maybe sent — prefer `kody api workflowRunList` with `workflow_id` when known, otherwise a recent list, before retry). Re-publishing the same commit is safe (durable dedupe / `already_published`). |
|
|
@@ -165,21 +165,17 @@ npx @kodycodes/cli api usageGet --params '{}'
|
|
|
165
165
|
the returned `cli_command` (never ask a human to paste a token); humans run
|
|
166
166
|
`kody login`; CI/headless uses `tokenCreate` + `KODY_API_TOKEN`.
|
|
167
167
|
- For `execute --local` specifically: `--token` / `KODY_API_TOKEN` wins when
|
|
168
|
-
set; else
|
|
169
|
-
`kody
|
|
170
|
-
|
|
171
|
-
`
|
|
172
|
-
|
|
173
|
-
a different API origin, use `auth bootstrap --api-url <origin>` or set
|
|
174
|
-
`KODY_API_TOKEN`. Paired `kody login` OAuth is accepted as Bearer on
|
|
175
|
-
CapabilityProxy and package-graph. Unpaired API origins need bootstrap or a
|
|
176
|
-
scoped `kody_at_…` token.
|
|
168
|
+
set; else the one saved CLI credential from `kody login` or
|
|
169
|
+
`kody auth bootstrap` (same slot, whichever ran last). A token an older CLI
|
|
170
|
+
left in the old API-token slot is moved into that credential only when nothing
|
|
171
|
+
else is saved; `kody login` deletes it. For a different API origin, use
|
|
172
|
+
`auth bootstrap --api-url <origin>` or set `KODY_API_TOKEN`.
|
|
177
173
|
- Wrong/expired token → 401 with the same agent-first not-authenticated guidance
|
|
178
174
|
(or the OAuth platform-gap message when the bearer is login OAuth).
|
|
179
175
|
- Wrong scopes → the error names the missing scope and the exact command to mint
|
|
180
|
-
a token that adds it (see [
|
|
181
|
-
lacks the permission, it says so instead: a new token cannot add it, and
|
|
182
|
-
org Owner has to grant it.
|
|
176
|
+
a token that adds it (see [Narrower scopes](#narrower-scopes)). When your org
|
|
177
|
+
role lacks the permission, it says so instead: a new token cannot add it, and
|
|
178
|
+
an org Owner has to grant it.
|
|
183
179
|
- Account flag off → the error includes `feature_disabled` and the
|
|
184
180
|
`local-execute` feature flag. Another token does not bypass that flag.
|
|
185
181
|
- Prefer the env var so the token stays out of shell history and `ps`.
|
|
@@ -190,56 +186,42 @@ npx @kodycodes/cli api usageGet --params '{}'
|
|
|
190
186
|
One resolver picks the credential for every command, and `kody whoami` reports
|
|
191
187
|
the same pick:
|
|
192
188
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
| `whoami`, `api`, `package`, `execute --local`, `context`, `daemon`, `dev` | `--token`, `KODY_API_TOKEN`, stored API token, `kody login` |
|
|
196
|
-
| `search`, cloud `execute` (no `--local`) | `--token`, `kody login` (over MCP), `KODY_API_TOKEN`, stored API token |
|
|
197
|
-
| `auth bootstrap --scopes` (minting) | `--token`, `kody login`, `KODY_API_TOKEN`, stored API token |
|
|
189
|
+
Every command uses the same order: `--token`, `KODY_API_TOKEN`, then the one
|
|
190
|
+
saved CLI credential.
|
|
198
191
|
|
|
199
192
|
Desktop integrations can set `KODY_CREDENTIAL_SOURCE=login` to select only the
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
## Opt-in scopes
|
|
220
|
-
|
|
221
|
-
Bootstrap tokens default to local-execute use scopes plus `package:write`,
|
|
222
|
-
`package:create`, and `token:delete`. They do not include `search:read`. Pass
|
|
223
|
-
`--scopes` when a task needs a different set (the list replaces the defaults):
|
|
193
|
+
saved credential. Unset it for normal CLI precedence.
|
|
194
|
+
|
|
195
|
+
- The saved credential comes from `kody login` or `kody auth bootstrap`. Both
|
|
196
|
+
save the same kind of `kody_at_…` (every scope your org role grants, 14d idle
|
|
197
|
+
/ 3mo max) in the same slot, so whichever ran last is what every command,
|
|
198
|
+
including git, uses. There is no second token and no fallback between them.
|
|
199
|
+
- A token saved by an older CLI in the old API-token slot is moved into the
|
|
200
|
+
saved credential the first time nothing else is saved, and is ignored once a
|
|
201
|
+
login exists. `kody login` deletes it. Old tokens keep working until they
|
|
202
|
+
expire.
|
|
203
|
+
- `kody whoami` prints `credential:` (which one is in use, with its token id)
|
|
204
|
+
and its `scopes:`. With `--json` the same data is under `credential`.
|
|
205
|
+
- `insufficient_scope` errors end with `Credential used: …` and how to widen it.
|
|
206
|
+
|
|
207
|
+
## Narrower scopes
|
|
208
|
+
|
|
209
|
+
Bootstrap saves the same scopes as `kody login` by default. Pass `--scopes` only
|
|
210
|
+
when you want a deliberately narrower credential (the list replaces the
|
|
211
|
+
default):
|
|
224
212
|
|
|
225
213
|
```bash
|
|
226
|
-
# After `kody login` (mints any scope your org role grants):
|
|
227
214
|
npx @kodycodes/cli auth bootstrap --lifetime short \
|
|
228
215
|
--scopes org:execute,org:read,package:execute,package:read,package:write
|
|
229
|
-
|
|
230
|
-
# Agents on MCP without `kody login`: pass scopes when minting the code
|
|
231
|
-
# cliCredentialBootstrap({ lifetime: "short", scopes: ["org:execute", "org:read", "package:execute", "package:read", "package:write"] })
|
|
232
|
-
npx @kodycodes/cli auth bootstrap --code 'kody_bc_…' --lifetime short
|
|
233
216
|
```
|
|
234
217
|
|
|
235
|
-
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
the stored token. A token can only mint scopes it already holds.
|
|
218
|
+
- The CLI passes the list to `cliCredentialBootstrap`. It mints with `--token`
|
|
219
|
+
when given, else `KODY_API_TOKEN`, else the saved credential. A child token
|
|
220
|
+
never exceeds its parent: only scopes the parent holds, never past its expiry.
|
|
239
221
|
- A bootstrap code's scopes are fixed when it is minted, so `--code` with
|
|
240
222
|
`--scopes` is an error that prints the matching `cliCredentialBootstrap` call.
|
|
241
|
-
- `
|
|
242
|
-
|
|
223
|
+
- `git` needs `package:read` and `package:write`, so a narrowed credential
|
|
224
|
+
without them makes `kody auth setup-git` fail with how to fix it.
|
|
243
225
|
|
|
244
226
|
## Git HTTPS (`setup-git`)
|
|
245
227
|
|
|
@@ -248,36 +230,30 @@ Kody provides persistent `kody_at_…` HTTPS git auth (see
|
|
|
248
230
|
helper once:
|
|
249
231
|
|
|
250
232
|
```bash
|
|
251
|
-
kody login #
|
|
233
|
+
kody login # agents on Kody MCP: cliCredentialBootstrap, then its cli_command
|
|
252
234
|
kody auth setup-git
|
|
253
235
|
git clone https://kody.codes/@owner/name.git
|
|
254
236
|
```
|
|
255
237
|
|
|
256
|
-
`setup-git`
|
|
257
|
-
user-owned
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
on the minted token. Configures a **stable** credential helper (global `kody`
|
|
264
|
-
only when that install's version supports `git-credential`, otherwise
|
|
265
|
-
`npx -y @kodycodes/cli@<exact-version> …` — never a major-only `@1` range that
|
|
266
|
-
can reuse a stale npx cache, and never an ephemeral `~/.npm/_npx/…` path).
|
|
267
|
-
Re-running `setup-git` rewrites stale helper entries; every CLI command also
|
|
268
|
-
refreshes an outdated pin silently.
|
|
238
|
+
`setup-git` never mints a token. It checks that the saved CLI credential is
|
|
239
|
+
user-owned and holds `package:read` and `package:write`
|
|
240
|
+
(`GET /v1/tokens/current`), then configures a **stable** credential helper
|
|
241
|
+
(global `kody` only when that install's version supports `git-credential`,
|
|
242
|
+
otherwise `npx -y @kodycodes/cli@<exact-version> …` — never a major-only `@1`
|
|
243
|
+
range or an ephemeral `~/.npm/_npx/…` path). Re-running `setup-git` rewrites
|
|
244
|
+
stale helper entries; every CLI command also refreshes an outdated pin silently.
|
|
269
245
|
|
|
270
246
|
```bash
|
|
271
247
|
git config --global credential.https://kody.codes.helper '!… git-credential'
|
|
272
248
|
git config --global credential.https://kody.codes.useHttpPath true
|
|
273
249
|
```
|
|
274
250
|
|
|
275
|
-
The helper
|
|
276
|
-
|
|
277
|
-
`
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
251
|
+
The helper sends `KODY_API_TOKEN` when set, else the saved credential, and
|
|
252
|
+
refreshes it the same way every other command does. Undo with
|
|
253
|
+
`kody auth remove-git` (clears git config helpers and revokes any token left in
|
|
254
|
+
the old API-token slot; leaves the saved credential alone). Push moves live HEAD
|
|
255
|
+
only (packages do not auto-publish). Existing `kody login` / `auth bootstrap`
|
|
256
|
+
flows are unchanged.
|
|
281
257
|
|
|
282
258
|
## Local package testing (`kody dev`)
|
|
283
259
|
|
|
@@ -602,7 +578,9 @@ CLI credentials are stored in the OS secret store:
|
|
|
602
578
|
|
|
603
579
|
- macOS: Keychain, read and written through Apple's `/usr/bin/security`, so one
|
|
604
580
|
"Always Allow" covers the terminal, `npx`, the background service, and
|
|
605
|
-
Kody.app instead of each node binary asking separately
|
|
581
|
+
Kody.app instead of each node binary asking separately. Calls give up after
|
|
582
|
+
`KODY_KEYCHAIN_TIMEOUT_MS` (2 minutes). Login and other blocking reads cannot
|
|
583
|
+
print while they wait; machine-key reads print a wait notice after 1.5 s.
|
|
606
584
|
- Windows: Credential Manager
|
|
607
585
|
- Linux: Secret Service / libsecret (not the in-memory kernel keyring)
|
|
608
586
|
|
|
@@ -617,8 +595,8 @@ is always printed too, so you can paste it into a browser if no window appears.
|
|
|
617
595
|
|
|
618
596
|
Access tokens refresh automatically on expiry or HTTP 401.
|
|
619
597
|
|
|
620
|
-
`execute --local` prefers `--token` / `KODY_API_TOKEN` when set, then
|
|
621
|
-
|
|
598
|
+
`execute --local` prefers `--token` / `KODY_API_TOKEN` when set, then the one
|
|
599
|
+
saved CLI credential. See
|
|
622
600
|
[Which credential a command uses](#which-credential-a-command-uses).
|
|
623
601
|
|
|
624
602
|
## Execution context daemon performance
|
|
@@ -9,16 +9,16 @@ import {
|
|
|
9
9
|
loginWithDevice,
|
|
10
10
|
refreshStoredCredentials,
|
|
11
11
|
resolvePendingOrgSlug
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-XQQYWLYQ.js";
|
|
13
13
|
import "./chunk-GVSGNTG6.js";
|
|
14
14
|
import "./chunk-CWWHR4FH.js";
|
|
15
15
|
import "./chunk-CASGRYOF.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-B5DIPCOD.js";
|
|
17
|
+
import "./chunk-XRIUHO5Q.js";
|
|
18
|
+
import "./chunk-KMEHILCP.js";
|
|
19
|
+
import "./chunk-22AN66MM.js";
|
|
20
|
+
import "./chunk-ENFBLA4M.js";
|
|
21
|
+
import "./chunk-Z7DR5UNN.js";
|
|
22
22
|
import "./chunk-NKH2L5RA.js";
|
|
23
23
|
import "./chunk-XV646S3B.js";
|
|
24
24
|
import "./chunk-YVWOK4LV.js";
|
|
@@ -34,4 +34,4 @@ export {
|
|
|
34
34
|
refreshStoredCredentials,
|
|
35
35
|
resolvePendingOrgSlug
|
|
36
36
|
};
|
|
37
|
-
//# sourceMappingURL=auth-
|
|
37
|
+
//# sourceMappingURL=auth-I4XH63PZ.js.map
|
package/dist/auth-bootstrap.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
1
|
+
import type { StoredApiToken } from './api-token-store.js';
|
|
2
|
+
import { type SecretBackend, type StoreResolution } from './store.js';
|
|
3
3
|
/** ADR 0056 idle / absolute lifetime caps (seconds). */
|
|
4
4
|
export declare const cliTokenLifetimePolicy: {
|
|
5
5
|
readonly minIdleTtlSeconds: 60;
|
|
@@ -49,9 +49,14 @@ export type BootstrapRedeemResponse = {
|
|
|
49
49
|
expires_at?: string | null;
|
|
50
50
|
max_expires_at?: string | null;
|
|
51
51
|
created_via?: string;
|
|
52
|
+
login_org?: {
|
|
53
|
+
slug: string;
|
|
54
|
+
} | null;
|
|
52
55
|
};
|
|
53
56
|
type BootstrapRedeemRequestBody = {
|
|
54
57
|
code: string;
|
|
58
|
+
} | {
|
|
59
|
+
code: string;
|
|
55
60
|
lifetime: CliTokenLifetimeAlias;
|
|
56
61
|
} | {
|
|
57
62
|
code: string;
|
|
@@ -121,6 +126,7 @@ export declare function authBootstrap(input: {
|
|
|
121
126
|
idleTtlSeconds?: number;
|
|
122
127
|
maxLifetimeSeconds?: number;
|
|
123
128
|
apiUrl?: string;
|
|
129
|
+
mcpUrl?: string;
|
|
124
130
|
fetchFn?: typeof fetch;
|
|
125
131
|
backend?: SecretBackend;
|
|
126
132
|
resolution?: StoreResolution;
|
|
@@ -148,6 +154,7 @@ export declare function authBootstrapWithScopes(input: {
|
|
|
148
154
|
lifetime: ResolvedCliTokenLifetime;
|
|
149
155
|
mint: (params: Record<string, unknown>) => Promise<unknown>;
|
|
150
156
|
apiUrl?: string;
|
|
157
|
+
mcpUrl?: string;
|
|
151
158
|
fetchFn?: typeof fetch;
|
|
152
159
|
backend?: SecretBackend;
|
|
153
160
|
resolution?: StoreResolution;
|
package/dist/bin.js
CHANGED
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
runCli
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-V3KIBQVH.js";
|
|
6
6
|
import "./chunk-E4R3Y6MM.js";
|
|
7
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-4QDPGKUS.js";
|
|
8
8
|
import "./chunk-46IJPEID.js";
|
|
9
9
|
import "./chunk-NKQRWYSY.js";
|
|
10
10
|
import "./chunk-MIT3TUWB.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-LGG77FR7.js";
|
|
12
|
+
import "./chunk-7UV4RVJW.js";
|
|
13
|
+
import "./chunk-HBHIQDJI.js";
|
|
14
14
|
import "./chunk-6ZYUGXVW.js";
|
|
15
15
|
import "./chunk-CWWHR4FH.js";
|
|
16
16
|
import "./chunk-CASGRYOF.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-B5DIPCOD.js";
|
|
18
|
+
import "./chunk-XRIUHO5Q.js";
|
|
19
|
+
import "./chunk-KMEHILCP.js";
|
|
20
|
+
import "./chunk-22AN66MM.js";
|
|
21
|
+
import "./chunk-ENFBLA4M.js";
|
|
22
|
+
import "./chunk-Z7DR5UNN.js";
|
|
23
23
|
import "./chunk-NKH2L5RA.js";
|
|
24
24
|
import "./chunk-XV646S3B.js";
|
|
25
25
|
import "./chunk-YVWOK4LV.js";
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
deleteStoredApiToken,
|
|
4
|
+
loadStoredApiToken
|
|
5
|
+
} from "./chunk-ENFBLA4M.js";
|
|
6
|
+
import {
|
|
7
|
+
loadCredentials,
|
|
8
|
+
saveCredentials
|
|
9
|
+
} from "./chunk-Z7DR5UNN.js";
|
|
10
|
+
import {
|
|
11
|
+
apiTokenEnvVar,
|
|
12
|
+
defaultApiUrl,
|
|
13
|
+
defaultMcpUrl
|
|
14
|
+
} from "./chunk-NKH2L5RA.js";
|
|
15
|
+
|
|
16
|
+
// src/cli-credential.ts
|
|
17
|
+
var precedence = [
|
|
18
|
+
"token-flag",
|
|
19
|
+
"env",
|
|
20
|
+
"login"
|
|
21
|
+
];
|
|
22
|
+
function loadCandidate(source, input) {
|
|
23
|
+
try {
|
|
24
|
+
if (source === "token-flag") {
|
|
25
|
+
const flag = input.tokenValues?.token?.trim();
|
|
26
|
+
return { candidate: flag ? { source, token: flag } : null };
|
|
27
|
+
}
|
|
28
|
+
if (source === "env") {
|
|
29
|
+
const value = (input.env ?? process.env)[apiTokenEnvVar]?.trim();
|
|
30
|
+
return { candidate: value ? { source, token: value } : null };
|
|
31
|
+
}
|
|
32
|
+
const mcpUrl = input.mcpUrl || defaultMcpUrl;
|
|
33
|
+
const login = input.loadLogin ? input.loadLogin(mcpUrl, input.org) : loadCredentials(mcpUrl, input.loginBackend, void 0, {
|
|
34
|
+
org: input.org
|
|
35
|
+
});
|
|
36
|
+
const desktop = (input.env ?? process.env).KODY_CREDENTIAL_SOURCE === "login";
|
|
37
|
+
const saved = login ?? (desktop || input.org ? null : adoptLegacyStoredApiToken(input, mcpUrl));
|
|
38
|
+
return { candidate: saved ? { source, token: null, login: saved } : null };
|
|
39
|
+
} catch (error) {
|
|
40
|
+
return { candidate: null, error };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function adoptLegacyStoredApiToken(input, mcpUrl) {
|
|
44
|
+
const apiUrl = input.apiUrl || defaultApiUrl;
|
|
45
|
+
const legacy = (input.loadApiToken ?? loadStoredApiToken)(
|
|
46
|
+
apiUrl,
|
|
47
|
+
input.apiTokenBackend,
|
|
48
|
+
input.apiTokenResolution
|
|
49
|
+
);
|
|
50
|
+
if (!legacy) return null;
|
|
51
|
+
const adopted = storedCredentialsFromApiToken({
|
|
52
|
+
mcpUrl,
|
|
53
|
+
token: legacy.token,
|
|
54
|
+
expiresAt: legacy.expiresAt ? Date.parse(legacy.expiresAt) : void 0,
|
|
55
|
+
scopes: legacy.scopes ?? [],
|
|
56
|
+
apiUrl
|
|
57
|
+
});
|
|
58
|
+
try {
|
|
59
|
+
;
|
|
60
|
+
(input.saveLogin ?? saveCredentials)(adopted, input.loginBackend);
|
|
61
|
+
(input.deleteApiToken ?? deleteStoredApiToken)(
|
|
62
|
+
apiUrl,
|
|
63
|
+
input.apiTokenBackend,
|
|
64
|
+
input.apiTokenResolution
|
|
65
|
+
);
|
|
66
|
+
} catch {
|
|
67
|
+
}
|
|
68
|
+
return adopted;
|
|
69
|
+
}
|
|
70
|
+
function storedCredentialsFromApiToken(input) {
|
|
71
|
+
const issuer = new URL(input.mcpUrl).origin;
|
|
72
|
+
return {
|
|
73
|
+
version: 1,
|
|
74
|
+
mcpUrl: input.mcpUrl,
|
|
75
|
+
...input.org ? { org: input.org } : {},
|
|
76
|
+
resource: input.mcpUrl,
|
|
77
|
+
authorizationServerUrl: issuer,
|
|
78
|
+
clientId: new URL("/oauth/cli-client-metadata.json", issuer).href,
|
|
79
|
+
accessToken: input.token,
|
|
80
|
+
tokenType: "bearer",
|
|
81
|
+
...input.expiresAt !== void 0 && Number.isFinite(input.expiresAt) ? { expiresAt: input.expiresAt } : {},
|
|
82
|
+
scope: input.scopes.join(" "),
|
|
83
|
+
...input.apiUrl ? { apiUrl: new URL(input.apiUrl).origin } : {}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
var activeCredential = null;
|
|
87
|
+
function resolveCliCredential(input = {}) {
|
|
88
|
+
const purpose = input.purpose ?? "call";
|
|
89
|
+
const source = (input.env ?? process.env).KODY_CREDENTIAL_SOURCE;
|
|
90
|
+
if (source && source !== "login")
|
|
91
|
+
throw new Error("KODY_CREDENTIAL_SOURCE must be login when set.");
|
|
92
|
+
let picked = null;
|
|
93
|
+
const shadowed = [];
|
|
94
|
+
for (const candidateSource of source === "login" ? ["login"] : precedence) {
|
|
95
|
+
const loaded = loadCandidate(candidateSource, input);
|
|
96
|
+
if (loaded.error !== void 0 && !picked) throw loaded.error;
|
|
97
|
+
if (!loaded.candidate) continue;
|
|
98
|
+
if (picked) shadowed.push(loaded.candidate);
|
|
99
|
+
else picked = loaded.candidate;
|
|
100
|
+
}
|
|
101
|
+
if (!picked) return null;
|
|
102
|
+
const credential = { ...picked, purpose, shadowed };
|
|
103
|
+
activeCredential = credential;
|
|
104
|
+
return credential;
|
|
105
|
+
}
|
|
106
|
+
function activeCliCredential() {
|
|
107
|
+
return activeCredential;
|
|
108
|
+
}
|
|
109
|
+
function resetActiveCliCredential() {
|
|
110
|
+
activeCredential = null;
|
|
111
|
+
}
|
|
112
|
+
function noteActiveLoginCredential(input) {
|
|
113
|
+
if (activeCredential?.source === "login") {
|
|
114
|
+
activeCredential = { ...activeCredential, login: input.login };
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
activeCredential = {
|
|
118
|
+
source: "login",
|
|
119
|
+
token: null,
|
|
120
|
+
login: input.login,
|
|
121
|
+
purpose: input.purpose ?? "call",
|
|
122
|
+
shadowed: []
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function describeCliCredential(candidate) {
|
|
126
|
+
switch (candidate.source) {
|
|
127
|
+
case "token-flag":
|
|
128
|
+
return "--token";
|
|
129
|
+
case "env":
|
|
130
|
+
return apiTokenEnvVar;
|
|
131
|
+
case "login":
|
|
132
|
+
return candidate.login?.org ? `saved CLI credential (org ${candidate.login.org})` : "saved CLI credential";
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
var callPurposeCommands = "api, package, execute --local, context, daemon, dev, search, cloud execute, and git";
|
|
136
|
+
var sessionPurposeCommands = callPurposeCommands;
|
|
137
|
+
var resignInHint = "Run `kody login` (agents on Kody MCP: call cliCredentialBootstrap with no scopes and run the returned cli_command) to save a credential with every scope your org role allows.";
|
|
138
|
+
function credentialUsedNote(input) {
|
|
139
|
+
const { credential } = input;
|
|
140
|
+
if (!credential) return null;
|
|
141
|
+
const used = `Credential used: ${describeCliCredential(credential)}.`;
|
|
142
|
+
if (credential.source === "env" || credential.source === "token-flag") {
|
|
143
|
+
return `${used} It wins over the saved CLI credential; mint a token with the missing scope (tokenCreate) and update ${credential.source === "env" ? apiTokenEnvVar : "--token"}, or unset it to use the saved credential.`;
|
|
144
|
+
}
|
|
145
|
+
return `${used} Your org role must grant the scope. If this credential was minted with a narrower --scopes list, ${resignInHint}`;
|
|
146
|
+
}
|
|
147
|
+
function credentialRejectedNote(input) {
|
|
148
|
+
const { credential } = input;
|
|
149
|
+
if (!credential) return null;
|
|
150
|
+
const used = `Credential used: ${describeCliCredential(credential)}.`;
|
|
151
|
+
if (credential.source === "token-flag" || credential.source === "env") {
|
|
152
|
+
const name = credential.source === "env" ? apiTokenEnvVar : "--token";
|
|
153
|
+
return `${used} ${name} wins over the saved CLI credential; unset or replace ${name} before retrying, or mint a fresh token (agents: cliCredentialBootstrap then run the returned cli_command; CI: tokenCreate) and update that value. Humans: \`kody login\` saves a fresh credential.`;
|
|
154
|
+
}
|
|
155
|
+
return `${used} ${resignInHint}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export {
|
|
159
|
+
storedCredentialsFromApiToken,
|
|
160
|
+
resolveCliCredential,
|
|
161
|
+
activeCliCredential,
|
|
162
|
+
resetActiveCliCredential,
|
|
163
|
+
noteActiveLoginCredential,
|
|
164
|
+
describeCliCredential,
|
|
165
|
+
callPurposeCommands,
|
|
166
|
+
sessionPurposeCommands,
|
|
167
|
+
credentialUsedNote,
|
|
168
|
+
credentialRejectedNote
|
|
169
|
+
};
|
|
170
|
+
//# sourceMappingURL=chunk-22AN66MM.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/cli-credential.ts"],
|
|
4
|
+
"mappings": ";;;;;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I,WAAW,WAAW,gBAAgB,WAAW,WAAW,OAAO;AACtE,UAAM,OAAO,WAAW,WAAW,QAAQ,iBAAiB;AAC5D,WAAO,GAAG,IAAI,IAAI,IAAI,yDAAyD,IAAI;AAAA,EACpF;AACA,SAAO,GAAG,IAAI,IAAI,YAAY;AAC/B;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
expectedPairedApiOrigin,
|
|
4
4
|
isPairedApiUrl,
|
|
5
5
|
notAuthenticatedMessage
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-KMEHILCP.js";
|
|
7
7
|
import {
|
|
8
8
|
noteActiveLoginCredential,
|
|
9
9
|
resolveCliCredential
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-22AN66MM.js";
|
|
11
11
|
import {
|
|
12
12
|
defaultApiUrl,
|
|
13
13
|
defaultMcpUrl
|
|
@@ -36,14 +36,19 @@ async function resolveLocalExecuteBearer(input) {
|
|
|
36
36
|
if (credential?.token) return credential.token;
|
|
37
37
|
const apiUrl = input.apiUrl ?? defaultApiUrl;
|
|
38
38
|
const mcpUrl = input.mcpUrl ?? defaultMcpUrl;
|
|
39
|
-
|
|
39
|
+
const saved = credential?.login;
|
|
40
|
+
const savedForThisApi = saved?.apiUrl !== void 0 && saved.apiUrl === urlOriginOrValue(apiUrl);
|
|
41
|
+
if (saved && savedForThisApi && saved.accessToken.startsWith("kody_at_") && (saved.expiresAt === void 0 || saved.expiresAt > (input.now ?? Date.now()) + 6e4)) {
|
|
42
|
+
return saved.accessToken;
|
|
43
|
+
}
|
|
44
|
+
if (!savedForThisApi && !isPairedApiUrl(apiUrl, mcpUrl)) {
|
|
40
45
|
const apiOrigin = urlOriginOrValue(apiUrl);
|
|
41
46
|
const mcpOrigin = urlOriginOrValue(mcpUrl);
|
|
42
47
|
throw new Error(
|
|
43
48
|
`kody login credentials for ${mcpOrigin} are only sent to ${expectedPairedApiOrigin(mcpUrl)}. For ${apiOrigin}, run \`kody auth bootstrap --code \u2026 --api-url ${apiOrigin}\` or set KODY_API_TOKEN.`
|
|
44
49
|
);
|
|
45
50
|
}
|
|
46
|
-
const ensure = input.ensureCredentials ?? (await import("./auth-
|
|
51
|
+
const ensure = input.ensureCredentials ?? (await import("./auth-I4XH63PZ.js")).ensureFreshCredentials;
|
|
47
52
|
try {
|
|
48
53
|
const credentials = await ensure({
|
|
49
54
|
mcpUrl: input.mcpUrl,
|
|
@@ -65,4 +70,4 @@ async function resolveLocalExecuteBearer(input) {
|
|
|
65
70
|
export {
|
|
66
71
|
resolveLocalExecuteBearer
|
|
67
72
|
};
|
|
68
|
-
//# sourceMappingURL=chunk-
|
|
73
|
+
//# sourceMappingURL=chunk-4QDPGKUS.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/local-execute-auth.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;AAcA,SAAS,iBAAiB,OAAuB;AAChD,MAAI;AACH,WAAO,IAAI,IAAI,KAAK,EAAE;AAAA,EACvB,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAaA,eAAsB,0BACrB,OAUkB;AAClB,QAAM,aAAa,qBAAqB;AAAA,IACvC,aAAa,MAAM;AAAA,IACnB,KAAK,MAAM;AAAA,IACX,QAAQ,MAAM;AAAA,IACd,QAAQ,MAAM;AAAA,IACd,GAAI,MAAM,MAAM,EAAE,KAAK,MAAM,IAAI,IAAI,CAAC;AAAA,IACtC,GAAI,MAAM,eAAe,EAAE,cAAc,MAAM,aAAa,IAAI,CAAC;AAAA,IACjE,GAAI,MAAM,kBACP,EAAE,iBAAiB,MAAM,gBAAgB,IACzC,CAAC;AAAA,IACJ,GAAI,MAAM,qBACP,EAAE,oBAAoB,MAAM,mBAAmB,IAC/C,CAAC;AAAA,IACJ,GAAI,MAAM,UAAU,EAAE,cAAc,MAAM,QAAQ,IAAI,CAAC;AAAA,EACxD,CAAC;AACD,MAAI,YAAY,MAAO,QAAO,WAAW;AAEzC,QAAM,SAAS,MAAM,UAAU;AAC/B,QAAM,SAAS,MAAM,UAAU;AAC/B,QAAM,QAAQ,YAAY;AAC1B,QAAM,kBACL,OAAO,WAAW,UAAa,MAAM,WAAW,iBAAiB,MAAM;AACxE,MACC,SACA,mBACA,MAAM,YAAY,WAAW,UAAU,MACtC,MAAM,cAAc,UACpB,MAAM,aAAa,MAAM,OAAO,KAAK,IAAI,KAAK,MAC9C;AACD,WAAO,MAAM;AAAA,EACd;AACA,MAAI,CAAC,mBAAmB,CAAC,eAAe,QAAQ,MAAM,GAAG;AACxD,UAAM,YAAY,iBAAiB,MAAM;AACzC,UAAM,YAAY,iBAAiB,MAAM;AACzC,UAAM,IAAI;AAAA,MACT,8BAA8B,SAAS,qBAAqB,wBAAwB,MAAM,CAAC,SAAS,SAAS,uDAAkD,SAAS;AAAA,IACzK;AAAA,EACD;AAEA,QAAM,SACL,MAAM,sBACL,MAAM,OAAO,oBAAW,GAAG;AAC7B,MAAI;AACH,UAAM,cAAc,MAAM,OAAO;AAAA,MAChC,QAAQ,MAAM;AAAA,MACd,KAAK,MAAM;AAAA,MACX,SAAS,MAAM;AAAA,MACf,SAAS,MAAM;AAAA,MACf,KAAK,MAAM;AAAA,IACZ,CAAC;AACD,8BAA0B,EAAE,OAAO,YAAY,CAAC;AAChD,WAAO,YAAY;AAAA,EACpB,SAAS,OAAO;AAEf,QACC,iBAAiB,SACjB,MAAM,QAAQ,WAAW,2BAA2B,GACnD;AACD,YAAM;AAAA,IACP;AACA,UAAM,IAAI,MAAM,wBAAwB,MAAM,WAAW,iBAAiB,CAAC;AAAA,EAC5E;AACD;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -2,17 +2,17 @@ import { createRequire as __createRequire } from 'node:module'; const require =
|
|
|
2
2
|
import {
|
|
3
3
|
bundleLocalUserModule
|
|
4
4
|
} from "./chunk-MAIWMWV7.js";
|
|
5
|
-
import {
|
|
6
|
-
loadPackageManifest,
|
|
7
|
-
resolveExportModulePath
|
|
8
|
-
} from "./chunk-EMEUJKXR.js";
|
|
9
5
|
import {
|
|
10
6
|
LocalPackageGraphError,
|
|
11
7
|
absolutizeWorkerdPackageImports,
|
|
12
8
|
hasLiteralDynamicSavedPackageImports,
|
|
13
9
|
listSavedPackageImports,
|
|
14
10
|
rewriteBareKodyBuiltinImports
|
|
15
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-B4OOCRLZ.js";
|
|
12
|
+
import {
|
|
13
|
+
loadPackageManifest,
|
|
14
|
+
resolveExportModulePath
|
|
15
|
+
} from "./chunk-EMEUJKXR.js";
|
|
16
16
|
|
|
17
17
|
// src/mock-local-deps.ts
|
|
18
18
|
import { access, readFile } from "node:fs/promises";
|
|
@@ -193,4 +193,4 @@ export {
|
|
|
193
193
|
mergePackageGraphs,
|
|
194
194
|
tryLoadSelfManifest
|
|
195
195
|
};
|
|
196
|
-
//# sourceMappingURL=chunk-
|
|
196
|
+
//# sourceMappingURL=chunk-5BNIKSOV.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
cliConfigDir
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-Z7DR5UNN.js";
|
|
5
5
|
|
|
6
6
|
// src/execution-context/fs-access.ts
|
|
7
7
|
import {
|
|
@@ -461,4 +461,4 @@ export {
|
|
|
461
461
|
resolveHostPath,
|
|
462
462
|
fsFeatures
|
|
463
463
|
};
|
|
464
|
-
//# sourceMappingURL=chunk-
|
|
464
|
+
//# sourceMappingURL=chunk-7UV4RVJW.js.map
|