@outputai/llm 0.8.1 → 0.8.2-next.0f9af4b.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outputai/llm",
3
- "version": "0.8.1",
3
+ "version": "0.8.2-next.0f9af4b.0",
4
4
  "description": "Framework abstraction to interact with LLM models",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -12,26 +12,26 @@
12
12
  "entities": "8.0.0",
13
13
  "gray-matter": "4.0.3",
14
14
  "liquidjs": "10.25.7",
15
- "undici": "8.1.0",
16
- "@outputai/core": "0.8.1"
15
+ "undici": "8.5.0",
16
+ "@outputai/core": "0.8.2-next.0f9af4b.0"
17
17
  },
18
18
  "devDependencies": {
19
- "ai": "6.0.168",
20
19
  "@ai-sdk/amazon-bedrock": "4.0.111",
21
20
  "@ai-sdk/anthropic": "3.0.81",
22
21
  "@ai-sdk/azure": "3.0.68",
23
22
  "@ai-sdk/google-vertex": "4.0.140",
24
23
  "@ai-sdk/openai": "3.0.67",
25
- "@ai-sdk/perplexity": "3.0.33"
24
+ "@ai-sdk/perplexity": "3.0.33",
25
+ "ai": "6.0.168"
26
26
  },
27
27
  "peerDependencies": {
28
- "ai": ">=6 <7",
29
28
  "@ai-sdk/amazon-bedrock": ">=4 <5",
30
29
  "@ai-sdk/anthropic": ">=3 <4",
31
30
  "@ai-sdk/azure": ">=3 <4",
32
31
  "@ai-sdk/google-vertex": ">=4 <5",
33
32
  "@ai-sdk/openai": ">=3 <4",
34
- "@ai-sdk/perplexity": ">=3 <4"
33
+ "@ai-sdk/perplexity": ">=3 <4",
34
+ "ai": ">=6 <7"
35
35
  },
36
36
  "license": "Apache-2.0",
37
37
  "publishConfig": {
package/src/agent.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ValidationError } from '@outputai/core';
2
- import { resolveInvocationDir } from '@outputai/core/sdk_utils';
2
+ import { Path } from '@outputai/core/sdk/helpers';
3
3
  import { ToolLoopAgent as AIToolLoopAgent, stepCountIs } from 'ai';
4
4
  import { loadAiSdkTextOptions } from './ai_sdk_options.js';
5
5
  import { prepareTextPrompt } from './prompt/prepare_text.js';
@@ -38,8 +38,8 @@ export class Agent extends AIToolLoopAgent {
38
38
  }
39
39
 
40
40
  // Must be captured synchronously — Temporal async activity execution
41
- // breaks the call stack, so resolveInvocationDir() fails if called lazily.
42
- const resolvedPromptDir = promptDir ?? resolveInvocationDir();
41
+ // breaks the call stack, so Path.resolveInvocationDir() fails if called lazily.
42
+ const resolvedPromptDir = promptDir ?? Path.resolveInvocationDir();
43
43
 
44
44
  const { loadedPrompt, tools } = prepareTextPrompt( { prompt, variables, promptDir: resolvedPromptDir, skills, tools: toolsArg } );
45
45
 
package/src/agent.spec.js CHANGED
@@ -46,8 +46,10 @@ vi.mock( '@outputai/core', () => ( {
46
46
  ValidationError: coreMocks.ValidationError
47
47
  } ) );
48
48
 
49
- vi.mock( '@outputai/core/sdk_utils', () => ( {
50
- resolveInvocationDir: () => state.invocationDir
49
+ vi.mock( '@outputai/core/sdk/helpers', () => ( {
50
+ Path: {
51
+ resolveInvocationDir: () => state.invocationDir
52
+ }
51
53
  } ) );
52
54
 
53
55
  vi.mock( 'ai', () => {
package/src/cost/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { fetchModelsPricing } from './fetch_models_pricing.js';
2
- import { Tracing } from '@outputai/core/sdk_activity_integration';
2
+ import { Tracing } from '@outputai/core/sdk/runtime';
3
3
 
4
4
  /**
5
5
  * Calculates the cost of an llm call based on the model and usage.
@@ -6,7 +6,7 @@ vi.mock( './fetch_models_pricing.js', () => ( {
6
6
  fetchModelsPricing: ( ...args ) => mockFetchModelsPricing( ...args )
7
7
  } ) );
8
8
 
9
- vi.mock( '@outputai/core/sdk_activity_integration', () => {
9
+ vi.mock( '@outputai/core/sdk/runtime', () => {
10
10
  class LLMUsage {
11
11
  static TYPE = 'llm:usage';
12
12
  type = LLMUsage.TYPE;
@@ -44,7 +44,7 @@ vi.mock( '@outputai/core/sdk_activity_integration', () => {
44
44
  };
45
45
  } );
46
46
 
47
- import { Tracing } from '@outputai/core/sdk_activity_integration';
47
+ import { Tracing } from '@outputai/core/sdk/runtime';
48
48
  import { calculateLLMCallCost } from './index.js';
49
49
 
50
50
  const expectLLMUsage = ( result, { modelId, usage, total, tokensUsed } ) => {
@@ -1,5 +1,5 @@
1
1
  import { encodeXML, decodeXML } from 'entities';
2
- import { isPlainObject } from '@outputai/core/sdk_utils';
2
+ import { Objects } from '@outputai/core/sdk/helpers';
3
3
 
4
4
  const VAR_SAFE_FILTER = '__var_safe';
5
5
 
@@ -56,7 +56,7 @@ export const decode = value => {
56
56
  if ( Array.isArray( value ) ) {
57
57
  return value.map( decode );
58
58
  }
59
- if ( isPlainObject( value ) ) {
59
+ if ( Objects.isPlainObject( value ) ) {
60
60
  return Object.fromEntries(
61
61
  Object.entries( value ).map( ( [ k, v ] ) => [ k, decode( v ) ] )
62
62
  );
@@ -1,6 +1,6 @@
1
1
  import { join } from 'path';
2
2
  import { readdirSync, readFileSync } from 'node:fs';
3
- import { resolveInvocationDir } from '@outputai/core/sdk_utils';
3
+ import { Path } from '@outputai/core/sdk/helpers';
4
4
  import { FatalError } from '@outputai/core';
5
5
 
6
6
  const scanDir = dir => {
@@ -41,5 +41,5 @@ const findContent = ( name, dir ) => {
41
41
  * @param {string} [dir] - Directory to search, defaults to invocation directory
42
42
  * @returns {{ content: string, dir: string } | null}
43
43
  */
44
- export const loadContent = ( name, dir = resolveInvocationDir() ) =>
44
+ export const loadContent = ( name, dir = Path.resolveInvocationDir() ) =>
45
45
  findContent( name, dir ) ?? null;
@@ -6,9 +6,11 @@ import { tmpdir } from 'node:os';
6
6
  // Hoisted state so mocks can read dynamic values set in tests
7
7
  const state = vi.hoisted( () => ( { dir: '', entries: {} } ) );
8
8
 
9
- // Mock core utils to control resolveInvocationDir
10
- vi.mock( '@outputai/core/sdk_utils', () => ( {
11
- resolveInvocationDir: () => state.dir
9
+ // Mock SDK helpers to control resolveInvocationDir
10
+ vi.mock( '@outputai/core/sdk/helpers', () => ( {
11
+ Path: {
12
+ resolveInvocationDir: () => state.dir
13
+ }
12
14
  } ) );
13
15
 
14
16
  // Mock node:fs.readFileSync for directory scans while delegating file reads
@@ -1,4 +1,4 @@
1
- import { Tracing, emitEvent } from '@outputai/core/sdk_activity_integration';
1
+ import { Tracing, Event } from '@outputai/core/sdk/runtime';
2
2
 
3
3
  export const startTrace = ( { name, ...details } ) => {
4
4
  const traceId = `${name}-${Date.now()}`;
@@ -13,7 +13,7 @@ export const endTraceWithError = ( { traceId, error } ) => {
13
13
  export const endTraceWithSuccess = ( { traceId, result, cost, ...extra } ) => {
14
14
  if ( cost ) {
15
15
  Tracing.addEventAttribute( { eventId: traceId, attribute: cost } );
16
- emitEvent( 'cost:llm:request', cost );
16
+ Event.emit( 'cost:llm:request', cost );
17
17
  }
18
18
  Tracing.addEventEnd( { id: traceId, details: { result, ...extra } } );
19
19
  };
@@ -1,19 +1,22 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
2
 
3
- vi.mock( '@outputai/core/sdk_activity_integration', () => ( {
3
+ vi.mock( '@outputai/core/sdk/runtime', () => ( {
4
4
  Tracing: {
5
5
  addEventStart: vi.fn(),
6
6
  addEventError: vi.fn(),
7
7
  addEventAttribute: vi.fn(),
8
8
  addEventEnd: vi.fn()
9
9
  },
10
- emitEvent: vi.fn()
10
+ Event: {
11
+ emit: vi.fn()
12
+ }
11
13
  } ) );
12
14
 
13
- import { Tracing, emitEvent } from '@outputai/core/sdk_activity_integration';
15
+ import { Tracing, Event } from '@outputai/core/sdk/runtime';
14
16
  import { startTrace, endTraceWithError, endTraceWithSuccess } from './trace.js';
15
17
 
16
18
  const tracing = vi.mocked( Tracing, true );
19
+ const event = vi.mocked( Event, true );
17
20
 
18
21
  describe( 'trace utils', () => {
19
22
  beforeEach( () => {
@@ -69,7 +72,7 @@ describe( 'trace utils', () => {
69
72
  eventId: 'trace-a',
70
73
  attribute: cost
71
74
  } );
72
- expect( emitEvent ).toHaveBeenCalledWith( 'cost:llm:request', cost );
75
+ expect( event.emit ).toHaveBeenCalledWith( 'cost:llm:request', cost );
73
76
  expect( tracing.addEventEnd ).toHaveBeenCalledWith( {
74
77
  id: 'trace-a',
75
78
  details: {
@@ -94,7 +97,7 @@ describe( 'trace utils', () => {
94
97
  } );
95
98
 
96
99
  expect( tracing.addEventAttribute ).not.toHaveBeenCalled();
97
- expect( emitEvent ).not.toHaveBeenCalled();
100
+ expect( event.emit ).not.toHaveBeenCalled();
98
101
  expect( tracing.addEventEnd ).toHaveBeenCalledWith( {
99
102
  id: 'trace-no-cost',
100
103
  details: {