codex-claude-relay 0.1.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/LICENSE +21 -0
- package/README.md +534 -0
- package/README.zh.md +522 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +304 -0
- package/dist/git.d.ts +11 -0
- package/dist/git.js +58 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +10 -0
- package/dist/launch.d.ts +29 -0
- package/dist/launch.js +66 -0
- package/dist/parse/jsonl.d.ts +21 -0
- package/dist/parse/jsonl.js +75 -0
- package/dist/providers/claude.d.ts +36 -0
- package/dist/providers/claude.js +401 -0
- package/dist/providers/codex.d.ts +11 -0
- package/dist/providers/codex.js +310 -0
- package/dist/redact.d.ts +10 -0
- package/dist/redact.js +84 -0
- package/dist/summarize.d.ts +13 -0
- package/dist/summarize.js +241 -0
- package/dist/types.d.ts +87 -0
- package/dist/types.js +9 -0
- package/package.json +56 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export type AgentName = 'codex' | 'claude';
|
|
2
|
+
export interface GitContext {
|
|
3
|
+
/** Absolute path to git root, or to cwd if not in a git repo. */
|
|
4
|
+
root: string;
|
|
5
|
+
/** True if `root` is actually a git repository top-level. */
|
|
6
|
+
inRepo: boolean;
|
|
7
|
+
/** Last path segment of `root`, used as a name signal during ranking. */
|
|
8
|
+
repoName: string;
|
|
9
|
+
/** Best-effort current branch name, or null if unavailable. */
|
|
10
|
+
branch: string | null;
|
|
11
|
+
/** Truncated `git status --short` output, or null if not in a repo / git missing. */
|
|
12
|
+
statusShort: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface SessionCandidate {
|
|
15
|
+
/** Absolute path to the JSONL transcript file. */
|
|
16
|
+
path: string;
|
|
17
|
+
/** mtime of the file in epoch ms. */
|
|
18
|
+
mtimeMs: number;
|
|
19
|
+
/** Working directory recorded inside the transcript (if any). */
|
|
20
|
+
recordedCwd: string | null;
|
|
21
|
+
/** Higher = better match. Producers should set this on a 0..100-ish scale. */
|
|
22
|
+
score: number;
|
|
23
|
+
/** Human-readable reason for the score (debugging / inspect). */
|
|
24
|
+
reasons: string[];
|
|
25
|
+
}
|
|
26
|
+
/** A normalized event extracted from either Codex or Claude transcripts. */
|
|
27
|
+
export interface TranscriptEvent {
|
|
28
|
+
/** Source line index in the JSONL file (for debugging). */
|
|
29
|
+
lineNo: number;
|
|
30
|
+
/** Original epoch ms timestamp if any. Falls back to file mtime ordering. */
|
|
31
|
+
timestampMs: number | null;
|
|
32
|
+
kind: 'user_message' | 'assistant_message' | 'thinking' | 'tool_call' | 'tool_result' | 'system' | 'unknown';
|
|
33
|
+
/** Brief text payload. For tool calls this is a compact summary. */
|
|
34
|
+
text: string;
|
|
35
|
+
/** Tool name if kind === 'tool_call' or 'tool_result'. */
|
|
36
|
+
toolName?: string;
|
|
37
|
+
/** Shell command, if extractable from the tool call. */
|
|
38
|
+
command?: string;
|
|
39
|
+
/** Files that this event touched (read, edited, created). */
|
|
40
|
+
files?: string[];
|
|
41
|
+
/** If the tool result represents an error. */
|
|
42
|
+
isError?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface ParsedSession {
|
|
45
|
+
/** The source JSONL file. */
|
|
46
|
+
path: string;
|
|
47
|
+
/** Working directory recorded in metadata, if any. */
|
|
48
|
+
recordedCwd: string | null;
|
|
49
|
+
/** Recorded git branch, if any. */
|
|
50
|
+
recordedBranch: string | null;
|
|
51
|
+
/** Session id, if any. */
|
|
52
|
+
sessionId: string | null;
|
|
53
|
+
/** Earliest and latest timestamps observed. */
|
|
54
|
+
startedAtMs: number | null;
|
|
55
|
+
endedAtMs: number | null;
|
|
56
|
+
/** Number of lines we successfully parsed. */
|
|
57
|
+
parsedLines: number;
|
|
58
|
+
/** Number of malformed JSONL lines we skipped. */
|
|
59
|
+
skippedLines: number;
|
|
60
|
+
/** All events in original order. */
|
|
61
|
+
events: TranscriptEvent[];
|
|
62
|
+
}
|
|
63
|
+
export interface HandoffContent {
|
|
64
|
+
/** The fully-rendered prompt string. */
|
|
65
|
+
text: string;
|
|
66
|
+
/** Whether the source session may be stale (older than ~24h). */
|
|
67
|
+
stale: boolean;
|
|
68
|
+
/** Human-readable provenance line, e.g. file path + timestamp. */
|
|
69
|
+
source: string;
|
|
70
|
+
/** Source agent name. */
|
|
71
|
+
sourceAgent: AgentName;
|
|
72
|
+
}
|
|
73
|
+
export interface RelayOptions {
|
|
74
|
+
/** Force using the latest session regardless of repo match. */
|
|
75
|
+
last: boolean;
|
|
76
|
+
/** Include current git diff in the handoff. */
|
|
77
|
+
withDiff: boolean;
|
|
78
|
+
/** Cap on the rendered handoff prompt length (in characters). */
|
|
79
|
+
maxChars: number;
|
|
80
|
+
/** Print the handoff but do not launch anything. */
|
|
81
|
+
dryRun: boolean;
|
|
82
|
+
/** Disable secret redaction in the handoff (default: redaction ON). */
|
|
83
|
+
noRedact: boolean;
|
|
84
|
+
/** Print verbose info about discovery & parsing. */
|
|
85
|
+
debug: boolean;
|
|
86
|
+
}
|
|
87
|
+
export declare const DEFAULT_OPTIONS: RelayOptions;
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codex-claude-relay",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Stateless context handoff between OpenAI Codex CLI and Anthropic Claude Code. Reads native session transcripts, condenses them, and launches the other agent with the handoff as its initial prompt.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"relay": "./dist/cli.js",
|
|
8
|
+
"codex-claude-relay": "./dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"README.zh.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -p tsconfig.json",
|
|
23
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
24
|
+
"test": "node --test --import tsx test/*.test.ts",
|
|
25
|
+
"prepublishOnly": "npm run build",
|
|
26
|
+
"relay": "node dist/cli.js"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"codex",
|
|
30
|
+
"claude",
|
|
31
|
+
"claude-code",
|
|
32
|
+
"cli",
|
|
33
|
+
"handoff",
|
|
34
|
+
"ai-agents",
|
|
35
|
+
"context",
|
|
36
|
+
"relay"
|
|
37
|
+
],
|
|
38
|
+
"author": "Jayden Lee <lij850601@gmail.com>",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/Picrew/codex-claude-relay.git"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/Picrew/codex-claude-relay/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/Picrew/codex-claude-relay#readme",
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=20"
|
|
49
|
+
},
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "^20.11.0",
|
|
53
|
+
"tsx": "^4.7.0",
|
|
54
|
+
"typescript": "^5.4.0"
|
|
55
|
+
}
|
|
56
|
+
}
|