frizz-server 0.15.1 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev-child.js +302 -966
- package/package.json +2 -4
- package/web-dist/assets/{abnfDiagram-VRR7QNED-CZEP8flc.js → abnfDiagram-VRR7QNED-F0qjxmRk.js} +1 -1
- package/web-dist/assets/{arc-BSyeo0Gb.js → arc-CrYFqZTr.js} +1 -1
- package/web-dist/assets/architecture-TIHT7OUA-C0JxXLr4.js +1 -0
- package/web-dist/assets/architectureDiagram-ZJ3FMSHR-CDc4YHK_.js +36 -0
- package/web-dist/assets/{blockDiagram-677ZJIJ3-CsJ7cQv7.js → blockDiagram-677ZJIJ3-BYGw-JxJ.js} +1 -1
- package/web-dist/assets/{c4Diagram-LMCZKHZV-BueHBn6U.js → c4Diagram-LMCZKHZV-CXmtTgR3.js} +1 -1
- package/web-dist/assets/channel-DifAP5TB.js +1 -0
- package/web-dist/assets/{chunk-32BRIVSS-DxkYbkXg.js → chunk-32BRIVSS-Dcl1ahv1.js} +1 -1
- package/web-dist/assets/{chunk-52WLFC77-B4RUR7JZ.js → chunk-52WLFC77-Cxg8NzyU.js} +1 -1
- package/web-dist/assets/{chunk-C7G6YPKG-BLRgwvy4.js → chunk-C7G6YPKG-BTRJT4SU.js} +1 -1
- package/web-dist/assets/{chunk-EX3LRPZG-BAtxNbJC.js → chunk-EX3LRPZG-D3DsCkcK.js} +1 -1
- package/web-dist/assets/chunk-FWX5IMBZ-BaYxlniC.js +2 -0
- package/web-dist/assets/{chunk-HOUHSVGY-0dpVw62j.js → chunk-HOUHSVGY-BQvc97cd.js} +1 -1
- package/web-dist/assets/{chunk-ICXQ74PX-BZZPAhRZ.js → chunk-ICXQ74PX-CqUiFlzN.js} +1 -1
- package/web-dist/assets/{chunk-MOJQB5TN-ooRCpdkt.js → chunk-MOJQB5TN-BBiAo7jY.js} +1 -1
- package/web-dist/assets/{chunk-OGEWGWER-Ah-NEmel.js → chunk-OGEWGWER-CQv8z0Jl.js} +1 -1
- package/web-dist/assets/{chunk-PUDLZKDR-LtHfx3UY.js → chunk-PUDLZKDR-DgBWZqan.js} +1 -1
- package/web-dist/assets/{chunk-Q4XR5HBZ-Bd3maQzn.js → chunk-Q4XR5HBZ-BEkp4ta8.js} +1 -1
- package/web-dist/assets/{chunk-RYQCIY6F-Cu_KplZW.js → chunk-RYQCIY6F-DhqLIuZ8.js} +1 -1
- package/web-dist/assets/{chunk-V7JOEXUC-Baak7qeE.js → chunk-V7JOEXUC-CEKW_k2r.js} +1 -1
- package/web-dist/assets/{chunk-VAUOI2AC-DmUeRv29.js → chunk-VAUOI2AC-eG9Qea5F.js} +1 -1
- package/web-dist/assets/{chunk-VR4S4FIN-BpgSzLFF.js → chunk-VR4S4FIN-Dh9ykKIH.js} +1 -1
- package/web-dist/assets/{chunk-WYO6CB5R-PnbowZ3i.js → chunk-WYO6CB5R-aJO5_vM2.js} +1 -1
- package/web-dist/assets/{chunk-XXDRQBXY-DYlTP5J-.js → chunk-XXDRQBXY-CoME9yS2.js} +1 -1
- package/web-dist/assets/{chunk-ZGVPDNZ5-D5-YXqW9.js → chunk-ZGVPDNZ5-D7lz31EA.js} +1 -1
- package/web-dist/assets/classDiagram-OUVF2IWQ-DS2QgAdA.js +1 -0
- package/web-dist/assets/classDiagram-v2-EOCWNBFH-DS2QgAdA.js +1 -0
- package/web-dist/assets/cose-bilkent-JH36ORCC-BGjI6_fv.js +1 -0
- package/web-dist/assets/{cynefin-VYW2F7L2-8VyxZobI.js → cynefin-VYW2F7L2-BgKfWGcf.js} +1 -1
- package/web-dist/assets/{cynefinDiagram-TSTJHNR4-yFUBmk3y.js → cynefinDiagram-TSTJHNR4-Cf6G8uhA.js} +1 -1
- package/web-dist/assets/{dagre-VKFMJZFB-wUCK5Cyw.js → dagre-VKFMJZFB-Br1AERzs.js} +1 -1
- package/web-dist/assets/{diagram-FQU43EPY-CGzrn40X.js → diagram-FQU43EPY-Bz3S9gMS.js} +1 -1
- package/web-dist/assets/{diagram-G47NLZAW-DuhlaKXR.js → diagram-G47NLZAW-K3cSRbUU.js} +1 -1
- package/web-dist/assets/{diagram-NH7WQ7WH-CryBrnG8.js → diagram-NH7WQ7WH-D2CTX85x.js} +1 -1
- package/web-dist/assets/{diagram-OA4YK3LP-C_6Ugdyv.js → diagram-OA4YK3LP-C8ism6QE.js} +1 -1
- package/web-dist/assets/{diagram-WEI45ONY-CklWH5cu.js → diagram-WEI45ONY-B3QdWUgl.js} +1 -1
- package/web-dist/assets/dist-Dng9GpIG.js +1 -0
- package/web-dist/assets/{ebnfDiagram-CCIWWBDH-DmMOqNaR.js → ebnfDiagram-CCIWWBDH-Kcny1wgG.js} +1 -1
- package/web-dist/assets/{erDiagram-Q63AITRT-DBpmNhHP.js → erDiagram-Q63AITRT-DzhHVwtF.js} +1 -1
- package/web-dist/assets/eventmodeling-45OFAUF4-Ck66Gbxc.js +1 -0
- package/web-dist/assets/flowDiagram-23GEKE2U-D1a5GG8A.js +1 -0
- package/web-dist/assets/ganttDiagram-NO4QXBWP-DC8PuKr0.js +292 -0
- package/web-dist/assets/{gitGraph-TEB2WS4Q-CdNkzLjA.js → gitGraph-TEB2WS4Q-BkTxL5Im.js} +1 -1
- package/web-dist/assets/{gitGraphDiagram-IHSO6WYX-BrIGgHoU.js → gitGraphDiagram-IHSO6WYX-Cdv3PsZ7.js} +1 -1
- package/web-dist/assets/index-B6UpwCN9.js +321 -0
- package/web-dist/assets/index-BGha5d3h.css +2 -0
- package/web-dist/assets/{info-DKCQHKI2-BYiyjhUV.js → info-DKCQHKI2-_97Fm7OC.js} +1 -1
- package/web-dist/assets/{infoDiagram-FWYZ7A6U-5zjTG5N-.js → infoDiagram-FWYZ7A6U-DzEOuge1.js} +1 -1
- package/web-dist/assets/{ishikawaDiagram-FXEZZL3T-Ca2QU8ga.js → ishikawaDiagram-FXEZZL3T-DOH7kgxq.js} +1 -1
- package/web-dist/assets/{journeyDiagram-5HDEW3XC-CzUGQDiX.js → journeyDiagram-5HDEW3XC-W3Pb34TM.js} +1 -1
- package/web-dist/assets/{kanban-definition-HUTT4EX6-CjTCAZS0.js → kanban-definition-HUTT4EX6-m2wPO6Fw.js} +1 -1
- package/web-dist/assets/{line-uxNpP2NX.js → line-DDgEgp7v.js} +1 -1
- package/web-dist/assets/{linear-z2V0wJk9.js → linear-BvuJcg7R.js} +1 -1
- package/web-dist/assets/{mermaid-parser.core-BADU525L.js → mermaid-parser.core-E6zwJo_Q.js} +3 -3
- package/web-dist/assets/{mermaid.core-OvwlqnDg.js → mermaid.core-CdPWWaNX.js} +3 -3
- package/web-dist/assets/{mindmap-definition-LN4V7U3C-BtbgfcR8.js → mindmap-definition-LN4V7U3C-CQSuoX8Y.js} +1 -1
- package/web-dist/assets/{packet-7NZHBO7P-BsfLS3kE.js → packet-7NZHBO7P-IYL-kxKk.js} +1 -1
- package/web-dist/assets/{pegDiagram-2B236MQR-CB5AkYXG.js → pegDiagram-2B236MQR-77nrZw7p.js} +1 -1
- package/web-dist/assets/{pie-RZYD4A2V-DgnPemgQ.js → pie-RZYD4A2V-D-HMkMEp.js} +1 -1
- package/web-dist/assets/{pieDiagram-ENE6RG2P-DgiTOSOg.js → pieDiagram-ENE6RG2P-BBT3oTRw.js} +1 -1
- package/web-dist/assets/{quadrantDiagram-ABIIQ3AL-D56bxzKq.js → quadrantDiagram-ABIIQ3AL-D9sakySA.js} +1 -1
- package/web-dist/assets/{radar-I7S5WNFK-Buix85nx.js → radar-I7S5WNFK-Du2wwhvU.js} +1 -1
- package/web-dist/assets/{railroad-3IZDKUUU-_-csUIwQ.js → railroad-3IZDKUUU-BeovO7I9.js} +1 -1
- package/web-dist/assets/railroad-abnf-AHOZXSZD-v680F1ic.js +1 -0
- package/web-dist/assets/railroad-ebnf-EBAXGLYW-CRJ63M2I.js +1 -0
- package/web-dist/assets/railroad-peg-LSFZ7HO6-BGk4vBZ5.js +1 -0
- package/web-dist/assets/{railroadDiagram-RFXS5EU6-C5pjXI43.js → railroadDiagram-RFXS5EU6-DkT02ymw.js} +1 -1
- package/web-dist/assets/{requirementDiagram-TGXJPOKE-DKG82b1A.js → requirementDiagram-TGXJPOKE-OTDOS7go.js} +1 -1
- package/web-dist/assets/{sankeyDiagram-HTMAVEWB-xNsa0WzO.js → sankeyDiagram-HTMAVEWB-CFv8QoQv.js} +1 -1
- package/web-dist/assets/{sequenceDiagram-DBY2YBRQ-CWHvrs9Q.js → sequenceDiagram-DBY2YBRQ-BxtgEXN_.js} +1 -1
- package/web-dist/assets/src-Bw9IVjiO.js +1 -0
- package/web-dist/assets/{stateDiagram-2N3HPSRC-DirRfNzF.js → stateDiagram-2N3HPSRC-CONF36mF.js} +1 -1
- package/web-dist/assets/stateDiagram-v2-6OUMAXLB-BQHK4Pf5.js +1 -0
- package/web-dist/assets/{swimlanes-5IMT3BWC-B0GC66v6.js → swimlanes-5IMT3BWC-BWd7faiv.js} +1 -1
- package/web-dist/assets/swimlanesDiagram-G3AALYLV-B-4qgyuU.js +8 -0
- package/web-dist/assets/{timeline-definition-FHXFAJF6-D-UsR0sc.js → timeline-definition-FHXFAJF6-OR-dwLCj.js} +1 -1
- package/web-dist/assets/{treeView-QDETBFTQ-BcjBpVxS.js → treeView-QDETBFTQ-DtnexCv7.js} +1 -1
- package/web-dist/assets/{treemap-6X3UGDF4-CrsT6ziM.js → treemap-6X3UGDF4-Ll9_imgW.js} +1 -1
- package/web-dist/assets/{vennDiagram-L72KCM5P-DrY93og0.js → vennDiagram-L72KCM5P-CKJ53gnu.js} +1 -1
- package/web-dist/assets/{wardley-OPB4EBWU-D1WgLKZM.js → wardley-OPB4EBWU-C5WP1BQ8.js} +1 -1
- package/web-dist/assets/{wardleyDiagram-EHGQE667-BJ5hU4aG.js → wardleyDiagram-EHGQE667-DVyy-odH.js} +1 -1
- package/web-dist/assets/{xychartDiagram-FW5EYKEG-DS28rhax.js → xychartDiagram-FW5EYKEG-DDv_yf-W.js} +1 -1
- package/web-dist/index.html +2 -3
- package/web-dist/assets/TerminalPane-ChkS6RgS.js +0 -7
- package/web-dist/assets/architecture-TIHT7OUA-D3wgsRS5.js +0 -1
- package/web-dist/assets/architectureDiagram-ZJ3FMSHR-BEXzrjrX.js +0 -36
- package/web-dist/assets/channel-DCxTKTH_.js +0 -1
- package/web-dist/assets/chunk-FWX5IMBZ-BSC2st3T.js +0 -2
- package/web-dist/assets/classDiagram-OUVF2IWQ-DWiNurp2.js +0 -1
- package/web-dist/assets/classDiagram-v2-EOCWNBFH-DWiNurp2.js +0 -1
- package/web-dist/assets/cose-bilkent-JH36ORCC-BUIsLrGc.js +0 -1
- package/web-dist/assets/dist-DoH_9pyS.js +0 -1
- package/web-dist/assets/eventmodeling-45OFAUF4-CRp1CVTM.js +0 -1
- package/web-dist/assets/flowDiagram-23GEKE2U-lZUkMIKX.js +0 -1
- package/web-dist/assets/ganttDiagram-NO4QXBWP-BVFPEPZK.js +0 -292
- package/web-dist/assets/index-D5dploZD.js +0 -321
- package/web-dist/assets/index-Wees4UUL.css +0 -1
- package/web-dist/assets/railroad-abnf-AHOZXSZD-BGBPTyyT.js +0 -1
- package/web-dist/assets/railroad-ebnf-EBAXGLYW-isH8svgX.js +0 -1
- package/web-dist/assets/railroad-peg-LSFZ7HO6-DAuLC_Z3.js +0 -1
- package/web-dist/assets/rolldown-runtime-Bh1tDfsg.js +0 -1
- package/web-dist/assets/src-C4XfhTaE.js +0 -1
- package/web-dist/assets/stateDiagram-v2-6OUMAXLB-D58IKdqf.js +0 -1
- package/web-dist/assets/swimlanesDiagram-G3AALYLV-B1vaMvkV.js +0 -8
package/dist/dev-child.js
CHANGED
|
@@ -13812,7 +13812,7 @@ function parseGithubWakeSteer(text2) {
|
|
|
13812
13812
|
function frizzRoute(path3) {
|
|
13813
13813
|
return `${FRIZZ_ROUTE_PREFIX}${path3.startsWith("/") ? path3 : `/${path3}`}`;
|
|
13814
13814
|
}
|
|
13815
|
-
var import_yaml, ATTACHMENT_IMAGE_EXTENSIONS, ATTACHMENT_TEXT_EXTENSIONS, ATTACHMENT_OFFICE_EXTENSIONS, ATTACHMENT_DATA_EXTENSIONS, ATTACHMENT_ARCHIVE_EXTENSIONS, ATTACHMENT_DOC_EXTENSIONS, ATTACHMENT_EXTENSIONS, ATTACHMENT_MAX_BASE64_CHARS, ATTACHMENT_MAX_BYTES, ATTACHMENT_EXT_SET, ATTACHMENT_ACCEPT, FrizzStatus, BlockMechanism, RuntimeState, Backend, CodexModel, ClaudeModel, AcpAgent, ACP_MODEL_PREFIX, AcpAgentModel, AcpAgentModels, AcpAgentModelsInput, ThreadProfileOption, ThreadAgent, SubAgentView, BgShellView, CompletionHoldOp, CompletionHold, AskOption, AskQuestion, PendingAsk, AwaitingHint, RETIRED_AWAITING_KINDS, RETIRED_LINE_RE, RETIRED_AWAITING_REPLACEMENT, AWAITING_KEY_RE, AWAITING_YAML_KEYS, AWAITING_SEQUENCE_KEYS, AWAITING_HINT_MAX, AWAITING_HINT_VALUE_MAX, AWAITING_TITLE_MAX, AWAITING_ITEM_KINDS, AWAITING_DURATION_RE, DURATION_UNIT_MS, AWAITING_FOR_MAX_MS, SnoozeUntil, SNOOZE_PROMPT_MAX, SnoozePrompt, RECURRING_PROMPT_MAX, RECURRING_MIN_INTERVAL_SECONDS, RECURRING_MAX_INTERVAL_SECONDS, RecurringPromptText, RecurringIntervalSeconds, ThreadRecurringPrompt, INTERRUPT_MARKERS, ALLDONE_SENTINEL, OPT_OUT_NOTE, OVER_QUESTION_NOTE, TIMER_PROMPT_MAX, TIMER_MAX_DELAY_SECONDS, TIMER_MAX_ARMED, TimerPromptText, PR_WATCH_SPENT_TRAILER, PR_WATCH_ARMED_TRAILER, SHELL_DONE_TRAILER, ISSUE_WATCH_SPENT_TRAILER, ISSUE_WATCH_ARMED_TRAILER, INTERRUPT_ENDED_LEAD, SIGNOFF_NUDGE_MARKER, SIGNOFF_NUDGE_MESSAGE, PARK_CORRECTION_NAMES_LEAD, PARK_CORRECTION_RETIRED_LEAD, PARK_CORRECTION_QUESTION_LEAD, ThreadWatchKind, GithubChecksState, GithubMergeState, GithubWatchStatus, GithubIssueStatus, ThreadWatchView, PR_WATCH_FOR_MAX_MS, PR_WATCH_DEFAULT_FOR_MS, PR_WATCH_MAX_ARMED, PrWatchView, AddOwnPrWatchInput, AddOwnPrWatchResult, DropOwnPrWatchInput, DropOwnPrWatchResult, OwnWatchKind, AddOwnWatchInput, OwnWatchView, AddOwnWatchResult, DropOwnWatchInput, DropOwnWatchResult, OWN_WATCH_MAX_ARMED, QUESTION_FENCE_RETIRED_AT, AskQuestionKind, ASK_MAX_DEPTH, AskedOptionSchema, AskedQuestionSchema, AskInput, RegisteredQuestionView, AskResult, UnaskInput, UnaskResult, QuestionAnswerSchema, AnswerQuestionsInput, AnswerQuestionsResult, DismissQuestionsInput, DismissQuestionsResult, BURIED_ANSWERS_HEADER, ANSWER_FOLLOW_UP_MARKER, ANSWER_CONTINUATION_INDENT, indentAnswerContinuation, DISMISSED_ANSWER, MarkOwnDoneInput, MarkOwnDoneResult, ListOwnPrWatchesInput, OwnPrWatchesResult, ThreadTimerView, ThreadFence, LimitWindow, LimitPause, ProviderError, ThreadLinkView, UpsertOwnLinkInput, UpsertOwnLinkResult, DropOwnLinkInput, DropOwnLinkResult, ThreadView, BoardErrorItem, BoardSnapshot, QuotaWindow, ProviderQuota, QuotaSnapshot, ProviderAuth, AccountEmails, AuthSnapshot, AccountBackend, AccountLogoutInput, AccountLogoutResult,
|
|
13815
|
+
var import_yaml, ATTACHMENT_IMAGE_EXTENSIONS, ATTACHMENT_TEXT_EXTENSIONS, ATTACHMENT_OFFICE_EXTENSIONS, ATTACHMENT_DATA_EXTENSIONS, ATTACHMENT_ARCHIVE_EXTENSIONS, ATTACHMENT_DOC_EXTENSIONS, ATTACHMENT_EXTENSIONS, ATTACHMENT_MAX_BASE64_CHARS, ATTACHMENT_MAX_BYTES, ATTACHMENT_EXT_SET, ATTACHMENT_ACCEPT, FrizzStatus, BlockMechanism, RuntimeState, Backend, CodexModel, ClaudeModel, AcpAgent, ACP_MODEL_PREFIX, AcpAgentModel, AcpAgentModels, AcpAgentModelsInput, ThreadProfileOption, ThreadAgent, SubAgentView, BgShellView, CompletionHoldOp, CompletionHold, AskOption, AskQuestion, PendingAsk, AwaitingHint, RETIRED_AWAITING_KINDS, RETIRED_LINE_RE, RETIRED_AWAITING_REPLACEMENT, AWAITING_KEY_RE, AWAITING_YAML_KEYS, AWAITING_SEQUENCE_KEYS, AWAITING_HINT_MAX, AWAITING_HINT_VALUE_MAX, AWAITING_TITLE_MAX, AWAITING_ITEM_KINDS, AWAITING_DURATION_RE, DURATION_UNIT_MS, AWAITING_FOR_MAX_MS, SnoozeUntil, SNOOZE_PROMPT_MAX, SnoozePrompt, RECURRING_PROMPT_MAX, RECURRING_MIN_INTERVAL_SECONDS, RECURRING_MAX_INTERVAL_SECONDS, RecurringPromptText, RecurringIntervalSeconds, ThreadRecurringPrompt, INTERRUPT_MARKERS, ALLDONE_SENTINEL, OPT_OUT_NOTE, OVER_QUESTION_NOTE, TIMER_PROMPT_MAX, TIMER_MAX_DELAY_SECONDS, TIMER_MAX_ARMED, TimerPromptText, PR_WATCH_SPENT_TRAILER, PR_WATCH_ARMED_TRAILER, SHELL_DONE_TRAILER, ISSUE_WATCH_SPENT_TRAILER, ISSUE_WATCH_ARMED_TRAILER, INTERRUPT_ENDED_LEAD, SIGNOFF_NUDGE_MARKER, SIGNOFF_NUDGE_MESSAGE, PARK_CORRECTION_NAMES_LEAD, PARK_CORRECTION_RETIRED_LEAD, PARK_CORRECTION_QUESTION_LEAD, ThreadWatchKind, GithubChecksState, GithubMergeState, GithubWatchStatus, GithubIssueStatus, ThreadWatchView, PR_WATCH_FOR_MAX_MS, PR_WATCH_DEFAULT_FOR_MS, PR_WATCH_MAX_ARMED, PrWatchView, AddOwnPrWatchInput, AddOwnPrWatchResult, DropOwnPrWatchInput, DropOwnPrWatchResult, OwnWatchKind, AddOwnWatchInput, OwnWatchView, AddOwnWatchResult, DropOwnWatchInput, DropOwnWatchResult, OWN_WATCH_MAX_ARMED, QUESTION_FENCE_RETIRED_AT, AskQuestionKind, ASK_MAX_DEPTH, AskedOptionSchema, AskedQuestionSchema, AskInput, RegisteredQuestionView, AskResult, UnaskInput, UnaskResult, QuestionAnswerSchema, AnswerQuestionsInput, AnswerQuestionsResult, DismissQuestionsInput, DismissQuestionsResult, BURIED_ANSWERS_HEADER, ANSWER_FOLLOW_UP_MARKER, ANSWER_CONTINUATION_INDENT, indentAnswerContinuation, DISMISSED_ANSWER, MarkOwnDoneInput, MarkOwnDoneResult, ListOwnPrWatchesInput, OwnPrWatchesResult, ThreadTimerView, ThreadFence, LimitWindow, LimitPause, ProviderError, ThreadLinkView, UpsertOwnLinkInput, UpsertOwnLinkResult, DropOwnLinkInput, DropOwnLinkResult, ThreadView, BoardErrorItem, BoardSnapshot, QuotaWindow, ProviderQuota, QuotaSnapshot, ProviderAuth, AccountEmails, AuthSnapshot, AccountBackend, AccountLogoutInput, AccountLogoutResult, PermissionMode, LocalFileOpener, Settings, DispatchProviderPreferences, DispatchPreferences, DispatchProfileSnapshotShape, DispatchProfileSnapshot, SetDispatchPreferenceInput, DispatchInput, ADOPT_THREAD_MESSAGE_MAX_CHARS, AdoptThreadInput, AdoptThreadResult, AdoptSessionInput, FollowUpInput, UnqueueFollowUpInput, UnqueueFollowUpResult, DeliverQueuedNowInput, DeliverQueuedNowResult, SetThreadSnoozeInput, SetThreadPinnedInput, SetThreadRecurringPromptInput, SetOwnThreadRecurringPromptInput, SetOwnThreadRecurringPromptResult, GetOwnThreadRecurringPromptInput, OwnThreadRecurringPromptResult, SetOwnThreadTimerInput, CancelOwnThreadTimerInput, ListOwnThreadTimersInput, OwnThreadTimersResult, ThreadActivityItem, ListOwnThreadActivityInput, OwnThreadActivityResult, SetOwnThreadTimerResult, CancelOwnThreadTimerResult, SetOwnThreadStopHookInput, SetOwnThreadHeartbeatInput, ThreadPluginReloadResult, RenameThreadInput, AiRenameThreadInput, AiRenameThreadResult, SetOwnThreadTitleInput, SetOwnThreadTitleResult, SetThreadPermissionInput, SetThreadPermissionResult, ThreadProfileOptionsInput, ThreadProfileOptionsResult, ThreadSkillSource, ThreadSkill, ThreadSkillsInput, ThreadSkillsResult, SetThreadProfileInput, SetThreadProfileResult, UpgradeThreadModelInput, UpgradeThreadModelResult, DISPATCH_TASK_BANNER, DISPATCH_TASK_BANNER_MARKER, GITHUB_DISPATCH_UI_BOUNDARY, WAKE_TIME_HEADER_TAIL, WAKE_TRAILERS, HUMAN_GAP_FLOOR_MS, HUMAN_GAP_NOTE_TAIL, WAKE_DELIVERY_TOKEN_TAIL, WAKE_DELIVERY_TOKEN_LINE, NOISE_PREFIXES, AGENT_MESSAGE_WRAPPER, GithubWakeItem, GithubWakeSteer, WAKE_SCOPE, WAKE_REVIEW_LEAD, WAKE_BACKLOG_TAIL, WAKE_REF, WAKE_SINGLE, WAKE_MULTI_HEAD, WAKE_ITEM, WAKE_MORE, PR_WATCH_FINISHED, PR_WATCH_CI_PASSED, PR_WATCH_CI_GATED, PR_WATCH_STATE, PR_WATCH_CI_FAILED, GithubStatus, GithubRefCard, GithubRefPreviewInput, GithubRefPreviewResult, GithubItem, GithubListInput, GithubListResult, GithubBatchInput, GithubBatchResult, BoardMeta, ServerEvent, TranscriptEdit, TranscriptTodo, TranscriptToolCall, TranscriptPart, TranscriptMessage, TranscriptPageCursor, EditedFile, TranscriptPage, TranscriptEarlierInput, SocketTranscriptSlug, SocketFilePath, SocketTranscriptClientMsg, SocketFileClientMsg, SocketClientMsg, ProjectCard, ProjectRailCounts, PROJECT_ICON_EXTENSIONS, PROJECT_ICON_MAX_BASE64_CHARS, DirectoryPickResult, ThreadLocation, FRIZZ_ROUTE_PREFIX, DEFAULT_PORT, threadIdentityName;
|
|
13816
13816
|
var init_src = __esm({
|
|
13817
13817
|
"packages/shared/src/index.ts"() {
|
|
13818
13818
|
"use strict";
|
|
@@ -15007,13 +15007,6 @@ ${ANSWER_CONTINUATION_INDENT}`);
|
|
|
15007
15007
|
activeThreads: external_exports.number().int().positive().optional(),
|
|
15008
15008
|
detail: external_exports.string().max(200).optional()
|
|
15009
15009
|
});
|
|
15010
|
-
AccountLoginStartInput = external_exports.object({ backend: AccountBackend }).strict();
|
|
15011
|
-
AccountLoginStartResult = external_exports.object({ attemptId: ThreadSlug });
|
|
15012
|
-
AccountLoginStatusInput = external_exports.object({ attemptId: ThreadSlug }).strict();
|
|
15013
|
-
AccountLoginStatusResult = external_exports.object({
|
|
15014
|
-
state: external_exports.enum(["running", "exited", "unknown"]),
|
|
15015
|
-
auth: ProviderAuth
|
|
15016
|
-
});
|
|
15017
15010
|
PermissionMode = external_exports.enum(["auto", "default", "acceptEdits", "plan", "bypassPermissions"]);
|
|
15018
15011
|
LocalFileOpener = external_exports.enum(["system", "cursor", "vscode", "finder", "copy"]);
|
|
15019
15012
|
Settings = external_exports.object({
|
|
@@ -17841,7 +17834,7 @@ var init_sqlite_quiet = __esm({
|
|
|
17841
17834
|
});
|
|
17842
17835
|
|
|
17843
17836
|
// packages/server/src/sqlite.ts
|
|
17844
|
-
import { createRequire
|
|
17837
|
+
import { createRequire } from "node:module";
|
|
17845
17838
|
function namedParameters(sql) {
|
|
17846
17839
|
const found = /* @__PURE__ */ new Set();
|
|
17847
17840
|
for (let index = 0; index < sql.length; index++) {
|
|
@@ -17905,7 +17898,7 @@ var init_sqlite = __esm({
|
|
|
17905
17898
|
"packages/server/src/sqlite.ts"() {
|
|
17906
17899
|
"use strict";
|
|
17907
17900
|
init_sqlite_quiet();
|
|
17908
|
-
({ DatabaseSync } =
|
|
17901
|
+
({ DatabaseSync } = createRequire(import.meta.url)("node:sqlite"));
|
|
17909
17902
|
PreparedStatement = class {
|
|
17910
17903
|
#statement;
|
|
17911
17904
|
#required;
|
|
@@ -20915,9 +20908,9 @@ var init_storage = __esm({
|
|
|
20915
20908
|
|
|
20916
20909
|
// packages/server/src/machine-config.ts
|
|
20917
20910
|
import { closeSync as closeSync5, fsyncSync as fsyncSync5, mkdirSync as mkdirSync7, openSync as openSync6, readFileSync as readFileSync6, renameSync as renameSync5, rmSync as rmSync6, writeFileSync as writeFileSync6 } from "node:fs";
|
|
20918
|
-
import { dirname as
|
|
20911
|
+
import { dirname as dirname6, join as join9 } from "node:path";
|
|
20919
20912
|
function machineConfigPath(home) {
|
|
20920
|
-
return
|
|
20913
|
+
return join9(frizzPaths({ home }).data, "config.json");
|
|
20921
20914
|
}
|
|
20922
20915
|
function readAll(home) {
|
|
20923
20916
|
let raw2;
|
|
@@ -20930,7 +20923,7 @@ function readAll(home) {
|
|
|
20930
20923
|
}
|
|
20931
20924
|
function writeAll(home, all) {
|
|
20932
20925
|
const path3 = machineConfigPath(home);
|
|
20933
|
-
mkdirSync7(
|
|
20926
|
+
mkdirSync7(dirname6(path3), { recursive: true });
|
|
20934
20927
|
const temp = `${path3}.${process.pid}.tmp`;
|
|
20935
20928
|
let fd2;
|
|
20936
20929
|
try {
|
|
@@ -20976,9 +20969,9 @@ var init_machine_config = __esm({
|
|
|
20976
20969
|
|
|
20977
20970
|
// packages/server/src/settings.ts
|
|
20978
20971
|
import { readFileSync as readFileSync7, rmSync as rmSync7 } from "node:fs";
|
|
20979
|
-
import { join as
|
|
20972
|
+
import { join as join10 } from "node:path";
|
|
20980
20973
|
function legacyMachineSettingsPath(home) {
|
|
20981
|
-
return
|
|
20974
|
+
return join10(frizzPaths({ home }).data, "settings.json");
|
|
20982
20975
|
}
|
|
20983
20976
|
function pickMachine(settings) {
|
|
20984
20977
|
return Object.fromEntries(MACHINE_KEYS.map((key) => [key, settings[key]]));
|
|
@@ -21312,8 +21305,8 @@ var init_codex_error = __esm({
|
|
|
21312
21305
|
});
|
|
21313
21306
|
|
|
21314
21307
|
// packages/server/src/discover.ts
|
|
21315
|
-
import { readdirSync as readdirSync3, statSync as
|
|
21316
|
-
import { dirname as
|
|
21308
|
+
import { readdirSync as readdirSync3, statSync as statSync4, openSync as openSync7, readSync, closeSync as closeSync6 } from "node:fs";
|
|
21309
|
+
import { dirname as dirname7, join as join11 } from "node:path";
|
|
21317
21310
|
function sentinelFor(sessionId) {
|
|
21318
21311
|
return `threads/${sessionId}/`;
|
|
21319
21312
|
}
|
|
@@ -21350,10 +21343,10 @@ function discoverTranscriptId(logDir, sessionId, opts = {}) {
|
|
|
21350
21343
|
if (name.startsWith(".") || !name.endsWith(".jsonl")) continue;
|
|
21351
21344
|
const id2 = name.slice(0, -".jsonl".length);
|
|
21352
21345
|
if (!id2 || id2 === sessionId || exclude?.has(id2)) continue;
|
|
21353
|
-
const path3 =
|
|
21346
|
+
const path3 = join11(logDir, name);
|
|
21354
21347
|
let mtime;
|
|
21355
21348
|
try {
|
|
21356
|
-
mtime =
|
|
21349
|
+
mtime = statSync4(path3).mtimeMs;
|
|
21357
21350
|
} catch {
|
|
21358
21351
|
continue;
|
|
21359
21352
|
}
|
|
@@ -21368,7 +21361,7 @@ function discoverTranscriptId(logDir, sessionId, opts = {}) {
|
|
|
21368
21361
|
}
|
|
21369
21362
|
function mtimeOfNonEmpty(path3) {
|
|
21370
21363
|
try {
|
|
21371
|
-
const st2 =
|
|
21364
|
+
const st2 = statSync4(path3, { throwIfNoEntry: false });
|
|
21372
21365
|
return st2 && st2.size > 0 ? st2.mtimeMs : void 0;
|
|
21373
21366
|
} catch {
|
|
21374
21367
|
return void 0;
|
|
@@ -21378,7 +21371,7 @@ function discoverTranscriptDir(logDir, sessionId, memo3 = strandedLogDirs) {
|
|
|
21378
21371
|
const name = `${sessionId}.jsonl`;
|
|
21379
21372
|
const better = (best2, dir) => {
|
|
21380
21373
|
if (dir === logDir) return best2;
|
|
21381
|
-
const at2 = mtimeOfNonEmpty(
|
|
21374
|
+
const at2 = mtimeOfNonEmpty(join11(dir, name));
|
|
21382
21375
|
if (at2 === void 0) return best2;
|
|
21383
21376
|
return !best2 || at2 > best2.mtimeMs ? { dir, mtimeMs: at2 } : best2;
|
|
21384
21377
|
};
|
|
@@ -21387,11 +21380,11 @@ function discoverTranscriptDir(logDir, sessionId, memo3 = strandedLogDirs) {
|
|
|
21387
21380
|
if (best) return best.dir;
|
|
21388
21381
|
let entries2;
|
|
21389
21382
|
try {
|
|
21390
|
-
entries2 = readdirSync3(
|
|
21383
|
+
entries2 = readdirSync3(dirname7(logDir), { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
21391
21384
|
} catch {
|
|
21392
21385
|
return void 0;
|
|
21393
21386
|
}
|
|
21394
|
-
for (const entry of entries2) best = better(best,
|
|
21387
|
+
for (const entry of entries2) best = better(best, join11(dirname7(logDir), entry));
|
|
21395
21388
|
if (!best) return void 0;
|
|
21396
21389
|
memo3.add(best.dir);
|
|
21397
21390
|
return best.dir;
|
|
@@ -21410,10 +21403,10 @@ var init_discover = __esm({
|
|
|
21410
21403
|
|
|
21411
21404
|
// packages/server/src/session-files.ts
|
|
21412
21405
|
import { lstatSync, rmSync as rmSync8 } from "node:fs";
|
|
21413
|
-
import { join as
|
|
21406
|
+
import { join as join12 } from "node:path";
|
|
21414
21407
|
function systemPromptPath(sessionId) {
|
|
21415
21408
|
if (!SESSION_ID_RE.test(sessionId)) throw new Error("invalid session id");
|
|
21416
|
-
return
|
|
21409
|
+
return join12(SYSTEM_PROMPT_DIR, `${sessionId}.md`);
|
|
21417
21410
|
}
|
|
21418
21411
|
function isDirectDirectory(path3) {
|
|
21419
21412
|
try {
|
|
@@ -21433,7 +21426,7 @@ function pathAbsent(path3) {
|
|
|
21433
21426
|
}
|
|
21434
21427
|
function unlinkDirectChild(parent, filename) {
|
|
21435
21428
|
if (!isDirectDirectory(parent)) return pathAbsent(parent);
|
|
21436
|
-
const child =
|
|
21429
|
+
const child = join12(parent, filename);
|
|
21437
21430
|
try {
|
|
21438
21431
|
rmSync8(child, { force: true });
|
|
21439
21432
|
} catch {
|
|
@@ -21443,12 +21436,12 @@ function unlinkDirectChild(parent, filename) {
|
|
|
21443
21436
|
}
|
|
21444
21437
|
function cleanupAdoptionSessionFiles(projectDir, sessionId) {
|
|
21445
21438
|
if (!SESSION_ID_RE.test(sessionId)) return false;
|
|
21446
|
-
const frizzDir =
|
|
21439
|
+
const frizzDir = join12(projectDir, ".frizz");
|
|
21447
21440
|
let clean = true;
|
|
21448
21441
|
if (isDirectDirectory(frizzDir)) {
|
|
21449
|
-
const threads =
|
|
21442
|
+
const threads = join12(frizzDir, "threads");
|
|
21450
21443
|
if (isDirectDirectory(threads)) {
|
|
21451
|
-
const child =
|
|
21444
|
+
const child = join12(threads, sessionId);
|
|
21452
21445
|
try {
|
|
21453
21446
|
rmSync8(child, { recursive: true, force: true });
|
|
21454
21447
|
} catch {
|
|
@@ -21700,10 +21693,10 @@ var init_adoption_recovery = __esm({
|
|
|
21700
21693
|
});
|
|
21701
21694
|
|
|
21702
21695
|
// packages/server/src/backend/codex-models.ts
|
|
21703
|
-
import { join as
|
|
21696
|
+
import { join as join13 } from "node:path";
|
|
21704
21697
|
import { readFileSync as readFileSync8 } from "node:fs";
|
|
21705
21698
|
function cachePath(codexHome) {
|
|
21706
|
-
return
|
|
21699
|
+
return join13(codexHome, "models_cache.json");
|
|
21707
21700
|
}
|
|
21708
21701
|
function toCodexModel(raw2) {
|
|
21709
21702
|
if (!raw2 || typeof raw2 !== "object") return void 0;
|
|
@@ -22422,10 +22415,10 @@ var init_claude_agent_sdk_protocol = __esm({
|
|
|
22422
22415
|
});
|
|
22423
22416
|
|
|
22424
22417
|
// packages/server/src/backend/claude-broker-diagnostics.ts
|
|
22425
|
-
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync8, readFileSync as readFileSync9, renameSync as renameSync6, statSync as
|
|
22426
|
-
import { join as
|
|
22418
|
+
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync8, readFileSync as readFileSync9, renameSync as renameSync6, statSync as statSync5 } from "node:fs";
|
|
22419
|
+
import { join as join14 } from "node:path";
|
|
22427
22420
|
function claudeBrokerDiagnosticLogPath(stateDir, sessionId) {
|
|
22428
|
-
return
|
|
22421
|
+
return join14(stateDir, "claude-broker", `${sessionId}.diagnostics.log`);
|
|
22429
22422
|
}
|
|
22430
22423
|
function readClaudeBrokerExit(stateDir, sessionId, generation) {
|
|
22431
22424
|
if (!generation) return null;
|
|
@@ -22526,10 +22519,10 @@ var init_daemon_tree = __esm({
|
|
|
22526
22519
|
});
|
|
22527
22520
|
|
|
22528
22521
|
// packages/server/src/backend/ipc-path.ts
|
|
22529
|
-
import { join as
|
|
22522
|
+
import { join as join15 } from "node:path";
|
|
22530
22523
|
function frizzIpcPath(name) {
|
|
22531
22524
|
if (process.platform === "win32") return `\\\\.\\pipe\\${name}`;
|
|
22532
|
-
return
|
|
22525
|
+
return join15(process.env.TMPDIR ?? "/tmp", `${name}.sock`);
|
|
22533
22526
|
}
|
|
22534
22527
|
var init_ipc_path = __esm({
|
|
22535
22528
|
"packages/server/src/backend/ipc-path.ts"() {
|
|
@@ -22541,7 +22534,7 @@ var init_ipc_path = __esm({
|
|
|
22541
22534
|
import { spawn } from "node:child_process";
|
|
22542
22535
|
import { createHash as createHash5, randomUUID as randomUUID8 } from "node:crypto";
|
|
22543
22536
|
import { accessSync, constants as fsConstants, mkdirSync as mkdirSync9, readFileSync as readFileSync10, readdirSync as readdirSync4, unlinkSync, writeFileSync as writeFileSync7 } from "node:fs";
|
|
22544
|
-
import { delimiter, dirname as
|
|
22537
|
+
import { delimiter, dirname as dirname8, isAbsolute as isAbsolute3, join as join16 } from "node:path";
|
|
22545
22538
|
function windowsShimTarget(shimPath) {
|
|
22546
22539
|
let body;
|
|
22547
22540
|
try {
|
|
@@ -22551,7 +22544,7 @@ function windowsShimTarget(shimPath) {
|
|
|
22551
22544
|
}
|
|
22552
22545
|
const target = WINDOWS_SHIM_TARGET.exec(body)?.[1];
|
|
22553
22546
|
if (!target) return void 0;
|
|
22554
|
-
const full =
|
|
22547
|
+
const full = join16(dirname8(shimPath), target);
|
|
22555
22548
|
try {
|
|
22556
22549
|
accessSync(full, fsConstants.F_OK);
|
|
22557
22550
|
return full;
|
|
@@ -22572,17 +22565,17 @@ function resolveClaudeExecutableAbsolute(bin, env = process.env) {
|
|
|
22572
22565
|
for (const dir of searchPath(env).split(delimiter)) {
|
|
22573
22566
|
if (!dir) continue;
|
|
22574
22567
|
if (windows) {
|
|
22575
|
-
const exe =
|
|
22568
|
+
const exe = join16(dir, `${candidate}.exe`);
|
|
22576
22569
|
try {
|
|
22577
22570
|
accessSync(exe, fsConstants.F_OK);
|
|
22578
22571
|
return exe;
|
|
22579
22572
|
} catch {
|
|
22580
22573
|
}
|
|
22581
|
-
const viaShim = windowsShimTarget(
|
|
22574
|
+
const viaShim = windowsShimTarget(join16(dir, `${candidate}.cmd`));
|
|
22582
22575
|
if (viaShim) return viaShim;
|
|
22583
22576
|
continue;
|
|
22584
22577
|
}
|
|
22585
|
-
const full =
|
|
22578
|
+
const full = join16(dir, candidate);
|
|
22586
22579
|
try {
|
|
22587
22580
|
accessSync(full, fsConstants.X_OK);
|
|
22588
22581
|
return full;
|
|
@@ -22597,17 +22590,17 @@ function claudeBrokerSocketPath(stateDir, sessionId) {
|
|
|
22597
22590
|
}
|
|
22598
22591
|
function claudeBrokerRecordPath(stateDir, sessionId) {
|
|
22599
22592
|
const key = createHash5("sha256").update(sessionId).digest("hex").slice(0, 16);
|
|
22600
|
-
return
|
|
22593
|
+
return join16(stateDir, "claude-broker", `${key}.json`);
|
|
22601
22594
|
}
|
|
22602
22595
|
function claudeBrokerRetirementPath(stateDir, sessionId) {
|
|
22603
22596
|
const key = createHash5("sha256").update(sessionId).digest("hex").slice(0, 16);
|
|
22604
|
-
return
|
|
22597
|
+
return join16(stateDir, "claude-broker", `${key}.retired`);
|
|
22605
22598
|
}
|
|
22606
22599
|
function markBrokerRetired(stateDir, sessionId, reason, generation) {
|
|
22607
22600
|
const mark = { at: (/* @__PURE__ */ new Date()).toISOString(), generation, reason };
|
|
22608
22601
|
try {
|
|
22609
22602
|
const path3 = claudeBrokerRetirementPath(stateDir, sessionId);
|
|
22610
|
-
mkdirSync9(
|
|
22603
|
+
mkdirSync9(dirname8(path3), { recursive: true });
|
|
22611
22604
|
writeFileSync7(path3, JSON.stringify(mark));
|
|
22612
22605
|
} catch {
|
|
22613
22606
|
}
|
|
@@ -22668,7 +22661,7 @@ function liveBrokerRecord(recordPath2) {
|
|
|
22668
22661
|
return null;
|
|
22669
22662
|
}
|
|
22670
22663
|
function liveBrokerRecords(stateDir) {
|
|
22671
|
-
const dir =
|
|
22664
|
+
const dir = join16(stateDir, "claude-broker");
|
|
22672
22665
|
let names;
|
|
22673
22666
|
try {
|
|
22674
22667
|
names = readdirSync4(dir);
|
|
@@ -22678,7 +22671,7 @@ function liveBrokerRecords(stateDir) {
|
|
|
22678
22671
|
const out = [];
|
|
22679
22672
|
for (const name of names) {
|
|
22680
22673
|
if (!name.endsWith(".json")) continue;
|
|
22681
|
-
const record = liveBrokerRecord(
|
|
22674
|
+
const record = liveBrokerRecord(join16(dir, name));
|
|
22682
22675
|
if (record) out.push(record);
|
|
22683
22676
|
}
|
|
22684
22677
|
return out;
|
|
@@ -22686,7 +22679,7 @@ function liveBrokerRecords(stateDir) {
|
|
|
22686
22679
|
function forkBroker(options) {
|
|
22687
22680
|
const socketPath = claudeBrokerSocketPath(options.stateDir, options.sessionId);
|
|
22688
22681
|
const recordPath2 = claudeBrokerRecordPath(options.stateDir, options.sessionId);
|
|
22689
|
-
mkdirSync9(
|
|
22682
|
+
mkdirSync9(dirname8(recordPath2), { recursive: true });
|
|
22690
22683
|
const generation = randomUUID8();
|
|
22691
22684
|
const config = {
|
|
22692
22685
|
socketPath,
|
|
@@ -23198,7 +23191,7 @@ var init_delivery_ledger = __esm({
|
|
|
23198
23191
|
});
|
|
23199
23192
|
|
|
23200
23193
|
// packages/server/src/codex-subagents.ts
|
|
23201
|
-
import { closeSync as closeSync7, openSync as openSync8, readSync as readSync2, statSync as
|
|
23194
|
+
import { closeSync as closeSync7, openSync as openSync8, readSync as readSync2, statSync as statSync6 } from "node:fs";
|
|
23202
23195
|
function createCodexSubAgentTracker(deps) {
|
|
23203
23196
|
const findRollouts = deps.findRollouts ?? ((ids) => findRolloutsByIds(ids, deps.codexHome));
|
|
23204
23197
|
const readAppended = deps.readAppended ?? defaultReadAppended;
|
|
@@ -23390,7 +23383,7 @@ function agentLabel(path3) {
|
|
|
23390
23383
|
function defaultReadAppended(path3, offset) {
|
|
23391
23384
|
let size;
|
|
23392
23385
|
try {
|
|
23393
|
-
size =
|
|
23386
|
+
size = statSync6(path3).size;
|
|
23394
23387
|
} catch {
|
|
23395
23388
|
return void 0;
|
|
23396
23389
|
}
|
|
@@ -23532,15 +23525,15 @@ var init_completion_relay = __esm({
|
|
|
23532
23525
|
|
|
23533
23526
|
// packages/server/src/tail-cache.ts
|
|
23534
23527
|
import { createHash as createHash6 } from "node:crypto";
|
|
23535
|
-
import { closeSync as closeSync8, openSync as openSync9, readFileSync as readFileSync11, readSync as readSync3, statSync as
|
|
23536
|
-
import { join as
|
|
23528
|
+
import { closeSync as closeSync8, openSync as openSync9, readFileSync as readFileSync11, readSync as readSync3, statSync as statSync7 } from "node:fs";
|
|
23529
|
+
import { join as join17 } from "node:path";
|
|
23537
23530
|
function foldSchemaDigest(dir = import.meta.dirname) {
|
|
23538
23531
|
if (foldSchemaMemo) return foldSchemaMemo;
|
|
23539
23532
|
const hash = createHash6("sha256").update("frizz-tail-state-v1\0");
|
|
23540
23533
|
let read = 0;
|
|
23541
23534
|
for (const name of FOLD_SOURCES) {
|
|
23542
23535
|
try {
|
|
23543
|
-
hash.update(name).update("\0").update(readFileSync11(
|
|
23536
|
+
hash.update(name).update("\0").update(readFileSync11(join17(dir, name)));
|
|
23544
23537
|
read++;
|
|
23545
23538
|
} catch {
|
|
23546
23539
|
hash.update(name).update("\0missing\0");
|
|
@@ -23570,7 +23563,7 @@ function measureFence(path3, offset) {
|
|
|
23570
23563
|
if (!Number.isSafeInteger(offset) || offset <= 0) return null;
|
|
23571
23564
|
let fd2;
|
|
23572
23565
|
try {
|
|
23573
|
-
const stat2 =
|
|
23566
|
+
const stat2 = statSync7(path3);
|
|
23574
23567
|
if (stat2.size < offset) return null;
|
|
23575
23568
|
fd2 = openSync9(path3, "r");
|
|
23576
23569
|
const window = Math.min(SAMPLE_BYTES, offset);
|
|
@@ -23743,10 +23736,10 @@ var init_tail_cache = __esm({
|
|
|
23743
23736
|
});
|
|
23744
23737
|
|
|
23745
23738
|
// packages/server/src/tailer.ts
|
|
23746
|
-
import { statSync as
|
|
23739
|
+
import { statSync as statSync8, openSync as openSync10, readSync as readSync4, closeSync as closeSync9, readdirSync as readdirSync5, realpathSync as realpathSync5, mkdirSync as mkdirSync10, writeFileSync as writeFileSync8, readFileSync as readFileSync12, existsSync as existsSync5 } from "node:fs";
|
|
23747
23740
|
import { execFile as execFile2 } from "node:child_process";
|
|
23748
23741
|
import { promisify as promisify2 } from "node:util";
|
|
23749
|
-
import { basename as basename4, join as
|
|
23742
|
+
import { basename as basename4, join as join18, win32 } from "node:path";
|
|
23750
23743
|
import { homedir as homedir7 } from "node:os";
|
|
23751
23744
|
async function probeShellsAlive(outputFiles, opts = {}) {
|
|
23752
23745
|
const platform3 = opts.platform ?? process.platform;
|
|
@@ -24067,7 +24060,7 @@ function launchTaskId(text2) {
|
|
|
24067
24060
|
function readDescendantSidecars(sessionDir, mtimeMs) {
|
|
24068
24061
|
let names;
|
|
24069
24062
|
try {
|
|
24070
|
-
names = readdirSync5(
|
|
24063
|
+
names = readdirSync5(join18(sessionDir, "subagents"));
|
|
24071
24064
|
} catch {
|
|
24072
24065
|
return [];
|
|
24073
24066
|
}
|
|
@@ -24078,7 +24071,7 @@ function readDescendantSidecars(sessionDir, mtimeMs) {
|
|
|
24078
24071
|
if (!agentId) continue;
|
|
24079
24072
|
let parsed;
|
|
24080
24073
|
try {
|
|
24081
|
-
parsed = JSON.parse(readFileSync12(
|
|
24074
|
+
parsed = JSON.parse(readFileSync12(join18(sessionDir, "subagents", name), "utf8"));
|
|
24082
24075
|
} catch {
|
|
24083
24076
|
continue;
|
|
24084
24077
|
}
|
|
@@ -24092,7 +24085,7 @@ function readDescendantSidecars(sessionDir, mtimeMs) {
|
|
|
24092
24085
|
agentType: text2(meta.agentType),
|
|
24093
24086
|
parentAgentId: text2(meta.parentAgentId),
|
|
24094
24087
|
spawnDepth: typeof meta.spawnDepth === "number" && Number.isFinite(meta.spawnDepth) ? meta.spawnDepth : void 0,
|
|
24095
|
-
spawnedAtMs: mtimeMs(
|
|
24088
|
+
spawnedAtMs: mtimeMs(join18(sessionDir, "subagents", name))
|
|
24096
24089
|
});
|
|
24097
24090
|
}
|
|
24098
24091
|
return out;
|
|
@@ -24561,13 +24554,13 @@ function isPermMarker(v) {
|
|
|
24561
24554
|
}
|
|
24562
24555
|
function defaultMtimeMs(path3) {
|
|
24563
24556
|
try {
|
|
24564
|
-
return
|
|
24557
|
+
return statSync8(path3).mtimeMs;
|
|
24565
24558
|
} catch {
|
|
24566
24559
|
return void 0;
|
|
24567
24560
|
}
|
|
24568
24561
|
}
|
|
24569
24562
|
function defaultLogDir(project) {
|
|
24570
|
-
return
|
|
24563
|
+
return join18(homedir7(), ".claude", "projects", project.cwdSlug);
|
|
24571
24564
|
}
|
|
24572
24565
|
function defaultReadPermMarker(project) {
|
|
24573
24566
|
if (!project.stateDir) return () => void 0;
|
|
@@ -24699,7 +24692,7 @@ function createTailer(deps) {
|
|
|
24699
24692
|
return paneDead(row.slug);
|
|
24700
24693
|
}
|
|
24701
24694
|
const defaultBackend = {
|
|
24702
|
-
transcriptPath: (sessionId) =>
|
|
24695
|
+
transcriptPath: (sessionId) => join18(logDir, `${sessionId}.jsonl`),
|
|
24703
24696
|
foldLine: (state, line) => {
|
|
24704
24697
|
const rec = parseLine(line);
|
|
24705
24698
|
if (rec) applyRecord(state, rec);
|
|
@@ -24839,7 +24832,7 @@ ${ask}`;
|
|
|
24839
24832
|
return state.path.replace(/\.jsonl$/, "");
|
|
24840
24833
|
}
|
|
24841
24834
|
function descendantSidecars(state) {
|
|
24842
|
-
const at2 = mtimeMs(
|
|
24835
|
+
const at2 = mtimeMs(join18(sessionDirOf(state), "subagents"));
|
|
24843
24836
|
const cached2 = descendantIndex.get(state.slug);
|
|
24844
24837
|
if (cached2 && cached2.at === at2) return cached2.all;
|
|
24845
24838
|
const all = readDescendantSidecars(sessionDirOf(state), mtimeMs);
|
|
@@ -24853,7 +24846,7 @@ ${ask}`;
|
|
|
24853
24846
|
return descendantIndex.get(state.slug)?.byToolUse.get(id2);
|
|
24854
24847
|
}
|
|
24855
24848
|
function descendantTranscript(state, meta) {
|
|
24856
|
-
return
|
|
24849
|
+
return join18(sessionDirOf(state), "subagents", `agent-${meta.agentId}.jsonl`);
|
|
24857
24850
|
}
|
|
24858
24851
|
function subAgentDescendantTasks(slug, id2) {
|
|
24859
24852
|
const state = states.get(slug);
|
|
@@ -25199,10 +25192,10 @@ ${ask}`;
|
|
|
25199
25192
|
if (name.startsWith(".") || !name.endsWith(".jsonl")) continue;
|
|
25200
25193
|
const id2 = name.slice(0, -".jsonl".length);
|
|
25201
25194
|
if (!id2 || registered.has(id2)) continue;
|
|
25202
|
-
const path3 =
|
|
25195
|
+
const path3 = join18(logDir, name);
|
|
25203
25196
|
let mtime;
|
|
25204
25197
|
try {
|
|
25205
|
-
mtime =
|
|
25198
|
+
mtime = statSync8(path3).mtimeMs;
|
|
25206
25199
|
} catch {
|
|
25207
25200
|
continue;
|
|
25208
25201
|
}
|
|
@@ -25355,7 +25348,7 @@ ${ask}`;
|
|
|
25355
25348
|
if (entry.path !== state.path) {
|
|
25356
25349
|
let derivedSize = 0;
|
|
25357
25350
|
try {
|
|
25358
|
-
derivedSize =
|
|
25351
|
+
derivedSize = statSync8(state.path).size;
|
|
25359
25352
|
} catch {
|
|
25360
25353
|
derivedSize = 0;
|
|
25361
25354
|
}
|
|
@@ -25412,7 +25405,7 @@ ${ask}`;
|
|
|
25412
25405
|
function consume(state, backend, onLine) {
|
|
25413
25406
|
let size;
|
|
25414
25407
|
try {
|
|
25415
|
-
size =
|
|
25408
|
+
size = statSync8(state.path).size;
|
|
25416
25409
|
} catch {
|
|
25417
25410
|
return;
|
|
25418
25411
|
}
|
|
@@ -25471,7 +25464,7 @@ ${ask}`;
|
|
|
25471
25464
|
);
|
|
25472
25465
|
try {
|
|
25473
25466
|
mkdirSync10(stallLogDir, { recursive: true });
|
|
25474
|
-
writeFileSync8(
|
|
25467
|
+
writeFileSync8(join18(stallLogDir, `${row.slug}.stall.log`), `session_id: ${row.session_id}
|
|
25475
25468
|
captured_at: ${new Date(now()).toISOString()}
|
|
25476
25469
|
|
|
25477
25470
|
${detail2}
|
|
@@ -25481,10 +25474,10 @@ ${detail2}
|
|
|
25481
25474
|
}
|
|
25482
25475
|
function relocatedTranscript(state) {
|
|
25483
25476
|
const name = `${state.nativeSessionId}.jsonl`;
|
|
25484
|
-
const home =
|
|
25477
|
+
const home = join18(logDir, name);
|
|
25485
25478
|
const homeAt = home === state.path ? void 0 : mtimeOfNonEmpty(home);
|
|
25486
25479
|
const dir = discoverTranscriptDir(logDir, state.nativeSessionId);
|
|
25487
|
-
const sibling = dir ?
|
|
25480
|
+
const sibling = dir ? join18(dir, name) : void 0;
|
|
25488
25481
|
const siblingAt = sibling && sibling !== state.path ? mtimeOfNonEmpty(sibling) : void 0;
|
|
25489
25482
|
if (homeAt === void 0) return siblingAt === void 0 ? void 0 : sibling;
|
|
25490
25483
|
if (siblingAt === void 0) return home;
|
|
@@ -25519,7 +25512,7 @@ ${detail2}
|
|
|
25519
25512
|
}
|
|
25520
25513
|
let size = 0;
|
|
25521
25514
|
try {
|
|
25522
|
-
size =
|
|
25515
|
+
size = statSync8(state.path).size;
|
|
25523
25516
|
} catch {
|
|
25524
25517
|
size = 0;
|
|
25525
25518
|
}
|
|
@@ -25536,7 +25529,7 @@ ${detail2}
|
|
|
25536
25529
|
state.nextDiscoverMs = nowMs + DISCOVER_RETRY_MS;
|
|
25537
25530
|
const strandedDir = discoverTranscriptDir(logDir, row.session_id);
|
|
25538
25531
|
if (strandedDir) {
|
|
25539
|
-
state.path =
|
|
25532
|
+
state.path = join18(strandedDir, `${row.session_id}.jsonl`);
|
|
25540
25533
|
state.offset = 0;
|
|
25541
25534
|
state.partial = "";
|
|
25542
25535
|
state.primed = false;
|
|
@@ -25560,7 +25553,7 @@ ${detail2}
|
|
|
25560
25553
|
committed = false;
|
|
25561
25554
|
}
|
|
25562
25555
|
if (!committed) return false;
|
|
25563
|
-
state.path =
|
|
25556
|
+
state.path = join18(logDir, `${found}.jsonl`);
|
|
25564
25557
|
state.offset = 0;
|
|
25565
25558
|
state.partial = "";
|
|
25566
25559
|
state.primed = false;
|
|
@@ -25620,7 +25613,7 @@ ${detail2}
|
|
|
25620
25613
|
continue;
|
|
25621
25614
|
}
|
|
25622
25615
|
if (!state) {
|
|
25623
|
-
const path3 = backend.transcriptPath(nativeId) ??
|
|
25616
|
+
const path3 = backend.transcriptPath(nativeId) ?? join18(logDir, `${nativeId}.jsonl`);
|
|
25624
25617
|
state = newTailState(row.slug, row.session_id, path3, false, nativeId, runtimeGeneration);
|
|
25625
25618
|
state.dismissedOps = deps.storage.retiredOps(row.slug, row.session_id);
|
|
25626
25619
|
hydrateFromCache(state, row, nativeId);
|
|
@@ -26078,14 +26071,14 @@ var init_tailer = __esm({
|
|
|
26078
26071
|
});
|
|
26079
26072
|
|
|
26080
26073
|
// packages/server/src/backend/codex.ts
|
|
26081
|
-
import { join as
|
|
26074
|
+
import { join as join19 } from "node:path";
|
|
26082
26075
|
import { homedir as homedir8 } from "node:os";
|
|
26083
|
-
import { readdirSync as readdirSync6, statSync as
|
|
26076
|
+
import { readdirSync as readdirSync6, statSync as statSync9, readFileSync as readFileSync13, openSync as openSync11, readSync as readSync5, closeSync as closeSync10 } from "node:fs";
|
|
26084
26077
|
function defaultCodexHome() {
|
|
26085
|
-
return process.env.CODEX_HOME && process.env.CODEX_HOME.trim() ? process.env.CODEX_HOME :
|
|
26078
|
+
return process.env.CODEX_HOME && process.env.CODEX_HOME.trim() ? process.env.CODEX_HOME : join19(homedir8(), ".codex");
|
|
26086
26079
|
}
|
|
26087
26080
|
function sessionsDir(codexHome) {
|
|
26088
|
-
return
|
|
26081
|
+
return join19(codexHome, "sessions");
|
|
26089
26082
|
}
|
|
26090
26083
|
function codexSandbox(mode) {
|
|
26091
26084
|
switch (mode) {
|
|
@@ -26531,17 +26524,17 @@ function collectRollouts(dir, out, budget) {
|
|
|
26531
26524
|
const files = entries2.filter((e) => e.isFile() && e.name.startsWith("rollout-") && e.name.endsWith(".jsonl")).sort(descByName);
|
|
26532
26525
|
for (const d of dirs) {
|
|
26533
26526
|
if (budget.n <= 0) return;
|
|
26534
|
-
collectRollouts(
|
|
26527
|
+
collectRollouts(join19(dir, d.name), out, budget);
|
|
26535
26528
|
}
|
|
26536
26529
|
for (const f of files) {
|
|
26537
26530
|
if (budget.n <= 0) return;
|
|
26538
26531
|
let mtimeMs;
|
|
26539
26532
|
try {
|
|
26540
|
-
mtimeMs =
|
|
26533
|
+
mtimeMs = statSync9(join19(dir, f.name)).mtimeMs;
|
|
26541
26534
|
} catch {
|
|
26542
26535
|
continue;
|
|
26543
26536
|
}
|
|
26544
|
-
out.push({ path:
|
|
26537
|
+
out.push({ path: join19(dir, f.name), mtimeMs });
|
|
26545
26538
|
budget.n--;
|
|
26546
26539
|
}
|
|
26547
26540
|
}
|
|
@@ -26585,8 +26578,8 @@ function readCodexThreadNames(codexHome = defaultCodexHome()) {
|
|
|
26585
26578
|
const out = /* @__PURE__ */ new Map();
|
|
26586
26579
|
let raw2;
|
|
26587
26580
|
try {
|
|
26588
|
-
const path3 =
|
|
26589
|
-
if (
|
|
26581
|
+
const path3 = join19(codexHome, "session_index.jsonl");
|
|
26582
|
+
if (statSync9(path3).size > SESSION_INDEX_MAX_BYTES) return out;
|
|
26590
26583
|
raw2 = readFileSync13(path3, "utf8");
|
|
26591
26584
|
} catch {
|
|
26592
26585
|
return out;
|
|
@@ -26789,19 +26782,19 @@ function searchPath2(env) {
|
|
|
26789
26782
|
function vendoredNativeBeside(launcherJs, arch, access) {
|
|
26790
26783
|
const triple = WINDOWS_TRIPLE[arch];
|
|
26791
26784
|
if (!triple) return void 0;
|
|
26792
|
-
const { dirname:
|
|
26793
|
-
const pkgRoot =
|
|
26785
|
+
const { dirname: dirname27, join: join50 } = win322;
|
|
26786
|
+
const pkgRoot = dirname27(dirname27(launcherJs));
|
|
26794
26787
|
const platformPkg = `codex-win32-${arch}`;
|
|
26795
26788
|
const vendorRoots = [
|
|
26796
|
-
|
|
26789
|
+
join50(pkgRoot, "node_modules", "@openai", platformPkg, "vendor"),
|
|
26797
26790
|
// nested under the package
|
|
26798
|
-
|
|
26791
|
+
join50(dirname27(pkgRoot), platformPkg, "vendor"),
|
|
26799
26792
|
// hoisted beside it: <prefix>\node_modules\@openai\<pkg>
|
|
26800
|
-
|
|
26793
|
+
join50(pkgRoot, "vendor")
|
|
26801
26794
|
// the pre-platform-package layout, binaries inside @openai/codex itself
|
|
26802
26795
|
];
|
|
26803
26796
|
for (const root of vendorRoots) {
|
|
26804
|
-
const exe =
|
|
26797
|
+
const exe = join50(root, triple, "bin", "codex.exe");
|
|
26805
26798
|
if (access(exe, "exists")) return exe;
|
|
26806
26799
|
}
|
|
26807
26800
|
return void 0;
|
|
@@ -29125,7 +29118,7 @@ var require_websocket = __commonJS({
|
|
|
29125
29118
|
var http = __require("http");
|
|
29126
29119
|
var net2 = __require("net");
|
|
29127
29120
|
var tls = __require("tls");
|
|
29128
|
-
var { randomBytes
|
|
29121
|
+
var { randomBytes, createHash: createHash17 } = __require("crypto");
|
|
29129
29122
|
var { Duplex, Readable: Readable2 } = __require("stream");
|
|
29130
29123
|
var { URL: URL2 } = __require("url");
|
|
29131
29124
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -29663,7 +29656,7 @@ var require_websocket = __commonJS({
|
|
|
29663
29656
|
}
|
|
29664
29657
|
}
|
|
29665
29658
|
const defaultPort = isSecure ? 443 : 80;
|
|
29666
|
-
const key =
|
|
29659
|
+
const key = randomBytes(16).toString("base64");
|
|
29667
29660
|
const request = isSecure ? https.request : http.request;
|
|
29668
29661
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
29669
29662
|
let perMessageDeflate;
|
|
@@ -30702,14 +30695,14 @@ import { connect } from "node:net";
|
|
|
30702
30695
|
import { Agent as HttpAgent } from "node:http";
|
|
30703
30696
|
import { createHash as createHash7, randomUUID as randomUUID9 } from "node:crypto";
|
|
30704
30697
|
import { existsSync as existsSync6, mkdirSync as mkdirSync11, readFileSync as readFileSync15, unlinkSync as unlinkSync2, writeFileSync as writeFileSync9 } from "node:fs";
|
|
30705
|
-
import { join as
|
|
30698
|
+
import { join as join20 } from "node:path";
|
|
30706
30699
|
import { PassThrough, Writable } from "node:stream";
|
|
30707
30700
|
import { StringDecoder } from "node:string_decoder";
|
|
30708
30701
|
function nativeDir(stateDir) {
|
|
30709
|
-
return
|
|
30702
|
+
return join20(stateDir, "codex-app-server-native");
|
|
30710
30703
|
}
|
|
30711
30704
|
function nativeRecordPath(stateDir, projectId) {
|
|
30712
|
-
return
|
|
30705
|
+
return join20(nativeDir(stateDir), `${projectId}.json`);
|
|
30713
30706
|
}
|
|
30714
30707
|
function nativeListenSocketPath(stateDir, projectId) {
|
|
30715
30708
|
const key = createHash7("sha256").update(stateDir).update("\0").update(projectId).digest("hex").slice(0, 16);
|
|
@@ -30982,14 +30975,14 @@ import { spawn as spawn3 } from "node:child_process";
|
|
|
30982
30975
|
import { createConnection } from "node:net";
|
|
30983
30976
|
import { createHash as createHash8, randomUUID as randomUUID10 } from "node:crypto";
|
|
30984
30977
|
import { existsSync as existsSync7, mkdirSync as mkdirSync12, readFileSync as readFileSync16, unlinkSync as unlinkSync3 } from "node:fs";
|
|
30985
|
-
import { join as
|
|
30978
|
+
import { join as join21 } from "node:path";
|
|
30986
30979
|
import { PassThrough as PassThrough2, Writable as Writable2 } from "node:stream";
|
|
30987
30980
|
import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
30988
30981
|
function daemonDir(stateDir) {
|
|
30989
|
-
return
|
|
30982
|
+
return join21(stateDir, "codex-app-server");
|
|
30990
30983
|
}
|
|
30991
30984
|
function recordPath(stateDir, projectId) {
|
|
30992
|
-
return
|
|
30985
|
+
return join21(daemonDir(stateDir), `${projectId}.json`);
|
|
30993
30986
|
}
|
|
30994
30987
|
function codexAppServerSocketPath(stateDir, projectId) {
|
|
30995
30988
|
const key = createHash8("sha256").update(stateDir).update("\0").update(projectId).digest("hex").slice(0, 16);
|
|
@@ -31287,7 +31280,7 @@ var init_codex_app_server_host = __esm({
|
|
|
31287
31280
|
});
|
|
31288
31281
|
|
|
31289
31282
|
// packages/server/src/backend/claude-quota.ts
|
|
31290
|
-
import { join as
|
|
31283
|
+
import { join as join22 } from "node:path";
|
|
31291
31284
|
import { homedir as homedir9, platform } from "node:os";
|
|
31292
31285
|
import { createHash as createHash9 } from "node:crypto";
|
|
31293
31286
|
import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
@@ -31295,7 +31288,7 @@ import { execFile as execFile3 } from "node:child_process";
|
|
|
31295
31288
|
import { promisify as promisify3 } from "node:util";
|
|
31296
31289
|
function claudeConfigDir() {
|
|
31297
31290
|
const override = process.env.CLAUDE_CONFIG_DIR;
|
|
31298
|
-
return override && override.trim() ? override :
|
|
31291
|
+
return override && override.trim() ? override : join22(homedir9(), ".claude");
|
|
31299
31292
|
}
|
|
31300
31293
|
function tokenFromCredentialsJson(raw2) {
|
|
31301
31294
|
let doc;
|
|
@@ -31324,7 +31317,7 @@ async function readKeychainToken() {
|
|
|
31324
31317
|
}
|
|
31325
31318
|
async function readAccessToken(configDir) {
|
|
31326
31319
|
try {
|
|
31327
|
-
const fromFile = tokenFromCredentialsJson(await readFile(
|
|
31320
|
+
const fromFile = tokenFromCredentialsJson(await readFile(join22(configDir, ".credentials.json"), "utf8"));
|
|
31328
31321
|
if (fromFile) return fromFile;
|
|
31329
31322
|
} catch {
|
|
31330
31323
|
}
|
|
@@ -31398,8 +31391,8 @@ function retryAtFrom(res, now) {
|
|
|
31398
31391
|
function cachePaths(cacheDir, configDir) {
|
|
31399
31392
|
const profile = createHash9("sha256").update(configDir).digest("hex").slice(0, 12);
|
|
31400
31393
|
return {
|
|
31401
|
-
data:
|
|
31402
|
-
lock:
|
|
31394
|
+
data: join22(cacheDir, `claude-${profile}.json`),
|
|
31395
|
+
lock: join22(cacheDir, `claude-${profile}.lock`)
|
|
31403
31396
|
};
|
|
31404
31397
|
}
|
|
31405
31398
|
async function readShared(path3) {
|
|
@@ -31611,7 +31604,7 @@ function refreshSharedInBackground(paths, claudeBin, deps, now) {
|
|
|
31611
31604
|
async function refreshClaudeQuotaInBackground(claudeBin = "claude", deps = {}) {
|
|
31612
31605
|
const now = (deps.now ?? Date.now)();
|
|
31613
31606
|
const configDir = claudeConfigDir();
|
|
31614
|
-
const cacheDir = deps.cacheDir ??
|
|
31607
|
+
const cacheDir = deps.cacheDir ?? join22(frizzRoots().cache, "quota-cache");
|
|
31615
31608
|
try {
|
|
31616
31609
|
await mkdir(cacheDir, { recursive: true, mode: 448 });
|
|
31617
31610
|
} catch {
|
|
@@ -31625,7 +31618,7 @@ async function refreshClaudeQuotaInBackground(claudeBin = "claude", deps = {}) {
|
|
|
31625
31618
|
async function readClaudeQuota(claudeBin = "claude", deps = {}, options = {}) {
|
|
31626
31619
|
const now = (deps.now ?? Date.now)();
|
|
31627
31620
|
const configDir = claudeConfigDir();
|
|
31628
|
-
const cacheDir = deps.cacheDir ??
|
|
31621
|
+
const cacheDir = deps.cacheDir ?? join22(frizzRoots().cache, "quota-cache");
|
|
31629
31622
|
const paths = cachePaths(cacheDir, configDir);
|
|
31630
31623
|
try {
|
|
31631
31624
|
await mkdir(cacheDir, { recursive: true, mode: 448 });
|
|
@@ -31732,19 +31725,19 @@ var init_claude_quota = __esm({
|
|
|
31732
31725
|
});
|
|
31733
31726
|
|
|
31734
31727
|
// packages/server/src/backend/auth-status.ts
|
|
31735
|
-
import { join as
|
|
31728
|
+
import { join as join23 } from "node:path";
|
|
31736
31729
|
import { homedir as homedir10, platform as platform2 } from "node:os";
|
|
31737
|
-
import { readFileSync as readFileSync17, statSync as
|
|
31730
|
+
import { readFileSync as readFileSync17, statSync as statSync10 } from "node:fs";
|
|
31738
31731
|
import { execFile as execFile4 } from "node:child_process";
|
|
31739
31732
|
import { promisify as promisify4 } from "node:util";
|
|
31740
31733
|
function claudeConfigDir2() {
|
|
31741
31734
|
const override = process.env.CLAUDE_CONFIG_DIR;
|
|
31742
|
-
return override && override.trim() ? override :
|
|
31735
|
+
return override && override.trim() ? override : join23(homedir10(), ".claude");
|
|
31743
31736
|
}
|
|
31744
31737
|
function claudeFileState(configDir) {
|
|
31745
31738
|
let raw2;
|
|
31746
31739
|
try {
|
|
31747
|
-
raw2 = readFileSync17(
|
|
31740
|
+
raw2 = readFileSync17(join23(configDir, ".credentials.json"), "utf8");
|
|
31748
31741
|
} catch (err) {
|
|
31749
31742
|
return err.code === "ENOENT" ? "absent" : "error";
|
|
31750
31743
|
}
|
|
@@ -31777,7 +31770,7 @@ function readCodexAuthState(codexHome = defaultCodexHome()) {
|
|
|
31777
31770
|
if (process.env.OPENAI_API_KEY || process.env.CODEX_API_KEY || process.env.CODEX_ACCESS_TOKEN) return "authed";
|
|
31778
31771
|
let raw2;
|
|
31779
31772
|
try {
|
|
31780
|
-
raw2 = readFileSync17(
|
|
31773
|
+
raw2 = readFileSync17(join23(codexHome, "auth.json"), "utf8");
|
|
31781
31774
|
} catch (err) {
|
|
31782
31775
|
return err.code === "ENOENT" ? "signed-out" : "unknown";
|
|
31783
31776
|
}
|
|
@@ -31797,7 +31790,7 @@ function readCodexAuthState(codexHome = defaultCodexHome()) {
|
|
|
31797
31790
|
function readCodexAccountId(codexHome = defaultCodexHome()) {
|
|
31798
31791
|
if (process.env.OPENAI_API_KEY || process.env.CODEX_API_KEY || process.env.CODEX_ACCESS_TOKEN) return void 0;
|
|
31799
31792
|
try {
|
|
31800
|
-
const doc = JSON.parse(readFileSync17(
|
|
31793
|
+
const doc = JSON.parse(readFileSync17(join23(codexHome, "auth.json"), "utf8"));
|
|
31801
31794
|
if (!doc || typeof doc !== "object") return void 0;
|
|
31802
31795
|
const tokens = doc.tokens;
|
|
31803
31796
|
if (!tokens || typeof tokens !== "object") return void 0;
|
|
@@ -31856,12 +31849,12 @@ function asEmail(value) {
|
|
|
31856
31849
|
}
|
|
31857
31850
|
function claudeAccountFile() {
|
|
31858
31851
|
const override = process.env.CLAUDE_CONFIG_DIR;
|
|
31859
|
-
return override && override.trim() ?
|
|
31852
|
+
return override && override.trim() ? join23(override, ".claude.json") : join23(homedir10(), ".claude.json");
|
|
31860
31853
|
}
|
|
31861
31854
|
function readClaudeAccountEmail(path3 = claudeAccountFile()) {
|
|
31862
31855
|
let stat2;
|
|
31863
31856
|
try {
|
|
31864
|
-
stat2 =
|
|
31857
|
+
stat2 = statSync10(path3);
|
|
31865
31858
|
} catch {
|
|
31866
31859
|
return void 0;
|
|
31867
31860
|
}
|
|
@@ -31880,7 +31873,7 @@ function readClaudeAccountEmail(path3 = claudeAccountFile()) {
|
|
|
31880
31873
|
function readCodexAccountEmail(codexHome = defaultCodexHome()) {
|
|
31881
31874
|
let doc;
|
|
31882
31875
|
try {
|
|
31883
|
-
doc = JSON.parse(readFileSync17(
|
|
31876
|
+
doc = JSON.parse(readFileSync17(join23(codexHome, "auth.json"), "utf8"));
|
|
31884
31877
|
} catch {
|
|
31885
31878
|
return void 0;
|
|
31886
31879
|
}
|
|
@@ -35169,11 +35162,11 @@ var init_codex_app_server = __esm({
|
|
|
35169
35162
|
});
|
|
35170
35163
|
|
|
35171
35164
|
// packages/server/src/backend/codex-quota.ts
|
|
35172
|
-
import { join as
|
|
35173
|
-
import { readdirSync as readdirSync7, statSync as
|
|
35165
|
+
import { join as join24 } from "node:path";
|
|
35166
|
+
import { readdirSync as readdirSync7, statSync as statSync11, openSync as openSync12, readSync as readSync6, fstatSync, closeSync as closeSync11 } from "node:fs";
|
|
35174
35167
|
import { spawn as spawn4 } from "node:child_process";
|
|
35175
35168
|
function sessionsDir2(codexHome) {
|
|
35176
|
-
return
|
|
35169
|
+
return join24(codexHome, "sessions");
|
|
35177
35170
|
}
|
|
35178
35171
|
function newestRollouts(dir, out, budget) {
|
|
35179
35172
|
if (budget.n <= 0) return;
|
|
@@ -35187,11 +35180,11 @@ function newestRollouts(dir, out, budget) {
|
|
|
35187
35180
|
const files = entries2.filter((e) => e.isFile() && e.name.startsWith("rollout-") && e.name.endsWith(".jsonl")).map((e) => e.name).sort(descByName2);
|
|
35188
35181
|
for (const d of dirs) {
|
|
35189
35182
|
if (budget.n <= 0) return;
|
|
35190
|
-
newestRollouts(
|
|
35183
|
+
newestRollouts(join24(dir, d), out, budget);
|
|
35191
35184
|
}
|
|
35192
35185
|
for (const f of files) {
|
|
35193
35186
|
if (budget.n <= 0) return;
|
|
35194
|
-
out.push(
|
|
35187
|
+
out.push(join24(dir, f));
|
|
35195
35188
|
budget.n--;
|
|
35196
35189
|
}
|
|
35197
35190
|
}
|
|
@@ -35263,7 +35256,7 @@ function readCodexQuotaFromRollouts(codexHome = defaultCodexHome()) {
|
|
|
35263
35256
|
newestRollouts(sessionsDir2(codexHome), rollouts, { n: 8 });
|
|
35264
35257
|
const byMtime = rollouts.map((path3) => {
|
|
35265
35258
|
try {
|
|
35266
|
-
return { path: path3, mtimeMs:
|
|
35259
|
+
return { path: path3, mtimeMs: statSync11(path3).mtimeMs };
|
|
35267
35260
|
} catch {
|
|
35268
35261
|
return void 0;
|
|
35269
35262
|
}
|
|
@@ -35474,9 +35467,9 @@ var init_local_path = __esm({
|
|
|
35474
35467
|
|
|
35475
35468
|
// packages/server/src/local-file.ts
|
|
35476
35469
|
import { spawn as spawn5 } from "node:child_process";
|
|
35477
|
-
import { existsSync as existsSync9, readFileSync as readFileSync18, realpathSync as realpathSync6, statSync as
|
|
35470
|
+
import { existsSync as existsSync9, readFileSync as readFileSync18, realpathSync as realpathSync6, statSync as statSync12 } from "node:fs";
|
|
35478
35471
|
import { homedir as homedir11 } from "node:os";
|
|
35479
|
-
import { dirname as
|
|
35472
|
+
import { dirname as dirname9, isAbsolute as isAbsolute4, join as join25, resolve as resolve5, sep as sep2 } from "node:path";
|
|
35480
35473
|
function isUnder(real, root) {
|
|
35481
35474
|
let rootReal;
|
|
35482
35475
|
try {
|
|
@@ -35488,12 +35481,12 @@ function isUnder(real, root) {
|
|
|
35488
35481
|
return real === rootReal || real.startsWith(rootReal.endsWith(sep2) ? rootReal : rootReal + sep2);
|
|
35489
35482
|
}
|
|
35490
35483
|
try {
|
|
35491
|
-
const trusted =
|
|
35484
|
+
const trusted = statSync12(rootReal, { bigint: true });
|
|
35492
35485
|
if (!trusted.isDirectory() || trusted.ino === 0n) return false;
|
|
35493
35486
|
for (let ancestor = real; ; ) {
|
|
35494
|
-
const actual =
|
|
35487
|
+
const actual = statSync12(ancestor, { bigint: true });
|
|
35495
35488
|
if (actual.dev === trusted.dev && actual.ino === trusted.ino) return true;
|
|
35496
|
-
const parent =
|
|
35489
|
+
const parent = dirname9(ancestor);
|
|
35497
35490
|
if (parent === ancestor) return false;
|
|
35498
35491
|
ancestor = parent;
|
|
35499
35492
|
}
|
|
@@ -35512,7 +35505,7 @@ function resolveLocalFile(rawPath, roots) {
|
|
|
35512
35505
|
}
|
|
35513
35506
|
if (!roots.some((root) => isUnder(real, root))) throw new Error("Local file is outside Frizz's trusted roots");
|
|
35514
35507
|
try {
|
|
35515
|
-
if (!
|
|
35508
|
+
if (!statSync12(real).isFile()) throw new Error("Local path is not a regular file");
|
|
35516
35509
|
} catch (error) {
|
|
35517
35510
|
if (error instanceof Error && error.message === "Local path is not a regular file") throw error;
|
|
35518
35511
|
throw new Error("Local file was not found");
|
|
@@ -35522,7 +35515,7 @@ function resolveLocalFile(rawPath, roots) {
|
|
|
35522
35515
|
function resolveOpenableFile(raw2, projectDir, roots, home = homedir11()) {
|
|
35523
35516
|
const trimmed = raw2.trim().replace(/:\d+(?::\d+)?$/, "");
|
|
35524
35517
|
if (!trimmed) return null;
|
|
35525
|
-
const abs = trimmed === "~" ? home : /^~[\/\\]/.test(trimmed) ?
|
|
35518
|
+
const abs = trimmed === "~" ? home : /^~[\/\\]/.test(trimmed) ? join25(home, trimmed.slice(2)) : isAbsolute4(trimmed) ? trimmed : resolve5(projectDir, trimmed);
|
|
35526
35519
|
try {
|
|
35527
35520
|
return resolveLocalFile(abs, roots);
|
|
35528
35521
|
} catch {
|
|
@@ -35580,7 +35573,7 @@ function localFileOpenCommand(path3, selected, options = {}) {
|
|
|
35580
35573
|
const exists = options.exists ?? existsSync9;
|
|
35581
35574
|
const localAppData = env.LOCALAPPDATA;
|
|
35582
35575
|
if (localAppData) {
|
|
35583
|
-
const exe =
|
|
35576
|
+
const exe = join25(localAppData, ...editor.exe);
|
|
35584
35577
|
if (exists(exe)) return { command: exe, args: [path3] };
|
|
35585
35578
|
}
|
|
35586
35579
|
if (/["%\r\n]/u.test(path3)) throw new Error(`cannot hand ${path3} to the ${editor.shim} shim through cmd.exe`);
|
|
@@ -35846,7 +35839,7 @@ var init_claude_model_upgrade = __esm({
|
|
|
35846
35839
|
// packages/server/src/frizz.ts
|
|
35847
35840
|
import { execFile as execFile6 } from "node:child_process";
|
|
35848
35841
|
import { lstatSync as lstatSync2, realpathSync as realpathSync7 } from "node:fs";
|
|
35849
|
-
import { basename as basename5, dirname as
|
|
35842
|
+
import { basename as basename5, dirname as dirname10, join as join26, resolve as resolve6 } from "node:path";
|
|
35850
35843
|
import { promisify as promisify5 } from "node:util";
|
|
35851
35844
|
function frizzScriptsDir() {
|
|
35852
35845
|
if (process.env.FRIZZ_SCRIPTS_DIR) return process.env.FRIZZ_SCRIPTS_DIR;
|
|
@@ -35855,11 +35848,11 @@ function frizzScriptsDir() {
|
|
|
35855
35848
|
function directFrizzRoot(projectDir) {
|
|
35856
35849
|
try {
|
|
35857
35850
|
const projectRoot = realpathSync7(projectDir);
|
|
35858
|
-
const path3 =
|
|
35851
|
+
const path3 = join26(projectRoot, ".frizz");
|
|
35859
35852
|
const stat2 = lstatSync2(path3);
|
|
35860
35853
|
if (!stat2.isDirectory() || stat2.isSymbolicLink()) return null;
|
|
35861
35854
|
const real = realpathSync7(path3);
|
|
35862
|
-
return
|
|
35855
|
+
return dirname10(real) === projectRoot && basename5(real) === ".frizz" ? real : null;
|
|
35863
35856
|
} catch {
|
|
35864
35857
|
return null;
|
|
35865
35858
|
}
|
|
@@ -35869,7 +35862,7 @@ function frizzDirExists(projectDir) {
|
|
|
35869
35862
|
}
|
|
35870
35863
|
async function readBoard(projectDir, scriptsDir = frizzScriptsDir()) {
|
|
35871
35864
|
if (!directFrizzRoot(projectDir)) throw new Error("unsafe or missing .frizz directory");
|
|
35872
|
-
const { stdout } = await execFileP("node", [
|
|
35865
|
+
const { stdout } = await execFileP("node", [join26(scriptsDir, "index.mjs"), "--json"], {
|
|
35873
35866
|
cwd: projectDir,
|
|
35874
35867
|
env: { ...process.env, CLAUDE_PROJECT_DIR: projectDir },
|
|
35875
35868
|
maxBuffer: 32 * 1024 * 1024
|
|
@@ -35894,7 +35887,7 @@ async function readBoard(projectDir, scriptsDir = frizzScriptsDir()) {
|
|
|
35894
35887
|
};
|
|
35895
35888
|
}
|
|
35896
35889
|
async function runThreadUpdate(projectDir, slug, args, scriptsDir = frizzScriptsDir()) {
|
|
35897
|
-
await execFileP("node", [
|
|
35890
|
+
await execFileP("node", [join26(scriptsDir, "thread-update.mjs"), slug, ...args], {
|
|
35898
35891
|
cwd: projectDir,
|
|
35899
35892
|
env: { ...process.env, CLAUDE_PROJECT_DIR: projectDir }
|
|
35900
35893
|
});
|
|
@@ -36006,7 +35999,7 @@ var init_awaiting = __esm({
|
|
|
36006
35999
|
// packages/server/src/backend/project-mcp-servers.ts
|
|
36007
36000
|
import { readFileSync as readFileSync19 } from "node:fs";
|
|
36008
36001
|
import { homedir as homedir12 } from "node:os";
|
|
36009
|
-
import { join as
|
|
36002
|
+
import { join as join27 } from "node:path";
|
|
36010
36003
|
function readJsonObject(path3) {
|
|
36011
36004
|
try {
|
|
36012
36005
|
const parsed = JSON.parse(readFileSync19(path3, "utf8"));
|
|
@@ -36102,15 +36095,15 @@ function projectMcpServers(cwd, options = {}) {
|
|
|
36102
36095
|
const env = options.env ?? process.env;
|
|
36103
36096
|
const home = options.home ?? homedir12();
|
|
36104
36097
|
const configOverride = options.claudeConfigDir ?? (env.CLAUDE_CONFIG_DIR?.trim() ? env.CLAUDE_CONFIG_DIR.trim() : void 0);
|
|
36105
|
-
const accountFile = configOverride ?
|
|
36106
|
-
const userSettingsFile =
|
|
36098
|
+
const accountFile = configOverride ? join27(configOverride, ".claude.json") : join27(home, ".claude.json");
|
|
36099
|
+
const userSettingsFile = join27(configOverride ?? join27(home, ".claude"), "settings.json");
|
|
36107
36100
|
const account = readJsonObject(accountFile);
|
|
36108
36101
|
const out = userScopeRemoteServers(account, cwd, env);
|
|
36109
|
-
const declared = objectField(readJsonObject(
|
|
36102
|
+
const declared = objectField(readJsonObject(join27(cwd, ".mcp.json")), "mcpServers");
|
|
36110
36103
|
if (!declared) return out;
|
|
36111
36104
|
const approval = collectApproval([
|
|
36112
|
-
readJsonObject(
|
|
36113
|
-
readJsonObject(
|
|
36105
|
+
readJsonObject(join27(cwd, ".claude", "settings.json")),
|
|
36106
|
+
readJsonObject(join27(cwd, ".claude", "settings.local.json")),
|
|
36114
36107
|
readJsonObject(userSettingsFile),
|
|
36115
36108
|
objectField(objectField(account, "projects"), cwd)
|
|
36116
36109
|
]);
|
|
@@ -36135,17 +36128,17 @@ var init_project_mcp_servers = __esm({
|
|
|
36135
36128
|
|
|
36136
36129
|
// packages/server/src/worker-plugin-dir.ts
|
|
36137
36130
|
import { existsSync as existsSync10 } from "node:fs";
|
|
36138
|
-
import { dirname as
|
|
36131
|
+
import { dirname as dirname11, join as join28 } from "node:path";
|
|
36139
36132
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
36140
36133
|
function resolveWorkerPluginDir(moduleUrl = import.meta.url, env = process.env) {
|
|
36141
36134
|
const override = env.FRIZZ_WORKER_PLUGIN_DIR;
|
|
36142
|
-
if (override && existsSync10(
|
|
36135
|
+
if (override && existsSync10(join28(override, ".claude-plugin", "plugin.json")))
|
|
36143
36136
|
return override;
|
|
36144
|
-
let current =
|
|
36137
|
+
let current = dirname11(fileURLToPath3(moduleUrl));
|
|
36145
36138
|
for (; ; ) {
|
|
36146
|
-
const candidate =
|
|
36147
|
-
if (existsSync10(
|
|
36148
|
-
const parent =
|
|
36139
|
+
const candidate = join28(current, "cc-worker");
|
|
36140
|
+
if (existsSync10(join28(candidate, ".claude-plugin", "plugin.json"))) return candidate;
|
|
36141
|
+
const parent = dirname11(current);
|
|
36149
36142
|
if (parent === current) return void 0;
|
|
36150
36143
|
current = parent;
|
|
36151
36144
|
}
|
|
@@ -37153,11 +37146,11 @@ checks. Depth scales with blast radius and yields to the project's conventions.`
|
|
|
37153
37146
|
});
|
|
37154
37147
|
|
|
37155
37148
|
// packages/server/src/backend/acp-agents.ts
|
|
37156
|
-
import { accessSync as accessSync3, constants, statSync as
|
|
37157
|
-
import { delimiter as delimiter2, isAbsolute as isAbsolute6, join as
|
|
37149
|
+
import { accessSync as accessSync3, constants, statSync as statSync13 } from "node:fs";
|
|
37150
|
+
import { delimiter as delimiter2, isAbsolute as isAbsolute6, join as join29 } from "node:path";
|
|
37158
37151
|
function isExecutableFile(path3) {
|
|
37159
37152
|
try {
|
|
37160
|
-
if (!
|
|
37153
|
+
if (!statSync13(path3).isFile()) return false;
|
|
37161
37154
|
if (process.platform !== "win32") accessSync3(path3, constants.X_OK);
|
|
37162
37155
|
return true;
|
|
37163
37156
|
} catch {
|
|
@@ -37170,9 +37163,9 @@ function findOnPath(command, env = process.env) {
|
|
|
37170
37163
|
const exts = process.platform === "win32" ? ["", ...(env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";")] : [""];
|
|
37171
37164
|
for (const dir of dirs) {
|
|
37172
37165
|
for (const ext of exts) {
|
|
37173
|
-
const candidate =
|
|
37166
|
+
const candidate = join29(dir, command + ext.toLowerCase());
|
|
37174
37167
|
if (isExecutableFile(candidate)) return candidate;
|
|
37175
|
-
if (ext && isExecutableFile(
|
|
37168
|
+
if (ext && isExecutableFile(join29(dir, command + ext))) return join29(dir, command + ext);
|
|
37176
37169
|
}
|
|
37177
37170
|
}
|
|
37178
37171
|
return void 0;
|
|
@@ -38120,8 +38113,8 @@ var init_claude_agent_broker_bridge = __esm({
|
|
|
38120
38113
|
});
|
|
38121
38114
|
|
|
38122
38115
|
// packages/server/src/dispatch.ts
|
|
38123
|
-
import { closeSync as closeSync12, constants as constants2, existsSync as existsSync11, fstatSync as fstatSync2, lstatSync as lstatSync3, openSync as openSync13, readFileSync as readFileSync20, realpathSync as realpathSync8, statSync as
|
|
38124
|
-
import { basename as basename6, join as
|
|
38116
|
+
import { closeSync as closeSync12, constants as constants2, existsSync as existsSync11, fstatSync as fstatSync2, lstatSync as lstatSync3, openSync as openSync13, readFileSync as readFileSync20, realpathSync as realpathSync8, statSync as statSync14, writeFileSync as writeFileSync10, mkdirSync as mkdirSync13, rmSync as rmSync9 } from "node:fs";
|
|
38117
|
+
import { basename as basename6, join as join30, dirname as dirname12 } from "node:path";
|
|
38125
38118
|
import { createHash as createHash11, randomUUID as randomUUID13 } from "node:crypto";
|
|
38126
38119
|
function fallbackTitle(prompt) {
|
|
38127
38120
|
const firstLine2 = prompt.trim().split("\n", 1)[0].trim();
|
|
@@ -38140,7 +38133,7 @@ function fallbackTitle(prompt) {
|
|
|
38140
38133
|
}
|
|
38141
38134
|
function resolveSlug(frizzDir, base, taken) {
|
|
38142
38135
|
base = ThreadSlug.parse(base);
|
|
38143
|
-
const isTaken = (slug) => existsSync11(
|
|
38136
|
+
const isTaken = (slug) => existsSync11(join30(frizzDir, `${slug}.md`)) || (taken?.(slug) ?? false);
|
|
38144
38137
|
if (!isTaken(base)) return base;
|
|
38145
38138
|
for (let n = 2; ; n++) {
|
|
38146
38139
|
const suffix = `-${n}`;
|
|
@@ -38157,16 +38150,16 @@ function resolveLegacyThreadFile(projectDir, value) {
|
|
|
38157
38150
|
if (!parsed.success) return null;
|
|
38158
38151
|
try {
|
|
38159
38152
|
const projectRoot = realpathSync8(projectDir);
|
|
38160
|
-
const frizzPath =
|
|
38153
|
+
const frizzPath = join30(projectRoot, ".frizz");
|
|
38161
38154
|
const frizzStat = lstatSync3(frizzPath);
|
|
38162
38155
|
if (!frizzStat.isDirectory() || frizzStat.isSymbolicLink()) return null;
|
|
38163
38156
|
const realFrizz = realpathSync8(frizzPath);
|
|
38164
|
-
if (
|
|
38165
|
-
const path3 =
|
|
38157
|
+
if (dirname12(realFrizz) !== projectRoot || basename6(realFrizz) !== ".frizz") return null;
|
|
38158
|
+
const path3 = join30(realFrizz, `${parsed.data}.md`);
|
|
38166
38159
|
const before = lstatSync3(path3);
|
|
38167
38160
|
if (!before.isFile() || before.isSymbolicLink()) return null;
|
|
38168
38161
|
const realPath = realpathSync8(path3);
|
|
38169
|
-
if (
|
|
38162
|
+
if (dirname12(realPath) !== realFrizz || basename6(realPath) !== `${parsed.data}.md`) return null;
|
|
38170
38163
|
let contents;
|
|
38171
38164
|
let openedBefore;
|
|
38172
38165
|
let openedAfter;
|
|
@@ -38206,7 +38199,7 @@ function boardAuthorizesAdoption(board, slug) {
|
|
|
38206
38199
|
return !board.errorItems.some((item) => item.file === `${slug}.md`);
|
|
38207
38200
|
}
|
|
38208
38201
|
function ensureSafeDirectDirectory(parent, name) {
|
|
38209
|
-
const path3 =
|
|
38202
|
+
const path3 = join30(parent, name);
|
|
38210
38203
|
try {
|
|
38211
38204
|
mkdirSync13(path3);
|
|
38212
38205
|
} catch (error) {
|
|
@@ -38216,7 +38209,7 @@ function ensureSafeDirectDirectory(parent, name) {
|
|
|
38216
38209
|
const stat2 = lstatSync3(path3);
|
|
38217
38210
|
if (!stat2.isDirectory() || stat2.isSymbolicLink()) throw new Error("unsafe project directory");
|
|
38218
38211
|
const real = realpathSync8(path3);
|
|
38219
|
-
if (
|
|
38212
|
+
if (dirname12(real) !== parent || basename6(real) !== name) throw new Error("unsafe project directory");
|
|
38220
38213
|
return real;
|
|
38221
38214
|
}
|
|
38222
38215
|
function scratchDirRelPath(sessionId) {
|
|
@@ -38236,8 +38229,8 @@ function loadWorkerPrompt(kind = "claude") {
|
|
|
38236
38229
|
function monitorScriptsDir() {
|
|
38237
38230
|
const plugin = workerPluginDir();
|
|
38238
38231
|
if (!plugin) return void 0;
|
|
38239
|
-
const dir =
|
|
38240
|
-
return existsSync11(
|
|
38232
|
+
const dir = join30(plugin, "skills", "gh", "scripts");
|
|
38233
|
+
return existsSync11(join30(dir, "ci-watch.mjs")) ? dir : void 0;
|
|
38241
38234
|
}
|
|
38242
38235
|
function codexScratchpadHookConfig(hookScript, sessionId) {
|
|
38243
38236
|
if (!hookScript || !sessionId) return {};
|
|
@@ -38249,7 +38242,7 @@ function codexScratchpadHookConfig(hookScript, sessionId) {
|
|
|
38249
38242
|
}
|
|
38250
38243
|
]
|
|
38251
38244
|
});
|
|
38252
|
-
const bashBackgroundHook =
|
|
38245
|
+
const bashBackgroundHook = join30(dirname12(hookScript), "bash-background.mjs");
|
|
38253
38246
|
return {
|
|
38254
38247
|
bypass_hook_trust: true,
|
|
38255
38248
|
hooks: {
|
|
@@ -38275,7 +38268,7 @@ function codexScratchpadHookConfig(hookScript, sessionId) {
|
|
|
38275
38268
|
}
|
|
38276
38269
|
function scratchpadHookScript() {
|
|
38277
38270
|
const plugin = workerPluginDir();
|
|
38278
|
-
return plugin ?
|
|
38271
|
+
return plugin ? join30(plugin, "hooks", "scratchpad.mjs") : void 0;
|
|
38279
38272
|
}
|
|
38280
38273
|
function composePrompt(sessionId, prompt, kind = "claude") {
|
|
38281
38274
|
const children2 = kind === "codex" ? "Native sub-agents share it \u2014 have each write its OWN file rather than all editing one." : "Name it in a sub-agent's prompt when you want its notes to land somewhere you can read; give each child its OWN file rather than having them all edit one.";
|
|
@@ -38291,10 +38284,10 @@ function scratchpadOrientation(sessionId, kind = "claude") {
|
|
|
38291
38284
|
return `SCRATCH DIRECTORY: .frizz/threads/${sessionId}/ \u2014 yours, free-form, as many files as you like, and nothing is expected in it. A single direct task usually needs none; writing notes is never a substitute for doing the work (${children2}). Nothing in this directory is read automatically; if you want a note back after a compaction, mcp__frizz__goal with post_compaction: true re-sends a prompt of your choosing.`;
|
|
38292
38285
|
}
|
|
38293
38286
|
function frizzConfigBlock(projectDir) {
|
|
38294
|
-
const path3 =
|
|
38287
|
+
const path3 = join30(projectDir, "FRIZZ.md");
|
|
38295
38288
|
let body;
|
|
38296
38289
|
try {
|
|
38297
|
-
const st2 =
|
|
38290
|
+
const st2 = statSync14(path3);
|
|
38298
38291
|
if (!st2.isFile() || st2.size > FRIZZ_MD_MAX_BYTES) return "";
|
|
38299
38292
|
body = readFileSync20(path3, "utf8").trim();
|
|
38300
38293
|
} catch {
|
|
@@ -38335,7 +38328,7 @@ function resolveFrizzMcp(target, moduleUrl = import.meta.url, env = process.env,
|
|
|
38335
38328
|
const { stateDir, serverLock, projectId } = typeof target === "string" ? { stateDir: target } : target;
|
|
38336
38329
|
const pluginDir = resolveWorkerPluginDir(moduleUrl, env);
|
|
38337
38330
|
if (!pluginDir) return void 0;
|
|
38338
|
-
const scriptPath =
|
|
38331
|
+
const scriptPath = join30(pluginDir, "bin", FRIZZ_MCP.script);
|
|
38339
38332
|
if (!existsSync11(scriptPath)) return void 0;
|
|
38340
38333
|
return {
|
|
38341
38334
|
scriptPath,
|
|
@@ -38418,7 +38411,7 @@ function buildClaudeResumeCommand(opts) {
|
|
|
38418
38411
|
}
|
|
38419
38412
|
function createDispatcher(deps) {
|
|
38420
38413
|
const readBoardSource = deps.readBoard ?? readBoard;
|
|
38421
|
-
const frizzDir =
|
|
38414
|
+
const frizzDir = join30(deps.project.dir, ".frizz");
|
|
38422
38415
|
const adoptionRuntime = deps.adoptionRuntime ?? productionRuntime;
|
|
38423
38416
|
function cleanupPrewrites(built) {
|
|
38424
38417
|
for (const path3 of new Set(built.prewrite.map((file) => file.path))) {
|
|
@@ -38431,7 +38424,7 @@ function createDispatcher(deps) {
|
|
|
38431
38424
|
function cleanupDispatchFiles(scratchRel, built, sessionId) {
|
|
38432
38425
|
cleanupPrewrites(built);
|
|
38433
38426
|
try {
|
|
38434
|
-
rmSync9(
|
|
38427
|
+
rmSync9(join30(deps.project.dir, scratchRel), { force: true, recursive: true });
|
|
38435
38428
|
} catch {
|
|
38436
38429
|
}
|
|
38437
38430
|
cleanupAdoptionSessionFiles(deps.project.dir, sessionId);
|
|
@@ -38924,7 +38917,7 @@ import {
|
|
|
38924
38917
|
watch as fsWatch
|
|
38925
38918
|
} from "node:fs";
|
|
38926
38919
|
import { homedir as homedir14 } from "node:os";
|
|
38927
|
-
import { dirname as
|
|
38920
|
+
import { dirname as dirname13, join as join31 } from "node:path";
|
|
38928
38921
|
import watcher from "@parcel/watcher";
|
|
38929
38922
|
function appServerTurnStalled(liveness, lastActivityAt, nowMs) {
|
|
38930
38923
|
if (!liveness) return false;
|
|
@@ -38973,7 +38966,7 @@ function registeredLegacyFileIsTerminal(projectDir, slug) {
|
|
|
38973
38966
|
return status === "done" || status === "dismissed";
|
|
38974
38967
|
}
|
|
38975
38968
|
function isBoardRelevantFrizzPath(roots, path3) {
|
|
38976
|
-
return path3.endsWith(".md") && roots.has(
|
|
38969
|
+
return path3.endsWith(".md") && roots.has(dirname13(path3));
|
|
38977
38970
|
}
|
|
38978
38971
|
function futureSnooze(row, nowMs) {
|
|
38979
38972
|
const parsed = SnoozeUntil.safeParse(row.snoozed_until);
|
|
@@ -39773,7 +39766,7 @@ function createBoard(project, storage, bus, tailer, bootId, deps = {}) {
|
|
|
39773
39766
|
if (parcelSub || stopped) return Promise.resolve();
|
|
39774
39767
|
if (watchSetup) return watchSetup;
|
|
39775
39768
|
const setup = (async () => {
|
|
39776
|
-
const dir =
|
|
39769
|
+
const dir = join31(project.dir, ".frizz");
|
|
39777
39770
|
const roots = /* @__PURE__ */ new Set([dir]);
|
|
39778
39771
|
try {
|
|
39779
39772
|
roots.add(realpathSync9(dir));
|
|
@@ -39788,7 +39781,7 @@ function createBoard(project, storage, bus, tailer, bootId, deps = {}) {
|
|
|
39788
39781
|
}
|
|
39789
39782
|
if (events.some((event) => isBoardRelevantFrizzPath(roots, event.path))) scheduleRebuild();
|
|
39790
39783
|
},
|
|
39791
|
-
{ ignore: FRIZZ_WATCH_IGNORED_DIRS.map((name) =>
|
|
39784
|
+
{ ignore: FRIZZ_WATCH_IGNORED_DIRS.map((name) => join31(dir, name)) }
|
|
39792
39785
|
);
|
|
39793
39786
|
if (stopped) {
|
|
39794
39787
|
await next.unsubscribe();
|
|
@@ -42697,7 +42690,7 @@ var init_resume = __esm({
|
|
|
42697
42690
|
});
|
|
42698
42691
|
|
|
42699
42692
|
// packages/server/src/backend/claude.ts
|
|
42700
|
-
import { join as
|
|
42693
|
+
import { join as join32 } from "node:path";
|
|
42701
42694
|
function toolResultText2(content) {
|
|
42702
42695
|
if (typeof content === "string") return content;
|
|
42703
42696
|
if (!Array.isArray(content)) return "";
|
|
@@ -42788,7 +42781,7 @@ function createClaudeBackend(opts) {
|
|
|
42788
42781
|
return { argv, env: claudeWorkerEnvironment(), prewrite: [] };
|
|
42789
42782
|
},
|
|
42790
42783
|
transcriptPath(sessionId) {
|
|
42791
|
-
return
|
|
42784
|
+
return join32(opts.logDir, `${sessionId}.jsonl`);
|
|
42792
42785
|
},
|
|
42793
42786
|
parseLine(line) {
|
|
42794
42787
|
return parseClaudeLine(line);
|
|
@@ -42814,9 +42807,9 @@ var init_claude = __esm({
|
|
|
42814
42807
|
|
|
42815
42808
|
// packages/server/src/backend/acp-transcript.ts
|
|
42816
42809
|
import { appendFileSync as appendFileSync3, existsSync as existsSync13, mkdirSync as mkdirSync14, readFileSync as readFileSync21 } from "node:fs";
|
|
42817
|
-
import { dirname as
|
|
42810
|
+
import { dirname as dirname14, join as join33 } from "node:path";
|
|
42818
42811
|
function acpTranscriptPath(stateDir, sessionId) {
|
|
42819
|
-
return
|
|
42812
|
+
return join33(stateDir, ACP_TRANSCRIPT_DIR, `${sessionId}.jsonl`);
|
|
42820
42813
|
}
|
|
42821
42814
|
function parseAcpRecord(line) {
|
|
42822
42815
|
if (!line.trim()) return void 0;
|
|
@@ -43017,7 +43010,7 @@ var init_acp_transcript = __esm({
|
|
|
43017
43010
|
AcpTranscriptWriter = class {
|
|
43018
43011
|
constructor(path3) {
|
|
43019
43012
|
this.path = path3;
|
|
43020
|
-
mkdirSync14(
|
|
43013
|
+
mkdirSync14(dirname14(path3), { recursive: true });
|
|
43021
43014
|
if (!existsSync13(path3)) appendFileSync3(path3, "");
|
|
43022
43015
|
}
|
|
43023
43016
|
append(record) {
|
|
@@ -43405,14 +43398,14 @@ import { spawn as spawn7 } from "node:child_process";
|
|
|
43405
43398
|
import { createConnection as createConnection2 } from "node:net";
|
|
43406
43399
|
import { createHash as createHash13, randomUUID as randomUUID15 } from "node:crypto";
|
|
43407
43400
|
import { existsSync as existsSync14, mkdirSync as mkdirSync15, readFileSync as readFileSync22, readdirSync as readdirSync8, unlinkSync as unlinkSync4 } from "node:fs";
|
|
43408
|
-
import { join as
|
|
43401
|
+
import { join as join34 } from "node:path";
|
|
43409
43402
|
import { PassThrough as PassThrough3, Writable as Writable3 } from "node:stream";
|
|
43410
43403
|
import { StringDecoder as StringDecoder5 } from "node:string_decoder";
|
|
43411
43404
|
function daemonDir2(stateDir) {
|
|
43412
|
-
return
|
|
43405
|
+
return join34(stateDir, "acp-daemon");
|
|
43413
43406
|
}
|
|
43414
43407
|
function acpDaemonRecordPath(stateDir, sessionId) {
|
|
43415
|
-
return
|
|
43408
|
+
return join34(daemonDir2(stateDir), `${sessionId}.json`);
|
|
43416
43409
|
}
|
|
43417
43410
|
function acpDaemonSocketPath(stateDir, sessionId) {
|
|
43418
43411
|
const key = createHash13("sha256").update(stateDir).update("\0").update(sessionId).digest("hex").slice(0, 16);
|
|
@@ -44402,182 +44395,6 @@ var init_acp_bridge = __esm({
|
|
|
44402
44395
|
}
|
|
44403
44396
|
});
|
|
44404
44397
|
|
|
44405
|
-
// packages/server/src/login-utility.ts
|
|
44406
|
-
import { randomBytes } from "node:crypto";
|
|
44407
|
-
import pty from "node-pty";
|
|
44408
|
-
function createLoginUtility(deps) {
|
|
44409
|
-
const spawnPty = deps.spawnPty ?? pty.spawn;
|
|
44410
|
-
const env = deps.env ?? process.env;
|
|
44411
|
-
const lifetimeMs = deps.lifetimeMs ?? ATTEMPT_LIFETIME_MS;
|
|
44412
|
-
const attempts = /* @__PURE__ */ new Map();
|
|
44413
|
-
function loginArgv(backend) {
|
|
44414
|
-
if (backend === "codex") {
|
|
44415
|
-
const codex = resolveCodexExecutable(deps.codexBin, { env });
|
|
44416
|
-
return { file: codex.file, args: [...codex.args, "login"] };
|
|
44417
|
-
}
|
|
44418
|
-
return { file: resolveClaudeExecutableAbsolute(deps.claudeBin, env), args: ["auth", "login"] };
|
|
44419
|
-
}
|
|
44420
|
-
function failedAttempt(id2, backend, cause) {
|
|
44421
|
-
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
44422
|
-
const error = `Could not start the ${backend === "codex" ? "Codex" : "Claude"} sign-in: ${reason}`;
|
|
44423
|
-
return {
|
|
44424
|
-
id: id2,
|
|
44425
|
-
backend,
|
|
44426
|
-
timer: setTimeout(() => teardown(id2), lifetimeMs),
|
|
44427
|
-
buffer: `${error}\r
|
|
44428
|
-
`,
|
|
44429
|
-
bufferBytes: Buffer.byteLength(error) + 2,
|
|
44430
|
-
exited: true,
|
|
44431
|
-
error,
|
|
44432
|
-
dataListeners: /* @__PURE__ */ new Set(),
|
|
44433
|
-
exitListeners: /* @__PURE__ */ new Set()
|
|
44434
|
-
};
|
|
44435
|
-
}
|
|
44436
|
-
function teardown(id2) {
|
|
44437
|
-
const attempt = attempts.get(id2);
|
|
44438
|
-
if (!attempt) return;
|
|
44439
|
-
clearTimeout(attempt.timer);
|
|
44440
|
-
attempts.delete(id2);
|
|
44441
|
-
attempt.buffer = "";
|
|
44442
|
-
attempt.bufferBytes = 0;
|
|
44443
|
-
attempt.dataListeners.clear();
|
|
44444
|
-
for (const listener of attempt.exitListeners) {
|
|
44445
|
-
try {
|
|
44446
|
-
listener();
|
|
44447
|
-
} catch {
|
|
44448
|
-
}
|
|
44449
|
-
}
|
|
44450
|
-
attempt.exitListeners.clear();
|
|
44451
|
-
try {
|
|
44452
|
-
attempt.term?.kill();
|
|
44453
|
-
} catch {
|
|
44454
|
-
}
|
|
44455
|
-
}
|
|
44456
|
-
return {
|
|
44457
|
-
start(backend) {
|
|
44458
|
-
for (const attempt2 of attempts.values()) {
|
|
44459
|
-
if (attempt2.backend !== backend) continue;
|
|
44460
|
-
if (!attempt2.exited) return { attemptId: attempt2.id };
|
|
44461
|
-
teardown(attempt2.id);
|
|
44462
|
-
}
|
|
44463
|
-
const id2 = `login-${randomBytes(8).toString("hex")}`;
|
|
44464
|
-
let term;
|
|
44465
|
-
try {
|
|
44466
|
-
const { file, args } = loginArgv(backend);
|
|
44467
|
-
term = spawnPty(file, args, {
|
|
44468
|
-
name: process.platform === "win32" ? "xterm-color" : "xterm-256color",
|
|
44469
|
-
cwd: deps.cwd,
|
|
44470
|
-
env,
|
|
44471
|
-
cols: 120,
|
|
44472
|
-
rows: 30
|
|
44473
|
-
});
|
|
44474
|
-
} catch (cause) {
|
|
44475
|
-
const failed = failedAttempt(id2, backend, cause);
|
|
44476
|
-
failed.timer.unref?.();
|
|
44477
|
-
attempts.set(id2, failed);
|
|
44478
|
-
return { attemptId: id2 };
|
|
44479
|
-
}
|
|
44480
|
-
const attempt = {
|
|
44481
|
-
id: id2,
|
|
44482
|
-
backend,
|
|
44483
|
-
term,
|
|
44484
|
-
timer: setTimeout(() => teardown(id2), lifetimeMs),
|
|
44485
|
-
buffer: "",
|
|
44486
|
-
bufferBytes: 0,
|
|
44487
|
-
exited: false,
|
|
44488
|
-
dataListeners: /* @__PURE__ */ new Set(),
|
|
44489
|
-
exitListeners: /* @__PURE__ */ new Set()
|
|
44490
|
-
};
|
|
44491
|
-
attempt.timer.unref?.();
|
|
44492
|
-
term.onData((chunk) => {
|
|
44493
|
-
attempt.buffer += chunk;
|
|
44494
|
-
attempt.bufferBytes += Buffer.byteLength(chunk);
|
|
44495
|
-
while (attempt.bufferBytes > REPLAY_CAP_BYTES && attempt.buffer.length > 0) {
|
|
44496
|
-
const drop = attempt.buffer.slice(0, Math.ceil(attempt.buffer.length / 4));
|
|
44497
|
-
attempt.buffer = attempt.buffer.slice(drop.length);
|
|
44498
|
-
attempt.bufferBytes -= Buffer.byteLength(drop);
|
|
44499
|
-
}
|
|
44500
|
-
for (const listener of attempt.dataListeners) {
|
|
44501
|
-
try {
|
|
44502
|
-
listener(chunk);
|
|
44503
|
-
} catch {
|
|
44504
|
-
}
|
|
44505
|
-
}
|
|
44506
|
-
});
|
|
44507
|
-
term.onExit(() => {
|
|
44508
|
-
attempt.exited = true;
|
|
44509
|
-
for (const listener of attempt.exitListeners) {
|
|
44510
|
-
try {
|
|
44511
|
-
listener();
|
|
44512
|
-
} catch {
|
|
44513
|
-
}
|
|
44514
|
-
}
|
|
44515
|
-
});
|
|
44516
|
-
attempts.set(id2, attempt);
|
|
44517
|
-
return { attemptId: id2 };
|
|
44518
|
-
},
|
|
44519
|
-
attach(slug) {
|
|
44520
|
-
const attempt = attempts.get(slug);
|
|
44521
|
-
if (!attempt) return null;
|
|
44522
|
-
return {
|
|
44523
|
-
replay: () => attempt.buffer,
|
|
44524
|
-
onData: (listener) => {
|
|
44525
|
-
attempt.dataListeners.add(listener);
|
|
44526
|
-
return () => attempt.dataListeners.delete(listener);
|
|
44527
|
-
},
|
|
44528
|
-
write: (data) => {
|
|
44529
|
-
if (!attempt.exited) {
|
|
44530
|
-
try {
|
|
44531
|
-
attempt.term?.write(data);
|
|
44532
|
-
} catch {
|
|
44533
|
-
}
|
|
44534
|
-
}
|
|
44535
|
-
},
|
|
44536
|
-
resize: (cols, rows) => {
|
|
44537
|
-
if (!attempt.exited) {
|
|
44538
|
-
try {
|
|
44539
|
-
attempt.term?.resize(cols, rows);
|
|
44540
|
-
} catch {
|
|
44541
|
-
}
|
|
44542
|
-
}
|
|
44543
|
-
},
|
|
44544
|
-
onExit: (listener) => {
|
|
44545
|
-
if (attempt.exited) {
|
|
44546
|
-
listener();
|
|
44547
|
-
return () => {
|
|
44548
|
-
};
|
|
44549
|
-
}
|
|
44550
|
-
attempt.exitListeners.add(listener);
|
|
44551
|
-
return () => attempt.exitListeners.delete(listener);
|
|
44552
|
-
},
|
|
44553
|
-
close: () => {
|
|
44554
|
-
}
|
|
44555
|
-
};
|
|
44556
|
-
},
|
|
44557
|
-
status(attemptId) {
|
|
44558
|
-
const attempt = attempts.get(attemptId);
|
|
44559
|
-
if (!attempt) return { state: "exited" };
|
|
44560
|
-
return { state: attempt.exited ? "exited" : "running", backend: attempt.backend, ...attempt.error ? { error: attempt.error } : {} };
|
|
44561
|
-
},
|
|
44562
|
-
cancel(attemptId) {
|
|
44563
|
-
teardown(attemptId);
|
|
44564
|
-
},
|
|
44565
|
-
stop() {
|
|
44566
|
-
for (const id2 of [...attempts.keys()]) teardown(id2);
|
|
44567
|
-
}
|
|
44568
|
-
};
|
|
44569
|
-
}
|
|
44570
|
-
var ATTEMPT_LIFETIME_MS, REPLAY_CAP_BYTES;
|
|
44571
|
-
var init_login_utility = __esm({
|
|
44572
|
-
"packages/server/src/login-utility.ts"() {
|
|
44573
|
-
"use strict";
|
|
44574
|
-
init_claude_broker_host();
|
|
44575
|
-
init_codex_executable();
|
|
44576
|
-
ATTEMPT_LIFETIME_MS = 10 * 60 * 1e3;
|
|
44577
|
-
REPLAY_CAP_BYTES = 256 * 1024;
|
|
44578
|
-
}
|
|
44579
|
-
});
|
|
44580
|
-
|
|
44581
44398
|
// node_modules/.pnpm/@anthropic-ai+claude-agent-sdk@0.3.282_@anthropic-ai+sdk@0.111.0_zod@4.4.3__@modelconte_2775e0bf363ceb1ee09ef372c727fb7d/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs
|
|
44582
44399
|
import { createRequire as IW } from "node:module";
|
|
44583
44400
|
import { randomUUID as Ol } from "crypto";
|
|
@@ -68641,13 +68458,13 @@ var init_claude_models = __esm({
|
|
|
68641
68458
|
});
|
|
68642
68459
|
|
|
68643
68460
|
// packages/server/src/backend/codex-app-server-diagnostics.ts
|
|
68644
|
-
import { appendFileSync as appendFileSync5, mkdirSync as mkdirSync17, renameSync as renameSync9, statSync as
|
|
68645
|
-
import { join as
|
|
68461
|
+
import { appendFileSync as appendFileSync5, mkdirSync as mkdirSync17, renameSync as renameSync9, statSync as statSync16 } from "node:fs";
|
|
68462
|
+
import { join as join36 } from "node:path";
|
|
68646
68463
|
function codexDiagnosticLogPath(stateDir, projectId) {
|
|
68647
|
-
return
|
|
68464
|
+
return join36(stateDir, "codex-app-server", `${projectId}.diagnostics.log`);
|
|
68648
68465
|
}
|
|
68649
68466
|
function createCodexDiagnosticSink(stateDir, projectId, now = () => /* @__PURE__ */ new Date()) {
|
|
68650
|
-
const dir =
|
|
68467
|
+
const dir = join36(stateDir, "codex-app-server");
|
|
68651
68468
|
const path3 = codexDiagnosticLogPath(stateDir, projectId);
|
|
68652
68469
|
let ensured = false;
|
|
68653
68470
|
return (event) => {
|
|
@@ -68658,7 +68475,7 @@ function createCodexDiagnosticSink(stateDir, projectId, now = () => /* @__PURE__
|
|
|
68658
68475
|
ensured = true;
|
|
68659
68476
|
}
|
|
68660
68477
|
try {
|
|
68661
|
-
if (
|
|
68478
|
+
if (statSync16(path3).size > MAX_BYTES2) renameSync9(path3, `${path3}.1`);
|
|
68662
68479
|
} catch {
|
|
68663
68480
|
}
|
|
68664
68481
|
appendFileSync5(path3, `${JSON.stringify({ at: now().toISOString(), ...event })}
|
|
@@ -68679,7 +68496,7 @@ var init_codex_app_server_diagnostics = __esm({
|
|
|
68679
68496
|
import { execFile as execFile9 } from "node:child_process";
|
|
68680
68497
|
import { readdirSync as readdirSync10, unlinkSync as unlinkSync6 } from "node:fs";
|
|
68681
68498
|
import { connect as connectSocket } from "node:net";
|
|
68682
|
-
import { join as
|
|
68499
|
+
import { join as join37 } from "node:path";
|
|
68683
68500
|
function parseLsofSocketNames(stdout) {
|
|
68684
68501
|
const referenced = /* @__PURE__ */ new Set();
|
|
68685
68502
|
for (const line of stdout.split("\n")) {
|
|
@@ -68696,7 +68513,7 @@ function sweepStaleSockets(options, deps = {}) {
|
|
|
68696
68513
|
const keep = new Set(options.keep ?? []);
|
|
68697
68514
|
let candidates;
|
|
68698
68515
|
try {
|
|
68699
|
-
candidates = (deps.readdir ?? readdirSync10)(options.dir).filter((name) => name.startsWith(options.prefix) && name.endsWith(".sock")).map((name) =>
|
|
68516
|
+
candidates = (deps.readdir ?? readdirSync10)(options.dir).filter((name) => name.startsWith(options.prefix) && name.endsWith(".sock")).map((name) => join37(options.dir, name)).filter((path3) => !keep.has(path3));
|
|
68700
68517
|
} catch {
|
|
68701
68518
|
return;
|
|
68702
68519
|
}
|
|
@@ -68747,7 +68564,7 @@ var init_stale_socket_sweep = __esm({
|
|
|
68747
68564
|
// packages/server/src/orphan-reaper.ts
|
|
68748
68565
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
68749
68566
|
import { readFileSync as readFileSync24 } from "node:fs";
|
|
68750
|
-
import { dirname as
|
|
68567
|
+
import { dirname as dirname16 } from "node:path";
|
|
68751
68568
|
function firstTokenBasename(command) {
|
|
68752
68569
|
const first = command.trimStart().split(/\s+/, 1)[0] ?? "";
|
|
68753
68570
|
const slash = first.lastIndexOf("/");
|
|
@@ -68975,7 +68792,7 @@ function sweepOrphansOnce(deps = {}) {
|
|
|
68975
68792
|
}
|
|
68976
68793
|
function sweepStaleBrokerSockets() {
|
|
68977
68794
|
try {
|
|
68978
|
-
sweepStaleSockets({ dir:
|
|
68795
|
+
sweepStaleSockets({ dir: dirname16(claudeBrokerSocketPath("", "")), prefix: CLAUDE_BROKER_SOCKET_PREFIX });
|
|
68979
68796
|
} catch {
|
|
68980
68797
|
}
|
|
68981
68798
|
}
|
|
@@ -69044,7 +68861,7 @@ var init_orphan_reaper = __esm({
|
|
|
69044
68861
|
});
|
|
69045
68862
|
|
|
69046
68863
|
// packages/server/src/context.ts
|
|
69047
|
-
import { join as
|
|
68864
|
+
import { join as join38 } from "node:path";
|
|
69048
68865
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
69049
68866
|
import { homedir as homedir15 } from "node:os";
|
|
69050
68867
|
function reconcileSessions(storage) {
|
|
@@ -69139,7 +68956,6 @@ function deliverClaudeBrokerWake(deps) {
|
|
|
69139
68956
|
function projectContextCleanups(get) {
|
|
69140
68957
|
return {
|
|
69141
68958
|
tailer: () => get()?.tailer.stop(),
|
|
69142
|
-
loginUtility: () => get()?.loginUtility?.stop(),
|
|
69143
68959
|
subscriptions: () => get()?.stopSubscriptions(),
|
|
69144
68960
|
scheduler: async () => {
|
|
69145
68961
|
await get()?.scheduler.stop();
|
|
@@ -69197,7 +69013,7 @@ async function createContext(opts = {}) {
|
|
|
69197
69013
|
function createContextUnchecked(opts, resources) {
|
|
69198
69014
|
const home = opts.home ?? homedir15();
|
|
69199
69015
|
const project = opts.project ?? resolveProject();
|
|
69200
|
-
const storage = createStorage(opts.database ??
|
|
69016
|
+
const storage = createStorage(opts.database ?? join38(project.stateDir, "ui.db"), project.id);
|
|
69201
69017
|
resources.storage = storage;
|
|
69202
69018
|
const bus = new Bus();
|
|
69203
69019
|
const transcriptChange = new Emitter();
|
|
@@ -69599,8 +69415,7 @@ ${wakeDeliveryToken(deliveryId)}`;
|
|
|
69599
69415
|
teardownProject: opts.teardownProject,
|
|
69600
69416
|
launchProjectId: opts.launchProjectId,
|
|
69601
69417
|
claudeBin: opts.claudeBin,
|
|
69602
|
-
codexBin: opts.codexBin
|
|
69603
|
-
loginUtility: createLoginUtility({ claudeBin: opts.claudeBin, codexBin: opts.codexBin, cwd: project.dir })
|
|
69418
|
+
codexBin: opts.codexBin
|
|
69604
69419
|
};
|
|
69605
69420
|
}
|
|
69606
69421
|
var CONTEXT_STARTUP_CLEANUP_TIMEOUT_MS, QUOTA_REFRESH_INTERVAL_MS, ContextStartupError;
|
|
@@ -69625,7 +69440,6 @@ var init_context = __esm({
|
|
|
69625
69440
|
init_acp_transcript();
|
|
69626
69441
|
init_acp_bridge();
|
|
69627
69442
|
init_auth_status();
|
|
69628
|
-
init_login_utility();
|
|
69629
69443
|
init_usage_limit();
|
|
69630
69444
|
init_claude_models();
|
|
69631
69445
|
init_claude_model_upgrade();
|
|
@@ -72303,7 +72117,7 @@ var init_server = __esm({
|
|
|
72303
72117
|
|
|
72304
72118
|
// packages/server/src/repair.ts
|
|
72305
72119
|
import { existsSync as existsSync16, readFileSync as readFileSync25, writeFileSync as writeFileSync11 } from "node:fs";
|
|
72306
|
-
import { basename as basename7, dirname as
|
|
72120
|
+
import { basename as basename7, dirname as dirname17, resolve as resolve9 } from "node:path";
|
|
72307
72121
|
function quoteValue(v) {
|
|
72308
72122
|
if (/^[\w./#:+-]+$/.test(v)) return v;
|
|
72309
72123
|
return `"${v.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
@@ -72315,7 +72129,7 @@ function deriveTitle(body, slug) {
|
|
|
72315
72129
|
function repairThreadFile(frizzDir, file) {
|
|
72316
72130
|
const root = resolve9(frizzDir);
|
|
72317
72131
|
const abs = resolve9(root, file);
|
|
72318
|
-
if (
|
|
72132
|
+
if (dirname17(abs) !== root) throw new RepairError(`refusing to repair "${file}": not directly under .frizz/`);
|
|
72319
72133
|
if (!abs.endsWith(".md")) throw new RepairError(`refusing to repair "${file}": not a .md thread file`);
|
|
72320
72134
|
if (!existsSync16(abs)) throw new RepairError(`no thread file to repair: ${basename7(abs)}`);
|
|
72321
72135
|
const content = readFileSync25(abs, "utf8");
|
|
@@ -72718,10 +72532,10 @@ var init_bash_background = __esm({
|
|
|
72718
72532
|
});
|
|
72719
72533
|
|
|
72720
72534
|
// packages/server/src/transcript.ts
|
|
72721
|
-
import { closeSync as closeSync14, existsSync as existsSync17, fstatSync as fstatSync3, mkdirSync as mkdirSync18, openSync as openSync15, readdirSync as readdirSync11, readFileSync as readFileSync27, readSync as readSync8, renameSync as renameSync10, statSync as
|
|
72535
|
+
import { closeSync as closeSync14, existsSync as existsSync17, fstatSync as fstatSync3, mkdirSync as mkdirSync18, openSync as openSync15, readdirSync as readdirSync11, readFileSync as readFileSync27, readSync as readSync8, renameSync as renameSync10, statSync as statSync17, unlinkSync as unlinkSync7, writeFileSync as writeFileSync12 } from "node:fs";
|
|
72722
72536
|
import { createHash as createHash14 } from "node:crypto";
|
|
72723
72537
|
import { StringDecoder as StringDecoder6 } from "node:string_decoder";
|
|
72724
|
-
import { join as
|
|
72538
|
+
import { join as join39 } from "node:path";
|
|
72725
72539
|
import { homedir as homedir16 } from "node:os";
|
|
72726
72540
|
function formatTokens(n) {
|
|
72727
72541
|
if (n >= 1e6) return `${(n / 1e6).toFixed(1)}M`;
|
|
@@ -73301,14 +73115,14 @@ function pruneScreenshotCache() {
|
|
|
73301
73115
|
if (entries2.length <= SCREENSHOT_CACHE_MAX) return;
|
|
73302
73116
|
const byMtime = entries2.map((n) => {
|
|
73303
73117
|
try {
|
|
73304
|
-
return { n, m:
|
|
73118
|
+
return { n, m: statSync17(join39(SCREENSHOT_CACHE_DIR, n)).mtimeMs };
|
|
73305
73119
|
} catch {
|
|
73306
73120
|
return { n, m: 0 };
|
|
73307
73121
|
}
|
|
73308
73122
|
}).sort((a, b) => b.m - a.m);
|
|
73309
73123
|
for (const { n } of byMtime.slice(SCREENSHOT_CACHE_MAX)) {
|
|
73310
73124
|
try {
|
|
73311
|
-
unlinkSync7(
|
|
73125
|
+
unlinkSync7(join39(SCREENSHOT_CACHE_DIR, n));
|
|
73312
73126
|
} catch {
|
|
73313
73127
|
}
|
|
73314
73128
|
}
|
|
@@ -73338,14 +73152,14 @@ function persistBase64Image(mediaType, data, idKey) {
|
|
|
73338
73152
|
const ext = IMAGE_MEDIA_EXT[typeof mediaType === "string" ? mediaType.toLowerCase() : ""];
|
|
73339
73153
|
if (!ext || !data) return void 0;
|
|
73340
73154
|
const name = createHash14("sha256").update(idKey).digest("hex").slice(0, 32);
|
|
73341
|
-
const path3 =
|
|
73155
|
+
const path3 = join39(SCREENSHOT_CACHE_DIR, `${name}.${ext}`);
|
|
73342
73156
|
try {
|
|
73343
73157
|
if (existsSync17(path3)) return path3;
|
|
73344
73158
|
if (data.length > SCREENSHOT_MAX_BASE64) return void 0;
|
|
73345
73159
|
const buf = Buffer.from(data, "base64");
|
|
73346
73160
|
if (buf.length === 0 || !looksLikeImage(buf, ext)) return void 0;
|
|
73347
73161
|
mkdirSync18(SCREENSHOT_CACHE_DIR, { recursive: true });
|
|
73348
|
-
const tmp =
|
|
73162
|
+
const tmp = join39(SCREENSHOT_CACHE_DIR, `.${name}.${process.pid}.${screenshotTmpSeq++}.tmp`);
|
|
73349
73163
|
writeFileSync12(tmp, buf);
|
|
73350
73164
|
renameSync10(tmp, path3);
|
|
73351
73165
|
pruneScreenshotCache();
|
|
@@ -73360,14 +73174,14 @@ function persistSentFile(srcPath, idKey) {
|
|
|
73360
73174
|
const outExt = ext === "jpeg" ? "jpg" : ext;
|
|
73361
73175
|
try {
|
|
73362
73176
|
const name = createHash14("sha256").update(idKey).digest("hex").slice(0, 32);
|
|
73363
|
-
const dest =
|
|
73177
|
+
const dest = join39(SCREENSHOT_CACHE_DIR, `${name}.${outExt}`);
|
|
73364
73178
|
if (existsSync17(dest)) return dest;
|
|
73365
|
-
const size =
|
|
73179
|
+
const size = statSync17(srcPath).size;
|
|
73366
73180
|
if (size === 0 || size > SENT_IMAGE_MAX_BYTES) return void 0;
|
|
73367
73181
|
const buf = readFileSync27(srcPath);
|
|
73368
73182
|
if (!looksLikeImage(buf, outExt)) return void 0;
|
|
73369
73183
|
mkdirSync18(SCREENSHOT_CACHE_DIR, { recursive: true });
|
|
73370
|
-
const tmp =
|
|
73184
|
+
const tmp = join39(SCREENSHOT_CACHE_DIR, `.${name}.${process.pid}.${screenshotTmpSeq++}.tmp`);
|
|
73371
73185
|
writeFileSync12(tmp, buf);
|
|
73372
73186
|
renameSync10(tmp, dest);
|
|
73373
73187
|
pruneScreenshotCache();
|
|
@@ -73825,16 +73639,16 @@ function verifyIncrementalParse(path3, identityPrefix, incremental) {
|
|
|
73825
73639
|
}
|
|
73826
73640
|
}
|
|
73827
73641
|
function logDirOf(project) {
|
|
73828
|
-
return
|
|
73642
|
+
return join39(homedir16(), ".claude", "projects", project.cwdSlug);
|
|
73829
73643
|
}
|
|
73830
73644
|
function resolveTranscriptPath(project, sessionId) {
|
|
73831
|
-
const path3 =
|
|
73645
|
+
const path3 = join39(logDirOf(project), `${sessionId}.jsonl`);
|
|
73832
73646
|
try {
|
|
73833
|
-
if (
|
|
73647
|
+
if (statSync17(path3).size > 0) return path3;
|
|
73834
73648
|
} catch {
|
|
73835
73649
|
}
|
|
73836
73650
|
const stranded = discoverTranscriptDir(logDirOf(project), sessionId);
|
|
73837
|
-
return stranded ?
|
|
73651
|
+
return stranded ? join39(stranded, `${sessionId}.jsonl`) : path3;
|
|
73838
73652
|
}
|
|
73839
73653
|
function projectCodexTranscript(raw2, identityPrefix = "codex") {
|
|
73840
73654
|
const out = [];
|
|
@@ -75805,12 +75619,12 @@ var init_background_shell_output = __esm({
|
|
|
75805
75619
|
});
|
|
75806
75620
|
|
|
75807
75621
|
// packages/server/src/image-header.ts
|
|
75808
|
-
import { closeSync as closeSync16, openSync as openSync17, readSync as readSync10, statSync as
|
|
75622
|
+
import { closeSync as closeSync16, openSync as openSync17, readSync as readSync10, statSync as statSync18 } from "node:fs";
|
|
75809
75623
|
import { extname } from "node:path";
|
|
75810
75624
|
function readHead3(path3, budget) {
|
|
75811
75625
|
let fd2;
|
|
75812
75626
|
try {
|
|
75813
|
-
const size =
|
|
75627
|
+
const size = statSync18(path3).size;
|
|
75814
75628
|
if (size === 0) return void 0;
|
|
75815
75629
|
const buffer = Buffer.alloc(Math.min(size, budget));
|
|
75816
75630
|
fd2 = openSync17(path3, "r");
|
|
@@ -76074,10 +75888,10 @@ var init_directory_picker = __esm({
|
|
|
76074
75888
|
});
|
|
76075
75889
|
|
|
76076
75890
|
// packages/server/src/router.ts
|
|
76077
|
-
import { readFileSync as readFileSync28, statSync as
|
|
76078
|
-
import { join as
|
|
75891
|
+
import { readFileSync as readFileSync28, statSync as statSync19 } from "node:fs";
|
|
75892
|
+
import { join as join40, resolve as resolve10 } from "node:path";
|
|
76079
75893
|
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
76080
|
-
import { basename as basename9, dirname as
|
|
75894
|
+
import { basename as basename9, dirname as dirname18 } from "node:path";
|
|
76081
75895
|
import { existsSync as existsSync18, mkdirSync as mkdirSync19, rmSync as rmSync11, writeFileSync as writeFileSync13 } from "node:fs";
|
|
76082
75896
|
import { homedir as homedir17 } from "node:os";
|
|
76083
75897
|
function validateGithubDispatchProfile(input) {
|
|
@@ -76252,11 +76066,11 @@ function projectCard(entry, stale) {
|
|
|
76252
76066
|
function addProjectAtPath(input, home = homedir17()) {
|
|
76253
76067
|
const typed = input.trim();
|
|
76254
76068
|
if (!typed) throw new Error("Enter a folder path.");
|
|
76255
|
-
const expanded = typed === "~" || typed.startsWith("~/") ?
|
|
76069
|
+
const expanded = typed === "~" || typed.startsWith("~/") ? join40(home, typed.slice(1)) : typed;
|
|
76256
76070
|
const absolute = resolve10(expanded);
|
|
76257
76071
|
let stats;
|
|
76258
76072
|
try {
|
|
76259
|
-
stats =
|
|
76073
|
+
stats = statSync19(absolute);
|
|
76260
76074
|
} catch {
|
|
76261
76075
|
throw new Error(`No folder at ${absolute}`);
|
|
76262
76076
|
}
|
|
@@ -76281,7 +76095,7 @@ function storeProjectIcon(id2, name, bytes) {
|
|
|
76281
76095
|
if (!entry) throw new Error("No such project.");
|
|
76282
76096
|
if (bytes.length === 0) throw new Error("That file is empty.");
|
|
76283
76097
|
const path3 = customIconPath(id2, `.${extension2}`);
|
|
76284
|
-
mkdirSync19(
|
|
76098
|
+
mkdirSync19(dirname18(path3), { recursive: true });
|
|
76285
76099
|
writeFileSync13(path3, bytes);
|
|
76286
76100
|
if (!imageDimensions(path3)) {
|
|
76287
76101
|
rmSync11(path3, { force: true });
|
|
@@ -76331,7 +76145,7 @@ function mergeSubAgentSteers(messages, steers) {
|
|
|
76331
76145
|
return merged;
|
|
76332
76146
|
}
|
|
76333
76147
|
function createRouter(ctx) {
|
|
76334
|
-
const frizzDir =
|
|
76148
|
+
const frizzDir = join40(ctx.project.dir, ".frizz");
|
|
76335
76149
|
const openRoots = openableFileRoots(ctx.project);
|
|
76336
76150
|
function isAutoTitledSession(slug) {
|
|
76337
76151
|
return ctx.storage.getSession(slug)?.title_auto === 1;
|
|
@@ -78244,33 +78058,6 @@ Say which way you went and why in your write-up, so the human can course-correct
|
|
|
78244
78058
|
});
|
|
78245
78059
|
}
|
|
78246
78060
|
}),
|
|
78247
|
-
// Slice B login utility: the sign-in modal's PRIMARY action. Starts (or re-attaches to) the one
|
|
78248
|
-
// live `claude auth login` pty — login-utility.ts runs it on node-pty directly — addressed by a
|
|
78249
|
-
// server-issued slug-shaped attempt id the browser then attaches to over the existing hardened
|
|
78250
|
-
// /term transport.
|
|
78251
|
-
accountLoginStart: mutation({
|
|
78252
|
-
input: AccountLoginStartInput,
|
|
78253
|
-
output: AccountLoginStartResult,
|
|
78254
|
-
handler: async ({ input }) => ctx.loginUtility.start(input.backend)
|
|
78255
|
-
}),
|
|
78256
|
-
accountLoginStatus: query({
|
|
78257
|
-
input: AccountLoginStatusInput,
|
|
78258
|
-
output: AccountLoginStatusResult,
|
|
78259
|
-
handler: async ({ input }) => {
|
|
78260
|
-
const { state, backend } = ctx.loginUtility.status(input.attemptId);
|
|
78261
|
-
const auth = await readAuthSnapshot({ claudeBin: ctx.claudeBin });
|
|
78262
|
-
if (state === "exited") ctx.loginUtility.cancel(input.attemptId);
|
|
78263
|
-
return { state, auth: backend === "acp" ? "unknown" : auth[backend ?? "claude"] };
|
|
78264
|
-
}
|
|
78265
|
-
}),
|
|
78266
|
-
accountLoginCancel: mutation({
|
|
78267
|
-
input: AccountLoginStatusInput,
|
|
78268
|
-
output: external_exports.object({}),
|
|
78269
|
-
handler: async ({ input }) => {
|
|
78270
|
-
ctx.loginUtility.cancel(input.attemptId);
|
|
78271
|
-
return {};
|
|
78272
|
-
}
|
|
78273
|
-
}),
|
|
78274
78061
|
/**
|
|
78275
78062
|
* Every project this machine knows about, most recently opened first.
|
|
78276
78063
|
*
|
|
@@ -78889,7 +78676,7 @@ var init_compression = __esm({
|
|
|
78889
78676
|
});
|
|
78890
78677
|
|
|
78891
78678
|
// packages/server/src/local-image.ts
|
|
78892
|
-
import { readFileSync as readFileSync29, realpathSync as realpathSync12, statSync as
|
|
78679
|
+
import { readFileSync as readFileSync29, realpathSync as realpathSync12, statSync as statSync20 } from "node:fs";
|
|
78893
78680
|
import { extname as extname2, isAbsolute as isAbsolute9 } from "node:path";
|
|
78894
78681
|
function resolveLocalImage(rawPath) {
|
|
78895
78682
|
if (rawPath) rawPath = normalizeLocalPath(rawPath);
|
|
@@ -78903,7 +78690,7 @@ function resolveLocalImage(rawPath) {
|
|
|
78903
78690
|
return { status: 404 };
|
|
78904
78691
|
}
|
|
78905
78692
|
try {
|
|
78906
|
-
if (!
|
|
78693
|
+
if (!statSync20(real).isFile()) return { status: 404 };
|
|
78907
78694
|
return { status: 200, contentType, body: readFileSync29(real) };
|
|
78908
78695
|
} catch {
|
|
78909
78696
|
return { status: 404 };
|
|
@@ -78925,9 +78712,9 @@ var init_local_image = __esm({
|
|
|
78925
78712
|
});
|
|
78926
78713
|
|
|
78927
78714
|
// packages/server/src/project-icon.ts
|
|
78928
|
-
import { readFileSync as readFileSync30, readdirSync as readdirSync12, realpathSync as realpathSync13, statSync as
|
|
78715
|
+
import { readFileSync as readFileSync30, readdirSync as readdirSync12, realpathSync as realpathSync13, statSync as statSync21 } from "node:fs";
|
|
78929
78716
|
import { homedir as homedir18 } from "node:os";
|
|
78930
|
-
import { basename as basename10, dirname as
|
|
78717
|
+
import { basename as basename10, dirname as dirname19, extname as extname3, join as join41, relative as relative2, sep as sep4 } from "node:path";
|
|
78931
78718
|
function normalizeStem(stem) {
|
|
78932
78719
|
const sized = stem.toLowerCase().replace(/[@-]\d+(\.\d+)?x(\d+)?$/u, "").replace(/[-_]\d{2,4}$/u, "");
|
|
78933
78720
|
const normalized = sized.replace(VARIANT_SUFFIX, "");
|
|
@@ -78945,7 +78732,7 @@ function sizeScore(dimensions) {
|
|
|
78945
78732
|
return Math.max(0, Math.min(40, Math.round(Math.log2(edge / 24) * 8)));
|
|
78946
78733
|
}
|
|
78947
78734
|
function under(root, relativeDirectory) {
|
|
78948
|
-
return relativeDirectory ?
|
|
78735
|
+
return relativeDirectory ? join41(root, relativeDirectory) : root;
|
|
78949
78736
|
}
|
|
78950
78737
|
function listFiles(directory) {
|
|
78951
78738
|
try {
|
|
@@ -78967,19 +78754,19 @@ function iconDirectories(root) {
|
|
|
78967
78754
|
for (const asset of ASSET_DIRECTORIES) directories.push(under(root, asset));
|
|
78968
78755
|
for (const host of HOST_DIRECTORIES) {
|
|
78969
78756
|
if (!children2.has(host)) continue;
|
|
78970
|
-
for (const asset of ASSET_DIRECTORIES) directories.push(under(
|
|
78757
|
+
for (const asset of ASSET_DIRECTORIES) directories.push(under(join41(root, host), asset));
|
|
78971
78758
|
}
|
|
78972
78759
|
for (const extra of EXTRA_DIRECTORIES) directories.push(under(root, extra));
|
|
78973
78760
|
for (const container of WORKSPACE_CONTAINERS) {
|
|
78974
78761
|
if (!children2.has(container)) continue;
|
|
78975
78762
|
let members;
|
|
78976
78763
|
try {
|
|
78977
|
-
members = readdirSync12(
|
|
78764
|
+
members = readdirSync12(join41(root, container), { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name);
|
|
78978
78765
|
} catch {
|
|
78979
78766
|
continue;
|
|
78980
78767
|
}
|
|
78981
78768
|
for (const member of members) {
|
|
78982
|
-
for (const asset of ASSET_DIRECTORIES) directories.push(under(
|
|
78769
|
+
for (const asset of ASSET_DIRECTORIES) directories.push(under(join41(root, container, member), asset));
|
|
78983
78770
|
}
|
|
78984
78771
|
}
|
|
78985
78772
|
return [...new Set(directories)];
|
|
@@ -78992,8 +78779,8 @@ function manifestIcons(manifestPath) {
|
|
|
78992
78779
|
return [];
|
|
78993
78780
|
}
|
|
78994
78781
|
if (!Array.isArray(parsed?.icons)) return [];
|
|
78995
|
-
const directory =
|
|
78996
|
-
return parsed.icons.map((icon) => typeof icon?.src === "string" ? icon.src : void 0).filter((src) => !!src && !/^(https?:)?\/\//u.test(src) && !src.startsWith("data:")).map((src) =>
|
|
78782
|
+
const directory = dirname19(manifestPath);
|
|
78783
|
+
return parsed.icons.map((icon) => typeof icon?.src === "string" ? icon.src : void 0).filter((src) => !!src && !/^(https?:)?\/\//u.test(src) && !src.startsWith("data:")).map((src) => join41(directory, src.replace(/[?#].*$/u, "").replace(/^\//u, "")));
|
|
78997
78784
|
}
|
|
78998
78785
|
function projectIconCandidates(root) {
|
|
78999
78786
|
const projectStem = normalizeStem(basename10(root)).normalized;
|
|
@@ -79012,10 +78799,10 @@ function projectIconCandidates(root) {
|
|
|
79012
78799
|
for (const name of listFiles(directory)) {
|
|
79013
78800
|
const extension2 = extname3(name).toLowerCase();
|
|
79014
78801
|
if (MANIFEST_NAMES.includes(name.toLowerCase())) {
|
|
79015
|
-
for (const icon of manifestIcons(
|
|
78802
|
+
for (const icon of manifestIcons(join41(directory, name))) {
|
|
79016
78803
|
if (MEASURABLE_IMAGE_EXTENSIONS.has(extname3(icon).toLowerCase())) {
|
|
79017
78804
|
fromManifest.add(icon);
|
|
79018
|
-
files.push({ path: icon, directory:
|
|
78805
|
+
files.push({ path: icon, directory: dirname19(icon) });
|
|
79019
78806
|
}
|
|
79020
78807
|
}
|
|
79021
78808
|
continue;
|
|
@@ -79023,7 +78810,7 @@ function projectIconCandidates(root) {
|
|
|
79023
78810
|
if (!MEASURABLE_IMAGE_EXTENSIONS.has(extension2)) continue;
|
|
79024
78811
|
const stem = name.slice(0, name.length - extension2.length);
|
|
79025
78812
|
if (normalizeStem(stem).normalized === "favicon") iconHomes.add(directory);
|
|
79026
|
-
files.push({ path:
|
|
78813
|
+
files.push({ path: join41(directory, name), directory });
|
|
79027
78814
|
if (files.length >= MAX_CANDIDATES) break;
|
|
79028
78815
|
}
|
|
79029
78816
|
}
|
|
@@ -79075,7 +78862,7 @@ function resolveProjectIconResponse(id2, options = {}) {
|
|
|
79075
78862
|
let real;
|
|
79076
78863
|
try {
|
|
79077
78864
|
real = realpathSync13(path3);
|
|
79078
|
-
if (!
|
|
78865
|
+
if (!statSync21(real).isFile()) return { status: 404 };
|
|
79079
78866
|
} catch {
|
|
79080
78867
|
return { status: 404 };
|
|
79081
78868
|
}
|
|
@@ -79200,8 +78987,8 @@ var init_project_icon = __esm({
|
|
|
79200
78987
|
});
|
|
79201
78988
|
|
|
79202
78989
|
// packages/server/src/local-visualization.ts
|
|
79203
|
-
import { readdirSync as readdirSync13, readFileSync as readFileSync31, realpathSync as realpathSync14, statSync as
|
|
79204
|
-
import { join as
|
|
78990
|
+
import { readdirSync as readdirSync13, readFileSync as readFileSync31, realpathSync as realpathSync14, statSync as statSync22 } from "node:fs";
|
|
78991
|
+
import { join as join42, sep as sep5 } from "node:path";
|
|
79205
78992
|
function children(path3, pattern) {
|
|
79206
78993
|
try {
|
|
79207
78994
|
return readdirSync13(path3, { withFileTypes: true }).filter((entry) => entry.isDirectory() && pattern.test(entry.name)).map((entry) => entry.name).sort().reverse();
|
|
@@ -79213,7 +79000,7 @@ function isUnder2(path3, root) {
|
|
|
79213
79000
|
return path3 === root || path3.startsWith(root.endsWith(sep5) ? root : root + sep5);
|
|
79214
79001
|
}
|
|
79215
79002
|
function resolveFragment(projectDir, sessionId, file) {
|
|
79216
|
-
const base =
|
|
79003
|
+
const base = join42(projectDir, ".codex", "visualizations");
|
|
79217
79004
|
let projectReal;
|
|
79218
79005
|
let baseReal;
|
|
79219
79006
|
try {
|
|
@@ -79224,15 +79011,15 @@ function resolveFragment(projectDir, sessionId, file) {
|
|
|
79224
79011
|
}
|
|
79225
79012
|
if (!isUnder2(baseReal, projectReal)) return null;
|
|
79226
79013
|
for (const year of children(base, YEAR_PART)) {
|
|
79227
|
-
const yearDir =
|
|
79014
|
+
const yearDir = join42(base, year);
|
|
79228
79015
|
for (const month of children(yearDir, DATE_PART)) {
|
|
79229
|
-
const monthDir =
|
|
79016
|
+
const monthDir = join42(yearDir, month);
|
|
79230
79017
|
for (const day of children(monthDir, DATE_PART)) {
|
|
79231
|
-
const sessionRoot =
|
|
79232
|
-
const candidate =
|
|
79018
|
+
const sessionRoot = join42(baseReal, year, month, day, sessionId);
|
|
79019
|
+
const candidate = join42(monthDir, day, sessionId, file);
|
|
79233
79020
|
try {
|
|
79234
79021
|
const real = realpathSync14(candidate);
|
|
79235
|
-
if (isUnder2(real, sessionRoot) &&
|
|
79022
|
+
if (isUnder2(real, sessionRoot) && statSync22(real).isFile()) return real;
|
|
79236
79023
|
} catch {
|
|
79237
79024
|
}
|
|
79238
79025
|
}
|
|
@@ -79317,7 +79104,7 @@ function resolveLocalVisualization(projectDir, sessionId, file) {
|
|
|
79317
79104
|
if (!path3) return { status: 404 };
|
|
79318
79105
|
let fragment;
|
|
79319
79106
|
try {
|
|
79320
|
-
const size =
|
|
79107
|
+
const size = statSync22(path3).size;
|
|
79321
79108
|
if (size > MAX_FRAGMENT_BYTES) return { status: 413 };
|
|
79322
79109
|
fragment = readFileSync31(path3, "utf8");
|
|
79323
79110
|
} catch {
|
|
@@ -79362,7 +79149,7 @@ var init_local_visualization = __esm({
|
|
|
79362
79149
|
|
|
79363
79150
|
// packages/server/src/app.ts
|
|
79364
79151
|
import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync14 } from "node:fs";
|
|
79365
|
-
import { join as
|
|
79152
|
+
import { join as join43 } from "node:path";
|
|
79366
79153
|
import { randomUUID as randomUUID18 } from "node:crypto";
|
|
79367
79154
|
function createApp(ctx, options = {}) {
|
|
79368
79155
|
const app = new Hono2();
|
|
@@ -79466,10 +79253,10 @@ function createApp(ctx, options = {}) {
|
|
|
79466
79253
|
if (typeof body.data !== "string" || body.data.length > ATTACHMENT_MAX_BASE64_CHARS) return c.json({ error: "bad payload" }, 400);
|
|
79467
79254
|
const ext = `.${attachmentExtension(name)}`;
|
|
79468
79255
|
const buf = Buffer.from(body.data, "base64");
|
|
79469
|
-
const dir =
|
|
79256
|
+
const dir = join43(ctx.project.stateDir, "attachments");
|
|
79470
79257
|
mkdirSync20(dir, { recursive: true });
|
|
79471
79258
|
const base = name.replace(/\.[^.]+$/, "").replace(/[^a-zA-Z0-9_-]+/g, "-").slice(0, 40) || "file";
|
|
79472
|
-
const path3 =
|
|
79259
|
+
const path3 = join43(dir, `${Date.now()}-${randomUUID18().slice(0, 8)}-${base}${ext}`);
|
|
79473
79260
|
writeFileSync14(path3, buf);
|
|
79474
79261
|
return c.json({ path: path3 });
|
|
79475
79262
|
});
|
|
@@ -79527,407 +79314,6 @@ var init_app = __esm({
|
|
|
79527
79314
|
}
|
|
79528
79315
|
});
|
|
79529
79316
|
|
|
79530
|
-
// packages/server/src/terminal.ts
|
|
79531
|
-
import "node-pty";
|
|
79532
|
-
function parseTermClientMsg(raw2) {
|
|
79533
|
-
let value;
|
|
79534
|
-
try {
|
|
79535
|
-
value = JSON.parse(raw2);
|
|
79536
|
-
} catch {
|
|
79537
|
-
return null;
|
|
79538
|
-
}
|
|
79539
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
79540
|
-
const msg = value;
|
|
79541
|
-
if (msg.t === "input") {
|
|
79542
|
-
if (Object.keys(msg).length !== 2 || !Object.prototype.hasOwnProperty.call(msg, "d") || typeof msg.d !== "string" || Buffer.byteLength(msg.d, "utf8") > TERMINAL_MAX_INPUT_BYTES) return null;
|
|
79543
|
-
return { t: "input", d: msg.d };
|
|
79544
|
-
}
|
|
79545
|
-
if (msg.t === "resize") {
|
|
79546
|
-
if (Object.keys(msg).length !== 3 || !Object.prototype.hasOwnProperty.call(msg, "cols") || !Object.prototype.hasOwnProperty.call(msg, "rows")) return null;
|
|
79547
|
-
const cols = msg.cols;
|
|
79548
|
-
const rows = msg.rows;
|
|
79549
|
-
if (!Number.isFinite(cols) || !Number.isInteger(cols) || !Number.isFinite(rows) || !Number.isInteger(rows) || cols < 1 || rows < 1 || cols > TERMINAL_MAX_COLS || rows > TERMINAL_MAX_ROWS) {
|
|
79550
|
-
return null;
|
|
79551
|
-
}
|
|
79552
|
-
return { t: "resize", cols, rows };
|
|
79553
|
-
}
|
|
79554
|
-
return null;
|
|
79555
|
-
}
|
|
79556
|
-
function parseTermSlug(url) {
|
|
79557
|
-
const path3 = (url ?? "").split("?")[0];
|
|
79558
|
-
const m = path3.match(TERM_PATH);
|
|
79559
|
-
if (!m) return null;
|
|
79560
|
-
const parsed = ThreadSlug.safeParse(m[1]);
|
|
79561
|
-
return parsed.success ? parsed.data : null;
|
|
79562
|
-
}
|
|
79563
|
-
function adaptLoginSource(attachment) {
|
|
79564
|
-
return {
|
|
79565
|
-
onData(listener) {
|
|
79566
|
-
const unsubscribe = attachment.onData(listener);
|
|
79567
|
-
const replay = attachment.replay();
|
|
79568
|
-
if (replay) queueMicrotask(() => listener(replay));
|
|
79569
|
-
return { dispose: unsubscribe };
|
|
79570
|
-
},
|
|
79571
|
-
onExit(listener) {
|
|
79572
|
-
const unsubscribe = attachment.onExit(() => listener({ exitCode: 0 }));
|
|
79573
|
-
return { dispose: unsubscribe };
|
|
79574
|
-
},
|
|
79575
|
-
resize: (cols, rows) => attachment.resize(cols, rows),
|
|
79576
|
-
write: (data) => attachment.write(data),
|
|
79577
|
-
// Deliberately does NOT kill the login pty: closing one tab must not abandon an OAuth flow another
|
|
79578
|
-
// tab is still driving, and the utility owns that lifecycle (cancel / success / timeout / stop).
|
|
79579
|
-
kill: () => attachment.close()
|
|
79580
|
-
};
|
|
79581
|
-
}
|
|
79582
|
-
function createTerminalServer(deps = {}) {
|
|
79583
|
-
const wss = new import_websocket_server.default({ noServer: true, maxPayload: TERMINAL_MAX_MESSAGE_BYTES });
|
|
79584
|
-
let closing = false;
|
|
79585
|
-
let closePromise = null;
|
|
79586
|
-
const configuredInteger = (value, fallback, minimum = 0) => value !== void 0 && Number.isSafeInteger(value) && value >= minimum ? value : fallback;
|
|
79587
|
-
const maxOutputBufferBytes = configuredInteger(
|
|
79588
|
-
deps.maxOutputBufferBytes,
|
|
79589
|
-
TERMINAL_MAX_OUTPUT_BUFFER_BYTES
|
|
79590
|
-
);
|
|
79591
|
-
const maxViewers = configuredInteger(deps.maxViewers, TERMINAL_MAX_VIEWERS);
|
|
79592
|
-
const maxViewersPerSlug = configuredInteger(
|
|
79593
|
-
deps.maxViewersPerSlug,
|
|
79594
|
-
TERMINAL_MAX_VIEWERS_PER_SLUG
|
|
79595
|
-
);
|
|
79596
|
-
const inputRateWindowMs = configuredInteger(
|
|
79597
|
-
deps.inputRateWindowMs,
|
|
79598
|
-
TERMINAL_INPUT_RATE_WINDOW_MS,
|
|
79599
|
-
1
|
|
79600
|
-
);
|
|
79601
|
-
const maxInputFramesPerWindow = configuredInteger(
|
|
79602
|
-
deps.maxInputFramesPerWindow,
|
|
79603
|
-
TERMINAL_MAX_INPUT_FRAMES_PER_WINDOW
|
|
79604
|
-
);
|
|
79605
|
-
const maxInputBytesPerWindow = configuredInteger(
|
|
79606
|
-
deps.maxInputBytesPerWindow,
|
|
79607
|
-
TERMINAL_MAX_INPUT_BYTES_PER_WINDOW
|
|
79608
|
-
);
|
|
79609
|
-
const closeGraceMs = configuredInteger(deps.closeGraceMs, TERMINAL_CLOSE_GRACE_MS);
|
|
79610
|
-
const shutdownGraceMs = configuredInteger(
|
|
79611
|
-
deps.shutdownGraceMs,
|
|
79612
|
-
TERMINAL_SHUTDOWN_GRACE_MS
|
|
79613
|
-
);
|
|
79614
|
-
const now = deps.now ?? Date.now;
|
|
79615
|
-
const terminateSocket = deps.terminateSocket ?? ((ws2) => ws2.terminate());
|
|
79616
|
-
let viewerCount = 0;
|
|
79617
|
-
const viewersPerSlug = /* @__PURE__ */ new Map();
|
|
79618
|
-
const viewers = /* @__PURE__ */ new Set();
|
|
79619
|
-
const pendingUpgrades = /* @__PURE__ */ new Set();
|
|
79620
|
-
const reserveViewer = (slug) => {
|
|
79621
|
-
const slugCount = viewersPerSlug.get(slug) ?? 0;
|
|
79622
|
-
if (viewerCount >= maxViewers || slugCount >= maxViewersPerSlug) return null;
|
|
79623
|
-
viewerCount += 1;
|
|
79624
|
-
viewersPerSlug.set(slug, slugCount + 1);
|
|
79625
|
-
let released = false;
|
|
79626
|
-
return {
|
|
79627
|
-
slug,
|
|
79628
|
-
release() {
|
|
79629
|
-
if (released) return;
|
|
79630
|
-
released = true;
|
|
79631
|
-
viewerCount -= 1;
|
|
79632
|
-
const nextSlugCount = (viewersPerSlug.get(slug) ?? 1) - 1;
|
|
79633
|
-
if (nextSlugCount <= 0) viewersPerSlug.delete(slug);
|
|
79634
|
-
else viewersPerSlug.set(slug, nextSlugCount);
|
|
79635
|
-
}
|
|
79636
|
-
};
|
|
79637
|
-
};
|
|
79638
|
-
const rawDataBuffer = (raw2) => {
|
|
79639
|
-
if (Buffer.isBuffer(raw2)) return raw2;
|
|
79640
|
-
if (Array.isArray(raw2)) return Buffer.concat(raw2);
|
|
79641
|
-
return Buffer.from(raw2);
|
|
79642
|
-
};
|
|
79643
|
-
wss.on("error", () => {
|
|
79644
|
-
});
|
|
79645
|
-
const acceptViewer = (ws2, slug, reservation) => {
|
|
79646
|
-
let term;
|
|
79647
|
-
let cleaned = false;
|
|
79648
|
-
let closeStarted = false;
|
|
79649
|
-
let terminated = false;
|
|
79650
|
-
let forceCloseTimer;
|
|
79651
|
-
let dataSubscription;
|
|
79652
|
-
let exitSubscription;
|
|
79653
|
-
const inputWindow = [];
|
|
79654
|
-
let inputWindowBytes = 0;
|
|
79655
|
-
const cleanup = () => {
|
|
79656
|
-
if (cleaned) return;
|
|
79657
|
-
cleaned = true;
|
|
79658
|
-
reservation.release();
|
|
79659
|
-
const ownedDataSubscription = dataSubscription;
|
|
79660
|
-
dataSubscription = void 0;
|
|
79661
|
-
const ownedExitSubscription = exitSubscription;
|
|
79662
|
-
exitSubscription = void 0;
|
|
79663
|
-
try {
|
|
79664
|
-
ownedDataSubscription?.dispose();
|
|
79665
|
-
} catch {
|
|
79666
|
-
}
|
|
79667
|
-
try {
|
|
79668
|
-
ownedExitSubscription?.dispose();
|
|
79669
|
-
} catch {
|
|
79670
|
-
}
|
|
79671
|
-
const ownedTerm = term;
|
|
79672
|
-
term = void 0;
|
|
79673
|
-
if (ownedTerm) {
|
|
79674
|
-
try {
|
|
79675
|
-
ownedTerm.kill();
|
|
79676
|
-
} catch {
|
|
79677
|
-
}
|
|
79678
|
-
}
|
|
79679
|
-
};
|
|
79680
|
-
let viewer;
|
|
79681
|
-
const forceTerminate = () => {
|
|
79682
|
-
if (terminated) return;
|
|
79683
|
-
terminated = true;
|
|
79684
|
-
cleanup();
|
|
79685
|
-
try {
|
|
79686
|
-
terminateSocket(ws2);
|
|
79687
|
-
} catch {
|
|
79688
|
-
}
|
|
79689
|
-
viewers.delete(viewer);
|
|
79690
|
-
};
|
|
79691
|
-
const beginClose = (code, reason) => {
|
|
79692
|
-
if (closeStarted) return;
|
|
79693
|
-
closeStarted = true;
|
|
79694
|
-
cleanup();
|
|
79695
|
-
if (ws2.readyState === import_websocket.default.CLOSED) {
|
|
79696
|
-
viewers.delete(viewer);
|
|
79697
|
-
return;
|
|
79698
|
-
}
|
|
79699
|
-
forceCloseTimer = setTimeout(forceTerminate, closeGraceMs);
|
|
79700
|
-
forceCloseTimer.unref?.();
|
|
79701
|
-
try {
|
|
79702
|
-
if (ws2.readyState === import_websocket.default.OPEN || ws2.readyState === import_websocket.default.CONNECTING) {
|
|
79703
|
-
ws2.close(code, reason);
|
|
79704
|
-
}
|
|
79705
|
-
} catch {
|
|
79706
|
-
forceTerminate();
|
|
79707
|
-
}
|
|
79708
|
-
};
|
|
79709
|
-
viewer = {
|
|
79710
|
-
cleanup,
|
|
79711
|
-
shutdown() {
|
|
79712
|
-
closeStarted = true;
|
|
79713
|
-
cleanup();
|
|
79714
|
-
forceTerminate();
|
|
79715
|
-
}
|
|
79716
|
-
};
|
|
79717
|
-
viewers.add(viewer);
|
|
79718
|
-
ws2.once("close", () => {
|
|
79719
|
-
clearTimeout(forceCloseTimer);
|
|
79720
|
-
cleanup();
|
|
79721
|
-
viewers.delete(viewer);
|
|
79722
|
-
});
|
|
79723
|
-
ws2.on("error", () => beginClose(1011, "terminal transport failed"));
|
|
79724
|
-
if (closing) {
|
|
79725
|
-
viewer.shutdown();
|
|
79726
|
-
return;
|
|
79727
|
-
}
|
|
79728
|
-
let loginAttachment = null;
|
|
79729
|
-
try {
|
|
79730
|
-
loginAttachment = deps.resolveLogin?.(slug) ?? null;
|
|
79731
|
-
} catch {
|
|
79732
|
-
beginClose(1011, "terminal unavailable");
|
|
79733
|
-
return;
|
|
79734
|
-
}
|
|
79735
|
-
if (!loginAttachment) {
|
|
79736
|
-
beginClose(1008, "terminal attach denied");
|
|
79737
|
-
return;
|
|
79738
|
-
}
|
|
79739
|
-
try {
|
|
79740
|
-
term = adaptLoginSource(loginAttachment);
|
|
79741
|
-
} catch {
|
|
79742
|
-
beginClose(1011, "terminal unavailable");
|
|
79743
|
-
return;
|
|
79744
|
-
}
|
|
79745
|
-
const acceptInputSample = (bytes) => {
|
|
79746
|
-
const at2 = now();
|
|
79747
|
-
const cutoff = at2 - inputRateWindowMs;
|
|
79748
|
-
while (inputWindow.length > 0 && inputWindow[0].at <= cutoff) {
|
|
79749
|
-
inputWindowBytes -= inputWindow.shift().bytes;
|
|
79750
|
-
}
|
|
79751
|
-
if (inputWindow.length + 1 > maxInputFramesPerWindow || inputWindowBytes + bytes > maxInputBytesPerWindow) {
|
|
79752
|
-
return false;
|
|
79753
|
-
}
|
|
79754
|
-
inputWindow.push({ at: at2, bytes });
|
|
79755
|
-
inputWindowBytes += bytes;
|
|
79756
|
-
return true;
|
|
79757
|
-
};
|
|
79758
|
-
try {
|
|
79759
|
-
dataSubscription = term.onData((d) => {
|
|
79760
|
-
if (cleaned || ws2.readyState !== import_websocket.default.OPEN) return;
|
|
79761
|
-
if (ws2.bufferedAmount + Buffer.byteLength(d, "utf8") > maxOutputBufferBytes) {
|
|
79762
|
-
beginClose(1013, "terminal viewer overloaded");
|
|
79763
|
-
return;
|
|
79764
|
-
}
|
|
79765
|
-
try {
|
|
79766
|
-
ws2.send(d, (error) => {
|
|
79767
|
-
if (error) beginClose(1011, "terminal transport failed");
|
|
79768
|
-
});
|
|
79769
|
-
} catch {
|
|
79770
|
-
beginClose(1011, "terminal transport failed");
|
|
79771
|
-
}
|
|
79772
|
-
});
|
|
79773
|
-
exitSubscription = term.onExit(({ exitCode }) => {
|
|
79774
|
-
if (!cleaned) beginClose(1e3, `pty exit ${exitCode}`);
|
|
79775
|
-
});
|
|
79776
|
-
} catch {
|
|
79777
|
-
beginClose(1011, "terminal unavailable");
|
|
79778
|
-
return;
|
|
79779
|
-
}
|
|
79780
|
-
ws2.on("message", (raw2, isBinary) => {
|
|
79781
|
-
if (cleaned) return;
|
|
79782
|
-
if (isBinary) {
|
|
79783
|
-
beginClose(1003, "terminal text frames required");
|
|
79784
|
-
return;
|
|
79785
|
-
}
|
|
79786
|
-
const payload = rawDataBuffer(raw2);
|
|
79787
|
-
if (!acceptInputSample(payload.byteLength)) {
|
|
79788
|
-
beginClose(1013, "terminal input rate limited");
|
|
79789
|
-
return;
|
|
79790
|
-
}
|
|
79791
|
-
const msg = parseTermClientMsg(payload.toString("utf8"));
|
|
79792
|
-
if (!msg) {
|
|
79793
|
-
beginClose(1008, "invalid terminal message");
|
|
79794
|
-
return;
|
|
79795
|
-
}
|
|
79796
|
-
const activeTerm = term;
|
|
79797
|
-
if (!activeTerm) return;
|
|
79798
|
-
try {
|
|
79799
|
-
if (msg.t === "input") activeTerm.write(msg.d);
|
|
79800
|
-
else {
|
|
79801
|
-
activeTerm.resize(msg.cols, msg.rows);
|
|
79802
|
-
}
|
|
79803
|
-
} catch {
|
|
79804
|
-
beginClose(1011, "terminal unavailable");
|
|
79805
|
-
}
|
|
79806
|
-
});
|
|
79807
|
-
};
|
|
79808
|
-
return {
|
|
79809
|
-
handleUpgrade(req, socket, head) {
|
|
79810
|
-
const slug = parseTermSlug(req.url);
|
|
79811
|
-
if (slug === null) return false;
|
|
79812
|
-
if (closing) {
|
|
79813
|
-
rejectWebSocketUpgrade(socket, 503, "Service Unavailable");
|
|
79814
|
-
return true;
|
|
79815
|
-
}
|
|
79816
|
-
if (!isTrustedLocalWebSocketRequest(req)) {
|
|
79817
|
-
rejectWebSocketUpgrade(socket);
|
|
79818
|
-
return true;
|
|
79819
|
-
}
|
|
79820
|
-
const reservation = reserveViewer(slug);
|
|
79821
|
-
if (!reservation) {
|
|
79822
|
-
rejectWebSocketUpgrade(socket, 429, "Too Many Requests");
|
|
79823
|
-
return true;
|
|
79824
|
-
}
|
|
79825
|
-
let finished = false;
|
|
79826
|
-
const finishPending = () => {
|
|
79827
|
-
if (finished) return false;
|
|
79828
|
-
finished = true;
|
|
79829
|
-
pendingUpgrades.delete(pending);
|
|
79830
|
-
socket.removeListener("close", abandonPending);
|
|
79831
|
-
socket.removeListener("error", abandonPending);
|
|
79832
|
-
return true;
|
|
79833
|
-
};
|
|
79834
|
-
const abandonPending = () => {
|
|
79835
|
-
if (finishPending()) reservation.release();
|
|
79836
|
-
};
|
|
79837
|
-
const pending = {
|
|
79838
|
-
abort(status, reason) {
|
|
79839
|
-
if (!finishPending()) return;
|
|
79840
|
-
reservation.release();
|
|
79841
|
-
if (status) rejectWebSocketUpgrade(socket, status, reason);
|
|
79842
|
-
else {
|
|
79843
|
-
try {
|
|
79844
|
-
socket.destroy();
|
|
79845
|
-
} catch {
|
|
79846
|
-
}
|
|
79847
|
-
}
|
|
79848
|
-
}
|
|
79849
|
-
};
|
|
79850
|
-
pendingUpgrades.add(pending);
|
|
79851
|
-
socket.once("close", abandonPending);
|
|
79852
|
-
socket.once("error", abandonPending);
|
|
79853
|
-
try {
|
|
79854
|
-
wss.handleUpgrade(req, socket, head, (ws2) => {
|
|
79855
|
-
if (!finishPending()) {
|
|
79856
|
-
try {
|
|
79857
|
-
ws2.terminate();
|
|
79858
|
-
} catch {
|
|
79859
|
-
}
|
|
79860
|
-
return;
|
|
79861
|
-
}
|
|
79862
|
-
try {
|
|
79863
|
-
acceptViewer(ws2, slug, reservation);
|
|
79864
|
-
} catch {
|
|
79865
|
-
reservation.release();
|
|
79866
|
-
try {
|
|
79867
|
-
ws2.terminate();
|
|
79868
|
-
} catch {
|
|
79869
|
-
}
|
|
79870
|
-
}
|
|
79871
|
-
});
|
|
79872
|
-
} catch {
|
|
79873
|
-
pending.abort(400, "Bad Request");
|
|
79874
|
-
}
|
|
79875
|
-
return true;
|
|
79876
|
-
},
|
|
79877
|
-
close() {
|
|
79878
|
-
if (closePromise) return closePromise;
|
|
79879
|
-
closing = true;
|
|
79880
|
-
closePromise = (async () => {
|
|
79881
|
-
for (const pending of [...pendingUpgrades]) {
|
|
79882
|
-
pending.abort(503, "Service Unavailable");
|
|
79883
|
-
}
|
|
79884
|
-
for (const viewer of [...viewers]) viewer.shutdown();
|
|
79885
|
-
let drainTimer;
|
|
79886
|
-
const boundedServerDrain = new Promise((resolve13) => {
|
|
79887
|
-
let resolved2 = false;
|
|
79888
|
-
const finish = () => {
|
|
79889
|
-
if (resolved2) return;
|
|
79890
|
-
resolved2 = true;
|
|
79891
|
-
clearTimeout(drainTimer);
|
|
79892
|
-
resolve13();
|
|
79893
|
-
};
|
|
79894
|
-
drainTimer = setTimeout(finish, shutdownGraceMs);
|
|
79895
|
-
try {
|
|
79896
|
-
wss.close(finish);
|
|
79897
|
-
} catch {
|
|
79898
|
-
finish();
|
|
79899
|
-
}
|
|
79900
|
-
});
|
|
79901
|
-
await boundedServerDrain;
|
|
79902
|
-
viewers.clear();
|
|
79903
|
-
})();
|
|
79904
|
-
return closePromise;
|
|
79905
|
-
}
|
|
79906
|
-
};
|
|
79907
|
-
}
|
|
79908
|
-
var TERM_PATH, TERMINAL_MAX_INPUT_BYTES, TERMINAL_MAX_MESSAGE_BYTES, TERMINAL_MAX_COLS, TERMINAL_MAX_ROWS, TERMINAL_MAX_OUTPUT_BUFFER_BYTES, TERMINAL_MAX_VIEWERS, TERMINAL_MAX_VIEWERS_PER_SLUG, TERMINAL_INPUT_RATE_WINDOW_MS, TERMINAL_MAX_INPUT_FRAMES_PER_WINDOW, TERMINAL_MAX_INPUT_BYTES_PER_WINDOW, TERMINAL_CLOSE_GRACE_MS, TERMINAL_SHUTDOWN_GRACE_MS;
|
|
79909
|
-
var init_terminal = __esm({
|
|
79910
|
-
"packages/server/src/terminal.ts"() {
|
|
79911
|
-
"use strict";
|
|
79912
|
-
init_wrapper();
|
|
79913
|
-
init_src();
|
|
79914
|
-
init_local_origin();
|
|
79915
|
-
TERM_PATH = new RegExp(`^${FRIZZ_ROUTE_PREFIX}/term/([^/?]+)$`);
|
|
79916
|
-
TERMINAL_MAX_INPUT_BYTES = 1048576;
|
|
79917
|
-
TERMINAL_MAX_MESSAGE_BYTES = TERMINAL_MAX_INPUT_BYTES + 1024;
|
|
79918
|
-
TERMINAL_MAX_COLS = 1e3;
|
|
79919
|
-
TERMINAL_MAX_ROWS = 1e3;
|
|
79920
|
-
TERMINAL_MAX_OUTPUT_BUFFER_BYTES = 4 * 1024 * 1024;
|
|
79921
|
-
TERMINAL_MAX_VIEWERS = 32;
|
|
79922
|
-
TERMINAL_MAX_VIEWERS_PER_SLUG = 8;
|
|
79923
|
-
TERMINAL_INPUT_RATE_WINDOW_MS = 1e3;
|
|
79924
|
-
TERMINAL_MAX_INPUT_FRAMES_PER_WINDOW = 120;
|
|
79925
|
-
TERMINAL_MAX_INPUT_BYTES_PER_WINDOW = 2 * TERMINAL_MAX_MESSAGE_BYTES;
|
|
79926
|
-
TERMINAL_CLOSE_GRACE_MS = 250;
|
|
79927
|
-
TERMINAL_SHUTDOWN_GRACE_MS = 500;
|
|
79928
|
-
}
|
|
79929
|
-
});
|
|
79930
|
-
|
|
79931
79317
|
// packages/server/src/app-socket.ts
|
|
79932
79318
|
import { createHash as createHash15 } from "node:crypto";
|
|
79933
79319
|
function isWsPath(url) {
|
|
@@ -80790,11 +80176,11 @@ var init_app_socket = __esm({
|
|
|
80790
80176
|
});
|
|
80791
80177
|
|
|
80792
80178
|
// packages/server/src/local-file-watch.ts
|
|
80793
|
-
import { statSync as
|
|
80794
|
-
import { basename as basename11, dirname as
|
|
80179
|
+
import { statSync as statSync23, watch } from "node:fs";
|
|
80180
|
+
import { basename as basename11, dirname as dirname20 } from "node:path";
|
|
80795
80181
|
function stampOf(path3) {
|
|
80796
80182
|
try {
|
|
80797
|
-
const s =
|
|
80183
|
+
const s = statSync23(path3, { bigint: true });
|
|
80798
80184
|
return `${s.ino}:${s.size}:${s.mtimeNs}`;
|
|
80799
80185
|
} catch {
|
|
80800
80186
|
return "gone";
|
|
@@ -80814,7 +80200,7 @@ function watchLocalFile(path3, onChange) {
|
|
|
80814
80200
|
let entry = entries.get(path3);
|
|
80815
80201
|
if (!entry) {
|
|
80816
80202
|
const name = basename11(path3);
|
|
80817
|
-
const watcher2 = watch(
|
|
80203
|
+
const watcher2 = watch(dirname20(path3), { persistent: false }, (_event, changed) => {
|
|
80818
80204
|
if (changed !== null && changed !== void 0 && changed.toString() !== name) return;
|
|
80819
80205
|
const current = entries.get(path3);
|
|
80820
80206
|
if (!current) return;
|
|
@@ -80851,9 +80237,9 @@ var init_local_file_watch = __esm({
|
|
|
80851
80237
|
|
|
80852
80238
|
// packages/server/src/boot-progress.ts
|
|
80853
80239
|
import { mkdirSync as mkdirSync21, readFileSync as readFileSync32, renameSync as renameSync11, rmSync as rmSync12, writeFileSync as writeFileSync15 } from "node:fs";
|
|
80854
|
-
import { basename as basename12, dirname as
|
|
80240
|
+
import { basename as basename12, dirname as dirname21, join as join44 } from "node:path";
|
|
80855
80241
|
function bootProgressPath(stateDir) {
|
|
80856
|
-
return
|
|
80242
|
+
return join44(stateDir, BOOT_PROGRESS_NAME);
|
|
80857
80243
|
}
|
|
80858
80244
|
function createBootProgressPublisher(stateDir, minIntervalMs = 200) {
|
|
80859
80245
|
if (!stateDir) {
|
|
@@ -80873,8 +80259,8 @@ function createBootProgressPublisher(stateDir, minIntervalMs = 200) {
|
|
|
80873
80259
|
lastAt = now;
|
|
80874
80260
|
step++;
|
|
80875
80261
|
try {
|
|
80876
|
-
mkdirSync21(
|
|
80877
|
-
const temp =
|
|
80262
|
+
mkdirSync21(dirname21(path3), { recursive: true, mode: 448 });
|
|
80263
|
+
const temp = join44(dirname21(path3), `.${basename12(path3)}.${process.pid}.tmp`);
|
|
80878
80264
|
writeFileSync15(temp, `${JSON.stringify({ pid: process.pid, step, phase, at: new Date(now).toISOString() })}
|
|
80879
80265
|
`, "utf8");
|
|
80880
80266
|
renameSync11(temp, path3);
|
|
@@ -80901,12 +80287,12 @@ var init_boot_progress = __esm({
|
|
|
80901
80287
|
|
|
80902
80288
|
// packages/server/src/runtime-lease.ts
|
|
80903
80289
|
import { existsSync as existsSync19, mkdirSync as mkdirSync22, readdirSync as readdirSync14, readFileSync as readFileSync33, unlinkSync as unlinkSync8, writeFileSync as writeFileSync16 } from "node:fs";
|
|
80904
|
-
import { dirname as
|
|
80290
|
+
import { dirname as dirname22, join as join45 } from "node:path";
|
|
80905
80291
|
function runtimeVersionDir(bin) {
|
|
80906
|
-
let dir =
|
|
80292
|
+
let dir = dirname22(bin);
|
|
80907
80293
|
for (let step = 0; step < MAX_ASCENT; step++) {
|
|
80908
|
-
if (existsSync19(
|
|
80909
|
-
const parent =
|
|
80294
|
+
if (existsSync19(join45(dir, PROVISIONED_MARKER))) return dir;
|
|
80295
|
+
const parent = dirname22(dir);
|
|
80910
80296
|
if (parent === dir) return void 0;
|
|
80911
80297
|
dir = parent;
|
|
80912
80298
|
}
|
|
@@ -80924,9 +80310,9 @@ function leaseRuntime(bin, role) {
|
|
|
80924
80310
|
const versionDir = runtimeVersionDir(bin);
|
|
80925
80311
|
if (!versionDir) return () => {
|
|
80926
80312
|
};
|
|
80927
|
-
const path3 =
|
|
80313
|
+
const path3 = join45(versionDir, LEASES_DIR, `${process.pid}.json`);
|
|
80928
80314
|
try {
|
|
80929
|
-
mkdirSync22(
|
|
80315
|
+
mkdirSync22(dirname22(path3), { recursive: true });
|
|
80930
80316
|
const lease = { pid: process.pid, role, bin, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
80931
80317
|
writeFileSync16(path3, JSON.stringify(lease));
|
|
80932
80318
|
} catch {
|
|
@@ -80941,7 +80327,7 @@ function leaseRuntime(bin, role) {
|
|
|
80941
80327
|
};
|
|
80942
80328
|
}
|
|
80943
80329
|
function liveRuntimeLeases(versionDir) {
|
|
80944
|
-
const dir =
|
|
80330
|
+
const dir = join45(versionDir, LEASES_DIR);
|
|
80945
80331
|
let names;
|
|
80946
80332
|
try {
|
|
80947
80333
|
names = readdirSync14(dir);
|
|
@@ -80951,7 +80337,7 @@ function liveRuntimeLeases(versionDir) {
|
|
|
80951
80337
|
const live = [];
|
|
80952
80338
|
for (const name of names) {
|
|
80953
80339
|
if (!name.endsWith(".json")) continue;
|
|
80954
|
-
const path3 =
|
|
80340
|
+
const path3 = join45(dir, name);
|
|
80955
80341
|
let lease;
|
|
80956
80342
|
try {
|
|
80957
80343
|
lease = JSON.parse(readFileSync33(path3, "utf8"));
|
|
@@ -80983,7 +80369,7 @@ var init_runtime_lease = __esm({
|
|
|
80983
80369
|
// packages/server/src/runtimes.ts
|
|
80984
80370
|
import { createHash as createHash16 } from "node:crypto";
|
|
80985
80371
|
import {
|
|
80986
|
-
chmodSync
|
|
80372
|
+
chmodSync,
|
|
80987
80373
|
closeSync as closeSync17,
|
|
80988
80374
|
existsSync as existsSync20,
|
|
80989
80375
|
mkdirSync as mkdirSync23,
|
|
@@ -80992,18 +80378,18 @@ import {
|
|
|
80992
80378
|
readdirSync as readdirSync15,
|
|
80993
80379
|
renameSync as renameSync12,
|
|
80994
80380
|
rmSync as rmSync13,
|
|
80995
|
-
statSync as
|
|
80381
|
+
statSync as statSync24,
|
|
80996
80382
|
writeFileSync as writeFileSync17,
|
|
80997
80383
|
writeSync as writeSync2
|
|
80998
80384
|
} from "node:fs";
|
|
80999
|
-
import { dirname as
|
|
80385
|
+
import { dirname as dirname23, isAbsolute as isAbsolute10, join as join46, normalize, relative as relative3, sep as sep6 } from "node:path";
|
|
81000
80386
|
import { Readable, Transform, Writable as Writable4 } from "node:stream";
|
|
81001
80387
|
import { pipeline } from "node:stream/promises";
|
|
81002
80388
|
import { createGunzip } from "node:zlib";
|
|
81003
80389
|
function runtimesRoot(env = process.env) {
|
|
81004
80390
|
const override = env[RUNTIMES_DIR_ENV];
|
|
81005
80391
|
if (override && isAbsolute10(override)) return override;
|
|
81006
|
-
return
|
|
80392
|
+
return join46(frizzRoots().cache, "runtimes");
|
|
81007
80393
|
}
|
|
81008
80394
|
function isMusl() {
|
|
81009
80395
|
if (process.platform !== "linux") return false;
|
|
@@ -81020,15 +80406,15 @@ function runtimeCoordinates(backend, platform3 = process.platform, arch = proces
|
|
|
81020
80406
|
return { pkg: "@openai/codex", packageVersion: `${CODEX_VERSION}-${platform3}-${arch}`, label: CODEX_VERSION, binary: `codex${exe}` };
|
|
81021
80407
|
}
|
|
81022
80408
|
function provisionedBinary(backend, root, label) {
|
|
81023
|
-
const dir =
|
|
80409
|
+
const dir = join46(root, backend, label);
|
|
81024
80410
|
let marker;
|
|
81025
80411
|
try {
|
|
81026
|
-
marker = JSON.parse(readFileSync34(
|
|
80412
|
+
marker = JSON.parse(readFileSync34(join46(dir, MARKER), "utf8"));
|
|
81027
80413
|
} catch {
|
|
81028
80414
|
return void 0;
|
|
81029
80415
|
}
|
|
81030
80416
|
if (typeof marker.binary !== "string" || marker.label !== label) return void 0;
|
|
81031
|
-
const bin =
|
|
80417
|
+
const bin = join46(dir, marker.binary);
|
|
81032
80418
|
return existsSync20(bin) ? bin : void 0;
|
|
81033
80419
|
}
|
|
81034
80420
|
function octal(buffer, offset, length) {
|
|
@@ -81043,17 +80429,17 @@ function safeEntryPath(dest, name) {
|
|
|
81043
80429
|
if (parts.length < 2) return void 0;
|
|
81044
80430
|
const rel = normalize(parts.slice(1).join(sep6));
|
|
81045
80431
|
if (isAbsolute10(rel) || rel === ".." || rel.startsWith(`..${sep6}`)) return void 0;
|
|
81046
|
-
const full =
|
|
80432
|
+
const full = join46(dest, rel);
|
|
81047
80433
|
const back = relative3(dest, full);
|
|
81048
80434
|
if (back.startsWith("..") || isAbsolute10(back)) return void 0;
|
|
81049
80435
|
return full;
|
|
81050
80436
|
}
|
|
81051
80437
|
function locateBinary(dir, backend, binary) {
|
|
81052
80438
|
if (backend === "claude") {
|
|
81053
|
-
const direct =
|
|
80439
|
+
const direct = join46(dir, binary);
|
|
81054
80440
|
return existsSync20(direct) ? direct : void 0;
|
|
81055
80441
|
}
|
|
81056
|
-
const vendor =
|
|
80442
|
+
const vendor = join46(dir, "vendor");
|
|
81057
80443
|
let triples;
|
|
81058
80444
|
try {
|
|
81059
80445
|
triples = readdirSync15(vendor);
|
|
@@ -81061,7 +80447,7 @@ function locateBinary(dir, backend, binary) {
|
|
|
81061
80447
|
return void 0;
|
|
81062
80448
|
}
|
|
81063
80449
|
for (const triple of triples) {
|
|
81064
|
-
const candidate =
|
|
80450
|
+
const candidate = join46(vendor, triple, "bin", binary);
|
|
81065
80451
|
if (existsSync20(candidate)) return candidate;
|
|
81066
80452
|
}
|
|
81067
80453
|
return void 0;
|
|
@@ -81077,9 +80463,9 @@ async function provisionRuntime(backend, options) {
|
|
|
81077
80463
|
const registry = options.registry ?? REGISTRY;
|
|
81078
80464
|
const progress = options.onProgress ?? (() => {
|
|
81079
80465
|
});
|
|
81080
|
-
const backendDir =
|
|
81081
|
-
const finalDir =
|
|
81082
|
-
const partial =
|
|
80466
|
+
const backendDir = join46(root, backend);
|
|
80467
|
+
const finalDir = join46(backendDir, coordinates.label);
|
|
80468
|
+
const partial = join46(backendDir, `.partial-${coordinates.label}-${process.pid}`);
|
|
81083
80469
|
mkdirSync23(backendDir, { recursive: true });
|
|
81084
80470
|
rmSync13(partial, { recursive: true, force: true });
|
|
81085
80471
|
mkdirSync23(partial);
|
|
@@ -81116,7 +80502,7 @@ async function provisionRuntime(backend, options) {
|
|
|
81116
80502
|
if (digest !== integrity) throw new Error(`integrity mismatch for ${tarball}: expected ${integrity}, got ${digest}`);
|
|
81117
80503
|
const bin = locateBinary(partial, backend, coordinates.binary);
|
|
81118
80504
|
if (!bin) throw new Error(`${coordinates.pkg}@${coordinates.packageVersion} unpacked without a ${coordinates.binary} binary`);
|
|
81119
|
-
if (process.platform !== "win32")
|
|
80505
|
+
if (process.platform !== "win32") chmodSync(bin, 493);
|
|
81120
80506
|
const marker = {
|
|
81121
80507
|
backend,
|
|
81122
80508
|
label: coordinates.label,
|
|
@@ -81126,7 +80512,7 @@ async function provisionRuntime(backend, options) {
|
|
|
81126
80512
|
binary: relative3(partial, bin),
|
|
81127
80513
|
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
81128
80514
|
};
|
|
81129
|
-
writeFileSync17(
|
|
80515
|
+
writeFileSync17(join46(partial, MARKER), `${JSON.stringify(marker, null, 2)}
|
|
81130
80516
|
`, "utf8");
|
|
81131
80517
|
const rename2 = options.rename ?? renameSync12;
|
|
81132
80518
|
try {
|
|
@@ -81146,7 +80532,7 @@ async function provisionRuntime(backend, options) {
|
|
|
81146
80532
|
return { bin: theirs, label: coordinates.label, fetched: false };
|
|
81147
80533
|
}
|
|
81148
80534
|
progress("ready");
|
|
81149
|
-
return { bin:
|
|
80535
|
+
return { bin: join46(finalDir, marker.binary), label: coordinates.label, fetched: true };
|
|
81150
80536
|
} catch (err) {
|
|
81151
80537
|
rmSync13(partial, { recursive: true, force: true });
|
|
81152
80538
|
throw err;
|
|
@@ -81154,7 +80540,7 @@ async function provisionRuntime(backend, options) {
|
|
|
81154
80540
|
}
|
|
81155
80541
|
function sweepRuntimes(backend, root, keepLabel, now = Date.now(), deps = {}) {
|
|
81156
80542
|
const rm3 = deps.rm ?? defaultSweepRm;
|
|
81157
|
-
const backendDir =
|
|
80543
|
+
const backendDir = join46(root, backend);
|
|
81158
80544
|
let entries2;
|
|
81159
80545
|
try {
|
|
81160
80546
|
entries2 = readdirSync15(backendDir);
|
|
@@ -81164,10 +80550,10 @@ function sweepRuntimes(backend, root, keepLabel, now = Date.now(), deps = {}) {
|
|
|
81164
80550
|
const sweep = { removed: [], kept: [] };
|
|
81165
80551
|
for (const entry of entries2) {
|
|
81166
80552
|
if (entry === keepLabel) continue;
|
|
81167
|
-
const full =
|
|
80553
|
+
const full = join46(backendDir, entry);
|
|
81168
80554
|
if (entry.startsWith(".partial-")) {
|
|
81169
80555
|
try {
|
|
81170
|
-
if (now -
|
|
80556
|
+
if (now - statSync24(full).mtimeMs < 24 * 60 * 60 * 1e3) continue;
|
|
81171
80557
|
} catch {
|
|
81172
80558
|
continue;
|
|
81173
80559
|
}
|
|
@@ -81355,7 +80741,7 @@ var init_runtimes = __esm({
|
|
|
81355
80741
|
case "7": {
|
|
81356
80742
|
const file = safeEntryPath(this.dest, name);
|
|
81357
80743
|
if (!file) return;
|
|
81358
|
-
mkdirSync23(
|
|
80744
|
+
mkdirSync23(dirname23(file), { recursive: true });
|
|
81359
80745
|
this.fd = openSync18(file, "w", octal(header, 100, 8) & 511 || 420);
|
|
81360
80746
|
this.written.push(file);
|
|
81361
80747
|
return;
|
|
@@ -81447,7 +80833,6 @@ function createTenantMap(options) {
|
|
|
81447
80833
|
if (entry.app !== void 0) await options.closeApp?.(entry.app);
|
|
81448
80834
|
}],
|
|
81449
80835
|
["tailer", cleanups.tailer],
|
|
81450
|
-
["login utility", cleanups.loginUtility],
|
|
81451
80836
|
["subscriptions", cleanups.subscriptions],
|
|
81452
80837
|
["scheduler", cleanups.scheduler],
|
|
81453
80838
|
["board", cleanups.board],
|
|
@@ -81936,18 +81321,18 @@ var init_legacy_project_db = __esm({
|
|
|
81936
81321
|
});
|
|
81937
81322
|
|
|
81938
81323
|
// packages/server/src/frizz-db.ts
|
|
81939
|
-
import { existsSync as existsSync21, mkdirSync as mkdirSync24, readdirSync as readdirSync16, renameSync as renameSync13, statSync as
|
|
81940
|
-
import { basename as basename13, dirname as
|
|
81324
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync24, readdirSync as readdirSync16, renameSync as renameSync13, statSync as statSync25 } from "node:fs";
|
|
81325
|
+
import { basename as basename13, dirname as dirname24, join as join47 } from "node:path";
|
|
81941
81326
|
function frizzDatabaseLocation(options) {
|
|
81942
81327
|
if (options.stateDir !== void 0) {
|
|
81943
|
-
const projectsDir =
|
|
81328
|
+
const projectsDir = dirname24(options.stateDir);
|
|
81944
81329
|
if (basename13(projectsDir) === "projects") {
|
|
81945
|
-
return { path: options.path ??
|
|
81330
|
+
return { path: options.path ?? join47(dirname24(projectsDir), "ui.db"), projectsDir };
|
|
81946
81331
|
}
|
|
81947
|
-
return { path: options.path ??
|
|
81332
|
+
return { path: options.path ?? join47(options.stateDir, "ui.db"), projectsDir: void 0 };
|
|
81948
81333
|
}
|
|
81949
81334
|
const data = options.home ? frizzPaths({ home: options.home }).data : frizzRoots().data;
|
|
81950
|
-
return { path: options.path ??
|
|
81335
|
+
return { path: options.path ?? join47(data, "ui.db"), projectsDir: join47(data, "projects") };
|
|
81951
81336
|
}
|
|
81952
81337
|
function ensureFrizzSchema(db) {
|
|
81953
81338
|
db.exec(`
|
|
@@ -81966,7 +81351,7 @@ function ensureFrizzSchema(db) {
|
|
|
81966
81351
|
}
|
|
81967
81352
|
function openFrizzDatabase(options = {}) {
|
|
81968
81353
|
const { path: path3, projectsDir } = frizzDatabaseLocation(options);
|
|
81969
|
-
mkdirSync24(
|
|
81354
|
+
mkdirSync24(dirname24(path3), { recursive: true });
|
|
81970
81355
|
const db = new sqlite_default(path3);
|
|
81971
81356
|
db.pragma("busy_timeout = 5000");
|
|
81972
81357
|
db.pragma("journal_mode = WAL");
|
|
@@ -81978,10 +81363,10 @@ function openFrizzDatabase(options = {}) {
|
|
|
81978
81363
|
);
|
|
81979
81364
|
for (const projectId of retiredLegacyProjectIds(projectsDir)) {
|
|
81980
81365
|
if (alreadyImported.has(projectId)) continue;
|
|
81981
|
-
const dir =
|
|
81366
|
+
const dir = join47(projectsDir, projectId);
|
|
81982
81367
|
try {
|
|
81983
|
-
renameSync13(
|
|
81984
|
-
db.prepare("INSERT INTO imported_project (project_id, source, rows, imported_at) VALUES (?, ?, 0, ?)").run(projectId,
|
|
81368
|
+
renameSync13(join47(dir, "ui.db.imported"), join47(dir, "ui.db"));
|
|
81369
|
+
db.prepare("INSERT INTO imported_project (project_id, source, rows, imported_at) VALUES (?, ?, 0, ?)").run(projectId, join47(dir, "ui.db"), (/* @__PURE__ */ new Date()).toISOString());
|
|
81985
81370
|
alreadyImported.add(projectId);
|
|
81986
81371
|
log.info("frizz-db", `${projectId}: restored ui.db.imported to ui.db and recorded it as imported`);
|
|
81987
81372
|
} catch (error) {
|
|
@@ -81991,7 +81376,7 @@ function openFrizzDatabase(options = {}) {
|
|
|
81991
81376
|
}
|
|
81992
81377
|
for (const projectId of legacyProjectIds(projectsDir)) {
|
|
81993
81378
|
if (alreadyImported.has(projectId)) continue;
|
|
81994
|
-
const legacyPath =
|
|
81379
|
+
const legacyPath = join47(projectsDir, projectId, "ui.db");
|
|
81995
81380
|
try {
|
|
81996
81381
|
const rows = importLegacyProject(db, projectId, legacyPath);
|
|
81997
81382
|
imported.push({ projectId, rows });
|
|
@@ -82024,7 +81409,7 @@ function projectIdsWithFile(projectsDir, file) {
|
|
|
82024
81409
|
if (!existsSync21(projectsDir)) return [];
|
|
82025
81410
|
return readdirSync16(projectsDir).filter((name) => {
|
|
82026
81411
|
try {
|
|
82027
|
-
return
|
|
81412
|
+
return statSync25(join47(projectsDir, name, file)).isFile();
|
|
82028
81413
|
} catch {
|
|
82029
81414
|
return false;
|
|
82030
81415
|
}
|
|
@@ -82034,7 +81419,7 @@ function legacyProjectIds(projectsDir) {
|
|
|
82034
81419
|
return projectIdsWithFile(projectsDir, "ui.db");
|
|
82035
81420
|
}
|
|
82036
81421
|
function retiredLegacyProjectIds(projectsDir) {
|
|
82037
|
-
return projectIdsWithFile(projectsDir, "ui.db.imported").filter((id2) => !existsSync21(
|
|
81422
|
+
return projectIdsWithFile(projectsDir, "ui.db.imported").filter((id2) => !existsSync21(join47(projectsDir, id2, "ui.db")));
|
|
82038
81423
|
}
|
|
82039
81424
|
function tableColumns(db, schema, table) {
|
|
82040
81425
|
return db.prepare(`PRAGMA ${schema}.table_info(${table})`).all().map((c) => c.name);
|
|
@@ -82190,7 +81575,7 @@ var init_tenant_prime = __esm({
|
|
|
82190
81575
|
// packages/server/src/project-teardown.ts
|
|
82191
81576
|
import { rmSync as rmSync14 } from "node:fs";
|
|
82192
81577
|
import { homedir as homedir19 } from "node:os";
|
|
82193
|
-
import { dirname as
|
|
81578
|
+
import { dirname as dirname25, resolve as resolve11 } from "node:path";
|
|
82194
81579
|
async function stopProjectWorkers(ctx) {
|
|
82195
81580
|
let stopped = 0;
|
|
82196
81581
|
for (const row of ctx.storage.allSessions()) {
|
|
@@ -82210,7 +81595,7 @@ function deleteProjectState(projectId, home = homedir19()) {
|
|
|
82210
81595
|
if (!/^[\w.-]+$/u.test(projectId) || projectId === "." || projectId === "..") {
|
|
82211
81596
|
throw new Error(`Refusing to delete state for a malformed project id: ${projectId}`);
|
|
82212
81597
|
}
|
|
82213
|
-
if (
|
|
81598
|
+
if (dirname25(resolve11(target)) !== resolve11(dirname25(projectStateDir("x", home)))) {
|
|
82214
81599
|
throw new Error(`Refusing to delete ${target} \u2014 it is not a project state directory`);
|
|
82215
81600
|
}
|
|
82216
81601
|
rmSync14(target, { recursive: true, force: true });
|
|
@@ -82239,8 +81624,8 @@ __export(index_exports, {
|
|
|
82239
81624
|
unknownProjectPage: () => unknownProjectPage
|
|
82240
81625
|
});
|
|
82241
81626
|
import { createServer } from "node:http";
|
|
82242
|
-
import { readFileSync as readFileSync35, existsSync as existsSync22, statSync as
|
|
82243
|
-
import { dirname as
|
|
81627
|
+
import { readFileSync as readFileSync35, existsSync as existsSync22, statSync as statSync26 } from "node:fs";
|
|
81628
|
+
import { dirname as dirname26, join as join48, resolve as resolve12, extname as extname4, posix as posix2, sep as sep7 } from "node:path";
|
|
82244
81629
|
function readServerAddressHolder(path3) {
|
|
82245
81630
|
try {
|
|
82246
81631
|
const value = JSON.parse(readFileSync35(path3, "utf8"));
|
|
@@ -82368,12 +81753,12 @@ function staticIsFresh(req, etag, mtimeMs) {
|
|
|
82368
81753
|
}
|
|
82369
81754
|
function serveStatic(distDir, req, res) {
|
|
82370
81755
|
const rel = posix2.normalize((req.url ?? "/").split("?")[0].replace(/\\/g, "/")).replace(/^(\.\.[/\\])+/, "");
|
|
82371
|
-
let file =
|
|
82372
|
-
if (!file.startsWith(distDir + sep7)) file =
|
|
82373
|
-
if (!existsSync22(file)) file =
|
|
81756
|
+
let file = join48(distDir, rel === "/" ? "index.html" : rel);
|
|
81757
|
+
if (!file.startsWith(distDir + sep7)) file = join48(distDir, "index.html");
|
|
81758
|
+
if (!existsSync22(file)) file = join48(distDir, "index.html");
|
|
82374
81759
|
try {
|
|
82375
|
-
const stats =
|
|
82376
|
-
const cacheControl = file.startsWith(
|
|
81760
|
+
const stats = statSync26(file);
|
|
81761
|
+
const cacheControl = file.startsWith(join48(distDir, "assets") + sep7) ? STATIC_CACHE_IMMUTABLE : STATIC_CACHE_REVALIDATE;
|
|
82377
81762
|
const etag = `"${stats.size.toString(16)}-${Math.trunc(stats.mtimeMs).toString(16)}"`;
|
|
82378
81763
|
const headers = {
|
|
82379
81764
|
"content-type": MIME[extname4(file)] ?? "application/octet-stream",
|
|
@@ -82455,17 +81840,15 @@ async function startServer(opts = {}) {
|
|
|
82455
81840
|
return frizzDb?.db;
|
|
82456
81841
|
} },
|
|
82457
81842
|
// Each project's app carries ITS OWN owner proof, so /health stays honest per project rather than
|
|
82458
|
-
// answering for whichever one happened to launch the server. The
|
|
82459
|
-
// blunter reason:
|
|
81843
|
+
// answering for whichever one happened to launch the server. The socket is per project for a
|
|
81844
|
+
// blunter reason: it is a live feed of ONE board, so sharing the launcher's would push its
|
|
82460
81845
|
// threads into every other project's UI.
|
|
82461
81846
|
createApp: (tenantCtx) => ({
|
|
82462
81847
|
app: runtime.createApp(tenantCtx, appOptionsFor(tenantCtx)),
|
|
82463
|
-
terminal: runtime.createTerminal(terminalOptionsFor(tenantCtx)),
|
|
82464
81848
|
appSocket: runtime.createAppSocket(appSocketOptionsFor(tenantCtx))
|
|
82465
81849
|
}),
|
|
82466
81850
|
closeApp: async (surfaces) => {
|
|
82467
81851
|
await surfaces.appSocket.close();
|
|
82468
|
-
await surfaces.terminal.close();
|
|
82469
81852
|
},
|
|
82470
81853
|
// The same producers boot starts for the launching project, in the same order. The tailer's cold
|
|
82471
81854
|
// prime is what makes this affordable to do lazily — it is bounded per tick, so activating a
|
|
@@ -82483,9 +81866,6 @@ async function startServer(opts = {}) {
|
|
|
82483
81866
|
controlToken: effectiveOwnerToken,
|
|
82484
81867
|
requestOwnerStop
|
|
82485
81868
|
});
|
|
82486
|
-
const terminalOptionsFor = (c) => ({
|
|
82487
|
-
resolveLogin: (slug) => c.loginUtility.attach(slug)
|
|
82488
|
-
});
|
|
82489
81869
|
const appSocketOptionsFor = (c) => ({
|
|
82490
81870
|
bus: c.bus,
|
|
82491
81871
|
bootId: c.bootId,
|
|
@@ -82510,7 +81890,6 @@ async function startServer(opts = {}) {
|
|
|
82510
81890
|
watchFile: (path3, onChange) => watchLocalFile(resolveWatchableLocalFile(path3, openableFileRoots(c.project)), onChange)
|
|
82511
81891
|
});
|
|
82512
81892
|
let githubInit;
|
|
82513
|
-
let terminal;
|
|
82514
81893
|
let appSocket;
|
|
82515
81894
|
let vite;
|
|
82516
81895
|
let httpServer;
|
|
@@ -82565,9 +81944,6 @@ async function startServer(opts = {}) {
|
|
|
82565
81944
|
const closingHttp = stopHttp();
|
|
82566
81945
|
await Promise.all([closingHttp, Promise.allSettled([...requestTasks]).then(() => void 0)]);
|
|
82567
81946
|
});
|
|
82568
|
-
const cleanupTerminal = createRetryableCleanup(async () => {
|
|
82569
|
-
await terminal?.close();
|
|
82570
|
-
});
|
|
82571
81947
|
const cleanupAppSocket = createRetryableCleanup(async () => {
|
|
82572
81948
|
await appSocket?.close();
|
|
82573
81949
|
});
|
|
@@ -82580,7 +81956,6 @@ async function startServer(opts = {}) {
|
|
|
82580
81956
|
}
|
|
82581
81957
|
});
|
|
82582
81958
|
const cleanupTailer = createRetryableCleanup(tenant.tailer);
|
|
82583
|
-
const cleanupLoginUtility = createRetryableCleanup(tenant.loginUtility);
|
|
82584
81959
|
const cleanupSubscriptions = createRetryableCleanup(tenant.subscriptions);
|
|
82585
81960
|
const cleanupScheduler = createRetryableCleanup(tenant.scheduler);
|
|
82586
81961
|
const cleanupBoard = createRetryableCleanup(tenant.board);
|
|
@@ -82608,18 +81983,12 @@ async function startServer(opts = {}) {
|
|
|
82608
81983
|
name: "http requests",
|
|
82609
81984
|
run: cleanupHttp
|
|
82610
81985
|
},
|
|
82611
|
-
{
|
|
82612
|
-
name: "terminal transport",
|
|
82613
|
-
run: cleanupTerminal
|
|
82614
|
-
},
|
|
82615
81986
|
{
|
|
82616
81987
|
name: "application socket",
|
|
82617
81988
|
run: cleanupAppSocket
|
|
82618
81989
|
},
|
|
82619
81990
|
{ name: "other projects", run: cleanupExtraTenants },
|
|
82620
81991
|
{ name: "tailer producer", run: cleanupTailer },
|
|
82621
|
-
// Kill any live login-attempt pane so OAuth bytes never outlive the server.
|
|
82622
|
-
{ name: "login utility", run: cleanupLoginUtility },
|
|
82623
81992
|
{ name: "context subscriptions", run: cleanupSubscriptions },
|
|
82624
81993
|
{ name: "wake scheduler", run: cleanupScheduler },
|
|
82625
81994
|
{ name: "board producer and watcher", run: cleanupBoard },
|
|
@@ -82651,7 +82020,7 @@ async function startServer(opts = {}) {
|
|
|
82651
82020
|
if (statusPath && statusIdentity) runtime.removeStatus(statusPath, statusIdentity);
|
|
82652
82021
|
if (statusPath && statusIdentity) {
|
|
82653
82022
|
try {
|
|
82654
|
-
runtime.removeStatus(serverAddressPathForStateDir(
|
|
82023
|
+
runtime.removeStatus(serverAddressPathForStateDir(dirname26(statusPath)), statusIdentity);
|
|
82655
82024
|
} catch {
|
|
82656
82025
|
}
|
|
82657
82026
|
}
|
|
@@ -82763,13 +82132,6 @@ async function startServer(opts = {}) {
|
|
|
82763
82132
|
void githubInit.catch(() => void 0);
|
|
82764
82133
|
await runtime.afterPhase?.("GitHub initialization");
|
|
82765
82134
|
const app = await phase("application", () => runtime.createApp(ctx, appOptionsFor(ctx)));
|
|
82766
|
-
terminal = await phase(
|
|
82767
|
-
"terminal transport",
|
|
82768
|
-
() => runtime.createTerminal(terminalOptionsFor(ctx)),
|
|
82769
|
-
(value) => {
|
|
82770
|
-
terminal = value;
|
|
82771
|
-
}
|
|
82772
|
-
);
|
|
82773
82135
|
appSocket = await phase(
|
|
82774
82136
|
"application socket",
|
|
82775
82137
|
() => runtime.createAppSocket(appSocketOptionsFor(ctx)),
|
|
@@ -82777,7 +82139,7 @@ async function startServer(opts = {}) {
|
|
|
82777
82139
|
appSocket = value;
|
|
82778
82140
|
}
|
|
82779
82141
|
);
|
|
82780
|
-
tenants.adopt(project, ctx, { app,
|
|
82142
|
+
tenants.adopt(project, ctx, { app, appSocket });
|
|
82781
82143
|
await phase("board producer", () => ctx.board.start());
|
|
82782
82144
|
await phase("tailer producer", () => ctx.tailer.start((done, total) => {
|
|
82783
82145
|
bootProgress(`tailer producer ${done}/${total}`);
|
|
@@ -82789,7 +82151,7 @@ async function startServer(opts = {}) {
|
|
|
82789
82151
|
}
|
|
82790
82152
|
statusPath = serverLockPathFor(ctx.project);
|
|
82791
82153
|
const webRoot = resolve12(import.meta.dirname, "..", "..", "web");
|
|
82792
|
-
const distDir = opts.webDistDir ? resolve12(opts.webDistDir) :
|
|
82154
|
+
const distDir = opts.webDistDir ? resolve12(opts.webDistDir) : join48(webRoot, "dist");
|
|
82793
82155
|
startupPhase = "Vite";
|
|
82794
82156
|
if (opts.dev) {
|
|
82795
82157
|
try {
|
|
@@ -82867,7 +82229,7 @@ async function startServer(opts = {}) {
|
|
|
82867
82229
|
if (vite) {
|
|
82868
82230
|
vite.middlewares(req, res, () => {
|
|
82869
82231
|
try {
|
|
82870
|
-
const html = readFileSync35(
|
|
82232
|
+
const html = readFileSync35(join48(webRoot, "index.html"), "utf8");
|
|
82871
82233
|
void vite.transformIndexHtml(url, html).then((out) => {
|
|
82872
82234
|
res.writeHead(200, { "content-type": "text/html" });
|
|
82873
82235
|
res.end(out);
|
|
@@ -82898,9 +82260,7 @@ async function startServer(opts = {}) {
|
|
|
82898
82260
|
void routeToTenant(req.url ?? "/").then((routed) => {
|
|
82899
82261
|
const surfaces = routed?.surfaces;
|
|
82900
82262
|
if (routed) req.url = routed.url;
|
|
82901
|
-
const term = surfaces?.terminal ?? terminal;
|
|
82902
82263
|
const ws2 = surfaces?.appSocket ?? appSocket;
|
|
82903
|
-
if (term.handleUpgrade(req, socket, head)) return;
|
|
82904
82264
|
if (ws2.handleUpgrade(req, socket, head)) return;
|
|
82905
82265
|
socket.destroy();
|
|
82906
82266
|
}).catch(() => socket.destroy());
|
|
@@ -83018,7 +82378,6 @@ var init_index = __esm({
|
|
|
83018
82378
|
init_context();
|
|
83019
82379
|
init_app();
|
|
83020
82380
|
init_compression();
|
|
83021
|
-
init_terminal();
|
|
83022
82381
|
init_app_socket();
|
|
83023
82382
|
init_shutdown();
|
|
83024
82383
|
init_project();
|
|
@@ -83045,7 +82404,6 @@ var init_index = __esm({
|
|
|
83045
82404
|
createContext,
|
|
83046
82405
|
initGithub,
|
|
83047
82406
|
createApp,
|
|
83048
|
-
createTerminal: createTerminalServer,
|
|
83049
82407
|
createAppSocket: createAppSocketServer,
|
|
83050
82408
|
createVite: async (options) => {
|
|
83051
82409
|
const { createServer: createVite } = await import("vite");
|
|
@@ -83077,7 +82435,7 @@ var init_index = __esm({
|
|
|
83077
82435
|
}
|
|
83078
82436
|
};
|
|
83079
82437
|
isApiUrl = (url) => url === FRIZZ_ROUTE_PREFIX || url.startsWith(`${FRIZZ_ROUTE_PREFIX}/`);
|
|
83080
|
-
serverLockPathFor = (project) =>
|
|
82438
|
+
serverLockPathFor = (project) => join48(project.stateDir, "server.lock");
|
|
83081
82439
|
MIME = {
|
|
83082
82440
|
".html": "text/html",
|
|
83083
82441
|
".js": "text/javascript",
|
|
@@ -83101,28 +82459,7 @@ init_project_launch();
|
|
|
83101
82459
|
init_shutdown();
|
|
83102
82460
|
init_logging();
|
|
83103
82461
|
import { existsSync as existsSync23 } from "node:fs";
|
|
83104
|
-
import { join as
|
|
83105
|
-
|
|
83106
|
-
// packages/server/src/native-helper.ts
|
|
83107
|
-
import { chmodSync, statSync as statSync4 } from "node:fs";
|
|
83108
|
-
import { createRequire } from "node:module";
|
|
83109
|
-
import { dirname as dirname6, join as join9 } from "node:path";
|
|
83110
|
-
function ensureNativeHelperPermissions(options = {}) {
|
|
83111
|
-
const platform3 = options.platform ?? process.platform;
|
|
83112
|
-
if (platform3 === "win32") return;
|
|
83113
|
-
const stat2 = options.stat ?? ((path3) => statSync4(path3));
|
|
83114
|
-
const chmod = options.chmod ?? ((path3, mode) => chmodSync(path3, mode));
|
|
83115
|
-
const resolvePty = options.resolvePty ?? (() => createRequire(import.meta.url).resolve("node-pty/package.json"));
|
|
83116
|
-
try {
|
|
83117
|
-
const helper = join9(dirname6(resolvePty()), "prebuilds", `${platform3}-${options.arch ?? process.arch}`, "spawn-helper");
|
|
83118
|
-
const mode = stat2(helper).mode;
|
|
83119
|
-
if ((mode & 73) === 73) return;
|
|
83120
|
-
chmod(helper, mode | 493);
|
|
83121
|
-
} catch {
|
|
83122
|
-
}
|
|
83123
|
-
}
|
|
83124
|
-
|
|
83125
|
-
// packages/server/src/dev-child.ts
|
|
82462
|
+
import { join as join49 } from "node:path";
|
|
83126
82463
|
process.on("uncaughtException", (error) => {
|
|
83127
82464
|
log.error("dev-child", `uncaught exception: ${error instanceof Error ? error.stack ?? error.message : error}`);
|
|
83128
82465
|
process.exit(1);
|
|
@@ -83166,7 +82503,6 @@ try {
|
|
|
83166
82503
|
if (!serverTarget || !serverToken) throw new Error("stable server is missing global launch ownership");
|
|
83167
82504
|
registerProjectLaunchDelegate(serverTarget, serverToken);
|
|
83168
82505
|
}
|
|
83169
|
-
ensureNativeHelperPermissions();
|
|
83170
82506
|
const { startServer: startServer2 } = await Promise.resolve().then(() => (init_index(), index_exports));
|
|
83171
82507
|
const project = projectFromLaunchTarget(target);
|
|
83172
82508
|
const stableWebDist = process.env.FRIZZ_STABLE_WEB_DIST;
|
|
@@ -83180,7 +82516,7 @@ try {
|
|
|
83180
82516
|
];
|
|
83181
82517
|
if (!existsSync23(stableWebDist)) throw new Error("stable artifact launch is missing its verified web directory");
|
|
83182
82518
|
for (const [name, directory, requiredFile] of required) {
|
|
83183
|
-
if (!directory || !existsSync23(
|
|
82519
|
+
if (!directory || !existsSync23(join49(directory, requiredFile)))
|
|
83184
82520
|
throw new Error(`stable artifact launch is missing verified ${name}`);
|
|
83185
82521
|
}
|
|
83186
82522
|
}
|