@stagewhisper/stagewhisper 0.54.0 → 0.55.0
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/index.js +46 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -128,6 +128,17 @@ var init_client = __esm({
|
|
|
128
128
|
throw new Error(`Reasoning result post failed (${res.status}): ${text}`);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
+
async getReasoningJob(jobId) {
|
|
132
|
+
const res = await fetch(`${this.baseUrl}/api/v1/openclaw/reasoning-jobs/${jobId}`, {
|
|
133
|
+
method: "GET",
|
|
134
|
+
headers: this.headers()
|
|
135
|
+
});
|
|
136
|
+
if (!res.ok) {
|
|
137
|
+
const text = await res.text();
|
|
138
|
+
throw new Error(`Reasoning job fetch failed (${res.status}): ${text}`);
|
|
139
|
+
}
|
|
140
|
+
return res.json();
|
|
141
|
+
}
|
|
131
142
|
streamUrl() {
|
|
132
143
|
return `${this.baseUrl}/api/v1/openclaw/integrations/${this.integrationId}/stream`;
|
|
133
144
|
}
|
|
@@ -4241,6 +4252,35 @@ function createRelayService(api) {
|
|
|
4241
4252
|
if (!Number.isFinite(parsedDeadline)) return fallbackMs;
|
|
4242
4253
|
return Math.max(1e3, parsedDeadline - Date.now());
|
|
4243
4254
|
}
|
|
4255
|
+
function needsReasoningJobHydration(job) {
|
|
4256
|
+
if (job["_truncated"] === true) return true;
|
|
4257
|
+
if (typeof job["deadline_at"] !== "string") return true;
|
|
4258
|
+
if (typeof job["idempotency_key"] !== "string") return true;
|
|
4259
|
+
const responseSchema = job["response_schema"];
|
|
4260
|
+
if (typeof responseSchema !== "object" || responseSchema === null) return true;
|
|
4261
|
+
const payload = job["payload"];
|
|
4262
|
+
if (typeof payload !== "object" || payload === null) return true;
|
|
4263
|
+
return payload["_truncated"] === true;
|
|
4264
|
+
}
|
|
4265
|
+
async function hydrateReasoningJobEnvelope(rawJob, client) {
|
|
4266
|
+
const payload = rawJob["payload"];
|
|
4267
|
+
const payloadRecord = typeof payload === "object" && payload !== null ? payload : null;
|
|
4268
|
+
const jobId = typeof rawJob["job_id"] === "string" ? rawJob["job_id"] : typeof payloadRecord?.["job_id"] === "string" ? payloadRecord["job_id"] : typeof payloadRecord?.["id"] === "string" ? payloadRecord["id"] : null;
|
|
4269
|
+
if (!jobId) {
|
|
4270
|
+
api.logger.error("Received reasoning job without job_id");
|
|
4271
|
+
return null;
|
|
4272
|
+
}
|
|
4273
|
+
if (!needsReasoningJobHydration(rawJob)) {
|
|
4274
|
+
return rawJob;
|
|
4275
|
+
}
|
|
4276
|
+
try {
|
|
4277
|
+
api.logger.info(`Hydrating truncated reasoning job ${jobId}`);
|
|
4278
|
+
return await client.getReasoningJob(jobId);
|
|
4279
|
+
} catch (err) {
|
|
4280
|
+
api.logger.error(`Failed to hydrate reasoning job ${jobId}: ${err}`);
|
|
4281
|
+
return null;
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4244
4284
|
async function extractReplyForTask(sessionKey, taskId, maxAttempts = 3) {
|
|
4245
4285
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
4246
4286
|
if (attempt > 0) {
|
|
@@ -4707,10 +4747,14 @@ function createRelayService(api) {
|
|
|
4707
4747
|
}
|
|
4708
4748
|
}
|
|
4709
4749
|
async function handleReasoningJob(job, client) {
|
|
4710
|
-
|
|
4711
|
-
|
|
4750
|
+
const hydrated = await hydrateReasoningJobEnvelope(
|
|
4751
|
+
job,
|
|
4752
|
+
client
|
|
4753
|
+
);
|
|
4754
|
+
if (!hydrated) {
|
|
4712
4755
|
return;
|
|
4713
4756
|
}
|
|
4757
|
+
job = hydrated;
|
|
4714
4758
|
const correlationId = job.correlation_id;
|
|
4715
4759
|
api.logger.info(
|
|
4716
4760
|
`Received reasoning job: ${job.job_id} (purpose: ${job.purpose}, correlation: ${correlationId ?? "none"})`
|
package/openclaw.plugin.json
CHANGED