@factory/droid-sdk 0.6.0 → 0.7.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.
Files changed (80) hide show
  1. package/README.md +35 -482
  2. package/dist/chunk-5UXINOXG.mjs +24483 -0
  3. package/dist/chunk-5UXINOXG.mjs.map +1 -0
  4. package/dist/chunk-C3KHERVH.js +24483 -0
  5. package/dist/chunk-C3KHERVH.js.map +1 -0
  6. package/dist/{index-CwXX5IUH.d.cts → index-D_SzTnFR.d.mts} +83826 -81547
  7. package/dist/{index-CwXX5IUH.d.ts → index-D_SzTnFR.d.ts} +83826 -81547
  8. package/dist/index.d.mts +4 -0
  9. package/dist/index.d.ts +4 -93103
  10. package/dist/index.js +821 -11745
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +822 -0
  13. package/dist/index.mjs.map +1 -0
  14. package/dist/node.d.mts +736 -0
  15. package/dist/node.d.ts +736 -0
  16. package/dist/node.js +4601 -0
  17. package/dist/node.js.map +1 -0
  18. package/dist/node.mjs +4601 -0
  19. package/dist/node.mjs.map +1 -0
  20. package/docs/typescript-sdk-reference.md +1260 -0
  21. package/examples/browser/daemon-lifecycle.ts +95 -0
  22. package/examples/browser/daemon-multi-session.ts +66 -0
  23. package/examples/browser/daemon-session.ts +73 -0
  24. package/examples/browser/index.html +68 -0
  25. package/examples/browser/list-sessions.ts +52 -0
  26. package/examples/{abort-session-stream.ts → node/abort-session-stream.ts} +8 -10
  27. package/examples/node/ask-user-elicitation.ts +35 -0
  28. package/examples/node/compact-session.ts +48 -0
  29. package/examples/node/enter-spec-mode.ts +66 -0
  30. package/examples/node/fork-session.ts +45 -0
  31. package/examples/node/hook-execution.ts +94 -0
  32. package/examples/node/image-attachment.ts +35 -0
  33. package/examples/node/init-metadata.ts +24 -0
  34. package/examples/{interrupt-session.ts → node/interrupt-session.ts} +7 -6
  35. package/examples/node/list-sessions.ts +20 -0
  36. package/examples/node/multi-turn-session.ts +33 -0
  37. package/examples/node/observability.ts +88 -0
  38. package/examples/node/permission-handler.ts +55 -0
  39. package/examples/node/rename-session.ts +29 -0
  40. package/examples/node/result-metadata.ts +34 -0
  41. package/examples/node/rewind-session.ts +69 -0
  42. package/examples/node/run.ts +25 -0
  43. package/examples/{sdk-mcp-tool.ts → node/sdk-mcp-tool.ts} +22 -12
  44. package/examples/node/session-settings.ts +35 -0
  45. package/examples/node/session-stream.ts +44 -0
  46. package/examples/node/spec-mode-new-session.ts +92 -0
  47. package/examples/node/spec-mode-same-session.ts +85 -0
  48. package/examples/node/structured-output.ts +73 -0
  49. package/examples/node/tool-controls.ts +26 -0
  50. package/examples/package.json +3 -0
  51. package/package.json +20 -42
  52. package/dist/index.cjs +0 -12135
  53. package/dist/index.cjs.map +0 -1
  54. package/dist/index.d.cts +0 -93103
  55. package/dist/protocol/index.cjs +0 -6466
  56. package/dist/protocol/index.cjs.map +0 -1
  57. package/dist/protocol/index.d.cts +0 -2
  58. package/dist/protocol/index.d.ts +0 -2
  59. package/dist/protocol/index.js +0 -6078
  60. package/dist/protocol/index.js.map +0 -1
  61. package/docs/daemon-usage-guide.md +0 -544
  62. package/docs/sdk-usage-guide.md +0 -748
  63. package/examples/daemon-multi-session.ts +0 -67
  64. package/examples/droid-dev-structured-output.ts +0 -44
  65. package/examples/fork-session.ts +0 -68
  66. package/examples/hook-execution.ts +0 -68
  67. package/examples/init-metadata.ts +0 -24
  68. package/examples/list-sessions.ts +0 -19
  69. package/examples/multi-turn-session.ts +0 -40
  70. package/examples/permission-handler.ts +0 -41
  71. package/examples/readme-structured-output.ts +0 -26
  72. package/examples/result-metadata.ts +0 -63
  73. package/examples/run.ts +0 -39
  74. package/examples/session-stream.ts +0 -57
  75. package/examples/spec-mode-new-session.ts +0 -61
  76. package/examples/spec-mode-same-session.ts +0 -72
  77. package/examples/structured-output.ts +0 -60
  78. package/examples/test-compact.ts +0 -65
  79. package/examples/test-rewind.ts +0 -87
  80. package/examples/tool-controls.ts +0 -37
@@ -0,0 +1,736 @@
1
+ import { D as DaemonClientTransport, a as DaemonIpcMessageChannel, b as DaemonClientTransportKind, c as DaemonClientTransportEvents, I as InProcessDaemonClientTransportOptions, S as SessionNotificationEvent, R as RequestPermissionEvent, A as AskUserEvent, L as LogMetadata, d as DroidObservability, e as DroidClientOptions, f as InitializeSessionRequestParams, g as InitializeSessionResponse, h as LoadSessionRequestParams, i as LoadSessionResponse, j as AddUserMessageParams, k as AddUserMessageResponse, l as ResolveQueuedUserMessageParams, m as ResolveQueuedUserMessageResponse, n as InterruptSessionParams, o as InterruptSessionResponse, C as CloseSessionParams, p as CloseSessionResponse, K as KillWorkerSessionParams, q as KillWorkerSessionResponse, U as UpdateSessionSettingsRequestParams, r as UpdateSessionSettingsResponse, s as ChangeWorkingDirectoryParams, t as ChangeWorkingDirectoryResponse, u as SettingsLevel, T as ToggleMcpServerResponseSchema, v as AuthenticateMcpServerResponseSchema, w as CancelMcpAuthResponseSchema, x as ClearMcpAuthResponseSchema, y as AddMcpServerRequest, z as AddMcpServerResponseSchema, B as RemoveMcpServerResponseSchema, E as ListMcpRegistryResponseSchema, F as ListMcpToolsResponseSchema, G as ListToolsRequestParams, H as ListToolsResponseSchema, J as ListMcpServersResponseSchema, M as ToggleMcpToolResponseSchema, N as SubmitMcpAuthCodeRequestParamsSchema, O as SubmitMcpAuthCodeResponseSchema, P as SubmitMcpAuthErrorRequestParamsSchema, Q as SubmitMcpAuthErrorResponseSchema, V as ListSkillsResponseSchema, W as SetSkillDisabledRequest, X as SetSkillDisabledResponseSchema, Y as ListCommandsResponseSchema, Z as GetContextStatsResponseSchema, _ as GetContextBreakdownResponseSchema, $ as SubmitBugReportRequest, a0 as SubmitBugReportResponseSchema, a1 as GetRewindInfoResponseSchema, a2 as ExecuteRewindResponseSchema, a3 as CompactSessionResponseSchema, a4 as ForkSessionRequestParamsSchema, a5 as ForkSessionResponseSchema, a6 as RenameSessionRequestParams, a7 as RenameSessionResponseSchema, a8 as WarmupCacheResponseSchema, a9 as RequestPermissionHandlerResult, aa as ToolConfirmationOutcome, ab as RequestPermissionResult, ac as AskUserResult, ad as StringFramedDroidClientTransport, ae as ProcessTransportOptions, af as McpServerConfig, ag as HttpMcpConfig, ah as ToolSelectionOverrides, ai as AutonomyLevel, aj as DroidInteractionMode, ak as ReasoningEffort, al as SessionSource, am as SessionTag, an as HandlerOptions, ao as DroidResultMessage, ap as SessionSettings, aq as MessageOptions, ar as DroidStreamMessage, as as DroidStreamEvent, at as UpdateSessionSettingsResult, au as AddMcpServerRequestParams, av as AddMcpServerResult, aw as RemoveMcpServerRequestParams, ax as RemoveMcpServerResult, ay as ToggleMcpServerRequestParams, az as ToggleMcpServerResult, aA as ListMcpServersResult, aB as McpToolInfo, aC as ExecToolInfo, aD as AuthenticateMcpServerRequestParams, aE as AuthenticateMcpServerResult, aF as ListSkillsResult, aG as SetSkillDisabledRequestParams, aH as SetSkillDisabledResult, aI as GetRewindInfoRequestParams, aJ as GetRewindInfoResult, aK as ExecuteRewindRequestParams, aL as SessionRewindOutcome, aM as CompactSessionRequestParams, aN as SessionCompactionOutcome, aO as ForkSessionRequestParams, aP as GetContextStatsResult, aQ as RenameSessionRequestParams$1, aR as ListSessionsOptions, aS as SessionMetadata } from './index-D_SzTnFR.mjs';
2
+ export { aT as AbortError, kv as AddMcpServerRequest, aU as AddMcpServerRequestParamsSchema, aV as AddMcpServerRequestSchema, kw as AddMcpServerResponse, aW as AddMcpServerResultSchema, jG as AddMessageResult, kx as AddUserMessageRequest, ky as AddUserMessageRequestParams, aX as AddUserMessageRequestParamsSchema, aY as AddUserMessageRequestSchema, kz as AddUserMessageResponse, aZ as AddUserMessageResponseSchema, kA as AddUserMessageResult, a_ as AddUserMessageResultSchema, mr as ApplyPatchToolConfirmationDetails, a$ as ApplyPatchToolConfirmationDetailsSchema, mG as AskUserCollectedAnswer, b0 as AskUserCollectedAnswerSchema, mn as AskUserConfirmationDetails, b1 as AskUserConfirmationDetailsSchema, mD as AskUserQuestion, b2 as AskUserQuestionSchema, mE as AskUserRequest, jT as AskUserRequestHandlerEvents, mF as AskUserRequestParams, b3 as AskUserRequestParamsSchema, b4 as AskUserRequestSchema, mI as AskUserResponse, b5 as AskUserResponseSchema, mH as AskUserResult, b6 as AskUserResultSchema, hw as AssistantTextComplete, m4 as AssistantTextCompleteNotification, b7 as AssistantTextCompleteNotificationSchema, hv as AssistantTextDelta, m3 as AssistantTextDeltaNotification, b8 as AssistantTextDeltaNotificationSchema, j9 as Attribute, ja as Attributes, kB as AuthenticateMcpServerRequest, b9 as AuthenticateMcpServerRequestParamsSchema, ba as AuthenticateMcpServerRequestSchema, kC as AuthenticateMcpServerResponse, bb as AuthenticateMcpServerResultSchema, i8 as AutomationsResource, kk as AvailableModelConfig, bc as AvailableModelConfigSchema, nl as Base64ImageSource, bd as Base64ImageSourceSchema, hd as BaseDroidHookInput, k8 as BaseNotification, be as BaseNotificationSchema, k5 as BaseRequest, bf as BaseRequestSchema, k7 as BaseResponseFailure, bg as BaseResponseFailureSchema, k6 as BaseResponseSuccess, bh as BaseResponseSuccessSchema, bi as COMPACTION_TIMEOUT, kD as CancelMcpAuthRequest, kE as CancelMcpAuthRequestParams, bj as CancelMcpAuthRequestParamsSchema, bk as CancelMcpAuthRequestSchema, kF as CancelMcpAuthResponse, kG as CancelMcpAuthResult, bl as CancelMcpAuthResultSchema, kH as ChangeWorkingDirectoryRequest, kI as ChangeWorkingDirectoryRequestParams, bm as ChangeWorkingDirectoryRequestParamsSchema, bn as ChangeWorkingDirectoryRequestSchema, kJ as ChangeWorkingDirectoryResponse, bo as ChangeWorkingDirectoryResponseSchema, kK as ChangeWorkingDirectoryResult, bp as ChangeWorkingDirectoryResultSchema, kL as ClearMcpAuthRequest, kM as ClearMcpAuthRequestParams, bq as ClearMcpAuthRequestParamsSchema, br as ClearMcpAuthRequestSchema, kN as ClearMcpAuthResponse, kO as ClearMcpAuthResult, bs as ClearMcpAuthResultSchema, mC as CliRequestOrNotification, bt as CliRequestOrNotificationSchema, g_ as ClientAskUserHandler, bu as ClientDestroyedError, g$ as ClientPermissionHandler, kP as ClientRequest, bv as ClientRequestSchema, bw as ClientUiSurface, kQ as CloseSessionRequest, kR as CloseSessionRequestParams, bx as CloseSessionRequestParamsSchema, by as CloseSessionRequestSchema, kS as CloseSessionResponse, bz as CloseSessionResponseSchema, kT as CloseSessionResult, bA as CloseSessionResultSchema, i9 as CommandsResource, kU as CompactSessionRequest, bB as CompactSessionRequestParamsSchema, bC as CompactSessionRequestSchema, kV as CompactSessionResponse, kW as CompactSessionResult, bD as CompactSessionResultSchema, bE as ComputeLimitExceededError, iO as Computer, iN as ComputerApiOptions, ji as ComputerConnectAttemptContext, bF as ComputerConnectAttemptTrigger, jj as ComputerConnectSliOptions, jk as ComputerConnectSliRunContext, bG as ComputerConnectStartType, iP as ComputerListResponse, bH as ComputerListResponseSchema, iQ as ComputerMetric, bI as ComputerMetricSchema, iR as ComputerMetricsResponse, bJ as ComputerMetricsResponseSchema, bK as ComputerSchema, bL as ConcurrentStreamError, h_ as ConnectToDaemonOptions, hY as ConnectedDroid, hZ as ConnectedDroidSession, bM as ConnectionClosedError, gS as ConnectionError, bN as ConnectionFailureReason, nt as ContentBlock, bO as ContentBlockSchema, bP as ContextBreakdownCategorySchema, kj as ContextBreakdownResult, bQ as ContextBreakdownResultSchema, kl as ContextStats, bR as ContextStatsAccuracy, bS as ContextStatsSchema, iS as CreateComputerOptions, ia as CreateCronOptions, h$ as CreateDaemonSessionOptions, hF as CreateMessage, lY as CreateMessageNotification, bT as CreateMessageNotificationSchema, mm as CreateToolConfirmationDetails, bU as CreateToolConfirmationDetailsSchema, ib as CronOperationsResource, ic as CronsResource, id as CustomModelsResource, bV as DEFAULT_LOCAL_DAEMON_WS_URL, bW as DEFAULT_REQUEST_TIMEOUT, i0 as DaemonAuth, bX as DaemonAuthenticationMode, bY as DaemonClient, jm as DaemonClientConfig, bZ as DaemonClientMetaError, jb as DaemonCoreDeps, b_ as DaemonDroidEvent, jL as DaemonRequest, b$ as DaemonRequestPermissionSchema, ie as DaemonResources, c0 as DaemonSessionController, i1 as DaemonSessionSummary, jc as DaemonSpan, c1 as DecompSessionType, iY as DeleteComputerOptions, mZ as DiscoveredIssue, c2 as DiscoveredIssueSchema, n7 as DismissalRecord, c3 as DismissalRecordSchema, c4 as DismissalType, nr as DocumentBlock, c5 as DocumentBlockSchema, nq as DocumentSource, c6 as DocumentSourceSchema, hq as DroidAssistantMessage, h4 as DroidAttributeValue, h5 as DroidAttributes, gT as DroidClientError, c7 as DroidClientMethod, hu as DroidErrorMessage, c8 as DroidErrorType, c9 as DroidEvent, he as DroidHookEvent, ca as DroidHookEventSchema, h3 as DroidHookExecutionResult, cb as DroidHookExecutionResultSchema, hf as DroidHookInput, hg as DroidHookOutput, cc as DroidHookOutputSchema, cd as DroidHookSpecificOutputSchema, h6 as DroidLogEvent, h7 as DroidLogger, hX as DroidMessage, ce as DroidMessageType, h8 as DroidMetricEvent, h9 as DroidMetricSink, hh as DroidPermissionMode, ha as DroidSerializedError, cf as DroidServerMethod, hs as DroidToolCallMessage, ht as DroidToolResultMessage, hb as DroidTraceContextCarrier, hc as DroidTraceContextProvider, hr as DroidUserMessage, cg as DroidWorkingState, l_ as DroidWorkingStateChangedNotification, ch as DroidWorkingStateChangedNotificationSchema, mk as EditToolConfirmationDetails, ci as EditToolConfirmationDetailsSchema, k1 as EmptyResult, cj as EmptyResultSchema, mw as ErrorDetail, ck as ErrorDetailSchema, hW as ErrorEvent, lZ as ErrorNotification, cl as ErrorNotificationSchema, cm as ExecToolInfoSchema, kX as ExecuteRewindRequest, cn as ExecuteRewindRequestParamsSchema, co as ExecuteRewindRequestSchema, kY as ExecuteRewindResponse, kZ as ExecuteRewindResult, cp as ExecuteRewindResultSchema, ml as ExecuteToolConfirmationDetails, cq as ExecuteToolConfirmationDetailsSchema, mo as ExitSpecModeConfirmationDetails, cr as ExitSpecModeConfirmationDetailsSchema, cs as FACTORY_CLIENT_HEADER, ct as FACTORY_CLIENT_VERSION, cu as FACTORY_PROTOCOL_VERSION, iM as FactoryApiOptions, jq as FactoryDaemonConfig, cv as FactoryDaemonTransport, jr as FactoryDroidEvents, nu as FactoryDroidMessage, cw as FactoryDroidMessageRole, cx as FactoryDroidMessageSchema, cy as FeatureStatus, cz as FeatureSuccessState, cA as FeatureSuccessStateSchema, ig as FeedbackResource, ih as FileTransfersResource, i2 as ForkSessionOptions, k_ as ForkSessionRequest, cB as ForkSessionRequestSchema, k$ as ForkSessionResponse, l0 as ForkSessionResult, cC as ForkSessionResultSchema, iV as GetComputerByNameOptions, iW as GetComputerMetricsOptions, iU as GetComputerOptions, l1 as GetContextStatsRequest, l2 as GetContextStatsRequestParams, cD as GetContextStatsRequestParamsSchema, cE as GetContextStatsRequestSchema, l3 as GetContextStatsResponse, bS as GetContextStatsResultSchema, j4 as GetMachineTemplateOptions, l4 as GetRewindInfoRequest, cF as GetRewindInfoRequestParamsSchema, cG as GetRewindInfoRequestSchema, l5 as GetRewindInfoResponse, cH as GetRewindInfoResultSchema, ii as GetSessionMessagesOptions, km as GitRepoInfo, cI as GitRepoInfoSchema, ij as GitResource, n6 as Handoff, nh as HandoffItemsDismissedEntry, cJ as HandoffItemsDismissedEntrySchema, cK as HandoffSchema, mJ as HookCommand, cL as HookCommandSchema, hT as HookExecution, mb as HookExecutionCompletedNotification, cM as HookExecutionCompletedNotificationSchema, ma as HookExecutionStartedNotification, cN as HookExecutionStartedNotificationSchema, mK as HookResult, cO as HookResultSchema, kn as HttpHeader, cP as HttpHeaderSchema, cQ as HttpMcpConfigSchema, jn as IDaemonClient, gQ as IPC_DAEMON_URL, jz as IToolProgressStore, nm as ImageBlock, cR as ImageBlockSchema, gR as InProcessMessageHandler, jE as InitializeResult, l6 as InitializeSessionRequest, cS as InitializeSessionRequestParamsSchema, cT as InitializeSessionRequestSchema, cU as InitializeSessionResponseSchema, l7 as InitializeSessionResult, cV as InitializeSessionResultSchema, m$ as InteractiveCheck, cW as InteractiveCheckSchema, jH as InterruptResult, l8 as InterruptSessionRequest, l9 as InterruptSessionRequestParams, cX as InterruptSessionRequestParamsSchema, cY as InterruptSessionRequestSchema, la as InterruptSessionResponse, cZ as InterruptSessionResponseSchema, lb as InterruptSessionResult, c_ as InterruptSessionResultSchema, gU as InvalidSessionCwdError, c$ as IssueSeverity, d0 as JSONRPC_VERSION, j_ as JsonArray, d1 as JsonArraySchema, jZ as JsonObject, d2 as JsonObjectSchema, jY as JsonPrimitive, k3 as JsonRpcEnvelope, d3 as JsonRpcEnvelopeSchema, k4 as JsonRpcError, d4 as JsonRpcErrorCode, d5 as JsonRpcErrorSchema, ke as JsonRpcMessage, d6 as JsonRpcMessageSchema, d7 as JsonRpcMessageType, kc as JsonRpcNotification, d8 as JsonRpcNotificationSchema, k9 as JsonRpcRequest, d9 as JsonRpcRequestError, da as JsonRpcRequestSchema, kd as JsonRpcResponse, kb as JsonRpcResponseFailure, db as JsonRpcResponseFailureSchema, dc as JsonRpcResponseSchema, ka as JsonRpcResponseSuccess, dd as JsonRpcResponseSuccessSchema, j$ as JsonValue, de as JsonValueSchema, lc as KillWorkerSessionRequest, ld as KillWorkerSessionRequestParams, df as KillWorkerSessionRequestParamsSchema, dg as KillWorkerSessionRequestSchema, le as KillWorkerSessionResponse, dh as KillWorkerSessionResponseSchema, lf as KillWorkerSessionResult, di as KillWorkerSessionResultSchema, dj as LEGACY_FACTORY_API_VERSION, dk as LOCAL_MACHINE_ID, iT as ListComputersOptions, i3 as ListDaemonSessionsOptions, j3 as ListMachineTemplatesOptions, lg as ListMcpRegistryRequest, lh as ListMcpRegistryRequestParams, dl as ListMcpRegistryRequestParamsSchema, dm as ListMcpRegistryRequestSchema, li as ListMcpRegistryResponse, lj as ListMcpRegistryResult, dn as ListMcpRegistryResultSchema, lk as ListMcpServersRequest, ll as ListMcpServersRequestParams, dp as ListMcpServersRequestParamsSchema, dq as ListMcpServersRequestSchema, lm as ListMcpServersResponse, dr as ListMcpServersResultSchema, ln as ListMcpToolsRequest, lo as ListMcpToolsRequestParams, ds as ListMcpToolsRequestParamsSchema, dt as ListMcpToolsRequestSchema, lp as ListMcpToolsResponse, lq as ListMcpToolsResult, du as ListMcpToolsResultSchema, j8 as ListRemoteSessionsOptions, lu as ListSkillsRequest, lv as ListSkillsRequestParams, dv as ListSkillsRequestParamsSchema, dw as ListSkillsRequestSchema, lw as ListSkillsResponse, dx as ListSkillsResultSchema, lr as ListToolsRequest, dy as ListToolsRequestParamsSchema, dz as ListToolsRequestSchema, ls as ListToolsResponse, lt as ListToolsResult, dA as ListToolsResultSchema, jF as LoadResult, lz as LoadSessionRequest, dB as LoadSessionRequestParamsSchema, dC as LoadSessionRequestSchema, dD as LoadSessionResponseSchema, lA as LoadSessionResult, dE as LoadSessionResultSchema, jd as LogMetadata, dF as MACHINE_TYPE_WEBSOCKET_OVERRIDES, dG as MANAGED_COMPUTER_MAX_RETRIES, dH as MCP_AUTH_TIMEOUT, jv as MachineConnectionConfig, ju as MachineInfo, j1 as MachineTemplate, j2 as MachineTemplateBuildStatus, dI as MachineTemplateBuildStatusSchema, j5 as MachineTemplateListResponse, dJ as MachineTemplateListResponseSchema, dK as MachineTemplateSchema, dL as MachineType, ik as MarketplacesResource, hS as McpAuthCompleted, m9 as McpAuthCompletedNotification, dM as McpAuthCompletedNotificationSchema, dN as McpAuthOutcome, hR as McpAuthRequired, m8 as McpAuthRequiredNotification, dO as McpAuthRequiredNotificationSchema, mQ as McpHttpServerConfigFields, dP as McpHttpServerConfigFieldsSchema, mU as McpRegistryServer, dQ as McpRegistryServerSchema, il as McpResource, dR as McpServerConfigSchema, dS as McpServerStatus, mS as McpServerStatusInfo, dT as McpServerStatusInfoSchema, dU as McpServerType, mW as McpSseServerConfigFields, dV as McpSseServerConfigFieldsSchema, dW as McpStatus, hK as McpStatusChanged, m2 as McpStatusChangedNotification, dX as McpStatusChangedNotificationSchema, mT as McpStatusSummary, dY as McpStatusSummarySchema, mR as McpStdioServerConfigFields, dZ as McpStdioServerConfigFieldsSchema, ms as McpToolConfirmationDetails, d_ as McpToolConfirmationDetailsSchema, d$ as McpToolInfoSchema, mX as McpToolInputSchema, e0 as McpToolInputSchemaSchema, jJ as MessageRouterEvents, e1 as MessageVisibility, e2 as Metric, je as MetricLabels, ni as MilestoneValidationTriggeredEntry, e3 as MilestoneValidationTriggeredEntrySchema, n8 as MissionAcceptedEntry, e4 as MissionAcceptedEntrySchema, mY as MissionFeature, e5 as MissionFeatureSchema, hM as MissionFeaturesChanged, mf as MissionFeaturesChangedNotification, e6 as MissionFeaturesChangedNotificationSchema, hO as MissionHeartbeat, mh as MissionHeartbeatNotification, e7 as MissionHeartbeatNotificationSchema, n9 as MissionPausedEntry, e8 as MissionPausedEntrySchema, hN as MissionProgressEntry, mg as MissionProgressEntryNotification, e9 as MissionProgressEntryNotificationSchema, na as MissionResumedEntry, ea as MissionResumedEntrySchema, nb as MissionRunStartedEntry, eb as MissionRunStartedEntrySchema, ki as MissionSnapshot, ec as MissionSnapshotSchema, jC as MissionSnapshotStore, ed as MissionState, hL as MissionStateChanged, me as MissionStateChangedNotification, ee as MissionStateChangedNotificationSchema, jA as MissionStoreInterface, hQ as MissionWorkerCompleted, mj as MissionWorkerCompletedNotification, ef as MissionWorkerCompletedNotificationSchema, hP as MissionWorkerStarted, mi as MissionWorkerStartedNotification, eg as MissionWorkerStartedNotificationSchema, im as MissionsResource, eh as ModelProvider, ei as MultiMissionStateManager, ej as MultiSessionStateManager, jP as NotificationDispatcherEvents, hi as NotificationHookInput, ip as OpenedSessionSummary, ek as OtelTracing, jM as OutgoingMessage, ko as OutputFormat, el as OutputFormatSchema, em as OutputFormatType, jS as PendingAskUserRequest, jQ as PendingPermission, jo as PendingRequest, jU as PendingUserAction, jR as PermissionRequestHandlerEvents, hG as PermissionResolved, l$ as PermissionResolvedNotification, en as PermissionResolvedNotificationSchema, io as PluginsResource, hj as PreCompactHookInput, gV as ProcessExitError, nj as ProgressLogEntry, eo as ProgressLogEntrySchema, ep as ProgressLogEntryType, mp as ProposeMissionConfirmationDetails, eq as ProposeMissionConfirmationDetailsSchema, gW as ProtocolError, iq as ProxyResource, er as QueuedUserMessageDisplayGroup, es as QueuedUserMessageKind, jO as QueuedUserMessageState, et as REWIND_TIMEOUT, no as RedactedThinkingBlock, eu as RedactedThinkingBlockSchema, i_ as RefreshComputerOptions, i$ as RefreshComputerResponse, ev as RefreshComputerResponseSchema, ew as RelayConnectionError, ir as RelayResource, j6 as RemoteSession, j7 as RemoteSessionListResponse, ex as RemoteSessionListResponseSchema, ey as RemoteSessionSchema, lB as RemoveMcpServerRequest, ez as RemoveMcpServerRequestParamsSchema, eA as RemoveMcpServerRequestSchema, lC as RemoveMcpServerResponse, eB as RemoveMcpServerResultSchema, lD as RenameSessionRequest, eC as RenameSessionRequestParamsSchema, eD as RenameSessionRequestSchema, lE as RenameSessionResponse, lF as RenameSessionResult, eE as RenameSessionResultSchema, jN as RequestManagerEvents, mL as RequestPermissionRequest, mM as RequestPermissionRequestParams, eF as RequestPermissionRequestParamsSchema, eG as RequestPermissionRequestSchema, mO as RequestPermissionResponse, eH as RequestPermissionResponseSchema, mN as RequestPermissionResult, eI as RequestPermissionResultSchema, mP as RequestPermissionSelection, iZ as RestartComputerOptions, i4 as ResumeDaemonSessionOptions, j0 as RetryInstallDepsOptions, jg as RetryOptions, jh as RetryWarnLogger, kp as RewindEvictedFile, eJ as RewindEvictedFileSchema, kq as RewindFileCreation, eK as RewindFileCreationSchema, kr as RewindFileSnapshot, eL as RewindFileSnapshotSchema, i5 as RewindSessionParams, i6 as RewindSessionResult, eM as SDK_TAG, eN as SDK_VERSION, eO as SESSION_INIT_TIMEOUT, eP as SLACK_DELEGATION_MAX_RETRIES, iu as SearchSessionSummary, it as SearchSessionsResult, is as SemanticDiffResource, eQ as ServerRequestHandlerType, js as Session, hk as SessionEndHookInput, gX as SessionError, jw as SessionInitializedOutcome, jt as SessionManagerConfig, iv as SessionMessage, eR as SessionMetadataSchema, gY as SessionNotFoundError, mB as SessionNotification, mA as SessionNotificationParams, eS as SessionNotificationParamsSchema, mz as SessionNotificationPayload, eT as SessionNotificationPayloadSchema, eU as SessionNotificationSchema, eV as SessionNotificationSchemaList, eW as SessionNotificationType, iw as SessionOperationsResource, jK as SessionPendingRequest, eX as SessionPlatform, eY as SessionReplacedError, eZ as SessionReplacementError, h1 as SessionSettingsFile, e_ as SessionSettingsFileSchema, e$ as SessionSettingsSchema, f0 as SessionSourceSchema, h2 as SessionStartEvent, f1 as SessionStartEventSchema, hl as SessionStartHookInput, h0 as SessionSummary, f2 as SessionTagSchema, hI as SessionTitleUpdated, m1 as SessionTitleUpdatedNotification, f3 as SessionTitleUpdatedNotificationSchema, md as SessionTokenUsageChangedNotification, f4 as SessionTokenUsageChangedNotificationSchema, jI as SessionWebSocketConnectionEvents, hJ as SessionWorkingDirectoryChanged, i7 as SessionsResource, lx as SetSkillDisabledRequest, f5 as SetSkillDisabledRequestParamsSchema, f6 as SetSkillDisabledRequestSchema, ly as SetSkillDisabledResponse, f7 as SetSkillDisabledResultSchema, ix as SettingsResource, hH as SettingsUpdated, m0 as SettingsUpdatedNotification, f8 as SettingsUpdatedNotificationSchema, mx as SettingsUpdatedPayload, f9 as SettingsUpdatedPayloadSchema, n4 as SkillDeviation, fa as SkillDeviationSchema, n5 as SkillFeedback, fb as SkillFeedbackSchema, ks as SkillInfo, fc as SkillInfoSchema, fd as SkillLocation, kt as SkillResource, fe as SkillResourceSchema, iy as SkillsResource, iz as SoftwareFactoryActivitiesResource, iA as SoftwareFactoryChangesResource, iB as SoftwareFactoryEventsResource, iC as SoftwareFactoryResource, iD as SoftwareFactorySignalsResource, iE as SoftwareFactoryWorkstreamsResource, ff as SpanAttribute, fg as SpanEvent, fh as SpanName, kh as SseMcpConfig, fi as SseMcpConfigSchema, iF as SshResource, mq as StartMissionRunConfirmationDetails, fj as StartMissionRunConfirmationDetailsSchema, kg as StdioMcpConfig, fk as StdioMcpConfigSchema, hm as StopHookInput, jW as StoredAskUserAction, jV as StoredPermissionAction, fl as StreamStateTracker, hU as StructuredOutput, my as StructuredOutputError, fm as StructuredOutputErrorSchema, hV as StructuredOutputFields, m5 as StructuredOutputNotification, fn as StructuredOutputNotificationSchema, hn as SubagentStopHookInput, lG as SubmitBugReportRequest, lH as SubmitBugReportRequestParams, fo as SubmitBugReportRequestParamsSchema, fp as SubmitBugReportRequestSchema, lI as SubmitBugReportResponse, lJ as SubmitBugReportResult, fq as SubmitBugReportResultSchema, lK as SubmitMcpAuthCodeRequest, lL as SubmitMcpAuthCodeRequestParams, fr as SubmitMcpAuthCodeRequestSchema, lM as SubmitMcpAuthCodeResponse, lN as SubmitMcpAuthCodeResult, fs as SubmitMcpAuthCodeResultSchema, k2 as SuccessResult, ft as SuccessResultSchema, jy as TerminalMetadata, jx as TerminalSerializedState, iG as TerminalsResource, n1 as TestCase, fu as TestCaseSchema, n2 as TestFile, fv as TestFileSchema, n3 as Tests, fw as TestsSchema, nk as TextBlock, fx as TextBlockSchema, nn as ThinkingBlock, fy as ThinkingBlockSchema, hy as ThinkingTextComplete, m7 as ThinkingTextCompleteNotification, fz as ThinkingTextCompleteNotificationSchema, hx as ThinkingTextDelta, m6 as ThinkingTextDeltaNotification, fA as ThinkingTextDeltaNotificationSchema, gZ as TimeoutError, lO as ToggleMcpServerRequest, fB as ToggleMcpServerRequestParamsSchema, fC as ToggleMcpServerRequestSchema, lP as ToggleMcpServerResponse, fD as ToggleMcpServerResultSchema, lQ as ToggleMcpToolRequest, lR as ToggleMcpToolRequestParams, fE as ToggleMcpToolRequestParamsSchema, fF as ToggleMcpToolRequestSchema, lS as ToggleMcpToolResponse, lT as ToggleMcpToolResult, fG as ToggleMcpToolResultSchema, kf as TokenUsage, fH as TokenUsageSchema, hE as TokenUsageUpdate, hz as ToolCallDelta, mc as ToolCallNotification, fI as ToolCallNotificationSchema, mt as ToolConfirmationDetails, fJ as ToolConfirmationDetailsSchema, mu as ToolConfirmationInfo, fK as ToolConfirmationInfoSchema, mV as ToolConfirmationListItem, fL as ToolConfirmationListItemSchema, fM as ToolConfirmationType, ho as ToolHookInput, hC as ToolProgress, jB as ToolProgressNotifier, mv as ToolProgressUpdate, lX as ToolProgressUpdateNotification, fN as ToolProgressUpdateNotificationSchema, fO as ToolProgressUpdateSchema, hB as ToolResult, ns as ToolResultBlock, fP as ToolResultBlockSchema, lW as ToolResultNotification, fQ as ToolResultNotificationSchema, fR as ToolSelectionOverridesSchema, hA as ToolUse, np as ToolUseBlock, fS as ToolUseBlockSchema, fT as ToolUseSchema, jf as TraceContext, k0 as TraceContextMeta, fU as TraceContextMetaSchema, fV as TunnelConnection, jl as TunnelConnectionOptions, iH as UnstableResource, iX as UpdateComputerOptions, iI as UpdateCronOptions, iJ as UpdateSessionSettingsOptions, lU as UpdateSessionSettingsRequest, fW as UpdateSessionSettingsRequestParamsSchema, fX as UpdateSessionSettingsRequestSchema, lV as UpdateSessionSettingsResponse, fY as UpdateSessionSettingsResponseSchema, fZ as UpdateSessionSettingsResultSchema, iK as UpdatesResource, jD as UseMissionStoreSnapshotParams, hp as UserPromptSubmitHookInput, n0 as Verification, m_ as VerificationCommand, f_ as VerificationCommandSchema, f$ as VerificationSchema, jp as WebSocketConnectionConfig, g0 as WebSocketConnectionError, jI as WebSocketConnectionEvents, g1 as WebSocketDaemonTransport, jX as WebSocketDaemonTransportConfig, ne as WorkerCompletedEntry, g2 as WorkerCompletedEntrySchema, nf as WorkerFailedEntry, g3 as WorkerFailedEntrySchema, ng as WorkerPausedEntry, g4 as WorkerPausedEntrySchema, nd as WorkerSelectedFeatureEntry, g5 as WorkerSelectedFeatureEntrySchema, nc as WorkerStartedEntry, g6 as WorkerStartedEntrySchema, ku as WorkerStateInfo, g7 as WorkerStateInfoSchema, hD as WorkingStateChanged, iL as WorkspaceResource, g8 as buildUserMessageContentBlocks, g9 as configureDaemonCoreDeps, ga as connectAndAuthenticate, gb as connectToDaemon, gc as connectWithRetry, gd as convertNotificationToStreamMessage, ge as createComputer, gf as createResponseSchema, gg as createWebSocketDaemonClient, gh as defaultDaemonCoreDeps, gi as deleteComputer, gj as filterMessagesForUI, gk as getComputer, gl as getComputerByName, gm as getComputerMetrics, gn as getMachineTemplate, go as getPermissionToolInputForDisplay, gp as getQueuedUserMessageDisplayGroup, gq as getQueuedUserMessageReviewPriority, gr as getSubagentCallingMetadata, gs as getToolResultBlocks, gt as getToolResultToolUseId, gu as hasDecoupledInteractionSettings, gv as hasSubagentSessionTag, gw as inspectJsonRpcEnvelope, gx as isDaemonQueuedMessageKind, gy as isPendingToolResultMarker, gz as isPersistedHookMessage, gA as isReviewableQueuedMessageKind, gB as listComputers, gC as listMachineTemplates, gD as listRemoteSessions, gE as machineTypeToMachineConnectionType, gF as orderMessagesByParentChain, gG as recordComputerConnectSli, gH as refreshComputer, gI as repairParentChainCorruption, gJ as restartComputer, gK as retryInstallDeps, gL as retryWithLogger, gM as sumTokenUsage, gN as summarizeSessionToolUsage, gO as toError, gP as updateComputer } from './index-D_SzTnFR.mjs';
3
+ import EventEmitter from 'events';
4
+ import { z } from 'zod';
5
+ import { ChildProcess, StdioOptions } from 'child_process';
6
+ import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
7
+ import '@opentelemetry/api';
8
+ import 'eventemitter3';
9
+
10
+ declare class IpcDaemonClientTransport implements DaemonClientTransport {
11
+ private readonly connectionId;
12
+ private connected;
13
+ private readonly channel;
14
+ private unsubscribeMessage;
15
+ private unsubscribeDisconnect;
16
+ private readonly handlers;
17
+ private readonly handleChannelMessage;
18
+ private readonly handleChannelDisconnect;
19
+ constructor(channel?: DaemonIpcMessageChannel);
20
+ connect(_url: string): Promise<void>;
21
+ disconnect(): void;
22
+ isConnected(): boolean;
23
+ getConnectionId(): string | null;
24
+ isRelayConnection(): boolean;
25
+ getTransportKind(): DaemonClientTransportKind.Ipc;
26
+ send(data: string): void;
27
+ on<T extends keyof DaemonClientTransportEvents>(event: T, handler: DaemonClientTransportEvents[T]): void;
28
+ off<T extends keyof DaemonClientTransportEvents>(event: T, handler: DaemonClientTransportEvents[T]): void;
29
+ private cleanupSubscriptions;
30
+ private isChannelAvailable;
31
+ private sendWhenAvailable;
32
+ private normalizeError;
33
+ }
34
+
35
+ /**
36
+ * A DaemonClientTransport that forwards JSON-RPC frames directly to an
37
+ * in-process runtime instead of crossing an IPC/WS boundary.
38
+ *
39
+ * Why this exists: the TUI's "parent" mode previously plugged
40
+ * `InProcessDaemonClient` straight into `DaemonSessionController`, which
41
+ * meant every method had to re-implement DaemonClient's envelope/error
42
+ * handling. That's how the recent `/bug` and `/compact` regressions
43
+ * happened (`response.result` returned without `if (response.error)`).
44
+ *
45
+ * Routing the same calls through `DaemonClient(transport: this)` means
46
+ * envelope construction, schema validation, timeouts, and error
47
+ * propagation live in exactly one place; the runtime handles frames.
48
+ */
49
+ declare class InProcessDaemonClientTransport implements DaemonClientTransport {
50
+ private readonly connectionId;
51
+ private readonly options;
52
+ private connected;
53
+ private readonly unsubscribeFns;
54
+ private readonly handlers;
55
+ constructor(options: InProcessDaemonClientTransportOptions);
56
+ connect(url: string): Promise<void>;
57
+ disconnect(): void;
58
+ isConnected(): boolean;
59
+ getConnectionId(): string | null;
60
+ isRelayConnection(): boolean;
61
+ getTransportKind(): DaemonClientTransportKind.InProcess;
62
+ send(data: string): void;
63
+ on<T extends keyof DaemonClientTransportEvents>(event: T, handler: DaemonClientTransportEvents[T]): void;
64
+ off<T extends keyof DaemonClientTransportEvents>(event: T, handler: DaemonClientTransportEvents[T]): void;
65
+ /**
66
+ * Escape hatch for the in-process-only `setPendingSessionReady`
67
+ * coordination hook. Routed via the transport so DaemonSessionController
68
+ * can share in-flight session initialization/loading with the in-process
69
+ * runtime after it moves behind `DaemonClient`.
70
+ */
71
+ setPendingSessionReady(sessionId: string, promise: Promise<unknown>): void;
72
+ private sendWhenAvailable;
73
+ private registerUnsubscribe;
74
+ private cleanupSubscriptions;
75
+ private emitMessage;
76
+ private emitError;
77
+ private handleClose;
78
+ private normalizeError;
79
+ }
80
+
81
+ declare enum DroidClientEvent {
82
+ SESSION_NOTIFICATION = "session_notification",
83
+ REQUEST_PERMISSION = "request_permission",
84
+ ASK_USER = "ask_user",
85
+ ERROR = "error"
86
+ }
87
+ /**
88
+ * CLI mode for spawning droid processes
89
+ */
90
+ declare enum DroidProcessMode {
91
+ /** ACP child mode (`droid --acp`) */
92
+ Acp = "acp",
93
+ /** SDK mode (`droid exec --input-format stream-jsonrpc`) */
94
+ StreamJsonRpc = "stream-jsonrpc"
95
+ }
96
+ /**
97
+ * Direction of a JSON-RPC transport message when written to the
98
+ * droid-transport.log file.
99
+ */
100
+ declare enum TransportDirection {
101
+ /** Inbound: from droid process to host (daemon / CLI / host app). */
102
+ In = "in",
103
+ /** Outbound: from host to droid process, written successfully. */
104
+ Out = "out",
105
+ /**
106
+ * Outbound attempt that failed to reach the child process (e.g. EPIPE,
107
+ * ECONNRESET). Logged so frame loss is visible without conflating it
108
+ * with successfully sent frames.
109
+ */
110
+ OutFailed = "out_failed"
111
+ }
112
+
113
+ /** Observability logger interface for the exec core. */
114
+ interface Logger {
115
+ info(message: string, metadata?: LogMetadata): void;
116
+ warn(message: string, metadata?: LogMetadata): void;
117
+ exception(error: unknown, message: string, metadata?: LogMetadata): void;
118
+ }
119
+ /** Metrics emitter interface for the exec core. */
120
+ interface Metrics {
121
+ addToCounter(metric: string, value: number, tags?: Record<string, string>): void;
122
+ /**
123
+ * Record a millisecond-valued duration. Distinct from {@link addToCounter}
124
+ * so downstream sinks can model it as a histogram with a `ms` unit rather
125
+ * than a unitless counter.
126
+ */
127
+ recordDuration(metric: string, valueMs: number, tags?: Record<string, string>): void;
128
+ }
129
+ /** Tracing context interface for the exec core. */
130
+ interface Tracing {
131
+ getCurrentContext(): unknown;
132
+ injectContext(meta: Record<string, unknown>, context: unknown): void;
133
+ }
134
+ /** Result of resolving the droid executable path and prefix arguments. */
135
+ interface ResolvedDroidCommand {
136
+ execPath: string;
137
+ prefixArgs: string[];
138
+ }
139
+ /** Resolves the droid executable command for spawn. */
140
+ interface CommandResolver {
141
+ resolveDroidCommand(isDevelopment: boolean): ResolvedDroidCommand;
142
+ }
143
+ /** Resolves Factory home directory and directory name for path construction. */
144
+ interface FactoryPathResolver {
145
+ getFactoryHome(): string;
146
+ getFactoryDirName(): string;
147
+ }
148
+ /** Resolves environment values used by the exec core. */
149
+ interface EnvironmentResolver {
150
+ resolveTransportLogEnvValue(): string | undefined;
151
+ /**
152
+ * Sanitize the environment handed to a spawned droid child. The default
153
+ * implementation is identity; Factory wiring injects a strip that removes
154
+ * whole-process sandbox bridge material so it never crosses into a child.
155
+ */
156
+ sanitizeSpawnEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
157
+ }
158
+ /** Bundle of injectable dependencies for the exec core. */
159
+ interface ExecCoreDeps {
160
+ logger: Logger;
161
+ metrics: Metrics;
162
+ tracing: Tracing;
163
+ commandResolver: CommandResolver;
164
+ factoryPathResolver: FactoryPathResolver;
165
+ environmentResolver: EnvironmentResolver;
166
+ }
167
+ interface DroidProcessManagerOptions {
168
+ observability?: DroidObservability;
169
+ }
170
+ type DroidEventMap = {
171
+ [DroidClientEvent.SESSION_NOTIFICATION]: [SessionNotificationEvent];
172
+ [DroidClientEvent.REQUEST_PERMISSION]: [RequestPermissionEvent];
173
+ [DroidClientEvent.ASK_USER]: [AskUserEvent];
174
+ [DroidClientEvent.ERROR]: [Error];
175
+ };
176
+ type DroidEventType = keyof DroidEventMap;
177
+ /**
178
+ * Configuration for spawning a droid process
179
+ */
180
+ interface DroidProcessConfig {
181
+ /** Path to the droid executable (defaults to 'droid' or 'droid-dev') */
182
+ execPath?: string;
183
+ /** Whether to use development mode (droid-dev) */
184
+ isDevelopment?: boolean;
185
+ /** CLI mode for the spawned process */
186
+ mode: DroidProcessMode;
187
+ /** Working directory for the process */
188
+ cwd?: string;
189
+ /** Additional environment variables */
190
+ env?: Record<string, string>;
191
+ /** Trusted env merged after sanitizer strips inherited process env. */
192
+ trustedEnv?: Record<string, string>;
193
+ /** Extra CLI arguments to pass */
194
+ extraArgs?: string[];
195
+ /** Whether to allocate a Node IPC channel for this child process. */
196
+ enableIpc?: boolean;
197
+ /** Override stdio for trusted process topologies. */
198
+ stdio?: StdioOptions;
199
+ }
200
+ /**
201
+ * Represents a managed droid child process
202
+ */
203
+ interface ManagedProcess {
204
+ /** The underlying child process */
205
+ readonly childProcess: ChildProcess;
206
+ /** Send a message to the process (newline-delimited) */
207
+ send(message: string): Promise<void>;
208
+ /** Register a handler for incoming messages */
209
+ onMessage(handler: (message: string) => void): void;
210
+ /** Register a handler for errors */
211
+ onError(handler: (error: Error) => void): void;
212
+ /** Close the process gracefully */
213
+ close(): Promise<void>;
214
+ /** Check if the process is still connected */
215
+ readonly isConnected: boolean;
216
+ }
217
+ /**
218
+ * Options controlling the Windows Job Object spawn retry wrapper.
219
+ */
220
+ interface SpawnWithRetryOptions {
221
+ /** Max number of retries after the initial spawn. */
222
+ maxRetries?: number;
223
+ /** Backoff schedule in ms between attempts. */
224
+ backoffMs?: readonly number[];
225
+ /**
226
+ * How long to wait for early failure signals before committing to the
227
+ * spawn. On happy path this adds this much latency to spawn completion,
228
+ * so keep it short.
229
+ */
230
+ gracePeriodMs?: number;
231
+ /** Overrides `setTimeout` (primarily for tests). */
232
+ sleep?: (ms: number) => Promise<void>;
233
+ /**
234
+ * Overrides the platform check (primarily for tests). When `false`, retry
235
+ * machinery is skipped entirely and the spawn factory runs once.
236
+ */
237
+ enabled?: boolean;
238
+ /**
239
+ * Best-effort cleanup for children that exited early but we're NOT
240
+ * returning to the caller.
241
+ */
242
+ disposeEarlyExited?: (child: ChildProcess) => void | Promise<void>;
243
+ /** Used to tag log lines for easier correlation. */
244
+ logPrefix?: string;
245
+ /** Injected logger; defaults to no-op when not provided. */
246
+ logger?: Logger;
247
+ }
248
+
249
+ type McpSettingsLevel = SettingsLevel.User;
250
+ type PermissionHandlerResult = RequestPermissionHandlerResult | ToolConfirmationOutcome | RequestPermissionResult;
251
+ /**
252
+ * Derive the JSON-RPC error code for an outgoing failure response. An error can
253
+ * opt into a specific code by setting `metadata.code` on a {@link DroidClientError}
254
+ * (e.g. {@link JsonRpcErrorCode.CONFLICT} for a duplicate request); anything
255
+ * else falls back to INTERNAL_ERROR.
256
+ */
257
+ declare class DroidClient extends EventEmitter<DroidEventMap> {
258
+ private transport;
259
+ private requestTimeout;
260
+ private pendingRequests;
261
+ private permissionHandlers;
262
+ private askUserHandlers;
263
+ private pendingPermissionRequests;
264
+ private pendingAskUserRequests;
265
+ private currentSessionId;
266
+ private peerProtocolVersion;
267
+ /**
268
+ * Sticky error from a transport failure. Once set, all subsequent
269
+ * `sendRequest()` calls throw this error immediately, preventing
270
+ * requests from hanging on a dead transport.
271
+ */
272
+ private transportError;
273
+ private readonly logger;
274
+ private readonly tracing;
275
+ private readonly onRequestSettled;
276
+ constructor(options: DroidClientOptions, deps?: ExecCoreDeps);
277
+ get sessionId(): string | null;
278
+ get isConnected(): boolean;
279
+ private requireMcpOAuthOptOutSupport;
280
+ private validateMcpServersProtocolSupport;
281
+ initializeSession(params: InitializeSessionRequestParams): Promise<InitializeSessionResponse>;
282
+ loadSession(params: LoadSessionRequestParams): Promise<LoadSessionResponse>;
283
+ addUserMessage(params: AddUserMessageParams, requestId?: string): Promise<AddUserMessageResponse>;
284
+ resolveQueuedUserMessage(params: ResolveQueuedUserMessageParams): Promise<ResolveQueuedUserMessageResponse>;
285
+ interruptSession(params?: InterruptSessionParams): Promise<InterruptSessionResponse>;
286
+ closeSession(params?: CloseSessionParams): Promise<CloseSessionResponse>;
287
+ killWorkerSession(params: KillWorkerSessionParams): Promise<KillWorkerSessionResponse>;
288
+ updateSessionSettings(params: UpdateSessionSettingsRequestParams, requestId?: string): Promise<UpdateSessionSettingsResponse>;
289
+ changeWorkingDirectory(params: ChangeWorkingDirectoryParams): Promise<ChangeWorkingDirectoryResponse>;
290
+ toggleMcpServer(params: {
291
+ serverName: string;
292
+ enabled: boolean;
293
+ settingsLevel: McpSettingsLevel;
294
+ }): Promise<z.infer<typeof ToggleMcpServerResponseSchema>>;
295
+ authenticateMcpServer(params: {
296
+ serverName: string;
297
+ }): Promise<z.infer<typeof AuthenticateMcpServerResponseSchema>>;
298
+ cancelMcpAuth(params: {
299
+ serverName: string;
300
+ }): Promise<z.infer<typeof CancelMcpAuthResponseSchema>>;
301
+ clearMcpAuth(params: {
302
+ serverName: string;
303
+ }): Promise<z.infer<typeof ClearMcpAuthResponseSchema>>;
304
+ addMcpServer(params: AddMcpServerRequest['params']): Promise<z.infer<typeof AddMcpServerResponseSchema>>;
305
+ removeMcpServer(params: {
306
+ serverName: string;
307
+ settingsLevel: McpSettingsLevel;
308
+ }): Promise<z.infer<typeof RemoveMcpServerResponseSchema>>;
309
+ listMcpRegistry(): Promise<z.infer<typeof ListMcpRegistryResponseSchema>>;
310
+ listMcpTools(): Promise<z.infer<typeof ListMcpToolsResponseSchema>>;
311
+ listTools(params?: ListToolsRequestParams): Promise<z.infer<typeof ListToolsResponseSchema>>;
312
+ listMcpServers(): Promise<z.infer<typeof ListMcpServersResponseSchema>>;
313
+ toggleMcpTool(serverName: string, toolName: string, enabled: boolean): Promise<z.infer<typeof ToggleMcpToolResponseSchema>>;
314
+ submitMcpAuthCode(params: z.infer<typeof SubmitMcpAuthCodeRequestParamsSchema>): Promise<z.infer<typeof SubmitMcpAuthCodeResponseSchema>>;
315
+ submitMcpAuthError(params: z.infer<typeof SubmitMcpAuthErrorRequestParamsSchema>): Promise<z.infer<typeof SubmitMcpAuthErrorResponseSchema>>;
316
+ listSkills(): Promise<z.infer<typeof ListSkillsResponseSchema>>;
317
+ setSkillDisabled(skillName: string, disabled: boolean, settingsLevel?: SetSkillDisabledRequest['params']['settingsLevel']): Promise<z.infer<typeof SetSkillDisabledResponseSchema>>;
318
+ listCommands(): Promise<z.infer<typeof ListCommandsResponseSchema>>;
319
+ getContextStats(): Promise<z.infer<typeof GetContextStatsResponseSchema>>;
320
+ getContextBreakdown(): Promise<z.infer<typeof GetContextBreakdownResponseSchema>>;
321
+ submitBugReport(userComment: string, clientLogs?: string, source?: SubmitBugReportRequest['params']['source']): Promise<z.infer<typeof SubmitBugReportResponseSchema>>;
322
+ getRewindInfo(params: {
323
+ messageId: string;
324
+ }, timeout?: number): Promise<z.infer<typeof GetRewindInfoResponseSchema>>;
325
+ executeRewind(params: {
326
+ messageId: string;
327
+ filesToRestore: Array<{
328
+ filePath: string;
329
+ contentHash: string;
330
+ size: number;
331
+ }>;
332
+ filesToDelete: Array<{
333
+ filePath: string;
334
+ }>;
335
+ forkTitle: string;
336
+ }): Promise<z.infer<typeof ExecuteRewindResponseSchema>>;
337
+ compactSession(params: {
338
+ customInstructions?: string;
339
+ }): Promise<z.infer<typeof CompactSessionResponseSchema>>;
340
+ forkSession(params?: z.infer<typeof ForkSessionRequestParamsSchema>): Promise<z.infer<typeof ForkSessionResponseSchema>>;
341
+ renameSession(params: RenameSessionRequestParams, requestId?: string): Promise<z.infer<typeof RenameSessionResponseSchema>>;
342
+ warmupCache(): Promise<z.infer<typeof WarmupCacheResponseSchema>>;
343
+ onNotification(callback: (notification: Record<string, unknown>) => void, filter?: {
344
+ type?: string;
345
+ }): () => void;
346
+ onError(callback: (error: Error) => void): () => void;
347
+ setPermissionHandler(handler: (event: RequestPermissionEvent) => Promise<PermissionHandlerResult> | PermissionHandlerResult): void;
348
+ clearPermissionHandler(): void;
349
+ setAskUserHandler(handler: (event: AskUserEvent) => Promise<AskUserResult> | AskUserResult): void;
350
+ clearAskUserHandler(): void;
351
+ close(): Promise<void>;
352
+ private rejectAllPending;
353
+ private settleRequest;
354
+ private notifyRequestSettled;
355
+ private sendRequest;
356
+ private handleMessage;
357
+ private handleResponse;
358
+ private handleEvent;
359
+ /**
360
+ * When an incoming CLI->client request fails to parse, send back a
361
+ * structurally valid JsonRpcBaseResponseFailure so the peer's pending
362
+ * request doesn't hang. No-ops for notifications (no id to reply on)
363
+ * or events we can't correlate.
364
+ */
365
+ private replyWithParseFailureIfRequest;
366
+ /**
367
+ * Invariant: parsing failures for incoming events (notifications or
368
+ * server-initiated requests) must NEVER surface as user-visible ERROR
369
+ * notifications. Version skew, unknown inner enum values, missing
370
+ * fields, or malformed shapes all degrade to a log-and-drop so the
371
+ * session continues quietly instead of flashing a synthetic error on
372
+ * every
373
+ */
374
+ private logDroppedEventParseError;
375
+ private handlePermissionRequest;
376
+ private handleAskUserRequest;
377
+ private static getErrorType;
378
+ private static createErrorNotification;
379
+ private static getNestedString;
380
+ private static isRecord;
381
+ /**
382
+ * Create a full SessionNotificationEvent for locally-generated notifications.
383
+ * Used when the SDK needs to emit error notifications that weren't received from the CLI.
384
+ */
385
+ private static createNotificationEvent;
386
+ }
387
+
388
+ /**
389
+ * Internal implementation of ManagedProcess
390
+ */
391
+ declare class ManagedProcessImpl implements ManagedProcess {
392
+ private readonly logPrefix;
393
+ private readonly spawnContext;
394
+ private readonly transportLoggerDeps;
395
+ private _childProcess;
396
+ private messageHandler;
397
+ private errorHandler;
398
+ private readlineInterface;
399
+ private isClosing;
400
+ /** Latch so exit teardown/classification runs exactly once per process. */
401
+ private exitFinalized;
402
+ private exitDrainTimer;
403
+ /**
404
+ * Sticky error from a process error or unexpected exit event. Once set,
405
+ * all subsequent `send()` calls throw this error immediately instead of
406
+ * hanging on a dead transport.
407
+ */
408
+ private processError;
409
+ private queuedSendPromise;
410
+ private readonly logger;
411
+ constructor(childProcess: ChildProcess, logPrefix: string, spawnContext: {
412
+ cwd?: string;
413
+ execPath?: string;
414
+ } | undefined, deps: ExecCoreDeps, transportLoggerDeps?: ExecCoreDeps);
415
+ get childProcess(): ChildProcess;
416
+ private setupHandlers;
417
+ private finalizeExit;
418
+ send(message: string): Promise<void>;
419
+ onMessage(handler: (message: string) => void): void;
420
+ onError(handler: (error: Error) => void): void;
421
+ close(): Promise<void>;
422
+ get isConnected(): boolean;
423
+ }
424
+
425
+ /**
426
+ * ProcessTransport implements the StringFramedDroidClientTransport interface using a spawned
427
+ * droid child process. It uses DroidProcessManager internally for process management.
428
+ *
429
+ * This is a thin wrapper that maintains the existing API while delegating to
430
+ * the more general-purpose DroidProcessManager.
431
+ */
432
+ declare class ProcessTransport implements StringFramedDroidClientTransport {
433
+ private managedProcess;
434
+ private processManager;
435
+ private options;
436
+ private messageHandler;
437
+ private errorHandler;
438
+ private metrics;
439
+ constructor(options?: ProcessTransportOptions, deps?: ExecCoreDeps);
440
+ connect(): Promise<void>;
441
+ send(message: string): Promise<void>;
442
+ onMessage(handler: (message: string) => void): void;
443
+ onError(handler: (error: Error) => void): void;
444
+ close(): Promise<void>;
445
+ get isConnected(): boolean;
446
+ getManagedProcess(): ManagedProcess | null;
447
+ }
448
+
449
+ /**
450
+ * DroidProcessManager handles spawning and managing droid child processes.
451
+ * This is a generalized process manager that can spawn processes in different modes:
452
+ * - 'acp': For ACP child mode (`droid exec --output-format acp`)
453
+ * - 'stream-jsonrpc': For SDK mode (`droid exec --input-format stream-jsonrpc`)
454
+ */
455
+ declare class DroidProcessManager {
456
+ private readonly deps;
457
+ private readonly transportLoggerDeps;
458
+ private readonly logger;
459
+ private readonly commandResolver;
460
+ constructor(options?: DroidProcessManagerOptions, deps?: ExecCoreDeps);
461
+ /**
462
+ * Spawn a new droid process with the given configuration.
463
+ *
464
+ * Returns a synchronous ManagedProcess as soon as the OS reports the child
465
+ * as spawned. This does not retry Windows Job Object spawn failures — use
466
+ * {@link DroidProcessManager#spawnWithWindowsRetry} for that.
467
+ */
468
+ spawn(config: DroidProcessConfig): ManagedProcess;
469
+ /**
470
+ * Spawn a droid process with automatic retry for the Windows Job Object
471
+ * spawn error class (FAC-19070). On non-Windows platforms this behaves
472
+ * identically to {@link DroidProcessManager#spawn} but returns a promise.
473
+ *
474
+ * When a Windows child process exits within the startup grace period and
475
+ * the exit looks like the `AssignProcessToJobObject` failure pattern, the
476
+ * dead child is disposed and a fresh spawn is attempted, up to the
477
+ * configured retry cap.
478
+ */
479
+ spawnWithWindowsRetry(config: DroidProcessConfig, retryOptions?: SpawnWithRetryOptions): Promise<ManagedProcess>;
480
+ private prepareSpawn;
481
+ private invokeNodeSpawn;
482
+ private spawnChildProcess;
483
+ }
484
+
485
+ /**
486
+ * Check whether transport logging is enabled via env var. The result is
487
+ * cached on first access for performance (env vars don't change mid-run).
488
+ *
489
+ * @public
490
+ */
491
+ declare function isTransportLoggingEnabled(deps?: ExecCoreDeps): boolean;
492
+ /**
493
+ * Log a single JSON-RPC transport message. This is the hot path and is
494
+ * designed to be as cheap as possible when logging is disabled:
495
+ * - Single boolean check when the env var is unset.
496
+ * - No JSON serialisation (messages are already strings on the wire).
497
+ * - Fire-and-forget writes via `WriteStream.write()`: Node buffers
498
+ * internally and never blocks the caller.
499
+ * - Any I/O error disables the logger for the remainder of the process
500
+ * instead of propagating up into the transport.
501
+ */
502
+ declare function logTransportMessage(direction: TransportDirection, message: string, childPid?: number, deps?: ExecCoreDeps): void;
503
+ /**
504
+ * Test-only: reset the cached state so subsequent tests can re-read env vars.
505
+ * Waits for the underlying write stream to flush before resolving.
506
+ *
507
+ * @public
508
+ */
509
+ declare function __resetTransportLoggerForTests(deps?: ExecCoreDeps): Promise<void>;
510
+
511
+ declare function resolveExecCoreDeps(observability: DroidObservability | undefined, fallback?: ExecCoreDeps): ExecCoreDeps;
512
+
513
+ /**
514
+ * Wraps a Node `child_process.spawn` factory with automatic retries on the
515
+ * Windows Job Object spawn failure class. On non-Windows platforms (or when
516
+ * `enabled: false`) this simply invokes `spawnFactory()` once.
517
+ *
518
+ * On Windows, after each spawn we watch for early exits within
519
+ * `gracePeriodMs`. If the child exits early AND the exit looks like a Job
520
+ * Object failure (stderr marker, or non-zero exit without an explicit
521
+ * permanent-failure 'error' event), we dispose the dead child and respawn
522
+ * up to `maxRetries`.
523
+ */
524
+ declare function spawnWithWindowsJobObjectRetry(spawnFactory: () => ChildProcess, options?: SpawnWithRetryOptions): Promise<ChildProcess>;
525
+
526
+ /**
527
+ * Default timeout values for DroidClient
528
+ */
529
+
530
+ /**
531
+ * Windows kernel error string emitted to a child process's stderr when
532
+ * libuv's `uv_spawn` calls `AssignProcessToJobObject` on an
533
+ * already-terminated child handle. Used by the Windows spawn retry wrapper
534
+ * (FAC-19070) to identify the retryable failure class.
535
+ */
536
+ declare const WINDOWS_JOB_OBJECT_ERROR_MARKER = "AssignProcessToJobObject";
537
+ /**
538
+ * Metric key for child-process spawn latency emitted by the process
539
+ * transport. Kept byte-identical to the value historically sourced from the
540
+ * `@factory/logging` metric enum so downstream telemetry stays continuous.
541
+ */
542
+ declare const CLI_JSONRPC_CHILD_SPAWN_LATENCY_METRIC = "cli_jsonrpc_child_spawn_latency";
543
+ /** No-op logger used when no real logger is injected. Safe because it is observability-only. */
544
+ declare const noopLogger: Logger;
545
+
546
+ type ToolInputShape = Record<string, z.ZodTypeAny>;
547
+ type DroidToolResult = string | CallToolResult;
548
+ interface DroidTool {
549
+ name: string;
550
+ description?: string;
551
+ inputSchema?: ToolInputShape;
552
+ handler: (input: Record<string, unknown>) => DroidToolResult | Promise<DroidToolResult>;
553
+ }
554
+ interface SdkMcpServerOptions {
555
+ name: string;
556
+ version?: string;
557
+ tools: DroidTool[];
558
+ }
559
+ type DroidMcpServerConfig = McpServerConfig | SdkMcpServer;
560
+ declare function tool<InputShape extends ToolInputShape>(name: string, description: string, inputSchema: InputShape, handler: (input: z.infer<z.ZodObject<InputShape>>) => DroidToolResult | Promise<DroidToolResult>): DroidTool;
561
+ declare function tool(name: string, description: string, handler: DroidTool['handler']): DroidTool;
562
+ declare class SdkMcpServer {
563
+ readonly name: string;
564
+ readonly version: string;
565
+ readonly tools: DroidTool[];
566
+ private _httpServer;
567
+ private _url;
568
+ private _token;
569
+ constructor(options: SdkMcpServerOptions);
570
+ get config(): HttpMcpConfig | null;
571
+ start(): Promise<HttpMcpConfig>;
572
+ close(): Promise<void>;
573
+ private createMcpServer;
574
+ private handleRequest;
575
+ }
576
+ declare function createSdkMcpServer(options: SdkMcpServerOptions): SdkMcpServer;
577
+
578
+ interface TransportCreationOptions {
579
+ /** Defaults to `process.env.FACTORY_API_KEY`. */
580
+ apiKey?: string;
581
+ execPath?: string;
582
+ execArgs?: string[];
583
+ cwd?: string;
584
+ env?: Record<string, string>;
585
+ observability?: DroidObservability;
586
+ transport?: StringFramedDroidClientTransport;
587
+ }
588
+ interface SessionInitOptions extends ToolSelectionOverrides {
589
+ /** Defaults to `process.cwd()`. */
590
+ cwd?: string;
591
+ machineId?: string;
592
+ modelId?: string;
593
+ autonomyLevel?: AutonomyLevel;
594
+ interactionMode?: DroidInteractionMode;
595
+ reasoningEffort?: ReasoningEffort;
596
+ specModeModelId?: string;
597
+ specModeReasoningEffort?: ReasoningEffort;
598
+ mcpServers?: DroidMcpServerConfig[];
599
+ sessionSource?: SessionSource;
600
+ tags?: SessionTag[];
601
+ autoRejectPermissionRequests?: boolean;
602
+ /** When true, Factory-provided builtin skills are unavailable. */
603
+ disableBuiltinSkills?: boolean;
604
+ }
605
+
606
+ type NotificationCallback = (notification: Record<string, unknown>) => void;
607
+ interface NotificationFilter {
608
+ type?: string;
609
+ }
610
+ /** Aggregated result from a one-shot {@link run} call. */
611
+ type DroidResult = DroidResultMessage;
612
+ interface CreateSessionOptions extends SessionInitOptions, HandlerOptions, TransportCreationOptions {
613
+ abortSignal?: AbortSignal;
614
+ }
615
+ interface ResumeSessionOptions extends Pick<CreateSessionOptions, 'apiKey' | 'execPath' | 'execArgs' | 'env' | 'permissionHandler' | 'askUserHandler' | 'transport' | 'abortSignal' | 'observability' | 'disabledToolIds' | 'autoRejectPermissionRequests' | 'disableBuiltinSkills' | 'sessionSource'> {
616
+ mcpServers?: DroidMcpServerConfig[];
617
+ }
618
+
619
+ type ToolInfo = Omit<ExecToolInfo, 'id' | 'llmId' | 'currentlyAllowed'> & {
620
+ id: ExecToolInfo['llmId'];
621
+ allowed: ExecToolInfo['currentlyAllowed'];
622
+ };
623
+ type ListToolsOptions = ListToolsRequestParams;
624
+ type DroidSessionUpdateSettingsOptions = UpdateSessionSettingsRequestParams;
625
+ type ReplacementLoadParams = Omit<LoadSessionRequestParams, 'sessionId'>;
626
+ interface SessionRuntime {
627
+ abortSignal?: AbortSignal;
628
+ loadParams: ReplacementLoadParams;
629
+ }
630
+ interface SessionMetadataSnapshot {
631
+ settings: SessionSettings;
632
+ cwd?: string;
633
+ }
634
+ /** Create instances via {@link createSession} or {@link resumeSession}. */
635
+ declare class DroidSession {
636
+ private readonly _runtime;
637
+ private readonly _client;
638
+ private readonly _sessionId;
639
+ private _settings;
640
+ private _cwd;
641
+ private _settingsRevision;
642
+ private _status;
643
+ private _replacementSessionId;
644
+ private _cleanupAbortSignal;
645
+ private _cleanupCallbacks;
646
+ private readonly _activeBridges;
647
+ private readonly _notificationCleanups;
648
+ /** @internal */
649
+ constructor(client: DroidClient, sessionId: string, metadata: SessionMetadataSnapshot, _runtime: SessionRuntime, cleanupCallbacks?: Array<() => Promise<void> | void>);
650
+ get id(): string;
651
+ get settings(): Readonly<SessionSettings>;
652
+ get cwd(): string | undefined;
653
+ /** Yields message-level events until the final `result` message. */
654
+ stream(prompt: string, options?: MessageOptions & {
655
+ includePartialMessages?: false;
656
+ }): AsyncGenerator<DroidStreamMessage, void, undefined>;
657
+ /** Yields message-level events plus partial chunks until the final `result` message. */
658
+ stream(prompt: string, options: MessageOptions & {
659
+ includePartialMessages: true;
660
+ }): AsyncGenerator<DroidStreamEvent, void, undefined>;
661
+ interrupt(): Promise<void>;
662
+ close(): Promise<void>;
663
+ updateSettings(params: DroidSessionUpdateSettingsOptions): Promise<UpdateSessionSettingsResult>;
664
+ enterSpecMode(params?: Pick<UpdateSessionSettingsRequestParams, 'specModeModelId' | 'specModeReasoningEffort'>): Promise<UpdateSessionSettingsResult>;
665
+ addMcpServer(params: AddMcpServerRequestParams): Promise<AddMcpServerResult>;
666
+ removeMcpServer(params: RemoveMcpServerRequestParams): Promise<RemoveMcpServerResult>;
667
+ toggleMcpServer(params: ToggleMcpServerRequestParams): Promise<ToggleMcpServerResult>;
668
+ listMcpServers(): Promise<ListMcpServersResult>;
669
+ listMcpTools(): Promise<McpToolInfo[]>;
670
+ listTools(params?: ListToolsOptions): Promise<ToolInfo[]>;
671
+ authenticateMcpServer(params: AuthenticateMcpServerRequestParams): Promise<AuthenticateMcpServerResult>;
672
+ listSkills(): Promise<ListSkillsResult>;
673
+ setSkillDisabled(params: SetSkillDisabledRequestParams): Promise<SetSkillDisabledResult>;
674
+ getRewindInfo(params: Omit<GetRewindInfoRequestParams, 'sessionId'>): Promise<GetRewindInfoResult>;
675
+ rewind(params: Omit<ExecuteRewindRequestParams, 'sessionId'>): Promise<SessionRewindOutcome<DroidSession>>;
676
+ compact(params?: CompactSessionRequestParams): Promise<SessionCompactionOutcome<DroidSession>>;
677
+ fork(params?: ForkSessionRequestParams): Promise<DroidSession>;
678
+ getContextStats(): Promise<GetContextStatsResult>;
679
+ rename(params: RenameSessionRequestParams$1): Promise<void>;
680
+ onNotification(callback: NotificationCallback, filter?: NotificationFilter): () => void;
681
+ private _ensureNotClosed;
682
+ private _beginReplacement;
683
+ private _runReplacement;
684
+ private _loadReplacement;
685
+ private _bindAbortSignal;
686
+ private _bindMetadataNotifications;
687
+ private _releaseHandleSubscriptions;
688
+ private _disposeAfterFailedRollback;
689
+ }
690
+ declare function createSession(options?: CreateSessionOptions): Promise<DroidSession>;
691
+ /**
692
+ * Resumes an existing Droid session.
693
+ *
694
+ * The resumed session always runs in the working directory that was persisted
695
+ * with the session at creation time. `resumeSession()` intentionally does not
696
+ * accept a `cwd` option: the persisted session cwd is authoritative. The
697
+ * underlying subprocess is launched in the host process's `process.cwd()`, but
698
+ * this does not affect the session's working directory as far as the Droid is
699
+ * concerned. To run in a different directory, create a new session or fork the
700
+ * existing one.
701
+ *
702
+ * @throws {SessionNotFoundError} If the session ID does not exist.
703
+ */
704
+ declare function resumeSession(sessionId: string, options?: ResumeSessionOptions): Promise<DroidSession>;
705
+
706
+ interface RunOptions extends CreateSessionOptions, Omit<MessageOptions, 'includePartialMessages'> {
707
+ }
708
+ declare function run(prompt: string, options?: RunOptions): Promise<DroidResult>;
709
+
710
+ /**
711
+ * List droid sessions stored on disk.
712
+ *
713
+ * Sessions are read from `~/.factory/sessions/` (or the `sessionsDir`
714
+ * override) by scanning `.jsonl` files, mirroring the logic used by the
715
+ * `droid` CLI's `SessionService`. No JSON-RPC server calls are made.
716
+ *
717
+ * By default, returns sessions for `process.cwd()`. Pass a specific `cwd`
718
+ * to scope to a different project, or `fetchOutsideCWD: true` to return
719
+ * every session on disk regardless of working directory. Results are
720
+ * sorted by `modifiedTime` descending and can be capped with `limit`.
721
+ *
722
+ * @example
723
+ * ```ts
724
+ * // Sessions for the current project
725
+ * const sessions = await listSessions();
726
+ *
727
+ * // 10 most recent sessions across every project
728
+ * const recent = await listSessions({
729
+ * fetchOutsideCWD: true,
730
+ * limit: 10,
731
+ * });
732
+ * ```
733
+ */
734
+ declare function listSessions(options?: ListSessionsOptions): Promise<SessionMetadata[]>;
735
+
736
+ export { AddMcpServerRequestParams, AddMcpServerResponseSchema, AddMcpServerResult, AuthenticateMcpServerRequestParams, AuthenticateMcpServerResponseSchema, AuthenticateMcpServerResult, AutonomyLevel, CLI_JSONRPC_CHILD_SPAWN_LATENCY_METRIC, CancelMcpAuthResponseSchema, ClearMcpAuthResponseSchema, type CommandResolver, CompactSessionRequestParams, CompactSessionResponseSchema, type CreateSessionOptions, DaemonClientTransport, DaemonClientTransportEvents, DaemonIpcMessageChannel, DroidClient, DroidClientEvent, DroidClientOptions, type DroidEventMap, type DroidEventType, DroidInteractionMode, type DroidMcpServerConfig, DroidObservability, type DroidProcessConfig, DroidProcessManager, type DroidProcessManagerOptions, DroidProcessMode, type DroidResult, DroidResultMessage, DroidSession, type DroidSessionUpdateSettingsOptions, DroidStreamEvent, DroidStreamMessage, type DroidTool, type DroidToolResult, type EnvironmentResolver, type ExecCoreDeps, ExecToolInfo, ExecuteRewindRequestParams, ExecuteRewindResponseSchema, type FactoryPathResolver, ForkSessionRequestParams, ForkSessionRequestParamsSchema, ForkSessionResponseSchema, GetContextStatsResponseSchema, GetContextStatsResult, GetRewindInfoRequestParams, GetRewindInfoResponseSchema, GetRewindInfoResult, HttpMcpConfig, InProcessDaemonClientTransport, InProcessDaemonClientTransportOptions, InitializeSessionRequestParams, InitializeSessionResponse, IpcDaemonClientTransport, ListMcpRegistryResponseSchema, ListMcpServersResponseSchema, ListMcpServersResult, ListMcpToolsResponseSchema, ListSessionsOptions, ListSkillsResponseSchema, ListSkillsResult, type ListToolsOptions, ListToolsRequestParams, ListToolsResponseSchema, LoadSessionRequestParams, LoadSessionResponse, type Logger, type ManagedProcess, ManagedProcessImpl, McpServerConfig, McpToolInfo, MessageOptions, type Metrics, ProcessTransport, ProcessTransportOptions, ReasoningEffort, RemoveMcpServerRequestParams, RemoveMcpServerResponseSchema, RemoveMcpServerResult, RenameSessionRequestParams$1 as RenameSessionRequestParams, RenameSessionResponseSchema, RequestPermissionHandlerResult, type ResolvedDroidCommand, type ResumeSessionOptions, type RunOptions, SdkMcpServer, type SdkMcpServerOptions, SessionCompactionOutcome, SessionMetadata, SessionRewindOutcome, SessionSettings, SessionSource, SessionTag, SetSkillDisabledRequestParams, SetSkillDisabledResponseSchema, SetSkillDisabledResult, SettingsLevel, type SpawnWithRetryOptions, StringFramedDroidClientTransport, SubmitBugReportResponseSchema, SubmitMcpAuthCodeRequestParamsSchema, SubmitMcpAuthCodeResponseSchema, ToggleMcpServerRequestParams, ToggleMcpServerResponseSchema, ToggleMcpServerResult, ToggleMcpToolResponseSchema, ToolConfirmationOutcome, type ToolInfo, ToolSelectionOverrides, type Tracing, TransportDirection, UpdateSessionSettingsRequestParams, UpdateSessionSettingsResult, WINDOWS_JOB_OBJECT_ERROR_MARKER, __resetTransportLoggerForTests, createSdkMcpServer, createSession, isTransportLoggingEnabled, listSessions, logTransportMessage, noopLogger, resolveExecCoreDeps, resumeSession, run, spawnWithWindowsJobObjectRetry, tool };