sandbox-agent 0.2.2 → 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.ts +74 -4
- package/dist/index.js +483 -11
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NewSessionRequest, SessionConfigOption, SessionModeState, AnyMessage, AcpEnvelopeDirection, NewSessionResponse, PromptRequest, PromptResponse, SetSessionModeResponse, SetSessionConfigOptionResponse } from 'acp-http-client';
|
|
1
|
+
import { NewSessionRequest, SessionConfigOption, SessionModeState, AnyMessage, AcpEnvelopeDirection, RequestPermissionRequest, RequestPermissionResponse, NewSessionResponse, PermissionOptionKind, PromptRequest, PromptResponse, SetSessionModeResponse, SetSessionConfigOptionResponse } from 'acp-http-client';
|
|
2
2
|
export { AcpRpcError } from 'acp-http-client';
|
|
3
3
|
|
|
4
4
|
type SandboxAgentSpawnLogMode = "inherit" | "pipe" | "silent";
|
|
@@ -1353,6 +1353,14 @@ interface ProcessTerminalErrorFrame {
|
|
|
1353
1353
|
message: string;
|
|
1354
1354
|
}
|
|
1355
1355
|
type ProcessTerminalServerFrame = ProcessTerminalReadyFrame | ProcessTerminalExitFrame | ProcessTerminalErrorFrame;
|
|
1356
|
+
type TerminalReadyStatus = ProcessTerminalReadyFrame;
|
|
1357
|
+
type TerminalExitStatus = ProcessTerminalExitFrame;
|
|
1358
|
+
type TerminalErrorStatus = ProcessTerminalErrorFrame;
|
|
1359
|
+
type TerminalStatusMessage = ProcessTerminalServerFrame;
|
|
1360
|
+
interface TerminalResizePayload {
|
|
1361
|
+
cols: number;
|
|
1362
|
+
rows: number;
|
|
1363
|
+
}
|
|
1356
1364
|
interface SessionRecord {
|
|
1357
1365
|
id: string;
|
|
1358
1366
|
agent: string;
|
|
@@ -1480,8 +1488,25 @@ interface SessionSendOptions {
|
|
|
1480
1488
|
notification?: boolean;
|
|
1481
1489
|
}
|
|
1482
1490
|
type SessionEventListener = (event: SessionEvent) => void;
|
|
1491
|
+
type PermissionReply = "once" | "always" | "reject";
|
|
1492
|
+
type PermissionRequestListener = (request: SessionPermissionRequest) => void;
|
|
1483
1493
|
type ProcessLogListener = (entry: ProcessLogEntry) => void;
|
|
1484
1494
|
type ProcessLogFollowQuery = Omit<ProcessLogsQuery, "follow">;
|
|
1495
|
+
interface SessionPermissionRequestOption {
|
|
1496
|
+
optionId: string;
|
|
1497
|
+
name: string;
|
|
1498
|
+
kind: PermissionOptionKind;
|
|
1499
|
+
}
|
|
1500
|
+
interface SessionPermissionRequest {
|
|
1501
|
+
id: string;
|
|
1502
|
+
createdAt: number;
|
|
1503
|
+
sessionId: string;
|
|
1504
|
+
agentSessionId: string;
|
|
1505
|
+
availableReplies: PermissionReply[];
|
|
1506
|
+
options: SessionPermissionRequestOption[];
|
|
1507
|
+
toolCall: RequestPermissionRequest["toolCall"];
|
|
1508
|
+
rawRequest: RequestPermissionRequest;
|
|
1509
|
+
}
|
|
1485
1510
|
interface AgentQueryOptions {
|
|
1486
1511
|
config?: boolean;
|
|
1487
1512
|
noCache?: boolean;
|
|
@@ -1497,6 +1522,7 @@ interface ProcessTerminalConnectOptions extends ProcessTerminalWebSocketUrlOptio
|
|
|
1497
1522
|
protocols?: string | string[];
|
|
1498
1523
|
WebSocket?: typeof WebSocket;
|
|
1499
1524
|
}
|
|
1525
|
+
type ProcessTerminalSessionOptions = ProcessTerminalConnectOptions;
|
|
1500
1526
|
declare class SandboxAgentError extends Error {
|
|
1501
1527
|
readonly status: number;
|
|
1502
1528
|
readonly problem?: ProblemDetails;
|
|
@@ -1523,6 +1549,12 @@ declare class UnsupportedSessionConfigOptionError extends Error {
|
|
|
1523
1549
|
readonly availableConfigIds: string[];
|
|
1524
1550
|
constructor(sessionId: string, configId: string, availableConfigIds: string[]);
|
|
1525
1551
|
}
|
|
1552
|
+
declare class UnsupportedPermissionReplyError extends Error {
|
|
1553
|
+
readonly permissionId: string;
|
|
1554
|
+
readonly requestedReply: PermissionReply;
|
|
1555
|
+
readonly availableReplies: PermissionReply[];
|
|
1556
|
+
constructor(permissionId: string, requestedReply: PermissionReply, availableReplies: PermissionReply[]);
|
|
1557
|
+
}
|
|
1526
1558
|
declare class Session {
|
|
1527
1559
|
private record;
|
|
1528
1560
|
private readonly sandbox;
|
|
@@ -1534,7 +1566,7 @@ declare class Session {
|
|
|
1534
1566
|
get createdAt(): number;
|
|
1535
1567
|
get destroyedAt(): number | undefined;
|
|
1536
1568
|
refresh(): Promise<Session>;
|
|
1537
|
-
|
|
1569
|
+
rawSend(method: string, params?: Record<string, unknown>, options?: SessionSendOptions): Promise<unknown>;
|
|
1538
1570
|
prompt(prompt: PromptRequest["prompt"]): Promise<PromptResponse>;
|
|
1539
1571
|
setMode(modeId: string): Promise<SetSessionModeResponse | void>;
|
|
1540
1572
|
setConfigOption(configId: string, value: string): Promise<SetSessionConfigOptionResponse>;
|
|
@@ -1543,6 +1575,9 @@ declare class Session {
|
|
|
1543
1575
|
getConfigOptions(): Promise<SessionConfigOption[]>;
|
|
1544
1576
|
getModes(): Promise<SessionModeState | null>;
|
|
1545
1577
|
onEvent(listener: SessionEventListener): () => void;
|
|
1578
|
+
onPermissionRequest(listener: PermissionRequestListener): () => void;
|
|
1579
|
+
respondPermission(permissionId: string, reply: PermissionReply): Promise<void>;
|
|
1580
|
+
rawRespondPermission(permissionId: string, response: RequestPermissionResponse): Promise<void>;
|
|
1546
1581
|
toRecord(): SessionRecord;
|
|
1547
1582
|
apply(record: SessionRecord): void;
|
|
1548
1583
|
}
|
|
@@ -1558,6 +1593,7 @@ declare class LiveAcpConnection {
|
|
|
1558
1593
|
private lastAdapterExit;
|
|
1559
1594
|
private lastAdapterExitAt;
|
|
1560
1595
|
private readonly onObservedEnvelope;
|
|
1596
|
+
private readonly onPermissionRequest;
|
|
1561
1597
|
private constructor();
|
|
1562
1598
|
static create(options: {
|
|
1563
1599
|
baseUrl: string;
|
|
@@ -1567,6 +1603,7 @@ declare class LiveAcpConnection {
|
|
|
1567
1603
|
agent: string;
|
|
1568
1604
|
serverId: string;
|
|
1569
1605
|
onObservedEnvelope: (connection: LiveAcpConnection, envelope: AnyMessage, direction: AcpEnvelopeDirection, localSessionId: string | null) => void;
|
|
1606
|
+
onPermissionRequest: (connection: LiveAcpConnection, localSessionId: string, agentSessionId: string, request: RequestPermissionRequest) => Promise<RequestPermissionResponse>;
|
|
1570
1607
|
}): Promise<LiveAcpConnection>;
|
|
1571
1608
|
close(): Promise<void>;
|
|
1572
1609
|
hasBoundSession(localSessionId: string, agentSessionId?: string): boolean;
|
|
@@ -1576,9 +1613,33 @@ declare class LiveAcpConnection {
|
|
|
1576
1613
|
sendSessionMethod(localSessionId: string, method: string, params: Record<string, unknown>, options: SessionSendOptions): Promise<unknown>;
|
|
1577
1614
|
private handleEnvelope;
|
|
1578
1615
|
private handleAdapterNotification;
|
|
1616
|
+
private handlePermissionRequest;
|
|
1579
1617
|
private resolveSessionId;
|
|
1580
1618
|
private localFromEnvelopeParams;
|
|
1581
1619
|
}
|
|
1620
|
+
declare class ProcessTerminalSession {
|
|
1621
|
+
readonly socket: WebSocket;
|
|
1622
|
+
readonly closed: Promise<void>;
|
|
1623
|
+
private readonly readyListeners;
|
|
1624
|
+
private readonly dataListeners;
|
|
1625
|
+
private readonly exitListeners;
|
|
1626
|
+
private readonly errorListeners;
|
|
1627
|
+
private readonly closeListeners;
|
|
1628
|
+
private closeSignalSent;
|
|
1629
|
+
private closedResolve;
|
|
1630
|
+
constructor(socket: WebSocket);
|
|
1631
|
+
onReady(listener: (status: TerminalReadyStatus) => void): () => void;
|
|
1632
|
+
onData(listener: (data: Uint8Array) => void): () => void;
|
|
1633
|
+
onExit(listener: (status: TerminalExitStatus) => void): () => void;
|
|
1634
|
+
onError(listener: (error: TerminalErrorStatus | Error) => void): () => void;
|
|
1635
|
+
onClose(listener: () => void): () => void;
|
|
1636
|
+
sendInput(data: string | ArrayBuffer | ArrayBufferView): void;
|
|
1637
|
+
resize(payload: TerminalResizePayload): void;
|
|
1638
|
+
close(): void;
|
|
1639
|
+
private handleMessage;
|
|
1640
|
+
private sendFrame;
|
|
1641
|
+
private emitError;
|
|
1642
|
+
}
|
|
1582
1643
|
declare class SandboxAgent {
|
|
1583
1644
|
private readonly baseUrl;
|
|
1584
1645
|
private readonly token?;
|
|
@@ -1597,6 +1658,8 @@ declare class SandboxAgent {
|
|
|
1597
1658
|
private readonly pendingLiveConnections;
|
|
1598
1659
|
private readonly sessionHandles;
|
|
1599
1660
|
private readonly eventListeners;
|
|
1661
|
+
private readonly permissionListeners;
|
|
1662
|
+
private readonly pendingPermissionRequests;
|
|
1600
1663
|
private readonly nextSessionEventIndexBySession;
|
|
1601
1664
|
private readonly seedSessionEventIndexBySession;
|
|
1602
1665
|
constructor(options: SandboxAgentConnectOptions);
|
|
@@ -1630,13 +1693,16 @@ declare class SandboxAgent {
|
|
|
1630
1693
|
getSessionModes(sessionId: string): Promise<SessionModeState | null>;
|
|
1631
1694
|
private setSessionCategoryValue;
|
|
1632
1695
|
private hydrateSessionConfigOptions;
|
|
1633
|
-
|
|
1696
|
+
rawSendSessionMethod(sessionId: string, method: string, params: Record<string, unknown>, options?: SessionSendOptions): Promise<{
|
|
1634
1697
|
session: Session;
|
|
1635
1698
|
response: unknown;
|
|
1636
1699
|
}>;
|
|
1637
1700
|
private sendSessionMethodInternal;
|
|
1638
1701
|
private persistSessionStateFromMethod;
|
|
1639
1702
|
onSessionEvent(sessionId: string, listener: SessionEventListener): () => void;
|
|
1703
|
+
onPermissionRequest(sessionId: string, listener: PermissionRequestListener): () => void;
|
|
1704
|
+
respondPermission(permissionId: string, reply: PermissionReply): Promise<void>;
|
|
1705
|
+
rawRespondPermission(permissionId: string, response: RequestPermissionResponse): Promise<void>;
|
|
1640
1706
|
getHealth(): Promise<HealthResponse>;
|
|
1641
1707
|
listAgents(options?: AgentQueryOptions): Promise<AgentListResponse>;
|
|
1642
1708
|
getAgent(agent: string, options?: AgentQueryOptions): Promise<AgentInfo>;
|
|
@@ -1671,6 +1737,7 @@ declare class SandboxAgent {
|
|
|
1671
1737
|
resizeProcessTerminal(id: string, request: ProcessTerminalResizeRequest): Promise<ProcessTerminalResizeResponse>;
|
|
1672
1738
|
buildProcessTerminalWebSocketUrl(id: string, options?: ProcessTerminalWebSocketUrlOptions): string;
|
|
1673
1739
|
connectProcessTerminalWebSocket(id: string, options?: ProcessTerminalConnectOptions): WebSocket;
|
|
1740
|
+
connectProcessTerminal(id: string, options?: ProcessTerminalSessionOptions): ProcessTerminalSession;
|
|
1674
1741
|
private getLiveConnection;
|
|
1675
1742
|
private persistObservedEnvelope;
|
|
1676
1743
|
private persistSessionStateFromEvent;
|
|
@@ -1680,6 +1747,9 @@ declare class SandboxAgent {
|
|
|
1680
1747
|
private collectReplayEvents;
|
|
1681
1748
|
private upsertSessionHandle;
|
|
1682
1749
|
private requireSessionRecord;
|
|
1750
|
+
private enqueuePermissionRequest;
|
|
1751
|
+
private resolvePendingPermission;
|
|
1752
|
+
private cancelPendingPermissionsForSession;
|
|
1683
1753
|
private requestJson;
|
|
1684
1754
|
private requestRaw;
|
|
1685
1755
|
private startHealthWait;
|
|
@@ -1711,4 +1781,4 @@ interface InspectorUrlOptions {
|
|
|
1711
1781
|
*/
|
|
1712
1782
|
declare function buildInspectorUrl(options: InspectorUrlOptions): string;
|
|
1713
1783
|
|
|
1714
|
-
export { type AcpEnvelope, type AcpServerInfo, type AcpServerListResponse, type AgentInfo, type AgentInstallRequest, type AgentInstallResponse, type AgentListResponse, type AgentQuery, type AgentQueryOptions, type FsActionResponse, type FsDeleteQuery, type FsEntriesQuery, type FsEntry, type FsMoveRequest, type FsMoveResponse, type FsPathQuery, type FsStat, type FsUploadBatchQuery, type FsUploadBatchResponse, type FsWriteResponse, type HealthResponse, InMemorySessionPersistDriver, type InMemorySessionPersistDriverOptions, type InspectorUrlOptions, type ListEventsRequest, type ListPage, type ListPageRequest, LiveAcpConnection, type McpConfigQuery, type McpServerConfig, type ProblemDetails, type ProcessConfig, type ProcessCreateRequest, type ProcessInfo, type ProcessInputRequest, type ProcessInputResponse, type ProcessListResponse, type ProcessLogEntry, type ProcessLogFollowQuery, type ProcessLogListener, type ProcessLogSubscription, type ProcessLogsQuery, type ProcessLogsResponse, type ProcessLogsStream, type ProcessRunRequest, type ProcessRunResponse, type ProcessSignalQuery, type ProcessState, type ProcessTerminalClientFrame, type ProcessTerminalConnectOptions, type ProcessTerminalErrorFrame, type ProcessTerminalExitFrame, type ProcessTerminalReadyFrame, type ProcessTerminalResizeRequest, type ProcessTerminalResizeResponse, type ProcessTerminalServerFrame, type ProcessTerminalWebSocketUrlOptions, SandboxAgent, type SandboxAgentConnectOptions, SandboxAgentError, type SandboxAgentHealthWaitOptions, type SandboxAgentSpawnLogMode, type SandboxAgentSpawnOptions, type SandboxAgentStartOptions, Session, type SessionCreateRequest, type SessionEvent, type SessionEventListener, type SessionPersistDriver, type SessionRecord, type SessionResumeOrCreateRequest, type SessionSendOptions, type SkillsConfig, type SkillsConfigQuery, UnsupportedSessionCategoryError, UnsupportedSessionConfigOptionError, UnsupportedSessionValueError, buildInspectorUrl };
|
|
1784
|
+
export { type AcpEnvelope, type AcpServerInfo, type AcpServerListResponse, type AgentInfo, type AgentInstallRequest, type AgentInstallResponse, type AgentListResponse, type AgentQuery, type AgentQueryOptions, type FsActionResponse, type FsDeleteQuery, type FsEntriesQuery, type FsEntry, type FsMoveRequest, type FsMoveResponse, type FsPathQuery, type FsStat, type FsUploadBatchQuery, type FsUploadBatchResponse, type FsWriteResponse, type HealthResponse, InMemorySessionPersistDriver, type InMemorySessionPersistDriverOptions, type InspectorUrlOptions, type ListEventsRequest, type ListPage, type ListPageRequest, LiveAcpConnection, type McpConfigQuery, type McpServerConfig, type PermissionReply, type PermissionRequestListener, type ProblemDetails, type ProcessConfig, type ProcessCreateRequest, type ProcessInfo, type ProcessInputRequest, type ProcessInputResponse, type ProcessListResponse, type ProcessLogEntry, type ProcessLogFollowQuery, type ProcessLogListener, type ProcessLogSubscription, type ProcessLogsQuery, type ProcessLogsResponse, type ProcessLogsStream, type ProcessRunRequest, type ProcessRunResponse, type ProcessSignalQuery, type ProcessState, type ProcessTerminalClientFrame, type ProcessTerminalConnectOptions, type ProcessTerminalErrorFrame, type ProcessTerminalExitFrame, type ProcessTerminalReadyFrame, type ProcessTerminalResizeRequest, type ProcessTerminalResizeResponse, type ProcessTerminalServerFrame, ProcessTerminalSession, type ProcessTerminalSessionOptions, type ProcessTerminalWebSocketUrlOptions, SandboxAgent, type SandboxAgentConnectOptions, SandboxAgentError, type SandboxAgentHealthWaitOptions, type SandboxAgentSpawnLogMode, type SandboxAgentSpawnOptions, type SandboxAgentStartOptions, Session, type SessionCreateRequest, type SessionEvent, type SessionEventListener, type SessionPermissionRequest, type SessionPermissionRequestOption, type SessionPersistDriver, type SessionRecord, type SessionResumeOrCreateRequest, type SessionSendOptions, type SkillsConfig, type SkillsConfigQuery, type TerminalErrorStatus, type TerminalExitStatus, type TerminalReadyStatus, type TerminalResizePayload, type TerminalStatusMessage, UnsupportedPermissionReplyError, UnsupportedSessionCategoryError, UnsupportedSessionConfigOptionError, UnsupportedSessionValueError, buildInspectorUrl };
|