@opencode/codemode 2.2.6 → 2.2.7
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 +109 -21
- package/dist/codemode.d.ts +6 -1
- package/dist/codemode.js +2 -2
- package/dist/extension.d.ts +13 -0
- package/dist/extension.js +5 -1
- package/dist/index.d.ts +1 -1
- package/dist/interpreter/callback.d.ts +12 -1
- package/dist/interpreter/callback.js +13 -1
- package/dist/interpreter/interpreter.js +2 -2
- package/dist/interpreter/promises.js +2 -2
- package/dist/interpreter/runner.d.ts +1 -11
- package/dist/interpreter/runner.js +1 -13
- package/dist/stdlib/iterator.js +1 -2
- package/dist/suspend-error.d.ts +3 -2
- package/dist/suspend-error.js +3 -3
- package/dist/tool-runtime.d.ts +27 -6
- package/dist/tool-runtime.js +116 -26
- package/dist/tool.d.ts +45 -2
- package/dist/tool.js +30 -7
- package/dist/vm/host.d.ts +4 -1
- package/dist/vm/host.js +9 -4
- package/dist/vm/runtime/driver.d.ts +17 -7
- package/dist/vm/runtime/driver.js +89 -19
- package/dist/vm/runtime/execute.d.ts +1 -1
- package/dist/vm/runtime/execute.js +35 -7
- package/dist/vm/runtime/extensions.d.ts +1 -1
- package/dist/vm/runtime/extensions.js +82 -15
- package/dist/vm/runtime/interpreter.d.ts +3 -0
- package/dist/vm/runtime/interpreter.js +2 -0
- package/dist/vm/scheduler.d.ts +15 -3
- package/dist/vm/scheduler.js +13 -2
- package/dist/vm/snapshot/codec.d.ts +31 -1
- package/dist/vm/snapshot/codec.js +100 -3
- package/dist/vm/snapshot/snapshot.d.ts +5 -1
- package/dist/vm/snapshot/snapshot.js +5 -1
- package/dist/vm/snapshot.js +4 -1
- package/dist/vm/vm.d.ts +1 -0
- package/package.json +3 -3
|
@@ -19,8 +19,12 @@ export type Snapshot = {
|
|
|
19
19
|
export type Header = {
|
|
20
20
|
/** The build that wrote it: the package version, and a hash of the opcodes, the prelude's bytecode, codecs, and built-ins. */
|
|
21
21
|
readonly build: string;
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* A hash of the host's globals (extensions, a test harness), and of each extension's name and whether it has
|
|
24
|
+
* `snapshot` hooks, which the restoring runtime must have too.
|
|
25
|
+
*/
|
|
23
26
|
readonly hosts: string;
|
|
27
|
+
readonly runId: string;
|
|
24
28
|
/** The program texts, re-parsed and recompiled on restore, and checked against their hashes and bytecode hashes. */
|
|
25
29
|
readonly sources: ReadonlyArray<{
|
|
26
30
|
readonly id: string;
|
|
@@ -2,7 +2,10 @@ import { fromBytes, SnapshotError, toBytes } from "../../suspend-error.js";
|
|
|
2
2
|
export { fromBytes, SnapshotError, toBytes };
|
|
3
3
|
/** The snapshot format this build writes and reads: the bytecode VM's (see `src/vm/snapshot.ts`). */
|
|
4
4
|
export const FORMAT = 2;
|
|
5
|
-
export const hostsId = (ctx) => hash(
|
|
5
|
+
export const hostsId = (ctx) => hash([
|
|
6
|
+
...ctx.intrinsics.hosts(),
|
|
7
|
+
...(ctx.hosts?.extensions ?? []).map((extension) => `${extension.name} ${extension.hooked ? "hooks" : "no hooks"}`),
|
|
8
|
+
].join("\n"));
|
|
6
9
|
// --- Validation ---
|
|
7
10
|
const fail = (message) => {
|
|
8
11
|
throw new SnapshotError(`Invalid snapshot: ${message}`);
|
|
@@ -27,6 +30,7 @@ export const validate = (saved) => {
|
|
|
27
30
|
const checked = {
|
|
28
31
|
build: string(header.build, "the build"),
|
|
29
32
|
hosts: string(header.hosts, "the host globals"),
|
|
33
|
+
runId: string(header.runId, "the run id"),
|
|
30
34
|
sources: array(header.sources, "the sources").map((item) => {
|
|
31
35
|
const source = object(item, "a source");
|
|
32
36
|
return {
|
package/dist/vm/snapshot.js
CHANGED
|
@@ -34,7 +34,7 @@ const vmSpecs = () => (specs ??= [
|
|
|
34
34
|
name: "HostCalls",
|
|
35
35
|
ctor: HostCalls,
|
|
36
36
|
anchor: "hosts",
|
|
37
|
-
fields: ["queued", "running", "inbox", "nextID", "blocked", "input"],
|
|
37
|
+
fields: ["runId", "queued", "running", "inbox", "nextID", "blocked", "input"],
|
|
38
38
|
skip: ["ctx", "promises", "extension", "extensionResume"],
|
|
39
39
|
},
|
|
40
40
|
{
|
|
@@ -111,6 +111,7 @@ export const captureVm = (vm, options) => {
|
|
|
111
111
|
},
|
|
112
112
|
lost,
|
|
113
113
|
strict: options.strict,
|
|
114
|
+
hosts: ctx.hosts,
|
|
114
115
|
specs: vmSpecs(),
|
|
115
116
|
external: (value) => {
|
|
116
117
|
if (value === HOLE)
|
|
@@ -128,6 +129,7 @@ export const captureVm = (vm, options) => {
|
|
|
128
129
|
header: {
|
|
129
130
|
build: buildId(),
|
|
130
131
|
hosts: hostsId(ctx),
|
|
132
|
+
runId: vm.hosts.runId,
|
|
131
133
|
sources: programs.map((source) => ({
|
|
132
134
|
id: source.id,
|
|
133
135
|
code: source.code,
|
|
@@ -179,6 +181,7 @@ export const restoreVm = (vm, saved, options) => {
|
|
|
179
181
|
anchor: (name) => anchors.get(name),
|
|
180
182
|
node: (source, index) => sources.get(source)?.nodes[index],
|
|
181
183
|
interruption: options.interruption,
|
|
184
|
+
hosts: ctx.hosts,
|
|
182
185
|
specs: vmSpecs(),
|
|
183
186
|
external: (data) => {
|
|
184
187
|
if (data === "hole")
|
package/dist/vm/vm.d.ts
CHANGED
|
@@ -119,6 +119,7 @@ export declare class Vm {
|
|
|
119
119
|
* program value or its concurrent call is running: it holds live host values.
|
|
120
120
|
*/
|
|
121
121
|
get activeExtension(): {
|
|
122
|
+
readonly key: string;
|
|
122
123
|
readonly path: string;
|
|
123
124
|
} | undefined;
|
|
124
125
|
/** Saves the run's state as it is now. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@opencode/codemode",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.7",
|
|
5
5
|
"description": "Effect-native confined code execution over schema-described tools",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
],
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|