@lobu/runtime-device 21.2.1 → 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.
- 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/bundled-skills/lobu/SKILL.md +1 -1
- 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 +21 -6
- 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 +52 -33
- package/vendor/cli/dist/connectors/herdr.ts +406 -0
- package/vendor/cli/dist/connectors/jira-helpers.ts +313 -0
- package/vendor/cli/dist/connectors/jira.ts +35 -227
- package/vendor/cli/dist/connectors/linear.ts +7 -4
- package/vendor/cli/dist/connectors/linkedin-browser-script.ts +13 -0
- package/vendor/cli/dist/connectors/linkedin-draft-page.js +104 -0
- package/vendor/cli/dist/connectors/linkedin-drafts.ts +73 -0
- package/vendor/cli/dist/connectors/linkedin-identity.ts +32 -0
- package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +1185 -0
- package/vendor/cli/dist/connectors/linkedin-inbox.ts +156 -0
- package/vendor/cli/dist/connectors/linkedin-like.ts +114 -0
- package/vendor/cli/dist/connectors/linkedin-takeout.ts +577 -0
- package/vendor/cli/dist/connectors/linkedin.ts +3998 -0
- package/vendor/cli/dist/connectors/postgres.ts +27 -2
- package/vendor/cli/dist/connectors/takeout-utils.ts +240 -0
- package/vendor/cli/dist/connectors/tiktok-inbox-page.js +230 -0
- package/vendor/cli/dist/connectors/tiktok-web-page.js +217 -0
- package/vendor/cli/dist/connectors/tiktok_web.ts +319 -0
- package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +285 -567
- package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +74 -455
- package/vendor/cli/dist/connectors/whatsapp-web-identity.ts +135 -0
- package/vendor/cli/dist/connectors/whatsapp_web.ts +159 -618
- package/vendor/cli/dist/connectors/x-dm-adapter.js +556 -0
- package/vendor/cli/dist/connectors/x-identity.ts +31 -2
- package/vendor/cli/dist/connectors/x.ts +539 -253
- 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 +12 -5
- 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-handoff-banner.d.ts +39 -0
- package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
- 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/browser-source-read.d.ts +52 -0
- package/vendor/connector-sdk/dist/browser-source-read.js +107 -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 +169 -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 +8 -2
- package/vendor/connector-sdk/dist/index.js +3 -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 +13 -1
- package/vendor/connector-worker/dist/agent-turn/guest-entry.js +43 -30
- package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +416 -330
- 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/automation.d.ts +4 -11
- package/vendor/connector-worker/dist/daemon/automation.js +6 -6
- 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 +6 -4
- package/vendor/connector-worker/dist/daemon/client.js +3 -3
- 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 -120
- 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 +23 -6
- package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +57 -23
- 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 +29 -25
- 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 +15 -20
- package/vendor/connector-worker/dist/daemon/terminal-failure.js +0 -11
- package/vendor/connector-worker/dist/daemon/worker-id.d.ts +17 -0
- package/vendor/connector-worker/dist/daemon/worker-id.js +22 -0
- 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 +24 -29
- 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.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +2 -1
- package/vendor/core/dist/connector-query-errors.d.ts +32 -0
- package/vendor/core/dist/connector-query-errors.js +41 -1
- 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-conversations.js +2 -2
- 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-feeds.d.ts +14 -0
- package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
- 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 +130 -159
- package/vendor/core/dist/contracts/worker/protocol.js +88 -76
- package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
- package/vendor/core/dist/device-pin-tombstones.js +57 -0
- package/vendor/core/dist/index.d.ts +5 -5
- package/vendor/core/dist/index.js +4 -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 +17 -26
- 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/diagnostic-scrubber.js +437 -0
- package/vendor/core/dist/worker/auth.d.ts +44 -6
- package/vendor/core/dist/worker/auth.js +44 -11
- package/vendor/core/dist/worker/wire.d.ts +0 -10
- package/vendor/core/package.json +20 -11
- 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/connector-worker/dist/daemon/device-chat.d.ts +0 -9
- package/vendor/connector-worker/dist/daemon/device-chat.js +0 -61
- package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
- package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
- 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
- package/vendor/core/dist/utils/sentry-scrubber.js +0 -228
|
@@ -16,10 +16,11 @@
|
|
|
16
16
|
* 2. The SETTLE. `agentEnd` starts the `save_memory` write and returns
|
|
17
17
|
* without waiting, which is correct on a runtime that outlives the turn and
|
|
18
18
|
* silently lossy on one that does not: this isolate is disposed the moment
|
|
19
|
-
* `runAgentTurn` resolves. `
|
|
19
|
+
* `runAgentTurn` resolves. `capture` therefore awaits the plugin's
|
|
20
20
|
* `settle()` before returning, so the capture actually reaches the gateway.
|
|
21
21
|
*/
|
|
22
22
|
import type { PluginLogger } from '@lobu/plugin-api';
|
|
23
|
+
import type { TextResult } from '@lobu/plugin-toolkit';
|
|
23
24
|
/** What the guest needs from a turn to run its memory hooks. */
|
|
24
25
|
export interface TurnMemoryContext {
|
|
25
26
|
gatewayUrl: string;
|
|
@@ -39,7 +40,7 @@ export interface TurnMemoryContext {
|
|
|
39
40
|
*/
|
|
40
41
|
callTool: (mcpId: string, toolName: string, args: Record<string, unknown>, options?: {
|
|
41
42
|
timeoutMs?: number;
|
|
42
|
-
}) => Promise<
|
|
43
|
+
}) => Promise<TextResult>;
|
|
43
44
|
/** Where a hook's own diagnostics go. The host redacts and budgets them. */
|
|
44
45
|
logger: PluginLogger;
|
|
45
46
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* 2. The SETTLE. `agentEnd` starts the `save_memory` write and returns
|
|
17
17
|
* without waiting, which is correct on a runtime that outlives the turn and
|
|
18
18
|
* silently lossy on one that does not: this isolate is disposed the moment
|
|
19
|
-
* `runAgentTurn` resolves. `
|
|
19
|
+
* `runAgentTurn` resolves. `capture` therefore awaits the plugin's
|
|
20
20
|
* `settle()` before returning, so the capture actually reaches the gateway.
|
|
21
21
|
*/
|
|
22
22
|
import { PluginHost } from '@lobu/plugin-host';
|
|
@@ -30,22 +30,7 @@ function createTurnMemory(context) {
|
|
|
30
30
|
// The plugin addresses its server as `lobu`; the turn says which server that
|
|
31
31
|
// actually is. Routing on the turn's id rather than the plugin's literal is
|
|
32
32
|
// what keeps the guest free of a hardcoded server name.
|
|
33
|
-
const invoke =
|
|
34
|
-
// The plugin's contract is a `TextResult`; a failed call is text the hook
|
|
35
|
-
// inspects (it skips a recall whose text starts with "error:"), never a
|
|
36
|
-
// throw. Matching that here keeps the hook's own branches live.
|
|
37
|
-
try {
|
|
38
|
-
const text = await context.callTool(context.mcpId, toolName, args, options);
|
|
39
|
-
return { content: [{ type: 'text', text }] };
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
return {
|
|
43
|
-
content: [
|
|
44
|
-
{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` },
|
|
45
|
-
],
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
};
|
|
33
|
+
const invoke = (_gateway, _mcpId, toolName, args, options) => context.callTool(context.mcpId, toolName, args, options);
|
|
49
34
|
const plugin = createMemoryPlugin({
|
|
50
35
|
// The plugin passes these straight back to the invoker, which ignores
|
|
51
36
|
// them: this lane addresses the MCP route itself. They are filled in
|
|
@@ -55,9 +40,7 @@ function createTurnMemory(context) {
|
|
|
55
40
|
channelId: '',
|
|
56
41
|
conversationId: context.conversationId,
|
|
57
42
|
}, invoke);
|
|
58
|
-
// `PluginRuntimeContext`
|
|
59
|
-
// `logger` and `agentId`). The rest is filled
|
|
60
|
-
// with what this lane actually knows, and nothing is invented: a field this
|
|
43
|
+
// Fill `PluginRuntimeContext` with what this lane actually knows: a field this
|
|
61
44
|
// lane has no value for stays empty rather than carrying a plausible lie.
|
|
62
45
|
const runtime = {
|
|
63
46
|
logger: context.logger,
|
|
@@ -120,28 +120,16 @@ export type AgentTurnGatewayTool = 'list_conversations' | 'read_conversation' |
|
|
|
120
120
|
* plugin's on both lanes.
|
|
121
121
|
*/
|
|
122
122
|
export type AgentTurnMediaTool = 'upload_file' | 'generate_image' | 'generate_audio';
|
|
123
|
-
/**
|
|
124
|
-
* The agent's bash prefix policy, in the shape `@lobu/core/tool-policy`
|
|
125
|
-
* enforces. Restated rather than imported on purpose: this file is the
|
|
126
|
-
* host-side contract, and a type import here would be the first step toward a
|
|
127
|
-
* value import from the same module, which the guest bundle cannot take.
|
|
128
|
-
*/
|
|
129
|
-
export interface AgentTurnBashPolicy {
|
|
130
|
-
allowAll: boolean;
|
|
131
|
-
allowPrefixes: string[];
|
|
132
|
-
denyPrefixes: string[];
|
|
133
|
-
}
|
|
134
123
|
/** The tools of a turn and where they are called. */
|
|
135
124
|
export interface AgentTurnTools {
|
|
136
125
|
/** Gateway base URL, mount path included; the MCP route hangs off it. */
|
|
137
126
|
gatewayUrl: string;
|
|
138
127
|
definitions: AgentTurnTool[];
|
|
139
128
|
/**
|
|
140
|
-
* Workspace tools
|
|
129
|
+
* Workspace tools available for this turn. They run inside the isolate
|
|
141
130
|
* against a filesystem that lives for this turn only.
|
|
142
131
|
*/
|
|
143
132
|
builtin?: AgentTurnBuiltinTool[];
|
|
144
|
-
bashPolicy?: AgentTurnBashPolicy;
|
|
145
133
|
/**
|
|
146
134
|
* The conversation is pinned to a remote runtime sandbox: `bash` runs there
|
|
147
135
|
* through the host, not in the in-memory workspace. Absent → local bash.
|
|
@@ -150,12 +138,12 @@ export interface AgentTurnTools {
|
|
|
150
138
|
providerId: string;
|
|
151
139
|
};
|
|
152
140
|
/**
|
|
153
|
-
* Gateway tools
|
|
141
|
+
* Gateway tools available for this turn, by name. Their routing lives in
|
|
154
142
|
* the plugin package, so the wire carries only the names.
|
|
155
143
|
*/
|
|
156
144
|
gateway?: AgentTurnGatewayTool[];
|
|
157
145
|
/**
|
|
158
|
-
* Media tools
|
|
146
|
+
* Media tools available for this turn, by name. Same contract as
|
|
159
147
|
* `gateway`: names only, because the routing lives in the plugin package.
|
|
160
148
|
* `upload_file` additionally needs `builtin` to include a workspace tool —
|
|
161
149
|
* with no filesystem there is no file to show — and the guest drops it if
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import type { AgentTool } from '@mariozechner/pi-agent-core';
|
|
20
20
|
import { InMemoryFs } from 'just-bash/browser';
|
|
21
|
-
import type {
|
|
21
|
+
import type { AgentTurnBuiltinTool, RuntimeExecRequest, RuntimeExecResult } from './types.js';
|
|
22
22
|
/** Where a turn's files live; also the shell's working directory. */
|
|
23
23
|
export declare const WORKSPACE_ROOT = "/workspace";
|
|
24
24
|
/**
|
|
@@ -100,5 +100,5 @@ export interface RemoteRuntime {
|
|
|
100
100
|
* sees. A supplied remote runtime replaces only `bash`; file tools remain on
|
|
101
101
|
* this in-memory filesystem.
|
|
102
102
|
*/
|
|
103
|
-
export declare function createWorkspace(names: readonly AgentTurnBuiltinTool[],
|
|
103
|
+
export declare function createWorkspace(names: readonly AgentTurnBuiltinTool[], remote?: RemoteRuntime): AgentWorkspace;
|
|
104
104
|
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { withLobuFileParameters } from '@lobu/core/agent-tooling';
|
|
20
20
|
import { createEditTool, createFindTool, createLsTool, createReadTool, createWriteTool, DEFAULT_MAX_BYTES as MAX_BYTES, DEFAULT_MAX_LINES as MAX_LINES, formatSize, truncateHead, truncateLine, truncateTail, } from '@mariozechner/pi-coding-agent';
|
|
21
|
-
import {
|
|
21
|
+
import { isDirectPackageInstallCommand } from '@lobu/core/shell-safety';
|
|
22
22
|
import { Bash, InMemoryFs } from 'just-bash/browser';
|
|
23
23
|
/** Where a turn's files live; also the shell's working directory. */
|
|
24
24
|
export const WORKSPACE_ROOT = '/workspace';
|
|
@@ -202,7 +202,7 @@ async function runRemoteBash(remote, command, timeout) {
|
|
|
202
202
|
* sees. A supplied remote runtime replaces only `bash`; file tools remain on
|
|
203
203
|
* this in-memory filesystem.
|
|
204
204
|
*/
|
|
205
|
-
export function createWorkspace(names,
|
|
205
|
+
export function createWorkspace(names, remote) {
|
|
206
206
|
const fs = new InMemoryFs();
|
|
207
207
|
const ready = fs.mkdir(WORKSPACE_ROOT, { recursive: true });
|
|
208
208
|
const shell = new Bash({ fs, cwd: WORKSPACE_ROOT, executionLimits: BASH_LIMITS });
|
|
@@ -341,8 +341,6 @@ export function createWorkspace(names, bashPolicy, remote) {
|
|
|
341
341
|
execute: async (_id, args) => {
|
|
342
342
|
const command = requireString(args, 'command');
|
|
343
343
|
const timeout = optionalNumber(args, 'timeout');
|
|
344
|
-
if (bashPolicy)
|
|
345
|
-
enforceBashCommandPolicy(command, bashPolicy);
|
|
346
344
|
if (isDirectPackageInstallCommand(command)) {
|
|
347
345
|
throw new Error(remote
|
|
348
346
|
? 'DIRECT PACKAGE INSTALL BLOCKED. Use the sandbox packages configured by an admin.'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ExecutorClient } from './client.js';
|
|
2
|
+
/** Action work stops when its durable lease is revoked. Network failures alone
|
|
3
|
+
* do not prove revocation; the gateway's structured 409 does. */
|
|
4
|
+
export declare function monitorActionRun(client: ExecutorClient, runId: number, cfg: {
|
|
5
|
+
heartbeatIntervalMs: number;
|
|
6
|
+
shutdownSignal?: AbortSignal;
|
|
7
|
+
}): {
|
|
8
|
+
signal: AbortSignal;
|
|
9
|
+
revoked: () => boolean;
|
|
10
|
+
stop: () => void;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=action-monitor.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { WorkerHttpError } from './client.js';
|
|
2
|
+
import { log } from './log.js';
|
|
3
|
+
/** Action work stops when its durable lease is revoked. Network failures alone
|
|
4
|
+
* do not prove revocation; the gateway's structured 409 does. */
|
|
5
|
+
export function monitorActionRun(client, runId, cfg) {
|
|
6
|
+
const controller = new AbortController();
|
|
7
|
+
const signal = cfg.shutdownSignal
|
|
8
|
+
? AbortSignal.any([controller.signal, cfg.shutdownSignal])
|
|
9
|
+
: controller.signal;
|
|
10
|
+
const interval = setInterval(async () => {
|
|
11
|
+
try {
|
|
12
|
+
const response = await client.heartbeat(runId);
|
|
13
|
+
if (response?.continue === false)
|
|
14
|
+
controller.abort();
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (error instanceof WorkerHttpError && error.status === 409)
|
|
18
|
+
controller.abort();
|
|
19
|
+
else
|
|
20
|
+
log.debug('[executor] Action heartbeat failed:', error);
|
|
21
|
+
}
|
|
22
|
+
}, cfg.heartbeatIntervalMs);
|
|
23
|
+
return { signal, revoked: () => controller.signal.aborted, stop: () => clearInterval(interval) };
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=action-monitor.js.map
|
|
@@ -379,15 +379,6 @@ export async function executeAgentTurnRun(client, job, env, cfg) {
|
|
|
379
379
|
})),
|
|
380
380
|
...(turn.tools.builtin ? { builtin: turn.tools.builtin } : {}),
|
|
381
381
|
...(turn.tools.remote_runtime ? { remoteRuntime: { providerId: turn.tools.remote_runtime.provider_id } } : {}),
|
|
382
|
-
...(turn.tools.bash_policy
|
|
383
|
-
? {
|
|
384
|
-
bashPolicy: {
|
|
385
|
-
allowAll: turn.tools.bash_policy.allow_all,
|
|
386
|
-
allowPrefixes: turn.tools.bash_policy.allow_prefixes,
|
|
387
|
-
denyPrefixes: turn.tools.bash_policy.deny_prefixes,
|
|
388
|
-
},
|
|
389
|
-
}
|
|
390
|
-
: {}),
|
|
391
382
|
// Names only; the guest selects them out of the plugin
|
|
392
383
|
// package, which is where their routing and schemas live.
|
|
393
384
|
// Without the conversation they address there is nothing to
|
|
@@ -67,13 +67,6 @@ export interface AutomationExecutorConfig {
|
|
|
67
67
|
/** Maintained ACP entrypoints keyed by the local agent kind they drive. */
|
|
68
68
|
acpAdapters?: AutomationAcpAdapters;
|
|
69
69
|
}
|
|
70
|
-
/** Shared liveness/cancellation control for every device-local agent run. */
|
|
71
|
-
export declare function monitorDeviceAgentRun(client: ExecutorClient, runId: number, cfg: AutomationExecutorConfig, label: string): {
|
|
72
|
-
abortController: AbortController;
|
|
73
|
-
terminalSignal: AbortSignal;
|
|
74
|
-
shutdownRequested: () => boolean;
|
|
75
|
-
stop: () => void;
|
|
76
|
-
};
|
|
77
70
|
/** Local-CLI run result, mirrored from the Mac app's `ExecutorResult`. */
|
|
78
71
|
export interface ExecutorResult {
|
|
79
72
|
output: string;
|
|
@@ -100,10 +93,10 @@ export interface DeviceAgentRunAccess {
|
|
|
100
93
|
env: Record<string, string>;
|
|
101
94
|
}
|
|
102
95
|
/**
|
|
103
|
-
* Resolve what credential the spawned CLI runs with
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
96
|
+
* Resolve what credential the spawned Automation CLI runs with. When the poll
|
|
97
|
+
* envelope carries a per-run `agent_session`, the CLI authenticates as the
|
|
98
|
+
* run's assigned agent for exactly this run: the session token goes into the
|
|
99
|
+
* MCP wiring AND into
|
|
107
100
|
* LOBU_API_TOKEN/LOBU_MEMORY_URL, which `lobu memory` prefers
|
|
108
101
|
* over the device's ambient CLI session — so an unattended run never acts as
|
|
109
102
|
* the human user or the daemon. Without a session (older server, or a run with
|
|
@@ -36,8 +36,8 @@ import { WorkerDecodeError, WorkerHttpError } from './client.js';
|
|
|
36
36
|
import { log } from './log.js';
|
|
37
37
|
import { attachedInteractiveSession, handoffToInteractiveSession, } from './interactive-session.js';
|
|
38
38
|
import { AcpTranscript, runAcpTurn, } from './automation-acp.js';
|
|
39
|
-
/**
|
|
40
|
-
|
|
39
|
+
/** Liveness and cancellation control for a device Automation run. */
|
|
40
|
+
function monitorDeviceAgentRun(client, runId, cfg, label) {
|
|
41
41
|
const abortController = new AbortController();
|
|
42
42
|
const terminalController = new AbortController();
|
|
43
43
|
let shutdownRequested = false;
|
|
@@ -292,10 +292,10 @@ function claudeSessionMeta(base, maxBudgetUsd) {
|
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
294
|
/**
|
|
295
|
-
* Resolve what credential the spawned CLI runs with
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
295
|
+
* Resolve what credential the spawned Automation CLI runs with. When the poll
|
|
296
|
+
* envelope carries a per-run `agent_session`, the CLI authenticates as the
|
|
297
|
+
* run's assigned agent for exactly this run: the session token goes into the
|
|
298
|
+
* MCP wiring AND into
|
|
299
299
|
* LOBU_API_TOKEN/LOBU_MEMORY_URL, which `lobu memory` prefers
|
|
300
300
|
* over the device's ambient CLI session — so an unattended run never acts as
|
|
301
301
|
* the human user or the daemon. Without a session (older server, or a run with
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ExecutorClient, PollResponse } from '../client.js';
|
|
2
|
+
import { type ShellPlatform } from './os-shell.js';
|
|
1
3
|
export type DaemonBuiltinErrorCode = 'invalid_operation_input' | 'operation_backend_unavailable' | 'operation_execution_failed';
|
|
2
4
|
export type DaemonBuiltinResult = {
|
|
3
5
|
ok: true;
|
|
@@ -22,5 +24,15 @@ export declare function executeDaemonBuiltin(params: {
|
|
|
22
24
|
actionKey: string;
|
|
23
25
|
input: Record<string, unknown>;
|
|
24
26
|
shutdownSignal?: AbortSignal;
|
|
27
|
+
platform?: ShellPlatform;
|
|
25
28
|
}): Promise<DaemonBuiltinResult>;
|
|
29
|
+
/** Run one claimed built-in action and report its single terminal result. */
|
|
30
|
+
export declare function executeDaemonBuiltinActionRun(client: ExecutorClient, job: PollResponse, cfg: {
|
|
31
|
+
heartbeatIntervalMs: number;
|
|
32
|
+
shutdownSignal?: AbortSignal;
|
|
33
|
+
platform?: ShellPlatform;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
itemsCollected: number;
|
|
36
|
+
error?: string;
|
|
37
|
+
}>;
|
|
26
38
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { monitorActionRun } from '../action-monitor.js';
|
|
2
|
+
import { log } from '../log.js';
|
|
3
|
+
import { completeActionOnce } from '../terminal-delivery.js';
|
|
1
4
|
import { ShellInputError, runShellBuiltin } from './os-shell.js';
|
|
2
5
|
function describeShellFailure(output) {
|
|
3
6
|
if (output.timed_out) {
|
|
@@ -72,7 +75,7 @@ export async function executeDaemonBuiltin(params) {
|
|
|
72
75
|
};
|
|
73
76
|
}
|
|
74
77
|
try {
|
|
75
|
-
const output = await builtin(params.input, params.shutdownSignal);
|
|
78
|
+
const output = await builtin(params.input, params.shutdownSignal, params.platform ?? 'headless');
|
|
76
79
|
if (!output.success) {
|
|
77
80
|
return {
|
|
78
81
|
ok: false,
|
|
@@ -95,4 +98,61 @@ export async function executeDaemonBuiltin(params) {
|
|
|
95
98
|
};
|
|
96
99
|
}
|
|
97
100
|
}
|
|
101
|
+
/** Run one claimed built-in action and report its single terminal result. */
|
|
102
|
+
export async function executeDaemonBuiltinActionRun(client, job, cfg) {
|
|
103
|
+
const { run_id, connector_key, action_key, action_input } = job;
|
|
104
|
+
if (!run_id || !connector_key || !action_key) {
|
|
105
|
+
throw new Error('Invalid daemon built-in action: missing run_id, connector_key, or action_key');
|
|
106
|
+
}
|
|
107
|
+
if (job.compiled_code) {
|
|
108
|
+
const message = 'operation_backend_unavailable: a daemon built-in payload must not contain compiled_code';
|
|
109
|
+
await completeActionOnce(client, {
|
|
110
|
+
run_id,
|
|
111
|
+
worker_id: client.id,
|
|
112
|
+
status: 'failed',
|
|
113
|
+
error_message: message,
|
|
114
|
+
});
|
|
115
|
+
return { itemsCollected: 0, error: message };
|
|
116
|
+
}
|
|
117
|
+
const monitor = monitorActionRun(client, run_id, cfg);
|
|
118
|
+
try {
|
|
119
|
+
const result = await executeDaemonBuiltin({
|
|
120
|
+
connectorKey: connector_key,
|
|
121
|
+
actionKey: action_key,
|
|
122
|
+
input: (action_input ?? {}),
|
|
123
|
+
shutdownSignal: monitor.signal,
|
|
124
|
+
...(cfg.platform ? { platform: cfg.platform } : {}),
|
|
125
|
+
});
|
|
126
|
+
if (monitor.revoked())
|
|
127
|
+
return { itemsCollected: 0 };
|
|
128
|
+
if (!result.ok) {
|
|
129
|
+
const message = `${result.code}: ${result.error}`;
|
|
130
|
+
await completeActionOnce(client, {
|
|
131
|
+
run_id,
|
|
132
|
+
worker_id: client.id,
|
|
133
|
+
status: 'failed',
|
|
134
|
+
error_message: message,
|
|
135
|
+
...(result.output ? { action_output: result.output } : {}),
|
|
136
|
+
});
|
|
137
|
+
return { itemsCollected: 0, error: message };
|
|
138
|
+
}
|
|
139
|
+
await completeActionOnce(client, {
|
|
140
|
+
run_id,
|
|
141
|
+
worker_id: client.id,
|
|
142
|
+
status: 'success',
|
|
143
|
+
action_output: result.output,
|
|
144
|
+
});
|
|
145
|
+
return { itemsCollected: 0 };
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
// Delivery uncertainty is not an execution failure. The immutable payload
|
|
149
|
+
// was retried above; never send a contradictory terminal result here.
|
|
150
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
151
|
+
log.info(`[executor] Daemon built-in terminal delivery uncertain for ${run_id}:`, message);
|
|
152
|
+
return { itemsCollected: 0, error: message };
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
monitor.stop();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
98
158
|
//# sourceMappingURL=index.js.map
|
|
@@ -31,5 +31,6 @@ export interface ShellRunOutput {
|
|
|
31
31
|
timed_out: boolean;
|
|
32
32
|
duration_ms: number;
|
|
33
33
|
}
|
|
34
|
-
export
|
|
34
|
+
export type ShellPlatform = 'headless' | 'macos';
|
|
35
|
+
export declare function runShellBuiltin(input: Record<string, unknown>, shutdownSignal?: AbortSignal, platform?: ShellPlatform): Promise<ShellRunOutput>;
|
|
35
36
|
//# sourceMappingURL=os-shell.d.ts.map
|
|
@@ -2,27 +2,26 @@
|
|
|
2
2
|
* os.shell as a daemon builtin — the ONLY implementation.
|
|
3
3
|
*
|
|
4
4
|
* Every endpoint that offers the shared `os.shell` contract implements it
|
|
5
|
-
* locally
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* broken still be recovered.
|
|
5
|
+
* locally through this daemon builtin, on both headless hosts and Macs. The
|
|
6
|
+
* implementation is not named in the hashed contract, so both endpoints can
|
|
7
|
+
* offer the same contract. There is deliberately no gateway-compiled connector:
|
|
8
|
+
* shell execution needs a real process, which the isolate lane does not have,
|
|
9
|
+
* and running it on the daemon's own supervisor lets a device whose connector
|
|
10
|
+
* compiler is broken still be recovered.
|
|
12
11
|
*
|
|
13
|
-
* Keep the
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* credentials.
|
|
12
|
+
* Keep the argv, timeout bounds and returned shape in step with the shared
|
|
13
|
+
* contract in `packages/device-connectors/src/os-shell.ts`. Output is capped
|
|
14
|
+
* at 1MB per stream. A headless host runs `bash --noprofile --norc -c` in a
|
|
15
|
+
* minimal replacement environment so commands do not inherit daemon
|
|
16
|
+
* credentials. A Mac runs the signed-in user's `zsh -l -c` with the user's
|
|
17
|
+
* environment minus the daemon's credentials; the Mac app starts this daemon
|
|
18
|
+
* as its own child.
|
|
21
19
|
*
|
|
22
20
|
* LIFETIME: a run owns a process group for the duration of the call and no
|
|
23
21
|
* longer. Everything still in that group when the command returns is killed,
|
|
24
|
-
* which is what keeps a daemon from leaking processes
|
|
25
|
-
*
|
|
22
|
+
* which is what keeps a daemon from leaking processes: `&` and `nohup` alone
|
|
23
|
+
* do not leave that group. A process that explicitly creates a new session
|
|
24
|
+
* leaves the daemon's group ownership and is outside this cleanup. Cleanup is
|
|
26
25
|
* deliberate; what was a bug (#3629) is doing it QUIETLY -- a run used to
|
|
27
26
|
* report exit 0 while the poller it had just launched was being killed, so the
|
|
28
27
|
* loss surfaced as an unrelated failure much later. A run that leaves
|
|
@@ -33,6 +32,7 @@
|
|
|
33
32
|
import { existsSync } from 'node:fs';
|
|
34
33
|
import { homedir } from 'node:os';
|
|
35
34
|
import { isAbsolute } from 'node:path';
|
|
35
|
+
import { searchDirs } from '../agent-binaries.js';
|
|
36
36
|
import { countOwnedGroupSurvivors, releaseSupervisor, signalOwnedPosixProcessGroup, spawnSupervisedCli, terminateChild, } from '../automation-process.js';
|
|
37
37
|
/**
|
|
38
38
|
* A caller-supplied argument the builtin rejects before spawning anything.
|
|
@@ -69,17 +69,29 @@ function readTimeout(value) {
|
|
|
69
69
|
}
|
|
70
70
|
return Number(value);
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
function shellInvocation(platform, command) {
|
|
73
|
+
if (platform === 'macos') {
|
|
74
|
+
const env = { ...process.env };
|
|
75
|
+
delete env.WORKER_API_TOKEN;
|
|
76
|
+
delete env.LOBU_API_TOKEN;
|
|
77
|
+
delete env.LOBU_MEMORY_URL;
|
|
78
|
+
// An app-launched process starts with a stripped PATH.
|
|
79
|
+
env.PATH = [...searchDirs(), env.PATH ?? '/usr/bin:/bin'].join(':');
|
|
80
|
+
return { file: '/bin/zsh', args: ['-l', '-c', command], env };
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
file: 'bash',
|
|
84
|
+
args: ['--noprofile', '--norc', '-c', command],
|
|
85
|
+
env: {
|
|
86
|
+
PATH: process.env.PATH ?? '/usr/bin:/bin',
|
|
87
|
+
HOME: process.env.HOME ?? homedir(),
|
|
88
|
+
TMPDIR: process.env.TMPDIR ?? '/tmp',
|
|
89
|
+
LANG: 'C',
|
|
90
|
+
LC_ALL: 'C',
|
|
91
|
+
},
|
|
79
92
|
};
|
|
80
|
-
return env;
|
|
81
93
|
}
|
|
82
|
-
export async function runShellBuiltin(input, shutdownSignal) {
|
|
94
|
+
export async function runShellBuiltin(input, shutdownSignal, platform = 'headless') {
|
|
83
95
|
const command = typeof input.command === 'string' ? input.command.trim() : '';
|
|
84
96
|
if (!command)
|
|
85
97
|
throw new ShellInputError('command is required');
|
|
@@ -101,7 +113,8 @@ export async function runShellBuiltin(input, shutdownSignal) {
|
|
|
101
113
|
return await new Promise((resolve) => {
|
|
102
114
|
let supervised;
|
|
103
115
|
try {
|
|
104
|
-
|
|
116
|
+
const shell = shellInvocation(platform, command);
|
|
117
|
+
supervised = spawnSupervisedCli(shell.file, shell.args, shell.env, { stdin: 'pipe', cwd });
|
|
105
118
|
}
|
|
106
119
|
catch (error) {
|
|
107
120
|
const code = error.code;
|
|
@@ -40,6 +40,8 @@ export interface ExecutorClient {
|
|
|
40
40
|
* — multi-replica safe because the wait is Postgres-mediated.
|
|
41
41
|
*/
|
|
42
42
|
dispatchChromeAction(req: DispatchChromeActionRequest): Promise<Record<string, unknown>>;
|
|
43
|
+
/** Delegate a native device operation on behalf of the running parent action. */
|
|
44
|
+
executeConnectorOperation?(req: ExecuteConnectorOperationRequest, signal?: AbortSignal): Promise<ConnectorOperationResult>;
|
|
43
45
|
/** Spend only the current run's gateway-held HTTP credentials. */
|
|
44
46
|
httpFetch(runId: number, request: ConnectorHttpRequest, signal?: AbortSignal): Promise<ConnectorHttpResponse>;
|
|
45
47
|
/**
|
|
@@ -48,7 +50,6 @@ export interface ExecutorClient {
|
|
|
48
50
|
* re-spawn with the returned nudge.
|
|
49
51
|
*/
|
|
50
52
|
completeAutomation(runId: number, req: CompleteAutomationRequest): Promise<CompleteAutomationResponse>;
|
|
51
|
-
completeDeviceChat(runId: number, req: CompleteDeviceChatRequest): Promise<CompleteDeviceChatResponse>;
|
|
52
53
|
/**
|
|
53
54
|
* Report an agent turn. Fleet-only, so it posts to the shared worker route
|
|
54
55
|
* rather than the device-scoped `/me/runs/...` family.
|
|
@@ -68,8 +69,9 @@ export interface ExecutorClient {
|
|
|
68
69
|
* module's public surface is unchanged for importers, while the server annotates
|
|
69
70
|
* its request-body reads with the same shapes from that file.
|
|
70
71
|
*/
|
|
71
|
-
export type { CompleteActionRequest, CompleteAgentTurnRequest, CompleteAgentTurnResponse, CompleteAuthRequest, CompleteAutomationRequest, CompleteAutomationResponse,
|
|
72
|
-
import type { ConnectorHttpRequest, ConnectorHttpResponse, CompleteActionRequest, CompleteAgentTurnRequest, CompleteAgentTurnResponse, CompleteAuthRequest, CompleteAutomationRequest, CompleteAutomationResponse,
|
|
72
|
+
export type { CompleteActionRequest, CompleteAgentTurnRequest, CompleteAgentTurnResponse, CompleteAuthRequest, CompleteAutomationRequest, CompleteAutomationResponse, CompleteEmbeddingsRequest, CompleteRequest, ContentItem, DispatchChromeActionRequest, DispatchChromeActionResponse, EmbedEvent, EmitAuthArtifactRequest, HeartbeatRequest, HeartbeatResponse, OAuthCredentials, PollAuthSignalRequest, PollAuthSignalResponse, PollResponse, StreamBatch, } from "@lobu/core/contracts/worker/protocol";
|
|
73
|
+
import type { ConnectorHttpRequest, ConnectorHttpResponse, CompleteActionRequest, CompleteAgentTurnRequest, CompleteAgentTurnResponse, CompleteAuthRequest, CompleteAutomationRequest, CompleteAutomationResponse, CompleteEmbeddingsRequest, CompleteRequest, DispatchChromeActionRequest, EmbedEvent, EmitAuthArtifactRequest, ExecuteConnectorOperationRequest, HeartbeatRequest, HeartbeatResponse, PollAuthSignalRequest, PollAuthSignalResponse, PollResponse, StreamBatch } from "@lobu/core/contracts/worker/protocol";
|
|
74
|
+
import type { ConnectorOperationResult } from "@lobu/core/contracts/tools/manage-operations";
|
|
73
75
|
import type { AgentKind } from "@lobu/core/contracts/worker/device-automation";
|
|
74
76
|
/** Capability strings the worker advertises, keyed by name (e.g. `browser.debugger`). */
|
|
75
77
|
export type WorkerCapabilities = Record<string, boolean>;
|
|
@@ -229,6 +231,7 @@ export declare class WorkerClient implements ExecutorClient {
|
|
|
229
231
|
* times out. Throws on failure/timeout with the gateway's error message.
|
|
230
232
|
*/
|
|
231
233
|
dispatchChromeAction(req: DispatchChromeActionRequest): Promise<Record<string, unknown>>;
|
|
234
|
+
executeConnectorOperation(req: ExecuteConnectorOperationRequest, signal?: AbortSignal): Promise<ConnectorOperationResult>;
|
|
232
235
|
httpFetch(runId: number, request: ConnectorHttpRequest, signal?: AbortSignal): Promise<ConnectorHttpResponse>;
|
|
233
236
|
/**
|
|
234
237
|
* Health check
|
|
@@ -242,7 +245,6 @@ export declare class WorkerClient implements ExecutorClient {
|
|
|
242
245
|
*/
|
|
243
246
|
completeAutomation(runId: number, req: CompleteAutomationRequest): Promise<CompleteAutomationResponse>;
|
|
244
247
|
completeAgentTurn(req: CompleteAgentTurnRequest): Promise<CompleteAgentTurnResponse>;
|
|
245
|
-
completeDeviceChat(runId: number, req: CompleteDeviceChatRequest): Promise<CompleteDeviceChatResponse>;
|
|
246
248
|
get mcpWiring(): {
|
|
247
249
|
url: string;
|
|
248
250
|
bearer?: string;
|
|
@@ -311,6 +311,9 @@ export class WorkerClient {
|
|
|
311
311
|
throw new Error(result.error_message ??
|
|
312
312
|
`Chrome action '${req.action_key}' ${result.status === 'timeout' ? 'timed out' : 'failed'}`);
|
|
313
313
|
}
|
|
314
|
+
async executeConnectorOperation(req, signal) {
|
|
315
|
+
return this.requestJson('/api/workers/execute-operation', req, signal);
|
|
316
|
+
}
|
|
314
317
|
async httpFetch(runId, request, signal) {
|
|
315
318
|
return this.requestJson('/api/workers/http-fetch', { worker_id: this.id, run_id: runId, request }, signal);
|
|
316
319
|
}
|
|
@@ -360,9 +363,6 @@ export class WorkerClient {
|
|
|
360
363
|
async completeAgentTurn(req) {
|
|
361
364
|
return this.requestJson('/api/workers/complete-agent-turn', req);
|
|
362
365
|
}
|
|
363
|
-
async completeDeviceChat(runId, req) {
|
|
364
|
-
return this.requestJson(`/api/workers/me/runs/${runId}/complete-chat`, req);
|
|
365
|
-
}
|
|
366
366
|
get mcpWiring() {
|
|
367
367
|
if (!this.authToken)
|
|
368
368
|
return undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default active-run limit for paired device daemons (macOS and headless).
|
|
3
|
+
* Device runs mostly wait on I/O, so half the host's threads leaves room for
|
|
4
|
+
* the user's own work; keep at least two slots so a long command cannot
|
|
5
|
+
* monopolize the daemon, and cap the default to bound local agent load.
|
|
6
|
+
*/
|
|
7
|
+
export declare function defaultDeviceMaxConcurrentJobs(hostThreads?: number): number;
|
|
8
|
+
//# sourceMappingURL=device-concurrency.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { availableParallelism } from 'node:os';
|
|
2
|
+
const MIN_DEVICE_MAX_CONCURRENT_JOBS = 2;
|
|
3
|
+
const MAX_DEVICE_MAX_CONCURRENT_JOBS = 8;
|
|
4
|
+
/**
|
|
5
|
+
* Default active-run limit for paired device daemons (macOS and headless).
|
|
6
|
+
* Device runs mostly wait on I/O, so half the host's threads leaves room for
|
|
7
|
+
* the user's own work; keep at least two slots so a long command cannot
|
|
8
|
+
* monopolize the daemon, and cap the default to bound local agent load.
|
|
9
|
+
*/
|
|
10
|
+
export function defaultDeviceMaxConcurrentJobs(hostThreads = availableParallelism()) {
|
|
11
|
+
return Math.min(MAX_DEVICE_MAX_CONCURRENT_JOBS, Math.max(MIN_DEVICE_MAX_CONCURRENT_JOBS, Math.floor(hostThreads / 2)));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=device-concurrency.js.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { Env } from '@lobu/connector-sdk';
|
|
8
8
|
import type { AgentKind } from '@lobu/core/contracts/worker/device-automation';
|
|
9
|
-
import type
|
|
9
|
+
import { type ExecutorClient, type PollResponse } from './client.js';
|
|
10
10
|
import type { SyncExecutor } from '../executor/interface.js';
|
|
11
11
|
/**
|
|
12
12
|
* Resolve the executable compiled code for a job.
|