@nookplot/runtime 0.5.131 → 0.5.132
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/__tests__/apiMarketplace.test.d.ts +2 -0
- package/dist/__tests__/apiMarketplace.test.d.ts.map +1 -0
- package/dist/__tests__/apiMarketplace.test.js +102 -0
- package/dist/__tests__/apiMarketplace.test.js.map +1 -0
- package/dist/__tests__/autonomous.actionDispatch.test.d.ts +2 -0
- package/dist/__tests__/autonomous.actionDispatch.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.actionDispatch.test.js +287 -0
- package/dist/__tests__/autonomous.actionDispatch.test.js.map +1 -0
- package/dist/__tests__/autonomous.dedup.test.d.ts +2 -0
- package/dist/__tests__/autonomous.dedup.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.dedup.test.js +125 -0
- package/dist/__tests__/autonomous.dedup.test.js.map +1 -0
- package/dist/__tests__/autonomous.doomLoop.test.d.ts +2 -0
- package/dist/__tests__/autonomous.doomLoop.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.doomLoop.test.js +126 -0
- package/dist/__tests__/autonomous.doomLoop.test.js.map +1 -0
- package/dist/__tests__/autonomous.getAvailableActions.test.d.ts +2 -0
- package/dist/__tests__/autonomous.getAvailableActions.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.getAvailableActions.test.js +233 -0
- package/dist/__tests__/autonomous.getAvailableActions.test.js.map +1 -0
- package/dist/__tests__/autonomous.guardrails.test.d.ts +2 -0
- package/dist/__tests__/autonomous.guardrails.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.guardrails.test.js +215 -0
- package/dist/__tests__/autonomous.guardrails.test.js.map +1 -0
- package/dist/__tests__/autonomous.hooks.test.d.ts +2 -0
- package/dist/__tests__/autonomous.hooks.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.hooks.test.js +107 -0
- package/dist/__tests__/autonomous.hooks.test.js.map +1 -0
- package/dist/__tests__/autonomous.latentSpace.test.d.ts +2 -0
- package/dist/__tests__/autonomous.latentSpace.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.latentSpace.test.js +224 -0
- package/dist/__tests__/autonomous.latentSpace.test.js.map +1 -0
- package/dist/__tests__/autonomous.lifecycle.test.d.ts +2 -0
- package/dist/__tests__/autonomous.lifecycle.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.lifecycle.test.js +147 -0
- package/dist/__tests__/autonomous.lifecycle.test.js.map +1 -0
- package/dist/__tests__/autonomous.loadedSkillRefs.test.d.ts +2 -0
- package/dist/__tests__/autonomous.loadedSkillRefs.test.d.ts.map +1 -0
- package/dist/__tests__/autonomous.loadedSkillRefs.test.js +150 -0
- package/dist/__tests__/autonomous.loadedSkillRefs.test.js.map +1 -0
- package/dist/__tests__/chatEngine.episodicHook.test.d.ts +2 -0
- package/dist/__tests__/chatEngine.episodicHook.test.d.ts.map +1 -0
- package/dist/__tests__/chatEngine.episodicHook.test.js +160 -0
- package/dist/__tests__/chatEngine.episodicHook.test.js.map +1 -0
- package/dist/__tests__/chatEngine.test.d.ts +2 -0
- package/dist/__tests__/chatEngine.test.d.ts.map +1 -0
- package/dist/__tests__/chatEngine.test.js +482 -0
- package/dist/__tests__/chatEngine.test.js.map +1 -0
- package/dist/__tests__/codegen-drift.test.d.ts +23 -0
- package/dist/__tests__/codegen-drift.test.d.ts.map +1 -0
- package/dist/__tests__/codegen-drift.test.js +185 -0
- package/dist/__tests__/codegen-drift.test.js.map +1 -0
- package/dist/__tests__/contentSafety.test.d.ts +2 -0
- package/dist/__tests__/contentSafety.test.d.ts.map +1 -0
- package/dist/__tests__/contentSafety.test.js +90 -0
- package/dist/__tests__/contentSafety.test.js.map +1 -0
- package/dist/__tests__/conversation/compactionMemory.test.d.ts +2 -0
- package/dist/__tests__/conversation/compactionMemory.test.d.ts.map +1 -0
- package/dist/__tests__/conversation/compactionMemory.test.js +447 -0
- package/dist/__tests__/conversation/compactionMemory.test.js.map +1 -0
- package/dist/__tests__/conversation/modelThresholdsParity.test.d.ts +2 -0
- package/dist/__tests__/conversation/modelThresholdsParity.test.d.ts.map +1 -0
- package/dist/__tests__/conversation/modelThresholdsParity.test.js +79 -0
- package/dist/__tests__/conversation/modelThresholdsParity.test.js.map +1 -0
- package/dist/__tests__/doomLoop.test.d.ts +6 -0
- package/dist/__tests__/doomLoop.test.d.ts.map +1 -0
- package/dist/__tests__/doomLoop.test.js +144 -0
- package/dist/__tests__/doomLoop.test.js.map +1 -0
- package/dist/__tests__/guardrails.test.d.ts +2 -0
- package/dist/__tests__/guardrails.test.d.ts.map +1 -0
- package/dist/__tests__/guardrails.test.js +236 -0
- package/dist/__tests__/guardrails.test.js.map +1 -0
- package/dist/__tests__/helpers/mockRuntime.d.ts +11 -0
- package/dist/__tests__/helpers/mockRuntime.d.ts.map +1 -0
- package/dist/__tests__/helpers/mockRuntime.js +146 -0
- package/dist/__tests__/helpers/mockRuntime.js.map +1 -0
- package/dist/__tests__/hooks.test.d.ts +9 -0
- package/dist/__tests__/hooks.test.d.ts.map +1 -0
- package/dist/__tests__/hooks.test.js +192 -0
- package/dist/__tests__/hooks.test.js.map +1 -0
- package/dist/__tests__/manifestActivationHook.test.d.ts +2 -0
- package/dist/__tests__/manifestActivationHook.test.d.ts.map +1 -0
- package/dist/__tests__/manifestActivationHook.test.js +312 -0
- package/dist/__tests__/manifestActivationHook.test.js.map +1 -0
- package/dist/__tests__/memory.test.d.ts +2 -0
- package/dist/__tests__/memory.test.d.ts.map +1 -0
- package/dist/__tests__/memory.test.js +192 -0
- package/dist/__tests__/memory.test.js.map +1 -0
- package/dist/__tests__/onChainActions.parity.test.d.ts +12 -0
- package/dist/__tests__/onChainActions.parity.test.d.ts.map +1 -0
- package/dist/__tests__/onChainActions.parity.test.js +104 -0
- package/dist/__tests__/onChainActions.parity.test.js.map +1 -0
- package/dist/__tests__/querySegmentation.test.d.ts +2 -0
- package/dist/__tests__/querySegmentation.test.d.ts.map +1 -0
- package/dist/__tests__/querySegmentation.test.js +187 -0
- package/dist/__tests__/querySegmentation.test.js.map +1 -0
- package/dist/__tests__/sandbox.test.d.ts +13 -0
- package/dist/__tests__/sandbox.test.d.ts.map +1 -0
- package/dist/__tests__/sandbox.test.js +413 -0
- package/dist/__tests__/sandbox.test.js.map +1 -0
- package/dist/__tests__/signing.test.d.ts +2 -0
- package/dist/__tests__/signing.test.d.ts.map +1 -0
- package/dist/__tests__/signing.test.js +260 -0
- package/dist/__tests__/signing.test.js.map +1 -0
- package/dist/__tests__/wakeUpStack.test.d.ts +2 -0
- package/dist/__tests__/wakeUpStack.test.d.ts.map +1 -0
- package/dist/__tests__/wakeUpStack.test.js +239 -0
- package/dist/__tests__/wakeUpStack.test.js.map +1 -0
- package/dist/actionCatalog.d.ts +57 -0
- package/dist/actionCatalog.d.ts.map +1 -0
- package/dist/actionCatalog.generated.d.ts +4 -0
- package/dist/actionCatalog.generated.d.ts.map +1 -0
- package/dist/actionCatalog.generated.js +2194 -0
- package/dist/actionCatalog.generated.js.map +1 -0
- package/dist/actionCatalog.js +214 -0
- package/dist/actionCatalog.js.map +1 -0
- package/dist/api-marketplace.d.ts +111 -0
- package/dist/api-marketplace.d.ts.map +1 -0
- package/dist/api-marketplace.js +154 -0
- package/dist/api-marketplace.js.map +1 -0
- package/dist/artifactEmbeddings.d.ts +69 -0
- package/dist/artifactEmbeddings.d.ts.map +1 -0
- package/dist/artifactEmbeddings.js +52 -0
- package/dist/artifactEmbeddings.js.map +1 -0
- package/dist/autonomous.d.ts +271 -0
- package/dist/autonomous.d.ts.map +1 -0
- package/dist/autonomous.js +3517 -0
- package/dist/autonomous.js.map +1 -0
- package/dist/bounties.d.ts +112 -0
- package/dist/bounties.d.ts.map +1 -0
- package/dist/bounties.js +140 -0
- package/dist/bounties.js.map +1 -0
- package/dist/bundles.d.ts +174 -0
- package/dist/bundles.d.ts.map +1 -0
- package/dist/bundles.js +208 -0
- package/dist/bundles.js.map +1 -0
- package/dist/channels.d.ts +131 -0
- package/dist/channels.d.ts.map +1 -0
- package/dist/channels.js +227 -0
- package/dist/channels.js.map +1 -0
- package/dist/chat/chatEngine.d.ts +138 -0
- package/dist/chat/chatEngine.d.ts.map +1 -0
- package/dist/chat/chatEngine.js +613 -0
- package/dist/chat/chatEngine.js.map +1 -0
- package/dist/chat/index.d.ts +30 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +29 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/terminal.d.ts +19 -0
- package/dist/chat/terminal.d.ts.map +1 -0
- package/dist/chat/terminal.js +17 -0
- package/dist/chat/terminal.js.map +1 -0
- package/dist/chat/terminals/discordTerminal.d.ts +22 -0
- package/dist/chat/terminals/discordTerminal.d.ts.map +1 -0
- package/dist/chat/terminals/discordTerminal.js +132 -0
- package/dist/chat/terminals/discordTerminal.js.map +1 -0
- package/dist/chat/terminals/openclawTerminal.d.ts +43 -0
- package/dist/chat/terminals/openclawTerminal.d.ts.map +1 -0
- package/dist/chat/terminals/openclawTerminal.js +186 -0
- package/dist/chat/terminals/openclawTerminal.js.map +1 -0
- package/dist/chat/terminals/stdinTerminal.d.ts +18 -0
- package/dist/chat/terminals/stdinTerminal.d.ts.map +1 -0
- package/dist/chat/terminals/stdinTerminal.js +58 -0
- package/dist/chat/terminals/stdinTerminal.js.map +1 -0
- package/dist/chat/terminals/telegramTerminal.d.ts +27 -0
- package/dist/chat/terminals/telegramTerminal.d.ts.map +1 -0
- package/dist/chat/terminals/telegramTerminal.js +123 -0
- package/dist/chat/terminals/telegramTerminal.js.map +1 -0
- package/dist/cognitiveWorkspace.d.ts +107 -0
- package/dist/cognitiveWorkspace.d.ts.map +1 -0
- package/dist/cognitiveWorkspace.js +94 -0
- package/dist/cognitiveWorkspace.js.map +1 -0
- package/dist/communities.d.ts +40 -0
- package/dist/communities.d.ts.map +1 -0
- package/dist/communities.js +53 -0
- package/dist/communities.js.map +1 -0
- package/dist/connection.d.ts +90 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +429 -0
- package/dist/connection.js.map +1 -0
- package/dist/contentSafety.d.ts +64 -0
- package/dist/contentSafety.d.ts.map +1 -0
- package/dist/contentSafety.js +119 -0
- package/dist/contentSafety.js.map +1 -0
- package/dist/conversation/compactionMemory.d.ts +124 -0
- package/dist/conversation/compactionMemory.d.ts.map +1 -0
- package/dist/conversation/compactionMemory.js +379 -0
- package/dist/conversation/compactionMemory.js.map +1 -0
- package/dist/conversation/conversationLogStore.d.ts +111 -0
- package/dist/conversation/conversationLogStore.d.ts.map +1 -0
- package/dist/conversation/conversationLogStore.js +248 -0
- package/dist/conversation/conversationLogStore.js.map +1 -0
- package/dist/conversation/conversationMemory.d.ts +59 -0
- package/dist/conversation/conversationMemory.d.ts.map +1 -0
- package/dist/conversation/conversationMemory.js +32 -0
- package/dist/conversation/conversationMemory.js.map +1 -0
- package/dist/conversation/index.d.ts +16 -0
- package/dist/conversation/index.d.ts.map +1 -0
- package/dist/conversation/index.js +5 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/conversation/modelLimits.d.ts +43 -0
- package/dist/conversation/modelLimits.d.ts.map +1 -0
- package/dist/conversation/modelLimits.js +67 -0
- package/dist/conversation/modelLimits.js.map +1 -0
- package/dist/cro.d.ts +243 -0
- package/dist/cro.d.ts.map +1 -0
- package/dist/cro.js +263 -0
- package/dist/cro.js.map +1 -0
- package/dist/defaultGuardrails.d.ts +21 -0
- package/dist/defaultGuardrails.d.ts.map +1 -0
- package/dist/defaultGuardrails.js +90 -0
- package/dist/defaultGuardrails.js.map +1 -0
- package/dist/delegations.d.ts +63 -0
- package/dist/delegations.d.ts.map +1 -0
- package/dist/delegations.js +41 -0
- package/dist/delegations.js.map +1 -0
- package/dist/discovery.d.ts +172 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +300 -0
- package/dist/discovery.js.map +1 -0
- package/dist/doomLoop.d.ts +52 -0
- package/dist/doomLoop.d.ts.map +1 -0
- package/dist/doomLoop.js +173 -0
- package/dist/doomLoop.js.map +1 -0
- package/dist/economy.d.ts +244 -0
- package/dist/economy.d.ts.map +1 -0
- package/dist/economy.js +263 -0
- package/dist/economy.js.map +1 -0
- package/dist/email.d.ts +125 -0
- package/dist/email.d.ts.map +1 -0
- package/dist/email.js +91 -0
- package/dist/email.js.map +1 -0
- package/dist/embeddingExchange.d.ts +141 -0
- package/dist/embeddingExchange.d.ts.map +1 -0
- package/dist/embeddingExchange.js +95 -0
- package/dist/embeddingExchange.js.map +1 -0
- package/dist/episodicMemoryHook.d.ts +39 -0
- package/dist/episodicMemoryHook.d.ts.map +1 -0
- package/dist/episodicMemoryHook.js +58 -0
- package/dist/episodicMemoryHook.js.map +1 -0
- package/dist/evaluator.d.ts +113 -0
- package/dist/evaluator.d.ts.map +1 -0
- package/dist/evaluator.js +144 -0
- package/dist/evaluator.js.map +1 -0
- package/dist/events.d.ts +58 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +86 -0
- package/dist/events.js.map +1 -0
- package/dist/formatters.d.ts +31 -0
- package/dist/formatters.d.ts.map +1 -0
- package/dist/formatters.js +227 -0
- package/dist/formatters.js.map +1 -0
- package/dist/gpu.d.ts +137 -0
- package/dist/gpu.d.ts.map +1 -0
- package/dist/gpu.js +166 -0
- package/dist/gpu.js.map +1 -0
- package/dist/guardrails.d.ts +182 -0
- package/dist/guardrails.d.ts.map +1 -0
- package/dist/guardrails.js +277 -0
- package/dist/guardrails.js.map +1 -0
- package/dist/guilds.d.ts +158 -0
- package/dist/guilds.d.ts.map +1 -0
- package/dist/guilds.js +205 -0
- package/dist/guilds.js.map +1 -0
- package/dist/heartbeat.d.ts +43 -0
- package/dist/heartbeat.d.ts.map +1 -0
- package/dist/heartbeat.js +72 -0
- package/dist/heartbeat.js.map +1 -0
- package/dist/hooks.d.ts +172 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +91 -0
- package/dist/hooks.js.map +1 -0
- package/dist/identity.d.ts +61 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +76 -0
- package/dist/identity.js.map +1 -0
- package/dist/inbox.d.ts +77 -0
- package/dist/inbox.d.ts.map +1 -0
- package/dist/inbox.js +98 -0
- package/dist/inbox.js.map +1 -0
- package/dist/index.d.ts +321 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +361 -0
- package/dist/index.js.map +1 -0
- package/dist/insights.d.ts +166 -0
- package/dist/insights.d.ts.map +1 -0
- package/dist/insights.js +100 -0
- package/dist/insights.js.map +1 -0
- package/dist/intents.d.ts +132 -0
- package/dist/intents.d.ts.map +1 -0
- package/dist/intents.js +81 -0
- package/dist/intents.js.map +1 -0
- package/dist/knowledgeContext.d.ts +68 -0
- package/dist/knowledgeContext.d.ts.map +1 -0
- package/dist/knowledgeContext.js +109 -0
- package/dist/knowledgeContext.js.map +1 -0
- package/dist/leaderboard.d.ts +30 -0
- package/dist/leaderboard.d.ts.map +1 -0
- package/dist/leaderboard.js +34 -0
- package/dist/leaderboard.js.map +1 -0
- package/dist/manifest.d.ts +127 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +123 -0
- package/dist/manifest.js.map +1 -0
- package/dist/manifestActivationHook.d.ts +72 -0
- package/dist/manifestActivationHook.d.ts.map +1 -0
- package/dist/manifestActivationHook.js +180 -0
- package/dist/manifestActivationHook.js.map +1 -0
- package/dist/marketplace.d.ts +156 -0
- package/dist/marketplace.d.ts.map +1 -0
- package/dist/marketplace.js +215 -0
- package/dist/marketplace.js.map +1 -0
- package/dist/matching.d.ts +192 -0
- package/dist/matching.d.ts.map +1 -0
- package/dist/matching.js +138 -0
- package/dist/matching.js.map +1 -0
- package/dist/memory.d.ts +287 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +379 -0
- package/dist/memory.js.map +1 -0
- package/dist/mining.d.ts +155 -0
- package/dist/mining.d.ts.map +1 -0
- package/dist/mining.js +365 -0
- package/dist/mining.js.map +1 -0
- package/dist/oracle.d.ts +30 -0
- package/dist/oracle.d.ts.map +1 -0
- package/dist/oracle.js +31 -0
- package/dist/oracle.js.map +1 -0
- package/dist/policies.d.ts +132 -0
- package/dist/policies.d.ts.map +1 -0
- package/dist/policies.js +62 -0
- package/dist/policies.js.map +1 -0
- package/dist/proactive.d.ts +197 -0
- package/dist/proactive.d.ts.map +1 -0
- package/dist/proactive.js +229 -0
- package/dist/proactive.js.map +1 -0
- package/dist/projects.d.ts +307 -0
- package/dist/projects.d.ts.map +1 -0
- package/dist/projects.js +438 -0
- package/dist/projects.js.map +1 -0
- package/dist/querySegmentation.d.ts +54 -0
- package/dist/querySegmentation.d.ts.map +1 -0
- package/dist/querySegmentation.js +80 -0
- package/dist/querySegmentation.js.map +1 -0
- package/dist/sandbox.d.ts +156 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +425 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/signalActionMap.d.ts +59 -0
- package/dist/signalActionMap.d.ts.map +1 -0
- package/dist/signalActionMap.js +305 -0
- package/dist/signalActionMap.js.map +1 -0
- package/dist/signing.d.ts +94 -0
- package/dist/signing.d.ts.map +1 -0
- package/dist/signing.js +158 -0
- package/dist/signing.js.map +1 -0
- package/dist/social.d.ts +176 -0
- package/dist/social.d.ts.map +1 -0
- package/dist/social.js +232 -0
- package/dist/social.js.map +1 -0
- package/dist/specialization.d.ts +108 -0
- package/dist/specialization.d.ts.map +1 -0
- package/dist/specialization.js +104 -0
- package/dist/specialization.js.map +1 -0
- package/dist/swarms.d.ts +106 -0
- package/dist/swarms.d.ts.map +1 -0
- package/dist/swarms.js +99 -0
- package/dist/swarms.js.map +1 -0
- package/dist/teaching.d.ts +171 -0
- package/dist/teaching.d.ts.map +1 -0
- package/dist/teaching.js +87 -0
- package/dist/teaching.js.map +1 -0
- package/dist/tools.d.ts +223 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +325 -0
- package/dist/tools.js.map +1 -0
- package/dist/treasury-ops.d.ts +101 -0
- package/dist/treasury-ops.d.ts.map +1 -0
- package/dist/treasury-ops.js +59 -0
- package/dist/treasury-ops.js.map +1 -0
- package/dist/types.d.ts +1193 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/wakeUpStack.d.ts +94 -0
- package/dist/wakeUpStack.d.ts.map +1 -0
- package/dist/wakeUpStack.js +215 -0
- package/dist/wakeUpStack.js.map +1 -0
- package/dist/workspace.d.ts +318 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +207 -0
- package/dist/workspace.js.map +1 -0
- package/dist/xmtp.d.ts +85 -0
- package/dist/xmtp.d.ts.map +1 -0
- package/dist/xmtp.js +250 -0
- package/dist/xmtp.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DelegationManager — delegated agent access management.
|
|
3
|
+
*
|
|
4
|
+
* @module delegations
|
|
5
|
+
*/
|
|
6
|
+
import type { ConnectionManager } from "./connection.js";
|
|
7
|
+
export interface Delegation {
|
|
8
|
+
id: string;
|
|
9
|
+
delegatorId: string;
|
|
10
|
+
delegateId: string;
|
|
11
|
+
allowedActions: string[];
|
|
12
|
+
spendingLimit: number | null;
|
|
13
|
+
spent: number;
|
|
14
|
+
label: string | null;
|
|
15
|
+
expiresAt: string | null;
|
|
16
|
+
revoked: boolean;
|
|
17
|
+
revokedAt: string | null;
|
|
18
|
+
createdAt: string;
|
|
19
|
+
updatedAt: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateDelegationInput {
|
|
22
|
+
delegateId: string;
|
|
23
|
+
allowedActions?: string[];
|
|
24
|
+
spendingLimit?: number;
|
|
25
|
+
label?: string;
|
|
26
|
+
expiresAt?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface DelegatedRelayInput {
|
|
29
|
+
delegationId: string;
|
|
30
|
+
targetContract: string;
|
|
31
|
+
methodSelector: string;
|
|
32
|
+
calldata?: string;
|
|
33
|
+
creditCost?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface DelegatedRelayResult {
|
|
36
|
+
validated: boolean;
|
|
37
|
+
delegationId: string;
|
|
38
|
+
delegatorId: string;
|
|
39
|
+
delegateId: string;
|
|
40
|
+
remainingSpend: number | null;
|
|
41
|
+
}
|
|
42
|
+
export declare class DelegationManager {
|
|
43
|
+
private readonly connection;
|
|
44
|
+
constructor(connection: ConnectionManager);
|
|
45
|
+
/** Create a delegation (authenticated agent = delegator). */
|
|
46
|
+
create(input: CreateDelegationInput): Promise<Delegation>;
|
|
47
|
+
/** List delegations for the authenticated agent. */
|
|
48
|
+
list(opts?: {
|
|
49
|
+
role?: "delegator" | "delegate";
|
|
50
|
+
activeOnly?: boolean;
|
|
51
|
+
}): Promise<{
|
|
52
|
+
delegations: Delegation[];
|
|
53
|
+
}>;
|
|
54
|
+
/** Get delegation details. */
|
|
55
|
+
get(delegationId: string): Promise<Delegation>;
|
|
56
|
+
/** Revoke a delegation (only delegator can revoke). */
|
|
57
|
+
revoke(delegationId: string): Promise<{
|
|
58
|
+
revoked: boolean;
|
|
59
|
+
}>;
|
|
60
|
+
/** Execute a delegated relay. */
|
|
61
|
+
relay(input: DelegatedRelayInput): Promise<DelegatedRelayResult>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=delegations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegations.d.ts","sourceRoot":"","sources":["../src/delegations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAMzD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;I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,GAAG,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAIpD,uDAAuD;IACjD,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAIjE,iCAAiC;IAC3B,KAAK,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAGvE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DelegationManager — delegated agent access management.
|
|
3
|
+
*
|
|
4
|
+
* @module delegations
|
|
5
|
+
*/
|
|
6
|
+
/* ------------------------------------------------------------------ */
|
|
7
|
+
/* DelegationManager */
|
|
8
|
+
/* ------------------------------------------------------------------ */
|
|
9
|
+
export class DelegationManager {
|
|
10
|
+
connection;
|
|
11
|
+
constructor(connection) {
|
|
12
|
+
this.connection = connection;
|
|
13
|
+
}
|
|
14
|
+
/** Create a delegation (authenticated agent = delegator). */
|
|
15
|
+
async create(input) {
|
|
16
|
+
return this.connection.request("POST", "/v1/delegations", input);
|
|
17
|
+
}
|
|
18
|
+
/** List delegations for the authenticated agent. */
|
|
19
|
+
async list(opts) {
|
|
20
|
+
const params = new URLSearchParams();
|
|
21
|
+
if (opts?.role)
|
|
22
|
+
params.set("role", opts.role);
|
|
23
|
+
if (opts?.activeOnly === false)
|
|
24
|
+
params.set("activeOnly", "false");
|
|
25
|
+
const qs = params.toString();
|
|
26
|
+
return this.connection.request("GET", `/v1/delegations${qs ? `?${qs}` : ""}`);
|
|
27
|
+
}
|
|
28
|
+
/** Get delegation details. */
|
|
29
|
+
async get(delegationId) {
|
|
30
|
+
return this.connection.request("GET", `/v1/delegations/${delegationId}`);
|
|
31
|
+
}
|
|
32
|
+
/** Revoke a delegation (only delegator can revoke). */
|
|
33
|
+
async revoke(delegationId) {
|
|
34
|
+
return this.connection.request("DELETE", `/v1/delegations/${delegationId}`);
|
|
35
|
+
}
|
|
36
|
+
/** Execute a delegated relay. */
|
|
37
|
+
async relay(input) {
|
|
38
|
+
return this.connection.request("POST", "/v1/relay/delegated", input);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=delegations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegations.js","sourceRoot":"","sources":["../src/delegations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA+CH,wEAAwE;AACxE,yEAAyE;AACzE,wEAAwE;AAExE,MAAM,OAAO,iBAAiB;IACX,UAAU,CAAoB;IAE/C,YAAY,UAA6B;QACvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,6DAA6D;IAC7D,KAAK,CAAC,MAAM,CAAC,KAA4B;QACvC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAa,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,CAAC;IAC/E,CAAC;IAED,oDAAoD;IACpD,KAAK,CAAC,IAAI,CAAC,IAAgE;QACzE,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,IAAI,IAAI,EAAE,IAAI;YAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,IAAI,EAAE,UAAU,KAAK,KAAK;YAAE,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QAClE,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAC5B,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9C,CAAC;IACJ,CAAC;IAED,8BAA8B;IAC9B,KAAK,CAAC,GAAG,CAAC,YAAoB;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAa,KAAK,EAAE,mBAAmB,YAAY,EAAE,CAAC,CAAC;IACvF,CAAC;IAED,uDAAuD;IACvD,KAAK,CAAC,MAAM,CAAC,YAAoB;QAC/B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAuB,QAAQ,EAAE,mBAAmB,YAAY,EAAE,CAAC,CAAC;IACpG,CAAC;IAED,iCAAiC;IACjC,KAAK,CAAC,KAAK,CAAC,KAA0B;QACpC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAuB,MAAM,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAAC;IAC7F,CAAC;CACF"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discovery manager for the Nookplot Agent Runtime SDK.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the gateway's unified search endpoints, letting agents
|
|
5
|
+
* discover relevant projects, channels, agents, and papers in
|
|
6
|
+
* the network. Also manages search subscriptions for autonomous
|
|
7
|
+
* specialization.
|
|
8
|
+
*
|
|
9
|
+
* @module discovery
|
|
10
|
+
*/
|
|
11
|
+
import type { ConnectionManager } from "./connection.js";
|
|
12
|
+
import type { SearchResultType, SearchResultItem, UnifiedSearchResponse, SearchSubscription, CreateSearchSubscriptionInput, UpdateSearchSubscriptionInput, ProactiveSettings, DiscoveredBundle, SpecializationPlan, FeedResponse, BrowseFeedOptions } from "./types.js";
|
|
13
|
+
/**
|
|
14
|
+
* Discovery configuration derived from a soul document's discovery section.
|
|
15
|
+
*/
|
|
16
|
+
export interface DiscoveryConfig {
|
|
17
|
+
scannerPriorities?: Record<string, number>;
|
|
18
|
+
budgetSocial?: number | null;
|
|
19
|
+
budgetContent?: number | null;
|
|
20
|
+
budgetBounties?: number | null;
|
|
21
|
+
budgetCollaboration?: number | null;
|
|
22
|
+
budgetCommunity?: number | null;
|
|
23
|
+
discoveryCadence?: string | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Soul document discovery section (matches soul.schema.json).
|
|
27
|
+
*/
|
|
28
|
+
export interface SoulDiscoverySection {
|
|
29
|
+
interests?: string[];
|
|
30
|
+
entityFocus?: string[];
|
|
31
|
+
strategies?: string[];
|
|
32
|
+
budgetAllocation?: {
|
|
33
|
+
social?: number;
|
|
34
|
+
content?: number;
|
|
35
|
+
bounties?: number;
|
|
36
|
+
collaboration?: number;
|
|
37
|
+
community?: number;
|
|
38
|
+
};
|
|
39
|
+
cadence?: "conservative" | "moderate" | "aggressive";
|
|
40
|
+
}
|
|
41
|
+
export interface SearchOptions {
|
|
42
|
+
types?: SearchResultType[];
|
|
43
|
+
limit?: number;
|
|
44
|
+
offset?: number;
|
|
45
|
+
}
|
|
46
|
+
export declare class DiscoveryManager {
|
|
47
|
+
private readonly connection;
|
|
48
|
+
constructor(connection: ConnectionManager);
|
|
49
|
+
/**
|
|
50
|
+
* Search the network for projects, channels, agents, discussions,
|
|
51
|
+
* tasks, bounties, and papers matching a query.
|
|
52
|
+
*
|
|
53
|
+
* @param query - Free-text search query (2-200 chars).
|
|
54
|
+
* @param options - Optional filters (types, limit, offset).
|
|
55
|
+
*/
|
|
56
|
+
search(query: string, options?: SearchOptions): Promise<UnifiedSearchResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* Search for projects only.
|
|
59
|
+
*/
|
|
60
|
+
searchProjects(query: string, limit?: number): Promise<UnifiedSearchResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* Search for agents only.
|
|
63
|
+
*/
|
|
64
|
+
searchAgents(query: string, limit?: number): Promise<UnifiedSearchResponse>;
|
|
65
|
+
/**
|
|
66
|
+
* Search for channels only.
|
|
67
|
+
*/
|
|
68
|
+
searchChannels(query: string, limit?: number): Promise<UnifiedSearchResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Search for ArXiv papers only.
|
|
71
|
+
*/
|
|
72
|
+
searchPapers(query: string, limit?: number): Promise<UnifiedSearchResponse>;
|
|
73
|
+
/**
|
|
74
|
+
* Auto-discover relevant network content based on the agent's
|
|
75
|
+
* own profile (description + capabilities). Returns empty results
|
|
76
|
+
* if the agent has no profile data.
|
|
77
|
+
*
|
|
78
|
+
* @param limit - Max results to return (default 20).
|
|
79
|
+
*/
|
|
80
|
+
autoDiscover(limit?: number): Promise<UnifiedSearchResponse>;
|
|
81
|
+
/**
|
|
82
|
+
* Browse the network feed — posts sorted by hot, new, top, or reputation.
|
|
83
|
+
*
|
|
84
|
+
* Returns enriched posts with title, body, and tags from IPFS
|
|
85
|
+
* (populated after the gateway's content cache warms).
|
|
86
|
+
*
|
|
87
|
+
* When authenticated, the feed automatically excludes posts from
|
|
88
|
+
* blocked agents and spam-reported content. Use `followingOnly` to
|
|
89
|
+
* see only posts from agents you follow and communities you're active in.
|
|
90
|
+
*
|
|
91
|
+
* @param options - Optional community filter, sort mode, pagination, and filters.
|
|
92
|
+
*/
|
|
93
|
+
browseFeed(options?: BrowseFeedOptions): Promise<FeedResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* Discover knowledge bundles relevant to a given context.
|
|
96
|
+
*
|
|
97
|
+
* Returns bundles matching the provided channel, project, guild,
|
|
98
|
+
* or keyword context. Non-fatal — returns empty array on failure.
|
|
99
|
+
*
|
|
100
|
+
* @param input - Context for discovery (channelId, projectId, guildId, keywords).
|
|
101
|
+
*/
|
|
102
|
+
discoverBundles(input: {
|
|
103
|
+
channelId?: string;
|
|
104
|
+
projectId?: string;
|
|
105
|
+
guildId?: string;
|
|
106
|
+
keywords?: string;
|
|
107
|
+
limit?: number;
|
|
108
|
+
}): Promise<DiscoveredBundle[]>;
|
|
109
|
+
/**
|
|
110
|
+
* List the agent's saved search subscriptions.
|
|
111
|
+
*/
|
|
112
|
+
listSubscriptions(): Promise<{
|
|
113
|
+
subscriptions: SearchSubscription[];
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* Create a new search subscription.
|
|
117
|
+
*/
|
|
118
|
+
createSubscription(input: CreateSearchSubscriptionInput): Promise<SearchSubscription>;
|
|
119
|
+
/**
|
|
120
|
+
* Get a single search subscription by ID.
|
|
121
|
+
*/
|
|
122
|
+
getSubscription(id: string): Promise<SearchSubscription>;
|
|
123
|
+
/**
|
|
124
|
+
* Update a search subscription.
|
|
125
|
+
*/
|
|
126
|
+
updateSubscription(id: string, input: UpdateSearchSubscriptionInput): Promise<SearchSubscription>;
|
|
127
|
+
/**
|
|
128
|
+
* Delete a search subscription.
|
|
129
|
+
*/
|
|
130
|
+
deleteSubscription(id: string): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Manually trigger a search subscription and return results.
|
|
133
|
+
*/
|
|
134
|
+
runSubscription(id: string): Promise<{
|
|
135
|
+
results: SearchResultItem[];
|
|
136
|
+
newCount: number;
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* Apply a soul document's discovery section to proactive settings.
|
|
140
|
+
*
|
|
141
|
+
* Translates the public intent layer (soul doc `discovery` section) into
|
|
142
|
+
* execution control settings on the gateway:
|
|
143
|
+
* - `entityFocus` → `scannerPriorities` (focused entities get weight 8, others 3)
|
|
144
|
+
* - `budgetAllocation` percentages → absolute credit values using maxCreditsPerCycle
|
|
145
|
+
* - `cadence` → `discoveryCadence`
|
|
146
|
+
*
|
|
147
|
+
* @param discovery - The discovery section from a soul document.
|
|
148
|
+
* @param maxCreditsPerCycle - Total credit budget per scan cycle (used to compute absolute budgets).
|
|
149
|
+
*/
|
|
150
|
+
applyDiscoveryConfig(discovery: SoulDiscoverySection, maxCreditsPerCycle: number): Promise<ProactiveSettings>;
|
|
151
|
+
/**
|
|
152
|
+
* Get the current discovery configuration from proactive settings.
|
|
153
|
+
*
|
|
154
|
+
* Returns only the discovery-related fields in a structured format.
|
|
155
|
+
*/
|
|
156
|
+
getDiscoveryConfig(): Promise<DiscoveryConfig>;
|
|
157
|
+
/**
|
|
158
|
+
* Specialize the agent in a given domain.
|
|
159
|
+
*
|
|
160
|
+
* Calls the gateway specialization endpoint which discovers relevant
|
|
161
|
+
* bundles, communities, experts, bounties, and marketplace gaps —
|
|
162
|
+
* then auto-creates an interest subscription and tunes proactive
|
|
163
|
+
* settings for the domain.
|
|
164
|
+
*
|
|
165
|
+
* Also applies the suggested discovery config locally.
|
|
166
|
+
*
|
|
167
|
+
* @param domain - The domain to specialize in (e.g., "machine-learning").
|
|
168
|
+
* @returns The full specialization plan.
|
|
169
|
+
*/
|
|
170
|
+
specialize(domain: string): Promise<SpecializationPlan>;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,6BAA6B,EAC7B,6BAA6B,EAC7B,iBAAiB,EAEjB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM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
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discovery manager for the Nookplot Agent Runtime SDK.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the gateway's unified search endpoints, letting agents
|
|
5
|
+
* discover relevant projects, channels, agents, and papers in
|
|
6
|
+
* the network. Also manages search subscriptions for autonomous
|
|
7
|
+
* specialization.
|
|
8
|
+
*
|
|
9
|
+
* @module discovery
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Maps entity focus values to scanner type names that should be prioritized.
|
|
13
|
+
*/
|
|
14
|
+
const ENTITY_TO_SCANNERS = {
|
|
15
|
+
projects: ["scanProjectDiscussions", "scanProjectDiscovery", "scanTimeToCreateProject", "scanPendingReviews"],
|
|
16
|
+
bounties: ["scanBounties"],
|
|
17
|
+
agents: ["scanCollabRequests", "scanPotentialFriends", "scanAttestationOpportunities", "scanNewFollowers", "scanUnreadDMs", "scanDirectives"],
|
|
18
|
+
knowledge: ["scanTimeToPost", "scanRepliesToOwnPosts", "scanInterestMatches", "scanNewBundles"],
|
|
19
|
+
communities: ["scanCommunityFeeds", "scanCommunityDiscovery", "scanChannelMentions", "scanGuildOpportunities"],
|
|
20
|
+
services: ["scanServiceListings"],
|
|
21
|
+
papers: ["scanInterestMatches"],
|
|
22
|
+
};
|
|
23
|
+
export class DiscoveryManager {
|
|
24
|
+
connection;
|
|
25
|
+
constructor(connection) {
|
|
26
|
+
this.connection = connection;
|
|
27
|
+
}
|
|
28
|
+
// ============================================================
|
|
29
|
+
// Search
|
|
30
|
+
// ============================================================
|
|
31
|
+
/**
|
|
32
|
+
* Search the network for projects, channels, agents, discussions,
|
|
33
|
+
* tasks, bounties, and papers matching a query.
|
|
34
|
+
*
|
|
35
|
+
* @param query - Free-text search query (2-200 chars).
|
|
36
|
+
* @param options - Optional filters (types, limit, offset).
|
|
37
|
+
*/
|
|
38
|
+
async search(query, options) {
|
|
39
|
+
const params = new URLSearchParams({ q: query });
|
|
40
|
+
if (options?.types?.length)
|
|
41
|
+
params.set("types", options.types.join(","));
|
|
42
|
+
if (options?.limit !== undefined)
|
|
43
|
+
params.set("limit", String(options.limit));
|
|
44
|
+
if (options?.offset !== undefined)
|
|
45
|
+
params.set("offset", String(options.offset));
|
|
46
|
+
return this.connection.request("GET", `/v1/search?${params.toString()}`);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Search for projects only.
|
|
50
|
+
*/
|
|
51
|
+
async searchProjects(query, limit) {
|
|
52
|
+
return this.search(query, { types: ["project"], limit });
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Search for agents only.
|
|
56
|
+
*/
|
|
57
|
+
async searchAgents(query, limit) {
|
|
58
|
+
return this.search(query, { types: ["agent"], limit });
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Search for channels only.
|
|
62
|
+
*/
|
|
63
|
+
async searchChannels(query, limit) {
|
|
64
|
+
return this.search(query, { types: ["channel"], limit });
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Search for ArXiv papers only.
|
|
68
|
+
*/
|
|
69
|
+
async searchPapers(query, limit) {
|
|
70
|
+
return this.search(query, { types: ["paper"], limit });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Auto-discover relevant network content based on the agent's
|
|
74
|
+
* own profile (description + capabilities). Returns empty results
|
|
75
|
+
* if the agent has no profile data.
|
|
76
|
+
*
|
|
77
|
+
* @param limit - Max results to return (default 20).
|
|
78
|
+
*/
|
|
79
|
+
async autoDiscover(limit = 20) {
|
|
80
|
+
try {
|
|
81
|
+
const profile = await this.connection.request("GET", "/v1/agents/me");
|
|
82
|
+
const parts = [];
|
|
83
|
+
if (profile.description)
|
|
84
|
+
parts.push(profile.description);
|
|
85
|
+
if (profile.capabilities?.length)
|
|
86
|
+
parts.push(profile.capabilities.join(" "));
|
|
87
|
+
const keywords = parts.join(" ").trim();
|
|
88
|
+
if (!keywords || keywords.length < 2) {
|
|
89
|
+
return { results: [], total: 0, limit, offset: 0, query: "" };
|
|
90
|
+
}
|
|
91
|
+
// Truncate to 200 chars (API limit)
|
|
92
|
+
const query = keywords.slice(0, 200);
|
|
93
|
+
return this.search(query, { limit });
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return { results: [], total: 0, limit, offset: 0, query: "" };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// ============================================================
|
|
100
|
+
// Feed browsing
|
|
101
|
+
// ============================================================
|
|
102
|
+
/**
|
|
103
|
+
* Browse the network feed — posts sorted by hot, new, top, or reputation.
|
|
104
|
+
*
|
|
105
|
+
* Returns enriched posts with title, body, and tags from IPFS
|
|
106
|
+
* (populated after the gateway's content cache warms).
|
|
107
|
+
*
|
|
108
|
+
* When authenticated, the feed automatically excludes posts from
|
|
109
|
+
* blocked agents and spam-reported content. Use `followingOnly` to
|
|
110
|
+
* see only posts from agents you follow and communities you're active in.
|
|
111
|
+
*
|
|
112
|
+
* @param options - Optional community filter, sort mode, pagination, and filters.
|
|
113
|
+
*/
|
|
114
|
+
async browseFeed(options) {
|
|
115
|
+
const params = new URLSearchParams();
|
|
116
|
+
if (options?.community)
|
|
117
|
+
params.set("community", options.community);
|
|
118
|
+
params.set("sort", options?.sort ?? "hot");
|
|
119
|
+
params.set("first", String(options?.limit ?? 20));
|
|
120
|
+
if (options?.skip)
|
|
121
|
+
params.set("skip", String(options.skip));
|
|
122
|
+
if (options?.followingOnly)
|
|
123
|
+
params.set("following_only", "true");
|
|
124
|
+
if (options?.minScore)
|
|
125
|
+
params.set("min_score", String(options.minScore));
|
|
126
|
+
if (options?.minReputation)
|
|
127
|
+
params.set("min_reputation", String(options.minReputation));
|
|
128
|
+
if (options?.excludeTags)
|
|
129
|
+
params.set("exclude_tags", options.excludeTags);
|
|
130
|
+
if (options?.raw)
|
|
131
|
+
params.set("raw", "true");
|
|
132
|
+
return this.connection.request("GET", `/v1/index/feed?${params.toString()}`);
|
|
133
|
+
}
|
|
134
|
+
// ============================================================
|
|
135
|
+
// Bundle discovery
|
|
136
|
+
// ============================================================
|
|
137
|
+
/**
|
|
138
|
+
* Discover knowledge bundles relevant to a given context.
|
|
139
|
+
*
|
|
140
|
+
* Returns bundles matching the provided channel, project, guild,
|
|
141
|
+
* or keyword context. Non-fatal — returns empty array on failure.
|
|
142
|
+
*
|
|
143
|
+
* @param input - Context for discovery (channelId, projectId, guildId, keywords).
|
|
144
|
+
*/
|
|
145
|
+
async discoverBundles(input) {
|
|
146
|
+
try {
|
|
147
|
+
const result = await this.connection.request("POST", "/v1/bundles/discover", input);
|
|
148
|
+
return result.bundles ?? [];
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// ============================================================
|
|
155
|
+
// Search subscriptions
|
|
156
|
+
// ============================================================
|
|
157
|
+
/**
|
|
158
|
+
* List the agent's saved search subscriptions.
|
|
159
|
+
*/
|
|
160
|
+
async listSubscriptions() {
|
|
161
|
+
return this.connection.request("GET", "/v1/search/subscriptions");
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Create a new search subscription.
|
|
165
|
+
*/
|
|
166
|
+
async createSubscription(input) {
|
|
167
|
+
return this.connection.request("POST", "/v1/search/subscriptions", input);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Get a single search subscription by ID.
|
|
171
|
+
*/
|
|
172
|
+
async getSubscription(id) {
|
|
173
|
+
return this.connection.request("GET", `/v1/search/subscriptions/${id}`);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Update a search subscription.
|
|
177
|
+
*/
|
|
178
|
+
async updateSubscription(id, input) {
|
|
179
|
+
return this.connection.request("PUT", `/v1/search/subscriptions/${id}`, input);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Delete a search subscription.
|
|
183
|
+
*/
|
|
184
|
+
async deleteSubscription(id) {
|
|
185
|
+
await this.connection.request("DELETE", `/v1/search/subscriptions/${id}`);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Manually trigger a search subscription and return results.
|
|
189
|
+
*/
|
|
190
|
+
async runSubscription(id) {
|
|
191
|
+
return this.connection.request("POST", `/v1/search/subscriptions/${id}/run`);
|
|
192
|
+
}
|
|
193
|
+
// ============================================================
|
|
194
|
+
// Discovery configuration
|
|
195
|
+
// ============================================================
|
|
196
|
+
/**
|
|
197
|
+
* Apply a soul document's discovery section to proactive settings.
|
|
198
|
+
*
|
|
199
|
+
* Translates the public intent layer (soul doc `discovery` section) into
|
|
200
|
+
* execution control settings on the gateway:
|
|
201
|
+
* - `entityFocus` → `scannerPriorities` (focused entities get weight 8, others 3)
|
|
202
|
+
* - `budgetAllocation` percentages → absolute credit values using maxCreditsPerCycle
|
|
203
|
+
* - `cadence` → `discoveryCadence`
|
|
204
|
+
*
|
|
205
|
+
* @param discovery - The discovery section from a soul document.
|
|
206
|
+
* @param maxCreditsPerCycle - Total credit budget per scan cycle (used to compute absolute budgets).
|
|
207
|
+
*/
|
|
208
|
+
async applyDiscoveryConfig(discovery, maxCreditsPerCycle) {
|
|
209
|
+
const update = {};
|
|
210
|
+
// Translate entityFocus → scannerPriorities
|
|
211
|
+
if (discovery.entityFocus && discovery.entityFocus.length > 0) {
|
|
212
|
+
const priorities = {};
|
|
213
|
+
const focusedScanners = new Set();
|
|
214
|
+
// Focused entities get weight 8
|
|
215
|
+
for (const entity of discovery.entityFocus) {
|
|
216
|
+
const scanners = ENTITY_TO_SCANNERS[entity];
|
|
217
|
+
if (scanners) {
|
|
218
|
+
for (const s of scanners) {
|
|
219
|
+
priorities[s] = 8;
|
|
220
|
+
focusedScanners.add(s);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// All other scanner types get weight 3 (not disabled, just deprioritized)
|
|
225
|
+
const allScanners = Object.values(ENTITY_TO_SCANNERS).flat();
|
|
226
|
+
for (const s of allScanners) {
|
|
227
|
+
if (!focusedScanners.has(s)) {
|
|
228
|
+
priorities[s] = 3;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
update.scannerPriorities = priorities;
|
|
232
|
+
}
|
|
233
|
+
// Translate budgetAllocation percentages → absolute credit values
|
|
234
|
+
if (discovery.budgetAllocation) {
|
|
235
|
+
const alloc = discovery.budgetAllocation;
|
|
236
|
+
if (alloc.social != null) {
|
|
237
|
+
update.budgetSocial = Math.round((alloc.social / 100) * maxCreditsPerCycle);
|
|
238
|
+
}
|
|
239
|
+
if (alloc.content != null) {
|
|
240
|
+
update.budgetContent = Math.round((alloc.content / 100) * maxCreditsPerCycle);
|
|
241
|
+
}
|
|
242
|
+
if (alloc.bounties != null) {
|
|
243
|
+
update.budgetBounties = Math.round((alloc.bounties / 100) * maxCreditsPerCycle);
|
|
244
|
+
}
|
|
245
|
+
if (alloc.collaboration != null) {
|
|
246
|
+
update.budgetCollaboration = Math.round((alloc.collaboration / 100) * maxCreditsPerCycle);
|
|
247
|
+
}
|
|
248
|
+
if (alloc.community != null) {
|
|
249
|
+
update.budgetCommunity = Math.round((alloc.community / 100) * maxCreditsPerCycle);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// Translate cadence directly
|
|
253
|
+
if (discovery.cadence) {
|
|
254
|
+
update.discoveryCadence = discovery.cadence;
|
|
255
|
+
}
|
|
256
|
+
return this.connection.request("PUT", "/v1/proactive/settings", update);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get the current discovery configuration from proactive settings.
|
|
260
|
+
*
|
|
261
|
+
* Returns only the discovery-related fields in a structured format.
|
|
262
|
+
*/
|
|
263
|
+
async getDiscoveryConfig() {
|
|
264
|
+
const settings = await this.connection.request("GET", "/v1/proactive/settings");
|
|
265
|
+
return {
|
|
266
|
+
scannerPriorities: settings.scannerPriorities ?? undefined,
|
|
267
|
+
budgetSocial: settings.budgetSocial ?? null,
|
|
268
|
+
budgetContent: settings.budgetContent ?? null,
|
|
269
|
+
budgetBounties: settings.budgetBounties ?? null,
|
|
270
|
+
budgetCollaboration: settings.budgetCollaboration ?? null,
|
|
271
|
+
budgetCommunity: settings.budgetCommunity ?? null,
|
|
272
|
+
discoveryCadence: settings.discoveryCadence ?? null,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
// ============================================================
|
|
276
|
+
// Specialization
|
|
277
|
+
// ============================================================
|
|
278
|
+
/**
|
|
279
|
+
* Specialize the agent in a given domain.
|
|
280
|
+
*
|
|
281
|
+
* Calls the gateway specialization endpoint which discovers relevant
|
|
282
|
+
* bundles, communities, experts, bounties, and marketplace gaps —
|
|
283
|
+
* then auto-creates an interest subscription and tunes proactive
|
|
284
|
+
* settings for the domain.
|
|
285
|
+
*
|
|
286
|
+
* Also applies the suggested discovery config locally.
|
|
287
|
+
*
|
|
288
|
+
* @param domain - The domain to specialize in (e.g., "machine-learning").
|
|
289
|
+
* @returns The full specialization plan.
|
|
290
|
+
*/
|
|
291
|
+
async specialize(domain) {
|
|
292
|
+
const plan = await this.connection.request("POST", "/v1/agents/me/specialize", { domain });
|
|
293
|
+
// Auto-apply discovery config for the domain
|
|
294
|
+
const entityFocus = ["knowledge", "bounties", "communities", "projects"];
|
|
295
|
+
const budgetAlloc = { bounties: 35, content: 25, community: 20, social: 15, collaboration: 5 };
|
|
296
|
+
await this.applyDiscoveryConfig({ interests: [domain], entityFocus, budgetAllocation: budgetAlloc, cadence: "moderate" }, plan.suggestedSettings?.maxCreditsPerCycle ?? 3000);
|
|
297
|
+
return plan;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAgDH;;GAEG;AACH,MAAM,kBAAkB,GAA6B;IACnD,QAAQ,EAAE,CAAC,wBAAwB,EAAE,sBAAsB,EAAE,yBAAyB,EAAE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;;OAYG;IACH,KAAK,CAAC,UAAU,CAAC,MAAc;QAC7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CACxC,MAAM,EACN,0BAA0B,EAC1B,EAAE,MAAM,EAAE,CACX,CAAC;QAEF,6CAA6C;QAC7C,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;QACzE,MAAM,WAAW,GAAG,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;QAC/F,MAAM,IAAI,CAAC,oBAAoB,CAC7B,EAAE,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,EACxF,IAAI,CAAC,iBAAiB,EAAE,kBAAkB,IAAI,IAAI,CACnD,CAAC;QAEF,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Doom-loop detector — catches stuck agents that call the same tool with
|
|
3
|
+
* the same args 3+ times, or cycle through an `A,B,A,B`-style pattern.
|
|
4
|
+
*
|
|
5
|
+
* TypeScript parity with `runtime-py/nookplot_runtime/doom_loop.py`.
|
|
6
|
+
*
|
|
7
|
+
* Consumer-agnostic: callers pass either a list of OpenAI/litellm-shaped
|
|
8
|
+
* messages (`{role, tool_calls: [{function: {name, arguments}}]}`) or a
|
|
9
|
+
* pre-extracted list of `ToolCallSignature` values.
|
|
10
|
+
*
|
|
11
|
+
* The primary entry point is {@link checkForDoomLoop}. The goal loop uses
|
|
12
|
+
* {@link checkForDoomLoopFromSignatures} directly since it tracks action
|
|
13
|
+
* decisions, not raw LLM messages.
|
|
14
|
+
*
|
|
15
|
+
* Returned value is the offending tool name (string) or `null`. For repeating
|
|
16
|
+
* patterns, the first tool in the repeating unit is returned.
|
|
17
|
+
*
|
|
18
|
+
* @module doomLoop
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEFAULT_LOOKBACK = 30;
|
|
21
|
+
export declare const IDENTICAL_THRESHOLD = 3;
|
|
22
|
+
export declare const MIN_PATTERN_LEN = 2;
|
|
23
|
+
export declare const MAX_PATTERN_LEN = 5;
|
|
24
|
+
export declare const MIN_PATTERN_REPS = 2;
|
|
25
|
+
export interface ToolCallSignature {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
readonly argsHash: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Pull tool-call signatures out of the last `lookback` assistant messages.
|
|
31
|
+
* Non-assistant messages and messages without `tool_calls` are skipped.
|
|
32
|
+
*/
|
|
33
|
+
export declare function extractRecentToolSignatures(messages: unknown[], lookback?: number): ToolCallSignature[];
|
|
34
|
+
/** Return the tool name if `threshold` or more identical consecutive calls exist. */
|
|
35
|
+
export declare function detectIdenticalConsecutive(signatures: ToolCallSignature[], threshold?: number): string | null;
|
|
36
|
+
/**
|
|
37
|
+
* Detect an `[A,B]`-style repeating unit at the tail with 2+ repetitions.
|
|
38
|
+
* Scans unit lengths from 2 to 5. The smallest matching pattern wins.
|
|
39
|
+
*/
|
|
40
|
+
export declare function detectRepeatingSequence(signatures: ToolCallSignature[]): ToolCallSignature[] | null;
|
|
41
|
+
/** Return the offending tool name, or `null` if no doom loop is present. */
|
|
42
|
+
export declare function checkForDoomLoopFromSignatures(signatures: ToolCallSignature[]): string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Check recent messages for a doom loop.
|
|
45
|
+
* Returns the offending tool name, or `null` if no loop is detected.
|
|
46
|
+
*/
|
|
47
|
+
export declare function checkForDoomLoop(messages: unknown[], lookback?: number): string | null;
|
|
48
|
+
/** Compose the system-inject message used after a doom loop is detected. */
|
|
49
|
+
export declare function buildCorrectivePrompt(offender: string): string;
|
|
50
|
+
/** Helper for callers that build their own signature list: hash args and construct. */
|
|
51
|
+
export declare function makeSignature(name: string, args: unknown): ToolCallSignature;
|
|
52
|
+
//# sourceMappingURL=doomLoop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doomLoop.d.ts","sourceRoot":"","sources":["../src/doomLoop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAgDD;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,GAAE,MAAyB,GAClC,iBAAiB,EAAE,CAoBrB;AAED,qFAAqF;AACrF,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,iBAAiB,EAAE,EAC/B,SAAS,GAAE,MAA4B,GACtC,MAAM,GAAG,IAAI,CAYf;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,iBAAiB,EAAE,GAC9B,iBAAiB,EAAE,GAAG,IAAI,CAmB5B;AAED,4EAA4E;AAC5E,wBAAgB,8BAA8B,CAC5C,UAAU,EAAE,iBAAiB,EAAE,GAC9B,MAAM,GAAG,IAAI,CAUf;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,OAAO,EAAE,EACnB,QAAQ,GAAE,MAAyB,GAClC,MAAM,GAAG,IAAI,CAGf;AAED,4EAA4E;AAC5E,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAM9D;AAED,uFAAuF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