@intella/sdk 0.0.1 → 0.0.3

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/README.md +6 -483
  2. package/dist/agent-manager.d.ts +47 -0
  3. package/dist/agent-manager.d.ts.map +1 -0
  4. package/dist/agent-manager.js +90 -0
  5. package/dist/agent-manager.js.map +1 -0
  6. package/dist/agents/base-agent.d.ts +41 -0
  7. package/dist/agents/base-agent.d.ts.map +1 -0
  8. package/dist/agents/base-agent.js +148 -0
  9. package/dist/agents/base-agent.js.map +1 -0
  10. package/dist/agents/claude-agent.d.ts +24 -0
  11. package/dist/agents/claude-agent.d.ts.map +1 -0
  12. package/dist/agents/claude-agent.js +65 -0
  13. package/dist/agents/claude-agent.js.map +1 -0
  14. package/dist/agents/codex-agent.d.ts +25 -0
  15. package/dist/agents/codex-agent.d.ts.map +1 -0
  16. package/dist/agents/codex-agent.js +62 -0
  17. package/dist/agents/codex-agent.js.map +1 -0
  18. package/dist/agents/intella-lite-agent.d.ts +21 -0
  19. package/dist/agents/intella-lite-agent.d.ts.map +1 -0
  20. package/dist/agents/intella-lite-agent.js +43 -0
  21. package/dist/agents/intella-lite-agent.js.map +1 -0
  22. package/dist/agents/opencode-agent.d.ts +20 -0
  23. package/dist/agents/opencode-agent.d.ts.map +1 -0
  24. package/dist/agents/opencode-agent.js +36 -0
  25. package/dist/agents/opencode-agent.js.map +1 -0
  26. package/dist/filesystem/base-provider.d.ts +55 -0
  27. package/dist/filesystem/base-provider.d.ts.map +1 -0
  28. package/dist/filesystem/base-provider.js +45 -0
  29. package/dist/filesystem/base-provider.js.map +1 -0
  30. package/dist/filesystem/index.d.ts +3 -0
  31. package/dist/filesystem/index.d.ts.map +1 -0
  32. package/{src/filesystem/index.ts → dist/filesystem/index.js} +1 -2
  33. package/dist/filesystem/index.js.map +1 -0
  34. package/dist/filesystem/memory-provider.d.ts +44 -0
  35. package/dist/filesystem/memory-provider.d.ts.map +1 -0
  36. package/dist/filesystem/memory-provider.js +227 -0
  37. package/dist/filesystem/memory-provider.js.map +1 -0
  38. package/dist/filesystem-manager.d.ts +75 -0
  39. package/dist/filesystem-manager.d.ts.map +1 -0
  40. package/dist/filesystem-manager.js +162 -0
  41. package/dist/filesystem-manager.js.map +1 -0
  42. package/dist/index.d.ts +18 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/{src/index.ts → dist/index.js} +4 -47
  45. package/dist/index.js.map +1 -0
  46. package/dist/orchestrator.d.ts +32 -0
  47. package/dist/orchestrator.d.ts.map +1 -0
  48. package/dist/orchestrator.js +137 -0
  49. package/dist/orchestrator.js.map +1 -0
  50. package/dist/sandbox/base-provider.d.ts +106 -0
  51. package/dist/sandbox/base-provider.d.ts.map +1 -0
  52. package/dist/sandbox/base-provider.js +74 -0
  53. package/dist/sandbox/base-provider.js.map +1 -0
  54. package/dist/sandbox/daytona-provider.d.ts +93 -0
  55. package/dist/sandbox/daytona-provider.d.ts.map +1 -0
  56. package/dist/sandbox/daytona-provider.js +378 -0
  57. package/dist/sandbox/daytona-provider.js.map +1 -0
  58. package/dist/sandbox/e2b-provider.d.ts +85 -0
  59. package/dist/sandbox/e2b-provider.d.ts.map +1 -0
  60. package/dist/sandbox/e2b-provider.js +363 -0
  61. package/dist/sandbox/e2b-provider.js.map +1 -0
  62. package/dist/sandbox/modal-provider.d.ts +92 -0
  63. package/dist/sandbox/modal-provider.d.ts.map +1 -0
  64. package/dist/sandbox/modal-provider.js +516 -0
  65. package/dist/sandbox/modal-provider.js.map +1 -0
  66. package/dist/sandbox-manager.d.ts +59 -0
  67. package/dist/sandbox-manager.d.ts.map +1 -0
  68. package/dist/sandbox-manager.js +141 -0
  69. package/dist/sandbox-manager.js.map +1 -0
  70. package/dist/sdk.d.ts +173 -0
  71. package/dist/sdk.d.ts.map +1 -0
  72. package/dist/sdk.js +277 -0
  73. package/dist/sdk.js.map +1 -0
  74. package/dist/types.d.ts +423 -0
  75. package/dist/types.d.ts.map +1 -0
  76. package/dist/types.js +2 -0
  77. package/dist/types.js.map +1 -0
  78. package/dist/utils/code-extractor.d.ts +103 -0
  79. package/dist/utils/code-extractor.d.ts.map +1 -0
  80. package/dist/utils/code-extractor.js +133 -0
  81. package/dist/utils/code-extractor.js.map +1 -0
  82. package/package.json +23 -11
  83. package/examples/claude-code/README.md +0 -178
  84. package/examples/claude-code/advanced-config.ts +0 -55
  85. package/examples/claude-code/basic-usage.ts +0 -56
  86. package/examples/claude-code/model-comparison.ts +0 -50
  87. package/examples/claude-code/orchestration.ts +0 -70
  88. package/examples/claude-code/streaming.ts +0 -69
  89. package/examples/claude-code/tsconfig.json +0 -19
  90. package/examples/code-extractor/README.md +0 -77
  91. package/examples/code-extractor/example.ts +0 -145
  92. package/examples/filesystem/basic-usage.ts +0 -84
  93. package/examples/integrated-task/README.md +0 -68
  94. package/examples/integrated-task/integrated-usage.ts +0 -193
  95. package/examples/integrated-task/simple-example.ts +0 -51
  96. package/examples/integrated-task/tsconfig.json +0 -19
  97. package/examples/sandbox/basic-usage.ts +0 -173
  98. package/src/agent-manager.ts +0 -104
  99. package/src/agents/base-agent.ts +0 -166
  100. package/src/agents/claude-agent.ts +0 -77
  101. package/src/agents/codex-agent.ts +0 -72
  102. package/src/agents/intella-lite-agent.ts +0 -55
  103. package/src/agents/opencode-agent.ts +0 -45
  104. package/src/filesystem/agentfs-provider.ts +0 -328
  105. package/src/filesystem/base-provider.ts +0 -98
  106. package/src/filesystem/memory-provider.ts +0 -267
  107. package/src/filesystem-manager.ts +0 -213
  108. package/src/orchestrator.ts +0 -177
  109. package/src/sandbox/base-provider.ts +0 -184
  110. package/src/sandbox/daytona-provider.ts +0 -462
  111. package/src/sandbox/e2b-provider.ts +0 -419
  112. package/src/sandbox/modal-provider.ts +0 -597
  113. package/src/sandbox-manager.ts +0 -175
  114. package/src/sdk.ts +0 -401
  115. package/src/types.ts +0 -451
  116. package/src/utils/code-extractor.ts +0 -194
  117. package/tsconfig.json +0 -25
@@ -1,462 +0,0 @@
1
- import { BaseSandboxProvider } from './base-provider.js';
2
- import type { SandboxConfig, CommandResult, CodeExecutionResult, SandboxInfo } from '../types.js';
3
- import { Daytona, Sandbox } from '@daytonaio/sdk';
4
-
5
- /**
6
- * Daytona Sandbox Provider
7
- * Provides sandbox execution capabilities using Daytona
8
- */
9
- export class DaytonaSandboxProvider extends BaseSandboxProvider {
10
- protected client: Daytona | null = null;
11
- private sandboxInstance: Sandbox | null = null;
12
-
13
- constructor(config?: SandboxConfig) {
14
- super('daytona');
15
- if (config) {
16
- this.config = config;
17
- }
18
- }
19
-
20
-
21
- getClient(): Daytona {
22
- if (!this.client) {
23
- const apiKey =
24
- this.config.apiKey ||
25
- process.env.DAYTONA_API_KEY ||
26
- process.env.DAYTONA_API_TOKEN ||
27
- null;
28
-
29
- if (!apiKey) {
30
- throw new Error(
31
- 'Daytona API key is required. Set DAYTONA_API_KEY or DAYTONA_API_TOKEN environment variable or provide apiKey in config.'
32
- );
33
- }
34
- this.client = new Daytona({ apiKey });
35
- }
36
- return this.client;
37
- }
38
-
39
- /**
40
- * Initialize/create a Daytona sandbox
41
- */
42
- protected async initializeSandbox(config?: SandboxConfig): Promise<void> {
43
- if (config) {
44
- this.config = { ...this.config, ...config };
45
- }
46
-
47
- try {
48
- // Dynamic import to handle optional dependency
49
-
50
- const daytonaClient = this.getClient();
51
-
52
- // Create sandbox with language/template configuration
53
- const createOptions: any = {
54
- envVars: this.config.env || {},
55
- };
56
-
57
- // If templateId is provided, use it (could be a language or template name)
58
- if (this.config.templateId) {
59
- // Check if it's a language identifier
60
- const languageMap: Record<string, string> = {
61
- typescript: 'typescript',
62
- javascript: 'typescript', // Daytona uses typescript for JS
63
- python: 'python',
64
- java: 'java',
65
- go: 'go',
66
- rust: 'rust',
67
- };
68
-
69
- const language = languageMap[this.config.templateId.toLowerCase()];
70
- if (language) {
71
- createOptions.language = language;
72
- } else {
73
- // Assume it's a template ID
74
- createOptions.template = this.config.templateId;
75
- }
76
- }
77
-
78
- // Create the sandbox
79
- this.sandboxInstance = await daytonaClient.create(createOptions);
80
- this.sandboxId = this.sandboxInstance!.id;
81
- this.initialized = true;
82
- } catch (error) {
83
- throw new Error(
84
- `Failed to initialize Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`
85
- );
86
- }
87
- }
88
-
89
- /**
90
- * Connect to an existing Daytona sandbox by ID
91
- */
92
- async fromSandbox(sandboxId: string, config?: SandboxConfig): Promise<Sandbox> {
93
- if (config) {
94
- this.config = { ...this.config, ...config };
95
- }
96
-
97
- try {
98
- const daytonaClient = this.getClient();
99
-
100
- // Get existing sandbox by ID
101
- // Note: Daytona SDK may have a method to get sandbox by ID
102
- // If not available, we'll need to use the client's get method
103
-
104
-
105
- // Try to get sandbox by ID
106
- this.sandboxInstance = await daytonaClient.get(sandboxId);
107
-
108
- await daytonaClient.start(this.sandboxInstance!);
109
-
110
- this.sandboxId = this.sandboxInstance!.id || sandboxId;
111
- this.initialized = true;
112
- return this.sandboxInstance;
113
- } catch (error) {
114
- throw new Error(
115
- `Failed to connect to Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`
116
- );
117
- }
118
- }
119
-
120
- /**
121
- * Close/cleanup the Daytona sandbox
122
- */
123
- async close(): Promise<void> {
124
- if (this.sandboxInstance && this.initialized) {
125
- try {
126
- await this.sandboxInstance.delete();
127
- } catch (error) {
128
- // Ignore errors during cleanup
129
- console.warn('Error closing Daytona sandbox:', error);
130
- }
131
- this.sandboxInstance = null;
132
- this.client = null;
133
- this.sandboxId = null;
134
- this.initialized = false;
135
- }
136
- }
137
-
138
- /**
139
- * Execute a command in the Daytona sandbox
140
- * @param command - Command to execute
141
- * @param options - Execution options (cwd, env, timeout)
142
- */
143
- async executeCommand(
144
- command: string,
145
- options?: {
146
- cwd?: string;
147
- env?: Record<string, string>;
148
- timeout?: number;
149
- }
150
- ): Promise<CommandResult> {
151
- this.ensureInitialized();
152
-
153
- const startTime = Date.now();
154
- try {
155
- // Use process.executeCommand for shell commands
156
- // According to docs: https://www.daytona.io/docs/en/process-code-execution/
157
- const execOptions: any = {};
158
- if (options?.cwd) {
159
- execOptions.cwd = options.cwd;
160
- }
161
- if (options?.env) {
162
- execOptions.env = { ...this.config.env, ...options.env };
163
- }
164
- if (options?.timeout) {
165
- execOptions.timeout = options.timeout;
166
- }
167
-
168
- const response: any = await this.sandboxInstance!.process.executeCommand(
169
- command,
170
- Object.keys(execOptions).length > 0 ? execOptions : undefined
171
- );
172
-
173
- const executionTime = Date.now() - startTime;
174
-
175
- return {
176
- exitCode: response.exitCode || response.code || 0,
177
- stdout: response.result || response.stdout || '',
178
- stderr: response.stderr || response.error || '',
179
- executionTime,
180
- };
181
- } catch (error) {
182
- const executionTime = Date.now() - startTime;
183
- return {
184
- exitCode: 1,
185
- stdout: '',
186
- stderr: error instanceof Error ? error.message : String(error),
187
- executionTime,
188
- };
189
- }
190
- }
191
-
192
- /**
193
- * Run code (e.g., Python, JavaScript, TypeScript) in the Daytona sandbox
194
- * Uses the stateless codeRun method: https://www.daytona.io/docs/en/process-code-execution/
195
- */
196
- async runCode(
197
- code: string,
198
- options?: {
199
- language?: string;
200
- env?: Record<string, string>;
201
- timeout?: number;
202
- onStdout?: (data: string) => void;
203
- onStderr?: (data: string) => void;
204
- }
205
- ): Promise<CodeExecutionResult> {
206
- this.ensureInitialized();
207
-
208
- const startTime = Date.now();
209
- try {
210
- // Use process.codeRun for stateless code execution
211
- // According to docs: https://www.daytona.io/docs/en/process-code-execution/
212
- const codeRunOptions: any = {};
213
- if (options?.env) {
214
- codeRunOptions.env = { ...this.config.env, ...options.env };
215
- }
216
- if (options?.timeout) {
217
- codeRunOptions.timeout = options.timeout;
218
- }
219
-
220
- const response: any = await this.sandboxInstance!.process.codeRun(
221
- code,
222
- Object.keys(codeRunOptions).length > 0 ? codeRunOptions : undefined,
223
- options?.timeout
224
- );
225
-
226
- const executionTime = Date.now() - startTime;
227
-
228
- // Handle stdout/stderr callbacks if provided
229
- if (options?.onStdout && response.result) {
230
- options.onStdout(response.result);
231
- }
232
- if (options?.onStderr && response.stderr) {
233
- options.onStderr(response.stderr);
234
- }
235
-
236
- return {
237
- text: response.result || undefined,
238
- results: response.result ? [{ text: response.result }] : [],
239
- stdout: response.result ? [response.result] : [],
240
- stderr: response.stderr ? [response.stderr] : [],
241
- error: response.exitCode !== 0 || response.code !== 0
242
- ? {
243
- name: 'CodeExecutionError',
244
- value: response.stderr || response.error || 'Code execution failed',
245
- traceback: response.stderr || response.error || '',
246
- }
247
- : undefined,
248
- executionTime,
249
- };
250
- } catch (error) {
251
- const executionTime = Date.now() - startTime;
252
- return {
253
- text: undefined,
254
- results: [],
255
- stdout: [],
256
- stderr: [error instanceof Error ? error.message : String(error)],
257
- error: {
258
- name: 'CodeExecutionError',
259
- value: error instanceof Error ? error.message : String(error),
260
- traceback: error instanceof Error ? (error.stack || '') : '',
261
- },
262
- executionTime,
263
- };
264
- }
265
- }
266
-
267
- /**
268
- * Upload a file to the Daytona sandbox
269
- * Uses fs.uploadFile: https://www.daytona.io/docs/en/file-system-operations/
270
- */
271
- async uploadFile(localPath: string, remotePath: string): Promise<void> {
272
- this.ensureInitialized();
273
-
274
- try {
275
- const fs = await import('fs/promises');
276
- const content = await fs.readFile(localPath);
277
-
278
- // Use SDK fs.uploadFile method (takes Buffer and remote path)
279
- await this.sandboxInstance!.fs.uploadFile(content, remotePath);
280
- } catch (error) {
281
- throw new Error(
282
- `Failed to upload file to Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`
283
- );
284
- }
285
- }
286
-
287
- /**
288
- * Download a file from the Daytona sandbox
289
- * Uses fs.downloadFile: https://www.daytona.io/docs/en/file-system-operations/
290
- */
291
- async downloadFile(remotePath: string, localPath: string): Promise<void> {
292
- this.ensureInitialized();
293
-
294
- try {
295
- // Use SDK fs.downloadFile method (returns Buffer)
296
- const content = await this.sandboxInstance!.fs.downloadFile(remotePath);
297
- const fs = await import('fs/promises');
298
-
299
- // Write Buffer to local file
300
- await fs.writeFile(localPath, content);
301
- } catch (error) {
302
- throw new Error(
303
- `Failed to download file from Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`
304
- );
305
- }
306
- }
307
-
308
- /**
309
- * Read a file from the Daytona sandbox
310
- * Uses fs.downloadFile: https://www.daytona.io/docs/en/file-system-operations/
311
- */
312
- async readFile(path: string): Promise<string> {
313
- this.ensureInitialized();
314
-
315
- try {
316
- // Use SDK fs.downloadFile method (returns Buffer)
317
- const content = await this.sandboxInstance!.fs.downloadFile(path);
318
- return content.toString('utf-8');
319
- } catch (error) {
320
- throw new Error(
321
- `Failed to read file from Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`
322
- );
323
- }
324
- }
325
-
326
- /**
327
- * Write a file to the Daytona sandbox
328
- * Uses fs.uploadFile: https://www.daytona.io/docs/en/file-system-operations/
329
- */
330
- async writeFile(path: string, content: string): Promise<void> {
331
- this.ensureInitialized();
332
-
333
- try {
334
- // Use SDK fs.uploadFile method (takes Buffer and remote path)
335
- const buffer = Buffer.from(content, 'utf-8');
336
- await this.sandboxInstance!.fs.uploadFile(buffer, path);
337
- } catch (error) {
338
- throw new Error(
339
- `Failed to write file to Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`
340
- );
341
- }
342
- }
343
-
344
- /**
345
- * List files in a directory
346
- * Uses fs.listFiles: https://www.daytona.io/docs/en/file-system-operations/
347
- */
348
- async listFiles(path: string): Promise<string[]> {
349
- this.ensureInitialized();
350
-
351
- try {
352
- // Use SDK fs.listFiles method (returns File[] with name, isDir, size, modTime)
353
- const files = await this.sandboxInstance!.fs.listFiles(path);
354
- // Return array of file/directory names
355
- return files.map((file: any) => file.name || file.path);
356
- } catch (error) {
357
- throw new Error(
358
- `Failed to list files in Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`
359
- );
360
- }
361
- }
362
-
363
- /**
364
- * Check if a file exists
365
- */
366
- async fileExists(path: string): Promise<boolean> {
367
- this.ensureInitialized();
368
-
369
- try {
370
- await this.readFile(path);
371
- return true;
372
- } catch {
373
- return false;
374
- }
375
- }
376
-
377
- /**
378
- * Delete a file
379
- * Uses fs.deleteFile: https://www.daytona.io/docs/en/file-system-operations/
380
- */
381
- async deleteFile(path: string): Promise<void> {
382
- this.ensureInitialized();
383
-
384
- try {
385
- // Use SDK fs.deleteFile method
386
- await this.sandboxInstance!.fs.deleteFile(path);
387
- } catch (error) {
388
- throw new Error(
389
- `Failed to delete file in Daytona sandbox: ${error instanceof Error ? error.message : String(error)}`
390
- );
391
- }
392
- }
393
-
394
- /**
395
- * Get sandbox status
396
- */
397
- async getStatus(): Promise<{
398
- isRunning: boolean;
399
- createdAt?: number;
400
- [key: string]: unknown;
401
- }> {
402
- this.ensureInitialized();
403
-
404
- try {
405
- // Check if sandbox instance is available
406
- if (!this.sandboxInstance) {
407
- return {
408
- isRunning: false,
409
- };
410
- }
411
-
412
- // Try to get status from sandbox instance
413
- const sandboxAny = this.sandboxInstance as any;
414
- const status = sandboxAny.status || sandboxAny.state;
415
- const isRunning = status === 'running' || status === 'active' || this.initialized;
416
-
417
- return {
418
- isRunning,
419
- sandboxId: this.sandboxId,
420
- status,
421
- };
422
- } catch {
423
- return {
424
- isRunning: false,
425
- };
426
- }
427
- }
428
-
429
- /**
430
- * Get detailed sandbox information
431
- */
432
- async getInfo(sandboxId?: string): Promise<SandboxInfo> {
433
-
434
- if (!sandboxId && this.sandboxInstance) {
435
- this.ensureInitialized();
436
- const info = this.sandboxInstance
437
- return {
438
- sandboxId: info.id,
439
- provider: this.type,
440
- isRunning: info.state === 'started',
441
- isInitialized: this.initialized,
442
- createdAt: new Date(info.createdAt!),
443
- metadata: {},
444
- info: info,
445
- };
446
- } else if (sandboxId) {
447
- const sandbox = await this.client!.get(sandboxId);
448
- return {
449
- sandboxId: sandbox.id,
450
- provider: this.type,
451
- isRunning: sandbox.state === 'started',
452
- isInitialized: this.initialized,
453
- createdAt: new Date(sandbox.createdAt!),
454
- metadata: {},
455
- info: sandbox,
456
- };
457
- } else {
458
- throw new Error('Sandbox ID or active instance is required to get sandbox info');
459
- }
460
- }
461
- }
462
-