@harapter/adapter-codex 0.1.1 → 0.1.2
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/README.ja.md +115 -0
- package/README.md +46 -11
- package/README.zh-CN.md +109 -0
- package/package.json +8 -6
package/README.ja.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/adapter-codex</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>stable Codex App Server を Harapter の可搬ライフサイクルで実行します。</strong></p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="./README.md">English</a> · <a href="./README.zh-CN.md">简体中文</a> · <a href="./README.ja.md">日本語</a> · <a href="../../README.ja.md">Harapter</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-codex"><img src="https://img.shields.io/npm/v/%40harapter%2Fadapter-codex/next?style=flat-square&label=npm%20next" alt="npm next バージョン"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-codex"><img src="https://img.shields.io/npm/dm/%40harapter%2Fadapter-codex?style=flat-square" alt="npm ダウンロード数"></a>
|
|
14
|
+
<a href="https://github.com/yunfeizhu/harapter/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/yunfeizhu/harapter/ci.yml?branch=main&style=flat-square&label=ci" alt="CI ステータス"></a>
|
|
15
|
+
<img src="https://img.shields.io/badge/node-%3E%3D24-339933?style=flat-square&logo=nodedotjs&logoColor=white" alt="Node.js 24 以上">
|
|
16
|
+
<a href="../../LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-0B7285?style=flat-square" alt="Apache-2.0 ライセンス"></a>
|
|
17
|
+
<img src="https://img.shields.io/badge/status-pre--alpha-EA580C?style=flat-square" alt="Pre-alpha ステータス">
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<!-- markdownlint-enable MD033 -->
|
|
21
|
+
|
|
22
|
+
`@harapter/adapter-codex` は公式 stable App
|
|
23
|
+
Server に接続し、Thread、Turn、stream Event、Interaction、終端、native
|
|
24
|
+
interrupt を Harapter API に mapping します。人向け CLI
|
|
25
|
+
output の scraping は行いません。
|
|
26
|
+
|
|
27
|
+
## 前提条件
|
|
28
|
+
|
|
29
|
+
Codex の導入と認証はホストが行います。Adapter は Binary を含まず、credential や
|
|
30
|
+
`SecretRef` を読み取らず、Sandbox と Approval Policy を勝手に選びません。
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm add @harapter/core@next @harapter/adapter-codex@next
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## クイックスタート
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { HarnessRegistry, profileId } from '@harapter/core';
|
|
40
|
+
import {
|
|
41
|
+
CODEX_PROVIDER_ID,
|
|
42
|
+
createCodexProviderFactory,
|
|
43
|
+
} from '@harapter/adapter-codex';
|
|
44
|
+
|
|
45
|
+
const registry = new HarnessRegistry();
|
|
46
|
+
registry.register(createCodexProviderFactory());
|
|
47
|
+
|
|
48
|
+
const client = await registry.connect({
|
|
49
|
+
profileId: profileId('codex-local'),
|
|
50
|
+
providerId: CODEX_PROVIDER_ID,
|
|
51
|
+
displayName: 'Local Codex',
|
|
52
|
+
connection: {
|
|
53
|
+
kind: 'process',
|
|
54
|
+
command: 'codex',
|
|
55
|
+
args: ['app-server', '--stdio'],
|
|
56
|
+
ownership: 'adapter',
|
|
57
|
+
},
|
|
58
|
+
requiredCapabilities: [{ name: 'input.text' }, { name: 'run.stream' }],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const session = await client.createSession({
|
|
62
|
+
providerOptions: {
|
|
63
|
+
approvalPolicy: 'never',
|
|
64
|
+
sandbox: 'read-only',
|
|
65
|
+
ephemeral: true,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
const run = await session.start({
|
|
71
|
+
parts: [{ type: 'text', text: 'Describe the current project.' }],
|
|
72
|
+
});
|
|
73
|
+
for await (const event of run.events()) console.log(event.type);
|
|
74
|
+
console.log((await run.result()).status);
|
|
75
|
+
} finally {
|
|
76
|
+
try {
|
|
77
|
+
await session.close();
|
|
78
|
+
} finally {
|
|
79
|
+
await client.close();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Mapping と利用例
|
|
85
|
+
|
|
86
|
+
- Codex Thread が Session、Turn が Run で、一つの Thread に active
|
|
87
|
+
Turn は一つです;
|
|
88
|
+
- text と Image Reference は portable、任意 File Reference は unsupported です;
|
|
89
|
+
- stable Command/File Change Request は Approval
|
|
90
|
+
Interaction に mapping されます;
|
|
91
|
+
- `session.ref()` は同じ Provider、Profile、互換 App
|
|
92
|
+
Server だけに resume できます;
|
|
93
|
+
- `run.cancel()` は `turn/interrupt` 後の authoritative `interrupted`
|
|
94
|
+
でだけ native cancellation です;
|
|
95
|
+
- `CodexNativeClient` は明示的 Provider 機能を提供しますが portable
|
|
96
|
+
guarantee は持ちません。
|
|
97
|
+
|
|
98
|
+
`turn/completed`
|
|
99
|
+
だけが終端 authority です。未知・不正な terminal は success にならず、process
|
|
100
|
+
exit、EOF、Client Close、未確認 interrupt は `connection_aborted` になります。
|
|
101
|
+
|
|
102
|
+
## 設定と安全性
|
|
103
|
+
|
|
104
|
+
Profile は Adapter-owned `process`
|
|
105
|
+
connection のみです。message、queue、request、cancel settlement、Run
|
|
106
|
+
Event の上限を設定でき、未知 option は拒否します。Event
|
|
107
|
+
consumer が止まり queue が満杯になると、drop せず connection を abort します。
|
|
108
|
+
|
|
109
|
+
Error は Provider Message、Prompt、file content、credential、environment、local
|
|
110
|
+
path を含みません。未知 notification は bounded redacted raw
|
|
111
|
+
channel に残ります。
|
|
112
|
+
|
|
113
|
+
stable App Server には Fixture、mapping test、shared conformance、live Runtime
|
|
114
|
+
Evidence があります。正確な compatibility、options、live test、制限は
|
|
115
|
+
[英語の詳細ドキュメント](./README.md)を参照してください。
|
package/README.md
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/adapter-codex</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>Run the stable Codex App Server through Harapter's portable lifecycle.</strong></p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="./README.md">English</a> · <a href="./README.zh-CN.md">简体中文</a> · <a href="./README.ja.md">日本語</a> · <a href="../../README.md">Harapter</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-codex"><img src="https://img.shields.io/npm/v/%40harapter%2Fadapter-codex/next?style=flat-square&label=npm%20next" alt="npm next version"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-codex"><img src="https://img.shields.io/npm/dm/%40harapter%2Fadapter-codex?style=flat-square" alt="npm downloads"></a>
|
|
14
|
+
<a href="https://github.com/yunfeizhu/harapter/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/yunfeizhu/harapter/ci.yml?branch=main&style=flat-square&label=ci" alt="CI status"></a>
|
|
15
|
+
<img src="https://img.shields.io/badge/node-%3E%3D24-339933?style=flat-square&logo=nodedotjs&logoColor=white" alt="Node.js 24 or newer">
|
|
16
|
+
<a href="../../LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-0B7285?style=flat-square" alt="Apache-2.0 license"></a>
|
|
17
|
+
<img src="https://img.shields.io/badge/status-pre--alpha-EA580C?style=flat-square" alt="Pre-alpha status">
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<!-- markdownlint-enable MD033 -->
|
|
2
21
|
|
|
3
22
|
`@harapter/adapter-codex` exposes the official Codex harness through the stable
|
|
4
23
|
[Codex App Server](https://developers.openai.com/codex/app-server) interface and
|
|
@@ -6,6 +25,15 @@ maps it to the portable Harapter lifecycle. The harness and App Server source
|
|
|
6
25
|
live in the open-source
|
|
7
26
|
[OpenAI Codex repository](https://github.com/openai/codex).
|
|
8
27
|
|
|
28
|
+
## Use this Adapter when
|
|
29
|
+
|
|
30
|
+
- a host application needs Codex alongside other harnesses behind the same
|
|
31
|
+
portable lifecycle;
|
|
32
|
+
- you need stable App Server Sessions, streamed Turns, approvals, resume, and
|
|
33
|
+
native interruption without scraping CLI text; or
|
|
34
|
+
- you want Codex-specific behavior available through typed extensions while
|
|
35
|
+
keeping application orchestration Provider-agnostic.
|
|
36
|
+
|
|
9
37
|
## Installation
|
|
10
38
|
|
|
11
39
|
```bash
|
|
@@ -66,17 +94,24 @@ const client = await registry.connect({
|
|
|
66
94
|
});
|
|
67
95
|
|
|
68
96
|
const session = await client.createSession();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
97
|
+
try {
|
|
98
|
+
const run = await session.start({
|
|
99
|
+
parts: [{ type: 'text', text: 'Describe the current project.' }],
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
for await (const event of run.events()) {
|
|
103
|
+
// Render or persist according to the host's data policy.
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const result = await run.result();
|
|
107
|
+
console.log(result.status);
|
|
108
|
+
} finally {
|
|
109
|
+
try {
|
|
110
|
+
await session.close();
|
|
111
|
+
} finally {
|
|
112
|
+
await client.close();
|
|
113
|
+
}
|
|
75
114
|
}
|
|
76
|
-
|
|
77
|
-
const result = await run.result();
|
|
78
|
-
await session.close();
|
|
79
|
-
await client.close();
|
|
80
115
|
```
|
|
81
116
|
|
|
82
117
|
## Profile and process ownership
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
<h1 align="center"><code>@harapter/adapter-codex</code></h1>
|
|
4
|
+
|
|
5
|
+
<p align="center"><strong>通过 Harapter 可移植生命周期运行稳定版 Codex App Server。</strong></p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="./README.md">English</a> · <a href="./README.zh-CN.md">简体中文</a> · <a href="./README.ja.md">日本語</a> · <a href="../../README.zh-CN.md">Harapter</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-codex"><img src="https://img.shields.io/npm/v/%40harapter%2Fadapter-codex/next?style=flat-square&label=npm%20next" alt="npm next 版本"></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@harapter/adapter-codex"><img src="https://img.shields.io/npm/dm/%40harapter%2Fadapter-codex?style=flat-square" alt="npm 下载量"></a>
|
|
14
|
+
<a href="https://github.com/yunfeizhu/harapter/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/yunfeizhu/harapter/ci.yml?branch=main&style=flat-square&label=ci" alt="CI 状态"></a>
|
|
15
|
+
<img src="https://img.shields.io/badge/node-%3E%3D24-339933?style=flat-square&logo=nodedotjs&logoColor=white" alt="Node.js 24 或更高版本">
|
|
16
|
+
<a href="../../LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-0B7285?style=flat-square" alt="Apache-2.0 许可证"></a>
|
|
17
|
+
<img src="https://img.shields.io/badge/status-pre--alpha-EA580C?style=flat-square" alt="Pre-alpha 状态">
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<!-- markdownlint-enable MD033 -->
|
|
21
|
+
|
|
22
|
+
`@harapter/adapter-codex` 连接 Codex 官方稳定 App
|
|
23
|
+
Server,把 Thread、Turn、流式 Event、Interaction、终态和原生中断映射为 Harapter
|
|
24
|
+
API。它使用公开机器接口,不解析面向人的 CLI 文本。
|
|
25
|
+
|
|
26
|
+
## 前置条件
|
|
27
|
+
|
|
28
|
+
宿主负责安装并认证 Codex。Adapter 不包含 Codex Binary、不读取凭据、不解析
|
|
29
|
+
`SecretRef`,也不替宿主选择 Sandbox 或 Approval Policy。
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm add @harapter/core@next @harapter/adapter-codex@next
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 快速开始
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { HarnessRegistry, profileId } from '@harapter/core';
|
|
39
|
+
import {
|
|
40
|
+
CODEX_PROVIDER_ID,
|
|
41
|
+
createCodexProviderFactory,
|
|
42
|
+
} from '@harapter/adapter-codex';
|
|
43
|
+
|
|
44
|
+
const registry = new HarnessRegistry();
|
|
45
|
+
registry.register(createCodexProviderFactory());
|
|
46
|
+
|
|
47
|
+
const client = await registry.connect({
|
|
48
|
+
profileId: profileId('codex-local'),
|
|
49
|
+
providerId: CODEX_PROVIDER_ID,
|
|
50
|
+
displayName: 'Local Codex',
|
|
51
|
+
connection: {
|
|
52
|
+
kind: 'process',
|
|
53
|
+
command: 'codex',
|
|
54
|
+
args: ['app-server', '--stdio'],
|
|
55
|
+
ownership: 'adapter',
|
|
56
|
+
},
|
|
57
|
+
requiredCapabilities: [{ name: 'input.text' }, { name: 'run.stream' }],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const session = await client.createSession({
|
|
61
|
+
providerOptions: {
|
|
62
|
+
approvalPolicy: 'never',
|
|
63
|
+
sandbox: 'read-only',
|
|
64
|
+
ephemeral: true,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const run = await session.start({
|
|
70
|
+
parts: [{ type: 'text', text: 'Describe the current project.' }],
|
|
71
|
+
});
|
|
72
|
+
for await (const event of run.events()) console.log(event.type);
|
|
73
|
+
console.log((await run.result()).status);
|
|
74
|
+
} finally {
|
|
75
|
+
try {
|
|
76
|
+
await session.close();
|
|
77
|
+
} finally {
|
|
78
|
+
await client.close();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## 映射与常见用法
|
|
84
|
+
|
|
85
|
+
- Codex Thread 对应 Session,Turn 对应 Run;同一 Thread 同时只能有一个 Turn;
|
|
86
|
+
- 文本和 Image Reference 是可移植输入,任意 File Reference 不受支持;
|
|
87
|
+
- 稳定的 Command 与 File Change Request 映射为 Approval Interaction;
|
|
88
|
+
- `session.ref()` 只可恢复到相同 Provider、Profile 和兼容 App Server;
|
|
89
|
+
- `run.cancel()` 只有在 `turn/interrupt` 后收到权威 `interrupted`
|
|
90
|
+
终态时才算原生取消;
|
|
91
|
+
- `CodexNativeClient` 可访问显式 Provider 能力,但不获得可移植生命周期保证。
|
|
92
|
+
|
|
93
|
+
`turn/completed`
|
|
94
|
+
是唯一权威终态。未知或畸形终态不会被猜为成功;进程退出、EOF、Client
|
|
95
|
+
Close 或未确认的 Interrupt 会得到 `connection_aborted`。
|
|
96
|
+
|
|
97
|
+
## 配置与安全
|
|
98
|
+
|
|
99
|
+
Profile 只接受 Adapter 拥有的 `process`
|
|
100
|
+
连接。可配置消息、队列、请求、取消等待和 Run
|
|
101
|
+
Event 上限;未知选项会被拒绝。未消费 Event 导致 Queue 满时,Adapter 会中止连接而不是丢弃数据。
|
|
102
|
+
|
|
103
|
+
错误不会包含 Provider
|
|
104
|
+
Message、Prompt、文件内容、凭据、环境变量或本地路径。未知上游通知通过有界、脱敏的 Raw
|
|
105
|
+
Channel 保持可观察。
|
|
106
|
+
|
|
107
|
+
当前稳定 App Server 已有 Fixture、映射测试、共享 Conformance 和真实 Runtime
|
|
108
|
+
Evidence。精确兼容范围、Provider Options、Live Test 和未支持能力见
|
|
109
|
+
[英文详细文档](./README.md)。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harapter/adapter-codex",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Codex App Server provider adapter for Harapter.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -17,11 +17,13 @@
|
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/yunfeizhu/harapter/issues"
|
|
19
19
|
},
|
|
20
|
-
"homepage": "https://github.com/yunfeizhu/harapter#readme",
|
|
20
|
+
"homepage": "https://github.com/yunfeizhu/harapter/tree/main/providers/codex#readme",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"sideEffects": false,
|
|
23
23
|
"files": [
|
|
24
|
-
"dist"
|
|
24
|
+
"dist",
|
|
25
|
+
"README.zh-CN.md",
|
|
26
|
+
"README.ja.md"
|
|
25
27
|
],
|
|
26
28
|
"main": "./dist/index.js",
|
|
27
29
|
"types": "./dist/index.d.ts",
|
|
@@ -41,11 +43,11 @@
|
|
|
41
43
|
"tag": "next"
|
|
42
44
|
},
|
|
43
45
|
"dependencies": {
|
|
44
|
-
"@harapter/core": "0.1.
|
|
45
|
-
"@harapter/transport-jsonrpc-stdio": "0.1.
|
|
46
|
+
"@harapter/core": "0.1.2",
|
|
47
|
+
"@harapter/transport-jsonrpc-stdio": "0.1.2"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
|
-
"@harapter/conformance": "0.1.
|
|
50
|
+
"@harapter/conformance": "0.1.2"
|
|
49
51
|
},
|
|
50
52
|
"scripts": {
|
|
51
53
|
"build": "tsc --project tsconfig.build.json"
|