@agent-harness-experimental/adapter-openai-agents 0.0.0 → 0.0.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 ADDED
@@ -0,0 +1 @@
1
+ Copyright Vercel Inc. Pre-release. Not licensed as OSS yet.
package/README.md CHANGED
@@ -1,3 +1,140 @@
1
- # @agent-harness-experimental/adapter-openai-agents
1
+ # `@agent-harness-experimental/adapter-openai-agents`
2
2
 
3
- Placeholder package.
3
+ Adapter for running [OpenAI Agents JS](https://github.com/openai/openai-agents-js)
4
+ inside `agent-harness-experimental` with the OpenAI runner on the host and sandbox-backed
5
+ file and shell tools.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install agent-harness-experimental @agent-harness-experimental/adapter-openai-agents
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { createAgentSession } from "agent-harness-experimental";
17
+ import { openaiAgents } from "@agent-harness-experimental/adapter-openai-agents";
18
+
19
+ const agent = createAgentSession({
20
+ adapter: openaiAgents(),
21
+ });
22
+
23
+ const result = await agent.generate("Refactor the auth module to use JWT");
24
+ console.log(result.text);
25
+ await agent.close("stop");
26
+ ```
27
+
28
+ ## Configuration
29
+
30
+ ```ts
31
+ openaiAgents({
32
+ // OpenAI model ID
33
+ model: "gpt-5.4-mini",
34
+
35
+ // Maximum OpenAI Agents turns for one run
36
+ maxTurns: 10,
37
+
38
+ // OpenAI Agents SDK instructions appended by the adapter
39
+ instructions: "Prefer concise, targeted code changes.",
40
+
41
+ // Skill descriptors are exposed eagerly or through load_skill
42
+ skills: { loading: "lazy" },
43
+ });
44
+ ```
45
+
46
+ | Option | Type | Default | Description |
47
+ | --- | --- | --- | --- |
48
+ | `model` | `string` | OpenAI Agents SDK default | Model ID |
49
+ | `name` | `string` | `"Coding Agent"` | OpenAI Agents SDK agent name |
50
+ | `instructions` | `string` | — | Adapter-level instructions appended to the agent |
51
+ | `maxTurns` | `number` | — | Maximum SDK turns per run |
52
+ | `modelSettings` | `ModelSettings` | — | OpenAI Agents SDK model settings |
53
+ | `useResponses` | `boolean` | — | Passed to `OpenAIProvider` |
54
+ | `tracing` | `object` | — | OpenAI Agents SDK tracing controls |
55
+ | `skills.loading` | `'eager' \| 'lazy'` | `'eager'` | Whether skills are described up front or loaded through `load_skill` |
56
+ | `auth` | `object` | — | Optional per-adapter auth override (`gateway`, `openai`, or `openaiCompatible`) |
57
+
58
+ Sandbox runtime options such as `template`, `timeoutMs`, and `httpHandler`
59
+ belong on `createAgentSession({ sandbox })`.
60
+
61
+ ```ts
62
+ const agent = createAgentSession({
63
+ adapter: openaiAgents({ model: "gpt-5.4-mini" }),
64
+ sandbox: {
65
+ template: "snap_abc123",
66
+ timeoutMs: 60000,
67
+ httpHandler: async (request: Request) => fetch(request),
68
+ },
69
+ });
70
+ ```
71
+
72
+ ## Auth
73
+
74
+ `auth` is optional. If you omit it, OpenAI Agents uses ambient OpenAI
75
+ environment variables such as `OPENAI_API_KEY`, `OPENAI_BASE_URL`,
76
+ `OPENAI_ORGANIZATION`, and `OPENAI_PROJECT`.
77
+
78
+ ```ts
79
+ openaiAgents({
80
+ model: "gpt-5.4-mini",
81
+ auth: {
82
+ gateway: {
83
+ apiKey: { env: "AI_GATEWAY_API_KEY" },
84
+ baseURL: "https://ai-gateway.vercel.sh/v1",
85
+ },
86
+ },
87
+ });
88
+ ```
89
+
90
+ Use `auth.openaiCompatible` for OpenAI-compatible providers:
91
+
92
+ ```ts
93
+ openaiAgents({
94
+ model: "openai-compatible-model",
95
+ auth: {
96
+ openaiCompatible: {
97
+ name: "internal-openai-compatible",
98
+ apiKey: { env: "OPENAI_COMPATIBLE_API_KEY" },
99
+ baseURL: "https://models.example.invalid/v1",
100
+ },
101
+ },
102
+ });
103
+ ```
104
+
105
+ ## Built-in Tools
106
+
107
+ OpenAI Agents exposes standardized builtin names through `agent-harness-experimental`.
108
+
109
+ | Tool | Native Capability | Description |
110
+ | --- | --- | --- |
111
+ | `exec_command` | `shell()` | Execute a one-shot shell command in the sandbox |
112
+ | `apply_patch` | `filesystem()` patch tool | Create, update, move, or delete files |
113
+ | `view_image` | `filesystem()` image read | Return local sandbox image contents to the model |
114
+ | `load_skill` | `skills()` lazy loader | Materialize and load a lazily configured skill |
115
+
116
+ ## Features
117
+
118
+ - **Split runtime**: OpenAI Agents JS runs on the host while file and shell tools
119
+ operate inside the sandbox.
120
+ - **AI SDK tools**: User-defined AI SDK tools execute on the host and are
121
+ exposed to the OpenAI model as function tools.
122
+ - **Tool interception**: Built-in tools can be intercepted for approval via the
123
+ `permissions` option on `createAgentSession`.
124
+ - **Step-level `prepareStep`**: Tool visibility, instructions, and skill state
125
+ can change between internal OpenAI Agents model calls.
126
+ - **Skills**: Exposed through OpenAI Agents SDK `skills()` descriptors with
127
+ eager or lazy loading.
128
+ - **Subagents**: `createAgentSession({ agents })` is exposed through the canonical
129
+ host-side `delegate_task` tool with a shared split sandbox session.
130
+ - **Replay-friendly HTTP**: Sandbox-side HTTP traffic can be routed through the
131
+ test replay handler via `sandbox.httpHandler`.
132
+ - **Changed files**: `apply_patch` and shell-created file mutations are reported
133
+ through changed-file tracking.
134
+
135
+ ## Limitations
136
+
137
+ `exec_command` is one-shot shell execution. This adapter does not currently
138
+ expose PTY sessions or `write_stdin`, so workflows that need to feed input into
139
+ a long-running terminal process, REPL, watcher, or interactive prompt are not
140
+ fully portable to OpenAI Agents.
@@ -0,0 +1,31 @@
1
+ import type { AgentAdapter, GatewayAuthOptions, OpenAIAuthOptions, OpenAICompatibleAuthOptions } from 'agent-harness-experimental';
2
+ import { type ModelSettings } from '@openai/agents';
3
+ import { type OpenAIAgentsAdapterState } from './state.js';
4
+ export declare const OPENAI_AGENTS_BUILTIN_TOOLS: {
5
+ name: string;
6
+ inputSchema: import("agent-harness-experimental").JsonSchema;
7
+ nativeName?: string | undefined;
8
+ description?: string | undefined;
9
+ }[], OPENAI_AGENTS_PERMISSION_TOOL_CATEGORIES: import("agent-harness-experimental").PermissionToolCategories;
10
+ export interface OpenAIAgentsAdapterOptions {
11
+ model?: string;
12
+ name?: string;
13
+ instructions?: string;
14
+ maxTurns?: number;
15
+ modelSettings?: ModelSettings;
16
+ useResponses?: boolean;
17
+ tracing?: {
18
+ disabled?: boolean;
19
+ includeSensitiveData?: boolean;
20
+ };
21
+ skills?: {
22
+ loading?: 'eager' | 'lazy';
23
+ };
24
+ auth?: {
25
+ gateway?: GatewayAuthOptions;
26
+ openai?: OpenAIAuthOptions;
27
+ openaiCompatible?: OpenAICompatibleAuthOptions;
28
+ };
29
+ }
30
+ export declare function openaiAgents(options?: OpenAIAgentsAdapterOptions): AgentAdapter<OpenAIAgentsAdapterState>;
31
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAE5B,MAAM,4BAA4B,CAAC;AAepC,OAAO,EAA4F,KAAK,aAAa,EAAa,MAAM,gBAAgB,CAAC;AAOzJ,OAAO,EAAiE,KAAK,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAa1H,eAAO,MAAe,2BAA2B;;;;;KAA4B,wCAAwC,+DA4DnH,CAAC;AAEH,MAAM,WAAW,0BAA0B;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;KAChC,CAAC;IACF,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;KAC5B,CAAC;IACF,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,kBAAkB,CAAC;QAC7B,MAAM,CAAC,EAAE,iBAAiB,CAAC;QAC3B,gBAAgB,CAAC,EAAE,2BAA2B,CAAC;KAChD,CAAC;CACH;AAukBD,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,YAAY,CAAC,wBAAwB,CAAC,CAuMzG"}