@wrongstack/core 0.291.1 → 0.292.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/dist/coordination/director-tools.d.ts.map +1 -1
- package/dist/coordination/index.js +113 -113
- package/dist/coordination/index.js.map +3 -3
- package/dist/core/agent-loop.d.ts.map +1 -1
- package/dist/core/agent-response.d.ts.map +1 -1
- package/dist/core/context.d.ts +10 -0
- package/dist/core/context.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +20 -1
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/defaults/index.d.ts +1 -0
- package/dist/defaults/index.d.ts.map +1 -1
- package/dist/defaults/index.js +3132 -2440
- package/dist/defaults/index.js.map +4 -4
- package/dist/execution/auto-compaction-middleware.d.ts +34 -2
- package/dist/execution/auto-compaction-middleware.d.ts.map +1 -1
- package/dist/execution/compaction-core.d.ts +59 -0
- package/dist/execution/compaction-core.d.ts.map +1 -1
- package/dist/execution/compactor.d.ts.map +1 -1
- package/dist/execution/error-handler.d.ts +7 -0
- package/dist/execution/error-handler.d.ts.map +1 -1
- package/dist/execution/index.d.ts +1 -0
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js +4677 -3924
- package/dist/execution/index.js.map +4 -4
- package/dist/execution/intelligent-compactor.d.ts.map +1 -1
- package/dist/execution/model-runtime.d.ts.map +1 -1
- package/dist/execution/selective-compactor.d.ts +10 -0
- package/dist/execution/selective-compactor.d.ts.map +1 -1
- package/dist/execution/subagent-compaction.d.ts +24 -0
- package/dist/execution/subagent-compaction.d.ts.map +1 -0
- package/dist/hq/alerts.d.ts +5 -0
- package/dist/hq/alerts.d.ts.map +1 -1
- package/dist/hq/auth-audit.d.ts +115 -0
- package/dist/hq/auth-audit.d.ts.map +1 -0
- package/dist/hq/auth-store.d.ts +98 -2
- package/dist/hq/auth-store.d.ts.map +1 -1
- package/dist/hq/brain-bridge.d.ts +2 -8
- package/dist/hq/brain-bridge.d.ts.map +1 -1
- package/dist/hq/bridge-context.d.ts +74 -0
- package/dist/hq/bridge-context.d.ts.map +1 -0
- package/dist/hq/cost-bridge.d.ts +4 -10
- package/dist/hq/cost-bridge.d.ts.map +1 -1
- package/dist/hq/fleet-bridge.d.ts +2 -8
- package/dist/hq/fleet-bridge.d.ts.map +1 -1
- package/dist/hq/index.d.ts +2 -0
- package/dist/hq/index.d.ts.map +1 -1
- package/dist/hq/index.js +358 -222
- package/dist/hq/index.js.map +4 -4
- package/dist/hq/protocol/session.d.ts +13 -0
- package/dist/hq/protocol/session.d.ts.map +1 -1
- package/dist/hq/tool-bridge.d.ts +2 -8
- package/dist/hq/tool-bridge.d.ts.map +1 -1
- package/dist/hq/worktree-bridge.d.ts +2 -8
- package/dist/hq/worktree-bridge.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6054 -4741
- package/dist/index.js.map +4 -4
- package/dist/infrastructure/index.js +32 -15
- package/dist/infrastructure/index.js.map +2 -2
- package/dist/infrastructure/provider-cache-ledger.d.ts +48 -0
- package/dist/infrastructure/provider-cache-ledger.d.ts.map +1 -0
- package/dist/infrastructure/token-counter.d.ts +4 -2
- package/dist/infrastructure/token-counter.d.ts.map +1 -1
- package/dist/kernel/events/brain-events.d.ts +2 -0
- package/dist/kernel/events/brain-events.d.ts.map +1 -1
- package/dist/kernel/events/memory-events.d.ts +102 -0
- package/dist/kernel/events/memory-events.d.ts.map +1 -1
- package/dist/kernel/events/session-events.d.ts +35 -0
- package/dist/kernel/events/session-events.d.ts.map +1 -1
- package/dist/models/index.js +161 -78
- package/dist/models/index.js.map +3 -3
- package/dist/models/llm-selector.d.ts.map +1 -1
- package/dist/notifications/index.d.ts +40 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/notifier-impl.d.ts +34 -0
- package/dist/notifications/notifier-impl.d.ts.map +1 -0
- package/dist/notifications/notifier.d.ts +95 -0
- package/dist/notifications/notifier.d.ts.map +1 -0
- package/dist/notifications/types.d.ts +111 -0
- package/dist/notifications/types.d.ts.map +1 -0
- package/dist/plugin/api.d.ts +10 -1
- package/dist/plugin/api.d.ts.map +1 -1
- package/dist/registry/provider-registry.d.ts +1 -1
- package/dist/registry/provider-registry.d.ts.map +1 -1
- package/dist/security/index.js +15 -15
- package/dist/security/index.js.map +3 -3
- package/dist/skills/index.js +80 -80
- package/dist/skills/index.js.map +3 -3
- package/dist/storage/config-loader.d.ts +3 -5
- package/dist/storage/config-loader.d.ts.map +1 -1
- package/dist/storage/index.js +325 -259
- package/dist/storage/index.js.map +4 -4
- package/dist/storage/memory-consolidator.d.ts +14 -2
- package/dist/storage/memory-consolidator.d.ts.map +1 -1
- package/dist/storage/queue-store.d.ts +2 -0
- package/dist/storage/queue-store.d.ts.map +1 -1
- package/dist/tools/index.js +6 -6
- package/dist/tools/index.js.map +3 -3
- package/dist/tools/mcp-control.d.ts +1 -1
- package/dist/types/config.d.ts +64 -20
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/index.js +60 -34
- package/dist/types/index.js.map +3 -3
- package/dist/types/plugin.d.ts +11 -0
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/provider.d.ts +31 -0
- package/dist/types/provider.d.ts.map +1 -1
- package/dist/types/token-counter.d.ts +8 -1
- package/dist/types/token-counter.d.ts.map +1 -1
- package/dist/utils/cache-key.d.ts +19 -0
- package/dist/utils/cache-key.d.ts.map +1 -0
- package/dist/utils/compaction-preview.d.ts +8 -0
- package/dist/utils/compaction-preview.d.ts.map +1 -0
- package/dist/utils/context-breakdown.d.ts +59 -0
- package/dist/utils/context-breakdown.d.ts.map +1 -0
- package/dist/utils/context-evidence.d.ts +22 -0
- package/dist/utils/context-evidence.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1730 -1543
- package/dist/utils/index.js.map +4 -4
- package/dist/utils/token-estimate.d.ts +27 -0
- package/dist/utils/token-estimate.d.ts.map +1 -1
- package/instructions/llm/memory-consolidator.md +19 -3
- package/instructions/system.md +10 -2
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intelligent-compactor.d.ts","sourceRoot":"","sources":["../../src/execution/intelligent-compactor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAW,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"intelligent-compactor.d.ts","sourceRoot":"","sources":["../../src/execution/intelligent-compactor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAW,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAkB7D;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,gEAAgE;IAChE,QAAQ,EAAE,QAAQ,CAAC;IACnB,oEAAoE;IACpE,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,6EAA6E;IAC7E,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,6EAA6E;IAC7E,cAAc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|
@@ -55,6 +55,13 @@ export declare class SelectiveCompactor implements Compactor {
|
|
|
55
55
|
compact(ctx: Context, opts?: {
|
|
56
56
|
aggressive?: boolean | undefined;
|
|
57
57
|
}): Promise<CompactReport>;
|
|
58
|
+
/**
|
|
59
|
+
* Compute after-tokens, run the shared quality check, inject the evidence
|
|
60
|
+
* floor when compaction dropped the intent/path anchor, and assemble the
|
|
61
|
+
* report — shared by both exit paths so every SelectiveCompactor run reports
|
|
62
|
+
* quality and carries a `[context_state]` evidence digest like the others.
|
|
63
|
+
*/
|
|
64
|
+
private finalize;
|
|
58
65
|
/**
|
|
59
66
|
* Estimate the full API request token count: messages + systemPrompt + toolDefs.
|
|
60
67
|
* This is the accurate figure for context-window pressure monitoring.
|
|
@@ -73,6 +80,7 @@ export declare class SelectiveCompactor implements Compactor {
|
|
|
73
80
|
private executePlan;
|
|
74
81
|
private summarizeRange;
|
|
75
82
|
private messagePreview;
|
|
83
|
+
private toolEvidence;
|
|
76
84
|
/**
|
|
77
85
|
* Fallback when selector fails: aggressively trim from the oldest end
|
|
78
86
|
* until we hit targetBudget.
|
|
@@ -80,6 +88,8 @@ export declare class SelectiveCompactor implements Compactor {
|
|
|
80
88
|
private aggressiveRecencyTrim;
|
|
81
89
|
private computeTargetBudget;
|
|
82
90
|
private eliseOldToolResults;
|
|
91
|
+
/** Collapse superseded repeated reads that slipped under the elise threshold. */
|
|
92
|
+
private dedupStaleReads;
|
|
83
93
|
private hasTextContent;
|
|
84
94
|
/**
|
|
85
95
|
* Estimate message-array tokens via the shared `estimateMessages` primitive
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selective-compactor.d.ts","sourceRoot":"","sources":["../../src/execution/selective-compactor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,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Bus } from '../kernel/events.js';
|
|
4
|
+
import { type ContextWindowConfigLike } from '../types/context-window.js';
|
|
5
|
+
import { AutoCompactionMiddleware } from './auto-compaction-middleware.js';
|
|
6
|
+
/**
|
|
7
|
+
* Install proactive auto-compaction into a subagent's context-window pipeline.
|
|
8
|
+
*
|
|
9
|
+
* Subagents (CLI fleet host, the light webui/SDD factory) build their pipelines
|
|
10
|
+
* with `createDefaultPipelines()` and historically registered nothing on
|
|
11
|
+
* `contextWindow`, so they had **no proactive compaction** — they grew until a
|
|
12
|
+
* provider rejected the request and only then recovered reactively. This wires
|
|
13
|
+
* the same rule-based `HybridCompactor` + `AutoCompactionMiddleware` the leader
|
|
14
|
+
* uses, so a subagent shrinks on the warn/soft/hard thresholds (and gets the
|
|
15
|
+
* last-resort emergency trim) exactly like the leader.
|
|
16
|
+
*
|
|
17
|
+
* No custom estimator is passed: the middleware's internal
|
|
18
|
+
* `estimateRequestTokensCalibrated` default already applies per-(provider,model)
|
|
19
|
+
* calibration, which is what a subagent wants. Returns the middleware (so the
|
|
20
|
+
* caller could toggle it) or `undefined` when the provider window is unknown
|
|
21
|
+
* (0), in which case compaction is skipped rather than guessing a denominator.
|
|
22
|
+
*/
|
|
23
|
+
export declare function installSubagentAutoCompaction(pipelines: AgentPipelines, ctx: Context, contextConfig: ContextWindowConfigLike | undefined, events?: EventBus | undefined): AutoCompactionMiddleware | undefined;
|
|
24
|
+
//# sourceMappingURL=subagent-compaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent-compaction.d.ts","sourceRoot":"","sources":["../../src/execution/subagent-compaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAG3E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,cAAc,EACzB,GAAG,EAAE,OAAO,EACZ,aAAa,EAAE,uBAAuB,GAAG,SAAS,EAClD,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,GAC5B,wBAAwB,GAAG,SAAS,CAuCtC"}
|
package/dist/hq/alerts.d.ts
CHANGED
|
@@ -30,6 +30,11 @@ export interface HqAlertRuleConfig {
|
|
|
30
30
|
staleMachineSeconds?: number;
|
|
31
31
|
/** Minimum number of active agents before concurrency alert fires. Default: disabled (0). */
|
|
32
32
|
maxAgents?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Hours before expiry at which the `token-expiry-imminent` warning fires.
|
|
35
|
+
* Default 24. Set to 0 to disable the warning entirely (expired-only alert remains).
|
|
36
|
+
*/
|
|
37
|
+
tokenExpiryWarningHours?: number;
|
|
33
38
|
}
|
|
34
39
|
/**
|
|
35
40
|
* In-memory alert state. Tracks which rules are currently firing so the same
|
package/dist/hq/alerts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alerts.d.ts","sourceRoot":"","sources":["../../src/hq/alerts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhE,oEAAoE;AACpE,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;AAEzD,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,WAAW,EAAE,MA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EpE,YAAY,IAAI,EAAE;QAChB,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;QAClC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,yEAAyE;QACzE,SAAS,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;KACpD,EAIA;IAED;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,iBAAiB,EAAE,GAAG,GAAE,MAAmB,GAAG,OAAO,EAAE,CAyCrG;IAED,wCAAwC;IACxC,YAAY,IAAI,OAAO,EAAE,CAExB;IAED,6DAA6D;IAC7D,YAAY,CAAC,KAAK,SAAM,GAAG,OAAO,EAAE,CAEnC;IAED,gFAAgF;IAChF,IAAI,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,CAOrC;IAED;;;OAGG;IACH,aAAa,CACX,WAAW,EAAE,MAAM,UAAU,GAAG,IAAI,EACpC,MAAM,CAAC,EAAE,iBAAiB,GAAG,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC,EAClE,UAAU,SAAS,GAClB,MAAM,IAAI,CAkBZ;CACF;AAED,0EAA0E;AAC1E,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAO7D"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HQ auth audit log — append-only JSONL record of token lifecycle events.
|
|
3
|
+
*
|
|
4
|
+
* Stored at `<dataDir>/auth-audit.jsonl`. One entry per token create /
|
|
5
|
+
* revoke / first-run mint / live-reload-driven expiry sweep. Never holds
|
|
6
|
+
* raw token strings — only the token id, label, scope, and actor.
|
|
7
|
+
*
|
|
8
|
+
* Design:
|
|
9
|
+
* - **Append-only.** Nothing ever rewrites or deletes lines. Rotation is
|
|
10
|
+
* a separate operator concern (the file is bounded only by disk).
|
|
11
|
+
* - **Synchronous append** via `appendFileSync` so a power loss between
|
|
12
|
+
* the CLI's mutate call and the audit write loses at most the audit
|
|
13
|
+
* entry, never the auth state. Errors are swallowed (best-effort).
|
|
14
|
+
* - **Ring in memory** is intentionally NOT kept — this log is for
|
|
15
|
+
* long-term forensic review, not for live UI rendering. The HQ server
|
|
16
|
+
* doesn't load it; only the CLI mutators write to it.
|
|
17
|
+
* - **No PII.** `actor` is a free-form string the caller fills with
|
|
18
|
+
* whatever identity context it has (CLI user, env var, machine id).
|
|
19
|
+
* The token `id` is a UUID — safe to log. The token `token` string
|
|
20
|
+
* is NEVER recorded.
|
|
21
|
+
*
|
|
22
|
+
* @module hq/auth-audit
|
|
23
|
+
*/
|
|
24
|
+
/** Scope of the token the event is about. */
|
|
25
|
+
export type HqAuthAuditScope = 'browser' | 'client';
|
|
26
|
+
/** Kind of event recorded. */
|
|
27
|
+
export type HqAuthAuditKind =
|
|
28
|
+
/** Token created via `wstack hq token create` (or first-run mint). */
|
|
29
|
+
'create'
|
|
30
|
+
/** Token revoked via `wstack hq token revoke`. */
|
|
31
|
+
| 'revoke'
|
|
32
|
+
/**
|
|
33
|
+
* First-run bootstrap — both browser and client tokens minted by
|
|
34
|
+
* `ensureHqFirstRunAuthFile`. Recorded once per fresh data dir;
|
|
35
|
+
* subsequent calls (existing auth.json) do not log.
|
|
36
|
+
*/
|
|
37
|
+
| 'first-run'
|
|
38
|
+
/**
|
|
39
|
+
* Operator edited `auth.json` directly and the HQ server's
|
|
40
|
+
* live-reload watcher pruned one or more tokens whose `expiresAt`
|
|
41
|
+
* had already passed. The entry records how many were pruned.
|
|
42
|
+
*/
|
|
43
|
+
| 'expired-prune'
|
|
44
|
+
/**
|
|
45
|
+
* Password rotation — the operator changed the browser password, which
|
|
46
|
+
* also rotated the cookie secret (invalidating all active sessions).
|
|
47
|
+
* Recorded by `ensureHqFirstRunAuthFile` for the password-change path.
|
|
48
|
+
*/
|
|
49
|
+
| 'password-rotate';
|
|
50
|
+
export interface HqAuthAuditEntry {
|
|
51
|
+
/** Epoch milliseconds when the event was recorded. */
|
|
52
|
+
at: number;
|
|
53
|
+
kind: HqAuthAuditKind;
|
|
54
|
+
scope: HqAuthAuditScope;
|
|
55
|
+
/** Token id (UUID) — safe to log. Never the token string. */
|
|
56
|
+
tokenId: string;
|
|
57
|
+
/** Human-readable label, when the token carried one. */
|
|
58
|
+
label?: string;
|
|
59
|
+
/** Capabilities granted to the token, when known. */
|
|
60
|
+
capabilities?: readonly string[];
|
|
61
|
+
/** Optional expiresAt timestamp on the token (ISO). */
|
|
62
|
+
expiresAt?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Who performed the action. Free-form string — the CLI fills this with
|
|
65
|
+
* the OS user + hostname when available. Never contains the token string.
|
|
66
|
+
*/
|
|
67
|
+
actor?: string;
|
|
68
|
+
/**
|
|
69
|
+
* For `expired-prune`: how many tokens were filtered out by the
|
|
70
|
+
* live-reload watcher in this reload. For other kinds: undefined.
|
|
71
|
+
*/
|
|
72
|
+
prunedCount?: number;
|
|
73
|
+
/**
|
|
74
|
+
* SHA-256 hash (hex) of the redacted `auth.json` contents at the
|
|
75
|
+
* moment of the event — lets an operator reviewing the audit log tie
|
|
76
|
+
* an entry back to the exact on-disk state that produced it without
|
|
77
|
+
* the log ever holding derivable token material. Computed by
|
|
78
|
+
* `hqAuthContentHash` over a projection of the `HqAuthFile` with the
|
|
79
|
+
* raw token strings, `passwordHash`, and `cookieSecret` replaced by
|
|
80
|
+
* the constant sentinel `HQ_AUTH_CONTENT_HASH_REDACTED` (exported
|
|
81
|
+
* from `@wrongstack/core`) — so two files that differ only in secrets
|
|
82
|
+
* hash identically. Absent on entries emitted before the hash landed
|
|
83
|
+
* and when the file is unreadable at emit time. Re-derivable from the
|
|
84
|
+
* current `auth.json` via `hqAuthContentHash(await readHqAuthFile(dir))`.
|
|
85
|
+
*/
|
|
86
|
+
contentHash?: string;
|
|
87
|
+
}
|
|
88
|
+
/** Path to `auth-audit.jsonl` under the given data dir. */
|
|
89
|
+
export declare function hqAuthAuditPath(dataDir: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Append a single audit entry to `<dataDir>/auth-audit.jsonl`.
|
|
92
|
+
*
|
|
93
|
+
* Best-effort: errors are swallowed and the optional `onError` callback
|
|
94
|
+
* is invoked instead. The caller's mutation (auth.json write, token
|
|
95
|
+
* mint, etc.) has already succeeded by the time this is called, so a
|
|
96
|
+
* failed audit append must never roll it back.
|
|
97
|
+
*
|
|
98
|
+
* The data dir is created if missing. The file is opened in append mode
|
|
99
|
+
* so concurrent writers (e.g. two CLI invocations) do not clobber each
|
|
100
|
+
* other — JSONL append is the safe granularity.
|
|
101
|
+
*/
|
|
102
|
+
export declare function appendHqAuthAudit(dataDir: string, entry: HqAuthAuditEntry, options?: {
|
|
103
|
+
onError?: (err: Error) => void;
|
|
104
|
+
}): void;
|
|
105
|
+
/**
|
|
106
|
+
* Convenience: build an entry with a sensible default `at` (now) and
|
|
107
|
+
* append it. The `at` field can still be overridden via the partial.
|
|
108
|
+
*/
|
|
109
|
+
export declare function logHqAuthAudit(dataDir: string, partial: Omit<HqAuthAuditEntry, 'at'> & {
|
|
110
|
+
at?: number;
|
|
111
|
+
}, options?: {
|
|
112
|
+
onError?: (err: Error) => void;
|
|
113
|
+
now?: () => number;
|
|
114
|
+
}): void;
|
|
115
|
+
//# sourceMappingURL=auth-audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-audit.d.ts","sourceRoot":"","sources":["../../src/hq/auth-audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,6CAA6C;AAC7C,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEpD,8BAA8B;AAC9B,MAAM,MAAM,eAAe;AACzB,sEAAsE;AACpE,QAAQ;AACV,kDAAkD;GAChD,QAAQ;AACV;;;;GAIG;GACD,WAAW;AACb;;;;GAIG;GACD,eAAe;AACjB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
|
43
43
|
*/
|
|
44
44
|
capabilities?: string[];
|
|
45
|
+
/**
|
|
46
|
+
* Optional ISO timestamp after which the token is refused. When absent
|
|
47
|
+
* (the pre-TTL default), the token never expires. The HQ server rejects
|
|
48
|
+
* an expired token at both the HTTP and the WS-upgrade auth boundary,
|
|
49
|
+
* so TTL rotation is enforced even for long-lived browser sessions.
|
|
50
|
+
*
|
|
51
|
+
* The timestamp is wall-clock (`new Date().toISOString()`) — clock skew
|
|
52
|
+
* between the issuing HQ and the client just shifts the effective window
|
|
53
|
+
* slightly, which is acceptable for an operator-set rotation cadence.
|
|
54
|
+
*/
|
|
55
|
+
expiresAt?: string;
|
|
45
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* True when a token has a wall-clock expiry that has already passed.
|
|
59
|
+
* Returns `false` when `expiresAt` is absent (the pre-TTL default).
|
|
60
|
+
*
|
|
61
|
+
* The check is fail-open for malformed values: an unparseable timestamp
|
|
62
|
+
* is treated as "no expiry" rather than "already expired", because the
|
|
63
|
+
* latter would lock the operator out of their own HQ on a bad file edit.
|
|
64
|
+
* Use {@link tokenHasCapability} at the auth boundary to also deny
|
|
65
|
+
* capabilities for expired tokens.
|
|
66
|
+
*
|
|
67
|
+
* @param at - epoch milliseconds; defaults to `Date.now()`. Exposed so
|
|
68
|
+
* tests can inject a fixed clock.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isTokenExpired(token: Pick<HqToken, 'expiresAt'> | undefined, at?: number): boolean;
|
|
46
71
|
/**
|
|
47
72
|
* Check whether a token grants a capability. A token with no `capabilities`
|
|
48
73
|
* field is unrestricted (backward-compat). Otherwise the capability must be
|
|
49
|
-
* explicitly listed.
|
|
74
|
+
* explicitly listed. **Expired tokens are refused regardless of capability**
|
|
75
|
+
* — call this at the auth boundary so TTL rotation is enforced uniformly.
|
|
50
76
|
*/
|
|
51
77
|
export declare function tokenHasCapability(token: HqToken | undefined, capability: string): boolean;
|
|
52
78
|
/**
|
|
@@ -86,6 +112,36 @@ export interface HqAuthFile {
|
|
|
86
112
|
}
|
|
87
113
|
/** An empty auth file — what a brand-new HQ install starts with. */
|
|
88
114
|
export declare function emptyHqAuthFile(): HqAuthFile;
|
|
115
|
+
/**
|
|
116
|
+
* Sentinel value `hqAuthContentHash` substitutes for every raw secret
|
|
117
|
+
* (`HqToken.token`, `HqAuthFile.passwordHash`, `HqAuthFile.cookieSecret`)
|
|
118
|
+
* before hashing. Exported so downstream consumers of the audit log can
|
|
119
|
+
* recognize the redaction shape without hardcoding the literal — e.g. a
|
|
120
|
+
* forensic tool that re-derives a `contentHash` from a known on-disk
|
|
121
|
+
* `auth.json` can substitute this same sentinel and compare.
|
|
122
|
+
*/
|
|
123
|
+
export declare const HQ_AUTH_CONTENT_HASH_REDACTED = "<redacted>";
|
|
124
|
+
/**
|
|
125
|
+
* Compute a SHA-256 content hash over a *redacted* projection of an
|
|
126
|
+
* `HqAuthFile`. The projection replaces every raw token string, the
|
|
127
|
+
* `passwordHash`, and the `cookieSecret` with constant sentinels, so:
|
|
128
|
+
*
|
|
129
|
+
* - the audit log never holds derivable token material (a hash of a
|
|
130
|
+
* redacted projection can't be reversed to recover the originals),
|
|
131
|
+
* - two files that differ only in their secrets hash identically
|
|
132
|
+
* (reissuing a token without changing its id/label/expiry does not
|
|
133
|
+
* change the hash), and
|
|
134
|
+
* - the hash still flips whenever the structural state the operator
|
|
135
|
+
* cares about (version, token ids/labels/capabilities/expiries,
|
|
136
|
+
* alert rules, redaction policy) changes.
|
|
137
|
+
*
|
|
138
|
+
* Returns `undefined` when hashing or serialization throws (e.g. a
|
|
139
|
+
* future schema addition that isn't JSON-serializable) — callers
|
|
140
|
+
* should pass that through as an absent `contentHash` field rather
|
|
141
|
+
* than failing the audit append, matching the audit module's
|
|
142
|
+
* best-effort contract.
|
|
143
|
+
*/
|
|
144
|
+
export declare function hqAuthContentHash(file: HqAuthFile): string | undefined;
|
|
89
145
|
/** Path to `auth.json` under the given data directory. */
|
|
90
146
|
export declare function hqAuthFilePath(dataDir: string): string;
|
|
91
147
|
/** Path to the best-effort runtime endpoint marker under the given data directory. */
|
|
@@ -117,6 +173,22 @@ export interface EnsureHqFirstRunAuthOptions {
|
|
|
117
173
|
warn?: (msg: string) => void;
|
|
118
174
|
/** Optional browser password login. Hashed with scrypt before storage. */
|
|
119
175
|
password?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Optional time-to-live (milliseconds) stamped on the first-run browser
|
|
178
|
+
* and client tokens. When set, both tokens carry an `expiresAt` and the
|
|
179
|
+
* HQ server will refuse them once it passes. Default: no expiry.
|
|
180
|
+
*
|
|
181
|
+
* Only affects tokens minted by THIS call (the first run). Tokens added
|
|
182
|
+
* later via `wstack hq token create` choose their own TTL.
|
|
183
|
+
*/
|
|
184
|
+
tokenTtlMs?: number | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Optional `actor` string recorded in `auth-audit.jsonl` for the two
|
|
187
|
+
* `first-run` entries this function emits (one per minted token). The
|
|
188
|
+
* CLI fills this with `user@host`; when omitted the entry carries no
|
|
189
|
+
* `actor` field. Never contains the token string.
|
|
190
|
+
*/
|
|
191
|
+
actor?: string | undefined;
|
|
120
192
|
}
|
|
121
193
|
export interface EnsureHqFirstRunAuthResult {
|
|
122
194
|
authFile: HqAuthFile;
|
|
@@ -128,6 +200,13 @@ export interface EnsureHqFirstRunAuthResult {
|
|
|
128
200
|
* Ensure a brand-new HQ data directory has the auth required for safe
|
|
129
201
|
* first-run operation. Only a missing auth.json is bootstrapped; an existing
|
|
130
202
|
* file, including one with empty token arrays, is treated as operator intent.
|
|
203
|
+
*
|
|
204
|
+
* Caller surface: the sole production caller is `startHqServer` in
|
|
205
|
+
* `packages/cli/src/hq-server.ts`, which threads `actor: resolveAuditActor()`
|
|
206
|
+
* so both first-run audit entries carry `user@host`. Test callers live under
|
|
207
|
+
* `packages/core/tests/hq/` (token-ttl, first-run-audit, auth-store). Any
|
|
208
|
+
* new production caller MUST pass `actor` for the audit log to carry
|
|
209
|
+
* forensic identity — see `EnsureHqFirstRunAuthOptions.actor`.
|
|
131
210
|
*/
|
|
132
211
|
export declare function ensureHqFirstRunAuthFile(dataDir: string, opts?: EnsureHqFirstRunAuthOptions): Promise<EnsureHqFirstRunAuthResult>;
|
|
133
212
|
/**
|
|
@@ -154,11 +233,28 @@ export declare function hashHqPassword(password: string): Promise<string>;
|
|
|
154
233
|
export declare function verifyHqPassword(password: string, hash: string): Promise<boolean>;
|
|
155
234
|
/** Mint a secret used to sign browser session cookies. */
|
|
156
235
|
export declare function mintHqCookieSecret(): string;
|
|
236
|
+
/**
|
|
237
|
+
* Options for {@link mintHqToken}.
|
|
238
|
+
*
|
|
239
|
+
* - `label` — human-readable identifier persisted alongside the token.
|
|
240
|
+
* - `ttlMs` — when set, the token is stamped with `expiresAt = now + ttlMs`.
|
|
241
|
+
* Absent (the default) means the token never expires, preserving the
|
|
242
|
+
* pre-TTL contract.
|
|
243
|
+
* - `now` — epoch milliseconds override for deterministic tests.
|
|
244
|
+
*/
|
|
245
|
+
export interface MintHqTokenOptions {
|
|
246
|
+
label?: string | undefined;
|
|
247
|
+
ttlMs?: number | undefined;
|
|
248
|
+
now?: number | undefined;
|
|
249
|
+
}
|
|
157
250
|
/**
|
|
158
251
|
* Mint a fresh token. Used for both browser and client tokens; the caller
|
|
159
252
|
* decides which list to append to.
|
|
253
|
+
*
|
|
254
|
+
* Pass an options object to stamp an `expiresAt`; the bare-string overload
|
|
255
|
+
* (`mintHqToken('my-label')`) is preserved for backward-compat.
|
|
160
256
|
*/
|
|
161
|
-
export declare function mintHqToken(
|
|
257
|
+
export declare function mintHqToken(labelOrOptions?: string | MintHqTokenOptions): HqToken;
|
|
162
258
|
/**
|
|
163
259
|
* Backward-compat alias for `mintHqToken`. Phase 3 callers/tests use this.
|
|
164
260
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../src/hq/auth-store.ts"],"names":[],"mappings":"AA8BA,OAAO,KA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AAC,CAmBvF;AAED,0DAA0D;AAC1D,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,kBAAkB,GAAG,OAAO,CAcjF;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,oBAAc,CAAC;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,EACpC,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/D;IAAE,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAyDvB"}
|
|
@@ -16,16 +16,10 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import type { EventBus } from '../kernel/events.js';
|
|
18
18
|
import type { HqEventEnvelope } from './protocol.js';
|
|
19
|
-
import type
|
|
20
|
-
export interface BrainTelemetryBridgeOptions {
|
|
19
|
+
import { type BridgeContextOptions } from './bridge-context.js';
|
|
20
|
+
export interface BrainTelemetryBridgeOptions extends BridgeContextOptions {
|
|
21
21
|
/** Local EventBus emitting `brain.*` events. */
|
|
22
22
|
events: EventBus;
|
|
23
|
-
/** HQ publisher to forward envelopes to. */
|
|
24
|
-
publisher: HqPublisher;
|
|
25
|
-
/** Optional sessionId to tag envelopes with. */
|
|
26
|
-
sessionId?: string;
|
|
27
|
-
/** Override `now()` for deterministic tests. */
|
|
28
|
-
now?: () => string;
|
|
29
23
|
}
|
|
30
24
|
/**
|
|
31
25
|
* Start forwarding brain events to HQ. Returns a disposer that unsubscribes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brain-bridge.d.ts","sourceRoot":"","sources":["../../src/hq/brain-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAyC,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"brain-bridge.d.ts","sourceRoot":"","sources":["../../src/hq/brain-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAyC,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5F,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAErF,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACvE,gDAAgD;IAChD,MAAM,EAAE,QAAQ,CAAC;CAClB;AAgCD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,2BAA2B,GAAG,MAAM,IAAI,CAoEvF;AAED,yCAAyC;AACzC,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared context for HQ telemetry bridges.
|
|
3
|
+
*
|
|
4
|
+
* Every bridge (`cost-bridge`, `brain-bridge`, `worktree-bridge`,
|
|
5
|
+
* `fleet-bridge`, `tool-bridge`) repeats the same four pieces of
|
|
6
|
+
* boilerplate:
|
|
7
|
+
*
|
|
8
|
+
* 1. Resolve `now` from options or fall back to `new Date().toISOString()`.
|
|
9
|
+
* 2. Conditionally spread `{ sessionId }` into every `publishEvent` call.
|
|
10
|
+
* 3. Wrap every publish in `try / catch` (best-effort) so a transient
|
|
11
|
+
* publisher failure never breaks the host's event loop.
|
|
12
|
+
* 4. Collect unsubscribe handles and return a single disposer.
|
|
13
|
+
*
|
|
14
|
+
* This module collapses those four into one factory so each bridge shrinks
|
|
15
|
+
* to its event-mapping logic.
|
|
16
|
+
*
|
|
17
|
+
* @module hq/bridge-context
|
|
18
|
+
*/
|
|
19
|
+
import type { HqPublisher, HqPublishEventOptions } from './publisher.js';
|
|
20
|
+
export interface BridgeContextOptions {
|
|
21
|
+
/** HQ publisher to forward envelopes to. */
|
|
22
|
+
publisher: HqPublisher;
|
|
23
|
+
/** Override `now()` for deterministic tests. */
|
|
24
|
+
now?: (() => string) | undefined;
|
|
25
|
+
/** Optional sessionId to tag envelopes with when the event has none. */
|
|
26
|
+
sessionId?: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
export interface BridgeContext {
|
|
29
|
+
/** Resolved timestamp function (never undefined). */
|
|
30
|
+
readonly now: () => string;
|
|
31
|
+
/**
|
|
32
|
+
* Build the `{ sessionId } | {}` spread for a `publishEvent` call.
|
|
33
|
+
* The event-level sessionId (from the event payload) takes precedence
|
|
34
|
+
* over the bridge-level sessionId (from options).
|
|
35
|
+
*/
|
|
36
|
+
readonly sessionIdTag: (eventSessionId?: string) => {
|
|
37
|
+
sessionId?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Wrap a publish in try/catch so a transient publisher failure never
|
|
41
|
+
* breaks the host. Returns the envelope on success, `undefined` on
|
|
42
|
+
* failure.
|
|
43
|
+
*/
|
|
44
|
+
readonly safePublish: (options: HqPublishEventOptions) => void;
|
|
45
|
+
/** Track an unsubscribe handle for the disposer. */
|
|
46
|
+
readonly track: (off: () => void) => void;
|
|
47
|
+
/** Call every tracked unsubscribe handle. */
|
|
48
|
+
readonly dispose: () => void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a {@link BridgeContext} from the common bridge options.
|
|
52
|
+
*
|
|
53
|
+
* Usage in a bridge:
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* export function startSomethingBridge(opts: SomethingBridgeOptions): () => void {
|
|
57
|
+
* const { events, publisher } = opts;
|
|
58
|
+
* const ctx = createBridgeContext(opts);
|
|
59
|
+
*
|
|
60
|
+
* ctx.track(events.on('something.happened', (p) => {
|
|
61
|
+
* ctx.safePublish({
|
|
62
|
+
* type: 'something.event',
|
|
63
|
+
* payload: { ... },
|
|
64
|
+
* ...ctx.sessionIdTag(p.sessionId),
|
|
65
|
+
* timestamp: ctx.now(),
|
|
66
|
+
* });
|
|
67
|
+
* }));
|
|
68
|
+
*
|
|
69
|
+
* return ctx.dispose;
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function createBridgeContext(options: BridgeContextOptions): BridgeContext;
|
|
74
|
+
//# sourceMappingURL=bridge-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-context.d.ts","sourceRoot":"","sources":["../../src/hq/bridge-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAIzE,MAAM,WAAW,oBAAoB;IACnC,4CAA4C;IAC5C,SAAS,EAAE,WAAW,CAAC;IACvB,gDAAgD;IAChD,GAAG,CAAC,EAAE,CAAC,MAAM,MAAM,CAAC,GAAG,SAAS,CAAC;IACjC,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,KAAK;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3E;;;;OAIG;IACH,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAC/D,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAC1C,6CAA6C;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAmChF"}
|
package/dist/hq/cost-bridge.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CostTelemetryBridge — forwards local token/cost accounting events to the
|
|
3
|
-
* publisher as `session.usage` envelopes, giving the command center the
|
|
2
|
+
* CostTelemetryBridge — forwards local token/cost accounting events to the
|
|
3
|
+
* HQ publisher as `session.usage` envelopes, giving the command center the
|
|
4
4
|
* granular per-call cost signal it needs to render live cost trends and
|
|
5
5
|
* roll-ups across every connected machine.
|
|
6
6
|
*
|
|
@@ -17,16 +17,10 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import type { EventBus } from '../kernel/events.js';
|
|
19
19
|
import type { HqEventEnvelope } from './protocol.js';
|
|
20
|
-
import type
|
|
21
|
-
export interface CostTelemetryBridgeOptions {
|
|
20
|
+
import { type BridgeContextOptions } from './bridge-context.js';
|
|
21
|
+
export interface CostTelemetryBridgeOptions extends BridgeContextOptions {
|
|
22
22
|
/** Local EventBus emitting `token.accounted`. */
|
|
23
23
|
events: EventBus;
|
|
24
|
-
/** HQ publisher to forward envelopes to. */
|
|
25
|
-
publisher: HqPublisher;
|
|
26
|
-
/** Optional sessionId to tag envelopes with (overrides the event's, when set). */
|
|
27
|
-
sessionId?: string;
|
|
28
|
-
/** Override `now()` for deterministic tests. */
|
|
29
|
-
now?: () => string;
|
|
30
24
|
}
|
|
31
25
|
/**
|
|
32
26
|
* Start forwarding token/cost events to HQ. Returns a disposer that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cost-bridge.d.ts","sourceRoot":"","sources":["../../src/hq/cost-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"cost-bridge.d.ts","sourceRoot":"","sources":["../../src/hq/cost-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,eAAe,CAAC;AACrE,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAErF,MAAM,WAAW,0BAA2B,SAAQ,oBAAoB;IACtE,iDAAiD;IACjD,MAAM,EAAE,QAAQ,CAAC;CAClB;AAaD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,0BAA0B,GAAG,MAAM,IAAI,CA6BrF;AAED,yCAAyC;AACzC,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -16,18 +16,12 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import type { EventBus } from '../kernel/events.js';
|
|
18
18
|
import type { HqEventEnvelope } from './protocol.js';
|
|
19
|
-
import type
|
|
20
|
-
export interface FleetTelemetryBridgeOptions {
|
|
19
|
+
import { type BridgeContextOptions } from './bridge-context.js';
|
|
20
|
+
export interface FleetTelemetryBridgeOptions extends BridgeContextOptions {
|
|
21
21
|
/** Local EventBus emitting `coordinator.stats` (host EventBus after the FleetBus hop). */
|
|
22
22
|
events: EventBus;
|
|
23
|
-
/** HQ publisher to forward envelopes to. */
|
|
24
|
-
publisher: HqPublisher;
|
|
25
23
|
/** Coordinator run id — identifies this fleet instance. Falls back to a stable per-session id. */
|
|
26
24
|
runId: string;
|
|
27
|
-
/** Optional sessionId to tag envelopes with. */
|
|
28
|
-
sessionId?: string;
|
|
29
|
-
/** Override `now()` for deterministic tests. */
|
|
30
|
-
now?: () => string;
|
|
31
25
|
}
|
|
32
26
|
/**
|
|
33
27
|
* Start forwarding coordinator stats to HQ. Returns a disposer that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fleet-bridge.d.ts","sourceRoot":"","sources":["../../src/hq/fleet-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAA6C,MAAM,eAAe,CAAC;AAChG,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"fleet-bridge.d.ts","sourceRoot":"","sources":["../../src/hq/fleet-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAA6C,MAAM,eAAe,CAAC;AAChG,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAErF,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACvE,0FAA0F;IAC1F,MAAM,EAAE,QAAQ,CAAC;IACjB,kGAAkG;IAClG,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,2BAA2B,GAAG,MAAM,IAAI,CAiEvF;AAiBD,yCAAyC;AACzC,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/hq/index.d.ts
CHANGED
package/dist/hq/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hq/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hq/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC"}
|