@danypops/jittor 0.12.0 → 0.12.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danypops/jittor",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "Just-in-Time Token Optimizing Router for Pi -- supervised daemon, router policy, and CLI",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -16,7 +16,8 @@
16
16
  "service:install": "bun src/cli.ts service install"
17
17
  },
18
18
  "dependencies": {
19
- "@danypops/daemon-kit": "^0.3.1",
19
+ "@danypops/vehicle-server": "^0.2.1",
20
+ "@danypops/vehicle-client": "^0.1.1",
20
21
  "google-auth-library": "^10.9.0"
21
22
  },
22
23
  "devDependencies": {
@@ -41,7 +41,7 @@ export function systemctl(...args: string[]): void {
41
41
 
42
42
  /** cliPath is the caller's own entrypoint file -- resolved from the real CLI script's `import.meta.url`, never this module's own, so the installed unit's ExecStart always points at the actual runnable CLI. */
43
43
  export function installService(cliPath: string): void {
44
- const unitPath = resolveJittorPaths().systemdUnit;
44
+ const unitPath = resolveJittorPaths().serviceDescriptor;
45
45
  mkdirSync(dirname(unitPath), { recursive: true });
46
46
  const codexAuthFile = join(process.env["CODEX_HOME"] ?? join(homedir(), ".codex"), "auth.json");
47
47
  writeFileSync(unitPath, renderSystemdUnit({
@@ -8,7 +8,7 @@ export interface CliDependencies {
8
8
  stderr(line: string): void;
9
9
  systemctl(...args: string[]): void;
10
10
  installService(): void;
11
- serve(): void;
11
+ serve(): Promise<void>;
12
12
  }
13
13
 
14
14
  export function humanField(value: string): string {
package/src/cli.ts CHANGED
@@ -52,7 +52,7 @@ function usage(stderr: (line: string) => void): number {
52
52
  export async function runCli(args: string[], deps: CliDependencies = DEFAULT_DEPENDENCIES): Promise<number> {
53
53
  const [command, action, ...rest] = args;
54
54
  const fail = () => usage(deps.stderr);
55
- if (command === "serve") { deps.serve(); return 0; }
55
+ if (command === "serve") { await deps.serve(); return 0; }
56
56
  if (command === "session") return runSessionCommand(action, rest, deps, fail);
57
57
  if (command === "metrics") return runMetricsCommand(action, rest, deps, fail);
58
58
  if (command === "telemetry") return runTelemetryCommand(action, rest, deps, fail);
package/src/client.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AuthenticatedRpcClient, type FetchTransport } from "@danypops/daemon-kit/rpc-client";
1
+ import { AuthenticatedRpcClient, type FetchTransport } from "@danypops/vehicle-client/rpc-client";
2
2
  import type { OperationInputs, OperationName, OperationOutputs } from "./service.ts";
3
3
  import { ensureAuthToken, readDaemonHandle, resolveJittorPaths, type JittorPaths } from "./state.ts";
4
4
 
@@ -6,7 +6,7 @@ export type { FetchTransport };
6
6
 
7
7
  /**
8
8
  * Jittor's typed authenticated RPC client, now a thin named subclass of
9
- * `@danypops/daemon-kit/rpc-client`'s `AuthenticatedRpcClient` -- the shared substrate factored
9
+ * `@danypops/vehicle-client/rpc-client`'s `AuthenticatedRpcClient` -- the shared substrate factored
10
10
  * out after jittor's own client.ts and web-spider-daemon's were found byte-identical (see
11
11
  * daemon-kit's README). Keeps the old 3-positional-argument constructor so every existing call
12
12
  * site is untouched by this migration.
package/src/daemon.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { startDaemon as startDaemonKit, type RunningDaemon } from "@danypops/daemon-kit/daemon";
1
+ import { startDaemon as startDaemonKit, type RunningDaemon } from "@danypops/vehicle-server/daemon";
2
2
  import { MAINTENANCE_INTERVAL_MS, TELEMETRY_POLL_INTERVAL_MS } from "./constants.ts";
3
3
  import { DEFAULT_POLICY, UNCONFIGURED_ROUTE } from "./config.ts";
4
4
  import { SQLiteMetricStore } from "./adapters/sqlite-metric-store.ts";
@@ -23,7 +23,7 @@ import type { GoogleVertexMetricSource } from "./providers/google-vertex-contrac
23
23
  import { ensureAuthToken, resolveJittorPaths, type JittorPaths } from "./state.ts";
24
24
  import { logEvent, logger } from "./log.ts";
25
25
 
26
- export type { RunningDaemon } from "@danypops/daemon-kit/daemon";
26
+ export type { RunningDaemon } from "@danypops/vehicle-server/daemon";
27
27
 
28
28
  export function reportMaintenanceFailure(event: string, error: unknown): void {
29
29
  logEvent("error", event, { message: error instanceof Error ? error.message : String(error) });
@@ -65,7 +65,7 @@ export function telemetrySourcesFromEnvironment(env: Record<string, string | und
65
65
  }
66
66
 
67
67
  /**
68
- * Composition root, now built on `@danypops/daemon-kit/daemon`'s `startDaemon` for binding,
68
+ * Composition root, now built on `@danypops/vehicle-server/daemon`'s `startDaemon` for binding,
69
69
  * atomic handle write, maintenance-timer driving, and clean shutdown -- the skeleton that used to
70
70
  * be hand-rolled here (and, byte-identically, in web-spider-daemon's and papyrus's daemon.ts; see
71
71
  * daemon-kit's README). Each maintenance task still catches and classifies its own failure via
@@ -74,10 +74,10 @@ export function telemetrySourcesFromEnvironment(env: Record<string, string | und
74
74
  * daemon-kit's own generic "maintenance task failed: <name>" catch, which exists as a safety net
75
75
  * for tasks that don't self-classify, not to replace a consumer's own richer classification.
76
76
  */
77
- export function startDaemon(
77
+ export async function startDaemon(
78
78
  paths: JittorPaths = resolveJittorPaths(),
79
79
  env: Record<string, string | undefined> = process.env,
80
- ): RunningDaemon {
80
+ ): Promise<RunningDaemon> {
81
81
  const token = ensureAuthToken(paths);
82
82
  const db = openJittorDb(paths.database);
83
83
  const metrics = new SQLiteMetricStore(db);
@@ -96,7 +96,7 @@ export function startDaemon(
96
96
  });
97
97
  const service = new JittorService(metrics, router, benchmarks, modelRanker, sessionIdentity);
98
98
 
99
- const daemon = startDaemonKit({
99
+ const daemon = await startDaemonKit({
100
100
  daemonLabel: "Jittor",
101
101
  handlePath: paths.handle,
102
102
  logger,
@@ -115,8 +115,8 @@ export function startDaemon(
115
115
  return daemon;
116
116
  }
117
117
 
118
- export function serveMain(): void {
119
- const daemon = startDaemon();
118
+ export async function serveMain(): Promise<void> {
119
+ const daemon = await startDaemon();
120
120
  console.error(`[jittor] listening on ${daemon.host}:${daemon.port}`);
121
121
  const stop = async (): Promise<void> => {
122
122
  await daemon.stop();
package/src/db.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Database } from "bun:sqlite";
2
- import { openSqliteWithPragmas } from "@danypops/daemon-kit/storage";
2
+ import { openSqliteWithPragmas } from "@danypops/vehicle-server/storage";
3
3
  import { SQLITE_BUSY_TIMEOUT_MS } from "./constants.ts";
4
4
 
5
5
  const INITIAL_SCHEMA = `
@@ -31,7 +31,7 @@ CREATE INDEX session_identities_last_seen_idx
31
31
  `;
32
32
 
33
33
  /**
34
- * Delegates bootstrap (pragmas, migration engine) to `@danypops/daemon-kit/storage`, which
34
+ * Delegates bootstrap (pragmas, migration engine) to `@danypops/vehicle-server/storage`, which
35
35
  * generalizes the byte-identical pragma/PRAGMA-user_version skeleton jittor's own db.ts used to
36
36
  * hand-roll (see daemon-kit's README). Jittor's only remaining responsibility is its own schema.
37
37
  */
package/src/log.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Structured daemon logging, now backed by `@danypops/daemon-kit/logging` (pino) instead of a
2
+ * Structured daemon logging, now backed by `@danypops/vehicle-server/logging` (pino) instead of a
3
3
  * hand-rolled `console.error(JSON.stringify(...))` -- daemon-kit's own module doc explains why:
4
4
  * level ordering/filtering/child-scoping is exactly the kind of thing worth one shared,
5
5
  * dependency-backed implementation instead of four independent hand-rolled ones. One deliberate,
@@ -8,9 +8,9 @@
8
8
  * four daemons. `component`/`level`/`timestamp` and credential-safety (callers still must pass
9
9
  * only bounded, non-sensitive fields) are unchanged.
10
10
  */
11
- import { createLogger, type LogLevel as DaemonKitLogLevel, type Logger } from "@danypops/daemon-kit/logging";
11
+ import { createLogger, type LogLevel as VehicleLogLevel, type Logger } from "@danypops/vehicle-server/logging";
12
12
 
13
- export type LogLevel = Extract<DaemonKitLogLevel, "info" | "warn" | "error">;
13
+ export type LogLevel = Extract<VehicleLogLevel, "info" | "warn" | "error">;
14
14
 
15
15
  /**
16
16
  * Also passed directly as `StartDaemonOptions.logger` so daemon-kit's own maintenance-task
@@ -1,5 +1,5 @@
1
- import type { SessionIdentityRecord, SessionIdentityStore as DaemonKitSessionIdentityStore } from "@danypops/daemon-kit/session-identity";
1
+ import type { SessionIdentityRecord, SessionIdentityStore as VehicleSessionIdentityStore } from "@danypops/vehicle-server/session-identity";
2
2
 
3
3
  /** Jittor's persistence port for daemon-kit's storage-agnostic session-identity primitive. */
4
- export type SessionIdentityStore = DaemonKitSessionIdentityStore;
4
+ export type SessionIdentityStore = VehicleSessionIdentityStore;
5
5
  export type { SessionIdentityRecord };
package/src/service.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { errorResponse, healthResponse, readyResponse, requireBearerToken } from "@danypops/daemon-kit/http";
1
+ import { errorResponse, healthResponse, readyResponse, requireBearerToken } from "@danypops/vehicle-server/rpc-http";
2
2
  import { SERVICE_MAX_BODY_BYTES, SERVICE_MAX_RESPONSE_BYTES } from "./constants.ts";
3
3
  import { InvalidSessionSecretError, SessionIdentity, type RegisterSessionIdentityResult } from "./session-identity-service.ts";
4
4
  import { VERSION } from "./version.ts";
@@ -188,7 +188,7 @@ export interface JittorAppOptions {
188
188
 
189
189
  /**
190
190
  * Bearer-check and the trivial health/ready/not-found responses now delegate to
191
- * `@danypops/daemon-kit/http` (the same handful of lines every daemon's service.ts hand-rolled).
191
+ * `@danypops/vehicle-server/rpc-http` (the same handful of lines every daemon's service.ts hand-rolled).
192
192
  * The response-size guard below stays jittor-specific: daemon-kit's `jsonResponse` is intentionally
193
193
  * unbounded (it has no operation dispatch of its own to guard), while jittor's `/api/v1/ops` can
194
194
  * return arbitrarily large query results that must be capped (see SERVICE_MAX_RESPONSE_BYTES).
@@ -1,4 +1,4 @@
1
- import { isSessionRegistered, registerSessionIdentity, releaseSessionIdentity, verifySessionSecret } from "@danypops/daemon-kit/session-identity";
1
+ import { isSessionRegistered, registerSessionIdentity, releaseSessionIdentity, verifySessionSecret } from "@danypops/vehicle-server/session-identity";
2
2
  import type { SessionIdentityStore } from "./ports/session-identity-store.ts";
3
3
 
4
4
  export interface RegisterSessionIdentityResult {
package/src/state.ts CHANGED
@@ -1,20 +1,20 @@
1
1
  /**
2
- * Jittor's XDG paths/token/handle layout, now delegating to `@danypops/daemon-kit/paths` --
2
+ * Jittor's XDG paths/token/handle layout, now delegating to `@danypops/vehicle-server/paths` --
3
3
  * the shared substrate factored out after jittor's own state.ts and web-spider-daemon's were
4
4
  * found byte-identical (see daemon-kit's README). Kept as a thin jittor-named wrapper (same
5
5
  * exported function names/signatures as before) so every existing call site (daemon.ts,
6
6
  * client.ts, cli.ts, and their tests) is untouched by this migration.
7
7
  */
8
8
  import {
9
- ensureAuthToken as ensureDaemonKitAuthToken,
10
- readDaemonHandle as readDaemonKitHandle,
11
- removeDaemonHandle as removeDaemonKitHandle,
9
+ ensureAuthToken as ensureVehicleAuthToken,
10
+ readDaemonHandle as readVehicleHandle,
11
+ removeDaemonHandle as removeVehicleHandle,
12
12
  resolveDaemonPaths,
13
- writeDaemonHandle as writeDaemonKitHandle,
13
+ writeDaemonHandle as writeVehicleHandle,
14
14
  type DaemonHandle,
15
15
  type DaemonPaths,
16
16
  type PathEnvironment,
17
- } from "@danypops/daemon-kit/paths";
17
+ } from "@danypops/vehicle-server/paths";
18
18
  import {
19
19
  DATABASE_FILENAME,
20
20
  HANDLE_FILENAME,
@@ -39,17 +39,17 @@ export function resolveJittorPaths(options: PathEnvironment = {}): JittorPaths {
39
39
  }
40
40
 
41
41
  export function ensureAuthToken(paths: JittorPaths = resolveJittorPaths()): string {
42
- return ensureDaemonKitAuthToken(paths.token, "Jittor");
42
+ return ensureVehicleAuthToken(paths.token, "Jittor");
43
43
  }
44
44
 
45
45
  export function writeDaemonHandle(paths: JittorPaths, handle: DaemonHandle): void {
46
- writeDaemonKitHandle(paths.handle, handle);
46
+ writeVehicleHandle(paths.handle, handle);
47
47
  }
48
48
 
49
49
  export function readDaemonHandle(paths: JittorPaths = resolveJittorPaths()): DaemonHandle | null {
50
- return readDaemonKitHandle(paths.handle);
50
+ return readVehicleHandle(paths.handle);
51
51
  }
52
52
 
53
53
  export function removeDaemonHandle(paths: JittorPaths = resolveJittorPaths()): void {
54
- removeDaemonKitHandle(paths.handle);
54
+ removeVehicleHandle(paths.handle);
55
55
  }
package/src/version.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { readPackageVersion } from "@danypops/daemon-kit/version";
1
+ import { readPackageVersion } from "@danypops/vehicle-server/version";
2
2
 
3
3
  /** Runtime package version; package.json is the single release source of truth. */
4
4
  export const VERSION = readPackageVersion(new URL("../package.json", import.meta.url), "Jittor");