@kody-ade/kody-engine 0.4.256 → 0.4.258
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 +236 -147
- 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.258",
|
|
19
19
|
description: "kody \u2014 autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative agentAction profiles.",
|
|
20
20
|
license: "MIT",
|
|
21
21
|
type: "module",
|
|
@@ -3069,9 +3069,9 @@ function parseAgentResponsibilityReportsFromText(text) {
|
|
|
3069
3069
|
function parseAgentResponsibilityReport(raw) {
|
|
3070
3070
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
3071
3071
|
const obj = raw;
|
|
3072
|
-
const target =
|
|
3072
|
+
const target = parseAgentResponsibilityReportTarget(obj.target);
|
|
3073
3073
|
if (!target) return null;
|
|
3074
|
-
const evidence =
|
|
3074
|
+
const evidence = parseAgentResponsibilityReportEvidence(obj.evidence);
|
|
3075
3075
|
const facts = parseFacts(obj.facts);
|
|
3076
3076
|
if (!evidence && !facts) return null;
|
|
3077
3077
|
return {
|
|
@@ -3080,36 +3080,14 @@ function parseAgentResponsibilityReport(raw) {
|
|
|
3080
3080
|
...facts ? { facts } : {}
|
|
3081
3081
|
};
|
|
3082
3082
|
}
|
|
3083
|
-
function
|
|
3084
|
-
const priorFacts = parseFacts(state.extra.facts) ?? {};
|
|
3085
|
-
const nextFacts = { ...priorFacts };
|
|
3086
|
-
for (const [key, value] of Object.entries(report.facts ?? {})) {
|
|
3087
|
-
if (CONTROL_FACT_KEYS.has(key)) continue;
|
|
3088
|
-
nextFacts[key] = value;
|
|
3089
|
-
}
|
|
3090
|
-
for (const [key, value] of Object.entries(report.evidence ?? {})) {
|
|
3091
|
-
nextFacts[key] = value;
|
|
3092
|
-
}
|
|
3093
|
-
const pending = nextFacts.pendingEvidence;
|
|
3094
|
-
if (typeof pending === "string" && Object.hasOwn(report.evidence ?? {}, pending)) {
|
|
3095
|
-
delete nextFacts.pendingEvidence;
|
|
3096
|
-
}
|
|
3097
|
-
return {
|
|
3098
|
-
...state,
|
|
3099
|
-
extra: {
|
|
3100
|
-
...state.extra,
|
|
3101
|
-
facts: nextFacts
|
|
3102
|
-
}
|
|
3103
|
-
};
|
|
3104
|
-
}
|
|
3105
|
-
function parseTarget(raw) {
|
|
3083
|
+
function parseAgentResponsibilityReportTarget(raw) {
|
|
3106
3084
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
3107
3085
|
const target = raw;
|
|
3108
3086
|
if (target.type !== "goal" && target.type !== "task" && target.type !== "agentResponsibility") return null;
|
|
3109
3087
|
if (typeof target.id !== "string" || target.id.trim().length === 0) return null;
|
|
3110
3088
|
return { type: target.type, id: target.id.trim() };
|
|
3111
3089
|
}
|
|
3112
|
-
function
|
|
3090
|
+
function parseAgentResponsibilityReportEvidence(raw) {
|
|
3113
3091
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
3114
3092
|
const out = {};
|
|
3115
3093
|
for (const [key, value] of Object.entries(raw)) {
|
|
@@ -3158,6 +3136,10 @@ function parseAgentResponsibilityResult(raw) {
|
|
|
3158
3136
|
if (!isAgentResponsibilityResultStatus(obj.status)) return null;
|
|
3159
3137
|
const summary = typeof obj.summary === "string" ? obj.summary.trim() : "";
|
|
3160
3138
|
if (!summary) return null;
|
|
3139
|
+
const target = obj.target === void 0 ? void 0 : parseAgentResponsibilityReportTarget(obj.target);
|
|
3140
|
+
if (obj.target !== void 0 && !target) return null;
|
|
3141
|
+
const evidence = obj.evidence === void 0 ? void 0 : parseAgentResponsibilityReportEvidence(obj.evidence);
|
|
3142
|
+
if (obj.evidence !== void 0 && !evidence) return null;
|
|
3161
3143
|
const facts = parseFacts2(obj.facts);
|
|
3162
3144
|
if (!facts) return null;
|
|
3163
3145
|
const artifacts = parseArtifacts(obj.artifacts);
|
|
@@ -3168,51 +3150,16 @@ function parseAgentResponsibilityResult(raw) {
|
|
|
3168
3150
|
if (!blockers) return null;
|
|
3169
3151
|
return {
|
|
3170
3152
|
version: 1,
|
|
3153
|
+
...target ? { target } : {},
|
|
3171
3154
|
status: obj.status,
|
|
3172
3155
|
summary,
|
|
3156
|
+
...evidence ? { evidence } : {},
|
|
3173
3157
|
facts,
|
|
3174
3158
|
artifacts,
|
|
3175
3159
|
missingEvidence,
|
|
3176
3160
|
blockers
|
|
3177
3161
|
};
|
|
3178
3162
|
}
|
|
3179
|
-
function applyAgentResponsibilityResultToObjectiveState(state, result, evidenceOverride) {
|
|
3180
|
-
const priorFacts = parseFacts2(state.extra.facts) ?? {};
|
|
3181
|
-
const nextFacts = { ...priorFacts };
|
|
3182
|
-
for (const [key, value] of Object.entries(result.facts)) {
|
|
3183
|
-
if (CONTROL_FACT_KEYS2.has(key)) continue;
|
|
3184
|
-
nextFacts[key] = value;
|
|
3185
|
-
}
|
|
3186
|
-
const evidence = evidenceOverride || (typeof nextFacts.pendingEvidence === "string" ? nextFacts.pendingEvidence : "");
|
|
3187
|
-
if (evidence) {
|
|
3188
|
-
if (result.status === "pass") nextFacts[evidence] = true;
|
|
3189
|
-
if (result.status === "fail" || result.status === "blocked") nextFacts[evidence] = false;
|
|
3190
|
-
if ((result.status === "pass" || result.status === "fail" || result.status === "blocked") && nextFacts.pendingEvidence === evidence) {
|
|
3191
|
-
delete nextFacts.pendingEvidence;
|
|
3192
|
-
}
|
|
3193
|
-
}
|
|
3194
|
-
const blockers = parseStringArray(state.extra.blockers) ?? [];
|
|
3195
|
-
const resultBlockers = result.blockers.length > 0 || result.status !== "fail" && result.status !== "blocked" ? result.blockers : [result.summary];
|
|
3196
|
-
for (const blocker of resultBlockers) {
|
|
3197
|
-
if (!blockers.includes(blocker)) blockers.push(blocker);
|
|
3198
|
-
}
|
|
3199
|
-
return {
|
|
3200
|
-
...state,
|
|
3201
|
-
extra: {
|
|
3202
|
-
...state.extra,
|
|
3203
|
-
facts: nextFacts,
|
|
3204
|
-
blockers,
|
|
3205
|
-
lastAgentResponsibilityResult: {
|
|
3206
|
-
status: result.status,
|
|
3207
|
-
summary: result.summary,
|
|
3208
|
-
facts: result.facts,
|
|
3209
|
-
artifacts: result.artifacts,
|
|
3210
|
-
missingEvidence: result.missingEvidence,
|
|
3211
|
-
blockers: result.blockers
|
|
3212
|
-
}
|
|
3213
|
-
}
|
|
3214
|
-
};
|
|
3215
|
-
}
|
|
3216
3163
|
function isAgentResponsibilityResultStatus(value) {
|
|
3217
3164
|
return typeof value === "string" && STATUSES.has(value);
|
|
3218
3165
|
}
|
|
@@ -3263,6 +3210,7 @@ var RESULT_LINE, STATUSES, CONTROL_FACT_KEYS2;
|
|
|
3263
3210
|
var init_agent_responsibilityResult = __esm({
|
|
3264
3211
|
"src/agent-responsibilityResult.ts"() {
|
|
3265
3212
|
"use strict";
|
|
3213
|
+
init_agent_responsibilityReport();
|
|
3266
3214
|
RESULT_LINE = /^KODY_AGENT_RESPONSIBILITY_RESULT=(.+)$/gm;
|
|
3267
3215
|
STATUSES = /* @__PURE__ */ new Set(["pass", "fail", "blocked", "changed", "noop"]);
|
|
3268
3216
|
CONTROL_FACT_KEYS2 = /* @__PURE__ */ new Set(["blockers", "destination", "agent-responsibilities", "route", "stage", "state"]);
|
|
@@ -8122,6 +8070,177 @@ var init_appendCompanyIntentDecision = __esm({
|
|
|
8122
8070
|
}
|
|
8123
8071
|
});
|
|
8124
8072
|
|
|
8073
|
+
// src/agent-responsibilityEvidence.ts
|
|
8074
|
+
function agentResponsibilityReportToEvidence(report) {
|
|
8075
|
+
if (report.target.type !== "goal") return null;
|
|
8076
|
+
const evidence = report.evidence ?? {};
|
|
8077
|
+
const values = Object.values(evidence);
|
|
8078
|
+
const status = values.some((value) => value === false) ? "fail" : values.length > 0 || report.facts ? "changed" : "noop";
|
|
8079
|
+
return {
|
|
8080
|
+
version: 1,
|
|
8081
|
+
target: { type: "goal", id: report.target.id },
|
|
8082
|
+
status,
|
|
8083
|
+
summary: "responsibility reported goal evidence",
|
|
8084
|
+
evidence,
|
|
8085
|
+
facts: report.facts ?? {},
|
|
8086
|
+
artifacts: [],
|
|
8087
|
+
missingEvidence: [],
|
|
8088
|
+
blockers: [],
|
|
8089
|
+
sources: ["report"]
|
|
8090
|
+
};
|
|
8091
|
+
}
|
|
8092
|
+
function agentResponsibilityResultToEvidence(result, fallbackGoalId, explicitEvidence) {
|
|
8093
|
+
if (result.target && result.target.type !== "goal") return null;
|
|
8094
|
+
const targetId = result.target?.id ?? fallbackGoalId;
|
|
8095
|
+
if (!targetId) return null;
|
|
8096
|
+
const hasEvidenceValues = Object.keys(result.evidence ?? {}).length > 0;
|
|
8097
|
+
return {
|
|
8098
|
+
version: 1,
|
|
8099
|
+
target: { type: "goal", id: targetId },
|
|
8100
|
+
status: result.status,
|
|
8101
|
+
summary: result.summary,
|
|
8102
|
+
evidence: result.evidence,
|
|
8103
|
+
explicitEvidence: hasEvidenceValues ? void 0 : explicitEvidence,
|
|
8104
|
+
facts: result.facts,
|
|
8105
|
+
artifacts: result.artifacts,
|
|
8106
|
+
missingEvidence: result.missingEvidence,
|
|
8107
|
+
blockers: result.blockers,
|
|
8108
|
+
sources: ["result"]
|
|
8109
|
+
};
|
|
8110
|
+
}
|
|
8111
|
+
function mergeResponsibilityEvidence(items) {
|
|
8112
|
+
const reports = items.filter((item) => item.sources.includes("report") && !item.sources.includes("result"));
|
|
8113
|
+
const results = items.filter((item) => item.sources.includes("result"));
|
|
8114
|
+
const usedReports = /* @__PURE__ */ new Set();
|
|
8115
|
+
const merged = [];
|
|
8116
|
+
for (const result of results) {
|
|
8117
|
+
const reportIndex = reports.findIndex(
|
|
8118
|
+
(report, index) => !usedReports.has(index) && evidenceMatches(report, result, reports)
|
|
8119
|
+
);
|
|
8120
|
+
if (reportIndex >= 0) {
|
|
8121
|
+
usedReports.add(reportIndex);
|
|
8122
|
+
merged.push(mergeReportAndResult(reports[reportIndex], result));
|
|
8123
|
+
} else {
|
|
8124
|
+
merged.push(result);
|
|
8125
|
+
}
|
|
8126
|
+
}
|
|
8127
|
+
for (let i = 0; i < reports.length; i += 1) {
|
|
8128
|
+
if (!usedReports.has(i)) merged.push(reports[i]);
|
|
8129
|
+
}
|
|
8130
|
+
return merged;
|
|
8131
|
+
}
|
|
8132
|
+
function applyAgentResponsibilityEvidenceToGoalState(state, evidence) {
|
|
8133
|
+
const priorFacts = parseFacts3(state.extra.facts) ?? {};
|
|
8134
|
+
const nextFacts = { ...priorFacts };
|
|
8135
|
+
for (const [key, value] of Object.entries(evidence.facts)) {
|
|
8136
|
+
if (CONTROL_FACT_KEYS3.has(key)) continue;
|
|
8137
|
+
nextFacts[key] = value;
|
|
8138
|
+
}
|
|
8139
|
+
for (const [key, value] of Object.entries(evidence.evidence ?? {})) {
|
|
8140
|
+
nextFacts[key] = value;
|
|
8141
|
+
}
|
|
8142
|
+
const pending = typeof nextFacts.pendingEvidence === "string" ? nextFacts.pendingEvidence : "";
|
|
8143
|
+
const hasEvidenceValues = Object.keys(evidence.evidence ?? {}).length > 0;
|
|
8144
|
+
const statusEvidence = evidence.explicitEvidence || (hasEvidenceValues ? "" : pending);
|
|
8145
|
+
const hasPendingEvidenceValue = pending ? Object.hasOwn(evidence.evidence ?? {}, pending) : false;
|
|
8146
|
+
const terminalStatus = evidence.status === "pass" || evidence.status === "fail" || evidence.status === "blocked";
|
|
8147
|
+
if (statusEvidence && !Object.hasOwn(evidence.evidence ?? {}, statusEvidence)) {
|
|
8148
|
+
if (evidence.status === "pass") nextFacts[statusEvidence] = true;
|
|
8149
|
+
if (evidence.status === "fail" || evidence.status === "blocked") nextFacts[statusEvidence] = false;
|
|
8150
|
+
}
|
|
8151
|
+
if (pending && (hasPendingEvidenceValue || statusEvidence === pending && terminalStatus)) {
|
|
8152
|
+
delete nextFacts.pendingEvidence;
|
|
8153
|
+
}
|
|
8154
|
+
const blockers = parseStringArray3(state.extra.blockers) ?? [];
|
|
8155
|
+
const evidenceBlockers = evidence.blockers.length > 0 || evidence.status !== "fail" && evidence.status !== "blocked" ? evidence.blockers : [evidence.summary];
|
|
8156
|
+
for (const blocker of evidenceBlockers) {
|
|
8157
|
+
if (!blockers.includes(blocker)) blockers.push(blocker);
|
|
8158
|
+
}
|
|
8159
|
+
const nextExtra = {
|
|
8160
|
+
...state.extra,
|
|
8161
|
+
facts: nextFacts
|
|
8162
|
+
};
|
|
8163
|
+
if (blockers.length > 0 || Array.isArray(state.extra.blockers)) {
|
|
8164
|
+
nextExtra.blockers = blockers;
|
|
8165
|
+
}
|
|
8166
|
+
return {
|
|
8167
|
+
...state,
|
|
8168
|
+
extra: nextExtra
|
|
8169
|
+
};
|
|
8170
|
+
}
|
|
8171
|
+
function evidenceMatches(report, result, allReports) {
|
|
8172
|
+
if (report.target.id !== result.target.id) return false;
|
|
8173
|
+
if (result.explicitEvidence && Object.hasOwn(report.evidence ?? {}, result.explicitEvidence)) return true;
|
|
8174
|
+
const resultEvidenceKeys = Object.keys(result.evidence ?? {});
|
|
8175
|
+
if (resultEvidenceKeys.length > 0 && resultEvidenceKeys.some((key) => Object.hasOwn(report.evidence ?? {}, key))) {
|
|
8176
|
+
return true;
|
|
8177
|
+
}
|
|
8178
|
+
return !result.explicitEvidence && resultEvidenceKeys.length === 0 && allReports.filter((item) => item.target.id === result.target.id).length === 1;
|
|
8179
|
+
}
|
|
8180
|
+
function mergeReportAndResult(report, result) {
|
|
8181
|
+
return {
|
|
8182
|
+
...result,
|
|
8183
|
+
evidence: mergeOptionalRecords(report.evidence, result.evidence),
|
|
8184
|
+
facts: { ...report.facts, ...result.facts },
|
|
8185
|
+
artifacts: uniqueArtifacts([...report.artifacts, ...result.artifacts]),
|
|
8186
|
+
missingEvidence: uniqueStrings([...report.missingEvidence, ...result.missingEvidence]),
|
|
8187
|
+
blockers: uniqueStrings([...report.blockers, ...result.blockers]),
|
|
8188
|
+
sources: uniqueSources([...report.sources, ...result.sources])
|
|
8189
|
+
};
|
|
8190
|
+
}
|
|
8191
|
+
function mergeOptionalRecords(left, right) {
|
|
8192
|
+
const merged = { ...left ?? {}, ...right ?? {} };
|
|
8193
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
8194
|
+
}
|
|
8195
|
+
function uniqueStrings(values) {
|
|
8196
|
+
return [...new Set(values)].sort();
|
|
8197
|
+
}
|
|
8198
|
+
function uniqueSources(values) {
|
|
8199
|
+
const order = ["report", "result"];
|
|
8200
|
+
const set = new Set(values);
|
|
8201
|
+
return order.filter((source) => set.has(source));
|
|
8202
|
+
}
|
|
8203
|
+
function uniqueArtifacts(artifacts) {
|
|
8204
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8205
|
+
const out = [];
|
|
8206
|
+
for (const artifact of artifacts) {
|
|
8207
|
+
const key = `${artifact.label}
|
|
8208
|
+
${artifact.url ?? ""}
|
|
8209
|
+
${artifact.path ?? ""}`;
|
|
8210
|
+
if (seen.has(key)) continue;
|
|
8211
|
+
seen.add(key);
|
|
8212
|
+
out.push(artifact);
|
|
8213
|
+
}
|
|
8214
|
+
return out;
|
|
8215
|
+
}
|
|
8216
|
+
function parseFacts3(raw) {
|
|
8217
|
+
if (raw === void 0) return {};
|
|
8218
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
8219
|
+
const facts = {};
|
|
8220
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
8221
|
+
if (!key.trim()) return null;
|
|
8222
|
+
if (CONTROL_FACT_KEYS3.has(key)) continue;
|
|
8223
|
+
facts[key] = value;
|
|
8224
|
+
}
|
|
8225
|
+
return facts;
|
|
8226
|
+
}
|
|
8227
|
+
function parseStringArray3(raw) {
|
|
8228
|
+
if (!Array.isArray(raw)) return null;
|
|
8229
|
+
const out = [];
|
|
8230
|
+
for (const item of raw) {
|
|
8231
|
+
if (typeof item !== "string") return null;
|
|
8232
|
+
out.push(item);
|
|
8233
|
+
}
|
|
8234
|
+
return out;
|
|
8235
|
+
}
|
|
8236
|
+
var CONTROL_FACT_KEYS3;
|
|
8237
|
+
var init_agent_responsibilityEvidence = __esm({
|
|
8238
|
+
"src/agent-responsibilityEvidence.ts"() {
|
|
8239
|
+
"use strict";
|
|
8240
|
+
CONTROL_FACT_KEYS3 = /* @__PURE__ */ new Set(["blockers", "destination", "agent-responsibilities", "route", "stage", "state"]);
|
|
8241
|
+
}
|
|
8242
|
+
});
|
|
8243
|
+
|
|
8125
8244
|
// src/scripts/applyAgentResponsibilityReports.ts
|
|
8126
8245
|
function flushLogs(ctx) {
|
|
8127
8246
|
try {
|
|
@@ -8155,13 +8274,24 @@ function collectResults(raw, agentResult) {
|
|
|
8155
8274
|
if (agentResult?.finalText) out.push(...parseAgentResponsibilityResultsFromText(agentResult.finalText));
|
|
8156
8275
|
return out;
|
|
8157
8276
|
}
|
|
8158
|
-
function
|
|
8159
|
-
const
|
|
8277
|
+
function collectGoalResponsibilityEvidence(reports, results, fallbackGoalId, explicitEvidence) {
|
|
8278
|
+
const items = [];
|
|
8160
8279
|
for (const report of reports) {
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8280
|
+
const evidence = agentResponsibilityReportToEvidence(report);
|
|
8281
|
+
if (evidence) items.push(evidence);
|
|
8282
|
+
}
|
|
8283
|
+
for (const result of results) {
|
|
8284
|
+
const evidence = agentResponsibilityResultToEvidence(result, fallbackGoalId, explicitEvidence);
|
|
8285
|
+
if (evidence) items.push(evidence);
|
|
8286
|
+
}
|
|
8287
|
+
return mergeResponsibilityEvidence(items);
|
|
8288
|
+
}
|
|
8289
|
+
function groupGoalEvidence(evidenceItems) {
|
|
8290
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
8291
|
+
for (const evidence of evidenceItems) {
|
|
8292
|
+
const list = grouped.get(evidence.target.id) ?? [];
|
|
8293
|
+
list.push(evidence);
|
|
8294
|
+
grouped.set(evidence.target.id, list);
|
|
8165
8295
|
}
|
|
8166
8296
|
return grouped;
|
|
8167
8297
|
}
|
|
@@ -8178,30 +8308,17 @@ function snapshotFromState(goalId, state) {
|
|
|
8178
8308
|
const managed = managedGoalFromState(state);
|
|
8179
8309
|
return managed ? goalRunLogSnapshot(goalId, state.state, managed) : null;
|
|
8180
8310
|
}
|
|
8181
|
-
function
|
|
8182
|
-
const evidence = report.evidence ?? {};
|
|
8183
|
-
const values = Object.values(evidence);
|
|
8184
|
-
const status = values.some((value) => value === false) ? "fail" : values.length > 0 || report.facts ? "changed" : "noop";
|
|
8185
|
-
return {
|
|
8186
|
-
kind: "report",
|
|
8187
|
-
status,
|
|
8188
|
-
summary: "responsibility reported goal evidence",
|
|
8189
|
-
evidence,
|
|
8190
|
-
facts: report.facts ?? {},
|
|
8191
|
-
artifacts: [],
|
|
8192
|
-
missingEvidence: stringArrayField(goalAfter, "missingEvidence"),
|
|
8193
|
-
blockers: stringArrayField(goalAfter, "blockers")
|
|
8194
|
-
};
|
|
8195
|
-
}
|
|
8196
|
-
function responsibilityResultOutput(result) {
|
|
8311
|
+
function responsibilityEvidenceOutput(evidence) {
|
|
8197
8312
|
return {
|
|
8198
|
-
kind: "
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8313
|
+
kind: "responsibility-evidence",
|
|
8314
|
+
sources: evidence.sources,
|
|
8315
|
+
status: evidence.status,
|
|
8316
|
+
summary: evidence.summary,
|
|
8317
|
+
evidence: evidence.evidence ?? {},
|
|
8318
|
+
facts: evidence.facts,
|
|
8319
|
+
artifacts: evidence.artifacts,
|
|
8320
|
+
missingEvidence: evidence.missingEvidence,
|
|
8321
|
+
blockers: evidence.blockers
|
|
8205
8322
|
};
|
|
8206
8323
|
}
|
|
8207
8324
|
function evidenceInspection(goalBefore, goalAfter, responsibilityOutput, explicitEvidence) {
|
|
@@ -8244,16 +8361,15 @@ function stringArrayField(record2, key) {
|
|
|
8244
8361
|
const value = record2?.[key];
|
|
8245
8362
|
return Array.isArray(value) && value.every((item) => typeof item === "string") ? value : [];
|
|
8246
8363
|
}
|
|
8247
|
-
function describeMessage(goalId,
|
|
8248
|
-
const pieces =
|
|
8249
|
-
if (reports && reports.length > 0) pieces.push(`report=${reports.length}`);
|
|
8250
|
-
if (results.length > 0) pieces.push(`result=${results.map((result) => result.status).join(",")}`);
|
|
8364
|
+
function describeMessage(goalId, evidenceItems) {
|
|
8365
|
+
const pieces = evidenceItems.map((evidence) => `${evidence.sources.join("+")}:${evidence.status}`);
|
|
8251
8366
|
return `Apply agentResponsibility output to ${goalId}${pieces.length > 0 ? ` (${pieces.join("; ")})` : ""}`;
|
|
8252
8367
|
}
|
|
8253
8368
|
var applyAgentResponsibilityReports;
|
|
8254
8369
|
var init_applyAgentResponsibilityReports = __esm({
|
|
8255
8370
|
"src/scripts/applyAgentResponsibilityReports.ts"() {
|
|
8256
8371
|
"use strict";
|
|
8372
|
+
init_agent_responsibilityEvidence();
|
|
8257
8373
|
init_agent_responsibilityReport();
|
|
8258
8374
|
init_agent_responsibilityResult();
|
|
8259
8375
|
init_manager();
|
|
@@ -8264,11 +8380,11 @@ var init_applyAgentResponsibilityReports = __esm({
|
|
|
8264
8380
|
const reports = collectReports(ctx.data.agentResponsibilityReports, agentResult);
|
|
8265
8381
|
const results = collectResults(ctx.data.dutyResults, agentResult);
|
|
8266
8382
|
const resultGoalId = typeof ctx.args.goal === "string" && ctx.args.goal.length > 0 ? ctx.args.goal : null;
|
|
8267
|
-
|
|
8268
|
-
const
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
for (const goalId of
|
|
8383
|
+
const explicitEvidence = typeof ctx.args.evidence === "string" && ctx.args.evidence.length > 0 ? ctx.args.evidence : void 0;
|
|
8384
|
+
const evidenceItems = collectGoalResponsibilityEvidence(reports, results, resultGoalId, explicitEvidence);
|
|
8385
|
+
if (evidenceItems.length === 0) return;
|
|
8386
|
+
const evidenceByGoal = groupGoalEvidence(evidenceItems);
|
|
8387
|
+
for (const [goalId, goalEvidence] of evidenceByGoal) {
|
|
8272
8388
|
const prior = fetchGoalState(ctx.config, goalId, ctx.cwd);
|
|
8273
8389
|
if (!prior) {
|
|
8274
8390
|
stageGoalRunLogEvent(ctx.data, goalId, {
|
|
@@ -8278,8 +8394,9 @@ var init_applyAgentResponsibilityReports = __esm({
|
|
|
8278
8394
|
reason: "goal missing in state repo",
|
|
8279
8395
|
inspection: {
|
|
8280
8396
|
responsibilityOutput: {
|
|
8281
|
-
|
|
8282
|
-
|
|
8397
|
+
kind: "responsibility-evidence",
|
|
8398
|
+
count: goalEvidence.length,
|
|
8399
|
+
items: goalEvidence.map(responsibilityEvidenceOutput)
|
|
8283
8400
|
},
|
|
8284
8401
|
missingEvidence: [],
|
|
8285
8402
|
blockers: ["goal missing in state repo"]
|
|
@@ -8292,54 +8409,32 @@ var init_applyAgentResponsibilityReports = __esm({
|
|
|
8292
8409
|
continue;
|
|
8293
8410
|
}
|
|
8294
8411
|
let next = prior;
|
|
8295
|
-
for (const
|
|
8412
|
+
for (const evidence of goalEvidence) {
|
|
8296
8413
|
const beforeSnapshot = snapshotFromState(goalId, next);
|
|
8297
|
-
next =
|
|
8414
|
+
next = applyAgentResponsibilityEvidenceToGoalState(next, evidence);
|
|
8298
8415
|
const afterSnapshot = snapshotFromState(goalId, next);
|
|
8299
8416
|
const change = goalRunLogChange(beforeSnapshot, afterSnapshot);
|
|
8300
|
-
const output =
|
|
8417
|
+
const output = responsibilityEvidenceOutput(evidence);
|
|
8301
8418
|
stageGoalRunLogEvent(ctx.data, goalId, {
|
|
8302
8419
|
source: "goal-loop",
|
|
8303
8420
|
event: change ? "goal.evidence.applied" : "goal.evidence.unchanged",
|
|
8304
8421
|
goalState: next.state,
|
|
8305
|
-
|
|
8306
|
-
|
|
8422
|
+
evidence: evidence.explicitEvidence,
|
|
8423
|
+
evidenceValues: evidence.evidence,
|
|
8424
|
+
status: evidence.status,
|
|
8425
|
+
reason: evidence.summary,
|
|
8426
|
+
facts: evidence.facts,
|
|
8427
|
+
artifacts: evidence.artifacts,
|
|
8307
8428
|
goal: afterSnapshot ?? void 0,
|
|
8308
|
-
inspection: evidenceInspection(beforeSnapshot, afterSnapshot, output),
|
|
8429
|
+
inspection: evidenceInspection(beforeSnapshot, afterSnapshot, output, evidence.explicitEvidence),
|
|
8309
8430
|
decision: {
|
|
8310
8431
|
...evidenceDecision(change, afterSnapshot, output),
|
|
8311
|
-
evidence:
|
|
8432
|
+
evidence: evidence.explicitEvidence,
|
|
8433
|
+
evidenceValues: evidence.evidence
|
|
8312
8434
|
},
|
|
8313
8435
|
change
|
|
8314
8436
|
});
|
|
8315
8437
|
}
|
|
8316
|
-
if (goalId === resultGoalId) {
|
|
8317
|
-
const evidence = typeof ctx.args.evidence === "string" && ctx.args.evidence.length > 0 ? ctx.args.evidence : void 0;
|
|
8318
|
-
for (const result of results) {
|
|
8319
|
-
const beforeSnapshot = snapshotFromState(goalId, next);
|
|
8320
|
-
next = applyAgentResponsibilityResultToObjectiveState(next, result, evidence);
|
|
8321
|
-
const afterSnapshot = snapshotFromState(goalId, next);
|
|
8322
|
-
const change = goalRunLogChange(beforeSnapshot, afterSnapshot);
|
|
8323
|
-
const output = responsibilityResultOutput(result);
|
|
8324
|
-
stageGoalRunLogEvent(ctx.data, goalId, {
|
|
8325
|
-
source: "goal-loop",
|
|
8326
|
-
event: change ? "goal.evidence.applied" : "goal.evidence.unchanged",
|
|
8327
|
-
goalState: next.state,
|
|
8328
|
-
evidence,
|
|
8329
|
-
status: result.status,
|
|
8330
|
-
reason: result.summary,
|
|
8331
|
-
facts: result.facts,
|
|
8332
|
-
artifacts: result.artifacts,
|
|
8333
|
-
goal: afterSnapshot ?? beforeSnapshot ?? void 0,
|
|
8334
|
-
inspection: evidenceInspection(beforeSnapshot, afterSnapshot, output, evidence),
|
|
8335
|
-
decision: {
|
|
8336
|
-
...evidenceDecision(change, afterSnapshot, output),
|
|
8337
|
-
evidence
|
|
8338
|
-
},
|
|
8339
|
-
change
|
|
8340
|
-
});
|
|
8341
|
-
}
|
|
8342
|
-
}
|
|
8343
8438
|
const beforeCompletionSnapshot = snapshotFromState(goalId, next);
|
|
8344
8439
|
next = completeSatisfiedManagedGoal(next);
|
|
8345
8440
|
const afterCompletionSnapshot = snapshotFromState(goalId, next);
|
|
@@ -8364,13 +8459,7 @@ var init_applyAgentResponsibilityReports = __esm({
|
|
|
8364
8459
|
flushLogs(ctx);
|
|
8365
8460
|
continue;
|
|
8366
8461
|
}
|
|
8367
|
-
putGoalState(
|
|
8368
|
-
ctx.config,
|
|
8369
|
-
goalId,
|
|
8370
|
-
{ ...next, updatedAt: nowIso() },
|
|
8371
|
-
describeMessage(goalId, reportsByGoal.get(goalId), results),
|
|
8372
|
-
ctx.cwd
|
|
8373
|
-
);
|
|
8462
|
+
putGoalState(ctx.config, goalId, { ...next, updatedAt: nowIso() }, describeMessage(goalId, goalEvidence), ctx.cwd);
|
|
8374
8463
|
flushLogs(ctx);
|
|
8375
8464
|
}
|
|
8376
8465
|
};
|
|
@@ -21604,7 +21693,7 @@ async function runnerServe() {
|
|
|
21604
21693
|
init_config();
|
|
21605
21694
|
init_litellm();
|
|
21606
21695
|
import { spawn as spawn9 } from "child_process";
|
|
21607
|
-
function
|
|
21696
|
+
function parseTarget(positional) {
|
|
21608
21697
|
if (!Array.isArray(positional) || positional.length === 0) return "none";
|
|
21609
21698
|
const first = String(positional[0]).toLowerCase();
|
|
21610
21699
|
if (first === "vscode" || first === "code") return "vscode";
|
|
@@ -21619,7 +21708,7 @@ function buildProxyEnv(url) {
|
|
|
21619
21708
|
};
|
|
21620
21709
|
}
|
|
21621
21710
|
async function serve(opts) {
|
|
21622
|
-
const target =
|
|
21711
|
+
const target = parseTarget(opts.args);
|
|
21623
21712
|
const model = parseProviderModel(opts.config.agent.model);
|
|
21624
21713
|
const usesProxy = needsLitellmProxy(model);
|
|
21625
21714
|
let handle = null;
|
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.258",
|
|
4
4
|
"description": "kody — autonomous development engine. Single-session Claude Code agent behind a generic executor + declarative agentAction profiles.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|