@hua-labs/tap 0.4.2 → 0.5.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/index.d.mts CHANGED
@@ -106,6 +106,15 @@ interface AppServerState {
106
106
  manualCommand: string;
107
107
  auth?: AppServerAuthState | null;
108
108
  }
109
+ type PersistedBridgeLifecycleState = "spawning" | "initializing" | "ready" | "degraded-no-thread" | "degraded-no-bridge" | "stopping" | "stopped" | "crashed";
110
+ interface BridgeLifecycleRecord {
111
+ state: PersistedBridgeLifecycleState;
112
+ since: string;
113
+ updatedAt: string;
114
+ lastTransitionAt: string;
115
+ lastTransitionReason: string | null;
116
+ restartCount: number;
117
+ }
109
118
  interface BridgeState {
110
119
  pid: number;
111
120
  statePath: string;
@@ -113,6 +122,7 @@ interface BridgeState {
113
122
  appServer?: AppServerState | null;
114
123
  /** Instance-specific daemon state dir (thread/heartbeat/processed markers). */
115
124
  runtimeStateDir?: string | null;
125
+ lifecycle?: BridgeLifecycleRecord | null;
116
126
  }
117
127
  /** Runtime instance state. Supports multiple instances per runtime (e.g. codex-reviewer, codex-builder). */
118
128
  interface InstanceState {
@@ -129,12 +139,18 @@ interface InstanceState {
129
139
  lastAppliedHash: string;
130
140
  lastVerifiedAt: string | null;
131
141
  bridge: BridgeState | null;
142
+ /** Persisted lifecycle summary even when no bridge pid file exists. */
143
+ bridgeLifecycle?: BridgeLifecycleRecord | null;
132
144
  /** Headless mode configuration. null = interactive (default). */
133
145
  headless: HeadlessConfig | null;
134
146
  /** Whether bridge manages its own app-server process. Saved for restart mode preservation. */
135
147
  manageAppServer?: boolean;
136
148
  /** Whether bridge runs without auth gateway. Saved for restart mode preservation. */
137
149
  noAuth?: boolean;
150
+ /** Stable hash of resolved config for drift detection (v3+). */
151
+ configHash?: string;
152
+ /** Path to the instance config file (v3+). */
153
+ configSourceFile?: string;
138
154
  warnings: string[];
139
155
  }
140
156
  /** @deprecated Use InstanceState. Kept for v1 state migration. */
@@ -275,7 +291,7 @@ interface TapResolvedConfig {
275
291
  appServerUrl: string;
276
292
  towerName: string | null;
277
293
  }
278
- /** Config resolution source for diagnostics. */
294
+ /** Config resolution source for diagnostics (legacy API — backward compatible). */
279
295
  type ConfigSource = "cli-flag" | "env" | "local-config" | "shared-config" | "legacy-shell-config" | "auto";
280
296
  interface ConfigResolution {
281
297
  config: TapResolvedConfig;
@@ -320,6 +336,39 @@ declare function updateBridgeHeartbeat(stateDir: string, instanceId: InstanceId)
320
336
  declare function getHeartbeatAge(stateDir: string, instanceId: InstanceId): number | null;
321
337
  declare function rotateLog(logPath: string): void;
322
338
 
339
+ type BridgePresence = "bridge-live" | "bridge-stale" | "stopped";
340
+ type BridgeLifecycleStatus = "ready" | "initializing" | "degraded-no-thread" | "bridge-stale" | "stopped";
341
+ interface BridgeLifecycleSnapshot {
342
+ presence: BridgePresence;
343
+ status: BridgeLifecycleStatus;
344
+ summary: string;
345
+ lastTransitionAt: string | null;
346
+ lastTransitionReason: string | null;
347
+ restartCount: number;
348
+ threadId: string | null;
349
+ threadCwd: string | null;
350
+ savedThreadId: string | null;
351
+ savedThreadCwd: string | null;
352
+ activeTurnId: string | null;
353
+ connected: boolean | null;
354
+ initialized: boolean | null;
355
+ appServerHealthy: boolean | null;
356
+ }
357
+
358
+ type CodexSessionTurnState = "active" | "idle" | "waiting-approval" | "disconnected";
359
+ type CodexSessionStatus = "initializing" | "active" | "idle" | "waiting-approval" | "disconnected";
360
+ interface CodexSessionSnapshot {
361
+ status: CodexSessionStatus;
362
+ turnState: CodexSessionTurnState | null;
363
+ summary: string;
364
+ activeTurnId: string | null;
365
+ lastTurnAt: string | null;
366
+ lastDispatchAt: string | null;
367
+ idleSince: string | null;
368
+ connected: boolean | null;
369
+ initialized: boolean | null;
370
+ }
371
+
323
372
  interface BridgeStartOptions {
324
373
  instanceId: InstanceId;
325
374
  runtime: RuntimeName;
@@ -345,6 +394,8 @@ interface BridgeStartOptions {
345
394
  manageAppServer?: boolean;
346
395
  /** Skip auth gateway — app-server listens directly on the public port (localhost only). */
347
396
  noAuth?: boolean;
397
+ /** Persisted lifecycle from the previous session, used to track restarts. */
398
+ previousLifecycle?: BridgeLifecycleRecord | null;
348
399
  }
349
400
 
350
401
  interface RestartBridgeOptions extends BridgeStartOptions {
@@ -365,16 +416,23 @@ declare function restartBridge(options: RestartBridgeOptions): Promise<BridgeSta
365
416
  * Ref: tap public repo tap-ops-dashboard.ps1 (single-agent view)
366
417
  * M74 extends to control-tower view (all agents, all bridges, all PRs).
367
418
  */
419
+
368
420
  interface AgentInfo {
369
421
  name: string;
422
+ instanceId: string | null;
423
+ presence: "bridge-live" | "bridge-stale" | "mcp-only";
424
+ lifecycle: BridgeLifecycleSnapshot["status"] | null;
370
425
  status: string | null;
371
426
  lastActivity: string | null;
372
427
  joinedAt: string | null;
428
+ idleSeconds: number | null;
373
429
  }
374
430
  interface BridgeInfo {
375
431
  instanceId: string;
376
432
  runtime: string;
377
433
  status: "running" | "stopped" | "stale";
434
+ lifecycle: BridgeLifecycleSnapshot | null;
435
+ session: CodexSessionSnapshot | null;
378
436
  pid: number | null;
379
437
  port: number | null;
380
438
  heartbeatAge: number | null;