@codeworksh/harness 0.2.0-dev.20261013121551 → 0.2.0-dev.20261013124604
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/effect.d.mts +846 -823
- package/effect.mjs +19 -136
- package/effect.mjs.map +1 -1
- package/package.json +3 -3
- package/resize-D34zcVQl.mjs +461 -0
- package/resize-D34zcVQl.mjs.map +1 -0
- package/tool/image/worker.mjs +1 -1
- package/resize-Dwv5dCgY.mjs +0 -263
- package/resize-Dwv5dCgY.mjs.map +0 -1
package/effect.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as __reExport, t as __exportAll } from "./rolldown-runtime-B4FMCO8f.mjs";
|
|
2
2
|
import { a as io_exports, i as errors_exports, n as shell_exports, o as instance_exports, r as filesystem_exports, s as posix } from "./resource-DFZh0e-s.mjs";
|
|
3
|
+
import { a as decode, c as importModule, d as share, l as lendResolve, n as dimensionNote, o as load$5, r as resize, s as load$4, u as resolveModule } from "./resize-D34zcVQl.mjs";
|
|
3
4
|
import "./daytona-D4sNwzSr.mjs";
|
|
4
5
|
import "./vercel-3GouQSJI.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { createRequire, registerHooks } from "node:module";
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
7
|
import { Cause, Clock, Config, Context, Crypto, Data, DateTime, Deferred, Duration, Effect, Exit, Fiber, FiberSet, FileSystem, Layer, LayerMap, Metric, Option, Path, Predicate, PubSub, Queue, Random, Ref, Result, Schedule, Schema, SchemaIssue, Scope, Semaphore, Stream, String as String$1 } from "effect";
|
|
8
8
|
import { Message, Model, getEnvApiKey, llm, normalizeOptionalNulls, stream } from "@codeworksh/aikit";
|
|
9
9
|
import { MessageID as ID, SessionID as ID$1 } from "@codeworksh/plugin/ids";
|
|
@@ -16,10 +16,10 @@ import { NodeChildProcessSpawner, NodeCrypto, NodeFileSystem, NodePath } from "@
|
|
|
16
16
|
import { Model as Model$1, VariantSchema } from "effect/schema";
|
|
17
17
|
import { Hex } from "effect/encoding";
|
|
18
18
|
import { MemoryProvider, RealFSProvider, SqliteProvider, create } from "@platformatic/vfs";
|
|
19
|
-
import fs
|
|
19
|
+
import fs from "node:fs";
|
|
20
20
|
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
21
21
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
22
|
-
import {
|
|
22
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
23
23
|
import { DirectoryNotFoundError, DirectoryNotFoundError as DirectoryNotFoundError$1, Info, Info as Info$1, NotDirectoryError, NotDirectoryError as NotDirectoryError$1, Service, Service as Service$8 } from "@codeworksh/plugin/location";
|
|
24
24
|
import { generateModels } from "@codeworksh/aikit/modelgen";
|
|
25
25
|
import { JsonGitHubCopilotAuthStorage, getGitHubCopilotApiKey } from "@codeworksh/aikit/oauth/github/copilot";
|
|
@@ -28,9 +28,6 @@ import { parse, printParseErrorCode } from "jsonc-parser";
|
|
|
28
28
|
import * as Section from "@codeworksh/plugin/plugin/section";
|
|
29
29
|
import * as Diff from "diff";
|
|
30
30
|
import { FetchHttpClient, HttpClient } from "effect/http";
|
|
31
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
32
|
-
import path from "node:path";
|
|
33
|
-
import { Script, constants } from "node:vm";
|
|
34
31
|
import npa from "npm-package-arg";
|
|
35
32
|
import * as AikitFailure from "@codeworksh/aikit/failure";
|
|
36
33
|
import "@codeworksh/plugin/tool/error";
|
|
@@ -380,7 +377,7 @@ var db_exports = /* @__PURE__ */ __exportAll({
|
|
|
380
377
|
defaultLayer: () => defaultLayer$1,
|
|
381
378
|
layer: () => layer$26,
|
|
382
379
|
locationConfig: () => locationConfig,
|
|
383
|
-
path: () => path$
|
|
380
|
+
path: () => path$1,
|
|
384
381
|
resolveDatabaseLocation: () => resolveDatabaseLocation
|
|
385
382
|
});
|
|
386
383
|
const setup = Effect.gen(function* () {
|
|
@@ -407,11 +404,11 @@ function resolveDatabaseLocation(configured, data) {
|
|
|
407
404
|
if (configured === ":memory:" || posix.isAbsolute(configured)) return configured;
|
|
408
405
|
return posix.join(data, configured);
|
|
409
406
|
}
|
|
410
|
-
const path$
|
|
407
|
+
const path$1 = Effect.fn("Database.path")(function* (data) {
|
|
411
408
|
const directory = data ?? (yield* resolve$4()).data;
|
|
412
409
|
return resolveDatabaseLocation(yield* locationConfig, directory);
|
|
413
410
|
});
|
|
414
|
-
const defaultLayer$1 = Layer.unwrap(path$
|
|
411
|
+
const defaultLayer$1 = Layer.unwrap(path$1().pipe(Effect.map(layer$26)));
|
|
415
412
|
//#endregion
|
|
416
413
|
//#region src/event/schema.ts
|
|
417
414
|
var schema_exports$7 = /* @__PURE__ */ __exportAll({});
|
|
@@ -4007,7 +4004,8 @@ const fromBash = (bash) => {
|
|
|
4007
4004
|
});
|
|
4008
4005
|
return shell_exports.Shell.of((0, shell_exports.fromExec)({ exec }));
|
|
4009
4006
|
};
|
|
4010
|
-
const
|
|
4007
|
+
const JustBash = load$4("just-bash").pipe(Effect.map((module) => module), Effect.orDie);
|
|
4008
|
+
const make$12 = (module, vfs, cwd) => fromBash(new module.Bash({
|
|
4011
4009
|
fs: bridge(vfs, cwd),
|
|
4012
4010
|
cwd
|
|
4013
4011
|
}));
|
|
@@ -4016,9 +4014,10 @@ const make$12 = (vfs, cwd) => fromBash(new Bash({
|
|
|
4016
4014
|
* mount binds its cwd. This matches Flue's BashFactory ownership: mounts share
|
|
4017
4015
|
* the VFS, but shell state (functions, options, command hashes) is mount-local.
|
|
4018
4016
|
*/
|
|
4019
|
-
const transport$1 = (inner) => Layer.provideMerge(Layer.effect(shell_exports.Shell, Effect.
|
|
4020
|
-
const
|
|
4021
|
-
|
|
4017
|
+
const transport$1 = (inner) => Layer.provideMerge(Layer.effect(shell_exports.Shell, Effect.gen(function* () {
|
|
4018
|
+
const module = yield* JustBash;
|
|
4019
|
+
const vfs = yield* Vfs;
|
|
4020
|
+
return (0, shell_exports.perMount)(make$12(module, vfs, "/"), (cwd) => make$12(module, vfs, cwd));
|
|
4022
4021
|
})), inner);
|
|
4023
4022
|
//#endregion
|
|
4024
4023
|
//#region src/sandbox/virtual.ts
|
|
@@ -6134,7 +6133,7 @@ var Accumulator = class {
|
|
|
6134
6133
|
//#endregion
|
|
6135
6134
|
//#region src/tool/output.ts
|
|
6136
6135
|
/** A new, unused output file path under `spillPath`. */
|
|
6137
|
-
const path
|
|
6136
|
+
const path = (spillPath, prefix) => crypto.randomBytes(8).pipe(Effect.map((bytes) => posix.join(spillPath, `${prefix}-${Hex.encode(bytes)}.log`)), Effect.orDie);
|
|
6138
6137
|
/** First line printed when the output file cannot be created; the command then runs unsaved. */
|
|
6139
6138
|
const unsaved = (file) => `codework: output not saved, cannot create ${file}`;
|
|
6140
6139
|
const HEADER = "codework-output";
|
|
@@ -6522,7 +6521,7 @@ const runStreaming = (shell, stream, params, file) => Effect.gen(function* () {
|
|
|
6522
6521
|
});
|
|
6523
6522
|
const bashHandler = (params) => Effect.gen(function* () {
|
|
6524
6523
|
const shell = yield* ToolShell;
|
|
6525
|
-
const file = yield* path
|
|
6524
|
+
const file = yield* path((yield* io_exports.SandboxIO.Current).spillPath, "codework-bash");
|
|
6526
6525
|
return yield* (shell.stream !== void 0 ? runStreaming(shell, shell.stream, params, file) : runBuffered(shell, params, file)).pipe(Effect.onInterrupt(() => cleanUp(shell, file, {
|
|
6527
6526
|
output: "",
|
|
6528
6527
|
truncated: false
|
|
@@ -7352,7 +7351,7 @@ const grepHandler = (params) => Effect.gen(function* () {
|
|
|
7352
7351
|
const isDirectory = stat.value.isDirectory;
|
|
7353
7352
|
const context = params.context && params.context > 0 ? Math.trunc(params.context) : 0;
|
|
7354
7353
|
const limit = Math.max(1, Math.trunc(params.limit ?? DEFAULT_LIMIT$1));
|
|
7355
|
-
const errors = yield* path
|
|
7354
|
+
const errors = yield* path(sandbox.spillPath, "codework-grep");
|
|
7356
7355
|
const run = yield* withCommand("rg", sandbox, shell, fs, (command) => Effect.gen(function* () {
|
|
7357
7356
|
const argv = [
|
|
7358
7357
|
command,
|
|
@@ -7627,7 +7626,7 @@ const INLINE = /* @__PURE__ */ new Set([
|
|
|
7627
7626
|
"image/gif",
|
|
7628
7627
|
"image/webp"
|
|
7629
7628
|
]);
|
|
7630
|
-
const toPng = (bytes) => load$
|
|
7629
|
+
const toPng = (bytes) => load$5.pipe(Effect.map((photon) => {
|
|
7631
7630
|
if (photon === void 0) return void 0;
|
|
7632
7631
|
try {
|
|
7633
7632
|
const image = decode(photon, bytes);
|
|
@@ -7935,124 +7934,6 @@ const builtins = Object.freeze([
|
|
|
7935
7934
|
instructionPlugin
|
|
7936
7935
|
]);
|
|
7937
7936
|
//#endregion
|
|
7938
|
-
//#region src/util/module.ts
|
|
7939
|
-
/*!
|
|
7940
|
-
* Adapted from OpenCode packages/util/src/runtime/import.node.ts.
|
|
7941
|
-
*
|
|
7942
|
-
* MIT License
|
|
7943
|
-
*
|
|
7944
|
-
* Copyright (c) 2025 opencode
|
|
7945
|
-
*
|
|
7946
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7947
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
7948
|
-
* in the Software without restriction, including without limitation the rights
|
|
7949
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7950
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
7951
|
-
* furnished to do so, subject to the following conditions:
|
|
7952
|
-
*
|
|
7953
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
7954
|
-
* copies or substantial portions of the Software.
|
|
7955
|
-
*
|
|
7956
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
7957
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
7958
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
7959
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
7960
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
7961
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
7962
|
-
* SOFTWARE.
|
|
7963
|
-
*/
|
|
7964
|
-
/**
|
|
7965
|
-
* Packages a plugin must share with the harness instead of using the copy installed beside it.
|
|
7966
|
-
*
|
|
7967
|
-
* A plugin is installed into the store as its own npm tree, so `effect` and the plugin SDK land
|
|
7968
|
-
* there a second time. Two copies of the *same version* are still two module instances, and
|
|
7969
|
-
* Effect Schema's checks do not survive the crossing: a schema built by one copy and evaluated by
|
|
7970
|
-
* the other reports every check as failed, so a tool whose success type is `Schema.Finite` dies
|
|
7971
|
-
* on "Expected a finite number" for `22800`. Nothing about that is visible at registration --
|
|
7972
|
-
* `Schema.isSchema` passes, the JSON Schema is derived correctly, and the tool reaches the model
|
|
7973
|
-
* -- so it surfaces on the first call rather than at boot.
|
|
7974
|
-
*
|
|
7975
|
-
* Resolution is the right place to fix it. A symlink into the store cannot be: a generation is
|
|
7976
|
-
* immutable and shared by every project on the machine, while the harness doing the loading is
|
|
7977
|
-
* whichever one is running now, and two applications embedding the harness need not agree on
|
|
7978
|
-
* where their `effect` lives.
|
|
7979
|
-
*/
|
|
7980
|
-
const sharedPackages = /* @__PURE__ */ new Set(["effect", "@codeworksh/plugin"]);
|
|
7981
|
-
/** The package a bare specifier names: `effect/Schema` -> `effect`, `@a/b/c` -> `@a/b`. */
|
|
7982
|
-
function packageOf(specifier) {
|
|
7983
|
-
if (specifier.startsWith(".") || specifier.startsWith("/") || specifier.includes(":")) return "";
|
|
7984
|
-
const segments = specifier.split("/");
|
|
7985
|
-
return specifier.startsWith("@") ? segments.slice(0, 2).join("/") : segments[0] ?? "";
|
|
7986
|
-
}
|
|
7987
|
-
/**
|
|
7988
|
-
* Resolve the shared packages as though this module had imported them, for as long as `run`
|
|
7989
|
-
* takes. Anything else resolves exactly as it would have.
|
|
7990
|
-
*/
|
|
7991
|
-
function withSharedModules(run) {
|
|
7992
|
-
const hook = registerHooks({ resolve(specifier, context, nextResolve) {
|
|
7993
|
-
return sharedPackages.has(packageOf(specifier)) ? nextResolve(specifier, {
|
|
7994
|
-
...context,
|
|
7995
|
-
parentURL: import.meta.url
|
|
7996
|
-
}) : nextResolve(specifier, context);
|
|
7997
|
-
} });
|
|
7998
|
-
return run().finally(() => hook.deregister());
|
|
7999
|
-
}
|
|
8000
|
-
/** Use Node's main loader even when the caller runs inside a bundler or test VM. */
|
|
8001
|
-
async function importModule(specifier) {
|
|
8002
|
-
const imported = await withSharedModules(() => new Script(`import(${JSON.stringify(specifier)})`, { importModuleDynamically: constants.USE_MAIN_CONTEXT_DEFAULT_LOADER }).runInThisContext());
|
|
8003
|
-
if (typeof imported !== "object" || imported === null) return imported;
|
|
8004
|
-
const module = imported;
|
|
8005
|
-
const exports = module["module.exports"];
|
|
8006
|
-
if (exports !== module.default || typeof exports !== "object" && typeof exports !== "function" || exports === null) return imported;
|
|
8007
|
-
return Object.assign({}, module, exports);
|
|
8008
|
-
}
|
|
8009
|
-
/** Node resolution scoped synchronously to the caller. */
|
|
8010
|
-
function resolveModule(specifier, directory, conditions) {
|
|
8011
|
-
const hook = registerHooks({ resolve(target, context, nextResolve) {
|
|
8012
|
-
return nextResolve(target, {
|
|
8013
|
-
...context,
|
|
8014
|
-
parentURL: pathToFileURL(path.join(directory, "package.json")).href,
|
|
8015
|
-
...conditions === void 0 ? {} : { conditions: [.../* @__PURE__ */ new Set([...context.conditions, ...conditions])] }
|
|
8016
|
-
});
|
|
8017
|
-
} });
|
|
8018
|
-
try {
|
|
8019
|
-
const resolve = (target) => {
|
|
8020
|
-
const resolved = import.meta.resolve(path.isAbsolute(target) ? pathToFileURL(target).href : target);
|
|
8021
|
-
if (resolved.startsWith("file:")) statSync(new URL(resolved));
|
|
8022
|
-
return resolved;
|
|
8023
|
-
};
|
|
8024
|
-
try {
|
|
8025
|
-
return resolve(specifier);
|
|
8026
|
-
} catch (error) {
|
|
8027
|
-
if (path.extname(specifier) || !missing(error)) throw error;
|
|
8028
|
-
for (const extension of [
|
|
8029
|
-
".ts",
|
|
8030
|
-
".tsx",
|
|
8031
|
-
".js",
|
|
8032
|
-
".jsx",
|
|
8033
|
-
".mts",
|
|
8034
|
-
".mjs",
|
|
8035
|
-
".cts",
|
|
8036
|
-
".cjs"
|
|
8037
|
-
]) try {
|
|
8038
|
-
return resolve(specifier + extension);
|
|
8039
|
-
} catch (cause) {
|
|
8040
|
-
if (!missing(cause)) throw cause;
|
|
8041
|
-
}
|
|
8042
|
-
throw error;
|
|
8043
|
-
}
|
|
8044
|
-
} finally {
|
|
8045
|
-
hook.deregister();
|
|
8046
|
-
}
|
|
8047
|
-
}
|
|
8048
|
-
function missing(error) {
|
|
8049
|
-
return error instanceof Error && "code" in error && [
|
|
8050
|
-
"ENOENT",
|
|
8051
|
-
"ENOTDIR",
|
|
8052
|
-
"ERR_MODULE_NOT_FOUND"
|
|
8053
|
-
].includes(String(error.code));
|
|
8054
|
-
}
|
|
8055
|
-
//#endregion
|
|
8056
7937
|
//#region src/plugin/error.ts
|
|
8057
7938
|
/**
|
|
8058
7939
|
* The reference as the person wrote it -- the string they will recognise in their settings file,
|
|
@@ -11844,12 +11725,14 @@ var plugin_exports = /* @__PURE__ */ __exportAll({
|
|
|
11844
11725
|
definition: () => definition$1,
|
|
11845
11726
|
identity: () => digest,
|
|
11846
11727
|
inspect: () => inspect,
|
|
11728
|
+
lendResolve: () => lendResolve,
|
|
11847
11729
|
localName: () => localName,
|
|
11848
11730
|
parse: () => parse$1,
|
|
11849
11731
|
probe: () => probe,
|
|
11850
11732
|
resolve: () => resolve$2,
|
|
11851
11733
|
resolveCached: () => required,
|
|
11852
11734
|
settingsLock: () => lock,
|
|
11735
|
+
share: () => share,
|
|
11853
11736
|
update: () => update
|
|
11854
11737
|
});
|
|
11855
11738
|
//#endregion
|