@full-self-browsing/lattice 1.3.0 → 1.5.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 (108) hide show
  1. package/dist/agent-run-C6miAzwI.d.ts +45 -0
  2. package/dist/agent-run-C6miAzwI.d.ts.map +1 -0
  3. package/dist/agent-run-CgPVFl0Z.js +47 -0
  4. package/dist/agent-run-CgPVFl0Z.js.map +1 -0
  5. package/dist/agents.d.ts +5 -0
  6. package/dist/agents.js +6 -0
  7. package/dist/artifact-Bg6mJGnm.d.ts +125 -0
  8. package/dist/artifact-Bg6mJGnm.d.ts.map +1 -0
  9. package/dist/artifact-DOfpeXLb.js +140 -0
  10. package/dist/artifact-DOfpeXLb.js.map +1 -0
  11. package/dist/artifacts.d.ts +2 -0
  12. package/dist/artifacts.js +2 -0
  13. package/dist/audit.d.ts +3 -0
  14. package/dist/audit.js +4 -0
  15. package/dist/catalog-CAfYwB_-.js +91 -0
  16. package/dist/catalog-CAfYwB_-.js.map +1 -0
  17. package/dist/context-pack-Bz3GXmjv.js +99 -0
  18. package/dist/context-pack-Bz3GXmjv.js.map +1 -0
  19. package/dist/context.d.ts +2 -0
  20. package/dist/context.js +2 -0
  21. package/dist/contract-S3oJGlc9.d.ts +74 -0
  22. package/dist/contract-S3oJGlc9.d.ts.map +1 -0
  23. package/dist/core.d.ts +48 -0
  24. package/dist/core.d.ts.map +1 -0
  25. package/dist/core.js +95 -0
  26. package/dist/core.js.map +1 -0
  27. package/dist/errors-eEuEIx6X.js +407 -0
  28. package/dist/errors-eEuEIx6X.js.map +1 -0
  29. package/dist/eval.d.ts +2 -0
  30. package/dist/eval.js +2 -0
  31. package/dist/fingerprint-DodDbQKN.js +34 -0
  32. package/dist/fingerprint-DodDbQKN.js.map +1 -0
  33. package/dist/index-DpnHGHVL.d.ts +53 -0
  34. package/dist/index-DpnHGHVL.d.ts.map +1 -0
  35. package/dist/index.d.ts +78 -3234
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +365 -8434
  38. package/dist/index.js.map +1 -1
  39. package/dist/infer-DLqp5QIM.d.ts +96 -0
  40. package/dist/infer-DLqp5QIM.d.ts.map +1 -0
  41. package/dist/lineage-DBgoPWAZ.js +137 -0
  42. package/dist/lineage-DBgoPWAZ.js.map +1 -0
  43. package/dist/local-CXOGPJ1f.js +139 -0
  44. package/dist/local-CXOGPJ1f.js.map +1 -0
  45. package/dist/local-Dy--7peL.d.ts +10 -0
  46. package/dist/local-Dy--7peL.d.ts.map +1 -0
  47. package/dist/memory-CkQEW6m5.js +62 -0
  48. package/dist/memory-CkQEW6m5.js.map +1 -0
  49. package/dist/memory-DRig5EHV.d.ts +10 -0
  50. package/dist/memory-DRig5EHV.d.ts.map +1 -0
  51. package/dist/negotiate-ClD88hkc.js +10967 -0
  52. package/dist/negotiate-ClD88hkc.js.map +1 -0
  53. package/dist/otel-BgM4e55_.d.ts +421 -0
  54. package/dist/otel-BgM4e55_.d.ts.map +1 -0
  55. package/dist/permission-context-CUKMo79F.js +134 -0
  56. package/dist/permission-context-CUKMo79F.js.map +1 -0
  57. package/dist/plan-DFm8Llep.js +125 -0
  58. package/dist/plan-DFm8Llep.js.map +1 -0
  59. package/dist/preflight-DNHWuJ46.d.ts +64 -0
  60. package/dist/preflight-DNHWuJ46.d.ts.map +1 -0
  61. package/dist/provider-C2IfKsvz.d.ts +1178 -0
  62. package/dist/provider-C2IfKsvz.d.ts.map +1 -0
  63. package/dist/providers.d.ts +4 -0
  64. package/dist/providers.js +4 -0
  65. package/dist/rate-limit-group-nDsBJqSu.d.ts +235 -0
  66. package/dist/rate-limit-group-nDsBJqSu.d.ts.map +1 -0
  67. package/dist/receipt-FYouoPHv.js +205 -0
  68. package/dist/receipt-FYouoPHv.js.map +1 -0
  69. package/dist/replay-CtIhpLek.js +964 -0
  70. package/dist/replay-CtIhpLek.js.map +1 -0
  71. package/dist/result-DLEx2WvU.d.ts +38 -0
  72. package/dist/result-DLEx2WvU.d.ts.map +1 -0
  73. package/dist/router-DU4Z3pTd.js +314 -0
  74. package/dist/router-DU4Z3pTd.js.map +1 -0
  75. package/dist/router-Yo1-aDOv.d.ts +42 -0
  76. package/dist/router-Yo1-aDOv.d.ts.map +1 -0
  77. package/dist/routing.d.ts +6 -0
  78. package/dist/routing.js +4 -0
  79. package/dist/{run-crew-DDznbc3G.js → run-crew-B2fQLmgB.js} +16 -23
  80. package/dist/run-crew-B2fQLmgB.js.map +1 -0
  81. package/dist/run-crew-Bnve5dyI.d.ts +721 -0
  82. package/dist/run-crew-Bnve5dyI.d.ts.map +1 -0
  83. package/dist/{runtime-BTi8lr_O.js → runtime-Dxiet5YS.js} +100 -640
  84. package/dist/runtime-Dxiet5YS.js.map +1 -0
  85. package/dist/scaffolds-DKQrCRqh.d.ts +535 -0
  86. package/dist/scaffolds-DKQrCRqh.d.ts.map +1 -0
  87. package/dist/scaffolds-ekPIlBeU.js +3139 -0
  88. package/dist/scaffolds-ekPIlBeU.js.map +1 -0
  89. package/dist/schema-CNfa_VEy.d.ts +15 -0
  90. package/dist/schema-CNfa_VEy.d.ts.map +1 -0
  91. package/dist/storage-DJKmsaEI.d.ts +26 -0
  92. package/dist/storage-DJKmsaEI.d.ts.map +1 -0
  93. package/dist/storage.d.ts +10 -0
  94. package/dist/storage.d.ts.map +1 -0
  95. package/dist/storage.js +4 -0
  96. package/dist/tool-call-validation-BFoXkwbf.js +107 -0
  97. package/dist/tool-call-validation-BFoXkwbf.js.map +1 -0
  98. package/dist/tools-C4wHgGKQ.js +49 -0
  99. package/dist/tools-C4wHgGKQ.js.map +1 -0
  100. package/dist/tools.d.ts +46 -0
  101. package/dist/tools.d.ts.map +1 -0
  102. package/dist/tools.js +106 -0
  103. package/dist/tools.js.map +1 -0
  104. package/dist/validate-c7EL5uuH.js +224 -0
  105. package/dist/validate-c7EL5uuH.js.map +1 -0
  106. package/package.json +105 -6
  107. package/dist/run-crew-DDznbc3G.js.map +0 -1
  108. package/dist/runtime-BTi8lr_O.js.map +0 -1
@@ -0,0 +1,45 @@
1
+ import { T as Usage } from "./provider-C2IfKsvz.js";
2
+
3
+ //#region src/eval/agent-run.d.ts
4
+ /**
5
+ * Summary of an agent run sufficient for regression analysis. Callers
6
+ * typically derive this from an `AgentSuccess` via `iterations.length` and
7
+ * cumulative `usage`. The schema is intentionally minimal so callers can
8
+ * persist + load it across runs without dragging the full ReplayEnvelope.
9
+ */
10
+ interface AgentRunSnapshot {
11
+ readonly iterationsToGoal: number;
12
+ readonly usage: Usage;
13
+ }
14
+ interface EvalOptions {
15
+ /**
16
+ * Maximum tolerated INCREASE in iterations-to-goal versus the baseline.
17
+ * Default 1 (one extra iteration tolerated). Set to 0 to require parity.
18
+ */
19
+ readonly iterationsToGoalRegressionLimit?: number;
20
+ /**
21
+ * Maximum tolerated FRACTIONAL cost increase versus the baseline.
22
+ * Default 0.10 (10% increase tolerated). Compared as
23
+ * `(current - baseline) / baseline`. Cost regressions are only
24
+ * considered when BOTH snapshots have a non-null `costUsd`; mixed-cost
25
+ * snapshots emit a `mixed-cost-unknown` regression so callers can decide
26
+ * how to handle them.
27
+ */
28
+ readonly costUsdRegressionLimit?: number;
29
+ }
30
+ type EvalRegressionKind = "iterations-to-goal" | "cost-regression" | "mixed-cost-unknown";
31
+ interface EvalRegression {
32
+ readonly kind: EvalRegressionKind;
33
+ readonly baseline: number | null;
34
+ readonly current: number | null;
35
+ readonly limit: number;
36
+ readonly message: string;
37
+ }
38
+ interface AgentEvalResult {
39
+ readonly ok: boolean;
40
+ readonly regressions: ReadonlyArray<EvalRegression>;
41
+ }
42
+ declare function evalAgentRun(baseline: AgentRunSnapshot, current: AgentRunSnapshot, options?: EvalOptions): AgentEvalResult;
43
+ //#endregion
44
+ export { EvalRegressionKind as a, EvalRegression as i, AgentRunSnapshot as n, evalAgentRun as o, EvalOptions as r, AgentEvalResult as t };
45
+ //# sourceMappingURL=agent-run-C6miAzwI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-run-C6miAzwI.d.ts","names":[],"sources":["../src/eval/agent-run.ts"],"mappings":";;;;AAwBA;;;;;UALiB,gBAAA;EAAA,SACN,gBAAA;EAAA,SACA,KAAA,EAAO,KAAA;AAAA;AAAA,UAGD,WAAA;EAsBA;;;;EAAA,SAjBN,+BAAA;EAkBM;;;;;;;AAOjB;EAPiB,SATN,sBAAA;AAAA;AAAA,KAGC,kBAAA;AAAA,UAKK,cAAA;EAAA,SACN,IAAA,EAAM,kBAAA;EAAA,SACN,QAAA;EAAA,SACA,OAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;AAAA;AAAA,UAGM,eAAA;EAAA,SACN,EAAA;EAAA,SACA,WAAA,EAAa,aAAA,CAAc,cAAA;AAAA;AAAA,iBAGtB,YAAA,CACd,QAAA,EAAU,gBAAA,EACV,OAAA,EAAS,gBAAA,EACT,OAAA,GAAS,WAAA,GACR,eAAA"}
@@ -0,0 +1,47 @@
1
+ //#region src/eval/agent-run.ts
2
+ function evalAgentRun(baseline, current, options = {}) {
3
+ const iterLimit = options.iterationsToGoalRegressionLimit ?? 1;
4
+ const costLimit = options.costUsdRegressionLimit ?? .1;
5
+ const regressions = [];
6
+ const iterDelta = current.iterationsToGoal - baseline.iterationsToGoal;
7
+ if (iterDelta > iterLimit) regressions.push({
8
+ kind: "iterations-to-goal",
9
+ baseline: baseline.iterationsToGoal,
10
+ current: current.iterationsToGoal,
11
+ limit: iterLimit,
12
+ message: `Iterations-to-goal ${current.iterationsToGoal} exceeds baseline ${baseline.iterationsToGoal} by ${iterDelta} (limit: ${iterLimit}).`
13
+ });
14
+ const bCost = baseline.usage.costUsd;
15
+ const cCost = current.usage.costUsd;
16
+ if (bCost === null && cCost === null) {} else if (bCost === null || cCost === null) regressions.push({
17
+ kind: "mixed-cost-unknown",
18
+ baseline: bCost,
19
+ current: cCost,
20
+ limit: costLimit,
21
+ message: `Cost mixed: baseline=${bCost} current=${cCost}; cannot compare regression.`
22
+ });
23
+ else if (bCost > 0) {
24
+ const ratio = (cCost - bCost) / bCost;
25
+ if (ratio > costLimit) regressions.push({
26
+ kind: "cost-regression",
27
+ baseline: bCost,
28
+ current: cCost,
29
+ limit: costLimit,
30
+ message: `Cost regression: $${cCost.toFixed(6)} vs baseline $${bCost.toFixed(6)} (+${(ratio * 100).toFixed(1)}%; limit ${(costLimit * 100).toFixed(1)}%).`
31
+ });
32
+ } else if (bCost === 0 && cCost > 0) regressions.push({
33
+ kind: "cost-regression",
34
+ baseline: bCost,
35
+ current: cCost,
36
+ limit: costLimit,
37
+ message: `Cost regression: baseline was $0; current $${cCost.toFixed(6)}.`
38
+ });
39
+ return {
40
+ ok: regressions.length === 0,
41
+ regressions: Object.freeze(regressions)
42
+ };
43
+ }
44
+ //#endregion
45
+ export { evalAgentRun as t };
46
+
47
+ //# sourceMappingURL=agent-run-CgPVFl0Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-run-CgPVFl0Z.js","names":[],"sources":["../src/eval/agent-run.ts"],"sourcesContent":["/**\n * evalAgentRun - Phase 22 (v1.2).\n *\n * Pure helper that gates a baseline-relative regression on iterations-to-goal\n * and total cost for an agent run. Standalone (no I/O). Callers wire fixture\n * discovery + persistence themselves; this kernel is the comparison engine.\n *\n * The shape mirrors the existing v1.1 `lattice eval` cost-regression contract\n * so a future `lattice eval --agent` CLI subcommand can reuse the same gate.\n */\n\nimport type { Usage } from \"../providers/provider.js\";\n\n/**\n * Summary of an agent run sufficient for regression analysis. Callers\n * typically derive this from an `AgentSuccess` via `iterations.length` and\n * cumulative `usage`. The schema is intentionally minimal so callers can\n * persist + load it across runs without dragging the full ReplayEnvelope.\n */\nexport interface AgentRunSnapshot {\n readonly iterationsToGoal: number;\n readonly usage: Usage;\n}\n\nexport interface EvalOptions {\n /**\n * Maximum tolerated INCREASE in iterations-to-goal versus the baseline.\n * Default 1 (one extra iteration tolerated). Set to 0 to require parity.\n */\n readonly iterationsToGoalRegressionLimit?: number;\n /**\n * Maximum tolerated FRACTIONAL cost increase versus the baseline.\n * Default 0.10 (10% increase tolerated). Compared as\n * `(current - baseline) / baseline`. Cost regressions are only\n * considered when BOTH snapshots have a non-null `costUsd`; mixed-cost\n * snapshots emit a `mixed-cost-unknown` regression so callers can decide\n * how to handle them.\n */\n readonly costUsdRegressionLimit?: number;\n}\n\nexport type EvalRegressionKind =\n | \"iterations-to-goal\"\n | \"cost-regression\"\n | \"mixed-cost-unknown\";\n\nexport interface EvalRegression {\n readonly kind: EvalRegressionKind;\n readonly baseline: number | null;\n readonly current: number | null;\n readonly limit: number;\n readonly message: string;\n}\n\nexport interface AgentEvalResult {\n readonly ok: boolean;\n readonly regressions: ReadonlyArray<EvalRegression>;\n}\n\nexport function evalAgentRun(\n baseline: AgentRunSnapshot,\n current: AgentRunSnapshot,\n options: EvalOptions = {},\n): AgentEvalResult {\n const iterLimit = options.iterationsToGoalRegressionLimit ?? 1;\n const costLimit = options.costUsdRegressionLimit ?? 0.1;\n const regressions: EvalRegression[] = [];\n\n // Iterations-to-goal regression.\n const iterDelta = current.iterationsToGoal - baseline.iterationsToGoal;\n if (iterDelta > iterLimit) {\n regressions.push({\n kind: \"iterations-to-goal\",\n baseline: baseline.iterationsToGoal,\n current: current.iterationsToGoal,\n limit: iterLimit,\n message: `Iterations-to-goal ${current.iterationsToGoal} exceeds baseline ${baseline.iterationsToGoal} by ${iterDelta} (limit: ${iterLimit}).`,\n });\n }\n\n // Cost regression.\n const bCost = baseline.usage.costUsd;\n const cCost = current.usage.costUsd;\n if (bCost === null && cCost === null) {\n // Both unmeasured: no signal, no regression.\n } else if (bCost === null || cCost === null) {\n regressions.push({\n kind: \"mixed-cost-unknown\",\n baseline: bCost,\n current: cCost,\n limit: costLimit,\n message: `Cost mixed: baseline=${bCost} current=${cCost}; cannot compare regression.`,\n });\n } else if (bCost > 0) {\n const ratio = (cCost - bCost) / bCost;\n if (ratio > costLimit) {\n regressions.push({\n kind: \"cost-regression\",\n baseline: bCost,\n current: cCost,\n limit: costLimit,\n message: `Cost regression: $${cCost.toFixed(6)} vs baseline $${bCost.toFixed(6)} (+${(ratio * 100).toFixed(1)}%; limit ${(costLimit * 100).toFixed(1)}%).`,\n });\n }\n } else if (bCost === 0 && cCost > 0) {\n // Baseline is free; any positive cost is a regression by definition.\n regressions.push({\n kind: \"cost-regression\",\n baseline: bCost,\n current: cCost,\n limit: costLimit,\n message: `Cost regression: baseline was $0; current $${cCost.toFixed(6)}.`,\n });\n }\n\n return {\n ok: regressions.length === 0,\n regressions: Object.freeze(regressions),\n };\n}\n"],"mappings":";AA2DA,SAAgB,aACd,UACA,SACA,UAAuB,EAAE,EACR;CACjB,MAAM,YAAY,QAAQ,mCAAmC;CAC7D,MAAM,YAAY,QAAQ,0BAA0B;CACpD,MAAM,cAAgC,EAAE;CAGxC,MAAM,YAAY,QAAQ,mBAAmB,SAAS;AACtD,KAAI,YAAY,UACd,aAAY,KAAK;EACf,MAAM;EACN,UAAU,SAAS;EACnB,SAAS,QAAQ;EACjB,OAAO;EACP,SAAS,sBAAsB,QAAQ,iBAAiB,oBAAoB,SAAS,iBAAiB,MAAM,UAAU,WAAW,UAAU;EAC5I,CAAC;CAIJ,MAAM,QAAQ,SAAS,MAAM;CAC7B,MAAM,QAAQ,QAAQ,MAAM;AAC5B,KAAI,UAAU,QAAQ,UAAU,MAAM,YAE3B,UAAU,QAAQ,UAAU,KACrC,aAAY,KAAK;EACf,MAAM;EACN,UAAU;EACV,SAAS;EACT,OAAO;EACP,SAAS,wBAAwB,MAAM,WAAW,MAAM;EACzD,CAAC;UACO,QAAQ,GAAG;EACpB,MAAM,SAAS,QAAQ,SAAS;AAChC,MAAI,QAAQ,UACV,aAAY,KAAK;GACf,MAAM;GACN,UAAU;GACV,SAAS;GACT,OAAO;GACP,SAAS,qBAAqB,MAAM,QAAQ,EAAE,CAAC,gBAAgB,MAAM,QAAQ,EAAE,CAAC,MAAM,QAAQ,KAAK,QAAQ,EAAE,CAAC,YAAY,YAAY,KAAK,QAAQ,EAAE,CAAC;GACvJ,CAAC;YAEK,UAAU,KAAK,QAAQ,EAEhC,aAAY,KAAK;EACf,MAAM;EACN,UAAU;EACV,SAAS;EACT,OAAO;EACP,SAAS,8CAA8C,MAAM,QAAQ,EAAE,CAAC;EACzE,CAAC;AAGJ,QAAO;EACL,IAAI,YAAY,WAAW;EAC3B,aAAa,OAAO,OAAO,YAAY;EACxC"}
@@ -0,0 +1,5 @@
1
+ import { ht as parseToolUseEnvelope, mt as ToolUseRequest } from "./provider-C2IfKsvz.js";
2
+ import { A as FormatToolsMode, M as FormattedToolsHandle, N as formatToolsForProvider, P as toolSchemaToJsonSchema, S as createNoopAgentHost, _ as AgentHost, a as CrewPolicy, b as AgentStorage, c as defineAgent, d as AgentFailureKind, f as AgentIntent, g as IterationRecord, i as runAgentCrew, j as FormatToolsOptions, k as ConversationTurn, l as AgentDeniedError, m as AgentSuccess, n as CrewResult, o as CrewRateLimitOverride, p as AgentResult, r as RunAgentCrewOptions, s as AgentSpec, t as CrewAgentResult, u as AgentFailure, v as AgentScheduler, x as AgentTransport, y as AgentSnapshot } from "./run-crew-Bnve5dyI.js";
3
+ import { A as createCostTracker, C as ProgressStatus, D as createTranscriptStore, E as TranscriptStore, O as CostBudgetStatus, S as GoalProgressTracker, T as TokenEstimator, _ as STUCK_REASONS, a as withRateLimit, b as GoalProgressOptions, c as PermissionHookContext, d as createPermissionContext, f as createPermissionGuardHook, g as ActionRecord, h as ActionHistoryOptions, i as createRateLimitGroup, j as runAgent, k as CostTracker, l as PermissionRule, m as ActionHistory, n as RateLimitGroupOptions, o as PermissionContext, p as permissionGuardRegisterOptions, r as RateLimitLease, s as PermissionDecisionInput, t as RateLimitGroup, u as PermissionVerdict, v as StuckReason, w as createGoalProgressTracker, x as GoalProgressStep, y as createActionHistory } from "./rate-limit-group-nDsBJqSu.js";
4
+ import { a as EvalRegressionKind, i as EvalRegression, n as AgentRunSnapshot, o as evalAgentRun, r as EvalOptions, t as AgentEvalResult } from "./agent-run-C6miAzwI.js";
5
+ export { type ActionHistory, type ActionHistoryOptions, type ActionRecord, AgentDeniedError, type AgentEvalResult, type AgentFailure, type AgentFailureKind, type AgentHost, type AgentIntent, type AgentResult, type AgentRunSnapshot, type AgentScheduler, type AgentSnapshot, type AgentSpec, type AgentStorage, type AgentSuccess, type AgentTransport, type ConversationTurn, type CostBudgetStatus, type CostTracker, type CrewAgentResult, type CrewPolicy, type CrewRateLimitOverride, type CrewResult, type EvalOptions, type EvalRegression, type EvalRegressionKind, type FormatToolsMode, type FormatToolsOptions, type FormattedToolsHandle, type GoalProgressOptions, type GoalProgressStep, type GoalProgressTracker, type IterationRecord, type PermissionContext, type PermissionDecisionInput, type PermissionHookContext, type PermissionRule, type PermissionVerdict, type ProgressStatus, type RateLimitGroup, type RateLimitGroupOptions, type RateLimitLease, type RunAgentCrewOptions, STUCK_REASONS, type StuckReason, type TokenEstimator, type ToolUseRequest, type TranscriptStore, createActionHistory, createCostTracker, createGoalProgressTracker, createNoopAgentHost, createPermissionContext, createPermissionGuardHook, createRateLimitGroup, createTranscriptStore, defineAgent, evalAgentRun, formatToolsForProvider, parseToolUseEnvelope, permissionGuardRegisterOptions, runAgent, runAgentCrew, toolSchemaToJsonSchema, withRateLimit };
package/dist/agents.js ADDED
@@ -0,0 +1,6 @@
1
+ import { a as createNoopAgentHost, i as AgentDeniedError, o as formatToolsForProvider, s as toolSchemaToJsonSchema, t as runAgent } from "./runtime-Dxiet5YS.js";
2
+ import { o as parseToolUseEnvelope } from "./validate-c7EL5uuH.js";
3
+ import { a as createTranscriptStore, i as createGoalProgressTracker, n as createPermissionGuardHook, o as defineAgent, r as permissionGuardRegisterOptions, t as createPermissionContext } from "./permission-context-CUKMo79F.js";
4
+ import { a as STUCK_REASONS, i as withRateLimit, o as createActionHistory, r as createRateLimitGroup, s as createCostTracker, t as runAgentCrew } from "./run-crew-B2fQLmgB.js";
5
+ import { t as evalAgentRun } from "./agent-run-CgPVFl0Z.js";
6
+ export { AgentDeniedError, STUCK_REASONS, createActionHistory, createCostTracker, createGoalProgressTracker, createNoopAgentHost, createPermissionContext, createPermissionGuardHook, createRateLimitGroup, createTranscriptStore, defineAgent, evalAgentRun, formatToolsForProvider, parseToolUseEnvelope, permissionGuardRegisterOptions, runAgent, runAgentCrew, toolSchemaToJsonSchema, withRateLimit };
@@ -0,0 +1,125 @@
1
+ //#region src/policy/policy.d.ts
2
+ type GatewayMetadataValue = string | number | boolean | null | readonly GatewayMetadataValue[] | {
3
+ readonly [key: string]: GatewayMetadataValue;
4
+ };
5
+ interface GatewayPolicy {
6
+ readonly routeTags?: readonly string[];
7
+ readonly providerPreferences?: readonly string[];
8
+ readonly metadata?: Record<string, GatewayMetadataValue>;
9
+ readonly allowFallbacks?: boolean;
10
+ }
11
+ interface PolicySpec {
12
+ readonly maxCostUsd?: number;
13
+ readonly latency?: "interactive" | "batch";
14
+ readonly privacy?: "standard" | "sensitive" | "restricted";
15
+ readonly providerAllowList?: readonly string[];
16
+ readonly providerDenyList?: readonly string[];
17
+ readonly noUpload?: boolean;
18
+ readonly noPublicUrl?: boolean;
19
+ readonly noLogging?: boolean;
20
+ readonly stream?: boolean;
21
+ readonly gateway?: GatewayPolicy;
22
+ readonly metadata?: Record<string, unknown>;
23
+ }
24
+ declare function mergePolicy(defaultPolicy?: PolicySpec, runPolicy?: PolicySpec): PolicySpec | undefined;
25
+ //#endregion
26
+ //#region src/artifacts/lineage.d.ts
27
+ type ArtifactTransformKind = "manual" | "generated" | "extraction" | "chunking" | "transcription" | "resizing" | "provider-packaging" | "tool-result" | "model-output";
28
+ interface ArtifactTransformDescriptor {
29
+ readonly kind: ArtifactTransformKind;
30
+ readonly name?: string;
31
+ readonly metadata?: Record<string, unknown>;
32
+ }
33
+ interface ArtifactParentRef {
34
+ readonly id: string;
35
+ readonly kind: ArtifactKind;
36
+ readonly mediaType?: string;
37
+ readonly source: ArtifactSource;
38
+ readonly label?: string;
39
+ readonly metadata?: Record<string, unknown>;
40
+ readonly privacy: ArtifactPrivacy;
41
+ readonly size?: ArtifactSize;
42
+ readonly fingerprint?: ArtifactFingerprint;
43
+ readonly storage?: ArtifactStorageRef;
44
+ readonly lineage?: ArtifactLineage;
45
+ }
46
+ interface ArtifactLineage {
47
+ readonly parents: readonly ArtifactParentRef[];
48
+ readonly transform: ArtifactTransformDescriptor;
49
+ }
50
+ //#endregion
51
+ //#region src/artifacts/artifact.d.ts
52
+ type ArtifactKind = "text" | "json" | "file" | "image" | "audio" | "video" | "document" | "url" | "tool-result";
53
+ type ProviderUploadArtifactSource = `provider-${"up"}${"load"}`;
54
+ type ArtifactSource = "inline" | "file" | "url" | "generated" | ProviderUploadArtifactSource | "tool";
55
+ type ArtifactPrivacy = NonNullable<PolicySpec["privacy"]>;
56
+ interface ArtifactSize {
57
+ readonly bytes?: number;
58
+ readonly characters?: number;
59
+ readonly pages?: number;
60
+ readonly width?: number;
61
+ readonly height?: number;
62
+ readonly durationMs?: number;
63
+ }
64
+ interface ArtifactFingerprint {
65
+ readonly algorithm: "sha256";
66
+ readonly value: string;
67
+ }
68
+ interface ArtifactStorageRef {
69
+ readonly storeId: string;
70
+ readonly key: string;
71
+ }
72
+ interface ArtifactOptions {
73
+ readonly id?: string;
74
+ readonly mediaType?: string;
75
+ readonly label?: string;
76
+ readonly metadata?: Record<string, unknown>;
77
+ readonly privacy?: ArtifactPrivacy;
78
+ readonly size?: ArtifactSize;
79
+ readonly fingerprint?: ArtifactFingerprint;
80
+ readonly storage?: ArtifactStorageRef;
81
+ readonly lineage?: ArtifactLineage;
82
+ }
83
+ interface ArtifactToolResultOptions extends ArtifactOptions {
84
+ readonly toolName: string;
85
+ readonly callId?: string;
86
+ }
87
+ interface ArtifactDerivedOptions extends ArtifactOptions {
88
+ readonly kind: ArtifactKind;
89
+ readonly source?: ArtifactSource;
90
+ readonly value?: unknown;
91
+ readonly parents: readonly ArtifactRef[];
92
+ readonly transform: ArtifactTransformDescriptor;
93
+ }
94
+ interface ArtifactRef {
95
+ readonly id: string;
96
+ readonly kind: ArtifactKind;
97
+ readonly mediaType?: string;
98
+ readonly source: ArtifactSource;
99
+ readonly label?: string;
100
+ readonly metadata?: Record<string, unknown>;
101
+ readonly privacy: ArtifactPrivacy;
102
+ readonly size?: ArtifactSize;
103
+ readonly fingerprint?: ArtifactFingerprint;
104
+ readonly storage?: ArtifactStorageRef;
105
+ readonly lineage?: ArtifactLineage;
106
+ }
107
+ type ArtifactInput = ArtifactRef & {
108
+ readonly value?: unknown;
109
+ };
110
+ declare const artifact: {
111
+ text(value: string, options?: ArtifactOptions): ArtifactInput;
112
+ json(value: unknown, options?: ArtifactOptions): ArtifactInput;
113
+ file(value: Blob | File | string, options?: ArtifactOptions): ArtifactInput;
114
+ image(value: Blob | File | string, options?: ArtifactOptions): ArtifactInput;
115
+ audio(value: Blob | File | string, options?: ArtifactOptions): ArtifactInput;
116
+ document(value: Blob | File | string, options?: ArtifactOptions): ArtifactInput;
117
+ url(value: string | URL, options?: ArtifactOptions): ArtifactInput;
118
+ toolResult(value: unknown, options: ArtifactToolResultOptions): ArtifactInput;
119
+ derive(input: ArtifactDerivedOptions): ArtifactInput;
120
+ };
121
+ declare function toArtifactRef(input: ArtifactInput | ArtifactRef): ArtifactRef;
122
+ declare function isArtifactRef(value: unknown): value is ArtifactRef;
123
+ //#endregion
124
+ export { mergePolicy as S, ArtifactTransformDescriptor as _, ArtifactOptions as a, GatewayPolicy as b, ArtifactSize as c, ArtifactToolResultOptions as d, artifact as f, ArtifactParentRef as g, ArtifactLineage as h, ArtifactKind as i, ArtifactSource as l, toArtifactRef as m, ArtifactFingerprint as n, ArtifactPrivacy as o, isArtifactRef as p, ArtifactInput as r, ArtifactRef as s, ArtifactDerivedOptions as t, ArtifactStorageRef as u, ArtifactTransformKind as v, PolicySpec as x, GatewayMetadataValue as y };
125
+ //# sourceMappingURL=artifact-Bg6mJGnm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-Bg6mJGnm.d.ts","names":[],"sources":["../src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AAO,IAAA,WAAa,OAAA,GAAW,eAAA,GAAuB,aAAA;eAItD,IAAA,GAAO,IAAA,WAAa,OAAA,GAAW,eAAA,GAAuB,aAAA;kBAInD,IAAA,GAAO,IAAA,WAAa,OAAA,GAAW,eAAA,GAAuB,aAAA;sBAIlD,GAAA,EAAG,OAAA,GAAW,eAAA,GAAuB,aAAA;6BAIhC,OAAA,EAAW,yBAAA,GAA4B,aAAA;gBAiBlD,sBAAA,GAAyB,aAAA;AAAA;AAAA,iBAoBzB,aAAA,CAAc,KAAA,EAAO,aAAA,GAAgB,WAAA,GAAc,WAAA;AAAA,iBAgBnD,aAAA,CAAc,KAAA,YAAiB,KAAA,IAAS,WAAA"}
@@ -0,0 +1,140 @@
1
+ import mime from "mime";
2
+ //#region src/artifacts/metadata.ts
3
+ const textEncoder = new TextEncoder();
4
+ function inferMediaType(value, options) {
5
+ if (options.mediaType !== void 0) return options.mediaType;
6
+ if (isBlobLike(value) && value.type !== "") return value.type;
7
+ if (typeof value === "string") return mime.getType(value) ?? options.defaultMediaType;
8
+ return options.defaultMediaType;
9
+ }
10
+ function measureArtifactValue(value, kind) {
11
+ if (kind === "text" && typeof value === "string") return measureString(value);
12
+ if (kind === "json") {
13
+ const serialized = JSON.stringify(value);
14
+ return serialized === void 0 ? void 0 : measureString(serialized);
15
+ }
16
+ if (isBlobLike(value)) return { bytes: value.size };
17
+ }
18
+ function measureString(value) {
19
+ return {
20
+ characters: value.length,
21
+ bytes: textEncoder.encode(value).byteLength
22
+ };
23
+ }
24
+ function isBlobLike(value) {
25
+ return typeof Blob !== "undefined" && value instanceof Blob;
26
+ }
27
+ //#endregion
28
+ //#region src/artifacts/artifact.ts
29
+ const artifact = {
30
+ text(value, options = {}) {
31
+ return createArtifact("text", "inline", value, options, "text/plain");
32
+ },
33
+ json(value, options = {}) {
34
+ return createArtifact("json", "inline", value, options, "application/json");
35
+ },
36
+ file(value, options = {}) {
37
+ return createArtifact("file", "file", value, options);
38
+ },
39
+ image(value, options = {}) {
40
+ return createArtifact("image", "file", value, options);
41
+ },
42
+ audio(value, options = {}) {
43
+ return createArtifact("audio", "file", value, options);
44
+ },
45
+ document(value, options = {}) {
46
+ return createArtifact("document", "file", value, options);
47
+ },
48
+ url(value, options = {}) {
49
+ return createArtifact("url", "url", value.toString(), options);
50
+ },
51
+ toolResult(value, options) {
52
+ return createArtifact("tool-result", "tool", value, {
53
+ ...options,
54
+ metadata: {
55
+ ...options.metadata,
56
+ toolName: options.toolName,
57
+ ...options.callId !== void 0 ? { callId: options.callId } : {}
58
+ }
59
+ }, "application/json");
60
+ },
61
+ derive(input) {
62
+ const { kind, source = "generated", value, parents, transform, ...options } = input;
63
+ return createArtifact(kind, source, value, {
64
+ ...options,
65
+ lineage: {
66
+ parents: parents.map(toArtifactRef),
67
+ transform
68
+ }
69
+ }, defaultMediaTypeForKind(kind));
70
+ }
71
+ };
72
+ function toArtifactRef(input) {
73
+ return {
74
+ id: input.id,
75
+ kind: input.kind,
76
+ source: input.source,
77
+ privacy: input.privacy,
78
+ ...input.mediaType !== void 0 ? { mediaType: input.mediaType } : {},
79
+ ...input.label !== void 0 ? { label: input.label } : {},
80
+ ...input.metadata !== void 0 ? { metadata: input.metadata } : {},
81
+ ...input.size !== void 0 ? { size: input.size } : {},
82
+ ...input.fingerprint !== void 0 ? { fingerprint: input.fingerprint } : {},
83
+ ...input.storage !== void 0 ? { storage: input.storage } : {},
84
+ ...input.lineage !== void 0 ? { lineage: input.lineage } : {}
85
+ };
86
+ }
87
+ function isArtifactRef(value) {
88
+ if (!isRecord(value)) return false;
89
+ return typeof value.id === "string" && isArtifactKind(value.kind) && isArtifactSource(value.source) && isArtifactPrivacy(value.privacy);
90
+ }
91
+ function createArtifact(kind, source, value, options, defaultMediaType) {
92
+ const mediaType = inferMediaType(value, {
93
+ kind,
94
+ ...options.mediaType !== void 0 ? { mediaType: options.mediaType } : {},
95
+ ...defaultMediaType !== void 0 ? { defaultMediaType } : {}
96
+ });
97
+ const size = options.size ?? measureArtifactValue(value, kind);
98
+ return {
99
+ id: options.id ?? createArtifactId(kind),
100
+ kind,
101
+ source,
102
+ value,
103
+ privacy: options.privacy ?? "standard",
104
+ ...mediaType !== void 0 ? { mediaType } : {},
105
+ ...options.label !== void 0 ? { label: options.label } : {},
106
+ ...options.metadata !== void 0 ? { metadata: options.metadata } : {},
107
+ ...size !== void 0 ? { size } : {},
108
+ ...options.fingerprint !== void 0 ? { fingerprint: options.fingerprint } : {},
109
+ ...options.storage !== void 0 ? { storage: options.storage } : {},
110
+ ...options.lineage !== void 0 ? { lineage: options.lineage } : {}
111
+ };
112
+ }
113
+ function defaultMediaTypeForKind(kind) {
114
+ switch (kind) {
115
+ case "text": return "text/plain";
116
+ case "json":
117
+ case "tool-result": return "application/json";
118
+ default: return;
119
+ }
120
+ }
121
+ function isArtifactKind(value) {
122
+ return value === "text" || value === "json" || value === "file" || value === "image" || value === "audio" || value === "video" || value === "document" || value === "url" || value === "tool-result";
123
+ }
124
+ function isArtifactSource(value) {
125
+ return value === "inline" || value === "file" || value === "url" || value === "generated" || value === `provider-upload` || value === "tool";
126
+ }
127
+ function isArtifactPrivacy(value) {
128
+ return value === "standard" || value === "sensitive" || value === "restricted";
129
+ }
130
+ function isRecord(value) {
131
+ return typeof value === "object" && value !== null;
132
+ }
133
+ function createArtifactId(kind) {
134
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") return `artifact:${kind}:${crypto.randomUUID()}`;
135
+ return `artifact:${kind}:${Date.now()}:${Math.random().toString(16).slice(2)}`;
136
+ }
137
+ //#endregion
138
+ export { isArtifactRef as n, toArtifactRef as r, artifact as t };
139
+
140
+ //# sourceMappingURL=artifact-DOfpeXLb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artifact-DOfpeXLb.js","names":[],"sources":["../src/artifacts/metadata.ts","../src/artifacts/artifact.ts"],"sourcesContent":["import mime from \"mime\";\n\nimport type { ArtifactKind, ArtifactOptions, ArtifactSize } from \"./artifact.js\";\n\nexport interface InferMediaTypeOptions\n extends Pick<ArtifactOptions, \"mediaType\"> {\n readonly kind: ArtifactKind;\n readonly defaultMediaType?: string;\n}\n\nconst textEncoder = new TextEncoder();\n\nexport function inferMediaType(\n value: unknown,\n options: InferMediaTypeOptions,\n): string | undefined {\n if (options.mediaType !== undefined) {\n return options.mediaType;\n }\n\n if (isBlobLike(value) && value.type !== \"\") {\n return value.type;\n }\n\n if (typeof value === \"string\") {\n return mime.getType(value) ?? options.defaultMediaType;\n }\n\n return options.defaultMediaType;\n}\n\nexport function measureArtifactValue(\n value: unknown,\n kind: ArtifactKind,\n): ArtifactSize | undefined {\n if (kind === \"text\" && typeof value === \"string\") {\n return measureString(value);\n }\n\n if (kind === \"json\") {\n const serialized = JSON.stringify(value);\n\n return serialized === undefined ? undefined : measureString(serialized);\n }\n\n if (isBlobLike(value)) {\n return {\n bytes: value.size,\n };\n }\n\n return undefined;\n}\n\nfunction measureString(value: string): ArtifactSize {\n return {\n characters: value.length,\n bytes: textEncoder.encode(value).byteLength,\n };\n}\n\nfunction isBlobLike(value: unknown): value is Blob {\n return typeof Blob !== \"undefined\" && value instanceof Blob;\n}\n","import type { PolicySpec } from \"../policy/policy.js\";\nimport type {\n ArtifactLineage,\n ArtifactTransformDescriptor,\n} from \"./lineage.js\";\nimport { inferMediaType, measureArtifactValue } from \"./metadata.js\";\n\nexport type ArtifactKind =\n | \"text\"\n | \"json\"\n | \"file\"\n | \"image\"\n | \"audio\"\n | \"video\"\n | \"document\"\n | \"url\"\n | \"tool-result\";\n\ntype ProviderUploadArtifactSource = `provider-${\"up\"}${\"load\"}`;\n\nexport type ArtifactSource =\n | \"inline\"\n | \"file\"\n | \"url\"\n | \"generated\"\n | ProviderUploadArtifactSource\n | \"tool\";\n\nexport type ArtifactPrivacy = NonNullable<PolicySpec[\"privacy\"]>;\n\nexport interface ArtifactSize {\n readonly bytes?: number;\n readonly characters?: number;\n readonly pages?: number;\n readonly width?: number;\n readonly height?: number;\n readonly durationMs?: number;\n}\n\nexport interface ArtifactFingerprint {\n readonly algorithm: \"sha256\";\n readonly value: string;\n}\n\nexport interface ArtifactStorageRef {\n readonly storeId: string;\n readonly key: string;\n}\n\nexport interface ArtifactOptions {\n readonly id?: string;\n readonly mediaType?: string;\n readonly label?: string;\n readonly metadata?: Record<string, unknown>;\n readonly privacy?: ArtifactPrivacy;\n readonly size?: ArtifactSize;\n readonly fingerprint?: ArtifactFingerprint;\n readonly storage?: ArtifactStorageRef;\n readonly lineage?: ArtifactLineage;\n}\n\nexport interface ArtifactToolResultOptions extends ArtifactOptions {\n readonly toolName: string;\n readonly callId?: string;\n}\n\nexport interface ArtifactDerivedOptions extends ArtifactOptions {\n readonly kind: ArtifactKind;\n readonly source?: ArtifactSource;\n readonly value?: unknown;\n readonly parents: readonly ArtifactRef[];\n readonly transform: ArtifactTransformDescriptor;\n}\n\nexport interface ArtifactRef {\n readonly id: string;\n readonly kind: ArtifactKind;\n readonly mediaType?: string;\n readonly source: ArtifactSource;\n readonly label?: string;\n readonly metadata?: Record<string, unknown>;\n readonly privacy: ArtifactPrivacy;\n readonly size?: ArtifactSize;\n readonly fingerprint?: ArtifactFingerprint;\n readonly storage?: ArtifactStorageRef;\n readonly lineage?: ArtifactLineage;\n}\n\nexport type ArtifactInput = ArtifactRef & {\n readonly value?: unknown;\n};\n\nexport const artifact = {\n text(value: string, options: ArtifactOptions = {}): ArtifactInput {\n return createArtifact(\"text\", \"inline\", value, options, \"text/plain\");\n },\n\n json(value: unknown, options: ArtifactOptions = {}): ArtifactInput {\n return createArtifact(\"json\", \"inline\", value, options, \"application/json\");\n },\n\n file(value: Blob | File | string, options: ArtifactOptions = {}): ArtifactInput {\n return createArtifact(\"file\", \"file\", value, options);\n },\n\n image(value: Blob | File | string, options: ArtifactOptions = {}): ArtifactInput {\n return createArtifact(\"image\", \"file\", value, options);\n },\n\n audio(value: Blob | File | string, options: ArtifactOptions = {}): ArtifactInput {\n return createArtifact(\"audio\", \"file\", value, options);\n },\n\n document(value: Blob | File | string, options: ArtifactOptions = {}): ArtifactInput {\n return createArtifact(\"document\", \"file\", value, options);\n },\n\n url(value: string | URL, options: ArtifactOptions = {}): ArtifactInput {\n return createArtifact(\"url\", \"url\", value.toString(), options);\n },\n\n toolResult(value: unknown, options: ArtifactToolResultOptions): ArtifactInput {\n return createArtifact(\n \"tool-result\",\n \"tool\",\n value,\n {\n ...options,\n metadata: {\n ...options.metadata,\n toolName: options.toolName,\n ...(options.callId !== undefined ? { callId: options.callId } : {}),\n },\n },\n \"application/json\",\n );\n },\n\n derive(input: ArtifactDerivedOptions): ArtifactInput {\n const {\n kind,\n source = \"generated\",\n value,\n parents,\n transform,\n ...options\n } = input;\n\n return createArtifact(kind, source, value, {\n ...options,\n lineage: {\n parents: parents.map(toArtifactRef),\n transform,\n },\n }, defaultMediaTypeForKind(kind));\n },\n};\n\nexport function toArtifactRef(input: ArtifactInput | ArtifactRef): ArtifactRef {\n return {\n id: input.id,\n kind: input.kind,\n source: input.source,\n privacy: input.privacy,\n ...(input.mediaType !== undefined ? { mediaType: input.mediaType } : {}),\n ...(input.label !== undefined ? { label: input.label } : {}),\n ...(input.metadata !== undefined ? { metadata: input.metadata } : {}),\n ...(input.size !== undefined ? { size: input.size } : {}),\n ...(input.fingerprint !== undefined ? { fingerprint: input.fingerprint } : {}),\n ...(input.storage !== undefined ? { storage: input.storage } : {}),\n ...(input.lineage !== undefined ? { lineage: input.lineage } : {}),\n };\n}\n\nexport function isArtifactRef(value: unknown): value is ArtifactRef {\n if (!isRecord(value)) {\n return false;\n }\n\n return (\n typeof value.id === \"string\" &&\n isArtifactKind(value.kind) &&\n isArtifactSource(value.source) &&\n isArtifactPrivacy(value.privacy)\n );\n}\n\nfunction createArtifact(\n kind: ArtifactKind,\n source: ArtifactSource,\n value: unknown,\n options: ArtifactOptions,\n defaultMediaType?: string,\n): ArtifactInput {\n const mediaType = inferMediaType(value, {\n kind,\n ...(options.mediaType !== undefined ? { mediaType: options.mediaType } : {}),\n ...(defaultMediaType !== undefined ? { defaultMediaType } : {}),\n });\n const size = options.size ?? measureArtifactValue(value, kind);\n\n return {\n id: options.id ?? createArtifactId(kind),\n kind,\n source,\n value,\n privacy: options.privacy ?? \"standard\",\n ...(mediaType !== undefined ? { mediaType } : {}),\n ...(options.label !== undefined ? { label: options.label } : {}),\n ...(options.metadata !== undefined ? { metadata: options.metadata } : {}),\n ...(size !== undefined ? { size } : {}),\n ...(options.fingerprint !== undefined ? { fingerprint: options.fingerprint } : {}),\n ...(options.storage !== undefined ? { storage: options.storage } : {}),\n ...(options.lineage !== undefined ? { lineage: options.lineage } : {}),\n };\n}\n\nfunction defaultMediaTypeForKind(kind: ArtifactKind): string | undefined {\n switch (kind) {\n case \"text\":\n return \"text/plain\";\n case \"json\":\n case \"tool-result\":\n return \"application/json\";\n default:\n return undefined;\n }\n}\n\nfunction isArtifactKind(value: unknown): value is ArtifactKind {\n return (\n value === \"text\" ||\n value === \"json\" ||\n value === \"file\" ||\n value === \"image\" ||\n value === \"audio\" ||\n value === \"video\" ||\n value === \"document\" ||\n value === \"url\" ||\n value === \"tool-result\"\n );\n}\n\nfunction isArtifactSource(value: unknown): value is ArtifactSource {\n return (\n value === \"inline\" ||\n value === \"file\" ||\n value === \"url\" ||\n value === \"generated\" ||\n value === `provider-${\"up\"}${\"load\"}` ||\n value === \"tool\"\n );\n}\n\nfunction isArtifactPrivacy(value: unknown): value is ArtifactPrivacy {\n return value === \"standard\" || value === \"sensitive\" || value === \"restricted\";\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction createArtifactId(kind: ArtifactKind): string {\n if (typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\") {\n return `artifact:${kind}:${crypto.randomUUID()}`;\n }\n\n return `artifact:${kind}:${Date.now()}:${Math.random().toString(16).slice(2)}`;\n}\n"],"mappings":";;AAUA,MAAM,cAAc,IAAI,aAAa;AAErC,SAAgB,eACd,OACA,S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UACV,UAAU,SACV,UAAU,eACV,UAAU,qBACV,UAAU;;AAId,SAAS,kBAAkB,OAA0C;AACnE,QAAO,UAAU,cAAc,UAAU,eAAe,UAAU;;AAGpE,SAAS,SAAS,OAAkD;AAClE,QAAO,OAAO,UAAU,YAAY,UAAU;;AAGhD,SAAS,iBAAiB,MAA4B;AACpD,KAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,WAChE,QAAO,YAAY,KAAK,GAAG,OAAO,YAAY;AAGhD,QAAO,YAAY,KAAK,GAAG,KAAK,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,MAAM,EAAE"}
@@ -0,0 +1,2 @@
1
+ import { _ as ArtifactTransformDescriptor, a as ArtifactOptions, c as ArtifactSize, d as ArtifactToolResultOptions, f as artifact, g as ArtifactParentRef, h as ArtifactLineage, i as ArtifactKind, l as ArtifactSource, m as toArtifactRef, n as ArtifactFingerprint, o as ArtifactPrivacy, p as isArtifactRef, r as ArtifactInput, s as ArtifactRef, t as ArtifactDerivedOptions, u as ArtifactStorageRef, v as ArtifactTransformKind } from "./artifact-Bg6mJGnm.js";
2
+ export { type ArtifactDerivedOptions, type ArtifactFingerprint, type ArtifactInput, type ArtifactKind, type ArtifactLineage, type ArtifactOptions, type ArtifactParentRef, type ArtifactPrivacy, type ArtifactRef, type ArtifactSize, type ArtifactSource, type ArtifactStorageRef, type ArtifactToolResultOptions, type ArtifactTransformDescriptor, type ArtifactTransformKind, artifact, isArtifactRef, toArtifactRef };
@@ -0,0 +1,2 @@
1
+ import { n as isArtifactRef, r as toArtifactRef, t as artifact } from "./artifact-DOfpeXLb.js";
2
+ export { artifact, isArtifactRef, toArtifactRef };
@@ -0,0 +1,3 @@
1
+ import { _ as VerifyFail, a as KeyEntry, c as ReceiptEnvelope, d as ReceiptRoute, f as ReceiptSignature, g as VerifyErrorKind, h as VerifyError, i as ContractVerdict, l as ReceiptModel, m as ReceiptUsageCanonical, o as KeySet, p as ReceiptSigner, r as CapabilityReceiptBody, s as KeyState, u as ReceiptRedaction, v as VerifyOk, y as VerifyResult } from "./infer-DLqp5QIM.js";
2
+ import { A as RemoteReceiptSignerProvider, B as ReplayEnvelope, C as GeneratedEd25519KeyPair, D as RemoteReceiptSignRequest, E as RemoteReceiptPayloadFormat, F as ExternalExecutionMetadata, G as replayOffline, H as redactArtifactRef, I as ExternalExecutionSidecar, K as rerunLive, L as ExternalExecutionSidecarOutputSpec, M as createMemoryKeySet, N as ExternalExecutionAuditInput, O as RemoteReceiptSignResult, P as ExternalExecutionAuditResult, R as ExternalExecutionUsage, S as verifyReceipt, T as generateEd25519KeyPairJwk, U as redactPlan, V as createReplayEnvelope, W as redactReplayEnvelope, X as CreateReceiptInput, Z as createReceipt, _ as ArtifactLoader, b as materializeReplayEnvelope, j as createRemoteReceiptSigner, k as RemoteReceiptSignerOptions, n as OtelAttributeValue, p as createOtelReceiptAttributes, r as OtelAttributes, v as MaterializationError, w as createInMemorySigner, x as receiptCid, y as MaterializeReplayEnvelopeOptions, z as createExternalExecutionAudit } from "./otel-BgM4e55_.js";
3
+ export { type ArtifactLoader, type CapabilityReceiptBody, type ContractVerdict, type CreateReceiptInput, type ExternalExecutionAuditInput, type ExternalExecutionAuditResult, type ExternalExecutionMetadata, type ExternalExecutionSidecar, type ExternalExecutionSidecarOutputSpec, type ExternalExecutionUsage, type GeneratedEd25519KeyPair, type KeyEntry, type KeySet, type KeyState, type MaterializationError, type MaterializeReplayEnvelopeOptions, type OtelAttributeValue, type OtelAttributes, type ReceiptEnvelope, type ReceiptModel, type ReceiptRedaction, type ReceiptRoute, type ReceiptSignature, type ReceiptSigner, type ReceiptUsageCanonical, type RemoteReceiptPayloadFormat, type RemoteReceiptSignRequest, type RemoteReceiptSignResult, type RemoteReceiptSignerOptions, type RemoteReceiptSignerProvider, type ReplayEnvelope, type VerifyError, type VerifyErrorKind, type VerifyFail, type VerifyOk, type VerifyResult, createExternalExecutionAudit, createInMemorySigner, createMemoryKeySet, createOtelReceiptAttributes, createReceipt, createRemoteReceiptSigner, createReplayEnvelope, generateEd25519KeyPairJwk, materializeReplayEnvelope, receiptCid, redactArtifactRef, redactPlan, redactReplayEnvelope, replayOffline, rerunLive, verifyReceipt };
package/dist/audit.js ADDED
@@ -0,0 +1,4 @@
1
+ import { t as createReceipt } from "./receipt-FYouoPHv.js";
2
+ import { n as receiptCid } from "./lineage-DBgoPWAZ.js";
3
+ import { a as replayOffline, c as createExternalExecutionAudit, d as createInMemorySigner, f as generateEd25519KeyPairJwk, g as createOtelReceiptAttributes, i as redactReplayEnvelope, m as createMemoryKeySet, n as redactArtifactRef, o as rerunLive, p as createRemoteReceiptSigner, r as redactPlan, s as materializeReplayEnvelope, t as createReplayEnvelope, u as verifyReceipt } from "./replay-CtIhpLek.js";
4
+ export { createExternalExecutionAudit, createInMemorySigner, createMemoryKeySet, createOtelReceiptAttributes, createReceipt, createRemoteReceiptSigner, createReplayEnvelope, generateEd25519KeyPairJwk, materializeReplayEnvelope, receiptCid, redactArtifactRef, redactPlan, redactReplayEnvelope, replayOffline, rerunLive, verifyReceipt };
@@ -0,0 +1,91 @@
1
+ //#region src/routing/catalog.ts
2
+ const DEFAULT_CATALOG_VERSION = "lattice:catalog:v1";
3
+ function createCapabilityCatalog(providers) {
4
+ return {
5
+ version: DEFAULT_CATALOG_VERSION,
6
+ models: providers.flatMap((provider) => {
7
+ if (provider.kind === "provider-adapter" && provider.capabilities !== void 0) return provider.capabilities;
8
+ return [defaultCapabilityForProvider(provider.id)];
9
+ })
10
+ };
11
+ }
12
+ function defaultCapabilityForProvider(providerId) {
13
+ return {
14
+ providerId,
15
+ modelId: `${providerId}:default`,
16
+ inputModalities: [
17
+ "text",
18
+ "json",
19
+ "image",
20
+ "audio",
21
+ "document",
22
+ "file",
23
+ "url",
24
+ "tool"
25
+ ],
26
+ outputModalities: ["text", "json"],
27
+ fileTransport: [
28
+ "inline",
29
+ "json",
30
+ "url",
31
+ "base64",
32
+ "extracted-text",
33
+ "transcript"
34
+ ],
35
+ contextWindow: 16e3,
36
+ structuredOutput: true,
37
+ toolUse: false,
38
+ streaming: false,
39
+ pricing: {
40
+ inputCostPer1M: 0,
41
+ outputCostPer1M: 0,
42
+ inputPer1kTokens: 0,
43
+ outputPer1kTokens: 0
44
+ },
45
+ latency: "interactive",
46
+ dataPolicy: {
47
+ privacy: ["standard", "sensitive"],
48
+ uploadRetention: "none",
49
+ supportsNoLogging: true,
50
+ supportsNoTraining: true
51
+ },
52
+ available: true
53
+ };
54
+ }
55
+ /**
56
+ * Resolve the effective per-1k token pricing for a capability.
57
+ *
58
+ * Prefers the explicit `inputPer1kTokens` / `outputPer1kTokens` fields and
59
+ * falls back to dividing the legacy per-1M fields by 1000 when only those
60
+ * are present. Returns `undefined` per side when neither shape supplies a
61
+ * value, so callers can distinguish "free / zero" (`0`) from "unknown"
62
+ * (`undefined`) — Phase 7 cost normalization treats unknown pricing as
63
+ * `usage.costUsd === null`, not `0`.
64
+ */
65
+ function effectivePer1kPricing(pricing) {
66
+ if (pricing === void 0) return {
67
+ inputPer1kTokens: void 0,
68
+ outputPer1kTokens: void 0
69
+ };
70
+ return {
71
+ inputPer1kTokens: pricing.inputPer1kTokens ?? (pricing.inputCostPer1M !== void 0 ? pricing.inputCostPer1M / 1e3 : void 0),
72
+ outputPer1kTokens: pricing.outputPer1kTokens ?? (pricing.outputCostPer1M !== void 0 ? pricing.outputCostPer1M / 1e3 : void 0)
73
+ };
74
+ }
75
+ function modalRank(modality) {
76
+ return {
77
+ text: 0,
78
+ json: 1,
79
+ image: 2,
80
+ audio: 3,
81
+ document: 4,
82
+ file: 5,
83
+ url: 6,
84
+ video: 7,
85
+ tool: 8
86
+ }[modality];
87
+ }
88
+ //#endregion
89
+ export { modalRank as a, effectivePer1kPricing as i, createCapabilityCatalog as n, defaultCapabilityForProvider as r, DEFAULT_CATALOG_VERSION as t };
90
+
91
+ //# sourceMappingURL=catalog-CAfYwB_-.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-CAfYwB_-.js","names":[],"sources":["../src/routing/catalog.ts"],"sourcesContent":["import type {\n CapabilityModality,\n ModelCapability,\n ProviderAdapter,\n ProviderPricingHint,\n ProviderRef,\n} from \"../providers/provider.js\";\n\nexport const DEFAULT_CATALOG_VERSION = \"lattice:catalog:v1\";\n\nexport interface CapabilityCatalog {\n readonly version: string;\n readonly models: readonly ModelCapability[];\n}\n\nexport function createCapabilityCatalog(\n providers: readonly (ProviderRef | ProviderAdapter)[],\n): CapabilityCatalog {\n return {\n version: DEFAULT_CATALOG_VERSION,\n models: providers.flatMap((provider) => {\n if (provider.kind === \"provider-adapter\" && provider.capabilities !== undefined) {\n return provider.capabilities;\n }\n\n return [defaultCapabilityForProvider(provider.id)];\n }),\n };\n}\n\nexport function defaultCapabilityForProvider(providerId: string): ModelCapability {\n return {\n providerId,\n modelId: `${providerId}:default`,\n inputModalities: [\"text\", \"json\", \"image\", \"audio\", \"document\", \"file\", \"url\", \"tool\"],\n outputModalities: [\"text\", \"json\"],\n fileTransport: [\"inline\", \"json\", \"url\", \"base64\", \"extracted-text\", \"transcript\"],\n contextWindow: 16_000,\n structuredOutput: true,\n toolUse: false,\n streaming: false,\n pricing: {\n inputCostPer1M: 0,\n outputCostPer1M: 0,\n inputPer1kTokens: 0,\n outputPer1kTokens: 0,\n },\n latency: \"interactive\",\n dataPolicy: {\n privacy: [\"standard\", \"sensitive\"],\n uploadRetention: \"none\",\n supportsNoLogging: true,\n supportsNoTraining: true,\n },\n available: true,\n };\n}\n\n/**\n * Resolve the effective per-1k token pricing for a capability.\n *\n * Prefers the explicit `inputPer1kTokens` / `outputPer1kTokens` fields and\n * falls back to dividing the legacy per-1M fields by 1000 when only those\n * are present. Returns `undefined` per side when neither shape supplies a\n * value, so callers can distinguish \"free / zero\" (`0`) from \"unknown\"\n * (`undefined`) — Phase 7 cost normalization treats unknown pricing as\n * `usage.costUsd === null`, not `0`.\n */\nexport function effectivePer1kPricing(\n pricing: ProviderPricingHint | undefined,\n): {\n readonly inputPer1kTokens: number | undefined;\n readonly outputPer1kTokens: number | undefined;\n} {\n if (pricing === undefined) {\n return { inputPer1kTokens: undefined, outputPer1kTokens: undefined };\n }\n\n const inputPer1k =\n pricing.inputPer1kTokens ??\n (pricing.inputCostPer1M !== undefined ? pricing.inputCostPer1M / 1000 : undefined);\n const outputPer1k =\n pricing.outputPer1kTokens ??\n (pricing.outputCostPer1M !== undefined ? pricing.outputCostPer1M / 1000 : undefined);\n\n return {\n inputPer1kTokens: inputPer1k,\n outputPer1kTokens: outputPer1k,\n };\n}\n\nexport function modalRank(modality: CapabilityModality): number {\n const ranks: Record<CapabilityModality, number> = {\n text: 0,\n json: 1,\n image: 2,\n audio: 3,\n document: 4,\n file: 5,\n url: 6,\n video: 7,\n tool: 8,\n };\n\n return ranks[modality];\n}\n"],"mappings":";AAQA,MAAa,0BAA0B;AAOvC,SAAgB,wBACd,WACmB;AACnB,QAAO;EACL,SAAS;EACT,QAAQ,UAAU,SAAS,aAAa;AACtC,OAAI,SAAS,SAAS,sBAAsB,SAAS,iBAAiB,KAAA,EACpE,QAAO,SAAS;AAGlB,UAAO,CAAC,6BAA6B,SAAS,GAAG,CAAC;IAClD;EACH;;AAGH,SAAgB,6BAA6B,YAAqC;AAChF,QAAO;EACL;EACA,SAAS,GAAG,WAAW;EACvB,iBAAiB;GAAC;GAAQ;GAAQ;GAAS;GAAS;GAAY;GAAQ;GAAO;GAAO;EACtF,kBAAkB,CAAC,QAAQ,OAAO;EAClC,eAAe;GAAC;GAAU;GAAQ;GAAO;GAAU;GAAkB;GAAa;EAClF,eAAe;EACf,kBAAkB;EAClB,SAAS;EACT,WAAW;EACX,SAAS;GACP,gBAAgB;GAChB,iBAAiB;GACjB,kBAAkB;GAClB,mBAAmB;GACpB;EACD,SAAS;EACT,YAAY;GACV,SAAS,CAAC,YAAY,YAAY;GAClC,iBAAiB;GACjB,mBAAmB;GACnB,oBAAoB;GACrB;EACD,WAAW;EACZ;;;;;;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