monomind 2.1.0 → 2.1.4
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 +77 -94
- package/package.json +3 -3
- package/packages/@monomind/cli/.claude/commands/mastermind/createorg.md +8 -9
- package/packages/@monomind/cli/.claude/helpers/handlers/capture-handler.cjs +24 -10
- package/packages/@monomind/cli/.claude/helpers/handlers/gates-handler.cjs +2 -2
- package/packages/@monomind/cli/.claude/helpers/handlers/route-handler.cjs +29 -0
- package/packages/@monomind/cli/.claude/helpers/handlers/session-handler.cjs +35 -23
- package/packages/@monomind/cli/.claude/helpers/hook-handler.cjs +21 -0
- package/packages/@monomind/cli/.claude/helpers/utils/monograph.cjs +73 -2
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/createorg.md +91 -701
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/org-settings.md +46 -47
- package/packages/@monomind/cli/.claude/skills/mastermind-skills/runorg.md +12 -1
- package/packages/@monomind/cli/README.md +77 -94
- package/packages/@monomind/cli/dist/src/browser/workflow/store.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/commands/browse.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/doctor-env-checks.js +5 -0
- package/packages/@monomind/cli/dist/src/commands/org.js +46 -29
- package/packages/@monomind/cli/dist/src/commands/platforms.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/init/executor.js +30 -6
- package/packages/@monomind/cli/dist/src/mcp-tools/auto-install.d.ts +8 -8
- package/packages/@monomind/cli/dist/src/mcp-tools/coherence/types.d.ts +31 -31
- package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +5 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +28 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts +36 -36
- package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +4 -4
- package/packages/@monomind/cli/dist/src/memory/ewc-consolidation.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/memory/sona-optimizer.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/orgrt/broker.d.ts +3 -1
- package/packages/@monomind/cli/dist/src/orgrt/broker.js +8 -3
- package/packages/@monomind/cli/dist/src/orgrt/bus.d.ts +5 -1
- package/packages/@monomind/cli/dist/src/orgrt/bus.js +5 -1
- package/packages/@monomind/cli/dist/src/orgrt/daemon.d.ts +35 -1
- package/packages/@monomind/cli/dist/src/orgrt/daemon.js +190 -21
- package/packages/@monomind/cli/dist/src/orgrt/forwarder.js +47 -10
- package/packages/@monomind/cli/dist/src/orgrt/inbox.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/orgrt/inbox.js +56 -0
- package/packages/@monomind/cli/dist/src/orgrt/policy.d.ts +5 -1
- package/packages/@monomind/cli/dist/src/orgrt/policy.js +58 -5
- package/packages/@monomind/cli/dist/src/orgrt/server.d.ts +3 -2
- package/packages/@monomind/cli/dist/src/orgrt/server.js +31 -40
- package/packages/@monomind/cli/dist/src/orgrt/session.d.ts +11 -1
- package/packages/@monomind/cli/dist/src/orgrt/session.js +32 -1
- package/packages/@monomind/cli/dist/src/orgrt/test-loop.js +8 -8
- package/packages/@monomind/cli/dist/src/orgrt/types.d.ts +53 -53
- package/packages/@monomind/cli/dist/src/output.d.ts +29 -29
- package/packages/@monomind/cli/dist/src/output.js +10 -2
- package/packages/@monomind/cli/dist/src/pricing/model-pricing.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/types.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/ui/collector.mjs +20 -5
- package/packages/@monomind/cli/dist/src/ui/dashboard.html +465 -500
- package/packages/@monomind/cli/dist/src/ui/orgs-files.js +192 -0
- package/packages/@monomind/cli/dist/src/ui/orgs.html +21 -52
- package/packages/@monomind/cli/dist/src/ui/server.mjs +174 -164
- package/packages/@monomind/cli/package.json +12 -16
- package/packages/@monomind/cli/scripts/publish.sh +6 -0
- package/scripts/generate-agent-avatars.mjs +3 -3
- package/packages/@monomind/cli/dist/src/orgrt/live.html +0 -56
package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts
CHANGED
|
@@ -13,14 +13,14 @@ export declare const PrioritizeGapsInputSchema: z.ZodObject<{
|
|
|
13
13
|
startLine: z.ZodNumber;
|
|
14
14
|
endLine: z.ZodNumber;
|
|
15
15
|
}, "strip", z.ZodTypeAny, {
|
|
16
|
-
type: "function" | "line" | "branch";
|
|
17
16
|
id: string;
|
|
17
|
+
type: "branch" | "function" | "line";
|
|
18
18
|
file: string;
|
|
19
19
|
startLine: number;
|
|
20
20
|
endLine: number;
|
|
21
21
|
}, {
|
|
22
|
-
type: "function" | "line" | "branch";
|
|
23
22
|
id: string;
|
|
23
|
+
type: "branch" | "function" | "line";
|
|
24
24
|
file: string;
|
|
25
25
|
startLine: number;
|
|
26
26
|
endLine: number;
|
|
@@ -52,9 +52,15 @@ export declare const PrioritizeGapsInputSchema: z.ZodObject<{
|
|
|
52
52
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
53
53
|
groupBy: z.ZodDefault<z.ZodEnum<["risk", "file", "type", "none"]>>;
|
|
54
54
|
}, "strip", z.ZodTypeAny, {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
gaps?: {
|
|
56
|
+
id: string;
|
|
57
|
+
type: "branch" | "function" | "line";
|
|
58
|
+
file: string;
|
|
59
|
+
startLine: number;
|
|
60
|
+
endLine: number;
|
|
61
|
+
}[] | undefined;
|
|
62
|
+
targetPath?: string | undefined;
|
|
63
|
+
factors: ("business-critical" | "change-frequency" | "complexity" | "defect-history" | "dependency-count" | "test-difficulty")[];
|
|
58
64
|
weights?: {
|
|
59
65
|
complexity: number;
|
|
60
66
|
changeFrequency: number;
|
|
@@ -63,16 +69,18 @@ export declare const PrioritizeGapsInputSchema: z.ZodObject<{
|
|
|
63
69
|
dependencyCount: number;
|
|
64
70
|
testDifficulty: number;
|
|
65
71
|
} | undefined;
|
|
72
|
+
limit: number;
|
|
73
|
+
groupBy: "file" | "none" | "risk" | "type";
|
|
74
|
+
}, {
|
|
66
75
|
gaps?: {
|
|
67
|
-
type: "function" | "line" | "branch";
|
|
68
76
|
id: string;
|
|
77
|
+
type: "branch" | "function" | "line";
|
|
69
78
|
file: string;
|
|
70
79
|
startLine: number;
|
|
71
80
|
endLine: number;
|
|
72
81
|
}[] | undefined;
|
|
73
82
|
targetPath?: string | undefined;
|
|
74
|
-
|
|
75
|
-
limit?: number | undefined;
|
|
83
|
+
factors?: ("business-critical" | "change-frequency" | "complexity" | "defect-history" | "dependency-count" | "test-difficulty")[] | undefined;
|
|
76
84
|
weights?: {
|
|
77
85
|
complexity?: number | undefined;
|
|
78
86
|
changeFrequency?: number | undefined;
|
|
@@ -81,16 +89,8 @@ export declare const PrioritizeGapsInputSchema: z.ZodObject<{
|
|
|
81
89
|
dependencyCount?: number | undefined;
|
|
82
90
|
testDifficulty?: number | undefined;
|
|
83
91
|
} | undefined;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
id: string;
|
|
87
|
-
file: string;
|
|
88
|
-
startLine: number;
|
|
89
|
-
endLine: number;
|
|
90
|
-
}[] | undefined;
|
|
91
|
-
targetPath?: string | undefined;
|
|
92
|
-
factors?: ("complexity" | "change-frequency" | "defect-history" | "business-critical" | "dependency-count" | "test-difficulty")[] | undefined;
|
|
93
|
-
groupBy?: "type" | "none" | "file" | "risk" | undefined;
|
|
92
|
+
limit?: number | undefined;
|
|
93
|
+
groupBy?: "file" | "none" | "risk" | "type" | undefined;
|
|
94
94
|
}>;
|
|
95
95
|
export type PrioritizeGapsInput = z.infer<typeof PrioritizeGapsInputSchema>;
|
|
96
96
|
export interface PrioritizeGapsOutput {
|
|
@@ -176,14 +176,14 @@ export declare const toolDefinition: {
|
|
|
176
176
|
startLine: z.ZodNumber;
|
|
177
177
|
endLine: z.ZodNumber;
|
|
178
178
|
}, "strip", z.ZodTypeAny, {
|
|
179
|
-
type: "function" | "line" | "branch";
|
|
180
179
|
id: string;
|
|
180
|
+
type: "branch" | "function" | "line";
|
|
181
181
|
file: string;
|
|
182
182
|
startLine: number;
|
|
183
183
|
endLine: number;
|
|
184
184
|
}, {
|
|
185
|
-
type: "function" | "line" | "branch";
|
|
186
185
|
id: string;
|
|
186
|
+
type: "branch" | "function" | "line";
|
|
187
187
|
file: string;
|
|
188
188
|
startLine: number;
|
|
189
189
|
endLine: number;
|
|
@@ -215,9 +215,15 @@ export declare const toolDefinition: {
|
|
|
215
215
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
216
216
|
groupBy: z.ZodDefault<z.ZodEnum<["risk", "file", "type", "none"]>>;
|
|
217
217
|
}, "strip", z.ZodTypeAny, {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
gaps?: {
|
|
219
|
+
id: string;
|
|
220
|
+
type: "branch" | "function" | "line";
|
|
221
|
+
file: string;
|
|
222
|
+
startLine: number;
|
|
223
|
+
endLine: number;
|
|
224
|
+
}[] | undefined;
|
|
225
|
+
targetPath?: string | undefined;
|
|
226
|
+
factors: ("business-critical" | "change-frequency" | "complexity" | "defect-history" | "dependency-count" | "test-difficulty")[];
|
|
221
227
|
weights?: {
|
|
222
228
|
complexity: number;
|
|
223
229
|
changeFrequency: number;
|
|
@@ -226,16 +232,18 @@ export declare const toolDefinition: {
|
|
|
226
232
|
dependencyCount: number;
|
|
227
233
|
testDifficulty: number;
|
|
228
234
|
} | undefined;
|
|
235
|
+
limit: number;
|
|
236
|
+
groupBy: "file" | "none" | "risk" | "type";
|
|
237
|
+
}, {
|
|
229
238
|
gaps?: {
|
|
230
|
-
type: "function" | "line" | "branch";
|
|
231
239
|
id: string;
|
|
240
|
+
type: "branch" | "function" | "line";
|
|
232
241
|
file: string;
|
|
233
242
|
startLine: number;
|
|
234
243
|
endLine: number;
|
|
235
244
|
}[] | undefined;
|
|
236
245
|
targetPath?: string | undefined;
|
|
237
|
-
|
|
238
|
-
limit?: number | undefined;
|
|
246
|
+
factors?: ("business-critical" | "change-frequency" | "complexity" | "defect-history" | "dependency-count" | "test-difficulty")[] | undefined;
|
|
239
247
|
weights?: {
|
|
240
248
|
complexity?: number | undefined;
|
|
241
249
|
changeFrequency?: number | undefined;
|
|
@@ -244,16 +252,8 @@ export declare const toolDefinition: {
|
|
|
244
252
|
dependencyCount?: number | undefined;
|
|
245
253
|
testDifficulty?: number | undefined;
|
|
246
254
|
} | undefined;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
id: string;
|
|
250
|
-
file: string;
|
|
251
|
-
startLine: number;
|
|
252
|
-
endLine: number;
|
|
253
|
-
}[] | undefined;
|
|
254
|
-
targetPath?: string | undefined;
|
|
255
|
-
factors?: ("complexity" | "change-frequency" | "defect-history" | "business-critical" | "dependency-count" | "test-difficulty")[] | undefined;
|
|
256
|
-
groupBy?: "type" | "none" | "file" | "risk" | undefined;
|
|
255
|
+
limit?: number | undefined;
|
|
256
|
+
groupBy?: "file" | "none" | "risk" | "type" | undefined;
|
|
257
257
|
}>;
|
|
258
258
|
handler: typeof handler;
|
|
259
259
|
};
|
package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts
CHANGED
|
@@ -15,16 +15,16 @@ export declare const DetectSecretsInputSchema: z.ZodObject<{
|
|
|
15
15
|
scanHistory: z.ZodDefault<z.ZodBoolean>;
|
|
16
16
|
}, "strip", z.ZodTypeAny, {
|
|
17
17
|
targetPath: string;
|
|
18
|
+
secretTypes: ("api-key" | "aws-key" | "aws-secret" | "azure-key" | "certificate" | "connection-string" | "gcp-key" | "generic" | "password" | "private-key" | "token")[];
|
|
18
19
|
excludePatterns: string[];
|
|
19
|
-
secretTypes: ("password" | "token" | "api-key" | "private-key" | "connection-string" | "certificate" | "aws-key" | "aws-secret" | "gcp-key" | "azure-key" | "generic")[];
|
|
20
20
|
includeEntropy: boolean;
|
|
21
21
|
entropyThreshold: number;
|
|
22
22
|
verifySecrets: boolean;
|
|
23
23
|
scanHistory: boolean;
|
|
24
24
|
}, {
|
|
25
25
|
targetPath: string;
|
|
26
|
+
secretTypes?: ("api-key" | "aws-key" | "aws-secret" | "azure-key" | "certificate" | "connection-string" | "gcp-key" | "generic" | "password" | "private-key" | "token")[] | undefined;
|
|
26
27
|
excludePatterns?: string[] | undefined;
|
|
27
|
-
secretTypes?: ("password" | "token" | "api-key" | "private-key" | "connection-string" | "certificate" | "aws-key" | "aws-secret" | "gcp-key" | "azure-key" | "generic")[] | undefined;
|
|
28
28
|
includeEntropy?: boolean | undefined;
|
|
29
29
|
entropyThreshold?: number | undefined;
|
|
30
30
|
verifySecrets?: boolean | undefined;
|
|
@@ -116,16 +116,16 @@ export declare const toolDefinition: {
|
|
|
116
116
|
scanHistory: z.ZodDefault<z.ZodBoolean>;
|
|
117
117
|
}, "strip", z.ZodTypeAny, {
|
|
118
118
|
targetPath: string;
|
|
119
|
+
secretTypes: ("api-key" | "aws-key" | "aws-secret" | "azure-key" | "certificate" | "connection-string" | "gcp-key" | "generic" | "password" | "private-key" | "token")[];
|
|
119
120
|
excludePatterns: string[];
|
|
120
|
-
secretTypes: ("password" | "token" | "api-key" | "private-key" | "connection-string" | "certificate" | "aws-key" | "aws-secret" | "gcp-key" | "azure-key" | "generic")[];
|
|
121
121
|
includeEntropy: boolean;
|
|
122
122
|
entropyThreshold: number;
|
|
123
123
|
verifySecrets: boolean;
|
|
124
124
|
scanHistory: boolean;
|
|
125
125
|
}, {
|
|
126
126
|
targetPath: string;
|
|
127
|
+
secretTypes?: ("api-key" | "aws-key" | "aws-secret" | "azure-key" | "certificate" | "connection-string" | "gcp-key" | "generic" | "password" | "private-key" | "token")[] | undefined;
|
|
127
128
|
excludePatterns?: string[] | undefined;
|
|
128
|
-
secretTypes?: ("password" | "token" | "api-key" | "private-key" | "connection-string" | "certificate" | "aws-key" | "aws-secret" | "gcp-key" | "azure-key" | "generic")[] | undefined;
|
|
129
129
|
includeEntropy?: boolean | undefined;
|
|
130
130
|
entropyThreshold?: number | undefined;
|
|
131
131
|
verifySecrets?: boolean | undefined;
|
|
@@ -127,6 +127,12 @@ export declare class EWCConsolidator {
|
|
|
127
127
|
private globalFisher;
|
|
128
128
|
private consolidationHistory;
|
|
129
129
|
private initialized;
|
|
130
|
+
/** Dirty flag: true when in-memory state diverges from disk */
|
|
131
|
+
private dirty;
|
|
132
|
+
/** Pending debounced write timer */
|
|
133
|
+
private saveTimer;
|
|
134
|
+
/** Debounce window for disk writes (ms) */
|
|
135
|
+
private static readonly SAVE_DEBOUNCE_MS;
|
|
130
136
|
constructor(config?: Partial<EWCConfig>);
|
|
131
137
|
/**
|
|
132
138
|
* Initialize the consolidator by loading persisted state
|
|
@@ -237,6 +243,12 @@ export declare class EWCConsolidator {
|
|
|
237
243
|
* Prune old, low-importance patterns to stay within limit
|
|
238
244
|
*/
|
|
239
245
|
private pruneOldPatterns;
|
|
246
|
+
/**
|
|
247
|
+
* Schedule a debounced disk flush.
|
|
248
|
+
* Multiple calls within SAVE_DEBOUNCE_MS coalesce into one write,
|
|
249
|
+
* preventing blocking I/O on every consolidation or gradient event.
|
|
250
|
+
*/
|
|
251
|
+
private scheduleSave;
|
|
240
252
|
/**
|
|
241
253
|
* Save state to disk
|
|
242
254
|
*/
|
|
@@ -94,6 +94,12 @@ export declare class SONAOptimizer {
|
|
|
94
94
|
private failedRoutings;
|
|
95
95
|
private lastUpdate;
|
|
96
96
|
private persistencePath;
|
|
97
|
+
/** Set when in-memory state diverges from disk — triggers next debounced write */
|
|
98
|
+
private dirty;
|
|
99
|
+
/** NodeJS timeout handle for debounced disk flush */
|
|
100
|
+
private saveTimer;
|
|
101
|
+
/** Debounce window for disk writes (ms) — batches rapid trajectory bursts */
|
|
102
|
+
private static readonly SAVE_DEBOUNCE_MS;
|
|
97
103
|
constructor(options?: {
|
|
98
104
|
persistencePath?: string;
|
|
99
105
|
});
|
|
@@ -182,6 +188,12 @@ export declare class SONAOptimizer {
|
|
|
182
188
|
* Load patterns from disk
|
|
183
189
|
*/
|
|
184
190
|
private loadFromDisk;
|
|
191
|
+
/**
|
|
192
|
+
* Schedule a debounced disk flush.
|
|
193
|
+
* Multiple calls within SAVE_DEBOUNCE_MS coalesce into a single write,
|
|
194
|
+
* preventing blocking I/O on every trajectory event during swarm bursts.
|
|
195
|
+
*/
|
|
196
|
+
private scheduleSave;
|
|
185
197
|
/**
|
|
186
198
|
* Save patterns to disk
|
|
187
199
|
*/
|
|
@@ -4,7 +4,9 @@ export interface BrokerEntry {
|
|
|
4
4
|
updatedAt: number;
|
|
5
5
|
}
|
|
6
6
|
export declare function defaultRegistryDir(): string;
|
|
7
|
-
/** Publish that this process hosts org `name`, reachable via `url`. Call again periodically (heartbeat) — see BrokerLease.
|
|
7
|
+
/** Publish that this process hosts org `name`, reachable via `url`. Call again periodically (heartbeat) — see BrokerLease.
|
|
8
|
+
* Writes via tmp+rename (same-directory rename is atomic on POSIX/NTFS) so a concurrent lookupOrg() never observes a
|
|
9
|
+
* partially-written entry — this file is rewritten every heartbeat (default 20s) while other processes may read it. */
|
|
8
10
|
export declare function registerOrg(name: string, url: string, dir?: string): void;
|
|
9
11
|
/** Remove this process's registration for `name` (best effort). */
|
|
10
12
|
export declare function unregisterOrg(name: string, dir?: string): void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// monolean: file-based local broker for cross-process org discovery (different
|
|
3
3
|
// `monomind org` processes / project directories, same machine). Upgrade path:
|
|
4
4
|
// a real network registry when cross-machine discovery is needed.
|
|
5
|
-
import { mkdirSync, writeFileSync, readFileSync, unlinkSync } from 'node:fs';
|
|
5
|
+
import { mkdirSync, writeFileSync, readFileSync, unlinkSync, renameSync } from 'node:fs';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { homedir } from 'node:os';
|
|
8
8
|
const SAFE_NAME = /^[a-z0-9][a-z0-9_-]*$/i;
|
|
@@ -15,11 +15,16 @@ function entryPath(name, dir) {
|
|
|
15
15
|
throw new Error(`invalid org name for broker registry: ${name}`);
|
|
16
16
|
return join(dir, `${name}.json`);
|
|
17
17
|
}
|
|
18
|
-
/** Publish that this process hosts org `name`, reachable via `url`. Call again periodically (heartbeat) — see BrokerLease.
|
|
18
|
+
/** Publish that this process hosts org `name`, reachable via `url`. Call again periodically (heartbeat) — see BrokerLease.
|
|
19
|
+
* Writes via tmp+rename (same-directory rename is atomic on POSIX/NTFS) so a concurrent lookupOrg() never observes a
|
|
20
|
+
* partially-written entry — this file is rewritten every heartbeat (default 20s) while other processes may read it. */
|
|
19
21
|
export function registerOrg(name, url, dir = defaultRegistryDir()) {
|
|
20
22
|
mkdirSync(dir, { recursive: true });
|
|
21
23
|
const entry = { url, pid: process.pid, updatedAt: Date.now() };
|
|
22
|
-
|
|
24
|
+
const dest = entryPath(name, dir);
|
|
25
|
+
const tmp = `${dest}.${process.pid}.tmp`;
|
|
26
|
+
writeFileSync(tmp, JSON.stringify(entry));
|
|
27
|
+
renameSync(tmp, dest);
|
|
23
28
|
}
|
|
24
29
|
/** Remove this process's registration for `name` (best effort). */
|
|
25
30
|
export function unregisterOrg(name, dir = defaultRegistryDir()) {
|
|
@@ -15,7 +15,11 @@ export declare class OrgBus {
|
|
|
15
15
|
constructor(org: string, run: string, dir: string);
|
|
16
16
|
subscribe(fn: Listener): () => void;
|
|
17
17
|
emit(partial: Omit<BusEvent, 'id' | 'ts' | 'org' | 'run'>): BusEvent;
|
|
18
|
-
/**
|
|
18
|
+
/** Await all queued disk writes (tests, shutdown). Listeners registered via subscribe() run
|
|
19
|
+
* synchronously inside emit() — flush() has no visibility into any async work they schedule
|
|
20
|
+
* off of that (e.g. the forwarder's HTTP POSTs). A caller that needs an async subscriber's
|
|
21
|
+
* work to have settled too must await that subscriber's own completion signal separately
|
|
22
|
+
* (see daemon.ts stopOrg(), which awaits forwarder.settle() alongside bus.flush()). */
|
|
19
23
|
flush(): Promise<void>;
|
|
20
24
|
static readHistory(dir: string): BusEvent[];
|
|
21
25
|
}
|
|
@@ -45,7 +45,11 @@ export class OrgBus {
|
|
|
45
45
|
}
|
|
46
46
|
return e;
|
|
47
47
|
}
|
|
48
|
-
/**
|
|
48
|
+
/** Await all queued disk writes (tests, shutdown). Listeners registered via subscribe() run
|
|
49
|
+
* synchronously inside emit() — flush() has no visibility into any async work they schedule
|
|
50
|
+
* off of that (e.g. the forwarder's HTTP POSTs). A caller that needs an async subscriber's
|
|
51
|
+
* work to have settled too must await that subscriber's own completion signal separately
|
|
52
|
+
* (see daemon.ts stopOrg(), which awaits forwarder.settle() alongside bus.flush()). */
|
|
49
53
|
flush() { return this.pending; }
|
|
50
54
|
static readHistory(dir) {
|
|
51
55
|
const f = join(dir, 'bus.jsonl');
|
|
@@ -33,11 +33,14 @@ export interface DaemonOpts {
|
|
|
33
33
|
inboxUrl?: string;
|
|
34
34
|
/** Override the broker's file registry directory (tests only). */
|
|
35
35
|
brokerDir?: string;
|
|
36
|
+
/** Override how long stopOrg() waits for agent sessions before proceeding anyway (tests only; default 15000ms). */
|
|
37
|
+
stopWaitMs?: number;
|
|
36
38
|
}
|
|
37
39
|
export declare class OrgDaemon {
|
|
38
40
|
private root;
|
|
39
41
|
private opts;
|
|
40
42
|
private orgs;
|
|
43
|
+
private waking;
|
|
41
44
|
private globalSubscribers;
|
|
42
45
|
private leases;
|
|
43
46
|
private forwarders;
|
|
@@ -49,9 +52,18 @@ export declare class OrgDaemon {
|
|
|
49
52
|
listOrgs(): RunningOrg[];
|
|
50
53
|
getOrg(name: string): RunningOrg | undefined;
|
|
51
54
|
startOrg(name: string, taskOverride?: string): Promise<RunningOrg>;
|
|
55
|
+
/**
|
|
56
|
+
* Resolves an org_send `to` address ("role" for same-org, "org:role" for
|
|
57
|
+
* cross-org) into its parts. Centralizes the one addressing rule that
|
|
58
|
+
* matters (an "own-org:role" self-prefix is intra-org, not cross-org) so
|
|
59
|
+
* deliver()/deliverRemote() don't each re-derive it — the qualified `to`
|
|
60
|
+
* string returned is always the canonical display form for that address.
|
|
61
|
+
*/
|
|
62
|
+
private resolveAddress;
|
|
52
63
|
/** Route a message. to = "role" (same org) or "org:role" (cross-org). Returns a receipt string. */
|
|
53
64
|
deliver(fromOrg: string, fromRole: string, to: string, subject: string, body: string): Promise<string>;
|
|
54
|
-
/** Cross-process leg of deliver(): ask the machine-local broker who hosts targetOrgName, then POST over HTTP.
|
|
65
|
+
/** Cross-process leg of deliver(): ask the machine-local broker who hosts targetOrgName, then POST over HTTP.
|
|
66
|
+
* `to` here is always the fully-qualified "org:role" display form (resolveAddress already normalized it). */
|
|
55
67
|
private deliverRemote;
|
|
56
68
|
/** Inbound handler for cross-process delivery — called by the server's POST /api/xdeliver route
|
|
57
69
|
* when ANOTHER process's deliverRemote() reaches this daemon. Pushes straight into the target
|
|
@@ -63,6 +75,28 @@ export declare class OrgDaemon {
|
|
|
63
75
|
ok: false;
|
|
64
76
|
error: string;
|
|
65
77
|
};
|
|
78
|
+
private hasOrgDef;
|
|
79
|
+
private questionsPath;
|
|
80
|
+
private readQuestions;
|
|
81
|
+
private writeQuestions;
|
|
82
|
+
/** Agent-initiated human question (ask_human tool). Persists to questions.json (survives
|
|
83
|
+
* process/dashboard restarts) and emits a 'question' BusEvent so the dashboard's SSE
|
|
84
|
+
* stream and global inbox pick it up in real time. Returns a receipt string for the tool call. */
|
|
85
|
+
askHuman(org: string, role: string, question: string): Promise<string>;
|
|
86
|
+
/** Delivers a human's answer to a pending ask_human question. If the org is still
|
|
87
|
+
* running, pushes straight into the role's live mailbox (picked up on its very next
|
|
88
|
+
* generator tick — see Mailbox.stream()). If the org has since stopped, queues the
|
|
89
|
+
* answer via the same offline fallback deliver()/receiveRemote() already use
|
|
90
|
+
* (inbox.ts + autoWake) and it's delivered when the org next starts. */
|
|
91
|
+
answerQuestion(org: string, role: string, questionId: string, answer: string): Promise<{
|
|
92
|
+
ok: true;
|
|
93
|
+
} | {
|
|
94
|
+
ok: false;
|
|
95
|
+
error: string;
|
|
96
|
+
}>;
|
|
97
|
+
/** Start an offline org in the background so queued messages get drained.
|
|
98
|
+
* Fire-and-forget — errors are logged but don't propagate to the sender. */
|
|
99
|
+
private autoWake;
|
|
66
100
|
stopOrg(name: string): Promise<void>;
|
|
67
101
|
stopAll(): Promise<void>;
|
|
68
102
|
private persistState;
|