1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Allow long const eval for large JavaScript bundles
//! # PCTX Runtime
//!
//! A Deno extension providing registry-backed tool invocation and console output capturing.
//!
//! ## Overview
//!
//! This crate provides a pre-compiled V8 snapshot containing:
//! - **Registry Invocation**: Call any registered action (local callbacks, MCP tools, etc.) from JavaScript
//! - **Console Capturing**: Automatic stdout/stderr capture for testing and logging
//! - **Bash Execution**: `justBash` global for running shell commands via `just-bash`
//! - **Timers**: `setTimeout`/`setInterval` support
//!
//! The extension is initialized with a `PctxRegistry` that routes `invokeInternal` calls
//! to the appropriate handler at runtime.
//!
//! ## JavaScript API
//!
//! The runtime exposes the following globals:
//!
//! - `invokeInternal({ name, arguments })` - Invoke a registered action by ID
//! - `justBash` - Shell execution via the `just-bash` library
//!
//! ## Console Capturing
//!
//! All console methods are overridden and captured to arrays:
//!
//! ```javascript
//! console.log("hello"); // -> globalThis.__stdout
//! console.error("oops"); // -> globalThis.__stderr
//! console.warn("warn"); // -> globalThis.__stderr
//! console.info("info"); // -> globalThis.__stdout
//! console.debug("dbg"); // -> globalThis.__stdout
//! ```
pub use *;
/// Pre-compiled V8 snapshot containing the PCTX runtime
///
/// This snapshot includes:
/// - MCP tool calling JavaScript API (callMCPTool)
/// - Callback calling JavaScript API (invokeCallback)
/// - Console output capturing setup
/// - Network fetch with host permissions
/// - TypeScript type definitions
///
/// The snapshot is created at build time and loads instantly at runtime.
pub static RUNTIME_SNAPSHOT: & =
include_bytes!;
// Deno extension providing MCP client, local tools, and console capturing.
// Initialize with MCPRegistry, CallableToolRegistry, and AllowedHosts configuration.
// See README.md for complete documentation.
extension!;