@lobu/runtime-device 21.2.1 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component.json +1 -1
- package/dist/dependencies.bun.lock +91 -83
- package/npm-shrinkwrap.json +492 -438
- package/package.json +12 -2
- package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +5 -6
- package/vendor/cli/dist/commands/_lib/apply/client.d.ts +1 -0
- package/vendor/cli/dist/commands/_lib/apply/client.js +26 -7
- package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +9 -1
- package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +1 -0
- package/vendor/cli/dist/commands/_lib/apply/diff.js +46 -4
- package/vendor/cli/dist/commands/_lib/apply/map-config.js +18 -38
- package/vendor/cli/dist/commands/_lib/init-from-org/bootstrap.js +5 -17
- package/vendor/cli/dist/commands/init.d.ts +0 -2
- package/vendor/cli/dist/commands/init.js +0 -27
- package/vendor/cli/dist/commands/login.d.ts +17 -0
- package/vendor/cli/dist/commands/login.js +43 -17
- package/vendor/cli/dist/commands/memory/_lib/errors.d.ts +0 -8
- package/vendor/cli/dist/commands/memory/_lib/errors.js +0 -12
- package/vendor/cli/dist/commands/memory/_lib/mcp.js +6 -6
- package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +4 -10
- package/vendor/cli/dist/config/define.d.ts +21 -15
- package/vendor/cli/dist/config/define.js +2 -2
- package/vendor/cli/dist/connectors/README.md +7 -5
- package/vendor/cli/dist/connectors/_google/actions.ts +270 -0
- package/vendor/cli/dist/connectors/_google/discovery/calendar_v3.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/chat_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/docs_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/drive_v3.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/gmail_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/people_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/sheets_v4.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/tasks_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/youtube_v3.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery.ts +442 -0
- package/vendor/cli/dist/connectors/_google/errors.ts +91 -0
- package/vendor/cli/dist/connectors/_google/list-feed.ts +223 -0
- package/vendor/cli/dist/connectors/_google/policies.ts +127 -0
- package/vendor/cli/dist/connectors/agentid.ts +43 -0
- package/vendor/cli/dist/connectors/chat-user-identity.ts +2 -1
- package/vendor/cli/dist/connectors/github-automation-events.ts +9 -0
- package/vendor/cli/dist/connectors/github-identity.ts +28 -3
- package/vendor/cli/dist/connectors/github.ts +101 -59
- package/vendor/cli/dist/connectors/google_calendar.ts +207 -719
- package/vendor/cli/dist/connectors/google_drive.ts +16 -2
- package/vendor/cli/dist/connectors/google_gmail.ts +51 -33
- package/vendor/cli/dist/connectors/herdr.ts +406 -0
- package/vendor/cli/dist/connectors/jira.ts +6 -6
- package/vendor/cli/dist/connectors/linear.ts +7 -4
- package/vendor/cli/dist/connectors/postgres.ts +27 -2
- package/vendor/cli/dist/connectors/tiktok-inbox-page.js +230 -0
- package/vendor/cli/dist/connectors/tiktok-web-page.js +211 -0
- package/vendor/cli/dist/connectors/tiktok_web.ts +286 -0
- package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +228 -10
- package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +47 -14
- package/vendor/cli/dist/connectors/whatsapp-web-identity.ts +121 -0
- package/vendor/cli/dist/connectors/whatsapp_web.ts +170 -29
- package/vendor/cli/dist/connectors/x.ts +276 -136
- package/vendor/cli/dist/index.js +1 -37
- package/vendor/cli/dist/internal/context.d.ts +10 -0
- package/vendor/cli/dist/internal/context.js +26 -16
- package/vendor/cli/dist/internal/node-version.d.ts +1 -1
- package/vendor/cli/dist/internal/node-version.js +1 -1
- package/vendor/cli/dist/internal/oauth.d.ts +3 -1
- package/vendor/cli/dist/internal/oauth.js +4 -3
- package/vendor/cli/dist/internal/runtime-components.d.ts +9 -0
- package/vendor/cli/dist/internal/runtime-components.js +67 -2
- package/vendor/cli/dist/mac-auth.js +17 -1
- package/vendor/cli/dist/providers.json +1 -1
- package/vendor/cli/dist/runtime-components.json +4 -4
- package/vendor/cli/dist/templates/AGENTS.md.tmpl +11 -4
- package/vendor/cli/dist/templates/README.md.tmpl +1 -1
- package/vendor/cli/dist/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
- package/vendor/cli/dist/vendor/ora/index.d.ts +332 -0
- package/vendor/cli/dist/vendor/ora/index.js +424 -0
- package/vendor/cli/dist/vendor/ora/license +9 -0
- package/vendor/cli/dist/vendor/ora/package.json +64 -0
- package/vendor/cli/dist/vendor/ora/readme.md +329 -0
- package/vendor/cli/package.json +2 -2
- package/vendor/connector-sdk/dist/browser-requirement.d.ts +36 -0
- package/vendor/connector-sdk/dist/browser-requirement.js +60 -0
- package/vendor/connector-sdk/dist/connector-runtime.d.ts +3 -1
- package/vendor/connector-sdk/dist/connector-runtime.js +10 -0
- package/vendor/connector-sdk/dist/connector-types.d.ts +159 -45
- package/vendor/connector-sdk/dist/define-connector.d.ts +4 -2
- package/vendor/connector-sdk/dist/define-connector.js +3 -0
- package/vendor/connector-sdk/dist/index.d.ts +5 -2
- package/vendor/connector-sdk/dist/index.js +1 -0
- package/vendor/connector-sdk/dist/reaction-client-types.d.ts +16 -21
- package/vendor/connector-sdk/dist/reaction-client-types.typecheck.d.ts +5 -0
- package/vendor/connector-sdk/package.json +5 -1
- package/vendor/connector-worker/dist/agent-turn/guest-entry.js +31 -27
- package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +131 -185
- package/vendor/connector-worker/dist/agent-turn/memory.d.ts +3 -2
- package/vendor/connector-worker/dist/agent-turn/memory.js +3 -20
- package/vendor/connector-worker/dist/agent-turn/types.d.ts +3 -15
- package/vendor/connector-worker/dist/agent-turn/workspace.d.ts +2 -2
- package/vendor/connector-worker/dist/agent-turn/workspace.js +2 -4
- package/vendor/connector-worker/dist/daemon/action-monitor.d.ts +12 -0
- package/vendor/connector-worker/dist/daemon/action-monitor.js +25 -0
- package/vendor/connector-worker/dist/daemon/agent-turn.js +0 -9
- package/vendor/connector-worker/dist/daemon/builtins/index.d.ts +12 -0
- package/vendor/connector-worker/dist/daemon/builtins/index.js +61 -1
- package/vendor/connector-worker/dist/daemon/builtins/os-shell.d.ts +2 -1
- package/vendor/connector-worker/dist/daemon/builtins/os-shell.js +40 -27
- package/vendor/connector-worker/dist/daemon/client.d.ts +5 -1
- package/vendor/connector-worker/dist/daemon/client.js +3 -0
- package/vendor/connector-worker/dist/daemon/device-concurrency.d.ts +8 -0
- package/vendor/connector-worker/dist/daemon/device-concurrency.js +13 -0
- package/vendor/connector-worker/dist/daemon/executor.d.ts +1 -1
- package/vendor/connector-worker/dist/daemon/executor.js +48 -117
- package/vendor/connector-worker/dist/daemon/log.d.ts +2 -0
- package/vendor/connector-worker/dist/daemon/log.js +23 -2
- package/vendor/connector-worker/dist/daemon/mac-device-daemon.d.ts +20 -4
- package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +53 -13
- package/vendor/connector-worker/dist/daemon/native-bridge/client.d.ts +6 -0
- package/vendor/connector-worker/dist/daemon/native-bridge/client.js +15 -0
- package/vendor/connector-worker/dist/daemon/native-bridge/executor.js +2 -0
- package/vendor/connector-worker/dist/daemon/native-bridge/protocol.d.ts +1 -1
- package/vendor/connector-worker/dist/daemon/native-bridge/protocol.js +1 -0
- package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +3 -0
- package/vendor/connector-worker/dist/daemon/poll-loop.js +5 -1
- package/vendor/connector-worker/dist/daemon/start.d.ts +1 -0
- package/vendor/connector-worker/dist/daemon/start.js +12 -5
- package/vendor/connector-worker/dist/executor/interface.d.ts +34 -2
- package/vendor/connector-worker/dist/executor/isolate.js +66 -15
- package/vendor/connector-worker/dist/executor/redact.d.ts +1 -0
- package/vendor/connector-worker/dist/executor/redact.js +97 -26
- package/vendor/connector-worker/dist/executor/runtime.d.ts +7 -0
- package/vendor/connector-worker/dist/executor/runtime.js +26 -0
- package/vendor/connector-worker/dist/isolate/bridge.js +3 -1
- package/vendor/connector-worker/dist/mac-device-daemon.js +10 -3
- package/vendor/connector-worker/package.json +2 -2
- package/vendor/core/dist/agent-policy.js +1 -1
- package/vendor/core/dist/agent-store.d.ts +2 -0
- package/vendor/core/dist/agent-tooling.d.ts +1 -1
- package/vendor/core/dist/agent-tooling.js +1 -1
- package/vendor/core/dist/capabilities.js +2 -0
- package/vendor/core/dist/contracts/agent-settings.d.ts +0 -11
- package/vendor/core/dist/contracts/agent-settings.js +1 -7
- package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +93 -0
- package/vendor/core/dist/contracts/tools/collection-presentation.js +88 -0
- package/vendor/core/dist/contracts/tools/collection-selection.d.ts +47 -0
- package/vendor/core/dist/contracts/tools/collection-selection.js +74 -0
- package/vendor/core/dist/contracts/tools/manage-agents.d.ts +10 -4
- package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +1 -1
- package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +5 -1
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +19 -4
- package/vendor/core/dist/contracts/tools/manage-automations.js +25 -8
- package/vendor/core/dist/contracts/tools/manage-connections.d.ts +1 -0
- package/vendor/core/dist/contracts/tools/manage-connections.js +3 -0
- package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +11 -0
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +42 -3
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +181 -152
- package/vendor/core/dist/contracts/tools/manage-entity.js +118 -162
- package/vendor/core/dist/contracts/tools/manage-operations.d.ts +41 -3
- package/vendor/core/dist/contracts/tools/manage-operations.js +40 -2
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +182 -7
- package/vendor/core/dist/contracts/tools/manage-views.js +49 -13
- package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +11 -2
- package/vendor/core/dist/contracts/tools/read-knowledge.js +23 -3
- package/vendor/core/dist/contracts/tools/save-memory.d.ts +3 -6
- package/vendor/core/dist/contracts/tools/save-memory.js +2 -6
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +2 -1
- package/vendor/core/dist/contracts/tools/view-attach.js +7 -2
- package/vendor/core/dist/contracts/worker/protocol.d.ts +122 -28
- package/vendor/core/dist/contracts/worker/protocol.js +81 -17
- package/vendor/core/dist/index.d.ts +3 -4
- package/vendor/core/dist/index.js +3 -6
- package/vendor/core/dist/json-template.d.ts +6 -10
- package/vendor/core/dist/json-template.js +5 -9
- package/vendor/core/dist/logger.js +11 -5
- package/vendor/core/dist/shell-safety.d.ts +9 -0
- package/vendor/core/dist/shell-safety.js +154 -0
- package/vendor/core/dist/suggestions.d.ts +1 -1
- package/vendor/core/dist/suggestions.js +1 -1
- package/vendor/core/dist/tool-trace-summary.d.ts +1 -1
- package/vendor/core/dist/tool-trace-summary.js +1 -1
- package/vendor/core/dist/types.d.ts +1 -3
- package/vendor/core/dist/utils/diagnostic-scrubber.d.ts +7 -0
- package/vendor/core/dist/utils/{sentry-scrubber.js → diagnostic-scrubber.js} +25 -53
- package/vendor/core/dist/worker/auth.d.ts +44 -6
- package/vendor/core/dist/worker/auth.js +44 -11
- package/vendor/core/package.json +15 -6
- package/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
- package/vendor/ora/index.d.ts +332 -0
- package/vendor/ora/index.js +424 -0
- package/vendor/ora/license +9 -0
- package/vendor/ora/package.json +53 -0
- package/vendor/ora/readme.md +329 -0
- package/vendor/cli/dist/commands/telemetry.d.ts +0 -10
- package/vendor/cli/dist/commands/telemetry.js +0 -66
- package/vendor/core/dist/sentry.d.ts +0 -26
- package/vendor/core/dist/sentry.js +0 -133
- package/vendor/core/dist/tool-policy.d.ts +0 -74
- package/vendor/core/dist/tool-policy.js +0 -305
- package/vendor/core/dist/utils/sentry-scrubber.d.ts +0 -29
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
* Executes sync and action runs in a V8 isolate from compiled connector code.
|
|
5
5
|
* Generates embeddings and streams results.
|
|
6
6
|
*/
|
|
7
|
+
import { validateBrowserRequirement } from '@lobu/connector-sdk';
|
|
7
8
|
import { stableStringify } from '@lobu/core/contracts/tools/view-content-hash';
|
|
8
9
|
import { executeAutomationRun } from './automation.js';
|
|
9
|
-
import {
|
|
10
|
+
import { monitorActionRun } from './action-monitor.js';
|
|
11
|
+
import { executeDaemonBuiltinActionRun, hasDaemonBuiltin, hasDaemonBuiltinConnector, } from './builtins/index.js';
|
|
10
12
|
import { executeAgentTurnRun } from './agent-turn.js';
|
|
11
13
|
import { executeDeviceChatRun } from './device-chat.js';
|
|
12
14
|
import { attachedInteractiveSession, attachInteractiveSession } from './interactive-session.js';
|
|
13
15
|
import { log } from './log.js';
|
|
14
16
|
import { reportTerminalFailure } from './terminal-failure.js';
|
|
15
17
|
import { completeActionOnce } from './terminal-delivery.js';
|
|
18
|
+
import { envelopeToContentItem } from '../executor/runtime.js';
|
|
16
19
|
import { withoutDeploymentProviderKeys } from '../env.js';
|
|
17
20
|
export async function resolveJobCode(job) {
|
|
18
21
|
if (job.compiled_code)
|
|
@@ -77,7 +80,20 @@ async function resolveJobExecution(select, job, timeoutMs, customExecutor) {
|
|
|
77
80
|
return { ok: true, code: codeResult.code, executor: customExecutor };
|
|
78
81
|
}
|
|
79
82
|
try {
|
|
80
|
-
const executor = await select.selectExecutor({
|
|
83
|
+
const executor = await select.selectExecutor({
|
|
84
|
+
timeoutMs,
|
|
85
|
+
logSink: (level, line) => {
|
|
86
|
+
const context = { run_id: job.run_id, connector_key: job.connector_key, source: 'connector' };
|
|
87
|
+
if (level === 'error')
|
|
88
|
+
log.error(context, line);
|
|
89
|
+
else if (level === 'warn')
|
|
90
|
+
log.warn(context, line);
|
|
91
|
+
else if (level === 'debug')
|
|
92
|
+
log.debug(context, line);
|
|
93
|
+
else
|
|
94
|
+
log.info(context, line);
|
|
95
|
+
},
|
|
96
|
+
});
|
|
81
97
|
return { ok: true, code: codeResult.code, executor };
|
|
82
98
|
}
|
|
83
99
|
catch (err) {
|
|
@@ -176,7 +192,7 @@ export async function executeRun(client, job, workerEnv, config = {}) {
|
|
|
176
192
|
await reportTerminalFailure(client, job, message, 'error_message');
|
|
177
193
|
}
|
|
178
194
|
catch (error) {
|
|
179
|
-
log.
|
|
195
|
+
log.error('[executor] Failed to reject invalid daemon built-in run:', error);
|
|
180
196
|
}
|
|
181
197
|
return { itemsCollected: 0, error: message };
|
|
182
198
|
}
|
|
@@ -215,12 +231,12 @@ export async function executeRun(client, job, workerEnv, config = {}) {
|
|
|
215
231
|
}
|
|
216
232
|
catch (error) {
|
|
217
233
|
const message = error instanceof Error ? error.message : String(error);
|
|
218
|
-
log.
|
|
234
|
+
log.error(`[executor] Unhandled ${job.run_type ?? 'unknown'} run ${job.run_id} failure:`, error);
|
|
219
235
|
try {
|
|
220
236
|
await reportTerminalFailure(client, job, message);
|
|
221
237
|
}
|
|
222
238
|
catch (completeErr) {
|
|
223
|
-
log.
|
|
239
|
+
log.error('[executor] Terminal completion after unhandled failure errored:', completeErr);
|
|
224
240
|
}
|
|
225
241
|
return { itemsCollected: 0, error: message };
|
|
226
242
|
}
|
|
@@ -237,7 +253,7 @@ async function executeSyncRun(client, job, env, cfg) {
|
|
|
237
253
|
const execution = await resolveJobExecution(select, job, cfg.timeoutMs, cfg.executor);
|
|
238
254
|
if (!execution.ok) {
|
|
239
255
|
const errorMessage = `Run ${run_id} (${connector_key}): ${execution.error}`;
|
|
240
|
-
log.
|
|
256
|
+
log.error('[executor]', errorMessage);
|
|
241
257
|
await client.complete({
|
|
242
258
|
run_id,
|
|
243
259
|
worker_id: client.id,
|
|
@@ -282,6 +298,7 @@ async function executeSyncRun(client, job, env, cfg) {
|
|
|
282
298
|
executor: laneExecutor,
|
|
283
299
|
job: {
|
|
284
300
|
mode: 'sync',
|
|
301
|
+
browser: validatedBrowserGrant(job.browser_grant),
|
|
285
302
|
httpAuth: job.http_auth,
|
|
286
303
|
config: mergeEnv(env, job.connection_credentials, feedConfig),
|
|
287
304
|
checkpoint: checkpoint,
|
|
@@ -348,7 +365,7 @@ async function executeSyncRun(client, job, env, cfg) {
|
|
|
348
365
|
catch (error) {
|
|
349
366
|
stopHeartbeat();
|
|
350
367
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
351
|
-
log.
|
|
368
|
+
log.error(`[executor] Sync run ${run_id} failed:`, error);
|
|
352
369
|
const diag = extractExecutionDiagnostics(error);
|
|
353
370
|
await client.complete({
|
|
354
371
|
run_id,
|
|
@@ -412,7 +429,7 @@ async function executeActionRun(client, job, env, cfg) {
|
|
|
412
429
|
const execution = await resolveJobExecution(select, job, cfg.timeoutMs, cfg.executor);
|
|
413
430
|
if (!execution.ok) {
|
|
414
431
|
const errorMessage = `Action run ${run_id} (${connector_key}): ${execution.error}`;
|
|
415
|
-
log.
|
|
432
|
+
log.error('[executor]', errorMessage);
|
|
416
433
|
await completeActionOnce(client, {
|
|
417
434
|
run_id,
|
|
418
435
|
worker_id: client.id,
|
|
@@ -424,21 +441,7 @@ async function executeActionRun(client, job, env, cfg) {
|
|
|
424
441
|
const compiled_code = execution.code;
|
|
425
442
|
const laneExecutor = execution.executor;
|
|
426
443
|
log.info(`[executor] Starting action run ${run_id} (${connector_key}/${action_key})`);
|
|
427
|
-
|
|
428
|
-
// mid-action. Action runs can legitimately take minutes (LLM calls,
|
|
429
|
-
// long Playwright sessions, third-party API rate-limit waits); the
|
|
430
|
-
// reaper's default threshold is 120s, so a 30s heartbeat gives ~3
|
|
431
|
-
// ticks of grace. Without this the row sits "running" until the worker
|
|
432
|
-
// process dies, and the lane was previously excluded from the reaper
|
|
433
|
-
// (lobu#859) because the heartbeat was missing.
|
|
434
|
-
const heartbeatInterval = setInterval(async () => {
|
|
435
|
-
try {
|
|
436
|
-
await client.heartbeat(run_id);
|
|
437
|
-
}
|
|
438
|
-
catch (err) {
|
|
439
|
-
log.debug('[executor] Action heartbeat failed:', err);
|
|
440
|
-
}
|
|
441
|
-
}, cfg.heartbeatIntervalMs);
|
|
444
|
+
const monitor = monitorActionRun(client, run_id, cfg);
|
|
442
445
|
let terminalPayloadStarted = false;
|
|
443
446
|
try {
|
|
444
447
|
const result = await executeCompiledConnector({
|
|
@@ -446,6 +449,7 @@ async function executeActionRun(client, job, env, cfg) {
|
|
|
446
449
|
executor: laneExecutor,
|
|
447
450
|
job: {
|
|
448
451
|
mode: 'action',
|
|
452
|
+
browser: validatedBrowserGrant(job.browser_grant),
|
|
449
453
|
httpAuth: job.http_auth,
|
|
450
454
|
// NOTE: unlike the gateway's inline action path (manage_operations
|
|
451
455
|
// `executeLocalActionInline`, which merges the connection's own config
|
|
@@ -466,7 +470,13 @@ async function executeActionRun(client, job, env, cfg) {
|
|
|
466
470
|
credentials: credentials ?? null,
|
|
467
471
|
},
|
|
468
472
|
hooks: {
|
|
473
|
+
signal: monitor.signal,
|
|
469
474
|
...(job.http_auth ? { onHttpFetch: (request, signal) => client.httpFetch(run_id, request, signal) } : {}),
|
|
475
|
+
onOperationExecute: async (request) => {
|
|
476
|
+
if (!client.executeConnectorOperation)
|
|
477
|
+
throw new Error('Connector operations are not available on this host');
|
|
478
|
+
return client.executeConnectorOperation({ parent_run_id: run_id, worker_id: client.id, request }, monitor.signal);
|
|
479
|
+
},
|
|
470
480
|
onChromeDispatch: async (actionKey, actionInput) => {
|
|
471
481
|
return client.dispatchChromeAction({
|
|
472
482
|
parent_run_id: run_id,
|
|
@@ -481,6 +491,8 @@ async function executeActionRun(client, job, env, cfg) {
|
|
|
481
491
|
throw new Error(`Expected action result, got mode=${result.mode}`);
|
|
482
492
|
}
|
|
483
493
|
const actionOutput = result.output;
|
|
494
|
+
if (monitor.revoked())
|
|
495
|
+
return { itemsCollected: 0 };
|
|
484
496
|
terminalPayloadStarted = true;
|
|
485
497
|
await completeActionOnce(client, {
|
|
486
498
|
run_id,
|
|
@@ -493,8 +505,8 @@ async function executeActionRun(client, job, env, cfg) {
|
|
|
493
505
|
}
|
|
494
506
|
catch (error) {
|
|
495
507
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
496
|
-
log.
|
|
497
|
-
if (terminalPayloadStarted) {
|
|
508
|
+
log.error(`[executor] Action run ${run_id} failed:`, error);
|
|
509
|
+
if (terminalPayloadStarted || monitor.revoked()) {
|
|
498
510
|
return { itemsCollected: 0, error: errorMessage };
|
|
499
511
|
}
|
|
500
512
|
await completeActionOnce(client, {
|
|
@@ -506,67 +518,7 @@ async function executeActionRun(client, job, env, cfg) {
|
|
|
506
518
|
return { itemsCollected: 0, error: errorMessage };
|
|
507
519
|
}
|
|
508
520
|
finally {
|
|
509
|
-
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
async function executeDaemonBuiltinActionRun(client, job, cfg) {
|
|
513
|
-
const { run_id, connector_key, action_key, action_input } = job;
|
|
514
|
-
if (!run_id || !connector_key || !action_key) {
|
|
515
|
-
throw new Error('Invalid daemon built-in action: missing run_id, connector_key, or action_key');
|
|
516
|
-
}
|
|
517
|
-
if (job.compiled_code) {
|
|
518
|
-
const message = 'operation_backend_unavailable: a daemon built-in payload must not contain compiled_code';
|
|
519
|
-
await completeActionOnce(client, {
|
|
520
|
-
run_id,
|
|
521
|
-
worker_id: client.id,
|
|
522
|
-
status: 'failed',
|
|
523
|
-
error_message: message,
|
|
524
|
-
});
|
|
525
|
-
return { itemsCollected: 0, error: message };
|
|
526
|
-
}
|
|
527
|
-
const heartbeatInterval = setInterval(async () => {
|
|
528
|
-
try {
|
|
529
|
-
await client.heartbeat(run_id);
|
|
530
|
-
}
|
|
531
|
-
catch (error) {
|
|
532
|
-
log.debug('[executor] Daemon built-in heartbeat failed:', error);
|
|
533
|
-
}
|
|
534
|
-
}, cfg.heartbeatIntervalMs);
|
|
535
|
-
try {
|
|
536
|
-
const result = await executeDaemonBuiltin({
|
|
537
|
-
connectorKey: connector_key,
|
|
538
|
-
actionKey: action_key,
|
|
539
|
-
input: (action_input ?? {}),
|
|
540
|
-
shutdownSignal: cfg.shutdownSignal,
|
|
541
|
-
});
|
|
542
|
-
if (!result.ok) {
|
|
543
|
-
const message = `${result.code}: ${result.error}`;
|
|
544
|
-
await completeActionOnce(client, {
|
|
545
|
-
run_id,
|
|
546
|
-
worker_id: client.id,
|
|
547
|
-
status: 'failed',
|
|
548
|
-
error_message: message,
|
|
549
|
-
...(result.output ? { action_output: result.output } : {}),
|
|
550
|
-
});
|
|
551
|
-
return { itemsCollected: 0, error: message };
|
|
552
|
-
}
|
|
553
|
-
await completeActionOnce(client, {
|
|
554
|
-
run_id,
|
|
555
|
-
worker_id: client.id,
|
|
556
|
-
status: 'success',
|
|
557
|
-
action_output: result.output,
|
|
558
|
-
});
|
|
559
|
-
return { itemsCollected: 0 };
|
|
560
|
-
}
|
|
561
|
-
catch (error) {
|
|
562
|
-
// Delivery uncertainty is not an execution failure. The immutable payload
|
|
563
|
-
// was retried above; never send a contradictory terminal result here.
|
|
564
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
565
|
-
log.info(`[executor] Daemon built-in terminal delivery uncertain for ${run_id}:`, message);
|
|
566
|
-
return { itemsCollected: 0, error: message };
|
|
567
|
-
}
|
|
568
|
-
finally {
|
|
569
|
-
clearInterval(heartbeatInterval);
|
|
521
|
+
monitor.stop();
|
|
570
522
|
}
|
|
571
523
|
}
|
|
572
524
|
/**
|
|
@@ -585,7 +537,7 @@ async function executeAuthRun(client, job, env, cfg) {
|
|
|
585
537
|
const execution = await resolveJobExecution(select, job, 0, cfg.executor);
|
|
586
538
|
if (!execution.ok) {
|
|
587
539
|
const errorMessage = `Auth run ${run_id} (${connector_key}): ${execution.error}`;
|
|
588
|
-
log.
|
|
540
|
+
log.error('[executor]', errorMessage);
|
|
589
541
|
await client.completeAuth({
|
|
590
542
|
run_id,
|
|
591
543
|
worker_id: client.id,
|
|
@@ -670,7 +622,7 @@ async function executeAuthRun(client, job, env, cfg) {
|
|
|
670
622
|
catch (error) {
|
|
671
623
|
clearInterval(heartbeatInterval);
|
|
672
624
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
673
|
-
log.
|
|
625
|
+
log.error(`[executor] Auth run ${run_id} failed:`, error);
|
|
674
626
|
const diag = extractExecutionDiagnostics(error);
|
|
675
627
|
try {
|
|
676
628
|
await client.completeAuth({
|
|
@@ -818,7 +770,7 @@ async function executeEmbedBackfillRun(client, job, _env, cfg) {
|
|
|
818
770
|
}
|
|
819
771
|
catch (error) {
|
|
820
772
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
821
|
-
log.
|
|
773
|
+
log.error(`[executor] Embed backfill run ${run_id} failed:`, error);
|
|
822
774
|
await client.complete({
|
|
823
775
|
run_id,
|
|
824
776
|
worker_id: client.id,
|
|
@@ -844,33 +796,6 @@ function mergeEnv(env, connectionCredentials, feedConfig) {
|
|
|
844
796
|
...(feedConfig ?? {}),
|
|
845
797
|
};
|
|
846
798
|
}
|
|
847
|
-
/**
|
|
848
|
-
* Convert a V1 EventEnvelope (the SDK's standard sync output) into the
|
|
849
|
-
* gateway-bound ContentItem shape (without an embedding).
|
|
850
|
-
*/
|
|
851
|
-
function toContentItem(event) {
|
|
852
|
-
const occurredAtIso = event.occurred_at instanceof Date
|
|
853
|
-
? event.occurred_at.toISOString()
|
|
854
|
-
: event.occurred_at;
|
|
855
|
-
return {
|
|
856
|
-
id: event.origin_id,
|
|
857
|
-
title: event.title,
|
|
858
|
-
payload_type: event.payload_type,
|
|
859
|
-
payload_text: event.payload_text,
|
|
860
|
-
payload_data: event.payload_data,
|
|
861
|
-
payload_template: event.payload_template,
|
|
862
|
-
attachments: event.attachments,
|
|
863
|
-
author_name: event.author_name,
|
|
864
|
-
occurred_at: occurredAtIso,
|
|
865
|
-
source_url: event.source_url ?? undefined,
|
|
866
|
-
score: typeof event.score === 'number' ? event.score : 0,
|
|
867
|
-
metadata: event.metadata ?? {},
|
|
868
|
-
origin_parent_id: event.origin_parent_id ?? undefined,
|
|
869
|
-
origin_type: event.origin_type,
|
|
870
|
-
semantic_type: event.semantic_type ?? event.origin_type,
|
|
871
|
-
automation_signals: event.automation_signals,
|
|
872
|
-
};
|
|
873
|
-
}
|
|
874
799
|
/**
|
|
875
800
|
* Convert a chunk of events into ContentItems, generating embeddings for the
|
|
876
801
|
* whole chunk in a single batch call (one HTTP round-trip / vectorized local
|
|
@@ -880,7 +805,7 @@ function toContentItem(event) {
|
|
|
880
805
|
* semantics as the previous per-event path).
|
|
881
806
|
*/
|
|
882
807
|
async function processEventChunk(events, generateEmbeddings) {
|
|
883
|
-
const contentItems = events.map(
|
|
808
|
+
const contentItems = events.map(envelopeToContentItem);
|
|
884
809
|
if (!generateEmbeddings || contentItems.length === 0) {
|
|
885
810
|
return contentItems;
|
|
886
811
|
}
|
|
@@ -918,4 +843,10 @@ async function processEventChunk(events, generateEmbeddings) {
|
|
|
918
843
|
}
|
|
919
844
|
return contentItems;
|
|
920
845
|
}
|
|
846
|
+
function validatedBrowserGrant(value) {
|
|
847
|
+
if (value == null)
|
|
848
|
+
return undefined;
|
|
849
|
+
validateBrowserRequirement(value);
|
|
850
|
+
return value;
|
|
851
|
+
}
|
|
921
852
|
//# sourceMappingURL=executor.js.map
|
|
@@ -10,6 +10,8 @@ export declare function setDebug(enabled: boolean): void;
|
|
|
10
10
|
export declare const log: {
|
|
11
11
|
/** Always-on: one line per run, startup/shutdown, and hard failures. */
|
|
12
12
|
info: (...parts: unknown[]) => void;
|
|
13
|
+
warn: (...parts: unknown[]) => void;
|
|
14
|
+
error: (...parts: unknown[]) => void;
|
|
13
15
|
/** Debug-only: poll chatter, heartbeats, retry and backoff detail. */
|
|
14
16
|
debug: (...parts: unknown[]) => void;
|
|
15
17
|
};
|
|
@@ -6,19 +6,40 @@
|
|
|
6
6
|
* the run's start and its terminal result — plus startup/shutdown and hard
|
|
7
7
|
* failures. Pass `--debug` to enable the poll/heartbeat/retry chatter.
|
|
8
8
|
*/
|
|
9
|
+
import { scrubDiagnosticValue } from '@lobu/core';
|
|
9
10
|
let debugEnabled = false;
|
|
11
|
+
function write(level, parts) {
|
|
12
|
+
let line;
|
|
13
|
+
try {
|
|
14
|
+
const record = scrubDiagnosticValue({
|
|
15
|
+
timestamp: new Date().toISOString(), level, service: 'lobu-worker',
|
|
16
|
+
release: process.env.APP_GIT_SHA,
|
|
17
|
+
message: parts.filter((part) => typeof part === 'string').join(' '),
|
|
18
|
+
data: parts.filter((part) => typeof part !== 'string'),
|
|
19
|
+
});
|
|
20
|
+
line = JSON.stringify(record, (_key, value) => typeof value === 'bigint' ? String(value) : value);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// A diagnostic must not prevent a run from reporting its terminal state.
|
|
24
|
+
line = JSON.stringify({ level, service: 'lobu-worker', message: 'Log record could not be serialized safely' });
|
|
25
|
+
}
|
|
26
|
+
// stderr is intentional: stdout belongs to the CLI's machine protocol.
|
|
27
|
+
console.error(line);
|
|
28
|
+
}
|
|
10
29
|
export function setDebug(enabled) {
|
|
11
30
|
debugEnabled = enabled;
|
|
12
31
|
}
|
|
13
32
|
export const log = {
|
|
14
33
|
/** Always-on: one line per run, startup/shutdown, and hard failures. */
|
|
15
34
|
info: (...parts) => {
|
|
16
|
-
|
|
35
|
+
write('info', parts);
|
|
17
36
|
},
|
|
37
|
+
warn: (...parts) => write('warn', parts),
|
|
38
|
+
error: (...parts) => write('error', parts),
|
|
18
39
|
/** Debug-only: poll chatter, heartbeats, retry and backoff detail. */
|
|
19
40
|
debug: (...parts) => {
|
|
20
41
|
if (debugEnabled)
|
|
21
|
-
|
|
42
|
+
write('debug', parts);
|
|
22
43
|
},
|
|
23
44
|
};
|
|
24
45
|
//# sourceMappingURL=log.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type AgentKind } from '@lobu/core/contracts/worker/device-automation';
|
|
2
2
|
import type { PollResponse } from '@lobu/core/contracts/worker/protocol';
|
|
3
|
-
import { MutableWorkerAdvertisementProvider } from './client.js';
|
|
3
|
+
import { MutableWorkerAdvertisementProvider, WorkerClient } from './client.js';
|
|
4
4
|
import { WorkerPollLoop } from './poll-loop.js';
|
|
5
5
|
import { NativeBridgeClient } from './native-bridge/client.js';
|
|
6
6
|
import { NATIVE_BRIDGE_PROTOCOL } from './native-bridge/protocol.js';
|
|
@@ -25,6 +25,12 @@ export interface MacDeviceDaemonMetadata {
|
|
|
25
25
|
platform: typeof MAC_DEVICE_PLATFORM;
|
|
26
26
|
artifact: 'standalone-bun-macho-arm64';
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* EX_NOPERM: the server rejected the device credential (401/403). The app
|
|
30
|
+
* must resolve authorization instead of restarting with the same key.
|
|
31
|
+
*/
|
|
32
|
+
export declare const MAC_DAEMON_CREDENTIAL_REJECTED_EXIT = 77;
|
|
33
|
+
export declare function macDeviceDaemonExitCode(error: unknown): number;
|
|
28
34
|
export declare function macDeviceDaemonMetadata(version: string): MacDeviceDaemonMetadata;
|
|
29
35
|
/**
|
|
30
36
|
* Argv for re-entering this daemon's own entrypoint. A compiled artifact is its
|
|
@@ -34,9 +40,9 @@ export declare function macDeviceDaemonMetadata(version: string): MacDeviceDaemo
|
|
|
34
40
|
export declare function packagedDaemonArgs(...args: string[]): string[];
|
|
35
41
|
export declare function selectMacDeviceDaemonAgentKind(runnableAgentKinds: readonly AgentKind[], explicitAgentKind?: AgentKind): AgentKind | undefined;
|
|
36
42
|
export declare function createMacDeviceDaemonShutdown(controller: AbortController, loop: WorkerPollLoop, bridge?: NativeBridgeClient, shutdownTimeoutMs?: number): () => Promise<void>;
|
|
37
|
-
export declare function validateMacDeviceDaemonOptions(options: MacDeviceDaemonOptions): Required<Pick<MacDeviceDaemonOptions, 'apiUrl' | 'workerId' | 'workerApiToken'>> & Omit<MacDeviceDaemonOptions, 'apiUrl' | 'workerId' | 'workerApiToken'>;
|
|
43
|
+
export declare function validateMacDeviceDaemonOptions(options: MacDeviceDaemonOptions, hostThreads?: number): Required<Pick<MacDeviceDaemonOptions, 'apiUrl' | 'workerId' | 'workerApiToken'>> & Omit<MacDeviceDaemonOptions, 'apiUrl' | 'workerId' | 'workerApiToken'>;
|
|
38
44
|
/**
|
|
39
|
-
* Whether the
|
|
45
|
+
* Whether the app advertised a local implementation of this run's connector.
|
|
40
46
|
*
|
|
41
47
|
* The daemon answers from the inventory the Mac app itself declared over the
|
|
42
48
|
* bridge — the same manifests it advertises to the gateway — so what it will
|
|
@@ -46,10 +52,20 @@ export declare function validateMacDeviceDaemonOptions(options: MacDeviceDaemonO
|
|
|
46
52
|
* the contract's identity; a contract carrying its implementation cannot be
|
|
47
53
|
* shared with a second endpoint.
|
|
48
54
|
*
|
|
49
|
-
* A payload carrying `compiled_code` is not
|
|
55
|
+
* A payload carrying `compiled_code` is not local connector work: the
|
|
50
56
|
* gateway ships code only for connectors the device does NOT implement.
|
|
51
57
|
*/
|
|
52
58
|
export declare function bridgeImplementsRun(job: PollResponse, advertisementProvider: MutableWorkerAdvertisementProvider | undefined): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Run a connector claim the app advertised. A daemon built-in (os.shell) runs
|
|
61
|
+
* here, with the built-in owning timeout, cancellation and process reaping.
|
|
62
|
+
* Everything else is native app work over the bridge.
|
|
63
|
+
*/
|
|
64
|
+
export declare function executeAdvertisedConnectorRun(client: WorkerClient, job: PollResponse, dependencies: {
|
|
65
|
+
advertisementProvider: MutableWorkerAdvertisementProvider | undefined;
|
|
66
|
+
bridge: NativeBridgeClient | undefined;
|
|
67
|
+
shutdownSignal?: AbortSignal;
|
|
68
|
+
}): Promise<unknown>;
|
|
53
69
|
export declare function createMacDeviceDaemon(options: MacDeviceDaemonOptions, dependencies?: {
|
|
54
70
|
advertisementProvider?: MutableWorkerAdvertisementProvider;
|
|
55
71
|
bridge?: NativeBridgeClient;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { hostname } from 'node:os';
|
|
2
2
|
import { AGENT_KINDS, } from '@lobu/core/contracts/worker/device-automation';
|
|
3
3
|
import { executeAutomationRun } from './automation.js';
|
|
4
|
+
import { executeDaemonBuiltinActionRun, hasDaemonBuiltin } from './builtins/index.js';
|
|
5
|
+
import { defaultDeviceMaxConcurrentJobs } from './device-concurrency.js';
|
|
4
6
|
import { executeDeviceChatRun } from './device-chat.js';
|
|
5
7
|
import { locateBinary, resolveRunnableAgentKinds, supportsOpenCodeAcp, } from './agent-binaries.js';
|
|
6
|
-
import { MutableWorkerAdvertisementProvider, WorkerClient, } from './client.js';
|
|
8
|
+
import { MutableWorkerAdvertisementProvider, WorkerClient, WorkerHttpError, } from './client.js';
|
|
7
9
|
import { installWorkerPollLoopSignals, WorkerPollLoop } from './poll-loop.js';
|
|
8
10
|
import { setDebug } from './log.js';
|
|
9
11
|
import { NativeBridgeClient } from './native-bridge/client.js';
|
|
@@ -18,9 +20,18 @@ const DEFAULT_POLL_INTERVAL_MS = 10000;
|
|
|
18
20
|
// Mac daemon's claim latency well below that even when the server returns its
|
|
19
21
|
// normal ten-second idle hint.
|
|
20
22
|
const SOURCE_READ_IDLE_DELAY_CEILING_MS = 1000;
|
|
21
|
-
const DEFAULT_MAX_CONCURRENT_JOBS = 1;
|
|
22
23
|
const NATIVE_BRIDGE_SHUTDOWN_TIMEOUT_MS = 5000;
|
|
23
24
|
export const INTERNAL_ACP_ADAPTER_ARG = '--internal-acp-adapter';
|
|
25
|
+
/**
|
|
26
|
+
* EX_NOPERM: the server rejected the device credential (401/403). The app
|
|
27
|
+
* must resolve authorization instead of restarting with the same key.
|
|
28
|
+
*/
|
|
29
|
+
export const MAC_DAEMON_CREDENTIAL_REJECTED_EXIT = 77;
|
|
30
|
+
export function macDeviceDaemonExitCode(error) {
|
|
31
|
+
return error instanceof WorkerHttpError && (error.status === 401 || error.status === 403)
|
|
32
|
+
? MAC_DAEMON_CREDENTIAL_REJECTED_EXIT
|
|
33
|
+
: 1;
|
|
34
|
+
}
|
|
24
35
|
export function macDeviceDaemonMetadata(version) {
|
|
25
36
|
return {
|
|
26
37
|
name: 'lobu-device-daemon',
|
|
@@ -107,7 +118,7 @@ function withTimeout(promise, timeoutMs, label) {
|
|
|
107
118
|
});
|
|
108
119
|
});
|
|
109
120
|
}
|
|
110
|
-
export function validateMacDeviceDaemonOptions(options) {
|
|
121
|
+
export function validateMacDeviceDaemonOptions(options, hostThreads) {
|
|
111
122
|
const workerId = options.workerId?.trim() || defaultWorkerId();
|
|
112
123
|
if (!WORKER_ID_PATTERN.test(workerId)) {
|
|
113
124
|
throw new Error(`invalid --worker-id '${workerId}': expected 1-128 characters of letters, digits, dot, underscore, colon or hyphen`);
|
|
@@ -151,7 +162,7 @@ export function validateMacDeviceDaemonOptions(options) {
|
|
|
151
162
|
workerId,
|
|
152
163
|
workerApiToken,
|
|
153
164
|
pollIntervalMs: pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS,
|
|
154
|
-
maxConcurrentJobs: maxConcurrentJobs ??
|
|
165
|
+
maxConcurrentJobs: maxConcurrentJobs ?? defaultDeviceMaxConcurrentJobs(hostThreads),
|
|
155
166
|
...(defaultAgentKind ? { defaultAgentKind } : {}),
|
|
156
167
|
};
|
|
157
168
|
}
|
|
@@ -164,7 +175,7 @@ async function rejectUnadvertisedConnector(client, job) {
|
|
|
164
175
|
await reportTerminalFailure(client, job, message, 'error_message');
|
|
165
176
|
}
|
|
166
177
|
/**
|
|
167
|
-
* Whether the
|
|
178
|
+
* Whether the app advertised a local implementation of this run's connector.
|
|
168
179
|
*
|
|
169
180
|
* The daemon answers from the inventory the Mac app itself declared over the
|
|
170
181
|
* bridge — the same manifests it advertises to the gateway — so what it will
|
|
@@ -174,7 +185,7 @@ async function rejectUnadvertisedConnector(client, job) {
|
|
|
174
185
|
* the contract's identity; a contract carrying its implementation cannot be
|
|
175
186
|
* shared with a second endpoint.
|
|
176
187
|
*
|
|
177
|
-
* A payload carrying `compiled_code` is not
|
|
188
|
+
* A payload carrying `compiled_code` is not local connector work: the
|
|
178
189
|
* gateway ships code only for connectors the device does NOT implement.
|
|
179
190
|
*/
|
|
180
191
|
export function bridgeImplementsRun(job, advertisementProvider) {
|
|
@@ -185,6 +196,29 @@ export function bridgeImplementsRun(job, advertisementProvider) {
|
|
|
185
196
|
manifest !== null &&
|
|
186
197
|
manifest.key === job.connector_key);
|
|
187
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Run a connector claim the app advertised. A daemon built-in (os.shell) runs
|
|
201
|
+
* here, with the built-in owning timeout, cancellation and process reaping.
|
|
202
|
+
* Everything else is native app work over the bridge.
|
|
203
|
+
*/
|
|
204
|
+
export async function executeAdvertisedConnectorRun(client, job, dependencies) {
|
|
205
|
+
if (!bridgeImplementsRun(job, dependencies.advertisementProvider)) {
|
|
206
|
+
return rejectUnadvertisedConnector(client, job);
|
|
207
|
+
}
|
|
208
|
+
if (job.run_type === 'action' &&
|
|
209
|
+
job.connector_key &&
|
|
210
|
+
job.action_key &&
|
|
211
|
+
hasDaemonBuiltin(job.connector_key, job.action_key)) {
|
|
212
|
+
return executeDaemonBuiltinActionRun(client, job, {
|
|
213
|
+
heartbeatIntervalMs: 30000,
|
|
214
|
+
...(dependencies.shutdownSignal ? { shutdownSignal: dependencies.shutdownSignal } : {}),
|
|
215
|
+
platform: 'macos',
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
if (!dependencies.bridge)
|
|
219
|
+
return rejectUnsupportedRun(client, job);
|
|
220
|
+
return executeNativeBridgeRun(client, dependencies.bridge, job);
|
|
221
|
+
}
|
|
188
222
|
export function createMacDeviceDaemon(options, dependencies = {}) {
|
|
189
223
|
const validated = validateMacDeviceDaemonOptions(options);
|
|
190
224
|
if (validated.noPoll)
|
|
@@ -271,6 +305,14 @@ export function createMacDeviceDaemon(options, dependencies = {}) {
|
|
|
271
305
|
pollIntervalMs: validated.pollIntervalMs,
|
|
272
306
|
maxIdleDelayMs: SOURCE_READ_IDLE_DELAY_CEILING_MS,
|
|
273
307
|
maxConcurrentJobs: validated.maxConcurrentJobs,
|
|
308
|
+
...(nativeBridge
|
|
309
|
+
? {
|
|
310
|
+
onActiveJobsChange: (activeJobs) => {
|
|
311
|
+
nativeBridge.reportActivity(activeJobs).catch(() => { });
|
|
312
|
+
},
|
|
313
|
+
}
|
|
314
|
+
: {}),
|
|
315
|
+
failClosedOnPollAuthError: true,
|
|
274
316
|
execute: async (job) => {
|
|
275
317
|
if (job.run_type === 'automation') {
|
|
276
318
|
return executeAutomationRun(client, job, automationConfig);
|
|
@@ -279,13 +321,11 @@ export function createMacDeviceDaemon(options, dependencies = {}) {
|
|
|
279
321
|
return executeDeviceChatRun(client, job, automationConfig);
|
|
280
322
|
}
|
|
281
323
|
if (job.run_type === 'sync' || job.run_type === 'action' || job.run_type === 'auth') {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
return executeNativeBridgeRun(client, nativeBridge, job);
|
|
324
|
+
return executeAdvertisedConnectorRun(client, job, {
|
|
325
|
+
advertisementProvider: dependencies.advertisementProvider,
|
|
326
|
+
bridge: nativeBridge,
|
|
327
|
+
shutdownSignal: shutdownController.signal,
|
|
328
|
+
});
|
|
289
329
|
}
|
|
290
330
|
return rejectUnsupportedRun(client, job);
|
|
291
331
|
},
|
|
@@ -37,6 +37,12 @@ export declare class NativeBridgeClient {
|
|
|
37
37
|
cancel(requestId: string, runId: number): Promise<void>;
|
|
38
38
|
cancelAndAbandon(requestId: string, runId: number, error: Error): Promise<void>;
|
|
39
39
|
cancelActiveRuns(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Tell the app how many runs this daemon is executing. The app holds staged
|
|
42
|
+
* updates while any are live: work the daemon runs itself (shell commands,
|
|
43
|
+
* Automations, chat) never passes through the app's own run table.
|
|
44
|
+
*/
|
|
45
|
+
reportActivity(activeRuns: number): Promise<void>;
|
|
40
46
|
shutdown(): Promise<void>;
|
|
41
47
|
close(error?: NativeBridgeProtocolError): void;
|
|
42
48
|
onTransportFailure(handler: (error: Error) => void): () => void;
|
|
@@ -144,6 +144,21 @@ export class NativeBridgeClient {
|
|
|
144
144
|
const cancellations = [...this.pending.values()].map((pending) => this.cancel(pending.requestId, pending.runId));
|
|
145
145
|
await Promise.allSettled(cancellations);
|
|
146
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Tell the app how many runs this daemon is executing. The app holds staged
|
|
149
|
+
* updates while any are live: work the daemon runs itself (shell commands,
|
|
150
|
+
* Automations, chat) never passes through the app's own run table.
|
|
151
|
+
*/
|
|
152
|
+
async reportActivity(activeRuns) {
|
|
153
|
+
if (!this.handshakeComplete || this.failure)
|
|
154
|
+
return;
|
|
155
|
+
await this.send({
|
|
156
|
+
version: NATIVE_BRIDGE_PROTOCOL_VERSION,
|
|
157
|
+
kind: 'activity',
|
|
158
|
+
request_id: randomUUID(),
|
|
159
|
+
payload: { active_runs: activeRuns },
|
|
160
|
+
});
|
|
161
|
+
}
|
|
147
162
|
async shutdown() {
|
|
148
163
|
if (!this.handshakeComplete || this.failure)
|
|
149
164
|
return;
|
|
@@ -184,6 +184,8 @@ function bridgeJob(job) {
|
|
|
184
184
|
connector_key: job.connector_key,
|
|
185
185
|
connector_version: job.connector_version,
|
|
186
186
|
connector_manifest_hash: job.connector_manifest_hash,
|
|
187
|
+
source_attribution: job.source_attribution,
|
|
188
|
+
source_url: job.source_url,
|
|
187
189
|
feed_key: job.feed_key,
|
|
188
190
|
feed_id: job.feed_id,
|
|
189
191
|
config: job.config ?? {},
|
|
@@ -6,7 +6,7 @@ export declare const NATIVE_BRIDGE_MAX_INBOUND_FRAMES = 128;
|
|
|
6
6
|
export declare const NATIVE_BRIDGE_MAX_OUTBOUND_FRAMES = 128;
|
|
7
7
|
export declare const NATIVE_BRIDGE_MAX_OUTBOUND_FRAMES_PER_RUN = 32;
|
|
8
8
|
export declare const NATIVE_BRIDGE_MAX_RETAINED_RUN_KEYS = 128;
|
|
9
|
-
export declare const NATIVE_BRIDGE_KINDS: readonly ["hello", "hello_ack", "run", "cancel", "shutdown", "ping", "stream", "complete", "failed", "capabilities", "diagnostic"];
|
|
9
|
+
export declare const NATIVE_BRIDGE_KINDS: readonly ["hello", "hello_ack", "run", "cancel", "shutdown", "ping", "stream", "complete", "failed", "capabilities", "diagnostic", "activity"];
|
|
10
10
|
export type NativeBridgeKind = (typeof NATIVE_BRIDGE_KINDS)[number];
|
|
11
11
|
export interface NativeBridgeFrame {
|
|
12
12
|
version: number;
|
|
@@ -20,6 +20,8 @@ export interface WorkerPollLoopOptions {
|
|
|
20
20
|
beforeIdlePoll?: () => Promise<void>;
|
|
21
21
|
/** Persisted device credentials treat poll-time revocation as terminal. */
|
|
22
22
|
failClosedOnPollAuthError?: boolean;
|
|
23
|
+
/** Called with the new count each time a run starts or finishes. */
|
|
24
|
+
onActiveJobsChange?: (activeJobs: number) => void;
|
|
23
25
|
}
|
|
24
26
|
export type WorkerPollLoopExit = (code: number) => void;
|
|
25
27
|
export interface WorkerPollLoopSignalOptions {
|
|
@@ -35,6 +37,7 @@ export declare class WorkerPollLoop {
|
|
|
35
37
|
private readonly execute;
|
|
36
38
|
private readonly beforeIdlePoll?;
|
|
37
39
|
private readonly failClosedOnPollAuthError;
|
|
40
|
+
private readonly onActiveJobsChange?;
|
|
38
41
|
private running;
|
|
39
42
|
private admittingJobs;
|
|
40
43
|
private activeJobs;
|