@mastra/core 1.87.0-alpha.13 → 1.87.0-alpha.15
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/agent/durable/index.cjs +1 -1
- package/dist/agent/durable/index.js +1 -1
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.js +2 -2
- package/dist/agent-builder/ee/index.cjs +1 -1
- package/dist/agent-builder/ee/index.js +1 -1
- package/dist/agent-controller/index.cjs +1 -1
- package/dist/agent-controller/index.js +1 -1
- package/dist/{agent-controller-DDxEG9Nd.cjs → agent-controller-DhDQXNoI.cjs} +5 -5
- package/dist/{agent-controller-DYwtbG2-.js → agent-controller-DihwxeVJ.js} +5 -5
- package/dist/background-tasks/index.cjs +1 -1
- package/dist/background-tasks/index.js +1 -1
- package/dist/{background-tasks-B8Lk1bt5.js → background-tasks-BoUX5G90.js} +1 -1
- package/dist/{background-tasks-LfQsDG6J.cjs → background-tasks-udYDvnlw.cjs} +1 -1
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/{builder-CPgUrTDP.cjs → builder-B2n-bUbl.cjs} +2 -2
- package/dist/{builder-DLaSPG2u.js → builder-Cn1lOWio.js} +2 -2
- package/dist/channels/index.cjs +2 -2
- package/dist/channels/index.js +2 -2
- package/dist/{channels-BPxJYR70.js → channels-DA3oMfhF.js} +1 -1
- package/dist/{channels-DH9fKqmy.cjs → channels-HRrlHnwF.cjs} +1 -1
- package/dist/coding-agent/index.cjs +2 -2
- package/dist/coding-agent/index.js +2 -2
- package/dist/{constants-Bou0hEgY.cjs → constants-CFO8w780.cjs} +8 -0
- package/dist/{constants-CFWgIaqA.js → constants-CUv0mU2y.js} +8 -0
- package/dist/datasets/index.cjs +2 -2
- package/dist/datasets/index.js +2 -2
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +759 -749
- package/dist/docs/references/docs-harness-schedules.md +34 -0
- package/dist/docs/references/docs-signals-sending-signals.md +13 -0
- package/dist/docs/references/docs-signals-state-signals.md +1 -1
- package/dist/docs/references/reference-signals-time-signal-provider.md +35 -0
- package/dist/docs/references/reference-workspace-factory-sandbox.md +2 -0
- package/dist/evals/index.cjs +2 -2
- package/dist/evals/index.js +2 -2
- package/dist/evals/scoreTraces/index.cjs +2 -2
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/harness/index.cjs +1 -1
- package/dist/harness/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/knowledge/index.cjs +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/llm/index.cjs +3 -3
- package/dist/llm/index.js +3 -3
- package/dist/{llm-DeOr7BXy.cjs → llm-Bljw7LII.cjs} +2 -2
- package/dist/{llm-DGa7alUy.js → llm-CxHzqEEI.js} +2 -2
- package/dist/loop/index.cjs +2 -2
- package/dist/loop/index.js +2 -2
- package/dist/{manager-BErWwr50.js → manager-BimN8ZdV.js} +3 -3
- package/dist/{manager-B-pQMauy.cjs → manager-DVYVB-3O.cjs} +3 -3
- package/dist/mastra/index.cjs +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/{mastra-B1BKkzX0.js → mastra-BpMvri3z.js} +17 -16
- package/dist/{mastra-CoWxmLQl.cjs → mastra-k8L1lFip.cjs} +17 -16
- package/dist/memory/index.cjs +2 -2
- package/dist/memory/index.js +2 -2
- package/dist/{model-CGH6nAvh.cjs → model-CrDuEDRq.cjs} +1 -1
- package/dist/{model-Bz3zffBv.js → model-sUJDcX2v.js} +1 -1
- package/dist/{netlify-CzbukKO2.js → netlify-BEJ96z-w.js} +1 -1
- package/dist/{netlify-D7oirBdu.cjs → netlify-Td-JUUkt.cjs} +1 -1
- package/dist/notifications/index.cjs +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/processor-provider/index.cjs +1 -1
- package/dist/processor-provider/index.js +1 -1
- package/dist/processors/index.cjs +2 -2
- package/dist/processors/index.js +2 -2
- package/dist/{provider-registry-DTaqnIYP.cjs → provider-registry-CCYXykIZ.cjs} +4 -4
- package/dist/{provider-registry-CdCkSE3h.js → provider-registry-DBG4hlGl.js} +4 -4
- package/dist/{registry-generator-CcgFsigf.cjs → registry-generator-BxiC9XcX.cjs} +1 -1
- package/dist/{registry-generator-Dbxm-MYh.js → registry-generator-D2lO3JJJ.js} +1 -1
- package/dist/{rehydrate-D7eaaJxI.cjs → rehydrate-BD0zOfc8.cjs} +2 -2
- package/dist/{rehydrate-BhmzzvtV.js → rehydrate-PRFAu8yl.js} +2 -2
- package/dist/relevance/index.cjs +2 -2
- package/dist/relevance/index.js +2 -2
- package/dist/{run-registry-59R9kE8Z.cjs → run-registry-BvMXuIb_.cjs} +530 -367
- package/dist/{run-registry-Du22tS_D.js → run-registry-Cqp-VFdv.js} +530 -367
- package/dist/{scheduler-B-VZUvv_.js → scheduler-0ShtMM1I.js} +71 -21
- package/dist/{scheduler-D00X03jQ.cjs → scheduler-CMjK0LoQ.cjs} +82 -20
- package/dist/signals/index.cjs +1 -1
- package/dist/signals/index.js +1 -1
- package/dist/signals/time-signal-provider.d.ts +8 -0
- package/dist/{signals-CIwzgkvN.cjs → signals-CbmgVwL-.cjs} +74 -7
- package/dist/{signals-BTfT-6DE.js → signals-Clupx3jz.js} +74 -7
- package/dist/storage/constants.cjs +1 -1
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/knowledge/base.d.ts +33 -1
- package/dist/storage/domains/knowledge/inmemory.d.ts +2 -0
- package/dist/storage/domains/knowledge/pages-inmemory.d.ts +20 -12
- package/dist/storage/domains/schedules/base.d.ts +31 -2
- package/dist/storage/domains/schedules/inmemory.d.ts +9 -2
- package/dist/storage/index.cjs +3 -3
- package/dist/storage/index.js +3 -3
- package/dist/stream/index.cjs +2 -2
- package/dist/stream/index.js +2 -2
- package/dist/{stream-mYc-fHPF.cjs → stream-BIbVD8V8.cjs} +1 -1
- package/dist/{stream-C_oNulbg.js → stream-D607FmAx.js} +1 -1
- package/dist/test-utils/llm-mock.cjs +1 -1
- package/dist/test-utils/llm-mock.js +1 -1
- package/dist/tool-loop-agent/index.cjs +1 -1
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/{tool-loop-agent-Bi09dOW5.cjs → tool-loop-agent-Cnf7vONA.cjs} +3 -3
- package/dist/{tool-loop-agent-Du1BJO8a.js → tool-loop-agent-eyoY_TEX.js} +3 -3
- package/dist/{utils-nyjsIsHZ.js → utils-CQkzZUcK.js} +1 -1
- package/dist/{utils-BGq3p2MX.cjs → utils-O1TXaFUl.cjs} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/dist/{validate-CcE7gP2j.cjs → validate-CEgWy7P0.cjs} +1 -1
- package/dist/{validate-q0hhKzA4.js → validate-CTWjOlWp.js} +1 -1
- package/dist/vector/index.cjs +1 -1
- package/dist/vector/index.js +1 -1
- package/dist/worker/index.cjs +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/{worker-DmJLbaGI.cjs → worker-CCDvbK3P.cjs} +2 -2
- package/dist/{worker-Dboi5I9k.js → worker-CCNb2aJe.js} +3 -3
- package/dist/{worker-Dzfx-9D0.cjs → worker-CI1joT3R.cjs} +3 -3
- package/dist/{worker-Wv2nS-Df.js → worker-D52cos24.js} +2 -2
- package/dist/{workflow-BPf1-mkb.cjs → workflow-BJL0qlPN.cjs} +3 -3
- package/dist/{workflow-CFfCkulP.js → workflow-DsmyWwxG.js} +3 -3
- package/dist/workflows/builder/index.cjs +1 -1
- package/dist/workflows/builder/index.js +1 -1
- package/dist/workflows/evented/index.cjs +1 -1
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +7 -5
- package/dist/workflows/index.js +6 -6
- package/dist/workflows/scheduler/claim.d.ts +51 -0
- package/dist/workflows/scheduler/index.d.ts +2 -0
- package/package.json +7 -7
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
import { t as MastraBase } from "./base-CKLWBhDo.js";
|
|
2
2
|
import { a as RegisteredLogger } from "./logger-BwbmRqfc.js";
|
|
3
3
|
import { m as computeNextFire } from "./schedules-DZfSx-7P.js";
|
|
4
|
+
// src/workflows/scheduler/claim.ts
|
|
5
|
+
/**
|
|
6
|
+
* Deterministic per occurrence. Unscoped rows keep `sched_<id>_<fireAt>`; a
|
|
7
|
+
* tenant's row adds its encoded tenant so equal ids in two tenants never share
|
|
8
|
+
* a run id.
|
|
9
|
+
*/
|
|
10
|
+
function scheduleRunId(schedule) {
|
|
11
|
+
if (schedule.tenantId === void 0) return `sched_${schedule.id}_${schedule.nextFireAt}`;
|
|
12
|
+
return `sched@${encodeURIComponent(schedule.tenantId)}/${schedule.id}_${schedule.nextFireAt}`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Claim one occurrence of a due schedule: advance `nextFireAt` with a
|
|
16
|
+
* compare-and-swap so only one caller across processes wins it. Returns
|
|
17
|
+
* undefined when another caller won, or the row was paused or changed.
|
|
18
|
+
* Throws when the cron can't produce a next fire time.
|
|
19
|
+
*/
|
|
20
|
+
async function claimScheduleFire({ store, schedule, now }) {
|
|
21
|
+
const { nextFireAt, completed } = computeNextFire(schedule, now);
|
|
22
|
+
const runId = scheduleRunId(schedule);
|
|
23
|
+
return await (schedule.tenantId === void 0 ? store : store.forTenant(schedule.tenantId)).updateScheduleNextFire(schedule.id, schedule.nextFireAt, nextFireAt, now, runId, completed ? "completed" : void 0) ? {
|
|
24
|
+
schedule,
|
|
25
|
+
runId,
|
|
26
|
+
actualFireAt: now
|
|
27
|
+
} : void 0;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* One scheduler tick without a timer. Lists due tenant schedules (of every
|
|
31
|
+
* tenant on the root store, or one tenant's on its view), hands each
|
|
32
|
+
* occurrence to `dispatch`, and only then advances the row. Schedules without
|
|
33
|
+
* a tenant belong to the in-process `Scheduler` and are never touched here, so
|
|
34
|
+
* one occurrence is never fired by both. A failed dispatch leaves the row due for the next tick; a
|
|
35
|
+
* crash after dispatch re-dispatches the same `runId` next tick, so `dispatch`
|
|
36
|
+
* must be idempotent on it (e.g. a named queue task). Hosts that drive ticks
|
|
37
|
+
* from outside the process (a cron job calling an HTTP route) call this.
|
|
38
|
+
* `onError` receives every failed occurrence; a failing dispatch stays due and
|
|
39
|
+
* fails again each tick, so log or alert on it.
|
|
40
|
+
* Returns the occurrences this tick dispatched and advanced.
|
|
41
|
+
*/
|
|
42
|
+
async function runScheduleTick({ store, now, limit, dispatch, onError }) {
|
|
43
|
+
const due = (await store.listDueSchedules(now, limit, { tenants: true })).filter((schedule) => schedule.tenantId !== void 0);
|
|
44
|
+
const fired = [];
|
|
45
|
+
for (const schedule of due) try {
|
|
46
|
+
const fire = {
|
|
47
|
+
schedule,
|
|
48
|
+
runId: scheduleRunId(schedule),
|
|
49
|
+
scheduledFireAt: schedule.nextFireAt
|
|
50
|
+
};
|
|
51
|
+
computeNextFire(schedule, now);
|
|
52
|
+
await dispatch(fire);
|
|
53
|
+
if (await claimScheduleFire({
|
|
54
|
+
store,
|
|
55
|
+
schedule,
|
|
56
|
+
now
|
|
57
|
+
})) fired.push(fire);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
onError(error, schedule);
|
|
60
|
+
}
|
|
61
|
+
return fired;
|
|
62
|
+
}
|
|
4
63
|
// src/workflows/scheduler/scheduler.ts
|
|
5
64
|
const TOPIC_WORKFLOWS = "workflows";
|
|
6
65
|
const TOPIC_AGENT_SCHEDULES = "agent-schedules";
|
|
@@ -171,7 +230,7 @@ var Scheduler = class extends MastraBase {
|
|
|
171
230
|
if (this.#config.enabled === true || this.#lastTickBusy) return interval;
|
|
172
231
|
let next;
|
|
173
232
|
try {
|
|
174
|
-
next = await this.#schedulesStore.listDueSchedules(Number.MAX_SAFE_INTEGER, 1);
|
|
233
|
+
next = await this.#schedulesStore.listDueSchedules(Number.MAX_SAFE_INTEGER, 1, { unscoped: true });
|
|
175
234
|
} catch (err) {
|
|
176
235
|
this.logger.error("Failed to look up the next scheduled fire", { error: err });
|
|
177
236
|
return interval;
|
|
@@ -197,11 +256,12 @@ var Scheduler = class extends MastraBase {
|
|
|
197
256
|
let due;
|
|
198
257
|
this.#lastTickBusy = true;
|
|
199
258
|
try {
|
|
200
|
-
due = await this.#schedulesStore.listDueSchedules(Date.now(), this.#config.batchSize);
|
|
259
|
+
due = await this.#schedulesStore.listDueSchedules(Date.now(), this.#config.batchSize, { unscoped: true });
|
|
201
260
|
} catch (err) {
|
|
202
261
|
this.logger.error("Failed to list due schedules", { error: err });
|
|
203
262
|
return;
|
|
204
263
|
}
|
|
264
|
+
due = due.filter((schedule) => schedule.tenantId === void 0);
|
|
205
265
|
this.#lastTickBusy = due.length > 0;
|
|
206
266
|
for (const schedule of due) {
|
|
207
267
|
if (this.#stopping) break;
|
|
@@ -340,34 +400,24 @@ var Scheduler = class extends MastraBase {
|
|
|
340
400
|
async #fireSchedule(schedule) {
|
|
341
401
|
if (!await this.#ensureTargetReady(schedule)) return;
|
|
342
402
|
if (!this.#ensureTargetCurrent(schedule)) return;
|
|
343
|
-
|
|
344
|
-
let newNextFireAt;
|
|
345
|
-
let completed;
|
|
403
|
+
let fire;
|
|
346
404
|
try {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
cron: schedule.cron,
|
|
352
|
-
error: err
|
|
405
|
+
fire = await claimScheduleFire({
|
|
406
|
+
store: this.#schedulesStore,
|
|
407
|
+
schedule,
|
|
408
|
+
now: Date.now()
|
|
353
409
|
});
|
|
354
|
-
this.#notifyError(err, schedule.id);
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
const runId = `sched_${schedule.id}_${schedule.nextFireAt}`;
|
|
358
|
-
let claimed = false;
|
|
359
|
-
try {
|
|
360
|
-
claimed = await this.#schedulesStore.updateScheduleNextFire(schedule.id, schedule.nextFireAt, newNextFireAt, actualFireAt, runId, completed ? "completed" : void 0);
|
|
361
410
|
} catch (err) {
|
|
362
411
|
this.logger.error("Failed to claim due schedule fire", {
|
|
363
412
|
scheduleId: schedule.id,
|
|
364
|
-
|
|
413
|
+
cron: schedule.cron,
|
|
365
414
|
error: err
|
|
366
415
|
});
|
|
367
416
|
this.#notifyError(err, schedule.id);
|
|
368
417
|
return;
|
|
369
418
|
}
|
|
370
|
-
if (!
|
|
419
|
+
if (!fire) return;
|
|
420
|
+
const { runId, actualFireAt } = fire;
|
|
371
421
|
this.logger.info("Claimed schedule occurrence", {
|
|
372
422
|
scheduleId: schedule.id,
|
|
373
423
|
runId,
|
|
@@ -487,4 +537,4 @@ var Scheduler = class extends MastraBase {
|
|
|
487
537
|
* accurate. This alias will be removed in a future major release.
|
|
488
538
|
*/
|
|
489
539
|
const WorkflowScheduler = Scheduler;
|
|
490
|
-
export { WorkflowScheduler as n, Scheduler as t };
|
|
540
|
+
export { runScheduleTick as i, WorkflowScheduler as n, claimScheduleFire as r, Scheduler as t };
|
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
const require_base = require("./base-BIzR1D3_.cjs");
|
|
2
2
|
const require_logger = require("./logger-CvzZYuJd.cjs");
|
|
3
3
|
const require_schedules = require("./schedules-BZS8McF7.cjs");
|
|
4
|
+
// src/workflows/scheduler/claim.ts
|
|
5
|
+
/**
|
|
6
|
+
* Deterministic per occurrence. Unscoped rows keep `sched_<id>_<fireAt>`; a
|
|
7
|
+
* tenant's row adds its encoded tenant so equal ids in two tenants never share
|
|
8
|
+
* a run id.
|
|
9
|
+
*/
|
|
10
|
+
function scheduleRunId(schedule) {
|
|
11
|
+
if (schedule.tenantId === void 0) return `sched_${schedule.id}_${schedule.nextFireAt}`;
|
|
12
|
+
return `sched@${encodeURIComponent(schedule.tenantId)}/${schedule.id}_${schedule.nextFireAt}`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Claim one occurrence of a due schedule: advance `nextFireAt` with a
|
|
16
|
+
* compare-and-swap so only one caller across processes wins it. Returns
|
|
17
|
+
* undefined when another caller won, or the row was paused or changed.
|
|
18
|
+
* Throws when the cron can't produce a next fire time.
|
|
19
|
+
*/
|
|
20
|
+
async function claimScheduleFire({ store, schedule, now }) {
|
|
21
|
+
const { nextFireAt, completed } = require_schedules.computeNextFire(schedule, now);
|
|
22
|
+
const runId = scheduleRunId(schedule);
|
|
23
|
+
return await (schedule.tenantId === void 0 ? store : store.forTenant(schedule.tenantId)).updateScheduleNextFire(schedule.id, schedule.nextFireAt, nextFireAt, now, runId, completed ? "completed" : void 0) ? {
|
|
24
|
+
schedule,
|
|
25
|
+
runId,
|
|
26
|
+
actualFireAt: now
|
|
27
|
+
} : void 0;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* One scheduler tick without a timer. Lists due tenant schedules (of every
|
|
31
|
+
* tenant on the root store, or one tenant's on its view), hands each
|
|
32
|
+
* occurrence to `dispatch`, and only then advances the row. Schedules without
|
|
33
|
+
* a tenant belong to the in-process `Scheduler` and are never touched here, so
|
|
34
|
+
* one occurrence is never fired by both. A failed dispatch leaves the row due for the next tick; a
|
|
35
|
+
* crash after dispatch re-dispatches the same `runId` next tick, so `dispatch`
|
|
36
|
+
* must be idempotent on it (e.g. a named queue task). Hosts that drive ticks
|
|
37
|
+
* from outside the process (a cron job calling an HTTP route) call this.
|
|
38
|
+
* `onError` receives every failed occurrence; a failing dispatch stays due and
|
|
39
|
+
* fails again each tick, so log or alert on it.
|
|
40
|
+
* Returns the occurrences this tick dispatched and advanced.
|
|
41
|
+
*/
|
|
42
|
+
async function runScheduleTick({ store, now, limit, dispatch, onError }) {
|
|
43
|
+
const due = (await store.listDueSchedules(now, limit, { tenants: true })).filter((schedule) => schedule.tenantId !== void 0);
|
|
44
|
+
const fired = [];
|
|
45
|
+
for (const schedule of due) try {
|
|
46
|
+
const fire = {
|
|
47
|
+
schedule,
|
|
48
|
+
runId: scheduleRunId(schedule),
|
|
49
|
+
scheduledFireAt: schedule.nextFireAt
|
|
50
|
+
};
|
|
51
|
+
require_schedules.computeNextFire(schedule, now);
|
|
52
|
+
await dispatch(fire);
|
|
53
|
+
if (await claimScheduleFire({
|
|
54
|
+
store,
|
|
55
|
+
schedule,
|
|
56
|
+
now
|
|
57
|
+
})) fired.push(fire);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
onError(error, schedule);
|
|
60
|
+
}
|
|
61
|
+
return fired;
|
|
62
|
+
}
|
|
4
63
|
// src/workflows/scheduler/scheduler.ts
|
|
5
64
|
const TOPIC_WORKFLOWS = "workflows";
|
|
6
65
|
const TOPIC_AGENT_SCHEDULES = "agent-schedules";
|
|
@@ -171,7 +230,7 @@ var Scheduler = class extends require_base.MastraBase {
|
|
|
171
230
|
if (this.#config.enabled === true || this.#lastTickBusy) return interval;
|
|
172
231
|
let next;
|
|
173
232
|
try {
|
|
174
|
-
next = await this.#schedulesStore.listDueSchedules(Number.MAX_SAFE_INTEGER, 1);
|
|
233
|
+
next = await this.#schedulesStore.listDueSchedules(Number.MAX_SAFE_INTEGER, 1, { unscoped: true });
|
|
175
234
|
} catch (err) {
|
|
176
235
|
this.logger.error("Failed to look up the next scheduled fire", { error: err });
|
|
177
236
|
return interval;
|
|
@@ -197,11 +256,12 @@ var Scheduler = class extends require_base.MastraBase {
|
|
|
197
256
|
let due;
|
|
198
257
|
this.#lastTickBusy = true;
|
|
199
258
|
try {
|
|
200
|
-
due = await this.#schedulesStore.listDueSchedules(Date.now(), this.#config.batchSize);
|
|
259
|
+
due = await this.#schedulesStore.listDueSchedules(Date.now(), this.#config.batchSize, { unscoped: true });
|
|
201
260
|
} catch (err) {
|
|
202
261
|
this.logger.error("Failed to list due schedules", { error: err });
|
|
203
262
|
return;
|
|
204
263
|
}
|
|
264
|
+
due = due.filter((schedule) => schedule.tenantId === void 0);
|
|
205
265
|
this.#lastTickBusy = due.length > 0;
|
|
206
266
|
for (const schedule of due) {
|
|
207
267
|
if (this.#stopping) break;
|
|
@@ -340,34 +400,24 @@ var Scheduler = class extends require_base.MastraBase {
|
|
|
340
400
|
async #fireSchedule(schedule) {
|
|
341
401
|
if (!await this.#ensureTargetReady(schedule)) return;
|
|
342
402
|
if (!this.#ensureTargetCurrent(schedule)) return;
|
|
343
|
-
|
|
344
|
-
let newNextFireAt;
|
|
345
|
-
let completed;
|
|
403
|
+
let fire;
|
|
346
404
|
try {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
cron: schedule.cron,
|
|
352
|
-
error: err
|
|
405
|
+
fire = await claimScheduleFire({
|
|
406
|
+
store: this.#schedulesStore,
|
|
407
|
+
schedule,
|
|
408
|
+
now: Date.now()
|
|
353
409
|
});
|
|
354
|
-
this.#notifyError(err, schedule.id);
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
const runId = `sched_${schedule.id}_${schedule.nextFireAt}`;
|
|
358
|
-
let claimed = false;
|
|
359
|
-
try {
|
|
360
|
-
claimed = await this.#schedulesStore.updateScheduleNextFire(schedule.id, schedule.nextFireAt, newNextFireAt, actualFireAt, runId, completed ? "completed" : void 0);
|
|
361
410
|
} catch (err) {
|
|
362
411
|
this.logger.error("Failed to claim due schedule fire", {
|
|
363
412
|
scheduleId: schedule.id,
|
|
364
|
-
|
|
413
|
+
cron: schedule.cron,
|
|
365
414
|
error: err
|
|
366
415
|
});
|
|
367
416
|
this.#notifyError(err, schedule.id);
|
|
368
417
|
return;
|
|
369
418
|
}
|
|
370
|
-
if (!
|
|
419
|
+
if (!fire) return;
|
|
420
|
+
const { runId, actualFireAt } = fire;
|
|
371
421
|
this.logger.info("Claimed schedule occurrence", {
|
|
372
422
|
scheduleId: schedule.id,
|
|
373
423
|
runId,
|
|
@@ -499,3 +549,15 @@ Object.defineProperty(exports, "WorkflowScheduler", {
|
|
|
499
549
|
return WorkflowScheduler;
|
|
500
550
|
}
|
|
501
551
|
});
|
|
552
|
+
Object.defineProperty(exports, "claimScheduleFire", {
|
|
553
|
+
enumerable: true,
|
|
554
|
+
get: function() {
|
|
555
|
+
return claimScheduleFire;
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
Object.defineProperty(exports, "runScheduleTick", {
|
|
559
|
+
enumerable: true,
|
|
560
|
+
get: function() {
|
|
561
|
+
return runScheduleTick;
|
|
562
|
+
}
|
|
563
|
+
});
|
package/dist/signals/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_signals = require("../signals-CWxAMEmE.cjs");
|
|
3
3
|
const require_state_processor = require("../state-processor-kRNZ38Nf.cjs");
|
|
4
4
|
const require_signal_provider = require("../signal-provider-BFAvh_AJ.cjs");
|
|
5
|
-
const require_signals$1 = require("../signals-
|
|
5
|
+
const require_signals$1 = require("../signals-CbmgVwL-.cjs");
|
|
6
6
|
exports.GoalSignalProvider = require_signal_provider.GoalSignalProvider;
|
|
7
7
|
exports.SignalProvider = require_signal_provider.SignalProvider;
|
|
8
8
|
exports.TaskSignalProvider = require_signals$1.TaskSignalProvider;
|
package/dist/signals/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as isCreatedAgentSignal, l as mastraDBMessageToSignal, n as createSignal } from "../signals-CqR_iWkg.js";
|
|
2
2
|
import { o as assignTaskIds } from "../state-processor-B9kxpM53.js";
|
|
3
3
|
import { i as isSignalProvider, n as WebhookSignalProvider, r as SignalProvider, t as GoalSignalProvider } from "../signal-provider-BslnAjWG.js";
|
|
4
|
-
import { n as TaskSignalProvider, t as TimeSignalProvider } from "../signals-
|
|
4
|
+
import { n as TaskSignalProvider, t as TimeSignalProvider } from "../signals-Clupx3jz.js";
|
|
5
5
|
export { GoalSignalProvider, SignalProvider, TaskSignalProvider, TimeSignalProvider, WebhookSignalProvider, assignTaskIds, createSignal, isCreatedAgentSignal, isSignalProvider, mastraDBMessageToSignal };
|
|
@@ -31,6 +31,14 @@ export type TimeSignalProviderOptions = {
|
|
|
31
31
|
* `false`: it moves on once `interval` has passed since the last time the model was shown.
|
|
32
32
|
*/
|
|
33
33
|
align?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Also report the zones users send as `timeZone` in the attributes or metadata of their messages (default `true`).
|
|
36
|
+
* At each step the newest valid zones among the user messages in context are added after the
|
|
37
|
+
* configured ones, up to `max` (default 10). `false` reports only the configured zones.
|
|
38
|
+
*/
|
|
39
|
+
messageTimeZones?: boolean | {
|
|
40
|
+
max?: number;
|
|
41
|
+
};
|
|
34
42
|
};
|
|
35
43
|
/**
|
|
36
44
|
* Keeps the agent aware of the current time through a `<current-time>` state signal.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_signal_provider = require("./signal-provider-BFAvh_AJ.cjs");
|
|
2
2
|
const require_state_processor = require("./state-processor-kRNZ38Nf.cjs");
|
|
3
|
+
const require_signals = require("./signals-CWxAMEmE.cjs");
|
|
3
4
|
// src/signals/task-signal-provider.ts
|
|
4
5
|
/**
|
|
5
6
|
* Bundles the built-in task tools and the {@link TaskStateProcessor} behind a
|
|
@@ -55,6 +56,11 @@ const MINUTE_MS = 6e4;
|
|
|
55
56
|
const HOUR_MS = 60 * MINUTE_MS;
|
|
56
57
|
const DEFAULT_INTERVAL_MS = 15 * MINUTE_MS;
|
|
57
58
|
const DAY_MS = 24 * HOUR_MS;
|
|
59
|
+
const DEFAULT_MESSAGE_ZONES = 10;
|
|
60
|
+
/** Distinct `timeZone` values examined per step, cached or not, so the result never depends on the cache. */
|
|
61
|
+
const ZONE_SCAN_BUDGET = 16;
|
|
62
|
+
const MAX_ZONE_LENGTH = 64;
|
|
63
|
+
const ZONE_CACHE_SIZE = 256;
|
|
58
64
|
const TIME_TAG = "current-time";
|
|
59
65
|
const TIME_UPDATE_TAG = "current-time-update";
|
|
60
66
|
const NAMED_INTERVALS = {
|
|
@@ -153,6 +159,25 @@ function localClock(date, timeZone) {
|
|
|
153
159
|
function lastShown(args) {
|
|
154
160
|
return (args.deltasSinceSnapshot.at(-1) ?? args.lastSnapshot)?.metadata?.value;
|
|
155
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* The zone a user message carries. Agent-facing signal `attributes` come first, then the signal's
|
|
164
|
+
* own `metadata`, then message `metadata`. The first one set to a non-empty string is the only one
|
|
165
|
+
* read: an invalid value there skips the message rather than falling back.
|
|
166
|
+
*/
|
|
167
|
+
function messageTimeZone(message) {
|
|
168
|
+
const metadata = message.content?.metadata;
|
|
169
|
+
for (const value of [
|
|
170
|
+
metadata?.signal?.attributes?.timeZone,
|
|
171
|
+
metadata?.signal?.metadata?.timeZone,
|
|
172
|
+
metadata?.timeZone
|
|
173
|
+
]) if (typeof value === "string" && value) return value;
|
|
174
|
+
}
|
|
175
|
+
function resolveMessageZoneLimit(option) {
|
|
176
|
+
if (option === false) return 0;
|
|
177
|
+
const max = option === true || option === void 0 ? DEFAULT_MESSAGE_ZONES : option.max ?? DEFAULT_MESSAGE_ZONES;
|
|
178
|
+
if (!Number.isInteger(max) || max < 1) throw new Error(`TimeSignalProvider: messageTimeZones.max must be a positive integer, got ${String(max)}`);
|
|
179
|
+
return max;
|
|
180
|
+
}
|
|
156
181
|
function pad(value) {
|
|
157
182
|
return String(value).padStart(2, "0");
|
|
158
183
|
}
|
|
@@ -172,7 +197,13 @@ var TimeStateProcessor = class {
|
|
|
172
197
|
#align;
|
|
173
198
|
#format;
|
|
174
199
|
#formatTime;
|
|
200
|
+
#configured;
|
|
201
|
+
#messageZoneLimit;
|
|
202
|
+
/** Canonical names by raw value, `null` for rejected values; least recently used first. */
|
|
203
|
+
#zoneCache = /* @__PURE__ */ new Map();
|
|
175
204
|
constructor(options, timeZones) {
|
|
205
|
+
this.#messageZoneLimit = resolveMessageZoneLimit(options.messageTimeZones);
|
|
206
|
+
this.#configured = new Set(timeZones.map(resolveTimeZone));
|
|
176
207
|
this.#align = options.align ?? true;
|
|
177
208
|
this.#intervalMs = resolveInterval(options.interval, this.#align);
|
|
178
209
|
this.timeZones = timeZones;
|
|
@@ -184,6 +215,41 @@ var TimeStateProcessor = class {
|
|
|
184
215
|
}).format(date) : defaultFormatter(this.#intervalMs);
|
|
185
216
|
this.#formatTime = format ? this.#format : timeOfDayFormatter(this.#intervalMs);
|
|
186
217
|
}
|
|
218
|
+
#canonicalZone(raw) {
|
|
219
|
+
let canonical = this.#zoneCache.get(raw);
|
|
220
|
+
if (canonical !== void 0) this.#zoneCache.delete(raw);
|
|
221
|
+
else {
|
|
222
|
+
try {
|
|
223
|
+
canonical = new Intl.DateTimeFormat("en-US", { timeZone: raw }).resolvedOptions().timeZone;
|
|
224
|
+
} catch {
|
|
225
|
+
canonical = null;
|
|
226
|
+
}
|
|
227
|
+
if (this.#zoneCache.size >= ZONE_CACHE_SIZE) this.#zoneCache.delete(this.#zoneCache.keys().next().value);
|
|
228
|
+
}
|
|
229
|
+
this.#zoneCache.set(raw, canonical);
|
|
230
|
+
return canonical ?? void 0;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The configured zones, then the newest valid zones users sent as `timeZone`, sorted by
|
|
234
|
+
* canonical name so the list only changes when the set does. Scans newest first and stops after
|
|
235
|
+
* `ZONE_SCAN_BUDGET` distinct values: a zone behind that many newer ones is left out.
|
|
236
|
+
*/
|
|
237
|
+
#zones(messages) {
|
|
238
|
+
if (!this.#messageZoneLimit || !messages?.length) return this.timeZones;
|
|
239
|
+
const seen = /* @__PURE__ */ new Set();
|
|
240
|
+
const learned = /* @__PURE__ */ new Set();
|
|
241
|
+
for (let i = messages.length - 1; i >= 0 && learned.size < this.#messageZoneLimit; i--) {
|
|
242
|
+
const message = messages[i];
|
|
243
|
+
if (!require_signals.isUserAuthoredMessage(message)) continue;
|
|
244
|
+
const raw = messageTimeZone(message);
|
|
245
|
+
if (typeof raw !== "string" || !raw || raw.length > MAX_ZONE_LENGTH || seen.has(raw)) continue;
|
|
246
|
+
if (seen.size === ZONE_SCAN_BUDGET) break;
|
|
247
|
+
seen.add(raw);
|
|
248
|
+
const canonical = this.#canonicalZone(raw);
|
|
249
|
+
if (canonical && !this.#configured.has(canonical)) learned.add(canonical);
|
|
250
|
+
}
|
|
251
|
+
return learned.size ? [...this.timeZones, ...[...learned].sort()] : this.timeZones;
|
|
252
|
+
}
|
|
187
253
|
/** The bucket the clock is in for one zone, keyed by its local wall-clock start. */
|
|
188
254
|
#bucket(now, timeZone) {
|
|
189
255
|
const clock = localClock(now, timeZone);
|
|
@@ -193,21 +259,22 @@ var TimeStateProcessor = class {
|
|
|
193
259
|
}
|
|
194
260
|
computeStateSignal(args) {
|
|
195
261
|
const now = /* @__PURE__ */ new Date();
|
|
262
|
+
const zones = this.#zones(args.messages);
|
|
196
263
|
const shown = args.contextWindow.hasSnapshot ? lastShown(args) : void 0;
|
|
197
264
|
const shownZones = shown?.timeZones;
|
|
198
|
-
const inWindow = typeof shown?.iso === "string" && Array.isArray(shownZones) && shownZones.length ===
|
|
265
|
+
const inWindow = typeof shown?.iso === "string" && Array.isArray(shownZones) && shownZones.length === zones.length && shownZones.every((zone, i) => zone === zones[i]);
|
|
199
266
|
let cacheKey;
|
|
200
267
|
if (this.#align) {
|
|
201
|
-
cacheKey = `time:${
|
|
268
|
+
cacheKey = `time:${zones.map((timeZone) => `${timeZone}=${this.#bucket(now, timeZone)}`).join("|")}`;
|
|
202
269
|
if (inWindow && args.tracking?.currentCacheKey === cacheKey) return;
|
|
203
270
|
} else {
|
|
204
271
|
const last = args.tracking?.updatedAt ? Date.parse(args.tracking.updatedAt) : NaN;
|
|
205
272
|
if (inWindow && now.getTime() - last < this.#intervalMs) return;
|
|
206
|
-
cacheKey = `time:${
|
|
273
|
+
cacheKey = `time:${zones.join("|")}@${now.toISOString()}`;
|
|
207
274
|
}
|
|
208
275
|
const value = {
|
|
209
276
|
iso: now.toISOString(),
|
|
210
|
-
timeZones:
|
|
277
|
+
timeZones: zones,
|
|
211
278
|
interval: this.#intervalMs
|
|
212
279
|
};
|
|
213
280
|
const line = (timeZone, format) => `${timeZone}: ${format(now, {
|
|
@@ -219,18 +286,18 @@ var TimeStateProcessor = class {
|
|
|
219
286
|
tagName: TIME_TAG,
|
|
220
287
|
mode: "snapshot",
|
|
221
288
|
cacheKey,
|
|
222
|
-
contents:
|
|
289
|
+
contents: zones.map((timeZone) => line(timeZone, this.#format)).join("\n"),
|
|
223
290
|
value
|
|
224
291
|
};
|
|
225
292
|
const shownAt = new Date(shown.iso);
|
|
226
|
-
const rolled =
|
|
293
|
+
const rolled = zones.filter((timeZone) => localClock(shownAt, timeZone).date !== localClock(now, timeZone).date);
|
|
227
294
|
const changed = rolled.length ? "date" : "time";
|
|
228
295
|
return {
|
|
229
296
|
id: this.stateId,
|
|
230
297
|
tagName: TIME_UPDATE_TAG,
|
|
231
298
|
mode: "delta",
|
|
232
299
|
cacheKey,
|
|
233
|
-
contents:
|
|
300
|
+
contents: zones.map((timeZone) => line(timeZone, rolled.includes(timeZone) ? this.#format : this.#formatTime)).join("\n"),
|
|
234
301
|
attributes: { changed },
|
|
235
302
|
value,
|
|
236
303
|
delta: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { r as SignalProvider } from "./signal-provider-BslnAjWG.js";
|
|
2
2
|
import { f as taskCheckTool, h as taskWriteTool, m as taskUpdateTool, n as TaskStateProcessor, p as taskCompleteTool } from "./state-processor-B9kxpM53.js";
|
|
3
|
+
import { c as isUserAuthoredMessage } from "./signals-CqR_iWkg.js";
|
|
3
4
|
// src/signals/task-signal-provider.ts
|
|
4
5
|
/**
|
|
5
6
|
* Bundles the built-in task tools and the {@link TaskStateProcessor} behind a
|
|
@@ -55,6 +56,11 @@ const MINUTE_MS = 6e4;
|
|
|
55
56
|
const HOUR_MS = 60 * MINUTE_MS;
|
|
56
57
|
const DEFAULT_INTERVAL_MS = 15 * MINUTE_MS;
|
|
57
58
|
const DAY_MS = 24 * HOUR_MS;
|
|
59
|
+
const DEFAULT_MESSAGE_ZONES = 10;
|
|
60
|
+
/** Distinct `timeZone` values examined per step, cached or not, so the result never depends on the cache. */
|
|
61
|
+
const ZONE_SCAN_BUDGET = 16;
|
|
62
|
+
const MAX_ZONE_LENGTH = 64;
|
|
63
|
+
const ZONE_CACHE_SIZE = 256;
|
|
58
64
|
const TIME_TAG = "current-time";
|
|
59
65
|
const TIME_UPDATE_TAG = "current-time-update";
|
|
60
66
|
const NAMED_INTERVALS = {
|
|
@@ -153,6 +159,25 @@ function localClock(date, timeZone) {
|
|
|
153
159
|
function lastShown(args) {
|
|
154
160
|
return (args.deltasSinceSnapshot.at(-1) ?? args.lastSnapshot)?.metadata?.value;
|
|
155
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* The zone a user message carries. Agent-facing signal `attributes` come first, then the signal's
|
|
164
|
+
* own `metadata`, then message `metadata`. The first one set to a non-empty string is the only one
|
|
165
|
+
* read: an invalid value there skips the message rather than falling back.
|
|
166
|
+
*/
|
|
167
|
+
function messageTimeZone(message) {
|
|
168
|
+
const metadata = message.content?.metadata;
|
|
169
|
+
for (const value of [
|
|
170
|
+
metadata?.signal?.attributes?.timeZone,
|
|
171
|
+
metadata?.signal?.metadata?.timeZone,
|
|
172
|
+
metadata?.timeZone
|
|
173
|
+
]) if (typeof value === "string" && value) return value;
|
|
174
|
+
}
|
|
175
|
+
function resolveMessageZoneLimit(option) {
|
|
176
|
+
if (option === false) return 0;
|
|
177
|
+
const max = option === true || option === void 0 ? DEFAULT_MESSAGE_ZONES : option.max ?? DEFAULT_MESSAGE_ZONES;
|
|
178
|
+
if (!Number.isInteger(max) || max < 1) throw new Error(`TimeSignalProvider: messageTimeZones.max must be a positive integer, got ${String(max)}`);
|
|
179
|
+
return max;
|
|
180
|
+
}
|
|
156
181
|
function pad(value) {
|
|
157
182
|
return String(value).padStart(2, "0");
|
|
158
183
|
}
|
|
@@ -172,7 +197,13 @@ var TimeStateProcessor = class {
|
|
|
172
197
|
#align;
|
|
173
198
|
#format;
|
|
174
199
|
#formatTime;
|
|
200
|
+
#configured;
|
|
201
|
+
#messageZoneLimit;
|
|
202
|
+
/** Canonical names by raw value, `null` for rejected values; least recently used first. */
|
|
203
|
+
#zoneCache = /* @__PURE__ */ new Map();
|
|
175
204
|
constructor(options, timeZones) {
|
|
205
|
+
this.#messageZoneLimit = resolveMessageZoneLimit(options.messageTimeZones);
|
|
206
|
+
this.#configured = new Set(timeZones.map(resolveTimeZone));
|
|
176
207
|
this.#align = options.align ?? true;
|
|
177
208
|
this.#intervalMs = resolveInterval(options.interval, this.#align);
|
|
178
209
|
this.timeZones = timeZones;
|
|
@@ -184,6 +215,41 @@ var TimeStateProcessor = class {
|
|
|
184
215
|
}).format(date) : defaultFormatter(this.#intervalMs);
|
|
185
216
|
this.#formatTime = format ? this.#format : timeOfDayFormatter(this.#intervalMs);
|
|
186
217
|
}
|
|
218
|
+
#canonicalZone(raw) {
|
|
219
|
+
let canonical = this.#zoneCache.get(raw);
|
|
220
|
+
if (canonical !== void 0) this.#zoneCache.delete(raw);
|
|
221
|
+
else {
|
|
222
|
+
try {
|
|
223
|
+
canonical = new Intl.DateTimeFormat("en-US", { timeZone: raw }).resolvedOptions().timeZone;
|
|
224
|
+
} catch {
|
|
225
|
+
canonical = null;
|
|
226
|
+
}
|
|
227
|
+
if (this.#zoneCache.size >= ZONE_CACHE_SIZE) this.#zoneCache.delete(this.#zoneCache.keys().next().value);
|
|
228
|
+
}
|
|
229
|
+
this.#zoneCache.set(raw, canonical);
|
|
230
|
+
return canonical ?? void 0;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* The configured zones, then the newest valid zones users sent as `timeZone`, sorted by
|
|
234
|
+
* canonical name so the list only changes when the set does. Scans newest first and stops after
|
|
235
|
+
* `ZONE_SCAN_BUDGET` distinct values: a zone behind that many newer ones is left out.
|
|
236
|
+
*/
|
|
237
|
+
#zones(messages) {
|
|
238
|
+
if (!this.#messageZoneLimit || !messages?.length) return this.timeZones;
|
|
239
|
+
const seen = /* @__PURE__ */ new Set();
|
|
240
|
+
const learned = /* @__PURE__ */ new Set();
|
|
241
|
+
for (let i = messages.length - 1; i >= 0 && learned.size < this.#messageZoneLimit; i--) {
|
|
242
|
+
const message = messages[i];
|
|
243
|
+
if (!isUserAuthoredMessage(message)) continue;
|
|
244
|
+
const raw = messageTimeZone(message);
|
|
245
|
+
if (typeof raw !== "string" || !raw || raw.length > MAX_ZONE_LENGTH || seen.has(raw)) continue;
|
|
246
|
+
if (seen.size === ZONE_SCAN_BUDGET) break;
|
|
247
|
+
seen.add(raw);
|
|
248
|
+
const canonical = this.#canonicalZone(raw);
|
|
249
|
+
if (canonical && !this.#configured.has(canonical)) learned.add(canonical);
|
|
250
|
+
}
|
|
251
|
+
return learned.size ? [...this.timeZones, ...[...learned].sort()] : this.timeZones;
|
|
252
|
+
}
|
|
187
253
|
/** The bucket the clock is in for one zone, keyed by its local wall-clock start. */
|
|
188
254
|
#bucket(now, timeZone) {
|
|
189
255
|
const clock = localClock(now, timeZone);
|
|
@@ -193,21 +259,22 @@ var TimeStateProcessor = class {
|
|
|
193
259
|
}
|
|
194
260
|
computeStateSignal(args) {
|
|
195
261
|
const now = /* @__PURE__ */ new Date();
|
|
262
|
+
const zones = this.#zones(args.messages);
|
|
196
263
|
const shown = args.contextWindow.hasSnapshot ? lastShown(args) : void 0;
|
|
197
264
|
const shownZones = shown?.timeZones;
|
|
198
|
-
const inWindow = typeof shown?.iso === "string" && Array.isArray(shownZones) && shownZones.length ===
|
|
265
|
+
const inWindow = typeof shown?.iso === "string" && Array.isArray(shownZones) && shownZones.length === zones.length && shownZones.every((zone, i) => zone === zones[i]);
|
|
199
266
|
let cacheKey;
|
|
200
267
|
if (this.#align) {
|
|
201
|
-
cacheKey = `time:${
|
|
268
|
+
cacheKey = `time:${zones.map((timeZone) => `${timeZone}=${this.#bucket(now, timeZone)}`).join("|")}`;
|
|
202
269
|
if (inWindow && args.tracking?.currentCacheKey === cacheKey) return;
|
|
203
270
|
} else {
|
|
204
271
|
const last = args.tracking?.updatedAt ? Date.parse(args.tracking.updatedAt) : NaN;
|
|
205
272
|
if (inWindow && now.getTime() - last < this.#intervalMs) return;
|
|
206
|
-
cacheKey = `time:${
|
|
273
|
+
cacheKey = `time:${zones.join("|")}@${now.toISOString()}`;
|
|
207
274
|
}
|
|
208
275
|
const value = {
|
|
209
276
|
iso: now.toISOString(),
|
|
210
|
-
timeZones:
|
|
277
|
+
timeZones: zones,
|
|
211
278
|
interval: this.#intervalMs
|
|
212
279
|
};
|
|
213
280
|
const line = (timeZone, format) => `${timeZone}: ${format(now, {
|
|
@@ -219,18 +286,18 @@ var TimeStateProcessor = class {
|
|
|
219
286
|
tagName: TIME_TAG,
|
|
220
287
|
mode: "snapshot",
|
|
221
288
|
cacheKey,
|
|
222
|
-
contents:
|
|
289
|
+
contents: zones.map((timeZone) => line(timeZone, this.#format)).join("\n"),
|
|
223
290
|
value
|
|
224
291
|
};
|
|
225
292
|
const shownAt = new Date(shown.iso);
|
|
226
|
-
const rolled =
|
|
293
|
+
const rolled = zones.filter((timeZone) => localClock(shownAt, timeZone).date !== localClock(now, timeZone).date);
|
|
227
294
|
const changed = rolled.length ? "date" : "time";
|
|
228
295
|
return {
|
|
229
296
|
id: this.stateId,
|
|
230
297
|
tagName: TIME_UPDATE_TAG,
|
|
231
298
|
mode: "delta",
|
|
232
299
|
cacheKey,
|
|
233
|
-
contents:
|
|
300
|
+
contents: zones.map((timeZone) => line(timeZone, rolled.includes(timeZone) ? this.#format : this.#formatTime)).join("\n"),
|
|
234
301
|
attributes: { changed },
|
|
235
302
|
value,
|
|
236
303
|
delta: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_constants = require("../constants-
|
|
2
|
+
const require_constants = require("../constants-CFO8w780.cjs");
|
|
3
3
|
exports.AGENTS_SCHEMA = require_constants.AGENTS_SCHEMA;
|
|
4
4
|
exports.AGENT_VERSIONS_SCHEMA = require_constants.AGENT_VERSIONS_SCHEMA;
|
|
5
5
|
exports.DATASETS_SCHEMA = require_constants.DATASETS_SCHEMA;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as AGENTS_SCHEMA, n as AGENT_VERSIONS_SCHEMA, r as DATASETS_SCHEMA, i as DATASET_ITEMS_SCHEMA, a as DATASET_VERSIONS_SCHEMA, o as EXPERIMENTS_SCHEMA, s as EXPERIMENT_RESULTS_SCHEMA, c as FAVORITES_SCHEMA, l as HARNESS_SESSIONS_SCHEMA, u as KNOWLEDGE_ACCESS_STATE_SCHEMA, d as KNOWLEDGE_ACTIVITY_SCHEMA, f as KNOWLEDGE_CURSORS_SCHEMA, p as KNOWLEDGE_IMPORT_RUNS_SCHEMA, m as KNOWLEDGE_IMPORT_STATE_SCHEMA, h as KNOWLEDGE_MENTIONS_SCHEMA, g as KNOWLEDGE_NODES_SCHEMA, _ as KNOWLEDGE_NODE_ADDRESSES_SCHEMA, v as KNOWLEDGE_NODE_SCOPES_SCHEMA, y as KNOWLEDGE_PROPOSALS_SCHEMA, b as KNOWLEDGE_RECORDS_SCHEMA, x as KNOWLEDGE_RECORD_SCOPES_SCHEMA, S as KNOWLEDGE_SCOPE_ADDRESSES_SCHEMA, C as KNOWLEDGE_SCOPE_GRANTS_SCHEMA, w as KNOWLEDGE_SEMANTIC_OUTBOX_SCHEMA, T as KNOWLEDGE_TABLE_NAMES, E as KNOWLEDGE_V2_ACTIVITY_SCHEMA, D as KNOWLEDGE_V2_MENTIONS_SCHEMA, O as KNOWLEDGE_V2_NODES_SCHEMA, k as KNOWLEDGE_V2_RECORDS_SCHEMA, A as MCP_CLIENTS_SCHEMA, j as MCP_CLIENT_VERSIONS_SCHEMA, M as MCP_SERVERS_SCHEMA, N as MCP_SERVER_VERSIONS_SCHEMA, P as MEMORY_RUN_FENCES_SCHEMA, F as NOTIFICATIONS_SCHEMA, I as OBSERVATIONAL_MEMORY_SCHEMA, L as OBSERVATIONAL_MEMORY_TABLE_SCHEMA, R as OLD_SPAN_SCHEMA, z as PROMPT_BLOCKS_SCHEMA, B as PROMPT_BLOCK_VERSIONS_SCHEMA, V as RUN_FENCING_TABLE_SCHEMAS, H as SCORERS_SCHEMA, U as SCORER_DEFINITIONS_SCHEMA, W as SCORER_DEFINITION_VERSIONS_SCHEMA, G as SKILLS_SCHEMA, K as SKILL_BLOBS_SCHEMA, q as SKILL_VERSIONS_SCHEMA, J as SPAN_SCHEMA, Y as TABLE_AGENTS, X as TABLE_AGENT_VERSIONS, Z as TABLE_BACKGROUND_TASKS, Q as TABLE_CHANNEL_CONFIG, $ as TABLE_CHANNEL_INSTALLATIONS, et as TABLE_CONFIGS, tt as TABLE_DATASETS, nt as TABLE_DATASET_ITEMS, rt as TABLE_DATASET_VERSIONS, it as TABLE_EXPERIMENTS, at as TABLE_EXPERIMENT_RESULTS, ot as TABLE_FAVORITES, st as TABLE_HARNESS_SESSIONS, ct as TABLE_KNOWLEDGE_ACCESS_STATE, lt as TABLE_KNOWLEDGE_ACTIVITY, ut as TABLE_KNOWLEDGE_CURSORS, dt as TABLE_KNOWLEDGE_IMPORT_RUNS, ft as TABLE_KNOWLEDGE_IMPORT_STATE, pt as TABLE_KNOWLEDGE_MENTIONS, mt as TABLE_KNOWLEDGE_NODES, ht as TABLE_KNOWLEDGE_NODE_ADDRESSES, gt as TABLE_KNOWLEDGE_NODE_SCOPES, _t as TABLE_KNOWLEDGE_PROPOSALS, vt as TABLE_KNOWLEDGE_RECORDS, yt as TABLE_KNOWLEDGE_RECORD_SCOPES, bt as TABLE_KNOWLEDGE_SCOPE_ADDRESSES, xt as TABLE_KNOWLEDGE_SCOPE_GRANTS, St as TABLE_KNOWLEDGE_SEMANTIC_OUTBOX, Ct as TABLE_MCP_CLIENTS, wt as TABLE_MCP_CLIENT_VERSIONS, Tt as TABLE_MCP_SERVERS, Et as TABLE_MCP_SERVER_VERSIONS, Dt as TABLE_MEMORY_RUN_FENCES, Ot as TABLE_MESSAGES, kt as TABLE_NOTIFICATIONS, At as TABLE_OBSERVATIONAL_MEMORY, jt as TABLE_PROMPT_BLOCKS, Mt as TABLE_PROMPT_BLOCK_VERSIONS, Nt as TABLE_RESOURCES, Pt as TABLE_SCHEDULES, Ft as TABLE_SCHEDULE_TRIGGERS, It as TABLE_SCHEMAS, Lt as TABLE_SCORERS, Rt as TABLE_SCORER_DEFINITIONS, zt as TABLE_SCORER_DEFINITION_VERSIONS, Bt as TABLE_SKILLS, Vt as TABLE_SKILL_BLOBS, Ht as TABLE_SKILL_VERSIONS, Ut as TABLE_SPANS, Wt as TABLE_THREADS, Gt as TABLE_THREAD_STATE, Kt as TABLE_TOOL_PROVIDER_CONNECTIONS, qt as TABLE_TRACES, Jt as TABLE_WORKFLOW_DEFINITIONS, Yt as TABLE_WORKFLOW_RUNS, Xt as TABLE_WORKFLOW_RUN_ENTRIES, Zt as TABLE_WORKFLOW_RUN_OWNERS, Qt as TABLE_WORKFLOW_SNAPSHOT, $t as TABLE_WORKSPACES, en as TABLE_WORKSPACE_VERSIONS, tn as THREAD_STATE_SCHEMA, nn as TOOL_PROVIDER_CONNECTIONS_SCHEMA, rn as WORKFLOW_DEFINITIONS_SCHEMA, in as WORKFLOW_RUNS_SCHEMA, an as WORKFLOW_RUN_ENTRIES_SCHEMA, on as WORKFLOW_RUN_JOURNAL_TABLE_CONFIGS, sn as WORKFLOW_RUN_OWNERS_SCHEMA, cn as WORKSPACES_SCHEMA, ln as WORKSPACE_VERSIONS_SCHEMA } from "../constants-
|
|
1
|
+
export { t as AGENTS_SCHEMA, n as AGENT_VERSIONS_SCHEMA, r as DATASETS_SCHEMA, i as DATASET_ITEMS_SCHEMA, a as DATASET_VERSIONS_SCHEMA, o as EXPERIMENTS_SCHEMA, s as EXPERIMENT_RESULTS_SCHEMA, c as FAVORITES_SCHEMA, l as HARNESS_SESSIONS_SCHEMA, u as KNOWLEDGE_ACCESS_STATE_SCHEMA, d as KNOWLEDGE_ACTIVITY_SCHEMA, f as KNOWLEDGE_CURSORS_SCHEMA, p as KNOWLEDGE_IMPORT_RUNS_SCHEMA, m as KNOWLEDGE_IMPORT_STATE_SCHEMA, h as KNOWLEDGE_MENTIONS_SCHEMA, g as KNOWLEDGE_NODES_SCHEMA, _ as KNOWLEDGE_NODE_ADDRESSES_SCHEMA, v as KNOWLEDGE_NODE_SCOPES_SCHEMA, y as KNOWLEDGE_PROPOSALS_SCHEMA, b as KNOWLEDGE_RECORDS_SCHEMA, x as KNOWLEDGE_RECORD_SCOPES_SCHEMA, S as KNOWLEDGE_SCOPE_ADDRESSES_SCHEMA, C as KNOWLEDGE_SCOPE_GRANTS_SCHEMA, w as KNOWLEDGE_SEMANTIC_OUTBOX_SCHEMA, T as KNOWLEDGE_TABLE_NAMES, E as KNOWLEDGE_V2_ACTIVITY_SCHEMA, D as KNOWLEDGE_V2_MENTIONS_SCHEMA, O as KNOWLEDGE_V2_NODES_SCHEMA, k as KNOWLEDGE_V2_RECORDS_SCHEMA, A as MCP_CLIENTS_SCHEMA, j as MCP_CLIENT_VERSIONS_SCHEMA, M as MCP_SERVERS_SCHEMA, N as MCP_SERVER_VERSIONS_SCHEMA, P as MEMORY_RUN_FENCES_SCHEMA, F as NOTIFICATIONS_SCHEMA, I as OBSERVATIONAL_MEMORY_SCHEMA, L as OBSERVATIONAL_MEMORY_TABLE_SCHEMA, R as OLD_SPAN_SCHEMA, z as PROMPT_BLOCKS_SCHEMA, B as PROMPT_BLOCK_VERSIONS_SCHEMA, V as RUN_FENCING_TABLE_SCHEMAS, H as SCORERS_SCHEMA, U as SCORER_DEFINITIONS_SCHEMA, W as SCORER_DEFINITION_VERSIONS_SCHEMA, G as SKILLS_SCHEMA, K as SKILL_BLOBS_SCHEMA, q as SKILL_VERSIONS_SCHEMA, J as SPAN_SCHEMA, Y as TABLE_AGENTS, X as TABLE_AGENT_VERSIONS, Z as TABLE_BACKGROUND_TASKS, Q as TABLE_CHANNEL_CONFIG, $ as TABLE_CHANNEL_INSTALLATIONS, et as TABLE_CONFIGS, tt as TABLE_DATASETS, nt as TABLE_DATASET_ITEMS, rt as TABLE_DATASET_VERSIONS, it as TABLE_EXPERIMENTS, at as TABLE_EXPERIMENT_RESULTS, ot as TABLE_FAVORITES, st as TABLE_HARNESS_SESSIONS, ct as TABLE_KNOWLEDGE_ACCESS_STATE, lt as TABLE_KNOWLEDGE_ACTIVITY, ut as TABLE_KNOWLEDGE_CURSORS, dt as TABLE_KNOWLEDGE_IMPORT_RUNS, ft as TABLE_KNOWLEDGE_IMPORT_STATE, pt as TABLE_KNOWLEDGE_MENTIONS, mt as TABLE_KNOWLEDGE_NODES, ht as TABLE_KNOWLEDGE_NODE_ADDRESSES, gt as TABLE_KNOWLEDGE_NODE_SCOPES, _t as TABLE_KNOWLEDGE_PROPOSALS, vt as TABLE_KNOWLEDGE_RECORDS, yt as TABLE_KNOWLEDGE_RECORD_SCOPES, bt as TABLE_KNOWLEDGE_SCOPE_ADDRESSES, xt as TABLE_KNOWLEDGE_SCOPE_GRANTS, St as TABLE_KNOWLEDGE_SEMANTIC_OUTBOX, Ct as TABLE_MCP_CLIENTS, wt as TABLE_MCP_CLIENT_VERSIONS, Tt as TABLE_MCP_SERVERS, Et as TABLE_MCP_SERVER_VERSIONS, Dt as TABLE_MEMORY_RUN_FENCES, Ot as TABLE_MESSAGES, kt as TABLE_NOTIFICATIONS, At as TABLE_OBSERVATIONAL_MEMORY, jt as TABLE_PROMPT_BLOCKS, Mt as TABLE_PROMPT_BLOCK_VERSIONS, Nt as TABLE_RESOURCES, Pt as TABLE_SCHEDULES, Ft as TABLE_SCHEDULE_TRIGGERS, It as TABLE_SCHEMAS, Lt as TABLE_SCORERS, Rt as TABLE_SCORER_DEFINITIONS, zt as TABLE_SCORER_DEFINITION_VERSIONS, Bt as TABLE_SKILLS, Vt as TABLE_SKILL_BLOBS, Ht as TABLE_SKILL_VERSIONS, Ut as TABLE_SPANS, Wt as TABLE_THREADS, Gt as TABLE_THREAD_STATE, Kt as TABLE_TOOL_PROVIDER_CONNECTIONS, qt as TABLE_TRACES, Jt as TABLE_WORKFLOW_DEFINITIONS, Yt as TABLE_WORKFLOW_RUNS, Xt as TABLE_WORKFLOW_RUN_ENTRIES, Zt as TABLE_WORKFLOW_RUN_OWNERS, Qt as TABLE_WORKFLOW_SNAPSHOT, $t as TABLE_WORKSPACES, en as TABLE_WORKSPACE_VERSIONS, tn as THREAD_STATE_SCHEMA, nn as TOOL_PROVIDER_CONNECTIONS_SCHEMA, rn as WORKFLOW_DEFINITIONS_SCHEMA, in as WORKFLOW_RUNS_SCHEMA, an as WORKFLOW_RUN_ENTRIES_SCHEMA, on as WORKFLOW_RUN_JOURNAL_TABLE_CONFIGS, sn as WORKFLOW_RUN_OWNERS_SCHEMA, cn as WORKSPACES_SCHEMA, ln as WORKSPACE_VERSIONS_SCHEMA } from "../constants-CUv0mU2y.js";
|