@snappedly-tools/shipyard 0.7.0 → 0.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.
- package/README.md +34 -41
- package/dist/MountConfig-BHnKnA4h.d.ts +145 -0
- package/dist/{chunk-WAXEMZUV.js → chunk-44I2BL6E.js} +225 -33
- package/dist/chunk-44I2BL6E.js.map +1 -0
- package/dist/{chunk-56TDSWFU.js → chunk-JI3HDDMS.js} +3 -3
- package/dist/{chunk-56TDSWFU.js.map → chunk-JI3HDDMS.js.map} +1 -1
- package/dist/{chunk-FDYOTN55.js → chunk-L6PX5QTU.js} +253 -878
- package/dist/chunk-L6PX5QTU.js.map +1 -0
- package/dist/index.d.ts +117 -97
- package/dist/index.js +322 -344
- package/dist/index.js.map +1 -1
- package/dist/main.js +235 -139
- package/dist/main.js.map +1 -1
- package/dist/sandboxes/docker.d.ts +1 -3
- package/dist/sandboxes/docker.js +2 -4
- package/dist/templates/parallel-planner/main.mts +67 -9
- package/dist/templates/parallel-planner/planner-branch.mts +151 -0
- package/dist/templates/parallel-planner-with-review/main.mts +70 -12
- package/dist/templates/parallel-planner-with-review/planner-branch.mts +151 -0
- package/dist/templates/sequential-reviewer/main.mts +52 -3
- package/dist/templates/simple-loop/main.mts +51 -2
- package/package.json +1 -17
- package/dist/MountConfig-bZoCs4Dd.d.ts +0 -26
- package/dist/SandboxProvider-XJQqEdSf.d.ts +0 -261
- package/dist/chunk-ACD46ZM4.js +0 -136
- package/dist/chunk-ACD46ZM4.js.map +0 -1
- package/dist/chunk-FDYOTN55.js.map +0 -1
- package/dist/chunk-KMGNFXKN.js +0 -38
- package/dist/chunk-KMGNFXKN.js.map +0 -1
- package/dist/chunk-SOJTAJTF.js +0 -78
- package/dist/chunk-SOJTAJTF.js.map +0 -1
- package/dist/chunk-WAXEMZUV.js.map +0 -1
- package/dist/sandboxes/no-sandbox.d.ts +0 -37
- package/dist/sandboxes/no-sandbox.js +0 -4
- package/dist/sandboxes/no-sandbox.js.map +0 -1
- package/dist/sandboxes/vercel.d.ts +0 -104
- package/dist/sandboxes/vercel.js +0 -166
- package/dist/sandboxes/vercel.js.map +0 -1
- package/dist/templates/blank/main.mts +0 -13
- package/dist/templates/blank/prompt.md +0 -12
- package/dist/templates/blank/template.json +0 -4
package/dist/sandboxes/vercel.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { createIsolatedSandboxProvider, shellQuote } from '../chunk-KMGNFXKN.js';
|
|
2
|
-
import { MAX_TAIL_CHARS, StreamedProcessOutput } from '../chunk-ACD46ZM4.js';
|
|
3
|
-
import { execFileSync } from 'child_process';
|
|
4
|
-
import { mkdir, lstat, writeFile, chmod, mkdtemp, readFile, rm } from 'fs/promises';
|
|
5
|
-
import { randomUUID } from 'crypto';
|
|
6
|
-
import { tmpdir } from 'os';
|
|
7
|
-
import { dirname, join } from 'path';
|
|
8
|
-
import { Writable } from 'stream';
|
|
9
|
-
|
|
10
|
-
var VERCEL_REPO_PATH = "/vercel/sandbox/workspace";
|
|
11
|
-
var vercel = (options) => createIsolatedSandboxProvider({
|
|
12
|
-
name: "vercel",
|
|
13
|
-
env: options?.env,
|
|
14
|
-
create: async (createOptions) => {
|
|
15
|
-
const maxOutputTailChars = options?.maxOutputTailChars ?? MAX_TAIL_CHARS;
|
|
16
|
-
const { Sandbox } = await import('@vercel/sandbox');
|
|
17
|
-
const createParams = {};
|
|
18
|
-
if (options?.source) createParams.source = options.source;
|
|
19
|
-
if (options?.ports) createParams.ports = options.ports;
|
|
20
|
-
if (options?.resources) createParams.resources = options.resources;
|
|
21
|
-
if (options?.networkPolicy)
|
|
22
|
-
createParams.networkPolicy = options.networkPolicy;
|
|
23
|
-
const resolvedRuntime = options?.runtime ?? options?.template;
|
|
24
|
-
if (resolvedRuntime) createParams.runtime = resolvedRuntime;
|
|
25
|
-
const timeoutValue = options?.timeout ?? options?.timeoutMs;
|
|
26
|
-
if (timeoutValue !== void 0) createParams.timeout = timeoutValue;
|
|
27
|
-
createParams.env = createOptions.env;
|
|
28
|
-
if (options?.token) createParams.token = options.token;
|
|
29
|
-
if (options?.projectId) createParams.projectId = options.projectId;
|
|
30
|
-
if (options?.teamId) createParams.teamId = options.teamId;
|
|
31
|
-
const sandbox = await Sandbox.create(
|
|
32
|
-
createParams
|
|
33
|
-
);
|
|
34
|
-
await sandbox.mkDir(VERCEL_REPO_PATH);
|
|
35
|
-
const handle = {
|
|
36
|
-
worktreePath: VERCEL_REPO_PATH,
|
|
37
|
-
exec: async (command, opts) => {
|
|
38
|
-
if (opts?.onLine || opts?.maxOutputBytes !== void 0) {
|
|
39
|
-
const output = new StreamedProcessOutput({
|
|
40
|
-
...opts,
|
|
41
|
-
maxOutputTailChars
|
|
42
|
-
});
|
|
43
|
-
let partial = "";
|
|
44
|
-
const stdoutWritable = new Writable({
|
|
45
|
-
write(chunk, _encoding, callback) {
|
|
46
|
-
const error = output.checkLimit(chunk.toString());
|
|
47
|
-
if (error !== void 0) {
|
|
48
|
-
callback(error);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const text = partial + chunk.toString();
|
|
52
|
-
const lines = text.split("\n");
|
|
53
|
-
partial = lines.pop() ?? "";
|
|
54
|
-
for (const line of lines) {
|
|
55
|
-
output.addStdoutLine(line);
|
|
56
|
-
}
|
|
57
|
-
callback();
|
|
58
|
-
},
|
|
59
|
-
final(callback) {
|
|
60
|
-
if (partial) {
|
|
61
|
-
output.addStdoutLine(partial);
|
|
62
|
-
partial = "";
|
|
63
|
-
}
|
|
64
|
-
callback();
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
const stderrWritable = new Writable({
|
|
68
|
-
write(chunk, _encoding, callback) {
|
|
69
|
-
const error = output.checkLimit(chunk.toString());
|
|
70
|
-
if (error !== void 0) {
|
|
71
|
-
callback(error);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
output.addStderr(chunk.toString());
|
|
75
|
-
callback();
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
const result2 = await sandbox.runCommand({
|
|
79
|
-
cmd: "sh",
|
|
80
|
-
args: ["-c", command],
|
|
81
|
-
cwd: opts?.cwd ?? VERCEL_REPO_PATH,
|
|
82
|
-
stdout: stdoutWritable,
|
|
83
|
-
stderr: stderrWritable,
|
|
84
|
-
...opts?.sudo ? { sudo: true } : {}
|
|
85
|
-
});
|
|
86
|
-
if (output.error !== void 0) throw output.error;
|
|
87
|
-
return output.result(result2.exitCode);
|
|
88
|
-
}
|
|
89
|
-
const result = await sandbox.runCommand({
|
|
90
|
-
cmd: "sh",
|
|
91
|
-
args: ["-c", command],
|
|
92
|
-
cwd: opts?.cwd ?? VERCEL_REPO_PATH,
|
|
93
|
-
...opts?.sudo ? { sudo: true } : {}
|
|
94
|
-
});
|
|
95
|
-
const stdout = await result.stdout();
|
|
96
|
-
const stderr = await result.stderr();
|
|
97
|
-
return {
|
|
98
|
-
stdout,
|
|
99
|
-
stderr,
|
|
100
|
-
exitCode: result.exitCode
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
|
-
copyIn: async (hostPath, sandboxPath) => {
|
|
104
|
-
const info = await lstat(hostPath);
|
|
105
|
-
if (info.isSymbolicLink()) {
|
|
106
|
-
throw new Error(`Refusing to copy a symbolic link: ${hostPath}`);
|
|
107
|
-
}
|
|
108
|
-
if (info.isDirectory()) {
|
|
109
|
-
const tempDir = await mkdtemp(join(tmpdir(), "shipyard-copyin-"));
|
|
110
|
-
const tarPath = join(tempDir, "archive.tar.gz");
|
|
111
|
-
try {
|
|
112
|
-
execFileSync("tar", ["-czf", tarPath, "-C", hostPath, "."]);
|
|
113
|
-
const tarContent = await readFile(tarPath);
|
|
114
|
-
const sandboxTarPath = `/tmp/shipyard-copyin-${randomUUID()}.tar.gz`;
|
|
115
|
-
await sandbox.writeFiles([
|
|
116
|
-
{ path: sandboxTarPath, content: tarContent }
|
|
117
|
-
]);
|
|
118
|
-
await sandbox.runCommand({
|
|
119
|
-
cmd: "sh",
|
|
120
|
-
args: [
|
|
121
|
-
"-c",
|
|
122
|
-
`mkdir -p ${shellQuote(sandboxPath)} && tar -xzf ${shellQuote(sandboxTarPath)} -C ${shellQuote(sandboxPath)} && rm -f ${shellQuote(sandboxTarPath)}`
|
|
123
|
-
]
|
|
124
|
-
});
|
|
125
|
-
} finally {
|
|
126
|
-
await rm(tempDir, { recursive: true, force: true }).catch(
|
|
127
|
-
() => {
|
|
128
|
-
}
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
const content = await readFile(hostPath);
|
|
133
|
-
await sandbox.writeFiles([{ path: sandboxPath, content }]);
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
copyFileOut: async (sandboxPath, hostPath) => {
|
|
137
|
-
const buffer = await sandbox.readFileToBuffer({
|
|
138
|
-
path: sandboxPath
|
|
139
|
-
});
|
|
140
|
-
if (!buffer) {
|
|
141
|
-
throw new Error(`File not found in Vercel sandbox: ${sandboxPath}`);
|
|
142
|
-
}
|
|
143
|
-
await mkdir(dirname(hostPath), { recursive: true, mode: 448 });
|
|
144
|
-
try {
|
|
145
|
-
if ((await lstat(hostPath)).isSymbolicLink()) {
|
|
146
|
-
throw new Error(
|
|
147
|
-
`Refusing to overwrite symbolic link: ${hostPath}`
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
} catch (error) {
|
|
151
|
-
if (error.code !== "ENOENT") throw error;
|
|
152
|
-
}
|
|
153
|
-
await writeFile(hostPath, buffer, { mode: 384 });
|
|
154
|
-
await chmod(hostPath, 384);
|
|
155
|
-
},
|
|
156
|
-
close: async () => {
|
|
157
|
-
await sandbox.stop();
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
return handle;
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
export { vercel };
|
|
165
|
-
//# sourceMappingURL=vercel.js.map
|
|
166
|
-
//# sourceMappingURL=vercel.js.map
|
|
@@ -1 +0,0 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QACF,SAAS,KAAA,EAAO;AACd,UAAA,IAAK,KAAA,CAAgC,IAAA,KAAS,QAAA,EAAU,MAAM,KAAA;AAAA,QAChE;AACA,QAAA,MAAM,UAAU,QAAA,EAAU,MAAA,EAAQ,EAAE,IAAA,EAAM,KAAO,CAAA;AACjD,QAAA,MAAM,KAAA,CAAM,UAAU,GAAK,CAAA;AAAA,MAC7B,CAAA;AAAA,MAEA,OAAO,YAA2B;AAChC,QAAA,MAAM,QAAQ,IAAA,EAAK;AAAA,MACrB;AAAA,KACF;AAEA,IAAA,OAAO,MAAA;AAAA,EACT;AACF,CAAC","file":"vercel.js","sourcesContent":["/**\n * Vercel isolated sandbox provider — wraps `@vercel/sandbox` into a SandboxProvider.\n *\n * Usage:\n * import { vercel } from \"@snappedly-tools/shipyard/sandboxes/vercel\";\n * await run({ agent: codex(CODEX_MODELS.routine), sandbox: vercel() });\n */\n\nimport { execFileSync } from \"node:child_process\";\nimport {\n lstat,\n chmod,\n mkdir,\n mkdtemp,\n readFile,\n rm,\n writeFile,\n} from \"node:fs/promises\";\nimport { randomUUID } from \"node:crypto\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { Writable } from \"node:stream\";\nimport {\n createIsolatedSandboxProvider,\n type ExecResult,\n type IsolatedSandboxHandle,\n type IsolatedSandboxProvider,\n} from \"../SandboxProvider.js\";\nimport { MAX_TAIL_CHARS } from \"../boundedTail.js\";\nimport { StreamedProcessOutput } from \"../processOutput.js\";\nimport { shellQuote } from \"../shellQuote.js\";\n\n/** Worktree path inside the Vercel sandbox. */\nconst VERCEL_REPO_PATH = \"/vercel/sandbox/workspace\";\n\n/**\n * Options for creating a Vercel sandbox provider.\n *\n * All `@vercel/sandbox` `Sandbox.create()` options are accepted as pass-through,\n * plus Shipyard-specific options for auth and branch strategy.\n */\nexport interface VercelOptions {\n /**\n * Vercel access token.\n *\n * Falls back to the SDK's default auth behavior, which reads\n * `VERCEL_OIDC_TOKEN` (recommended for Vercel-hosted environments) or\n * `VERCEL_TOKEN` from the environment.\n */\n readonly token?: string;\n\n // ---- Pass-through @vercel/sandbox Sandbox.create() options ----\n\n /**\n * The source of the sandbox (git repo, tarball, or snapshot).\n * Omit to start an empty sandbox.\n */\n readonly source?:\n | {\n type: \"git\";\n url: string;\n depth?: number;\n revision?: string;\n username?: string;\n password?: string;\n }\n | {\n type: \"tarball\";\n url: string;\n }\n | {\n type: \"snapshot\";\n snapshotId: string;\n };\n\n /** Array of port numbers to expose from the sandbox (up to 4). */\n readonly ports?: number[];\n\n /** Timeout in milliseconds before the sandbox auto-terminates. */\n readonly timeout?: number;\n\n /**\n * Resources to allocate to the sandbox.\n * Each vCPU gets 2048 MB of memory.\n */\n readonly resources?: {\n vcpus: number;\n };\n\n /**\n * The runtime of the sandbox (e.g. `\"node24\"`, `\"node22\"`, `\"python3.13\"`).\n * Defaults to `\"node24\"`.\n */\n readonly runtime?: string;\n\n /**\n * Network policy for the sandbox.\n * Defaults to full internet access if not specified.\n */\n readonly networkPolicy?: Record<string, unknown>;\n\n /**\n * Vercel project ID to associate sandbox operations with.\n */\n readonly projectId?: string;\n\n /**\n * Vercel team ID to associate sandbox operations with.\n */\n readonly teamId?: string;\n\n /**\n * Timeout in milliseconds (alias for `timeout`, kept for discoverability).\n */\n readonly timeoutMs?: number;\n\n /**\n * Sandbox template shorthand (e.g. `\"node-22\"`).\n * Maps to the `runtime` option.\n */\n readonly template?: string;\n\n /** Environment variables injected by this provider. Merged at launch time with env resolver and agent provider env. */\n readonly env?: Record<string, string>;\n\n /**\n * Maximum number of characters of streamed `exec` output retained per stream\n * (stdout and stderr) when an `onLine` callback is supplied (default: 64KiB).\n *\n * Output is delivered live to `onLine` regardless; this only bounds the tail\n * returned in `ExecResult`, preventing a long-running agent's output from\n * overflowing V8's max string length and crashing the run.\n */\n readonly maxOutputTailChars?: number;\n}\n\n/**\n * Create a Vercel isolated sandbox provider.\n *\n * The returned provider creates Vercel Firecracker microVM sandboxes via\n * the `@vercel/sandbox` SDK. Each sandbox is ephemeral — one sandbox per run.\n *\n * Requires `@vercel/sandbox` to be installed as a peer dependency.\n */\nexport const vercel = (options?: VercelOptions): IsolatedSandboxProvider =>\n createIsolatedSandboxProvider({\n name: \"vercel\",\n env: options?.env,\n create: async (createOptions): Promise<IsolatedSandboxHandle> => {\n const maxOutputTailChars = options?.maxOutputTailChars ?? MAX_TAIL_CHARS;\n // Dynamic import so the peer dependency is only loaded at runtime\n const { Sandbox } = await import(\"@vercel/sandbox\");\n\n const createParams: Record<string, unknown> = {};\n\n // Pass through SDK options\n if (options?.source) createParams.source = options.source;\n if (options?.ports) createParams.ports = options.ports;\n if (options?.resources) createParams.resources = options.resources;\n if (options?.networkPolicy)\n createParams.networkPolicy = options.networkPolicy;\n // runtime takes precedence over the template convenience alias\n const resolvedRuntime = options?.runtime ?? options?.template;\n if (resolvedRuntime) createParams.runtime = resolvedRuntime;\n\n // Timeout: prefer explicit timeout, fall back to timeoutMs alias\n const timeoutValue = options?.timeout ?? options?.timeoutMs;\n if (timeoutValue !== undefined) createParams.timeout = timeoutValue;\n\n // Merge provider env with Shipyard env\n createParams.env = createOptions.env;\n\n // Auth: pass token and team/project IDs if provided\n if (options?.token) createParams.token = options.token;\n if (options?.projectId) createParams.projectId = options.projectId;\n if (options?.teamId) createParams.teamId = options.teamId;\n\n const sandbox = await Sandbox.create(\n createParams as Parameters<typeof Sandbox.create>[0],\n );\n\n // Ensure worktree directory exists\n await sandbox.mkDir(VERCEL_REPO_PATH);\n\n const handle: IsolatedSandboxHandle = {\n worktreePath: VERCEL_REPO_PATH,\n\n exec: async (\n command: string,\n opts?: {\n onLine?: (line: string) => void;\n cwd?: string;\n sudo?: boolean;\n maxOutputBytes?: number;\n },\n ): Promise<ExecResult> => {\n if (opts?.onLine || opts?.maxOutputBytes !== undefined) {\n const output = new StreamedProcessOutput({\n ...opts,\n maxOutputTailChars,\n });\n let partial = \"\";\n\n const stdoutWritable = new Writable({\n write(chunk, _encoding, callback) {\n const error = output.checkLimit(chunk.toString());\n if (error !== undefined) {\n callback(error);\n return;\n }\n const text = partial + chunk.toString();\n const lines = text.split(\"\\n\");\n partial = lines.pop() ?? \"\";\n for (const line of lines) {\n output.addStdoutLine(line);\n }\n callback();\n },\n final(callback) {\n if (partial) {\n output.addStdoutLine(partial);\n partial = \"\";\n }\n callback();\n },\n });\n\n const stderrWritable = new Writable({\n write(chunk, _encoding, callback) {\n const error = output.checkLimit(chunk.toString());\n if (error !== undefined) {\n callback(error);\n return;\n }\n output.addStderr(chunk.toString());\n callback();\n },\n });\n\n const result = await sandbox.runCommand({\n cmd: \"sh\",\n args: [\"-c\", command],\n cwd: opts?.cwd ?? VERCEL_REPO_PATH,\n stdout: stdoutWritable,\n stderr: stderrWritable,\n ...(opts?.sudo ? { sudo: true } : {}),\n });\n\n if (output.error !== undefined) throw output.error;\n return output.result(result.exitCode);\n }\n\n const result = await sandbox.runCommand({\n cmd: \"sh\",\n args: [\"-c\", command],\n cwd: opts?.cwd ?? VERCEL_REPO_PATH,\n ...(opts?.sudo ? { sudo: true } : {}),\n });\n\n const stdout = await result.stdout();\n const stderr = await result.stderr();\n\n return {\n stdout,\n stderr,\n exitCode: result.exitCode,\n };\n },\n\n copyIn: async (\n hostPath: string,\n sandboxPath: string,\n ): Promise<void> => {\n const info = await lstat(hostPath);\n if (info.isSymbolicLink()) {\n throw new Error(`Refusing to copy a symbolic link: ${hostPath}`);\n }\n if (info.isDirectory()) {\n const tempDir = await mkdtemp(join(tmpdir(), \"shipyard-copyin-\"));\n const tarPath = join(tempDir, \"archive.tar.gz\");\n try {\n execFileSync(\"tar\", [\"-czf\", tarPath, \"-C\", hostPath, \".\"]);\n const tarContent = await readFile(tarPath);\n const sandboxTarPath = `/tmp/shipyard-copyin-${randomUUID()}.tar.gz`;\n await sandbox.writeFiles([\n { path: sandboxTarPath, content: tarContent },\n ]);\n await sandbox.runCommand({\n cmd: \"sh\",\n args: [\n \"-c\",\n `mkdir -p ${shellQuote(sandboxPath)} && tar -xzf ${shellQuote(sandboxTarPath)} -C ${shellQuote(sandboxPath)} && rm -f ${shellQuote(sandboxTarPath)}`,\n ],\n });\n } finally {\n await rm(tempDir, { recursive: true, force: true }).catch(\n () => {},\n );\n }\n } else {\n const content = await readFile(hostPath);\n await sandbox.writeFiles([{ path: sandboxPath, content }]);\n }\n },\n\n copyFileOut: async (\n sandboxPath: string,\n hostPath: string,\n ): Promise<void> => {\n const buffer = await sandbox.readFileToBuffer({\n path: sandboxPath,\n });\n if (!buffer) {\n throw new Error(`File not found in Vercel sandbox: ${sandboxPath}`);\n }\n await mkdir(dirname(hostPath), { recursive: true, mode: 0o700 });\n try {\n if ((await lstat(hostPath)).isSymbolicLink()) {\n throw new Error(\n `Refusing to overwrite symbolic link: ${hostPath}`,\n );\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n }\n await writeFile(hostPath, buffer, { mode: 0o600 });\n await chmod(hostPath, 0o600);\n },\n\n close: async (): Promise<void> => {\n await sandbox.stop();\n },\n };\n\n return handle;\n },\n });\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CODEX_MODELS, run, codex } from "@snappedly-tools/shipyard";
|
|
2
|
-
import { docker } from "@snappedly-tools/shipyard/sandboxes/docker";
|
|
3
|
-
|
|
4
|
-
// Blank template: customize this to build your own orchestration.
|
|
5
|
-
// Generated entrypoint: .shipyard/main.mts
|
|
6
|
-
// Run this with: npx shipyard run
|
|
7
|
-
// Or add to package.json scripts: "shipyard": "shipyard run"
|
|
8
|
-
|
|
9
|
-
await run({
|
|
10
|
-
agent: codex(CODEX_MODELS.routine),
|
|
11
|
-
sandbox: docker(),
|
|
12
|
-
promptFile: "./.shipyard/prompt.md",
|
|
13
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# Context
|
|
2
|
-
|
|
3
|
-
<!-- Use !`command` to pull in dynamic context. Commands run inside the sandbox. -->
|
|
4
|
-
<!-- Example: !`git log --oneline -10` or !`{{LIST_TASKS_COMMAND}}` -->
|
|
5
|
-
|
|
6
|
-
# Task
|
|
7
|
-
|
|
8
|
-
<!-- Describe what the agent should do. -->
|
|
9
|
-
|
|
10
|
-
# Done
|
|
11
|
-
|
|
12
|
-
<!-- When the task is complete, output <promise>COMPLETE</promise> to signal early termination. -->
|