@hua-labs/tap 0.2.6 → 0.3.1

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
@@ -170,8 +170,8 @@ interface TapStateV1 {
170
170
  packageVersion: string;
171
171
  runtimes: Partial<Record<RuntimeName, RuntimeState>>;
172
172
  }
173
- type CommandName = "init" | "init-worktree" | "add" | "remove" | "status" | "serve" | "bridge" | "up" | "down" | "comms" | "dashboard" | "doctor" | "unknown";
174
- type CommandCode = "TAP_INIT_OK" | "TAP_ADD_OK" | "TAP_REMOVE_OK" | "TAP_STATUS_OK" | "TAP_SERVE_OK" | "TAP_NO_OP" | "TAP_ALREADY_INITIALIZED" | "TAP_INIT_CLONE_FAILED" | "TAP_NOT_INITIALIZED" | "TAP_RUNTIME_UNKNOWN" | "TAP_RUNTIME_NOT_FOUND" | "TAP_CONFIG_INVALID" | "TAP_LOCAL_SERVER_MISSING" | "TAP_INVALID_ARGUMENT" | "TAP_INSTANCE_NOT_FOUND" | "TAP_INSTANCE_AMBIGUOUS" | "TAP_PORT_CONFLICT" | "TAP_PATCH_FAILED" | "TAP_VERIFY_FAILED" | "TAP_ROLLBACK_FAILED" | "TAP_BRIDGE_START_OK" | "TAP_BRIDGE_START_FAILED" | "TAP_BRIDGE_STOP_OK" | "TAP_BRIDGE_STATUS_OK" | "TAP_BRIDGE_NOT_RUNNING" | "TAP_BRIDGE_SCRIPT_MISSING" | "TAP_UP_OK" | "TAP_DOWN_OK" | "TAP_COMMS_PULL_OK" | "TAP_COMMS_PULL_FAILED" | "TAP_COMMS_PUSH_OK" | "TAP_COMMS_PUSH_FAILED" | "TAP_COMMS_NOT_REPO" | "TAP_SERVE_NO_SERVER" | "TAP_SERVE_BUN_REQUIRED" | "TAP_REVIEW_START_OK" | "TAP_REVIEW_TERMINATED" | "TAP_INTERNAL_ERROR";
173
+ type CommandName = "init" | "init-worktree" | "add" | "remove" | "status" | "serve" | "bridge" | "up" | "down" | "comms" | "dashboard" | "doctor" | "watch" | "gui" | "unknown";
174
+ type CommandCode = "TAP_INIT_OK" | "TAP_ADD_OK" | "TAP_REMOVE_OK" | "TAP_STATUS_OK" | "TAP_SERVE_OK" | "TAP_NO_OP" | "TAP_ALREADY_INITIALIZED" | "TAP_INIT_CLONE_FAILED" | "TAP_NOT_INITIALIZED" | "TAP_RUNTIME_UNKNOWN" | "TAP_RUNTIME_NOT_FOUND" | "TAP_CONFIG_INVALID" | "TAP_LOCAL_SERVER_MISSING" | "TAP_INVALID_ARGUMENT" | "TAP_INSTANCE_NOT_FOUND" | "TAP_INSTANCE_AMBIGUOUS" | "TAP_PORT_CONFLICT" | "TAP_PATCH_FAILED" | "TAP_VERIFY_FAILED" | "TAP_ROLLBACK_FAILED" | "TAP_BRIDGE_START_OK" | "TAP_BRIDGE_START_FAILED" | "TAP_BRIDGE_STOP_OK" | "TAP_BRIDGE_STATUS_OK" | "TAP_BRIDGE_NOT_RUNNING" | "TAP_BRIDGE_SCRIPT_MISSING" | "TAP_UP_OK" | "TAP_DOWN_OK" | "TAP_COMMS_PULL_OK" | "TAP_COMMS_PULL_FAILED" | "TAP_COMMS_PUSH_OK" | "TAP_COMMS_PUSH_FAILED" | "TAP_COMMS_NOT_REPO" | "TAP_SERVE_NO_SERVER" | "TAP_SERVE_BUN_REQUIRED" | "TAP_REVIEW_START_OK" | "TAP_REVIEW_TERMINATED" | "TAP_WATCH_OK" | "TAP_WATCH_RESTARTED" | "TAP_WATCH_FAILED" | "TAP_BRIDGE_WATCH_OK" | "TAP_BRIDGE_WATCH_RESTARTED" | "TAP_PORT_IN_USE" | "TAP_GUI_ERROR" | "TAP_INTERNAL_ERROR";
175
175
  interface CommandResult<T = Record<string, unknown>> {
176
176
  ok: boolean;
177
177
  command: CommandName;
@@ -190,6 +190,57 @@ declare function createInitialState(commsDir: string, repoRoot: string, packageV
190
190
 
191
191
  declare const version: string;
192
192
 
193
+ interface GeminiIdeCursor {
194
+ line: number;
195
+ character: number;
196
+ }
197
+ interface GeminiIdeFile {
198
+ path: string;
199
+ timestamp: number;
200
+ isActive?: boolean;
201
+ cursor?: GeminiIdeCursor;
202
+ selectedText?: string;
203
+ }
204
+ interface GeminiIdeContext {
205
+ workspaceState?: {
206
+ openFiles?: GeminiIdeFile[];
207
+ isTrusted?: boolean;
208
+ };
209
+ }
210
+ interface GeminiIdeInfo {
211
+ name: string;
212
+ displayName: string;
213
+ }
214
+ interface GeminiIdeCompanionServerOptions {
215
+ port?: number;
216
+ host?: string;
217
+ endpointPath?: string;
218
+ authToken?: string;
219
+ enableDiscoveryFile?: boolean;
220
+ discoveryPid?: number;
221
+ workspacePaths?: string[];
222
+ ideInfo?: GeminiIdeInfo;
223
+ logger?: {
224
+ info?: (...args: unknown[]) => void;
225
+ warn?: (...args: unknown[]) => void;
226
+ error?: (...args: unknown[]) => void;
227
+ };
228
+ }
229
+ interface GeminiIdeCompanionServer {
230
+ readonly port: number;
231
+ readonly host: string;
232
+ readonly url: string;
233
+ readonly endpointPath: string;
234
+ readonly authToken: string;
235
+ readonly discoveryFilePath: string | null;
236
+ sessionIds(): string[];
237
+ sendDiffAccepted(filePath: string, content?: string, sessionId?: string): Promise<string[]>;
238
+ sendDiffRejected(filePath: string, sessionId?: string): Promise<string[]>;
239
+ sendContextUpdate(context: GeminiIdeContext, sessionId?: string): Promise<string[]>;
240
+ close(): Promise<void>;
241
+ }
242
+ declare function startGeminiIdeCompanionServer(options?: GeminiIdeCompanionServerOptions): Promise<GeminiIdeCompanionServer>;
243
+
193
244
  /**
194
245
  * Shared config (tap-config.json) — git tracked, repo-level defaults.
195
246
  * All paths are repo-relative unless explicitly absolute.
@@ -248,6 +299,26 @@ declare function resolveConfig(overrides?: ConfigOverrides, startDir?: string):
248
299
  declare function saveSharedConfig(repoRoot: string, config: TapSharedConfig): void;
249
300
  declare function saveLocalConfig(repoRoot: string, config: TapLocalConfig): void;
250
301
 
302
+ /**
303
+ * Bridge observability — heartbeat monitoring, turn stuck detection, log rotation.
304
+ *
305
+ * Consolidated from bridge-state.ts (heartbeat/turn functions) and
306
+ * bridge-log-rotate.ts into a single observability module.
307
+ *
308
+ * @module engine/bridge-observability
309
+ */
310
+
311
+ /**
312
+ * Update the heartbeat timestamp for a running bridge.
313
+ * Only the owning process (matching PID) can update the heartbeat.
314
+ */
315
+ declare function updateBridgeHeartbeat(stateDir: string, instanceId: InstanceId): void;
316
+ /**
317
+ * Get heartbeat age in seconds. Returns null if no state or no heartbeat.
318
+ */
319
+ declare function getHeartbeatAge(stateDir: string, instanceId: InstanceId): number | null;
320
+ declare function rotateLog(logPath: string): void;
321
+
251
322
  interface BridgeStartOptions {
252
323
  instanceId: InstanceId;
253
324
  runtime: RuntimeName;
@@ -274,34 +345,17 @@ interface BridgeStartOptions {
274
345
  /** Skip auth gateway — app-server listens directly on the public port (localhost only). */
275
346
  noAuth?: boolean;
276
347
  }
348
+
277
349
  interface RestartBridgeOptions extends BridgeStartOptions {
278
350
  /** Max seconds to wait for active turn to complete before killing. Default: 30 */
279
351
  drainTimeoutSeconds?: number;
280
352
  }
281
353
  /**
282
- * Graceful bridge restart: wait for active turn cleanup stop start.
354
+ * Graceful bridge restart: wait for active turn -> cleanup -> stop -> start.
283
355
  * Prevents message loss during restart by draining active work first
284
356
  * and replaying unprocessed messages on the new instance.
285
- *
286
- * For headless instances: drain phase cleans up headless dispatch files
287
- * to prevent the new bridge from re-injecting completed review requests.
288
- * (별 finding: eager marking + replay collision)
289
357
  */
290
358
  declare function restartBridge(options: RestartBridgeOptions): Promise<BridgeState>;
291
- declare function rotateLog(logPath: string): void;
292
- /**
293
- * Update the heartbeat timestamp for a running bridge.
294
- * Bridge processes should call this periodically.
295
- *
296
- * Only the owning process (matching PID) can update the heartbeat.
297
- * This prevents state dir collision when multiple writers exist.
298
- * See: 묵 finding — bridge-heartbeat-state-dir-collision
299
- */
300
- declare function updateBridgeHeartbeat(stateDir: string, instanceId: InstanceId): void;
301
- /**
302
- * Get heartbeat age in seconds. Returns null if no state or no heartbeat.
303
- */
304
- declare function getHeartbeatAge(stateDir: string, instanceId: InstanceId): number | null;
305
359
 
306
360
  /**
307
361
  * Dashboard data collection engine.
@@ -496,4 +550,4 @@ declare function resolveNodeRuntime(configCommand: string, repoRoot: string): Re
496
550
  */
497
551
  declare function buildRuntimeEnv(repoRoot: string, baseEnv?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
498
552
 
499
- export { type AdapterContext, type AgentControlOptions, type AgentControlResult, type AgentInfo, type AppServerAuthState, type AppServerState, type ApplyResult, type ArtifactKind, type BridgeInfo, type BridgeMode, type BridgeState, type CommandCode, type CommandName, type CommandResult, type ConfigOverrides, type ConfigResolution, type ConfigSource, type DashboardSnapshot, type DashboardWarning, type EventStreamOptions, type HealthReport, type HttpServerOptions, type InstanceId, type InstanceState, LOCAL_CONFIG_FILE, type OwnedArtifact, type PRInfo, type PatchOp, type PatchOpType, type PatchPlan, type Platform, type ProbeResult, type ResolvedRuntime, type RuntimeAdapter, type RuntimeName, type RuntimeSource, type RuntimeState, SHARED_CONFIG_FILE, type StateApiOptions, type TapLocalConfig, type TapResolvedConfig, type TapSharedConfig, type TapState, type TapStateV1, type VerifyCheck, type VerifyResult, buildRuntimeEnv, collectDashboardSnapshot, createInitialState, getConfig, getDashboardSnapshot, getFnmBinDir, getHealthReport, getHeartbeatAge, loadLocalConfig, loadSharedConfig, loadState, probeFnmNode, readNodeVersion, resolveConfig, resolveNodeRuntime, restartBridge, rotateLog, saveLocalConfig, saveSharedConfig, saveState, startAgents, startHttpServer, stateExists, stopAgents, streamEvents, updateBridgeHeartbeat, version };
553
+ export { type AdapterContext, type AgentControlOptions, type AgentControlResult, type AgentInfo, type AppServerAuthState, type AppServerState, type ApplyResult, type ArtifactKind, type BridgeInfo, type BridgeMode, type BridgeState, type CommandCode, type CommandName, type CommandResult, type ConfigOverrides, type ConfigResolution, type ConfigSource, type DashboardSnapshot, type DashboardWarning, type EventStreamOptions, type GeminiIdeCompanionServer, type GeminiIdeCompanionServerOptions, type GeminiIdeContext, type GeminiIdeCursor, type GeminiIdeFile, type GeminiIdeInfo, type HealthReport, type HttpServerOptions, type InstanceId, type InstanceState, LOCAL_CONFIG_FILE, type OwnedArtifact, type PRInfo, type PatchOp, type PatchOpType, type PatchPlan, type Platform, type ProbeResult, type ResolvedRuntime, type RuntimeAdapter, type RuntimeName, type RuntimeSource, type RuntimeState, SHARED_CONFIG_FILE, type StateApiOptions, type TapLocalConfig, type TapResolvedConfig, type TapSharedConfig, type TapState, type TapStateV1, type VerifyCheck, type VerifyResult, buildRuntimeEnv, collectDashboardSnapshot, createInitialState, getConfig, getDashboardSnapshot, getFnmBinDir, getHealthReport, getHeartbeatAge, loadLocalConfig, loadSharedConfig, loadState, probeFnmNode, readNodeVersion, resolveConfig, resolveNodeRuntime, restartBridge, rotateLog, saveLocalConfig, saveSharedConfig, saveState, startAgents, startGeminiIdeCompanionServer, startHttpServer, stateExists, stopAgents, streamEvents, updateBridgeHeartbeat, version };