@codeworksh/plugin 0.0.1-canary.10.1.g65d5c167
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/LICENSE +21 -0
- package/README.md +111 -0
- package/error-ClDISWlT.d.mts +11 -0
- package/event-9PbbjnHJ.d.mts +895 -0
- package/event.d.mts +2 -0
- package/event.mjs +125 -0
- package/event.mjs.map +1 -0
- package/filesystem-Cp-KapCE.d.mts +142 -0
- package/ids-CHjmAdTc.d.mts +43 -0
- package/ids.d.mts +2 -0
- package/ids.mjs +48 -0
- package/ids.mjs.map +1 -0
- package/index.d.mts +3 -0
- package/index.mjs +3 -0
- package/io-BYs7hbiY.d.mts +497 -0
- package/location-D4hAfuXF.d.mts +61 -0
- package/location.d.mts +2 -0
- package/location.mjs +48 -0
- package/location.mjs.map +1 -0
- package/package.json +169 -0
- package/plugin/prompt.d.mts +2 -0
- package/plugin/prompt.mjs +7 -0
- package/plugin/prompt.mjs.map +1 -0
- package/plugin/tool.d.mts +2 -0
- package/plugin/tool.mjs +29 -0
- package/plugin/tool.mjs.map +1 -0
- package/plugin-DHCdfzdO.d.mts +140 -0
- package/plugin-lorpq7Oi.mjs +41 -0
- package/plugin-lorpq7Oi.mjs.map +1 -0
- package/plugin.d.mts +4 -0
- package/plugin.mjs +4 -0
- package/posix.d.mts +6 -0
- package/posix.mjs +8 -0
- package/posix.mjs.map +1 -0
- package/project-CLGsIFD-.d.mts +21 -0
- package/project.d.mts +2 -0
- package/project.mjs +22 -0
- package/project.mjs.map +1 -0
- package/prompt-BcpagjGh.d.mts +10 -0
- package/repo.d.mts +42 -0
- package/repo.mjs +46 -0
- package/repo.mjs.map +1 -0
- package/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/sandbox/driver.d.mts +2 -0
- package/sandbox/driver.mjs +63 -0
- package/sandbox/driver.mjs.map +1 -0
- package/sandbox/errors.d.mts +2 -0
- package/sandbox/errors.mjs +160 -0
- package/sandbox/errors.mjs.map +1 -0
- package/sandbox/filesystem.d.mts +2 -0
- package/sandbox/filesystem.mjs +142 -0
- package/sandbox/filesystem.mjs.map +1 -0
- package/sandbox/instance.d.mts +2 -0
- package/sandbox/instance.mjs +144 -0
- package/sandbox/instance.mjs.map +1 -0
- package/sandbox/io.d.mts +2 -0
- package/sandbox/io.mjs +127 -0
- package/sandbox/io.mjs.map +1 -0
- package/sandbox/resource.d.mts +28 -0
- package/sandbox/resource.mjs +29 -0
- package/sandbox/resource.mjs.map +1 -0
- package/sandbox/shell.d.mts +2 -0
- package/sandbox/shell.mjs +93 -0
- package/sandbox/shell.mjs.map +1 -0
- package/sandbox.d.mts +19 -0
- package/sandbox.mjs +49 -0
- package/sandbox.mjs.map +1 -0
- package/schema.d.mts +93 -0
- package/schema.mjs +107 -0
- package/schema.mjs.map +1 -0
- package/settings-C6RxGd-M.d.mts +557 -0
- package/settings.d.mts +2 -0
- package/settings.mjs +132 -0
- package/settings.mjs.map +1 -0
- package/shell-CZ6Y4lNU.d.mts +109 -0
- package/space-CR-9UxdT.d.mts +25 -0
- package/space.d.mts +2 -0
- package/space.mjs +33 -0
- package/space.mjs.map +1 -0
- package/tool/error.d.mts +2 -0
- package/tool/error.mjs +11 -0
- package/tool/error.mjs.map +1 -0
- package/tool/progress.d.mts +2 -0
- package/tool/progress.mjs +11 -0
- package/tool/progress.mjs.map +1 -0
- package/tool-BoVqkYvL.d.mts +287 -0
- package/tool-DuYBgiJf.d.mts +142 -0
- package/tool.d.mts +2 -0
- package/tool.mjs +71 -0
- package/tool.mjs.map +1 -0
package/settings.mjs
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { isAikitModelInfo, validateAikitModelInfo } from "./schema.mjs";
|
|
2
|
+
import { Model as Model$1 } from "@codeworksh/aikit";
|
|
3
|
+
import { Effect, Schema, SchemaGetter, SchemaIssue } from "effect";
|
|
4
|
+
//#region src/settings.ts
|
|
5
|
+
const ThinkingLevel = Schema.Literals(Object.values(Model$1.ThinkingLevelEnum));
|
|
6
|
+
const ToolExecution = Schema.Literals(["sequential", "parallel"]);
|
|
7
|
+
const Budgets = Schema.Record(Schema.Literals(Object.values(Model$1.ThinkingLevelEnum).filter((level) => level !== "off")), Schema.optional(Schema.Finite));
|
|
8
|
+
/** Aikit does not export its request schema; keep this routing surface checked against its public types. */
|
|
9
|
+
const requestFields = {
|
|
10
|
+
temperature: Schema.optional(Schema.Finite),
|
|
11
|
+
maxTokens: Schema.optional(Schema.Finite),
|
|
12
|
+
cacheRetention: Schema.optional(Schema.Literals([
|
|
13
|
+
"none",
|
|
14
|
+
"short",
|
|
15
|
+
"long"
|
|
16
|
+
])),
|
|
17
|
+
headers: Schema.optional(Schema.Record(Schema.String, Schema.String)),
|
|
18
|
+
timeoutMs: Schema.optional(Schema.Finite),
|
|
19
|
+
maxRetries: Schema.optional(Schema.Finite),
|
|
20
|
+
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
|
|
21
|
+
thinkingBudgets: Schema.optional(Budgets),
|
|
22
|
+
baseURL: Schema.optional(Schema.String),
|
|
23
|
+
method: Schema.optional(Schema.Literals(Object.values(Model$1.APIMethodEnum)))
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* An API key named, never written: `"${NAME}"`, read from the host process environment when the
|
|
27
|
+
* model is called. Settings only ever hold the variable's name.
|
|
28
|
+
*/
|
|
29
|
+
const keyReference = /^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/;
|
|
30
|
+
const keyReferenceError = "apiKey must reference an environment variable, e.g. \"${OPENAI_API_KEY}\"";
|
|
31
|
+
const KeyReference = Schema.String.check(Schema.makeFilter((value) => keyReference.test(value) || keyReferenceError));
|
|
32
|
+
/** The variable a `"${NAME}"` reference names. */
|
|
33
|
+
const keyName = (reference) => keyReference.exec(reference)?.[1] ?? reference;
|
|
34
|
+
const reserved = /* @__PURE__ */ new Set([
|
|
35
|
+
"toolChoice",
|
|
36
|
+
"activeTools",
|
|
37
|
+
"provider",
|
|
38
|
+
"id",
|
|
39
|
+
"signal",
|
|
40
|
+
"sessionId",
|
|
41
|
+
"reasoning",
|
|
42
|
+
"modelId",
|
|
43
|
+
"onPayload",
|
|
44
|
+
"api",
|
|
45
|
+
"npm",
|
|
46
|
+
"providerOptionsKey",
|
|
47
|
+
"compat",
|
|
48
|
+
"thinkingLevelMap"
|
|
49
|
+
]);
|
|
50
|
+
/** The wire protocol a model speaks, which a catalog entry may have wrong for a local endpoint. */
|
|
51
|
+
const ModelProtocol = Schema.Literals(Object.values(Model$1.KnownProviderEnum));
|
|
52
|
+
const Block = Schema.StructWithRest(Schema.Struct({
|
|
53
|
+
...requestFields,
|
|
54
|
+
protocol: Schema.optional(ModelProtocol),
|
|
55
|
+
thinkingLevel: Schema.optional(ThinkingLevel),
|
|
56
|
+
toolExecution: Schema.optional(ToolExecution),
|
|
57
|
+
contextWindow: Schema.optional(Schema.Finite),
|
|
58
|
+
/** Which environment variable holds the key for this model: `"${NAME}"`. */
|
|
59
|
+
apiKey: Schema.optional(KeyReference),
|
|
60
|
+
extras: Schema.optional(Schema.Record(Schema.String, Schema.Unknown))
|
|
61
|
+
}), [Schema.Record(Schema.String, Schema.Unknown)]).check(Schema.makeFilter((value) => Object.keys(value).every((key) => !reserved.has(key)) || "Reserved configuration key in model options"));
|
|
62
|
+
const Model = Schema.Struct({
|
|
63
|
+
provider: Schema.optional(Schema.String),
|
|
64
|
+
id: Schema.optional(Schema.String),
|
|
65
|
+
thinkingLevel: Schema.optional(ThinkingLevel),
|
|
66
|
+
toolExecution: Schema.optional(ToolExecution),
|
|
67
|
+
thinkingBudgets: Schema.optional(Budgets),
|
|
68
|
+
options: Schema.optional(Block),
|
|
69
|
+
providerOptions: Schema.optional(Schema.Record(Schema.String, Schema.Record(Schema.String, Block)))
|
|
70
|
+
});
|
|
71
|
+
const reasonOf = (cause) => cause instanceof Error ? cause.message : String(cause);
|
|
72
|
+
const decodeModelEntry = (value, options) => Effect.try({
|
|
73
|
+
try: () => {
|
|
74
|
+
const entry = validateAikitModelInfo(value, "models entry");
|
|
75
|
+
if (entry.provider.key !== void 0 && !keyReference.test(entry.provider.key)) throw new Error(`models entry ${entry.provider.id}/${entry.id}: provider.key: ${keyReferenceError}`);
|
|
76
|
+
return entry;
|
|
77
|
+
},
|
|
78
|
+
catch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options)
|
|
79
|
+
});
|
|
80
|
+
/**
|
|
81
|
+
* A catalog entry in settings: an aikit `Model.Info`, read exactly like an entry of the generated
|
|
82
|
+
* catalog. The one difference is `provider.key`, which must be a `"${NAME}"` reference.
|
|
83
|
+
*/
|
|
84
|
+
const ModelEntry = Schema.Unknown.pipe(Schema.decodeTo(Schema.declare(isAikitModelInfo, { expected: "aikit Model.Info" }), {
|
|
85
|
+
decode: SchemaGetter.transformEffect(decodeModelEntry),
|
|
86
|
+
encode: SchemaGetter.transformEffect(decodeModelEntry)
|
|
87
|
+
}));
|
|
88
|
+
/** A module to load: a path, a `file:` URL, or a package spec. */
|
|
89
|
+
const PluginReference = Schema.String.check(Schema.isNonEmpty());
|
|
90
|
+
/**
|
|
91
|
+
* Configuration for a plugin something else already selected, named by its ID (`plugin`) or by
|
|
92
|
+
* its registered module string (`package`). It never loads anything: an entry naming a plugin
|
|
93
|
+
* that is not in the selection is ignored.
|
|
94
|
+
*/
|
|
95
|
+
const config = {
|
|
96
|
+
enabled: Schema.optional(Schema.Boolean),
|
|
97
|
+
options: Schema.optional(Schema.Record(Schema.String, Schema.Unknown))
|
|
98
|
+
};
|
|
99
|
+
const PluginPatch = Schema.Union([Schema.Struct({
|
|
100
|
+
plugin: PluginReference,
|
|
101
|
+
...config
|
|
102
|
+
}), Schema.Struct({
|
|
103
|
+
package: PluginReference,
|
|
104
|
+
...config
|
|
105
|
+
})], { mode: "oneOf" });
|
|
106
|
+
const PluginEntry = Schema.Union([PluginReference, PluginPatch]);
|
|
107
|
+
const Patch = Schema.Struct({
|
|
108
|
+
$schema: Schema.optional(Schema.String),
|
|
109
|
+
plugins: Schema.optional(Schema.Array(PluginEntry)),
|
|
110
|
+
model: Schema.optional(Model),
|
|
111
|
+
models: Schema.optional(Schema.Array(ModelEntry))
|
|
112
|
+
});
|
|
113
|
+
/** Let aikit supply model-aware generation defaults. */
|
|
114
|
+
const defaults = {
|
|
115
|
+
plugins: [],
|
|
116
|
+
declared: [],
|
|
117
|
+
models: [],
|
|
118
|
+
model: {
|
|
119
|
+
provider: "openai",
|
|
120
|
+
id: "gpt-5.6-luna",
|
|
121
|
+
thinkingLevel: "high",
|
|
122
|
+
toolExecution: "sequential",
|
|
123
|
+
options: {
|
|
124
|
+
timeoutMs: 36e5,
|
|
125
|
+
maxRetries: 3
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
//#endregion
|
|
130
|
+
export { Block, KeyReference, Model, ModelEntry, ModelProtocol, Patch, PluginEntry, PluginPatch, ThinkingLevel, ToolExecution, defaults, keyName, requestFields };
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=settings.mjs.map
|
package/settings.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.mjs","names":["AikitModel"],"sources":["../../src/settings.ts"],"sourcesContent":["import { Model as AikitModel, type Protocol } from \"@codeworksh/aikit\";\nimport { Effect, Schema, type SchemaAST, SchemaGetter, SchemaIssue } from \"effect\";\nimport { isAikitModelInfo, validateAikitModelInfo } from \"./schema.ts\";\n\nexport const ThinkingLevel = Schema.Literals(Object.values(AikitModel.ThinkingLevelEnum));\nexport const ToolExecution = Schema.Literals([\"sequential\", \"parallel\"]);\nexport type ToolExecution = typeof ToolExecution.Type;\nconst Budgets = Schema.Record(\n\tSchema.Literals(Object.values(AikitModel.ThinkingLevelEnum).filter((level) => level !== \"off\")),\n\tSchema.optional(Schema.Finite),\n);\n\n/** Aikit does not export its request schema; keep this routing surface checked against its public types. */\nexport const requestFields = {\n\ttemperature: Schema.optional(Schema.Finite),\n\tmaxTokens: Schema.optional(Schema.Finite),\n\tcacheRetention: Schema.optional(Schema.Literals([\"none\", \"short\", \"long\"])),\n\theaders: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n\ttimeoutMs: Schema.optional(Schema.Finite),\n\tmaxRetries: Schema.optional(Schema.Finite),\n\tmetadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n\tthinkingBudgets: Schema.optional(Budgets),\n\tbaseURL: Schema.optional(Schema.String),\n\tmethod: Schema.optional(Schema.Literals(Object.values(AikitModel.APIMethodEnum))),\n} satisfies Record<\n\t| Exclude<keyof Protocol.CommonOptions, \"signal\" | \"sessionId\" | \"reasoning\" | \"apiKey\" | \"onPayload\">\n\t| \"baseURL\"\n\t| \"method\",\n\tSchema.Top\n>;\n\n/**\n * An API key named, never written: `\"${NAME}\"`, read from the host process environment when the\n * model is called. Settings only ever hold the variable's name.\n */\nconst keyReference = /^\\$\\{([A-Za-z_][A-Za-z0-9_]*)\\}$/;\nconst keyReferenceError = 'apiKey must reference an environment variable, e.g. \"${OPENAI_API_KEY}\"';\nexport const KeyReference = Schema.String.check(\n\tSchema.makeFilter((value) => keyReference.test(value) || keyReferenceError),\n);\n\n/** The variable a `\"${NAME}\"` reference names. */\nexport const keyName = (reference: string): string => keyReference.exec(reference)?.[1] ?? reference;\n\nconst reserved = new Set([\n\t\"toolChoice\",\n\t\"activeTools\",\n\t\"provider\",\n\t\"id\",\n\t\"signal\",\n\t\"sessionId\",\n\t\"reasoning\",\n\t\"modelId\",\n\t\"onPayload\",\n\t\"api\",\n\t\"npm\",\n\t\"providerOptionsKey\",\n\t\"compat\",\n\t\"thinkingLevelMap\",\n]);\n\n/** The wire protocol a model speaks, which a catalog entry may have wrong for a local endpoint. */\nexport const ModelProtocol = Schema.Literals(Object.values(AikitModel.KnownProviderEnum));\n\nexport const Block = Schema.StructWithRest(\n\tSchema.Struct({\n\t\t...requestFields,\n\t\tprotocol: Schema.optional(ModelProtocol),\n\t\tthinkingLevel: Schema.optional(ThinkingLevel),\n\t\ttoolExecution: Schema.optional(ToolExecution),\n\t\tcontextWindow: Schema.optional(Schema.Finite),\n\t\t/** Which environment variable holds the key for this model: `\"${NAME}\"`. */\n\t\tapiKey: Schema.optional(KeyReference),\n\t\textras: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n\t}),\n\t[Schema.Record(Schema.String, Schema.Unknown)],\n).check(\n\tSchema.makeFilter(\n\t\t(value) => Object.keys(value).every((key) => !reserved.has(key)) || \"Reserved configuration key in model options\",\n\t),\n);\nexport type Block = typeof Block.Type;\n\nexport const Model = Schema.Struct({\n\tprovider: Schema.optional(Schema.String),\n\tid: Schema.optional(Schema.String),\n\tthinkingLevel: Schema.optional(ThinkingLevel),\n\ttoolExecution: Schema.optional(ToolExecution),\n\tthinkingBudgets: Schema.optional(Budgets),\n\toptions: Schema.optional(Block),\n\tproviderOptions: Schema.optional(Schema.Record(Schema.String, Schema.Record(Schema.String, Block))),\n});\nconst reasonOf = (cause: unknown): string => (cause instanceof Error ? cause.message : String(cause));\n\nconst decodeModelEntry = (value: unknown, options: SchemaAST.ParseOptions) =>\n\tEffect.try({\n\t\ttry: () => {\n\t\t\tconst entry = validateAikitModelInfo(value, \"models entry\");\n\t\t\tif (entry.provider.key !== undefined && !keyReference.test(entry.provider.key)) {\n\t\t\t\tthrow new Error(`models entry ${entry.provider.id}/${entry.id}: provider.key: ${keyReferenceError}`);\n\t\t\t}\n\t\t\treturn entry;\n\t\t},\n\t\tcatch: (cause) => new SchemaIssue.InvalidValue({ message: reasonOf(cause) }, value, options),\n\t});\n\n/**\n * A catalog entry in settings: an aikit `Model.Info`, read exactly like an entry of the generated\n * catalog. The one difference is `provider.key`, which must be a `\"${NAME}\"` reference.\n */\nexport const ModelEntry = Schema.Unknown.pipe(\n\tSchema.decodeTo(Schema.declare<AikitModel.Info>(isAikitModelInfo, { expected: \"aikit Model.Info\" }), {\n\t\tdecode: SchemaGetter.transformEffect(decodeModelEntry),\n\t\tencode: SchemaGetter.transformEffect(decodeModelEntry),\n\t}),\n);\nexport type ModelEntry = typeof ModelEntry.Type;\n\n/** A module to load: a path, a `file:` URL, or a package spec. */\nconst PluginReference = Schema.String.check(Schema.isNonEmpty());\n/**\n * Configuration for a plugin something else already selected, named by its ID (`plugin`) or by\n * its registered module string (`package`). It never loads anything: an entry naming a plugin\n * that is not in the selection is ignored.\n */\nconst config = {\n\tenabled: Schema.optional(Schema.Boolean),\n\toptions: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),\n};\nexport const PluginPatch = Schema.Union(\n\t[Schema.Struct({ plugin: PluginReference, ...config }), Schema.Struct({ package: PluginReference, ...config })],\n\t// `oneOf`, so an entry carrying both keys is a decode failure rather than one of them being\n\t// quietly dropped -- naming a plugin two ways at once says two different things.\n\t{ mode: \"oneOf\" },\n);\nexport const PluginEntry = Schema.Union([PluginReference, PluginPatch]);\nexport type PluginEntry = typeof PluginEntry.Type;\n\nexport const Patch = Schema.Struct({\n\t$schema: Schema.optional(Schema.String),\n\tplugins: Schema.optional(Schema.Array(PluginEntry)),\n\tmodel: Schema.optional(Model),\n\tmodels: Schema.optional(Schema.Array(ModelEntry)),\n});\nexport type Patch = typeof Patch.Type;\n\n/**\n * One plugin entry, and where it came from.\n *\n * Flattening every layer's `plugins` into one array loses the file that declared each entry, and\n * that cannot be recovered afterwards: two layers may declare the same string, so attribution is\n * genuinely gone rather than merely inconvenient. Three things need it -- anchoring a relative\n * path, naming the declaring layer in `plugin list`, and the missing-plugin diagnostic -- so the\n * loaded shape carries it from the start.\n *\n * In simple terms:\n * `written` - is what module the developer is declaring - what\n * `file` - where the module is being declared - where\n * `entry` - the resolved path of the module, relative to the `file`; especially needed for local.\n *\n * Example:\n * written: \"@acme/x@^1\"\n * entry: \"@acme/x@^1\"\n * file: \"/Users/me/.codework/settings.jsonc\"\n *\n * written: \"./plugins/mine.mjs\"\n * entry: \"/Users/me/.codework/plugins/mine.mjs\"\n * file: \"/Users/me/.codework/settings.jsonc\"\n */\nexport interface Declared {\n\t/** The entry exactly as the file spells it, which is the string a person will search for. */\n\treadonly written: PluginEntry;\n\t/** The same entry with any relative path anchored to the directory of its declaring file. */\n\treadonly entry: PluginEntry;\n\t/** The settings file that declared it. */\n\treadonly file: string;\n}\n\n/** A `models` entry, and the settings file that declared it. */\nexport interface DeclaredModel {\n\treadonly entry: AikitModel.Info;\n\treadonly file: string;\n}\n\nexport interface Info {\n\t/**\n\t * Plugin entries added to the harness selection, in order: every layer's entries, lowest\n\t * priority first, so a project's list extends the user's rather than replacing it.\n\t *\n\t * Anchored, and stripped of provenance: this is the list the loader consumes. {@link Info.declared}\n\t * is the same list with the file each entry came from.\n\t */\n\treadonly plugins: ReadonlyArray<PluginEntry>;\n\t/** {@link Info.plugins}, with the origin of each entry. Same order, same length. */\n\treadonly declared: ReadonlyArray<Declared>;\n\t/**\n\t * Catalog entries from every layer, lowest priority first. Applied over the generated catalog\n\t * in this order, so for one `provider.id` + `id` the last entry wins.\n\t */\n\treadonly models: ReadonlyArray<DeclaredModel>;\n\treadonly model: typeof Model.Type & {\n\t\treadonly provider: string;\n\t\treadonly id: string;\n\t\treadonly thinkingLevel: AikitModel.ThinkingLevel;\n\t\treadonly toolExecution: ToolExecution;\n\t};\n}\n\n/** Let aikit supply model-aware generation defaults. */\nexport const defaults: Info = {\n\tplugins: [],\n\tdeclared: [],\n\tmodels: [],\n\tmodel: {\n\t\tprovider: \"openai\",\n\t\tid: \"gpt-5.6-luna\",\n\t\tthinkingLevel: \"high\",\n\t\ttoolExecution: \"sequential\",\n\t\toptions: { timeoutMs: 3_600_000, maxRetries: 3 },\n\t},\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Context, Effect, Schema, Stream } from "effect";
|
|
2
|
+
//#region src/sandbox/shell.d.ts
|
|
3
|
+
declare const ShellError_base: Schema.Class<ShellError, Schema.TaggedStruct<"ShellError", {
|
|
4
|
+
readonly command: Schema.String;
|
|
5
|
+
readonly cause: Schema.optional<Schema.Defect>;
|
|
6
|
+
}>, import("effect/Cause").YieldableError>;
|
|
7
|
+
/**
|
|
8
|
+
* The pluggable execution contract. Local sandboxes usually get a Shell through
|
|
9
|
+
* just-bash over the local `Local.Vfs`; remote sandboxes provide their own
|
|
10
|
+
* native Shell. Either way the rest of the harness depends only on this service
|
|
11
|
+
* tag.
|
|
12
|
+
*/
|
|
13
|
+
declare class ShellError extends ShellError_base {}
|
|
14
|
+
interface ExecResult {
|
|
15
|
+
readonly stdout: string;
|
|
16
|
+
readonly stderr: string;
|
|
17
|
+
readonly exitCode: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* One options shape for every entry point. `cwd` is the operation-level
|
|
21
|
+
* override: it wins over the mount's working directory, and a relative value
|
|
22
|
+
* resolves against it. Neither mutates shared state, so concurrent commands in
|
|
23
|
+
* one mount can run in different directories.
|
|
24
|
+
*/
|
|
25
|
+
interface ShellOptions {
|
|
26
|
+
readonly env?: Record<string, string>;
|
|
27
|
+
readonly cwd?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A streamed chunk of command output, terminated by a single `exit` carrying the
|
|
31
|
+
* exit code. (A backend-level mirror of the tool layer's event; kept here so
|
|
32
|
+
* `sandbox/` does not depend on `tool/`.)
|
|
33
|
+
*/
|
|
34
|
+
type ExecChunk = {
|
|
35
|
+
readonly _tag: "stdout";
|
|
36
|
+
readonly bytes: Uint8Array;
|
|
37
|
+
} | {
|
|
38
|
+
readonly _tag: "stderr";
|
|
39
|
+
readonly bytes: Uint8Array;
|
|
40
|
+
} | {
|
|
41
|
+
readonly _tag: "exit";
|
|
42
|
+
readonly exitCode: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The command-execution capability a sandbox exposes. For an in-process
|
|
46
|
+
* backend this is just-bash; for a remote backend it is the sandbox's own
|
|
47
|
+
* shell. The {@link Shell} service tag carries this interface.
|
|
48
|
+
*/
|
|
49
|
+
interface ISandboxExe {
|
|
50
|
+
readonly exec: (command: string, options?: ShellOptions) => Effect.Effect<ExecResult, ShellError>;
|
|
51
|
+
/**
|
|
52
|
+
* Run a program with an explicit argument vector, bypassing shell word
|
|
53
|
+
* splitting. Callers that build commands from untrusted values — branch
|
|
54
|
+
* names, file paths — must use this instead of interpolating into
|
|
55
|
+
* {@link exec}, where a space or `$(…)` would change what runs.
|
|
56
|
+
*
|
|
57
|
+
* Backends whose transport only accepts a string quote the vector with
|
|
58
|
+
* {@link quote}; backends that spawn directly pass it through untouched.
|
|
59
|
+
*/
|
|
60
|
+
readonly execArgv: (argv: ReadonlyArray<string>, options?: ShellOptions) => Effect.Effect<ExecResult, ShellError>;
|
|
61
|
+
/**
|
|
62
|
+
* Optional streaming output: stdout/stderr chunks then a terminal `exit`.
|
|
63
|
+
* Backends that can stream (e.g. Vercel) implement it; `ToolShell.fromSandboxShell`
|
|
64
|
+
* bridges it to `ToolShell.stream` so the bash tool streams over them too.
|
|
65
|
+
*/
|
|
66
|
+
readonly stream?: (command: string, options?: ShellOptions) => Stream.Stream<ExecChunk, ShellError>;
|
|
67
|
+
}
|
|
68
|
+
type MountFactory = (cwd: string) => ISandboxExe;
|
|
69
|
+
declare const perMount: (transport: ISandboxExe, make: MountFactory) => ISandboxExe;
|
|
70
|
+
/**
|
|
71
|
+
* POSIX single-quote escaping: wrap in `'…'` and rewrite each embedded quote as
|
|
72
|
+
* `'\''`. Everything inside single quotes is literal to the shell, so this is
|
|
73
|
+
* safe for arbitrary bytes.
|
|
74
|
+
*/
|
|
75
|
+
declare const quote: (value: string) => string;
|
|
76
|
+
/** Render an argument vector as one shell-safe command string. */
|
|
77
|
+
declare const quoteArgv: (argv: ReadonlyArray<string>) => string;
|
|
78
|
+
/**
|
|
79
|
+
* Resolve a per-command cwd against the sandbox cwd. Passing a relative cwd
|
|
80
|
+
* straight to a host or remote process API would otherwise resolve it against
|
|
81
|
+
* that API's own default, which need not be the filesystem's configured cwd.
|
|
82
|
+
*/
|
|
83
|
+
declare const resolveCwd: (base: string | undefined, cwd: string | undefined) => string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Complete a string-only backend: `execArgv` quotes the vector and runs it
|
|
86
|
+
* through `exec`. Backends that spawn a real argument vector (Vercel) implement
|
|
87
|
+
* `execArgv` themselves instead, so the args never meet a shell parser at all.
|
|
88
|
+
*
|
|
89
|
+
* `cwd` rides the options rather than a `cd <dir> && …` prefix. Every backend
|
|
90
|
+
* we wrap takes a working directory natively, and the prefix form cannot tell a
|
|
91
|
+
* failed `cd` from a failed command — both arrive as one exit code.
|
|
92
|
+
*/
|
|
93
|
+
declare const fromExec: (backend: Omit<ISandboxExe, "execArgv">) => ISandboxExe;
|
|
94
|
+
/**
|
|
95
|
+
* Bind a cwd-neutral backend to one mount's working directory.
|
|
96
|
+
*
|
|
97
|
+
* The transport is shared between mounts and must stay rooted at the namespace
|
|
98
|
+
* root, so the directory cannot live inside it: two mounts at different
|
|
99
|
+
* directories would otherwise see each other's. This wrapper is per mount, and
|
|
100
|
+
* an operation-level `cwd` still wins — resolved against the mount's, so a
|
|
101
|
+
* relative one means what it reads like.
|
|
102
|
+
*/
|
|
103
|
+
declare const withCwd: (backend: ISandboxExe, cwd: string) => ISandboxExe;
|
|
104
|
+
declare const Shell_base: Context.ServiceClass<Shell, "@codeworksh/plugin/sandbox/shell", ISandboxExe>;
|
|
105
|
+
/** Execution service — the live {@link ISandboxExe} for the active sandbox. */
|
|
106
|
+
declare class Shell extends Shell_base {}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { ShellError as a, perMount as c, resolveCwd as d, withCwd as f, Shell as i, quote as l, ExecResult as n, ShellOptions as o, ISandboxExe as r, fromExec as s, ExecChunk as t, quoteArgv as u };
|
|
109
|
+
//# sourceMappingURL=shell-CZ6Y4lNU.d.mts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
declare namespace space_d_exports {
|
|
3
|
+
export { ID, Info, Kind, space_d_exports as SpaceSchema, Status };
|
|
4
|
+
}
|
|
5
|
+
declare const ID: Schema.brand<Schema.String, "Space.ID">;
|
|
6
|
+
type ID = typeof ID.Type;
|
|
7
|
+
declare const Kind: Schema.Literals<readonly ["primary", "linked", "copy", "plain"]>;
|
|
8
|
+
type Kind = typeof Kind.Type;
|
|
9
|
+
declare const Status: Schema.Literals<readonly ["active", "archived"]>;
|
|
10
|
+
type Status = typeof Status.Type;
|
|
11
|
+
declare const Info_base: Schema.Class<Info, Schema.Struct<{
|
|
12
|
+
readonly id: Schema.brand<Schema.String, "Space.ID">;
|
|
13
|
+
readonly projectId: Schema.brand<Schema.String, "Project.ID">;
|
|
14
|
+
readonly location: Schema.brand<Schema.String, "AbsolutePath">;
|
|
15
|
+
readonly kind: Schema.Literals<readonly ["primary", "linked", "copy", "plain"]>;
|
|
16
|
+
readonly env: Schema.brand<Schema.String, "SandboxInstance.ID"> & {
|
|
17
|
+
local: string & import("effect/Brand").Brand<"SandboxInstance.ID">;
|
|
18
|
+
create: () => string & import("effect/Brand").Brand<"SandboxInstance.ID">;
|
|
19
|
+
};
|
|
20
|
+
readonly status: Schema.Literals<readonly ["active", "archived"]>;
|
|
21
|
+
}>, {}>;
|
|
22
|
+
declare class Info extends Info_base {}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { space_d_exports as a, Status as i, Info as n, Kind as r, ID as t };
|
|
25
|
+
//# sourceMappingURL=space-CR-9UxdT.d.mts.map
|
package/space.d.mts
ADDED
package/space.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { AbsolutePath } from "./schema.mjs";
|
|
3
|
+
import { ID as ID$1 } from "./project.mjs";
|
|
4
|
+
import { ID as ID$2 } from "./sandbox/instance.mjs";
|
|
5
|
+
import { Schema } from "effect";
|
|
6
|
+
//#region src/space.ts
|
|
7
|
+
var space_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
ID: () => ID,
|
|
9
|
+
Info: () => Info,
|
|
10
|
+
Kind: () => Kind,
|
|
11
|
+
SpaceSchema: () => space_exports,
|
|
12
|
+
Status: () => Status
|
|
13
|
+
});
|
|
14
|
+
const ID = Schema.String.pipe(Schema.brand("Space.ID"));
|
|
15
|
+
const Kind = Schema.Literals([
|
|
16
|
+
"primary",
|
|
17
|
+
"linked",
|
|
18
|
+
"copy",
|
|
19
|
+
"plain"
|
|
20
|
+
]);
|
|
21
|
+
const Status = Schema.Literals(["active", "archived"]);
|
|
22
|
+
var Info = class extends Schema.Class("Space.Info")({
|
|
23
|
+
id: ID,
|
|
24
|
+
projectId: ID$1,
|
|
25
|
+
location: AbsolutePath,
|
|
26
|
+
kind: Kind,
|
|
27
|
+
env: ID$2,
|
|
28
|
+
status: Status
|
|
29
|
+
}) {};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { ID, Info, Kind, space_exports as SpaceSchema, Status };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=space.mjs.map
|
package/space.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"space.mjs","names":["ProjectSchema.ID","SandboxInstance.ID"],"sources":["../../src/space.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { ProjectSchema } from \"./project.ts\";\nimport { SandboxInstance } from \"./sandbox/instance.ts\";\nimport { AbsolutePath } from \"./schema.ts\";\n\n// hash(env, location) — no project component, so re-pointing a space to\n// another project never rewrites the key sessions reference.\nexport const ID = Schema.String.pipe(Schema.brand(\"Space.ID\"));\nexport type ID = typeof ID.Type;\n\n// primary: the main checkout (one per project+env); linked: a git worktree\n// sharing the primary's store; copy: another clone; plain: a non-git directory.\nexport const Kind = Schema.Literals([\"primary\", \"linked\", \"copy\", \"plain\"]);\nexport type Kind = typeof Kind.Type;\n\nexport const Status = Schema.Literals([\"active\", \"archived\"]);\nexport type Status = typeof Status.Type;\n\n// One directory in one env that belongs to a project; the unit sessions attach to.\nexport class Info extends Schema.Class<Info>(\"Space.Info\")({\n\tid: ID,\n\tprojectId: ProjectSchema.ID,\n\tlocation: AbsolutePath,\n\tkind: Kind,\n\tenv: SandboxInstance.ID,\n\tstatus: Status,\n}) {}\n\nexport * as SpaceSchema from \"./space.ts\";\n"],"mappings":";;;;;;;;;;;;;AAOA,MAAa,KAAK,OAAO,OAAO,KAAK,OAAO,MAAM,UAAU,CAAC;AAK7D,MAAa,OAAO,OAAO,SAAS;CAAC;CAAW;CAAU;CAAQ;AAAO,CAAC;AAG1E,MAAa,SAAS,OAAO,SAAS,CAAC,UAAU,UAAU,CAAC;AAI5D,IAAa,OAAb,cAA0B,OAAO,MAAY,YAAY,CAAC,CAAC;CAC1D,IAAI;CACJ,WAAWA;CACX,UAAU;CACV,MAAM;CACN,KAAKC;CACL,QAAQ;AACT,CAAC,CAAC,CAAC,CAAC"}
|
package/tool/error.d.mts
ADDED
package/tool/error.mjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
//#region src/tool/error.ts
|
|
3
|
+
/** A typed wrapper for a tool failure crossing the heterogeneous registry boundary. */
|
|
4
|
+
var ToolExecutionError = class extends Schema.TaggedError()("ToolExecutionError", {
|
|
5
|
+
toolName: Schema.String,
|
|
6
|
+
cause: Schema.Defect()
|
|
7
|
+
}) {};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ToolExecutionError };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=error.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.mjs","names":[],"sources":["../../../src/tool/error.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\n/** A typed wrapper for a tool failure crossing the heterogeneous registry boundary. */\nexport class ToolExecutionError extends Schema.TaggedError<ToolExecutionError>()(\"ToolExecutionError\", {\n\ttoolName: Schema.String,\n\tcause: Schema.Defect(),\n}) {}\n"],"mappings":";;;AAGA,IAAa,qBAAb,cAAwC,OAAO,YAAgC,CAAC,CAAC,sBAAsB;CACtG,UAAU,OAAO;CACjB,OAAO,OAAO,OAAO;AACtB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
//#region src/tool/progress.ts
|
|
3
|
+
var ToolProgress = class extends Context.Service()("@codeworksh/plugin/tool/progress/ToolProgress") {};
|
|
4
|
+
/** Build a `ToolProgress` Layer from a `report` implementation. */
|
|
5
|
+
const make = (report) => Layer.succeed(ToolProgress, ToolProgress.of({ report }));
|
|
6
|
+
/** Drops every update — the default until the executor wires a live event sink. */
|
|
7
|
+
const noop = make(() => Effect.void);
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ToolProgress, make, noop };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=progress.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.mjs","names":[],"sources":["../../../src/tool/progress.ts"],"sourcesContent":["import { Context, Effect, Layer } from \"effect\";\nimport type { ModelContent } from \"../tool.ts\";\n\n/**\n * `ToolProgress` — the side-channel a long-running tool (e.g. streaming bash)\n * writes interim output to, instead of an `onUpdate` callback.\n *\n * Most tools never call `report` and keep a clean `Effect<Success, Failure>`\n * signature. Throttling / coalescing lives in the Layer (the live one routes to\n * the run's event PubSub, tagged with the active callID); the handler just\n * reports.\n */\n\n/** Mirror of aikit's `Message.ToolRunningPartial` (kept structural to stay decoupled). */\nexport interface ToolProgressPartial {\n\treadonly content?: ModelContent;\n\treadonly details?: unknown;\n}\n\nexport interface IToolProgress {\n\treadonly report: (partial: ToolProgressPartial) => Effect.Effect<void>;\n}\n\nexport class ToolProgress extends Context.Service<ToolProgress, IToolProgress>()(\n\t\"@codeworksh/plugin/tool/progress/ToolProgress\",\n) {}\n\n/** Build a `ToolProgress` Layer from a `report` implementation. */\nexport const make = (report: IToolProgress[\"report\"]): Layer.Layer<ToolProgress> =>\n\tLayer.succeed(ToolProgress, ToolProgress.of({ report }));\n\n/** Drops every update — the default until the executor wires a live event sink. */\nexport const noop: Layer.Layer<ToolProgress> = make(() => Effect.void);\n"],"mappings":";;AAuBA,IAAa,eAAb,cAAkC,QAAQ,QAAqC,CAAC,CAC/E,+CACD,CAAC,CAAC,CAAC;;AAGH,MAAa,QAAQ,WACpB,MAAM,QAAQ,cAAc,aAAa,GAAG,EAAE,OAAO,CAAC,CAAC;;AAGxD,MAAa,OAAkC,WAAW,OAAO,IAAI"}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { a as RegisteredTool, i as ModelContent, t as AnyToolDef } from "./tool-DuYBgiJf.mjs";
|
|
2
|
+
import { Effect, Schema } from "effect";
|
|
3
|
+
declare namespace tool_d_exports {
|
|
4
|
+
export { HookReturn, ToolAddOptions, ToolAfter, ToolAfterFn, ToolAfterResult, ToolBefore, ToolBeforeFn, ToolBeforeResult, ToolDefPatch, ToolRegistration, ToolRegistry, ToolResultContent };
|
|
5
|
+
}
|
|
6
|
+
declare const ToolBefore: Schema.Struct<{
|
|
7
|
+
readonly callID: Schema.String;
|
|
8
|
+
readonly toolName: Schema.String;
|
|
9
|
+
readonly rawArgs: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
10
|
+
readonly sessionId: Schema.brand<Schema.String, "Session.ID"> & {
|
|
11
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Session.ID">;
|
|
12
|
+
create: () => string & import("effect/Brand").Brand<"Session.ID">;
|
|
13
|
+
};
|
|
14
|
+
readonly messageId: Schema.brand<Schema.String, "Message.ID"> & {
|
|
15
|
+
create: () => string & import("effect/Brand").Brand<"Message.ID">;
|
|
16
|
+
from: (id: string) => string & import("effect/Brand").Brand<"Message.ID">;
|
|
17
|
+
};
|
|
18
|
+
readonly params: Schema.Unknown;
|
|
19
|
+
}>;
|
|
20
|
+
type ToolBefore = typeof ToolBefore.Type;
|
|
21
|
+
declare const ToolAfter: Schema.Struct<{
|
|
22
|
+
readonly callID: Schema.String;
|
|
23
|
+
readonly toolName: Schema.String;
|
|
24
|
+
readonly rawArgs: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
25
|
+
readonly sessionId: Schema.brand<Schema.String, "Session.ID"> & {
|
|
26
|
+
ascending: (id?: string) => string & import("effect/Brand").Brand<"Session.ID">;
|
|
27
|
+
create: () => string & import("effect/Brand").Brand<"Session.ID">;
|
|
28
|
+
};
|
|
29
|
+
readonly messageId: Schema.brand<Schema.String, "Message.ID"> & {
|
|
30
|
+
create: () => string & import("effect/Brand").Brand<"Message.ID">;
|
|
31
|
+
from: (id: string) => string & import("effect/Brand").Brand<"Message.ID">;
|
|
32
|
+
};
|
|
33
|
+
readonly params: Schema.Unknown;
|
|
34
|
+
readonly terminal: Schema.decodeTo<Schema.declare<{
|
|
35
|
+
addedToolNames?: string[];
|
|
36
|
+
arguments: Record<string, any>;
|
|
37
|
+
callID: string;
|
|
38
|
+
name: string;
|
|
39
|
+
namespace?: string;
|
|
40
|
+
result: {
|
|
41
|
+
content: ({
|
|
42
|
+
type: "text";
|
|
43
|
+
text: string;
|
|
44
|
+
textSignature?: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: "image";
|
|
47
|
+
data: string;
|
|
48
|
+
mimeType: string;
|
|
49
|
+
})[];
|
|
50
|
+
details?: any;
|
|
51
|
+
isError: false;
|
|
52
|
+
};
|
|
53
|
+
status: "completed";
|
|
54
|
+
thoughtSignature?: string;
|
|
55
|
+
time: {
|
|
56
|
+
start: number;
|
|
57
|
+
end: number;
|
|
58
|
+
};
|
|
59
|
+
type: "toolCall";
|
|
60
|
+
} | {
|
|
61
|
+
addedToolNames?: string[];
|
|
62
|
+
arguments: Record<string, any>;
|
|
63
|
+
callID: string;
|
|
64
|
+
name: string;
|
|
65
|
+
namespace?: string;
|
|
66
|
+
result: {
|
|
67
|
+
content: ({
|
|
68
|
+
type: "text";
|
|
69
|
+
text: string;
|
|
70
|
+
textSignature?: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "image";
|
|
73
|
+
data: string;
|
|
74
|
+
mimeType: string;
|
|
75
|
+
})[];
|
|
76
|
+
details?: any;
|
|
77
|
+
isError: true;
|
|
78
|
+
};
|
|
79
|
+
status: "error";
|
|
80
|
+
thoughtSignature?: string;
|
|
81
|
+
time: {
|
|
82
|
+
start: number;
|
|
83
|
+
end: number;
|
|
84
|
+
};
|
|
85
|
+
type: "toolCall";
|
|
86
|
+
} | {
|
|
87
|
+
addedToolNames?: string[];
|
|
88
|
+
arguments: Record<string, any>;
|
|
89
|
+
callID: string;
|
|
90
|
+
name: string;
|
|
91
|
+
namespace?: string;
|
|
92
|
+
result: {
|
|
93
|
+
content: ({
|
|
94
|
+
type: "text";
|
|
95
|
+
text: string;
|
|
96
|
+
textSignature?: string;
|
|
97
|
+
} | {
|
|
98
|
+
type: "image";
|
|
99
|
+
data: string;
|
|
100
|
+
mimeType: string;
|
|
101
|
+
})[];
|
|
102
|
+
details?: any;
|
|
103
|
+
isError: true;
|
|
104
|
+
};
|
|
105
|
+
status: "skipped";
|
|
106
|
+
thoughtSignature?: string;
|
|
107
|
+
time: {
|
|
108
|
+
start: number;
|
|
109
|
+
end: number;
|
|
110
|
+
};
|
|
111
|
+
type: "toolCall";
|
|
112
|
+
} | {
|
|
113
|
+
addedToolNames?: string[];
|
|
114
|
+
arguments: Record<string, any>;
|
|
115
|
+
callID: string;
|
|
116
|
+
name: string;
|
|
117
|
+
namespace?: string;
|
|
118
|
+
result: {
|
|
119
|
+
content: ({
|
|
120
|
+
type: "text";
|
|
121
|
+
text: string;
|
|
122
|
+
textSignature?: string;
|
|
123
|
+
} | {
|
|
124
|
+
type: "image";
|
|
125
|
+
data: string;
|
|
126
|
+
mimeType: string;
|
|
127
|
+
})[];
|
|
128
|
+
details?: any;
|
|
129
|
+
isError: true;
|
|
130
|
+
};
|
|
131
|
+
status: "aborted";
|
|
132
|
+
thoughtSignature?: string;
|
|
133
|
+
time: {
|
|
134
|
+
start: number;
|
|
135
|
+
end: number;
|
|
136
|
+
};
|
|
137
|
+
type: "toolCall";
|
|
138
|
+
}, {
|
|
139
|
+
addedToolNames?: string[];
|
|
140
|
+
arguments: Record<string, any>;
|
|
141
|
+
callID: string;
|
|
142
|
+
name: string;
|
|
143
|
+
namespace?: string;
|
|
144
|
+
result: {
|
|
145
|
+
content: ({
|
|
146
|
+
type: "text";
|
|
147
|
+
text: string;
|
|
148
|
+
textSignature?: string;
|
|
149
|
+
} | {
|
|
150
|
+
type: "image";
|
|
151
|
+
data: string;
|
|
152
|
+
mimeType: string;
|
|
153
|
+
})[];
|
|
154
|
+
details?: any;
|
|
155
|
+
isError: false;
|
|
156
|
+
};
|
|
157
|
+
status: "completed";
|
|
158
|
+
thoughtSignature?: string;
|
|
159
|
+
time: {
|
|
160
|
+
start: number;
|
|
161
|
+
end: number;
|
|
162
|
+
};
|
|
163
|
+
type: "toolCall";
|
|
164
|
+
} | {
|
|
165
|
+
addedToolNames?: string[];
|
|
166
|
+
arguments: Record<string, any>;
|
|
167
|
+
callID: string;
|
|
168
|
+
name: string;
|
|
169
|
+
namespace?: string;
|
|
170
|
+
result: {
|
|
171
|
+
content: ({
|
|
172
|
+
type: "text";
|
|
173
|
+
text: string;
|
|
174
|
+
textSignature?: string;
|
|
175
|
+
} | {
|
|
176
|
+
type: "image";
|
|
177
|
+
data: string;
|
|
178
|
+
mimeType: string;
|
|
179
|
+
})[];
|
|
180
|
+
details?: any;
|
|
181
|
+
isError: true;
|
|
182
|
+
};
|
|
183
|
+
status: "error";
|
|
184
|
+
thoughtSignature?: string;
|
|
185
|
+
time: {
|
|
186
|
+
start: number;
|
|
187
|
+
end: number;
|
|
188
|
+
};
|
|
189
|
+
type: "toolCall";
|
|
190
|
+
} | {
|
|
191
|
+
addedToolNames?: string[];
|
|
192
|
+
arguments: Record<string, any>;
|
|
193
|
+
callID: string;
|
|
194
|
+
name: string;
|
|
195
|
+
namespace?: string;
|
|
196
|
+
result: {
|
|
197
|
+
content: ({
|
|
198
|
+
type: "text";
|
|
199
|
+
text: string;
|
|
200
|
+
textSignature?: string;
|
|
201
|
+
} | {
|
|
202
|
+
type: "image";
|
|
203
|
+
data: string;
|
|
204
|
+
mimeType: string;
|
|
205
|
+
})[];
|
|
206
|
+
details?: any;
|
|
207
|
+
isError: true;
|
|
208
|
+
};
|
|
209
|
+
status: "skipped";
|
|
210
|
+
thoughtSignature?: string;
|
|
211
|
+
time: {
|
|
212
|
+
start: number;
|
|
213
|
+
end: number;
|
|
214
|
+
};
|
|
215
|
+
type: "toolCall";
|
|
216
|
+
} | {
|
|
217
|
+
addedToolNames?: string[];
|
|
218
|
+
arguments: Record<string, any>;
|
|
219
|
+
callID: string;
|
|
220
|
+
name: string;
|
|
221
|
+
namespace?: string;
|
|
222
|
+
result: {
|
|
223
|
+
content: ({
|
|
224
|
+
type: "text";
|
|
225
|
+
text: string;
|
|
226
|
+
textSignature?: string;
|
|
227
|
+
} | {
|
|
228
|
+
type: "image";
|
|
229
|
+
data: string;
|
|
230
|
+
mimeType: string;
|
|
231
|
+
})[];
|
|
232
|
+
details?: any;
|
|
233
|
+
isError: true;
|
|
234
|
+
};
|
|
235
|
+
status: "aborted";
|
|
236
|
+
thoughtSignature?: string;
|
|
237
|
+
time: {
|
|
238
|
+
start: number;
|
|
239
|
+
end: number;
|
|
240
|
+
};
|
|
241
|
+
type: "toolCall";
|
|
242
|
+
}>, Schema.Unknown, never, never>;
|
|
243
|
+
}>;
|
|
244
|
+
type ToolAfter = typeof ToolAfter.Type;
|
|
245
|
+
declare const ToolBeforeResult: Schema.Struct<{
|
|
246
|
+
readonly block: Schema.Boolean;
|
|
247
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
248
|
+
}>;
|
|
249
|
+
type ToolBeforeResult = typeof ToolBeforeResult.Type;
|
|
250
|
+
type ToolResultContent = ModelContent;
|
|
251
|
+
interface ToolAfterResult {
|
|
252
|
+
readonly content?: ToolResultContent;
|
|
253
|
+
readonly details?: unknown;
|
|
254
|
+
readonly isError?: boolean;
|
|
255
|
+
}
|
|
256
|
+
type HookReturn<A> = A | void | Promise<A | void> | Effect.Effect<A | void, unknown>;
|
|
257
|
+
type ToolBeforeFn = (call: ToolBefore) => HookReturn<ToolBeforeResult>;
|
|
258
|
+
type ToolAfterFn = (call: ToolAfter) => HookReturn<ToolAfterResult>;
|
|
259
|
+
interface ToolAddOptions {
|
|
260
|
+
readonly beforeToolCall?: ToolBeforeFn;
|
|
261
|
+
readonly afterToolCall?: ToolAfterFn;
|
|
262
|
+
}
|
|
263
|
+
interface ToolDefPatch {
|
|
264
|
+
readonly description?: string;
|
|
265
|
+
readonly label?: string;
|
|
266
|
+
readonly promptSnippet?: string;
|
|
267
|
+
readonly promptGuidelines?: ReadonlyArray<string>;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* One frozen bucket entry: the winning tool for a name together with the hooks that
|
|
271
|
+
* `add` declared alongside it. Kept here rather than in the bucket implementation so
|
|
272
|
+
* the executor shares the contract without importing plugin assembly.
|
|
273
|
+
*/
|
|
274
|
+
interface ToolRegistration {
|
|
275
|
+
readonly tool: RegisteredTool;
|
|
276
|
+
readonly hooks: ToolAddOptions;
|
|
277
|
+
}
|
|
278
|
+
interface ToolRegistry {
|
|
279
|
+
readonly add: (tool: RegisteredTool, options?: ToolAddOptions) => void;
|
|
280
|
+
readonly update: (name: string, patch: ToolDefPatch) => void;
|
|
281
|
+
readonly list: () => ReadonlyArray<AnyToolDef>;
|
|
282
|
+
readonly get: (name: string) => AnyToolDef | undefined;
|
|
283
|
+
readonly has: (name: string) => boolean;
|
|
284
|
+
}
|
|
285
|
+
//#endregion
|
|
286
|
+
export { ToolAfterResult as a, ToolBeforeResult as c, ToolRegistry as d, ToolResultContent as f, ToolAfterFn as i, ToolDefPatch as l, ToolAddOptions as n, ToolBefore as o, tool_d_exports as p, ToolAfter as r, ToolBeforeFn as s, HookReturn as t, ToolRegistration as u };
|
|
287
|
+
//# sourceMappingURL=tool-BoVqkYvL.d.mts.map
|