sandbox-agent 0.3.0 → 0.3.2

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,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";
@@ -1488,8 +1488,25 @@ interface SessionSendOptions {
1488
1488
  notification?: boolean;
1489
1489
  }
1490
1490
  type SessionEventListener = (event: SessionEvent) => void;
1491
+ type PermissionReply = "once" | "always" | "reject";
1492
+ type PermissionRequestListener = (request: SessionPermissionRequest) => void;
1491
1493
  type ProcessLogListener = (entry: ProcessLogEntry) => void;
1492
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
+ }
1493
1510
  interface AgentQueryOptions {
1494
1511
  config?: boolean;
1495
1512
  noCache?: boolean;
@@ -1532,6 +1549,12 @@ declare class UnsupportedSessionConfigOptionError extends Error {
1532
1549
  readonly availableConfigIds: string[];
1533
1550
  constructor(sessionId: string, configId: string, availableConfigIds: string[]);
1534
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
+ }
1535
1558
  declare class Session {
1536
1559
  private record;
1537
1560
  private readonly sandbox;
@@ -1543,7 +1566,7 @@ declare class Session {
1543
1566
  get createdAt(): number;
1544
1567
  get destroyedAt(): number | undefined;
1545
1568
  refresh(): Promise<Session>;
1546
- send(method: string, params?: Record<string, unknown>, options?: SessionSendOptions): Promise<unknown>;
1569
+ rawSend(method: string, params?: Record<string, unknown>, options?: SessionSendOptions): Promise<unknown>;
1547
1570
  prompt(prompt: PromptRequest["prompt"]): Promise<PromptResponse>;
1548
1571
  setMode(modeId: string): Promise<SetSessionModeResponse | void>;
1549
1572
  setConfigOption(configId: string, value: string): Promise<SetSessionConfigOptionResponse>;
@@ -1552,6 +1575,9 @@ declare class Session {
1552
1575
  getConfigOptions(): Promise<SessionConfigOption[]>;
1553
1576
  getModes(): Promise<SessionModeState | null>;
1554
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>;
1555
1581
  toRecord(): SessionRecord;
1556
1582
  apply(record: SessionRecord): void;
1557
1583
  }
@@ -1567,6 +1593,7 @@ declare class LiveAcpConnection {
1567
1593
  private lastAdapterExit;
1568
1594
  private lastAdapterExitAt;
1569
1595
  private readonly onObservedEnvelope;
1596
+ private readonly onPermissionRequest;
1570
1597
  private constructor();
1571
1598
  static create(options: {
1572
1599
  baseUrl: string;
@@ -1576,6 +1603,7 @@ declare class LiveAcpConnection {
1576
1603
  agent: string;
1577
1604
  serverId: string;
1578
1605
  onObservedEnvelope: (connection: LiveAcpConnection, envelope: AnyMessage, direction: AcpEnvelopeDirection, localSessionId: string | null) => void;
1606
+ onPermissionRequest: (connection: LiveAcpConnection, localSessionId: string, agentSessionId: string, request: RequestPermissionRequest) => Promise<RequestPermissionResponse>;
1579
1607
  }): Promise<LiveAcpConnection>;
1580
1608
  close(): Promise<void>;
1581
1609
  hasBoundSession(localSessionId: string, agentSessionId?: string): boolean;
@@ -1585,6 +1613,7 @@ declare class LiveAcpConnection {
1585
1613
  sendSessionMethod(localSessionId: string, method: string, params: Record<string, unknown>, options: SessionSendOptions): Promise<unknown>;
1586
1614
  private handleEnvelope;
1587
1615
  private handleAdapterNotification;
1616
+ private handlePermissionRequest;
1588
1617
  private resolveSessionId;
1589
1618
  private localFromEnvelopeParams;
1590
1619
  }
@@ -1629,6 +1658,8 @@ declare class SandboxAgent {
1629
1658
  private readonly pendingLiveConnections;
1630
1659
  private readonly sessionHandles;
1631
1660
  private readonly eventListeners;
1661
+ private readonly permissionListeners;
1662
+ private readonly pendingPermissionRequests;
1632
1663
  private readonly nextSessionEventIndexBySession;
1633
1664
  private readonly seedSessionEventIndexBySession;
1634
1665
  constructor(options: SandboxAgentConnectOptions);
@@ -1662,13 +1693,16 @@ declare class SandboxAgent {
1662
1693
  getSessionModes(sessionId: string): Promise<SessionModeState | null>;
1663
1694
  private setSessionCategoryValue;
1664
1695
  private hydrateSessionConfigOptions;
1665
- sendSessionMethod(sessionId: string, method: string, params: Record<string, unknown>, options?: SessionSendOptions): Promise<{
1696
+ rawSendSessionMethod(sessionId: string, method: string, params: Record<string, unknown>, options?: SessionSendOptions): Promise<{
1666
1697
  session: Session;
1667
1698
  response: unknown;
1668
1699
  }>;
1669
1700
  private sendSessionMethodInternal;
1670
1701
  private persistSessionStateFromMethod;
1671
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>;
1672
1706
  getHealth(): Promise<HealthResponse>;
1673
1707
  listAgents(options?: AgentQueryOptions): Promise<AgentListResponse>;
1674
1708
  getAgent(agent: string, options?: AgentQueryOptions): Promise<AgentInfo>;
@@ -1713,6 +1747,9 @@ declare class SandboxAgent {
1713
1747
  private collectReplayEvents;
1714
1748
  private upsertSessionHandle;
1715
1749
  private requireSessionRecord;
1750
+ private enqueuePermissionRequest;
1751
+ private resolvePendingPermission;
1752
+ private cancelPendingPermissionsForSession;
1716
1753
  private requestJson;
1717
1754
  private requestRaw;
1718
1755
  private startHealthWait;
@@ -1744,4 +1781,4 @@ interface InspectorUrlOptions {
1744
1781
  */
1745
1782
  declare function buildInspectorUrl(options: InspectorUrlOptions): string;
1746
1783
 
1747
- 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, 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 SessionPersistDriver, type SessionRecord, type SessionResumeOrCreateRequest, type SessionSendOptions, type SkillsConfig, type SkillsConfigQuery, type TerminalErrorStatus, type TerminalExitStatus, type TerminalReadyStatus, type TerminalResizePayload, type TerminalStatusMessage, 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 };