@femtomc/mu-agent 26.2.72 → 26.2.73
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 +27 -37
- package/dist/extensions/branding.d.ts +1 -1
- package/dist/extensions/branding.js +1 -1
- package/dist/extensions/index.d.ts +5 -13
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +7 -15
- package/dist/extensions/mu-operator.d.ts +2 -2
- package/dist/extensions/mu-operator.js +4 -4
- package/dist/extensions/mu-serve.d.ts +2 -2
- package/dist/extensions/mu-serve.d.ts.map +1 -1
- package/dist/extensions/mu-serve.js +6 -14
- package/dist/extensions/mu-tools.d.ts +9 -0
- package/dist/extensions/mu-tools.d.ts.map +1 -0
- package/dist/extensions/mu-tools.js +12 -0
- package/dist/extensions/operator-command.d.ts +3 -4
- package/dist/extensions/operator-command.d.ts.map +1 -1
- package/dist/extensions/operator-command.js +58 -115
- package/dist/extensions/query.d.ts +4 -0
- package/dist/extensions/query.d.ts.map +1 -0
- package/dist/extensions/query.js +402 -0
- package/dist/operator.d.ts +15 -0
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +130 -10
- package/dist/session_factory.d.ts +7 -0
- package/dist/session_factory.d.ts.map +1 -1
- package/dist/session_factory.js +21 -2
- package/package.json +2 -2
- package/prompts/roles/operator.md +22 -40
- package/prompts/roles/orchestrator.md +18 -12
- package/prompts/roles/reviewer.md +8 -7
- package/prompts/roles/worker.md +8 -11
- package/dist/extensions/activities.d.ts +0 -7
- package/dist/extensions/activities.d.ts.map +0 -1
- package/dist/extensions/activities.js +0 -236
- package/dist/extensions/cron.d.ts +0 -7
- package/dist/extensions/cron.d.ts.map +0 -1
- package/dist/extensions/cron.js +0 -247
- package/dist/extensions/heartbeats.d.ts +0 -7
- package/dist/extensions/heartbeats.d.ts.map +0 -1
- package/dist/extensions/heartbeats.js +0 -192
- package/dist/extensions/messaging-setup/actions.d.ts +0 -22
- package/dist/extensions/messaging-setup/actions.d.ts.map +0 -1
- package/dist/extensions/messaging-setup/actions.js +0 -229
- package/dist/extensions/messaging-setup/adapters.d.ts +0 -24
- package/dist/extensions/messaging-setup/adapters.d.ts.map +0 -1
- package/dist/extensions/messaging-setup/adapters.js +0 -170
- package/dist/extensions/messaging-setup/index.d.ts +0 -17
- package/dist/extensions/messaging-setup/index.d.ts.map +0 -1
- package/dist/extensions/messaging-setup/index.js +0 -261
- package/dist/extensions/messaging-setup/parser.d.ts +0 -33
- package/dist/extensions/messaging-setup/parser.d.ts.map +0 -1
- package/dist/extensions/messaging-setup/parser.js +0 -240
- package/dist/extensions/messaging-setup/runtime.d.ts +0 -16
- package/dist/extensions/messaging-setup/runtime.d.ts.map +0 -1
- package/dist/extensions/messaging-setup/runtime.js +0 -110
- package/dist/extensions/messaging-setup/types.d.ts +0 -157
- package/dist/extensions/messaging-setup/types.d.ts.map +0 -1
- package/dist/extensions/messaging-setup/types.js +0 -4
- package/dist/extensions/messaging-setup/ui.d.ts +0 -15
- package/dist/extensions/messaging-setup/ui.d.ts.map +0 -1
- package/dist/extensions/messaging-setup/ui.js +0 -173
- package/dist/extensions/messaging-setup.d.ts +0 -3
- package/dist/extensions/messaging-setup.d.ts.map +0 -1
- package/dist/extensions/messaging-setup.js +0 -2
- package/dist/extensions/mu-full-tools.d.ts +0 -10
- package/dist/extensions/mu-full-tools.d.ts.map +0 -1
- package/dist/extensions/mu-full-tools.js +0 -25
- package/dist/extensions/mu-query-tools.d.ts +0 -10
- package/dist/extensions/mu-query-tools.d.ts.map +0 -1
- package/dist/extensions/mu-query-tools.js +0 -11
- package/dist/extensions/orchestration-runs-readonly.d.ts +0 -4
- package/dist/extensions/orchestration-runs-readonly.d.ts.map +0 -1
- package/dist/extensions/orchestration-runs-readonly.js +0 -226
- package/dist/extensions/orchestration-runs.d.ts +0 -4
- package/dist/extensions/orchestration-runs.d.ts.map +0 -1
- package/dist/extensions/orchestration-runs.js +0 -315
- package/dist/extensions/server-tools-readonly.d.ts +0 -4
- package/dist/extensions/server-tools-readonly.d.ts.map +0 -1
- package/dist/extensions/server-tools-readonly.js +0 -5
- package/dist/extensions/server-tools.d.ts +0 -25
- package/dist/extensions/server-tools.d.ts.map +0 -1
- package/dist/extensions/server-tools.js +0 -833
- package/prompts/skills/messaging-setup-brief.md +0 -25
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import { StringEnum } from "@mariozechner/pi-ai";
|
|
2
|
+
import { Type } from "@sinclair/typebox";
|
|
3
|
+
import { clampInt, fetchMuJson, fetchMuStatus, parseFieldPaths, selectFields, textResult, toJsonText, } from "./shared.js";
|
|
4
|
+
function trimOrNull(value) {
|
|
5
|
+
if (value == null)
|
|
6
|
+
return null;
|
|
7
|
+
const trimmed = value.trim();
|
|
8
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
9
|
+
}
|
|
10
|
+
function appendIf(search, key, value) {
|
|
11
|
+
if (value == null)
|
|
12
|
+
return;
|
|
13
|
+
const text = typeof value === "number" ? String(Math.trunc(value)) : value.trim();
|
|
14
|
+
if (text.length === 0)
|
|
15
|
+
return;
|
|
16
|
+
search.set(key, text);
|
|
17
|
+
}
|
|
18
|
+
const QUERY_ACTIONS = ["describe", "get", "list", "search", "timeline", "stats", "trace"];
|
|
19
|
+
const QUERY_RESOURCES = [
|
|
20
|
+
"status",
|
|
21
|
+
"control_plane",
|
|
22
|
+
"issues",
|
|
23
|
+
"issues_ready",
|
|
24
|
+
"forum_topics",
|
|
25
|
+
"forum_messages",
|
|
26
|
+
"events",
|
|
27
|
+
"runs",
|
|
28
|
+
"activities",
|
|
29
|
+
"heartbeats",
|
|
30
|
+
"cron",
|
|
31
|
+
"identities",
|
|
32
|
+
"context",
|
|
33
|
+
];
|
|
34
|
+
const QUERY_DESCRIPTOR = {
|
|
35
|
+
version: 1,
|
|
36
|
+
tool: "query",
|
|
37
|
+
actions: [...QUERY_ACTIONS],
|
|
38
|
+
resources: {
|
|
39
|
+
status: { actions: ["get"], note: "Repo/control-plane status snapshot." },
|
|
40
|
+
control_plane: { actions: ["get"], note: "Extracted control_plane view from status." },
|
|
41
|
+
issues: { actions: ["list", "get"], note: "Issue listing + targeted issue retrieval." },
|
|
42
|
+
issues_ready: { actions: ["list"], note: "Ready leaf issue discovery." },
|
|
43
|
+
forum_topics: { actions: ["list"], note: "Forum topic discovery." },
|
|
44
|
+
forum_messages: { actions: ["list"], note: "Topic message reads." },
|
|
45
|
+
events: { actions: ["list", "trace"], note: "Event queries + tail inspection." },
|
|
46
|
+
runs: { actions: ["list", "get", "trace"], note: "Run list/status/trace." },
|
|
47
|
+
activities: { actions: ["list", "get", "trace"], note: "Activity list/get/events." },
|
|
48
|
+
heartbeats: { actions: ["list", "get"], note: "Heartbeat program inspection." },
|
|
49
|
+
cron: { actions: ["stats", "list", "get"], note: "Cron status/list/get." },
|
|
50
|
+
identities: { actions: ["list"], note: "Identity binding list." },
|
|
51
|
+
context: { actions: ["search", "timeline", "stats"], note: "Cross-store historical context." },
|
|
52
|
+
},
|
|
53
|
+
defaults: {
|
|
54
|
+
list_limit: 20,
|
|
55
|
+
trace_limit: 40,
|
|
56
|
+
max_limit: 500,
|
|
57
|
+
},
|
|
58
|
+
mutation_pathway: {
|
|
59
|
+
tool: "command",
|
|
60
|
+
kinds: [
|
|
61
|
+
"run_start",
|
|
62
|
+
"run_resume",
|
|
63
|
+
"run_interrupt",
|
|
64
|
+
"reload",
|
|
65
|
+
"update",
|
|
66
|
+
"issue_create",
|
|
67
|
+
"issue_update",
|
|
68
|
+
"issue_claim",
|
|
69
|
+
"issue_open",
|
|
70
|
+
"issue_close",
|
|
71
|
+
"issue_dep",
|
|
72
|
+
"issue_undep",
|
|
73
|
+
"forum_post",
|
|
74
|
+
"heartbeat_create",
|
|
75
|
+
"heartbeat_update",
|
|
76
|
+
"heartbeat_delete",
|
|
77
|
+
"heartbeat_trigger",
|
|
78
|
+
"heartbeat_enable",
|
|
79
|
+
"heartbeat_disable",
|
|
80
|
+
"cron_create",
|
|
81
|
+
"cron_update",
|
|
82
|
+
"cron_delete",
|
|
83
|
+
"cron_trigger",
|
|
84
|
+
"cron_enable",
|
|
85
|
+
"cron_disable",
|
|
86
|
+
],
|
|
87
|
+
note: "All mutations are routed through command -> /api/commands/submit.",
|
|
88
|
+
},
|
|
89
|
+
hints: [
|
|
90
|
+
"Narrow first: pass limit + filters before broad scans.",
|
|
91
|
+
"Use fields for targeted projection and context hygiene.",
|
|
92
|
+
],
|
|
93
|
+
examples: [
|
|
94
|
+
{ action: "get", resource: "status" },
|
|
95
|
+
{ action: "list", resource: "issues", status: "open", limit: 20 },
|
|
96
|
+
{ action: "get", resource: "issues", id: "mu-abc123", fields: "id,title,status,tags" },
|
|
97
|
+
{ action: "search", resource: "context", query: "reload failure", limit: 30 },
|
|
98
|
+
{ action: "timeline", resource: "context", conversation_key: "telegram:bot:chat-1:binding-1", limit: 80 },
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
export function queryExtension(pi) {
|
|
102
|
+
pi.on("before_agent_start", async (event) => {
|
|
103
|
+
const lines = [
|
|
104
|
+
"",
|
|
105
|
+
"[MU QUERY]",
|
|
106
|
+
"Tool: query(action=describe|get|list|search|timeline|stats|trace, resource=...)",
|
|
107
|
+
"Use query(action=describe) first when you need machine-readable capability discovery.",
|
|
108
|
+
];
|
|
109
|
+
return {
|
|
110
|
+
systemPrompt: `${event.systemPrompt}${lines.join("\n")}`,
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
const QueryParams = Type.Object({
|
|
114
|
+
action: StringEnum(QUERY_ACTIONS),
|
|
115
|
+
resource: Type.Optional(StringEnum(QUERY_RESOURCES)),
|
|
116
|
+
id: Type.Optional(Type.String({ description: "Primary identifier for get/trace actions" })),
|
|
117
|
+
query: Type.Optional(Type.String({ description: "Search query text" })),
|
|
118
|
+
q: Type.Optional(Type.String({ description: "Alias for query" })),
|
|
119
|
+
status: Type.Optional(Type.String({ description: "Status filter" })),
|
|
120
|
+
tag: Type.Optional(Type.String({ description: "Issue tag filter" })),
|
|
121
|
+
contains: Type.Optional(Type.String({ description: "Case-insensitive contains filter" })),
|
|
122
|
+
type: Type.Optional(Type.String({ description: "Event type filter" })),
|
|
123
|
+
source: Type.Optional(Type.String({ description: "Event/context source filter" })),
|
|
124
|
+
sources: Type.Optional(Type.String({ description: "Comma-separated source kinds (context)" })),
|
|
125
|
+
root_issue_id: Type.Optional(Type.String({ description: "Run root issue id for lookup" })),
|
|
126
|
+
issue_id: Type.Optional(Type.String({ description: "Issue filter" })),
|
|
127
|
+
run_id: Type.Optional(Type.String({ description: "Run filter" })),
|
|
128
|
+
session_id: Type.Optional(Type.String({ description: "Session filter" })),
|
|
129
|
+
conversation_key: Type.Optional(Type.String({ description: "Conversation key filter" })),
|
|
130
|
+
channel: Type.Optional(Type.String({ description: "Channel filter" })),
|
|
131
|
+
channel_tenant_id: Type.Optional(Type.String({ description: "Channel tenant filter" })),
|
|
132
|
+
channel_conversation_id: Type.Optional(Type.String({ description: "Channel conversation filter" })),
|
|
133
|
+
actor_binding_id: Type.Optional(Type.String({ description: "Actor binding filter" })),
|
|
134
|
+
topic: Type.Optional(Type.String({ description: "Forum topic" })),
|
|
135
|
+
prefix: Type.Optional(Type.String({ description: "Forum topic prefix" })),
|
|
136
|
+
author: Type.Optional(Type.String({ description: "Author filter" })),
|
|
137
|
+
role: Type.Optional(Type.String({ description: "Role filter" })),
|
|
138
|
+
kind: Type.Optional(Type.String({ description: "Kind filter (activities)" })),
|
|
139
|
+
schedule_kind: Type.Optional(Type.String({ description: "Cron schedule kind filter" })),
|
|
140
|
+
target_kind: Type.Optional(Type.String({ description: "Program target kind filter" })),
|
|
141
|
+
enabled: Type.Optional(Type.Boolean({ description: "Enabled state filter" })),
|
|
142
|
+
include_inactive: Type.Optional(Type.Boolean({ description: "Include inactive identity bindings" })),
|
|
143
|
+
since: Type.Optional(Type.Number({ description: "Only rows >= epoch ms" })),
|
|
144
|
+
until: Type.Optional(Type.Number({ description: "Only rows <= epoch ms" })),
|
|
145
|
+
order: Type.Optional(Type.String({ description: "Order for timeline: asc|desc" })),
|
|
146
|
+
limit: Type.Optional(Type.Number({ description: "Max rows (default 20, max 500)" })),
|
|
147
|
+
fields: Type.Optional(Type.String({
|
|
148
|
+
description: "Comma-separated projection fields (e.g. items.0.source_kind,total)",
|
|
149
|
+
})),
|
|
150
|
+
});
|
|
151
|
+
pi.registerTool({
|
|
152
|
+
name: "query",
|
|
153
|
+
label: "Query",
|
|
154
|
+
description: "Read-only query tool for mu state. Supports self-discovery (action=describe), targeted retrieval, and cross-store context search/timeline/stats.",
|
|
155
|
+
parameters: QueryParams,
|
|
156
|
+
async execute(_toolCallId, params) {
|
|
157
|
+
if (params.action === "describe") {
|
|
158
|
+
const resource = trimOrNull(params.resource);
|
|
159
|
+
if (resource && resource in QUERY_DESCRIPTOR.resources) {
|
|
160
|
+
const selected = {
|
|
161
|
+
...QUERY_DESCRIPTOR,
|
|
162
|
+
resources: {
|
|
163
|
+
[resource]: QUERY_DESCRIPTOR.resources[resource],
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
return textResult(toJsonText(selected), selected);
|
|
167
|
+
}
|
|
168
|
+
return textResult(toJsonText(QUERY_DESCRIPTOR), QUERY_DESCRIPTOR);
|
|
169
|
+
}
|
|
170
|
+
const resource = trimOrNull(params.resource);
|
|
171
|
+
if (!resource) {
|
|
172
|
+
return textResult("resource is required for non-describe actions");
|
|
173
|
+
}
|
|
174
|
+
const fields = parseFieldPaths(trimOrNull(params.fields) ?? undefined);
|
|
175
|
+
const render = (payload) => {
|
|
176
|
+
const output = fields.length > 0 ? selectFields(payload, fields) : payload;
|
|
177
|
+
return textResult(toJsonText(output), {
|
|
178
|
+
action: params.action,
|
|
179
|
+
resource,
|
|
180
|
+
fields,
|
|
181
|
+
payload,
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
const limit = clampInt(params.limit, params.action === "trace" ? 40 : 20, 1, 500);
|
|
185
|
+
switch (resource) {
|
|
186
|
+
case "status": {
|
|
187
|
+
if (params.action !== "get")
|
|
188
|
+
return textResult("status only supports action=get");
|
|
189
|
+
const status = await fetchMuStatus();
|
|
190
|
+
return render(status);
|
|
191
|
+
}
|
|
192
|
+
case "control_plane": {
|
|
193
|
+
if (params.action !== "get")
|
|
194
|
+
return textResult("control_plane only supports action=get");
|
|
195
|
+
const status = await fetchMuStatus();
|
|
196
|
+
return render(status.control_plane);
|
|
197
|
+
}
|
|
198
|
+
case "issues": {
|
|
199
|
+
if (params.action === "get") {
|
|
200
|
+
const id = trimOrNull(params.id) ?? trimOrNull(params.issue_id);
|
|
201
|
+
if (!id)
|
|
202
|
+
return textResult("issues get requires id");
|
|
203
|
+
const payload = await fetchMuJson(`/api/issues/${encodeURIComponent(id)}`);
|
|
204
|
+
return render(payload);
|
|
205
|
+
}
|
|
206
|
+
if (params.action !== "list")
|
|
207
|
+
return textResult("issues supports action=list|get");
|
|
208
|
+
const search = new URLSearchParams();
|
|
209
|
+
appendIf(search, "status", trimOrNull(params.status) ?? "open");
|
|
210
|
+
appendIf(search, "tag", trimOrNull(params.tag));
|
|
211
|
+
appendIf(search, "contains", trimOrNull(params.contains));
|
|
212
|
+
appendIf(search, "limit", limit);
|
|
213
|
+
const payload = await fetchMuJson(`/api/issues?${search.toString()}`);
|
|
214
|
+
return render({ count: payload.length, issues: payload });
|
|
215
|
+
}
|
|
216
|
+
case "issues_ready": {
|
|
217
|
+
if (params.action !== "list")
|
|
218
|
+
return textResult("issues_ready only supports action=list");
|
|
219
|
+
const search = new URLSearchParams();
|
|
220
|
+
appendIf(search, "root", trimOrNull(params.root_issue_id));
|
|
221
|
+
appendIf(search, "contains", trimOrNull(params.contains));
|
|
222
|
+
appendIf(search, "limit", limit);
|
|
223
|
+
const payload = await fetchMuJson(`/api/issues/ready?${search.toString()}`);
|
|
224
|
+
return render({ count: payload.length, issues: payload });
|
|
225
|
+
}
|
|
226
|
+
case "forum_topics": {
|
|
227
|
+
if (params.action !== "list")
|
|
228
|
+
return textResult("forum_topics only supports action=list");
|
|
229
|
+
const search = new URLSearchParams();
|
|
230
|
+
appendIf(search, "prefix", trimOrNull(params.prefix));
|
|
231
|
+
appendIf(search, "limit", limit);
|
|
232
|
+
const payload = await fetchMuJson(`/api/forum/topics?${search.toString()}`);
|
|
233
|
+
return render({ count: payload.length, topics: payload });
|
|
234
|
+
}
|
|
235
|
+
case "forum_messages": {
|
|
236
|
+
if (params.action !== "list")
|
|
237
|
+
return textResult("forum_messages only supports action=list");
|
|
238
|
+
const topic = trimOrNull(params.topic);
|
|
239
|
+
if (!topic)
|
|
240
|
+
return textResult("forum_messages list requires topic");
|
|
241
|
+
const search = new URLSearchParams();
|
|
242
|
+
appendIf(search, "topic", topic);
|
|
243
|
+
appendIf(search, "limit", limit);
|
|
244
|
+
const payload = await fetchMuJson(`/api/forum/read?${search.toString()}`);
|
|
245
|
+
return render({ count: payload.length, topic, messages: payload });
|
|
246
|
+
}
|
|
247
|
+
case "events": {
|
|
248
|
+
if (params.action === "trace") {
|
|
249
|
+
const payload = await fetchMuJson(`/api/events/tail?n=${limit}`);
|
|
250
|
+
return render({ count: payload.length, events: payload });
|
|
251
|
+
}
|
|
252
|
+
if (params.action !== "list")
|
|
253
|
+
return textResult("events supports action=list|trace");
|
|
254
|
+
const search = new URLSearchParams();
|
|
255
|
+
appendIf(search, "type", trimOrNull(params.type));
|
|
256
|
+
appendIf(search, "source", trimOrNull(params.source));
|
|
257
|
+
appendIf(search, "issue_id", trimOrNull(params.issue_id));
|
|
258
|
+
appendIf(search, "run_id", trimOrNull(params.run_id));
|
|
259
|
+
appendIf(search, "contains", trimOrNull(params.contains));
|
|
260
|
+
appendIf(search, "since", params.since ?? null);
|
|
261
|
+
appendIf(search, "limit", limit);
|
|
262
|
+
const payload = await fetchMuJson(`/api/events?${search.toString()}`);
|
|
263
|
+
return render({ count: payload.length, events: payload });
|
|
264
|
+
}
|
|
265
|
+
case "runs": {
|
|
266
|
+
if (params.action === "list") {
|
|
267
|
+
const search = new URLSearchParams();
|
|
268
|
+
appendIf(search, "status", trimOrNull(params.status));
|
|
269
|
+
appendIf(search, "limit", limit);
|
|
270
|
+
const payload = await fetchMuJson(`/api/runs?${search.toString()}`);
|
|
271
|
+
return render(payload);
|
|
272
|
+
}
|
|
273
|
+
if (params.action === "get") {
|
|
274
|
+
const id = trimOrNull(params.id) ?? trimOrNull(params.root_issue_id);
|
|
275
|
+
if (!id)
|
|
276
|
+
return textResult("runs get requires id or root_issue_id");
|
|
277
|
+
const payload = await fetchMuJson(`/api/runs/${encodeURIComponent(id)}`);
|
|
278
|
+
return render(payload);
|
|
279
|
+
}
|
|
280
|
+
if (params.action === "trace") {
|
|
281
|
+
const id = trimOrNull(params.id) ?? trimOrNull(params.root_issue_id);
|
|
282
|
+
if (!id)
|
|
283
|
+
return textResult("runs trace requires id or root_issue_id");
|
|
284
|
+
const payload = await fetchMuJson(`/api/runs/${encodeURIComponent(id)}/trace?limit=${limit}`);
|
|
285
|
+
return render(payload);
|
|
286
|
+
}
|
|
287
|
+
return textResult("runs supports action=list|get|trace");
|
|
288
|
+
}
|
|
289
|
+
case "activities": {
|
|
290
|
+
if (params.action === "list") {
|
|
291
|
+
const search = new URLSearchParams();
|
|
292
|
+
appendIf(search, "status", trimOrNull(params.status));
|
|
293
|
+
appendIf(search, "kind", trimOrNull(params.kind));
|
|
294
|
+
appendIf(search, "limit", limit);
|
|
295
|
+
const payload = await fetchMuJson(`/api/activities?${search.toString()}`);
|
|
296
|
+
return render(payload);
|
|
297
|
+
}
|
|
298
|
+
if (params.action === "get") {
|
|
299
|
+
const id = trimOrNull(params.id);
|
|
300
|
+
if (!id)
|
|
301
|
+
return textResult("activities get requires id");
|
|
302
|
+
const payload = await fetchMuJson(`/api/activities/${encodeURIComponent(id)}`);
|
|
303
|
+
return render(payload);
|
|
304
|
+
}
|
|
305
|
+
if (params.action === "trace") {
|
|
306
|
+
const id = trimOrNull(params.id);
|
|
307
|
+
if (!id)
|
|
308
|
+
return textResult("activities trace requires id");
|
|
309
|
+
const search = new URLSearchParams();
|
|
310
|
+
appendIf(search, "limit", limit);
|
|
311
|
+
const payload = await fetchMuJson(`/api/activities/${encodeURIComponent(id)}/events?${search.toString()}`);
|
|
312
|
+
return render(payload);
|
|
313
|
+
}
|
|
314
|
+
return textResult("activities supports action=list|get|trace");
|
|
315
|
+
}
|
|
316
|
+
case "heartbeats": {
|
|
317
|
+
if (params.action === "list") {
|
|
318
|
+
const search = new URLSearchParams();
|
|
319
|
+
appendIf(search, "enabled", params.enabled == null ? null : String(params.enabled));
|
|
320
|
+
appendIf(search, "target_kind", trimOrNull(params.target_kind));
|
|
321
|
+
appendIf(search, "limit", limit);
|
|
322
|
+
const payload = await fetchMuJson(`/api/heartbeats?${search.toString()}`);
|
|
323
|
+
return render(payload);
|
|
324
|
+
}
|
|
325
|
+
if (params.action === "get") {
|
|
326
|
+
const id = trimOrNull(params.id);
|
|
327
|
+
if (!id)
|
|
328
|
+
return textResult("heartbeats get requires id");
|
|
329
|
+
const payload = await fetchMuJson(`/api/heartbeats/${encodeURIComponent(id)}`);
|
|
330
|
+
return render(payload);
|
|
331
|
+
}
|
|
332
|
+
return textResult("heartbeats supports action=list|get");
|
|
333
|
+
}
|
|
334
|
+
case "cron": {
|
|
335
|
+
if (params.action === "stats") {
|
|
336
|
+
const payload = await fetchMuJson("/api/cron/status");
|
|
337
|
+
return render(payload);
|
|
338
|
+
}
|
|
339
|
+
if (params.action === "list") {
|
|
340
|
+
const search = new URLSearchParams();
|
|
341
|
+
appendIf(search, "enabled", params.enabled == null ? null : String(params.enabled));
|
|
342
|
+
appendIf(search, "target_kind", trimOrNull(params.target_kind));
|
|
343
|
+
appendIf(search, "schedule_kind", trimOrNull(params.schedule_kind));
|
|
344
|
+
appendIf(search, "limit", limit);
|
|
345
|
+
const payload = await fetchMuJson(`/api/cron?${search.toString()}`);
|
|
346
|
+
return render(payload);
|
|
347
|
+
}
|
|
348
|
+
if (params.action === "get") {
|
|
349
|
+
const id = trimOrNull(params.id);
|
|
350
|
+
if (!id)
|
|
351
|
+
return textResult("cron get requires id");
|
|
352
|
+
const payload = await fetchMuJson(`/api/cron/${encodeURIComponent(id)}`);
|
|
353
|
+
return render(payload);
|
|
354
|
+
}
|
|
355
|
+
return textResult("cron supports action=stats|list|get");
|
|
356
|
+
}
|
|
357
|
+
case "identities": {
|
|
358
|
+
if (params.action !== "list")
|
|
359
|
+
return textResult("identities only supports action=list");
|
|
360
|
+
const search = new URLSearchParams();
|
|
361
|
+
appendIf(search, "include_inactive", params.include_inactive ? "true" : null);
|
|
362
|
+
const payload = await fetchMuJson(`/api/identities${search.size > 0 ? `?${search.toString()}` : ""}`);
|
|
363
|
+
return render(payload);
|
|
364
|
+
}
|
|
365
|
+
case "context": {
|
|
366
|
+
if (params.action !== "search" && params.action !== "timeline" && params.action !== "stats") {
|
|
367
|
+
return textResult("context supports action=search|timeline|stats");
|
|
368
|
+
}
|
|
369
|
+
const search = new URLSearchParams();
|
|
370
|
+
appendIf(search, "query", trimOrNull(params.query) ?? trimOrNull(params.q));
|
|
371
|
+
appendIf(search, "sources", trimOrNull(params.sources));
|
|
372
|
+
appendIf(search, "source", trimOrNull(params.source));
|
|
373
|
+
appendIf(search, "issue_id", trimOrNull(params.issue_id));
|
|
374
|
+
appendIf(search, "run_id", trimOrNull(params.run_id));
|
|
375
|
+
appendIf(search, "session_id", trimOrNull(params.session_id));
|
|
376
|
+
appendIf(search, "conversation_key", trimOrNull(params.conversation_key));
|
|
377
|
+
appendIf(search, "channel", trimOrNull(params.channel));
|
|
378
|
+
appendIf(search, "channel_tenant_id", trimOrNull(params.channel_tenant_id));
|
|
379
|
+
appendIf(search, "channel_conversation_id", trimOrNull(params.channel_conversation_id));
|
|
380
|
+
appendIf(search, "actor_binding_id", trimOrNull(params.actor_binding_id));
|
|
381
|
+
appendIf(search, "topic", trimOrNull(params.topic));
|
|
382
|
+
appendIf(search, "author", trimOrNull(params.author));
|
|
383
|
+
appendIf(search, "role", trimOrNull(params.role));
|
|
384
|
+
appendIf(search, "since", params.since ?? null);
|
|
385
|
+
appendIf(search, "until", params.until ?? null);
|
|
386
|
+
appendIf(search, "order", trimOrNull(params.order));
|
|
387
|
+
appendIf(search, "limit", limit);
|
|
388
|
+
const endpoint = params.action === "timeline"
|
|
389
|
+
? "/api/context/timeline"
|
|
390
|
+
: params.action === "stats"
|
|
391
|
+
? "/api/context/stats"
|
|
392
|
+
: "/api/context/search";
|
|
393
|
+
const payload = await fetchMuJson(`${endpoint}${search.size > 0 ? `?${search.toString()}` : ""}`);
|
|
394
|
+
return render(payload);
|
|
395
|
+
}
|
|
396
|
+
default:
|
|
397
|
+
return textResult(`unsupported resource: ${resource}`);
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
export default queryExtension;
|
package/dist/operator.d.ts
CHANGED
|
@@ -141,6 +141,11 @@ export declare class ApprovedCommandBroker {
|
|
|
141
141
|
details?: string;
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
|
+
export type MessagingOperatorConversationSessionStore = {
|
|
145
|
+
getSessionId: (conversationKey: string) => Promise<string | null> | string | null;
|
|
146
|
+
setSessionId: (conversationKey: string, sessionId: string) => Promise<void> | void;
|
|
147
|
+
stop?: () => Promise<void> | void;
|
|
148
|
+
};
|
|
144
149
|
export type MessagingOperatorRuntimeOpts = {
|
|
145
150
|
backend: MessagingOperatorBackend;
|
|
146
151
|
broker?: ApprovedCommandBroker;
|
|
@@ -148,7 +153,15 @@ export type MessagingOperatorRuntimeOpts = {
|
|
|
148
153
|
enabledChannels?: readonly string[];
|
|
149
154
|
sessionIdFactory?: () => string;
|
|
150
155
|
turnIdFactory?: () => string;
|
|
156
|
+
conversationSessionStore?: MessagingOperatorConversationSessionStore;
|
|
151
157
|
};
|
|
158
|
+
export declare class JsonFileConversationSessionStore implements MessagingOperatorConversationSessionStore {
|
|
159
|
+
#private;
|
|
160
|
+
constructor(path: string);
|
|
161
|
+
getSessionId(conversationKey: string): Promise<string | null>;
|
|
162
|
+
setSessionId(conversationKey: string, sessionId: string): Promise<void>;
|
|
163
|
+
stop(): Promise<void>;
|
|
164
|
+
}
|
|
152
165
|
export declare class MessagingOperatorRuntime {
|
|
153
166
|
#private;
|
|
154
167
|
constructor(opts: MessagingOperatorRuntimeOpts);
|
|
@@ -170,6 +183,8 @@ export type PiMessagingOperatorBackendOpts = {
|
|
|
170
183
|
sessionIdleTtlMs?: number;
|
|
171
184
|
maxSessions?: number;
|
|
172
185
|
auditTurns?: boolean;
|
|
186
|
+
persistSessions?: boolean;
|
|
187
|
+
sessionDirForRepoRoot?: (repoRoot: string) => string;
|
|
173
188
|
};
|
|
174
189
|
export { DEFAULT_OPERATOR_SYSTEM_PROMPT };
|
|
175
190
|
export declare class PiMessagingOperatorBackend implements MessagingOperatorBackend {
|
package/dist/operator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAmB,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAEtE,MAAM,MAAM,gCAAgC,GAAG;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uBAAuB,EAAE,MAAM,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS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