spec-cat 0.1.63 → 0.1.65
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/.output/nitro.json +1 -1
- package/.output/public/_nuxt/B-bFNWCF.js +43 -0
- package/.output/public/_nuxt/{D4LyIv_t.js → BEWSHKZd.js} +1 -1
- package/.output/public/_nuxt/{Su-Cl_JF.js → BHhMtuRK.js} +1 -1
- package/.output/public/_nuxt/{DwpuOtAP.js → BwRpECPL.js} +1 -1
- package/.output/public/_nuxt/{FfyCVKRU.js → CC_9aMCT.js} +1 -1
- package/.output/public/_nuxt/CHHbeXzh.js +1 -0
- package/.output/public/_nuxt/{DIOhMCOf.js → CzV__9yP.js} +3 -3
- package/.output/public/_nuxt/{Bz2rU2zs.js → DWDrIutw.js} +1 -1
- package/.output/public/_nuxt/D_4Ow2w2.js +1 -0
- package/.output/public/_nuxt/D_T_F7lf.js +1 -0
- package/.output/public/_nuxt/{DPOGSCeV.js → DqFq1MXh.js} +1 -1
- package/.output/public/_nuxt/YzuyFhrD.js +174 -0
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/cdc4ded8-9ff7-4e22-abbe-3b8c94caa781.json +1 -0
- package/.output/public/_nuxt/default.Cyeq1Er8.css +1 -0
- package/.output/public/_nuxt/entry.uBSFaL6A.css +1 -0
- package/.output/public/_nuxt/{useTheme.Cny4Z64J.css → useTheme.B4wINCoW.css} +1 -1
- package/.output/public/_nuxt/uyJF9wDo.js +58 -0
- package/.output/server/chunks/_/aiProviderRegistry.mjs +1 -2
- package/.output/server/chunks/_/aiProviderRegistry.mjs.map +1 -1
- package/.output/server/chunks/_/aiProviderSelection.mjs +2 -2
- package/.output/server/chunks/_/chatGit.mjs +1 -2
- package/.output/server/chunks/_/chatGit.mjs.map +1 -1
- package/.output/server/chunks/_/claudeProvider.mjs +1 -215
- package/.output/server/chunks/_/claudeProvider.mjs.map +1 -1
- package/.output/server/chunks/_/claudeService.mjs +50 -54
- package/.output/server/chunks/_/claudeService.mjs.map +1 -1
- package/.output/server/chunks/_/codexProvider.mjs +47 -812
- package/.output/server/chunks/_/codexProvider.mjs.map +1 -1
- package/.output/server/chunks/_/git.mjs +1 -2
- package/.output/server/chunks/_/git.mjs.map +1 -1
- package/.output/server/chunks/_/gitApiHelpers.mjs +1 -1
- package/.output/server/chunks/_/gitBranchOperations.mjs +1 -1
- package/.output/server/chunks/_/interactiveProviderQuery.mjs +160 -0
- package/.output/server/chunks/_/interactiveProviderQuery.mjs.map +1 -0
- package/.output/server/chunks/_/jobPersister.mjs +37 -6
- package/.output/server/chunks/_/jobPersister.mjs.map +1 -1
- package/.output/server/chunks/_/jobQueue.mjs +430 -278
- package/.output/server/chunks/_/jobQueue.mjs.map +1 -1
- package/.output/server/chunks/_/terminalSessions.mjs +582 -0
- package/.output/server/chunks/_/terminalSessions.mjs.map +1 -0
- package/.output/server/chunks/_/worktreeSetup.mjs +98 -0
- package/.output/server/chunks/_/worktreeSetup.mjs.map +1 -0
- package/.output/server/chunks/build/client.precomputed.mjs +1 -1
- package/.output/server/chunks/build/client.precomputed.mjs.map +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +1227 -620
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/_ws.mjs +21 -111
- package/.output/server/chunks/routes/_ws.mjs.map +1 -1
- package/.output/server/chunks/routes/api/ai/providers.get.mjs +3 -1
- package/.output/server/chunks/routes/api/ai/providers.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/chat/compare.get.mjs +4 -5
- package/.output/server/chunks/routes/api/chat/compare.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/chat/context.get.mjs +4 -2
- package/.output/server/chunks/routes/api/chat/context.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/chat/finalize.post.mjs +11 -7
- package/.output/server/chunks/routes/api/chat/finalize.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/chat/generate-commit-message.post.mjs +26 -29
- package/.output/server/chunks/routes/api/chat/generate-commit-message.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/chat/preview-sync.post.mjs +4 -5
- package/.output/server/chunks/routes/api/chat/preview-sync.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/chat/preview.delete.mjs +4 -5
- package/.output/server/chunks/routes/api/chat/preview.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/api/chat/preview.post.mjs +4 -6
- package/.output/server/chunks/routes/api/chat/preview.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/chat/rebase.post.mjs +4 -7
- package/.output/server/chunks/routes/api/chat/rebase.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/chat/worktree-commit.post.mjs +4 -6
- package/.output/server/chunks/routes/api/chat/worktree-commit.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/chat/worktree.delete.mjs +11 -4
- package/.output/server/chunks/routes/api/chat/worktree.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/api/chat/worktree.post.mjs +4 -6
- package/.output/server/chunks/routes/api/chat/worktree.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/conversations/_conversationId/archive.post.mjs +10 -9
- package/.output/server/chunks/routes/api/conversations/_conversationId/archive.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/conversations/archives/_archiveId/restore.post.mjs +4 -7
- package/.output/server/chunks/routes/api/conversations/archives/_archiveId/restore.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/conversations/archives/_archiveId_.delete.mjs +4 -7
- package/.output/server/chunks/routes/api/conversations/archives/_archiveId_.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/api/conversations/archives.delete.mjs +40 -0
- package/.output/server/chunks/routes/api/conversations/archives.delete.mjs.map +1 -0
- package/.output/server/chunks/routes/api/conversations/archives.get.mjs +4 -7
- package/.output/server/chunks/routes/api/conversations/archives.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/conversations/update.post.mjs +4 -7
- package/.output/server/chunks/routes/api/conversations/update.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/conversations.get.mjs +4 -7
- package/.output/server/chunks/routes/api/conversations.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/conversations.post.mjs +4 -7
- package/.output/server/chunks/routes/api/conversations.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/cwd.get.mjs +4 -2
- package/.output/server/chunks/routes/api/cwd.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/branch-rename.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/branch-rename.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/branch.delete.mjs +4 -5
- package/.output/server/chunks/routes/api/git/branch.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/branches.get.mjs +4 -6
- package/.output/server/chunks/routes/api/git/branches.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/checkout.post.mjs +4 -5
- package/.output/server/chunks/routes/api/git/checkout.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/cherry-pick.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/cherry-pick.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/clean.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/clean.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/commit/_id_.get.mjs +3 -4
- package/.output/server/chunks/routes/api/git/commit/_id_.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/commit.post.mjs +4 -5
- package/.output/server/chunks/routes/api/git/commit.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/diff.get.mjs +4 -5
- package/.output/server/chunks/routes/api/git/diff.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/fetch.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/fetch.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/file-diff.get.mjs +4 -5
- package/.output/server/chunks/routes/api/git/file-diff.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/graph.get.mjs +4 -5
- package/.output/server/chunks/routes/api/git/graph.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/log.get.mjs +4 -5
- package/.output/server/chunks/routes/api/git/log.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/merge-base.get.mjs +4 -5
- package/.output/server/chunks/routes/api/git/merge-base.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/merge.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/merge.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/pull.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/pull.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/push.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/push.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/rebase.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/rebase.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/remote.delete.mjs +3 -4
- package/.output/server/chunks/routes/api/git/remote.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/remote.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/remote.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/remote.put.mjs +3 -4
- package/.output/server/chunks/routes/api/git/remote.put.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/remotes.get.mjs +3 -4
- package/.output/server/chunks/routes/api/git/remotes.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/reset.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/reset.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/revert.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/revert.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/show.get.mjs +4 -5
- package/.output/server/chunks/routes/api/git/show.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/stage.post.mjs +4 -5
- package/.output/server/chunks/routes/api/git/stage.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/stash-apply.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/stash-apply.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/stash-branch.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/stash-branch.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/stash-drop.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/stash-drop.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/stash-pop.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/stash-pop.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/stash.get.mjs +3 -4
- package/.output/server/chunks/routes/api/git/stash.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/stash.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/stash.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/state.get.mjs +3 -4
- package/.output/server/chunks/routes/api/git/state.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/status.get.mjs +4 -5
- package/.output/server/chunks/routes/api/git/status.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/tag/_name_.get.mjs +3 -4
- package/.output/server/chunks/routes/api/git/tag/_name_.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/tag-push.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/tag-push.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/tag.delete.mjs +3 -4
- package/.output/server/chunks/routes/api/git/tag.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/tag.post.mjs +3 -4
- package/.output/server/chunks/routes/api/git/tag.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/git/unstage.post.mjs +4 -5
- package/.output/server/chunks/routes/api/git/unstage.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/index.get.mjs +7 -4
- package/.output/server/chunks/routes/api/index.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/index.get2.mjs +4 -2
- package/.output/server/chunks/routes/api/index.get2.mjs.map +1 -1
- package/.output/server/chunks/routes/api/index.get3.mjs +4 -2
- package/.output/server/chunks/routes/api/index.get3.mjs.map +1 -1
- package/.output/server/chunks/routes/api/index.post.mjs +19 -16
- package/.output/server/chunks/routes/api/index.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/index.post2.mjs +4 -6
- package/.output/server/chunks/routes/api/index.post2.mjs.map +1 -1
- package/.output/server/chunks/routes/api/jobs/_id/cancel.post.mjs +6 -3
- package/.output/server/chunks/routes/api/jobs/_id/cancel.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/jobs/_id_.get.mjs +7 -4
- package/.output/server/chunks/routes/api/jobs/_id_.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/rebase/abort.post.mjs +4 -2
- package/.output/server/chunks/routes/api/rebase/abort.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/rebase/ai-resolve.post.mjs +19 -105
- package/.output/server/chunks/routes/api/rebase/ai-resolve.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/rebase/conflicts.get.mjs +3 -1
- package/.output/server/chunks/routes/api/rebase/conflicts.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/rebase/continue-sync.post.mjs +4 -2
- package/.output/server/chunks/routes/api/rebase/continue-sync.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/rebase/continue.post.mjs +71 -73
- package/.output/server/chunks/routes/api/rebase/continue.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/rebase/resolve.put.mjs +3 -1
- package/.output/server/chunks/routes/api/rebase/resolve.put.mjs.map +1 -1
- package/.output/server/chunks/routes/api/repository/status.get.mjs +4 -5
- package/.output/server/chunks/routes/api/repository/status.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/settings.get.mjs +6 -5
- package/.output/server/chunks/routes/api/settings.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/settings.post.mjs +5 -3
- package/.output/server/chunks/routes/api/settings.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/skills/_skillId/prompt.post.mjs +3 -1
- package/.output/server/chunks/routes/api/skills/_skillId/prompt.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/specs/_featureId/_...filename_.get.mjs +3 -1
- package/.output/server/chunks/routes/api/specs/_featureId/_...filename_.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/specs/_featureId/_...filename_.put.mjs +3 -1
- package/.output/server/chunks/routes/api/specs/_featureId/_...filename_.put.mjs.map +1 -1
- package/.output/server/chunks/routes/api/specs/features.get.mjs +3 -1
- package/.output/server/chunks/routes/api/specs/features.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/specs/reindex.post.mjs +4 -2
- package/.output/server/chunks/routes/api/specs/reindex.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/specs/search.get.mjs +4 -2
- package/.output/server/chunks/routes/api/specs/search.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/specs/status.get.mjs +4 -2
- package/.output/server/chunks/routes/api/specs/status.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/specs/traceability/_featureId_.get.mjs +4 -2
- package/.output/server/chunks/routes/api/specs/traceability/_featureId_.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/worktrees/_name/switch.post.mjs +4 -2
- package/.output/server/chunks/routes/api/worktrees/_name/switch.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/worktrees/_name_.delete.mjs +3 -1
- package/.output/server/chunks/routes/api/worktrees/_name_.delete.mjs.map +1 -1
- package/.output/server/chunks/routes/git-watcher-ws.mjs +4 -2
- package/.output/server/chunks/routes/git-watcher-ws.mjs.map +1 -1
- package/.output/server/chunks/routes/renderer.mjs +4 -2
- package/.output/server/chunks/routes/terminal-ws.mjs +230 -0
- package/.output/server/chunks/routes/terminal-ws.mjs.map +1 -0
- package/.output/server/index.mjs +4 -2
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/node-pty/build/Makefile +369 -0
- package/.output/server/node_modules/node-pty/build/Release/pty.node +0 -0
- package/.output/server/node_modules/node-pty/build/binding.Makefile +6 -0
- package/.output/server/node_modules/node-pty/build/config.gypi +513 -0
- package/.output/server/node_modules/node-pty/build/pty.target.mk +168 -0
- package/.output/server/node_modules/node-pty/lib/eventEmitter2.js +47 -0
- package/.output/server/node_modules/node-pty/lib/index.js +52 -0
- package/.output/server/node_modules/node-pty/lib/shared/conout.js +11 -0
- package/.output/server/node_modules/node-pty/lib/terminal.js +190 -0
- package/.output/server/node_modules/node-pty/lib/unixTerminal.js +346 -0
- package/.output/server/node_modules/node-pty/lib/utils.js +39 -0
- package/.output/server/node_modules/node-pty/lib/windowsConoutConnection.js +125 -0
- package/.output/server/node_modules/node-pty/lib/windowsPtyAgent.js +320 -0
- package/.output/server/node_modules/node-pty/lib/windowsTerminal.js +199 -0
- package/.output/server/node_modules/node-pty/package.json +64 -0
- package/.output/server/package.json +2 -1
- package/package.json +6 -1
- package/.output/public/_nuxt/2zamijve.js +0 -1
- package/.output/public/_nuxt/BEjIzkrM.js +0 -85
- package/.output/public/_nuxt/BaSsfm-t.js +0 -36
- package/.output/public/_nuxt/BjdLSVUw.js +0 -1
- package/.output/public/_nuxt/DeqM2TrP.js +0 -1
- package/.output/public/_nuxt/builds/meta/74089fa1-2fbb-4792-94aa-7535d2aec557.json +0 -1
- package/.output/public/_nuxt/default.DKSPicGu.css +0 -1
- package/.output/public/_nuxt/entry.BUDfUMkE.css +0 -1
- package/.output/public/_nuxt/zrVRZSxq.js +0 -64
- package/.output/server/chunks/_/baseBranch.mjs +0 -137
- package/.output/server/chunks/_/baseBranch.mjs.map +0 -1
- package/.output/server/chunks/_/claude.mjs +0 -164
- package/.output/server/chunks/_/claude.mjs.map +0 -1
- package/.output/server/chunks/_/conversationStore.mjs +0 -257
- package/.output/server/chunks/_/conversationStore.mjs.map +0 -1
- package/.output/server/chunks/_/geminiProvider.mjs +0 -372
- package/.output/server/chunks/_/geminiProvider.mjs.map +0 -1
- package/.output/server/chunks/_/gitExec.mjs +0 -48
- package/.output/server/chunks/_/gitExec.mjs.map +0 -1
- package/.output/server/chunks/_/providerProcessError.mjs +0 -163
- package/.output/server/chunks/_/providerProcessError.mjs.map +0 -1
- package/.output/server/chunks/_/uiAdapter.mjs +0 -421
- package/.output/server/chunks/_/uiAdapter.mjs.map +0 -1
- package/.output/server/chunks/routes/api/chat.post.mjs +0 -276
- package/.output/server/chunks/routes/api/chat.post.mjs.map +0 -1
|
@@ -1,611 +1,30 @@
|
|
|
1
1
|
import { r as registerProvider } from './aiProviderRegistry.mjs';
|
|
2
|
-
import { mkdtempSync, mkdirSync, existsSync, accessSync, constants,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { b as transformCodexEvent } from './uiAdapter.mjs';
|
|
2
|
+
import { mkdtempSync, mkdirSync, existsSync, symlinkSync, accessSync, constants, copyFileSync, cpSync } from 'node:fs';
|
|
3
|
+
import { execSync } from 'node:child_process';
|
|
4
|
+
import { join } from 'node:path';
|
|
6
5
|
import { e as ensureSpecCatTmpDir } from './worktreePaths.mjs';
|
|
6
|
+
import { t as getSpecCatStorePath } from '../nitro/nitro.mjs';
|
|
7
7
|
import 'node:os';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function getStringValue(obj, keys) {
|
|
29
|
-
for (const key of keys) {
|
|
30
|
-
const value = obj[key];
|
|
31
|
-
if (typeof value === "string" && value.trim()) {
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return "";
|
|
36
|
-
}
|
|
37
|
-
function getObjectValue(obj, keys) {
|
|
38
|
-
for (const key of keys) {
|
|
39
|
-
const value = obj[key];
|
|
40
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
function parseJsonObject(input) {
|
|
47
|
-
if (input && typeof input === "object" && !Array.isArray(input)) {
|
|
48
|
-
return input;
|
|
49
|
-
}
|
|
50
|
-
if (typeof input === "string" && input.trim()) {
|
|
51
|
-
try {
|
|
52
|
-
const parsed = JSON.parse(input);
|
|
53
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
54
|
-
return parsed;
|
|
55
|
-
}
|
|
56
|
-
} catch {
|
|
57
|
-
}
|
|
58
|
-
return { raw: input };
|
|
59
|
-
}
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
function stringifyUnknown(value) {
|
|
63
|
-
if (typeof value === "string") return value;
|
|
64
|
-
if (value === void 0 || value === null) return "";
|
|
65
|
-
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
66
|
-
try {
|
|
67
|
-
return JSON.stringify(value);
|
|
68
|
-
} catch {
|
|
69
|
-
return String(value);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function joinTextChunks(chunks) {
|
|
73
|
-
return chunks.filter(Boolean).join("");
|
|
74
|
-
}
|
|
75
|
-
function deriveToolNameFromEventType(eventType) {
|
|
76
|
-
if (!eventType) return "";
|
|
77
|
-
if (eventType === "item.started" || eventType === "item.updated" || eventType === "item.completed") {
|
|
78
|
-
return "";
|
|
79
|
-
}
|
|
80
|
-
const base = eventType.replace(/^response\.output_item\./, "").replace(/(?:_begin|_end|_start|_stop|_done|_added|_updated|_completed|_failed)$/, "").replace(/(?:\.begin|\.end|\.start|\.stop|\.done|\.added|\.updated|\.completed|\.failed)$/, "").replace(/[._]+/g, " ").trim();
|
|
81
|
-
if (!base) return "";
|
|
82
|
-
const parts = base.split(/\s+/).filter(Boolean);
|
|
83
|
-
return parts.map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
84
|
-
}
|
|
85
|
-
function inferToolNameFromInput(input) {
|
|
86
|
-
if (typeof input.command === "string" || typeof input.cmd === "string") {
|
|
87
|
-
return "Bash";
|
|
88
|
-
}
|
|
89
|
-
const hasPath = typeof input.file_path === "string" || typeof input.path === "string";
|
|
90
|
-
const hasContent = typeof input.content === "string" || typeof input.text === "string";
|
|
91
|
-
const hasEditShape = typeof input.old_string === "string" || typeof input.new_string === "string";
|
|
92
|
-
if (hasPath && hasEditShape) return "Edit";
|
|
93
|
-
if (hasPath && hasContent) return "Write";
|
|
94
|
-
if (hasPath) return "Read";
|
|
95
|
-
return "";
|
|
96
|
-
}
|
|
97
|
-
function normalizeGenericToolName(name) {
|
|
98
|
-
if (!name) return "";
|
|
99
|
-
const lowered = name.toLowerCase();
|
|
100
|
-
const compact = lowered.replace(/[^a-z0-9]/g, "");
|
|
101
|
-
if (compact === "functioncall" || compact === "toolcall" || compact === "itemstarted" || compact === "itemupdated" || compact === "itemcompleted") {
|
|
102
|
-
return "";
|
|
103
|
-
}
|
|
104
|
-
return name;
|
|
105
|
-
}
|
|
106
|
-
function extractFallbackInputFromEvent(event) {
|
|
107
|
-
const keys = [
|
|
108
|
-
"file_path",
|
|
109
|
-
"filePath",
|
|
110
|
-
"path",
|
|
111
|
-
"command",
|
|
112
|
-
"cmd",
|
|
113
|
-
"pattern",
|
|
114
|
-
"query",
|
|
115
|
-
"glob",
|
|
116
|
-
"offset",
|
|
117
|
-
"limit",
|
|
118
|
-
"old_string",
|
|
119
|
-
"new_string",
|
|
120
|
-
"content",
|
|
121
|
-
"text"
|
|
122
|
-
];
|
|
123
|
-
const input = {};
|
|
124
|
-
for (const key of keys) {
|
|
125
|
-
const value = event[key];
|
|
126
|
-
if (value === void 0 || value === null) continue;
|
|
127
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
128
|
-
const normalizedKey = key === "filePath" ? "file_path" : key;
|
|
129
|
-
input[normalizedKey] = value;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return input;
|
|
133
|
-
}
|
|
134
|
-
function withSessionFields(event, source) {
|
|
135
|
-
const merged = { ...event };
|
|
136
|
-
const sessionFields = extractSessionFields(source);
|
|
137
|
-
for (const [key, value] of Object.entries(sessionFields)) {
|
|
138
|
-
if (merged[key] === void 0) {
|
|
139
|
-
merged[key] = value;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return merged;
|
|
143
|
-
}
|
|
144
|
-
function withEnvelopeIdentifiers(event, source) {
|
|
145
|
-
const merged = { ...event };
|
|
146
|
-
const idKeys = ["item_id", "id", "call_id", "tool_call_id", "tool_use_id"];
|
|
147
|
-
for (const key of idKeys) {
|
|
148
|
-
const sourceValue = source[key];
|
|
149
|
-
if (merged[key] === void 0 && typeof sourceValue === "string" && sourceValue.length > 0) {
|
|
150
|
-
merged[key] = sourceValue;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return merged;
|
|
154
|
-
}
|
|
155
|
-
function extractSessionFields(source) {
|
|
156
|
-
const out = {};
|
|
157
|
-
const keys = ["thread_id", "threadId", "session_id", "sessionId", "conversation_id", "conversationId"];
|
|
158
|
-
for (const key of keys) {
|
|
159
|
-
const value = source[key];
|
|
160
|
-
if (typeof value === "string" && value.length > 0) {
|
|
161
|
-
out[key] = value;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
const response = source.response;
|
|
165
|
-
if (response && typeof response === "object" && !Array.isArray(response)) {
|
|
166
|
-
const responseObj = response;
|
|
167
|
-
for (const key of keys) {
|
|
168
|
-
const value = responseObj[key];
|
|
169
|
-
if (typeof value === "string" && value.length > 0 && out[key] === void 0) {
|
|
170
|
-
out[key] = value;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return out;
|
|
175
|
-
}
|
|
176
|
-
function extractSessionId(event) {
|
|
177
|
-
const fields = extractSessionFields(event);
|
|
178
|
-
return fields.thread_id || fields.threadId || fields.session_id || fields.sessionId || fields.conversation_id || fields.conversationId;
|
|
179
|
-
}
|
|
180
|
-
function extractPermissionRequest(event) {
|
|
181
|
-
const eventType = getStringValue(event, ["type"]).toLowerCase();
|
|
182
|
-
const permission = getObjectValue(event, ["permission"]);
|
|
183
|
-
if (permission) {
|
|
184
|
-
const tool2 = getStringValue(permission, ["tool", "name", "action"]) || "Permission";
|
|
185
|
-
return {
|
|
186
|
-
tool: tool2,
|
|
187
|
-
description: getStringValue(permission, ["description", "message", "text"]) || `Permission required: ${tool2}`,
|
|
188
|
-
path: getStringValue(permission, ["path"]),
|
|
189
|
-
file_path: getStringValue(permission, ["file_path", "filePath"]),
|
|
190
|
-
command: getStringValue(permission, ["command", "cmd"])
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
const looksLikePermissionEvent = eventType.includes("permission") || eventType.includes("approval") || eventType.includes("confirm");
|
|
194
|
-
if (!looksLikePermissionEvent) {
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
const tool = getStringValue(event, ["tool", "name", "action"]) || "Permission";
|
|
198
|
-
const description = getStringValue(event, ["description", "message", "text"]) || `Permission required: ${tool}`;
|
|
199
|
-
return {
|
|
200
|
-
tool,
|
|
201
|
-
description,
|
|
202
|
-
path: getStringValue(event, ["path"]),
|
|
203
|
-
file_path: getStringValue(event, ["file_path", "filePath"]),
|
|
204
|
-
command: getStringValue(event, ["command", "cmd"])
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
function extractToolUse(event) {
|
|
208
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
209
|
-
const eventType = getStringValue(event, ["type"]).toLowerCase();
|
|
210
|
-
const envelopeType = getStringValue(event, ["envelope_type"]).toLowerCase();
|
|
211
|
-
const phaseType = envelopeType || eventType;
|
|
212
|
-
const disallowedTypes = /* @__PURE__ */ new Set([
|
|
213
|
-
"agent_message",
|
|
214
|
-
"agent_message_delta",
|
|
215
|
-
"task_complete",
|
|
216
|
-
"turn.completed",
|
|
217
|
-
"turn.failed",
|
|
218
|
-
"error",
|
|
219
|
-
"result"
|
|
220
|
-
]);
|
|
221
|
-
if (disallowedTypes.has(eventType)) return null;
|
|
222
|
-
const toolObj = getObjectValue(event, ["tool", "function"]);
|
|
223
|
-
const explicitInput = toolObj ? (_c = (_b = (_a = toolObj.arguments) != null ? _a : toolObj.input) != null ? _b : toolObj.args) != null ? _c : toolObj.parameters : (_g = (_f = (_e = (_d = event.arguments) != null ? _d : event.input) != null ? _e : event.args) != null ? _f : event.parameters) != null ? _g : event.payload;
|
|
224
|
-
const parsedInput = parseJsonObject(explicitInput);
|
|
225
|
-
const fallbackInput = Object.keys(parsedInput).length === 0 ? extractFallbackInputFromEvent(event) : {};
|
|
226
|
-
const input = Object.keys(fallbackInput).length > 0 ? fallbackInput : parsedInput;
|
|
227
|
-
const explicitToolName = toolObj ? getStringValue(toolObj, ["name", "tool_name", "toolName"]) : getStringValue(event, ["name", "tool_name", "toolName", "function_name", "functionName", "item_type"]);
|
|
228
|
-
const derivedToolName = deriveToolNameFromEventType(eventType);
|
|
229
|
-
const toolName = normalizeGenericToolName(explicitToolName) || normalizeGenericToolName(derivedToolName) || inferToolNameFromInput(input);
|
|
230
|
-
if (!toolName) return null;
|
|
231
|
-
const hasToolShape = phaseType.includes("tool") || phaseType.includes("function_call") || phaseType.includes("call.started") || phaseType.includes("call.start") || phaseType.includes("tool_call") || phaseType.includes("item.started") || phaseType.includes("item.updated") || phaseType.endsWith("_begin") || phaseType.endsWith(".begin") || phaseType.endsWith("_start") || phaseType.endsWith(".start") || !!event.tool_call_id || !!event.call_id || !!event.tool_use_id;
|
|
232
|
-
if (!hasToolShape && Object.keys(input).length === 0) {
|
|
233
|
-
return null;
|
|
234
|
-
}
|
|
235
|
-
const toolUseId = getStringValue(event, ["tool_use_id", "toolUseId", "tool_call_id", "call_id", "item_id", "id"]) || `codex-tool-${toolName}`;
|
|
236
|
-
return { toolUseId, name: toolName, input };
|
|
237
|
-
}
|
|
238
|
-
function extractToolResult(event) {
|
|
239
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
240
|
-
const eventType = getStringValue(event, ["type"]).toLowerCase();
|
|
241
|
-
const envelopeType = getStringValue(event, ["envelope_type"]).toLowerCase();
|
|
242
|
-
const phaseType = envelopeType || eventType;
|
|
243
|
-
const resultObj = getObjectValue(event, ["result"]);
|
|
244
|
-
const toolUseId = getStringValue(event, ["tool_use_id", "toolUseId", "tool_call_id", "call_id", "item_id", "id"]);
|
|
245
|
-
const contentSource = (_h = (_d = (_c = (_b = (_a = event.output) != null ? _a : event.content) != null ? _b : event.result) != null ? _c : event.text) != null ? _d : event.message) != null ? _h : (_g = (_f = (_e = resultObj == null ? void 0 : resultObj.output) != null ? _e : resultObj == null ? void 0 : resultObj.content) != null ? _f : resultObj == null ? void 0 : resultObj.text) != null ? _g : resultObj == null ? void 0 : resultObj.message;
|
|
246
|
-
const content = stringifyUnknown(contentSource);
|
|
247
|
-
const status = getStringValue(event, ["status"]).toLowerCase();
|
|
248
|
-
const isError = event.is_error === true || status === "error" || status === "failed" || status === "failure";
|
|
249
|
-
const hasResultShape = phaseType.includes("tool_result") || phaseType.includes("tool.output") || phaseType.includes("function_call_output") || phaseType.includes("call.completed") || phaseType.includes("tool.end") || phaseType.includes("tool.finish") || phaseType.includes("tool.result") || phaseType.endsWith("_end") || phaseType.endsWith(".end") || phaseType.endsWith("_done") || phaseType.endsWith(".done") || phaseType.endsWith("_completed") || phaseType.endsWith(".completed") || toolUseId.length > 0 && content.length > 0 && !eventType.includes("message");
|
|
250
|
-
if (!hasResultShape || !toolUseId) {
|
|
251
|
-
return null;
|
|
252
|
-
}
|
|
253
|
-
const normalizedContent = content.trim();
|
|
254
|
-
if (!normalizedContent && (eventType === "function_call" || eventType === "tool_call")) {
|
|
255
|
-
return null;
|
|
256
|
-
}
|
|
257
|
-
return {
|
|
258
|
-
toolUseId,
|
|
259
|
-
content: normalizedContent,
|
|
260
|
-
isError
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
function extractAgentTextFromEvent(event) {
|
|
264
|
-
const directText = typeof event.message === "string" ? event.message : typeof event.text === "string" ? event.text : "";
|
|
265
|
-
if (directText) {
|
|
266
|
-
return directText;
|
|
267
|
-
}
|
|
268
|
-
const content = event.content;
|
|
269
|
-
if (Array.isArray(content)) {
|
|
270
|
-
const chunks = content.map((entry) => {
|
|
271
|
-
if (!entry || typeof entry !== "object") return "";
|
|
272
|
-
const part = entry;
|
|
273
|
-
if (typeof part.text === "string") return part.text;
|
|
274
|
-
if (typeof part.content === "string") return part.content;
|
|
275
|
-
return "";
|
|
276
|
-
}).filter(Boolean);
|
|
277
|
-
if (chunks.length > 0) {
|
|
278
|
-
return joinTextChunks(chunks);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
return "";
|
|
282
|
-
}
|
|
283
|
-
function extractReasoningTextFromEvent(event) {
|
|
284
|
-
const directText = getStringValue(event, ["text", "message", "summary"]);
|
|
285
|
-
if (directText) return directText;
|
|
286
|
-
const summary = event.summary;
|
|
287
|
-
if (Array.isArray(summary)) {
|
|
288
|
-
const chunks = summary.map((entry) => {
|
|
289
|
-
if (!entry || typeof entry !== "object") return "";
|
|
290
|
-
const part = entry;
|
|
291
|
-
return getStringValue(part, ["text", "summary", "content"]);
|
|
292
|
-
}).filter(Boolean);
|
|
293
|
-
if (chunks.length > 0) {
|
|
294
|
-
return chunks.join("\n");
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
const content = event.content;
|
|
298
|
-
if (Array.isArray(content)) {
|
|
299
|
-
const chunks = content.map((entry) => {
|
|
300
|
-
if (!entry || typeof entry !== "object") return "";
|
|
301
|
-
const part = entry;
|
|
302
|
-
return getStringValue(part, ["text", "summary", "content"]);
|
|
303
|
-
}).filter(Boolean);
|
|
304
|
-
if (chunks.length > 0) {
|
|
305
|
-
return chunks.join("\n");
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return "";
|
|
309
|
-
}
|
|
310
|
-
function extractErrorMessage(event) {
|
|
311
|
-
const directCandidates = [event.message, event.error, event.content, event.text];
|
|
312
|
-
for (const value of directCandidates) {
|
|
313
|
-
if (typeof value === "string" && value.trim()) {
|
|
314
|
-
return value.trim();
|
|
315
|
-
}
|
|
316
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
317
|
-
const message = value.message;
|
|
318
|
-
if (typeof message === "string" && message.trim()) {
|
|
319
|
-
return message.trim();
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
const result = event.result;
|
|
324
|
-
if (result && typeof result === "object" && !Array.isArray(result)) {
|
|
325
|
-
const resultObj = result;
|
|
326
|
-
const nestedCandidates = [resultObj.message, resultObj.error, resultObj.content, resultObj.text];
|
|
327
|
-
for (const value of nestedCandidates) {
|
|
328
|
-
if (typeof value === "string" && value.trim()) {
|
|
329
|
-
return value.trim();
|
|
330
|
-
}
|
|
331
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
332
|
-
const message = value.message;
|
|
333
|
-
if (typeof message === "string" && message.trim()) {
|
|
334
|
-
return message.trim();
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
return "";
|
|
340
|
-
}
|
|
341
|
-
function mapCodexEventToUIEvents(event) {
|
|
342
|
-
const eventType = typeof event.type === "string" ? event.type : "";
|
|
343
|
-
const sessionId = extractSessionId(event) || void 0;
|
|
344
|
-
const asTextStreamEvents = (text) => [
|
|
345
|
-
{
|
|
346
|
-
type: "block_start",
|
|
347
|
-
sessionId,
|
|
348
|
-
blockId: `blk-${Date.now()}-${Math.random().toString(36).substring(2, 6)}`,
|
|
349
|
-
blockType: "text",
|
|
350
|
-
text
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
type: "block_end",
|
|
354
|
-
sessionId,
|
|
355
|
-
blockId: ""
|
|
356
|
-
}
|
|
357
|
-
];
|
|
358
|
-
const asThinkingStreamEvents = (thinking) => [
|
|
359
|
-
{
|
|
360
|
-
type: "block_start",
|
|
361
|
-
sessionId,
|
|
362
|
-
blockId: `blk-${Date.now()}-${Math.random().toString(36).substring(2, 6)}`,
|
|
363
|
-
blockType: "thinking",
|
|
364
|
-
thinking
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
type: "block_end",
|
|
368
|
-
sessionId,
|
|
369
|
-
blockId: ""
|
|
370
|
-
}
|
|
371
|
-
];
|
|
372
|
-
const mapPermissionRequest = () => {
|
|
373
|
-
const permission = extractPermissionRequest(event);
|
|
374
|
-
if (!permission) return null;
|
|
375
|
-
return {
|
|
376
|
-
type: "permission_request",
|
|
377
|
-
sessionId,
|
|
378
|
-
tool: permission.tool,
|
|
379
|
-
description: permission.description,
|
|
380
|
-
input: event.permission
|
|
381
|
-
};
|
|
382
|
-
};
|
|
383
|
-
const mapToolUseAsStreamEvents = () => {
|
|
384
|
-
const toolUse = extractToolUse(event);
|
|
385
|
-
if (!toolUse) return null;
|
|
386
|
-
const inputJson = JSON.stringify(toolUse.input);
|
|
387
|
-
const blockId = `blk-${Date.now()}-${Math.random().toString(36).substring(2, 6)}`;
|
|
388
|
-
return [
|
|
389
|
-
{
|
|
390
|
-
type: "block_start",
|
|
391
|
-
sessionId,
|
|
392
|
-
blockId,
|
|
393
|
-
blockType: "tool_use",
|
|
394
|
-
index: 0,
|
|
395
|
-
name: toolUse.name,
|
|
396
|
-
toolUseId: toolUse.toolUseId
|
|
397
|
-
},
|
|
398
|
-
{
|
|
399
|
-
type: "block_delta",
|
|
400
|
-
sessionId,
|
|
401
|
-
blockId,
|
|
402
|
-
index: 0,
|
|
403
|
-
partialJson: inputJson
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
type: "block_end",
|
|
407
|
-
sessionId,
|
|
408
|
-
blockId,
|
|
409
|
-
index: 0
|
|
410
|
-
}
|
|
411
|
-
];
|
|
412
|
-
};
|
|
413
|
-
const mapToolResult = () => {
|
|
414
|
-
const result = extractToolResult(event);
|
|
415
|
-
if (!result) return null;
|
|
416
|
-
return {
|
|
417
|
-
type: "tool_result",
|
|
418
|
-
sessionId,
|
|
419
|
-
toolUseId: result.toolUseId,
|
|
420
|
-
content: result.content,
|
|
421
|
-
isError: result.isError
|
|
422
|
-
};
|
|
423
|
-
};
|
|
424
|
-
const getFinalMessageText = () => {
|
|
425
|
-
const directCandidates = [
|
|
426
|
-
event.last_agent_message,
|
|
427
|
-
event.last_assistant_message,
|
|
428
|
-
event.final_message,
|
|
429
|
-
event.output_text,
|
|
430
|
-
event.response_text
|
|
431
|
-
];
|
|
432
|
-
for (const value of directCandidates) {
|
|
433
|
-
if (typeof value === "string" && value.trim()) {
|
|
434
|
-
return value;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
const result = event.result;
|
|
438
|
-
if (result && typeof result === "object") {
|
|
439
|
-
const resultObj = result;
|
|
440
|
-
const nestedCandidates = [resultObj.message, resultObj.text, resultObj.output_text];
|
|
441
|
-
for (const value of nestedCandidates) {
|
|
442
|
-
if (typeof value === "string" && value.trim()) {
|
|
443
|
-
return value;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
return "";
|
|
448
|
-
};
|
|
449
|
-
if (eventType === "agent_message_delta") {
|
|
450
|
-
const text = typeof event.delta === "string" ? event.delta : typeof event.text === "string" ? event.text : "";
|
|
451
|
-
if (!text) return [];
|
|
452
|
-
const blockId = `blk-${Date.now()}-${Math.random().toString(36).substring(2, 6)}`;
|
|
453
|
-
return [
|
|
454
|
-
{
|
|
455
|
-
type: "block_start",
|
|
456
|
-
sessionId,
|
|
457
|
-
blockId,
|
|
458
|
-
blockType: "text",
|
|
459
|
-
text: ""
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
type: "block_delta",
|
|
463
|
-
sessionId,
|
|
464
|
-
blockId,
|
|
465
|
-
text
|
|
466
|
-
},
|
|
467
|
-
{
|
|
468
|
-
type: "block_end",
|
|
469
|
-
sessionId,
|
|
470
|
-
blockId
|
|
471
|
-
}
|
|
472
|
-
];
|
|
473
|
-
}
|
|
474
|
-
if (eventType === "agent_message") {
|
|
475
|
-
const text = extractAgentTextFromEvent(event);
|
|
476
|
-
if (!text) return [];
|
|
477
|
-
return asTextStreamEvents(text);
|
|
478
|
-
}
|
|
479
|
-
if (eventType === "reasoning" || eventType === "agent_reasoning") {
|
|
480
|
-
const thinking = extractReasoningTextFromEvent(event);
|
|
481
|
-
if (!thinking) return [];
|
|
482
|
-
return asThinkingStreamEvents(thinking);
|
|
483
|
-
}
|
|
484
|
-
if (eventType === "task_complete" || eventType === "turn.completed") {
|
|
485
|
-
const finalText = getFinalMessageText();
|
|
486
|
-
const resultEvent = {
|
|
487
|
-
type: "turn_result",
|
|
488
|
-
sessionId,
|
|
489
|
-
subtype: "success"
|
|
490
|
-
};
|
|
491
|
-
if (!finalText) {
|
|
492
|
-
return [resultEvent];
|
|
493
|
-
}
|
|
494
|
-
return [
|
|
495
|
-
...asTextStreamEvents(finalText),
|
|
496
|
-
resultEvent
|
|
497
|
-
];
|
|
498
|
-
}
|
|
499
|
-
if (eventType === "turn.failed" || eventType === "error") {
|
|
500
|
-
const errorMessage = extractErrorMessage(event) || "Provider reported an execution error.";
|
|
501
|
-
const resultEvent = {
|
|
502
|
-
type: "turn_result",
|
|
503
|
-
sessionId,
|
|
504
|
-
subtype: "error"
|
|
505
|
-
};
|
|
506
|
-
const errorEvent2 = {
|
|
507
|
-
type: "error",
|
|
508
|
-
sessionId,
|
|
509
|
-
error: errorMessage
|
|
510
|
-
};
|
|
511
|
-
return [resultEvent, errorEvent2];
|
|
512
|
-
}
|
|
513
|
-
if (eventType === "result") {
|
|
514
|
-
const status = getStringValue(event, ["status"]).toLowerCase();
|
|
515
|
-
const isError = event.is_error === true || status === "error" || status === "failed" || status === "failure";
|
|
516
|
-
if (isError) {
|
|
517
|
-
const errorMessage = extractErrorMessage(event) || "Provider reported an execution error.";
|
|
518
|
-
const resultEvent = {
|
|
519
|
-
type: "turn_result",
|
|
520
|
-
sessionId,
|
|
521
|
-
subtype: "error"
|
|
522
|
-
};
|
|
523
|
-
const errorEvent2 = {
|
|
524
|
-
type: "error",
|
|
525
|
-
sessionId,
|
|
526
|
-
error: errorMessage
|
|
527
|
-
};
|
|
528
|
-
return [resultEvent, errorEvent2];
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
const permissionEvent = mapPermissionRequest();
|
|
532
|
-
if (permissionEvent) {
|
|
533
|
-
return [permissionEvent];
|
|
534
|
-
}
|
|
535
|
-
const toolResultEvent = mapToolResult();
|
|
536
|
-
if (toolResultEvent) {
|
|
537
|
-
return [toolResultEvent];
|
|
538
|
-
}
|
|
539
|
-
const toolUseEvents = mapToolUseAsStreamEvents();
|
|
540
|
-
if (toolUseEvents) {
|
|
541
|
-
return toolUseEvents;
|
|
542
|
-
}
|
|
543
|
-
return [];
|
|
544
|
-
}
|
|
545
|
-
function processCodexJsonLine(cleanedLine) {
|
|
546
|
-
try {
|
|
547
|
-
const parsed = JSON.parse(cleanedLine);
|
|
548
|
-
const eventsToProcess = (() => {
|
|
549
|
-
var _a, _b;
|
|
550
|
-
const outerType = typeof parsed.type === "string" ? parsed.type : "";
|
|
551
|
-
if (outerType === "event_msg") {
|
|
552
|
-
const payload = parsed.payload;
|
|
553
|
-
if (payload && typeof payload === "object") {
|
|
554
|
-
return [withSessionFields(payload, parsed)];
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
const nestedEventCandidates = [parsed.event, parsed.data];
|
|
558
|
-
for (const candidate of nestedEventCandidates) {
|
|
559
|
-
if (candidate && typeof candidate === "object" && !Array.isArray(candidate)) {
|
|
560
|
-
const candidateObj = candidate;
|
|
561
|
-
if (typeof candidateObj.type === "string") {
|
|
562
|
-
return [withSessionFields(candidateObj, parsed)];
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
const isItemEnvelope = outerType === "item.started" || outerType === "item.completed" || outerType === "item.updated" || outerType === "item.added" || outerType.startsWith("response.output_item.");
|
|
567
|
-
if (isItemEnvelope) {
|
|
568
|
-
const item = parsed.item;
|
|
569
|
-
if (item && typeof item === "object") {
|
|
570
|
-
const itemEvent = withEnvelopeIdentifiers(
|
|
571
|
-
withSessionFields(item, parsed),
|
|
572
|
-
parsed
|
|
573
|
-
);
|
|
574
|
-
itemEvent.envelope_type = outerType;
|
|
575
|
-
if (typeof itemEvent.type === "string" && itemEvent.type.toLowerCase() === "message") {
|
|
576
|
-
itemEvent.type = "agent_message";
|
|
577
|
-
}
|
|
578
|
-
return [itemEvent];
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
if (outerType === "response.output_text.delta") {
|
|
582
|
-
const delta = getStringValue(parsed, ["delta", "text"]);
|
|
583
|
-
if (delta) {
|
|
584
|
-
return [withSessionFields({ type: "agent_message_delta", delta }, parsed)];
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
if (outerType === "response.completed") {
|
|
588
|
-
return [withSessionFields({ type: "turn.completed", result: (_a = parsed.response) != null ? _a : parsed.result }, parsed)];
|
|
589
|
-
}
|
|
590
|
-
if (outerType === "response.failed") {
|
|
591
|
-
return [withSessionFields({ type: "turn.failed", error: (_b = parsed.error) != null ? _b : parsed.response }, parsed)];
|
|
592
|
-
}
|
|
593
|
-
return [parsed];
|
|
594
|
-
})();
|
|
595
|
-
const diagnostics = eventsToProcess.map((event) => extractCodexDiagnosticFromEvent(event)).filter((diag) => !!diag);
|
|
596
|
-
const mappedEvents = eventsToProcess.flatMap((event) => mapCodexEventToUIEvents(event));
|
|
597
|
-
return {
|
|
598
|
-
mappedEvents,
|
|
599
|
-
diagnostics
|
|
600
|
-
};
|
|
601
|
-
} catch {
|
|
602
|
-
return {
|
|
603
|
-
mappedEvents: [],
|
|
604
|
-
diagnostics: [],
|
|
605
|
-
nonJson: cleanedLine
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
}
|
|
8
|
+
import 'node:http';
|
|
9
|
+
import 'node:https';
|
|
10
|
+
import 'node:crypto';
|
|
11
|
+
import 'stream';
|
|
12
|
+
import 'events';
|
|
13
|
+
import 'http';
|
|
14
|
+
import 'crypto';
|
|
15
|
+
import 'buffer';
|
|
16
|
+
import 'zlib';
|
|
17
|
+
import 'https';
|
|
18
|
+
import 'net';
|
|
19
|
+
import 'tls';
|
|
20
|
+
import 'url';
|
|
21
|
+
import 'node:events';
|
|
22
|
+
import 'node:buffer';
|
|
23
|
+
import 'node:fs/promises';
|
|
24
|
+
import 'child_process';
|
|
25
|
+
import 'util';
|
|
26
|
+
import 'node:module';
|
|
27
|
+
import 'node:url';
|
|
609
28
|
|
|
610
29
|
function detectCodexCli() {
|
|
611
30
|
if (typeof process.env.CODEX_CLI_PATH === "string" && process.env.CODEX_CLI_PATH.length > 0 && existsSync(process.env.CODEX_CLI_PATH)) {
|
|
@@ -648,20 +67,10 @@ function isCodexAvailable() {
|
|
|
648
67
|
return false;
|
|
649
68
|
}
|
|
650
69
|
}
|
|
651
|
-
function
|
|
652
|
-
|
|
653
|
-
proc.kill("SIGTERM");
|
|
654
|
-
const forceKillTimer = setTimeout(() => {
|
|
655
|
-
try {
|
|
656
|
-
proc.kill("SIGKILL");
|
|
657
|
-
} catch {
|
|
658
|
-
}
|
|
659
|
-
}, 3e3);
|
|
660
|
-
proc.once("exit", () => clearTimeout(forceKillTimer));
|
|
661
|
-
} catch {
|
|
662
|
-
}
|
|
70
|
+
function safePathSegment(value) {
|
|
71
|
+
return value.replace(/[^a-zA-Z0-9._-]/g, "-").slice(0, 120) || "default";
|
|
663
72
|
}
|
|
664
|
-
function resolveCodexHomeForSpawn(ephemeral) {
|
|
73
|
+
function resolveCodexHomeForSpawn(ephemeral, hookHomeKey) {
|
|
665
74
|
const sourceCodexHome = (() => {
|
|
666
75
|
if (typeof process.env.CODEX_HOME === "string" && process.env.CODEX_HOME.length > 0) {
|
|
667
76
|
return process.env.CODEX_HOME;
|
|
@@ -719,6 +128,25 @@ function resolveCodexHomeForSpawn(ephemeral) {
|
|
|
719
128
|
}
|
|
720
129
|
}
|
|
721
130
|
}
|
|
131
|
+
if (hookHomeKey) {
|
|
132
|
+
try {
|
|
133
|
+
const managedHome = getSpecCatStorePath(join("codex-home", safePathSegment(hookHomeKey)));
|
|
134
|
+
mkdirSync(managedHome, { recursive: true });
|
|
135
|
+
seedCodexAuth(managedHome);
|
|
136
|
+
if (sourceCodexHome && sourceCodexHome !== managedHome) {
|
|
137
|
+
const realSessions = join(sourceCodexHome, "sessions");
|
|
138
|
+
const linkedSessions = join(managedHome, "sessions");
|
|
139
|
+
if (existsSync(realSessions) && !existsSync(linkedSessions)) {
|
|
140
|
+
try {
|
|
141
|
+
symlinkSync(realSessions, linkedSessions, "dir");
|
|
142
|
+
} catch {
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return managedHome;
|
|
147
|
+
} catch {
|
|
148
|
+
}
|
|
149
|
+
}
|
|
722
150
|
if (typeof process.env.CODEX_HOME === "string" && process.env.CODEX_HOME.length > 0) {
|
|
723
151
|
return process.env.CODEX_HOME;
|
|
724
152
|
}
|
|
@@ -806,206 +234,13 @@ const metadata = {
|
|
|
806
234
|
conflictResolution: true
|
|
807
235
|
}
|
|
808
236
|
};
|
|
809
|
-
function buildCodexExecArgs(opts) {
|
|
810
|
-
const isResume = !!opts.resumeSessionId;
|
|
811
|
-
const args = isResume ? ["exec", "resume", "--json", "--model", opts.selection.modelKey] : ["exec", "--json", "--model", opts.selection.modelKey];
|
|
812
|
-
if (opts.ephemeral) {
|
|
813
|
-
args.push("--ephemeral");
|
|
814
|
-
}
|
|
815
|
-
const mode = opts.permissionMode || "ask";
|
|
816
|
-
switch (mode) {
|
|
817
|
-
case "plan":
|
|
818
|
-
case "ask":
|
|
819
|
-
if (!isResume) {
|
|
820
|
-
args.push("--sandbox", "workspace-write");
|
|
821
|
-
}
|
|
822
|
-
break;
|
|
823
|
-
case "auto":
|
|
824
|
-
args.push("--full-auto");
|
|
825
|
-
break;
|
|
826
|
-
case "bypass":
|
|
827
|
-
args.push("--dangerously-bypass-approvals-and-sandbox");
|
|
828
|
-
break;
|
|
829
|
-
}
|
|
830
|
-
if (opts.resumeSessionId) {
|
|
831
|
-
args.push(opts.resumeSessionId, "-");
|
|
832
|
-
} else {
|
|
833
|
-
args.push("-");
|
|
834
|
-
}
|
|
835
|
-
return args;
|
|
836
|
-
}
|
|
837
|
-
function buildCodexPrompt(opts) {
|
|
838
|
-
if (!opts.systemPrompt) {
|
|
839
|
-
return opts.message;
|
|
840
|
-
}
|
|
841
|
-
return [
|
|
842
|
-
"System instructions:",
|
|
843
|
-
opts.systemPrompt,
|
|
844
|
-
"",
|
|
845
|
-
"User request:",
|
|
846
|
-
opts.message
|
|
847
|
-
].join("\n");
|
|
848
|
-
}
|
|
849
|
-
function extractSessionIdFromRecord(input) {
|
|
850
|
-
const directKeys = [
|
|
851
|
-
"thread_id",
|
|
852
|
-
"threadId",
|
|
853
|
-
"session_id",
|
|
854
|
-
"sessionId",
|
|
855
|
-
"conversation_id",
|
|
856
|
-
"conversationId"
|
|
857
|
-
];
|
|
858
|
-
for (const key of directKeys) {
|
|
859
|
-
const value = input[key];
|
|
860
|
-
if (typeof value === "string" && value.trim().length > 0) {
|
|
861
|
-
return value;
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
const nestedKeys = ["event", "payload", "data", "response", "item"];
|
|
865
|
-
for (const nestedKey of nestedKeys) {
|
|
866
|
-
const nested = input[nestedKey];
|
|
867
|
-
if (nested && typeof nested === "object" && !Array.isArray(nested)) {
|
|
868
|
-
const nestedSessionId = extractSessionIdFromRecord(nested);
|
|
869
|
-
if (nestedSessionId) {
|
|
870
|
-
return nestedSessionId;
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
return null;
|
|
875
|
-
}
|
|
876
237
|
const codexProvider = {
|
|
877
238
|
metadata,
|
|
878
|
-
toCanonicalEvents(data) {
|
|
879
|
-
return transformCodexEvent(data);
|
|
880
|
-
},
|
|
881
|
-
streamChat(opts, callbacks) {
|
|
882
|
-
var _a, _b;
|
|
883
|
-
const cliPath = getCodexCliPath();
|
|
884
|
-
const fallbackCodexHome = resolveCodexHomeForSpawn(!!opts.ephemeral);
|
|
885
|
-
const disposableCodexHome = fallbackCodexHome && basename(fallbackCodexHome).startsWith("codex-home-") ? fallbackCodexHome : null;
|
|
886
|
-
let codexHomeCleaned = false;
|
|
887
|
-
const cleanupCodexHome = () => {
|
|
888
|
-
if (codexHomeCleaned || !disposableCodexHome) return;
|
|
889
|
-
codexHomeCleaned = true;
|
|
890
|
-
try {
|
|
891
|
-
rmSync(disposableCodexHome, { recursive: true, force: true });
|
|
892
|
-
} catch {
|
|
893
|
-
}
|
|
894
|
-
};
|
|
895
|
-
const args = buildCodexExecArgs(opts);
|
|
896
|
-
const prompt = buildCodexPrompt(opts);
|
|
897
|
-
const isBypassLike = (opts.permissionMode || "ask") === "bypass" || (opts.permissionMode || "ask") === "auto";
|
|
898
|
-
const syntheticToolCount = 32;
|
|
899
|
-
let sessionInitEmitted = false;
|
|
900
|
-
let discoveredSessionId = null;
|
|
901
|
-
const emitSessionInit = (sessionId) => {
|
|
902
|
-
if (sessionInitEmitted) return;
|
|
903
|
-
callbacks.onProviderJson({
|
|
904
|
-
type: "session_init",
|
|
905
|
-
sessionId,
|
|
906
|
-
model: opts.selection.modelKey,
|
|
907
|
-
tools: Array.from({ length: syntheticToolCount }, (_, idx) => `tool-${idx + 1}`),
|
|
908
|
-
permissionMode: isBypassLike ? "bypassPermissions" : opts.permissionMode || "ask",
|
|
909
|
-
cwd: opts.cwd
|
|
910
|
-
});
|
|
911
|
-
sessionInitEmitted = true;
|
|
912
|
-
};
|
|
913
|
-
if (opts.resumeSessionId) {
|
|
914
|
-
discoveredSessionId = opts.resumeSessionId;
|
|
915
|
-
emitSessionInit(opts.resumeSessionId);
|
|
916
|
-
}
|
|
917
|
-
const proc = spawn(cliPath, args, {
|
|
918
|
-
cwd: opts.cwd,
|
|
919
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
920
|
-
env: {
|
|
921
|
-
...process.env,
|
|
922
|
-
NODE_NO_WARNINGS: "1",
|
|
923
|
-
NO_COLOR: "1",
|
|
924
|
-
...fallbackCodexHome ? { CODEX_HOME: fallbackCodexHome } : {}
|
|
925
|
-
}
|
|
926
|
-
});
|
|
927
|
-
if (proc.stdin) {
|
|
928
|
-
proc.stdin.on("error", () => {
|
|
929
|
-
});
|
|
930
|
-
proc.stdin.write(prompt);
|
|
931
|
-
proc.stdin.end();
|
|
932
|
-
}
|
|
933
|
-
let stdoutBuffer = "";
|
|
934
|
-
let stderrBuffer = "";
|
|
935
|
-
const nonJsonOutput = [];
|
|
936
|
-
const handleStreamChunk = (chunk, stream) => {
|
|
937
|
-
const merged = (stream === "stdout" ? stdoutBuffer : stderrBuffer) + chunk;
|
|
938
|
-
const lines = merged.split("\n");
|
|
939
|
-
const tail = lines.pop() || "";
|
|
940
|
-
if (stream === "stdout") {
|
|
941
|
-
stdoutBuffer = tail;
|
|
942
|
-
} else {
|
|
943
|
-
stderrBuffer = tail;
|
|
944
|
-
}
|
|
945
|
-
for (const line of lines) {
|
|
946
|
-
const cleaned = line.trim();
|
|
947
|
-
if (!cleaned) continue;
|
|
948
|
-
try {
|
|
949
|
-
const parsed = JSON.parse(cleaned);
|
|
950
|
-
const candidateSessionId = extractSessionIdFromRecord(parsed);
|
|
951
|
-
if (candidateSessionId && !discoveredSessionId) {
|
|
952
|
-
discoveredSessionId = candidateSessionId;
|
|
953
|
-
emitSessionInit(candidateSessionId);
|
|
954
|
-
}
|
|
955
|
-
} catch {
|
|
956
|
-
}
|
|
957
|
-
const processed = processCodexJsonLine(cleaned);
|
|
958
|
-
nonJsonOutput.push(...processed.diagnostics);
|
|
959
|
-
if (processed.nonJson) {
|
|
960
|
-
nonJsonOutput.push(processed.nonJson);
|
|
961
|
-
continue;
|
|
962
|
-
}
|
|
963
|
-
for (const mapped of processed.mappedEvents) {
|
|
964
|
-
callbacks.onProviderJson(mapped);
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
};
|
|
968
|
-
(_a = proc.stdout) == null ? void 0 : _a.on("data", (data) => {
|
|
969
|
-
handleStreamChunk(data.toString(), "stdout");
|
|
970
|
-
});
|
|
971
|
-
(_b = proc.stderr) == null ? void 0 : _b.on("data", (data) => {
|
|
972
|
-
handleStreamChunk(data.toString(), "stderr");
|
|
973
|
-
});
|
|
974
|
-
proc.on("close", (exitCode, signal) => {
|
|
975
|
-
if (!sessionInitEmitted) {
|
|
976
|
-
emitSessionInit(discoveredSessionId || void 0);
|
|
977
|
-
}
|
|
978
|
-
const flushTail = (tail) => {
|
|
979
|
-
const cleaned = tail.trim();
|
|
980
|
-
if (!cleaned) return;
|
|
981
|
-
const processed = processCodexJsonLine(cleaned);
|
|
982
|
-
nonJsonOutput.push(...processed.diagnostics);
|
|
983
|
-
if (processed.nonJson) {
|
|
984
|
-
nonJsonOutput.push(processed.nonJson);
|
|
985
|
-
return;
|
|
986
|
-
}
|
|
987
|
-
for (const mapped of processed.mappedEvents) {
|
|
988
|
-
callbacks.onProviderJson(mapped);
|
|
989
|
-
}
|
|
990
|
-
};
|
|
991
|
-
flushTail(stdoutBuffer);
|
|
992
|
-
flushTail(stderrBuffer);
|
|
993
|
-
cleanupCodexHome();
|
|
994
|
-
callbacks.onClose({ exitCode, signal, nonJsonOutput });
|
|
995
|
-
});
|
|
996
|
-
proc.on("error", (error) => {
|
|
997
|
-
cleanupCodexHome();
|
|
998
|
-
callbacks.onError(error);
|
|
999
|
-
});
|
|
1000
|
-
return {
|
|
1001
|
-
kill: () => killProc(proc)
|
|
1002
|
-
};
|
|
1003
|
-
},
|
|
1004
239
|
isModelSupported(modelKey) {
|
|
1005
240
|
return metadata.models.some((model) => model.key === modelKey);
|
|
1006
241
|
}
|
|
1007
242
|
};
|
|
1008
243
|
registerProvider(codexProvider);
|
|
1009
244
|
|
|
1010
|
-
export {
|
|
245
|
+
export { codexProvider as default, resolveCodexHomeForSpawn };
|
|
1011
246
|
//# sourceMappingURL=codexProvider.mjs.map
|