@tangle-network/agent-app 0.43.76 → 0.44.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.
Files changed (153) hide show
  1. package/README.md +1 -1
  2. package/dist/DesignCanvas-Z362I3R3.js +10 -0
  3. package/dist/{DesignCanvasEditor-FJIVYOA2.js → DesignCanvasEditor-ZFE2W4OJ.js} +4 -4
  4. package/dist/assets/index.d.ts +4 -4
  5. package/dist/assets/index.js +223 -11
  6. package/dist/assets/index.js.map +1 -1
  7. package/dist/assistant/index.d.ts +7 -7
  8. package/dist/assistant/index.js +3 -3
  9. package/dist/assistant/index.js.map +1 -1
  10. package/dist/{attachment-validation-Dv1A_Puy.d.ts → attachment-validation-DRuLEjAE.d.ts} +1 -1
  11. package/dist/{auth-_FU8w01b.d.ts → auth-anc7mv2W.d.ts} +2 -2
  12. package/dist/chat-routes/index.d.ts +14 -11
  13. package/dist/chat-routes/index.js +16 -17
  14. package/dist/chat-routes/index.js.map +1 -1
  15. package/dist/chat-store/index.d.ts +26 -7
  16. package/dist/chat-store/index.js +14 -5
  17. package/dist/chat-store/index.js.map +1 -1
  18. package/dist/{chunk-ROLFDOMJ.js → chunk-4TI7QWLW.js} +3 -3
  19. package/dist/{chunk-3JUTOVUH.js → chunk-6KMAM7BL.js} +1 -1
  20. package/dist/chunk-6KMAM7BL.js.map +1 -0
  21. package/dist/{chunk-WL7XHLDK.js → chunk-ICOHEZK6.js} +77 -5
  22. package/dist/chunk-ICOHEZK6.js.map +1 -0
  23. package/dist/{chunk-22GLESKE.js → chunk-O63WWYET.js} +2 -4
  24. package/dist/chunk-O63WWYET.js.map +1 -0
  25. package/dist/{chunk-E7N67FYI.js → chunk-Q3FONVAK.js} +5 -5
  26. package/dist/{chunk-E7N67FYI.js.map → chunk-Q3FONVAK.js.map} +1 -1
  27. package/dist/{chunk-RXOTWZ4G.js → chunk-TKRI463Z.js} +4 -4
  28. package/dist/chunk-TKRI463Z.js.map +1 -0
  29. package/dist/config/index.d.ts +1 -1
  30. package/dist/config/index.js +123 -4
  31. package/dist/config/index.js.map +1 -1
  32. package/dist/{contract-B3h7peV3.d.ts → contract-CEewO6DI.d.ts} +1 -1
  33. package/dist/design-canvas/index.d.ts +4 -4
  34. package/dist/design-canvas-react/index.js +7 -7
  35. package/dist/design-canvas-react/lazy.js +1 -1
  36. package/dist/eval/index.d.ts +1 -1
  37. package/dist/eval/index.js +22 -8
  38. package/dist/eval/index.js.map +1 -1
  39. package/dist/{flow-types-CqomVAUN.d.ts → flow-types-CJxEmaRy.d.ts} +1 -1
  40. package/dist/integrations/index.js +67 -5
  41. package/dist/integrations/index.js.map +1 -1
  42. package/dist/interactions/index.d.ts +6 -4
  43. package/dist/interactions/index.js +1 -2
  44. package/dist/knowledge/index.js +63 -4
  45. package/dist/knowledge/index.js.map +1 -1
  46. package/dist/knowledge-loop/index.d.ts +1 -1
  47. package/dist/knowledge-loop/index.js +94 -4
  48. package/dist/knowledge-loop/index.js.map +1 -1
  49. package/dist/{mcp-BjPqQ-3C.d.ts → mcp-D3qVzbE1.d.ts} +2 -2
  50. package/dist/{mcp-rpc-BfUOsalw.d.ts → mcp-rpc-CzU5LWWT.d.ts} +1 -1
  51. package/dist/missions/index.js +1143 -23
  52. package/dist/missions/index.js.map +1 -1
  53. package/dist/{model-DmdkIteM.d.ts → model-CdCDfBA9.d.ts} +1 -1
  54. package/dist/object-store/index.js +113 -8
  55. package/dist/object-store/index.js.map +1 -1
  56. package/dist/{parts-2ymE5cs-.d.ts → parts-Co_lFgLI.d.ts} +3 -3
  57. package/dist/platform/index.d.ts +1 -1
  58. package/dist/preflight/cli.d.ts +13 -0
  59. package/dist/preflight/cli.js +50 -0
  60. package/dist/preflight/cli.js.map +1 -0
  61. package/dist/preset-cloudflare/index.d.ts +1 -1
  62. package/dist/preset-cloudflare/index.js +284 -11
  63. package/dist/preset-cloudflare/index.js.map +1 -1
  64. package/dist/{queue-C24V13h9.d.ts → queue-CD5-_VTX.d.ts} +1 -1
  65. package/dist/redact/index.js +116 -8
  66. package/dist/redact/index.js.map +1 -1
  67. package/dist/runtime/index.d.ts +19 -111
  68. package/dist/runtime/index.js +234 -14
  69. package/dist/runtime/index.js.map +1 -1
  70. package/dist/sandbox/index.d.ts +3 -3
  71. package/dist/sandbox/index.js +2 -3
  72. package/dist/sequences/index.d.ts +4 -4
  73. package/dist/stream/index.d.ts +4 -4
  74. package/dist/{stream-normalizer-QYUl4vnl.d.ts → stream-normalizer-DnuqkZvw.d.ts} +2 -2
  75. package/dist/tangle/index.js +42 -4
  76. package/dist/tangle/index.js.map +1 -1
  77. package/dist/teams/index.js +5 -5
  78. package/dist/teams/invitations-api.js +4 -4
  79. package/dist/teams-react/index.js +3 -3
  80. package/dist/theme/index.js +0 -1
  81. package/dist/tools/index.d.ts +6 -6
  82. package/dist/tools/index.js +5 -7
  83. package/dist/trace/index.d.ts +1 -1
  84. package/dist/trace/index.js +179 -10
  85. package/dist/trace/index.js.map +1 -1
  86. package/dist/{turn-buffer-BaSgxVmK.d.ts → turn-buffer-BcPfhr1_.d.ts} +1 -1
  87. package/dist/turn-stream/index.d.ts +1 -1
  88. package/dist/{types-CBRyqijY.d.ts → types-BCxK0wyS.d.ts} +1 -1
  89. package/dist/{types-CEchbvgz.d.ts → types-XIZqIdX1.d.ts} +1 -1
  90. package/dist/web-react/index.d.ts +10 -10
  91. package/dist/web-react/index.js +5 -5
  92. package/dist/work-product/index.d.ts +4 -4
  93. package/dist/work-product/index.js +735 -15
  94. package/dist/work-product/index.js.map +1 -1
  95. package/dist/work-product-react/index.d.ts +1 -1
  96. package/dist/work-product-react/index.js.map +1 -1
  97. package/package.json +4 -19
  98. package/dist/DesignCanvas-UNL34LS2.js +0 -12
  99. package/dist/chunk-22GLESKE.js.map +0 -1
  100. package/dist/chunk-3JUTOVUH.js.map +0 -1
  101. package/dist/chunk-5EQCITY3.js +0 -20
  102. package/dist/chunk-5EQCITY3.js.map +0 -1
  103. package/dist/chunk-5SD6HT2V.js +0 -236
  104. package/dist/chunk-5SD6HT2V.js.map +0 -1
  105. package/dist/chunk-5TESA4SN.js +0 -74
  106. package/dist/chunk-5TESA4SN.js.map +0 -1
  107. package/dist/chunk-6GQ5DKFK.js +0 -920
  108. package/dist/chunk-6GQ5DKFK.js.map +0 -1
  109. package/dist/chunk-7ESQUSAC.js +0 -343
  110. package/dist/chunk-7ESQUSAC.js.map +0 -1
  111. package/dist/chunk-7LNGJDNA.js +0 -1
  112. package/dist/chunk-7LNGJDNA.js.map +0 -1
  113. package/dist/chunk-AP2UXKUK.js +0 -69
  114. package/dist/chunk-AP2UXKUK.js.map +0 -1
  115. package/dist/chunk-FA4XR66Y.js +0 -32
  116. package/dist/chunk-FA4XR66Y.js.map +0 -1
  117. package/dist/chunk-FKCB5FTD.js +0 -126
  118. package/dist/chunk-FKCB5FTD.js.map +0 -1
  119. package/dist/chunk-GPBRL2XR.js +0 -102
  120. package/dist/chunk-GPBRL2XR.js.map +0 -1
  121. package/dist/chunk-HRH7ASAG.js +0 -759
  122. package/dist/chunk-HRH7ASAG.js.map +0 -1
  123. package/dist/chunk-HYTIHYNV.js +0 -297
  124. package/dist/chunk-HYTIHYNV.js.map +0 -1
  125. package/dist/chunk-LGBO24FL.js +0 -190
  126. package/dist/chunk-LGBO24FL.js.map +0 -1
  127. package/dist/chunk-NLSSFLLS.js +0 -1168
  128. package/dist/chunk-NLSSFLLS.js.map +0 -1
  129. package/dist/chunk-OSMNYPOG.js +0 -129
  130. package/dist/chunk-OSMNYPOG.js.map +0 -1
  131. package/dist/chunk-QYOD3K56.js +0 -124
  132. package/dist/chunk-QYOD3K56.js.map +0 -1
  133. package/dist/chunk-RXOTWZ4G.js.map +0 -1
  134. package/dist/chunk-UAKFCMWK.js +0 -1
  135. package/dist/chunk-UAKFCMWK.js.map +0 -1
  136. package/dist/chunk-UKTYKG57.js +0 -48
  137. package/dist/chunk-UKTYKG57.js.map +0 -1
  138. package/dist/chunk-UOAYS72M.js +0 -80
  139. package/dist/chunk-UOAYS72M.js.map +0 -1
  140. package/dist/chunk-WL7XHLDK.js.map +0 -1
  141. package/dist/composer/index.d.ts +0 -2
  142. package/dist/composer/index.js +0 -22
  143. package/dist/composer/index.js.map +0 -1
  144. package/dist/core-7qIM7svy.d.ts +0 -21
  145. package/dist/durable-chat/index.d.ts +0 -464
  146. package/dist/durable-chat/index.js +0 -59
  147. package/dist/durable-chat/index.js.map +0 -1
  148. package/dist/index.d.ts +0 -51
  149. package/dist/index.js +0 -827
  150. package/dist/index.js.map +0 -1
  151. /package/dist/{DesignCanvas-UNL34LS2.js.map → DesignCanvas-Z362I3R3.js.map} +0 -0
  152. /package/dist/{DesignCanvasEditor-FJIVYOA2.js.map → DesignCanvasEditor-ZFE2W4OJ.js.map} +0 -0
  153. /package/dist/{chunk-ROLFDOMJ.js.map → chunk-4TI7QWLW.js.map} +0 -0
@@ -1,8 +1,98 @@
1
+ // src/knowledge-loop/index.ts
1
2
  import {
2
- createKnowledgeLoop,
3
- createReviewerDecider,
4
- reviewCandidate
5
- } from "../chunk-GPBRL2XR.js";
3
+ runKnowledgeResearchLoop,
4
+ textSourceAdapter
5
+ } from "@tangle-network/agent-knowledge";
6
+ var DEFAULT_MIN_CONFIDENCE = 0.7;
7
+ var DEFAULT_GOAL = "Acquire and ground the knowledge this product requires.";
8
+ function reviewCandidate(candidate, minConfidence) {
9
+ if (!candidate.proposalText) {
10
+ return {
11
+ accepted: true,
12
+ reason: "no-proposal",
13
+ confidence: candidate.confidence ?? 1,
14
+ minConfidence
15
+ };
16
+ }
17
+ const confidence = candidate.confidence ?? 0;
18
+ if (confidence >= minConfidence) {
19
+ return {
20
+ accepted: true,
21
+ reason: `confidence ${confidence.toFixed(2)} >= minConfidence ${minConfidence.toFixed(2)}`,
22
+ confidence,
23
+ minConfidence
24
+ };
25
+ }
26
+ return {
27
+ accepted: false,
28
+ reason: `confidence ${confidence.toFixed(2)} < minConfidence ${minConfidence.toFixed(2)}`,
29
+ confidence,
30
+ minConfidence
31
+ };
32
+ }
33
+ function createReviewerDecider(propose) {
34
+ return async (input) => {
35
+ const candidate = await propose(input);
36
+ const verdict = reviewCandidate(candidate, input.minConfidence);
37
+ return { candidate, verdict };
38
+ };
39
+ }
40
+ function toResearchDecision(decision) {
41
+ const { candidate, verdict } = decision;
42
+ return {
43
+ notes: candidate.notes,
44
+ sourcePaths: candidate.sourcePaths,
45
+ sourceTexts: candidate.sourceTexts,
46
+ proposalText: verdict.accepted ? candidate.proposalText : void 0,
47
+ done: candidate.done,
48
+ metadata: {
49
+ ...candidate.metadata ?? {},
50
+ gate: verdict
51
+ }
52
+ };
53
+ }
54
+ var noopDecider = (input) => ({
55
+ candidate: { done: true, notes: "no decider supplied; nothing proposed" },
56
+ verdict: {
57
+ accepted: true,
58
+ reason: "no-proposal",
59
+ confidence: 1,
60
+ minConfidence: input.minConfidence
61
+ }
62
+ });
63
+ function createKnowledgeLoop(knowledge, deps) {
64
+ const goal = knowledge.loop?.goal ?? deps.defaultGoal ?? DEFAULT_GOAL;
65
+ const minConfidence = knowledge.loop?.minConfidence ?? deps.defaultMinConfidence ?? DEFAULT_MIN_CONFIDENCE;
66
+ const freshness = knowledge.loop?.freshness;
67
+ const adapters = [...deps.adapters ?? [], textSourceAdapter];
68
+ const decide = deps.decide ?? noopDecider;
69
+ const run = () => runKnowledgeResearchLoop({
70
+ root: deps.root,
71
+ goal,
72
+ maxIterations: deps.maxIterations,
73
+ actor: deps.actor,
74
+ signal: deps.signal,
75
+ onStep: deps.onStep,
76
+ sourceOptions: { adapters },
77
+ async step(context) {
78
+ const decision = await decide({
79
+ context,
80
+ goal,
81
+ minConfidence,
82
+ freshness,
83
+ sources: knowledge.sources,
84
+ driver: deps.driver
85
+ });
86
+ return toResearchDecision(decision);
87
+ }
88
+ });
89
+ return {
90
+ run,
91
+ goal,
92
+ minConfidence,
93
+ adapters
94
+ };
95
+ }
6
96
  export {
7
97
  createKnowledgeLoop,
8
98
  createReviewerDecider,
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../src/knowledge-loop/index.ts"],"sourcesContent":["/**\n * `@tangle-network/agent-app/knowledge-loop` — wire the declarative\n * `AgentKnowledgeConfig` to a running, source-grounded, eval-gated knowledge\n * acquisition loop.\n *\n * This module does NOT implement a loop. `@tangle-network/agent-knowledge`\n * already ships `runKnowledgeResearchLoop` — the source-grounded,\n * propose-don't-apply primitive (sources become immutable records first; only\n * accepted `---FILE: knowledge/...---` write blocks are applied; lint +\n * validation + optional readiness gate every iteration). It is pluggable on two\n * seams: a `SourceAdapter[]` (how raw bytes/text become curated source records —\n * text by default, audio/video/image adapters added by the consumer) and a\n * `step` decider (the per-iteration policy: an agentic judge, a sandbox run, or\n * a deterministic gate — the loop deliberately bakes none).\n *\n * `createKnowledgeLoop(config.knowledge, deps)` is the thin mapper between the\n * two:\n *\n * - `config.knowledge.sources` → adapter selection. The text adapter is the\n * default; `deps.adapters` is the multimodal seam (prepend an audio/video/\n * image `SourceAdapter` and the loop ingests that media). agent-app bakes no\n * media handler — it's a parameter.\n * - `config.knowledge.loop` → `runKnowledgeResearchLoop` options. `goal` maps\n * to the loop goal, `minConfidence` to the gate threshold, `freshness` is\n * threaded to the decider so a per-source-freshness policy can read it.\n * - `deps.decide` → the pluggable gate. DEFAULT is a reviewer policy\n * (agent-knowledge's propose-don't-apply posture): a candidate carrying\n * confidence below `minConfidence` is gated OUT (its proposal text is\n * dropped — sources are still recorded, because grounding is never the thing\n * we gate); at/above threshold it is accepted and the loop applies the write\n * blocks. Swap in an agentic judge or a sandbox run by passing your own\n * `decide`.\n * - `deps.driver` → the agent-runtime turn driver (this repo's `../runtime`\n * `runAppToolLoop` seam, or any compatible driver) the decider invokes for\n * the loop's agent turns. Optional; a deterministic / sandbox decider needs\n * no model turns and omits it.\n *\n * Layering: agent-knowledge and agent-runtime are PEER dependencies, never\n * bundled. This module imports only TYPES + the loop entry from agent-knowledge\n * and stays substrate-free behind the `decide` / `driver` / `adapters` seams.\n */\n\nimport type {\n AddSourceTextInput,\n KnowledgeResearchLoopContext,\n KnowledgeResearchLoopDecision,\n KnowledgeResearchLoopResult,\n RunKnowledgeResearchLoopOptions,\n SourceAdapter,\n} from '@tangle-network/agent-knowledge'\nimport {\n runKnowledgeResearchLoop,\n textSourceAdapter,\n} from '@tangle-network/agent-knowledge'\nimport type { AgentKnowledgeConfig, KnowledgeSourceSpec } from '../config/index'\n\n/**\n * A research candidate the decider evaluates before the loop applies it. This is\n * the propose-don't-apply unit: notes + the sources discovered this iteration +\n * the proposed write blocks, each carrying a confidence the gate scores against\n * the configured `minConfidence`.\n */\nexport interface KnowledgeCandidate {\n /** Human-readable research transcript for this iteration. */\n notes?: string\n /**\n * Textual source artifacts to register as immutable sources BEFORE any\n * proposal is applied. Recording these is grounding, not the gated step — a\n * rejected candidate still keeps its sources (so the next iteration is better\n * grounded). The decider may not strip these.\n */\n sourceTexts?: AddSourceTextInput[]\n /** Local files to register as immutable sources (same grounding posture). */\n sourcePaths?: string[]\n /**\n * Safe-write-protocol text (`---FILE: knowledge/...---` blocks). This IS the\n * gated step: the default decider drops it when `confidence < minConfidence`.\n */\n proposalText?: string\n /**\n * Aggregate confidence in this candidate's proposal, in [0, 1]. The default\n * reviewer gate compares this to `minConfidence`. A candidate with no\n * `proposalText` needs no confidence (nothing is gated).\n */\n confidence?: number\n /** The researcher's signal that the goal is met; ends the loop. */\n done?: boolean\n metadata?: Record<string, unknown>\n}\n\n/** The verdict a gate returns for one candidate. */\nexport interface KnowledgeGateVerdict {\n /** Whether the candidate's proposal is accepted (applied) or gated out. */\n accepted: boolean\n /** Why — surfaced in the decision metadata for audit. */\n reason: string\n /** The confidence the gate scored (echoed for telemetry). */\n confidence: number\n /** The threshold it was scored against. */\n minConfidence: number\n}\n\n/**\n * The pluggable acquisition policy. Given the loop context (current index, lint,\n * validation, freshness target, the driver), produce a candidate AND a gate\n * verdict on it. This is the seam an agentic judge or a sandbox run plugs into;\n * the default {@link createReviewerDecider} is a confidence gate.\n */\nexport interface KnowledgeDecider {\n (input: KnowledgeDeciderInput): Promise<KnowledgeDecision> | KnowledgeDecision\n}\n\n/** Define the input parameters required to decide knowledge proposals within an agent-knowledge loop */\nexport interface KnowledgeDeciderInput {\n /** The agent-knowledge loop context for this iteration. */\n context: KnowledgeResearchLoopContext\n /** The acquisition goal (from `config.loop.goal` or a deps fallback). */\n goal: string\n /** The confidence threshold a proposal must clear to be applied. */\n minConfidence: number\n /** The freshness target (`config.loop.freshness`), if set. */\n freshness?: string\n /** The configured sources, for a decider that fetches/selects among them. */\n sources: KnowledgeSourceSpec[]\n /** The agent-runtime turn driver, if one was supplied to the loop. */\n driver?: KnowledgeLoopDriver\n}\n\n/** Define a decision containing a candidate and the gate's verdict on that candidate */\nexport interface KnowledgeDecision {\n /** The candidate the policy produced (may be empty to end the loop). */\n candidate: KnowledgeCandidate\n /** The gate's verdict on the candidate's proposal. */\n verdict: KnowledgeGateVerdict\n}\n\n/**\n * The agent-runtime turn driver seam. This is exactly `../runtime`'s\n * `runAppToolLoop` shape (a bounded, awaitable tool-driving turn loop over a\n * model). Typed structurally so a decider can drive the loop's agent turns\n * without this module importing the runtime engine. A deterministic / sandbox\n * decider may omit it.\n */\nexport interface KnowledgeLoopDriver {\n (opts: {\n systemPrompt: string\n userMessage: string\n }): Promise<{ finalText: string }>\n}\n\n/** Define dependencies required to create and run a knowledge processing loop */\nexport interface CreateKnowledgeLoopDeps {\n /**\n * The knowledge-base root the loop reads/writes (an agent-knowledge layout).\n * Required — agent-knowledge owns disk; agent-app owns only the wiring.\n */\n root: string\n /**\n * The per-iteration policy. Defaults to {@link createReviewerDecider} keyed on\n * the config's `minConfidence`. Pass your own to use an agentic judge or a\n * sandbox run.\n */\n decide?: KnowledgeDecider\n /**\n * Extra source adapters (audio/video/image/PDF/...). The text adapter is\n * always present as the fallback; these are tried first so a multimodal\n * source is claimed by its adapter. This is the multimodal seam.\n */\n adapters?: SourceAdapter[]\n /** The agent-runtime turn driver for the loop's agent turns. */\n driver?: KnowledgeLoopDriver\n /**\n * Fallback goal when `config.loop.goal` is unset. agent-knowledge requires a\n * goal; this keeps the loop runnable for a config with only requirement specs.\n */\n defaultGoal?: string\n /** Default confidence threshold when `config.loop.minConfidence` is unset. */\n defaultMinConfidence?: number\n /** Max research iterations (forwarded to agent-knowledge). Default 3. */\n maxIterations?: number\n /** Actor stamped on the loop's knowledge events. */\n actor?: string\n /** Abort the loop. */\n signal?: AbortSignal\n /** Per-step hook (forwarded to agent-knowledge's `onStep`). */\n onStep?: RunKnowledgeResearchLoopOptions['onStep']\n}\n\n/** The handle `createKnowledgeLoop` returns. */\nexport interface KnowledgeLoop {\n /** Run the acquisition loop to completion and return the agent-knowledge result. */\n run(): Promise<KnowledgeResearchLoopResult>\n /** The resolved goal the loop pursues. */\n readonly goal: string\n /** The resolved confidence gate threshold. */\n readonly minConfidence: number\n /** The adapters the loop uses (consumer extras first, text last). */\n readonly adapters: SourceAdapter[]\n}\n\nconst DEFAULT_MIN_CONFIDENCE = 0.7\nconst DEFAULT_GOAL = 'Acquire and ground the knowledge this product requires.'\n\n/**\n * The default gate — agent-knowledge's propose-don't-apply reviewer posture as a\n * confidence threshold. A candidate's `proposalText` is applied only when its\n * `confidence` is at/above `minConfidence`; otherwise the proposal is gated out\n * (sources are still recorded). A candidate with no `proposalText` is trivially\n * accepted (nothing to gate). This is the floor policy; swap in an agentic judge\n * or a sandbox-run decider via `deps.decide` for richer review.\n */\nexport function reviewCandidate(\n candidate: KnowledgeCandidate,\n minConfidence: number,\n): KnowledgeGateVerdict {\n if (!candidate.proposalText) {\n return {\n accepted: true,\n reason: 'no-proposal',\n confidence: candidate.confidence ?? 1,\n minConfidence,\n }\n }\n const confidence = candidate.confidence ?? 0\n if (confidence >= minConfidence) {\n return {\n accepted: true,\n reason: `confidence ${confidence.toFixed(2)} >= minConfidence ${minConfidence.toFixed(2)}`,\n confidence,\n minConfidence,\n }\n }\n return {\n accepted: false,\n reason: `confidence ${confidence.toFixed(2)} < minConfidence ${minConfidence.toFixed(2)}`,\n confidence,\n minConfidence,\n }\n}\n\n/**\n * Wrap a candidate-producing policy in the default reviewer gate. The policy\n * decides WHAT to propose (notes, sources, proposalText, confidence); the gate\n * decides whether the proposal is APPLIED. Use this when you have a proposer but\n * want the standard confidence gate; pass a full {@link KnowledgeDecider} to\n * `deps.decide` to own the gate too.\n */\nexport function createReviewerDecider(\n propose: (\n input: KnowledgeDeciderInput,\n ) => Promise<KnowledgeCandidate> | KnowledgeCandidate,\n): KnowledgeDecider {\n return async (input) => {\n const candidate = await propose(input)\n const verdict = reviewCandidate(candidate, input.minConfidence)\n return { candidate, verdict }\n }\n}\n\n/**\n * Apply a gate verdict to a candidate, producing the agent-knowledge decision.\n * Grounding (sources) always passes through; the gated `proposalText` is dropped\n * when the verdict rejects it. The verdict is recorded in `metadata.gate` so the\n * loop's event stream carries the audit trail.\n */\nfunction toResearchDecision(decision: KnowledgeDecision): KnowledgeResearchLoopDecision {\n const { candidate, verdict } = decision\n return {\n notes: candidate.notes,\n sourcePaths: candidate.sourcePaths,\n sourceTexts: candidate.sourceTexts,\n proposalText: verdict.accepted ? candidate.proposalText : undefined,\n done: candidate.done,\n metadata: {\n ...(candidate.metadata ?? {}),\n gate: verdict,\n },\n }\n}\n\n/**\n * The do-nothing default policy: when no `decide` is supplied, the loop runs\n * with a proposer that proposes nothing and ends immediately. A real product\n * supplies a proposer (agentic judge, sandbox run, or deterministic) via\n * `deps.decide`; this keeps `createKnowledgeLoop` total for a config that only\n * declares sources/requirements without a wired researcher yet.\n */\nconst noopDecider: KnowledgeDecider = (input) => ({\n candidate: { done: true, notes: 'no decider supplied; nothing proposed' },\n verdict: {\n accepted: true,\n reason: 'no-proposal',\n confidence: 1,\n minConfidence: input.minConfidence,\n },\n})\n\n/**\n * Build a runnable knowledge-acquisition loop from the product's\n * `AgentKnowledgeConfig` and a small set of seams. Maps config → agent-knowledge\n * `runKnowledgeResearchLoop` options; never reimplements the loop.\n */\nexport function createKnowledgeLoop(\n knowledge: AgentKnowledgeConfig,\n deps: CreateKnowledgeLoopDeps,\n): KnowledgeLoop {\n const goal = knowledge.loop?.goal ?? deps.defaultGoal ?? DEFAULT_GOAL\n const minConfidence =\n knowledge.loop?.minConfidence ?? deps.defaultMinConfidence ?? DEFAULT_MIN_CONFIDENCE\n const freshness = knowledge.loop?.freshness\n\n // Multimodal seam: consumer adapters are tried first; the text adapter is the\n // always-present fallback (it claims text/.md/.txt/.json/.csv). A config\n // source whose media an extra adapter claims is ingested by that adapter.\n const adapters: SourceAdapter[] = [...(deps.adapters ?? []), textSourceAdapter]\n\n const decide = deps.decide ?? noopDecider\n\n const run = (): Promise<KnowledgeResearchLoopResult> =>\n runKnowledgeResearchLoop({\n root: deps.root,\n goal,\n maxIterations: deps.maxIterations,\n actor: deps.actor,\n signal: deps.signal,\n onStep: deps.onStep,\n sourceOptions: { adapters },\n async step(context) {\n const decision = await decide({\n context,\n goal,\n minConfidence,\n freshness,\n sources: knowledge.sources,\n driver: deps.driver,\n })\n return toResearchDecision(decision)\n },\n })\n\n return {\n run,\n goal,\n minConfidence,\n adapters,\n }\n}\n"],"mappings":";AAkDA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAmJP,IAAM,yBAAyB;AAC/B,IAAM,eAAe;AAUd,SAAS,gBACd,WACA,eACsB;AACtB,MAAI,CAAC,UAAU,cAAc;AAC3B,WAAO;AAAA,MACL,UAAU;AAAA,MACV,QAAQ;AAAA,MACR,YAAY,UAAU,cAAc;AAAA,MACpC;AAAA,IACF;AAAA,EACF;AACA,QAAM,aAAa,UAAU,cAAc;AAC3C,MAAI,cAAc,eAAe;AAC/B,WAAO;AAAA,MACL,UAAU;AAAA,MACV,QAAQ,cAAc,WAAW,QAAQ,CAAC,CAAC,qBAAqB,cAAc,QAAQ,CAAC,CAAC;AAAA,MACxF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,SAAO;AAAA,IACL,UAAU;AAAA,IACV,QAAQ,cAAc,WAAW,QAAQ,CAAC,CAAC,oBAAoB,cAAc,QAAQ,CAAC,CAAC;AAAA,IACvF;AAAA,IACA;AAAA,EACF;AACF;AASO,SAAS,sBACd,SAGkB;AAClB,SAAO,OAAO,UAAU;AACtB,UAAM,YAAY,MAAM,QAAQ,KAAK;AACrC,UAAM,UAAU,gBAAgB,WAAW,MAAM,aAAa;AAC9D,WAAO,EAAE,WAAW,QAAQ;AAAA,EAC9B;AACF;AAQA,SAAS,mBAAmB,UAA4D;AACtF,QAAM,EAAE,WAAW,QAAQ,IAAI;AAC/B,SAAO;AAAA,IACL,OAAO,UAAU;AAAA,IACjB,aAAa,UAAU;AAAA,IACvB,aAAa,UAAU;AAAA,IACvB,cAAc,QAAQ,WAAW,UAAU,eAAe;AAAA,IAC1D,MAAM,UAAU;AAAA,IAChB,UAAU;AAAA,MACR,GAAI,UAAU,YAAY,CAAC;AAAA,MAC3B,MAAM;AAAA,IACR;AAAA,EACF;AACF;AASA,IAAM,cAAgC,CAAC,WAAW;AAAA,EAChD,WAAW,EAAE,MAAM,MAAM,OAAO,wCAAwC;AAAA,EACxE,SAAS;AAAA,IACP,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,eAAe,MAAM;AAAA,EACvB;AACF;AAOO,SAAS,oBACd,WACA,MACe;AACf,QAAM,OAAO,UAAU,MAAM,QAAQ,KAAK,eAAe;AACzD,QAAM,gBACJ,UAAU,MAAM,iBAAiB,KAAK,wBAAwB;AAChE,QAAM,YAAY,UAAU,MAAM;AAKlC,QAAM,WAA4B,CAAC,GAAI,KAAK,YAAY,CAAC,GAAI,iBAAiB;AAE9E,QAAM,SAAS,KAAK,UAAU;AAE9B,QAAM,MAAM,MACV,yBAAyB;AAAA,IACvB,MAAM,KAAK;AAAA,IACX;AAAA,IACA,eAAe,KAAK;AAAA,IACpB,OAAO,KAAK;AAAA,IACZ,QAAQ,KAAK;AAAA,IACb,QAAQ,KAAK;AAAA,IACb,eAAe,EAAE,SAAS;AAAA,IAC1B,MAAM,KAAK,SAAS;AAClB,YAAM,WAAW,MAAM,OAAO;AAAA,QAC5B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS,UAAU;AAAA,QACnB,QAAQ,KAAK;AAAA,MACf,CAAC;AACD,aAAO,mBAAmB,QAAQ;AAAA,IACpC;AAAA,EACF,CAAC;AAEH,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -1,5 +1,5 @@
1
- import { c as AppToolContext, f as AppToolName, d as AppToolDefinition } from './types-CBRyqijY.js';
2
- import { a as ToolHeaderNames } from './auth-_FU8w01b.js';
1
+ import { a as AppToolContext, b as AppToolName, c as AppToolDefinition } from './types-BCxK0wyS.js';
2
+ import { T as ToolHeaderNames } from './auth-anc7mv2W.js';
3
3
 
4
4
  /** Default route path each app tool is served at. A product mounts its routes
5
5
  * at these paths (or supplies its own via {@link BuildMcpServerOptions.paths}). */
@@ -55,4 +55,4 @@ interface CreateMcpToolHandlerOptions<TEnv = Record<string, never>> {
55
55
  */
56
56
  declare function createMcpToolHandler<TEnv = Record<string, never>>(opts: CreateMcpToolHandlerOptions<TEnv>): (request: Request) => Promise<Response>;
57
57
 
58
- export { type CreateMcpToolHandlerOptions as C, MCP_PROTOCOL_VERSIONS as M, type McpProtocolVersion as a, type McpServerInfo as b, type McpToolDefinition as c, createMcpToolHandler as d };
58
+ export { type CreateMcpToolHandlerOptions as C, MCP_PROTOCOL_VERSIONS as M, type McpToolDefinition as a, type McpProtocolVersion as b, type McpServerInfo as c, createMcpToolHandler as d };