effect-agent 0.1.0-beta.123 → 0.1.0-beta.124
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.
|
@@ -146,6 +146,7 @@ const renderJsonSchemaType = (schema, defs, depth, indent) => {
|
|
|
146
146
|
return fields.length === 0 ? "{}" : `{\n${fields.join("\n")}\n${indent}}`;
|
|
147
147
|
}
|
|
148
148
|
if (isJsonSchemaRecord(schema.additionalProperties)) return `Record<string, ${renderJsonSchemaType(schema.additionalProperties, defs, depth + 1, indent)}>`;
|
|
149
|
+
if (type === "object" && !("properties" in schema) && !("patternProperties" in schema) && schema.additionalProperties === false) return "Record<string, never>";
|
|
149
150
|
if (type === "object" && !("properties" in schema) && !("additionalProperties" in schema)) return "Record<string, unknown>";
|
|
150
151
|
}
|
|
151
152
|
throw new Error(`Code Mode cannot render the JSON schema fragment ${JSON.stringify(schema).slice(0, 200)}; fix or simplify the Tool's Schema`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeMode.mjs","names":["ToolExecutionClassAnnotation"],"sources":["../../src/capabilities/CodeMode.ts"],"sourcesContent":["import {\n type Layer,\n Cause,\n Context,\n Duration,\n Effect,\n Exit,\n Option,\n Schema,\n type Scope,\n} from \"effect\";\nimport { Tool, Toolkit } from \"effect/unstable/ai\";\n\nimport { utf8ByteLength } from \"../core/internal/utf8.ts\";\nimport { AdditionalToolCatalog, IncludesCatalogDocumentation } from \"../core/ToolExposure.ts\";\nimport {\n type ToolBrokerConfigurationError,\n type ToolBrokerUnavailableError,\n ToolBroker,\n type ProgrammaticCallOutcome,\n type ToolBrokerPass,\n ProgrammaticCallRecord,\n} from \"../engine/ToolBroker.ts\";\nimport { CurrentToolCatalog } from \"../engine/ToolExposure.ts\";\nimport {\n type CodeExecutionError,\n CodeExecutionHost,\n CodeExecutionLimits,\n CodeExecutionNamespace,\n CodeExecutionRequest,\n CodeExecutor,\n JsIdentifier,\n type CodeExecutionResult,\n type CodeHostCall,\n type CodeHostCallResult,\n} from \"../sandbox/CodeExecutor.ts\";\nimport { NetworkDisabled } from \"../sandbox/Sandbox.ts\";\n\n/**\n * Code Mode (D-035, ADR-0017; capability spec §9.1): one native Effect AI\n * Tool whose input is bounded JavaScript source, executed in one isolated\n * `CodeExecutor` pass that may call an explicit construction-time allowlist\n * of existing Tools through typed sandbox globals and the engine-owned\n * `ToolBroker`. The builder follows the Delegation pattern: an explicit\n * record of selected Tools plus namespace mapping fixed at construction,\n * returning an ordinary Tool and a handler Layer, with no ambient registry\n * (CAP-014). Deployment class `E` only.\n */\n\nconst maxFailureTextLength = 4 * 1024;\nconst BoundedFailureText = Schema.String.check(Schema.isMaxLength(maxFailureTextLength));\nconst BoundedErrorTag = Schema.NonEmptyString.check(Schema.isMaxLength(256));\nconst BoundedLogLine = Schema.String.check(Schema.isMaxLength(16 * 1024));\nconst BoundedLogs = Schema.Array(BoundedLogLine).check(Schema.isMaxLength(4_096));\nconst BoundedCode = Schema.NonEmptyString.check(Schema.isMaxLength(512 * 1024));\n\n/** A pass-local report, available to the host even when the caller interrupts execution. */\nexport const CodeModePassReport = Schema.Struct({\n status: Schema.Literals([\"completed\", \"failed\", \"interrupted\", \"defect\"]),\n calls: Schema.Array(ProgrammaticCallRecord),\n});\n\nexport type CodeModePassReport = typeof CodeModePassReport.Type;\n\nconst encodedJsonByteLength = (value: unknown): number | undefined => {\n try {\n const encoded = JSON.stringify(value);\n\n return encoded === undefined ? undefined : utf8ByteLength(encoded);\n } catch {\n return undefined;\n }\n};\n\n/** Model-decoded Code Mode parameters: one async function expression. */\nexport const CodeModeParameters = Schema.Struct({\n code: BoundedCode,\n});\n\n/**\n * The bounded model-visible success: the program's JSON result plus captured\n * logs, both already passed through the aggregate egress budget (CAP-016).\n */\nexport class CodeModeSuccess extends Schema.Class<CodeModeSuccess>(\n \"@effect-agent/capabilities/CodeModeSuccess\",\n)({\n result: Schema.Json,\n logs: BoundedLogs,\n}) {}\n\n/**\n * The bounded model-visible failure envelope. `failureMode: \"return\"` turns\n * it into a failed Tool result, so a model can correct a failing program\n * without a blind retry; it carries the same bounded log capture as success\n * plus the bounded thrown value where one exists, all inside the same\n * aggregate egress budget (CAP-016).\n */\nexport class CodeModeFailure extends Schema.TaggedError<CodeModeFailure>()(\"CodeModeFailure\", {\n errorTag: BoundedErrorTag,\n message: BoundedFailureText,\n logs: BoundedLogs,\n thrown: Schema.optionalKey(Schema.Json),\n /** Invocation-ordered evidence that fits the egress budget. This is not a replay plan. */\n calls: Schema.optionalKey(Schema.Array(ProgrammaticCallRecord)),\n omittedCalls: Schema.optionalKey(Schema.Natural),\n}) {}\n\n/** A selective documentation request is invalid or cannot fit its declared byte budget. */\nexport class CodeModeDescriptionError extends Schema.TaggedError<CodeModeDescriptionError>()(\n \"CodeModeDescriptionError\",\n {\n reason: Schema.Literals([\n \"invalid-selection\",\n \"unknown-method\",\n \"invalid-bound\",\n \"limit-exceeded\",\n ]),\n message: BoundedFailureText,\n },\n) {}\n\nconst DescriptionMethods = Schema.Array(Schema.NonEmptyString.check(Schema.isMaxLength(257))).check(\n Schema.isMinLength(1),\n Schema.isMaxLength(64),\n Schema.isUnique(),\n);\n\nconst DescriptionByteLimit = Schema.Int.check(\n Schema.isBetween({ minimum: 1, maximum: 256 * 1024 }),\n);\n\n/** The namespace-record shape accepted by `CodeMode.make`. */\nexport type CodeModeNamespaces = Record<string, Record<string, Tool.Any>>;\n\n/**\n * Union of every Tool selected across all namespaces, computed distributively\n * per namespace: indexing the namespace union with the INTERSECTION of method\n * keys would erase every Tool once two namespaces have disjoint methods.\n */\nexport type CodeModeSelectedTool<Namespaces extends CodeModeNamespaces> = {\n [Namespace in keyof Namespaces]: Namespaces[Namespace][keyof Namespaces[Namespace]];\n}[keyof Namespaces];\n\n/** The selected Tools re-keyed by their own Tool names. */\nexport type CodeModeSelectedRecord<Namespaces extends CodeModeNamespaces> = {\n readonly [T in CodeModeSelectedTool<Namespaces> as T[\"name\"]]: T;\n};\n\n/**\n * The native Effect AI Tool created by `CodeMode.make` (CAP-014). Its only\n * per-call dependency is the engine-provided `ToolBroker`; the `CodeExecutor`\n * and every selected handler and redaction service are construction requirements of the handler\n * Layer instead, so they stay visible in the composed `R`.\n */\nexport type CodeModeTool<Name extends string> = Tool.Tool<\n Name,\n {\n readonly parameters: typeof CodeModeParameters;\n readonly success: typeof CodeModeSuccess;\n readonly failure: typeof CodeModeFailure;\n readonly failureMode: \"return\";\n },\n ToolBroker\n>;\n\n/** Singleton Tool record provided by one Code Mode handler Layer. */\nexport type CodeModeTools<Name extends string> = {\n readonly [Key in Name]: CodeModeTool<Name>;\n};\n\n/** Construction requirements of the Code Mode handler Layer. */\nexport type CodeModeLayerRequirements<\n Namespaces extends CodeModeNamespaces,\n RedactionRequirements = never,\n> =\n | CodeExecutor\n | Exclude<RedactionRequirements, Scope.Scope>\n | Tool.HandlersFor<CodeModeSelectedRecord<Namespaces>>\n | Tool.HandlerServices<CodeModeSelectedTool<Namespaces>>;\n\nexport interface CodeModeOptions<\n Namespaces extends CodeModeNamespaces,\n RedactionRequirements = never,\n> {\n /** Model-visible description; the builder appends the sandbox contract. */\n readonly description: string;\n /** Include all sandbox declarations in the model-facing description. Defaults to true. */\n readonly includeDeclarations?: boolean | undefined;\n /**\n * Explicit allowlist: namespace name → method name → native Effect AI\n * Tool. Reads and mutations are allowed; calls requiring additional approval fail closed.\n */\n readonly tools: Namespaces;\n /** Executor limits for one pass; a bounded default applies when omitted. */\n readonly limits?: CodeExecutionLimits | undefined;\n /**\n * Aggregate model-visible egress budget in UTF-8 bytes across the final\n * result, captured logs, and any thrown value (CAP-016). Default 65536.\n */\n readonly maxEgressBytes?: number | undefined;\n /**\n * Host-only ephemeral report after executor resources and invocation fibers close, including\n * failure, defect, and interruption. It contains no arguments/results and is never a checkpoint.\n * Keep this total callback bounded; its services are captured with the handler Layer.\n */\n readonly onPassExit?:\n | ((report: CodeModePassReport) => Effect.Effect<void, never, RedactionRequirements>)\n | undefined;\n /**\n * Optional aggregate redaction pass applied to the model-visible egress\n * before the byte budget. Its services are acquired with the handler Layer;\n * temporary resources close with each redaction invocation.\n * It must be total; a defect stays a defect.\n */\n readonly redactEgress?:\n | ((egress: {\n readonly result: Schema.Json;\n readonly logs: ReadonlyArray<string>;\n }) => Effect.Effect<\n {\n readonly result: Schema.Json;\n readonly logs: ReadonlyArray<string>;\n },\n never,\n RedactionRequirements\n >)\n | undefined;\n}\n\n/**\n * An immutable Code Mode definition: one model-facing Tool over an explicit\n * allowlist, plus the handler Layer that runs generated programs through the\n * `CodeExecutor` port and the engine-owned broker. It owns no acquired\n * resources.\n */\nexport interface CodeModeDefinition<\n Name extends string,\n Namespaces extends CodeModeNamespaces,\n RedactionRequirements = never,\n> {\n readonly name: Name;\n /** The assembled model-facing description, optionally including all declarations. */\n readonly description: string;\n /** Rendered TypeScript declarations of the sandbox globals (documentation only). */\n readonly declarations: string;\n /**\n * Render complete encoded-schema declarations for 1–64 unique, exact namespace.method names.\n * The UTF-8 byte limit defaults to 16384 and must be an integer from 1 through 262144.\n * Oversized documentation fails rather than truncating a declaration. This host operation\n * does not authorize a model to see the selected methods; filter selections by current\n * visibility and inherited grants before returning its output to a model.\n */\n readonly describe: (\n methods: ReadonlyArray<string>,\n options?: { readonly maxBytes?: number | undefined },\n ) => Effect.Effect<string, CodeModeDescriptionError>;\n /** The executor-facing namespace catalog derived from the allowlist. */\n readonly namespaces: ReadonlyArray<CodeExecutionNamespace>;\n readonly limits: CodeExecutionLimits;\n readonly maxEgressBytes: number;\n /** The ordinary Effect AI Tool to include in the model-facing Toolkit. */\n readonly tool: CodeModeTool<Name>;\n /** Handler Layer; selected handler requirements stay visible in `R`. */\n readonly handlers: Layer.Layer<\n Tool.HandlersFor<CodeModeTools<Name>>,\n never,\n CodeModeLayerRequirements<Namespaces, RedactionRequirements>\n >;\n}\n\nconst defaultLimits = CodeExecutionLimits.make({\n maxSourceBytes: 256 * 1024,\n maxWallTime: Duration.seconds(30),\n maxLogBytes: 256 * 1024,\n maxResultBytes: 1024 * 1024,\n maxHostCalls: 64,\n maxHostCallArgumentBytes: 256 * 1024,\n maxHostCallResultBytes: 1024 * 1024,\n});\n\nconst defaultMaxEgressBytes = 64 * 1024;\n\n// ---------------------------------------------------------------------------\n// Declaration rendering (capability spec §9.1): the encoded side of each\n// Schema — the JSON that actually crosses the sandbox boundary — rendered as\n// TypeScript documentation via the same JSON-schema derivation Effect AI\n// applies to Tool parameters. A schema the renderer cannot express fails Tool\n// construction closed rather than degrading to `unknown`.\n// ---------------------------------------------------------------------------\n\nconst MAX_RENDER_DEPTH = 24;\n\nconst isJsonSchemaRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst renderJsonSchemaType = (\n schema: unknown,\n defs: Record<string, unknown>,\n depth: number,\n indent: string,\n): string => {\n if (depth > MAX_RENDER_DEPTH) {\n throw new Error(\"Code Mode declaration rendering exceeded its depth bound\");\n }\n if (!isJsonSchemaRecord(schema)) {\n throw new Error(`Code Mode cannot render the JSON schema fragment ${JSON.stringify(schema)}`);\n }\n const reference = schema.$ref;\n\n if (typeof reference === \"string\") {\n const match = /^#\\/\\$defs\\/(.+)$/.exec(reference);\n // JSON-pointer tokens escape `/` as `~1` and `~` as `~0`.\n const key = match === null ? undefined : match[1].replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\");\n const resolved = key === undefined ? undefined : defs[key];\n\n if (resolved === undefined) {\n throw new Error(`Code Mode cannot resolve the JSON schema reference ${reference}`);\n }\n\n return renderJsonSchemaType(resolved, defs, depth + 1, indent);\n }\n if (Array.isArray(schema.enum)) {\n return schema.enum.map((value) => JSON.stringify(value)).join(\" | \");\n }\n if (\"const\" in schema) {\n return JSON.stringify(schema.const);\n }\n const union = schema.anyOf ?? schema.oneOf;\n\n if (Array.isArray(union)) {\n return union.map((member) => renderJsonSchemaType(member, defs, depth + 1, indent)).join(\" | \");\n }\n const type = schema.type;\n\n if (Array.isArray(type)) {\n return type\n .map((member) => renderJsonSchemaType({ ...schema, type: member }, defs, depth + 1, indent))\n .join(\" | \");\n }\n switch (type) {\n case \"string\": {\n return \"string\";\n }\n case \"number\":\n case \"integer\": {\n return \"number\";\n }\n case \"boolean\": {\n return \"boolean\";\n }\n case \"null\": {\n return \"null\";\n }\n case \"array\": {\n if (!(\"items\" in schema)) {\n throw new Error(\"Code Mode cannot render an array schema without items\");\n }\n\n return `ReadonlyArray<${renderJsonSchemaType(schema.items, defs, depth + 1, indent)}>`;\n }\n case \"object\":\n case undefined: {\n if (isJsonSchemaRecord(schema.properties)) {\n const required = Array.isArray(schema.required) ? schema.required : [];\n const inner = `${indent} `;\n\n const fields = Object.entries(schema.properties).map(([key, property]) => {\n const optional = required.includes(key) ? \"\" : \"?\";\n // A JSON property name need not be a TypeScript identifier.\n const rendered = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);\n\n return `${inner}readonly ${rendered}${optional}: ${renderJsonSchemaType(property, defs, depth + 1, inner)};`;\n });\n\n return fields.length === 0 ? \"{}\" : `{\\n${fields.join(\"\\n\")}\\n${indent}}`;\n }\n if (isJsonSchemaRecord(schema.additionalProperties)) {\n return `Record<string, ${renderJsonSchemaType(schema.additionalProperties, defs, depth + 1, indent)}>`;\n }\n // A bare `{ \"type\": \"object\" }` states \"any JSON object\" (Schema.Json's\n // object member derives to exactly this); rendering it as an\n // unconstrained record is faithful, not a deriver degradation.\n if (type === \"object\" && !(\"properties\" in schema) && !(\"additionalProperties\" in schema)) {\n return \"Record<string, unknown>\";\n }\n break;\n }\n default: {\n break;\n }\n }\n throw new Error(\n `Code Mode cannot render the JSON schema fragment ${JSON.stringify(schema).slice(0, 200)}; fix or simplify the Tool's Schema`,\n );\n};\n\nconst renderTopLevel = (jsonSchema: unknown, indent: string): string => {\n const defs =\n isJsonSchemaRecord(jsonSchema) && isJsonSchemaRecord(jsonSchema.$defs)\n ? jsonSchema.$defs\n : ({} as Record<string, unknown>);\n\n return renderJsonSchemaType(jsonSchema, defs, 0, indent);\n};\n\nconst decodeIdentifier = Schema.decodeUnknownOption(JsIdentifier);\n\ninterface ResolvedMethod {\n readonly namespace: string;\n readonly method: string;\n readonly tool: Tool.Any;\n}\n\nconst renderDeclarations = (methods: ReadonlyArray<ResolvedMethod>): string => {\n const namespaces = new Map<string, Array<ResolvedMethod>>();\n\n for (const method of methods) {\n const existing = namespaces.get(method.namespace) ?? [];\n\n existing.push(method);\n namespaces.set(method.namespace, existing);\n }\n\n const blocks = [...namespaces.entries()].map(([namespace, members]) => {\n const lines = members.map((member) => {\n const parameters = renderTopLevel(Tool.getJsonSchema(member.tool), \" \");\n const success = renderTopLevel(Tool.getJsonSchemaFromSchema(member.tool.successSchema), \" \");\n\n // A description is arbitrary text: newlines and comment terminators\n // must not be able to break out of the documentation comment.\n const safeDescription = member.tool.description\n ?.replaceAll(\"*/\", \"*\\\\/\")\n .replaceAll(/\\s*\\n\\s*/g, \" \");\n\n const description = safeDescription === undefined ? \"\" : ` /** ${safeDescription} */\\n`;\n\n return `${description} ${member.method}(input: ${parameters}): Promise<${success}>;`;\n });\n\n return `declare const ${namespace}: {\\n${lines.join(\"\\n\")}\\n};`;\n });\n\n return blocks.join(\"\\n\\n\");\n};\n\n// ---------------------------------------------------------------------------\n// Aggregate model-visible egress (CAP-016): the final result, captured logs,\n// and any thrown value share one byte budget. Logs are truncated line-by-line\n// with an explicit marker; a result that alone exceeds the budget is a typed\n// failure rather than silent truncation.\n// ---------------------------------------------------------------------------\n\nconst truncationMarker = \"… logs truncated by the egress budget\";\nconst MAX_EGRESS_LOG_LINE_CHARACTERS = 16_000;\n\n/**\n * Budget charge of one log line as it actually crosses to the model: the\n * JSON-encoded string (quotes, escapes) plus one array separator. Charging\n * raw UTF-8 would undercount model-visible bytes for escape-heavy content.\n */\nconst encodedLogLineBytes = (line: string): number => {\n try {\n return utf8ByteLength(JSON.stringify(line)) + 1;\n } catch {\n return Number.MAX_SAFE_INTEGER;\n }\n};\n\nconst budgetedLogs = (\n logs: ReadonlyArray<string>,\n remainingBytes: number,\n): ReadonlyArray<string> => {\n const kept: Array<string> = [];\n let used = 0;\n let truncated = false;\n\n for (const raw of logs) {\n // Per-line cap keeps every kept line inside the BoundedLogLine schema.\n const line =\n raw.length > MAX_EGRESS_LOG_LINE_CHARACTERS\n ? `${raw.slice(0, MAX_EGRESS_LOG_LINE_CHARACTERS - 1)}…`\n : raw;\n\n const bytes = encodedLogLineBytes(line);\n\n if (kept.length >= 4_096 || used + bytes > remainingBytes) {\n truncated = true;\n break;\n }\n kept.push(line);\n used += bytes;\n }\n if (truncated) {\n // Truncation is never silent: drop kept lines from the end until the\n // marker itself fits inside the budget.\n const markerBytes = encodedLogLineBytes(truncationMarker);\n\n while (kept.length > 0 && used + markerBytes > remainingBytes) {\n used -= encodedLogLineBytes(kept.pop() ?? \"\");\n }\n if (markerBytes <= remainingBytes) {\n kept.push(truncationMarker);\n }\n }\n\n return kept;\n};\n\nconst boundedMessage = (message: string): string => message.slice(0, maxFailureTextLength);\n\nconst executionFailureMessage = (error: CodeExecutionError): string => {\n switch (error._tag) {\n case \"CodeExecutionTimeoutError\": {\n return `The program exceeded its ${Duration.format(error.maxWallTime)} ${error.kind} budget`;\n }\n case \"CodeOutputLimitError\": {\n return `The ${error.surface} limit of ${error.limit} bytes was exceeded (${error.observed} bytes observed)`;\n }\n case \"CodeHostCallLimitError\": {\n return `The pass exceeded its executor cap of ${error.limit} host calls`;\n }\n default: {\n return error.message;\n }\n }\n};\n\n/** UTF-8-aware truncation so a message can never exceed the aggregate budget. */\nconst truncateToUtf8Bytes = (value: string, maxBytes: number): string => {\n if (utf8ByteLength(value) <= maxBytes) {\n return value;\n }\n let output = \"\";\n let used = 0;\n\n for (const character of value) {\n const bytes = utf8ByteLength(character);\n\n if (used + bytes + 3 > maxBytes) {\n break;\n }\n output += character;\n used += bytes;\n }\n\n return `${output}…`;\n};\n\ntype EgressRedactor<Requirements = never> = NonNullable<\n CodeModeOptions<CodeModeNamespaces, Requirements>[\"redactEgress\"]\n>;\n\n// ---------------------------------------------------------------------------\n// Builder\n// ---------------------------------------------------------------------------\n\nconst make = <\n const Name extends string,\n Namespaces extends CodeModeNamespaces,\n RedactionRequirements = never,\n>(\n name: Name,\n options: CodeModeOptions<Namespaces, RedactionRequirements>,\n): CodeModeDefinition<Name, Namespaces, RedactionRequirements> => {\n const limits = options.limits ?? defaultLimits;\n const maxEgressBytes = options.maxEgressBytes ?? defaultMaxEgressBytes;\n\n // Fail closed on an invalid egress bound: NaN would make every size\n // comparison false and Infinity would remove the bound entirely.\n if (\n !Number.isSafeInteger(maxEgressBytes) ||\n maxEgressBytes < 256 ||\n maxEgressBytes > 4 * 1024 * 1024\n ) {\n throw new Error(\n `Code Mode maxEgressBytes must be an integer between 256 and ${4 * 1024 * 1024}; received ${String(maxEgressBytes)}`,\n );\n }\n\n // Construction-time fail-closed validation (CAP-014).\n const methods: Array<ResolvedMethod> = [];\n const toolsByName = new Map<string, Tool.Any>();\n const methodToTool = new Map<string, string>();\n\n for (const [namespace, namespaceMethods] of Object.entries(options.tools)) {\n if (Option.isNone(decodeIdentifier(namespace))) {\n throw new Error(`Code Mode namespace ${namespace} is not a valid JavaScript identifier`);\n }\n const entries = Object.entries(namespaceMethods);\n\n if (entries.length === 0) {\n throw new Error(`Code Mode namespace ${namespace} declares no methods`);\n }\n for (const [method, tool] of entries) {\n if (Option.isNone(decodeIdentifier(method))) {\n throw new Error(\n `Code Mode method ${namespace}.${method} is not a valid JavaScript identifier`,\n );\n }\n const approval = tool.needsApproval;\n\n if (approval !== undefined && approval !== false) {\n throw new Error(\n `Code Mode rejects Tool ${tool.name} (${namespace}.${method}): approval-requiring Tools cannot be invoked programmatically in the ephemeral slice`,\n );\n }\n const existing = toolsByName.get(tool.name);\n\n if (existing !== undefined && existing !== tool) {\n throw new Error(\n `Code Mode selected two different Tools named ${tool.name}; Tool names must identify one Tool`,\n );\n }\n toolsByName.set(tool.name, tool);\n methodToTool.set(`${namespace}.${method}`, tool.name);\n methods.push({ namespace, method, tool });\n }\n }\n if (methods.length === 0) {\n throw new Error(\"Code Mode requires at least one allowlisted Tool\");\n }\n\n // Declarations derive from the encoded Schemas and fail construction closed\n // on anything the renderer cannot express.\n const declarations = renderDeclarations(methods);\n\n const methodsByPath = new Map(\n methods.map((method) => [`${method.namespace}.${method.method}`, method]),\n );\n\n const describe = Effect.fn(\"CodeMode.describe\")(function* (\n selected: ReadonlyArray<string>,\n options?: { readonly maxBytes?: number | undefined },\n ) {\n const paths = yield* Schema.decodeEffect(DescriptionMethods)(selected).pipe(\n Effect.mapError(() =>\n CodeModeDescriptionError.make({\n reason: \"invalid-selection\",\n message:\n \"Select between 1 and 64 unique namespace.method names, each at most 257 characters\",\n }),\n ),\n );\n\n const maxBytes = yield* Schema.decodeEffect(DescriptionByteLimit)(\n options?.maxBytes ?? 16 * 1024,\n ).pipe(\n Effect.mapError(() =>\n CodeModeDescriptionError.make({\n reason: \"invalid-bound\",\n message: \"The documentation byte limit must be an integer between 1 and 262144\",\n }),\n ),\n );\n\n const selectedMethods: Array<ResolvedMethod> = [];\n\n for (const path of paths) {\n const method = methodsByPath.get(path);\n\n if (method === undefined) {\n return yield* CodeModeDescriptionError.make({\n reason: \"unknown-method\",\n message: \"The selection contains a method outside this Code Mode allowlist\",\n });\n }\n selectedMethods.push(method);\n }\n\n const documentation = renderDeclarations(selectedMethods);\n\n if (utf8ByteLength(documentation) > maxBytes) {\n return yield* CodeModeDescriptionError.make({\n reason: \"limit-exceeded\",\n message: `The selected declarations exceed the ${maxBytes}-byte documentation limit; select fewer methods or raise the limit`,\n });\n }\n\n return documentation;\n });\n\n const namespaces = [...new Set(methods.map((method) => method.namespace))].map((namespace) =>\n CodeExecutionNamespace.make({\n name: namespace,\n methods: methods\n .filter((method) => method.namespace === namespace)\n .map((method) => method.method),\n }),\n );\n\n const description = [\n options.description,\n \"\",\n \"The `code` argument must be one JavaScript async function expression; the sandbox invokes it exactly once with no arguments. It runs isolated with no ambient network, filesystem, environment, or secrets. Return one JSON value. `console.log` output is captured within a bounded budget and returned alongside the result.\",\n \"Namespace methods return Promises. An expected Tool failure rejects with a JSON envelope carrying a stable `_tag`; catch it to branch. Use Promise.all for independent calls; the host bounds concurrency. Await every call you need. Writes may complete before a failure: inspect call outcomes and never blindly retry a program.\",\n ...(options.includeDeclarations === false\n ? []\n : [\"\", \"Sandbox globals:\", \"```ts\", declarations, \"```\"]),\n ].join(\"\\n\");\n\n const tool = Tool.make(name, {\n description,\n parameters: CodeModeParameters,\n success: CodeModeSuccess,\n failure: CodeModeFailure,\n failureMode: \"return\",\n })\n .annotate(Tool.Readonly, false)\n .annotate(ToolExecutionClassAnnotation, \"uncertain\")\n .annotate(IncludesCatalogDocumentation, options.includeDeclarations !== false)\n .annotate(\n AdditionalToolCatalog,\n Object.freeze(methods.map((method) => Object.freeze({ ...method }))),\n )\n .addDependency(ToolBroker) as CodeModeTool<Name>;\n\n const outerToolkit = Toolkit.make(tool);\n\n /**\n * The nested namespace record collapses into one Toolkit keyed by exact\n * Tool names. The assertion restores the name-keyed record type TypeScript\n * cannot compute from `Map` iteration; construction above guarantees the\n * name uniqueness the type states.\n */\n const selectedToolkit = Toolkit.make(...toolsByName.values()) as unknown as Toolkit.Toolkit<\n CodeModeSelectedRecord<Namespaces>\n >;\n\n const executionRequest = (\n code: string,\n visibleNamespaces: ReadonlyArray<CodeExecutionNamespace>,\n ): CodeExecutionRequest =>\n CodeExecutionRequest.make({\n language: \"javascript\",\n source: code,\n namespaces: visibleNamespaces,\n network: NetworkDisabled.make({}),\n limits,\n });\n\n const routeHostCall = (\n pass: ToolBrokerPass,\n hostCall: CodeHostCall,\n visiblePaths: ReadonlySet<string> | undefined,\n ): Effect.Effect<CodeHostCallResult> =>\n Effect.gen(function* () {\n const path = `${hostCall.namespace}.${hostCall.method}`;\n\n const toolName =\n visiblePaths === undefined || visiblePaths.has(path) ? methodToTool.get(path) : undefined;\n\n if (toolName === undefined) {\n return {\n _tag: \"CodeHostCallFailure\",\n error: {\n _tag: \"UnknownCodeModeMethod\",\n message: \"The requested method is not available in this pass\",\n },\n } as const;\n }\n\n const outcome: ProgrammaticCallOutcome = yield* pass.invoke({\n toolName,\n encodedArguments: hostCall.argument,\n });\n\n switch (outcome._tag) {\n case \"ProgrammaticCallSuccess\": {\n const value = decodeBrokerJson(outcome.encodedResult);\n\n return Option.isSome(value)\n ? ({ _tag: \"CodeHostCallSuccess\", value: value.value } as const)\n : ({ _tag: \"CodeHostCallFailure\", error: brokerProtocolEnvelope } as const);\n }\n case \"ProgrammaticCallFailure\": {\n const value = decodeBrokerJson(outcome.encodedResult);\n\n return {\n _tag: \"CodeHostCallFailure\",\n error: Option.isSome(value) ? value.value : brokerProtocolEnvelope,\n } as const;\n }\n case \"ProgrammaticCallError\": {\n return {\n _tag: \"CodeHostCallFailure\",\n error: { _tag: outcome.errorTag, message: outcome.message },\n } as const;\n }\n }\n });\n\n const build = Effect.gen(function* () {\n const captured = yield* Effect.context<never>();\n const redactionServices = yield* Effect.context<Exclude<RedactionRequirements, Scope.Scope>>();\n const configuredRedactor = options.redactEgress;\n\n const redact: EgressRedactor | undefined =\n configuredRedactor === undefined\n ? undefined\n : (egress) =>\n Effect.scoped(configuredRedactor(egress)).pipe(\n // Merge invocation-local services before opening the redaction Scope.\n // The inner Scope shadows any Scope retained in the construction context.\n Effect.updateContext((current: Context.Context<never>) =>\n Context.merge(current, redactionServices),\n ),\n );\n\n const withHandler = yield* selectedToolkit;\n const executor = yield* CodeExecutor;\n\n const successEgress = (\n execution: CodeExecutionResult,\n ): Effect.Effect<CodeModeSuccess, CodeModeFailure> =>\n Effect.gen(function* () {\n let egress: { readonly result: Schema.Json; readonly logs: ReadonlyArray<string> } = {\n result: execution.value,\n logs: execution.logs,\n };\n\n if (redact !== undefined) {\n egress = yield* redact(egress);\n }\n const resultBytes = encodedJsonByteLength(egress.result);\n\n if (resultBytes === undefined || resultBytes > maxEgressBytes) {\n return yield* CodeModeFailure.make({\n errorTag: \"CodeModeEgressExceeded\",\n message: `The program result of ${resultBytes ?? \"unencodable\"} bytes exceeds the ${maxEgressBytes}-byte model-visible egress budget; return a smaller value`,\n logs: budgetedLogs(egress.logs, Math.max(0, maxEgressBytes - 256)),\n });\n }\n\n return CodeModeSuccess.make({\n result: egress.result,\n logs: budgetedLogs(egress.logs, maxEgressBytes - resultBytes),\n });\n });\n\n /**\n * The failure half of the aggregate egress policy (CAP-016): the configured\n * redaction pass covers failure logs and thrown values exactly like success\n * egress — a program cannot leak by logging and then throwing — and the\n * message itself is bounded by the budget, not only by its own schema cap.\n */\n const failureEgress = (\n error: CodeExecutionError | ToolBrokerUnavailableError | ToolBrokerConfigurationError,\n ): Effect.Effect<CodeModeFailure> =>\n Effect.gen(function* () {\n if (\n error._tag === \"ToolBrokerUnavailableError\" ||\n error._tag === \"ToolBrokerConfigurationError\"\n ) {\n return CodeModeFailure.make({\n errorTag: error._tag,\n message: truncateToUtf8Bytes(boundedMessage(error.message), maxEgressBytes),\n logs: [],\n });\n }\n let logs: ReadonlyArray<string> = \"logs\" in error ? error.logs : [];\n let candidateThrown = error._tag === \"CodeProgramFailedError\" ? error.thrown : undefined;\n\n if (redact !== undefined) {\n const redacted = yield* redact({ result: candidateThrown ?? null, logs });\n\n logs = redacted.logs;\n candidateThrown = candidateThrown === undefined ? undefined : redacted.result;\n }\n\n const message = truncateToUtf8Bytes(\n boundedMessage(executionFailureMessage(error)),\n maxEgressBytes,\n );\n\n const messageBytes = utf8ByteLength(message);\n\n // `thrown` is included only when it fits TOGETHER with the message inside\n // the aggregate budget, and it reduces the log allowance only when it is\n // actually included.\n const candidateBytes =\n candidateThrown === undefined ? undefined : encodedJsonByteLength(candidateThrown);\n\n const includeThrown =\n candidateThrown !== undefined &&\n candidateBytes !== undefined &&\n messageBytes + candidateBytes <= maxEgressBytes;\n\n const remaining = Math.max(\n 0,\n maxEgressBytes - messageBytes - (includeThrown ? (candidateBytes ?? 0) : 0),\n );\n\n return CodeModeFailure.make({\n errorTag: error._tag,\n message,\n logs: budgetedLogs(logs, remaining),\n ...(includeThrown ? { thrown: candidateThrown } : {}),\n });\n });\n\n const invoke = Effect.fn(`CodeMode.${name}`)(function* (parameters: { readonly code: string }) {\n const broker = yield* ToolBroker;\n // Resolve invocation authority before restoring captured construction services. A Layer\n // built under an older Run must not restore that Run's catalogue or hidden method names.\n const catalogue = yield* Effect.serviceOption(CurrentToolCatalog);\n\n const visiblePaths = Option.isNone(catalogue)\n ? undefined\n : new Set(\n catalogue.value.entries.flatMap((entry) =>\n entry.kind === \"code-mode\" &&\n entry.nativeToolName === name &&\n methodsByPath.get(`${entry.namespace}.${entry.method}`)?.tool.name === entry.tool.name\n ? [`${entry.namespace}.${entry.method}`]\n : [],\n ),\n );\n\n const visibleNamespaces =\n visiblePaths === undefined\n ? namespaces\n : namespaces.flatMap((namespace) => {\n const allowed = namespace.methods.filter((method) =>\n visiblePaths.has(`${namespace.name}.${method}`),\n );\n\n return allowed.length === 0\n ? []\n : [CodeExecutionNamespace.make({ name: namespace.name, methods: allowed })];\n });\n\n let calls: ReadonlyArray<ProgrammaticCallRecord> = [];\n\n const execution = Effect.gen(function* () {\n const pass = yield* broker.openPass(withHandler, {\n maxResultBytes: limits.maxHostCallResultBytes,\n concurrency: limits.maxHostCallConcurrency ?? 4,\n });\n\n const host = CodeExecutionHost.of({\n call: (hostCall) => routeHostCall(pass, hostCall, visiblePaths),\n });\n\n return yield* executor.execute(executionRequest(parameters.code, visibleNamespaces)).pipe(\n Effect.provideService(CodeExecutionHost, host),\n Effect.scoped,\n Effect.onExit((exit) =>\n Effect.gen(function* () {\n calls = yield* pass.snapshot;\n if (options.onPassExit !== undefined) {\n yield* Effect.scoped(\n options.onPassExit({\n status: Exit.isSuccess(exit)\n ? \"completed\"\n : Cause.hasInterrupts(exit.cause)\n ? \"interrupted\"\n : Cause.hasDies(exit.cause)\n ? \"defect\"\n : \"failed\",\n calls,\n }),\n ).pipe(Effect.provideContext(redactionServices));\n }\n }),\n ),\n );\n }).pipe(\n Effect.scoped,\n // The live engine broker is re-provided innermost so a Layer built\n // inside another Run can never shadow it; the captured construction\n // context supplies the selected handlers' services (same idiom as\n // Subagent.layer). TypeScript cannot reduce the deferred Exclude\n // over the generic namespace record, so the same private-assertion\n // contract as the engine's provideHookServices pins the identity\n // that providing the captured Context leaves no requirements; it\n // never bypasses validation.\n Effect.provideService(ToolBroker, broker),\n Effect.provideContext(captured),\n ) as Effect.Effect<\n CodeExecutionResult,\n CodeExecutionError | ToolBrokerUnavailableError | ToolBrokerConfigurationError\n >;\n\n return yield* execution.pipe(\n Effect.catch((error) => failureEgress(error).pipe(Effect.flatMap(Effect.fail))),\n Effect.flatMap(successEgress),\n Effect.mapError((failure) => {\n if (calls.length === 0) return failure;\n\n const complete = CodeModeFailure.make({\n errorTag: failure.errorTag,\n message: failure.message,\n logs: failure.logs,\n ...(failure.thrown === undefined ? {} : { thrown: failure.thrown }),\n calls,\n omittedCalls: 0,\n });\n\n if ((encodedJsonByteLength(complete) ?? Infinity) <= maxEgressBytes) return complete;\n\n // Evidence takes priority over logs and thrown values. Never silently omit calls.\n const base = {\n errorTag: failure.errorTag,\n message: truncateToUtf8Bytes(failure.message, Math.min(256, maxEgressBytes / 4)),\n logs: [],\n };\n\n const kept: Array<ProgrammaticCallRecord> = [];\n\n for (const call of calls) {\n const candidate = CodeModeFailure.make({\n ...base,\n calls: [...kept, call],\n omittedCalls: calls.length - kept.length - 1,\n });\n\n if ((encodedJsonByteLength(candidate) ?? Infinity) > maxEgressBytes) break;\n kept.push(call);\n }\n\n return CodeModeFailure.make({\n ...base,\n calls: kept,\n omittedCalls: calls.length - kept.length,\n });\n }),\n );\n });\n\n return { [name]: invoke } as unknown as Toolkit.HandlersFrom<CodeModeTools<Name>>;\n });\n\n /**\n * TypeScript cannot unify the two spellings of the singleton Tool record\n * (`CodeModeTools<Name>` versus the toolkit's name-remapped form) over a\n * generic `Name`, nor reduce the deferred `Exclude` when `toLayer`\n * subtracts what `build` consumed; the assertions pin the layer to its\n * documented requirement surface and never bypass validation.\n */\n const handlers = outerToolkit.toLayer(\n build as unknown as Effect.Effect<\n Toolkit.HandlersFrom<Toolkit.ToolsByName<readonly [CodeModeTool<Name>]>>,\n never,\n | CodeExecutor\n | Tool.HandlersFor<CodeModeSelectedRecord<Namespaces>>\n | Exclude<RedactionRequirements, Scope.Scope>\n >,\n ) as unknown as Layer.Layer<\n Tool.HandlersFor<CodeModeTools<Name>>,\n never,\n CodeModeLayerRequirements<Namespaces, RedactionRequirements>\n >;\n\n return Object.freeze({\n name,\n description,\n declarations,\n describe,\n namespaces,\n limits,\n maxEgressBytes,\n tool,\n handlers,\n });\n};\n\n/**\n * Fail-closed JSON boundary for broker outcomes: hostile values can throw\n * from trap getters during decode, and a value outside the JSON surface must\n * become a typed failure envelope — never a fabricated success.\n */\nconst decodeBrokerJson = (value: unknown): Option.Option<Schema.Json> => {\n try {\n return Schema.decodeUnknownOption(Schema.Json)(value);\n } catch {\n return Option.none();\n }\n};\n\nconst brokerProtocolEnvelope: Schema.Json = {\n _tag: \"CodeModeProtocolError\",\n message: \"The broker returned a value outside the JSON surface\",\n};\n\n// The engine annotation is imported under a local alias to keep the builder\n// readable next to Effect AI's own `Tool.Readonly` annotation.\nimport { ToolExecutionClass as ToolExecutionClassAnnotation } from \"../engine/DurableStep.ts\";\n\n/** Code Mode builder namespace (capability spec §9.1). */\nexport { make };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB,OAAO,OAAO,MAAM,OAAO,YAAY,oBAAoB,CAAC;AACvF,MAAM,kBAAkB,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC;AAC3E,MAAM,iBAAiB,OAAO,OAAO,MAAM,OAAO,YAAY,KAAS,CAAC;AACxE,MAAM,cAAc,OAAO,MAAM,cAAc,CAAC,CAAC,MAAM,OAAO,YAAY,I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/CodeMode.ts"],"sourcesContent":["import {\n type Layer,\n Cause,\n Context,\n Duration,\n Effect,\n Exit,\n Option,\n Schema,\n type Scope,\n} from \"effect\";\nimport { Tool, Toolkit } from \"effect/unstable/ai\";\n\nimport { utf8ByteLength } from \"../core/internal/utf8.ts\";\nimport { AdditionalToolCatalog, IncludesCatalogDocumentation } from \"../core/ToolExposure.ts\";\nimport {\n type ToolBrokerConfigurationError,\n type ToolBrokerUnavailableError,\n ToolBroker,\n type ProgrammaticCallOutcome,\n type ToolBrokerPass,\n ProgrammaticCallRecord,\n} from \"../engine/ToolBroker.ts\";\nimport { CurrentToolCatalog } from \"../engine/ToolExposure.ts\";\nimport {\n type CodeExecutionError,\n CodeExecutionHost,\n CodeExecutionLimits,\n CodeExecutionNamespace,\n CodeExecutionRequest,\n CodeExecutor,\n JsIdentifier,\n type CodeExecutionResult,\n type CodeHostCall,\n type CodeHostCallResult,\n} from \"../sandbox/CodeExecutor.ts\";\nimport { NetworkDisabled } from \"../sandbox/Sandbox.ts\";\n\n/**\n * Code Mode (D-035, ADR-0017; capability spec §9.1): one native Effect AI\n * Tool whose input is bounded JavaScript source, executed in one isolated\n * `CodeExecutor` pass that may call an explicit construction-time allowlist\n * of existing Tools through typed sandbox globals and the engine-owned\n * `ToolBroker`. The builder follows the Delegation pattern: an explicit\n * record of selected Tools plus namespace mapping fixed at construction,\n * returning an ordinary Tool and a handler Layer, with no ambient registry\n * (CAP-014). Deployment class `E` only.\n */\n\nconst maxFailureTextLength = 4 * 1024;\nconst BoundedFailureText = Schema.String.check(Schema.isMaxLength(maxFailureTextLength));\nconst BoundedErrorTag = Schema.NonEmptyString.check(Schema.isMaxLength(256));\nconst BoundedLogLine = Schema.String.check(Schema.isMaxLength(16 * 1024));\nconst BoundedLogs = Schema.Array(BoundedLogLine).check(Schema.isMaxLength(4_096));\nconst BoundedCode = Schema.NonEmptyString.check(Schema.isMaxLength(512 * 1024));\n\n/** A pass-local report, available to the host even when the caller interrupts execution. */\nexport const CodeModePassReport = Schema.Struct({\n status: Schema.Literals([\"completed\", \"failed\", \"interrupted\", \"defect\"]),\n calls: Schema.Array(ProgrammaticCallRecord),\n});\n\nexport type CodeModePassReport = typeof CodeModePassReport.Type;\n\nconst encodedJsonByteLength = (value: unknown): number | undefined => {\n try {\n const encoded = JSON.stringify(value);\n\n return encoded === undefined ? undefined : utf8ByteLength(encoded);\n } catch {\n return undefined;\n }\n};\n\n/** Model-decoded Code Mode parameters: one async function expression. */\nexport const CodeModeParameters = Schema.Struct({\n code: BoundedCode,\n});\n\n/**\n * The bounded model-visible success: the program's JSON result plus captured\n * logs, both already passed through the aggregate egress budget (CAP-016).\n */\nexport class CodeModeSuccess extends Schema.Class<CodeModeSuccess>(\n \"@effect-agent/capabilities/CodeModeSuccess\",\n)({\n result: Schema.Json,\n logs: BoundedLogs,\n}) {}\n\n/**\n * The bounded model-visible failure envelope. `failureMode: \"return\"` turns\n * it into a failed Tool result, so a model can correct a failing program\n * without a blind retry; it carries the same bounded log capture as success\n * plus the bounded thrown value where one exists, all inside the same\n * aggregate egress budget (CAP-016).\n */\nexport class CodeModeFailure extends Schema.TaggedError<CodeModeFailure>()(\"CodeModeFailure\", {\n errorTag: BoundedErrorTag,\n message: BoundedFailureText,\n logs: BoundedLogs,\n thrown: Schema.optionalKey(Schema.Json),\n /** Invocation-ordered evidence that fits the egress budget. This is not a replay plan. */\n calls: Schema.optionalKey(Schema.Array(ProgrammaticCallRecord)),\n omittedCalls: Schema.optionalKey(Schema.Natural),\n}) {}\n\n/** A selective documentation request is invalid or cannot fit its declared byte budget. */\nexport class CodeModeDescriptionError extends Schema.TaggedError<CodeModeDescriptionError>()(\n \"CodeModeDescriptionError\",\n {\n reason: Schema.Literals([\n \"invalid-selection\",\n \"unknown-method\",\n \"invalid-bound\",\n \"limit-exceeded\",\n ]),\n message: BoundedFailureText,\n },\n) {}\n\nconst DescriptionMethods = Schema.Array(Schema.NonEmptyString.check(Schema.isMaxLength(257))).check(\n Schema.isMinLength(1),\n Schema.isMaxLength(64),\n Schema.isUnique(),\n);\n\nconst DescriptionByteLimit = Schema.Int.check(\n Schema.isBetween({ minimum: 1, maximum: 256 * 1024 }),\n);\n\n/** The namespace-record shape accepted by `CodeMode.make`. */\nexport type CodeModeNamespaces = Record<string, Record<string, Tool.Any>>;\n\n/**\n * Union of every Tool selected across all namespaces, computed distributively\n * per namespace: indexing the namespace union with the INTERSECTION of method\n * keys would erase every Tool once two namespaces have disjoint methods.\n */\nexport type CodeModeSelectedTool<Namespaces extends CodeModeNamespaces> = {\n [Namespace in keyof Namespaces]: Namespaces[Namespace][keyof Namespaces[Namespace]];\n}[keyof Namespaces];\n\n/** The selected Tools re-keyed by their own Tool names. */\nexport type CodeModeSelectedRecord<Namespaces extends CodeModeNamespaces> = {\n readonly [T in CodeModeSelectedTool<Namespaces> as T[\"name\"]]: T;\n};\n\n/**\n * The native Effect AI Tool created by `CodeMode.make` (CAP-014). Its only\n * per-call dependency is the engine-provided `ToolBroker`; the `CodeExecutor`\n * and every selected handler and redaction service are construction requirements of the handler\n * Layer instead, so they stay visible in the composed `R`.\n */\nexport type CodeModeTool<Name extends string> = Tool.Tool<\n Name,\n {\n readonly parameters: typeof CodeModeParameters;\n readonly success: typeof CodeModeSuccess;\n readonly failure: typeof CodeModeFailure;\n readonly failureMode: \"return\";\n },\n ToolBroker\n>;\n\n/** Singleton Tool record provided by one Code Mode handler Layer. */\nexport type CodeModeTools<Name extends string> = {\n readonly [Key in Name]: CodeModeTool<Name>;\n};\n\n/** Construction requirements of the Code Mode handler Layer. */\nexport type CodeModeLayerRequirements<\n Namespaces extends CodeModeNamespaces,\n RedactionRequirements = never,\n> =\n | CodeExecutor\n | Exclude<RedactionRequirements, Scope.Scope>\n | Tool.HandlersFor<CodeModeSelectedRecord<Namespaces>>\n | Tool.HandlerServices<CodeModeSelectedTool<Namespaces>>;\n\nexport interface CodeModeOptions<\n Namespaces extends CodeModeNamespaces,\n RedactionRequirements = never,\n> {\n /** Model-visible description; the builder appends the sandbox contract. */\n readonly description: string;\n /** Include all sandbox declarations in the model-facing description. Defaults to true. */\n readonly includeDeclarations?: boolean | undefined;\n /**\n * Explicit allowlist: namespace name → method name → native Effect AI\n * Tool. Reads and mutations are allowed; calls requiring additional approval fail closed.\n */\n readonly tools: Namespaces;\n /** Executor limits for one pass; a bounded default applies when omitted. */\n readonly limits?: CodeExecutionLimits | undefined;\n /**\n * Aggregate model-visible egress budget in UTF-8 bytes across the final\n * result, captured logs, and any thrown value (CAP-016). Default 65536.\n */\n readonly maxEgressBytes?: number | undefined;\n /**\n * Host-only ephemeral report after executor resources and invocation fibers close, including\n * failure, defect, and interruption. It contains no arguments/results and is never a checkpoint.\n * Keep this total callback bounded; its services are captured with the handler Layer.\n */\n readonly onPassExit?:\n | ((report: CodeModePassReport) => Effect.Effect<void, never, RedactionRequirements>)\n | undefined;\n /**\n * Optional aggregate redaction pass applied to the model-visible egress\n * before the byte budget. Its services are acquired with the handler Layer;\n * temporary resources close with each redaction invocation.\n * It must be total; a defect stays a defect.\n */\n readonly redactEgress?:\n | ((egress: {\n readonly result: Schema.Json;\n readonly logs: ReadonlyArray<string>;\n }) => Effect.Effect<\n {\n readonly result: Schema.Json;\n readonly logs: ReadonlyArray<string>;\n },\n never,\n RedactionRequirements\n >)\n | undefined;\n}\n\n/**\n * An immutable Code Mode definition: one model-facing Tool over an explicit\n * allowlist, plus the handler Layer that runs generated programs through the\n * `CodeExecutor` port and the engine-owned broker. It owns no acquired\n * resources.\n */\nexport interface CodeModeDefinition<\n Name extends string,\n Namespaces extends CodeModeNamespaces,\n RedactionRequirements = never,\n> {\n readonly name: Name;\n /** The assembled model-facing description, optionally including all declarations. */\n readonly description: string;\n /** Rendered TypeScript declarations of the sandbox globals (documentation only). */\n readonly declarations: string;\n /**\n * Render complete encoded-schema declarations for 1–64 unique, exact namespace.method names.\n * The UTF-8 byte limit defaults to 16384 and must be an integer from 1 through 262144.\n * Oversized documentation fails rather than truncating a declaration. This host operation\n * does not authorize a model to see the selected methods; filter selections by current\n * visibility and inherited grants before returning its output to a model.\n */\n readonly describe: (\n methods: ReadonlyArray<string>,\n options?: { readonly maxBytes?: number | undefined },\n ) => Effect.Effect<string, CodeModeDescriptionError>;\n /** The executor-facing namespace catalog derived from the allowlist. */\n readonly namespaces: ReadonlyArray<CodeExecutionNamespace>;\n readonly limits: CodeExecutionLimits;\n readonly maxEgressBytes: number;\n /** The ordinary Effect AI Tool to include in the model-facing Toolkit. */\n readonly tool: CodeModeTool<Name>;\n /** Handler Layer; selected handler requirements stay visible in `R`. */\n readonly handlers: Layer.Layer<\n Tool.HandlersFor<CodeModeTools<Name>>,\n never,\n CodeModeLayerRequirements<Namespaces, RedactionRequirements>\n >;\n}\n\nconst defaultLimits = CodeExecutionLimits.make({\n maxSourceBytes: 256 * 1024,\n maxWallTime: Duration.seconds(30),\n maxLogBytes: 256 * 1024,\n maxResultBytes: 1024 * 1024,\n maxHostCalls: 64,\n maxHostCallArgumentBytes: 256 * 1024,\n maxHostCallResultBytes: 1024 * 1024,\n});\n\nconst defaultMaxEgressBytes = 64 * 1024;\n\n// ---------------------------------------------------------------------------\n// Declaration rendering (capability spec §9.1): the encoded side of each\n// Schema — the JSON that actually crosses the sandbox boundary — rendered as\n// TypeScript documentation via the same JSON-schema derivation Effect AI\n// applies to Tool parameters. A schema the renderer cannot express fails Tool\n// construction closed rather than degrading to `unknown`.\n// ---------------------------------------------------------------------------\n\nconst MAX_RENDER_DEPTH = 24;\n\nconst isJsonSchemaRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst renderJsonSchemaType = (\n schema: unknown,\n defs: Record<string, unknown>,\n depth: number,\n indent: string,\n): string => {\n if (depth > MAX_RENDER_DEPTH) {\n throw new Error(\"Code Mode declaration rendering exceeded its depth bound\");\n }\n if (!isJsonSchemaRecord(schema)) {\n throw new Error(`Code Mode cannot render the JSON schema fragment ${JSON.stringify(schema)}`);\n }\n const reference = schema.$ref;\n\n if (typeof reference === \"string\") {\n const match = /^#\\/\\$defs\\/(.+)$/.exec(reference);\n // JSON-pointer tokens escape `/` as `~1` and `~` as `~0`.\n const key = match === null ? undefined : match[1].replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\");\n const resolved = key === undefined ? undefined : defs[key];\n\n if (resolved === undefined) {\n throw new Error(`Code Mode cannot resolve the JSON schema reference ${reference}`);\n }\n\n return renderJsonSchemaType(resolved, defs, depth + 1, indent);\n }\n if (Array.isArray(schema.enum)) {\n return schema.enum.map((value) => JSON.stringify(value)).join(\" | \");\n }\n if (\"const\" in schema) {\n return JSON.stringify(schema.const);\n }\n const union = schema.anyOf ?? schema.oneOf;\n\n if (Array.isArray(union)) {\n return union.map((member) => renderJsonSchemaType(member, defs, depth + 1, indent)).join(\" | \");\n }\n const type = schema.type;\n\n if (Array.isArray(type)) {\n return type\n .map((member) => renderJsonSchemaType({ ...schema, type: member }, defs, depth + 1, indent))\n .join(\" | \");\n }\n switch (type) {\n case \"string\": {\n return \"string\";\n }\n case \"number\":\n case \"integer\": {\n return \"number\";\n }\n case \"boolean\": {\n return \"boolean\";\n }\n case \"null\": {\n return \"null\";\n }\n case \"array\": {\n if (!(\"items\" in schema)) {\n throw new Error(\"Code Mode cannot render an array schema without items\");\n }\n\n return `ReadonlyArray<${renderJsonSchemaType(schema.items, defs, depth + 1, indent)}>`;\n }\n case \"object\":\n case undefined: {\n if (isJsonSchemaRecord(schema.properties)) {\n const required = Array.isArray(schema.required) ? schema.required : [];\n const inner = `${indent} `;\n\n const fields = Object.entries(schema.properties).map(([key, property]) => {\n const optional = required.includes(key) ? \"\" : \"?\";\n // A JSON property name need not be a TypeScript identifier.\n const rendered = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : JSON.stringify(key);\n\n return `${inner}readonly ${rendered}${optional}: ${renderJsonSchemaType(property, defs, depth + 1, inner)};`;\n });\n\n return fields.length === 0 ? \"{}\" : `{\\n${fields.join(\"\\n\")}\\n${indent}}`;\n }\n if (isJsonSchemaRecord(schema.additionalProperties)) {\n return `Record<string, ${renderJsonSchemaType(schema.additionalProperties, defs, depth + 1, indent)}>`;\n }\n // Schema.Record(Schema.String, Schema.Never) accepts only an empty object.\n if (\n type === \"object\" &&\n !(\"properties\" in schema) &&\n !(\"patternProperties\" in schema) &&\n schema.additionalProperties === false\n ) {\n return \"Record<string, never>\";\n }\n // A bare `{ \"type\": \"object\" }` states \"any JSON object\" (Schema.Json's\n // object member derives to exactly this); rendering it as an\n // unconstrained record is faithful, not a deriver degradation.\n if (type === \"object\" && !(\"properties\" in schema) && !(\"additionalProperties\" in schema)) {\n return \"Record<string, unknown>\";\n }\n break;\n }\n default: {\n break;\n }\n }\n throw new Error(\n `Code Mode cannot render the JSON schema fragment ${JSON.stringify(schema).slice(0, 200)}; fix or simplify the Tool's Schema`,\n );\n};\n\nconst renderTopLevel = (jsonSchema: unknown, indent: string): string => {\n const defs =\n isJsonSchemaRecord(jsonSchema) && isJsonSchemaRecord(jsonSchema.$defs)\n ? jsonSchema.$defs\n : ({} as Record<string, unknown>);\n\n return renderJsonSchemaType(jsonSchema, defs, 0, indent);\n};\n\nconst decodeIdentifier = Schema.decodeUnknownOption(JsIdentifier);\n\ninterface ResolvedMethod {\n readonly namespace: string;\n readonly method: string;\n readonly tool: Tool.Any;\n}\n\nconst renderDeclarations = (methods: ReadonlyArray<ResolvedMethod>): string => {\n const namespaces = new Map<string, Array<ResolvedMethod>>();\n\n for (const method of methods) {\n const existing = namespaces.get(method.namespace) ?? [];\n\n existing.push(method);\n namespaces.set(method.namespace, existing);\n }\n\n const blocks = [...namespaces.entries()].map(([namespace, members]) => {\n const lines = members.map((member) => {\n const parameters = renderTopLevel(Tool.getJsonSchema(member.tool), \" \");\n const success = renderTopLevel(Tool.getJsonSchemaFromSchema(member.tool.successSchema), \" \");\n\n // A description is arbitrary text: newlines and comment terminators\n // must not be able to break out of the documentation comment.\n const safeDescription = member.tool.description\n ?.replaceAll(\"*/\", \"*\\\\/\")\n .replaceAll(/\\s*\\n\\s*/g, \" \");\n\n const description = safeDescription === undefined ? \"\" : ` /** ${safeDescription} */\\n`;\n\n return `${description} ${member.method}(input: ${parameters}): Promise<${success}>;`;\n });\n\n return `declare const ${namespace}: {\\n${lines.join(\"\\n\")}\\n};`;\n });\n\n return blocks.join(\"\\n\\n\");\n};\n\n// ---------------------------------------------------------------------------\n// Aggregate model-visible egress (CAP-016): the final result, captured logs,\n// and any thrown value share one byte budget. Logs are truncated line-by-line\n// with an explicit marker; a result that alone exceeds the budget is a typed\n// failure rather than silent truncation.\n// ---------------------------------------------------------------------------\n\nconst truncationMarker = \"… logs truncated by the egress budget\";\nconst MAX_EGRESS_LOG_LINE_CHARACTERS = 16_000;\n\n/**\n * Budget charge of one log line as it actually crosses to the model: the\n * JSON-encoded string (quotes, escapes) plus one array separator. Charging\n * raw UTF-8 would undercount model-visible bytes for escape-heavy content.\n */\nconst encodedLogLineBytes = (line: string): number => {\n try {\n return utf8ByteLength(JSON.stringify(line)) + 1;\n } catch {\n return Number.MAX_SAFE_INTEGER;\n }\n};\n\nconst budgetedLogs = (\n logs: ReadonlyArray<string>,\n remainingBytes: number,\n): ReadonlyArray<string> => {\n const kept: Array<string> = [];\n let used = 0;\n let truncated = false;\n\n for (const raw of logs) {\n // Per-line cap keeps every kept line inside the BoundedLogLine schema.\n const line =\n raw.length > MAX_EGRESS_LOG_LINE_CHARACTERS\n ? `${raw.slice(0, MAX_EGRESS_LOG_LINE_CHARACTERS - 1)}…`\n : raw;\n\n const bytes = encodedLogLineBytes(line);\n\n if (kept.length >= 4_096 || used + bytes > remainingBytes) {\n truncated = true;\n break;\n }\n kept.push(line);\n used += bytes;\n }\n if (truncated) {\n // Truncation is never silent: drop kept lines from the end until the\n // marker itself fits inside the budget.\n const markerBytes = encodedLogLineBytes(truncationMarker);\n\n while (kept.length > 0 && used + markerBytes > remainingBytes) {\n used -= encodedLogLineBytes(kept.pop() ?? \"\");\n }\n if (markerBytes <= remainingBytes) {\n kept.push(truncationMarker);\n }\n }\n\n return kept;\n};\n\nconst boundedMessage = (message: string): string => message.slice(0, maxFailureTextLength);\n\nconst executionFailureMessage = (error: CodeExecutionError): string => {\n switch (error._tag) {\n case \"CodeExecutionTimeoutError\": {\n return `The program exceeded its ${Duration.format(error.maxWallTime)} ${error.kind} budget`;\n }\n case \"CodeOutputLimitError\": {\n return `The ${error.surface} limit of ${error.limit} bytes was exceeded (${error.observed} bytes observed)`;\n }\n case \"CodeHostCallLimitError\": {\n return `The pass exceeded its executor cap of ${error.limit} host calls`;\n }\n default: {\n return error.message;\n }\n }\n};\n\n/** UTF-8-aware truncation so a message can never exceed the aggregate budget. */\nconst truncateToUtf8Bytes = (value: string, maxBytes: number): string => {\n if (utf8ByteLength(value) <= maxBytes) {\n return value;\n }\n let output = \"\";\n let used = 0;\n\n for (const character of value) {\n const bytes = utf8ByteLength(character);\n\n if (used + bytes + 3 > maxBytes) {\n break;\n }\n output += character;\n used += bytes;\n }\n\n return `${output}…`;\n};\n\ntype EgressRedactor<Requirements = never> = NonNullable<\n CodeModeOptions<CodeModeNamespaces, Requirements>[\"redactEgress\"]\n>;\n\n// ---------------------------------------------------------------------------\n// Builder\n// ---------------------------------------------------------------------------\n\nconst make = <\n const Name extends string,\n Namespaces extends CodeModeNamespaces,\n RedactionRequirements = never,\n>(\n name: Name,\n options: CodeModeOptions<Namespaces, RedactionRequirements>,\n): CodeModeDefinition<Name, Namespaces, RedactionRequirements> => {\n const limits = options.limits ?? defaultLimits;\n const maxEgressBytes = options.maxEgressBytes ?? defaultMaxEgressBytes;\n\n // Fail closed on an invalid egress bound: NaN would make every size\n // comparison false and Infinity would remove the bound entirely.\n if (\n !Number.isSafeInteger(maxEgressBytes) ||\n maxEgressBytes < 256 ||\n maxEgressBytes > 4 * 1024 * 1024\n ) {\n throw new Error(\n `Code Mode maxEgressBytes must be an integer between 256 and ${4 * 1024 * 1024}; received ${String(maxEgressBytes)}`,\n );\n }\n\n // Construction-time fail-closed validation (CAP-014).\n const methods: Array<ResolvedMethod> = [];\n const toolsByName = new Map<string, Tool.Any>();\n const methodToTool = new Map<string, string>();\n\n for (const [namespace, namespaceMethods] of Object.entries(options.tools)) {\n if (Option.isNone(decodeIdentifier(namespace))) {\n throw new Error(`Code Mode namespace ${namespace} is not a valid JavaScript identifier`);\n }\n const entries = Object.entries(namespaceMethods);\n\n if (entries.length === 0) {\n throw new Error(`Code Mode namespace ${namespace} declares no methods`);\n }\n for (const [method, tool] of entries) {\n if (Option.isNone(decodeIdentifier(method))) {\n throw new Error(\n `Code Mode method ${namespace}.${method} is not a valid JavaScript identifier`,\n );\n }\n const approval = tool.needsApproval;\n\n if (approval !== undefined && approval !== false) {\n throw new Error(\n `Code Mode rejects Tool ${tool.name} (${namespace}.${method}): approval-requiring Tools cannot be invoked programmatically in the ephemeral slice`,\n );\n }\n const existing = toolsByName.get(tool.name);\n\n if (existing !== undefined && existing !== tool) {\n throw new Error(\n `Code Mode selected two different Tools named ${tool.name}; Tool names must identify one Tool`,\n );\n }\n toolsByName.set(tool.name, tool);\n methodToTool.set(`${namespace}.${method}`, tool.name);\n methods.push({ namespace, method, tool });\n }\n }\n if (methods.length === 0) {\n throw new Error(\"Code Mode requires at least one allowlisted Tool\");\n }\n\n // Declarations derive from the encoded Schemas and fail construction closed\n // on anything the renderer cannot express.\n const declarations = renderDeclarations(methods);\n\n const methodsByPath = new Map(\n methods.map((method) => [`${method.namespace}.${method.method}`, method]),\n );\n\n const describe = Effect.fn(\"CodeMode.describe\")(function* (\n selected: ReadonlyArray<string>,\n options?: { readonly maxBytes?: number | undefined },\n ) {\n const paths = yield* Schema.decodeEffect(DescriptionMethods)(selected).pipe(\n Effect.mapError(() =>\n CodeModeDescriptionError.make({\n reason: \"invalid-selection\",\n message:\n \"Select between 1 and 64 unique namespace.method names, each at most 257 characters\",\n }),\n ),\n );\n\n const maxBytes = yield* Schema.decodeEffect(DescriptionByteLimit)(\n options?.maxBytes ?? 16 * 1024,\n ).pipe(\n Effect.mapError(() =>\n CodeModeDescriptionError.make({\n reason: \"invalid-bound\",\n message: \"The documentation byte limit must be an integer between 1 and 262144\",\n }),\n ),\n );\n\n const selectedMethods: Array<ResolvedMethod> = [];\n\n for (const path of paths) {\n const method = methodsByPath.get(path);\n\n if (method === undefined) {\n return yield* CodeModeDescriptionError.make({\n reason: \"unknown-method\",\n message: \"The selection contains a method outside this Code Mode allowlist\",\n });\n }\n selectedMethods.push(method);\n }\n\n const documentation = renderDeclarations(selectedMethods);\n\n if (utf8ByteLength(documentation) > maxBytes) {\n return yield* CodeModeDescriptionError.make({\n reason: \"limit-exceeded\",\n message: `The selected declarations exceed the ${maxBytes}-byte documentation limit; select fewer methods or raise the limit`,\n });\n }\n\n return documentation;\n });\n\n const namespaces = [...new Set(methods.map((method) => method.namespace))].map((namespace) =>\n CodeExecutionNamespace.make({\n name: namespace,\n methods: methods\n .filter((method) => method.namespace === namespace)\n .map((method) => method.method),\n }),\n );\n\n const description = [\n options.description,\n \"\",\n \"The `code` argument must be one JavaScript async function expression; the sandbox invokes it exactly once with no arguments. It runs isolated with no ambient network, filesystem, environment, or secrets. Return one JSON value. `console.log` output is captured within a bounded budget and returned alongside the result.\",\n \"Namespace methods return Promises. An expected Tool failure rejects with a JSON envelope carrying a stable `_tag`; catch it to branch. Use Promise.all for independent calls; the host bounds concurrency. Await every call you need. Writes may complete before a failure: inspect call outcomes and never blindly retry a program.\",\n ...(options.includeDeclarations === false\n ? []\n : [\"\", \"Sandbox globals:\", \"```ts\", declarations, \"```\"]),\n ].join(\"\\n\");\n\n const tool = Tool.make(name, {\n description,\n parameters: CodeModeParameters,\n success: CodeModeSuccess,\n failure: CodeModeFailure,\n failureMode: \"return\",\n })\n .annotate(Tool.Readonly, false)\n .annotate(ToolExecutionClassAnnotation, \"uncertain\")\n .annotate(IncludesCatalogDocumentation, options.includeDeclarations !== false)\n .annotate(\n AdditionalToolCatalog,\n Object.freeze(methods.map((method) => Object.freeze({ ...method }))),\n )\n .addDependency(ToolBroker) as CodeModeTool<Name>;\n\n const outerToolkit = Toolkit.make(tool);\n\n /**\n * The nested namespace record collapses into one Toolkit keyed by exact\n * Tool names. The assertion restores the name-keyed record type TypeScript\n * cannot compute from `Map` iteration; construction above guarantees the\n * name uniqueness the type states.\n */\n const selectedToolkit = Toolkit.make(...toolsByName.values()) as unknown as Toolkit.Toolkit<\n CodeModeSelectedRecord<Namespaces>\n >;\n\n const executionRequest = (\n code: string,\n visibleNamespaces: ReadonlyArray<CodeExecutionNamespace>,\n ): CodeExecutionRequest =>\n CodeExecutionRequest.make({\n language: \"javascript\",\n source: code,\n namespaces: visibleNamespaces,\n network: NetworkDisabled.make({}),\n limits,\n });\n\n const routeHostCall = (\n pass: ToolBrokerPass,\n hostCall: CodeHostCall,\n visiblePaths: ReadonlySet<string> | undefined,\n ): Effect.Effect<CodeHostCallResult> =>\n Effect.gen(function* () {\n const path = `${hostCall.namespace}.${hostCall.method}`;\n\n const toolName =\n visiblePaths === undefined || visiblePaths.has(path) ? methodToTool.get(path) : undefined;\n\n if (toolName === undefined) {\n return {\n _tag: \"CodeHostCallFailure\",\n error: {\n _tag: \"UnknownCodeModeMethod\",\n message: \"The requested method is not available in this pass\",\n },\n } as const;\n }\n\n const outcome: ProgrammaticCallOutcome = yield* pass.invoke({\n toolName,\n encodedArguments: hostCall.argument,\n });\n\n switch (outcome._tag) {\n case \"ProgrammaticCallSuccess\": {\n const value = decodeBrokerJson(outcome.encodedResult);\n\n return Option.isSome(value)\n ? ({ _tag: \"CodeHostCallSuccess\", value: value.value } as const)\n : ({ _tag: \"CodeHostCallFailure\", error: brokerProtocolEnvelope } as const);\n }\n case \"ProgrammaticCallFailure\": {\n const value = decodeBrokerJson(outcome.encodedResult);\n\n return {\n _tag: \"CodeHostCallFailure\",\n error: Option.isSome(value) ? value.value : brokerProtocolEnvelope,\n } as const;\n }\n case \"ProgrammaticCallError\": {\n return {\n _tag: \"CodeHostCallFailure\",\n error: { _tag: outcome.errorTag, message: outcome.message },\n } as const;\n }\n }\n });\n\n const build = Effect.gen(function* () {\n const captured = yield* Effect.context<never>();\n const redactionServices = yield* Effect.context<Exclude<RedactionRequirements, Scope.Scope>>();\n const configuredRedactor = options.redactEgress;\n\n const redact: EgressRedactor | undefined =\n configuredRedactor === undefined\n ? undefined\n : (egress) =>\n Effect.scoped(configuredRedactor(egress)).pipe(\n // Merge invocation-local services before opening the redaction Scope.\n // The inner Scope shadows any Scope retained in the construction context.\n Effect.updateContext((current: Context.Context<never>) =>\n Context.merge(current, redactionServices),\n ),\n );\n\n const withHandler = yield* selectedToolkit;\n const executor = yield* CodeExecutor;\n\n const successEgress = (\n execution: CodeExecutionResult,\n ): Effect.Effect<CodeModeSuccess, CodeModeFailure> =>\n Effect.gen(function* () {\n let egress: { readonly result: Schema.Json; readonly logs: ReadonlyArray<string> } = {\n result: execution.value,\n logs: execution.logs,\n };\n\n if (redact !== undefined) {\n egress = yield* redact(egress);\n }\n const resultBytes = encodedJsonByteLength(egress.result);\n\n if (resultBytes === undefined || resultBytes > maxEgressBytes) {\n return yield* CodeModeFailure.make({\n errorTag: \"CodeModeEgressExceeded\",\n message: `The program result of ${resultBytes ?? \"unencodable\"} bytes exceeds the ${maxEgressBytes}-byte model-visible egress budget; return a smaller value`,\n logs: budgetedLogs(egress.logs, Math.max(0, maxEgressBytes - 256)),\n });\n }\n\n return CodeModeSuccess.make({\n result: egress.result,\n logs: budgetedLogs(egress.logs, maxEgressBytes - resultBytes),\n });\n });\n\n /**\n * The failure half of the aggregate egress policy (CAP-016): the configured\n * redaction pass covers failure logs and thrown values exactly like success\n * egress — a program cannot leak by logging and then throwing — and the\n * message itself is bounded by the budget, not only by its own schema cap.\n */\n const failureEgress = (\n error: CodeExecutionError | ToolBrokerUnavailableError | ToolBrokerConfigurationError,\n ): Effect.Effect<CodeModeFailure> =>\n Effect.gen(function* () {\n if (\n error._tag === \"ToolBrokerUnavailableError\" ||\n error._tag === \"ToolBrokerConfigurationError\"\n ) {\n return CodeModeFailure.make({\n errorTag: error._tag,\n message: truncateToUtf8Bytes(boundedMessage(error.message), maxEgressBytes),\n logs: [],\n });\n }\n let logs: ReadonlyArray<string> = \"logs\" in error ? error.logs : [];\n let candidateThrown = error._tag === \"CodeProgramFailedError\" ? error.thrown : undefined;\n\n if (redact !== undefined) {\n const redacted = yield* redact({ result: candidateThrown ?? null, logs });\n\n logs = redacted.logs;\n candidateThrown = candidateThrown === undefined ? undefined : redacted.result;\n }\n\n const message = truncateToUtf8Bytes(\n boundedMessage(executionFailureMessage(error)),\n maxEgressBytes,\n );\n\n const messageBytes = utf8ByteLength(message);\n\n // `thrown` is included only when it fits TOGETHER with the message inside\n // the aggregate budget, and it reduces the log allowance only when it is\n // actually included.\n const candidateBytes =\n candidateThrown === undefined ? undefined : encodedJsonByteLength(candidateThrown);\n\n const includeThrown =\n candidateThrown !== undefined &&\n candidateBytes !== undefined &&\n messageBytes + candidateBytes <= maxEgressBytes;\n\n const remaining = Math.max(\n 0,\n maxEgressBytes - messageBytes - (includeThrown ? (candidateBytes ?? 0) : 0),\n );\n\n return CodeModeFailure.make({\n errorTag: error._tag,\n message,\n logs: budgetedLogs(logs, remaining),\n ...(includeThrown ? { thrown: candidateThrown } : {}),\n });\n });\n\n const invoke = Effect.fn(`CodeMode.${name}`)(function* (parameters: { readonly code: string }) {\n const broker = yield* ToolBroker;\n // Resolve invocation authority before restoring captured construction services. A Layer\n // built under an older Run must not restore that Run's catalogue or hidden method names.\n const catalogue = yield* Effect.serviceOption(CurrentToolCatalog);\n\n const visiblePaths = Option.isNone(catalogue)\n ? undefined\n : new Set(\n catalogue.value.entries.flatMap((entry) =>\n entry.kind === \"code-mode\" &&\n entry.nativeToolName === name &&\n methodsByPath.get(`${entry.namespace}.${entry.method}`)?.tool.name === entry.tool.name\n ? [`${entry.namespace}.${entry.method}`]\n : [],\n ),\n );\n\n const visibleNamespaces =\n visiblePaths === undefined\n ? namespaces\n : namespaces.flatMap((namespace) => {\n const allowed = namespace.methods.filter((method) =>\n visiblePaths.has(`${namespace.name}.${method}`),\n );\n\n return allowed.length === 0\n ? []\n : [CodeExecutionNamespace.make({ name: namespace.name, methods: allowed })];\n });\n\n let calls: ReadonlyArray<ProgrammaticCallRecord> = [];\n\n const execution = Effect.gen(function* () {\n const pass = yield* broker.openPass(withHandler, {\n maxResultBytes: limits.maxHostCallResultBytes,\n concurrency: limits.maxHostCallConcurrency ?? 4,\n });\n\n const host = CodeExecutionHost.of({\n call: (hostCall) => routeHostCall(pass, hostCall, visiblePaths),\n });\n\n return yield* executor.execute(executionRequest(parameters.code, visibleNamespaces)).pipe(\n Effect.provideService(CodeExecutionHost, host),\n Effect.scoped,\n Effect.onExit((exit) =>\n Effect.gen(function* () {\n calls = yield* pass.snapshot;\n if (options.onPassExit !== undefined) {\n yield* Effect.scoped(\n options.onPassExit({\n status: Exit.isSuccess(exit)\n ? \"completed\"\n : Cause.hasInterrupts(exit.cause)\n ? \"interrupted\"\n : Cause.hasDies(exit.cause)\n ? \"defect\"\n : \"failed\",\n calls,\n }),\n ).pipe(Effect.provideContext(redactionServices));\n }\n }),\n ),\n );\n }).pipe(\n Effect.scoped,\n // The live engine broker is re-provided innermost so a Layer built\n // inside another Run can never shadow it; the captured construction\n // context supplies the selected handlers' services (same idiom as\n // Subagent.layer). TypeScript cannot reduce the deferred Exclude\n // over the generic namespace record, so the same private-assertion\n // contract as the engine's provideHookServices pins the identity\n // that providing the captured Context leaves no requirements; it\n // never bypasses validation.\n Effect.provideService(ToolBroker, broker),\n Effect.provideContext(captured),\n ) as Effect.Effect<\n CodeExecutionResult,\n CodeExecutionError | ToolBrokerUnavailableError | ToolBrokerConfigurationError\n >;\n\n return yield* execution.pipe(\n Effect.catch((error) => failureEgress(error).pipe(Effect.flatMap(Effect.fail))),\n Effect.flatMap(successEgress),\n Effect.mapError((failure) => {\n if (calls.length === 0) return failure;\n\n const complete = CodeModeFailure.make({\n errorTag: failure.errorTag,\n message: failure.message,\n logs: failure.logs,\n ...(failure.thrown === undefined ? {} : { thrown: failure.thrown }),\n calls,\n omittedCalls: 0,\n });\n\n if ((encodedJsonByteLength(complete) ?? Infinity) <= maxEgressBytes) return complete;\n\n // Evidence takes priority over logs and thrown values. Never silently omit calls.\n const base = {\n errorTag: failure.errorTag,\n message: truncateToUtf8Bytes(failure.message, Math.min(256, maxEgressBytes / 4)),\n logs: [],\n };\n\n const kept: Array<ProgrammaticCallRecord> = [];\n\n for (const call of calls) {\n const candidate = CodeModeFailure.make({\n ...base,\n calls: [...kept, call],\n omittedCalls: calls.length - kept.length - 1,\n });\n\n if ((encodedJsonByteLength(candidate) ?? Infinity) > maxEgressBytes) break;\n kept.push(call);\n }\n\n return CodeModeFailure.make({\n ...base,\n calls: kept,\n omittedCalls: calls.length - kept.length,\n });\n }),\n );\n });\n\n return { [name]: invoke } as unknown as Toolkit.HandlersFrom<CodeModeTools<Name>>;\n });\n\n /**\n * TypeScript cannot unify the two spellings of the singleton Tool record\n * (`CodeModeTools<Name>` versus the toolkit's name-remapped form) over a\n * generic `Name`, nor reduce the deferred `Exclude` when `toLayer`\n * subtracts what `build` consumed; the assertions pin the layer to its\n * documented requirement surface and never bypass validation.\n */\n const handlers = outerToolkit.toLayer(\n build as unknown as Effect.Effect<\n Toolkit.HandlersFrom<Toolkit.ToolsByName<readonly [CodeModeTool<Name>]>>,\n never,\n | CodeExecutor\n | Tool.HandlersFor<CodeModeSelectedRecord<Namespaces>>\n | Exclude<RedactionRequirements, Scope.Scope>\n >,\n ) as unknown as Layer.Layer<\n Tool.HandlersFor<CodeModeTools<Name>>,\n never,\n CodeModeLayerRequirements<Namespaces, RedactionRequirements>\n >;\n\n return Object.freeze({\n name,\n description,\n declarations,\n describe,\n namespaces,\n limits,\n maxEgressBytes,\n tool,\n handlers,\n });\n};\n\n/**\n * Fail-closed JSON boundary for broker outcomes: hostile values can throw\n * from trap getters during decode, and a value outside the JSON surface must\n * become a typed failure envelope — never a fabricated success.\n */\nconst decodeBrokerJson = (value: unknown): Option.Option<Schema.Json> => {\n try {\n return Schema.decodeUnknownOption(Schema.Json)(value);\n } catch {\n return Option.none();\n }\n};\n\nconst brokerProtocolEnvelope: Schema.Json = {\n _tag: \"CodeModeProtocolError\",\n message: \"The broker returned a value outside the JSON surface\",\n};\n\n// The engine annotation is imported under a local alias to keep the builder\n// readable next to Effect AI's own `Tool.Readonly` annotation.\nimport { ToolExecutionClass as ToolExecutionClassAnnotation } from \"../engine/DurableStep.ts\";\n\n/** Code Mode builder namespace (capability spec §9.1). */\nexport { make };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,MAAM,uBAAuB;AAC7B,MAAM,qBAAqB,OAAO,OAAO,MAAM,OAAO,YAAY,oBAAoB,CAAC;AACvF,MAAM,kBAAkB,OAAO,eAAe,MAAM,OAAO,YAAY,GAAG,CAAC;AAC3E,MAAM,iBAAiB,OAAO,OAAO,MAAM,OAAO,YAAY,KAAS,CAAC;AACxE,MAAM,cAAc,OAAO,MAAM,cAAc,CAAC,CAAC,MAAM,OAAO,YAAY,IAAK,CAAC;AAChF,MAAM,cAAc,OAAO,eAAe,MAAM,OAAO,YAAY,MAAU,CAAC;;AAG9E,MAAa,qBAAqB,OAAO,OAAO;CAC9C,QAAQ,OAAO,SAAS;EAAC;EAAa;EAAU;EAAe;CAAQ,CAAC;CACxE,OAAO,OAAO,MAAM,sBAAsB;AAC5C,CAAC;AAID,MAAM,yBAAyB,UAAuC;CACpE,IAAI;EACF,MAAM,UAAU,KAAK,UAAU,KAAK;EAEpC,OAAO,YAAY,KAAA,IAAY,KAAA,IAAY,eAAe,OAAO;CACnE,QAAQ;EACN;CACF;AACF;;AAGA,MAAa,qBAAqB,OAAO,OAAO,EAC9C,MAAM,YACR,CAAC;;;;;AAMD,IAAa,kBAAb,cAAqC,OAAO,MAC1C,4CACF,CAAC,CAAC;CACA,QAAQ,OAAO;CACf,MAAM;AACR,CAAC,CAAC,CAAC,CAAC;;;;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;KACxB,MAAM,YAAY,gBAAgB,KAAK;MACrC,GAAG;MACH,OAAO,CAAC,GAAG,MAAM,IAAI;MACrB,cAAc,MAAM,SAAS,KAAK,SAAS;KAC7C,CAAC;KAED,KAAK,sBAAsB,SAAS,KAAK,YAAY,gBAAgB;KACrE,KAAK,KAAK,IAAI;IAChB;IAEA,OAAO,gBAAgB,KAAK;KAC1B,GAAG;KACH,OAAO;KACP,cAAc,MAAM,SAAS,KAAK;IACpC,CAAC;GACH,CAAC,CACH;EACF,CAAC;EAED,OAAO,GAAG,OAAO,OAAO;CAC1B,CAAC;;;;;;;;CASD,MAAM,WAAW,aAAa,QAC5B,KAOF;CAMA,OAAO,OAAO,OAAO;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH;;;;;;AAOA,MAAM,oBAAoB,UAA+C;CACvE,IAAI;EACF,OAAO,OAAO,oBAAoB,OAAO,IAAI,CAAC,CAAC,KAAK;CACtD,QAAQ;EACN,OAAO,OAAO,KAAK;CACrB;AACF;AAEA,MAAM,yBAAsC;CAC1C,MAAM;CACN,SAAS;AACX"}
|
|
@@ -585,6 +585,25 @@ export declare const readPending: (request: Pick<{
|
|
|
585
585
|
readonly reportKind?: "update" | undefined;
|
|
586
586
|
} | undefined;
|
|
587
587
|
readonly messageAdmission?: {
|
|
588
|
+
readonly schemaVersion: 1;
|
|
589
|
+
readonly message: {
|
|
590
|
+
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
591
|
+
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
592
|
+
};
|
|
593
|
+
readonly peerName: string;
|
|
594
|
+
readonly sender: {
|
|
595
|
+
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
596
|
+
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
597
|
+
};
|
|
598
|
+
readonly returnAddress: {
|
|
599
|
+
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
600
|
+
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
601
|
+
};
|
|
602
|
+
readonly inReplyTo?: {
|
|
603
|
+
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
604
|
+
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
605
|
+
} | undefined;
|
|
606
|
+
} | {
|
|
588
607
|
readonly _tag: "WorkerCompletion";
|
|
589
608
|
readonly budgetExhausted: boolean;
|
|
590
609
|
readonly schemaVersion: 1;
|
|
@@ -625,25 +644,6 @@ export declare const readPending: (request: Pick<{
|
|
|
625
644
|
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
626
645
|
};
|
|
627
646
|
readonly update: Update;
|
|
628
|
-
} | {
|
|
629
|
-
readonly schemaVersion: 1;
|
|
630
|
-
readonly message: {
|
|
631
|
-
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
632
|
-
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
633
|
-
};
|
|
634
|
-
readonly peerName: string;
|
|
635
|
-
readonly sender: {
|
|
636
|
-
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
637
|
-
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
638
|
-
};
|
|
639
|
-
readonly returnAddress: {
|
|
640
|
-
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
641
|
-
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
642
|
-
};
|
|
643
|
-
readonly inReplyTo?: {
|
|
644
|
-
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
645
|
-
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
646
|
-
} | undefined;
|
|
647
647
|
} | undefined;
|
|
648
648
|
};
|
|
649
649
|
readonly envelopeDigest: string & import("effect/Brand").Brand<"@effect-agent/thread/Digest">;
|
|
@@ -776,6 +776,25 @@ export declare const prepareMessageDelivery: (options: {
|
|
|
776
776
|
readonly reportKind?: "update" | undefined;
|
|
777
777
|
} | undefined;
|
|
778
778
|
readonly messageAdmission?: {
|
|
779
|
+
readonly schemaVersion: 1;
|
|
780
|
+
readonly message: {
|
|
781
|
+
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
782
|
+
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
783
|
+
};
|
|
784
|
+
readonly peerName: string;
|
|
785
|
+
readonly sender: {
|
|
786
|
+
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
787
|
+
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
788
|
+
};
|
|
789
|
+
readonly returnAddress: {
|
|
790
|
+
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
791
|
+
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
792
|
+
};
|
|
793
|
+
readonly inReplyTo?: {
|
|
794
|
+
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
795
|
+
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
796
|
+
} | undefined;
|
|
797
|
+
} | {
|
|
779
798
|
readonly _tag: "WorkerCompletion";
|
|
780
799
|
readonly budgetExhausted: boolean;
|
|
781
800
|
readonly schemaVersion: 1;
|
|
@@ -816,25 +835,6 @@ export declare const prepareMessageDelivery: (options: {
|
|
|
816
835
|
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
817
836
|
};
|
|
818
837
|
readonly update: Update;
|
|
819
|
-
} | {
|
|
820
|
-
readonly schemaVersion: 1;
|
|
821
|
-
readonly message: {
|
|
822
|
-
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
823
|
-
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
824
|
-
};
|
|
825
|
-
readonly peerName: string;
|
|
826
|
-
readonly sender: {
|
|
827
|
-
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
828
|
-
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
829
|
-
};
|
|
830
|
-
readonly returnAddress: {
|
|
831
|
-
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
832
|
-
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
833
|
-
};
|
|
834
|
-
readonly inReplyTo?: {
|
|
835
|
-
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
836
|
-
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
837
|
-
} | undefined;
|
|
838
838
|
} | undefined;
|
|
839
839
|
};
|
|
840
840
|
readonly envelopeDigest: string & import("effect/Brand").Brand<"@effect-agent/thread/Digest">;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"effect-agent","version":"0.1.0-beta.123","devDependencies":{"@effect/platform-node":"4.0.0-rc.116","@effect/vitest":"4.0.0-rc.116","effect":"4.0.0-rc.116","typescript":"7.0.2","vite-plus":"0.3.2"},"peerDependencies":{"effect":"^4.0.0-rc.116"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./activity-store":{"types":"./dist/durable/ActivityStore.d.mts","default":"./dist/durable/ActivityStore.mjs"},"./admin":{"types":"./dist/durable/Admin.d.mts","default":"./dist/durable/Admin.mjs"},"./agent":{"types":"./dist/core/Agent.d.mts","default":"./dist/core/Agent.mjs"},"./agent-error":{"types":"./dist/core/AgentError.d.mts","default":"./dist/core/AgentError.mjs"},"./agent-policy":{"types":"./dist/core/AgentPolicy.d.mts","default":"./dist/core/AgentPolicy.mjs"},"./agent-registration":{"types":"./dist/durable/AgentRegistration.d.mts","default":"./dist/durable/AgentRegistration.mjs"},"./agent-runtime":{"types":"./dist/engine/AgentRuntime.d.mts","default":"./dist/engine/AgentRuntime.mjs"},"./agent-updates":{"types":"./dist/core/AgentUpdates.d.mts","default":"./dist/core/AgentUpdates.mjs"},"./approval":{"types":"./dist/capabilities/Approval.d.mts","default":"./dist/capabilities/Approval.mjs"},"./budget":{"types":"./dist/capabilities/Budget.d.mts","default":"./dist/capabilities/Budget.mjs"},"./code-executor":{"types":"./dist/sandbox/CodeExecutor.d.mts","default":"./dist/sandbox/CodeExecutor.mjs"},"./code-mode":{"types":"./dist/capabilities/CodeMode.d.mts","default":"./dist/capabilities/CodeMode.mjs"},"./commands":{"types":"./dist/capabilities/Commands.d.mts","default":"./dist/capabilities/Commands.mjs"},"./committed-activity":{"types":"./dist/durable/CommittedActivity.d.mts","default":"./dist/durable/CommittedActivity.mjs"},"./compaction":{"types":"./dist/engine/Compaction.d.mts","default":"./dist/engine/Compaction.mjs"},"./context-compactor":{"types":"./dist/engine/ContextCompactor.d.mts","default":"./dist/engine/ContextCompactor.mjs"},"./context-history":{"types":"./dist/engine/ContextHistory.d.mts","default":"./dist/engine/ContextHistory.mjs"},"./context-tools":{"types":"./dist/capabilities/ContextTools.d.mts","default":"./dist/capabilities/ContextTools.mjs"},"./context-window":{"types":"./dist/engine/ContextWindow.d.mts","default":"./dist/engine/ContextWindow.mjs"},"./digest":{"types":"./dist/durable/Digest.d.mts","default":"./dist/durable/Digest.mjs"},"./durable-agent-runtime":{"types":"./dist/durable/DurableAgentRuntime.d.mts","default":"./dist/durable/DurableAgentRuntime.mjs"},"./durable-failpoint":{"types":"./dist/durable/DurableFailpoint.d.mts","default":"./dist/durable/DurableFailpoint.mjs"},"./durable-step":{"types":"./dist/engine/DurableStep.d.mts","default":"./dist/engine/DurableStep.mjs"},"./event-source":{"types":"./dist/durable/EventSource.d.mts","default":"./dist/durable/EventSource.mjs"},"./failure-diagnostic":{"types":"./dist/core/FailureDiagnostic.d.mts","default":"./dist/core/FailureDiagnostic.mjs"},"./git-hub-workflow-source":{"types":"./dist/durable/GitHubWorkflowSource.d.mts","default":"./dist/durable/GitHubWorkflowSource.mjs"},"./id-generator":{"types":"./dist/core/IdGenerator.d.mts","default":"./dist/core/IdGenerator.mjs"},"./identifiers":{"types":"./dist/core/Identifiers.d.mts","default":"./dist/core/Identifiers.mjs"},"./in-memory":{"types":"./dist/InMemory.d.mts","default":"./dist/InMemory.mjs"},"./interactive-browser":{"types":"./dist/sandbox/InteractiveBrowser.d.mts","default":"./dist/sandbox/InteractiveBrowser.mjs"},"./mcp":{"types":"./dist/capabilities/Mcp.d.mts","default":"./dist/capabilities/Mcp.mjs"},"./mcp-client":{"types":"./dist/capabilities/McpClient.d.mts","default":"./dist/capabilities/McpClient.mjs"},"./memory":{"types":"./dist/core/Memory.d.mts","default":"./dist/core/Memory.mjs"},"./memory-namespace":{"types":"./dist/core/MemoryNamespace.d.mts","default":"./dist/core/MemoryNamespace.mjs"},"./memory-notes":{"types":"./dist/capabilities/MemoryNotes.d.mts","default":"./dist/capabilities/MemoryNotes.mjs"},"./memory-reference":{"types":"./dist/core/MemoryReference.d.mts","default":"./dist/core/MemoryReference.mjs"},"./memory-revalidation":{"types":"./dist/core/MemoryRevalidation.d.mts","default":"./dist/core/MemoryRevalidation.mjs"},"./memory-store":{"types":"./dist/core/MemoryStore.d.mts","default":"./dist/core/MemoryStore.mjs"},"./message-delivery":{"types":"./dist/durable/MessageDelivery.d.mts","default":"./dist/durable/MessageDelivery.mjs"},"./messaging":{"types":"./dist/capabilities/Messaging.d.mts","default":"./dist/capabilities/Messaging.mjs"},"./messaging-host":{"types":"./dist/engine/MessagingHost.d.mts","default":"./dist/engine/MessagingHost.mjs"},"./model-context":{"types":"./dist/capabilities/ModelContext.d.mts","default":"./dist/capabilities/ModelContext.mjs"},"./operation-authorizer":{"types":"./dist/durable/OperationAuthorizer.d.mts","default":"./dist/durable/OperationAuthorizer.mjs"},"./output":{"types":"./dist/engine/Output.d.mts","default":"./dist/engine/Output.mjs"},"./page-capture":{"types":"./dist/sandbox/PageCapture.d.mts","default":"./dist/sandbox/PageCapture.mjs"},"./page-crawl":{"types":"./dist/sandbox/PageCrawl.d.mts","default":"./dist/sandbox/PageCrawl.mjs"},"./page-screenshot":{"types":"./dist/sandbox/PageScreenshot.d.mts","default":"./dist/sandbox/PageScreenshot.mjs"},"./persistent-history":{"types":"./dist/durable/PersistentHistory.d.mts","default":"./dist/durable/PersistentHistory.mjs"},"./prepared-input-admission":{"types":"./dist/durable/PreparedInputAdmission.d.mts","default":"./dist/durable/PreparedInputAdmission.mjs"},"./receipt":{"types":"./dist/core/Receipt.d.mts","default":"./dist/core/Receipt.mjs"},"./records":{"types":"./dist/durable/Records.d.mts","default":"./dist/durable/Records.mjs"},"./recovery":{"types":"./dist/durable/Recovery.d.mts","default":"./dist/durable/Recovery.mjs"},"./redaction":{"types":"./dist/capabilities/Redaction.d.mts","default":"./dist/capabilities/Redaction.mjs"},"./remembering":{"types":"./dist/capabilities/Remembering.d.mts","default":"./dist/capabilities/Remembering.mjs"},"./remembering-store":{"types":"./dist/core/RememberingStore.d.mts","default":"./dist/core/RememberingStore.mjs"},"./run-event":{"types":"./dist/core/RunEvent.d.mts","default":"./dist/core/RunEvent.mjs"},"./run-event-sink":{"types":"./dist/engine/RunEventSink.d.mts","default":"./dist/engine/RunEventSink.mjs"},"./run-hooks":{"types":"./dist/capabilities/RunHooks.d.mts","default":"./dist/capabilities/RunHooks.mjs"},"./run-journal":{"types":"./dist/durable/RunJournal.d.mts","default":"./dist/durable/RunJournal.mjs"},"./run-options":{"types":"./dist/engine/RunOptions.d.mts","default":"./dist/engine/RunOptions.mjs"},"./run-policy-usage":{"types":"./dist/core/RunPolicyUsage.d.mts","default":"./dist/core/RunPolicyUsage.mjs"},"./sandbox":{"types":"./dist/sandbox/Sandbox.d.mts","default":"./dist/sandbox/Sandbox.mjs"},"./schedule":{"types":"./dist/durable/Schedule.d.mts","default":"./dist/durable/Schedule.mjs"},"./schedule-transition":{"types":"./dist/durable/ScheduleTransition.d.mts","default":"./dist/durable/ScheduleTransition.mjs"},"./scheduling":{"types":"./dist/durable/Scheduling.d.mts","default":"./dist/durable/Scheduling.mjs"},"./semantic-memory":{"types":"./dist/capabilities/SemanticMemory.d.mts","default":"./dist/capabilities/SemanticMemory.mjs"},"./semantic-memory-index":{"types":"./dist/core/SemanticMemoryIndex.d.mts","default":"./dist/core/SemanticMemoryIndex.mjs"},"./semantic-memory-revalidation":{"types":"./dist/core/SemanticMemoryRevalidation.d.mts","default":"./dist/core/SemanticMemoryRevalidation.mjs"},"./sql-thread-native-reads":{"types":"./dist/durable/SqlThreadNativeReads.d.mts","default":"./dist/durable/SqlThreadNativeReads.mjs"},"./sql-memory-store":{"types":"./dist/durable/SqlMemoryStore.d.mts","default":"./dist/durable/SqlMemoryStore.mjs"},"./sql-message-delivery-store":{"types":"./dist/durable/SqlMessageDeliveryStore.d.mts","default":"./dist/durable/SqlMessageDeliveryStore.mjs"},"./sql-storage-v2-upgrade":{"types":"./dist/durable/SqlStorageV2Upgrade.d.mts","default":"./dist/durable/SqlStorageV2Upgrade.mjs"},"./sql-subscription-store":{"types":"./dist/durable/SqlSubscriptionStore.d.mts","default":"./dist/durable/SqlSubscriptionStore.mjs"},"./subagent":{"types":"./dist/capabilities/Subagent.d.mts","default":"./dist/capabilities/Subagent.mjs"},"./subagent-contract":{"types":"./dist/core/SubagentContract.d.mts","default":"./dist/core/SubagentContract.mjs"},"./subagent-host":{"types":"./dist/engine/SubagentHost.d.mts","default":"./dist/engine/SubagentHost.mjs"},"./subagent-reservations":{"types":"./dist/capabilities/SubagentReservations.d.mts","default":"./dist/capabilities/SubagentReservations.mjs"},"./submission-ledger":{"types":"./dist/durable/SubmissionLedger.d.mts","default":"./dist/durable/SubmissionLedger.mjs"},"./submission-status":{"types":"./dist/durable/SubmissionStatus.d.mts","default":"./dist/durable/SubmissionStatus.mjs"},"./subscription":{"types":"./dist/durable/Subscription.d.mts","default":"./dist/durable/Subscription.mjs"},"./subscription-input":{"types":"./dist/durable/SubscriptionInput.d.mts","default":"./dist/durable/SubscriptionInput.mjs"},"./subscription-tools":{"types":"./dist/durable/SubscriptionTools.d.mts","default":"./dist/durable/SubscriptionTools.mjs"},"./subscription-transition":{"types":"./dist/durable/SubscriptionTransition.d.mts","default":"./dist/durable/SubscriptionTransition.mjs"},"./subscriptions":{"types":"./dist/durable/Subscriptions.d.mts","default":"./dist/durable/Subscriptions.mjs"},"./testing/certification":{"types":"./dist/durable/Certification.d.mts","default":"./dist/durable/Certification.mjs"},"./testing/durable-failpoint-test-control":{"types":"./dist/durable/DurableFailpointTestControl.d.mts","default":"./dist/durable/DurableFailpointTestControl.mjs"},"./testing/message-delivery-store-conformance":{"types":"./dist/durable/MessageDeliveryStoreConformance.d.mts","default":"./dist/durable/MessageDeliveryStoreConformance.mjs"},"./testing/schedule-store-conformance":{"types":"./dist/durable/ScheduleStoreConformance.d.mts","default":"./dist/durable/ScheduleStoreConformance.mjs"},"./testing/submission-ledger-conformance":{"types":"./dist/durable/SubmissionLedgerConformance.d.mts","default":"./dist/durable/SubmissionLedgerConformance.mjs"},"./testing/subscription-store-conformance":{"types":"./dist/durable/SubscriptionStoreConformance.d.mts","default":"./dist/durable/SubscriptionStoreConformance.mjs"},"./testing/thread-store-conformance":{"types":"./dist/durable/ThreadStoreConformance.d.mts","default":"./dist/durable/ThreadStoreConformance.mjs"},"./thread":{"types":"./dist/core/Thread.d.mts","default":"./dist/core/Thread.mjs"},"./thread-context-history":{"types":"./dist/durable/ThreadContextHistory.d.mts","default":"./dist/durable/ThreadContextHistory.mjs"},"./thread-context-history-projection":{"types":"./dist/durable/ThreadContextHistoryProjection.d.mts","default":"./dist/durable/ThreadContextHistoryProjection.mjs"},"./thread-history":{"types":"./dist/engine/ThreadHistory.d.mts","default":"./dist/engine/ThreadHistory.mjs"},"./thread-invariants":{"types":"./dist/durable/ThreadInvariants.d.mts","default":"./dist/durable/ThreadInvariants.mjs"},"./thread-projection":{"types":"./dist/durable/ThreadProjection.d.mts","default":"./dist/durable/ThreadProjection.mjs"},"./thread-projection-maintenance":{"types":"./dist/durable/ThreadProjectionMaintenance.d.mts","default":"./dist/durable/ThreadProjectionMaintenance.mjs"},"./thread-store":{"types":"./dist/durable/ThreadStore.d.mts","default":"./dist/durable/ThreadStore.mjs"},"./tool-broker":{"types":"./dist/engine/ToolBroker.d.mts","default":"./dist/engine/ToolBroker.mjs"},"./tool-discovery":{"types":"./dist/capabilities/ToolDiscovery.d.mts","default":"./dist/capabilities/ToolDiscovery.mjs"},"./tool-exposure":{"types":"./dist/ToolExposure.d.mts","default":"./dist/ToolExposure.mjs"},"./tool-reconciler":{"types":"./dist/durable/ToolReconciler.d.mts","default":"./dist/durable/ToolReconciler.mjs"},"./tool-result":{"types":"./dist/core/ToolResult.d.mts","default":"./dist/core/ToolResult.mjs"},"./usage":{"types":"./dist/core/Usage.d.mts","default":"./dist/core/Usage.mjs"},"./wake-scheduler":{"types":"./dist/durable/WakeScheduler.d.mts","default":"./dist/durable/WakeScheduler.mjs"},"./web-capture":{"types":"./dist/capabilities/WebCapture.d.mts","default":"./dist/capabilities/WebCapture.mjs"},"./web-search":{"types":"./dist/capabilities/WebSearch.d.mts","default":"./dist/capabilities/WebSearch.mjs"},"./worker":{"types":"./dist/core/Worker.d.mts","default":"./dist/core/Worker.mjs"},"./worker-host":{"types":"./dist/durable/WorkerHost.d.mts","default":"./dist/durable/WorkerHost.mjs"}},"description":"Effect-native agents, execution, subagents, and sandbox contracts in one tree-shakeable package.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/danieljvdm/effect-agent.git","directory":"packages/effect-agent"},"files":["dist","src"],"type":"module","sideEffects":[],"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"tsc --noEmit -p tsconfig.json","test":"vp test --passWithNoTests"}}
|
|
1
|
+
{"name":"effect-agent","version":"0.1.0-beta.124","devDependencies":{"@effect/platform-node":"4.0.0-rc.116","@effect/vitest":"4.0.0-rc.116","effect":"4.0.0-rc.116","typescript":"7.0.2","vite-plus":"0.3.2"},"peerDependencies":{"effect":"^4.0.0-rc.116"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./activity-store":{"types":"./dist/durable/ActivityStore.d.mts","default":"./dist/durable/ActivityStore.mjs"},"./admin":{"types":"./dist/durable/Admin.d.mts","default":"./dist/durable/Admin.mjs"},"./agent":{"types":"./dist/core/Agent.d.mts","default":"./dist/core/Agent.mjs"},"./agent-error":{"types":"./dist/core/AgentError.d.mts","default":"./dist/core/AgentError.mjs"},"./agent-policy":{"types":"./dist/core/AgentPolicy.d.mts","default":"./dist/core/AgentPolicy.mjs"},"./agent-registration":{"types":"./dist/durable/AgentRegistration.d.mts","default":"./dist/durable/AgentRegistration.mjs"},"./agent-runtime":{"types":"./dist/engine/AgentRuntime.d.mts","default":"./dist/engine/AgentRuntime.mjs"},"./agent-updates":{"types":"./dist/core/AgentUpdates.d.mts","default":"./dist/core/AgentUpdates.mjs"},"./approval":{"types":"./dist/capabilities/Approval.d.mts","default":"./dist/capabilities/Approval.mjs"},"./budget":{"types":"./dist/capabilities/Budget.d.mts","default":"./dist/capabilities/Budget.mjs"},"./code-executor":{"types":"./dist/sandbox/CodeExecutor.d.mts","default":"./dist/sandbox/CodeExecutor.mjs"},"./code-mode":{"types":"./dist/capabilities/CodeMode.d.mts","default":"./dist/capabilities/CodeMode.mjs"},"./commands":{"types":"./dist/capabilities/Commands.d.mts","default":"./dist/capabilities/Commands.mjs"},"./committed-activity":{"types":"./dist/durable/CommittedActivity.d.mts","default":"./dist/durable/CommittedActivity.mjs"},"./compaction":{"types":"./dist/engine/Compaction.d.mts","default":"./dist/engine/Compaction.mjs"},"./context-compactor":{"types":"./dist/engine/ContextCompactor.d.mts","default":"./dist/engine/ContextCompactor.mjs"},"./context-history":{"types":"./dist/engine/ContextHistory.d.mts","default":"./dist/engine/ContextHistory.mjs"},"./context-tools":{"types":"./dist/capabilities/ContextTools.d.mts","default":"./dist/capabilities/ContextTools.mjs"},"./context-window":{"types":"./dist/engine/ContextWindow.d.mts","default":"./dist/engine/ContextWindow.mjs"},"./digest":{"types":"./dist/durable/Digest.d.mts","default":"./dist/durable/Digest.mjs"},"./durable-agent-runtime":{"types":"./dist/durable/DurableAgentRuntime.d.mts","default":"./dist/durable/DurableAgentRuntime.mjs"},"./durable-failpoint":{"types":"./dist/durable/DurableFailpoint.d.mts","default":"./dist/durable/DurableFailpoint.mjs"},"./durable-step":{"types":"./dist/engine/DurableStep.d.mts","default":"./dist/engine/DurableStep.mjs"},"./event-source":{"types":"./dist/durable/EventSource.d.mts","default":"./dist/durable/EventSource.mjs"},"./failure-diagnostic":{"types":"./dist/core/FailureDiagnostic.d.mts","default":"./dist/core/FailureDiagnostic.mjs"},"./git-hub-workflow-source":{"types":"./dist/durable/GitHubWorkflowSource.d.mts","default":"./dist/durable/GitHubWorkflowSource.mjs"},"./id-generator":{"types":"./dist/core/IdGenerator.d.mts","default":"./dist/core/IdGenerator.mjs"},"./identifiers":{"types":"./dist/core/Identifiers.d.mts","default":"./dist/core/Identifiers.mjs"},"./in-memory":{"types":"./dist/InMemory.d.mts","default":"./dist/InMemory.mjs"},"./interactive-browser":{"types":"./dist/sandbox/InteractiveBrowser.d.mts","default":"./dist/sandbox/InteractiveBrowser.mjs"},"./mcp":{"types":"./dist/capabilities/Mcp.d.mts","default":"./dist/capabilities/Mcp.mjs"},"./mcp-client":{"types":"./dist/capabilities/McpClient.d.mts","default":"./dist/capabilities/McpClient.mjs"},"./memory":{"types":"./dist/core/Memory.d.mts","default":"./dist/core/Memory.mjs"},"./memory-namespace":{"types":"./dist/core/MemoryNamespace.d.mts","default":"./dist/core/MemoryNamespace.mjs"},"./memory-notes":{"types":"./dist/capabilities/MemoryNotes.d.mts","default":"./dist/capabilities/MemoryNotes.mjs"},"./memory-reference":{"types":"./dist/core/MemoryReference.d.mts","default":"./dist/core/MemoryReference.mjs"},"./memory-revalidation":{"types":"./dist/core/MemoryRevalidation.d.mts","default":"./dist/core/MemoryRevalidation.mjs"},"./memory-store":{"types":"./dist/core/MemoryStore.d.mts","default":"./dist/core/MemoryStore.mjs"},"./message-delivery":{"types":"./dist/durable/MessageDelivery.d.mts","default":"./dist/durable/MessageDelivery.mjs"},"./messaging":{"types":"./dist/capabilities/Messaging.d.mts","default":"./dist/capabilities/Messaging.mjs"},"./messaging-host":{"types":"./dist/engine/MessagingHost.d.mts","default":"./dist/engine/MessagingHost.mjs"},"./model-context":{"types":"./dist/capabilities/ModelContext.d.mts","default":"./dist/capabilities/ModelContext.mjs"},"./operation-authorizer":{"types":"./dist/durable/OperationAuthorizer.d.mts","default":"./dist/durable/OperationAuthorizer.mjs"},"./output":{"types":"./dist/engine/Output.d.mts","default":"./dist/engine/Output.mjs"},"./page-capture":{"types":"./dist/sandbox/PageCapture.d.mts","default":"./dist/sandbox/PageCapture.mjs"},"./page-crawl":{"types":"./dist/sandbox/PageCrawl.d.mts","default":"./dist/sandbox/PageCrawl.mjs"},"./page-screenshot":{"types":"./dist/sandbox/PageScreenshot.d.mts","default":"./dist/sandbox/PageScreenshot.mjs"},"./persistent-history":{"types":"./dist/durable/PersistentHistory.d.mts","default":"./dist/durable/PersistentHistory.mjs"},"./prepared-input-admission":{"types":"./dist/durable/PreparedInputAdmission.d.mts","default":"./dist/durable/PreparedInputAdmission.mjs"},"./receipt":{"types":"./dist/core/Receipt.d.mts","default":"./dist/core/Receipt.mjs"},"./records":{"types":"./dist/durable/Records.d.mts","default":"./dist/durable/Records.mjs"},"./recovery":{"types":"./dist/durable/Recovery.d.mts","default":"./dist/durable/Recovery.mjs"},"./redaction":{"types":"./dist/capabilities/Redaction.d.mts","default":"./dist/capabilities/Redaction.mjs"},"./remembering":{"types":"./dist/capabilities/Remembering.d.mts","default":"./dist/capabilities/Remembering.mjs"},"./remembering-store":{"types":"./dist/core/RememberingStore.d.mts","default":"./dist/core/RememberingStore.mjs"},"./run-event":{"types":"./dist/core/RunEvent.d.mts","default":"./dist/core/RunEvent.mjs"},"./run-event-sink":{"types":"./dist/engine/RunEventSink.d.mts","default":"./dist/engine/RunEventSink.mjs"},"./run-hooks":{"types":"./dist/capabilities/RunHooks.d.mts","default":"./dist/capabilities/RunHooks.mjs"},"./run-journal":{"types":"./dist/durable/RunJournal.d.mts","default":"./dist/durable/RunJournal.mjs"},"./run-options":{"types":"./dist/engine/RunOptions.d.mts","default":"./dist/engine/RunOptions.mjs"},"./run-policy-usage":{"types":"./dist/core/RunPolicyUsage.d.mts","default":"./dist/core/RunPolicyUsage.mjs"},"./sandbox":{"types":"./dist/sandbox/Sandbox.d.mts","default":"./dist/sandbox/Sandbox.mjs"},"./schedule":{"types":"./dist/durable/Schedule.d.mts","default":"./dist/durable/Schedule.mjs"},"./schedule-transition":{"types":"./dist/durable/ScheduleTransition.d.mts","default":"./dist/durable/ScheduleTransition.mjs"},"./scheduling":{"types":"./dist/durable/Scheduling.d.mts","default":"./dist/durable/Scheduling.mjs"},"./semantic-memory":{"types":"./dist/capabilities/SemanticMemory.d.mts","default":"./dist/capabilities/SemanticMemory.mjs"},"./semantic-memory-index":{"types":"./dist/core/SemanticMemoryIndex.d.mts","default":"./dist/core/SemanticMemoryIndex.mjs"},"./semantic-memory-revalidation":{"types":"./dist/core/SemanticMemoryRevalidation.d.mts","default":"./dist/core/SemanticMemoryRevalidation.mjs"},"./sql-thread-native-reads":{"types":"./dist/durable/SqlThreadNativeReads.d.mts","default":"./dist/durable/SqlThreadNativeReads.mjs"},"./sql-memory-store":{"types":"./dist/durable/SqlMemoryStore.d.mts","default":"./dist/durable/SqlMemoryStore.mjs"},"./sql-message-delivery-store":{"types":"./dist/durable/SqlMessageDeliveryStore.d.mts","default":"./dist/durable/SqlMessageDeliveryStore.mjs"},"./sql-storage-v2-upgrade":{"types":"./dist/durable/SqlStorageV2Upgrade.d.mts","default":"./dist/durable/SqlStorageV2Upgrade.mjs"},"./sql-subscription-store":{"types":"./dist/durable/SqlSubscriptionStore.d.mts","default":"./dist/durable/SqlSubscriptionStore.mjs"},"./subagent":{"types":"./dist/capabilities/Subagent.d.mts","default":"./dist/capabilities/Subagent.mjs"},"./subagent-contract":{"types":"./dist/core/SubagentContract.d.mts","default":"./dist/core/SubagentContract.mjs"},"./subagent-host":{"types":"./dist/engine/SubagentHost.d.mts","default":"./dist/engine/SubagentHost.mjs"},"./subagent-reservations":{"types":"./dist/capabilities/SubagentReservations.d.mts","default":"./dist/capabilities/SubagentReservations.mjs"},"./submission-ledger":{"types":"./dist/durable/SubmissionLedger.d.mts","default":"./dist/durable/SubmissionLedger.mjs"},"./submission-status":{"types":"./dist/durable/SubmissionStatus.d.mts","default":"./dist/durable/SubmissionStatus.mjs"},"./subscription":{"types":"./dist/durable/Subscription.d.mts","default":"./dist/durable/Subscription.mjs"},"./subscription-input":{"types":"./dist/durable/SubscriptionInput.d.mts","default":"./dist/durable/SubscriptionInput.mjs"},"./subscription-tools":{"types":"./dist/durable/SubscriptionTools.d.mts","default":"./dist/durable/SubscriptionTools.mjs"},"./subscription-transition":{"types":"./dist/durable/SubscriptionTransition.d.mts","default":"./dist/durable/SubscriptionTransition.mjs"},"./subscriptions":{"types":"./dist/durable/Subscriptions.d.mts","default":"./dist/durable/Subscriptions.mjs"},"./testing/certification":{"types":"./dist/durable/Certification.d.mts","default":"./dist/durable/Certification.mjs"},"./testing/durable-failpoint-test-control":{"types":"./dist/durable/DurableFailpointTestControl.d.mts","default":"./dist/durable/DurableFailpointTestControl.mjs"},"./testing/message-delivery-store-conformance":{"types":"./dist/durable/MessageDeliveryStoreConformance.d.mts","default":"./dist/durable/MessageDeliveryStoreConformance.mjs"},"./testing/schedule-store-conformance":{"types":"./dist/durable/ScheduleStoreConformance.d.mts","default":"./dist/durable/ScheduleStoreConformance.mjs"},"./testing/submission-ledger-conformance":{"types":"./dist/durable/SubmissionLedgerConformance.d.mts","default":"./dist/durable/SubmissionLedgerConformance.mjs"},"./testing/subscription-store-conformance":{"types":"./dist/durable/SubscriptionStoreConformance.d.mts","default":"./dist/durable/SubscriptionStoreConformance.mjs"},"./testing/thread-store-conformance":{"types":"./dist/durable/ThreadStoreConformance.d.mts","default":"./dist/durable/ThreadStoreConformance.mjs"},"./thread":{"types":"./dist/core/Thread.d.mts","default":"./dist/core/Thread.mjs"},"./thread-context-history":{"types":"./dist/durable/ThreadContextHistory.d.mts","default":"./dist/durable/ThreadContextHistory.mjs"},"./thread-context-history-projection":{"types":"./dist/durable/ThreadContextHistoryProjection.d.mts","default":"./dist/durable/ThreadContextHistoryProjection.mjs"},"./thread-history":{"types":"./dist/engine/ThreadHistory.d.mts","default":"./dist/engine/ThreadHistory.mjs"},"./thread-invariants":{"types":"./dist/durable/ThreadInvariants.d.mts","default":"./dist/durable/ThreadInvariants.mjs"},"./thread-projection":{"types":"./dist/durable/ThreadProjection.d.mts","default":"./dist/durable/ThreadProjection.mjs"},"./thread-projection-maintenance":{"types":"./dist/durable/ThreadProjectionMaintenance.d.mts","default":"./dist/durable/ThreadProjectionMaintenance.mjs"},"./thread-store":{"types":"./dist/durable/ThreadStore.d.mts","default":"./dist/durable/ThreadStore.mjs"},"./tool-broker":{"types":"./dist/engine/ToolBroker.d.mts","default":"./dist/engine/ToolBroker.mjs"},"./tool-discovery":{"types":"./dist/capabilities/ToolDiscovery.d.mts","default":"./dist/capabilities/ToolDiscovery.mjs"},"./tool-exposure":{"types":"./dist/ToolExposure.d.mts","default":"./dist/ToolExposure.mjs"},"./tool-reconciler":{"types":"./dist/durable/ToolReconciler.d.mts","default":"./dist/durable/ToolReconciler.mjs"},"./tool-result":{"types":"./dist/core/ToolResult.d.mts","default":"./dist/core/ToolResult.mjs"},"./usage":{"types":"./dist/core/Usage.d.mts","default":"./dist/core/Usage.mjs"},"./wake-scheduler":{"types":"./dist/durable/WakeScheduler.d.mts","default":"./dist/durable/WakeScheduler.mjs"},"./web-capture":{"types":"./dist/capabilities/WebCapture.d.mts","default":"./dist/capabilities/WebCapture.mjs"},"./web-search":{"types":"./dist/capabilities/WebSearch.d.mts","default":"./dist/capabilities/WebSearch.mjs"},"./worker":{"types":"./dist/core/Worker.d.mts","default":"./dist/core/Worker.mjs"},"./worker-host":{"types":"./dist/durable/WorkerHost.d.mts","default":"./dist/durable/WorkerHost.mjs"}},"description":"Effect-native agents, execution, subagents, and sandbox contracts in one tree-shakeable package.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/danieljvdm/effect-agent.git","directory":"packages/effect-agent"},"files":["dist","src"],"type":"module","sideEffects":[],"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"tsc --noEmit -p tsconfig.json","test":"vp test --passWithNoTests"}}
|
|
@@ -377,6 +377,15 @@ const renderJsonSchemaType = (
|
|
|
377
377
|
if (isJsonSchemaRecord(schema.additionalProperties)) {
|
|
378
378
|
return `Record<string, ${renderJsonSchemaType(schema.additionalProperties, defs, depth + 1, indent)}>`;
|
|
379
379
|
}
|
|
380
|
+
// Schema.Record(Schema.String, Schema.Never) accepts only an empty object.
|
|
381
|
+
if (
|
|
382
|
+
type === "object" &&
|
|
383
|
+
!("properties" in schema) &&
|
|
384
|
+
!("patternProperties" in schema) &&
|
|
385
|
+
schema.additionalProperties === false
|
|
386
|
+
) {
|
|
387
|
+
return "Record<string, never>";
|
|
388
|
+
}
|
|
380
389
|
// A bare `{ "type": "object" }` states "any JSON object" (Schema.Json's
|
|
381
390
|
// object member derives to exactly this); rendering it as an
|
|
382
391
|
// unconstrained record is faithful, not a deriver degradation.
|