@theokit/sdk 2.29.0 → 3.0.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/CHANGELOG.md +20 -0
- package/dist/a2a/index.cjs +8 -1
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.d.cts +1 -1
- package/dist/a2a/index.d.ts +1 -1
- package/dist/a2a/index.js +8 -1
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a/subagent.d.cts +5 -1
- package/dist/a2a/subagent.d.ts +5 -1
- package/dist/agent-factory.d.ts +5 -20
- package/dist/concurrency.cjs +10 -1
- package/dist/concurrency.cjs.map +1 -1
- package/dist/concurrency.d.cts +7 -1
- package/dist/concurrency.d.ts +7 -1
- package/dist/concurrency.js +10 -1
- package/dist/concurrency.js.map +1 -1
- package/dist/create-skill.d.ts +7 -7
- package/dist/{cron-COSAehOL.d.ts → cron-BLRe166v.d.ts} +392 -31
- package/dist/{cron-yJoNUZxe.d.cts → cron-C2jWAvlQ.d.cts} +392 -31
- package/dist/cron.cjs +89 -44
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +89 -44
- package/dist/cron.js.map +1 -1
- package/dist/define-tool.d.ts +12 -1
- package/dist/{errors-tP-8O-hR.d.cts → errors-DZpCGlYv.d.cts} +1 -1
- package/dist/{errors-BxMIlgLP.d.ts → errors-D_Bfo30u.d.ts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/index.cjs +179 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -246
- package/dist/index.d.ts +64 -246
- package/dist/index.js +168 -45
- package/dist/index.js.map +1 -1
- package/dist/internal/plugins/index.d.cts +1 -1
- package/dist/internal/plugins/index.d.ts +1 -1
- package/dist/internal/plugins/types.d.cts +4 -0
- package/dist/internal/plugins/types.d.ts +4 -0
- package/dist/retry.cjs +10 -1
- package/dist/retry.cjs.map +1 -1
- package/dist/retry.d.cts +12 -1
- package/dist/retry.d.ts +12 -1
- package/dist/retry.js +10 -1
- package/dist/retry.js.map +1 -1
- package/dist/{run-q_P0vHlY.d.cts → run-CLXKMRgq.d.cts} +1 -1
- package/dist/{run-q_P0vHlY.d.ts → run-CLXKMRgq.d.ts} +1 -1
- package/dist/server/auth/index.cjs +8 -1
- package/dist/server/auth/index.cjs.map +1 -1
- package/dist/server/auth/index.d.cts +1 -1
- package/dist/server/auth/index.d.ts +1 -1
- package/dist/server/auth/index.js +8 -1
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/auth/orchestrator.d.cts +5 -1
- package/dist/server/auth/orchestrator.d.ts +5 -1
- package/dist/subscription/define-subscription.d.cts +5 -0
- package/dist/subscription/define-subscription.d.ts +5 -0
- package/dist/subscription/index.cjs +8 -1
- package/dist/subscription/index.cjs.map +1 -1
- package/dist/subscription/index.d.cts +1 -1
- package/dist/subscription/index.d.ts +1 -1
- package/dist/subscription/index.js +8 -1
- package/dist/subscription/index.js.map +1 -1
- package/dist/types/cron.d.ts +30 -13
- package/package.json +1 -1
package/dist/cron.cjs
CHANGED
|
@@ -17769,15 +17769,31 @@ setAgentFacade({
|
|
|
17769
17769
|
// src/cron.ts
|
|
17770
17770
|
init_errors();
|
|
17771
17771
|
|
|
17772
|
+
// src/internal/cron/fire-handler.ts
|
|
17773
|
+
init_registry();
|
|
17774
|
+
|
|
17772
17775
|
// src/internal/cron/run-job.ts
|
|
17773
17776
|
init_errors();
|
|
17774
17777
|
init_agent_factory_registry();
|
|
17775
17778
|
async function runCronJob(job) {
|
|
17776
|
-
if (job.
|
|
17777
|
-
if (job.
|
|
17778
|
-
|
|
17779
|
-
|
|
17780
|
-
|
|
17779
|
+
if (job.workflow !== void 0) return job.workflow.run(job.inputData);
|
|
17780
|
+
if (job.agent !== void 0) return runWithEphemeralAgent(job.agent, requireMessage(job));
|
|
17781
|
+
if (job.agentId !== void 0) return runWithExistingAgent(job.agentId, requireMessage(job));
|
|
17782
|
+
throw new ConfigurationError(
|
|
17783
|
+
`Cron job ${job.id} has no target (agent, agentId, or workflow) \u2014 cannot run.`,
|
|
17784
|
+
{ code: "cron_no_target" }
|
|
17785
|
+
);
|
|
17786
|
+
}
|
|
17787
|
+
function isAgentRun(outcome) {
|
|
17788
|
+
return typeof outcome.wait === "function";
|
|
17789
|
+
}
|
|
17790
|
+
function requireMessage(job) {
|
|
17791
|
+
if (job.message === void 0) {
|
|
17792
|
+
throw new ConfigurationError(`Cron job ${job.id} is an agent target but has no message.`, {
|
|
17793
|
+
code: "cron_missing_message"
|
|
17794
|
+
});
|
|
17795
|
+
}
|
|
17796
|
+
return job.message;
|
|
17781
17797
|
}
|
|
17782
17798
|
async function runWithExistingAgent(agentId, message) {
|
|
17783
17799
|
const info = await getAgentFacade().get(agentId).catch(() => void 0);
|
|
@@ -17795,6 +17811,37 @@ async function runWithEphemeralAgent(baseOptions, message) {
|
|
|
17795
17811
|
return agent.send(message);
|
|
17796
17812
|
}
|
|
17797
17813
|
|
|
17814
|
+
// src/internal/cron/fire-handler.ts
|
|
17815
|
+
async function fireCronJobAsTask(job) {
|
|
17816
|
+
const fireTs = Date.now();
|
|
17817
|
+
const taskId = `cron-${job.id}-${fireTs}`;
|
|
17818
|
+
try {
|
|
17819
|
+
await submit({
|
|
17820
|
+
kind: "cron",
|
|
17821
|
+
id: taskId,
|
|
17822
|
+
allowReservedPrefix: true,
|
|
17823
|
+
meta: { jobId: job.id, jobName: job.name, schedule: job.cron, firedAt: fireTs },
|
|
17824
|
+
work: async (ctx) => {
|
|
17825
|
+
const outcome = await runCronJob(job);
|
|
17826
|
+
if (isAgentRun(outcome)) {
|
|
17827
|
+
ctx.signal.addEventListener("abort", () => void outcome.cancel().catch(() => {
|
|
17828
|
+
}), {
|
|
17829
|
+
once: true
|
|
17830
|
+
});
|
|
17831
|
+
const result = await outcome.wait();
|
|
17832
|
+
ctx.emit({ status: result.status, runId: outcome.id });
|
|
17833
|
+
return { status: result.status, runId: outcome.id };
|
|
17834
|
+
}
|
|
17835
|
+
ctx.emit({ status: outcome.status, runId: outcome.id });
|
|
17836
|
+
return { status: outcome.status, runId: outcome.id };
|
|
17837
|
+
}
|
|
17838
|
+
});
|
|
17839
|
+
} catch {
|
|
17840
|
+
const outcome = await runCronJob(job);
|
|
17841
|
+
if (isAgentRun(outcome)) await outcome.wait();
|
|
17842
|
+
}
|
|
17843
|
+
}
|
|
17844
|
+
|
|
17798
17845
|
// src/internal/cron/store.ts
|
|
17799
17846
|
var jobs = /* @__PURE__ */ new Map();
|
|
17800
17847
|
function listJobs() {
|
|
@@ -17985,7 +18032,6 @@ function estimateNextRunAt(_cron, _timezone) {
|
|
|
17985
18032
|
}
|
|
17986
18033
|
|
|
17987
18034
|
// src/cron.ts
|
|
17988
|
-
init_registry();
|
|
17989
18035
|
var Cron = class {
|
|
17990
18036
|
constructor() {
|
|
17991
18037
|
}
|
|
@@ -18052,7 +18098,8 @@ var Cron = class {
|
|
|
18052
18098
|
return updateJobStatus(jobId, false);
|
|
18053
18099
|
}
|
|
18054
18100
|
/**
|
|
18055
|
-
* Manually trigger a cron job off-schedule. Returns the resulting `Run
|
|
18101
|
+
* Manually trigger a cron job off-schedule. Returns the resulting `Run`
|
|
18102
|
+
* (agent target) or `WorkflowRun` (workflow target — SE35).
|
|
18056
18103
|
*
|
|
18057
18104
|
* @public
|
|
18058
18105
|
*/
|
|
@@ -18069,30 +18116,7 @@ var Cron = class {
|
|
|
18069
18116
|
* @public
|
|
18070
18117
|
*/
|
|
18071
18118
|
static start(options = {}) {
|
|
18072
|
-
setCronFireHandler(
|
|
18073
|
-
const fireTs = Date.now();
|
|
18074
|
-
const taskId = `cron-${job.id}-${fireTs}`;
|
|
18075
|
-
try {
|
|
18076
|
-
await submit({
|
|
18077
|
-
kind: "cron",
|
|
18078
|
-
id: taskId,
|
|
18079
|
-
allowReservedPrefix: true,
|
|
18080
|
-
meta: { jobId: job.id, jobName: job.name, schedule: job.cron, firedAt: fireTs },
|
|
18081
|
-
work: async (ctx) => {
|
|
18082
|
-
const run = await runCronJob(job);
|
|
18083
|
-
ctx.signal.addEventListener("abort", () => void run.cancel().catch(() => {
|
|
18084
|
-
}), {
|
|
18085
|
-
once: true
|
|
18086
|
-
});
|
|
18087
|
-
const result = await run.wait();
|
|
18088
|
-
ctx.emit({ status: result.status, runId: run.id });
|
|
18089
|
-
return { status: result.status, runId: run.id };
|
|
18090
|
-
}
|
|
18091
|
-
});
|
|
18092
|
-
} catch {
|
|
18093
|
-
await runCronJob(job).then((run) => run.wait());
|
|
18094
|
-
}
|
|
18095
|
-
});
|
|
18119
|
+
setCronFireHandler(fireCronJobAsTask);
|
|
18096
18120
|
startScheduler(options.cwd);
|
|
18097
18121
|
return Promise.resolve();
|
|
18098
18122
|
}
|
|
@@ -18116,17 +18140,7 @@ var Cron = class {
|
|
|
18116
18140
|
}
|
|
18117
18141
|
};
|
|
18118
18142
|
async function createCronJob(options) {
|
|
18119
|
-
|
|
18120
|
-
throw new ConfigurationError(
|
|
18121
|
-
"agent and agentId are mutually exclusive \u2014 pass either agent (ephemeral) or agentId (reuse).",
|
|
18122
|
-
{ code: "cron_agent_exclusive" }
|
|
18123
|
-
);
|
|
18124
|
-
}
|
|
18125
|
-
if (options.agent === void 0 && options.agentId === void 0) {
|
|
18126
|
-
throw new ConfigurationError("Cron job requires either agent or agentId", {
|
|
18127
|
-
code: "cron_missing_agent"
|
|
18128
|
-
});
|
|
18129
|
-
}
|
|
18143
|
+
validateCronTarget(options);
|
|
18130
18144
|
validateCronExpression(options.cron);
|
|
18131
18145
|
const timezone = options.timezone ?? "UTC";
|
|
18132
18146
|
validateTimezone(timezone);
|
|
@@ -18137,20 +18151,51 @@ async function createCronJob(options) {
|
|
|
18137
18151
|
id: generateCronId(),
|
|
18138
18152
|
cron: options.cron,
|
|
18139
18153
|
timezone,
|
|
18140
|
-
message: options.message,
|
|
18141
18154
|
enabled: options.enabled ?? true,
|
|
18142
18155
|
status: options.enabled === false ? "paused" : "scheduled",
|
|
18143
18156
|
runtime,
|
|
18144
18157
|
createdAt: now,
|
|
18145
18158
|
nextRunAt: estimateNextRunAt(options.cron),
|
|
18146
18159
|
...options.name !== void 0 ? { name: options.name } : {},
|
|
18160
|
+
...options.message !== void 0 ? { message: options.message } : {},
|
|
18147
18161
|
...options.agent !== void 0 ? { agent: options.agent } : {},
|
|
18148
|
-
...options.agentId !== void 0 ? { agentId: options.agentId } : {}
|
|
18162
|
+
...options.agentId !== void 0 ? { agentId: options.agentId } : {},
|
|
18163
|
+
...options.workflow !== void 0 ? { workflow: options.workflow } : {},
|
|
18164
|
+
...options.inputData !== void 0 ? { inputData: options.inputData } : {}
|
|
18149
18165
|
};
|
|
18150
18166
|
upsertJob(job);
|
|
18151
18167
|
return job;
|
|
18152
18168
|
}
|
|
18169
|
+
function validateCronTarget(options) {
|
|
18170
|
+
const targets = [options.agent, options.agentId, options.workflow].filter(
|
|
18171
|
+
(t) => t !== void 0
|
|
18172
|
+
).length;
|
|
18173
|
+
if (targets > 1) {
|
|
18174
|
+
throw new ConfigurationError(
|
|
18175
|
+
"agent, agentId, and workflow are mutually exclusive \u2014 pass exactly one target.",
|
|
18176
|
+
{ code: "cron_ambiguous_target" }
|
|
18177
|
+
);
|
|
18178
|
+
}
|
|
18179
|
+
if (targets === 0) {
|
|
18180
|
+
throw new ConfigurationError(
|
|
18181
|
+
"Cron job requires exactly one target: agent, agentId, or workflow.",
|
|
18182
|
+
{ code: "cron_no_target" }
|
|
18183
|
+
);
|
|
18184
|
+
}
|
|
18185
|
+
if (options.workflow !== void 0 && options.message !== void 0) {
|
|
18186
|
+
throw new ConfigurationError(
|
|
18187
|
+
"A workflow cron target takes inputData, not a message \u2014 remove `message`.",
|
|
18188
|
+
{ code: "cron_workflow_message" }
|
|
18189
|
+
);
|
|
18190
|
+
}
|
|
18191
|
+
if (options.workflow === void 0 && options.message === void 0) {
|
|
18192
|
+
throw new ConfigurationError("An agent cron target requires a message.", {
|
|
18193
|
+
code: "cron_missing_message"
|
|
18194
|
+
});
|
|
18195
|
+
}
|
|
18196
|
+
}
|
|
18153
18197
|
function detectRuntime(options) {
|
|
18198
|
+
if (options.workflow !== void 0) return "local";
|
|
18154
18199
|
if (options.agentId !== void 0) {
|
|
18155
18200
|
return options.agentId.startsWith("bc-") ? "cloud" : "local";
|
|
18156
18201
|
}
|