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