@femtomc/mu-control-plane 26.2.28
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 +29 -0
- package/dist/adapter_audit.d.ts +27 -0
- package/dist/adapter_audit.d.ts.map +1 -0
- package/dist/adapter_audit.js +57 -0
- package/dist/channel_adapters.d.ts +53 -0
- package/dist/channel_adapters.d.ts.map +1 -0
- package/dist/channel_adapters.js +734 -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/command_journal.d.ts +308 -0
- package/dist/command_journal.d.ts.map +1 -0
- package/dist/command_journal.js +197 -0
- package/dist/command_parser.d.ts +31 -0
- package/dist/command_parser.d.ts.map +1 -0
- package/dist/command_parser.js +130 -0
- package/dist/command_pipeline.d.ts +100 -0
- package/dist/command_pipeline.d.ts.map +1 -0
- package/dist/command_pipeline.js +637 -0
- package/dist/command_record.d.ts +89 -0
- package/dist/command_record.d.ts.map +1 -0
- package/dist/command_record.js +138 -0
- package/dist/command_state.d.ts +29 -0
- package/dist/command_state.d.ts.map +1 -0
- package/dist/command_state.js +64 -0
- package/dist/confirmation_manager.d.ts +54 -0
- package/dist/confirmation_manager.d.ts.map +1 -0
- package/dist/confirmation_manager.js +99 -0
- package/dist/idempotency_ledger.d.ts +84 -0
- package/dist/idempotency_ledger.d.ts.map +1 -0
- package/dist/idempotency_ledger.js +174 -0
- package/dist/identity_store.d.ts +219 -0
- package/dist/identity_store.d.ts.map +1 -0
- package/dist/identity_store.js +323 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/meta_agent.d.ts +127 -0
- package/dist/meta_agent.d.ts.map +1 -0
- package/dist/meta_agent.js +415 -0
- package/dist/models.d.ts +132 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +62 -0
- package/dist/mu_cli_runner.d.ts +76 -0
- package/dist/mu_cli_runner.d.ts.map +1 -0
- package/dist/mu_cli_runner.js +364 -0
- package/dist/operator_tooling.d.ts +19 -0
- package/dist/operator_tooling.d.ts.map +1 -0
- package/dist/operator_tooling.js +126 -0
- package/dist/outbox.d.ts +253 -0
- package/dist/outbox.d.ts.map +1 -0
- package/dist/outbox.js +313 -0
- package/dist/paths.d.ts +13 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +15 -0
- package/dist/policy.d.ts +182 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +434 -0
- package/dist/runtime.d.ts +79 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +260 -0
- package/dist/serialized_mutation_executor.d.ts +5 -0
- package/dist/serialized_mutation_executor.d.ts.map +1 -0
- package/dist/serialized_mutation_executor.js +8 -0
- package/dist/writer_lock.d.ts +28 -0
- package/dist/writer_lock.d.ts.map +1 -0
- package/dist/writer_lock.js +97 -0
- package/package.json +18 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { appendJsonl, readJsonl } from "@femtomc/mu-core/node";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { AssuranceTierSchema } from "./models.js";
|
|
4
|
+
export const ChannelSchema = z.enum(["slack", "discord", "telegram"]);
|
|
5
|
+
export const DeprecatedChannelSchema = z.enum(["imessage"]);
|
|
6
|
+
export const CHANNEL_ASSURANCE_TIERS = {
|
|
7
|
+
slack: "tier_a",
|
|
8
|
+
discord: "tier_a",
|
|
9
|
+
telegram: "tier_b",
|
|
10
|
+
};
|
|
11
|
+
export function assuranceTierForChannel(channel) {
|
|
12
|
+
return CHANNEL_ASSURANCE_TIERS[channel];
|
|
13
|
+
}
|
|
14
|
+
export const IdentityBindingStatusSchema = z.enum(["active", "unlinked", "revoked"]);
|
|
15
|
+
export const IdentityBindingSchema = z.object({
|
|
16
|
+
binding_id: z.string().min(1),
|
|
17
|
+
operator_id: z.string().min(1),
|
|
18
|
+
channel: ChannelSchema,
|
|
19
|
+
channel_tenant_id: z.string().min(1),
|
|
20
|
+
channel_actor_id: z.string().min(1),
|
|
21
|
+
assurance_tier: AssuranceTierSchema,
|
|
22
|
+
scopes: z.array(z.string().min(1)).default([]),
|
|
23
|
+
status: IdentityBindingStatusSchema,
|
|
24
|
+
linked_at_ms: z.number().int(),
|
|
25
|
+
updated_at_ms: z.number().int(),
|
|
26
|
+
unlinked_at_ms: z.number().int().nullable().default(null),
|
|
27
|
+
revoked_at_ms: z.number().int().nullable().default(null),
|
|
28
|
+
revoked_by_binding_id: z.string().min(1).nullable().default(null),
|
|
29
|
+
revoke_reason: z.string().nullable().default(null),
|
|
30
|
+
});
|
|
31
|
+
export const IdentityLinkEntrySchema = z.object({
|
|
32
|
+
kind: z.literal("link"),
|
|
33
|
+
ts_ms: z.number().int(),
|
|
34
|
+
binding: IdentityBindingSchema,
|
|
35
|
+
});
|
|
36
|
+
export const IdentityUnlinkEntrySchema = z.object({
|
|
37
|
+
kind: z.literal("unlink"),
|
|
38
|
+
ts_ms: z.number().int(),
|
|
39
|
+
binding_id: z.string().min(1),
|
|
40
|
+
actor_binding_id: z.string().min(1),
|
|
41
|
+
reason: z.string().nullable().default(null),
|
|
42
|
+
});
|
|
43
|
+
export const IdentityRevokeEntrySchema = z.object({
|
|
44
|
+
kind: z.literal("revoke"),
|
|
45
|
+
ts_ms: z.number().int(),
|
|
46
|
+
binding_id: z.string().min(1),
|
|
47
|
+
actor_binding_id: z.string().min(1),
|
|
48
|
+
reason: z.string().nullable().default(null),
|
|
49
|
+
});
|
|
50
|
+
export const IdentityStoreEntrySchema = z.discriminatedUnion("kind", [
|
|
51
|
+
IdentityLinkEntrySchema,
|
|
52
|
+
IdentityUnlinkEntrySchema,
|
|
53
|
+
IdentityRevokeEntrySchema,
|
|
54
|
+
]);
|
|
55
|
+
const DeprecatedIdentityLinkEntrySchema = z
|
|
56
|
+
.object({
|
|
57
|
+
kind: z.literal("link"),
|
|
58
|
+
ts_ms: z.number().int(),
|
|
59
|
+
binding: z
|
|
60
|
+
.object({
|
|
61
|
+
binding_id: z.string().min(1),
|
|
62
|
+
channel: DeprecatedChannelSchema,
|
|
63
|
+
})
|
|
64
|
+
.passthrough(),
|
|
65
|
+
})
|
|
66
|
+
.passthrough();
|
|
67
|
+
function bindingPrincipalKey(binding) {
|
|
68
|
+
return `${binding.channel}::${binding.channel_tenant_id}::${binding.channel_actor_id}`;
|
|
69
|
+
}
|
|
70
|
+
function resolvePrincipalKey(opts) {
|
|
71
|
+
return `${opts.channel}::${opts.channelTenantId}::${opts.channelActorId}`;
|
|
72
|
+
}
|
|
73
|
+
function cloneBinding(binding) {
|
|
74
|
+
return IdentityBindingSchema.parse(binding);
|
|
75
|
+
}
|
|
76
|
+
function assertBindingTier(binding) {
|
|
77
|
+
const expected = assuranceTierForChannel(binding.channel);
|
|
78
|
+
if (binding.assurance_tier !== expected) {
|
|
79
|
+
throw new Error(`binding ${binding.binding_id} has invalid assurance tier ${binding.assurance_tier} for channel ${binding.channel} (expected ${expected})`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export class IdentityStore {
|
|
83
|
+
#path;
|
|
84
|
+
#loaded = false;
|
|
85
|
+
#bindingsById = new Map();
|
|
86
|
+
#activeByPrincipal = new Map();
|
|
87
|
+
#deprecatedBindingIds = new Set();
|
|
88
|
+
#deprecations = [];
|
|
89
|
+
constructor(path) {
|
|
90
|
+
this.#path = path;
|
|
91
|
+
}
|
|
92
|
+
get path() {
|
|
93
|
+
return this.#path;
|
|
94
|
+
}
|
|
95
|
+
listDeprecations() {
|
|
96
|
+
return this.#deprecations.map((entry) => ({ ...entry }));
|
|
97
|
+
}
|
|
98
|
+
async load() {
|
|
99
|
+
const rows = await readJsonl(this.#path);
|
|
100
|
+
this.#bindingsById.clear();
|
|
101
|
+
this.#activeByPrincipal.clear();
|
|
102
|
+
this.#deprecatedBindingIds.clear();
|
|
103
|
+
this.#deprecations.length = 0;
|
|
104
|
+
for (let idx = 0; idx < rows.length; idx++) {
|
|
105
|
+
const parsed = IdentityStoreEntrySchema.safeParse(rows[idx]);
|
|
106
|
+
if (!parsed.success) {
|
|
107
|
+
const deprecated = DeprecatedIdentityLinkEntrySchema.safeParse(rows[idx]);
|
|
108
|
+
if (deprecated.success) {
|
|
109
|
+
this.#recordDeprecatedChannelBinding({
|
|
110
|
+
bindingId: deprecated.data.binding.binding_id,
|
|
111
|
+
channel: deprecated.data.binding.channel,
|
|
112
|
+
tsMs: deprecated.data.ts_ms,
|
|
113
|
+
});
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
throw new Error(`invalid identity row ${idx}: ${parsed.error.message}`);
|
|
117
|
+
}
|
|
118
|
+
this.#applyEntry(parsed.data, { replay: true });
|
|
119
|
+
}
|
|
120
|
+
this.#loaded = true;
|
|
121
|
+
}
|
|
122
|
+
async #ensureLoaded() {
|
|
123
|
+
if (!this.#loaded) {
|
|
124
|
+
await this.load();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
#recordDeprecatedChannelBinding(opts) {
|
|
128
|
+
this.#deprecatedBindingIds.add(opts.bindingId);
|
|
129
|
+
this.#deprecations.push({
|
|
130
|
+
reason: "channel_deprecated",
|
|
131
|
+
bindingId: opts.bindingId,
|
|
132
|
+
channel: opts.channel,
|
|
133
|
+
tsMs: opts.tsMs,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
#applyEntry(entry, opts) {
|
|
137
|
+
switch (entry.kind) {
|
|
138
|
+
case "link": {
|
|
139
|
+
assertBindingTier(entry.binding);
|
|
140
|
+
this.#bindingsById.set(entry.binding.binding_id, cloneBinding(entry.binding));
|
|
141
|
+
if (entry.binding.status === "active") {
|
|
142
|
+
this.#activeByPrincipal.set(bindingPrincipalKey(entry.binding), entry.binding.binding_id);
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case "unlink": {
|
|
147
|
+
const current = this.#bindingsById.get(entry.binding_id);
|
|
148
|
+
if (!current) {
|
|
149
|
+
if (this.#deprecatedBindingIds.has(entry.binding_id)) {
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
if (opts.replay) {
|
|
153
|
+
throw new Error(`identity unlink references unknown binding: ${entry.binding_id}`);
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
const next = IdentityBindingSchema.parse({
|
|
158
|
+
...current,
|
|
159
|
+
status: "unlinked",
|
|
160
|
+
updated_at_ms: entry.ts_ms,
|
|
161
|
+
unlinked_at_ms: entry.ts_ms,
|
|
162
|
+
});
|
|
163
|
+
this.#bindingsById.set(next.binding_id, next);
|
|
164
|
+
this.#activeByPrincipal.delete(bindingPrincipalKey(current));
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case "revoke": {
|
|
168
|
+
const current = this.#bindingsById.get(entry.binding_id);
|
|
169
|
+
if (!current) {
|
|
170
|
+
if (this.#deprecatedBindingIds.has(entry.binding_id)) {
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
if (opts.replay) {
|
|
174
|
+
throw new Error(`identity revoke references unknown binding: ${entry.binding_id}`);
|
|
175
|
+
}
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
const next = IdentityBindingSchema.parse({
|
|
179
|
+
...current,
|
|
180
|
+
status: "revoked",
|
|
181
|
+
updated_at_ms: entry.ts_ms,
|
|
182
|
+
revoked_at_ms: entry.ts_ms,
|
|
183
|
+
revoked_by_binding_id: entry.actor_binding_id,
|
|
184
|
+
revoke_reason: entry.reason,
|
|
185
|
+
});
|
|
186
|
+
this.#bindingsById.set(next.binding_id, next);
|
|
187
|
+
this.#activeByPrincipal.delete(bindingPrincipalKey(current));
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
get(bindingId) {
|
|
193
|
+
const binding = this.#bindingsById.get(bindingId);
|
|
194
|
+
return binding ? cloneBinding(binding) : null;
|
|
195
|
+
}
|
|
196
|
+
resolveActive(opts) {
|
|
197
|
+
const principal = resolvePrincipalKey(opts);
|
|
198
|
+
const bindingId = this.#activeByPrincipal.get(principal);
|
|
199
|
+
if (!bindingId) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
const binding = this.#bindingsById.get(bindingId);
|
|
203
|
+
if (!binding || binding.status !== "active") {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
return cloneBinding(binding);
|
|
207
|
+
}
|
|
208
|
+
listBindings(opts = {}) {
|
|
209
|
+
const includeInactive = opts.includeInactive ?? false;
|
|
210
|
+
const out = [];
|
|
211
|
+
for (const binding of this.#bindingsById.values()) {
|
|
212
|
+
if (!includeInactive && binding.status !== "active") {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
out.push(cloneBinding(binding));
|
|
216
|
+
}
|
|
217
|
+
out.sort((a, b) => {
|
|
218
|
+
if (a.linked_at_ms !== b.linked_at_ms) {
|
|
219
|
+
return a.linked_at_ms - b.linked_at_ms;
|
|
220
|
+
}
|
|
221
|
+
return a.binding_id.localeCompare(b.binding_id);
|
|
222
|
+
});
|
|
223
|
+
return out;
|
|
224
|
+
}
|
|
225
|
+
async link(opts) {
|
|
226
|
+
await this.#ensureLoaded();
|
|
227
|
+
const channel = ChannelSchema.parse(opts.channel);
|
|
228
|
+
const nowMs = Math.trunc(opts.nowMs ?? Date.now());
|
|
229
|
+
const existingById = this.#bindingsById.get(opts.bindingId);
|
|
230
|
+
if (existingById) {
|
|
231
|
+
return { kind: "binding_exists", binding: cloneBinding(existingById) };
|
|
232
|
+
}
|
|
233
|
+
const principal = resolvePrincipalKey({
|
|
234
|
+
channel,
|
|
235
|
+
channelTenantId: opts.channelTenantId,
|
|
236
|
+
channelActorId: opts.channelActorId,
|
|
237
|
+
});
|
|
238
|
+
const existingPrincipalBindingId = this.#activeByPrincipal.get(principal);
|
|
239
|
+
if (existingPrincipalBindingId) {
|
|
240
|
+
const existing = this.#bindingsById.get(existingPrincipalBindingId);
|
|
241
|
+
if (existing) {
|
|
242
|
+
return { kind: "principal_already_linked", binding: cloneBinding(existing) };
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const binding = IdentityBindingSchema.parse({
|
|
246
|
+
binding_id: opts.bindingId,
|
|
247
|
+
operator_id: opts.operatorId,
|
|
248
|
+
channel,
|
|
249
|
+
channel_tenant_id: opts.channelTenantId,
|
|
250
|
+
channel_actor_id: opts.channelActorId,
|
|
251
|
+
assurance_tier: assuranceTierForChannel(channel),
|
|
252
|
+
scopes: [...(opts.scopes ?? [])],
|
|
253
|
+
status: "active",
|
|
254
|
+
linked_at_ms: nowMs,
|
|
255
|
+
updated_at_ms: nowMs,
|
|
256
|
+
unlinked_at_ms: null,
|
|
257
|
+
revoked_at_ms: null,
|
|
258
|
+
revoked_by_binding_id: null,
|
|
259
|
+
revoke_reason: null,
|
|
260
|
+
});
|
|
261
|
+
const entry = IdentityLinkEntrySchema.parse({
|
|
262
|
+
kind: "link",
|
|
263
|
+
ts_ms: nowMs,
|
|
264
|
+
binding,
|
|
265
|
+
});
|
|
266
|
+
await appendJsonl(this.#path, entry);
|
|
267
|
+
this.#applyEntry(entry, { replay: false });
|
|
268
|
+
return { kind: "linked", binding: cloneBinding(binding) };
|
|
269
|
+
}
|
|
270
|
+
async unlinkSelf(opts) {
|
|
271
|
+
await this.#ensureLoaded();
|
|
272
|
+
const current = this.#bindingsById.get(opts.bindingId);
|
|
273
|
+
if (!current) {
|
|
274
|
+
return { kind: "not_found" };
|
|
275
|
+
}
|
|
276
|
+
if (current.status !== "active") {
|
|
277
|
+
return { kind: "already_inactive", binding: cloneBinding(current) };
|
|
278
|
+
}
|
|
279
|
+
if (opts.actorBindingId !== opts.bindingId) {
|
|
280
|
+
return { kind: "invalid_actor" };
|
|
281
|
+
}
|
|
282
|
+
const nowMs = Math.trunc(opts.nowMs ?? Date.now());
|
|
283
|
+
const entry = IdentityUnlinkEntrySchema.parse({
|
|
284
|
+
kind: "unlink",
|
|
285
|
+
ts_ms: nowMs,
|
|
286
|
+
binding_id: opts.bindingId,
|
|
287
|
+
actor_binding_id: opts.actorBindingId,
|
|
288
|
+
reason: opts.reason ?? null,
|
|
289
|
+
});
|
|
290
|
+
await appendJsonl(this.#path, entry);
|
|
291
|
+
this.#applyEntry(entry, { replay: false });
|
|
292
|
+
const updated = this.#bindingsById.get(opts.bindingId);
|
|
293
|
+
if (!updated) {
|
|
294
|
+
throw new Error(`identity binding missing after unlink: ${opts.bindingId}`);
|
|
295
|
+
}
|
|
296
|
+
return { kind: "unlinked", binding: cloneBinding(updated) };
|
|
297
|
+
}
|
|
298
|
+
async revoke(opts) {
|
|
299
|
+
await this.#ensureLoaded();
|
|
300
|
+
const current = this.#bindingsById.get(opts.bindingId);
|
|
301
|
+
if (!current) {
|
|
302
|
+
return { kind: "not_found" };
|
|
303
|
+
}
|
|
304
|
+
if (current.status !== "active") {
|
|
305
|
+
return { kind: "already_inactive", binding: cloneBinding(current) };
|
|
306
|
+
}
|
|
307
|
+
const nowMs = Math.trunc(opts.nowMs ?? Date.now());
|
|
308
|
+
const entry = IdentityRevokeEntrySchema.parse({
|
|
309
|
+
kind: "revoke",
|
|
310
|
+
ts_ms: nowMs,
|
|
311
|
+
binding_id: opts.bindingId,
|
|
312
|
+
actor_binding_id: opts.actorBindingId,
|
|
313
|
+
reason: opts.reason ?? null,
|
|
314
|
+
});
|
|
315
|
+
await appendJsonl(this.#path, entry);
|
|
316
|
+
this.#applyEntry(entry, { replay: false });
|
|
317
|
+
const updated = this.#bindingsById.get(opts.bindingId);
|
|
318
|
+
if (!updated) {
|
|
319
|
+
throw new Error(`identity binding missing after revoke: ${opts.bindingId}`);
|
|
320
|
+
}
|
|
321
|
+
return { kind: "revoked", binding: cloneBinding(updated) };
|
|
322
|
+
}
|
|
323
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from "./adapter_audit.js";
|
|
2
|
+
export * from "./channel_adapters.js";
|
|
3
|
+
export * from "./command_context.js";
|
|
4
|
+
export * from "./command_journal.js";
|
|
5
|
+
export * from "./command_parser.js";
|
|
6
|
+
export * from "./command_pipeline.js";
|
|
7
|
+
export * from "./command_record.js";
|
|
8
|
+
export * from "./command_state.js";
|
|
9
|
+
export * from "./confirmation_manager.js";
|
|
10
|
+
export * from "./idempotency_ledger.js";
|
|
11
|
+
export * from "./identity_store.js";
|
|
12
|
+
export * from "./meta_agent.js";
|
|
13
|
+
export * from "./models.js";
|
|
14
|
+
export * from "./mu_cli_runner.js";
|
|
15
|
+
export * from "./operator_tooling.js";
|
|
16
|
+
export * from "./outbox.js";
|
|
17
|
+
export * from "./paths.js";
|
|
18
|
+
export * from "./policy.js";
|
|
19
|
+
export * from "./runtime.js";
|
|
20
|
+
export * from "./serialized_mutation_executor.js";
|
|
21
|
+
export * from "./writer_lock.js";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,mCAAmC,CAAC;AAClD,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from "./adapter_audit.js";
|
|
2
|
+
export * from "./channel_adapters.js";
|
|
3
|
+
export * from "./command_context.js";
|
|
4
|
+
export * from "./command_journal.js";
|
|
5
|
+
export * from "./command_parser.js";
|
|
6
|
+
export * from "./command_pipeline.js";
|
|
7
|
+
export * from "./command_record.js";
|
|
8
|
+
export * from "./command_state.js";
|
|
9
|
+
export * from "./confirmation_manager.js";
|
|
10
|
+
export * from "./idempotency_ledger.js";
|
|
11
|
+
export * from "./identity_store.js";
|
|
12
|
+
export * from "./meta_agent.js";
|
|
13
|
+
export * from "./models.js";
|
|
14
|
+
export * from "./mu_cli_runner.js";
|
|
15
|
+
export * from "./operator_tooling.js";
|
|
16
|
+
export * from "./outbox.js";
|
|
17
|
+
export * from "./paths.js";
|
|
18
|
+
export * from "./policy.js";
|
|
19
|
+
export * from "./runtime.js";
|
|
20
|
+
export * from "./serialized_mutation_executor.js";
|
|
21
|
+
export * from "./writer_lock.js";
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CommandContextResolver } from "./command_context.js";
|
|
3
|
+
import type { IdentityBinding } from "./identity_store.js";
|
|
4
|
+
import type { InboundEnvelope } from "./models.js";
|
|
5
|
+
export declare const MetaApprovedCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
6
|
+
kind: z.ZodLiteral<"status">;
|
|
7
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
8
|
+
kind: z.ZodLiteral<"ready">;
|
|
9
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
10
|
+
kind: z.ZodLiteral<"issue_get">;
|
|
11
|
+
issue_id: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
13
|
+
kind: z.ZodLiteral<"forum_read">;
|
|
14
|
+
topic: z.ZodOptional<z.ZodString>;
|
|
15
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
16
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
17
|
+
kind: z.ZodLiteral<"run_resume">;
|
|
18
|
+
root_issue_id: z.ZodOptional<z.ZodString>;
|
|
19
|
+
max_steps: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
21
|
+
kind: z.ZodLiteral<"run_start">;
|
|
22
|
+
prompt: z.ZodString;
|
|
23
|
+
max_steps: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
}, z.core.$strip>], "kind">;
|
|
25
|
+
export type MetaApprovedCommand = z.infer<typeof MetaApprovedCommandSchema>;
|
|
26
|
+
export declare const MetaAgentBackendTurnResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
27
|
+
kind: z.ZodLiteral<"respond">;
|
|
28
|
+
message: z.ZodString;
|
|
29
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
+
kind: z.ZodLiteral<"command">;
|
|
31
|
+
command: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
32
|
+
kind: z.ZodLiteral<"status">;
|
|
33
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
34
|
+
kind: z.ZodLiteral<"ready">;
|
|
35
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
36
|
+
kind: z.ZodLiteral<"issue_get">;
|
|
37
|
+
issue_id: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
39
|
+
kind: z.ZodLiteral<"forum_read">;
|
|
40
|
+
topic: z.ZodOptional<z.ZodString>;
|
|
41
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
+
kind: z.ZodLiteral<"run_resume">;
|
|
44
|
+
root_issue_id: z.ZodOptional<z.ZodString>;
|
|
45
|
+
max_steps: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
47
|
+
kind: z.ZodLiteral<"run_start">;
|
|
48
|
+
prompt: z.ZodString;
|
|
49
|
+
max_steps: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
}, z.core.$strip>], "kind">;
|
|
51
|
+
}, z.core.$strip>], "kind">;
|
|
52
|
+
export type MetaAgentBackendTurnResult = z.infer<typeof MetaAgentBackendTurnResultSchema>;
|
|
53
|
+
export type MetaAgentBackendTurnInput = {
|
|
54
|
+
sessionId: string;
|
|
55
|
+
turnId: string;
|
|
56
|
+
inbound: InboundEnvelope;
|
|
57
|
+
binding: IdentityBinding;
|
|
58
|
+
};
|
|
59
|
+
export interface MessagingMetaAgentBackend {
|
|
60
|
+
runTurn(input: MetaAgentBackendTurnInput): Promise<MetaAgentBackendTurnResult>;
|
|
61
|
+
}
|
|
62
|
+
export type MetaAgentDecision = {
|
|
63
|
+
kind: "response";
|
|
64
|
+
message: string;
|
|
65
|
+
metaSessionId: string;
|
|
66
|
+
metaTurnId: string;
|
|
67
|
+
} | {
|
|
68
|
+
kind: "command";
|
|
69
|
+
commandText: string;
|
|
70
|
+
metaSessionId: string;
|
|
71
|
+
metaTurnId: string;
|
|
72
|
+
} | {
|
|
73
|
+
kind: "reject";
|
|
74
|
+
reason: "meta_agent_disabled" | "meta_agent_action_disallowed" | "meta_agent_invalid_output" | "context_missing" | "context_ambiguous" | "context_unauthorized" | "cli_validation_failed";
|
|
75
|
+
details?: string;
|
|
76
|
+
metaSessionId: string;
|
|
77
|
+
metaTurnId: string;
|
|
78
|
+
};
|
|
79
|
+
export type ApprovedCommandBrokerOpts = {
|
|
80
|
+
contextResolver?: CommandContextResolver;
|
|
81
|
+
runTriggersEnabled?: boolean;
|
|
82
|
+
};
|
|
83
|
+
export declare class ApprovedCommandBroker {
|
|
84
|
+
#private;
|
|
85
|
+
constructor(opts?: ApprovedCommandBrokerOpts);
|
|
86
|
+
approve(opts: {
|
|
87
|
+
proposal: MetaApprovedCommand;
|
|
88
|
+
inbound: InboundEnvelope;
|
|
89
|
+
}): {
|
|
90
|
+
kind: "approved";
|
|
91
|
+
commandText: string;
|
|
92
|
+
} | {
|
|
93
|
+
kind: "reject";
|
|
94
|
+
reason: "meta_agent_action_disallowed" | "context_missing" | "context_ambiguous" | "context_unauthorized" | "cli_validation_failed";
|
|
95
|
+
details?: string;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export type MessagingMetaAgentRuntimeOpts = {
|
|
99
|
+
backend: MessagingMetaAgentBackend;
|
|
100
|
+
broker?: ApprovedCommandBroker;
|
|
101
|
+
enabled?: boolean;
|
|
102
|
+
enabledChannels?: readonly string[];
|
|
103
|
+
sessionIdFactory?: () => string;
|
|
104
|
+
turnIdFactory?: () => string;
|
|
105
|
+
};
|
|
106
|
+
export declare class MessagingMetaAgentRuntime {
|
|
107
|
+
#private;
|
|
108
|
+
constructor(opts: MessagingMetaAgentRuntimeOpts);
|
|
109
|
+
handleInbound(opts: {
|
|
110
|
+
inbound: InboundEnvelope;
|
|
111
|
+
binding: IdentityBinding;
|
|
112
|
+
}): Promise<MetaAgentDecision>;
|
|
113
|
+
}
|
|
114
|
+
export type PiMessagingMetaAgentBackendOpts = {
|
|
115
|
+
provider?: string;
|
|
116
|
+
model?: string;
|
|
117
|
+
thinking?: string;
|
|
118
|
+
systemPrompt?: string;
|
|
119
|
+
timeoutMs?: number;
|
|
120
|
+
piBinary?: string;
|
|
121
|
+
};
|
|
122
|
+
export declare class PiMessagingMetaAgentBackend implements MessagingMetaAgentBackend {
|
|
123
|
+
#private;
|
|
124
|
+
constructor(opts?: PiMessagingMetaAgentBackendOpts);
|
|
125
|
+
runTurn(input: MetaAgentBackendTurnInput): Promise<MetaAgentBackendTurnResult>;
|
|
126
|
+
}
|
|
127
|
+
//# 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,CAA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