mono-pilot 0.2.10 → 0.2.13
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 +260 -2
- package/dist/src/agents-paths.js +36 -0
- package/dist/src/brief/blocks.js +83 -0
- package/dist/src/brief/defaults.js +60 -0
- package/dist/src/brief/frontmatter.js +53 -0
- package/dist/src/brief/paths.js +10 -0
- package/dist/src/brief/reflection.js +27 -0
- package/dist/src/cli.js +62 -5
- package/dist/src/cluster/bus.js +102 -0
- package/dist/src/cluster/follower.js +137 -0
- package/dist/src/cluster/init.js +182 -0
- package/dist/src/cluster/leader.js +97 -0
- package/dist/src/cluster/log.js +49 -0
- package/dist/src/cluster/protocol.js +34 -0
- package/dist/src/cluster/services/bus.js +243 -0
- package/dist/src/cluster/services/embedding.js +12 -0
- package/dist/src/cluster/socket.js +86 -0
- package/dist/src/cluster/test-bus.js +175 -0
- package/dist/src/cluster_v2/connection-lifecycle.js +31 -0
- package/dist/src/cluster_v2/connection-lifecycle.test.js +24 -0
- package/dist/src/cluster_v2/connection.js +159 -0
- package/dist/src/cluster_v2/connection.test.js +55 -0
- package/dist/src/cluster_v2/events.js +102 -0
- package/dist/src/cluster_v2/index.js +2 -0
- package/dist/src/cluster_v2/observability.js +99 -0
- package/dist/src/cluster_v2/observability.test.js +46 -0
- package/dist/src/cluster_v2/rpc.js +389 -0
- package/dist/src/cluster_v2/rpc.test.js +110 -0
- package/dist/src/cluster_v2/runtime.failover.integration.test.js +156 -0
- package/dist/src/cluster_v2/runtime.js +531 -0
- package/dist/src/cluster_v2/runtime.lease-compromise.integration.test.js +91 -0
- package/dist/src/cluster_v2/runtime.lifecycle.integration.test.js +225 -0
- package/dist/src/cluster_v2/services/bus.integration.test.js +140 -0
- package/dist/src/cluster_v2/services/bus.js +450 -0
- package/dist/src/cluster_v2/services/discord/auth-store.js +82 -0
- package/dist/src/cluster_v2/services/discord/collector.js +569 -0
- package/dist/src/cluster_v2/services/discord/index.js +1 -0
- package/dist/src/cluster_v2/services/discord/oauth.js +87 -0
- package/dist/src/cluster_v2/services/discord/rpc-client.js +325 -0
- package/dist/src/cluster_v2/services/embedding.js +66 -0
- package/dist/src/cluster_v2/services/registry-cache.js +107 -0
- package/dist/src/cluster_v2/services/registry-cache.test.js +66 -0
- package/dist/src/cluster_v2/services/registry.js +36 -0
- package/dist/src/cluster_v2/services/twitter/collector.js +1055 -0
- package/dist/src/cluster_v2/services/twitter/index.js +1 -0
- package/dist/src/config/digest.js +78 -0
- package/dist/src/config/discord.js +143 -0
- package/dist/src/config/image-gen.js +48 -0
- package/dist/src/config/mono-pilot.js +31 -0
- package/dist/src/config/twitter.js +100 -0
- package/dist/src/extensions/cluster.js +311 -0
- package/dist/src/extensions/commands/build-memory.js +76 -0
- package/dist/src/extensions/commands/digest/backfill.js +779 -0
- package/dist/src/extensions/commands/digest/index.js +1133 -0
- package/dist/src/extensions/commands/image-model.js +214 -0
- package/dist/src/extensions/game/bus-injection.js +47 -0
- package/dist/src/extensions/game/identity.js +83 -0
- package/dist/src/extensions/game/mailbox.js +61 -0
- package/dist/src/extensions/game/system-prompt.js +134 -0
- package/dist/src/extensions/game/tools.js +28 -0
- package/dist/src/extensions/lifecycle.js +337 -0
- package/dist/src/extensions/mode-runtime.js +26 -2
- package/dist/src/extensions/mono-game.js +66 -0
- package/dist/src/extensions/mono-pilot.js +100 -18
- package/dist/src/extensions/nvim.js +47 -0
- package/dist/src/extensions/session-hints.js +1 -2
- package/dist/src/extensions/sftp.js +897 -0
- package/dist/src/extensions/status.js +676 -0
- package/dist/src/extensions/system-events.js +478 -0
- package/dist/src/extensions/system-prompt.js +24 -14
- package/dist/src/extensions/user-message.js +70 -1
- package/dist/src/lsp/client.js +235 -0
- package/dist/src/lsp/index.js +165 -0
- package/dist/src/lsp/runtime.js +67 -0
- package/dist/src/lsp/server.js +242 -0
- package/dist/src/memory/build-memory.js +103 -0
- package/dist/src/memory/config/defaults.js +55 -0
- package/dist/src/memory/config/loader.js +29 -0
- package/dist/src/memory/config/paths.js +9 -0
- package/dist/src/memory/config/resolve.js +90 -0
- package/dist/src/memory/config/types.js +1 -0
- package/dist/src/memory/embeddings/batch-runner.js +39 -0
- package/dist/src/memory/embeddings/cache.js +47 -0
- package/dist/src/memory/embeddings/chunk-limits.js +26 -0
- package/dist/src/memory/embeddings/input-limits.js +48 -0
- package/dist/src/memory/embeddings/local.js +108 -0
- package/dist/src/memory/embeddings/types.js +1 -0
- package/dist/src/memory/index-manager.js +552 -0
- package/dist/src/memory/indexing/embeddings.js +67 -0
- package/dist/src/memory/indexing/files.js +180 -0
- package/dist/src/memory/indexing/index-file.js +105 -0
- package/dist/src/memory/log.js +38 -0
- package/dist/src/memory/paths.js +15 -0
- package/dist/src/memory/runtime/index.js +299 -0
- package/dist/src/memory/runtime/thread.js +116 -0
- package/dist/src/memory/search/fts.js +57 -0
- package/dist/src/memory/search/hybrid.js +50 -0
- package/dist/src/memory/search/text.js +30 -0
- package/dist/src/memory/search/vector.js +43 -0
- package/dist/src/memory/session/content-hash.js +7 -0
- package/dist/src/memory/session/entry.js +33 -0
- package/dist/src/memory/session/flush-policy.js +34 -0
- package/dist/src/memory/session/hook.js +191 -0
- package/dist/src/memory/session/paths.js +15 -0
- package/dist/src/memory/session/session-reader.js +88 -0
- package/dist/src/memory/session/transcript/content-hash.js +7 -0
- package/dist/src/memory/session/transcript/entry.js +28 -0
- package/dist/src/memory/session/transcript/flush.js +56 -0
- package/dist/src/memory/session/transcript/paths.js +28 -0
- package/dist/src/memory/session/transcript/reader.js +112 -0
- package/dist/src/memory/session/transcript/state.js +31 -0
- package/dist/src/memory/store/schema.js +89 -0
- package/dist/src/memory/store/sqlite.js +89 -0
- package/dist/src/memory/types.js +1 -0
- package/dist/src/memory/warm.js +25 -0
- package/dist/{tools → src/tools}/README.md +28 -2
- package/dist/{tools → src/tools}/apply-patch-description.md +8 -2
- package/dist/{tools → src/tools}/apply-patch.js +174 -104
- package/dist/{tools → src/tools}/apply-patch.test.js +52 -1
- package/dist/{tools/ask-question.js → src/tools/ask-user-question.js} +3 -3
- package/dist/src/tools/ast-grep.js +357 -0
- package/dist/src/tools/brief-write.js +122 -0
- package/dist/src/tools/bus-send.js +100 -0
- package/dist/{tools → src/tools}/call-mcp-tool.js +20 -24
- package/dist/src/tools/codex-apply-patch-description.md +52 -0
- package/dist/src/tools/codex-apply-patch.js +540 -0
- package/dist/{tools → src/tools}/delete.js +24 -0
- package/dist/src/tools/exit-plan-mode.js +83 -0
- package/dist/{tools → src/tools}/fetch-mcp-resource.js +31 -3
- package/dist/src/tools/generate-image.js +567 -0
- package/dist/{tools → src/tools}/glob.js +55 -1
- package/dist/{tools → src/tools}/list-mcp-resources.js +32 -3
- package/dist/{tools → src/tools}/list-mcp-tools.js +38 -3
- package/dist/src/tools/ls.js +48 -0
- package/dist/src/tools/lsp-diagnostics.js +67 -0
- package/dist/src/tools/lsp-symbols.js +54 -0
- package/dist/src/tools/mailbox.js +85 -0
- package/dist/src/tools/memory-get.js +90 -0
- package/dist/src/tools/memory-search.js +180 -0
- package/dist/{tools → src/tools}/plan-mode-reminder.md +3 -4
- package/dist/{tools → src/tools}/read-file.js +8 -19
- package/dist/{tools → src/tools}/rg.js +10 -20
- package/dist/{tools → src/tools}/shell.js +19 -42
- package/dist/{tools → src/tools}/subagent.js +255 -6
- package/dist/{tools → src/tools}/switch-mode.js +37 -6
- package/dist/{tools → src/tools}/web-fetch.js +105 -7
- package/dist/{tools → src/tools}/web-search.js +29 -1
- package/package.json +21 -9
- package/dist/src/utils/mcp-client.js +0 -282
- /package/dist/{tools → src/tools}/ask-mode-reminder.md +0 -0
- /package/dist/{tools → src/tools}/rg.test.js +0 -0
- /package/dist/{tools → src/tools}/semantic-search-description.md +0 -0
- /package/dist/{tools → src/tools}/semantic-search.js +0 -0
- /package/dist/{tools → src/tools}/shell-description.md +0 -0
- /package/dist/{tools → src/tools}/subagent-description.md +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Helpers for enforcing embedding model input size limits.
|
|
2
|
+
// Tokenizers operate over bytes; token_count <= utf8_byte_length.
|
|
3
|
+
export function estimateUtf8Bytes(text) {
|
|
4
|
+
if (!text)
|
|
5
|
+
return 0;
|
|
6
|
+
return Buffer.byteLength(text, "utf8");
|
|
7
|
+
}
|
|
8
|
+
export function splitTextToUtf8ByteLimit(text, maxUtf8Bytes) {
|
|
9
|
+
if (maxUtf8Bytes <= 0)
|
|
10
|
+
return [text];
|
|
11
|
+
if (estimateUtf8Bytes(text) <= maxUtf8Bytes)
|
|
12
|
+
return [text];
|
|
13
|
+
const parts = [];
|
|
14
|
+
let cursor = 0;
|
|
15
|
+
while (cursor < text.length) {
|
|
16
|
+
let low = cursor + 1;
|
|
17
|
+
let high = Math.min(text.length, cursor + maxUtf8Bytes);
|
|
18
|
+
let best = cursor;
|
|
19
|
+
while (low <= high) {
|
|
20
|
+
const mid = Math.floor((low + high) / 2);
|
|
21
|
+
const bytes = estimateUtf8Bytes(text.slice(cursor, mid));
|
|
22
|
+
if (bytes <= maxUtf8Bytes) {
|
|
23
|
+
best = mid;
|
|
24
|
+
low = mid + 1;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
high = mid - 1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (best <= cursor) {
|
|
31
|
+
best = Math.min(text.length, cursor + 1);
|
|
32
|
+
}
|
|
33
|
+
if (best < text.length &&
|
|
34
|
+
best > cursor &&
|
|
35
|
+
text.charCodeAt(best - 1) >= 0xd800 &&
|
|
36
|
+
text.charCodeAt(best - 1) <= 0xdbff &&
|
|
37
|
+
text.charCodeAt(best) >= 0xdc00 &&
|
|
38
|
+
text.charCodeAt(best) <= 0xdfff) {
|
|
39
|
+
best -= 1;
|
|
40
|
+
}
|
|
41
|
+
const part = text.slice(cursor, best);
|
|
42
|
+
if (!part)
|
|
43
|
+
break;
|
|
44
|
+
parts.push(part);
|
|
45
|
+
cursor = best;
|
|
46
|
+
}
|
|
47
|
+
return parts;
|
|
48
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
function normalizeEmbedding(vector) {
|
|
4
|
+
const sanitized = vector.map((value) => (Number.isFinite(value) ? value : 0));
|
|
5
|
+
const magnitude = Math.sqrt(sanitized.reduce((sum, value) => sum + value * value, 0));
|
|
6
|
+
if (magnitude < 1e-10) {
|
|
7
|
+
return sanitized;
|
|
8
|
+
}
|
|
9
|
+
return sanitized.map((value) => value / magnitude);
|
|
10
|
+
}
|
|
11
|
+
export async function createLocalEmbeddingProvider(params) {
|
|
12
|
+
const modelPath = params.modelPath?.trim() || "hf:gpustack/bge-m3-GGUF/bge-m3-Q8_0.gguf";
|
|
13
|
+
const modelCacheDir = params.modelCacheDir?.trim() || join(homedir(), ".mono-pilot", "models");
|
|
14
|
+
const nodeLlamaCpp = await import("node-llama-cpp");
|
|
15
|
+
const { getLlama, resolveModelFile } = nodeLlamaCpp;
|
|
16
|
+
const logLevel = nodeLlamaCpp.LlamaLogLevel?.error;
|
|
17
|
+
let llama = null;
|
|
18
|
+
let model = null;
|
|
19
|
+
let context = null;
|
|
20
|
+
let closing = false;
|
|
21
|
+
let inFlightRequests = 0;
|
|
22
|
+
let disposePromise = null;
|
|
23
|
+
const idleWaiters = new Set();
|
|
24
|
+
const notifyIfIdle = () => {
|
|
25
|
+
if (inFlightRequests !== 0) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
for (const resolve of idleWaiters) {
|
|
29
|
+
resolve();
|
|
30
|
+
}
|
|
31
|
+
idleWaiters.clear();
|
|
32
|
+
};
|
|
33
|
+
const waitForIdle = async () => {
|
|
34
|
+
if (inFlightRequests === 0) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
await new Promise((resolve) => {
|
|
38
|
+
idleWaiters.add(resolve);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const runWithInFlightTracking = async (operation) => {
|
|
42
|
+
if (closing) {
|
|
43
|
+
throw new Error("embedding provider is closing");
|
|
44
|
+
}
|
|
45
|
+
inFlightRequests += 1;
|
|
46
|
+
try {
|
|
47
|
+
return await operation();
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
inFlightRequests = Math.max(0, inFlightRequests - 1);
|
|
51
|
+
notifyIfIdle();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const ensureContext = async () => {
|
|
55
|
+
if (!llama) {
|
|
56
|
+
llama = await getLlama({ logLevel: logLevel ?? "error" });
|
|
57
|
+
}
|
|
58
|
+
if (!model) {
|
|
59
|
+
const resolved = await resolveModelFile(modelPath, modelCacheDir);
|
|
60
|
+
model = await llama.loadModel({ modelPath: resolved });
|
|
61
|
+
}
|
|
62
|
+
if (!context) {
|
|
63
|
+
context = await model.createEmbeddingContext();
|
|
64
|
+
}
|
|
65
|
+
return context;
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
id: "local",
|
|
69
|
+
model: modelPath,
|
|
70
|
+
embedQuery: async (text) => {
|
|
71
|
+
return runWithInFlightTracking(async () => {
|
|
72
|
+
const ctx = await ensureContext();
|
|
73
|
+
const embedding = await ctx.getEmbeddingFor(text);
|
|
74
|
+
return normalizeEmbedding(Array.from(embedding.vector));
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
embedBatch: async (texts) => {
|
|
78
|
+
return runWithInFlightTracking(async () => {
|
|
79
|
+
const ctx = await ensureContext();
|
|
80
|
+
const embeddings = await Promise.all(texts.map(async (text) => {
|
|
81
|
+
const embedding = await ctx.getEmbeddingFor(text);
|
|
82
|
+
return normalizeEmbedding(Array.from(embedding.vector));
|
|
83
|
+
}));
|
|
84
|
+
return embeddings;
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
dispose: async () => {
|
|
88
|
+
if (disposePromise) {
|
|
89
|
+
await disposePromise;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
closing = true;
|
|
93
|
+
disposePromise = (async () => {
|
|
94
|
+
await waitForIdle();
|
|
95
|
+
if (context) {
|
|
96
|
+
await context.dispose();
|
|
97
|
+
context = null;
|
|
98
|
+
}
|
|
99
|
+
if (model) {
|
|
100
|
+
await model.dispose();
|
|
101
|
+
model = null;
|
|
102
|
+
}
|
|
103
|
+
llama = null;
|
|
104
|
+
})();
|
|
105
|
+
await disposePromise;
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|