memeloop 0.1.0 → 0.1.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.
Files changed (55) hide show
  1. package/THIRD_PARTY_NOTICES.md +29 -0
  2. package/dist/browser.d.cts +7 -7
  3. package/dist/browser.d.ts +7 -7
  4. package/dist/{chunk-44YHBKDL.js → chunk-2C6BJZI3.js} +3 -3
  5. package/dist/{chunk-HVB2BR3H.js → chunk-KFS2EJT6.js} +2 -2
  6. package/dist/{chunk-XHRBV6I3.js → chunk-MAJWHAKR.js} +2 -2
  7. package/dist/{chunk-QFHAAIIM.js → chunk-T7FSXWFR.js} +95 -8
  8. package/dist/chunk-T7FSXWFR.js.map +1 -0
  9. package/dist/conversation.d.cts +1 -1
  10. package/dist/conversation.d.ts +1 -1
  11. package/dist/{fetchProvider-Cm0sO4Tl.d.ts → fetchProvider-WWnWnQFP.d.ts} +1 -1
  12. package/dist/{fetchProvider-BpcGVSOG.d.cts → fetchProvider-toTHy5Nu.d.cts} +1 -1
  13. package/dist/index.cjs +295 -201
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +10 -10
  16. package/dist/index.d.ts +10 -10
  17. package/dist/index.js +11 -5
  18. package/dist/index.js.map +1 -1
  19. package/dist/llm-providers.d.cts +1 -1
  20. package/dist/llm-providers.d.ts +1 -1
  21. package/dist/loop-api.cjs +291 -201
  22. package/dist/loop-api.cjs.map +1 -1
  23. package/dist/loop-api.d.cts +5 -5
  24. package/dist/loop-api.d.ts +5 -5
  25. package/dist/loop-api.js +6 -4
  26. package/dist/mobile.cjs +235 -149
  27. package/dist/mobile.cjs.map +1 -1
  28. package/dist/mobile.d.cts +3 -3
  29. package/dist/mobile.d.ts +3 -3
  30. package/dist/mobile.js +2 -2
  31. package/dist/model-catalog.cjs +246 -0
  32. package/dist/model-catalog.cjs.map +1 -0
  33. package/dist/model-catalog.d.cts +57 -0
  34. package/dist/model-catalog.d.ts +57 -0
  35. package/dist/model-catalog.js +213 -0
  36. package/dist/model-catalog.js.map +1 -0
  37. package/dist/{orchestration-portable-Zw0g5tbj.d.ts → orchestration-portable-BHB_YrNN.d.ts} +1 -1
  38. package/dist/{orchestration-portable-Bsf8YRfp.d.cts → orchestration-portable-mvYBvGBb.d.cts} +1 -1
  39. package/dist/orchestration-portable.d.cts +2 -2
  40. package/dist/orchestration-portable.d.ts +2 -2
  41. package/dist/{promptConcat-deDSWZE3.d.ts → promptConcat-0WNFTg4l.d.ts} +2 -2
  42. package/dist/{promptConcat-WTN-uHcz.d.cts → promptConcat-D6wr5V-V.d.cts} +2 -2
  43. package/dist/{providerRegistry-9trr5aoK.d.ts → providerRegistry-Bi6pAvSj.d.ts} +1 -1
  44. package/dist/{providerRegistry-xk_B1Ekv.d.cts → providerRegistry-CPsktuiX.d.cts} +1 -1
  45. package/dist/{registry-8eztoD_r.d.cts → registry-D0kbxksn.d.cts} +2 -2
  46. package/dist/{registry-DV24sI-3.d.ts → registry-DDbvhlhs.d.ts} +2 -2
  47. package/dist/{runtime-SKSXVYIM.js → runtime-PGWR6FIV.js} +3 -3
  48. package/dist/{scriptDeploymentPipeline-DsnT0AG6.d.ts → scriptDeploymentPipeline-CXJcC82H.d.ts} +2 -1
  49. package/dist/{scriptDeploymentPipeline-BAeo1dPb.d.cts → scriptDeploymentPipeline-yG1ZhVVI.d.cts} +2 -1
  50. package/package.json +9 -2
  51. package/dist/chunk-QFHAAIIM.js.map +0 -1
  52. /package/dist/{chunk-44YHBKDL.js.map → chunk-2C6BJZI3.js.map} +0 -0
  53. /package/dist/{chunk-HVB2BR3H.js.map → chunk-KFS2EJT6.js.map} +0 -0
  54. /package/dist/{chunk-XHRBV6I3.js.map → chunk-MAJWHAKR.js.map} +0 -0
  55. /package/dist/{runtime-SKSXVYIM.js.map → runtime-PGWR6FIV.js.map} +0 -0
@@ -1,8 +1,8 @@
1
- export { A as AGENT_AGENT_LOOP_ID, a as AGENT_TOOL_LOOP_ID, b as AgentAgentBatchRunInput, c as AgentAgentBatchRunResult, d as AgentAgentConfigEntry, e as AgentAgentContext, f as AgentAgentDescriptor, g as AgentAgentFormatResultsOptions, h as AgentAgentLoopContext, i as AgentAgentLoopScript, j as AgentAgentLoopScriptArguments, k as AgentAgentLoopScriptReference, l as AgentAgentRunAgentFailure, m as AgentAgentRunAgentInput, n as AgentAgentRunAgentResult, o as AgentAgentScriptContext, p as AgentToolLoopContext, q as AgentToolLoopIterationGenerator, r as AgentToolLoopIterationResult, s as AgentToolLoopScript, t as AgentToolLoopScriptContext, u as AgentToolLoopScriptReference, v as AgentToolLoopState, w as AgentToolLoopTurnStartResult, B as BUILTIN_AGENT_AGENT_LOOP_ARTIFACT_RESOURCE_LIFECYCLE_SCRIPT_ID, x as BUILTIN_AGENT_AGENT_LOOP_DECLARATIVE_AGENT_RUN_SCRIPT_ID, y as BUILTIN_AGENT_AGENT_LOOP_QUALITY_GATE_SCRIPT_ID, z as BUILTIN_AGENT_TOOL_LOOP_DEFAULT_SCRIPT_ID, C as BUILTIN_TOOL_PLUGIN_IDS, D as CompactionOptions, E as CompactionResult, H as HookRegistry, L as LoadAgentAgentLoopScriptOptions, F as LoadAgentToolLoopScriptOptions, G as LoopRegistryImpl, P as PLUGIN_ASK_QUESTION, I as PLUGIN_ASK_USER_QUESTION, J as PLUGIN_MCP_CLIENT, K as PLUGIN_MCP_FORWARD, M as PLUGIN_ORCHESTRATION, N as PLUGIN_REMOTE_AGENT, O as PLUGIN_SPAWN_AGENT, Q as PLUGIN_TASK, R as PLUGIN_TODO_WRITE, S as PromptConcatPluginPreview, T as PromptConcatStreamState, U as TokenTracker, V as autoCompact, W as builtinAgentAgentLoopSources, X as builtinAgentToolLoopSources, Y as clearHooks, Z as compactMessages, _ as createAgentAgentLoopDefinition, $ as createAgentToolLoopDefinition, a0 as createAgentToolLoopRunner, a1 as executeHooks, a2 as findPromptById, a3 as flattenPrompts, a4 as getAgentAgentLoopId, a5 as getBuiltinAgentAgentLoopSource, a6 as getBuiltinAgentToolLoopSource, a7 as getBuiltinToolPlugins, a8 as getDefaultHookRegistry, a9 as getHookCount, aa as getLoopRegistry, ab as hasHooks, ac as listRegisteredHookTypes, ad as loadAgentAgentLoopScript, ae as loadAgentToolLoopScript, af as promptConcatStream, ag as registerBuiltinLoops, ah as registerBuiltinPromptPlugins, ai as registerBuiltinToolPlugins, aj as registerHook, ak as resetLoopRegistry, al as shouldCompact, am as unregisterHook } from './promptConcat-WTN-uHcz.cjs';
2
- export { F as FetchLLMProviderConfig, R as RunAgentToolLoopTurnCallbacks, a as RunAgentToolLoopTurnResult, c as createFetchLLMProvider, g as getBuiltinLoopProfile, b as getBuiltinLoopProfiles, e as registerBuiltinLoopProfiles, r as resolveAgentToolLoopTerminalState, d as runAgentToolLoopTurn } from './fetchProvider-BpcGVSOG.cjs';
3
- export { A as ALL_CATEGORIES, a as AgentProfileRegistry, b as AgentStartData, c as AgentStopData, C as CategoryConfig, d as ContextCompactionData, e as CreateAgentLoopRunnerOptions, f as CreateAgentOptions, H as HookContext, g as HookHandler, h as HookResult, i as HookType, L as LoadPluginModuleOptions, j as LoadedPlugin, M as MemeLoopRuntime, k as MergedPermissions, P as PERMISSIONS_TABLE_DDL, l as PermissionAction, m as PermissionRule, n as PermissionSet, o as PermissionSqlDatabase, p as PermissionSqlStatement, q as PluginAPI, r as PluginAPIOptions, s as PluginExports, t as PluginManifest, u as PluginModule, v as PostToolUseData, w as PreToolUseData, S as SendMessageOptions, T as TaskCategory, U as UserPromptSubmitData, x as checkPermission, y as clearPluginRegistrations, z as createAgentLoopRunner, B as createAgentLoopScriptRunner, D as createAgentProfileRunner, E as createMemeLoopRuntime, F as createPluginAPI, G as getAgentProfileRegistry, I as getCategoryConfig, J as getLoadedPlugin, K as getPluginRegistrations, N as isPluginLoaded, O as isTaskCategory, Q as listPlugins, R as loadPluginModule, V as loadPluginModules, W as loadUserPermissions, X as matchPattern, Y as mergePermissionSets, Z as registerPluginHooks, _ as registerPluginTools, $ as resetAgentProfileRegistry, a0 as resolveCategory, a1 as saveUserPermissions, a2 as unloadAllPlugins, a3 as unloadPlugin, a4 as validatePluginManifest } from './registry-8eztoD_r.cjs';
4
- export { A as AgentFrameworkContext, a as AgentInstance, b as AgentInstanceLatestStatus, a as AgentInstanceModel, c as AgentInstanceState, d as AgentLoopDefinition, e as AgentLoopGenerator, f as AgentLoopInput, g as AgentLoopRuntime, h as AgentLoopScriptPolicy, i as AgentLoopStep, j as AgentToolLoopOptions, I as IChatSyncAdapter, k as ILLMProvider, l as INetworkService, m as IToolRegistry, L as LoopPlugin, n as LoopProfile, o as LoopProfilePluginEntry, p as LoopProfilePrompt, q as LoopProfileScriptReference, r as LoopScriptCheckpointStore, M as MemeLoopLogger, S as ScriptLoadGate, s as ScriptLoadGateDecision, t as ScriptLoadGateRequest, T as ToolCallingMatch, w as matchAllToolCallings, x as matchToolCalling } from './scriptDeploymentPipeline-BAeo1dPb.cjs';
5
- export { A as AgentProfile, a as AgentProfileType, B as BUILTIN_AGENT_PROFILES, P as ProviderConfig, b as ProviderRegistry, R as RegisteredProvider, T as ToolPermissionRules, c as buildAgent, e as exploreAgent, l as librarianAgent, o as oracleAgent, p as planAgent } from './providerRegistry-xk_B1Ekv.cjs';
1
+ export { A as AGENT_AGENT_LOOP_ID, a as AGENT_TOOL_LOOP_ID, b as AgentAgentBatchRunInput, c as AgentAgentBatchRunResult, d as AgentAgentConfigEntry, e as AgentAgentContext, f as AgentAgentDescriptor, g as AgentAgentFormatResultsOptions, h as AgentAgentLoopContext, i as AgentAgentLoopScript, j as AgentAgentLoopScriptArguments, k as AgentAgentLoopScriptReference, l as AgentAgentRunAgentFailure, m as AgentAgentRunAgentInput, n as AgentAgentRunAgentResult, o as AgentAgentScriptContext, p as AgentToolLoopContext, q as AgentToolLoopIterationGenerator, r as AgentToolLoopIterationResult, s as AgentToolLoopScript, t as AgentToolLoopScriptContext, u as AgentToolLoopScriptReference, v as AgentToolLoopState, w as AgentToolLoopTurnStartResult, B as BUILTIN_AGENT_AGENT_LOOP_ARTIFACT_RESOURCE_LIFECYCLE_SCRIPT_ID, x as BUILTIN_AGENT_AGENT_LOOP_DECLARATIVE_AGENT_RUN_SCRIPT_ID, y as BUILTIN_AGENT_AGENT_LOOP_QUALITY_GATE_SCRIPT_ID, z as BUILTIN_AGENT_TOOL_LOOP_DEFAULT_SCRIPT_ID, C as BUILTIN_TOOL_PLUGIN_IDS, D as CompactionOptions, E as CompactionResult, H as HookRegistry, L as LoadAgentAgentLoopScriptOptions, F as LoadAgentToolLoopScriptOptions, G as LoopRegistryImpl, P as PLUGIN_ASK_QUESTION, I as PLUGIN_ASK_USER_QUESTION, J as PLUGIN_MCP_CLIENT, K as PLUGIN_MCP_FORWARD, M as PLUGIN_ORCHESTRATION, N as PLUGIN_REMOTE_AGENT, O as PLUGIN_SPAWN_AGENT, Q as PLUGIN_TASK, R as PLUGIN_TODO_WRITE, S as PromptConcatPluginPreview, T as PromptConcatStreamState, U as TokenTracker, V as autoCompact, W as builtinAgentAgentLoopSources, X as builtinAgentToolLoopSources, Y as clearHooks, Z as compactMessages, _ as createAgentAgentLoopDefinition, $ as createAgentToolLoopDefinition, a0 as createAgentToolLoopRunner, a1 as executeHooks, a2 as findPromptById, a3 as flattenPrompts, a4 as getAgentAgentLoopId, a5 as getBuiltinAgentAgentLoopSource, a6 as getBuiltinAgentToolLoopSource, a7 as getBuiltinToolPlugins, a8 as getDefaultHookRegistry, a9 as getHookCount, aa as getLoopRegistry, ab as hasHooks, ac as listRegisteredHookTypes, ad as loadAgentAgentLoopScript, ae as loadAgentToolLoopScript, af as promptConcatStream, ag as registerBuiltinLoops, ah as registerBuiltinPromptPlugins, ai as registerBuiltinToolPlugins, aj as registerHook, ak as resetLoopRegistry, al as shouldCompact, am as unregisterHook } from './promptConcat-D6wr5V-V.cjs';
2
+ export { F as FetchLLMProviderConfig, R as RunAgentToolLoopTurnCallbacks, a as RunAgentToolLoopTurnResult, c as createFetchLLMProvider, g as getBuiltinLoopProfile, b as getBuiltinLoopProfiles, e as registerBuiltinLoopProfiles, r as resolveAgentToolLoopTerminalState, d as runAgentToolLoopTurn } from './fetchProvider-toTHy5Nu.cjs';
3
+ export { A as ALL_CATEGORIES, a as AgentProfileRegistry, b as AgentStartData, c as AgentStopData, C as CategoryConfig, d as ContextCompactionData, e as CreateAgentLoopRunnerOptions, f as CreateAgentOptions, H as HookContext, g as HookHandler, h as HookResult, i as HookType, L as LoadPluginModuleOptions, j as LoadedPlugin, M as MemeLoopRuntime, k as MergedPermissions, P as PERMISSIONS_TABLE_DDL, l as PermissionAction, m as PermissionRule, n as PermissionSet, o as PermissionSqlDatabase, p as PermissionSqlStatement, q as PluginAPI, r as PluginAPIOptions, s as PluginExports, t as PluginManifest, u as PluginModule, v as PostToolUseData, w as PreToolUseData, S as SendMessageOptions, T as TaskCategory, U as UserPromptSubmitData, x as checkPermission, y as clearPluginRegistrations, z as createAgentLoopRunner, B as createAgentLoopScriptRunner, D as createAgentProfileRunner, E as createMemeLoopRuntime, F as createPluginAPI, G as getAgentProfileRegistry, I as getCategoryConfig, J as getLoadedPlugin, K as getPluginRegistrations, N as isPluginLoaded, O as isTaskCategory, Q as listPlugins, R as loadPluginModule, V as loadPluginModules, W as loadUserPermissions, X as matchPattern, Y as mergePermissionSets, Z as registerPluginHooks, _ as registerPluginTools, $ as resetAgentProfileRegistry, a0 as resolveCategory, a1 as saveUserPermissions, a2 as unloadAllPlugins, a3 as unloadPlugin, a4 as validatePluginManifest } from './registry-D0kbxksn.cjs';
4
+ export { A as AgentFrameworkContext, a as AgentInstance, b as AgentInstanceLatestStatus, a as AgentInstanceModel, c as AgentInstanceState, d as AgentLoopDefinition, e as AgentLoopGenerator, f as AgentLoopInput, g as AgentLoopRuntime, h as AgentLoopScriptPolicy, i as AgentLoopStep, j as AgentToolLoopOptions, I as IChatSyncAdapter, k as ILLMProvider, l as INetworkService, m as IToolRegistry, L as LoopPlugin, n as LoopProfile, o as LoopProfilePluginEntry, p as LoopProfilePrompt, q as LoopProfileScriptReference, r as LoopScriptCheckpointStore, M as MemeLoopLogger, S as ScriptLoadGate, s as ScriptLoadGateDecision, t as ScriptLoadGateRequest, T as TOOL_PARAMETER_PARSE_ERROR_KEY, w as ToolCallingMatch, x as matchAllToolCallings, y as matchToolCalling } from './scriptDeploymentPipeline-yG1ZhVVI.cjs';
5
+ export { A as AgentProfile, a as AgentProfileType, B as BUILTIN_AGENT_PROFILES, P as ProviderConfig, b as ProviderRegistry, R as RegisteredProvider, T as ToolPermissionRules, c as buildAgent, e as exploreAgent, l as librarianAgent, o as oracleAgent, p as planAgent } from './providerRegistry-CPsktuiX.cjs';
6
6
  import { l as ConversationEventStore } from './interface-IrKBFtL1.cjs';
7
7
  export { m as AgentDefinition, n as AgentDefinitionModelConfig, o as AgentDefinitionToolConfig, p as AgentHeartbeatConfig, q as AgentInstanceMeta, r as AiAPIConfig, A as AttachmentReference, a as ChatAttachmentPart, b as ChatMessage, c as ChatMessagePart, d as ChatReasoningPart, e as ChatRole, f as ChatTextPart, g as ChatToolCallPart, h as ChatToolResultPart, D as DetailRefType, k as DetailReference, G as GetMessagesOptions, H as HostAgentToolConfig, I as IAgentStorage, L as ListConversationsOptions, M as ModelParameters, s as ModelSelection, T as ToolCall } from './interface-IrKBFtL1.cjs';
8
8
  export { ChatMessageProjection, buildLegacyChatMessageParts, buildToolResultSummary, createAgentInstanceFromDefinition, createChatMessage, getChatMessageParts, isToolResultPart, parseLegacyToolResultContent, projectChatMessageParts } from './conversation.cjs';
@@ -1,8 +1,8 @@
1
- export { A as AGENT_AGENT_LOOP_ID, a as AGENT_TOOL_LOOP_ID, b as AgentAgentBatchRunInput, c as AgentAgentBatchRunResult, d as AgentAgentConfigEntry, e as AgentAgentContext, f as AgentAgentDescriptor, g as AgentAgentFormatResultsOptions, h as AgentAgentLoopContext, i as AgentAgentLoopScript, j as AgentAgentLoopScriptArguments, k as AgentAgentLoopScriptReference, l as AgentAgentRunAgentFailure, m as AgentAgentRunAgentInput, n as AgentAgentRunAgentResult, o as AgentAgentScriptContext, p as AgentToolLoopContext, q as AgentToolLoopIterationGenerator, r as AgentToolLoopIterationResult, s as AgentToolLoopScript, t as AgentToolLoopScriptContext, u as AgentToolLoopScriptReference, v as AgentToolLoopState, w as AgentToolLoopTurnStartResult, B as BUILTIN_AGENT_AGENT_LOOP_ARTIFACT_RESOURCE_LIFECYCLE_SCRIPT_ID, x as BUILTIN_AGENT_AGENT_LOOP_DECLARATIVE_AGENT_RUN_SCRIPT_ID, y as BUILTIN_AGENT_AGENT_LOOP_QUALITY_GATE_SCRIPT_ID, z as BUILTIN_AGENT_TOOL_LOOP_DEFAULT_SCRIPT_ID, C as BUILTIN_TOOL_PLUGIN_IDS, D as CompactionOptions, E as CompactionResult, H as HookRegistry, L as LoadAgentAgentLoopScriptOptions, F as LoadAgentToolLoopScriptOptions, G as LoopRegistryImpl, P as PLUGIN_ASK_QUESTION, I as PLUGIN_ASK_USER_QUESTION, J as PLUGIN_MCP_CLIENT, K as PLUGIN_MCP_FORWARD, M as PLUGIN_ORCHESTRATION, N as PLUGIN_REMOTE_AGENT, O as PLUGIN_SPAWN_AGENT, Q as PLUGIN_TASK, R as PLUGIN_TODO_WRITE, S as PromptConcatPluginPreview, T as PromptConcatStreamState, U as TokenTracker, V as autoCompact, W as builtinAgentAgentLoopSources, X as builtinAgentToolLoopSources, Y as clearHooks, Z as compactMessages, _ as createAgentAgentLoopDefinition, $ as createAgentToolLoopDefinition, a0 as createAgentToolLoopRunner, a1 as executeHooks, a2 as findPromptById, a3 as flattenPrompts, a4 as getAgentAgentLoopId, a5 as getBuiltinAgentAgentLoopSource, a6 as getBuiltinAgentToolLoopSource, a7 as getBuiltinToolPlugins, a8 as getDefaultHookRegistry, a9 as getHookCount, aa as getLoopRegistry, ab as hasHooks, ac as listRegisteredHookTypes, ad as loadAgentAgentLoopScript, ae as loadAgentToolLoopScript, af as promptConcatStream, ag as registerBuiltinLoops, ah as registerBuiltinPromptPlugins, ai as registerBuiltinToolPlugins, aj as registerHook, ak as resetLoopRegistry, al as shouldCompact, am as unregisterHook } from './promptConcat-deDSWZE3.js';
2
- export { F as FetchLLMProviderConfig, R as RunAgentToolLoopTurnCallbacks, a as RunAgentToolLoopTurnResult, c as createFetchLLMProvider, g as getBuiltinLoopProfile, b as getBuiltinLoopProfiles, e as registerBuiltinLoopProfiles, r as resolveAgentToolLoopTerminalState, d as runAgentToolLoopTurn } from './fetchProvider-Cm0sO4Tl.js';
3
- export { A as ALL_CATEGORIES, a as AgentProfileRegistry, b as AgentStartData, c as AgentStopData, C as CategoryConfig, d as ContextCompactionData, e as CreateAgentLoopRunnerOptions, f as CreateAgentOptions, H as HookContext, g as HookHandler, h as HookResult, i as HookType, L as LoadPluginModuleOptions, j as LoadedPlugin, M as MemeLoopRuntime, k as MergedPermissions, P as PERMISSIONS_TABLE_DDL, l as PermissionAction, m as PermissionRule, n as PermissionSet, o as PermissionSqlDatabase, p as PermissionSqlStatement, q as PluginAPI, r as PluginAPIOptions, s as PluginExports, t as PluginManifest, u as PluginModule, v as PostToolUseData, w as PreToolUseData, S as SendMessageOptions, T as TaskCategory, U as UserPromptSubmitData, x as checkPermission, y as clearPluginRegistrations, z as createAgentLoopRunner, B as createAgentLoopScriptRunner, D as createAgentProfileRunner, E as createMemeLoopRuntime, F as createPluginAPI, G as getAgentProfileRegistry, I as getCategoryConfig, J as getLoadedPlugin, K as getPluginRegistrations, N as isPluginLoaded, O as isTaskCategory, Q as listPlugins, R as loadPluginModule, V as loadPluginModules, W as loadUserPermissions, X as matchPattern, Y as mergePermissionSets, Z as registerPluginHooks, _ as registerPluginTools, $ as resetAgentProfileRegistry, a0 as resolveCategory, a1 as saveUserPermissions, a2 as unloadAllPlugins, a3 as unloadPlugin, a4 as validatePluginManifest } from './registry-DV24sI-3.js';
4
- export { A as AgentFrameworkContext, a as AgentInstance, b as AgentInstanceLatestStatus, a as AgentInstanceModel, c as AgentInstanceState, d as AgentLoopDefinition, e as AgentLoopGenerator, f as AgentLoopInput, g as AgentLoopRuntime, h as AgentLoopScriptPolicy, i as AgentLoopStep, j as AgentToolLoopOptions, I as IChatSyncAdapter, k as ILLMProvider, l as INetworkService, m as IToolRegistry, L as LoopPlugin, n as LoopProfile, o as LoopProfilePluginEntry, p as LoopProfilePrompt, q as LoopProfileScriptReference, r as LoopScriptCheckpointStore, M as MemeLoopLogger, S as ScriptLoadGate, s as ScriptLoadGateDecision, t as ScriptLoadGateRequest, T as ToolCallingMatch, w as matchAllToolCallings, x as matchToolCalling } from './scriptDeploymentPipeline-DsnT0AG6.js';
5
- export { A as AgentProfile, a as AgentProfileType, B as BUILTIN_AGENT_PROFILES, P as ProviderConfig, b as ProviderRegistry, R as RegisteredProvider, T as ToolPermissionRules, c as buildAgent, e as exploreAgent, l as librarianAgent, o as oracleAgent, p as planAgent } from './providerRegistry-9trr5aoK.js';
1
+ export { A as AGENT_AGENT_LOOP_ID, a as AGENT_TOOL_LOOP_ID, b as AgentAgentBatchRunInput, c as AgentAgentBatchRunResult, d as AgentAgentConfigEntry, e as AgentAgentContext, f as AgentAgentDescriptor, g as AgentAgentFormatResultsOptions, h as AgentAgentLoopContext, i as AgentAgentLoopScript, j as AgentAgentLoopScriptArguments, k as AgentAgentLoopScriptReference, l as AgentAgentRunAgentFailure, m as AgentAgentRunAgentInput, n as AgentAgentRunAgentResult, o as AgentAgentScriptContext, p as AgentToolLoopContext, q as AgentToolLoopIterationGenerator, r as AgentToolLoopIterationResult, s as AgentToolLoopScript, t as AgentToolLoopScriptContext, u as AgentToolLoopScriptReference, v as AgentToolLoopState, w as AgentToolLoopTurnStartResult, B as BUILTIN_AGENT_AGENT_LOOP_ARTIFACT_RESOURCE_LIFECYCLE_SCRIPT_ID, x as BUILTIN_AGENT_AGENT_LOOP_DECLARATIVE_AGENT_RUN_SCRIPT_ID, y as BUILTIN_AGENT_AGENT_LOOP_QUALITY_GATE_SCRIPT_ID, z as BUILTIN_AGENT_TOOL_LOOP_DEFAULT_SCRIPT_ID, C as BUILTIN_TOOL_PLUGIN_IDS, D as CompactionOptions, E as CompactionResult, H as HookRegistry, L as LoadAgentAgentLoopScriptOptions, F as LoadAgentToolLoopScriptOptions, G as LoopRegistryImpl, P as PLUGIN_ASK_QUESTION, I as PLUGIN_ASK_USER_QUESTION, J as PLUGIN_MCP_CLIENT, K as PLUGIN_MCP_FORWARD, M as PLUGIN_ORCHESTRATION, N as PLUGIN_REMOTE_AGENT, O as PLUGIN_SPAWN_AGENT, Q as PLUGIN_TASK, R as PLUGIN_TODO_WRITE, S as PromptConcatPluginPreview, T as PromptConcatStreamState, U as TokenTracker, V as autoCompact, W as builtinAgentAgentLoopSources, X as builtinAgentToolLoopSources, Y as clearHooks, Z as compactMessages, _ as createAgentAgentLoopDefinition, $ as createAgentToolLoopDefinition, a0 as createAgentToolLoopRunner, a1 as executeHooks, a2 as findPromptById, a3 as flattenPrompts, a4 as getAgentAgentLoopId, a5 as getBuiltinAgentAgentLoopSource, a6 as getBuiltinAgentToolLoopSource, a7 as getBuiltinToolPlugins, a8 as getDefaultHookRegistry, a9 as getHookCount, aa as getLoopRegistry, ab as hasHooks, ac as listRegisteredHookTypes, ad as loadAgentAgentLoopScript, ae as loadAgentToolLoopScript, af as promptConcatStream, ag as registerBuiltinLoops, ah as registerBuiltinPromptPlugins, ai as registerBuiltinToolPlugins, aj as registerHook, ak as resetLoopRegistry, al as shouldCompact, am as unregisterHook } from './promptConcat-0WNFTg4l.js';
2
+ export { F as FetchLLMProviderConfig, R as RunAgentToolLoopTurnCallbacks, a as RunAgentToolLoopTurnResult, c as createFetchLLMProvider, g as getBuiltinLoopProfile, b as getBuiltinLoopProfiles, e as registerBuiltinLoopProfiles, r as resolveAgentToolLoopTerminalState, d as runAgentToolLoopTurn } from './fetchProvider-WWnWnQFP.js';
3
+ export { A as ALL_CATEGORIES, a as AgentProfileRegistry, b as AgentStartData, c as AgentStopData, C as CategoryConfig, d as ContextCompactionData, e as CreateAgentLoopRunnerOptions, f as CreateAgentOptions, H as HookContext, g as HookHandler, h as HookResult, i as HookType, L as LoadPluginModuleOptions, j as LoadedPlugin, M as MemeLoopRuntime, k as MergedPermissions, P as PERMISSIONS_TABLE_DDL, l as PermissionAction, m as PermissionRule, n as PermissionSet, o as PermissionSqlDatabase, p as PermissionSqlStatement, q as PluginAPI, r as PluginAPIOptions, s as PluginExports, t as PluginManifest, u as PluginModule, v as PostToolUseData, w as PreToolUseData, S as SendMessageOptions, T as TaskCategory, U as UserPromptSubmitData, x as checkPermission, y as clearPluginRegistrations, z as createAgentLoopRunner, B as createAgentLoopScriptRunner, D as createAgentProfileRunner, E as createMemeLoopRuntime, F as createPluginAPI, G as getAgentProfileRegistry, I as getCategoryConfig, J as getLoadedPlugin, K as getPluginRegistrations, N as isPluginLoaded, O as isTaskCategory, Q as listPlugins, R as loadPluginModule, V as loadPluginModules, W as loadUserPermissions, X as matchPattern, Y as mergePermissionSets, Z as registerPluginHooks, _ as registerPluginTools, $ as resetAgentProfileRegistry, a0 as resolveCategory, a1 as saveUserPermissions, a2 as unloadAllPlugins, a3 as unloadPlugin, a4 as validatePluginManifest } from './registry-DDbvhlhs.js';
4
+ export { A as AgentFrameworkContext, a as AgentInstance, b as AgentInstanceLatestStatus, a as AgentInstanceModel, c as AgentInstanceState, d as AgentLoopDefinition, e as AgentLoopGenerator, f as AgentLoopInput, g as AgentLoopRuntime, h as AgentLoopScriptPolicy, i as AgentLoopStep, j as AgentToolLoopOptions, I as IChatSyncAdapter, k as ILLMProvider, l as INetworkService, m as IToolRegistry, L as LoopPlugin, n as LoopProfile, o as LoopProfilePluginEntry, p as LoopProfilePrompt, q as LoopProfileScriptReference, r as LoopScriptCheckpointStore, M as MemeLoopLogger, S as ScriptLoadGate, s as ScriptLoadGateDecision, t as ScriptLoadGateRequest, T as TOOL_PARAMETER_PARSE_ERROR_KEY, w as ToolCallingMatch, x as matchAllToolCallings, y as matchToolCalling } from './scriptDeploymentPipeline-CXJcC82H.js';
5
+ export { A as AgentProfile, a as AgentProfileType, B as BUILTIN_AGENT_PROFILES, P as ProviderConfig, b as ProviderRegistry, R as RegisteredProvider, T as ToolPermissionRules, c as buildAgent, e as exploreAgent, l as librarianAgent, o as oracleAgent, p as planAgent } from './providerRegistry-Bi6pAvSj.js';
6
6
  import { l as ConversationEventStore } from './interface-IrKBFtL1.js';
7
7
  export { m as AgentDefinition, n as AgentDefinitionModelConfig, o as AgentDefinitionToolConfig, p as AgentHeartbeatConfig, q as AgentInstanceMeta, r as AiAPIConfig, A as AttachmentReference, a as ChatAttachmentPart, b as ChatMessage, c as ChatMessagePart, d as ChatReasoningPart, e as ChatRole, f as ChatTextPart, g as ChatToolCallPart, h as ChatToolResultPart, D as DetailRefType, k as DetailReference, G as GetMessagesOptions, H as HostAgentToolConfig, I as IAgentStorage, L as ListConversationsOptions, M as ModelParameters, s as ModelSelection, T as ToolCall } from './interface-IrKBFtL1.js';
8
8
  export { ChatMessageProjection, buildLegacyChatMessageParts, buildToolResultSummary, createAgentInstanceFromDefinition, createChatMessage, getChatMessageParts, isToolResultPart, parseLegacyToolResultContent, projectChatMessageParts } from './conversation.js';
package/dist/loop-api.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  unloadAllPlugins,
18
18
  unloadPlugin,
19
19
  validatePluginManifest
20
- } from "./chunk-44YHBKDL.js";
20
+ } from "./chunk-2C6BJZI3.js";
21
21
  import {
22
22
  AGENT_AGENT_LOOP_ID,
23
23
  AGENT_TOOL_LOOP_ID,
@@ -61,7 +61,7 @@ import {
61
61
  registerBuiltinPromptPlugins,
62
62
  registerBuiltinToolPlugins,
63
63
  resetAgentProfileRegistry
64
- } from "./chunk-XHRBV6I3.js";
64
+ } from "./chunk-MAJWHAKR.js";
65
65
  import {
66
66
  ALL_CATEGORIES,
67
67
  getCategoryConfig,
@@ -72,12 +72,13 @@ import "./chunk-AZFYDWIN.js";
72
72
  import {
73
73
  resolveAgentToolLoopTerminalState,
74
74
  runAgentToolLoopTurn
75
- } from "./chunk-HVB2BR3H.js";
75
+ } from "./chunk-KFS2EJT6.js";
76
76
  import {
77
77
  createFetchLLMProvider
78
78
  } from "./chunk-K6P63KD4.js";
79
79
  import {
80
80
  HookRegistry,
81
+ TOOL_PARAMETER_PARSE_ERROR_KEY,
81
82
  autoCompact,
82
83
  checkPermission,
83
84
  clearHooks,
@@ -104,7 +105,7 @@ import {
104
105
  resetLoopRegistry,
105
106
  shouldCompact,
106
107
  unregisterHook
107
- } from "./chunk-QFHAAIIM.js";
108
+ } from "./chunk-T7FSXWFR.js";
108
109
  import {
109
110
  buildLegacyChatMessageParts,
110
111
  buildToolResultSummary,
@@ -140,6 +141,7 @@ export {
140
141
  PLUGIN_TASK,
141
142
  PLUGIN_TODO_WRITE,
142
143
  ProviderRegistry,
144
+ TOOL_PARAMETER_PARSE_ERROR_KEY,
143
145
  TokenTracker,
144
146
  autoCompact,
145
147
  buildAgent,
package/dist/mobile.cjs CHANGED
@@ -102,6 +102,148 @@ function createFetchLLMProvider(config) {
102
102
  };
103
103
  }
104
104
 
105
+ // src/conversation/parts.ts
106
+ function tryParseJson(value) {
107
+ try {
108
+ return JSON.parse(value);
109
+ } catch {
110
+ return void 0;
111
+ }
112
+ }
113
+ function parseLegacyToolResultContent(content) {
114
+ const match = /(?:<functions_result>\s*)?Tool:\s*(.+?)\nParameters:\s*(.+?)\n(Error|Result):\s*([\s\S]*?)\s*(?:<\/functions_result>|$)/su.exec(content.trim());
115
+ if (!match) return null;
116
+ const [, rawToolName, rawParameters, kind, rawBody] = match;
117
+ const parsedParameters = tryParseJson(rawParameters.trim());
118
+ const result = rawBody.trim();
119
+ return {
120
+ type: "tool-result",
121
+ toolName: rawToolName.trim(),
122
+ parameters: parsedParameters,
123
+ result,
124
+ isError: kind === "Error",
125
+ payload: tryParseJson(result)
126
+ };
127
+ }
128
+ function isTextPart(part) {
129
+ return part.type === "text";
130
+ }
131
+ function isReasoningPart(part) {
132
+ return part.type === "reasoning";
133
+ }
134
+ function isToolCallPart(part) {
135
+ return part.type === "tool-call";
136
+ }
137
+ function isAttachmentPart(part) {
138
+ return part.type === "attachment";
139
+ }
140
+ function isToolResultPart(part) {
141
+ return part.type === "tool-result";
142
+ }
143
+ function buildToolResultSummary(part) {
144
+ const prefix = part.isError ? "Error" : "Result";
145
+ const suffix = part.result.trim();
146
+ if (suffix.length === 0) return `${prefix} from ${part.toolName}`;
147
+ return `${prefix} from ${part.toolName}: ${suffix}`;
148
+ }
149
+ function projectChatMessageParts(parts) {
150
+ const text = parts.filter(isTextPart).map((part) => part.text.trim()).filter(Boolean);
151
+ const reasoning = parts.filter(isReasoningPart).map((part) => part.text.trim()).filter(Boolean);
152
+ const toolCalls = parts.filter(isToolCallPart).map((part) => ({ id: part.toolCallId, toolName: part.toolName, arguments: part.arguments }));
153
+ const attachments = parts.filter(isAttachmentPart).map((part) => part.attachment);
154
+ const toolResults = parts.filter(isToolResultPart);
155
+ let content = text.join("\n\n");
156
+ if (content.length === 0 && toolResults.length > 0) {
157
+ content = toolResults.map(buildToolResultSummary).join("\n\n");
158
+ }
159
+ if (content.length === 0 && toolCalls.length > 0) {
160
+ content = toolCalls.map((part) => `Tool call: ${part.toolName}`).join("\n\n");
161
+ }
162
+ return {
163
+ content,
164
+ reasoning_content: reasoning.length > 0 ? reasoning.join("\n\n") : void 0,
165
+ toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
166
+ attachments: attachments.length > 0 ? attachments : void 0
167
+ };
168
+ }
169
+ function buildLegacyChatMessageParts(input) {
170
+ const parts = [];
171
+ if (input.role !== "tool" && typeof input.content === "string" && input.content.trim().length > 0) {
172
+ parts.push({ type: "text", text: input.content });
173
+ }
174
+ if (typeof input.reasoning_content === "string" && input.reasoning_content.trim().length > 0) {
175
+ parts.push({ type: "reasoning", text: input.reasoning_content });
176
+ }
177
+ if (input.toolCalls) {
178
+ for (const toolCall of input.toolCalls) {
179
+ parts.push({
180
+ type: "tool-call",
181
+ toolCallId: toolCall.id,
182
+ toolName: toolCall.toolName,
183
+ arguments: toolCall.arguments
184
+ });
185
+ }
186
+ }
187
+ if (input.attachments) {
188
+ for (const attachment of input.attachments) {
189
+ parts.push({ type: "attachment", attachment });
190
+ }
191
+ }
192
+ if (input.role === "tool") {
193
+ const metadata = input.metadata ?? {};
194
+ const parsed = typeof input.content === "string" ? parseLegacyToolResultContent(input.content) : null;
195
+ const toolName = typeof metadata.toolId === "string" && metadata.toolId.length > 0 ? metadata.toolId : parsed?.toolName ?? "tool";
196
+ const result = parsed?.result ?? (typeof input.content === "string" ? input.content : "");
197
+ const payload = parsed?.payload ?? tryParseJson(result);
198
+ parts.push({
199
+ type: "tool-result",
200
+ toolName,
201
+ parameters: metadata.toolParameters ?? parsed?.parameters,
202
+ result,
203
+ isError: metadata.isError === true || parsed?.isError === true,
204
+ payload,
205
+ detailRef: input.detailRef
206
+ });
207
+ }
208
+ return parts;
209
+ }
210
+ function getChatMessageParts(message) {
211
+ return message.parts ?? buildLegacyChatMessageParts(message);
212
+ }
213
+
214
+ // src/conversation/factory.ts
215
+ function createChatMessage(input) {
216
+ const now = Date.now();
217
+ const parts = input.parts ?? buildLegacyChatMessageParts({
218
+ role: input.role,
219
+ content: input.content,
220
+ reasoning_content: input.reasoning_content,
221
+ toolCalls: input.toolCalls,
222
+ attachments: input.attachments,
223
+ detailRef: input.detailRef,
224
+ metadata: input.metadata
225
+ });
226
+ const projection = projectChatMessageParts(parts);
227
+ return {
228
+ messageId: input.messageId,
229
+ conversationId: input.conversationId,
230
+ originNodeId: input.originNodeId ?? "unknown",
231
+ timestamp: now,
232
+ lamportClock: input.lamportClock ?? now,
233
+ role: input.role,
234
+ parts: parts.length > 0 ? parts : void 0,
235
+ content: input.content ?? projection.content,
236
+ contentType: input.contentType ?? "text/plain",
237
+ metadata: input.metadata,
238
+ duration: input.duration,
239
+ toolCalls: input.toolCalls ?? projection.toolCalls,
240
+ reasoning_content: input.reasoning_content ?? projection.reasoning_content,
241
+ hidden: input.hidden,
242
+ attachments: input.attachments ?? projection.attachments,
243
+ detailRef: input.detailRef
244
+ };
245
+ }
246
+
105
247
  // src/tools/pluginRegistry.ts
106
248
  var defaultPluginRegistry = /* @__PURE__ */ new Map();
107
249
  var activeOverride = null;
@@ -229,6 +371,7 @@ function flattenResponses(responses) {
229
371
  // src/promptUtilities/responsePatternUtility.ts
230
372
  var import_json5 = __toESM(require("json5"), 1);
231
373
  var MAX_FALLBACK_INPUT_LENGTH = 1e3;
374
+ var TOOL_PARAMETER_PARSE_ERROR_KEY = "__memeloopToolParameterParseError";
232
375
  function parseToolParameters(parametersText) {
233
376
  if (!parametersText || !parametersText.trim()) {
234
377
  return {};
@@ -242,7 +385,9 @@ function parseToolParameters(parametersText) {
242
385
  return import_json5.default.parse(trimmedText);
243
386
  } catch {
244
387
  }
245
- return { input: trimmedText.substring(0, MAX_FALLBACK_INPUT_LENGTH) };
388
+ return {
389
+ [TOOL_PARAMETER_PARSE_ERROR_KEY]: `Invalid tool arguments JSON. Return one valid JSON object inside the tool tag. Received: ${trimmedText.substring(0, MAX_FALLBACK_INPUT_LENGTH)}`
390
+ };
246
391
  }
247
392
  function extractFunctionCallsParameters(text) {
248
393
  const parameters = {};
@@ -748,148 +893,6 @@ async function* streamLlm(context, request) {
748
893
  yield resolved;
749
894
  }
750
895
 
751
- // src/conversation/parts.ts
752
- function tryParseJson(value) {
753
- try {
754
- return JSON.parse(value);
755
- } catch {
756
- return void 0;
757
- }
758
- }
759
- function parseLegacyToolResultContent(content) {
760
- const match = /(?:<functions_result>\s*)?Tool:\s*(.+?)\nParameters:\s*(.+?)\n(Error|Result):\s*([\s\S]*?)\s*(?:<\/functions_result>|$)/su.exec(content.trim());
761
- if (!match) return null;
762
- const [, rawToolName, rawParameters, kind, rawBody] = match;
763
- const parsedParameters = tryParseJson(rawParameters.trim());
764
- const result = rawBody.trim();
765
- return {
766
- type: "tool-result",
767
- toolName: rawToolName.trim(),
768
- parameters: parsedParameters,
769
- result,
770
- isError: kind === "Error",
771
- payload: tryParseJson(result)
772
- };
773
- }
774
- function isTextPart(part) {
775
- return part.type === "text";
776
- }
777
- function isReasoningPart(part) {
778
- return part.type === "reasoning";
779
- }
780
- function isToolCallPart(part) {
781
- return part.type === "tool-call";
782
- }
783
- function isAttachmentPart(part) {
784
- return part.type === "attachment";
785
- }
786
- function isToolResultPart(part) {
787
- return part.type === "tool-result";
788
- }
789
- function buildToolResultSummary(part) {
790
- const prefix = part.isError ? "Error" : "Result";
791
- const suffix = part.result.trim();
792
- if (suffix.length === 0) return `${prefix} from ${part.toolName}`;
793
- return `${prefix} from ${part.toolName}: ${suffix}`;
794
- }
795
- function projectChatMessageParts(parts) {
796
- const text = parts.filter(isTextPart).map((part) => part.text.trim()).filter(Boolean);
797
- const reasoning = parts.filter(isReasoningPart).map((part) => part.text.trim()).filter(Boolean);
798
- const toolCalls = parts.filter(isToolCallPart).map((part) => ({ id: part.toolCallId, toolName: part.toolName, arguments: part.arguments }));
799
- const attachments = parts.filter(isAttachmentPart).map((part) => part.attachment);
800
- const toolResults = parts.filter(isToolResultPart);
801
- let content = text.join("\n\n");
802
- if (content.length === 0 && toolResults.length > 0) {
803
- content = toolResults.map(buildToolResultSummary).join("\n\n");
804
- }
805
- if (content.length === 0 && toolCalls.length > 0) {
806
- content = toolCalls.map((part) => `Tool call: ${part.toolName}`).join("\n\n");
807
- }
808
- return {
809
- content,
810
- reasoning_content: reasoning.length > 0 ? reasoning.join("\n\n") : void 0,
811
- toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
812
- attachments: attachments.length > 0 ? attachments : void 0
813
- };
814
- }
815
- function buildLegacyChatMessageParts(input) {
816
- const parts = [];
817
- if (input.role !== "tool" && typeof input.content === "string" && input.content.trim().length > 0) {
818
- parts.push({ type: "text", text: input.content });
819
- }
820
- if (typeof input.reasoning_content === "string" && input.reasoning_content.trim().length > 0) {
821
- parts.push({ type: "reasoning", text: input.reasoning_content });
822
- }
823
- if (input.toolCalls) {
824
- for (const toolCall of input.toolCalls) {
825
- parts.push({
826
- type: "tool-call",
827
- toolCallId: toolCall.id,
828
- toolName: toolCall.toolName,
829
- arguments: toolCall.arguments
830
- });
831
- }
832
- }
833
- if (input.attachments) {
834
- for (const attachment of input.attachments) {
835
- parts.push({ type: "attachment", attachment });
836
- }
837
- }
838
- if (input.role === "tool") {
839
- const metadata = input.metadata ?? {};
840
- const parsed = typeof input.content === "string" ? parseLegacyToolResultContent(input.content) : null;
841
- const toolName = typeof metadata.toolId === "string" && metadata.toolId.length > 0 ? metadata.toolId : parsed?.toolName ?? "tool";
842
- const result = parsed?.result ?? (typeof input.content === "string" ? input.content : "");
843
- const payload = parsed?.payload ?? tryParseJson(result);
844
- parts.push({
845
- type: "tool-result",
846
- toolName,
847
- parameters: metadata.toolParameters ?? parsed?.parameters,
848
- result,
849
- isError: metadata.isError === true || parsed?.isError === true,
850
- payload,
851
- detailRef: input.detailRef
852
- });
853
- }
854
- return parts;
855
- }
856
- function getChatMessageParts(message) {
857
- return message.parts ?? buildLegacyChatMessageParts(message);
858
- }
859
-
860
- // src/conversation/factory.ts
861
- function createChatMessage(input) {
862
- const now = Date.now();
863
- const parts = input.parts ?? buildLegacyChatMessageParts({
864
- role: input.role,
865
- content: input.content,
866
- reasoning_content: input.reasoning_content,
867
- toolCalls: input.toolCalls,
868
- attachments: input.attachments,
869
- detailRef: input.detailRef,
870
- metadata: input.metadata
871
- });
872
- const projection = projectChatMessageParts(parts);
873
- return {
874
- messageId: input.messageId,
875
- conversationId: input.conversationId,
876
- originNodeId: input.originNodeId ?? "unknown",
877
- timestamp: now,
878
- lamportClock: input.lamportClock ?? now,
879
- role: input.role,
880
- parts: parts.length > 0 ? parts : void 0,
881
- content: input.content ?? projection.content,
882
- contentType: input.contentType ?? "text/plain",
883
- metadata: input.metadata,
884
- duration: input.duration,
885
- toolCalls: input.toolCalls ?? projection.toolCalls,
886
- reasoning_content: input.reasoning_content ?? projection.reasoning_content,
887
- hidden: input.hidden,
888
- attachments: input.attachments ?? projection.attachments,
889
- detailRef: input.detailRef
890
- };
891
- }
892
-
893
896
  // src/promptUtilities/promptConcat.ts
894
897
  function collectPromptSourcePaths(prompts, basePath = "agentFrameworkConfig.prompts") {
895
898
  const out = {};
@@ -1397,6 +1400,10 @@ async function executeRegistryTool(context, toolId, parameters) {
1397
1400
  }
1398
1401
  }
1399
1402
  async function executeWithGuards(context, options, conversationId, recentToolCalls, call) {
1403
+ const parameterParseError = call.parameters[TOOL_PARAMETER_PARSE_ERROR_KEY];
1404
+ if (typeof parameterParseError === "string") {
1405
+ return { text: parameterParseError, isError: true };
1406
+ }
1400
1407
  const signature = `${call.toolId}:${JSON.stringify(call.parameters)}`;
1401
1408
  recentToolCalls.push(signature);
1402
1409
  const threshold = Math.max(2, options?.doomLoopThreshold ?? 3);
@@ -1819,6 +1826,49 @@ function resolveMaxIterations(context) {
1819
1826
  const configured = context.agentToolLoop?.maxIterations;
1820
1827
  return configured != null && configured > 0 ? configured : DEFAULT_MAX_ITERATIONS;
1821
1828
  }
1829
+ function pluginToolCallSignature(calls) {
1830
+ return calls.map((call) => `${call.toolId}:${JSON.stringify(call.parameters)}`).join("|");
1831
+ }
1832
+ async function blockRepeatedPluginToolCalls(context, input, state, calls, hookContext) {
1833
+ if (calls.length === 0) return { blocked: false };
1834
+ const signature = pluginToolCallSignature(calls);
1835
+ state.recentToolCalls.push(signature);
1836
+ const threshold = Math.max(2, context.agentToolLoop?.doomLoopThreshold ?? 3);
1837
+ const last = state.recentToolCalls.slice(-threshold);
1838
+ if (last.length !== threshold || !last.every((entry) => entry === signature)) {
1839
+ return { blocked: false };
1840
+ }
1841
+ const message = `Blocked by doom-loop guard: the model repeated the same tool call ${threshold} times. Change the arguments or approach before trying again.`;
1842
+ const firstCall = calls[0];
1843
+ const lamportClock = await nextLamportClockForConversation(
1844
+ context.storage,
1845
+ input.conversationId
1846
+ );
1847
+ const toolMessage = createChatMessage({
1848
+ messageId: `${input.conversationId}:t:doom-loop:${state.iteration}:${Date.now().toString(36)}`,
1849
+ conversationId: input.conversationId,
1850
+ originNodeId: "local",
1851
+ lamportClock,
1852
+ role: "tool",
1853
+ parts: [{
1854
+ type: "tool-result",
1855
+ toolName: firstCall.toolId,
1856
+ parameters: firstCall.parameters,
1857
+ result: message,
1858
+ isError: true
1859
+ }],
1860
+ metadata: {
1861
+ isToolResult: true,
1862
+ isError: true,
1863
+ toolId: firstCall.toolId,
1864
+ toolParameters: firstCall.parameters,
1865
+ doomLoopBlocked: true
1866
+ }
1867
+ });
1868
+ hookContext.agent.messages.push(toolMessage);
1869
+ await context.storage.appendMessage(toolMessage);
1870
+ return { blocked: true, message };
1871
+ }
1822
1872
  function createAgentToolLoopState(context) {
1823
1873
  return {
1824
1874
  iteration: 0,
@@ -1959,7 +2009,7 @@ async function* runAgentToolLoopIteration(context, input, state) {
1959
2009
  iteration
1960
2010
  }
1961
2011
  };
1962
- const messages = await buildLlmMessages(context, input.conversationId, history);
2012
+ const messages = await buildLlmMessages(hookContext, input.conversationId, history);
1963
2013
  const request = { conversationId: input.conversationId, messages };
1964
2014
  const assistantMessageId = `${input.conversationId}:a:${iteration}:${Date.now().toString(36)}`;
1965
2015
  const assistantLamportClock = await nextLamportClockForConversation(
@@ -2016,6 +2066,31 @@ async function* runAgentToolLoopIteration(context, input, state) {
2016
2066
  await hookContext.persistAgentMessage?.(assistantMessage);
2017
2067
  const { calls, parallel } = matchAllToolCallings(assistantText);
2018
2068
  if (hasPlugins && frameworkConfig) {
2069
+ const doomLoop = await blockRepeatedPluginToolCalls(
2070
+ context,
2071
+ input,
2072
+ state,
2073
+ calls,
2074
+ hookContext
2075
+ );
2076
+ if (doomLoop.blocked) {
2077
+ yield {
2078
+ type: "tool",
2079
+ data: {
2080
+ toolId: calls[0].toolId,
2081
+ parameters: calls[0].parameters,
2082
+ parallel,
2083
+ result: doomLoop.message,
2084
+ isError: true
2085
+ }
2086
+ };
2087
+ yield finishAgentToolLoopThinking(state, "error", {
2088
+ status: "blocked",
2089
+ conversationId: input.conversationId,
2090
+ reason: doomLoop.message
2091
+ });
2092
+ return { action: "stop", reason: "error" };
2093
+ }
2019
2094
  const { hooks } = await createHooksWithPlugins(
2020
2095
  frameworkConfig,
2021
2096
  {
@@ -2389,9 +2464,9 @@ var builtinProfileSources = {
2389
2464
  "{",
2390
2465
  ' "id": "memeloop:general-assistant",',
2391
2466
  ' "name": "\u901A\u7528\u52A9\u624B",',
2392
- ' "description": "\u901A\u7528\u81EA\u7136\u8BED\u8A00\u52A9\u7406\uFF0C\u7528\u4E8E\u65E5\u5E38\u95EE\u7B54\u548C\u7B80\u5355\u4EFB\u52A1\u3002",',
2467
+ ' "description": "\u53EF\u9760\u7684\u901A\u7528\u667A\u80FD\u4F53\uFF0C\u7528\u4E8E\u5BF9\u8BDD\u3001Wiki \u77E5\u8BC6\u5DE5\u4F5C\u3001\u76EE\u6807\u63A8\u8FDB\u548C\u65E5\u5E38\u8BA1\u7B97\u673A\u64CD\u4F5C\u3002",',
2393
2468
  ' "loopId": "agent-tool-loop",',
2394
- ' "systemPrompt": "You are a helpful general-purpose assistant. When you need to use a tool, output ONLY the tool call in this exact XML format:\\n<tool_use name=\\"TOOL_NAME\\">{\\"param\\":\\"value\\"}</tool_use>\\nNever wrap tool calls in markdown code blocks or add explanatory text before/after the tool call in the same message. After receiving the tool result, continue responding normally.",',
2469
+ ` "systemPrompt": "You are MemeLoop, a reliable general-purpose agent for conversation, knowledge work, goal completion, and everyday computer tasks.\\n\\nOperating contract:\\n- Treat the user request as the active goal. For a task with three or more meaningful steps, use the planning tool actually listed in the tool instructions (for example manage-todo or todoWrite) to create a short plan, keep exactly one item in progress, and update it as work advances. Continue until the goal is achieved or genuinely blocked.\\n- Use tools for actions and for facts that must be read from the user's environment. Never claim that an action succeeded without a successful tool result. Never invent search results, file contents, counts, or completion evidence.\\n- Use the exact tool name and parameter schema shown in the tool list. When calling a tool, output ONLY one tool call in this exact XML format:\\n<tool_use name=\\"TOOL_NAME\\">{\\"param\\":\\"value\\"}</tool_use>\\n The JSON must be valid. Never wrap the call in markdown or add text before or after it. After the tool result, reassess the goal and continue.\\n- If a tool fails, read the error and change the arguments or approach. Do not repeat an identical failed call more than once, and do not retry the same approach more than twice.\\n- For Wiki work, use an injected available workspace name or ID; do not guess one. Search before relying on stored knowledge. For wiki-search, exact-title filter syntax is [title[Exact Title]], tag syntax is [tag[Tag]], and semantic search uses searchType \\"vector\\" with query. A filter search uses searchType \\"filter\\" with filter. After a write, verify important content with a valid exact-title search. If verification fails, report that honestly.\\n- Save durable facts, decisions, plans, and user-requested memories to Wiki when useful. Do not store credentials or other sensitive data unless the user explicitly asks.\\n- For UI or computer actions, inspect the current state before acting, prefer reversible changes, verify the resulting state, and ask before destructive actions or consequential external communication.\\n- Do not ask for confirmation before an explicitly requested reversible action when the target is already known. Ask a concise question only when missing information materially changes the result. Otherwise make safe, explicit assumptions and proceed.\\n- In the final response, lead with the outcome, cite concrete verification, and state any remaining limitation briefly.",`,
2395
2470
  ' "tools": [',
2396
2471
  ' "workspacesList",',
2397
2472
  ' "wikiSearch",',
@@ -2404,7 +2479,8 @@ var builtinProfileSources = {
2404
2479
  ' { "id": "builtin:mcp-client" },',
2405
2480
  ' { "id": "builtin:mcp-forward" },',
2406
2481
  ' { "id": "builtin:spawn-agent" },',
2407
- ' { "id": "builtin:ask-question" }',
2482
+ ' { "id": "builtin:ask-question" },',
2483
+ ' { "id": "builtin:todo-write" }',
2408
2484
  " ],",
2409
2485
  ' "agentTools": [',
2410
2486
  " {",
@@ -2460,6 +2536,16 @@ var builtinProfileSources = {
2460
2536
  ' "toolListPosition": { "targetId": "builtin-system", "position": "after" }',
2461
2537
  " }",
2462
2538
  " }",
2539
+ " },",
2540
+ " {",
2541
+ ' "toolId": "todo",',
2542
+ ' "parameters": {',
2543
+ ' "todoParam": {',
2544
+ ' "toolListPosition": { "targetId": "builtin-system", "position": "after" },',
2545
+ ' "todoInjectionTargetId": "builtin-system",',
2546
+ ' "toolResultDuration": 1',
2547
+ " }",
2548
+ " }",
2463
2549
  " }",
2464
2550
  " ],",
2465
2551
  ' "agentFrameworkConfig": {',
@@ -2467,7 +2553,7 @@ var builtinProfileSources = {
2467
2553
  " {",
2468
2554
  ' "id": "builtin-system",',
2469
2555
  ' "role": "system",',
2470
- ' "text": "You are a helpful general-purpose assistant. When you need to use a tool, output ONLY the tool call in this exact XML format:\\n<tool_use name=\\"TOOL_NAME\\">{\\"param\\":\\"value\\"}</tool_use>\\nNever wrap tool calls in markdown code blocks or add explanatory text before/after the tool call in the same message. After receiving the tool result, continue responding normally."',
2556
+ ` "text": "You are MemeLoop, a reliable general-purpose agent for conversation, knowledge work, goal completion, and everyday computer tasks.\\n\\nOperating contract:\\n- Treat the user request as the active goal. For a task with three or more meaningful steps, use the planning tool actually listed in the tool instructions (for example manage-todo or todoWrite) to create a short plan, keep exactly one item in progress, and update it as work advances. Continue until the goal is achieved or genuinely blocked.\\n- Use tools for actions and for facts that must be read from the user's environment. Never claim that an action succeeded without a successful tool result. Never invent search results, file contents, counts, or completion evidence.\\n- Use the exact tool name and parameter schema shown in the tool list. When calling a tool, output ONLY one tool call in this exact XML format:\\n<tool_use name=\\"TOOL_NAME\\">{\\"param\\":\\"value\\"}</tool_use>\\n The JSON must be valid. Never wrap the call in markdown or add text before or after it. After the tool result, reassess the goal and continue.\\n- If a tool fails, read the error and change the arguments or approach. Do not repeat an identical failed call more than once, and do not retry the same approach more than twice.\\n- For Wiki work, use an injected available workspace name or ID; do not guess one. Search before relying on stored knowledge. For wiki-search, exact-title filter syntax is [title[Exact Title]], tag syntax is [tag[Tag]], and semantic search uses searchType \\"vector\\" with query. A filter search uses searchType \\"filter\\" with filter. After a write, verify important content with a valid exact-title search. If verification fails, report that honestly.\\n- Save durable facts, decisions, plans, and user-requested memories to Wiki when useful. Do not store credentials or other sensitive data unless the user explicitly asks.\\n- For UI or computer actions, inspect the current state before acting, prefer reversible changes, verify the resulting state, and ask before destructive actions or consequential external communication.\\n- Do not ask for confirmation before an explicitly requested reversible action when the target is already known. Ask a concise question only when missing information materially changes the result. Otherwise make safe, explicit assumptions and proceed.\\n- In the final response, lead with the outcome, cite concrete verification, and state any remaining limitation briefly."`,
2471
2557
  " }",
2472
2558
  " ],",
2473
2559
  ' "plugins": [{ "toolId": "fullReplacement" }],',
@@ -2479,7 +2565,7 @@ var builtinProfileSources = {
2479
2565
  ' "temperature": 0.5,',
2480
2566
  ' "maxTokens": 4096',
2481
2567
  " },",
2482
- ' "version": "1.0.0"',
2568
+ ' "version": "1.1.0"',
2483
2569
  "}",
2484
2570
  ""
2485
2571
  ].join("\n"),