@ai-hero/sandcastle 0.0.1 → 0.1.4
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/LICENSE +21 -0
- package/README.md +152 -90
- package/dist/AgentProvider.d.ts.map +1 -1
- package/dist/AgentProvider.js +0 -6
- package/dist/AgentProvider.js.map +1 -1
- package/dist/Display.d.ts +6 -0
- package/dist/Display.d.ts.map +1 -1
- package/dist/Display.js +7 -0
- package/dist/Display.js.map +1 -1
- package/dist/InitService.d.ts.map +1 -1
- package/dist/InitService.js +0 -1
- package/dist/InitService.js.map +1 -1
- package/dist/Orchestrator.d.ts +15 -2
- package/dist/Orchestrator.d.ts.map +1 -1
- package/dist/Orchestrator.js +76 -18
- package/dist/Orchestrator.js.map +1 -1
- package/dist/PromptArgumentSubstitution.d.ts +5 -0
- package/dist/PromptArgumentSubstitution.d.ts.map +1 -1
- package/dist/PromptArgumentSubstitution.js.map +1 -1
- package/dist/SandboxLifecycle.js +7 -7
- package/dist/SandboxLifecycle.js.map +1 -1
- package/dist/cli.d.ts +0 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +16 -16
- package/dist/cli.js.map +1 -1
- package/dist/main.js +0 -0
- package/dist/run.d.ts +32 -5
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +35 -15
- package/dist/run.js.map +1 -1
- package/dist/templates/blank/prompt.md +1 -1
- package/dist/templates/parallel-planner/main.ts +37 -28
- package/dist/templates/parallel-planner/merge-prompt.md +1 -1
- package/dist/templates/parallel-planner/plan-prompt.md +1 -1
- package/dist/templates/sequential-reviewer/review-prompt.md +32 -20
- package/dist/templates/simple-loop/prompt.md +1 -1
- package/dist/templates.js +1 -1
- package/dist/templates.js.map +1 -1
- package/package.json +7 -1
- package/dist/Config.d.ts +0 -35
- package/dist/Config.d.ts.map +0 -1
- package/dist/Config.js +0 -56
- package/dist/Config.js.map +0 -1
- package/dist/DockerSandbox.d.ts +0 -6
- package/dist/DockerSandbox.d.ts.map +0 -1
- package/dist/DockerSandbox.js +0 -122
- package/dist/DockerSandbox.js.map +0 -1
- package/dist/FilesystemSandbox.d.ts +0 -6
- package/dist/FilesystemSandbox.d.ts.map +0 -1
- package/dist/FilesystemSandbox.js +0 -83
- package/dist/FilesystemSandbox.js.map +0 -1
- package/dist/Sandbox.d.ts +0 -23
- package/dist/Sandbox.d.ts.map +0 -1
- package/dist/Sandbox.js +0 -5
- package/dist/Sandbox.js.map +0 -1
- package/dist/SyncService.d.ts +0 -20
- package/dist/SyncService.d.ts.map +0 -1
- package/dist/SyncService.js +0 -504
- package/dist/SyncService.js.map +0 -1
- package/dist/TokenResolver.d.ts +0 -6
- package/dist/TokenResolver.d.ts.map +0 -1
- package/dist/TokenResolver.js +0 -43
- package/dist/TokenResolver.js.map +0 -1
|
@@ -167,34 +167,43 @@ for (let iteration = 1; iteration <= MAX_ITERATIONS; iteration++) {
|
|
|
167
167
|
continue;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
170
|
+
if (completedBranches.length === 1) {
|
|
171
|
+
// Single branch — merge directly without spinning up a merge agent.
|
|
172
|
+
const { execSync } = await import("node:child_process");
|
|
173
|
+
const branch = completedBranches[0]!;
|
|
174
|
+
console.log(`\nSingle branch — merging ${branch} directly.`);
|
|
175
|
+
execSync(`git merge ${branch}`, { stdio: "inherit" });
|
|
176
|
+
console.log("\nBranch merged.");
|
|
177
|
+
} else {
|
|
178
|
+
// -------------------------------------------------------------------------
|
|
179
|
+
// Phase 3: Merge
|
|
180
|
+
//
|
|
181
|
+
// One sonnet agent merges all completed branches into the current branch,
|
|
182
|
+
// resolving any conflicts and running tests to confirm everything still works.
|
|
183
|
+
//
|
|
184
|
+
// The {{BRANCHES}} and {{ISSUES}} prompt arguments are lists that the agent
|
|
185
|
+
// uses to know which branches to merge and which issues to close.
|
|
186
|
+
// -------------------------------------------------------------------------
|
|
187
|
+
await sandcastle.run({
|
|
188
|
+
hooks,
|
|
189
|
+
copyToSandbox,
|
|
190
|
+
name: "merger",
|
|
191
|
+
maxIterations: 10,
|
|
192
|
+
// Sonnet is sufficient for merge conflict resolution.
|
|
193
|
+
model: "claude-sonnet-4-6",
|
|
194
|
+
promptFile: "./.sandcastle/merge-prompt.md",
|
|
195
|
+
promptArgs: {
|
|
196
|
+
// A markdown list of branch names, one per line.
|
|
197
|
+
BRANCHES: completedBranches.map((b) => `- ${b}`).join("\n"),
|
|
198
|
+
// A markdown list of issue numbers and titles, one per line.
|
|
199
|
+
ISSUES: completedIssues
|
|
200
|
+
.map((i) => `- #${i.number}: ${i.title}`)
|
|
201
|
+
.join("\n"),
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
console.log("\nBranches merged.");
|
|
206
|
+
}
|
|
198
207
|
}
|
|
199
208
|
|
|
200
209
|
console.log("\nAll done.");
|
|
@@ -8,7 +8,7 @@ For each branch:
|
|
|
8
8
|
|
|
9
9
|
1. Run `git merge <branch> --no-edit`
|
|
10
10
|
2. If there are merge conflicts, resolve them intelligently by reading both sides and choosing the correct resolution
|
|
11
|
-
3. After resolving conflicts, run `npm run typecheck` and `
|
|
11
|
+
3. After resolving conflicts, run `npm run typecheck` and `npm run test` to verify everything works
|
|
12
12
|
4. If tests fail, fix the issues before proceeding to the next branch
|
|
13
13
|
|
|
14
14
|
After all branches are merged, make a single commit summarizing the merge.
|
|
@@ -4,7 +4,7 @@ Here are the open issues in the repo:
|
|
|
4
4
|
|
|
5
5
|
<issues-json>
|
|
6
6
|
|
|
7
|
-
!`gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'`
|
|
7
|
+
!`gh issue list --state open --label Sandcastle --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'`
|
|
8
8
|
|
|
9
9
|
</issues-json>
|
|
10
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TASK
|
|
2
2
|
|
|
3
|
-
Review the code changes on branch `{{BRANCH}}` and
|
|
3
|
+
Review the code changes on branch `{{BRANCH}}` and improve code clarity, consistency, and maintainability while preserving exact functionality.
|
|
4
4
|
|
|
5
5
|
# CONTEXT
|
|
6
6
|
|
|
@@ -12,32 +12,44 @@ Review the code changes on branch `{{BRANCH}}` and provide actionable feedback.
|
|
|
12
12
|
|
|
13
13
|
!`git log main..{{BRANCH}} --oneline`
|
|
14
14
|
|
|
15
|
-
# REVIEW
|
|
15
|
+
# REVIEW PROCESS
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
1. **Understand the change**: Read the diff and commits above to understand the intent.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
2. **Analyze for improvements**: Look for opportunities to:
|
|
20
|
+
- Reduce unnecessary complexity and nesting
|
|
21
|
+
- Eliminate redundant code and abstractions
|
|
22
|
+
- Improve readability through clear variable and function names
|
|
23
|
+
- Consolidate related logic
|
|
24
|
+
- Remove unnecessary comments that describe obvious code
|
|
25
|
+
- Avoid nested ternary operators - prefer switch statements or if/else chains
|
|
26
|
+
- Choose clarity over brevity - explicit code is often better than overly compact code
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
3. **Check correctness**:
|
|
29
|
+
- Does the implementation match the intent? Are edge cases handled?
|
|
30
|
+
- Are new/changed behaviours covered by tests?
|
|
31
|
+
- Are there unsafe casts, `any` types, or unchecked assumptions?
|
|
32
|
+
- Does the change introduce injection vulnerabilities, credential leaks, or other security issues?
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
4. **Maintain balance**: Avoid over-simplification that could:
|
|
35
|
+
- Reduce code clarity or maintainability
|
|
36
|
+
- Create overly clever solutions that are hard to understand
|
|
37
|
+
- Combine too many concerns into single functions or components
|
|
38
|
+
- Remove helpful abstractions that improve code organization
|
|
39
|
+
- Make the code harder to debug or extend
|
|
28
40
|
|
|
29
|
-
|
|
30
|
-
REVIEW RESULT: APPROVED
|
|
41
|
+
5. **Apply project standards**: Follow the established coding standards in the project.
|
|
31
42
|
|
|
32
|
-
|
|
33
|
-
```
|
|
43
|
+
6. **Preserve functionality**: Never change what the code does - only how it does it. All original features, outputs, and behaviors must remain intact.
|
|
34
44
|
|
|
35
|
-
|
|
45
|
+
# EXECUTION
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
REVIEW RESULT: CHANGES MADE
|
|
47
|
+
If you find improvements to make:
|
|
39
48
|
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
1. Make the changes directly on this branch
|
|
50
|
+
2. Run tests and type checking to ensure nothing is broken
|
|
51
|
+
3. Commit describing the refinements
|
|
42
52
|
|
|
43
|
-
|
|
53
|
+
If the code is already clean and well-structured, do nothing.
|
|
54
|
+
|
|
55
|
+
Once complete, output <promise>COMPLETE</promise>.
|
package/dist/templates.js
CHANGED
package/dist/templates.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAC1B;;WAES;IACT,GAAG;IACH,SAAS;IACT,GAAG;IACH;gBACc;IACd,GAAG;IACH,uBAAuB;IACvB,GAAG;IACH,OAAO;IACP,GAAG;IACH,
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAC1B;;WAES;IACT,GAAG;IACH,SAAS;IACT,GAAG;IACH;gBACc;IACd,GAAG;IACH,uBAAuB;IACvB,GAAG;IACH,OAAO;IACP,GAAG;IACH,sDAAsD;IACtD,GAAG;IACH;;;;;;;;;CASD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-hero/sandcastle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "CLI for orchestrating AI agents in isolated sandbox environments",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,10 +33,16 @@
|
|
|
33
33
|
"ai",
|
|
34
34
|
"agent"
|
|
35
35
|
],
|
|
36
|
+
"packageManager": "npm@10.9.2",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/mattpocock/sandcastle"
|
|
40
|
+
},
|
|
36
41
|
"license": "MIT",
|
|
37
42
|
"devDependencies": {
|
|
38
43
|
"@changesets/cli": "^2.30.0",
|
|
39
44
|
"@effect/vitest": "^0.28.0",
|
|
45
|
+
"@types/node": "^25.5.0",
|
|
40
46
|
"@typescript/native-preview": "^7.0.0-dev.20260317.1",
|
|
41
47
|
"husky": "^9.1.7",
|
|
42
48
|
"lint-staged": "^15.5.1",
|
package/dist/Config.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { FileSystem } from "@effect/platform";
|
|
2
|
-
import { Effect, Schema } from "effect";
|
|
3
|
-
declare const HookDefinition: Schema.Struct<{
|
|
4
|
-
command: typeof Schema.String;
|
|
5
|
-
}>;
|
|
6
|
-
declare const SandcastleConfigSchema: Schema.Struct<{
|
|
7
|
-
hooks: Schema.optional<Schema.Struct<{
|
|
8
|
-
onSandboxReady: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
9
|
-
command: typeof Schema.String;
|
|
10
|
-
}>>>;
|
|
11
|
-
}>>;
|
|
12
|
-
defaultMaxIterations: Schema.optional<typeof Schema.Number>;
|
|
13
|
-
model: Schema.optional<typeof Schema.String>;
|
|
14
|
-
agent: Schema.optional<typeof Schema.String>;
|
|
15
|
-
imageName: Schema.optional<typeof Schema.String>;
|
|
16
|
-
}>;
|
|
17
|
-
export type HookDefinition = typeof HookDefinition.Type;
|
|
18
|
-
export type SandcastleConfig = typeof SandcastleConfigSchema.Type;
|
|
19
|
-
export declare class ConfigError extends Error {
|
|
20
|
-
readonly _tag = "ConfigError";
|
|
21
|
-
constructor(message: string);
|
|
22
|
-
}
|
|
23
|
-
export declare const readConfig: (repoDir: string) => Effect.Effect<{
|
|
24
|
-
readonly hooks?: {
|
|
25
|
-
readonly onSandboxReady?: readonly {
|
|
26
|
-
readonly command: string;
|
|
27
|
-
}[] | undefined;
|
|
28
|
-
} | undefined;
|
|
29
|
-
readonly defaultMaxIterations?: number | undefined;
|
|
30
|
-
readonly model?: string | undefined;
|
|
31
|
-
readonly agent?: string | undefined;
|
|
32
|
-
readonly imageName?: string | undefined;
|
|
33
|
-
}, ConfigError, FileSystem.FileSystem>;
|
|
34
|
-
export {};
|
|
35
|
-
//# sourceMappingURL=Config.d.ts.map
|
package/dist/Config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGxC,QAAA,MAAM,cAAc;;EAEuB,CAAC;AAE5C,QAAA,MAAM,sBAAsB;;;;;;;;;;EAUiB,CAAC;AAE9C,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AACxD,MAAM,MAAM,gBAAgB,GAAG,OAAO,sBAAsB,CAAC,IAAI,CAAC;AAElE,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,YAAY,OAAO,EAAE,MAAM,EAE1B;CACF;AAUD,eAAO,MAAM,UAAU;;;;;;;;;;sCAoCnB,CAAC"}
|
package/dist/Config.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { FileSystem } from "@effect/platform";
|
|
2
|
-
import { Effect, Schema } from "effect";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
const HookDefinition = Schema.Struct({
|
|
5
|
-
command: Schema.String,
|
|
6
|
-
}).annotations({ title: "HookDefinition" });
|
|
7
|
-
const SandcastleConfigSchema = Schema.Struct({
|
|
8
|
-
hooks: Schema.optional(Schema.Struct({
|
|
9
|
-
onSandboxReady: Schema.optional(Schema.Array(HookDefinition)),
|
|
10
|
-
})),
|
|
11
|
-
defaultMaxIterations: Schema.optional(Schema.Number),
|
|
12
|
-
model: Schema.optional(Schema.String),
|
|
13
|
-
agent: Schema.optional(Schema.String),
|
|
14
|
-
imageName: Schema.optional(Schema.String),
|
|
15
|
-
}).annotations({ title: "SandcastleConfig" });
|
|
16
|
-
export class ConfigError extends Error {
|
|
17
|
-
_tag = "ConfigError";
|
|
18
|
-
constructor(message) {
|
|
19
|
-
super(message);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const RENAMED_KEYS = {
|
|
23
|
-
defaultIterations: "defaultMaxIterations",
|
|
24
|
-
};
|
|
25
|
-
const decodeConfig = Schema.decodeUnknownEither(SandcastleConfigSchema, {
|
|
26
|
-
onExcessProperty: "error",
|
|
27
|
-
});
|
|
28
|
-
export const readConfig = (repoDir) => Effect.gen(function* () {
|
|
29
|
-
const fs = yield* FileSystem.FileSystem;
|
|
30
|
-
const content = yield* fs
|
|
31
|
-
.readFileString(join(repoDir, ".sandcastle", "config.json"))
|
|
32
|
-
.pipe(Effect.catchAll(() => Effect.succeed(null)));
|
|
33
|
-
if (content === null)
|
|
34
|
-
return {};
|
|
35
|
-
let raw;
|
|
36
|
-
try {
|
|
37
|
-
raw = JSON.parse(content);
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
return yield* Effect.fail(new ConfigError("Invalid JSON in config.json"));
|
|
41
|
-
}
|
|
42
|
-
// Check for renamed keys and produce clear errors
|
|
43
|
-
if (typeof raw === "object" && raw !== null) {
|
|
44
|
-
for (const [oldKey, newKey] of Object.entries(RENAMED_KEYS)) {
|
|
45
|
-
if (oldKey in raw) {
|
|
46
|
-
return yield* Effect.fail(new ConfigError(`"${oldKey}" has been renamed to "${newKey}" in config.json. Please update your config.`));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const result = decodeConfig(raw);
|
|
51
|
-
if (result._tag === "Left") {
|
|
52
|
-
return yield* Effect.fail(new ConfigError(result.left.message));
|
|
53
|
-
}
|
|
54
|
-
return result.right;
|
|
55
|
-
});
|
|
56
|
-
//# sourceMappingURL=Config.js.map
|
package/dist/Config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Config.js","sourceRoot":"","sources":["../src/Config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAE5C,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAC,QAAQ,CACpB,MAAM,CAAC,MAAM,CAAC;QACZ,cAAc,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;KAC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,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,6BAA6B,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,kDAAkD;IAClD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC5C,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5D,IAAI,MAAM,IAAI,GAAG,EAAE,CAAC;gBAClB,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CACvB,IAAI,WAAW,CACb,IAAI,MAAM,0BAA0B,MAAM,8CAA8C,CACzF,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC,CAAC,CAAC"}
|
package/dist/DockerSandbox.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DockerSandbox.d.ts","sourceRoot":"","sources":["../src/DockerSandbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAKvC,OAAO,EAAE,OAAO,EAAuB,MAAM,cAAc,CAAC;AA+K5D,eAAO,MAAM,aAAa;;CAKzB,CAAC"}
|
package/dist/DockerSandbox.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { FileSystem } from "@effect/platform";
|
|
2
|
-
import { NodeFileSystem } from "@effect/platform-node";
|
|
3
|
-
import { Effect, Layer } from "effect";
|
|
4
|
-
import { execFile, spawn } from "node:child_process";
|
|
5
|
-
import { dirname } from "node:path";
|
|
6
|
-
import { createInterface } from "node:readline";
|
|
7
|
-
import { CopyError, ExecError } from "./errors.js";
|
|
8
|
-
import { Sandbox } from "./Sandbox.js";
|
|
9
|
-
const makeDockerSandbox = (containerName) => Effect.gen(function* () {
|
|
10
|
-
const fs = yield* FileSystem.FileSystem;
|
|
11
|
-
return {
|
|
12
|
-
exec: (command, options) => Effect.async((resume) => {
|
|
13
|
-
const args = ["exec"];
|
|
14
|
-
if (options?.cwd) {
|
|
15
|
-
args.push("-w", options.cwd);
|
|
16
|
-
}
|
|
17
|
-
args.push(containerName, "sh", "-c", command);
|
|
18
|
-
execFile("docker", args, { maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {
|
|
19
|
-
if (error && error.code === undefined) {
|
|
20
|
-
resume(Effect.fail(new ExecError({
|
|
21
|
-
command,
|
|
22
|
-
message: `docker exec failed: ${error.message}`,
|
|
23
|
-
})));
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
resume(Effect.succeed({
|
|
27
|
-
stdout: stdout.toString(),
|
|
28
|
-
stderr: stderr.toString(),
|
|
29
|
-
exitCode: typeof error?.code === "number"
|
|
30
|
-
? error.code
|
|
31
|
-
: 0,
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}),
|
|
36
|
-
execStreaming: (command, onStdoutLine, options) => Effect.async((resume) => {
|
|
37
|
-
const args = ["exec"];
|
|
38
|
-
if (options?.cwd) {
|
|
39
|
-
args.push("-w", options.cwd);
|
|
40
|
-
}
|
|
41
|
-
args.push(containerName, "sh", "-c", command);
|
|
42
|
-
const proc = spawn("docker", args, {
|
|
43
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
44
|
-
});
|
|
45
|
-
const stdoutChunks = [];
|
|
46
|
-
const stderrChunks = [];
|
|
47
|
-
const rl = createInterface({ input: proc.stdout });
|
|
48
|
-
rl.on("line", (line) => {
|
|
49
|
-
stdoutChunks.push(line);
|
|
50
|
-
onStdoutLine(line);
|
|
51
|
-
});
|
|
52
|
-
proc.stderr.on("data", (chunk) => {
|
|
53
|
-
stderrChunks.push(chunk.toString());
|
|
54
|
-
});
|
|
55
|
-
proc.on("error", (error) => {
|
|
56
|
-
resume(Effect.fail(new ExecError({
|
|
57
|
-
command,
|
|
58
|
-
message: `docker exec streaming failed: ${error.message}`,
|
|
59
|
-
})));
|
|
60
|
-
});
|
|
61
|
-
proc.on("close", (code) => {
|
|
62
|
-
resume(Effect.succeed({
|
|
63
|
-
stdout: stdoutChunks.join("\n"),
|
|
64
|
-
stderr: stderrChunks.join(""),
|
|
65
|
-
exitCode: code ?? 0,
|
|
66
|
-
}));
|
|
67
|
-
});
|
|
68
|
-
}),
|
|
69
|
-
copyIn: (hostPath, sandboxPath) => Effect.gen(function* () {
|
|
70
|
-
// Ensure parent directory exists in container
|
|
71
|
-
const parentDir = dirname(sandboxPath);
|
|
72
|
-
yield* Effect.async((resume) => {
|
|
73
|
-
execFile("docker", ["exec", containerName, "mkdir", "-p", parentDir], (error) => {
|
|
74
|
-
if (error) {
|
|
75
|
-
resume(Effect.fail(new CopyError({
|
|
76
|
-
message: `Failed to create dir ${parentDir}: ${error.message}`,
|
|
77
|
-
})));
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
resume(Effect.succeed(undefined));
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
// docker cp hostPath containerName:sandboxPath
|
|
85
|
-
yield* Effect.async((resume) => {
|
|
86
|
-
execFile("docker", ["cp", hostPath, `${containerName}:${sandboxPath}`], (error) => {
|
|
87
|
-
if (error) {
|
|
88
|
-
resume(Effect.fail(new CopyError({
|
|
89
|
-
message: `Failed to copy ${hostPath} -> ${containerName}:${sandboxPath}: ${error.message}`,
|
|
90
|
-
})));
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
resume(Effect.succeed(undefined));
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
}),
|
|
98
|
-
copyOut: (sandboxPath, hostPath) => Effect.gen(function* () {
|
|
99
|
-
// Ensure parent directory exists on host
|
|
100
|
-
yield* fs.makeDirectory(dirname(hostPath), { recursive: true }).pipe(Effect.mapError((error) => new CopyError({
|
|
101
|
-
message: `Failed to create host dir ${dirname(hostPath)}: ${error}`,
|
|
102
|
-
})));
|
|
103
|
-
// docker cp containerName:sandboxPath hostPath
|
|
104
|
-
yield* Effect.async((resume) => {
|
|
105
|
-
execFile("docker", ["cp", `${containerName}:${sandboxPath}`, hostPath], (error) => {
|
|
106
|
-
if (error) {
|
|
107
|
-
resume(Effect.fail(new CopyError({
|
|
108
|
-
message: `Failed to copy ${containerName}:${sandboxPath} -> ${hostPath}: ${error.message}`,
|
|
109
|
-
})));
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
resume(Effect.succeed(undefined));
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
}),
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
export const DockerSandbox = {
|
|
120
|
-
layer: (containerName) => Layer.effect(Sandbox, makeDockerSandbox(containerName)).pipe(Layer.provide(NodeFileSystem.layer)),
|
|
121
|
-
};
|
|
122
|
-
//# sourceMappingURL=DockerSandbox.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DockerSandbox.js","sourceRoot":"","sources":["../src/DockerSandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,C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AAC,IAAI,EAAE,GAAG,aAAa,IAAI,WAAW,EAAE,EAAE,QAAQ,CAAC,EACnD,CAAC,KAAK,EAAE,EAAE;oBACR,IAAI,KAAK,EAAE,CAAC;wBACV,MAAM,CACJ,MAAM,CAAC,IAAI,CACT,IAAI,SAAS,CAAC;4BACZ,OAAO,EAAE,kBAAkB,aAAa,IAAI,WAAW,OAAO,QAAQ,KAAK,KAAK,CAAC,OAAO,EAAE;yBAC3F,CAAC,CACH,CACF,CAAC;oBACJ,CAAC;yBAAM,CAAC;wBACN,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;oBACpC,CAAC;gBACH,CAAC,CACF,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;KACL,CAAC;AACJ,CAAC,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,KAAK,EAAE,CAAC,aAAqB,EAAwB,EAAE,CACrD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAC1D,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CACpC;CACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FilesystemSandbox.d.ts","sourceRoot":"","sources":["../src/FilesystemSandbox.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAKvC,OAAO,EAAE,OAAO,EAAuB,MAAM,cAAc,CAAC;AA8H5D,eAAO,MAAM,iBAAiB;;CAK7B,CAAC"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { FileSystem } from "@effect/platform";
|
|
2
|
-
import { NodeFileSystem } from "@effect/platform-node";
|
|
3
|
-
import { Effect, Layer } from "effect";
|
|
4
|
-
import { execFile, spawn } from "node:child_process";
|
|
5
|
-
import { dirname } from "node:path";
|
|
6
|
-
import { createInterface } from "node:readline";
|
|
7
|
-
import { CopyError, ExecError } from "./errors.js";
|
|
8
|
-
import { Sandbox } from "./Sandbox.js";
|
|
9
|
-
const makeFilesystemSandbox = (sandboxDir) => Effect.gen(function* () {
|
|
10
|
-
const fs = yield* FileSystem.FileSystem;
|
|
11
|
-
return {
|
|
12
|
-
exec: (command, options) => Effect.async((resume) => {
|
|
13
|
-
execFile("sh", ["-c", command], { cwd: options?.cwd ?? sandboxDir }, (error, stdout, stderr) => {
|
|
14
|
-
if (error && error.code === undefined) {
|
|
15
|
-
resume(Effect.fail(new ExecError({
|
|
16
|
-
command,
|
|
17
|
-
message: `Failed to exec: ${error.message}`,
|
|
18
|
-
})));
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
resume(Effect.succeed({
|
|
22
|
-
stdout: stdout.toString(),
|
|
23
|
-
stderr: stderr.toString(),
|
|
24
|
-
exitCode: typeof error?.code === "number"
|
|
25
|
-
? error.code
|
|
26
|
-
: 0,
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}),
|
|
31
|
-
execStreaming: (command, onStdoutLine, options) => Effect.async((resume) => {
|
|
32
|
-
const proc = spawn("sh", ["-c", command], {
|
|
33
|
-
cwd: options?.cwd ?? sandboxDir,
|
|
34
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
35
|
-
});
|
|
36
|
-
const stdoutChunks = [];
|
|
37
|
-
const stderrChunks = [];
|
|
38
|
-
const rl = createInterface({ input: proc.stdout });
|
|
39
|
-
rl.on("line", (line) => {
|
|
40
|
-
stdoutChunks.push(line);
|
|
41
|
-
onStdoutLine(line);
|
|
42
|
-
});
|
|
43
|
-
proc.stderr.on("data", (chunk) => {
|
|
44
|
-
stderrChunks.push(chunk.toString());
|
|
45
|
-
});
|
|
46
|
-
proc.on("error", (error) => {
|
|
47
|
-
resume(Effect.fail(new ExecError({
|
|
48
|
-
command,
|
|
49
|
-
message: `Failed to exec: ${error.message}`,
|
|
50
|
-
})));
|
|
51
|
-
});
|
|
52
|
-
proc.on("close", (code) => {
|
|
53
|
-
resume(Effect.succeed({
|
|
54
|
-
stdout: stdoutChunks.join("\n"),
|
|
55
|
-
stderr: stderrChunks.join(""),
|
|
56
|
-
exitCode: code ?? 0,
|
|
57
|
-
}));
|
|
58
|
-
});
|
|
59
|
-
}),
|
|
60
|
-
copyIn: (hostPath, sandboxPath) => Effect.gen(function* () {
|
|
61
|
-
yield* fs
|
|
62
|
-
.makeDirectory(dirname(sandboxPath), { recursive: true })
|
|
63
|
-
.pipe(Effect.mapError((error) => new CopyError({
|
|
64
|
-
message: `Failed to copy ${hostPath} -> ${sandboxPath}: ${error}`,
|
|
65
|
-
})));
|
|
66
|
-
yield* fs.copyFile(hostPath, sandboxPath).pipe(Effect.mapError((error) => new CopyError({
|
|
67
|
-
message: `Failed to copy ${hostPath} -> ${sandboxPath}: ${error}`,
|
|
68
|
-
})));
|
|
69
|
-
}),
|
|
70
|
-
copyOut: (sandboxPath, hostPath) => Effect.gen(function* () {
|
|
71
|
-
yield* fs.makeDirectory(dirname(hostPath), { recursive: true }).pipe(Effect.mapError((error) => new CopyError({
|
|
72
|
-
message: `Failed to copy ${sandboxPath} -> ${hostPath}: ${error}`,
|
|
73
|
-
})));
|
|
74
|
-
yield* fs.copyFile(sandboxPath, hostPath).pipe(Effect.mapError((error) => new CopyError({
|
|
75
|
-
message: `Failed to copy ${sandboxPath} -> ${hostPath}: ${error}`,
|
|
76
|
-
})));
|
|
77
|
-
}),
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
export const FilesystemSandbox = {
|
|
81
|
-
layer: (sandboxDir) => Layer.effect(Sandbox, makeFilesystemSandbox(sandboxDir)).pipe(Layer.provide(NodeFileSystem.layer)),
|
|
82
|
-
};
|
|
83
|
-
//# sourceMappingURL=FilesystemSandbox.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FilesystemSandbox.js","sourceRoot":"","sources":["../src/FilesystemSandbox.ts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AE,CAAC,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAClE,MAAM,CAAC,QAAQ,CACb,CAAC,KAAK,EAAE,EAAE,CACR,IAAI,SAAS,CAAC;gBACZ,OAAO,EAAE,kBAAkB,WAAW,OAAO,QAAQ,KAAK,KAAK,EAAE;aAClE,CAAC,CACL,CACF,CAAC;YACF,KAAK,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,IAAI,CAC5C,MAAM,CAAC,QAAQ,CACb,CAAC,KAAK,EAAE,EAAE,CACR,IAAI,SAAS,CAAC;gBACZ,OAAO,EAAE,kBAAkB,WAAW,OAAO,QAAQ,KAAK,KAAK,EAAE;aAClE,CAAC,CACL,CACF,CAAC;QACJ,CAAC,CAAC;KACL,CAAC;AACJ,CAAC,CAAC,CAAC;AAEL,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,KAAK,EAAE,CAAC,UAAkB,EAAwB,EAAE,CAClD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAC3D,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CACpC;CACJ,CAAC"}
|
package/dist/Sandbox.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Context, Effect } from "effect";
|
|
2
|
-
import type { CopyError, ExecError } from "./errors.js";
|
|
3
|
-
export { type SandboxError } from "./errors.js";
|
|
4
|
-
export { ExecError, ExecHostError, CopyError, DockerError, SyncError, PromptError, AgentError, ConfigDirError, InitError, } from "./errors.js";
|
|
5
|
-
export interface ExecResult {
|
|
6
|
-
readonly stdout: string;
|
|
7
|
-
readonly stderr: string;
|
|
8
|
-
readonly exitCode: number;
|
|
9
|
-
}
|
|
10
|
-
export interface SandboxService {
|
|
11
|
-
readonly exec: (command: string, options?: {
|
|
12
|
-
cwd?: string;
|
|
13
|
-
}) => Effect.Effect<ExecResult, ExecError>;
|
|
14
|
-
readonly execStreaming: (command: string, onStdoutLine: (line: string) => void, options?: {
|
|
15
|
-
cwd?: string;
|
|
16
|
-
}) => Effect.Effect<ExecResult, ExecError>;
|
|
17
|
-
readonly copyIn: (hostPath: string, sandboxPath: string) => Effect.Effect<void, CopyError>;
|
|
18
|
-
readonly copyOut: (sandboxPath: string, hostPath: string) => Effect.Effect<void, CopyError>;
|
|
19
|
-
}
|
|
20
|
-
declare const Sandbox_base: Context.TagClass<Sandbox, "Sandbox", SandboxService>;
|
|
21
|
-
export declare class Sandbox extends Sandbox_base {
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=Sandbox.d.ts.map
|
package/dist/Sandbox.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Sandbox.d.ts","sourceRoot":"","sources":["../src/Sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,SAAS,EACT,aAAa,EACb,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,EACV,cAAc,EACd,SAAS,GACV,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,CACb,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,KACvB,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAE1C,QAAQ,CAAC,aAAa,EAAE,CACtB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EACpC,OAAO,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,KACvB,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAE1C,QAAQ,CAAC,MAAM,EAAE,CACf,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAEpC,QAAQ,CAAC,OAAO,EAAE,CAChB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,KACb,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;CACrC;;AAED,qBAAa,OAAQ,SAAQ,YAG1B;CAAG"}
|
package/dist/Sandbox.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { Context } from "effect";
|
|
2
|
-
export { ExecError, ExecHostError, CopyError, DockerError, SyncError, PromptError, AgentError, ConfigDirError, InitError, } from "./errors.js";
|
|
3
|
-
export class Sandbox extends Context.Tag("Sandbox")() {
|
|
4
|
-
}
|
|
5
|
-
//# sourceMappingURL=Sandbox.js.map
|
package/dist/Sandbox.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Sandbox.js","sourceRoot":"","sources":["../src/Sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,QAAQ,CAAC;AAIzC,OAAO,EACL,SAAS,EACT,aAAa,EACb,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,UAAU,EACV,cAAc,EACd,SAAS,GACV,MAAM,aAAa,CAAC;AA+BrB,MAAM,OAAO,OAAQ,SAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAGhD;CAAG"}
|
package/dist/SyncService.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
|
-
import { ExecError } from "./errors.js";
|
|
3
|
-
import { type ExecResult, Sandbox, type SandboxError, type SandboxService } from "./Sandbox.js";
|
|
4
|
-
export declare const execOk: (sandbox: SandboxService, command: string, options?: {
|
|
5
|
-
cwd?: string | undefined;
|
|
6
|
-
} | undefined) => Effect.Effect<ExecResult, ExecError, never>;
|
|
7
|
-
export declare const runHooks: (hooks: readonly {
|
|
8
|
-
readonly command: string;
|
|
9
|
-
}[] | undefined, options?: {
|
|
10
|
-
cwd?: string | undefined;
|
|
11
|
-
} | undefined) => Effect.Effect<void, ExecError, Sandbox>;
|
|
12
|
-
export declare const syncIn: (hostRepoDir: string, sandboxRepoDir: string, options?: {
|
|
13
|
-
branch?: string | undefined;
|
|
14
|
-
} | undefined) => Effect.Effect<{
|
|
15
|
-
branch: string;
|
|
16
|
-
}, SandboxError, Sandbox>;
|
|
17
|
-
export declare const syncOut: (hostRepoDir: string, sandboxRepoDir: string, baseHead: string, options?: {
|
|
18
|
-
branch?: string | undefined;
|
|
19
|
-
} | undefined) => Effect.Effect<void, SandboxError, Sandbox>;
|
|
20
|
-
//# sourceMappingURL=SyncService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SyncService.d.ts","sourceRoot":"","sources":["../src/SyncService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAehC,OAAO,EAAE,SAAS,EAA4B,MAAM,aAAa,CAAC;AAClE,OAAO,EACL,KAAK,UAAU,EACf,OAAO,EACP,KAAK,YAAY,EACjB,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;AA4BtB,eAAO,MAAM,MAAM;;6DAchB,CAAC;AAEJ,eAAO,MAAM,QAAQ;;;;yDAUjB,CAAC;AAEL,eAAO,MAAM,MAAM;;;;yBA0Kf,CAAC;AAEL,eAAO,MAAM,OAAO;;4DA2BhB,CAAC"}
|