@lobu/worker 2.8.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 (117) hide show
  1. package/dist/core/error-handler.d.ts +7 -0
  2. package/dist/core/error-handler.d.ts.map +1 -0
  3. package/dist/core/error-handler.js +58 -0
  4. package/dist/core/error-handler.js.map +1 -0
  5. package/dist/core/project-scanner.d.ts +9 -0
  6. package/dist/core/project-scanner.d.ts.map +1 -0
  7. package/dist/core/project-scanner.js +64 -0
  8. package/dist/core/project-scanner.js.map +1 -0
  9. package/dist/core/types.d.ts +102 -0
  10. package/dist/core/types.d.ts.map +1 -0
  11. package/dist/core/types.js +8 -0
  12. package/dist/core/types.js.map +1 -0
  13. package/dist/core/url-utils.d.ts +5 -0
  14. package/dist/core/url-utils.d.ts.map +1 -0
  15. package/dist/core/url-utils.js +13 -0
  16. package/dist/core/url-utils.js.map +1 -0
  17. package/dist/core/workspace.d.ts +29 -0
  18. package/dist/core/workspace.d.ts.map +1 -0
  19. package/dist/core/workspace.js +104 -0
  20. package/dist/core/workspace.js.map +1 -0
  21. package/dist/embedded/just-bash-bootstrap.d.ts +21 -0
  22. package/dist/embedded/just-bash-bootstrap.d.ts.map +1 -0
  23. package/dist/embedded/just-bash-bootstrap.js +215 -0
  24. package/dist/embedded/just-bash-bootstrap.js.map +1 -0
  25. package/dist/gateway/gateway-integration.d.ts +57 -0
  26. package/dist/gateway/gateway-integration.d.ts.map +1 -0
  27. package/dist/gateway/gateway-integration.js +209 -0
  28. package/dist/gateway/gateway-integration.js.map +1 -0
  29. package/dist/gateway/message-batcher.d.ts +27 -0
  30. package/dist/gateway/message-batcher.d.ts.map +1 -0
  31. package/dist/gateway/message-batcher.js +102 -0
  32. package/dist/gateway/message-batcher.js.map +1 -0
  33. package/dist/gateway/sse-client.d.ts +74 -0
  34. package/dist/gateway/sse-client.d.ts.map +1 -0
  35. package/dist/gateway/sse-client.js +748 -0
  36. package/dist/gateway/sse-client.js.map +1 -0
  37. package/dist/gateway/types.d.ts +60 -0
  38. package/dist/gateway/types.d.ts.map +1 -0
  39. package/dist/gateway/types.js +6 -0
  40. package/dist/gateway/types.js.map +1 -0
  41. package/dist/index.d.ts +3 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +112 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/instructions/builder.d.ts +8 -0
  46. package/dist/instructions/builder.d.ts.map +1 -0
  47. package/dist/instructions/builder.js +53 -0
  48. package/dist/instructions/builder.js.map +1 -0
  49. package/dist/instructions/providers.d.ts +13 -0
  50. package/dist/instructions/providers.d.ts.map +1 -0
  51. package/dist/instructions/providers.js +26 -0
  52. package/dist/instructions/providers.js.map +1 -0
  53. package/dist/modules/lifecycle.d.ts +18 -0
  54. package/dist/modules/lifecycle.d.ts.map +1 -0
  55. package/dist/modules/lifecycle.js +56 -0
  56. package/dist/modules/lifecycle.js.map +1 -0
  57. package/dist/openclaw/custom-tools.d.ts +17 -0
  58. package/dist/openclaw/custom-tools.d.ts.map +1 -0
  59. package/dist/openclaw/custom-tools.js +195 -0
  60. package/dist/openclaw/custom-tools.js.map +1 -0
  61. package/dist/openclaw/instructions.d.ts +15 -0
  62. package/dist/openclaw/instructions.d.ts.map +1 -0
  63. package/dist/openclaw/instructions.js +32 -0
  64. package/dist/openclaw/instructions.js.map +1 -0
  65. package/dist/openclaw/model-resolver.d.ts +30 -0
  66. package/dist/openclaw/model-resolver.d.ts.map +1 -0
  67. package/dist/openclaw/model-resolver.js +147 -0
  68. package/dist/openclaw/model-resolver.js.map +1 -0
  69. package/dist/openclaw/plugin-loader.d.ts +39 -0
  70. package/dist/openclaw/plugin-loader.d.ts.map +1 -0
  71. package/dist/openclaw/plugin-loader.js +347 -0
  72. package/dist/openclaw/plugin-loader.js.map +1 -0
  73. package/dist/openclaw/processor.d.ts +38 -0
  74. package/dist/openclaw/processor.d.ts.map +1 -0
  75. package/dist/openclaw/processor.js +182 -0
  76. package/dist/openclaw/processor.js.map +1 -0
  77. package/dist/openclaw/session-context.d.ts +44 -0
  78. package/dist/openclaw/session-context.d.ts.map +1 -0
  79. package/dist/openclaw/session-context.js +151 -0
  80. package/dist/openclaw/session-context.js.map +1 -0
  81. package/dist/openclaw/tool-policy.d.ts +23 -0
  82. package/dist/openclaw/tool-policy.d.ts.map +1 -0
  83. package/dist/openclaw/tool-policy.js +151 -0
  84. package/dist/openclaw/tool-policy.js.map +1 -0
  85. package/dist/openclaw/tools.d.ts +6 -0
  86. package/dist/openclaw/tools.d.ts.map +1 -0
  87. package/dist/openclaw/tools.js +158 -0
  88. package/dist/openclaw/tools.js.map +1 -0
  89. package/dist/openclaw/worker.d.ts +39 -0
  90. package/dist/openclaw/worker.d.ts.map +1 -0
  91. package/dist/openclaw/worker.js +1340 -0
  92. package/dist/openclaw/worker.js.map +1 -0
  93. package/dist/server.d.ts +7 -0
  94. package/dist/server.d.ts.map +1 -0
  95. package/dist/server.js +304 -0
  96. package/dist/server.js.map +1 -0
  97. package/dist/shared/audio-provider-suggestions.d.ts +13 -0
  98. package/dist/shared/audio-provider-suggestions.d.ts.map +1 -0
  99. package/dist/shared/audio-provider-suggestions.js +105 -0
  100. package/dist/shared/audio-provider-suggestions.js.map +1 -0
  101. package/dist/shared/processor-utils.d.ts +6 -0
  102. package/dist/shared/processor-utils.d.ts.map +1 -0
  103. package/dist/shared/processor-utils.js +30 -0
  104. package/dist/shared/processor-utils.js.map +1 -0
  105. package/dist/shared/provider-auth-hints.d.ts +6 -0
  106. package/dist/shared/provider-auth-hints.d.ts.map +1 -0
  107. package/dist/shared/provider-auth-hints.js +51 -0
  108. package/dist/shared/provider-auth-hints.js.map +1 -0
  109. package/dist/shared/tool-display-config.d.ts +16 -0
  110. package/dist/shared/tool-display-config.d.ts.map +1 -0
  111. package/dist/shared/tool-display-config.js +67 -0
  112. package/dist/shared/tool-display-config.js.map +1 -0
  113. package/dist/shared/tool-implementations.d.ts +55 -0
  114. package/dist/shared/tool-implementations.d.ts.map +1 -0
  115. package/dist/shared/tool-implementations.js +519 -0
  116. package/dist/shared/tool-implementations.js.map +1 -0
  117. package/package.json +55 -0
@@ -0,0 +1,7 @@
1
+ import { type WorkerTransport } from "@lobu/core";
2
+ /**
3
+ * Handle execution error - decides between authentication and generic errors
4
+ * Generic error handler that works for any AI agent
5
+ */
6
+ export declare function handleExecutionError(error: unknown, transport: WorkerTransport): Promise<void>;
7
+ //# sourceMappingURL=error-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/core/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAqChE;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,eAAe,GACzB,OAAO,CAAC,IAAI,CAAC,CAyBf"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleExecutionError = handleExecutionError;
4
+ const core_1 = require("@lobu/core");
5
+ const logger = (0, core_1.createLogger)("worker");
6
+ /**
7
+ * Format error message for display
8
+ * Generic error formatter that works for any AI agent
9
+ */
10
+ function formatErrorMessage(error) {
11
+ let errorMsg = `💥 Worker crashed`;
12
+ if (error instanceof Error) {
13
+ errorMsg += `: ${error.message}`;
14
+ // Add error type if it's not generic
15
+ if (error.constructor.name !== "Error" &&
16
+ error.constructor.name !== "WorkspaceError") {
17
+ errorMsg = `💥 Worker crashed (${error.constructor.name}): ${error.message}`;
18
+ }
19
+ }
20
+ else {
21
+ errorMsg += ": Unknown error";
22
+ }
23
+ return errorMsg;
24
+ }
25
+ function classifyError(error) {
26
+ if (!(error instanceof Error))
27
+ return undefined;
28
+ if (error.message.includes("No model configured") ||
29
+ error.message.includes("No provider specified"))
30
+ return "NO_MODEL_CONFIGURED";
31
+ return undefined;
32
+ }
33
+ /**
34
+ * Handle execution error - decides between authentication and generic errors
35
+ * Generic error handler that works for any AI agent
36
+ */
37
+ async function handleExecutionError(error, transport) {
38
+ logger.error("Worker execution failed:", error);
39
+ const code = classifyError(error);
40
+ try {
41
+ if (code) {
42
+ // Known error — clean message, no "Worker crashed" text
43
+ await transport.signalError(error instanceof Error ? error : new Error(String(error)), code);
44
+ }
45
+ else {
46
+ // Unknown error — existing behavior
47
+ const errorMsg = formatErrorMessage(error);
48
+ await transport.sendStreamDelta(errorMsg, true, true);
49
+ await transport.signalError(error instanceof Error ? error : new Error(String(error)));
50
+ }
51
+ }
52
+ catch (gatewayError) {
53
+ logger.error("Failed to send error via gateway:", gatewayError);
54
+ // Re-throw the original error
55
+ throw error;
56
+ }
57
+ }
58
+ //# sourceMappingURL=error-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/core/error-handler.ts"],"names":[],"mappings":";;AAyCA,oDA4BC;AArED,qCAAgE;AAEhE,MAAM,MAAM,GAAG,IAAA,mBAAY,EAAC,QAAQ,CAAC,CAAC;AAEtC;;;GAGG;AACH,SAAS,kBAAkB,CAAC,KAAc;IACxC,IAAI,QAAQ,GAAG,mBAAmB,CAAC;IAEnC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,QAAQ,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;QACjC,qCAAqC;QACrC,IACE,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,OAAO;YAClC,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,gBAAgB,EAC3C,CAAC;YACD,QAAQ,GAAG,sBAAsB,KAAK,CAAC,WAAW,CAAC,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QAC/E,CAAC;IACH,CAAC;SAAM,CAAC;QACN,QAAQ,IAAI,iBAAiB,CAAC;IAChC,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAChD,IACE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC;QAC7C,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAC;QAE/C,OAAO,qBAAqB,CAAC;IAC/B,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,oBAAoB,CACxC,KAAc,EACd,SAA0B;IAE1B,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;IAEhD,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAElC,IAAI,CAAC;QACH,IAAI,IAAI,EAAE,CAAC;YACT,wDAAwD;YACxD,MAAM,SAAS,CAAC,WAAW,CACzB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EACzD,IAAI,CACL,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,oCAAoC;YACpC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC3C,MAAM,SAAS,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YACtD,MAAM,SAAS,CAAC,WAAW,CACzB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAC1D,CAAC;QACJ,CAAC;IACH,CAAC;IAAC,OAAO,YAAY,EAAE,CAAC;QACtB,MAAM,CAAC,KAAK,CAAC,mCAAmC,EAAE,YAAY,CAAC,CAAC;QAChE,8BAA8B;QAC9B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Scan a directory tree and find all project directories
3
+ * A project directory is one that contains a build config file
4
+ * (Makefile, package.json, pyproject.toml, etc.)
5
+ *
6
+ * Generic utility that works for any AI agent
7
+ */
8
+ export declare function listAppDirectories(rootDirectory: string): string[];
9
+ //# sourceMappingURL=project-scanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-scanner.d.ts","sourceRoot":"","sources":["../../src/core/project-scanner.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,EAAE,CAuDlE"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.listAppDirectories = listAppDirectories;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ /**
9
+ * Scan a directory tree and find all project directories
10
+ * A project directory is one that contains a build config file
11
+ * (Makefile, package.json, pyproject.toml, etc.)
12
+ *
13
+ * Generic utility that works for any AI agent
14
+ */
15
+ function listAppDirectories(rootDirectory) {
16
+ const foundDirectories = [];
17
+ const ignored = new Set([
18
+ "node_modules",
19
+ ".git",
20
+ ".next",
21
+ "dist",
22
+ "build",
23
+ "vendor",
24
+ "target",
25
+ ".venv",
26
+ "venv",
27
+ ]);
28
+ const buildConfigFiles = new Set([
29
+ "Makefile",
30
+ "makefile",
31
+ "package.json",
32
+ "pyproject.toml",
33
+ "Cargo.toml",
34
+ "pom.xml",
35
+ "build.gradle",
36
+ "build.gradle.kts",
37
+ "CMakeLists.txt",
38
+ "go.mod",
39
+ ]);
40
+ const walk = (dir) => {
41
+ let entries = [];
42
+ try {
43
+ entries = node_fs_1.default.readdirSync(dir, { withFileTypes: true });
44
+ }
45
+ catch {
46
+ return;
47
+ }
48
+ // Check if current directory has any build config files
49
+ const hasConfigFile = entries.some((entry) => entry.isFile() && buildConfigFiles.has(entry.name));
50
+ if (hasConfigFile) {
51
+ foundDirectories.push(dir);
52
+ }
53
+ // Recursively walk subdirectories
54
+ for (const entry of entries) {
55
+ const p = `${dir}/${entry.name}`;
56
+ if (entry.isDirectory() && !ignored.has(entry.name)) {
57
+ walk(p);
58
+ }
59
+ }
60
+ };
61
+ walk(rootDirectory);
62
+ return foundDirectories;
63
+ }
64
+ //# sourceMappingURL=project-scanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-scanner.js","sourceRoot":"","sources":["../../src/core/project-scanner.ts"],"names":[],"mappings":";;;;;AASA,gDAuDC;AAhED,sDAAyB;AAEzB;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAC,aAAqB;IACtD,MAAM,gBAAgB,GAAa,EAAE,CAAC;IACtC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC;QACtB,cAAc;QACd,MAAM;QACN,OAAO;QACP,MAAM;QACN,OAAO;QACP,QAAQ;QACR,QAAQ;QACR,OAAO;QACP,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC;QAC/B,UAAU;QACV,UAAU;QACV,cAAc;QACd,gBAAgB;QAChB,YAAY;QACZ,SAAS;QACT,cAAc;QACd,kBAAkB;QAClB,gBAAgB;QAChB,QAAQ;KACT,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,CAAC,GAAW,EAAQ,EAAE;QACjC,IAAI,OAAO,GAAgB,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,OAAO,GAAG,iBAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;QACT,CAAC;QAED,wDAAwD;QACxD,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAChC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAC9D,CAAC;QAEF,IAAI,aAAa,EAAE,CAAC;YAClB,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;QAED,kCAAkC;QAClC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,MAAM,CAAC,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YACjC,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACpD,IAAI,CAAC,CAAC,CAAC,CAAC;YACV,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC,aAAa,CAAC,CAAC;IACpB,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Consolidated types for worker package
4
+ * Merged from: base/types.ts, types.ts, interfaces.ts
5
+ */
6
+ import type { WorkerTransport } from "@lobu/core";
7
+ /**
8
+ * Interface for worker executors
9
+ * Allows different agent implementations
10
+ */
11
+ export interface WorkerExecutor {
12
+ /**
13
+ * Execute the worker job
14
+ */
15
+ execute(): Promise<void>;
16
+ /**
17
+ * Cleanup worker resources
18
+ */
19
+ cleanup(): Promise<void>;
20
+ /**
21
+ * Get the worker transport for sending updates to gateway
22
+ */
23
+ getWorkerTransport(): WorkerTransport | null;
24
+ }
25
+ export interface WorkerConfig {
26
+ sessionKey: string;
27
+ userId: string;
28
+ agentId: string;
29
+ channelId: string;
30
+ conversationId: string;
31
+ userPrompt: string;
32
+ responseChannel: string;
33
+ responseId: string;
34
+ botResponseId?: string;
35
+ agentOptions: string;
36
+ teamId?: string;
37
+ platform: string;
38
+ platformMetadata?: any;
39
+ workspace: {
40
+ baseDirectory: string;
41
+ };
42
+ }
43
+ export interface WorkspaceSetupConfig {
44
+ baseDirectory: string;
45
+ }
46
+ export interface WorkspaceInfo {
47
+ baseDirectory: string;
48
+ userDirectory: string;
49
+ }
50
+ /**
51
+ * Progress update from AI agent execution
52
+ */
53
+ export type ProgressUpdate = {
54
+ type: "output";
55
+ data: unknown;
56
+ timestamp: number;
57
+ } | {
58
+ type: "completion";
59
+ data: {
60
+ exitCode?: number;
61
+ message?: string;
62
+ success?: boolean;
63
+ sessionId?: string;
64
+ };
65
+ timestamp: number;
66
+ } | {
67
+ type: "error";
68
+ data: Error | {
69
+ message?: string;
70
+ stack?: string;
71
+ error?: string;
72
+ };
73
+ timestamp: number;
74
+ } | {
75
+ type: "status_update";
76
+ data: {
77
+ elapsedSeconds: number;
78
+ state: string;
79
+ };
80
+ timestamp: number;
81
+ };
82
+ /**
83
+ * Callback for receiving progress updates during AI execution
84
+ */
85
+ export type ProgressCallback = (update: ProgressUpdate) => Promise<void>;
86
+ /**
87
+ * Session context for AI execution
88
+ * Contains information about the current session (platform, user, workspace)
89
+ */
90
+ /**
91
+ * Result from session execution (includes session metadata)
92
+ */
93
+ export interface SessionExecutionResult {
94
+ success: boolean;
95
+ exitCode: number;
96
+ output: string;
97
+ error?: string;
98
+ sessionKey: string;
99
+ persisted?: boolean;
100
+ storagePath?: string;
101
+ }
102
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMlD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;OAEG;IACH,kBAAkB,IAAI,eAAe,GAAG,IAAI,CAAC;CAC9C;AAMD,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,E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AC;QACvB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzE;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bun
2
+ "use strict";
3
+ /**
4
+ * Consolidated types for worker package
5
+ * Merged from: base/types.ts, types.ts, interfaces.ts
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":";;AAEA;;;GAGG"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Ensure URL has http:// or https:// prefix
3
+ */
4
+ export declare function ensureBaseUrl(url: string): string;
5
+ //# sourceMappingURL=url-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-utils.d.ts","sourceRoot":"","sources":["../../src/core/url-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKjD"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureBaseUrl = ensureBaseUrl;
4
+ /**
5
+ * Ensure URL has http:// or https:// prefix
6
+ */
7
+ function ensureBaseUrl(url) {
8
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
9
+ return `http://${url}`;
10
+ }
11
+ return url;
12
+ }
13
+ //# sourceMappingURL=url-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-utils.js","sourceRoot":"","sources":["../../src/core/url-utils.ts"],"names":[],"mappings":";;AAGA,sCAKC;AARD;;GAEG;AACH,SAAgB,aAAa,CAAC,GAAW;IACvC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9D,OAAO,UAAU,GAAG,EAAE,CAAC;IACzB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { WorkspaceInfo, WorkspaceSetupConfig } from "./types";
2
+ /**
3
+ * Setup workspace directory environment variable
4
+ * Used by MCP process manager
5
+ */
6
+ export declare function setupWorkspaceEnv(deploymentName: string | undefined): void;
7
+ /**
8
+ * Simplified WorkspaceManager - only handles directory creation
9
+ * All VCS operations (git, etc.) are handled by modules via hooks
10
+ */
11
+ export declare class WorkspaceManager {
12
+ private config;
13
+ private workspaceInfo?;
14
+ constructor(config: WorkspaceSetupConfig);
15
+ /**
16
+ * Setup workspace directory - creates thread-specific directory only
17
+ * VCS operations are handled by module hooks (e.g., GitHub module)
18
+ */
19
+ setupWorkspace(username: string, sessionKey?: string): Promise<WorkspaceInfo>;
20
+ /**
21
+ * Ensure directory exists
22
+ */
23
+ private ensureDirectory;
24
+ /**
25
+ * Get current working directory
26
+ */
27
+ getCurrentWorkingDirectory(): string;
28
+ }
29
+ //# sourceMappingURL=workspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/core/workspace.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAoBnE;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAY1E;AAiBD;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,aAAa,CAAC,CAAgB;gBAE1B,MAAM,EAAE,oBAAoB;IAIxC;;;OAGG;IACG,cAAc,CAClB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,CAAC;IAwCzB;;OAEG;YACW,eAAe;IAU7B;;OAEG;IACH,0BAA0B,IAAI,MAAM;CAGrC"}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkspaceManager = void 0;
4
+ exports.setupWorkspaceEnv = setupWorkspaceEnv;
5
+ const promises_1 = require("node:fs/promises");
6
+ const core_1 = require("@lobu/core");
7
+ const logger = (0, core_1.createLogger)("workspace");
8
+ // ============================================================================
9
+ // WORKSPACE UTILITIES
10
+ // ============================================================================
11
+ /**
12
+ * Get workspace directory path for a thread
13
+ */
14
+ function getWorkspacePathForThread(baseDirectory, conversationId) {
15
+ // Sanitize thread ID for filesystem
16
+ const sanitizedConversationId = (0, core_1.sanitizeConversationId)(conversationId);
17
+ return `${baseDirectory}/${sanitizedConversationId}`;
18
+ }
19
+ /**
20
+ * Setup workspace directory environment variable
21
+ * Used by MCP process manager
22
+ */
23
+ function setupWorkspaceEnv(deploymentName) {
24
+ const conversationId = process.env.CONVERSATION_ID;
25
+ if (conversationId) {
26
+ const baseDir = process.env.WORKSPACE_DIR || "/workspace";
27
+ const workspaceDir = getWorkspacePathForThread(baseDir, conversationId);
28
+ process.env.WORKSPACE_DIR = workspaceDir;
29
+ logger.info(`📁 Set WORKSPACE_DIR for process manager: ${workspaceDir}`);
30
+ }
31
+ else if (deploymentName) {
32
+ // deploymentName is no longer parseable (it may be hashed/collision-resistant).
33
+ logger.warn("WORKSPACE_DIR not set (missing CONVERSATION_ID env var)");
34
+ }
35
+ }
36
+ /**
37
+ * Get conversation identifier from various sources
38
+ * Priority: CONVERSATION_ID > sessionKey > username
39
+ */
40
+ function getThreadIdentifier(sessionKey, username) {
41
+ const conversationId = process.env.CONVERSATION_ID || sessionKey || username || "default";
42
+ return conversationId;
43
+ }
44
+ // ============================================================================
45
+ // WORKSPACE MANAGER
46
+ // ============================================================================
47
+ /**
48
+ * Simplified WorkspaceManager - only handles directory creation
49
+ * All VCS operations (git, etc.) are handled by modules via hooks
50
+ */
51
+ class WorkspaceManager {
52
+ config;
53
+ workspaceInfo;
54
+ constructor(config) {
55
+ this.config = config;
56
+ }
57
+ /**
58
+ * Setup workspace directory - creates thread-specific directory only
59
+ * VCS operations are handled by module hooks (e.g., GitHub module)
60
+ */
61
+ async setupWorkspace(username, sessionKey) {
62
+ try {
63
+ // Use thread-specific directory to avoid conflicts between concurrent threads
64
+ const conversationId = getThreadIdentifier(sessionKey, username);
65
+ logger.info(`Setting up workspace directory for ${username}, conversation: ${conversationId}...`);
66
+ const userDirectory = getWorkspacePathForThread(this.config.baseDirectory, conversationId);
67
+ // Ensure base directory exists
68
+ await this.ensureDirectory(this.config.baseDirectory);
69
+ // Ensure user directory exists
70
+ await this.ensureDirectory(userDirectory);
71
+ // Create workspace info
72
+ this.workspaceInfo = {
73
+ baseDirectory: this.config.baseDirectory,
74
+ userDirectory,
75
+ };
76
+ logger.info(`Workspace directory setup completed for ${username} (conversation: ${conversationId}) at ${userDirectory}`);
77
+ return this.workspaceInfo;
78
+ }
79
+ catch (error) {
80
+ throw new core_1.WorkspaceError("setupWorkspace", `Failed to setup workspace directory`, error);
81
+ }
82
+ }
83
+ /**
84
+ * Ensure directory exists
85
+ */
86
+ async ensureDirectory(path) {
87
+ try {
88
+ await (0, promises_1.mkdir)(path, { recursive: true });
89
+ }
90
+ catch (error) {
91
+ if (error.code !== "EEXIST") {
92
+ throw error;
93
+ }
94
+ }
95
+ }
96
+ /**
97
+ * Get current working directory
98
+ */
99
+ getCurrentWorkingDirectory() {
100
+ return this.workspaceInfo?.userDirectory || this.config.baseDirectory;
101
+ }
102
+ }
103
+ exports.WorkspaceManager = WorkspaceManager;
104
+ //# sourceMappingURL=workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/core/workspace.ts"],"names":[],"mappings":";;;AA8BA,8CAYC;AA1CD,+CAAyC;AACzC,qCAIoB;AAGpB,MAAM,MAAM,GAAG,IAAA,mBAAY,EAAC,WAAW,CAAC,CAAC;AAEzC,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E;;GAEG;AACH,SAAS,yBAAyB,CAChC,aAAqB,EACrB,cAAsB;IAEtB,oCAAoC;IACpC,MAAM,uBAAuB,GAAG,IAAA,6BAAsB,EAAC,cAAc,CAAC,CAAC;IACvE,OAAO,GAAG,aAAa,IAAI,uBAAuB,EAAE,CAAC;AACvD,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,cAAkC;IAClE,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAEnD,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,YAAY,CAAC;QAC1D,MAAM,YAAY,GAAG,yBAAyB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QACxE,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,YAAY,CAAC;QACzC,MAAM,CAAC,IAAI,CAAC,6CAA6C,YAAY,EAAE,CAAC,CAAC;IAC3E,CAAC;SAAM,IAAI,cAAc,EAAE,CAAC;QAC1B,gFAAgF;QAChF,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,mBAAmB,CAAC,UAAmB,EAAE,QAAiB;IACjE,MAAM,cAAc,GAClB,OAAO,CAAC,GAAG,CAAC,eAAe,I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AAM,IAAA,gBAAK,EAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC5B,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,0BAA0B;QACxB,OAAO,IAAI,CAAC,aAAa,EAAE,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;IACxE,CAAC;CACF;AA1ED,4CA0EC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Worker-side just-bash bootstrap for embedded deployment mode.
3
+ *
4
+ * Creates a just-bash Bash instance from environment variables and wraps it
5
+ * as a BashOperations interface for pi-coding-agent's bash tool.
6
+ *
7
+ * When nix binaries are detected on PATH (via nix-shell wrapper from gateway)
8
+ * or known CLI tools (e.g. owletto) are found, they are registered as
9
+ * just-bash customCommands that delegate to real exec.
10
+ */
11
+ import type { BashOperations } from "@mariozechner/pi-coding-agent";
12
+ export declare function buildBinaryInvocation(binaryPath: string, args: string[]): {
13
+ command: string;
14
+ args: string[];
15
+ };
16
+ /**
17
+ * Create a BashOperations adapter backed by a just-bash Bash instance.
18
+ * Reads configuration from environment variables.
19
+ */
20
+ export declare function createEmbeddedBashOps(): Promise<BashOperations>;
21
+ //# sourceMappingURL=just-bash-bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"just-bash-bootstrap.d.ts","sourceRoot":"","sources":["../../src/embedded/just-bash-bootstrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAQpE,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAAE,GACb;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAYrC;AAuGD;;;GAGG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,cAAc,CAAC,CAmFrE"}