@lobu/runtime-device 20.0.0 → 20.0.1

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 (59) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +5 -5
  3. package/npm-shrinkwrap.json +23 -23
  4. package/package.json +1 -1
  5. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +14 -4
  6. package/vendor/cli/dist/commands/_lib/apply/deployment.js +1 -1
  7. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +10 -3
  8. package/vendor/cli/dist/commands/_lib/apply/desired-state.js +45 -6
  9. package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +3 -0
  10. package/vendor/cli/dist/commands/_lib/apply/diff.js +10 -3
  11. package/vendor/cli/dist/commands/_lib/apply/map-config.js +17 -12
  12. package/vendor/cli/dist/commands/_lib/apply/shared.d.ts +6 -2
  13. package/vendor/cli/dist/commands/_lib/apply/shared.js +11 -4
  14. package/vendor/cli/dist/commands/call.js +9 -3
  15. package/vendor/cli/dist/commands/dev.js +2 -1
  16. package/vendor/cli/dist/commands/doctor.d.ts +6 -0
  17. package/vendor/cli/dist/commands/doctor.js +26 -0
  18. package/vendor/cli/dist/commands/init.d.ts +3 -1
  19. package/vendor/cli/dist/commands/init.js +26 -15
  20. package/vendor/cli/dist/commands/memory/_lib/mcp.d.ts +0 -6
  21. package/vendor/cli/dist/commands/memory/_lib/mcp.js +1 -14
  22. package/vendor/cli/dist/commands/org.js +8 -0
  23. package/vendor/cli/dist/commands/whoami.d.ts +1 -0
  24. package/vendor/cli/dist/commands/whoami.js +10 -4
  25. package/vendor/cli/dist/config/define.d.ts +21 -6
  26. package/vendor/cli/dist/config/define.js +4 -0
  27. package/vendor/cli/dist/connectors/chat-automation-events.ts +33 -0
  28. package/vendor/cli/dist/connectors/discord.ts +2 -0
  29. package/vendor/cli/dist/connectors/gchat.ts +2 -0
  30. package/vendor/cli/dist/connectors/google_drive.ts +210 -40
  31. package/vendor/cli/dist/connectors/slack-automation-events.ts +0 -31
  32. package/vendor/cli/dist/connectors/slack.ts +2 -2
  33. package/vendor/cli/dist/connectors/teams.ts +2 -0
  34. package/vendor/cli/dist/connectors/telegram.ts +2 -0
  35. package/vendor/cli/dist/connectors/whatsapp.ts +2 -0
  36. package/vendor/cli/dist/index.js +3 -1
  37. package/vendor/cli/dist/internal/gateway-url.d.ts +4 -4
  38. package/vendor/cli/dist/internal/gateway-url.js +4 -4
  39. package/vendor/cli/dist/mac-auth.js +3 -1
  40. package/vendor/cli/dist/runtime-components.json +4 -4
  41. package/vendor/cli/package.json +1 -1
  42. package/vendor/connector-sdk/dist/index.d.ts +1 -1
  43. package/vendor/connector-sdk/dist/logger.js +4 -1
  44. package/vendor/connector-sdk/dist/reaction-sdk.d.ts +9 -0
  45. package/vendor/connector-sdk/package.json +1 -1
  46. package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +13 -1
  47. package/vendor/connector-worker/dist/agent-turn/workspace.d.ts +9 -0
  48. package/vendor/connector-worker/dist/agent-turn/workspace.js +27 -1
  49. package/vendor/connector-worker/dist/daemon/client.d.ts +8 -2
  50. package/vendor/connector-worker/dist/daemon/client.js +3 -2
  51. package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +1 -0
  52. package/vendor/connector-worker/dist/daemon/poll-loop.js +20 -2
  53. package/vendor/connector-worker/package.json +1 -1
  54. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +16 -0
  55. package/vendor/core/dist/contracts/tools/manage-automations.js +12 -3
  56. package/vendor/core/dist/contracts/worker/protocol.d.ts +9 -0
  57. package/vendor/core/dist/contracts/worker/protocol.js +10 -1
  58. package/vendor/core/dist/logger.js +4 -2
  59. package/vendor/core/package.json +1 -1
@@ -13,6 +13,8 @@ export interface InitOptions {
13
13
  noSentry?: boolean;
14
14
  hostedSlack?: boolean;
15
15
  listProviders?: boolean;
16
+ /** Scaffold files without installing project dependencies. */
17
+ skipInstall?: boolean;
16
18
  /**
17
19
  * Bootstrap a complete, re-appliable project from an existing Lobu Cloud org
18
20
  * (the inverse of `lobu apply`) instead of scaffolding a blank project. Never
@@ -32,5 +34,5 @@ export declare function initCommand(cwd?: string, projectNameArg?: string, optio
32
34
  * Warn-don't-fail: a broken/missing installer must not abort the scaffold, so
33
35
  * the failure is returned as a warning string for the caller to print.
34
36
  */
35
- export declare function installScaffoldedProjectDeps(projectDir: string): string | null;
37
+ export declare function installScaffoldedProjectDeps(projectDir: string, stdio?: "inherit" | "pipe"): string | null;
36
38
  //# sourceMappingURL=init.d.ts.map
@@ -8,6 +8,7 @@ import chalk from "chalk";
8
8
  import ora from "ora";
9
9
  import { getProviderById, loadProviderRegistry, } from "../commands/providers/registry.js";
10
10
  import { DEFAULT_LOBU_MCP_URL } from "../internal/context.js";
11
+ import { agentApiBase } from "../internal/gateway-url.js";
11
12
  import { setLocalEnvValue } from "../internal/local-env.js";
12
13
  import { renderTemplate } from "../utils/template.js";
13
14
  import { installProjectDeps } from "./_lib/ensure-deps-installed.js";
@@ -260,13 +261,16 @@ export async function initCommand(cwd = process.cwd(), projectNameArg, options =
260
261
  // Same package.json/tsconfig the blank scaffold writes, so the bootstrapped
261
262
  // lobu.config.ts can resolve @lobu/cli/config + re-apply outside this monorepo.
262
263
  await scaffoldProjectPackaging(projectDir, projectName, cliVersion);
263
- const depsSpinner = ora("Installing project dependencies...").start();
264
- const depsWarning = installScaffoldedProjectDeps(projectDir);
265
- if (depsWarning) {
266
- depsSpinner.warn(depsWarning);
264
+ if (options.skipInstall) {
265
+ console.log(chalk.yellow("\nSkipped dependency installation. Run `npm install` (or `bun install`) before `lobu apply`."));
267
266
  }
268
267
  else {
269
- depsSpinner.succeed("Project dependencies installed");
268
+ console.log(chalk.dim("\nInstalling project dependencies (this may take a few minutes)..."));
269
+ const depsWarning = installScaffoldedProjectDeps(projectDir, "inherit");
270
+ if (depsWarning)
271
+ console.log(chalk.yellow(`\n⚠ ${depsWarning}`));
272
+ else
273
+ console.log(chalk.green("✓ Project dependencies installed"));
270
274
  }
271
275
  if (!here) {
272
276
  console.log(chalk.cyan(`\n Next: cd ${projectName}\n`));
@@ -581,18 +585,25 @@ export async function initCommand(cwd = process.cwd(), projectNameArg, options =
581
585
  await scaffoldProjectPackaging(projectDir, projectName, cliVersion);
582
586
  await mkdir(join(projectDir, "connectors"), { recursive: true });
583
587
  await writeFile(join(projectDir, "connectors", ".gitkeep"), "");
584
- // Install the freshly-declared devDependencies now so the runtime can
585
- // resolve @lobu/connector-sdk from the project and editor types work
586
- // out of the box. Warn-don't-fail (printed after the spinner settles).
587
- spinner.text = "Installing project dependencies...";
588
- const depsWarning = installScaffoldedProjectDeps(projectDir);
589
- spinner.text = "Creating Lobu project...";
590
588
  await renderTemplate("AGENTS.md.tmpl", variables, join(projectDir, "AGENTS.md"));
591
589
  await renderTemplate("TESTING.md.tmpl", variables, join(projectDir, "TESTING.md"));
592
- spinner.succeed("Project created successfully!");
590
+ // Keep the potentially long install visible. Hiding installer output behind
591
+ // the scaffold spinner makes a healthy first run look wedged on small hosts.
592
+ spinner.succeed("Project files created");
593
+ let depsWarning = null;
594
+ if (options.skipInstall) {
595
+ console.log(chalk.yellow("\nSkipped dependency installation. Run `npm install` (or `bun install`) before `lobu apply`."));
596
+ }
597
+ else {
598
+ console.log(chalk.dim("\nInstalling project dependencies (this may take a few minutes)..."));
599
+ depsWarning = installScaffoldedProjectDeps(projectDir, "inherit");
600
+ }
593
601
  if (depsWarning) {
594
602
  console.log(chalk.yellow(`\n⚠ ${depsWarning}`));
595
603
  }
604
+ else if (!options.skipInstall) {
605
+ console.log(chalk.green("✓ Project dependencies installed"));
606
+ }
596
607
  const gatewayUrl = `http://localhost:${gatewayPort}`;
597
608
  console.log(chalk.green("\n✓ Lobu initialized!\n"));
598
609
  console.log(chalk.bold("Next steps:\n"));
@@ -611,7 +622,7 @@ export async function initCommand(cwd = process.cwd(), projectNameArg, options =
611
622
  console.log(chalk.cyan(` ${n++}. Link the project to Lobu Cloud and register it: lobu login && lobu org set <slug> && lobu apply`));
612
623
  console.log(chalk.dim(" Then `lobu run` prints a short-lived `/lobu link <code>` for the hosted Slack bot."));
613
624
  }
614
- console.log(chalk.cyan(` ${n++}. API docs: ${gatewayUrl}/api/docs`));
625
+ console.log(chalk.cyan(` ${n++}. API docs: ${agentApiBase(gatewayUrl)}/api/docs`));
615
626
  console.log(chalk.dim("\n See README.md for layout, AGENTS.md for the agent contract.\n"));
616
627
  }
617
628
  catch (error) {
@@ -737,9 +748,9 @@ async function generateLobuConfig(projectDir, options) {
737
748
  * Warn-don't-fail: a broken/missing installer must not abort the scaffold, so
738
749
  * the failure is returned as a warning string for the caller to print.
739
750
  */
740
- export function installScaffoldedProjectDeps(projectDir) {
751
+ export function installScaffoldedProjectDeps(projectDir, stdio = "pipe") {
741
752
  try {
742
- installProjectDeps(projectDir, { stdio: "pipe" });
753
+ installProjectDeps(projectDir, { stdio });
743
754
  return null;
744
755
  }
745
756
  catch (error) {
@@ -12,10 +12,4 @@ export declare function mcpRpc(mcpUrl: string, method: string, params?: Record<s
12
12
  * Call a Lobu memory tool over the REST proxy at `POST /api/{orgSlug}/{toolName}`.
13
13
  */
14
14
  export declare function restToolCall<T = unknown>(mcpUrl: string, toolName: string, args: Record<string, unknown>, contextName?: string): Promise<T>;
15
- /**
16
- * GET sibling of `restToolCall` — fetches `${origin}/api/${orgSlug}/${path}`.
17
- * Used by `lobu call --list` to hit `GET /api/<org>/tools` without spinning up
18
- * an MCP session for discovery.
19
- */
20
- export declare function restGet<T = unknown>(mcpUrl: string, path: string, contextName?: string): Promise<T>;
21
15
  //# sourceMappingURL=mcp.d.ts.map
@@ -152,8 +152,7 @@ export async function mcpRpc(mcpUrl, method, params, contextName) {
152
152
  * the raw handler result as parsed JSON (no MCP envelope). Throws `ApiError` on
153
153
  * non-2xx, surfacing the server's `{ error }` message when present.
154
154
  *
155
- * `restToolCall` (POST) and `restGet` (GET) are thin wrappers — they differ only
156
- * in HTTP method/body and the labels used in the no-org and failure messages.
155
+ * `restToolCall` is a thin POST wrapper used by the CLI call path.
157
156
  */
158
157
  async function restCall(mcpUrl, path, opts, contextName) {
159
158
  const headers = {};
@@ -208,16 +207,4 @@ export function restToolCall(mcpUrl, toolName, args, contextName) {
208
207
  noOrgMessage: (url) => `Cannot call ${toolName}: no org slug on MCP URL ${url}. Use --org or run: lobu memory org set <org>`,
209
208
  }, contextName);
210
209
  }
211
- /**
212
- * GET sibling of `restToolCall` — fetches `${origin}/api/${orgSlug}/${path}`.
213
- * Used by `lobu call --list` to hit `GET /api/<org>/tools` without spinning up
214
- * an MCP session for discovery.
215
- */
216
- export function restGet(mcpUrl, path, contextName) {
217
- return restCall(mcpUrl, path, {
218
- method: "GET",
219
- failureLabel: `GET ${path}`,
220
- noOrgMessage: (url) => `Cannot GET ${path}: no org slug on MCP URL ${url}. Use --org or run: lobu org set <slug>`,
221
- }, contextName);
222
- }
223
210
  //# sourceMappingURL=mcp.js.map
@@ -29,6 +29,14 @@ export async function orgCurrentCommand(options) {
29
29
  }
30
30
  export async function orgSetCommand(slug, options) {
31
31
  const target = await resolveContext(options?.context);
32
+ const orgs = await listOrganizations({ context: target.name });
33
+ const current = await getActiveOrg(target.name);
34
+ if (current !== slug && !orgs.some((org) => org.slug === slug)) {
35
+ const available = orgs.map((org) => org.slug).join(", ");
36
+ throw new Error(available
37
+ ? `Organization "${slug}" is not available for this login. Available: ${available}`
38
+ : `Organization "${slug}" is not available for this login.`);
39
+ }
32
40
  await setActiveOrg(slug, target.name);
33
41
  console.log(chalk.green(`\n Active org for context ${target.name} set to ${slug}\n`));
34
42
  }
@@ -1,5 +1,6 @@
1
1
  export declare function whoamiCommand(options?: {
2
2
  context?: string;
3
3
  json?: boolean;
4
+ includeTokens?: boolean;
4
5
  }): Promise<void>;
5
6
  //# sourceMappingURL=whoami.d.ts.map
@@ -13,7 +13,7 @@ export async function whoamiCommand(options) {
13
13
  const target = await resolveContext(options?.context);
14
14
  const creds = await refreshCredentials(await loadCredentials(target.name), target.name);
15
15
  if (options?.json) {
16
- await emitJson(target, creds);
16
+ await emitJson(target, creds, options.includeTokens ?? false);
17
17
  return;
18
18
  }
19
19
  if (!creds) {
@@ -45,7 +45,7 @@ export async function whoamiCommand(options) {
45
45
  }
46
46
  console.log();
47
47
  }
48
- async function emitJson(target, creds) {
48
+ async function emitJson(target, creds, includeTokens) {
49
49
  const local = isLoopbackUrl(target.url);
50
50
  // For loopback contexts with no stored creds, getAgentApiToken transparently
51
51
  // POSTs /api/local-init to mint a worker PAT + session — the same zero-config
@@ -80,8 +80,14 @@ async function emitJson(target, creds) {
80
80
  email: effective?.email,
81
81
  name: effective?.name,
82
82
  userId: effective?.userId,
83
- accessToken: effective?.accessToken,
84
- workerToken: workerToken ?? effective?.accessToken,
83
+ hasAccessToken: Boolean(effective?.accessToken),
84
+ hasWorkerToken: Boolean(workerToken ?? effective?.accessToken),
85
+ ...(includeTokens
86
+ ? {
87
+ accessToken: effective?.accessToken,
88
+ workerToken: workerToken ?? effective?.accessToken,
89
+ }
90
+ : {}),
85
91
  expiresAt: effective?.expiresAt,
86
92
  orgSlug,
87
93
  personalOrgSlug,
@@ -9,7 +9,7 @@
9
9
  * Automation reactions) live in their own modules; these objects only declare
10
10
  * config and references.
11
11
  */
12
- import type { AutomationEventTrigger, AutomationScheduleTrigger, AutomationWorkspaceEventTrigger, ConnectorClass, ConnectorRuntime, Dimension, EventSet, Measure, ReactionClient, ReactionContext, Segment } from "@lobu/connector-sdk";
12
+ import type { AutomationEventTrigger, AutomationScheduleTrigger, AutomationWorkspaceEventTrigger, ConnectorClass, ConnectorRuntime, Dimension, EventSet, Measure, ReactionClient, AutomationScriptContext, ReactionContext, Segment } from "@lobu/connector-sdk";
13
13
  import { type StringOptions, type TOptional, type TSchema, type TString } from "@sinclair/typebox";
14
14
  import type { SecretRef } from "./secret.js";
15
15
  /** A connector referenced by its key, or by the class produced by `defineConnector`. */
@@ -413,6 +413,14 @@ export declare function connectorFromFile<_Connector extends ConnectorClassExpor
413
413
  * `<Handler>` generic on {@link reactionFromFile} against the referenced module.
414
414
  */
415
415
  export type ReactionHandler = (ctx: ReactionContext, client: ReactionClient, params?: Record<string, unknown>) => Promise<unknown>;
416
+ export type AutomationScriptHandler = (ctx: AutomationScriptContext, client: ReactionClient, params?: Record<string, unknown>) => Promise<unknown>;
417
+ export interface ScriptSource {
418
+ readonly kind: "scriptSource";
419
+ path: string;
420
+ params?: Record<string, unknown>;
421
+ }
422
+ /** Execute a local TypeScript job directly, with the owning agent's SDK permissions. */
423
+ export declare function scriptFromFile<_Handler extends AutomationScriptHandler = AutomationScriptHandler>(path: string, params?: Record<string, unknown>): ScriptSource;
416
424
  /**
417
425
  * A local reaction source file to compile + run in a sandboxed isolate when the
418
426
  * Automation fires. Built with {@link reactionFromFile} and set on
@@ -475,6 +483,8 @@ export interface Automation {
475
483
  slug: string;
476
484
  /** Owning agent (handle or id). Every Automation belongs to exactly one agent. */
477
485
  agent: Agent | string;
486
+ /** Script job or agent execution. Omitted preserves the stored executor; "agent" clears a script executor. */
487
+ executor?: ScriptSource | "agent";
478
488
  name?: string;
479
489
  description?: string;
480
490
  /**
@@ -501,11 +511,12 @@ export interface Automation {
501
511
  * Automation until the next `lobu apply`; re-applying is the explicit upgrade
502
512
  * action for a declarative project.
503
513
  *
504
- * Supply {@link Automation.prompt}, `skills`, or a {@link Automation.reaction}
505
- * script. Any one of the three is required for schedule triggers, event
514
+ * Supply {@link Automation.prompt}, `skills`, a {@link Automation.reaction}
515
+ * script, or an {@link Automation.executor} script. Any one is required for schedule triggers, event
506
516
  * triggers with execution `"window"`, and Automations with no triggers
507
- * (manual runs); an event trigger with execution `"turn"` may omit all three,
508
- * since the incoming event is the content and a built-in default applies.
517
+ * (manual runs); an event trigger with execution `"turn"` may omit all
518
+ * instruction sources, since the incoming event is the content and a built-in
519
+ * default applies.
509
520
  */
510
521
  skills?: string[];
511
522
  /**
@@ -550,8 +561,12 @@ export interface Automation {
550
561
  * client, params?) => …` ({@link ReactionHandler}). Kept in its own file (not
551
562
  * inline) so your IDE type-checks it; the path must stay under the config
552
563
  * directory.
564
+ *
565
+ * Omit to preserve a previously installed reaction. Set explicitly to `null`
566
+ * to remove it — required when switching a reaction-driven Automation to a
567
+ * script executor so the same work is not performed twice.
553
568
  */
554
- reaction?: ReactionSource;
569
+ reaction?: ReactionSource | null;
555
570
  }
556
571
  export declare function defineAutomation(config: Omit<Automation, "kind">): Automation;
557
572
  /**
@@ -115,6 +115,10 @@ export function defineConnection(config) {
115
115
  export function connectorFromFile(path) {
116
116
  return { kind: "connectorSource", path };
117
117
  }
118
+ /** Execute a local TypeScript job directly, with the owning agent's SDK permissions. */
119
+ export function scriptFromFile(path, params) {
120
+ return { kind: "scriptSource", path, ...(params ? { params } : {}) };
121
+ }
118
122
  /**
119
123
  * Reference a local reaction source file to compile + ship at apply time.
120
124
  *
@@ -0,0 +1,33 @@
1
+ import type { ConnectorAutomationEvent } from "@lobu/connector-sdk";
2
+
3
+ // All server chat adapters use the same normalized message signal and turn
4
+ // routing. Keep the catalog aligned with that shared runtime capability.
5
+ export const CHAT_AUTOMATION_EVENTS: ConnectorAutomationEvent[] = [
6
+ {
7
+ key: "message.created",
8
+ label: "A message is sent",
9
+ description: "Runs for messages in the selected conversation scope.",
10
+ resourceType: "channel",
11
+ filterSchema: {
12
+ type: "object",
13
+ properties: {
14
+ channel_id: {
15
+ type: "string",
16
+ title: "Channel",
17
+ description: "Optional channel or direct-message identifier.",
18
+ },
19
+ mention_only: {
20
+ type: "boolean",
21
+ title: "Only when mentioned",
22
+ },
23
+ },
24
+ },
25
+ capabilities: { steering: true, replyToSource: true },
26
+ defaults: {
27
+ execution: "turn",
28
+ activeRun: "steer",
29
+ output: "reply_to_source",
30
+ },
31
+ },
32
+ ];
33
+
@@ -2,11 +2,13 @@ import {
2
2
  type ConnectorDefinition,
3
3
  IntegrationConnector,
4
4
  } from "@lobu/connector-sdk";
5
+ import { CHAT_AUTOMATION_EVENTS } from "./chat-automation-events.js";
5
6
 
6
7
  export default class DiscordConnector extends IntegrationConnector {
7
8
  readonly definition: ConnectorDefinition = {
8
9
  key: "discord",
9
10
  kind: "integration",
11
+ automationEvents: CHAT_AUTOMATION_EVENTS,
10
12
  name: "Discord",
11
13
  description:
12
14
  "Connect a Discord bot and route server conversations to Lobu agents.",
@@ -2,11 +2,13 @@ import {
2
2
  type ConnectorDefinition,
3
3
  IntegrationConnector,
4
4
  } from "@lobu/connector-sdk";
5
+ import { CHAT_AUTOMATION_EVENTS } from "./chat-automation-events.js";
5
6
 
6
7
  export default class GoogleChatConnector extends IntegrationConnector {
7
8
  readonly definition: ConnectorDefinition = {
8
9
  key: "gchat",
9
10
  kind: "integration",
11
+ automationEvents: CHAT_AUTOMATION_EVENTS,
10
12
  name: "Google Chat",
11
13
  description: "Connect a Google Chat app to Lobu.",
12
14
  version: "1.0.2",