@bastani/atomic 0.9.16-alpha.7 → 0.9.16-alpha.8
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 +19 -0
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/README.md +4 -4
- package/dist/builtin/intercom/broker/broker.ts +617 -22
- package/dist/builtin/intercom/broker/client-message-validation.ts +9 -0
- package/dist/builtin/intercom/broker/client.ts +200 -10
- package/dist/builtin/intercom/broker/pending-send-registry.ts +4 -0
- package/dist/builtin/intercom/broker/send-handler.ts +90 -36
- package/dist/builtin/intercom/broker/send-signature.ts +20 -8
- package/dist/builtin/intercom/group.ts +85 -0
- package/dist/builtin/intercom/index.bundle.mjs +680 -53
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/session-target.ts +54 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +18 -3
- package/dist/builtin/intercom/source-ownership.ts +31 -0
- package/dist/builtin/intercom/types.ts +115 -0
- package/dist/builtin/mcp/index.bundle.mjs +109 -35
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +173 -51
- package/dist/builtin/web-access/index.bundle.mjs +109 -35
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +15 -0
- package/dist/builtin/workflows/README.md +40 -37
- package/dist/builtin/workflows/builtin/adversarial-verification.js +13 -0
- package/dist/builtin/workflows/builtin/{shared-prompts.ts → chunk-0x6e303p.js} +133 -154
- package/dist/builtin/workflows/builtin/chunk-29wrp38a.js +199 -0
- package/dist/builtin/workflows/builtin/chunk-2dqb5s2q.js +602 -0
- package/dist/builtin/workflows/builtin/chunk-4febxsv4.js +264 -0
- package/dist/builtin/workflows/builtin/chunk-5n10x7j2.js +69730 -0
- package/dist/builtin/workflows/builtin/chunk-5wgwscd0.js +4 -0
- package/dist/builtin/workflows/builtin/chunk-6fqs7c01.js +155 -0
- package/dist/builtin/workflows/builtin/chunk-7430zyas.js +126 -0
- package/dist/builtin/workflows/builtin/chunk-7at6dnkr.js +33 -0
- package/dist/builtin/workflows/builtin/chunk-82ha8p41.js +175 -0
- package/dist/builtin/workflows/builtin/chunk-bfkmzv9h.js +156 -0
- package/dist/builtin/workflows/builtin/chunk-c53y8bdh.js +345 -0
- package/dist/builtin/workflows/builtin/chunk-cdtd3m3w.js +529 -0
- package/dist/builtin/workflows/builtin/chunk-cg9tmks0.js +206 -0
- package/dist/builtin/workflows/builtin/chunk-hdpj1dkw.js +2447 -0
- package/dist/builtin/workflows/builtin/chunk-hzzn6adg.js +221 -0
- package/dist/builtin/workflows/builtin/chunk-nqr34qp3.js +1061 -0
- package/dist/builtin/workflows/builtin/chunk-qwzvgxnq.js +404 -0
- package/dist/builtin/workflows/builtin/chunk-qx2ptjs3.js +215 -0
- package/dist/builtin/workflows/builtin/chunk-v04c5qmd.js +1207 -0
- package/dist/builtin/workflows/builtin/chunk-wpckd35c.js +12 -0
- package/dist/builtin/workflows/builtin/chunk-x2ghn0je.js +4110 -0
- package/dist/builtin/workflows/builtin/chunk-zf28603f.js +1080 -0
- package/dist/builtin/workflows/builtin/classify-and-act.js +12 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +10 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.js +12 -0
- package/dist/builtin/workflows/builtin/goal.js +16 -0
- package/dist/builtin/workflows/builtin/index.js +49 -0
- package/dist/builtin/workflows/builtin/loop-until-done.js +12 -0
- package/dist/builtin/workflows/builtin/open-claude-design.js +11 -0
- package/dist/builtin/workflows/builtin/ralph.js +16 -0
- package/dist/builtin/workflows/builtin/steering-context.d.ts +6 -0
- package/dist/builtin/workflows/builtin/steering-context.js +7 -0
- package/dist/builtin/workflows/builtin/tournament.js +13 -0
- package/dist/builtin/workflows/package.json +10 -7
- package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +41 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +1228 -428
- package/dist/builtin/workflows/src/{index.bundle.mjs → index.js} +956 -427
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +403 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +327 -0
- package/dist/builtin/workflows/src/shared/budget.d.ts +67 -0
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +60 -0
- package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.d.ts +21 -0
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +12 -5
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +2 -0
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +2 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +4 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/builtin-install-layout.d.ts +1 -1
- package/dist/core/builtin-install-layout.d.ts.map +1 -1
- package/dist/core/builtin-install-layout.js +1 -1
- package/dist/core/builtin-install-layout.js.map +1 -1
- package/dist/core/codex-fast-mode.d.ts +10 -7
- package/dist/core/codex-fast-mode.d.ts.map +1 -1
- package/dist/core/codex-fast-mode.js +31 -13
- package/dist/core/codex-fast-mode.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +35 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +6 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/model-runtime.d.ts +2 -0
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +4 -0
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +1 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +8 -0
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +5 -5
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-storage.d.ts +2 -0
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +4 -2
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +6 -1
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +8 -9
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +1 -1
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +4 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +69 -10
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +18 -2
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +33 -5
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +8 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +13 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/intercom.md +15 -6
- package/docs/packages.md +2 -2
- package/docs/providers.md +8 -3
- package/docs/quickstart.md +2 -2
- package/docs/rpc.md +21 -4
- package/docs/settings.md +6 -4
- package/docs/subagents.md +1 -1
- package/docs/usage.md +1 -1
- package/docs/workflows.md +108 -239
- package/npm-shrinkwrap.json +32 -32
- package/package.json +9 -13
- package/dist/builtin/workflows/ambient.d.ts +0 -61
- package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +0 -26
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +0 -391
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +0 -34
- package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +0 -108
- package/dist/builtin/workflows/builtin/classify-and-act.ts +0 -40
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +0 -14
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +0 -96
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +0 -37
- package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +0 -41
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +0 -90
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +0 -31
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +0 -64
- package/dist/builtin/workflows/builtin/goal-convergence.ts +0 -87
- package/dist/builtin/workflows/builtin/goal-ledger.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-models.ts +0 -72
- package/dist/builtin/workflows/builtin/goal-orchestrator-prompts.ts +0 -94
- package/dist/builtin/workflows/builtin/goal-prompts.ts +0 -217
- package/dist/builtin/workflows/builtin/goal-reducer.ts +0 -176
- package/dist/builtin/workflows/builtin/goal-reports.ts +0 -76
- package/dist/builtin/workflows/builtin/goal-reverify.ts +0 -305
- package/dist/builtin/workflows/builtin/goal-review.ts +0 -139
- package/dist/builtin/workflows/builtin/goal-runner.ts +0 -504
- package/dist/builtin/workflows/builtin/goal-schemas.ts +0 -89
- package/dist/builtin/workflows/builtin/goal-types.ts +0 -164
- package/dist/builtin/workflows/builtin/goal.ts +0 -78
- package/dist/builtin/workflows/builtin/index.ts +0 -16
- package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +0 -87
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +0 -282
- package/dist/builtin/workflows/builtin/loop-until-done.ts +0 -51
- package/dist/builtin/workflows/builtin/open-claude-design-live-protocol.ts +0 -305
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +0 -337
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +0 -347
- package/dist/builtin/workflows/builtin/open-claude-design-setup.ts +0 -313
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +0 -311
- package/dist/builtin/workflows/builtin/open-claude-design.ts +0 -57
- package/dist/builtin/workflows/builtin/pattern-artifact-root.ts +0 -28
- package/dist/builtin/workflows/builtin/progress-scoring.ts +0 -230
- package/dist/builtin/workflows/builtin/ralph-core.ts +0 -449
- package/dist/builtin/workflows/builtin/ralph-forked-prompts.ts +0 -100
- package/dist/builtin/workflows/builtin/ralph-models.ts +0 -183
- package/dist/builtin/workflows/builtin/ralph-review-gate.ts +0 -103
- package/dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts +0 -104
- package/dist/builtin/workflows/builtin/ralph-runner.ts +0 -459
- package/dist/builtin/workflows/builtin/ralph.ts +0 -82
- package/dist/builtin/workflows/builtin/review-convergence.ts +0 -229
- package/dist/builtin/workflows/builtin/selection-math.ts +0 -156
- package/dist/builtin/workflows/builtin/steering-context.ts +0 -51
- package/dist/builtin/workflows/builtin/tournament-prompts.ts +0 -70
- package/dist/builtin/workflows/builtin/tournament-runner.ts +0 -400
- package/dist/builtin/workflows/builtin/tournament.ts +0 -73
- package/dist/builtin/workflows/builtin/verification-criteria.ts +0 -330
- package/dist/builtin/workflows/builtin/verification-prompts.ts +0 -206
- package/dist/builtin/workflows/builtin/verification-usage.ts +0 -44
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import {
|
|
2
|
+
build_scoring_prompt,
|
|
3
|
+
scoring_prompt_reads
|
|
4
|
+
} from "./chunk-7430zyas.js";
|
|
5
|
+
import {
|
|
6
|
+
stableArtifactRoot
|
|
7
|
+
} from "./chunk-wpckd35c.js";
|
|
8
|
+
import {
|
|
9
|
+
workflow
|
|
10
|
+
} from "./chunk-bfkmzv9h.js";
|
|
11
|
+
import {
|
|
12
|
+
withSteeringPropagationContext
|
|
13
|
+
} from "./chunk-0x6e303p.js";
|
|
14
|
+
|
|
15
|
+
// dist/builtin/workflows/builtin/generate-and-filter.ts
|
|
16
|
+
import { Type as Type2 } from "typebox";
|
|
17
|
+
|
|
18
|
+
// dist/builtin/workflows/builtin/generate-and-filter-runner.ts
|
|
19
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
20
|
+
import { join } from "node:path";
|
|
21
|
+
import { Type } from "typebox";
|
|
22
|
+
|
|
23
|
+
// dist/builtin/workflows/builtin/generate-and-filter-prompts.ts
|
|
24
|
+
var GROUNDED_REPORTING = "Before reporting progress, audit each claim against a tool result from this session. Report only work you can point to evidence for; say so explicitly when something is unverified.";
|
|
25
|
+
var READABLE_REPORT = "Lead with the outcome. Keep facts, decisions, caveats, and next steps; drop background and repetition. Use complete, readable sentences rather than compressed fragments.";
|
|
26
|
+
function renderGeneratorPrompt(task, ordinal) {
|
|
27
|
+
return `<role>
|
|
28
|
+
You independently generate candidate ${ordinal}; do not imitate or assume other candidates.
|
|
29
|
+
</role>
|
|
30
|
+
|
|
31
|
+
<success_criteria>
|
|
32
|
+
One distinct, concrete candidate states its value, constraints, risks, and how it can be evaluated.
|
|
33
|
+
</success_criteria>
|
|
34
|
+
|
|
35
|
+
<stop_rules>
|
|
36
|
+
Stop after one self-contained, evaluable candidate; do not add alternatives.
|
|
37
|
+
</stop_rules>
|
|
38
|
+
|
|
39
|
+
<output_format>
|
|
40
|
+
A candidate artifact with title, proposal, criteria-based rationale, risks, and evaluation evidence. ${READABLE_REPORT}
|
|
41
|
+
${GROUNDED_REPORTING}
|
|
42
|
+
</output_format>
|
|
43
|
+
|
|
44
|
+
<objective>
|
|
45
|
+
${task}
|
|
46
|
+
</objective>`;
|
|
47
|
+
}
|
|
48
|
+
function renderFilterPrompt(task, candidatePaths, shortlistSize) {
|
|
49
|
+
return `<artifacts>
|
|
50
|
+
Read every candidate: ${candidatePaths.join(", ")}
|
|
51
|
+
</artifacts>
|
|
52
|
+
|
|
53
|
+
<role>
|
|
54
|
+
You deduplicate and filter independently generated candidates.
|
|
55
|
+
</role>
|
|
56
|
+
|
|
57
|
+
<rubric>
|
|
58
|
+
First collapse substantively equivalent candidates. Then score fit to the task, feasibility, evidence, distinctiveness, and risk. Near-duplicates must not gain weight by repetition. Record every discarded candidate and a concrete reason.
|
|
59
|
+
</rubric>
|
|
60
|
+
|
|
61
|
+
<success_criteria>
|
|
62
|
+
At most ${shortlistSize} strongest distinct candidates remain, ranked by the rubric, and every discarded candidate has a concrete reason.
|
|
63
|
+
</success_criteria>
|
|
64
|
+
|
|
65
|
+
<stop_rules>
|
|
66
|
+
Stop after every candidate is shortlisted once or recorded as discarded.
|
|
67
|
+
</stop_rules>
|
|
68
|
+
|
|
69
|
+
<output_format>
|
|
70
|
+
Call structured_output with shortlist (candidate artifact paths in ranked order) and discarded entries containing path and a concise, criteria-based reason.
|
|
71
|
+
</output_format>
|
|
72
|
+
|
|
73
|
+
<objective>
|
|
74
|
+
Select at most ${shortlistSize} strongest candidates for: ${task}
|
|
75
|
+
</objective>`;
|
|
76
|
+
}
|
|
77
|
+
function renderJudgePrompt(task, filterPath, shortlistSize, candidates = []) {
|
|
78
|
+
const head = {
|
|
79
|
+
task: `Rank at most ${shortlistSize} distinct candidate paths for: ${task}.`,
|
|
80
|
+
groundTruthNote: `Read the filter report at ${filterPath} and every candidate path it references before judging.`,
|
|
81
|
+
candidates,
|
|
82
|
+
outputFormat: "Call structured_output with shortlist (candidate paths in ranked order) and rationale (a concise, criteria-based explanation)."
|
|
83
|
+
};
|
|
84
|
+
const prompt = build_scoring_prompt(head, {
|
|
85
|
+
id: "filtered_shortlist",
|
|
86
|
+
name: "Filtered shortlist",
|
|
87
|
+
description: "Check task fit, feasibility, evidence, distinctiveness, and material risk; do not restore a duplicate merely because it is phrased differently."
|
|
88
|
+
});
|
|
89
|
+
return { prompt, reads: [filterPath, ...scoring_prompt_reads(head)] };
|
|
90
|
+
}
|
|
91
|
+
function renderFinalShortlistPrompt(task, decisionPath) {
|
|
92
|
+
return `<artifact>
|
|
93
|
+
Read the authoritative selection at ${decisionPath}; follow its order and do not add candidates.
|
|
94
|
+
</artifact>
|
|
95
|
+
|
|
96
|
+
<role>
|
|
97
|
+
You present a concise, actionable final shortlist so the reader can choose the next evaluation without reading the selection session.
|
|
98
|
+
</role>
|
|
99
|
+
|
|
100
|
+
<success_criteria>
|
|
101
|
+
Every selected candidate appears once in authoritative order with its differentiator, evidence, tradeoffs, and recommended next evaluation.
|
|
102
|
+
</success_criteria>
|
|
103
|
+
|
|
104
|
+
<stop_rules>
|
|
105
|
+
Stop after presenting every selected candidate once; do not add or reorder candidates.
|
|
106
|
+
</stop_rules>
|
|
107
|
+
|
|
108
|
+
<output_format>
|
|
109
|
+
Ranked markdown shortlist with candidate path, differentiator, evidence, tradeoffs, and recommended next evaluation. ${READABLE_REPORT}
|
|
110
|
+
${GROUNDED_REPORTING}
|
|
111
|
+
</output_format>
|
|
112
|
+
|
|
113
|
+
<objective>
|
|
114
|
+
Summarize the selected candidates for: ${task}
|
|
115
|
+
</objective>`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// dist/builtin/workflows/builtin/generate-and-filter-runner.ts
|
|
119
|
+
var filterSchema = Type.Object({
|
|
120
|
+
shortlist: Type.Array(Type.String()),
|
|
121
|
+
discarded: Type.Array(Type.Object({ path: Type.String(), reason: Type.String() }, { additionalProperties: false }))
|
|
122
|
+
}, { additionalProperties: false });
|
|
123
|
+
var judgeSchema = Type.Object({ shortlist: Type.Array(Type.String()), rationale: Type.String() }, { additionalProperties: false });
|
|
124
|
+
function isRecord(value) {
|
|
125
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
126
|
+
}
|
|
127
|
+
function strings(value) {
|
|
128
|
+
return Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
129
|
+
}
|
|
130
|
+
function filterDecision(value) {
|
|
131
|
+
if (value === undefined || !isRecord(value) || !strings(value.shortlist) || !Array.isArray(value.discarded))
|
|
132
|
+
return;
|
|
133
|
+
const valid = value.discarded.every((entry) => isRecord(entry) && typeof entry.path === "string" && typeof entry.reason === "string");
|
|
134
|
+
return valid ? value : undefined;
|
|
135
|
+
}
|
|
136
|
+
function judgeDecision(value) {
|
|
137
|
+
return value !== undefined && isRecord(value) && strings(value.shortlist) && typeof value.rationale === "string" ? value : undefined;
|
|
138
|
+
}
|
|
139
|
+
async function runGenerateAndFilter(ctx) {
|
|
140
|
+
const root = await stableArtifactRoot(ctx, "generate-and-filter");
|
|
141
|
+
const candidatePaths = Array.from({ length: ctx.inputs.num_candidates }, (_, index) => join(root, `candidate-${index + 1}.md`));
|
|
142
|
+
const shortlistLimit = Math.min(ctx.inputs.shortlist_size, ctx.inputs.num_candidates);
|
|
143
|
+
await ctx.parallel(candidatePaths.map((path, index) => ({
|
|
144
|
+
name: `generate-${index + 1}`,
|
|
145
|
+
prompt: renderGeneratorPrompt(ctx.inputs.prompt, index + 1),
|
|
146
|
+
context: "fresh",
|
|
147
|
+
output: path,
|
|
148
|
+
outputMode: "file-only"
|
|
149
|
+
})), { concurrency: ctx.inputs.max_concurrency, failFast: false });
|
|
150
|
+
const manifestPath = join(root, "manifest.json");
|
|
151
|
+
await writeFile(manifestPath, JSON.stringify({ task: ctx.inputs.prompt, candidate_artifact_paths: candidatePaths }, null, 2));
|
|
152
|
+
const filterPath = join(root, "filter.json");
|
|
153
|
+
const filtered = await ctx.task("dedupe-and-filter", {
|
|
154
|
+
prompt: renderFilterPrompt(ctx.inputs.prompt, candidatePaths, shortlistLimit),
|
|
155
|
+
context: "fresh",
|
|
156
|
+
reads: [manifestPath, ...candidatePaths],
|
|
157
|
+
schema: filterSchema
|
|
158
|
+
});
|
|
159
|
+
const filteredDecision = filterDecision(filtered.structured);
|
|
160
|
+
await writeFile(filterPath, `${JSON.stringify(filteredDecision ?? { shortlist: [], discarded: [] }, null, 2)}
|
|
161
|
+
`);
|
|
162
|
+
const selectCandidates = (paths) => [...new Set(paths.filter((path) => candidatePaths.includes(path)))].slice(0, shortlistLimit);
|
|
163
|
+
const fallbackShortlist = candidatePaths.slice(0, shortlistLimit);
|
|
164
|
+
const filteredShortlist = selectCandidates(filteredDecision?.shortlist ?? []);
|
|
165
|
+
let shortlist = filteredShortlist.length > 0 ? filteredShortlist : fallbackShortlist;
|
|
166
|
+
let judgePath = null;
|
|
167
|
+
let decisionPath = filterPath;
|
|
168
|
+
if (ctx.inputs.use_judge) {
|
|
169
|
+
judgePath = join(root, "judge.json");
|
|
170
|
+
const judgeCandidates = await Promise.all(shortlist.map(async (path) => ({ path, body: await readFile(path, "utf8") })));
|
|
171
|
+
const judgePrompt = renderJudgePrompt(ctx.inputs.prompt, filterPath, shortlistLimit, judgeCandidates);
|
|
172
|
+
const judged = await ctx.task("judge", {
|
|
173
|
+
prompt: judgePrompt.prompt,
|
|
174
|
+
context: "fresh",
|
|
175
|
+
reads: judgePrompt.reads,
|
|
176
|
+
schema: judgeSchema
|
|
177
|
+
});
|
|
178
|
+
const judgedDecision = judgeDecision(judged.structured);
|
|
179
|
+
await writeFile(judgePath, `${JSON.stringify(judgedDecision ?? { shortlist: [], rationale: "Judge stage produced no valid structured decision." }, null, 2)}
|
|
180
|
+
`);
|
|
181
|
+
const judgedShortlist = selectCandidates(judgedDecision?.shortlist ?? []);
|
|
182
|
+
shortlist = judgedShortlist.length > 0 ? judgedShortlist : shortlist;
|
|
183
|
+
decisionPath = judgePath;
|
|
184
|
+
}
|
|
185
|
+
const finalPath = join(root, "shortlist.md");
|
|
186
|
+
const finalShortlist = await ctx.task("final-shortlist", {
|
|
187
|
+
prompt: renderFinalShortlistPrompt(ctx.inputs.prompt, decisionPath),
|
|
188
|
+
context: "fresh",
|
|
189
|
+
reads: [decisionPath, ...shortlist],
|
|
190
|
+
output: finalPath,
|
|
191
|
+
outputMode: "file-only"
|
|
192
|
+
});
|
|
193
|
+
return { result: finalShortlist.text, shortlist, candidate_artifact_paths: candidatePaths, filter_path: filterPath, judge_path: judgePath, final_path: finalPath, artifact_dir: root, manifest_path: manifestPath };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// dist/builtin/workflows/builtin/generate-and-filter.ts
|
|
197
|
+
var generate_and_filter_default = workflow({
|
|
198
|
+
name: "generate-and-filter",
|
|
199
|
+
description: "Generate more independent candidates than needed, deduplicate and filter them by rubric, optionally judge them, and return a parent-consumable shortlist.",
|
|
200
|
+
heartbeatIntervalMinutes: 15,
|
|
201
|
+
inputs: {
|
|
202
|
+
prompt: Type2.String({ description: "Prompt for candidate generation and selection." }),
|
|
203
|
+
num_candidates: Type2.Integer({ minimum: 2, maximum: 20, default: 8, description: "Number of independent candidates to generate." }),
|
|
204
|
+
shortlist_size: Type2.Integer({ minimum: 1, maximum: 10, default: 3, description: "Maximum number of candidates in the final shortlist." }),
|
|
205
|
+
use_judge: Type2.Boolean({ default: true, description: "Whether an independent judge reviews the filtered shortlist." }),
|
|
206
|
+
max_concurrency: Type2.Integer({ minimum: 1, maximum: 12, default: 4, description: "Maximum simultaneous generator stages." })
|
|
207
|
+
},
|
|
208
|
+
outputs: {
|
|
209
|
+
result: Type2.String({ description: "Compact reference to the final shortlist report artifact; read `final_path` for the full report." }),
|
|
210
|
+
shortlist: Type2.Array(Type2.String(), { description: "Ranked paths to selected candidate artifacts." }),
|
|
211
|
+
candidate_artifact_paths: Type2.Array(Type2.String(), { description: "Paths to every generated candidate artifact." }),
|
|
212
|
+
filter_path: Type2.String({ description: "Path to the dedupe and filter decision." }),
|
|
213
|
+
judge_path: Type2.Union([Type2.String(), Type2.Null()], { description: "Path to the optional judge decision, or null when disabled." }),
|
|
214
|
+
final_path: Type2.String({ description: "Path to the final shortlist report." }),
|
|
215
|
+
artifact_dir: Type2.String({ description: "Directory containing run artifacts." }),
|
|
216
|
+
manifest_path: Type2.String({ description: "Path to the candidate artifact manifest." })
|
|
217
|
+
},
|
|
218
|
+
run: async (ctx) => await runGenerateAndFilter(withSteeringPropagationContext(ctx))
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
export { generate_and_filter_default };
|