omnicell-router 0.2.0 → 0.3.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 (102) hide show
  1. package/backend/dist/budget/budget-manager.d.ts +25 -0
  2. package/backend/dist/budget/budget-manager.js +54 -0
  3. package/backend/dist/cli/clients/index.js +2 -0
  4. package/backend/dist/cli/clients/omp.d.ts +53 -0
  5. package/backend/dist/cli/clients/omp.js +664 -0
  6. package/backend/dist/cli/clients/pi.js +79 -32
  7. package/backend/dist/cli/index.js +2 -2
  8. package/backend/dist/cli/types.d.ts +1 -1
  9. package/backend/dist/config/governance-limits.d.ts +68 -0
  10. package/backend/dist/config/governance-limits.js +261 -0
  11. package/backend/dist/config/index.js +1 -1
  12. package/backend/dist/config/types.d.ts +15 -5
  13. package/backend/dist/flywheel/collector.d.ts +74 -0
  14. package/backend/dist/flywheel/collector.js +235 -0
  15. package/backend/dist/flywheel/dataset.d.ts +130 -0
  16. package/backend/dist/flywheel/dataset.js +638 -0
  17. package/backend/dist/flywheel/decision-capture.d.ts +68 -0
  18. package/backend/dist/flywheel/decision-capture.js +85 -0
  19. package/backend/dist/flywheel/prune.d.ts +133 -0
  20. package/backend/dist/flywheel/prune.js +495 -0
  21. package/backend/dist/flywheel/schema.d.ts +108 -0
  22. package/backend/dist/flywheel/schema.js +117 -0
  23. package/backend/dist/flywheel/trainer.d.ts +84 -0
  24. package/backend/dist/flywheel/trainer.js +198 -0
  25. package/backend/dist/harness/adapters/amp.js +1 -0
  26. package/backend/dist/harness/adapters/claude.js +1 -0
  27. package/backend/dist/harness/adapters/cline.js +3 -1
  28. package/backend/dist/harness/adapters/codex.js +3 -1
  29. package/backend/dist/harness/adapters/cursor.js +1 -0
  30. package/backend/dist/harness/adapters/declarative.d.ts +3 -1
  31. package/backend/dist/harness/adapters/declarative.js +15 -1
  32. package/backend/dist/harness/adapters/dsh.js +1 -1
  33. package/backend/dist/harness/adapters/gemini-cli.js +1 -0
  34. package/backend/dist/harness/adapters/github-copilot.js +1 -0
  35. package/backend/dist/harness/adapters/index.d.ts +11 -3
  36. package/backend/dist/harness/adapters/index.js +48 -1
  37. package/backend/dist/harness/adapters/omp.d.ts +11 -0
  38. package/backend/dist/harness/adapters/omp.js +22 -0
  39. package/backend/dist/harness/adapters/opencode.js +1 -0
  40. package/backend/dist/harness/adapters/pi.js +2 -1
  41. package/backend/dist/harness/adapters/types.d.ts +19 -4
  42. package/backend/dist/harness/adapters/windsurf.js +1 -0
  43. package/backend/dist/harness/adapters/zed.js +3 -1
  44. package/backend/dist/harness/hosts.js +1 -0
  45. package/backend/dist/harness/translation.js +12 -4
  46. package/backend/dist/harness/types.d.ts +2 -2
  47. package/backend/dist/harness/writers/skill.d.ts +1 -1
  48. package/backend/dist/opencode/agents.d.ts +7 -0
  49. package/backend/dist/opencode/agents.js +22 -3
  50. package/backend/dist/opencode/catalog/custom-store.d.ts +50 -0
  51. package/backend/dist/opencode/catalog/custom-store.js +144 -0
  52. package/backend/dist/opencode/credentials/push.d.ts +38 -0
  53. package/backend/dist/opencode/credentials/push.js +116 -0
  54. package/backend/dist/opencode/credentials/reconcile.d.ts +49 -0
  55. package/backend/dist/opencode/credentials/reconcile.js +216 -0
  56. package/backend/dist/opencode/sync.d.ts +29 -0
  57. package/backend/dist/opencode/sync.js +186 -0
  58. package/backend/dist/pipeline/account-selection.d.ts +101 -0
  59. package/backend/dist/pipeline/account-selection.js +112 -0
  60. package/backend/dist/pipeline/orchestrator.js +34 -3
  61. package/backend/dist/providers/systemone.d.ts +29 -0
  62. package/backend/dist/providers/systemone.js +170 -0
  63. package/backend/dist/ratelimit/duration.d.ts +24 -0
  64. package/backend/dist/ratelimit/duration.js +43 -0
  65. package/backend/dist/ratelimit/governance-runtime.d.ts +121 -0
  66. package/backend/dist/ratelimit/governance-runtime.js +183 -0
  67. package/backend/dist/ratelimit/index.d.ts +4 -0
  68. package/backend/dist/ratelimit/index.js +4 -0
  69. package/backend/dist/ratelimit/limiter.d.ts +157 -0
  70. package/backend/dist/ratelimit/limiter.js +244 -0
  71. package/backend/dist/ratelimit/sliding-window-counter.d.ts +63 -0
  72. package/backend/dist/ratelimit/sliding-window-counter.js +103 -0
  73. package/backend/dist/ratelimit/subject.d.ts +26 -0
  74. package/backend/dist/ratelimit/subject.js +28 -0
  75. package/backend/dist/resilience/account-state.d.ts +84 -0
  76. package/backend/dist/resilience/account-state.js +228 -0
  77. package/backend/dist/router/layer1-classifier.d.ts +111 -0
  78. package/backend/dist/router/layer1-classifier.js +467 -0
  79. package/backend/dist/router/layer2-judge.d.ts +111 -0
  80. package/backend/dist/router/layer2-judge.js +373 -0
  81. package/backend/dist/router/retry-escalation.d.ts +89 -0
  82. package/backend/dist/router/retry-escalation.js +99 -0
  83. package/backend/dist/routes/flywheel.d.ts +3 -0
  84. package/backend/dist/routes/flywheel.js +268 -0
  85. package/backend/dist/routes/harness.js +4 -1
  86. package/backend/dist/routes/systemone.d.ts +3 -0
  87. package/backend/dist/routes/systemone.js +90 -0
  88. package/backend/dist/server.d.ts +0 -15
  89. package/backend/dist/server.js +40 -43
  90. package/backend/dist/session/session-manager.d.ts +15 -0
  91. package/backend/dist/session/session-manager.js +17 -0
  92. package/backend/dist/session/session-row.d.ts +78 -0
  93. package/backend/dist/session/session-row.js +52 -0
  94. package/backend/dist/surfaces/governance-envelope.d.ts +34 -0
  95. package/backend/dist/surfaces/governance-envelope.js +47 -0
  96. package/backend/dist/utils/token-estimator.d.ts +7 -0
  97. package/backend/dist/utils/token-estimator.js +20 -0
  98. package/bin/ocr.js +2 -2
  99. package/frontend/dist/assets/{index-DvXKvNxl.js → index-B7GKsUyU.js} +264 -244
  100. package/frontend/dist/assets/{index-1o7qI-KJ.css → index-DLKLOkQJ.css} +1 -1
  101. package/frontend/dist/index.html +2 -2
  102. package/package.json +1 -1
@@ -0,0 +1,25 @@
1
+ import { Usage } from '../types/openai.js';
2
+ import { ModelPricing } from '../types/router.js';
3
+ /**
4
+ * FinOps cost accounting only — the budget/limit enforcement mechanism
5
+ * (reasoning-effort clamping + max_completion_tokens cap) was removed;
6
+ * cost math is kept because savings/trace stats still depend on it.
7
+ */
8
+ export declare class BudgetManager {
9
+ /**
10
+ * Calculate exact cost in USD for a given usage and model pricing.
11
+ *
12
+ * Reasoning tokens are billed at `pricing.reasoning` when the catalog
13
+ * declares it (preferred for models with separate thinking surcharge
14
+ * like OpenAI o-series / Anthropic extended-thinking). Otherwise they
15
+ * roll into `pricing.output` at the same rate — most models bill
16
+ * thinking tokens as plain output, so this is the natural baseline and
17
+ * a higher effort level simply produces more tokens, which costs more
18
+ * without any per-token multiplier gymnastics.
19
+ */
20
+ static calculateCost(usage: Usage | undefined, pricing: ModelPricing): number;
21
+ /**
22
+ * Calculate baseline cost if this request was sent to a standard plus-tier model (e.g. Claude 3.5 Sonnet).
23
+ */
24
+ static calculateBaselineCost(usage: Usage | undefined, baselinePricing: ModelPricing): number;
25
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * FinOps cost accounting only — the budget/limit enforcement mechanism
3
+ * (reasoning-effort clamping + max_completion_tokens cap) was removed;
4
+ * cost math is kept because savings/trace stats still depend on it.
5
+ */
6
+ export class BudgetManager {
7
+ /**
8
+ * Calculate exact cost in USD for a given usage and model pricing.
9
+ *
10
+ * Reasoning tokens are billed at `pricing.reasoning` when the catalog
11
+ * declares it (preferred for models with separate thinking surcharge
12
+ * like OpenAI o-series / Anthropic extended-thinking). Otherwise they
13
+ * roll into `pricing.output` at the same rate — most models bill
14
+ * thinking tokens as plain output, so this is the natural baseline and
15
+ * a higher effort level simply produces more tokens, which costs more
16
+ * without any per-token multiplier gymnastics.
17
+ */
18
+ static calculateCost(usage, pricing) {
19
+ if (!usage)
20
+ return 0;
21
+ const cachedPromptTokens = usage.prompt_tokens_details?.cached_tokens || 0;
22
+ const uncachedPromptTokens = Math.max(0, usage.prompt_tokens - cachedPromptTokens);
23
+ const completionTokens = usage.completion_tokens || 0;
24
+ const reasoningTokens = usage.completion_tokens_details?.reasoning_tokens || 0;
25
+ const promptCost = (uncachedPromptTokens / 1_000_000) * pricing.input;
26
+ const cachedPromptCost = (cachedPromptTokens / 1_000_000) * pricing.cacheRead;
27
+ let completionCost;
28
+ if (pricing.reasoning && reasoningTokens > 0) {
29
+ // Catalog declares a dedicated reasoning price — charge reasoning
30
+ // tokens at that rate and the visible output at the normal rate.
31
+ const normalCompletionTokens = Math.max(0, completionTokens - reasoningTokens);
32
+ completionCost =
33
+ (normalCompletionTokens / 1_000_000) * pricing.output +
34
+ (reasoningTokens / 1_000_000) * pricing.reasoning;
35
+ }
36
+ else {
37
+ // No dedicated reasoning price → reasoning tokens are billed as
38
+ // plain output (the model-default behavior of every upstream we
39
+ // route to today). Higher effort simply spends more tokens.
40
+ completionCost = (completionTokens / 1_000_000) * pricing.output;
41
+ }
42
+ return promptCost + cachedPromptCost + completionCost;
43
+ }
44
+ /**
45
+ * Calculate baseline cost if this request was sent to a standard plus-tier model (e.g. Claude 3.5 Sonnet).
46
+ */
47
+ static calculateBaselineCost(usage, baselinePricing) {
48
+ if (!usage)
49
+ return 0;
50
+ const promptCost = (usage.prompt_tokens / 1_000_000) * baselinePricing.input;
51
+ const completionCost = (usage.completion_tokens / 1_000_000) * baselinePricing.output;
52
+ return promptCost + completionCost;
53
+ }
54
+ }
@@ -4,6 +4,7 @@ import { ClaudeClientAdapter } from './claude.js';
4
4
  import { CodexClientAdapter } from './codex.js';
5
5
  import { PiClientAdapter } from './pi.js';
6
6
  import { DshClientAdapter } from './dsh.js';
7
+ import { OmpClientAdapter } from './omp.js';
7
8
  const adapters = {
8
9
  opencode: new OpenCodeClientAdapter(),
9
10
  'opencode-proxy': new OpenCodeProxyClientAdapter(),
@@ -11,6 +12,7 @@ const adapters = {
11
12
  codex: new CodexClientAdapter(),
12
13
  pi: new PiClientAdapter(),
13
14
  dsh: new DshClientAdapter(),
15
+ omp: new OmpClientAdapter(),
14
16
  };
15
17
  export function getClientAdapter(name) {
16
18
  const normalized = name.toLowerCase().trim();
@@ -0,0 +1,53 @@
1
+ import { ClientAdapter } from './base.js';
2
+ import { ClientHookStatus, ModelProfileBinding } from '../types.js';
3
+ /** Resolve the models file inside an omp agent dir: `.yml` wins over
4
+ * `.yaml` (omp's own precedence); the `.yml` name is the default target. */
5
+ export declare function resolveOmpModelsPath(dir: string): string;
6
+ export declare class OmpClientAdapter implements ClientAdapter {
7
+ name: "omp";
8
+ displayName: string;
9
+ /** models.yml (or models.yaml when only that exists) — the hook target. */
10
+ getConfigPath(): string;
11
+ /** config.yml (modelRoles) — derived from the models dir so test redirects isolate it too. */
12
+ getRolesPath(): string;
13
+ getStatus(): Promise<ClientHookStatus>;
14
+ setup(options?: {
15
+ port?: number;
16
+ models?: Record<string, string>;
17
+ apiKey?: string;
18
+ contextWindow?: number;
19
+ extraModels?: string[]; /** Effective role bindings (manual + profile-linked, merged by the console route): role → modelRef. */
20
+ agentModels?: Record<string, string>; /** Profile-link echo for the OCR sidecar meta: role → profile-slot key ('' id = un-link). */
21
+ profile?: ModelProfileBinding;
22
+ }): Promise<{
23
+ success: boolean;
24
+ message: string;
25
+ }>;
26
+ /**
27
+ * Profile-change write-through: re-resolve the linked roles' slot keys
28
+ * against the JUST-SAVED profile slots and rewrite the linked modelRoles
29
+ * entries WITHOUT a full setup. Only LINKED roles are touched: manual picks
30
+ * and foreign pins stay byte-identical. A slot ref of 'auto' — or a slot
31
+ * the profile no longer defines — strips the role's router-owned entry
32
+ * (inherit the tier preset). A no-diff save writes nothing.
33
+ */
34
+ refreshProfileBindings(profileId: string, tags: Record<string, string>, slots: Record<string, string>): Promise<{
35
+ success: boolean;
36
+ message: string;
37
+ }>;
38
+ teardown(): Promise<{
39
+ success: boolean;
40
+ message: string;
41
+ }>;
42
+ /** Remove the OCR provider from a models document in place; true when changed. */
43
+ private stripProvider;
44
+ /**
45
+ * Remove router-owned modelRoles entries from config.yml (values qualified
46
+ * with the `omnicell-router/` prefix). Restore-then-strip like models.yml:
47
+ * a backup written by a re-setup contains the pins, so restoring alone
48
+ * would leave them behind. The user's own roles survive; an emptied
49
+ * modelRoles node is pruned, and a config.yml that ends up completely
50
+ * empty (fresh-install case) is removed outright.
51
+ */
52
+ private stripModelRoles;
53
+ }