@femtomc/mu-agent 26.2.33
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 +28 -0
- package/dist/command_context.d.ts +31 -0
- package/dist/command_context.d.ts.map +1 -0
- package/dist/command_context.js +221 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/meta_agent.d.ts +147 -0
- package/dist/meta_agent.d.ts.map +1 -0
- package/dist/meta_agent.js +424 -0
- package/dist/mu_roles.d.ts +15 -0
- package/dist/mu_roles.d.ts.map +1 -0
- package/dist/mu_roles.js +165 -0
- package/dist/pi_backend.d.ts +20 -0
- package/dist/pi_backend.d.ts.map +1 -0
- package/dist/pi_backend.js +27 -0
- package/dist/pi_sdk_backend.d.ts +20 -0
- package/dist/pi_sdk_backend.d.ts.map +1 -0
- package/dist/pi_sdk_backend.js +152 -0
- package/dist/prompt.d.ts +17 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +153 -0
- package/package.json +23 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @femtomc/mu-agent
|
|
2
|
+
|
|
3
|
+
Shared mu agent runtime package.
|
|
4
|
+
|
|
5
|
+
This package centralizes reusable agent logic that was previously split across
|
|
6
|
+
`@femtomc/mu-control-plane` and `@femtomc/mu-orchestrator`, including:
|
|
7
|
+
|
|
8
|
+
- Messaging meta-agent runtime + backend
|
|
9
|
+
- Command context resolution for meta-agent command proposals
|
|
10
|
+
- Role prompt loading/defaults for orchestrator + worker agents
|
|
11
|
+
- pi CLI/SDK orchestration backends and resource loader helpers
|
|
12
|
+
- Prompt/template helpers used by orchestration roles
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @femtomc/mu-agent
|
|
18
|
+
# or: bun add @femtomc/mu-agent
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Development
|
|
22
|
+
|
|
23
|
+
From repo root (`mu/`):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
bun run build
|
|
27
|
+
bun test packages/orchestrator packages/control-plane
|
|
28
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type ContextResolutionSource = "explicit" | "conversation" | "none";
|
|
2
|
+
export type ContextResolutionFailureReason = "context_missing" | "context_ambiguous" | "context_unauthorized" | "cli_validation_failed";
|
|
3
|
+
export type ContextResolutionDecision = {
|
|
4
|
+
kind: "resolved";
|
|
5
|
+
repoRoot: string;
|
|
6
|
+
commandKey: string;
|
|
7
|
+
args: string[];
|
|
8
|
+
normalizedText: string;
|
|
9
|
+
targetId: string;
|
|
10
|
+
source: ContextResolutionSource;
|
|
11
|
+
} | {
|
|
12
|
+
kind: "reject";
|
|
13
|
+
reason: ContextResolutionFailureReason;
|
|
14
|
+
details?: string;
|
|
15
|
+
};
|
|
16
|
+
export type CommandContextResolverOpts = {
|
|
17
|
+
allowedRepoRoots?: readonly string[];
|
|
18
|
+
};
|
|
19
|
+
export declare class CommandContextResolver {
|
|
20
|
+
#private;
|
|
21
|
+
constructor(opts?: CommandContextResolverOpts);
|
|
22
|
+
resolve(opts: {
|
|
23
|
+
repoRoot: string;
|
|
24
|
+
commandKey: string;
|
|
25
|
+
args: readonly string[];
|
|
26
|
+
inboundTargetType: string;
|
|
27
|
+
inboundTargetId: string;
|
|
28
|
+
metadata: Record<string, unknown>;
|
|
29
|
+
}): ContextResolutionDecision;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=command_context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command_context.d.ts","sourceRoot":"","sources":["../src/command_context.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,uBAAuB,GAAG,UAAU,GAAG,cAAc,GAAG,MAAM,CAAC;AAE3E,MAAM,MAAM,8BAA8B,GACvC,iBAAiB,GACjB,mBAAmB,GACnB,sBAAsB,GACtB,uBAAuB,CAAC;AAE3B,MAAM,MAAM,yBAAyB,GAClC;IACA,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,uBAAuB,CAAC;CAC/B,GACD;IACA,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,8BAA8B,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEL,MAAM,MAAM,0BAA0B,GAAG;IACxC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC,CAAC;AAsJF,qBAAa,sBAAsB;;gBAGf,IAAI,GAAE,0BAA+B;IAQjD,OAAO,CAAC,IAAI,EAAE;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;QACxB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC,GAAG,yBAAyB;CAqG7B"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { resolve as resolvePath } from "node:path";
|
|
2
|
+
const ISSUE_ID_RE = /^mu-[a-z0-9][a-z0-9-]*$/;
|
|
3
|
+
const SAFE_TOPIC_RE = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}$/;
|
|
4
|
+
const SAFE_TARGET_RE = /^(?!-)[A-Za-z0-9._:@/-]{1,200}$/;
|
|
5
|
+
const ISSUE_TARGET_COMMANDS = new Set([
|
|
6
|
+
"issue get",
|
|
7
|
+
"issue update",
|
|
8
|
+
"issue claim",
|
|
9
|
+
"issue close",
|
|
10
|
+
"run resume",
|
|
11
|
+
]);
|
|
12
|
+
const TOPIC_TARGET_COMMANDS = new Set(["forum read", "forum post"]);
|
|
13
|
+
const GENERIC_TARGET_COMMANDS = new Set(["audit get", "dlq inspect", "dlq replay"]);
|
|
14
|
+
function readString(value) {
|
|
15
|
+
if (typeof value !== "string") {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const trimmed = value.trim();
|
|
19
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
20
|
+
}
|
|
21
|
+
function collectDistinct(values) {
|
|
22
|
+
const out = [];
|
|
23
|
+
for (const value of values) {
|
|
24
|
+
if (!out.includes(value)) {
|
|
25
|
+
out.push(value);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
function collectIssueCandidates(opts) {
|
|
31
|
+
const candidates = [];
|
|
32
|
+
const targetType = opts.inboundTargetType.toLowerCase();
|
|
33
|
+
if (targetType === "issue" ||
|
|
34
|
+
targetType === "issue_id" ||
|
|
35
|
+
targetType === "run_root" ||
|
|
36
|
+
targetType === "root_issue") {
|
|
37
|
+
const fromTarget = readString(opts.inboundTargetId);
|
|
38
|
+
if (fromTarget) {
|
|
39
|
+
candidates.push(fromTarget);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
for (const key of ["issue_id", "root_issue_id", "run_root_id"]) {
|
|
43
|
+
const fromMeta = readString(opts.metadata[key]);
|
|
44
|
+
if (fromMeta) {
|
|
45
|
+
candidates.push(fromMeta);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const arr = opts.metadata.issue_ids;
|
|
49
|
+
if (Array.isArray(arr)) {
|
|
50
|
+
for (const entry of arr) {
|
|
51
|
+
const item = readString(entry);
|
|
52
|
+
if (item) {
|
|
53
|
+
candidates.push(item);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return collectDistinct(candidates);
|
|
58
|
+
}
|
|
59
|
+
function collectTopicCandidates(opts) {
|
|
60
|
+
const candidates = [];
|
|
61
|
+
const targetType = opts.inboundTargetType.toLowerCase();
|
|
62
|
+
if (targetType === "topic" || targetType === "forum_topic" || targetType === "forum") {
|
|
63
|
+
const fromTarget = readString(opts.inboundTargetId);
|
|
64
|
+
if (fromTarget) {
|
|
65
|
+
candidates.push(fromTarget);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
for (const key of ["topic", "forum_topic"]) {
|
|
69
|
+
const fromMeta = readString(opts.metadata[key]);
|
|
70
|
+
if (fromMeta) {
|
|
71
|
+
candidates.push(fromMeta);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return collectDistinct(candidates);
|
|
75
|
+
}
|
|
76
|
+
function reject(reason, details) {
|
|
77
|
+
return {
|
|
78
|
+
kind: "reject",
|
|
79
|
+
reason,
|
|
80
|
+
details,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function resolveFromCandidates(opts) {
|
|
84
|
+
if (opts.explicitValue != null) {
|
|
85
|
+
if (!opts.validate(opts.explicitValue)) {
|
|
86
|
+
return { kind: "reject", reason: "cli_validation_failed", details: opts.invalidDetails };
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
kind: "resolved",
|
|
90
|
+
value: opts.explicitValue,
|
|
91
|
+
source: "explicit",
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (opts.conversationCandidates.length === 0) {
|
|
95
|
+
return { kind: "reject", reason: "context_missing" };
|
|
96
|
+
}
|
|
97
|
+
if (opts.conversationCandidates.length > 1) {
|
|
98
|
+
return {
|
|
99
|
+
kind: "reject",
|
|
100
|
+
reason: "context_ambiguous",
|
|
101
|
+
details: `candidates=${opts.conversationCandidates.join(",")}`,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const only = opts.conversationCandidates[0];
|
|
105
|
+
if (!opts.validate(only)) {
|
|
106
|
+
return { kind: "reject", reason: "cli_validation_failed", details: opts.invalidDetails };
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
kind: "resolved",
|
|
110
|
+
value: only,
|
|
111
|
+
source: "conversation",
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function normalizeTargetlessArgs(args) {
|
|
115
|
+
return args.map((arg) => arg.trim()).filter((arg) => arg.length > 0);
|
|
116
|
+
}
|
|
117
|
+
export class CommandContextResolver {
|
|
118
|
+
#allowedRepoRoots;
|
|
119
|
+
constructor(opts = {}) {
|
|
120
|
+
if (!opts.allowedRepoRoots || opts.allowedRepoRoots.length === 0) {
|
|
121
|
+
this.#allowedRepoRoots = null;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this.#allowedRepoRoots = new Set(opts.allowedRepoRoots.map((path) => resolvePath(path)));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
resolve(opts) {
|
|
128
|
+
const repoRoot = resolvePath(opts.repoRoot);
|
|
129
|
+
if (this.#allowedRepoRoots && !this.#allowedRepoRoots.has(repoRoot)) {
|
|
130
|
+
return reject("context_unauthorized", `repo_root=${repoRoot}`);
|
|
131
|
+
}
|
|
132
|
+
const args = normalizeTargetlessArgs(opts.args);
|
|
133
|
+
const metadata = opts.metadata ?? {};
|
|
134
|
+
if (ISSUE_TARGET_COMMANDS.has(opts.commandKey)) {
|
|
135
|
+
const explicit = args[0];
|
|
136
|
+
const resolved = resolveFromCandidates({
|
|
137
|
+
explicitValue: explicit,
|
|
138
|
+
conversationCandidates: collectIssueCandidates({
|
|
139
|
+
inboundTargetType: opts.inboundTargetType,
|
|
140
|
+
inboundTargetId: opts.inboundTargetId,
|
|
141
|
+
metadata,
|
|
142
|
+
}),
|
|
143
|
+
validate: (value) => ISSUE_ID_RE.test(value),
|
|
144
|
+
invalidDetails: "issue id must match /^mu-[a-z0-9][a-z0-9-]*$/",
|
|
145
|
+
});
|
|
146
|
+
if (resolved.kind === "reject") {
|
|
147
|
+
return resolved;
|
|
148
|
+
}
|
|
149
|
+
const rest = explicit != null ? args.slice(1) : args;
|
|
150
|
+
const resolvedArgs = [resolved.value, ...rest];
|
|
151
|
+
return {
|
|
152
|
+
kind: "resolved",
|
|
153
|
+
repoRoot,
|
|
154
|
+
commandKey: opts.commandKey,
|
|
155
|
+
args: resolvedArgs,
|
|
156
|
+
normalizedText: [opts.commandKey, ...resolvedArgs].join(" ").trim(),
|
|
157
|
+
targetId: resolved.value,
|
|
158
|
+
source: resolved.source,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (TOPIC_TARGET_COMMANDS.has(opts.commandKey)) {
|
|
162
|
+
const explicit = args[0];
|
|
163
|
+
const resolved = resolveFromCandidates({
|
|
164
|
+
explicitValue: explicit,
|
|
165
|
+
conversationCandidates: collectTopicCandidates({
|
|
166
|
+
inboundTargetType: opts.inboundTargetType,
|
|
167
|
+
inboundTargetId: opts.inboundTargetId,
|
|
168
|
+
metadata,
|
|
169
|
+
}),
|
|
170
|
+
validate: (value) => SAFE_TOPIC_RE.test(value),
|
|
171
|
+
invalidDetails: "topic must match /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,199}$/",
|
|
172
|
+
});
|
|
173
|
+
if (resolved.kind === "reject") {
|
|
174
|
+
return resolved;
|
|
175
|
+
}
|
|
176
|
+
const rest = explicit != null ? args.slice(1) : args;
|
|
177
|
+
const resolvedArgs = [resolved.value, ...rest];
|
|
178
|
+
return {
|
|
179
|
+
kind: "resolved",
|
|
180
|
+
repoRoot,
|
|
181
|
+
commandKey: opts.commandKey,
|
|
182
|
+
args: resolvedArgs,
|
|
183
|
+
normalizedText: [opts.commandKey, ...resolvedArgs].join(" ").trim(),
|
|
184
|
+
targetId: resolved.value,
|
|
185
|
+
source: resolved.source,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
if (GENERIC_TARGET_COMMANDS.has(opts.commandKey)) {
|
|
189
|
+
const explicit = args[0];
|
|
190
|
+
if (!explicit) {
|
|
191
|
+
return reject("context_missing");
|
|
192
|
+
}
|
|
193
|
+
if (!SAFE_TARGET_RE.test(explicit)) {
|
|
194
|
+
return reject("cli_validation_failed", "target contains unsafe characters");
|
|
195
|
+
}
|
|
196
|
+
if (args.length > 1) {
|
|
197
|
+
return reject("cli_validation_failed", "unexpected extra target arguments");
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
kind: "resolved",
|
|
201
|
+
repoRoot,
|
|
202
|
+
commandKey: opts.commandKey,
|
|
203
|
+
args: [explicit],
|
|
204
|
+
normalizedText: [opts.commandKey, explicit].join(" "),
|
|
205
|
+
targetId: explicit,
|
|
206
|
+
source: "explicit",
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const normalizedArgs = normalizeTargetlessArgs(args);
|
|
210
|
+
const normalizedText = [opts.commandKey, ...normalizedArgs].join(" ").trim();
|
|
211
|
+
return {
|
|
212
|
+
kind: "resolved",
|
|
213
|
+
repoRoot,
|
|
214
|
+
commandKey: opts.commandKey,
|
|
215
|
+
args: normalizedArgs,
|
|
216
|
+
normalizedText,
|
|
217
|
+
targetId: readString(opts.inboundTargetId) ?? opts.commandKey,
|
|
218
|
+
source: "none",
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CommandContextResolver } from "./command_context.js";
|
|
3
|
+
export type MessagingMetaInboundEnvelope = {
|
|
4
|
+
channel: string;
|
|
5
|
+
channel_tenant_id: string;
|
|
6
|
+
channel_conversation_id: string;
|
|
7
|
+
request_id: string;
|
|
8
|
+
repo_root: string;
|
|
9
|
+
command_text: string;
|
|
10
|
+
target_type: string;
|
|
11
|
+
target_id: string;
|
|
12
|
+
metadata: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
export type MessagingMetaIdentityBinding = {
|
|
15
|
+
binding_id: string;
|
|
16
|
+
assurance_tier: string;
|
|
17
|
+
};
|
|
18
|
+
type InboundEnvelope = MessagingMetaInboundEnvelope;
|
|
19
|
+
type IdentityBinding = MessagingMetaIdentityBinding;
|
|
20
|
+
export declare const MetaApprovedCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
21
|
+
kind: z.ZodLiteral<"status">;
|
|
22
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
23
|
+
kind: z.ZodLiteral<"ready">;
|
|
24
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
25
|
+
kind: z.ZodLiteral<"issue_list">;
|
|
26
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
27
|
+
kind: z.ZodLiteral<"issue_get">;
|
|
28
|
+
issue_id: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
+
kind: z.ZodLiteral<"forum_read">;
|
|
31
|
+
topic: z.ZodOptional<z.ZodString>;
|
|
32
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
34
|
+
kind: z.ZodLiteral<"run_resume">;
|
|
35
|
+
root_issue_id: z.ZodOptional<z.ZodString>;
|
|
36
|
+
max_steps: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
38
|
+
kind: z.ZodLiteral<"run_start">;
|
|
39
|
+
prompt: z.ZodString;
|
|
40
|
+
max_steps: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
}, z.core.$strip>], "kind">;
|
|
42
|
+
export type MetaApprovedCommand = z.infer<typeof MetaApprovedCommandSchema>;
|
|
43
|
+
export declare const MetaAgentBackendTurnResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
44
|
+
kind: z.ZodLiteral<"respond">;
|
|
45
|
+
message: z.ZodString;
|
|
46
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
47
|
+
kind: z.ZodLiteral<"command">;
|
|
48
|
+
command: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
49
|
+
kind: z.ZodLiteral<"status">;
|
|
50
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
51
|
+
kind: z.ZodLiteral<"ready">;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
kind: z.ZodLiteral<"issue_list">;
|
|
54
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
55
|
+
kind: z.ZodLiteral<"issue_get">;
|
|
56
|
+
issue_id: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
58
|
+
kind: z.ZodLiteral<"forum_read">;
|
|
59
|
+
topic: z.ZodOptional<z.ZodString>;
|
|
60
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
62
|
+
kind: z.ZodLiteral<"run_resume">;
|
|
63
|
+
root_issue_id: z.ZodOptional<z.ZodString>;
|
|
64
|
+
max_steps: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
66
|
+
kind: z.ZodLiteral<"run_start">;
|
|
67
|
+
prompt: z.ZodString;
|
|
68
|
+
max_steps: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
}, z.core.$strip>], "kind">;
|
|
70
|
+
}, z.core.$strip>], "kind">;
|
|
71
|
+
export type MetaAgentBackendTurnResult = z.infer<typeof MetaAgentBackendTurnResultSchema>;
|
|
72
|
+
export type MetaAgentBackendTurnInput = {
|
|
73
|
+
sessionId: string;
|
|
74
|
+
turnId: string;
|
|
75
|
+
inbound: InboundEnvelope;
|
|
76
|
+
binding: IdentityBinding;
|
|
77
|
+
};
|
|
78
|
+
export interface MessagingMetaAgentBackend {
|
|
79
|
+
runTurn(input: MetaAgentBackendTurnInput): Promise<MetaAgentBackendTurnResult>;
|
|
80
|
+
}
|
|
81
|
+
export type MetaAgentDecision = {
|
|
82
|
+
kind: "response";
|
|
83
|
+
message: string;
|
|
84
|
+
metaSessionId: string;
|
|
85
|
+
metaTurnId: string;
|
|
86
|
+
} | {
|
|
87
|
+
kind: "command";
|
|
88
|
+
commandText: string;
|
|
89
|
+
metaSessionId: string;
|
|
90
|
+
metaTurnId: string;
|
|
91
|
+
} | {
|
|
92
|
+
kind: "reject";
|
|
93
|
+
reason: "meta_agent_disabled" | "meta_agent_action_disallowed" | "meta_agent_invalid_output" | "context_missing" | "context_ambiguous" | "context_unauthorized" | "cli_validation_failed";
|
|
94
|
+
details?: string;
|
|
95
|
+
metaSessionId: string;
|
|
96
|
+
metaTurnId: string;
|
|
97
|
+
};
|
|
98
|
+
export type ApprovedCommandBrokerOpts = {
|
|
99
|
+
contextResolver?: CommandContextResolver;
|
|
100
|
+
runTriggersEnabled?: boolean;
|
|
101
|
+
};
|
|
102
|
+
export declare class ApprovedCommandBroker {
|
|
103
|
+
#private;
|
|
104
|
+
constructor(opts?: ApprovedCommandBrokerOpts);
|
|
105
|
+
approve(opts: {
|
|
106
|
+
proposal: MetaApprovedCommand;
|
|
107
|
+
inbound: InboundEnvelope;
|
|
108
|
+
}): {
|
|
109
|
+
kind: "approved";
|
|
110
|
+
commandText: string;
|
|
111
|
+
} | {
|
|
112
|
+
kind: "reject";
|
|
113
|
+
reason: "meta_agent_action_disallowed" | "context_missing" | "context_ambiguous" | "context_unauthorized" | "cli_validation_failed";
|
|
114
|
+
details?: string;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export type MessagingMetaAgentRuntimeOpts = {
|
|
118
|
+
backend: MessagingMetaAgentBackend;
|
|
119
|
+
broker?: ApprovedCommandBroker;
|
|
120
|
+
enabled?: boolean;
|
|
121
|
+
enabledChannels?: readonly string[];
|
|
122
|
+
sessionIdFactory?: () => string;
|
|
123
|
+
turnIdFactory?: () => string;
|
|
124
|
+
};
|
|
125
|
+
export declare class MessagingMetaAgentRuntime {
|
|
126
|
+
#private;
|
|
127
|
+
constructor(opts: MessagingMetaAgentRuntimeOpts);
|
|
128
|
+
handleInbound(opts: {
|
|
129
|
+
inbound: InboundEnvelope;
|
|
130
|
+
binding: IdentityBinding;
|
|
131
|
+
}): Promise<MetaAgentDecision>;
|
|
132
|
+
}
|
|
133
|
+
export type PiMessagingMetaAgentBackendOpts = {
|
|
134
|
+
provider?: string;
|
|
135
|
+
model?: string;
|
|
136
|
+
thinking?: string;
|
|
137
|
+
systemPrompt?: string;
|
|
138
|
+
timeoutMs?: number;
|
|
139
|
+
piBinary?: string;
|
|
140
|
+
};
|
|
141
|
+
export declare class PiMessagingMetaAgentBackend implements MessagingMetaAgentBackend {
|
|
142
|
+
#private;
|
|
143
|
+
constructor(opts?: PiMessagingMetaAgentBackendOpts);
|
|
144
|
+
runTurn(input: MetaAgentBackendTurnInput): Promise<MetaAgentBackendTurnResult>;
|
|
145
|
+
}
|
|
146
|
+
export {};
|
|
147
|
+
//# sourceMappingURL=meta_agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta_agent.d.ts","sourceRoot":"","sources":["../src/meta_agent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,MAAM,4BAA4B,GAAG;IAC1C,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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