@pinta-ai/pinta-codex 1.2.0
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/.codex-plugin/plugin.json +40 -0
- package/CHANGELOG.md +50 -0
- package/LICENSE +136 -0
- package/README.md +214 -0
- package/dist/core/config.d.ts +10 -0
- package/dist/core/config.js +100 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/identity.d.ts +1 -0
- package/dist/core/identity.js +3 -0
- package/dist/core/identity.js.map +1 -0
- package/dist/core/otlp.d.ts +57 -0
- package/dist/core/otlp.js +182 -0
- package/dist/core/otlp.js.map +1 -0
- package/dist/core/redact.d.ts +57 -0
- package/dist/core/redact.js +149 -0
- package/dist/core/redact.js.map +1 -0
- package/dist/core/retry-queue.d.ts +26 -0
- package/dist/core/retry-queue.js +127 -0
- package/dist/core/retry-queue.js.map +1 -0
- package/dist/core/trace.d.ts +10 -0
- package/dist/core/trace.js +61 -0
- package/dist/core/trace.js.map +1 -0
- package/dist/core/transport.d.ts +10 -0
- package/dist/core/transport.js +77 -0
- package/dist/core/transport.js.map +1 -0
- package/dist/core/types.d.ts +48 -0
- package/dist/core/types.js +45 -0
- package/dist/core/types.js.map +1 -0
- package/dist/handlers/default.d.ts +6 -0
- package/dist/handlers/default.js +11 -0
- package/dist/handlers/default.js.map +1 -0
- package/dist/handlers/post-tool-use.d.ts +3 -0
- package/dist/handlers/post-tool-use.js +15 -0
- package/dist/handlers/post-tool-use.js.map +1 -0
- package/dist/handlers/pre-tool-use.d.ts +3 -0
- package/dist/handlers/pre-tool-use.js +15 -0
- package/dist/handlers/pre-tool-use.js.map +1 -0
- package/dist/handlers/session.d.ts +3 -0
- package/dist/handlers/session.js +15 -0
- package/dist/handlers/session.js.map +1 -0
- package/dist/handlers/stop.d.ts +3 -0
- package/dist/handlers/stop.js +15 -0
- package/dist/handlers/stop.js.map +1 -0
- package/dist/handlers/user-prompt.d.ts +3 -0
- package/dist/handlers/user-prompt.js +15 -0
- package/dist/handlers/user-prompt.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/hooks.json +54 -0
- package/package.json +43 -0
- package/tools/.data/events.json +1585 -0
- package/tools/_lib.ts +274 -0
- package/tools/doctor.ts +250 -0
- package/tools/install-hooks.ts +71 -0
- package/tools/mock-server.ts +436 -0
- package/tools/setup.ts +288 -0
- package/tools/test-otlp.ts +58 -0
- package/tools/test-redact.ts +286 -0
- package/tools/tsconfig.json +13 -0
- package/tools/uninstall-hooks.ts +39 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pinta-codex",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Generic OTLP forwarder for Codex hook events",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Pinta AI",
|
|
7
|
+
"email": "support@pinta.sh",
|
|
8
|
+
"url": "https://pinta.sh"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://pinta.sh",
|
|
11
|
+
"repository": "https://github.com/awarecorp/pinta-codex",
|
|
12
|
+
"license": "SEE LICENSE IN ../LICENSE",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"codex",
|
|
15
|
+
"opentelemetry",
|
|
16
|
+
"observability",
|
|
17
|
+
"otlp"
|
|
18
|
+
],
|
|
19
|
+
"hooks": "./hooks.json",
|
|
20
|
+
"interface": {
|
|
21
|
+
"displayName": "Pinta Codex",
|
|
22
|
+
"shortDescription": "Forward Codex hook events to any OTLP/HTTP collector",
|
|
23
|
+
"longDescription": "Captures Codex hook events, converts them to OTLP spans, and sends them to any OTLP/HTTP traces collector. Use with Pinta Manager for managed identity attribution, or any OTel pipeline of your choice.",
|
|
24
|
+
"developerName": "Pinta AI",
|
|
25
|
+
"category": "Productivity",
|
|
26
|
+
"capabilities": [
|
|
27
|
+
"Interactive",
|
|
28
|
+
"Write"
|
|
29
|
+
],
|
|
30
|
+
"websiteURL": "https://pinta.sh",
|
|
31
|
+
"privacyPolicyURL": "https://pinta.sh",
|
|
32
|
+
"termsOfServiceURL": "https://pinta.sh",
|
|
33
|
+
"defaultPrompt": [
|
|
34
|
+
"Review code with Pinta telemetry enabled.",
|
|
35
|
+
"Send Codex tool activity to my Pinta endpoint.",
|
|
36
|
+
"Trace this coding session for security review."
|
|
37
|
+
],
|
|
38
|
+
"brandColor": "#0F766E"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to pinta-codex are documented here.
|
|
4
|
+
|
|
5
|
+
## [1.2.0] - 2026-04-29 (BREAKING)
|
|
6
|
+
|
|
7
|
+
### BREAKING CHANGES
|
|
8
|
+
|
|
9
|
+
- **Pinta CLI dependency removed** — `pinta identity id/email` is no longer invoked. Identity attribution moves to the relay layer (Pinta Manager attaches on forward; OSS users handle in their own pipeline).
|
|
10
|
+
- **`PINTA_CODEX_API_KEY` semantic changed** — was: Pinta backend API key sent as `x-api-key`. Now: optional, treated as a token wrapped into `OTEL_EXPORTER_OTLP_HEADERS=x-pinta-relay-token=<value>`. New primary key is `OTEL_EXPORTER_OTLP_HEADERS` (full headers string in `key=val,key=val` format).
|
|
11
|
+
- **`PINTA_CODEX_ENDPOINT` deprecated (still accepted)** — new primary is `OTEL_EXPORTER_OTLP_ENDPOINT`. `npm run setup` auto-migrates legacy keys to OTel-spec naming (writes `~/.codex/pinta-codex.env.bak` first).
|
|
12
|
+
- **PreToolUse fail-close removed** — without identity to check, the deny path no longer fires. All hooks exit 0 on success.
|
|
13
|
+
- **`member.identity.*` resource attributes removed** — relay attaches identity if present.
|
|
14
|
+
- **`codex.client = "codex"` vestigial resource attribute removed.**
|
|
15
|
+
- **`src/enterprise/` directory removed** — `PintaIdentityResolver` deleted.
|
|
16
|
+
- **`src/handlers/auth-message.ts` removed** — no auth message to print.
|
|
17
|
+
- **`src/core/identity.ts` reduced to empty stub.**
|
|
18
|
+
- **`tools/setup.ts` no longer prompts for or checks Pinta identity** (step 5 dropped).
|
|
19
|
+
- **`tools/doctor.ts` no longer checks pinta CLI presence or identity authentication.**
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- vitest test suite (`tests/core/otlp.test.ts`) — 5 tests covering OTLP builder + identity absence regression guards.
|
|
24
|
+
- `tools/_lib.ts`: `migrateLegacyEnvKeys(p)` — auto-rename legacy `PINTA_CODEX_*` keys to OTel-spec on next setup run, with `.bak` backup.
|
|
25
|
+
- `src/core/config.ts`: `hasOtlpEndpoint(config)` helper (currently unused — reserved for future signaling).
|
|
26
|
+
- `src/core/config.ts`: silent disable when no endpoint configured (was: `loadConfig()` threw).
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- `buildOtlpPayload` signature: `{event, traceId, identity, now?}` → `{event, traceId, now?}`.
|
|
31
|
+
- `Transport`: takes `PintaCodexConfig` (renamed from `PintaConfig`); reads `config.endpoint`/`config.headers` set by config resolution; silent-disable when endpoint missing.
|
|
32
|
+
- `package.json` description updated.
|
|
33
|
+
- `.codex-plugin/plugin.json` description + interface.shortDescription/longDescription updated for OTel collector framing.
|
|
34
|
+
- `tools/mock-server.ts` reduced to a generic OTLP collector + viewer (removed Pinta-backend-specific endpoints, auth gate, identity extraction).
|
|
35
|
+
- Hint messages in transport now reference `OTEL_EXPORTER_OTLP_*` env names.
|
|
36
|
+
|
|
37
|
+
### Migration
|
|
38
|
+
|
|
39
|
+
**Existing users with `~/.codex/pinta-codex.env`:** Just run `npm run setup` again. The migration helper detects legacy keys, writes a `.bak`, and renames in place. Then re-run `codex` — same plugin behavior, just with new env names.
|
|
40
|
+
|
|
41
|
+
**Manual config users:** Update `~/.codex/pinta-codex.env`:
|
|
42
|
+
|
|
43
|
+
```env
|
|
44
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=https://your-collector.example.com
|
|
45
|
+
OTEL_EXPORTER_OTLP_HEADERS=x-pinta-relay-token=YOUR-TOKEN
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
(Or for non-Pinta collectors: `OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer YOUR-TOKEN`.)
|
|
49
|
+
|
|
50
|
+
**Identity attribution:** v1.0/1.1's `member.identity.*` resource attrs are gone. If you depended on them in your pipeline, attach them at your collector / forwarder layer. Pinta Manager users (M9d+): manager handles this automatically.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# PolyForm Noncommercial License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree
|
|
8
|
+
to them as both strict obligations and conditions to all
|
|
9
|
+
your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the
|
|
14
|
+
software to do everything you might do with the software
|
|
15
|
+
that would otherwise infringe the licensor's copyright
|
|
16
|
+
in it for any permitted purpose. However, you may
|
|
17
|
+
only distribute the software according to [Distribution
|
|
18
|
+
License](#distribution-license) and make changes or new works
|
|
19
|
+
based on the software according to [Changes and New Works
|
|
20
|
+
License](#changes-and-new-works-license).
|
|
21
|
+
|
|
22
|
+
## Distribution License
|
|
23
|
+
|
|
24
|
+
The licensor grants you an additional copyright license to
|
|
25
|
+
distribute copies of the software. Your license to distribute
|
|
26
|
+
covers distributing the software with changes and new works
|
|
27
|
+
permitted by [Changes and New Works
|
|
28
|
+
License](#changes-and-new-works-license).
|
|
29
|
+
|
|
30
|
+
## Notices
|
|
31
|
+
|
|
32
|
+
You must ensure that anyone who gets a copy of any part of
|
|
33
|
+
the software from you also gets a copy of these terms or the
|
|
34
|
+
URL for them above, as well as copies of any plain-text lines
|
|
35
|
+
beginning with `Required Notice:` that the licensor provided
|
|
36
|
+
with the software. For example:
|
|
37
|
+
|
|
38
|
+
> Required Notice: Copyright Pinta AI (https://pinta.sh)
|
|
39
|
+
|
|
40
|
+
## Changes and New Works License
|
|
41
|
+
|
|
42
|
+
The licensor grants you an additional copyright license to make
|
|
43
|
+
changes and new works based on the software for any permitted
|
|
44
|
+
purpose.
|
|
45
|
+
|
|
46
|
+
## Patent License
|
|
47
|
+
|
|
48
|
+
The licensor grants you a patent license for the software that
|
|
49
|
+
covers patent claims the licensor can license, or becomes able
|
|
50
|
+
to license, that you would infringe by using the software.
|
|
51
|
+
|
|
52
|
+
## Noncommercial Purposes
|
|
53
|
+
|
|
54
|
+
Any noncommercial purpose is a permitted purpose.
|
|
55
|
+
|
|
56
|
+
## Personal Uses
|
|
57
|
+
|
|
58
|
+
Personal use for research, experiment, and testing for
|
|
59
|
+
the benefit of public knowledge, personal study, private
|
|
60
|
+
entertainment, hobby projects, amateur pursuits, or religious
|
|
61
|
+
observance, without any anticipated commercial application,
|
|
62
|
+
is use for a permitted purpose.
|
|
63
|
+
|
|
64
|
+
## Noncommercial Organizations
|
|
65
|
+
|
|
66
|
+
Use by any charitable organization, educational institution,
|
|
67
|
+
public research organization, public safety or health
|
|
68
|
+
organization, environmental protection organization, or
|
|
69
|
+
government institution is use for a permitted purpose
|
|
70
|
+
regardless of the source of funding or obligations resulting
|
|
71
|
+
from the funding.
|
|
72
|
+
|
|
73
|
+
## Fair Use
|
|
74
|
+
|
|
75
|
+
You may have "fair use" rights for the software under the
|
|
76
|
+
law. These terms do not limit them.
|
|
77
|
+
|
|
78
|
+
## No Other Rights
|
|
79
|
+
|
|
80
|
+
These terms do not allow you to sublicense or transfer any of
|
|
81
|
+
your licenses to anyone else, or prevent the licensor from
|
|
82
|
+
granting licenses to anyone else. These terms do not imply
|
|
83
|
+
any other licenses.
|
|
84
|
+
|
|
85
|
+
## Patent Defense
|
|
86
|
+
|
|
87
|
+
If you make any written claim that the software infringes or
|
|
88
|
+
contributes to infringement of any patent, your patent license
|
|
89
|
+
for the software granted under these terms ends immediately. If
|
|
90
|
+
your company makes such a claim, your patent license ends
|
|
91
|
+
immediately for work on behalf of your company.
|
|
92
|
+
|
|
93
|
+
## Violations
|
|
94
|
+
|
|
95
|
+
The first time you are notified in writing that you have
|
|
96
|
+
violated any of these terms, or done anything with the software
|
|
97
|
+
not covered by your licenses, your licenses can nonetheless
|
|
98
|
+
continue if you come into full compliance with these terms,
|
|
99
|
+
and take practical steps to correct past violations, within
|
|
100
|
+
32 days of receiving notice. Otherwise, all your licenses
|
|
101
|
+
end immediately.
|
|
102
|
+
|
|
103
|
+
## No Liability
|
|
104
|
+
|
|
105
|
+
***As far as the law allows, the software comes as is, without
|
|
106
|
+
any warranty or condition, and the licensor will not be liable
|
|
107
|
+
to you for any damages arising out of these terms or the use
|
|
108
|
+
or nature of the software, under any kind of legal claim.***
|
|
109
|
+
|
|
110
|
+
## Definitions
|
|
111
|
+
|
|
112
|
+
The **licensor** is the individual or entity offering these
|
|
113
|
+
terms, and the **software** is the software the licensor makes
|
|
114
|
+
available under these terms.
|
|
115
|
+
|
|
116
|
+
**You** refers to the individual or entity agreeing to these
|
|
117
|
+
terms.
|
|
118
|
+
|
|
119
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
120
|
+
or other kind of organization that you work for, plus all
|
|
121
|
+
organizations that have control over, are under the control
|
|
122
|
+
of, or are under common control with that organization.
|
|
123
|
+
**Control** means ownership of substantially all the assets of
|
|
124
|
+
an entity, or the power to direct its management and policies
|
|
125
|
+
by vote, contract, or otherwise. Control can be direct or
|
|
126
|
+
indirect.
|
|
127
|
+
|
|
128
|
+
**Your licenses** are all the licenses granted to you for the
|
|
129
|
+
software under these terms.
|
|
130
|
+
|
|
131
|
+
**Use** means anything you do with the software requiring one
|
|
132
|
+
of your licenses.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
Required Notice: Copyright (c) 2026 Pinta AI
|
package/README.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# pinta-codex
|
|
2
|
+
|
|
3
|
+
Generic OTLP forwarder for Codex hook events.
|
|
4
|
+
|
|
5
|
+
> **엔드유저 설치 가이드:** [`docs/installation-guide.md`](./docs/installation-guide.md)
|
|
6
|
+
> **pinta-cc와의 차이:** [`docs/codex-vs-claude-code.md`](./docs/codex-vs-claude-code.md)
|
|
7
|
+
> 이 README는 개발자 관점 개요입니다.
|
|
8
|
+
|
|
9
|
+
## Channels
|
|
10
|
+
|
|
11
|
+
두 채널이 병행 운영됩니다. `~/.codex/hooks.json` 의 absolute-path prefix 로 구분되어 같은 머신에서 공존 가능합니다.
|
|
12
|
+
|
|
13
|
+
| Channel | 사용자 | 설치 |
|
|
14
|
+
|---------|-------|------|
|
|
15
|
+
| **Pinta Manager** (v0.2+) | Pinta 사용자 | catalog 가 npm tarball install → manager root prefix 로 hooks.json entry 자동 등록. **manual setup 불필요.** |
|
|
16
|
+
| **Git clone + npm run setup** | OSS / standalone | 아래 Quick start 참조. `~/.codex/pinta-codex.env` 에 직접 endpoint/token 작성. |
|
|
17
|
+
|
|
18
|
+
## Quick start (OSS / standalone)
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
git clone https://github.com/awarecorp/pinta-codex.git
|
|
22
|
+
cd pinta-codex
|
|
23
|
+
npm install
|
|
24
|
+
npm run setup # interactive: build + env (OTLP collector URL) + config.toml + hooks.json
|
|
25
|
+
codex # hooks fire immediately
|
|
26
|
+
npm run doctor # verify everything green
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`setup`은 idempotent — 재실행해도 안전합니다. `doctor`는 read-only.
|
|
30
|
+
|
|
31
|
+
## What it captures
|
|
32
|
+
|
|
33
|
+
Codex의 hook 시스템 (실험적; `~/.codex/config.toml`의 `features.codex_hooks = true` 활성화 필요) 이 현재 발화하는 5개 이벤트가 모두 핸들링됩니다.
|
|
34
|
+
|
|
35
|
+
| Event | Notes |
|
|
36
|
+
|-------|-------|
|
|
37
|
+
| `SessionStart` | health ping + drain retry queue |
|
|
38
|
+
| `UserPromptSubmit` | starts a new ULID trace per user turn |
|
|
39
|
+
| `PreToolUse` | **Bash tool only** (current Codex limitation) |
|
|
40
|
+
| `PostToolUse` | **Bash tool only** (current Codex limitation) |
|
|
41
|
+
| `Stop` | final flush |
|
|
42
|
+
|
|
43
|
+
각 invocation은 `node dist/index.js`를 spawn하고, 이벤트를 OTLP span 하나로 매핑한 뒤 `{endpoint}/traces`로 POST합니다.
|
|
44
|
+
|
|
45
|
+
## Behavior
|
|
46
|
+
|
|
47
|
+
- OTLP/HTTP JSON transport. 헤더는 `OTEL_EXPORTER_OTLP_HEADERS` 에서 읽음 (`key=val,key=val` 형식)
|
|
48
|
+
- Top-level 이벤트 필드는 `codex.*` span attribute 로 평탄화 (Bronze; 형제 adaptor는 `cc.*`, `mcp.*`)
|
|
49
|
+
- **No fail-close** — 모든 hook은 성공 시 exit 0 (전송 실패는 retry queue 로 흡수)
|
|
50
|
+
- Disk-backed retry queue at `.plugin-data/failed-spans.jsonl` (cap 1000). 다음 hook 호출 시 일괄 drain
|
|
51
|
+
- One trace per user turn — `UserPromptSubmit` ULID 기반
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
`npm run setup` 이 `~/.codex/pinta-codex.env` 에 endpoint + 헤더를 씁니다. 환경변수로 파일 값을 덮어쓸 수 있습니다.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# OTel-spec (primary)
|
|
59
|
+
export OTEL_EXPORTER_OTLP_ENDPOINT="https://your-collector.example.com"
|
|
60
|
+
export OTEL_EXPORTER_OTLP_HEADERS="x-pinta-relay-token=YOUR-TOKEN"
|
|
61
|
+
|
|
62
|
+
# Non-Pinta collectors
|
|
63
|
+
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer YOUR-TOKEN"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`~/.codex/pinta-codex.env` 예시:
|
|
67
|
+
|
|
68
|
+
```env
|
|
69
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=https://your-collector.example.com
|
|
70
|
+
OTEL_EXPORTER_OTLP_HEADERS=x-pinta-relay-token=YOUR-TOKEN
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
**Resolution precedence (highest to lowest):**
|
|
74
|
+
1. Explicit `process.env` (`OTEL_EXPORTER_OTLP_*`)
|
|
75
|
+
2. `~/.codex/pinta-codex.env` (managed by `npm run setup`)
|
|
76
|
+
3. Legacy `PINTA_CODEX_*` keys (auto-migrated on next `npm run setup`)
|
|
77
|
+
4. Parity keys (`CLAUDE_PLUGIN_OPTION_ENDPOINT` / `CLAUDE_PLUGIN_OPTION_API_KEY`)
|
|
78
|
+
|
|
79
|
+
Optional overrides:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
export CODEX_PLUGIN_DATA="/abs/path/to/.plugin-data" # override runtime data dir
|
|
83
|
+
export CODEX_CLI_VERSION="$(codex --version | awk '{print $NF}')"
|
|
84
|
+
export CODEX_HOME="/abs/path/to/.codex" # override ~/.codex during install
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Identity — not needed
|
|
88
|
+
|
|
89
|
+
v1.2부터 Pinta CLI 의존이 제거되었습니다. Identity 부착은 relay 계층 책임입니다. Pinta Manager 가 forward 시 첨부하며, OSS 사용자는 자기 pipeline 에서 처리합니다. 플러그인 자체는 identity 없이 동작하며, 어떤 hook 도 identity 부재로 차단되지 않습니다.
|
|
90
|
+
|
|
91
|
+
## Manual install (advanced)
|
|
92
|
+
|
|
93
|
+
interactive setup 을 쓰지 않으려면:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npm run build
|
|
97
|
+
npm run install-hooks # merges absolute paths into ~/.codex/hooks.json
|
|
98
|
+
npm run install-hooks -- --dry-run # preview without writing
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`install-hooks` 는 idempotent: `~/.codex/hooks.json` 이 번들 템플릿과 이미 일치하면 `already up to date` 로 no-op. 이전 경로의 stale pinta-codex 엔트리는 자동 감지·제거 (`removed N stale pinta-codex entries`).
|
|
102
|
+
|
|
103
|
+
`~/.codex/config.toml` 에 수동으로 추가:
|
|
104
|
+
|
|
105
|
+
```toml
|
|
106
|
+
[features]
|
|
107
|
+
codex_hooks = true
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
> **Why an install script?** Codex는 아직 `.codex-plugin/plugin.json` 에서 hook 을 자동 로드하지 않습니다. `install-hooks` 가 번들 `hooks.json` 템플릿의 `${CODEX_PLUGIN_ROOT}` 를 절대경로로 교체하고 user-level 파일에 merge 합니다. Codex 가 plugin-hook auto-discovery 를 추가하면 이 단계는 사라집니다.
|
|
111
|
+
|
|
112
|
+
## Uninstall
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npm run uninstall-hooks
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
`dist/index.js` 를 참조하는 이 플러그인의 `~/.codex/hooks.json` 엔트리만 제거합니다. 다른 hook 은 건드리지 않습니다.
|
|
119
|
+
|
|
120
|
+
완전 제거:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
rm ~/.codex/pinta-codex.env
|
|
124
|
+
# ~/.codex/config.toml 에서 [features] codex_hooks = true 라인 수동 삭제
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Local development
|
|
128
|
+
|
|
129
|
+
Mock server (OTLP viewer at `http://localhost:3000`):
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npm run mock-server
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
다른 터미널에서 endpoint 를 mock 으로 설정하고 Codex 시작:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:3000 codex
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
또는 stdin pipe 로 setup:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
printf 'http://localhost:3000\n\n' | npm run setup
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Scripts
|
|
148
|
+
|
|
149
|
+
| Script | Purpose |
|
|
150
|
+
|--------|---------|
|
|
151
|
+
| `npm run setup` | one-shot interactive installer (build + env + config + hooks) |
|
|
152
|
+
| `npm run doctor` | read-only health check; exits 1 on failure |
|
|
153
|
+
| `npm test` | vitest test suite |
|
|
154
|
+
| `npm run build` | `tsc` into `dist/` |
|
|
155
|
+
| `npm run dev` | `tsc --watch` |
|
|
156
|
+
| `npm run install-hooks` | merge entries into `~/.codex/hooks.json` (supports `-- --dry-run`) |
|
|
157
|
+
| `npm run uninstall-hooks` | remove this plugin's entries from `~/.codex/hooks.json` |
|
|
158
|
+
| `npm run mock-server` | local OTLP collector for testing |
|
|
159
|
+
| `npm run test:otlp` | span-flattening unit checks (legacy assert-based) |
|
|
160
|
+
| `npm run test:redact` | redaction unit checks (legacy assert-based) |
|
|
161
|
+
|
|
162
|
+
## BREAKING CHANGES from 1.0.x / 1.1.x
|
|
163
|
+
|
|
164
|
+
상세한 마이그레이션 안내는 [`CHANGELOG.md`](./CHANGELOG.md) 를 참조하세요.
|
|
165
|
+
|
|
166
|
+
요약:
|
|
167
|
+
- Pinta CLI 의존 제거. `pinta login` 불필요
|
|
168
|
+
- `PINTA_CODEX_ENDPOINT` / `PINTA_CODEX_API_KEY` → `OTEL_EXPORTER_OTLP_ENDPOINT` / `OTEL_EXPORTER_OTLP_HEADERS` (legacy 키는 backward-compat 으로 인식되며 다음 `npm run setup` 시 자동 마이그레이션)
|
|
169
|
+
- PreToolUse fail-close 제거. 모든 hook 은 exit 0 on success
|
|
170
|
+
- `member.identity.*` resource attribute 제거
|
|
171
|
+
|
|
172
|
+
### 마이그레이션 액션
|
|
173
|
+
|
|
174
|
+
| 채널 | 액션 |
|
|
175
|
+
|------|------|
|
|
176
|
+
| **Pinta Manager v0.2+** | 자동. 다음 reconcile 에 기존 hook entry 가 manager-installed 1.2.0 entry 로 교체되고 `~/.codex/pinta-codex.env` 의 PINTA_* 키는 OTEL_* 로 갱신. |
|
|
177
|
+
| **Git clone (기존 사용자)** | `git pull && npm run setup` 1회 재실행. setup 이 legacy `PINTA_CODEX_*` 키를 OTel 키로 자동 마이그레이션 (.bak 백업). |
|
|
178
|
+
| **재setup 안 함** | hook 자체는 1.0.x/1.1.x 코드 그대로라면 동작 유지. 단 dist/ 가 1.2.0 으로 빌드된 상태에서 PINTA_CODEX_* 만 남아있으면 backward-compat path 로 동작 (재setup 권장). |
|
|
179
|
+
|
|
180
|
+
## Repo layout
|
|
181
|
+
|
|
182
|
+
```text
|
|
183
|
+
pinta-codex/
|
|
184
|
+
├── .codex-plugin/plugin.json # plugin manifest (forward-compatible with future auto-discovery)
|
|
185
|
+
├── .agents/plugins/marketplace.json # local marketplace pointer
|
|
186
|
+
├── .github/workflows/ # CI (PR validation + dist/ rebuild on main)
|
|
187
|
+
├── hooks.json # template using ${CODEX_PLUGIN_ROOT} — resolved by install-hooks
|
|
188
|
+
├── LICENSE # PolyForm Noncommercial 1.0.0
|
|
189
|
+
├── CHANGELOG.md # version history + BREAKING CHANGES
|
|
190
|
+
├── docs/
|
|
191
|
+
│ ├── installation-guide.md # end-user install walkthrough
|
|
192
|
+
│ └── codex-vs-claude-code.md # UX differences vs pinta-cc
|
|
193
|
+
├── src/
|
|
194
|
+
│ ├── core/ # OSS-reusable (config, transport, otlp, redact, retry-queue, trace, types, identity stub)
|
|
195
|
+
│ ├── handlers/ # per-event handlers
|
|
196
|
+
│ └── index.ts # stdin → type guard → handler dispatch
|
|
197
|
+
├── tests/
|
|
198
|
+
│ └── core/ # vitest tests (otlp.test.ts etc.)
|
|
199
|
+
├── tools/
|
|
200
|
+
│ ├── setup.ts # one-shot interactive installer
|
|
201
|
+
│ ├── doctor.ts # read-only health check
|
|
202
|
+
│ ├── install-hooks.ts # merge into ~/.codex/hooks.json
|
|
203
|
+
│ ├── uninstall-hooks.ts # remove pinta-codex entries
|
|
204
|
+
│ ├── mock-server.ts # local OTLP viewer
|
|
205
|
+
│ ├── test-otlp.ts # span-flattening checks (legacy)
|
|
206
|
+
│ ├── test-redact.ts # redaction checks (legacy)
|
|
207
|
+
│ └── _lib.ts # shared utilities (migrateLegacyEnvKeys etc.)
|
|
208
|
+
├── vitest.config.ts
|
|
209
|
+
└── .plugin-data/ # created at runtime (trace.json, failed-spans.jsonl)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
PolyForm Noncommercial 1.0.0. See [`LICENSE`](./LICENSE).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface PintaCodexConfig {
|
|
2
|
+
pluginRoot: string;
|
|
3
|
+
pluginData: string;
|
|
4
|
+
tracePath: string;
|
|
5
|
+
endpoint?: string;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export declare function loadConfig(): PintaCodexConfig;
|
|
9
|
+
/** Returns true if OTel endpoint is configured (signal to silently disable telemetry). */
|
|
10
|
+
export declare function hasOtlpEndpoint(config: PintaCodexConfig): boolean;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadConfig = loadConfig;
|
|
7
|
+
exports.hasOtlpEndpoint = hasOtlpEndpoint;
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
function readEnvFile(p) {
|
|
12
|
+
const out = {};
|
|
13
|
+
let content;
|
|
14
|
+
try {
|
|
15
|
+
content = node_fs_1.default.readFileSync(p, "utf-8");
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
for (const raw of content.split("\n")) {
|
|
21
|
+
const line = raw.trim();
|
|
22
|
+
if (!line || line.startsWith("#"))
|
|
23
|
+
continue;
|
|
24
|
+
const idx = line.indexOf("=");
|
|
25
|
+
if (idx < 0)
|
|
26
|
+
continue;
|
|
27
|
+
const key = line.slice(0, idx).trim();
|
|
28
|
+
let value = line.slice(idx + 1).trim();
|
|
29
|
+
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
30
|
+
(value.startsWith("'") && value.endsWith("'"))) {
|
|
31
|
+
value = value.slice(1, -1);
|
|
32
|
+
}
|
|
33
|
+
if (key)
|
|
34
|
+
out[key] = value;
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
function resolveEndpoint(envFile) {
|
|
39
|
+
return process.env.OTEL_EXPORTER_OTLP_ENDPOINT
|
|
40
|
+
?? envFile.OTEL_EXPORTER_OTLP_ENDPOINT
|
|
41
|
+
?? process.env.PINTA_CODEX_ENDPOINT // legacy
|
|
42
|
+
?? envFile.PINTA_CODEX_ENDPOINT // legacy
|
|
43
|
+
?? process.env.CLAUDE_PLUGIN_OPTION_ENDPOINT // parity
|
|
44
|
+
?? undefined;
|
|
45
|
+
}
|
|
46
|
+
function resolveHeaders(envFile) {
|
|
47
|
+
// Primary: OTel-spec, already in `key=val,key=val` format
|
|
48
|
+
if (process.env.OTEL_EXPORTER_OTLP_HEADERS)
|
|
49
|
+
return process.env.OTEL_EXPORTER_OTLP_HEADERS;
|
|
50
|
+
if (envFile.OTEL_EXPORTER_OTLP_HEADERS)
|
|
51
|
+
return envFile.OTEL_EXPORTER_OTLP_HEADERS;
|
|
52
|
+
// Legacy: raw token → wrap as x-pinta-relay-token header
|
|
53
|
+
if (process.env.PINTA_CODEX_API_KEY) {
|
|
54
|
+
return `x-pinta-relay-token=${process.env.PINTA_CODEX_API_KEY}`;
|
|
55
|
+
}
|
|
56
|
+
if (envFile.PINTA_CODEX_API_KEY) {
|
|
57
|
+
return `x-pinta-relay-token=${envFile.PINTA_CODEX_API_KEY}`;
|
|
58
|
+
}
|
|
59
|
+
// Parity: Claude Code-style userConfig env (raw token, same wrap)
|
|
60
|
+
if (process.env.CLAUDE_PLUGIN_OPTION_API_KEY) {
|
|
61
|
+
return `x-pinta-relay-token=${process.env.CLAUDE_PLUGIN_OPTION_API_KEY}`;
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
function parseHeadersString(raw) {
|
|
66
|
+
const out = {};
|
|
67
|
+
if (!raw)
|
|
68
|
+
return out;
|
|
69
|
+
for (const pair of raw.split(",")) {
|
|
70
|
+
const [k, ...rest] = pair.split("=");
|
|
71
|
+
if (k && rest.length > 0)
|
|
72
|
+
out[k.trim()] = rest.join("=").trim();
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
function loadConfig() {
|
|
77
|
+
const pluginRoot = process.env.CODEX_PLUGIN_ROOT
|
|
78
|
+
?? process.env.CLAUDE_PLUGIN_ROOT
|
|
79
|
+
?? process.cwd();
|
|
80
|
+
const pluginData = process.env.CODEX_PLUGIN_DATA
|
|
81
|
+
?? process.env.CLAUDE_PLUGIN_DATA
|
|
82
|
+
?? node_path_1.default.join(pluginRoot, ".plugin-data");
|
|
83
|
+
const codexHome = process.env.CODEX_HOME ?? node_path_1.default.join(node_os_1.default.homedir(), ".codex");
|
|
84
|
+
const envFilePath = node_path_1.default.join(codexHome, "pinta-codex.env");
|
|
85
|
+
const envFile = node_fs_1.default.existsSync(envFilePath) ? readEnvFile(envFilePath) : {};
|
|
86
|
+
const endpoint = resolveEndpoint(envFile);
|
|
87
|
+
const headersRaw = resolveHeaders(envFile);
|
|
88
|
+
return {
|
|
89
|
+
pluginRoot,
|
|
90
|
+
pluginData,
|
|
91
|
+
tracePath: node_path_1.default.join(pluginData, "trace.json"),
|
|
92
|
+
endpoint: endpoint?.replace(/\/+$/, ""),
|
|
93
|
+
headers: parseHeadersString(headersRaw ?? ""),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/** Returns true if OTel endpoint is configured (signal to silently disable telemetry). */
|
|
97
|
+
function hasOtlpEndpoint(config) {
|
|
98
|
+
return Boolean(config.endpoint);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/core/identity.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { BaseEvent } from "./types.js";
|
|
2
|
+
export interface OtlpAttribute {
|
|
3
|
+
key: string;
|
|
4
|
+
value: {
|
|
5
|
+
stringValue: string;
|
|
6
|
+
} | {
|
|
7
|
+
intValue: number;
|
|
8
|
+
} | {
|
|
9
|
+
doubleValue: number;
|
|
10
|
+
} | {
|
|
11
|
+
boolValue: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface OtlpSpan {
|
|
15
|
+
traceId: string;
|
|
16
|
+
spanId: string;
|
|
17
|
+
name: string;
|
|
18
|
+
kind: number;
|
|
19
|
+
startTimeUnixNano: string;
|
|
20
|
+
endTimeUnixNano: string;
|
|
21
|
+
attributes: OtlpAttribute[];
|
|
22
|
+
}
|
|
23
|
+
export interface ResourceSpans {
|
|
24
|
+
resource: {
|
|
25
|
+
attributes: OtlpAttribute[];
|
|
26
|
+
};
|
|
27
|
+
scopeSpans: Array<{
|
|
28
|
+
scope: {
|
|
29
|
+
name: string;
|
|
30
|
+
version: string;
|
|
31
|
+
};
|
|
32
|
+
spans: OtlpSpan[];
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
export interface OtlpPayload {
|
|
36
|
+
resourceSpans: ResourceSpans[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Convert a 26-char Crockford ULID into 32 lowercase hex chars (16 bytes)
|
|
40
|
+
* suitable for an OTLP traceId. Decoding is straightforward because each
|
|
41
|
+
* Crockford char carries 5 bits and 26 chars = 130 bits; we keep the low
|
|
42
|
+
* 128 bits (the spec already pads timestamp+randomness into 128 bits).
|
|
43
|
+
*/
|
|
44
|
+
export declare function ulidToTraceId(ulid: string): string;
|
|
45
|
+
/** Generate a fresh 16-hex-char (8-byte) span ID. */
|
|
46
|
+
export declare function newSpanId(): string;
|
|
47
|
+
export declare function buildOtlpPayload(args: {
|
|
48
|
+
event: BaseEvent;
|
|
49
|
+
traceId: string;
|
|
50
|
+
now?: number;
|
|
51
|
+
}): OtlpPayload;
|
|
52
|
+
/**
|
|
53
|
+
* Combine multiple per-hook payloads into a single OTLP payload by
|
|
54
|
+
* concatenating their resourceSpans arrays. The Pinta backend's parser
|
|
55
|
+
* iterates over resourceSpans natively.
|
|
56
|
+
*/
|
|
57
|
+
export declare function mergeBatch(payloads: OtlpPayload[]): OtlpPayload;
|