@lobu/core 7.1.0 → 8.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 (41) hide show
  1. package/dist/capabilities.d.ts +1 -1
  2. package/dist/capabilities.d.ts.map +1 -1
  3. package/dist/capabilities.js +1 -0
  4. package/dist/capabilities.js.map +1 -1
  5. package/dist/index.d.ts +8 -6
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +19 -7
  8. package/dist/index.js.map +1 -1
  9. package/dist/lobu-guidance.d.ts +5 -0
  10. package/dist/lobu-guidance.d.ts.map +1 -0
  11. package/dist/lobu-guidance.js +51 -0
  12. package/dist/lobu-guidance.js.map +1 -0
  13. package/dist/lobu-toml-schema.d.ts +49 -0
  14. package/dist/lobu-toml-schema.d.ts.map +1 -1
  15. package/dist/lobu-toml-schema.js +48 -0
  16. package/dist/lobu-toml-schema.js.map +1 -1
  17. package/dist/modules.d.ts +1 -47
  18. package/dist/modules.d.ts.map +1 -1
  19. package/dist/modules.js +0 -74
  20. package/dist/modules.js.map +1 -1
  21. package/dist/types.d.ts +38 -1
  22. package/dist/types.d.ts.map +1 -1
  23. package/dist/utils/encryption.d.ts +21 -0
  24. package/dist/utils/encryption.d.ts.map +1 -1
  25. package/dist/utils/encryption.js +50 -12
  26. package/dist/utils/encryption.js.map +1 -1
  27. package/dist/utils/session-file.d.ts +86 -0
  28. package/dist/utils/session-file.d.ts.map +1 -0
  29. package/dist/utils/session-file.js +104 -0
  30. package/dist/utils/session-file.js.map +1 -0
  31. package/dist/worker/auth.d.ts +18 -0
  32. package/dist/worker/auth.d.ts.map +1 -1
  33. package/dist/worker/auth.js +13 -0
  34. package/dist/worker/auth.js.map +1 -1
  35. package/dist/worker/transport.d.ts +0 -5
  36. package/dist/worker/transport.d.ts.map +1 -1
  37. package/dist/worker/wire.d.ts +105 -0
  38. package/dist/worker/wire.d.ts.map +1 -0
  39. package/dist/worker/wire.js +18 -0
  40. package/dist/worker/wire.js.map +1 -0
  41. package/package.json +1 -1
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Gateway ↔ worker wire contract.
3
+ *
4
+ * `MessagePayload` is what `MessageConsumer` (gateway) enqueues on the runs
5
+ * queue, what `EmbeddedDeploymentManager.dispatch*` writes to the worker SSE
6
+ * stream, and what the worker's `GatewayClient.handleThreadMessage` /
7
+ * `handleExecJob` consumes. Same shape on both sides — keep it here.
8
+ *
9
+ * Before this lived in core, the worker had its own `MessagePayload`
10
+ * declaration that was a structural subset of the gateway's (missing
11
+ * `organizationId`, `networkConfig`, `egressConfig`, `mcpConfig`, `nixConfig`,
12
+ * `preApprovedTools`). At runtime the worker's zod schema was patched with
13
+ * `.passthrough()` so the extra fields survived parsing, but the static type
14
+ * silently lied. Hoisting closes the gap.
15
+ */
16
+ import type { AgentEgressConfig, AgentMcpConfig, AgentOptions, NetworkConfig, NixConfig } from "../types";
17
+ /**
18
+ * Job type for queue messages.
19
+ * - `message`: standard agent message execution.
20
+ * - `exec`: direct command execution in the sandbox.
21
+ */
22
+ export type JobType = "message" | "exec";
23
+ /**
24
+ * Universal message payload for every gateway → worker hop.
25
+ * Used by: platform inbound → runs queue → MessageConsumer → worker.
26
+ */
27
+ export interface MessagePayload {
28
+ userId: string;
29
+ conversationId: string;
30
+ messageId: string;
31
+ channelId: string;
32
+ /**
33
+ * Team/workspace ID. Required in the gateway-produced payload (always
34
+ * stamped by `buildMessagePayload`), but optional in the wire type
35
+ * because Slack carries the workspace ID in `platformMetadata` and the
36
+ * worker reads it defensively (`payload.teamId ?? platformMetadata.teamId`).
37
+ * The worker SSE schema parses it with `z.string().optional()`.
38
+ */
39
+ teamId?: string;
40
+ /** Agent / session ID for tenant isolation. */
41
+ agentId: string;
42
+ /**
43
+ * Owning organization of the agent. Plumbed through so child queries
44
+ * (grants, user-agents, channel-bindings, secrets) can scope by org —
45
+ * agent IDs are per-org-unique, so `agent_id = ?` alone is ambiguous.
46
+ */
47
+ organizationId?: string;
48
+ /** Bot identifier. */
49
+ botId: string;
50
+ /** Platform name (`slack`, `telegram`, ...). */
51
+ platform: string;
52
+ messageText: string;
53
+ platformMetadata: Record<string, unknown>;
54
+ agentOptions: AgentOptions;
55
+ networkConfig?: NetworkConfig;
56
+ /**
57
+ * The runs.id of the row the runs-queue claimed when this message was
58
+ * dispatched. Threaded all the way to the worker so the per-run
59
+ * agent_transcript_snapshot POST can attribute the snapshot to the
60
+ * correct run unambiguously — codex P1#1 on PR #865.
61
+ */
62
+ runId?: number;
63
+ /**
64
+ * Per-run worker JWT bound to `runId` above. Minted by the runs-queue
65
+ * dispatcher (`MessageConsumer.handleMessage`) so the snapshot route can
66
+ * require `tokenData.runId === body.runId` and reject any attempt by a
67
+ * same-(org, agent, conv) deployment-lifetime token to write under a
68
+ * different run's slot — codex round 2 finding A on PR #865.
69
+ */
70
+ runJobToken?: string;
71
+ /** Per-agent egress judge configuration. */
72
+ egressConfig?: AgentEgressConfig;
73
+ /** Per-agent MCP configuration (additive to global MCPs). */
74
+ mcpConfig?: AgentMcpConfig;
75
+ /** Nix environment configuration for the agent workspace. */
76
+ nixConfig?: NixConfig;
77
+ /**
78
+ * MCP tool grant patterns the operator has pre-approved.
79
+ * Synced to the grant store at deployment time to bypass the approval card.
80
+ */
81
+ preApprovedTools?: string[];
82
+ /**
83
+ * Job ID from the gateway (set when the payload rode through the worker
84
+ * SSE stream). Optional — direct-enqueue paths leave it unset.
85
+ */
86
+ jobId?: string;
87
+ /** Job type (default: `message`). */
88
+ jobType?: JobType;
89
+ /** Unique ID for the exec job (for response routing). */
90
+ execId?: string;
91
+ /** Command to execute. */
92
+ execCommand?: string;
93
+ /** Working directory for the command. */
94
+ execCwd?: string;
95
+ /** Additional environment variables. */
96
+ execEnv?: Record<string, string>;
97
+ /** Timeout in milliseconds. */
98
+ execTimeout?: number;
99
+ }
100
+ /** Queued message envelope used by the worker's in-process batcher. */
101
+ export interface QueuedMessage {
102
+ payload: MessagePayload;
103
+ timestamp: number;
104
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,CAAC,EAAE,MAAM,CAAC;IAEf,qCAAqC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAGlB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,+BAA+B;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /**
3
+ * Gateway ↔ worker wire contract.
4
+ *
5
+ * `MessagePayload` is what `MessageConsumer` (gateway) enqueues on the runs
6
+ * queue, what `EmbeddedDeploymentManager.dispatch*` writes to the worker SSE
7
+ * stream, and what the worker's `GatewayClient.handleThreadMessage` /
8
+ * `handleExecJob` consumes. Same shape on both sides — keep it here.
9
+ *
10
+ * Before this lived in core, the worker had its own `MessagePayload`
11
+ * declaration that was a structural subset of the gateway's (missing
12
+ * `organizationId`, `networkConfig`, `egressConfig`, `mcpConfig`, `nixConfig`,
13
+ * `preApprovedTools`). At runtime the worker's zod schema was patched with
14
+ * `.passthrough()` so the extra fields survived parsing, but the static type
15
+ * silently lied. Hoisting closes the gap.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ //# sourceMappingURL=wire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.js","sourceRoot":"","sources":["../../src/worker/wire.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/core",
3
- "version": "7.1.0",
3
+ "version": "8.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Core types and utilities for Lobu agent platform",
6
6
  "repository": {