nebula-ai-core 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.
Files changed (109) hide show
  1. package/README.md +24 -0
  2. package/package.json +69 -0
  3. package/src/brain/compaction.ts +131 -0
  4. package/src/brain/frozen-prefix.ts +320 -0
  5. package/src/brain/history-persist.ts +154 -0
  6. package/src/brain/index.ts +43 -0
  7. package/src/brain/openai-brain.ts +533 -0
  8. package/src/brain/sanitize.ts +23 -0
  9. package/src/brain/stub.ts +20 -0
  10. package/src/brain/types.ts +129 -0
  11. package/src/chain.ts +75 -0
  12. package/src/claude-plugins/discovery.ts +152 -0
  13. package/src/claude-plugins/index.ts +6 -0
  14. package/src/claude-plugins/types.ts +38 -0
  15. package/src/commands/index.ts +16 -0
  16. package/src/commands/registry.ts +255 -0
  17. package/src/config.ts +213 -0
  18. package/src/economy/index.ts +6 -0
  19. package/src/events/index.ts +4 -0
  20. package/src/events/listeners.ts +37 -0
  21. package/src/events/queue.ts +63 -0
  22. package/src/events/router.ts +42 -0
  23. package/src/events/types.ts +28 -0
  24. package/src/format.ts +12 -0
  25. package/src/identity/agent-card.ts +110 -0
  26. package/src/identity/deployments.ts +20 -0
  27. package/src/identity/erc8004.ts +161 -0
  28. package/src/identity/index.ts +29 -0
  29. package/src/identity/keystore-blob.ts +60 -0
  30. package/src/identity/receipt.ts +27 -0
  31. package/src/identity/stub.ts +29 -0
  32. package/src/identity/types.ts +20 -0
  33. package/src/index.ts +372 -0
  34. package/src/locks.ts +233 -0
  35. package/src/mcp/discovery.ts +150 -0
  36. package/src/mcp/index.ts +10 -0
  37. package/src/mcp/manager.ts +110 -0
  38. package/src/mcp/stdio-client.ts +154 -0
  39. package/src/mcp/types.ts +44 -0
  40. package/src/memory/edit.ts +53 -0
  41. package/src/memory/encryption.ts +88 -0
  42. package/src/memory/fs-util.ts +15 -0
  43. package/src/memory/index-file.ts +74 -0
  44. package/src/memory/index-sync.ts +99 -0
  45. package/src/memory/index.ts +58 -0
  46. package/src/memory/list-tool.ts +105 -0
  47. package/src/memory/pack-blob.ts +120 -0
  48. package/src/memory/pack-gather.ts +112 -0
  49. package/src/memory/parser.ts +20 -0
  50. package/src/memory/read-tool.ts +198 -0
  51. package/src/memory/save-tool.ts +189 -0
  52. package/src/memory/scan.ts +63 -0
  53. package/src/memory/topic.ts +32 -0
  54. package/src/memory/types.ts +49 -0
  55. package/src/migration/index.ts +6 -0
  56. package/src/migration/option3-crypto.ts +127 -0
  57. package/src/operator/index.ts +9 -0
  58. package/src/operator/keychain.ts +53 -0
  59. package/src/operator/keystore-file.ts +33 -0
  60. package/src/operator/privkey-base.ts +60 -0
  61. package/src/operator/raw-privkey.ts +39 -0
  62. package/src/operator/signer.ts +46 -0
  63. package/src/operator/walletconnect.ts +454 -0
  64. package/src/pairing.ts +285 -0
  65. package/src/paths.ts +70 -0
  66. package/src/permission/dangerous.ts +108 -0
  67. package/src/permission/env-redact.ts +54 -0
  68. package/src/permission/index.ts +16 -0
  69. package/src/permission/path-guard.ts +114 -0
  70. package/src/permission/service.ts +191 -0
  71. package/src/plugins/context.ts +225 -0
  72. package/src/plugins/hooks.ts +81 -0
  73. package/src/plugins/index.ts +24 -0
  74. package/src/plugins/tool-search.ts +49 -0
  75. package/src/public/card.ts +67 -0
  76. package/src/runtime/activity.ts +29 -0
  77. package/src/runtime/index.ts +2 -0
  78. package/src/runtime/runtime.ts +113 -0
  79. package/src/sandbox/credentials.ts +25 -0
  80. package/src/sandbox/docker.ts +396 -0
  81. package/src/sandbox/factory.ts +99 -0
  82. package/src/sandbox/index.ts +15 -0
  83. package/src/sandbox/linux.ts +141 -0
  84. package/src/sandbox/local.ts +19 -0
  85. package/src/sandbox/macos.ts +71 -0
  86. package/src/sandbox/seatbelt-profile.ts +139 -0
  87. package/src/sandbox/types.ts +129 -0
  88. package/src/skills/index.ts +8 -0
  89. package/src/skills/scanner.ts +257 -0
  90. package/src/skills/triggers.ts +78 -0
  91. package/src/skills/types.ts +37 -0
  92. package/src/storage/encryption.ts +87 -0
  93. package/src/storage/factory.ts +31 -0
  94. package/src/storage/index.ts +11 -0
  95. package/src/storage/local-stub.ts +70 -0
  96. package/src/storage/sqlite.ts +95 -0
  97. package/src/storage/types.ts +21 -0
  98. package/src/tools/escalation.ts +200 -0
  99. package/src/tools/index.ts +11 -0
  100. package/src/tools/registry.ts +152 -0
  101. package/src/tools/types.ts +65 -0
  102. package/src/tools/zod-helpers.ts +36 -0
  103. package/src/tools/zod-schema.ts +99 -0
  104. package/src/wallet/drain.ts +79 -0
  105. package/src/wallet/eoa.ts +51 -0
  106. package/src/wallet/index.ts +47 -0
  107. package/src/wallet/keystore.ts +50 -0
  108. package/src/wallet/operator-keystore-crypto.ts +530 -0
  109. package/src/wallet/operator-session.ts +344 -0
@@ -0,0 +1,161 @@
1
+ /**
2
+ * ERC-8004 ("Trustless Agents") Identity Registry client.
3
+ *
4
+ * Thin viem wrapper over the on-chain `NebulaIdentityRegistry` (see
5
+ * contracts/src/NebulaIdentityRegistry.sol). Each agent owns a transferable
6
+ * ERC-721 identity whose tokenURI is the agent card. Register, resolve, and
7
+ * reverse-resolve (agent EOA → id).
8
+ *
9
+ * The registry address is supplied per call (the CLI/tools read it from
10
+ * `NEBULA_IDENTITY_REGISTRY` or config). No canonical Mantle deployment is
11
+ * baked in yet — run `contracts/script/DeployIdentityRegistry.s.sol` and set
12
+ * the env var.
13
+ */
14
+ import type { Address, Hex, PublicClient, WalletClient } from 'viem'
15
+ import type { NebulaNetwork } from '../config'
16
+
17
+ export const IDENTITY_REGISTRY_ABI = [
18
+ {
19
+ type: 'function',
20
+ name: 'register',
21
+ stateMutability: 'nonpayable',
22
+ inputs: [
23
+ { name: 'cardURI', type: 'string' },
24
+ { name: 'agentAddress', type: 'address' },
25
+ ],
26
+ outputs: [{ name: 'agentId', type: 'uint256' }],
27
+ },
28
+ {
29
+ type: 'function',
30
+ name: 'setAgentCard',
31
+ stateMutability: 'nonpayable',
32
+ inputs: [
33
+ { name: 'agentId', type: 'uint256' },
34
+ { name: 'cardURI', type: 'string' },
35
+ ],
36
+ outputs: [],
37
+ },
38
+ {
39
+ type: 'function',
40
+ name: 'resolve',
41
+ stateMutability: 'view',
42
+ inputs: [{ name: 'agentId', type: 'uint256' }],
43
+ outputs: [
44
+ { name: 'owner', type: 'address' },
45
+ { name: 'agentAddress', type: 'address' },
46
+ { name: 'cardURI', type: 'string' },
47
+ ],
48
+ },
49
+ {
50
+ type: 'function',
51
+ name: 'agentIdByAddress',
52
+ stateMutability: 'view',
53
+ inputs: [{ name: '', type: 'address' }],
54
+ outputs: [{ name: '', type: 'uint256' }],
55
+ },
56
+ {
57
+ type: 'function',
58
+ name: 'ownerOf',
59
+ stateMutability: 'view',
60
+ inputs: [{ name: 'tokenId', type: 'uint256' }],
61
+ outputs: [{ name: 'owner', type: 'address' }],
62
+ },
63
+ {
64
+ type: 'function',
65
+ name: 'tokenURI',
66
+ stateMutability: 'view',
67
+ inputs: [{ name: 'agentId', type: 'uint256' }],
68
+ outputs: [{ name: '', type: 'string' }],
69
+ },
70
+ {
71
+ type: 'function',
72
+ name: 'totalAgents',
73
+ stateMutability: 'view',
74
+ inputs: [],
75
+ outputs: [{ name: '', type: 'uint256' }],
76
+ },
77
+ {
78
+ type: 'event',
79
+ name: 'AgentRegistered',
80
+ inputs: [
81
+ { name: 'agentId', type: 'uint256', indexed: true },
82
+ { name: 'owner', type: 'address', indexed: true },
83
+ { name: 'agentAddress', type: 'address', indexed: true },
84
+ { name: 'cardURI', type: 'string', indexed: false },
85
+ ],
86
+ },
87
+ ] as const
88
+
89
+ /**
90
+ * Deployed registry addresses per network. Override at runtime with
91
+ * NEBULA_IDENTITY_REGISTRY. Mainnet pending a funded deploy.
92
+ */
93
+ export const NEBULA_IDENTITY_REGISTRY: Partial<Record<NebulaNetwork, Address>> = {
94
+ 'mantle-testnet': '0x529ae7B0e8A8191c0307b918AA62f1Fc6557a621',
95
+ }
96
+
97
+ /** Resolve the registry address: explicit override → env → baked-in. null if unset. */
98
+ export function resolveRegistryAddress(network: NebulaNetwork, override?: string): Address | null {
99
+ const candidate =
100
+ override || process.env.NEBULA_IDENTITY_REGISTRY || NEBULA_IDENTITY_REGISTRY[network]
101
+ if (!candidate) return null
102
+ return candidate as Address
103
+ }
104
+
105
+ export interface ResolvedAgent {
106
+ agentId: bigint
107
+ owner: Address
108
+ agentAddress: Address
109
+ cardURI: string
110
+ }
111
+
112
+ /** Register a new agent identity. Returns the minted agentId + tx hash. */
113
+ export async function registerAgent(opts: {
114
+ walletClient: WalletClient
115
+ publicClient: PublicClient
116
+ registry: Address
117
+ cardURI: string
118
+ agentAddress: Address
119
+ }): Promise<{ agentId: bigint; txHash: Hex }> {
120
+ const account = opts.walletClient.account
121
+ if (!account) throw new Error('walletClient has no account')
122
+ const { request, result } = await opts.publicClient.simulateContract({
123
+ address: opts.registry,
124
+ abi: IDENTITY_REGISTRY_ABI,
125
+ functionName: 'register',
126
+ args: [opts.cardURI, opts.agentAddress],
127
+ account,
128
+ })
129
+ const txHash = await opts.walletClient.writeContract(request)
130
+ await opts.publicClient.waitForTransactionReceipt({ hash: txHash })
131
+ return { agentId: result as bigint, txHash }
132
+ }
133
+
134
+ /** Resolve an agent id → owner, operational address, card URI. */
135
+ export async function resolveAgentById(opts: {
136
+ publicClient: PublicClient
137
+ registry: Address
138
+ agentId: bigint
139
+ }): Promise<ResolvedAgent> {
140
+ const [owner, agentAddress, cardURI] = (await opts.publicClient.readContract({
141
+ address: opts.registry,
142
+ abi: IDENTITY_REGISTRY_ABI,
143
+ functionName: 'resolve',
144
+ args: [opts.agentId],
145
+ })) as [Address, Address, string]
146
+ return { agentId: opts.agentId, owner, agentAddress, cardURI }
147
+ }
148
+
149
+ /** Reverse-resolve: agent operational EOA → agentId (0n if not registered). */
150
+ export async function agentIdByAddress(opts: {
151
+ publicClient: PublicClient
152
+ registry: Address
153
+ agentAddress: Address
154
+ }): Promise<bigint> {
155
+ return (await opts.publicClient.readContract({
156
+ address: opts.registry,
157
+ abi: IDENTITY_REGISTRY_ABI,
158
+ functionName: 'agentIdByAddress',
159
+ args: [opts.agentAddress],
160
+ })) as bigint
161
+ }
@@ -0,0 +1,29 @@
1
+ export type { AgentIdentity, IdentityProvider } from './types'
2
+ export { StubIdentity } from './stub'
3
+
4
+ export {
5
+ EXPLORER_BASE,
6
+ type NetworkName,
7
+ explorerTxUrl,
8
+ explorerTokenUrl,
9
+ } from './deployments'
10
+ export { saveKeystoreLocally } from './keystore-blob'
11
+
12
+ // ERC-8004 (Trustless Agents) identity
13
+ export {
14
+ IDENTITY_REGISTRY_ABI,
15
+ NEBULA_IDENTITY_REGISTRY,
16
+ resolveRegistryAddress,
17
+ registerAgent,
18
+ resolveAgentById,
19
+ agentIdByAddress,
20
+ type ResolvedAgent,
21
+ } from './erc8004'
22
+ export {
23
+ type AgentCard,
24
+ type AgentCardSkill,
25
+ type AgentCardRegistration,
26
+ DEFAULT_AGENT_SKILLS,
27
+ buildAgentCard,
28
+ cardToDataUri,
29
+ } from './agent-card'
@@ -0,0 +1,60 @@
1
+ import { mkdir, writeFile } from 'node:fs/promises'
2
+ import { dirname } from 'node:path'
3
+ import type { Address, Hex } from 'viem'
4
+ import type { OperatorSigner } from '../operator/signer'
5
+ import {
6
+ type OperatorEncryptedKeystore,
7
+ encodeKeystoreBytes,
8
+ encryptAgentKey,
9
+ } from '../wallet/operator-keystore-crypto'
10
+
11
+ /**
12
+ * Local encrypted-keystore lifecycle.
13
+ *
14
+ * The agent's private key is encrypted to the operator wallet and stored as a
15
+ * local file at `~/.nebula/agents/<id>/keystore.json`. The ciphertext is
16
+ * decryptable only by the operator's wallet signature (sign-derived key, see
17
+ * operator-keystore-crypto.ts). Keys never leave RAM in plaintext.
18
+ */
19
+
20
+ /** Write an encrypted keystore JSON to `cachePath`, mkdir-p'ing the parent. */
21
+ async function writeKeystoreCache(
22
+ cachePath: string,
23
+ keystore: OperatorEncryptedKeystore,
24
+ ): Promise<void> {
25
+ await mkdir(dirname(cachePath), { recursive: true })
26
+ await writeFile(cachePath, JSON.stringify(keystore, null, 2), 'utf8')
27
+ }
28
+
29
+ /**
30
+ * Encrypt the agent privkey to the operator wallet and save the ciphertext
31
+ * to a local file. Performs ZERO chain or storage operations.
32
+ *
33
+ * **Call this BEFORE funding the agent EOA.** The encrypted keystore on disk
34
+ * is the durable insurance against any subsequent failure: once it exists,
35
+ * the operator wallet can always decrypt + recover the agent privkey, even
36
+ * if any later step blows up.
37
+ */
38
+ export async function saveKeystoreLocally(opts: {
39
+ signer?: OperatorSigner
40
+ agentAddress: Address
41
+ agentPrivkey: Hex
42
+ cachePath: string
43
+ /**
44
+ * Optional pre-derived AES key (32 bytes). When provided, the caller has
45
+ * already derived the keystore-scope key via `precomputeAllScopes` and wants
46
+ * to avoid a second `signTypedData` call. Used by `nebula init` so the
47
+ * operator-session cache and the encrypted keystore share the same derive.
48
+ */
49
+ precomputedKey?: Buffer
50
+ }): Promise<{ keystore: OperatorEncryptedKeystore; bytes: Uint8Array }> {
51
+ const keystore = await encryptAgentKey({
52
+ signer: opts.signer,
53
+ agentAddress: opts.agentAddress,
54
+ agentPrivkey: opts.agentPrivkey,
55
+ precomputedKey: opts.precomputedKey,
56
+ })
57
+ await writeKeystoreCache(opts.cachePath, keystore)
58
+ const bytes = encodeKeystoreBytes(keystore)
59
+ return { keystore, bytes }
60
+ }
@@ -0,0 +1,27 @@
1
+ import type { Hex, PublicClient, TransactionReceipt } from 'viem'
2
+
3
+ /**
4
+ * viem's `waitForTransactionReceipt` throws `TransactionReceiptNotFoundError`
5
+ * from inside its block-watcher when the RPC returns null for a tx that's
6
+ * still propagating. On Mantle's eventually-consistent testnet that's common.
7
+ * Wrap with a tolerant poll loop so hackathon-path UX doesn't bail.
8
+ */
9
+ export async function waitForReceiptResilient(
10
+ client: PublicClient,
11
+ hash: Hex,
12
+ opts?: { tries?: number; delayMs?: number },
13
+ ): Promise<TransactionReceipt> {
14
+ const tries = opts?.tries ?? 30
15
+ const delayMs = opts?.delayMs ?? 2000
16
+ let lastErr: unknown
17
+ for (let i = 0; i < tries; i++) {
18
+ try {
19
+ const receipt = await client.getTransactionReceipt({ hash })
20
+ return receipt
21
+ } catch (e) {
22
+ lastErr = e
23
+ await new Promise(r => setTimeout(r, delayMs))
24
+ }
25
+ }
26
+ throw lastErr ?? new Error(`receipt never arrived for ${hash}`)
27
+ }
@@ -0,0 +1,29 @@
1
+ import { placeholderAgentId } from '../paths'
2
+ import type { AgentIdentity, IdentityProvider } from './types'
3
+
4
+ /**
5
+ * Local stub identity provider. Fabricates an agent id from the wallet
6
+ * address so runtime + memory have something stable to key on before the
7
+ * iNFT is minted (phase 4).
8
+ */
9
+ export class StubIdentity implements IdentityProvider {
10
+ constructor(
11
+ private readonly ownerAddress: string,
12
+ private readonly agentEoa: string,
13
+ private readonly subname?: string,
14
+ ) {}
15
+
16
+ async current(): Promise<AgentIdentity> {
17
+ return {
18
+ agentId: placeholderAgentId(this.agentEoa),
19
+ iNFT: {
20
+ contract: null,
21
+ tokenId: null,
22
+ ownerAddress: this.ownerAddress,
23
+ network: 'local-stub',
24
+ },
25
+ agentEoa: this.agentEoa,
26
+ subname: this.subname,
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * iNFT state as seen by the runtime. Phase 4 wires this to the real
3
+ * ERC-7857 contract. Phase 1 provides a stub that fabricates an id from
4
+ * the wallet address so the rest of the runtime can reference identity.
5
+ */
6
+ export interface AgentIdentity {
7
+ agentId: string
8
+ iNFT: {
9
+ contract: string | null
10
+ tokenId: string | null
11
+ ownerAddress: string
12
+ network: 'mantle-mainnet' | 'mantle-testnet' | 'local-stub'
13
+ }
14
+ agentEoa: string
15
+ subname?: string
16
+ }
17
+
18
+ export interface IdentityProvider {
19
+ current(): Promise<AgentIdentity>
20
+ }
package/src/index.ts ADDED
@@ -0,0 +1,372 @@
1
+ // nebula-ai-core: always-on infrastructure for the nebula harness.
2
+ export const VERSION = '0.0.0'
3
+
4
+ export * from './config'
5
+ export { formatMnt } from './format'
6
+ export { agentPaths, placeholderAgentId } from './paths'
7
+
8
+ export type {
9
+ NebulaEvent,
10
+ EventPayload,
11
+ EventSource,
12
+ Listener,
13
+ RouterDeps,
14
+ } from './events'
15
+ export { EventQueue, newEventId, listeners, routeLoop } from './events'
16
+
17
+ export type {
18
+ ToolCall,
19
+ ToolDef,
20
+ ToolResult,
21
+ ToolSchema,
22
+ JSONSchema,
23
+ FetchEscalation,
24
+ EscalationDeps,
25
+ } from './tools'
26
+ export {
27
+ ToolRegistry,
28
+ zodToJsonSchema,
29
+ coerceBool,
30
+ coerceInt,
31
+ detectFetchEscalation,
32
+ mergeEscalationResult,
33
+ runEscalation,
34
+ } from './tools'
35
+
36
+ export type {
37
+ ApplyResult,
38
+ CommandScope,
39
+ CommandSurface,
40
+ ParsedSlash,
41
+ PermissionApi,
42
+ PermissionToggleMode,
43
+ SlashCommand,
44
+ } from './commands'
45
+ export {
46
+ COMMAND_REGISTRY,
47
+ applyPerms,
48
+ applyYolo,
49
+ commandsForSurface,
50
+ findCommand,
51
+ parseSlash,
52
+ suggestForPrefix,
53
+ } from './commands'
54
+
55
+ export type {
56
+ Brain,
57
+ BrainCompactionEvent,
58
+ BrainInferInput,
59
+ BrainTurn,
60
+ BrainMessage,
61
+ BrainProvider,
62
+ BrainProviderOpts,
63
+ CompactionOpts,
64
+ FrozenPrefix,
65
+ HistoryPersist,
66
+ FsHistoryPersistOpts,
67
+ OpenAIBrainOpts,
68
+ SummarizeFn,
69
+ } from './brain'
70
+ export {
71
+ StubBrain,
72
+ OpenAIBrain,
73
+ DEFAULT_BASE_URL,
74
+ DEFAULT_MODEL,
75
+ DEFAULT_CHANNEL_KEY,
76
+ DEFAULT_MAX_OUTPUT_TOKENS,
77
+ previewToolArgs,
78
+ inferToolOk,
79
+ buildFrozenPrefix,
80
+ renderFrozenPrefix,
81
+ DEFAULT_SYSTEM_PROMPT,
82
+ DEFAULT_COMPACTION_OPTS,
83
+ SUMMARY_SYSTEM_PROMPT,
84
+ estimateTokens,
85
+ shouldCompact,
86
+ compactHistory,
87
+ createFsHistoryPersist,
88
+ sanitizeChannelKey,
89
+ } from './brain'
90
+
91
+ export type {
92
+ MemoryType,
93
+ MemoryPartition,
94
+ MemoryFrontmatter,
95
+ MemoryTopic,
96
+ MemoryIndexEntry,
97
+ MemoryIndex,
98
+ EditOp,
99
+ EditAction,
100
+ ThreatScanResult,
101
+ } from './memory'
102
+ export {
103
+ parseTopic,
104
+ stringifyTopic,
105
+ scanForThreats,
106
+ applyEdit,
107
+ EditError,
108
+ parseIndex,
109
+ stringifyIndex,
110
+ readIndexFile,
111
+ writeIndexFile,
112
+ addEntryLine,
113
+ removeEntryLine,
114
+ readTopic,
115
+ writeTopic,
116
+ topicPath,
117
+ makeMemorySaveTool,
118
+ type MemorySaveArgs,
119
+ makeMemoryReadTool,
120
+ type MemoryReadArgs,
121
+ makeMemoryListTool,
122
+ type MemoryListArgs,
123
+ type MemoryListAgentFile,
124
+ ensureSyntheticIndexEntries,
125
+ STANDARD_SYNTHETIC_INDEX_FILES,
126
+ type SyntheticIndexFile,
127
+ type SyntheticIndexResult,
128
+ INDEX_LINE_LIMIT,
129
+ INDEX_BYTE_LIMIT,
130
+ MEMORY_BLOB_VERSION,
131
+ deriveMemoryKey,
132
+ encryptMemoryBytes,
133
+ decryptMemoryBytes,
134
+ PACK_BLOB_VERSION,
135
+ encodePackBlob,
136
+ decodePackBlob,
137
+ isV2Envelope,
138
+ type PackBlob,
139
+ type EncodePackOpts,
140
+ gatherAgentPack,
141
+ gatherUserPack,
142
+ writeAgentPack,
143
+ writeUserPack,
144
+ type GatherResult,
145
+ } from './memory'
146
+
147
+ export type { Storage } from './storage'
148
+ export {
149
+ LocalStubStorage,
150
+ SqliteStorage,
151
+ getStorage,
152
+ downloadBlobByRoot,
153
+ encrypt as encryptBytes,
154
+ decrypt as decryptBytes,
155
+ packEnvelope,
156
+ unpackEnvelope,
157
+ type EncryptedEnvelope,
158
+ } from './storage'
159
+
160
+ export {
161
+ encryptKey,
162
+ decryptKey,
163
+ generateAgentWallet,
164
+ saveKeystore,
165
+ loadKeystore,
166
+ type EncryptedKeystore,
167
+ type AgentWalletMaterial,
168
+ OPERATOR_KEYSTORE_VERSION,
169
+ OPERATOR_BLOB_SCOPES,
170
+ type OperatorBlobScope,
171
+ encryptAgentKey,
172
+ decryptAgentKey,
173
+ encryptOperatorBlob,
174
+ decryptOperatorBlob,
175
+ encodeKeystoreBytes,
176
+ decodeKeystoreBytes,
177
+ encodeOperatorBlobBytes,
178
+ decodeOperatorBlobBytes,
179
+ sniffKeystoreVersion,
180
+ deriveKeystoreKey,
181
+ deriveBlobKey,
182
+ deriveLegacyEmptyDomainKey,
183
+ tryDecryptKeystoreWithKey,
184
+ tryDecryptOperatorBlobWithKey,
185
+ type OperatorEncryptedKeystore,
186
+ type OperatorEncryptedBlob,
187
+ OPERATOR_SESSION_VERSION,
188
+ DEFAULT_OPERATOR_SESSION_TTL_MS,
189
+ type OperatorSession,
190
+ type OperatorSessionKeys,
191
+ type PrecomputeAllScopesOpts,
192
+ type PrecomputeVerifyKey,
193
+ operatorSessionPath,
194
+ writeOperatorSession,
195
+ readOperatorSession,
196
+ clearOperatorSession,
197
+ isOperatorSessionFresh,
198
+ isOperatorSessionComplete,
199
+ requiredScopesForAgent,
200
+ getSessionKey,
201
+ precomputeAllScopes,
202
+ buildOperatorSession,
203
+ drainAgentEOA,
204
+ type DrainAgentResult,
205
+ } from './wallet'
206
+
207
+ export type { AgentIdentity, IdentityProvider } from './identity'
208
+ export {
209
+ StubIdentity,
210
+ EXPLORER_BASE,
211
+ type NetworkName,
212
+ explorerTxUrl,
213
+ explorerTokenUrl,
214
+ saveKeystoreLocally,
215
+ IDENTITY_REGISTRY_ABI,
216
+ NEBULA_IDENTITY_REGISTRY,
217
+ resolveRegistryAddress,
218
+ registerAgent,
219
+ resolveAgentById,
220
+ agentIdByAddress,
221
+ type ResolvedAgent,
222
+ type AgentCard,
223
+ type AgentCardSkill,
224
+ type AgentCardRegistration,
225
+ DEFAULT_AGENT_SKILLS,
226
+ buildAgentCard,
227
+ cardToDataUri,
228
+ } from './identity'
229
+
230
+ export {
231
+ type OperatorSigner,
232
+ KeychainOperatorSigner,
233
+ KeystoreFileOperatorSigner,
234
+ RawPrivkeyOperatorSigner,
235
+ WalletConnectOperatorSigner,
236
+ NEBULA_WC_PROJECT_ID,
237
+ type WalletConnectOperatorSignerOptions,
238
+ } from './operator'
239
+ export { waitForReceiptResilient } from './identity/receipt'
240
+ export {
241
+ MIN_GAS_PRICE,
242
+ STORAGE_SUBMIT_GAS,
243
+ getGasPriceWithFloor,
244
+ makeViemClients,
245
+ mantleChain,
246
+ type ViemClients,
247
+ } from './chain'
248
+
249
+ export { Runtime, type RuntimeDeps, ActivityLog, type ActivityEntry } from './runtime'
250
+
251
+ export {
252
+ acquireScopedLock,
253
+ clearStaleScopedLock,
254
+ DEFAULT_LOCK_TTL_SECONDS,
255
+ type AcquireScopedLockOpts,
256
+ type AcquireScopedLockResult,
257
+ type ClearStaleScopedLockReason,
258
+ type ClearStaleScopedLockResult,
259
+ type ScopedLockHandle,
260
+ } from './locks'
261
+
262
+ export {
263
+ PairingStore,
264
+ PAIRING_ALPHABET,
265
+ PAIRING_CODE_LENGTH,
266
+ PAIRING_CODE_TTL_SECONDS,
267
+ PAIRING_RATE_LIMIT_SECONDS,
268
+ PAIRING_LOCKOUT_SECONDS,
269
+ PAIRING_MAX_PENDING_PER_PLATFORM,
270
+ PAIRING_MAX_FAILED_ATTEMPTS,
271
+ type PairingStoreOpts,
272
+ type PendingEntry,
273
+ type ApprovedEntry,
274
+ type PendingListing,
275
+ type ApprovedListing,
276
+ type ApproveResult,
277
+ } from './pairing'
278
+
279
+ export {
280
+ encryptToPubkey,
281
+ decryptWithPrivkey,
282
+ generateBootstrapKeypair,
283
+ type Option3Envelope,
284
+ } from './migration'
285
+
286
+ export {
287
+ HookBus,
288
+ type HookName,
289
+ type HookHandler,
290
+ type PreToolCallContext,
291
+ type PreToolCallResult,
292
+ type PostToolCallContext,
293
+ loadPlugins,
294
+ type PluginContext,
295
+ type NativePlugin,
296
+ type PluginLoadResult,
297
+ type PluginLoaderDeps,
298
+ type DelegateBrainFactory,
299
+ type DelegateBrainFactoryOpts,
300
+ type DelegateBrainHandle,
301
+ type DelegateBrainTurn,
302
+ type VisionInferFn,
303
+ type VisionInferInput,
304
+ type VisionInferImage,
305
+ type VisionInferResult,
306
+ makeToolSearchTool,
307
+ type ToolSearchArgs,
308
+ } from './plugins'
309
+
310
+ export {
311
+ detectDangerousCommand,
312
+ DANGEROUS_PATTERNS,
313
+ PathGuard,
314
+ type PathGuardOpts,
315
+ type PathGuardResult,
316
+ redactEnv,
317
+ type EnvRedactResult,
318
+ PermissionService,
319
+ type PermissionMode,
320
+ type PermissionDecision,
321
+ type PermissionRequest,
322
+ type PermissionPrompter,
323
+ type PermissionServiceOpts,
324
+ type DangerousMatch,
325
+ } from './permission'
326
+
327
+ export type { SkillFrontmatter, SkillRef, SkillSource } from './skills'
328
+ export {
329
+ scanSkills,
330
+ parseFrontmatter as parseSkillFrontmatter,
331
+ matchTriggers as matchSkillTriggers,
332
+ matchFilePattern,
333
+ matchBashPattern,
334
+ type SkillScannerOptions,
335
+ type SkillTriggerMatch,
336
+ } from './skills'
337
+
338
+ export {
339
+ discoverMcpServers,
340
+ McpManager,
341
+ McpStdioClient,
342
+ type McpDiscoveryOptions,
343
+ type McpServerConfig,
344
+ type McpServerStdio,
345
+ type McpServerHttp,
346
+ type McpToolMeta,
347
+ type McpDiscoveryResult,
348
+ } from './mcp'
349
+
350
+ export {
351
+ discoverClaudeExtras,
352
+ type ClaudeExtrasOptions,
353
+ type ClaudeCommand,
354
+ type ClaudeAgent,
355
+ type ClaudeExtrasDiscoveryResult,
356
+ } from './claude-plugins'
357
+
358
+ export {
359
+ LocalBackend,
360
+ MacOSSandboxExecBackend,
361
+ DockerBackend,
362
+ makeSandboxBackend,
363
+ buildSeatbeltProfile,
364
+ type SandboxBackend,
365
+ type SandboxBackendOpts,
366
+ type SandboxMode,
367
+ type SandboxSpawnRequest,
368
+ type WrappedSpawn,
369
+ type SeatbeltProfileOpts,
370
+ type MakeSandboxOpts,
371
+ type DockerBackendOpts,
372
+ } from './sandbox'