@hasna/economy 0.3.28 → 0.4.0
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/CHANGELOG.md +95 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +6 -13
- package/SECURITY.md +1 -1
- package/dist/cli/commands/extras.d.ts.map +1 -1
- package/dist/cli/index.js +1135 -853
- package/dist/db/cloud.d.ts +16 -8
- package/dist/db/cloud.d.ts.map +1 -1
- package/dist/db/database.d.ts +19 -0
- package/dist/db/database.d.ts.map +1 -1
- package/dist/index.js +198 -19
- package/dist/ingest/claude.d.ts.map +1 -1
- package/dist/ingest/loops.d.ts +9 -0
- package/dist/ingest/loops.d.ts.map +1 -1
- package/dist/lib/accounts-store.d.ts +83 -0
- package/dist/lib/accounts-store.d.ts.map +1 -0
- package/dist/lib/accounts.d.ts +2 -1
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/api-display-url.d.ts +19 -0
- package/dist/lib/api-display-url.d.ts.map +1 -0
- package/dist/lib/autosync-gate.d.ts +15 -0
- package/dist/lib/autosync-gate.d.ts.map +1 -0
- package/dist/lib/cloud-ingest.d.ts +15 -1
- package/dist/lib/cloud-ingest.d.ts.map +1 -1
- package/dist/lib/cloud-storage.d.ts +166 -10
- package/dist/lib/cloud-storage.d.ts.map +1 -1
- package/dist/lib/gatherer.d.ts.map +1 -1
- package/dist/lib/serve-auth.d.ts.map +1 -1
- package/dist/lib/store/index.d.ts +6 -3
- package/dist/lib/store/index.d.ts.map +1 -1
- package/dist/lib/test-hermetic-accounts.d.ts +3 -2
- package/dist/lib/test-hermetic-accounts.d.ts.map +1 -1
- package/dist/lib/test-hermetic-fleet-env.d.ts +4 -0
- package/dist/lib/test-hermetic-fleet-env.d.ts.map +1 -0
- package/dist/mcp/agent-registry.d.ts +85 -0
- package/dist/mcp/agent-registry.d.ts.map +1 -0
- package/dist/mcp/harness.d.ts +26 -0
- package/dist/mcp/harness.d.ts.map +1 -0
- package/dist/mcp/index.js +1340 -302
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/otel/index.js +430 -16
- package/dist/server/index.js +548 -155
- package/dist/server/serve.d.ts +0 -2
- package/dist/server/serve.d.ts.map +1 -1
- package/docs/cli.md +2 -3
- package/docs/configuration.md +23 -10
- package/docs/ingestion.md +1 -1
- package/docs/mcp.md +4 -2
- package/docs/otel.md +8 -2
- package/docs/rest-api.md +2 -2
- package/package.json +5 -11
- package/postinstall.js +52 -1
- package/dashboard/README.md +0 -26
- package/dist/cli/brains.d.ts +0 -3
- package/dist/cli/brains.d.ts.map +0 -1
package/dist/db/cloud.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { AuthQueryClient } from '@hasna/contracts/auth';
|
|
2
|
-
import type { ServerDataBackend } from '@hasna/contracts/schemas';
|
|
3
2
|
import pg from 'pg';
|
|
4
3
|
import type { DbAdapter, SqliteAdapter as Database } from './sqlite-adapter.js';
|
|
5
4
|
/** The environment shape the backend resolver reads. */
|
|
@@ -9,18 +8,27 @@ export declare function getCloudDatabaseUrl(env?: Env): string | undefined;
|
|
|
9
8
|
/**
|
|
10
9
|
* Resolve the server data backend from database configuration ALONE.
|
|
11
10
|
*
|
|
12
|
-
* `@hasna/contracts` 0.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
11
|
+
* `@hasna/contracts` 1.0.2 narrowed its published `ServerDataBackendSchema` to
|
|
12
|
+
* `z.literal("postgresql")` — SQLite is legacy-import input, never a LIVE
|
|
13
|
+
* backend, so the contract's health vocabulary only speaks the authoritative
|
|
14
|
+
* arm. Economy's serve still runs a real on-box SQLite backend in local mode,
|
|
15
|
+
* so the resolver keeps its own two-arm union and the runtime reports the
|
|
16
|
+
* honest backend on `/health` (the contract schema is asserted against the
|
|
17
|
+
* postgresql arm in `foundation-probe.contract.test.ts`).
|
|
18
|
+
*
|
|
19
|
+
* The retired deployment-mode axis stays gone: the only switch is the server's
|
|
20
|
+
* data backend, `sqlite | postgresql`, and a present database URL is what
|
|
21
|
+
* selects `postgresql`. Retired `STORAGE_MODE` / `MODE` variables are rejected
|
|
22
|
+
* with a migration hint rather than normalized or silently mapped, so a
|
|
23
|
+
* half-migrated deployment fails loudly at startup instead of quietly serving
|
|
24
|
+
* the wrong store.
|
|
18
25
|
*
|
|
19
26
|
* The rejection stays local because economy also honours the bare `DATABASE_URL`
|
|
20
27
|
* alias, which the contract's own resolver does not read — deferring to it
|
|
21
28
|
* wholesale would silently downgrade such a deployment to sqlite.
|
|
22
29
|
*/
|
|
23
|
-
export
|
|
30
|
+
export type EconomyServerBackend = 'sqlite' | 'postgresql';
|
|
31
|
+
export declare function resolveEconomyServerBackend(env?: Env): EconomyServerBackend;
|
|
24
32
|
/** True when the serve reads and writes PostgreSQL directly. */
|
|
25
33
|
export declare function isPostgresBackend(env?: Env): boolean;
|
|
26
34
|
/** HMAC signing secret for API-key verification (server-held, never in a token). */
|
package/dist/db/cloud.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../../src/db/cloud.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../../src/db/cloud.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAK/E,wDAAwD;AACxD,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;AAqB7C,8DAA8D;AAC9D,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,GAAiB,GAAG,MAAM,GAAG,SAAS,CAO9E;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,YAAY,CAAA;AAE1D,wBAAgB,2BAA2B,CAAC,GAAG,GAAE,GAAiB,GAAG,oBAAoB,CAGxF;AAED,gEAAgE;AAChE,wBAAgB,iBAAiB,CAAC,GAAG,GAAE,GAAiB,GAAG,OAAO,CAEjE;AAED,oFAAoF;AACpF,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,SAAS,CAOzD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,qBAAwB,GAAG,QAAQ,CASvE;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,GAAG,qBAAwB,GAAG,EAAE,CAAC,IAAI,CAWpE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,eAAe,CAcjE;AAED,+EAA+E;AAC/E,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAE1C;AAED,YAAY,EAAE,SAAS,EAAE,CAAA"}
|
package/dist/db/database.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { SqliteAdapter as Database } from './sqlite-adapter.js';
|
|
2
|
+
export type PathKind = "config" | "data" | "state" | "cache";
|
|
3
|
+
export interface PathsResolverOptions {
|
|
4
|
+
app: string;
|
|
5
|
+
internal?: boolean;
|
|
6
|
+
platform?: string;
|
|
7
|
+
home?: string;
|
|
8
|
+
env?: Record<string, string | undefined>;
|
|
9
|
+
}
|
|
10
|
+
export declare function dataDir(options: PathsResolverOptions): string;
|
|
11
|
+
/** The resolver (XDG / macOS) CACHE root for an app; `HASNA_CACHE_HOME` overrides it. */
|
|
12
|
+
export declare function cacheDir(options: PathsResolverOptions): string;
|
|
2
13
|
import type { EconomyRequest, EconomySession, EconomyProject, CostCenter, CostCenterBreakdown, CostCenterKind, Budget, BudgetStatus, CostSummary, ZeroCostModelBreakdown, ModelBreakdown, ProjectBreakdown, AgentBreakdown, AccountBreakdown, Period, Agent, SessionFilter } from '../types/index.js';
|
|
3
14
|
export declare function getMachineId(): string;
|
|
4
15
|
/**
|
|
@@ -104,6 +115,14 @@ export declare function deleteGoal(db: Database, id: string): void;
|
|
|
104
115
|
export declare function listGoals(db: Database): Goal[];
|
|
105
116
|
export declare function getGoalStatuses(db: Database): GoalStatus[];
|
|
106
117
|
export declare function getIngestState(db: Database, source: string, key: string): string | null;
|
|
118
|
+
/**
|
|
119
|
+
* Load every ingest_state row for one source into a Map. Ingest loops that
|
|
120
|
+
* check one key per corpus file (e.g. tens of thousands of session jsonl
|
|
121
|
+
* files) must use this instead of calling getIngestState per file — one
|
|
122
|
+
* prepared query per file turns an O(n) scan into an O(n) query blowup that
|
|
123
|
+
* dominates the whole ingest pass.
|
|
124
|
+
*/
|
|
125
|
+
export declare function loadIngestState(db: Database, source: string): Map<string, string>;
|
|
107
126
|
export declare function setIngestState(db: Database, source: string, key: string, value: string): void;
|
|
108
127
|
export declare function queryRequestsSince(db: Database, since: string): EconomyRequest[];
|
|
109
128
|
export interface FeedbackRecord {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAc/D,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAS7D,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,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AAO,mBAAmB,EAAE,aAAa,EAAE,IAAI,GAAG,YAAY,CAAC,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAChH,IAAI,CAON;AAED,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,QAAQ,EACZ,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC3D,OAAO,mBAAmB,EAAE,aAAa,EAAE,CAQ7C;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,mBAAmB,EAAE,eAAe,EAAE,CAE/F;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,CAqBnD;AAsJD,wBAAgB,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAuC3H"}
|
package/dist/index.js
CHANGED
|
@@ -594,7 +594,59 @@ import { copyFileSync, existsSync, mkdirSync, readdirSync, statSync } from "fs";
|
|
|
594
594
|
import { hostname, platform } from "os";
|
|
595
595
|
import { homedir } from "os";
|
|
596
596
|
import { join, resolve } from "path";
|
|
597
|
-
import {
|
|
597
|
+
import { homedir as pathsResolverHomedir } from "os";
|
|
598
|
+
import { join as pathsResolverJoin } from "path";
|
|
599
|
+
function pathsResolverAssertApp(app) {
|
|
600
|
+
if (typeof app !== "string" || app.length === 0) {
|
|
601
|
+
throw new TypeError("paths: app must be a non-empty string");
|
|
602
|
+
}
|
|
603
|
+
if (!PATHS_RESOLVER_APP_SLUG_RE.test(app)) {
|
|
604
|
+
throw new TypeError(`paths: invalid app slug "${app}" \u2014 expected lowercase kebab-case ([a-z0-9]+(-[a-z0-9]+)*)`);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
function pathsResolverAssertKind(kind) {
|
|
608
|
+
if (!Object.keys(PATHS_RESOLVER_KIND_ENV).includes(kind)) {
|
|
609
|
+
throw new TypeError(`paths: invalid path kind "${kind}" \u2014 expected one of ${Object.keys(PATHS_RESOLVER_KIND_ENV).join(", ")}`);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
function pathsResolverBaseDir(kind, options) {
|
|
613
|
+
pathsResolverAssertKind(kind);
|
|
614
|
+
const env = options.env ?? process.env;
|
|
615
|
+
const override = env[PATHS_RESOLVER_KIND_ENV[kind]];
|
|
616
|
+
if (typeof override === "string" && override.length > 0)
|
|
617
|
+
return override;
|
|
618
|
+
const home = options.home ?? pathsResolverHomedir();
|
|
619
|
+
const platform2 = options.platform ?? process.platform;
|
|
620
|
+
if (platform2 === "darwin") {
|
|
621
|
+
switch (kind) {
|
|
622
|
+
case "config":
|
|
623
|
+
case "data":
|
|
624
|
+
return pathsResolverJoin(home, "Library", "Application Support", "Hasna");
|
|
625
|
+
case "cache":
|
|
626
|
+
return pathsResolverJoin(home, "Library", "Caches", "Hasna");
|
|
627
|
+
case "state":
|
|
628
|
+
return pathsResolverJoin(home, "Library", "Logs", "Hasna");
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
switch (kind) {
|
|
632
|
+
case "config":
|
|
633
|
+
return pathsResolverJoin(home, ".config", "hasna");
|
|
634
|
+
case "data":
|
|
635
|
+
return pathsResolverJoin(home, ".local", "share", "hasna");
|
|
636
|
+
case "state":
|
|
637
|
+
return pathsResolverJoin(home, ".local", "state", "hasna");
|
|
638
|
+
case "cache":
|
|
639
|
+
return pathsResolverJoin(home, ".cache", "hasna");
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
function pathsResolverResolve(kind, options) {
|
|
643
|
+
pathsResolverAssertApp(options.app);
|
|
644
|
+
const appSegment = options.internal === true ? pathsResolverJoin("internal", options.app) : options.app;
|
|
645
|
+
return pathsResolverJoin(pathsResolverBaseDir(kind, options), appSegment);
|
|
646
|
+
}
|
|
647
|
+
function dataDir(options) {
|
|
648
|
+
return pathsResolverResolve("data", options);
|
|
649
|
+
}
|
|
598
650
|
function normalizeMachineId(value) {
|
|
599
651
|
const id = value?.trim().toLowerCase().split(".")[0];
|
|
600
652
|
return id && id.length > 0 ? id : null;
|
|
@@ -617,7 +669,7 @@ function macHostMachineId() {
|
|
|
617
669
|
return null;
|
|
618
670
|
}
|
|
619
671
|
function getMachineId() {
|
|
620
|
-
const envMachine = normalizeMachineId(process.env["
|
|
672
|
+
const envMachine = normalizeMachineId(process.env["HASNA_ECONOMY_MACHINE_ID"]);
|
|
621
673
|
if (envMachine)
|
|
622
674
|
return envMachine;
|
|
623
675
|
const hostMachine = normalizeMachineId(hostname()) ?? "unknown";
|
|
@@ -1990,8 +2042,16 @@ function queryUsageSnapshots(db, opts = {}) {
|
|
|
1990
2042
|
function listMachineRegistry(db) {
|
|
1991
2043
|
return db.prepare(`SELECT * FROM machines ORDER BY last_seen_at DESC`).all();
|
|
1992
2044
|
}
|
|
2045
|
+
var PATHS_RESOLVER_KIND_ENV, PATHS_RESOLVER_APP_SLUG_RE;
|
|
1993
2046
|
var init_database = __esm(() => {
|
|
1994
2047
|
init_sqlite_adapter();
|
|
2048
|
+
PATHS_RESOLVER_KIND_ENV = {
|
|
2049
|
+
config: "HASNA_CONFIG_HOME",
|
|
2050
|
+
data: "HASNA_DATA_HOME",
|
|
2051
|
+
state: "HASNA_STATE_HOME",
|
|
2052
|
+
cache: "HASNA_CACHE_HOME"
|
|
2053
|
+
};
|
|
2054
|
+
PATHS_RESOLVER_APP_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
1995
2055
|
});
|
|
1996
2056
|
|
|
1997
2057
|
// src/lib/agents.ts
|
|
@@ -2021,8 +2081,8 @@ import { randomUUID } from "crypto";
|
|
|
2021
2081
|
// package.json
|
|
2022
2082
|
var package_default = {
|
|
2023
2083
|
name: "@hasna/economy",
|
|
2024
|
-
version: "0.
|
|
2025
|
-
description: "AI coding cost tracker \u2014 CLI + MCP server + REST API
|
|
2084
|
+
version: "0.4.0",
|
|
2085
|
+
description: "AI coding cost tracker \u2014 CLI + MCP server + REST API for Claude Code, Codex, OpenCode, Cursor, Pi, and Hermes, with legacy Gemini CLI session and Gemini API billing ingestion",
|
|
2026
2086
|
repository: {
|
|
2027
2087
|
type: "git",
|
|
2028
2088
|
url: "git+https://github.com/hasna/economy.git"
|
|
@@ -2053,7 +2113,6 @@ var package_default = {
|
|
|
2053
2113
|
files: [
|
|
2054
2114
|
"dist",
|
|
2055
2115
|
"docs",
|
|
2056
|
-
"dashboard/dist",
|
|
2057
2116
|
"postinstall.js",
|
|
2058
2117
|
"LICENSE",
|
|
2059
2118
|
"README.md",
|
|
@@ -2063,12 +2122,11 @@ var package_default = {
|
|
|
2063
2122
|
"CODE_OF_CONDUCT.md"
|
|
2064
2123
|
],
|
|
2065
2124
|
scripts: {
|
|
2066
|
-
build: "
|
|
2125
|
+
build: "bun build src/cli/index.ts --outdir dist/cli --target bun --packages external && bun build src/mcp/index.ts --outdir dist/mcp --target bun --packages external && bun build src/server/index.ts --outdir dist/server --target bun --packages external && bun build src/db/pg-sync-worker.ts --outdir dist/server --target bun --packages external && bun build src/otel/index.ts --outdir dist/otel --target bun --packages external && bun build src/index.ts --outdir dist --target bun --packages external && tsc --emitDeclarationOnly --outDir dist",
|
|
2067
2126
|
"build:cli": "bun build src/cli/index.ts --outdir dist/cli --target bun --packages external",
|
|
2068
2127
|
"build:mcp": "bun build src/mcp/index.ts --outdir dist/mcp --target bun --packages external",
|
|
2069
2128
|
"build:server": "bun build src/server/index.ts --outdir dist/server --target bun --packages external",
|
|
2070
2129
|
"build:lib": "bun build src/index.ts --outdir dist --target bun --packages external",
|
|
2071
|
-
"build:dashboard": "cd dashboard && bun run build",
|
|
2072
2130
|
"artifact-scan": "bun scripts/contracts-cli.mjs artifact-scan dist",
|
|
2073
2131
|
prepack: "bun run build && bun run artifact-scan",
|
|
2074
2132
|
typecheck: "tsc --noEmit",
|
|
@@ -2098,12 +2156,8 @@ var package_default = {
|
|
|
2098
2156
|
access: "public"
|
|
2099
2157
|
},
|
|
2100
2158
|
dependencies: {
|
|
2101
|
-
"@hasna/
|
|
2102
|
-
"@hasna/agent-registry": "^0.1.0",
|
|
2103
|
-
"@hasna/contracts": "0.13.4",
|
|
2159
|
+
"@hasna/contracts": "1.0.2",
|
|
2104
2160
|
"@hasna/events": "^0.1.16",
|
|
2105
|
-
"@hasna/mcp-harness": "^0.1.0",
|
|
2106
|
-
"@hasna/paths": "0.1.0",
|
|
2107
2161
|
"@hasna/projects": "1.0.0",
|
|
2108
2162
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
2109
2163
|
chalk: "^5.4.1",
|
|
@@ -2112,7 +2166,7 @@ var package_default = {
|
|
|
2112
2166
|
zod: "^3.24.2"
|
|
2113
2167
|
},
|
|
2114
2168
|
devDependencies: {
|
|
2115
|
-
"@types/bun": "
|
|
2169
|
+
"@types/bun": "1.3.14",
|
|
2116
2170
|
"@types/pg": "^8.20.0",
|
|
2117
2171
|
"bun-types": "latest",
|
|
2118
2172
|
typescript: "^5.7.2"
|
|
@@ -3099,19 +3153,144 @@ function queryModelEfficiency(db) {
|
|
|
3099
3153
|
FROM requests GROUP BY model ORDER BY cost DESC`).all();
|
|
3100
3154
|
}
|
|
3101
3155
|
|
|
3102
|
-
// src/lib/contracts-client/storage.ts
|
|
3103
|
-
import { resolveStorageClient } from "@hasna/contracts/client/storage";
|
|
3104
|
-
|
|
3105
3156
|
// src/lib/cloud-storage.ts
|
|
3157
|
+
import {
|
|
3158
|
+
appConfigDiskValue,
|
|
3159
|
+
ClientTransportConfigurationError,
|
|
3160
|
+
clientTransportEnvKeys,
|
|
3161
|
+
createClientTransport,
|
|
3162
|
+
credentialDiskSources,
|
|
3163
|
+
credentialOverrideEnvKey,
|
|
3164
|
+
credentialPointerEnvKey,
|
|
3165
|
+
CREDENTIAL_PROFILE_ENV_KEY,
|
|
3166
|
+
keychainConfigValue
|
|
3167
|
+
} from "@hasna/contracts/client";
|
|
3168
|
+
import { createHasnaStorageClient } from "@hasna/contracts/client/storage";
|
|
3106
3169
|
var ECONOMY_APP = "economy";
|
|
3170
|
+
var RETIRED_STORAGE_MODE_KEYS = [
|
|
3171
|
+
"HASNA_ECONOMY_STORAGE_MODE",
|
|
3172
|
+
"HASNA_ECONOMY_MODE",
|
|
3173
|
+
"ECONOMY_STORAGE_MODE",
|
|
3174
|
+
"ECONOMY_MODE"
|
|
3175
|
+
];
|
|
3176
|
+
function assertNoRetiredStorageMode(env) {
|
|
3177
|
+
const legacyKey = RETIRED_STORAGE_MODE_KEYS.find((key) => Object.hasOwn(env, key) && env[key] !== undefined);
|
|
3178
|
+
if (!legacyKey)
|
|
3179
|
+
return;
|
|
3180
|
+
throw new Error(`${legacyKey} was removed. Deployment modes no longer exist: delete the storage-mode variable. ` + `The client routes through the HTTP API resolved by @hasna/contracts ` + `(HASNA_ECONOMY_API_URL + HASNA_ECONOMY_API_KEY, the Keychain, or ` + `~/.hasna/economy/config/credentials), or serves the local SQLite store only when ` + `HASNA_ECONOMY_LOCAL=1 is set.`);
|
|
3181
|
+
}
|
|
3182
|
+
var LOCAL_STORAGE_OPT_IN_KEYS = ["HASNA_ECONOMY_LOCAL", "ECONOMY_LOCAL"];
|
|
3183
|
+
function envFlagSet(env, key) {
|
|
3184
|
+
const raw = env[key];
|
|
3185
|
+
if (raw === undefined)
|
|
3186
|
+
return false;
|
|
3187
|
+
const value = raw.trim().toLowerCase();
|
|
3188
|
+
return value !== "" && value !== "0" && value !== "false" && value !== "no" && value !== "off";
|
|
3189
|
+
}
|
|
3190
|
+
function localStorageExplicitlyOptedIn(env) {
|
|
3191
|
+
return LOCAL_STORAGE_OPT_IN_KEYS.some((key) => envFlagSet(env, key));
|
|
3192
|
+
}
|
|
3193
|
+
function economyAuthorityEnvKeys() {
|
|
3194
|
+
const keys = clientTransportEnvKeys(ECONOMY_APP);
|
|
3195
|
+
return [
|
|
3196
|
+
...keys.apiUrlKeys,
|
|
3197
|
+
...keys.apiKeyKeys,
|
|
3198
|
+
credentialOverrideEnvKey(ECONOMY_APP),
|
|
3199
|
+
credentialPointerEnvKey(ECONOMY_APP),
|
|
3200
|
+
CREDENTIAL_PROFILE_ENV_KEY
|
|
3201
|
+
];
|
|
3202
|
+
}
|
|
3203
|
+
function hasEconomyEnvAuthorityIntent(env) {
|
|
3204
|
+
return economyAuthorityEnvKeys().some((key) => (env[key] ?? "").trim().length > 0);
|
|
3205
|
+
}
|
|
3206
|
+
function hostedAuthorityConfigured(env, options = {}) {
|
|
3207
|
+
const keys = clientTransportEnvKeys(ECONOMY_APP);
|
|
3208
|
+
if (keys.apiUrlKeys.some((key) => (env[key] ?? "").trim().length > 0))
|
|
3209
|
+
return true;
|
|
3210
|
+
if (keychainConfigValue(ECONOMY_APP, env, options.credentials?.keychain) !== null)
|
|
3211
|
+
return true;
|
|
3212
|
+
return appConfigDiskValue(ECONOMY_APP, env, keys.apiUrlKeys) !== null;
|
|
3213
|
+
}
|
|
3214
|
+
function economyResolverEnv(env) {
|
|
3215
|
+
const blanks = economyAuthorityEnvKeys().filter((key) => (key in env) && (env[key] ?? "").trim() === "");
|
|
3216
|
+
if (blanks.length === 0)
|
|
3217
|
+
return env;
|
|
3218
|
+
const next = { ...env };
|
|
3219
|
+
for (const key of blanks)
|
|
3220
|
+
delete next[key];
|
|
3221
|
+
return next;
|
|
3222
|
+
}
|
|
3223
|
+
var CONTRACTS_AMBIENT_ENVIRONMENT = Symbol.for("hasna:contracts:ambientClientEnvironment");
|
|
3224
|
+
function isAmbientEconomyEnv(env) {
|
|
3225
|
+
if (typeof process !== "undefined" && env === process.env)
|
|
3226
|
+
return true;
|
|
3227
|
+
return env[CONTRACTS_AMBIENT_ENVIRONMENT] === true;
|
|
3228
|
+
}
|
|
3229
|
+
function economyResolverInputs(env, credentials = {}) {
|
|
3230
|
+
const normalised = economyResolverEnv(env);
|
|
3231
|
+
if (normalised === env)
|
|
3232
|
+
return { env: normalised, credentials };
|
|
3233
|
+
const keychain = { ...credentials.keychain };
|
|
3234
|
+
if (keychain.enabled === undefined && keychain.run === undefined) {
|
|
3235
|
+
keychain.enabled = isAmbientEconomyEnv(env);
|
|
3236
|
+
}
|
|
3237
|
+
return { env: normalised, credentials: { ...credentials, keychain } };
|
|
3238
|
+
}
|
|
3239
|
+
function resolveEconomyStorageClient(name, env, overrides = {}) {
|
|
3240
|
+
const { env: resolverEnv, credentials } = economyResolverInputs(env, overrides.credentials);
|
|
3241
|
+
const wired = createClientTransport(name, resolverEnv, {
|
|
3242
|
+
credentials,
|
|
3243
|
+
...overrides.fetchImpl ? { fetchImpl: overrides.fetchImpl } : {},
|
|
3244
|
+
...overrides.headers ? { headers: overrides.headers } : {},
|
|
3245
|
+
...overrides.timeoutMs ? { timeoutMs: overrides.timeoutMs } : {},
|
|
3246
|
+
...overrides.retry !== undefined ? { retry: overrides.retry } : {},
|
|
3247
|
+
...overrides.sleepImpl ? { sleepImpl: overrides.sleepImpl } : {}
|
|
3248
|
+
});
|
|
3249
|
+
return {
|
|
3250
|
+
transport: "http",
|
|
3251
|
+
client: createHasnaStorageClient(name, wired.client),
|
|
3252
|
+
resolution: wired.resolution
|
|
3253
|
+
};
|
|
3254
|
+
}
|
|
3255
|
+
function localEconomyNotice() {
|
|
3256
|
+
return `economy: local mode (${LOCAL_STORAGE_OPT_IN_KEYS[0]}=1) \u2014 reading and writing the on-box ` + `SQLite store, not the hosted fleet. Data in the shared economy API is NOT included.`;
|
|
3257
|
+
}
|
|
3258
|
+
function credentialRequiredError(env, cause) {
|
|
3259
|
+
const keys = clientTransportEnvKeys(ECONOMY_APP);
|
|
3260
|
+
const clientEnv = env;
|
|
3261
|
+
const detail = cause instanceof Error ? cause.message : `No API key could be resolved for '${ECONOMY_APP}'. Looked in the Keychain (macOS only), ` + `then for a credential file at ${credentialDiskSources(ECONOMY_APP, clientEnv).join(" or ") || "<no HOME set>"}, ` + `then for ${keys.apiKeyKeys[0]} in the environment.`;
|
|
3262
|
+
const wayOut = hostedAuthorityConfigured(clientEnv) ? `${keys.apiUrlKeys[0]} (or the Keychain hasna.credentials.${ECONOMY_APP}.api-url item, or ` + `~/.hasna/${ECONOMY_APP}/config/credentials) selects a hosted service, so ${LOCAL_STORAGE_OPT_IN_KEYS[0]} ` + `does not apply; unset the authority to use the local store.` : `Or set ${LOCAL_STORAGE_OPT_IN_KEYS[0]}=1 to explicitly opt into the local store.`;
|
|
3263
|
+
return new Error(`Economy fails closed instead of silently serving the local SQLite store: ${detail} ` + `Set ${keys.apiUrlKeys[0]} and ${keys.apiKeyKeys[0]} (or store the key in the Keychain item ` + `hasna.credentials.${ECONOMY_APP}.api-key, or in ~/.hasna/${ECONOMY_APP}/config/credentials) to use the ` + `hosted economy API at ${keys.apiUrlKeys[0]} or the default fleet gateway. ` + wayOut);
|
|
3264
|
+
}
|
|
3107
3265
|
var cache;
|
|
3266
|
+
var localNoticePrinted = false;
|
|
3108
3267
|
function resolveEconomyCloudStorage(env = process.env, overrides) {
|
|
3109
|
-
|
|
3110
|
-
|
|
3268
|
+
assertNoRetiredStorageMode(env);
|
|
3269
|
+
const clientEnv = env;
|
|
3270
|
+
if (localStorageExplicitlyOptedIn(env) && !hasEconomyEnvAuthorityIntent(clientEnv)) {
|
|
3271
|
+
return { active: false, client: null };
|
|
3272
|
+
}
|
|
3273
|
+
let resolved;
|
|
3274
|
+
try {
|
|
3275
|
+
resolved = resolveEconomyStorageClient(ECONOMY_APP, clientEnv, overrides ?? {});
|
|
3276
|
+
} catch (error) {
|
|
3277
|
+
if (error instanceof ClientTransportConfigurationError) {
|
|
3278
|
+
throw credentialRequiredError(env, error);
|
|
3279
|
+
}
|
|
3280
|
+
throw error;
|
|
3281
|
+
}
|
|
3282
|
+
return { active: true, client: resolved.client };
|
|
3111
3283
|
}
|
|
3112
3284
|
function economyCloudStorage(env = process.env) {
|
|
3113
|
-
if (cache === undefined)
|
|
3285
|
+
if (cache === undefined) {
|
|
3114
3286
|
cache = resolveEconomyCloudStorage(env);
|
|
3287
|
+
if (!cache.active && !localNoticePrinted) {
|
|
3288
|
+
localNoticePrinted = true;
|
|
3289
|
+
if (typeof process !== "undefined")
|
|
3290
|
+
process.stderr.write(`${localEconomyNotice()}
|
|
3291
|
+
`);
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3115
3294
|
return cache;
|
|
3116
3295
|
}
|
|
3117
3296
|
function cleanQuery(query) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/ingest/claude.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAYxE,OAAO,KAAK,EAAkB,KAAK,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/ingest/claude.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAYxE,OAAO,KAAK,EAAkB,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAiE9D,wBAAsB,YAAY,CAChC,EAAE,EAAE,QAAQ,EACZ,OAAO,UAAQ,EACf,WAAW,SAAsB,GAChC,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAEhE;AAED,wBAAsB,YAAY,CAChC,EAAE,EAAE,QAAQ,EACZ,OAAO,UAAQ,EACf,WAAW,SAAsB,GAChC,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAEhE;AAED,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,QAAQ,EACZ,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,KAAK,EAChB,OAAO,UAAQ,GACd,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA8IhE"}
|
package/dist/ingest/loops.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export type PathKind = "config" | "data" | "state" | "cache";
|
|
2
|
+
export interface PathsResolverOptions {
|
|
3
|
+
app: string;
|
|
4
|
+
internal?: boolean;
|
|
5
|
+
platform?: string;
|
|
6
|
+
home?: string;
|
|
7
|
+
env?: Record<string, string | undefined>;
|
|
8
|
+
}
|
|
9
|
+
export declare function dataDir(options: PathsResolverOptions): string;
|
|
1
10
|
import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
|
|
2
11
|
/**
|
|
3
12
|
* The default OpenLoops store path, resolved through the @hasna/paths resolver
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loops.d.ts","sourceRoot":"","sources":["../../src/ingest/loops.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loops.d.ts","sourceRoot":"","sources":["../../src/ingest/loops.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAS7D,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC1C;AA0DD,wBAAgB,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAE7D;AACD,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAiCxE;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAc3C;AAED,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAwGD,wBAAsB,WAAW,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,UAAQ,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA+FhH"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type CredentialChainOptions } from '@hasna/contracts/client';
|
|
3
|
+
/** Test injection for the accounts credential chain (keychain runner, tier-1 key). */
|
|
4
|
+
export interface ResolveAccountsStoreOptions {
|
|
5
|
+
credentials?: CredentialChainOptions;
|
|
6
|
+
}
|
|
7
|
+
/** Minimal profile record — the fields economy's attribution reads. */
|
|
8
|
+
declare const profileSchema: z.ZodObject<{
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
tool: z.ZodString;
|
|
11
|
+
email: z.ZodOptional<z.ZodString>;
|
|
12
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
13
|
+
dir: z.ZodString;
|
|
14
|
+
description: z.ZodOptional<z.ZodString>;
|
|
15
|
+
createdAt: z.ZodString;
|
|
16
|
+
lastUsedAt: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
name: string;
|
|
19
|
+
tool: string;
|
|
20
|
+
dir: string;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
description?: string | undefined;
|
|
23
|
+
email?: string | undefined;
|
|
24
|
+
displayName?: string | undefined;
|
|
25
|
+
lastUsedAt?: string | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
name: string;
|
|
28
|
+
tool: string;
|
|
29
|
+
dir: string;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
description?: string | undefined;
|
|
32
|
+
email?: string | undefined;
|
|
33
|
+
displayName?: string | undefined;
|
|
34
|
+
lastUsedAt?: string | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
/** Minimal tool definition — economy reads `id` and `envVar` (dir matching). */
|
|
37
|
+
declare const toolDefSchema: z.ZodObject<{
|
|
38
|
+
id: z.ZodString;
|
|
39
|
+
label: z.ZodString;
|
|
40
|
+
envVar: z.ZodString;
|
|
41
|
+
defaultDir: z.ZodString;
|
|
42
|
+
bin: z.ZodString;
|
|
43
|
+
}, "strip", z.ZodTypeAny, {
|
|
44
|
+
label: string;
|
|
45
|
+
id: string;
|
|
46
|
+
envVar: string;
|
|
47
|
+
defaultDir: string;
|
|
48
|
+
bin: string;
|
|
49
|
+
}, {
|
|
50
|
+
label: string;
|
|
51
|
+
id: string;
|
|
52
|
+
envVar: string;
|
|
53
|
+
defaultDir: string;
|
|
54
|
+
bin: string;
|
|
55
|
+
}>;
|
|
56
|
+
export type Profile = z.infer<typeof profileSchema>;
|
|
57
|
+
export type ToolDef = z.infer<typeof toolDefSchema>;
|
|
58
|
+
/**
|
|
59
|
+
* The minimal store surface economy uses for attribution. Both transports
|
|
60
|
+
* (local JSON and accounts-serve API) implement it.
|
|
61
|
+
*/
|
|
62
|
+
export interface AccountsStore {
|
|
63
|
+
readonly transport: 'local' | 'api';
|
|
64
|
+
listProfiles(tool?: string): Promise<Profile[]>;
|
|
65
|
+
findProfile(name: string, tool?: string): Promise<Profile | undefined>;
|
|
66
|
+
currentProfile(tool: string): Promise<Profile | undefined>;
|
|
67
|
+
listTools(): Promise<ToolDef[]>;
|
|
68
|
+
}
|
|
69
|
+
/** The profile name last applied to a tool's live default paths, if any. */
|
|
70
|
+
export declare function appliedProfileName(toolId: string): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Resolve the active registry store for this process — the credential chain
|
|
73
|
+
* alone: the API transport when `@hasna/contracts` resolves an accounts
|
|
74
|
+
* credential for this environment (env `HASNA_ACCOUNTS_API_KEY` / legacy
|
|
75
|
+
* `ACCOUNTS_API_KEY`, the accounts credentials file, or the Keychain, with the
|
|
76
|
+
* authority defaulted to the fleet gateway `https://api.hasna.com/accounts`),
|
|
77
|
+
* else the local JSON registry. Retired `*_STORAGE_MODE` / `*_MODE` variables
|
|
78
|
+
* are a hard error so a half-migrated deployment fails loudly instead of
|
|
79
|
+
* silently reading the wrong dataset.
|
|
80
|
+
*/
|
|
81
|
+
export declare function resolveStore(env?: NodeJS.ProcessEnv, options?: ResolveAccountsStoreOptions): AccountsStore;
|
|
82
|
+
export {};
|
|
83
|
+
//# sourceMappingURL=accounts-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts-store.d.ts","sourceRoot":"","sources":["../../src/lib/accounts-store.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAA6C,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAKhH,sFAAsF;AACtF,MAAM,WAAW,2BAA2B;IAC1C,WAAW,CAAC,EAAE,sBAAsB,CAAA;CACrC;AAKD,uEAAuE;AACvE,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;EASjB,CAAA;AAEF,gFAAgF;AAChF,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;EAMjB,CAAA;AAYF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AACnD,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AAEnD;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,GAAG,KAAK,CAAA;IACnC,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC/C,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAA;IACtE,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAAA;IAC1D,SAAS,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;CAChC;AAqDD,4EAA4E;AAC5E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAErE;AA4PD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,OAAO,GAAE,2BAAgC,GACxC,aAAa,CAiBf"}
|
package/dist/lib/accounts.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ResolveAccountsStoreOptions } from './accounts-store.js';
|
|
1
2
|
import type { Agent } from './agents.js';
|
|
2
3
|
export interface AccountAttribution {
|
|
3
4
|
account_key: string;
|
|
@@ -6,6 +7,6 @@ export interface AccountAttribution {
|
|
|
6
7
|
account_email?: string;
|
|
7
8
|
account_source: 'override' | 'env' | 'applied' | 'current';
|
|
8
9
|
}
|
|
9
|
-
export declare function resolveAccountForAgent(agent: Agent, env?: NodeJS.ProcessEnv): Promise<AccountAttribution | null>;
|
|
10
|
+
export declare function resolveAccountForAgent(agent: Agent, env?: NodeJS.ProcessEnv, options?: ResolveAccountsStoreOptions): Promise<AccountAttribution | null>;
|
|
10
11
|
export declare function withAccount<T extends object>(record: T, account: AccountAttribution | null): T & Partial<AccountAttribution>;
|
|
11
12
|
//# sourceMappingURL=accounts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/lib/accounts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/lib/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,2BAA2B,EAAE,MAAM,qBAAqB,CAAA;AAExG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,UAAU,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,CAAA;CAC3D;AAqFD,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,KAAK,EACZ,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAwBpC;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAC1C,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,kBAAkB,GAAG,IAAI,GACjC,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAUjC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display-URL normalization for the Hasna API gateway (issue #1588).
|
|
3
|
+
*
|
|
4
|
+
* The station wrappers and Keychain configure the gateway form
|
|
5
|
+
* `https://api.hasna.com/<app>` (no `/v1`); requests go to
|
|
6
|
+
* `https://api.hasna.com/<app>/v1/...`. Status and whoami surfaces must
|
|
7
|
+
* therefore print the RESOLVED `/v1` root — never a bare base URL and never
|
|
8
|
+
* the origin alone (which no longer even identifies the app behind the shared
|
|
9
|
+
* gateway).
|
|
10
|
+
*
|
|
11
|
+
* Normalization is intentionally limited to the gateway form. Legacy origins
|
|
12
|
+
* (`https://<app>.hasna.xyz`, allowed for todos until hasna/apps#1512 ships)
|
|
13
|
+
* and self-hosted/custom endpoints keep the caller's existing display behavior:
|
|
14
|
+
* this helper returns `null` for anything that is not
|
|
15
|
+
* `https://api.hasna.com/<app>` or the already-resolved
|
|
16
|
+
* `https://api.hasna.com/<app>/v1`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function gatewayApiV1Root(raw: string | null | undefined): string | null;
|
|
19
|
+
//# sourceMappingURL=api-display-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-display-url.d.ts","sourceRoot":"","sources":["../../src/lib/api-display-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAwB9E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
|
|
2
|
+
export declare const AUTOSYNC_STATE_SOURCE = "autosync";
|
|
3
|
+
export declare const AUTOSYNC_STATE_KEY = "last_run";
|
|
4
|
+
export declare const DEFAULT_AUTOSYNC_INTERVAL_MS: number;
|
|
5
|
+
/** The auto-sync interval in ms: env seconds, 0 = always sync, default 10 min. */
|
|
6
|
+
export declare function autosyncIntervalMs(env?: NodeJS.ProcessEnv): number;
|
|
7
|
+
/** The store that holds the autosync marker: the ingest cache in hosted mode, the local db otherwise. */
|
|
8
|
+
export declare function autosyncMarkerStore(env?: NodeJS.ProcessEnv): Database;
|
|
9
|
+
/** Epoch ms of the last auto-sync, or 0 when the store has never auto-synced. */
|
|
10
|
+
export declare function autosyncLastRun(db?: Database, env?: NodeJS.ProcessEnv): number;
|
|
11
|
+
/** Record that an auto-sync just completed. */
|
|
12
|
+
export declare function markAutoSync(db?: Database, env?: NodeJS.ProcessEnv): void;
|
|
13
|
+
/** Whether the auto-sync should run now: always when the interval is 0, otherwise at most once per interval. */
|
|
14
|
+
export declare function autoSyncDue(db?: Database, env?: NodeJS.ProcessEnv): boolean;
|
|
15
|
+
//# sourceMappingURL=autosync-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autosync-gate.d.ts","sourceRoot":"","sources":["../../src/lib/autosync-gate.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAExE,eAAO,MAAM,qBAAqB,aAAa,CAAA;AAC/C,eAAO,MAAM,kBAAkB,aAAa,CAAA;AAC5C,eAAO,MAAM,4BAA4B,QAAc,CAAA;AAEvD,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAM/E;AAED,yGAAyG;AACzG,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,QAAQ,CAGlF;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAK3F;AAED,+CAA+C;AAC/C,wBAAgB,YAAY,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,IAAI,CAGtF;AAED,gHAAgH;AAChH,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAIxF"}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
import type { SqliteAdapter as Database } from '../db/sqlite-adapter.js';
|
|
1
2
|
import type { SyncAllResult } from './sync-all.js';
|
|
2
3
|
import type { ActiveEconomyCloudStorage } from './cloud-storage.js';
|
|
3
4
|
import type { SyncOptions } from '../types/index.js';
|
|
4
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Machine-local mtime cache path: `HASNA_ECONOMY_INGEST_CACHE` when set, else
|
|
7
|
+
* `<cache root>/economy/ingest-cache.json`. Never under the app data home.
|
|
8
|
+
*/
|
|
5
9
|
export declare function getIngestCachePath(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Push every ingest-table row a scratch store holds to the shared API. The
|
|
12
|
+
* economy-otel sidecar uses this in hosted mode: same readers, same
|
|
13
|
+
* idempotent /v1/ingest upserts, no SQLite under the app home.
|
|
14
|
+
*/
|
|
15
|
+
export declare function pushIngestRows(cloud: ActiveEconomyCloudStorage, scratch: Database): Promise<{
|
|
16
|
+
posted: boolean;
|
|
17
|
+
ingested: Record<string, number>;
|
|
18
|
+
total: number;
|
|
19
|
+
}>;
|
|
6
20
|
export interface CloudSyncOptions extends SyncOptions {
|
|
7
21
|
/** Claude/Takumi JSONL root override (tests). */
|
|
8
22
|
projectsDir?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-ingest.d.ts","sourceRoot":"","sources":["../../src/lib/cloud-ingest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cloud-ingest.d.ts","sourceRoot":"","sources":["../../src/lib/cloud-ingest.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAGxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAA;AAGnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAKpD;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAI3C;AA0FD;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,yBAAyB,EAChC,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAK/E;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,iDAAiD;IACjD,WAAW,CA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