@tutti-os/agent-gui 0.0.46 → 0.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/{AgentMentionSearchController-D5ks45fN.d.ts → AgentMentionSearchController-CExFPobz.d.ts} +1 -1
  2. package/dist/AgentMessageMarkdown-DeYPURtF.d.ts +7 -0
  3. package/dist/agent-conversation/index.d.ts +4 -3
  4. package/dist/agent-conversation/index.js +8 -8
  5. package/dist/agent-message-center/index.d.ts +1 -1
  6. package/dist/agent-message-center/index.js +9 -9
  7. package/dist/{agentConversationVM-1QgRwvwZ.d.ts → agentConversationVM-BTMtRteS.d.ts} +14 -0
  8. package/dist/{AgentMessageMarkdown-Cts0dAIm.d.ts → agentGuiNodeTypes-B5Y6yDKy.d.ts} +43 -9
  9. package/dist/app/renderer/agentactivity.css +92 -9
  10. package/dist/{chunk-FRG36S6N.js → chunk-2FOBSURO.js} +5 -5
  11. package/dist/chunk-2FOBSURO.js.map +1 -0
  12. package/dist/{chunk-AMNXH4DJ.js → chunk-2RYZ4EBF.js} +2 -2
  13. package/dist/{chunk-EIC7XS3C.js → chunk-5QTC2L52.js} +2 -2
  14. package/dist/{chunk-ZJ7OSY4T.js → chunk-7NCWSH7U.js} +9 -9
  15. package/dist/{chunk-ZJ7OSY4T.js.map → chunk-7NCWSH7U.js.map} +1 -1
  16. package/dist/{chunk-62QOR3TC.js → chunk-HCS3HUUX.js} +5 -5
  17. package/dist/{chunk-OL54R6OL.js → chunk-J3SJZMI5.js} +2 -2
  18. package/dist/{chunk-VFQR7AZI.js → chunk-KACBTC7Y.js} +25 -3
  19. package/dist/chunk-KACBTC7Y.js.map +1 -0
  20. package/dist/{chunk-FJG2EH4V.js → chunk-KUCWRSXU.js} +2 -2
  21. package/dist/{chunk-D6IYEVDT.js → chunk-MCH35MAX.js} +2 -2
  22. package/dist/{chunk-NZ2BGOJU.js → chunk-Q4X6Q4E6.js} +2 -2
  23. package/dist/{chunk-EU7RWKHE.js → chunk-R6GOICRO.js} +5 -5
  24. package/dist/chunk-SD56WDSC.js +359 -0
  25. package/dist/chunk-SD56WDSC.js.map +1 -0
  26. package/dist/{chunk-TXXWUG2J.js → chunk-VE6JY2TH.js} +2 -1
  27. package/dist/{chunk-TXXWUG2J.js.map → chunk-VE6JY2TH.js.map} +1 -1
  28. package/dist/{chunk-QT45WUPQ.js → chunk-XJXSR5XI.js} +244 -21
  29. package/dist/chunk-XJXSR5XI.js.map +1 -0
  30. package/dist/{chunk-BAQTM6VS.js → chunk-ZAF4IVUT.js} +848 -102
  31. package/dist/chunk-ZAF4IVUT.js.map +1 -0
  32. package/dist/context-mention-palette/index.d.ts +3 -3
  33. package/dist/context-mention-palette/index.js +9 -9
  34. package/dist/i18n/index.d.ts +24 -2
  35. package/dist/i18n/index.js +2 -2
  36. package/dist/index.d.ts +22 -6
  37. package/dist/index.js +847 -812
  38. package/dist/index.js.map +1 -1
  39. package/dist/plan-decision-ops.d.ts +1 -1
  40. package/dist/queued-prompt-runtime.d.ts +97 -0
  41. package/dist/queued-prompt-runtime.js +9 -0
  42. package/dist/queued-prompt-runtime.js.map +1 -0
  43. package/dist/workbench/contribution.js +3 -3
  44. package/dist/workbench/index.js +9 -9
  45. package/dist/workbench/launch.js +2 -2
  46. package/dist/workbench/sessionTitle.js +3 -3
  47. package/dist/workspace-agent-generated-files.js +3 -3
  48. package/package.json +21 -14
  49. package/dist/chunk-BAQTM6VS.js.map +0 -1
  50. package/dist/chunk-FRG36S6N.js.map +0 -1
  51. package/dist/chunk-QT45WUPQ.js.map +0 -1
  52. package/dist/chunk-VFQR7AZI.js.map +0 -1
  53. /package/dist/{chunk-AMNXH4DJ.js.map → chunk-2RYZ4EBF.js.map} +0 -0
  54. /package/dist/{chunk-EIC7XS3C.js.map → chunk-5QTC2L52.js.map} +0 -0
  55. /package/dist/{chunk-62QOR3TC.js.map → chunk-HCS3HUUX.js.map} +0 -0
  56. /package/dist/{chunk-OL54R6OL.js.map → chunk-J3SJZMI5.js.map} +0 -0
  57. /package/dist/{chunk-FJG2EH4V.js.map → chunk-KUCWRSXU.js.map} +0 -0
  58. /package/dist/{chunk-D6IYEVDT.js.map → chunk-MCH35MAX.js.map} +0 -0
  59. /package/dist/{chunk-NZ2BGOJU.js.map → chunk-Q4X6Q4E6.js.map} +0 -0
  60. /package/dist/{chunk-EU7RWKHE.js.map → chunk-R6GOICRO.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-GCBDIQDX.js";
4
4
  import {
5
5
  translateInUiLanguage
6
- } from "./chunk-VFQR7AZI.js";
6
+ } from "./chunk-KACBTC7Y.js";
7
7
 
8
8
  // shared/utils/agentSessionMentionText.ts
9
9
  import {
@@ -314,4 +314,4 @@ export {
314
314
  resolveAgentGUIProviderDisplayLabel,
315
315
  firstAgentGUIUserMessageTitle
316
316
  };
317
- //# sourceMappingURL=chunk-FJG2EH4V.js.map
317
+ //# sourceMappingURL=chunk-KUCWRSXU.js.map
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  translate,
16
16
  translateInUiLanguage
17
- } from "./chunk-EIC7XS3C.js";
17
+ } from "./chunk-5QTC2L52.js";
18
18
 
19
19
  // shared/workspaceAgentActivityListViewModel.ts
20
20
  import { normalizeAgentActivityDisplayStatus } from "@tutti-os/agent-activity-core";
@@ -993,4 +993,4 @@ export {
993
993
  resolveWorkspaceAgentActivityStatus,
994
994
  resolveWorkspaceAgentActivityTitle
995
995
  };
996
- //# sourceMappingURL=chunk-D6IYEVDT.js.map
996
+ //# sourceMappingURL=chunk-MCH35MAX.js.map
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-MTFSQWZ6.js";
15
15
  import {
16
16
  translate
17
- } from "./chunk-EIC7XS3C.js";
17
+ } from "./chunk-5QTC2L52.js";
18
18
 
19
19
  // shared/managedAgentProviders.ts
20
20
  function normalizeManagedAgentProvider(provider) {
@@ -113,4 +113,4 @@ export {
113
113
  userAvatarPlaceholderUrl,
114
114
  workspaceAgentActivityStatusLabel
115
115
  };
116
- //# sourceMappingURL=chunk-NZ2BGOJU.js.map
116
+ //# sourceMappingURL=chunk-Q4X6Q4E6.js.map
@@ -1,11 +1,11 @@
1
- import {
2
- isAgentGuiWorkbenchProvider,
3
- normalizeAgentGuiWorkbenchProvider
4
- } from "./chunk-22L4VWUR.js";
5
1
  import {
6
2
  agentGuiWorkbenchOpenSessionActivationType,
7
3
  agentGuiWorkbenchPrefillPromptActivationType
8
4
  } from "./chunk-F5DYXCY3.js";
5
+ import {
6
+ isAgentGuiWorkbenchProvider,
7
+ normalizeAgentGuiWorkbenchProvider
8
+ } from "./chunk-22L4VWUR.js";
9
9
 
10
10
  // workbench/launch.ts
11
11
  var agentGuiWorkbenchTypeId = "agent-gui";
@@ -157,4 +157,4 @@ export {
157
157
  createAgentGuiWorkbenchDraftLaunchRequest,
158
158
  createAgentGuiWorkbenchLaunchDescriptor
159
159
  };
160
- //# sourceMappingURL=chunk-EU7RWKHE.js.map
160
+ //# sourceMappingURL=chunk-R6GOICRO.js.map
@@ -0,0 +1,359 @@
1
+ // agentQueuedPromptRuntimeCore.ts
2
+ var DEFAULT_CLAIM_LEASE_MS = 3e4;
3
+ var EMPTY_AGENT_QUEUED_PROMPT_SNAPSHOT = Object.freeze({
4
+ queuesByKey: Object.freeze({}),
5
+ version: 0
6
+ });
7
+ function createAgentQueuedPromptRuntime() {
8
+ let snapshot = EMPTY_AGENT_QUEUED_PROMPT_SNAPSHOT;
9
+ const emptyQueuesByKey = /* @__PURE__ */ new Map();
10
+ const expiredClaimsByKey = /* @__PURE__ */ new Map();
11
+ const listeners = /* @__PURE__ */ new Set();
12
+ let claimExpiryTimer = null;
13
+ const notify = () => {
14
+ for (const listener of [...listeners]) {
15
+ listener();
16
+ }
17
+ };
18
+ const updateQueue = (workspaceId, agentSessionId, updater, options) => {
19
+ const key = queueKey(workspaceId, agentSessionId);
20
+ const current = snapshot.queuesByKey[key] ?? getEmptyQueueSnapshot(emptyQueuesByKey, { workspaceId, agentSessionId });
21
+ const queueForUpdate = options?.releaseExpiredClaim === false ? current : withExpiredClaimReleased(current);
22
+ if (queueForUpdate !== current && current.claim) {
23
+ expiredClaimsByKey.set(key, current.claim);
24
+ }
25
+ const nextQueue = updater(queueForUpdate);
26
+ if (nextQueue === current) {
27
+ return;
28
+ }
29
+ const nextQueuesByKey = {
30
+ ...snapshot.queuesByKey
31
+ };
32
+ if (nextQueue === null || isEmptyQueue(nextQueue)) {
33
+ delete nextQueuesByKey[key];
34
+ } else {
35
+ nextQueuesByKey[key] = freezeQueue(nextQueue);
36
+ }
37
+ clearExpiredClaimIfReplaced(expiredClaimsByKey, key, nextQueue);
38
+ snapshot = Object.freeze({
39
+ queuesByKey: Object.freeze(nextQueuesByKey),
40
+ version: snapshot.version + 1
41
+ });
42
+ scheduleClaimExpiryWakeup();
43
+ notify();
44
+ };
45
+ const releaseExpiredClaims = () => {
46
+ claimExpiryTimer = null;
47
+ let changed = false;
48
+ const nextQueuesByKey = {
49
+ ...snapshot.queuesByKey
50
+ };
51
+ for (const [key, queue] of Object.entries(snapshot.queuesByKey)) {
52
+ const nextQueue = withExpiredClaimReleased(queue);
53
+ if (nextQueue === queue) {
54
+ continue;
55
+ }
56
+ changed = true;
57
+ if (queue.claim) {
58
+ expiredClaimsByKey.set(key, queue.claim);
59
+ }
60
+ if (isEmptyQueue(nextQueue)) {
61
+ delete nextQueuesByKey[key];
62
+ } else {
63
+ nextQueuesByKey[key] = nextQueue;
64
+ }
65
+ }
66
+ if (changed) {
67
+ snapshot = Object.freeze({
68
+ queuesByKey: Object.freeze(nextQueuesByKey),
69
+ version: snapshot.version + 1
70
+ });
71
+ notify();
72
+ }
73
+ scheduleClaimExpiryWakeup();
74
+ };
75
+ const scheduleClaimExpiryWakeup = () => {
76
+ if (claimExpiryTimer) {
77
+ clearTimeout(claimExpiryTimer);
78
+ claimExpiryTimer = null;
79
+ }
80
+ let nextExpiryUnixMs = null;
81
+ for (const queue of Object.values(snapshot.queuesByKey)) {
82
+ if (!queue.claim) {
83
+ continue;
84
+ }
85
+ nextExpiryUnixMs = nextExpiryUnixMs === null ? queue.claim.leasedUntilUnixMs : Math.min(nextExpiryUnixMs, queue.claim.leasedUntilUnixMs);
86
+ }
87
+ if (nextExpiryUnixMs === null) {
88
+ return;
89
+ }
90
+ claimExpiryTimer = setTimeout(
91
+ releaseExpiredClaims,
92
+ Math.max(1, nextExpiryUnixMs - Date.now() + 1)
93
+ );
94
+ claimExpiryTimer.unref?.();
95
+ };
96
+ return {
97
+ claimNextToDrain(input) {
98
+ const workspaceId = input.workspaceId.trim();
99
+ const agentSessionId = input.agentSessionId.trim();
100
+ const ownerId = input.ownerId.trim();
101
+ if (!workspaceId || !agentSessionId || !ownerId) {
102
+ return null;
103
+ }
104
+ const current = withExpiredClaimReleased(
105
+ snapshot.queuesByKey[queueKey(workspaceId, agentSessionId)] ?? getEmptyQueueSnapshot(emptyQueuesByKey, {
106
+ workspaceId,
107
+ agentSessionId
108
+ })
109
+ );
110
+ if (current.claim || current.prompts.length === 0) {
111
+ return null;
112
+ }
113
+ const prompt = current.prompts[0];
114
+ const claim = Object.freeze({
115
+ workspaceId,
116
+ agentSessionId,
117
+ ownerId,
118
+ promptId: prompt.id,
119
+ claimId: `claim-${Date.now()}-${Math.random().toString(36).slice(2)}`,
120
+ leasedUntilUnixMs: Date.now() + Math.max(1, input.leaseMs ?? DEFAULT_CLAIM_LEASE_MS)
121
+ });
122
+ updateQueue(workspaceId, agentSessionId, (queue) => ({
123
+ ...queue,
124
+ claim
125
+ }));
126
+ expiredClaimsByKey.delete(queueKey(workspaceId, agentSessionId));
127
+ return { claim, prompt };
128
+ },
129
+ cleanupSession(input) {
130
+ const workspaceId = input.workspaceId.trim();
131
+ const agentSessionId = input.agentSessionId.trim();
132
+ if (!workspaceId || !agentSessionId) {
133
+ return;
134
+ }
135
+ updateQueue(workspaceId, agentSessionId, () => null);
136
+ expiredClaimsByKey.delete(queueKey(workspaceId, agentSessionId));
137
+ },
138
+ completeClaim(input) {
139
+ let completed = false;
140
+ const key = queueKey(input.workspaceId, input.agentSessionId);
141
+ updateQueue(
142
+ input.workspaceId,
143
+ input.agentSessionId,
144
+ (queue) => {
145
+ const matchingClaim = claimMatches(queue.claim, input) ? queue.claim : queue.claim === null && claimMatches(expiredClaimsByKey.get(key) ?? null, input) ? expiredClaimsByKey.get(key) : null;
146
+ if (!matchingClaim) {
147
+ return queue;
148
+ }
149
+ completed = true;
150
+ const promptId = matchingClaim.promptId;
151
+ expiredClaimsByKey.delete(key);
152
+ return {
153
+ ...queue,
154
+ claim: null,
155
+ failedPromptId: queue.failedPromptId === promptId ? null : queue.failedPromptId,
156
+ prompts: Object.freeze(
157
+ queue.prompts.filter((prompt) => prompt.id !== promptId)
158
+ ),
159
+ retryBlock: queue.retryBlock?.queuedPromptId === promptId ? null : queue.retryBlock,
160
+ sendNextPromptId: queue.sendNextPromptId === promptId ? null : queue.sendNextPromptId
161
+ };
162
+ },
163
+ { releaseExpiredClaim: false }
164
+ );
165
+ return completed;
166
+ },
167
+ enqueue(input) {
168
+ updateQueue(input.workspaceId, input.agentSessionId, (queue) => ({
169
+ ...queue,
170
+ prompts: Object.freeze([...queue.prompts, freezePrompt(input.prompt)])
171
+ }));
172
+ },
173
+ getSessionSnapshot(input) {
174
+ const workspaceId = input.workspaceId.trim();
175
+ const agentSessionId = input.agentSessionId.trim();
176
+ const key = queueKey(workspaceId, agentSessionId);
177
+ const current = snapshot.queuesByKey[key] ?? getEmptyQueueSnapshot(emptyQueuesByKey, {
178
+ workspaceId,
179
+ agentSessionId
180
+ });
181
+ const next = withExpiredClaimReleased(current);
182
+ if (next !== current) {
183
+ updateQueue(workspaceId, agentSessionId, () => next);
184
+ }
185
+ return snapshot.queuesByKey[key] ?? next;
186
+ },
187
+ getSnapshot() {
188
+ return snapshot;
189
+ },
190
+ markPromptFailed(input) {
191
+ updateQueue(input.workspaceId, input.agentSessionId, (queue) => ({
192
+ ...queue,
193
+ failedPromptId: input.promptId.trim() || queue.failedPromptId
194
+ }));
195
+ },
196
+ promotePrompt(input) {
197
+ const promptId = input.promptId.trim();
198
+ if (!promptId) {
199
+ return;
200
+ }
201
+ updateQueue(input.workspaceId, input.agentSessionId, (queue) => {
202
+ const index = queue.prompts.findIndex(
203
+ (prompt) => prompt.id === promptId
204
+ );
205
+ if (index < 0) {
206
+ return queue;
207
+ }
208
+ if (queue.claim?.promptId === promptId) {
209
+ return queue;
210
+ }
211
+ const prompts = [...queue.prompts];
212
+ if (index > 0) {
213
+ const [selected] = prompts.splice(index, 1);
214
+ prompts.unshift(selected);
215
+ }
216
+ return {
217
+ ...queue,
218
+ failedPromptId: queue.failedPromptId === promptId ? null : queue.failedPromptId,
219
+ prompts: Object.freeze(prompts),
220
+ retryBlock: queue.retryBlock?.queuedPromptId === promptId ? null : queue.retryBlock,
221
+ sendNextPromptId: promptId
222
+ };
223
+ });
224
+ },
225
+ releaseClaim(input) {
226
+ let released = false;
227
+ updateQueue(input.workspaceId, input.agentSessionId, (queue) => {
228
+ if (!claimMatches(queue.claim, input)) {
229
+ return queue;
230
+ }
231
+ released = true;
232
+ return { ...queue, claim: null };
233
+ });
234
+ return released;
235
+ },
236
+ releaseOwner(ownerId) {
237
+ const normalizedOwnerId = ownerId.trim();
238
+ if (!normalizedOwnerId) {
239
+ return;
240
+ }
241
+ for (const queue of Object.values(snapshot.queuesByKey)) {
242
+ if (queue.claim?.ownerId === normalizedOwnerId) {
243
+ updateQueue(queue.workspaceId, queue.agentSessionId, (current) => ({
244
+ ...current,
245
+ claim: current.claim?.ownerId === normalizedOwnerId ? null : current.claim
246
+ }));
247
+ }
248
+ }
249
+ },
250
+ removePrompt(input) {
251
+ const promptId = input.promptId.trim();
252
+ if (!promptId) {
253
+ return null;
254
+ }
255
+ let removed = null;
256
+ updateQueue(input.workspaceId, input.agentSessionId, (queue) => {
257
+ removed = queue.prompts.find((prompt) => prompt.id === promptId) ?? null;
258
+ if (!removed) {
259
+ return queue;
260
+ }
261
+ if (queue.claim?.promptId === promptId) {
262
+ removed = null;
263
+ return queue;
264
+ }
265
+ const key = queueKey(input.workspaceId, input.agentSessionId);
266
+ if (expiredClaimsByKey.get(key)?.promptId === promptId) {
267
+ expiredClaimsByKey.delete(key);
268
+ }
269
+ return {
270
+ ...queue,
271
+ claim: queue.claim?.promptId === promptId ? null : queue.claim,
272
+ failedPromptId: queue.failedPromptId === promptId ? null : queue.failedPromptId,
273
+ prompts: Object.freeze(
274
+ queue.prompts.filter((prompt) => prompt.id !== promptId)
275
+ ),
276
+ retryBlock: queue.retryBlock?.queuedPromptId === promptId ? null : queue.retryBlock,
277
+ sendNextPromptId: queue.sendNextPromptId === promptId ? null : queue.sendNextPromptId
278
+ };
279
+ });
280
+ return removed;
281
+ },
282
+ setRetryBlock(input) {
283
+ updateQueue(input.workspaceId, input.agentSessionId, (queue) => ({
284
+ ...queue,
285
+ retryBlock: input.retryBlock ? Object.freeze({ ...input.retryBlock }) : null
286
+ }));
287
+ },
288
+ subscribe(listener) {
289
+ listeners.add(listener);
290
+ return () => {
291
+ listeners.delete(listener);
292
+ };
293
+ }
294
+ };
295
+ }
296
+ function queueKey(workspaceId, agentSessionId) {
297
+ return `${workspaceId.trim()}\0${agentSessionId.trim()}`;
298
+ }
299
+ function emptyQueueSnapshot(input) {
300
+ return freezeQueue({
301
+ workspaceId: input.workspaceId,
302
+ agentSessionId: input.agentSessionId,
303
+ claim: null,
304
+ failedPromptId: null,
305
+ prompts: Object.freeze([]),
306
+ retryBlock: null,
307
+ sendNextPromptId: null
308
+ });
309
+ }
310
+ function getEmptyQueueSnapshot(cache, input) {
311
+ const key = queueKey(input.workspaceId, input.agentSessionId);
312
+ const existing = cache.get(key);
313
+ if (existing) {
314
+ return existing;
315
+ }
316
+ const next = emptyQueueSnapshot(input);
317
+ cache.set(key, next);
318
+ return next;
319
+ }
320
+ function freezePrompt(prompt) {
321
+ return Object.freeze({
322
+ ...prompt,
323
+ content: Object.freeze([
324
+ ...prompt.content
325
+ ])
326
+ });
327
+ }
328
+ function freezeQueue(queue) {
329
+ return Object.freeze({
330
+ ...queue,
331
+ claim: queue.claim ? Object.freeze({ ...queue.claim }) : null,
332
+ prompts: Object.freeze(queue.prompts.map(freezePrompt)),
333
+ retryBlock: queue.retryBlock ? Object.freeze({ ...queue.retryBlock }) : null
334
+ });
335
+ }
336
+ function withExpiredClaimReleased(queue) {
337
+ if (!queue.claim || queue.claim.leasedUntilUnixMs > Date.now()) {
338
+ return queue;
339
+ }
340
+ return freezeQueue({ ...queue, claim: null });
341
+ }
342
+ function isEmptyQueue(queue) {
343
+ return queue.prompts.length === 0 && queue.claim === null && queue.failedPromptId === null && queue.retryBlock === null && queue.sendNextPromptId === null;
344
+ }
345
+ function claimMatches(claim, input) {
346
+ return claim !== null && claim.workspaceId === input.workspaceId.trim() && claim.agentSessionId === input.agentSessionId.trim() && claim.ownerId === input.ownerId.trim() && claim.claimId === input.claimId.trim();
347
+ }
348
+ function clearExpiredClaimIfReplaced(expiredClaimsByKey, key, queue) {
349
+ const expiredClaim = expiredClaimsByKey.get(key);
350
+ if (expiredClaim && (queue === null || queue.claim !== null || !queue.prompts.some((prompt) => prompt.id === expiredClaim.promptId))) {
351
+ expiredClaimsByKey.delete(key);
352
+ }
353
+ }
354
+
355
+ export {
356
+ EMPTY_AGENT_QUEUED_PROMPT_SNAPSHOT,
357
+ createAgentQueuedPromptRuntime
358
+ };
359
+ //# sourceMappingURL=chunk-SD56WDSC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../agentQueuedPromptRuntimeCore.ts"],"sourcesContent":["import type { AgentGUIQueuedPromptVM } from \"./agent-gui/agentGuiNode/model/agentGuiNodeTypes\";\nimport type { AgentPromptContentBlock } from \"./shared/contracts/dto\";\n\nexport interface AgentQueuedPromptRetryBlock {\n queuedPromptId: string;\n sessionStateUpdatedAtUnixMs: number | null;\n conversationUpdatedAtUnixMs: number | null;\n}\n\nexport interface AgentQueuedPromptClaim {\n agentSessionId: string;\n claimId: string;\n ownerId: string;\n promptId: string;\n leasedUntilUnixMs: number;\n workspaceId: string;\n}\n\nexport interface AgentQueuedPromptQueueSnapshot {\n agentSessionId: string;\n claim: AgentQueuedPromptClaim | null;\n failedPromptId: string | null;\n prompts: readonly AgentGUIQueuedPromptVM[];\n retryBlock: AgentQueuedPromptRetryBlock | null;\n sendNextPromptId: string | null;\n workspaceId: string;\n}\n\nexport interface AgentQueuedPromptSnapshot {\n queuesByKey: Readonly<Record<string, AgentQueuedPromptQueueSnapshot>>;\n version: number;\n}\n\nexport interface AgentQueuedPromptClaimResult {\n claim: AgentQueuedPromptClaim;\n prompt: AgentGUIQueuedPromptVM;\n}\n\nexport interface AgentQueuedPromptRuntime {\n claimNextToDrain(input: {\n agentSessionId: string;\n leaseMs?: number;\n ownerId: string;\n workspaceId: string;\n }): AgentQueuedPromptClaimResult | null;\n cleanupSession(input: { agentSessionId: string; workspaceId: string }): void;\n completeClaim(input: {\n agentSessionId: string;\n claimId: string;\n ownerId: string;\n workspaceId: string;\n }): boolean;\n enqueue(input: {\n prompt: AgentGUIQueuedPromptVM;\n agentSessionId: string;\n workspaceId: string;\n }): void;\n getSessionSnapshot(input: {\n agentSessionId: string;\n workspaceId: string;\n }): AgentQueuedPromptQueueSnapshot;\n getSnapshot(): AgentQueuedPromptSnapshot;\n markPromptFailed(input: {\n agentSessionId: string;\n promptId: string;\n workspaceId: string;\n }): void;\n promotePrompt(input: {\n agentSessionId: string;\n promptId: string;\n workspaceId: string;\n }): void;\n releaseClaim(input: {\n agentSessionId: string;\n claimId: string;\n ownerId: string;\n workspaceId: string;\n }): boolean;\n releaseOwner(ownerId: string): void;\n removePrompt(input: {\n agentSessionId: string;\n promptId: string;\n workspaceId: string;\n }): AgentGUIQueuedPromptVM | null;\n setRetryBlock(input: {\n agentSessionId: string;\n retryBlock: AgentQueuedPromptRetryBlock | null;\n workspaceId: string;\n }): void;\n subscribe(listener: () => void): () => void;\n}\n\nconst DEFAULT_CLAIM_LEASE_MS = 30_000;\n\nexport const EMPTY_AGENT_QUEUED_PROMPT_SNAPSHOT: AgentQueuedPromptSnapshot =\n Object.freeze({\n queuesByKey: Object.freeze({}),\n version: 0\n });\n\nexport function createAgentQueuedPromptRuntime(): AgentQueuedPromptRuntime {\n let snapshot = EMPTY_AGENT_QUEUED_PROMPT_SNAPSHOT;\n const emptyQueuesByKey = new Map<string, AgentQueuedPromptQueueSnapshot>();\n const expiredClaimsByKey = new Map<string, AgentQueuedPromptClaim>();\n const listeners = new Set<() => void>();\n let claimExpiryTimer: ReturnType<typeof setTimeout> | null = null;\n\n const notify = (): void => {\n for (const listener of [...listeners]) {\n listener();\n }\n };\n\n const updateQueue = (\n workspaceId: string,\n agentSessionId: string,\n updater: (\n queue: AgentQueuedPromptQueueSnapshot\n ) => AgentQueuedPromptQueueSnapshot | null,\n options?: { releaseExpiredClaim?: boolean }\n ): void => {\n const key = queueKey(workspaceId, agentSessionId);\n const current =\n snapshot.queuesByKey[key] ??\n getEmptyQueueSnapshot(emptyQueuesByKey, { workspaceId, agentSessionId });\n const queueForUpdate =\n options?.releaseExpiredClaim === false\n ? current\n : withExpiredClaimReleased(current);\n if (queueForUpdate !== current && current.claim) {\n expiredClaimsByKey.set(key, current.claim);\n }\n const nextQueue = updater(queueForUpdate);\n if (nextQueue === current) {\n return;\n }\n const nextQueuesByKey: Record<string, AgentQueuedPromptQueueSnapshot> = {\n ...snapshot.queuesByKey\n };\n if (nextQueue === null || isEmptyQueue(nextQueue)) {\n delete nextQueuesByKey[key];\n } else {\n nextQueuesByKey[key] = freezeQueue(nextQueue);\n }\n clearExpiredClaimIfReplaced(expiredClaimsByKey, key, nextQueue);\n snapshot = Object.freeze({\n queuesByKey: Object.freeze(nextQueuesByKey),\n version: snapshot.version + 1\n });\n scheduleClaimExpiryWakeup();\n notify();\n };\n\n const releaseExpiredClaims = (): void => {\n claimExpiryTimer = null;\n let changed = false;\n const nextQueuesByKey: Record<string, AgentQueuedPromptQueueSnapshot> = {\n ...snapshot.queuesByKey\n };\n for (const [key, queue] of Object.entries(snapshot.queuesByKey)) {\n const nextQueue = withExpiredClaimReleased(queue);\n if (nextQueue === queue) {\n continue;\n }\n changed = true;\n if (queue.claim) {\n expiredClaimsByKey.set(key, queue.claim);\n }\n if (isEmptyQueue(nextQueue)) {\n delete nextQueuesByKey[key];\n } else {\n nextQueuesByKey[key] = nextQueue;\n }\n }\n if (changed) {\n snapshot = Object.freeze({\n queuesByKey: Object.freeze(nextQueuesByKey),\n version: snapshot.version + 1\n });\n notify();\n }\n scheduleClaimExpiryWakeup();\n };\n\n const scheduleClaimExpiryWakeup = (): void => {\n if (claimExpiryTimer) {\n clearTimeout(claimExpiryTimer);\n claimExpiryTimer = null;\n }\n let nextExpiryUnixMs: number | null = null;\n for (const queue of Object.values(snapshot.queuesByKey)) {\n if (!queue.claim) {\n continue;\n }\n nextExpiryUnixMs =\n nextExpiryUnixMs === null\n ? queue.claim.leasedUntilUnixMs\n : Math.min(nextExpiryUnixMs, queue.claim.leasedUntilUnixMs);\n }\n if (nextExpiryUnixMs === null) {\n return;\n }\n claimExpiryTimer = setTimeout(\n releaseExpiredClaims,\n Math.max(1, nextExpiryUnixMs - Date.now() + 1)\n );\n (claimExpiryTimer as { unref?: () => void }).unref?.();\n };\n\n return {\n claimNextToDrain(input) {\n const workspaceId = input.workspaceId.trim();\n const agentSessionId = input.agentSessionId.trim();\n const ownerId = input.ownerId.trim();\n if (!workspaceId || !agentSessionId || !ownerId) {\n return null;\n }\n const current = withExpiredClaimReleased(\n snapshot.queuesByKey[queueKey(workspaceId, agentSessionId)] ??\n getEmptyQueueSnapshot(emptyQueuesByKey, {\n workspaceId,\n agentSessionId\n })\n );\n if (current.claim || current.prompts.length === 0) {\n return null;\n }\n const prompt = current.prompts[0]!;\n const claim: AgentQueuedPromptClaim = Object.freeze({\n workspaceId,\n agentSessionId,\n ownerId,\n promptId: prompt.id,\n claimId: `claim-${Date.now()}-${Math.random().toString(36).slice(2)}`,\n leasedUntilUnixMs:\n Date.now() + Math.max(1, input.leaseMs ?? DEFAULT_CLAIM_LEASE_MS)\n });\n updateQueue(workspaceId, agentSessionId, (queue) => ({\n ...queue,\n claim\n }));\n expiredClaimsByKey.delete(queueKey(workspaceId, agentSessionId));\n return { claim, prompt };\n },\n cleanupSession(input) {\n const workspaceId = input.workspaceId.trim();\n const agentSessionId = input.agentSessionId.trim();\n if (!workspaceId || !agentSessionId) {\n return;\n }\n updateQueue(workspaceId, agentSessionId, () => null);\n expiredClaimsByKey.delete(queueKey(workspaceId, agentSessionId));\n },\n completeClaim(input) {\n let completed = false;\n const key = queueKey(input.workspaceId, input.agentSessionId);\n updateQueue(\n input.workspaceId,\n input.agentSessionId,\n (queue) => {\n const matchingClaim = claimMatches(queue.claim, input)\n ? queue.claim\n : queue.claim === null &&\n claimMatches(expiredClaimsByKey.get(key) ?? null, input)\n ? expiredClaimsByKey.get(key)!\n : null;\n if (!matchingClaim) {\n return queue;\n }\n completed = true;\n const promptId = matchingClaim.promptId;\n expiredClaimsByKey.delete(key);\n return {\n ...queue,\n claim: null,\n failedPromptId:\n queue.failedPromptId === promptId ? null : queue.failedPromptId,\n prompts: Object.freeze(\n queue.prompts.filter((prompt) => prompt.id !== promptId)\n ),\n retryBlock:\n queue.retryBlock?.queuedPromptId === promptId\n ? null\n : queue.retryBlock,\n sendNextPromptId:\n queue.sendNextPromptId === promptId\n ? null\n : queue.sendNextPromptId\n };\n },\n { releaseExpiredClaim: false }\n );\n return completed;\n },\n enqueue(input) {\n updateQueue(input.workspaceId, input.agentSessionId, (queue) => ({\n ...queue,\n prompts: Object.freeze([...queue.prompts, freezePrompt(input.prompt)])\n }));\n },\n getSessionSnapshot(input) {\n const workspaceId = input.workspaceId.trim();\n const agentSessionId = input.agentSessionId.trim();\n const key = queueKey(workspaceId, agentSessionId);\n const current =\n snapshot.queuesByKey[key] ??\n getEmptyQueueSnapshot(emptyQueuesByKey, {\n workspaceId,\n agentSessionId\n });\n const next = withExpiredClaimReleased(current);\n if (next !== current) {\n updateQueue(workspaceId, agentSessionId, () => next);\n }\n return snapshot.queuesByKey[key] ?? next;\n },\n getSnapshot() {\n return snapshot;\n },\n markPromptFailed(input) {\n updateQueue(input.workspaceId, input.agentSessionId, (queue) => ({\n ...queue,\n failedPromptId: input.promptId.trim() || queue.failedPromptId\n }));\n },\n promotePrompt(input) {\n const promptId = input.promptId.trim();\n if (!promptId) {\n return;\n }\n updateQueue(input.workspaceId, input.agentSessionId, (queue) => {\n const index = queue.prompts.findIndex(\n (prompt) => prompt.id === promptId\n );\n if (index < 0) {\n return queue;\n }\n if (queue.claim?.promptId === promptId) {\n return queue;\n }\n const prompts = [...queue.prompts];\n if (index > 0) {\n const [selected] = prompts.splice(index, 1);\n prompts.unshift(selected!);\n }\n return {\n ...queue,\n failedPromptId:\n queue.failedPromptId === promptId ? null : queue.failedPromptId,\n prompts: Object.freeze(prompts),\n retryBlock:\n queue.retryBlock?.queuedPromptId === promptId\n ? null\n : queue.retryBlock,\n sendNextPromptId: promptId\n };\n });\n },\n releaseClaim(input) {\n let released = false;\n updateQueue(input.workspaceId, input.agentSessionId, (queue) => {\n if (!claimMatches(queue.claim, input)) {\n return queue;\n }\n released = true;\n return { ...queue, claim: null };\n });\n return released;\n },\n releaseOwner(ownerId) {\n const normalizedOwnerId = ownerId.trim();\n if (!normalizedOwnerId) {\n return;\n }\n for (const queue of Object.values(snapshot.queuesByKey)) {\n if (queue.claim?.ownerId === normalizedOwnerId) {\n updateQueue(queue.workspaceId, queue.agentSessionId, (current) => ({\n ...current,\n claim:\n current.claim?.ownerId === normalizedOwnerId\n ? null\n : current.claim\n }));\n }\n }\n },\n removePrompt(input) {\n const promptId = input.promptId.trim();\n if (!promptId) {\n return null;\n }\n let removed: AgentGUIQueuedPromptVM | null = null;\n updateQueue(input.workspaceId, input.agentSessionId, (queue) => {\n removed =\n queue.prompts.find((prompt) => prompt.id === promptId) ?? null;\n if (!removed) {\n return queue;\n }\n if (queue.claim?.promptId === promptId) {\n removed = null;\n return queue;\n }\n const key = queueKey(input.workspaceId, input.agentSessionId);\n if (expiredClaimsByKey.get(key)?.promptId === promptId) {\n expiredClaimsByKey.delete(key);\n }\n return {\n ...queue,\n claim: queue.claim?.promptId === promptId ? null : queue.claim,\n failedPromptId:\n queue.failedPromptId === promptId ? null : queue.failedPromptId,\n prompts: Object.freeze(\n queue.prompts.filter((prompt) => prompt.id !== promptId)\n ),\n retryBlock:\n queue.retryBlock?.queuedPromptId === promptId\n ? null\n : queue.retryBlock,\n sendNextPromptId:\n queue.sendNextPromptId === promptId ? null : queue.sendNextPromptId\n };\n });\n return removed;\n },\n setRetryBlock(input) {\n updateQueue(input.workspaceId, input.agentSessionId, (queue) => ({\n ...queue,\n retryBlock: input.retryBlock\n ? Object.freeze({ ...input.retryBlock })\n : null\n }));\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n }\n };\n}\n\nfunction queueKey(workspaceId: string, agentSessionId: string): string {\n return `${workspaceId.trim()}\\0${agentSessionId.trim()}`;\n}\n\nfunction emptyQueueSnapshot(input: {\n workspaceId: string;\n agentSessionId: string;\n}): AgentQueuedPromptQueueSnapshot {\n return freezeQueue({\n workspaceId: input.workspaceId,\n agentSessionId: input.agentSessionId,\n claim: null,\n failedPromptId: null,\n prompts: Object.freeze([]),\n retryBlock: null,\n sendNextPromptId: null\n });\n}\n\nfunction getEmptyQueueSnapshot(\n cache: Map<string, AgentQueuedPromptQueueSnapshot>,\n input: {\n workspaceId: string;\n agentSessionId: string;\n }\n): AgentQueuedPromptQueueSnapshot {\n const key = queueKey(input.workspaceId, input.agentSessionId);\n const existing = cache.get(key);\n if (existing) {\n return existing;\n }\n const next = emptyQueueSnapshot(input);\n cache.set(key, next);\n return next;\n}\n\nfunction freezePrompt(prompt: AgentGUIQueuedPromptVM): AgentGUIQueuedPromptVM {\n return Object.freeze({\n ...prompt,\n content: Object.freeze([\n ...prompt.content\n ]) as unknown as AgentPromptContentBlock[]\n });\n}\n\nfunction freezeQueue(\n queue: AgentQueuedPromptQueueSnapshot\n): AgentQueuedPromptQueueSnapshot {\n return Object.freeze({\n ...queue,\n claim: queue.claim ? Object.freeze({ ...queue.claim }) : null,\n prompts: Object.freeze(queue.prompts.map(freezePrompt)),\n retryBlock: queue.retryBlock ? Object.freeze({ ...queue.retryBlock }) : null\n });\n}\n\nfunction withExpiredClaimReleased(\n queue: AgentQueuedPromptQueueSnapshot\n): AgentQueuedPromptQueueSnapshot {\n if (!queue.claim || queue.claim.leasedUntilUnixMs > Date.now()) {\n return queue;\n }\n return freezeQueue({ ...queue, claim: null });\n}\n\nfunction isEmptyQueue(queue: AgentQueuedPromptQueueSnapshot): boolean {\n return (\n queue.prompts.length === 0 &&\n queue.claim === null &&\n queue.failedPromptId === null &&\n queue.retryBlock === null &&\n queue.sendNextPromptId === null\n );\n}\n\nfunction claimMatches(\n claim: AgentQueuedPromptClaim | null,\n input: {\n agentSessionId: string;\n claimId: string;\n ownerId: string;\n workspaceId: string;\n }\n): claim is AgentQueuedPromptClaim {\n return (\n claim !== null &&\n claim.workspaceId === input.workspaceId.trim() &&\n claim.agentSessionId === input.agentSessionId.trim() &&\n claim.ownerId === input.ownerId.trim() &&\n claim.claimId === input.claimId.trim()\n );\n}\n\nfunction clearExpiredClaimIfReplaced(\n expiredClaimsByKey: Map<string, AgentQueuedPromptClaim>,\n key: string,\n queue: AgentQueuedPromptQueueSnapshot | null\n): void {\n const expiredClaim = expiredClaimsByKey.get(key);\n if (\n expiredClaim &&\n (queue === null ||\n queue.claim !== null ||\n !queue.prompts.some((prompt) => prompt.id === expiredClaim.promptId))\n ) {\n expiredClaimsByKey.delete(key);\n }\n}\n"],"mappings":";AA4FA,IAAM,yBAAyB;AAExB,IAAM,qCACX,OAAO,OAAO;AAAA,EACZ,aAAa,OAAO,OAAO,CAAC,CAAC;AAAA,EAC7B,SAAS;AACX,CAAC;AAEI,SAAS,iCAA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AAI,GAAG;AAC9D,WAAO;AAAA,EACT;AACA,SAAO,YAAY,EAAE,GAAG,OAAO,OAAO,KAAK,CAAC;AAC9C;AAEA,SAAS,aAAa,OAAgD;AACpE,SACE,MAAM,QAAQ,WAAW,KACzB,MAAM,UAAU,QAChB,MAAM,mBAAmB,QACzB,MAAM,eAAe,QACrB,MAAM,qBAAqB;AAE/B;AAEA,SAAS,aACP,OACA,OAMiC;AACjC,SACE,UAAU,QACV,MAAM,gBAAgB,MAAM,YAAY,KAAK,KAC7C,MAAM,mBAAmB,MAAM,eAAe,KAAK,KACnD,MAAM,YAAY,MAAM,QAAQ,KAAK,KACrC,MAAM,YAAY,MAAM,QAAQ,KAAK;AAEzC;AAEA,SAAS,4BACP,oBACA,KACA,OACM;AACN,QAAM,eAAe,mBAAmB,IAAI,GAAG;AAC/C,MACE,iBACC,UAAU,QACT,MAAM,UAAU,QAChB,CAAC,MAAM,QAAQ,KAAK,CAAC,WAAW,OAAO,OAAO,aAAa,QAAQ,IACrE;AACA,uBAAmB,OAAO,GAAG;AAAA,EAC/B;AACF;","names":[]}
@@ -109,6 +109,7 @@ function toAgentHostRuntimeApi(hostApi) {
109
109
  onHostEvent: hostApi.onHostEvent,
110
110
  persistence: hostApi.persistence,
111
111
  runtime: hostApi.runtime,
112
+ toast: hostApi.toast,
112
113
  userProjects: hostApi.userProjects,
113
114
  workspace: hostApi.workspace,
114
115
  workspaceAgentProbes: hostApi.workspaceAgentProbes
@@ -194,4 +195,4 @@ export {
194
195
  useOptionalAgentHostApi,
195
196
  getOptionalAgentHostApi
196
197
  };
197
- //# sourceMappingURL=chunk-TXXWUG2J.js.map
198
+ //# sourceMappingURL=chunk-VE6JY2TH.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../agentActivityRuntime.tsx","../agentActivityHost.tsx","../host/agentHostApi.ts"],"sourcesContent":["import {\n createContext,\n useContext,\n useSyncExternalStore,\n type JSX,\n type PropsWithChildren\n} from \"react\";\nimport type {\n AgentActivityCancelSessionInput,\n AgentActivityCancelSessionResult,\n AgentActivityCreateSessionInput,\n AgentActivityDeleteSessionInput,\n AgentActivityDeleteSessionResult,\n AgentActivityMessageOrder,\n AgentActivityMessagePage,\n AgentActivitySendInput,\n AgentActivitySendInputResult,\n AgentActivitySession,\n AgentActivitySnapshot,\n AgentActivitySnapshotListener,\n AgentActivitySubmitInteractiveInput\n} from \"@tutti-os/agent-activity-core\";\nimport type {\n AgentHostAgentSessionComposerSettings,\n AgentHostActivateAgentSessionResult,\n AgentHostRuntimeOpenclawGatewayWarmupResult,\n AgentHostUpdateAgentSessionSettingsResult,\n AgentHostUnactivateAgentSessionResult,\n AgentHostAgentSessionState\n} from \"./shared/contracts/dto\";\nimport type { AgentGUIProviderTargetRef } from \"./types\";\n\nexport interface AgentActivityRuntimeListSessionMessagesInput {\n afterVersion?: number;\n beforeVersion?: number;\n cache?: boolean;\n agentSessionId: string;\n limit?: number;\n order?: AgentActivityMessageOrder;\n signal?: AbortSignal;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeListGeneratedFilesInput {\n limit?: number;\n query?: string;\n sessionCwd?: string;\n signal?: AbortSignal;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeGeneratedFile {\n label: string;\n path: string;\n}\n\nexport interface AgentActivityRuntimeGeneratedFileList {\n entries: AgentActivityRuntimeGeneratedFile[];\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeEnsureSessionSynchronizedInput {\n afterVersion?: number;\n agentSessionId: string;\n onError?: (error: unknown) => void;\n workspaceId: string;\n}\n\nexport type AgentActivityRuntimeRetainSessionEventsInput =\n AgentActivityRuntimeEnsureSessionSynchronizedInput;\n\nexport interface AgentActivityRuntimeSetSessionPinnedInput {\n agentSessionId: string;\n pinned: boolean;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeTrackSettingsProjectChangeInput {\n action: \"clear\" | \"create_new\" | \"select_existing\";\n agentSessionId: string;\n provider?: string | null;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeGetSessionControlStateInput {\n agentSessionId: string;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeGetComposerOptionsInput {\n cwd?: string | null;\n force?: boolean;\n provider?: string;\n settings?: AgentHostAgentSessionComposerSettings | null;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeUpdateSessionSettingsInput {\n agentSessionId: string;\n settings: AgentHostAgentSessionComposerSettings;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeTrackDraftComposerSettingsChangeInput {\n nextSettings: AgentHostAgentSessionComposerSettings;\n previousSettings: AgentHostAgentSessionComposerSettings;\n provider: string;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeWarmupOpenclawGatewayInput {\n workspaceId?: string | null;\n}\n\nexport interface AgentActivityRuntimeDiagnosticInput {\n details?: Record<string, unknown>;\n event: string;\n level?: \"debug\" | \"info\" | \"warn\" | \"error\";\n source?: string;\n workspaceId?: string | null;\n}\n\nexport interface AgentActivityRuntimeActivateSessionInput {\n agentSessionId: string;\n cwd?: string;\n initialContent?: AgentActivitySendInput[\"content\"];\n /** 仅展示用首轮文本(bundle 折叠成一个 chip);initialContent 仍带展开后的文件。 */\n initialDisplayPrompt?: string | null;\n metadata?: Record<string, unknown>;\n mode: \"existing\" | \"new\";\n openclawGatewayReady?: boolean;\n provider?: string;\n /**\n * Opaque host-owned target reference. AgentGUI passes this through only; hosts\n * must not treat it as authority and must re-authenticate before launch.\n */\n providerTargetRef?: AgentGUIProviderTargetRef | null;\n settings?: AgentHostAgentSessionComposerSettings;\n title?: string;\n visible?: boolean;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeUnactivateSessionInput {\n agentSessionId: string;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeReadSessionAttachmentInput {\n agentSessionId: string;\n attachmentId: string;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeReadPromptAssetInput {\n agentSessionId?: string | null;\n assetId?: string | null;\n hostPath?: string | null;\n kind?: string | null;\n mimeType: string;\n name?: string | null;\n path?: string | null;\n sha256?: string | null;\n uploadStatus?: string | null;\n uri?: string | null;\n workspaceId: string;\n}\n\nexport type AgentActivityRuntimePromptContentBlock =\n AgentActivitySendInput[\"content\"][number] & {\n assetId?: string;\n hostPath?: string;\n kind?: string;\n path?: string;\n sizeBytes?: number;\n uploadStatus?: string;\n uri?: string;\n };\n\nexport interface AgentActivityRuntimeUploadPromptContentInput {\n content: AgentActivityRuntimePromptContentBlock[];\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeUploadPromptContentResult {\n content: AgentActivityRuntimePromptContentBlock[];\n}\n\nexport interface AgentActivityRuntimeSessionAttachment {\n attachmentId: string;\n mimeType: string;\n name?: string;\n data: string;\n}\n\nexport interface AgentActivityRuntimePromptAsset {\n assetId?: string;\n hostPath?: string;\n kind?: string;\n mimeType: string;\n name?: string;\n path: string;\n uploadStatus?: string;\n uri?: string;\n data: string;\n}\n\nexport interface AgentActivityRuntime {\n cancelSession(\n input: AgentActivityCancelSessionInput\n ): Promise<AgentActivityCancelSessionResult>;\n createSession(\n input: AgentActivityCreateSessionInput\n ): Promise<AgentActivitySession>;\n deleteSession(\n input: AgentActivityDeleteSessionInput\n ): Promise<AgentActivityDeleteSessionResult>;\n activateSession(\n input: AgentActivityRuntimeActivateSessionInput\n ): Promise<AgentHostActivateAgentSessionResult>;\n getSession(\n workspaceId: string,\n agentSessionId: string\n ): Promise<AgentActivitySession>;\n getComposerOptions(\n input: AgentActivityRuntimeGetComposerOptionsInput\n ): Promise<unknown>;\n updateSessionSettings(\n input: AgentActivityRuntimeUpdateSessionSettingsInput\n ): Promise<AgentHostUpdateAgentSessionSettingsResult>;\n warmupOpenclawGateway?(\n input?: AgentActivityRuntimeWarmupOpenclawGatewayInput\n ): Promise<AgentHostRuntimeOpenclawGatewayWarmupResult>;\n getSessionControlState(\n input: AgentActivityRuntimeGetSessionControlStateInput\n ): Promise<AgentHostAgentSessionState>;\n getSnapshot(workspaceId: string): AgentActivitySnapshot;\n listSessionMessages(\n input: AgentActivityRuntimeListSessionMessagesInput\n ): Promise<AgentActivityMessagePage>;\n listAgentGeneratedFiles?(\n input: AgentActivityRuntimeListGeneratedFilesInput\n ): Promise<AgentActivityRuntimeGeneratedFileList>;\n load(\n workspaceId: string,\n signal?: AbortSignal\n ): Promise<AgentActivitySnapshot>;\n ensureSessionSynchronized?(\n input: AgentActivityRuntimeEnsureSessionSynchronizedInput\n ): () => void;\n /** @deprecated Use ensureSessionSynchronized. */\n retainSessionEvents(\n input: AgentActivityRuntimeRetainSessionEventsInput\n ): () => void;\n sendInput(\n input: AgentActivitySendInput\n ): Promise<AgentActivitySendInputResult>;\n uploadPromptContent?(\n input: AgentActivityRuntimeUploadPromptContentInput\n ): Promise<AgentActivityRuntimeUploadPromptContentResult>;\n readSessionAttachment?(\n input: AgentActivityRuntimeReadSessionAttachmentInput\n ): Promise<AgentActivityRuntimeSessionAttachment>;\n readPromptAsset?(\n input: AgentActivityRuntimeReadPromptAssetInput\n ): Promise<AgentActivityRuntimePromptAsset>;\n setSessionPinned(\n input: AgentActivityRuntimeSetSessionPinnedInput\n ): Promise<AgentActivitySession>;\n trackSettingsProjectChange?(\n input: AgentActivityRuntimeTrackSettingsProjectChangeInput\n ): Promise<void>;\n trackDraftComposerSettingsChange?(\n input: AgentActivityRuntimeTrackDraftComposerSettingsChangeInput\n ): Promise<void>;\n reportDiagnostic?(\n input: AgentActivityRuntimeDiagnosticInput\n ): Promise<void> | void;\n unactivateSession(\n input: AgentActivityRuntimeUnactivateSessionInput\n ): Promise<AgentHostUnactivateAgentSessionResult>;\n submitInteractive(\n input: AgentActivitySubmitInteractiveInput\n ): Promise<unknown>;\n subscribeSessionEvents(\n workspaceId: string,\n listener: (event: unknown) => void\n ): () => void;\n subscribe(\n workspaceId: string,\n listener: AgentActivitySnapshotListener\n ): () => void;\n}\n\nconst AgentActivityRuntimeContext = createContext<AgentActivityRuntime | null>(\n null\n);\n\nlet currentAgentActivityRuntime: AgentActivityRuntime | null = null;\n\nexport interface AgentActivityRuntimeProviderProps extends PropsWithChildren {\n runtime?: AgentActivityRuntime | null;\n}\n\nexport function AgentActivityRuntimeProvider({\n children,\n runtime\n}: AgentActivityRuntimeProviderProps): JSX.Element {\n currentAgentActivityRuntime = runtime ?? null;\n return (\n <AgentActivityRuntimeContext.Provider value={runtime ?? null}>\n {children}\n </AgentActivityRuntimeContext.Provider>\n );\n}\n\nexport function useAgentActivityRuntime(): AgentActivityRuntime {\n const runtime =\n useContext(AgentActivityRuntimeContext) ?? getTestAgentActivityRuntime();\n if (!runtime) {\n throw new Error(\n \"AgentActivityRuntimeProvider is missing an AgentActivityRuntime instance.\"\n );\n }\n return runtime;\n}\n\nexport function useOptionalAgentActivityRuntime(): AgentActivityRuntime | null {\n return (\n useContext(AgentActivityRuntimeContext) ?? getTestAgentActivityRuntime()\n );\n}\n\nexport function useAgentActivitySnapshot(\n workspaceId: string\n): AgentActivitySnapshot {\n const runtime = useAgentActivityRuntime();\n const normalizedWorkspaceId = workspaceId.trim();\n return useSyncExternalStore(\n (listener) => runtime.subscribe(normalizedWorkspaceId, listener),\n () => runtime.getSnapshot(normalizedWorkspaceId),\n () => runtime.getSnapshot(normalizedWorkspaceId)\n );\n}\n\nexport function getAgentActivityRuntime(): AgentActivityRuntime {\n const runtime =\n getExplicitWindowTestAgentActivityRuntime() ??\n currentAgentActivityRuntime ??\n getTestAgentActivityRuntime();\n if (!runtime) {\n throw new Error(\n \"AgentActivityRuntimeProvider is missing an AgentActivityRuntime instance.\"\n );\n }\n return runtime;\n}\n\nexport function getOptionalAgentActivityRuntime(): AgentActivityRuntime | null {\n return (\n getExplicitWindowTestAgentActivityRuntime() ??\n currentAgentActivityRuntime ??\n getTestAgentActivityRuntime()\n );\n}\n\nexport function resetAgentActivityRuntimeForTests(): void {\n if (process.env.NODE_ENV === \"test\") {\n currentAgentActivityRuntime = null;\n }\n}\n\nexport function setAgentActivityRuntimeForTests(\n runtime: AgentActivityRuntime | null\n): void {\n if (process.env.NODE_ENV === \"test\") {\n currentAgentActivityRuntime = runtime;\n }\n}\n\nfunction getTestAgentActivityRuntime(): AgentActivityRuntime | null {\n if (process.env.NODE_ENV !== \"test\") {\n return null;\n }\n if (typeof window === \"undefined\") {\n return null;\n }\n const explicitRuntime = getExplicitWindowTestAgentActivityRuntime();\n if (explicitRuntime) {\n return explicitRuntime;\n }\n if (currentAgentActivityRuntime) {\n return currentAgentActivityRuntime;\n }\n const testRuntime = (\n window as unknown as Window & {\n agentActivityRuntime?: AgentActivityRuntime;\n }\n ).agentActivityRuntime;\n return testRuntime ?? null;\n}\n\nfunction getExplicitWindowTestAgentActivityRuntime(): AgentActivityRuntime | null {\n if (process.env.NODE_ENV !== \"test\" || typeof window === \"undefined\") {\n return null;\n }\n const testDescriptor = Object.getOwnPropertyDescriptor(\n window,\n \"agentActivityRuntime\"\n );\n if (!testDescriptor || !(\"value\" in testDescriptor)) {\n return null;\n }\n return (testDescriptor.value as AgentActivityRuntime | undefined) ?? null;\n}\n","import {\n createContext,\n useContext,\n useMemo,\n type JSX,\n type PropsWithChildren\n} from \"react\";\nimport {\n toAgentHostRuntimeApi,\n type AgentHostInputApi,\n type AgentHostRuntimeApi\n} from \"./host/agentHostApi\";\nimport {\n AgentActivityRuntimeProvider,\n type AgentActivityRuntime\n} from \"./agentActivityRuntime\";\n\nconst AgentActivityHostContext = createContext<AgentHostRuntimeApi | null>(\n null\n);\n\nlet currentAgentHostApi: AgentHostRuntimeApi | null = null;\n\nexport interface AgentActivityHostProviderProps extends PropsWithChildren {\n agentActivityRuntime?: AgentActivityRuntime | null;\n agentHostApi?: AgentHostInputApi | null;\n}\n\nexport function AgentActivityHostProvider({\n agentActivityRuntime,\n agentHostApi,\n children\n}: AgentActivityHostProviderProps): JSX.Element {\n const resolvedAgentHostApi = useMemo(\n () => (agentHostApi ? toAgentHostRuntimeApi(agentHostApi) : null),\n [agentHostApi]\n );\n currentAgentHostApi = resolvedAgentHostApi;\n return (\n <AgentActivityRuntimeProvider runtime={agentActivityRuntime}>\n <AgentActivityHostContext.Provider value={resolvedAgentHostApi}>\n {children}\n </AgentActivityHostContext.Provider>\n </AgentActivityRuntimeProvider>\n );\n}\n\nexport function useAgentHostApi(): AgentHostRuntimeApi {\n const agentHostApi =\n useContext(AgentActivityHostContext) ?? getTestAgentHostApi();\n if (!agentHostApi) {\n throw new Error(\n \"AgentActivityHostProvider is missing an agentHostApi instance.\"\n );\n }\n return agentHostApi;\n}\n\nexport function useOptionalAgentHostApi(): AgentHostRuntimeApi | null {\n return useContext(AgentActivityHostContext) ?? getTestAgentHostApi();\n}\n\nexport function getAgentHostApi(): AgentHostRuntimeApi {\n const agentHostApi =\n getExplicitWindowTestAgentHostApi() ??\n currentAgentHostApi ??\n getTestAgentHostApi();\n if (!agentHostApi) {\n throw new Error(\n \"AgentActivityHostProvider is missing an agentHostApi instance.\"\n );\n }\n return agentHostApi;\n}\n\nexport function getOptionalAgentHostApi(): AgentHostRuntimeApi | null {\n return (\n getExplicitWindowTestAgentHostApi() ??\n currentAgentHostApi ??\n getTestAgentHostApi()\n );\n}\n\nexport function resetAgentHostApiForTests(): void {\n if (process.env.NODE_ENV === \"test\") {\n currentAgentHostApi = null;\n }\n}\n\nexport function setAgentHostApiForTests(\n agentHostApi: AgentHostInputApi | AgentHostRuntimeApi | null\n): void {\n if (process.env.NODE_ENV === \"test\") {\n currentAgentHostApi = agentHostApi\n ? toAgentHostRuntimeApi(agentHostApi)\n : null;\n }\n}\n\nfunction getTestAgentHostApi(): AgentHostRuntimeApi | null {\n if (process.env.NODE_ENV !== \"test\") {\n return null;\n }\n if (typeof window === \"undefined\") {\n return null;\n }\n const explicitAgentHostApi = getExplicitWindowTestAgentHostApi();\n if (explicitAgentHostApi) {\n return explicitAgentHostApi;\n }\n if (currentAgentHostApi) {\n return currentAgentHostApi;\n }\n const testAgentHostApi = (\n window as unknown as Window & {\n agentHostApi?: AgentHostInputApi | AgentHostRuntimeApi;\n }\n ).agentHostApi;\n return testAgentHostApi ? toAgentHostRuntimeApi(testAgentHostApi) : null;\n}\n\nfunction getExplicitWindowTestAgentHostApi(): AgentHostRuntimeApi | null {\n if (process.env.NODE_ENV !== \"test\" || typeof window === \"undefined\") {\n return null;\n }\n const testDescriptor = Object.getOwnPropertyDescriptor(\n window,\n \"agentHostApi\"\n );\n if (!testDescriptor || !(\"value\" in testDescriptor)) {\n return null;\n }\n const testAgentHostApi = testDescriptor.value as\n | AgentHostInputApi\n | AgentHostRuntimeApi\n | undefined;\n return testAgentHostApi ? toAgentHostRuntimeApi(testAgentHostApi) : null;\n}\n","import type {\n AgentHostBatchUserInfoInput,\n AgentHostBatchUserInfoResult,\n AgentHostDeleteWorkspaceAgentSessionInput,\n AgentHostWorkspaceAgentListInput as AgentHostListWorkspaceAgentsInput,\n AgentHostListWorkspaceAgentProbesInput,\n AgentHostWorkspaceAgentSessionMessages,\n AgentHostWorkspaceAgentSessionMessagesInput,\n AgentHostWorkspaceAgentSessionSummary,\n AgentHostWorkspaceAgentSessionSummaryInput,\n AgentHostWorkspaceAgentProbesResult,\n AgentHostWorkspaceAgentSnapshot,\n PersistWriteResult,\n ReadWorkspaceAgentReadStateInput,\n ReadWorkspaceFileResult as AgentHostReadWorkspaceFileResult,\n WorkspaceAgentReadStateSnapshot,\n WriteWorkspaceAgentReadStateInput\n} from \"../shared/contracts/dto\";\nimport type { WorkspaceUserProjectService } from \"@tutti-os/workspace-user-project/contracts\";\n\ntype AgentHostAsyncResult<T = any> = Promise<T>;\ntype AgentHostRecord = Record<string, unknown>;\ntype AgentHostUnsubscribe = () => void;\ntype AgentHostWorkspaceScopedInput<\n T extends {\n workspaceId?: string | null;\n }\n> = Omit<T, \"workspaceId\"> & {\n workspaceId: string;\n};\ntype AgentHostWorkspaceAgentsListInput =\n AgentHostWorkspaceScopedInput<AgentHostListWorkspaceAgentsInput>;\ntype AgentHostWorkspaceAgentSessionMessagesRuntimeInput =\n AgentHostWorkspaceScopedInput<AgentHostWorkspaceAgentSessionMessagesInput>;\ntype AgentHostWorkspaceAgentSessionSummaryRuntimeInput =\n AgentHostWorkspaceScopedInput<AgentHostWorkspaceAgentSessionSummaryInput>;\ntype AgentHostDeleteWorkspaceAgentSessionRuntimeInput =\n AgentHostWorkspaceScopedInput<AgentHostDeleteWorkspaceAgentSessionInput>;\n\nexport type AgentHostClipboardApi = {\n writeImage?: (input: {\n data: string;\n mimeType: \"image/png\";\n }) => AgentHostAsyncResult<void>;\n writeText: (text: string) => AgentHostAsyncResult<void>;\n};\n\nexport type AgentHostDebugApi = {\n logRuntimeDiagnostics: (\n payload: unknown\n ) => AgentHostAsyncResult<void> | void;\n logTerminalDiagnostics?: (\n payload: unknown\n ) => AgentHostAsyncResult<void> | void;\n};\n\nexport type AgentHostFilesystemApi = AgentHostRecord & {\n readFileText: (payload: {\n path?: string;\n uri?: string;\n }) => AgentHostAsyncResult<{\n content: string;\n name?: string;\n path?: string;\n }>;\n};\n\nexport type AgentHostMetaApi = AgentHostRecord & {\n appVersion?: string | null;\n isPackaged?: boolean;\n isTest?: boolean;\n mainPid?: number | null;\n platform?: string;\n workspaceId?: string;\n};\n\nexport type AgentHostEnvironmentApi = AgentHostRecord & {\n getBaseUrl?: () => AgentHostAsyncResult<string>;\n warmupOpenclawGateway?: (input?: unknown) => AgentHostAsyncResult<unknown>;\n};\n\nexport type AgentHostPersistenceApi = AgentHostRecord & {\n readWorkspaceAgentReadState: (\n input: ReadWorkspaceAgentReadStateInput\n ) => AgentHostAsyncResult<WorkspaceAgentReadStateSnapshot>;\n writeWorkspaceAgentReadState: (\n input: WriteWorkspaceAgentReadStateInput\n ) => AgentHostAsyncResult<PersistWriteResult>;\n};\n\nexport interface AgentHostSelectedFile {\n name?: string;\n path: string;\n}\n\nexport interface AgentHostSelectFilesInput {\n allowDirectories?: boolean;\n}\n\nexport type AgentHostWorkspaceApi = AgentHostRecord & {\n copyPath?: (input: { path: string }) => AgentHostAsyncResult<void>;\n ensureDirectory: (input: { path: string }) => AgentHostAsyncResult<void>;\n getPathForFile: (file: File) => string;\n readFile: (input: {\n path: string;\n }) => AgentHostAsyncResult<AgentHostReadWorkspaceFileResult>;\n selectContextEntries?: () => AgentHostAsyncResult<{ entries: unknown[] }>;\n selectDirectory: () => AgentHostAsyncResult<{ path: string } | null>;\n selectFiles: (\n input?: AgentHostSelectFilesInput\n ) => AgentHostAsyncResult<AgentHostSelectedFile[]>;\n writeFileText: (input: {\n content: string;\n path: string;\n }) => AgentHostAsyncResult<unknown>;\n};\n\nexport interface AgentHostInputApi {\n account?: AgentHostAccountApi;\n agentGuiBatch?: AgentHostAgentGuiBatchApi;\n agentSessions?: AgentHostAgentSessionsApi;\n clipboard: AgentHostClipboardApi;\n debug?: AgentHostDebugApi;\n filesystem: AgentHostFilesystemApi;\n meta?: AgentHostMetaApi;\n onHostEvent?: (listener: (event: any) => void) => AgentHostUnsubscribe;\n persistence?: AgentHostPersistenceApi;\n runtime?: AgentHostEnvironmentApi;\n userProjects?: AgentHostUserProjectsApi;\n workspace: AgentHostWorkspaceApi;\n workspaceAgentProbes?: AgentHostWorkspaceAgentProbesApi;\n workspaceAgents?: AgentHostWorkspaceAgentsApi;\n}\n\nexport type AgentHostApi = AgentHostInputApi;\n\nexport type AgentHostAccountApi = AgentHostRecord & {\n batchGetUserInfo: (\n input: AgentHostBatchUserInfoInput\n ) => AgentHostAsyncResult<AgentHostBatchUserInfoResult>;\n ensureProfiles?: (input: any) => AgentHostAsyncResult<any>;\n};\n\nexport type AgentHostAgentGuiBatchApi = AgentHostRecord & {\n exportRun: (input: any) => AgentHostAsyncResult<any>;\n};\n\nexport type AgentHostWorkspaceAgentProbesApi = AgentHostRecord & {\n list: (\n input: AgentHostListWorkspaceAgentProbesInput\n ) => AgentHostAsyncResult<AgentHostWorkspaceAgentProbesResult>;\n};\n\nexport type AgentProviderProbeListInput =\n AgentHostListWorkspaceAgentProbesInput;\nexport type AgentProviderProbeListResult = AgentHostWorkspaceAgentProbesResult;\n\nexport interface AgentHostUserProject {\n id: string;\n path: string;\n label: string;\n createdAtUnixMs?: number;\n updatedAtUnixMs?: number;\n lastUsedAtUnixMs?: number;\n}\n\nexport type AgentHostUserProjectsApi = AgentHostRecord & {\n service?: WorkspaceUserProjectService;\n checkPath?: (input: { path: string }) => AgentHostAsyncResult<{\n exists: boolean;\n isDirectory: boolean;\n path: string;\n }>;\n create?: (input: {\n name: string;\n }) => AgentHostAsyncResult<AgentHostUserProject>;\n getDefaultSelection?: () => AgentHostAsyncResult<{\n path: string | null;\n } | null>;\n list: () => AgentHostAsyncResult<{\n projects: AgentHostUserProject[];\n }>;\n subscribe?: (listener: () => void) => AgentHostUnsubscribe;\n prepareSelection?: (input: {\n projectLocked: boolean;\n selectedPath: string | null;\n }) => AgentHostAsyncResult<{\n isSelectedPathMissing: boolean;\n projects: AgentHostUserProject[];\n selection:\n | {\n kind: \"clear\";\n suppressedPath: string;\n }\n | {\n kind: \"none\";\n }\n | {\n kind: \"select\";\n path: string;\n };\n }>;\n remove?: (input: { path: string }) => AgentHostAsyncResult<void>;\n isNoProjectPath?: (input: { path: string }) => boolean;\n rememberDefaultSelection?: (input: {\n path: string | null;\n }) => AgentHostAsyncResult<void>;\n use: (input: { path: string }) => AgentHostAsyncResult<AgentHostUserProject>;\n};\n\nexport type AgentHostAgentSessionsApi = AgentHostRecord & {\n activate: (input: any) => AgentHostAsyncResult<any>;\n /**\n * @deprecated AgentGUI production writes must use AgentActivityRuntime.cancelSession.\n */\n cancel: (input: any) => AgentHostAsyncResult<any>;\n /**\n * @deprecated AgentGUI production writes must use AgentActivityRuntime.sendInput.\n */\n exec: (input: any) => AgentHostAsyncResult<any>;\n getComposerOptions?: (input: any) => AgentHostAsyncResult<any>;\n getState: (input: any) => AgentHostAsyncResult<any>;\n onEvent?: (listener: (event: any) => void) => AgentHostUnsubscribe;\n /**\n * @deprecated AgentGUI production writes must use AgentActivityRuntime.setSessionPinned.\n */\n pinSession?: (input: any) => AgentHostAsyncResult<any>;\n /**\n * @deprecated AgentGUI production sync must use AgentActivityRuntime.ensureSessionSynchronized.\n */\n releaseEventStream?: (input?: any) => AgentHostAsyncResult;\n /**\n * @deprecated AgentGUI production sync must use AgentActivityRuntime.ensureSessionSynchronized.\n */\n retainEventStream?: (input: any) => AgentHostAsyncResult;\n /**\n * @deprecated AgentGUI production writes must use AgentActivityRuntime.submitInteractive.\n */\n submitInteractive: (input: any) => AgentHostAsyncResult<any>;\n /**\n * @deprecated AgentGUI production UI must derive events from AgentActivityRuntime snapshots.\n */\n trackSettingsProjectChange?: (input: {\n action: \"clear\" | \"create_new\" | \"select_existing\";\n agentSessionId: string;\n provider?: string | null;\n }) => AgentHostAsyncResult<void>;\n subscribeEvents: (\n input: any,\n listener: (event: any) => void\n ) => AgentHostUnsubscribe;\n unactivate: (input: any) => AgentHostAsyncResult<any>;\n updateSettings: (input: any) => AgentHostAsyncResult<any>;\n};\n\n/**\n * @deprecated Legacy host DTO projection. AgentGUI production reads and writes\n * must use AgentActivityRuntime and AgentActivity* models.\n */\nexport type AgentHostWorkspaceAgentsApi = AgentHostRecord & {\n /**\n * @deprecated Use AgentActivityRuntime.deleteSession.\n */\n deleteSession: (\n input: AgentHostDeleteWorkspaceAgentSessionRuntimeInput\n ) => AgentHostAsyncResult<any>;\n /**\n * @deprecated Derive summaries from AgentActivitySnapshot/session messages.\n */\n getSessionSummary: (\n input: AgentHostWorkspaceAgentSessionSummaryRuntimeInput\n ) => AgentHostAsyncResult<AgentHostWorkspaceAgentSessionSummary>;\n /**\n * @deprecated Use AgentActivityRuntime.load/getSnapshot.\n */\n list: (\n input: string | AgentHostWorkspaceAgentsListInput\n ) => AgentHostAsyncResult<AgentHostWorkspaceAgentSnapshot>;\n /**\n * @deprecated Use AgentActivityRuntime.listSessionMessages.\n */\n listSessionMessages: (\n input: AgentHostWorkspaceAgentSessionMessagesRuntimeInput\n ) => AgentHostAsyncResult<AgentHostWorkspaceAgentSessionMessages>;\n};\n\nexport interface AgentHostRuntimeApi {\n account?: AgentHostAccountApi;\n agentGuiBatch: AgentHostAgentGuiBatchApi;\n clipboard: AgentHostClipboardApi;\n debug?: AgentHostDebugApi;\n filesystem: AgentHostFilesystemApi;\n meta?: AgentHostMetaApi;\n onHostEvent?: (listener: (event: any) => void) => AgentHostUnsubscribe;\n persistence?: AgentHostPersistenceApi;\n runtime?: AgentHostEnvironmentApi;\n userProjects?: AgentHostUserProjectsApi;\n workspace: AgentHostWorkspaceApi;\n workspaceAgentProbes?: AgentHostWorkspaceAgentProbesApi;\n}\n\nexport function toAgentHostRuntimeApi(\n hostApi: AgentHostInputApi | AgentHostRuntimeApi\n): AgentHostRuntimeApi {\n return {\n account: hostApi.account,\n agentGuiBatch: hostApi.agentGuiBatch ?? ({} as AgentHostAgentGuiBatchApi),\n clipboard: hostApi.clipboard,\n debug: hostApi.debug,\n filesystem: hostApi.filesystem,\n meta: hostApi.meta,\n onHostEvent: hostApi.onHostEvent,\n persistence: hostApi.persistence,\n runtime: hostApi.runtime,\n userProjects: hostApi.userProjects,\n workspace: hostApi.workspace,\n workspaceAgentProbes: hostApi.workspaceAgentProbes\n };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAgTH;AAhBJ,IAAM,8BAA8B;AAAA,EAClC;AACF;AAEA,IAAI,8BAA2D;AAMxD,SAAS,6BAA6B;AAAA,EAC3C;AAAA,EACA;AACF,GAAmD;AACjD,gCAA8B,WAAW;AACzC,SACE,oBAAC,4BAA4B,UAA5B,EAAqC,OAAO,WAAW,MACrD,UACH;AAEJ;AAEO,SAAS,0BAAgD;AAC9D,QAAM,UACJ,WAAW,2BAA2B,KAAK,4BAA4B;AACzE,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,kCAA+D;AAC7E,SACE,WAAW,2BAA2B,KAAK,4BAA4B;AAE3E;AAEO,SAAS,yBACd,aACuB;A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CAAkC;AAC/D,MAAI,sBAAsB;AACxB,WAAO;AAAA,EACT;AACA,MAAI,qBAAqB;AACvB,WAAO;AAAA,EACT;AACA,QAAM,mBACJ,OAGA;AACF,SAAO,mBAAmB,sBAAsB,gBAAgB,IAAI;AACtE;AAEA,SAAS,oCAAgE;AACvE,MAAI,QAAQ,IAAI,aAAa,UAAU,OAAO,WAAW,aAAa;AACpE,WAAO;AAAA,EACT;AACA,QAAM,iBAAiB,OAAO;AAAA,IAC5B;AAAA,IACA;AAAA,EACF;AACA,MAAI,CAAC,kBAAkB,EAAE,WAAW,iBAAiB;AACnD,WAAO;AAAA,EACT;AACA,QAAM,mBAAmB,eAAe;AAIxC,SAAO,mBAAmB,sBAAsB,gBAAgB,IAAI;AACtE;","names":["createContext","useContext","jsx","createContext","useContext"]}
1
+ {"version":3,"sources":["../agentActivityRuntime.tsx","../agentActivityHost.tsx","../host/agentHostApi.ts"],"sourcesContent":["import {\n createContext,\n useContext,\n useSyncExternalStore,\n type JSX,\n type PropsWithChildren\n} from \"react\";\nimport type {\n AgentActivityCancelSessionInput,\n AgentActivityCancelSessionResult,\n AgentActivityCreateSessionInput,\n AgentActivityDeleteSessionInput,\n AgentActivityDeleteSessionResult,\n AgentActivityMessageOrder,\n AgentActivityMessagePage,\n AgentActivitySendInput,\n AgentActivitySendInputResult,\n AgentActivitySession,\n AgentActivitySnapshot,\n AgentActivitySnapshotListener,\n AgentActivitySubmitInteractiveInput\n} from \"@tutti-os/agent-activity-core\";\nimport type {\n AgentHostAgentSessionComposerSettings,\n AgentHostActivateAgentSessionResult,\n AgentHostRuntimeOpenclawGatewayWarmupResult,\n AgentHostUpdateAgentSessionSettingsResult,\n AgentHostUnactivateAgentSessionResult,\n AgentHostAgentSessionState\n} from \"./shared/contracts/dto\";\nimport type { AgentGUIProviderTargetRef } from \"./types\";\n\nexport interface AgentActivityRuntimeListSessionMessagesInput {\n afterVersion?: number;\n beforeVersion?: number;\n cache?: boolean;\n agentSessionId: string;\n limit?: number;\n order?: AgentActivityMessageOrder;\n signal?: AbortSignal;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeListGeneratedFilesInput {\n limit?: number;\n query?: string;\n sessionCwd?: string;\n signal?: AbortSignal;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeGeneratedFile {\n label: string;\n path: string;\n}\n\nexport interface AgentActivityRuntimeGeneratedFileList {\n entries: AgentActivityRuntimeGeneratedFile[];\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeEnsureSessionSynchronizedInput {\n afterVersion?: number;\n agentSessionId: string;\n onError?: (error: unknown) => void;\n workspaceId: string;\n}\n\nexport type AgentActivityRuntimeRetainSessionEventsInput =\n AgentActivityRuntimeEnsureSessionSynchronizedInput;\n\nexport interface AgentActivityRuntimeSetSessionPinnedInput {\n agentSessionId: string;\n pinned: boolean;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeTrackSettingsProjectChangeInput {\n action: \"clear\" | \"create_new\" | \"select_existing\";\n agentSessionId: string;\n provider?: string | null;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeGetSessionControlStateInput {\n agentSessionId: string;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeGetComposerOptionsInput {\n cwd?: string | null;\n force?: boolean;\n provider?: string;\n settings?: AgentHostAgentSessionComposerSettings | null;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeUpdateSessionSettingsInput {\n agentSessionId: string;\n settings: AgentHostAgentSessionComposerSettings;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeTrackDraftComposerSettingsChangeInput {\n nextSettings: AgentHostAgentSessionComposerSettings;\n previousSettings: AgentHostAgentSessionComposerSettings;\n provider: string;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeWarmupOpenclawGatewayInput {\n workspaceId?: string | null;\n}\n\nexport interface AgentActivityRuntimeDiagnosticInput {\n details?: Record<string, unknown>;\n event: string;\n level?: \"debug\" | \"info\" | \"warn\" | \"error\";\n source?: string;\n workspaceId?: string | null;\n}\n\nexport interface AgentActivityRuntimeActivateSessionInput {\n agentSessionId: string;\n cwd?: string;\n initialContent?: AgentActivitySendInput[\"content\"];\n /** 仅展示用首轮文本(bundle 折叠成一个 chip);initialContent 仍带展开后的文件。 */\n initialDisplayPrompt?: string | null;\n metadata?: Record<string, unknown>;\n mode: \"existing\" | \"new\";\n openclawGatewayReady?: boolean;\n provider?: string;\n /**\n * Opaque host-owned target reference. AgentGUI passes this through only; hosts\n * must not treat it as authority and must re-authenticate before launch.\n */\n providerTargetRef?: AgentGUIProviderTargetRef | null;\n settings?: AgentHostAgentSessionComposerSettings;\n title?: string;\n visible?: boolean;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeUnactivateSessionInput {\n agentSessionId: string;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeReadSessionAttachmentInput {\n agentSessionId: string;\n attachmentId: string;\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeReadPromptAssetInput {\n agentSessionId?: string | null;\n assetId?: string | null;\n hostPath?: string | null;\n kind?: string | null;\n mimeType: string;\n name?: string | null;\n path?: string | null;\n sha256?: string | null;\n uploadStatus?: string | null;\n uri?: string | null;\n workspaceId: string;\n}\n\nexport type AgentActivityRuntimePromptContentBlock =\n AgentActivitySendInput[\"content\"][number] & {\n assetId?: string;\n hostPath?: string;\n kind?: string;\n path?: string;\n sizeBytes?: number;\n uploadStatus?: string;\n uri?: string;\n };\n\nexport interface AgentActivityRuntimeUploadPromptContentInput {\n content: AgentActivityRuntimePromptContentBlock[];\n workspaceId: string;\n}\n\nexport interface AgentActivityRuntimeUploadPromptContentResult {\n content: AgentActivityRuntimePromptContentBlock[];\n}\n\nexport interface AgentActivityRuntimeSessionAttachment {\n attachmentId: string;\n mimeType: string;\n name?: string;\n data: string;\n}\n\nexport interface AgentActivityRuntimePromptAsset {\n assetId?: string;\n hostPath?: string;\n kind?: string;\n mimeType: string;\n name?: string;\n path: string;\n uploadStatus?: string;\n uri?: string;\n data: string;\n}\n\nexport interface AgentActivityRuntime {\n cancelSession(\n input: AgentActivityCancelSessionInput\n ): Promise<AgentActivityCancelSessionResult>;\n createSession(\n input: AgentActivityCreateSessionInput\n ): Promise<AgentActivitySession>;\n deleteSession(\n input: AgentActivityDeleteSessionInput\n ): Promise<AgentActivityDeleteSessionResult>;\n activateSession(\n input: AgentActivityRuntimeActivateSessionInput\n ): Promise<AgentHostActivateAgentSessionResult>;\n getSession(\n workspaceId: string,\n agentSessionId: string\n ): Promise<AgentActivitySession>;\n getComposerOptions(\n input: AgentActivityRuntimeGetComposerOptionsInput\n ): Promise<unknown>;\n updateSessionSettings(\n input: AgentActivityRuntimeUpdateSessionSettingsInput\n ): Promise<AgentHostUpdateAgentSessionSettingsResult>;\n warmupOpenclawGateway?(\n input?: AgentActivityRuntimeWarmupOpenclawGatewayInput\n ): Promise<AgentHostRuntimeOpenclawGatewayWarmupResult>;\n getSessionControlState(\n input: AgentActivityRuntimeGetSessionControlStateInput\n ): Promise<AgentHostAgentSessionState>;\n getSnapshot(workspaceId: string): AgentActivitySnapshot;\n listSessionMessages(\n input: AgentActivityRuntimeListSessionMessagesInput\n ): Promise<AgentActivityMessagePage>;\n listAgentGeneratedFiles?(\n input: AgentActivityRuntimeListGeneratedFilesInput\n ): Promise<AgentActivityRuntimeGeneratedFileList>;\n load(\n workspaceId: string,\n signal?: AbortSignal\n ): Promise<AgentActivitySnapshot>;\n ensureSessionSynchronized?(\n input: AgentActivityRuntimeEnsureSessionSynchronizedInput\n ): () => void;\n /** @deprecated Use ensureSessionSynchronized. */\n retainSessionEvents(\n input: AgentActivityRuntimeRetainSessionEventsInput\n ): () => void;\n sendInput(\n input: AgentActivitySendInput\n ): Promise<AgentActivitySendInputResult>;\n uploadPromptContent?(\n input: AgentActivityRuntimeUploadPromptContentInput\n ): Promise<AgentActivityRuntimeUploadPromptContentResult>;\n readSessionAttachment?(\n input: AgentActivityRuntimeReadSessionAttachmentInput\n ): Promise<AgentActivityRuntimeSessionAttachment>;\n readPromptAsset?(\n input: AgentActivityRuntimeReadPromptAssetInput\n ): Promise<AgentActivityRuntimePromptAsset>;\n setSessionPinned(\n input: AgentActivityRuntimeSetSessionPinnedInput\n ): Promise<AgentActivitySession>;\n trackSettingsProjectChange?(\n input: AgentActivityRuntimeTrackSettingsProjectChangeInput\n ): Promise<void>;\n trackDraftComposerSettingsChange?(\n input: AgentActivityRuntimeTrackDraftComposerSettingsChangeInput\n ): Promise<void>;\n reportDiagnostic?(\n input: AgentActivityRuntimeDiagnosticInput\n ): Promise<void> | void;\n unactivateSession(\n input: AgentActivityRuntimeUnactivateSessionInput\n ): Promise<AgentHostUnactivateAgentSessionResult>;\n submitInteractive(\n input: AgentActivitySubmitInteractiveInput\n ): Promise<unknown>;\n subscribeSessionEvents(\n workspaceId: string,\n listener: (event: unknown) => void\n ): () => void;\n subscribe(\n workspaceId: string,\n listener: AgentActivitySnapshotListener\n ): () => void;\n}\n\nconst AgentActivityRuntimeContext = createContext<AgentActivityRuntime | null>(\n null\n);\n\nlet currentAgentActivityRuntime: AgentActivityRuntime | null = null;\n\nexport interface AgentActivityRuntimeProviderProps extends PropsWithChildren {\n runtime?: AgentActivityRuntime | null;\n}\n\nexport function AgentActivityRuntimeProvider({\n children,\n runtime\n}: AgentActivityRuntimeProviderProps): JSX.Element {\n currentAgentActivityRuntime = runtime ?? null;\n return (\n <AgentActivityRuntimeContext.Provider value={runtime ?? null}>\n {children}\n </AgentActivityRuntimeContext.Provider>\n );\n}\n\nexport function useAgentActivityRuntime(): AgentActivityRuntime {\n const runtime =\n useContext(AgentActivityRuntimeContext) ?? getTestAgentActivityRuntime();\n if (!runtime) {\n throw new Error(\n \"AgentActivityRuntimeProvider is missing an AgentActivityRuntime instance.\"\n );\n }\n return runtime;\n}\n\nexport function useOptionalAgentActivityRuntime(): AgentActivityRuntime | null {\n return (\n useContext(AgentActivityRuntimeContext) ?? getTestAgentActivityRuntime()\n );\n}\n\nexport function useAgentActivitySnapshot(\n workspaceId: string\n): AgentActivitySnapshot {\n const runtime = useAgentActivityRuntime();\n const normalizedWorkspaceId = workspaceId.trim();\n return useSyncExternalStore(\n (listener) => runtime.subscribe(normalizedWorkspaceId, listener),\n () => runtime.getSnapshot(normalizedWorkspaceId),\n () => runtime.getSnapshot(normalizedWorkspaceId)\n );\n}\n\nexport function getAgentActivityRuntime(): AgentActivityRuntime {\n const runtime =\n getExplicitWindowTestAgentActivityRuntime() ??\n currentAgentActivityRuntime ??\n getTestAgentActivityRuntime();\n if (!runtime) {\n throw new Error(\n \"AgentActivityRuntimeProvider is missing an AgentActivityRuntime instance.\"\n );\n }\n return runtime;\n}\n\nexport function getOptionalAgentActivityRuntime(): AgentActivityRuntime | null {\n return (\n getExplicitWindowTestAgentActivityRuntime() ??\n currentAgentActivityRuntime ??\n getTestAgentActivityRuntime()\n );\n}\n\nexport function resetAgentActivityRuntimeForTests(): void {\n if (process.env.NODE_ENV === \"test\") {\n currentAgentActivityRuntime = null;\n }\n}\n\nexport function setAgentActivityRuntimeForTests(\n runtime: AgentActivityRuntime | null\n): void {\n if (process.env.NODE_ENV === \"test\") {\n currentAgentActivityRuntime = runtime;\n }\n}\n\nfunction getTestAgentActivityRuntime(): AgentActivityRuntime | null {\n if (process.env.NODE_ENV !== \"test\") {\n return null;\n }\n if (typeof window === \"undefined\") {\n return null;\n }\n const explicitRuntime = getExplicitWindowTestAgentActivityRuntime();\n if (explicitRuntime) {\n return explicitRuntime;\n }\n if (currentAgentActivityRuntime) {\n return currentAgentActivityRuntime;\n }\n const testRuntime = (\n window as unknown as Window & {\n agentActivityRuntime?: AgentActivityRuntime;\n }\n ).agentActivityRuntime;\n return testRuntime ?? null;\n}\n\nfunction getExplicitWindowTestAgentActivityRuntime(): AgentActivityRuntime | null {\n if (process.env.NODE_ENV !== \"test\" || typeof window === \"undefined\") {\n return null;\n }\n const testDescriptor = Object.getOwnPropertyDescriptor(\n window,\n \"agentActivityRuntime\"\n );\n if (!testDescriptor || !(\"value\" in testDescriptor)) {\n return null;\n }\n return (testDescriptor.value as AgentActivityRuntime | undefined) ?? null;\n}\n","import {\n createContext,\n useContext,\n useMemo,\n type JSX,\n type PropsWithChildren\n} from \"react\";\nimport {\n toAgentHostRuntimeApi,\n type AgentHostInputApi,\n type AgentHostRuntimeApi\n} from \"./host/agentHostApi\";\nimport {\n AgentActivityRuntimeProvider,\n type AgentActivityRuntime\n} from \"./agentActivityRuntime\";\n\nconst AgentActivityHostContext = createContext<AgentHostRuntimeApi | null>(\n null\n);\n\nlet currentAgentHostApi: AgentHostRuntimeApi | null = null;\n\nexport interface AgentActivityHostProviderProps extends PropsWithChildren {\n agentActivityRuntime?: AgentActivityRuntime | null;\n agentHostApi?: AgentHostInputApi | null;\n}\n\nexport function AgentActivityHostProvider({\n agentActivityRuntime,\n agentHostApi,\n children\n}: AgentActivityHostProviderProps): JSX.Element {\n const resolvedAgentHostApi = useMemo(\n () => (agentHostApi ? toAgentHostRuntimeApi(agentHostApi) : null),\n [agentHostApi]\n );\n currentAgentHostApi = resolvedAgentHostApi;\n return (\n <AgentActivityRuntimeProvider runtime={agentActivityRuntime}>\n <AgentActivityHostContext.Provider value={resolvedAgentHostApi}>\n {children}\n </AgentActivityHostContext.Provider>\n </AgentActivityRuntimeProvider>\n );\n}\n\nexport function useAgentHostApi(): AgentHostRuntimeApi {\n const agentHostApi =\n useContext(AgentActivityHostContext) ?? getTestAgentHostApi();\n if (!agentHostApi) {\n throw new Error(\n \"AgentActivityHostProvider is missing an agentHostApi instance.\"\n );\n }\n return agentHostApi;\n}\n\nexport function useOptionalAgentHostApi(): AgentHostRuntimeApi | null {\n return useContext(AgentActivityHostContext) ?? getTestAgentHostApi();\n}\n\nexport function getAgentHostApi(): AgentHostRuntimeApi {\n const agentHostApi =\n getExplicitWindowTestAgentHostApi() ??\n currentAgentHostApi ??\n getTestAgentHostApi();\n if (!agentHostApi) {\n throw new Error(\n \"AgentActivityHostProvider is missing an agentHostApi instance.\"\n );\n }\n return agentHostApi;\n}\n\nexport function getOptionalAgentHostApi(): AgentHostRuntimeApi | null {\n return (\n getExplicitWindowTestAgentHostApi() ??\n currentAgentHostApi ??\n getTestAgentHostApi()\n );\n}\n\nexport function resetAgentHostApiForTests(): void {\n if (process.env.NODE_ENV === \"test\") {\n currentAgentHostApi = null;\n }\n}\n\nexport function setAgentHostApiForTests(\n agentHostApi: AgentHostInputApi | AgentHostRuntimeApi | null\n): void {\n if (process.env.NODE_ENV === \"test\") {\n currentAgentHostApi = agentHostApi\n ? toAgentHostRuntimeApi(agentHostApi)\n : null;\n }\n}\n\nfunction getTestAgentHostApi(): AgentHostRuntimeApi | null {\n if (process.env.NODE_ENV !== \"test\") {\n return null;\n }\n if (typeof window === \"undefined\") {\n return null;\n }\n const explicitAgentHostApi = getExplicitWindowTestAgentHostApi();\n if (explicitAgentHostApi) {\n return explicitAgentHostApi;\n }\n if (currentAgentHostApi) {\n return currentAgentHostApi;\n }\n const testAgentHostApi = (\n window as unknown as Window & {\n agentHostApi?: AgentHostInputApi | AgentHostRuntimeApi;\n }\n ).agentHostApi;\n return testAgentHostApi ? toAgentHostRuntimeApi(testAgentHostApi) : null;\n}\n\nfunction getExplicitWindowTestAgentHostApi(): AgentHostRuntimeApi | null {\n if (process.env.NODE_ENV !== \"test\" || typeof window === \"undefined\") {\n return null;\n }\n const testDescriptor = Object.getOwnPropertyDescriptor(\n window,\n \"agentHostApi\"\n );\n if (!testDescriptor || !(\"value\" in testDescriptor)) {\n return null;\n }\n const testAgentHostApi = testDescriptor.value as\n | AgentHostInputApi\n | AgentHostRuntimeApi\n | undefined;\n return testAgentHostApi ? toAgentHostRuntimeApi(testAgentHostApi) : null;\n}\n","import type {\n AgentHostBatchUserInfoInput,\n AgentHostBatchUserInfoResult,\n AgentHostDeleteWorkspaceAgentSessionInput,\n AgentHostWorkspaceAgentListInput as AgentHostListWorkspaceAgentsInput,\n AgentHostListWorkspaceAgentProbesInput,\n AgentHostWorkspaceAgentSessionMessages,\n AgentHostWorkspaceAgentSessionMessagesInput,\n AgentHostWorkspaceAgentSessionSummary,\n AgentHostWorkspaceAgentSessionSummaryInput,\n AgentHostWorkspaceAgentProbesResult,\n AgentHostWorkspaceAgentSnapshot,\n PersistWriteResult,\n ReadWorkspaceAgentReadStateInput,\n ReadWorkspaceFileResult as AgentHostReadWorkspaceFileResult,\n WorkspaceAgentReadStateSnapshot,\n WriteWorkspaceAgentReadStateInput\n} from \"../shared/contracts/dto\";\nimport type { WorkspaceUserProjectService } from \"@tutti-os/workspace-user-project/contracts\";\n\ntype AgentHostAsyncResult<T = any> = Promise<T>;\ntype AgentHostRecord = Record<string, unknown>;\ntype AgentHostUnsubscribe = () => void;\ntype AgentHostWorkspaceScopedInput<\n T extends {\n workspaceId?: string | null;\n }\n> = Omit<T, \"workspaceId\"> & {\n workspaceId: string;\n};\ntype AgentHostWorkspaceAgentsListInput =\n AgentHostWorkspaceScopedInput<AgentHostListWorkspaceAgentsInput>;\ntype AgentHostWorkspaceAgentSessionMessagesRuntimeInput =\n AgentHostWorkspaceScopedInput<AgentHostWorkspaceAgentSessionMessagesInput>;\ntype AgentHostWorkspaceAgentSessionSummaryRuntimeInput =\n AgentHostWorkspaceScopedInput<AgentHostWorkspaceAgentSessionSummaryInput>;\ntype AgentHostDeleteWorkspaceAgentSessionRuntimeInput =\n AgentHostWorkspaceScopedInput<AgentHostDeleteWorkspaceAgentSessionInput>;\n\nexport type AgentHostClipboardApi = {\n writeImage?: (input: {\n data: string;\n mimeType: \"image/png\";\n }) => AgentHostAsyncResult<void>;\n writeText: (text: string) => AgentHostAsyncResult<void>;\n};\n\nexport type AgentHostDebugApi = {\n logRuntimeDiagnostics: (\n payload: unknown\n ) => AgentHostAsyncResult<void> | void;\n logTerminalDiagnostics?: (\n payload: unknown\n ) => AgentHostAsyncResult<void> | void;\n};\n\nexport type AgentHostFilesystemApi = AgentHostRecord & {\n readFileText: (payload: {\n path?: string;\n uri?: string;\n }) => AgentHostAsyncResult<{\n content: string;\n name?: string;\n path?: string;\n }>;\n};\n\nexport type AgentHostMetaApi = AgentHostRecord & {\n appVersion?: string | null;\n isPackaged?: boolean;\n isTest?: boolean;\n mainPid?: number | null;\n platform?: string;\n workspaceId?: string;\n};\n\nexport type AgentHostEnvironmentApi = AgentHostRecord & {\n getBaseUrl?: () => AgentHostAsyncResult<string>;\n warmupOpenclawGateway?: (input?: unknown) => AgentHostAsyncResult<unknown>;\n};\n\nexport type AgentHostPersistenceApi = AgentHostRecord & {\n readWorkspaceAgentReadState: (\n input: ReadWorkspaceAgentReadStateInput\n ) => AgentHostAsyncResult<WorkspaceAgentReadStateSnapshot>;\n writeWorkspaceAgentReadState: (\n input: WriteWorkspaceAgentReadStateInput\n ) => AgentHostAsyncResult<PersistWriteResult>;\n};\n\nexport type AgentHostToastApi = AgentHostRecord & {\n error: (title: string, description?: string) => void;\n info?: (title: string, description?: string) => void;\n success?: (title: string, description?: string) => void;\n};\n\nexport interface AgentHostSelectedFile {\n name?: string;\n path: string;\n}\n\nexport interface AgentHostSelectFilesInput {\n allowDirectories?: boolean;\n}\n\nexport interface AgentHostApplyWorkspaceGitPatchInput {\n allowBinary?: boolean;\n atomic?: boolean;\n cwd: string;\n diff: string;\n revert?: boolean;\n target?: \"unstaged\" | \"staged\" | \"staged-and-unstaged\";\n}\n\nexport interface AgentHostApplyWorkspaceGitPatchResult {\n status: \"success\" | \"partial-success\" | \"error\";\n appliedPaths: string[];\n skippedPaths: string[];\n conflictedPaths: string[];\n errorCode?: \"not-git-repo\" | string;\n execOutput?: {\n command: string;\n stdout: string;\n stderr: string;\n };\n}\n\nexport interface AgentHostResolveWorkspaceGitPatchSupportInput {\n cwd: string;\n}\n\nexport interface AgentHostResolveWorkspaceGitPatchSupportResult {\n supported: boolean;\n root?: string;\n errorCode?: \"not-git-repo\" | string;\n}\n\nexport type AgentHostWorkspaceApi = AgentHostRecord & {\n applyGitPatch?: (\n input: AgentHostApplyWorkspaceGitPatchInput\n ) => AgentHostAsyncResult<AgentHostApplyWorkspaceGitPatchResult>;\n resolveGitPatchSupport?: (\n input: AgentHostResolveWorkspaceGitPatchSupportInput\n ) => AgentHostAsyncResult<AgentHostResolveWorkspaceGitPatchSupportResult>;\n copyPath?: (input: { path: string }) => AgentHostAsyncResult<void>;\n ensureDirectory: (input: { path: string }) => AgentHostAsyncResult<void>;\n getReferenceForFile?: (file: File) => {\n kind: \"file\" | \"folder\";\n path: string;\n };\n readFile: (input: {\n path: string;\n }) => AgentHostAsyncResult<AgentHostReadWorkspaceFileResult>;\n selectContextEntries?: () => AgentHostAsyncResult<{ entries: unknown[] }>;\n selectDirectory: () => AgentHostAsyncResult<{ path: string } | null>;\n selectFiles: (\n input?: AgentHostSelectFilesInput\n ) => AgentHostAsyncResult<AgentHostSelectedFile[]>;\n writeFileText: (input: {\n content: string;\n path: string;\n }) => AgentHostAsyncResult<unknown>;\n};\n\nexport interface AgentHostInputApi {\n account?: AgentHostAccountApi;\n agentGuiBatch?: AgentHostAgentGuiBatchApi;\n agentSessions?: AgentHostAgentSessionsApi;\n clipboard: AgentHostClipboardApi;\n debug?: AgentHostDebugApi;\n filesystem: AgentHostFilesystemApi;\n meta?: AgentHostMetaApi;\n onHostEvent?: (listener: (event: any) => void) => AgentHostUnsubscribe;\n persistence?: AgentHostPersistenceApi;\n runtime?: AgentHostEnvironmentApi;\n toast?: AgentHostToastApi;\n userProjects?: AgentHostUserProjectsApi;\n workspace: AgentHostWorkspaceApi;\n workspaceAgentProbes?: AgentHostWorkspaceAgentProbesApi;\n workspaceAgents?: AgentHostWorkspaceAgentsApi;\n}\n\nexport type AgentHostApi = AgentHostInputApi;\n\nexport type AgentHostAccountApi = AgentHostRecord & {\n batchGetUserInfo: (\n input: AgentHostBatchUserInfoInput\n ) => AgentHostAsyncResult<AgentHostBatchUserInfoResult>;\n ensureProfiles?: (input: any) => AgentHostAsyncResult<any>;\n};\n\nexport type AgentHostAgentGuiBatchApi = AgentHostRecord & {\n exportRun: (input: any) => AgentHostAsyncResult<any>;\n};\n\nexport type AgentHostWorkspaceAgentProbesApi = AgentHostRecord & {\n list: (\n input: AgentHostListWorkspaceAgentProbesInput\n ) => AgentHostAsyncResult<AgentHostWorkspaceAgentProbesResult>;\n};\n\nexport type AgentProviderProbeListInput =\n AgentHostListWorkspaceAgentProbesInput;\nexport type AgentProviderProbeListResult = AgentHostWorkspaceAgentProbesResult;\n\nexport interface AgentHostUserProject {\n id: string;\n path: string;\n label: string;\n createdAtUnixMs?: number;\n updatedAtUnixMs?: number;\n lastUsedAtUnixMs?: number;\n}\n\nexport type AgentHostUserProjectsApi = AgentHostRecord & {\n service?: WorkspaceUserProjectService;\n checkPath?: (input: { path: string }) => AgentHostAsyncResult<{\n exists: boolean;\n isDirectory: boolean;\n path: string;\n }>;\n create?: (input: {\n name: string;\n }) => AgentHostAsyncResult<AgentHostUserProject>;\n getDefaultSelection?: () => AgentHostAsyncResult<{\n path: string | null;\n } | null>;\n list: () => AgentHostAsyncResult<{\n projects: AgentHostUserProject[];\n }>;\n subscribe?: (listener: () => void) => AgentHostUnsubscribe;\n prepareSelection?: (input: {\n projectLocked: boolean;\n selectedPath: string | null;\n }) => AgentHostAsyncResult<{\n isSelectedPathMissing: boolean;\n projects: AgentHostUserProject[];\n selection:\n | {\n kind: \"clear\";\n suppressedPath: string;\n }\n | {\n kind: \"none\";\n }\n | {\n kind: \"select\";\n path: string;\n };\n }>;\n remove?: (input: { path: string }) => AgentHostAsyncResult<void>;\n isNoProjectPath?: (input: { path: string }) => boolean;\n rememberDefaultSelection?: (input: {\n path: string | null;\n }) => AgentHostAsyncResult<void>;\n use: (input: { path: string }) => AgentHostAsyncResult<AgentHostUserProject>;\n};\n\nexport type AgentHostAgentSessionsApi = AgentHostRecord & {\n activate: (input: any) => AgentHostAsyncResult<any>;\n /**\n * @deprecated AgentGUI production writes must use AgentActivityRuntime.cancelSession.\n */\n cancel: (input: any) => AgentHostAsyncResult<any>;\n /**\n * @deprecated AgentGUI production writes must use AgentActivityRuntime.sendInput.\n */\n exec: (input: any) => AgentHostAsyncResult<any>;\n getComposerOptions?: (input: any) => AgentHostAsyncResult<any>;\n getState: (input: any) => AgentHostAsyncResult<any>;\n onEvent?: (listener: (event: any) => void) => AgentHostUnsubscribe;\n /**\n * @deprecated AgentGUI production writes must use AgentActivityRuntime.setSessionPinned.\n */\n pinSession?: (input: any) => AgentHostAsyncResult<any>;\n /**\n * @deprecated AgentGUI production sync must use AgentActivityRuntime.ensureSessionSynchronized.\n */\n releaseEventStream?: (input?: any) => AgentHostAsyncResult;\n /**\n * @deprecated AgentGUI production sync must use AgentActivityRuntime.ensureSessionSynchronized.\n */\n retainEventStream?: (input: any) => AgentHostAsyncResult;\n /**\n * @deprecated AgentGUI production writes must use AgentActivityRuntime.submitInteractive.\n */\n submitInteractive: (input: any) => AgentHostAsyncResult<any>;\n /**\n * @deprecated AgentGUI production UI must derive events from AgentActivityRuntime snapshots.\n */\n trackSettingsProjectChange?: (input: {\n action: \"clear\" | \"create_new\" | \"select_existing\";\n agentSessionId: string;\n provider?: string | null;\n }) => AgentHostAsyncResult<void>;\n subscribeEvents: (\n input: any,\n listener: (event: any) => void\n ) => AgentHostUnsubscribe;\n unactivate: (input: any) => AgentHostAsyncResult<any>;\n updateSettings: (input: any) => AgentHostAsyncResult<any>;\n};\n\n/**\n * @deprecated Legacy host DTO projection. AgentGUI production reads and writes\n * must use AgentActivityRuntime and AgentActivity* models.\n */\nexport type AgentHostWorkspaceAgentsApi = AgentHostRecord & {\n /**\n * @deprecated Use AgentActivityRuntime.deleteSession.\n */\n deleteSession: (\n input: AgentHostDeleteWorkspaceAgentSessionRuntimeInput\n ) => AgentHostAsyncResult<any>;\n /**\n * @deprecated Derive summaries from AgentActivitySnapshot/session messages.\n */\n getSessionSummary: (\n input: AgentHostWorkspaceAgentSessionSummaryRuntimeInput\n ) => AgentHostAsyncResult<AgentHostWorkspaceAgentSessionSummary>;\n /**\n * @deprecated Use AgentActivityRuntime.load/getSnapshot.\n */\n list: (\n input: string | AgentHostWorkspaceAgentsListInput\n ) => AgentHostAsyncResult<AgentHostWorkspaceAgentSnapshot>;\n /**\n * @deprecated Use AgentActivityRuntime.listSessionMessages.\n */\n listSessionMessages: (\n input: AgentHostWorkspaceAgentSessionMessagesRuntimeInput\n ) => AgentHostAsyncResult<AgentHostWorkspaceAgentSessionMessages>;\n};\n\nexport interface AgentHostRuntimeApi {\n account?: AgentHostAccountApi;\n agentGuiBatch: AgentHostAgentGuiBatchApi;\n clipboard: AgentHostClipboardApi;\n debug?: AgentHostDebugApi;\n filesystem: AgentHostFilesystemApi;\n meta?: AgentHostMetaApi;\n onHostEvent?: (listener: (event: any) => void) => AgentHostUnsubscribe;\n persistence?: AgentHostPersistenceApi;\n runtime?: AgentHostEnvironmentApi;\n toast?: AgentHostToastApi;\n userProjects?: AgentHostUserProjectsApi;\n workspace: AgentHostWorkspaceApi;\n workspaceAgentProbes?: AgentHostWorkspaceAgentProbesApi;\n}\n\nexport function toAgentHostRuntimeApi(\n hostApi: AgentHostInputApi | AgentHostRuntimeApi\n): AgentHostRuntimeApi {\n return {\n account: hostApi.account,\n agentGuiBatch: hostApi.agentGuiBatch ?? ({} as AgentHostAgentGuiBatchApi),\n clipboard: hostApi.clipboard,\n debug: hostApi.debug,\n filesystem: hostApi.filesystem,\n meta: hostApi.meta,\n onHostEvent: hostApi.onHostEvent,\n persistence: hostApi.persistence,\n runtime: hostApi.runtime,\n toast: hostApi.toast,\n userProjects: hostApi.userProjects,\n workspace: hostApi.workspace,\n workspaceAgentProbes: hostApi.workspaceAgentProbes\n };\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAgTH;AAhBJ,IAAM,8BAA8B;AAAA,EAClC;AACF;AAEA,IAAI,8BAA2D;AAMxD,SAAS,6BAA6B;AAAA,EAC3C;AAAA,EACA;AACF,GAAmD;AACjD,gCAA8B,WAAW;AACzC,SACE,oBAAC,4BAA4B,UAA5B,EAAqC,OAAO,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