@enclave-vm/core 2.19.1 → 2.19.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +262 -105
- package/adapters/worker-pool/config.d.ts +15 -5
- package/adapters/worker-pool/protocol.d.ts +27 -1
- package/adapters/worker-pool/worker-pool-adapter.d.ts +24 -0
- package/adapters/worker-pool/worker-slot.d.ts +35 -6
- package/async-context.d.ts +34 -0
- package/babel/babel-wrapper.d.ts +21 -12
- package/babel/multi-file-transform.d.ts +3 -0
- package/babel/text-scan.d.ts +54 -0
- package/deadline-guard.d.ts +16 -0
- package/dynamic-import.d.ts +25 -0
- package/enclave-options.d.ts +62 -0
- package/enclave.d.ts +31 -7
- package/esm/index.mjs +4649 -774
- package/esm/worker.mjs +1136 -134
- package/execution-deadline.d.ts +6 -0
- package/global-function-gate.d.ts +34 -1
- package/index.d.ts +3 -3
- package/index.js +4690 -815
- package/interpreter/interpreter.d.ts +204 -6
- package/memory-tracker.d.ts +7 -0
- package/package.json +3 -3
- package/realm-airlock.d.ts +6 -1
- package/realm-memory.d.ts +89 -0
- package/realm-stack.d.ts +25 -0
- package/safe-runtime.d.ts +2 -0
- package/sandbox-rejections.d.ts +3 -1
- package/scoring/feature-extractor.d.ts +52 -1
- package/scoring/index.d.ts +2 -1
- package/scoring/scorers/index.d.ts +2 -1
- package/scoring/scorers/local-llm.scorer.d.ts +9 -3
- package/scoring/scorers/progressive.scorer.d.ts +28 -1
- package/scoring/scorers/rule-based.scorer.d.ts +11 -1
- package/scoring/types.d.ts +36 -8
- package/secure-proxy.d.ts +17 -3
- package/session/session.d.ts +8 -1
- package/session-types.d.ts +6 -4
- package/sidecar/index.d.ts +1 -1
- package/sidecar/reference-config.d.ts +18 -1
- package/sidecar/reference-resolver.d.ts +19 -1
- package/sidecar/reference-sidecar.d.ts +37 -0
- package/src/adapters/worker-pool/package.json +3 -3
- package/src/adapters/worker-pool/worker-script.js +2250 -428
- package/thrown-value.d.ts +59 -0
- package/types.d.ts +75 -19
- package/value-sanitizer.d.ts +6 -1
- package/worker.js +1136 -134
package/execution-deadline.d.ts
CHANGED
|
@@ -52,6 +52,12 @@ export interface HostActivity {
|
|
|
52
52
|
readonly inFlight: number;
|
|
53
53
|
/** The execution has settled by itself: stop watching */
|
|
54
54
|
close(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Runs a callback of the host (a tool handler, a function from `globals`) in the async context
|
|
57
|
+
* of the caller of `run()`. The script itself runs in another one (see ./async-context); where
|
|
58
|
+
* this is absent the callback is called as it is.
|
|
59
|
+
*/
|
|
60
|
+
inHostContext?<R>(fn: () => R): R;
|
|
55
61
|
}
|
|
56
62
|
/**
|
|
57
63
|
* Create the tracker of one execution.
|
|
@@ -34,6 +34,12 @@ export declare function isBuiltinPrototype(prototype: unknown): boolean;
|
|
|
34
34
|
* operate on data and are not gated; every other host function is.
|
|
35
35
|
*/
|
|
36
36
|
export declare function isBuiltinMethod(fn: unknown): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The built-in prototypes `fn` is a method of, or undefined when it is not a built-in method
|
|
39
|
+
* (see {@link isBuiltinMethod}). The membrane of the single VM runs such a method on a value of
|
|
40
|
+
* the host that has one of them in its prototype chain.
|
|
41
|
+
*/
|
|
42
|
+
export declare function builtinMethodHomes(fn: unknown): readonly object[] | undefined;
|
|
37
43
|
/**
|
|
38
44
|
* Whether `fn` is a built-in method that changes its receiver (see {@link MUTATING_BUILTIN_METHODS}).
|
|
39
45
|
*/
|
|
@@ -42,6 +48,29 @@ export declare function isMutatingBuiltinMethod(fn: unknown): boolean;
|
|
|
42
48
|
* Whether `fn` is a built-in method that runs a regular expression (see {@link REGEXP_MATCH_METHODS}).
|
|
43
49
|
*/
|
|
44
50
|
export declare function isRegExpMatchMethod(fn: unknown): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Whether `fn` is a built-in method that answers with the source text of the function it is
|
|
53
|
+
* called on: `Function.prototype.toString`, and `Object.prototype.toLocaleString`, which calls
|
|
54
|
+
* the `toString` of its receiver.
|
|
55
|
+
*/
|
|
56
|
+
export declare function isFunctionTextMethod(fn: unknown): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* What a script gets for the text of a host function: the form the engine gives a function
|
|
59
|
+
* without source, `function name() { [native code] }`.
|
|
60
|
+
*
|
|
61
|
+
* The source text of a function passed in `globals` is the host's code. A script may call the
|
|
62
|
+
* function; no conversion of it to a string (`toString()`, `String()`, a template literal,
|
|
63
|
+
* concatenation) gives that text. The name is the function's own `name` when that is a data
|
|
64
|
+
* property holding a plain identifier (no getter of the host runs for it); otherwise the form
|
|
65
|
+
* has no name.
|
|
66
|
+
*/
|
|
67
|
+
export declare function hostFunctionText(fn: unknown): string;
|
|
68
|
+
/**
|
|
69
|
+
* `text` without the source of the function `fn`: each occurrence is replaced by the fixed text.
|
|
70
|
+
* For the message of an error a host function raised while it ran on `fn`: such a message may
|
|
71
|
+
* quote the value the function ran on.
|
|
72
|
+
*/
|
|
73
|
+
export declare function withoutFunctionSource(text: string, fn: unknown): string;
|
|
45
74
|
/** What a script is told when it runs a regular expression of the host */
|
|
46
75
|
export declare const HOST_REGEXP_MESSAGE: string;
|
|
47
76
|
/** Default `maxGlobalFunctionCalls` is this many times `maxToolCalls`. */
|
|
@@ -91,5 +120,9 @@ export interface GlobalFunctionCallGate {
|
|
|
91
120
|
* Refuses calls once the execution is aborted or `maxGlobalFunctionCalls` is spent, sanitizes the
|
|
92
121
|
* return value like a tool result and re-creates it in the sandbox realm (a promise becomes a
|
|
93
122
|
* sandbox-realm promise), and turns host errors into safe errors.
|
|
123
|
+
*
|
|
124
|
+
* @param ownedBySandbox Whether a function was made in the sandbox realm. Such a function is the
|
|
125
|
+
* script's own, not a host function: the gate does not take a call to it (it would run it on
|
|
126
|
+
* copies of its arguments made for the host).
|
|
94
127
|
*/
|
|
95
|
-
export declare function createGlobalFunctionGate(context: ExecutionContext, realm: SandboxRealmBridge, unwrap?: UnwrapSandboxValue): GlobalFunctionCallGate;
|
|
128
|
+
export declare function createGlobalFunctionGate(context: ExecutionContext, realm: SandboxRealmBridge, unwrap?: UnwrapSandboxValue, ownedBySandbox?: (value: object) => boolean): GlobalFunctionCallGate;
|
package/index.d.ts
CHANGED
|
@@ -14,15 +14,15 @@ export { Enclave, runAgentScript } from './enclave';
|
|
|
14
14
|
export { disableSandboxRejectionGuard, isHostPromise } from './sandbox-rejections';
|
|
15
15
|
export type { ExecutionResult, ExecutionError, ExecutionStats, EnclaveConfig, CreateEnclaveOptions, ToolHandler, SafeRuntimeContext, ExecutionContext, SandboxAdapter, SecurityLevel, AstPreset, SecurityLevelConfig, SecureProxyLevelConfig, ReferenceSidecarOptions, WorkerPoolConfig, PartialDoubleVmConfig, CallToolOptions, ToolCallResult, ToolCallErrorInfo, ToolNamespaces, NormalizedToolNamespace, ConsoleHandler, ConsoleLevel, } from './types';
|
|
16
16
|
export { SECURITY_LEVEL_CONFIGS } from './types';
|
|
17
|
-
export { ScoringGate, ScoringGateError, createScoringGate, FeatureExtractor, ScoringCache, BaseScorer, DisabledScorer, RuleBasedScorer, ExternalApiScorer, ExternalApiScorerError, DEFAULT_SCORING_CONFIG, RULE_THRESHOLDS, } from './scoring';
|
|
17
|
+
export { ScoringGate, ScoringGateError, createScoringGate, FeatureExtractor, FeatureExtractionError, ScoringCache, BaseScorer, DisabledScorer, RuleBasedScorer, ExternalApiScorer, ExternalApiScorerError, DEFAULT_SCORING_CONFIG, RULE_THRESHOLDS, } from './scoring';
|
|
18
18
|
export type { Scorer, ScorerType, RiskLevel, SensitiveCategory, RuleId, ExtractedFeatures, ExtractedToolCall, PatternSignals, NumericSignals, SensitiveAccess, ExtractionMeta, RiskSignal, ScoringResult, ScoringGateResult, ScoringGateConfig, ScoringCacheConfig, LocalLlmConfig, ExternalApiConfig, } from './scoring';
|
|
19
19
|
export { createSafeRuntime, serializeSafeRuntime, SafeRuntimeOptions } from './safe-runtime';
|
|
20
20
|
export { createSecureProxy, wrapGlobalsWithSecureProxy, createSecureStandardLibrary, isSecureProxy, createSafeReflect, buildBlockedPropertiesFromConfig, getBlockedPropertiesForLevel, BLOCKED_PROPERTY_CATEGORIES, DEFAULT_SECURE_PROXY_CONFIG, SecureProxyOptions, BlockedPropertyCategory, } from './secure-proxy';
|
|
21
21
|
export { MemoryTracker, MemoryLimitError, MemoryTrackerConfig, MemoryUsageSnapshot, estimateStringSize, estimateArraySize, estimateObjectSize, } from './memory-tracker';
|
|
22
|
-
export { ReferenceConfig, REFERENCE_CONFIGS, REF_ID_PREFIX, REF_ID_SUFFIX, REF_ID_PATTERN, isReferenceId, getReferenceConfig, ReferenceSidecar, ReferenceSource, ReferenceMetadata, SidecarLimitError, ReferenceNotFoundError, ReferenceResolver, ResolutionLimitError, CompositeHandle, isCompositeHandle, } from './sidecar';
|
|
22
|
+
export { ReferenceConfig, REFERENCE_CONFIGS, REF_ID_PREFIX, REF_ID_SUFFIX, REF_ID_PATTERN, isReferenceId, getReferenceConfig, getMaxTotalResolvedSize, ReferenceSidecar, ReferenceSource, ReferenceMetadata, SidecarLimitError, ReferenceNotFoundError, ReferenceResolver, ResolutionLimitError, CompositeHandle, isCompositeHandle, } from './sidecar';
|
|
23
23
|
export { InterpreterAdapter } from './adapters/interpreter-adapter';
|
|
24
24
|
export type { InterpreterAdapterOptions } from './adapters/interpreter-adapter';
|
|
25
|
-
export { Interpreter, InterpreterError, StepLimitError } from './interpreter/interpreter';
|
|
25
|
+
export { Interpreter, InterpreterError, StepLimitError, DeadlineError } from './interpreter/interpreter';
|
|
26
26
|
export type { InterpreterOptions } from './interpreter/interpreter';
|
|
27
27
|
export { WorkerPoolAdapter, WorkerSlotStatus, ResourceUsage, WorkerPoolMetrics, DEFAULT_WORKER_POOL_CONFIG, WORKER_POOL_PRESETS, buildWorkerPoolConfig, WorkerPoolError, WorkerTimeoutError, WorkerMemoryError, WorkerCrashedError, WorkerPoolDisposedError, QueueFullError, QueueTimeoutError, ExecutionAbortedError, MessageFloodError, MessageValidationError, MessageSizeError, WorkerStartupError, TooManyPendingCallsError, WorkerSlot, ExecutionQueue, QueueStats, MemoryMonitor, MemoryMonitorStats, } from './adapters/worker-pool';
|
|
28
28
|
export { Session, createSession, SessionEmitter, createSessionEmitter, SessionStateMachine, createSessionStateMachine, EmbeddedChannel, createEmbeddedChannelPair, } from './session';
|