@outputai/cli 0.10.1-next.d815a8e.0 → 0.10.1-next.f6a7c1a.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.
@@ -80,7 +80,7 @@ services:
80
80
  condition: service_healthy
81
81
  worker:
82
82
  condition: service_healthy
83
- image: outputai/api:${OUTPUT_API_VERSION:-0.10.1-next.d815a8e.0}
83
+ image: outputai/api:${OUTPUT_API_VERSION:-0.10.1-next.f6a7c1a.0}
84
84
  init: true
85
85
  networks:
86
86
  - main
@@ -1,3 +1,3 @@
1
1
  {
2
- "framework": "0.10.1-next.d815a8e.0"
2
+ "framework": "0.10.1-next.f6a7c1a.0"
3
3
  }
@@ -3,13 +3,15 @@ import { readFile } from 'node:fs/promises';
3
3
  import { getWorkflowIdResult, getWorkflowIdRunsRidResult, getWorkflowIdTraceLog, getWorkflowIdRunsRidTraceLog } from '#api/generated/api.js';
4
4
  import { normalizeWorkflowStatus } from '#utils/normalize_workflow_status.js';
5
5
  import { TERMINAL_STATUSES } from '#utils/format_workflow_result.js';
6
+ import { createBoundedCache } from '#views/dev/utils/bounded_cache.js';
6
7
  const EMPTY_DETAIL = {
7
8
  result: null,
8
9
  trace: null,
9
10
  steps: [],
10
11
  loading: false
11
12
  };
12
- const runDetailCache = new Map();
13
+ const RUN_DETAIL_CACHE_MAX = 50;
14
+ const runDetailCache = createBoundedCache(RUN_DETAIL_CACHE_MAX);
13
15
  const stepNameOf = (node) => {
14
16
  if (node.name) {
15
17
  return node.name;
@@ -3,6 +3,7 @@ import { fetchWorkflowHistory } from '#services/workflow_history.js';
3
3
  import buildSpanLabels from '#utils/span_labels.js';
4
4
  import { isTerminalRunStatus } from '#views/dev/hooks/use_run_detail.js';
5
5
  import { usePoll, POLL_INTERVAL_MS } from '#views/dev/hooks/use_poll.js';
6
+ import { createBoundedCache } from '#views/dev/utils/bounded_cache.js';
6
7
  const EMPTY_GRAPH = {
7
8
  spans: [],
8
9
  totalDurationMs: 0,
@@ -11,7 +12,8 @@ const EMPTY_GRAPH = {
11
12
  loading: false,
12
13
  error: null
13
14
  };
14
- const stepGraphCache = new Map();
15
+ const STEP_GRAPH_CACHE_MAX = 50;
16
+ const stepGraphCache = createBoundedCache(STEP_GRAPH_CACHE_MAX);
15
17
  /**
16
18
  * Fetches a run's correlated step spans for the dev TUI's waterfall overlay,
17
19
  * reusing the same `fetchWorkflowHistory` path as the `workflow history` CLI
@@ -0,0 +1,14 @@
1
+ export interface BoundedCache<K, V extends {}> {
2
+ get(key: K): V | undefined;
3
+ set(key: K, value: V): void;
4
+ has(key: K): boolean;
5
+ clear(): void;
6
+ size(): number;
7
+ }
8
+ /**
9
+ * A small LRU cache backed by an insertion-ordered `Map`, capped at `maxSize`
10
+ * entries. Reading a key refreshes its recency; once the cap is exceeded the
11
+ * least-recently-used entries are evicted. Drop-in compatible with the
12
+ * `Map.get` / `Map.set` calls it replaces.
13
+ */
14
+ export declare const createBoundedCache: <K, V extends {}>(maxSize: number) => BoundedCache<K, V>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * A small LRU cache backed by an insertion-ordered `Map`, capped at `maxSize`
3
+ * entries. Reading a key refreshes its recency; once the cap is exceeded the
4
+ * least-recently-used entries are evicted. Drop-in compatible with the
5
+ * `Map.get` / `Map.set` calls it replaces.
6
+ */
7
+ export const createBoundedCache = (maxSize) => {
8
+ if (maxSize < 1) {
9
+ throw new Error('createBoundedCache: maxSize must be >= 1');
10
+ }
11
+ const entries = new Map();
12
+ return {
13
+ get(key) {
14
+ const value = entries.get(key);
15
+ if (value === undefined) {
16
+ return value;
17
+ }
18
+ entries.delete(key);
19
+ entries.set(key, value);
20
+ return value;
21
+ },
22
+ set(key, value) {
23
+ entries.delete(key);
24
+ entries.set(key, value);
25
+ if (entries.size > maxSize) {
26
+ const oldest = entries.keys().next();
27
+ if (!oldest.done) {
28
+ entries.delete(oldest.value);
29
+ }
30
+ }
31
+ },
32
+ has(key) {
33
+ return entries.has(key);
34
+ },
35
+ clear() {
36
+ entries.clear();
37
+ },
38
+ size() {
39
+ return entries.size;
40
+ }
41
+ };
42
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { createBoundedCache } from './bounded_cache.js';
3
+ describe('createBoundedCache', () => {
4
+ it('round-trips set and get', () => {
5
+ const cache = createBoundedCache(3);
6
+ cache.set('a', 1);
7
+ expect(cache.get('a')).toBe(1);
8
+ expect(cache.get('missing')).toBeUndefined();
9
+ });
10
+ it('evicts the oldest entry once maxSize is exceeded', () => {
11
+ const cache = createBoundedCache(2);
12
+ cache.set('a', 1);
13
+ cache.set('b', 2);
14
+ cache.set('c', 3);
15
+ expect(cache.has('a')).toBe(false);
16
+ expect(cache.get('b')).toBe(2);
17
+ expect(cache.get('c')).toBe(3);
18
+ });
19
+ it('refreshes recency on get so the touched entry survives eviction', () => {
20
+ const cache = createBoundedCache(2);
21
+ cache.set('a', 1);
22
+ cache.set('b', 2);
23
+ // Touch 'a' so 'b' becomes the least-recently-used entry.
24
+ expect(cache.get('a')).toBe(1);
25
+ cache.set('c', 3);
26
+ expect(cache.has('a')).toBe(true);
27
+ expect(cache.has('b')).toBe(false);
28
+ expect(cache.has('c')).toBe(true);
29
+ });
30
+ it('updates an existing key in place without growing', () => {
31
+ const cache = createBoundedCache(2);
32
+ cache.set('a', 1);
33
+ cache.set('a', 2);
34
+ expect(cache.get('a')).toBe(2);
35
+ expect(cache.size()).toBe(1);
36
+ });
37
+ it('supports has and clear', () => {
38
+ const cache = createBoundedCache(2);
39
+ cache.set('a', 1);
40
+ expect(cache.has('a')).toBe(true);
41
+ cache.clear();
42
+ expect(cache.has('a')).toBe(false);
43
+ expect(cache.size()).toBe(0);
44
+ });
45
+ it('never exceeds maxSize', () => {
46
+ const cache = createBoundedCache(3);
47
+ Array.from({ length: 100 }, (_, i) => i).forEach(i => {
48
+ cache.set(`key-${i}`, i);
49
+ expect(cache.size()).toBeLessThanOrEqual(3);
50
+ });
51
+ expect(cache.size()).toBe(3);
52
+ });
53
+ });
@@ -1671,5 +1671,5 @@
1671
1671
  ]
1672
1672
  }
1673
1673
  },
1674
- "version": "0.10.1-next.d815a8e.0"
1674
+ "version": "0.10.1-next.f6a7c1a.0"
1675
1675
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outputai/cli",
3
- "version": "0.10.1-next.d815a8e.0",
3
+ "version": "0.10.1-next.f6a7c1a.0",
4
4
  "description": "CLI for Output.ai workflow generation",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -38,9 +38,9 @@
38
38
  "semver": "7.7.4",
39
39
  "undici": "8.5.0",
40
40
  "yaml": "^2.8.3",
41
- "@outputai/evals": "0.10.1-next.d815a8e.0",
42
- "@outputai/credentials": "0.10.1-next.d815a8e.0",
43
- "@outputai/llm": "0.10.1-next.d815a8e.0"
41
+ "@outputai/credentials": "0.10.1-next.f6a7c1a.0",
42
+ "@outputai/evals": "0.10.1-next.f6a7c1a.0",
43
+ "@outputai/llm": "0.10.1-next.f6a7c1a.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/cli-progress": "3.11.6",