@poe-platform/safe-js 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +206 -0
- package/dist/agent-defs/agents/claude-code.d.ts +2 -0
- package/dist/agent-defs/agents/claude-desktop.d.ts +2 -0
- package/dist/agent-defs/agents/codex.d.ts +2 -0
- package/dist/agent-defs/agents/cursor.d.ts +2 -0
- package/dist/agent-defs/agents/gemini-cli.d.ts +2 -0
- package/dist/agent-defs/agents/goose.d.ts +2 -0
- package/dist/agent-defs/agents/index.d.ts +10 -0
- package/dist/agent-defs/agents/kimi.d.ts +2 -0
- package/dist/agent-defs/agents/opencode.d.ts +2 -0
- package/dist/agent-defs/agents/pi.d.ts +2 -0
- package/dist/agent-defs/agents/poe-agent.d.ts +2 -0
- package/dist/agent-defs/capabilities.d.ts +14 -0
- package/dist/agent-defs/index.d.ts +6 -0
- package/dist/agent-defs/registry.d.ts +3 -0
- package/dist/agent-defs/specifier.d.ts +7 -0
- package/dist/agent-defs/types.d.ts +35 -0
- package/dist/agent-harness-tools/binary-exists.d.ts +10 -0
- package/dist/agent-harness-tools/execution-env.d.ts +108 -0
- package/dist/agent-harness-tools/hooks.d.ts +30 -0
- package/dist/agent-harness-tools/index.d.ts +18 -0
- package/dist/agent-harness-tools/log-stream.d.ts +28 -0
- package/dist/agent-harness-tools/participant.d.ts +10 -0
- package/dist/agent-harness-tools/paths.d.ts +14 -0
- package/dist/agent-harness-tools/plan-readiness.d.ts +7 -0
- package/dist/agent-harness-tools/plans.d.ts +35 -0
- package/dist/agent-harness-tools/poe-command-execution.d.ts +37 -0
- package/dist/agent-harness-tools/run-logs.d.ts +17 -0
- package/dist/agent-harness-tools/run-poe-command.d.ts +33 -0
- package/dist/agent-harness-tools/runner.d.ts +33 -0
- package/dist/agent-harness-tools/select-agent.d.ts +18 -0
- package/dist/agent-harness-tools/sequence.d.ts +7 -0
- package/dist/agent-harness-tools/skill-config.d.ts +1 -0
- package/dist/agent-harness-tools/stage.d.ts +22 -0
- package/dist/agent-harness-tools/workspace-transfer.d.ts +3 -0
- package/dist/agent-spawn/acp/middleware.d.ts +38 -0
- package/dist/agent-spawn/acp/types.d.ts +180 -0
- package/dist/agent-spawn/adapters/claude.d.ts +3 -0
- package/dist/agent-spawn/adapters/codex.d.ts +2 -0
- package/dist/agent-spawn/adapters/cursor.d.ts +2 -0
- package/dist/agent-spawn/adapters/index.d.ts +12 -0
- package/dist/agent-spawn/adapters/kimi.d.ts +2 -0
- package/dist/agent-spawn/adapters/native.d.ts +5 -0
- package/dist/agent-spawn/adapters/opencode.d.ts +2 -0
- package/dist/agent-spawn/adapters/pi.d.ts +2 -0
- package/dist/agent-spawn/environment.d.ts +2 -0
- package/dist/agent-spawn/parallel.d.ts +30 -0
- package/dist/agent-spawn/retry.d.ts +26 -0
- package/dist/agent-spawn/types.d.ts +272 -0
- package/dist/auth-store/create-secret-store.d.ts +2 -0
- package/dist/auth-store/encrypted-file-store.d.ts +47 -0
- package/dist/auth-store/index.d.ts +7 -0
- package/dist/auth-store/keychain-store.d.ts +25 -0
- package/dist/auth-store/provider-store.d.ts +14 -0
- package/dist/auth-store/types.d.ts +22 -0
- package/dist/config-mutations/execution/run-mutations.d.ts +7 -0
- package/dist/config-mutations/fs-utils.d.ts +18 -0
- package/dist/config-mutations/index.d.ts +8 -0
- package/dist/config-mutations/mutations/config-mutation.d.ts +47 -0
- package/dist/config-mutations/mutations/file-mutation.d.ts +62 -0
- package/dist/config-mutations/mutations/template-mutation.d.ts +40 -0
- package/dist/config-mutations/template/render.d.ts +6 -0
- package/dist/config-mutations/types.d.ts +168 -0
- package/dist/poe-code-config/compile/schema-compiler.d.ts +11 -0
- package/dist/poe-code-config/config.d.ts +2 -0
- package/dist/poe-code-config/configured-services.d.ts +29 -0
- package/dist/poe-code-config/index.d.ts +16 -0
- package/dist/poe-code-config/inspect.d.ts +13 -0
- package/dist/poe-code-config/memory.d.ts +14 -0
- package/dist/poe-code-config/merge-callbacks.d.ts +38 -0
- package/dist/poe-code-config/merge.d.ts +2 -0
- package/dist/poe-code-config/plan-scope.d.ts +8 -0
- package/dist/poe-code-config/provider-config.d.ts +16 -0
- package/dist/poe-code-config/resolve.d.ts +2 -0
- package/dist/poe-code-config/runtime.d.ts +114 -0
- package/dist/poe-code-config/schema.d.ts +14 -0
- package/dist/poe-code-config/state/fs.d.ts +24 -0
- package/dist/poe-code-config/state/index.d.ts +12 -0
- package/dist/poe-code-config/state/jobs.d.ts +34 -0
- package/dist/poe-code-config/state/templates.d.ts +18 -0
- package/dist/poe-code-config/store.d.ts +12 -0
- package/dist/poe-code-config/types.d.ts +88 -0
- package/dist/process-runner/docker/build-context.d.ts +5 -0
- package/dist/process-runner/docker/context.d.ts +3 -0
- package/dist/process-runner/docker/docker-execution-env.d.ts +28 -0
- package/dist/process-runner/docker/docker-runner.d.ts +2 -0
- package/dist/process-runner/docker/engine.d.ts +3 -0
- package/dist/process-runner/host/host-execution-env.d.ts +2 -0
- package/dist/process-runner/host/host-runner.d.ts +3 -0
- package/dist/process-runner/index.d.ts +10 -0
- package/dist/process-runner/testing/index.d.ts +2 -0
- package/dist/process-runner/testing/mock-runner.d.ts +3 -0
- package/dist/process-runner/types.d.ts +191 -0
- package/dist/process-runner/workspace-transfer.d.ts +61 -0
- package/dist/providers/auth/api-key.d.ts +5 -0
- package/dist/providers/auth/types.d.ts +14 -0
- package/dist/providers/compatibility.d.ts +4 -0
- package/dist/providers/index.d.ts +8 -0
- package/dist/providers/providers/anthropic.d.ts +1 -0
- package/dist/providers/providers/cloudflare.d.ts +1 -0
- package/dist/providers/providers/generated.d.ts +5 -0
- package/dist/providers/providers/openai.d.ts +1 -0
- package/dist/providers/providers/poe.d.ts +2 -0
- package/dist/providers/registry.d.ts +44 -0
- package/dist/providers/types.d.ts +54 -0
- package/dist/safe-fs/bridge/filesystem.d.ts +88 -0
- package/dist/safe-fs/bridge/index.d.ts +6 -0
- package/dist/safe-fs/bridge/types.d.ts +75 -0
- package/dist/safe-fs/config.d.ts +15 -0
- package/dist/safe-fs/config.node.d.ts +2 -0
- package/dist/safe-fs/contracts/errors.d.ts +50 -0
- package/dist/safe-fs/contracts/filesystem.d.ts +96 -0
- package/dist/safe-fs/contracts/index.d.ts +4 -0
- package/dist/safe-fs/contracts/io.d.ts +8 -0
- package/dist/safe-fs/contracts/path.d.ts +8 -0
- package/dist/safe-fs/contracts/portable-path.d.ts +13 -0
- package/dist/safe-fs/contracts/virtual-path.d.ts +7 -0
- package/dist/safe-fs/core.d.ts +12 -0
- package/dist/safe-fs/fs/memory/index.d.ts +58 -0
- package/dist/safe-fs/fs/mount/comparison.d.ts +19 -0
- package/dist/safe-fs/fs/mount/index.d.ts +44 -0
- package/dist/safe-fs/fs/overlay/index.d.ts +73 -0
- package/dist/safe-fs/fs/readonly/index.d.ts +31 -0
- package/dist/safe-fs/fs/real/index.d.ts +76 -0
- package/dist/safe-fs/fs/s3/filesystem.d.ts +93 -0
- package/dist/safe-fs/fs/s3/http/index.d.ts +2 -0
- package/dist/safe-fs/fs/s3/http/transport.d.ts +3 -0
- package/dist/safe-fs/fs/s3/http/types.d.ts +30 -0
- package/dist/safe-fs/fs/s3/index.d.ts +6 -0
- package/dist/safe-fs/fs/s3/mock.d.ts +48 -0
- package/dist/safe-fs/fs/s3/transport.d.ts +103 -0
- package/dist/safe-fs/fs/webdav/index.d.ts +2 -0
- package/dist/safe-fs/fs/webdav/webdav.d.ts +101 -0
- package/dist/safe-fs/index.d.ts +14 -0
- package/dist/safe-fs/node/filesystem.d.ts +11 -0
- package/dist/safe-fs/node/index.d.ts +2 -0
- package/dist/safe-fs/node-host.d.ts +1 -0
- package/dist/safe-fs/node-unavailable.d.ts +1 -0
- package/dist/safe-fs/platform/browser.d.ts +12 -0
- package/dist/safe-fs/platform/node.d.ts +13 -0
- package/dist/safe-js/browser/chunks/chunk-QGN6DKT5.js +4335 -0
- package/dist/safe-js/browser/chunks/chunk-QGN6DKT5.js.map +7 -0
- package/dist/safe-js/browser/safe-fs-core.js +67 -0
- package/dist/safe-js/browser/safe-fs-core.js.map +7 -0
- package/dist/safe-js/browser/safe-fs.js +67 -0
- package/dist/safe-js/browser/safe-fs.js.map +7 -0
- package/dist/safe-js/chunks/chunk-2QRYPKQQ.js +4315 -0
- package/dist/safe-js/chunks/chunk-2QRYPKQQ.js.map +7 -0
- package/dist/safe-js/chunks/chunk-4YIDX44G.js +40 -0
- package/dist/safe-js/chunks/chunk-4YIDX44G.js.map +7 -0
- package/dist/safe-js/chunks/chunk-7M2SJPSZ.js +2613 -0
- package/dist/safe-js/chunks/chunk-7M2SJPSZ.js.map +7 -0
- package/dist/safe-js/chunks/chunk-DC5B3GYM.js +8248 -0
- package/dist/safe-js/chunks/chunk-DC5B3GYM.js.map +7 -0
- package/dist/safe-js/chunks/chunk-Z3D76J4U.js +30732 -0
- package/dist/safe-js/chunks/chunk-Z3D76J4U.js.map +7 -0
- package/dist/safe-js/cli.d.ts +36 -0
- package/dist/safe-js/cli.js +724 -0
- package/dist/safe-js/cli.js.map +7 -0
- package/dist/safe-js/core.d.ts +6 -0
- package/dist/safe-js/core.js +14 -0
- package/dist/safe-js/core.js.map +7 -0
- package/dist/safe-js/dump.d.ts +2 -0
- package/dist/safe-js/error/format.d.ts +15 -0
- package/dist/safe-js/error/shape.d.ts +28 -0
- package/dist/safe-js/index.d.ts +56 -0
- package/dist/safe-js/index.js +454 -0
- package/dist/safe-js/index.js.map +7 -0
- package/dist/safe-js/interp/arguments.d.ts +10 -0
- package/dist/safe-js/interp/async.d.ts +56 -0
- package/dist/safe-js/interp/budget.d.ts +95 -0
- package/dist/safe-js/interp/exceptions.d.ts +45 -0
- package/dist/safe-js/interp/generator.d.ts +16 -0
- package/dist/safe-js/interp/globals/console-json.d.ts +14 -0
- package/dist/safe-js/interp/host-bridge.d.ts +29 -0
- package/dist/safe-js/interp/host-call.d.ts +130 -0
- package/dist/safe-js/interp/interpreter.d.ts +63 -0
- package/dist/safe-js/interp/promise-replay.d.ts +70 -0
- package/dist/safe-js/interp/regex/compile-guard.d.ts +33 -0
- package/dist/safe-js/interp/regex/parse.d.ts +62 -0
- package/dist/safe-js/interp/scope.d.ts +43 -0
- package/dist/safe-js/interp/values.d.ts +136 -0
- package/dist/safe-js/lint/index.d.ts +38 -0
- package/dist/safe-js/lint/rules/AS-export-import-meta.d.ts +21 -0
- package/dist/safe-js/lint/rules/module-registry.d.ts +33 -0
- package/dist/safe-js/lint.d.ts +1 -0
- package/dist/safe-js/loader/extract-block.d.ts +10 -0
- package/dist/safe-js/loader/find-exported.d.ts +2 -0
- package/dist/safe-js/loader/frontmatter.d.ts +5 -0
- package/dist/safe-js/migrate.d.ts +33 -0
- package/dist/safe-js/migration-file.d.ts +55 -0
- package/dist/safe-js/modules/agent.d.ts +132 -0
- package/dist/safe-js/modules/env.d.ts +14 -0
- package/dist/safe-js/modules/fail.d.ts +6 -0
- package/dist/safe-js/modules/fs-config.d.ts +12 -0
- package/dist/safe-js/modules/fs.d.ts +82 -0
- package/dist/safe-js/modules/harness.d.ts +19 -0
- package/dist/safe-js/modules/log.d.ts +16 -0
- package/dist/safe-js/modules/mcp-transport.d.ts +26 -0
- package/dist/safe-js/modules/mcp.d.ts +63 -0
- package/dist/safe-js/modules/metric.d.ts +4 -0
- package/dist/safe-js/modules/registry.d.ts +16 -0
- package/dist/safe-js/modules/time.d.ts +12 -0
- package/dist/safe-js/observability/otel.d.ts +21 -0
- package/dist/safe-js/output-stream.d.ts +12 -0
- package/dist/safe-js/parse/parse-export.d.ts +36 -0
- package/dist/safe-js/parse/parser.d.ts +356 -0
- package/dist/safe-js/parse/tokenizer.d.ts +26 -0
- package/dist/safe-js/parse.d.ts +4 -0
- package/dist/safe-js/random.d.ts +9 -0
- package/dist/safe-js/restore.d.ts +26 -0
- package/dist/safe-js/run.d.ts +74 -0
- package/dist/safe-js/runner/run-harness.d.ts +32 -0
- package/dist/safe-js/safe-fs-core.js +130 -0
- package/dist/safe-js/safe-fs-core.js.map +7 -0
- package/dist/safe-js/safe-fs-node.js +94 -0
- package/dist/safe-js/safe-fs-node.js.map +7 -0
- package/dist/safe-js/safe-fs.js +94 -0
- package/dist/safe-js/safe-fs.js.map +7 -0
- package/dist/safe-js/snapshot/arguments.d.ts +17 -0
- package/dist/safe-js/snapshot/backend.d.ts +19 -0
- package/dist/safe-js/snapshot/dump-format.d.ts +7 -0
- package/dist/safe-js/snapshot/dump.d.ts +23 -0
- package/dist/safe-js/snapshot/float32array.d.ts +12 -0
- package/dist/safe-js/snapshot/migration.d.ts +35 -0
- package/dist/safe-js/snapshot/policy.d.ts +49 -0
- package/dist/safe-js/snapshot/replay-data.d.ts +71 -0
- package/dist/safe-js/snapshot/validation.d.ts +15 -0
- package/dist/task-list/backends/gh-issues-client.d.ts +19 -0
- package/dist/task-list/backends/gh-issues-sync.d.ts +46 -0
- package/dist/task-list/backends/gh-issues.d.ts +21 -0
- package/dist/task-list/index.d.ts +9 -0
- package/dist/task-list/move.d.ts +2 -0
- package/dist/task-list/open.d.ts +5 -0
- package/dist/task-list/state-machine.d.ts +16 -0
- package/dist/task-list/state.d.ts +29 -0
- package/dist/task-list/types.d.ts +206 -0
- package/dist/tiny-mcp-client/index.d.ts +662 -0
- package/dist/tiny-stdio-mcp-server/content/audio.d.ts +15 -0
- package/dist/tiny-stdio-mcp-server/content/convert.d.ts +16 -0
- package/dist/tiny-stdio-mcp-server/content/file-type.d.ts +11 -0
- package/dist/tiny-stdio-mcp-server/content/file.d.ts +28 -0
- package/dist/tiny-stdio-mcp-server/content/image.d.ts +15 -0
- package/dist/tiny-stdio-mcp-server/content/index.d.ts +7 -0
- package/dist/tiny-stdio-mcp-server/content/mime.d.ts +7 -0
- package/dist/tiny-stdio-mcp-server/content/remote.d.ts +5 -0
- package/dist/tiny-stdio-mcp-server/index.d.ts +9 -0
- package/dist/tiny-stdio-mcp-server/schema.d.ts +20 -0
- package/dist/tiny-stdio-mcp-server/server.d.ts +35 -0
- package/dist/tiny-stdio-mcp-server/types.d.ts +247 -0
- package/dist/toolcraft-design/acp/components.d.ts +19 -0
- package/dist/toolcraft-design/acp/index.d.ts +4 -0
- package/dist/toolcraft-design/acp/writer.d.ts +13 -0
- package/dist/toolcraft-design/components/browser.d.ts +15 -0
- package/dist/toolcraft-design/components/catalog.d.ts +26 -0
- package/dist/toolcraft-design/components/color.d.ts +31 -0
- package/dist/toolcraft-design/components/command-errors.d.ts +18 -0
- package/dist/toolcraft-design/components/detail-card.d.ts +22 -0
- package/dist/toolcraft-design/components/file-changes.d.ts +16 -0
- package/dist/toolcraft-design/components/help-formatter-plain.d.ts +5 -0
- package/dist/toolcraft-design/components/help-formatter.d.ts +50 -0
- package/dist/toolcraft-design/components/inspector-card.d.ts +21 -0
- package/dist/toolcraft-design/components/logger.d.ts +11 -0
- package/dist/toolcraft-design/components/resource-browser.d.ts +21 -0
- package/dist/toolcraft-design/components/symbols.d.ts +12 -0
- package/dist/toolcraft-design/components/table.d.ts +16 -0
- package/dist/toolcraft-design/components/template.d.ts +19 -0
- package/dist/toolcraft-design/components/text.d.ts +16 -0
- package/dist/toolcraft-design/dashboard/buffer.d.ts +25 -0
- package/dist/toolcraft-design/dashboard/components/footer.d.ts +8 -0
- package/dist/toolcraft-design/dashboard/dashboard.d.ts +20 -0
- package/dist/toolcraft-design/dashboard/index.d.ts +8 -0
- package/dist/toolcraft-design/dashboard/should-use-dashboard.d.ts +10 -0
- package/dist/toolcraft-design/dashboard/snapshot.d.ts +10 -0
- package/dist/toolcraft-design/dashboard/terminal.d.ts +37 -0
- package/dist/toolcraft-design/dashboard/types.d.ts +38 -0
- package/dist/toolcraft-design/explorer/events.d.ts +77 -0
- package/dist/toolcraft-design/explorer/index.d.ts +8 -0
- package/dist/toolcraft-design/explorer/keymap.d.ts +31 -0
- package/dist/toolcraft-design/explorer/runtime.d.ts +2 -0
- package/dist/toolcraft-design/explorer/state.d.ts +224 -0
- package/dist/toolcraft-design/index.d.ts +62 -0
- package/dist/toolcraft-design/internal/output-format.d.ts +6 -0
- package/dist/toolcraft-design/internal/strip-ansi.d.ts +1 -0
- package/dist/toolcraft-design/internal/theme-detect.d.ts +12 -0
- package/dist/toolcraft-design/internal/theme-state.d.ts +12 -0
- package/dist/toolcraft-design/prompts/index.d.ts +91 -0
- package/dist/toolcraft-design/prompts/interactive/cancel-symbol.d.ts +2 -0
- package/dist/toolcraft-design/prompts/interactive/select.d.ts +18 -0
- package/dist/toolcraft-design/prompts/primitives/cancel.d.ts +2 -0
- package/dist/toolcraft-design/prompts/primitives/intro.d.ts +1 -0
- package/dist/toolcraft-design/prompts/primitives/log.d.ts +18 -0
- package/dist/toolcraft-design/prompts/primitives/note.d.ts +1 -0
- package/dist/toolcraft-design/prompts/primitives/outro.d.ts +1 -0
- package/dist/toolcraft-design/prompts/primitives/spinner.d.ts +6 -0
- package/dist/toolcraft-design/prompts/theme.d.ts +11 -0
- package/dist/toolcraft-design/screen/screen.d.ts +40 -0
- package/dist/toolcraft-design/screen/style.d.ts +16 -0
- package/dist/toolcraft-design/static/index.d.ts +4 -0
- package/dist/toolcraft-design/static/menu.d.ts +11 -0
- package/dist/toolcraft-design/static/spinner.d.ts +14 -0
- package/dist/toolcraft-design/terminal/driver.d.ts +34 -0
- package/dist/toolcraft-design/terminal/input.d.ts +25 -0
- package/dist/toolcraft-design/terminal-markdown/ast.d.ts +98 -0
- package/dist/toolcraft-design/terminal-markdown/html-renderer.d.ts +7 -0
- package/dist/toolcraft-design/terminal-markdown/index.d.ts +12 -0
- package/dist/toolcraft-design/terminal-markdown/parser.d.ts +5 -0
- package/dist/toolcraft-design/terminal-markdown/plaintext-renderer.d.ts +11 -0
- package/dist/toolcraft-design/terminal-markdown/renderer.d.ts +7 -0
- package/dist/toolcraft-design/tokens/brand.d.ts +5 -0
- package/dist/toolcraft-design/tokens/colors.d.ts +37 -0
- package/dist/toolcraft-design/tokens/index.d.ts +6 -0
- package/dist/toolcraft-design/tokens/spacing.d.ts +6 -0
- package/dist/toolcraft-design/tokens/typography.d.ts +7 -0
- package/dist/toolcraft-design/tokens/widths.d.ts +5 -0
- package/dist/toolcraft-schema/index.d.ts +184 -0
- package/dist/toolcraft-schema/json-schema/index.d.ts +5 -0
- package/dist/toolcraft-schema/json-schema/types.d.ts +33 -0
- package/dist/toolcraft-schema/json-schema-document.d.ts +14 -0
- package/dist/toolcraft-schema/json.d.ts +10 -0
- package/dist/toolcraft-schema/oneof.d.ts +15 -0
- package/dist/toolcraft-schema/record.d.ts +5 -0
- package/dist/toolcraft-schema/union.d.ts +8 -0
- package/dist/toolcraft-schema/validate.d.ts +17 -0
- package/package.json +89 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export type BudgetName = "steps" | "deadline" | "callDepth" | "stringLength" | "arrayLength" | "dataSize" | "dataDepth";
|
|
2
|
+
export type BudgetOptions = {
|
|
3
|
+
maxSteps?: number;
|
|
4
|
+
deadline?: number | Date;
|
|
5
|
+
maxCallDepth?: number;
|
|
6
|
+
stringLength?: number;
|
|
7
|
+
arrayLength?: number;
|
|
8
|
+
dataSize?: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const REGEX_STEP_LIMIT = 2000;
|
|
11
|
+
export declare const REGEX_COMPILE_LIMITS: Readonly<{
|
|
12
|
+
sourceLength: 4096;
|
|
13
|
+
flagsLength: 8;
|
|
14
|
+
depth: 64;
|
|
15
|
+
allocations: 16384;
|
|
16
|
+
}>;
|
|
17
|
+
export declare class SandboxError extends Error {
|
|
18
|
+
readonly code: "aborted" | "budgetExceeded" | "reentry";
|
|
19
|
+
readonly budget?: BudgetName;
|
|
20
|
+
readonly current?: number;
|
|
21
|
+
readonly limit?: number;
|
|
22
|
+
constructor(input: "aborted");
|
|
23
|
+
constructor(input: "reentry");
|
|
24
|
+
constructor(input: {
|
|
25
|
+
budget: BudgetName;
|
|
26
|
+
current: number;
|
|
27
|
+
limit: number;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
type BudgetLimits = {
|
|
31
|
+
maxSteps?: number;
|
|
32
|
+
maxCallDepth?: number;
|
|
33
|
+
stringLength?: number;
|
|
34
|
+
arrayLength?: number;
|
|
35
|
+
dataSize?: number;
|
|
36
|
+
};
|
|
37
|
+
export type CompileOwner = {
|
|
38
|
+
readonly budget: Budget;
|
|
39
|
+
readonly generation: number;
|
|
40
|
+
};
|
|
41
|
+
export type CompileTicket = {
|
|
42
|
+
readonly owner: CompileOwner;
|
|
43
|
+
};
|
|
44
|
+
export declare class Budget {
|
|
45
|
+
readonly deadline?: number;
|
|
46
|
+
readonly limits: Readonly<BudgetLimits>;
|
|
47
|
+
stepsUsed: number;
|
|
48
|
+
peakCallDepth: number;
|
|
49
|
+
currentDataSize: number;
|
|
50
|
+
peakDataSize: number;
|
|
51
|
+
currentCallDepth: number;
|
|
52
|
+
private allChecksSuspended;
|
|
53
|
+
private deadlineChecksSuspended;
|
|
54
|
+
private visitsUntilDeadlineCheck;
|
|
55
|
+
private retainedDataSize;
|
|
56
|
+
private readonly retainedData;
|
|
57
|
+
private readonly retainedValueSources;
|
|
58
|
+
private compileGeneration;
|
|
59
|
+
private activeCompileOwner?;
|
|
60
|
+
private compileUses;
|
|
61
|
+
private provisionalScopes;
|
|
62
|
+
private readonly compileTickets;
|
|
63
|
+
private readonly completedCompileTickets;
|
|
64
|
+
constructor(options?: BudgetOptions);
|
|
65
|
+
visitNode(): void;
|
|
66
|
+
allocateString(value: string): string;
|
|
67
|
+
allocateArrayLength(length: number): void;
|
|
68
|
+
allocateCollectionEntries(count: number): void;
|
|
69
|
+
reconcileDataUsage(usage: number): void;
|
|
70
|
+
setRetainedDataUsage(owner: object, usage: number): void;
|
|
71
|
+
setRetainedValues(owner: object, values: (() => Iterable<unknown>) | undefined): void;
|
|
72
|
+
retainedValues(): Iterable<unknown>;
|
|
73
|
+
acquireCompileOwner(reset?: boolean, owner?: CompileOwner): {
|
|
74
|
+
owner: CompileOwner;
|
|
75
|
+
release: () => void;
|
|
76
|
+
};
|
|
77
|
+
createCompileTicket(owner: CompileOwner): CompileTicket;
|
|
78
|
+
compileTicketUsage(ticket: CompileTicket): number;
|
|
79
|
+
resizeCompileTicket(ticket: CompileTicket, usage: number): void;
|
|
80
|
+
discardCompileTicket(ticket: CompileTicket): void;
|
|
81
|
+
reconcileCompileData(usage: number, included: ReadonlySet<CompileTicket>, transferred?: ReadonlySet<CompileTicket>, retainedOwner?: object, complete?: boolean): ReadonlySet<CompileTicket>;
|
|
82
|
+
chargeDataUsage(usage: number): void;
|
|
83
|
+
provisionDataUsage(usage: number): () => void;
|
|
84
|
+
enterCall(): () => void;
|
|
85
|
+
enterAwait(): () => void;
|
|
86
|
+
reset(): void;
|
|
87
|
+
suspendChecks(): () => void;
|
|
88
|
+
suspendDeadlineChecks(): () => void;
|
|
89
|
+
private checkDeadline;
|
|
90
|
+
private checkDataUsage;
|
|
91
|
+
private checkSampledDeadline;
|
|
92
|
+
private enterDepth;
|
|
93
|
+
}
|
|
94
|
+
export declare function allocateRegexSteps(steps: number): void;
|
|
95
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { BreakStatement, ContinueStatement, ParseResult, ThrowStatement, TryStatement } from "../parse.js";
|
|
2
|
+
import { type SandboxErrorName, type ErrorSourceSpan } from "../error/shape.js";
|
|
3
|
+
import { type Budget } from "./budget.js";
|
|
4
|
+
import type { Scope } from "./scope.js";
|
|
5
|
+
import { type SandboxObject, type SandboxValue } from "./values.js";
|
|
6
|
+
declare const capturedExceptionBrand: unique symbol;
|
|
7
|
+
export type { SandboxErrorName } from "../error/shape.js";
|
|
8
|
+
export type CompletionKind = "normal" | "return" | "throw" | "break" | "continue";
|
|
9
|
+
export type CompletionResult = {
|
|
10
|
+
kind: CompletionKind;
|
|
11
|
+
hasValue: boolean;
|
|
12
|
+
span?: ErrorSourceSpan;
|
|
13
|
+
stackFrames?: readonly string[];
|
|
14
|
+
value: SandboxValue;
|
|
15
|
+
label?: string;
|
|
16
|
+
node?: BreakStatement | ContinueStatement;
|
|
17
|
+
};
|
|
18
|
+
export type EvaluationResult<TError> = CompletionResult | {
|
|
19
|
+
kind: "error";
|
|
20
|
+
error: TError;
|
|
21
|
+
};
|
|
22
|
+
type CapturedException = {
|
|
23
|
+
readonly reason: unknown;
|
|
24
|
+
readonly sandbox: boolean;
|
|
25
|
+
readonly stackFrames: readonly string[];
|
|
26
|
+
readonly [capturedExceptionBrand]: true;
|
|
27
|
+
};
|
|
28
|
+
type ExceptionContext = {
|
|
29
|
+
budget: Budget;
|
|
30
|
+
callStack: readonly string[];
|
|
31
|
+
scope: Scope;
|
|
32
|
+
};
|
|
33
|
+
type EvaluateExceptionNode<TContext, TError> = (node: ParseResult, context: TContext) => Promise<EvaluationResult<TError>>;
|
|
34
|
+
export declare function evaluateThrowStatement<TContext extends ExceptionContext, TError>(node: ThrowStatement, context: TContext, evaluateNode: EvaluateExceptionNode<TContext, TError>): Promise<EvaluationResult<TError>>;
|
|
35
|
+
export declare function evaluateTryStatement<TContext extends ExceptionContext, TError>(node: TryStatement, context: TContext, evaluateNode: EvaluateExceptionNode<TContext, TError>): Promise<EvaluationResult<TError>>;
|
|
36
|
+
export declare function createCapturedException(reason: unknown, stackFrames: readonly string[], sandbox?: boolean): CapturedException;
|
|
37
|
+
export declare function isCapturedException(value: unknown): value is CapturedException;
|
|
38
|
+
export declare function coerceThrownValue(reason: unknown, budget: Budget, stackFrames: readonly string[], span?: ErrorSourceSpan, sandbox?: boolean): SandboxValue;
|
|
39
|
+
export declare function surfaceThrownValue(reason: unknown, budget: Budget, stackFrames?: readonly string[], span?: ErrorSourceSpan): SandboxObject;
|
|
40
|
+
export declare function createSubsetErrorValue(name: string, message: SandboxValue, stackFrames: readonly string[], budget: Budget, options?: {
|
|
41
|
+
cause?: unknown;
|
|
42
|
+
chargeBudget?: boolean;
|
|
43
|
+
span?: ErrorSourceSpan;
|
|
44
|
+
}): SandboxObject;
|
|
45
|
+
export declare function isSandboxErrorConstructorInstance(value: SandboxValue, name: SandboxErrorName): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type GeneratorCompletion = {
|
|
2
|
+
type: "normal" | "return" | "throw";
|
|
3
|
+
value: unknown;
|
|
4
|
+
};
|
|
5
|
+
export type GeneratorChannel = {
|
|
6
|
+
next(value?: unknown): Promise<IteratorResult<unknown>>;
|
|
7
|
+
return(value?: unknown): Promise<IteratorResult<unknown>>;
|
|
8
|
+
throw(error?: unknown): Promise<IteratorResult<unknown>>;
|
|
9
|
+
snapshot(): GeneratorChannelSnapshot;
|
|
10
|
+
};
|
|
11
|
+
export type GeneratorChannelSnapshot = {
|
|
12
|
+
yieldNodeId?: number;
|
|
13
|
+
sent: GeneratorCompletion[];
|
|
14
|
+
};
|
|
15
|
+
export declare function createGeneratorChannel(body: (yieldValue: (value?: unknown, yieldNodeId?: number) => Promise<GeneratorCompletion>) => Promise<unknown>): GeneratorChannel;
|
|
16
|
+
export declare function restoreGeneratorChannel(body: Parameters<typeof createGeneratorChannel>[0], snapshot: GeneratorChannelSnapshot): GeneratorChannel;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Budget, CompileOwner } from "../budget.js";
|
|
2
|
+
import type { HostCallJournal } from "../host-call.js";
|
|
3
|
+
import { type SandboxObject } from "../values.js";
|
|
4
|
+
export type ConsoleSink = {
|
|
5
|
+
error: (...args: unknown[]) => void;
|
|
6
|
+
log: (...args: unknown[]) => void;
|
|
7
|
+
};
|
|
8
|
+
export type ConsoleJsonGlobalsOptions = {
|
|
9
|
+
budget: Budget;
|
|
10
|
+
compileOwner?: CompileOwner;
|
|
11
|
+
sink?: ConsoleSink;
|
|
12
|
+
hostCalls?: HostCallJournal;
|
|
13
|
+
};
|
|
14
|
+
export declare function createConsoleJsonGlobals(options: ConsoleJsonGlobalsOptions): Record<"JSON" | "console", SandboxObject>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Budget, type CompileOwner } from "./budget.js";
|
|
2
|
+
import { type PendingHostCallPolicyMode } from "../snapshot/policy.js";
|
|
3
|
+
import { type HostCallJournal, type HostCallOutcome } from "./host-call.js";
|
|
4
|
+
import { type SandboxClosure, type SandboxValue } from "./values.js";
|
|
5
|
+
import type { RunLifecycle } from "../snapshot/dump.js";
|
|
6
|
+
type CallerInjectedFunction = {
|
|
7
|
+
bivarianceHack(...args: readonly unknown[]): unknown;
|
|
8
|
+
}["bivarianceHack"];
|
|
9
|
+
type HostBridgeOptions = {
|
|
10
|
+
registerCapabilities?: boolean;
|
|
11
|
+
capabilityPath?: readonly string[];
|
|
12
|
+
budget: Budget;
|
|
13
|
+
compileOwner?: CompileOwner;
|
|
14
|
+
hostCalls?: HostCallJournal;
|
|
15
|
+
moduleId?: string;
|
|
16
|
+
operation?: string;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
lifecycle?: RunLifecycle;
|
|
19
|
+
proofFunctions?: WeakMap<object, SandboxClosure>;
|
|
20
|
+
};
|
|
21
|
+
export type CallerInjectedBinding = SandboxValue | CallerInjectedFunction | readonly CallerInjectedBinding[] | {
|
|
22
|
+
readonly [key: string]: CallerInjectedBinding;
|
|
23
|
+
};
|
|
24
|
+
export declare function declareHostOperation<TFunction extends CallerInjectedFunction>(operation: TFunction, policy: PendingHostCallPolicyMode, options?: {
|
|
25
|
+
onReplay?: (args: readonly unknown[], outcome: HostCallOutcome) => void;
|
|
26
|
+
}): TFunction;
|
|
27
|
+
export declare function readHostOperationPolicy(operation: CallerInjectedFunction): PendingHostCallPolicyMode | undefined;
|
|
28
|
+
export declare function wrapCallerInjectedBindings(bindings: Record<string, CallerInjectedBinding>, options: HostBridgeOptions): Record<string, SandboxValue>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { type SandboxClosure, type SandboxValue } from "./values.js";
|
|
2
|
+
import type { Budget, CompileOwner } from "./budget.js";
|
|
3
|
+
import { type ReplayData } from "../snapshot/replay-data.js";
|
|
4
|
+
import { type PendingHostCallPolicyMode } from "../snapshot/policy.js";
|
|
5
|
+
export type HostCallLifecycle = "created" | "running" | "settled" | "consumed" | "cancelled";
|
|
6
|
+
export type HostCallOutcome = {
|
|
7
|
+
status: "fulfilled";
|
|
8
|
+
value: SandboxValue;
|
|
9
|
+
} | {
|
|
10
|
+
status: "rejected";
|
|
11
|
+
reason: SandboxValue;
|
|
12
|
+
};
|
|
13
|
+
export type HostCallRecord = {
|
|
14
|
+
id: string;
|
|
15
|
+
runId: string;
|
|
16
|
+
sourceHash: string;
|
|
17
|
+
moduleId: string;
|
|
18
|
+
operation: string;
|
|
19
|
+
argumentDigest: string;
|
|
20
|
+
policy: PendingHostCallPolicyMode;
|
|
21
|
+
lifecycle: HostCallLifecycle;
|
|
22
|
+
outcome?: HostCallOutcome;
|
|
23
|
+
asynchronous?: boolean;
|
|
24
|
+
callbacks?: Array<{
|
|
25
|
+
id: number;
|
|
26
|
+
step: number;
|
|
27
|
+
arguments: ReplayData;
|
|
28
|
+
}>;
|
|
29
|
+
functions?: number[];
|
|
30
|
+
};
|
|
31
|
+
export type HostCallReplay = {
|
|
32
|
+
version: 1;
|
|
33
|
+
calls: Array<Omit<HostCallRecord, "outcome" | "asynchronous"> & {
|
|
34
|
+
asynchronous: boolean;
|
|
35
|
+
outcome?: {
|
|
36
|
+
status: "fulfilled" | "rejected";
|
|
37
|
+
data: ReplayData;
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
export type HostCallResumeProof = {
|
|
42
|
+
callId: string;
|
|
43
|
+
sourceHash: string;
|
|
44
|
+
moduleId: string;
|
|
45
|
+
operation: string;
|
|
46
|
+
argumentDigest: string;
|
|
47
|
+
outcome: HostCallOutcome;
|
|
48
|
+
callbackDisposition?: "joined" | "detached";
|
|
49
|
+
};
|
|
50
|
+
export type HostCallResumeContext = {
|
|
51
|
+
callbacks: ReadonlyMap<number, (...args: readonly unknown[]) => Promise<unknown>>;
|
|
52
|
+
replayed: ReadonlyArray<{
|
|
53
|
+
callbackId: number;
|
|
54
|
+
result: Promise<unknown>;
|
|
55
|
+
}>;
|
|
56
|
+
waitForCallbacks: () => Promise<void>;
|
|
57
|
+
toSandboxValue: (value: unknown) => SandboxValue;
|
|
58
|
+
};
|
|
59
|
+
export type HostCallResumeRequest = Omit<HostCallRecord, "id" | "outcome"> & {
|
|
60
|
+
callId: string;
|
|
61
|
+
requirement: "external-reconciliation";
|
|
62
|
+
};
|
|
63
|
+
export type HostCallResumeProvider = (request: HostCallResumeRequest, context?: HostCallResumeContext) => HostCallResumeProof | Promise<HostCallResumeProof>;
|
|
64
|
+
export declare class HostCallResumabilityError extends Error {
|
|
65
|
+
#private;
|
|
66
|
+
readonly action: "reset" | "external-reconciliation";
|
|
67
|
+
readonly callId: string;
|
|
68
|
+
readonly lifecycle: HostCallLifecycle;
|
|
69
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
70
|
+
constructor(record: HostCallRecord, action: "reset" | "external-reconciliation", message: string);
|
|
71
|
+
}
|
|
72
|
+
export declare class UnresolvedReplayCapabilityError extends TypeError {
|
|
73
|
+
readonly id: string;
|
|
74
|
+
constructor(id: string);
|
|
75
|
+
}
|
|
76
|
+
export declare class HostCallJournal {
|
|
77
|
+
private readonly sourceHash;
|
|
78
|
+
private readonly resumeProvider?;
|
|
79
|
+
private budget?;
|
|
80
|
+
private compileOwner?;
|
|
81
|
+
readonly runId: string;
|
|
82
|
+
private nextCall;
|
|
83
|
+
private readonly records;
|
|
84
|
+
private readonly restored;
|
|
85
|
+
private readonly outcomes;
|
|
86
|
+
private readonly recordedReplay;
|
|
87
|
+
private retainedSize;
|
|
88
|
+
private readonly outcomeSizes;
|
|
89
|
+
private readonly capabilities;
|
|
90
|
+
private readonly requiredHostCapabilities;
|
|
91
|
+
private readonly capabilityIds;
|
|
92
|
+
readonly nativeClosures: WeakMap<object, SandboxClosure>;
|
|
93
|
+
private readonly hostSources;
|
|
94
|
+
private readonly encodedOutcomes;
|
|
95
|
+
private readonly callbackSizes;
|
|
96
|
+
private readonly completedCallbackOwners;
|
|
97
|
+
private readonly capabilityWaiters;
|
|
98
|
+
readonly identifyCapability: (key: SandboxClosure) => string | undefined;
|
|
99
|
+
readonly resolveCapability: (id: string) => SandboxClosure;
|
|
100
|
+
constructor(sourceHash: string, records?: readonly HostCallRecord[], resumeProvider?: HostCallResumeProvider | undefined, replay?: unknown, budget?: Budget | undefined, compileOwner?: CompileOwner | undefined);
|
|
101
|
+
issue(input: {
|
|
102
|
+
moduleId: string;
|
|
103
|
+
operation: string;
|
|
104
|
+
argumentDigest: string;
|
|
105
|
+
policy: PendingHostCallPolicyMode;
|
|
106
|
+
}): {
|
|
107
|
+
record: HostCallRecord;
|
|
108
|
+
restored: boolean;
|
|
109
|
+
};
|
|
110
|
+
private createRecord;
|
|
111
|
+
start(record: HostCallRecord): void;
|
|
112
|
+
settle(record: HostCallRecord, outcome: HostCallOutcome): void;
|
|
113
|
+
consume(record: HostCallRecord): void;
|
|
114
|
+
cancel(record: HostCallRecord, reason: SandboxValue): void;
|
|
115
|
+
reconcile(record: HostCallRecord, context?: HostCallResumeContext): Promise<HostCallOutcome>;
|
|
116
|
+
snapshot(): HostCallRecord[];
|
|
117
|
+
dispose(): void;
|
|
118
|
+
registerCallbackFunction(record: HostCallRecord, id: number, closure: SandboxClosure, native: object): void;
|
|
119
|
+
registerHostCapability(path: string, closure: SandboxClosure, native: object): void;
|
|
120
|
+
rebindHostCapability(original: SandboxClosure, restored: SandboxClosure): void;
|
|
121
|
+
validateHostCapabilities(): void;
|
|
122
|
+
waitForCapability(id: string): Promise<void>;
|
|
123
|
+
trackCallbackCompletion(record: HostCallRecord, callbacks: readonly Promise<unknown>[]): void;
|
|
124
|
+
recordCallback(record: HostCallRecord, id: number, args: SandboxValue[], step: number): string;
|
|
125
|
+
callbackPositions(): ReadonlyMap<string, number>;
|
|
126
|
+
private retainOutcome;
|
|
127
|
+
replayOutcome(record: HostCallRecord): HostCallOutcome | undefined;
|
|
128
|
+
snapshotReplay(): HostCallReplay;
|
|
129
|
+
}
|
|
130
|
+
export declare function digestHostCallArguments(args: readonly unknown[]): string;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ParseResult, SourceSpan } from "../parse.js";
|
|
2
|
+
import { type InterpreterYieldPoint } from "./async.js";
|
|
3
|
+
import type { GeneratorCompletion } from "./generator.js";
|
|
4
|
+
import { Budget, type CompileOwner } from "./budget.js";
|
|
5
|
+
import { CompileScope } from "./regex/compile-guard.js";
|
|
6
|
+
import { type SandboxValue } from "./values.js";
|
|
7
|
+
import { Scope } from "./scope.js";
|
|
8
|
+
export type InterpreterValue = SandboxValue;
|
|
9
|
+
export type InterpreterStats = {
|
|
10
|
+
nodeVisits: number;
|
|
11
|
+
currentDataSize: number;
|
|
12
|
+
peakDataSize: number;
|
|
13
|
+
};
|
|
14
|
+
export type InterpreterSnapshot = {
|
|
15
|
+
bindings: Record<string, InterpreterValue>;
|
|
16
|
+
loopIterations?: Record<string, LoopIterationSnapshot>;
|
|
17
|
+
resumeNodeId?: number;
|
|
18
|
+
};
|
|
19
|
+
export type LoopIterationSnapshot = number | {
|
|
20
|
+
index: number;
|
|
21
|
+
values: InterpreterValue[];
|
|
22
|
+
};
|
|
23
|
+
export type InterpreterErrorCode = "LABEL_NOT_FOUND" | "UNBOUND_IDENTIFIER" | "UNSUPPORTED_NODE";
|
|
24
|
+
export type InterpreterError = {
|
|
25
|
+
code: InterpreterErrorCode;
|
|
26
|
+
message: string;
|
|
27
|
+
name: string;
|
|
28
|
+
nodeId?: number;
|
|
29
|
+
nodeType: ParseResult["type"];
|
|
30
|
+
span: SourceSpan;
|
|
31
|
+
stack: string;
|
|
32
|
+
};
|
|
33
|
+
export type InterpreterResult = {
|
|
34
|
+
ok: true;
|
|
35
|
+
returnValue?: InterpreterValue;
|
|
36
|
+
snapshot: InterpreterSnapshot;
|
|
37
|
+
stats: InterpreterStats;
|
|
38
|
+
} | {
|
|
39
|
+
ok: false;
|
|
40
|
+
error: InterpreterError;
|
|
41
|
+
snapshot: InterpreterSnapshot;
|
|
42
|
+
stats: InterpreterStats;
|
|
43
|
+
};
|
|
44
|
+
export type InterpretOptions = {
|
|
45
|
+
compilation?: CompileScope;
|
|
46
|
+
compileOwner?: CompileOwner;
|
|
47
|
+
captureReplayState?: () => unknown;
|
|
48
|
+
bindings?: Record<string, InterpreterValue>;
|
|
49
|
+
budget?: Budget;
|
|
50
|
+
onYield?: (yieldPoint: InterpreterYieldPoint) => void;
|
|
51
|
+
scope?: Scope;
|
|
52
|
+
signal?: AbortSignal;
|
|
53
|
+
surfaceUnhandledThrows?: boolean;
|
|
54
|
+
useScopeDirectly?: boolean;
|
|
55
|
+
generatorYield?: (value?: SandboxValue, yieldNodeId?: number) => Promise<GeneratorCompletion>;
|
|
56
|
+
generatorResume?: {
|
|
57
|
+
sent: GeneratorCompletion[];
|
|
58
|
+
yieldNodeId: number;
|
|
59
|
+
};
|
|
60
|
+
snapshot?: InterpreterSnapshot;
|
|
61
|
+
};
|
|
62
|
+
export declare function interpret(node: ParseResult, options?: InterpretOptions): Promise<InterpreterResult>;
|
|
63
|
+
export { Scope } from "./scope.js";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { type Budget } from "./budget.js";
|
|
3
|
+
type ReplayEvent = {
|
|
4
|
+
kind: "promise";
|
|
5
|
+
id: number;
|
|
6
|
+
step: number;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "callback-start";
|
|
9
|
+
token: string;
|
|
10
|
+
step: number;
|
|
11
|
+
promises: number;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "callback-end";
|
|
14
|
+
token: string;
|
|
15
|
+
step: number;
|
|
16
|
+
};
|
|
17
|
+
export type PromiseReplaySnapshot = {
|
|
18
|
+
version: 1;
|
|
19
|
+
steps: number;
|
|
20
|
+
promises: number;
|
|
21
|
+
settlements: Array<{
|
|
22
|
+
id: number;
|
|
23
|
+
step: number;
|
|
24
|
+
}>;
|
|
25
|
+
events?: ReplayEvent[];
|
|
26
|
+
executionTrace?: {
|
|
27
|
+
start: number;
|
|
28
|
+
nodes: number[];
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare class PromiseReplay {
|
|
32
|
+
private steps;
|
|
33
|
+
private nextPromise;
|
|
34
|
+
private position;
|
|
35
|
+
private readonly replaying;
|
|
36
|
+
private readonly restored;
|
|
37
|
+
private readonly restoredEvents;
|
|
38
|
+
private readonly events;
|
|
39
|
+
private readonly ready;
|
|
40
|
+
private readonly callbackTasks;
|
|
41
|
+
private readonly completedCallbacks;
|
|
42
|
+
private readonly rejectors;
|
|
43
|
+
private failure?;
|
|
44
|
+
private callbackCount;
|
|
45
|
+
private readonly waiting;
|
|
46
|
+
private readonly liveWaiters;
|
|
47
|
+
private budget?;
|
|
48
|
+
private executionTrace?;
|
|
49
|
+
constructor(snapshot?: unknown);
|
|
50
|
+
get currentStep(): number;
|
|
51
|
+
beforeNode(nodeId?: number): void | Promise<void>;
|
|
52
|
+
track<TValue>(promise: Promise<TValue>): Promise<TValue>;
|
|
53
|
+
beginCallback(token: string): void;
|
|
54
|
+
completeCallback(token: string): void;
|
|
55
|
+
waitForLiveExecution(): void | Promise<void>;
|
|
56
|
+
registerCallbacks(callbacks: ReadonlyArray<{
|
|
57
|
+
token: string;
|
|
58
|
+
start: () => void;
|
|
59
|
+
}>): void;
|
|
60
|
+
private assertHealthy;
|
|
61
|
+
fail(reason: unknown): void;
|
|
62
|
+
validateCallbacks(positions: ReadonlyMap<string, number>): void;
|
|
63
|
+
validateNodes(root: object): void;
|
|
64
|
+
snapshot(): PromiseReplaySnapshot;
|
|
65
|
+
attachBudget(budget: Budget): void;
|
|
66
|
+
dispose(): void;
|
|
67
|
+
private drain;
|
|
68
|
+
}
|
|
69
|
+
export declare const promiseReplayContext: AsyncLocalStorage<PromiseReplay>;
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type CompileOwner, type CompileTicket } from "../budget.js";
|
|
2
|
+
import type { RegexPattern } from "./parse.js";
|
|
3
|
+
export declare class CompileScope {
|
|
4
|
+
readonly owner?: CompileOwner | undefined;
|
|
5
|
+
readonly parent?: CompileScope | undefined;
|
|
6
|
+
readonly tickets: Set<CompileTicket>;
|
|
7
|
+
closed: boolean;
|
|
8
|
+
constructor(owner?: CompileOwner | undefined, parent?: CompileScope | undefined);
|
|
9
|
+
forward(tickets: Iterable<CompileTicket>, parent: CompileScope): void;
|
|
10
|
+
dispose(): void;
|
|
11
|
+
}
|
|
12
|
+
export declare class RegexCompileGuard {
|
|
13
|
+
private readonly scope?;
|
|
14
|
+
private allocations;
|
|
15
|
+
private depth;
|
|
16
|
+
private readonly ticket?;
|
|
17
|
+
private retained;
|
|
18
|
+
constructor(scope?: CompileScope | undefined);
|
|
19
|
+
checkLength(length: number, flags?: boolean): void;
|
|
20
|
+
work(units: number): void;
|
|
21
|
+
allocate(units: number): void;
|
|
22
|
+
array(length: number): void;
|
|
23
|
+
enterGroup(): void;
|
|
24
|
+
leaveGroup(): void;
|
|
25
|
+
preflight(source: string, flags: string): void;
|
|
26
|
+
retain(pattern: RegexPattern, valueUnits?: number): void;
|
|
27
|
+
retainScratch(): void;
|
|
28
|
+
close(): void;
|
|
29
|
+
}
|
|
30
|
+
export declare function regexCompiledData(pattern: RegexPattern): {
|
|
31
|
+
units: number;
|
|
32
|
+
ticket?: CompileTicket;
|
|
33
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type CompileScope } from "./compile-guard.js";
|
|
2
|
+
export type RegexFlags = {
|
|
3
|
+
global: boolean;
|
|
4
|
+
ignoreCase: boolean;
|
|
5
|
+
multiline: boolean;
|
|
6
|
+
dotAll: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type CharacterKind = "digit" | "word" | "space";
|
|
9
|
+
export type CharacterClassItem = {
|
|
10
|
+
type: "character";
|
|
11
|
+
value: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "range";
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: "kind";
|
|
18
|
+
kind: CharacterKind;
|
|
19
|
+
negated: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type RegexNode = {
|
|
22
|
+
type: "empty";
|
|
23
|
+
} | {
|
|
24
|
+
type: "literal";
|
|
25
|
+
value: string;
|
|
26
|
+
} | {
|
|
27
|
+
type: "dot";
|
|
28
|
+
} | {
|
|
29
|
+
type: "anchor";
|
|
30
|
+
kind: "start" | "end";
|
|
31
|
+
} | {
|
|
32
|
+
type: "wordBoundary";
|
|
33
|
+
negated: boolean;
|
|
34
|
+
} | {
|
|
35
|
+
type: "characterClass";
|
|
36
|
+
negated: boolean;
|
|
37
|
+
items: CharacterClassItem[];
|
|
38
|
+
} | {
|
|
39
|
+
type: "sequence";
|
|
40
|
+
elements: RegexNode[];
|
|
41
|
+
} | {
|
|
42
|
+
type: "alternation";
|
|
43
|
+
alternatives: RegexNode[];
|
|
44
|
+
} | {
|
|
45
|
+
type: "group";
|
|
46
|
+
capturing: boolean;
|
|
47
|
+
index?: number;
|
|
48
|
+
body: RegexNode;
|
|
49
|
+
} | {
|
|
50
|
+
type: "quantifier";
|
|
51
|
+
body: RegexNode;
|
|
52
|
+
min: number;
|
|
53
|
+
max?: number;
|
|
54
|
+
greedy: boolean;
|
|
55
|
+
};
|
|
56
|
+
export type RegexPattern = {
|
|
57
|
+
source: string;
|
|
58
|
+
flags: RegexFlags;
|
|
59
|
+
captureCount: number;
|
|
60
|
+
body: RegexNode;
|
|
61
|
+
};
|
|
62
|
+
export declare function parseRegex(source: string, flags?: string, compilation?: CompileScope, valueUnits?: number): RegexPattern;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { VariableDeclarationKind } from "../parse.js";
|
|
2
|
+
import type { InterpreterSnapshot, InterpreterValue } from "./interpreter.js";
|
|
3
|
+
type ScopeLookupResult = {
|
|
4
|
+
found: true;
|
|
5
|
+
kind: VariableDeclarationKind;
|
|
6
|
+
value: InterpreterValue;
|
|
7
|
+
} | {
|
|
8
|
+
found: false;
|
|
9
|
+
};
|
|
10
|
+
type ScopeOptions = {
|
|
11
|
+
functionBoundary?: boolean;
|
|
12
|
+
chargeData?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare class Scope {
|
|
15
|
+
#private;
|
|
16
|
+
private readonly parent?;
|
|
17
|
+
private readonly importMeta?;
|
|
18
|
+
private readonly options;
|
|
19
|
+
constructor(bindings?: Record<string, InterpreterValue>, parent?: Scope | undefined, importMeta?: InterpreterValue, options?: ScopeOptions, restoredBindings?: Record<string, InterpreterValue>);
|
|
20
|
+
child(bindings?: Record<string, InterpreterValue>, options?: ScopeOptions): Scope;
|
|
21
|
+
consumeRestoredBinding(name: string): {
|
|
22
|
+
found: true;
|
|
23
|
+
value: InterpreterValue;
|
|
24
|
+
} | {
|
|
25
|
+
found: false;
|
|
26
|
+
};
|
|
27
|
+
hasOwnBinding(name: string): boolean;
|
|
28
|
+
getOwnBindingKind(name: string): VariableDeclarationKind | undefined;
|
|
29
|
+
isFunctionBoundary(): boolean;
|
|
30
|
+
iterationChild(names: readonly string[]): Scope;
|
|
31
|
+
lookupImportMeta(): InterpreterValue;
|
|
32
|
+
retainedValues(): InterpreterValue[];
|
|
33
|
+
declare(name: string, kind: VariableDeclarationKind, value: InterpreterValue): void;
|
|
34
|
+
declareVar(name: string): void;
|
|
35
|
+
predeclare(name: string, kind: VariableDeclarationKind): void;
|
|
36
|
+
assign(name: string, value: InterpreterValue): void;
|
|
37
|
+
lookup(name: string): ScopeLookupResult;
|
|
38
|
+
snapshot(): InterpreterSnapshot;
|
|
39
|
+
copyInitializedBindingsFrom(source: Scope, names: readonly string[]): void;
|
|
40
|
+
private resolveScope;
|
|
41
|
+
private requireInitializedBinding;
|
|
42
|
+
}
|
|
43
|
+
export {};
|