Skip to content

Commit 97a1b38

Browse files
authored
Merge pull request #1 from VaiYav/chore/dependency-updates
feat: reconcile roadmap implementation wave
2 parents 5335e1f + fc83acb commit 97a1b38

979 files changed

Lines changed: 112952 additions & 30640 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.agents/skills/swarm/scripts/batching.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,7 @@ function formatValue(value: unknown): string {
169169
* sees a column name as a name, never as template syntax.
170170
*/
171171
function renderTaskBlock(instruction: string): string {
172-
return instruction.replace(
173-
/\{([^}]+)\}/g,
174-
(_m, raw) => `\`${String(raw).trim()}\``,
175-
);
172+
return instruction.replace(/\{([^}]+)\}/g, (_m, raw) => `\`${String(raw).trim()}\``);
176173
}
177174

178175
/**
@@ -185,10 +182,7 @@ function renderTaskBlock(instruction: string): string {
185182
* col1: <value>
186183
* col2: <value>
187184
*/
188-
function renderItemsBlock(
189-
rows: Array<Record<string, unknown>>,
190-
placeholders: string[],
191-
): string {
185+
function renderItemsBlock(rows: Array<Record<string, unknown>>, placeholders: string[]): string {
192186
const lines: string[] = [];
193187

194188
for (const row of rows) {

.agents/skills/swarm/scripts/executor.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ export async function callTask(args: {
3939
mode?: "agent" | "invoke";
4040
}): Promise<string> {
4141
if (typeof tools.swarmTask !== "function") {
42-
throw new Error(
43-
"Swarm requires a 'swarm_task' tool in the PTC configuration.",
44-
);
42+
throw new Error("Swarm requires a 'swarm_task' tool in the PTC configuration.");
4543
}
4644
return tools.swarmTask(args);
4745
}
@@ -148,10 +146,7 @@ export function deduplicateFailures(results: TaskResult[]): FailureGroup[] {
148146
* @param row - The table row to update (mutated in place).
149147
* @param value - The subagent's parsed structured output.
150148
*/
151-
export function mergeResult(
152-
row: Record<string, unknown>,
153-
value: Record<string, unknown>,
154-
): void {
149+
export function mergeResult(row: Record<string, unknown>, value: Record<string, unknown>): void {
155150
for (const [k, v] of Object.entries(value)) {
156151
if (!RESERVED_COLUMNS.has(k)) {
157152
row[k] = v;

.agents/skills/swarm/scripts/filter.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,9 @@ function deepEquals(a: unknown, b: unknown): boolean {
3434
* @param row - The table row to test against.
3535
* @returns `true` if the row matches the filter.
3636
*/
37-
export function evaluateFilter(
38-
filter: SwarmFilter,
39-
row: Record<string, unknown>,
40-
): boolean {
37+
export function evaluateFilter(filter: SwarmFilter, row: Record<string, unknown>): boolean {
4138
if (filter == null || typeof filter !== "object") {
42-
throw new Error(
43-
`evaluateFilter: expected a filter object, got ${JSON.stringify(filter)}`,
44-
);
39+
throw new Error(`evaluateFilter: expected a filter object, got ${JSON.stringify(filter)}`);
4540
}
4641

4742
if ("and" in filter) {

.agents/skills/swarm/scripts/index.ts

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,7 @@ function buildDispatchUnits(
120120
* Single-row units pass through directly. Batch units are unpacked
121121
* into one result per row — missing rows become failures.
122122
*/
123-
function unpackDispatchResults(
124-
units: DispatchUnit[],
125-
results: TaskResult[],
126-
): TaskResult[] {
123+
function unpackDispatchResults(units: DispatchUnit[], results: TaskResult[]): TaskResult[] {
127124
const rowResults: TaskResult[] = [];
128125

129126
for (let idx = 0; idx < units.length; idx++) {
@@ -142,10 +139,7 @@ function unpackDispatchResults(
142139
continue;
143140
}
144141

145-
const { results: unpacked } = unpackBatchResults(
146-
result.result ?? "",
147-
unit.rowIds,
148-
);
142+
const { results: unpacked } = unpackBatchResults(result.result ?? "", unit.rowIds);
149143
for (const rowId of unit.rowIds) {
150144
const value = unpacked.get(rowId);
151145
if (value !== undefined) {
@@ -206,21 +200,14 @@ function mergeRowResults(
206200
* Verify every `{column}` reference in `instruction` resolves on at
207201
* least one matched row. Throws with a list of unresolved paths.
208202
*/
209-
function validatePlaceholders(
210-
instruction: string,
211-
rows: Record<string, unknown>[],
212-
): void {
203+
function validatePlaceholders(instruction: string, rows: Record<string, unknown>[]): void {
213204
const placeholders = extractPlaceholders(instruction);
214205
if (placeholders.length === 0) {
215206
return;
216207
}
217-
const unresolved = placeholders.filter(
218-
(p) => !rows.some((r) => readColumn(r, p) !== undefined),
219-
);
208+
const unresolved = placeholders.filter((p) => !rows.some((r) => readColumn(r, p) !== undefined));
220209
if (unresolved.length > 0) {
221-
throw new Error(
222-
`instruction references unknown column(s): ${unresolved.join(", ")}`,
223-
);
210+
throw new Error(`instruction references unknown column(s): ${unresolved.join(", ")}`);
224211
}
225212
}
226213

@@ -249,26 +236,13 @@ export async function create(source: CreateSource): Promise<SwarmHandle> {
249236
* @param options - Dispatch configuration (instruction, filter, schema, etc.).
250237
* @returns A summary with completion counts and deduplicated failure groups.
251238
*/
252-
export async function run(
253-
tableId: string,
254-
options: RunOptions,
255-
): Promise<RunResult> {
239+
export async function run(tableId: string, options: RunOptions): Promise<RunResult> {
256240
const allRows = await loadTable(tableId);
257-
const {
258-
instruction,
259-
context,
260-
filter,
261-
subagentType,
262-
responseSchema,
263-
batchSize,
264-
concurrency,
265-
} = options;
241+
const { instruction, context, filter, subagentType, responseSchema, batchSize, concurrency } =
242+
options;
266243
const mode = subagentType != null ? "agent" : "invoke";
267244

268-
const effectiveConcurrency = Math.max(
269-
1,
270-
Math.min(concurrency ?? MAX_SUBAGENTS, MAX_SUBAGENTS),
271-
);
245+
const effectiveConcurrency = Math.max(1, Math.min(concurrency ?? MAX_SUBAGENTS, MAX_SUBAGENTS));
272246

273247
// -----------------------------------------------------------------------
274248
// 1. Partition rows into matched (dispatched) and skipped (filtered out)
@@ -329,10 +303,7 @@ export async function run(
329303
}
330304

331305
const rowResults = unpackDispatchResults(units, dispatchResults);
332-
const { completed, failed: mergeFailed } = mergeRowResults(
333-
rowResults,
334-
rowById,
335-
);
306+
const { completed, failed: mergeFailed } = mergeRowResults(rowResults, rowById);
336307
const failed = mergeFailed + interpolationErrors.length;
337308
const allRowResults = [...interpolationErrors, ...rowResults];
338309

.agents/skills/swarm/scripts/interpolate.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ import { readColumn } from "./utils.js";
1717
* @returns The interpolated string with all placeholders resolved.
1818
* @throws Error listing all missing column paths.
1919
*/
20-
export function interpolate(
21-
template: string,
22-
row: Record<string, unknown>,
23-
): string {
20+
export function interpolate(template: string, row: Record<string, unknown>): string {
2421
const missing: string[] = [];
2522

2623
const result = template.replace(/\{([^}]+)\}/g, (_match, rawPath) => {
@@ -44,9 +41,7 @@ export function interpolate(
4441
});
4542

4643
if (missing.length > 0) {
47-
throw new Error(
48-
`Interpolation failed: missing columns: ${missing.join(", ")}`,
49-
);
44+
throw new Error(`Interpolation failed: missing columns: ${missing.join(", ")}`);
5045
}
5146

5247
return result;

.agents/skills/swarm/scripts/table.ts

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,14 @@ export function parseJsonl(content: string): Record<string, unknown>[] {
138138
const parseLine = (line: string, idx: number): Record<string, unknown> => {
139139
try {
140140
const parsed = JSON.parse(line);
141-
if (
142-
typeof parsed !== "object" ||
143-
parsed === null ||
144-
Array.isArray(parsed)
145-
) {
141+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
146142
throw new Error(`expected object`);
147143
}
148144
return parsed as Record<string, unknown>;
149145
} catch (e) {
150-
throw new Error(
151-
`JSONL parse error at line ${idx + 1}: ${(e as Error).message}`,
152-
{ cause: e },
153-
);
146+
throw new Error(`JSONL parse error at line ${idx + 1}: ${(e as Error).message}`, {
147+
cause: e,
148+
});
154149
}
155150
};
156151

@@ -195,9 +190,7 @@ export function extractSeqFromPath(filePath: string): number {
195190
* @param paths - List of file paths.
196191
* @returns Array of `{ id, file }` row objects.
197192
*/
198-
export function pathsToRows(
199-
paths: string[],
200-
): Array<{ id: string; file: string }> {
193+
export function pathsToRows(paths: string[]): Array<{ id: string; file: string }> {
201194
const basenames = paths.map((p) => {
202195
const parts = p.split("/");
203196
return parts[parts.length - 1] || p;
@@ -286,9 +279,7 @@ export async function globFiles(pattern: string): Promise<string[]> {
286279
*/
287280
export async function readFile(path: string): Promise<string> {
288281
if (typeof tools.readFile !== "function") {
289-
throw new Error(
290-
`Swarm requires a 'readFile' tool in the PTC configuration`,
291-
);
282+
throw new Error(`Swarm requires a 'readFile' tool in the PTC configuration`);
292283
}
293284
return tools.readFile({ file_path: path });
294285
}
@@ -315,16 +306,12 @@ export async function writeFile(
315306
previousContent?: string,
316307
): Promise<void> {
317308
if (typeof tools.writeFile !== "function") {
318-
throw new Error(
319-
`Swarm requires a 'writeFile' tool in the PTC configuration`,
320-
);
309+
throw new Error(`Swarm requires a 'writeFile' tool in the PTC configuration`);
321310
}
322311
const result = await tools.writeFile({ file_path: path, content });
323312
if (typeof result === "string" && result.includes("already exists")) {
324313
if (typeof tools.editFile !== "function") {
325-
throw new Error(
326-
"Swarm requires an 'edit_file' PTC tool to update existing tables",
327-
);
314+
throw new Error("Swarm requires an 'edit_file' PTC tool to update existing tables");
328315
}
329316
if (previousContent == null) {
330317
throw new Error(
@@ -438,14 +425,10 @@ async function resolveGlob(pattern: string | string[]): Promise<string[]> {
438425
* @throws Error if the source is invalid, empty, or missing required PTC tools.
439426
*/
440427
export async function createTable(source: CreateSource): Promise<SwarmHandle> {
441-
const sourceCount = [source.glob, source.filePaths, source.tasks].filter(
442-
(s) => s != null,
443-
).length;
428+
const sourceCount = [source.glob, source.filePaths, source.tasks].filter((s) => s != null).length;
444429

445430
if (sourceCount === 0) {
446-
throw new Error(
447-
"create() requires exactly one source: glob, filePaths, or tasks",
448-
);
431+
throw new Error("create() requires exactly one source: glob, filePaths, or tasks");
449432
}
450433

451434
if (sourceCount > 1) {
@@ -510,9 +493,7 @@ export async function createTable(source: CreateSource): Promise<SwarmHandle> {
510493
* @returns The table's row array (by reference — mutations are visible).
511494
* @throws Error if the table is not found (evicted or never created).
512495
*/
513-
export async function loadTable(
514-
id: string,
515-
): Promise<Record<string, unknown>[]> {
496+
export async function loadTable(id: string): Promise<Record<string, unknown>[]> {
516497
const cached = cache.get(id);
517498
if (cached) {
518499
return cached.rows;
@@ -546,10 +527,7 @@ export async function loadTable(
546527
* @param rows - The updated row array to persist.
547528
* @throws Error if the table has not been loaded into cache.
548529
*/
549-
export async function saveTable(
550-
id: string,
551-
rows: Record<string, unknown>[],
552-
): Promise<void> {
530+
export async function saveTable(id: string, rows: Record<string, unknown>[]): Promise<void> {
553531
const cached = cache.get(id);
554532
if (!cached) {
555533
throw new Error(`Table "${id}" is not loaded - call loadTable first`);

.agents/skills/swarm/scripts/types.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ export interface CreateSource {
5656
* the same batch size are grouped together, then chunked into
5757
* batches of that size.
5858
*/
59-
export type BatchFn = (
60-
row: Record<string, unknown>,
61-
rowCount: number,
62-
) => number;
59+
export type BatchFn = (row: Record<string, unknown>, rowCount: number) => number;
6360

6461
/**
6562
* Options for `run()`.

.agents/skills/swarm/scripts/utils.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
* @param path - Dot-separated column path (e.g. `"file"` or `"meta.score"`).
1010
* @returns The resolved value, or `undefined` if the path is invalid.
1111
*/
12-
export function readColumn(
13-
row: Record<string, unknown>,
14-
path: string,
15-
): unknown {
12+
export function readColumn(row: Record<string, unknown>, path: string): unknown {
1613
const segments = path.split(".");
1714

1815
let current = row;

0 commit comments

Comments
 (0)