@bobannomi/app-host 0.1.0-next.1 → 0.1.1

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.
@@ -40,286 +40,6 @@ interface ExecutionInstructions {
40
40
  content: string;
41
41
  }
42
42
 
43
- /** How an agent explains findings and delivers results, independently of update timing. */
44
- type ReplyStyle = "collaborative" | "direct" | "explanatory";
45
-
46
- /** Application choices; none of these fields grants access to a resource. */
47
- interface SessionConfigurationInput {
48
- model?: {
49
- provider: string;
50
- model: string;
51
- };
52
- roleId?: string | null;
53
- systemPrompt?: string | null;
54
- executionInstructions?: {
55
- revision: number;
56
- content: string;
57
- } | null;
58
- effort?: string | null;
59
- workMode?: "execute" | "plan";
60
- maxTurns?: number;
61
- sessionMode?: "direct" | "coordinator";
62
- replyStyle?: ReplyStyle;
63
- approvalMode?: "ask" | "auto_review" | "full_access";
64
- tools?: {
65
- allowed?: string[];
66
- denied?: string[];
67
- };
68
- pluginsEnabled?: boolean;
69
- pluginAutoSelectionEnabled?: boolean;
70
- activePluginId?: string | null;
71
- pluginIds?: string[];
72
- serviceBindings?: string[];
73
- memory?: {
74
- enabled: boolean;
75
- };
76
- }
77
- interface ResolvedSessionConfiguration extends Required<Omit<SessionConfigurationInput, "tools">> {
78
- tools: {
79
- allowed: string[];
80
- denied: string[];
81
- };
82
- }
83
- interface SessionConfigurationSnapshot {
84
- revision: number;
85
- configuration: ResolvedSessionConfiguration;
86
- configurationRoot: {
87
- cwd: string;
88
- settingsRoot: string;
89
- };
90
- }
91
- interface SessionCreationReceipt {
92
- dataScopeId: string;
93
- sessionId: string;
94
- requestId: string;
95
- action: "create-session";
96
- state: "prepared" | "completed" | "unknown";
97
- revision?: number;
98
- configuration?: SessionConfigurationSnapshot;
99
- }
100
- interface SessionConfigurationBinding {
101
- revision: number;
102
- /** Explicit creation choices plus subsequent editor deltas; never accepted as public metadata. */
103
- configurationInput?: SessionConfigurationInput;
104
- /** Original non-role defaults for fields that role selection can replace. */
105
- roleBaseConfiguration?: SessionConfigurationInput;
106
- effectiveConfiguration: ResolvedSessionConfiguration;
107
- resolvedResources: (ConfigurationResourceRef & {
108
- revision: string;
109
- })[];
110
- defaultsRevision: string;
111
- configurationRoot: {
112
- cwd: string;
113
- settingsRoot: string;
114
- };
115
- }
116
- interface ConfigurationResourceRef {
117
- kind: "model" | "role" | "tool" | "plugin" | "service" | "skill" | "mcp";
118
- id: string;
119
- }
120
-
121
- /** A directory's actual filesystem identity, captured by trusted execution code. */
122
- interface SessionExecutionRoot {
123
- readonly canonicalRoot: string;
124
- readonly rootIdentity: {
125
- readonly dev: string;
126
- readonly ino: string;
127
- };
128
- }
129
- /** Execution provenance describes a business relationship; it grants no access. */
130
- type SessionExecutionSource = {
131
- readonly kind: "interactive";
132
- } | {
133
- readonly kind: "channel";
134
- readonly conversationId: string;
135
- } | {
136
- readonly kind: "automation";
137
- readonly service: string;
138
- readonly sourceId: string;
139
- } | {
140
- readonly kind: "child";
141
- readonly sessionId: string;
142
- readonly runId: string;
143
- readonly childId: string;
144
- readonly postRunPurpose?: "review" | "maintenance";
145
- } | {
146
- readonly kind: "fork";
147
- readonly sessionId: string;
148
- readonly requestId: string;
149
- };
150
- /** Frozen alongside configuration when work is accepted, then copied to Input/Run. */
151
- interface SessionExecutionBinding {
152
- readonly version: 1;
153
- readonly cwd: SessionExecutionRoot;
154
- readonly settingsRoot: SessionExecutionRoot;
155
- readonly source: SessionExecutionSource;
156
- }
157
-
158
- /**
159
- * `closing` 表示 Session 正在停止当前工作并等待资源释放,此时不再接收新工作。
160
- * 等待结束后,Session 会进入不可逆的 archived 状态。
161
- */
162
- type SessionStatus = "idle" | "running" | "closing" | "archived" | "error";
163
- type SessionStorage = "sqlite" | "memory";
164
- interface SessionRecord {
165
- id: string;
166
- storage?: SessionStorage;
167
- parentId?: string;
168
- projectId?: string;
169
- cwd: string;
170
- cwdRelative?: string;
171
- title: string;
172
- model: string;
173
- agent?: string;
174
- status: SessionStatus;
175
- metadata: Record<string, unknown> & {
176
- configurationBinding?: SessionConfigurationBinding;
177
- executionBinding?: SessionExecutionBinding;
178
- };
179
- createdAt: number;
180
- updatedAt: number;
181
- archivedAt?: number;
182
- }
183
-
184
- interface WorkspaceConversationCreation {
185
- dataScopeId: string;
186
- requestId: string;
187
- sessionId: string;
188
- workspaceId?: string;
189
- outsideProject?: boolean;
190
- taskLocation: "current" | "worktree";
191
- configuration: SessionConfigurationInput;
192
- preparationRevision?: string;
193
- }
194
- interface WorkspaceConversationResult extends SessionCreationReceipt {
195
- session?: SessionRecord;
196
- operationState?: "prepared" | "running" | "completed" | "failed" | "unknown";
197
- indexBindingPending?: true;
198
- workspaceId?: string;
199
- executionRoot?: string;
200
- privateSessionId?: string;
201
- worktree?: {
202
- id: string;
203
- path: string;
204
- branch: string;
205
- sourceHead: string;
206
- projectId: string;
207
- projectPath: string;
208
- configDir: string;
209
- environment: "native" | "wsl";
210
- distribution?: string;
211
- };
212
- }
213
-
214
- interface ControlOption {
215
- id: string;
216
- name: string;
217
- }
218
- interface DraftComposerTarget {
219
- source: "instance";
220
- workspaceId?: string;
221
- outsideProject?: boolean;
222
- roleId?: string | null;
223
- }
224
- interface DraftComposerOptions {
225
- source: "instance";
226
- optionsRevision: string;
227
- skills: (ControlOption & {
228
- path: string;
229
- source?: string;
230
- })[];
231
- plugins: (ControlOption & {
232
- agents: ControlOption[];
233
- })[];
234
- }
235
- type SessionControlAction = "readContext" | "configure" | "compact" | "edit" | "fork" | "resume" | "goalRead" | "goalWrite" | "goalStop";
236
- interface SessionControls {
237
- dataScopeId: string;
238
- sessionId: string;
239
- source: "instance" | "auxiliary" | "im";
240
- revision: number;
241
- optionsRevision: string;
242
- actions: Record<SessionControlAction, boolean>;
243
- models: ControlOption[];
244
- roles: ControlOption[];
245
- efforts: ControlOption[];
246
- workModes: ControlOption[];
247
- permissionModes?: ControlOption[];
248
- appServiceBindings?: ControlOption[];
249
- skills: (ControlOption & {
250
- path: string;
251
- source?: string;
252
- })[];
253
- commands: ControlOption[];
254
- contexts: ControlOption[];
255
- plugins?: (ControlOption & {
256
- agents: ControlOption[];
257
- })[];
258
- }
259
- type SessionControlOriginal = {
260
- action: "compact";
261
- body: {
262
- requestId: string;
263
- expectedRevision: number;
264
- };
265
- } | {
266
- action: "fork";
267
- body: {
268
- requestId: string;
269
- id: string;
270
- copyHistory?: boolean;
271
- beforeMessageId?: string;
272
- afterMessageId?: string;
273
- storage?: "sqlite";
274
- };
275
- };
276
- interface SessionControlReceipt {
277
- dataScopeId: string;
278
- sessionId: string;
279
- requestId: string;
280
- action: SessionControlOriginal["action"] | "configure";
281
- state: "prepared" | "created" | "completed" | "unknown";
282
- revision?: number;
283
- targetSessionId?: string;
284
- }
285
- interface SessionControlMethodMap {
286
- "sessions.getDraftComposerOptions": {
287
- params: DraftComposerTarget;
288
- result: DraftComposerOptions;
289
- };
290
- "sessions.createConversation": {
291
- params: WorkspaceConversationCreation;
292
- result: WorkspaceConversationResult;
293
- };
294
- "sessions.bindConversationIndex": {
295
- params: {
296
- original: WorkspaceConversationCreation;
297
- dataScopeId: string;
298
- };
299
- result: WorkspaceConversationResult;
300
- };
301
- "sessions.getConversationCreationResult": {
302
- params: WorkspaceConversationCreation;
303
- result: WorkspaceConversationResult | null;
304
- };
305
- "sessions.getControls": {
306
- params: {
307
- connectionId: string;
308
- sessionId: string;
309
- };
310
- result: SessionControls;
311
- };
312
- "sessions.getControlResult": {
313
- params: {
314
- connectionId?: string;
315
- requestId: string;
316
- sessionId: string;
317
- original: SessionControlOriginal;
318
- };
319
- result: SessionControlReceipt | null;
320
- };
321
- }
322
-
323
43
  interface ServiceWork {
324
44
  requestId: string;
325
45
  state: ServiceWorkState;
@@ -441,7 +161,7 @@ type Entry<P, R> = {
441
161
  params: P;
442
162
  result: R;
443
163
  };
444
- interface ServiceHostMethodMap extends Pick<SessionControlMethodMap, "sessions.getControls" | "sessions.getControlResult"> {
164
+ interface ServiceHostMethodMap {
445
165
  "secrets.get": Entry<{
446
166
  key: string;
447
167
  }, string | null>;
@@ -464,11 +184,6 @@ interface ServiceHostMethodMap extends Pick<SessionControlMethodMap, "sessions.g
464
184
  id: string;
465
185
  name: string;
466
186
  }[]>;
467
- "agent.listRoles": Entry<Record<string, never>, {
468
- id: string;
469
- name: string;
470
- description: string;
471
- }[]>;
472
187
  "agent.getConnection": Entry<{
473
188
  workspaceId?: string;
474
189
  executionRoot?: string;
@@ -507,7 +222,7 @@ interface ServiceHostMethodMap extends Pick<SessionControlMethodMap, "sessions.g
507
222
  }, ServiceWork | null>;
508
223
  }
509
224
  type ServiceHostMethod = keyof ServiceHostMethodMap;
510
- declare const SERVICE_HOST_METHODS: readonly ["secrets.get", "secrets.set", "secrets.delete", "context.get", "context.resolveInvocation", "agent.listModels", "agent.listRoles", "agent.getConnection", "agent.resolveSkills", "sessions.getConnection", "sessions.getControls", "sessions.getControlResult", "workspace.gitStatus", "workspace.createTaskWorktree", "workspace.getWorktree", "workspace.releaseExecutionRoot", "work.list", "work.get"];
225
+ declare const SERVICE_HOST_METHODS: readonly ["secrets.get", "secrets.set", "secrets.delete", "context.get", "context.resolveInvocation", "agent.listModels", "agent.getConnection", "agent.resolveSkills", "sessions.getConnection", "workspace.gitStatus", "workspace.createTaskWorktree", "workspace.getWorktree", "workspace.releaseExecutionRoot", "work.list", "work.get"];
511
226
  declare const SERVICE_HOST_MAX_FRAME_BYTES: number;
512
227
  declare const SERVICE_HOST_MAX_PENDING = 64;
513
228
  declare const validServiceContext: (v: unknown) => v is ServiceContext;
@@ -548,6 +263,92 @@ type ServiceHostFrame = PageFetchFrame | {
548
263
  };
549
264
  declare function isServiceHostFrame(v: unknown): v is ServiceHostFrame;
550
265
 
266
+ /** How an agent explains findings and delivers results, independently of update timing. */
267
+ type ReplyStyle = "collaborative" | "direct" | "explanatory";
268
+
269
+ /** User-facing authorization presets, independent from read-only planning. */
270
+ type ApprovalMode = "ask" | "auto_review" | "full_access";
271
+ type WorkMode = "execute" | "plan";
272
+ type PermissionMode = "default" | "plan" | "full_auto" | ApprovalMode;
273
+ /** Ordered user inputs already written to the model history of one Run. */
274
+ interface AppliedInputStateSnapshot {
275
+ revision: number;
276
+ inputIds: readonly string[];
277
+ }
278
+ interface AgentPermissionRequest {
279
+ toolName: string;
280
+ /** Captured from the actual tool registration by the execution pipeline. */
281
+ confirmationMode?: "manual" | "client";
282
+ /** Host-scoped concrete operation; never reuse or create a tool-wide session grant. */
283
+ confirmation?: "once";
284
+ /** Captured host registration; never supplied by the model. */
285
+ toolSource?: string;
286
+ toolDescription?: string;
287
+ reason?: string;
288
+ input?: Record<string, unknown>;
289
+ }
290
+ interface AgentPermissionDecision {
291
+ status: "approved" | "denied" | "expired";
292
+ decision?: "once" | "session";
293
+ reason?: string;
294
+ answer?: string;
295
+ }
296
+
297
+ interface ControlOption {
298
+ id: string;
299
+ name: string;
300
+ }
301
+ type SessionControlAction = "readContext" | "configure" | "compact" | "edit" | "fork" | "resume" | "goalRead" | "goalWrite" | "goalStop";
302
+ interface SessionControls {
303
+ dataScopeId: string;
304
+ sessionId: string;
305
+ source: "instance" | "auxiliary" | "im";
306
+ revision: number;
307
+ optionsRevision: string;
308
+ actions: Record<SessionControlAction, boolean>;
309
+ models: ControlOption[];
310
+ roles: ControlOption[];
311
+ efforts: ControlOption[];
312
+ workModes: ControlOption[];
313
+ permissionModes?: ControlOption[];
314
+ appServiceBindings?: ControlOption[];
315
+ skills: (ControlOption & {
316
+ path: string;
317
+ source?: string;
318
+ })[];
319
+ commands: ControlOption[];
320
+ contexts: ControlOption[];
321
+ plugins?: (ControlOption & {
322
+ agents: ControlOption[];
323
+ })[];
324
+ }
325
+ type SessionControlOriginal = {
326
+ action: "compact";
327
+ body: {
328
+ requestId: string;
329
+ expectedRevision: number;
330
+ };
331
+ } | {
332
+ action: "fork";
333
+ body: {
334
+ requestId: string;
335
+ id: string;
336
+ copyHistory?: boolean;
337
+ beforeMessageId?: string;
338
+ afterMessageId?: string;
339
+ storage?: "sqlite";
340
+ };
341
+ };
342
+ interface SessionControlReceipt {
343
+ dataScopeId: string;
344
+ sessionId: string;
345
+ requestId: string;
346
+ action: SessionControlOriginal["action"] | "configure";
347
+ state: "prepared" | "created" | "completed" | "unknown";
348
+ revision?: number;
349
+ targetSessionId?: string;
350
+ }
351
+
551
352
  interface AppAgentModel {
552
353
  id: string;
553
354
  name: string;
@@ -580,11 +381,6 @@ interface AppHostAgent {
580
381
  privateSessionId?: string;
581
382
  }): Promise<AgentConnection>;
582
383
  listModels(): Promise<AppAgentModel[]>;
583
- listRoles(): Promise<{
584
- id: string;
585
- name: string;
586
- description: string;
587
- }[]>;
588
384
  resolveSkills(skillIds: string[]): Promise<{
589
385
  type: "skill";
590
386
  name: string;
@@ -592,19 +388,6 @@ interface AppHostAgent {
592
388
  }[]>;
593
389
  }
594
390
 
595
- interface AppHostSessionControls {
596
- getControls(input: {
597
- connection: AgentConnection;
598
- sessionId: string;
599
- }): Promise<SessionControls>;
600
- getControlResult(input: {
601
- connection?: AgentConnection;
602
- requestId: string;
603
- sessionId: string;
604
- original: SessionControlOriginal;
605
- }): Promise<SessionControlReceipt | null>;
606
- }
607
-
608
391
  interface TextBlock {
609
392
  type: "text";
610
393
  text: string;
@@ -741,29 +524,6 @@ interface RunToolResultStore {
741
524
  }): Promise<ToolResultSearch>;
742
525
  }
743
526
 
744
- /** User-facing authorization presets, independent from read-only planning. */
745
- type ApprovalMode = "ask" | "auto_review" | "full_access";
746
- type WorkMode = "execute" | "plan";
747
- type PermissionMode = "default" | "plan" | "full_auto" | ApprovalMode;
748
- interface AgentPermissionRequest {
749
- toolName: string;
750
- /** Captured from the actual tool registration by the execution pipeline. */
751
- confirmationMode?: "manual" | "client";
752
- /** Host-scoped concrete operation; never reuse or create a tool-wide session grant. */
753
- confirmation?: "once";
754
- /** Captured host registration; never supplied by the model. */
755
- toolSource?: string;
756
- toolDescription?: string;
757
- reason?: string;
758
- input?: Record<string, unknown>;
759
- }
760
- interface AgentPermissionDecision {
761
- status: "approved" | "denied" | "expired";
762
- decision?: "once" | "session";
763
- reason?: string;
764
- answer?: string;
765
- }
766
-
767
527
  /** Agent-reported progress; format validity alone does not prove completion. */
768
528
  interface StructuredDelivery {
769
529
  status: "done" | "partial" | "blocked" | "waiting";
@@ -952,6 +712,12 @@ interface AgentSerializedError {
952
712
  stack?: string;
953
713
  }
954
714
  type AgentEventInput = {
715
+ type: "input.applied";
716
+ data: {
717
+ inputIds: string[];
718
+ revision: number;
719
+ };
720
+ } | {
955
721
  type: "input.accepted";
956
722
  data: {
957
723
  content: string | ContentBlock[];
@@ -961,7 +727,9 @@ type AgentEventInput = {
961
727
  };
962
728
  } | {
963
729
  type: "run.started";
964
- data: Record<string, never>;
730
+ data: {
731
+ tracksAppliedInputs?: true;
732
+ };
965
733
  } | {
966
734
  type: "run.completed";
967
735
  data: {
@@ -1119,6 +887,7 @@ interface AgentExecutionProfile {
1119
887
  executableHooks?: boolean;
1120
888
  }
1121
889
  interface AgentEffectContext {
890
+ appliedInputState?: AppliedInputStateSnapshot;
1122
891
  agentId: string;
1123
892
  sessionId: string;
1124
893
  runId: string;
@@ -1145,7 +914,18 @@ interface AgentRunToolContribution {
1145
914
  /** End only after this exact definition succeeds and the whole batch is delivered. */
1146
915
  readonly endRunOnSuccess?: true;
1147
916
  }
917
+ interface RequestImageCapabilities {
918
+ modelCapabilities: {
919
+ image: "native" | "unsupported" | "unknown";
920
+ };
921
+ providerCapabilities: {
922
+ image: "native" | "unsupported" | "unknown";
923
+ imageMediaTypes: readonly string[];
924
+ };
925
+ }
1148
926
  interface AgentRunContribution {
927
+ /** Prepare only this Run's initial input against the model selected for its first request. */
928
+ readonly prepareInitialContent?: (images: RequestImageCapabilities) => Promise<string | ContentBlock[]>;
1149
929
  readonly systemGuidance?: string;
1150
930
  readonly tools?: readonly AgentRunToolContribution[];
1151
931
  /** Include actual tool result IDs as model-visible reference data. */
@@ -1184,6 +964,8 @@ interface AgentExecutionContext {
1184
964
  emit(event: AgentEventInput): Promise<void>;
1185
965
  /** Optional, non-durable diagnostics; never used for execution decisions. */
1186
966
  observe?(event: AgentEventInput): void;
967
+ getAppliedInputState?(): AppliedInputStateSnapshot;
968
+ markInputsApplied?(inputIds: readonly string[]): Promise<void>;
1187
969
  takeSteeredInputs(options?: {
1188
970
  closeIfEmpty?: boolean;
1189
971
  }): Promise<AgentChildInput[]>;
@@ -1454,6 +1236,8 @@ interface ToolContext {
1454
1236
  environment?: ExecutionEnvironmentHandle;
1455
1237
  /** Host-captured network policy of the actual calling session, including inherited tools. */
1456
1238
  canUseNetwork?: boolean;
1239
+ /** Approval policy captured for this actual tool call by the runtime. */
1240
+ approvalMode?: ApprovalMode;
1457
1241
  sessionId?: string;
1458
1242
  /** Stable model-issued tool call identity. Retries of the same call reuse this value. */
1459
1243
  toolCallId?: string;
@@ -1633,13 +1417,7 @@ interface AppServiceHost {
1633
1417
  resolveInvocation(ticket: string): Promise<ServiceInvocation>;
1634
1418
  };
1635
1419
  agent: AppHostAgent;
1636
- sessions: Pick<AppHostSessionControls, "getControls"> & {
1637
- getControlResult(input: {
1638
- connection: AgentConnection;
1639
- sessionId: string;
1640
- requestId: string;
1641
- original: SessionControlOriginal;
1642
- }): Promise<SessionControlReceipt | null>;
1420
+ sessions: {
1643
1421
  getConnection(input: {
1644
1422
  dataScopeId: string;
1645
1423
  sessionId: string;