dsh-budget 0.1.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 +26 -0
- package/LICENSE +201 -0
- package/README.es.md +140 -0
- package/README.hi.md +140 -0
- package/README.md +140 -0
- package/README.pt.md +140 -0
- package/README.zh.md +140 -0
- package/SECURITY.md +37 -0
- package/THIRD_PARTY_NOTICES.md +23 -0
- package/cordis.patch.yml +73 -0
- package/lib/client.js +4893 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +1225 -0
- package/lib/typert.host.js +26 -0
- package/lib/types/aggregate/usage.d.ts +112 -0
- package/lib/types/aggregate/usage.d.ts.map +1 -0
- package/lib/types/client/BudgetTab.d.ts +18 -0
- package/lib/types/client/BudgetTab.d.ts.map +1 -0
- package/lib/types/client/index.d.ts +35 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/locales.d.ts +42 -0
- package/lib/types/client/locales.d.ts.map +1 -0
- package/lib/types/client/present.d.ts +19 -0
- package/lib/types/client/present.d.ts.map +1 -0
- package/lib/types/client/remote.d.ts +270 -0
- package/lib/types/client/remote.d.ts.map +1 -0
- package/lib/types/client/styles.d.ts +12 -0
- package/lib/types/client/styles.d.ts.map +1 -0
- package/lib/types/command.d.ts +51 -0
- package/lib/types/command.d.ts.map +1 -0
- package/lib/types/config.d.ts +132 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/estimate/carbon.d.ts +128 -0
- package/lib/types/estimate/carbon.d.ts.map +1 -0
- package/lib/types/estimate/cost.d.ts +71 -0
- package/lib/types/estimate/cost.d.ts.map +1 -0
- package/lib/types/estimate/latency-stats.d.ts +111 -0
- package/lib/types/estimate/latency-stats.d.ts.map +1 -0
- package/lib/types/estimate/models.d.ts +29 -0
- package/lib/types/estimate/models.d.ts.map +1 -0
- package/lib/types/estimate/prices.d.ts +85 -0
- package/lib/types/estimate/prices.d.ts.map +1 -0
- package/lib/types/estimate/sanitize.d.ts +56 -0
- package/lib/types/estimate/sanitize.d.ts.map +1 -0
- package/lib/types/events.d.ts +57 -0
- package/lib/types/events.d.ts.map +1 -0
- package/lib/types/governance.d.ts +67 -0
- package/lib/types/governance.d.ts.map +1 -0
- package/lib/types/index.d.ts +50 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/service.d.ts +67 -0
- package/lib/types/service.d.ts.map +1 -0
- package/lib/types/typert.host.d.ts +258 -0
- package/lib/types/typert.host.d.ts.map +1 -0
- package/lib/types/wire.d.ts +629 -0
- package/lib/types/wire.d.ts.map +1 -0
- package/lib/wire-DVO8yw7L.js +4219 -0
- package/package.json +164 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session audit events for `dsh-budget` (declaration merging into the
|
|
3
|
+
* harness `SessionEventMap`). Both events are log-only: the panel/command
|
|
4
|
+
* surfaces are the model-visible projections, and these events keep the
|
|
5
|
+
* alert/block trail reconstructable from the session log. Amounts are plain
|
|
6
|
+
* numbers, webhook URLs are sanitized before they ever reach a payload.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-budget/events
|
|
9
|
+
*/
|
|
10
|
+
declare module '@deepseek-ai/dsh-session/types' {
|
|
11
|
+
interface SessionEventMap {
|
|
12
|
+
/**
|
|
13
|
+
* A threshold alert fired (warn ratio reached or a cap crossed). Log-only
|
|
14
|
+
* audit — the panel/command render the same facts for the user.
|
|
15
|
+
*/
|
|
16
|
+
'budget/alert': {
|
|
17
|
+
scope: 'session' | 'daily' | 'monthly';
|
|
18
|
+
kind: 'warn' | 'over';
|
|
19
|
+
usedUsd: number;
|
|
20
|
+
capUsd: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A budget cap crossed and the over-limit policy blocked the scope (or
|
|
24
|
+
* a user lifted a block). `blocked` records the current state after the
|
|
25
|
+
* transition.
|
|
26
|
+
*/
|
|
27
|
+
'budget/block': {
|
|
28
|
+
scope: 'session' | 'daily' | 'monthly';
|
|
29
|
+
blocked: boolean;
|
|
30
|
+
degradation?: {
|
|
31
|
+
from: string;
|
|
32
|
+
to: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** The alert audit event type. */
|
|
38
|
+
export declare const ALERT_EVENT: "budget/alert";
|
|
39
|
+
/** The block audit event type. */
|
|
40
|
+
export declare const BLOCK_EVENT: "budget/block";
|
|
41
|
+
/** Alert payload type. */
|
|
42
|
+
export type BudgetAlertEvent = {
|
|
43
|
+
scope: 'session' | 'daily' | 'monthly';
|
|
44
|
+
kind: 'warn' | 'over';
|
|
45
|
+
usedUsd: number;
|
|
46
|
+
capUsd: number;
|
|
47
|
+
};
|
|
48
|
+
/** Block payload type. */
|
|
49
|
+
export type BudgetBlockEvent = {
|
|
50
|
+
scope: 'session' | 'daily' | 'monthly';
|
|
51
|
+
blocked: boolean;
|
|
52
|
+
degradation?: {
|
|
53
|
+
from: string;
|
|
54
|
+
to: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,QAAQ,gCAAgC,CAAC;IAC9C,UAAU,eAAe;QACvB;;;WAGG;QACH,cAAc,EAAE;YACd,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;YACtC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;YACrB,OAAO,EAAE,MAAM,CAAA;YACf,MAAM,EAAE,MAAM,CAAA;SACf,CAAA;QACD;;;;WAIG;QACH,cAAc,EAAE;YACd,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;YACtC,OAAO,EAAE,OAAO,CAAA;YAChB,WAAW,CAAC,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,EAAE,EAAE,MAAM,CAAA;aAAE,CAAA;SAC3C,CAAA;KACF;CACF;AAED,kCAAkC;AAClC,eAAO,MAAM,WAAW,EAAG,cAAuB,CAAA;AAElD,kCAAkC;AAClC,eAAO,MAAM,WAAW,EAAG,cAAuB,CAAA;AAElD,0BAA0B;AAC1B,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;IACtC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,0BAA0B;AAC1B,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;IACtC,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;CAC3C,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Budget governance: the per-scope cap checks, threshold alerts, and the
|
|
3
|
+
* over-limit policy (alert / block / degrade). Pure decision logic — the only
|
|
4
|
+
* side effect is the optional webhook POST, which is fire-and-forget and
|
|
5
|
+
* sanitized. The actual request blocking happens in the `llm/stream`
|
|
6
|
+
* waterfall short-circuit owned by `src/index.ts`; this module only decides.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-budget/governance
|
|
9
|
+
*/
|
|
10
|
+
import type { ResolvedConfig } from './config.ts';
|
|
11
|
+
import { BudgetAggregator } from './aggregate/usage.ts';
|
|
12
|
+
/** One scope's budget check outcome. */
|
|
13
|
+
export interface ScopeDecision {
|
|
14
|
+
scope: 'session' | 'daily' | 'monthly';
|
|
15
|
+
/** Cap in USD; undefined = unlimited. */
|
|
16
|
+
capUsd: number | undefined;
|
|
17
|
+
usedUsd: number;
|
|
18
|
+
/** usedUsd / capUsd; 0 when unlimited. */
|
|
19
|
+
ratio: number;
|
|
20
|
+
/** `warn` (threshold reached), `over` (cap crossed), or `ok`. */
|
|
21
|
+
state: 'ok' | 'warn' | 'over';
|
|
22
|
+
}
|
|
23
|
+
/** The degradation target for the current model, when configured. */
|
|
24
|
+
export interface Degradation {
|
|
25
|
+
from: string;
|
|
26
|
+
to: string;
|
|
27
|
+
}
|
|
28
|
+
/** Governance wiring: a decision sink plus the webhook notifier. */
|
|
29
|
+
export interface GovernanceHooks {
|
|
30
|
+
/** Called for every warn/over decision worth alerting (cooldown-gated). */
|
|
31
|
+
onAlert: (decision: ScopeDecision) => void;
|
|
32
|
+
/** Called when a scope becomes blocked under block/degrade policy. */
|
|
33
|
+
onBlock: (scope: 'session' | 'daily' | 'monthly', degradation: Degradation | undefined) => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Check every budget scope for one session after new usage landed.
|
|
37
|
+
*
|
|
38
|
+
* @param config - resolved plugin config.
|
|
39
|
+
* @param aggregator - the runtime aggregator.
|
|
40
|
+
* @param sessionId - owning session id.
|
|
41
|
+
* @param hooks - alert/block sinks.
|
|
42
|
+
* @param at - current timestamp (injected for tests).
|
|
43
|
+
* @returns the per-scope decisions, in scope order.
|
|
44
|
+
*/
|
|
45
|
+
export declare function checkBudgets(config: ResolvedConfig, aggregator: BudgetAggregator, sessionId: string, hooks: GovernanceHooks, at: number): ScopeDecision[];
|
|
46
|
+
/** The degradation pair for the current attribution, when configured. */
|
|
47
|
+
export declare function degradationFor(config: ResolvedConfig, aggregator: BudgetAggregator, _scope: 'session' | 'daily' | 'monthly'): Degradation | undefined;
|
|
48
|
+
/** Sanitize a webhook URL for logs: scheme + host only, credentials dropped. */
|
|
49
|
+
export declare function webhookDisplay(url: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Fire one threshold-alert webhook POST (JSON body). Failures are swallowed
|
|
52
|
+
* and returned — alerts must never crash the hot path. The URL itself is
|
|
53
|
+
* never logged with credentials attached.
|
|
54
|
+
*
|
|
55
|
+
* @param url - validated webhook URL.
|
|
56
|
+
* @param payload - JSON-serializable payload.
|
|
57
|
+
* @param timeoutMs - request timeout.
|
|
58
|
+
* @param logger - warn sink for failures.
|
|
59
|
+
* @returns the outcome (ok or the error message).
|
|
60
|
+
*/
|
|
61
|
+
export declare function sendWebhook(url: string, payload: Record<string, unknown>, timeoutMs: number, logger: {
|
|
62
|
+
warn: (message: string) => void;
|
|
63
|
+
}): Promise<{
|
|
64
|
+
ok: boolean;
|
|
65
|
+
error?: string;
|
|
66
|
+
}>;
|
|
67
|
+
//# sourceMappingURL=governance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"governance.d.ts","sourceRoot":"","sources":["../../src/governance.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,sBAAsB,CAAA;AAGxE,wCAAwC;AACxC,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;IACtC,yCAAyC;IACzC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAA;IACb,iEAAiE;IACjE,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;CAC9B;AAED,qEAAqE;AACrE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;CACX;AAED,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC9B,2EAA2E;IAC3E,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAA;IAC1C,sEAAsE;IACtE,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,EAAE,WAAW,EAAE,WAAW,GAAG,SAAS,KAAK,IAAI,CAAA;CAChG;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,gBAAgB,EAC5B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,eAAe,EACtB,EAAE,EAAE,MAAM,GACT,aAAa,EAAE,CA+BjB;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAC5B,MAAM,EAAE,cAAc,EACtB,UAAU,EAAE,gBAAgB,EAC5B,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,SAAS,GACtC,WAAW,GAAG,SAAS,CAMzB;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOlD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE;IAAE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GAC1C,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAuB1C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dsh-budget` 鈥?cost governance for DeepSeek Harness. Aggregated
|
|
3
|
+
* token/cost/carbon metering per model, session and day; session/daily/monthly
|
|
4
|
+
* budget caps with threshold alerts (webhook + desktop notification flag) and
|
|
5
|
+
* alert/block/degrade over-limit policies; per-model latency statistics; the
|
|
6
|
+
* `budget` Typert Remote (`budget/status`, `budget/setSettings`,
|
|
7
|
+
* `budget/unblock`) that the browser half's Settings tab consumes; the
|
|
8
|
+
* `/budget` command; and `budget/alert` + `budget/block` session audit events.
|
|
9
|
+
*
|
|
10
|
+
* Function plugin 鈥?no default export (the Loader unwraps
|
|
11
|
+
* `exports.default ?? exports`).
|
|
12
|
+
*
|
|
13
|
+
* Seam notes (verified against 0.1.0-rc.6 and the local checkout):
|
|
14
|
+
* - Usage arrives as `assistant/message` events (`usage?: TokenUsage`);
|
|
15
|
+
* provider/model attribution comes from the latest `request/header`
|
|
16
|
+
* (`header.config.provider` / `header.config.model`).
|
|
17
|
+
* - Blocking happens on the `llm/stream` waterfall: when a scope is blocked
|
|
18
|
+
* the listener short-circuits (no `next()`) and yields a text block plus an
|
|
19
|
+
* error finish that names the budget breach 鈥?loop-built requests are
|
|
20
|
+
* deep-frozen and may NOT be rewritten, so `degrade` manifests the same way
|
|
21
|
+
* with corrective text naming the degraded model (plus the alert). A
|
|
22
|
+
* waterfall listener short-circuit is a deliberate claim, not a passthrough
|
|
23
|
+
* bug: pass-through paths always call `next()`.
|
|
24
|
+
* - Session audit appends use the two-argument `Session.append` form (the
|
|
25
|
+
* pinned rc.6 peers have no append-envelope option).
|
|
26
|
+
*
|
|
27
|
+
* @module dsh-budget
|
|
28
|
+
*/
|
|
29
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
30
|
+
import { Config } from './config.ts';
|
|
31
|
+
export declare const name = "dsh-budget";
|
|
32
|
+
/** Hard services: the session store every aggregation keys off. */
|
|
33
|
+
export declare const inject: string[];
|
|
34
|
+
export { Config, resolveConfig } from './config.ts';
|
|
35
|
+
export type { ResolvedConfig } from './config.ts';
|
|
36
|
+
export { BudgetAggregator } from './aggregate/usage.ts';
|
|
37
|
+
export { checkBudgets, degradationFor } from './governance.ts';
|
|
38
|
+
export { BudgetService, effectiveCap } from './service.ts';
|
|
39
|
+
export { budgetCommand, parseBudgetArgs, renderBudgetModels, renderBudgetOverview } from './command.ts';
|
|
40
|
+
export { ALERT_EVENT, BLOCK_EVENT } from './events.ts';
|
|
41
|
+
/**
|
|
42
|
+
* Mount the plugin: resolve config, build the aggregator, wire the session
|
|
43
|
+
* event feed, the budget checks, the `llm/stream` blocker, the webhook
|
|
44
|
+
* alerts, the `budget` Remote service, and the `/budget` command.
|
|
45
|
+
*
|
|
46
|
+
* @param ctx - the plugin context (host).
|
|
47
|
+
* @param config - raw plugin config.
|
|
48
|
+
*/
|
|
49
|
+
export declare function apply(ctx: Context, config: Config): Promise<void>;
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAA;AAOnD,eAAO,MAAM,IAAI,eAAe,CAAA;AAEhC,mEAAmE;AACnE,eAAO,MAAM,MAAM,UAAe,CAAA;AAElC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACnD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACvG,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAatD;;;;;;;GAOG;AACH,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiIvE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The budget host service: assembles the `BudgetStatus` snapshot and serves
|
|
3
|
+
* it under the `budget` Typert Remote namespace (`budget/status`), plus the
|
|
4
|
+
* two runtime actions — `setSettings` (session-scoped runtime caps and alert
|
|
5
|
+
* switches, never a config-file write) and `unblock` (lift one blocked scope
|
|
6
|
+
* after user confirmation). All data comes from the runtime aggregator; the
|
|
7
|
+
* service performs no I/O of its own.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-budget/service
|
|
10
|
+
*/
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
13
|
+
import type { ResolvedConfig } from './config.ts';
|
|
14
|
+
import { BudgetAggregator } from './aggregate/usage.ts';
|
|
15
|
+
import type { BudgetScope } from './wire.ts';
|
|
16
|
+
import { type BudgetStatus } from './wire.ts';
|
|
17
|
+
declare module '@deepseek-ai/cordis' {
|
|
18
|
+
interface Context {
|
|
19
|
+
/** Budget snapshot + runtime actions service (this package). */
|
|
20
|
+
budget: BudgetService;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Runtime-editable settings (session-scoped; a reload restores cordis.yml). */
|
|
24
|
+
export interface RuntimeSettings {
|
|
25
|
+
sessionCapUsd: number | null;
|
|
26
|
+
dailyCapUsd: number | null;
|
|
27
|
+
monthlyCapUsd: number | null;
|
|
28
|
+
alertsEnabled: boolean;
|
|
29
|
+
desktopNotifications: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Effective cap lookup: runtime override first, then the config. */
|
|
32
|
+
export declare function effectiveCap(settings: RuntimeSettings, config: ResolvedConfig, scope: BudgetScope): number | null;
|
|
33
|
+
/**
|
|
34
|
+
* The `budget` Typert Remote service. Constructed by `src/index.ts` with the
|
|
35
|
+
* shared aggregator, the resolved config, and the runtime settings object;
|
|
36
|
+
* mounted through `ctx.plugin`.
|
|
37
|
+
*/
|
|
38
|
+
export declare class BudgetService extends TypertRemoteService {
|
|
39
|
+
private readonly bindings;
|
|
40
|
+
/** No service dependencies: pure status surface over injected bindings. */
|
|
41
|
+
static inject: never[];
|
|
42
|
+
/**
|
|
43
|
+
* @param ctx - the mounting context.
|
|
44
|
+
* @param bindings - aggregator, resolved config, runtime settings, and the degraded-model probe.
|
|
45
|
+
*/
|
|
46
|
+
constructor(ctx: Context, bindings: {
|
|
47
|
+
aggregator: BudgetAggregator;
|
|
48
|
+
config: ResolvedConfig;
|
|
49
|
+
settings: RuntimeSettings;
|
|
50
|
+
/** Current session id the panel/command attribute usage to. */
|
|
51
|
+
sessionId: () => string;
|
|
52
|
+
/** Degradation pair in force (when a cap blocked under degrade). */
|
|
53
|
+
degradation: () => {
|
|
54
|
+
from: string;
|
|
55
|
+
to: string;
|
|
56
|
+
} | undefined;
|
|
57
|
+
/** Audit hook called after a block is lifted. */
|
|
58
|
+
onUnblock?: (scope: BudgetScope) => void;
|
|
59
|
+
});
|
|
60
|
+
/** Assemble the wire snapshot for one session. */
|
|
61
|
+
status(sessionId?: string): BudgetStatus;
|
|
62
|
+
/** Apply the panel's runtime settings and return the refreshed snapshot. */
|
|
63
|
+
setSettings(settingsJson: string): BudgetStatus;
|
|
64
|
+
/** Lift one blocked scope and return the refreshed snapshot. */
|
|
65
|
+
unblock(scope: BudgetScope): BudgetStatus;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAA0B,KAAK,YAAY,EAAkC,MAAM,WAAW,CAAA;AAErG,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf,gEAAgE;QAChE,MAAM,EAAE,aAAa,CAAA;KACtB;CACF;AAED,gFAAgF;AAChF,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,aAAa,EAAE,OAAO,CAAA;IACtB,oBAAoB,EAAE,OAAO,CAAA;CAC9B;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAIjH;AAUD;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,mBAAmB;IAUlD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAT3B,2EAA2E;IAC3E,MAAM,CAAC,MAAM,UAAK;IAElB;;;OAGG;gBAED,GAAG,EAAE,OAAO,EACK,QAAQ,EAAE;QACzB,UAAU,EAAE,gBAAgB,CAAA;QAC5B,MAAM,EAAE,cAAc,CAAA;QACtB,QAAQ,EAAE,eAAe,CAAA;QACzB,+DAA+D;QAC/D,SAAS,EAAE,MAAM,MAAM,CAAA;QACvB,oEAAoE;QACpE,WAAW,EAAE,MAAM;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,GAAG,SAAS,CAAA;QAC3D,iDAAiD;QACjD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAA;KACzC;IAKH,kDAAkD;IAClD,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY;IAyCxC,4EAA4E;IAC5E,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY;IAiB/C,gEAAgE;IAChE,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY;CAK1C"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hand-written Typert HOST manifest for `dsh-budget`, exported as
|
|
3
|
+
* `./typert` so the harness's typert-loader registers the `budget`
|
|
4
|
+
* status/setSettings/unblock invocations automatically when this plugin
|
|
5
|
+
* mounts. Same shape as a generator output (validated by the loader): package
|
|
6
|
+
* face, empty model and schemas, and the canonical invocation list shared
|
|
7
|
+
* with the client Remote contribution (`src/wire.ts`).
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-budget/typert
|
|
10
|
+
*/
|
|
11
|
+
/** Host Typert manifest (validated by `@deepseek-ai/dsh-typert-loader`). */
|
|
12
|
+
export declare const TYPERT: Readonly<{
|
|
13
|
+
package: "dsh-budget";
|
|
14
|
+
face: "host";
|
|
15
|
+
schemas: readonly never[];
|
|
16
|
+
invocations: readonly (Readonly<{
|
|
17
|
+
readonly id: "dsh-budget#budget/status";
|
|
18
|
+
readonly service: "budget";
|
|
19
|
+
readonly namespace: "budget";
|
|
20
|
+
readonly method: "status";
|
|
21
|
+
readonly invocation: Readonly<{
|
|
22
|
+
kind: "direct";
|
|
23
|
+
}>;
|
|
24
|
+
readonly parameters: readonly never[];
|
|
25
|
+
readonly result: Readonly<{
|
|
26
|
+
mode: "strict";
|
|
27
|
+
typeSymbol: "dsh-budget/types#BudgetStatus";
|
|
28
|
+
schema: import("zod").ZodObject<{
|
|
29
|
+
scopes: import("zod").ZodArray<import("zod").ZodObject<{
|
|
30
|
+
scope: import("zod").ZodEnum<{
|
|
31
|
+
session: "session";
|
|
32
|
+
daily: "daily";
|
|
33
|
+
monthly: "monthly";
|
|
34
|
+
}>;
|
|
35
|
+
capUsd: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
36
|
+
usedUsd: import("zod").ZodNumber;
|
|
37
|
+
ratio: import("zod").ZodNumber;
|
|
38
|
+
tokens: import("zod").ZodNumber;
|
|
39
|
+
carbonKg: import("zod").ZodNumber;
|
|
40
|
+
}, import("zod/v4/core").$strip>>;
|
|
41
|
+
models: import("zod").ZodArray<import("zod").ZodObject<{
|
|
42
|
+
provider: import("zod").ZodString;
|
|
43
|
+
model: import("zod").ZodString;
|
|
44
|
+
inputTokens: import("zod").ZodNumber;
|
|
45
|
+
outputTokens: import("zod").ZodNumber;
|
|
46
|
+
costUsd: import("zod").ZodNumber;
|
|
47
|
+
carbonKg: import("zod").ZodNumber;
|
|
48
|
+
latency: import("zod").ZodObject<{
|
|
49
|
+
min: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
50
|
+
p50: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
51
|
+
p95: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
52
|
+
max: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
53
|
+
samples: import("zod").ZodNumber;
|
|
54
|
+
}, import("zod/v4/core").$strip>;
|
|
55
|
+
}, import("zod/v4/core").$strip>>;
|
|
56
|
+
alerts: import("zod").ZodArray<import("zod").ZodObject<{
|
|
57
|
+
scope: import("zod").ZodEnum<{
|
|
58
|
+
session: "session";
|
|
59
|
+
daily: "daily";
|
|
60
|
+
monthly: "monthly";
|
|
61
|
+
}>;
|
|
62
|
+
kind: import("zod").ZodUnion<readonly [import("zod").ZodLiteral<"warn">, import("zod").ZodLiteral<"over">]>;
|
|
63
|
+
at: import("zod").ZodNumber;
|
|
64
|
+
usedUsd: import("zod").ZodNumber;
|
|
65
|
+
capUsd: import("zod").ZodNumber;
|
|
66
|
+
}, import("zod/v4/core").$strip>>;
|
|
67
|
+
blockedScopes: import("zod").ZodArray<import("zod").ZodEnum<{
|
|
68
|
+
session: "session";
|
|
69
|
+
daily: "daily";
|
|
70
|
+
monthly: "monthly";
|
|
71
|
+
}>>;
|
|
72
|
+
currency: import("zod").ZodObject<{
|
|
73
|
+
code: import("zod").ZodString;
|
|
74
|
+
rate: import("zod").ZodNumber;
|
|
75
|
+
decimals: import("zod").ZodNumber;
|
|
76
|
+
}, import("zod/v4/core").$strip>;
|
|
77
|
+
alertsEnabled: import("zod").ZodBoolean;
|
|
78
|
+
desktopNotifications: import("zod").ZodBoolean;
|
|
79
|
+
degradedModel: import("zod").ZodNullable<import("zod").ZodString>;
|
|
80
|
+
}, import("zod/v4/core").$strip>;
|
|
81
|
+
}>;
|
|
82
|
+
readonly sourceLocation: Readonly<{
|
|
83
|
+
file: "src/wire.ts";
|
|
84
|
+
line: 1;
|
|
85
|
+
column: 1;
|
|
86
|
+
}>;
|
|
87
|
+
}> | Readonly<{
|
|
88
|
+
readonly id: "dsh-budget#budget/setSettings";
|
|
89
|
+
readonly service: "budget";
|
|
90
|
+
readonly namespace: "budget";
|
|
91
|
+
readonly method: "setSettings";
|
|
92
|
+
readonly invocation: Readonly<{
|
|
93
|
+
kind: "direct";
|
|
94
|
+
}>;
|
|
95
|
+
readonly parameters: readonly Readonly<{
|
|
96
|
+
name: string;
|
|
97
|
+
wire: string;
|
|
98
|
+
source: "json";
|
|
99
|
+
codec: Readonly<{
|
|
100
|
+
mode: "strict";
|
|
101
|
+
typeSymbol: "dsh-budget/types#BudgetSettingsJson";
|
|
102
|
+
schema: import("zod").ZodString;
|
|
103
|
+
}>;
|
|
104
|
+
}>[];
|
|
105
|
+
readonly result: Readonly<{
|
|
106
|
+
mode: "strict";
|
|
107
|
+
typeSymbol: "dsh-budget/types#BudgetStatus";
|
|
108
|
+
schema: import("zod").ZodObject<{
|
|
109
|
+
scopes: import("zod").ZodArray<import("zod").ZodObject<{
|
|
110
|
+
scope: import("zod").ZodEnum<{
|
|
111
|
+
session: "session";
|
|
112
|
+
daily: "daily";
|
|
113
|
+
monthly: "monthly";
|
|
114
|
+
}>;
|
|
115
|
+
capUsd: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
116
|
+
usedUsd: import("zod").ZodNumber;
|
|
117
|
+
ratio: import("zod").ZodNumber;
|
|
118
|
+
tokens: import("zod").ZodNumber;
|
|
119
|
+
carbonKg: import("zod").ZodNumber;
|
|
120
|
+
}, import("zod/v4/core").$strip>>;
|
|
121
|
+
models: import("zod").ZodArray<import("zod").ZodObject<{
|
|
122
|
+
provider: import("zod").ZodString;
|
|
123
|
+
model: import("zod").ZodString;
|
|
124
|
+
inputTokens: import("zod").ZodNumber;
|
|
125
|
+
outputTokens: import("zod").ZodNumber;
|
|
126
|
+
costUsd: import("zod").ZodNumber;
|
|
127
|
+
carbonKg: import("zod").ZodNumber;
|
|
128
|
+
latency: import("zod").ZodObject<{
|
|
129
|
+
min: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
130
|
+
p50: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
131
|
+
p95: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
132
|
+
max: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
133
|
+
samples: import("zod").ZodNumber;
|
|
134
|
+
}, import("zod/v4/core").$strip>;
|
|
135
|
+
}, import("zod/v4/core").$strip>>;
|
|
136
|
+
alerts: import("zod").ZodArray<import("zod").ZodObject<{
|
|
137
|
+
scope: import("zod").ZodEnum<{
|
|
138
|
+
session: "session";
|
|
139
|
+
daily: "daily";
|
|
140
|
+
monthly: "monthly";
|
|
141
|
+
}>;
|
|
142
|
+
kind: import("zod").ZodUnion<readonly [import("zod").ZodLiteral<"warn">, import("zod").ZodLiteral<"over">]>;
|
|
143
|
+
at: import("zod").ZodNumber;
|
|
144
|
+
usedUsd: import("zod").ZodNumber;
|
|
145
|
+
capUsd: import("zod").ZodNumber;
|
|
146
|
+
}, import("zod/v4/core").$strip>>;
|
|
147
|
+
blockedScopes: import("zod").ZodArray<import("zod").ZodEnum<{
|
|
148
|
+
session: "session";
|
|
149
|
+
daily: "daily";
|
|
150
|
+
monthly: "monthly";
|
|
151
|
+
}>>;
|
|
152
|
+
currency: import("zod").ZodObject<{
|
|
153
|
+
code: import("zod").ZodString;
|
|
154
|
+
rate: import("zod").ZodNumber;
|
|
155
|
+
decimals: import("zod").ZodNumber;
|
|
156
|
+
}, import("zod/v4/core").$strip>;
|
|
157
|
+
alertsEnabled: import("zod").ZodBoolean;
|
|
158
|
+
desktopNotifications: import("zod").ZodBoolean;
|
|
159
|
+
degradedModel: import("zod").ZodNullable<import("zod").ZodString>;
|
|
160
|
+
}, import("zod/v4/core").$strip>;
|
|
161
|
+
}>;
|
|
162
|
+
readonly sourceLocation: Readonly<{
|
|
163
|
+
file: "src/wire.ts";
|
|
164
|
+
line: 1;
|
|
165
|
+
column: 1;
|
|
166
|
+
}>;
|
|
167
|
+
}> | Readonly<{
|
|
168
|
+
readonly id: "dsh-budget#budget/unblock";
|
|
169
|
+
readonly service: "budget";
|
|
170
|
+
readonly namespace: "budget";
|
|
171
|
+
readonly method: "unblock";
|
|
172
|
+
readonly invocation: Readonly<{
|
|
173
|
+
kind: "direct";
|
|
174
|
+
}>;
|
|
175
|
+
readonly parameters: readonly Readonly<{
|
|
176
|
+
name: string;
|
|
177
|
+
wire: string;
|
|
178
|
+
source: "json";
|
|
179
|
+
codec: Readonly<{
|
|
180
|
+
mode: "strict";
|
|
181
|
+
typeSymbol: "dsh-budget/types#BudgetUnblockScope";
|
|
182
|
+
schema: import("zod").ZodEnum<{
|
|
183
|
+
session: "session";
|
|
184
|
+
daily: "daily";
|
|
185
|
+
monthly: "monthly";
|
|
186
|
+
}>;
|
|
187
|
+
}>;
|
|
188
|
+
}>[];
|
|
189
|
+
readonly result: Readonly<{
|
|
190
|
+
mode: "strict";
|
|
191
|
+
typeSymbol: "dsh-budget/types#BudgetStatus";
|
|
192
|
+
schema: import("zod").ZodObject<{
|
|
193
|
+
scopes: import("zod").ZodArray<import("zod").ZodObject<{
|
|
194
|
+
scope: import("zod").ZodEnum<{
|
|
195
|
+
session: "session";
|
|
196
|
+
daily: "daily";
|
|
197
|
+
monthly: "monthly";
|
|
198
|
+
}>;
|
|
199
|
+
capUsd: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
200
|
+
usedUsd: import("zod").ZodNumber;
|
|
201
|
+
ratio: import("zod").ZodNumber;
|
|
202
|
+
tokens: import("zod").ZodNumber;
|
|
203
|
+
carbonKg: import("zod").ZodNumber;
|
|
204
|
+
}, import("zod/v4/core").$strip>>;
|
|
205
|
+
models: import("zod").ZodArray<import("zod").ZodObject<{
|
|
206
|
+
provider: import("zod").ZodString;
|
|
207
|
+
model: import("zod").ZodString;
|
|
208
|
+
inputTokens: import("zod").ZodNumber;
|
|
209
|
+
outputTokens: import("zod").ZodNumber;
|
|
210
|
+
costUsd: import("zod").ZodNumber;
|
|
211
|
+
carbonKg: import("zod").ZodNumber;
|
|
212
|
+
latency: import("zod").ZodObject<{
|
|
213
|
+
min: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
214
|
+
p50: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
215
|
+
p95: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
216
|
+
max: import("zod").ZodNullable<import("zod").ZodNumber>;
|
|
217
|
+
samples: import("zod").ZodNumber;
|
|
218
|
+
}, import("zod/v4/core").$strip>;
|
|
219
|
+
}, import("zod/v4/core").$strip>>;
|
|
220
|
+
alerts: import("zod").ZodArray<import("zod").ZodObject<{
|
|
221
|
+
scope: import("zod").ZodEnum<{
|
|
222
|
+
session: "session";
|
|
223
|
+
daily: "daily";
|
|
224
|
+
monthly: "monthly";
|
|
225
|
+
}>;
|
|
226
|
+
kind: import("zod").ZodUnion<readonly [import("zod").ZodLiteral<"warn">, import("zod").ZodLiteral<"over">]>;
|
|
227
|
+
at: import("zod").ZodNumber;
|
|
228
|
+
usedUsd: import("zod").ZodNumber;
|
|
229
|
+
capUsd: import("zod").ZodNumber;
|
|
230
|
+
}, import("zod/v4/core").$strip>>;
|
|
231
|
+
blockedScopes: import("zod").ZodArray<import("zod").ZodEnum<{
|
|
232
|
+
session: "session";
|
|
233
|
+
daily: "daily";
|
|
234
|
+
monthly: "monthly";
|
|
235
|
+
}>>;
|
|
236
|
+
currency: import("zod").ZodObject<{
|
|
237
|
+
code: import("zod").ZodString;
|
|
238
|
+
rate: import("zod").ZodNumber;
|
|
239
|
+
decimals: import("zod").ZodNumber;
|
|
240
|
+
}, import("zod/v4/core").$strip>;
|
|
241
|
+
alertsEnabled: import("zod").ZodBoolean;
|
|
242
|
+
desktopNotifications: import("zod").ZodBoolean;
|
|
243
|
+
degradedModel: import("zod").ZodNullable<import("zod").ZodString>;
|
|
244
|
+
}, import("zod/v4/core").$strip>;
|
|
245
|
+
}>;
|
|
246
|
+
readonly sourceLocation: Readonly<{
|
|
247
|
+
file: "src/wire.ts";
|
|
248
|
+
line: 1;
|
|
249
|
+
column: 1;
|
|
250
|
+
}>;
|
|
251
|
+
}>)[];
|
|
252
|
+
model: Readonly<{
|
|
253
|
+
services: readonly never[];
|
|
254
|
+
events: readonly never[];
|
|
255
|
+
objects: readonly never[];
|
|
256
|
+
}>;
|
|
257
|
+
}>;
|
|
258
|
+
//# sourceMappingURL=typert.host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typert.host.d.ts","sourceRoot":"","sources":["../../src/typert.host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,4EAA4E;AAC5E,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUjB,CAAA"}
|