@bobannomi/client 0.1.1 → 0.3.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/dist/index.d.ts CHANGED
@@ -1,3 +1,27 @@
1
+ interface UsagePrice {
2
+ provider: string;
3
+ model: string;
4
+ currency: string;
5
+ source: string;
6
+ adoptedAt: number;
7
+ inputPerMillion: number;
8
+ outputPerMillion: number;
9
+ cacheReadPerMillion: number;
10
+ cacheCreationPerMillion: number;
11
+ subscription: boolean;
12
+ inputIncludesCache?: boolean;
13
+ }
14
+ interface UsageSettings {
15
+ version: 1;
16
+ prices: UsagePrice[];
17
+ budget: {
18
+ enabled: boolean;
19
+ tokens: number | null;
20
+ amount: number | null;
21
+ currency: string;
22
+ };
23
+ }
24
+
1
25
  type ContextBucketId = "system" | "tools" | "rules" | "skills" | "mcp" | "subagents" | "summary" | "conversation";
2
26
  interface ContextUsageBucket {
3
27
  id: ContextBucketId;
@@ -122,7 +146,6 @@ interface SessionConfigurationInput {
122
146
  pluginAutoSelectionEnabled?: boolean;
123
147
  activePluginId?: string | null;
124
148
  pluginIds?: string[];
125
- serviceBindings?: string[];
126
149
  memory?: {
127
150
  enabled: boolean;
128
151
  };
@@ -168,6 +191,16 @@ type DispatchedSessionCreation = CreateClientSessionInput$1 & {
168
191
  id: string;
169
192
  requestId: string;
170
193
  };
194
+ /** The daemon resolves this registered project's active directory. */
195
+ type CreateSessionByProjectInput = Omit<CreateClientSessionInput$1, "cwd" | "projectId"> & {
196
+ projectId: string;
197
+ cwd?: never;
198
+ };
199
+ type SessionCreationInput = CreateClientSessionInput$1 | CreateSessionByProjectInput;
200
+ type DispatchedSessionCreationRequest = SessionCreationInput & {
201
+ id: string;
202
+ requestId: string;
203
+ };
171
204
  interface SessionCreationReceipt {
172
205
  dataScopeId: string;
173
206
  sessionId: string;
@@ -199,11 +232,6 @@ interface SessionConfigurationOptions {
199
232
  name: string;
200
233
  revision: string;
201
234
  }[];
202
- services: {
203
- id: string;
204
- name: string;
205
- revision: string;
206
- }[];
207
235
  defaults: SessionConfigurationInput;
208
236
  }
209
237
 
@@ -340,6 +368,17 @@ interface SessionSearchResult {
340
368
  messageId: string;
341
369
  snippet: string;
342
370
  }
371
+ interface ProjectRecord {
372
+ id: string;
373
+ name: string;
374
+ path: string;
375
+ pinnedAt?: number;
376
+ defaultShell?: string;
377
+ lastOpenedAt: number;
378
+ archivedAt?: number;
379
+ createdAt: number;
380
+ updatedAt: number;
381
+ }
343
382
  interface SessionInputRecord {
344
383
  id: string;
345
384
  sessionId: string;
@@ -525,6 +564,78 @@ interface PluginUiInstanceRecord {
525
564
  /** Shape validation only; the Server must also verify ownership against the actual Part. */
526
565
  declare function readPluginUiInstance(metadata: unknown): PluginUiInstanceRecord | undefined;
527
566
 
567
+ type SessionManagementAction = "rename" | "pin" | "archive" | "delete";
568
+ interface SessionMutationResult {
569
+ readonly sessionId: string;
570
+ readonly action: SessionManagementAction;
571
+ readonly revision?: number;
572
+ readonly deletedSessionIds?: readonly string[];
573
+ }
574
+ interface SessionMutationPublicReceipt {
575
+ readonly dataScopeId: string;
576
+ readonly sessionId: string;
577
+ readonly requestId: string;
578
+ readonly result: SessionMutationResult;
579
+ }
580
+ interface SessionDirectoryEntry {
581
+ readonly id: string;
582
+ readonly title: string;
583
+ readonly project: {
584
+ readonly id: string;
585
+ readonly displayName: string;
586
+ };
587
+ readonly status: string;
588
+ readonly updatedAt: number;
589
+ /** Display fields only, present when this caller can read the session. */
590
+ readonly summary?: {
591
+ cwd: string;
592
+ model: string;
593
+ createdAt: number;
594
+ metadata: Record<string, unknown>;
595
+ projectId?: string;
596
+ cwdRelative?: string;
597
+ parentId?: string;
598
+ agent?: string;
599
+ archivedAt?: number;
600
+ storage?: "sqlite" | "memory";
601
+ };
602
+ readonly pinnedAt?: number;
603
+ readonly source: "instance" | "im";
604
+ readonly hints: Readonly<Record<"read" | "execute" | SessionManagementAction, boolean>>;
605
+ readonly unavailableReason?: string;
606
+ }
607
+ interface SessionDirectoryPage {
608
+ readonly dataScopeId: string;
609
+ readonly entries: readonly SessionDirectoryEntry[];
610
+ readonly nextCursor?: string;
611
+ }
612
+ interface SessionResourceRevision {
613
+ readonly revision: number;
614
+ readonly treeRevision?: string;
615
+ }
616
+ /** The connection identity an admitted Run must use for model requests. */
617
+ interface ExpectedModelConnection {
618
+ readonly provider: string;
619
+ readonly fingerprint: string;
620
+ }
621
+ interface SessionActivityPage {
622
+ dataScopeId: string;
623
+ revision: string;
624
+ /** Resume the instance event stream after this authorized snapshot. */
625
+ cursor: number;
626
+ entries: {
627
+ sessionId: string;
628
+ latestSeq: number;
629
+ status: string;
630
+ storage: "sqlite" | "memory";
631
+ lastRunStatus?: "completed" | "failed" | "interrupted";
632
+ attentionSeq: number;
633
+ activeRunId?: string;
634
+ pendingQuestionIds: string[];
635
+ pendingApprovalIds: string[];
636
+ }[];
637
+ }
638
+
528
639
  type GoalStatus = "active" | "waiting_user" | "blocked" | "paused" | "completed" | "cancelled";
529
640
  type GoalAction = "pause" | "resume" | "cancel" | "budget" | "cancel_resume";
530
641
  interface GoalUsage {
@@ -594,6 +705,7 @@ interface CreateSessionGoalInput {
594
705
  tokenBudget?: number;
595
706
  items?: SessionUserInputItem[];
596
707
  attachments?: PromptAttachment[];
708
+ expectedModelConnection?: ExpectedModelConnection;
597
709
  }
598
710
  interface UpdateSessionGoalInput {
599
711
  requestId: string;
@@ -601,6 +713,7 @@ interface UpdateSessionGoalInput {
601
713
  objective: string;
602
714
  items?: SessionUserInputItem[];
603
715
  attachments?: PromptAttachment[];
716
+ expectedModelConnection?: ExpectedModelConnection;
604
717
  }
605
718
  interface GoalActionInput {
606
719
  requestId: string;
@@ -611,6 +724,8 @@ interface GoalActionInput {
611
724
  questionId?: string;
612
725
  response?: string;
613
726
  objectiveVersion?: number;
727
+ /** Only accepted when resuming a Goal. */
728
+ expectedModelConnection?: ExpectedModelConnection;
614
729
  }
615
730
  /** Public durable command receipt; runtime/source and plugin admission evidence stay private. */
616
731
  interface SessionGoalRequestReceipt {
@@ -676,77 +791,9 @@ type SessionRuntimeConfig = {
676
791
  pluginsEnabled?: boolean;
677
792
  memoryEnabled?: boolean;
678
793
  pluginAutoSelectionEnabled?: boolean;
679
- appServiceBindings?: string[];
680
794
  };
681
795
  type SessionRuntimeConfigPatch = Partial<SessionRuntimeConfig>;
682
796
 
683
- type SessionManagementAction = "rename" | "pin" | "archive" | "delete";
684
- interface SessionMutationResult {
685
- readonly sessionId: string;
686
- readonly action: SessionManagementAction;
687
- readonly revision?: number;
688
- readonly deletedSessionIds?: readonly string[];
689
- }
690
- interface SessionMutationPublicReceipt {
691
- readonly dataScopeId: string;
692
- readonly sessionId: string;
693
- readonly requestId: string;
694
- readonly result: SessionMutationResult;
695
- }
696
- interface SessionDirectoryEntry {
697
- readonly id: string;
698
- readonly title: string;
699
- readonly project: {
700
- readonly id: string;
701
- readonly displayName: string;
702
- };
703
- readonly status: string;
704
- readonly updatedAt: number;
705
- /** Display fields only, present when this caller can read the session. */
706
- readonly summary?: {
707
- cwd: string;
708
- model: string;
709
- createdAt: number;
710
- metadata: Record<string, unknown>;
711
- projectId?: string;
712
- cwdRelative?: string;
713
- parentId?: string;
714
- agent?: string;
715
- archivedAt?: number;
716
- storage?: "sqlite" | "memory";
717
- };
718
- readonly pinnedAt?: number;
719
- readonly source: "instance" | "im";
720
- readonly hints: Readonly<Record<"read" | "execute" | SessionManagementAction, boolean>>;
721
- readonly unavailableReason?: string;
722
- }
723
- interface SessionDirectoryPage {
724
- readonly dataScopeId: string;
725
- readonly entries: readonly SessionDirectoryEntry[];
726
- readonly nextCursor?: string;
727
- }
728
- interface SessionResourceRevision {
729
- readonly revision: number;
730
- readonly treeRevision?: string;
731
- }
732
- interface SessionActivityPage {
733
- dataScopeId: string;
734
- revision: string;
735
- /** Resume the instance event stream after this authorized snapshot. */
736
- cursor: number;
737
- entries: {
738
- sessionId: string;
739
- latestSeq: number;
740
- status: string;
741
- storage: "sqlite" | "memory";
742
- lastRunStatus?: "completed" | "failed" | "interrupted";
743
- attentionSeq: number;
744
- activeRunId?: string;
745
- pendingQuestionIds: string[];
746
- pendingApprovalIds: string[];
747
- }[];
748
- }
749
-
750
797
  type ScheduledTaskStatus = "active" | "paused" | "completed";
751
798
  type ScheduledTaskDestination = "standalone" | "chat";
752
799
  type ScheduledTaskExecutionMode = "local" | "worktree";
@@ -898,7 +945,6 @@ interface SessionControls {
898
945
  efforts: ControlOption[];
899
946
  workModes: ControlOption[];
900
947
  permissionModes?: ControlOption[];
901
- appServiceBindings?: ControlOption[];
902
948
  skills: (ControlOption & {
903
949
  path: string;
904
950
  source?: string;
@@ -972,6 +1018,146 @@ interface AgentSessionStateSnapshot {
972
1018
  goal?: SessionGoal | null;
973
1019
  }
974
1020
 
1021
+ interface StorageRetentionPolicy {
1022
+ version: 1;
1023
+ enabled: boolean;
1024
+ days: number;
1025
+ lastRunAt: number | null;
1026
+ }
1027
+ interface MaintenanceBackupManifest {
1028
+ version: 1 | 2 | 3;
1029
+ backupId: string;
1030
+ createdAt: number;
1031
+ database: "database.sqlite";
1032
+ directories: Record<"artifacts" | "memory" | "execution-output" | "attachments", boolean> & {
1033
+ notes?: boolean;
1034
+ };
1035
+ attachments?: {
1036
+ assets: number;
1037
+ uniqueBlobs: number;
1038
+ physicalBytes: number;
1039
+ consistency: {
1040
+ errors: number;
1041
+ warnings: number;
1042
+ issueCounts: Record<string, number>;
1043
+ };
1044
+ };
1045
+ recovery: {
1046
+ reviveLiveProcesses: false;
1047
+ closeActiveRecordsOnStartup: true;
1048
+ };
1049
+ }
1050
+
1051
+ /** Maintenance wire values contain no runtime objects, credentials or message content. */
1052
+ interface UsageFilter {
1053
+ from?: number;
1054
+ to?: number;
1055
+ project?: string;
1056
+ provider?: string;
1057
+ model?: string;
1058
+ }
1059
+ interface UsageRequest {
1060
+ id: string;
1061
+ time: number;
1062
+ project: string;
1063
+ sessionId: string;
1064
+ runId: string;
1065
+ provider: string;
1066
+ model: string;
1067
+ status: string;
1068
+ completeness: "complete" | "partial" | "unknown";
1069
+ inputTokens: number | null;
1070
+ outputTokens: number | null;
1071
+ cacheReadTokens: number | null;
1072
+ cacheCreationTokens: number | null;
1073
+ cost: {
1074
+ amount: number;
1075
+ currency: string;
1076
+ kind: "estimate";
1077
+ source: string;
1078
+ adoptedAt: number;
1079
+ price: UsagePrice;
1080
+ } | null;
1081
+ subscription?: true;
1082
+ }
1083
+ interface UsageReport {
1084
+ scannedAt: number;
1085
+ requests: UsageRequest[];
1086
+ warnings: string[];
1087
+ options: {
1088
+ projects: string[];
1089
+ providers: string[];
1090
+ models: string[];
1091
+ };
1092
+ totals: {
1093
+ requests: number;
1094
+ unknown: number;
1095
+ partial: number;
1096
+ input: number;
1097
+ output: number;
1098
+ cacheRead: number;
1099
+ cacheCreation: number;
1100
+ costs: Record<string, number>;
1101
+ };
1102
+ settings: UsageSettings;
1103
+ }
1104
+ interface StorageCategory {
1105
+ id: string;
1106
+ name: string;
1107
+ paths: string[];
1108
+ bytes: number;
1109
+ files: number;
1110
+ errors: string[];
1111
+ }
1112
+ interface StorageReport {
1113
+ scannedAt: number;
1114
+ dataDirectory: string;
1115
+ totalBytes: number;
1116
+ availableBytes: number | null;
1117
+ writable: boolean;
1118
+ categories: StorageCategory[];
1119
+ backups?: Array<{
1120
+ path: string;
1121
+ createdAt: number;
1122
+ bytes: number;
1123
+ manifest: MaintenanceBackupManifest;
1124
+ }>;
1125
+ }
1126
+ interface CleanupCandidate {
1127
+ id: string;
1128
+ kind: "session" | "log";
1129
+ label: string;
1130
+ updatedAt: number;
1131
+ bytes: number;
1132
+ children?: number;
1133
+ attachments?: number;
1134
+ }
1135
+ interface CleanupPreview {
1136
+ id: string;
1137
+ createdAt: number;
1138
+ olderThan: number;
1139
+ candidates: CleanupCandidate[];
1140
+ protected: Array<{
1141
+ id: string;
1142
+ reason: string;
1143
+ }>;
1144
+ bytes: number;
1145
+ scope: string;
1146
+ }
1147
+ interface CleanupResult {
1148
+ auditId: string;
1149
+ completed: string[];
1150
+ skipped: Array<{
1151
+ id: string;
1152
+ reason: string;
1153
+ }>;
1154
+ failures: Array<{
1155
+ id: string;
1156
+ reason: string;
1157
+ }>;
1158
+ releasedBytes: number;
1159
+ }
1160
+
975
1161
  type JobKind = "terminal" | "shell" | "agent" | "dream" | "workflow";
976
1162
  type JobTarget = {
977
1163
  kind: "agent";
@@ -1067,6 +1253,7 @@ declare class ProtocolValidationError extends Error {
1067
1253
  type TerminalRuntime = "local" | "environment";
1068
1254
  type TerminalSessionStatus = JobStatus;
1069
1255
  type TerminalSource = "user" | "agent";
1256
+ type TerminalSignal = "interrupt" | "eof" | "terminate";
1070
1257
  type TerminalScope = {
1071
1258
  kind: "project";
1072
1259
  projectId: string;
@@ -1074,6 +1261,21 @@ type TerminalScope = {
1074
1261
  kind: "session";
1075
1262
  sessionId: string;
1076
1263
  };
1264
+ interface TerminalCreateRequest {
1265
+ scope: TerminalScope;
1266
+ runtime: TerminalRuntime;
1267
+ cols: number;
1268
+ rows: number;
1269
+ name?: string;
1270
+ shell?: string;
1271
+ shellArgs?: string[];
1272
+ /** 直接运行命令;命令退出后终端结束,不保留空闲 shell。 */
1273
+ command?: string;
1274
+ /** 仅此终端子进程的覆盖值,不修改智能体或系统环境。 */
1275
+ env?: Record<string, string>;
1276
+ cwd?: string;
1277
+ source?: TerminalSource;
1278
+ }
1077
1279
  /** 可以通过 HTTP/SSE 发送的终端状态,不包含 PTY 或子进程对象。 */
1078
1280
  interface TerminalSessionInfo {
1079
1281
  id: string;
@@ -1095,6 +1297,20 @@ interface TerminalSessionInfo {
1095
1297
  exitedAt?: string;
1096
1298
  exitCode?: number | null;
1097
1299
  }
1300
+ interface TerminalWriteRequest {
1301
+ terminalId: string;
1302
+ data: string;
1303
+ }
1304
+ interface TerminalResizeRequest {
1305
+ terminalId: string;
1306
+ cols: number;
1307
+ rows: number;
1308
+ }
1309
+ interface TerminalReadRequest {
1310
+ terminalId: string;
1311
+ after?: number;
1312
+ maxChars?: number;
1313
+ }
1098
1314
  interface TerminalReadResult {
1099
1315
  terminalId: string;
1100
1316
  data: string;
@@ -1124,30 +1340,167 @@ type TerminalEvent = {
1124
1340
  message: string;
1125
1341
  };
1126
1342
 
1127
- declare const CURRENT_PROTOCOL_VERSION = 7;
1128
- interface ProtocolVersion {
1129
- version: number;
1343
+ type ChannelDeliveryStatus = "pending" | "sent" | "failed" | "unknown";
1344
+ interface ExternalConversationRecord {
1345
+ id: string;
1346
+ connector: string;
1347
+ accountId: string;
1348
+ workspaceId?: string;
1349
+ chatId: string;
1350
+ threadId?: string;
1351
+ sessionId: string;
1352
+ createdAt: number;
1353
+ updatedAt: number;
1130
1354
  }
1131
- interface ServerCapabilities {
1132
- daemonStorage?: {
1133
- instanceId: string;
1134
- pid: number;
1135
- configDir: string;
1136
- dataDir: string;
1137
- storePath: string;
1138
- };
1139
- dataScopeId?: string;
1140
- serverVersion: string;
1141
- protocol: ProtocolVersion;
1142
- features: Record<string, number>;
1143
- attachments?: AttachmentTransferCapabilities;
1144
- agentEnvironments?: AgentEnvironmentCapabilities;
1145
- /**
1146
- * Present when this daemon instance serves the MCP OAuth operation API.
1147
- * The random `instanceId` changes on every daemon start so a client can
1148
- * detect a restart and refuse to replay an operation from an old instance.
1149
- */
1150
- mcpOAuth?: McpOAuthCapabilities;
1355
+ interface ChannelDeliveryRecord {
1356
+ id: string;
1357
+ conversationId: string;
1358
+ connector: string;
1359
+ accountId: string;
1360
+ chatId: string;
1361
+ threadId?: string;
1362
+ sessionId: string;
1363
+ inputId: string;
1364
+ runId: string;
1365
+ externalMessageId: string;
1366
+ content: string;
1367
+ status: ChannelDeliveryStatus;
1368
+ attemptCount: number;
1369
+ externalDeliveryId?: string;
1370
+ error?: string;
1371
+ createdAt: number;
1372
+ updatedAt: number;
1373
+ sentAt?: number;
1374
+ platformMeta?: Record<string, unknown>;
1375
+ }
1376
+
1377
+ interface DurableChannelMessageInput {
1378
+ connector: string;
1379
+ accountId: string;
1380
+ workspaceId?: string;
1381
+ chatId: string;
1382
+ threadId?: string;
1383
+ externalMessageId: string;
1384
+ senderId: string;
1385
+ content: string;
1386
+ cwd: string;
1387
+ model: string;
1388
+ metadata?: Record<string, unknown>;
1389
+ platformMeta?: Record<string, unknown>;
1390
+ }
1391
+ interface DurableChannelMessageResult {
1392
+ conversation: ExternalConversationRecord;
1393
+ delivery: ChannelDeliveryRecord;
1394
+ duplicate: boolean;
1395
+ }
1396
+ interface RecordChannelDeliveryInput {
1397
+ status: Extract<ChannelDeliveryStatus, "sent" | "failed" | "unknown">;
1398
+ externalDeliveryId?: string;
1399
+ error?: string;
1400
+ }
1401
+ interface ChannelStatusSnapshot {
1402
+ conversations: ExternalConversationRecord[];
1403
+ deliveries: ChannelDeliveryRecord[];
1404
+ }
1405
+
1406
+ type ChannelRuntimeState = "stopped" | "starting" | "running" | "stopping" | "error";
1407
+ type ChannelDomain = "feishu" | "lark";
1408
+ interface ChannelConnectorRuntimeStatus {
1409
+ connector: string;
1410
+ enabled: boolean;
1411
+ state: ChannelRuntimeState;
1412
+ accountId?: string;
1413
+ domain?: ChannelDomain;
1414
+ botName?: string;
1415
+ startedAt?: number;
1416
+ lastError?: string;
1417
+ }
1418
+ interface ChannelDenialNotice {
1419
+ connector: string;
1420
+ sender: string;
1421
+ chatId: string;
1422
+ at: number;
1423
+ seq: number;
1424
+ }
1425
+ interface ChannelRuntimeStatus {
1426
+ bootId: string;
1427
+ connectors: ChannelConnectorRuntimeStatus[];
1428
+ recentDenials: ChannelDenialNotice[];
1429
+ }
1430
+ interface FeishuChannelSnapshot {
1431
+ configured: boolean;
1432
+ enabled: boolean;
1433
+ appId?: string;
1434
+ domain?: ChannelDomain;
1435
+ botName?: string;
1436
+ allowFrom: Array<{
1437
+ name: string;
1438
+ id: string;
1439
+ }>;
1440
+ replyAtBotNames?: string[];
1441
+ sendProgress?: boolean;
1442
+ sendToolHints?: boolean;
1443
+ }
1444
+ type FeishuRegistrationState = "idle" | "starting" | "qr_ready" | "polling" | "slow_down" | "domain_switched" | "succeeded" | "expired" | "cancelled" | "error";
1445
+ interface FeishuRegistrationSnapshot {
1446
+ state: FeishuRegistrationState;
1447
+ attempt: number;
1448
+ domain: ChannelDomain;
1449
+ qrUrl?: string;
1450
+ expiresAt?: number;
1451
+ remainingSeconds?: number;
1452
+ pollIntervalMs?: number;
1453
+ error?: {
1454
+ code: string;
1455
+ message: string;
1456
+ };
1457
+ warning?: string;
1458
+ }
1459
+ interface ChannelRuntimeControlInput {
1460
+ connector?: string;
1461
+ }
1462
+ interface FeishuConnectInput {
1463
+ appId: string;
1464
+ appSecret: string;
1465
+ domain?: ChannelDomain;
1466
+ }
1467
+ interface FeishuAllowInput {
1468
+ id: string;
1469
+ name?: string;
1470
+ }
1471
+ interface FeishuPatchInput {
1472
+ enabled?: boolean;
1473
+ sendProgress?: boolean;
1474
+ sendToolHints?: boolean;
1475
+ }
1476
+ interface FeishuRegistrationStartInput {
1477
+ domain?: ChannelDomain;
1478
+ }
1479
+
1480
+ declare const CURRENT_PROTOCOL_VERSION = 7;
1481
+ interface ProtocolVersion {
1482
+ version: number;
1483
+ }
1484
+ interface ServerCapabilities {
1485
+ daemonStorage?: {
1486
+ instanceId: string;
1487
+ pid: number;
1488
+ configDir: string;
1489
+ dataDir: string;
1490
+ storePath: string;
1491
+ };
1492
+ dataScopeId?: string;
1493
+ serverVersion: string;
1494
+ protocol: ProtocolVersion;
1495
+ features: Record<string, number>;
1496
+ attachments?: AttachmentTransferCapabilities;
1497
+ agentEnvironments?: AgentEnvironmentCapabilities;
1498
+ /**
1499
+ * Present when this daemon instance serves the MCP OAuth operation API.
1500
+ * The random `instanceId` changes on every daemon start so a client can
1501
+ * detect a restart and refuse to replay an operation from an old instance.
1502
+ */
1503
+ mcpOAuth?: McpOAuthCapabilities;
1151
1504
  }
1152
1505
  interface McpOAuthCapabilities {
1153
1506
  instanceId: string;
@@ -1175,6 +1528,67 @@ interface ProtocolCompatibility {
1175
1528
  declare function checkProtocolCompatibility(server: ServerCapabilities, client: ClientProtocolSupport): ProtocolCompatibility;
1176
1529
  declare function supportsFeature(capabilities: ServerCapabilities, feature: string, minimumVersion?: number): boolean;
1177
1530
 
1531
+ declare const MCP_OAUTH_LOGIN_UPDATED_EVENT = "mcp.oauth.login.updated";
1532
+ declare const MCP_OAUTH_LOGIN_COMPLETED_EVENT = "mcp.oauth.login.completed";
1533
+ type OAuthCallbackMode = "local" | "manual";
1534
+ type OAuthOperationState = "pending" | "completed" | "failed" | "cancelled";
1535
+ declare const MCP_OAUTH_AUTH_STATUSES: readonly ["not-configured", "not-logged-in", "valid", "expired-refreshable", "reauthentication-required", "static", "unsupported"];
1536
+ type McpOAuthAuthStatus = (typeof MCP_OAUTH_AUTH_STATUSES)[number];
1537
+ interface McpOAuthServerSnapshot {
1538
+ name: string;
1539
+ enabled: boolean;
1540
+ transport: "stdio" | "http" | "sse";
1541
+ endpoint?: string;
1542
+ authMode: "none" | "oauth" | "bearer" | "custom";
1543
+ authStatus: McpOAuthAuthStatus;
1544
+ scopes: string[];
1545
+ runtimeStatus: "connected" | "disconnected" | "error" | "unavailable";
1546
+ }
1547
+ interface McpOAuthStatusSnapshot {
1548
+ servers: McpOAuthServerSnapshot[];
1549
+ }
1550
+ interface McpOAuthLoginInput {
1551
+ oauthInstanceId: string;
1552
+ requestId: string;
1553
+ scopes?: string[];
1554
+ callbackMode: OAuthCallbackMode;
1555
+ }
1556
+ interface OAuthOperationView {
1557
+ loginId: string;
1558
+ name: string;
1559
+ state: OAuthOperationState;
1560
+ credentialCommitted: boolean;
1561
+ authorizationReady: boolean;
1562
+ errorCode?: string;
1563
+ /** Only present on an authenticated GET operation response. */
1564
+ authorizationUrl?: string;
1565
+ runtimeSync?: OAuthOperationEventData["runtimeSync"];
1566
+ }
1567
+ interface McpOAuthLoginResponse {
1568
+ loginId: string;
1569
+ operation: OAuthOperationView;
1570
+ }
1571
+ interface OAuthOperationEventData {
1572
+ loginId: string;
1573
+ name: string;
1574
+ state: OAuthOperationState;
1575
+ credentialCommitted: boolean;
1576
+ authorizationReady: boolean;
1577
+ errorCode?: string;
1578
+ runtimeSync?: {
1579
+ status: McpOAuthServerSnapshot["runtimeStatus"];
1580
+ affectedRuntimes: number;
1581
+ failures: Array<{
1582
+ runtimeId: string;
1583
+ message: string;
1584
+ }>;
1585
+ };
1586
+ }
1587
+ interface OAuthOperationEvent {
1588
+ event: typeof MCP_OAUTH_LOGIN_UPDATED_EVENT | typeof MCP_OAUTH_LOGIN_COMPLETED_EVENT;
1589
+ data: OAuthOperationEventData;
1590
+ }
1591
+
1178
1592
  declare const WORKSPACE_CHANGE_REASONS: readonly ["not_git_repository", "preexisting_dirty_overlap", "non_linear_head_change", "post_commit_worktree_changed", "git_inspection_failed", "sensitive_content_path", "concurrent_run_overlap", "execution_environment_unavailable", "daemon_restarted", "observation_budget_exceeded", "observation_cancelled"];
1179
1593
  interface WorkspaceChangeFile {
1180
1594
  path: string;
@@ -1280,6 +1694,52 @@ interface PluginPresentation {
1280
1694
  keywords?: string[];
1281
1695
  }
1282
1696
 
1697
+ /** Distribution metadata describes install candidates; it never grants runtime permission. */
1698
+ interface MarketplacePlugin {
1699
+ id: string;
1700
+ name: string;
1701
+ version: string;
1702
+ displayName?: string;
1703
+ description?: string;
1704
+ icon?: string;
1705
+ introduction?: string;
1706
+ prompts?: Array<{
1707
+ title: string;
1708
+ prompt: string;
1709
+ }>;
1710
+ homepage?: string;
1711
+ author?: {
1712
+ name: string;
1713
+ url?: string;
1714
+ email?: string;
1715
+ };
1716
+ license?: string;
1717
+ keywords?: string[];
1718
+ category: string;
1719
+ componentTypes: string[];
1720
+ artifact: {
1721
+ url: string;
1722
+ sha256: string;
1723
+ size: number;
1724
+ };
1725
+ requires: {
1726
+ host: string;
1727
+ node?: string;
1728
+ platforms?: string[];
1729
+ };
1730
+ source: {
1731
+ repository: string;
1732
+ commit: string;
1733
+ path: string;
1734
+ };
1735
+ }
1736
+ interface MarketplaceSource {
1737
+ id: string;
1738
+ name: string;
1739
+ url: string;
1740
+ enabled: boolean;
1741
+ builtin: boolean;
1742
+ }
1283
1743
  interface MarketplaceProvenance {
1284
1744
  sourceId: string;
1285
1745
  catalogUrl: string;
@@ -1289,6 +1749,111 @@ interface MarketplaceProvenance {
1289
1749
  commit: string;
1290
1750
  path: string;
1291
1751
  }
1752
+ interface MarketplaceSourceView extends MarketplaceSource {
1753
+ updatedAt?: string;
1754
+ stale?: boolean;
1755
+ error?: string;
1756
+ }
1757
+ interface MarketplaceEntry {
1758
+ sourceId: string;
1759
+ plugin: MarketplacePlugin;
1760
+ installedVersion?: string;
1761
+ installedSourceId?: string;
1762
+ updateAvailable: boolean;
1763
+ compatible: boolean;
1764
+ incompatibility?: string;
1765
+ }
1766
+ interface MarketplaceCatalog {
1767
+ sources: MarketplaceSourceView[];
1768
+ entries: MarketplaceEntry[];
1769
+ }
1770
+ interface MarketplaceSelection {
1771
+ cwd: string;
1772
+ sourceId: string;
1773
+ pluginId: string;
1774
+ version: string;
1775
+ }
1776
+ interface MarketplacePreview {
1777
+ candidateId: string;
1778
+ identity: {
1779
+ id: string;
1780
+ name: string;
1781
+ version: string;
1782
+ displayName?: string;
1783
+ };
1784
+ requestedPermissions: string[];
1785
+ approvalRequired: boolean;
1786
+ replacementRequired: boolean;
1787
+ sourceName: string;
1788
+ }
1789
+ interface MarketplaceInstallInput {
1790
+ cwd: string;
1791
+ candidateId: string;
1792
+ operationId: string;
1793
+ approvedPermissions: string[];
1794
+ allowSourceChange?: boolean;
1795
+ }
1796
+ interface MarketplaceOperation {
1797
+ operationId: string;
1798
+ status: "pending" | "installed" | "failed" | "unknown";
1799
+ pluginId?: string;
1800
+ version?: string;
1801
+ message: string;
1802
+ code?: string;
1803
+ }
1804
+
1805
+ interface MemoryEntryRecord {
1806
+ id: string;
1807
+ content: string;
1808
+ tags?: string[];
1809
+ source?: {
1810
+ type: "user_message" | "manual_remember" | "manual_edit";
1811
+ sessionId?: string;
1812
+ messageSha256?: string;
1813
+ };
1814
+ createdAt: number;
1815
+ updatedAt: number;
1816
+ /** Content and metadata fingerprint, required for conflict-aware editing. */
1817
+ revision?: string;
1818
+ }
1819
+ interface MemoryRevision {
1820
+ id: string;
1821
+ revision: string;
1822
+ }
1823
+ interface UpdateMemoryEntryInput {
1824
+ cwd: string;
1825
+ id: string;
1826
+ content: string;
1827
+ expectedRevision: string;
1828
+ }
1829
+ interface ClearMemoryInput {
1830
+ cwd: string;
1831
+ expectedEntries: MemoryRevision[];
1832
+ }
1833
+
1834
+ interface MarketplaceCatalogRequest {
1835
+ cwd: string;
1836
+ refresh?: boolean;
1837
+ }
1838
+ interface MarketplaceSourcesResponse {
1839
+ sources: MarketplaceSource[];
1840
+ }
1841
+ interface MarketplaceAddSourceRequest {
1842
+ url: string;
1843
+ }
1844
+ interface MarketplaceSourceEnabledRequest {
1845
+ enabled: boolean;
1846
+ }
1847
+ interface MarketplacePreviewRequest extends MarketplaceSelection {
1848
+ }
1849
+ interface MarketplaceInstallRequest extends MarketplaceInstallInput {
1850
+ }
1851
+ interface MarketplaceCancelRequest {
1852
+ candidateId: string;
1853
+ }
1854
+ interface MarketplaceCancelResponse {
1855
+ cancelled: true;
1856
+ }
1292
1857
 
1293
1858
  type PluginRuntimeStatus = {
1294
1859
  state: "disabled";
@@ -1354,6 +1919,17 @@ interface PluginInfo {
1354
1919
  path?: string;
1355
1920
  }>;
1356
1921
  }
1922
+ interface PluginLocalPreview {
1923
+ sourceDigest: string;
1924
+ identity: {
1925
+ id: string;
1926
+ name: string;
1927
+ version: string;
1928
+ displayName?: string;
1929
+ };
1930
+ requestedPermissions: string[];
1931
+ replacementRequired?: boolean;
1932
+ }
1357
1933
  interface PluginArchivePreview {
1358
1934
  archiveDigest: string;
1359
1935
  identity: {
@@ -1398,7 +1974,7 @@ interface HookInfo {
1398
1974
  origin: "settings" | "runtime";
1399
1975
  }
1400
1976
 
1401
- /** Read-only descriptors for capabilities already available on the daemon. */
1977
+ /** Read-only model descriptions for selection and display. */
1402
1978
  interface ModelInfo {
1403
1979
  id: string;
1404
1980
  label: string;
@@ -1437,6 +2013,31 @@ interface SkillMarketplaceSelection {
1437
2013
  version: string;
1438
2014
  sha256: string;
1439
2015
  }
2016
+ interface SkillMarketplaceEntry {
2017
+ id: string;
2018
+ name: string;
2019
+ displayName: string;
2020
+ description: string;
2021
+ version: string;
2022
+ license: string;
2023
+ requirements?: string;
2024
+ source: {
2025
+ repository: string;
2026
+ commit: string;
2027
+ path: string;
2028
+ };
2029
+ artifact: {
2030
+ url: string;
2031
+ size: number;
2032
+ sha256: string;
2033
+ };
2034
+ }
2035
+ type SkillMarketplaceInstallInput = SkillMarketplaceSelection & ({
2036
+ scope: "personal";
2037
+ } | {
2038
+ scope: "project";
2039
+ projectPath: string;
2040
+ });
1440
2041
  interface SkillInfo {
1441
2042
  id: string;
1442
2043
  name: string;
@@ -1565,6 +2166,8 @@ interface ProviderDefaultsSnapshot {
1565
2166
  }>;
1566
2167
  fastModeAvailable: false;
1567
2168
  fastModeReason: string;
2169
+ /** Present when the caller supplied a proof for its current account gateway. */
2170
+ accountGatewayMatches?: boolean;
1568
2171
  }
1569
2172
  interface ProviderConnectionTestResult {
1570
2173
  status: "verified" | "failed";
@@ -1574,6 +2177,7 @@ interface ProviderConnectionTestResult {
1574
2177
  }
1575
2178
  type ProviderDefaultsRequest = {
1576
2179
  action: "snapshot";
2180
+ accountGatewayProof?: string;
1577
2181
  } | {
1578
2182
  action: "updateModel";
1579
2183
  provider?: string;
@@ -1686,11 +2290,18 @@ interface SseStreamOptions<T = unknown> {
1686
2290
  /** 超过该毫秒数没有收到任何原始 SSE 帧(含注释帧)就中止当前连接;0/未设置表示关闭。 */
1687
2291
  idleTimeoutMs?: number;
1688
2292
  }
2293
+ interface SseReaderOptions {
2294
+ signal?: AbortSignal;
2295
+ /** Maximum UTF-8 bytes before the blank line that ends a frame. */
2296
+ maxFrameBytes?: number;
2297
+ /** Reports incoming bytes, including fragments and comments. */
2298
+ onChunk?: () => void;
2299
+ }
1689
2300
  /**
1690
2301
  * 将 SSE 字节流解析为事件异步迭代器。
1691
2302
  * `open` 负责建立连接并返回 response body,便于重试或注入。
1692
2303
  */
1693
- declare function streamServerSentEvents<T>(open: () => Promise<ReadableStream<Uint8Array>>, decode?: (value: unknown) => T): AsyncIterable<T>;
2304
+ declare function streamServerSentEvents<T>(open: () => Promise<ReadableStream<Uint8Array>>, decode?: (value: unknown) => T, options?: SseReaderOptions): AsyncIterable<T>;
1694
2305
  declare class SseTransport {
1695
2306
  private readonly transport;
1696
2307
  constructor(transport: HttpTransport);
@@ -1698,49 +2309,53 @@ declare class SseTransport {
1698
2309
  }
1699
2310
 
1700
2311
  declare class ScheduleResource {
1701
- private readonly transport;
2312
+ #private;
1702
2313
  constructor(transport: HttpTransport);
2314
+ readonly tasks: {
2315
+ list: (options?: {
2316
+ status?: ScheduledTaskRecord["status"];
2317
+ signal?: AbortSignal;
2318
+ }) => Promise<ScheduledTaskRecord[]>;
2319
+ get: (id: string, options?: {
2320
+ signal?: AbortSignal;
2321
+ }) => Promise<ScheduledTaskRecord>;
2322
+ create: (input: CreateScheduledTaskInput, options?: {
2323
+ signal?: AbortSignal;
2324
+ }) => Promise<ScheduledTaskRecord>;
2325
+ update: (id: string, input: UpdateScheduledTaskInput, options?: {
2326
+ signal?: AbortSignal;
2327
+ }) => Promise<ScheduledTaskRecord>;
2328
+ remove: (id: string, options?: {
2329
+ signal?: AbortSignal;
2330
+ }) => Promise<void>;
2331
+ trigger: (id: string, options?: {
2332
+ signal?: AbortSignal;
2333
+ requestId?: string;
2334
+ }) => Promise<ScheduledRunRecord>;
2335
+ /** Reads the exact manual request without starting work. A missing record does not authorize replay. */
2336
+ getTriggerResult: (id: string, requestId: string, options?: {
2337
+ signal?: AbortSignal;
2338
+ }) => Promise<ScheduledRunRecord | null>;
2339
+ };
2340
+ readonly runs: {
2341
+ list: (options?: {
2342
+ taskId?: string;
2343
+ unread?: boolean;
2344
+ limit?: number;
2345
+ signal?: AbortSignal;
2346
+ }) => Promise<ScheduledRunRecord[]>;
2347
+ /** Reads one run belonging to this task, regardless of how it was triggered. */
2348
+ get: (taskId: string, runId: string, options?: {
2349
+ signal?: AbortSignal;
2350
+ }) => Promise<ScheduledRunRecord | null>;
2351
+ setUnread: (id: string, unread: boolean, options?: {
2352
+ taskId?: string;
2353
+ signal?: AbortSignal;
2354
+ }) => Promise<ScheduledRunRecord>;
2355
+ };
1703
2356
  getStatus(options?: {
1704
2357
  signal?: AbortSignal;
1705
2358
  }): Promise<ScheduledTaskStatusSummary>;
1706
- listTasks(options?: {
1707
- status?: ScheduledTaskRecord["status"];
1708
- signal?: AbortSignal;
1709
- }): Promise<ScheduledTaskRecord[]>;
1710
- getTask(id: string, options?: {
1711
- signal?: AbortSignal;
1712
- }): Promise<ScheduledTaskRecord>;
1713
- createTask(input: CreateScheduledTaskInput, options?: {
1714
- signal?: AbortSignal;
1715
- }): Promise<ScheduledTaskRecord>;
1716
- updateTask(id: string, input: UpdateScheduledTaskInput, options?: {
1717
- signal?: AbortSignal;
1718
- }): Promise<ScheduledTaskRecord>;
1719
- removeTask(id: string, options?: {
1720
- signal?: AbortSignal;
1721
- }): Promise<void>;
1722
- triggerTask(id: string, options?: {
1723
- signal?: AbortSignal;
1724
- requestId?: string;
1725
- }): Promise<ScheduledRunRecord>;
1726
- /** Reads the exact manual request without starting work. A missing record does not authorize replay. */
1727
- getTriggerTaskResult(id: string, requestId: string, options?: {
1728
- signal?: AbortSignal;
1729
- }): Promise<ScheduledRunRecord | null>;
1730
- listRuns(options?: {
1731
- taskId?: string;
1732
- unread?: boolean;
1733
- limit?: number;
1734
- signal?: AbortSignal;
1735
- }): Promise<ScheduledRunRecord[]>;
1736
- /** Reads one run belonging to this task, regardless of how it was triggered. */
1737
- getRun(taskId: string, runId: string, options?: {
1738
- signal?: AbortSignal;
1739
- }): Promise<ScheduledRunRecord | null>;
1740
- setRunUnread(id: string, unread: boolean, options?: {
1741
- taskId?: string;
1742
- signal?: AbortSignal;
1743
- }): Promise<ScheduledRunRecord>;
1744
2359
  }
1745
2360
  interface ScheduledTaskStatusSummary {
1746
2361
  running: true;
@@ -1857,40 +2472,203 @@ interface SessionFileFindOptions extends SessionFileFindInput, SessionFileReques
1857
2472
  interface SessionFileSearchOptions extends SessionFileSearchInput, SessionFileRequestOptions {
1858
2473
  }
1859
2474
 
1860
- /** Public Agent lifecycle request, response and synchronization types. */
1861
-
1862
- /** `BobanNomiClient` 构造参数。 */
1863
- interface BobanNomiClientOptions {
1864
- /** daemon HTTP 根地址,例如 `http://127.0.0.1:8787`。 */
1865
- baseUrl: string;
1866
- /** Bearer token;与 daemon registry 中的 token 对应。 */
1867
- token?: string;
1868
- /** 可注入的 fetch,便于测试或自定义传输。 */
1869
- fetch?: typeof fetch;
2475
+ type CommandKind = "session" | "template";
2476
+ type CommandSelection = "execute" | "submenu" | "insert";
2477
+ type CommandSource = "builtin" | "bundled" | "user" | "plugin" | "project";
2478
+ interface CommandCatalogEntryBase {
2479
+ name: string;
2480
+ displayName?: string;
2481
+ description?: string;
2482
+ source?: CommandSource;
2483
+ argumentHint?: string;
2484
+ selection?: CommandSelection;
2485
+ requiresEmptyComposer?: boolean;
1870
2486
  }
1871
- interface BobanNomiServerHealth {
1872
- ok: true;
1873
- version?: string;
1874
- startedAt: number;
1875
- uptimeMs: number;
1876
- sessionCount: number;
1877
- activeRunCount: number;
1878
- queuedRunCount: number;
2487
+ type CommandCatalogEntry = CommandCatalogEntryBase & ({
2488
+ kind: "session";
2489
+ path?: never;
2490
+ skillName?: never;
2491
+ } | {
2492
+ kind: "template";
2493
+ path: string;
2494
+ skillName: string;
2495
+ });
2496
+ interface ListCommandsOptions {
2497
+ cwd: string;
1879
2498
  }
1880
- /** `GET /sessions` 查询参数。 */
1881
- interface ListSessionsOptions {
1882
- cwd?: string;
2499
+ interface ListProjectsOptions {
1883
2500
  includeArchived?: boolean;
1884
- includeChildren?: boolean;
1885
- limit?: number;
1886
2501
  }
1887
- /** `POST /sessions` 请求体。 */
1888
- interface ExecutionInstructions {
1889
- revision: number;
2502
+ interface ProviderInfo {
2503
+ name: string;
2504
+ displayName: string;
2505
+ hasKey: boolean;
2506
+ active: boolean;
2507
+ local?: boolean;
2508
+ custom?: boolean;
2509
+ requiresApiKey?: boolean;
2510
+ source?: "builtin" | "catalog" | "custom" | "subscription";
2511
+ }
2512
+ type McpRuntimeStatus = "connected" | "disconnected" | "error" | "unavailable";
2513
+ interface McpRuntimeSyncResult {
2514
+ status: McpRuntimeStatus;
2515
+ affectedRuntimes: number;
2516
+ failures: Array<{
2517
+ runtimeId: string;
2518
+ message: string;
2519
+ }>;
2520
+ }
2521
+ interface MemoryListResponse {
2522
+ directory: string;
2523
+ entries: MemoryEntryRecord[];
2524
+ }
2525
+ interface AuthStatus {
2526
+ codex: {
2527
+ configured: boolean;
2528
+ state: string;
2529
+ source: string;
2530
+ detail?: string;
2531
+ profileLabel?: string;
2532
+ };
2533
+ storedProviders: string[];
2534
+ envProviders: Array<{
2535
+ name: string;
2536
+ envKey: string;
2537
+ }>;
2538
+ }
2539
+ interface StartDreamResponse {
2540
+ taskId: string;
2541
+ }
2542
+ interface OutputStyleInfo {
2543
+ name: string;
1890
2544
  content: string;
2545
+ source: "builtin" | "user";
1891
2546
  }
1892
2547
 
1893
- type CreateClientSessionInput = CreateSessionInput;
2548
+ interface AttachmentStorageIssue {
2549
+ code: "missing_blob" | "size_mismatch" | "orphan_blob" | "stale_lease" | "deleted_asset_retained";
2550
+ severity: "warning" | "error";
2551
+ assetId?: string;
2552
+ sha256?: string;
2553
+ expectedSizeBytes?: number;
2554
+ actualSizeBytes?: number;
2555
+ collectible?: boolean;
2556
+ }
2557
+ interface AttachmentStorageReport {
2558
+ summary: {
2559
+ assets: Record<"importing" | "ready" | "failed" | "deleted", number>;
2560
+ uniqueBlobs: number;
2561
+ physicalBytes: number;
2562
+ logicalBytes: number;
2563
+ deduplicatedBytes: number;
2564
+ activeLeases: number;
2565
+ expiredLeases: number;
2566
+ reclaimableBytes: number;
2567
+ };
2568
+ issues: AttachmentStorageIssue[];
2569
+ latestGcAudit?: {
2570
+ id: string;
2571
+ policy: string;
2572
+ result: unknown;
2573
+ createdAt: number;
2574
+ };
2575
+ }
2576
+ interface AttachmentStorageRepairResult {
2577
+ expiredLeases: number;
2578
+ deletedOrphanBlobs: number;
2579
+ releasedBytes: number;
2580
+ }
2581
+ interface AttachmentStorageGcResult {
2582
+ scannedAssets: number;
2583
+ expiredLeases: number;
2584
+ deletedAssets: number;
2585
+ deletedBlobs: number;
2586
+ releasedBytes: number;
2587
+ skipped: Record<"notDeleted" | "gracePeriod" | "missingHash" | "referenced" | "activeLease" | "sharedBlob", number>;
2588
+ errors: Array<{
2589
+ assetId: string;
2590
+ code: "blob_delete_failed";
2591
+ }>;
2592
+ }
2593
+
2594
+ interface PluginListResult {
2595
+ plugins: PluginInfo[];
2596
+ warnings: string[];
2597
+ }
2598
+ interface ReloadPluginsResponse extends PluginListResult {
2599
+ message: string;
2600
+ }
2601
+ /** Paths are read by the daemon in its execution environment. */
2602
+ interface PluginLocalPreviewInput {
2603
+ cwd: string;
2604
+ sourcePath: string;
2605
+ }
2606
+ interface PluginLocalInstallInput extends PluginLocalPreviewInput {
2607
+ scope: "user";
2608
+ approvedPermissions: string[];
2609
+ /** Pass the preview digest to reject a directory that changed before install. */
2610
+ expectedSourceDigest?: string;
2611
+ allowSourceChange?: boolean;
2612
+ link?: boolean;
2613
+ }
2614
+ interface PluginArchivePreviewInput {
2615
+ cwd: string;
2616
+ archivePath: string;
2617
+ }
2618
+ interface PluginArchiveInstallInput extends PluginArchivePreviewInput {
2619
+ expectedArchiveDigest: string;
2620
+ approvedPermissions: string[];
2621
+ allowSourceChange?: boolean;
2622
+ }
2623
+ interface PluginGitPreviewInput {
2624
+ cwd: string;
2625
+ url: string;
2626
+ ref?: string;
2627
+ }
2628
+ interface PluginGitInstallInput extends PluginGitPreviewInput {
2629
+ expectedSourceDigest: string;
2630
+ approvedPermissions: string[];
2631
+ allowSourceChange?: boolean;
2632
+ }
2633
+
2634
+ /** Public Agent lifecycle request, response and synchronization types. */
2635
+
2636
+ /** `BobanNomiClient` 构造参数。 */
2637
+ interface BobanNomiClientOptions {
2638
+ /** daemon HTTP 根地址,例如 `http://127.0.0.1:8787`。 */
2639
+ baseUrl: string;
2640
+ /** Bearer token;与 daemon registry 中的 token 对应。 */
2641
+ token?: string;
2642
+ /** 可注入的 fetch,便于测试或自定义传输。 */
2643
+ fetch?: typeof fetch;
2644
+ /** Optional display catalog. It supplies models.list() without configuring the daemon. */
2645
+ providers?: readonly ModelProviderInfo[] | ((options: {
2646
+ signal?: AbortSignal;
2647
+ }) => Promise<readonly ModelProviderInfo[]>);
2648
+ }
2649
+ interface BobanNomiServerHealth {
2650
+ ok: true;
2651
+ version?: string;
2652
+ startedAt: number;
2653
+ uptimeMs: number;
2654
+ sessionCount: number;
2655
+ activeRunCount: number;
2656
+ queuedRunCount: number;
2657
+ }
2658
+ /** `GET /sessions` 查询参数。 */
2659
+ interface ListSessionsOptions {
2660
+ cwd?: string;
2661
+ includeArchived?: boolean;
2662
+ includeChildren?: boolean;
2663
+ limit?: number;
2664
+ }
2665
+ /** `POST /sessions` 请求体。 */
2666
+ interface ExecutionInstructions {
2667
+ revision: number;
2668
+ content: string;
2669
+ }
2670
+
2671
+ type CreateClientSessionInput = CreateSessionInput;
1894
2672
  type ForkClientSessionInput = ForkSessionInput;
1895
2673
  interface EditLatestClientPromptInput {
1896
2674
  outputSchema?: Record<string, unknown>;
@@ -1899,6 +2677,7 @@ interface EditLatestClientPromptInput {
1899
2677
  sourceMessageId: string;
1900
2678
  attachments?: AdmitPromptAttachmentInput[];
1901
2679
  metadata?: Record<string, unknown>;
2680
+ expectedModelConnection?: ExpectedModelConnection;
1902
2681
  }
1903
2682
  interface PromoteQueuedClientPromptInput {
1904
2683
  queuedRunId: string;
@@ -1924,12 +2703,13 @@ interface AdmitClientPromptInput {
1924
2703
  delivery?: InputDelivery;
1925
2704
  /** Bind a follow-up to the running reply observed by the caller. */
1926
2705
  expectedActiveRunId?: string;
2706
+ /** Pin this submission to the selected gateway connection. */
2707
+ expectedModelConnection?: ExpectedModelConnection;
1927
2708
  outputSchema?: Record<string, unknown>;
1928
2709
  attachments?: AdmitPromptAttachmentInput[];
1929
2710
  metadata?: Record<string, unknown>;
1930
2711
  }
1931
2712
  /** Session identity is carried by the URL; only lifecycle prompt fields are public. */
1932
- type PromptInputForClient = AdmitClientPromptInput;
1933
2713
  /** `POST /sessions/:id/runs/:runId/resume` 请求体。`id` 用于安全重试。 */
1934
2714
  interface ResumeInterruptedRunInput {
1935
2715
  /** If supplied, must equal the original prompt's contract. */
@@ -1983,18 +2763,6 @@ interface PromptResponse {
1983
2763
  interface ResumeInterruptedRunResponse extends PromptResponse {
1984
2764
  source_run: SessionRunRecord;
1985
2765
  }
1986
- /** `PATCH /sessions/:id` 请求体。 */
1987
- interface UpdateClientSessionInput {
1988
- title?: string;
1989
- metadata?: {
1990
- app?: Record<string, unknown>;
1991
- };
1992
- }
1993
- interface CompactSessionResponse {
1994
- messageCount: number;
1995
- messages: SessionMessageRecord[];
1996
- parts: SessionMessagePartRecord[];
1997
- }
1998
2766
  interface RewindSessionResponse {
1999
2767
  turns: number;
2000
2768
  removed: number;
@@ -2021,11 +2789,22 @@ interface SessionExportResponse {
2021
2789
  filepath: string;
2022
2790
  messageCount: number;
2023
2791
  }
2792
+ /** Filters for jobs belonging to one session. */
2793
+ interface ListSessionJobsOptions {
2794
+ kinds?: JobKind[];
2795
+ statuses?: JobStatus[];
2796
+ startedAfter?: number;
2797
+ startedBefore?: number;
2798
+ updatedAfter?: number;
2799
+ updatedBefore?: number;
2800
+ includeFinished?: boolean;
2801
+ limit?: number;
2802
+ signal?: AbortSignal;
2803
+ }
2024
2804
  /** `POST /background-shells` 请求体。 */
2025
2805
  interface CreateBackgroundShellInput {
2026
2806
  /** Stable caller identity for safe retries of one logical creation request. */
2027
2807
  requestId?: string;
2028
- sessionId: string;
2029
2808
  command: string;
2030
2809
  cwd?: string;
2031
2810
  description?: string;
@@ -2082,90 +2861,224 @@ declare class ProtocolClient {
2082
2861
  capabilities(options?: CapabilitiesOptions): Promise<ServerCapabilities>;
2083
2862
  }
2084
2863
 
2085
- /** Runtime discovery and authorized model-provider management. */
2086
- declare class RuntimeResource {
2864
+ declare class EventResource {
2087
2865
  private readonly transport;
2088
- constructor(transport: HttpTransport);
2089
- listModels(options?: {
2090
- signal?: AbortSignal;
2091
- }): Promise<ModelProviderInfo[]>;
2092
- modelProviders(input?: ModelProviderRequest, options?: {
2093
- signal?: AbortSignal;
2094
- }): Promise<ModelProviderConnection[]>;
2095
- providerDefaults(input: Extract<ProviderDefaultsRequest, {
2096
- action: "test";
2097
- }>, options?: {
2098
- signal?: AbortSignal;
2099
- }): Promise<ProviderConnectionTestResult>;
2100
- providerDefaults(input?: Exclude<ProviderDefaultsRequest, {
2101
- action: "test";
2102
- }>, options?: {
2103
- signal?: AbortSignal;
2104
- }): Promise<ProviderDefaultsSnapshot>;
2105
- listAgentPersonas(options?: {
2106
- signal?: AbortSignal;
2107
- }): Promise<AgentPersonaInfo[]>;
2108
- listSkills(options?: {
2109
- signal?: AbortSignal;
2110
- }): Promise<SkillSnapshot>;
2111
- getSessionMcp(sessionId: string, options?: {
2866
+ private readonly sse;
2867
+ constructor(transport: HttpTransport, sse: SseTransport);
2868
+ /** `GET /events` — 用于 attach 时的历史 replay。 */
2869
+ list(options?: ListEventsOptions & {
2112
2870
  signal?: AbortSignal;
2113
- }): Promise<McpServerStatus[]>;
2871
+ }): Promise<SessionEventRecord[]>;
2872
+ stream(options?: Omit<EventSyncOptions, "reconnectDelayMs"> & {
2873
+ transportReconnect?: boolean;
2874
+ onOpen?: () => void;
2875
+ }): AsyncIterable<SessionEventRecord>;
2114
2876
  }
2115
2877
 
2116
- type ReadOptions = {
2117
- signal?: AbortSignal;
2118
- };
2119
- /** Observation of terminals belonging to one authorized session. */
2120
- declare class SessionTerminalResource {
2121
- private readonly transport;
2122
- constructor(transport: HttpTransport);
2123
- list(sessionId: string, options?: ReadOptions): Promise<TerminalSessionInfo[]>;
2124
- read(sessionId: string, terminalId: string, options?: ReadOptions & {
2125
- after?: number;
2126
- maxChars?: number;
2127
- }): Promise<TerminalReadResult>;
2128
- stream(sessionId: string, terminalId: string, options?: ReadOptions): Promise<AsyncIterable<TerminalEvent>>;
2878
+ interface SyncEventsClient {
2879
+ sessions: {
2880
+ byId(sessionId: string): {
2881
+ getState(options?: {
2882
+ signal?: AbortSignal;
2883
+ partView?: "summary";
2884
+ }): Promise<AgentSessionStateSnapshot>;
2885
+ };
2886
+ };
2887
+ events: {
2888
+ list(options?: ListEventsOptions & {
2889
+ signal?: AbortSignal;
2890
+ }): Promise<SessionEventRecord[]>;
2891
+ stream(options?: Omit<EventSyncOptions, "reconnectDelayMs"> & {
2892
+ transportReconnect?: boolean;
2893
+ }): AsyncIterable<SessionEventRecord>;
2894
+ };
2895
+ }
2896
+ type GlobalEventReducer = (state: BobanNomiClientState, event: SessionEventRecord) => BobanNomiClientState;
2897
+ declare function hydrateState(events: Iterable<SessionEventRecord>): BobanNomiClientState;
2898
+ /** 公开迭代接口保留原有默认空闲超时和全局 replay 结束标记。 */
2899
+ declare function syncEvents(client: SyncEventsClient, options?: EventSyncOptions & {
2900
+ globalReducer?: GlobalEventReducer;
2901
+ }): AsyncIterable<SyncEventUpdate>;
2902
+
2903
+ interface SessionMessageWithParts {
2904
+ message: SessionMessageRecord;
2905
+ parts: SessionMessagePartRecord[];
2906
+ }
2907
+ declare function selectSessionMessagesWithParts(bucket: SessionBucket | undefined): SessionMessageWithParts[];
2908
+ /**
2909
+ * Default display view: hides superseded parts and drops assistant messages that
2910
+ * have no visible parts left. The raw state keeps the diagnostic records.
2911
+ */
2912
+ declare function getVisibleSessionMessages(bucket: SessionBucket | undefined): SessionMessageWithParts[];
2913
+ declare function selectSessionInputs(bucket: SessionBucket | undefined): SessionInputRecord[];
2914
+ declare function selectSessionOrderedMessages(bucket: SessionBucket | undefined): SessionMessageRecord[];
2915
+ declare function selectSessionParts(bucket: SessionBucket | undefined): SessionMessagePartRecord[];
2916
+ declare function selectSessionRuns(bucket: SessionBucket | undefined): SessionRunRecord[];
2917
+ /** Current bounded-retry wait, if the latest active run is waiting. */
2918
+ declare function selectSessionModelRetry(bucket: SessionBucket | undefined): SessionModelRetryState | undefined;
2919
+ /** Aggregated usage completeness for the most recently updated run. */
2920
+ declare function selectSessionModelUsage(bucket: SessionBucket | undefined): SessionModelUsageSummary | undefined;
2921
+ declare function selectSessionTasks(bucket: SessionBucket | undefined): SessionExecutionRecord[];
2922
+ declare function selectSessionPermissions(bucket: SessionBucket | undefined): PermissionRequestRecord[];
2923
+ declare function selectFirstPendingPermission(state: BobanNomiClientState, sessionId?: string): PermissionRequestRecord | undefined;
2924
+
2925
+ interface RunResult {
2926
+ run: SessionRunRecord;
2927
+ messages: SessionMessageWithParts[];
2129
2928
  }
2130
2929
 
2131
- type Options = {
2930
+ type RequestOptions$8 = {
2132
2931
  signal?: AbortSignal;
2133
2932
  };
2134
- declare class SessionManagementResource {
2135
- private readonly transport;
2136
- private authenticatedCapabilities?;
2137
- constructor(transport: HttpTransport);
2138
- private ready;
2139
- getRevision(sessionId: string, input: {
2140
- action: SessionManagementAction;
2141
- }, options?: Options): Promise<SessionResourceRevision>;
2142
- private mutate;
2143
- rename(id: string, input: {
2933
+ /** Operations for one session, using the connection that created this handle. */
2934
+ interface SessionHandle {
2935
+ readonly id: string;
2936
+ get(options?: RequestOptions$8): Promise<SessionRecord>;
2937
+ getState(options?: RequestOptions$8 & {
2938
+ partView?: "summary";
2939
+ }): Promise<AgentSessionStateSnapshot>;
2940
+ /** Merge JSON fields into this session's application metadata on the daemon. */
2941
+ updateAppMetadata(metadata: Record<string, unknown>, options?: RequestOptions$8): Promise<SessionRecord>;
2942
+ /** Submit an input and return its admission result. */
2943
+ prompt(input: AdmitClientPromptInput, options?: RequestOptions$8): Promise<PromptResponse>;
2944
+ /** Observe an existing run until it reaches a durable terminal state. */
2945
+ waitForRun(runId: string, options?: RequestOptions$8): Promise<RunResult>;
2946
+ interrupt(options?: RequestOptions$8 & {
2947
+ expectedRunId?: string;
2948
+ }): Promise<InterruptSessionResponse>;
2949
+ getControls(options?: RequestOptions$8): Promise<SessionControls>;
2950
+ getControlResult(input: {
2144
2951
  requestId: string;
2145
- title: string;
2146
- expectedRevision: number;
2147
- }, options?: Options): Promise<SessionMutationPublicReceipt>;
2148
- setPinned(id: string, input: {
2952
+ original: SessionControlOriginal;
2953
+ }, options?: RequestOptions$8): Promise<SessionControlReceipt | null>;
2954
+ getContextUsage(options?: RequestOptions$8): Promise<ContextUsageSnapshot>;
2955
+ getUsage(options?: RequestOptions$8): Promise<SessionUsageResponse>;
2956
+ editLatestPrompt(input: EditLatestClientPromptInput, options?: RequestOptions$8): Promise<PromptResponse>;
2957
+ resumeInterruptedRun(runId: string, input?: ResumeInterruptedRunInput, options?: RequestOptions$8): Promise<ResumeInterruptedRunResponse>;
2958
+ fork(input?: ForkClientSessionInput, options?: RequestOptions$8): Promise<SessionRecord>;
2959
+ /** Compact the transcript using the recorded configuration revision and request ID. */
2960
+ compact(input: {
2149
2961
  requestId: string;
2150
- pinned: boolean;
2151
2962
  expectedRevision: number;
2152
- }, options?: Options): Promise<SessionMutationPublicReceipt>;
2153
- archive(id: string, input: {
2154
- requestId: string;
2155
- expectedTreeRevision: string;
2156
- }, options?: Options): Promise<SessionMutationPublicReceipt>;
2157
- delete(id: string, input: {
2158
- requestId: string;
2159
- expectedTreeRevision: string;
2160
- }, options?: Options): Promise<SessionMutationPublicReceipt>;
2161
- getMutation(sessionId: string, requestId: string, options?: Options): Promise<SessionMutationPublicReceipt | null>;
2963
+ }, options?: RequestOptions$8): Promise<SessionControlReceipt>;
2964
+ rewind(input?: {
2965
+ count?: number;
2966
+ }, options?: RequestOptions$8): Promise<RewindSessionResponse>;
2967
+ remember(options?: RequestOptions$8): Promise<RememberSessionResponse>;
2968
+ export(input?: {
2969
+ filename?: string;
2970
+ json?: boolean;
2971
+ }, options?: RequestOptions$8): Promise<SessionExportResponse>;
2972
+ /** Read or update settings, and recover the result of the original update. */
2973
+ readonly configuration: {
2974
+ get(options?: RequestOptions$8): Promise<SessionConfigurationSnapshot>;
2975
+ update(input: ConfigureClientSessionInput, options?: RequestOptions$8): Promise<SessionControlReceipt>;
2976
+ getResult(input: SessionConfigurationResultInput, options?: RequestOptions$8): Promise<SessionControlReceipt | null>;
2977
+ };
2978
+ readonly queue: {
2979
+ promote(inputId: string, input: PromoteQueuedClientPromptInput, options?: RequestOptions$8): Promise<PromoteQueuedPromptResponse>;
2980
+ cancel(inputId: string, input: CancelQueuedClientPromptInput, options: RequestOptions$8 & {
2981
+ responseMode: "receipt";
2982
+ }): Promise<QueuedPromptCancelReceipt>;
2983
+ cancel(inputId: string, input: CancelQueuedClientPromptInput, options?: RequestOptions$8 & {
2984
+ responseMode?: "snapshot";
2985
+ }): Promise<CancelQueuedPromptResponse>;
2986
+ };
2987
+ readonly goal: {
2988
+ get(): Promise<SessionGoal | null>;
2989
+ create(input: CreateSessionGoalInput): Promise<SessionGoal>;
2990
+ update(goalId: string, input: UpdateSessionGoalInput): Promise<SessionGoal>;
2991
+ applyAction(goalId: string, input: GoalActionInput): Promise<SessionGoal>;
2992
+ getRequest(requestId: string): Promise<SessionGoalRequestReceipt>;
2993
+ };
2994
+ /** Perform versioned management operations and query their durable receipts. */
2995
+ readonly management: {
2996
+ /** Interrupt active work before archiving the session tree. */
2997
+ archiveAndInterrupt(options?: RequestOptions$8): Promise<SessionRecord>;
2998
+ getRevision(input: {
2999
+ action: SessionManagementAction;
3000
+ }, options?: RequestOptions$8): Promise<SessionResourceRevision>;
3001
+ rename(input: {
3002
+ requestId: string;
3003
+ title: string;
3004
+ expectedRevision: number;
3005
+ }, options?: RequestOptions$8): Promise<SessionMutationPublicReceipt>;
3006
+ setPinned(input: {
3007
+ requestId: string;
3008
+ pinned: boolean;
3009
+ expectedRevision: number;
3010
+ }, options?: RequestOptions$8): Promise<SessionMutationPublicReceipt>;
3011
+ archive(input: {
3012
+ requestId: string;
3013
+ expectedTreeRevision: string;
3014
+ }, options?: RequestOptions$8): Promise<SessionMutationPublicReceipt>;
3015
+ delete(input: {
3016
+ requestId: string;
3017
+ expectedTreeRevision: string;
3018
+ }, options?: RequestOptions$8): Promise<SessionMutationPublicReceipt>;
3019
+ getMutation(requestId: string, options?: RequestOptions$8): Promise<SessionMutationPublicReceipt | null>;
3020
+ };
3021
+ readonly messages: {
3022
+ list(options?: ListMessagesOptions & RequestOptions$8): Promise<SessionMessageRecord[]>;
3023
+ listParts(options?: ListClientMessagePartsOptions & RequestOptions$8): Promise<SessionMessagePartRecord[]>;
3024
+ getPart(messageId: string, partId: string, options?: RequestOptions$8): Promise<SessionMessagePartRecord>;
3025
+ };
3026
+ /** Read-only access. Paths are relative to the session's execution directory on the daemon. */
3027
+ readonly files: {
3028
+ list(options?: SessionFileListOptions): Promise<SessionDirectoryResult>;
3029
+ stat(path: string, options?: SessionFileRequestOptions): Promise<SessionFileInfo>;
3030
+ readText(path: string, options?: SessionFileReadOptions): Promise<SessionTextFileResult>;
3031
+ find(options: SessionFileFindOptions): Promise<SessionFindFilesResult>;
3032
+ search(options: SessionFileSearchOptions): Promise<SessionSearchFilesResult>;
3033
+ };
3034
+ /** Observe terminals already associated with this session. */
3035
+ readonly terminals: {
3036
+ list(options?: RequestOptions$8): Promise<TerminalSessionInfo[]>;
3037
+ read(terminalId: string, options?: RequestOptions$8 & {
3038
+ after?: number;
3039
+ maxChars?: number;
3040
+ }): Promise<TerminalReadResult>;
3041
+ stream(terminalId: string, options?: RequestOptions$8): Promise<AsyncIterable<TerminalEvent>>;
3042
+ };
3043
+ /** Manage background jobs and subagent runs belonging to this session. */
3044
+ readonly jobs: {
3045
+ list(options?: ListSessionJobsOptions): Promise<JobListResult>;
3046
+ createBackgroundShell(input: CreateBackgroundShellInput, options?: RequestOptions$8): Promise<CreateBackgroundShellResult>;
3047
+ read(target: JobTarget, options?: RequestOptions$8 & {
3048
+ after?: number;
3049
+ maxChars?: number;
3050
+ }): Promise<JobReadResult>;
3051
+ wait(target: JobTarget, input?: {
3052
+ timeoutMs?: number;
3053
+ after?: number;
3054
+ maxChars?: number;
3055
+ }, options?: RequestOptions$8): Promise<JobWaitResult>;
3056
+ send(target: JobTarget, input: {
3057
+ data: string;
3058
+ }, options?: RequestOptions$8): Promise<JobInputReceipt | void>;
3059
+ cancel(target: JobTarget, input: {
3060
+ reason?: string;
3061
+ } | undefined, options: RequestOptions$8 & {
3062
+ responseMode: "receipt";
3063
+ }): Promise<JobCancelReceipt>;
3064
+ cancel(target: JobTarget, input?: {
3065
+ reason?: string;
3066
+ }, options?: RequestOptions$8 & {
3067
+ responseMode?: "snapshot";
3068
+ }): Promise<JobSnapshot>;
3069
+ };
3070
+ /** Read MCP connection status for this session. The daemon may initialize its runtime. */
3071
+ readonly mcp: {
3072
+ list(options?: RequestOptions$8): Promise<McpServerStatus[]>;
3073
+ };
2162
3074
  }
2163
3075
 
3076
+ /** Find, prepare, and create sessions on one daemon connection. */
2164
3077
  declare class SessionResource {
2165
- private readonly transport;
2166
- readonly resources: SessionManagementResource;
2167
- readonly terminals: SessionTerminalResource;
2168
- constructor(transport: HttpTransport);
3078
+ #private;
3079
+ constructor(transport: HttpTransport, events?: EventResource);
3080
+ /** Bind a session ID locally. Operations use this resource's daemon connection when called. */
3081
+ byId(sessionId: string): SessionHandle;
2169
3082
  /** `GET /sessions/search` - search saved conversation text without opening it. */
2170
3083
  search(options: SearchSessionsOptions & {
2171
3084
  signal?: AbortSignal;
@@ -2185,160 +3098,46 @@ declare class SessionResource {
2185
3098
  getDraftComposerOptions(input: DraftComposerTarget, options?: {
2186
3099
  signal?: AbortSignal;
2187
3100
  }): Promise<DraftComposerOptions>;
2188
- getControls(sessionId: string, options?: {
2189
- signal?: AbortSignal;
2190
- }): Promise<SessionControls>;
2191
- getControlResult(sessionId: string, input: {
2192
- requestId: string;
2193
- original: SessionControlOriginal;
2194
- }, options?: {
2195
- signal?: AbortSignal;
2196
- }): Promise<SessionControlReceipt | null>;
2197
- /** Current context assembly requires execution authority; /usage is historical billing. */
2198
- getContextUsage(sessionId: string, options?: {
2199
- signal?: AbortSignal;
2200
- }): Promise<ContextUsageSnapshot>;
2201
- /** `GET /sessions/:id` */
2202
- get(sessionId: string, options?: {
2203
- signal?: AbortSignal;
2204
- }): Promise<SessionRecord>;
2205
3101
  /** `POST /sessions` */
2206
- create(input: CreateClientSessionInput, options?: {
3102
+ create(input: SessionCreationInput, options?: {
2207
3103
  signal?: AbortSignal;
2208
3104
  }): Promise<SessionRecord>;
2209
3105
  getConfigurationOptions(input: {
2210
3106
  cwd: string;
2211
3107
  projectId?: string;
3108
+ } | {
3109
+ projectId: string;
3110
+ cwd?: never;
2212
3111
  }, options?: {
2213
3112
  signal?: AbortSignal;
2214
3113
  }): Promise<SessionConfigurationOptions>;
2215
3114
  getCreationResult(input: {
2216
3115
  requestId: string;
2217
3116
  sessionId: string;
2218
- original: DispatchedSessionCreation;
3117
+ original: DispatchedSessionCreationRequest;
2219
3118
  }, options?: {
2220
3119
  signal?: AbortSignal;
2221
3120
  }): Promise<SessionCreationReceipt | null>;
2222
- getConfiguration(sessionId: string, options?: {
2223
- signal?: AbortSignal;
2224
- }): Promise<SessionConfigurationSnapshot>;
2225
- configure(sessionId: string, input: ConfigureClientSessionInput, options?: {
2226
- signal?: AbortSignal;
2227
- }): Promise<SessionControlReceipt>;
2228
- getConfigurationResult(sessionId: string, input: SessionConfigurationResultInput, options?: {
2229
- signal?: AbortSignal;
2230
- }): Promise<SessionControlReceipt | null>;
2231
- /** `PATCH /sessions/:id` - update title or application metadata. */
2232
- update(sessionId: string, input: UpdateClientSessionInput, options?: {
2233
- signal?: AbortSignal;
2234
- }): Promise<SessionRecord>;
2235
- /** `POST /sessions/:id/fork` */
2236
- fork(sessionId: string, input?: ForkClientSessionInput, options?: {
2237
- signal?: AbortSignal;
2238
- }): Promise<SessionRecord>;
2239
- /** `DELETE /sessions/:id` */
2240
- archive(sessionId: string, options?: {
2241
- signal?: AbortSignal;
2242
- }): Promise<SessionRecord>;
2243
- /** `DELETE /sessions/:id/hard` */
2244
- delete(sessionId: string, options?: {
2245
- signal?: AbortSignal;
2246
- }): Promise<string[]>;
2247
- /** `GET /sessions/:id/state` - atomic attach snapshot plus SSE cursor. */
2248
- getState(sessionId: string, options?: {
2249
- signal?: AbortSignal;
2250
- partView?: "summary";
2251
- }): Promise<AgentSessionStateSnapshot>;
2252
- /** `GET /sessions/:id/messages` */
2253
- listMessages(sessionId: string, options?: ListMessagesOptions & {
2254
- signal?: AbortSignal;
2255
- }): Promise<SessionMessageRecord[]>;
2256
- /** `GET /sessions/:id/parts` */
2257
- listMessageParts(sessionId: string, options?: ListClientMessagePartsOptions & {
2258
- signal?: AbortSignal;
2259
- }): Promise<SessionMessagePartRecord[]>;
2260
- /** Read full canonical content for one part in its session/message scope. */
2261
- getMessagePart(sessionId: string, messageId: string, partId: string, options?: {
2262
- signal?: AbortSignal;
2263
- }): Promise<SessionMessagePartRecord>;
2264
- /** `POST /sessions/:id/prompts` — 提交用户输入并触发/排队一次 run。 */
2265
- admitPrompt(sessionId: string, input: AdmitClientPromptInput, options?: {
2266
- signal?: AbortSignal;
2267
- }): Promise<PromptResponse>;
2268
- /** `POST /sessions/:id/prompts/latest/edit` */
2269
- editLatestPrompt(sessionId: string, input: EditLatestClientPromptInput, options?: {
2270
- signal?: AbortSignal;
2271
- }): Promise<PromptResponse>;
2272
- /** Promote one durable queued prompt into the exact active run. */
2273
- promoteQueuedPrompt(sessionId: string, inputId: string, input: PromoteQueuedClientPromptInput, options?: {
2274
- signal?: AbortSignal;
2275
- }): Promise<PromoteQueuedPromptResponse>;
2276
- /** Cancel one durable prompt that is still waiting in the run queue. */
2277
- cancelQueuedPrompt(sessionId: string, inputId: string, input: CancelQueuedClientPromptInput, options: {
2278
- signal?: AbortSignal;
2279
- responseMode: "receipt";
2280
- }): Promise<QueuedPromptCancelReceipt>;
2281
- cancelQueuedPrompt(sessionId: string, inputId: string, input: CancelQueuedClientPromptInput, options?: {
2282
- signal?: AbortSignal;
2283
- responseMode?: "snapshot";
2284
- }): Promise<CancelQueuedPromptResponse>;
2285
- /**
2286
- * `POST /sessions/:id/runs/:runId/resume` — 显式重放一次中断 run 的原始 prompt。
2287
- * 服务端复用原 Input,创建一个带恢复来源的新 Run。旧模型连接已经结束。
2288
- */
2289
- resumeInterruptedRun(sessionId: string, runId: string, input?: ResumeInterruptedRunInput, options?: {
2290
- signal?: AbortSignal;
2291
- }): Promise<ResumeInterruptedRunResponse>;
2292
- /** `POST /sessions/:id/interrupt` — 中断当前/排队中的 run。 */
2293
- interrupt(sessionId: string, options?: {
2294
- signal?: AbortSignal;
2295
- expectedRunId?: string;
2296
- }): Promise<InterruptSessionResponse>;
2297
- /** `POST /sessions/:id/compact` */
2298
- compact(sessionId: string, options?: {
2299
- signal?: AbortSignal;
2300
- requestId?: string;
2301
- expectedRevision?: number;
2302
- }): Promise<CompactSessionResponse>;
2303
- /** `POST /sessions/:id/rewind` */
2304
- rewind(sessionId: string, input?: {
2305
- count?: number;
2306
- }, options?: {
2307
- signal?: AbortSignal;
2308
- }): Promise<RewindSessionResponse>;
2309
- /** `POST /sessions/:id/remember` */
2310
- remember(sessionId: string, options?: {
2311
- signal?: AbortSignal;
2312
- }): Promise<RememberSessionResponse>;
2313
- /** `POST /sessions/:id/export` */
2314
- export(sessionId: string, input?: {
2315
- filename?: string;
2316
- json?: boolean;
2317
- }, options?: {
2318
- signal?: AbortSignal;
2319
- }): Promise<SessionExportResponse>;
2320
- /** `GET /sessions/:id/usage` */
2321
- getUsage(sessionId: string, options?: {
2322
- signal?: AbortSignal;
2323
- }): Promise<SessionUsageResponse>;
2324
- /** `GET /sessions/:id/goal` */
2325
- getGoal(sessionId: string): Promise<SessionGoal | null>;
2326
- /** Reads the original durable action receipt after a response was lost. */
2327
- getGoalRequest(sessionId: string, requestId: string): Promise<SessionGoalRequestReceipt>;
2328
- /** `POST /sessions/:id/goals` */
2329
- createGoal(sessionId: string, input: CreateSessionGoalInput): Promise<SessionGoal>;
2330
- /** `PATCH /sessions/:id/goals/:goalId` */
2331
- updateGoal(sessionId: string, goalId: string, input: UpdateSessionGoalInput): Promise<SessionGoal>;
2332
- /** `POST /sessions/:id/goals/:goalId/actions` */
2333
- applyGoalAction(sessionId: string, goalId: string, input: GoalActionInput): Promise<SessionGoal>;
2334
- }
2335
-
2336
- /** Generate a caller-stable id for one prompt admission attempt. */
2337
- declare function createPromptRequestId(): string;
3121
+ }
3122
+
3123
+ /** Generate an ID to save before sending a session request that may need recovery. */
3124
+ declare function createSessionRequestId(): string;
2338
3125
 
2339
3126
  declare class AttachmentResource {
2340
3127
  private readonly transport;
2341
3128
  constructor(transport: HttpTransport);
3129
+ /** Manage daemon attachment storage. Ordinary session connections cannot use these methods. */
3130
+ readonly storage: {
3131
+ scan: (options?: {
3132
+ signal?: AbortSignal;
3133
+ }) => Promise<AttachmentStorageReport>;
3134
+ repair: (options?: {
3135
+ signal?: AbortSignal;
3136
+ }) => Promise<AttachmentStorageRepairResult>;
3137
+ gc: (options?: {
3138
+ signal?: AbortSignal;
3139
+ }) => Promise<AttachmentStorageGcResult>;
3140
+ };
2342
3141
  /** `POST /attachments` — upload bytes without JSON or multipart buffering. */
2343
3142
  upload(input: UploadAttachmentInput): Promise<AttachmentAssetRecord>;
2344
3143
  getUpload(input: Omit<UploadAttachmentInput, "body">): Promise<AttachmentAssetRecord | null>;
@@ -2353,116 +3152,923 @@ declare class AttachmentResource {
2353
3152
  }
2354
3153
 
2355
3154
  declare class PermissionResource {
2356
- private readonly transport;
3155
+ #private;
2357
3156
  constructor(transport: HttpTransport);
2358
- /** Answer an actual AskUser question; this cannot approve tools. */
2359
- answerQuestion(requestId: string, input: {
2360
- answer: string;
2361
- }, options?: {
2362
- signal?: AbortSignal;
2363
- }): Promise<PermissionRequestRecord>;
2364
- listApprovals(): Promise<PermissionRequestRecord[]>;
2365
- revokeApproval(requestId: string): Promise<PermissionRequestRecord>;
2366
- /** `GET /permissions` */
2367
- list(options?: ListPermissionsOptions & {
2368
- signal?: AbortSignal;
2369
- }): Promise<PermissionRequestRecord[]>;
2370
- /** `POST /permissions/:id/reply` — 批准/拒绝工具权限请求。 */
2371
- reply(requestId: string, input: ReplyPermissionInput, options?: {
2372
- signal?: AbortSignal;
2373
- }): Promise<PermissionRequestRecord>;
3157
+ readonly requests: {
3158
+ /** `GET /permissions` */
3159
+ list: (options?: ListPermissionsOptions & {
3160
+ signal?: AbortSignal;
3161
+ }) => Promise<PermissionRequestRecord[]>;
3162
+ /** `POST /permissions/:id/reply` — 批准/拒绝工具权限请求。 */
3163
+ reply: (requestId: string, input: ReplyPermissionInput, options?: {
3164
+ signal?: AbortSignal;
3165
+ }) => Promise<PermissionRequestRecord>;
3166
+ /** Answer an actual AskUser question; this cannot approve tools. */
3167
+ answerQuestion: (requestId: string, input: {
3168
+ answer: string;
3169
+ }, options?: {
3170
+ signal?: AbortSignal;
3171
+ }) => Promise<PermissionRequestRecord>;
3172
+ };
3173
+ readonly approvals: {
3174
+ list: () => Promise<PermissionRequestRecord[]>;
3175
+ revoke: (requestId: string) => Promise<PermissionRequestRecord>;
3176
+ };
2374
3177
  }
2375
3178
 
2376
- declare class JobResource {
3179
+ type RequestOptions$7 = {
3180
+ signal?: AbortSignal;
3181
+ };
3182
+ /** Manage marketplace sources and look up the result of an original install. */
3183
+ declare class PluginMarketplaceResource {
2377
3184
  private readonly transport;
2378
3185
  constructor(transport: HttpTransport);
2379
- list(options: {
2380
- sessionId: string;
2381
- kinds?: JobKind[];
2382
- statuses?: JobStatus[];
2383
- startedAfter?: number;
2384
- startedBefore?: number;
2385
- updatedAfter?: number;
2386
- updatedBefore?: number;
2387
- includeFinished?: boolean;
2388
- limit?: number;
2389
- signal?: AbortSignal;
2390
- }): Promise<JobListResult>;
2391
- createBackgroundShell(input: CreateBackgroundShellInput, options?: {
2392
- signal?: AbortSignal;
2393
- }): Promise<CreateBackgroundShellResult>;
2394
- read(target: JobTarget, options: {
2395
- sessionId: string;
2396
- after?: number;
2397
- maxChars?: number;
2398
- signal?: AbortSignal;
2399
- }): Promise<JobReadResult>;
2400
- wait(target: JobTarget, input: {
2401
- sessionId: string;
2402
- timeoutMs?: number;
2403
- after?: number;
2404
- maxChars?: number;
2405
- }, options?: {
2406
- signal?: AbortSignal;
2407
- }): Promise<JobWaitResult>;
2408
- send(target: JobTarget, input: {
2409
- sessionId: string;
2410
- data: string;
2411
- }, options?: {
2412
- signal?: AbortSignal;
2413
- }): Promise<JobInputReceipt | void>;
2414
- cancel(target: JobTarget, input: {
2415
- sessionId: string;
2416
- reason?: string;
2417
- }, options: {
2418
- signal?: AbortSignal;
2419
- responseMode: "receipt";
2420
- }): Promise<JobCancelReceipt>;
2421
- cancel(target: JobTarget, input: {
2422
- sessionId: string;
2423
- reason?: string;
2424
- }, options?: {
2425
- signal?: AbortSignal;
2426
- responseMode?: "snapshot";
2427
- }): Promise<JobSnapshot>;
3186
+ catalog({ signal, ...query }: MarketplaceCatalogRequest & RequestOptions$7): Promise<MarketplaceCatalog>;
3187
+ listSources(options?: RequestOptions$7): Promise<MarketplaceSourcesResponse>;
3188
+ addSource(input: MarketplaceAddSourceRequest, options?: RequestOptions$7): Promise<MarketplaceSourcesResponse>;
3189
+ setSourceEnabled(sourceId: string, input: MarketplaceSourceEnabledRequest, options?: RequestOptions$7): Promise<MarketplaceSourcesResponse>;
3190
+ removeSource(sourceId: string, options?: RequestOptions$7): Promise<MarketplaceSourcesResponse>;
3191
+ preview(input: MarketplacePreviewRequest, options?: RequestOptions$7): Promise<MarketplacePreview>;
3192
+ cancel(input: MarketplaceCancelRequest, options?: RequestOptions$7): Promise<MarketplaceCancelResponse>;
3193
+ /** Save the operation ID before submitting. Recover an uncertain result with getOperation. */
3194
+ install(input: MarketplaceInstallRequest, options?: RequestOptions$7): Promise<MarketplaceOperation>;
3195
+ /** Look up the original operation without repeating its install. */
3196
+ getOperation(operationId: string, options?: RequestOptions$7): Promise<MarketplaceOperation>;
2428
3197
  }
2429
3198
 
2430
- declare class EventResource {
3199
+ type RequestOptions$6 = {
3200
+ signal?: AbortSignal;
3201
+ };
3202
+ type DirectoryInput = {
3203
+ cwd: string;
3204
+ };
3205
+ type PluginMessage = {
3206
+ message: string;
3207
+ };
3208
+ /** Manage native plugins in the daemon. Uses a management connection. */
3209
+ declare class PluginResource {
2431
3210
  private readonly transport;
2432
- private readonly sse;
2433
- constructor(transport: HttpTransport, sse: SseTransport);
2434
- /** `GET /events` — 用于 attach 时的历史 replay。 */
2435
- list(options?: ListEventsOptions & {
3211
+ readonly marketplace: PluginMarketplaceResource;
3212
+ constructor(transport: HttpTransport);
3213
+ /** List native plugins for a directory in the daemon environment. */
3214
+ list({ signal, cwd }: DirectoryInput & RequestOptions$6): Promise<PluginListResult>;
3215
+ enable(id: string, input: DirectoryInput, options?: RequestOptions$6): Promise<PluginMessage>;
3216
+ disable(id: string, input: DirectoryInput, options?: RequestOptions$6): Promise<PluginMessage>;
3217
+ /** Read the identity, digest and requested permissions for a directory on the daemon machine. */
3218
+ previewLocal(input: PluginLocalPreviewInput, options?: RequestOptions$6): Promise<PluginLocalPreview>;
3219
+ /** Install or link a plugin directory the daemon can read after approval. */
3220
+ installLocal(input: PluginLocalInstallInput, options?: RequestOptions$6): Promise<PluginMessage>;
3221
+ /** Read the digest and required permissions for an archive on the daemon machine. */
3222
+ previewArchive(input: PluginArchivePreviewInput, options?: RequestOptions$6): Promise<PluginArchivePreview>;
3223
+ /** Install the previewed archive with its original digest and approved permissions. */
3224
+ installArchive(input: PluginArchiveInstallInput, options?: RequestOptions$6): Promise<PluginMessage>;
3225
+ /** Read the digest and required permissions for a Git source. */
3226
+ previewGit(input: PluginGitPreviewInput, options?: RequestOptions$6): Promise<PluginGitPreview>;
3227
+ /** Install the previewed Git source with its original digest and approved permissions. */
3228
+ installGit(input: PluginGitInstallInput, options?: RequestOptions$6): Promise<PluginMessage>;
3229
+ uninstall(id: string, input: DirectoryInput, options?: RequestOptions$6): Promise<PluginMessage>;
3230
+ reload(input: DirectoryInput, options?: RequestOptions$6): Promise<ReloadPluginsResponse>;
3231
+ }
3232
+
3233
+ type RequestOptions$5 = {
3234
+ signal?: AbortSignal;
3235
+ };
3236
+ interface ChannelQuery {
3237
+ connector?: string;
3238
+ limit?: number;
3239
+ }
3240
+ interface FeishuComposedSnapshot {
3241
+ feishu: FeishuChannelSnapshot;
3242
+ runtime: ChannelRuntimeStatus;
3243
+ }
3244
+ /** Manage daemon-owned channel configuration or deliver messages with a daemon bearer token. */
3245
+ declare class ChannelResource {
3246
+ private readonly transport;
3247
+ constructor(transport: HttpTransport);
3248
+ /** Read the running connectors or temporarily start and stop them. */
3249
+ readonly runtime: {
3250
+ status: (options?: RequestOptions$5) => Promise<ChannelRuntimeStatus>;
3251
+ start: (input?: ChannelRuntimeControlInput, options?: RequestOptions$5) => Promise<ChannelRuntimeStatus>;
3252
+ stop: (input?: ChannelRuntimeControlInput, options?: RequestOptions$5) => Promise<ChannelRuntimeStatus>;
3253
+ };
3254
+ /** Configure Feishu or Lark. Status snapshots omit credentials. */
3255
+ readonly feishu: {
3256
+ status: (options?: RequestOptions$5) => Promise<FeishuChannelSnapshot>;
3257
+ connect: (input: FeishuConnectInput, options?: RequestOptions$5) => Promise<FeishuComposedSnapshot>;
3258
+ update: (input: FeishuPatchInput, options?: RequestOptions$5) => Promise<FeishuComposedSnapshot>;
3259
+ disconnect: (options?: RequestOptions$5) => Promise<FeishuComposedSnapshot>;
3260
+ allowlist: {
3261
+ add: (input: FeishuAllowInput, options?: RequestOptions$5) => Promise<FeishuChannelSnapshot>;
3262
+ remove: (key: string, options?: RequestOptions$5) => Promise<FeishuChannelSnapshot>;
3263
+ };
3264
+ registration: {
3265
+ start: (input?: FeishuRegistrationStartInput, options?: RequestOptions$5) => Promise<FeishuRegistrationSnapshot>;
3266
+ status: (options?: RequestOptions$5) => Promise<FeishuRegistrationSnapshot>;
3267
+ cancel: (options?: RequestOptions$5) => Promise<FeishuRegistrationSnapshot>;
3268
+ };
3269
+ };
3270
+ /** Submit external messages and work with durable delivery records. */
3271
+ readonly connector: {
3272
+ /** Retain the external message ID when retrying the same input. */
3273
+ submitMessage: (input: DurableChannelMessageInput, options?: RequestOptions$5) => Promise<DurableChannelMessageResult>;
3274
+ status: (query?: ChannelQuery, options?: RequestOptions$5) => Promise<ChannelStatusSnapshot>;
3275
+ listPendingDeliveries: (query?: ChannelQuery, options?: RequestOptions$5) => Promise<ChannelDeliveryRecord[]>;
3276
+ /** Look up the stored result after an interrupted request. Returns null for an unknown ID. */
3277
+ getDelivery: (deliveryId: string, options?: RequestOptions$5) => Promise<ChannelDeliveryRecord | null>;
3278
+ recordDelivery: (deliveryId: string, input: RecordChannelDeliveryInput, options?: RequestOptions$5) => Promise<ChannelDeliveryRecord>;
3279
+ };
3280
+ }
3281
+
3282
+ /**
3283
+ * ProjectResource: 项目目录探测、绑定、别名与元数据管理资源。
3284
+ */
3285
+
3286
+ type RequestOptions$4 = {
3287
+ signal?: AbortSignal;
3288
+ };
3289
+ declare class ProjectResource {
3290
+ private readonly transport;
3291
+ constructor(transport: HttpTransport);
3292
+ /** `GET /projects` */
3293
+ list(options?: ListProjectsOptions & {
2436
3294
  signal?: AbortSignal;
2437
- }): Promise<SessionEventRecord[]>;
2438
- stream(options?: Omit<EventSyncOptions, "reconnectDelayMs"> & {
2439
- transportReconnect?: boolean;
2440
- onOpen?: () => void;
2441
- }): AsyncIterable<SessionEventRecord>;
3295
+ }): Promise<ProjectRecord[]>;
3296
+ /** Register or reopen a directory on the daemon host and update its last-opened time. */
3297
+ register(path: string, options?: RequestOptions$4): Promise<ProjectRecord>;
3298
+ /** Alias for register. This can create or restore a project record. */
3299
+ inspect(path: string, options?: RequestOptions$4): Promise<ProjectRecord>;
3300
+ /** `PATCH /projects/:id` (name) */
3301
+ rename(projectId: string, name: string, options?: RequestOptions$4): Promise<ProjectRecord>;
3302
+ /** `PATCH /projects/:id` (pinned) */
3303
+ setPinned(projectId: string, pinned: boolean, options?: RequestOptions$4): Promise<ProjectRecord>;
3304
+ /** `PATCH /projects/:id` (defaultShell) */
3305
+ setDefaultShell(projectId: string, defaultShell: string | null, options?: RequestOptions$4): Promise<ProjectRecord>;
3306
+ /** `POST /projects/:id/rebind` */
3307
+ rebind(projectId: string, path: string, options?: string | (RequestOptions$4 & {
3308
+ expectedPath?: string;
3309
+ })): Promise<ProjectRecord>;
3310
+ /** `DELETE /projects/:id` */
3311
+ archive(projectId: string, options?: RequestOptions$4): Promise<ProjectRecord>;
3312
+ /** `POST /project/init` */
3313
+ init(input: {
3314
+ cwd: string;
3315
+ }, options?: {
3316
+ signal?: AbortSignal;
3317
+ }): Promise<string>;
3318
+ }
3319
+
3320
+ interface TaskWorktreeRecord {
3321
+ id: string;
3322
+ projectId: string;
3323
+ projectPath: string;
3324
+ path: string;
3325
+ branch: string;
3326
+ sessionId?: string;
3327
+ task?: string;
3328
+ bytes: number | null;
3329
+ dirty: boolean | null;
3330
+ active: boolean;
3331
+ preserved: boolean;
3332
+ disposable: boolean;
3333
+ cleanupAllowed: boolean;
3334
+ directoryRemoved?: boolean;
3335
+ reason?: string;
3336
+ }
3337
+ type RequestOptions$3 = {
3338
+ signal?: AbortSignal;
3339
+ };
3340
+ /** Inspect and maintain task worktrees managed by the daemon. */
3341
+ declare class WorktreeResource {
3342
+ private readonly transport;
3343
+ constructor(transport: HttpTransport);
3344
+ list(options?: RequestOptions$3): Promise<TaskWorktreeRecord[]>;
3345
+ cleanup(id: string, options?: RequestOptions$3): Promise<void>;
3346
+ setDisposable(id: string, disposable: boolean, options?: RequestOptions$3): Promise<void>;
3347
+ }
3348
+
3349
+ declare class GitResource {
3350
+ private readonly transport;
3351
+ constructor(transport: HttpTransport);
3352
+ /** `GET /git/diff?cwd=&full=` */
3353
+ getDiff(options: {
3354
+ cwd: string;
3355
+ full?: boolean;
3356
+ signal?: AbortSignal;
3357
+ }): Promise<string>;
3358
+ /** `GET /git/branch?cwd=&list=` */
3359
+ getBranch(options: {
3360
+ cwd: string;
3361
+ list?: boolean;
3362
+ signal?: AbortSignal;
3363
+ }): Promise<string>;
3364
+ /** `GET /git/status?cwd=` */
3365
+ getStatus(options: {
3366
+ cwd: string;
3367
+ signal?: AbortSignal;
3368
+ }): Promise<string>;
3369
+ /** `POST /git/commit` */
3370
+ commit(input: {
3371
+ cwd: string;
3372
+ message: string;
3373
+ }, options?: {
3374
+ signal?: AbortSignal;
3375
+ }): Promise<string>;
2442
3376
  }
2443
3377
 
2444
- /** Read-only files in the workspace chosen by the session, without starting an Agent. */
2445
- declare class FilesResource {
3378
+ declare class HookResource {
2446
3379
  private readonly transport;
2447
3380
  constructor(transport: HttpTransport);
2448
- list(sessionId: string, options?: SessionFileListOptions): Promise<SessionDirectoryResult>;
2449
- stat(sessionId: string, path: string, options?: SessionFileRequestOptions): Promise<SessionFileInfo>;
2450
- readText(sessionId: string, path: string, options?: SessionFileReadOptions): Promise<SessionTextFileResult>;
2451
- find(sessionId: string, options: SessionFileFindOptions): Promise<SessionFindFilesResult>;
2452
- search(sessionId: string, options: SessionFileSearchOptions): Promise<SessionSearchFilesResult>;
3381
+ /** `GET /hooks?cwd=&sessionId=` */
3382
+ list(options: {
3383
+ cwd: string;
3384
+ sessionId?: string;
3385
+ signal?: AbortSignal;
3386
+ }): Promise<HookInfo[]>;
3387
+ }
3388
+
3389
+ type RequestOptions$2 = {
3390
+ signal?: AbortSignal;
3391
+ };
3392
+ /** Pass an HTTP server's reference from a list response to runtimeStatus or synchronize. */
3393
+ interface McpServerRuntimeRef {
3394
+ name: string;
3395
+ endpointFingerprint: string;
3396
+ }
3397
+ type McpManagedServerConfig = ({
3398
+ type: "stdio";
3399
+ command: string;
3400
+ args?: string[];
3401
+ env?: Record<string, string>;
3402
+ cwd?: string;
3403
+ } | {
3404
+ type: "http" | "sse";
3405
+ url: string;
3406
+ headers?: Record<string, string>;
3407
+ oauth?: {
3408
+ scopes?: string[];
3409
+ clientId?: string;
3410
+ callbackPort?: number;
3411
+ resourceUrl?: string;
3412
+ callbackUrl?: string;
3413
+ };
3414
+ }) & {
3415
+ enabled?: boolean;
3416
+ };
3417
+ type McpManagedServerSummary = Omit<McpOAuthStatusSnapshot["servers"][number], "endpoint"> & {
3418
+ summary: string;
3419
+ runtimeRef?: McpServerRuntimeRef;
3420
+ };
3421
+ interface McpConfigOperationResult {
3422
+ persisted: boolean;
3423
+ credentialRemoved: boolean;
3424
+ runtimeFailures: McpRuntimeSyncResult["failures"];
3425
+ }
3426
+ /** Manage the daemon's global MCP configuration using an administrator connection. */
3427
+ declare class McpServersResource {
3428
+ private readonly transport;
3429
+ private readonly basePath;
3430
+ constructor(transport: HttpTransport);
3431
+ list(options?: RequestOptions$2): Promise<{
3432
+ servers: McpManagedServerSummary[];
3433
+ }>;
3434
+ getConfig(name: string, options?: RequestOptions$2): Promise<McpManagedServerConfig>;
3435
+ exportConfig(options?: RequestOptions$2): Promise<{
3436
+ mcpServers: Record<string, McpManagedServerConfig>;
3437
+ }>;
3438
+ add(input: {
3439
+ name: string;
3440
+ config: McpManagedServerConfig;
3441
+ }, options?: RequestOptions$2): Promise<McpConfigOperationResult & {
3442
+ runtimeSync: McpRuntimeSyncResult;
3443
+ }>;
3444
+ update({ name, ...body }: {
3445
+ name: string;
3446
+ config: McpManagedServerConfig;
3447
+ expectedConfig: McpManagedServerConfig;
3448
+ }, options?: RequestOptions$2): Promise<McpConfigOperationResult>;
3449
+ setEnabled({ name, enabled }: {
3450
+ name: string;
3451
+ enabled: boolean;
3452
+ }, options?: RequestOptions$2): Promise<McpConfigOperationResult>;
3453
+ remove(name: string, options?: RequestOptions$2): Promise<McpConfigOperationResult>;
3454
+ private serverPath;
3455
+ private request;
3456
+ }
3457
+ /** Discover and manage globally configured MCP connections on the daemon. */
3458
+ declare class McpResource {
3459
+ private readonly transport;
3460
+ readonly servers: McpServersResource;
3461
+ constructor(transport: HttpTransport);
3462
+ listAppServers(options?: {
3463
+ signal?: AbortSignal;
3464
+ }): Promise<{
3465
+ servers: Array<{
3466
+ name: string;
3467
+ transport: "stdio" | "http" | "sse";
3468
+ summary: string;
3469
+ enabled?: false;
3470
+ runtimeStatus: McpRuntimeSyncResult["status"];
3471
+ runtimeRef?: McpServerRuntimeRef;
3472
+ }>;
3473
+ }>;
3474
+ runtimeStatus(ref: McpServerRuntimeRef, options?: RequestOptions$2): Promise<McpRuntimeSyncResult>;
3475
+ runtimeStatus(name: string, fingerprint: string, options?: RequestOptions$2): Promise<McpRuntimeSyncResult>;
3476
+ synchronize(ref: McpServerRuntimeRef, options?: RequestOptions$2): Promise<McpRuntimeSyncResult>;
3477
+ synchronize(name: string, fingerprint: string, options?: RequestOptions$2): Promise<McpRuntimeSyncResult>;
3478
+ /**
3479
+ * Ask every active Runtime to re-check the latest global config for `name`.
3480
+ * Only the server name crosses the wire.
3481
+ */
3482
+ reconcileGlobal(name: string, options?: {
3483
+ signal?: AbortSignal;
3484
+ }): Promise<McpRuntimeSyncResult>;
3485
+ authStatus(options?: {
3486
+ signal?: AbortSignal;
3487
+ }): Promise<McpOAuthStatusSnapshot>;
3488
+ startLogin(name: string, input: McpOAuthLoginInput, options?: {
3489
+ signal?: AbortSignal;
3490
+ }): Promise<McpOAuthLoginResponse>;
3491
+ getLogin(loginId: string, options?: {
3492
+ signal?: AbortSignal;
3493
+ }): Promise<OAuthOperationView>;
3494
+ submitCallback(loginId: string, callbackUrl: string, options?: {
3495
+ signal?: AbortSignal;
3496
+ }): Promise<OAuthOperationView>;
3497
+ cancelLogin(loginId: string, options?: {
3498
+ signal?: AbortSignal;
3499
+ }): Promise<OAuthOperationView>;
3500
+ logout(name: string, options?: {
3501
+ signal?: AbortSignal;
3502
+ }): Promise<McpOAuthStatusSnapshot>;
3503
+ watchLogin(loginId: string, options?: {
3504
+ signal?: AbortSignal;
3505
+ }): AsyncIterable<OAuthOperationEvent>;
3506
+ }
3507
+
3508
+ /** Discover available daemon commands. Product code owns their interactive presentation. */
3509
+ declare class CommandResource {
3510
+ private readonly transport;
3511
+ constructor(transport: HttpTransport);
3512
+ /** `GET /commands` */
3513
+ list(options: ListCommandsOptions & {
3514
+ signal?: AbortSignal;
3515
+ }): Promise<CommandCatalogEntry[]>;
3516
+ }
3517
+
3518
+ /** Read daemon context previews and usage reports for an execution directory. */
3519
+ declare class ContextResource {
3520
+ private readonly transport;
3521
+ constructor(transport: HttpTransport);
3522
+ /** `GET /context?cwd=` */
3523
+ getPreview(options: {
3524
+ cwd: string;
3525
+ signal?: AbortSignal;
3526
+ }): Promise<string>;
3527
+ /** `GET /context/status?cwd=` */
3528
+ getStatus(options: {
3529
+ cwd: string;
3530
+ signal?: AbortSignal;
3531
+ }): Promise<string>;
3532
+ /** `GET /context/usage?cwd=&sessionId=&refresh=` */
3533
+ getUsage(options: {
3534
+ cwd: string;
3535
+ sessionId?: string;
3536
+ refresh?: boolean;
3537
+ previousContextWindow?: number;
3538
+ signal?: AbortSignal;
3539
+ }): Promise<{
3540
+ snapshot: unknown;
3541
+ report: string;
3542
+ }>;
3543
+ }
3544
+
3545
+ /** Read-only operational snapshots used by the native host diagnostics page. */
3546
+ interface HostDiagnosticSnapshots {
3547
+ readiness: {
3548
+ phase: string;
3549
+ accepting: boolean;
3550
+ };
3551
+ runtime: {
3552
+ permissions: {
3553
+ byStatus: Record<string, number>;
3554
+ };
3555
+ coordinator: {
3556
+ activeRunCount: number;
3557
+ queuedRunCount: number;
3558
+ };
3559
+ };
3560
+ storageHealth: {
3561
+ writable: boolean;
3562
+ availableBytes: number | null;
3563
+ logsDirectory: string;
3564
+ };
3565
+ environment: {
3566
+ kind: string;
3567
+ distribution?: string;
3568
+ checks: Array<{
3569
+ name: string;
3570
+ status: "ok" | "warning" | "failed";
3571
+ detail: string;
3572
+ }>;
3573
+ };
3574
+ logs: {
3575
+ logs: unknown[];
3576
+ scope?: string;
3577
+ };
3578
+ details: {
3579
+ expiresAt: number | null;
3580
+ };
3581
+ errors: {
3582
+ errors: Array<{
3583
+ timestamp: number;
3584
+ category: string;
3585
+ sessionId: string;
3586
+ runId: string;
3587
+ level: "error" | "warn";
3588
+ event: string;
3589
+ }>;
3590
+ };
3591
+ }
3592
+ type DiagnosticOptions = {
3593
+ signal?: AbortSignal;
3594
+ };
3595
+ type ContentOptions = DiagnosticOptions & {
3596
+ includeContent?: boolean;
3597
+ };
3598
+ interface DiagnosticExecutionQuery extends DiagnosticOptions {
3599
+ kind?: string;
3600
+ outcome?: string;
3601
+ failureKind?: string;
3602
+ sessionId?: string;
3603
+ runId?: string;
3604
+ childId?: string;
3605
+ workflowRunId?: string;
3606
+ workflowTaskId?: string;
3607
+ model?: string;
3608
+ provider?: string;
3609
+ from?: string | number;
3610
+ to?: string | number;
3611
+ reviewStatus?: string;
3612
+ reviewRisk?: string;
3613
+ }
3614
+ /** Daemon diagnostic snapshots and durable execution observations. */
3615
+ declare class DiagnosticResource {
3616
+ private readonly transport;
3617
+ constructor(transport: HttpTransport);
3618
+ /** The original normalized endpoint, without this connection's bearer token. */
3619
+ target(): string;
3620
+ /** Finite native-host diagnostics; this never accepts an arbitrary route or mutation. */
3621
+ get<K extends keyof HostDiagnosticSnapshots>(kind: K, options?: {
3622
+ signal?: AbortSignal;
3623
+ }): Promise<HostDiagnosticSnapshots[K]>;
3624
+ getRun(runId: string, { signal, ...query }?: ContentOptions): Promise<Record<string, unknown>>;
3625
+ listSettlements({ signal, ...query }?: ContentOptions): Promise<Record<string, unknown>>;
3626
+ listExecutions({ signal, ...query }?: DiagnosticExecutionQuery): Promise<Record<string, unknown>>;
3627
+ setDetails(minutes: number, options?: DiagnosticOptions): Promise<HostDiagnosticSnapshots["details"]>;
3628
+ }
3629
+
3630
+ interface DaemonRestartPreview {
3631
+ complete?: boolean;
3632
+ activities?: {
3633
+ id: string;
3634
+ kind: string;
3635
+ state: "active" | "queued" | "unknown";
3636
+ }[];
3637
+ runs: {
3638
+ id: string;
3639
+ sessionId: string;
3640
+ status: string;
3641
+ }[];
3642
+ tasks: {
3643
+ id: string;
3644
+ sessionId: string;
3645
+ status: string;
3646
+ }[];
3647
+ terminals: {
3648
+ id: string;
3649
+ status: string;
3650
+ }[];
3651
+ }
3652
+ interface MaintenanceBackupResult {
3653
+ path: string;
3654
+ manifest: MaintenanceBackupManifest;
3655
+ totalBytes?: number;
3656
+ excludes?: string[];
3657
+ settingsExcluded?: boolean;
3658
+ settingsSnapshotPath?: string;
3659
+ }
3660
+ type RequestOptions$1 = {
3661
+ signal?: AbortSignal;
3662
+ };
3663
+ type PolicySettings = Pick<StorageRetentionPolicy, "enabled" | "days">;
3664
+ type UsageBudget = UsageSettings["budget"];
3665
+ /** Maintenance of daemon-managed data. All paths refer to the daemon environment. */
3666
+ declare class MaintenanceResource {
3667
+ private readonly transport;
3668
+ constructor(transport: HttpTransport);
3669
+ getRestartPreview(options?: RequestOptions$1): Promise<DaemonRestartPreview>;
3670
+ prepareRestart({ stopActive, signal }?: RequestOptions$1 & {
3671
+ stopActive?: boolean;
3672
+ }): Promise<{
3673
+ prepared: true;
3674
+ }>;
3675
+ readonly cleanup: {
3676
+ preview: (input: {
3677
+ kind: "session" | "log";
3678
+ olderThan: number;
3679
+ }, options?: RequestOptions$1) => Promise<CleanupPreview>;
3680
+ execute: (input: {
3681
+ previewId: string;
3682
+ ids: string[];
3683
+ }, options?: RequestOptions$1) => Promise<CleanupResult>;
3684
+ audits: (options?: RequestOptions$1) => Promise<{
3685
+ audits: Record<string, unknown>[];
3686
+ }>;
3687
+ getPolicy: (options?: RequestOptions$1) => Promise<StorageRetentionPolicy>;
3688
+ updatePolicy: (input: PolicySettings & {
3689
+ expected: PolicySettings;
3690
+ }, options?: RequestOptions$1) => Promise<StorageRetentionPolicy>;
3691
+ runPolicy: (options?: RequestOptions$1) => Promise<{
3692
+ skipped: true;
3693
+ } | {
3694
+ skipped: false;
3695
+ result: CleanupResult | null;
3696
+ }>;
3697
+ };
3698
+ readonly usage: {
3699
+ get: (input?: UsageFilter, options?: RequestOptions$1) => Promise<UsageReport>;
3700
+ getSettings: (options?: RequestOptions$1) => Promise<UsageSettings>;
3701
+ updateBudget: (input: UsageBudget & {
3702
+ expected?: UsageBudget;
3703
+ }, options?: RequestOptions$1) => Promise<UsageSettings>;
3704
+ addPrice: (input: UsagePrice, options?: RequestOptions$1) => Promise<UsageSettings>;
3705
+ };
3706
+ readonly storage: {
3707
+ get: (options?: RequestOptions$1) => Promise<StorageReport>;
3708
+ };
3709
+ readonly backups: {
3710
+ create: (input: {
3711
+ destination: string;
3712
+ includeMemory: boolean;
3713
+ includeOutput: boolean;
3714
+ }, options?: RequestOptions$1) => Promise<MaintenanceBackupResult>;
3715
+ verify: (source: string, options?: RequestOptions$1) => Promise<MaintenanceBackupResult>;
3716
+ restore: (input: {
3717
+ source: string;
3718
+ target: string;
3719
+ }, options?: RequestOptions$1) => Promise<MaintenanceBackupResult>;
3720
+ };
3721
+ private post;
3722
+ }
3723
+
3724
+ interface ProjectFactRecord {
3725
+ key: string;
3726
+ type: string;
3727
+ label: string;
3728
+ value: string;
3729
+ confidence: number;
3730
+ observedAt?: string;
3731
+ sourceSessionId?: string;
3732
+ sourceMessageId?: string;
3733
+ status?: "superseded";
3734
+ replacement?: {
3735
+ byKey: string;
3736
+ operationId: string;
3737
+ at: string;
3738
+ };
3739
+ manualSource?: {
3740
+ kind: "manual_replace";
3741
+ operationId: string;
3742
+ oldKey: string;
3743
+ at: string;
3744
+ sessionId?: string;
3745
+ };
3746
+ }
3747
+ interface FactReplacementResult {
3748
+ oldKey: string;
3749
+ newKey: string;
3750
+ operationId: string;
3751
+ relatedActiveKeys: string[];
3752
+ cacheWarning?: string;
3753
+ }
3754
+ /** Work with daemon memory and environment facts in the given execution directory. */
3755
+ declare class MemoryResource {
3756
+ private readonly transport;
3757
+ constructor(transport: HttpTransport);
3758
+ /** `GET /memory?cwd=` */
3759
+ listMemory(options: {
3760
+ cwd: string;
3761
+ signal?: AbortSignal;
3762
+ }): Promise<MemoryListResponse>;
3763
+ /** `GET /facts?cwd=` — current project environment facts. */
3764
+ listFacts(options: {
3765
+ cwd: string;
3766
+ signal?: AbortSignal;
3767
+ }): Promise<{
3768
+ facts: ProjectFactRecord[];
3769
+ }>;
3770
+ /** `POST /facts/replace` — replace exactly one selected environment fact. */
3771
+ replaceFact(input: {
3772
+ cwd: string;
3773
+ oldKey: string;
3774
+ newValue: string;
3775
+ sessionId?: string;
3776
+ }, options?: {
3777
+ signal?: AbortSignal;
3778
+ }): Promise<FactReplacementResult>;
3779
+ /** `GET /memory/:id?cwd=` */
3780
+ getMemory(entryId: string, options: {
3781
+ cwd: string;
3782
+ signal?: AbortSignal;
3783
+ }): Promise<MemoryEntryRecord>;
3784
+ /** `POST /memory` */
3785
+ addMemory(input: {
3786
+ cwd: string;
3787
+ content: string;
3788
+ tags?: string[];
3789
+ }, options?: {
3790
+ signal?: AbortSignal;
3791
+ }): Promise<MemoryEntryRecord>;
3792
+ /** `DELETE /memory/:id?cwd=` */
3793
+ removeMemory(entryId: string, options: {
3794
+ cwd: string;
3795
+ signal?: AbortSignal;
3796
+ expectedRevision?: string;
3797
+ }): Promise<void>;
3798
+ updateMemory(input: UpdateMemoryEntryInput, options?: {
3799
+ signal?: AbortSignal;
3800
+ }): Promise<MemoryEntryRecord>;
3801
+ clearMemory(input: ClearMemoryInput, options?: {
3802
+ signal?: AbortSignal;
3803
+ }): Promise<{
3804
+ deleted: number;
3805
+ }>;
3806
+ getDreamStatus(input: {
3807
+ cwd: string;
3808
+ }): Promise<{
3809
+ status: string;
3810
+ startedAt: number;
3811
+ finishedAt?: number;
3812
+ taskId?: string;
3813
+ error?: string;
3814
+ } | null>;
3815
+ /** `POST /dream` */
3816
+ startDream(input: {
3817
+ cwd: string;
3818
+ sessionId?: string;
3819
+ preview?: boolean;
3820
+ }, options?: {
3821
+ signal?: AbortSignal;
3822
+ }): Promise<StartDreamResponse>;
3823
+ }
3824
+
3825
+ type RequestOptions = {
3826
+ signal?: AbortSignal;
3827
+ };
3828
+ interface GlobalSettingsPatch {
3829
+ [setting: string]: unknown;
3830
+ maxTurns?: number;
3831
+ expectedMaxTurns?: number;
3832
+ replyStyle?: ReplyStyle;
3833
+ showReasoning?: boolean;
3834
+ systemPrompt?: string | null;
3835
+ }
3836
+ /** Daemon settings, profile and output styles. */
3837
+ declare class SettingsResource {
3838
+ private readonly transport;
3839
+ constructor(transport: HttpTransport);
3840
+ /** Read the daemon's current global settings. */
3841
+ getGlobal({ signal }?: RequestOptions): Promise<Record<string, unknown>>;
3842
+ /** Read effective settings including overrides for a daemon-side project directory. */
3843
+ getEffective(options: RequestOptions & {
3844
+ cwd: string;
3845
+ }): Promise<Record<string, unknown>>;
3846
+ /** Read global settings without cwd, or the merged project settings with cwd. */
3847
+ get(options?: RequestOptions & {
3848
+ cwd?: string;
3849
+ }): Promise<Record<string, unknown>>;
3850
+ /** Apply a targeted change to global settings. Pass only the fields the caller changes. */
3851
+ updateGlobal(patch: GlobalSettingsPatch, options?: RequestOptions): Promise<Record<string, unknown>>;
3852
+ /** Apply a global patch. Existing callers may use this alias. */
3853
+ update(patch: Record<string, unknown>, options?: {
3854
+ signal?: AbortSignal;
3855
+ }): Promise<Record<string, unknown>>;
3856
+ /** `GET /profile` */
3857
+ getProfileStatus(options?: {
3858
+ signal?: AbortSignal;
3859
+ }): Promise<string>;
3860
+ /** `POST /profile/init` */
3861
+ initProfile(options?: {
3862
+ signal?: AbortSignal;
3863
+ }): Promise<string>;
3864
+ /** `GET /output-styles` */
3865
+ listOutputStyles(options?: {
3866
+ signal?: AbortSignal;
3867
+ }): Promise<OutputStyleInfo[]>;
3868
+ }
3869
+
3870
+ /** Daemon execution terminals. Desktop interactive terminals use AppHost. */
3871
+ declare class TerminalResource {
3872
+ private readonly transport;
3873
+ private readonly sse;
3874
+ constructor(transport: HttpTransport, sse: SseTransport);
3875
+ create(input: TerminalCreateRequest, options?: {
3876
+ signal?: AbortSignal;
3877
+ }): Promise<TerminalSessionInfo>;
3878
+ list(options?: {
3879
+ projectId?: string;
3880
+ sessionId?: string;
3881
+ source?: TerminalSource;
3882
+ signal?: AbortSignal;
3883
+ }): Promise<TerminalSessionInfo[]>;
3884
+ get(terminalId: string, options?: {
3885
+ signal?: AbortSignal;
3886
+ }): Promise<TerminalSessionInfo>;
3887
+ read(terminalId: string, options?: {
3888
+ signal?: AbortSignal;
3889
+ }): Promise<TerminalReadResult>;
3890
+ write(input: TerminalWriteRequest, options?: {
3891
+ signal?: AbortSignal;
3892
+ }): Promise<void>;
3893
+ resize(input: TerminalResizeRequest, options?: {
3894
+ signal?: AbortSignal;
3895
+ }): Promise<void>;
3896
+ signal(terminalId: string, signal: TerminalSignal, options?: {
3897
+ signal?: AbortSignal;
3898
+ }): Promise<void>;
3899
+ close(terminalId: string, options?: {
3900
+ signal?: AbortSignal;
3901
+ }): Promise<void>;
3902
+ streamEvents(options?: {
3903
+ signal?: AbortSignal;
3904
+ }): AsyncIterable<TerminalEvent>;
2453
3905
  }
2454
3906
 
2455
3907
  declare class BobanNomiClient {
2456
3908
  readonly protocol: ProtocolClient;
2457
- readonly runtime: RuntimeResource;
3909
+ /** Models grouped by provider, from the caller's catalog or the daemon. */
3910
+ readonly models: {
3911
+ list({ signal }?: {
3912
+ signal?: AbortSignal;
3913
+ }): Promise<ModelProviderInfo[]>;
3914
+ };
3915
+ /** Model-provider connections and defaults. Requires daemon management access. */
3916
+ readonly modelProviders: {
3917
+ catalog(options?: {
3918
+ signal?: AbortSignal;
3919
+ }): Promise<ProviderInfo[]>;
3920
+ auth: {
3921
+ status(options?: {
3922
+ signal?: AbortSignal;
3923
+ }): Promise<AuthStatus>;
3924
+ login: (body: {
3925
+ provider: string;
3926
+ apiKey?: string;
3927
+ }, options?: {
3928
+ signal?: AbortSignal;
3929
+ }) => Promise<{
3930
+ message: string;
3931
+ }>;
3932
+ logout: (body: {
3933
+ provider: string;
3934
+ }, options?: {
3935
+ signal?: AbortSignal;
3936
+ }) => Promise<{
3937
+ message: string;
3938
+ }>;
3939
+ };
3940
+ list: (options?: {
3941
+ signal?: AbortSignal;
3942
+ }) => Promise<ModelProviderConnection[]>;
3943
+ refresh: (options?: {
3944
+ signal?: AbortSignal;
3945
+ }) => Promise<ModelProviderConnection[]>;
3946
+ connect: (input: {
3947
+ provider: string;
3948
+ apiKey: string;
3949
+ headers?: Record<string, string> | undefined;
3950
+ secretHeaders?: Record<string, string | null> | undefined;
3951
+ }, options?: {
3952
+ signal?: AbortSignal;
3953
+ }) => Promise<ModelProviderConnection[]>;
3954
+ updateHeaders: (input: {
3955
+ provider: string;
3956
+ headers: Record<string, string>;
3957
+ secretHeaders?: Record<string, string | null> | undefined;
3958
+ }, options?: {
3959
+ signal?: AbortSignal;
3960
+ }) => Promise<ModelProviderConnection[]>;
3961
+ createCustom: (input: {
3962
+ value: CustomModelProviderInput;
3963
+ }, options?: {
3964
+ signal?: AbortSignal;
3965
+ }) => Promise<ModelProviderConnection[]>;
3966
+ syncAccount: (input: {
3967
+ value: CustomModelProviderInput;
3968
+ }, options?: {
3969
+ signal?: AbortSignal;
3970
+ }) => Promise<ModelProviderConnection[]>;
3971
+ updateCustom: (input: {
3972
+ provider: string;
3973
+ value: CustomModelProviderInput;
3974
+ }, options?: {
3975
+ signal?: AbortSignal;
3976
+ }) => Promise<ModelProviderConnection[]>;
3977
+ disconnect: (input: {
3978
+ provider: string;
3979
+ disableDefault?: boolean | undefined;
3980
+ replacement?: {
3981
+ provider: string;
3982
+ model: string;
3983
+ } | undefined;
3984
+ }, options?: {
3985
+ signal?: AbortSignal;
3986
+ }) => Promise<ModelProviderConnection[]>;
3987
+ removeCustom: (input: {
3988
+ provider: string;
3989
+ disableDefault?: boolean | undefined;
3990
+ replacement?: {
3991
+ provider: string;
3992
+ model: string;
3993
+ } | undefined;
3994
+ }, options?: {
3995
+ signal?: AbortSignal;
3996
+ }) => Promise<ModelProviderConnection[]>;
3997
+ defaults: {
3998
+ get: ({ accountGatewayProof, signal }?: {
3999
+ signal?: AbortSignal;
4000
+ } & {
4001
+ accountGatewayProof?: string;
4002
+ }) => Promise<ProviderDefaultsSnapshot>;
4003
+ updateModel: (input: {
4004
+ model: string;
4005
+ effort?: string | null | undefined;
4006
+ provider?: string | undefined;
4007
+ expectedRevision?: string | undefined;
4008
+ }, options?: {
4009
+ signal?: AbortSignal;
4010
+ }) => Promise<ProviderDefaultsSnapshot>;
4011
+ updateEffort: (input: {
4012
+ effort: string | null;
4013
+ expectedRevision: string;
4014
+ }, options?: {
4015
+ signal?: AbortSignal;
4016
+ }) => Promise<ProviderDefaultsSnapshot>;
4017
+ test: (input: {
4018
+ model: string;
4019
+ provider: string;
4020
+ }, options?: {
4021
+ signal?: AbortSignal;
4022
+ }) => Promise<ProviderConnectionTestResult>;
4023
+ };
4024
+ };
4025
+ /** Agent roles available to this connection. */
4026
+ readonly agents: {
4027
+ list(options?: {
4028
+ signal?: AbortSignal;
4029
+ }): Promise<AgentPersonaInfo[]>;
4030
+ };
4031
+ /** Available skills and their sources. */
4032
+ readonly skills: {
4033
+ list: (options?: {
4034
+ signal?: AbortSignal;
4035
+ }) => Promise<SkillSnapshot>;
4036
+ marketplace: {
4037
+ list: (options?: {
4038
+ signal?: AbortSignal;
4039
+ }) => Promise<SkillMarketplaceEntry[]>;
4040
+ install: (body: SkillMarketplaceInstallInput, options?: {
4041
+ signal?: AbortSignal;
4042
+ }) => Promise<SkillSnapshot>;
4043
+ };
4044
+ remove: (id: string, body: {
4045
+ expectedContent: string;
4046
+ }, options?: {
4047
+ signal?: AbortSignal;
4048
+ }) => Promise<SkillSnapshot>;
4049
+ };
2458
4050
  readonly schedules: ScheduleResource;
2459
4051
  readonly sessions: SessionResource;
2460
4052
  readonly attachments: AttachmentResource;
2461
4053
  readonly permissions: PermissionResource;
2462
- readonly jobs: JobResource;
2463
4054
  readonly events: EventResource;
2464
- readonly files: FilesResource;
2465
- constructor(options: BobanNomiClientOptions);
4055
+ /** Daemon plugin installation and lifecycle. Requires management access. */
4056
+ readonly plugins: PluginResource;
4057
+ readonly channels: ChannelResource;
4058
+ readonly projects: ProjectResource;
4059
+ readonly worktrees: WorktreeResource;
4060
+ readonly git: GitResource;
4061
+ readonly hooks: HookResource;
4062
+ readonly mcp: McpResource;
4063
+ readonly commands: CommandResource;
4064
+ readonly context: ContextResource;
4065
+ readonly diagnostics: DiagnosticResource;
4066
+ readonly maintenance: MaintenanceResource;
4067
+ readonly memory: MemoryResource;
4068
+ readonly settings: SettingsResource;
4069
+ /** Global daemon execution terminal access. Session-scoped output is under sessions.byId(). */
4070
+ readonly terminals: TerminalResource;
4071
+ constructor(options: BobanNomiClientOptions | HttpTransport);
2466
4072
  }
2467
4073
 
2468
4074
  /**
@@ -2476,61 +4082,16 @@ declare class UnsupportedSessionEventSchemaVersionError extends Error {
2476
4082
  constructor(event: SessionEventRecord);
2477
4083
  }
2478
4084
  /** 空客户端状态,作为 replay/hydrate 起点。 */
2479
- declare function createInitialClientState(): BobanNomiClientState;
4085
+ declare function createClientState(): BobanNomiClientState;
2480
4086
  /** 按序批量应用事件。 */
2481
4087
  declare function applyEvents(state: BobanNomiClientState, events: Iterable<SessionEventRecord>): BobanNomiClientState;
2482
4088
  /** Replace one session bucket with an atomic server snapshot. */
2483
- declare function applySessionSnapshot(state: BobanNomiClientState, snapshot: AgentSessionStateSnapshot): BobanNomiClientState;
4089
+ declare function replaceSessionState(state: BobanNomiClientState, snapshot: AgentSessionStateSnapshot): BobanNomiClientState;
2484
4090
  /**
2485
4091
  * 应用单条事件。已见过的 `seq` 直接返回原 state(引用相等,便于 live 去重)。
2486
4092
  */
2487
4093
  declare function applyEvent(state: BobanNomiClientState, event: SessionEventRecord): BobanNomiClientState;
2488
4094
 
2489
- interface SessionMessageWithParts {
2490
- message: SessionMessageRecord;
2491
- parts: SessionMessagePartRecord[];
2492
- }
2493
- declare function selectSessionMessagesWithParts(bucket: SessionBucket | undefined): SessionMessageWithParts[];
2494
- /**
2495
- * Default display view: hides superseded parts and drops assistant messages that
2496
- * have no visible parts left. The raw state keeps the diagnostic records.
2497
- */
2498
- declare function selectVisibleSessionMessagesWithParts(bucket: SessionBucket | undefined): SessionMessageWithParts[];
2499
- declare function selectSessionInputs(bucket: SessionBucket | undefined): SessionInputRecord[];
2500
- declare function selectSessionOrderedMessages(bucket: SessionBucket | undefined): SessionMessageRecord[];
2501
- declare function selectSessionParts(bucket: SessionBucket | undefined): SessionMessagePartRecord[];
2502
- declare function selectSessionRuns(bucket: SessionBucket | undefined): SessionRunRecord[];
2503
- /** Current bounded-retry wait, if the latest active run is waiting. */
2504
- declare function selectSessionModelRetry(bucket: SessionBucket | undefined): SessionModelRetryState | undefined;
2505
- /** Aggregated usage completeness for the most recently updated run. */
2506
- declare function selectSessionModelUsage(bucket: SessionBucket | undefined): SessionModelUsageSummary | undefined;
2507
- declare function selectSessionTasks(bucket: SessionBucket | undefined): SessionExecutionRecord[];
2508
- declare function selectSessionPermissions(bucket: SessionBucket | undefined): PermissionRequestRecord[];
2509
- declare function selectFirstPendingPermission(state: BobanNomiClientState, sessionId?: string): PermissionRequestRecord | undefined;
2510
-
2511
- interface SyncEventsClient {
2512
- sessions: {
2513
- getState(sessionId: string, options?: {
2514
- signal?: AbortSignal;
2515
- partView?: "summary";
2516
- }): Promise<AgentSessionStateSnapshot>;
2517
- };
2518
- events: {
2519
- list(options?: ListEventsOptions & {
2520
- signal?: AbortSignal;
2521
- }): Promise<SessionEventRecord[]>;
2522
- stream(options?: Omit<EventSyncOptions, "reconnectDelayMs"> & {
2523
- transportReconnect?: boolean;
2524
- }): AsyncIterable<SessionEventRecord>;
2525
- };
2526
- }
2527
- type GlobalEventReducer = (state: BobanNomiClientState, event: SessionEventRecord) => BobanNomiClientState;
2528
- declare function hydrateState(events: Iterable<SessionEventRecord>): BobanNomiClientState;
2529
- /** 公开迭代接口保留原有默认空闲超时和全局 replay 结束标记。 */
2530
- declare function syncEvents(client: SyncEventsClient, options?: EventSyncOptions & {
2531
- globalReducer?: GlobalEventReducer;
2532
- }): AsyncIterable<SyncEventUpdate>;
2533
-
2534
4095
  type SyncConnectionStatus = "idle" | "connecting" | "connected" | "reconnecting" | "error";
2535
4096
  interface SessionSyncControllerOptions {
2536
4097
  client: SyncEventsClient;
@@ -2565,18 +4126,6 @@ declare class SessionSyncController {
2565
4126
  start(): Promise<void>;
2566
4127
  }
2567
4128
 
2568
- interface WaitForRunOptions {
2569
- sessionId: string;
2570
- runId: string;
2571
- signal?: AbortSignal;
2572
- }
2573
- interface RunResult {
2574
- run: SessionRunRecord;
2575
- messages: SessionMessageWithParts[];
2576
- }
2577
- /** Wait for this Run's durable terminal state using the shared snapshot/recovery algorithm. */
2578
- declare function waitForRun(client: SyncEventsClient, options: WaitForRunOptions): Promise<RunResult>;
2579
-
2580
4129
  /** Normalize stored presets for client display and request construction. */
2581
4130
  declare function normalizeApprovalMode(value: unknown): ApprovalMode | undefined;
2582
4131
  declare function isWorkMode(value: unknown): value is WorkMode;
@@ -2584,5 +4133,5 @@ declare function isWorkMode(value: unknown): value is WorkMode;
2584
4133
  declare function readSessionRuntimeConfig(session: SessionRecord, defaults?: Partial<SessionRuntimeConfig>): SessionRuntimeConfig;
2585
4134
  declare function patchSessionRuntimeMetadata(metadata: Record<string, unknown>, patch: SessionRuntimeConfigPatch): Record<string, unknown>;
2586
4135
 
2587
- export { AttachmentResource, BobanNomiApiError, BobanNomiClient, CURRENT_PROTOCOL_VERSION, EventResource, FilesResource, HttpTransport, IncompatibleProtocolError, JobResource, PermissionResource, ProtocolClient, ProtocolValidationError, RuntimeResource, ScheduleResource, SessionManagementResource, SessionResource, SessionSyncController, SseTransport, UnsupportedSessionEventSchemaVersionError, applyEvent, applyEvents, applySessionSnapshot, attachmentRangeHeader, checkProtocolCompatibility, createInitialClientState, createPromptRequestId, hydrateState, isSupersededModelPart, isWorkMode, normalizeApprovalMode, normalizeDaemonBaseUrl, parseCreateSessionGoalInput, parseGoalActionInput, parseMcpCallResultData, parseUpdateSessionGoalInput, patchSessionRuntimeMetadata, readPluginUiInstance, readRuntimeMetadata, readSessionModelRetryState, readSessionModelUsage, readSessionRuntimeConfig, readWorkspaceChangesMetadata, responseArray, responseField, selectFirstPendingPermission, selectSessionInputs, selectSessionMessagesWithParts, selectSessionModelRetry, selectSessionModelUsage, selectSessionOrderedMessages, selectSessionParts, selectSessionPermissions, selectSessionRuns, selectSessionTasks, selectVisibleSessionMessagesWithParts, streamServerSentEvents, supportsFeature, syncEvents, waitForRun };
2588
- export type { AdmitClientPromptInput, AdmitPromptAttachmentInput, AgentEnvironmentCapabilities, AgentPersonaInfo, ApprovalMode, ApprovalReviewRecord, AttachmentAssetRecord, BobanNomiClientOptions, BobanNomiClientState, BobanNomiServerHealth, CancelQueuedClientPromptInput, CancelQueuedPromptResponse, CancelResponseMode, ClientProtocolSupport, CompactSessionResponse, ConfigureClientSessionInput, ContextBucketId, ContextUsageBucket, ContextUsageSnapshot, ContextUsageTip, ContextUsageTipCode, CreateBackgroundShellInput, CreateBackgroundShellResult, CreateClientSessionInput, CreateScheduledTaskInput, CreateSessionGoalInput, CustomModelProviderInput, DispatchedSessionCreation, DownloadAttachmentOptions, DraftComposerOptions, DraftComposerTarget, EditLatestClientPromptInput, EventSyncOptions, ExecutionInstructions, ForkClientSessionInput, GoalActionInput, GoalExternalWait, GoalStopReason, HookInfo, HttpRequestOptions, HttpTransportOptions, InputDelivery, InterruptSessionResponse, JobCancelReceipt, JobCapabilities, JobInputReceipt, JobKind, JobListResult, JobReadResult, JobSnapshot, JobStatus, JobTarget, JobWaitResult, JsonValue, ListClientMessagePartsOptions, ListEventsOptions, ListMessagePartsOptions, ListMessagesOptions, ListPermissionsOptions, ListSessionsOptions, McpServerStatus, ModelInfo, ModelProviderConnection, ModelProviderInfo, ModelProviderRequest, PermissionRequestRecord, PermissionStatus, PluginArchiveError, PluginArchivePreview, PluginGitPreview, PluginInfo, PluginRuntimeStatus, PluginUiInstanceRecord, PluginUiInventory, PromoteQueuedClientPromptInput, PromoteQueuedPromptResponse, PromptInputForClient, PromptResponse, ProtocolCompatibility, ProviderConnectionTestResult, ProviderDefaultsRequest, ProviderDefaultsSnapshot, QueuedPromptCancelReceipt, RawRequestOptions, RememberSessionResponse, ReplyPermissionInput, ResolvedSessionConfiguration, ResumeInterruptedRunInput, ResumeInterruptedRunResponse, RewindSessionResponse, RunResult, ScheduledRunRecord, ScheduledTaskRecord, ScheduledTaskStatusSummary, SearchSessionsOptions, ServerCapabilities, SessionActivityPage, SessionAttachmentMessagePartRecord, SessionBucket, SessionComposerContext, SessionConfigurationInput, SessionConfigurationOptions, SessionConfigurationResultInput, SessionConfigurationSnapshot, SessionControlOriginal, SessionControlReceipt, SessionControls, SessionCreationReceipt, SessionDirectoryEntry, SessionDirectoryPage, SessionDirectoryResult, SessionEventRecord, SessionExecutionRecord, SessionExportResponse, SessionFileErrorCode, SessionFileFindInput, SessionFileFindOptions, SessionFileInfo, SessionFileListInput, SessionFileListOptions, SessionFileReadInput, SessionFileReadOptions, SessionFileRequestOptions, SessionFileSearchInput, SessionFileSearchMatch, SessionFileSearchOptions, SessionFileStatInput, SessionFindFilesResult, SessionGoal, SessionGoalRequestReceipt, SessionInputAttachmentRecord, SessionInputRecord, SessionManagementAction, SessionMessagePartRecord, SessionMessageRecord, SessionMessageWithParts, SessionModelRetryState, SessionModelUsageSummary, SessionMutationPublicReceipt, SessionRecord, SessionResourceRevision, SessionRunAttemptRecord, SessionRunRecord, SessionRuntimeConfig, SessionRuntimeConfigPatch, SessionSearchFilesResult, SessionSearchResult, AgentSessionStateSnapshot as SessionStateSnapshot, SessionSyncControllerOptions, SessionTextFileResult, SessionTransformationMessagePartRecord, SessionUsageResponse, SessionUserInputItem, SkillInfo, SkillProject, SkillSnapshot, SkillSource, SyncConnectionStatus, SyncEventUpdate, SyncEventsClient, UpdateClientSessionInput, UpdateScheduledTaskInput, UpdateSessionGoalInput, UploadAttachmentInput, WaitForRunOptions, WorkMode, WorkspaceChangeFile, WorkspaceChangesMetadata };
4136
+ export { AttachmentResource, BobanNomiApiError, BobanNomiClient, CURRENT_PROTOCOL_VERSION, ChannelResource, CommandResource, ContextResource, DiagnosticResource, EventResource, GitResource, HookResource, HttpTransport, IncompatibleProtocolError, MaintenanceResource, McpResource, McpServersResource, MemoryResource, PermissionResource, PluginMarketplaceResource, PluginResource, ProjectResource, ProtocolClient, ProtocolValidationError, ScheduleResource, SessionResource, SessionSyncController, SettingsResource, SseTransport, TerminalResource, UnsupportedSessionEventSchemaVersionError, WorktreeResource, applyEvent, applyEvents, attachmentRangeHeader, checkProtocolCompatibility, createClientState, createSessionRequestId, getVisibleSessionMessages, hydrateState, isSupersededModelPart, isWorkMode, normalizeApprovalMode, normalizeDaemonBaseUrl, parseCreateSessionGoalInput, parseGoalActionInput, parseMcpCallResultData, parseUpdateSessionGoalInput, patchSessionRuntimeMetadata, readPluginUiInstance, readRuntimeMetadata, readSessionModelRetryState, readSessionModelUsage, readSessionRuntimeConfig, readWorkspaceChangesMetadata, replaceSessionState, responseArray, responseField, selectFirstPendingPermission, selectSessionInputs, selectSessionMessagesWithParts, selectSessionModelRetry, selectSessionModelUsage, selectSessionOrderedMessages, selectSessionParts, selectSessionPermissions, selectSessionRuns, selectSessionTasks, streamServerSentEvents, supportsFeature, syncEvents };
4137
+ export type { AdmitClientPromptInput, AdmitPromptAttachmentInput, AgentEnvironmentCapabilities, AgentPersonaInfo, ApprovalMode, ApprovalReviewRecord, AttachmentAssetRecord, AttachmentStorageGcResult, AttachmentStorageIssue, AttachmentStorageRepairResult, AttachmentStorageReport, AuthStatus, BobanNomiClientOptions, BobanNomiClientState, BobanNomiServerHealth, CancelQueuedClientPromptInput, CancelQueuedPromptResponse, CancelResponseMode, ChannelConnectorRuntimeStatus, ChannelDeliveryRecord, ChannelDeliveryStatus, ChannelDenialNotice, ChannelDomain, ChannelQuery, ChannelRuntimeControlInput, ChannelRuntimeState, ChannelRuntimeStatus, ChannelStatusSnapshot, CleanupCandidate, CleanupPreview, CleanupResult, ClearMemoryInput, ClientProtocolSupport, CommandCatalogEntry, CommandKind, CommandSelection, CommandSource, ConfigureClientSessionInput, ContextBucketId, ContextUsageBucket, ContextUsageSnapshot, ContextUsageTip, ContextUsageTipCode, CreateBackgroundShellInput, CreateBackgroundShellResult, CreateClientSessionInput, CreateScheduledTaskInput, CreateSessionByProjectInput, CreateSessionGoalInput, CustomModelProviderInput, DaemonRestartPreview, DiagnosticExecutionQuery, DispatchedSessionCreation, DispatchedSessionCreationRequest, DownloadAttachmentOptions, DraftComposerOptions, DraftComposerTarget, DurableChannelMessageInput, DurableChannelMessageResult, EditLatestClientPromptInput, EventSyncOptions, ExecutionInstructions, ExpectedModelConnection, ExternalConversationRecord, FactReplacementResult, FeishuAllowInput, FeishuChannelSnapshot, FeishuComposedSnapshot, FeishuConnectInput, FeishuPatchInput, FeishuRegistrationSnapshot, FeishuRegistrationStartInput, FeishuRegistrationState, ForkClientSessionInput, GlobalSettingsPatch, GoalActionInput, GoalExternalWait, GoalStopReason, HookInfo, HostDiagnosticSnapshots, HttpRequestOptions, HttpTransportOptions, InputDelivery, InterruptSessionResponse, JobCancelReceipt, JobCapabilities, JobInputReceipt, JobKind, JobListResult, JobReadResult, JobSnapshot, JobStatus, JobTarget, JobWaitResult, JsonValue, ListClientMessagePartsOptions, ListCommandsOptions, ListEventsOptions, ListMessagePartsOptions, ListMessagesOptions, ListPermissionsOptions, ListProjectsOptions, ListSessionJobsOptions, ListSessionsOptions, MaintenanceBackupManifest, MaintenanceBackupResult, MarketplaceAddSourceRequest, MarketplaceCancelRequest, MarketplaceCancelResponse, MarketplaceCatalog, MarketplaceCatalogRequest, MarketplaceEntry, MarketplaceInstallInput, MarketplaceInstallRequest, MarketplaceOperation, MarketplacePreview, MarketplacePreviewRequest, MarketplaceProvenance, MarketplaceSelection, MarketplaceSource, MarketplaceSourceEnabledRequest, MarketplaceSourceView, MarketplaceSourcesResponse, McpConfigOperationResult, McpManagedServerConfig, McpManagedServerSummary, McpOAuthLoginInput, McpOAuthLoginResponse, McpOAuthStatusSnapshot, McpRuntimeStatus, McpRuntimeSyncResult, McpServerRuntimeRef, McpServerStatus, MemoryEntryRecord, MemoryListResponse, MemoryRevision, ModelInfo, ModelProviderConnection, ModelProviderInfo, ModelProviderRequest, OAuthOperationEvent, OAuthOperationView, OutputStyleInfo, PermissionRequestRecord, PermissionStatus, PluginArchiveError, PluginArchiveInstallInput, PluginArchivePreview, PluginArchivePreviewInput, PluginGitInstallInput, PluginGitPreview, PluginGitPreviewInput, PluginInfo, PluginListResult, PluginLocalInstallInput, PluginLocalPreview, PluginLocalPreviewInput, PluginRuntimeStatus, PluginUiInstanceRecord, PluginUiInventory, ProjectFactRecord, ProjectRecord, PromoteQueuedClientPromptInput, PromoteQueuedPromptResponse, PromptResponse, ProtocolCompatibility, ProviderConnectionTestResult, ProviderDefaultsRequest, ProviderDefaultsSnapshot, ProviderInfo, QueuedPromptCancelReceipt, RawRequestOptions, RecordChannelDeliveryInput, ReloadPluginsResponse, RememberSessionResponse, ReplyPermissionInput, ResolvedSessionConfiguration, ResumeInterruptedRunInput, ResumeInterruptedRunResponse, RewindSessionResponse, RunResult, ScheduledRunRecord, ScheduledTaskRecord, ScheduledTaskStatusSummary, SearchSessionsOptions, ServerCapabilities, SessionActivityPage, SessionAttachmentMessagePartRecord, SessionBucket, SessionComposerContext, SessionConfigurationInput, SessionConfigurationOptions, SessionConfigurationResultInput, SessionConfigurationSnapshot, SessionControlOriginal, SessionControlReceipt, SessionControls, SessionCreationInput, SessionCreationReceipt, SessionDirectoryEntry, SessionDirectoryPage, SessionDirectoryResult, SessionEventRecord, SessionExecutionRecord, SessionExportResponse, SessionFileErrorCode, SessionFileFindInput, SessionFileFindOptions, SessionFileInfo, SessionFileListInput, SessionFileListOptions, SessionFileReadInput, SessionFileReadOptions, SessionFileRequestOptions, SessionFileSearchInput, SessionFileSearchMatch, SessionFileSearchOptions, SessionFileStatInput, SessionFindFilesResult, SessionGoal, SessionGoalRequestReceipt, SessionHandle, SessionInputAttachmentRecord, SessionInputRecord, SessionManagementAction, SessionMessagePartRecord, SessionMessageRecord, SessionMessageWithParts, SessionModelRetryState, SessionModelUsageSummary, SessionMutationPublicReceipt, SessionRecord, SessionResourceRevision, SessionRunAttemptRecord, SessionRunRecord, SessionRuntimeConfig, SessionRuntimeConfigPatch, SessionSearchFilesResult, SessionSearchResult, AgentSessionStateSnapshot as SessionStateSnapshot, SessionSyncControllerOptions, SessionTextFileResult, SessionTransformationMessagePartRecord, SessionUsageResponse, SessionUserInputItem, SkillInfo, SkillMarketplaceEntry, SkillMarketplaceInstallInput, SkillProject, SkillSnapshot, SkillSource, StartDreamResponse, StorageCategory, StorageReport, StorageRetentionPolicy, SyncConnectionStatus, SyncEventUpdate, SyncEventsClient, TaskWorktreeRecord, TerminalCreateRequest, TerminalEvent, TerminalReadRequest, TerminalReadResult, TerminalResizeRequest, TerminalRuntime, TerminalSessionInfo, TerminalSessionStatus, TerminalSignal, TerminalSource, TerminalWriteRequest, UpdateMemoryEntryInput, UpdateScheduledTaskInput, UpdateSessionGoalInput, UploadAttachmentInput, UsageFilter, UsagePrice, UsageReport, UsageRequest, UsageSettings, WorkMode, WorkspaceChangeFile, WorkspaceChangesMetadata };