@spotpatch/bridge 0.1.0 → 0.2.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/cli.js +15 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1878 -168
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -2
- package/dist/index.d.ts +110 -2
- package/dist/index.js +1884 -164
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { ExternalHandoffActiveAdapterKind, ExternalHandoffReportableDispatchPhase, ExternalHandoffSummary } from '@spotpatch/shared';
|
|
1
|
+
import { ExternalHandoffActiveAdapterKind, externalHandoffSnapshotSchema, ExternalHandoffReportableDispatchPhase, ExternalHandoffSummary, ResolvedAgentCheckDefinition, AgentLimits, ExternalAgentControlStatus, ExternalAgentControlConnectRequest, ExternalAgentControlDisconnectRequest, ExternalAgentControlCancelRequest, ExternalAgentManagedResult } from '@spotpatch/shared';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/server';
|
|
4
4
|
import { StdioServerHandle } from '@modelcontextprotocol/server/stdio';
|
|
5
|
+
import { ManagedExecutionPort, ManagedExecutionResult } from '@spotpatch/agent';
|
|
5
6
|
|
|
6
7
|
type ActiveAdapterKind = ExternalHandoffActiveAdapterKind;
|
|
7
8
|
type ActiveReportPhase = ExternalHandoffReportableDispatchPhase;
|
|
9
|
+
type AgentDeliveryPhase = Exclude<ActiveReportPhase, "dispatching">;
|
|
10
|
+
type AgentHandoffSnapshot = z.infer<typeof externalHandoffSnapshotSchema>;
|
|
8
11
|
/**
|
|
9
12
|
* Lease data is connector-private. It must never be included in MCP output,
|
|
10
13
|
* Channel metadata, diagnostics, or browser-facing state.
|
|
@@ -26,6 +29,16 @@ interface ActiveBridgeClient {
|
|
|
26
29
|
readonly activeRelease: (lease: ActiveBridgeLease, signal?: AbortSignal) => Promise<void>;
|
|
27
30
|
readonly activeReport: (lease: ActiveBridgeLease, cursor: string, phase: ActiveReportPhase, signal?: AbortSignal) => Promise<void>;
|
|
28
31
|
}
|
|
32
|
+
interface AgentDeliveryLifecycle {
|
|
33
|
+
/** The sole state-writing path available to a vendor adapter. */
|
|
34
|
+
readonly report: (phase: AgentDeliveryPhase) => Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
interface AgentAdapter {
|
|
37
|
+
readonly kind: ActiveAdapterKind;
|
|
38
|
+
readonly close: () => Promise<void>;
|
|
39
|
+
/** Resolves only after a proved completed/failed terminal report. */
|
|
40
|
+
readonly deliver: (handoff: AgentHandoffSnapshot, lifecycle: AgentDeliveryLifecycle, signal: AbortSignal) => Promise<void>;
|
|
41
|
+
}
|
|
29
42
|
|
|
30
43
|
declare const sessionListItemSchema: z.ZodObject<{
|
|
31
44
|
sessionId: z.ZodString;
|
|
@@ -499,4 +512,99 @@ interface SpotPatchMcpScope {
|
|
|
499
512
|
declare function createSpotPatchMcpServer(cwd?: string, scope?: SpotPatchMcpScope): McpServer;
|
|
500
513
|
declare function serveSpotPatchMcp(cwd?: string, scope?: SpotPatchMcpScope): StdioServerHandle;
|
|
501
514
|
|
|
502
|
-
|
|
515
|
+
interface ManagedThreadCleanupEntry {
|
|
516
|
+
readonly threadId: string;
|
|
517
|
+
readonly createdAt: string;
|
|
518
|
+
}
|
|
519
|
+
interface ManagedThreadCleanupJournal {
|
|
520
|
+
list(): Promise<readonly ManagedThreadCleanupEntry[]>;
|
|
521
|
+
add(threadId: string): Promise<void>;
|
|
522
|
+
remove(threadId: string): Promise<void>;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
type ManagedAdapterEvent = Readonly<{
|
|
526
|
+
type: "phase";
|
|
527
|
+
revision: number;
|
|
528
|
+
phase: "preparing" | "running" | "auditing" | "validating" | "applying";
|
|
529
|
+
}> | Readonly<{
|
|
530
|
+
type: "result";
|
|
531
|
+
result: ManagedExecutionResult;
|
|
532
|
+
}> | Readonly<{
|
|
533
|
+
type: "cleanup-warning";
|
|
534
|
+
revision: number;
|
|
535
|
+
}> | Readonly<{
|
|
536
|
+
type: "failure";
|
|
537
|
+
revision: number;
|
|
538
|
+
reason: "apply" | "change-limit" | "config-isolation" | "protocol" | "scope" | "snapshot" | "validation" | "workspace-conflict";
|
|
539
|
+
}>;
|
|
540
|
+
interface ManagedAdapterConnection {
|
|
541
|
+
readonly adapter: AgentAdapter;
|
|
542
|
+
readonly authReadiness: "authenticated" | "auth-not-required" | "signed-out" | "unknown";
|
|
543
|
+
readonly requestedModel?: string;
|
|
544
|
+
readonly effectiveModel?: string;
|
|
545
|
+
}
|
|
546
|
+
interface ConnectManagedAdapterOptions {
|
|
547
|
+
readonly bridgeAdapter: BridgeCliAdapter;
|
|
548
|
+
readonly execution: ManagedExecutionPort;
|
|
549
|
+
readonly cleanupJournal: ManagedThreadCleanupJournal;
|
|
550
|
+
readonly onEvent: (event: ManagedAdapterEvent) => void;
|
|
551
|
+
readonly privateRuntimeBase?: string;
|
|
552
|
+
readonly projectRoot: string;
|
|
553
|
+
readonly runtimeKey: string;
|
|
554
|
+
readonly sessionId: string;
|
|
555
|
+
readonly signal: AbortSignal;
|
|
556
|
+
}
|
|
557
|
+
type ConnectManagedAdapter = (options: ConnectManagedAdapterOptions) => Promise<ManagedAdapterConnection>;
|
|
558
|
+
interface ExternalAgentSupervisor {
|
|
559
|
+
getStatus(): ExternalAgentControlStatus;
|
|
560
|
+
connect(request: ExternalAgentControlConnectRequest, signal: AbortSignal): Promise<ExternalAgentControlStatus>;
|
|
561
|
+
disconnect(request: ExternalAgentControlDisconnectRequest): Promise<ExternalAgentControlStatus>;
|
|
562
|
+
cancel(request: ExternalAgentControlCancelRequest): Promise<ExternalAgentControlStatus>;
|
|
563
|
+
getResult(revision: number): ExternalAgentManagedResult | undefined;
|
|
564
|
+
subscribe(listener: (status: ExternalAgentControlStatus) => void): () => void;
|
|
565
|
+
dispose(): Promise<void>;
|
|
566
|
+
}
|
|
567
|
+
interface CreateExternalAgentSupervisorOptions {
|
|
568
|
+
readonly bridgeAdapter: BridgeCliAdapter;
|
|
569
|
+
readonly checks?: Readonly<Record<string, ResolvedAgentCheckDefinition>>;
|
|
570
|
+
readonly configBase?: string;
|
|
571
|
+
readonly confirmManagedAccess?: (projectLabel: string) => Promise<boolean>;
|
|
572
|
+
readonly connectManagedAdapter?: ConnectManagedAdapter;
|
|
573
|
+
readonly limits?: Readonly<AgentLimits>;
|
|
574
|
+
readonly now?: () => Date;
|
|
575
|
+
readonly projectLabel?: string;
|
|
576
|
+
readonly root: string;
|
|
577
|
+
readonly sessionId: string;
|
|
578
|
+
}
|
|
579
|
+
declare function createExternalAgentSupervisor(options: CreateExternalAgentSupervisorOptions): Promise<ExternalAgentSupervisor>;
|
|
580
|
+
|
|
581
|
+
interface CodexProtocolDiagnostics {
|
|
582
|
+
readonly stderrBytesObserved: number;
|
|
583
|
+
readonly stderrTruncated: boolean;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
interface ConnectManagedCodexAppServerOptions extends ConnectManagedAdapterOptions {
|
|
587
|
+
readonly maximumLineBytes?: number;
|
|
588
|
+
readonly maximumStderrBytes?: number;
|
|
589
|
+
readonly pathValue?: string;
|
|
590
|
+
readonly processShutdownTimeoutMs?: number;
|
|
591
|
+
readonly requestTimeoutMs?: number;
|
|
592
|
+
readonly terminalTimeoutMs?: number;
|
|
593
|
+
}
|
|
594
|
+
declare class ManagedCodexAppServerAdapter implements AgentAdapter {
|
|
595
|
+
#private;
|
|
596
|
+
readonly kind: "codex-app-server";
|
|
597
|
+
private constructor();
|
|
598
|
+
static connect(options: ConnectManagedCodexAppServerOptions): Promise<Readonly<{
|
|
599
|
+
adapter: ManagedCodexAppServerAdapter;
|
|
600
|
+
authReadiness: ManagedAdapterConnection["authReadiness"];
|
|
601
|
+
requestedModel: string;
|
|
602
|
+
effectiveModel: string;
|
|
603
|
+
}>>;
|
|
604
|
+
diagnostics(): CodexProtocolDiagnostics;
|
|
605
|
+
deliver(handoff: AgentHandoffSnapshot, lifecycle: AgentDeliveryLifecycle, signal: AbortSignal): Promise<void>;
|
|
606
|
+
close(): Promise<void>;
|
|
607
|
+
}
|
|
608
|
+
declare function connectManagedCodexAppServer(options: ConnectManagedCodexAppServerOptions): Promise<ManagedAdapterConnection>;
|
|
609
|
+
|
|
610
|
+
export { type BridgeCliAdapter, type BridgeSetupClient, type BridgeSetupMode, type BridgeSetupPlan, type ConnectManagedAdapter, type ConnectManagedAdapterOptions, type ConnectManagedCodexAppServerOptions, type CreateExternalAgentSupervisorOptions, type ExternalAgentSessionListItem, type ExternalAgentSupervisor, type HandoffDelivery, type HandoffWaitDelivery, type ManagedAdapterConnection, type ManagedAdapterEvent, ManagedCodexAppServerAdapter, type RunSpotPatchBridgeCliOptions, type SpotPatchBridgeClient, applyBridgeSetupPlan, connectManagedCodexAppServer, createBridgeSetupPlan, createExternalAgentSupervisor, createSpotPatchBridgeClient, createSpotPatchMcpServer, runSpotPatchBridgeCli, serveSpotPatchMcp };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { ExternalHandoffActiveAdapterKind, ExternalHandoffReportableDispatchPhase, ExternalHandoffSummary } from '@spotpatch/shared';
|
|
1
|
+
import { ExternalHandoffActiveAdapterKind, externalHandoffSnapshotSchema, ExternalHandoffReportableDispatchPhase, ExternalHandoffSummary, ResolvedAgentCheckDefinition, AgentLimits, ExternalAgentControlStatus, ExternalAgentControlConnectRequest, ExternalAgentControlDisconnectRequest, ExternalAgentControlCancelRequest, ExternalAgentManagedResult } from '@spotpatch/shared';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { McpServer } from '@modelcontextprotocol/server';
|
|
4
4
|
import { StdioServerHandle } from '@modelcontextprotocol/server/stdio';
|
|
5
|
+
import { ManagedExecutionPort, ManagedExecutionResult } from '@spotpatch/agent';
|
|
5
6
|
|
|
6
7
|
type ActiveAdapterKind = ExternalHandoffActiveAdapterKind;
|
|
7
8
|
type ActiveReportPhase = ExternalHandoffReportableDispatchPhase;
|
|
9
|
+
type AgentDeliveryPhase = Exclude<ActiveReportPhase, "dispatching">;
|
|
10
|
+
type AgentHandoffSnapshot = z.infer<typeof externalHandoffSnapshotSchema>;
|
|
8
11
|
/**
|
|
9
12
|
* Lease data is connector-private. It must never be included in MCP output,
|
|
10
13
|
* Channel metadata, diagnostics, or browser-facing state.
|
|
@@ -26,6 +29,16 @@ interface ActiveBridgeClient {
|
|
|
26
29
|
readonly activeRelease: (lease: ActiveBridgeLease, signal?: AbortSignal) => Promise<void>;
|
|
27
30
|
readonly activeReport: (lease: ActiveBridgeLease, cursor: string, phase: ActiveReportPhase, signal?: AbortSignal) => Promise<void>;
|
|
28
31
|
}
|
|
32
|
+
interface AgentDeliveryLifecycle {
|
|
33
|
+
/** The sole state-writing path available to a vendor adapter. */
|
|
34
|
+
readonly report: (phase: AgentDeliveryPhase) => Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
interface AgentAdapter {
|
|
37
|
+
readonly kind: ActiveAdapterKind;
|
|
38
|
+
readonly close: () => Promise<void>;
|
|
39
|
+
/** Resolves only after a proved completed/failed terminal report. */
|
|
40
|
+
readonly deliver: (handoff: AgentHandoffSnapshot, lifecycle: AgentDeliveryLifecycle, signal: AbortSignal) => Promise<void>;
|
|
41
|
+
}
|
|
29
42
|
|
|
30
43
|
declare const sessionListItemSchema: z.ZodObject<{
|
|
31
44
|
sessionId: z.ZodString;
|
|
@@ -499,4 +512,99 @@ interface SpotPatchMcpScope {
|
|
|
499
512
|
declare function createSpotPatchMcpServer(cwd?: string, scope?: SpotPatchMcpScope): McpServer;
|
|
500
513
|
declare function serveSpotPatchMcp(cwd?: string, scope?: SpotPatchMcpScope): StdioServerHandle;
|
|
501
514
|
|
|
502
|
-
|
|
515
|
+
interface ManagedThreadCleanupEntry {
|
|
516
|
+
readonly threadId: string;
|
|
517
|
+
readonly createdAt: string;
|
|
518
|
+
}
|
|
519
|
+
interface ManagedThreadCleanupJournal {
|
|
520
|
+
list(): Promise<readonly ManagedThreadCleanupEntry[]>;
|
|
521
|
+
add(threadId: string): Promise<void>;
|
|
522
|
+
remove(threadId: string): Promise<void>;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
type ManagedAdapterEvent = Readonly<{
|
|
526
|
+
type: "phase";
|
|
527
|
+
revision: number;
|
|
528
|
+
phase: "preparing" | "running" | "auditing" | "validating" | "applying";
|
|
529
|
+
}> | Readonly<{
|
|
530
|
+
type: "result";
|
|
531
|
+
result: ManagedExecutionResult;
|
|
532
|
+
}> | Readonly<{
|
|
533
|
+
type: "cleanup-warning";
|
|
534
|
+
revision: number;
|
|
535
|
+
}> | Readonly<{
|
|
536
|
+
type: "failure";
|
|
537
|
+
revision: number;
|
|
538
|
+
reason: "apply" | "change-limit" | "config-isolation" | "protocol" | "scope" | "snapshot" | "validation" | "workspace-conflict";
|
|
539
|
+
}>;
|
|
540
|
+
interface ManagedAdapterConnection {
|
|
541
|
+
readonly adapter: AgentAdapter;
|
|
542
|
+
readonly authReadiness: "authenticated" | "auth-not-required" | "signed-out" | "unknown";
|
|
543
|
+
readonly requestedModel?: string;
|
|
544
|
+
readonly effectiveModel?: string;
|
|
545
|
+
}
|
|
546
|
+
interface ConnectManagedAdapterOptions {
|
|
547
|
+
readonly bridgeAdapter: BridgeCliAdapter;
|
|
548
|
+
readonly execution: ManagedExecutionPort;
|
|
549
|
+
readonly cleanupJournal: ManagedThreadCleanupJournal;
|
|
550
|
+
readonly onEvent: (event: ManagedAdapterEvent) => void;
|
|
551
|
+
readonly privateRuntimeBase?: string;
|
|
552
|
+
readonly projectRoot: string;
|
|
553
|
+
readonly runtimeKey: string;
|
|
554
|
+
readonly sessionId: string;
|
|
555
|
+
readonly signal: AbortSignal;
|
|
556
|
+
}
|
|
557
|
+
type ConnectManagedAdapter = (options: ConnectManagedAdapterOptions) => Promise<ManagedAdapterConnection>;
|
|
558
|
+
interface ExternalAgentSupervisor {
|
|
559
|
+
getStatus(): ExternalAgentControlStatus;
|
|
560
|
+
connect(request: ExternalAgentControlConnectRequest, signal: AbortSignal): Promise<ExternalAgentControlStatus>;
|
|
561
|
+
disconnect(request: ExternalAgentControlDisconnectRequest): Promise<ExternalAgentControlStatus>;
|
|
562
|
+
cancel(request: ExternalAgentControlCancelRequest): Promise<ExternalAgentControlStatus>;
|
|
563
|
+
getResult(revision: number): ExternalAgentManagedResult | undefined;
|
|
564
|
+
subscribe(listener: (status: ExternalAgentControlStatus) => void): () => void;
|
|
565
|
+
dispose(): Promise<void>;
|
|
566
|
+
}
|
|
567
|
+
interface CreateExternalAgentSupervisorOptions {
|
|
568
|
+
readonly bridgeAdapter: BridgeCliAdapter;
|
|
569
|
+
readonly checks?: Readonly<Record<string, ResolvedAgentCheckDefinition>>;
|
|
570
|
+
readonly configBase?: string;
|
|
571
|
+
readonly confirmManagedAccess?: (projectLabel: string) => Promise<boolean>;
|
|
572
|
+
readonly connectManagedAdapter?: ConnectManagedAdapter;
|
|
573
|
+
readonly limits?: Readonly<AgentLimits>;
|
|
574
|
+
readonly now?: () => Date;
|
|
575
|
+
readonly projectLabel?: string;
|
|
576
|
+
readonly root: string;
|
|
577
|
+
readonly sessionId: string;
|
|
578
|
+
}
|
|
579
|
+
declare function createExternalAgentSupervisor(options: CreateExternalAgentSupervisorOptions): Promise<ExternalAgentSupervisor>;
|
|
580
|
+
|
|
581
|
+
interface CodexProtocolDiagnostics {
|
|
582
|
+
readonly stderrBytesObserved: number;
|
|
583
|
+
readonly stderrTruncated: boolean;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
interface ConnectManagedCodexAppServerOptions extends ConnectManagedAdapterOptions {
|
|
587
|
+
readonly maximumLineBytes?: number;
|
|
588
|
+
readonly maximumStderrBytes?: number;
|
|
589
|
+
readonly pathValue?: string;
|
|
590
|
+
readonly processShutdownTimeoutMs?: number;
|
|
591
|
+
readonly requestTimeoutMs?: number;
|
|
592
|
+
readonly terminalTimeoutMs?: number;
|
|
593
|
+
}
|
|
594
|
+
declare class ManagedCodexAppServerAdapter implements AgentAdapter {
|
|
595
|
+
#private;
|
|
596
|
+
readonly kind: "codex-app-server";
|
|
597
|
+
private constructor();
|
|
598
|
+
static connect(options: ConnectManagedCodexAppServerOptions): Promise<Readonly<{
|
|
599
|
+
adapter: ManagedCodexAppServerAdapter;
|
|
600
|
+
authReadiness: ManagedAdapterConnection["authReadiness"];
|
|
601
|
+
requestedModel: string;
|
|
602
|
+
effectiveModel: string;
|
|
603
|
+
}>>;
|
|
604
|
+
diagnostics(): CodexProtocolDiagnostics;
|
|
605
|
+
deliver(handoff: AgentHandoffSnapshot, lifecycle: AgentDeliveryLifecycle, signal: AbortSignal): Promise<void>;
|
|
606
|
+
close(): Promise<void>;
|
|
607
|
+
}
|
|
608
|
+
declare function connectManagedCodexAppServer(options: ConnectManagedCodexAppServerOptions): Promise<ManagedAdapterConnection>;
|
|
609
|
+
|
|
610
|
+
export { type BridgeCliAdapter, type BridgeSetupClient, type BridgeSetupMode, type BridgeSetupPlan, type ConnectManagedAdapter, type ConnectManagedAdapterOptions, type ConnectManagedCodexAppServerOptions, type CreateExternalAgentSupervisorOptions, type ExternalAgentSessionListItem, type ExternalAgentSupervisor, type HandoffDelivery, type HandoffWaitDelivery, type ManagedAdapterConnection, type ManagedAdapterEvent, ManagedCodexAppServerAdapter, type RunSpotPatchBridgeCliOptions, type SpotPatchBridgeClient, applyBridgeSetupPlan, connectManagedCodexAppServer, createBridgeSetupPlan, createExternalAgentSupervisor, createSpotPatchBridgeClient, createSpotPatchMcpServer, runSpotPatchBridgeCli, serveSpotPatchMcp };
|