effect-agent 0.1.0-beta.122 → 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.
- package/dist/capabilities/CodeMode.mjs +1 -0
- package/dist/capabilities/CodeMode.mjs.map +1 -1
- package/dist/durable/MessageDelivery.d.mts +38 -38
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +38 -38
- package/dist/index.d.mts +2 -3
- package/dist/index.mjs +1 -2
- package/dist/sandbox/InteractiveBrowser.d.mts +1 -1
- package/dist/sandbox/PageScreenshot.d.mts +48 -2
- package/package.json +1 -1
- package/src/capabilities/CodeMode.ts +9 -0
- package/src/index.ts +0 -1
- package/dist/PageScreenshot-BpgZKAxl.d.mts +0 -48
- package/dist/sandbox/ProtectedBrowser.d.mts +0 -283
- package/dist/sandbox/ProtectedBrowser.mjs +0 -298
- package/dist/sandbox/ProtectedBrowser.mjs.map +0 -1
- package/src/sandbox/ProtectedBrowser.ts +0 -452
|
@@ -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,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;;;;;;;;AASJ,IAAa,kBAAb,cAAqC,OAAO,YAA6B,CAAC,CAAC,mBAAmB;CAC5F,UAAU;CACV,SAAS;CACT,MAAM;CACN,QAAQ,OAAO,YAAY,OAAO,IAAI;;CAEtC,OAAO,OAAO,YAAY,OAAO,MAAM,sBAA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AM,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"}
|
|
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 // 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,Y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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">;
|
|
@@ -93,6 +93,25 @@ export declare const makeMessageDeliveryFixture: (messageId?: any, owner?: any,
|
|
|
93
93
|
readonly reportKind?: "update" | undefined;
|
|
94
94
|
} | undefined;
|
|
95
95
|
readonly messageAdmission?: {
|
|
96
|
+
readonly schemaVersion: 1;
|
|
97
|
+
readonly message: {
|
|
98
|
+
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
99
|
+
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
100
|
+
};
|
|
101
|
+
readonly peerName: string;
|
|
102
|
+
readonly sender: {
|
|
103
|
+
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
104
|
+
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
105
|
+
};
|
|
106
|
+
readonly returnAddress: {
|
|
107
|
+
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
108
|
+
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
109
|
+
};
|
|
110
|
+
readonly inReplyTo?: {
|
|
111
|
+
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
112
|
+
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
113
|
+
} | undefined;
|
|
114
|
+
} | {
|
|
96
115
|
readonly _tag: "WorkerCompletion";
|
|
97
116
|
readonly budgetExhausted: boolean;
|
|
98
117
|
readonly schemaVersion: 1;
|
|
@@ -133,25 +152,6 @@ export declare const makeMessageDeliveryFixture: (messageId?: any, owner?: any,
|
|
|
133
152
|
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
134
153
|
};
|
|
135
154
|
readonly update: Update;
|
|
136
|
-
} | {
|
|
137
|
-
readonly schemaVersion: 1;
|
|
138
|
-
readonly message: {
|
|
139
|
-
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
140
|
-
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
141
|
-
};
|
|
142
|
-
readonly peerName: string;
|
|
143
|
-
readonly sender: {
|
|
144
|
-
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
145
|
-
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
146
|
-
};
|
|
147
|
-
readonly returnAddress: {
|
|
148
|
-
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
149
|
-
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
150
|
-
};
|
|
151
|
-
readonly inReplyTo?: {
|
|
152
|
-
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
153
|
-
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
154
|
-
} | undefined;
|
|
155
155
|
} | undefined;
|
|
156
156
|
};
|
|
157
157
|
readonly envelopeDigest: string & import("effect/Brand").Brand<"@effect-agent/thread/Digest">;
|
|
@@ -266,6 +266,25 @@ export declare const makeWorkerUpdateDeliveryFixture: (id: string) => Effect.Eff
|
|
|
266
266
|
readonly reportKind?: "update" | undefined;
|
|
267
267
|
} | undefined;
|
|
268
268
|
readonly messageAdmission?: {
|
|
269
|
+
readonly schemaVersion: 1;
|
|
270
|
+
readonly message: {
|
|
271
|
+
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
272
|
+
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
273
|
+
};
|
|
274
|
+
readonly peerName: string;
|
|
275
|
+
readonly sender: {
|
|
276
|
+
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
277
|
+
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
278
|
+
};
|
|
279
|
+
readonly returnAddress: {
|
|
280
|
+
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
281
|
+
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
282
|
+
};
|
|
283
|
+
readonly inReplyTo?: {
|
|
284
|
+
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
285
|
+
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
286
|
+
} | undefined;
|
|
287
|
+
} | {
|
|
269
288
|
readonly _tag: "WorkerCompletion";
|
|
270
289
|
readonly budgetExhausted: boolean;
|
|
271
290
|
readonly schemaVersion: 1;
|
|
@@ -306,25 +325,6 @@ export declare const makeWorkerUpdateDeliveryFixture: (id: string) => Effect.Eff
|
|
|
306
325
|
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
307
326
|
};
|
|
308
327
|
readonly update: Update;
|
|
309
|
-
} | {
|
|
310
|
-
readonly schemaVersion: 1;
|
|
311
|
-
readonly message: {
|
|
312
|
-
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
313
|
-
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
314
|
-
};
|
|
315
|
-
readonly peerName: string;
|
|
316
|
-
readonly sender: {
|
|
317
|
-
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
318
|
-
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
319
|
-
};
|
|
320
|
-
readonly returnAddress: {
|
|
321
|
-
readonly threadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
322
|
-
readonly agentId: string & import("effect/Brand").Brand<"@effect-agent/core/AgentId">;
|
|
323
|
-
};
|
|
324
|
-
readonly inReplyTo?: {
|
|
325
|
-
readonly ownerThreadId: string & import("effect/Brand").Brand<"@effect-agent/core/ThreadId">;
|
|
326
|
-
readonly messageId: string & import("effect/Brand").Brand<"@effect-agent/thread/IdempotencyKey">;
|
|
327
|
-
} | undefined;
|
|
328
328
|
} | undefined;
|
|
329
329
|
};
|
|
330
330
|
readonly envelopeDigest: string & import("effect/Brand").Brand<"@effect-agent/thread/Digest">;
|
package/dist/index.d.mts
CHANGED
|
@@ -84,8 +84,7 @@ import { t as ThreadProjectionMaintenance_d_exports } from "./durable/ThreadProj
|
|
|
84
84
|
import { t as WorkerHost_d_exports } from "./durable/WorkerHost.mjs";
|
|
85
85
|
import { t as Compaction_d_exports } from "./engine/Compaction.mjs";
|
|
86
86
|
import { t as Output_d_exports } from "./Output-V-6YL1_Z.mjs";
|
|
87
|
-
import {
|
|
87
|
+
import { t as PageScreenshot_d_exports } from "./sandbox/PageScreenshot.mjs";
|
|
88
88
|
import { t as InteractiveBrowser_d_exports } from "./sandbox/InteractiveBrowser.mjs";
|
|
89
89
|
import { t as PageCrawl_d_exports } from "./sandbox/PageCrawl.mjs";
|
|
90
|
-
|
|
91
|
-
export { ActivityStore_d_exports as ActivityStore, Admin_d_exports as Admin, Agent_d_exports as Agent, AgentError_d_exports as AgentError, AgentPolicy_d_exports as AgentPolicy, AgentRegistration_d_exports as AgentRegistration, AgentRuntime_d_exports as AgentRuntime, AgentUpdates_d_exports as AgentUpdates, Approval_d_exports as Approval, Budget_d_exports as Budget, CodeExecutor_d_exports as CodeExecutor, CodeMode_d_exports as CodeMode, Commands_d_exports as Commands, CommittedActivity_d_exports as CommittedActivity, Compaction_d_exports as Compaction, ContextCompactor_d_exports as ContextCompactor, ContextHistory_d_exports as ContextHistory, ContextTools_d_exports as ContextTools, ContextWindow_d_exports as ContextWindow, Digest_d_exports as Digest, DurableAgentRuntime_d_exports as DurableAgentRuntime, DurableFailpoint_d_exports as DurableFailpoint, DurableStep_d_exports as DurableStep, EventSource_d_exports as EventSource, FailureDiagnostic_d_exports as FailureDiagnostic, IdGenerator_d_exports as IdGenerator, Identifiers_d_exports as Identifiers, InMemory_d_exports as InMemory, InteractiveBrowser_d_exports as InteractiveBrowser, Mcp_d_exports as Mcp, McpClient_d_exports as McpClient, Memory_d_exports as Memory, MemoryNamespace_d_exports as MemoryNamespace, MemoryNotes_d_exports as MemoryNotes, MemoryReference_d_exports as MemoryReference, MemoryRevalidation_d_exports as MemoryRevalidation, MemoryStore_d_exports as MemoryStore, MessageDelivery_d_exports as MessageDelivery, Messaging_d_exports as Messaging, MessagingHost_d_exports as MessagingHost, ModelContext_d_exports as ModelContext, OperationAuthorizer_d_exports as OperationAuthorizer, Output_d_exports as Output, PageCapture_d_exports as PageCapture, PageCrawl_d_exports as PageCrawl, PageScreenshot_d_exports as PageScreenshot, PersistentHistory_d_exports as PersistentHistory, PreparedInputAdmission_d_exports as PreparedInputAdmission, ProtectedBrowser_d_exports as ProtectedBrowser, Receipt_d_exports as Receipt, Records_d_exports as Records, Recovery_d_exports as Recovery, Redaction_d_exports as Redaction, Remembering_d_exports as Remembering, RememberingStore_d_exports as RememberingStore, RunEvent_d_exports as RunEvent, RunEventSink_d_exports as RunEventSink, RunHooks_d_exports as RunHooks, RunJournal_d_exports as RunJournal, RunOptions_d_exports as RunOptions, RunPolicyUsage_d_exports as RunPolicyUsage, Sandbox_d_exports as Sandbox, Schedule_d_exports as Schedule, ScheduleTransition_d_exports as ScheduleTransition, Scheduling_d_exports as Scheduling, SemanticMemory_d_exports as SemanticMemory, SemanticMemoryIndex_d_exports as SemanticMemoryIndex, SemanticMemoryRevalidation_d_exports as SemanticMemoryRevalidation, SqlThreadNativeReads_d_exports as SqlThreadNativeReads, Subagent_d_exports as Subagent, SubagentContract_d_exports as SubagentContract, SubagentHost_d_exports as SubagentHost, SubagentReservations_d_exports as SubagentReservations, SubmissionLedger_d_exports as SubmissionLedger, SubmissionStatus_d_exports as SubmissionStatus, Subscription_d_exports as Subscription, SubscriptionInput_d_exports as SubscriptionInput, SubscriptionTools_d_exports as SubscriptionTools, SubscriptionTransition_d_exports as SubscriptionTransition, Subscriptions_d_exports as Subscriptions, Thread_d_exports as Thread, ThreadContextHistory_d_exports as ThreadContextHistory, ThreadContextHistoryProjection_d_exports as ThreadContextHistoryProjection, ThreadHistory_d_exports as ThreadHistory, ThreadInvariants_d_exports as ThreadInvariants, ThreadProjection_d_exports as ThreadProjection, ThreadProjectionMaintenance_d_exports as ThreadProjectionMaintenance, ThreadStore_d_exports as ThreadStore, ToolBroker_d_exports as ToolBroker, ToolDiscovery_d_exports as ToolDiscovery, ToolExposure_d_exports as ToolExposure, ToolReconciler_d_exports as ToolReconciler, ToolResult_d_exports as ToolResult, Usage_d_exports as Usage, WakeScheduler_d_exports as WakeScheduler, WebCapture_d_exports as WebCapture, WebSearch_d_exports as WebSearch, Worker_d_exports as Worker, WorkerHost_d_exports as WorkerHost };
|
|
90
|
+
export { ActivityStore_d_exports as ActivityStore, Admin_d_exports as Admin, Agent_d_exports as Agent, AgentError_d_exports as AgentError, AgentPolicy_d_exports as AgentPolicy, AgentRegistration_d_exports as AgentRegistration, AgentRuntime_d_exports as AgentRuntime, AgentUpdates_d_exports as AgentUpdates, Approval_d_exports as Approval, Budget_d_exports as Budget, CodeExecutor_d_exports as CodeExecutor, CodeMode_d_exports as CodeMode, Commands_d_exports as Commands, CommittedActivity_d_exports as CommittedActivity, Compaction_d_exports as Compaction, ContextCompactor_d_exports as ContextCompactor, ContextHistory_d_exports as ContextHistory, ContextTools_d_exports as ContextTools, ContextWindow_d_exports as ContextWindow, Digest_d_exports as Digest, DurableAgentRuntime_d_exports as DurableAgentRuntime, DurableFailpoint_d_exports as DurableFailpoint, DurableStep_d_exports as DurableStep, EventSource_d_exports as EventSource, FailureDiagnostic_d_exports as FailureDiagnostic, IdGenerator_d_exports as IdGenerator, Identifiers_d_exports as Identifiers, InMemory_d_exports as InMemory, InteractiveBrowser_d_exports as InteractiveBrowser, Mcp_d_exports as Mcp, McpClient_d_exports as McpClient, Memory_d_exports as Memory, MemoryNamespace_d_exports as MemoryNamespace, MemoryNotes_d_exports as MemoryNotes, MemoryReference_d_exports as MemoryReference, MemoryRevalidation_d_exports as MemoryRevalidation, MemoryStore_d_exports as MemoryStore, MessageDelivery_d_exports as MessageDelivery, Messaging_d_exports as Messaging, MessagingHost_d_exports as MessagingHost, ModelContext_d_exports as ModelContext, OperationAuthorizer_d_exports as OperationAuthorizer, Output_d_exports as Output, PageCapture_d_exports as PageCapture, PageCrawl_d_exports as PageCrawl, PageScreenshot_d_exports as PageScreenshot, PersistentHistory_d_exports as PersistentHistory, PreparedInputAdmission_d_exports as PreparedInputAdmission, Receipt_d_exports as Receipt, Records_d_exports as Records, Recovery_d_exports as Recovery, Redaction_d_exports as Redaction, Remembering_d_exports as Remembering, RememberingStore_d_exports as RememberingStore, RunEvent_d_exports as RunEvent, RunEventSink_d_exports as RunEventSink, RunHooks_d_exports as RunHooks, RunJournal_d_exports as RunJournal, RunOptions_d_exports as RunOptions, RunPolicyUsage_d_exports as RunPolicyUsage, Sandbox_d_exports as Sandbox, Schedule_d_exports as Schedule, ScheduleTransition_d_exports as ScheduleTransition, Scheduling_d_exports as Scheduling, SemanticMemory_d_exports as SemanticMemory, SemanticMemoryIndex_d_exports as SemanticMemoryIndex, SemanticMemoryRevalidation_d_exports as SemanticMemoryRevalidation, SqlThreadNativeReads_d_exports as SqlThreadNativeReads, Subagent_d_exports as Subagent, SubagentContract_d_exports as SubagentContract, SubagentHost_d_exports as SubagentHost, SubagentReservations_d_exports as SubagentReservations, SubmissionLedger_d_exports as SubmissionLedger, SubmissionStatus_d_exports as SubmissionStatus, Subscription_d_exports as Subscription, SubscriptionInput_d_exports as SubscriptionInput, SubscriptionTools_d_exports as SubscriptionTools, SubscriptionTransition_d_exports as SubscriptionTransition, Subscriptions_d_exports as Subscriptions, Thread_d_exports as Thread, ThreadContextHistory_d_exports as ThreadContextHistory, ThreadContextHistoryProjection_d_exports as ThreadContextHistoryProjection, ThreadHistory_d_exports as ThreadHistory, ThreadInvariants_d_exports as ThreadInvariants, ThreadProjection_d_exports as ThreadProjection, ThreadProjectionMaintenance_d_exports as ThreadProjectionMaintenance, ThreadStore_d_exports as ThreadStore, ToolBroker_d_exports as ToolBroker, ToolDiscovery_d_exports as ToolDiscovery, ToolExposure_d_exports as ToolExposure, ToolReconciler_d_exports as ToolReconciler, ToolResult_d_exports as ToolResult, Usage_d_exports as Usage, WakeScheduler_d_exports as WakeScheduler, WebCapture_d_exports as WebCapture, WebSearch_d_exports as WebSearch, Worker_d_exports as Worker, WorkerHost_d_exports as WorkerHost };
|
package/dist/index.mjs
CHANGED
|
@@ -50,7 +50,6 @@ import { t as Output_exports } from "./engine/Output.mjs";
|
|
|
50
50
|
import { t as PageCapture_exports } from "./sandbox/PageCapture.mjs";
|
|
51
51
|
import { t as PageCrawl_exports } from "./sandbox/PageCrawl.mjs";
|
|
52
52
|
import { t as PageScreenshot_exports } from "./sandbox/PageScreenshot.mjs";
|
|
53
|
-
import { t as ProtectedBrowser_exports } from "./sandbox/ProtectedBrowser.mjs";
|
|
54
53
|
import { t as RememberingStore_exports } from "./core/RememberingStore.mjs";
|
|
55
54
|
import { t as Remembering_exports } from "./capabilities/Remembering.mjs";
|
|
56
55
|
import { t as RunHooks_exports } from "./capabilities/RunHooks.mjs";
|
|
@@ -97,4 +96,4 @@ import { t as ThreadProjectionMaintenance_exports } from "./durable/ThreadProjec
|
|
|
97
96
|
import { t as ThreadContextHistoryProjection_exports } from "./durable/ThreadContextHistoryProjection.mjs";
|
|
98
97
|
import { t as ThreadContextHistory_exports } from "./durable/ThreadContextHistory.mjs";
|
|
99
98
|
import { t as SqlThreadNativeReads_exports } from "./durable/SqlThreadNativeReads.mjs";
|
|
100
|
-
export { ActivityStore_exports as ActivityStore, Admin_exports as Admin, Agent_exports as Agent, AgentError_exports as AgentError, AgentPolicy_exports as AgentPolicy, AgentRegistration_exports as AgentRegistration, AgentRuntime_exports as AgentRuntime, AgentUpdates_exports as AgentUpdates, Approval_exports as Approval, Budget_exports as Budget, CodeExecutor_exports as CodeExecutor, CodeMode_exports as CodeMode, Commands_exports as Commands, CommittedActivity_exports as CommittedActivity, Compaction_exports as Compaction, ContextCompactor_exports as ContextCompactor, ContextHistory_exports as ContextHistory, ContextTools_exports as ContextTools, ContextWindow_exports as ContextWindow, Digest_exports as Digest, DurableAgentRuntime_exports as DurableAgentRuntime, DurableFailpoint_exports as DurableFailpoint, DurableStep_exports as DurableStep, EventSource_exports as EventSource, FailureDiagnostic_exports as FailureDiagnostic, IdGenerator_exports as IdGenerator, Identifiers_exports as Identifiers, InMemory_exports as InMemory, InteractiveBrowser_exports as InteractiveBrowser, Mcp_exports as Mcp, McpClient_exports as McpClient, Memory_exports as Memory, MemoryNamespace_exports as MemoryNamespace, MemoryNotes_exports as MemoryNotes, MemoryReference_exports as MemoryReference, MemoryRevalidation_exports as MemoryRevalidation, MemoryStore_exports as MemoryStore, MessageDelivery_exports as MessageDelivery, Messaging_exports as Messaging, MessagingHost_exports as MessagingHost, ModelContext_exports as ModelContext, OperationAuthorizer_exports as OperationAuthorizer, Output_exports as Output, PageCapture_exports as PageCapture, PageCrawl_exports as PageCrawl, PageScreenshot_exports as PageScreenshot, PersistentHistory_exports as PersistentHistory, PreparedInputAdmission_exports as PreparedInputAdmission,
|
|
99
|
+
export { ActivityStore_exports as ActivityStore, Admin_exports as Admin, Agent_exports as Agent, AgentError_exports as AgentError, AgentPolicy_exports as AgentPolicy, AgentRegistration_exports as AgentRegistration, AgentRuntime_exports as AgentRuntime, AgentUpdates_exports as AgentUpdates, Approval_exports as Approval, Budget_exports as Budget, CodeExecutor_exports as CodeExecutor, CodeMode_exports as CodeMode, Commands_exports as Commands, CommittedActivity_exports as CommittedActivity, Compaction_exports as Compaction, ContextCompactor_exports as ContextCompactor, ContextHistory_exports as ContextHistory, ContextTools_exports as ContextTools, ContextWindow_exports as ContextWindow, Digest_exports as Digest, DurableAgentRuntime_exports as DurableAgentRuntime, DurableFailpoint_exports as DurableFailpoint, DurableStep_exports as DurableStep, EventSource_exports as EventSource, FailureDiagnostic_exports as FailureDiagnostic, IdGenerator_exports as IdGenerator, Identifiers_exports as Identifiers, InMemory_exports as InMemory, InteractiveBrowser_exports as InteractiveBrowser, Mcp_exports as Mcp, McpClient_exports as McpClient, Memory_exports as Memory, MemoryNamespace_exports as MemoryNamespace, MemoryNotes_exports as MemoryNotes, MemoryReference_exports as MemoryReference, MemoryRevalidation_exports as MemoryRevalidation, MemoryStore_exports as MemoryStore, MessageDelivery_exports as MessageDelivery, Messaging_exports as Messaging, MessagingHost_exports as MessagingHost, ModelContext_exports as ModelContext, OperationAuthorizer_exports as OperationAuthorizer, Output_exports as Output, PageCapture_exports as PageCapture, PageCrawl_exports as PageCrawl, PageScreenshot_exports as PageScreenshot, PersistentHistory_exports as PersistentHistory, PreparedInputAdmission_exports as PreparedInputAdmission, Receipt_exports as Receipt, Records_exports as Records, Recovery_exports as Recovery, Redaction_exports as Redaction, Remembering_exports as Remembering, RememberingStore_exports as RememberingStore, RunEvent_exports as RunEvent, RunEventSink_exports as RunEventSink, RunHooks_exports as RunHooks, RunJournal_exports as RunJournal, RunOptions_exports as RunOptions, RunPolicyUsage_exports as RunPolicyUsage, Sandbox_exports as Sandbox, Schedule_exports as Schedule, ScheduleTransition_exports as ScheduleTransition, Scheduling_exports as Scheduling, SemanticMemory_exports as SemanticMemory, SemanticMemoryIndex_exports as SemanticMemoryIndex, SemanticMemoryRevalidation_exports as SemanticMemoryRevalidation, SqlThreadNativeReads_exports as SqlThreadNativeReads, Subagent_exports as Subagent, SubagentContract_exports as SubagentContract, SubagentHost_exports as SubagentHost, SubagentReservations_exports as SubagentReservations, SubmissionLedger_exports as SubmissionLedger, SubmissionStatus_exports as SubmissionStatus, Subscription_exports as Subscription, SubscriptionInput_exports as SubscriptionInput, SubscriptionTools_exports as SubscriptionTools, SubscriptionTransition_exports as SubscriptionTransition, Subscriptions_exports as Subscriptions, Thread_exports as Thread, ThreadContextHistory_exports as ThreadContextHistory, ThreadContextHistoryProjection_exports as ThreadContextHistoryProjection, ThreadHistory_exports as ThreadHistory, ThreadInvariants_exports as ThreadInvariants, ThreadProjection_exports as ThreadProjection, ThreadProjectionMaintenance_exports as ThreadProjectionMaintenance, ThreadStore_exports as ThreadStore, ToolBroker_exports as ToolBroker, ToolDiscovery_exports as ToolDiscovery, ToolExposure_exports as ToolExposure, ToolReconciler_exports as ToolReconciler, ToolResult_exports as ToolResult, Usage_exports as Usage, WakeScheduler_exports as WakeScheduler, WebCapture_exports as WebCapture, WebSearch_exports as WebSearch, Worker_exports as Worker, WorkerHost_exports as WorkerHost };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { p as SandboxImplementation } from "../Sandbox-CEsDWBLq.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { PageScreenshotResult } from "./PageScreenshot.mjs";
|
|
3
3
|
import { Context, Effect, Schema, Scope } from "effect";
|
|
4
4
|
declare namespace InteractiveBrowser_d_exports {
|
|
5
5
|
export { BrowserActionResult, BrowserClickRequest, BrowserExpectedTarget, BrowserExpectedTargetState, BrowserFileSelectionResult, BrowserFillRequest, BrowserHandle, BrowserNavigateRequest, BrowserNavigationResult, BrowserReadTextRequest, BrowserScreenshotRequest, BrowserScrollRequest, BrowserSelectFileRequest, BrowserTextResult, InteractiveBrowser, InteractiveBrowserActionError, InteractiveBrowserBusyError, InteractiveBrowserCapacityError, InteractiveBrowserError, InteractiveBrowserExpiredError, InteractiveBrowserFailureEvidence, InteractiveBrowserHost, InteractiveBrowserLimitError, InteractiveBrowserNetworkPolicy, InteractiveBrowserPolicy, InteractiveBrowserPolicyDeniedError, InteractiveBrowserProtocolError, InteractiveBrowserTargetUrl, InteractiveBrowserUnsupportedError };
|
|
@@ -1,2 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { p as SandboxImplementation } from "../Sandbox-CEsDWBLq.mjs";
|
|
2
|
+
import { B as PageUrlTarget, E as PageCaptureUnsupportedError, M as PageNavigationOptions, N as PageResourcePolicy, V as PageViewport, h as PageCaptureNavigationError, k as PageHtmlTarget, v as PageCaptureProtocolError, y as PageCaptureRateLimitedError } from "../PageCapture-Df8Xwskw.mjs";
|
|
3
|
+
import { Context, Effect, Schema } from "effect";
|
|
4
|
+
declare namespace PageScreenshot_d_exports {
|
|
5
|
+
export { PageScreenshot, PageScreenshotCapture, PageScreenshotError, PageScreenshotLimits, PageScreenshotOutputLimitError, PageScreenshotRequest, PageScreenshotResult };
|
|
6
|
+
}
|
|
7
|
+
declare const PageScreenshotLimits_base: Schema.Class<PageScreenshotLimits, Schema.Struct<{
|
|
8
|
+
readonly maxOutputBytes: Schema.Int;
|
|
9
|
+
}>, {}>;
|
|
10
|
+
/** The byte limit and full-page choice are fixed before Browser Run starts. */
|
|
11
|
+
export declare class PageScreenshotLimits extends PageScreenshotLimits_base {}
|
|
12
|
+
declare const PageScreenshotRequest_base: Schema.Class<PageScreenshotRequest, Schema.Struct<{
|
|
13
|
+
readonly target: Schema.Union<readonly [typeof PageUrlTarget, typeof PageHtmlTarget]>;
|
|
14
|
+
readonly engine: Schema.Literals<readonly ["chromium", "kitesurf"]>;
|
|
15
|
+
readonly limits: typeof PageScreenshotLimits;
|
|
16
|
+
readonly fullPage: Schema.Boolean;
|
|
17
|
+
readonly navigation: Schema.optionalKey<typeof PageNavigationOptions>;
|
|
18
|
+
readonly viewport: Schema.optionalKey<typeof PageViewport>;
|
|
19
|
+
readonly resourcePolicy: Schema.optionalKey<typeof PageResourcePolicy>;
|
|
20
|
+
}>, {}>;
|
|
21
|
+
/** Schema-first request for exactly one PNG screenshot. */
|
|
22
|
+
export declare class PageScreenshotRequest extends PageScreenshotRequest_base {}
|
|
23
|
+
declare const PageScreenshotResult_base: Schema.Class<PageScreenshotResult, Schema.Struct<{
|
|
24
|
+
readonly implementation: typeof SandboxImplementation;
|
|
25
|
+
readonly mediaType: Schema.Literal<"image/png">;
|
|
26
|
+
readonly bytes: Schema.Uint8Array;
|
|
27
|
+
}>, {}>;
|
|
28
|
+
/** The only successful output: bytes are caller-owned and never durable framework data. */
|
|
29
|
+
export declare class PageScreenshotResult extends PageScreenshotResult_base {}
|
|
30
|
+
declare const PageScreenshotOutputLimitError_base: Schema.Class<PageScreenshotOutputLimitError, Schema.TaggedStruct<"PageScreenshotOutputLimitError", {
|
|
31
|
+
readonly implementation: typeof SandboxImplementation;
|
|
32
|
+
readonly limit: Schema.Int;
|
|
33
|
+
readonly observed: Schema.Natural;
|
|
34
|
+
}>, import("effect/Cause").YieldableError>;
|
|
35
|
+
/** The response crossed the request's PNG byte limit. */
|
|
36
|
+
export declare class PageScreenshotOutputLimitError extends PageScreenshotOutputLimitError_base {}
|
|
37
|
+
/** Expected screenshot failures. The shared capture errors keep identical semantics. */
|
|
38
|
+
export declare const PageScreenshotError: Schema.Union<readonly [typeof PageCaptureRateLimitedError, typeof PageCaptureNavigationError, typeof PageCaptureUnsupportedError, typeof PageCaptureProtocolError, typeof PageScreenshotOutputLimitError]>;
|
|
39
|
+
export type PageScreenshotError = typeof PageScreenshotError.Type;
|
|
40
|
+
declare const PageScreenshot_base: Context.ServiceClass<PageScreenshot, "@effect-agent/sandbox/PageScreenshot", {
|
|
41
|
+
readonly capture: (request: PageScreenshotRequest) => Effect.Effect<PageScreenshotResult, PageScreenshotError>;
|
|
42
|
+
}>;
|
|
43
|
+
/** Stateless, one-output PNG capture port. It owns neither persistence nor later byte handoff. */
|
|
44
|
+
export declare class PageScreenshot extends PageScreenshot_base {}
|
|
45
|
+
export type PageScreenshotCapture = (request: PageScreenshotRequest) => Effect.Effect<PageScreenshotResult, PageScreenshotError>;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { PageScreenshot_d_exports as t };
|
|
48
|
+
//# sourceMappingURL=PageScreenshot.d.mts.map
|