@opencode-ai/simulation 0.0.0-dev-17880
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/dist/backend/index.d.ts +17 -0
- package/dist/backend/index.js +29 -0
- package/dist/backend/network.d.ts +33 -0
- package/dist/backend/network.js +44 -0
- package/dist/backend/openai.d.ts +4 -0
- package/dist/backend/openai.js +101 -0
- package/dist/backend/simulated-provider.d.ts +27 -0
- package/dist/backend/simulated-provider.js +485 -0
- package/dist/control-server.d.ts +27 -0
- package/dist/control-server.js +99 -0
- package/dist/frontend/actions.d.ts +90 -0
- package/dist/frontend/actions.js +154 -0
- package/dist/frontend/renderer.d.ts +18 -0
- package/dist/frontend/renderer.js +38 -0
- package/dist/frontend/semantics.d.ts +8 -0
- package/dist/frontend/semantics.js +7 -0
- package/dist/frontend/server.d.ts +6 -0
- package/dist/frontend/server.js +64 -0
- package/dist/frontend/simulation.d.ts +5 -0
- package/dist/frontend/simulation.js +20 -0
- package/dist/manifest.d.ts +27 -0
- package/dist/manifest.js +61 -0
- package/dist/protocol/index.d.ts +2 -0
- package/dist/protocol/index.js +10 -0
- package/dist/recording.d.ts +65 -0
- package/dist/recording.js +105 -0
- package/package.json +65 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { createWriteStream } from "node:fs";
|
|
2
|
+
import { mkdir } from "node:fs/promises";
|
|
3
|
+
import { dirname } from "node:path";
|
|
4
|
+
import { Writable } from "node:stream";
|
|
5
|
+
import { finished } from "node:stream/promises";
|
|
6
|
+
import { Schema } from "effect";
|
|
7
|
+
export const Header = Schema.Struct({
|
|
8
|
+
type: Schema.Literal("header"),
|
|
9
|
+
version: Schema.Literal(1),
|
|
10
|
+
cols: Schema.Number,
|
|
11
|
+
rows: Schema.Number,
|
|
12
|
+
encoding: Schema.Literal("base64")
|
|
13
|
+
}), Output = Schema.Struct({
|
|
14
|
+
type: Schema.Literal("output"),
|
|
15
|
+
at_ms: Schema.Number,
|
|
16
|
+
data: Schema.String
|
|
17
|
+
}), Resize = Schema.Struct({
|
|
18
|
+
type: Schema.Literal("resize"),
|
|
19
|
+
at_ms: Schema.Number,
|
|
20
|
+
cols: Schema.Number,
|
|
21
|
+
rows: Schema.Number
|
|
22
|
+
}), Event = Schema.Union([Header, Output, Resize]);
|
|
23
|
+
|
|
24
|
+
export class Timeline extends Writable {
|
|
25
|
+
isTTY = !0;
|
|
26
|
+
path;
|
|
27
|
+
columns;
|
|
28
|
+
rows;
|
|
29
|
+
output;
|
|
30
|
+
started = performance.now();
|
|
31
|
+
timestamps = [];
|
|
32
|
+
done;
|
|
33
|
+
constructor(path, cols, rows, output) {
|
|
34
|
+
super();
|
|
35
|
+
this.path = path;
|
|
36
|
+
this.columns = cols;
|
|
37
|
+
this.rows = rows;
|
|
38
|
+
this.output = output;
|
|
39
|
+
this.on("error", () => {});
|
|
40
|
+
output.on("error", (error) => this.destroy(error));
|
|
41
|
+
}
|
|
42
|
+
static async create(path, cols, rows) {
|
|
43
|
+
await mkdir(dirname(path), { recursive: !0 });
|
|
44
|
+
const output = createWriteStream(path), timeline = new Timeline(path, cols, rows, output);
|
|
45
|
+
await new Promise((resolve, reject) => {
|
|
46
|
+
output.write(`${JSON.stringify({ type: "header", version: 1, cols, rows, encoding: "base64" })}
|
|
47
|
+
`, (error) => error ? reject(error) : resolve());
|
|
48
|
+
});
|
|
49
|
+
return timeline;
|
|
50
|
+
}
|
|
51
|
+
getColorDepth() {
|
|
52
|
+
return 24;
|
|
53
|
+
}
|
|
54
|
+
write(chunk, encoding, callback) {
|
|
55
|
+
if (!this.writableEnded) {
|
|
56
|
+
this.timestamps.push(this.elapsed());
|
|
57
|
+
if (typeof encoding === "function")
|
|
58
|
+
return super.write(chunk, encoding);
|
|
59
|
+
if (encoding === void 0)
|
|
60
|
+
return super.write(chunk, callback);
|
|
61
|
+
return super.write(chunk, encoding, callback);
|
|
62
|
+
}
|
|
63
|
+
const done = typeof encoding === "function" ? encoding : callback;
|
|
64
|
+
queueMicrotask(() => done?.(null));
|
|
65
|
+
return !0;
|
|
66
|
+
}
|
|
67
|
+
_write(chunk, _encoding, callback) {
|
|
68
|
+
this.writeOutput(chunk, this.timestamps.shift() ?? this.elapsed(), callback);
|
|
69
|
+
}
|
|
70
|
+
_final(callback) {
|
|
71
|
+
this.writeOutput(Buffer.alloc(0), this.elapsed(), (error) => {
|
|
72
|
+
if (error)
|
|
73
|
+
return callback(error);
|
|
74
|
+
this.output.end(callback);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
finish() {
|
|
78
|
+
if (this.done)
|
|
79
|
+
return this.done;
|
|
80
|
+
this.end();
|
|
81
|
+
this.done = finished(this).then(() => this.path);
|
|
82
|
+
return this.done;
|
|
83
|
+
}
|
|
84
|
+
resize(cols, rows) {
|
|
85
|
+
if (this.writableEnded)
|
|
86
|
+
return;
|
|
87
|
+
const event = { type: "resize", at_ms: this.elapsed(), cols, rows };
|
|
88
|
+
this.output.write(`${JSON.stringify(event)}
|
|
89
|
+
`);
|
|
90
|
+
}
|
|
91
|
+
elapsed() {
|
|
92
|
+
return Math.max(0, Math.round(performance.now() - this.started));
|
|
93
|
+
}
|
|
94
|
+
writeOutput(data, at_ms, callback) {
|
|
95
|
+
const event = {
|
|
96
|
+
type: "output",
|
|
97
|
+
at_ms,
|
|
98
|
+
data: data.toString("base64")
|
|
99
|
+
};
|
|
100
|
+
this.output.write(`${JSON.stringify(event)}
|
|
101
|
+
`, callback);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export * as SimulationRecording from "./recording";
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
+
"name": "@opencode-ai/simulation",
|
|
4
|
+
"version": "0.0.0-dev-17880",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/anomalyco/opencode.git",
|
|
10
|
+
"directory": "packages/simulation"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
"./backend": {
|
|
20
|
+
"import": "./dist/backend/index.js",
|
|
21
|
+
"types": "./dist/backend/index.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./backend/*": {
|
|
24
|
+
"import": "./dist/backend/*.js",
|
|
25
|
+
"types": "./dist/backend/*.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./frontend": {
|
|
28
|
+
"import": "./dist/frontend/simulation.js",
|
|
29
|
+
"types": "./dist/frontend/simulation.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./frontend/*": {
|
|
32
|
+
"import": "./dist/frontend/*.js",
|
|
33
|
+
"types": "./dist/frontend/*.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./protocol": {
|
|
36
|
+
"import": "./dist/protocol/index.js",
|
|
37
|
+
"types": "./dist/protocol/index.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./recording": {
|
|
40
|
+
"import": "./dist/recording.js",
|
|
41
|
+
"types": "./dist/recording.d.ts"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "bun run script/build.ts",
|
|
46
|
+
"test": "bun test --timeout 30000 --only-failures",
|
|
47
|
+
"typecheck": "tsgo -b"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@opencode-ai/core": "0.0.0-dev-17880",
|
|
51
|
+
"@opencode-ai/ai": "0.0.0-dev-17880",
|
|
52
|
+
"@opencode-ai/plugin": "0.0.0-dev-17880",
|
|
53
|
+
"@opencode-ai/protocol": "0.0.0-dev-17880",
|
|
54
|
+
"@opencode-ai/util": "0.0.0-dev-17880",
|
|
55
|
+
"@opentui/core": "0.5.6",
|
|
56
|
+
"effect": "4.0.0-rc.110",
|
|
57
|
+
"ws": "8.21.0"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@tsconfig/bun": "1.0.9",
|
|
61
|
+
"@types/bun": "1.3.13",
|
|
62
|
+
"@types/ws": "8.18.1",
|
|
63
|
+
"@typescript/native-preview": "7.0.0-dev.20251207.1"
|
|
64
|
+
}
|
|
65
|
+
}
|