@@ -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 */
287280export 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 */
440427export 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` ) ;
0 commit comments