@outputai/core 0.15.1-next.fd6bb62.0 → 0.16.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/dist/credentials/index.d.ts +1 -1
- package/dist/credentials/types.d.ts +4 -4
- package/dist/evals/aggregate.d.ts +2 -0
- package/dist/evals/aggregate.js +11 -0
- package/dist/evals/eval_workflow.d.ts +20 -0
- package/dist/evals/eval_workflow.js +98 -0
- package/dist/evals/index.d.ts +7 -0
- package/dist/evals/index.js +4 -0
- package/dist/evals/interpret.d.ts +3 -0
- package/dist/evals/interpret.js +40 -0
- package/dist/evals/schemas.d.ts +96 -0
- package/dist/evals/schemas.js +60 -0
- package/dist/evals/verdict.d.ts +27 -0
- package/dist/evals/verdict.js +109 -0
- package/dist/evals/verify.d.ts +42 -0
- package/dist/evals/verify.js +19 -0
- package/package.json +57 -15
- package/src/consts.d.ts +2 -0
- package/src/helpers/path.js +34 -0
- package/src/http/fetch/index.d.ts +3 -5
- package/src/http/index.d.ts +1 -0
- package/src/interface/index.d.ts +1 -0
- package/src/llm/agent.js +147 -0
- package/src/llm/ai_provider.js +131 -0
- package/src/llm/ai_sdk_options.js +126 -0
- package/src/llm/consts.js +6 -0
- package/src/llm/deprecated_provider_aliases.js +8 -0
- package/src/llm/generate.js +98 -0
- package/src/llm/index.d.ts +697 -0
- package/src/llm/index.js +6 -0
- package/src/llm/judge.js +48 -0
- package/src/llm/prompt/content.js +70 -0
- package/src/llm/prompt/interpolations.js +58 -0
- package/src/llm/prompt/loader.js +67 -0
- package/src/llm/prompt/markup/attributes.js +52 -0
- package/src/llm/prompt/markup/nodes.js +71 -0
- package/src/llm/prompt/markup/tokenizer.js +3 -0
- package/src/llm/prompt/markup/tokens.js +26 -0
- package/src/llm/prompt/validations.js +129 -0
- package/src/llm/utils/cost.js +267 -0
- package/src/llm/utils/error_handler.js +53 -0
- package/src/llm/utils/file.js +42 -0
- package/src/llm/utils/google_vertex_auth.js +31 -0
- package/src/llm/utils/image.js +37 -0
- package/src/llm/utils/legacy_cost_attribute.js +75 -0
- package/src/llm/utils/metering.js +139 -0
- package/src/llm/utils/models.js +15 -0
- package/src/llm/utils/models_pricing.js +96 -0
- package/src/llm/utils/models_pricing_snapshot.json +4711 -0
- package/src/llm/utils/skills.js +74 -0
- package/src/llm/utils/sources.js +73 -0
- package/src/llm/utils/stream.js +75 -0
- package/src/llm/utils/tools.js +62 -0
- package/src/llm/utils/usage.js +155 -0
- package/src/llm/utils/usage_tools.js +23 -0
- package/src/llm/utils/web_search.js +155 -0
- package/src/llm/utils/wrap.js +279 -0
- package/src/llm/validations.js +234 -0
- package/src/worker/bundler_options.js +1 -9
- package/src/worker/interceptors/activity.js +0 -1
- package/src/worker/interceptors/workflow.js +0 -1
- package/src/worker/loader/workflows.js +16 -2
- package/src/worker/webpack_loaders/workflow_rewriter/index.mjs +3 -7
- package/src/worker/webpack_loaders/workflow_rewriter/rewrite_activity_calls.js +27 -7
- package/src/worker/webpack_loaders/workflow_validator/npm_workflow_export_resolve.js +5 -6
- package/src/sdk/README.md +0 -47
- package/src/sdk/helpers/component_metadata.d.ts +0 -17
- package/src/sdk/helpers/component_metadata.js +0 -6
- package/src/sdk/helpers/index.d.ts +0 -12
- package/src/sdk/helpers/index.js +0 -3
- package/src/sdk/helpers/objects.d.ts +0 -56
- package/src/sdk/helpers/objects.js +0 -8
- package/src/sdk/helpers/path.d.ts +0 -11
- package/src/sdk/helpers/path.js +0 -32
- package/src/sdk/runtime/context.d.ts +0 -30
- package/src/sdk/runtime/context.js +0 -15
- package/src/sdk/runtime/events.d.ts +0 -13
- package/src/sdk/runtime/events.js +0 -5
- package/src/sdk/runtime/index.d.ts +0 -12
- package/src/sdk/runtime/index.js +0 -3
- package/src/sdk/runtime/tracing.d.ts +0 -48
- package/src/sdk/runtime/tracing.js +0 -11
|
@@ -103,8 +103,7 @@ const findPackageJson = ( fromDir, packageName ) => {
|
|
|
103
103
|
/**
|
|
104
104
|
* Choose the best concrete file target from a package exports target.
|
|
105
105
|
*
|
|
106
|
-
*
|
|
107
|
-
* `webpackConfigHook`.
|
|
106
|
+
* Uses the same conditions as `webpackConfigHook`.
|
|
108
107
|
*
|
|
109
108
|
* @param {string|Array|object|null|undefined} target - Value from package.json `exports`.
|
|
110
109
|
* @returns {string|null} Relative file target, or null when no supported condition resolves.
|
|
@@ -126,7 +125,7 @@ const resolveConditionalExportTarget = target => {
|
|
|
126
125
|
return null;
|
|
127
126
|
}
|
|
128
127
|
|
|
129
|
-
for ( const condition of [ '
|
|
128
|
+
for ( const condition of [ 'import', 'module', 'webpack', 'default' ] ) {
|
|
130
129
|
if ( condition in target ) {
|
|
131
130
|
const resolved = resolveConditionalExportTarget( target[condition] );
|
|
132
131
|
if ( resolved ) {
|
|
@@ -138,7 +137,7 @@ const resolveConditionalExportTarget = target => {
|
|
|
138
137
|
};
|
|
139
138
|
|
|
140
139
|
/**
|
|
141
|
-
* Resolve a bare package specifier
|
|
140
|
+
* Resolve a bare package specifier from its package.json `exports`.
|
|
142
141
|
*
|
|
143
142
|
* This keeps AST workflow import resolution aligned with webpack's configured condition order before
|
|
144
143
|
* falling back to Node's `require.resolve`.
|
|
@@ -147,7 +146,7 @@ const resolveConditionalExportTarget = target => {
|
|
|
147
146
|
* @param {string} specifier - Bare npm package specifier.
|
|
148
147
|
* @returns {string|null} Absolute module path selected from package exports, or null when unsupported.
|
|
149
148
|
*/
|
|
150
|
-
const
|
|
149
|
+
const resolveBareSpecifierWithExportConditions = ( fromAbsoluteFile, specifier ) => {
|
|
151
150
|
const { packageName, subpath } = packagePartsFromSpecifier( specifier );
|
|
152
151
|
const pkgJsonPath = findPackageJson( dirname( fromAbsoluteFile ), packageName );
|
|
153
152
|
if ( !pkgJsonPath ) {
|
|
@@ -315,7 +314,7 @@ const moduleMayExportWorkflows = ( moduleAbsPath, visited = new Set() ) => {
|
|
|
315
314
|
* @returns {string|null} Absolute path to the resolved entry file, or null on failure.
|
|
316
315
|
*/
|
|
317
316
|
const resolveBareSpecifierToFirstModule = ( fromAbsoluteFile, specifier ) => {
|
|
318
|
-
const conditionalEntry =
|
|
317
|
+
const conditionalEntry = resolveBareSpecifierWithExportConditions( fromAbsoluteFile, specifier );
|
|
319
318
|
if ( conditionalEntry ) {
|
|
320
319
|
return conditionalEntry;
|
|
321
320
|
}
|
package/src/sdk/README.md
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
## SDK integration API for Output packages
|
|
2
|
-
|
|
3
|
-
**THESE MODULES ARE NOT PUBLIC. DO NOT IMPORT THEM ON YOUR PROJECT.**
|
|
4
|
-
|
|
5
|
-
This folder contains integration helpers used by other Output SDK packages.
|
|
6
|
-
|
|
7
|
-
The two subfolders represent a hard Temporal boundary. Code imported by
|
|
8
|
-
workflow-bundled modules must only depend on `helpers`. Code that needs worker
|
|
9
|
-
or activity runtime state belongs in `runtime`.
|
|
10
|
-
|
|
11
|
-
Do not change these without reviewing call-sites.
|
|
12
|
-
|
|
13
|
-
### `helpers`
|
|
14
|
-
|
|
15
|
-
Helpers must be safe to import while Temporal workflows are bundled and executed
|
|
16
|
-
in the workflow sandbox.
|
|
17
|
-
|
|
18
|
-
Allowed:
|
|
19
|
-
|
|
20
|
-
- Stateless functions and namespace objects.
|
|
21
|
-
- Deterministic code with no runtime side effects at import time.
|
|
22
|
-
- Imports from other sandbox-safe helper modules.
|
|
23
|
-
- Small, dependency-free helpers for any deterministic computation that can run
|
|
24
|
-
without worker or activity state.
|
|
25
|
-
|
|
26
|
-
Not allowed:
|
|
27
|
-
|
|
28
|
-
- Access to activity context, async storage, sinks, tracing state, workers, or
|
|
29
|
-
clients.
|
|
30
|
-
- Imports from `@temporalio/activity`, `@temporalio/worker`, or Node-only APIs
|
|
31
|
-
that cannot be bundled into workflow code.
|
|
32
|
-
- Process, filesystem, network, clock, randomness, or environment access unless
|
|
33
|
-
the behavior is known to be safe and deterministic in the workflow sandbox.
|
|
34
|
-
- Any import chain that reaches `runtime`.
|
|
35
|
-
|
|
36
|
-
If a helper cannot satisfy these rules, put it in `runtime` instead.
|
|
37
|
-
|
|
38
|
-
### `runtime`
|
|
39
|
-
|
|
40
|
-
Runtime modules are for helpers that need Output or Temporal runtime state.
|
|
41
|
-
|
|
42
|
-
Use `runtime` for activity-only integrations such as context lookup, event
|
|
43
|
-
emission, tracing, async storage, worker state, sinks, and other behavior that is
|
|
44
|
-
not safe inside workflow-bundled code.
|
|
45
|
-
|
|
46
|
-
Runtime modules may depend on activity runtime APIs and internal state, but they
|
|
47
|
-
must not be imported by workflow-safe code.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tools to extract data from Outputai Core Components metadata storage
|
|
3
|
-
*/
|
|
4
|
-
export declare const ComponentMetadata: {
|
|
5
|
-
/**
|
|
6
|
-
* Extract the name from a workflow(), step() or evaluator() return
|
|
7
|
-
* @param fn
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
getName( fn: Function ): string | undefined;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Check if a function has metadata from workflow(), step() or evaluator()
|
|
14
|
-
* @param fn
|
|
15
|
-
*/
|
|
16
|
-
has( fn: Function ): boolean;
|
|
17
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* > [!WARNING]
|
|
3
|
-
* > **Internal use only.** Not part of the public API; may change without notice.
|
|
4
|
-
*
|
|
5
|
-
* These are stateless helpers for other SDK modules integration.
|
|
6
|
-
* They can be used while Temporal workflows are bundled.
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
*/
|
|
10
|
-
export * from './component_metadata.js';
|
|
11
|
-
export * from './path.js';
|
|
12
|
-
export * from './objects.js';
|
package/src/sdk/helpers/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/** Tools to manipulate JS Objects */
|
|
2
|
-
export declare const Objects: {
|
|
3
|
-
/**
|
|
4
|
-
* Node safe clone implementation that doesn't use global structuredClone().
|
|
5
|
-
*
|
|
6
|
-
* Returns a cloned version of the object.
|
|
7
|
-
*
|
|
8
|
-
* Only clones static properties. Getters become static properties.
|
|
9
|
-
*
|
|
10
|
-
* @param object
|
|
11
|
-
*/
|
|
12
|
-
clone( object: object ): object,
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Returns true if the value is a plain object:
|
|
16
|
-
* - `{}`
|
|
17
|
-
* - `new Object()`
|
|
18
|
-
* - `Object.create(null)`
|
|
19
|
-
*
|
|
20
|
-
* @param object - The value to check.
|
|
21
|
-
* @returns Whether the value is a plain object.
|
|
22
|
-
*/
|
|
23
|
-
isPlainObject( object: unknown ): boolean,
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Creates a new object by recursively merging overlays onto a base object.
|
|
27
|
-
* Later objects overwrite fields from earlier objects.
|
|
28
|
-
*
|
|
29
|
-
* Non-object overlays are ignored.
|
|
30
|
-
*
|
|
31
|
-
* @param base - The base object.
|
|
32
|
-
* @param overlays - The overriding objects, applied from left to right.
|
|
33
|
-
* @throws {Error} If `base` is not a plain object.
|
|
34
|
-
* @returns A new merged object.
|
|
35
|
-
*/
|
|
36
|
-
deepMerge( base: object, ...overlays: Array<object | null | undefined> ): object,
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Creates a new object by recursively merging overlays onto a base object.
|
|
40
|
-
* Existing leaf values are resolved by the resolver function.
|
|
41
|
-
*
|
|
42
|
-
* Non-object overlays are ignored.
|
|
43
|
-
*
|
|
44
|
-
* @param base - The base object.
|
|
45
|
-
* @param args - The overriding objects, applied from left to right, followed by the resolver function.
|
|
46
|
-
* @throws {Error} If `base` is not a plain object.
|
|
47
|
-
* @returns A new merged object.
|
|
48
|
-
*/
|
|
49
|
-
deepMergeWithResolver(
|
|
50
|
-
base: object,
|
|
51
|
-
...args: [
|
|
52
|
-
...overlays: Array<object | null | undefined>,
|
|
53
|
-
resolver: ( a: unknown, b: unknown ) => unknown
|
|
54
|
-
]
|
|
55
|
-
): object
|
|
56
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tools to interact with filesystem paths
|
|
3
|
-
*/
|
|
4
|
-
export declare const Path: {
|
|
5
|
-
/**
|
|
6
|
-
* Return the first immediate directory of the file invoking the code that called this function.
|
|
7
|
-
*
|
|
8
|
-
* Excludes `@outputai/core`, node, other internal paths, and any additional ignore paths.
|
|
9
|
-
*/
|
|
10
|
-
resolveInvocationDir( additionalIgnorePaths?: string[] ): string
|
|
11
|
-
};
|
package/src/sdk/helpers/path.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as stackTraceParser from 'stacktrace-parser';
|
|
2
|
-
|
|
3
|
-
// OS separator, but in a deterministic way, allowing this to work in Temporal's sandbox
|
|
4
|
-
// This avoids importing from node:path
|
|
5
|
-
const SEP = new Error().stack.includes( '/' ) ? '/' : '\\';
|
|
6
|
-
const transformSeparators = path => path.replaceAll( '/', SEP );
|
|
7
|
-
|
|
8
|
-
const defaultIgnorePaths = [
|
|
9
|
-
'/@outputai/core/',
|
|
10
|
-
'/@outputai/llm/',
|
|
11
|
-
'/@outputai/evals/',
|
|
12
|
-
'/sdk/core/',
|
|
13
|
-
'/sdk/llm/',
|
|
14
|
-
'/sdk/evals/',
|
|
15
|
-
'node:internal/',
|
|
16
|
-
'evalmachine.',
|
|
17
|
-
'webpack/bootstrap'
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
export const Path = {
|
|
21
|
-
resolveInvocationDir: ( additionalIgnorePaths = [] ) => {
|
|
22
|
-
const stack = new Error().stack;
|
|
23
|
-
const lines = stackTraceParser.parse( stack );
|
|
24
|
-
const ignorePaths = [ ...additionalIgnorePaths, ...defaultIgnorePaths ].map( transformSeparators );
|
|
25
|
-
|
|
26
|
-
const frame = lines.find( l => !ignorePaths.some( p => l.file.includes( p ) ) );
|
|
27
|
-
if ( !frame ) {
|
|
28
|
-
throw new Error( `Invocation dir resolution via stack trace failed. Stack: ${stack}` );
|
|
29
|
-
}
|
|
30
|
-
return frame.file.replace( 'file://', '' ).split( SEP ).slice( 0, -1 ).join( SEP );
|
|
31
|
-
}
|
|
32
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Info } from '@temporalio/activity';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Context object
|
|
5
|
-
*/
|
|
6
|
-
export type Context = {
|
|
7
|
-
/** Temporal info about the current activity */
|
|
8
|
-
activityInfo: Info,
|
|
9
|
-
/** Path of the workflow file */
|
|
10
|
-
workflowFilename: string
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Tools to interact with Runtime context
|
|
15
|
-
*/
|
|
16
|
-
export declare const Context: {
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Returns information about the current Temporal execution.
|
|
20
|
-
*
|
|
21
|
-
* Only available when called from within a step or evaluator (Temporal Activities) running in the Temporal runtime.
|
|
22
|
-
*
|
|
23
|
-
* @remarks
|
|
24
|
-
* - Returns `null` when not called inside a Temporal Activity (steps/evaluators);
|
|
25
|
-
* - Returns `null` when not called from within a running Temporal worker, like in unit tests environment;
|
|
26
|
-
*
|
|
27
|
-
* @returns The workflow context, or `null` if unavailable or incomplete.
|
|
28
|
-
*/
|
|
29
|
-
getActivityContext(): Context | null;
|
|
30
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Storage } from '#async_storage';
|
|
2
|
-
|
|
3
|
-
export const Context = {
|
|
4
|
-
getActivityContext: () => {
|
|
5
|
-
const ctx = Storage.load();
|
|
6
|
-
if ( !ctx ) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
workflowFilename: ctx.workflowFilename,
|
|
12
|
-
activityInfo: ctx.activityInfo
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tools to interact with Events
|
|
3
|
-
*/
|
|
4
|
-
export declare const Event: {
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Emits an event on step message bus.
|
|
8
|
-
*
|
|
9
|
-
* @param eventName - The name of the event to emit
|
|
10
|
-
* @param payload - An optional payload to send to the event.
|
|
11
|
-
*/
|
|
12
|
-
emit( eventName: string, payload?: object ): boolean;
|
|
13
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* > [!WARNING]
|
|
3
|
-
* > **Internal use only.** Not part of the public API; may change without notice.
|
|
4
|
-
*
|
|
5
|
-
* These are helpers for other SDK modules integration.
|
|
6
|
-
* These need Temporal activity runtime to work, as they access state, emit events and use node:* modules.
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
*/
|
|
10
|
-
export * from './context.js';
|
|
11
|
-
export * from './events.js';
|
|
12
|
-
export * from './tracing.js';
|
package/src/sdk/runtime/index.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Attribute } from '#trace_attribute';
|
|
2
|
-
|
|
3
|
-
export type BaseAttribute = InstanceType<typeof Attribute.BaseAttribute>;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Tools to interact with Tracing
|
|
7
|
-
*/
|
|
8
|
-
export declare const Tracing: {
|
|
9
|
-
Attribute: typeof Attribute;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Creates a new event.
|
|
13
|
-
*
|
|
14
|
-
* @param args
|
|
15
|
-
* @param args.id - A unique id for the Event.
|
|
16
|
-
* @param args.kind - The kind of Event, like HTTP, DiskWrite, DBOp, etc.
|
|
17
|
-
* @param args.name - The human-friendly name of the Event: query, request, create.
|
|
18
|
-
* @param args.details - Arbitrary data to add to this event, it will be used as the "input" field.
|
|
19
|
-
*/
|
|
20
|
-
addEventStart( args: { id: string; kind: string; name: string; details: unknown } ): void;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Concludes an event.
|
|
24
|
-
*
|
|
25
|
-
* @param args
|
|
26
|
-
* @param args.id - The id of the event to conclude.
|
|
27
|
-
* @param args.details - Arbitrary data to add to this event, it will be used as the "output" field.
|
|
28
|
-
*/
|
|
29
|
-
addEventEnd( args: { id: string; details: unknown } ): void;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Concludes an event with an error.
|
|
33
|
-
*
|
|
34
|
-
* @param args
|
|
35
|
-
* @param args.id - The id of the event to conclude.
|
|
36
|
-
* @param args.details - Arbitrary data to add to this event, it will be used as the "error" field.
|
|
37
|
-
*/
|
|
38
|
-
addEventError( args: { id: string; details: unknown } ): void;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Adds an attribute to an event.
|
|
42
|
-
*
|
|
43
|
-
* @param args
|
|
44
|
-
* @param args.eventId - The id of the event to attach the attribute to.
|
|
45
|
-
* @param args.attribute - The attribute to attach to the event.
|
|
46
|
-
*/
|
|
47
|
-
addEventAttribute( args: { eventId: string; attribute: Attribute.Instance } ): void;
|
|
48
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { addEventActionWithContext as send, EventAction } from '#tracing';
|
|
2
|
-
|
|
3
|
-
import { Attribute } from '#trace_attribute';
|
|
4
|
-
|
|
5
|
-
export const Tracing = {
|
|
6
|
-
Attribute,
|
|
7
|
-
addEventStart: ( { id, kind, name, details } ) => send( EventAction.START, { kind, name, details, id } ),
|
|
8
|
-
addEventEnd: ( { id, details } ) => send( EventAction.END, { id, details } ),
|
|
9
|
-
addEventError: ( { id, details } ) => send( EventAction.ERROR, { id, details } ),
|
|
10
|
-
addEventAttribute: ( { eventId, attribute } ) => send( EventAction.ADD_ATTR, { id: eventId, details: attribute } )
|
|
11
|
-
};
|