@agentplat/provider-openai 0.2.0-beta.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/LICENSE +202 -0
- package/README.md +34 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +267 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# `@agentplat/provider-openai`
|
|
2
|
+
|
|
3
|
+
OpenAI Agents SDK adapter for `@agentplat/runtime`.
|
|
4
|
+
|
|
5
|
+
The adapter creates an isolated SDK runner for every execution. Supply credentials
|
|
6
|
+
through `RuntimeExecutionContext.credentials` or an `apiKeyResolver`; it does not
|
|
7
|
+
mutate the process-wide OpenAI configuration.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { OpenAIAgentProvider } from '@agentplat/provider-openai';
|
|
11
|
+
import { DefaultAgentRuntime } from '@agentplat/runtime';
|
|
12
|
+
|
|
13
|
+
const runtime = new DefaultAgentRuntime();
|
|
14
|
+
runtime.registerProvider('openai', new OpenAIAgentProvider());
|
|
15
|
+
|
|
16
|
+
const result = await runtime.run(
|
|
17
|
+
{
|
|
18
|
+
id: 'agent-1',
|
|
19
|
+
tenantId: 'tenant-1',
|
|
20
|
+
name: 'Support agent',
|
|
21
|
+
platform: 'openai',
|
|
22
|
+
modelName: 'gpt-5.4-mini',
|
|
23
|
+
instructions: 'Answer concisely.',
|
|
24
|
+
},
|
|
25
|
+
{ input: 'Hello' },
|
|
26
|
+
{
|
|
27
|
+
agentId: 'agent-1',
|
|
28
|
+
tenant: { tenantId: 'tenant-1' },
|
|
29
|
+
credentials: { openaiApiKey: process.env.OPENAI_API_KEY! },
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Never store API keys in agent definitions or metadata.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Agent } from '@openai/agents';
|
|
2
|
+
import type { AgentDefinition, AgentProvider, AgentRunInput, AgentRunResult, AgentStreamEvent, RuntimeExecutionContext } from '@agentplat/runtime';
|
|
3
|
+
export type OpenAIApiKeyResolver = (context: RuntimeExecutionContext) => Promise<string | undefined> | string | undefined;
|
|
4
|
+
export interface OpenAIAgentProviderOptions {
|
|
5
|
+
/** Static key for single-tenant services. Prefer apiKeyResolver for multi-tenant runtimes. */
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
apiKeyResolver?: OpenAIApiKeyResolver;
|
|
8
|
+
baseURL?: string;
|
|
9
|
+
organization?: string;
|
|
10
|
+
project?: string;
|
|
11
|
+
useResponses?: boolean;
|
|
12
|
+
useResponsesWebSocket?: boolean;
|
|
13
|
+
defaultModel?: string;
|
|
14
|
+
/** Tracing is disabled by default so tenant credentials and data never use global tracing state. */
|
|
15
|
+
tracingDisabled?: boolean;
|
|
16
|
+
traceIncludeSensitiveData?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface OpenAIFileCitation {
|
|
19
|
+
fileId: string;
|
|
20
|
+
filename?: string;
|
|
21
|
+
quote?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface OpenAIAgentBuildResult {
|
|
24
|
+
agent: Agent;
|
|
25
|
+
model: string | undefined;
|
|
26
|
+
}
|
|
27
|
+
export declare class OpenAIAgentProvider implements AgentProvider {
|
|
28
|
+
private readonly options;
|
|
29
|
+
constructor(options?: OpenAIAgentProviderOptions);
|
|
30
|
+
run(definition: AgentDefinition, input: AgentRunInput, context: RuntimeExecutionContext): Promise<AgentRunResult>;
|
|
31
|
+
stream(definition: AgentDefinition, input: AgentRunInput, context: RuntimeExecutionContext): AsyncIterable<AgentStreamEvent>;
|
|
32
|
+
private resolveApiKey;
|
|
33
|
+
private createModelProvider;
|
|
34
|
+
private createRunner;
|
|
35
|
+
}
|
|
36
|
+
export declare function createOpenAIAgent(definition: AgentDefinition, options?: Pick<OpenAIAgentProviderOptions, 'defaultModel'>): OpenAIAgentBuildResult;
|
|
37
|
+
export declare function extractOpenAIFileCitations(value: unknown): OpenAIFileCitation[];
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA0C,MAAM,gBAAgB,CAAC;AAS/E,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,oBAAoB,GAAG,CACjC,OAAO,EAAE,uBAAuB,KAC7B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,GAAG,SAAS,CAAC;AAEtD,MAAM,WAAW,0BAA0B;IACzC,8FAA8F;IAC9F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oGAAoG;IACpG,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAgBD,qBAAa,mBAAoB,YAAW,aAAa;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,GAAE,0BAA+B;IAE/D,GAAG,CACP,UAAU,EAAE,eAAe,EAC3B,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,cAAc,CAAC;IAsCnB,MAAM,CACX,UAAU,EAAE,eAAe,EAC3B,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,uBAAuB,GAC/B,aAAa,CAAC,gBAAgB,CAAC;YA8CpB,aAAa;IAmB3B,OAAO,CAAC,mBAAmB;IAY3B,OAAO,CAAC,YAAY;CAYrB;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,eAAe,EAC3B,OAAO,GAAE,IAAI,CAAC,0BAA0B,EAAE,cAAc,CAAM,GAC7D,sBAAsB,CAkBxB;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,GACb,kBAAkB,EAAE,CAuCtB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { Agent, OpenAIProvider, Runner, fileSearchTool } from '@openai/agents';
|
|
2
|
+
import { AgentPlatError } from '@agentplat/core';
|
|
3
|
+
const DEFAULT_INSTRUCTIONS = 'You are a helpful assistant.';
|
|
4
|
+
export class OpenAIAgentProvider {
|
|
5
|
+
options;
|
|
6
|
+
constructor(options = {}) {
|
|
7
|
+
this.options = options;
|
|
8
|
+
}
|
|
9
|
+
async run(definition, input, context) {
|
|
10
|
+
const apiKey = await this.resolveApiKey(context);
|
|
11
|
+
const modelProvider = this.createModelProvider(apiKey);
|
|
12
|
+
const { agent, model } = createOpenAIAgent(definition, {
|
|
13
|
+
defaultModel: this.options.defaultModel,
|
|
14
|
+
});
|
|
15
|
+
const runner = this.createRunner(modelProvider, definition.name);
|
|
16
|
+
try {
|
|
17
|
+
const result = await runner.run(agent, toAgentInput(input.input), buildRunOptions(input, context));
|
|
18
|
+
const citations = extractOpenAIFileCitations(result.rawResponses);
|
|
19
|
+
const responseDetails = {};
|
|
20
|
+
if (result.lastResponseId) {
|
|
21
|
+
responseDetails.lastResponseId = result.lastResponseId;
|
|
22
|
+
}
|
|
23
|
+
if (citations.length > 0) {
|
|
24
|
+
responseDetails.citations = citations.map(toCitationJson);
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
runId: context.runId,
|
|
28
|
+
conversationId: input.conversationId,
|
|
29
|
+
status: 'completed',
|
|
30
|
+
output: stringifyOutput(result.finalOutput),
|
|
31
|
+
result: responseDetails,
|
|
32
|
+
metadata: compactMetadata({ provider: 'openai', model }),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw toAdapterError(error);
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
await modelProvider.close();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async *stream(definition, input, context) {
|
|
43
|
+
yield { type: 'started', runId: context.runId };
|
|
44
|
+
let modelProvider;
|
|
45
|
+
try {
|
|
46
|
+
const apiKey = await this.resolveApiKey(context);
|
|
47
|
+
modelProvider = this.createModelProvider(apiKey);
|
|
48
|
+
const { agent } = createOpenAIAgent(definition, {
|
|
49
|
+
defaultModel: this.options.defaultModel,
|
|
50
|
+
});
|
|
51
|
+
const runner = this.createRunner(modelProvider, definition.name);
|
|
52
|
+
const result = await runner.run(agent, toAgentInput(input.input), {
|
|
53
|
+
...buildRunOptions(input, context),
|
|
54
|
+
stream: true,
|
|
55
|
+
});
|
|
56
|
+
for await (const token of result.toTextStream()) {
|
|
57
|
+
yield { type: 'token', runId: context.runId, content: token };
|
|
58
|
+
}
|
|
59
|
+
await result.completed;
|
|
60
|
+
const citations = extractOpenAIFileCitations(result.rawResponses);
|
|
61
|
+
const payload = {};
|
|
62
|
+
if (result.lastResponseId)
|
|
63
|
+
payload.lastResponseId = result.lastResponseId;
|
|
64
|
+
if (citations.length > 0) {
|
|
65
|
+
payload.citations = citations.map(toCitationJson);
|
|
66
|
+
}
|
|
67
|
+
yield {
|
|
68
|
+
type: 'completed',
|
|
69
|
+
runId: context.runId,
|
|
70
|
+
content: stringifyOutput(result.finalOutput),
|
|
71
|
+
payload,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
const adapterError = toAdapterError(error);
|
|
76
|
+
yield {
|
|
77
|
+
type: 'failed',
|
|
78
|
+
runId: context.runId,
|
|
79
|
+
content: adapterError.message,
|
|
80
|
+
};
|
|
81
|
+
throw adapterError;
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
await modelProvider?.close();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async resolveApiKey(context) {
|
|
88
|
+
const resolved = (await this.options.apiKeyResolver?.(context)) ??
|
|
89
|
+
context.credentials?.openaiApiKey ??
|
|
90
|
+
context.credentials?.apiKey ??
|
|
91
|
+
this.options.apiKey;
|
|
92
|
+
if (!resolved?.trim()) {
|
|
93
|
+
throw new AgentPlatError('UNAUTHORIZED', 'An OpenAI API key is required for this execution', { statusCode: 401 });
|
|
94
|
+
}
|
|
95
|
+
return resolved;
|
|
96
|
+
}
|
|
97
|
+
createModelProvider(apiKey) {
|
|
98
|
+
const providerOptions = {
|
|
99
|
+
apiKey,
|
|
100
|
+
baseURL: this.options.baseURL,
|
|
101
|
+
organization: this.options.organization,
|
|
102
|
+
project: this.options.project,
|
|
103
|
+
useResponses: this.options.useResponses,
|
|
104
|
+
useResponsesWebSocket: this.options.useResponsesWebSocket,
|
|
105
|
+
};
|
|
106
|
+
return new OpenAIProvider(providerOptions);
|
|
107
|
+
}
|
|
108
|
+
createRunner(modelProvider, workflowName) {
|
|
109
|
+
return new Runner({
|
|
110
|
+
modelProvider,
|
|
111
|
+
workflowName,
|
|
112
|
+
tracingDisabled: this.options.tracingDisabled ?? true,
|
|
113
|
+
traceIncludeSensitiveData: this.options.traceIncludeSensitiveData ?? false,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export function createOpenAIAgent(definition, options = {}) {
|
|
118
|
+
const model = resolveModel(definition, options.defaultModel);
|
|
119
|
+
const modelSettings = resolveModelSettings(definition);
|
|
120
|
+
const tools = resolveFileSearchTools(definition);
|
|
121
|
+
return {
|
|
122
|
+
model,
|
|
123
|
+
agent: new Agent({
|
|
124
|
+
name: definition.name || 'AgentPlat Agent',
|
|
125
|
+
instructions: definition.instructions || DEFAULT_INSTRUCTIONS,
|
|
126
|
+
...(definition.description
|
|
127
|
+
? { handoffDescription: definition.description }
|
|
128
|
+
: {}),
|
|
129
|
+
...(model ? { model } : {}),
|
|
130
|
+
...(Object.keys(modelSettings).length > 0 ? { modelSettings } : {}),
|
|
131
|
+
...(tools.length > 0 ? { tools } : {}),
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export function extractOpenAIFileCitations(value) {
|
|
136
|
+
const citations = new Map();
|
|
137
|
+
const seen = new Set();
|
|
138
|
+
const visit = (candidate) => {
|
|
139
|
+
if (!candidate || typeof candidate !== 'object' || seen.has(candidate)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
seen.add(candidate);
|
|
143
|
+
if (Array.isArray(candidate)) {
|
|
144
|
+
for (const item of candidate)
|
|
145
|
+
visit(item);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const object = candidate;
|
|
149
|
+
if (object.type === 'file_citation') {
|
|
150
|
+
const nested = asRecord(object.file_citation);
|
|
151
|
+
const fileId = firstString(object.fileId, object.file_id, nested?.fileId, nested?.file_id);
|
|
152
|
+
if (fileId) {
|
|
153
|
+
const citation = compactCitation({
|
|
154
|
+
fileId,
|
|
155
|
+
filename: firstString(object.filename, nested?.filename),
|
|
156
|
+
quote: firstString(object.quote, object.text, nested?.quote),
|
|
157
|
+
});
|
|
158
|
+
citations.set(JSON.stringify(citation), citation);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
for (const nestedValue of Object.values(object))
|
|
162
|
+
visit(nestedValue);
|
|
163
|
+
};
|
|
164
|
+
visit(value);
|
|
165
|
+
return [...citations.values()];
|
|
166
|
+
}
|
|
167
|
+
function buildRunOptions(input, context) {
|
|
168
|
+
return {
|
|
169
|
+
context: {
|
|
170
|
+
tenantId: context.tenant.tenantId,
|
|
171
|
+
organizationId: context.tenant.organizationId,
|
|
172
|
+
workspaceId: context.tenant.workspaceId,
|
|
173
|
+
agentId: context.agentId,
|
|
174
|
+
runId: context.runId,
|
|
175
|
+
mode: input.mode ?? 'invoke',
|
|
176
|
+
policies: context.policies,
|
|
177
|
+
metadata: context.metadata,
|
|
178
|
+
inputMetadata: input.metadata,
|
|
179
|
+
},
|
|
180
|
+
...(context.signal ? { signal: context.signal } : {}),
|
|
181
|
+
...(input.conversationId ? { conversationId: input.conversationId } : {}),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function resolveModel(definition, defaultModel) {
|
|
185
|
+
const provider = asRecord(definition.metadata?.provider);
|
|
186
|
+
return firstString(definition.modelName, provider?.model, defaultModel);
|
|
187
|
+
}
|
|
188
|
+
function resolveModelSettings(definition) {
|
|
189
|
+
const configured = asRecord(definition.config?.modelSettings);
|
|
190
|
+
const provider = asRecord(definition.metadata?.provider);
|
|
191
|
+
const legacyGeneration = asRecord(provider?.generation);
|
|
192
|
+
return compactObject({
|
|
193
|
+
temperature: firstNumber(configured?.temperature, legacyGeneration?.temperature),
|
|
194
|
+
topP: firstNumber(configured?.topP, configured?.top_p, legacyGeneration?.topP, legacyGeneration?.top_p),
|
|
195
|
+
frequencyPenalty: firstNumber(configured?.frequencyPenalty, configured?.frequency_penalty),
|
|
196
|
+
presencePenalty: firstNumber(configured?.presencePenalty, configured?.presence_penalty),
|
|
197
|
+
maxTokens: firstNumber(configured?.maxTokens, configured?.max_output_tokens, legacyGeneration?.maxTokens, legacyGeneration?.max_output_tokens),
|
|
198
|
+
store: firstBoolean(configured?.store),
|
|
199
|
+
parallelToolCalls: firstBoolean(configured?.parallelToolCalls, configured?.parallel_tool_calls),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
function resolveFileSearchTools(definition) {
|
|
203
|
+
const openAI = asRecord(definition.capabilities?.openai);
|
|
204
|
+
const configured = asRecord(openAI?.fileSearch);
|
|
205
|
+
const configuredIds = stringArray(configured?.vectorStoreIds);
|
|
206
|
+
const metadataKnowledge = asRecord(definition.metadata?.knowledge);
|
|
207
|
+
const legacyId = firstString(metadataKnowledge?.vectorStoreId);
|
|
208
|
+
const vectorStoreIds = configuredIds.length > 0 ? configuredIds : legacyId ? [legacyId] : [];
|
|
209
|
+
const enabled = firstBoolean(configured?.enabled, metadataKnowledge?.enabled);
|
|
210
|
+
if (enabled === false || vectorStoreIds.length === 0)
|
|
211
|
+
return [];
|
|
212
|
+
const retrieval = asRecord(metadataKnowledge?.retrieval);
|
|
213
|
+
const maxNumResults = firstNumber(configured?.maxNumResults, configured?.max_num_results, retrieval?.maxNumResults, retrieval?.max_num_results);
|
|
214
|
+
return [
|
|
215
|
+
fileSearchTool(vectorStoreIds, maxNumResults === undefined ? {} : { maxNumResults }),
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
function toAgentInput(input) {
|
|
219
|
+
return input;
|
|
220
|
+
}
|
|
221
|
+
function stringifyOutput(output) {
|
|
222
|
+
if (typeof output === 'string')
|
|
223
|
+
return output;
|
|
224
|
+
if (output === undefined)
|
|
225
|
+
return '';
|
|
226
|
+
return JSON.stringify(output);
|
|
227
|
+
}
|
|
228
|
+
function toAdapterError(error) {
|
|
229
|
+
if (error instanceof AgentPlatError)
|
|
230
|
+
return error;
|
|
231
|
+
const message = error instanceof Error ? error.message : 'Unknown OpenAI error';
|
|
232
|
+
return new AgentPlatError('ADAPTER_ERROR', `OpenAI agent run failed: ${message}`, {
|
|
233
|
+
details: { provider: 'openai' },
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function asRecord(value) {
|
|
237
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
238
|
+
? value
|
|
239
|
+
: undefined;
|
|
240
|
+
}
|
|
241
|
+
function firstString(...values) {
|
|
242
|
+
return values.find((value) => typeof value === 'string' && value.length > 0);
|
|
243
|
+
}
|
|
244
|
+
function firstNumber(...values) {
|
|
245
|
+
return values.find((value) => typeof value === 'number' && Number.isFinite(value));
|
|
246
|
+
}
|
|
247
|
+
function firstBoolean(...values) {
|
|
248
|
+
return values.find((value) => typeof value === 'boolean');
|
|
249
|
+
}
|
|
250
|
+
function stringArray(value) {
|
|
251
|
+
return Array.isArray(value)
|
|
252
|
+
? value.filter((item) => typeof item === 'string' && item.length > 0)
|
|
253
|
+
: [];
|
|
254
|
+
}
|
|
255
|
+
function compactObject(object) {
|
|
256
|
+
return Object.fromEntries(Object.entries(object).filter(([, value]) => value !== undefined));
|
|
257
|
+
}
|
|
258
|
+
function compactMetadata(metadata) {
|
|
259
|
+
return compactObject(metadata);
|
|
260
|
+
}
|
|
261
|
+
function compactCitation(citation) {
|
|
262
|
+
return compactObject(citation);
|
|
263
|
+
}
|
|
264
|
+
function toCitationJson(citation) {
|
|
265
|
+
return citation;
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,MAA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AAE,CACzB,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CACtD,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,GAAG,MAAiB;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAoB,EAAE,CAAC,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzB,CAAC,CAAC,KAAK,CAAC,MAAM,CACV,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CACtE;QACH,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED,SAAS,aAAa,CAAmB,MAAS;IAChD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAC7D,CAAC;AACT,CAAC;AAED,SAAS,eAAe,CACtB,QAA4C;IAE5C,OAAO,aAAa,CAAC,QAAQ,CAAa,CAAC;AAC7C,CAAC;AAED,SAAS,eAAe,CAAC,QAA4B;IACnD,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,cAAc,CAAC,QAA4B;IAClD,OAAO,QAAiC,CAAC;AAC3C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentplat/provider-openai",
|
|
3
|
+
"version": "0.2.0-beta.1",
|
|
4
|
+
"description": "OpenAI Agents SDK provider for the AgentPlat runtime.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@openai/agents": "^0.13.3",
|
|
22
|
+
"zod": "^4.0.0",
|
|
23
|
+
"@agentplat/core": "^0.2.0-beta.1",
|
|
24
|
+
"@agentplat/runtime": "^0.2.0-beta.1"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/Agentplat/agentplat.git",
|
|
32
|
+
"directory": "packages/provider-openai"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.json",
|
|
36
|
+
"type-check": "tsc -p tsconfig.json --noEmit",
|
|
37
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
|
|
38
|
+
}
|
|
39
|
+
}
|