@openai/agents-core 0.3.6 → 0.3.8
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/errors.d.ts +40 -0
- package/dist/errors.js +38 -1
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +34 -0
- package/dist/errors.mjs.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -1
- package/dist/index.mjs.map +1 -1
- package/dist/metadata.js +2 -2
- package/dist/metadata.mjs +2 -2
- package/dist/result.d.ts +17 -0
- package/dist/result.js +71 -24
- package/dist/result.js.map +1 -1
- package/dist/result.mjs +69 -22
- package/dist/result.mjs.map +1 -1
- package/dist/run.d.ts +14 -47
- package/dist/run.js +421 -994
- package/dist/run.js.map +1 -1
- package/dist/run.mjs +405 -978
- package/dist/run.mjs.map +1 -1
- package/dist/runState.d.ts +1286 -172
- package/dist/runState.js +146 -16
- package/dist/runState.js.map +1 -1
- package/dist/runState.mjs +142 -12
- package/dist/runState.mjs.map +1 -1
- package/dist/runner/constants.d.ts +1 -0
- package/dist/runner/constants.js +6 -0
- package/dist/runner/constants.js.map +1 -0
- package/dist/runner/constants.mjs +3 -0
- package/dist/runner/constants.mjs.map +1 -0
- package/dist/runner/conversation.d.ts +85 -0
- package/dist/runner/conversation.js +275 -0
- package/dist/runner/conversation.js.map +1 -0
- package/dist/runner/conversation.mjs +269 -0
- package/dist/runner/conversation.mjs.map +1 -0
- package/dist/runner/guardrails.d.ts +23 -0
- package/dist/runner/guardrails.js +174 -0
- package/dist/runner/guardrails.js.map +1 -0
- package/dist/runner/guardrails.mjs +166 -0
- package/dist/runner/guardrails.mjs.map +1 -0
- package/dist/runner/items.d.ts +18 -0
- package/dist/runner/items.js +89 -0
- package/dist/runner/items.js.map +1 -0
- package/dist/runner/items.mjs +79 -0
- package/dist/runner/items.mjs.map +1 -0
- package/dist/runner/mcpApprovals.d.ts +25 -0
- package/dist/runner/mcpApprovals.js +66 -0
- package/dist/runner/mcpApprovals.js.map +1 -0
- package/dist/runner/mcpApprovals.mjs +63 -0
- package/dist/runner/mcpApprovals.mjs.map +1 -0
- package/dist/runner/modelOutputs.d.ts +10 -0
- package/dist/runner/modelOutputs.js +206 -0
- package/dist/runner/modelOutputs.js.map +1 -0
- package/dist/runner/modelOutputs.mjs +203 -0
- package/dist/runner/modelOutputs.mjs.map +1 -0
- package/dist/runner/modelPreparation.d.ts +8 -0
- package/dist/runner/modelPreparation.js +41 -0
- package/dist/runner/modelPreparation.js.map +1 -0
- package/dist/runner/modelPreparation.mjs +38 -0
- package/dist/runner/modelPreparation.mjs.map +1 -0
- package/dist/runner/modelSettings.d.ts +20 -0
- package/dist/runner/modelSettings.js +97 -0
- package/dist/runner/modelSettings.js.map +1 -0
- package/dist/runner/modelSettings.mjs +92 -0
- package/dist/runner/modelSettings.mjs.map +1 -0
- package/dist/runner/runLoop.d.ts +32 -0
- package/dist/runner/runLoop.js +62 -0
- package/dist/runner/runLoop.js.map +1 -0
- package/dist/runner/runLoop.mjs +57 -0
- package/dist/runner/runLoop.mjs.map +1 -0
- package/dist/runner/sessionPersistence.d.ts +26 -0
- package/dist/runner/sessionPersistence.js +441 -0
- package/dist/runner/sessionPersistence.js.map +1 -0
- package/dist/runner/sessionPersistence.mjs +431 -0
- package/dist/runner/sessionPersistence.mjs.map +1 -0
- package/dist/runner/steps.d.ts +48 -0
- package/dist/runner/steps.js +40 -0
- package/dist/runner/steps.js.map +1 -0
- package/dist/runner/steps.mjs +36 -0
- package/dist/runner/steps.mjs.map +1 -0
- package/dist/runner/streaming.d.ts +9 -0
- package/dist/runner/streaming.js +74 -0
- package/dist/runner/streaming.js.map +1 -0
- package/dist/runner/streaming.mjs +65 -0
- package/dist/runner/streaming.mjs.map +1 -0
- package/dist/runner/toolExecution.d.ts +15 -0
- package/dist/runner/toolExecution.js +997 -0
- package/dist/runner/toolExecution.js.map +1 -0
- package/dist/runner/toolExecution.mjs +984 -0
- package/dist/runner/toolExecution.mjs.map +1 -0
- package/dist/runner/toolUseTracker.d.ts +9 -0
- package/dist/runner/toolUseTracker.js +34 -0
- package/dist/runner/toolUseTracker.js.map +1 -0
- package/dist/runner/toolUseTracker.mjs +30 -0
- package/dist/runner/toolUseTracker.mjs.map +1 -0
- package/dist/runner/tracing.d.ts +23 -0
- package/dist/runner/tracing.js +45 -0
- package/dist/runner/tracing.js.map +1 -0
- package/dist/runner/tracing.mjs +41 -0
- package/dist/runner/tracing.mjs.map +1 -0
- package/dist/runner/turnPreparation.d.ts +30 -0
- package/dist/runner/turnPreparation.js +80 -0
- package/dist/runner/turnPreparation.js.map +1 -0
- package/dist/runner/turnPreparation.mjs +74 -0
- package/dist/runner/turnPreparation.mjs.map +1 -0
- package/dist/runner/turnResolution.d.ts +3 -0
- package/dist/runner/turnResolution.js +531 -0
- package/dist/runner/turnResolution.js.map +1 -0
- package/dist/runner/turnResolution.mjs +526 -0
- package/dist/runner/turnResolution.mjs.map +1 -0
- package/dist/runner/types.d.ts +66 -0
- package/dist/runner/types.js +3 -0
- package/dist/runner/types.js.map +1 -0
- package/dist/runner/types.mjs +2 -0
- package/dist/runner/types.mjs.map +1 -0
- package/dist/shims/mcp-server/node.js +76 -30
- package/dist/shims/mcp-server/node.js.map +1 -1
- package/dist/shims/mcp-server/node.mjs +76 -30
- package/dist/shims/mcp-server/node.mjs.map +1 -1
- package/dist/tool.d.ts +28 -2
- package/dist/tool.js +7 -1
- package/dist/tool.js.map +1 -1
- package/dist/tool.mjs +8 -2
- package/dist/tool.mjs.map +1 -1
- package/dist/toolGuardrail.d.ts +101 -0
- package/dist/toolGuardrail.js +58 -0
- package/dist/toolGuardrail.js.map +1 -0
- package/dist/toolGuardrail.mjs +51 -0
- package/dist/toolGuardrail.mjs.map +1 -0
- package/dist/tracing/config.d.ts +3 -0
- package/dist/tracing/config.js +3 -0
- package/dist/tracing/config.js.map +1 -0
- package/dist/tracing/config.mjs +2 -0
- package/dist/tracing/config.mjs.map +1 -0
- package/dist/tracing/context.d.ts +2 -0
- package/dist/tracing/context.js +95 -24
- package/dist/tracing/context.js.map +1 -1
- package/dist/tracing/context.mjs +95 -24
- package/dist/tracing/context.mjs.map +1 -1
- package/dist/tracing/createSpans.d.ts +11 -11
- package/dist/tracing/index.d.ts +2 -0
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/tracing/provider.js +54 -4
- package/dist/tracing/provider.js.map +1 -1
- package/dist/tracing/provider.mjs +54 -4
- package/dist/tracing/provider.mjs.map +1 -1
- package/dist/tracing/spans.d.ts +2 -0
- package/dist/tracing/spans.js +6 -0
- package/dist/tracing/spans.js.map +1 -1
- package/dist/tracing/spans.mjs +6 -0
- package/dist/tracing/spans.mjs.map +1 -1
- package/dist/tracing/traces.d.ts +11 -1
- package/dist/tracing/traces.js +15 -2
- package/dist/tracing/traces.js.map +1 -1
- package/dist/tracing/traces.mjs +15 -2
- package/dist/tracing/traces.mjs.map +1 -1
- package/dist/types/protocol.d.ts +11 -0
- package/dist/types/protocol.js +1 -0
- package/dist/types/protocol.js.map +1 -1
- package/dist/types/protocol.mjs +1 -0
- package/dist/types/protocol.mjs.map +1 -1
- package/dist/utils/binary.d.ts +6 -0
- package/dist/utils/binary.js +53 -0
- package/dist/utils/binary.js.map +1 -0
- package/dist/utils/binary.mjs +49 -0
- package/dist/utils/binary.mjs.map +1 -0
- package/dist/utils/toolGuardrails.d.ts +24 -0
- package/dist/utils/toolGuardrails.js +58 -0
- package/dist/utils/toolGuardrails.js.map +1 -0
- package/dist/utils/toolGuardrails.mjs +54 -0
- package/dist/utils/toolGuardrails.mjs.map +1 -0
- package/package.json +4 -3
- package/dist/runImplementation.d.ts +0 -161
- package/dist/runImplementation.js +0 -2054
- package/dist/runImplementation.js.map +0 -1
- package/dist/runImplementation.mjs +0 -2028
- package/dist/runImplementation.mjs.map +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ToolInputGuardrailDefinition, ToolInputGuardrailResult, ToolOutputGuardrailDefinition, ToolOutputGuardrailResult } from '../toolGuardrail';
|
|
2
|
+
import type { Agent } from '../agent';
|
|
3
|
+
import type { RunContext } from '../runContext';
|
|
4
|
+
import type * as protocol from '../types/protocol';
|
|
5
|
+
export declare function runToolInputGuardrails<TContext, TAgent extends Agent<any, any>>({ guardrails, context, agent, toolCall, onResult, }: {
|
|
6
|
+
guardrails?: ToolInputGuardrailDefinition<TContext>[];
|
|
7
|
+
context: RunContext<TContext>;
|
|
8
|
+
agent: TAgent;
|
|
9
|
+
toolCall: protocol.FunctionCallItem;
|
|
10
|
+
onResult?: (result: ToolInputGuardrailResult) => void;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
type: 'allow';
|
|
13
|
+
} | {
|
|
14
|
+
type: 'reject';
|
|
15
|
+
message: string;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function runToolOutputGuardrails<TContext, TAgent extends Agent<any, any>>({ guardrails, context, agent, toolCall, toolOutput, onResult, }: {
|
|
18
|
+
guardrails?: ToolOutputGuardrailDefinition<TContext>[];
|
|
19
|
+
context: RunContext<TContext>;
|
|
20
|
+
agent: TAgent;
|
|
21
|
+
toolCall: protocol.FunctionCallItem;
|
|
22
|
+
toolOutput: unknown;
|
|
23
|
+
onResult?: (result: ToolOutputGuardrailResult) => void;
|
|
24
|
+
}): Promise<unknown>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runToolInputGuardrails = runToolInputGuardrails;
|
|
4
|
+
exports.runToolOutputGuardrails = runToolOutputGuardrails;
|
|
5
|
+
const errors_1 = require("../errors.js");
|
|
6
|
+
function normalizeBehavior(output) {
|
|
7
|
+
return output.behavior ?? { type: 'allow' };
|
|
8
|
+
}
|
|
9
|
+
async function runToolInputGuardrails({ guardrails, context, agent, toolCall, onResult, }) {
|
|
10
|
+
const list = guardrails ?? [];
|
|
11
|
+
for (const guardrail of list) {
|
|
12
|
+
const output = await guardrail.run({
|
|
13
|
+
context,
|
|
14
|
+
agent,
|
|
15
|
+
toolCall,
|
|
16
|
+
});
|
|
17
|
+
const behavior = normalizeBehavior(output);
|
|
18
|
+
const result = {
|
|
19
|
+
guardrail: { type: 'tool_input', name: guardrail.name },
|
|
20
|
+
output: { ...output, behavior },
|
|
21
|
+
};
|
|
22
|
+
onResult?.(result);
|
|
23
|
+
if (behavior.type === 'rejectContent') {
|
|
24
|
+
return { type: 'reject', message: behavior.message };
|
|
25
|
+
}
|
|
26
|
+
if (behavior.type === 'throwException') {
|
|
27
|
+
throw new errors_1.ToolInputGuardrailTripwireTriggered(`Tool input guardrail triggered: ${guardrail.name}`, result);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return { type: 'allow' };
|
|
31
|
+
}
|
|
32
|
+
async function runToolOutputGuardrails({ guardrails, context, agent, toolCall, toolOutput, onResult, }) {
|
|
33
|
+
const list = guardrails ?? [];
|
|
34
|
+
let finalOutput = toolOutput;
|
|
35
|
+
for (const guardrail of list) {
|
|
36
|
+
const output = await guardrail.run({
|
|
37
|
+
context,
|
|
38
|
+
agent,
|
|
39
|
+
toolCall,
|
|
40
|
+
output: toolOutput,
|
|
41
|
+
});
|
|
42
|
+
const behavior = normalizeBehavior(output);
|
|
43
|
+
const result = {
|
|
44
|
+
guardrail: { type: 'tool_output', name: guardrail.name },
|
|
45
|
+
output: { ...output, behavior },
|
|
46
|
+
};
|
|
47
|
+
onResult?.(result);
|
|
48
|
+
if (behavior.type === 'rejectContent') {
|
|
49
|
+
finalOutput = behavior.message;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
if (behavior.type === 'throwException') {
|
|
53
|
+
throw new errors_1.ToolOutputGuardrailTripwireTriggered(`Tool output guardrail triggered: ${guardrail.name}`, result);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return finalOutput;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=toolGuardrails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolGuardrails.js","sourceRoot":"","sources":["../../src/utils/toolGuardrails.ts"],"names":[],"mappings":";;AAqBA,wDAwCC;AAED,0DA6CC;AAlGD,yCAGmB;AAEnB,SAAS,iBAAiB,CACxB,MAAmC;IAEnC,OAAO,MAAM,CAAC,QAAQ,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC9C,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAG1C,EACA,UAAU,EACV,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAQ,GAOT;IACC,MAAM,IAAI,GAAG,UAAU,IAAI,EAAE,CAAC;IAC9B,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC;YACjC,OAAO;YACP,KAAK;YACL,QAAQ;SACT,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,MAAM,GAA6B;YACvC,SAAS,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE;YACvD,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE;SAChC,CAAC;QACF,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;QACnB,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YACtC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;QACvD,CAAC;QACD,IAAI,QAAQ,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YACvC,MAAM,IAAI,4CAAmC,CAC3C,mCAAmC,SAAS,CAAC,IAAI,EAAE,EACnD,MAAM,CACP,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC;AAEM,KAAK,UAAU,uBAAuB,CAG3C,EACA,UAAU,EACV,OAAO,EACP,KAAK,EACL,QAAQ,EACR,UAAU,EACV,QAAQ,GAQT;IACC,MAAM,IAAI,GAAG,UAAU,IAAI,EAAE,CAAC;IAC9B,IAAI,WAAW,GAAG,UAAU,CAAC;IAC7B,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC;YACjC,OAAO;YACP,KAAK;YACL,QAAQ;YACR,MAAM,EAAE,UAAU;SACnB,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,MAAM,GAA8B;YACxC,SAAS,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE;YACxD,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE;SAChC,CAAC;QACF,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;QACnB,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YACtC,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC;YAC/B,MAAM;QACR,CAAC;QACD,IAAI,QAAQ,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YACvC,MAAM,IAAI,6CAAoC,CAC5C,oCAAoC,SAAS,CAAC,IAAI,EAAE,EACpD,MAAM,CACP,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ToolInputGuardrailTripwireTriggered, ToolOutputGuardrailTripwireTriggered, } from "../errors.mjs";
|
|
2
|
+
function normalizeBehavior(output) {
|
|
3
|
+
return output.behavior ?? { type: 'allow' };
|
|
4
|
+
}
|
|
5
|
+
export async function runToolInputGuardrails({ guardrails, context, agent, toolCall, onResult, }) {
|
|
6
|
+
const list = guardrails ?? [];
|
|
7
|
+
for (const guardrail of list) {
|
|
8
|
+
const output = await guardrail.run({
|
|
9
|
+
context,
|
|
10
|
+
agent,
|
|
11
|
+
toolCall,
|
|
12
|
+
});
|
|
13
|
+
const behavior = normalizeBehavior(output);
|
|
14
|
+
const result = {
|
|
15
|
+
guardrail: { type: 'tool_input', name: guardrail.name },
|
|
16
|
+
output: { ...output, behavior },
|
|
17
|
+
};
|
|
18
|
+
onResult?.(result);
|
|
19
|
+
if (behavior.type === 'rejectContent') {
|
|
20
|
+
return { type: 'reject', message: behavior.message };
|
|
21
|
+
}
|
|
22
|
+
if (behavior.type === 'throwException') {
|
|
23
|
+
throw new ToolInputGuardrailTripwireTriggered(`Tool input guardrail triggered: ${guardrail.name}`, result);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { type: 'allow' };
|
|
27
|
+
}
|
|
28
|
+
export async function runToolOutputGuardrails({ guardrails, context, agent, toolCall, toolOutput, onResult, }) {
|
|
29
|
+
const list = guardrails ?? [];
|
|
30
|
+
let finalOutput = toolOutput;
|
|
31
|
+
for (const guardrail of list) {
|
|
32
|
+
const output = await guardrail.run({
|
|
33
|
+
context,
|
|
34
|
+
agent,
|
|
35
|
+
toolCall,
|
|
36
|
+
output: toolOutput,
|
|
37
|
+
});
|
|
38
|
+
const behavior = normalizeBehavior(output);
|
|
39
|
+
const result = {
|
|
40
|
+
guardrail: { type: 'tool_output', name: guardrail.name },
|
|
41
|
+
output: { ...output, behavior },
|
|
42
|
+
};
|
|
43
|
+
onResult?.(result);
|
|
44
|
+
if (behavior.type === 'rejectContent') {
|
|
45
|
+
finalOutput = behavior.message;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
if (behavior.type === 'throwException') {
|
|
49
|
+
throw new ToolOutputGuardrailTripwireTriggered(`Tool output guardrail triggered: ${guardrail.name}`, result);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return finalOutput;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=toolGuardrails.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolGuardrails.mjs","sourceRoot":"","sources":["../../src/utils/toolGuardrails.ts"],"names":[],"mappings":"OAUO,EACL,mCAAmC,EACnC,oCAAoC,GACrC;AAED,SAAS,iBAAiB,CACxB,MAAmC;IAEnC,OAAO,MAAM,CAAC,QAAQ,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC9C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAG1C,EACA,UAAU,EACV,OAAO,EACP,KAAK,EACL,QAAQ,EACR,QAAQ,GAOT;IACC,MAAM,IAAI,GAAG,UAAU,IAAI,EAAE,CAAC;IAC9B,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC;YACjC,OAAO;YACP,KAAK;YACL,QAAQ;SACT,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,MAAM,GAA6B;YACvC,SAAS,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE;YACvD,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE;SAChC,CAAC;QACF,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;QACnB,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YACtC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;QACvD,CAAC;QACD,IAAI,QAAQ,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YACvC,MAAM,IAAI,mCAAmC,CAC3C,mCAAmC,SAAS,CAAC,IAAI,EAAE,EACnD,MAAM,CACP,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAG3C,EACA,UAAU,EACV,OAAO,EACP,KAAK,EACL,QAAQ,EACR,UAAU,EACV,QAAQ,GAQT;IACC,MAAM,IAAI,GAAG,UAAU,IAAI,EAAE,CAAC;IAC9B,IAAI,WAAW,GAAG,UAAU,CAAC;IAC7B,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC;YACjC,OAAO;YACP,KAAK;YACL,QAAQ;YACR,MAAM,EAAE,UAAU;SACnB,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,MAAM,GAA8B;YACxC,SAAS,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE;YACxD,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE;SAChC,CAAC;QACF,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC;QACnB,IAAI,QAAQ,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;YACtC,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC;YAC/B,MAAM;QACR,CAAC;QACD,IAAI,QAAQ,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YACvC,MAAM,IAAI,oCAAoC,CAC5C,oCAAoC,SAAS,CAAC,IAAI,EAAE,EACpD,MAAM,CACP,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@openai/agents-core",
|
|
3
3
|
"repository": "https://github.com/openai/openai-agents-js",
|
|
4
4
|
"homepage": "https://openai.github.io/openai-agents-js/",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.8",
|
|
6
6
|
"description": "The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows.",
|
|
7
7
|
"author": "OpenAI <support@openai.com>",
|
|
8
8
|
"main": "dist/index.js",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
],
|
|
63
63
|
"license": "MIT",
|
|
64
64
|
"optionalDependencies": {
|
|
65
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
65
|
+
"@modelcontextprotocol/sdk": "^1.25.2"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"debug": "^4.4.0",
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"scripts": {
|
|
106
106
|
"prebuild": "tsx ../../scripts/embedMeta.ts",
|
|
107
107
|
"build": "tsc",
|
|
108
|
-
"build-check": "tsc --noEmit -p ./tsconfig.test.json"
|
|
108
|
+
"build-check": "tsc --noEmit -p ./tsconfig.test.json",
|
|
109
|
+
"dist:check": "tsc --noEmit -p ./tsconfig.dist-check.json"
|
|
109
110
|
}
|
|
110
111
|
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { Agent } from './agent';
|
|
2
|
-
import { Handoff } from './handoff';
|
|
3
|
-
import { RunItem, RunToolApprovalItem } from './items';
|
|
4
|
-
import { Logger } from './logger';
|
|
5
|
-
import { ModelResponse } from './model';
|
|
6
|
-
import { ComputerTool, FunctionTool, HostedMCPTool, ShellTool, ApplyPatchTool } from './tool';
|
|
7
|
-
import { AgentInputItem, UnknownContext } from './types';
|
|
8
|
-
import { Runner } from './run';
|
|
9
|
-
import { RunContext } from './runContext';
|
|
10
|
-
import { StreamedRunResult } from './result';
|
|
11
|
-
import { z } from 'zod';
|
|
12
|
-
import * as protocol from './types/protocol';
|
|
13
|
-
import { type Session, type SessionInputCallback } from './memory/session';
|
|
14
|
-
type ToolRunHandoff = {
|
|
15
|
-
toolCall: protocol.FunctionCallItem;
|
|
16
|
-
handoff: Handoff<any, any>;
|
|
17
|
-
};
|
|
18
|
-
type ToolRunFunction<TContext = UnknownContext> = {
|
|
19
|
-
toolCall: protocol.FunctionCallItem;
|
|
20
|
-
tool: FunctionTool<TContext>;
|
|
21
|
-
};
|
|
22
|
-
type ToolRunComputer = {
|
|
23
|
-
toolCall: protocol.ComputerUseCallItem;
|
|
24
|
-
computer: ComputerTool<any, any>;
|
|
25
|
-
};
|
|
26
|
-
type ToolRunShell = {
|
|
27
|
-
toolCall: protocol.ShellCallItem;
|
|
28
|
-
shell: ShellTool;
|
|
29
|
-
};
|
|
30
|
-
type ToolRunApplyPatch = {
|
|
31
|
-
toolCall: protocol.ApplyPatchCallItem;
|
|
32
|
-
applyPatch: ApplyPatchTool;
|
|
33
|
-
};
|
|
34
|
-
type ToolRunMCPApprovalRequest = {
|
|
35
|
-
requestItem: RunToolApprovalItem;
|
|
36
|
-
mcpTool: HostedMCPTool;
|
|
37
|
-
};
|
|
38
|
-
export type ProcessedResponse<TContext = UnknownContext> = {
|
|
39
|
-
newItems: RunItem[];
|
|
40
|
-
handoffs: ToolRunHandoff[];
|
|
41
|
-
functions: ToolRunFunction<TContext>[];
|
|
42
|
-
computerActions: ToolRunComputer[];
|
|
43
|
-
shellActions: ToolRunShell[];
|
|
44
|
-
applyPatchActions: ToolRunApplyPatch[];
|
|
45
|
-
mcpApprovalRequests: ToolRunMCPApprovalRequest[];
|
|
46
|
-
toolsUsed: string[];
|
|
47
|
-
hasToolsOrApprovalsToRun(): boolean;
|
|
48
|
-
};
|
|
49
|
-
export declare const nextStepSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
50
|
-
type: z.ZodLiteral<"next_step_handoff">;
|
|
51
|
-
newAgent: z.ZodAny;
|
|
52
|
-
}, "strip", z.ZodTypeAny, {
|
|
53
|
-
type: "next_step_handoff";
|
|
54
|
-
newAgent?: any;
|
|
55
|
-
}, {
|
|
56
|
-
type: "next_step_handoff";
|
|
57
|
-
newAgent?: any;
|
|
58
|
-
}>, z.ZodObject<{
|
|
59
|
-
type: z.ZodLiteral<"next_step_final_output">;
|
|
60
|
-
output: z.ZodString;
|
|
61
|
-
}, "strip", z.ZodTypeAny, {
|
|
62
|
-
type: "next_step_final_output";
|
|
63
|
-
output: string;
|
|
64
|
-
}, {
|
|
65
|
-
type: "next_step_final_output";
|
|
66
|
-
output: string;
|
|
67
|
-
}>, z.ZodObject<{
|
|
68
|
-
type: z.ZodLiteral<"next_step_run_again">;
|
|
69
|
-
}, "strip", z.ZodTypeAny, {
|
|
70
|
-
type: "next_step_run_again";
|
|
71
|
-
}, {
|
|
72
|
-
type: "next_step_run_again";
|
|
73
|
-
}>, z.ZodObject<{
|
|
74
|
-
type: z.ZodLiteral<"next_step_interruption">;
|
|
75
|
-
data: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
76
|
-
}, "strip", z.ZodTypeAny, {
|
|
77
|
-
type: "next_step_interruption";
|
|
78
|
-
data: Record<string, any>;
|
|
79
|
-
}, {
|
|
80
|
-
type: "next_step_interruption";
|
|
81
|
-
data: Record<string, any>;
|
|
82
|
-
}>]>;
|
|
83
|
-
export type NextStep = z.infer<typeof nextStepSchema>;
|
|
84
|
-
/**
|
|
85
|
-
* Internal convenience wrapper that groups the outcome of a single agent turn. It lets the caller
|
|
86
|
-
* update the RunState in one shot and decide which step to execute next.
|
|
87
|
-
*/
|
|
88
|
-
declare class SingleStepResult {
|
|
89
|
-
/**
|
|
90
|
-
* The input items (i.e., the items before run() was called). May be mutated by handoff input filters.
|
|
91
|
-
*/
|
|
92
|
-
originalInput: string | AgentInputItem[];
|
|
93
|
-
/**
|
|
94
|
-
* The model response for the current step
|
|
95
|
-
*/
|
|
96
|
-
modelResponse: ModelResponse;
|
|
97
|
-
/**
|
|
98
|
-
* The items before the current step was executed
|
|
99
|
-
*/
|
|
100
|
-
preStepItems: RunItem[];
|
|
101
|
-
/**
|
|
102
|
-
* The items after the current step was executed
|
|
103
|
-
*/
|
|
104
|
-
newStepItems: RunItem[];
|
|
105
|
-
/**
|
|
106
|
-
* The next step to execute
|
|
107
|
-
*/
|
|
108
|
-
nextStep: NextStep;
|
|
109
|
-
constructor(
|
|
110
|
-
/**
|
|
111
|
-
* The input items (i.e., the items before run() was called). May be mutated by handoff input filters.
|
|
112
|
-
*/
|
|
113
|
-
originalInput: string | AgentInputItem[],
|
|
114
|
-
/**
|
|
115
|
-
* The model response for the current step
|
|
116
|
-
*/
|
|
117
|
-
modelResponse: ModelResponse,
|
|
118
|
-
/**
|
|
119
|
-
* The items before the current step was executed
|
|
120
|
-
*/
|
|
121
|
-
preStepItems: RunItem[],
|
|
122
|
-
/**
|
|
123
|
-
* The items after the current step was executed
|
|
124
|
-
*/
|
|
125
|
-
newStepItems: RunItem[],
|
|
126
|
-
/**
|
|
127
|
-
* The next step to execute
|
|
128
|
-
*/
|
|
129
|
-
nextStep: NextStep);
|
|
130
|
-
/**
|
|
131
|
-
* The items generated during the agent run (i.e. everything generated after originalInput)
|
|
132
|
-
*/
|
|
133
|
-
get generatedItems(): RunItem[];
|
|
134
|
-
}
|
|
135
|
-
export declare function executeShellActions(agent: Agent<any, any>, actions: ToolRunShell[], runner: Runner, runContext: RunContext, customLogger?: Logger | undefined): Promise<RunItem[]>;
|
|
136
|
-
export declare function executeApplyPatchOperations(agent: Agent<any, any>, actions: ToolRunApplyPatch[], runner: Runner, runContext: RunContext, customLogger?: Logger | undefined): Promise<RunItem[]>;
|
|
137
|
-
export declare function streamStepItemsToRunResult(result: StreamedRunResult<any, any>, items: RunItem[]): void;
|
|
138
|
-
export declare function addStepToRunResult(result: StreamedRunResult<any, any>, step: SingleStepResult, options?: {
|
|
139
|
-
skipItems?: Set<RunItem>;
|
|
140
|
-
}): void;
|
|
141
|
-
export declare class AgentToolUseTracker {
|
|
142
|
-
#private;
|
|
143
|
-
addToolUse(agent: Agent<any, any>, toolNames: string[]): void;
|
|
144
|
-
hasUsedTools(agent: Agent<any, any>): boolean;
|
|
145
|
-
toJSON(): Record<string, string[]>;
|
|
146
|
-
}
|
|
147
|
-
export declare function prepareInputItemsWithSession(input: string | AgentInputItem[], session?: Session, sessionInputCallback?: SessionInputCallback, options?: {
|
|
148
|
-
/**
|
|
149
|
-
* When true (default), the returned `preparedInput` includes both the persisted session history
|
|
150
|
-
* and the new turn items. Set to false when upstream code already provides history to the model
|
|
151
|
-
* (e.g. server-managed conversations) to avoid sending duplicated messages each turn.
|
|
152
|
-
*/
|
|
153
|
-
includeHistoryInPreparedInput?: boolean;
|
|
154
|
-
/**
|
|
155
|
-
* When true, ensures new turn inputs are still provided to the model even if the session input
|
|
156
|
-
* callback drops them from persistence (used for server-managed conversations that redact
|
|
157
|
-
* writes).
|
|
158
|
-
*/
|
|
159
|
-
preserveDroppedNewItems?: boolean;
|
|
160
|
-
}): Promise<PreparedInputWithSessionResult>;
|
|
161
|
-
export {};
|