@openai/agents-core 0.2.1 → 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.
- package/dist/editor.d.ts +38 -0
- package/dist/editor.js +3 -0
- package/dist/editor.js.map +1 -0
- package/dist/editor.mjs +2 -0
- package/dist/editor.mjs.map +1 -0
- package/dist/extensions/handoffFilters.js +4 -0
- package/dist/extensions/handoffFilters.js.map +1 -1
- package/dist/extensions/handoffFilters.mjs +4 -0
- package/dist/extensions/handoffFilters.mjs.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -1
- package/dist/index.mjs.map +1 -1
- package/dist/items.d.ts +518 -4
- package/dist/items.js +22 -1
- package/dist/items.js.map +1 -1
- package/dist/items.mjs +22 -1
- package/dist/items.mjs.map +1 -1
- package/dist/memory/memorySession.d.ts +22 -0
- package/dist/memory/memorySession.js +64 -0
- package/dist/memory/memorySession.js.map +1 -0
- package/dist/memory/memorySession.mjs +60 -0
- package/dist/memory/memorySession.mjs.map +1 -0
- package/dist/memory/session.d.ts +36 -0
- package/dist/memory/session.js +3 -0
- package/dist/memory/session.js.map +1 -0
- package/dist/memory/session.mjs +2 -0
- package/dist/memory/session.mjs.map +1 -0
- package/dist/metadata.js +2 -2
- package/dist/metadata.mjs +2 -2
- package/dist/model.d.ts +10 -2
- package/dist/run.d.ts +88 -8
- package/dist/run.js +859 -347
- package/dist/run.js.map +1 -1
- package/dist/run.mjs +859 -347
- package/dist/run.mjs.map +1 -1
- package/dist/runContext.js +2 -2
- package/dist/runContext.js.map +1 -1
- package/dist/runContext.mjs +2 -2
- package/dist/runContext.mjs.map +1 -1
- package/dist/runImplementation.d.ts +37 -3
- package/dist/runImplementation.js +1116 -319
- package/dist/runImplementation.js.map +1 -1
- package/dist/runImplementation.mjs +1106 -317
- package/dist/runImplementation.mjs.map +1 -1
- package/dist/runState.d.ts +4453 -785
- package/dist/runState.js +62 -3
- package/dist/runState.js.map +1 -1
- package/dist/runState.mjs +62 -3
- package/dist/runState.mjs.map +1 -1
- package/dist/shell.d.ts +36 -0
- package/dist/shell.js +3 -0
- package/dist/shell.js.map +1 -0
- package/dist/shell.mjs +2 -0
- package/dist/shell.mjs.map +1 -0
- package/dist/tool.d.ts +62 -1
- package/dist/tool.js +30 -0
- package/dist/tool.js.map +1 -1
- package/dist/tool.mjs +28 -0
- package/dist/tool.mjs.map +1 -1
- package/dist/types/aliases.d.ts +3 -3
- package/dist/types/protocol.d.ts +5470 -1519
- package/dist/types/protocol.js +74 -1
- package/dist/types/protocol.js.map +1 -1
- package/dist/types/protocol.mjs +73 -0
- package/dist/types/protocol.mjs.map +1 -1
- package/dist/utils/applyDiff.d.ts +9 -0
- package/dist/utils/applyDiff.js +275 -0
- package/dist/utils/applyDiff.js.map +1 -0
- package/dist/utils/applyDiff.mjs +272 -0
- package/dist/utils/applyDiff.mjs.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -0
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/serialize.js +12 -0
- package/dist/utils/serialize.js.map +1 -1
- package/dist/utils/serialize.mjs +12 -0
- package/dist/utils/serialize.mjs.map +1 -1
- package/dist/utils/smartString.d.ts +9 -0
- package/dist/utils/smartString.js +15 -0
- package/dist/utils/smartString.js.map +1 -1
- package/dist/utils/smartString.mjs +14 -3
- package/dist/utils/smartString.mjs.map +1 -1
- package/package.json +3 -3
package/dist/items.mjs
CHANGED
|
@@ -123,16 +123,37 @@ export class RunHandoffOutputItem extends RunItemBase {
|
|
|
123
123
|
export class RunToolApprovalItem extends RunItemBase {
|
|
124
124
|
rawItem;
|
|
125
125
|
agent;
|
|
126
|
+
toolName;
|
|
126
127
|
type = 'tool_approval_item';
|
|
127
|
-
constructor(rawItem, agent
|
|
128
|
+
constructor(rawItem, agent,
|
|
129
|
+
/**
|
|
130
|
+
* Explicit tool name to use for approval tracking when not present on the raw item.
|
|
131
|
+
*/
|
|
132
|
+
toolName) {
|
|
128
133
|
super();
|
|
129
134
|
this.rawItem = rawItem;
|
|
130
135
|
this.agent = agent;
|
|
136
|
+
this.toolName = toolName;
|
|
137
|
+
this.toolName = toolName ?? rawItem.name;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Returns the tool name if available on the raw item or provided explicitly.
|
|
141
|
+
* Kept for backwards compatibility with code that previously relied on `rawItem.name`.
|
|
142
|
+
*/
|
|
143
|
+
get name() {
|
|
144
|
+
return this.toolName ?? this.rawItem.name;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Returns the arguments if the raw item has an arguments property otherwise this will be undefined.
|
|
148
|
+
*/
|
|
149
|
+
get arguments() {
|
|
150
|
+
return 'arguments' in this.rawItem ? this.rawItem.arguments : undefined;
|
|
131
151
|
}
|
|
132
152
|
toJSON() {
|
|
133
153
|
return {
|
|
134
154
|
...super.toJSON(),
|
|
135
155
|
agent: this.agent.toJSON(),
|
|
156
|
+
toolName: this.toolName,
|
|
136
157
|
};
|
|
137
158
|
}
|
|
138
159
|
}
|
package/dist/items.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"items.mjs","sourceRoot":"","sources":["../src/items.ts"],"names":[],"mappings":"OACO,EAAE,aAAa,EAAE;AAGxB,MAAM,OAAO,WAAW;IACN,IAAI,GAAW,WAAoB,CAAC;IAC7C,OAAO,CAAsB;IAEpC,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IAI1C;IACA;IAJO,IAAI,GAAG,qBAA8B,CAAC;IAEtD,YACS,OAAsC,EACtC,KAAY;QAEnB,KAAK,EAAE,CAAC;QAHD,YAAO,G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
|
1
|
+
import type { AgentInputItem } from '../types';
|
|
2
|
+
import type { Session } from './session';
|
|
3
|
+
import { Logger } from '../logger';
|
|
4
|
+
export type MemorySessionOptions = {
|
|
5
|
+
sessionId?: string;
|
|
6
|
+
initialItems?: AgentInputItem[];
|
|
7
|
+
logger?: Logger;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Simple in-memory session store intended for demos or tests. Not recommended for production use.
|
|
11
|
+
*/
|
|
12
|
+
export declare class MemorySession implements Session {
|
|
13
|
+
private readonly sessionId;
|
|
14
|
+
private readonly logger;
|
|
15
|
+
private items;
|
|
16
|
+
constructor(options?: MemorySessionOptions);
|
|
17
|
+
getSessionId(): Promise<string>;
|
|
18
|
+
getItems(limit?: number): Promise<AgentInputItem[]>;
|
|
19
|
+
addItems(items: AgentInputItem[]): Promise<void>;
|
|
20
|
+
popItem(): Promise<AgentInputItem | undefined>;
|
|
21
|
+
clearSession(): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemorySession = void 0;
|
|
4
|
+
const _shims_1 = require("@openai/agents-core/_shims");
|
|
5
|
+
const logger_1 = require("../logger.js");
|
|
6
|
+
/**
|
|
7
|
+
* Simple in-memory session store intended for demos or tests. Not recommended for production use.
|
|
8
|
+
*/
|
|
9
|
+
class MemorySession {
|
|
10
|
+
sessionId;
|
|
11
|
+
logger;
|
|
12
|
+
items;
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
this.sessionId = options.sessionId ?? (0, _shims_1.randomUUID)();
|
|
15
|
+
this.items = options.initialItems
|
|
16
|
+
? options.initialItems.map(cloneAgentItem)
|
|
17
|
+
: [];
|
|
18
|
+
this.logger = options.logger ?? logger_1.logger;
|
|
19
|
+
}
|
|
20
|
+
async getSessionId() {
|
|
21
|
+
return this.sessionId;
|
|
22
|
+
}
|
|
23
|
+
async getItems(limit) {
|
|
24
|
+
if (limit === undefined) {
|
|
25
|
+
const cloned = this.items.map(cloneAgentItem);
|
|
26
|
+
this.logger.debug(`Getting items from memory session (${this.sessionId}): ${JSON.stringify(cloned)}`);
|
|
27
|
+
return cloned;
|
|
28
|
+
}
|
|
29
|
+
if (limit <= 0) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const start = Math.max(this.items.length - limit, 0);
|
|
33
|
+
const items = this.items.slice(start).map(cloneAgentItem);
|
|
34
|
+
this.logger.debug(`Getting items from memory session (${this.sessionId}): ${JSON.stringify(items)}`);
|
|
35
|
+
return items;
|
|
36
|
+
}
|
|
37
|
+
async addItems(items) {
|
|
38
|
+
if (items.length === 0) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const cloned = items.map(cloneAgentItem);
|
|
42
|
+
this.logger.debug(`Adding items to memory session (${this.sessionId}): ${JSON.stringify(cloned)}`);
|
|
43
|
+
this.items = [...this.items, ...cloned];
|
|
44
|
+
}
|
|
45
|
+
async popItem() {
|
|
46
|
+
if (this.items.length === 0) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
const item = this.items[this.items.length - 1];
|
|
50
|
+
const cloned = cloneAgentItem(item);
|
|
51
|
+
this.logger.debug(`Popping item from memory session (${this.sessionId}): ${JSON.stringify(cloned)}`);
|
|
52
|
+
this.items = this.items.slice(0, -1);
|
|
53
|
+
return cloned;
|
|
54
|
+
}
|
|
55
|
+
async clearSession() {
|
|
56
|
+
this.logger.debug(`Clearing memory session (${this.sessionId})`);
|
|
57
|
+
this.items = [];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.MemorySession = MemorySession;
|
|
61
|
+
function cloneAgentItem(item) {
|
|
62
|
+
return structuredClone(item);
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=memorySession.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memorySession.js","sourceRoot":"","sources":["../../src/mem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C;AAED,SAAS,cAAc,CAA2B,IAAO;IACvD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { randomUUID } from '@openai/agents-core/_shims';
|
|
2
|
+
import { logger } from "../logger.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* Simple in-memory session store intended for demos or tests. Not recommended for production use.
|
|
5
|
+
*/
|
|
6
|
+
export class MemorySession {
|
|
7
|
+
sessionId;
|
|
8
|
+
logger;
|
|
9
|
+
items;
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
this.sessionId = options.sessionId ?? randomUUID();
|
|
12
|
+
this.items = options.initialItems
|
|
13
|
+
? options.initialItems.map(cloneAgentItem)
|
|
14
|
+
: [];
|
|
15
|
+
this.logger = options.logger ?? logger;
|
|
16
|
+
}
|
|
17
|
+
async getSessionId() {
|
|
18
|
+
return this.sessionId;
|
|
19
|
+
}
|
|
20
|
+
async getItems(limit) {
|
|
21
|
+
if (limit === undefined) {
|
|
22
|
+
const cloned = this.items.map(cloneAgentItem);
|
|
23
|
+
this.logger.debug(`Getting items from memory session (${this.sessionId}): ${JSON.stringify(cloned)}`);
|
|
24
|
+
return cloned;
|
|
25
|
+
}
|
|
26
|
+
if (limit <= 0) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
const start = Math.max(this.items.length - limit, 0);
|
|
30
|
+
const items = this.items.slice(start).map(cloneAgentItem);
|
|
31
|
+
this.logger.debug(`Getting items from memory session (${this.sessionId}): ${JSON.stringify(items)}`);
|
|
32
|
+
return items;
|
|
33
|
+
}
|
|
34
|
+
async addItems(items) {
|
|
35
|
+
if (items.length === 0) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const cloned = items.map(cloneAgentItem);
|
|
39
|
+
this.logger.debug(`Adding items to memory session (${this.sessionId}): ${JSON.stringify(cloned)}`);
|
|
40
|
+
this.items = [...this.items, ...cloned];
|
|
41
|
+
}
|
|
42
|
+
async popItem() {
|
|
43
|
+
if (this.items.length === 0) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const item = this.items[this.items.length - 1];
|
|
47
|
+
const cloned = cloneAgentItem(item);
|
|
48
|
+
this.logger.debug(`Popping item from memory session (${this.sessionId}): ${JSON.stringify(cloned)}`);
|
|
49
|
+
this.items = this.items.slice(0, -1);
|
|
50
|
+
return cloned;
|
|
51
|
+
}
|
|
52
|
+
async clearSession() {
|
|
53
|
+
this.logger.debug(`Clearing memory session (${this.sessionId})`);
|
|
54
|
+
this.items = [];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function cloneAgentItem(item) {
|
|
58
|
+
return structuredClone(item);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=memorySession.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memorySession.mjs","sourceRoot":"","sources":["../../src/memory/memorySession.ts"],"names":[],"mappings":"OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B;OAIhD,EAAE,MAAM,EAAU;AAQzB;;GAEG;AACH,MAAM,OAAO,aAAa;IACP,SAAS,CAAS;IAClB,MAAM,CAAS;IAExB,KAAK,CAAmB;IAEhC,YAAY,UAAgC,EAAE;QAC5C,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,UAAU,EAAE,CAAC;QACnD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,YAAY;YAC/B,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,cAAc,CAAC;YAC1C,CAAC,CAAC,EAAE,CAAC;QACP,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAc;QAC3B,IAAI,KAAK,KAAK,SAAS,EAAE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ACnB,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,qCAAqC,IAAI,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAClF,CAAC;QACF,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACjE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;CACF;AAED,SAAS,cAAc,CAA2B,IAAO;IACvD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AgentInputItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* A function that combines session history with new input items before the model call.
|
|
4
|
+
*/
|
|
5
|
+
export type SessionInputCallback = (historyItems: AgentInputItem[], newItems: AgentInputItem[]) => AgentInputItem[] | Promise<AgentInputItem[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Interface representing a persistent session store for conversation history.
|
|
8
|
+
*/
|
|
9
|
+
export interface Session {
|
|
10
|
+
/**
|
|
11
|
+
* Ensure and return the identifier for this session.
|
|
12
|
+
*/
|
|
13
|
+
getSessionId(): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Retrieve items from the conversation history.
|
|
16
|
+
*
|
|
17
|
+
* @param limit - The maximum number of items to return. When provided the most
|
|
18
|
+
* recent {@link limit} items should be returned in chronological order.
|
|
19
|
+
*/
|
|
20
|
+
getItems(limit?: number): Promise<AgentInputItem[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Append new items to the conversation history.
|
|
23
|
+
*
|
|
24
|
+
* @param items - Items to add to the session history.
|
|
25
|
+
*/
|
|
26
|
+
addItems(items: AgentInputItem[]): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Remove and return the most recent item from the conversation history if it
|
|
29
|
+
* exists.
|
|
30
|
+
*/
|
|
31
|
+
popItem(): Promise<AgentInputItem | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Remove all items that belong to the session and reset its state.
|
|
34
|
+
*/
|
|
35
|
+
clearSession(): Promise<void>;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/memory/session.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.mjs","sourceRoot":"","sources":["../../src/memory/session.ts"],"names":[],"mappings":""}
|
package/dist/metadata.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.METADATA = void 0;
|
|
5
5
|
exports.METADATA = {
|
|
6
6
|
"name": "@openai/agents-core",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.3.1",
|
|
8
8
|
"versions": {
|
|
9
|
-
"@openai/agents-core": "0.
|
|
9
|
+
"@openai/agents-core": "0.3.1",
|
|
10
10
|
"openai": "^6"
|
|
11
11
|
}
|
|
12
12
|
};
|
package/dist/metadata.mjs
CHANGED
package/dist/model.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Usage } from './usage';
|
|
2
2
|
import { StreamEvent } from './types/protocol';
|
|
3
|
-
import { HostedTool, ComputerTool, FunctionTool } from './tool';
|
|
3
|
+
import { HostedTool, ComputerTool, FunctionTool, ShellTool, ApplyPatchTool } from './tool';
|
|
4
4
|
import { Handoff } from './handoff';
|
|
5
5
|
import { AgentInputItem, AgentOutputItem, JsonSchemaDefinition, TextOutput, InputText, InputImage, InputFile } from './types';
|
|
6
6
|
export type ModelSettingsToolChoice = 'auto' | 'required' | 'none' | (string & {});
|
|
@@ -127,12 +127,20 @@ export type SerializedComputerTool = {
|
|
|
127
127
|
environment: ComputerTool['computer']['environment'];
|
|
128
128
|
dimensions: ComputerTool['computer']['dimensions'];
|
|
129
129
|
};
|
|
130
|
+
export type SerializedShellTool = {
|
|
131
|
+
type: ShellTool['type'];
|
|
132
|
+
name: ShellTool['name'];
|
|
133
|
+
};
|
|
134
|
+
export type SerializedApplyPatchTool = {
|
|
135
|
+
type: ApplyPatchTool['type'];
|
|
136
|
+
name: ApplyPatchTool['name'];
|
|
137
|
+
};
|
|
130
138
|
export type SerializedHostedTool = {
|
|
131
139
|
type: HostedTool['type'];
|
|
132
140
|
name: HostedTool['name'];
|
|
133
141
|
providerData?: HostedTool['providerData'];
|
|
134
142
|
};
|
|
135
|
-
export type SerializedTool = SerializedFunctionTool | SerializedComputerTool | SerializedHostedTool;
|
|
143
|
+
export type SerializedTool = SerializedFunctionTool | SerializedComputerTool | SerializedShellTool | SerializedApplyPatchTool | SerializedHostedTool;
|
|
136
144
|
export type SerializedHandoff = {
|
|
137
145
|
/**
|
|
138
146
|
* The name of the tool that represents the handoff.
|
package/dist/run.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Agent, AgentOutputType } from './agent';
|
|
2
2
|
import { InputGuardrail, OutputGuardrail } from './guardrail';
|
|
3
3
|
import { HandoffInputFilter } from './handoff';
|
|
4
|
-
import { Model, ModelProvider, ModelSettings } from './model';
|
|
4
|
+
import { Model, ModelProvider, ModelSettings, ModelTracing } from './model';
|
|
5
5
|
import { RunContext } from './runContext';
|
|
6
6
|
import { AgentInputItem } from './types';
|
|
7
7
|
import { RunResult, StreamedRunResult } from './result';
|
|
8
8
|
import { RunHooks } from './lifecycle';
|
|
9
9
|
import { RunItem } from './items';
|
|
10
10
|
import { RunState } from './runState';
|
|
11
|
+
import type { Session, SessionInputCallback } from './memory/session';
|
|
11
12
|
/**
|
|
12
13
|
* Configures settings for the entire agent run.
|
|
13
14
|
*/
|
|
@@ -68,36 +69,74 @@ export type RunConfig = {
|
|
|
68
69
|
* An optional dictionary of additional metadata to include with the trace.
|
|
69
70
|
*/
|
|
70
71
|
traceMetadata?: Record<string, string>;
|
|
72
|
+
/**
|
|
73
|
+
* Customizes how session history is combined with the current turn's input.
|
|
74
|
+
* When omitted, history items are appended before the new input.
|
|
75
|
+
*/
|
|
76
|
+
sessionInputCallback?: SessionInputCallback;
|
|
77
|
+
/**
|
|
78
|
+
* Invoked immediately before calling the model, allowing callers to edit the
|
|
79
|
+
* system instructions or input items that will be sent to the model.
|
|
80
|
+
*/
|
|
81
|
+
callModelInputFilter?: CallModelInputFilter;
|
|
71
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* Common run options shared between streaming and non-streaming execution pathways.
|
|
85
|
+
*/
|
|
72
86
|
type SharedRunOptions<TContext = undefined> = {
|
|
73
87
|
context?: TContext | RunContext<TContext>;
|
|
74
88
|
maxTurns?: number;
|
|
75
89
|
signal?: AbortSignal;
|
|
76
90
|
previousResponseId?: string;
|
|
77
91
|
conversationId?: string;
|
|
92
|
+
session?: Session;
|
|
93
|
+
sessionInputCallback?: SessionInputCallback;
|
|
94
|
+
callModelInputFilter?: CallModelInputFilter;
|
|
78
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Options for runs that stream incremental events as the model responds.
|
|
98
|
+
*/
|
|
79
99
|
export type StreamRunOptions<TContext = undefined> = SharedRunOptions<TContext> & {
|
|
80
100
|
/**
|
|
81
101
|
* Whether to stream the run. If true, the run will emit events as the model responds.
|
|
82
102
|
*/
|
|
83
103
|
stream: true;
|
|
84
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
* Options for runs that collect the full model response before returning.
|
|
107
|
+
*/
|
|
85
108
|
export type NonStreamRunOptions<TContext = undefined> = SharedRunOptions<TContext> & {
|
|
86
109
|
/**
|
|
87
|
-
*
|
|
110
|
+
* Run to completion without streaming incremental events; leave undefined or set to `false`.
|
|
88
111
|
*/
|
|
89
112
|
stream?: false;
|
|
90
113
|
};
|
|
114
|
+
/**
|
|
115
|
+
* Options polymorphic over streaming or non-streaming execution modes.
|
|
116
|
+
*/
|
|
91
117
|
export type IndividualRunOptions<TContext = undefined> = StreamRunOptions<TContext> | NonStreamRunOptions<TContext>;
|
|
92
|
-
export declare function getTurnInput(originalInput: string | AgentInputItem[], generatedItems: RunItem[]): AgentInputItem[];
|
|
93
118
|
/**
|
|
94
|
-
*
|
|
119
|
+
* Executes an agent workflow with the shared default `Runner` instance.
|
|
120
|
+
*
|
|
121
|
+
* @param agent - The entry agent to invoke.
|
|
122
|
+
* @param input - A string utterance, structured input items, or a resumed `RunState`.
|
|
123
|
+
* @param options - Controls streaming mode, context, session handling, and turn limits.
|
|
124
|
+
* @returns A `RunResult` when `stream` is false, otherwise a `StreamedRunResult`.
|
|
125
|
+
*/
|
|
126
|
+
export declare function run<TAgent extends Agent<any, any>, TContext = undefined>(agent: TAgent, input: string | AgentInputItem[] | RunState<TContext, TAgent>, options?: NonStreamRunOptions<TContext>): Promise<RunResult<TContext, TAgent>>;
|
|
127
|
+
export declare function run<TAgent extends Agent<any, any>, TContext = undefined>(agent: TAgent, input: string | AgentInputItem[] | RunState<TContext, TAgent>, options?: StreamRunOptions<TContext>): Promise<StreamedRunResult<TContext, TAgent>>;
|
|
128
|
+
/**
|
|
129
|
+
* Orchestrates agent execution, including guardrails, tool calls, session persistence, and
|
|
130
|
+
* tracing. Reuse a `Runner` instance when you want consistent configuration across multiple runs.
|
|
95
131
|
*/
|
|
96
132
|
export declare class Runner extends RunHooks<any, AgentOutputType<unknown>> {
|
|
97
133
|
#private;
|
|
98
134
|
readonly config: RunConfig;
|
|
99
|
-
|
|
100
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Creates a runner with optional defaults that apply to every subsequent run invocation.
|
|
137
|
+
*
|
|
138
|
+
* @param config - Overrides for models, guardrails, tracing, or session behavior.
|
|
139
|
+
*/
|
|
101
140
|
constructor(config?: Partial<RunConfig>);
|
|
102
141
|
/**
|
|
103
142
|
* Run a workflow starting at the given agent. The agent will run in a loop until a final
|
|
@@ -123,8 +162,49 @@ export declare class Runner extends RunHooks<any, AgentOutputType<unknown>> {
|
|
|
123
162
|
*/
|
|
124
163
|
run<TAgent extends Agent<any, any>, TContext = undefined>(agent: TAgent, input: string | AgentInputItem[] | RunState<TContext, TAgent>, options?: NonStreamRunOptions<TContext>): Promise<RunResult<TContext, TAgent>>;
|
|
125
164
|
run<TAgent extends Agent<any, any>, TContext = undefined>(agent: TAgent, input: string | AgentInputItem[] | RunState<TContext, TAgent>, options?: StreamRunOptions<TContext>): Promise<StreamedRunResult<TContext, TAgent>>;
|
|
165
|
+
private readonly inputGuardrailDefs;
|
|
166
|
+
private readonly outputGuardrailDefs;
|
|
126
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Mutable view of the instructions + input items that the model will receive.
|
|
170
|
+
* Filters always see a copy so they can edit without side effects.
|
|
171
|
+
*/
|
|
172
|
+
export type ModelInputData = {
|
|
173
|
+
input: AgentInputItem[];
|
|
174
|
+
instructions?: string;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Shape of the payload given to `callModelInputFilter`. Mirrored in the Python SDK so filters can
|
|
178
|
+
* share the same implementation across languages.
|
|
179
|
+
*/
|
|
180
|
+
export type CallModelInputFilterArgs<TContext = unknown> = {
|
|
181
|
+
modelData: ModelInputData;
|
|
182
|
+
agent: Agent<TContext, AgentOutputType>;
|
|
183
|
+
context: TContext | undefined;
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* Hook invoked immediately before a model call is issued, allowing callers to adjust the
|
|
187
|
+
* instructions or input array. Returning a new array enables redaction, truncation, or
|
|
188
|
+
* augmentation of the payload that will be sent to the provider.
|
|
189
|
+
*/
|
|
190
|
+
export type CallModelInputFilter<TContext = unknown> = (args: CallModelInputFilterArgs<TContext>) => ModelInputData | Promise<ModelInputData>;
|
|
191
|
+
/**
|
|
192
|
+
* Constructs the model input array for the current turn by combining the original turn input with
|
|
193
|
+
* any new run items (excluding tool approval placeholders). This helps ensure that repeated calls
|
|
194
|
+
* to the Responses API only send newly generated content.
|
|
195
|
+
*
|
|
196
|
+
* See: https://platform.openai.com/docs/guides/conversation-state?api-mode=responses.
|
|
197
|
+
*/
|
|
198
|
+
export declare function getTurnInput(originalInput: string | AgentInputItem[], generatedItems: RunItem[]): AgentInputItem[];
|
|
199
|
+
/**
|
|
200
|
+
* Resolves the effective model for the next turn by giving precedence to the agent-specific
|
|
201
|
+
* configuration when present, otherwise falling back to the runner-level default.
|
|
202
|
+
*/
|
|
127
203
|
export declare function selectModel(agentModel: string | Model, runConfigModel: string | Model | undefined): string | Model;
|
|
128
|
-
|
|
129
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Normalizes tracing configuration into the format expected by model providers.
|
|
206
|
+
* Returns `false` to disable tracing, `true` to include full payload data, or
|
|
207
|
+
* `'enabled_without_data'` to omit sensitive content while still emitting spans.
|
|
208
|
+
*/
|
|
209
|
+
export declare function getTracing(tracingDisabled: boolean, traceIncludeSensitiveData: boolean): ModelTracing;
|
|
130
210
|
export {};
|