@monoclaw/machine 1.0.21 → 1.0.22
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 +90 -15
- 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");
|
|
@@ -1713,15 +1747,20 @@ var echoModule = {
|
|
|
1713
1747
|
},
|
|
1714
1748
|
estimate: (job) => job.capability === "tts" ? { characters: job.text.length } : {},
|
|
1715
1749
|
async runTool(name, input, files, options, conn, secret) {
|
|
1716
|
-
if (name === "echo_speak")
|
|
1750
|
+
if (name === "echo_speak") {
|
|
1751
|
+
const out = await this.run({ capability: "tts", text: String(input.text ?? ""), options: resolveOptions(TTS_FIELDS, options, settableArgs(TTS_FIELDS, input)) }, conn, secret);
|
|
1752
|
+
return { ...out, text: audioWords(out) };
|
|
1753
|
+
}
|
|
1717
1754
|
if (name === "echo_transcribe") {
|
|
1718
1755
|
const file = files.find((f) => f.field === "file");
|
|
1719
1756
|
if (!file) throw new Error("echo_transcribe needs the file to transcribe.");
|
|
1720
|
-
|
|
1757
|
+
const out = await this.run({ capability: "stt", audio: file.bytes, mime: file.mime, options: resolveOptions(STT_FIELDS, options, settableArgs(STT_FIELDS, input)) }, conn, secret);
|
|
1758
|
+
return { ...out, text: transcriptWords(out, file.name, "Echo") };
|
|
1721
1759
|
}
|
|
1722
1760
|
if (name === "echo_image") {
|
|
1723
1761
|
const ref = files.find((f) => f.field === "reference_image");
|
|
1724
|
-
|
|
1762
|
+
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);
|
|
1763
|
+
return { ...out, text: imageWords(out) };
|
|
1725
1764
|
}
|
|
1726
1765
|
if (name === "echo_lookup") {
|
|
1727
1766
|
const q = String(input.query ?? "").trim();
|
|
@@ -1938,12 +1977,14 @@ function elevenlabsModule(deps = {}) {
|
|
|
1938
1977
|
estimate: (job) => job.capability === "tts" ? { characters: job.text.length } : job.capability === "tool" && job.tool === "elevenlabs_speak" ? { characters: String(job.input.text ?? "").length } : {},
|
|
1939
1978
|
async runTool(name, input, files, options, conn, secret) {
|
|
1940
1979
|
if (name === "elevenlabs_speak") {
|
|
1941
|
-
|
|
1980
|
+
const spoken = await this.run({ capability: "tts", text: String(input.text ?? ""), options: { ...options, ...settableArgs(await this.options("speech", conn, secret), input) } }, conn, secret);
|
|
1981
|
+
return { ...spoken, text: audioWords(spoken) };
|
|
1942
1982
|
}
|
|
1943
1983
|
if (name === "elevenlabs_transcribe") {
|
|
1944
1984
|
const file = files.find((f2) => f2.field === "file");
|
|
1945
1985
|
if (!file) throw new Error("elevenlabs_transcribe needs the file to transcribe.");
|
|
1946
|
-
|
|
1986
|
+
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);
|
|
1987
|
+
return { ...heard, text: transcriptWords(heard, file.name, "ElevenLabs") };
|
|
1947
1988
|
}
|
|
1948
1989
|
throw unknownTool("ElevenLabs", name, this.manifest.provides.tools);
|
|
1949
1990
|
},
|
|
@@ -2119,7 +2160,8 @@ function falModule(deps = {}) {
|
|
|
2119
2160
|
},
|
|
2120
2161
|
async runTool(name, input, files, options, conn, secret) {
|
|
2121
2162
|
if (name !== "fal_image") throw unknownTool(this.manifest.name, name, this.manifest.provides.tools);
|
|
2122
|
-
|
|
2163
|
+
const out = await this.run(asImageJob({ capability: "tool", tool: name, input, files, options }), conn, secret);
|
|
2164
|
+
return { ...out, text: imageWords(out) };
|
|
2123
2165
|
},
|
|
2124
2166
|
async run(job, _conn, secret) {
|
|
2125
2167
|
if (job.capability !== "image") throw new Error("fal makes images.");
|
|
@@ -3597,7 +3639,8 @@ function kokoroModule(voice) {
|
|
|
3597
3639
|
estimate: (job) => job.capability === "tts" ? { characters: job.text.length } : job.capability === "tool" ? { characters: String(job.input.text ?? "").length } : {},
|
|
3598
3640
|
async runTool(name, input, _files, options, conn, secret) {
|
|
3599
3641
|
if (name !== "kokoro_speak") throw unknownTool("Kokoro", name, this.manifest.provides.tools);
|
|
3600
|
-
|
|
3642
|
+
const out = await this.run({ capability: "tts", text: String(input.text ?? ""), options: resolveOptions(KOKORO_FIELDS, options, settableArgs(KOKORO_FIELDS, input)) }, conn, secret);
|
|
3643
|
+
return { ...out, text: audioWords(out) };
|
|
3601
3644
|
},
|
|
3602
3645
|
async run(job) {
|
|
3603
3646
|
if (job.capability !== "tts") throw new Error("Kokoro only makes speech.");
|
|
@@ -3697,7 +3740,8 @@ function parakeetModule(voice) {
|
|
|
3697
3740
|
if (name !== "parakeet_transcribe") throw unknownTool("Parakeet", name, this.manifest.provides.tools);
|
|
3698
3741
|
const file = files.find((f) => f.field === "file");
|
|
3699
3742
|
if (!file) throw new Error("parakeet_transcribe needs the file to transcribe.");
|
|
3700
|
-
|
|
3743
|
+
const out = await this.run({ capability: "stt", audio: file.bytes, mime: file.mime, options: resolveOptions(PARAKEET_FIELDS, options, settableArgs(PARAKEET_FIELDS, input)) }, conn, secret);
|
|
3744
|
+
return { ...out, text: transcriptWords(out, file.name, "Parakeet") };
|
|
3701
3745
|
},
|
|
3702
3746
|
async run(job) {
|
|
3703
3747
|
if (job.capability !== "stt") throw new Error("Parakeet only transcribes.");
|
|
@@ -4086,7 +4130,7 @@ var ModuleRegistry = class {
|
|
|
4086
4130
|
return this.installedIds().map((id) => this.report(id));
|
|
4087
4131
|
}
|
|
4088
4132
|
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 }));
|
|
4133
|
+
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
4134
|
}
|
|
4091
4135
|
/**
|
|
4092
4136
|
* The fields a module offers for one use, choices filled in (live where the module fetches them). `use` is the word
|
|
@@ -4176,7 +4220,6 @@ function formatUseResult(name, r, cwd) {
|
|
|
4176
4220
|
if (r.error) return { content: [{ type: "text", text: r.error }], isError: true };
|
|
4177
4221
|
return formatToolResult({ name }, r, cwd);
|
|
4178
4222
|
}
|
|
4179
|
-
var READ_ONLY_TOOLS = /* @__PURE__ */ new Set(["find_tools", "list_agents", "image_view", "agents_options", "agents_read_profile"]);
|
|
4180
4223
|
var RESTART_PLAIN = "The service restarted while this ran; call it again.";
|
|
4181
4224
|
function restartMessage(call) {
|
|
4182
4225
|
switch (call.kind) {
|
|
@@ -4184,7 +4227,7 @@ function restartMessage(call) {
|
|
|
4184
4227
|
case "list":
|
|
4185
4228
|
return RESTART_PLAIN;
|
|
4186
4229
|
case "use":
|
|
4187
|
-
return
|
|
4230
|
+
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
4231
|
case "send":
|
|
4189
4232
|
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
4233
|
}
|
|
@@ -4205,6 +4248,11 @@ var ToolWaits = class {
|
|
|
4205
4248
|
resolve(id, r) {
|
|
4206
4249
|
this.waits.get(id)?.finish(r);
|
|
4207
4250
|
}
|
|
4251
|
+
/** The service is running the call and says whether it only reads: a read is safe to repeat if the connection is lost meanwhile. */
|
|
4252
|
+
started(id, readOnly) {
|
|
4253
|
+
const w = this.waits.get(id);
|
|
4254
|
+
if (w && readOnly) w.lost = RESTART_PLAIN;
|
|
4255
|
+
}
|
|
4208
4256
|
closeAll(reason = "Session closed.") {
|
|
4209
4257
|
for (const w of [...this.waits.values()]) w.finish({ error: reason, files: [] });
|
|
4210
4258
|
}
|
|
@@ -4311,6 +4359,9 @@ var SessionToolRunner = class {
|
|
|
4311
4359
|
result(id, r) {
|
|
4312
4360
|
this.waits.resolve(id, r);
|
|
4313
4361
|
}
|
|
4362
|
+
started(id, readOnly) {
|
|
4363
|
+
this.waits.started(id, readOnly);
|
|
4364
|
+
}
|
|
4314
4365
|
/** The connection to the service closed: every waiting call ends now (bug: a tool call lost in a server restart). */
|
|
4315
4366
|
failWaiting() {
|
|
4316
4367
|
this.waits.failWaiting();
|
|
@@ -4717,6 +4768,10 @@ var SessionManager = class {
|
|
|
4717
4768
|
}
|
|
4718
4769
|
live.session.toolResult?.(id, { text: r.text, error: r.error, files, ...r.next ? { next: r.next } : {} });
|
|
4719
4770
|
}
|
|
4771
|
+
/** The service is running a call (`tool.started`, 1.0.22): a read-only one is safe to repeat if the connection is lost. */
|
|
4772
|
+
toolStarted(groupId, id, readOnly) {
|
|
4773
|
+
this.live.get(groupId)?.session?.toolStarted?.(id, readOnly);
|
|
4774
|
+
}
|
|
4720
4775
|
answerApproval(groupId, id, allow, updatedInput) {
|
|
4721
4776
|
const live = this.live.get(groupId);
|
|
4722
4777
|
if (!live) return;
|
|
@@ -5020,7 +5075,7 @@ function guessMime(name) {
|
|
|
5020
5075
|
}
|
|
5021
5076
|
|
|
5022
5077
|
// src/version.ts
|
|
5023
|
-
var APP_VERSION = true ? "1.0.
|
|
5078
|
+
var APP_VERSION = true ? "1.0.22" : fromPackage();
|
|
5024
5079
|
|
|
5025
5080
|
// src/diag.ts
|
|
5026
5081
|
var MAX_HELD = 200;
|
|
@@ -5427,6 +5482,9 @@ var HostClient = class {
|
|
|
5427
5482
|
case "tool.result":
|
|
5428
5483
|
await this.sessions.toolResult(frame.groupId, frame.id, { text: frame.text, error: frame.error, files: frame.files, next: frame.next });
|
|
5429
5484
|
return;
|
|
5485
|
+
case "tool.started":
|
|
5486
|
+
this.sessions.toolStarted(frame.groupId, frame.id, frame.readOnly);
|
|
5487
|
+
return;
|
|
5430
5488
|
case "module.add":
|
|
5431
5489
|
try {
|
|
5432
5490
|
const { install } = this.registry.add(frame.module);
|
|
@@ -5495,7 +5553,18 @@ var HostClient = class {
|
|
|
5495
5553
|
}
|
|
5496
5554
|
case "provider_account.update": {
|
|
5497
5555
|
const a = this.accounts.get(frame.id);
|
|
5498
|
-
if (a)
|
|
5556
|
+
if (a) {
|
|
5557
|
+
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 });
|
|
5558
|
+
if (frame.monthlyCapUsd !== void 0 || frame.monthlyCapCharacters !== void 0) {
|
|
5559
|
+
const settings = { ...a.settings ?? {} };
|
|
5560
|
+
if (frame.monthlyCapUsd === null) delete settings.monthlyCapUsd;
|
|
5561
|
+
else if (frame.monthlyCapUsd !== void 0) settings.monthlyCapUsd = frame.monthlyCapUsd;
|
|
5562
|
+
if (frame.monthlyCapCharacters === null) delete settings.monthlyCapCharacters;
|
|
5563
|
+
else if (frame.monthlyCapCharacters !== void 0) settings.monthlyCapCharacters = frame.monthlyCapCharacters;
|
|
5564
|
+
this.accounts.setSettings(a.id, settings);
|
|
5565
|
+
log("info", `connection ${a.id.slice(0, 12)}: monthly cap ${settings.monthlyCapUsd !== void 0 ? `$${settings.monthlyCapUsd}` : settings.monthlyCapCharacters !== void 0 ? `${settings.monthlyCapCharacters} characters` : "cleared"}`);
|
|
5566
|
+
}
|
|
5567
|
+
}
|
|
5499
5568
|
await this.reportAccount(frame.id);
|
|
5500
5569
|
return;
|
|
5501
5570
|
}
|
|
@@ -6450,6 +6519,9 @@ ${r.text}`, final: true });
|
|
|
6450
6519
|
toolResult(id, result) {
|
|
6451
6520
|
this.tools.result(id, result);
|
|
6452
6521
|
}
|
|
6522
|
+
toolStarted(id, readOnly) {
|
|
6523
|
+
this.tools.started(id, readOnly);
|
|
6524
|
+
}
|
|
6453
6525
|
connectionLost() {
|
|
6454
6526
|
for (const w of [...this.agentWaits.values()]) w.finish({ error: w.lost });
|
|
6455
6527
|
this.tools.failWaiting();
|
|
@@ -7122,6 +7194,9 @@ ${files.map((a) => `- ${a.localPath} (${a.mime}, ${a.size} bytes)${a.note ? `: $
|
|
|
7122
7194
|
toolResult(id, result) {
|
|
7123
7195
|
this.tools.result(id, result);
|
|
7124
7196
|
}
|
|
7197
|
+
toolStarted(id, readOnly) {
|
|
7198
|
+
this.tools.started(id, readOnly);
|
|
7199
|
+
}
|
|
7125
7200
|
/** The machine's connection to the service closed: what was waiting for it ends now, each call with its own words. */
|
|
7126
7201
|
connectionLost() {
|
|
7127
7202
|
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.22",
|
|
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.22",
|
|
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.22",
|
|
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
|
}
|