@clicksmith/core 0.1.0 → 0.1.1
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/index.d.ts +452 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2226,6 +2226,457 @@ interface SubmitResponse {
|
|
|
2226
2226
|
runId: string;
|
|
2227
2227
|
bundle: CaptureBundle;
|
|
2228
2228
|
}
|
|
2229
|
+
/** One-shot fast path: send all captured elements + prompt in a single request. */
|
|
2230
|
+
declare const RunRequestSchema: z.ZodObject<{
|
|
2231
|
+
app: z.ZodObject<{
|
|
2232
|
+
url: z.ZodString;
|
|
2233
|
+
route: z.ZodString;
|
|
2234
|
+
page: z.ZodOptional<z.ZodString>;
|
|
2235
|
+
}, "strip", z.ZodTypeAny, {
|
|
2236
|
+
url: string;
|
|
2237
|
+
route: string;
|
|
2238
|
+
page?: string | undefined;
|
|
2239
|
+
}, {
|
|
2240
|
+
url: string;
|
|
2241
|
+
route: string;
|
|
2242
|
+
page?: string | undefined;
|
|
2243
|
+
}>;
|
|
2244
|
+
elements: z.ZodArray<z.ZodObject<Omit<{
|
|
2245
|
+
id: z.ZodNumber;
|
|
2246
|
+
ts: z.ZodString;
|
|
2247
|
+
locator: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
2248
|
+
kind: z.ZodLiteral<"source">;
|
|
2249
|
+
file: z.ZodString;
|
|
2250
|
+
line: z.ZodNumber;
|
|
2251
|
+
column: z.ZodOptional<z.ZodNumber>;
|
|
2252
|
+
export: z.ZodOptional<z.ZodString>;
|
|
2253
|
+
}, "strip", z.ZodTypeAny, {
|
|
2254
|
+
kind: "source";
|
|
2255
|
+
file: string;
|
|
2256
|
+
line: number;
|
|
2257
|
+
column?: number | undefined;
|
|
2258
|
+
export?: string | undefined;
|
|
2259
|
+
}, {
|
|
2260
|
+
kind: "source";
|
|
2261
|
+
file: string;
|
|
2262
|
+
line: number;
|
|
2263
|
+
column?: number | undefined;
|
|
2264
|
+
export?: string | undefined;
|
|
2265
|
+
}>, z.ZodObject<{
|
|
2266
|
+
kind: z.ZodLiteral<"attr">;
|
|
2267
|
+
attr: z.ZodString;
|
|
2268
|
+
value: z.ZodString;
|
|
2269
|
+
selector: z.ZodString;
|
|
2270
|
+
}, "strip", z.ZodTypeAny, {
|
|
2271
|
+
kind: "attr";
|
|
2272
|
+
value: string;
|
|
2273
|
+
attr: string;
|
|
2274
|
+
selector: string;
|
|
2275
|
+
}, {
|
|
2276
|
+
kind: "attr";
|
|
2277
|
+
value: string;
|
|
2278
|
+
attr: string;
|
|
2279
|
+
selector: string;
|
|
2280
|
+
}>, z.ZodObject<{
|
|
2281
|
+
kind: z.ZodLiteral<"behavioral">;
|
|
2282
|
+
role: z.ZodString;
|
|
2283
|
+
name: z.ZodString;
|
|
2284
|
+
nth: z.ZodOptional<z.ZodNumber>;
|
|
2285
|
+
}, "strip", z.ZodTypeAny, {
|
|
2286
|
+
kind: "behavioral";
|
|
2287
|
+
role: string;
|
|
2288
|
+
name: string;
|
|
2289
|
+
nth?: number | undefined;
|
|
2290
|
+
}, {
|
|
2291
|
+
kind: "behavioral";
|
|
2292
|
+
role: string;
|
|
2293
|
+
name: string;
|
|
2294
|
+
nth?: number | undefined;
|
|
2295
|
+
}>, z.ZodObject<{
|
|
2296
|
+
kind: z.ZodLiteral<"dom">;
|
|
2297
|
+
selector: z.ZodString;
|
|
2298
|
+
fingerprint: z.ZodString;
|
|
2299
|
+
}, "strip", z.ZodTypeAny, {
|
|
2300
|
+
kind: "dom";
|
|
2301
|
+
selector: string;
|
|
2302
|
+
fingerprint: string;
|
|
2303
|
+
}, {
|
|
2304
|
+
kind: "dom";
|
|
2305
|
+
selector: string;
|
|
2306
|
+
fingerprint: string;
|
|
2307
|
+
}>]>;
|
|
2308
|
+
el: z.ZodObject<{
|
|
2309
|
+
tag: z.ZodString;
|
|
2310
|
+
text: z.ZodOptional<z.ZodString>;
|
|
2311
|
+
role: z.ZodOptional<z.ZodString>;
|
|
2312
|
+
label: z.ZodOptional<z.ZodString>;
|
|
2313
|
+
attrs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2314
|
+
iconHints: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2315
|
+
}, "strip", z.ZodTypeAny, {
|
|
2316
|
+
tag: string;
|
|
2317
|
+
attrs: Record<string, string>;
|
|
2318
|
+
role?: string | undefined;
|
|
2319
|
+
text?: string | undefined;
|
|
2320
|
+
label?: string | undefined;
|
|
2321
|
+
iconHints?: string[] | undefined;
|
|
2322
|
+
}, {
|
|
2323
|
+
tag: string;
|
|
2324
|
+
role?: string | undefined;
|
|
2325
|
+
text?: string | undefined;
|
|
2326
|
+
label?: string | undefined;
|
|
2327
|
+
attrs?: Record<string, string> | undefined;
|
|
2328
|
+
iconHints?: string[] | undefined;
|
|
2329
|
+
}>;
|
|
2330
|
+
near: z.ZodDefault<z.ZodObject<{
|
|
2331
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2332
|
+
headings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2333
|
+
landmarks: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2334
|
+
parentText: z.ZodOptional<z.ZodString>;
|
|
2335
|
+
}, "strip", z.ZodTypeAny, {
|
|
2336
|
+
labels?: string[] | undefined;
|
|
2337
|
+
headings?: string[] | undefined;
|
|
2338
|
+
landmarks?: string[] | undefined;
|
|
2339
|
+
parentText?: string | undefined;
|
|
2340
|
+
}, {
|
|
2341
|
+
labels?: string[] | undefined;
|
|
2342
|
+
headings?: string[] | undefined;
|
|
2343
|
+
landmarks?: string[] | undefined;
|
|
2344
|
+
parentText?: string | undefined;
|
|
2345
|
+
}>>;
|
|
2346
|
+
conditions: z.ZodObject<{
|
|
2347
|
+
viewport: z.ZodObject<{
|
|
2348
|
+
w: z.ZodNumber;
|
|
2349
|
+
h: z.ZodNumber;
|
|
2350
|
+
}, "strip", z.ZodTypeAny, {
|
|
2351
|
+
w: number;
|
|
2352
|
+
h: number;
|
|
2353
|
+
}, {
|
|
2354
|
+
w: number;
|
|
2355
|
+
h: number;
|
|
2356
|
+
}>;
|
|
2357
|
+
theme: z.ZodOptional<z.ZodEnum<["light", "dark"]>>;
|
|
2358
|
+
mediaQueries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
|
|
2359
|
+
}, "strip", z.ZodTypeAny, {
|
|
2360
|
+
viewport: {
|
|
2361
|
+
w: number;
|
|
2362
|
+
h: number;
|
|
2363
|
+
};
|
|
2364
|
+
theme?: "light" | "dark" | undefined;
|
|
2365
|
+
mediaQueries?: Record<string, boolean> | undefined;
|
|
2366
|
+
}, {
|
|
2367
|
+
viewport: {
|
|
2368
|
+
w: number;
|
|
2369
|
+
h: number;
|
|
2370
|
+
};
|
|
2371
|
+
theme?: "light" | "dark" | undefined;
|
|
2372
|
+
mediaQueries?: Record<string, boolean> | undefined;
|
|
2373
|
+
}>;
|
|
2374
|
+
screenshot: z.ZodOptional<z.ZodString>;
|
|
2375
|
+
frameworkHints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2376
|
+
}, "id">, "strip", z.ZodTypeAny, {
|
|
2377
|
+
ts: string;
|
|
2378
|
+
locator: {
|
|
2379
|
+
kind: "source";
|
|
2380
|
+
file: string;
|
|
2381
|
+
line: number;
|
|
2382
|
+
column?: number | undefined;
|
|
2383
|
+
export?: string | undefined;
|
|
2384
|
+
} | {
|
|
2385
|
+
kind: "attr";
|
|
2386
|
+
value: string;
|
|
2387
|
+
attr: string;
|
|
2388
|
+
selector: string;
|
|
2389
|
+
} | {
|
|
2390
|
+
kind: "behavioral";
|
|
2391
|
+
role: string;
|
|
2392
|
+
name: string;
|
|
2393
|
+
nth?: number | undefined;
|
|
2394
|
+
} | {
|
|
2395
|
+
kind: "dom";
|
|
2396
|
+
selector: string;
|
|
2397
|
+
fingerprint: string;
|
|
2398
|
+
};
|
|
2399
|
+
el: {
|
|
2400
|
+
tag: string;
|
|
2401
|
+
attrs: Record<string, string>;
|
|
2402
|
+
role?: string | undefined;
|
|
2403
|
+
text?: string | undefined;
|
|
2404
|
+
label?: string | undefined;
|
|
2405
|
+
iconHints?: string[] | undefined;
|
|
2406
|
+
};
|
|
2407
|
+
near: {
|
|
2408
|
+
labels?: string[] | undefined;
|
|
2409
|
+
headings?: string[] | undefined;
|
|
2410
|
+
landmarks?: string[] | undefined;
|
|
2411
|
+
parentText?: string | undefined;
|
|
2412
|
+
};
|
|
2413
|
+
conditions: {
|
|
2414
|
+
viewport: {
|
|
2415
|
+
w: number;
|
|
2416
|
+
h: number;
|
|
2417
|
+
};
|
|
2418
|
+
theme?: "light" | "dark" | undefined;
|
|
2419
|
+
mediaQueries?: Record<string, boolean> | undefined;
|
|
2420
|
+
};
|
|
2421
|
+
screenshot?: string | undefined;
|
|
2422
|
+
frameworkHints?: Record<string, unknown> | undefined;
|
|
2423
|
+
}, {
|
|
2424
|
+
ts: string;
|
|
2425
|
+
locator: {
|
|
2426
|
+
kind: "source";
|
|
2427
|
+
file: string;
|
|
2428
|
+
line: number;
|
|
2429
|
+
column?: number | undefined;
|
|
2430
|
+
export?: string | undefined;
|
|
2431
|
+
} | {
|
|
2432
|
+
kind: "attr";
|
|
2433
|
+
value: string;
|
|
2434
|
+
attr: string;
|
|
2435
|
+
selector: string;
|
|
2436
|
+
} | {
|
|
2437
|
+
kind: "behavioral";
|
|
2438
|
+
role: string;
|
|
2439
|
+
name: string;
|
|
2440
|
+
nth?: number | undefined;
|
|
2441
|
+
} | {
|
|
2442
|
+
kind: "dom";
|
|
2443
|
+
selector: string;
|
|
2444
|
+
fingerprint: string;
|
|
2445
|
+
};
|
|
2446
|
+
el: {
|
|
2447
|
+
tag: string;
|
|
2448
|
+
role?: string | undefined;
|
|
2449
|
+
text?: string | undefined;
|
|
2450
|
+
label?: string | undefined;
|
|
2451
|
+
attrs?: Record<string, string> | undefined;
|
|
2452
|
+
iconHints?: string[] | undefined;
|
|
2453
|
+
};
|
|
2454
|
+
conditions: {
|
|
2455
|
+
viewport: {
|
|
2456
|
+
w: number;
|
|
2457
|
+
h: number;
|
|
2458
|
+
};
|
|
2459
|
+
theme?: "light" | "dark" | undefined;
|
|
2460
|
+
mediaQueries?: Record<string, boolean> | undefined;
|
|
2461
|
+
};
|
|
2462
|
+
near?: {
|
|
2463
|
+
labels?: string[] | undefined;
|
|
2464
|
+
headings?: string[] | undefined;
|
|
2465
|
+
landmarks?: string[] | undefined;
|
|
2466
|
+
parentText?: string | undefined;
|
|
2467
|
+
} | undefined;
|
|
2468
|
+
screenshot?: string | undefined;
|
|
2469
|
+
frameworkHints?: Record<string, unknown> | undefined;
|
|
2470
|
+
}>, "many">;
|
|
2471
|
+
prompt: z.ZodString;
|
|
2472
|
+
execution: z.ZodOptional<z.ZodObject<{
|
|
2473
|
+
mode: z.ZodOptional<z.ZodDefault<z.ZodEnum<["plan", "edit"]>>>;
|
|
2474
|
+
isolation: z.ZodOptional<z.ZodDefault<z.ZodEnum<["worktree", "branch", "inplace"]>>>;
|
|
2475
|
+
autoApply: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
2476
|
+
agentId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2477
|
+
baseRef: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2478
|
+
}, "strip", z.ZodTypeAny, {
|
|
2479
|
+
mode?: "plan" | "edit" | undefined;
|
|
2480
|
+
isolation?: "worktree" | "branch" | "inplace" | undefined;
|
|
2481
|
+
autoApply?: boolean | undefined;
|
|
2482
|
+
agentId?: string | undefined;
|
|
2483
|
+
baseRef?: string | undefined;
|
|
2484
|
+
}, {
|
|
2485
|
+
mode?: "plan" | "edit" | undefined;
|
|
2486
|
+
isolation?: "worktree" | "branch" | "inplace" | undefined;
|
|
2487
|
+
autoApply?: boolean | undefined;
|
|
2488
|
+
agentId?: string | undefined;
|
|
2489
|
+
baseRef?: string | undefined;
|
|
2490
|
+
}>>;
|
|
2491
|
+
enrichment: z.ZodOptional<z.ZodObject<{
|
|
2492
|
+
source: z.ZodLiteral<"code-review-graph">;
|
|
2493
|
+
perElement: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
2494
|
+
elementId: z.ZodNumber;
|
|
2495
|
+
reviewContext: z.ZodOptional<z.ZodString>;
|
|
2496
|
+
impactRadius: z.ZodOptional<z.ZodUnknown>;
|
|
2497
|
+
affectedFlows: z.ZodOptional<z.ZodUnknown>;
|
|
2498
|
+
}, "strip", z.ZodTypeAny, {
|
|
2499
|
+
elementId: number;
|
|
2500
|
+
reviewContext?: string | undefined;
|
|
2501
|
+
impactRadius?: unknown;
|
|
2502
|
+
affectedFlows?: unknown;
|
|
2503
|
+
}, {
|
|
2504
|
+
elementId: number;
|
|
2505
|
+
reviewContext?: string | undefined;
|
|
2506
|
+
impactRadius?: unknown;
|
|
2507
|
+
affectedFlows?: unknown;
|
|
2508
|
+
}>, "many">>;
|
|
2509
|
+
warnings: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
2510
|
+
}, "strip", z.ZodTypeAny, {
|
|
2511
|
+
source: "code-review-graph";
|
|
2512
|
+
perElement: {
|
|
2513
|
+
elementId: number;
|
|
2514
|
+
reviewContext?: string | undefined;
|
|
2515
|
+
impactRadius?: unknown;
|
|
2516
|
+
affectedFlows?: unknown;
|
|
2517
|
+
}[];
|
|
2518
|
+
warnings: string[];
|
|
2519
|
+
}, {
|
|
2520
|
+
source: "code-review-graph";
|
|
2521
|
+
perElement?: {
|
|
2522
|
+
elementId: number;
|
|
2523
|
+
reviewContext?: string | undefined;
|
|
2524
|
+
impactRadius?: unknown;
|
|
2525
|
+
affectedFlows?: unknown;
|
|
2526
|
+
}[] | undefined;
|
|
2527
|
+
warnings?: string[] | undefined;
|
|
2528
|
+
}>>;
|
|
2529
|
+
}, "strip", z.ZodTypeAny, {
|
|
2530
|
+
prompt: string;
|
|
2531
|
+
app: {
|
|
2532
|
+
url: string;
|
|
2533
|
+
route: string;
|
|
2534
|
+
page?: string | undefined;
|
|
2535
|
+
};
|
|
2536
|
+
elements: {
|
|
2537
|
+
ts: string;
|
|
2538
|
+
locator: {
|
|
2539
|
+
kind: "source";
|
|
2540
|
+
file: string;
|
|
2541
|
+
line: number;
|
|
2542
|
+
column?: number | undefined;
|
|
2543
|
+
export?: string | undefined;
|
|
2544
|
+
} | {
|
|
2545
|
+
kind: "attr";
|
|
2546
|
+
value: string;
|
|
2547
|
+
attr: string;
|
|
2548
|
+
selector: string;
|
|
2549
|
+
} | {
|
|
2550
|
+
kind: "behavioral";
|
|
2551
|
+
role: string;
|
|
2552
|
+
name: string;
|
|
2553
|
+
nth?: number | undefined;
|
|
2554
|
+
} | {
|
|
2555
|
+
kind: "dom";
|
|
2556
|
+
selector: string;
|
|
2557
|
+
fingerprint: string;
|
|
2558
|
+
};
|
|
2559
|
+
el: {
|
|
2560
|
+
tag: string;
|
|
2561
|
+
attrs: Record<string, string>;
|
|
2562
|
+
role?: string | undefined;
|
|
2563
|
+
text?: string | undefined;
|
|
2564
|
+
label?: string | undefined;
|
|
2565
|
+
iconHints?: string[] | undefined;
|
|
2566
|
+
};
|
|
2567
|
+
near: {
|
|
2568
|
+
labels?: string[] | undefined;
|
|
2569
|
+
headings?: string[] | undefined;
|
|
2570
|
+
landmarks?: string[] | undefined;
|
|
2571
|
+
parentText?: string | undefined;
|
|
2572
|
+
};
|
|
2573
|
+
conditions: {
|
|
2574
|
+
viewport: {
|
|
2575
|
+
w: number;
|
|
2576
|
+
h: number;
|
|
2577
|
+
};
|
|
2578
|
+
theme?: "light" | "dark" | undefined;
|
|
2579
|
+
mediaQueries?: Record<string, boolean> | undefined;
|
|
2580
|
+
};
|
|
2581
|
+
screenshot?: string | undefined;
|
|
2582
|
+
frameworkHints?: Record<string, unknown> | undefined;
|
|
2583
|
+
}[];
|
|
2584
|
+
execution?: {
|
|
2585
|
+
mode?: "plan" | "edit" | undefined;
|
|
2586
|
+
isolation?: "worktree" | "branch" | "inplace" | undefined;
|
|
2587
|
+
autoApply?: boolean | undefined;
|
|
2588
|
+
agentId?: string | undefined;
|
|
2589
|
+
baseRef?: string | undefined;
|
|
2590
|
+
} | undefined;
|
|
2591
|
+
enrichment?: {
|
|
2592
|
+
source: "code-review-graph";
|
|
2593
|
+
perElement: {
|
|
2594
|
+
elementId: number;
|
|
2595
|
+
reviewContext?: string | undefined;
|
|
2596
|
+
impactRadius?: unknown;
|
|
2597
|
+
affectedFlows?: unknown;
|
|
2598
|
+
}[];
|
|
2599
|
+
warnings: string[];
|
|
2600
|
+
} | undefined;
|
|
2601
|
+
}, {
|
|
2602
|
+
prompt: string;
|
|
2603
|
+
app: {
|
|
2604
|
+
url: string;
|
|
2605
|
+
route: string;
|
|
2606
|
+
page?: string | undefined;
|
|
2607
|
+
};
|
|
2608
|
+
elements: {
|
|
2609
|
+
ts: string;
|
|
2610
|
+
locator: {
|
|
2611
|
+
kind: "source";
|
|
2612
|
+
file: string;
|
|
2613
|
+
line: number;
|
|
2614
|
+
column?: number | undefined;
|
|
2615
|
+
export?: string | undefined;
|
|
2616
|
+
} | {
|
|
2617
|
+
kind: "attr";
|
|
2618
|
+
value: string;
|
|
2619
|
+
attr: string;
|
|
2620
|
+
selector: string;
|
|
2621
|
+
} | {
|
|
2622
|
+
kind: "behavioral";
|
|
2623
|
+
role: string;
|
|
2624
|
+
name: string;
|
|
2625
|
+
nth?: number | undefined;
|
|
2626
|
+
} | {
|
|
2627
|
+
kind: "dom";
|
|
2628
|
+
selector: string;
|
|
2629
|
+
fingerprint: string;
|
|
2630
|
+
};
|
|
2631
|
+
el: {
|
|
2632
|
+
tag: string;
|
|
2633
|
+
role?: string | undefined;
|
|
2634
|
+
text?: string | undefined;
|
|
2635
|
+
label?: string | undefined;
|
|
2636
|
+
attrs?: Record<string, string> | undefined;
|
|
2637
|
+
iconHints?: string[] | undefined;
|
|
2638
|
+
};
|
|
2639
|
+
conditions: {
|
|
2640
|
+
viewport: {
|
|
2641
|
+
w: number;
|
|
2642
|
+
h: number;
|
|
2643
|
+
};
|
|
2644
|
+
theme?: "light" | "dark" | undefined;
|
|
2645
|
+
mediaQueries?: Record<string, boolean> | undefined;
|
|
2646
|
+
};
|
|
2647
|
+
near?: {
|
|
2648
|
+
labels?: string[] | undefined;
|
|
2649
|
+
headings?: string[] | undefined;
|
|
2650
|
+
landmarks?: string[] | undefined;
|
|
2651
|
+
parentText?: string | undefined;
|
|
2652
|
+
} | undefined;
|
|
2653
|
+
screenshot?: string | undefined;
|
|
2654
|
+
frameworkHints?: Record<string, unknown> | undefined;
|
|
2655
|
+
}[];
|
|
2656
|
+
execution?: {
|
|
2657
|
+
mode?: "plan" | "edit" | undefined;
|
|
2658
|
+
isolation?: "worktree" | "branch" | "inplace" | undefined;
|
|
2659
|
+
autoApply?: boolean | undefined;
|
|
2660
|
+
agentId?: string | undefined;
|
|
2661
|
+
baseRef?: string | undefined;
|
|
2662
|
+
} | undefined;
|
|
2663
|
+
enrichment?: {
|
|
2664
|
+
source: "code-review-graph";
|
|
2665
|
+
perElement?: {
|
|
2666
|
+
elementId: number;
|
|
2667
|
+
reviewContext?: string | undefined;
|
|
2668
|
+
impactRadius?: unknown;
|
|
2669
|
+
affectedFlows?: unknown;
|
|
2670
|
+
}[] | undefined;
|
|
2671
|
+
warnings?: string[] | undefined;
|
|
2672
|
+
} | undefined;
|
|
2673
|
+
}>;
|
|
2674
|
+
type RunRequest = z.infer<typeof RunRequestSchema>;
|
|
2675
|
+
interface RunResponse {
|
|
2676
|
+
runId: string;
|
|
2677
|
+
sessionId: string;
|
|
2678
|
+
bundle: CaptureBundle;
|
|
2679
|
+
}
|
|
2229
2680
|
interface ApplyResponse {
|
|
2230
2681
|
applied: boolean;
|
|
2231
2682
|
commit?: string;
|
|
@@ -2317,4 +2768,4 @@ type ClientMessage = {
|
|
|
2317
2768
|
/** Ordered list of every WS event type, useful for tests and docs. */
|
|
2318
2769
|
declare const SERVER_EVENT_TYPES: readonly ["capture-ack", "element-removed", "agent-started", "agent-log", "plan-ready", "agent-done", "agent-error", "apply-started", "apply-done", "apply-error"];
|
|
2319
2770
|
|
|
2320
|
-
export { type AppContext, AppContextSchema, type ApplyResponse, type AttrLocator, AttrLocatorSchema, type BehavioralLocator, BehavioralLocatorSchema, CURRENT_BUNDLE_VERSION, type CaptureBundle, CaptureBundleSchema, type CaptureRequest, CaptureRequestSchema, type CaptureResponse, type CapturedElement, type CapturedElementInput, CapturedElementInputSchema, CapturedElementSchema, type ClientMessage, type Conditions, ConditionsSchema, type CreateSessionInput, DEFAULT_DAEMON_HOST, DEFAULT_DAEMON_PORT, DEFAULT_EXECUTION_OPTIONS, DEFAULT_SESSION_TTL_MS, type DomLocator, DomLocatorSchema, type ElementDescriptor, ElementDescriptorSchema, type ElementEnrichment, ElementEnrichmentSchema, type Enrichment, EnrichmentSchema, type ExecutionMode, ExecutionModeSchema, type ExecutionOptions, ExecutionOptionsSchema, type FinalizeInput, type HealthResponse, type Isolation, IsolationSchema, LOCATOR_PRIORITY, type Locator, type LocatorKind, LocatorSchema, type NearContext, NearContextSchema, type RemoveElementResponse, type RunStatus, RunStatusSchema, type RunSummary, SERVER_EVENT_TYPES, type SandboxInfo, type ServerEvent, type ServerEventType, type Session, type SessionResponse, SessionSchema, type SessionStatus, SessionStatusSchema, type SourceLocator, SourceLocatorSchema, type SubmitRequest, SubmitRequestSchema, type SubmitResponse, type ValidationResult, appendElement, compareLocators, confirmationReasons, createSession, describeLocator, deserializeBundle, finalizeSession, findElement, isCurrentVersion, isExpired, isSourceResolved, locatorRank, newRunId, newSessionId, nextElementId, parseBundle, parseElementRef, pickBestLocator, rankLocators, removeElement, requiresConfirmation, serializeBundle, touchSession, validateBundle };
|
|
2771
|
+
export { type AppContext, AppContextSchema, type ApplyResponse, type AttrLocator, AttrLocatorSchema, type BehavioralLocator, BehavioralLocatorSchema, CURRENT_BUNDLE_VERSION, type CaptureBundle, CaptureBundleSchema, type CaptureRequest, CaptureRequestSchema, type CaptureResponse, type CapturedElement, type CapturedElementInput, CapturedElementInputSchema, CapturedElementSchema, type ClientMessage, type Conditions, ConditionsSchema, type CreateSessionInput, DEFAULT_DAEMON_HOST, DEFAULT_DAEMON_PORT, DEFAULT_EXECUTION_OPTIONS, DEFAULT_SESSION_TTL_MS, type DomLocator, DomLocatorSchema, type ElementDescriptor, ElementDescriptorSchema, type ElementEnrichment, ElementEnrichmentSchema, type Enrichment, EnrichmentSchema, type ExecutionMode, ExecutionModeSchema, type ExecutionOptions, ExecutionOptionsSchema, type FinalizeInput, type HealthResponse, type Isolation, IsolationSchema, LOCATOR_PRIORITY, type Locator, type LocatorKind, LocatorSchema, type NearContext, NearContextSchema, type RemoveElementResponse, type RunRequest, RunRequestSchema, type RunResponse, type RunStatus, RunStatusSchema, type RunSummary, SERVER_EVENT_TYPES, type SandboxInfo, type ServerEvent, type ServerEventType, type Session, type SessionResponse, SessionSchema, type SessionStatus, SessionStatusSchema, type SourceLocator, SourceLocatorSchema, type SubmitRequest, SubmitRequestSchema, type SubmitResponse, type ValidationResult, appendElement, compareLocators, confirmationReasons, createSession, describeLocator, deserializeBundle, finalizeSession, findElement, isCurrentVersion, isExpired, isSourceResolved, locatorRank, newRunId, newSessionId, nextElementId, parseBundle, parseElementRef, pickBestLocator, rankLocators, removeElement, requiresConfirmation, serializeBundle, touchSession, validateBundle };
|
package/dist/index.js
CHANGED
|
@@ -336,6 +336,13 @@ var SubmitRequestSchema = z.object({
|
|
|
336
336
|
execution: ExecutionOptionsSchema.partial().optional(),
|
|
337
337
|
enrichment: EnrichmentSchema.optional()
|
|
338
338
|
});
|
|
339
|
+
var RunRequestSchema = z.object({
|
|
340
|
+
app: AppContextSchema,
|
|
341
|
+
elements: z.array(CapturedElementInputSchema).min(1),
|
|
342
|
+
prompt: z.string().min(1),
|
|
343
|
+
execution: ExecutionOptionsSchema.partial().optional(),
|
|
344
|
+
enrichment: EnrichmentSchema.optional()
|
|
345
|
+
});
|
|
339
346
|
var RunStatusSchema = z.enum([
|
|
340
347
|
"pending",
|
|
341
348
|
"running",
|
|
@@ -359,6 +366,6 @@ var SERVER_EVENT_TYPES = [
|
|
|
359
366
|
"apply-error"
|
|
360
367
|
];
|
|
361
368
|
|
|
362
|
-
export { AppContextSchema, AttrLocatorSchema, BehavioralLocatorSchema, CURRENT_BUNDLE_VERSION, CaptureBundleSchema, CaptureRequestSchema, CapturedElementInputSchema, CapturedElementSchema, ConditionsSchema, DEFAULT_DAEMON_HOST, DEFAULT_DAEMON_PORT, DEFAULT_EXECUTION_OPTIONS, DEFAULT_SESSION_TTL_MS, DomLocatorSchema, ElementDescriptorSchema, ElementEnrichmentSchema, EnrichmentSchema, ExecutionModeSchema, ExecutionOptionsSchema, IsolationSchema, LOCATOR_PRIORITY, LocatorSchema, NearContextSchema, RunStatusSchema, SERVER_EVENT_TYPES, SessionSchema, SessionStatusSchema, SourceLocatorSchema, SubmitRequestSchema, appendElement, compareLocators, confirmationReasons, createSession, describeLocator, deserializeBundle, finalizeSession, findElement, isCurrentVersion, isExpired, isSourceResolved, locatorRank, newRunId, newSessionId, nextElementId, parseBundle, parseElementRef, pickBestLocator, rankLocators, removeElement, requiresConfirmation, serializeBundle, touchSession, validateBundle };
|
|
369
|
+
export { AppContextSchema, AttrLocatorSchema, BehavioralLocatorSchema, CURRENT_BUNDLE_VERSION, CaptureBundleSchema, CaptureRequestSchema, CapturedElementInputSchema, CapturedElementSchema, ConditionsSchema, DEFAULT_DAEMON_HOST, DEFAULT_DAEMON_PORT, DEFAULT_EXECUTION_OPTIONS, DEFAULT_SESSION_TTL_MS, DomLocatorSchema, ElementDescriptorSchema, ElementEnrichmentSchema, EnrichmentSchema, ExecutionModeSchema, ExecutionOptionsSchema, IsolationSchema, LOCATOR_PRIORITY, LocatorSchema, NearContextSchema, RunRequestSchema, RunStatusSchema, SERVER_EVENT_TYPES, SessionSchema, SessionStatusSchema, SourceLocatorSchema, SubmitRequestSchema, appendElement, compareLocators, confirmationReasons, createSession, describeLocator, deserializeBundle, finalizeSession, findElement, isCurrentVersion, isExpired, isSourceResolved, locatorRank, newRunId, newSessionId, nextElementId, parseBundle, parseElementRef, pickBestLocator, rankLocators, removeElement, requiresConfirmation, serializeBundle, touchSession, validateBundle };
|
|
363
370
|
//# sourceMappingURL=index.js.map
|
|
364
371
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas.ts","../src/ids.ts","../src/locator.ts","../src/defaults.ts","../src/session.ts","../src/bundle.ts","../src/protocol.ts"],"names":["z"],"mappings":";;;AAMO,IAAM,sBAAA,GAAyB;AAEtC,IAAM,WAAA,GAAc,CAAA,CACjB,MAAA,EAAO,CACP,QAAA,CAAS,EAAE,MAAA,EAAQ,IAAA,EAAM,CAAA,CACzB,QAAA,CAAS,oBAAoB,CAAA;AAWzB,IAAM,mBAAA,GAAsB,EAAE,MAAA,CAAO;AAAA,EAC1C,IAAA,EAAM,CAAA,CAAE,OAAA,CAAQ,QAAQ,CAAA;AAAA,EACxB,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA,EACtB,MAAM,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,QAAA,EAAS;AAAA,EAChC,MAAA,EAAQ,EAAE,MAAA,EAAO,CAAE,KAAI,CAAE,WAAA,GAAc,QAAA,EAAS;AAAA,EAChD,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA;AACrB,CAAC;AAGM,IAAM,iBAAA,GAAoB,EAAE,MAAA,CAAO;AAAA,EACxC,IAAA,EAAM,CAAA,CAAE,OAAA,CAAQ,MAAM,CAAA;AAAA,EACtB,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA,EACtB,KAAA,EAAO,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A;AAAA,EACA,YAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["import { z } from 'zod';\n\n/**\n * The current {@link CaptureBundle} schema version. Bumped whenever the wire\n * format changes in a backward-incompatible way.\n */\nexport const CURRENT_BUNDLE_VERSION = 5 as const;\n\nconst isoDateTime = z\n .string()\n .datetime({ offset: true })\n .describe('ISO-8601 timestamp');\n\n/* -------------------------------------------------------------------------- */\n/* Locator */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A `source` locator is the most precise: it points at the exact file/line that\n * rendered the element, recovered from a dev-only `data-loc` attribute injected\n * by `@clicksmith/unplugin`.\n */\nexport const SourceLocatorSchema = z.object({\n kind: z.literal('source'),\n file: z.string().min(1),\n line: z.number().int().positive(),\n column: z.number().int().nonnegative().optional(),\n export: z.string().optional(),\n});\n\n/** A stable, author-provided attribute such as `data-testid` or `id`. */\nexport const AttrLocatorSchema = z.object({\n kind: z.literal('attr'),\n attr: z.string().min(1),\n value: z.string(),\n selector: z.string().min(1),\n});\n\n/** An accessibility-based locator: ARIA role + accessible name. */\nexport const BehavioralLocatorSchema = z.object({\n kind: z.literal('behavioral'),\n role: z.string().min(1),\n name: z.string(),\n nth: z.number().int().nonnegative().optional(),\n});\n\n/** Last-resort structural locator: a CSS selector plus a DOM fingerprint. */\nexport const DomLocatorSchema = z.object({\n kind: z.literal('dom'),\n selector: z.string().min(1),\n fingerprint: z.string().min(1),\n});\n\n/**\n * Discriminated union of all locator kinds, ranked exactly\n * `source -> attr -> behavioral -> dom` (see `locator.ts`).\n */\nexport const LocatorSchema = z.discriminatedUnion('kind', [\n SourceLocatorSchema,\n AttrLocatorSchema,\n BehavioralLocatorSchema,\n DomLocatorSchema,\n]);\n\n/* -------------------------------------------------------------------------- */\n/* Captured element */\n/* -------------------------------------------------------------------------- */\n\nexport const ElementDescriptorSchema = z.object({\n tag: z.string().min(1),\n text: z.string().optional(),\n role: z.string().optional(),\n label: z.string().optional(),\n attrs: z.record(z.string()).default({}),\n iconHints: z.array(z.string()).optional(),\n});\n\nexport const NearContextSchema = z.object({\n labels: z.array(z.string()).optional(),\n headings: z.array(z.string()).optional(),\n landmarks: z.array(z.string()).optional(),\n parentText: z.string().optional(),\n});\n\nexport const ConditionsSchema = z.object({\n viewport: z.object({\n w: z.number().int().positive(),\n h: z.number().int().positive(),\n }),\n theme: z.enum(['light', 'dark']).optional(),\n mediaQueries: z.record(z.boolean()).optional(),\n});\n\nexport const CapturedElementSchema = z.object({\n /** 1-based identifier surfaced to users as `#N`. Stable within a session. */\n id: z.number().int().positive(),\n ts: isoDateTime,\n locator: LocatorSchema,\n el: ElementDescriptorSchema,\n near: NearContextSchema.default({}),\n conditions: ConditionsSchema,\n screenshot: z.string().optional(),\n frameworkHints: z.record(z.unknown()).optional(),\n});\n\n/* -------------------------------------------------------------------------- */\n/* Execution options */\n/* -------------------------------------------------------------------------- */\n\nexport const ExecutionModeSchema = z.enum(['plan', 'edit']);\nexport const IsolationSchema = z.enum(['worktree', 'branch', 'inplace']);\n\n/**\n * How a run should be executed. The defaults — `plan` + `worktree` + no\n * auto-apply — are the immutable safe path. Any deviation (edit mode, inplace\n * isolation, or auto-apply) is a risky option requiring explicit confirmation.\n */\nexport const ExecutionOptionsSchema = z.object({\n mode: ExecutionModeSchema.default('plan'),\n isolation: IsolationSchema.default('worktree'),\n autoApply: z.boolean().default(false),\n agentId: z.string().optional(),\n /** Git ref the sandbox should branch from. Defaults to the current HEAD. */\n baseRef: z.string().optional(),\n});\n\n/* -------------------------------------------------------------------------- */\n/* Enrichment */\n/* -------------------------------------------------------------------------- */\n\nexport const ElementEnrichmentSchema = z.object({\n elementId: z.number().int().positive(),\n reviewContext: z.string().optional(),\n impactRadius: z.unknown().optional(),\n affectedFlows: z.unknown().optional(),\n});\n\nexport const EnrichmentSchema = z.object({\n source: z.literal('code-review-graph'),\n perElement: z.array(ElementEnrichmentSchema).default([]),\n warnings: z.array(z.string()).default([]),\n});\n\n/* -------------------------------------------------------------------------- */\n/* App context */\n/* -------------------------------------------------------------------------- */\n\nexport const AppContextSchema = z.object({\n url: z.string().url(),\n route: z.string().min(1),\n page: z.string().optional(),\n});\n\n/* -------------------------------------------------------------------------- */\n/* Capture bundle */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The finalized, agent-ready payload produced when a user submits a session.\n * Version 5.\n */\nexport const CaptureBundleSchema = z.object({\n v: z.literal(CURRENT_BUNDLE_VERSION),\n sessionId: z.string().min(1),\n submittedAt: isoDateTime,\n prompt: z.string().min(1),\n app: AppContextSchema,\n elements: z.array(CapturedElementSchema).min(1),\n execution: ExecutionOptionsSchema,\n enrichment: EnrichmentSchema.optional(),\n});\n\n/* -------------------------------------------------------------------------- */\n/* Session */\n/* -------------------------------------------------------------------------- */\n\nexport const SessionStatusSchema = z.enum(['active', 'submitted', 'expired']);\n\n/**\n * An in-progress capture session held by the daemon before the user submits.\n * Finalizing a session produces a {@link CaptureBundleSchema}.\n */\nexport const SessionSchema = z.object({\n id: z.string().min(1),\n createdAt: isoDateTime,\n updatedAt: isoDateTime,\n expiresAt: isoDateTime,\n status: SessionStatusSchema.default('active'),\n app: AppContextSchema,\n elements: z.array(CapturedElementSchema).default([]),\n prompt: z.string().optional(),\n /**\n * High-water mark of element ids ever assigned. Ensures `#N` ids are never\n * reused, even after the highest-numbered element is removed.\n */\n lastElementId: z.number().int().nonnegative().default(0),\n});\n","/**\n * Platform-neutral identifier helpers. These rely only on the Web Crypto API\n * (`globalThis.crypto`), which is available in modern browsers and Node >= 20,\n * with a deterministic-enough fallback so `core` never imports `node:crypto`.\n */\n\nfunction randomToken(bytes = 8): string {\n const cryptoObj = globalThis.crypto;\n if (cryptoObj?.getRandomValues) {\n const arr = new Uint8Array(bytes);\n cryptoObj.getRandomValues(arr);\n return Array.from(arr, (b) => b.toString(16).padStart(2, '0')).join('');\n }\n // Fallback for exotic runtimes without Web Crypto.\n let out = '';\n for (let i = 0; i < bytes; i++) {\n out += Math.floor(Math.random() * 256)\n .toString(16)\n .padStart(2, '0');\n }\n return out;\n}\n\n/** A new opaque session id, e.g. `cs_lt4f9q_a1b2c3d4`. */\nexport function newSessionId(now: Date = new Date()): string {\n return `cs_${now.getTime().toString(36)}_${randomToken(4)}`;\n}\n\n/** A new opaque run id, e.g. `run_lt4f9q_a1b2c3d4`. */\nexport function newRunId(now: Date = new Date()): string {\n return `run_${now.getTime().toString(36)}_${randomToken(4)}`;\n}\n\n/**\n * Assign the next element id for a session. Ids are 1-based, strictly\n * increasing, and never reused — even after the highest-numbered mark is\n * removed — so user-typed references like `#2` remain stable for the life of\n * the session. Pass the session's high-water mark (`lastElementId`) so removal\n * of the top id still advances the counter.\n */\nexport function nextElementId(existingIds: readonly number[], lastSeen = 0): number {\n return Math.max(lastSeen, ...existingIds, 0) + 1;\n}\n\n/** Parse a `#N` reference (e.g. `\"#3\"`, `\"3\"`, `\"# 3\"`) into a number. */\nexport function parseElementRef(ref: string): number | undefined {\n const match = ref.trim().match(/^#?\\s*(\\d+)$/);\n if (!match) return undefined;\n const n = Number.parseInt(match[1]!, 10);\n return Number.isSafeInteger(n) && n > 0 ? n : undefined;\n}\n","import type { Locator, LocatorKind } from './types.js';\n\n/**\n * The canonical locator priority, best first. This ordering is a hard contract\n * shared by the extension (which picks the best locator it can build) and the\n * agent instructions (which teach the agent to trust higher-ranked locators).\n */\nexport const LOCATOR_PRIORITY = ['source', 'attr', 'behavioral', 'dom'] as const;\n\nconst RANK: Record<LocatorKind, number> = {\n source: 0,\n attr: 1,\n behavioral: 2,\n dom: 3,\n};\n\n/** Numeric rank of a locator kind; lower is more precise. */\nexport function locatorRank(kind: LocatorKind): number {\n return RANK[kind];\n}\n\n/**\n * Comparator for `Array.prototype.sort`, ordering locators best-first per\n * {@link LOCATOR_PRIORITY}.\n */\nexport function compareLocators(a: Locator, b: Locator): number {\n return locatorRank(a.kind) - locatorRank(b.kind);\n}\n\n/** Return a new array of locators sorted best-first. Does not mutate input. */\nexport function rankLocators(locators: readonly Locator[]): Locator[] {\n return [...locators].sort(compareLocators);\n}\n\n/** The single most precise locator from a list, or `undefined` if empty. */\nexport function pickBestLocator(locators: readonly Locator[]): Locator | undefined {\n if (locators.length === 0) return undefined;\n return rankLocators(locators)[0];\n}\n\n/**\n * A compact, human- and agent-readable description of a locator, suitable for\n * embedding in instructions or logs.\n */\nexport function describeLocator(locator: Locator): string {\n switch (locator.kind) {\n case 'source':\n return `source:${locator.file}:${locator.line}${\n locator.column != null ? `:${locator.column}` : ''\n }`;\n case 'attr':\n return `attr:[${locator.attr}=\"${locator.value}\"]`;\n case 'behavioral':\n return `role:${locator.role}${locator.name ? ` name=\"${locator.name}\"` : ''}${\n locator.nth != null ? ` (nth=${locator.nth})` : ''\n }`;\n case 'dom':\n return `dom:${locator.selector}`;\n }\n}\n\n/** Whether a locator points directly at source (the strongest signal). */\nexport function isSourceResolved(locator: Locator): boolean {\n return locator.kind === 'source';\n}\n","import type { ExecutionOptions } from './types.js';\n\n/** Default localhost port the daemon listens on. */\nexport const DEFAULT_DAEMON_PORT = 8722;\n\n/** Default localhost host. ClickSmith only ever binds loopback. */\nexport const DEFAULT_DAEMON_HOST = '127.0.0.1';\n\n/** Default time-to-live for an unfinished capture session: 24 hours. */\nexport const DEFAULT_SESSION_TTL_MS = 24 * 60 * 60 * 1000;\n\n/**\n * The immutable safe defaults: plan mode, worktree isolation, no auto-apply.\n * Any change away from these is considered a \"risky option\".\n */\nexport const DEFAULT_EXECUTION_OPTIONS: ExecutionOptions = {\n mode: 'plan',\n isolation: 'worktree',\n autoApply: false,\n};\n\n/**\n * Whether a set of execution options deviates from the safe defaults and\n * therefore requires explicit user confirmation in the extension/CLI:\n * non-plan mode, in-place isolation, or auto-apply.\n */\nexport function requiresConfirmation(execution: ExecutionOptions): boolean {\n return execution.mode !== 'plan' || execution.isolation === 'inplace' || execution.autoApply;\n}\n\n/** Human-readable reasons a given execution config is considered risky. */\nexport function confirmationReasons(execution: ExecutionOptions): string[] {\n const reasons: string[] = [];\n if (execution.mode !== 'plan') {\n reasons.push('Edit mode lets the agent modify files directly instead of only proposing a plan.');\n }\n if (execution.isolation === 'inplace') {\n reasons.push('In-place isolation runs against your working tree instead of a throwaway worktree.');\n }\n if (execution.autoApply) {\n reasons.push('Auto-apply merges the agent’s changes back without a manual review step.');\n }\n return reasons;\n}\n","import { CaptureBundleSchema, CURRENT_BUNDLE_VERSION } from './schemas.js';\nimport { newSessionId, nextElementId } from './ids.js';\nimport { DEFAULT_EXECUTION_OPTIONS, DEFAULT_SESSION_TTL_MS } from './defaults.js';\nimport type {\n AppContext,\n CaptureBundle,\n CapturedElement,\n CapturedElementInput,\n ExecutionOptions,\n Session,\n} from './types.js';\n\nexport interface CreateSessionInput {\n app: AppContext;\n now?: Date;\n ttlMs?: number;\n id?: string;\n}\n\n/** Create a fresh, empty, active capture session. Pure. */\nexport function createSession(input: CreateSessionInput): Session {\n const now = input.now ?? new Date();\n const ttlMs = input.ttlMs ?? DEFAULT_SESSION_TTL_MS;\n const iso = now.toISOString();\n return {\n id: input.id ?? newSessionId(now),\n createdAt: iso,\n updatedAt: iso,\n expiresAt: new Date(now.getTime() + ttlMs).toISOString(),\n status: 'active',\n app: input.app,\n elements: [],\n lastElementId: 0,\n };\n}\n\n/**\n * Append a captured element to a session, assigning the next stable id. Returns\n * a new session plus the fully-formed element (so callers know the assigned id).\n * Pure — the input session is not mutated.\n */\nexport function appendElement(\n session: Session,\n input: CapturedElementInput,\n now: Date = new Date(),\n): { session: Session; element: CapturedElement } {\n const id = nextElementId(\n session.elements.map((e) => e.id),\n session.lastElementId,\n );\n const element: CapturedElement = { ...input, id };\n const next: Session = {\n ...session,\n elements: [...session.elements, element],\n lastElementId: id,\n updatedAt: now.toISOString(),\n };\n return { session: next, element };\n}\n\n/**\n * Remove a captured element by id. Ids are never renumbered, keeping existing\n * `#N` references valid. Returns the new session and whether anything changed.\n * Pure.\n */\nexport function removeElement(\n session: Session,\n elementId: number,\n now: Date = new Date(),\n): { session: Session; removed: boolean } {\n const elements = session.elements.filter((e) => e.id !== elementId);\n const removed = elements.length !== session.elements.length;\n if (!removed) return { session, removed: false };\n return {\n session: { ...session, elements, updatedAt: now.toISOString() },\n removed: true,\n };\n}\n\n/** Find a captured element by its `#N` id. */\nexport function findElement(session: Session, elementId: number): CapturedElement | undefined {\n return session.elements.find((e) => e.id === elementId);\n}\n\n/** Whether a session has passed its expiry (and was never submitted). */\nexport function isExpired(session: Session, now: Date = new Date()): boolean {\n if (session.status === 'submitted') return false;\n return new Date(session.expiresAt).getTime() <= now.getTime();\n}\n\n/** Slide a session's expiry forward by `ttlMs` from `now`. Pure. */\nexport function touchSession(\n session: Session,\n now: Date = new Date(),\n ttlMs: number = DEFAULT_SESSION_TTL_MS,\n): Session {\n return {\n ...session,\n updatedAt: now.toISOString(),\n expiresAt: new Date(now.getTime() + ttlMs).toISOString(),\n };\n}\n\nexport interface FinalizeInput {\n prompt: string;\n execution?: ExecutionOptions;\n submittedAt?: Date;\n enrichment?: CaptureBundle['enrichment'];\n}\n\n/**\n * Finalize a session into a validated v5 {@link CaptureBundle}. Throws if the\n * session has no elements or the prompt is empty. Does not mutate the session.\n */\nexport function finalizeSession(session: Session, input: FinalizeInput): CaptureBundle {\n if (session.elements.length === 0) {\n throw new Error(`Cannot finalize session ${session.id}: no captured elements.`);\n }\n if (!input.prompt.trim()) {\n throw new Error(`Cannot finalize session ${session.id}: prompt is empty.`);\n }\n const bundle: CaptureBundle = {\n v: CURRENT_BUNDLE_VERSION,\n sessionId: session.id,\n submittedAt: (input.submittedAt ?? new Date()).toISOString(),\n prompt: input.prompt.trim(),\n app: session.app,\n elements: session.elements,\n execution: input.execution ?? { ...DEFAULT_EXECUTION_OPTIONS },\n ...(input.enrichment ? { enrichment: input.enrichment } : {}),\n };\n // Validate before handing off; surfaces schema regressions early.\n return CaptureBundleSchema.parse(bundle);\n}\n","import type { z } from 'zod';\nimport { CaptureBundleSchema, CURRENT_BUNDLE_VERSION } from './schemas.js';\nimport type { CaptureBundle } from './types.js';\n\nexport type ValidationResult =\n | { ok: true; bundle: CaptureBundle }\n | { ok: false; error: z.ZodError };\n\n/** Validate an unknown value as a {@link CaptureBundle} without throwing. */\nexport function validateBundle(value: unknown): ValidationResult {\n const result = CaptureBundleSchema.safeParse(value);\n if (result.success) return { ok: true, bundle: result.data };\n return { ok: false, error: result.error };\n}\n\n/** Validate and throw on failure (with a readable message). */\nexport function parseBundle(value: unknown): CaptureBundle {\n const result = validateBundle(value);\n if (result.ok) return result.bundle;\n throw new Error(`Invalid CaptureBundle: ${result.error.message}`);\n}\n\n/** Deterministically serialize a bundle to JSON (stable key order, 2-space). */\nexport function serializeBundle(bundle: CaptureBundle): string {\n return JSON.stringify(parseBundle(bundle), stableReplacer(), 2);\n}\n\n/** Parse a JSON string into a validated bundle. */\nexport function deserializeBundle(json: string): CaptureBundle {\n let parsed: unknown;\n try {\n parsed = JSON.parse(json);\n } catch (err) {\n throw new Error(`CaptureBundle is not valid JSON: ${(err as Error).message}`);\n }\n return parseBundle(parsed);\n}\n\n/** Whether a value claims to be the current bundle version. */\nexport function isCurrentVersion(value: unknown): boolean {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { v?: unknown }).v === CURRENT_BUNDLE_VERSION\n );\n}\n\n/**\n * A JSON.stringify replacer that emits object keys in sorted order, producing\n * byte-stable output for hashing / golden-file comparisons.\n */\nfunction stableReplacer(): (this: unknown, key: string, value: unknown) => unknown {\n return function (_key, value) {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const sorted: Record<string, unknown> = {};\n for (const k of Object.keys(value as Record<string, unknown>).sort()) {\n sorted[k] = (value as Record<string, unknown>)[k];\n }\n return sorted;\n }\n return value;\n };\n}\n","import { z } from 'zod';\nimport {\n AppContextSchema,\n CapturedElementSchema,\n EnrichmentSchema,\n ExecutionOptionsSchema,\n} from './schemas.js';\nimport type { CaptureBundle, CapturedElement, Session } from './types.js';\n\n/* -------------------------------------------------------------------------- */\n/* HTTP request / response DTOs */\n/* -------------------------------------------------------------------------- */\n\n/** The element payload the extension sends (everything but the daemon id). */\nexport const CapturedElementInputSchema = CapturedElementSchema.omit({ id: true });\n\nexport const CaptureRequestSchema = z.object({\n /** Append to this session if present; otherwise the daemon opens one. */\n sessionId: z.string().optional(),\n app: AppContextSchema,\n element: CapturedElementInputSchema,\n});\nexport type CaptureRequest = z.infer<typeof CaptureRequestSchema>;\n\nexport interface CaptureResponse {\n sessionId: string;\n element: CapturedElement;\n}\n\nexport const SubmitRequestSchema = z.object({\n sessionId: z.string().min(1),\n prompt: z.string().min(1),\n execution: ExecutionOptionsSchema.partial().optional(),\n enrichment: EnrichmentSchema.optional(),\n});\nexport type SubmitRequest = z.infer<typeof SubmitRequestSchema>;\n\nexport interface SubmitResponse {\n runId: string;\n bundle: CaptureBundle;\n}\n\nexport interface ApplyResponse {\n applied: boolean;\n commit?: string;\n conflicts?: string[];\n}\n\nexport interface HealthResponse {\n ok: true;\n name: 'clicksmith-daemon';\n version: string;\n host: string;\n port: number;\n repoRoot: string | null;\n activeSessions: number;\n}\n\nexport type SessionResponse = Session;\n\nexport interface RemoveElementResponse {\n removed: boolean;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Run state */\n/* -------------------------------------------------------------------------- */\n\nexport const RunStatusSchema = z.enum([\n 'pending',\n 'running',\n 'plan-ready',\n 'done',\n 'applying',\n 'applied',\n 'error',\n 'apply-error',\n]);\nexport type RunStatus = z.infer<typeof RunStatusSchema>;\n\nexport interface RunSummary {\n runId: string;\n sessionId: string;\n agentId: string;\n status: RunStatus;\n createdAt: string;\n sandbox: SandboxInfo | null;\n}\n\nexport interface SandboxInfo {\n isolation: 'worktree' | 'branch' | 'inplace';\n path: string;\n branch: string | null;\n baseCommit: string;\n}\n\n/* -------------------------------------------------------------------------- */\n/* WebSocket event protocol */\n/* -------------------------------------------------------------------------- */\n\n/** Events streamed from daemon to the extension over the WebSocket. */\nexport type ServerEvent =\n | { type: 'capture-ack'; sessionId: string; element: CapturedElement }\n | { type: 'element-removed'; sessionId: string; elementId: number }\n | { type: 'agent-started'; runId: string; sessionId: string; agentId: string; sandbox: SandboxInfo | null }\n | { type: 'agent-log'; runId: string; stream: 'stdout' | 'stderr'; chunk: string }\n | { type: 'plan-ready'; runId: string; plan?: string; diff?: string }\n | { type: 'agent-done'; runId: string; exitCode: number }\n | { type: 'agent-error'; runId: string; message: string }\n | { type: 'apply-started'; runId: string }\n | { type: 'apply-done'; runId: string; commit?: string }\n | { type: 'apply-error'; runId: string; message: string; conflicts?: string[] };\n\nexport type ServerEventType = ServerEvent['type'];\n\n/** Messages the extension may send to the daemon over the WebSocket. */\nexport type ClientMessage =\n | { type: 'subscribe'; sessionId?: string }\n | { type: 'ping' };\n\n/** Ordered list of every WS event type, useful for tests and docs. */\nexport const SERVER_EVENT_TYPES = [\n 'capture-ack',\n 'element-removed',\n 'agent-started',\n 'agent-log',\n 'plan-ready',\n 'agent-done',\n 'agent-error',\n 'apply-started',\n 'apply-done',\n 'apply-error',\n] as const satisfies readonly ServerEventType[];\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/schemas.ts","../src/ids.ts","../src/locator.ts","../src/defaults.ts","../src/session.ts","../src/bundle.ts","../src/protocol.ts"],"names":["z"],"mappings":";;;AAMO,IAAM,sBAAA,GAAyB;AAEtC,IAAM,WAAA,GAAc,CAAA,CACjB,MAAA,EAAO,CACP,QAAA,CAAS,EAAE,MAAA,EAAQ,IAAA,EAAM,CAAA,CACzB,QAAA,CAAS,oBAAoB,CAAA;AAWzB,IAAM,mBAAA,GAAsB,EAAE,MAAA,CAAO;AAAA,EAC1C,IAAA,EAAM,CAAA,CAAE,OAAA,CAAQ,QAAQ,CAAA;AAAA,EACxB,IAAA,EAAM,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA,EACtB,MAAM,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,GAAM,QAAA,EAAS;AAAA,EAChC,MAAA,EA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D,UAAA,EAAY,iBAAiB,QAAA;AAC/B,CAAC;AASM,IAAM,gBAAA,GAAmBA,EAAE,MAAA,CAAO;AAAA,EACvC,GAAA,EAAK,gBAAA;AAAA,EACL,UAAUA,CAAAA,CAAE,KAAA,CAAM,0BAA0B,CAAA,CAAE,IAAI,CAAC,CAAA;AAAA,EACnD,MAAA,EAAQA,CAAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA,EACxB,SAAA,EAAW,sBAAA,CAAuB,OAAA,EAAQ,CAAE,QAAA,EAAS;AAAA,EACrD,UAAA,EAAY,iBAAiB,QAAA;AAC/B,CAAC;AAmCM,IAAM,eAAA,GAAkBA,EAAE,IAAA,CAAK;AAAA,EACpC,SAAA;AAAA,EACA,SAAA;AAAA,EACA,YAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAC;AA4CM,IAAM,kBAAA,GAAqB;AAAA,EAChC,aAAA;AAAA,EACA,iBAAA;AAAA,EACA,eAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,aAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["import { z } from 'zod';\n\n/**\n * The current {@link CaptureBundle} schema version. Bumped whenever the wire\n * format changes in a backward-incompatible way.\n */\nexport const CURRENT_BUNDLE_VERSION = 5 as const;\n\nconst isoDateTime = z\n .string()\n .datetime({ offset: true })\n .describe('ISO-8601 timestamp');\n\n/* -------------------------------------------------------------------------- */\n/* Locator */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A `source` locator is the most precise: it points at the exact file/line that\n * rendered the element, recovered from a dev-only `data-loc` attribute injected\n * by `@clicksmith/unplugin`.\n */\nexport const SourceLocatorSchema = z.object({\n kind: z.literal('source'),\n file: z.string().min(1),\n line: z.number().int().positive(),\n column: z.number().int().nonnegative().optional(),\n export: z.string().optional(),\n});\n\n/** A stable, author-provided attribute such as `data-testid` or `id`. */\nexport const AttrLocatorSchema = z.object({\n kind: z.literal('attr'),\n attr: z.string().min(1),\n value: z.string(),\n selector: z.string().min(1),\n});\n\n/** An accessibility-based locator: ARIA role + accessible name. */\nexport const BehavioralLocatorSchema = z.object({\n kind: z.literal('behavioral'),\n role: z.string().min(1),\n name: z.string(),\n nth: z.number().int().nonnegative().optional(),\n});\n\n/** Last-resort structural locator: a CSS selector plus a DOM fingerprint. */\nexport const DomLocatorSchema = z.object({\n kind: z.literal('dom'),\n selector: z.string().min(1),\n fingerprint: z.string().min(1),\n});\n\n/**\n * Discriminated union of all locator kinds, ranked exactly\n * `source -> attr -> behavioral -> dom` (see `locator.ts`).\n */\nexport const LocatorSchema = z.discriminatedUnion('kind', [\n SourceLocatorSchema,\n AttrLocatorSchema,\n BehavioralLocatorSchema,\n DomLocatorSchema,\n]);\n\n/* -------------------------------------------------------------------------- */\n/* Captured element */\n/* -------------------------------------------------------------------------- */\n\nexport const ElementDescriptorSchema = z.object({\n tag: z.string().min(1),\n text: z.string().optional(),\n role: z.string().optional(),\n label: z.string().optional(),\n attrs: z.record(z.string()).default({}),\n iconHints: z.array(z.string()).optional(),\n});\n\nexport const NearContextSchema = z.object({\n labels: z.array(z.string()).optional(),\n headings: z.array(z.string()).optional(),\n landmarks: z.array(z.string()).optional(),\n parentText: z.string().optional(),\n});\n\nexport const ConditionsSchema = z.object({\n viewport: z.object({\n w: z.number().int().positive(),\n h: z.number().int().positive(),\n }),\n theme: z.enum(['light', 'dark']).optional(),\n mediaQueries: z.record(z.boolean()).optional(),\n});\n\nexport const CapturedElementSchema = z.object({\n /** 1-based identifier surfaced to users as `#N`. Stable within a session. */\n id: z.number().int().positive(),\n ts: isoDateTime,\n locator: LocatorSchema,\n el: ElementDescriptorSchema,\n near: NearContextSchema.default({}),\n conditions: ConditionsSchema,\n screenshot: z.string().optional(),\n frameworkHints: z.record(z.unknown()).optional(),\n});\n\n/* -------------------------------------------------------------------------- */\n/* Execution options */\n/* -------------------------------------------------------------------------- */\n\nexport const ExecutionModeSchema = z.enum(['plan', 'edit']);\nexport const IsolationSchema = z.enum(['worktree', 'branch', 'inplace']);\n\n/**\n * How a run should be executed. The defaults — `plan` + `worktree` + no\n * auto-apply — are the immutable safe path. Any deviation (edit mode, inplace\n * isolation, or auto-apply) is a risky option requiring explicit confirmation.\n */\nexport const ExecutionOptionsSchema = z.object({\n mode: ExecutionModeSchema.default('plan'),\n isolation: IsolationSchema.default('worktree'),\n autoApply: z.boolean().default(false),\n agentId: z.string().optional(),\n /** Git ref the sandbox should branch from. Defaults to the current HEAD. */\n baseRef: z.string().optional(),\n});\n\n/* -------------------------------------------------------------------------- */\n/* Enrichment */\n/* -------------------------------------------------------------------------- */\n\nexport const ElementEnrichmentSchema = z.object({\n elementId: z.number().int().positive(),\n reviewContext: z.string().optional(),\n impactRadius: z.unknown().optional(),\n affectedFlows: z.unknown().optional(),\n});\n\nexport const EnrichmentSchema = z.object({\n source: z.literal('code-review-graph'),\n perElement: z.array(ElementEnrichmentSchema).default([]),\n warnings: z.array(z.string()).default([]),\n});\n\n/* -------------------------------------------------------------------------- */\n/* App context */\n/* -------------------------------------------------------------------------- */\n\nexport const AppContextSchema = z.object({\n url: z.string().url(),\n route: z.string().min(1),\n page: z.string().optional(),\n});\n\n/* -------------------------------------------------------------------------- */\n/* Capture bundle */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The finalized, agent-ready payload produced when a user submits a session.\n * Version 5.\n */\nexport const CaptureBundleSchema = z.object({\n v: z.literal(CURRENT_BUNDLE_VERSION),\n sessionId: z.string().min(1),\n submittedAt: isoDateTime,\n prompt: z.string().min(1),\n app: AppContextSchema,\n elements: z.array(CapturedElementSchema).min(1),\n execution: ExecutionOptionsSchema,\n enrichment: EnrichmentSchema.optional(),\n});\n\n/* -------------------------------------------------------------------------- */\n/* Session */\n/* -------------------------------------------------------------------------- */\n\nexport const SessionStatusSchema = z.enum(['active', 'submitted', 'expired']);\n\n/**\n * An in-progress capture session held by the daemon before the user submits.\n * Finalizing a session produces a {@link CaptureBundleSchema}.\n */\nexport const SessionSchema = z.object({\n id: z.string().min(1),\n createdAt: isoDateTime,\n updatedAt: isoDateTime,\n expiresAt: isoDateTime,\n status: SessionStatusSchema.default('active'),\n app: AppContextSchema,\n elements: z.array(CapturedElementSchema).default([]),\n prompt: z.string().optional(),\n /**\n * High-water mark of element ids ever assigned. Ensures `#N` ids are never\n * reused, even after the highest-numbered element is removed.\n */\n lastElementId: z.number().int().nonnegative().default(0),\n});\n","/**\n * Platform-neutral identifier helpers. These rely only on the Web Crypto API\n * (`globalThis.crypto`), which is available in modern browsers and Node >= 20,\n * with a deterministic-enough fallback so `core` never imports `node:crypto`.\n */\n\nfunction randomToken(bytes = 8): string {\n const cryptoObj = globalThis.crypto;\n if (cryptoObj?.getRandomValues) {\n const arr = new Uint8Array(bytes);\n cryptoObj.getRandomValues(arr);\n return Array.from(arr, (b) => b.toString(16).padStart(2, '0')).join('');\n }\n // Fallback for exotic runtimes without Web Crypto.\n let out = '';\n for (let i = 0; i < bytes; i++) {\n out += Math.floor(Math.random() * 256)\n .toString(16)\n .padStart(2, '0');\n }\n return out;\n}\n\n/** A new opaque session id, e.g. `cs_lt4f9q_a1b2c3d4`. */\nexport function newSessionId(now: Date = new Date()): string {\n return `cs_${now.getTime().toString(36)}_${randomToken(4)}`;\n}\n\n/** A new opaque run id, e.g. `run_lt4f9q_a1b2c3d4`. */\nexport function newRunId(now: Date = new Date()): string {\n return `run_${now.getTime().toString(36)}_${randomToken(4)}`;\n}\n\n/**\n * Assign the next element id for a session. Ids are 1-based, strictly\n * increasing, and never reused — even after the highest-numbered mark is\n * removed — so user-typed references like `#2` remain stable for the life of\n * the session. Pass the session's high-water mark (`lastElementId`) so removal\n * of the top id still advances the counter.\n */\nexport function nextElementId(existingIds: readonly number[], lastSeen = 0): number {\n return Math.max(lastSeen, ...existingIds, 0) + 1;\n}\n\n/** Parse a `#N` reference (e.g. `\"#3\"`, `\"3\"`, `\"# 3\"`) into a number. */\nexport function parseElementRef(ref: string): number | undefined {\n const match = ref.trim().match(/^#?\\s*(\\d+)$/);\n if (!match) return undefined;\n const n = Number.parseInt(match[1]!, 10);\n return Number.isSafeInteger(n) && n > 0 ? n : undefined;\n}\n","import type { Locator, LocatorKind } from './types.js';\n\n/**\n * The canonical locator priority, best first. This ordering is a hard contract\n * shared by the extension (which picks the best locator it can build) and the\n * agent instructions (which teach the agent to trust higher-ranked locators).\n */\nexport const LOCATOR_PRIORITY = ['source', 'attr', 'behavioral', 'dom'] as const;\n\nconst RANK: Record<LocatorKind, number> = {\n source: 0,\n attr: 1,\n behavioral: 2,\n dom: 3,\n};\n\n/** Numeric rank of a locator kind; lower is more precise. */\nexport function locatorRank(kind: LocatorKind): number {\n return RANK[kind];\n}\n\n/**\n * Comparator for `Array.prototype.sort`, ordering locators best-first per\n * {@link LOCATOR_PRIORITY}.\n */\nexport function compareLocators(a: Locator, b: Locator): number {\n return locatorRank(a.kind) - locatorRank(b.kind);\n}\n\n/** Return a new array of locators sorted best-first. Does not mutate input. */\nexport function rankLocators(locators: readonly Locator[]): Locator[] {\n return [...locators].sort(compareLocators);\n}\n\n/** The single most precise locator from a list, or `undefined` if empty. */\nexport function pickBestLocator(locators: readonly Locator[]): Locator | undefined {\n if (locators.length === 0) return undefined;\n return rankLocators(locators)[0];\n}\n\n/**\n * A compact, human- and agent-readable description of a locator, suitable for\n * embedding in instructions or logs.\n */\nexport function describeLocator(locator: Locator): string {\n switch (locator.kind) {\n case 'source':\n return `source:${locator.file}:${locator.line}${\n locator.column != null ? `:${locator.column}` : ''\n }`;\n case 'attr':\n return `attr:[${locator.attr}=\"${locator.value}\"]`;\n case 'behavioral':\n return `role:${locator.role}${locator.name ? ` name=\"${locator.name}\"` : ''}${\n locator.nth != null ? ` (nth=${locator.nth})` : ''\n }`;\n case 'dom':\n return `dom:${locator.selector}`;\n }\n}\n\n/** Whether a locator points directly at source (the strongest signal). */\nexport function isSourceResolved(locator: Locator): boolean {\n return locator.kind === 'source';\n}\n","import type { ExecutionOptions } from './types.js';\n\n/** Default localhost port the daemon listens on. */\nexport const DEFAULT_DAEMON_PORT = 8722;\n\n/** Default localhost host. ClickSmith only ever binds loopback. */\nexport const DEFAULT_DAEMON_HOST = '127.0.0.1';\n\n/** Default time-to-live for an unfinished capture session: 24 hours. */\nexport const DEFAULT_SESSION_TTL_MS = 24 * 60 * 60 * 1000;\n\n/**\n * The immutable safe defaults: plan mode, worktree isolation, no auto-apply.\n * Any change away from these is considered a \"risky option\".\n */\nexport const DEFAULT_EXECUTION_OPTIONS: ExecutionOptions = {\n mode: 'plan',\n isolation: 'worktree',\n autoApply: false,\n};\n\n/**\n * Whether a set of execution options deviates from the safe defaults and\n * therefore requires explicit user confirmation in the extension/CLI:\n * non-plan mode, in-place isolation, or auto-apply.\n */\nexport function requiresConfirmation(execution: ExecutionOptions): boolean {\n return execution.mode !== 'plan' || execution.isolation === 'inplace' || execution.autoApply;\n}\n\n/** Human-readable reasons a given execution config is considered risky. */\nexport function confirmationReasons(execution: ExecutionOptions): string[] {\n const reasons: string[] = [];\n if (execution.mode !== 'plan') {\n reasons.push('Edit mode lets the agent modify files directly instead of only proposing a plan.');\n }\n if (execution.isolation === 'inplace') {\n reasons.push('In-place isolation runs against your working tree instead of a throwaway worktree.');\n }\n if (execution.autoApply) {\n reasons.push('Auto-apply merges the agent’s changes back without a manual review step.');\n }\n return reasons;\n}\n","import { CaptureBundleSchema, CURRENT_BUNDLE_VERSION } from './schemas.js';\nimport { newSessionId, nextElementId } from './ids.js';\nimport { DEFAULT_EXECUTION_OPTIONS, DEFAULT_SESSION_TTL_MS } from './defaults.js';\nimport type {\n AppContext,\n CaptureBundle,\n CapturedElement,\n CapturedElementInput,\n ExecutionOptions,\n Session,\n} from './types.js';\n\nexport interface CreateSessionInput {\n app: AppContext;\n now?: Date;\n ttlMs?: number;\n id?: string;\n}\n\n/** Create a fresh, empty, active capture session. Pure. */\nexport function createSession(input: CreateSessionInput): Session {\n const now = input.now ?? new Date();\n const ttlMs = input.ttlMs ?? DEFAULT_SESSION_TTL_MS;\n const iso = now.toISOString();\n return {\n id: input.id ?? newSessionId(now),\n createdAt: iso,\n updatedAt: iso,\n expiresAt: new Date(now.getTime() + ttlMs).toISOString(),\n status: 'active',\n app: input.app,\n elements: [],\n lastElementId: 0,\n };\n}\n\n/**\n * Append a captured element to a session, assigning the next stable id. Returns\n * a new session plus the fully-formed element (so callers know the assigned id).\n * Pure — the input session is not mutated.\n */\nexport function appendElement(\n session: Session,\n input: CapturedElementInput,\n now: Date = new Date(),\n): { session: Session; element: CapturedElement } {\n const id = nextElementId(\n session.elements.map((e) => e.id),\n session.lastElementId,\n );\n const element: CapturedElement = { ...input, id };\n const next: Session = {\n ...session,\n elements: [...session.elements, element],\n lastElementId: id,\n updatedAt: now.toISOString(),\n };\n return { session: next, element };\n}\n\n/**\n * Remove a captured element by id. Ids are never renumbered, keeping existing\n * `#N` references valid. Returns the new session and whether anything changed.\n * Pure.\n */\nexport function removeElement(\n session: Session,\n elementId: number,\n now: Date = new Date(),\n): { session: Session; removed: boolean } {\n const elements = session.elements.filter((e) => e.id !== elementId);\n const removed = elements.length !== session.elements.length;\n if (!removed) return { session, removed: false };\n return {\n session: { ...session, elements, updatedAt: now.toISOString() },\n removed: true,\n };\n}\n\n/** Find a captured element by its `#N` id. */\nexport function findElement(session: Session, elementId: number): CapturedElement | undefined {\n return session.elements.find((e) => e.id === elementId);\n}\n\n/** Whether a session has passed its expiry (and was never submitted). */\nexport function isExpired(session: Session, now: Date = new Date()): boolean {\n if (session.status === 'submitted') return false;\n return new Date(session.expiresAt).getTime() <= now.getTime();\n}\n\n/** Slide a session's expiry forward by `ttlMs` from `now`. Pure. */\nexport function touchSession(\n session: Session,\n now: Date = new Date(),\n ttlMs: number = DEFAULT_SESSION_TTL_MS,\n): Session {\n return {\n ...session,\n updatedAt: now.toISOString(),\n expiresAt: new Date(now.getTime() + ttlMs).toISOString(),\n };\n}\n\nexport interface FinalizeInput {\n prompt: string;\n execution?: ExecutionOptions;\n submittedAt?: Date;\n enrichment?: CaptureBundle['enrichment'];\n}\n\n/**\n * Finalize a session into a validated v5 {@link CaptureBundle}. Throws if the\n * session has no elements or the prompt is empty. Does not mutate the session.\n */\nexport function finalizeSession(session: Session, input: FinalizeInput): CaptureBundle {\n if (session.elements.length === 0) {\n throw new Error(`Cannot finalize session ${session.id}: no captured elements.`);\n }\n if (!input.prompt.trim()) {\n throw new Error(`Cannot finalize session ${session.id}: prompt is empty.`);\n }\n const bundle: CaptureBundle = {\n v: CURRENT_BUNDLE_VERSION,\n sessionId: session.id,\n submittedAt: (input.submittedAt ?? new Date()).toISOString(),\n prompt: input.prompt.trim(),\n app: session.app,\n elements: session.elements,\n execution: input.execution ?? { ...DEFAULT_EXECUTION_OPTIONS },\n ...(input.enrichment ? { enrichment: input.enrichment } : {}),\n };\n // Validate before handing off; surfaces schema regressions early.\n return CaptureBundleSchema.parse(bundle);\n}\n","import type { z } from 'zod';\nimport { CaptureBundleSchema, CURRENT_BUNDLE_VERSION } from './schemas.js';\nimport type { CaptureBundle } from './types.js';\n\nexport type ValidationResult =\n | { ok: true; bundle: CaptureBundle }\n | { ok: false; error: z.ZodError };\n\n/** Validate an unknown value as a {@link CaptureBundle} without throwing. */\nexport function validateBundle(value: unknown): ValidationResult {\n const result = CaptureBundleSchema.safeParse(value);\n if (result.success) return { ok: true, bundle: result.data };\n return { ok: false, error: result.error };\n}\n\n/** Validate and throw on failure (with a readable message). */\nexport function parseBundle(value: unknown): CaptureBundle {\n const result = validateBundle(value);\n if (result.ok) return result.bundle;\n throw new Error(`Invalid CaptureBundle: ${result.error.message}`);\n}\n\n/** Deterministically serialize a bundle to JSON (stable key order, 2-space). */\nexport function serializeBundle(bundle: CaptureBundle): string {\n return JSON.stringify(parseBundle(bundle), stableReplacer(), 2);\n}\n\n/** Parse a JSON string into a validated bundle. */\nexport function deserializeBundle(json: string): CaptureBundle {\n let parsed: unknown;\n try {\n parsed = JSON.parse(json);\n } catch (err) {\n throw new Error(`CaptureBundle is not valid JSON: ${(err as Error).message}`);\n }\n return parseBundle(parsed);\n}\n\n/** Whether a value claims to be the current bundle version. */\nexport function isCurrentVersion(value: unknown): boolean {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { v?: unknown }).v === CURRENT_BUNDLE_VERSION\n );\n}\n\n/**\n * A JSON.stringify replacer that emits object keys in sorted order, producing\n * byte-stable output for hashing / golden-file comparisons.\n */\nfunction stableReplacer(): (this: unknown, key: string, value: unknown) => unknown {\n return function (_key, value) {\n if (value && typeof value === 'object' && !Array.isArray(value)) {\n const sorted: Record<string, unknown> = {};\n for (const k of Object.keys(value as Record<string, unknown>).sort()) {\n sorted[k] = (value as Record<string, unknown>)[k];\n }\n return sorted;\n }\n return value;\n };\n}\n","import { z } from 'zod';\nimport {\n AppContextSchema,\n CapturedElementSchema,\n EnrichmentSchema,\n ExecutionOptionsSchema,\n} from './schemas.js';\nimport type { CaptureBundle, CapturedElement, Session } from './types.js';\n\n/* -------------------------------------------------------------------------- */\n/* HTTP request / response DTOs */\n/* -------------------------------------------------------------------------- */\n\n/** The element payload the extension sends (everything but the daemon id). */\nexport const CapturedElementInputSchema = CapturedElementSchema.omit({ id: true });\n\nexport const CaptureRequestSchema = z.object({\n /** Append to this session if present; otherwise the daemon opens one. */\n sessionId: z.string().optional(),\n app: AppContextSchema,\n element: CapturedElementInputSchema,\n});\nexport type CaptureRequest = z.infer<typeof CaptureRequestSchema>;\n\nexport interface CaptureResponse {\n sessionId: string;\n element: CapturedElement;\n}\n\nexport const SubmitRequestSchema = z.object({\n sessionId: z.string().min(1),\n prompt: z.string().min(1),\n execution: ExecutionOptionsSchema.partial().optional(),\n enrichment: EnrichmentSchema.optional(),\n});\nexport type SubmitRequest = z.infer<typeof SubmitRequestSchema>;\n\nexport interface SubmitResponse {\n runId: string;\n bundle: CaptureBundle;\n}\n\n/** One-shot fast path: send all captured elements + prompt in a single request. */\nexport const RunRequestSchema = z.object({\n app: AppContextSchema,\n elements: z.array(CapturedElementInputSchema).min(1),\n prompt: z.string().min(1),\n execution: ExecutionOptionsSchema.partial().optional(),\n enrichment: EnrichmentSchema.optional(),\n});\nexport type RunRequest = z.infer<typeof RunRequestSchema>;\n\nexport interface RunResponse {\n runId: string;\n sessionId: string;\n bundle: CaptureBundle;\n}\n\nexport interface ApplyResponse {\n applied: boolean;\n commit?: string;\n conflicts?: string[];\n}\n\nexport interface HealthResponse {\n ok: true;\n name: 'clicksmith-daemon';\n version: string;\n host: string;\n port: number;\n repoRoot: string | null;\n activeSessions: number;\n}\n\nexport type SessionResponse = Session;\n\nexport interface RemoveElementResponse {\n removed: boolean;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Run state */\n/* -------------------------------------------------------------------------- */\n\nexport const RunStatusSchema = z.enum([\n 'pending',\n 'running',\n 'plan-ready',\n 'done',\n 'applying',\n 'applied',\n 'error',\n 'apply-error',\n]);\nexport type RunStatus = z.infer<typeof RunStatusSchema>;\n\nexport interface RunSummary {\n runId: string;\n sessionId: string;\n agentId: string;\n status: RunStatus;\n createdAt: string;\n sandbox: SandboxInfo | null;\n}\n\nexport interface SandboxInfo {\n isolation: 'worktree' | 'branch' | 'inplace';\n path: string;\n branch: string | null;\n baseCommit: string;\n}\n\n/* -------------------------------------------------------------------------- */\n/* WebSocket event protocol */\n/* -------------------------------------------------------------------------- */\n\n/** Events streamed from daemon to the extension over the WebSocket. */\nexport type ServerEvent =\n | { type: 'capture-ack'; sessionId: string; element: CapturedElement }\n | { type: 'element-removed'; sessionId: string; elementId: number }\n | { type: 'agent-started'; runId: string; sessionId: string; agentId: string; sandbox: SandboxInfo | null }\n | { type: 'agent-log'; runId: string; stream: 'stdout' | 'stderr'; chunk: string }\n | { type: 'plan-ready'; runId: string; plan?: string; diff?: string }\n | { type: 'agent-done'; runId: string; exitCode: number }\n | { type: 'agent-error'; runId: string; message: string }\n | { type: 'apply-started'; runId: string }\n | { type: 'apply-done'; runId: string; commit?: string }\n | { type: 'apply-error'; runId: string; message: string; conflicts?: string[] };\n\nexport type ServerEventType = ServerEvent['type'];\n\n/** Messages the extension may send to the daemon over the WebSocket. */\nexport type ClientMessage =\n | { type: 'subscribe'; sessionId?: string }\n | { type: 'ping' };\n\n/** Ordered list of every WS event type, useful for tests and docs. */\nexport const SERVER_EVENT_TYPES = [\n 'capture-ack',\n 'element-removed',\n 'agent-started',\n 'agent-log',\n 'plan-ready',\n 'agent-done',\n 'agent-error',\n 'apply-started',\n 'apply-done',\n 'apply-error',\n] as const satisfies readonly ServerEventType[];\n"]}
|
package/package.json
CHANGED