@brainervirus/workit-pi 8.15.1 → 8.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/workit.js +65 -2
- package/package.json +1 -1
package/dist/workit.js
CHANGED
|
@@ -16023,6 +16023,58 @@ function evaluateClosure(requestedOutcome, view) {
|
|
|
16023
16023
|
requirementIds: evaluations.map((item) => item.requirementId)
|
|
16024
16024
|
});
|
|
16025
16025
|
}
|
|
16026
|
+
var BRIEF_TEXT = 250;
|
|
16027
|
+
var BRIEF_BLOCKERS = 3;
|
|
16028
|
+
var BRIEF_OPEN = 8;
|
|
16029
|
+
var clip = (value) => {
|
|
16030
|
+
const fits = (text) => Buffer.byteLength(JSON.stringify(text)) <= BRIEF_TEXT;
|
|
16031
|
+
if (fits(value))
|
|
16032
|
+
return value;
|
|
16033
|
+
let length = Math.min(value.length, BRIEF_TEXT);
|
|
16034
|
+
while (length > 0 && !fits(`${value.slice(0, length)}…`))
|
|
16035
|
+
length -= 1;
|
|
16036
|
+
return `${value.slice(0, length)}…`;
|
|
16037
|
+
};
|
|
16038
|
+
function boundTaskSummary(summary) {
|
|
16039
|
+
const rules = new Map((summary.policy?.requirements ?? []).map((item) => [item.id, item]));
|
|
16040
|
+
const unmet = summary.requirements.filter((item) => item.status === "unsatisfied" || item.status === "unavailable");
|
|
16041
|
+
const { progress, closure } = summary;
|
|
16042
|
+
const next = progress.nextAction;
|
|
16043
|
+
const open = unmet.slice(0, BRIEF_OPEN).map((item) => ({
|
|
16044
|
+
dimension: rules.get(item.requirementId)?.dimension ?? "verification",
|
|
16045
|
+
before: rules.get(item.requirementId)?.before ?? "close",
|
|
16046
|
+
status: item.status
|
|
16047
|
+
}));
|
|
16048
|
+
const brief = {
|
|
16049
|
+
id: summary.id,
|
|
16050
|
+
revision: summary.revision,
|
|
16051
|
+
workspaceRevision: summary.workspaceRevision,
|
|
16052
|
+
updatedAt: summary.updatedAt,
|
|
16053
|
+
objective: clip(summary.objective),
|
|
16054
|
+
status: summary.status,
|
|
16055
|
+
closure: closure && {
|
|
16056
|
+
outcome: closure.outcome,
|
|
16057
|
+
at: closure.at,
|
|
16058
|
+
summary: clip(closure.summary)
|
|
16059
|
+
},
|
|
16060
|
+
progress: {
|
|
16061
|
+
summary: clip(progress.summary),
|
|
16062
|
+
nextAction: next && clip(next),
|
|
16063
|
+
blockers: progress.blockers.slice(0, BRIEF_BLOCKERS).map((item) => ({
|
|
16064
|
+
reason: clip(item.reason),
|
|
16065
|
+
dependentAction: clip(item.dependentAction)
|
|
16066
|
+
}))
|
|
16067
|
+
},
|
|
16068
|
+
requirements: { total: summary.requirements.length, unmet: unmet.length, open },
|
|
16069
|
+
truncated: false
|
|
16070
|
+
};
|
|
16071
|
+
brief.truncated = JSON.stringify(brief).includes("…") || progress.blockers.length > BRIEF_BLOCKERS || unmet.length > BRIEF_OPEN;
|
|
16072
|
+
return brief;
|
|
16073
|
+
}
|
|
16074
|
+
function briefInspectResult(request, result) {
|
|
16075
|
+
const { action, view } = request ?? {};
|
|
16076
|
+
return result.ok && action === "inspect" && (view ?? "summary") === "summary" ? { ...result, data: boundTaskSummary(result.data) } : result;
|
|
16077
|
+
}
|
|
16026
16078
|
|
|
16027
16079
|
// packages/workit-core/src/core/methods.ts
|
|
16028
16080
|
var METHODS = {
|
|
@@ -19460,6 +19512,15 @@ class WorkitCore {
|
|
|
19460
19512
|
if (!parsed.ok)
|
|
19461
19513
|
return parsed;
|
|
19462
19514
|
const input = parsed.data;
|
|
19515
|
+
if (this.context.readOnlyChild) {
|
|
19516
|
+
if (input.action !== "inspect")
|
|
19517
|
+
return failure2("permission_denied", "child sessions can only inspect the task summary");
|
|
19518
|
+
const task = this.store.readTask(input.taskId);
|
|
19519
|
+
if (!task.ok)
|
|
19520
|
+
return task;
|
|
19521
|
+
const summary = this.summary(task.data);
|
|
19522
|
+
return summary.ok ? { ...summary, data: boundTaskSummary(summary.data) } : summary;
|
|
19523
|
+
}
|
|
19463
19524
|
if ((this.context.workerId ?? null) !== null) {
|
|
19464
19525
|
if (input.action !== "inspect" && input.action !== "list")
|
|
19465
19526
|
return failure2("permission_denied", "helpers cannot control task lifecycle or scope");
|
|
@@ -23211,9 +23272,11 @@ var executeFamily = async (family, input, ctx) => {
|
|
|
23211
23272
|
const trust = trustedForMutation(ctx, parsed.data.action);
|
|
23212
23273
|
if (!trust.ok)
|
|
23213
23274
|
return output(trust);
|
|
23214
|
-
const
|
|
23275
|
+
const context = piContext(ctx);
|
|
23276
|
+
const core = new WorkitCore(new TaskStore(ctx.cwd), context);
|
|
23215
23277
|
const run = core[family];
|
|
23216
|
-
|
|
23278
|
+
const result = run.call(core, parsed.data);
|
|
23279
|
+
return output(family === "task" && (context.workerId ?? null) !== null ? briefInspectResult(parsed.data, result) : result);
|
|
23217
23280
|
};
|
|
23218
23281
|
var registerWorkitTools = (pi, options = {}) => {
|
|
23219
23282
|
for (const family of OPERATION_FAMILIES)
|