@elyracode/docker 0.9.55 → 0.9.57
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/CHANGELOG.md +4 -0
- package/extensions/index.ts +58 -29
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/extensions/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execSync } from "node:child_process";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import type { ExtensionAPI } from "@elyracode/coding-agent";
|
|
4
|
+
import type { AgentToolResult, ExtensionAPI } from "@elyracode/coding-agent";
|
|
5
5
|
import { Type } from "typebox";
|
|
6
6
|
|
|
7
7
|
// ── Helpers ─────────────────────────────────────────────────────────────────
|
|
@@ -40,14 +40,36 @@ function findComposeFile(cwd: string): string | undefined {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function getRunningContainers(cwd?: string): string {
|
|
43
|
-
return exec(
|
|
44
|
-
'docker ps --format "{{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"',
|
|
45
|
-
cwd,
|
|
46
|
-
);
|
|
43
|
+
return exec('docker ps --format "{{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"', cwd);
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
// ── Extension ───────────────────────────────────────────────────────────────
|
|
50
47
|
|
|
48
|
+
/** Details reported by docker_exec. */
|
|
49
|
+
interface ExecDetails {
|
|
50
|
+
container?: string;
|
|
51
|
+
command?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Details reported by docker_logs. */
|
|
55
|
+
interface LogsDetails {
|
|
56
|
+
container?: string;
|
|
57
|
+
lines?: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Details reported by docker_compose. */
|
|
61
|
+
interface ComposeDetails {
|
|
62
|
+
action?: string;
|
|
63
|
+
service?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Details reported by docker_env_check. */
|
|
67
|
+
interface EnvCheckDetails {
|
|
68
|
+
missing?: number;
|
|
69
|
+
different?: number;
|
|
70
|
+
extra?: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
51
73
|
export default function (elyra: ExtensionAPI): void {
|
|
52
74
|
// Inject Docker context into system prompt on session start
|
|
53
75
|
elyra.on("before_agent_start", async (_event, ctx) => {
|
|
@@ -64,15 +86,13 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
64
86
|
`## Docker Environment\n\n` +
|
|
65
87
|
`Compose file: ${composeFile}\n` +
|
|
66
88
|
`\`\`\`yaml\n${composeContent}\n\`\`\`\n\n` +
|
|
67
|
-
(running
|
|
68
|
-
? `Running containers:\n\`\`\`\n${running}\n\`\`\`\n\n`
|
|
69
|
-
: "No containers currently running.\n\n") +
|
|
89
|
+
(running ? `Running containers:\n\`\`\`\n${running}\n\`\`\`\n\n` : "No containers currently running.\n\n") +
|
|
70
90
|
`When running commands (migrations, tests, builds), use docker_exec to route them ` +
|
|
71
91
|
`to the appropriate container instead of running on the host.`;
|
|
72
92
|
|
|
73
93
|
const currentPrompt = ctx.getSystemPrompt();
|
|
74
94
|
return {
|
|
75
|
-
systemPrompt: currentPrompt
|
|
95
|
+
systemPrompt: `${currentPrompt}\n\n${contextBlock}`,
|
|
76
96
|
};
|
|
77
97
|
});
|
|
78
98
|
|
|
@@ -105,7 +125,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
105
125
|
}),
|
|
106
126
|
),
|
|
107
127
|
}),
|
|
108
|
-
execute: async (_toolCallId, params) => {
|
|
128
|
+
execute: async (_toolCallId, params): Promise<AgentToolResult<ExecDetails>> => {
|
|
109
129
|
if (!dockerAvailable()) {
|
|
110
130
|
return {
|
|
111
131
|
content: [{ type: "text", text: "Docker is not running or not installed." }],
|
|
@@ -163,7 +183,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
163
183
|
}),
|
|
164
184
|
),
|
|
165
185
|
}),
|
|
166
|
-
execute: async (_toolCallId, params) => {
|
|
186
|
+
execute: async (_toolCallId, params): Promise<AgentToolResult<LogsDetails>> => {
|
|
167
187
|
if (!dockerAvailable()) {
|
|
168
188
|
return {
|
|
169
189
|
content: [{ type: "text", text: "Docker is not running or not installed." }],
|
|
@@ -208,9 +228,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
208
228
|
};
|
|
209
229
|
}
|
|
210
230
|
|
|
211
|
-
const ps = exec(
|
|
212
|
-
'docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}\t{{.Size}}"',
|
|
213
|
-
);
|
|
231
|
+
const ps = exec('docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}\t{{.Size}}"');
|
|
214
232
|
|
|
215
233
|
// Get resource usage
|
|
216
234
|
let stats = "";
|
|
@@ -225,9 +243,9 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
225
243
|
}
|
|
226
244
|
|
|
227
245
|
const parts = ["# Docker Status\n"];
|
|
228
|
-
parts.push(
|
|
246
|
+
parts.push(`## Running Containers\n\`\`\`\n${ps || "No containers running"}\n\`\`\`\n`);
|
|
229
247
|
if (stats) {
|
|
230
|
-
parts.push(
|
|
248
|
+
parts.push(`## Resource Usage\n\`\`\`\n${stats}\n\`\`\`\n`);
|
|
231
249
|
}
|
|
232
250
|
|
|
233
251
|
return {
|
|
@@ -261,7 +279,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
261
279
|
}),
|
|
262
280
|
),
|
|
263
281
|
}),
|
|
264
|
-
execute: async (_toolCallId, params) => {
|
|
282
|
+
execute: async (_toolCallId, params): Promise<AgentToolResult<ComposeDetails>> => {
|
|
265
283
|
if (!dockerAvailable()) {
|
|
266
284
|
return {
|
|
267
285
|
content: [{ type: "text", text: "Docker is not running or not installed." }],
|
|
@@ -325,7 +343,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
325
343
|
}),
|
|
326
344
|
),
|
|
327
345
|
}),
|
|
328
|
-
execute: async (_toolCallId, params) => {
|
|
346
|
+
execute: async (_toolCallId, params): Promise<AgentToolResult<EnvCheckDetails>> => {
|
|
329
347
|
if (!dockerAvailable()) {
|
|
330
348
|
return {
|
|
331
349
|
content: [{ type: "text", text: "Docker is not running or not installed." }],
|
|
@@ -353,7 +371,10 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
353
371
|
const eqIdx = trimmed.indexOf("=");
|
|
354
372
|
if (eqIdx === -1) continue;
|
|
355
373
|
const key = trimmed.slice(0, eqIdx).trim();
|
|
356
|
-
const value = trimmed
|
|
374
|
+
const value = trimmed
|
|
375
|
+
.slice(eqIdx + 1)
|
|
376
|
+
.trim()
|
|
377
|
+
.replace(/^["']|["']$/g, "");
|
|
357
378
|
hostEnv.set(key, value);
|
|
358
379
|
}
|
|
359
380
|
|
|
@@ -381,9 +402,22 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
381
402
|
|
|
382
403
|
// Skip common system vars for "extra in container" check
|
|
383
404
|
const systemVars = new Set([
|
|
384
|
-
"PATH",
|
|
385
|
-
"
|
|
386
|
-
"
|
|
405
|
+
"PATH",
|
|
406
|
+
"HOME",
|
|
407
|
+
"HOSTNAME",
|
|
408
|
+
"TERM",
|
|
409
|
+
"SHLVL",
|
|
410
|
+
"PWD",
|
|
411
|
+
"LANG",
|
|
412
|
+
"LC_ALL",
|
|
413
|
+
"GPG_KEY",
|
|
414
|
+
"PHPIZE_DEPS",
|
|
415
|
+
"PHP_INI_DIR",
|
|
416
|
+
"PHP_VERSION",
|
|
417
|
+
"PHP_SHA256",
|
|
418
|
+
"COMPOSER_ALLOW_SUPERUSER",
|
|
419
|
+
"NODE_VERSION",
|
|
420
|
+
"YARN_VERSION",
|
|
387
421
|
]);
|
|
388
422
|
for (const [key] of containerEnv) {
|
|
389
423
|
if (!hostEnv.has(key) && !systemVars.has(key) && !key.startsWith("_")) {
|
|
@@ -438,9 +472,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
438
472
|
return;
|
|
439
473
|
}
|
|
440
474
|
|
|
441
|
-
const ps = exec(
|
|
442
|
-
'docker ps --format "{{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"',
|
|
443
|
-
);
|
|
475
|
+
const ps = exec('docker ps --format "{{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"');
|
|
444
476
|
|
|
445
477
|
if (!ps) {
|
|
446
478
|
ctx.ui.notify("No Docker containers running.", "info");
|
|
@@ -452,10 +484,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
452
484
|
return ` ${name}\t${image}\t${status}\t${ports || ""}`;
|
|
453
485
|
});
|
|
454
486
|
|
|
455
|
-
ctx.ui.notify(
|
|
456
|
-
`Docker Containers:\n\n${lines.join("\n")}`,
|
|
457
|
-
"info",
|
|
458
|
-
);
|
|
487
|
+
ctx.ui.notify(`Docker Containers:\n\n${lines.join("\n")}`, "info");
|
|
459
488
|
},
|
|
460
489
|
});
|
|
461
490
|
}
|