@lobu/runtime-device 22.0.0 → 23.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.
Files changed (77) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +3 -3
  3. package/npm-shrinkwrap.json +15 -15
  4. package/package.json +1 -1
  5. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +1 -1
  6. package/vendor/cli/dist/connectors/README.md +14 -1
  7. package/vendor/cli/dist/connectors/google_gmail.ts +1 -0
  8. package/vendor/cli/dist/connectors/jira-helpers.ts +313 -0
  9. package/vendor/cli/dist/connectors/jira.ts +29 -221
  10. package/vendor/cli/dist/connectors/linkedin-browser-script.ts +13 -0
  11. package/vendor/cli/dist/connectors/linkedin-draft-page.js +104 -0
  12. package/vendor/cli/dist/connectors/linkedin-drafts.ts +73 -0
  13. package/vendor/cli/dist/connectors/linkedin-identity.ts +32 -0
  14. package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +1185 -0
  15. package/vendor/cli/dist/connectors/linkedin-inbox.ts +156 -0
  16. package/vendor/cli/dist/connectors/linkedin-like.ts +114 -0
  17. package/vendor/cli/dist/connectors/linkedin-takeout.ts +577 -0
  18. package/vendor/cli/dist/connectors/linkedin.ts +3998 -0
  19. package/vendor/cli/dist/connectors/takeout-utils.ts +240 -0
  20. package/vendor/cli/dist/connectors/tiktok-inbox-page.js +9 -9
  21. package/vendor/cli/dist/connectors/tiktok-web-page.js +21 -15
  22. package/vendor/cli/dist/connectors/tiktok_web.ts +63 -30
  23. package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +64 -564
  24. package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +30 -444
  25. package/vendor/cli/dist/connectors/whatsapp-web-identity.ts +20 -6
  26. package/vendor/cli/dist/connectors/whatsapp_web.ts +45 -645
  27. package/vendor/cli/dist/connectors/x-dm-adapter.js +556 -0
  28. package/vendor/cli/dist/connectors/x-identity.ts +31 -2
  29. package/vendor/cli/dist/connectors/x.ts +266 -120
  30. package/vendor/cli/dist/runtime-components.json +4 -4
  31. package/vendor/cli/dist/templates/AGENTS.md.tmpl +2 -2
  32. package/vendor/cli/package.json +1 -1
  33. package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
  34. package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
  35. package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
  36. package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
  37. package/vendor/connector-sdk/dist/connector-types.d.ts +10 -0
  38. package/vendor/connector-sdk/dist/index.d.ts +3 -0
  39. package/vendor/connector-sdk/dist/index.js +2 -0
  40. package/vendor/connector-sdk/package.json +9 -1
  41. package/vendor/connector-worker/dist/agent-turn/guest-entry.js +15 -6
  42. package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +288 -148
  43. package/vendor/connector-worker/dist/daemon/automation.d.ts +4 -11
  44. package/vendor/connector-worker/dist/daemon/automation.js +6 -6
  45. package/vendor/connector-worker/dist/daemon/client.d.ts +2 -4
  46. package/vendor/connector-worker/dist/daemon/client.js +0 -3
  47. package/vendor/connector-worker/dist/daemon/executor.js +0 -3
  48. package/vendor/connector-worker/dist/daemon/mac-device-daemon.d.ts +4 -3
  49. package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +4 -10
  50. package/vendor/connector-worker/dist/daemon/native-bridge/executor.js +27 -25
  51. package/vendor/connector-worker/dist/daemon/start.js +3 -15
  52. package/vendor/connector-worker/dist/daemon/terminal-failure.js +0 -11
  53. package/vendor/connector-worker/dist/daemon/worker-id.d.ts +17 -0
  54. package/vendor/connector-worker/dist/daemon/worker-id.js +22 -0
  55. package/vendor/connector-worker/dist/mac-device-daemon.js +14 -26
  56. package/vendor/connector-worker/package.json +1 -1
  57. package/vendor/core/dist/capabilities.d.ts +1 -1
  58. package/vendor/core/dist/capabilities.js +0 -1
  59. package/vendor/core/dist/connector-query-errors.d.ts +32 -0
  60. package/vendor/core/dist/connector-query-errors.js +41 -1
  61. package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
  62. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
  63. package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
  64. package/vendor/core/dist/contracts/worker/protocol.d.ts +8 -131
  65. package/vendor/core/dist/contracts/worker/protocol.js +9 -61
  66. package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
  67. package/vendor/core/dist/device-pin-tombstones.js +57 -0
  68. package/vendor/core/dist/index.d.ts +2 -1
  69. package/vendor/core/dist/index.js +1 -0
  70. package/vendor/core/dist/logger.js +10 -25
  71. package/vendor/core/dist/utils/diagnostic-scrubber.js +258 -21
  72. package/vendor/core/dist/worker/wire.d.ts +0 -10
  73. package/vendor/core/package.json +6 -6
  74. package/vendor/connector-worker/dist/daemon/device-chat.d.ts +0 -9
  75. package/vendor/connector-worker/dist/daemon/device-chat.js +0 -61
  76. package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
  77. package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
@@ -10,7 +10,6 @@ import { executeAutomationRun } from './automation.js';
10
10
  import { monitorActionRun } from './action-monitor.js';
11
11
  import { executeDaemonBuiltinActionRun, hasDaemonBuiltin, hasDaemonBuiltinConnector, } from './builtins/index.js';
12
12
  import { executeAgentTurnRun } from './agent-turn.js';
13
- import { executeDeviceChatRun } from './device-chat.js';
14
13
  import { attachedInteractiveSession, attachInteractiveSession } from './interactive-session.js';
15
14
  import { log } from './log.js';
16
15
  import { reportTerminalFailure } from './terminal-failure.js';
@@ -217,8 +216,6 @@ export async function executeRun(client, job, workerEnv, config = {}) {
217
216
  // unreachable for them — but if a run does slip through (deploy skew), the
218
217
  // dispatcher reports the failure rather than stomping the run.
219
218
  return await executeAutomationRun(client, job, cfg);
220
- case 'chat_message':
221
- return await executeDeviceChatRun(client, job, cfg);
222
219
  case 'agent_turn':
223
220
  return await executeAgentTurnRun(client, job, env, cfg);
224
221
  case 'embed_backfill':
@@ -5,6 +5,7 @@ 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';
7
7
  export declare const MAC_DEVICE_PLATFORM = "macos";
8
+ export type ValidatedMacDeviceDaemonOptions = Required<Pick<MacDeviceDaemonOptions, 'apiUrl' | 'workerId' | 'workerApiToken'>> & Omit<MacDeviceDaemonOptions, 'apiUrl' | 'workerId' | 'workerApiToken'>;
8
9
  export declare const INTERNAL_ACP_ADAPTER_ARG = "--internal-acp-adapter";
9
10
  export interface MacDeviceDaemonOptions {
10
11
  apiUrl?: string;
@@ -40,7 +41,7 @@ export declare function macDeviceDaemonMetadata(version: string): MacDeviceDaemo
40
41
  export declare function packagedDaemonArgs(...args: string[]): string[];
41
42
  export declare function selectMacDeviceDaemonAgentKind(runnableAgentKinds: readonly AgentKind[], explicitAgentKind?: AgentKind): AgentKind | undefined;
42
43
  export declare function createMacDeviceDaemonShutdown(controller: AbortController, loop: WorkerPollLoop, bridge?: NativeBridgeClient, shutdownTimeoutMs?: number): () => Promise<void>;
43
- export declare function validateMacDeviceDaemonOptions(options: MacDeviceDaemonOptions, hostThreads?: number): Required<Pick<MacDeviceDaemonOptions, 'apiUrl' | 'workerId' | 'workerApiToken'>> & Omit<MacDeviceDaemonOptions, 'apiUrl' | 'workerId' | 'workerApiToken'>;
44
+ export declare function validateMacDeviceDaemonOptions(options: MacDeviceDaemonOptions, hostThreads?: number): ValidatedMacDeviceDaemonOptions;
44
45
  /**
45
46
  * Whether the app advertised a local implementation of this run's connector.
46
47
  *
@@ -66,10 +67,10 @@ export declare function executeAdvertisedConnectorRun(client: WorkerClient, job:
66
67
  bridge: NativeBridgeClient | undefined;
67
68
  shutdownSignal?: AbortSignal;
68
69
  }): Promise<unknown>;
69
- export declare function createMacDeviceDaemon(options: MacDeviceDaemonOptions, dependencies?: {
70
+ export declare function createMacDeviceDaemon(options: ValidatedMacDeviceDaemonOptions, dependencies?: {
70
71
  advertisementProvider?: MutableWorkerAdvertisementProvider;
71
72
  bridge?: NativeBridgeClient;
72
73
  shutdownController?: AbortController;
73
74
  }): WorkerPollLoop;
74
- export declare function runMacDeviceDaemon(options: MacDeviceDaemonOptions): Promise<void>;
75
+ export declare function runMacDeviceDaemon(options: ValidatedMacDeviceDaemonOptions): Promise<void>;
75
76
  //# sourceMappingURL=mac-device-daemon.d.ts.map
@@ -3,7 +3,6 @@ import { AGENT_KINDS, } from '@lobu/core/contracts/worker/device-automation';
3
3
  import { executeAutomationRun } from './automation.js';
4
4
  import { executeDaemonBuiltinActionRun, hasDaemonBuiltin } from './builtins/index.js';
5
5
  import { defaultDeviceMaxConcurrentJobs } from './device-concurrency.js';
6
- import { executeDeviceChatRun } from './device-chat.js';
7
6
  import { locateBinary, resolveRunnableAgentKinds, supportsOpenCodeAcp, } from './agent-binaries.js';
8
7
  import { MutableWorkerAdvertisementProvider, WorkerClient, WorkerHttpError, } from './client.js';
9
8
  import { installWorkerPollLoopSignals, WorkerPollLoop } from './poll-loop.js';
@@ -12,8 +11,8 @@ import { NativeBridgeClient } from './native-bridge/client.js';
12
11
  import { executeNativeBridgeRun } from './native-bridge/executor.js';
13
12
  import { NATIVE_BRIDGE_PROTOCOL } from './native-bridge/protocol.js';
14
13
  import { reportTerminalFailure } from './terminal-failure.js';
14
+ import { assertValidWorkerId } from './worker-id.js';
15
15
  export const MAC_DEVICE_PLATFORM = 'macos';
16
- const WORKER_ID_PATTERN = /^[A-Za-z0-9._:-]{1,128}$/;
17
16
  const WORKER_PAT_PATTERN = /^owl_pat_[A-Za-z0-9_-]{32}$/;
18
17
  const DEFAULT_POLL_INTERVAL_MS = 10000;
19
18
  // Source reads default to a ten-second end-to-end deadline. Keep the signed
@@ -120,9 +119,7 @@ function withTimeout(promise, timeoutMs, label) {
120
119
  }
121
120
  export function validateMacDeviceDaemonOptions(options, hostThreads) {
122
121
  const workerId = options.workerId?.trim() || defaultWorkerId();
123
- if (!WORKER_ID_PATTERN.test(workerId)) {
124
- throw new Error(`invalid --worker-id '${workerId}': expected 1-128 characters of letters, digits, dot, underscore, colon or hyphen`);
125
- }
122
+ assertValidWorkerId(workerId);
126
123
  const pollIntervalMs = validateNumber(options.pollIntervalMs, '--poll-interval-ms');
127
124
  const maxConcurrentJobs = validateNumber(options.maxConcurrentJobs, '--max-concurrent-jobs');
128
125
  const defaultAgentKind = validateAgentKind(options.defaultAgentKind);
@@ -220,7 +217,7 @@ export async function executeAdvertisedConnectorRun(client, job, dependencies) {
220
217
  return executeNativeBridgeRun(client, dependencies.bridge, job);
221
218
  }
222
219
  export function createMacDeviceDaemon(options, dependencies = {}) {
223
- const validated = validateMacDeviceDaemonOptions(options);
220
+ const validated = options;
224
221
  if (validated.noPoll)
225
222
  throw new Error('cannot create a polling daemon with --no-poll');
226
223
  const discoveredAgentKinds = resolveRunnableAgentKinds();
@@ -317,9 +314,6 @@ export function createMacDeviceDaemon(options, dependencies = {}) {
317
314
  if (job.run_type === 'automation') {
318
315
  return executeAutomationRun(client, job, automationConfig);
319
316
  }
320
- if (job.run_type === 'chat_message') {
321
- return executeDeviceChatRun(client, job, automationConfig);
322
- }
323
317
  if (job.run_type === 'sync' || job.run_type === 'action' || job.run_type === 'auth') {
324
318
  return executeAdvertisedConnectorRun(client, job, {
325
319
  advertisementProvider: dependencies.advertisementProvider,
@@ -337,7 +331,7 @@ export function createMacDeviceDaemon(options, dependencies = {}) {
337
331
  }
338
332
  export async function runMacDeviceDaemon(options) {
339
333
  setDebug(options.debug === true);
340
- const validated = validateMacDeviceDaemonOptions(options);
334
+ const validated = options;
341
335
  if (validated.noPoll)
342
336
  return;
343
337
  if (validated.supervisedStdio) {
@@ -1,5 +1,6 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { log } from '../log.js';
3
+ import { reportTerminalFailure } from '../terminal-failure.js';
3
4
  const FEED_READ_ACTION = '__lobu_feed_read';
4
5
  const NATIVE_BRIDGE_HEARTBEAT_INTERVAL_MS = 30_000;
5
6
  export const NATIVE_BRIDGE_EXECUTION_TIMEOUT_MS = 600_000;
@@ -8,7 +9,7 @@ export async function executeNativeBridgeRun(client, bridge, job, timeoutMs = NA
8
9
  throw new Error('native bridge run is missing run_id');
9
10
  const runId = job.run_id;
10
11
  const requestId = randomUUID();
11
- let operation;
12
+ let currentOperation;
12
13
  let itemsCollected = 0;
13
14
  let checkpoint = asRecord(job.checkpoint);
14
15
  let terminalDelivered = false;
@@ -70,8 +71,7 @@ export async function executeNativeBridgeRun(client, bridge, job, timeoutMs = NA
70
71
  await deliverTerminal(() => client.completeAuth(payload));
71
72
  };
72
73
  try {
73
- const currentOperation = nativeOperation(job);
74
- operation = currentOperation;
74
+ currentOperation = nativeOperation(job);
75
75
  heartbeatInterval = setInterval(() => {
76
76
  void client.heartbeat(runId).catch((error) => {
77
77
  log.debug(`[native-bridge] Heartbeat for run ${runId} failed:`, error);
@@ -116,27 +116,32 @@ export async function executeNativeBridgeRun(client, bridge, job, timeoutMs = NA
116
116
  catch (error) {
117
117
  const message = error instanceof Error ? error.message : String(error);
118
118
  log.info(`[native-bridge] Run ${runId} failed:`, message);
119
- try {
120
- if (operation === 'sync')
121
- await completeSync({}, message);
122
- else if (operation === 'auth')
123
- await completeAuth({}, message);
124
- else if (job.run_type === 'automation') {
125
- await client.completeAutomation(runId, {
126
- worker_id: client.id,
127
- output: '',
128
- error: message,
129
- duration_ms: 0,
130
- exit_reason: 'error_message',
131
- });
119
+ if (terminalReporter !== undefined) {
120
+ // A success terminal was already selected but its delivery budget is
121
+ // exhausted. Its outcome is immutable: never flip an executed run to
122
+ // failed and drop its output — leave it for stale-run handling.
123
+ log.info(`[native-bridge] Terminal report for run ${runId} failed:`, message);
124
+ }
125
+ else if (currentOperation === 'sync' || currentOperation === 'auth') {
126
+ // No terminal was selected yet and the run is a sync/auth: keep its
127
+ // own completion, preserving the bounded retry and partial progress.
128
+ const complete = currentOperation === 'sync' ? completeSync : completeAuth;
129
+ try {
130
+ await complete({}, message);
131
+ }
132
+ catch (completionError) {
133
+ log.info(`[native-bridge] Terminal report for run ${runId} failed:`, completionError);
132
134
  }
133
- else if (job.run_type === 'embed_backfill')
134
- await completeSync({}, message);
135
- else
136
- await completeAction({}, message);
137
135
  }
138
- catch (completionError) {
139
- log.info(`[native-bridge] Terminal report for run ${runId} failed:`, completionError);
136
+ else {
137
+ // No terminal was selected yet (bridge, stream, or timeout failure on
138
+ // any other run shape): report it under the run's own type.
139
+ try {
140
+ await reportTerminalFailure(client, job, message, 'error_message');
141
+ }
142
+ catch (completionError) {
143
+ log.info(`[native-bridge] Terminal report for run ${runId} failed:`, completionError);
144
+ }
140
145
  }
141
146
  return { itemsCollected, error: message };
142
147
  }
@@ -165,9 +170,6 @@ async function runWithTimeout(bridge, requestId, runId, timeoutMs, run) {
165
170
  }
166
171
  }
167
172
  function nativeOperation(job) {
168
- if (job.run_type === 'automation' || job.run_type === 'embed_backfill') {
169
- throw new Error('native bridge does not execute run_type ' + String(job.run_type));
170
- }
171
173
  if (job.run_type === 'sync')
172
174
  return 'sync';
173
175
  if (job.run_type === 'auth')
@@ -16,13 +16,7 @@ import { DEVICE_MANIFESTS_BY_PLATFORM } from './device-manifests.js';
16
16
  import { startDaemon } from './index.js';
17
17
  import { log, setDebug } from './log.js';
18
18
  import { attachInteractiveSession, deriveInteractiveWorkerId, detectInteractiveSession, } from './interactive-session.js';
19
- /**
20
- * Accepted `--worker-id` shape. Deliberately narrow: the default is
21
- * `<platform>:<short-hostname>` (or a session-derived id in a supported
22
- * interactive agent), and anything a shell, a URL path, or a JSON payload
23
- * would mangle has no business being a durable device identity.
24
- */
25
- const WORKER_ID_PATTERN = /^[A-Za-z0-9._:-]{1,128}$/;
19
+ import { assertValidWorkerId } from './worker-id.js';
26
20
  export function resolveDaemonWorkerId(opts, platform, shortHostname, interactiveSession) {
27
21
  return (opts.workerId ??
28
22
  (interactiveSession
@@ -72,14 +66,8 @@ export async function startDaemonCommand(opts) {
72
66
  if (platform && !isKnownPlatform(platform)) {
73
67
  throw new Error(`unknown device platform '${platform}'`);
74
68
  }
75
- // `worker_id` is the device's identity: the server upserts on
76
- // (user_id, worker_id) and Automation pins resolve the device row through it.
77
- // An unusable value therefore does not fail loudly — it mints a second device
78
- // and the pinned Automations go quiet on this one. Reject it at boot instead.
79
- if (opts.workerId !== undefined && !WORKER_ID_PATTERN.test(opts.workerId)) {
80
- throw new Error(`invalid --worker-id '${opts.workerId}': expected 1-128 characters of ` +
81
- 'letters, digits, dot, underscore, colon or hyphen');
82
- }
69
+ if (opts.workerId !== undefined)
70
+ assertValidWorkerId(opts.workerId);
83
71
  if (capabilities.length > 0 && !platform) {
84
72
  throw new Error('--capabilities requires --platform so the server can authorize the device capability set');
85
73
  }
@@ -20,17 +20,6 @@ export async function reportTerminalFailure(client, job, message, exitReason = '
20
20
  });
21
21
  return;
22
22
  }
23
- if (job.run_type === 'chat_message') {
24
- // Device chat completes through its adapter so the waiting Activity turn
25
- // receives a thread_response. Generic sync completion would finalize the
26
- // row without publishing that response.
27
- await client.completeDeviceChat(job.run_id, {
28
- worker_id: client.id,
29
- error: message,
30
- exit_reason: exitReason,
31
- });
32
- return;
33
- }
34
23
  if (job.run_type === 'agent_turn') {
35
24
  // The generic route refuses an agent turn with a 409, so a failure that
36
25
  // fell through to it would leave the run parked until the stale sweep.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Shared device-daemon worker-id shape.
3
+ *
4
+ * Accepted `--worker-id` shape. Deliberately narrow: the default is
5
+ * `<platform>:<short-hostname>` (or a session-derived id in a supported
6
+ * interactive agent), and anything a shell, a URL path, or a JSON payload
7
+ * would mangle has no business being a durable device identity.
8
+ */
9
+ /**
10
+ * `worker_id` is the device's identity: the server upserts on
11
+ * (user_id, worker_id) and Automation pins resolve the device row through it.
12
+ * An unusable value therefore does not fail loudly — it mints a second device
13
+ * and the pinned Automations go quiet on this one. Reject it at boot instead.
14
+ */
15
+ export declare const WORKER_ID_PATTERN: RegExp;
16
+ export declare function assertValidWorkerId(workerId: string): void;
17
+ //# sourceMappingURL=worker-id.d.ts.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Shared device-daemon worker-id shape.
3
+ *
4
+ * Accepted `--worker-id` shape. Deliberately narrow: the default is
5
+ * `<platform>:<short-hostname>` (or a session-derived id in a supported
6
+ * interactive agent), and anything a shell, a URL path, or a JSON payload
7
+ * would mangle has no business being a durable device identity.
8
+ */
9
+ /**
10
+ * `worker_id` is the device's identity: the server upserts on
11
+ * (user_id, worker_id) and Automation pins resolve the device row through it.
12
+ * An unusable value therefore does not fail loudly — it mints a second device
13
+ * and the pinned Automations go quiet on this one. Reject it at boot instead.
14
+ */
15
+ export const WORKER_ID_PATTERN = /^[A-Za-z0-9._:-]{1,128}$/;
16
+ export function assertValidWorkerId(workerId) {
17
+ if (!WORKER_ID_PATTERN.test(workerId)) {
18
+ throw new Error(`invalid --worker-id '${workerId}': expected 1-128 characters of ` +
19
+ 'letters, digits, dot, underscore, colon or hyphen');
20
+ }
21
+ }
22
+ //# sourceMappingURL=worker-id.js.map
@@ -86,6 +86,12 @@ function option(options, key) {
86
86
  throw new Error(`--${key} requires a value`);
87
87
  return value;
88
88
  }
89
+ function parsePositiveInt(raw, flag) {
90
+ if (!/^[1-9]\d*$/.test(raw)) {
91
+ throw new Error(`${flag} must be a positive integer (got '${raw}')`);
92
+ }
93
+ return Number(raw);
94
+ }
89
95
  async function main() {
90
96
  const args = process.argv.slice(2);
91
97
  const raw = parseArgs(args);
@@ -94,8 +100,6 @@ async function main() {
94
100
  return;
95
101
  }
96
102
  if (raw.version) {
97
- if (raw.version !== true)
98
- throw new Error('--version does not accept a value');
99
103
  process.stdout.write(`${JSON.stringify(macDeviceDaemonMetadata(VERSION))}\n`);
100
104
  return;
101
105
  }
@@ -107,44 +111,28 @@ async function main() {
107
111
  const defaultAgentKind = option(raw, 'default-agent-kind');
108
112
  const supervisedStdio = raw['supervised-stdio'] === true;
109
113
  const debug = raw.debug === true;
110
- if (raw.debug !== undefined && !debug)
111
- throw new Error('--debug does not accept a value');
112
- if (raw['no-poll'] !== undefined && !noPoll) {
113
- throw new Error('--no-poll does not accept a value');
114
- }
115
- if (raw['supervised-stdio'] !== undefined && !supervisedStdio) {
116
- throw new Error('--supervised-stdio does not accept a value');
117
- }
118
114
  const options = {
119
115
  apiUrl,
120
116
  workerId,
121
117
  workerApiToken: process.env.WORKER_API_TOKEN,
122
118
  version: VERSION,
123
- ...(pollInterval ? { pollIntervalMs: Number(pollInterval) } : {}),
124
- ...(maxConcurrent ? { maxConcurrentJobs: Number(maxConcurrent) } : {}),
119
+ ...(pollInterval
120
+ ? { pollIntervalMs: parsePositiveInt(pollInterval, '--poll-interval-ms') }
121
+ : {}),
122
+ ...(maxConcurrent
123
+ ? { maxConcurrentJobs: parsePositiveInt(maxConcurrent, '--max-concurrent-jobs') }
124
+ : {}),
125
125
  ...(defaultAgentKind ? { defaultAgentKind: defaultAgentKind } : {}),
126
126
  debug,
127
127
  noPoll,
128
128
  supervisedStdio,
129
129
  };
130
- if (pollInterval) {
131
- if (!/^[1-9]\d*$/.test(pollInterval)) {
132
- throw new Error(`--poll-interval-ms must be a positive integer (got '${pollInterval}')`);
133
- }
134
- options.pollIntervalMs = Number(pollInterval);
135
- }
136
- if (maxConcurrent) {
137
- if (!/^[1-9]\d*$/.test(maxConcurrent)) {
138
- throw new Error(`--max-concurrent-jobs must be a positive integer (got '${maxConcurrent}')`);
139
- }
140
- options.maxConcurrentJobs = Number(maxConcurrent);
141
- }
142
- validateMacDeviceDaemonOptions(options);
130
+ const validated = validateMacDeviceDaemonOptions(options);
143
131
  if (noPoll) {
144
132
  process.stdout.write(`${JSON.stringify(macDeviceDaemonMetadata(VERSION))}\n`);
145
133
  return;
146
134
  }
147
- await runMacDeviceDaemon(options);
135
+ await runMacDeviceDaemon(validated);
148
136
  }
149
137
  async function start() {
150
138
  if (process.argv[2] === INTERNAL_CLI_SUPERVISOR_ARG) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/connector-worker",
3
- "version": "22.0.0",
3
+ "version": "23.0.0",
4
4
  "description": "Self-hosted worker for Lobu memory — connectors and embedding generation",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  export declare const BROWSER_CAPABILITIES: readonly ["browser.tabs", "browser.scripting", "browser.history", "browser.bookmarks", "browser.downloads", "browser.notifications", "browser.debugger"];
2
2
  export declare const OS_CAPABILITIES: readonly ["os.shell", "os.files", "os.notifications"];
3
3
  export declare const IOS_CAPABILITIES: readonly ["ios.notifications", "ios.share-sheet", "ios.files"];
4
- export declare const MAC_DEVICE_CAPABILITIES: readonly ["automations.execute", "screentime", "local_directory", "healthkit", "photos", "calendar", "reminders", "system_audio", "computer_use"];
4
+ export declare const MAC_DEVICE_CAPABILITIES: readonly ["automations.execute", "screentime", "local_directory", "healthkit", "photos", "calendar", "reminders", "computer_use"];
5
5
  export declare const HEADLESS_CAPABILITIES: readonly ["os.shell", "os.files", "automations.execute"];
6
6
  export interface CapabilityAuthorizationResult {
7
7
  authorized: string[];
@@ -55,7 +55,6 @@ exports.MAC_DEVICE_CAPABILITIES = [
55
55
  "photos",
56
56
  "calendar",
57
57
  "reminders",
58
- "system_audio",
59
58
  "computer_use",
60
59
  ];
61
60
  // A server/VM with no UI or browser (the herdr box, a CI node, a k8s pod).
@@ -20,6 +20,8 @@
20
20
  export type ToolErrorCode =
21
21
  /** No auth profile configured for a connector that requires one. */
22
22
  "AUTH_MISSING"
23
+ /** Browser work stopped; an explicit bounded recovery or human handoff is required. */
24
+ | "BROWSER_INTERRUPTED"
23
25
  /** Credentials were rejected by the upstream (HTTP 401/403). */
24
26
  | "AUTH_INVALID"
25
27
  /** Connector / feed / connection / resource does not exist (HTTP 404). */
@@ -104,4 +106,34 @@ export interface ToolErrorSignal {
104
106
  * should source their retry decision from `isRetryable(classifyToolError(...))`.
105
107
  */
106
108
  export declare function classifyToolError(signal: ToolErrorSignal): ToolErrorCode;
109
+ /** Produced at the connector's page boundary, never inferred from error prose. */
110
+ declare const PAGE_INTERRUPTION_REASON_VALUES: readonly ["challenge_required", "login_required", "account_mismatch", "loading_failure"];
111
+ export type BrowserInterruptionReason = (typeof PAGE_INTERRUPTION_REASON_VALUES)[number] | "timeout" | "recovery_unavailable";
112
+ export interface BrowserRecovery {
113
+ recovery_id: string;
114
+ expires_at: string;
115
+ tab_id: number;
116
+ target_id: string;
117
+ window_id: number;
118
+ device_worker_id: string;
119
+ chrome_connection_id: number;
120
+ }
121
+ export declare class BrowserInterruptionError extends ToolError {
122
+ readonly reason: BrowserInterruptionReason;
123
+ readonly recovery?: BrowserRecovery | undefined;
124
+ constructor(reason: BrowserInterruptionReason, message: string, recovery?: BrowserRecovery | undefined);
125
+ toJSON(): {
126
+ recovery?: BrowserRecovery | undefined;
127
+ reason: BrowserInterruptionReason;
128
+ code: ToolErrorCode;
129
+ retryable: boolean;
130
+ message: string;
131
+ call_id?: string;
132
+ };
133
+ }
134
+ export declare function browserPageInterruption(value: unknown): {
135
+ reason: BrowserInterruptionReason;
136
+ message: string;
137
+ } | undefined;
138
+ export {};
107
139
  //# sourceMappingURL=connector-query-errors.d.ts.map
@@ -19,16 +19,21 @@
19
19
  * pick the right code; the catalog is the single source of truth for retryability.
20
20
  */
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.ToolError = exports.TOOL_ERRORS = void 0;
22
+ exports.BrowserInterruptionError = exports.ToolError = exports.TOOL_ERRORS = void 0;
23
23
  exports.isRetryable = isRetryable;
24
24
  exports.toToolErrorCode = toToolErrorCode;
25
25
  exports.isToolError = isToolError;
26
26
  exports.classifyToolError = classifyToolError;
27
+ exports.browserPageInterruption = browserPageInterruption;
27
28
  exports.TOOL_ERRORS = {
28
29
  AUTH_MISSING: {
29
30
  retryable: false,
30
31
  message: "No auth profile is configured for this connector.",
31
32
  },
33
+ BROWSER_INTERRUPTED: {
34
+ retryable: false,
35
+ message: "Browser reading was interrupted; see interruption.reason for the next step.",
36
+ },
32
37
  AUTH_INVALID: {
33
38
  retryable: false,
34
39
  message: "The connector's credentials were rejected.",
@@ -189,4 +194,39 @@ function classifyToolError(signal) {
189
194
  }
190
195
  return "INTERNAL";
191
196
  }
197
+ /** Produced at the connector's page boundary, never inferred from error prose. */
198
+ const PAGE_INTERRUPTION_REASON_VALUES = [
199
+ "challenge_required",
200
+ "login_required",
201
+ "account_mismatch",
202
+ "loading_failure",
203
+ ];
204
+ const PAGE_INTERRUPTION_REASONS = new Set(PAGE_INTERRUPTION_REASON_VALUES);
205
+ class BrowserInterruptionError extends ToolError {
206
+ constructor(reason, message, recovery) {
207
+ super("BROWSER_INTERRUPTED", message);
208
+ this.reason = reason;
209
+ this.recovery = recovery;
210
+ }
211
+ toJSON() {
212
+ return {
213
+ ...super.toJSON(),
214
+ reason: this.reason,
215
+ ...(this.recovery ? { recovery: this.recovery } : {}),
216
+ };
217
+ }
218
+ }
219
+ exports.BrowserInterruptionError = BrowserInterruptionError;
220
+ function browserPageInterruption(value) {
221
+ const marker = value?.__lobu_browser_interruption;
222
+ if (!marker ||
223
+ typeof marker.reason !== "string" ||
224
+ !PAGE_INTERRUPTION_REASONS.has(marker.reason) ||
225
+ typeof marker.message !== "string")
226
+ return undefined;
227
+ return {
228
+ reason: marker.reason,
229
+ message: marker.message.slice(0, 1000),
230
+ };
231
+ }
192
232
  //# sourceMappingURL=connector-query-errors.js.map
@@ -24,11 +24,11 @@ exports.ListConversationsAction = typebox_1.Type.Object({
24
24
  });
25
25
  exports.GetConversationAction = typebox_1.Type.Object({
26
26
  action: typebox_1.Type.Literal("get", {
27
- description: "Fetch one conversation by its (platform, conversation_id).",
27
+ description: "Fetch one conversation by id, optionally scoped to a platform.",
28
28
  }),
29
29
  agent_id: AgentId,
30
30
  platform: typebox_1.Type.Optional(typebox_1.Type.String({
31
- description: 'Conversation platform ("web" for app-owned conversations, or a channel platform like "slack"). Defaults to "web".',
31
+ description: 'Conversation platform ("web" for app-owned conversations, or a channel platform like "slack"). When omitted, resolves a unique active match for this agent across platforms; ambiguous ids return not found.',
32
32
  })),
33
33
  conversation_id: ConversationId,
34
34
  });
@@ -17,6 +17,7 @@ export declare const ReadFeedAction: import("@sinclair/typebox").TObject<{
17
17
  export declare const ReadFeedsAction: import("@sinclair/typebox").TObject<{
18
18
  action: import("@sinclair/typebox").TLiteral<"read_feeds">;
19
19
  reads: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
20
+ recovery_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
20
21
  feed_id: import("@sinclair/typebox").TInteger;
21
22
  query: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
22
23
  limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
@@ -104,6 +105,18 @@ export declare const ManageFeedsResultSchema: import("@sinclair/typebox").TUnion
104
105
  error: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
105
106
  error_code: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
106
107
  retryable: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
108
+ interruption: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
109
+ reason: import("@sinclair/typebox").TString;
110
+ recovery: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
111
+ recovery_id: import("@sinclair/typebox").TString;
112
+ expires_at: import("@sinclair/typebox").TString;
113
+ tab_id: import("@sinclair/typebox").TInteger;
114
+ target_id: import("@sinclair/typebox").TString;
115
+ window_id: import("@sinclair/typebox").TInteger;
116
+ device_worker_id: import("@sinclair/typebox").TString;
117
+ chrome_connection_id: import("@sinclair/typebox").TInteger;
118
+ }>>;
119
+ }>>;
107
120
  }>>;
108
121
  failures: import("@sinclair/typebox").TInteger;
109
122
  timeout_ms: import("@sinclair/typebox").TInteger;
@@ -148,6 +161,7 @@ export declare const ManageFeedsSchema: import("@sinclair/typebox").TUnion<[impo
148
161
  }>, import("@sinclair/typebox").TObject<{
149
162
  action: import("@sinclair/typebox").TLiteral<"read_feeds">;
150
163
  reads: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
164
+ recovery_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
151
165
  feed_id: import("@sinclair/typebox").TInteger;
152
166
  query: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
153
167
  limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
@@ -33,6 +33,11 @@ exports.ReadFeedAction = typebox_1.Type.Object({
33
33
  feed_id: typebox_1.Type.Number({ description: "Feed ID" }),
34
34
  });
35
35
  const FeedSourceRead = typebox_1.Type.Object({
36
+ recovery_id: typebox_1.Type.Optional(typebox_1.Type.String({
37
+ minLength: 1,
38
+ maxLength: 128,
39
+ description: "Consume a recovery handoff once for the identical source request, on its retained tab. The expected account is verified again.",
40
+ })),
36
41
  feed_id: typebox_1.Type.Integer({
37
42
  minimum: 1,
38
43
  description: "Feed ID to query at its source.",
@@ -183,6 +188,18 @@ exports.ManageFeedsResultSchema = typebox_1.Type.Union([
183
188
  error: typebox_1.Type.Optional(typebox_1.Type.String()),
184
189
  error_code: typebox_1.Type.Optional(typebox_1.Type.String()),
185
190
  retryable: typebox_1.Type.Optional(typebox_1.Type.Boolean()),
191
+ interruption: typebox_1.Type.Optional(typebox_1.Type.Object({
192
+ reason: typebox_1.Type.String(),
193
+ recovery: typebox_1.Type.Optional(typebox_1.Type.Object({
194
+ recovery_id: typebox_1.Type.String(),
195
+ expires_at: typebox_1.Type.String(),
196
+ tab_id: typebox_1.Type.Integer(),
197
+ target_id: typebox_1.Type.String(),
198
+ window_id: typebox_1.Type.Integer(),
199
+ device_worker_id: typebox_1.Type.String(),
200
+ chrome_connection_id: typebox_1.Type.Integer(),
201
+ })),
202
+ })),
186
203
  })),
187
204
  failures: typebox_1.Type.Integer(),
188
205
  timeout_ms: typebox_1.Type.Integer(),