@nuanu-ai/agentbrowse 0.2.47 → 0.2.49

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 (198) hide show
  1. package/README.md +81 -10
  2. package/dist/agentpay-gateway.d.ts +9 -0
  3. package/dist/agentpay-gateway.d.ts.map +1 -1
  4. package/dist/agentpay-gateway.js +31 -1
  5. package/dist/agentpay-stagehand-llm.d.ts.map +1 -1
  6. package/dist/agentpay-stagehand-llm.js +9 -1
  7. package/dist/command-api-tracing.d.ts +19 -0
  8. package/dist/command-api-tracing.d.ts.map +1 -0
  9. package/dist/command-api-tracing.js +137 -0
  10. package/dist/commands/act.d.ts.map +1 -1
  11. package/dist/commands/act.js +822 -670
  12. package/dist/commands/act.test-harness.d.ts +6 -0
  13. package/dist/commands/act.test-harness.d.ts.map +1 -1
  14. package/dist/commands/act.test-harness.js +44 -1
  15. package/dist/commands/action-acceptance.d.ts.map +1 -1
  16. package/dist/commands/action-acceptance.js +115 -0
  17. package/dist/commands/captcha-solve.d.ts.map +1 -1
  18. package/dist/commands/captcha-solve.js +83 -16
  19. package/dist/commands/click-action-executor.d.ts +0 -1
  20. package/dist/commands/click-action-executor.d.ts.map +1 -1
  21. package/dist/commands/click-action-executor.js +31 -77
  22. package/dist/commands/close.d.ts +3 -3
  23. package/dist/commands/close.d.ts.map +1 -1
  24. package/dist/commands/close.js +178 -0
  25. package/dist/commands/descriptor-validation.d.ts.map +1 -1
  26. package/dist/commands/descriptor-validation.js +75 -57
  27. package/dist/commands/end-session.d.ts +25 -0
  28. package/dist/commands/end-session.d.ts.map +1 -0
  29. package/dist/commands/end-session.js +161 -0
  30. package/dist/commands/extract-stagehand-executor.js +1 -1
  31. package/dist/commands/extract.d.ts.map +1 -1
  32. package/dist/commands/extract.js +339 -202
  33. package/dist/commands/fill-secret.d.ts +3 -3
  34. package/dist/commands/fill-secret.d.ts.map +1 -1
  35. package/dist/commands/fill-secret.js +419 -234
  36. package/dist/commands/get-secrets-catalog.d.ts.map +1 -1
  37. package/dist/commands/get-secrets-catalog.js +66 -5
  38. package/dist/commands/init.d.ts.map +1 -1
  39. package/dist/commands/init.js +6 -3
  40. package/dist/commands/interaction-kernel.d.ts +46 -0
  41. package/dist/commands/interaction-kernel.d.ts.map +1 -0
  42. package/dist/commands/interaction-kernel.js +215 -0
  43. package/dist/commands/launch.d.ts +1 -3
  44. package/dist/commands/launch.d.ts.map +1 -1
  45. package/dist/commands/launch.js +115 -27
  46. package/dist/commands/navigate.d.ts.map +1 -1
  47. package/dist/commands/navigate.js +188 -45
  48. package/dist/commands/observe-accessibility.d.ts.map +1 -1
  49. package/dist/commands/observe-accessibility.js +46 -39
  50. package/dist/commands/observe-dom-label-contract.d.ts.map +1 -1
  51. package/dist/commands/observe-dom-label-contract.js +5 -0
  52. package/dist/commands/observe-inventory.d.ts +13 -0
  53. package/dist/commands/observe-inventory.d.ts.map +1 -1
  54. package/dist/commands/observe-inventory.js +320 -65
  55. package/dist/commands/observe-persistence.d.ts.map +1 -1
  56. package/dist/commands/observe-persistence.js +3 -0
  57. package/dist/commands/observe-projection.d.ts +1 -0
  58. package/dist/commands/observe-projection.d.ts.map +1 -1
  59. package/dist/commands/observe-projection.js +7 -2
  60. package/dist/commands/observe-protected.d.ts +1 -0
  61. package/dist/commands/observe-protected.d.ts.map +1 -1
  62. package/dist/commands/observe-protected.js +9 -4
  63. package/dist/commands/observe-semantics.d.ts.map +1 -1
  64. package/dist/commands/observe-semantics.js +5 -2
  65. package/dist/commands/observe-stagehand.d.ts +1 -0
  66. package/dist/commands/observe-stagehand.d.ts.map +1 -1
  67. package/dist/commands/observe-stagehand.js +2 -0
  68. package/dist/commands/observe.d.ts +2 -0
  69. package/dist/commands/observe.d.ts.map +1 -1
  70. package/dist/commands/observe.js +387 -203
  71. package/dist/commands/observe.test-harness.d.ts +8 -0
  72. package/dist/commands/observe.test-harness.d.ts.map +1 -1
  73. package/dist/commands/observe.test-harness.js +48 -1
  74. package/dist/commands/poll-secret.d.ts +6 -0
  75. package/dist/commands/poll-secret.d.ts.map +1 -0
  76. package/dist/commands/poll-secret.js +159 -0
  77. package/dist/commands/request-secret.d.ts +6 -0
  78. package/dist/commands/request-secret.d.ts.map +1 -0
  79. package/dist/commands/request-secret.js +284 -0
  80. package/dist/commands/screenshot.d.ts.map +1 -1
  81. package/dist/commands/screenshot.js +172 -7
  82. package/dist/commands/select-action-executor.d.ts.map +1 -1
  83. package/dist/commands/semantic-observe.d.ts +4 -0
  84. package/dist/commands/semantic-observe.d.ts.map +1 -1
  85. package/dist/commands/semantic-observe.js +388 -17
  86. package/dist/commands/start-session.d.ts +31 -0
  87. package/dist/commands/start-session.d.ts.map +1 -0
  88. package/dist/commands/start-session.js +347 -0
  89. package/dist/commands/status.d.ts +2 -1
  90. package/dist/commands/status.d.ts.map +1 -1
  91. package/dist/commands/status.js +166 -144
  92. package/dist/control-semantics.d.ts +1 -0
  93. package/dist/control-semantics.d.ts.map +1 -1
  94. package/dist/control-semantics.js +51 -9
  95. package/dist/generated/build-config.d.ts +2 -0
  96. package/dist/generated/build-config.d.ts.map +1 -0
  97. package/dist/generated/build-config.js +2 -0
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +163 -63
  100. package/dist/otel-exporter.d.ts +58 -0
  101. package/dist/otel-exporter.d.ts.map +1 -0
  102. package/dist/otel-exporter.js +263 -0
  103. package/dist/otel-projector.d.ts +75 -0
  104. package/dist/otel-projector.d.ts.map +1 -0
  105. package/dist/otel-projector.js +409 -0
  106. package/dist/owned-browser.d.ts +1 -1
  107. package/dist/owned-browser.d.ts.map +1 -1
  108. package/dist/owned-browser.js +13 -1
  109. package/dist/owned-process.d.ts +2 -0
  110. package/dist/owned-process.d.ts.map +1 -1
  111. package/dist/owned-process.js +7 -3
  112. package/dist/playwright-runtime.d.ts +1 -1
  113. package/dist/playwright-runtime.d.ts.map +1 -1
  114. package/dist/playwright-runtime.js +8 -8
  115. package/dist/run-observability.d.ts +25 -0
  116. package/dist/run-observability.d.ts.map +1 -0
  117. package/dist/run-observability.js +115 -0
  118. package/dist/run-store.d.ts +274 -0
  119. package/dist/run-store.d.ts.map +1 -0
  120. package/dist/run-store.js +631 -0
  121. package/dist/runtime-metrics.d.ts +27 -0
  122. package/dist/runtime-metrics.d.ts.map +1 -0
  123. package/dist/runtime-metrics.js +66 -0
  124. package/dist/runtime-page-state.d.ts +11 -0
  125. package/dist/runtime-page-state.d.ts.map +1 -0
  126. package/dist/runtime-page-state.js +62 -0
  127. package/dist/runtime-protected-state.d.ts +16 -0
  128. package/dist/runtime-protected-state.d.ts.map +1 -0
  129. package/dist/runtime-protected-state.js +157 -0
  130. package/dist/runtime-state.d.ts +10 -44
  131. package/dist/runtime-state.d.ts.map +1 -1
  132. package/dist/runtime-state.js +57 -222
  133. package/dist/secrets/backend.d.ts +65 -16
  134. package/dist/secrets/backend.d.ts.map +1 -1
  135. package/dist/secrets/backend.js +135 -95
  136. package/dist/secrets/catalog-sync.d.ts.map +1 -1
  137. package/dist/secrets/catalog-sync.js +4 -1
  138. package/dist/secrets/form-matcher.d.ts +5 -5
  139. package/dist/secrets/form-matcher.d.ts.map +1 -1
  140. package/dist/secrets/form-matcher.js +292 -164
  141. package/dist/secrets/intent-output.d.ts +6 -10
  142. package/dist/secrets/intent-output.d.ts.map +1 -1
  143. package/dist/secrets/intent-output.js +4 -58
  144. package/dist/secrets/mock-agentpay-cabinet.d.ts +38 -27
  145. package/dist/secrets/mock-agentpay-cabinet.d.ts.map +1 -1
  146. package/dist/secrets/mock-agentpay-cabinet.js +177 -111
  147. package/dist/secrets/protected-artifact-guard.d.ts +2 -2
  148. package/dist/secrets/protected-artifact-guard.d.ts.map +1 -1
  149. package/dist/secrets/protected-artifact-guard.js +2 -2
  150. package/dist/secrets/protected-bindings.d.ts +1 -1
  151. package/dist/secrets/protected-bindings.d.ts.map +1 -1
  152. package/dist/secrets/protected-bindings.js +6 -0
  153. package/dist/secrets/protected-field-semantics.d.ts +9 -0
  154. package/dist/secrets/protected-field-semantics.d.ts.map +1 -0
  155. package/dist/secrets/protected-field-semantics.js +154 -0
  156. package/dist/secrets/protected-field-values.d.ts.map +1 -1
  157. package/dist/secrets/protected-field-values.js +3 -3
  158. package/dist/secrets/protected-fill.d.ts +1 -1
  159. package/dist/secrets/protected-fill.d.ts.map +1 -1
  160. package/dist/secrets/protected-fill.js +45 -149
  161. package/dist/secrets/protected-value-adapters.d.ts +2 -1
  162. package/dist/secrets/protected-value-adapters.d.ts.map +1 -1
  163. package/dist/secrets/protected-value-adapters.js +80 -1
  164. package/dist/secrets/request-output.d.ts +11 -0
  165. package/dist/secrets/request-output.d.ts.map +1 -0
  166. package/dist/secrets/request-output.js +75 -0
  167. package/dist/secrets/types.d.ts +15 -9
  168. package/dist/secrets/types.d.ts.map +1 -1
  169. package/dist/secrets/types.js +3 -0
  170. package/dist/session-event-exporter.d.ts +36 -0
  171. package/dist/session-event-exporter.d.ts.map +1 -0
  172. package/dist/session-event-exporter.js +428 -0
  173. package/dist/session.d.ts +16 -7
  174. package/dist/session.d.ts.map +1 -1
  175. package/dist/session.js +150 -23
  176. package/dist/sessions-backend.d.ts +354 -0
  177. package/dist/sessions-backend.d.ts.map +1 -0
  178. package/dist/sessions-backend.js +126 -0
  179. package/dist/solver/browser-launcher.d.ts +1 -1
  180. package/dist/solver/browser-launcher.d.ts.map +1 -1
  181. package/dist/solver/browser-launcher.js +39 -13
  182. package/dist/solver/captcha-solver.d.ts.map +1 -1
  183. package/dist/solver/captcha-solver.js +8 -1
  184. package/dist/solver/config.d.ts +0 -1
  185. package/dist/solver/config.d.ts.map +1 -1
  186. package/dist/solver/config.js +0 -22
  187. package/dist/solver/types.d.ts +1 -0
  188. package/dist/solver/types.d.ts.map +1 -1
  189. package/dist/workflow-session-completion.d.ts +33 -0
  190. package/dist/workflow-session-completion.d.ts.map +1 -0
  191. package/dist/workflow-session-completion.js +156 -0
  192. package/package.json +11 -1
  193. package/dist/commands/create-intent.d.ts +0 -6
  194. package/dist/commands/create-intent.d.ts.map +0 -1
  195. package/dist/commands/create-intent.js +0 -75
  196. package/dist/commands/poll-intent.d.ts +0 -6
  197. package/dist/commands/poll-intent.d.ts.map +0 -1
  198. package/dist/commands/poll-intent.js +0 -57
@@ -0,0 +1,347 @@
1
+ /**
2
+ * browse start-session — Start the workflow/run context on top of an existing browser session.
3
+ */
4
+ import { info } from '../output.js';
5
+ import { buildRunRootOtlpTraceRequest, buildRunStepOtlpTraceRequest, } from '../otel-exporter.js';
6
+ import { appendCommandLifecycleEventBestEffort, captureStepSnapshotBestEffort, } from '../run-observability.js';
7
+ import { finishRunRecord, finishRunStep, startCliRun, startRunStep } from '../run-store.js';
8
+ import { createRemoteSession } from '../sessions-backend.js';
9
+ import { isSessionAlive, loadSession, resolveBrowserSessionId, saveSession, } from '../session.js';
10
+ import { clearWorkflowState, completeWorkflowSessionRemote, } from '../workflow-session-completion.js';
11
+ const MAX_START_SESSION_NAME_LENGTH = 256;
12
+ function formatUnknownError(error) {
13
+ if (error instanceof Error) {
14
+ return error.message;
15
+ }
16
+ if (typeof error === 'string') {
17
+ return error;
18
+ }
19
+ if (error && typeof error === 'object') {
20
+ try {
21
+ return JSON.stringify(error);
22
+ }
23
+ catch {
24
+ return Object.prototype.toString.call(error);
25
+ }
26
+ }
27
+ return String(error);
28
+ }
29
+ function buildStartSessionFailure(reason) {
30
+ return {
31
+ success: false,
32
+ error: 'browser_session_unavailable',
33
+ outcomeType: 'blocked',
34
+ message: 'Session start failed.',
35
+ reason,
36
+ };
37
+ }
38
+ function normalizeStartSessionName(value) {
39
+ if (typeof value !== 'string') {
40
+ return undefined;
41
+ }
42
+ const trimmed = value.trim();
43
+ if (trimmed.length === 0) {
44
+ return undefined;
45
+ }
46
+ return trimmed.length > MAX_START_SESSION_NAME_LENGTH
47
+ ? trimmed.slice(0, MAX_START_SESSION_NAME_LENGTH)
48
+ : trimmed;
49
+ }
50
+ function normalizeMerchantName(value) {
51
+ if (typeof value !== 'string') {
52
+ return undefined;
53
+ }
54
+ const trimmed = value.trim();
55
+ return trimmed.length > 0 ? trimmed : undefined;
56
+ }
57
+ function buildStartSessionDisplayName(options) {
58
+ const requestedName = normalizeStartSessionName(options.requestedName);
59
+ if (requestedName) {
60
+ return requestedName;
61
+ }
62
+ return normalizeStartSessionName(options.pageTitle);
63
+ }
64
+ function finalizePreviousRunBestEffort(runId) {
65
+ if (!runId) {
66
+ return false;
67
+ }
68
+ try {
69
+ finishRunRecord(runId, {
70
+ status: 'aborted',
71
+ finalOutcome: {
72
+ success: false,
73
+ outcomeType: 'replaced_by_start_session',
74
+ message: 'Workflow session was replaced by a new start-session command.',
75
+ reason: 'A new workflow session was started on the same browser session.',
76
+ },
77
+ });
78
+ return true;
79
+ }
80
+ catch (error) {
81
+ info(`[start-session] failed to finalize previous local run ${runId}: ${formatUnknownError(error)}`);
82
+ return false;
83
+ }
84
+ }
85
+ function finalizeStartSessionStepBestEffort(runId, stepId, options) {
86
+ if (!stepId) {
87
+ return;
88
+ }
89
+ try {
90
+ finishRunStep({
91
+ runId,
92
+ stepId,
93
+ ...options,
94
+ });
95
+ }
96
+ catch (error) {
97
+ info(`[start-session] failed to finalize local run step ${stepId}: ${formatUnknownError(error)}`);
98
+ }
99
+ }
100
+ function finalizeRunRecordBestEffort(runId, options) {
101
+ try {
102
+ finishRunRecord(runId, {
103
+ status: options.status,
104
+ finalOutcome: {
105
+ success: options.success,
106
+ ...(options.outcomeType ? { outcomeType: options.outcomeType } : {}),
107
+ ...(options.message ? { message: options.message } : {}),
108
+ ...(options.reason ? { reason: options.reason } : {}),
109
+ },
110
+ });
111
+ }
112
+ catch (error) {
113
+ info(`[start-session] failed to finalize local run ${runId}: ${formatUnknownError(error)}`);
114
+ }
115
+ }
116
+ async function completePreviousWorkflowSessionIfNeeded(session) {
117
+ if (!session.intentSessionId) {
118
+ return null;
119
+ }
120
+ const remoteCompletion = await completeWorkflowSessionRemote({
121
+ session,
122
+ stepId: undefined,
123
+ command: 'start-session',
124
+ terminalStatus: 'canceled',
125
+ runStatus: 'aborted',
126
+ summary: 'Previous workflow session canceled because a new start-session replaced it.',
127
+ outcomeType: 'workflow_session_canceled',
128
+ message: 'Previous workflow session canceled because a new start-session replaced it.',
129
+ reason: 'A new start-session command replaced the previous workflow session.',
130
+ allowMissingStep: true,
131
+ });
132
+ if (remoteCompletion.success) {
133
+ return null;
134
+ }
135
+ return {
136
+ success: false,
137
+ error: remoteCompletion.error === 'backend_session_complete_failed'
138
+ ? 'workflow_session_complete_failed'
139
+ : remoteCompletion.error,
140
+ outcomeType: remoteCompletion.error === 'backend_session_complete_failed' ? 'failed' : 'blocked',
141
+ message: 'Session start failed.',
142
+ reason: `Active workflow session cleanup blocked start-session: ${remoteCompletion.reason}`,
143
+ };
144
+ }
145
+ export async function startSession(requestedName, options = {}) {
146
+ const session = loadSession();
147
+ if (!session) {
148
+ return buildStartSessionFailure('Launch a browser first. No persisted browser session was found.');
149
+ }
150
+ const previousWorkflowCompletionFailure = await completePreviousWorkflowSessionIfNeeded(session);
151
+ if (previousWorkflowCompletionFailure) {
152
+ return previousWorkflowCompletionFailure;
153
+ }
154
+ const replacedPreviousRun = finalizePreviousRunBestEffort(session.activeRunId);
155
+ const nextSession = clearWorkflowState(session);
156
+ if (replacedPreviousRun ||
157
+ session.intentSessionId ||
158
+ session.currentRequestId ||
159
+ session.lastKnownStatus ||
160
+ typeof session.lastEventSeq === 'number' ||
161
+ session.transientSecretCache) {
162
+ saveSession(nextSession);
163
+ }
164
+ if (!(await isSessionAlive(session))) {
165
+ return buildStartSessionFailure('The persisted browser session is no longer running. Launch a fresh browser first.');
166
+ }
167
+ const currentPageRef = nextSession.runtime?.currentPageRef;
168
+ const currentPage = currentPageRef ? nextSession.runtime?.pages[currentPageRef] : undefined;
169
+ const sessionDisplayName = buildStartSessionDisplayName({
170
+ requestedName,
171
+ pageTitle: currentPage?.title,
172
+ });
173
+ const sessionDescription = sessionDisplayName ?? normalizeStartSessionName(currentPage?.url);
174
+ const merchantName = normalizeMerchantName(options.merchantName);
175
+ const run = startCliRun({
176
+ sessionId: nextSession.identity?.browserInstanceRef ?? `pid-${nextSession.pid}`,
177
+ entryCommand: 'start-session',
178
+ ...(sessionDisplayName ? { displayName: sessionDisplayName } : {}),
179
+ profile: nextSession.profile,
180
+ url: currentPage?.url,
181
+ });
182
+ const step = startRunStep({
183
+ runId: run.runId,
184
+ command: 'start-session',
185
+ input: {
186
+ hadPreviousRun: replacedPreviousRun,
187
+ ...(currentPageRef ? { pageRef: currentPageRef } : {}),
188
+ ...(currentPage?.url ? { url: currentPage.url } : {}),
189
+ ...(currentPage?.title ? { title: currentPage.title } : {}),
190
+ },
191
+ });
192
+ captureStepSnapshotBestEffort({
193
+ session: nextSession,
194
+ step,
195
+ phase: 'before',
196
+ pageRef: currentPageRef,
197
+ url: currentPage?.url,
198
+ title: currentPage?.title,
199
+ });
200
+ appendCommandLifecycleEventBestEffort({
201
+ step,
202
+ phase: 'started',
203
+ attributes: {
204
+ hadPreviousRun: replacedPreviousRun,
205
+ hasRuntime: Boolean(nextSession.runtime),
206
+ },
207
+ });
208
+ const traceId = run.traceContext.traceId;
209
+ const spanId = step?.otel.spanId;
210
+ if (!step || !spanId) {
211
+ finalizeRunRecordBestEffort(run.runId, {
212
+ status: 'failed',
213
+ success: false,
214
+ outcomeType: 'backend_session_start_failed',
215
+ message: 'Workflow session start failed.',
216
+ reason: 'Local step creation failed before backend session start.',
217
+ });
218
+ return {
219
+ success: false,
220
+ error: 'backend_session_start_failed',
221
+ outcomeType: 'failed',
222
+ message: 'Session start failed.',
223
+ reason: 'Local step creation failed before backend session start.',
224
+ };
225
+ }
226
+ try {
227
+ const remoteSession = await createRemoteSession({
228
+ browserSessionId: resolveBrowserSessionId(nextSession),
229
+ description: sessionDescription,
230
+ ...(merchantName ? { merchantName } : {}),
231
+ ...(currentPageRef || currentPage?.url || currentPage?.title
232
+ ? {
233
+ page: {
234
+ ...(currentPageRef ? { ref: currentPageRef } : {}),
235
+ ...(currentPage?.url ? { url: currentPage.url } : {}),
236
+ ...(currentPage?.title ? { title: currentPage.title } : {}),
237
+ },
238
+ }
239
+ : {}),
240
+ run: {
241
+ id: run.runId,
242
+ trace_id: traceId,
243
+ started_at: run.startedAt,
244
+ source: run.source,
245
+ status: run.status,
246
+ ...(run.profile ? { profile: run.profile } : {}),
247
+ ...(run.hostHints?.[0] ? { site_host: run.hostHints[0] } : {}),
248
+ protected_run: run.protectedRun,
249
+ },
250
+ step: {
251
+ id: step.stepId,
252
+ ordinal: step.ordinal,
253
+ command: step.command,
254
+ started_at: step.startedAt,
255
+ span_id: spanId,
256
+ ...(currentPageRef ? { page_ref: currentPageRef } : {}),
257
+ },
258
+ context: {
259
+ client: 'browse-cli',
260
+ },
261
+ metadata: {
262
+ had_previous_run: replacedPreviousRun,
263
+ },
264
+ telemetry: {
265
+ root_trace: buildRunRootOtlpTraceRequest(run.runId) ?? undefined,
266
+ step_trace: buildRunStepOtlpTraceRequest(run.runId, step.stepId) ?? undefined,
267
+ },
268
+ });
269
+ nextSession.activeRunId = run.runId;
270
+ nextSession.browserSessionId = resolveBrowserSessionId(nextSession);
271
+ nextSession.intentSessionId = remoteSession.session.id;
272
+ nextSession.currentRequestId = remoteSession.current_request?.id ?? undefined;
273
+ nextSession.lastKnownStatus = remoteSession.session.status;
274
+ nextSession.lastEventSeq = remoteSession.session.last_event_seq;
275
+ saveSession(nextSession);
276
+ captureStepSnapshotBestEffort({
277
+ session: nextSession,
278
+ step,
279
+ phase: 'after',
280
+ pageRef: currentPageRef,
281
+ url: currentPage?.url,
282
+ title: currentPage?.title,
283
+ });
284
+ appendCommandLifecycleEventBestEffort({
285
+ step,
286
+ phase: 'completed',
287
+ attributes: {
288
+ outcomeType: 'workflow_session_started',
289
+ intentSessionId: remoteSession.session.id,
290
+ remoteLastEventSeq: remoteSession.session.last_event_seq,
291
+ ...(currentPageRef ? { pageRef: currentPageRef } : {}),
292
+ },
293
+ });
294
+ finalizeStartSessionStepBestEffort(run.runId, step.stepId, {
295
+ success: true,
296
+ outcomeType: 'workflow_session_started',
297
+ message: 'Workflow session started.',
298
+ });
299
+ return {
300
+ success: true,
301
+ runId: run.runId,
302
+ startedAt: run.startedAt,
303
+ browserSessionId: resolveBrowserSessionId(nextSession),
304
+ intentSessionId: remoteSession.session.id,
305
+ lastEventSeq: remoteSession.session.last_event_seq,
306
+ status: remoteSession.session.status,
307
+ currentRequestId: remoteSession.current_request?.id ?? null,
308
+ replacedPreviousRun,
309
+ profile: nextSession.profile,
310
+ pageRef: currentPageRef,
311
+ url: currentPage?.url,
312
+ title: currentPage?.title,
313
+ };
314
+ }
315
+ catch (error) {
316
+ const reason = formatUnknownError(error);
317
+ appendCommandLifecycleEventBestEffort({
318
+ step,
319
+ phase: 'failed',
320
+ attributes: {
321
+ outcomeType: 'backend_session_start_failed',
322
+ reason,
323
+ },
324
+ });
325
+ finalizeStartSessionStepBestEffort(run.runId, step.stepId, {
326
+ success: false,
327
+ outcomeType: 'backend_session_start_failed',
328
+ message: 'Workflow session start failed.',
329
+ reason,
330
+ });
331
+ finalizeRunRecordBestEffort(run.runId, {
332
+ status: 'failed',
333
+ success: false,
334
+ outcomeType: 'backend_session_start_failed',
335
+ message: 'Workflow session start failed.',
336
+ reason,
337
+ });
338
+ saveSession(nextSession);
339
+ return {
340
+ success: false,
341
+ error: 'backend_session_start_failed',
342
+ outcomeType: 'failed',
343
+ message: 'Session start failed.',
344
+ reason,
345
+ };
346
+ }
347
+ }
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * browse status — Check browser state (alive, current URL, title).
3
3
  */
4
- export declare function status(): Promise<void>;
4
+ import type { BrowseResult } from '../output.js';
5
+ export declare function status(): Promise<BrowseResult>;
5
6
  //# sourceMappingURL=status.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmKH,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAiG5C"}
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA+LjD,wBAAsB,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,CAwFpD"}