@codeworksh/harness 0.9.0-canary.158.1.gdff28d0d → 0.9.0-canary.160.1.g8b6596ff
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 +49 -292
- package/effect.d.mts +22 -22
- package/effect.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,329 +1,86 @@
|
|
|
1
1
|
# @codeworksh/harness
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The CodeWork agent harness: durable sessions and threads, the agent loop, tools, plugins, MCP and sandboxes, built on [Effect](https://effect.website). The `codework` CLI and RPC server boot it to run agents, and you can embed it to run them in your own Node process.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
> [!NOTE]
|
|
6
|
+
> This is an early release. Expect breaking changes between minor versions.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## Install
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- **Durable Sessions:** create sessions, fork their threads, and attach, resume, interrupt, and inspect each thread without rebuilding orchestration around every turn.
|
|
13
|
-
- **Streaming Agent Loop:** consume durable session events while the loop coordinates model output, tool calls, and continuations.
|
|
14
|
-
- **Tool Execution:** use the built-in Bash tool or register typed tools with sequential or parallel execution.
|
|
15
|
-
- **Model Flexibility:** select any provider and model available in Aikit's generated catalog, including its supported thinking levels.
|
|
16
|
-
- **Pluggable Sandboxes:** run the same workflow against the host machine, a virtual filesystem, or a remote sandbox.
|
|
17
|
-
|
|
18
|
-
## Plugins
|
|
19
|
-
|
|
20
|
-
Third-party plugins build against [`@codeworksh/plugin`](../plugin/README.md), the published SDK
|
|
21
|
-
that owns the plugin, tool and sandbox contract this package consumes — a plugin package depends
|
|
22
|
-
on it rather than on the whole harness. The same types are re-exported here as `Plugin` and `Tool`
|
|
23
|
-
for embedders who already hold the harness.
|
|
24
|
-
|
|
25
|
-
Pass a plugin list when constructing the harness. Each plugin declares an ID and the domain it extends — `tool` or `prompt` — and contributes during setup. Setup runs before every turn, after model resolution; its tools, hooks, and prompt are pinned for that turn.
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
import { Effect, Schema } from "effect";
|
|
29
|
-
import { Harness, Plugin, Tool } from "@codeworksh/harness/effect";
|
|
30
|
-
|
|
31
|
-
const echo = Plugin.define({
|
|
32
|
-
id: "acme.tool.echo",
|
|
33
|
-
kind: "tool",
|
|
34
|
-
setup(ctx) {
|
|
35
|
-
ctx.plugin.tools.add(
|
|
36
|
-
Tool.register(
|
|
37
|
-
Tool.make({
|
|
38
|
-
name: "echo",
|
|
39
|
-
description: "Echo a message",
|
|
40
|
-
parameters: Schema.Struct({ text: Schema.String }),
|
|
41
|
-
success: Schema.String,
|
|
42
|
-
handler: ({ text }) => Effect.succeed(text),
|
|
43
|
-
}),
|
|
44
|
-
),
|
|
45
|
-
{
|
|
46
|
-
beforeToolCall(call) {
|
|
47
|
-
// Arguments have already been decoded. Return { block: true, reason: "..." }
|
|
48
|
-
// to skip this handler and its after hook.
|
|
49
|
-
},
|
|
50
|
-
afterToolCall({ terminal }) {
|
|
51
|
-
// Completed/error results can be patched through content, details, isError.
|
|
52
|
-
// Aborted results are observation-only; keep cancellation cleanup short.
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
);
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// A prompt plugin writes the foundation and sections; the harness renders the prompt.
|
|
60
|
-
const prompt = Plugin.define({
|
|
61
|
-
id: "acme.prompt.main",
|
|
62
|
-
kind: "prompt",
|
|
63
|
-
setup(ctx) {
|
|
64
|
-
ctx.plugin.prompt.foundation.set("You are a terse assistant.");
|
|
65
|
-
ctx.plugin.prompt.sections.append(Plugin.Section.Rules, "Answer in one sentence.");
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// Omit `plugins` for the built-ins plus whatever settings add; passing it owns the whole
|
|
70
|
-
// selection, which is why this one supplies its own prompt plugin.
|
|
71
|
-
const runtime = Harness.layer({ plugins: [echo, prompt] });
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
Hooks belong to the tool registration. Sequential or parallel scheduling, selected with `Session.create({ tools: { execution: "parallel" } })`, covers the entire hook/handler pipeline. After runs for a started, interrupted tool if it has not already started, with a one-second cooperative cleanup grace period. The kernel owns result settlement.
|
|
75
|
-
|
|
76
|
-
`ctx.plugin.tools.update(name, patch)` rewrites a registration's model-facing prose without replacing the tool or its hooks. A read sees only earlier contributions, so a plugin patching `promptSnippet` or `promptGuidelines` must run _before_ the tool it patches is indexed. Declaring `kind: "tool"` puts it ahead of every prompt plugin already; what it still has to get right is its position among the other tool plugins, which is the order their entries are written in.
|
|
77
|
-
|
|
78
|
-
Prompt plugins write into `ctx.plugin.prompt`: `foundation.set(text)` for the untagged head (the last `set` wins), and `sections.append/set/remove/get` with a `Plugin.Section` value — the built-in `Rules`, `Addendum`, `ProjectContext` and `Skills`, or a custom `Plugin.Section.define("github_pr_rules", { format: "list" })`. Sections merge by name across plugins. The harness renders the foundation, then `<tools>`, the built-in sections, `<cwd>`, and custom sections in first-write order; `tools` and `cwd` are its own. Contributions close after setup; plugins receive event publication but no subscription or background lifecycle.
|
|
79
|
-
|
|
80
|
-
Omitting `plugins` selects Bash then the default prompt, followed by the host settings' `plugins` block. An explicit array replaces all of that, and an empty one runs nothing: the prompt is then a fallback foundation with only the harness-owned `<tools>` and `<cwd>`.
|
|
81
|
-
|
|
82
|
-
An entry is a **module** or a **configuration object**.
|
|
83
|
-
|
|
84
|
-
A module is a definition object, a local path, a `file:` URL, or a package spec. It is loaded if it is not already, and it takes the position it is written at — naming a module again moves it:
|
|
85
|
-
|
|
86
|
-
```ts
|
|
87
|
-
plugins: [echo, "./plugins/local.ts", "file:///opt/plugin.mjs", "@acme/codework-tool-proc@1.2.0"];
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
A configuration object addresses a plugin **something else already selected**, and names it one of two ways:
|
|
91
|
-
|
|
92
|
-
```jsonc
|
|
93
|
-
{ "plugin": "acme.tool.proc", "options": { "limit": 40 } } // by ID, when you know it
|
|
94
|
-
{ "package": "@acme/codework-tool-proc", "options": { "limit": 40 } } // by the package it came from
|
|
95
|
-
{ "plugin": "codework.tool.bash", "enabled": false } // drop a built-in
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Exactly one of `plugin` and `package` per entry. `plugin` is a plugin's ID; `package` is any name the module answers to — the package name, the exact spec, the path it was loaded from, or the name a local package's own manifest declares.
|
|
99
|
-
|
|
100
|
-
An **ID is a key**. The last module to claim one owns it, and the configuration written against it stays with the key rather than with whichever module is currently behind it. Two modules exporting one ID is the author's conflict to resolve — the replacement is logged at debug, not arbitrated here.
|
|
101
|
-
|
|
102
|
-
A configuration object **never loads, installs or reorders anything**. If its name matches nothing in the selection — a typo, a package you have not added, a plugin this build does not ship — the entry is **ignored**: one debug line, no failure, and nothing fetched. So adding a package and configuring it is two entries, in that order:
|
|
103
|
-
|
|
104
|
-
```jsonc
|
|
105
|
-
{ "plugins": ["@acme/codework-tool-proc@1.2.0", { "package": "@acme/codework-tool-proc", "options": { "limit": 40 } }] }
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Repeated configuration replaces rather than merges — the block is opaque, so the last entry owns it whole. `options` reaches that plugin as the second argument to `setup`, `{}` when nothing configured it. The harness never looks inside it, including the `null`s it strips everywhere else in a settings file, since inside an opaque block a `null` is a value its plugin may need:
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
Plugin.define({
|
|
112
|
-
id: "acme.tool.proc",
|
|
113
|
-
setup(ctx, options) {
|
|
114
|
-
const limit = typeof options.limit === "number" ? options.limit : 10;
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
Source modules must default-export one plugin object.
|
|
120
|
-
|
|
121
|
-
Settings entries take the same two forms, and they extend the built-in selection instead of standing in for it, so naming one plugin cannot silently drop Bash or the prompt:
|
|
122
|
-
|
|
123
|
-
```jsonc
|
|
124
|
-
// <project>/.codework/settings.jsonc, ~/.codework/settings.jsonc, or a --user-config-dir
|
|
125
|
-
{
|
|
126
|
-
"plugins": [
|
|
127
|
-
"@acme/codework-prompt-life",
|
|
128
|
-
"@acme/codework-tool-proc@1.2.0",
|
|
129
|
-
"./plugins/local.ts",
|
|
130
|
-
{ "package": "@acme/codework-tool-proc", "options": { "limit": 20 } },
|
|
131
|
-
{ "plugin": "codework.tool.bash", "enabled": false },
|
|
132
|
-
],
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Settings files are JSONC: comments and a trailing comma are part of the format, and a syntax error names what the parser expected and where (`PropertyNameExpected at 2:38`). Entries accumulate across settings layers, lowest priority first: a project's list extends the user's rather than standing in for it, the way every other key in the document merges. A project drops an inherited plugin the same way it drops a built-in, with `{ "plugin": "<id>", "enabled": false }`. A leading `~` expands to the home directory. A `./` or `../` path resolves against the directory of the file that declared it — inside `<project>/.codework/`, or beside `~/.codework/settings.jsonc` — so one entry means one file in every project; a `package` naming a relative path is anchored the same way. `file:` URLs, absolute paths and package specs are taken as written.
|
|
137
|
-
|
|
138
|
-
Setup order comes from the **domain a plugin declares**, not from where its entry sits. Every `kind: "tool"` plugin is set up before any `kind: "prompt"` plugin, so a prompt plugin always sees the complete tool set — including tools added from a settings file, which land after the built-ins in the array. Within one domain, entries keep the order they were written in, which is where composition actually happens: a plugin patching another's tool, or appending to the prompt a previous one rendered, is written after it on purpose.
|
|
139
|
-
|
|
140
|
-
That is the reason `kind` is part of the definition rather than something the harness guesses. A user's settings file and a project's are edited by different people at different times, and neither can see the other's ordering; what each plugin _is_ remains knowable in both.
|
|
141
|
-
|
|
142
|
-
A plugin package declares `@codeworksh/harness` and `effect` as **exact peer dependencies**, never as dependencies:
|
|
143
|
-
|
|
144
|
-
```jsonc
|
|
145
|
-
"peerDependencies": { "@codeworksh/harness": "0.0.1", "effect": "4.0.1" },
|
|
146
|
-
"devDependencies": { "effect": "4.0.1" }
|
|
10
|
+
```sh
|
|
11
|
+
pnpm add @codeworksh/harness effect@4.0.5
|
|
147
12
|
```
|
|
148
13
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
Package sources install with pnpm, with lifecycle scripts disabled, under the harness home cache. The installer inherits stderr, so a first install prints pnpm's own progress and errors to the terminal — and a `plugins` entry in a settings file means that can happen during `Harness.layer` construction, before any session exists. An omitted version means `latest` on the first installation; subsequent constructions reuse that completed installation. The selection is read once per `Harness.layer`, so an edited `plugins` block applies at the next construction; hot reload and daemon lifecycles are not implemented.
|
|
152
|
-
|
|
153
|
-
Failures are attributed: a bad reference, unreadable module, or malformed plugin fails `Harness.layer` construction with `PluginPreparationError`, which carries the failing phase (`source`, `install`, `import`, or `definition`) and the index of the offending reference. A failing package install reports `PluginInstallError`; a plugin's `setup` failure becomes `Plugin.SetupError` with the plugin id, surfacing as a `SnapshotError` for that turn. Plugins are trusted in-process code — local paths and `file:` references import whatever they point at, so only load sources you trust.
|
|
154
|
-
|
|
155
|
-
## Pluggable Sandboxes
|
|
156
|
-
|
|
157
|
-
Harness uses a driver-based sandbox architecture. Drivers share a common lifecycle and I/O surface, keeping provider details out of session and agent-loop code.
|
|
14
|
+
`effect` is a peer dependency pinned to an exact version. Node 24.14.1 or newer is required.
|
|
158
15
|
|
|
159
|
-
|
|
160
|
-
| -------------- | ------------------------------------------- | ----------------------------------------------------- |
|
|
161
|
-
| Local host | Real filesystem and processes | Working directly in the current machine or repository |
|
|
162
|
-
| In-memory VFS | Ephemeral virtual filesystem | Fast tests and isolated experiments |
|
|
163
|
-
| SQLite VFS | In-memory or file-backed virtual filesystem | Reproducible sandboxes with optional persistence |
|
|
164
|
-
| Vercel Sandbox | Remote sandbox | Isolated cloud execution on Vercel |
|
|
165
|
-
| Daytona | Remote sandbox | Managed development environments on Daytona |
|
|
16
|
+
## Usage
|
|
166
17
|
|
|
167
|
-
The
|
|
18
|
+
The public surface is the Effect SDK at `@codeworksh/harness/effect`. The root export is empty for now.
|
|
168
19
|
|
|
169
20
|
```ts
|
|
170
21
|
import { Effect } from "effect";
|
|
171
|
-
import { Harness,
|
|
22
|
+
import { Harness, Session } from "@codeworksh/harness/effect";
|
|
172
23
|
|
|
173
24
|
const program = Effect.gen(function* () {
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
25
|
+
const session = yield* Session.create({
|
|
26
|
+
directory: process.cwd(),
|
|
27
|
+
model: { provider: "openai", id: "gpt-5.5" },
|
|
28
|
+
thinkingLevel: "high",
|
|
29
|
+
});
|
|
30
|
+
// Stores the prompt, runs the main thread and waits until it is idle.
|
|
31
|
+
yield* session.main.run("Summarize this repository in one paragraph.");
|
|
32
|
+
const { usage } = yield* session.main.info;
|
|
33
|
+
console.log(`${session.id}: ${usage.input} in, ${usage.output} out, $${usage.cost}`);
|
|
178
34
|
});
|
|
179
35
|
|
|
180
36
|
await program.pipe(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
database: ":memory:",
|
|
184
|
-
home: ".codework",
|
|
185
|
-
}),
|
|
186
|
-
),
|
|
37
|
+
// `home` holds settings, the model catalog and the database. It defaults to ~/.codework.
|
|
38
|
+
Effect.provide(Harness.layer({ home: ".codework" })),
|
|
187
39
|
Effect.scoped,
|
|
188
40
|
Effect.runPromise,
|
|
189
41
|
);
|
|
190
42
|
```
|
|
191
43
|
|
|
192
|
-
|
|
44
|
+
API keys come from the process environment (here `OPENAI_API_KEY`), and the model catalog is kept in `<home>/models.gen.json`. See [models](https://github.com/codeworksh/codework/blob/main/docs/internals/03_models.md).
|
|
193
45
|
|
|
194
|
-
|
|
195
|
-
pnpm install @acme/codework-sandbox-e2b
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
```ts
|
|
199
|
-
Harness.layer({
|
|
200
|
-
sandboxes: ["@acme/codework-sandbox-e2b"],
|
|
201
|
-
});
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
Vercel and Daytona are the first remote drivers. More providers can be added behind the same lifecycle and I/O contracts without changing session or agent-loop code.
|
|
205
|
-
|
|
206
|
-
## Requirements
|
|
207
|
-
|
|
208
|
-
- Node.js 24.14.1 or newer
|
|
209
|
-
- An API key for the model provider you select, or OAuth credentials created with
|
|
210
|
-
`codework auth login --openai-codex` / `codework auth login --github-copilot`
|
|
211
|
-
- Network access to models.dev the first time: the model catalog is downloaded into `<home>/models.gen.json` on demand
|
|
212
|
-
|
|
213
|
-
## CLI
|
|
214
|
-
|
|
215
|
-
Run the current development release without installing it globally:
|
|
216
|
-
|
|
217
|
-
```sh
|
|
218
|
-
export OPENAI_API_KEY="..."
|
|
219
|
-
|
|
220
|
-
pnpm dlx @codeworksh/harness@dev \
|
|
221
|
-
--home .codework-beta \
|
|
222
|
-
run --cwd "$PWD" --provider openai --model gpt-5.5 --thinking high \
|
|
223
|
-
"Inspect this repository"
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
The streamed response remains clean on stdout for piping. Session context and the per-run model usage summary are written to stderr:
|
|
227
|
-
|
|
228
|
-
```text
|
|
229
|
-
session ses_...
|
|
230
|
-
sandbox local · /workspace/project
|
|
231
|
-
|
|
232
|
-
── response ─────────────────────────────────────────────────────────────
|
|
233
|
-
The response streams here.
|
|
234
|
-
── usage ────────────────────────────────────────────────────────────────
|
|
235
|
-
model openai/gpt-5.5
|
|
236
|
-
tokens 12,400 input · 820 output · 13,220 total
|
|
237
|
-
cache 9,600 read · 0 write
|
|
238
|
-
cost $0.014200 · 1 turn
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
The model catalog lives at `<home>/models.gen.json` and is refreshed once it is older than 15 minutes; `codework models refresh --force` downloads it now. Set `CODEWORK_MODELS_FILE` to pin a catalog you manage yourself.
|
|
242
|
-
|
|
243
|
-
The CLI prints the session ID to stderr. Provider, model, and thinking settings are stored with the session's thread, so use the same home directory and session ID to continue it:
|
|
244
|
-
|
|
245
|
-
```sh
|
|
246
|
-
pnpm dlx @codeworksh/harness@dev \
|
|
247
|
-
--home .codework-beta \
|
|
248
|
-
run --session <session-id> \
|
|
249
|
-
"Continue with the implementation"
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
Persisted settings are the fallback. A new CLI process can explicitly re-bind or change them while attaching; supplied values are recorded as the thread's latest configuration:
|
|
253
|
-
|
|
254
|
-
```sh
|
|
255
|
-
pnpm dlx @codeworksh/harness@dev \
|
|
256
|
-
--home .codework-beta \
|
|
257
|
-
run --session <session-id> \
|
|
258
|
-
--provider openai --model gpt-5.6-luna --thinking high \
|
|
259
|
-
"Continue with this model"
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
Local execution is the default. To create a session in a new Daytona sandbox, set `DAYTONA_API_KEY` and select the Daytona driver:
|
|
46
|
+
A session is one durable event log, and its threads live inside it. `session.main` is the main thread. A thread handle can `prompt` (store and return), `run` (store and wait), `interrupt`, `resume`, `fork` and `configure`, and exposes `events()` and `history()`. Every run, prompt and durable event is stored, so `Session.attach({ sessionId })` reaches a thread again after a restart, and `Control.Service`'s `resumeUnfinished` picks up runs a crash cut off, as the RPC server does at start.
|
|
263
47
|
|
|
264
|
-
|
|
265
|
-
export DAYTONA_API_KEY="..."
|
|
48
|
+
## What It Owns
|
|
266
49
|
|
|
267
|
-
|
|
268
|
-
--home .codework-beta \
|
|
269
|
-
run --sandbox-driver daytona --provider openai --model gpt-5.5 \
|
|
270
|
-
"Inspect this repository"
|
|
271
|
-
```
|
|
50
|
+
The harness is the agent itself. It owns the loop, prompt assembly, tool execution, the plugin catalog and installer, MCP clients, sandbox drivers and mounts, settings, and the SQLite store every run and durable event lands in.
|
|
272
51
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
```sh
|
|
276
|
-
pnpm dlx @codeworksh/harness@dev \
|
|
277
|
-
--home .codework-beta \
|
|
278
|
-
run --sandbox-driver daytona --sandbox-provider-id <daytona-sandbox-id> \
|
|
279
|
-
"Continue work in this sandbox"
|
|
280
|
-
```
|
|
52
|
+
It depends on [`@codeworksh/aikit`](https://github.com/codeworksh/codework/tree/main/packages/aikit) for every model call and on [`@codeworksh/plugin`](https://github.com/codeworksh/codework/tree/main/packages/plugin) for the plugin, tool and sandbox contracts. It never imports the CLI, the RPC server, `packages/schema` or anything under `apps/`. That keeps it a library that never knows how it is reached, so the RPC server, in-process `codework run` and ACP all boot the same harness.
|
|
281
53
|
|
|
282
|
-
|
|
54
|
+
Third parties extend it with plugins built against `@codeworksh/plugin`, not against this package. Pass them to `Harness.layer({ plugins })`, or list them in a settings file's `plugins` block. Remote sandboxes load from the `@codeworksh/harness/sandboxes/vercel` and `@codeworksh/harness/sandboxes/daytona` subpaths through `Harness.layer({ sandboxes })`, with their provider SDK installed beside it.
|
|
283
55
|
|
|
284
|
-
|
|
56
|
+
## Code Map
|
|
285
57
|
|
|
286
|
-
|
|
58
|
+
- [`src/effect.ts`](https://github.com/codeworksh/codework/blob/main/packages/harness/src/effect.ts) is the public SDK barrel.
|
|
59
|
+
- [`src/effect/harness.ts`](https://github.com/codeworksh/codework/blob/main/packages/harness/src/effect/harness.ts) builds `Harness.layer`: its options and the service wiring.
|
|
60
|
+
- [`src/effect/session.ts`](https://github.com/codeworksh/codework/blob/main/packages/harness/src/effect/session.ts) creates, attaches and relinks sessions and returns session and thread handles.
|
|
61
|
+
- [`src/control.ts`](https://github.com/codeworksh/codework/blob/main/packages/harness/src/control.ts) starts, joins and stops work: prompt, run, interrupt and resume.
|
|
62
|
+
- [`src/runner`](https://github.com/codeworksh/codework/tree/main/packages/harness/src/runner) holds execution, the per-thread coordinator, the loop, retries and the one boundary to aikit.
|
|
63
|
+
- [`src/event`](https://github.com/codeworksh/codework/tree/main/packages/harness/src/event) is the durable event log and its projectors.
|
|
64
|
+
- [`src/plugin`](https://github.com/codeworksh/codework/tree/main/packages/harness/src/plugin) loads, installs and runs plugins, including the built-in tools and prompt.
|
|
65
|
+
- [`src/sandbox`](https://github.com/codeworksh/codework/tree/main/packages/harness/src/sandbox) and [`src/sandboxes`](https://github.com/codeworksh/codework/tree/main/packages/harness/src/sandboxes) hold the driver registry, mounts and the bundled drivers.
|
|
66
|
+
- [`src/mcp`](https://github.com/codeworksh/codework/tree/main/packages/harness/src/mcp) runs MCP servers and exposes their tools.
|
|
67
|
+
- [`src/settings`](https://github.com/codeworksh/codework/tree/main/packages/harness/src/settings) reads and merges settings files.
|
|
68
|
+
- [`src/db`](https://github.com/codeworksh/codework/tree/main/packages/harness/src/db) is the SQLite store and its migrations.
|
|
287
69
|
|
|
288
|
-
##
|
|
70
|
+
## Working Locally
|
|
289
71
|
|
|
290
72
|
```sh
|
|
291
|
-
pnpm
|
|
73
|
+
pnpm check # vp check
|
|
74
|
+
pnpm test # vp test
|
|
75
|
+
pnpm build # vp pack
|
|
292
76
|
```
|
|
293
77
|
|
|
294
|
-
|
|
295
|
-
import { Effect } from "effect";
|
|
296
|
-
import { Harness, Session } from "@codeworksh/harness/effect";
|
|
297
|
-
|
|
298
|
-
const program = Effect.gen(function* () {
|
|
299
|
-
const session = yield* Session.create({
|
|
300
|
-
title: "Review Harness",
|
|
301
|
-
directory: process.cwd(),
|
|
302
|
-
model: { provider: "openai", id: "gpt-5.5" },
|
|
303
|
-
thinkingLevel: "high",
|
|
304
|
-
});
|
|
305
|
-
const info = yield* session.info;
|
|
306
|
-
|
|
307
|
-
console.log(`session ${info.id} in ${info.directory}`);
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
await program.pipe(
|
|
311
|
-
Effect.provide(Harness.layer({ database: ":memory:", home: ".codework-readme" })),
|
|
312
|
-
Effect.scoped,
|
|
313
|
-
Effect.runPromise,
|
|
314
|
-
);
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
Creating a session does not contact the provider. A session runs its prompts in threads: call `session.main.run(prompt)` to execute a turn on its `main` thread, and `session.main.events()` to obtain that thread's Effect `Stream`. `fork({ entryId })` on a thread starts a new one, and `session.thread(id)` reaches it later.
|
|
318
|
-
|
|
319
|
-
The Effect SDK currently includes:
|
|
78
|
+
`pnpm test:sandbox:e2e` runs the remote sandbox suites and needs provider credentials. See [testing](https://github.com/codeworksh/codework/blob/main/docs/internals/13_testing.md).
|
|
320
79
|
|
|
321
|
-
|
|
322
|
-
- `Session.create` and `relink`, which return a session handle, and `attach`, which returns a thread handle; a thread handle prompts, runs, resumes, interrupts, configures, forks, and exposes its events and history
|
|
323
|
-
- `Sandbox` drivers and lifecycle operations for in-memory, SQLite, Vercel, and Daytona environments
|
|
324
|
-
- Local host execution for sessions without a configured sandbox
|
|
325
|
-
- Effect-native errors, layers, streams, and resource scopes
|
|
80
|
+
## Learn More
|
|
326
81
|
|
|
327
|
-
|
|
82
|
+
- [Runtime](https://github.com/codeworksh/codework/blob/main/docs/internals/04_runtime.md): sessions, threads, runs and durability.
|
|
83
|
+
- [Services](https://github.com/codeworksh/codework/blob/main/docs/internals/02_services.md): Effect services, layers and errors.
|
|
84
|
+
- [Sandboxes](https://github.com/codeworksh/codework/blob/main/docs/internals/06_sandboxes.md), [settings](https://github.com/codeworksh/codework/blob/main/docs/internals/07_settings.md) and [plugins](https://github.com/codeworksh/codework/blob/main/docs/internals/08_plugins.md).
|
|
328
85
|
|
|
329
|
-
|
|
86
|
+
Report issues in the [CodeWork repository](https://github.com/codeworksh/codework/issues).
|
package/effect.d.mts
CHANGED
|
@@ -32570,11 +32570,6 @@ declare const parts: (message: Message.Message) => ({
|
|
|
32570
32570
|
type: "image";
|
|
32571
32571
|
data: string;
|
|
32572
32572
|
mimeType: string;
|
|
32573
|
-
} | {
|
|
32574
|
-
type: "thinking";
|
|
32575
|
-
thinking: string;
|
|
32576
|
-
thinkingSignature?: string;
|
|
32577
|
-
redacted?: boolean;
|
|
32578
32573
|
} | {
|
|
32579
32574
|
arguments: Record<string, any>;
|
|
32580
32575
|
callID: string;
|
|
@@ -32615,15 +32610,20 @@ declare const parts: (message: Message.Message) => ({
|
|
|
32615
32610
|
mimeType: string;
|
|
32616
32611
|
})[];
|
|
32617
32612
|
details?: any;
|
|
32618
|
-
isError:
|
|
32613
|
+
isError: true;
|
|
32619
32614
|
};
|
|
32620
|
-
status: "
|
|
32615
|
+
status: "aborted";
|
|
32621
32616
|
thoughtSignature?: string;
|
|
32622
32617
|
time: {
|
|
32623
32618
|
start: number;
|
|
32624
32619
|
end: number;
|
|
32625
32620
|
};
|
|
32626
32621
|
type: "toolCall";
|
|
32622
|
+
} | {
|
|
32623
|
+
type: "thinking";
|
|
32624
|
+
thinking: string;
|
|
32625
|
+
thinkingSignature?: string;
|
|
32626
|
+
redacted?: boolean;
|
|
32627
32627
|
} | {
|
|
32628
32628
|
arguments: Record<string, any>;
|
|
32629
32629
|
callID: string;
|
|
@@ -32640,9 +32640,9 @@ declare const parts: (message: Message.Message) => ({
|
|
|
32640
32640
|
mimeType: string;
|
|
32641
32641
|
})[];
|
|
32642
32642
|
details?: any;
|
|
32643
|
-
isError:
|
|
32643
|
+
isError: false;
|
|
32644
32644
|
};
|
|
32645
|
-
status: "
|
|
32645
|
+
status: "completed";
|
|
32646
32646
|
thoughtSignature?: string;
|
|
32647
32647
|
time: {
|
|
32648
32648
|
start: number;
|
|
@@ -32667,7 +32667,7 @@ declare const parts: (message: Message.Message) => ({
|
|
|
32667
32667
|
details?: any;
|
|
32668
32668
|
isError: true;
|
|
32669
32669
|
};
|
|
32670
|
-
status: "
|
|
32670
|
+
status: "error";
|
|
32671
32671
|
thoughtSignature?: string;
|
|
32672
32672
|
time: {
|
|
32673
32673
|
start: number;
|
|
@@ -32692,7 +32692,7 @@ declare const parts: (message: Message.Message) => ({
|
|
|
32692
32692
|
details?: any;
|
|
32693
32693
|
isError: true;
|
|
32694
32694
|
};
|
|
32695
|
-
status: "
|
|
32695
|
+
status: "skipped";
|
|
32696
32696
|
thoughtSignature?: string;
|
|
32697
32697
|
time: {
|
|
32698
32698
|
start: number;
|
|
@@ -32875,11 +32875,6 @@ declare const decodeMessage: (hydrated: HydratedEntry) => Effect.Effect<{
|
|
|
32875
32875
|
type: "image";
|
|
32876
32876
|
data: string;
|
|
32877
32877
|
mimeType: string;
|
|
32878
|
-
} | {
|
|
32879
|
-
type: "thinking";
|
|
32880
|
-
thinking: string;
|
|
32881
|
-
thinkingSignature?: string;
|
|
32882
|
-
redacted?: boolean;
|
|
32883
32878
|
} | {
|
|
32884
32879
|
arguments: Record<string, any>;
|
|
32885
32880
|
callID: string;
|
|
@@ -32920,15 +32915,20 @@ declare const decodeMessage: (hydrated: HydratedEntry) => Effect.Effect<{
|
|
|
32920
32915
|
mimeType: string;
|
|
32921
32916
|
})[];
|
|
32922
32917
|
details?: any;
|
|
32923
|
-
isError:
|
|
32918
|
+
isError: true;
|
|
32924
32919
|
};
|
|
32925
|
-
status: "
|
|
32920
|
+
status: "aborted";
|
|
32926
32921
|
thoughtSignature?: string;
|
|
32927
32922
|
time: {
|
|
32928
32923
|
start: number;
|
|
32929
32924
|
end: number;
|
|
32930
32925
|
};
|
|
32931
32926
|
type: "toolCall";
|
|
32927
|
+
} | {
|
|
32928
|
+
type: "thinking";
|
|
32929
|
+
thinking: string;
|
|
32930
|
+
thinkingSignature?: string;
|
|
32931
|
+
redacted?: boolean;
|
|
32932
32932
|
} | {
|
|
32933
32933
|
arguments: Record<string, any>;
|
|
32934
32934
|
callID: string;
|
|
@@ -32945,9 +32945,9 @@ declare const decodeMessage: (hydrated: HydratedEntry) => Effect.Effect<{
|
|
|
32945
32945
|
mimeType: string;
|
|
32946
32946
|
})[];
|
|
32947
32947
|
details?: any;
|
|
32948
|
-
isError:
|
|
32948
|
+
isError: false;
|
|
32949
32949
|
};
|
|
32950
|
-
status: "
|
|
32950
|
+
status: "completed";
|
|
32951
32951
|
thoughtSignature?: string;
|
|
32952
32952
|
time: {
|
|
32953
32953
|
start: number;
|
|
@@ -32972,7 +32972,7 @@ declare const decodeMessage: (hydrated: HydratedEntry) => Effect.Effect<{
|
|
|
32972
32972
|
details?: any;
|
|
32973
32973
|
isError: true;
|
|
32974
32974
|
};
|
|
32975
|
-
status: "
|
|
32975
|
+
status: "error";
|
|
32976
32976
|
thoughtSignature?: string;
|
|
32977
32977
|
time: {
|
|
32978
32978
|
start: number;
|
|
@@ -32997,7 +32997,7 @@ declare const decodeMessage: (hydrated: HydratedEntry) => Effect.Effect<{
|
|
|
32997
32997
|
details?: any;
|
|
32998
32998
|
isError: true;
|
|
32999
32999
|
};
|
|
33000
|
-
status: "
|
|
33000
|
+
status: "skipped";
|
|
33001
33001
|
thoughtSignature?: string;
|
|
33002
33002
|
time: {
|
|
33003
33003
|
start: number;
|