@slopus/happy-terminal 0.3.0-beta.13

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 (248) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE-CODEX +203 -0
  3. package/LICENSE-GROK-BUILD +204 -0
  4. package/LICENSE-HAPPY +21 -0
  5. package/README.md +60 -0
  6. package/THIRD-PARTY-NOTICES.md +34 -0
  7. package/dist/HappyTerminalUserError.d.ts +12 -0
  8. package/dist/app/AppTranscriptEntry.d.ts +33 -0
  9. package/dist/app/AppendOnlyStreamingRender.d.ts +12 -0
  10. package/dist/app/CodexFileDiff.d.ts +20 -0
  11. package/dist/app/CodexMcpToolCall.d.ts +25 -0
  12. package/dist/app/CodingAssistantAgentBackend.d.ts +81 -0
  13. package/dist/app/CodingAssistantApp.d.ts +128 -0
  14. package/dist/app/CompletedTurn.d.ts +11 -0
  15. package/dist/app/FileMentionAutocomplete.d.ts +30 -0
  16. package/dist/app/HappyTerminalProcessTerminal.d.ts +7 -0
  17. package/dist/app/NoticeChild.d.ts +4 -0
  18. package/dist/app/SecretMenuController.d.ts +31 -0
  19. package/dist/app/SelectionList.d.ts +24 -0
  20. package/dist/app/SessionDraftSync.d.ts +51 -0
  21. package/dist/app/StartupStatusApp.d.ts +34 -0
  22. package/dist/app/StartupStatusCardModel.d.ts +22 -0
  23. package/dist/app/TemporaryFullscreenController.d.ts +9 -0
  24. package/dist/app/TerminalColorLevel.d.ts +1 -0
  25. package/dist/app/TerminalOutputTrace.d.ts +12 -0
  26. package/dist/app/TerminalTheme.d.ts +11 -0
  27. package/dist/app/TranscriptEntryRenderCache.d.ts +10 -0
  28. package/dist/app/applyWorkflowRunUpdate.d.ts +2 -0
  29. package/dist/app/blendComposerBackground.d.ts +2 -0
  30. package/dist/app/boundedJsonStringify.d.ts +1 -0
  31. package/dist/app/calculateCacheHitPercent.d.ts +2 -0
  32. package/dist/app/codexDiffAnsi.d.ts +17 -0
  33. package/dist/app/compactCompletedTurnEntries.d.ts +2 -0
  34. package/dist/app/containsMarkdownTable.d.ts +1 -0
  35. package/dist/app/createAgentMarkdownTheme.d.ts +3 -0
  36. package/dist/app/createBackgroundTerminalViewer.d.ts +16 -0
  37. package/dist/app/createCompletedTurn.d.ts +6 -0
  38. package/dist/app/createEditorTheme.d.ts +3 -0
  39. package/dist/app/createFileMentionAutocompleteItems.d.ts +3 -0
  40. package/dist/app/createSecretInputPanel.d.ts +12 -0
  41. package/dist/app/createSelectionPanel.d.ts +14 -0
  42. package/dist/app/createSerialTaskQueue.d.ts +1 -0
  43. package/dist/app/createSessionPicker.d.ts +17 -0
  44. package/dist/app/createSlashCommands.d.ts +7 -0
  45. package/dist/app/createStopOnceHandler.d.ts +1 -0
  46. package/dist/app/createSubagentMonitor.d.ts +17 -0
  47. package/dist/app/createTerminalInputBurstHandler.d.ts +5 -0
  48. package/dist/app/createWorkflowMonitor.d.ts +15 -0
  49. package/dist/app/defaultTerminalTheme.d.ts +1 -0
  50. package/dist/app/describeModelChoice.d.ts +4 -0
  51. package/dist/app/describeProviderSignIn.d.ts +2 -0
  52. package/dist/app/describeReasoningLevel.d.ts +4 -0
  53. package/dist/app/detectCodexDiffLanguage.d.ts +1 -0
  54. package/dist/app/encodeModelChoice.d.ts +1 -0
  55. package/dist/app/endsAfterOpeningCodeFence.d.ts +1 -0
  56. package/dist/app/findFileMentionContext.d.ts +9 -0
  57. package/dist/app/findFileMentionPrefix.d.ts +5 -0
  58. package/dist/app/formatActivityElapsedTime.d.ts +1 -0
  59. package/dist/app/formatCodexMcpToolResult.d.ts +3 -0
  60. package/dist/app/formatCompactTokens.d.ts +1 -0
  61. package/dist/app/formatFileMention.d.ts +1 -0
  62. package/dist/app/formatProviderError.d.ts +6 -0
  63. package/dist/app/formatRelativeTime.d.ts +2 -0
  64. package/dist/app/formatResetDuration.d.ts +1 -0
  65. package/dist/app/formatSessionPickerEntry.d.ts +14 -0
  66. package/dist/app/formatSessionTokenStatus.d.ts +6 -0
  67. package/dist/app/formatSessionUsageSummary.d.ts +3 -0
  68. package/dist/app/formatStartupStatusUsageRemaining.d.ts +2 -0
  69. package/dist/app/formatStartupStatusUsageRows.d.ts +2 -0
  70. package/dist/app/formatSubagentToolCall.d.ts +10 -0
  71. package/dist/app/formatToolPermissionNotice.d.ts +3 -0
  72. package/dist/app/formatToolResultForDisplay.d.ts +2 -0
  73. package/dist/app/formatTurnUsageSummary.d.ts +2 -0
  74. package/dist/app/formatWorkUsageSummary.d.ts +14 -0
  75. package/dist/app/highlightAgentCode.d.ts +1 -0
  76. package/dist/app/highlightCodexDiffLine.d.ts +2 -0
  77. package/dist/app/highlightShellCommand.d.ts +1 -0
  78. package/dist/app/humanizeGoalStatus.d.ts +2 -0
  79. package/dist/app/humanizeMcpName.d.ts +1 -0
  80. package/dist/app/humanizePermissionMode.d.ts +2 -0
  81. package/dist/app/humanizePermissionReviewLevel.d.ts +2 -0
  82. package/dist/app/humanizeProviderId.d.ts +1 -0
  83. package/dist/app/humanizeReasoningLevel.d.ts +1 -0
  84. package/dist/app/humanizeSubagentStatus.d.ts +2 -0
  85. package/dist/app/humanizeToolName.d.ts +1 -0
  86. package/dist/app/humanizeWorkflowStatus.d.ts +2 -0
  87. package/dist/app/installResumeInstructions.d.ts +26 -0
  88. package/dist/app/installTerminalCrashCleanup.d.ts +26 -0
  89. package/dist/app/isLightTerminalBackground.d.ts +2 -0
  90. package/dist/app/layoutCodexFileDiff.d.ts +13 -0
  91. package/dist/app/looksLikeAuthenticationFailure.d.ts +5 -0
  92. package/dist/app/nearestXtermColorIndex.d.ts +2 -0
  93. package/dist/app/parseCodexMcpToolInvocation.d.ts +2 -0
  94. package/dist/app/parseSessionCommand.d.ts +6 -0
  95. package/dist/app/providerErrorResetAt.d.ts +2 -0
  96. package/dist/app/providerQuotaToStartupStatusUsage.d.ts +3 -0
  97. package/dist/app/readClipboardImage.d.ts +9 -0
  98. package/dist/app/renderActivityWave.d.ts +3 -0
  99. package/dist/app/renderAgentMarkdown.d.ts +8 -0
  100. package/dist/app/renderBackgroundTerminalCompletion.d.ts +1 -0
  101. package/dist/app/renderBackgroundTerminalInteraction.d.ts +2 -0
  102. package/dist/app/renderBackgroundTerminalSummary.d.ts +1 -0
  103. package/dist/app/renderChildRows.d.ts +13 -0
  104. package/dist/app/renderCodexDiffLine.d.ts +3 -0
  105. package/dist/app/renderCodexFileDiff.d.ts +7 -0
  106. package/dist/app/renderCodexMcpToolCall.d.ts +2 -0
  107. package/dist/app/renderCompletedTurnStats.d.ts +2 -0
  108. package/dist/app/renderExecCommand.d.ts +11 -0
  109. package/dist/app/renderExploration.d.ts +9 -0
  110. package/dist/app/renderFullscreenComponent.d.ts +8 -0
  111. package/dist/app/renderHappyTerminalBanner.d.ts +6 -0
  112. package/dist/app/renderHappyTerminalVersion.d.ts +1 -0
  113. package/dist/app/renderNoticeWithChildren.d.ts +7 -0
  114. package/dist/app/renderPendingSteeringMessages.d.ts +1 -0
  115. package/dist/app/renderStartupStatusCard.d.ts +7 -0
  116. package/dist/app/renderSubagentSummary.d.ts +6 -0
  117. package/dist/app/renderTurnCompletionSeparator.d.ts +1 -0
  118. package/dist/app/renderWorkflowSummary.d.ts +1 -0
  119. package/dist/app/resolveInputBackground.d.ts +3 -0
  120. package/dist/app/resolveStartupProviderQuota.d.ts +3 -0
  121. package/dist/app/resolveStartupSessionId.d.ts +18 -0
  122. package/dist/app/resolveTerminalColorLevel.d.ts +2 -0
  123. package/dist/app/resolveTerminalStyle.d.ts +1 -0
  124. package/dist/app/resolveTerminalTheme.d.ts +5 -0
  125. package/dist/app/runApp.d.ts +27 -0
  126. package/dist/app/runClipboardCommand.d.ts +8 -0
  127. package/dist/app/sanitizeTerminalText.d.ts +1 -0
  128. package/dist/app/shortenHomePath.d.ts +2 -0
  129. package/dist/app/sortSubagentsForDisplay.d.ts +2 -0
  130. package/dist/app/subagentElapsedMs.d.ts +2 -0
  131. package/dist/app/subagentLogMessageText.d.ts +2 -0
  132. package/dist/app/surfaceThemedLine.d.ts +3 -0
  133. package/dist/app/truncatePathToWidth.d.ts +1 -0
  134. package/dist/app/truncateTextForDisplay.d.ts +5 -0
  135. package/dist/app/truncateUtf8BytesForDisplay.d.ts +1 -0
  136. package/dist/app/upsertSubagentSummary.d.ts +2 -0
  137. package/dist/app/workflowDisplay.d.ts +2 -0
  138. package/dist/client/HappyAgentEventHub.d.ts +25 -0
  139. package/dist/client/RemoteAgent.d.ts +74 -0
  140. package/dist/client/RemoteAgentRunError.d.ts +4 -0
  141. package/dist/client/RemoteTerminalAttachment.d.ts +19 -0
  142. package/dist/client/RemoteTerminalClientReplica.d.ts +14 -0
  143. package/dist/client/ensureLocalProtocolServer.d.ts +10 -0
  144. package/dist/client/fetchProviderQuotas.d.ts +10 -0
  145. package/dist/client/index.d.ts +8 -0
  146. package/dist/client/loadAgentCatalog.d.ts +32 -0
  147. package/dist/config/createProjectConfigSecurityNotice.d.ts +10 -0
  148. package/dist/config/defaultConfig.d.ts +2 -0
  149. package/dist/config/getDefaultGlobalConfigPath.d.ts +1 -0
  150. package/dist/config/getDefaultLocalConfigPath.d.ts +1 -0
  151. package/dist/config/getDefaultRuntimeConfigPath.d.ts +1 -0
  152. package/dist/config/getHappyConfigDirectory.d.ts +1 -0
  153. package/dist/config/getHappyTerminalHome.d.ts +1 -0
  154. package/dist/config/index.d.ts +15 -0
  155. package/dist/config/loadConfig.d.ts +2 -0
  156. package/dist/config/mergeConfigValues.d.ts +2 -0
  157. package/dist/config/parseConfigToml.d.ts +7 -0
  158. package/dist/config/readConfigFile.d.ts +2 -0
  159. package/dist/config/readProjectConfigFile.d.ts +2 -0
  160. package/dist/config/resolveConfigPaths.d.ts +2 -0
  161. package/dist/config/runtimeConfigLock.d.ts +1 -0
  162. package/dist/config/types.d.ts +74 -0
  163. package/dist/config/updateRuntimeConfig.d.ts +2 -0
  164. package/dist/config/updateRuntimePreferences.d.ts +2 -0
  165. package/dist/config/withoutProjectMachineSettings.d.ts +7 -0
  166. package/dist/config/writeRuntimeConfig.d.ts +3 -0
  167. package/dist/config/writeRuntimeConfigDefaults.d.ts +2 -0
  168. package/dist/daemon/createUnixSocketFetch.d.ts +2 -0
  169. package/dist/daemon/daemonPid.d.ts +11 -0
  170. package/dist/daemon/ensureHappyAgentBinary.d.ts +15 -0
  171. package/dist/daemon/ensureLocalProtocolServer.d.ts +24 -0
  172. package/dist/daemon/getHappyDaemonPaths.d.ts +16 -0
  173. package/dist/daemon/happyAgentBinaryConfig.d.ts +15 -0
  174. package/dist/daemon/index.d.ts +5 -0
  175. package/dist/daemon/runDaemonCommand.d.ts +4 -0
  176. package/dist/debug/DebugLog.d.ts +11 -0
  177. package/dist/debug/closeNodeInspector.d.ts +1 -0
  178. package/dist/debug/createDebugJsonReplacer.d.ts +1 -0
  179. package/dist/debug/createRequestDebugDirectory.d.ts +1 -0
  180. package/dist/debug/getDebugRootDirectory.d.ts +1 -0
  181. package/dist/debug/getNodeInspectorUrl.d.ts +1 -0
  182. package/dist/debug/index.d.ts +8 -0
  183. package/dist/debug/openNodeInspector.d.ts +1 -0
  184. package/dist/debug/registerHappyTerminalDebugRoot.d.ts +5 -0
  185. package/dist/docs/DESIGN.md +2191 -0
  186. package/dist/docs/README.md +93 -0
  187. package/dist/docs/agents-and-collaboration.md +365 -0
  188. package/dist/docs/architecture.md +468 -0
  189. package/dist/docs/extending.md +561 -0
  190. package/dist/docs/happy.md +386 -0
  191. package/dist/docs/permissions-and-sandbox.md +342 -0
  192. package/dist/docs/workspaces.md +281 -0
  193. package/dist/errorToMessage.d.ts +1 -0
  194. package/dist/formatCliFailure.d.ts +10 -0
  195. package/dist/index.d.ts +3 -0
  196. package/dist/index.js +17151 -0
  197. package/dist/main.js +18946 -0
  198. package/dist/observability/daemonContext.d.ts +16 -0
  199. package/dist/observability/index.d.ts +1 -0
  200. package/dist/processes/BoundedOutputBuffer.d.ts +20 -0
  201. package/dist/processes/NativeProcessManager.d.ts +66 -0
  202. package/dist/processes/ProcessGroupReaper.d.ts +32 -0
  203. package/dist/processes/index.d.ts +7 -0
  204. package/dist/processes/isProcessRunning.d.ts +1 -0
  205. package/dist/processes/isTargetProcessAlive.d.ts +1 -0
  206. package/dist/processes/killProcessTree.d.ts +2 -0
  207. package/dist/processes/resolveSystemShell.d.ts +1 -0
  208. package/dist/processes/startProcessTransport.d.ts +33 -0
  209. package/dist/processes/types.d.ts +41 -0
  210. package/dist/processes/waitForProcessExit.d.ts +2 -0
  211. package/dist/protocol/AppletProtocol.d.ts +101 -0
  212. package/dist/protocol/Attachment.d.ts +96 -0
  213. package/dist/protocol/ClientProtocolTypes.d.ts +481 -0
  214. package/dist/protocol/DocumentProtocol.d.ts +109 -0
  215. package/dist/protocol/EventId.d.ts +1 -0
  216. package/dist/protocol/FolderProtocol.d.ts +236 -0
  217. package/dist/protocol/FolderSharingProtocol.d.ts +97 -0
  218. package/dist/protocol/GitHubPluginProtocol.d.ts +43 -0
  219. package/dist/protocol/GlobalSecurityProtocol.d.ts +7 -0
  220. package/dist/protocol/HappyCloudProtocol.d.ts +178 -0
  221. package/dist/protocol/InstallationProtocol.d.ts +80 -0
  222. package/dist/protocol/OnboardingProtocol.d.ts +47 -0
  223. package/dist/protocol/P2pCredentialProtocol.d.ts +273 -0
  224. package/dist/protocol/P2pIdentityProtocol.d.ts +8 -0
  225. package/dist/protocol/P2pPairingProtocol.d.ts +68 -0
  226. package/dist/protocol/P2pProtocol.d.ts +185 -0
  227. package/dist/protocol/PluginWireTypes.d.ts +81 -0
  228. package/dist/protocol/ProfileProtocol.d.ts +127 -0
  229. package/dist/protocol/ProjectFileProtocol.d.ts +63 -0
  230. package/dist/protocol/ProjectProtocol.d.ts +646 -0
  231. package/dist/protocol/ProtocolVersion.d.ts +8 -0
  232. package/dist/protocol/ServiceNotice.d.ts +175 -0
  233. package/dist/protocol/SessionProtocol.d.ts +1156 -0
  234. package/dist/protocol/SharingProtocol.d.ts +159 -0
  235. package/dist/protocol/SlotProtocol.d.ts +270 -0
  236. package/dist/protocol/TimelineProtocol.d.ts +88 -0
  237. package/dist/protocol/WorkletProtocol.d.ts +159 -0
  238. package/dist/protocol/createEventIdFactory.d.ts +7 -0
  239. package/dist/protocol/index.d.ts +34 -0
  240. package/dist/readPackageVersion.d.ts +1 -0
  241. package/dist/readPackageVersion.js +16 -0
  242. package/dist/reportCliFailure.d.ts +2 -0
  243. package/dist/runHappyTerminal.d.ts +6 -0
  244. package/dist/terminal/index.d.ts +2 -0
  245. package/dist/terminal/types.d.ts +39 -0
  246. package/dist/types.d.ts +6 -0
  247. package/dist/writeStderrSync.d.ts +5 -0
  248. package/package.json +97 -0
@@ -0,0 +1,1156 @@
1
+ import { type Static } from "@sinclair/typebox";
2
+ import type { AgentCompactionResult, AgentLoopEvent, AgentSnapshot, ContentBlock, AgentMessage, BashSessionActivity, BashSessionSnapshot, ChangeGoalStatusRequest, CreateGoalRequest, DockerExecutionConfig, DurableSkillDefinition, EnvironmentSecretRegistration, EnvironmentSecretUpdate, ExternalToolCall, ExternalToolCallResolution, ExternalToolDefinition, McpServerSummary, Message, Model, PermissionMode, ProviderError, ResolveExternalToolCallResponse, ScheduledMessage, SecretAttachmentScope, SecretReference, ServiceTier, SessionExecutionEnvironment, SessionGoal, SessionTask, StopReason, SystemMessage, Usage, UserInputRequest, UserInputResponse, UserMessage, WorkflowRun, WorkflowRunUpdate } from "./ClientProtocolTypes.js";
3
+ import type { Attachment } from "./Attachment.js";
4
+ import { type SessionEvent as ProviderSessionEvent, type ProviderModelCompatibilityType, type ProviderQuota, type ProviderUsage } from "@slopus/happy-providers";
5
+ import type { EventId } from "./EventId.js";
6
+ import type { GitChangeSnapshot, PresenceSnapshot } from "./ProjectProtocol.js";
7
+ export type SessionStatus = "idle" | "queued" | "running" | "completed" | "aborted" | "suspended" | "error" | "archived";
8
+ export type SessionSummaryStatus = SessionStatus;
9
+ /**
10
+ * The one collection a visible primary chat belongs to.
11
+ *
12
+ * Replacing this tagged value moves a chat atomically, so a delayed partial update cannot leave it
13
+ * visible in two different trees.
14
+ */
15
+ export declare const sessionScopeSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
16
+ kind: import("@sinclair/typebox").TLiteral<"project">;
17
+ projectId: import("@sinclair/typebox").TString;
18
+ }>, import("@sinclair/typebox").TObject<{
19
+ kind: import("@sinclair/typebox").TLiteral<"workspace">;
20
+ projectId: import("@sinclair/typebox").TString;
21
+ workspaceId: import("@sinclair/typebox").TString;
22
+ }>, import("@sinclair/typebox").TObject<{
23
+ folderId: import("@sinclair/typebox").TString;
24
+ kind: import("@sinclair/typebox").TLiteral<"folder">;
25
+ }>, import("@sinclair/typebox").TObject<{
26
+ kind: import("@sinclair/typebox").TLiteral<"unsorted">;
27
+ }>]>;
28
+ export type SessionScope = Static<typeof sessionScopeSchema>;
29
+ /** Moves a visible chat within the folder tree, or back into Unsorted. */
30
+ export declare const moveSessionRequestSchema: import("@sinclair/typebox").TObject<{
31
+ afterId: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>;
32
+ mutationId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
33
+ scope: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
34
+ folderId: import("@sinclair/typebox").TString;
35
+ kind: import("@sinclair/typebox").TLiteral<"folder">;
36
+ }>, import("@sinclair/typebox").TObject<{
37
+ kind: import("@sinclair/typebox").TLiteral<"unsorted">;
38
+ }>]>;
39
+ }>;
40
+ export type MoveSessionRequest = Static<typeof moveSessionRequestSchema>;
41
+ /**
42
+ * What a session is doing at this moment.
43
+ *
44
+ * `SessionStatus` answers whether a session is busy; this answers what the busy
45
+ * work is, so a client can render a status line without replaying the event log
46
+ * and tracking which streaming blocks are still open.
47
+ */
48
+ export type SessionActivityKind = "idle" | "queued" | "thinking" | "generating_message" | "generating_tool_call" | "reviewing_tool_call" | "executing_tool_call" | "waiting" | "awaiting_input" | "compacting" | "retrying" | "stopped" | "error";
49
+ export interface SessionActivityToolCall {
50
+ startedAt: number;
51
+ /** Latest short label the tool reported about its own progress. */
52
+ status?: string;
53
+ toolCallId: string;
54
+ toolName: string;
55
+ }
56
+ export interface SessionActivityPermissionReview {
57
+ action: string;
58
+ startedAt: number;
59
+ toolCallId: string;
60
+ toolName: string;
61
+ }
62
+ export interface SessionActivityCompaction {
63
+ compactionId: string;
64
+ estimatedTokensBefore: number;
65
+ reason: "context_window" | "manual" | "threshold";
66
+ startedAt: number;
67
+ }
68
+ export interface SessionActivityRetry {
69
+ attempt: number;
70
+ reason: string;
71
+ }
72
+ export interface SessionActivityWait {
73
+ dueAt: number;
74
+ startedAt: number;
75
+ toolCallId: string;
76
+ }
77
+ export interface SessionActivity {
78
+ /** Ready-to-display description of the current work, such as `Running Bash`. */
79
+ label: string;
80
+ kind: SessionActivityKind;
81
+ runId?: string;
82
+ /** When the session entered this activity, in milliseconds since the epoch. */
83
+ since: number;
84
+ compaction?: SessionActivityCompaction;
85
+ /** Requests the session is blocked on, including permission approvals. */
86
+ pendingInputRequestIds?: readonly string[];
87
+ retry?: SessionActivityRetry;
88
+ /** Tool calls whose requested action is currently being reviewed in Auto. */
89
+ reviewingToolCalls?: readonly SessionActivityPermissionReview[];
90
+ wait?: SessionActivityWait;
91
+ /** Tool calls that have started and not yet reported a result. */
92
+ toolCalls?: readonly SessionActivityToolCall[];
93
+ }
94
+ export type SessionUnreadReason = "attention_needed" | "turn_finished";
95
+ export interface SessionUnreadState {
96
+ reason: SessionUnreadReason;
97
+ since: number;
98
+ }
99
+ export type SessionTitleStatus = "idle" | "generating" | "ready" | "error";
100
+ export type { SessionExecutionEnvironment } from "./ClientProtocolTypes.js";
101
+ export type SessionInterruptionReason = "crash" | "shutdown";
102
+ export type SessionAgentType = "primary" | "subagent";
103
+ export interface SessionAgentMetadata {
104
+ depth: number;
105
+ rootSessionId: string;
106
+ type: SessionAgentType;
107
+ description?: string;
108
+ parentSessionId?: string;
109
+ parentToolCallId?: string;
110
+ taskName?: string;
111
+ /**
112
+ * The session that started this visible conversation on the user's behalf. Unlike a subagent
113
+ * parent, a delegator does not own the session: the conversation keeps its own place in the
114
+ * session list, and the user may take it over at any time.
115
+ */
116
+ delegatedBySessionId?: string;
117
+ }
118
+ export interface SessionInterruption {
119
+ interruptedAt: number;
120
+ message: string;
121
+ reason: SessionInterruptionReason;
122
+ runId?: string;
123
+ }
124
+ export declare const providerCredentialProvenanceSchema: import("@sinclair/typebox").TObject<{
125
+ bindingId: import("@sinclair/typebox").TString;
126
+ ownerInstanceId: import("@sinclair/typebox").TString;
127
+ ownerName: import("@sinclair/typebox").TString;
128
+ relation: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"owner">, import("@sinclair/typebox").TLiteral<"extra">]>;
129
+ sourceProviderId: import("@sinclair/typebox").TString;
130
+ visibility: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"owner_only">, import("@sinclair/typebox").TLiteral<"shared">]>;
131
+ }>;
132
+ export type ProviderCredentialProvenance = Static<typeof providerCredentialProvenanceSchema>;
133
+ export interface ProviderModelCatalog {
134
+ /**
135
+ * The credential source that makes this provider available in the current
136
+ * session. It is absent for daemon-wide catalogs that have no owner scope.
137
+ */
138
+ credential?: ProviderCredentialProvenance;
139
+ disabledReason?: "not_authenticated" | "not_enabled" | "no_models";
140
+ providerId: string;
141
+ providerType?: ProviderModelCompatibilityType;
142
+ models: readonly Model[];
143
+ serviceTiers?: readonly ServiceTier[];
144
+ /** Human-readable provider source label for owner-scoped catalogs. */
145
+ title?: string;
146
+ }
147
+ export interface ModelCatalog {
148
+ defaultModelId: string;
149
+ defaultProviderId: string;
150
+ models: readonly Model[];
151
+ providers: readonly ProviderModelCatalog[];
152
+ }
153
+ export interface DaemonIdentity {
154
+ version: string;
155
+ }
156
+ export interface ReadyHealthResponse {
157
+ catalog: ModelCatalog;
158
+ durableGlobalEventQueue: boolean;
159
+ healthy: true;
160
+ identity: DaemonIdentity;
161
+ protocolVersion: number;
162
+ ready: true;
163
+ status: "ready";
164
+ }
165
+ export interface StartingHealthResponse {
166
+ healthy: true;
167
+ identity: DaemonIdentity;
168
+ protocolVersion: number;
169
+ ready: false;
170
+ status: "starting";
171
+ }
172
+ export interface ErrorHealthResponse {
173
+ error: string;
174
+ healthy: false;
175
+ identity: DaemonIdentity;
176
+ protocolVersion: number;
177
+ ready: false;
178
+ status: "error";
179
+ }
180
+ export type HealthResponse = ErrorHealthResponse | ReadyHealthResponse | StartingHealthResponse;
181
+ export interface ListModelsResponse {
182
+ catalog: ModelCatalog;
183
+ }
184
+ export interface DaemonConfig {
185
+ p2p: {
186
+ name: string;
187
+ primaryId?: string;
188
+ role: "primary" | "secondary";
189
+ };
190
+ settings: {
191
+ inferenceMaxRetries: number;
192
+ durableGlobalEventQueue: boolean;
193
+ };
194
+ }
195
+ export interface GetDaemonConfigResponse {
196
+ config: DaemonConfig;
197
+ }
198
+ export declare const updateDaemonConfigRequestSchema: import("@sinclair/typebox").TObject<{
199
+ p2p: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
200
+ name: import("@sinclair/typebox").TString;
201
+ }>>;
202
+ settings: import("@sinclair/typebox").TObject<{
203
+ inferenceMaxRetries: import("@sinclair/typebox").TInteger;
204
+ durableGlobalEventQueue: import("@sinclair/typebox").TBoolean;
205
+ }>;
206
+ }>;
207
+ export type UpdateDaemonConfigRequest = Static<typeof updateDaemonConfigRequestSchema>;
208
+ export type UpdateDaemonConfigResponse = GetDaemonConfigResponse;
209
+ /**
210
+ * The user's global AGENTS.md. Every session reads it again before each turn, so a change made
211
+ * here reaches open sessions too. Empty text means the user has no global instructions.
212
+ */
213
+ export interface GetGlobalInstructionsResponse {
214
+ instructions: string;
215
+ }
216
+ export interface UpdateGlobalInstructionsRequest {
217
+ instructions: string;
218
+ }
219
+ export type UpdateGlobalInstructionsResponse = GetGlobalInstructionsResponse;
220
+ export interface PendingSteeringMessage {
221
+ createdAt: number;
222
+ message: UserMessage;
223
+ runId: string;
224
+ }
225
+ /** The turn currently occupying the session, timed from its original submission. */
226
+ export interface SessionActiveTurn {
227
+ runId: string;
228
+ startedAt: number;
229
+ /** Present for a standalone manual context compaction turn. */
230
+ kind?: "compaction";
231
+ }
232
+ export interface SessionPermissionReview {
233
+ action: string;
234
+ decision: "allow" | "deny";
235
+ fullAccessGranted?: true;
236
+ reason: string;
237
+ risk: "low" | "medium" | "high" | "critical";
238
+ toolCallId: string;
239
+ userAuthorization: "unknown" | "low" | "medium" | "high";
240
+ }
241
+ export interface ProtocolSession {
242
+ id: string;
243
+ /** What the session is doing at this moment. */
244
+ activity: SessionActivity;
245
+ activeTurn?: SessionActiveTurn;
246
+ agentId: string;
247
+ /** Stable Happy Terminal identity whose credentials and usage this session consumes. */
248
+ ownerInstanceId: string;
249
+ /** Human profile whose Git identity this session uses. */
250
+ profileId?: string;
251
+ /** Git state of the session's directory, when it is inside a repository. */
252
+ git?: GitChangeSnapshot;
253
+ archived: boolean;
254
+ /** The only project, workspace, folder, or Unsorted collection containing this chat. */
255
+ scope: SessionScope;
256
+ /** Present exactly when `scope` names a project or workspace. */
257
+ projectId?: string;
258
+ /** Present exactly when `scope` names a workspace. */
259
+ workspaceId?: string;
260
+ /** Present exactly when `scope` names a folder. */
261
+ folderId?: string;
262
+ trackUnread?: boolean;
263
+ unread?: SessionUnreadState;
264
+ appendSystemPrompt?: string;
265
+ cwd: string;
266
+ draft?: string;
267
+ draftUpdatedAt?: number;
268
+ providerId: string;
269
+ permissionMode: PermissionMode;
270
+ modelId: string;
271
+ /** Absent for a session with no place in an ordered list, such as a subagent. */
272
+ orderKey?: string;
273
+ effort?: string;
274
+ serviceTier?: ServiceTier;
275
+ secretIds: readonly string[];
276
+ projectSecretIds: readonly string[];
277
+ sessionSecretIds: readonly string[];
278
+ environment?: SessionExecutionEnvironment;
279
+ modelLocked: boolean;
280
+ /** The owner-scoped provider catalog used to validate and run this session. */
281
+ modelCatalog: ModelCatalog;
282
+ models: readonly Model[];
283
+ status: SessionStatus;
284
+ title?: string;
285
+ titleError?: string;
286
+ titleStatus: SessionTitleStatus;
287
+ recap?: string;
288
+ metadataUpdatedAt?: number;
289
+ metadataRunId?: string;
290
+ interruption?: SessionInterruption;
291
+ lastEventId?: EventId;
292
+ agent: SessionAgentMetadata;
293
+ snapshot: AgentSnapshot;
294
+ pendingUserInputs: readonly UserInputRequest[];
295
+ permissionReviews?: readonly SessionPermissionReview[];
296
+ pendingSteeringMessages?: readonly PendingSteeringMessage[];
297
+ subagents?: readonly SubagentSummary[];
298
+ shellCommands?: readonly ShellCommandState[];
299
+ mcpServers: readonly McpServerSummary[];
300
+ tasks: readonly SessionTask[];
301
+ workflowsEnabled?: boolean;
302
+ workflows?: readonly WorkflowRun[];
303
+ goal?: SessionGoal;
304
+ backgroundProcesses?: readonly BashSessionActivity[];
305
+ cumulativeUsage?: Usage;
306
+ externalTools?: readonly ExternalToolDefinition[];
307
+ skills?: readonly DurableSkillDefinition[];
308
+ pendingExternalToolCalls?: readonly ExternalToolCall[];
309
+ scheduledMessages?: readonly ScheduledMessage[];
310
+ systemPrompt?: string;
311
+ }
312
+ /**
313
+ * An assistant message the model is still producing.
314
+ *
315
+ * Committed transcripts never contain it, so without this a client that attaches
316
+ * mid-turn shows nothing until the message completes.
317
+ */
318
+ export interface SessionPartialMessage {
319
+ message: AgentMessage;
320
+ runId: string;
321
+ }
322
+ /**
323
+ * One turn of the transcript carried in a stream's opening frame.
324
+ *
325
+ * The messages alone do not say where a turn began, how it ended, or how long it
326
+ * took, so a client given only messages has to guess. This states it, which is
327
+ * what lets a client honour the guarantee that every turn ends in a final
328
+ * element even for history it never watched happen.
329
+ */
330
+ export interface SessionTranscriptTurn {
331
+ /** Identifies the run, and is the turn identity a client renders against. */
332
+ runId: string;
333
+ /** Present for a standalone manual context compaction turn. */
334
+ kind?: "compaction";
335
+ /** Messages belonging to this turn, in order, by id. */
336
+ messageIds: readonly string[];
337
+ startedAt: number;
338
+ /** Absent while the turn is still running. */
339
+ endedAt?: number;
340
+ /** Absent while the turn is still running. */
341
+ outcome?: "success" | "error" | "stopped";
342
+ errorMessage?: string;
343
+ /** Inference segments inside this run, in start order. */
344
+ groups?: readonly SessionTranscriptGroup[];
345
+ }
346
+ export interface SessionTranscriptGroup {
347
+ /** The assistant message identity allocated before the first output token. */
348
+ id: string;
349
+ startedAt: number;
350
+ endedAt?: number;
351
+ outcome?: "success" | "error" | "stopped";
352
+ reason?: "completed" | "steering" | "compaction" | "abort" | "error";
353
+ errorMessage?: string;
354
+ }
355
+ /** A durable service row ordered independently from conversational turns. */
356
+ export interface SessionTranscriptNotice {
357
+ createdAt: number;
358
+ eventId: EventId;
359
+ message: SystemMessage;
360
+ }
361
+ /**
362
+ * The transcript window carried in a stream's opening frame.
363
+ *
364
+ * The window is measured in whole turns, never in messages. A turn is the unit a
365
+ * conversation is read in, and half a turn is not a smaller answer but a broken
366
+ * one: a tool result whose call was cut away renders as an orphan.
367
+ */
368
+ export interface SessionTranscriptWindow {
369
+ messages: readonly Message[];
370
+ /** Durable occurrence time of each retained message, keyed by message ID. */
371
+ messageCreatedAt?: Readonly<Record<string, number>>;
372
+ /** Durable event order for messages sharing the same millisecond. */
373
+ messageEventId?: Readonly<Record<string, EventId>>;
374
+ /** When each steering message was actually applied to its run. */
375
+ messageSteeredAt?: Readonly<Record<string, number>>;
376
+ /**
377
+ * The group each boundary message closed, keyed by message ID.
378
+ *
379
+ * A steering message and a compaction both head the group that follows the
380
+ * one they closed. Which that was cannot be read from the clock, because a
381
+ * boundary and the group it opens routinely share a millisecond.
382
+ */
383
+ messageBoundaryGroupId?: Readonly<Record<string, string>>;
384
+ /** The inference group each durable error occurred in, keyed by message ID. */
385
+ messageGroupId?: Readonly<Record<string, string>>;
386
+ notices?: readonly SessionTranscriptNotice[];
387
+ /** True when this bounded window omitted older service notices in its position range. */
388
+ noticesTruncated?: boolean;
389
+ /** Resolved permission facts for tool calls contained in this page. */
390
+ permissionReviews?: readonly SessionPermissionReview[];
391
+ turns: readonly SessionTranscriptTurn[];
392
+ /** False when the conversation began before the first turn in this window. */
393
+ complete: boolean;
394
+ }
395
+ /**
396
+ * The first frame of a session event stream.
397
+ *
398
+ * It exists so attaching is a single request. A client connecting without a
399
+ * cursor gets the session here and never issues a follow-up call; a client
400
+ * resuming already has the transcript and gets back only the state that cannot
401
+ * be replayed from the durable log.
402
+ */
403
+ export interface SessionStreamHello {
404
+ activity: SessionActivity;
405
+ /**
406
+ * Current facts whose intermediate events are intentionally not retained.
407
+ * Present on resume after durable catch-up has been delivered.
408
+ */
409
+ current?: SessionStreamCurrentState;
410
+ /** Complete session usage at the hello cursor; later durable events update it. */
411
+ usage?: GetSessionUsageResponse;
412
+ /**
413
+ * Present only when the client attached without a cursor. Its transcript
414
+ * holds the most recent `SESSION_STREAM_TURN_LIMIT` complete turns, so the
415
+ * cost of attaching is bounded by recent activity rather than by the age of
416
+ * the session.
417
+ */
418
+ session?: ProtocolSession;
419
+ /** Turn boundaries and outcomes for the transcript in `session`. */
420
+ transcript?: SessionTranscriptWindow;
421
+ /** The assistant message currently being generated, when a run is mid-message. */
422
+ partial?: SessionPartialMessage;
423
+ /** The newest event id at the moment the stream opened. */
424
+ lastEventId?: EventId;
425
+ /** True when the client attached with a cursor and is resuming. */
426
+ resumed: boolean;
427
+ }
428
+ /**
429
+ * A session bootstrapped by request-response rather than by opening a stream.
430
+ *
431
+ * `cursor` is the position in the global live stream that this payload reflects,
432
+ * so a client can replay everything after it and know exactly what the snapshot
433
+ * already contains.
434
+ */
435
+ export interface SessionStateResponse extends SessionStreamHello {
436
+ /**
437
+ * The transcript continues what the client holds rather than replacing it.
438
+ *
439
+ * Set only when the client asked to catch up from a message it already has
440
+ * and the daemon could still page forward from there.
441
+ */
442
+ append?: boolean;
443
+ cursor: EventId;
444
+ }
445
+ export interface SessionStreamCurrentState {
446
+ draft?: string;
447
+ draftUpdatedAt?: number;
448
+ externalTools?: readonly ExternalToolDefinition[];
449
+ git?: GitChangeSnapshot;
450
+ interruption?: SessionInterruption;
451
+ mcpServers: readonly McpServerSummary[];
452
+ pendingExternalToolCalls?: readonly ExternalToolCall[];
453
+ projectSecretIds?: readonly string[];
454
+ secretIds?: readonly string[];
455
+ sessionSecretIds?: readonly string[];
456
+ skills?: readonly DurableSkillDefinition[];
457
+ scheduledMessages?: readonly ScheduledMessage[];
458
+ titleError?: string;
459
+ titleStatus?: SessionTitleStatus;
460
+ workflows?: readonly WorkflowRun[];
461
+ workflowsEnabled?: boolean;
462
+ }
463
+ /**
464
+ * How many recent turns the stream's opening frame carries.
465
+ *
466
+ * A turn is delivered whole or not at all, so this bounds the window without
467
+ * ever splitting one. The number of messages behind it varies: a turn may be a
468
+ * single reply or a long run of tool calls, and both arrive intact.
469
+ *
470
+ * The snapshot already reflects every event up to `lastEventId`, so a client
471
+ * that attaches without a cursor receives this window and nothing else; the
472
+ * event log is never replayed on top of it.
473
+ */
474
+ export declare const SESSION_STREAM_TURN_LIMIT = 20;
475
+ /** Service rows are bounded separately and never consume the conversational turn budget. */
476
+ export declare const SESSION_TRANSCRIPT_NOTICE_LIMIT = 50;
477
+ export interface SubagentSummary {
478
+ activeSince?: number;
479
+ agentId: string;
480
+ createdAt: number;
481
+ depth: number;
482
+ description: string;
483
+ elapsedMs?: number;
484
+ id: string;
485
+ latestText?: string;
486
+ modelId: string;
487
+ parentSessionId: string;
488
+ parentToolCallId?: string;
489
+ prompt?: string;
490
+ status: SessionStatus;
491
+ taskName?: string;
492
+ totalTokens?: number;
493
+ updatedAt: number;
494
+ usage?: Usage;
495
+ }
496
+ export interface SessionSummary {
497
+ id: string;
498
+ /** Stable Happy Terminal identity whose credentials and usage this session consumes. */
499
+ ownerInstanceId: string;
500
+ /** Human profile whose Git identity this session uses. */
501
+ profileId?: string;
502
+ archived: boolean;
503
+ /** The only project, workspace, folder, or Unsorted collection containing this chat. */
504
+ scope: SessionScope;
505
+ /** Present exactly when `scope` names a project or workspace. */
506
+ projectId?: string;
507
+ /** Present exactly when `scope` names a workspace. */
508
+ workspaceId?: string;
509
+ /** Present exactly when `scope` names a folder. */
510
+ folderId?: string;
511
+ trackUnread?: boolean;
512
+ unread?: SessionUnreadState;
513
+ cwd: string;
514
+ draft?: string;
515
+ draftUpdatedAt?: number;
516
+ providerId: string;
517
+ modelId: string;
518
+ /**
519
+ * Position in the ordered list of a project's chats.
520
+ *
521
+ * Absent for a session that has no place in that list. A subagent belongs to
522
+ * the session that started it, not to the sidebar, so it has no position and
523
+ * must never be given a stand-in one.
524
+ */
525
+ orderKey?: string;
526
+ permissionMode: PermissionMode;
527
+ effort?: string;
528
+ serviceTier?: ServiceTier;
529
+ environment?: SessionExecutionEnvironment;
530
+ status: SessionSummaryStatus;
531
+ title?: string;
532
+ titleError?: string;
533
+ titleStatus: SessionTitleStatus;
534
+ recap?: string;
535
+ metadataUpdatedAt?: number;
536
+ metadataRunId?: string;
537
+ createdAt: number;
538
+ updatedAt: number;
539
+ lastMessageAt?: number;
540
+ /** Ordered identity of the newest session mutation/state event. */
541
+ lastEventId?: EventId;
542
+ /**
543
+ * The session's current activity wait, present while the agent is inside a
544
+ * scheduled `wait` or `wait_until`.
545
+ *
546
+ * Activity is live-only, so this is what tells a client connecting in the
547
+ * middle of a long wait that the session is waiting.
548
+ */
549
+ wait?: SessionActivityWait;
550
+ interruption?: SessionInterruption;
551
+ inboxItems?: readonly {
552
+ answers?: Readonly<Record<string, readonly string[]>>;
553
+ createdAt: number;
554
+ questions: UserInputRequest["questions"];
555
+ requestId: string;
556
+ resolvedAt?: number;
557
+ status: "pending" | "answered";
558
+ }[];
559
+ }
560
+ export interface CreateSessionRequest {
561
+ apiKey?: string;
562
+ appendSystemPrompt?: string;
563
+ trackUnread?: boolean;
564
+ cwd: string;
565
+ /** Every session names what it runs on; the agent never chooses on a client's behalf. */
566
+ effort: string;
567
+ serviceTier: ServiceTier | null;
568
+ instructions?: string;
569
+ /** Human profile responsible for this session. Required for remote creation. */
570
+ identity?: string;
571
+ /** Refreshes the peer daemon's memory-only GitHub authentication for this managed project. */
572
+ gitSecret?: {
573
+ kind: "github";
574
+ };
575
+ modelId: string;
576
+ providerId: string;
577
+ permissionMode?: PermissionMode;
578
+ secretIds?: readonly string[];
579
+ workflowsEnabled?: boolean;
580
+ docker?: DockerExecutionConfig;
581
+ local?: boolean;
582
+ /**
583
+ * Explicit non-code destination. When absent, `cwd` resolves to a project or workspace scope.
584
+ * Folder and Unsorted creation derive their own safe working directory.
585
+ */
586
+ scope?: Extract<SessionScope, {
587
+ kind: "folder" | "unsorted";
588
+ }>;
589
+ workspaceId?: string;
590
+ /** Client-chosen cuid2 identity for the session. Repeating it returns the same session. */
591
+ id?: string;
592
+ /** Identity to give the project when this directory is not one yet. */
593
+ projectId?: string;
594
+ }
595
+ export interface UpdateSessionRequest {
596
+ appendSystemPrompt: string | null;
597
+ mutationId?: string;
598
+ }
599
+ /**
600
+ * Longest composer draft the daemon stores and mirrors. Drafts are held in one
601
+ * session row and broadcast on every change, so they need an explicit bound.
602
+ */
603
+ export declare const SESSION_DRAFT_MAX_LENGTH = 100000;
604
+ /**
605
+ * How far a client's draft timestamp may trail the daemon's clock before it is
606
+ * treated as that old rather than older still.
607
+ */
608
+ export declare const SESSION_DRAFT_MAX_CLOCK_SKEW_MS = 300000;
609
+ export interface SetSessionDraftRequest {
610
+ /** Draft text, or `null` to clear the draft. */
611
+ draft: string | null;
612
+ /** Identifies the writing client so it can ignore its own echo. */
613
+ origin?: string;
614
+ /**
615
+ * When the user typed this draft, in milliseconds since the epoch. The
616
+ * daemon keeps the newest draft, so a write created before the one already
617
+ * stored is discarded even if it arrives later. Omitting it means now.
618
+ */
619
+ updatedAt?: number;
620
+ mutationId?: string;
621
+ }
622
+ export interface AttachSecretRequest {
623
+ secretId: string;
624
+ scope?: SecretAttachmentScope;
625
+ }
626
+ export interface SecretSessionResponse {
627
+ session: ProtocolSession;
628
+ }
629
+ export type RegisterSecretRequest = EnvironmentSecretRegistration;
630
+ export type UpdateSecretRequest = EnvironmentSecretUpdate;
631
+ export type SecretSummary = SecretReference;
632
+ export interface ListSecretsResponse {
633
+ secrets: readonly SecretSummary[];
634
+ }
635
+ export interface RegisterSecretResponse {
636
+ secret: SecretSummary;
637
+ }
638
+ export interface UpdateSecretResponse {
639
+ secret: SecretSummary;
640
+ }
641
+ export interface UnregisterSecretResponse {
642
+ removed: boolean;
643
+ }
644
+ export type SetGoalRequest = CreateGoalRequest & {
645
+ mutationId?: string;
646
+ };
647
+ export type ChangeSessionGoalStatusRequest = ChangeGoalStatusRequest & {
648
+ mutationId?: string;
649
+ };
650
+ export interface GoalSessionResponse {
651
+ session: ProtocolSession;
652
+ }
653
+ export type AnswerUserInputRequest = UserInputResponse & {
654
+ mutationId?: string;
655
+ };
656
+ export interface CreateSessionResponse {
657
+ session: ProtocolSession;
658
+ }
659
+ export interface ForkSessionResponse {
660
+ session: ProtocolSession;
661
+ }
662
+ export interface RewindSessionRequest {
663
+ messageId: string;
664
+ }
665
+ export interface RewindSessionResponse {
666
+ message: UserMessage;
667
+ session: ProtocolSession;
668
+ }
669
+ export interface CompactSessionResponse {
670
+ result: AgentCompactionResult;
671
+ session: ProtocolSession;
672
+ }
673
+ export interface ListSessionsResponse {
674
+ sessions: readonly SessionSummary[];
675
+ }
676
+ export type ListSessionsArchivedFilter = boolean | "all";
677
+ export interface ListSessionsOptions {
678
+ archived?: ListSessionsArchivedFilter;
679
+ limit?: number;
680
+ }
681
+ export interface SessionArchiveResponse {
682
+ session: ProtocolSession;
683
+ }
684
+ export interface SessionReadResponse {
685
+ session: ProtocolSession;
686
+ }
687
+ export interface ListSubagentsResponse {
688
+ subagents: readonly SubagentSummary[];
689
+ }
690
+ export interface SessionUsageGroup {
691
+ kind: "attributed";
692
+ modelId: string;
693
+ providerId: string;
694
+ requestedModelId: string;
695
+ /** Set when these tokens were spent reviewing permissions rather than answering the user. */
696
+ role?: "permission_review";
697
+ usage: Usage;
698
+ responseModel?: string;
699
+ }
700
+ export interface SessionContextUsage {
701
+ approximate: boolean;
702
+ modelId: string;
703
+ providerId: string;
704
+ requestedModelId: string;
705
+ responseModel?: string;
706
+ totalTokens: number;
707
+ }
708
+ export interface GetSessionUsageResponse {
709
+ currentProviderId: string;
710
+ groups: readonly SessionUsageGroup[];
711
+ context?: SessionContextUsage;
712
+ quotas: readonly SessionProviderQuota[];
713
+ }
714
+ export interface GetCurrentProviderQuotaResponse {
715
+ currentProviderId: string;
716
+ quota?: ProviderQuota;
717
+ }
718
+ /** The latest usage reading Happy Terminal holds for every configured provider. */
719
+ export interface ListProviderUsageResponse {
720
+ providers: readonly ProviderUsageEntry[];
721
+ }
722
+ export interface ProviderUsageEntry {
723
+ credential?: ProviderCredentialProvenance;
724
+ providerId: string;
725
+ /** The last reading, or null when the provider has never answered. */
726
+ usage: ProviderUsage | null;
727
+ /** When Happy Terminal last finished asking, whatever the answer was. */
728
+ checkedAt: number | null;
729
+ /** Why the last attempt produced nothing, when it produced nothing. */
730
+ error: string | null;
731
+ }
732
+ export interface SessionProviderQuota {
733
+ providerId: string;
734
+ quota: ProviderQuota;
735
+ }
736
+ export interface StopWorkflowResponse {
737
+ workflow: WorkflowRun;
738
+ }
739
+ export interface ShutdownServerResponse {
740
+ pid?: number;
741
+ shuttingDown: boolean;
742
+ }
743
+ export interface StartInspectorResponse {
744
+ inspectorUrl: string;
745
+ }
746
+ export interface StopInspectorResponse {
747
+ stopped: boolean;
748
+ }
749
+ export interface ListExternalToolCallsResponse {
750
+ calls: readonly ExternalToolCall[];
751
+ }
752
+ export interface SubmitMessageRequest {
753
+ clientSubmissionId?: string;
754
+ content?: readonly ContentBlock[];
755
+ debug?: boolean;
756
+ displayText?: string;
757
+ interactive?: boolean;
758
+ /** Stable human profile identity. Local unattributed messages use null. */
759
+ identity?: string | null;
760
+ /** Refreshes the peer daemon's memory-only GitHub authentication for this managed project. */
761
+ gitSecret?: {
762
+ kind: "github";
763
+ };
764
+ /** Replaces the external function set for this and subsequent runs when present. */
765
+ externalTools?: readonly ExternalToolDefinition[];
766
+ /** Replaces the integration-owned durable skill set when present. */
767
+ skills?: readonly DurableSkillDefinition[];
768
+ /** Replaces Happy Terminal's assembled system prompt. Null restores Happy Terminal's normal prompt. */
769
+ systemPrompt?: string | null;
770
+ /**
771
+ * Reasoning effort for this run and subsequent ones. Applied when this message's run starts, so
772
+ * it never disturbs a run already in progress. Every message names it; nothing is inherited.
773
+ */
774
+ effort: string;
775
+ /** Model for this and subsequent runs. Applied when this message's run starts. */
776
+ modelId: string;
777
+ /** The account serving `modelId`. */
778
+ providerId: string;
779
+ /**
780
+ * Permission mode for this and subsequent runs. Applied when this message's run starts.
781
+ */
782
+ permissionMode?: PermissionMode;
783
+ /**
784
+ * Fast mode for this and subsequent runs. Null runs it on the standard tier. Applied when this
785
+ * message's run starts.
786
+ */
787
+ serviceTier: ServiceTier | null;
788
+ text: string;
789
+ /** Identity used to correlate the optimistic action with its stream echo. */
790
+ mutationId?: string;
791
+ }
792
+ export declare const submitContextMessageRequestSchema: import("@sinclair/typebox").TObject<{
793
+ clientSubmissionId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
794
+ identity: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>>;
795
+ mutationId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
796
+ text: import("@sinclair/typebox").TString;
797
+ }>;
798
+ export type SubmitContextMessageRequest = Static<typeof submitContextMessageRequestSchema>;
799
+ export interface BroadcastMessageRequest extends SubmitMessageRequest {
800
+ all?: boolean;
801
+ sessionIds?: readonly string[];
802
+ }
803
+ export interface BroadcastMessageResponse {
804
+ submissions: readonly SubmitMessageResponse[];
805
+ }
806
+ export type ResolveExternalToolCallRequest = ExternalToolCallResolution;
807
+ export type { ResolveExternalToolCallResponse };
808
+ export interface SubmitMessageResponse {
809
+ debugDirectory?: string;
810
+ eventId: EventId;
811
+ runId: string;
812
+ sessionId: string;
813
+ }
814
+ export interface SubmitContextMessageResponse {
815
+ delivery: "context";
816
+ eventId: EventId;
817
+ messageId: string;
818
+ sessionId: string;
819
+ }
820
+ export interface CancelScheduledMessageResponse {
821
+ cancelled: boolean;
822
+ message?: ScheduledMessage;
823
+ }
824
+ export interface RunShellCommandRequest {
825
+ command: string;
826
+ commandId: string;
827
+ }
828
+ export interface RunShellCommandResult {
829
+ command: string;
830
+ commandId: string;
831
+ errorMessage?: string;
832
+ exitCode: number | null;
833
+ output: string;
834
+ sessionId?: number;
835
+ timedOut: boolean;
836
+ }
837
+ export type ShellCommandState = {
838
+ command: string;
839
+ commandId: string;
840
+ sessionId: number;
841
+ status: "running";
842
+ } | (RunShellCommandResult & {
843
+ status: "finished";
844
+ });
845
+ export interface RunningShellCommandResponse {
846
+ command: string;
847
+ commandId: string;
848
+ eventId: EventId;
849
+ sessionId: number;
850
+ status: "running";
851
+ }
852
+ export type RunShellCommandResponse = RunningShellCommandResponse | (RunShellCommandResult & {
853
+ eventId: EventId;
854
+ status: "finished";
855
+ });
856
+ export type ReadBackgroundProcessResponse = BashSessionSnapshot;
857
+ export interface StopBackgroundProcessResponse {
858
+ process?: BashSessionSnapshot;
859
+ stopped: boolean;
860
+ }
861
+ export interface SteerMessageRequest extends SubmitMessageRequest {
862
+ clientSubmissionId?: string;
863
+ expectedRunId?: string;
864
+ }
865
+ export interface SteerMessageResponse extends SubmitMessageResponse {
866
+ delivery: "run" | "steer";
867
+ }
868
+ export interface AbortRunResponse {
869
+ aborted: boolean;
870
+ continued?: boolean;
871
+ eventId?: EventId;
872
+ stoppedProcesses?: number;
873
+ }
874
+ export interface AbortRunOptions {
875
+ continuePendingSteering?: boolean;
876
+ expectedRunId?: string;
877
+ steeringMessageIds?: readonly string[];
878
+ mutationId?: string;
879
+ }
880
+ export type SessionEvent = SessionCreatedEvent | SessionUpdatedEvent | SessionArchiveChangedEvent | SessionWorkspaceArchivedEvent | MessageSubmittedEvent | SteeringAppliedEvent | RunStartedEvent | AgentStreamEvent | ProviderStreamEvent | AgentMessageEvent | PermissionReviewEvent | SystemNoticeEvent | RunFinishedEvent | ProviderQuotaObservedEvent | RunErrorEvent | AbortRequestedEvent | SessionResetEvent | SessionRewoundEvent | SessionStatusChangedEvent | SessionTitleChangedEvent | SessionActivityChangedEvent | SessionGitChangedEvent | SessionConfigurationChangedEvent | PermissionModeChangedEvent | SessionDraftChangedEvent | SecretsChangedEvent | UserInputRequestedEvent | UserInputDetachedEvent | UserInputResolvedEvent | MutationAppliedEvent | McpServersChangedEvent | TasksChangedEvent | GoalChangedEvent | SubagentChangedEvent | SubagentsSuspendedEvent | WorkflowChangedEvent | ExternalToolCallRequestedEvent | ExternalToolCallResolvedEvent | ShellCommandStartedEvent | ShellCommandFinishedEvent | ScheduledMessageChangedEvent | ScheduledMessagesPrunedEvent;
881
+ export interface BaseSessionEvent<TType extends string, TData> {
882
+ createdAt: number;
883
+ data: TData;
884
+ id: EventId;
885
+ sessionId: string;
886
+ type: TType;
887
+ }
888
+ export type SessionCreatedEvent = BaseSessionEvent<"session_created", {
889
+ session: ProtocolSession;
890
+ }>;
891
+ /**
892
+ * A current-state refresh. `session.snapshot` never carries transcript or model-context messages;
893
+ * those have their own bounded transcript protocol and durable message rows.
894
+ */
895
+ export type SessionUpdatedEvent = BaseSessionEvent<"session_updated", {
896
+ /**
897
+ * One model-context message introduced by this state transition.
898
+ *
899
+ * This is deliberately singular: full model context remains daemon-owned, while
900
+ * visible history is loaded through the bounded request-response transcript.
901
+ */
902
+ appendedContextMessage?: SystemMessage;
903
+ mutationId?: string;
904
+ session: ProtocolSession;
905
+ }>;
906
+ export type SessionArchiveChangedEvent = BaseSessionEvent<"session_archived", {
907
+ archived: boolean;
908
+ mutationId?: string;
909
+ }>;
910
+ export type SessionWorkspaceArchivedEvent = BaseSessionEvent<"session_workspace_archived", {
911
+ reason: "workspace_archived";
912
+ workspaceId: string;
913
+ }>;
914
+ export type MessageSubmittedEvent = BaseSessionEvent<"message_submitted", {
915
+ displayText: string;
916
+ delivery?: "context" | "run" | "steer";
917
+ message: UserMessage;
918
+ mutationId?: string;
919
+ runId: string;
920
+ source?: "notification";
921
+ }>;
922
+ export type SteeringAppliedEvent = BaseSessionEvent<"steering_applied", {
923
+ messageIds: readonly string[];
924
+ runId: string;
925
+ }>;
926
+ export type RunStartedEvent = BaseSessionEvent<"run_started", {
927
+ runId: string;
928
+ kind?: "compaction";
929
+ }>;
930
+ export type AgentStreamEvent = BaseSessionEvent<"agent_event", {
931
+ event: AgentLoopEvent;
932
+ /** The current provider event retained losslessly beside Happy Terminal's indexed UI projection. */
933
+ providerEvent?: ProviderSessionEvent;
934
+ runId: string;
935
+ }>;
936
+ export type ProviderStreamEvent = BaseSessionEvent<"provider_event", {
937
+ event: ProviderSessionEvent;
938
+ runId: string;
939
+ }>;
940
+ export type AgentMessageEvent = BaseSessionEvent<"agent_message", {
941
+ message: Message;
942
+ runId: string;
943
+ }>;
944
+ /**
945
+ * A reviewed or denied Auto action, projected as a tool-row annotation.
946
+ *
947
+ * It carries no run id, and deliberately so: the permissions module that produces it runs inside a
948
+ * tool call, and Happy Terminal's frozen agent core exposes no owning run id to a module. The annotation is
949
+ * addressed by tool-call id, which is all a client needs to attach it, so a run id would be
950
+ * invented rather than real. It applies exactly like the same `permission_review` loop event
951
+ * delivered inside an `agent_event`, but it never takes part in run-lifecycle bookkeeping.
952
+ */
953
+ export type PermissionReviewEvent = BaseSessionEvent<"permission_review", {
954
+ event: Extract<AgentLoopEvent, {
955
+ type: "permission_review";
956
+ }>;
957
+ }>;
958
+ /** A visible service row that has no agent-run lifecycle or model-context effect. */
959
+ export type SystemNoticeEvent = BaseSessionEvent<"system_notice", {
960
+ message: SystemMessage;
961
+ }>;
962
+ export type RunFinishedEvent = BaseSessionEvent<"run_finished", {
963
+ agentRunId?: string;
964
+ /** Atomically decorates the completed turn's final message. */
965
+ attachmentMessageId?: string;
966
+ attachments?: readonly Attachment[];
967
+ /** Present whenever `stopReason` is `error`, so the failure stays readable in history. */
968
+ errorMessage?: string;
969
+ providerError?: ProviderError;
970
+ providerId?: string;
971
+ requestedModelId?: string;
972
+ modelLocked: boolean;
973
+ runId: string;
974
+ stopReason: StopReason;
975
+ }>;
976
+ /**
977
+ * What a provider said about the account while it was already answering this
978
+ * session. It costs no extra request, so it is the freshest thing a client can
979
+ * be told about a quota without asking the vendor.
980
+ */
981
+ export type ProviderQuotaObservedEvent = BaseSessionEvent<"provider_quota_observed", {
982
+ providerId: string;
983
+ quota: ProviderQuota;
984
+ }>;
985
+ export type RunErrorEvent = BaseSessionEvent<"run_error", {
986
+ errorMessage: string;
987
+ modelLocked: boolean;
988
+ providerError?: ProviderError;
989
+ providerId?: string;
990
+ requestedModelId?: string;
991
+ runId: string;
992
+ startupInterruption?: true;
993
+ }>;
994
+ export type AbortRequestedEvent = BaseSessionEvent<"abort_requested", {
995
+ continuePendingSteering?: true;
996
+ mutationId?: string;
997
+ runId?: string;
998
+ }>;
999
+ export type ShellCommandFinishedEvent = BaseSessionEvent<"shell_command_finished", RunShellCommandResult>;
1000
+ export type ShellCommandStartedEvent = BaseSessionEvent<"shell_command_started", {
1001
+ command: string;
1002
+ commandId: string;
1003
+ sessionId: number;
1004
+ }>;
1005
+ export type SubagentsSuspendedEvent = BaseSessionEvent<"subagents_suspended", {
1006
+ displayText: string;
1007
+ }>;
1008
+ /**
1009
+ * The session's durable lifecycle status changed.
1010
+ *
1011
+ * This is the persisted status, not the current-moment activity. A client needs
1012
+ * both: activity says what the session is doing, while status says whether it is
1013
+ * archived, suspended, failed, or simply idle.
1014
+ */
1015
+ export type SessionStatusChangedEvent = BaseSessionEvent<"session_status_changed", {
1016
+ status: SessionStatus;
1017
+ }>;
1018
+ export type SessionResetEvent = BaseSessionEvent<"session_reset", {
1019
+ snapshot: AgentSnapshot;
1020
+ /**
1021
+ * The transcript as it stands after the reset.
1022
+ *
1023
+ * The snapshot alone carries messages without the runs that produced
1024
+ * them, so a client rebuilding from it cannot say where one turn ended
1025
+ * and the next began. This keeps a rebuilt transcript as complete as the
1026
+ * one an attaching client is given.
1027
+ */
1028
+ transcript: SessionTranscriptWindow;
1029
+ }>;
1030
+ export type SessionRewoundEvent = BaseSessionEvent<"session_rewound", {
1031
+ messageId: string;
1032
+ snapshot: AgentSnapshot;
1033
+ /** The transcript as it stands after the rewind. See `SessionResetEvent`. */
1034
+ transcript: SessionTranscriptWindow;
1035
+ }>;
1036
+ export type SessionTitleChangedEvent = BaseSessionEvent<"session_title_changed", {
1037
+ errorMessage?: string;
1038
+ metadataRunId?: string;
1039
+ metadataUpdatedAt?: number;
1040
+ recap?: string;
1041
+ status: SessionTitleStatus;
1042
+ title?: string;
1043
+ }>;
1044
+ /**
1045
+ * The session started doing something different.
1046
+ *
1047
+ * The payload is the complete current activity rather than a description of the
1048
+ * change, so a client that just attached can render its status line from the
1049
+ * first one of these it sees.
1050
+ */
1051
+ export type SessionActivityChangedEvent = BaseSessionEvent<"session_activity_changed", {
1052
+ activity: SessionActivity;
1053
+ }>;
1054
+ export type ScheduledMessageChangedEvent = BaseSessionEvent<"scheduled_message_changed", {
1055
+ message: ScheduledMessage;
1056
+ mutationId?: string;
1057
+ }>;
1058
+ export type ScheduledMessagesPrunedEvent = BaseSessionEvent<"scheduled_messages_pruned", {
1059
+ messageIds: readonly string[];
1060
+ }>;
1061
+ /**
1062
+ * The Git state of the directory this session runs in.
1063
+ *
1064
+ * A UI shows the branch and the changed files next to the conversation, so the
1065
+ * session stream carries them rather than making a client open the project
1066
+ * stream as well and correlate the two.
1067
+ */
1068
+ export type SessionGitChangedEvent = BaseSessionEvent<"session_git_changed", {
1069
+ git: GitChangeSnapshot;
1070
+ }>;
1071
+ /** Which parts of the agent configuration one change actually altered. */
1072
+ export type SessionConfigurationField = "model" | "effort" | "serviceTier";
1073
+ /**
1074
+ * A change to the model, reasoning effort, or fast mode.
1075
+ *
1076
+ * Several of these can move together, most often when a message carries them, so one event
1077
+ * reports everything that changed at once. `changed` names the fields the change actually
1078
+ * altered; the remaining fields describe the resulting configuration and are always present so
1079
+ * a reader never has to reconstruct them from earlier events. Conversation state does not belong
1080
+ * in this event: messages are delivered through the transcript protocol and stored once in the
1081
+ * message table.
1082
+ */
1083
+ export type SessionConfigurationChangedEvent = BaseSessionEvent<"session_configuration_changed", {
1084
+ changed: readonly SessionConfigurationField[];
1085
+ effort?: string;
1086
+ modelId: string;
1087
+ providerId: string;
1088
+ serviceTier: ServiceTier | null;
1089
+ mutationId?: string;
1090
+ }>;
1091
+ export type PermissionModeChangedEvent = BaseSessionEvent<"permission_mode_changed", {
1092
+ mutationId?: string;
1093
+ permissionMode: PermissionMode;
1094
+ }>;
1095
+ /**
1096
+ * A composer draft change. The `origin` identifies the client that wrote the
1097
+ * draft so that client can ignore the echo of its own keystrokes. `updatedAt`
1098
+ * is the daemon-clamped moment the draft was typed; clients compare it against
1099
+ * their own unsent edit so the newer message wins rather than the later write.
1100
+ */
1101
+ export type SessionDraftChangedEvent = BaseSessionEvent<"session_draft_changed", {
1102
+ draft?: string;
1103
+ mutationId?: string;
1104
+ origin?: string;
1105
+ updatedAt: number;
1106
+ }>;
1107
+ export type SecretsChangedEvent = BaseSessionEvent<"secrets_changed", {
1108
+ projectSecretIds: readonly string[];
1109
+ secretIds: readonly string[];
1110
+ sessionSecretIds: readonly string[];
1111
+ mutationId?: string;
1112
+ }>;
1113
+ export type UserInputRequestedEvent = BaseSessionEvent<"user_input_requested", UserInputRequest>;
1114
+ /** Presence stopped an agent from waiting for this question; it stays open in the Inbox. */
1115
+ export type UserInputDetachedEvent = BaseSessionEvent<"user_input_detached", {
1116
+ presenceId: string;
1117
+ reason: "away" | "timeout";
1118
+ requestId: string;
1119
+ }>;
1120
+ export type UserInputResolvedEvent = BaseSessionEvent<"user_input_resolved", {
1121
+ answers?: UserInputResponse["answers"];
1122
+ mutationId?: string;
1123
+ requestId: string;
1124
+ status: "answered" | "cancelled";
1125
+ }>;
1126
+ export interface GetPresenceResponse {
1127
+ presence: PresenceSnapshot;
1128
+ }
1129
+ export interface SetPresenceResponse {
1130
+ presence: PresenceSnapshot;
1131
+ }
1132
+ export type MutationAppliedEvent = BaseSessionEvent<"mutation_applied", {
1133
+ mutationId: string;
1134
+ }>;
1135
+ export type McpServersChangedEvent = BaseSessionEvent<"mcp_servers_changed", {
1136
+ servers: readonly McpServerSummary[];
1137
+ }>;
1138
+ export type TasksChangedEvent = BaseSessionEvent<"tasks_changed", {
1139
+ tasks: readonly SessionTask[];
1140
+ }>;
1141
+ export type GoalChangedEvent = BaseSessionEvent<"goal_changed", {
1142
+ goal: SessionGoal | null;
1143
+ mutationId?: string;
1144
+ }>;
1145
+ export type SubagentChangedEvent = BaseSessionEvent<"subagent_changed", {
1146
+ subagent: SubagentSummary;
1147
+ }>;
1148
+ export type WorkflowChangedEvent = BaseSessionEvent<"workflow_changed", {
1149
+ update: WorkflowRunUpdate;
1150
+ }>;
1151
+ export type ExternalToolCallRequestedEvent = BaseSessionEvent<"external_tool_call_requested", {
1152
+ call: ExternalToolCall;
1153
+ }>;
1154
+ export type ExternalToolCallResolvedEvent = BaseSessionEvent<"external_tool_call_resolved", {
1155
+ call: ExternalToolCall;
1156
+ }>;