@guyghost/swarm-dao-core 0.3.0 → 0.4.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/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/registry.d.ts +46 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands/registry.js +352 -0
- package/dist/commands/registry.js.map +1 -0
- package/dist/control/gates.d.ts.map +1 -1
- package/dist/control/gates.js +17 -0
- package/dist/control/gates.js.map +1 -1
- package/dist/delivery/dependencies.d.ts.map +1 -1
- package/dist/delivery/dependencies.js +15 -7
- package/dist/delivery/dependencies.js.map +1 -1
- package/dist/delivery/execution.d.ts.map +1 -1
- package/dist/delivery/execution.js +7 -5
- package/dist/delivery/execution.js.map +1 -1
- package/dist/governance/agents.d.ts +2 -0
- package/dist/governance/agents.d.ts.map +1 -1
- package/dist/governance/agents.js +49 -12
- package/dist/governance/agents.js.map +1 -1
- package/dist/governance/delegation.machine.d.ts +316 -0
- package/dist/governance/delegation.machine.d.ts.map +1 -0
- package/dist/governance/delegation.machine.js +387 -0
- package/dist/governance/delegation.machine.js.map +1 -0
- package/dist/governance/delegation.utils.d.ts +55 -0
- package/dist/governance/delegation.utils.d.ts.map +1 -0
- package/dist/governance/delegation.utils.js +157 -0
- package/dist/governance/delegation.utils.js.map +1 -0
- package/dist/governance/index.d.ts +2 -0
- package/dist/governance/index.d.ts.map +1 -1
- package/dist/governance/index.js +2 -0
- package/dist/governance/index.js.map +1 -1
- package/dist/governance/lifecycle.d.ts +0 -6
- package/dist/governance/lifecycle.d.ts.map +1 -1
- package/dist/governance/lifecycle.js +7 -31
- package/dist/governance/lifecycle.js.map +1 -1
- package/dist/governance/proposal.machine.d.ts +65 -81
- package/dist/governance/proposal.machine.d.ts.map +1 -1
- package/dist/governance/proposal.machine.js +160 -357
- package/dist/governance/proposal.machine.js.map +1 -1
- package/dist/governance/proposal.utils.d.ts +19 -165
- package/dist/governance/proposal.utils.d.ts.map +1 -1
- package/dist/governance/proposal.utils.js +49 -119
- package/dist/governance/proposal.utils.js.map +1 -1
- package/dist/governance/scoring.d.ts.map +1 -1
- package/dist/governance/scoring.js +36 -16
- package/dist/governance/scoring.js.map +1 -1
- package/dist/host-tools/handlers.d.ts.map +1 -1
- package/dist/host-tools/handlers.js +24 -16
- package/dist/host-tools/handlers.js.map +1 -1
- package/dist/host-tools/messages.d.ts +10 -4
- package/dist/host-tools/messages.d.ts.map +1 -1
- package/dist/host-tools/messages.js +14 -17
- package/dist/host-tools/messages.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/integrations/http.d.ts +12 -1
- package/dist/integrations/http.d.ts.map +1 -1
- package/dist/integrations/http.js +114 -17
- package/dist/integrations/http.js.map +1 -1
- package/dist/intelligence/delegation.d.ts +40 -0
- package/dist/intelligence/delegation.d.ts.map +1 -0
- package/dist/intelligence/delegation.js +162 -0
- package/dist/intelligence/delegation.js.map +1 -0
- package/dist/intelligence/index.d.ts +1 -0
- package/dist/intelligence/index.d.ts.map +1 -1
- package/dist/intelligence/index.js +1 -0
- package/dist/intelligence/index.js.map +1 -1
- package/dist/intelligence/model.d.ts +28 -2
- package/dist/intelligence/model.d.ts.map +1 -1
- package/dist/intelligence/model.js +36 -3
- package/dist/intelligence/model.js.map +1 -1
- package/dist/intelligence/swarm.d.ts +13 -2
- package/dist/intelligence/swarm.d.ts.map +1 -1
- package/dist/intelligence/swarm.js +97 -50
- package/dist/intelligence/swarm.js.map +1 -1
- package/dist/persistence.d.ts +2 -6
- package/dist/persistence.d.ts.map +1 -1
- package/dist/persistence.js +109 -123
- package/dist/persistence.js.map +1 -1
- package/dist/types/index.d.ts +70 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// Swarm DAO Core — Delegation Orchestrator (DFI thin slice)
|
|
3
|
+
// ------------------------------------------------------------
|
|
4
|
+
// I/O layer ONLY. Drives the two delegation machines through their events.
|
|
5
|
+
// Owns: parse parent LLM signal, evaluate the pure gate, spawn child via
|
|
6
|
+
// `HostAdapter.spawnAgent`, fold child reasoning into the parent output, and
|
|
7
|
+
// run the drain/cancel cascade. Emits NO decision the machines do not
|
|
8
|
+
// authorize (INV-3). Child outputs fold into parent REASONING only — never
|
|
9
|
+
// into votes (INV-6, enforced structurally: weight 0, separate section).
|
|
10
|
+
//
|
|
11
|
+
// Fold integrity (B2): the request machine commits to a fold hash on
|
|
12
|
+
// CHILD_REPORTED (FNV-1a over the child output content) and the orchestrator
|
|
13
|
+
// must echo the identical hash on FOLD_COMPLETE. This binds the fold ack to
|
|
14
|
+
// the observed child report. A request cannot leave `reported` otherwise.
|
|
15
|
+
// ============================================================
|
|
16
|
+
import { buildChildAgent, computeMergedFoldHash, evaluateDelegationGate, extractDelegationSignals, normalizeFacet, } from "../governance/delegation.machine.js";
|
|
17
|
+
import { createCoordinatorState, createRequestState, dispatchCoordinatorEvent, dispatchDelegationEvent, profileFor, registeredArchetypes, } from "../governance/delegation.utils.js";
|
|
18
|
+
import { buildChildModelResolutionContext, resolveAgentModel } from "./model.js";
|
|
19
|
+
/**
|
|
20
|
+
* Run all declared delegations for a parent agent after it has produced an
|
|
21
|
+
* output. Returns the (possibly folded) parent content and the live machine
|
|
22
|
+
* states. No-op when delegation is disabled, the agent declares no delegates,
|
|
23
|
+
* or the parent emitted no recognizable signal.
|
|
24
|
+
*/
|
|
25
|
+
export async function runDelegations(params) {
|
|
26
|
+
const { parent, parentOutput, proposal, adapter, config, parentModelContext } = params;
|
|
27
|
+
const content = parentOutput.content ?? "";
|
|
28
|
+
const coordinators = [];
|
|
29
|
+
const requests = [];
|
|
30
|
+
const delegation = config.delegation;
|
|
31
|
+
const declared = parent.delegates ?? [];
|
|
32
|
+
const signals = delegation?.enabled === true && declared.length > 0 ? extractDelegationSignals(content) : [];
|
|
33
|
+
if (signals.length === 0) {
|
|
34
|
+
return { foldedContent: content, coordinators, requests, delegated: false };
|
|
35
|
+
}
|
|
36
|
+
const coordinator = createCoordinatorState(parent, config);
|
|
37
|
+
coordinators.push(coordinator);
|
|
38
|
+
params.onCoordinatorCreated?.(coordinator);
|
|
39
|
+
const archetypes = registeredArchetypes(config);
|
|
40
|
+
const parentResolvedModel = resolveAgentModel(parent, parentModelContext);
|
|
41
|
+
let counter = 0;
|
|
42
|
+
let delegated = false;
|
|
43
|
+
let foldedContent = content;
|
|
44
|
+
for (const signal of signals) {
|
|
45
|
+
const requestId = `${parent.id}:${normalizeFacet(signal.facet)}:${counter++}`;
|
|
46
|
+
const arrived = dispatchCoordinatorEvent(coordinator, {
|
|
47
|
+
type: "REQUEST_ARRIVED",
|
|
48
|
+
requestId,
|
|
49
|
+
facet: signal.facet,
|
|
50
|
+
archetype: signal.archetype,
|
|
51
|
+
});
|
|
52
|
+
if (!arrived.ok || arrived.ack?.accepted === false) {
|
|
53
|
+
// Coordinator-level refusal (budget / disabled / depth). Record a blocked
|
|
54
|
+
// request for audit; no child is spawned (INV-2, W4).
|
|
55
|
+
const req = createRequestState(requestId, coordinator, signal.facet, signal.archetype);
|
|
56
|
+
requests.push(req);
|
|
57
|
+
dispatchDelegationEvent(req, {
|
|
58
|
+
type: "GATE_DECIDED",
|
|
59
|
+
ok: false,
|
|
60
|
+
reasons: [arrived.ok ? (arrived.ack?.reason ?? "rejected by coordinator") : arrived.error],
|
|
61
|
+
});
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const req = createRequestState(requestId, coordinator, signal.facet, signal.archetype);
|
|
65
|
+
requests.push(req);
|
|
66
|
+
// Per-request gate (pure). Single authority for facet/archetype/depth.
|
|
67
|
+
const gate = evaluateDelegationGate({
|
|
68
|
+
facet: signal.facet,
|
|
69
|
+
archetype: signal.archetype,
|
|
70
|
+
parentDepth: coordinator.parentDepth,
|
|
71
|
+
maxDepth: delegation?.maxDepth ?? 0,
|
|
72
|
+
declared,
|
|
73
|
+
registeredArchetypes: archetypes,
|
|
74
|
+
});
|
|
75
|
+
dispatchDelegationEvent(req, { type: "GATE_DECIDED", ok: gate.ok, reasons: gate.reasons });
|
|
76
|
+
if (!gate.ok) {
|
|
77
|
+
// Resolve the coordinator slot we consumed: a blocked request is terminal.
|
|
78
|
+
dispatchCoordinatorEvent(coordinator, { type: "REQUEST_RESOLVED", requestId, terminalStatus: "blocked" });
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
dispatchDelegationEvent(req, {
|
|
82
|
+
type: "SPAWN_ACKED",
|
|
83
|
+
childAgentId: `${parent.id}:delegate:${normalizeFacet(signal.facet)}`,
|
|
84
|
+
});
|
|
85
|
+
const spec = declared.find((d) => normalizeFacet(d.facet) === normalizeFacet(signal.facet));
|
|
86
|
+
const childAgent = buildChildAgent(parent, spec ?? { facet: signal.facet, archetype: signal.archetype });
|
|
87
|
+
const profile = profileFor(config, signal.archetype);
|
|
88
|
+
const childModel = resolveAgentModel(childAgent, buildChildModelResolutionContext(config.defaultModel, {
|
|
89
|
+
parentAgentModel: parentResolvedModel,
|
|
90
|
+
profile,
|
|
91
|
+
parentSessionModel: parentModelContext.parentSessionModel,
|
|
92
|
+
hostDefaultModel: parentModelContext.hostDefaultModel,
|
|
93
|
+
}));
|
|
94
|
+
try {
|
|
95
|
+
const childOutput = await adapter.spawnAgent({
|
|
96
|
+
agent: childAgent,
|
|
97
|
+
proposal,
|
|
98
|
+
systemPrompt: profile?.promptId ? `[prompt:${profile.promptId}]` : childAgent.systemPrompt,
|
|
99
|
+
model: childModel,
|
|
100
|
+
timeoutMs: delegation?.foldTimeoutMs,
|
|
101
|
+
});
|
|
102
|
+
if (childOutput.error) {
|
|
103
|
+
dispatchDelegationEvent(req, { type: "CHILD_FAILED", error: childOutput.error });
|
|
104
|
+
dispatchCoordinatorEvent(coordinator, { type: "REQUEST_RESOLVED", requestId, terminalStatus: "failed" });
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
dispatchDelegationEvent(req, { type: "CHILD_REPORTED", output: childOutput });
|
|
108
|
+
// Fold: merge child reasoning into the parent's content (INV-6).
|
|
109
|
+
foldedContent = foldChildIntoParent(foldedContent, signal, childOutput);
|
|
110
|
+
// Echo the machine's commitment hash to acknowledge the fold (B2).
|
|
111
|
+
dispatchDelegationEvent(req, {
|
|
112
|
+
type: "FOLD_COMPLETE",
|
|
113
|
+
foldedInto: parent.id,
|
|
114
|
+
mergedAgentOutputHash: computeMergedFoldHash(childOutput.content ?? ""),
|
|
115
|
+
});
|
|
116
|
+
delegated = true;
|
|
117
|
+
dispatchCoordinatorEvent(coordinator, { type: "REQUEST_RESOLVED", requestId, terminalStatus: "delegated" });
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
const message = err instanceof Error ? err.message : "spawn failed";
|
|
121
|
+
dispatchDelegationEvent(req, { type: "SPAWN_FAILED", error: message });
|
|
122
|
+
dispatchCoordinatorEvent(coordinator, { type: "REQUEST_RESOLVED", requestId, terminalStatus: "failed" });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return { foldedContent, coordinators, requests, delegated };
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Append the child's investigation under a `## Delegated Facets` section.
|
|
129
|
+
* Pure. The parent's `## Vote` section is never touched (INV-6).
|
|
130
|
+
*/
|
|
131
|
+
export function foldChildIntoParent(parentContent, signal, childOutput) {
|
|
132
|
+
const childBlock = [
|
|
133
|
+
"",
|
|
134
|
+
"## Delegated Facets",
|
|
135
|
+
`### facet: ${signal.facet} | archetype: ${signal.archetype}`,
|
|
136
|
+
childOutput.content?.trim() ?? "_(no output)_",
|
|
137
|
+
"",
|
|
138
|
+
].join("\n");
|
|
139
|
+
return `${parentContent.replace(/\n*$/, "")}\n${childBlock}`;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Drain/cancel cascade (B3). Emit DRAIN to each coordinator, then CANCEL to
|
|
143
|
+
* every non-terminal request. Idempotent: terminal states ignore events.
|
|
144
|
+
*/
|
|
145
|
+
export function drainDelegations(coordinators, requests) {
|
|
146
|
+
for (const c of coordinators) {
|
|
147
|
+
dispatchCoordinatorEvent(c, { type: "DRAIN", reason: "proposal-terminal" });
|
|
148
|
+
}
|
|
149
|
+
const byParent = new Map(coordinators.map((c) => [c.parentAgentId, c]));
|
|
150
|
+
for (const r of requests) {
|
|
151
|
+
dispatchDelegationEvent(r, { type: "CANCEL", reason: "proposal-terminal" });
|
|
152
|
+
const owner = byParent.get(r.parentAgentId) ?? coordinators[0];
|
|
153
|
+
if (owner) {
|
|
154
|
+
dispatchCoordinatorEvent(owner, {
|
|
155
|
+
type: "REQUEST_RESOLVED",
|
|
156
|
+
requestId: r.requestId,
|
|
157
|
+
terminalStatus: "cancelled",
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=delegation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delegation.js","sourceRoot":"","sources":["../../src/intelligence/delegation.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,4DAA4D;AAC5D,+DAA+D;AAC/D,2EAA2E;AAC3E,yEAAyE;AACzE,6EAA6E;AAC7E,sEAAsE;AACtE,2EAA2E;AAC3E,yEAAyE;AACzE,EAAE;AACF,qEAAqE;AACrE,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,+DAA+D;AAE/D,OAAO,EACL,eAAe,EACf,qBAAqB,EAErB,sBAAsB,EACtB,wBAAwB,EACxB,cAAc,GACf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAGlB,wBAAwB,EACxB,uB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AAC,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,uBAAuB,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAC,CAAC;QAC5E,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QAC/D,IAAI,KAAK,EAAE,CAAC;YACV,wBAAwB,CAAC,KAAK,EAAE;gBAC9B,IAAI,EAAE,kBAAkB;gBACxB,SAAS,EAAE,CAAC,CAAC,SAAS;gBACtB,cAAc,EAAE,WAAW;aAC5B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intelligence/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intelligence/index.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intelligence/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intelligence/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|
|
@@ -1,16 +1,42 @@
|
|
|
1
|
-
import type { DAOAgent } from "../types/index.js";
|
|
1
|
+
import type { DAOAgent, DelegationProfileEntry } from "../types/index.js";
|
|
2
2
|
export interface ModelResolutionContext {
|
|
3
|
+
/** Model set on a parent agent (delegation inheritance). */
|
|
4
|
+
parentAgentModel?: string;
|
|
5
|
+
/** Model declared by the delegation profile for the child's archetype. */
|
|
6
|
+
profileDefaultModel?: string;
|
|
3
7
|
parentSessionModel?: string;
|
|
4
8
|
configDefaultModel: string;
|
|
5
9
|
hostDefaultModel?: string;
|
|
6
10
|
}
|
|
7
11
|
/**
|
|
8
12
|
* Resolve the model for a DAO agent using the inheritance chain:
|
|
9
|
-
*
|
|
13
|
+
*
|
|
14
|
+
* agent.model
|
|
15
|
+
* → profile.defaultModel (delegation profile, child archetype)
|
|
16
|
+
* → parentAgent.resolvedModel (delegation parent — default behaviour)
|
|
17
|
+
* → parentSessionModel
|
|
18
|
+
* → config.defaultModel
|
|
19
|
+
* → host default
|
|
20
|
+
*
|
|
21
|
+
* For a delegated child, `agent.model` carries the child's `DelegationSpec.model`
|
|
22
|
+
* (where `"inherit"` / omitted ⇒ fall through to the parent). The chain is
|
|
23
|
+
* strictly additive: every layer may only refine, never branch.
|
|
10
24
|
*/
|
|
11
25
|
export declare function resolveAgentModel(agent: DAOAgent, ctx: ModelResolutionContext): string;
|
|
12
26
|
export declare function describeModelResolution(agent: DAOAgent, resolved: string, ctx: ModelResolutionContext): string;
|
|
13
27
|
export declare function buildModelResolutionContext(configDefaultModel: string, options?: {
|
|
28
|
+
parentAgentModel?: string;
|
|
29
|
+
parentSessionModel?: string;
|
|
30
|
+
hostDefaultModel?: string;
|
|
31
|
+
}): ModelResolutionContext;
|
|
32
|
+
/**
|
|
33
|
+
* Build a resolution context for a delegated child. `profileDefaultModel` is
|
|
34
|
+
* sourced from the DAO's delegation profile for the child's archetype; the
|
|
35
|
+
* parent agent's resolved model is the default the child inherits.
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildChildModelResolutionContext(configDefaultModel: string, options: {
|
|
38
|
+
parentAgentModel: string;
|
|
39
|
+
profile?: DelegationProfileEntry;
|
|
14
40
|
parentSessionModel?: string;
|
|
15
41
|
hostDefaultModel?: string;
|
|
16
42
|
}): ModelResolutionContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/intelligence/model.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/intelligence/model.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE1E,MAAM,WAAW,sBAAsB;IACrC,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,0EAA0E;IAC1E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAWD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,sBAAsB,GAAG,MAAM,CAYtF;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,sBAAsB,GAAG,MAAM,CAqB9G;AAED,wBAAgB,2BAA2B,CACzC,kBAAkB,EAAE,MAAM,EAC1B,OAAO,CAAC,EAAE;IACR,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,GACA,sBAAsB,CAOxB;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,kBAAkB,EAAE,MAAM,EAC1B,OAAO,EAAE;IACP,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,GACA,sBAAsB,CAQxB"}
|
|
@@ -11,15 +11,33 @@ function pickModel(...candidates) {
|
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Resolve the model for a DAO agent using the inheritance chain:
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
|
+
* agent.model
|
|
16
|
+
* → profile.defaultModel (delegation profile, child archetype)
|
|
17
|
+
* → parentAgent.resolvedModel (delegation parent — default behaviour)
|
|
18
|
+
* → parentSessionModel
|
|
19
|
+
* → config.defaultModel
|
|
20
|
+
* → host default
|
|
21
|
+
*
|
|
22
|
+
* For a delegated child, `agent.model` carries the child's `DelegationSpec.model`
|
|
23
|
+
* (where `"inherit"` / omitted ⇒ fall through to the parent). The chain is
|
|
24
|
+
* strictly additive: every layer may only refine, never branch.
|
|
15
25
|
*/
|
|
16
26
|
export function resolveAgentModel(agent, ctx) {
|
|
17
|
-
|
|
27
|
+
const childOverride = agent.model && agent.model !== "inherit" ? agent.model : undefined;
|
|
28
|
+
return (pickModel(childOverride, ctx.profileDefaultModel, ctx.parentAgentModel, ctx.parentSessionModel, ctx.configDefaultModel, ctx.hostDefaultModel) ?? "default");
|
|
18
29
|
}
|
|
19
30
|
export function describeModelResolution(agent, resolved, ctx) {
|
|
20
|
-
|
|
31
|
+
const childOverride = agent.model && agent.model !== "inherit" ? agent.model : undefined;
|
|
32
|
+
if (childOverride && resolved === childOverride) {
|
|
21
33
|
return `${resolved} (agent override)`;
|
|
22
34
|
}
|
|
35
|
+
if (ctx.profileDefaultModel && resolved === ctx.profileDefaultModel) {
|
|
36
|
+
return `${resolved} (delegation profile default)`;
|
|
37
|
+
}
|
|
38
|
+
if (ctx.parentAgentModel && resolved === ctx.parentAgentModel) {
|
|
39
|
+
return `${resolved} (inherited from parent agent)`;
|
|
40
|
+
}
|
|
23
41
|
if (ctx.parentSessionModel && resolved === ctx.parentSessionModel) {
|
|
24
42
|
return `${resolved} (inherited from parent session)`;
|
|
25
43
|
}
|
|
@@ -33,9 +51,24 @@ export function describeModelResolution(agent, resolved, ctx) {
|
|
|
33
51
|
}
|
|
34
52
|
export function buildModelResolutionContext(configDefaultModel, options) {
|
|
35
53
|
return {
|
|
54
|
+
parentAgentModel: options?.parentAgentModel,
|
|
36
55
|
parentSessionModel: options?.parentSessionModel,
|
|
37
56
|
configDefaultModel,
|
|
38
57
|
hostDefaultModel: options?.hostDefaultModel,
|
|
39
58
|
};
|
|
40
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Build a resolution context for a delegated child. `profileDefaultModel` is
|
|
62
|
+
* sourced from the DAO's delegation profile for the child's archetype; the
|
|
63
|
+
* parent agent's resolved model is the default the child inherits.
|
|
64
|
+
*/
|
|
65
|
+
export function buildChildModelResolutionContext(configDefaultModel, options) {
|
|
66
|
+
return {
|
|
67
|
+
parentAgentModel: options.parentAgentModel,
|
|
68
|
+
profileDefaultModel: options.profile?.defaultModel,
|
|
69
|
+
parentSessionModel: options.parentSessionModel,
|
|
70
|
+
configDefaultModel,
|
|
71
|
+
hostDefaultModel: options.hostDefaultModel,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
41
74
|
//# sourceMappingURL=model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/intelligence/model.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,oCAAoC;AACpC,+DAA+D;
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/intelligence/model.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,oCAAoC;AACpC,+DAA+D;A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QAAQ,gCAAgC,CAAC;IACrD,CAAC;IACD,IAAI,GAAG,CAAC,kBAAkB,IAAI,QAAQ,KAAK,GAAG,CAAC,kBAAkB,EAAE,CAAC;QAClE,OAAO,GAAG,QAAQ,kCAAkC,CAAC;IACvD,CAAC;IACD,IAAI,QAAQ,KAAK,GAAG,CAAC,kBAAkB,EAAE,CAAC;QACxC,OAAO,GAAG,QAAQ,gBAAgB,CAAC;IACrC,CAAC;IACD,IAAI,GAAG,CAAC,gBAAgB,IAAI,QAAQ,KAAK,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAC9D,OAAO,GAAG,QAAQ,iBAAiB,CAAC;IACtC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,kBAA0B,EAC1B,OAIC;IAED,OAAO;QACL,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;QAC3C,kBAAkB,EAAE,OAAO,EAAE,kBAAkB;QAC/C,kBAAkB;QAClB,gBAAgB,EAAE,OAAO,EAAE,gBAAgB;KAC5C,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,kBAA0B,EAC1B,OAKC;IAED,OAAO;QACL,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,mBAAmB,EAAE,OAAO,CAAC,OAAO,EAAE,YAAY;QAClD,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,kBAAkB;QAClB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentOutput, DAOAgent, HostAdapter, Proposal } from "../types/index.js";
|
|
1
|
+
import type { AgentOutput, DAOAgent, DAOConfig, HostAdapter, Proposal } from "../types/index.js";
|
|
2
2
|
import { type ModelResolutionContext } from "./model.js";
|
|
3
3
|
export interface SwarmProgressUpdate {
|
|
4
4
|
agentId: string;
|
|
@@ -28,6 +28,17 @@ export declare function createDispatchModelContext(configDefaultModel: string, a
|
|
|
28
28
|
/**
|
|
29
29
|
* Dispatch swarm via a host adapter.
|
|
30
30
|
* This is the host-agnostic version — adapters implement the actual spawning.
|
|
31
|
+
*
|
|
32
|
+
* Delegation (DFI) is opt-in: pass `delegation?.config` with
|
|
33
|
+
* `config.delegation.enabled === true` to activate. When active, after each
|
|
34
|
+
* parent agent produces an output, declared facets are investigated by child
|
|
35
|
+
* agents and folded into the parent's reasoning (INV-6: votes untouched). Live
|
|
36
|
+
* coordinators are registered for the `delegation-closed` gate (INV-8) and
|
|
37
|
+
* drained on completion.
|
|
31
38
|
*/
|
|
32
|
-
export declare function dispatchSwarm(proposal: Proposal, agents: DAOAgent[], adapter: HostAdapter, maxConcurrent: number, modelContext: ModelResolutionContext, onUpdate?: (update: SwarmProgressUpdate) => void
|
|
39
|
+
export declare function dispatchSwarm(proposal: Proposal, agents: DAOAgent[], adapter: HostAdapter, maxConcurrent: number, modelContext: ModelResolutionContext, onUpdate?: (update: SwarmProgressUpdate) => void, delegation?: {
|
|
40
|
+
config: DAOConfig;
|
|
41
|
+
}): Promise<AgentOutput[]>;
|
|
42
|
+
/** Clear the coordinator registry for a proposal once deliberation is over. */
|
|
43
|
+
export declare function resetDelegationRegistry(proposalId: number): void;
|
|
33
44
|
//# sourceMappingURL=swarm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm.d.ts","sourceRoot":"","sources":["../../src/intelligence/swarm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"swarm.d.ts","sourceRoot":"","sources":["../../src/intelligence/swarm.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEjG,OAAO,EAGL,KAAK,sBAAsB,EAE5B,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,mBAAmB;IAClC,O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BAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAEhE"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// ============================================================
|
|
2
2
|
// Swarm DAO Core — Swarm Dispatch
|
|
3
3
|
// ============================================================
|
|
4
|
+
import { clearProposalCoordinators, registerProposalCoordinators } from "../governance/delegation.utils.js";
|
|
5
|
+
import { drainDelegations, runDelegations } from "./delegation.js";
|
|
4
6
|
import { buildModelResolutionContext, describeModelResolution, resolveAgentModel, } from "./model.js";
|
|
5
7
|
/**
|
|
6
8
|
* Build dispatch instructions for each agent.
|
|
@@ -65,61 +67,106 @@ export function createDispatchModelContext(configDefaultModel, adapter, options)
|
|
|
65
67
|
/**
|
|
66
68
|
* Dispatch swarm via a host adapter.
|
|
67
69
|
* This is the host-agnostic version — adapters implement the actual spawning.
|
|
70
|
+
*
|
|
71
|
+
* Delegation (DFI) is opt-in: pass `delegation?.config` with
|
|
72
|
+
* `config.delegation.enabled === true` to activate. When active, after each
|
|
73
|
+
* parent agent produces an output, declared facets are investigated by child
|
|
74
|
+
* agents and folded into the parent's reasoning (INV-6: votes untouched). Live
|
|
75
|
+
* coordinators are registered for the `delegation-closed` gate (INV-8) and
|
|
76
|
+
* drained on completion.
|
|
68
77
|
*/
|
|
69
|
-
export async function dispatchSwarm(proposal, agents, adapter, maxConcurrent, modelContext, onUpdate) {
|
|
78
|
+
export async function dispatchSwarm(proposal, agents, adapter, maxConcurrent, modelContext, onUpdate, delegation) {
|
|
70
79
|
const instructions = buildDispatchInstructions(proposal, agents, modelContext);
|
|
71
80
|
const outputs = [];
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
const agentById = new Map(agents.map((a) => [a.id, a]));
|
|
82
|
+
const delegationEnabled = delegation?.config?.delegation?.enabled === true;
|
|
83
|
+
const allCoordinators = [];
|
|
84
|
+
const allRequests = [];
|
|
85
|
+
// Register the mutable coordinators array up-front so the delegation-closed
|
|
86
|
+
// gate can observe in-flight coordinators as they are pushed during dispatch.
|
|
87
|
+
if (delegationEnabled) {
|
|
88
|
+
registerProposalCoordinators(proposal.id, allCoordinators);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
// Process in batches based on maxConcurrent
|
|
92
|
+
for (let i = 0; i < instructions.length; i += maxConcurrent) {
|
|
93
|
+
const batch = instructions.slice(i, i + maxConcurrent);
|
|
94
|
+
const batchPromises = batch.map(async (inst) => {
|
|
95
|
+
const agent = agentById.get(inst.agentId);
|
|
96
|
+
try {
|
|
97
|
+
if (!agent)
|
|
98
|
+
throw new Error(`Agent ${inst.agentId} not found`);
|
|
99
|
+
onUpdate?.({
|
|
100
|
+
agentId: inst.agentId,
|
|
101
|
+
agentName: inst.agentName,
|
|
102
|
+
phase: "started",
|
|
103
|
+
});
|
|
104
|
+
const output = await adapter.spawnAgent({
|
|
105
|
+
agent,
|
|
106
|
+
proposal,
|
|
107
|
+
systemPrompt: inst.prompt,
|
|
108
|
+
model: inst.model,
|
|
109
|
+
timeoutMs: inst.timeoutMs,
|
|
110
|
+
});
|
|
111
|
+
// DFI hook: fold declared delegations into the parent reasoning.
|
|
112
|
+
if (delegationEnabled && delegation && !output.error) {
|
|
113
|
+
const result = await runDelegations({
|
|
114
|
+
parent: agent,
|
|
115
|
+
parentOutput: output,
|
|
116
|
+
proposal,
|
|
117
|
+
adapter,
|
|
118
|
+
config: delegation.config,
|
|
119
|
+
parentModelContext: modelContext,
|
|
120
|
+
onCoordinatorCreated: (coordinator) => {
|
|
121
|
+
allCoordinators.push(coordinator);
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
allRequests.push(...result.requests);
|
|
125
|
+
if (result.delegated)
|
|
126
|
+
output.content = result.foldedContent;
|
|
127
|
+
}
|
|
128
|
+
outputs.push(output);
|
|
129
|
+
onUpdate?.({
|
|
130
|
+
agentId: inst.agentId,
|
|
131
|
+
agentName: inst.agentName,
|
|
132
|
+
phase: output.error ? "error" : "completed",
|
|
133
|
+
output,
|
|
134
|
+
});
|
|
135
|
+
return output;
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
const message = err instanceof Error ? err.message : "Unknown error";
|
|
139
|
+
const errorOutput = {
|
|
140
|
+
agentId: inst.agentId,
|
|
141
|
+
agentName: inst.agentName,
|
|
142
|
+
role: agent?.role ?? "unknown",
|
|
143
|
+
content: "",
|
|
144
|
+
durationMs: 0,
|
|
145
|
+
error: message,
|
|
146
|
+
};
|
|
147
|
+
outputs.push(errorOutput);
|
|
148
|
+
onUpdate?.({
|
|
149
|
+
agentId: inst.agentId,
|
|
150
|
+
agentName: inst.agentName,
|
|
151
|
+
phase: "error",
|
|
152
|
+
output: errorOutput,
|
|
153
|
+
});
|
|
154
|
+
return errorOutput;
|
|
155
|
+
}
|
|
83
156
|
});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
outputs.push(output);
|
|
93
|
-
onUpdate?.({
|
|
94
|
-
agentId: inst.agentId,
|
|
95
|
-
agentName: inst.agentName,
|
|
96
|
-
phase: output.error ? "error" : "completed",
|
|
97
|
-
output,
|
|
98
|
-
});
|
|
99
|
-
return output;
|
|
100
|
-
}
|
|
101
|
-
catch (err) {
|
|
102
|
-
const message = err instanceof Error ? err.message : "Unknown error";
|
|
103
|
-
const errorOutput = {
|
|
104
|
-
agentId: inst.agentId,
|
|
105
|
-
agentName: inst.agentName,
|
|
106
|
-
role: agent.role,
|
|
107
|
-
content: "",
|
|
108
|
-
durationMs: 0,
|
|
109
|
-
error: message,
|
|
110
|
-
};
|
|
111
|
-
outputs.push(errorOutput);
|
|
112
|
-
onUpdate?.({
|
|
113
|
-
agentId: inst.agentId,
|
|
114
|
-
agentName: inst.agentName,
|
|
115
|
-
phase: "error",
|
|
116
|
-
output: errorOutput,
|
|
117
|
-
});
|
|
118
|
-
return errorOutput;
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
await Promise.all(batchPromises);
|
|
157
|
+
await Promise.all(batchPromises);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
if (delegationEnabled) {
|
|
162
|
+
drainDelegations(allCoordinators, allRequests);
|
|
163
|
+
clearProposalCoordinators(proposal.id);
|
|
164
|
+
}
|
|
122
165
|
}
|
|
123
166
|
return outputs;
|
|
124
167
|
}
|
|
168
|
+
/** Clear the coordinator registry for a proposal once deliberation is over. */
|
|
169
|
+
export function resetDelegationRegistry(proposalId) {
|
|
170
|
+
clearProposalCoordinators(proposalId);
|
|
171
|
+
}
|
|
125
172
|
//# sourceMappingURL=swarm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm.js","sourceRoot":"","sources":["../../src/intelligence/swarm.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,kCAAkC;AAClC,+DAA+D;
|
|
1
|
+
{"version":3,"file":"swarm.js","sourceRoot":"","sources":["../../src/intelligence/swarm.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,kCAAkC;AAClC,+DAA+D;AAE/D,OAAO,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAE5G,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EAEvB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAmBpB;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAkB,EAClB,MAAkB,EAClB,YAAoC;IAEpC,MAAM,UAAU,GAAG;;eAEN,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC,KAAK;YACjC,QAAQ,CAAC,IAAI;;EAEvB,QAAQ,CAAC,WAAW;;EAEpB,QAAQ,CA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zB,IAAI,EAAE,KAAK,EAAE,IAAI,IAAI,SAAS;wBAC9B,OAAO,EAAE,EAAE;wBACX,UAAU,EAAE,CAAC;wBACb,KAAK,EAAE,OAAO;qBACf,CAAC;oBACF,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBAE1B,QAAQ,EAAE,CAAC;wBACT,OAAO,EAAE,IAAI,CAAC,OAAO;wBACrB,SAAS,EAAE,IAAI,CAAC,SAAS;wBACzB,KAAK,EAAE,OAAO;wBACd,MAAM,EAAE,WAAW;qBACpB,CAAC,CAAC;oBAEH,OAAO,WAAW,CAAC;gBACrB,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;YAAS,CAAC;QACT,IAAI,iBAAiB,EAAE,CAAC;YACtB,gBAAgB,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;YAC/C,yBAAyB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,uBAAuB,CAAC,UAAkB;IACxD,yBAAyB,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/persistence.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { AgentOutput, AuditEntry, CompositeScore, ControlCheckResult, DAOAgent, DAOArtefacts, DAOState, DeliveryPlan, ExecutionSnapshot, ExecutionVerification, Proposal, ProposalOutcome,
|
|
1
|
+
import type { AgentOutput, AuditEntry, CompositeScore, ControlCheckResult, DAOAgent, DAOArtefacts, DAOState, DeliveryPlan, ExecutionSnapshot, ExecutionVerification, Proposal, ProposalOutcome, StorageSettings, Vote } from "./types/index.js";
|
|
2
|
+
export declare function sanitizeErrorMessage(message: string): string;
|
|
2
3
|
export declare function getDaoRoot(cwd: string): string;
|
|
3
|
-
export declare function getProposalsDir(daoRoot: string): string;
|
|
4
4
|
export declare function getDecisionsDir(daoRoot: string): string;
|
|
5
5
|
export declare function padId(id: number): string;
|
|
6
|
-
export declare function getProposalPath(daoRoot: string, id: number): string;
|
|
7
6
|
export declare function initStorage(cwd: string): Promise<string>;
|
|
8
7
|
export declare function migrateFromLegacy(cwd: string, legacyDirectories?: string[]): Promise<boolean>;
|
|
9
8
|
export declare function getState(): DAOState;
|
|
@@ -12,8 +11,6 @@ export declare function getOrCreateState(cwd: string): DAOState;
|
|
|
12
11
|
export declare function loadState(cwd: string, options?: {
|
|
13
12
|
legacyDirectories?: string[];
|
|
14
13
|
}): Promise<DAOState | null>;
|
|
15
|
-
export declare function loadProposalsFromDisk(daoRoot: string): Promise<Proposal[]>;
|
|
16
|
-
export declare function saveProposal(proposalId: number): Promise<string | null>;
|
|
17
14
|
export declare function saveState(): Promise<void>;
|
|
18
15
|
export declare function saveDecisions(): Promise<void>;
|
|
19
16
|
export declare function getStorageSettings(daoRoot: string): Promise<StorageSettings>;
|
|
@@ -32,7 +29,6 @@ export declare function createProposalsBatch(entries: Array<{
|
|
|
32
29
|
}>): Promise<Proposal[]>;
|
|
33
30
|
export declare function getProposal(proposalId: number): Proposal | undefined;
|
|
34
31
|
export declare function listProposals(): Proposal[];
|
|
35
|
-
export declare function updateProposalStatus(proposalId: number, status: ProposalStatus): Promise<boolean>;
|
|
36
32
|
export declare function addVote(proposalId: number, vote: Vote): Promise<boolean>;
|
|
37
33
|
export declare function storeAgentOutput(proposalId: number, output: AgentOutput): Promise<boolean>;
|
|
38
34
|
export declare function storeDeliberationBatch(proposalId: number, votes: Vote[], outputs: AgentOutput[]): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../src/persistence.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,Q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