memeloop 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/dist/browser.cjs +1413 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.cts +3066 -0
- package/dist/browser.d.ts +3066 -0
- package/dist/browser.js +43 -0
- package/dist/chunk-426CJUZP.js +630 -0
- package/dist/chunk-426CJUZP.js.map +1 -0
- package/dist/chunk-44YHBKDL.js +382 -0
- package/dist/chunk-44YHBKDL.js.map +1 -0
- package/dist/chunk-7ZDTB4VZ.js +63 -0
- package/dist/chunk-7ZDTB4VZ.js.map +1 -0
- package/dist/chunk-AZFYDWIN.js +98 -0
- package/dist/chunk-AZFYDWIN.js.map +1 -0
- package/dist/chunk-BGPU4RR7.js +367 -0
- package/dist/chunk-BGPU4RR7.js.map +1 -0
- package/dist/chunk-CCEFAOSH.js +496 -0
- package/dist/chunk-CCEFAOSH.js.map +1 -0
- package/dist/chunk-FWSY5HOA.js +63 -0
- package/dist/chunk-FWSY5HOA.js.map +1 -0
- package/dist/chunk-GYIOMQMY.js +8726 -0
- package/dist/chunk-GYIOMQMY.js.map +1 -0
- package/dist/chunk-HVB2BR3H.js +42 -0
- package/dist/chunk-HVB2BR3H.js.map +1 -0
- package/dist/chunk-K6P63KD4.js +68 -0
- package/dist/chunk-K6P63KD4.js.map +1 -0
- package/dist/chunk-MRKY4HGF.js +205 -0
- package/dist/chunk-MRKY4HGF.js.map +1 -0
- package/dist/chunk-QFHAAIIM.js +2657 -0
- package/dist/chunk-QFHAAIIM.js.map +1 -0
- package/dist/chunk-VZKQX5PP.js +1 -0
- package/dist/chunk-VZKQX5PP.js.map +1 -0
- package/dist/chunk-WAI6BODI.js +175 -0
- package/dist/chunk-WAI6BODI.js.map +1 -0
- package/dist/chunk-XHRBV6I3.js +3637 -0
- package/dist/chunk-XHRBV6I3.js.map +1 -0
- package/dist/chunk-YMNXDNDW.js +798 -0
- package/dist/chunk-YMNXDNDW.js.map +1 -0
- package/dist/conversation.cjs +208 -0
- package/dist/conversation.cjs.map +1 -0
- package/dist/conversation.d.cts +100 -0
- package/dist/conversation.d.ts +100 -0
- package/dist/conversation.js +21 -0
- package/dist/conversation.js.map +1 -0
- package/dist/device-network-portable.cjs +702 -0
- package/dist/device-network-portable.cjs.map +1 -0
- package/dist/device-network-portable.d.cts +110 -0
- package/dist/device-network-portable.d.ts +110 -0
- package/dist/device-network-portable.js +53 -0
- package/dist/device-network-portable.js.map +1 -0
- package/dist/device-network.cjs +906 -0
- package/dist/device-network.cjs.map +1 -0
- package/dist/device-network.d.cts +6 -0
- package/dist/device-network.d.ts +6 -0
- package/dist/device-network.js +59 -0
- package/dist/device-network.js.map +1 -0
- package/dist/fetchProvider-BpcGVSOG.d.cts +91 -0
- package/dist/fetchProvider-Cm0sO4Tl.d.ts +91 -0
- package/dist/index.cjs +27957 -5459
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +94 -1320
- package/dist/index.d.ts +94 -1320
- package/dist/index.js +10576 -2386
- package/dist/index.js.map +1 -1
- package/dist/interface-IrKBFtL1.d.cts +493 -0
- package/dist/interface-IrKBFtL1.d.ts +493 -0
- package/dist/llm-providers.cjs +43 -8
- package/dist/llm-providers.cjs.map +1 -1
- package/dist/llm-providers.d.cts +2 -1
- package/dist/llm-providers.d.ts +2 -1
- package/dist/llm-providers.js +4 -2
- package/dist/llm-providers.js.map +1 -1
- package/dist/loop-api.cjs +5177 -2050
- package/dist/loop-api.cjs.map +1 -1
- package/dist/loop-api.d.cts +11 -5
- package/dist/loop-api.d.ts +11 -5
- package/dist/loop-api.js +84 -49
- package/dist/mobile.cjs +2625 -0
- package/dist/mobile.cjs.map +1 -0
- package/dist/mobile.d.cts +6 -0
- package/dist/mobile.d.ts +6 -0
- package/dist/mobile.js +22 -0
- package/dist/mobile.js.map +1 -0
- package/dist/orchestration-portable-Bsf8YRfp.d.cts +2192 -0
- package/dist/orchestration-portable-Zw0g5tbj.d.ts +2192 -0
- package/dist/orchestration-portable.cjs +9553 -0
- package/dist/orchestration-portable.cjs.map +1 -0
- package/dist/orchestration-portable.d.cts +5 -0
- package/dist/orchestration-portable.d.ts +5 -0
- package/dist/orchestration-portable.js +290 -0
- package/dist/orchestration-portable.js.map +1 -0
- package/dist/pairingInvite-BXPWY3aM.d.cts +149 -0
- package/dist/pairingInvite-Cuz0wuq9.d.ts +149 -0
- package/dist/promptConcat-WTN-uHcz.d.cts +516 -0
- package/dist/promptConcat-deDSWZE3.d.ts +516 -0
- package/dist/providerRegistry-9trr5aoK.d.ts +86 -0
- package/dist/providerRegistry-xk_B1Ekv.d.cts +86 -0
- package/dist/registry-8eztoD_r.d.cts +393 -0
- package/dist/registry-DV24sI-3.d.ts +393 -0
- package/dist/remoteClient-B_spK019.d.ts +87 -0
- package/dist/remoteClient-CBggnRy3.d.cts +87 -0
- package/dist/runtime-SKSXVYIM.js +18 -0
- package/dist/runtime-SKSXVYIM.js.map +1 -0
- package/dist/scriptDeploymentPipeline-BAeo1dPb.d.cts +2463 -0
- package/dist/scriptDeploymentPipeline-DsnT0AG6.d.ts +2463 -0
- package/dist/syncCloudDevices-BEqwgrhD.d.ts +49 -0
- package/dist/syncCloudDevices-Ds_Kcgrv.d.cts +49 -0
- package/dist/types-7pYti-k9.d.cts +255 -0
- package/dist/types-CdFVSntj.d.ts +255 -0
- package/package.json +110 -35
- package/dist/anthropic.cjs +0 -72
- package/dist/anthropic.cjs.map +0 -1
- package/dist/anthropic.d.cts +0 -21
- package/dist/anthropic.d.ts +0 -21
- package/dist/anthropic.js +0 -21
- package/dist/anthropic.js.map +0 -1
- package/dist/azure.cjs +0 -72
- package/dist/azure.cjs.map +0 -1
- package/dist/azure.d.cts +0 -21
- package/dist/azure.d.ts +0 -21
- package/dist/azure.js +0 -21
- package/dist/azure.js.map +0 -1
- package/dist/chunk-3CN7DFBL.js +0 -4894
- package/dist/chunk-3CN7DFBL.js.map +0 -1
- package/dist/chunk-4AZ4D7U5.js +0 -32
- package/dist/chunk-4AZ4D7U5.js.map +0 -1
- package/dist/chunk-6ON4XSOV.js +0 -63
- package/dist/chunk-6ON4XSOV.js.map +0 -1
- package/dist/chunk-DJQNGIXX.js +0 -4793
- package/dist/chunk-DJQNGIXX.js.map +0 -1
- package/dist/chunk-FKQP6AOQ.js +0 -32
- package/dist/chunk-FKQP6AOQ.js.map +0 -1
- package/dist/chunk-OVJ7JJBA.js +0 -35
- package/dist/chunk-OVJ7JJBA.js.map +0 -1
- package/dist/chunk-P4UZ7IXC.js +0 -42
- package/dist/chunk-YHJ2AEFR.js +0 -4933
- package/dist/chunk-YHJ2AEFR.js.map +0 -1
- package/dist/chunk-YVK7RYRO.js +0 -4973
- package/dist/chunk-YVK7RYRO.js.map +0 -1
- package/dist/code-assistant.json +0 -114
- package/dist/cohere.cjs +0 -72
- package/dist/cohere.cjs.map +0 -1
- package/dist/cohere.d.cts +0 -21
- package/dist/cohere.d.ts +0 -21
- package/dist/cohere.js +0 -21
- package/dist/cohere.js.map +0 -1
- package/dist/deepseek.cjs +0 -72
- package/dist/deepseek.cjs.map +0 -1
- package/dist/deepseek.d.cts +0 -21
- package/dist/deepseek.d.ts +0 -21
- package/dist/deepseek.js +0 -21
- package/dist/deepseek.js.map +0 -1
- package/dist/dist-65U7OYRG.js +0 -1257
- package/dist/dist-65U7OYRG.js.map +0 -1
- package/dist/fetchProvider-Cu4WkU5O.d.cts +0 -819
- package/dist/fetchProvider-Cu4WkU5O.d.ts +0 -819
- package/dist/frontend-ui-ux.json +0 -105
- package/dist/general-assistant.json +0 -95
- package/dist/git-master.json +0 -51
- package/dist/google-vertex.cjs +0 -72
- package/dist/google-vertex.cjs.map +0 -1
- package/dist/google-vertex.d.cts +0 -21
- package/dist/google-vertex.d.ts +0 -21
- package/dist/google-vertex.js +0 -21
- package/dist/google-vertex.js.map +0 -1
- package/dist/google.cjs +0 -72
- package/dist/google.cjs.map +0 -1
- package/dist/google.d.cts +0 -21
- package/dist/google.d.ts +0 -21
- package/dist/google.js +0 -21
- package/dist/google.js.map +0 -1
- package/dist/groq.cjs +0 -72
- package/dist/groq.cjs.map +0 -1
- package/dist/groq.d.cts +0 -21
- package/dist/groq.d.ts +0 -21
- package/dist/groq.js +0 -21
- package/dist/groq.js.map +0 -1
- package/dist/index.d.mts +0 -3203
- package/dist/index.mjs +0 -7064
- package/dist/index.mjs.map +0 -1
- package/dist/mistral.cjs +0 -72
- package/dist/mistral.cjs.map +0 -1
- package/dist/mistral.d.cts +0 -21
- package/dist/mistral.d.ts +0 -21
- package/dist/mistral.js +0 -21
- package/dist/mistral.js.map +0 -1
- package/dist/multipart-parser-EJCXIUHC.js +0 -372
- package/dist/multipart-parser-EJCXIUHC.js.map +0 -1
- package/dist/openai.cjs +0 -72
- package/dist/openai.cjs.map +0 -1
- package/dist/openai.d.cts +0 -21
- package/dist/openai.d.ts +0 -21
- package/dist/openai.js +0 -21
- package/dist/openai.js.map +0 -1
- package/dist/perplexity.cjs +0 -72
- package/dist/perplexity.cjs.map +0 -1
- package/dist/perplexity.d.cts +0 -21
- package/dist/perplexity.d.ts +0 -21
- package/dist/perplexity.js +0 -21
- package/dist/perplexity.js.map +0 -1
- package/dist/playwright.json +0 -52
- package/dist/promptConcat-BJdazTg5.d.cts +0 -1832
- package/dist/promptConcat-BJdazTg5.d.ts +0 -1832
- package/dist/promptConcat-CAkpni_8.d.cts +0 -1834
- package/dist/promptConcat-CAkpni_8.d.ts +0 -1834
- package/dist/promptConcat-CfH5-GAE.d.cts +0 -1036
- package/dist/promptConcat-ChcAZOOL.d.ts +0 -1036
- package/dist/promptConcat-G5TnJVRy.d.cts +0 -1800
- package/dist/promptConcat-G5TnJVRy.d.ts +0 -1800
- package/dist/promptConcat-L72eowzp.d.ts +0 -1090
- package/dist/promptConcat-eLHdN7K8.d.cts +0 -1090
- package/dist/src-VTSXKG72.js +0 -1409
- package/dist/src-VTSXKG72.js.map +0 -1
- package/dist/togetherai.cjs +0 -72
- package/dist/togetherai.cjs.map +0 -1
- package/dist/togetherai.d.cts +0 -21
- package/dist/togetherai.d.ts +0 -21
- package/dist/togetherai.js +0 -21
- package/dist/togetherai.js.map +0 -1
- package/dist/types-B0Jm2l38.d.cts +0 -767
- package/dist/types-B0Jm2l38.d.ts +0 -767
- package/dist/xai.cjs +0 -72
- package/dist/xai.cjs.map +0 -1
- package/dist/xai.d.cts +0 -21
- package/dist/xai.d.ts +0 -21
- package/dist/xai.js +0 -21
- package/dist/xai.js.map +0 -1
- /package/dist/{chunk-P4UZ7IXC.js.map → browser.js.map} +0 -0
|
@@ -1,1800 +0,0 @@
|
|
|
1
|
-
declare const BUILTIN_AGENT_AGENT_LOOP_QUALITY_GATE_SCRIPT_ID = "builtin:agent-agent-loop/quality-gate";
|
|
2
|
-
declare const builtinAgentAgentLoopSources: Readonly<Record<string, string>>;
|
|
3
|
-
declare function getBuiltinAgentAgentLoopSource(id: string): string | undefined;
|
|
4
|
-
|
|
5
|
-
interface PromptNode {
|
|
6
|
-
id: string;
|
|
7
|
-
text?: string;
|
|
8
|
-
/** TidGi IPrompt 兼容 */
|
|
9
|
-
caption?: string;
|
|
10
|
-
role?: 'system' | 'user' | 'assistant' | 'tool';
|
|
11
|
-
enabled?: boolean;
|
|
12
|
-
children?: PromptNode[];
|
|
13
|
-
/** UI 溯源,可选 */
|
|
14
|
-
source?: unknown;
|
|
15
|
-
/**
|
|
16
|
-
* 与插件 `dynamicPosition` 配合:用户轮次 ≥2 时将根级该节点移到列表末尾。
|
|
17
|
-
*/
|
|
18
|
-
dynamicPosition?: 'deferToEnd';
|
|
19
|
-
}
|
|
20
|
-
/** 与 TidGi `IPrompt` 对齐的别名 */
|
|
21
|
-
type IPrompt = PromptNode;
|
|
22
|
-
interface PromptPluginConfig {
|
|
23
|
-
id: string;
|
|
24
|
-
toolId: string;
|
|
25
|
-
enabled?: boolean;
|
|
26
|
-
/** defineTool:`approval`(mode / allowPatterns / denyPatterns)等,类型见 `tools/types` */
|
|
27
|
-
[key: string]: unknown;
|
|
28
|
-
}
|
|
29
|
-
interface AgentFrameworkConfig {
|
|
30
|
-
prompts: PromptNode[];
|
|
31
|
-
response?: unknown[];
|
|
32
|
-
plugins: PromptPluginConfig[];
|
|
33
|
-
}
|
|
34
|
-
interface AgentPromptDescription {
|
|
35
|
-
agentFrameworkConfig?: AgentFrameworkConfig;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface AgentDefinitionModelConfig {
|
|
39
|
-
provider?: string;
|
|
40
|
-
model?: string;
|
|
41
|
-
temperature?: number;
|
|
42
|
-
maxTokens?: number;
|
|
43
|
-
}
|
|
44
|
-
interface ModelSelection {
|
|
45
|
-
provider: string;
|
|
46
|
-
model: string;
|
|
47
|
-
[key: string]: unknown;
|
|
48
|
-
}
|
|
49
|
-
interface ModelParameters {
|
|
50
|
-
temperature?: number;
|
|
51
|
-
maxTokens?: number;
|
|
52
|
-
topP?: number;
|
|
53
|
-
[key: string]: unknown;
|
|
54
|
-
}
|
|
55
|
-
interface AiAPIConfig {
|
|
56
|
-
default?: ModelSelection;
|
|
57
|
-
embedding?: ModelSelection;
|
|
58
|
-
speech?: ModelSelection;
|
|
59
|
-
imageGeneration?: ModelSelection;
|
|
60
|
-
transcriptions?: ModelSelection;
|
|
61
|
-
free?: ModelSelection;
|
|
62
|
-
modelParameters: ModelParameters;
|
|
63
|
-
[key: string]: unknown;
|
|
64
|
-
}
|
|
65
|
-
interface AgentHeartbeatConfig {
|
|
66
|
-
enabled: boolean;
|
|
67
|
-
intervalSeconds: number;
|
|
68
|
-
message: string;
|
|
69
|
-
activeHoursStart?: string;
|
|
70
|
-
activeHoursEnd?: string;
|
|
71
|
-
}
|
|
72
|
-
interface AgentDefinitionToolConfig {
|
|
73
|
-
toolId: string;
|
|
74
|
-
enabled?: boolean;
|
|
75
|
-
parameters?: Record<string, unknown>;
|
|
76
|
-
tags?: string[];
|
|
77
|
-
}
|
|
78
|
-
type HostAgentToolConfig = AgentDefinitionToolConfig;
|
|
79
|
-
interface AgentDefinition {
|
|
80
|
-
id: string;
|
|
81
|
-
name: string;
|
|
82
|
-
description: string;
|
|
83
|
-
systemPrompt: string;
|
|
84
|
-
tools: string[];
|
|
85
|
-
modelConfig?: AgentDefinitionModelConfig;
|
|
86
|
-
promptSchema?: unknown;
|
|
87
|
-
/**
|
|
88
|
-
* TidGi-Desktop / memeloop:prompt 树、插件、maxIterations 等(结构见 memeloop prompt 类型)
|
|
89
|
-
* Typed as `AgentFrameworkConfig` so all hosts share a single canonical shape.
|
|
90
|
-
*/
|
|
91
|
-
agentFrameworkConfig?: AgentFrameworkConfig;
|
|
92
|
-
/** Host-specific explicit tool configuration. Hosts map this to prompt plugins at runtime. */
|
|
93
|
-
agentTools?: AgentDefinitionToolConfig[];
|
|
94
|
-
/** Host-specific avatar or icon URL. */
|
|
95
|
-
avatarUrl?: string;
|
|
96
|
-
/** Host-specific agent handler / framework ID. */
|
|
97
|
-
agentFrameworkID?: string;
|
|
98
|
-
/** Periodic auto-wake configuration. */
|
|
99
|
-
heartbeat?: AgentHeartbeatConfig;
|
|
100
|
-
/** Host-specific AI API config override. */
|
|
101
|
-
aiApiConfig?: AiAPIConfig;
|
|
102
|
-
version: string;
|
|
103
|
-
}
|
|
104
|
-
interface AgentInstanceMeta {
|
|
105
|
-
instanceId: string;
|
|
106
|
-
definitionId: string;
|
|
107
|
-
nodeId: string;
|
|
108
|
-
conversationId: string;
|
|
109
|
-
createdAt: number;
|
|
110
|
-
updatedAt: number;
|
|
111
|
-
definitionDelta?: Partial<AgentDefinition>;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
type ToolCallingMatch = {
|
|
115
|
-
found: false;
|
|
116
|
-
} | {
|
|
117
|
-
found: true;
|
|
118
|
-
toolId: string;
|
|
119
|
-
parameters: Record<string, unknown>;
|
|
120
|
-
originalText: string;
|
|
121
|
-
};
|
|
122
|
-
declare function matchToolCalling(responseText: string): ToolCallingMatch;
|
|
123
|
-
declare function matchAllToolCallings(responseText: string): {
|
|
124
|
-
calls: Array<ToolCallingMatch & {
|
|
125
|
-
found: true;
|
|
126
|
-
}>;
|
|
127
|
-
parallel: boolean;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* TidGi-Desktop `agentInstance/tools/types.ts` 迁移并适配 memeloop(无 tapable,用 HookSlot.promise 串行执行)。
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
/** 供 defineTool / 审批使用:agent 视图包含完整 AgentInstance。 */
|
|
135
|
-
type DefineToolAgentFrameworkContext = AgentFrameworkContext & {
|
|
136
|
-
agent: AgentInstanceModel;
|
|
137
|
-
};
|
|
138
|
-
type ToolApprovalMode = 'auto' | 'confirm';
|
|
139
|
-
interface ToolApprovalConfig {
|
|
140
|
-
mode: ToolApprovalMode;
|
|
141
|
-
allowPatterns?: string[];
|
|
142
|
-
denyPatterns?: string[];
|
|
143
|
-
timeoutMs?: number;
|
|
144
|
-
}
|
|
145
|
-
type ApprovalDecision = 'allow' | 'deny' | 'pending';
|
|
146
|
-
interface ToolApprovalRequest {
|
|
147
|
-
approvalId: string;
|
|
148
|
-
agentId: string;
|
|
149
|
-
toolName: string;
|
|
150
|
-
parameters: Record<string, unknown>;
|
|
151
|
-
originalText?: string;
|
|
152
|
-
created: Date;
|
|
153
|
-
}
|
|
154
|
-
type YieldNextRoundTarget = 'human' | 'self' | `agent:${string}`;
|
|
155
|
-
interface ToolActions {
|
|
156
|
-
yieldNextRoundTo?: YieldNextRoundTarget;
|
|
157
|
-
newUserMessage?: string;
|
|
158
|
-
toolCalling?: ToolCallingMatch;
|
|
159
|
-
}
|
|
160
|
-
interface BaseToolContext {
|
|
161
|
-
agentFrameworkContext: DefineToolAgentFrameworkContext;
|
|
162
|
-
metadata?: Record<string, unknown>;
|
|
163
|
-
actions?: ToolActions;
|
|
164
|
-
}
|
|
165
|
-
/** 与 TidGi IPromptConcatTool 对齐的插件行 */
|
|
166
|
-
interface FrameworkPluginToolConfig {
|
|
167
|
-
id: string;
|
|
168
|
-
toolId: string;
|
|
169
|
-
enabled?: boolean;
|
|
170
|
-
caption?: string;
|
|
171
|
-
content?: string;
|
|
172
|
-
forbidOverrides?: boolean;
|
|
173
|
-
approval?: ToolApprovalConfig;
|
|
174
|
-
timeoutMs?: number;
|
|
175
|
-
[key: string]: unknown;
|
|
176
|
-
}
|
|
177
|
-
interface PromptConcatHookContext extends BaseToolContext {
|
|
178
|
-
messages: ChatMessage[];
|
|
179
|
-
prompts: IPrompt[];
|
|
180
|
-
toolConfig: FrameworkPluginToolConfig;
|
|
181
|
-
pluginIndex?: number;
|
|
182
|
-
}
|
|
183
|
-
interface AgentResponse {
|
|
184
|
-
id: string;
|
|
185
|
-
text?: string;
|
|
186
|
-
enabled?: boolean;
|
|
187
|
-
children?: AgentResponse[];
|
|
188
|
-
}
|
|
189
|
-
interface PostProcessContext extends PromptConcatHookContext {
|
|
190
|
-
llmResponse: string;
|
|
191
|
-
responses?: AgentResponse[];
|
|
192
|
-
}
|
|
193
|
-
/** 流式响应子集(memeloop ILLMProvider 聚合为最终文本后注入) */
|
|
194
|
-
interface AIStreamResponseSubset {
|
|
195
|
-
status: 'update' | 'done';
|
|
196
|
-
content: string;
|
|
197
|
-
}
|
|
198
|
-
interface AIResponseContext extends BaseToolContext {
|
|
199
|
-
toolConfig: FrameworkPluginToolConfig;
|
|
200
|
-
agentFrameworkConfig?: {
|
|
201
|
-
plugins?: FrameworkPluginToolConfig[];
|
|
202
|
-
};
|
|
203
|
-
response: AIStreamResponseSubset;
|
|
204
|
-
requestId?: string;
|
|
205
|
-
isFinal?: boolean;
|
|
206
|
-
}
|
|
207
|
-
interface UserMessageContext extends BaseToolContext {
|
|
208
|
-
content: {
|
|
209
|
-
text: string;
|
|
210
|
-
file?: unknown;
|
|
211
|
-
wikiTiddlers?: Array<{
|
|
212
|
-
workspaceName: string;
|
|
213
|
-
tiddlerTitle: string;
|
|
214
|
-
}>;
|
|
215
|
-
};
|
|
216
|
-
messageId: string;
|
|
217
|
-
timestamp: Date;
|
|
218
|
-
}
|
|
219
|
-
interface AgentStatusContext extends BaseToolContext {
|
|
220
|
-
status: {
|
|
221
|
-
state: 'working' | 'completed' | 'failed' | 'canceled';
|
|
222
|
-
modified: Date;
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
interface ToolExecutionContext extends BaseToolContext {
|
|
226
|
-
toolResult: {
|
|
227
|
-
success: boolean;
|
|
228
|
-
data?: string;
|
|
229
|
-
error?: string;
|
|
230
|
-
metadata?: Record<string, unknown>;
|
|
231
|
-
};
|
|
232
|
-
toolInfo: {
|
|
233
|
-
toolId: string;
|
|
234
|
-
parameters: Record<string, unknown>;
|
|
235
|
-
originalText?: string;
|
|
236
|
-
};
|
|
237
|
-
requestId?: string;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Hook 槽:与 tapable AsyncSeriesHook 一致 — `tapAsync` 注册,`promise(ctx)` 串行触发。
|
|
241
|
-
*/
|
|
242
|
-
interface HookSlot {
|
|
243
|
-
tapAsync(name: string, function_: (context: any, callback: () => void) => void): void;
|
|
244
|
-
promise(context: unknown): Promise<void>;
|
|
245
|
-
}
|
|
246
|
-
interface PromptConcatHooks {
|
|
247
|
-
processPrompts: HookSlot;
|
|
248
|
-
finalizePrompts: HookSlot;
|
|
249
|
-
postProcess: HookSlot;
|
|
250
|
-
userMessageReceived: HookSlot;
|
|
251
|
-
agentStatusChanged: HookSlot;
|
|
252
|
-
toolExecuted: HookSlot;
|
|
253
|
-
responseUpdate: HookSlot;
|
|
254
|
-
responseComplete: HookSlot;
|
|
255
|
-
}
|
|
256
|
-
type PromptConcatTool = (hooks: PromptConcatHooks) => void;
|
|
257
|
-
|
|
258
|
-
type IMPlatformType = 'telegram' | 'discord' | 'lark' | 'wecom' | 'slack' | 'line' | 'qq';
|
|
259
|
-
interface IMChannel {
|
|
260
|
-
channelId: string;
|
|
261
|
-
platform: IMPlatformType;
|
|
262
|
-
nodeId: string;
|
|
263
|
-
webhookMode: 'cloud-relay' | 'direct';
|
|
264
|
-
webhookUrl?: string;
|
|
265
|
-
defaultDefinitionId?: string;
|
|
266
|
-
status: 'active' | 'inactive' | 'error';
|
|
267
|
-
}
|
|
268
|
-
interface IMChannelBinding {
|
|
269
|
-
channelId: string;
|
|
270
|
-
imUserId: string;
|
|
271
|
-
activeConversationId: string;
|
|
272
|
-
createdAt: number;
|
|
273
|
-
defaultDefinitionId?: string;
|
|
274
|
-
/** When set, the user's next inbound message is treated as an askQuestion answer (plan §20.3). */
|
|
275
|
-
pendingQuestionId?: string;
|
|
276
|
-
}
|
|
277
|
-
/** @deprecated Use IMChannelBinding */
|
|
278
|
-
type ImChannelBindingRecord = IMChannelBinding;
|
|
279
|
-
|
|
280
|
-
type VersionVector = Record<string, number>;
|
|
281
|
-
interface ConversationMeta {
|
|
282
|
-
conversationId: string;
|
|
283
|
-
title: string;
|
|
284
|
-
lastMessagePreview: string;
|
|
285
|
-
lastMessageTimestamp: number;
|
|
286
|
-
messageCount: number;
|
|
287
|
-
originNodeId: string;
|
|
288
|
-
definitionId: string;
|
|
289
|
-
instanceDelta?: Record<string, unknown>;
|
|
290
|
-
isUserInitiated: boolean;
|
|
291
|
-
sourceChannel?: {
|
|
292
|
-
channelId: string;
|
|
293
|
-
platform: string;
|
|
294
|
-
imUserId: string;
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
declare function isConversationMeta(value: unknown): value is ConversationMeta;
|
|
298
|
-
|
|
299
|
-
interface CheckpointRecord {
|
|
300
|
-
conversationId: string;
|
|
301
|
-
messages: ChatMessage[];
|
|
302
|
-
savedAt: string;
|
|
303
|
-
messageCount: number;
|
|
304
|
-
lastMessagePreview: string;
|
|
305
|
-
}
|
|
306
|
-
interface CheckpointSummary {
|
|
307
|
-
conversationId: string;
|
|
308
|
-
savedAt: string;
|
|
309
|
-
messageCount: number;
|
|
310
|
-
lastMessagePreview: string;
|
|
311
|
-
}
|
|
312
|
-
interface CheckpointStore {
|
|
313
|
-
saveCheckpoint(conversationId: string, messages: ChatMessage[]): Promise<CheckpointRecord>;
|
|
314
|
-
loadCheckpoint(conversationId: string): Promise<CheckpointRecord | null>;
|
|
315
|
-
listCheckpoints(): Promise<CheckpointSummary[]>;
|
|
316
|
-
deleteCheckpoint(conversationId: string): Promise<boolean>;
|
|
317
|
-
}
|
|
318
|
-
interface SessionStorageOptions {
|
|
319
|
-
records?: CheckpointRecord[];
|
|
320
|
-
}
|
|
321
|
-
declare function createCheckpointRecord(conversationId: string, messages: ChatMessage[], savedAt?: string): CheckpointRecord;
|
|
322
|
-
declare function parseCheckpointRecord(raw: string): CheckpointRecord | null;
|
|
323
|
-
declare function serializeCheckpointRecord(record: CheckpointRecord): string;
|
|
324
|
-
declare class InMemoryCheckpointStore implements CheckpointStore {
|
|
325
|
-
private readonly records;
|
|
326
|
-
constructor(options?: SessionStorageOptions);
|
|
327
|
-
saveCheckpoint(conversationId: string, messages: ChatMessage[]): Promise<CheckpointRecord>;
|
|
328
|
-
loadCheckpoint(conversationId: string): Promise<CheckpointRecord | null>;
|
|
329
|
-
listCheckpoints(): Promise<CheckpointSummary[]>;
|
|
330
|
-
deleteCheckpoint(conversationId: string): Promise<boolean>;
|
|
331
|
-
}
|
|
332
|
-
declare class SessionStorage extends InMemoryCheckpointStore {
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
type ConversationQueryMode = 'metadata-only' | 'full-content' | 'on-demand';
|
|
336
|
-
interface ListConversationsOptions {
|
|
337
|
-
limit?: number;
|
|
338
|
-
offset?: number;
|
|
339
|
-
}
|
|
340
|
-
interface GetMessagesOptions {
|
|
341
|
-
mode?: ConversationQueryMode;
|
|
342
|
-
}
|
|
343
|
-
interface IAgentStorage {
|
|
344
|
-
listConversations(options?: ListConversationsOptions): Promise<ConversationMeta[]>;
|
|
345
|
-
getMessages(conversationId: string, options?: GetMessagesOptions): Promise<ChatMessage[]>;
|
|
346
|
-
appendMessage(message: ChatMessage): Promise<void>;
|
|
347
|
-
/**
|
|
348
|
-
* Upsert conversation directory row (sync / Solid / peer metadata).
|
|
349
|
-
*/
|
|
350
|
-
upsertConversationMetadata(meta: ConversationMeta): Promise<void>;
|
|
351
|
-
/**
|
|
352
|
-
* Insert messages if messageId not present (merge from remote / Pod); refreshes per-conversation messageCount.
|
|
353
|
-
*/
|
|
354
|
-
insertMessagesIfAbsent(messages: ChatMessage[]): Promise<void>;
|
|
355
|
-
getAttachment(contentHash: string): Promise<AttachmentReference | null>;
|
|
356
|
-
saveAttachment(reference: AttachmentReference, data: Buffer | Uint8Array): Promise<void>;
|
|
357
|
-
/** Read persisted attachment bytes for cross-node RPC `memeloop.storage.getAttachmentBlob`. */
|
|
358
|
-
readAttachmentData?(contentHash: string): Promise<Uint8Array | null>;
|
|
359
|
-
getAgentDefinition(id: string): Promise<AgentDefinition | null>;
|
|
360
|
-
/** Optional optimization: use `SELECT MAX(lamportClock)` instead of scanning all messages for clock state. */
|
|
361
|
-
getMaxLamportClockForConversation?(conversationId: string): Promise<number>;
|
|
362
|
-
saveAgentInstance(meta: AgentInstanceMeta): Promise<void>;
|
|
363
|
-
/** Read the conversation metadata row used by AgentToolLoop to resolve `definitionId`. */
|
|
364
|
-
getConversationMeta(conversationId: string): Promise<ConversationMeta | null>;
|
|
365
|
-
/** IM user-to-conversation binding (persisted by memeloop-cli + SQLite). */
|
|
366
|
-
getImBinding?(channelId: string, imUserId: string): Promise<IMChannelBinding | null>;
|
|
367
|
-
setImBinding?(record: IMChannelBinding): Promise<void>;
|
|
368
|
-
}
|
|
369
|
-
interface MemeLoopLogger {
|
|
370
|
-
debug?(message: string, ...arguments_: unknown[]): void;
|
|
371
|
-
info?(message: string, ...arguments_: unknown[]): void;
|
|
372
|
-
warn?(message: string, ...arguments_: unknown[]): void;
|
|
373
|
-
error?(message: string, ...arguments_: unknown[]): void;
|
|
374
|
-
}
|
|
375
|
-
interface ILLMProvider {
|
|
376
|
-
name: string;
|
|
377
|
-
model?: unknown;
|
|
378
|
-
chat(request: unknown): AsyncIterable<unknown> | Promise<unknown>;
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* LLM Provider interface - now compatible with Vercel AI SDK's LanguageModelV1.
|
|
382
|
-
* The `model` field holds the actual LanguageModelV1 instance from @ai-sdk/openai, @ai-sdk/anthropic, etc.
|
|
383
|
-
*/
|
|
384
|
-
interface IToolRegistry {
|
|
385
|
-
registerTool(id: string, impl: unknown): void;
|
|
386
|
-
getTool(id: string): unknown | undefined;
|
|
387
|
-
listTools(): string[];
|
|
388
|
-
/** Prompt-concat plugin registry, isolated per runtime. Falls back to the process-level default registry. */
|
|
389
|
-
getPromptPlugins?: () => Map<string, (hooks: PromptConcatHooks) => void>;
|
|
390
|
-
}
|
|
391
|
-
interface IChatSyncAdapter {
|
|
392
|
-
start(): Promise<void>;
|
|
393
|
-
stop(): Promise<void>;
|
|
394
|
-
}
|
|
395
|
-
interface INetworkService {
|
|
396
|
-
start(): Promise<void>;
|
|
397
|
-
stop(): Promise<void>;
|
|
398
|
-
}
|
|
399
|
-
interface AgentToolLoopOptions {
|
|
400
|
-
/** Maximum LLM-to-tool round-trips. `0` means unlimited, still capped internally. */
|
|
401
|
-
maxIterations?: number;
|
|
402
|
-
/** Whether to parse `<tool_use>` / `<function_call>` and execute through `IToolRegistry` (default true). */
|
|
403
|
-
enableToolLoop?: boolean;
|
|
404
|
-
/** Cancellation check, e.g. when the user stops a run. */
|
|
405
|
-
isCancelled?: (conversationId: string) => boolean;
|
|
406
|
-
/** Attachment injection for promptConcat, aligned with `PromptConcatOptions`. */
|
|
407
|
-
readAttachmentFile?: (path: string) => Promise<Uint8Array | Buffer>;
|
|
408
|
-
/** Omit history older than this many milliseconds when building LLM input. `0` disables trimming. */
|
|
409
|
-
maxHistoryAgeMs?: number;
|
|
410
|
-
/**
|
|
411
|
-
* When `defineTool` / plugins are configured, fall back to `IToolRegistry` for tool calls not handled by `onResponseComplete`.
|
|
412
|
-
*/
|
|
413
|
-
fallbackRegistryTools?: boolean;
|
|
414
|
-
/**
|
|
415
|
-
* Tool permission rules (default allow).
|
|
416
|
-
* Supports wildcards such as "terminal.*" and "file.read".
|
|
417
|
-
*/
|
|
418
|
-
toolPermissions?: {
|
|
419
|
-
default?: 'allow' | 'ask' | 'deny';
|
|
420
|
-
rules?: Array<{
|
|
421
|
-
pattern: string;
|
|
422
|
-
action: 'allow' | 'ask' | 'deny';
|
|
423
|
-
}>;
|
|
424
|
-
perAgent?: Record<string, {
|
|
425
|
-
default?: 'allow' | 'ask' | 'deny';
|
|
426
|
-
rules?: Array<{
|
|
427
|
-
pattern: string;
|
|
428
|
-
action: 'allow' | 'ask' | 'deny';
|
|
429
|
-
}>;
|
|
430
|
-
}>;
|
|
431
|
-
};
|
|
432
|
-
/** Threshold for repeated identical tool+input calls (default 3). */
|
|
433
|
-
doomLoopThreshold?: number;
|
|
434
|
-
/** History compaction window: keep the most recent N turns plus the last user message. */
|
|
435
|
-
contextCompaction?: {
|
|
436
|
-
maxMessages?: number;
|
|
437
|
-
replayLastUserMessage?: boolean;
|
|
438
|
-
};
|
|
439
|
-
/**
|
|
440
|
-
* Auto-compaction: when message count exceeds threshold, summarizes old
|
|
441
|
-
* conversation turns via truncation or LLM summarization. Default: disabled.
|
|
442
|
-
*/
|
|
443
|
-
autoCompact?: {
|
|
444
|
-
/** Trigger compaction when message count exceeds this (default: 50) */
|
|
445
|
-
threshold?: number;
|
|
446
|
-
/** Number of recent turns to preserve (default: 4) */
|
|
447
|
-
recentTurnsToKeep?: number;
|
|
448
|
-
/** Maximum token estimate before compaction; 0 disables token-based compaction */
|
|
449
|
-
maxTokens?: number;
|
|
450
|
-
};
|
|
451
|
-
/** Session checkpoint: save conversation history after each turn for resume. */
|
|
452
|
-
sessionCheckpoint?: {
|
|
453
|
-
/** Enable checkpoint saves. Default: false. */
|
|
454
|
-
enabled?: boolean;
|
|
455
|
-
/** Store provided by the runtime host. */
|
|
456
|
-
store?: CheckpointStore;
|
|
457
|
-
/** Custom checkpoint directory (default: ~/.memeloop/sessions/) */
|
|
458
|
-
directory?: string;
|
|
459
|
-
};
|
|
460
|
-
/**
|
|
461
|
-
* After a tool returns `__memeloopToolResult.awaitSessionId`, AgentToolLoop waits here before the next LLM round.
|
|
462
|
-
*/
|
|
463
|
-
waitForTerminalSession?: (sessionId: string) => Promise<{
|
|
464
|
-
exitCode: number | null;
|
|
465
|
-
truncatedOutput: string;
|
|
466
|
-
}>;
|
|
467
|
-
}
|
|
468
|
-
interface AgentFrameworkContext {
|
|
469
|
-
storage: IAgentStorage;
|
|
470
|
-
llmProvider: ILLMProvider;
|
|
471
|
-
tools: IToolRegistry;
|
|
472
|
-
syncAdapters: IChatSyncAdapter[];
|
|
473
|
-
network: INetworkService;
|
|
474
|
-
/** Let host runtimes preserve platform-specific message aliases/metadata while core owns the loop. */
|
|
475
|
-
normalizeMessage?: (message: ChatMessage) => ChatMessage;
|
|
476
|
-
/** AgentToolLoop ReAct behavior, migrated from the TidGi-Desktop agentToolLoop integration. */
|
|
477
|
-
agentToolLoop?: AgentToolLoopOptions;
|
|
478
|
-
/**
|
|
479
|
-
* Host-injected runner used by `createMemeLoopRuntime` after a user sends a message.
|
|
480
|
-
*/
|
|
481
|
-
runAgentToolLoop?: (input: AgentLoopInput) => AgentLoopGenerator;
|
|
482
|
-
/** Run a child agent for orchestration loops such as AgentAgentLoop. */
|
|
483
|
-
runChildAgent?: AgentLoopRuntime['runChildAgent'];
|
|
484
|
-
/** Policy for loading script-backed loops. Defaults to bundled scripts + import specifiers only. */
|
|
485
|
-
loopScriptPolicy?: AgentLoopScriptPolicy;
|
|
486
|
-
/**
|
|
487
|
-
* Build the agent view supplied to defineTool hooks for a conversation.
|
|
488
|
-
*/
|
|
489
|
-
resolveAgentRuntimeView?: (conversationId: string, messages: ChatMessage[]) => Promise<AgentInstanceModel>;
|
|
490
|
-
/** Current agent view for defineTool / TidGi compatibility. */
|
|
491
|
-
agent?: {
|
|
492
|
-
id: string;
|
|
493
|
-
messages: ChatMessage[];
|
|
494
|
-
};
|
|
495
|
-
/** Persist a `ChatMessage` if the runtime host supplies this hook. */
|
|
496
|
-
persistAgentMessage?: (message: ChatMessage) => Promise<void>;
|
|
497
|
-
/** Cancellation markers written by `createMemeLoopRuntime`. */
|
|
498
|
-
conversationCancellation?: Set<string>;
|
|
499
|
-
/** Resolve an AgentDefinition from host-specific sources. */
|
|
500
|
-
resolveAgentDefinition?: (definitionId: string) => Promise<AgentDefinition | null>;
|
|
501
|
-
/** Fallback logger used when the host does not inject one. */
|
|
502
|
-
logger?: MemeLoopLogger;
|
|
503
|
-
/** TidGi defineTool compatibility: legacy plugins call this without arguments. */
|
|
504
|
-
isCancelled?: () => boolean;
|
|
505
|
-
}
|
|
506
|
-
type AgentInstanceState = 'submitted' | 'working' | 'input-required' | 'completed' | 'canceled' | 'failed' | 'unknown';
|
|
507
|
-
interface AgentInstanceLatestStatus {
|
|
508
|
-
state: AgentInstanceState;
|
|
509
|
-
message?: ChatMessage;
|
|
510
|
-
/** Human-readable sub-status for the header — shown while agent is working. */
|
|
511
|
-
progress?: string;
|
|
512
|
-
created?: Date;
|
|
513
|
-
modified?: Date;
|
|
514
|
-
}
|
|
515
|
-
interface AgentInstanceModel extends Omit<AgentDefinition, 'name'> {
|
|
516
|
-
agentDefId: string;
|
|
517
|
-
name?: string;
|
|
518
|
-
agentFrameworkConfig?: AgentFrameworkConfig;
|
|
519
|
-
messages: ChatMessage[];
|
|
520
|
-
status: AgentInstanceLatestStatus;
|
|
521
|
-
created: Date;
|
|
522
|
-
modified?: Date;
|
|
523
|
-
closed?: boolean;
|
|
524
|
-
volatile?: boolean;
|
|
525
|
-
isDelegatedAgentRun?: boolean;
|
|
526
|
-
parentAgentRunId?: string;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
declare function isUserInitiatedConversation(meta: ConversationMeta): boolean;
|
|
530
|
-
declare function createInstanceDeltaFromDefinition(definition: AgentDefinition, overrides: Partial<AgentDefinition>): Partial<AgentDefinition>;
|
|
531
|
-
|
|
532
|
-
interface AttachmentReference {
|
|
533
|
-
contentHash: string;
|
|
534
|
-
filename: string;
|
|
535
|
-
mimeType: string;
|
|
536
|
-
size: number;
|
|
537
|
-
}
|
|
538
|
-
type ChatRole = 'user' | 'assistant' | 'tool' | 'agent' | 'error';
|
|
539
|
-
interface ToolCall {
|
|
540
|
-
id: string;
|
|
541
|
-
toolName: string;
|
|
542
|
-
arguments: unknown;
|
|
543
|
-
}
|
|
544
|
-
/** Points to large tool output stored elsewhere (agent-run log, terminal session, file). */
|
|
545
|
-
type DetailRefType = 'agent-run' | 'terminal-session' | 'file';
|
|
546
|
-
interface DetailReference {
|
|
547
|
-
type: DetailRefType;
|
|
548
|
-
/** Delegated agent / spawn / remote conversation id */
|
|
549
|
-
conversationId?: string;
|
|
550
|
-
/** Terminal session id (often paired with `terminal:<sessionId>` conversation) */
|
|
551
|
-
sessionId?: string;
|
|
552
|
-
/** Node that holds the detail payload */
|
|
553
|
-
nodeId?: string;
|
|
554
|
-
/** e.g. `memeloop://node/.../file/...` from `buildMemeloopFileUri` in `../network/uri.js` */
|
|
555
|
-
fileUri?: string;
|
|
556
|
-
exitCode?: number;
|
|
557
|
-
}
|
|
558
|
-
interface ChatMessage {
|
|
559
|
-
messageId: string;
|
|
560
|
-
conversationId: string;
|
|
561
|
-
originNodeId: string;
|
|
562
|
-
timestamp: number;
|
|
563
|
-
lamportClock: number;
|
|
564
|
-
role: ChatRole;
|
|
565
|
-
content: string;
|
|
566
|
-
toolCalls?: ToolCall[];
|
|
567
|
-
attachments?: AttachmentReference[];
|
|
568
|
-
/** Summary lives in `content`; full payload fetched via detail ref (plan §5.2.1). */
|
|
569
|
-
detailRef?: DetailReference;
|
|
570
|
-
/** Reasoning/thinking content */
|
|
571
|
-
reasoning_content?: string;
|
|
572
|
-
/** Content MIME type */
|
|
573
|
-
contentType?: string;
|
|
574
|
-
/** Whether message should be hidden in UI */
|
|
575
|
-
hidden?: boolean;
|
|
576
|
-
/** Message processing duration in ms */
|
|
577
|
-
duration?: number | null;
|
|
578
|
-
/** Additional metadata */
|
|
579
|
-
metadata?: Record<string, unknown>;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* Domain factories for creating canonical ChatMessage and AgentInstance objects.
|
|
584
|
-
*
|
|
585
|
-
* These factories ensure that every host (Desktop, Mobile, CLI, Cloud)
|
|
586
|
-
* constructs messages and instances with the same required fields,
|
|
587
|
-
* default values, and clock behavior.
|
|
588
|
-
*
|
|
589
|
-
* Hosts that need a different originNodeId, message ID scheme, or lamport
|
|
590
|
-
* clock source should pass those values explicitly rather than creating
|
|
591
|
-
* their own factory.
|
|
592
|
-
*/
|
|
593
|
-
|
|
594
|
-
/**
|
|
595
|
-
* Create a canonical ChatMessage with required defaults.
|
|
596
|
-
*
|
|
597
|
-
* @param input.messageId - Unique message identifier. Use nanoid or equivalent.
|
|
598
|
-
* @param input.conversationId - The conversation/agent-instance this message belongs to.
|
|
599
|
-
* @param input.role - Message role (user, assistant, tool, agent, error).
|
|
600
|
-
* @param input.content - Message text content.
|
|
601
|
-
* @param input.originNodeId - Node that originated this message. Core default is "unknown";
|
|
602
|
-
* hosts should pass their own identifier (e.g. "tidgi-desktop", "memeloop-cli").
|
|
603
|
-
* @param input.contentType - MIME type override (default "text/plain").
|
|
604
|
-
* @param input.metadata - Optional metadata map.
|
|
605
|
-
* @param input.duration - Processing duration in ms.
|
|
606
|
-
* @param input.lamportClock - Lamport clock value. Defaults to `Date.now()`.
|
|
607
|
-
* @param input.toolCalls - Tool calls associated with assistant messages.
|
|
608
|
-
* @param input.reasoning_content - Reasoning/thinking content.
|
|
609
|
-
* @param input.hidden - Whether the message is hidden from the UI.
|
|
610
|
-
* @param input.detailRef - Reference to large tool output stored elsewhere.
|
|
611
|
-
*/
|
|
612
|
-
declare function createChatMessage(input: {
|
|
613
|
-
messageId: string;
|
|
614
|
-
conversationId: string;
|
|
615
|
-
role: ChatRole;
|
|
616
|
-
content: string;
|
|
617
|
-
originNodeId?: string;
|
|
618
|
-
contentType?: string;
|
|
619
|
-
metadata?: Record<string, unknown>;
|
|
620
|
-
duration?: number | null;
|
|
621
|
-
lamportClock?: number;
|
|
622
|
-
toolCalls?: ChatMessage['toolCalls'];
|
|
623
|
-
reasoning_content?: string;
|
|
624
|
-
hidden?: boolean;
|
|
625
|
-
attachments?: ChatMessage['attachments'];
|
|
626
|
-
detailRef?: ChatMessage['detailRef'];
|
|
627
|
-
}): ChatMessage;
|
|
628
|
-
/**
|
|
629
|
-
* Create an AgentInstance from an AgentDefinition.
|
|
630
|
-
*
|
|
631
|
-
* The returned instance has an empty message list, a default "completed"
|
|
632
|
-
* status, and copies all definition-level fields as instance defaults.
|
|
633
|
-
*
|
|
634
|
-
* @param definition - The AgentDefinition to base the instance on.
|
|
635
|
-
* @param overrides - Optional overrides for instance-specific fields:
|
|
636
|
-
* - `id`: Instance ID (default: nanoid-equivalent, must be provided by host)
|
|
637
|
-
* - `name`: Display name (default: definition.name)
|
|
638
|
-
* - `status`: Initial status
|
|
639
|
-
* - `volatile`: Whether the instance is ephemeral
|
|
640
|
-
* - `closed`: Whether closed on creation
|
|
641
|
-
* - `isDelegatedAgentRun`, `parentAgentRunId`: Delegated agent relationship
|
|
642
|
-
* - `agentFrameworkConfig`: Per-instance framework config override
|
|
643
|
-
*/
|
|
644
|
-
declare function createAgentInstanceFromDefinition(definition: AgentDefinition, overrides: {
|
|
645
|
-
id: string;
|
|
646
|
-
name?: string;
|
|
647
|
-
status?: AgentInstanceLatestStatus;
|
|
648
|
-
volatile?: boolean;
|
|
649
|
-
closed?: boolean;
|
|
650
|
-
isDelegatedAgentRun?: boolean;
|
|
651
|
-
parentAgentRunId?: string;
|
|
652
|
-
agentFrameworkConfig?: AgentFrameworkConfig;
|
|
653
|
-
}): AgentInstanceModel;
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* Unified loop contract for all agent loop types.
|
|
657
|
-
* Replaces the old AgentToolLoopInput / AgentToolLoopStep naming entirely.
|
|
658
|
-
*/
|
|
659
|
-
|
|
660
|
-
/** Standard input for any agent loop. */
|
|
661
|
-
interface AgentLoopInput {
|
|
662
|
-
conversationId: string;
|
|
663
|
-
message: string;
|
|
664
|
-
/** Host-prepared user message, used when the platform needs metadata/attachments on the turn root. */
|
|
665
|
-
userMessage?: Omit<Partial<ChatMessage>, 'conversationId' | 'role'> & {
|
|
666
|
-
content?: string;
|
|
667
|
-
};
|
|
668
|
-
/** If provided, these messages are loaded as conversation history on resume. */
|
|
669
|
-
resumeSession?: ChatMessage[];
|
|
670
|
-
}
|
|
671
|
-
/** Standard output step yielded by any agent loop. */
|
|
672
|
-
interface AgentLoopStep {
|
|
673
|
-
type: 'thinking' | 'tool' | 'message' | 'permission_request';
|
|
674
|
-
data: unknown;
|
|
675
|
-
}
|
|
676
|
-
/** Async iterable signature shared by all loop runners. */
|
|
677
|
-
type AgentLoopGenerator = AsyncIterable<AgentLoopStep>;
|
|
678
|
-
/** Describes a registered loop type. */
|
|
679
|
-
interface AgentLoopDefinition {
|
|
680
|
-
/** Unique id, e.g. "agent-tool-loop" or "agent-agent-loop". */
|
|
681
|
-
id: string;
|
|
682
|
-
/** Human-readable display name. */
|
|
683
|
-
name: string;
|
|
684
|
-
/** Short description of this loop's behaviour. */
|
|
685
|
-
description: string;
|
|
686
|
-
/** Factory: create a loop runner function for the given context. */
|
|
687
|
-
createRunner: (context: {
|
|
688
|
-
[key: string]: unknown;
|
|
689
|
-
}) => (input: AgentLoopInput) => AgentLoopGenerator;
|
|
690
|
-
}
|
|
691
|
-
type LoopProfileScriptReference = {
|
|
692
|
-
kind: 'builtin';
|
|
693
|
-
id: string;
|
|
694
|
-
} | {
|
|
695
|
-
kind: 'specifier';
|
|
696
|
-
specifier: string;
|
|
697
|
-
} | {
|
|
698
|
-
kind: 'source';
|
|
699
|
-
source: string;
|
|
700
|
-
name?: string;
|
|
701
|
-
};
|
|
702
|
-
interface AgentLoopScriptPolicy {
|
|
703
|
-
allowBuiltin?: boolean;
|
|
704
|
-
allowFile?: boolean;
|
|
705
|
-
allowNetwork?: boolean;
|
|
706
|
-
allowSource?: boolean;
|
|
707
|
-
allowSpecifier?: boolean;
|
|
708
|
-
importModule?: (specifier: string) => Promise<unknown>;
|
|
709
|
-
}
|
|
710
|
-
/** Capability extension point for a loop. */
|
|
711
|
-
interface LoopPlugin {
|
|
712
|
-
/** Unique plugin id, e.g. "fullReplacement" or "wikiTools". */
|
|
713
|
-
id: string;
|
|
714
|
-
/** Which loop id this plugin targets, or "*" for all loops. */
|
|
715
|
-
targetLoopId?: string;
|
|
716
|
-
/** Optional schema to validate against profile config. */
|
|
717
|
-
schema?: Record<string, unknown>;
|
|
718
|
-
/** Install the plugin into the given context. Mutates the context in place. */
|
|
719
|
-
install?: (context: {
|
|
720
|
-
[key: string]: unknown;
|
|
721
|
-
}, config?: Record<string, unknown>) => void;
|
|
722
|
-
}
|
|
723
|
-
/** A complete agent profile that describes which loop, which .mjs script, prompts, plugins, and hooks to use. */
|
|
724
|
-
interface LoopProfile {
|
|
725
|
-
/** Unique profile id, e.g. "memeloop:general-assistant". */
|
|
726
|
-
id: string;
|
|
727
|
-
/** Display name. */
|
|
728
|
-
name: string;
|
|
729
|
-
/** Description. */
|
|
730
|
-
description: string;
|
|
731
|
-
/** Which loop to run. Defaults to "agent-tool-loop" if omitted. */
|
|
732
|
-
loopId?: string;
|
|
733
|
-
/** Structured reference to the loop script. Prefer this over `script` for new profiles. */
|
|
734
|
-
scriptReference?: LoopProfileScriptReference;
|
|
735
|
-
/** Legacy alias for `scriptReference`. */
|
|
736
|
-
scriptRef?: LoopProfileScriptReference;
|
|
737
|
-
/** Legacy path/specifier to the .mjs loop script. */
|
|
738
|
-
script?: string;
|
|
739
|
-
/** System prompt (concise form; detailed prompts go to `prompts`). */
|
|
740
|
-
systemPrompt?: string;
|
|
741
|
-
/** Tool allowlist IDs. */
|
|
742
|
-
tools?: string[];
|
|
743
|
-
/** Agent-level tool configuration. */
|
|
744
|
-
agentTools?: Array<{
|
|
745
|
-
toolId: string;
|
|
746
|
-
enabled?: boolean;
|
|
747
|
-
parameters?: Record<string, unknown>;
|
|
748
|
-
tags?: string[];
|
|
749
|
-
}>;
|
|
750
|
-
/** Full agent framework configuration. */
|
|
751
|
-
agentFrameworkConfig?: AgentFrameworkConfig;
|
|
752
|
-
/** System prompt(s) for the agent. */
|
|
753
|
-
prompts?: LoopProfilePrompt[];
|
|
754
|
-
/** Tool / prompt / response plugin configs. */
|
|
755
|
-
plugins?: LoopProfilePluginEntry[];
|
|
756
|
-
/** Hook plugin configs. */
|
|
757
|
-
hookPlugins?: LoopProfilePluginEntry[];
|
|
758
|
-
/** Model configuration. */
|
|
759
|
-
modelConfig?: {
|
|
760
|
-
provider?: string;
|
|
761
|
-
model?: string;
|
|
762
|
-
temperature?: number;
|
|
763
|
-
maxTokens?: number;
|
|
764
|
-
};
|
|
765
|
-
/** Host-specific AI API config override. */
|
|
766
|
-
aiApiConfig?: AiAPIConfig;
|
|
767
|
-
/** Periodic auto-wake configuration. */
|
|
768
|
-
heartbeat?: {
|
|
769
|
-
enabled: boolean;
|
|
770
|
-
intervalSeconds: number;
|
|
771
|
-
message: string;
|
|
772
|
-
activeHoursStart?: string;
|
|
773
|
-
activeHoursEnd?: string;
|
|
774
|
-
};
|
|
775
|
-
/** Host-specific handler / framework ID. */
|
|
776
|
-
agentFrameworkID?: string;
|
|
777
|
-
/** Host-specific avatar or icon URL. */
|
|
778
|
-
avatarUrl?: string;
|
|
779
|
-
/** Tool permission configuration. */
|
|
780
|
-
permissions?: {
|
|
781
|
-
default?: 'allow' | 'ask' | 'deny';
|
|
782
|
-
rules?: Array<{
|
|
783
|
-
pattern: string;
|
|
784
|
-
action: 'allow' | 'ask' | 'deny';
|
|
785
|
-
}>;
|
|
786
|
-
perAgent?: Record<string, {
|
|
787
|
-
default?: string;
|
|
788
|
-
rules?: Array<{
|
|
789
|
-
pattern: string;
|
|
790
|
-
action: string;
|
|
791
|
-
}>;
|
|
792
|
-
}>;
|
|
793
|
-
};
|
|
794
|
-
/** Open schema for host-specific or loop-specific configuration. */
|
|
795
|
-
schema?: Record<string, unknown>;
|
|
796
|
-
/** Arbitrary metadata. */
|
|
797
|
-
metadata?: Record<string, unknown>;
|
|
798
|
-
/** Version string. */
|
|
799
|
-
version?: string;
|
|
800
|
-
}
|
|
801
|
-
interface LoopProfilePrompt {
|
|
802
|
-
id: string;
|
|
803
|
-
role: string;
|
|
804
|
-
text: string;
|
|
805
|
-
caption?: string;
|
|
806
|
-
children?: LoopProfilePrompt[];
|
|
807
|
-
}
|
|
808
|
-
interface LoopProfilePluginEntry {
|
|
809
|
-
/** Plugin id registered in the plugin registry. */
|
|
810
|
-
id: string;
|
|
811
|
-
/** Whether this plugin is enabled. */
|
|
812
|
-
enabled?: boolean;
|
|
813
|
-
/** Plugin-specific configuration. */
|
|
814
|
-
config?: Record<string, unknown>;
|
|
815
|
-
}
|
|
816
|
-
/** Minimal runtime context passed to a loop runner. */
|
|
817
|
-
interface AgentLoopRuntime {
|
|
818
|
-
/** Resolve a profile by id. */
|
|
819
|
-
resolveProfile: (profileId: string) => Promise<LoopProfile | null>;
|
|
820
|
-
/** Run a child agent (or sub-loop) and return its result. */
|
|
821
|
-
runChildAgent: (input: {
|
|
822
|
-
profileId: string;
|
|
823
|
-
prompt: string;
|
|
824
|
-
conversationId: string;
|
|
825
|
-
}) => AgentLoopGenerator;
|
|
826
|
-
/** Log an event for observability. */
|
|
827
|
-
log: (event: string, data?: Record<string, unknown>) => void;
|
|
828
|
-
/** Read/write persistent state for this run. */
|
|
829
|
-
state: {
|
|
830
|
-
get: <T>(key: string) => Promise<T | undefined>;
|
|
831
|
-
set: (key: string, value: unknown) => Promise<void>;
|
|
832
|
-
update: (key: string, updater: (previous: unknown) => unknown) => Promise<void>;
|
|
833
|
-
};
|
|
834
|
-
/** Checkpoint a completed step so it can be skipped on resume. */
|
|
835
|
-
checkpoint: (key: string, result: unknown) => Promise<void>;
|
|
836
|
-
/** Emit a progress step upstream. */
|
|
837
|
-
emit: (step: AgentLoopStep) => void;
|
|
838
|
-
/** Signal whether the run has been cancelled. */
|
|
839
|
-
signal: {
|
|
840
|
-
cancelled: boolean;
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
type AgentLoopScriptReference = string | LoopProfileScriptReference;
|
|
845
|
-
|
|
846
|
-
type LoadAgentAgentLoopScriptOptions = AgentLoopScriptPolicy;
|
|
847
|
-
type AgentAgentLoopScriptReference = AgentLoopScriptReference;
|
|
848
|
-
declare function loadAgentAgentLoopScript(scriptReference: AgentAgentLoopScriptReference, options?: LoadAgentAgentLoopScriptOptions): Promise<AgentAgentLoopScript>;
|
|
849
|
-
|
|
850
|
-
/**
|
|
851
|
-
* AgentAgent_Loop — a loop that orchestrates child agents.
|
|
852
|
-
*
|
|
853
|
-
* This loop does NOT call the LLM directly. Instead it coordinates child agents:
|
|
854
|
-
* - running a child agent and feeding its result to another child agent (review / verify)
|
|
855
|
-
* - splitting work across multiple parallel child agents
|
|
856
|
-
* - looping back to a child agent with feedback when a reviewer rejects the output
|
|
857
|
-
*
|
|
858
|
-
* The loop script (.mjs) holds the orchestration logic. This file provides the
|
|
859
|
-
* runtime that invokes the script and manages child agent runs.
|
|
860
|
-
*/
|
|
861
|
-
|
|
862
|
-
/**
|
|
863
|
-
* Typed API passed to a AgentAgent `.mjs` script.
|
|
864
|
-
*
|
|
865
|
-
* The API is intentionally primitive: scripts decide the workflow shape, role
|
|
866
|
-
* names, approval rules, retry limits, and delivery gates. This runtime only
|
|
867
|
-
* handles child-agent execution, progress events, cancellation, state, and
|
|
868
|
-
* checkpoints.
|
|
869
|
-
*/
|
|
870
|
-
interface AgentAgentLoopScriptArguments {
|
|
871
|
-
/** The parent turn input. `input.message` is the user's original goal. */
|
|
872
|
-
input: AgentLoopInput;
|
|
873
|
-
/** Host/runtime context for advanced integrations. Prefer the typed helpers below when possible. */
|
|
874
|
-
context: AgentAgentLoopContext;
|
|
875
|
-
/** Active profile. Scripts may define their own workflow-specific metadata keys here. */
|
|
876
|
-
profile?: LoopProfile;
|
|
877
|
-
/** Normalized worker agents read from `context.agents` or `profile.metadata.agents`. */
|
|
878
|
-
agents: AgentAgentDescriptor[];
|
|
879
|
-
/**
|
|
880
|
-
* Read raw agent entries from `profile.metadata[key]`; defaults to `agents`.
|
|
881
|
-
* This is deliberately generic so scripts can choose names like `critics`,
|
|
882
|
-
* `builders`, `verifiers`, or any other workflow-specific role.
|
|
883
|
-
*/
|
|
884
|
-
getAgentEntries: (key?: string) => AgentAgentConfigEntry[];
|
|
885
|
-
/** Low-level runtime hooks. Prefer `state`, `checkpoint`, `emit`, and run helpers first. */
|
|
886
|
-
runtime?: Partial<AgentLoopRuntime>;
|
|
887
|
-
/** Run one child agent and collect all yielded steps into a text result. */
|
|
888
|
-
runAgent: (input: AgentAgentRunAgentInput) => Promise<AgentAgentRunAgentResult>;
|
|
889
|
-
/** Run child agents concurrently. Use `runSequential` when order matters. */
|
|
890
|
-
runAgents: (inputs: AgentAgentRunAgentInput[]) => Promise<AgentAgentRunAgentResult[]>;
|
|
891
|
-
/** Run a batch of agents in order, aggregating successful output and failures. */
|
|
892
|
-
runSequential: (input?: AgentAgentBatchRunInput) => Promise<AgentAgentBatchRunResult>;
|
|
893
|
-
/** Run a batch of agents concurrently, aggregating successful output and failures. */
|
|
894
|
-
runParallel: (input?: AgentAgentBatchRunInput) => Promise<AgentAgentBatchRunResult>;
|
|
895
|
-
/** Format a batch result for final delivery or an intermediate report. */
|
|
896
|
-
formatAgentResults: (result: AgentAgentBatchRunResult, options?: AgentAgentFormatResultsOptions) => string;
|
|
897
|
-
/** Emit a formatted batch result as the parent loop's final/user-visible message. */
|
|
898
|
-
finishAgentResults: (result: AgentAgentBatchRunResult, options?: AgentAgentFormatResultsOptions) => void;
|
|
899
|
-
/** Emit a raw loop step upstream. Use sparingly; helpers already emit progress. */
|
|
900
|
-
emit: (step: AgentLoopStep) => void;
|
|
901
|
-
/** Emit a user-visible message or step and end the script's work. */
|
|
902
|
-
finish: (message: string | AgentLoopStep) => void;
|
|
903
|
-
/** True when the host cancelled this parent run. Long-running scripts should check this between phases. */
|
|
904
|
-
isCancelled: () => boolean;
|
|
905
|
-
/** Write an observability event through the host runtime logger. */
|
|
906
|
-
log: (event: string, data?: Record<string, unknown>) => void;
|
|
907
|
-
/** Per-run persistent state scoped by the host runtime. */
|
|
908
|
-
state: AgentLoopRuntime['state'];
|
|
909
|
-
/** Record a resumable milestone for long workflows. */
|
|
910
|
-
checkpoint: AgentLoopRuntime['checkpoint'];
|
|
911
|
-
}
|
|
912
|
-
type AgentAgentScriptContext = AgentAgentLoopScriptArguments;
|
|
913
|
-
type AgentAgentContext = AgentAgentScriptContext;
|
|
914
|
-
interface AgentAgentDescriptor {
|
|
915
|
-
/** Child profile id to run. */
|
|
916
|
-
profileId: string;
|
|
917
|
-
/** Prompt override for this child run. Defaults to the parent input message. */
|
|
918
|
-
prompt?: string;
|
|
919
|
-
/** Conversation id override. Defaults to `${parent}:child:${index}` for batch helpers. */
|
|
920
|
-
conversationId?: string;
|
|
921
|
-
/** Optional human-readable role label, e.g. "implementer" or "reviewer". */
|
|
922
|
-
label?: string;
|
|
923
|
-
[key: string]: unknown;
|
|
924
|
-
}
|
|
925
|
-
type AgentAgentConfigEntry = string | ({
|
|
926
|
-
profileId?: string;
|
|
927
|
-
profile?: string;
|
|
928
|
-
prompt?: string;
|
|
929
|
-
conversationId?: string;
|
|
930
|
-
label?: string;
|
|
931
|
-
} & Record<string, unknown>);
|
|
932
|
-
interface AgentAgentRunAgentInput {
|
|
933
|
-
/** Child profile id. `profile` is accepted as an ergonomic alias for scripts. */
|
|
934
|
-
profileId?: string;
|
|
935
|
-
profile?: string;
|
|
936
|
-
/** Defaults to the parent input message. */
|
|
937
|
-
prompt?: string;
|
|
938
|
-
conversationId?: string;
|
|
939
|
-
label?: string;
|
|
940
|
-
}
|
|
941
|
-
interface AgentAgentRunAgentResult {
|
|
942
|
-
profileId: string;
|
|
943
|
-
conversationId: string;
|
|
944
|
-
steps: AgentLoopStep[];
|
|
945
|
-
text: string;
|
|
946
|
-
}
|
|
947
|
-
interface AgentAgentRunAgentFailure {
|
|
948
|
-
profileId: string;
|
|
949
|
-
conversationId?: string;
|
|
950
|
-
error: string;
|
|
951
|
-
}
|
|
952
|
-
interface AgentAgentBatchRunInput {
|
|
953
|
-
/** Agents to run. Defaults to `ctx.agents`. */
|
|
954
|
-
agents?: AgentAgentConfigEntry[];
|
|
955
|
-
/** Prompt shared by every agent in this batch. Defaults to the parent input message. */
|
|
956
|
-
prompt?: string;
|
|
957
|
-
/** When false, the first child failure rejects the batch. Defaults to true. */
|
|
958
|
-
continueOnError?: boolean;
|
|
959
|
-
}
|
|
960
|
-
interface AgentAgentBatchRunResult {
|
|
961
|
-
results: AgentAgentRunAgentResult[];
|
|
962
|
-
failures: AgentAgentRunAgentFailure[];
|
|
963
|
-
text: string;
|
|
964
|
-
}
|
|
965
|
-
interface AgentAgentFormatResultsOptions {
|
|
966
|
-
emptyMessage?: string;
|
|
967
|
-
failureHeader?: string;
|
|
968
|
-
includeFailureSection?: boolean;
|
|
969
|
-
}
|
|
970
|
-
type AgentAgentLoopScriptResult = AgentLoopGenerator | AgentLoopStep | AgentLoopStep[] | string | undefined;
|
|
971
|
-
type AgentAgentLoopScript = (scriptArguments: AgentAgentLoopScriptArguments) => AgentAgentLoopScriptResult | Promise<AgentAgentLoopScriptResult>;
|
|
972
|
-
interface AgentAgentLoopContext {
|
|
973
|
-
[key: string]: unknown;
|
|
974
|
-
profile?: LoopProfile;
|
|
975
|
-
runtime?: Partial<AgentLoopRuntime>;
|
|
976
|
-
agents?: AgentAgentConfigEntry[];
|
|
977
|
-
script?: AgentAgentLoopScript;
|
|
978
|
-
loadScript?: (script: AgentAgentLoopScriptReference, context: AgentAgentLoopContext) => AgentAgentLoopScript | Promise<AgentAgentLoopScript>;
|
|
979
|
-
scriptPolicy?: LoadAgentAgentLoopScriptOptions;
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* Create the AgentAgent_Loop definition and register it with the loop registry.
|
|
983
|
-
*/
|
|
984
|
-
declare function createAgentAgentLoopDefinition(): AgentLoopDefinition;
|
|
985
|
-
/** Export loop id for consumers. */
|
|
986
|
-
declare function getAgentAgentLoopId(): string;
|
|
987
|
-
|
|
988
|
-
declare const BUILTIN_AGENT_TOOL_LOOP_DEFAULT_SCRIPT_ID = "builtin:agent-tool-loop/default";
|
|
989
|
-
declare const builtinAgentToolLoopSources: Readonly<Record<string, string>>;
|
|
990
|
-
declare function getBuiltinAgentToolLoopSource(id: string): string | undefined;
|
|
991
|
-
|
|
992
|
-
interface CompactionOptions {
|
|
993
|
-
/** Maximum token count to aim for after compaction (estimated by char count / 3.5). Default: 0 (no limit). */
|
|
994
|
-
maxTokens?: number;
|
|
995
|
-
/** Number of recent message turns (user+assistant pairs) to preserve. Default: 4. */
|
|
996
|
-
recentTurnsToKeep?: number;
|
|
997
|
-
/** Whether to attempt LLM summarization. Falls back to truncation if LLM unavailable or fails. Default: true. */
|
|
998
|
-
useLlmSummary?: boolean;
|
|
999
|
-
/** Optional LLM provider for summarization. */
|
|
1000
|
-
llmProvider?: ILLMProvider;
|
|
1001
|
-
}
|
|
1002
|
-
interface CompactionResult {
|
|
1003
|
-
/** Compacted messages (summary + recent turns). */
|
|
1004
|
-
messages: ChatMessage[];
|
|
1005
|
-
/** True if compaction reduced the message count. */
|
|
1006
|
-
compacted: boolean;
|
|
1007
|
-
/** Number of messages dropped. */
|
|
1008
|
-
droppedCount: number;
|
|
1009
|
-
/** Summary text generated or fallback notice. */
|
|
1010
|
-
summaryText: string;
|
|
1011
|
-
}
|
|
1012
|
-
/**
|
|
1013
|
-
* Deterministic compaction: keeps recent N turns and replaces older messages
|
|
1014
|
-
* with a single summary message.
|
|
1015
|
-
*/
|
|
1016
|
-
declare function compactMessages(messages: ChatMessage[], options?: Omit<CompactionOptions, 'llmProvider' | 'useLlmSummary'>): CompactionResult;
|
|
1017
|
-
/**
|
|
1018
|
-
* Checks whether compaction is needed based on message count threshold.
|
|
1019
|
-
* @returns true if message count exceeds threshold (default 50).
|
|
1020
|
-
*/
|
|
1021
|
-
declare function shouldCompact(messages: ChatMessage[], threshold?: number): boolean;
|
|
1022
|
-
/**
|
|
1023
|
-
* Auto-compact: estimates token usage, and if it exceeds maxTokens,
|
|
1024
|
-
* performs compaction to keep the context within bounds.
|
|
1025
|
-
*
|
|
1026
|
-
* Uses the LLM provider for summarization if available, falling back to
|
|
1027
|
-
* simple truncation + turn counting.
|
|
1028
|
-
*/
|
|
1029
|
-
declare function autoCompact(messages: ChatMessage[], options?: CompactionOptions): Promise<CompactionResult>;
|
|
1030
|
-
|
|
1031
|
-
/**
|
|
1032
|
-
* Layered permission system types.
|
|
1033
|
-
*
|
|
1034
|
-
* Permissions are resolved by merging rule sets from multiple layers
|
|
1035
|
-
* (default → agent → user → session), where later layers override earlier ones.
|
|
1036
|
-
*/
|
|
1037
|
-
/** Permission action for a tool invocation. */
|
|
1038
|
-
type PermissionAction = 'allow' | 'deny' | 'ask';
|
|
1039
|
-
/** A single permission rule: matches a tool name pattern to an action. */
|
|
1040
|
-
interface PermissionRule {
|
|
1041
|
-
/** Wildcard-capable pattern, e.g. `"file.*"`, `"shell(rm)"`, `"*"`. */
|
|
1042
|
-
toolPattern: string;
|
|
1043
|
-
action: PermissionAction;
|
|
1044
|
-
}
|
|
1045
|
-
/** A set of permission rules belonging to a specific source/layer. */
|
|
1046
|
-
interface PermissionSet {
|
|
1047
|
-
rules: PermissionRule[];
|
|
1048
|
-
/** Human-readable source identifier for debugging (e.g. "default", "agent:cli-buddy", "user"). */
|
|
1049
|
-
source: string;
|
|
1050
|
-
}
|
|
1051
|
-
/**
|
|
1052
|
-
* Result of merging multiple `PermissionSet` layers.
|
|
1053
|
-
* Each array contains flattened, deduplicated tool patterns for that action.
|
|
1054
|
-
*/
|
|
1055
|
-
interface MergedPermissions {
|
|
1056
|
-
allow: string[];
|
|
1057
|
-
deny: string[];
|
|
1058
|
-
ask: string[];
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
/**
|
|
1062
|
-
* Hook system types for memeloop.
|
|
1063
|
-
* Hooks are lifecycle callbacks that execute before/after key events in the agent loop.
|
|
1064
|
-
*/
|
|
1065
|
-
|
|
1066
|
-
/** Context passed to all hook handlers. */
|
|
1067
|
-
type HookContext = AgentFrameworkContext;
|
|
1068
|
-
/** Result returned by a hook handler. */
|
|
1069
|
-
interface HookResult {
|
|
1070
|
-
/** Whether to allow the action to proceed (false = block/deny) */
|
|
1071
|
-
allowed: boolean;
|
|
1072
|
-
/** Optional message explaining why the action was blocked */
|
|
1073
|
-
reason?: string;
|
|
1074
|
-
/** Optional data modified by the hook (e.g., transformed tool args) */
|
|
1075
|
-
modified?: Record<string, unknown>;
|
|
1076
|
-
/** Optional tool permission action. Interpreted by PreToolUse callers. */
|
|
1077
|
-
permissionAction?: PermissionAction;
|
|
1078
|
-
}
|
|
1079
|
-
/** Signature of a hook handler function. */
|
|
1080
|
-
type HookHandler = (context: HookContext, data: Record<string, unknown>) => Promise<HookResult>;
|
|
1081
|
-
/** Enum of supported hook event types. */
|
|
1082
|
-
type HookType = 'PreToolUse' | 'PostToolUse' | 'UserPromptSubmit' | 'ContextCompaction' | 'AgentStart' | 'AgentStop';
|
|
1083
|
-
/** Data passed to PreToolUse hooks. */
|
|
1084
|
-
interface PreToolUseData extends Record<string, unknown> {
|
|
1085
|
-
toolId: string;
|
|
1086
|
-
parameters: Record<string, unknown>;
|
|
1087
|
-
conversationId: string;
|
|
1088
|
-
}
|
|
1089
|
-
/** Data passed to PostToolUse hooks. */
|
|
1090
|
-
interface PostToolUseData extends Record<string, unknown> {
|
|
1091
|
-
toolId: string;
|
|
1092
|
-
parameters: Record<string, unknown>;
|
|
1093
|
-
result: string;
|
|
1094
|
-
isError: boolean;
|
|
1095
|
-
conversationId: string;
|
|
1096
|
-
}
|
|
1097
|
-
/** Data passed to UserPromptSubmit hooks. */
|
|
1098
|
-
interface UserPromptSubmitData extends Record<string, unknown> {
|
|
1099
|
-
message: string;
|
|
1100
|
-
conversationId: string;
|
|
1101
|
-
}
|
|
1102
|
-
/** Data passed to ContextCompaction hooks before built-in history compaction. */
|
|
1103
|
-
interface ContextCompactionData extends Record<string, unknown> {
|
|
1104
|
-
conversationId: string;
|
|
1105
|
-
iteration: number;
|
|
1106
|
-
history: ChatMessage[];
|
|
1107
|
-
autoCompact?: AgentFrameworkContext['agentToolLoop'] extends infer Options ? Options extends {
|
|
1108
|
-
autoCompact?: infer AutoCompact;
|
|
1109
|
-
} ? AutoCompact : never : never;
|
|
1110
|
-
contextCompaction?: AgentFrameworkContext['agentToolLoop'] extends infer Options ? Options extends {
|
|
1111
|
-
contextCompaction?: infer ContextCompaction;
|
|
1112
|
-
} ? ContextCompaction : never : never;
|
|
1113
|
-
}
|
|
1114
|
-
/** Data passed to AgentStart hooks. */
|
|
1115
|
-
interface AgentStartData extends Record<string, unknown> {
|
|
1116
|
-
conversationId: string;
|
|
1117
|
-
definitionId?: string;
|
|
1118
|
-
}
|
|
1119
|
-
/** Data passed to AgentStop hooks. */
|
|
1120
|
-
interface AgentStopData extends Record<string, unknown> {
|
|
1121
|
-
conversationId: string;
|
|
1122
|
-
reason: 'completed' | 'cancelled' | 'max-iterations' | 'error';
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
type LoadAgentToolLoopScriptOptions$1 = AgentLoopScriptPolicy;
|
|
1126
|
-
type AgentToolLoopScriptReference$1 = AgentLoopScriptReference;
|
|
1127
|
-
interface AgentToolLoopContext extends AgentFrameworkContext {
|
|
1128
|
-
profile?: LoopProfile;
|
|
1129
|
-
runtime?: Partial<AgentLoopRuntime>;
|
|
1130
|
-
script?: AgentToolLoopScript;
|
|
1131
|
-
loadScript?: (script: AgentToolLoopScriptReference$1, context: AgentToolLoopContext) => AgentToolLoopScript | Promise<AgentToolLoopScript>;
|
|
1132
|
-
scriptPolicy?: LoadAgentToolLoopScriptOptions$1;
|
|
1133
|
-
}
|
|
1134
|
-
interface AgentToolLoopState {
|
|
1135
|
-
iteration: number;
|
|
1136
|
-
maxIterations: number;
|
|
1137
|
-
recentToolCalls: string[];
|
|
1138
|
-
agentStarted: boolean;
|
|
1139
|
-
agentStopped: boolean;
|
|
1140
|
-
stopReason?: AgentStopData['reason'];
|
|
1141
|
-
}
|
|
1142
|
-
interface AgentToolLoopTurnStartResult {
|
|
1143
|
-
action: 'continue' | 'stop';
|
|
1144
|
-
step?: AgentLoopStep;
|
|
1145
|
-
}
|
|
1146
|
-
interface AgentToolLoopIterationResult {
|
|
1147
|
-
action: 'continue' | 'stop';
|
|
1148
|
-
reason?: AgentStopData['reason'];
|
|
1149
|
-
}
|
|
1150
|
-
type AgentToolLoopIterationGenerator = AsyncGenerator<AgentLoopStep, AgentToolLoopIterationResult, void>;
|
|
1151
|
-
interface AgentToolLoopScriptContext {
|
|
1152
|
-
/** The host turn input. `input.message` is the user prompt for this turn. */
|
|
1153
|
-
input: AgentLoopInput;
|
|
1154
|
-
/** Full host context for advanced integrations. Prefer the primitive helpers below. */
|
|
1155
|
-
context: AgentToolLoopContext;
|
|
1156
|
-
/** Active profile selected by the registry/runtime. */
|
|
1157
|
-
profile?: LoopProfile;
|
|
1158
|
-
/** Create mutable loop state for one turn. Scripts can store it in checkpoints if they implement resume. */
|
|
1159
|
-
createState: () => AgentToolLoopState;
|
|
1160
|
-
/** Persist the user turn and run pre-agent hooks. Returns a blocking step when a hook stops the turn. */
|
|
1161
|
-
startTurn: (state: AgentToolLoopState) => Promise<AgentToolLoopTurnStartResult>;
|
|
1162
|
-
/** Run exactly one LLM/tool iteration. The script owns the surrounding loop policy. */
|
|
1163
|
-
runIteration: (state: AgentToolLoopState) => AgentToolLoopIterationGenerator;
|
|
1164
|
-
/** Run AgentStop hooks once. Pass a reason when stopping because of an error outside `runIteration`. */
|
|
1165
|
-
stopTurn: (state: AgentToolLoopState, reason?: AgentStopData['reason']) => Promise<void>;
|
|
1166
|
-
/** Emit a raw loop step upstream. */
|
|
1167
|
-
emit: (step: AgentLoopStep) => void;
|
|
1168
|
-
/** Emit a user-visible message or step. */
|
|
1169
|
-
finish: (message: string | AgentLoopStep) => void;
|
|
1170
|
-
/** True when host cancellation has been requested for this conversation. */
|
|
1171
|
-
isCancelled: () => boolean;
|
|
1172
|
-
/** Write an observability event through the runtime and host logger. */
|
|
1173
|
-
log: (event: string, data?: Record<string, unknown>) => void;
|
|
1174
|
-
}
|
|
1175
|
-
type AgentToolLoopScriptResult = AgentLoopGenerator | AgentLoopStep | AgentLoopStep[] | string | undefined;
|
|
1176
|
-
type AgentToolLoopScript = (scriptContext: AgentToolLoopScriptContext) => AgentToolLoopScriptResult | Promise<AgentToolLoopScriptResult>;
|
|
1177
|
-
|
|
1178
|
-
declare function createAgentToolLoopRunner(context: AgentFrameworkContext): (input: AgentLoopInput) => AgentLoopGenerator;
|
|
1179
|
-
declare function createAgentToolLoopDefinition(name?: string): AgentLoopDefinition;
|
|
1180
|
-
|
|
1181
|
-
/**
|
|
1182
|
-
* AgentToolLoop runner — convenience API for driving a full loop turn.
|
|
1183
|
-
*/
|
|
1184
|
-
|
|
1185
|
-
interface RunAgentToolLoopTurnCallbacks {
|
|
1186
|
-
onStep?: (step: AgentLoopStep) => void | Promise<void>;
|
|
1187
|
-
onProgress?: (status: string, data: Record<string, unknown>, step: AgentLoopStep) => void | Promise<void>;
|
|
1188
|
-
agentToolLoop?: (input: AgentLoopInput) => AgentLoopGenerator;
|
|
1189
|
-
}
|
|
1190
|
-
interface RunAgentToolLoopTurnResult {
|
|
1191
|
-
state: AgentInstanceState;
|
|
1192
|
-
stepCount: number;
|
|
1193
|
-
}
|
|
1194
|
-
declare function resolveAgentToolLoopTerminalState(step: AgentLoopStep, current: AgentInstanceState): AgentInstanceState;
|
|
1195
|
-
declare function runAgentToolLoopTurn(context: AgentFrameworkContext, input: AgentLoopInput, callbacks?: RunAgentToolLoopTurnCallbacks): Promise<RunAgentToolLoopTurnResult>;
|
|
1196
|
-
|
|
1197
|
-
type LoadAgentToolLoopScriptOptions = AgentLoopScriptPolicy;
|
|
1198
|
-
type AgentToolLoopScriptReference = AgentLoopScriptReference;
|
|
1199
|
-
declare function loadAgentToolLoopScript(scriptReference: AgentToolLoopScriptReference, options?: LoadAgentToolLoopScriptOptions): Promise<AgentToolLoopScript>;
|
|
1200
|
-
|
|
1201
|
-
/**
|
|
1202
|
-
* Built-in loop registrations — installed at startup so getLoopRegistry().createRunner('agent-tool-loop') works.
|
|
1203
|
-
*
|
|
1204
|
-
* This module allows hosts to skip manual registerLoop() for the built-in loop types.
|
|
1205
|
-
* Hosts can still override by calling registerLoop() with the same id after.
|
|
1206
|
-
*/
|
|
1207
|
-
declare const AGENT_TOOL_LOOP_ID = "agent-tool-loop";
|
|
1208
|
-
declare const AGENT_AGENT_LOOP_ID: string;
|
|
1209
|
-
/**
|
|
1210
|
-
* Register the default built-in loops (agent-tool-loop and agent-agent-loop) with the loop registry.
|
|
1211
|
-
* Safe to call multiple times — skips already-registered loops.
|
|
1212
|
-
*/
|
|
1213
|
-
declare function registerBuiltinLoops(): void;
|
|
1214
|
-
|
|
1215
|
-
/**
|
|
1216
|
-
* Builtin tool plugins — registers core tools as LoopPlugin entries.
|
|
1217
|
-
*
|
|
1218
|
-
* Each tool is a separate LoopPlugin that can be overridden by user/host plugins
|
|
1219
|
-
* with the same id. The plugin.install callback calls the tool registry to
|
|
1220
|
-
* register the tool implementation.
|
|
1221
|
-
*
|
|
1222
|
-
* These are registered in the loop registry at startup and loaded by
|
|
1223
|
-
* `registerBuiltinTools` via plugin discovery.
|
|
1224
|
-
*/
|
|
1225
|
-
|
|
1226
|
-
declare const PLUGIN_MCP_CLIENT = "builtin:mcp-client";
|
|
1227
|
-
declare const PLUGIN_MCP_FORWARD = "builtin:mcp-forward";
|
|
1228
|
-
declare const PLUGIN_SPAWN_AGENT = "builtin:spawn-agent";
|
|
1229
|
-
declare const PLUGIN_REMOTE_AGENT = "builtin:remote-agent";
|
|
1230
|
-
declare const PLUGIN_ASK_QUESTION = "builtin:ask-question";
|
|
1231
|
-
declare const PLUGIN_TODO_WRITE = "builtin:todo-write";
|
|
1232
|
-
declare const PLUGIN_ASK_USER_QUESTION = "builtin:ask-user-question";
|
|
1233
|
-
declare const PLUGIN_TASK = "builtin:task";
|
|
1234
|
-
declare const BUILTIN_TOOL_PLUGIN_IDS: readonly ["builtin:mcp-client", "builtin:mcp-forward", "builtin:spawn-agent", "builtin:remote-agent", "builtin:ask-question", "builtin:todo-write", "builtin:ask-user-question", "builtin:task"];
|
|
1235
|
-
declare function getBuiltinToolPlugins(): LoopPlugin[];
|
|
1236
|
-
/** Register all builtin tool plugins with the loop registry. */
|
|
1237
|
-
declare function registerBuiltinToolPlugins(): void;
|
|
1238
|
-
|
|
1239
|
-
/**
|
|
1240
|
-
* Agent loop registry.
|
|
1241
|
-
*
|
|
1242
|
-
* Discovers, registers, and resolves loop types, loop profiles, and loop plugins.
|
|
1243
|
-
* Core does NOT hard-import any loop implementation; all are registered by host or plugin.
|
|
1244
|
-
*/
|
|
1245
|
-
|
|
1246
|
-
type LoopPluginSelection = string | LoopProfilePluginEntry;
|
|
1247
|
-
declare class LoopRegistryImpl {
|
|
1248
|
-
private readonly loops;
|
|
1249
|
-
private readonly profiles;
|
|
1250
|
-
private readonly plugins;
|
|
1251
|
-
registerLoop(definition: AgentLoopDefinition): void;
|
|
1252
|
-
getLoop(id: string): AgentLoopDefinition | undefined;
|
|
1253
|
-
listLoops(): AgentLoopDefinition[];
|
|
1254
|
-
registerProfile(profile: LoopProfile): void;
|
|
1255
|
-
getProfile(id: string): LoopProfile | undefined;
|
|
1256
|
-
listProfiles(): LoopProfile[];
|
|
1257
|
-
registerPlugin(plugin: LoopPlugin): void;
|
|
1258
|
-
getPlugin(id: string): LoopPlugin | undefined;
|
|
1259
|
-
listPlugins(): LoopPlugin[];
|
|
1260
|
-
installPluginsForLoop(loopId: string, target: {
|
|
1261
|
-
[key: string]: unknown;
|
|
1262
|
-
}, selected?: LoopPluginSelection[]): void;
|
|
1263
|
-
installPluginsForProfile(profile: LoopProfile, target: {
|
|
1264
|
-
[key: string]: unknown;
|
|
1265
|
-
}): void;
|
|
1266
|
-
createRunnerForProfile(profile: LoopProfile, context?: {
|
|
1267
|
-
[key: string]: unknown;
|
|
1268
|
-
}): ((input: AgentLoopInput) => AgentLoopGenerator) | null;
|
|
1269
|
-
createRunner(loopId: string, context?: {
|
|
1270
|
-
[key: string]: unknown;
|
|
1271
|
-
}): ((input: AgentLoopInput) => AgentLoopGenerator) | null;
|
|
1272
|
-
reset(): void;
|
|
1273
|
-
}
|
|
1274
|
-
declare function getLoopRegistry(): LoopRegistryImpl;
|
|
1275
|
-
declare function resetLoopRegistry(): void;
|
|
1276
|
-
|
|
1277
|
-
interface TokenTrackerConfig {
|
|
1278
|
-
/** Maximum context window in tokens (default: 200000) */
|
|
1279
|
-
contextWindow?: number;
|
|
1280
|
-
/** Trigger compaction when usage exceeds this fraction (default: 0.90) */
|
|
1281
|
-
compactionThreshold?: number;
|
|
1282
|
-
/** Buffer tokens reserved for output (default: 16000) */
|
|
1283
|
-
outputBuffer?: number;
|
|
1284
|
-
}
|
|
1285
|
-
interface TokenUsage {
|
|
1286
|
-
promptTokens: number;
|
|
1287
|
-
completionTokens: number;
|
|
1288
|
-
totalTokens: number;
|
|
1289
|
-
contextWindow: number;
|
|
1290
|
-
usagePercent: number;
|
|
1291
|
-
shouldCompact: boolean;
|
|
1292
|
-
}
|
|
1293
|
-
/**
|
|
1294
|
-
* Tracks token usage and decides when to trigger auto-compaction.
|
|
1295
|
-
*/
|
|
1296
|
-
declare class TokenTracker {
|
|
1297
|
-
private promptTokens;
|
|
1298
|
-
private completionTokens;
|
|
1299
|
-
private readonly contextWindow;
|
|
1300
|
-
private readonly compactionThreshold;
|
|
1301
|
-
private readonly outputBuffer;
|
|
1302
|
-
private compacting;
|
|
1303
|
-
private consecutiveCompactionFailures;
|
|
1304
|
-
private maxConsecutiveFailures;
|
|
1305
|
-
constructor(config?: TokenTrackerConfig);
|
|
1306
|
-
/** Record token usage from an LLM response */
|
|
1307
|
-
recordUsage(promptTokens: number, completionTokens: number): void;
|
|
1308
|
-
/** Manually set the prompt token count (e.g., from estimation) */
|
|
1309
|
-
setPromptTokens(tokens: number): void;
|
|
1310
|
-
/** Get current usage */
|
|
1311
|
-
getUsage(): TokenUsage;
|
|
1312
|
-
/** Check if auto-compaction should be triggered */
|
|
1313
|
-
shouldTriggerCompaction(): boolean;
|
|
1314
|
-
/** Mark that compaction is starting */
|
|
1315
|
-
markCompactionStart(): void;
|
|
1316
|
-
/** Mark that compaction succeeded — reset token counts */
|
|
1317
|
-
markCompactionSuccess(estimatedPostTokens: number): void;
|
|
1318
|
-
/** Mark that compaction failed */
|
|
1319
|
-
markCompactionFailure(): void;
|
|
1320
|
-
/** Reset all counters */
|
|
1321
|
-
reset(): void;
|
|
1322
|
-
/** Get a human-readable summary */
|
|
1323
|
-
formatUsage(): string;
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
interface CreateAgentOptions {
|
|
1327
|
-
definitionId: string;
|
|
1328
|
-
initialMessage?: string;
|
|
1329
|
-
}
|
|
1330
|
-
interface SendMessageOptions {
|
|
1331
|
-
conversationId: string;
|
|
1332
|
-
message: string;
|
|
1333
|
-
definitionId?: string;
|
|
1334
|
-
userMessage?: AgentLoopInput['userMessage'];
|
|
1335
|
-
resumeSession?: ChatMessage[];
|
|
1336
|
-
}
|
|
1337
|
-
interface MemeLoopRuntime {
|
|
1338
|
-
createAgent(options: CreateAgentOptions): Promise<{
|
|
1339
|
-
conversationId: string;
|
|
1340
|
-
}>;
|
|
1341
|
-
sendMessage(options: SendMessageOptions): Promise<void>;
|
|
1342
|
-
cancelAgent(conversationId: string): Promise<void>;
|
|
1343
|
-
subscribeToUpdates(conversationId: string, listener: (update: unknown) => void): () => void;
|
|
1344
|
-
}
|
|
1345
|
-
interface CreateAgentLoopRunnerOptions {
|
|
1346
|
-
definitionId: string;
|
|
1347
|
-
conversationId?: string;
|
|
1348
|
-
}
|
|
1349
|
-
declare function createAgentLoopRunner(context: AgentFrameworkContext, options: CreateAgentLoopRunnerOptions): Promise<((input: AgentLoopInput) => AgentLoopGenerator) | null>;
|
|
1350
|
-
declare function createMemeLoopRuntime(context: AgentFrameworkContext): MemeLoopRuntime;
|
|
1351
|
-
|
|
1352
|
-
/**
|
|
1353
|
-
* Built-in Loop Profiles.
|
|
1354
|
-
*
|
|
1355
|
-
* Each profile defines which agent loop to run, which .mjs script to load,
|
|
1356
|
-
* which prompts, plugins, and hook plugins to enable.
|
|
1357
|
-
*
|
|
1358
|
-
* Replaces the old `src/prompt/loadBuiltins.ts`.
|
|
1359
|
-
*/
|
|
1360
|
-
|
|
1361
|
-
/** Get all built-in Loop Profiles. */
|
|
1362
|
-
declare function getBuiltinLoopProfiles(): LoopProfile[];
|
|
1363
|
-
/** Get a built-in Loop Profile by id. */
|
|
1364
|
-
declare function getBuiltinLoopProfile(id: string): LoopProfile | undefined;
|
|
1365
|
-
/** Register bundled profiles with the global loop registry. */
|
|
1366
|
-
declare function registerBuiltinLoopProfiles(): void;
|
|
1367
|
-
|
|
1368
|
-
/**
|
|
1369
|
-
* Extended agent definition used by the agent profile registry.
|
|
1370
|
-
* Wraps the protocol-level AgentDefinition with additional runtime metadata.
|
|
1371
|
-
*/
|
|
1372
|
-
interface AgentProfile {
|
|
1373
|
-
/** Unique ID for this agent (matches protocol id convention like "memeloop:build") */
|
|
1374
|
-
id: string;
|
|
1375
|
-
/** Display name */
|
|
1376
|
-
name: string;
|
|
1377
|
-
/** Agent type / role */
|
|
1378
|
-
type: AgentProfileType;
|
|
1379
|
-
/** System prompt / instructions for the agent */
|
|
1380
|
-
prompt: string;
|
|
1381
|
-
/** Tool permission rules (mutually exclusive with permissive defaults) */
|
|
1382
|
-
permissions: ToolPermissionRules;
|
|
1383
|
-
/** Optional model override (provider/model string) */
|
|
1384
|
-
model?: string;
|
|
1385
|
-
/** Underlying protocol-compatible definition for framework integration */
|
|
1386
|
-
protocolDef: AgentDefinition;
|
|
1387
|
-
}
|
|
1388
|
-
type AgentProfileType = 'build' | 'plan' | 'explore' | 'oracle' | 'librarian';
|
|
1389
|
-
interface ToolPermissionRules {
|
|
1390
|
-
/** Default action for tools not matching any rule */
|
|
1391
|
-
default: 'allow' | 'ask' | 'deny';
|
|
1392
|
-
/** Per-tool or wildcard rules */
|
|
1393
|
-
rules: Array<{
|
|
1394
|
-
pattern: string;
|
|
1395
|
-
action: 'allow' | 'ask' | 'deny';
|
|
1396
|
-
}>;
|
|
1397
|
-
}
|
|
1398
|
-
/**
|
|
1399
|
-
* Build agent: full access, default model.
|
|
1400
|
-
* Primary agent for executing tasks, writing code, running commands.
|
|
1401
|
-
*/
|
|
1402
|
-
declare const buildAgent: AgentProfile;
|
|
1403
|
-
/**
|
|
1404
|
-
* Plan agent: read-only, denies file edits and terminal execution.
|
|
1405
|
-
* Used for high-level planning and task decomposition.
|
|
1406
|
-
*/
|
|
1407
|
-
declare const planAgent: AgentProfile;
|
|
1408
|
-
/**
|
|
1409
|
-
* Explore agent: read + search tools only.
|
|
1410
|
-
* Fast search and codebase exploration without modification.
|
|
1411
|
-
*/
|
|
1412
|
-
declare const exploreAgent: AgentProfile;
|
|
1413
|
-
/**
|
|
1414
|
-
* Oracle agent: read-only, for architecture consultation and code review.
|
|
1415
|
-
*/
|
|
1416
|
-
declare const oracleAgent: AgentProfile;
|
|
1417
|
-
/**
|
|
1418
|
-
* Librarian agent: read + web search tools only.
|
|
1419
|
-
* External documentation lookup and context gathering.
|
|
1420
|
-
*/
|
|
1421
|
-
declare const librarianAgent: AgentProfile;
|
|
1422
|
-
/** Built-in agent profiles used by the task delegation tool. */
|
|
1423
|
-
declare const BUILTIN_AGENT_PROFILES: AgentProfile[];
|
|
1424
|
-
|
|
1425
|
-
/**
|
|
1426
|
-
* Registry for agent profiles used by task delegation.
|
|
1427
|
-
* Pre-seeded with built-in profiles (build, plan, explore, oracle, librarian).
|
|
1428
|
-
*/
|
|
1429
|
-
declare class AgentProfileRegistry {
|
|
1430
|
-
private readonly profiles;
|
|
1431
|
-
constructor();
|
|
1432
|
-
/** Seed the registry with built-in agent profiles. */
|
|
1433
|
-
private seedDefaults;
|
|
1434
|
-
/**
|
|
1435
|
-
* Register a new agent profile or override an existing one.
|
|
1436
|
-
* Throws if the profile is invalid.
|
|
1437
|
-
*/
|
|
1438
|
-
registerAgentProfile(profile: AgentProfile): void;
|
|
1439
|
-
/**
|
|
1440
|
-
* Get an agent profile by ID.
|
|
1441
|
-
* Returns undefined if not found.
|
|
1442
|
-
*/
|
|
1443
|
-
getAgentProfile(id: string): AgentProfile | undefined;
|
|
1444
|
-
/**
|
|
1445
|
-
* List all registered agent profiles.
|
|
1446
|
-
*/
|
|
1447
|
-
listAgentProfiles(): AgentProfile[];
|
|
1448
|
-
/**
|
|
1449
|
-
* List agent profiles filtered by type.
|
|
1450
|
-
*/
|
|
1451
|
-
listAgentProfilesByType(type: AgentProfileType): AgentProfile[];
|
|
1452
|
-
/**
|
|
1453
|
-
* Remove an agent profile by ID.
|
|
1454
|
-
*/
|
|
1455
|
-
unregisterAgentProfile(id: string): boolean;
|
|
1456
|
-
/**
|
|
1457
|
-
* Reset the registry to only built-in defaults.
|
|
1458
|
-
*/
|
|
1459
|
-
reset(): void;
|
|
1460
|
-
}
|
|
1461
|
-
declare function getAgentProfileRegistry(): AgentProfileRegistry;
|
|
1462
|
-
declare function resetAgentProfileRegistry(): void;
|
|
1463
|
-
|
|
1464
|
-
/**
|
|
1465
|
-
* Task category system for routing tasks to appropriate agent configurations.
|
|
1466
|
-
* Each category maps to a model, temperature, and description for delegation decisions.
|
|
1467
|
-
*/
|
|
1468
|
-
type TaskCategory = 'visual-engineering' | 'ultrabrain' | 'artistry' | 'quick' | 'unspecified-low' | 'unspecified-high' | 'writing';
|
|
1469
|
-
interface CategoryConfig {
|
|
1470
|
-
/** Model identifier (e.g., "default", "gpt-4o", "claude-opus") */
|
|
1471
|
-
model: string;
|
|
1472
|
-
/** LLM temperature (0.0 = deterministic, 1.0 = creative) */
|
|
1473
|
-
temperature: number;
|
|
1474
|
-
/** Human-readable description of the category's purpose */
|
|
1475
|
-
description: string;
|
|
1476
|
-
}
|
|
1477
|
-
/**
|
|
1478
|
-
* Get the configuration for a task category.
|
|
1479
|
-
* @throws {Error} if the category is unknown
|
|
1480
|
-
*/
|
|
1481
|
-
declare function getCategoryConfig(category: TaskCategory): CategoryConfig;
|
|
1482
|
-
/**
|
|
1483
|
-
* Type guard: check if a string is a valid TaskCategory.
|
|
1484
|
-
*/
|
|
1485
|
-
declare function isTaskCategory(value: string): value is TaskCategory;
|
|
1486
|
-
/** All registered category identifiers (read-only). */
|
|
1487
|
-
declare const ALL_CATEGORIES: TaskCategory[];
|
|
1488
|
-
/**
|
|
1489
|
-
* Resolve a category string (or fallback to "unspecified-low").
|
|
1490
|
-
* Never throws; always returns a valid config.
|
|
1491
|
-
*/
|
|
1492
|
-
declare function resolveCategory(category: string): CategoryConfig;
|
|
1493
|
-
|
|
1494
|
-
interface ProviderConfig {
|
|
1495
|
-
name: string;
|
|
1496
|
-
baseUrl?: string;
|
|
1497
|
-
apiKey?: string;
|
|
1498
|
-
}
|
|
1499
|
-
interface RegisteredProvider {
|
|
1500
|
-
provider: ILLMProvider;
|
|
1501
|
-
config: ProviderConfig;
|
|
1502
|
-
}
|
|
1503
|
-
declare class ProviderRegistry {
|
|
1504
|
-
private providers;
|
|
1505
|
-
register(provider: ILLMProvider, config?: Omit<ProviderConfig, 'name'>): void;
|
|
1506
|
-
unregister(name: string): void;
|
|
1507
|
-
get(name: string): ILLMProvider | undefined;
|
|
1508
|
-
getConfig(name: string): ProviderConfig | undefined;
|
|
1509
|
-
upsertConfig(config: ProviderConfig): void;
|
|
1510
|
-
list(): string[];
|
|
1511
|
-
listConfigs(): ProviderConfig[];
|
|
1512
|
-
resolve(modelId: string): {
|
|
1513
|
-
provider: ILLMProvider;
|
|
1514
|
-
providerName: string;
|
|
1515
|
-
modelName?: string;
|
|
1516
|
-
};
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
/**
|
|
1520
|
-
* Hook registry for managing lifecycle hook handlers.
|
|
1521
|
-
* Hooks execute in registration order (first registered, first executed).
|
|
1522
|
-
*
|
|
1523
|
-
* Converted from module-level singletons to an instance class for test isolation
|
|
1524
|
-
* and multi-runtime support. Backward-compatible function exports delegate to a
|
|
1525
|
-
* default global instance.
|
|
1526
|
-
*/
|
|
1527
|
-
|
|
1528
|
-
/**
|
|
1529
|
-
* Instance-level hook registry. Each instance maintains its own handler state.
|
|
1530
|
-
*/
|
|
1531
|
-
declare class HookRegistry {
|
|
1532
|
-
private readonly hookRegistry;
|
|
1533
|
-
private readonly hookOrder;
|
|
1534
|
-
/**
|
|
1535
|
-
* Register a hook handler for a specific lifecycle event.
|
|
1536
|
-
*/
|
|
1537
|
-
registerHook(type: HookType, handler: HookHandler, name?: string): void;
|
|
1538
|
-
/**
|
|
1539
|
-
* Unregister a specific hook handler by name.
|
|
1540
|
-
*/
|
|
1541
|
-
unregisterHook(type: HookType, name: string): boolean;
|
|
1542
|
-
/**
|
|
1543
|
-
* Execute all registered hooks for a given type in registration order.
|
|
1544
|
-
*/
|
|
1545
|
-
executeHooks(type: HookType, context: HookContext, data: Record<string, unknown>): Promise<HookResult>;
|
|
1546
|
-
/**
|
|
1547
|
-
* Check if any hooks are registered for a given type.
|
|
1548
|
-
*/
|
|
1549
|
-
hasHooks(type: HookType): boolean;
|
|
1550
|
-
/**
|
|
1551
|
-
* Remove all registered hooks of all types.
|
|
1552
|
-
*/
|
|
1553
|
-
clearHooks(): void;
|
|
1554
|
-
/**
|
|
1555
|
-
* List all hook types that have at least one registered handler.
|
|
1556
|
-
*/
|
|
1557
|
-
listRegisteredHookTypes(): HookType[];
|
|
1558
|
-
/**
|
|
1559
|
-
* Get the count of registered handlers for a hook type.
|
|
1560
|
-
*/
|
|
1561
|
-
getHookCount(type: HookType): number;
|
|
1562
|
-
}
|
|
1563
|
-
declare function getDefaultHookRegistry(): HookRegistry;
|
|
1564
|
-
declare function registerHook(type: HookType, handler: HookHandler, name?: string): void;
|
|
1565
|
-
declare function unregisterHook(type: HookType, name: string): boolean;
|
|
1566
|
-
declare function executeHooks(type: HookType, context: HookContext, data: Record<string, unknown>): Promise<HookResult>;
|
|
1567
|
-
declare function hasHooks(type: HookType): boolean;
|
|
1568
|
-
declare function clearHooks(): void;
|
|
1569
|
-
declare function listRegisteredHookTypes(): HookType[];
|
|
1570
|
-
/**
|
|
1571
|
-
* Get the count of registered handlers for a hook type.
|
|
1572
|
-
*/
|
|
1573
|
-
declare function getHookCount(type: HookType): number;
|
|
1574
|
-
|
|
1575
|
-
/**
|
|
1576
|
-
* Test whether a tool name matches a wildcard pattern.
|
|
1577
|
-
*
|
|
1578
|
-
* Supported patterns:
|
|
1579
|
-
* - `*` → matches everything
|
|
1580
|
-
* - `file.*` → matches any tool starting with `file.`
|
|
1581
|
-
* - `shell(*)` → matches tools like `shell(rm)`, `shell(ls)` (literal parens)
|
|
1582
|
-
* - exact name → matches only that exact tool name
|
|
1583
|
-
*
|
|
1584
|
-
* Patterns are converted to anchored regexes internally.
|
|
1585
|
-
*/
|
|
1586
|
-
declare function matchPattern(toolName: string, pattern: string): boolean;
|
|
1587
|
-
/**
|
|
1588
|
-
* Merge multiple permission sets from lowest to highest priority.
|
|
1589
|
-
*
|
|
1590
|
-
* Sets are processed in order; later rules override earlier ones for the same tool pattern.
|
|
1591
|
-
* Within a single set, rules are processed in order (last wins).
|
|
1592
|
-
*
|
|
1593
|
-
* @param sets - Ordered from lowest to highest priority (e.g. default → agent → user → session)
|
|
1594
|
-
* @returns Flattened `MergedPermissions` with all unique patterns per action.
|
|
1595
|
-
*/
|
|
1596
|
-
declare function mergePermissionSets(sets: PermissionSet[]): MergedPermissions;
|
|
1597
|
-
/**
|
|
1598
|
-
* Check what action applies to a given tool name under merged permissions.
|
|
1599
|
-
*
|
|
1600
|
-
* Precedence: exact patterns always beat wildcards.
|
|
1601
|
-
* Within same specificity: deny > ask > allow.
|
|
1602
|
-
*/
|
|
1603
|
-
declare function checkPermission(toolName: string, merged: MergedPermissions): PermissionAction;
|
|
1604
|
-
|
|
1605
|
-
interface PermissionSqlStatement {
|
|
1606
|
-
get(...arguments_: unknown[]): unknown;
|
|
1607
|
-
run(...arguments_: unknown[]): unknown;
|
|
1608
|
-
}
|
|
1609
|
-
interface PermissionSqlDatabase {
|
|
1610
|
-
prepare(sql: string): PermissionSqlStatement;
|
|
1611
|
-
}
|
|
1612
|
-
/**
|
|
1613
|
-
* Load user-level permission set from SQLite.
|
|
1614
|
-
*
|
|
1615
|
-
* The `permissions` table stores JSON blobs keyed by `source`.
|
|
1616
|
-
* Returns an empty set if no persisted rules exist.
|
|
1617
|
-
*/
|
|
1618
|
-
declare function loadUserPermissions(database: PermissionSqlDatabase): PermissionSet;
|
|
1619
|
-
/**
|
|
1620
|
-
* Persist user-level permission set to SQLite.
|
|
1621
|
-
*
|
|
1622
|
-
* Uses INSERT OR REPLACE so first-time saves work without explicit table detection.
|
|
1623
|
-
*/
|
|
1624
|
-
declare function saveUserPermissions(database: PermissionSqlDatabase, set: PermissionSet): void;
|
|
1625
|
-
/** SQL statement to create the permissions table during migration. */
|
|
1626
|
-
declare const PERMISSIONS_TABLE_DDL = "\n CREATE TABLE IF NOT EXISTS permissions (\n source TEXT PRIMARY KEY,\n rulesJson TEXT NOT NULL,\n updatedAt INTEGER NOT NULL\n );\n";
|
|
1627
|
-
|
|
1628
|
-
/**
|
|
1629
|
-
* Plugin marketplace architecture types.
|
|
1630
|
-
* Plugins can provide tools and hooks to extend memeloop.
|
|
1631
|
-
*/
|
|
1632
|
-
|
|
1633
|
-
/**
|
|
1634
|
-
* Plugin manifest schema.
|
|
1635
|
-
* Host adapters may read this from files or construct it programmatically.
|
|
1636
|
-
*/
|
|
1637
|
-
interface PluginManifest {
|
|
1638
|
-
/** Unique plugin identifier (e.g. "plugin-hello", "@scope/my-plugin") */
|
|
1639
|
-
name: string;
|
|
1640
|
-
/** Semantic version */
|
|
1641
|
-
version: string;
|
|
1642
|
-
/** Human-readable description */
|
|
1643
|
-
description: string;
|
|
1644
|
-
/** Declared exports: what the plugin provides */
|
|
1645
|
-
exports?: PluginExports;
|
|
1646
|
-
/** Plugin author */
|
|
1647
|
-
author?: string;
|
|
1648
|
-
/** Minimum memeloop version requirement (semver range) */
|
|
1649
|
-
minMemeloopVersion?: string;
|
|
1650
|
-
}
|
|
1651
|
-
/** Declared capabilities a plugin may export. */
|
|
1652
|
-
interface PluginExports {
|
|
1653
|
-
/** Tool IDs this plugin implements */
|
|
1654
|
-
tools?: string[];
|
|
1655
|
-
/** Hook types this plugin listens for */
|
|
1656
|
-
hooks?: HookType[];
|
|
1657
|
-
}
|
|
1658
|
-
/**
|
|
1659
|
-
* Shape of a loaded plugin module's default export.
|
|
1660
|
-
* Plugins must export default an object conforming to this interface.
|
|
1661
|
-
*/
|
|
1662
|
-
interface PluginModule {
|
|
1663
|
-
/** Plugin identity (must match manifest name) */
|
|
1664
|
-
name: string;
|
|
1665
|
-
/**
|
|
1666
|
-
* Called when the plugin is loaded. Receives the PluginAPI for registering
|
|
1667
|
-
* tools and hooks. Return a cleanup function for teardown.
|
|
1668
|
-
*/
|
|
1669
|
-
activate: (api: PluginAPI) => (() => void) | Promise<() => void> | undefined;
|
|
1670
|
-
}
|
|
1671
|
-
/**
|
|
1672
|
-
* API surface exposed to plugins. Plugins call these methods in their
|
|
1673
|
-
* `activate` function to register their capabilities.
|
|
1674
|
-
*/
|
|
1675
|
-
interface PluginAPI {
|
|
1676
|
-
/**
|
|
1677
|
-
* Register a tool implementation.
|
|
1678
|
-
* @param toolId - Unique tool ID (e.g. "plugin-hello.sayHi")
|
|
1679
|
-
* @param impl - Tool implementation function
|
|
1680
|
-
* @param schema - Optional parameter schema (Zod type)
|
|
1681
|
-
*/
|
|
1682
|
-
registerTool(toolId: string, impl: (...arguments_: unknown[]) => unknown, schema?: unknown): void;
|
|
1683
|
-
/**
|
|
1684
|
-
* Register a lifecycle hook handler.
|
|
1685
|
-
* @param type - Hook event type
|
|
1686
|
-
* @param handler - Async handler function
|
|
1687
|
-
* @param name - Optional handler name (enables dedup/unregistration)
|
|
1688
|
-
*/
|
|
1689
|
-
registerHook(type: HookType, handler: HookHandler, name?: string): void;
|
|
1690
|
-
/** Log to memeloop's logger (falls back to console). */
|
|
1691
|
-
logger: {
|
|
1692
|
-
debug: (message: string, ...arguments_: unknown[]) => void;
|
|
1693
|
-
info: (message: string, ...arguments_: unknown[]) => void;
|
|
1694
|
-
warn: (message: string, ...arguments_: unknown[]) => void;
|
|
1695
|
-
error: (message: string, ...arguments_: unknown[]) => void;
|
|
1696
|
-
};
|
|
1697
|
-
}
|
|
1698
|
-
/** Metadata about a loaded plugin instance. */
|
|
1699
|
-
interface LoadedPlugin {
|
|
1700
|
-
/** Manifest data */
|
|
1701
|
-
manifest: PluginManifest;
|
|
1702
|
-
/** Optional host-provided source identifier, e.g. package name or file path. */
|
|
1703
|
-
source: string;
|
|
1704
|
-
/** The loaded plugin module */
|
|
1705
|
-
module: PluginModule;
|
|
1706
|
-
/** Cleanup function returned by activate(), if any */
|
|
1707
|
-
cleanup: (() => void) | undefined;
|
|
1708
|
-
/** When the plugin was loaded */
|
|
1709
|
-
loadedAt: Date;
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
declare function validatePluginManifest(object: unknown): PluginManifest | null;
|
|
1713
|
-
interface LoadPluginModuleOptions {
|
|
1714
|
-
manifest: PluginManifest;
|
|
1715
|
-
module: PluginModule;
|
|
1716
|
-
api?: unknown;
|
|
1717
|
-
source?: string;
|
|
1718
|
-
}
|
|
1719
|
-
declare function loadPluginModule(options: LoadPluginModuleOptions): Promise<LoadedPlugin | null>;
|
|
1720
|
-
declare function loadPluginModules(plugins: LoadPluginModuleOptions[]): Promise<LoadedPlugin[]>;
|
|
1721
|
-
declare function unloadPlugin(name: string): boolean;
|
|
1722
|
-
declare function listPlugins(): LoadedPlugin[];
|
|
1723
|
-
declare function getLoadedPlugin(name: string): LoadedPlugin | undefined;
|
|
1724
|
-
declare function isPluginLoaded(name: string): boolean;
|
|
1725
|
-
declare function unloadAllPlugins(): void;
|
|
1726
|
-
|
|
1727
|
-
/**
|
|
1728
|
-
* Plugin registry: bridges plugin exports to memeloop's tool and hook registries.
|
|
1729
|
-
*
|
|
1730
|
-
* Provides a `createPluginAPI()` factory that plugins call during `activate()`
|
|
1731
|
-
* to register their tools and hooks with the host runtime.
|
|
1732
|
-
*
|
|
1733
|
-
* Converted from module-level singletons to an instance class for test isolation
|
|
1734
|
-
* and multi-runtime support.
|
|
1735
|
-
*/
|
|
1736
|
-
|
|
1737
|
-
/** Plugin API factory options. */
|
|
1738
|
-
interface PluginAPIOptions {
|
|
1739
|
-
toolRegistry?: {
|
|
1740
|
-
registerTool(id: string, impl: unknown): void;
|
|
1741
|
-
};
|
|
1742
|
-
logger?: PluginAPI['logger'];
|
|
1743
|
-
}
|
|
1744
|
-
/**
|
|
1745
|
-
* Track which tools/plugins belong to each plugin so we can clean up on unload.
|
|
1746
|
-
*/
|
|
1747
|
-
interface PluginRegistration {
|
|
1748
|
-
pluginName: string;
|
|
1749
|
-
tools: string[];
|
|
1750
|
-
hooks: Array<{
|
|
1751
|
-
type: HookType;
|
|
1752
|
-
name: string;
|
|
1753
|
-
}>;
|
|
1754
|
-
}
|
|
1755
|
-
declare function createPluginAPI(options?: PluginAPIOptions): PluginAPI;
|
|
1756
|
-
declare function registerPluginTools(pluginName: string, tools: Array<readonly [string, (...arguments_: unknown[]) => unknown, unknown?]>): void;
|
|
1757
|
-
declare function registerPluginHooks(pluginName: string, hooks: Array<readonly [HookType, HookHandler, string?]>): void;
|
|
1758
|
-
declare function getPluginRegistrations(pluginName: string): PluginRegistration | undefined;
|
|
1759
|
-
declare function clearPluginRegistrations(): void;
|
|
1760
|
-
|
|
1761
|
-
/**
|
|
1762
|
-
* 注册内置 prompt 插件(fullReplacement、dynamicPosition)。
|
|
1763
|
-
* @param target 若传入(如节点 `ToolRegistry` 上的 Map),只写入该表;否则写入活动注册表(全局或 ALS)。
|
|
1764
|
-
*/
|
|
1765
|
-
declare function registerBuiltinPromptPlugins(target?: Map<string, PromptConcatTool>): void;
|
|
1766
|
-
|
|
1767
|
-
/** 扁平化后的 LLM 消息(不依赖 peer `ai` 包导出,避免 d.ts 与 SDK 主版本不一致) */
|
|
1768
|
-
type PromptFlatModelMessage = {
|
|
1769
|
-
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
1770
|
-
content: unknown;
|
|
1771
|
-
};
|
|
1772
|
-
declare function findPromptById(prompts: PromptNode[], id: string): {
|
|
1773
|
-
prompt: PromptNode;
|
|
1774
|
-
parent: PromptNode[];
|
|
1775
|
-
index: number;
|
|
1776
|
-
} | undefined;
|
|
1777
|
-
declare function flattenPrompts(prompts: PromptNode[]): PromptFlatModelMessage[];
|
|
1778
|
-
interface PromptConcatPluginPreview {
|
|
1779
|
-
id: string;
|
|
1780
|
-
toolId?: string;
|
|
1781
|
-
caption?: string;
|
|
1782
|
-
}
|
|
1783
|
-
interface PromptConcatStreamState {
|
|
1784
|
-
processedPrompts: PromptNode[];
|
|
1785
|
-
flatPrompts: PromptFlatModelMessage[];
|
|
1786
|
-
step: 'flatten' | 'complete' | 'plugin' | 'finalize';
|
|
1787
|
-
isComplete: boolean;
|
|
1788
|
-
/** prompt 节点 id → JSON 路径(如 agentFrameworkConfig.prompts.0) */
|
|
1789
|
-
sourcePaths?: Record<string, string>;
|
|
1790
|
-
/** Desktop UI: plugin currently being processed. */
|
|
1791
|
-
currentPlugin?: PromptConcatPluginPreview;
|
|
1792
|
-
/** Desktop UI: progress value between 0 and 1. */
|
|
1793
|
-
progress?: number;
|
|
1794
|
-
}
|
|
1795
|
-
interface PromptConcatOptions {
|
|
1796
|
-
readAttachmentFile?: (path: string) => Promise<Uint8Array | Buffer>;
|
|
1797
|
-
}
|
|
1798
|
-
declare function promptConcatStream(agentConfig: Pick<AgentPromptDescription, 'agentFrameworkConfig'>, messages: ChatMessage[], agentFrameworkContext: AgentFrameworkContext, options?: PromptConcatOptions): AsyncGenerator<PromptConcatStreamState, PromptConcatStreamState, unknown>;
|
|
1799
|
-
|
|
1800
|
-
export { type AgentInstanceState as $, type AgentDefinition as A, type AgentAgentBatchRunResult as B, type ConversationMeta as C, type DefineToolAgentFrameworkContext as D, type AgentAgentConfigEntry as E, type AgentAgentContext as F, type GetMessagesOptions as G, type AgentAgentDescriptor as H, type IAgentStorage as I, type AgentAgentFormatResultsOptions as J, type AgentAgentLoopContext as K, type ListConversationsOptions as L, type MemeLoopRuntime as M, type AgentAgentLoopScript as N, type AgentAgentLoopScriptArguments as O, type PromptConcatTool as P, type AgentAgentLoopScriptReference as Q, type AgentAgentRunAgentFailure as R, type AgentAgentRunAgentInput as S, type ToolApprovalConfig as T, type AgentAgentRunAgentResult as U, type VersionVector as V, type AgentAgentScriptContext as W, type AgentDefinitionModelConfig as X, type AgentHeartbeatConfig as Y, type AgentInstanceModel as Z, type AgentInstanceLatestStatus as _, type ChatMessage as a, type ModelParameters as a$, type AgentLoopDefinition as a0, type AgentLoopRuntime as a1, type AgentLoopScriptPolicy as a2, type AgentLoopStep as a3, type AgentProfile as a4, AgentProfileRegistry as a5, type AgentProfileType as a6, type AgentPromptDescription as a7, type AgentResponse as a8, type AgentStartData as a9, type CreateAgentOptions as aA, type DetailRefType as aB, type FrameworkPluginToolConfig as aC, type HookContext as aD, type HookHandler as aE, HookRegistry as aF, type HookResult as aG, type HookSlot as aH, type HookType as aI, type HostAgentToolConfig as aJ, type IChatSyncAdapter as aK, type ILLMProvider as aL, type IMChannel as aM, type INetworkService as aN, type ImChannelBindingRecord as aO, type LoadAgentAgentLoopScriptOptions as aP, type LoadAgentToolLoopScriptOptions as aQ, type LoadPluginModuleOptions as aR, type LoadedPlugin as aS, type LoopPlugin as aT, type LoopProfile as aU, type LoopProfilePluginEntry as aV, type LoopProfilePrompt as aW, type LoopProfileScriptReference as aX, LoopRegistryImpl as aY, type MemeLoopLogger as aZ, type MergedPermissions as a_, type AgentStatusContext as aa, type AgentStopData as ab, type AgentToolLoopContext as ac, type AgentToolLoopIterationGenerator as ad, type AgentToolLoopIterationResult as ae, type AgentToolLoopOptions as af, type AgentToolLoopScript as ag, type AgentToolLoopScriptContext as ah, type AgentToolLoopScriptReference as ai, type AgentToolLoopState as aj, type AgentToolLoopTurnStartResult as ak, type AiAPIConfig as al, BUILTIN_AGENT_AGENT_LOOP_QUALITY_GATE_SCRIPT_ID as am, BUILTIN_AGENT_PROFILES as an, BUILTIN_AGENT_TOOL_LOOP_DEFAULT_SCRIPT_ID as ao, BUILTIN_TOOL_PLUGIN_IDS as ap, type BaseToolContext as aq, type CategoryConfig as ar, type ChatRole as as, type CheckpointRecord as at, type CheckpointStore as au, type CompactionOptions as av, type CompactionResult as aw, type ContextCompactionData as ax, type ConversationQueryMode as ay, type CreateAgentLoopRunnerOptions as az, type AgentFrameworkConfig as b, flattenPrompts as b$, type ModelSelection as b0, PERMISSIONS_TABLE_DDL as b1, PLUGIN_ASK_QUESTION as b2, PLUGIN_ASK_USER_QUESTION as b3, PLUGIN_MCP_CLIENT as b4, PLUGIN_MCP_FORWARD as b5, PLUGIN_REMOTE_AGENT as b6, PLUGIN_SPAWN_AGENT as b7, PLUGIN_TASK as b8, PLUGIN_TODO_WRITE as b9, type ToolApprovalMode as bA, type ToolCall as bB, type ToolExecutionContext as bC, type ToolPermissionRules as bD, type UserMessageContext as bE, type UserPromptSubmitData as bF, type YieldNextRoundTarget as bG, autoCompact as bH, buildAgent as bI, builtinAgentAgentLoopSources as bJ, builtinAgentToolLoopSources as bK, checkPermission as bL, clearHooks as bM, clearPluginRegistrations as bN, compactMessages as bO, createAgentAgentLoopDefinition as bP, createAgentInstanceFromDefinition as bQ, createAgentLoopRunner as bR, createAgentToolLoopDefinition as bS, createAgentToolLoopRunner as bT, createChatMessage as bU, createCheckpointRecord as bV, createInstanceDeltaFromDefinition as bW, createMemeLoopRuntime as bX, createPluginAPI as bY, executeHooks as bZ, exploreAgent as b_, type PermissionAction as ba, type PermissionRule as bb, type PermissionSet as bc, type PermissionSqlDatabase as bd, type PermissionSqlStatement as be, type PluginAPI as bf, type PluginAPIOptions as bg, type PluginExports as bh, type PluginManifest as bi, type PluginModule as bj, type PostToolUseData as bk, type PreToolUseData as bl, type PromptConcatPluginPreview as bm, type PromptConcatStreamState as bn, type PromptNode as bo, type PromptPluginConfig as bp, type ProviderConfig as bq, ProviderRegistry as br, type RegisteredProvider as bs, type RunAgentToolLoopTurnCallbacks as bt, type RunAgentToolLoopTurnResult as bu, type SendMessageOptions as bv, SessionStorage as bw, type TaskCategory as bx, TokenTracker as by, type ToolActions as bz, type IMPlatformType as c, getAgentAgentLoopId as c0, getAgentProfileRegistry as c1, getBuiltinAgentAgentLoopSource as c2, getBuiltinAgentToolLoopSource as c3, getBuiltinLoopProfile as c4, getBuiltinLoopProfiles as c5, getBuiltinToolPlugins as c6, getCategoryConfig as c7, getDefaultHookRegistry as c8, getHookCount as c9, registerBuiltinToolPlugins as cA, registerHook as cB, registerPluginHooks as cC, registerPluginTools as cD, resetAgentProfileRegistry as cE, resetLoopRegistry as cF, resolveAgentToolLoopTerminalState as cG, resolveCategory as cH, runAgentToolLoopTurn as cI, saveUserPermissions as cJ, serializeCheckpointRecord as cK, shouldCompact as cL, unloadAllPlugins as cM, unloadPlugin as cN, unregisterHook as cO, validatePluginManifest as cP, registerBuiltinLoopProfiles as cQ, getLoadedPlugin as ca, getLoopRegistry as cb, getPluginRegistrations as cc, hasHooks as cd, isConversationMeta as ce, isPluginLoaded as cf, isTaskCategory as cg, isUserInitiatedConversation as ch, librarianAgent as ci, listPlugins as cj, listRegisteredHookTypes as ck, loadAgentAgentLoopScript as cl, loadAgentToolLoopScript as cm, loadPluginModule as cn, loadPluginModules as co, loadUserPermissions as cp, matchAllToolCallings as cq, matchPattern as cr, matchToolCalling as cs, mergePermissionSets as ct, oracleAgent as cu, parseCheckpointRecord as cv, planAgent as cw, promptConcatStream as cx, registerBuiltinLoops as cy, registerBuiltinPromptPlugins as cz, type IMChannelBinding as d, type AttachmentReference as e, type AgentInstanceMeta as f, type ApprovalDecision as g, type ToolApprovalRequest as h, type AgentFrameworkContext as i, type AgentLoopInput as j, type AgentLoopGenerator as k, type IToolRegistry as l, type PromptConcatHookContext as m, type IPrompt as n, findPromptById as o, type PostProcessContext as p, type AIResponseContext as q, type ToolCallingMatch as r, type PromptConcatHooks as s, type AgentDefinitionToolConfig as t, type DetailReference as u, AGENT_AGENT_LOOP_ID as v, AGENT_TOOL_LOOP_ID as w, type AIStreamResponseSubset as x, ALL_CATEGORIES as y, type AgentAgentBatchRunInput as z };
|