@tangle-network/agent-runtime 0.128.0 → 0.131.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +70 -20
  2. package/dist/{activation-DhWJ3p8N.js → activation-BCzMOTaV.js} +3 -3
  3. package/dist/{activation-DhWJ3p8N.js.map → activation-BCzMOTaV.js.map} +1 -1
  4. package/dist/agent.d.ts +2 -3
  5. package/dist/agent.js +4 -5
  6. package/dist/agent.js.map +1 -1
  7. package/dist/{analyst-loop-DvSciOfB.js → analyst-loop-BE8cDs5Q.js} +2 -2
  8. package/dist/{analyst-loop-DvSciOfB.js.map → analyst-loop-BE8cDs5Q.js.map} +1 -1
  9. package/dist/analyst-loop.d.ts +1 -1
  10. package/dist/analyst-loop.js +1 -1
  11. package/dist/authoring-CvHwo1oW.js +163 -0
  12. package/dist/authoring-CvHwo1oW.js.map +1 -0
  13. package/dist/candidate-execution/index.js +4 -4
  14. package/dist/{candidate-execution-BFpq-Xi6.js → candidate-execution-BNxKr-Bu.js} +5 -5
  15. package/dist/{candidate-execution-BFpq-Xi6.js.map → candidate-execution-BNxKr-Bu.js.map} +1 -1
  16. package/dist/{conversation-BpLQZGPH.js → conversation-DNtxaJ1Z.js} +113 -31
  17. package/dist/conversation-DNtxaJ1Z.js.map +1 -0
  18. package/dist/conversation.d.ts +2 -2
  19. package/dist/conversation.js +2 -2
  20. package/dist/environment-provider-CxvSd1W6.d.ts +86 -0
  21. package/dist/{environment-provider-DqFS6FSZ.js → environment-provider-Dyg8DtLK.js} +8 -4
  22. package/dist/environment-provider-Dyg8DtLK.js.map +1 -0
  23. package/dist/environment-provider.d.ts +1 -1
  24. package/dist/environment-provider.js +1 -1
  25. package/dist/graph-BJTxGOFB.js +471 -0
  26. package/dist/graph-BJTxGOFB.js.map +1 -0
  27. package/dist/{improvement-cycle-IJgCbKWQ.js → improvement-cycle-Csp38cWg.js} +133 -224
  28. package/dist/improvement-cycle-Csp38cWg.js.map +1 -0
  29. package/dist/{index-BhZhQw77.d.ts → index-CoO7atyo.d.ts} +556 -1278
  30. package/dist/{index-BhuzfG2r.d.ts → index-DwGtu9nc.d.ts} +7 -9
  31. package/dist/{index-Efjb3nrQ.d.ts → index-qYHpsmG2.d.ts} +36 -18
  32. package/dist/index.d.ts +353 -11
  33. package/dist/index.js +111 -354
  34. package/dist/index.js.map +1 -1
  35. package/dist/intelligence.d.ts +6 -6
  36. package/dist/intelligence.js +9 -8
  37. package/dist/intelligence.js.map +1 -1
  38. package/dist/kernel.d.ts +7 -5
  39. package/dist/kernel.js +13 -9
  40. package/dist/{knowledge-DF63xPr4.js → knowledge-ce0_uKCl.js} +19 -17
  41. package/dist/knowledge-ce0_uKCl.js.map +1 -0
  42. package/dist/knowledge.d.ts +1 -1
  43. package/dist/knowledge.js +1 -1
  44. package/dist/{loop-runner-bin-Ckp_9tmD.d.ts → loop-runner-bin-BwgZ8m_7.d.ts} +6 -3
  45. package/dist/{loop-runner-bin-CWqOpCEw.js → loop-runner-bin-DSbuDDqM.js} +5 -27
  46. package/dist/loop-runner-bin-DSbuDDqM.js.map +1 -0
  47. package/dist/loop-runner-bin.d.ts +1 -1
  48. package/dist/loop-runner-bin.js +1 -1
  49. package/dist/materialization-COJ1UYQ-.js +272 -0
  50. package/dist/materialization-COJ1UYQ-.js.map +1 -0
  51. package/dist/mcp/bin.js +39 -47
  52. package/dist/mcp/bin.js.map +1 -1
  53. package/dist/mcp/index.d.ts +24 -26
  54. package/dist/mcp/index.js +66 -83
  55. package/dist/mcp/index.js.map +1 -1
  56. package/dist/mcp/memory-bin.js +1 -1
  57. package/dist/{memory-server-DL6cE2Ag.js → memory-server-5HEJH672.js} +2 -2
  58. package/dist/{memory-server-DL6cE2Ag.js.map → memory-server-5HEJH672.js.map} +1 -1
  59. package/dist/model-policy-CqziaqS1.js +232 -0
  60. package/dist/model-policy-CqziaqS1.js.map +1 -0
  61. package/dist/{openai-tools-B68JaOCx.d.ts → openai-tools-D3oMyVGl.d.ts} +2 -2
  62. package/dist/{openai-tools-D3XfrrQ6.js → openai-tools-ru75mLjq.js} +2 -2
  63. package/dist/openai-tools-ru75mLjq.js.map +1 -0
  64. package/dist/{prepare--8EvLqCr.js → prepare-DYWjVcPx.js} +169 -153
  65. package/dist/prepare-DYWjVcPx.js.map +1 -0
  66. package/dist/primeintellect/index.d.ts +7 -6
  67. package/dist/primeintellect/index.js +9 -11
  68. package/dist/primeintellect/index.js.map +1 -1
  69. package/dist/profiles.d.ts +21 -174
  70. package/dist/profiles.js +67 -276
  71. package/dist/profiles.js.map +1 -1
  72. package/dist/{protected-model-port-CXVfOUu_.js → protected-model-port-48ALLGxT.js} +2 -2
  73. package/dist/{protected-model-port-CXVfOUu_.js.map → protected-model-port-48ALLGxT.js.map} +1 -1
  74. package/dist/{redact-PQzmE1Jn.d.ts → redact-9_Gf-8m3.d.ts} +58 -69
  75. package/dist/{researcher-CoVqNhfI.js → researcher-Skz5-Uc8.js} +50 -26
  76. package/dist/researcher-Skz5-Uc8.js.map +1 -0
  77. package/dist/{run-layout-C2FGmZ3v.js → run-layout-CeJsEAom.js} +2 -2
  78. package/dist/{run-layout-C2FGmZ3v.js.map → run-layout-CeJsEAom.js.map} +1 -1
  79. package/dist/runtime-D-QfLbSd.d.ts +893 -0
  80. package/dist/{runtime-5uDVVfER.js → runtime-hiAABiTk.js} +315 -1191
  81. package/dist/runtime-hiAABiTk.js.map +1 -0
  82. package/dist/{sandbox-events-Yhd1GYWl.js → sandbox-events-CRDwc5WN.js} +42 -5
  83. package/dist/sandbox-events-CRDwc5WN.js.map +1 -0
  84. package/dist/snapshot-CXiiuHhL.js +21 -0
  85. package/dist/snapshot-CXiiuHhL.js.map +1 -0
  86. package/dist/{spawn-journal-DsZKDqeh.js → spawn-journal-saHQzqYi.js} +15 -21
  87. package/dist/spawn-journal-saHQzqYi.js.map +1 -0
  88. package/dist/stream-agent-turn-C852AgMT.d.ts +128 -0
  89. package/dist/stream-agent-turn-rYgaOLO0.js +910 -0
  90. package/dist/stream-agent-turn-rYgaOLO0.js.map +1 -0
  91. package/dist/{structural-rollout-zY0oqQzO.js → structural-rollout-3uxVGcg2.js} +459 -235
  92. package/dist/structural-rollout-3uxVGcg2.js.map +1 -0
  93. package/dist/{supervise-CsTKbH9R.js → supervise-iPN27pO0.js} +864 -4785
  94. package/dist/supervise-iPN27pO0.js.map +1 -0
  95. package/dist/{supervisor-DpjO0Gmy.js → supervisor-CV6Jh28D.js} +7439 -2897
  96. package/dist/supervisor-CV6Jh28D.js.map +1 -0
  97. package/dist/testing.d.ts +3 -1
  98. package/dist/testing.js +271 -221
  99. package/dist/testing.js.map +1 -1
  100. package/dist/{top-app-5unxqovu.js → top-app-G4M18b6i.js} +3 -3
  101. package/dist/{top-app-5unxqovu.js.map → top-app-G4M18b6i.js.map} +1 -1
  102. package/dist/tui/bin.js +1 -1
  103. package/dist/tui/index.js +1 -1
  104. package/dist/{environment-provider-CUFsyymu.d.ts → types-C6Q-J0Dt.d.ts} +51 -114
  105. package/dist/{types-DnNGJ5Gz.d.ts → types-ebIY0dMG.d.ts} +556 -30
  106. package/dist/{util-MVgdwuIS.js → util-Bw6srryQ.js} +3 -2
  107. package/dist/{util-MVgdwuIS.js.map → util-Bw6srryQ.js.map} +1 -1
  108. package/dist/{workspace-archive-BQxvkypI.js → workspace-archive-aOfJ47ms.js} +3 -3
  109. package/dist/{workspace-archive-BQxvkypI.js.map → workspace-archive-aOfJ47ms.js.map} +1 -1
  110. package/package.json +12 -15
  111. package/skills/agent-graphs/IMPROVE.md +3 -3
  112. package/skills/agent-graphs/SKILL.md +4 -5
  113. package/skills/agent-graphs/cases/review-pipeline.json +1 -2
  114. package/skills/agent-graphs/cases/unmeasured-harness.json +2 -4
  115. package/dist/backends-CiOCyRHb.js +0 -743
  116. package/dist/backends-CiOCyRHb.js.map +0 -1
  117. package/dist/conversation-BpLQZGPH.js.map +0 -1
  118. package/dist/environment-provider-DqFS6FSZ.js.map +0 -1
  119. package/dist/improvement-cycle-IJgCbKWQ.js.map +0 -1
  120. package/dist/index-DLM0W1h1.d.ts +0 -545
  121. package/dist/knowledge-DF63xPr4.js.map +0 -1
  122. package/dist/local-harness-BIajef4A.d.ts +0 -465
  123. package/dist/loop-runner-bin-CWqOpCEw.js.map +0 -1
  124. package/dist/model-resolution-Btd9iIKV.js +0 -98
  125. package/dist/model-resolution-Btd9iIKV.js.map +0 -1
  126. package/dist/openai-tools-D3XfrrQ6.js.map +0 -1
  127. package/dist/prepare--8EvLqCr.js.map +0 -1
  128. package/dist/researcher-CoVqNhfI.js.map +0 -1
  129. package/dist/runtime-5uDVVfER.js.map +0 -1
  130. package/dist/sandbox-events-Yhd1GYWl.js.map +0 -1
  131. package/dist/spawn-journal-DsZKDqeh.js.map +0 -1
  132. package/dist/structural-rollout-zY0oqQzO.js.map +0 -1
  133. package/dist/supervise-CsTKbH9R.js.map +0 -1
  134. package/dist/supervisor-DpjO0Gmy.js.map +0 -1
  135. package/dist/types-C9j4qg6l.d.ts +0 -500
  136. package/skills/agent-graphs/cases/floor-trap-pi.json +0 -11
@@ -1,4 +1,4 @@
1
- import { E as SandboxClient, k as Validator, r as Driver, t as AgentRunSpec, w as OutputAdapter } from "./types-DnNGJ5Gz.js";
1
+ import { k as Validator, r as Driver, t as AgentRunSpec, w as OutputAdapter } from "./types-ebIY0dMG.js";
2
2
  import { a as UiFindingSeverity, c as coderTaskToPrompt, i as UiFindingScreenshot, n as UI_LENSES, o as UiLens, r as UiFinding, s as CoderTask, t as UI_FINDING_SEVERITIES } from "./substrate-BcnuSHXm.js";
3
3
  import { AgentProfile } from "@tangle-network/agent-interface";
4
4
  import { SandboxEvent } from "@tangle-network/sandbox";
@@ -170,13 +170,11 @@ interface ResearchOutput {
170
170
  }
171
171
  /** Options for the source-grounded researcher profile preset. @experimental */
172
172
  interface ResearcherProfileOptions {
173
- /** Sandbox-SDK backend.type. Default `'opencode/zai-coding-plan/glm-5.1'`. */
174
- harness?: string;
175
- /** Default model id passed in `AgentProfile.model.default`. */
176
- model?: string;
173
+ /** Caller-owned exact harness/provider/model identity. */
174
+ profile: AgentProfile;
177
175
  /** Custom system prompt replacement. Default = built-in researcher preset. */
178
176
  systemPrompt?: string;
179
- /** Stable name for `AgentRunSpec.name`. Default = `researcher-${harness}`. */
177
+ /** Stable name for `AgentRunSpec.name`. Default = `profile.name`. */
180
178
  name?: string;
181
179
  /**
182
180
  * Default 0.7. Minimum (citations with quote) / items ratio for `valid=true`.
@@ -185,7 +183,7 @@ interface ResearcherProfileOptions {
185
183
  citationDensityMin?: number;
186
184
  }
187
185
  /** Build a source-grounded researcher profile with output parsing and validation. @experimental */
188
- declare function researcherProfile(options?: ResearcherProfileOptions & {
186
+ declare function researcherProfile(options: ResearcherProfileOptions & {
189
187
  task?: ResearchTask;
190
188
  }): {
191
189
  profile: AgentProfile;
@@ -196,10 +194,8 @@ declare function researcherProfile(options?: ResearcherProfileOptions & {
196
194
  };
197
195
  /** @experimental */
198
196
  interface MultiHarnessResearcherFanoutOptions {
199
- /** Backend.type identifiers, one per parallel agent. */
200
- harnesses?: string[];
201
- /** Optional per-harness model override. Indexed parallel to `harnesses`. */
202
- models?: (string | undefined)[];
197
+ /** Exact execution profiles, one per parallel researcher. */
198
+ profiles: ReadonlyArray<AgentProfile>;
203
199
  /** Default citation density floor for the shared validator. */
204
200
  citationDensityMin?: number;
205
201
  /** Optional task — narrows the validator's namespace check. */
@@ -212,7 +208,7 @@ interface MultiHarnessResearcherFanoutOptions {
212
208
  *
213
209
  * @experimental
214
210
  */
215
- declare function multiHarnessResearcherFanout(options?: MultiHarnessResearcherFanoutOptions): {
211
+ declare function multiHarnessResearcherFanout(options: MultiHarnessResearcherFanoutOptions): {
216
212
  agentRuns: AgentRunSpec<ResearchTask>[];
217
213
  output: OutputAdapter<ResearchOutput>;
218
214
  validator: Validator<ResearchOutput>;
@@ -242,6 +238,18 @@ declare function createResearcherValidator(task: ResearchTask, config?: {
242
238
  namespaceCheck?: boolean;
243
239
  }): Validator<ResearchOutput>;
244
240
  //#endregion
241
+ //#region src/profiles/ui-auditor/lens-prompts.d.ts
242
+ /** Cross-lens rules injected into every UI audit iteration: finding quality standards and scope limits. @experimental */
243
+ declare const SHARED_AUDITOR_RULES: string;
244
+ /** Per-lens auditor briefs: concrete signals to look for and cross-lens distinctions to respect. @experimental */
245
+ declare const LENS_BRIEFS: Record<UiLens, string>;
246
+ /**
247
+ * Build a system prompt for a single auditor iteration.
248
+ *
249
+ * @experimental
250
+ */
251
+ declare function buildAuditorSystemPrompt(lens: UiLens): string;
252
+ //#endregion
245
253
  //#region src/profiles/ui-auditor/task.d.ts
246
254
  /** @experimental */
247
255
  interface UiAuditViewport {
@@ -325,171 +333,10 @@ interface UiAuditOutput {
325
333
  notes?: string;
326
334
  }
327
335
  //#endregion
328
- //#region src/profiles/ui-auditor/judge.d.ts
329
- /** @experimental */
330
- interface UiJudgeTokenUsage {
331
- input: number;
332
- output: number;
333
- }
334
- /** @experimental */
335
- interface UiJudgeInput {
336
- lens: UiLens;
337
- captures: readonly UiAuditCapture[];
338
- /** Free-form product context the consumer wants the judge to know. */
339
- productContext?: string;
340
- /** Findings already on file across earlier iterations — for similarTo linkage. */
341
- knownFindingIds?: readonly number[];
342
- /** The full prompt the loop kernel synthesized for this iteration. */
343
- promptText: string;
344
- /** Cooperative cancellation. */
345
- signal: AbortSignal;
346
- }
347
- /** @experimental */
348
- interface UiJudgeOutput {
349
- findings: UiFinding[];
350
- /** Optional triage commentary. */
351
- notes?: string;
352
- /** Optional usage; folded into the kernel cost ledger when present. */
353
- tokenUsage?: UiJudgeTokenUsage;
354
- /** Optional total cost in USD. */
355
- costUsd?: number;
356
- }
357
- /** @experimental */
358
- type UiJudge = (input: UiJudgeInput) => Promise<UiJudgeOutput>;
359
- //#endregion
360
- //#region src/profiles/ui-auditor/in-process-client.d.ts
361
- /** @experimental */
362
- interface InProcessUiAuditClientOptions {
363
- /**
364
- * Absolute path under which screenshots are written. Each capture lands
365
- * at `<workspaceDir>/screenshots/<filename>`; finding screenshot paths
366
- * are workspace-relative (`screenshots/<filename>`).
367
- */
368
- workspaceDir: string;
369
- /** The vision judge that turns captures into findings. */
370
- judge: UiJudge;
371
- /**
372
- * Navigation policy.
373
- *
374
- * `'strict'` (default) waits for `networkidle` and fails the iteration
375
- * if the page does not settle. `'spa'` waits for `domcontentloaded` —
376
- * use for single-page apps that hold open long-poll/websocket
377
- * connections and never settle.
378
- */
379
- navPolicy?: 'strict' | 'spa';
380
- /**
381
- * Browser launch override. Default: chromium headless via Playwright.
382
- * Consumers pass a custom factory to target a remote browser, a
383
- * different channel, or a fleet adapter.
384
- */
385
- launchBrowser?: () => Promise<BrowserHandle>;
386
- }
387
- /** @experimental */
388
- interface BrowserHandle {
389
- newContext(options?: {
390
- viewport?: {
391
- width: number;
392
- height: number;
393
- };
394
- }): Promise<BrowserContextHandle>;
395
- close(): Promise<void>;
396
- }
397
- /** @experimental */
398
- interface BrowserContextHandle {
399
- newPage(): Promise<PageHandle>;
400
- close(): Promise<void>;
401
- }
402
- /** @experimental */
403
- interface PageHandle {
404
- setViewportSize(size: {
405
- width: number;
406
- height: number;
407
- }): Promise<void>;
408
- goto(url: string, options?: {
409
- waitUntil?: string;
410
- timeout?: number;
411
- }): Promise<unknown>;
412
- waitForSelector(selector: string, options?: {
413
- timeout?: number;
414
- }): Promise<unknown>;
415
- waitForTimeout(ms: number): Promise<void>;
416
- screenshot(options: {
417
- path: string;
418
- fullPage?: boolean;
419
- }): Promise<void>;
420
- locator(selector: string): {
421
- first(): {
422
- screenshot(options: {
423
- path: string;
424
- }): Promise<void>;
425
- };
426
- };
427
- }
428
- /** Create a `SandboxClient` that drives a local Playwright browser for in-process UI audits. @experimental */
429
- declare function createInProcessUiAuditClient(options: InProcessUiAuditClientOptions): SandboxClient & {
430
- /**
431
- * Close the underlying browser. Idempotent.
432
- *
433
- * Contract: callers MUST ensure no iterations are in flight when this is
434
- * called. The kernel respects this — `runAgentRounds` awaits every iteration
435
- * before returning, so `await runAgentRounds(...); await client.close()` is the
436
- * intended pattern (see `examples/ui-audit`). If `close()` is invoked
437
- * concurrently with a running iteration, the browser teardown will race
438
- * against in-flight page operations; the iteration will surface an
439
- * AggregateError carrying both the iteration error and the close error,
440
- * but no work is lost silently.
441
- */
442
- close(): Promise<void>;
443
- };
444
- //#endregion
445
- //#region src/profiles/ui-auditor/lens-prompts.d.ts
446
- /** Cross-lens rules injected into every UI audit iteration: finding quality standards and scope limits. @experimental */
447
- declare const SHARED_AUDITOR_RULES: string;
448
- /** Per-lens auditor briefs: concrete signals to look for and cross-lens distinctions to respect. @experimental */
449
- declare const LENS_BRIEFS: Record<UiLens, string>;
450
- /**
451
- * Build a system prompt for a single auditor iteration.
452
- *
453
- * @experimental
454
- */
455
- declare function buildAuditorSystemPrompt(lens: UiLens): string;
456
- //#endregion
457
336
  //#region src/profiles/ui-auditor/output-adapter.d.ts
458
337
  /** Parse raw `SandboxEvent` emissions from an audit iteration into structured `UiAuditOutput`. @experimental */
459
338
  declare function parseAuditorEvents(events: SandboxEvent[]): UiAuditOutput;
460
339
  //#endregion
461
- //#region src/profiles/ui-auditor/profile.d.ts
462
- /** @experimental */
463
- interface UiAuditorProfileOptions {
464
- /**
465
- * Stable name surfaced in trace events. Defaults to `ui-auditor`.
466
- */
467
- name?: string;
468
- /**
469
- * Optional model identifier passed in `AgentProfile.model.default`.
470
- * The consumer's `SandboxClient` chooses how to interpret it.
471
- */
472
- model?: string;
473
- /**
474
- * Task bound to the validator. Without it the validator uses the lens
475
- * embedded in the iteration output as its expectation — fine for one-off
476
- * use; less strict than passing the task explicitly.
477
- */
478
- task?: UiAuditTask;
479
- }
480
- /**
481
- * Preset `runAgentRounds` bundle for vision-driven UI audits: returns the `AgentRunSpec`, output adapter, validator, and prompt formatter the loop kernel needs.
482
- *
483
- * @experimental
484
- */
485
- declare function uiAuditorProfile(options?: UiAuditorProfileOptions): {
486
- profile: AgentProfile;
487
- taskToPrompt: (task: UiAuditTask) => string;
488
- output: OutputAdapter<UiAuditOutput>;
489
- validator: Validator<UiAuditOutput>;
490
- agentRunSpec: AgentRunSpec<UiAuditTask>;
491
- };
492
- //#endregion
493
340
  //#region src/profiles/ui-auditor/prompt.d.ts
494
341
  /** Wrap a `UiAuditTask` in a machine-readable envelope so iterations are self-describing. @experimental */
495
342
  declare function encodeAuditTaskEnvelope(task: UiAuditTask): string;
@@ -508,5 +355,5 @@ declare function formatAuditorPrompt(task: UiAuditTask): string;
508
355
  /** Build a `Validator` that rejects off-lens findings and findings missing screenshot evidence. @experimental */
509
356
  declare function createUiAuditorValidator(task: UiAuditTask): Validator<UiAuditOutput>;
510
357
  //#endregion
511
- export { type AppendFindingsResult, type AuditIndex, type AuditRegistry, type AuditRegistryCapture, type BrowserContextHandle, type BrowserHandle, type CoderTask, type InProcessUiAuditClientOptions, type KnowledgeItem, type KnowledgeUpdate, LENS_BRIEFS, type MultiHarnessResearcherFanoutOptions, type PageHandle, type RegisterCapturesOptions, type ResearchOutput, type ResearchSource, type ResearchTask, type ResearcherProfileOptions, SHARED_AUDITOR_RULES, UI_FINDING_SEVERITIES, UI_LENSES, type UiAuditCapture, type UiAuditCaptureRequest, type UiAuditOutput, type UiAuditTask, type UiAuditViewport, type UiAuditorProfileOptions, type UiFinding, type UiFindingScreenshot, type UiFindingSeverity, type UiJudge, type UiJudgeInput, type UiJudgeOutput, type UiJudgeTokenUsage, type UiLens, appendFindings, buildAuditorSystemPrompt, coderTaskToPrompt, createInProcessUiAuditClient, createResearcherValidator, createUiAuditorValidator, decodeAuditTaskEnvelope, encodeAuditTaskEnvelope, formatAuditorPrompt, initAuditWorkspace, multiHarnessResearcherFanout, parseAuditorEvents, readAuditRegistry, registerCaptures, researcherProfile, summarizeRegistry, uiAuditorProfile, writeAuditIndex };
358
+ export { type AppendFindingsResult, type AuditIndex, type AuditRegistry, type AuditRegistryCapture, type CoderTask, type KnowledgeItem, type KnowledgeUpdate, LENS_BRIEFS, type MultiHarnessResearcherFanoutOptions, type RegisterCapturesOptions, type ResearchOutput, type ResearchSource, type ResearchTask, type ResearcherProfileOptions, SHARED_AUDITOR_RULES, UI_FINDING_SEVERITIES, UI_LENSES, type UiAuditCapture, type UiAuditCaptureRequest, type UiAuditOutput, type UiAuditTask, type UiAuditViewport, type UiFinding, type UiFindingScreenshot, type UiFindingSeverity, type UiLens, appendFindings, buildAuditorSystemPrompt, coderTaskToPrompt, createResearcherValidator, createUiAuditorValidator, decodeAuditTaskEnvelope, encodeAuditTaskEnvelope, formatAuditorPrompt, initAuditWorkspace, multiHarnessResearcherFanout, parseAuditorEvents, readAuditRegistry, registerCaptures, researcherProfile, summarizeRegistry, writeAuditIndex };
512
359
  //# sourceMappingURL=profiles.d.ts.map
package/dist/profiles.js CHANGED
@@ -1,8 +1,8 @@
1
- import { n as multiHarnessResearcherFanout, r as researcherProfile, t as createResearcherValidator } from "./researcher-CoVqNhfI.js";
1
+ import { i as researcherProfile, n as createResearcherValidator, r as multiHarnessResearcherFanout } from "./researcher-Skz5-Uc8.js";
2
2
  import { n as UI_LENSES, t as UI_FINDING_SEVERITIES } from "./substrate-B0TYNrXn.js";
3
3
  import { t as coderTaskToPrompt } from "./coder-yhVWbdWc.js";
4
- import { promises } from "node:fs";
5
4
  import path from "node:path";
5
+ import { promises } from "node:fs";
6
6
  //#region src/profiles/ui-auditor/slugify.ts
7
7
  /**
8
8
  *
@@ -317,241 +317,6 @@ async function writeAuditIndex(workspaceDir) {
317
317
  return out;
318
318
  }
319
319
  //#endregion
320
- //#region src/profiles/ui-auditor/prompt.ts
321
- const ENVELOPE_BEGIN = "<<UI_AUDIT_TASK>>";
322
- const ENVELOPE_END = "<<UI_AUDIT_TASK_END>>";
323
- /** Wrap a `UiAuditTask` in a machine-readable envelope so iterations are self-describing. @experimental */
324
- function encodeAuditTaskEnvelope(task) {
325
- return `${ENVELOPE_BEGIN}${JSON.stringify(task)}${ENVELOPE_END}`;
326
- }
327
- /**
328
- * Parse a task envelope back out of a prompt string. Returns undefined if
329
- * the prompt does not contain a complete envelope OR if the payload is
330
- * not valid JSON.
331
- *
332
- * @experimental
333
- */
334
- function decodeAuditTaskEnvelope(prompt) {
335
- const start = prompt.indexOf(ENVELOPE_BEGIN);
336
- if (start === -1) return void 0;
337
- const payloadStart = start + 17;
338
- const end = prompt.indexOf(ENVELOPE_END, payloadStart);
339
- if (end === -1) return void 0;
340
- const payload = prompt.slice(payloadStart, end);
341
- try {
342
- const parsed = JSON.parse(payload);
343
- if (!parsed || typeof parsed !== "object") return void 0;
344
- const t = parsed;
345
- if (typeof t.lens !== "string" || !Array.isArray(t.captures)) return void 0;
346
- return t;
347
- } catch {
348
- return;
349
- }
350
- }
351
- /** Produce the user message for one audit iteration: lens, captures to take, and the task envelope. @experimental */
352
- function formatAuditorPrompt(task) {
353
- const lines = [];
354
- lines.push(`# UI audit iteration — lens: ${task.lens}`);
355
- lines.push("");
356
- if (task.productContext && task.productContext.trim().length > 0) {
357
- lines.push("## Product context");
358
- lines.push(task.productContext.trim());
359
- lines.push("");
360
- }
361
- lines.push("## Captures to take");
362
- task.captures.forEach((cap, i) => {
363
- const detail = [
364
- `viewport=${cap.viewport ? `${cap.viewport.width}x${cap.viewport.height}` : "1280x800 (default)"}`,
365
- cap.fullPage ? "fullPage=true" : null,
366
- cap.elementSelector ? `selector=\`${cap.elementSelector}\`` : null,
367
- cap.waitFor ? `waitFor=\`${cap.waitFor}\`` : null,
368
- cap.waitMs !== void 0 ? `waitMs=${cap.waitMs}` : null,
369
- cap.label ? `label=${cap.label}` : null
370
- ].filter((s) => s !== null).join(" · ");
371
- lines.push(`${i + 1}. route=\`${cap.route}\` url=${cap.url} ${detail ? `(${detail})` : ""}`);
372
- });
373
- lines.push("");
374
- if (task.knownFindingIds && task.knownFindingIds.length > 0) {
375
- lines.push("## Known findings (link via similarTo, do not refile)");
376
- lines.push(task.knownFindingIds.map((n) => `#${String(n).padStart(3, "0")}`).join(", "));
377
- lines.push("");
378
- }
379
- lines.push("## Output format");
380
- lines.push("Emit a single JSON object with the shape `{ findings: UiFinding[], notes?: string }` where every finding has the fields enumerated in your system prompt. The screenshots field on each finding must reference the captures above by path. Do not emit findings outside the lens.");
381
- return lines.join("\n");
382
- }
383
- //#endregion
384
- //#region src/profiles/ui-auditor/in-process-client.ts
385
- function asSandboxEvent(type, data) {
386
- return {
387
- type,
388
- data
389
- };
390
- }
391
- const DEFAULT_VIEWPORT = {
392
- width: 1280,
393
- height: 800
394
- };
395
- const NAV_TIMEOUT_MS = 3e4;
396
- async function defaultLaunch() {
397
- const mod = await import("playwright");
398
- if (!mod?.chromium || typeof mod.chromium.launch !== "function") throw new Error("ui-auditor: playwright is not installed. Install `playwright` (and run `playwright install chromium`) or pass a custom `launchBrowser` to createInProcessUiAuditClient.");
399
- return mod.chromium.launch({ headless: true });
400
- }
401
- function nowStamp() {
402
- const d = /* @__PURE__ */ new Date();
403
- const pad = (n) => String(n).padStart(2, "0");
404
- return `${d.getUTCFullYear()}${pad(d.getUTCMonth() + 1)}${pad(d.getUTCDate())}-${pad(d.getUTCHours())}${pad(d.getUTCMinutes())}${pad(d.getUTCSeconds())}-${String(d.getUTCMilliseconds()).padStart(3, "0")}`;
405
- }
406
- function viewportOf(req) {
407
- return req.viewport ?? DEFAULT_VIEWPORT;
408
- }
409
- function captureFilename(req) {
410
- const vp = viewportOf(req);
411
- const labelPart = req.label ? `--${slugify(req.label, "label")}` : "";
412
- return `${slugify(req.route, "route")}--${vp.width}x${vp.height}${labelPart}--${nowStamp()}.png`;
413
- }
414
- function assertHttpUrl(url) {
415
- let parsed;
416
- try {
417
- parsed = new URL(url);
418
- } catch {
419
- throw new Error(`ui-auditor: capture url is not parseable (got ${JSON.stringify(url)})`);
420
- }
421
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new Error(`ui-auditor: capture url must use http or https (got ${parsed.protocol} in ${JSON.stringify(url)})`);
422
- }
423
- async function captureOne(page, req, outAbsPath, signal, navPolicy) {
424
- signal.throwIfAborted();
425
- assertHttpUrl(req.url);
426
- await page.setViewportSize(viewportOf(req));
427
- const waitUntil = navPolicy === "spa" ? "domcontentloaded" : "networkidle";
428
- await page.goto(req.url, {
429
- waitUntil,
430
- timeout: NAV_TIMEOUT_MS
431
- });
432
- if (req.waitFor) await page.waitForSelector(req.waitFor, { timeout: 15e3 });
433
- const extra = req.waitMs ?? 500;
434
- if (extra > 0) await page.waitForTimeout(extra);
435
- signal.throwIfAborted();
436
- if (req.elementSelector) await page.locator(req.elementSelector).first().screenshot({ path: outAbsPath });
437
- else await page.screenshot({
438
- path: outAbsPath,
439
- fullPage: req.fullPage === true
440
- });
441
- }
442
- function makeSandboxId() {
443
- const rand = () => Math.random().toString(16).slice(2, 10);
444
- return `ui-audit-${rand()}${rand()}`;
445
- }
446
- /** Create a `SandboxClient` that drives a local Playwright browser for in-process UI audits. @experimental */
447
- function createInProcessUiAuditClient(options) {
448
- const launch = options.launchBrowser ?? defaultLaunch;
449
- const navPolicy = options.navPolicy ?? "strict";
450
- let browserPromise;
451
- let closed = false;
452
- async function getBrowser() {
453
- if (closed) throw new Error("ui-auditor: client is closed; create a new client to run another iteration");
454
- if (!browserPromise) browserPromise = launch();
455
- return browserPromise;
456
- }
457
- async function* runIteration(promptText, signal) {
458
- const task = decodeAuditTaskEnvelope(promptText);
459
- if (!task) throw new Error("ui-auditor: prompt is missing a UI_AUDIT_TASK envelope. Use uiAuditorProfile().taskToPrompt to format prompts, or pass an envelope-prefixed prompt manually.");
460
- if (task.captures.length === 0) throw new Error("ui-auditor: task has zero captures; nothing to audit.");
461
- yield asSandboxEvent("audit.lens", { lens: task.lens });
462
- const context = await (await getBrowser()).newContext({ viewport: DEFAULT_VIEWPORT });
463
- let primaryError;
464
- let closeError;
465
- try {
466
- const page = await context.newPage();
467
- const captures = [];
468
- const fs = await import("node:fs/promises");
469
- const path = await import("node:path");
470
- const shotsDir = path.join(options.workspaceDir, "screenshots");
471
- await fs.mkdir(shotsDir, { recursive: true });
472
- for (const req of task.captures) {
473
- signal.throwIfAborted();
474
- const filename = captureFilename(req);
475
- const absPath = path.join(shotsDir, filename);
476
- const relPath = `screenshots/${filename}`;
477
- await captureOne(page, req, absPath, signal, navPolicy);
478
- const vp = viewportOf(req);
479
- const cap = {
480
- path: relPath,
481
- viewport: `${vp.width}x${vp.height}`,
482
- fullPage: req.fullPage === true,
483
- route: req.route,
484
- url: req.url,
485
- capturedAt: (/* @__PURE__ */ new Date()).toISOString()
486
- };
487
- if (req.elementSelector) cap.elementSelector = req.elementSelector;
488
- if (req.label) cap.label = req.label;
489
- captures.push(cap);
490
- yield asSandboxEvent("audit.capture", cap);
491
- }
492
- const judgeOut = await options.judge({
493
- lens: task.lens,
494
- captures,
495
- productContext: task.productContext,
496
- knownFindingIds: task.knownFindingIds,
497
- promptText,
498
- signal
499
- });
500
- for (const finding of judgeOut.findings) yield asSandboxEvent("audit.finding", finding);
501
- if (judgeOut.notes && judgeOut.notes.trim().length > 0) yield asSandboxEvent("audit.notes", { notes: judgeOut.notes });
502
- const usage = judgeOut.tokenUsage ?? {
503
- input: 0,
504
- output: 0
505
- };
506
- yield asSandboxEvent("done", {
507
- tokenUsage: {
508
- inputTokens: usage.input,
509
- outputTokens: usage.output
510
- },
511
- totalCostUsd: judgeOut.costUsd ?? 0
512
- });
513
- } catch (err) {
514
- primaryError = err;
515
- } finally {
516
- try {
517
- await context.close();
518
- } catch (err) {
519
- closeError = err;
520
- }
521
- }
522
- if (primaryError !== void 0 && closeError !== void 0) throw new AggregateError([primaryError, closeError], "ui-auditor: iteration failed AND context.close() failed; both errors attached.");
523
- if (primaryError !== void 0) throw primaryError;
524
- if (closeError !== void 0) throw closeError;
525
- }
526
- function makeSyntheticSandbox() {
527
- return {
528
- id: makeSandboxId(),
529
- streamPrompt(message, opts) {
530
- return runIteration(message, opts?.signal ?? new AbortController().signal);
531
- },
532
- async delete() {}
533
- };
534
- }
535
- return {
536
- async create(_options) {
537
- return makeSyntheticSandbox();
538
- },
539
- describePlacement(box) {
540
- const id = box.id;
541
- return {
542
- kind: "sibling",
543
- sandboxId: typeof id === "string" ? id : void 0
544
- };
545
- },
546
- async close() {
547
- closed = true;
548
- const pending = browserPromise;
549
- browserPromise = void 0;
550
- if (pending) await (await pending).close();
551
- }
552
- };
553
- }
554
- //#endregion
555
320
  //#region src/profiles/ui-auditor/lens-prompts.ts
556
321
  /** Cross-lens rules injected into every UI audit iteration: finding quality standards and scope limits. @experimental */
557
322
  const SHARED_AUDITOR_RULES = `
@@ -734,6 +499,70 @@ function parseAuditorEvents(events) {
734
499
  return out;
735
500
  }
736
501
  //#endregion
502
+ //#region src/profiles/ui-auditor/prompt.ts
503
+ const ENVELOPE_BEGIN = "<<UI_AUDIT_TASK>>";
504
+ const ENVELOPE_END = "<<UI_AUDIT_TASK_END>>";
505
+ /** Wrap a `UiAuditTask` in a machine-readable envelope so iterations are self-describing. @experimental */
506
+ function encodeAuditTaskEnvelope(task) {
507
+ return `${ENVELOPE_BEGIN}${JSON.stringify(task)}${ENVELOPE_END}`;
508
+ }
509
+ /**
510
+ * Parse a task envelope back out of a prompt string. Returns undefined if
511
+ * the prompt does not contain a complete envelope OR if the payload is
512
+ * not valid JSON.
513
+ *
514
+ * @experimental
515
+ */
516
+ function decodeAuditTaskEnvelope(prompt) {
517
+ const start = prompt.indexOf(ENVELOPE_BEGIN);
518
+ if (start === -1) return void 0;
519
+ const payloadStart = start + 17;
520
+ const end = prompt.indexOf(ENVELOPE_END, payloadStart);
521
+ if (end === -1) return void 0;
522
+ const payload = prompt.slice(payloadStart, end);
523
+ try {
524
+ const parsed = JSON.parse(payload);
525
+ if (!parsed || typeof parsed !== "object") return void 0;
526
+ const t = parsed;
527
+ if (typeof t.lens !== "string" || !Array.isArray(t.captures)) return void 0;
528
+ return t;
529
+ } catch {
530
+ return;
531
+ }
532
+ }
533
+ /** Produce the user message for one audit iteration: lens, captures to take, and the task envelope. @experimental */
534
+ function formatAuditorPrompt(task) {
535
+ const lines = [];
536
+ lines.push(`# UI audit iteration — lens: ${task.lens}`);
537
+ lines.push("");
538
+ if (task.productContext && task.productContext.trim().length > 0) {
539
+ lines.push("## Product context");
540
+ lines.push(task.productContext.trim());
541
+ lines.push("");
542
+ }
543
+ lines.push("## Captures to take");
544
+ task.captures.forEach((cap, i) => {
545
+ const detail = [
546
+ `viewport=${cap.viewport ? `${cap.viewport.width}x${cap.viewport.height}` : "1280x800 (default)"}`,
547
+ cap.fullPage ? "fullPage=true" : null,
548
+ cap.elementSelector ? `selector=\`${cap.elementSelector}\`` : null,
549
+ cap.waitFor ? `waitFor=\`${cap.waitFor}\`` : null,
550
+ cap.waitMs !== void 0 ? `waitMs=${cap.waitMs}` : null,
551
+ cap.label ? `label=${cap.label}` : null
552
+ ].filter((s) => s !== null).join(" · ");
553
+ lines.push(`${i + 1}. route=\`${cap.route}\` url=${cap.url} ${detail ? `(${detail})` : ""}`);
554
+ });
555
+ lines.push("");
556
+ if (task.knownFindingIds && task.knownFindingIds.length > 0) {
557
+ lines.push("## Known findings (link via similarTo, do not refile)");
558
+ lines.push(task.knownFindingIds.map((n) => `#${String(n).padStart(3, "0")}`).join(", "));
559
+ lines.push("");
560
+ }
561
+ lines.push("## Output format");
562
+ lines.push("Emit a single JSON object with the shape `{ findings: UiFinding[], notes?: string }` where every finding has the fields enumerated in your system prompt. The screenshots field on each finding must reference the captures above by path. Do not emit findings outside the lens.");
563
+ return lines.join("\n");
564
+ }
565
+ //#endregion
737
566
  //#region src/profiles/ui-auditor/validator.ts
738
567
  const GENERIC_TITLE_PATTERNS = [
739
568
  /^improve\s/i,
@@ -803,44 +632,6 @@ function createUiAuditorValidator(task) {
803
632
  } };
804
633
  }
805
634
  //#endregion
806
- //#region src/profiles/ui-auditor/profile.ts
807
- /**
808
- * Preset `runAgentRounds` bundle for vision-driven UI audits: returns the `AgentRunSpec`, output adapter, validator, and prompt formatter the loop kernel needs.
809
- *
810
- * @experimental
811
- */
812
- function uiAuditorProfile(options = {}) {
813
- const name = options.name ?? "ui-auditor";
814
- const profile = {
815
- name,
816
- description: "Vision-driven UI auditor. One lens per iteration.",
817
- prompt: { systemPrompt: "" },
818
- model: options.model ? { default: options.model } : void 0,
819
- tools: {
820
- browser: true,
821
- vision: true
822
- },
823
- metadata: { role: "ui-auditor" }
824
- };
825
- const output = { parse: parseAuditorEvents };
826
- const validator = options.task ? createUiAuditorValidator(options.task) : createUiAuditorValidator({
827
- lens: "other",
828
- captures: []
829
- });
830
- const taskToPrompt = (task) => `${encodeAuditTaskEnvelope(task)}\n${buildAuditorSystemPrompt(task.lens)}\n\n${formatAuditorPrompt(task)}`;
831
- return {
832
- profile,
833
- taskToPrompt,
834
- output,
835
- validator,
836
- agentRunSpec: {
837
- name,
838
- profile,
839
- taskToPrompt
840
- }
841
- };
842
- }
843
- //#endregion
844
- export { LENS_BRIEFS, SHARED_AUDITOR_RULES, UI_FINDING_SEVERITIES, UI_LENSES, appendFindings, buildAuditorSystemPrompt, coderTaskToPrompt, createInProcessUiAuditClient, createResearcherValidator, createUiAuditorValidator, decodeAuditTaskEnvelope, encodeAuditTaskEnvelope, formatAuditorPrompt, initAuditWorkspace, multiHarnessResearcherFanout, parseAuditorEvents, readAuditRegistry, registerCaptures, researcherProfile, summarizeRegistry, uiAuditorProfile, writeAuditIndex };
635
+ export { LENS_BRIEFS, SHARED_AUDITOR_RULES, UI_FINDING_SEVERITIES, UI_LENSES, appendFindings, buildAuditorSystemPrompt, coderTaskToPrompt, createResearcherValidator, createUiAuditorValidator, decodeAuditTaskEnvelope, encodeAuditTaskEnvelope, formatAuditorPrompt, initAuditWorkspace, multiHarnessResearcherFanout, parseAuditorEvents, readAuditRegistry, registerCaptures, researcherProfile, summarizeRegistry, writeAuditIndex };
845
636
 
846
637
  //# sourceMappingURL=profiles.js.map