@ai-studio-3d/vyasa 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/README.md +69 -0
- package/data/common-kit.json +34 -0
- package/data/pricing.json +119 -0
- package/data/schema/AnalyticsData.json +214 -0
- package/data/schema/FoundationData.json +42 -0
- package/data/schema/KitData.json +321 -0
- package/data/schema/SearchData.json +173 -0
- package/data/schema/SessionDetailData.json +231 -0
- package/data/schema/SessionsListData.json +115 -0
- package/data/schema/WasteData.json +95 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +343 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/billing/index.d.ts +4 -0
- package/dist/core/billing/index.d.ts.map +1 -0
- package/dist/core/billing/index.js +43 -0
- package/dist/core/billing/index.js.map +1 -0
- package/dist/core/budget/index.d.ts +30 -0
- package/dist/core/budget/index.d.ts.map +1 -0
- package/dist/core/budget/index.js +61 -0
- package/dist/core/budget/index.js.map +1 -0
- package/dist/core/codex/index.d.ts +3 -0
- package/dist/core/codex/index.d.ts.map +1 -0
- package/dist/core/codex/index.js +212 -0
- package/dist/core/codex/index.js.map +1 -0
- package/dist/core/cursor/index.d.ts +3 -0
- package/dist/core/cursor/index.d.ts.map +1 -0
- package/dist/core/cursor/index.js +304 -0
- package/dist/core/cursor/index.js.map +1 -0
- package/dist/core/cursor/scan.d.ts +28 -0
- package/dist/core/cursor/scan.d.ts.map +1 -0
- package/dist/core/cursor/scan.js +79 -0
- package/dist/core/cursor/scan.js.map +1 -0
- package/dist/core/decisions/index.d.ts +21 -0
- package/dist/core/decisions/index.d.ts.map +1 -0
- package/dist/core/decisions/index.js +133 -0
- package/dist/core/decisions/index.js.map +1 -0
- package/dist/core/dlp/index.d.ts +7 -0
- package/dist/core/dlp/index.d.ts.map +1 -0
- package/dist/core/dlp/index.js +115 -0
- package/dist/core/dlp/index.js.map +1 -0
- package/dist/core/health/index.d.ts +10 -0
- package/dist/core/health/index.d.ts.map +1 -0
- package/dist/core/health/index.js +21 -0
- package/dist/core/health/index.js.map +1 -0
- package/dist/core/index/index.d.ts +9 -0
- package/dist/core/index/index.d.ts.map +1 -0
- package/dist/core/index/index.js +103 -0
- package/dist/core/index/index.js.map +1 -0
- package/dist/core/index/ingest.d.ts +16 -0
- package/dist/core/index/ingest.d.ts.map +1 -0
- package/dist/core/index/ingest.js +184 -0
- package/dist/core/index/ingest.js.map +1 -0
- package/dist/core/index/platforms.d.ts +21 -0
- package/dist/core/index/platforms.d.ts.map +1 -0
- package/dist/core/index/platforms.js +44 -0
- package/dist/core/index/platforms.js.map +1 -0
- package/dist/core/index/pricing-map.d.ts +10 -0
- package/dist/core/index/pricing-map.d.ts.map +1 -0
- package/dist/core/index/pricing-map.js +16 -0
- package/dist/core/index/pricing-map.js.map +1 -0
- package/dist/core/index/progress.d.ts +26 -0
- package/dist/core/index/progress.d.ts.map +1 -0
- package/dist/core/index/progress.js +59 -0
- package/dist/core/index/progress.js.map +1 -0
- package/dist/core/index/scan.d.ts +9 -0
- package/dist/core/index/scan.d.ts.map +1 -0
- package/dist/core/index/scan.js +42 -0
- package/dist/core/index/scan.js.map +1 -0
- package/dist/core/index/statements.d.ts +18 -0
- package/dist/core/index/statements.d.ts.map +1 -0
- package/dist/core/index/statements.js +82 -0
- package/dist/core/index/statements.js.map +1 -0
- package/dist/core/index/tail.d.ts +42 -0
- package/dist/core/index/tail.d.ts.map +1 -0
- package/dist/core/index/tail.js +123 -0
- package/dist/core/index/tail.js.map +1 -0
- package/dist/core/jsonl/index.d.ts +3 -0
- package/dist/core/jsonl/index.d.ts.map +1 -0
- package/dist/core/jsonl/index.js +106 -0
- package/dist/core/jsonl/index.js.map +1 -0
- package/dist/core/jsonl-validate/index.d.ts +10 -0
- package/dist/core/jsonl-validate/index.d.ts.map +1 -0
- package/dist/core/jsonl-validate/index.js +40 -0
- package/dist/core/jsonl-validate/index.js.map +1 -0
- package/dist/core/kit/detection.d.ts +94 -0
- package/dist/core/kit/detection.d.ts.map +1 -0
- package/dist/core/kit/detection.js +312 -0
- package/dist/core/kit/detection.js.map +1 -0
- package/dist/core/kit/index.d.ts +12 -0
- package/dist/core/kit/index.d.ts.map +1 -0
- package/dist/core/kit/index.js +131 -0
- package/dist/core/kit/index.js.map +1 -0
- package/dist/core/kit/scan.d.ts +28 -0
- package/dist/core/kit/scan.d.ts.map +1 -0
- package/dist/core/kit/scan.js +432 -0
- package/dist/core/kit/scan.js.map +1 -0
- package/dist/core/recap/index.d.ts +18 -0
- package/dist/core/recap/index.d.ts.map +1 -0
- package/dist/core/recap/index.js +88 -0
- package/dist/core/recap/index.js.map +1 -0
- package/dist/core/repetition/index.d.ts +5 -0
- package/dist/core/repetition/index.d.ts.map +1 -0
- package/dist/core/repetition/index.js +0 -0
- package/dist/core/repetition/index.js.map +1 -0
- package/dist/core/schema/index.d.ts +514 -0
- package/dist/core/schema/index.d.ts.map +1 -0
- package/dist/core/schema/index.js +2 -0
- package/dist/core/schema/index.js.map +1 -0
- package/dist/core/schema-watch/index.d.ts +34 -0
- package/dist/core/schema-watch/index.d.ts.map +1 -0
- package/dist/core/schema-watch/index.js +87 -0
- package/dist/core/schema-watch/index.js.map +1 -0
- package/dist/core/search/index.d.ts +44 -0
- package/dist/core/search/index.d.ts.map +1 -0
- package/dist/core/search/index.js +641 -0
- package/dist/core/search/index.js.map +1 -0
- package/dist/core/settings/index.d.ts +24 -0
- package/dist/core/settings/index.d.ts.map +1 -0
- package/dist/core/settings/index.js +76 -0
- package/dist/core/settings/index.js.map +1 -0
- package/dist/core/share/bundle.d.ts +40 -0
- package/dist/core/share/bundle.d.ts.map +1 -0
- package/dist/core/share/bundle.js +158 -0
- package/dist/core/share/bundle.js.map +1 -0
- package/dist/core/share/canonical/from-claude.d.ts +13 -0
- package/dist/core/share/canonical/from-claude.d.ts.map +1 -0
- package/dist/core/share/canonical/from-claude.js +129 -0
- package/dist/core/share/canonical/from-claude.js.map +1 -0
- package/dist/core/share/canonical/from-codex.d.ts +18 -0
- package/dist/core/share/canonical/from-codex.d.ts.map +1 -0
- package/dist/core/share/canonical/from-codex.js +183 -0
- package/dist/core/share/canonical/from-codex.js.map +1 -0
- package/dist/core/share/canonical/to-claude.d.ts +15 -0
- package/dist/core/share/canonical/to-claude.d.ts.map +1 -0
- package/dist/core/share/canonical/to-claude.js +146 -0
- package/dist/core/share/canonical/to-claude.js.map +1 -0
- package/dist/core/share/canonical/to-codex.d.ts +21 -0
- package/dist/core/share/canonical/to-codex.d.ts.map +1 -0
- package/dist/core/share/canonical/to-codex.js +124 -0
- package/dist/core/share/canonical/to-codex.js.map +1 -0
- package/dist/core/share/canonical/tool-map.d.ts +61 -0
- package/dist/core/share/canonical/tool-map.d.ts.map +1 -0
- package/dist/core/share/canonical/tool-map.js +299 -0
- package/dist/core/share/canonical/tool-map.js.map +1 -0
- package/dist/core/share/canonical/types.d.ts +57 -0
- package/dist/core/share/canonical/types.d.ts.map +1 -0
- package/dist/core/share/canonical/types.js +9 -0
- package/dist/core/share/canonical/types.js.map +1 -0
- package/dist/core/share/import.d.ts +28 -0
- package/dist/core/share/import.d.ts.map +1 -0
- package/dist/core/share/import.js +174 -0
- package/dist/core/share/import.js.map +1 -0
- package/dist/core/share/manifest.d.ts +37 -0
- package/dist/core/share/manifest.d.ts.map +1 -0
- package/dist/core/share/manifest.js +31 -0
- package/dist/core/share/manifest.js.map +1 -0
- package/dist/core/share/preview.d.ts +4 -0
- package/dist/core/share/preview.d.ts.map +1 -0
- package/dist/core/share/preview.js +153 -0
- package/dist/core/share/preview.js.map +1 -0
- package/dist/core/share/primer.d.ts +19 -0
- package/dist/core/share/primer.d.ts.map +1 -0
- package/dist/core/share/primer.js +196 -0
- package/dist/core/share/primer.js.map +1 -0
- package/dist/core/share/resume.d.ts +10 -0
- package/dist/core/share/resume.d.ts.map +1 -0
- package/dist/core/share/resume.js +58 -0
- package/dist/core/share/resume.js.map +1 -0
- package/dist/core/share/scrub.d.ts +10 -0
- package/dist/core/share/scrub.d.ts.map +1 -0
- package/dist/core/share/scrub.js +198 -0
- package/dist/core/share/scrub.js.map +1 -0
- package/dist/core/share/tar.d.ts +12 -0
- package/dist/core/share/tar.d.ts.map +1 -0
- package/dist/core/share/tar.js +78 -0
- package/dist/core/share/tar.js.map +1 -0
- package/dist/core/tags/index.d.ts +48 -0
- package/dist/core/tags/index.d.ts.map +1 -0
- package/dist/core/tags/index.js +113 -0
- package/dist/core/tags/index.js.map +1 -0
- package/dist/core/today/index.d.ts +25 -0
- package/dist/core/today/index.d.ts.map +1 -0
- package/dist/core/today/index.js +42 -0
- package/dist/core/today/index.js.map +1 -0
- package/dist/core/waste/abandoned.d.ts +12 -0
- package/dist/core/waste/abandoned.d.ts.map +1 -0
- package/dist/core/waste/abandoned.js +127 -0
- package/dist/core/waste/abandoned.js.map +1 -0
- package/dist/core/waste/cache-miss.d.ts +9 -0
- package/dist/core/waste/cache-miss.d.ts.map +1 -0
- package/dist/core/waste/cache-miss.js +84 -0
- package/dist/core/waste/cache-miss.js.map +1 -0
- package/dist/core/waste/index.d.ts +12 -0
- package/dist/core/waste/index.d.ts.map +1 -0
- package/dist/core/waste/index.js +45 -0
- package/dist/core/waste/index.js.map +1 -0
- package/dist/core/waste/wrong-model.d.ts +11 -0
- package/dist/core/waste/wrong-model.d.ts.map +1 -0
- package/dist/core/waste/wrong-model.js +104 -0
- package/dist/core/waste/wrong-model.js.map +1 -0
- package/dist/db/index.d.ts +10 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +29 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/migrate.d.ts +8 -0
- package/dist/db/migrate.d.ts.map +1 -0
- package/dist/db/migrate.js +282 -0
- package/dist/db/migrate.js.map +1 -0
- package/dist/server/events.d.ts +4 -0
- package/dist/server/events.d.ts.map +1 -0
- package/dist/server/events.js +54 -0
- package/dist/server/events.js.map +1 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +238 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/routes/foundation.d.ts +2 -0
- package/dist/server/routes/foundation.d.ts.map +1 -0
- package/dist/server/routes/foundation.js +2 -0
- package/dist/server/routes/foundation.js.map +1 -0
- package/dist/server/routes/search.d.ts +2 -0
- package/dist/server/routes/search.d.ts.map +1 -0
- package/dist/server/routes/search.js +2 -0
- package/dist/server/routes/search.js.map +1 -0
- package/dist/server/routes/sessions.d.ts +2 -0
- package/dist/server/routes/sessions.d.ts.map +1 -0
- package/dist/server/routes/sessions.js +2 -0
- package/dist/server/routes/sessions.js.map +1 -0
- package/dist/server/routes/waste.d.ts +2 -0
- package/dist/server/routes/waste.d.ts.map +1 -0
- package/dist/server/routes/waste.js +2 -0
- package/dist/server/routes/waste.js.map +1 -0
- package/dist/web/assets/index-Ba1VvTj0.js +37 -0
- package/dist/web/index.html +12 -0
- package/package.json +76 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bidirectional tool name + argument-shape mapping between Claude and Codex.
|
|
3
|
+
*
|
|
4
|
+
* Source of truth for mappings: see plan tool-mapping table. Shapes verified
|
|
5
|
+
* against real session data (~/.codex/sessions/...) AND upstream openai/codex
|
|
6
|
+
* Rust enum (codex-rs/protocol/src/models.rs).
|
|
7
|
+
*
|
|
8
|
+
* "Faithful" mappings round-trip cleanly. "Best-effort" mappings preserve
|
|
9
|
+
* semantics but may produce slightly different surface text. "Wrapped" mappings
|
|
10
|
+
* preserve the original tool name + args as printable text inside a no-op shell
|
|
11
|
+
* call — full data is recoverable but the receiving agent sees only "shell".
|
|
12
|
+
*/
|
|
13
|
+
const WRAP_TAG = '[vyasa] preserved tool call:';
|
|
14
|
+
/**
|
|
15
|
+
* Translate one Claude tool_use block into a Codex response_item payload.
|
|
16
|
+
* Returns the appropriate payload kind (function_call vs custom_tool_call).
|
|
17
|
+
*/
|
|
18
|
+
export function claudeToolToCodex(tool, args) {
|
|
19
|
+
switch (tool) {
|
|
20
|
+
case 'Bash': {
|
|
21
|
+
const command = stringField(args, 'command') ?? '';
|
|
22
|
+
return {
|
|
23
|
+
kind: 'function_call',
|
|
24
|
+
name: 'exec_command',
|
|
25
|
+
arguments: JSON.stringify({
|
|
26
|
+
cmd: command,
|
|
27
|
+
workdir: stringField(args, 'workdir') ?? '.',
|
|
28
|
+
yield_time_ms: 1000,
|
|
29
|
+
max_output_tokens: 2000,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
case 'Read': {
|
|
34
|
+
const filePath = stringField(args, 'file_path') ?? stringField(args, 'path') ?? '';
|
|
35
|
+
return {
|
|
36
|
+
kind: 'function_call',
|
|
37
|
+
name: 'exec_command',
|
|
38
|
+
arguments: JSON.stringify({
|
|
39
|
+
cmd: `cat ${shellQuote(filePath)}`,
|
|
40
|
+
workdir: '.',
|
|
41
|
+
yield_time_ms: 1000,
|
|
42
|
+
max_output_tokens: 2000,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
case 'Write': {
|
|
47
|
+
const filePath = stringField(args, 'file_path') ?? '';
|
|
48
|
+
const content = stringField(args, 'content') ?? '';
|
|
49
|
+
return {
|
|
50
|
+
kind: 'custom_tool_call',
|
|
51
|
+
name: 'apply_patch',
|
|
52
|
+
input: buildAddFilePatch(filePath, content),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
case 'Edit': {
|
|
56
|
+
const filePath = stringField(args, 'file_path') ?? '';
|
|
57
|
+
const oldString = stringField(args, 'old_string') ?? '';
|
|
58
|
+
const newString = stringField(args, 'new_string') ?? '';
|
|
59
|
+
return {
|
|
60
|
+
kind: 'custom_tool_call',
|
|
61
|
+
name: 'apply_patch',
|
|
62
|
+
input: buildUpdateFilePatch(filePath, oldString, newString),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
case 'Glob': {
|
|
66
|
+
const pattern = stringField(args, 'pattern') ?? '';
|
|
67
|
+
const path = stringField(args, 'path') ?? '.';
|
|
68
|
+
return {
|
|
69
|
+
kind: 'function_call',
|
|
70
|
+
name: 'exec_command',
|
|
71
|
+
arguments: JSON.stringify({
|
|
72
|
+
cmd: `find ${shellQuote(path)} -name ${shellQuote(pattern)}`,
|
|
73
|
+
workdir: '.',
|
|
74
|
+
yield_time_ms: 1000,
|
|
75
|
+
max_output_tokens: 2000,
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
case 'Grep': {
|
|
80
|
+
const pattern = stringField(args, 'pattern') ?? '';
|
|
81
|
+
const path = stringField(args, 'path') ?? '.';
|
|
82
|
+
return {
|
|
83
|
+
kind: 'function_call',
|
|
84
|
+
name: 'exec_command',
|
|
85
|
+
arguments: JSON.stringify({
|
|
86
|
+
cmd: `grep -r ${shellQuote(pattern)} ${shellQuote(path)}`,
|
|
87
|
+
workdir: '.',
|
|
88
|
+
yield_time_ms: 1000,
|
|
89
|
+
max_output_tokens: 2000,
|
|
90
|
+
}),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
default:
|
|
94
|
+
return wrapUnknownAsCodex(tool, args);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export function codexCallToClaude(payload) {
|
|
98
|
+
if (payload.kind === 'function_call') {
|
|
99
|
+
if (payload.name === 'exec_command') {
|
|
100
|
+
const args = parseArgs(payload.arguments);
|
|
101
|
+
const cmd = args['cmd'] ?? '';
|
|
102
|
+
// Recognise the wrap tag and unwrap if present
|
|
103
|
+
const unwrapped = unwrapShellEcho(cmd);
|
|
104
|
+
if (unwrapped)
|
|
105
|
+
return unwrapped;
|
|
106
|
+
return {
|
|
107
|
+
name: 'Bash',
|
|
108
|
+
input: { command: cmd, description: '' },
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Other function_call names (e.g. write_stdin) → wrap as Bash echo with preserved args
|
|
112
|
+
return wrapUnknownAsClaudeBash(payload.name, parseArgs(payload.arguments));
|
|
113
|
+
}
|
|
114
|
+
// custom_tool_call
|
|
115
|
+
if (payload.name === 'apply_patch') {
|
|
116
|
+
const parsed = parseApplyPatch(payload.input);
|
|
117
|
+
if (parsed)
|
|
118
|
+
return parsed;
|
|
119
|
+
// Couldn't parse patch — wrap it so nothing is lost
|
|
120
|
+
return wrapUnknownAsClaudeBash('apply_patch', { input: payload.input });
|
|
121
|
+
}
|
|
122
|
+
return wrapUnknownAsClaudeBash(payload.name, { input: payload.input });
|
|
123
|
+
}
|
|
124
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
125
|
+
function stringField(obj, key) {
|
|
126
|
+
const v = obj[key];
|
|
127
|
+
return typeof v === 'string' ? v : undefined;
|
|
128
|
+
}
|
|
129
|
+
function shellQuote(s) {
|
|
130
|
+
// Single-quote and escape any embedded single quotes
|
|
131
|
+
return `'${s.replace(/'/g, `'"'"'`)}'`;
|
|
132
|
+
}
|
|
133
|
+
function parseArgs(stringified) {
|
|
134
|
+
try {
|
|
135
|
+
const parsed = JSON.parse(stringified);
|
|
136
|
+
if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
137
|
+
return parsed;
|
|
138
|
+
}
|
|
139
|
+
return { _raw: stringified };
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return { _raw: stringified };
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function buildAddFilePatch(filePath, content) {
|
|
146
|
+
const lines = content.split('\n');
|
|
147
|
+
const body = lines.map((l) => `+${l}`).join('\n');
|
|
148
|
+
return `*** Begin Patch\n*** Add File: ${filePath}\n${body}\n*** End Patch`;
|
|
149
|
+
}
|
|
150
|
+
function buildUpdateFilePatch(filePath, oldStr, newStr) {
|
|
151
|
+
const oldLines = oldStr.split('\n').map((l) => `-${l}`).join('\n');
|
|
152
|
+
const newLines = newStr.split('\n').map((l) => `+${l}`).join('\n');
|
|
153
|
+
return [
|
|
154
|
+
`*** Begin Patch`,
|
|
155
|
+
`*** Update File: ${filePath}`,
|
|
156
|
+
`@@`,
|
|
157
|
+
oldLines,
|
|
158
|
+
newLines,
|
|
159
|
+
`*** End Patch`,
|
|
160
|
+
].join('\n');
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Parse an apply_patch input to a Claude tool_use call. Returns null if the patch
|
|
164
|
+
* shape is unrecognized (caller should wrap).
|
|
165
|
+
*/
|
|
166
|
+
export function parseApplyPatch(input) {
|
|
167
|
+
const lines = input.split('\n');
|
|
168
|
+
// Find the file action
|
|
169
|
+
let action = null;
|
|
170
|
+
let filePath = '';
|
|
171
|
+
for (const line of lines) {
|
|
172
|
+
const add = line.match(/^\*\*\* Add File: (.+)$/);
|
|
173
|
+
if (add) {
|
|
174
|
+
action = 'add';
|
|
175
|
+
filePath = add[1];
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
const upd = line.match(/^\*\*\* Update File: (.+)$/);
|
|
179
|
+
if (upd) {
|
|
180
|
+
action = 'update';
|
|
181
|
+
filePath = upd[1];
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (!action || !filePath)
|
|
186
|
+
return null;
|
|
187
|
+
if (action === 'add') {
|
|
188
|
+
// Collect all `+` lines after the Add File header until *** End Patch or another *** marker
|
|
189
|
+
const contentLines = [];
|
|
190
|
+
let collecting = false;
|
|
191
|
+
for (const line of lines) {
|
|
192
|
+
if (line.startsWith('*** Add File:')) {
|
|
193
|
+
collecting = true;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (!collecting)
|
|
197
|
+
continue;
|
|
198
|
+
if (line.startsWith('***'))
|
|
199
|
+
break;
|
|
200
|
+
if (line.startsWith('+'))
|
|
201
|
+
contentLines.push(line.slice(1));
|
|
202
|
+
else if (line === '')
|
|
203
|
+
contentLines.push('');
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
name: 'Write',
|
|
207
|
+
input: { file_path: filePath, content: contentLines.join('\n') },
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
// Update: collect first `-` block (old) and first `+` block (new) within first hunk
|
|
211
|
+
const minusLines = [];
|
|
212
|
+
const plusLines = [];
|
|
213
|
+
let inHunk = false;
|
|
214
|
+
for (const line of lines) {
|
|
215
|
+
if (line.startsWith('@@')) {
|
|
216
|
+
inHunk = true;
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (!inHunk)
|
|
220
|
+
continue;
|
|
221
|
+
if (line.startsWith('***'))
|
|
222
|
+
break;
|
|
223
|
+
if (line.startsWith('-'))
|
|
224
|
+
minusLines.push(line.slice(1));
|
|
225
|
+
else if (line.startsWith('+'))
|
|
226
|
+
plusLines.push(line.slice(1));
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
name: 'Edit',
|
|
230
|
+
input: {
|
|
231
|
+
file_path: filePath,
|
|
232
|
+
old_string: minusLines.join('\n'),
|
|
233
|
+
new_string: plusLines.join('\n'),
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
// ─── Wrapping unknown tools ───────────────────────────────────────────────────
|
|
238
|
+
// We preserve the original tool name + args as printable text inside a shell echo.
|
|
239
|
+
// On the reverse trip, unwrapShellEcho recovers them.
|
|
240
|
+
function wrapUnknownAsCodex(tool, args) {
|
|
241
|
+
const payload = JSON.stringify({ tool, args });
|
|
242
|
+
// Single-line echo with the JSON as a single-quoted string
|
|
243
|
+
return {
|
|
244
|
+
kind: 'function_call',
|
|
245
|
+
name: 'exec_command',
|
|
246
|
+
arguments: JSON.stringify({
|
|
247
|
+
cmd: `echo ${shellQuote(`${WRAP_TAG} ${payload}`)}`,
|
|
248
|
+
workdir: '.',
|
|
249
|
+
yield_time_ms: 1000,
|
|
250
|
+
max_output_tokens: 2000,
|
|
251
|
+
}),
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function wrapUnknownAsClaudeBash(tool, args) {
|
|
255
|
+
const payload = JSON.stringify({ tool, args });
|
|
256
|
+
return {
|
|
257
|
+
name: 'Bash',
|
|
258
|
+
input: {
|
|
259
|
+
command: `echo ${shellQuote(`${WRAP_TAG} ${payload}`)}`,
|
|
260
|
+
description: `Preserved ${tool} call from cross-platform translation`,
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* If `cmd` is one of our wrap-tag echoes, recover the original tool + args.
|
|
266
|
+
* Returns null if `cmd` isn't a recognized wrap.
|
|
267
|
+
*/
|
|
268
|
+
function unwrapShellEcho(cmd) {
|
|
269
|
+
// Match: echo '<WRAP_TAG> <json-with-escaped-quotes>'
|
|
270
|
+
const match = cmd.match(/^echo '(.+)'$/s);
|
|
271
|
+
if (!match)
|
|
272
|
+
return null;
|
|
273
|
+
const body = match[1];
|
|
274
|
+
const tagIdx = body.indexOf(WRAP_TAG);
|
|
275
|
+
if (tagIdx !== 0)
|
|
276
|
+
return null;
|
|
277
|
+
const jsonPart = body.slice(WRAP_TAG.length).trim();
|
|
278
|
+
// Reverse the single-quote escaping from shellQuote
|
|
279
|
+
const unescaped = jsonPart.replace(/'"'"'/g, `'`);
|
|
280
|
+
try {
|
|
281
|
+
const parsed = JSON.parse(unescaped);
|
|
282
|
+
if (typeof parsed.tool === 'string' && parsed.args && typeof parsed.args === 'object') {
|
|
283
|
+
return { name: parsed.tool, input: parsed.args };
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
/* fallthrough */
|
|
288
|
+
}
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
// Exported for tests
|
|
292
|
+
export const _internal = {
|
|
293
|
+
buildAddFilePatch,
|
|
294
|
+
buildUpdateFilePatch,
|
|
295
|
+
shellQuote,
|
|
296
|
+
unwrapShellEcho,
|
|
297
|
+
WRAP_TAG,
|
|
298
|
+
};
|
|
299
|
+
//# sourceMappingURL=tool-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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U;IACV,eAAe;IACf,QAAQ;CACT,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-neutral session representation.
|
|
3
|
+
*
|
|
4
|
+
* Used as the intermediate for cross-platform translation (Claude ↔ Codex).
|
|
5
|
+
* Designed to be lossless for the records we round-trip — see plan for fidelity
|
|
6
|
+
* notes per block kind.
|
|
7
|
+
*/
|
|
8
|
+
export type Platform = 'claude-code' | 'codex';
|
|
9
|
+
export interface CanonicalSession {
|
|
10
|
+
sessionId: string;
|
|
11
|
+
platform: Platform;
|
|
12
|
+
/** Source `cwd` from session_meta (Codex) or first user record's `cwd` (Claude). */
|
|
13
|
+
project: string | null;
|
|
14
|
+
/** ISO timestamp of the first user-facing block. */
|
|
15
|
+
startedAt: string | null;
|
|
16
|
+
/** ISO timestamp of the last user-facing block. */
|
|
17
|
+
endedAt: string | null;
|
|
18
|
+
/** Source CLI version if known (e.g. "0.125.0" for Codex). Used for provenance/debugging. */
|
|
19
|
+
sourceCliVersion: string | null;
|
|
20
|
+
blocks: CanonicalBlock[];
|
|
21
|
+
}
|
|
22
|
+
export type CanonicalBlock = {
|
|
23
|
+
kind: 'user_text';
|
|
24
|
+
text: string;
|
|
25
|
+
ts: string;
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'assistant_text';
|
|
28
|
+
text: string;
|
|
29
|
+
ts: string;
|
|
30
|
+
model?: string;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'tool_call';
|
|
33
|
+
tool: string;
|
|
34
|
+
args: Record<string, unknown>;
|
|
35
|
+
callId: string;
|
|
36
|
+
ts: string;
|
|
37
|
+
model?: string;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'tool_result';
|
|
40
|
+
callId: string;
|
|
41
|
+
output: string;
|
|
42
|
+
isError?: boolean;
|
|
43
|
+
ts: string;
|
|
44
|
+
} | {
|
|
45
|
+
kind: 'system_text';
|
|
46
|
+
text: string;
|
|
47
|
+
subtype?: string;
|
|
48
|
+
ts: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'thinking';
|
|
51
|
+
text: string;
|
|
52
|
+
ts: string;
|
|
53
|
+
} | {
|
|
54
|
+
kind: 'reasoning_opaque';
|
|
55
|
+
ts: string;
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/core/share/canonical/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,QAAQ,GAAG,aAAa,GAAG,OAAO,CAAA;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,QAAQ,CAAA;IAClB,oFAAoF;IACpF,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,oDAAoD;IACpD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,mDAAmD;IACnD,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,6FAA6F;IAC7F,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB;AAED,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAQ,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,WAAW,CAAC;IAAQ,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACrH;IAAE,IAAI,EAAE,aAAa,CAAC;IAAM,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC3F;IAAE,IAAI,EAAE,aAAa,CAAC;IAAM,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACxE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAS,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-neutral session representation.
|
|
3
|
+
*
|
|
4
|
+
* Used as the intermediate for cross-platform translation (Claude ↔ Codex).
|
|
5
|
+
* Designed to be lossless for the records we round-trip — see plan for fidelity
|
|
6
|
+
* notes per block kind.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/core/share/canonical/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Database from 'better-sqlite3';
|
|
2
|
+
import { type Manifest } from './manifest.js';
|
|
3
|
+
import type { Platform } from './canonical/types.js';
|
|
4
|
+
export interface ImportResult {
|
|
5
|
+
/** The platform the session was placed for (may differ from source if --to was used). */
|
|
6
|
+
platform: Platform;
|
|
7
|
+
/** Source platform from the bundle's manifest. */
|
|
8
|
+
sourcePlatform: Platform;
|
|
9
|
+
sessionId: string;
|
|
10
|
+
placedAt: string;
|
|
11
|
+
alreadyExisted: boolean;
|
|
12
|
+
/** True when receiver translated the JSONL across platforms. */
|
|
13
|
+
translated: boolean;
|
|
14
|
+
/** Where the bundled plan file was re-linked (if any). */
|
|
15
|
+
planPlacedAt?: string;
|
|
16
|
+
/** True when the bundle's tags/custom name were restored into the local DB. */
|
|
17
|
+
metaRestored?: boolean;
|
|
18
|
+
manifest: Manifest;
|
|
19
|
+
}
|
|
20
|
+
export declare class ImportError extends Error {
|
|
21
|
+
constructor(msg: string);
|
|
22
|
+
}
|
|
23
|
+
export declare function importBundle(bundlePath: string, opts?: {
|
|
24
|
+
home?: string;
|
|
25
|
+
toPlatform?: Platform;
|
|
26
|
+
db?: Database.Database;
|
|
27
|
+
}): ImportResult;
|
|
28
|
+
//# sourceMappingURL=import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../../src/core/share/import.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAA;AAOrC,OAAO,EAAoB,KAAK,QAAQ,EAAiB,MAAM,eAAe,CAAA;AAK9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAEpD,MAAM,WAAW,YAAY;IAC3B,yFAAyF;IACzF,QAAQ,EAAE,QAAQ,CAAA;IAClB,kDAAkD;IAClD,cAAc,EAAE,QAAQ,CAAA;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,OAAO,CAAA;IACvB,gEAAgE;IAChE,UAAU,EAAE,OAAO,CAAA;IACnB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,+EAA+E;IAC/E,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAED,qBAAa,WAAY,SAAQ,KAAK;gBACxB,GAAG,EAAE,MAAM;CAIxB;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,QAAQ,CAAC;IAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAA;CAAO,GAC1E,YAAY,CA+Hd"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { gunzipSync } from 'node:zlib';
|
|
2
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, statSync, utimesSync } from 'node:fs';
|
|
3
|
+
import { join, dirname, basename } from 'node:path';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { tarUnpack } from './tar.js';
|
|
6
|
+
import { restoreSessionMeta } from '../tags/index.js';
|
|
7
|
+
import { validateManifest, ManifestError } from './manifest.js';
|
|
8
|
+
import { fromClaudeJsonl } from './canonical/from-claude.js';
|
|
9
|
+
import { fromCodexJsonl } from './canonical/from-codex.js';
|
|
10
|
+
import { toClaudeJsonl } from './canonical/to-claude.js';
|
|
11
|
+
import { toCodexJsonl } from './canonical/to-codex.js';
|
|
12
|
+
export class ImportError extends Error {
|
|
13
|
+
constructor(msg) {
|
|
14
|
+
super(msg);
|
|
15
|
+
this.name = 'ImportError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function importBundle(bundlePath, opts = {}) {
|
|
19
|
+
const home = opts.home ?? homedir();
|
|
20
|
+
let bundleData;
|
|
21
|
+
try {
|
|
22
|
+
bundleData = readFileSync(bundlePath);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
throw new ImportError(`cannot read bundle file ${bundlePath}: ${err.message}`);
|
|
26
|
+
}
|
|
27
|
+
let tarData;
|
|
28
|
+
try {
|
|
29
|
+
tarData = gunzipSync(bundleData);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
throw new ImportError(`bundle is not a valid gzip stream: ${err.message}`);
|
|
33
|
+
}
|
|
34
|
+
const entries = tarUnpack(tarData);
|
|
35
|
+
const manifestEntry = entries.find((e) => e.name === 'manifest.json');
|
|
36
|
+
const sessionEntry = entries.find((e) => e.name === 'session.jsonl');
|
|
37
|
+
if (!manifestEntry)
|
|
38
|
+
throw new ImportError('bundle missing manifest.json');
|
|
39
|
+
if (!sessionEntry)
|
|
40
|
+
throw new ImportError('bundle missing session.jsonl');
|
|
41
|
+
let manifest;
|
|
42
|
+
try {
|
|
43
|
+
const raw = JSON.parse(manifestEntry.data.toString('utf8'));
|
|
44
|
+
manifest = validateManifest(raw);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
if (err instanceof ManifestError)
|
|
48
|
+
throw new ImportError(err.message);
|
|
49
|
+
throw new ImportError(`manifest.json malformed: ${err.message}`);
|
|
50
|
+
}
|
|
51
|
+
// Cursor sessions aren't exportable as .vyasa bundles today (no canonical
|
|
52
|
+
// adapter, no portable JSONL). If we ever see one in an imported bundle,
|
|
53
|
+
// refuse early rather than crash deeper in the translator.
|
|
54
|
+
if (manifest.platform === 'cursor') {
|
|
55
|
+
throw new ImportError('Cursor bundles are not supported for import.');
|
|
56
|
+
}
|
|
57
|
+
const sourcePlatform = manifest.platform;
|
|
58
|
+
if (sessionEntry.data.length !== manifest.jsonlSizeBytes) {
|
|
59
|
+
throw new ImportError(`jsonl size mismatch (manifest=${manifest.jsonlSizeBytes}, actual=${sessionEntry.data.length})`);
|
|
60
|
+
}
|
|
61
|
+
const effectivePlatform = opts.toPlatform ?? sourcePlatform;
|
|
62
|
+
const translated = effectivePlatform !== sourcePlatform;
|
|
63
|
+
// Translate JSONL if requested
|
|
64
|
+
let payload;
|
|
65
|
+
if (translated) {
|
|
66
|
+
const sourceText = sessionEntry.data.toString('utf8');
|
|
67
|
+
const canonical = sourcePlatform === 'claude-code'
|
|
68
|
+
? fromClaudeJsonl(sourceText)
|
|
69
|
+
: fromCodexJsonl(sourceText);
|
|
70
|
+
const rendered = effectivePlatform === 'claude-code'
|
|
71
|
+
? toClaudeJsonl(canonical)
|
|
72
|
+
: toCodexJsonl(canonical);
|
|
73
|
+
payload = Buffer.from(rendered, 'utf8');
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
payload = sessionEntry.data;
|
|
77
|
+
}
|
|
78
|
+
const targetPath = resolveTargetPath(home, manifest, effectivePlatform);
|
|
79
|
+
// Idempotency: only meaningful for verbatim placement; translated bytes won't
|
|
80
|
+
// match a previously-translated file's mtime, so we always re-place on translation.
|
|
81
|
+
let alreadyExisted = false;
|
|
82
|
+
if (!translated && existsSync(targetPath)) {
|
|
83
|
+
const existingMtime = statSync(targetPath).mtimeMs;
|
|
84
|
+
if (Math.abs(existingMtime - manifest.originalMtimeMs) < 1000) {
|
|
85
|
+
alreadyExisted = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!alreadyExisted) {
|
|
89
|
+
mkdirSync(dirname(targetPath), { recursive: true });
|
|
90
|
+
writeFileSync(targetPath, payload);
|
|
91
|
+
if (!translated) {
|
|
92
|
+
try {
|
|
93
|
+
const t = new Date(manifest.originalMtimeMs);
|
|
94
|
+
utimesSync(targetPath, t, t);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// Non-fatal: mtime preservation is best-effort
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Re-link the bundled plan file so the recipient can continue it. Claude Code
|
|
102
|
+
// only — plan files live at ~/.claude/plans/<slug>.md.
|
|
103
|
+
let planPlacedAt;
|
|
104
|
+
if (effectivePlatform === 'claude-code' && manifest.planFile) {
|
|
105
|
+
const planEntry = entries.find((e) => e.name === `plan/${manifest.planFile.slug}.md`);
|
|
106
|
+
if (planEntry) {
|
|
107
|
+
const planDest = join(home, '.claude', 'plans', `${manifest.planFile.slug}.md`);
|
|
108
|
+
mkdirSync(dirname(planDest), { recursive: true });
|
|
109
|
+
writeFileSync(planDest, planEntry.data);
|
|
110
|
+
planPlacedAt = planDest;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Restore vyasa tags + custom name so the imported session arrives labeled.
|
|
114
|
+
// FK-free metadata tables mean this works even before the session is indexed.
|
|
115
|
+
let metaRestored = false;
|
|
116
|
+
if (opts.db && (manifest.customName || (manifest.tags && manifest.tags.length > 0))) {
|
|
117
|
+
restoreSessionMeta(opts.db, manifest.sessionId, {
|
|
118
|
+
customName: manifest.customName ?? null,
|
|
119
|
+
tags: manifest.tags ?? [],
|
|
120
|
+
});
|
|
121
|
+
metaRestored = true;
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
platform: effectivePlatform,
|
|
125
|
+
sourcePlatform,
|
|
126
|
+
sessionId: manifest.sessionId,
|
|
127
|
+
placedAt: targetPath,
|
|
128
|
+
alreadyExisted,
|
|
129
|
+
translated,
|
|
130
|
+
planPlacedAt,
|
|
131
|
+
metaRestored,
|
|
132
|
+
manifest,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function resolveTargetPath(home, m, effective) {
|
|
136
|
+
if (effective === 'claude-code') {
|
|
137
|
+
// For translated bundles into Claude, m.projectDir may be empty (came from Codex).
|
|
138
|
+
// Synthesize a directory name from the project path or fall back to '_imported'.
|
|
139
|
+
const projectDir = m.projectDir || encodeProjectDir(m.project) || '_imported';
|
|
140
|
+
return join(home, '.claude', 'projects', projectDir, `${m.sessionId}.jsonl`);
|
|
141
|
+
}
|
|
142
|
+
// Codex: derive YYYY/MM/DD from the original path/filename, or synthesize a fresh
|
|
143
|
+
// path when translating Claude→Codex (Claude paths don't encode date).
|
|
144
|
+
if (effective === m.platform) {
|
|
145
|
+
// Same-platform Codex import — use original date hints
|
|
146
|
+
const filename = basename(m.originalPath);
|
|
147
|
+
const pathMatch = m.originalPath.match(/sessions\/(\d{4})\/(\d{2})\/(\d{2})\//);
|
|
148
|
+
if (pathMatch) {
|
|
149
|
+
const [, yyyy, mm, dd] = pathMatch;
|
|
150
|
+
return join(home, '.codex', 'sessions', yyyy, mm, dd, filename);
|
|
151
|
+
}
|
|
152
|
+
const fnMatch = filename.match(/^rollout-(\d{4})-(\d{2})-(\d{2})T/);
|
|
153
|
+
if (fnMatch) {
|
|
154
|
+
const [, yyyy, mm, dd] = fnMatch;
|
|
155
|
+
return join(home, '.codex', 'sessions', yyyy, mm, dd, filename);
|
|
156
|
+
}
|
|
157
|
+
return join(home, '.codex', 'sessions', '_imported', filename);
|
|
158
|
+
}
|
|
159
|
+
// Translated Claude→Codex: synthesize a rollout filename + path from current time
|
|
160
|
+
const now = new Date();
|
|
161
|
+
const yyyy = String(now.getUTCFullYear());
|
|
162
|
+
const mm = String(now.getUTCMonth() + 1).padStart(2, '0');
|
|
163
|
+
const dd = String(now.getUTCDate()).padStart(2, '0');
|
|
164
|
+
const isoCompact = now.toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
165
|
+
const filename = `rollout-${isoCompact}-${m.sessionId}.jsonl`;
|
|
166
|
+
return join(home, '.codex', 'sessions', yyyy, mm, dd, filename);
|
|
167
|
+
}
|
|
168
|
+
function encodeProjectDir(project) {
|
|
169
|
+
if (!project)
|
|
170
|
+
return null;
|
|
171
|
+
// Mirror Claude Code's encoding: replace '/' with '-'
|
|
172
|
+
return project.replace(/\//g, '-');
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../../src/core/share/import.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAClG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACpC,O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ScrubReport } from '../schema/index.js';
|
|
2
|
+
export declare const MANIFEST_SCHEMA_VERSION = 1;
|
|
3
|
+
export interface Manifest {
|
|
4
|
+
schema: 1;
|
|
5
|
+
/** Cursor sessions cannot currently be exported via .vyasa bundles (the
|
|
6
|
+
* share button is hidden in the UI), but the manifest type accepts it so
|
|
7
|
+
* future Cursor-export work doesn't require a schema bump. */
|
|
8
|
+
platform: 'claude-code' | 'codex' | 'cursor';
|
|
9
|
+
sessionId: string;
|
|
10
|
+
project: string;
|
|
11
|
+
/** For claude-code: the encoded project directory name (e.g. "-Users-abhinav-Desktop-foo").
|
|
12
|
+
* For codex: empty string — placement uses date-derived directories instead. */
|
|
13
|
+
projectDir: string;
|
|
14
|
+
originalPath: string;
|
|
15
|
+
originalMtimeMs: number;
|
|
16
|
+
exportedAt: string;
|
|
17
|
+
exportedBy: string;
|
|
18
|
+
/** Byte length of the (possibly scrubbed) session.jsonl actually packed. */
|
|
19
|
+
jsonlSizeBytes: number;
|
|
20
|
+
/** Present when the session JSONL was scrubbed on export (claude-code default). Additive/optional → schema stays 1. */
|
|
21
|
+
scrubReport?: ScrubReport;
|
|
22
|
+
/** Present when the session's plan file was bundled (tar entry `plan/<slug>.md`). */
|
|
23
|
+
planFile?: {
|
|
24
|
+
slug: string;
|
|
25
|
+
originalPath: string;
|
|
26
|
+
sizeBytes: number;
|
|
27
|
+
};
|
|
28
|
+
/** vyasa custom name override, so a shared session arrives named. */
|
|
29
|
+
customName?: string | null;
|
|
30
|
+
/** vyasa tags, so a shared session arrives tagged (e.g. attached to a PR). */
|
|
31
|
+
tags?: string[];
|
|
32
|
+
}
|
|
33
|
+
export declare class ManifestError extends Error {
|
|
34
|
+
constructor(msg: string);
|
|
35
|
+
}
|
|
36
|
+
export declare function validateManifest(raw: unknown): Manifest;
|
|
37
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/core/share/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,eAAO,MAAM,uBAAuB,IAAI,CAAA;AAExC,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,CAAC,CAAA;IACT;;mEAE+D;IAC/D,QAAQ,EAAE,aAAa,GAAG,OAAO,GAAG,QAAQ,CAAA;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf;qFACiF;IACjF,UAAU,EAAE,MAAM,CAAA;IAClB,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,4EAA4E;IAC5E,cAAc,EAAE,MAAM,CAAA;IACtB,uHAAuH;IACvH,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,qFAAqF;IACrF,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;IACpE,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,8EAA8E;IAC9E,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,GAAG,EAAE,MAAM;CAIxB;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,QAAQ,CAsBvD"}
|