@nyte-ai/host 0.0.18 → 0.0.21
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/THIRD-PARTY-NOTICES.md +66 -0
- package/dist/chunks/{canvas-preview-rp6fz0w5.js → canvas-preview-2jwbe14k.js} +5 -5
- package/dist/chunks/{canvas-preview-j1tnf51w.js → canvas-preview-3a6tst4d.js} +1 -1
- package/dist/chunks/{canvas-preview-m02v4yy6.js → canvas-preview-55s0y68g.js} +3 -2
- package/dist/chunks/{canvas-preview-xn10d4f8.js → canvas-preview-5ekjx6sw.js} +9 -4
- package/dist/chunks/{canvas-preview-g3qj3y3k.js → canvas-preview-8hr08aeh.js} +13 -3
- package/dist/chunks/{canvas-preview-75db60xy.js → canvas-preview-8xc0vn7v.js} +5 -4
- package/dist/chunks/{canvas-preview-zn2d0k9d.js → canvas-preview-af86jz8t.js} +14 -6
- package/dist/chunks/{canvas-preview-d9wwhbtz.js → canvas-preview-aq5j4p25.js} +1 -1
- package/dist/chunks/{canvas-preview-ewgspmsd.js → canvas-preview-b3r1tna2.js} +1 -1
- package/dist/chunks/canvas-preview-befkjea2.js +60 -0
- package/dist/chunks/canvas-preview-bxnqt8cd.js +103 -0
- package/dist/chunks/{canvas-preview-senpjwep.js → canvas-preview-crmzxxt8.js} +3 -3
- package/dist/chunks/{canvas-preview-ymgz0937.js → canvas-preview-drctegz4.js} +8 -4
- package/dist/chunks/{canvas-preview-yrfz2ak6.js → canvas-preview-e3vnkkc5.js} +6 -6
- package/dist/chunks/canvas-preview-ec2mt7es.js +108 -0
- package/dist/chunks/{canvas-preview-0nrnbt76.js → canvas-preview-eehzfefa.js} +199 -125
- package/dist/chunks/{canvas-preview-5hxat7hh.js → canvas-preview-geg2gckp.js} +8 -6
- package/dist/chunks/{canvas-preview-8xgt67ka.js → canvas-preview-gh7c9831.js} +20 -16
- package/dist/chunks/{canvas-preview-1ta3avah.js → canvas-preview-k2xaz0ym.js} +10 -5
- package/dist/chunks/canvas-preview-kp75gb63.js +141 -0
- package/dist/chunks/{canvas-preview-evh92ywd.js → canvas-preview-mstbvwz3.js} +26 -11
- package/dist/chunks/{canvas-preview-h8hshnff.js → canvas-preview-pkzqg96v.js} +1 -1
- package/dist/chunks/{canvas-preview-ehf3vp31.js → canvas-preview-vm9zdp2t.js} +45 -58
- package/dist/chunks/{canvas-preview-76fwvd6e.js → canvas-preview-w54ymtb3.js} +1 -1
- package/dist/chunks/canvas-preview-y5y6ghaw.js +125 -0
- package/dist/chunks/{canvas-preview-vax9ne4e.js → canvas-preview-y7kq0c8q.js} +22 -11
- package/dist/chunks/{canvas-preview-98aj5p34.js → canvas-preview-ycepb05s.js} +1 -1
- package/dist/src/canvas-preview.js +7 -3
- package/dist/src/deploy/cloudflare/worker.js +1 -1
- package/dist/src/deploy/vercel/server/routes/[...].js +2 -2
- package/dist/src/deploy/vercel/server/utils/host.js +1 -1
- package/dist/src/deploy/vercel/server/workflows/drive.js +3 -3
- package/dist/src/images/exif.d.ts +1 -0
- package/dist/src/images/exif.js +6 -0
- package/dist/src/images/node.d.ts +37 -0
- package/dist/src/images/node.js +12 -0
- package/dist/src/images/photon.d.ts +3 -0
- package/dist/src/images/photon.js +7 -0
- package/dist/src/images/worker.d.ts +1 -0
- package/dist/src/images/worker.js +23 -0
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +23 -22
- package/dist/src/listen-fetch.js +3 -3
- package/dist/src/listen.js +4 -4
- package/dist/src/local/command.d.ts +5 -0
- package/dist/src/local/command.js +6 -2
- package/dist/src/local/files.js +2 -2
- package/dist/src/local/git-watch.d.ts +1 -1
- package/dist/src/local/git-watch.js +1 -1
- package/dist/src/local/git.js +3 -3
- package/dist/src/local/github.js +2 -2
- package/dist/src/local/jobs.d.ts +1 -1
- package/dist/src/local/jobs.js +2 -1
- package/dist/src/local/provider.js +9 -9
- package/dist/src/local/snapshots.js +2 -2
- package/dist/src/local/worktrees.js +2 -2
- package/dist/src/mcp/connect.d.ts +0 -13
- package/dist/src/mcp/connect.js +1 -1
- package/dist/src/mcp/hub.js +2 -2
- package/dist/src/open.d.ts +2 -30
- package/dist/src/open.js +20 -18
- package/dist/src/serve/binding.js +1 -1
- package/dist/src/serve/handler.js +2 -2
- package/dist/src/sqlite.d.ts +2 -1
- package/dist/src/sqlite.js +4 -3
- package/dist/src/store-usage.js +4 -1
- package/dist/src/usage-history.d.ts +54 -0
- package/dist/src/usage-history.js +14 -0
- package/dist/src/usage-service.d.ts +2 -1
- package/dist/src/usage-service.js +7 -3
- package/dist/src/usage-worker.js +8 -4
- package/dist/src/usage.d.ts +150 -27
- package/dist/src/usage.js +12 -2
- package/package.json +16 -8
- package/src/canvas-preview.ts +4 -3
- package/src/images/exif.ts +69 -0
- package/src/images/node.ts +163 -0
- package/src/images/photon.ts +141 -0
- package/src/images/worker.ts +29 -0
- package/src/index.ts +19 -1
- package/src/local/command.ts +64 -12
- package/src/local/files.ts +8 -3
- package/src/local/git-watch.ts +16 -6
- package/src/local/git.ts +7 -2
- package/src/local/github.ts +3 -4
- package/src/local/jobs.ts +55 -69
- package/src/local/snapshots.ts +4 -2
- package/src/local/worktrees.ts +4 -4
- package/src/mcp/connect.ts +1 -14
- package/src/mcp/hub.ts +18 -9
- package/src/open.ts +16 -36
- package/src/serve/binding.ts +4 -3
- package/src/sqlite.ts +46 -9
- package/src/store-usage.ts +5 -2
- package/src/usage-history.ts +219 -0
- package/src/usage-service.ts +12 -3
- package/src/usage.ts +251 -176
- package/dist/chunks/canvas-preview-a3yw0j70.js +0 -72
- package/dist/chunks/canvas-preview-azg56359.js +0 -68
- package/dist/src/store-owner.d.ts +0 -15
- package/dist/src/store-owner.js +0 -9
- package/src/store-owner.ts +0 -98
package/dist/src/local/jobs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExecutionEnv } from "@nyte-ai/core";
|
|
2
|
-
/** Returns `exec` for a folder: each call starts one process as a `Job` (a fresh id; `key` null, core keys pty jobs) in `cwd` resolved against `root` (default `root`), with `env` laid over `process.env`. A string command runs through the platform shell (`/bin/sh -c`, `cmd.exe /d /s /c` on Windows) and an argv directly; `[]` with `pty` runs the login shell (`shell()` read at each start, else `$SHELL`, else `/bin/sh`, as a login shell; §37h), a pty's environment carrying `TERM=xterm-256color`, `COLORTERM=truecolor` and `TERM_PROGRAM=Nyte` without Electron's `ELECTRON_RUN_AS_NODE` and `NODE_OPTIONS`, and `[]` without one throws `SdkError("invalid")`. A program that cannot start throws `SdkError("unavailable")`. Without `pty` the process is piped through `node:child_process` in its own process group, stdout and stderr interleaved in `output` (with `stdio: "protocol"`, stderr's frames tagged `stream: "stderr"` and the pipe paced like a pty, so a reader open from the start misses nothing) and stdin fed by `write`; with `pty` it runs under `@lydell/node-pty`, loaded on first use through `createRequire` (§41a; `loadPty`, given, loads it instead, on every pty start), at the given size, and a platform where it does not load throws `SdkError("unavailable")`. `output()` opens a reader over the last 1 MiB of output that yields `bytes`, a `gap` where the reader fell behind or opened after output was dropped, and `exit { code }` last; a merged pipe never stalls, and a pty or a protocol pipe pauses while its slowest open reader is 256 KiB behind, resuming once it is within 64 KiB. `resize` resizes a pty (`not-pty` for a pipe, `missing` once it ended); `idle`
|
|
2
|
+
/** Returns `exec` for a folder: each call starts one process as a `Job` (a fresh id; `key` null, core keys pty jobs) in `cwd` resolved against `root` (default `root`), with `env` laid over `process.env`. A string command runs through the platform shell (`/bin/sh -c`, `cmd.exe /d /s /c` on Windows) and an argv directly; `[]` with `pty` runs the login shell (`shell()` read at each start, else `$SHELL`, else `/bin/sh`, as a login shell; §37h), a pty's environment carrying `TERM=xterm-256color`, `COLORTERM=truecolor` and `TERM_PROGRAM=Nyte` without Electron's `ELECTRON_RUN_AS_NODE` and `NODE_OPTIONS`, and `[]` without one throws `SdkError("invalid")`. A program that cannot start throws `SdkError("unavailable")`. Without `pty` the process is piped through `node:child_process` in its own process group, stdout and stderr interleaved in `output` (with `stdio: "protocol"`, stderr's frames tagged `stream: "stderr"` and the pipe paced like a pty, so a reader open from the start misses nothing) and stdin fed by `write`; with `pty` it runs under `@lydell/node-pty`, loaded on first use through `createRequire` (§41a; `loadPty`, given, loads it instead, on every pty start), at the given size, and a platform where it does not load throws `SdkError("unavailable")`. `output()` opens a reader over the last 1 MiB of output that yields `bytes`, a `gap` where the reader fell behind or opened after output was dropped, and `exit { code }` last; a merged pipe never stalls, and a pty or a protocol pipe pauses while its slowest open reader is 256 KiB behind, resuming once it is within 64 KiB. `resize` resizes a pty (`not-pty` for a pipe, `missing` once it ended); `idle` checks the OS process table for a login shell with no live children (false for a pipe or explicit command, true once it ended); `stop` sends SIGTERM to a pipe's process group (SIGHUP to a pty), SIGKILL after 2 s (on Windows, which has no signals, it ends a pipe's process tree at once with `taskkill /T /F`), and answers `settled { outcome }` (also once it ended); `settled` resolves `exited { code, reason }` (`code` null after a signal), `reason` `exited` when the process ended on its own and `terminated` after `stop` or an aborted `signal`, and an aborted `settled` signal rejects with `SdkError("unavailable")`; `close` detaches this handle's readers. An aborted `signal` stops the process. `signal` on the options ends every reader of every job started here, leaving the processes running (what the provider's `close` does). */
|
|
3
3
|
export declare function localExec(root: string, options?: {
|
|
4
4
|
readonly shell?: () => string | null;
|
|
5
5
|
readonly signal?: AbortSignal;
|
package/dist/src/local/jobs.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
localProvider2
|
|
3
|
-
} from "../../chunks/canvas-preview-
|
|
4
|
-
import"../../chunks/canvas-preview-
|
|
5
|
-
import"../../chunks/canvas-preview-
|
|
6
|
-
import"../../chunks/canvas-preview-
|
|
3
|
+
} from "../../chunks/canvas-preview-e3vnkkc5.js";
|
|
4
|
+
import"../../chunks/canvas-preview-2jwbe14k.js";
|
|
5
|
+
import"../../chunks/canvas-preview-5ekjx6sw.js";
|
|
6
|
+
import"../../chunks/canvas-preview-8xc0vn7v.js";
|
|
7
7
|
import"../../chunks/canvas-preview-1sq7z9jq.js";
|
|
8
|
-
import"../../chunks/canvas-preview-
|
|
9
|
-
import"../../chunks/canvas-preview-
|
|
8
|
+
import"../../chunks/canvas-preview-vm9zdp2t.js";
|
|
9
|
+
import"../../chunks/canvas-preview-crmzxxt8.js";
|
|
10
10
|
import"../../chunks/canvas-preview-tjhabynd.js";
|
|
11
|
-
import"../../chunks/canvas-preview-
|
|
11
|
+
import"../../chunks/canvas-preview-drctegz4.js";
|
|
12
12
|
import"../../chunks/canvas-preview-kn7kvbfj.js";
|
|
13
|
-
import"../../chunks/canvas-preview-azg56359.js";
|
|
14
13
|
import"../../chunks/canvas-preview-yjz0f7n4.js";
|
|
15
|
-
import"../../chunks/canvas-preview-
|
|
14
|
+
import"../../chunks/canvas-preview-af86jz8t.js";
|
|
15
|
+
import"../../chunks/canvas-preview-bxnqt8cd.js";
|
|
16
16
|
import"../../chunks/canvas-preview-0nq75h9k.js";
|
|
17
17
|
import"../../chunks/canvas-preview-mgcx2b2p.js";
|
|
18
18
|
export {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
localSnapshots2
|
|
3
|
-
} from "../../chunks/canvas-preview-
|
|
3
|
+
} from "../../chunks/canvas-preview-crmzxxt8.js";
|
|
4
4
|
import"../../chunks/canvas-preview-tjhabynd.js";
|
|
5
5
|
import"../../chunks/canvas-preview-kn7kvbfj.js";
|
|
6
|
-
import"../../chunks/canvas-preview-
|
|
6
|
+
import"../../chunks/canvas-preview-bxnqt8cd.js";
|
|
7
7
|
import"../../chunks/canvas-preview-0nq75h9k.js";
|
|
8
8
|
import"../../chunks/canvas-preview-mgcx2b2p.js";
|
|
9
9
|
export {
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
addWorktree2,
|
|
4
4
|
hasBranch2,
|
|
5
5
|
localWorktrees2
|
|
6
|
-
} from "../../chunks/canvas-preview-
|
|
7
|
-
import"../../chunks/canvas-preview-
|
|
6
|
+
} from "../../chunks/canvas-preview-2jwbe14k.js";
|
|
7
|
+
import"../../chunks/canvas-preview-bxnqt8cd.js";
|
|
8
8
|
import"../../chunks/canvas-preview-0nq75h9k.js";
|
|
9
9
|
export {
|
|
10
10
|
addWorktree2 as addWorktree,
|
|
@@ -5,24 +5,11 @@ import type { McpWorkspace } from "@nyte-ai/core/server";
|
|
|
5
5
|
import type { McpOAuthConfig } from "@nyte-ai/schema";
|
|
6
6
|
import type { McpServerEntry } from "./config.ts";
|
|
7
7
|
import type { McpOAuthSettings } from "./oauth.ts";
|
|
8
|
-
/**
|
|
9
|
-
* Opens the transport to one server for one workspace. A url server that
|
|
10
|
-
* needs OAuth sends its stored tokens; when it needs a new sign-in the
|
|
11
|
-
* connection fails with `McpOAuthAuthorizationRequiredError`, after passing
|
|
12
|
-
* the server's challenge to `challenged`. Throws when the entry cannot be
|
|
13
|
-
* started, such as a missing `${VAR}`.
|
|
14
|
-
*/
|
|
15
8
|
export type McpConnector = (entry: McpServerEntry, context: {
|
|
16
9
|
readonly workspace: McpWorkspace;
|
|
17
10
|
readonly home: string;
|
|
18
11
|
readonly secrets: PluginStorage["secrets"];
|
|
19
12
|
readonly challenged: (challenge: OAuthChallenge) => void;
|
|
20
13
|
}) => McpTransport;
|
|
21
|
-
/**
|
|
22
|
-
* Runs stdio servers on this machine, in `cwd` resolved against the
|
|
23
|
-
* workspace folder, and connects to url servers over streamable HTTP. A url
|
|
24
|
-
* server without an `Authorization` header signs in with OAuth.
|
|
25
|
-
*/
|
|
26
14
|
export declare const connectServer: McpConnector;
|
|
27
|
-
/** A server's OAuth options with `${VAR}`s in `clientSecret` resolved. */
|
|
28
15
|
export declare function oauthSettings(config: McpOAuthConfig, server: string): McpOAuthSettings;
|
package/dist/src/mcp/connect.js
CHANGED
package/dist/src/mcp/hub.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMcpHub2
|
|
3
|
-
} from "../../chunks/canvas-preview-
|
|
4
|
-
import"../../chunks/canvas-preview-
|
|
3
|
+
} from "../../chunks/canvas-preview-gh7c9831.js";
|
|
4
|
+
import"../../chunks/canvas-preview-pkzqg96v.js";
|
|
5
5
|
import"../../chunks/canvas-preview-5z63am63.js";
|
|
6
6
|
import"../../chunks/canvas-preview-vaatfznm.js";
|
|
7
7
|
import"../../chunks/canvas-preview-kdqgrstc.js";
|
package/dist/src/open.d.ts
CHANGED
|
@@ -1,42 +1,14 @@
|
|
|
1
1
|
import type { Models } from "@nyte-ai/ai";
|
|
2
2
|
import type { WorkspaceTarget } from "@nyte-ai/schema";
|
|
3
3
|
import type { Host, OpenOptions, Plugin, Store } from "@nyte-ai/core";
|
|
4
|
-
/**
|
|
5
|
-
* Describes what `openHost` takes: `OpenOptions` with `store`, `workspace`,
|
|
6
|
-
* `models` and `plugins` optional, `secrets` defaulting to this machine's key,
|
|
7
|
-
* and the home directory holding `.nyte`. Every `OpenOptions` is one, so the
|
|
8
|
-
* sdk's Node `open` passes its options straight through.
|
|
9
|
-
*/
|
|
10
4
|
export type OpenHostOptions = Omit<OpenOptions, "store" | "workspace" | "models" | "plugins"> & {
|
|
11
|
-
/** The host's store; absent, `sqliteStore` at `<home>/.nyte/nyte.db`, which the host then closes with itself (§51c). */
|
|
12
5
|
readonly store?: Store;
|
|
13
|
-
/** Where a root session acts when `create` names none; default the local folder `process.cwd()` (§51c). */
|
|
14
6
|
readonly workspace?: WorkspaceTarget;
|
|
15
|
-
/** The `@nyte-ai/ai` catalog; absent, `nyteModels` over this host's encrypted credential store (§42e). */
|
|
16
7
|
readonly models?: Models;
|
|
17
|
-
/** Core plugins loaded after the first-party built-ins and before the plugin files; default none. One with a built-in's id replaces that built-in, as a bundled client's `codemode` runtime does, and a `local` environment provider among them replaces the default one. */
|
|
18
8
|
readonly plugins?: readonly Plugin<"core">[];
|
|
19
|
-
/** The directory whose `.nyte` holds the store, settings, plugins, secrets key and identity key; default `os.homedir()`. */
|
|
20
9
|
readonly home?: string;
|
|
21
|
-
/** The login shell the default local provider's pty jobs run, read at each start; absent or null is `$SHELL`. */
|
|
22
10
|
readonly shell?: () => string | null;
|
|
11
|
+
readonly label?: string;
|
|
12
|
+
readonly onRevoked?: () => void;
|
|
23
13
|
};
|
|
24
|
-
/**
|
|
25
|
-
* Opens the Node host the sdk's Node `open` calls: `composeHost` with
|
|
26
|
-
* `home` (default `os.homedir()`), `store` (default `<home>/.nyte/nyte.db`,
|
|
27
|
-
* checked every 500 ms for another process's commits, which are then read so
|
|
28
|
-
* a second process on the file sees the first one's runs live),
|
|
29
|
-
* `workspace` (default the local folder `process.cwd()`), `secrets` (default
|
|
30
|
-
* `defaultSecrets(home)`), `models` (default `nyteModels`), `localProvider`
|
|
31
|
-
* unless a plugin provides the `local` environment, every first-party plugin
|
|
32
|
-
* of `@nyte-ai/plugin` that `plugins` does not replace by id, then `plugins`
|
|
33
|
-
* and `filePlugins`' files, `settingsSeed`'s seed and
|
|
34
|
-
* `hostDescription()`; each file that did not load becomes a
|
|
35
|
-
* `server.report` row. The host's `loadPlugins` is `pluginLoader` over
|
|
36
|
-
* the plugin directories (§47l), which `watchPlugins` watches for hot reload
|
|
37
|
-
* (§49a). `listen` defaults `identity` to `identitySigner(host.hostId, home)`
|
|
38
|
-
* and `describe` to the description; nothing here reads the secrets key, even
|
|
39
|
-
* with a credential stored (§50d, §55). `close()` stops the watch, closes the
|
|
40
|
-
* open listeners, the host, then a store it opened.
|
|
41
|
-
*/
|
|
42
14
|
export declare function openHost(options: OpenHostOptions): Promise<Host>;
|
package/dist/src/open.js
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
2
|
openHost2
|
|
3
|
-
} from "../chunks/canvas-preview-
|
|
3
|
+
} from "../chunks/canvas-preview-y7kq0c8q.js";
|
|
4
4
|
import"../chunks/canvas-preview-4e0pxa32.js";
|
|
5
|
+
import"../chunks/canvas-preview-y5y6ghaw.js";
|
|
6
|
+
import"../chunks/canvas-preview-ec2mt7es.js";
|
|
7
|
+
import"../chunks/canvas-preview-befkjea2.js";
|
|
5
8
|
import"../chunks/canvas-preview-9aqczacs.js";
|
|
6
|
-
import"../chunks/canvas-preview-
|
|
7
|
-
import"../chunks/canvas-preview-
|
|
8
|
-
import"../chunks/canvas-preview-
|
|
9
|
-
import"../chunks/canvas-preview-
|
|
9
|
+
import"../chunks/canvas-preview-e3vnkkc5.js";
|
|
10
|
+
import"../chunks/canvas-preview-2jwbe14k.js";
|
|
11
|
+
import"../chunks/canvas-preview-5ekjx6sw.js";
|
|
12
|
+
import"../chunks/canvas-preview-8xc0vn7v.js";
|
|
10
13
|
import"../chunks/canvas-preview-1sq7z9jq.js";
|
|
11
|
-
import"../chunks/canvas-preview-
|
|
12
|
-
import"../chunks/canvas-preview-
|
|
14
|
+
import"../chunks/canvas-preview-vm9zdp2t.js";
|
|
15
|
+
import"../chunks/canvas-preview-crmzxxt8.js";
|
|
13
16
|
import"../chunks/canvas-preview-tjhabynd.js";
|
|
14
|
-
import"../chunks/canvas-preview-
|
|
15
|
-
import"../chunks/canvas-preview-
|
|
17
|
+
import"../chunks/canvas-preview-gh7c9831.js";
|
|
18
|
+
import"../chunks/canvas-preview-pkzqg96v.js";
|
|
16
19
|
import"../chunks/canvas-preview-5z63am63.js";
|
|
17
20
|
import"../chunks/canvas-preview-vaatfznm.js";
|
|
18
|
-
import"../chunks/canvas-preview-
|
|
21
|
+
import"../chunks/canvas-preview-drctegz4.js";
|
|
19
22
|
import"../chunks/canvas-preview-kn7kvbfj.js";
|
|
20
|
-
import"../chunks/canvas-preview-azg56359.js";
|
|
21
23
|
import"../chunks/canvas-preview-yjz0f7n4.js";
|
|
22
|
-
import"../chunks/canvas-preview-
|
|
24
|
+
import"../chunks/canvas-preview-af86jz8t.js";
|
|
23
25
|
import"../chunks/canvas-preview-s94ebwf5.js";
|
|
24
26
|
import"../chunks/canvas-preview-kdqgrstc.js";
|
|
25
|
-
import"../chunks/canvas-preview-
|
|
27
|
+
import"../chunks/canvas-preview-mstbvwz3.js";
|
|
26
28
|
import"../chunks/canvas-preview-zaaj99wd.js";
|
|
27
|
-
import"../chunks/canvas-preview-
|
|
28
|
-
import"../chunks/canvas-preview-
|
|
29
|
-
import"../chunks/canvas-preview-
|
|
30
|
-
import"../chunks/canvas-preview-
|
|
31
|
-
import"../chunks/canvas-preview-m02v4yy6.js";
|
|
29
|
+
import"../chunks/canvas-preview-ycepb05s.js";
|
|
30
|
+
import"../chunks/canvas-preview-w54ymtb3.js";
|
|
31
|
+
import"../chunks/canvas-preview-aq5j4p25.js";
|
|
32
|
+
import"../chunks/canvas-preview-55s0y68g.js";
|
|
32
33
|
import"../chunks/canvas-preview-rp4x6y1h.js";
|
|
33
34
|
import"../chunks/canvas-preview-skzwvw4d.js";
|
|
35
|
+
import"../chunks/canvas-preview-bxnqt8cd.js";
|
|
34
36
|
import"../chunks/canvas-preview-518dh8by.js";
|
|
35
37
|
import"../chunks/canvas-preview-0cmbkp2j.js";
|
|
36
38
|
import"../chunks/canvas-preview-69fkk9yn.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createHandler2
|
|
3
|
-
} from "../../chunks/canvas-preview-
|
|
4
|
-
import"../../chunks/canvas-preview-
|
|
3
|
+
} from "../../chunks/canvas-preview-aq5j4p25.js";
|
|
4
|
+
import"../../chunks/canvas-preview-55s0y68g.js";
|
|
5
5
|
import"../../chunks/canvas-preview-rp4x6y1h.js";
|
|
6
6
|
export {
|
|
7
7
|
createHandler2 as createHandler
|
package/dist/src/sqlite.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Store } from "@nyte-ai/core";
|
|
2
|
-
/**
|
|
2
|
+
/** The local store's file: `NYTE_DB` when set, so a source run keeps its own chats, else `.nyte/nyte.db` under `home`. */
|
|
3
|
+
export declare function storePath(home: string): string;
|
|
3
4
|
export declare function sqliteStore(input: {
|
|
4
5
|
readonly path: string;
|
|
5
6
|
} | {
|
package/dist/src/sqlite.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
storePath2,
|
|
2
3
|
sqliteStore2
|
|
3
|
-
} from "../chunks/canvas-preview-
|
|
4
|
+
} from "../chunks/canvas-preview-mstbvwz3.js";
|
|
4
5
|
import"../chunks/canvas-preview-zaaj99wd.js";
|
|
5
|
-
import"../chunks/canvas-preview-a3yw0j70.js";
|
|
6
6
|
import"../chunks/canvas-preview-0cmbkp2j.js";
|
|
7
7
|
import"../chunks/canvas-preview-69fkk9yn.js";
|
|
8
8
|
export {
|
|
9
|
-
sqliteStore2 as sqliteStore
|
|
9
|
+
sqliteStore2 as sqliteStore,
|
|
10
|
+
storePath2 as storePath
|
|
10
11
|
};
|
package/dist/src/store-usage.js
CHANGED
|
@@ -4,8 +4,11 @@ import {
|
|
|
4
4
|
shiftDay2,
|
|
5
5
|
projectUsageReport2,
|
|
6
6
|
readNyteUsage2
|
|
7
|
-
} from "../chunks/canvas-preview-
|
|
7
|
+
} from "../chunks/canvas-preview-geg2gckp.js";
|
|
8
8
|
import"../chunks/canvas-preview-srgfpdmf.js";
|
|
9
|
+
import"../chunks/canvas-preview-mstbvwz3.js";
|
|
10
|
+
import"../chunks/canvas-preview-zaaj99wd.js";
|
|
11
|
+
import"../chunks/canvas-preview-0cmbkp2j.js";
|
|
9
12
|
import"../chunks/canvas-preview-69fkk9yn.js";
|
|
10
13
|
export {
|
|
11
14
|
USAGE_EVENTS2 as USAGE_EVENTS,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Stats } from "node:fs";
|
|
2
|
+
import { Type, type TSchema } from "typebox";
|
|
3
|
+
export interface HistoryLine {
|
|
4
|
+
readonly text: string;
|
|
5
|
+
/** False for a last line without its newline: its writer may still be appending it. */
|
|
6
|
+
readonly terminated: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface HistoryFold<Scan> {
|
|
9
|
+
line(line: HistoryLine): void;
|
|
10
|
+
scan(): Scan;
|
|
11
|
+
}
|
|
12
|
+
/** Folds a history file's lines into a scan. `scan()` returns a copy, so folding goes on without changing it. */
|
|
13
|
+
export type HistoryParser<Scan> = (from: Scan | undefined) => HistoryFold<Scan>;
|
|
14
|
+
export interface FileScan<Scan> {
|
|
15
|
+
readonly size: number;
|
|
16
|
+
readonly mtimeMs: number;
|
|
17
|
+
/** The byte after the last newline, where a grown file resumes. */
|
|
18
|
+
readonly position: number;
|
|
19
|
+
/** The scan of every line up to `position`. */
|
|
20
|
+
readonly committed: Scan;
|
|
21
|
+
}
|
|
22
|
+
export declare function fileScanSchema<Scan extends TSchema>(scan: Scan): Type.TObject<{
|
|
23
|
+
size: Type.TNumber;
|
|
24
|
+
mtimeMs: Type.TNumber;
|
|
25
|
+
position: Type.TNumber;
|
|
26
|
+
committed: Scan;
|
|
27
|
+
}>;
|
|
28
|
+
/** Scans keyed by path. A scan answers while its file keeps the size and mtime it was read at. */
|
|
29
|
+
export declare class UsageScanCache<Scan> {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(files?: Iterable<readonly [string, FileScan<Scan>]>);
|
|
32
|
+
keys(): IterableIterator<string>;
|
|
33
|
+
entries(): IterableIterator<[string, FileScan<Scan>]>;
|
|
34
|
+
get(path: string): FileScan<Scan> | undefined;
|
|
35
|
+
set(path: string, scan: FileScan<Scan>): void;
|
|
36
|
+
/** Forgets every file a read did not reach. */
|
|
37
|
+
keepOnly(seen: ReadonlySet<string>): void;
|
|
38
|
+
/** Whether a scan was added or forgotten since the last {@link markSaved}. */
|
|
39
|
+
get changed(): boolean;
|
|
40
|
+
markSaved(): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Reads a history file through `cache`. An unchanged file answers from the cache without being
|
|
44
|
+
* opened, and a file that only grew is read from its last newline on; any other change rereads it.
|
|
45
|
+
* A last line without its newline is folded into the answer but not the cache, since its writer may
|
|
46
|
+
* still be appending it: the next read starts from that line again.
|
|
47
|
+
*/
|
|
48
|
+
export declare function readHistory<Scan>(path: string, info: Stats, parser: HistoryParser<Scan>, cache: UsageScanCache<Scan> | undefined, signal: AbortSignal | undefined): Promise<Scan>;
|
|
49
|
+
/** Reads a cache document written by {@link writeCacheDocument}; a missing, torn or outdated one reads as `undefined`. */
|
|
50
|
+
export declare function readCacheDocument<Document>(path: string, validator: {
|
|
51
|
+
Check(value: unknown): value is Document;
|
|
52
|
+
}): Promise<Document | undefined>;
|
|
53
|
+
/** Replaces the cache document whole, so a reader never sees half of one. Resolves whether the write landed. */
|
|
54
|
+
export declare function writeCacheDocument<Document>(path: string, document: Document): Promise<boolean>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fileScanSchema2,
|
|
3
|
+
UsageScanCache2,
|
|
4
|
+
readHistory2,
|
|
5
|
+
readCacheDocument2,
|
|
6
|
+
writeCacheDocument2
|
|
7
|
+
} from "../chunks/canvas-preview-kp75gb63.js";
|
|
8
|
+
export {
|
|
9
|
+
UsageScanCache2 as UsageScanCache,
|
|
10
|
+
fileScanSchema2 as fileScanSchema,
|
|
11
|
+
readCacheDocument2 as readCacheDocument,
|
|
12
|
+
readHistory2 as readHistory,
|
|
13
|
+
writeCacheDocument2 as writeCacheDocument
|
|
14
|
+
};
|
|
@@ -13,7 +13,8 @@ export interface UsageScanReader {
|
|
|
13
13
|
export declare function catalogForUsage(models: Pick<Models, "getModels">): readonly Model<Api>[];
|
|
14
14
|
export declare class UsageScanner implements UsageScanReader {
|
|
15
15
|
private readonly home;
|
|
16
|
-
private readonly
|
|
16
|
+
private readonly cachePath;
|
|
17
|
+
private caches;
|
|
17
18
|
private readonly models;
|
|
18
19
|
private readonly scans;
|
|
19
20
|
constructor(home: string);
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
catalogForUsage2,
|
|
3
3
|
UsageScanner2
|
|
4
|
-
} from "../chunks/canvas-preview-
|
|
5
|
-
import"../chunks/canvas-preview-
|
|
6
|
-
import"../chunks/canvas-preview-
|
|
4
|
+
} from "../chunks/canvas-preview-k2xaz0ym.js";
|
|
5
|
+
import"../chunks/canvas-preview-eehzfefa.js";
|
|
6
|
+
import"../chunks/canvas-preview-geg2gckp.js";
|
|
7
|
+
import"../chunks/canvas-preview-kp75gb63.js";
|
|
7
8
|
import"../chunks/canvas-preview-srgfpdmf.js";
|
|
9
|
+
import"../chunks/canvas-preview-mstbvwz3.js";
|
|
10
|
+
import"../chunks/canvas-preview-zaaj99wd.js";
|
|
11
|
+
import"../chunks/canvas-preview-0cmbkp2j.js";
|
|
8
12
|
import"../chunks/canvas-preview-69fkk9yn.js";
|
|
9
13
|
export {
|
|
10
14
|
UsageScanner2 as UsageScanner,
|
package/dist/src/usage-worker.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import"../chunks/canvas-preview-srgfpdmf.js";
|
|
2
1
|
import"../chunks/canvas-preview-69fkk9yn.js";
|
|
3
|
-
import"../chunks/canvas-preview-
|
|
4
|
-
import"../chunks/canvas-preview-
|
|
2
|
+
import"../chunks/canvas-preview-zaaj99wd.js";
|
|
3
|
+
import"../chunks/canvas-preview-0cmbkp2j.js";
|
|
4
|
+
import"../chunks/canvas-preview-mstbvwz3.js";
|
|
5
|
+
import"../chunks/canvas-preview-srgfpdmf.js";
|
|
6
|
+
import"../chunks/canvas-preview-geg2gckp.js";
|
|
7
|
+
import"../chunks/canvas-preview-kp75gb63.js";
|
|
8
|
+
import"../chunks/canvas-preview-eehzfefa.js";
|
|
5
9
|
import {
|
|
6
10
|
UsageScanner2
|
|
7
|
-
} from "../chunks/canvas-preview-
|
|
11
|
+
} from "../chunks/canvas-preview-k2xaz0ym.js";
|
|
8
12
|
|
|
9
13
|
// src/usage-worker.ts
|
|
10
14
|
import { parentPort } from "node:worker_threads";
|
package/dist/src/usage.d.ts
CHANGED
|
@@ -1,29 +1,83 @@
|
|
|
1
|
+
import { Type, type Static } from "typebox";
|
|
1
2
|
import { type Models } from "@nyte-ai/ai";
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
3
|
+
import { UsageScanCache } from "./usage-history.ts";
|
|
4
|
+
import type { LocalHistoryUsage, UsageWindow } from "./usage-types.ts";
|
|
4
5
|
export interface ClaudeCodeUsageOptions {
|
|
5
6
|
readonly models: Pick<Models, "getModels">;
|
|
7
|
+
readonly window: UsageWindow;
|
|
6
8
|
readonly configDir?: string;
|
|
7
9
|
readonly signal?: AbortSignal;
|
|
8
10
|
readonly cache?: UsageScanCache<ClaudeCodeFileScan>;
|
|
9
11
|
}
|
|
10
|
-
export type UsageScanCache<T> = Map<string, FileScan<T>>;
|
|
11
|
-
export interface FileScan<T> {
|
|
12
|
-
readonly size: number;
|
|
13
|
-
readonly mtimeMs: number;
|
|
14
|
-
readonly scan: T;
|
|
15
|
-
}
|
|
16
|
-
export interface ClaudeCodeFileScan {
|
|
17
|
-
readonly keyed: readonly (readonly [string, Snapshot])[];
|
|
18
|
-
readonly anonymous: readonly Snapshot[];
|
|
19
|
-
readonly malformedRecords: number;
|
|
20
|
-
}
|
|
21
12
|
export type ClaudeCodeUsage = LocalHistoryUsage;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
declare const snapshot: Type.TObject<{
|
|
14
|
+
model: Type.TString;
|
|
15
|
+
usage: Type.TObject<{
|
|
16
|
+
input: Type.TNumber;
|
|
17
|
+
output: Type.TNumber;
|
|
18
|
+
cacheRead: Type.TNumber;
|
|
19
|
+
cacheWrite: Type.TNumber;
|
|
20
|
+
cacheWrite1h: Type.TOptional<Type.TNumber>;
|
|
21
|
+
reasoning: Type.TOptional<Type.TNumber>;
|
|
22
|
+
totalTokens: Type.TNumber;
|
|
23
|
+
cost: Type.TObject<{
|
|
24
|
+
input: Type.TNumber;
|
|
25
|
+
output: Type.TNumber;
|
|
26
|
+
cacheRead: Type.TNumber;
|
|
27
|
+
cacheWrite: Type.TNumber;
|
|
28
|
+
total: Type.TNumber;
|
|
29
|
+
}>;
|
|
30
|
+
}>;
|
|
31
|
+
costUSD: Type.TOptional<Type.TNumber>;
|
|
32
|
+
at: Type.TUnion<[Type.TNumber, Type.TNull]>;
|
|
33
|
+
}>;
|
|
34
|
+
export type Snapshot = Static<typeof snapshot>;
|
|
35
|
+
declare const claudeCodeFileScan: Type.TObject<{
|
|
36
|
+
keyed: Type.TArray<Type.TTuple<[Type.TString, Type.TObject<{
|
|
37
|
+
model: Type.TString;
|
|
38
|
+
usage: Type.TObject<{
|
|
39
|
+
input: Type.TNumber;
|
|
40
|
+
output: Type.TNumber;
|
|
41
|
+
cacheRead: Type.TNumber;
|
|
42
|
+
cacheWrite: Type.TNumber;
|
|
43
|
+
cacheWrite1h: Type.TOptional<Type.TNumber>;
|
|
44
|
+
reasoning: Type.TOptional<Type.TNumber>;
|
|
45
|
+
totalTokens: Type.TNumber;
|
|
46
|
+
cost: Type.TObject<{
|
|
47
|
+
input: Type.TNumber;
|
|
48
|
+
output: Type.TNumber;
|
|
49
|
+
cacheRead: Type.TNumber;
|
|
50
|
+
cacheWrite: Type.TNumber;
|
|
51
|
+
total: Type.TNumber;
|
|
52
|
+
}>;
|
|
53
|
+
}>;
|
|
54
|
+
costUSD: Type.TOptional<Type.TNumber>;
|
|
55
|
+
at: Type.TUnion<[Type.TNumber, Type.TNull]>;
|
|
56
|
+
}>]>>;
|
|
57
|
+
anonymous: Type.TArray<Type.TObject<{
|
|
58
|
+
model: Type.TString;
|
|
59
|
+
usage: Type.TObject<{
|
|
60
|
+
input: Type.TNumber;
|
|
61
|
+
output: Type.TNumber;
|
|
62
|
+
cacheRead: Type.TNumber;
|
|
63
|
+
cacheWrite: Type.TNumber;
|
|
64
|
+
cacheWrite1h: Type.TOptional<Type.TNumber>;
|
|
65
|
+
reasoning: Type.TOptional<Type.TNumber>;
|
|
66
|
+
totalTokens: Type.TNumber;
|
|
67
|
+
cost: Type.TObject<{
|
|
68
|
+
input: Type.TNumber;
|
|
69
|
+
output: Type.TNumber;
|
|
70
|
+
cacheRead: Type.TNumber;
|
|
71
|
+
cacheWrite: Type.TNumber;
|
|
72
|
+
total: Type.TNumber;
|
|
73
|
+
}>;
|
|
74
|
+
}>;
|
|
75
|
+
costUSD: Type.TOptional<Type.TNumber>;
|
|
76
|
+
at: Type.TUnion<[Type.TNumber, Type.TNull]>;
|
|
77
|
+
}>>;
|
|
78
|
+
malformedRecords: Type.TInteger;
|
|
79
|
+
}>;
|
|
80
|
+
export type ClaudeCodeFileScan = Static<typeof claudeCodeFileScan>;
|
|
27
81
|
/**
|
|
28
82
|
* Reads Claude Code's local usage under `<configDir>/projects`. The configured root may be a
|
|
29
83
|
* symlink (as may a system ancestor such as macOS `/tmp`), but links below it are skipped, to
|
|
@@ -35,19 +89,82 @@ export declare function readClaudeCodeUsage(options: ClaudeCodeUsageOptions): Pr
|
|
|
35
89
|
export type CodexUsage = LocalHistoryUsage;
|
|
36
90
|
export interface CodexUsageOptions {
|
|
37
91
|
readonly models: Pick<Models, "getModels">;
|
|
92
|
+
readonly window: UsageWindow;
|
|
38
93
|
readonly homeDir?: string;
|
|
39
94
|
readonly signal?: AbortSignal;
|
|
40
95
|
readonly cache?: UsageScanCache<CodexFileScan>;
|
|
41
96
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
97
|
+
declare const codexRow: Type.TObject<{
|
|
98
|
+
model: Type.TString;
|
|
99
|
+
usage: Type.TObject<{
|
|
100
|
+
input: Type.TNumber;
|
|
101
|
+
output: Type.TNumber;
|
|
102
|
+
cacheRead: Type.TNumber;
|
|
103
|
+
cacheWrite: Type.TNumber;
|
|
104
|
+
cacheWrite1h: Type.TOptional<Type.TNumber>;
|
|
105
|
+
reasoning: Type.TOptional<Type.TNumber>;
|
|
106
|
+
totalTokens: Type.TNumber;
|
|
107
|
+
cost: Type.TObject<{
|
|
108
|
+
input: Type.TNumber;
|
|
109
|
+
output: Type.TNumber;
|
|
110
|
+
cacheRead: Type.TNumber;
|
|
111
|
+
cacheWrite: Type.TNumber;
|
|
112
|
+
total: Type.TNumber;
|
|
113
|
+
}>;
|
|
114
|
+
}>;
|
|
115
|
+
at: Type.TUnion<[Type.TNumber, Type.TNull]>;
|
|
116
|
+
}>;
|
|
117
|
+
export type CodexRow = Static<typeof codexRow>;
|
|
118
|
+
declare const codexFileScan: Type.TObject<{
|
|
119
|
+
modern: Type.TArray<Type.TTuple<[Type.TString, Type.TObject<{
|
|
120
|
+
model: Type.TString;
|
|
121
|
+
usage: Type.TObject<{
|
|
122
|
+
input: Type.TNumber;
|
|
123
|
+
output: Type.TNumber;
|
|
124
|
+
cacheRead: Type.TNumber;
|
|
125
|
+
cacheWrite: Type.TNumber;
|
|
126
|
+
cacheWrite1h: Type.TOptional<Type.TNumber>;
|
|
127
|
+
reasoning: Type.TOptional<Type.TNumber>;
|
|
128
|
+
totalTokens: Type.TNumber;
|
|
129
|
+
cost: Type.TObject<{
|
|
130
|
+
input: Type.TNumber;
|
|
131
|
+
output: Type.TNumber;
|
|
132
|
+
cacheRead: Type.TNumber;
|
|
133
|
+
cacheWrite: Type.TNumber;
|
|
134
|
+
total: Type.TNumber;
|
|
135
|
+
}>;
|
|
136
|
+
}>;
|
|
137
|
+
at: Type.TUnion<[Type.TNumber, Type.TNull]>;
|
|
138
|
+
}>]>>;
|
|
139
|
+
legacy: Type.TArray<Type.TObject<{
|
|
140
|
+
model: Type.TString;
|
|
141
|
+
usage: Type.TObject<{
|
|
142
|
+
input: Type.TNumber;
|
|
143
|
+
output: Type.TNumber;
|
|
144
|
+
cacheRead: Type.TNumber;
|
|
145
|
+
cacheWrite: Type.TNumber;
|
|
146
|
+
cacheWrite1h: Type.TOptional<Type.TNumber>;
|
|
147
|
+
reasoning: Type.TOptional<Type.TNumber>;
|
|
148
|
+
totalTokens: Type.TNumber;
|
|
149
|
+
cost: Type.TObject<{
|
|
150
|
+
input: Type.TNumber;
|
|
151
|
+
output: Type.TNumber;
|
|
152
|
+
cacheRead: Type.TNumber;
|
|
153
|
+
cacheWrite: Type.TNumber;
|
|
154
|
+
total: Type.TNumber;
|
|
155
|
+
}>;
|
|
156
|
+
}>;
|
|
157
|
+
at: Type.TUnion<[Type.TNumber, Type.TNull]>;
|
|
158
|
+
}>>;
|
|
159
|
+
malformedRecords: Type.TInteger;
|
|
160
|
+
cursor: Type.TObject<{
|
|
161
|
+
model: Type.TString;
|
|
162
|
+
sawMeta: Type.TBoolean;
|
|
163
|
+
signature: Type.TOptional<Type.TString>;
|
|
164
|
+
forkAnchorMs: Type.TOptional<Type.TNumber>;
|
|
165
|
+
}>;
|
|
166
|
+
}>;
|
|
167
|
+
export type CodexFileScan = Static<typeof codexFileScan>;
|
|
51
168
|
/**
|
|
52
169
|
* Reads Codex's local usage from `sessions` and `archived_sessions` (where the legacy format
|
|
53
170
|
* lives). A `response_id` is unique across files, so one map dedups a forked rollout's repeated
|
|
@@ -61,12 +178,18 @@ export interface UsageScanCaches {
|
|
|
61
178
|
readonly codex: UsageScanCache<CodexFileScan>;
|
|
62
179
|
}
|
|
63
180
|
export declare function createUsageScanCaches(): UsageScanCaches;
|
|
181
|
+
/** Restores the scans {@link saveUsageScanCaches} wrote to `path`; each still answers only while its file is unchanged. */
|
|
182
|
+
export declare function loadUsageScanCaches(path: string): Promise<UsageScanCaches>;
|
|
183
|
+
/** Writes `caches` to `path` when a read changed them since they were last saved; a failed write is tried again on the next save. */
|
|
184
|
+
export declare function saveUsageScanCaches(path: string, caches: UsageScanCaches): Promise<void>;
|
|
64
185
|
export interface LocalUsage {
|
|
65
186
|
readonly claudeCode: LocalHistoryUsage;
|
|
66
187
|
readonly codex: LocalHistoryUsage;
|
|
67
188
|
}
|
|
68
189
|
export declare function readLocalUsage(options: {
|
|
69
190
|
readonly models: Pick<Models, "getModels">;
|
|
191
|
+
readonly window: UsageWindow;
|
|
70
192
|
readonly signal?: AbortSignal;
|
|
71
193
|
readonly caches?: UsageScanCaches;
|
|
72
194
|
}): Promise<LocalUsage>;
|
|
195
|
+
export {};
|