@aigne/core 1.0.10 → 1.0.11
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/lib/cjs/agent.d.ts +63 -19
- package/lib/cjs/agent.js +57 -16
- package/lib/cjs/context.d.ts +1 -1
- package/lib/cjs/definitions/data-schema.d.ts +61 -0
- package/lib/cjs/definitions/memory.d.ts +18 -5
- package/lib/cjs/definitions/open-api.d.ts +3 -3
- package/lib/cjs/definitions/preload.d.ts +43 -0
- package/lib/cjs/definitions/preload.js +34 -0
- package/lib/cjs/function-agent.d.ts +15 -56
- package/lib/cjs/function-agent.js +9 -6
- package/lib/cjs/index.d.ts +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/llm-agent.d.ts +17 -60
- package/lib/cjs/llm-agent.js +8 -5
- package/lib/cjs/llm-decision-agent.d.ts +28 -31
- package/lib/cjs/llm-decision-agent.js +2 -2
- package/lib/cjs/llm-model.d.ts +4 -4
- package/lib/cjs/memorable.d.ts +21 -13
- package/lib/cjs/memorable.js +2 -2
- package/lib/cjs/open-api-agent.d.ts +9 -38
- package/lib/cjs/open-api-agent.js +12 -6
- package/lib/cjs/pipeline-agent.d.ts +14 -37
- package/lib/cjs/pipeline-agent.js +10 -10
- package/lib/cjs/runnable.d.ts +7 -24
- package/lib/cjs/sandbox-function-agent.d.ts +10 -38
- package/lib/cjs/sandbox-function-agent.js +9 -5
- package/lib/cjs/sandbox-function-runner.d.ts +8 -17
- package/lib/cjs/sandbox-function-runner.js +1 -0
- package/lib/cjs/utils/index.d.ts +1 -0
- package/lib/cjs/utils/index.js +1 -0
- package/lib/cjs/utils/logger.d.ts +3 -0
- package/lib/cjs/utils/logger.js +17 -0
- package/lib/cjs/utils/message-utils.d.ts +1 -1
- package/lib/cjs/utils/message-utils.js +1 -4
- package/lib/cjs/utils/open-api-parameter.js +3 -6
- package/lib/cjs/utils/runnable-type.d.ts +4 -22
- package/lib/cjs/utils/structured-output-schema.d.ts +2 -2
- package/lib/cjs/utils/type-utils.d.ts +1 -0
- package/lib/cjs/{logger.js → utils/type-utils.js} +0 -2
- package/lib/dts/agent.d.ts +63 -19
- package/lib/dts/context.d.ts +1 -1
- package/lib/dts/definitions/data-schema.d.ts +61 -0
- package/lib/dts/definitions/memory.d.ts +18 -5
- package/lib/dts/definitions/open-api.d.ts +3 -3
- package/lib/dts/definitions/preload.d.ts +43 -0
- package/lib/dts/function-agent.d.ts +15 -56
- package/lib/dts/index.d.ts +1 -1
- package/lib/dts/llm-agent.d.ts +17 -60
- package/lib/dts/llm-decision-agent.d.ts +28 -31
- package/lib/dts/llm-model.d.ts +4 -4
- package/lib/dts/memorable.d.ts +21 -13
- package/lib/dts/open-api-agent.d.ts +9 -38
- package/lib/dts/pipeline-agent.d.ts +14 -37
- package/lib/dts/runnable.d.ts +7 -24
- package/lib/dts/sandbox-function-agent.d.ts +10 -38
- package/lib/dts/sandbox-function-runner.d.ts +8 -17
- package/lib/dts/utils/index.d.ts +1 -0
- package/lib/dts/utils/logger.d.ts +3 -0
- package/lib/dts/utils/message-utils.d.ts +1 -1
- package/lib/dts/utils/runnable-type.d.ts +4 -22
- package/lib/dts/utils/structured-output-schema.d.ts +2 -2
- package/lib/dts/utils/type-utils.d.ts +1 -0
- package/lib/esm/agent.d.ts +63 -19
- package/lib/esm/agent.js +53 -9
- package/lib/esm/context.d.ts +1 -1
- package/lib/esm/definitions/data-schema.d.ts +61 -0
- package/lib/esm/definitions/memory.d.ts +18 -5
- package/lib/esm/definitions/open-api.d.ts +3 -3
- package/lib/esm/definitions/preload.d.ts +43 -0
- package/lib/esm/definitions/preload.js +31 -0
- package/lib/esm/function-agent.d.ts +15 -56
- package/lib/esm/function-agent.js +9 -6
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/llm-agent.d.ts +17 -60
- package/lib/esm/llm-agent.js +8 -5
- package/lib/esm/llm-decision-agent.d.ts +28 -31
- package/lib/esm/llm-decision-agent.js +4 -4
- package/lib/esm/llm-model.d.ts +4 -4
- package/lib/esm/memorable.d.ts +21 -13
- package/lib/esm/memorable.js +2 -2
- package/lib/esm/open-api-agent.d.ts +9 -38
- package/lib/esm/open-api-agent.js +11 -5
- package/lib/esm/pipeline-agent.d.ts +14 -37
- package/lib/esm/pipeline-agent.js +9 -6
- package/lib/esm/runnable.d.ts +7 -24
- package/lib/esm/sandbox-function-agent.d.ts +10 -38
- package/lib/esm/sandbox-function-agent.js +9 -5
- package/lib/esm/sandbox-function-runner.d.ts +8 -17
- package/lib/esm/sandbox-function-runner.js +2 -1
- package/lib/esm/utils/index.d.ts +1 -0
- package/lib/esm/utils/index.js +1 -0
- package/lib/esm/utils/logger.d.ts +3 -0
- package/lib/esm/utils/logger.js +14 -0
- package/lib/esm/utils/message-utils.d.ts +1 -1
- package/lib/esm/utils/message-utils.js +1 -4
- package/lib/esm/utils/open-api-parameter.js +1 -1
- package/lib/esm/utils/runnable-type.d.ts +4 -22
- package/lib/esm/utils/structured-output-schema.d.ts +2 -2
- package/lib/esm/utils/type-utils.d.ts +1 -0
- package/lib/esm/utils/type-utils.js +1 -0
- package/package.json +1 -1
- package/lib/cjs/definitions/data-type-schema.d.ts +0 -42
- package/lib/cjs/logger.d.ts +0 -2
- package/lib/dts/definitions/data-type-schema.d.ts +0 -42
- package/lib/dts/logger.d.ts +0 -2
- package/lib/esm/definitions/data-type-schema.d.ts +0 -42
- package/lib/esm/logger.d.ts +0 -2
- package/lib/esm/logger.js +0 -2
- /package/lib/cjs/definitions/{data-type-schema.js → data-schema.js} +0 -0
- /package/lib/esm/definitions/{data-type-schema.js → data-schema.js} +0 -0
package/lib/esm/runnable.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import type { Context, ContextState } from "./context";
|
|
2
2
|
import type { DataType } from "./definitions/data-type";
|
|
3
|
-
import type { Memorable } from "./memorable";
|
|
4
3
|
import { OrderedRecord } from "./utils/ordered-map";
|
|
5
4
|
export interface RunOptions {
|
|
6
5
|
stream?: boolean;
|
|
7
6
|
}
|
|
8
7
|
export type RunnableResponse<T> = T | RunnableResponseStream<T>;
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
[name: string]: any;
|
|
13
|
-
} = {}, State extends ContextState = ContextState> {
|
|
8
|
+
export type RunnableInput = Record<string, any>;
|
|
9
|
+
export type RunnableOutput = Record<string, any>;
|
|
10
|
+
export declare abstract class Runnable<I extends RunnableInput = RunnableInput, O extends RunnableOutput = RunnableOutput, State extends ContextState = ContextState> {
|
|
14
11
|
definition: RunnableDefinition;
|
|
15
12
|
context?: Context<State> | undefined;
|
|
16
13
|
constructor(definition: RunnableDefinition, context?: Context<State> | undefined);
|
|
@@ -35,25 +32,11 @@ export interface RunnableDefinition {
|
|
|
35
32
|
type: string;
|
|
36
33
|
name?: string;
|
|
37
34
|
description?: string;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
outputs: OrderedRecord<RunnableOutput>;
|
|
35
|
+
inputs: OrderedRecord<RunnableInputType>;
|
|
36
|
+
outputs: OrderedRecord<RunnableOutputType>;
|
|
41
37
|
}
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
name?: string;
|
|
45
|
-
memory?: Memorable<any>;
|
|
46
|
-
query?: {
|
|
47
|
-
from: "variable";
|
|
48
|
-
fromVariableId?: string;
|
|
49
|
-
fromVariablePropPath?: string[];
|
|
50
|
-
};
|
|
51
|
-
options?: {
|
|
52
|
-
k?: number;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
export type RunnableInput = DataType;
|
|
56
|
-
export type RunnableOutput = DataType;
|
|
38
|
+
export type RunnableInputType = DataType;
|
|
39
|
+
export type RunnableOutputType = DataType;
|
|
57
40
|
export interface RunnableResponseDelta<T> {
|
|
58
41
|
$text?: string;
|
|
59
42
|
delta?: Partial<T>;
|
|
@@ -1,48 +1,20 @@
|
|
|
1
|
-
import { Agent, type AgentProcessOptions } from "./agent";
|
|
1
|
+
import { Agent, type AgentDefinition, type AgentMemories, type AgentPreloads, type AgentProcessInput, type AgentProcessOptions, type CreateAgentInputSchema, type CreateAgentMemoriesSchema, type CreateAgentMemoriesType, type CreateAgentOptions, type CreateAgentOutputSchema, type CreateAgentPreloadsSchema, type CreateAgentPreloadsType } from "./agent";
|
|
2
2
|
import type { Context, ContextState } from "./context";
|
|
3
|
-
import { type
|
|
4
|
-
import {
|
|
5
|
-
import type { MemorableSearchOutput, MemoryItemWithScore } from "./memorable";
|
|
6
|
-
import type { RunnableDefinition } from "./runnable";
|
|
3
|
+
import { type SchemaToType } from "./definitions/data-schema";
|
|
4
|
+
import type { RunnableInput, RunnableOutput } from "./runnable";
|
|
7
5
|
import type { SandboxFunctionRunner } from "./sandbox-function-runner";
|
|
8
|
-
export declare class SandboxFunctionAgent<I extends {
|
|
9
|
-
[name: string]: any;
|
|
10
|
-
} = {}, O extends {
|
|
11
|
-
[name: string]: any;
|
|
12
|
-
} = {}, Memories extends {
|
|
13
|
-
[name: string]: MemoryItemWithScore[];
|
|
14
|
-
} = {}, State extends ContextState = ContextState> extends Agent<I, O, Memories, State> {
|
|
6
|
+
export declare class SandboxFunctionAgent<I extends RunnableInput = RunnableInput, O extends RunnableOutput = RunnableOutput, State extends ContextState = ContextState, Preloads extends AgentPreloads = AgentPreloads, Memories extends AgentMemories = AgentMemories> extends Agent<I, O, State, Preloads, Memories> {
|
|
15
7
|
definition: SandboxFunctionAgentDefinition;
|
|
16
|
-
runner?: SandboxFunctionRunner<I, O,
|
|
8
|
+
runner?: SandboxFunctionRunner<I, O, State, Preloads, Memories> | undefined;
|
|
17
9
|
static create: typeof create;
|
|
18
|
-
constructor(definition: SandboxFunctionAgentDefinition, context?: Context<State>, runner?: SandboxFunctionRunner<I, O,
|
|
19
|
-
process(input: I, options: AgentProcessOptions<Memories>): Promise<import("./runnable").RunnableResponseStream<O>>;
|
|
10
|
+
constructor(definition: SandboxFunctionAgentDefinition, context?: Context<State>, runner?: SandboxFunctionRunner<I, O, State, Preloads, Memories> | undefined);
|
|
11
|
+
process(input: AgentProcessInput<I, Preloads, Memories>, options: AgentProcessOptions<Preloads, Memories>): Promise<import("./runnable").RunnableResponseStream<O>>;
|
|
20
12
|
}
|
|
21
|
-
export
|
|
22
|
-
[name: string]: DataTypeSchema;
|
|
23
|
-
}, O extends {
|
|
24
|
-
[name: string]: DataTypeSchema;
|
|
25
|
-
}, Memories extends {
|
|
26
|
-
[name: string]: CreateRunnableMemory<I>;
|
|
27
|
-
}, State extends ContextState> {
|
|
28
|
-
context?: Context<State>;
|
|
29
|
-
name?: string;
|
|
30
|
-
inputs: I;
|
|
31
|
-
outputs: O;
|
|
32
|
-
memories?: Memories;
|
|
13
|
+
export declare function create<I extends CreateAgentInputSchema, O extends CreateAgentOutputSchema, State extends ContextState, Preloads extends CreateAgentPreloadsSchema<I>, Memories extends CreateAgentMemoriesSchema<I>>(options: CreateAgentOptions<I, O, State, Preloads, Memories> & {
|
|
33
14
|
language?: string;
|
|
34
15
|
code: string;
|
|
35
|
-
}
|
|
36
|
-
export
|
|
37
|
-
[name: string]: DataTypeSchema;
|
|
38
|
-
}, O extends {
|
|
39
|
-
[name: string]: DataTypeSchema;
|
|
40
|
-
}, Memories extends {
|
|
41
|
-
[name: string]: CreateRunnableMemory<I>;
|
|
42
|
-
}, State extends ContextState>({ context, ...options }: CreateSandboxFunctionAgentOptions<I, O, Memories, State>): SandboxFunctionAgent<SchemaMapType<I>, SchemaMapType<O>, {
|
|
43
|
-
[name in keyof Memories]: MemorableSearchOutput<Memories[name]["memory"]>;
|
|
44
|
-
}, State>;
|
|
45
|
-
export interface SandboxFunctionAgentDefinition extends RunnableDefinition {
|
|
16
|
+
}): SandboxFunctionAgent<SchemaToType<I>, SchemaToType<O>, State, CreateAgentPreloadsType<I, Preloads>, CreateAgentMemoriesType<I, Memories>>;
|
|
17
|
+
export interface SandboxFunctionAgentDefinition extends AgentDefinition {
|
|
46
18
|
type: "sandbox_function_agent";
|
|
47
19
|
language?: string;
|
|
48
20
|
code?: string;
|
|
@@ -12,10 +12,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
};
|
|
13
13
|
import { nanoid } from "nanoid";
|
|
14
14
|
import { inject, injectable } from "tsyringe";
|
|
15
|
-
import { Agent } from "./agent";
|
|
15
|
+
import { Agent, } from "./agent";
|
|
16
16
|
import { TYPES } from "./constants";
|
|
17
|
-
import { schemaToDataType
|
|
18
|
-
import { toRunnableMemories
|
|
17
|
+
import { schemaToDataType } from "./definitions/data-schema";
|
|
18
|
+
import { toRunnableMemories } from "./definitions/memory";
|
|
19
|
+
import { preloadCreatorsToPreloads } from "./definitions/preload";
|
|
19
20
|
let SandboxFunctionAgent = class SandboxFunctionAgent extends Agent {
|
|
20
21
|
definition;
|
|
21
22
|
runner;
|
|
@@ -39,6 +40,7 @@ let SandboxFunctionAgent = class SandboxFunctionAgent extends Agent {
|
|
|
39
40
|
language,
|
|
40
41
|
code,
|
|
41
42
|
input,
|
|
43
|
+
preloads: options.preloads,
|
|
42
44
|
memories: options.memories,
|
|
43
45
|
context: { state: context.state },
|
|
44
46
|
}, { stream: true });
|
|
@@ -52,10 +54,11 @@ SandboxFunctionAgent = __decorate([
|
|
|
52
54
|
__metadata("design:paramtypes", [Object, Object, Function])
|
|
53
55
|
], SandboxFunctionAgent);
|
|
54
56
|
export { SandboxFunctionAgent };
|
|
55
|
-
export function create(
|
|
57
|
+
export function create(options) {
|
|
56
58
|
const agentId = options.name || nanoid();
|
|
57
59
|
const inputs = schemaToDataType(options.inputs);
|
|
58
60
|
const outputs = schemaToDataType(options.outputs);
|
|
61
|
+
const preloads = preloadCreatorsToPreloads(inputs, options.preloads);
|
|
59
62
|
const memories = toRunnableMemories(agentId, inputs, options.memories ?? {});
|
|
60
63
|
return new SandboxFunctionAgent({
|
|
61
64
|
id: agentId,
|
|
@@ -63,8 +66,9 @@ export function create({ context, ...options }) {
|
|
|
63
66
|
type: "sandbox_function_agent",
|
|
64
67
|
inputs,
|
|
65
68
|
outputs,
|
|
69
|
+
preloads,
|
|
66
70
|
memories,
|
|
67
71
|
language: options.language,
|
|
68
72
|
code: options.code,
|
|
69
|
-
}, context);
|
|
73
|
+
}, options.context);
|
|
70
74
|
}
|
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
import { Agent } from "./agent";
|
|
1
|
+
import { Agent, type AgentMemories, type AgentPreloads } from "./agent";
|
|
2
2
|
import type { Context, ContextState } from "./context";
|
|
3
|
-
import type {
|
|
4
|
-
export
|
|
5
|
-
[name: string]: any;
|
|
6
|
-
} = {}, Memories extends {
|
|
7
|
-
[name: string]: MemoryItemWithScore[];
|
|
8
|
-
} = {}, State extends ContextState = ContextState> {
|
|
3
|
+
import type { RunnableInput, RunnableOutput } from "./runnable";
|
|
4
|
+
export type SandboxFunctionRunnerInput<Input extends RunnableInput = RunnableInput, State extends ContextState = ContextState, Preloads extends AgentPreloads = AgentPreloads, Memories extends AgentMemories = AgentMemories> = {
|
|
9
5
|
name: string;
|
|
10
6
|
language?: string;
|
|
11
7
|
code: string;
|
|
12
|
-
input:
|
|
8
|
+
input: Input;
|
|
9
|
+
preloads: Preloads;
|
|
13
10
|
memories: Memories;
|
|
14
11
|
context: Pick<Context<State>, "state">;
|
|
15
|
-
}
|
|
16
|
-
export type SandboxFunctionRunnerOutput<
|
|
17
|
-
export declare abstract class SandboxFunctionRunner<I extends {
|
|
18
|
-
[name: string]: any;
|
|
19
|
-
} = {}, O extends {
|
|
20
|
-
[name: string]: any;
|
|
21
|
-
} = {}, Memories extends {
|
|
22
|
-
[name: string]: MemoryItemWithScore[];
|
|
23
|
-
} = {}, State extends ContextState = ContextState> extends Agent<SandboxFunctionRunnerInput<I, Memories, State>, SandboxFunctionRunnerOutput<O>> {
|
|
12
|
+
};
|
|
13
|
+
export type SandboxFunctionRunnerOutput<Output extends RunnableOutput> = Output;
|
|
14
|
+
export declare abstract class SandboxFunctionRunner<I extends RunnableInput = RunnableInput, O extends RunnableOutput = RunnableOutput, State extends ContextState = ContextState, Preloads extends AgentPreloads = AgentPreloads, Memories extends AgentMemories = AgentMemories> extends Agent<SandboxFunctionRunnerInput<I, State, Preloads, Memories>, SandboxFunctionRunnerOutput<O>> {
|
|
24
15
|
constructor(context?: Context);
|
|
25
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Agent } from "./agent";
|
|
1
|
+
import { Agent, } from "./agent";
|
|
2
2
|
import { OrderedRecord } from "./utils";
|
|
3
3
|
export class SandboxFunctionRunner extends Agent {
|
|
4
4
|
constructor(context) {
|
|
@@ -12,6 +12,7 @@ export class SandboxFunctionRunner extends Agent {
|
|
|
12
12
|
{ id: "language", name: "language", type: "string" },
|
|
13
13
|
{ id: "code", name: "code", type: "string", required: true },
|
|
14
14
|
{ id: "input", name: "input", type: "object", required: true },
|
|
15
|
+
{ id: "preloads", name: "preloads", type: "object", required: true },
|
|
15
16
|
{ id: "memories", name: "memories", type: "object", required: true },
|
|
16
17
|
{ id: "context", name: "context", type: "object", required: true },
|
|
17
18
|
]),
|
package/lib/esm/utils/index.d.ts
CHANGED
package/lib/esm/utils/index.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function logLevel() {
|
|
2
|
+
return process.env.LOG_LEVEL || "info";
|
|
3
|
+
}
|
|
4
|
+
function createLogger(logger, level = logLevel()) {
|
|
5
|
+
return {
|
|
6
|
+
debug: level === "debug" ? logger.debug : () => { },
|
|
7
|
+
info: level === "debug" || level === "info" ? logger.info : () => { },
|
|
8
|
+
warn: level === "debug" || level === "info" || level === "warn"
|
|
9
|
+
? logger.warn
|
|
10
|
+
: () => { },
|
|
11
|
+
error: logger.error,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export const logger = createLogger(console);
|
|
@@ -11,7 +11,7 @@ export declare function memoriesToMessages(memories: {
|
|
|
11
11
|
memory: string;
|
|
12
12
|
};
|
|
13
13
|
export declare function prepareMessages(definition: Pick<LLMAgentDefinition, "messages" | "memories" | "primaryMemoryId">, input: {
|
|
14
|
-
[name: string]:
|
|
14
|
+
[name: string]: unknown;
|
|
15
15
|
}, memories: {
|
|
16
16
|
[name: string]: MemoryItemWithScore[];
|
|
17
17
|
}): {
|
|
@@ -41,12 +41,9 @@ export function memoriesToMessages(memories, { primaryMemoryName } = {}) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
export function prepareMessages(definition, input, memories) {
|
|
44
|
-
const variables = { ...input, ...memories };
|
|
45
44
|
const originalMessages = OrderedRecord.toArray(definition.messages).map(({ role, content }) => ({
|
|
46
45
|
role,
|
|
47
|
-
content: typeof content === "string"
|
|
48
|
-
? renderMessage(content, variables)
|
|
49
|
-
: content,
|
|
46
|
+
content: typeof content === "string" ? renderMessage(content, input) : content,
|
|
50
47
|
}));
|
|
51
48
|
if (!originalMessages.length)
|
|
52
49
|
throw new Error("Messages are required");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isEmpty, omitBy } from "lodash";
|
|
2
|
-
import logger from "
|
|
2
|
+
import { logger } from "./logger";
|
|
3
3
|
import { OrderedRecord } from "./ordered-map";
|
|
4
4
|
export async function formatOpenAPIRequest(api, inputs, input) {
|
|
5
5
|
const { url, method, ...inputParams } = processParameters(api, inputs, input);
|
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
import type { Runnable, RunnableResponseStream } from "../runnable";
|
|
1
|
+
import type { Runnable, RunnableInput, RunnableOutput, RunnableResponseStream } from "../runnable";
|
|
2
2
|
import type { UnionToIntersection } from "./union";
|
|
3
|
-
export type ExtractRunnableInputType<T> = T extends Runnable<infer I,
|
|
4
|
-
export type ExtractRunnableOutputType<T> = T extends Runnable<
|
|
5
|
-
export type ExtractRunnableInputTypeIntersection<T> = UnionToIntersection<ExtractRunnableInputType<T>,
|
|
6
|
-
export type ExtractRunnableOutputTypeIntersection<T> = UnionToIntersection<ExtractRunnableOutputType<T>, {}>;
|
|
7
|
-
export type BindAgentInput = {
|
|
8
|
-
from: "ai";
|
|
9
|
-
};
|
|
10
|
-
export type PickInputFrom<I, From extends BindAgentInput["from"]> = {
|
|
11
|
-
[key in keyof I as I[key] extends {
|
|
12
|
-
from: From;
|
|
13
|
-
} ? key : never]: I[key];
|
|
14
|
-
};
|
|
15
|
-
export type OmitBoundAgentInput<Case extends BoundAgent, From extends BindAgentInput["from"]> = Omit<UnionToIntersection<ExtractRunnableInputType<Case["runnable"]>, {}>, keyof PickInputFrom<Required<UnionToIntersection<NonNullable<Case["input"]>, {}>>, From>>;
|
|
16
|
-
export type BindAgentInputs<R extends Runnable> = {
|
|
17
|
-
[key in keyof ExtractRunnableInputType<R>]?: BindAgentInput;
|
|
18
|
-
};
|
|
19
|
-
export interface BoundAgent<R extends Runnable = Runnable, I extends BindAgentInputs<R> = BindAgentInputs<R>> {
|
|
20
|
-
description?: string;
|
|
21
|
-
runnable: R;
|
|
22
|
-
input?: I;
|
|
23
|
-
}
|
|
3
|
+
export type ExtractRunnableInputType<T> = T extends Runnable<infer I, RunnableOutput> ? I : never;
|
|
4
|
+
export type ExtractRunnableOutputType<T> = T extends Runnable<RunnableInput, infer O> ? Exclude<O, RunnableResponseStream<unknown>> : never;
|
|
5
|
+
export type ExtractRunnableInputTypeIntersection<T> = UnionToIntersection<ExtractRunnableInputType<T>, Record<string, unknown>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RunnableOutputType } from "../runnable";
|
|
2
2
|
import { OrderedRecord } from "./ordered-map";
|
|
3
|
-
export declare function outputsToJsonSchema(outputs: OrderedRecord<
|
|
3
|
+
export declare function outputsToJsonSchema(outputs: OrderedRecord<RunnableOutputType>): object;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ArrayElement<T> = T extends (infer U)[] ? U : never;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { MakeNullablePropertyOptional } from "../utils/nullable";
|
|
2
|
-
import { OrderedRecord } from "../utils/ordered-map";
|
|
3
|
-
import type { DataType } from "./data-type";
|
|
4
|
-
export declare function schemaToDataType(dataType: {
|
|
5
|
-
[name: string]: DataTypeSchema;
|
|
6
|
-
}): OrderedRecord<DataType>;
|
|
7
|
-
export type DataTypeSchema = DataTypeSchemaString | DataTypeSchemaNumber | DataTypeSchemaBoolean | DataTypeSchemaObject | DataTypeSchemaArray;
|
|
8
|
-
export interface DataTypeSchemaBase {
|
|
9
|
-
description?: string;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface DataTypeSchemaString extends DataTypeSchemaBase {
|
|
13
|
-
type: "string";
|
|
14
|
-
}
|
|
15
|
-
export interface DataTypeSchemaNumber extends DataTypeSchemaBase {
|
|
16
|
-
type: "number";
|
|
17
|
-
}
|
|
18
|
-
export interface DataTypeSchemaBoolean extends DataTypeSchemaBase {
|
|
19
|
-
type: "boolean";
|
|
20
|
-
}
|
|
21
|
-
export interface DataTypeSchemaObject extends DataTypeSchemaBase {
|
|
22
|
-
type: "object";
|
|
23
|
-
properties?: {
|
|
24
|
-
[key: string]: DataTypeSchema;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export interface DataTypeSchemaArray extends DataTypeSchemaBase {
|
|
28
|
-
type: "array";
|
|
29
|
-
items?: DataTypeSchema;
|
|
30
|
-
}
|
|
31
|
-
type SchemaTypeInner<T extends DataTypeSchema> = T extends DataTypeSchemaString ? string : T extends DataTypeSchemaNumber ? number : T extends DataTypeSchemaBoolean ? boolean : T extends DataTypeSchemaObject ? MakeNullablePropertyOptional<{
|
|
32
|
-
[K in keyof T["properties"]]: SchemaType<NonNullable<T["properties"]>[K]>;
|
|
33
|
-
}> : T extends DataTypeSchemaArray ? T["items"] extends null | undefined ? SchemaType<{
|
|
34
|
-
type: "object";
|
|
35
|
-
}>[] : SchemaType<NonNullable<T["items"]>>[] : never;
|
|
36
|
-
export type SchemaType<T extends DataTypeSchema> = T["required"] extends true ? SchemaTypeInner<T> : SchemaTypeInner<T> | undefined | null;
|
|
37
|
-
export type SchemaMapType<T extends Record<string, DataTypeSchema>> = SchemaType<{
|
|
38
|
-
type: "object";
|
|
39
|
-
required: true;
|
|
40
|
-
properties: T;
|
|
41
|
-
}>;
|
|
42
|
-
export {};
|
package/lib/cjs/logger.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { MakeNullablePropertyOptional } from "../utils/nullable";
|
|
2
|
-
import { OrderedRecord } from "../utils/ordered-map";
|
|
3
|
-
import type { DataType } from "./data-type";
|
|
4
|
-
export declare function schemaToDataType(dataType: {
|
|
5
|
-
[name: string]: DataTypeSchema;
|
|
6
|
-
}): OrderedRecord<DataType>;
|
|
7
|
-
export type DataTypeSchema = DataTypeSchemaString | DataTypeSchemaNumber | DataTypeSchemaBoolean | DataTypeSchemaObject | DataTypeSchemaArray;
|
|
8
|
-
export interface DataTypeSchemaBase {
|
|
9
|
-
description?: string;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface DataTypeSchemaString extends DataTypeSchemaBase {
|
|
13
|
-
type: "string";
|
|
14
|
-
}
|
|
15
|
-
export interface DataTypeSchemaNumber extends DataTypeSchemaBase {
|
|
16
|
-
type: "number";
|
|
17
|
-
}
|
|
18
|
-
export interface DataTypeSchemaBoolean extends DataTypeSchemaBase {
|
|
19
|
-
type: "boolean";
|
|
20
|
-
}
|
|
21
|
-
export interface DataTypeSchemaObject extends DataTypeSchemaBase {
|
|
22
|
-
type: "object";
|
|
23
|
-
properties?: {
|
|
24
|
-
[key: string]: DataTypeSchema;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export interface DataTypeSchemaArray extends DataTypeSchemaBase {
|
|
28
|
-
type: "array";
|
|
29
|
-
items?: DataTypeSchema;
|
|
30
|
-
}
|
|
31
|
-
type SchemaTypeInner<T extends DataTypeSchema> = T extends DataTypeSchemaString ? string : T extends DataTypeSchemaNumber ? number : T extends DataTypeSchemaBoolean ? boolean : T extends DataTypeSchemaObject ? MakeNullablePropertyOptional<{
|
|
32
|
-
[K in keyof T["properties"]]: SchemaType<NonNullable<T["properties"]>[K]>;
|
|
33
|
-
}> : T extends DataTypeSchemaArray ? T["items"] extends null | undefined ? SchemaType<{
|
|
34
|
-
type: "object";
|
|
35
|
-
}>[] : SchemaType<NonNullable<T["items"]>>[] : never;
|
|
36
|
-
export type SchemaType<T extends DataTypeSchema> = T["required"] extends true ? SchemaTypeInner<T> : SchemaTypeInner<T> | undefined | null;
|
|
37
|
-
export type SchemaMapType<T extends Record<string, DataTypeSchema>> = SchemaType<{
|
|
38
|
-
type: "object";
|
|
39
|
-
required: true;
|
|
40
|
-
properties: T;
|
|
41
|
-
}>;
|
|
42
|
-
export {};
|
package/lib/dts/logger.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { MakeNullablePropertyOptional } from "../utils/nullable";
|
|
2
|
-
import { OrderedRecord } from "../utils/ordered-map";
|
|
3
|
-
import type { DataType } from "./data-type";
|
|
4
|
-
export declare function schemaToDataType(dataType: {
|
|
5
|
-
[name: string]: DataTypeSchema;
|
|
6
|
-
}): OrderedRecord<DataType>;
|
|
7
|
-
export type DataTypeSchema = DataTypeSchemaString | DataTypeSchemaNumber | DataTypeSchemaBoolean | DataTypeSchemaObject | DataTypeSchemaArray;
|
|
8
|
-
export interface DataTypeSchemaBase {
|
|
9
|
-
description?: string;
|
|
10
|
-
required?: boolean;
|
|
11
|
-
}
|
|
12
|
-
export interface DataTypeSchemaString extends DataTypeSchemaBase {
|
|
13
|
-
type: "string";
|
|
14
|
-
}
|
|
15
|
-
export interface DataTypeSchemaNumber extends DataTypeSchemaBase {
|
|
16
|
-
type: "number";
|
|
17
|
-
}
|
|
18
|
-
export interface DataTypeSchemaBoolean extends DataTypeSchemaBase {
|
|
19
|
-
type: "boolean";
|
|
20
|
-
}
|
|
21
|
-
export interface DataTypeSchemaObject extends DataTypeSchemaBase {
|
|
22
|
-
type: "object";
|
|
23
|
-
properties?: {
|
|
24
|
-
[key: string]: DataTypeSchema;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export interface DataTypeSchemaArray extends DataTypeSchemaBase {
|
|
28
|
-
type: "array";
|
|
29
|
-
items?: DataTypeSchema;
|
|
30
|
-
}
|
|
31
|
-
type SchemaTypeInner<T extends DataTypeSchema> = T extends DataTypeSchemaString ? string : T extends DataTypeSchemaNumber ? number : T extends DataTypeSchemaBoolean ? boolean : T extends DataTypeSchemaObject ? MakeNullablePropertyOptional<{
|
|
32
|
-
[K in keyof T["properties"]]: SchemaType<NonNullable<T["properties"]>[K]>;
|
|
33
|
-
}> : T extends DataTypeSchemaArray ? T["items"] extends null | undefined ? SchemaType<{
|
|
34
|
-
type: "object";
|
|
35
|
-
}>[] : SchemaType<NonNullable<T["items"]>>[] : never;
|
|
36
|
-
export type SchemaType<T extends DataTypeSchema> = T["required"] extends true ? SchemaTypeInner<T> : SchemaTypeInner<T> | undefined | null;
|
|
37
|
-
export type SchemaMapType<T extends Record<string, DataTypeSchema>> = SchemaType<{
|
|
38
|
-
type: "object";
|
|
39
|
-
required: true;
|
|
40
|
-
properties: T;
|
|
41
|
-
}>;
|
|
42
|
-
export {};
|
package/lib/esm/logger.d.ts
DELETED
package/lib/esm/logger.js
DELETED
|
File without changes
|
|
File without changes
|