@rallycry/conveyor-agent 8.13.0 → 9.0.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.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _project_shared from '@project/shared';
2
- import { AgentSessionServiceMethods, AgentMode, AgentQuestion, AgentRunnerStatus, TagAuditRunnerRequest, TaskAuditRunnerRequest, DebugTelemetryEvent, DebugSessionSummary } from '@project/shared';
2
+ import { AgentSessionServiceMethods, AgentMode, AgentQuestion, AgentRunnerStatus } from '@project/shared';
3
3
  export * from '@project/shared';
4
4
  import { ChildProcess } from 'node:child_process';
5
5
 
@@ -255,8 +255,6 @@ interface LifecycleCallbacks {
255
255
  onTokenRefresh: () => void;
256
256
  onGitFlush: () => void;
257
257
  }
258
- /** 30 min idle, 60 min dormant, 30s heartbeat, 45 min token refresh, 2 min git flush */
259
- declare const DEFAULT_LIFECYCLE_CONFIG: LifecycleConfig;
260
258
  declare class Lifecycle {
261
259
  readonly config: LifecycleConfig;
262
260
  private readonly callbacks;
@@ -474,136 +472,6 @@ interface AgentRunnerCallbacks {
474
472
  onStatusChange: (status: string) => void | Promise<void>;
475
473
  }
476
474
 
477
- interface ProjectConnectionConfig {
478
- apiUrl: string;
479
- projectToken: string;
480
- projectId: string;
481
- }
482
- interface TaskAssignment {
483
- taskId: string;
484
- taskToken: string;
485
- sessionId?: string;
486
- apiUrl: string;
487
- mode: string;
488
- branch: string;
489
- devBranch: string;
490
- useWorktree?: boolean;
491
- isAuto?: boolean;
492
- useSandbox?: boolean;
493
- agentMode?: string;
494
- pty?: boolean;
495
- /**
496
- * Decrypted Claude Code subscription token (`CLAUDE_CODE_OAUTH_TOKEN`) for the
497
- * assigning user, resolved server-side. Forwarded into the forked child's env
498
- * so the `claude` CLI is authenticated without a login prompt. Absent when the
499
- * user has no key configured — the child then falls back to the runner
500
- * machine's own `~/.claude` login.
501
- */
502
- claudeCodeOauthToken?: string;
503
- }
504
- interface IncomingChatMessage {
505
- content: string;
506
- userId: string;
507
- chatId?: string;
508
- projectId: string;
509
- /** When set, only the runner whose session matches should react. Other
510
- * runners on the same project room must ignore the message. */
511
- targetSessionId?: string | null;
512
- timestamp: string;
513
- }
514
- interface SwitchBranchRequest {
515
- branch: string;
516
- syncAfter?: boolean;
517
- }
518
- declare class ProjectConnection {
519
- private socket;
520
- private readonly config;
521
- private eventBuffer;
522
- private flushTimer;
523
- private reconnectCallbacks;
524
- constructor(config: ProjectConnectionConfig);
525
- get projectId(): string;
526
- get connected(): boolean;
527
- call<M extends keyof AgentSessionServiceMethods>(method: M, payload: AgentSessionServiceMethods[M]["payload"], opts?: {
528
- timeoutMs?: number;
529
- }): Promise<AgentSessionServiceMethods[M]["response"]>;
530
- connect(): Promise<void>;
531
- disconnect(): void;
532
- onReconnect(callback: () => void): void;
533
- onTaskAssignment(callback: (assignment: TaskAssignment) => void): void;
534
- onStopTask(callback: (data: {
535
- taskId: string;
536
- }) => void): void;
537
- onShutdown(callback: () => void): void;
538
- onDisconnect(callback: () => void): void;
539
- onChatMessage(callback: (msg: IncomingChatMessage) => void): void;
540
- onSwitchBranch(callback: (data: SwitchBranchRequest, cb: (res: {
541
- ok: boolean;
542
- error?: string;
543
- }) => void) => void): void;
544
- onSyncEnvironment(callback: (cb: (res: {
545
- ok: boolean;
546
- error?: string;
547
- }) => void) => void): void;
548
- onRestartStartCommand(callback: (cb: (res: {
549
- ok: boolean;
550
- error?: string;
551
- }) => void) => void): void;
552
- onAuditTags(callback: (request: TagAuditRunnerRequest) => void): void;
553
- onAuditTasks(callback: (request: TaskAuditRunnerRequest) => void): void;
554
- sendHeartbeat(): void;
555
- sendEvent(event: Record<string, unknown>): void;
556
- emitStatus(status: "busy" | "idle"): void;
557
- emitTaskStarted(taskId: string): void;
558
- emitTaskStopped(taskId: string, reason: string): void;
559
- private flushEvents;
560
- private requireSocket;
561
- }
562
-
563
- interface ProjectRunnerConfig {
564
- conveyorApiUrl: string;
565
- projectToken: string;
566
- projectId: string;
567
- projectDir: string;
568
- }
569
- declare class ProjectRunner {
570
- private connection;
571
- private projectDir;
572
- private activeAgents;
573
- private heartbeatTimer;
574
- private stopping;
575
- private resolveLifecycle;
576
- private chatSessionIds;
577
- /** ProjectCodespaceSession id assigned at register time. Used to filter
578
- * targeted incoming chat messages so we only react to ones addressed
579
- * to this specific runner. */
580
- private projectSessionId;
581
- private startCmd;
582
- private setupComplete;
583
- private branchSwitchCommand;
584
- private commitWatcher;
585
- constructor(config: ProjectRunnerConfig);
586
- start(): Promise<void>;
587
- /** Best-effort WIP commit + push of every tracked working tree on shutdown.
588
- * Iterates the main project dir plus any active agent worktrees so nothing
589
- * pending is lost when the pod is killed. Never throws.
590
- *
591
- * Callers that kill child agents first must snapshot the worktree dirs
592
- * BEFORE the kill — the child exit handler removes entries from
593
- * `activeAgents`, so reading it after the kill misses the worktrees. */
594
- flushGitOnShutdown(dirs?: Set<string>): Promise<void>;
595
- stop(): Promise<void>;
596
- /** Idempotent final step: tear down the socket and resolve the lifecycle
597
- * promise so start() returns. Called from stop()'s finally and from the
598
- * shutdown watchdog. */
599
- private finishShutdown;
600
- private wireEventHandlers;
601
- private handleReconnect;
602
- private handleAuditTags;
603
- private handleAuditTasks;
604
- private getCurrentBranch;
605
- }
606
-
607
475
  declare class PlanSync {
608
476
  private planFileSnapshot;
609
477
  private lockedPlanFile;
@@ -617,62 +485,6 @@ declare class PlanSync {
617
485
  syncPlanFile(): Promise<void>;
618
486
  }
619
487
 
620
- interface CacheEntry {
621
- content: Buffer;
622
- mimeType: string;
623
- fileName: string;
624
- createdAt: number;
625
- size: number;
626
- }
627
- declare class FileCache {
628
- private cache;
629
- private currentSize;
630
- private readonly maxSizeBytes;
631
- private readonly ttlMs;
632
- constructor(maxSizeBytes?: number, ttlMs?: number);
633
- get(fileId: string): CacheEntry | null;
634
- set(fileId: string, content: Buffer, mimeType: string, fileName: string): void;
635
- private delete;
636
- clear(): void;
637
- get stats(): {
638
- entries: number;
639
- sizeBytes: number;
640
- maxSizeBytes: number;
641
- };
642
- }
643
-
644
- interface CommitWatcherConfig {
645
- projectDir: string;
646
- pollIntervalMs: number;
647
- debounceMs: number;
648
- }
649
- interface NewCommitsData {
650
- branch: string;
651
- previousSha: string;
652
- newCommitSha: string;
653
- commitCount: number;
654
- latestMessage: string;
655
- latestAuthor: string;
656
- }
657
- interface CommitWatcherCallbacks {
658
- onNewCommits: (data: NewCommitsData) => Promise<void>;
659
- }
660
- declare class CommitWatcher {
661
- private config;
662
- private callbacks;
663
- private interval;
664
- private lastKnownRemoteSha;
665
- private branch;
666
- private debounceTimer;
667
- private isSyncing;
668
- constructor(config: CommitWatcherConfig, callbacks: CommitWatcherCallbacks);
669
- start(branch: string): void;
670
- stop(): void;
671
- private getLocalHeadSha;
672
- private poll;
673
- private handleNewCommits;
674
- }
675
-
676
488
  /** Returns true if the working tree has uncommitted changes (staged or unstaged). */
677
489
  declare function hasUncommittedChanges(cwd: string): boolean;
678
490
  /** Returns the current branch name, or null if on detached HEAD. */
@@ -712,316 +524,6 @@ declare function detachWorktreeBranch(projectDir: string, branch: string): void;
712
524
  */
713
525
  declare function removeWorktree(projectDir: string, taskId: string): void;
714
526
 
715
- interface BreakpointInfo {
716
- breakpointId: string;
717
- file: string;
718
- line: number;
719
- condition?: string;
720
- }
721
- interface ProbeInfo {
722
- probeId: string;
723
- breakpointId: string;
724
- file: string;
725
- line: number;
726
- expressions: string[];
727
- label: string;
728
- }
729
- interface ProbeHit {
730
- label: string;
731
- data: Record<string, unknown>;
732
- timestamp: number;
733
- }
734
- interface CallFrameInfo {
735
- index: number;
736
- functionName: string;
737
- file: string;
738
- line: number;
739
- column: number;
740
- callFrameId: string;
741
- }
742
- interface ScopeVariable {
743
- name: string;
744
- type: string;
745
- value: string;
746
- }
747
- interface PausedState {
748
- callFrames: CallFrameInfo[];
749
- reason: string;
750
- hitBreakpoints?: string[];
751
- }
752
- type InspectorProtocol = "cdp" | "webkit";
753
- declare class CdpDebugClient {
754
- private ws;
755
- private requestId;
756
- private pendingRequests;
757
- private breakpoints;
758
- private probes;
759
- private probeCounter;
760
- private probeBufferInjected;
761
- private pausedState;
762
- private autoResumeTimer;
763
- private protocol;
764
- private onPausedCallback;
765
- private onResumedCallback;
766
- private onAutoResumedCallback;
767
- connect(wsUrl: string, protocol?: InspectorProtocol): Promise<void>;
768
- disconnect(): void;
769
- isConnected(): boolean;
770
- getProtocol(): InspectorProtocol;
771
- setBreakpoint(file: string, line: number, condition?: string): Promise<string>;
772
- removeBreakpoint(breakpointId: string): Promise<void>;
773
- removeAllBreakpoints(): Promise<void>;
774
- listBreakpoints(): BreakpointInfo[];
775
- setLogpoint(file: string, line: number, expressions: string[], label?: string): Promise<string>;
776
- removeProbe(probeId: string): Promise<void>;
777
- listProbes(): ProbeInfo[];
778
- getProbeResults(label?: string, limit?: number): Promise<ProbeHit[]>;
779
- clearProbeResults(label?: string): Promise<void>;
780
- isPaused(): boolean;
781
- getPausedState(): PausedState | null;
782
- getCallStack(): CallFrameInfo[];
783
- getScopeVariables(callFrameId: string): Promise<ScopeVariable[]>;
784
- resume(): Promise<void>;
785
- stepOver(): Promise<void>;
786
- stepInto(): Promise<void>;
787
- evaluate(expression: string, callFrameId?: string): Promise<{
788
- type: string;
789
- value: string;
790
- }>;
791
- onPaused(callback: (state: PausedState) => void): void;
792
- onResumed(callback: () => void): void;
793
- onAutoResumed(callback: () => void): void;
794
- private send;
795
- private handleMessage;
796
- private handlePaused;
797
- private ensureProbeBuffer;
798
- private extractEvalError;
799
- private fileToUrlRegex;
800
- private formatRemoteObject;
801
- private truncateValue;
802
- private clearAutoResumeTimer;
803
- private cleanup;
804
- }
805
-
806
- interface ConsoleMessage {
807
- level: string;
808
- text: string;
809
- timestamp: number;
810
- url?: string;
811
- line?: number;
812
- }
813
- interface NetworkRequest {
814
- url: string;
815
- method: string;
816
- status?: number;
817
- resourceType?: string;
818
- timestamp: number;
819
- duration?: number;
820
- }
821
- interface ClientPageError {
822
- message: string;
823
- stack?: string;
824
- timestamp: number;
825
- }
826
-
827
- declare class PlaywrightDebugClient {
828
- private browser;
829
- private page;
830
- private cdpSession;
831
- private breakpoints;
832
- private probes;
833
- private probeCounter;
834
- private probeBufferInjected;
835
- private pausedState;
836
- private autoResumeTimer;
837
- private inactivityTimer;
838
- private onPausedCallback;
839
- private onResumedCallback;
840
- private onAutoResumedCallback;
841
- private consoleMessages;
842
- private networkRequests;
843
- private pageErrors;
844
- private sourceMapDetected;
845
- launch(previewUrl: string): Promise<void>;
846
- close(): Promise<void>;
847
- isConnected(): boolean;
848
- hasSourceMaps(): boolean | null;
849
- setBreakpoint(file: string, line: number, condition?: string): Promise<string>;
850
- removeBreakpoint(breakpointId: string): Promise<void>;
851
- removeAllBreakpoints(): Promise<void>;
852
- listBreakpoints(): BreakpointInfo[];
853
- setLogpoint(file: string, line: number, expressions: string[], label?: string): Promise<string>;
854
- removeProbe(probeId: string): Promise<void>;
855
- listProbes(): ProbeInfo[];
856
- getProbeResults(label?: string, limit?: number): Promise<ProbeHit[]>;
857
- clearProbeResults(label?: string): Promise<void>;
858
- isPaused(): boolean;
859
- getPausedState(): PausedState | null;
860
- getCallStack(): CallFrameInfo[];
861
- getScopeVariables(callFrameId: string): Promise<ScopeVariable[]>;
862
- resume(): Promise<void>;
863
- stepOver(): Promise<void>;
864
- stepInto(): Promise<void>;
865
- evaluate(expression: string, callFrameId?: string): Promise<{
866
- type: string;
867
- value: string;
868
- }>;
869
- navigate(url: string): Promise<void>;
870
- click(selector: string): Promise<void>;
871
- screenshot(): Promise<string>;
872
- getCurrentUrl(): string;
873
- getConsoleMessages(level?: string, limit?: number): ConsoleMessage[];
874
- getNetworkRequests(filter?: string, limit?: number): NetworkRequest[];
875
- getPageErrors(limit?: number): ClientPageError[];
876
- onPaused(callback: (state: PausedState) => void): void;
877
- onResumed(callback: () => void): void;
878
- onAutoResumed(callback: () => void): void;
879
- private setupCdpEvents;
880
- private handlePaused;
881
- private setupPassiveCapture;
882
- private checkSourceMaps;
883
- private ensureProbeBuffer;
884
- private requireSession;
885
- private requirePage;
886
- private fileToUrlRegex;
887
- private clearAutoResumeTimer;
888
- private resetInactivityTimer;
889
- private clearInactivityTimer;
890
- }
891
-
892
- type InspectorRuntime = "node" | "bun" | "unknown";
893
- interface DebugEventHandler {
894
- onDebugModeEntered: () => void;
895
- onDebugModeExited: () => void;
896
- onBreakpointHit: (state: PausedState) => void;
897
- onClientBreakpointHit: (state: PausedState) => void;
898
- onAutoResumed: () => void;
899
- onDebugError: (message: string) => void;
900
- onOutput: (stream: "stdout" | "stderr", data: string) => void;
901
- }
902
- interface DebugModeOptions {
903
- serverSide?: boolean;
904
- clientSide?: boolean;
905
- previewUrl?: string;
906
- }
907
- declare class DebugManager {
908
- private cdpClient;
909
- private playwrightClient;
910
- private debugProcess;
911
- private _isDebugMode;
912
- private _isClientDebugMode;
913
- private startCommand;
914
- private workingDir;
915
- private eventHandler;
916
- private breakpointHitQueue;
917
- private clientBreakpointHitQueue;
918
- constructor(startCommand: string, workingDir: string, eventHandler: DebugEventHandler);
919
- isDebugMode(): boolean;
920
- isClientDebugMode(): boolean;
921
- getClient(): CdpDebugClient | null;
922
- getPlaywrightClient(): PlaywrightDebugClient | null;
923
- drainBreakpointHitQueue(): PausedState[];
924
- drainClientBreakpointHitQueue(): PausedState[];
925
- enterDebugMode(killCurrentProcess?: () => void, options?: DebugModeOptions): Promise<void>;
926
- exitDebugMode(restartNormalServer?: () => void): Promise<void>;
927
- private activateServerDebug;
928
- private activateClientDebug;
929
- private ensurePlaywrightInstalled;
930
- private startWithInspector;
931
- }
932
- declare function detectRuntime(startCommand: string): InspectorRuntime;
933
- declare function injectBunInspectFlag(command: string): string;
934
-
935
- /**
936
- * Orchestrates the debug session lifecycle, tracks state for the web UI,
937
- * and generates session summaries. Wraps DebugManager events and forwards
938
- * state changes to the API via AgentConnection.
939
- */
940
- declare class DebugLifecycleManager {
941
- private connection;
942
- private debugManager;
943
- private hypothesis?;
944
- private sessionStartedAt?;
945
- private breakpointsHitCount;
946
- private telemetryEvents;
947
- private reproduceRequested;
948
- private keyFindings;
949
- private _isActive;
950
- constructor(connection: AgentConnection);
951
- get isActive(): boolean;
952
- setDebugManager(manager: DebugManager): void;
953
- /**
954
- * Creates a DebugEventHandler that bridges DebugManager events
955
- * to the lifecycle manager and broadcasts state to the web UI.
956
- */
957
- createEventHandler(baseOnOutput: (stream: "stdout" | "stderr", data: string) => void): DebugEventHandler;
958
- /** Mark the hypothesis for the current debug session */
959
- setHypothesis(hypothesis: string): void;
960
- /** Signal that the user has been asked to reproduce the bug */
961
- requestReproduce(hypothesis?: string): void;
962
- /** Add a telemetry event to the debug session */
963
- addTelemetryEvent(event: DebugTelemetryEvent): void;
964
- /** Generate and broadcast a debug session summary, then reset state */
965
- completeSession(): DebugSessionSummary | null;
966
- /** Auto-exit cleanup — called when agent session ends */
967
- autoCleanup(): void;
968
- private getBreakpoints;
969
- private getProbes;
970
- private buildState;
971
- private broadcastState;
972
- }
973
-
974
- interface Observation {
975
- description: string;
976
- confirmsHypothesis: boolean;
977
- iteration: number;
978
- timestamp: number;
979
- }
980
- interface HypothesisState {
981
- hypothesis: string | null;
982
- iteration: number;
983
- observations: Observation[];
984
- active: boolean;
985
- conclusion: string | null;
986
- }
987
- declare class HypothesisTracker {
988
- private hypothesis;
989
- private iteration;
990
- private observations;
991
- private _active;
992
- private conclusion;
993
- /**
994
- * Start or update the current debugging hypothesis.
995
- * Increments the iteration count if a hypothesis was already set.
996
- */
997
- setHypothesis(text: string): {
998
- accepted: boolean;
999
- message: string;
1000
- };
1001
- /**
1002
- * Record an observation from debug data (breakpoint hit, telemetry, etc.).
1003
- */
1004
- recordObservation(description: string, confirmsHypothesis: boolean): void;
1005
- /**
1006
- * End the debug session with a conclusion.
1007
- */
1008
- concludeSession(conclusion: string): string;
1009
- /**
1010
- * Get formatted debug context for injection into the agent's system prompt.
1011
- * Returns empty string if no active session.
1012
- */
1013
- getDebugContext(): string;
1014
- /**
1015
- * Get the full state (for serialization/testing).
1016
- */
1017
- getState(): HypothesisState;
1018
- isActive(): boolean;
1019
- getIteration(): number;
1020
- getMaxIterations(): number;
1021
- private getSessionSummary;
1022
- private reset;
1023
- }
1024
-
1025
527
  interface ConveyorConfig {
1026
528
  setupCommand?: string;
1027
529
  startCommand?: string;
@@ -1045,4 +547,4 @@ declare function runStartCommand(cmd: string, cwd: string, onOutput: (stream: "s
1045
547
  /** Fetch full git history if the repo was cloned with --depth=1. */
1046
548
  declare function unshallowRepo(workspaceDir: string): void;
1047
549
 
1048
- export { AgentConnection, type AgentConnectionConfig, type AgentRunnerCallbacks, type AgentRunnerConfig, type ApiKeyUpdateData, CommitWatcher, type ConveyorConfig, DEFAULT_LIFECYCLE_CONFIG, type DebugEventHandler, DebugLifecycleManager, DebugManager, type DebugModeOptions, FileCache, HypothesisTracker, type IncomingMessage, type InspectorRuntime, Lifecycle, type LifecycleCallbacks, type LifecycleConfig, type ModeAction, ModeController, type ModeTaskContext, PlanSync, ProjectConnection, ProjectRunner, SessionRunner, type SessionRunnerCallbacks, type SessionRunnerConfig, type SetModeData, detachWorktreeBranch, detectRuntime, ensureWorktree, flushPendingChanges, getCurrentBranch, hasUncommittedChanges, hasUnpushedCommits, injectBunInspectFlag, loadConveyorConfig, loadForwardPorts, pushToOrigin, removeWorktree, runAuthTokenCommand, runSetupCommand, runStartCommand, stageAndCommit, unshallowRepo, updateRemoteToken };
550
+ export { AgentConnection, type AgentConnectionConfig, type AgentRunnerCallbacks, type AgentRunnerConfig, type ApiKeyUpdateData, type ConveyorConfig, type IncomingMessage, type LifecycleCallbacks, type LifecycleConfig, type ModeAction, type ModeTaskContext, PlanSync, SessionRunner, type SessionRunnerCallbacks, type SessionRunnerConfig, type SetModeData, detachWorktreeBranch, ensureWorktree, flushPendingChanges, getCurrentBranch, hasUncommittedChanges, hasUnpushedCommits, loadConveyorConfig, loadForwardPorts, pushToOrigin, removeWorktree, runAuthTokenCommand, runSetupCommand, runStartCommand, stageAndCommit, unshallowRepo, updateRemoteToken };