@kody-ade/kody-engine 0.4.575 → 0.4.576
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/bin/kody.js +24 -8
- package/package.json +1 -1
package/dist/bin/kody.js
CHANGED
|
@@ -15,7 +15,7 @@ var init_package = __esm({
|
|
|
15
15
|
"package.json"() {
|
|
16
16
|
package_default = {
|
|
17
17
|
name: "@kody-ade/kody-engine",
|
|
18
|
-
version: "0.4.
|
|
18
|
+
version: "0.4.576",
|
|
19
19
|
description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
|
|
20
20
|
license: "MIT",
|
|
21
21
|
type: "module",
|
|
@@ -3068,6 +3068,12 @@ function createStateBackendFromEnv(env = process.env, client) {
|
|
|
3068
3068
|
transport = createConvexClientFromEnv(env);
|
|
3069
3069
|
}
|
|
3070
3070
|
return {
|
|
3071
|
+
async listLoops(tenantId2) {
|
|
3072
|
+
const result = await transport.query(anyApi.agencyRequestLoops.list, {
|
|
3073
|
+
tenantId: requireTenant(tenantId2)
|
|
3074
|
+
});
|
|
3075
|
+
return Array.isArray(result) ? result : [];
|
|
3076
|
+
},
|
|
3071
3077
|
async get(tenantId2, taskKey, kind) {
|
|
3072
3078
|
const result = await transport.query(anyApi.taskState.get, {
|
|
3073
3079
|
tenantId: requireTenant(tenantId2),
|
|
@@ -14215,7 +14221,7 @@ async function dispatchLoopsWith(input) {
|
|
|
14215
14221
|
let reason = "target did not complete";
|
|
14216
14222
|
let runFailed = false;
|
|
14217
14223
|
try {
|
|
14218
|
-
const result = await input.run(loopJob(loop), runId);
|
|
14224
|
+
const result = await input.run(loopJob(loop, runId), runId, loop.id);
|
|
14219
14225
|
exitCode = result.exitCode;
|
|
14220
14226
|
reason = result.reason ?? (exitCode === 0 ? "dispatched" : "target failed");
|
|
14221
14227
|
} catch (error) {
|
|
@@ -14285,6 +14291,14 @@ function selectRunnableLoops(loops, now, options) {
|
|
|
14285
14291
|
(loop) => loop.enabled && (!options.loopId || loop.id === options.loopId) && (options.force || loop.trigger.type === "schedule" && dueSlot(loop, now) !== null)
|
|
14286
14292
|
);
|
|
14287
14293
|
}
|
|
14294
|
+
function mergeLoopDefinitions(repositoryLoops, runtimeLoops) {
|
|
14295
|
+
const byId = new Map(repositoryLoops.map((loop) => [loop.id, loop]));
|
|
14296
|
+
for (const candidate of runtimeLoops) {
|
|
14297
|
+
const loop = normalizeLoopDefinition(candidate);
|
|
14298
|
+
if (loop) byId.set(loop.id, loop);
|
|
14299
|
+
}
|
|
14300
|
+
return [...byId.values()].sort((left, right) => left.id.localeCompare(right.id));
|
|
14301
|
+
}
|
|
14288
14302
|
function loopDispatchSlot(loop, now, force, nonce) {
|
|
14289
14303
|
return force ? `manual:${now.toISOString()}:${nonce}` : dueSlot(loop, now);
|
|
14290
14304
|
}
|
|
@@ -14318,9 +14332,9 @@ function dueSlot(loop, now) {
|
|
|
14318
14332
|
const day = parts.find((part) => part.type === "day")?.value;
|
|
14319
14333
|
return `${year}-${month}-${day}T${loop.trigger.at.time}[${loop.trigger.at.timezone}]`;
|
|
14320
14334
|
}
|
|
14321
|
-
function loopJob(loop) {
|
|
14335
|
+
function loopJob(loop, runId) {
|
|
14322
14336
|
const cliArgs = { ...loop.input };
|
|
14323
|
-
return loop.target.kind === "workflow" ? { workflow: loop.target.id, cliArgs, flavor: "scheduled" } : { capability: loop.target.id, cliArgs, flavor: "scheduled" };
|
|
14337
|
+
return loop.target.kind === "workflow" ? { workflow: loop.target.id, workflowRunId: runId, cliArgs, flavor: "scheduled" } : { capability: loop.target.id, cliArgs, flavor: "scheduled" };
|
|
14324
14338
|
}
|
|
14325
14339
|
function repositoryTenant(config) {
|
|
14326
14340
|
const [envOwner, envRepo] = (process.env.GITHUB_REPOSITORY ?? "").split("/");
|
|
@@ -14343,13 +14357,14 @@ var init_dispatchLoops = __esm({
|
|
|
14343
14357
|
const now = /* @__PURE__ */ new Date();
|
|
14344
14358
|
const force = ctx.data.jobForce === true;
|
|
14345
14359
|
const requestedLoopId = typeof ctx.args.loop === "string" ? ctx.args.loop.trim() : "";
|
|
14346
|
-
const
|
|
14360
|
+
const backend = createStateBackendFromEnv();
|
|
14361
|
+
const loops = mergeLoopDefinitions(listLoopDefinitions(ctx.cwd), await backend.listLoops(tenantId2));
|
|
14362
|
+
const due = selectRunnableLoops(loops, now, {
|
|
14347
14363
|
force,
|
|
14348
14364
|
...requestedLoopId ? { loopId: requestedLoopId } : {}
|
|
14349
14365
|
});
|
|
14350
14366
|
process.stdout.write(`\u2192 kody: Loop scheduler found ${due.length} runnable Loop(s)${force ? " (manual)" : ""}
|
|
14351
14367
|
`);
|
|
14352
|
-
const backend = createStateBackendFromEnv();
|
|
14353
14368
|
const results = await dispatchLoopsWith({
|
|
14354
14369
|
loops: due,
|
|
14355
14370
|
tenantId: tenantId2,
|
|
@@ -14357,13 +14372,13 @@ var init_dispatchLoops = __esm({
|
|
|
14357
14372
|
now,
|
|
14358
14373
|
force,
|
|
14359
14374
|
nonce: randomUUID,
|
|
14360
|
-
run: (job, parentRunId) => runJob(job, {
|
|
14375
|
+
run: (job, parentRunId, loopId) => runJob(job, {
|
|
14361
14376
|
cwd: ctx.cwd,
|
|
14362
14377
|
config: ctx.config,
|
|
14363
14378
|
verbose: ctx.verbose,
|
|
14364
14379
|
quiet: ctx.quiet,
|
|
14365
14380
|
chain: false,
|
|
14366
|
-
preloadedData: { parentRunId }
|
|
14381
|
+
preloadedData: { parentRunId, loopId }
|
|
14367
14382
|
})
|
|
14368
14383
|
});
|
|
14369
14384
|
for (const result of results) {
|
|
@@ -23364,6 +23379,7 @@ async function runJob(job, base) {
|
|
|
23364
23379
|
await notifyWorkflowCompleted({
|
|
23365
23380
|
workflowId: workflowIdentity,
|
|
23366
23381
|
runId: valid.workflowRunId,
|
|
23382
|
+
...typeof base.preloadedData?.loopId === "string" ? { loopId: base.preloadedData.loopId } : {},
|
|
23367
23383
|
status: result.workflowState?.status === "blocked" ? "blocked" : result.exitCode === 0 ? "success" : "failed",
|
|
23368
23384
|
...result.reason ? { summary: result.reason } : {},
|
|
23369
23385
|
...Object.keys(facts).length > 0 ? { output: facts } : {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kody-ade/kody-engine",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.576",
|
|
4
4
|
"description": "kody — autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative implementation profiles.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|