@rubytech/taskmaster 1.17.8 → 1.17.10
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/build-info.json
CHANGED
|
@@ -120,11 +120,29 @@ export async function executeJob(state, job, nowMs, opts) {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
const statusPrefix = status === "ok" ? prefix : `${prefix} (${status})`;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (
|
|
127
|
-
state.deps.
|
|
123
|
+
// When delivery was skipped (no external channel), inject the report directly
|
|
124
|
+
// into the admin's main session transcript and broadcast a live "chat" event
|
|
125
|
+
// so it appears immediately in web chat without requiring a heartbeat cycle.
|
|
126
|
+
if (status === "skipped" && state.deps.injectToMainSession) {
|
|
127
|
+
const injected = await state.deps.injectToMainSession({
|
|
128
|
+
agentId: job.agentId ?? "",
|
|
129
|
+
message: body,
|
|
130
|
+
label: statusPrefix,
|
|
131
|
+
});
|
|
132
|
+
if (!injected) {
|
|
133
|
+
// Session doesn't exist yet — fall back to system event.
|
|
134
|
+
state.deps.enqueueSystemEvent(`${statusPrefix}: ${body}`, {
|
|
135
|
+
agentId: job.agentId,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
state.deps.enqueueSystemEvent(`${statusPrefix}: ${body}`, {
|
|
141
|
+
agentId: job.agentId,
|
|
142
|
+
});
|
|
143
|
+
if (job.wakeMode === "now") {
|
|
144
|
+
state.deps.requestHeartbeatNow({ reason: `cron:${job.id}:post` });
|
|
145
|
+
}
|
|
128
146
|
}
|
|
129
147
|
}
|
|
130
148
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { appendFileSync, existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
1
4
|
import { resolveDefaultAgentId } from "../agents/agent-scope.js";
|
|
2
5
|
import { loadConfig } from "../config/config.js";
|
|
3
6
|
import { resolveAgentMainSessionKey } from "../config/sessions.js";
|
|
@@ -11,6 +14,7 @@ import { enqueueSystemEvent } from "../infra/system-events.js";
|
|
|
11
14
|
import { getChildLogger } from "../logging.js";
|
|
12
15
|
import { normalizeAgentId } from "../routing/session-key.js";
|
|
13
16
|
import { defaultRuntime } from "../runtime.js";
|
|
17
|
+
import { loadSessionEntry } from "./session-utils.js";
|
|
14
18
|
export function buildGatewayCronService(params) {
|
|
15
19
|
const cronLogger = getChildLogger({ module: "cron" });
|
|
16
20
|
const storePath = resolveCronStorePath(params.cfg.cron?.store);
|
|
@@ -44,6 +48,49 @@ export function buildGatewayCronService(params) {
|
|
|
44
48
|
deps: { ...params.deps, runtime: defaultRuntime },
|
|
45
49
|
});
|
|
46
50
|
},
|
|
51
|
+
injectToMainSession: async ({ agentId: reqAgentId, message, label }) => {
|
|
52
|
+
try {
|
|
53
|
+
const { agentId, cfg: runtimeConfig } = resolveCronAgent(reqAgentId);
|
|
54
|
+
const sessionKey = resolveAgentMainSessionKey({ cfg: runtimeConfig, agentId });
|
|
55
|
+
const { storePath: sPath, entry } = loadSessionEntry(sessionKey);
|
|
56
|
+
const sessionId = entry?.sessionId;
|
|
57
|
+
if (!sessionId || !sPath)
|
|
58
|
+
return false;
|
|
59
|
+
const transcriptPath = entry?.sessionFile
|
|
60
|
+
? entry.sessionFile
|
|
61
|
+
: path.join(path.dirname(sPath), `${sessionId}.jsonl`);
|
|
62
|
+
if (!existsSync(transcriptPath))
|
|
63
|
+
return false;
|
|
64
|
+
const now = Date.now();
|
|
65
|
+
const messageId = randomUUID().slice(0, 8);
|
|
66
|
+
const labelPrefix = label ? `[${label}]\n\n` : "";
|
|
67
|
+
const messageBody = {
|
|
68
|
+
role: "assistant",
|
|
69
|
+
content: [{ type: "text", text: `${labelPrefix}${message}` }],
|
|
70
|
+
timestamp: now,
|
|
71
|
+
stopReason: "injected",
|
|
72
|
+
usage: { input: 0, output: 0, totalTokens: 0 },
|
|
73
|
+
};
|
|
74
|
+
const transcriptEntry = {
|
|
75
|
+
type: "message",
|
|
76
|
+
id: messageId,
|
|
77
|
+
timestamp: new Date(now).toISOString(),
|
|
78
|
+
message: messageBody,
|
|
79
|
+
};
|
|
80
|
+
appendFileSync(transcriptPath, `${JSON.stringify(transcriptEntry)}\n`, "utf-8");
|
|
81
|
+
params.broadcast("chat", {
|
|
82
|
+
runId: `inject-${messageId}`,
|
|
83
|
+
sessionKey,
|
|
84
|
+
seq: 0,
|
|
85
|
+
state: "final",
|
|
86
|
+
message: messageBody,
|
|
87
|
+
});
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
},
|
|
47
94
|
runIsolatedAgentJob: async ({ job, message }) => {
|
|
48
95
|
const { agentId, cfg: runtimeConfig } = resolveCronAgent(job.agentId);
|
|
49
96
|
return await runCronIsolatedAgentTurn({
|
|
@@ -455,7 +455,13 @@ export async function runGatewayUpdate(opts = {}) {
|
|
|
455
455
|
}
|
|
456
456
|
const spec = `@rubytech/taskmaster@${normalizeTag(opts.tag)}`;
|
|
457
457
|
const installArgv = globalInstallArgs(globalManager, spec, needsSudo);
|
|
458
|
-
|
|
458
|
+
// npm CDN propagation can take 2–10 minutes after publish: the package
|
|
459
|
+
// metadata resolves immediately but the tarball may 404 at some CDN nodes.
|
|
460
|
+
// Retry up to 3 times with a 60-second delay on E404 so the update
|
|
461
|
+
// completes without requiring user intervention.
|
|
462
|
+
const MAX_RETRIES = 3;
|
|
463
|
+
const RETRY_DELAY_MS = 60_000;
|
|
464
|
+
let updateStep = await runStep({
|
|
459
465
|
runCommand,
|
|
460
466
|
name: installArgv.join(" "),
|
|
461
467
|
argv: installArgv,
|
|
@@ -466,6 +472,23 @@ export async function runGatewayUpdate(opts = {}) {
|
|
|
466
472
|
stepIndex: 0,
|
|
467
473
|
totalSteps: 1,
|
|
468
474
|
});
|
|
475
|
+
for (let attempt = 1; attempt <= MAX_RETRIES && updateStep.exitCode !== 0; attempt++) {
|
|
476
|
+
const isE404 = (updateStep.stderrTail ?? "").includes("E404");
|
|
477
|
+
if (!isE404)
|
|
478
|
+
break;
|
|
479
|
+
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
|
|
480
|
+
updateStep = await runStep({
|
|
481
|
+
runCommand,
|
|
482
|
+
name: `${installArgv.join(" ")} (retry ${attempt}/${MAX_RETRIES})`,
|
|
483
|
+
argv: installArgv,
|
|
484
|
+
cwd: pkgRoot,
|
|
485
|
+
timeoutMs,
|
|
486
|
+
env: { PATH: augmentedPath },
|
|
487
|
+
progress,
|
|
488
|
+
stepIndex: 0,
|
|
489
|
+
totalSteps: 1,
|
|
490
|
+
});
|
|
491
|
+
}
|
|
469
492
|
const steps = [updateStep];
|
|
470
493
|
const afterVersion = await readPackageVersion(pkgRoot);
|
|
471
494
|
// Post-install verification: check for issues even when exit code is 0
|