@codeworksh/plugin 0.0.1-dev.20260925150557 → 0.1.0-canary.1.1.gc0ff5572
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 +13 -5
- package/{event-BnLveFBB.d.mts → event-6sTQ_4bq.d.mts} +53 -49
- package/event.d.mts +1 -1
- package/filesystem-CuGE9poU.d.mts +268 -0
- package/filesystem-omtKo08x.mjs +381 -0
- package/filesystem-omtKo08x.mjs.map +1 -0
- package/ids.mjs +1 -1
- package/ids.mjs.map +1 -1
- package/index.d.mts +4 -3
- package/index.mjs +3 -2
- package/io-Dgh8U41k.mjs +188 -0
- package/io-Dgh8U41k.mjs.map +1 -0
- package/{io-BYs7hbiY.d.mts → io-nhvNKC33.d.mts} +51 -8
- package/{location-D4hAfuXF.d.mts → location-Q39els63.d.mts} +9 -14
- package/location.d.mts +2 -2
- package/location.mjs +2 -5
- package/location.mjs.map +1 -1
- package/package.json +8 -3
- package/plugin/prompt.d.mts +1 -1
- package/plugin/prompt.mjs.map +1 -1
- package/plugin/section.d.mts +27 -0
- package/plugin/section.mjs +65 -0
- package/plugin/section.mjs.map +1 -0
- package/plugin/tool.d.mts +1 -1
- package/{plugin-B1M3SjEb.d.mts → plugin-Deb2QWIP.d.mts} +27 -9
- package/{plugin-lorpq7Oi.mjs → plugin-XaYYRsX-.mjs} +3 -1
- package/{plugin-lorpq7Oi.mjs.map → plugin-XaYYRsX-.mjs.map} +1 -1
- package/plugin.d.mts +5 -4
- package/plugin.mjs +3 -2
- package/prompt-DWaA5ZXj.d.mts +21 -0
- package/sandbox/driver.d.mts +1 -1
- package/sandbox/driver.mjs +7 -3
- package/sandbox/driver.mjs.map +1 -1
- package/sandbox/errors.d.mts +1 -1
- package/sandbox/filesystem.d.mts +2 -2
- package/sandbox/filesystem.mjs +2 -142
- package/sandbox/instance.d.mts +1 -1
- package/sandbox/io.d.mts +2 -2
- package/sandbox/io.mjs +3 -127
- package/sandbox.d.mts +3 -3
- package/sandbox.mjs +8 -5
- package/sandbox.mjs.map +1 -1
- package/schema.d.mts +3 -1
- package/schema.mjs +4 -2
- package/schema.mjs.map +1 -1
- package/settings-47Mzxhl0.d.mts +587 -0
- package/settings.d.mts +2 -2
- package/settings.mjs +56 -5
- package/settings.mjs.map +1 -1
- package/tool/progress.d.mts +1 -1
- package/{tool-BoVqkYvL.d.mts → tool-D4_I_rzy.d.mts} +2 -2
- package/{tool-DuYBgiJf.d.mts → tool-_ajVYIY5.d.mts} +20 -1
- package/tool.d.mts +1 -1
- package/tool.mjs +2 -1
- package/tool.mjs.map +1 -1
- package/filesystem-Cp-KapCE.d.mts +0 -142
- package/prompt-BcpagjGh.d.mts +0 -10
- package/sandbox/filesystem.mjs.map +0 -1
- package/sandbox/io.mjs.map +0 -1
- package/settings-bbJi7FiQ.d.mts +0 -207
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { i as Definition, o as Payload, r as Data, s as PublishOptions } from "./event-
|
|
1
|
+
import { i as Definition, o as Payload, r as Data, s as PublishOptions } from "./event-6sTQ_4bq.mjs";
|
|
2
2
|
import { n as SessionID } from "./ids-CHjmAdTc.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { o as Service, r as Info } from "./location-Q39els63.mjs";
|
|
4
|
+
import { f as io_d_exports, i as Identity, s as Provides } from "./io-nhvNKC33.mjs";
|
|
5
|
+
import { i as Info$1 } from "./settings-47Mzxhl0.mjs";
|
|
6
|
+
import { t as section_d_exports } from "./plugin/section.mjs";
|
|
7
|
+
import { n as prompt_d_exports, t as PromptRegistry } from "./prompt-DWaA5ZXj.mjs";
|
|
8
|
+
import { d as ToolRegistry, p as tool_d_exports } from "./tool-D4_I_rzy.mjs";
|
|
8
9
|
import { Model } from "@codeworksh/aikit";
|
|
9
10
|
import { Effect } from "effect";
|
|
10
11
|
//#region src/plugin/registry.d.ts
|
|
@@ -36,10 +37,22 @@ interface Config {
|
|
|
36
37
|
interface Events {
|
|
37
38
|
readonly publish: <D extends Definition>(definition: D, data: Data<D>, options?: PublishOptions) => Effect.Effect<Payload<D>>;
|
|
38
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* The harness's own directories on the host, all under its home (`--home`, `~/.codework` by
|
|
42
|
+
* default). App-level: the same for every session, and never a session's project or its sandbox.
|
|
43
|
+
*/
|
|
44
|
+
interface Paths {
|
|
45
|
+
readonly home: string;
|
|
46
|
+
readonly bin: string;
|
|
47
|
+
readonly cache: string;
|
|
48
|
+
readonly data: string;
|
|
49
|
+
readonly log: string;
|
|
50
|
+
}
|
|
39
51
|
/** One object, shared by every plugin in one exchange. */
|
|
40
52
|
interface SharedPluginContext {
|
|
41
53
|
readonly sessionId: SessionID;
|
|
42
54
|
readonly sandbox: Identity;
|
|
55
|
+
readonly paths: Paths;
|
|
43
56
|
readonly location: Info;
|
|
44
57
|
readonly settings: Info$1;
|
|
45
58
|
readonly model: Model.Info;
|
|
@@ -123,6 +136,11 @@ interface Plugin {
|
|
|
123
136
|
* `plugin.<id>.*`.
|
|
124
137
|
*/
|
|
125
138
|
readonly events?: ReadonlyArray<Definition>;
|
|
139
|
+
/**
|
|
140
|
+
* Off until a user asks for it. An `optIn` plugin is selected like any other but runs only
|
|
141
|
+
* when a settings entry turns it on: `{ "plugin": "<id>", "enabled": true }`.
|
|
142
|
+
*/
|
|
143
|
+
readonly optIn?: boolean;
|
|
126
144
|
/**
|
|
127
145
|
* `options` is this plugin's own configuration block, `{}` when its entry carried none.
|
|
128
146
|
* Unvalidated: the harness never looks inside it, so a plugin checks whatever shape it
|
|
@@ -133,8 +151,8 @@ interface Plugin {
|
|
|
133
151
|
}
|
|
134
152
|
declare const define: (plugin: Plugin) => Plugin;
|
|
135
153
|
declare namespace plugin_d_exports {
|
|
136
|
-
export { Config, Events, Mount, Plugin, PluginKind, PluginOptions, PluginPatch, PluginRef, PluginRegistry, PluginSpec, prompt_d_exports as Prompt, PromptResolver, SharedPluginContext, tool_d_exports as Tool, define, domains, rank };
|
|
154
|
+
export { Config, Events, Mount, Paths, Plugin, PluginKind, PluginOptions, PluginPatch, PluginRef, PluginRegistry, PluginSpec, prompt_d_exports as Prompt, PromptResolver, section_d_exports as Section, SharedPluginContext, tool_d_exports as Tool, define, domains, rank };
|
|
137
155
|
}
|
|
138
156
|
//#endregion
|
|
139
|
-
export { define as a, PluginOptions as c, PluginSpec as d, Config as f,
|
|
140
|
-
//# sourceMappingURL=plugin-
|
|
157
|
+
export { PluginRegistry as _, define as a, PluginOptions as c, PluginSpec as d, Config as f, SharedPluginContext as g, PromptResolver as h, PluginKind as i, PluginPatch as l, Paths as m, Mount as n, domains as o, Events as p, Plugin as r, rank as s, plugin_d_exports as t, PluginRef as u };
|
|
158
|
+
//# sourceMappingURL=plugin-Deb2QWIP.d.mts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { t as prompt_exports } from "./plugin/prompt.mjs";
|
|
3
|
+
import { t as section_exports } from "./plugin/section.mjs";
|
|
3
4
|
import { t as tool_exports } from "./plugin/tool.mjs";
|
|
4
5
|
//#region src/plugin/plugin.ts
|
|
5
6
|
/**
|
|
@@ -30,6 +31,7 @@ const define = (plugin) => plugin;
|
|
|
30
31
|
//#region src/plugin.ts
|
|
31
32
|
var plugin_exports = /* @__PURE__ */ __exportAll({
|
|
32
33
|
Prompt: () => prompt_exports,
|
|
34
|
+
Section: () => section_exports,
|
|
33
35
|
Tool: () => tool_exports,
|
|
34
36
|
define: () => define,
|
|
35
37
|
domains: () => domains,
|
|
@@ -38,4 +40,4 @@ var plugin_exports = /* @__PURE__ */ __exportAll({
|
|
|
38
40
|
//#endregion
|
|
39
41
|
export { rank as i, define as n, domains as r, plugin_exports as t };
|
|
40
42
|
|
|
41
|
-
//# sourceMappingURL=plugin-
|
|
43
|
+
//# sourceMappingURL=plugin-XaYYRsX-.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-
|
|
1
|
+
{"version":3,"file":"plugin-XaYYRsX-.mjs","names":[],"sources":["../../src/plugin/plugin.ts","../../src/plugin.ts"],"sourcesContent":["import type { Effect } from \"effect\";\nimport type { Definition } from \"../event.ts\";\nimport type { Service as LocationService } from \"../location.ts\";\nimport type { SandboxIO } from \"../sandbox/io.ts\";\nimport type { SharedPluginContext } from \"./context.ts\";\nimport type { PluginOptions } from \"./ref.ts\";\n\n/**\n * The domains a plugin can extend, and the order the harness runs them in.\n *\n * Order is declared, not positional. A plugin's place used to come from where its entry sat in\n * the `plugins` array, which is unknowable when the entry is written: a user's settings file and\n * a project's are edited by different people at different times, and neither can see the other's\n * order. Since a prompt plugin indexes the tools registered before it, that made a tool added\n * from settings invisible in the system prompt, with no way to fix it from a settings file.\n *\n * A plugin instead says which domain it extends, and the harness runs the domains in this order.\n * Entries within one domain keep the order they were written in, because that is where\n * composition actually happens -- a plugin patching another's tool, or appending to the prompt a\n * previous one rendered, is written next to it and deliberately after it.\n *\n * Kept as data so a later release can add a domain, or make the order configurable, without\n * touching the loader: `{ tool: 1, skill: 2, prompt: 3 }` needs no code change here.\n */\nexport const domains = { tool: 1, prompt: 2 } as const;\n\nexport type PluginKind = keyof typeof domains;\n\n/** Sort key for a plugin: its domain first, then where it was written. */\nexport const rank = (kind: PluginKind) => domains[kind];\n\nexport type Mount = SandboxIO.Provides | LocationService;\nexport interface Plugin {\n\treadonly id: string;\n\t/**\n\t * The domain this plugin extends, which decides when it runs: every `tool` plugin is set up\n\t * before any `prompt` plugin, whichever settings layer each came from, so a prompt plugin\n\t * always sees the complete tool set. Plugins within one domain run in the order they were\n\t * written.\n\t */\n\treadonly kind: PluginKind;\n\t/**\n\t * Event definitions this plugin publishes. Declared rather than registered at\n\t * runtime so they are known before the event system builds, and so a bad type\n\t * fails the boot instead of the first publish. Types must be namespaced\n\t * `plugin.<id>.*`.\n\t */\n\treadonly events?: ReadonlyArray<Definition>;\n\t/**\n\t * Off until a user asks for it. An `optIn` plugin is selected like any other but runs only\n\t * when a settings entry turns it on: `{ \"plugin\": \"<id>\", \"enabled\": true }`.\n\t */\n\treadonly optIn?: boolean;\n\t/**\n\t * `options` is this plugin's own configuration block, `{}` when its entry carried none.\n\t * Unvalidated: the harness never looks inside it, so a plugin checks whatever shape it\n\t * documents. It is a second argument rather than a context field so `ctx` stays one object\n\t * shared by every plugin in the exchange.\n\t */\n\treadonly setup: (\n\t\tctx: SharedPluginContext,\n\t\toptions: PluginOptions,\n\t) => void | Promise<void> | Effect.Effect<void, unknown, Mount>;\n}\n\nexport const define = (plugin: Plugin): Plugin => plugin;\n","/**\n * The plugin authoring surface.\n *\n * Everything a third-party plugin needs to describe itself and to write into the harness during\n * `setup`, and nothing about how the harness finds, installs or runs it. Loading, the store and\n * the `.npmrc` anchoring stay in `@codeworksh/harness`, which imports this same module — so a\n * plugin and its host agree on one set of types rather than two that happen to match.\n */\nexport type { Config, Events, Paths, PromptResolver, SharedPluginContext } from \"./plugin/context.ts\";\nexport { define, domains, type Mount, type Plugin, type PluginKind, rank } from \"./plugin/plugin.ts\";\nexport * as Prompt from \"./plugin/prompt.ts\";\nexport * as Section from \"./plugin/section.ts\";\nexport type { PluginOptions, PluginPatch, PluginRef, PluginSpec } from \"./plugin/ref.ts\";\nexport type { PluginRegistry } from \"./plugin/registry.ts\";\nexport * as Tool from \"./plugin/tool.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,UAAU;CAAE,MAAM;CAAG,QAAQ;AAAE;;AAK5C,MAAa,QAAQ,SAAqB,QAAQ;AAoClD,MAAa,UAAU,WAA2B"}
|
package/plugin.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { t as section_d_exports } from "./plugin/section.mjs";
|
|
2
|
+
import { n as prompt_d_exports } from "./prompt-DWaA5ZXj.mjs";
|
|
3
|
+
import { p as tool_d_exports } from "./tool-D4_I_rzy.mjs";
|
|
4
|
+
import { _ as PluginRegistry, a as define, c as PluginOptions, d as PluginSpec, f as Config, g as SharedPluginContext, h as PromptResolver, i as PluginKind, l as PluginPatch, m as Paths, n as Mount, o as domains, p as Events, r as Plugin, s as rank, u as PluginRef } from "./plugin-Deb2QWIP.mjs";
|
|
5
|
+
export { type Config, type Events, type Mount, type Paths, type Plugin, type PluginKind, type PluginOptions, type PluginPatch, type PluginRef, type PluginRegistry, type PluginSpec, prompt_d_exports as Prompt, type PromptResolver, section_d_exports as Section, type SharedPluginContext, tool_d_exports as Tool, define, domains, rank };
|
package/plugin.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { i as rank, n as define, r as domains } from "./plugin-
|
|
1
|
+
import { i as rank, n as define, r as domains } from "./plugin-XaYYRsX-.mjs";
|
|
2
2
|
import { t as prompt_exports } from "./plugin/prompt.mjs";
|
|
3
|
+
import { t as section_exports } from "./plugin/section.mjs";
|
|
3
4
|
import { t as tool_exports } from "./plugin/tool.mjs";
|
|
4
|
-
export { prompt_exports as Prompt, tool_exports as Tool, define, domains, rank };
|
|
5
|
+
export { prompt_exports as Prompt, section_exports as Section, tool_exports as Tool, define, domains, rank };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Section } from "./plugin/section.mjs";
|
|
2
|
+
declare namespace prompt_d_exports {
|
|
3
|
+
export { PromptRegistry };
|
|
4
|
+
}
|
|
5
|
+
interface PromptRegistry {
|
|
6
|
+
/** The untagged head of the system prompt; the last `set` wins. */
|
|
7
|
+
readonly foundation: {
|
|
8
|
+
readonly set: (text: string) => void;
|
|
9
|
+
readonly get: () => string | undefined;
|
|
10
|
+
};
|
|
11
|
+
readonly sections: {
|
|
12
|
+
readonly append: (section: Section, entry: string) => void;
|
|
13
|
+
readonly set: (section: Section, entries: ReadonlyArray<string>) => void;
|
|
14
|
+
/** Writing a removed section again opens a new one, last in order. */
|
|
15
|
+
readonly remove: (section: Section) => void;
|
|
16
|
+
readonly get: (section: Section) => ReadonlyArray<string> | undefined;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { prompt_d_exports as n, PromptRegistry as t };
|
|
21
|
+
//# sourceMappingURL=prompt-DWaA5ZXj.d.mts.map
|
package/sandbox/driver.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as RuntimeConfigBase, C as Module, D as Provisioned, E as Observed, F as driver, I as driver_d_exports, L as erase, M as Source, N as apiVersion, O as Registered, P as defineModule, R as withSource, S as Driver, T as Name, b as Capabilities, j as RuntimeInput, k as Registration, v as AbsolutePath, w as ModuleDefinition, x as Definition, y as ApiVersion } from "../io-nhvNKC33.mjs";
|
|
2
2
|
export { AbsolutePath, ApiVersion, Capabilities, Definition, Driver, Module, ModuleDefinition, Name, Observed, Provisioned, Registered, Registration, RuntimeConfigBase, RuntimeInput, driver_d_exports as SandboxDriver, Source, apiVersion, driver, erase, defineModule as module, withSource };
|
package/sandbox/driver.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "../rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import "./instance.mjs";
|
|
3
|
-
import "
|
|
3
|
+
import "../io-Dgh8U41k.mjs";
|
|
4
4
|
import { Schema } from "effect";
|
|
5
5
|
//#region src/sandbox/driver.ts
|
|
6
6
|
var driver_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -19,8 +19,12 @@ const apiVersion = 1;
|
|
|
19
19
|
/** Open driver identity. Adding a driver never extends a union in core. */
|
|
20
20
|
const Name = Schema.String.check(Schema.isNonEmpty()).pipe(Schema.brand("SandboxDriver.Name"));
|
|
21
21
|
/** A path whose coordinate system is the mounted namespace. */
|
|
22
|
-
const AbsolutePath = Schema.String.check(Schema.
|
|
23
|
-
const RuntimeConfigBase = Schema.Struct({
|
|
22
|
+
const AbsolutePath = Schema.String.check(Schema.isStartingWith("/")).pipe(Schema.brand("SandboxDriver.AbsolutePath"));
|
|
23
|
+
const RuntimeConfigBase = Schema.Struct({
|
|
24
|
+
defaultCwd: AbsolutePath,
|
|
25
|
+
/** Where oversized tool output is written inside the sandbox; `SandboxIO.DEFAULT_SPILL_PATH` when absent. */
|
|
26
|
+
spillPath: Schema.optional(AbsolutePath)
|
|
27
|
+
});
|
|
24
28
|
const erase = (value) => ({
|
|
25
29
|
name: value.name,
|
|
26
30
|
kind: value.kind,
|
package/sandbox/driver.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"driver.mjs","names":[],"sources":["../../../src/sandbox/driver.ts"],"sourcesContent":["import { type Effect, type Layer, Option, Schema } from \"effect\";\nimport type { SandboxProviderError } from \"./errors.ts\";\nimport { SandboxInstance } from \"./instance.ts\";\nimport { SandboxIO } from \"./io.ts\";\n\n/** Version of the loadable sandbox-driver module ABI. */\nexport const apiVersion = 1 as const;\nexport type ApiVersion = typeof apiVersion;\n\n/** Open driver identity. Adding a driver never extends a union in core. */\nexport const Name = Schema.String.check(Schema.isNonEmpty()).pipe(Schema.brand(\"SandboxDriver.Name\"));\nexport type Name = typeof Name.Type;\n\n/** A path whose coordinate system is the mounted namespace. */\nexport const AbsolutePath = Schema.String.check(Schema.
|
|
1
|
+
{"version":3,"file":"driver.mjs","names":[],"sources":["../../../src/sandbox/driver.ts"],"sourcesContent":["import { type Effect, type Layer, Option, Schema } from \"effect\";\nimport type { SandboxProviderError } from \"./errors.ts\";\nimport { SandboxInstance } from \"./instance.ts\";\nimport { SandboxIO } from \"./io.ts\";\n\n/** Version of the loadable sandbox-driver module ABI. */\nexport const apiVersion = 1 as const;\nexport type ApiVersion = typeof apiVersion;\n\n/** Open driver identity. Adding a driver never extends a union in core. */\nexport const Name = Schema.String.check(Schema.isNonEmpty()).pipe(Schema.brand(\"SandboxDriver.Name\"));\nexport type Name = typeof Name.Type;\n\n/** A path whose coordinate system is the mounted namespace. */\nexport const AbsolutePath = Schema.String.check(Schema.isStartingWith(\"/\")).pipe(\n\tSchema.brand(\"SandboxDriver.AbsolutePath\"),\n);\nexport type AbsolutePath = typeof AbsolutePath.Type;\n\nexport const RuntimeConfigBase = Schema.Struct({\n\tdefaultCwd: AbsolutePath,\n\t/** Where oversized tool output is written inside the sandbox; `SandboxIO.DEFAULT_SPILL_PATH` when absent. */\n\tspillPath: Schema.optional(AbsolutePath),\n});\nexport interface RuntimeConfigBase extends Schema.Schema.Type<typeof RuntimeConfigBase> {}\n\nexport interface Capabilities {\n\treadonly inspect: boolean;\n\treadonly reattach: boolean;\n\treadonly wake: boolean;\n\treadonly stop: boolean;\n\treadonly destroy: boolean;\n\treadonly cancels: boolean;\n}\n\nexport interface Observed {\n\treadonly status: SandboxInstance.Status;\n\treadonly providerStatus?: string | undefined;\n\treadonly metadata?: Readonly<Record<string, string>> | undefined;\n}\n\nexport interface Provisioned<RuntimeConfig extends RuntimeConfigBase> {\n\treadonly providerResourceId?: string | undefined;\n\treadonly providerStatus?: string | undefined;\n\treadonly runtimeConfig: RuntimeConfig;\n\treadonly metadata?: Readonly<Record<string, string>> | undefined;\n}\n\nexport interface RuntimeInput<RuntimeConfig extends RuntimeConfigBase> {\n\treadonly id: SandboxInstance.ID;\n\treadonly providerResourceId: Option.Option<string>;\n\treadonly runtimeConfig: RuntimeConfig;\n}\n\nexport interface Driver<CreateConfig, RuntimeConfig extends RuntimeConfigBase> {\n\treadonly name: Name;\n\treadonly kind: Exclude<SandboxInstance.Kind, \"local\">;\n\treadonly capabilities: Capabilities;\n\treadonly createConfigCodec: Schema.Codec<CreateConfig, unknown>;\n\treadonly runtimeConfigCodec: Schema.Codec<RuntimeConfig, unknown>;\n\treadonly create: (input: {\n\t\treadonly instanceId: SandboxInstance.ID;\n\t\treadonly config: CreateConfig;\n\t}) => Effect.Effect<Provisioned<RuntimeConfig>, SandboxProviderError>;\n\treadonly runtimeConfigFor?:\n\t\t| ((input: {\n\t\t\t\treadonly providerResourceId: string;\n\t\t\t\treadonly overrides?: Partial<RuntimeConfig> | undefined;\n\t\t }) => Effect.Effect<RuntimeConfig, SandboxProviderError>)\n\t\t| undefined;\n\treadonly attach: (\n\t\tinput: RuntimeInput<RuntimeConfig>,\n\t) => Layer.Layer<SandboxIO.FileSystem | SandboxIO.Shell, SandboxProviderError>;\n\treadonly inspect?: (input: RuntimeInput<RuntimeConfig>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly wake?: (input: RuntimeInput<RuntimeConfig>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly stop?: (input: RuntimeInput<RuntimeConfig>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly destroy?: (input: RuntimeInput<RuntimeConfig>) => Effect.Effect<void, SandboxProviderError>;\n}\n\nexport type Definition<CreateConfig, RuntimeConfig extends RuntimeConfigBase> = Pick<\n\tDriver<CreateConfig, RuntimeConfig>,\n\t\"name\" | \"createConfigCodec\" | \"runtimeConfigCodec\"\n>;\n\n/** Registry-only erased shape. Driver authors construct it via {@link driver}. */\nexport interface Registered {\n\treadonly name: Name;\n\treadonly kind: Exclude<SandboxInstance.Kind, \"local\">;\n\treadonly capabilities: Capabilities;\n\treadonly createConfigCodec: Schema.Codec<unknown, unknown>;\n\treadonly runtimeConfigCodec: Schema.Codec<RuntimeConfigBase, unknown>;\n\treadonly create: (input: {\n\t\treadonly instanceId: SandboxInstance.ID;\n\t\treadonly config: unknown;\n\t}) => Effect.Effect<Provisioned<RuntimeConfigBase>, SandboxProviderError>;\n\treadonly runtimeConfigFor?:\n\t\t| ((input: {\n\t\t\t\treadonly providerResourceId: string;\n\t\t\t\treadonly overrides?: Readonly<Record<string, unknown>> | undefined;\n\t\t }) => Effect.Effect<RuntimeConfigBase, SandboxProviderError>)\n\t\t| undefined;\n\treadonly attach: (\n\t\tinput: RuntimeInput<RuntimeConfigBase>,\n\t) => Layer.Layer<SandboxIO.FileSystem | SandboxIO.Shell, SandboxProviderError>;\n\treadonly inspect?: (input: RuntimeInput<RuntimeConfigBase>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly wake?: (input: RuntimeInput<RuntimeConfigBase>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly stop?: (input: RuntimeInput<RuntimeConfigBase>) => Effect.Effect<Observed, SandboxProviderError>;\n\treadonly destroy?: (input: RuntimeInput<RuntimeConfigBase>) => Effect.Effect<void, SandboxProviderError>;\n}\n\nexport const erase = <CreateConfig, RuntimeConfig extends RuntimeConfigBase>(\n\tvalue: Driver<CreateConfig, RuntimeConfig>,\n): Registered => ({\n\tname: value.name,\n\tkind: value.kind,\n\tcapabilities: value.capabilities,\n\tcreateConfigCodec: value.createConfigCodec as Schema.Codec<unknown, unknown>,\n\truntimeConfigCodec: value.runtimeConfigCodec as Schema.Codec<RuntimeConfigBase, unknown>,\n\tcreate: (input) => value.create({ instanceId: input.instanceId, config: input.config as CreateConfig }),\n\t...(value.runtimeConfigFor === undefined\n\t\t? {}\n\t\t: {\n\t\t\t\truntimeConfigFor: (input: {\n\t\t\t\t\treadonly providerResourceId: string;\n\t\t\t\t\treadonly overrides?: Readonly<Record<string, unknown>> | undefined;\n\t\t\t\t}) =>\n\t\t\t\t\tvalue.runtimeConfigFor!({\n\t\t\t\t\t\tproviderResourceId: input.providerResourceId,\n\t\t\t\t\t\t...(input.overrides === undefined ? {} : { overrides: input.overrides as Partial<RuntimeConfig> }),\n\t\t\t\t\t}),\n\t\t\t}),\n\tattach: (input) => value.attach(input as RuntimeInput<RuntimeConfig>),\n\t...(value.inspect === undefined\n\t\t? {}\n\t\t: { inspect: (input: RuntimeInput<RuntimeConfigBase>) => value.inspect!(input as RuntimeInput<RuntimeConfig>) }),\n\t...(value.wake === undefined\n\t\t? {}\n\t\t: { wake: (input: RuntimeInput<RuntimeConfigBase>) => value.wake!(input as RuntimeInput<RuntimeConfig>) }),\n\t...(value.stop === undefined\n\t\t? {}\n\t\t: { stop: (input: RuntimeInput<RuntimeConfigBase>) => value.stop!(input as RuntimeInput<RuntimeConfig>) }),\n\t...(value.destroy === undefined\n\t\t? {}\n\t\t: { destroy: (input: RuntimeInput<RuntimeConfigBase>) => value.destroy!(input as RuntimeInput<RuntimeConfig>) }),\n});\n\nexport type Source = \"core\" | \"builtin\" | \"package\" | \"file\";\n\nexport interface Registration {\n\treadonly registered: Registered;\n\treadonly apiVersion: ApiVersion;\n\treadonly source: Source;\n}\n\nexport interface Module<Options> {\n\treadonly apiVersion: ApiVersion;\n\treadonly name: Name;\n\treadonly options: Schema.Codec<Options, unknown>;\n\treadonly make: (options: Options) => Registration;\n}\n\nexport interface ModuleDefinition<Options> {\n\treadonly apiVersion: ApiVersion;\n\treadonly name: string | Name;\n\treadonly options: Schema.Codec<Options, unknown>;\n\treadonly make: (options: Options) => Registration;\n}\n\n/** Define the default export of a loadable sandbox package. */\nconst defineModule = <Options>(value: ModuleDefinition<Options>): Module<Options> => ({\n\t...value,\n\tname: Name.make(value.name),\n});\nexport { defineModule as module };\n\n/** Construct a driver and its registry contribution. */\nexport const driver = <CreateConfig, RuntimeConfig extends RuntimeConfigBase>(\n\tvalue: Driver<CreateConfig, RuntimeConfig>,\n): Driver<CreateConfig, RuntimeConfig> & Registration =>\n\tObject.assign(value, {\n\t\tregistered: erase(value),\n\t\tapiVersion,\n\t\tsource: \"builtin\" as const,\n\t});\n\n/** Attach trusted origin metadata without changing the driver implementation. */\nexport const withSource = (registration: Registration, source: Source): Registration => ({\n\t...registration,\n\tsource,\n});\n\nexport * as SandboxDriver from \"./driver.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAMA,MAAa,aAAa;;AAI1B,MAAa,OAAO,OAAO,OAAO,MAAM,OAAO,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,oBAAoB,CAAC;;AAIpG,MAAa,eAAe,OAAO,OAAO,MAAM,OAAO,eAAe,GAAG,CAAC,CAAC,CAAC,KAC3E,OAAO,MAAM,4BAA4B,CAC1C;AAGA,MAAa,oBAAoB,OAAO,OAAO;CAC9C,YAAY;;CAEZ,WAAW,OAAO,SAAS,YAAY;AACxC,CAAC;AAuFD,MAAa,SACZ,WACiB;CACjB,MAAM,MAAM;CACZ,MAAM,MAAM;CACZ,cAAc,MAAM;CACpB,mBAAmB,MAAM;CACzB,oBAAoB,MAAM;CAC1B,SAAS,UAAU,MAAM,OAAO;EAAE,YAAY,MAAM;EAAY,QAAQ,MAAM;CAAuB,CAAC;CACtG,GAAI,MAAM,qBAAqB,KAAA,IAC5B,CAAC,IACD,EACA,mBAAmB,UAIlB,MAAM,iBAAkB;EACvB,oBAAoB,MAAM;EAC1B,GAAI,MAAM,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,MAAM,UAAoC;CACjG,CAAC,EACH;CACF,SAAS,UAAU,MAAM,OAAO,KAAoC;CACpE,GAAI,MAAM,YAAY,KAAA,IACnB,CAAC,IACD,EAAE,UAAU,UAA2C,MAAM,QAAS,KAAoC,EAAE;CAC/G,GAAI,MAAM,SAAS,KAAA,IAChB,CAAC,IACD,EAAE,OAAO,UAA2C,MAAM,KAAM,KAAoC,EAAE;CACzG,GAAI,MAAM,SAAS,KAAA,IAChB,CAAC,IACD,EAAE,OAAO,UAA2C,MAAM,KAAM,KAAoC,EAAE;CACzG,GAAI,MAAM,YAAY,KAAA,IACnB,CAAC,IACD,EAAE,UAAU,UAA2C,MAAM,QAAS,KAAoC,EAAE;AAChH;;AAyBA,MAAM,gBAAyB,WAAuD;CACrF,GAAG;CACH,MAAM,KAAK,KAAK,MAAM,IAAI;AAC3B;;AAIA,MAAa,UACZ,UAEA,OAAO,OAAO,OAAO;CACpB,YAAY,MAAM,KAAK;CACvB,YAAA;CACA,QAAQ;AACT,CAAC;;AAGF,MAAa,cAAc,cAA4B,YAAkC;CACxF,GAAG;CACH;AACD"}
|
package/sandbox/errors.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as SandboxRegisterError, B as SandboxBusyError, G as SandboxDriverNotRegisteredError, H as SandboxDestroyError, J as SandboxMustBeStoppedError, K as SandboxDriverRegistrationError, Q as SandboxRefreshError, U as SandboxDriverLoadError, V as SandboxCreateError, W as SandboxDriverLoadPhase, X as SandboxProviderError, Y as SandboxNotFoundError, Z as SandboxReadError, at as SandboxWakeError, ct as providerError, dt as sanitizeError, et as SandboxRemovedError, it as SandboxUnsupportedError, lt as providerErrorCause, nt as SandboxTransitionConflictError, ot as errors_d_exports, q as SandboxMountError, rt as SandboxUnavailError, st as makeRedactor, tt as SandboxStopError, ut as providerErrorIsNotFound, z as Redactor } from "../io-nhvNKC33.mjs";
|
|
2
2
|
export { Redactor, SandboxBusyError, SandboxCreateError, SandboxDestroyError, SandboxDriverLoadError, SandboxDriverLoadPhase, SandboxDriverNotRegisteredError, SandboxDriverRegistrationError, errors_d_exports as SandboxError, SandboxMountError, SandboxMustBeStoppedError, SandboxNotFoundError, SandboxProviderError, SandboxReadError, SandboxRefreshError, SandboxRegisterError, SandboxRemovedError, SandboxStopError, SandboxTransitionConflictError, SandboxUnavailError, SandboxUnsupportedError, SandboxWakeError, makeRedactor, providerError, providerErrorCause, providerErrorIsNotFound, sanitizeError };
|
package/sandbox/filesystem.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as Provider, c as filesystem_d_exports, d as
|
|
2
|
-
export { FileStat, FileSystemError, Interface, OperationUnsupportedError, Provider, RmOptions, filesystem_d_exports as SandboxFileSystem, Service, fromProvider, isNotFoundError, realpathScripts, validateRmOptions, withCwd };
|
|
1
|
+
import { _ as LineScanOptions, a as Provider, c as filesystem_d_exports, d as readBytesScript, f as readBytesViaShell, g as LineScan, h as withCwd, i as OperationUnsupportedError, l as fromProvider, m as validateRmOptions, n as FileSystemError, o as RmOptions, p as realpathScripts, r as Interface, s as Service, t as FileStat, u as isNotFoundError, v as scan_d_exports } from "../filesystem-CuGE9poU.mjs";
|
|
2
|
+
export { FileStat, FileSystemError, Interface, type LineScan, type LineScanOptions, OperationUnsupportedError, Provider, RmOptions, filesystem_d_exports as SandboxFileSystem, scan_d_exports as Scan, Service, fromProvider, isNotFoundError, readBytesScript, readBytesViaShell, realpathScripts, validateRmOptions, withCwd };
|
package/sandbox/filesystem.mjs
CHANGED
|
@@ -1,142 +1,2 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
|
|
3
|
-
import { Context, Effect, Schema } from "effect";
|
|
4
|
-
//#region src/sandbox/filesystem.ts
|
|
5
|
-
var filesystem_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
-
FileSystemError: () => FileSystemError,
|
|
7
|
-
OperationUnsupportedError: () => OperationUnsupportedError,
|
|
8
|
-
SandboxFileSystem: () => filesystem_exports,
|
|
9
|
-
Service: () => Service,
|
|
10
|
-
fromProvider: () => fromProvider,
|
|
11
|
-
isNotFoundError: () => isNotFoundError,
|
|
12
|
-
realpathScripts: () => realpathScripts,
|
|
13
|
-
validateRmOptions: () => validateRmOptions,
|
|
14
|
-
withCwd: () => withCwd
|
|
15
|
-
});
|
|
16
|
-
/**
|
|
17
|
-
* The runtime filesystem contract, independent of any backend.
|
|
18
|
-
*
|
|
19
|
-
* Two surfaces, deliberately:
|
|
20
|
-
* - {@link Provider} is what a backend implements — plain promises that reject,
|
|
21
|
-
* matching every SDK we wrap.
|
|
22
|
-
* - {@link Interface} is what the harness consumes — Effect with a typed error
|
|
23
|
-
* channel and tracing spans. {@link fromProvider} bridges the two exactly
|
|
24
|
-
* once, so no consumer ever writes `Effect.tryPromise` against a filesystem.
|
|
25
|
-
*
|
|
26
|
-
* Implementations:
|
|
27
|
-
* - Local:
|
|
28
|
-
* implement it over a VFS (`./local`);
|
|
29
|
-
* local filesystem use OS primitives; hence have broader filesytem capabilities.
|
|
30
|
-
*
|
|
31
|
-
* - Remote:
|
|
32
|
-
* implement it over a provider (`./remote`).
|
|
33
|
-
* remote filesytems depends on the interface provided by the remote provider; hence can have limited filesytem capabilities.
|
|
34
|
-
*
|
|
35
|
-
* `isFile`/`isDirectory` are required booleans; size, mtime, and isSymbolicLink are omitted when the
|
|
36
|
-
* backend cannot report them — never fabricated.
|
|
37
|
-
*
|
|
38
|
-
* **Paths are POSIX, and the harness is Unix-only (for now!).** Every path uses `/`
|
|
39
|
-
* separators on both the host and inside a sandbox — Windows is not supported,
|
|
40
|
-
* so no translation layer exists. Consumers must use the shared Effect POSIX
|
|
41
|
-
* path implementation, never the platform default, or a host running the harness would
|
|
42
|
-
* impose its own flavour on a remote sandbox's paths. Relative paths resolve
|
|
43
|
-
* against the backend's configured `cwd`.
|
|
44
|
-
*/
|
|
45
|
-
var OperationUnsupportedError = class extends Schema.TaggedError()("OperationUnsupportedError", {
|
|
46
|
-
operation: Schema.String,
|
|
47
|
-
message: Schema.String
|
|
48
|
-
}) {};
|
|
49
|
-
/** A backend operation failed. `cause` carries the provider's own rejection. */
|
|
50
|
-
var FileSystemError = class extends Schema.TaggedError()("SandboxFileSystemError", {
|
|
51
|
-
method: Schema.String,
|
|
52
|
-
path: Schema.String,
|
|
53
|
-
cause: Schema.optional(Schema.Defect())
|
|
54
|
-
}) {};
|
|
55
|
-
/** Whether a provider failure means the path itself is definitively absent. */
|
|
56
|
-
const isNotFoundError = (cause) => {
|
|
57
|
-
const code = cause?.code;
|
|
58
|
-
return code === "ENOENT" || code === "ENOTDIR";
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Shell forms of `realpath` for backends that only expose a process API.
|
|
62
|
-
* `pwd -P` is the portable primitive: directories resolve directly, anything
|
|
63
|
-
* else resolves its parent and keeps the final name as given. Run as
|
|
64
|
-
* `sh -c <script> _ <path>`; try the first, fall back to the second.
|
|
65
|
-
*/
|
|
66
|
-
const realpathScripts = ["cd -- \"$1\" && pwd -P", "cd -- \"$(dirname -- \"$1\")\" && printf '%s/%s' \"$(pwd -P)\" \"$(basename -- \"$1\")\""];
|
|
67
|
-
/** The runtime filesystem service — the live {@link Interface} for the active sandbox. */
|
|
68
|
-
var Service = class extends Context.Service()("@codeworksh/plugin/sandbox/filesystem/Service") {};
|
|
69
|
-
/**
|
|
70
|
-
* Reject `rm` options a provider does not implement, before any mutation. Only
|
|
71
|
-
* `recursive` and `force` are part of the contract; anything else is refused
|
|
72
|
-
* loudly rather than silently ignored.
|
|
73
|
-
*/
|
|
74
|
-
const validateRmOptions = (options, operation = "rm") => Effect.suspend(() => {
|
|
75
|
-
for (const option of Object.keys(options ?? {})) {
|
|
76
|
-
if (option === "recursive" || option === "force") continue;
|
|
77
|
-
return Effect.fail(new OperationUnsupportedError({
|
|
78
|
-
operation,
|
|
79
|
-
message: `Unsupported rm option: ${option}`
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
82
|
-
return Effect.void;
|
|
83
|
-
});
|
|
84
|
-
/**
|
|
85
|
-
* Lift a {@link Provider} into the runtime {@link Interface}: one place that
|
|
86
|
-
* converts rejections into {@link FileSystemError}, validates `rm` options,
|
|
87
|
-
* creates missing parents on write, and names a tracing span per operation.
|
|
88
|
-
*/
|
|
89
|
-
const fromProvider = (provider) => {
|
|
90
|
-
const attempt = (method, path, run) => Effect.tryPromise({
|
|
91
|
-
try: run,
|
|
92
|
-
catch: (cause) => new FileSystemError({
|
|
93
|
-
method,
|
|
94
|
-
path,
|
|
95
|
-
cause
|
|
96
|
-
})
|
|
97
|
-
});
|
|
98
|
-
const writeCreatingParents = (path, content) => {
|
|
99
|
-
const write = attempt("writeFile", path, () => provider.writeFile(path, content));
|
|
100
|
-
const parent = posix.dirname(path);
|
|
101
|
-
return write.pipe(Effect.catch(() => attempt("mkdir", parent, () => provider.mkdir(parent, { recursive: true })).pipe(Effect.ignore, Effect.andThen(write))));
|
|
102
|
-
};
|
|
103
|
-
return {
|
|
104
|
-
readFile: Effect.fn("SandboxFileSystem.readFile")((path) => attempt("readFile", path, () => provider.readFile(path))),
|
|
105
|
-
readFileBuffer: Effect.fn("SandboxFileSystem.readFileBuffer")((path) => attempt("readFileBuffer", path, () => provider.readFileBuffer(path))),
|
|
106
|
-
writeFile: Effect.fn("SandboxFileSystem.writeFile")(writeCreatingParents),
|
|
107
|
-
stat: Effect.fn("SandboxFileSystem.stat")((path) => attempt("stat", path, () => provider.stat(path))),
|
|
108
|
-
...provider.lstat === void 0 ? {} : { lstat: Effect.fn("SandboxFileSystem.lstat")((path) => attempt("lstat", path, () => provider.lstat(path))) },
|
|
109
|
-
readdir: Effect.fn("SandboxFileSystem.readdir")((path) => attempt("readdir", path, () => provider.readdir(path))),
|
|
110
|
-
exists: Effect.fn("SandboxFileSystem.exists")((path) => attempt("exists", path, () => provider.exists(path))),
|
|
111
|
-
mkdir: Effect.fn("SandboxFileSystem.mkdir")((path, options) => attempt("mkdir", path, () => provider.mkdir(path, options))),
|
|
112
|
-
rm: Effect.fn("SandboxFileSystem.rm")((path, options) => validateRmOptions(options).pipe(Effect.andThen(attempt("rm", path, () => provider.rm(path, options))))),
|
|
113
|
-
realpath: Effect.fn("SandboxFileSystem.realpath")((path) => attempt("realpath", path, () => provider.realpath(path)))
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
/**
|
|
117
|
-
* Bind a cwd-neutral filesystem to one mount's working directory.
|
|
118
|
-
*
|
|
119
|
-
* The counterpart of `Shell.withCwd`, and the reason relative paths mean the
|
|
120
|
-
* same thing to both: a shared transport stays rooted at the namespace root, so
|
|
121
|
-
* resolution happens here, per mount, rather than inside a VFS whose `chdir` is
|
|
122
|
-
* global state two mounts would fight over.
|
|
123
|
-
*/
|
|
124
|
-
const withCwd = (fs, cwd) => {
|
|
125
|
-
const at = (path) => posix.resolve(cwd, path);
|
|
126
|
-
return {
|
|
127
|
-
readFile: (path) => fs.readFile(at(path)),
|
|
128
|
-
readFileBuffer: (path) => fs.readFileBuffer(at(path)),
|
|
129
|
-
writeFile: (path, content) => fs.writeFile(at(path), content),
|
|
130
|
-
stat: (path) => fs.stat(at(path)),
|
|
131
|
-
readdir: (path) => fs.readdir(at(path)),
|
|
132
|
-
exists: (path) => fs.exists(at(path)),
|
|
133
|
-
mkdir: (path, options) => fs.mkdir(at(path), options),
|
|
134
|
-
rm: (path, options) => fs.rm(at(path), options),
|
|
135
|
-
realpath: (path) => fs.realpath(at(path)),
|
|
136
|
-
...fs.lstat === void 0 ? {} : { lstat: (path) => fs.lstat(at(path)) }
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
//#endregion
|
|
140
|
-
export { FileSystemError, OperationUnsupportedError, filesystem_exports as SandboxFileSystem, Service, fromProvider, isNotFoundError, realpathScripts, validateRmOptions, withCwd };
|
|
141
|
-
|
|
142
|
-
//# sourceMappingURL=filesystem.mjs.map
|
|
1
|
+
import { a as fromProvider, c as readBytesViaShell, d as withCwd, f as scan_exports, i as filesystem_exports, l as realpathScripts, n as OperationUnsupportedError, o as isNotFoundError, r as Service, s as readBytesScript, t as FileSystemError, u as validateRmOptions } from "../filesystem-omtKo08x.mjs";
|
|
2
|
+
export { FileSystemError, OperationUnsupportedError, filesystem_exports as SandboxFileSystem, scan_exports as Scan, Service, fromProvider, isNotFoundError, readBytesScript, readBytesViaShell, realpathScripts, validateRmOptions, withCwd };
|
package/sandbox/instance.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ct as mountable, St as isMountable, Tt as toField, _t as Status, bt as fromField, ft as ID, gt as PersistedError, ht as Ownership, mt as Kind, pt as Info, vt as Usage, wt as toColumn, xt as instance_d_exports, yt as fromColumn } from "../io-nhvNKC33.mjs";
|
|
2
2
|
export { ID, Info, Kind, Ownership, PersistedError, instance_d_exports as SandboxInstance, Status, Usage, fromColumn, fromField, isMountable, mountable, toColumn, toField };
|
package/sandbox/io.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { Current, FileSystem, Identity, Layer, Provides, io_d_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual };
|
|
1
|
+
import { _ as withMutation, a as Layer, c as Shell, d as identityLayer, f as io_d_exports, g as virtual, h as resolveMountCwd, i as Identity, l as host, m as remote, n as DEFAULT_SPILL_PATH, o as Mutation, p as mount, r as FileSystem, s as Provides, t as Current, u as hostLayer } from "../io-nhvNKC33.mjs";
|
|
2
|
+
export { Current, DEFAULT_SPILL_PATH, FileSystem, Identity, Layer, Mutation, Provides, io_d_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual, withMutation };
|
package/sandbox/io.mjs
CHANGED
|
@@ -1,127 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { Service, withCwd } from "./filesystem.mjs";
|
|
5
|
-
import { Shell as Shell$1, withCwd as withCwd$1 } from "./shell.mjs";
|
|
6
|
-
import { Context, Effect, Layer } from "effect";
|
|
7
|
-
//#region src/sandbox/io.ts
|
|
8
|
-
var io_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
-
Current: () => Current,
|
|
10
|
-
FileSystem: () => FileSystem,
|
|
11
|
-
SandboxIO: () => io_exports,
|
|
12
|
-
Shell: () => Shell,
|
|
13
|
-
host: () => host,
|
|
14
|
-
hostLayer: () => hostLayer,
|
|
15
|
-
identityLayer: () => identityLayer,
|
|
16
|
-
mount: () => mount,
|
|
17
|
-
remote: () => remote,
|
|
18
|
-
resolveMountCwd: () => resolveMountCwd,
|
|
19
|
-
virtual: () => virtual
|
|
20
|
-
});
|
|
21
|
-
/**
|
|
22
|
-
* `SandboxIO` is a **mount**: a filesystem, a shell, and the identity and
|
|
23
|
-
* working directory they act on.
|
|
24
|
-
*
|
|
25
|
-
* It is the whole vocabulary a consumer needs. Project, Git, Copy, Location, and
|
|
26
|
-
* every tool ask for `SandboxIO.FileSystem`, `SandboxIO.Shell`, and
|
|
27
|
-
* `SandboxIO.Current` — never for a driver, an address, or a provider SDK — so
|
|
28
|
-
* a host directory, an in-memory VFS, and a remote microVM are interchangeable
|
|
29
|
-
* behind one contract.
|
|
30
|
-
*
|
|
31
|
-
* The mount neither creates nor destroys infrastructure. `SandboxInstance` is
|
|
32
|
-
* the durable namespace it acts on — a device, which exists whether or not
|
|
33
|
-
* anything has it mounted — and `Sandbox.Controller` is the only path that
|
|
34
|
-
* creates, stops, or destroys one.
|
|
35
|
-
*/
|
|
36
|
-
/**
|
|
37
|
-
* The filesystem tag. Re-exported here so consumers import one namespace —
|
|
38
|
-
* Project, Git, Copy, and the runner ask for `SandboxIO.FileSystem`, never for
|
|
39
|
-
* the module that happens to define it. Code *inside* `sandbox/` keeps importing
|
|
40
|
-
* the tag directly, since `io.ts` is built on top of it.
|
|
41
|
-
*/
|
|
42
|
-
const FileSystem = Service;
|
|
43
|
-
/** The shell tag. Re-exported here so consumers import one namespace. */
|
|
44
|
-
const Shell = Shell$1;
|
|
45
|
-
/** Identity and working directory of the current mount. */
|
|
46
|
-
var Current = class extends Context.Service()("@codeworksh/plugin/sandbox/io/Current") {};
|
|
47
|
-
/**
|
|
48
|
-
* Resolve a mount's cwd without consulting ambient process state.
|
|
49
|
-
*
|
|
50
|
-
* The default is supplied by the namespace adapter:
|
|
51
|
-
* provider metadata remotely, `/` for a virtual filesystem, and `process.cwd()` for the host adapter.
|
|
52
|
-
* An explicit absolute cwd replaces it; a relative cwd is resolved inside it. The
|
|
53
|
-
* result is therefore always the one concrete absolute path `Current` requires.
|
|
54
|
-
*
|
|
55
|
-
* A non-absolute default throws rather than failing typed. It is the one
|
|
56
|
-
* defect-level guard in this module, and deliberately so:
|
|
57
|
-
* Adapters reading a value from a provider call this inside their own error channel,
|
|
58
|
-
* where the throw becomes their typed failure (see `EnvDaytona.mountCwd`).
|
|
59
|
-
*/
|
|
60
|
-
const resolveMountCwd = (defaultCwd, cwd) => {
|
|
61
|
-
if (!posix.isAbsolute(defaultCwd)) throw new TypeError(`Sandbox default cwd must be absolute: ${defaultCwd}`);
|
|
62
|
-
if (cwd === void 0) return posix.resolve(defaultCwd);
|
|
63
|
-
return posix.isAbsolute(cwd) ? posix.resolve(cwd) : posix.resolve(defaultCwd, cwd);
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Bind a cwd-neutral transport to one mount.
|
|
67
|
-
*
|
|
68
|
-
* The transport underneath is shared between
|
|
69
|
-
* mounts and stays rooted at the namespace root, and everything directory-shaped
|
|
70
|
-
* happens here, once per mount. Two mounts of one namespace at different working
|
|
71
|
-
* directories therefore coexist without seeing or moving each other's.
|
|
72
|
-
*
|
|
73
|
-
* It consumes the same two tags it provides — the transport is supplied by the
|
|
74
|
-
* layer this is composed over, not by itself.
|
|
75
|
-
*/
|
|
76
|
-
const mount = (identity) => Layer.mergeAll(Layer.succeed(Current, identity), Layer.effect(Service, Effect.map(Service, (fs) => withCwd(fs, identity.cwd))), Layer.effect(Shell$1, Effect.map(Shell$1, (shell) => withCwd$1(shell, identity.cwd))));
|
|
77
|
-
/**
|
|
78
|
-
* Just the identity tag, with no filesystem or shell beneath it. For consumers
|
|
79
|
-
* assembled from stubs — a test that runs `Project` over a fake filesystem still
|
|
80
|
-
* needs to know which namespace it is in.
|
|
81
|
-
*/
|
|
82
|
-
const identityLayer = (identity) => Layer.succeed(Current, identity);
|
|
83
|
-
/** The host identity alone. See {@link identityLayer}. */
|
|
84
|
-
const hostLayer = (cwd) => identityLayer(host(cwd));
|
|
85
|
-
/**
|
|
86
|
-
* The host, rooted at `cwd`. Always `SandboxInstance.ID.local`: the working
|
|
87
|
-
* directory selects where relative paths resolve, it does not make a second host
|
|
88
|
-
* namespace — two mounts rooted at different directories still agree on absolute
|
|
89
|
-
* paths.
|
|
90
|
-
*
|
|
91
|
-
* The host coordinate is explicit so a caller cannot accidentally substitute ambient process
|
|
92
|
-
* state for the application or session directory it owns.
|
|
93
|
-
*/
|
|
94
|
-
const host = (cwd) => ({
|
|
95
|
-
id: ID.local,
|
|
96
|
-
driver: "local",
|
|
97
|
-
kind: "local",
|
|
98
|
-
cwd: resolveMountCwd(cwd)
|
|
99
|
-
});
|
|
100
|
-
/**
|
|
101
|
-
* A VFS-backed namespace. The id is minted per call unless one is named, because
|
|
102
|
-
* building one of these builds a fresh VFS: N unnamed calls are N distinct
|
|
103
|
-
* namespaces, none of which outlives the process. A file-backed store is the
|
|
104
|
-
* exception — its file is the state, so whoever knows the file supplies the id
|
|
105
|
-
* it was registered under.
|
|
106
|
-
*/
|
|
107
|
-
const virtual = (input) => ({
|
|
108
|
-
id: input.id ?? ID.create(),
|
|
109
|
-
driver: input.driver,
|
|
110
|
-
kind: "virtual",
|
|
111
|
-
cwd: resolveMountCwd(input.defaultCwd ?? "/", input.cwd)
|
|
112
|
-
});
|
|
113
|
-
/**
|
|
114
|
-
* A provider-hosted namespace. The id is always supplied: a remote resource's
|
|
115
|
-
* durable identity is minted and recorded by whoever provisioned it, never
|
|
116
|
-
* derived here from the provider's own locator.
|
|
117
|
-
*/
|
|
118
|
-
const remote = (input) => ({
|
|
119
|
-
id: input.id,
|
|
120
|
-
driver: input.driver,
|
|
121
|
-
kind: "remote",
|
|
122
|
-
cwd: resolveMountCwd(input.defaultCwd, input.cwd)
|
|
123
|
-
});
|
|
124
|
-
//#endregion
|
|
125
|
-
export { Current, FileSystem, io_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual };
|
|
126
|
-
|
|
127
|
-
//# sourceMappingURL=io.mjs.map
|
|
1
|
+
import "./instance.mjs";
|
|
2
|
+
import { a as Shell, c as identityLayer, d as remote, f as resolveMountCwd, i as Mutation, l as io_exports, m as withMutation, n as DEFAULT_SPILL_PATH, o as host, p as virtual, r as FileSystem, s as hostLayer, t as Current, u as mount } from "../io-Dgh8U41k.mjs";
|
|
3
|
+
export { Current, DEFAULT_SPILL_PATH, FileSystem, Mutation, io_exports as SandboxIO, Shell, host, hostLayer, identityLayer, mount, remote, resolveMountCwd, virtual, withMutation };
|
package/sandbox.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { c as filesystem_d_exports } from "./filesystem-
|
|
1
|
+
import { A as RuntimeConfigBase, C as Module, D as Provisioned, E as Observed, F as driver, N as apiVersion, P as defineModule, S as Driver, T as Name, X as SandboxProviderError, _ as withMutation, a as Layer, b as Capabilities, c as Shell, ct as providerError, dt as sanitizeError, i as Identity, j as RuntimeInput, k as Registration, lt as providerErrorCause, n as DEFAULT_SPILL_PATH, o as Mutation, r as FileSystem, s as Provides, st as makeRedactor, t as Current, ut as providerErrorIsNotFound, v as AbsolutePath, w as ModuleDefinition, x as Definition, xt as instance_d_exports, y as ApiVersion, z as Redactor } from "./io-nhvNKC33.mjs";
|
|
2
|
+
import { c as filesystem_d_exports } from "./filesystem-CuGE9poU.mjs";
|
|
3
3
|
import { a as ShellError, i as Shell$1, l as quote, n as ExecResult, o as ShellOptions, r as ISandboxExe, s as fromExec, t as ExecChunk, u as quoteArgv } from "./shell-CZ6Y4lNU.mjs";
|
|
4
4
|
import { SandboxResource as resource_d_exports } from "./sandbox/resource.mjs";
|
|
5
5
|
declare namespace driver_d_exports {
|
|
6
6
|
export { AbsolutePath, ApiVersion, Capabilities, Definition, Driver, Module, ModuleDefinition, Name, Observed, Provisioned, Registration, RuntimeConfigBase as RuntimeConfig, RuntimeConfigBase, RuntimeInput, driver_d_exports as SandboxDriver, apiVersion, driver, defineModule as module };
|
|
7
7
|
}
|
|
8
8
|
declare namespace io_d_exports {
|
|
9
|
-
export { Current, FileSystem, Identity, Layer, Provides, io_d_exports as SandboxIO, Shell };
|
|
9
|
+
export { Current, DEFAULT_SPILL_PATH, FileSystem, Identity, Layer, Mutation, Provides, io_d_exports as SandboxIO, Shell, withMutation };
|
|
10
10
|
}
|
|
11
11
|
declare namespace provider_d_exports {
|
|
12
12
|
export { Redactor, SandboxProviderError, makeRedactor, providerError, providerErrorCause, providerErrorIsNotFound, sanitizeError };
|
package/sandbox.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import { SandboxInstance as instance_exports } from "./sandbox/instance.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { Shell,
|
|
5
|
-
import {
|
|
3
|
+
import { i as filesystem_exports } from "./filesystem-omtKo08x.mjs";
|
|
4
|
+
import { a as Shell, i as Mutation, m as withMutation, n as DEFAULT_SPILL_PATH, r as FileSystem, t as Current } from "./io-Dgh8U41k.mjs";
|
|
5
|
+
import { Shell as Shell$1, ShellError, fromExec, quote, quoteArgv } from "./sandbox/shell.mjs";
|
|
6
6
|
import { AbsolutePath, Name, RuntimeConfigBase, driver, module as defineModule } from "./sandbox/driver.mjs";
|
|
7
7
|
import { SandboxProviderError, makeRedactor, providerError, providerErrorCause, providerErrorIsNotFound, sanitizeError } from "./sandbox/errors.mjs";
|
|
8
8
|
import { SandboxResource as resource_exports } from "./sandbox/resource.mjs";
|
|
@@ -20,9 +20,12 @@ var driver_exports = /* @__PURE__ */ __exportAll({
|
|
|
20
20
|
//#region src/sandbox/public/io.ts
|
|
21
21
|
var io_exports = /* @__PURE__ */ __exportAll({
|
|
22
22
|
Current: () => Current,
|
|
23
|
+
DEFAULT_SPILL_PATH: () => DEFAULT_SPILL_PATH,
|
|
23
24
|
FileSystem: () => FileSystem,
|
|
25
|
+
Mutation: () => Mutation,
|
|
24
26
|
SandboxIO: () => io_exports,
|
|
25
|
-
Shell: () => Shell
|
|
27
|
+
Shell: () => Shell,
|
|
28
|
+
withMutation: () => withMutation
|
|
26
29
|
});
|
|
27
30
|
//#endregion
|
|
28
31
|
//#region src/sandbox/provider.ts
|
|
@@ -37,7 +40,7 @@ var provider_exports = /* @__PURE__ */ __exportAll({
|
|
|
37
40
|
//#endregion
|
|
38
41
|
//#region src/sandbox/public/shell.ts
|
|
39
42
|
var shell_exports = /* @__PURE__ */ __exportAll({
|
|
40
|
-
Shell: () => Shell,
|
|
43
|
+
Shell: () => Shell$1,
|
|
41
44
|
ShellError: () => ShellError,
|
|
42
45
|
fromExec: () => fromExec,
|
|
43
46
|
quote: () => quote,
|
package/sandbox.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandbox.mjs","names":[],"sources":["../../src/sandbox/public/driver.ts","../../src/sandbox/public/io.ts","../../src/sandbox/provider.ts","../../src/sandbox/public/shell.ts"],"sourcesContent":["export { AbsolutePath, apiVersion, driver, module, Name, RuntimeConfigBase } from \"../driver.ts\";\nexport type {\n\tApiVersion,\n\tCapabilities,\n\tDefinition,\n\tDriver,\n\tModule,\n\tModuleDefinition,\n\tObserved,\n\tProvisioned,\n\tRegistration,\n\tRuntimeConfigBase as RuntimeConfig,\n\tRuntimeInput,\n} from \"../driver.ts\";\n\nexport * as SandboxDriver from \"./driver.ts\";\n","export { Current, FileSystem, Shell } from \"../io.ts\";\nexport type { Identity, Layer, Provides } from \"../io.ts\";\n\nexport * as SandboxIO from \"./io.ts\";\n","export {\n\tmakeRedactor,\n\tproviderError,\n\tproviderErrorCause,\n\tproviderErrorIsNotFound,\n\tSandboxProviderError,\n\tsanitizeError,\n} from \"./errors.ts\";\nexport type { Redactor } from \"./errors.ts\";\n","export { fromExec, quote, quoteArgv, Shell, ShellError } from \"../shell.ts\";\nexport type { ExecChunk, ExecResult, ISandboxExe, ShellOptions } from \"../shell.ts\";\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"sandbox.mjs","names":[],"sources":["../../src/sandbox/public/driver.ts","../../src/sandbox/public/io.ts","../../src/sandbox/provider.ts","../../src/sandbox/public/shell.ts"],"sourcesContent":["export { AbsolutePath, apiVersion, driver, module, Name, RuntimeConfigBase } from \"../driver.ts\";\nexport type {\n\tApiVersion,\n\tCapabilities,\n\tDefinition,\n\tDriver,\n\tModule,\n\tModuleDefinition,\n\tObserved,\n\tProvisioned,\n\tRegistration,\n\tRuntimeConfigBase as RuntimeConfig,\n\tRuntimeInput,\n} from \"../driver.ts\";\n\nexport * as SandboxDriver from \"./driver.ts\";\n","export { Current, DEFAULT_SPILL_PATH, FileSystem, Mutation, Shell, withMutation } from \"../io.ts\";\nexport type { Identity, Layer, Provides } from \"../io.ts\";\n\nexport * as SandboxIO from \"./io.ts\";\n","export {\n\tmakeRedactor,\n\tproviderError,\n\tproviderErrorCause,\n\tproviderErrorIsNotFound,\n\tSandboxProviderError,\n\tsanitizeError,\n} from \"./errors.ts\";\nexport type { Redactor } from \"./errors.ts\";\n","export { fromExec, quote, quoteArgv, Shell, ShellError } from \"../shell.ts\";\nexport type { ExecChunk, ExecResult, ISandboxExe, ShellOptions } from \"../shell.ts\";\n"],"mappings":""}
|