@hasna/economy 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/CHANGELOG.md +33 -4
  2. package/README.md +28 -61
  3. package/dashboard/README.md +17 -64
  4. package/docs/README.md +12 -0
  5. package/docs/cli.md +88 -0
  6. package/docs/configuration.md +88 -0
  7. package/docs/ingestion.md +47 -0
  8. package/docs/mcp.md +65 -0
  9. package/docs/otel.md +53 -0
  10. package/docs/rest-api.md +89 -0
  11. package/package.json +6 -7
  12. package/dist/cli/brains.d.ts +0 -3
  13. package/dist/cli/brains.d.ts.map +0 -1
  14. package/dist/cli/commands/brief.d.ts +0 -11
  15. package/dist/cli/commands/brief.d.ts.map +0 -1
  16. package/dist/cli/commands/completion.d.ts +0 -2
  17. package/dist/cli/commands/completion.d.ts.map +0 -1
  18. package/dist/cli/commands/extras.d.ts +0 -4
  19. package/dist/cli/commands/extras.d.ts.map +0 -1
  20. package/dist/cli/commands/menubar.d.ts +0 -7
  21. package/dist/cli/commands/menubar.d.ts.map +0 -1
  22. package/dist/cli/commands/notification.d.ts +0 -8
  23. package/dist/cli/commands/notification.d.ts.map +0 -1
  24. package/dist/cli/commands/todos.d.ts +0 -29
  25. package/dist/cli/commands/todos.d.ts.map +0 -1
  26. package/dist/cli/commands/tui.d.ts +0 -26
  27. package/dist/cli/commands/tui.d.ts.map +0 -1
  28. package/dist/cli/commands/watch.d.ts +0 -10
  29. package/dist/cli/commands/watch.d.ts.map +0 -1
  30. package/dist/cli/index.d.ts +0 -3
  31. package/dist/cli/index.d.ts.map +0 -1
  32. package/dist/cli/index.js +0 -12304
  33. package/dist/db/cloud.d.ts +0 -28
  34. package/dist/db/cloud.d.ts.map +0 -1
  35. package/dist/db/database.d.ts +0 -150
  36. package/dist/db/database.d.ts.map +0 -1
  37. package/dist/db/pg-migrations.d.ts +0 -7
  38. package/dist/db/pg-migrations.d.ts.map +0 -1
  39. package/dist/db/pg-sync-worker.d.ts +0 -2
  40. package/dist/db/pg-sync-worker.d.ts.map +0 -1
  41. package/dist/db/sync-pg.d.ts +0 -43
  42. package/dist/db/sync-pg.d.ts.map +0 -1
  43. package/dist/index.d.ts +0 -3
  44. package/dist/index.d.ts.map +0 -1
  45. package/dist/index.js +0 -3729
  46. package/dist/ingest/billing.d.ts +0 -27
  47. package/dist/ingest/billing.d.ts.map +0 -1
  48. package/dist/ingest/claude-quota.d.ts +0 -5
  49. package/dist/ingest/claude-quota.d.ts.map +0 -1
  50. package/dist/ingest/claude.d.ts +0 -18
  51. package/dist/ingest/claude.d.ts.map +0 -1
  52. package/dist/ingest/codex-quota.d.ts +0 -5
  53. package/dist/ingest/codex-quota.d.ts.map +0 -1
  54. package/dist/ingest/codex.d.ts +0 -8
  55. package/dist/ingest/codex.d.ts.map +0 -1
  56. package/dist/ingest/cursor.d.ts +0 -6
  57. package/dist/ingest/cursor.d.ts.map +0 -1
  58. package/dist/ingest/gemini.d.ts +0 -6
  59. package/dist/ingest/gemini.d.ts.map +0 -1
  60. package/dist/ingest/hermes.d.ts +0 -6
  61. package/dist/ingest/hermes.d.ts.map +0 -1
  62. package/dist/ingest/loops.d.ts +0 -6
  63. package/dist/ingest/loops.d.ts.map +0 -1
  64. package/dist/ingest/opencode.d.ts +0 -7
  65. package/dist/ingest/opencode.d.ts.map +0 -1
  66. package/dist/ingest/otel.d.ts +0 -33
  67. package/dist/ingest/otel.d.ts.map +0 -1
  68. package/dist/ingest/pi.d.ts +0 -7
  69. package/dist/ingest/pi.d.ts.map +0 -1
  70. package/dist/ingest/plugin.d.ts +0 -17
  71. package/dist/ingest/plugin.d.ts.map +0 -1
  72. package/dist/lib/accounts.d.ts +0 -11
  73. package/dist/lib/accounts.d.ts.map +0 -1
  74. package/dist/lib/agents.d.ts +0 -11
  75. package/dist/lib/agents.d.ts.map +0 -1
  76. package/dist/lib/analytics.d.ts +0 -68
  77. package/dist/lib/analytics.d.ts.map +0 -1
  78. package/dist/lib/billing-diff.d.ts +0 -22
  79. package/dist/lib/billing-diff.d.ts.map +0 -1
  80. package/dist/lib/brief.d.ts +0 -72
  81. package/dist/lib/brief.d.ts.map +0 -1
  82. package/dist/lib/cloud-storage.d.ts +0 -48
  83. package/dist/lib/cloud-storage.d.ts.map +0 -1
  84. package/dist/lib/config.d.ts +0 -13
  85. package/dist/lib/config.d.ts.map +0 -1
  86. package/dist/lib/contracts-client/index.d.ts +0 -3
  87. package/dist/lib/contracts-client/index.d.ts.map +0 -1
  88. package/dist/lib/contracts-client/mode.d.ts +0 -20
  89. package/dist/lib/contracts-client/mode.d.ts.map +0 -1
  90. package/dist/lib/contracts-client/storage.d.ts +0 -83
  91. package/dist/lib/contracts-client/storage.d.ts.map +0 -1
  92. package/dist/lib/contracts-client/transport.d.ts +0 -148
  93. package/dist/lib/contracts-client/transport.d.ts.map +0 -1
  94. package/dist/lib/gatherer.d.ts +0 -21
  95. package/dist/lib/gatherer.d.ts.map +0 -1
  96. package/dist/lib/model-config.d.ts +0 -8
  97. package/dist/lib/model-config.d.ts.map +0 -1
  98. package/dist/lib/open-projects.d.ts +0 -19
  99. package/dist/lib/open-projects.d.ts.map +0 -1
  100. package/dist/lib/package-metadata.d.ts +0 -8
  101. package/dist/lib/package-metadata.d.ts.map +0 -1
  102. package/dist/lib/paths.d.ts +0 -20
  103. package/dist/lib/paths.d.ts.map +0 -1
  104. package/dist/lib/periods.d.ts +0 -6
  105. package/dist/lib/periods.d.ts.map +0 -1
  106. package/dist/lib/pricing.d.ts +0 -13
  107. package/dist/lib/pricing.d.ts.map +0 -1
  108. package/dist/lib/savings.d.ts +0 -17
  109. package/dist/lib/savings.d.ts.map +0 -1
  110. package/dist/lib/serve-auth.d.ts +0 -4
  111. package/dist/lib/serve-auth.d.ts.map +0 -1
  112. package/dist/lib/spikes.d.ts +0 -18
  113. package/dist/lib/spikes.d.ts.map +0 -1
  114. package/dist/lib/store/index.d.ts +0 -303
  115. package/dist/lib/store/index.d.ts.map +0 -1
  116. package/dist/lib/sync-all.d.ts +0 -28
  117. package/dist/lib/sync-all.d.ts.map +0 -1
  118. package/dist/lib/watch-paths.d.ts +0 -3
  119. package/dist/lib/watch-paths.d.ts.map +0 -1
  120. package/dist/lib/webhooks.d.ts +0 -3
  121. package/dist/lib/webhooks.d.ts.map +0 -1
  122. package/dist/mcp/http.d.ts +0 -14
  123. package/dist/mcp/http.d.ts.map +0 -1
  124. package/dist/mcp/index.d.ts +0 -3
  125. package/dist/mcp/index.d.ts.map +0 -1
  126. package/dist/mcp/index.js +0 -6193
  127. package/dist/mcp/server.d.ts +0 -4
  128. package/dist/mcp/server.d.ts.map +0 -1
  129. package/dist/openapi.d.ts +0 -3
  130. package/dist/openapi.d.ts.map +0 -1
  131. package/dist/otel/index.d.ts +0 -3
  132. package/dist/otel/index.d.ts.map +0 -1
  133. package/dist/otel/index.js +0 -1399
  134. package/dist/server/index.d.ts +0 -3
  135. package/dist/server/index.d.ts.map +0 -1
  136. package/dist/server/index.js +0 -7977
  137. package/dist/server/pg-sync-worker.js +0 -31
  138. package/dist/server/serve.d.ts +0 -42
  139. package/dist/server/serve.d.ts.map +0 -1
  140. package/dist/types/index.d.ts +0 -238
  141. package/dist/types/index.d.ts.map +0 -1
@@ -1,83 +0,0 @@
1
- import type { Env } from "./mode.js";
2
- import { createClientTransport, type HasnaHttpTransport, type HasnaRequestOptions, type QueryParams } from "./transport.js";
3
- /** Options for a list() call: filters/pagination as query params. */
4
- export interface StorageListOptions extends Pick<HasnaRequestOptions, "timeoutMs" | "headers" | "retry" | "signal"> {
5
- /** Query params (limit, offset, cursor, filters, ...). */
6
- query?: QueryParams;
7
- }
8
- /** Options for a get() call. */
9
- export type StorageGetOptions = Pick<HasnaRequestOptions, "timeoutMs" | "headers" | "retry" | "signal" | "query">;
10
- /** Options for a create() call. */
11
- export interface StorageCreateOptions extends Pick<HasnaRequestOptions, "timeoutMs" | "headers" | "retry" | "signal" | "query"> {
12
- /**
13
- * Idempotency key for the create. Defaults to a fresh UUID so a transparently
14
- * retried POST is deduped by the server instead of creating a duplicate. Pass
15
- * a stable value to make an app-level operation idempotent across calls.
16
- */
17
- idempotencyKey?: string;
18
- }
19
- /** Options for an update() call. */
20
- export interface StorageUpdateOptions extends Pick<HasnaRequestOptions, "timeoutMs" | "headers" | "retry" | "signal" | "query"> {
21
- /** HTTP verb for the update. Default `PATCH` (partial); use `PUT` for replace. */
22
- method?: "PATCH" | "PUT";
23
- /** Idempotency key. PUT is idempotent by definition; set this to make PATCH retry-safe too. */
24
- idempotencyKey?: string;
25
- }
26
- /** Options for a delete() call. */
27
- export type StorageDeleteOptions = Pick<HasnaRequestOptions, "timeoutMs" | "headers" | "retry" | "signal" | "query">;
28
- /** Result of a list() call. `items` is the extracted array; `raw` is the full envelope. */
29
- export interface StorageListResult<T> {
30
- items: T[];
31
- /** Total count when the server reports one (`total`/`count`), else null. */
32
- total: number | null;
33
- /** Opaque pagination cursor when the server reports one, else null. */
34
- cursor: string | null;
35
- /** The full parsed response body (envelope preserved). */
36
- raw: unknown;
37
- }
38
- /**
39
- * The app storage interface, HTTP edition. This is deliberately the same small
40
- * CRUD surface a local store exposes, so an app's resolver can return either a
41
- * local implementation or this one behind one interface.
42
- */
43
- export interface HasnaStorageClient {
44
- /** App slug this client targets. */
45
- readonly name: string;
46
- /** `<origin>/v1` base URL. */
47
- readonly baseUrl: string;
48
- /** The underlying HTTP transport (escape hatch for non-CRUD routes). */
49
- readonly transport: HasnaHttpTransport;
50
- /** List a collection. Returns extracted `items` plus the raw envelope. */
51
- list<T = unknown>(resource: string, options?: StorageListOptions): Promise<StorageListResult<T>>;
52
- /** Fetch one entity by id. Returns `null` on 404. */
53
- get<T = unknown>(resource: string, id: string, options?: StorageGetOptions): Promise<T | null>;
54
- /** Create one entity. Retry-safe via an auto `Idempotency-Key`. */
55
- create<T = unknown>(resource: string, body: unknown, options?: StorageCreateOptions): Promise<T>;
56
- /** Update one entity by id (PATCH by default). */
57
- update<T = unknown>(resource: string, id: string, patch: unknown, options?: StorageUpdateOptions): Promise<T>;
58
- /** Delete one entity by id. Resolves for 2xx and 404 (already gone). */
59
- delete(resource: string, id: string, options?: StorageDeleteOptions): Promise<void>;
60
- }
61
- /**
62
- * Wrap an HTTP transport with the resource CRUD storage interface. Use this when
63
- * you already have a transport (e.g. from `createClientTransport`).
64
- */
65
- export declare function createHasnaStorageClient(name: string, transport: HasnaHttpTransport): HasnaStorageClient;
66
- /** Result of {@link resolveStorageClient}. */
67
- export type ResolveStorageClientResult = {
68
- transport: "local";
69
- client: null;
70
- } | {
71
- transport: "cloud-http";
72
- client: HasnaStorageClient;
73
- };
74
- /**
75
- * The one call an app's storage resolver makes. Reads the client-flip env for
76
- * `name`; when it resolves to `cloud-http` (mode=cloud/self_hosted + API_URL +
77
- * API_KEY), returns a ready {@link HasnaStorageClient}. Otherwise returns
78
- * `{ transport: 'local', client: null }` so the app uses its local store.
79
- * Throws if cloud was requested but is misconfigured (so callers never silently
80
- * read the wrong dataset).
81
- */
82
- export declare function resolveStorageClient(name: string, env?: Env, overrides?: Parameters<typeof createClientTransport>[2]): ResolveStorageClientResult;
83
- //# sourceMappingURL=storage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/lib/contracts-client/storage.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,qBAAqB,EAErB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAExB,qEAAqE;AACrE,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,mBAAmB,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IACjH,0DAA0D;IAC1D,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,gCAAgC;AAChC,MAAM,MAAM,iBAAiB,GAAG,IAA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CAAC,CAAC,CAAC,GACtD,0BAA0B,CAM5B"}
@@ -1,148 +0,0 @@
1
- import { type Env, type StorageMode } from "./mode.js";
2
- /** Default cloud host template. `<app>` is the app slug. */
3
- export declare function defaultCloudBaseUrl(name: string): string;
4
- export interface ClientTransportEnvKeys {
5
- /** Mode keys, in precedence order. */
6
- modeKeys: string[];
7
- /** API base-URL keys, in precedence order. */
8
- apiUrlKeys: string[];
9
- /** API-key keys, in precedence order. */
10
- apiKeyKeys: string[];
11
- }
12
- /** Resolve the canonical client-flip env-key spec for an app. */
13
- export declare function clientTransportEnvKeys(name: string): ClientTransportEnvKeys;
14
- /** Normalize a base URL to `<origin>/v1` (dropping any trailing slash or existing /v1). */
15
- export declare function toV1BaseUrl(apiUrl: string): string;
16
- export type ClientTransportKind = "local" | "cloud-http";
17
- export interface ClientTransportResolution {
18
- /** Where the client should read/write from. */
19
- transport: ClientTransportKind;
20
- /** Resolved storage mode (`local` | `cloud`). */
21
- mode: StorageMode;
22
- /** Deprecated mode alias that was normalized (e.g. `self_hosted`), if any. */
23
- deprecatedAlias: string | null;
24
- /** Env key the mode was read from, or `"default"`. */
25
- modeSource: string;
26
- /** `<origin>/v1` base for the cloud API when transport is cloud-http, else null. */
27
- baseUrl: string | null;
28
- /** Env key the API URL came from, `"default"` (host template), or null. */
29
- apiUrlSource: string | null;
30
- /** Whether an API key is present (value never exposed). */
31
- apiKeyPresent: boolean;
32
- /** Env key the API key came from, or null. */
33
- apiKeySource: string | null;
34
- /**
35
- * True when the operator asked for cloud but the config is incomplete (no API
36
- * key), so we fell back to local. Callers SHOULD treat this as an error rather
37
- * than silently reading local data.
38
- */
39
- misconfigured: boolean;
40
- /** Human-readable warning, or null. Never contains secret values. */
41
- warning: string | null;
42
- }
43
- /**
44
- * Resolve how a client should reach an app's data given the environment.
45
- *
46
- * Precedence for the mode: the first present of `HASNA_<NAME>_STORAGE_MODE`,
47
- * `HASNA_<NAME>_MODE`, `<NAME>_STORAGE_MODE`, `<NAME>_MODE`, else `local`.
48
- */
49
- export declare function resolveClientTransport(name: string, env?: Env): ClientTransportResolution;
50
- /** Thrown when a cloud HTTP request returns a non-2xx status. */
51
- export declare class HasnaHttpError extends Error {
52
- readonly status: number;
53
- readonly method: string;
54
- readonly path: string;
55
- readonly body: unknown;
56
- constructor(method: string, path: string, status: number, body: unknown);
57
- }
58
- type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
59
- /** Query params for a request. Nullish values are dropped; arrays repeat the key. */
60
- export type QueryParams = URLSearchParams | Record<string, string | number | boolean | null | undefined | ReadonlyArray<string | number | boolean>>;
61
- /** Retry policy for transient failures (network errors, timeouts, 5xx, 429). */
62
- export interface HasnaRetryOptions {
63
- /** Max RETRY attempts after the first try. Default 2 (=> up to 3 total tries). */
64
- retries?: number;
65
- /** Base backoff in ms for exponential backoff. Default 200. */
66
- baseDelayMs?: number;
67
- /** Backoff ceiling in ms. Default 2000. */
68
- maxDelayMs?: number;
69
- /** HTTP statuses that trigger a retry. Default 408, 425, 429, 500, 502, 503, 504. */
70
- retryStatuses?: number[];
71
- }
72
- /** Per-call request options: query, idempotency, timeout, retry, extra headers. */
73
- export interface HasnaRequestOptions {
74
- /** Query string params appended to the URL. */
75
- query?: QueryParams;
76
- /**
77
- * Idempotency key sent as `Idempotency-Key`. When set, unsafe methods (POST)
78
- * become safe to retry: the server dedupes replays. Auto-generated for
79
- * `create()` in the storage client.
80
- */
81
- idempotencyKey?: string;
82
- /** Override the transport timeout for this call (ms). */
83
- timeoutMs?: number;
84
- /** Extra headers merged into this call (override transport headers). */
85
- headers?: Record<string, string>;
86
- /** Override or disable retry for this call. `false` disables retries. */
87
- retry?: HasnaRetryOptions | false;
88
- /** Caller abort signal, combined with the internal timeout. */
89
- signal?: AbortSignal;
90
- }
91
- export interface HasnaHttpTransportOptions {
92
- /** App slug (for error context / default host). */
93
- name: string;
94
- /** `<origin>/v1` base. Usually from `resolveClientTransport().baseUrl`. */
95
- baseUrl: string;
96
- /** The API key (secret). Sent as both `x-api-key` and `Authorization: Bearer`. */
97
- apiKey: string;
98
- /** Override fetch (tests). Defaults to global fetch. */
99
- fetchImpl?: FetchLike;
100
- /** Extra headers merged into every request. */
101
- headers?: Record<string, string>;
102
- /** Per-request timeout in ms. Default 30000. */
103
- timeoutMs?: number;
104
- /** Default retry policy for all requests. Pass `false` to disable. */
105
- retry?: HasnaRetryOptions | false;
106
- /** Injectable sleep (tests). Defaults to a real timer. */
107
- sleepImpl?: (ms: number) => Promise<void>;
108
- }
109
- export interface HasnaHttpTransport {
110
- readonly baseUrl: string;
111
- request<T = unknown>(method: string, path: string, body?: unknown, opts?: HasnaRequestOptions): Promise<T>;
112
- get<T = unknown>(path: string, opts?: HasnaRequestOptions): Promise<T>;
113
- post<T = unknown>(path: string, body?: unknown, opts?: HasnaRequestOptions): Promise<T>;
114
- put<T = unknown>(path: string, body?: unknown, opts?: HasnaRequestOptions): Promise<T>;
115
- patch<T = unknown>(path: string, body?: unknown, opts?: HasnaRequestOptions): Promise<T>;
116
- del<T = unknown>(path: string, body?: unknown, opts?: HasnaRequestOptions): Promise<T>;
117
- }
118
- /** Append query params to a `/v1`-relative path (no-op when empty). */
119
- export declare function appendQuery(path: string, query?: QueryParams): string;
120
- /**
121
- * Build an authenticated HTTP transport for an app's cloud `/v1` API. Sends the
122
- * API key on every request as BOTH `x-api-key` and `Authorization: Bearer`
123
- * (serve apps accept either), returns parsed JSON, times out, and retries
124
- * transient failures with exponential backoff + jitter. Never logs the key.
125
- *
126
- * Retry safety: idempotent methods (GET/HEAD/PUT/DELETE/OPTIONS) are always
127
- * retried on transient failure; POST/PATCH are retried ONLY when an
128
- * `Idempotency-Key` is supplied, so replays can't create duplicates.
129
- */
130
- export declare function createHasnaHttpTransport(options: HasnaHttpTransportOptions): HasnaHttpTransport;
131
- /**
132
- * Convenience: resolve transport from env and, when cloud-http, build the HTTP
133
- * client in one call. Returns `{ transport: 'local', resolution }` for local, or
134
- * `{ transport: 'cloud-http', client, resolution }` for cloud. Throws if the
135
- * config is `misconfigured` (cloud requested but unusable) so callers can't drift
136
- * onto local data by accident.
137
- */
138
- export declare function createClientTransport(name: string, env?: Env, overrides?: Partial<Pick<HasnaHttpTransportOptions, "fetchImpl" | "headers" | "timeoutMs" | "retry" | "sleepImpl">>): {
139
- transport: "local";
140
- client: null;
141
- resolution: ClientTransportResolution;
142
- } | {
143
- transport: "cloud-http";
144
- client: HasnaHttpTransport;
145
- resolution: ClientTransportResolution;
146
- };
147
- export {};
148
- //# sourceMappingURL=transport.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/lib/contracts-client/transport.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAkC,KAAK,GAAG,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAEvF,4DAA4D;AAC5D,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,MAAM,WAAW,sBAAsB;IACrC,sCAAsC;IACtC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,8CAA8C;IAC9C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,yCAAyC;IACzC,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,iEAAiE;AACjE,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB,CAY3E;AAUD,2FAA2F;AAC3F,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAWlD;AAED,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,YAAY,CAAC;AAEzD,MAAM,WAAW,yBAAyB;IACxC,+CAA+C;IAC/C,SAAS,EAAE,mBAAmB,CAAC;IAC/B,iDAAiD;IACjD,IAAI,EAAE,WAAW,CAAC;IAClB,8EAA8E;IAC9E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,oFAAoF;IACp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AAC;IAAC,MAAM,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,yBAAyB,CAAA;CAAE,GAC3E;IAAE,SAAS,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAC;IAAC,UAAU,EAAE,yBAAyB,CAAA;CAAE,CA4BjG"}
@@ -1,21 +0,0 @@
1
- interface TrainingMessage {
2
- role: 'system' | 'user' | 'assistant';
3
- content: string;
4
- }
5
- interface TrainingExample {
6
- messages: TrainingMessage[];
7
- }
8
- interface GatherResult {
9
- source: string;
10
- examples: TrainingExample[];
11
- count: number;
12
- }
13
- interface GathererOptions {
14
- limit?: number;
15
- since?: Date;
16
- outputDir?: string;
17
- }
18
- type GatherTrainingDataFn = (options?: GathererOptions) => Promise<GatherResult>;
19
- export declare const gatherTrainingData: GatherTrainingDataFn;
20
- export {};
21
- //# sourceMappingURL=gatherer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"gatherer.d.ts","sourceRoot":"","sources":["../../src/lib/gatherer.ts"],"names":[],"mappings":"AAQA,UAAU,eAAe;IACvB,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAA;IACrC,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,UAAU,eAAe;IACvB,QAAQ,EAAE,eAAe,EAAE,CAAA;CAC5B;AAED,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,eAAe,EAAE,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;CACd;AAED,UAAU,eAAe;IACvB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,KAAK,oBAAoB,GAAG,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;AAShF,eAAO,MAAM,kBAAkB,EAAE,oBAkNhC,CAAA"}
@@ -1,8 +0,0 @@
1
- export declare const DEFAULT_MODEL = "gpt-4o-mini";
2
- /** Returns the active fine-tuned model ID, or DEFAULT_MODEL if none set. */
3
- export declare function getActiveModel(): string;
4
- /** Persists the active fine-tuned model ID to ~/.hasna/economy/config.json. */
5
- export declare function setActiveModel(id: string): void;
6
- /** Clears the active model, falling back to DEFAULT_MODEL. */
7
- export declare function clearActiveModel(): void;
8
- //# sourceMappingURL=model-config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"model-config.d.ts","sourceRoot":"","sources":["../../src/lib/model-config.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,aAAa,gBAAgB,CAAA;AA8B1C,4EAA4E;AAC5E,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAI/C;AAED,8DAA8D;AAC9D,wBAAgB,gBAAgB,IAAI,IAAI,CAIvC"}
@@ -1,19 +0,0 @@
1
- import type { SqliteAdapter as Database } from '@hasna/cloud';
2
- interface OpenProject {
3
- id: string;
4
- name: string;
5
- description: string | null;
6
- path: string;
7
- tags: string[];
8
- created_at: string;
9
- }
10
- type ListOpenProjects = (options: {
11
- status: 'active';
12
- limit: number;
13
- }) => OpenProject[];
14
- export declare function syncOpenProjectsRegistry(db: Database, listActiveProjects?: ListOpenProjects): Promise<{
15
- imported: number;
16
- skipped: number;
17
- }>;
18
- export {};
19
- //# sourceMappingURL=open-projects.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"open-projects.d.ts","sourceRoot":"","sources":["../../src/lib/open-projects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,cAAc,CAAA;AAG7D,UAAU,WAAW;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,KAAK,gBAAgB,GAAG,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,KAAK,WAAW,EAAE,CAAA;AAEvF,wBAAsB,wBAAwB,CAC5C,EAAE,EAAE,QAAQ,EACZ,kBAAkB,CAAC,EAAE,gBAAgB,GACpC,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA2BhD"}
@@ -1,8 +0,0 @@
1
- type PackageMetadata = {
2
- name: string;
3
- version: string;
4
- };
5
- export declare function getPackageMetadata(): PackageMetadata;
6
- export declare const packageMetadata: PackageMetadata;
7
- export {};
8
- //# sourceMappingURL=package-metadata.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-metadata.d.ts","sourceRoot":"","sources":["../../src/lib/package-metadata.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAID,wBAAgB,kBAAkB,IAAI,eAAe,CAYpD;AAED,eAAO,MAAM,eAAe,iBAAuB,CAAA"}
@@ -1,20 +0,0 @@
1
- /** Cross-platform home directory (Windows USERPROFILE, Unix HOME). */
2
- export declare function getHomeDir(): string;
3
- export declare function expandHome(path: string): string;
4
- export declare function agentPaths(): {
5
- claudeProjects: string;
6
- claudeCredentials: string;
7
- takumiProjects: string;
8
- codexDir: string;
9
- codexDb: string;
10
- codexAuth: string;
11
- codexConfig: string;
12
- geminiTmp: string;
13
- geminiHistory: string;
14
- opencodeMessages: string;
15
- piSessions: string;
16
- hermesDir: string;
17
- hermesDb: string;
18
- };
19
- export declare function existingAgentPaths(): string[];
20
- //# sourceMappingURL=paths.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/lib/paths.ts"],"names":[],"mappings":"AAIA,sEAAsE;AACtE,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED,wBAAgB,UAAU;;;;;;;;;;;;;;EAiBzB;AAED,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAE7C"}
@@ -1,6 +0,0 @@
1
- import type { Period } from '../types/index.js';
2
- export declare function usageSnapshotFilterForPeriod(period: Period): {
3
- date?: string;
4
- since?: string;
5
- };
6
- //# sourceMappingURL=periods.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"periods.d.ts","sourceRoot":"","sources":["../../src/lib/periods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAM/C,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAsB9F"}
@@ -1,13 +0,0 @@
1
- import type { SqliteAdapter as Database } from '@hasna/cloud';
2
- import type { ModelPricing } from '../types/index.js';
3
- import { type DbModelPricing } from '../db/database.js';
4
- export declare const DEFAULT_PRICING: Record<string, ModelPricing>;
5
- export declare function normalizeModelName(raw: string): string;
6
- export declare function ensurePricingSeeded(db: Database): void;
7
- export declare function getPricingFromDb(db: Database, model: string): ModelPricing | null;
8
- export declare function getPricing(model: string): ModelPricing | null;
9
- export declare function computeCost(model: string, inputTokens: number, outputTokens: number, cacheReadTokens?: number, cacheWriteTokens?: number, cacheWrite1hTokens?: number, cacheStorageTokenHours?: number): number;
10
- export declare function computeCostFromDb(db: Database, model: string, inputTokens: number, outputTokens: number, cacheReadTokens?: number, cacheWriteTokens?: number, cacheWrite1hTokens?: number, cacheStorageTokenHours?: number): number;
11
- export declare function getPricingFromRows(rows: DbModelPricing[], model: string): ModelPricing | null;
12
- export declare function estimateCostFromRows(rows: DbModelPricing[], model: string, inputTokens: number, outputTokens: number, cacheReadTokens?: number, cacheWriteTokens?: number, cacheWrite1hTokens?: number, cacheStorageTokenHours?: number): number;
13
- //# sourceMappingURL=pricing.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/lib/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,EAA6E,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAIlI,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CA+FxD,CAAA;AAqND,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOtD;AA2CD,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAMtD;AA+GD,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAoBjF;AA4BD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAG7D;AAMD,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,eAAe,SAAI,EACnB,gBAAgB,SAAI,EACpB,kBAAkB,SAAI,EACtB,sBAAsB,SAAI,GACzB,MAAM,CAIR;AAED,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,eAAe,SAAI,EACnB,gBAAgB,SAAI,EACpB,kBAAkB,SAAI,EACtB,sBAAsB,SAAI,GACzB,MAAM,CAIR;AAMD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAW7F;AAMD,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,cAAc,EAAE,EACtB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,eAAe,SAAI,EACnB,gBAAgB,SAAI,EACpB,kBAAkB,SAAI,EACtB,sBAAsB,SAAI,GACzB,MAAM,CAIR"}
@@ -1,17 +0,0 @@
1
- import type { SqliteAdapter as Database } from '@hasna/cloud';
2
- import type { Agent, CostBasis } from './agents.js';
3
- import type { Period } from '../types/index.js';
4
- export interface SavingsSummary {
5
- period: Period;
6
- api_equivalent_usd: number;
7
- subscription_fee_usd: number;
8
- included_consumed_usd: number;
9
- on_demand_usd: number;
10
- saved_usd: number;
11
- by_agent: Record<string, Partial<SavingsSummary>>;
12
- }
13
- /** saved = max(0, api_equivalent - on_demand - prorated_subscription_fee) */
14
- export declare function computeSavedUsd(apiEquivalent: number, onDemand: number, subscriptionFee: number): number;
15
- export declare function querySavingsSummary(db: Database, period: Period, agent?: Agent): SavingsSummary;
16
- export declare function defaultCostBasisForAgent(agent: Agent): CostBasis;
17
- //# sourceMappingURL=savings.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"savings.d.ts","sourceRoot":"","sources":["../../src/lib/savings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE/C,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,EAAE,MAAM,CAAA;IAC1B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,qBAAqB,EAAE,MAAM,CAAA;IAC7B,aAAa,EAAE,MAAM,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,CAAA;CAClD;AAoCD,6EAA6E;AAC7E,wBAAgB,eAAe,CAC7B,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,MAAM,CAER;AAED,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,KAAK,GACZ,cAAc,CAmHhB;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAIhE"}
@@ -1,4 +0,0 @@
1
- export declare function getServeApiToken(): string | undefined;
2
- export declare function getServeBindHost(): string;
3
- export declare function isAuthorizedRequest(req: Request, path: string): boolean;
4
- //# sourceMappingURL=serve-auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serve-auth.d.ts","sourceRoot":"","sources":["../../src/lib/serve-auth.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAErD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAIzC;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CASvE"}
@@ -1,18 +0,0 @@
1
- import type { SqliteAdapter as Database } from '@hasna/cloud';
2
- export interface SpikeInfo {
3
- date: string;
4
- cost_usd: number;
5
- average_usd: number;
6
- ratio: number;
7
- }
8
- /** Detect daily cost spikes: today > 2× rolling 7-day mean (min 7 days history). */
9
- export declare function detectCostSpikes(dailyTotals: Array<{
10
- date: string;
11
- cost_usd: number;
12
- }>, opts?: {
13
- windowDays?: number;
14
- multiplier?: number;
15
- }): SpikeInfo[];
16
- export declare function queryRecentSpikes(db: Database, days?: number): SpikeInfo[];
17
- export declare function getTodaySpike(db: Database): SpikeInfo | null;
18
- //# sourceMappingURL=spikes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spikes.d.ts","sourceRoot":"","sources":["../../src/lib/spikes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,cAAc,CAAA;AAE7D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,EACtD,IAAI,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAClD,SAAS,EAAE,CAqBb;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,SAAK,GAAG,SAAS,EAAE,CAUtE;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,GAAG,SAAS,GAAG,IAAI,CAI5D"}