@monoclaw/machine 1.0.21 → 1.0.23
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/cli.js +154 -39
- package/npm-shrinkwrap.json +2 -2
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -883,7 +883,9 @@ var ProviderAccountReport = z3.object({
|
|
|
883
883
|
/** The module this connection belongs to. */
|
|
884
884
|
module: ModuleId,
|
|
885
885
|
type: ProviderAccountType,
|
|
886
|
-
readiness: ProviderReadiness
|
|
886
|
+
readiness: ProviderReadiness,
|
|
887
|
+
/** The connection's monthly cap, as set on the machine or by the server (machine programs from 1.0.22). */
|
|
888
|
+
settings: z3.object({ monthlyCapUsd: z3.number().optional(), monthlyCapCharacters: z3.number().optional() }).optional()
|
|
887
889
|
});
|
|
888
890
|
var ModelInfo = z3.object({ id: z3.string(), name: z3.string(), description: z3.string().default("") });
|
|
889
891
|
var CommandInfo = z3.object({ name: z3.string(), description: z3.string().default(""), argumentHint: z3.string().default("") });
|
|
@@ -1221,6 +1223,11 @@ var RouterFrame = z4.discriminatedUnion("t", [
|
|
|
1221
1223
|
* The answer to a `tool.call`, a `tool.use` or a `tools.find`: the tool's text for the agent, and the files it made, which the agent's host saves in
|
|
1222
1224
|
* the agent's folder (under `images/`).
|
|
1223
1225
|
*/
|
|
1226
|
+
/**
|
|
1227
|
+
* The server received a `tool.use` and is running it (machine programs from 1.0.22). `readOnly`: the tool only reads, so
|
|
1228
|
+
* if the connection is lost before the result the call is safe to repeat; otherwise the agent is told it may have run.
|
|
1229
|
+
*/
|
|
1230
|
+
z4.object({ t: z4.literal("tool.started"), groupId: z4.string(), id: z4.string(), readOnly: z4.boolean() }),
|
|
1224
1231
|
z4.object({
|
|
1225
1232
|
t: z4.literal("tool.result"),
|
|
1226
1233
|
groupId: z4.string(),
|
|
@@ -1247,7 +1254,15 @@ var RouterFrame = z4.discriminatedUnion("t", [
|
|
|
1247
1254
|
/** A client's one-shot envelope with the account's secret, sealed to the host's public key; relayed once, never stored. */
|
|
1248
1255
|
z4.object({ t: z4.literal("provider_account.secret"), id: z4.string(), envelope: z4.string() }),
|
|
1249
1256
|
/** Rename an account or change its allowed folders (the host keeps its own copy and enforces the folders). */
|
|
1250
|
-
z4.object({
|
|
1257
|
+
z4.object({
|
|
1258
|
+
t: z4.literal("provider_account.update"),
|
|
1259
|
+
id: z4.string(),
|
|
1260
|
+
name: z4.string().optional(),
|
|
1261
|
+
allowedFolders: z4.array(z4.string()).optional(),
|
|
1262
|
+
/** A monthly cap on the key (machine programs from 1.0.22; docs/spec/modules.md § 6): a number sets it, null clears it, absent leaves it. */
|
|
1263
|
+
monthlyCapUsd: z4.number().positive().nullable().optional(),
|
|
1264
|
+
monthlyCapCharacters: z4.number().int().positive().nullable().optional()
|
|
1265
|
+
}),
|
|
1251
1266
|
/** Forget an account and its secret. */
|
|
1252
1267
|
z4.object({ t: z4.literal("provider_account.remove"), id: z4.string() }),
|
|
1253
1268
|
/** Re-check an account's readiness now; answered with `provider_account.readiness`. */
|
|
@@ -1622,6 +1637,25 @@ function settableArgs(fields, input) {
|
|
|
1622
1637
|
function unknownTool(moduleName, name, tools) {
|
|
1623
1638
|
return new Error(`${moduleName} has no tool "${name}". Its tools: ${tools.map((t) => t.name).join(", ") || "none"}.`);
|
|
1624
1639
|
}
|
|
1640
|
+
var mmss = (ms) => {
|
|
1641
|
+
const s = Math.round(ms / 1e3);
|
|
1642
|
+
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
|
|
1643
|
+
};
|
|
1644
|
+
function audioWords(out) {
|
|
1645
|
+
const ms = out.files.reduce((n, f) => n + (f.durationMs ?? 0), 0);
|
|
1646
|
+
return ms > 0 ? `Made ${mmss(ms)} of audio.` : "Made audio.";
|
|
1647
|
+
}
|
|
1648
|
+
function transcriptWords(out, fileName, moduleName) {
|
|
1649
|
+
const text2 = (out.text ?? "").trim();
|
|
1650
|
+
if (!text2) return `${fileName} has no speech that ${moduleName} could hear.`;
|
|
1651
|
+
return `Transcript of ${fileName}${out.language ? ` (${out.language})` : ""}:
|
|
1652
|
+
|
|
1653
|
+
${text2}`;
|
|
1654
|
+
}
|
|
1655
|
+
function imageWords(out) {
|
|
1656
|
+
const n = out.files.length;
|
|
1657
|
+
return n === 0 ? "Made no image." : `Made ${n} image${n === 1 ? "" : "s"}.`;
|
|
1658
|
+
}
|
|
1625
1659
|
|
|
1626
1660
|
// src/modules/echo.ts
|
|
1627
1661
|
var PIXEL = Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==", "base64");
|
|
@@ -1646,10 +1680,6 @@ function silentWav(durationMs, voice) {
|
|
|
1646
1680
|
header.writeUInt32LE(samples, 40);
|
|
1647
1681
|
return Buffer.concat([header, data]);
|
|
1648
1682
|
}
|
|
1649
|
-
var TTS_FIELDS = [
|
|
1650
|
-
{ key: "voice", label: "Voice", type: "select", choices: [{ value: "echo-a", label: "Echo A", group: "Test" }, { value: "echo-b", label: "Echo B", group: "Test" }], default: "echo-a", required: false },
|
|
1651
|
-
{ key: "speed", label: "Speed", type: "number", min: 0.5, max: 2, step: 0.05, default: 1, required: false }
|
|
1652
|
-
];
|
|
1653
1683
|
var STT_FIELDS = [{ key: "language", label: "Language", type: "select", choices: [{ value: "auto", label: "Detect" }, { value: "en", label: "English" }], default: "auto", required: false }];
|
|
1654
1684
|
var IMAGE_FIELDS = [
|
|
1655
1685
|
{ key: "image_size", label: "Size", type: "select", choices: [{ value: "square", label: "Square" }, { value: "landscape_16_9", label: "Landscape 16:9" }], default: "square", required: false, agentSettable: true },
|
|
@@ -1662,7 +1692,7 @@ var echoModule = {
|
|
|
1662
1692
|
manifestVersion: 1,
|
|
1663
1693
|
id: "echo",
|
|
1664
1694
|
name: "Echo (test)",
|
|
1665
|
-
summary: "Repeats what you say, and fakes
|
|
1695
|
+
summary: "Repeats what you say, and fakes transcripts and images. For testing without a model.",
|
|
1666
1696
|
category: "other",
|
|
1667
1697
|
publisher: { name: "MonoClaw", tier: "monoclaw" },
|
|
1668
1698
|
runs: "local",
|
|
@@ -1670,7 +1700,7 @@ var echoModule = {
|
|
|
1670
1700
|
cost: null,
|
|
1671
1701
|
provides: {
|
|
1672
1702
|
agent: { providerId: "echo" },
|
|
1673
|
-
jobs: ["
|
|
1703
|
+
jobs: ["transcription"],
|
|
1674
1704
|
tools: [
|
|
1675
1705
|
{
|
|
1676
1706
|
name: "echo_image",
|
|
@@ -1685,7 +1715,6 @@ var echoModule = {
|
|
|
1685
1715
|
result: { views: ["images", "text"] },
|
|
1686
1716
|
timeoutMs: 3e4
|
|
1687
1717
|
},
|
|
1688
|
-
speakTool("echo_speak", "the echo module (silence of the right length)", false),
|
|
1689
1718
|
transcribeTool("echo_transcribe", "the echo module (it reports the bytes it heard)", false),
|
|
1690
1719
|
{
|
|
1691
1720
|
name: "echo_lookup",
|
|
@@ -1703,25 +1732,25 @@ var echoModule = {
|
|
|
1703
1732
|
]
|
|
1704
1733
|
}
|
|
1705
1734
|
},
|
|
1706
|
-
legacyCapabilities: ["agent", "
|
|
1735
|
+
legacyCapabilities: ["agent", "stt", "image"],
|
|
1707
1736
|
providerId: "echo",
|
|
1708
1737
|
defaultConnection: { id: "echo", name: "Echo (test)" },
|
|
1709
1738
|
status: () => ({ state: "ready", progress: null, summary: "Ready" }),
|
|
1710
1739
|
readiness: async () => ({ ready: true, summary: "Ready", details: {} }),
|
|
1711
1740
|
async options(use) {
|
|
1712
|
-
return use === "
|
|
1741
|
+
return use === "transcription" || use === "tool:echo_transcribe" ? STT_FIELDS : use === "tool:echo_image" ? IMAGE_FIELDS : [];
|
|
1713
1742
|
},
|
|
1714
|
-
estimate: (job) => job.capability === "tts" ? { characters: job.text.length } : {},
|
|
1715
1743
|
async runTool(name, input, files, options, conn, secret) {
|
|
1716
|
-
if (name === "echo_speak") return this.run({ capability: "tts", text: String(input.text ?? ""), options: resolveOptions(TTS_FIELDS, options, settableArgs(TTS_FIELDS, input)) }, conn, secret);
|
|
1717
1744
|
if (name === "echo_transcribe") {
|
|
1718
1745
|
const file = files.find((f) => f.field === "file");
|
|
1719
1746
|
if (!file) throw new Error("echo_transcribe needs the file to transcribe.");
|
|
1720
|
-
|
|
1747
|
+
const out = await this.run({ capability: "stt", audio: file.bytes, mime: file.mime, options: resolveOptions(STT_FIELDS, options, settableArgs(STT_FIELDS, input)) }, conn, secret);
|
|
1748
|
+
return { ...out, text: transcriptWords(out, file.name, "Echo") };
|
|
1721
1749
|
}
|
|
1722
1750
|
if (name === "echo_image") {
|
|
1723
1751
|
const ref = files.find((f) => f.field === "reference_image");
|
|
1724
|
-
|
|
1752
|
+
const out = await this.run({ capability: "image", prompt: String(input.prompt ?? ""), args: settableArgs(IMAGE_FIELDS, input), options, ...ref ? { reference: { bytes: ref.bytes, mime: ref.mime } } : {} }, conn, secret);
|
|
1753
|
+
return { ...out, text: imageWords(out) };
|
|
1725
1754
|
}
|
|
1726
1755
|
if (name === "echo_lookup") {
|
|
1727
1756
|
const q = String(input.query ?? "").trim();
|
|
@@ -1734,12 +1763,7 @@ ${JSON.stringify(q)},${JSON.stringify(`echo found ${q} again`)}
|
|
|
1734
1763
|
throw unknownTool("Echo (test)", name, this.manifest.provides.tools);
|
|
1735
1764
|
},
|
|
1736
1765
|
async run(job) {
|
|
1737
|
-
if (job.capability === "tts")
|
|
1738
|
-
const o2 = resolveOptions(TTS_FIELDS, job.options);
|
|
1739
|
-
if (/echo-fail/.test(job.text)) throw new Error("echo cannot say that");
|
|
1740
|
-
const durationMs = Math.round(job.text.length * 60 / num(o2.speed, 1));
|
|
1741
|
-
return { files: [{ bytes: silentWav(durationMs, str(o2.voice, "echo-a")), mime: "audio/wav", name: "speech.wav", durationMs }], usage: { amount: job.text.length, unit: "characters" } };
|
|
1742
|
-
}
|
|
1766
|
+
if (job.capability === "tts") throw new Error("echo does not speak: the fake voice is the echo-voice module.");
|
|
1743
1767
|
if (job.capability === "stt") return { files: [], text: `echo heard ${job.audio.length} bytes of ${job.mime}`, language: "en", usage: { amount: 1, unit: "seconds" } };
|
|
1744
1768
|
if (job.capability === "tool") throw new Error("echo runs its tools through runTool.");
|
|
1745
1769
|
const o = resolveOptions(IMAGE_FIELDS, job.options, job.args);
|
|
@@ -1748,6 +1772,53 @@ ${JSON.stringify(q)},${JSON.stringify(`echo found ${q} again`)}
|
|
|
1748
1772
|
}
|
|
1749
1773
|
};
|
|
1750
1774
|
|
|
1775
|
+
// src/modules/echo-voice.ts
|
|
1776
|
+
var ECHO_VOICE_FIELDS = [
|
|
1777
|
+
{ key: "voice", label: "Voice", type: "select", choices: [{ value: "echo-a", label: "Echo A", group: "Test" }, { value: "echo-b", label: "Echo B", group: "Test" }], default: "echo-a", required: false },
|
|
1778
|
+
{ key: "speed", label: "Speed", type: "number", min: 0.5, max: 2, step: 0.05, default: 1, required: false }
|
|
1779
|
+
];
|
|
1780
|
+
var echoVoiceModule = {
|
|
1781
|
+
id: "echo-voice",
|
|
1782
|
+
version: "1.0.0",
|
|
1783
|
+
manifest: {
|
|
1784
|
+
manifestVersion: 1,
|
|
1785
|
+
id: "echo-voice",
|
|
1786
|
+
name: "Echo voice (test)",
|
|
1787
|
+
summary: "A fake voice for your agents: silence of the right length, playable. For testing without a model.",
|
|
1788
|
+
category: "voice",
|
|
1789
|
+
publisher: { name: "MonoClaw", tier: "monoclaw" },
|
|
1790
|
+
runs: "local",
|
|
1791
|
+
key: null,
|
|
1792
|
+
cost: null,
|
|
1793
|
+
provides: {
|
|
1794
|
+
jobs: ["speech"],
|
|
1795
|
+
tools: [speakTool("echo_voice_speak", "the echo voice module (silence of the right length)", false)]
|
|
1796
|
+
}
|
|
1797
|
+
},
|
|
1798
|
+
legacyCapabilities: ["tts"],
|
|
1799
|
+
defaultConnection: { id: "echo-voice", name: "Echo voice (test)" },
|
|
1800
|
+
status: () => ({ state: "ready", progress: null, summary: "Ready" }),
|
|
1801
|
+
readiness: async () => ({ ready: true, summary: "Ready", details: {} }),
|
|
1802
|
+
async options(use) {
|
|
1803
|
+
return use === "speech" || use === "tool:echo_voice_speak" ? ECHO_VOICE_FIELDS : [];
|
|
1804
|
+
},
|
|
1805
|
+
estimate: (job) => job.capability === "tts" ? { characters: job.text.length } : {},
|
|
1806
|
+
async runTool(name, input, _files, options, conn, secret) {
|
|
1807
|
+
if (name === "echo_voice_speak") {
|
|
1808
|
+
const out = await this.run({ capability: "tts", text: String(input.text ?? ""), options: resolveOptions(ECHO_VOICE_FIELDS, options, settableArgs(ECHO_VOICE_FIELDS, input)) }, conn, secret);
|
|
1809
|
+
return { ...out, text: audioWords(out) };
|
|
1810
|
+
}
|
|
1811
|
+
throw unknownTool("Echo voice (test)", name, this.manifest.provides.tools);
|
|
1812
|
+
},
|
|
1813
|
+
async run(job) {
|
|
1814
|
+
if (job.capability !== "tts") throw new Error("Echo voice (test) only speaks.");
|
|
1815
|
+
const o = resolveOptions(ECHO_VOICE_FIELDS, job.options);
|
|
1816
|
+
if (/echo-fail/.test(job.text)) throw new Error("echo cannot say that");
|
|
1817
|
+
const durationMs = Math.round(job.text.length * 60 / num(o.speed, 1));
|
|
1818
|
+
return { files: [{ bytes: silentWav(durationMs, str(o.voice, "echo-a")), mime: "audio/wav", name: "speech.wav", durationMs }], usage: { amount: job.text.length, unit: "characters" } };
|
|
1819
|
+
}
|
|
1820
|
+
};
|
|
1821
|
+
|
|
1751
1822
|
// src/modules/http.ts
|
|
1752
1823
|
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
1753
1824
|
async function readCapped(res, cap, what = "file") {
|
|
@@ -1938,12 +2009,14 @@ function elevenlabsModule(deps = {}) {
|
|
|
1938
2009
|
estimate: (job) => job.capability === "tts" ? { characters: job.text.length } : job.capability === "tool" && job.tool === "elevenlabs_speak" ? { characters: String(job.input.text ?? "").length } : {},
|
|
1939
2010
|
async runTool(name, input, files, options, conn, secret) {
|
|
1940
2011
|
if (name === "elevenlabs_speak") {
|
|
1941
|
-
|
|
2012
|
+
const spoken = await this.run({ capability: "tts", text: String(input.text ?? ""), options: { ...options, ...settableArgs(await this.options("speech", conn, secret), input) } }, conn, secret);
|
|
2013
|
+
return { ...spoken, text: audioWords(spoken) };
|
|
1942
2014
|
}
|
|
1943
2015
|
if (name === "elevenlabs_transcribe") {
|
|
1944
2016
|
const file = files.find((f2) => f2.field === "file");
|
|
1945
2017
|
if (!file) throw new Error("elevenlabs_transcribe needs the file to transcribe.");
|
|
1946
|
-
|
|
2018
|
+
const heard = await this.run({ capability: "stt", audio: file.bytes, mime: file.mime, options: resolveOptions(ELEVENLABS_STT_FIELDS, options, settableArgs(ELEVENLABS_STT_FIELDS, input)) }, conn, secret);
|
|
2019
|
+
return { ...heard, text: transcriptWords(heard, file.name, "ElevenLabs") };
|
|
1947
2020
|
}
|
|
1948
2021
|
throw unknownTool("ElevenLabs", name, this.manifest.provides.tools);
|
|
1949
2022
|
},
|
|
@@ -2119,7 +2192,8 @@ function falModule(deps = {}) {
|
|
|
2119
2192
|
},
|
|
2120
2193
|
async runTool(name, input, files, options, conn, secret) {
|
|
2121
2194
|
if (name !== "fal_image") throw unknownTool(this.manifest.name, name, this.manifest.provides.tools);
|
|
2122
|
-
|
|
2195
|
+
const out = await this.run(asImageJob({ capability: "tool", tool: name, input, files, options }), conn, secret);
|
|
2196
|
+
return { ...out, text: imageWords(out) };
|
|
2123
2197
|
},
|
|
2124
2198
|
async run(job, _conn, secret) {
|
|
2125
2199
|
if (job.capability !== "image") throw new Error("fal makes images.");
|
|
@@ -3597,7 +3671,8 @@ function kokoroModule(voice) {
|
|
|
3597
3671
|
estimate: (job) => job.capability === "tts" ? { characters: job.text.length } : job.capability === "tool" ? { characters: String(job.input.text ?? "").length } : {},
|
|
3598
3672
|
async runTool(name, input, _files, options, conn, secret) {
|
|
3599
3673
|
if (name !== "kokoro_speak") throw unknownTool("Kokoro", name, this.manifest.provides.tools);
|
|
3600
|
-
|
|
3674
|
+
const out = await this.run({ capability: "tts", text: String(input.text ?? ""), options: resolveOptions(KOKORO_FIELDS, options, settableArgs(KOKORO_FIELDS, input)) }, conn, secret);
|
|
3675
|
+
return { ...out, text: audioWords(out) };
|
|
3601
3676
|
},
|
|
3602
3677
|
async run(job) {
|
|
3603
3678
|
if (job.capability !== "tts") throw new Error("Kokoro only makes speech.");
|
|
@@ -3697,7 +3772,8 @@ function parakeetModule(voice) {
|
|
|
3697
3772
|
if (name !== "parakeet_transcribe") throw unknownTool("Parakeet", name, this.manifest.provides.tools);
|
|
3698
3773
|
const file = files.find((f) => f.field === "file");
|
|
3699
3774
|
if (!file) throw new Error("parakeet_transcribe needs the file to transcribe.");
|
|
3700
|
-
|
|
3775
|
+
const out = await this.run({ capability: "stt", audio: file.bytes, mime: file.mime, options: resolveOptions(PARAKEET_FIELDS, options, settableArgs(PARAKEET_FIELDS, input)) }, conn, secret);
|
|
3776
|
+
return { ...out, text: transcriptWords(out, file.name, "Parakeet") };
|
|
3701
3777
|
},
|
|
3702
3778
|
async run(job) {
|
|
3703
3779
|
if (job.capability !== "stt") throw new Error("Parakeet only transcribes.");
|
|
@@ -3889,6 +3965,7 @@ var UsageLedger = class {
|
|
|
3889
3965
|
|
|
3890
3966
|
// src/modules/index.ts
|
|
3891
3967
|
var echoFromEnv = () => (process.env.MONOCLAW_PROVIDERS ?? "").split(",").map((s) => s.trim()).includes("echo");
|
|
3968
|
+
var TEST_MODULES = /* @__PURE__ */ new Set(["echo", "echo-voice"]);
|
|
3892
3969
|
function defaultModules(deps) {
|
|
3893
3970
|
const claude = deps.providers.claude;
|
|
3894
3971
|
const probe = async (env) => claude ? claude.probe(env) : { ready: false, summary: "Claude Code is switched off on this host (MONOCLAW_PROVIDERS)", details: {} };
|
|
@@ -3899,7 +3976,8 @@ function defaultModules(deps) {
|
|
|
3899
3976
|
kokoro: kokoroModule(deps.voice),
|
|
3900
3977
|
elevenlabs: elevenlabsModule({ fetch: deps.fetch }),
|
|
3901
3978
|
fal: falModule({ fetch: deps.fetch }),
|
|
3902
|
-
echo: echoModule
|
|
3979
|
+
echo: echoModule,
|
|
3980
|
+
"echo-voice": echoVoiceModule
|
|
3903
3981
|
};
|
|
3904
3982
|
}
|
|
3905
3983
|
var CHECKING = { ready: false, summary: "Checking\u2026", details: {} };
|
|
@@ -3936,7 +4014,7 @@ var ModuleRegistry = class {
|
|
|
3936
4014
|
}
|
|
3937
4015
|
/** What this machine can install, each with its version and its setup steps for this platform. */
|
|
3938
4016
|
catalogue() {
|
|
3939
|
-
return Object.keys(this.all).filter((id) => id
|
|
4017
|
+
return Object.keys(this.all).filter((id) => !TEST_MODULES.has(id) || this.echoAllowed()).map((id) => {
|
|
3940
4018
|
const m = this.all[id];
|
|
3941
4019
|
return { ...legacyCatalogueOf(m), version: m.version, setup: moduleSetup(m), manifest: this.manifestOf(m) };
|
|
3942
4020
|
});
|
|
@@ -3997,7 +4075,7 @@ var ModuleRegistry = class {
|
|
|
3997
4075
|
add(id) {
|
|
3998
4076
|
const m = this.module(id);
|
|
3999
4077
|
if (!m) throw new Error(`There is no module "${id}". See \`monoclaw modules list --all\`.`);
|
|
4000
|
-
if (id
|
|
4078
|
+
if (TEST_MODULES.has(id) && !this.echoAllowed()) throw new Error(`${id} is a test module: start the host with MONOCLAW_PROVIDERS=echo to use it.`);
|
|
4001
4079
|
if (!this.deps.config.get().modules.some((x) => x.id === id)) this.deps.config.update((c) => ({ ...c, modules: [...c.modules, { id, addedAt: (/* @__PURE__ */ new Date()).toISOString(), settings: {} }] }));
|
|
4002
4080
|
if (m.defaultConnection && !this.deps.accounts.get(m.defaultConnection.id)) this.deps.accounts.upsert({ id: m.defaultConnection.id, name: m.defaultConnection.name, type: connectionTypeOf(m), module: m.id, provider: m.providerId ?? m.id });
|
|
4003
4081
|
log("info", `module ${id} added`);
|
|
@@ -4086,7 +4164,7 @@ var ModuleRegistry = class {
|
|
|
4086
4164
|
return this.installedIds().map((id) => this.report(id));
|
|
4087
4165
|
}
|
|
4088
4166
|
connectionReports() {
|
|
4089
|
-
return this.connections().map((c) => ({ id: c.id, name: c.name, provider: c.provider, module: c.module, type: c.type, readiness: this.readinessCache.get(c.id) ?? CHECKING }));
|
|
4167
|
+
return this.connections().map((c) => ({ id: c.id, name: c.name, provider: c.provider, module: c.module, type: c.type, readiness: this.readinessCache.get(c.id) ?? CHECKING, ...c.settings && Object.keys(c.settings).length ? { settings: c.settings } : {} }));
|
|
4090
4168
|
}
|
|
4091
4169
|
/**
|
|
4092
4170
|
* The fields a module offers for one use, choices filled in (live where the module fetches them). `use` is the word
|
|
@@ -4169,14 +4247,13 @@ function formatToolResult(tool2, r, cwd) {
|
|
|
4169
4247
|
const where = f.path ? cwd ? path12.relative(cwd, f.path) || f.path : f.path : "";
|
|
4170
4248
|
lines.push(where ? `Saved ${where} (attachment:${f.attachmentId})` : `Made ${f.name} (attachment:${f.attachmentId}; not saved to the folder in this scope)`);
|
|
4171
4249
|
}
|
|
4172
|
-
if (made.length) lines.push(`The people in the project see ${made.every((f) => f.mime.startsWith("audio/")) ? "this audio" : "these images"} in your steps.`);
|
|
4250
|
+
if (made.length) lines.push(`The people in the project see ${made.every((f) => f.mime.startsWith("audio/")) ? "this audio" : made.every((f) => f.mime.startsWith("image/")) ? made.length === 1 ? "this image" : "these images" : made.length === 1 ? "this file" : "these files"} in your steps.`);
|
|
4173
4251
|
return { content: [{ type: "text", text: lines.join("\n") }, ...shown] };
|
|
4174
4252
|
}
|
|
4175
4253
|
function formatUseResult(name, r, cwd) {
|
|
4176
4254
|
if (r.error) return { content: [{ type: "text", text: r.error }], isError: true };
|
|
4177
4255
|
return formatToolResult({ name }, r, cwd);
|
|
4178
4256
|
}
|
|
4179
|
-
var READ_ONLY_TOOLS = /* @__PURE__ */ new Set(["find_tools", "list_agents", "image_view", "agents_options", "agents_read_profile"]);
|
|
4180
4257
|
var RESTART_PLAIN = "The service restarted while this ran; call it again.";
|
|
4181
4258
|
function restartMessage(call) {
|
|
4182
4259
|
switch (call.kind) {
|
|
@@ -4184,7 +4261,7 @@ function restartMessage(call) {
|
|
|
4184
4261
|
case "list":
|
|
4185
4262
|
return RESTART_PLAIN;
|
|
4186
4263
|
case "use":
|
|
4187
|
-
return
|
|
4264
|
+
return `The service restarted while ${call.name} ran. It may have run anyway: anything it made would be in your steps for the people in the project, and it may have cost money. Ask the person before calling it again.`;
|
|
4188
4265
|
case "send":
|
|
4189
4266
|
return `The service restarted while this message was being sent to ${call.to}. It may have arrived. If it matters, ask ${call.to} whether it did before sending it again.`;
|
|
4190
4267
|
}
|
|
@@ -4205,6 +4282,11 @@ var ToolWaits = class {
|
|
|
4205
4282
|
resolve(id, r) {
|
|
4206
4283
|
this.waits.get(id)?.finish(r);
|
|
4207
4284
|
}
|
|
4285
|
+
/** The service is running the call and says whether it only reads: a read is safe to repeat if the connection is lost meanwhile. */
|
|
4286
|
+
started(id, readOnly) {
|
|
4287
|
+
const w = this.waits.get(id);
|
|
4288
|
+
if (w && readOnly) w.lost = RESTART_PLAIN;
|
|
4289
|
+
}
|
|
4208
4290
|
closeAll(reason = "Session closed.") {
|
|
4209
4291
|
for (const w of [...this.waits.values()]) w.finish({ error: reason, files: [] });
|
|
4210
4292
|
}
|
|
@@ -4311,6 +4393,9 @@ var SessionToolRunner = class {
|
|
|
4311
4393
|
result(id, r) {
|
|
4312
4394
|
this.waits.resolve(id, r);
|
|
4313
4395
|
}
|
|
4396
|
+
started(id, readOnly) {
|
|
4397
|
+
this.waits.started(id, readOnly);
|
|
4398
|
+
}
|
|
4314
4399
|
/** The connection to the service closed: every waiting call ends now (bug: a tool call lost in a server restart). */
|
|
4315
4400
|
failWaiting() {
|
|
4316
4401
|
this.waits.failWaiting();
|
|
@@ -4685,7 +4770,7 @@ var SessionManager = class {
|
|
|
4685
4770
|
}
|
|
4686
4771
|
/**
|
|
4687
4772
|
* The server's answer to a `tool.call`. A Full agent's files are saved under `<cwd>/images/` (audio under
|
|
4688
|
-
* `<cwd>/audio/`) first; read-only and
|
|
4773
|
+
* `<cwd>/audio/`, any other kind under `<cwd>/files/`) first; read-only and
|
|
4689
4774
|
* chat-only sessions don't write to the folder, so they get only the attachment ids.
|
|
4690
4775
|
*/
|
|
4691
4776
|
async toolResult(groupId, id, r) {
|
|
@@ -4709,7 +4794,7 @@ var SessionManager = class {
|
|
|
4709
4794
|
continue;
|
|
4710
4795
|
}
|
|
4711
4796
|
try {
|
|
4712
|
-
files.push({ ...base, path: await this.saveFile(f, filesDirIn(live.cwd, f.mime.startsWith("audio/") ? "audio" : "images")) });
|
|
4797
|
+
files.push({ ...base, path: await this.saveFile(f, filesDirIn(live.cwd, f.mime.startsWith("audio/") ? "audio" : f.mime.startsWith("image/") ? "images" : "files")) });
|
|
4713
4798
|
} catch (e) {
|
|
4714
4799
|
log("warn", `[${groupId.slice(0, 8)}] could not save ${f.name}: ${e.message}`);
|
|
4715
4800
|
files.push(base);
|
|
@@ -4717,6 +4802,10 @@ var SessionManager = class {
|
|
|
4717
4802
|
}
|
|
4718
4803
|
live.session.toolResult?.(id, { text: r.text, error: r.error, files, ...r.next ? { next: r.next } : {} });
|
|
4719
4804
|
}
|
|
4805
|
+
/** The service is running a call (`tool.started`, 1.0.22): a read-only one is safe to repeat if the connection is lost. */
|
|
4806
|
+
toolStarted(groupId, id, readOnly) {
|
|
4807
|
+
this.live.get(groupId)?.session?.toolStarted?.(id, readOnly);
|
|
4808
|
+
}
|
|
4720
4809
|
answerApproval(groupId, id, allow, updatedInput) {
|
|
4721
4810
|
const live = this.live.get(groupId);
|
|
4722
4811
|
if (!live) return;
|
|
@@ -5020,7 +5109,7 @@ function guessMime(name) {
|
|
|
5020
5109
|
}
|
|
5021
5110
|
|
|
5022
5111
|
// src/version.ts
|
|
5023
|
-
var APP_VERSION = true ? "1.0.
|
|
5112
|
+
var APP_VERSION = true ? "1.0.23" : fromPackage();
|
|
5024
5113
|
|
|
5025
5114
|
// src/diag.ts
|
|
5026
5115
|
var MAX_HELD = 200;
|
|
@@ -5427,6 +5516,9 @@ var HostClient = class {
|
|
|
5427
5516
|
case "tool.result":
|
|
5428
5517
|
await this.sessions.toolResult(frame.groupId, frame.id, { text: frame.text, error: frame.error, files: frame.files, next: frame.next });
|
|
5429
5518
|
return;
|
|
5519
|
+
case "tool.started":
|
|
5520
|
+
this.sessions.toolStarted(frame.groupId, frame.id, frame.readOnly);
|
|
5521
|
+
return;
|
|
5430
5522
|
case "module.add":
|
|
5431
5523
|
try {
|
|
5432
5524
|
const { install } = this.registry.add(frame.module);
|
|
@@ -5495,7 +5587,18 @@ var HostClient = class {
|
|
|
5495
5587
|
}
|
|
5496
5588
|
case "provider_account.update": {
|
|
5497
5589
|
const a = this.accounts.get(frame.id);
|
|
5498
|
-
if (a)
|
|
5590
|
+
if (a) {
|
|
5591
|
+
this.accounts.upsert({ id: a.id, name: frame.name ?? a.name, type: a.type, module: a.module, provider: a.provider, allowedFolders: frame.allowedFolders ?? a.allowedFolders });
|
|
5592
|
+
if (frame.monthlyCapUsd !== void 0 || frame.monthlyCapCharacters !== void 0) {
|
|
5593
|
+
const settings = { ...a.settings ?? {} };
|
|
5594
|
+
if (frame.monthlyCapUsd === null) delete settings.monthlyCapUsd;
|
|
5595
|
+
else if (frame.monthlyCapUsd !== void 0) settings.monthlyCapUsd = frame.monthlyCapUsd;
|
|
5596
|
+
if (frame.monthlyCapCharacters === null) delete settings.monthlyCapCharacters;
|
|
5597
|
+
else if (frame.monthlyCapCharacters !== void 0) settings.monthlyCapCharacters = frame.monthlyCapCharacters;
|
|
5598
|
+
this.accounts.setSettings(a.id, settings);
|
|
5599
|
+
log("info", `connection ${a.id.slice(0, 12)}: monthly cap ${settings.monthlyCapUsd !== void 0 ? `$${settings.monthlyCapUsd}` : settings.monthlyCapCharacters !== void 0 ? `${settings.monthlyCapCharacters} characters` : "cleared"}`);
|
|
5600
|
+
}
|
|
5601
|
+
}
|
|
5499
5602
|
await this.reportAccount(frame.id);
|
|
5500
5603
|
return;
|
|
5501
5604
|
}
|
|
@@ -6385,8 +6488,14 @@ ${r.text}`, final: true });
|
|
|
6385
6488
|
}
|
|
6386
6489
|
if (text2.startsWith("find:") || text2.startsWith("use:")) {
|
|
6387
6490
|
const rest = text2.slice(text2.indexOf(":") + 1);
|
|
6388
|
-
const
|
|
6389
|
-
|
|
6491
|
+
const name = rest.split(":")[0]?.trim() ?? "";
|
|
6492
|
+
const input = rest.split(":").slice(1).join(":");
|
|
6493
|
+
const callId = text2.startsWith("use:") ? `tu-${newId().slice(0, 8)}` : null;
|
|
6494
|
+
if (callId) this.q.push({ kind: "tool", id: callId, name: `mcp__monoclaw-tools__${name}`, summary: `Use ${name}`, input });
|
|
6495
|
+
const r = text2.startsWith("find:") ? await this.tools.find({ query: rest.trim() || void 0 }) : await this.tools.use({ name, input });
|
|
6496
|
+
const out = r.content.map((c) => c.type === "text" ? c.text : `[image ${c.mimeType}, ${c.data.length} base64 characters]`).join("\n");
|
|
6497
|
+
if (callId) this.q.push({ kind: "tool_result", id: callId, name: `mcp__monoclaw-tools__${name}`, output: out, isError: !!r.isError });
|
|
6498
|
+
this.q.push({ kind: "text", text: out, final: true });
|
|
6390
6499
|
this.q.push({ kind: "done", interrupted: false });
|
|
6391
6500
|
return;
|
|
6392
6501
|
}
|
|
@@ -6450,6 +6559,9 @@ ${r.text}`, final: true });
|
|
|
6450
6559
|
toolResult(id, result) {
|
|
6451
6560
|
this.tools.result(id, result);
|
|
6452
6561
|
}
|
|
6562
|
+
toolStarted(id, readOnly) {
|
|
6563
|
+
this.tools.started(id, readOnly);
|
|
6564
|
+
}
|
|
6453
6565
|
connectionLost() {
|
|
6454
6566
|
for (const w of [...this.agentWaits.values()]) w.finish({ error: w.lost });
|
|
6455
6567
|
this.tools.failWaiting();
|
|
@@ -7122,6 +7234,9 @@ ${files.map((a) => `- ${a.localPath} (${a.mime}, ${a.size} bytes)${a.note ? `: $
|
|
|
7122
7234
|
toolResult(id, result) {
|
|
7123
7235
|
this.tools.result(id, result);
|
|
7124
7236
|
}
|
|
7237
|
+
toolStarted(id, readOnly) {
|
|
7238
|
+
this.tools.started(id, readOnly);
|
|
7239
|
+
}
|
|
7125
7240
|
/** The machine's connection to the service closed: what was waiting for it ends now, each call with its own words. */
|
|
7126
7241
|
connectionLost() {
|
|
7127
7242
|
for (const w of [...this.agentWaits.values()]) w.finish({ error: w.lost });
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monoclaw/machine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@monoclaw/machine",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.23",
|
|
10
10
|
"license": "UNLICENSED",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/claude-agent-sdk": "0.3.302",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monoclaw/machine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "Monoclaw host app: runs agents on your machine and connects them to your Monoclaw account (command.monoclaw.ai).",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"lint": "eslint src tests",
|
|
57
57
|
"test": "vitest run --exclude tests/claude.e2e.test.ts",
|
|
58
58
|
"test:claude": "vitest run tests/claude.e2e.test.ts",
|
|
59
|
-
"shrinkwrap": "node scripts/shrinkwrap.mjs"
|
|
59
|
+
"shrinkwrap": "node scripts/shrinkwrap.mjs",
|
|
60
|
+
"manifests": "tsx scripts/emit-manifests.ts"
|
|
60
61
|
}
|
|
61
62
|
}
|