@codeworksh/harness 0.0.1-dev.20260824142157 → 0.0.1-dev.20260824145955
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 +24 -0
- package/cli/index.mjs +50 -15
- package/cli/index.mjs.map +1 -1
- package/effect.mjs +2 -90
- package/effect.mjs.map +1 -1
- package/esm-1rae63aY.mjs +63852 -0
- package/esm-1rae63aY.mjs.map +1 -0
- package/package.json +2 -1
- package/rolldown-runtime-B4iAMlE-.mjs +35 -0
- package/{session-jgwp2MT6.mjs → session-m-xcehZ7.mjs} +125 -30
- package/session-m-xcehZ7.mjs.map +1 -0
- package/rolldown-runtime-D7D4PA-g.mjs +0 -13
- package/session-jgwp2MT6.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeworksh/harness",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.20260824145955",
|
|
4
4
|
"description": "AI agent harness — agent loop, tools, and code execution sandbox.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@vercel/sandbox": "^2.9.2",
|
|
60
60
|
"effect": "4.0.0-beta.107",
|
|
61
61
|
"just-bash": "^2.14.5",
|
|
62
|
+
"tslib": "^2.8.1",
|
|
62
63
|
"typebox": "^1.3.10",
|
|
63
64
|
"uuid": "^14.0.1",
|
|
64
65
|
"uuidv7": "^1.2.1"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
10
|
+
var __exportAll = (all, no_symbols) => {
|
|
11
|
+
let target = {};
|
|
12
|
+
for (var name in all) __defProp(target, name, {
|
|
13
|
+
get: all[name],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
17
|
+
return target;
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
21
|
+
key = keys[i];
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
23
|
+
get: ((k) => from[k]).bind(null, key),
|
|
24
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
34
|
+
//#endregion
|
|
35
|
+
export { __toESM as i, __exportAll as n, __require as r, __commonJSMin as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.mjs";
|
|
2
2
|
import { Cause, Config, Context, DateTime, Deferred, Duration, Effect, Exit, Fiber, FiberSet, FileSystem, Layer, LayerMap, Option, Path, PubSub, Queue, Ref, Result, Schedule, Schema, SchemaGetter, SchemaIssue, Scope, Semaphore, Stream, String as String$1 } from "effect";
|
|
3
3
|
import { uuidv7 } from "uuidv7";
|
|
4
4
|
import { Message, llm, stream } from "@codeworksh/aikit";
|
|
@@ -13,8 +13,6 @@ import { Buffer as Buffer$1 } from "node:buffer";
|
|
|
13
13
|
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
|
14
14
|
import { MemoryProvider, RealFSProvider, SqliteProvider, create } from "@platformatic/vfs";
|
|
15
15
|
import { Bash } from "just-bash";
|
|
16
|
-
import { Daytona, DaytonaNotFoundError } from "@daytona/sdk";
|
|
17
|
-
import { Sandbox } from "@vercel/sandbox";
|
|
18
16
|
import { createHash } from "crypto";
|
|
19
17
|
import { randomBytes } from "node:crypto";
|
|
20
18
|
//#region src/schema.ts
|
|
@@ -4089,6 +4087,7 @@ const providerFrom$1 = (sandbox, options) => {
|
|
|
4089
4087
|
await sandbox.fs.getFileDetails(path);
|
|
4090
4088
|
return true;
|
|
4091
4089
|
} catch (cause) {
|
|
4090
|
+
const { DaytonaNotFoundError } = await import("./esm-1rae63aY.mjs");
|
|
4092
4091
|
if (cause instanceof DaytonaNotFoundError) return false;
|
|
4093
4092
|
throw cause;
|
|
4094
4093
|
}
|
|
@@ -4174,22 +4173,28 @@ const statusFrom$1 = (state) => {
|
|
|
4174
4173
|
const shouldWake = (sandbox) => sandbox.state === "stopped" || sandbox.state === "archived";
|
|
4175
4174
|
const make$9 = (client = {}) => {
|
|
4176
4175
|
const redact = makeRedactor([client.apiKey ?? ""]);
|
|
4177
|
-
const daytona = () => new Daytona({
|
|
4176
|
+
const daytona = (sdk) => new sdk.Daytona({
|
|
4178
4177
|
...client.apiKey === void 0 ? {} : { apiKey: client.apiKey },
|
|
4179
4178
|
...client.apiUrl === void 0 ? {} : { apiUrl: client.apiUrl },
|
|
4180
4179
|
...client.target === void 0 ? {} : { target: client.target }
|
|
4181
4180
|
});
|
|
4182
|
-
const attempt = (operation, run) => Effect.
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4181
|
+
const attempt = (operation, run) => Effect.suspend(() => {
|
|
4182
|
+
let sdk;
|
|
4183
|
+
return Effect.tryPromise({
|
|
4184
|
+
try: () => import("./esm-1rae63aY.mjs").then((loaded) => {
|
|
4185
|
+
sdk = loaded;
|
|
4186
|
+
return run(loaded);
|
|
4187
|
+
}),
|
|
4188
|
+
catch: (cause) => providerError({
|
|
4189
|
+
driver: name$1,
|
|
4190
|
+
operation,
|
|
4191
|
+
cause,
|
|
4192
|
+
redact,
|
|
4193
|
+
notFound: sdk !== void 0 && cause instanceof sdk.DaytonaNotFoundError
|
|
4194
|
+
})
|
|
4195
|
+
});
|
|
4191
4196
|
});
|
|
4192
|
-
const get = (providerResourceId, operation) => attempt(operation, () => daytona().get(providerResourceId));
|
|
4197
|
+
const get = (providerResourceId, operation) => attempt(operation, (sdk) => daytona(sdk).get(providerResourceId));
|
|
4193
4198
|
const refresh = (sandbox, operation) => attempt(operation, () => sandbox.refreshData()).pipe(Effect.as(sandbox));
|
|
4194
4199
|
const observed = (sandbox) => ({
|
|
4195
4200
|
...statusFrom$1(sandbox.state),
|
|
@@ -4214,7 +4219,6 @@ const make$9 = (client = {}) => {
|
|
|
4214
4219
|
createConfigCodec: CreateConfig$1,
|
|
4215
4220
|
runtimeConfigCodec: RuntimeConfig$1,
|
|
4216
4221
|
create: ({ instanceId, config }) => Effect.gen(function* () {
|
|
4217
|
-
const sdk = daytona();
|
|
4218
4222
|
const base = {
|
|
4219
4223
|
language: config.language ?? "typescript",
|
|
4220
4224
|
...config.envVars === void 0 ? {} : { envVars: config.envVars },
|
|
@@ -4226,14 +4230,17 @@ const make$9 = (client = {}) => {
|
|
|
4226
4230
|
"codework-managed": "true"
|
|
4227
4231
|
}
|
|
4228
4232
|
};
|
|
4229
|
-
const sandbox = yield* attempt("create", () =>
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4233
|
+
const sandbox = yield* attempt("create", (loaded) => {
|
|
4234
|
+
const sdk = daytona(loaded);
|
|
4235
|
+
return config.image === void 0 ? sdk.create({
|
|
4236
|
+
...base,
|
|
4237
|
+
...config.snapshot === void 0 ? {} : { snapshot: config.snapshot }
|
|
4238
|
+
}) : sdk.create({
|
|
4239
|
+
...base,
|
|
4240
|
+
image: config.image,
|
|
4241
|
+
...config.resources === void 0 ? {} : { resources: config.resources }
|
|
4242
|
+
});
|
|
4243
|
+
});
|
|
4237
4244
|
const defaultCwd = yield* attempt("create.cwd", () => mountCwd(config.cwd, () => sandbox.getWorkDir()));
|
|
4238
4245
|
const state = statusFrom$1(sandbox.state);
|
|
4239
4246
|
return {
|
|
@@ -4272,7 +4279,8 @@ const credentialsFrom = (options) => options.token !== void 0 && options.teamId
|
|
|
4272
4279
|
teamId: options.teamId,
|
|
4273
4280
|
projectId: options.projectId
|
|
4274
4281
|
} : void 0;
|
|
4275
|
-
const createSandbox = (options, creds = credentialsFrom(options)) => {
|
|
4282
|
+
const createSandbox = async (options, creds = credentialsFrom(options)) => {
|
|
4283
|
+
const { Sandbox } = await import("@vercel/sandbox");
|
|
4276
4284
|
const withCreds = (params) => creds ? {
|
|
4277
4285
|
...params,
|
|
4278
4286
|
...creds
|
|
@@ -4465,14 +4473,14 @@ const make$8 = (client = {}) => {
|
|
|
4465
4473
|
notFound: isNotFound(cause)
|
|
4466
4474
|
})
|
|
4467
4475
|
});
|
|
4468
|
-
const get = (providerResourceId, resume, operation) => attempt(operation, () => Sandbox.get(credentials === void 0 ? {
|
|
4476
|
+
const get = (providerResourceId, resume, operation) => attempt(operation, () => import("@vercel/sandbox").then(({ Sandbox }) => Sandbox.get(credentials === void 0 ? {
|
|
4469
4477
|
name: providerResourceId,
|
|
4470
4478
|
resume
|
|
4471
4479
|
} : {
|
|
4472
4480
|
...credentials,
|
|
4473
4481
|
name: providerResourceId,
|
|
4474
4482
|
resume
|
|
4475
|
-
}));
|
|
4483
|
+
})));
|
|
4476
4484
|
const observed = (sandbox) => ({
|
|
4477
4485
|
...statusFrom(sandbox.status),
|
|
4478
4486
|
metadata: { cwd: sandbox.cwd }
|
|
@@ -6027,7 +6035,7 @@ var tool_exports = /* @__PURE__ */ __exportAll({
|
|
|
6027
6035
|
implement: () => implement,
|
|
6028
6036
|
make: () => make$2,
|
|
6029
6037
|
provide: () => provide,
|
|
6030
|
-
register: () => register,
|
|
6038
|
+
register: () => register$1,
|
|
6031
6039
|
toAikitTool: () => toAikitTool,
|
|
6032
6040
|
toProviderJsonSchema: () => toProviderJsonSchema
|
|
6033
6041
|
});
|
|
@@ -6057,7 +6065,7 @@ const toRegistered = (definition, handler) => ({
|
|
|
6057
6065
|
})))
|
|
6058
6066
|
});
|
|
6059
6067
|
/** Register a tool whose only requirement is the executor-provided progress service. */
|
|
6060
|
-
const register = (impl) => toRegistered(impl.definition, impl.handler);
|
|
6068
|
+
const register$1 = (impl) => toRegistered(impl.definition, impl.handler);
|
|
6061
6069
|
/**
|
|
6062
6070
|
* Discharge a tool's capability requirements into a {@link RegisteredTool}, erasing its `R`
|
|
6063
6071
|
* (the executor still provides `ToolProgress`). This is the registration boundary: a
|
|
@@ -7042,6 +7050,93 @@ const layer = (options = {}) => Layer.unwrap(Effect.gen(function* () {
|
|
|
7042
7050
|
return layer$7.pipe(Layer.provideMerge(layer$6.pipe(Layer.provide(loop))), Layer.provideMerge(layer$4()), Layer.provideMerge(layer$5), Layer.provideMerge(sandboxes), Layer.provideMerge(layer$18), Layer.provideMerge(layer$1), Layer.provideMerge(layer$20), Layer.provideMerge(database), Layer.provideMerge(global));
|
|
7043
7051
|
}));
|
|
7044
7052
|
//#endregion
|
|
7053
|
+
//#region src/effect/sandbox.ts
|
|
7054
|
+
var sandbox_exports = /* @__PURE__ */ __exportAll({
|
|
7055
|
+
Drivers: () => Drivers,
|
|
7056
|
+
Sandbox: () => sandbox_exports,
|
|
7057
|
+
SandboxInstance: () => instance_exports,
|
|
7058
|
+
create: () => create$2,
|
|
7059
|
+
destroy: () => destroy,
|
|
7060
|
+
get: () => get$1,
|
|
7061
|
+
list: () => list,
|
|
7062
|
+
refresh: () => refresh,
|
|
7063
|
+
register: () => register,
|
|
7064
|
+
stop: () => stop,
|
|
7065
|
+
wake: () => wake
|
|
7066
|
+
});
|
|
7067
|
+
const registered = Effect.fn("Sandbox.registered")(function* (name) {
|
|
7068
|
+
return yield* (yield* Registry).get(Name.make(name));
|
|
7069
|
+
});
|
|
7070
|
+
const create$2 = Effect.fn("Sandbox.create")(function* (input) {
|
|
7071
|
+
const controller = yield* Controller;
|
|
7072
|
+
const driver = yield* registered(input.driver);
|
|
7073
|
+
if (input.driver === "memory") {
|
|
7074
|
+
const cwd = AbsolutePath.make(input.cwd ?? "/");
|
|
7075
|
+
return yield* controller.create({
|
|
7076
|
+
driver,
|
|
7077
|
+
config: {
|
|
7078
|
+
defaultCwd: cwd,
|
|
7079
|
+
initializeCwd: cwd
|
|
7080
|
+
}
|
|
7081
|
+
});
|
|
7082
|
+
}
|
|
7083
|
+
if (input.driver === "sqldb") {
|
|
7084
|
+
const cwd = AbsolutePath.make(input.cwd ?? "/");
|
|
7085
|
+
return yield* controller.create({
|
|
7086
|
+
driver,
|
|
7087
|
+
config: {
|
|
7088
|
+
defaultCwd: cwd,
|
|
7089
|
+
initializeCwd: cwd,
|
|
7090
|
+
...input.location === void 0 ? {} : { location: input.location }
|
|
7091
|
+
}
|
|
7092
|
+
});
|
|
7093
|
+
}
|
|
7094
|
+
const { driver: _, ...config } = input;
|
|
7095
|
+
return yield* controller.create({
|
|
7096
|
+
driver,
|
|
7097
|
+
config
|
|
7098
|
+
});
|
|
7099
|
+
});
|
|
7100
|
+
const register = Effect.fn("Sandbox.register")(function* (input) {
|
|
7101
|
+
const controller = yield* Controller;
|
|
7102
|
+
const driver = yield* registered(input.driver);
|
|
7103
|
+
return yield* controller.register({
|
|
7104
|
+
driver,
|
|
7105
|
+
providerResourceId: input.providerResourceId
|
|
7106
|
+
});
|
|
7107
|
+
});
|
|
7108
|
+
const get$1 = Effect.fn("Sandbox.get")(function* (id) {
|
|
7109
|
+
return yield* (yield* Controller).get(id);
|
|
7110
|
+
});
|
|
7111
|
+
const list = Effect.fn("Sandbox.list")(function* (input) {
|
|
7112
|
+
return yield* (yield* Controller).list({
|
|
7113
|
+
...input?.driver === void 0 ? {} : { driver: Name.make(input.driver) },
|
|
7114
|
+
...input?.status === void 0 ? {} : { status: input.status }
|
|
7115
|
+
});
|
|
7116
|
+
});
|
|
7117
|
+
const refresh = Effect.fn("Sandbox.refresh")(function* (id) {
|
|
7118
|
+
return yield* (yield* Controller).refresh(id);
|
|
7119
|
+
});
|
|
7120
|
+
const wake = Effect.fn("Sandbox.wake")(function* (id) {
|
|
7121
|
+
return yield* (yield* Controller).wake(id);
|
|
7122
|
+
});
|
|
7123
|
+
const stop = Effect.fn("Sandbox.stop")(function* (id) {
|
|
7124
|
+
return yield* (yield* Controller).stop(id);
|
|
7125
|
+
});
|
|
7126
|
+
const destroy = Effect.fn("Sandbox.destroy")(function* (id) {
|
|
7127
|
+
yield* (yield* Controller).destroy(id);
|
|
7128
|
+
});
|
|
7129
|
+
const Drivers = {
|
|
7130
|
+
get memory() {
|
|
7131
|
+
return make$13().driver;
|
|
7132
|
+
},
|
|
7133
|
+
get sqldb() {
|
|
7134
|
+
return make$11().driver;
|
|
7135
|
+
},
|
|
7136
|
+
vercel: (options = {}) => make$8(options),
|
|
7137
|
+
daytona: (options = {}) => make$9(options)
|
|
7138
|
+
};
|
|
7139
|
+
//#endregion
|
|
7045
7140
|
//#region src/effect/session.ts
|
|
7046
7141
|
var session_exports = /* @__PURE__ */ __exportAll({
|
|
7047
7142
|
AbsolutePath: () => AbsolutePath$1,
|
|
@@ -7163,6 +7258,6 @@ const attach = Effect.fn("Session.attach")(function* (input) {
|
|
|
7163
7258
|
return found.value;
|
|
7164
7259
|
});
|
|
7165
7260
|
//#endregion
|
|
7166
|
-
export {
|
|
7261
|
+
export { create$2 as a, harness_exports as c, ID$4 as d, Drivers as i, layer as l, create$1 as n, register as o, session_exports as r, sandbox_exports as s, attach as t, tool_exports as u };
|
|
7167
7262
|
|
|
7168
|
-
//# sourceMappingURL=session-
|
|
7263
|
+
//# sourceMappingURL=session-m-xcehZ7.mjs.map
|