@ycodium-ai/plugin-api 0.2.5634 → 0.2.5763
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -65
- package/dist/_private/ycodium-attachment-kinds/chatAttachmentKinds.d.ts +34 -0
- package/dist/_private/ycodium-attachment-kinds/chatAttachmentKinds.js +70 -0
- package/dist/_private/ycodium-attachment-kinds/mediaKinds.d.ts +23 -0
- package/dist/_private/ycodium-attachment-kinds/mediaKinds.js +73 -0
- package/dist/_private/ycodium-composer-tokens/approvalFileChanges.d.ts +20 -0
- package/dist/_private/ycodium-composer-tokens/approvalFileChanges.js +45 -0
- package/dist/_private/ycodium-composer-tokens/composerFileLink.d.ts +1 -0
- package/dist/_private/ycodium-composer-tokens/composerFileLink.js +20 -0
- package/dist/_private/ycodium-composer-tokens/composerInlineTokens.d.ts +17 -0
- package/dist/_private/ycodium-composer-tokens/composerInlineTokens.js +91 -0
- package/dist/_private/ycodium-composer-tokens/composerLogic.d.ts +30 -0
- package/dist/_private/ycodium-composer-tokens/composerLogic.js +181 -0
- package/dist/_private/ycodium-composer-tokens/composerMentionDrag.d.ts +40 -0
- package/dist/_private/ycodium-composer-tokens/composerMentionDrag.js +60 -0
- package/dist/_private/ycodium-composer-tokens/composerPromptSegments.d.ts +16 -0
- package/dist/_private/ycodium-composer-tokens/composerPromptSegments.js +142 -0
- package/dist/_private/ycodium-composer-tokens/composerTrigger.d.ts +18 -0
- package/dist/_private/ycodium-composer-tokens/composerTrigger.js +44 -0
- package/dist/_private/ycodium-composer-tokens/contextWindowFormat.d.ts +2 -0
- package/dist/_private/ycodium-composer-tokens/contextWindowFormat.js +16 -0
- package/dist/_private/ycodium-composer-tokens/diffCount.d.ts +2 -0
- package/dist/_private/ycodium-composer-tokens/diffCount.js +15 -0
- package/dist/_private/ycodium-composer-tokens/pendingUserInput.d.ts +48 -0
- package/dist/_private/ycodium-composer-tokens/pendingUserInput.js +145 -0
- package/dist/_private/ycodium-composer-tokens/promptContextBlocks.d.ts +58 -0
- package/dist/_private/ycodium-composer-tokens/promptContextBlocks.js +121 -0
- package/dist/_private/ycodium-composer-tokens/proposedPlan.d.ts +21 -0
- package/dist/_private/ycodium-composer-tokens/proposedPlan.js +106 -0
- package/dist/_private/ycodium-composer-tokens/providerSkillSearch.d.ts +3 -0
- package/dist/_private/ycodium-composer-tokens/providerSkillSearch.js +79 -0
- package/dist/_private/ycodium-composer-tokens/providerSkills.d.ts +17 -0
- package/dist/_private/ycodium-composer-tokens/providerSkills.js +57 -0
- package/dist/_private/ycodium-composer-tokens/queueEntry.d.ts +31 -0
- package/dist/_private/ycodium-composer-tokens/queueEntry.js +44 -0
- package/dist/_private/ycodium-composer-tokens/reviewCommentBlocks.d.ts +29 -0
- package/dist/_private/ycodium-composer-tokens/reviewCommentBlocks.js +118 -0
- package/dist/_private/ycodium-composer-tokens/searchRanking.d.ts +27 -0
- package/dist/_private/ycodium-composer-tokens/searchRanking.js +129 -0
- package/dist/_private/ycodium-composer-tokens/skillTokens.d.ts +101 -0
- package/dist/_private/ycodium-composer-tokens/skillTokens.js +148 -0
- package/dist/_private/ycodium-composer-tokens/slashMenu.d.ts +130 -0
- package/dist/_private/ycodium-composer-tokens/slashMenu.js +175 -0
- package/dist/_private/ycodium-composer-tokens/userInputOptionText.d.ts +33 -0
- package/dist/_private/ycodium-composer-tokens/userInputOptionText.js +27 -0
- package/dist/_private/ycodium-credential-account/credentialAccount.d.ts +21 -0
- package/dist/_private/ycodium-credential-account/credentialAccount.js +62 -0
- package/dist/_private/ycodium-credential-account/quotaJson.d.ts +12 -0
- package/dist/_private/ycodium-credential-account/quotaJson.js +14 -0
- package/dist/_private/ycodium-credential-account/quotaRequest.d.ts +32 -0
- package/dist/_private/ycodium-credential-account/quotaRequest.js +60 -0
- package/dist/_private/ycodium-day-format/dayFormat.d.ts +31 -0
- package/dist/_private/ycodium-day-format/dayFormat.js +32 -0
- package/dist/_private/ycodium-day-format/timestampFormat.d.ts +35 -0
- package/dist/_private/ycodium-day-format/timestampFormat.js +119 -0
- package/dist/_private/ycodium-decision-order/decisionOrder.d.ts +19 -0
- package/dist/_private/ycodium-decision-order/decisionOrder.js +38 -0
- package/dist/_private/ycodium-diff-format/diffRendering.d.ts +42 -0
- package/dist/_private/ycodium-diff-format/diffRendering.js +171 -0
- package/dist/_private/ycodium-duration-format/durationFormat.d.ts +20 -0
- package/dist/_private/ycodium-duration-format/durationFormat.js +56 -0
- package/dist/_private/ycodium-fetch-ports/fetchPorts.d.ts +36 -0
- package/dist/_private/ycodium-fetch-ports/fetchPorts.js +69 -0
- package/dist/_private/ycodium-fetch-ports/netFault.d.ts +10 -0
- package/dist/_private/ycodium-fetch-ports/netFault.js +17 -0
- package/dist/_private/ycodium-full-access-mode/fullAccessNativeMode.d.ts +28 -0
- package/dist/_private/ycodium-full-access-mode/fullAccessNativeMode.js +30 -0
- package/dist/_private/ycodium-instance-config/homePath.d.ts +34 -0
- package/dist/_private/ycodium-instance-config/homePath.js +85 -0
- package/dist/_private/ycodium-instance-config/instanceConfig.d.ts +46 -0
- package/dist/_private/ycodium-instance-config/instanceConfig.js +111 -0
- package/dist/_private/ycodium-instance-config/launchArgs.d.ts +5 -0
- package/dist/_private/ycodium-instance-config/launchArgs.js +65 -0
- package/dist/_private/ycodium-instance-config/probeProcess.d.ts +39 -0
- package/dist/_private/ycodium-instance-config/probeProcess.js +55 -0
- package/dist/_private/ycodium-instance-config/programHomeSchema.d.ts +44 -0
- package/dist/_private/ycodium-instance-config/programHomeSchema.js +60 -0
- package/dist/_private/ycodium-instance-config/tomlScalar.d.ts +5 -0
- package/dist/_private/ycodium-instance-config/tomlScalar.js +11 -0
- package/dist/_private/ycodium-jsonl-stream/appendedJsonl.d.ts +47 -0
- package/dist/_private/ycodium-jsonl-stream/appendedJsonl.js +172 -0
- package/dist/_private/ycodium-jsonl-stream/claudeSessions.d.ts +63 -0
- package/dist/_private/ycodium-jsonl-stream/claudeSessions.js +220 -0
- package/dist/_private/ycodium-jsonl-stream/codexSessions.d.ts +41 -0
- package/dist/_private/ycodium-jsonl-stream/codexSessions.js +197 -0
- package/dist/_private/ycodium-jsonl-stream/history.d.ts +6 -0
- package/dist/_private/ycodium-jsonl-stream/history.js +389 -0
- package/dist/_private/ycodium-jsonl-stream/historyErrors.d.ts +6 -0
- package/dist/_private/ycodium-jsonl-stream/historyErrors.js +6 -0
- package/dist/_private/ycodium-jsonl-stream/historyFile.d.ts +19 -0
- package/dist/_private/ycodium-jsonl-stream/historyFile.js +117 -0
- package/dist/_private/ycodium-jsonl-stream/historyRecord.d.ts +31 -0
- package/dist/_private/ycodium-jsonl-stream/historyRecord.js +144 -0
- package/dist/_private/ycodium-jsonl-stream/historyWaiting.d.ts +8 -0
- package/dist/_private/ycodium-jsonl-stream/historyWaiting.js +142 -0
- package/dist/_private/ycodium-jsonl-stream/jsonObjectLine.d.ts +5 -0
- package/dist/_private/ycodium-jsonl-stream/jsonObjectLine.js +18 -0
- package/dist/_private/ycodium-jsonl-stream/jsonlStream.d.ts +79 -0
- package/dist/_private/ycodium-jsonl-stream/jsonlStream.js +603 -0
- package/dist/_private/ycodium-jsonl-stream/scanCache.d.ts +69 -0
- package/dist/_private/ycodium-jsonl-stream/scanCache.js +106 -0
- package/dist/_private/ycodium-jsonl-stream/sessionDirectory.d.ts +5 -0
- package/dist/_private/ycodium-jsonl-stream/sessionDirectory.js +32 -0
- package/dist/_private/ycodium-jsonl-stream/sessionTranscript.d.ts +16 -0
- package/dist/_private/ycodium-jsonl-stream/sessionTranscript.js +112 -0
- package/dist/_private/ycodium-jsonl-stream/usageFields.d.ts +5 -0
- package/dist/_private/ycodium-jsonl-stream/usageFields.js +11 -0
- package/dist/_private/ycodium-markdown-fence/markdownFence.d.ts +6 -0
- package/dist/_private/ycodium-markdown-fence/markdownFence.js +24 -0
- package/dist/_private/ycodium-source-control/pullRequestScope.d.ts +23 -0
- package/dist/_private/ycodium-source-control/pullRequestScope.js +29 -0
- package/dist/_private/ycodium-sse-stream/sseStream.d.ts +37 -0
- package/dist/_private/ycodium-sse-stream/sseStream.js +104 -0
- package/dist/_private/ycodium-system-text/memberInstructions.d.ts +13 -0
- package/dist/_private/ycodium-system-text/memberInstructions.js +9 -0
- package/dist/_private/ycodium-system-text/systemText.d.ts +179 -0
- package/dist/_private/ycodium-system-text/systemText.js +257 -0
- package/dist/_private/ycodium-system-text/threadPreset.d.ts +18 -0
- package/dist/_private/ycodium-system-text/threadPreset.js +21 -0
- package/dist/_private/ycodium-text-generation/branchName.d.ts +6 -0
- package/dist/_private/ycodium-text-generation/branchName.js +26 -0
- package/dist/_private/ycodium-text-generation/prompts.d.ts +70 -0
- package/dist/_private/ycodium-text-generation/prompts.js +266 -0
- package/dist/_private/ycodium-text-generation/sanitize.d.ts +10 -0
- package/dist/_private/ycodium-text-generation/sanitize.js +124 -0
- package/dist/_private/ycodium-text-generation/structuredTextGeneration.d.ts +29 -0
- package/dist/_private/ycodium-text-generation/structuredTextGeneration.js +163 -0
- package/dist/_private/ycodium-tool-label/toolLabel.d.ts +42 -0
- package/dist/_private/ycodium-tool-label/toolLabel.js +249 -0
- package/dist/_private/ycodium-ui-hooks/DiffStatCounts.d.ts +22 -0
- package/dist/_private/ycodium-ui-hooks/DiffStatCounts.js +22 -0
- package/dist/_private/ycodium-ui-hooks/ProviderSignInChallenge.d.ts +29 -0
- package/dist/_private/ycodium-ui-hooks/ProviderSignInChallenge.js +13 -0
- package/dist/_private/ycodium-ui-hooks/RenderErrorBoundary.d.ts +28 -0
- package/dist/_private/ycodium-ui-hooks/RenderErrorBoundary.js +22 -0
- package/dist/_private/ycodium-ui-hooks/RuntimeMaintenanceActions.d.ts +19 -0
- package/dist/_private/ycodium-ui-hooks/RuntimeMaintenanceActions.js +7 -0
- package/dist/_private/ycodium-ui-hooks/SkillInlineText.d.ts +13 -0
- package/dist/_private/ycodium-ui-hooks/SkillInlineText.js +13 -0
- package/dist/_private/ycodium-ui-hooks/bundleStyle.d.ts +4 -0
- package/dist/_private/ycodium-ui-hooks/bundleStyle.js +52 -0
- package/dist/_private/ycodium-ui-hooks/catalogKeys.d.ts +9 -0
- package/dist/_private/ycodium-ui-hooks/catalogKeys.js +1 -0
- package/dist/_private/ycodium-ui-hooks/clipboard.d.ts +22 -0
- package/dist/_private/ycodium-ui-hooks/clipboard.js +149 -0
- package/dist/_private/ycodium-ui-hooks/hostControls.d.ts +24 -0
- package/dist/_private/ycodium-ui-hooks/hostControls.js +25 -0
- package/dist/_private/ycodium-ui-hooks/inlineChips.d.ts +50 -0
- package/dist/_private/ycodium-ui-hooks/inlineChips.js +32 -0
- package/dist/_private/ycodium-ui-hooks/notifyMessages.d.ts +20 -0
- package/dist/_private/ycodium-ui-hooks/notifyMessages.js +26 -0
- package/dist/_private/ycodium-ui-hooks/presenterInputState.d.ts +52 -0
- package/dist/_private/ycodium-ui-hooks/presenterInputState.js +240 -0
- package/dist/_private/ycodium-ui-hooks/processRowHeader.d.ts +6 -0
- package/dist/_private/ycodium-ui-hooks/processRowHeader.js +6 -0
- package/dist/_private/ycodium-ui-hooks/timelineDisclosure.d.ts +5 -0
- package/dist/_private/ycodium-ui-hooks/timelineDisclosure.js +73 -0
- package/dist/_private/ycodium-ui-hooks/useMediaQuery.d.ts +20 -0
- package/dist/_private/ycodium-ui-hooks/useMediaQuery.js +70 -0
- package/dist/_private/ycodium-ui-hooks/workEntryIcons.d.ts +25 -0
- package/dist/_private/ycodium-ui-hooks/workEntryIcons.js +66 -0
- package/dist/_private/ycodium-workspace-path/directoryScope.d.ts +5 -0
- package/dist/_private/ycodium-workspace-path/directoryScope.js +28 -0
- package/dist/_private/ycodium-workspace-path/workspacePath.d.ts +19 -0
- package/dist/_private/ycodium-workspace-path/workspacePath.js +90 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js.map +1 -1
- package/dist/capabilityPorts.d.ts.map +1 -1
- package/dist/capabilityPorts.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js.map +1 -1
- package/dist/communication-view.d.ts.map +1 -1
- package/dist/communication-view.js.map +1 -1
- package/dist/communication.d.ts.map +1 -1
- package/dist/communication.js.map +1 -1
- package/dist/composer-control.d.ts.map +1 -1
- package/dist/composer-control.js.map +1 -1
- package/dist/composer.d.ts +22 -0
- package/dist/composer.d.ts.map +1 -0
- package/dist/composer.js +22 -0
- package/dist/composer.js.map +1 -0
- package/dist/conversation-queue.d.ts.map +1 -1
- package/dist/conversation-queue.js.map +1 -1
- package/dist/conversation-view.d.ts.map +1 -1
- package/dist/conversation-view.js.map +1 -1
- package/dist/conversation.d.ts +4 -9
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js.map +1 -1
- package/dist/conversationAttachments.d.ts.map +1 -1
- package/dist/conversationAttachments.js.map +1 -1
- package/dist/conversationBase.d.ts.map +1 -1
- package/dist/conversationBase.js.map +1 -1
- package/dist/conversationComposerApi.d.ts.map +1 -1
- package/dist/conversationComposerApi.js.map +1 -1
- package/dist/conversationComposerEnvironment.d.ts.map +1 -1
- package/dist/conversationComposerEnvironment.js.map +1 -1
- package/dist/conversationComposerHandle.d.ts.map +1 -1
- package/dist/conversationComposerHandle.js.map +1 -1
- package/dist/conversationComposerParts.d.ts.map +1 -1
- package/dist/conversationComposerParts.js.map +1 -1
- package/dist/conversationDerive.d.ts.map +1 -1
- package/dist/conversationDerive.js.map +1 -1
- package/dist/conversationDrafts.d.ts.map +1 -1
- package/dist/conversationDrafts.js.map +1 -1
- package/dist/conversationForks.d.ts.map +1 -1
- package/dist/conversationForks.js.map +1 -1
- package/dist/conversationHostModels.d.ts.map +1 -1
- package/dist/conversationHostModels.js.map +1 -1
- package/dist/conversationLoadFailure.d.ts.map +1 -1
- package/dist/conversationLoadFailure.js.map +1 -1
- package/dist/conversationMemberMentions.d.ts.map +1 -1
- package/dist/conversationMemberMentions.js.map +1 -1
- package/dist/conversationMessageLinks.d.ts.map +1 -1
- package/dist/conversationMessageLinks.js.map +1 -1
- package/dist/conversationMessageMemory.d.ts.map +1 -1
- package/dist/conversationMessageMemory.js.map +1 -1
- package/dist/conversationPresets.d.ts.map +1 -1
- package/dist/conversationPresets.js.map +1 -1
- package/dist/conversationRows.d.ts +2 -0
- package/dist/conversationRows.d.ts.map +1 -1
- package/dist/conversationRows.js.map +1 -1
- package/dist/conversationSessionMessage.d.ts.map +1 -1
- package/dist/conversationSessionMessage.js.map +1 -1
- package/dist/conversationSkills.d.ts.map +1 -1
- package/dist/conversationSkills.js.map +1 -1
- package/dist/conversationTrajectory.d.ts.map +1 -1
- package/dist/conversationTrajectory.js.map +1 -1
- package/dist/conversationTranscript.d.ts.map +1 -1
- package/dist/conversationTranscript.js.map +1 -1
- package/dist/conversationTurnSummaries.d.ts.map +1 -1
- package/dist/conversationTurnSummaries.js.map +1 -1
- package/dist/conversationViewProps.d.ts.map +1 -1
- package/dist/conversationViewProps.js.map +1 -1
- package/dist/conversationWorkEntry.d.ts.map +1 -1
- package/dist/conversationWorkEntry.js.map +1 -1
- package/dist/credential-account.d.ts +4 -0
- package/dist/credential-account.d.ts.map +1 -0
- package/dist/credential-account.js +4 -0
- package/dist/credential-account.js.map +1 -0
- package/dist/dataPorts.gen.d.ts +306 -0
- package/dist/dataPorts.gen.d.ts.map +1 -1
- package/dist/dataPorts.gen.js.map +1 -1
- package/dist/decision-card.d.ts.map +1 -1
- package/dist/decision-card.js.map +1 -1
- package/dist/decisions.d.ts.map +1 -1
- package/dist/decisions.js.map +1 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js.map +1 -1
- package/dist/derivedState.d.ts.map +1 -1
- package/dist/derivedState.js.map +1 -1
- package/dist/diagnosticData.d.ts.map +1 -1
- package/dist/diagnosticData.js.map +1 -1
- package/dist/diff-rendering.d.ts +2 -0
- package/dist/diff-rendering.d.ts.map +1 -0
- package/dist/diff-rendering.js +2 -0
- package/dist/diff-rendering.js.map +1 -0
- package/dist/display-format.d.ts +5 -0
- package/dist/display-format.d.ts.map +1 -0
- package/dist/display-format.js +5 -0
- package/dist/display-format.js.map +1 -0
- package/dist/entity-names.d.ts.map +1 -1
- package/dist/entity-names.js.map +1 -1
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/executor-mode.d.ts +2 -0
- package/dist/executor-mode.d.ts.map +1 -0
- package/dist/executor-mode.js +2 -0
- package/dist/executor-mode.js.map +1 -0
- package/dist/executor.d.ts +17 -1
- package/dist/executor.d.ts.map +1 -1
- package/dist/executor.js.map +1 -1
- package/dist/executorCapabilities.d.ts.map +1 -1
- package/dist/executorCapabilities.js.map +1 -1
- package/dist/executorCard.d.ts +6 -0
- package/dist/executorCard.d.ts.map +1 -1
- package/dist/executorCard.js.map +1 -1
- package/dist/executorCommandArgv.d.ts.map +1 -1
- package/dist/executorCommandArgv.js.map +1 -1
- package/dist/executorEffective.d.ts.map +1 -1
- package/dist/executorEffective.js.map +1 -1
- package/dist/executorErrors.d.ts.map +1 -1
- package/dist/executorErrors.js.map +1 -1
- package/dist/executorEvents.d.ts.map +1 -1
- package/dist/executorEvents.js.map +1 -1
- package/dist/executorModelOptions.d.ts.map +1 -1
- package/dist/executorModelOptions.js.map +1 -1
- package/dist/executorProcesses.d.ts.map +1 -1
- package/dist/executorProcesses.js.map +1 -1
- package/dist/executorSession.d.ts +8 -2
- package/dist/executorSession.d.ts.map +1 -1
- package/dist/executorSession.js.map +1 -1
- package/dist/executorSpawn.d.ts +5 -4
- package/dist/executorSpawn.d.ts.map +1 -1
- package/dist/executorSpawn.js +20 -7
- package/dist/executorSpawn.js.map +1 -1
- package/dist/fetch-ports.d.ts +2 -0
- package/dist/fetch-ports.d.ts.map +1 -0
- package/dist/fetch-ports.js +2 -0
- package/dist/fetch-ports.js.map +1 -0
- package/dist/file-preview.d.ts.map +1 -1
- package/dist/file-preview.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inline-tag.d.ts.map +1 -1
- package/dist/inline-tag.js.map +1 -1
- package/dist/instance-config.d.ts +7 -0
- package/dist/instance-config.d.ts.map +1 -0
- package/dist/instance-config.js +7 -0
- package/dist/instance-config.js.map +1 -0
- package/dist/interval.d.ts.map +1 -1
- package/dist/interval.js.map +1 -1
- package/dist/jsonl.d.ts +6 -0
- package/dist/jsonl.d.ts.map +1 -0
- package/dist/jsonl.js +6 -0
- package/dist/jsonl.js.map +1 -0
- package/dist/keyedSubscribers.d.ts.map +1 -1
- package/dist/keyedSubscribers.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js.map +1 -1
- package/dist/model-picker.d.ts.map +1 -1
- package/dist/model-picker.js.map +1 -1
- package/dist/modelCatalogNotice.d.ts.map +1 -1
- package/dist/modelCatalogNotice.js.map +1 -1
- package/dist/modelChoice.d.ts.map +1 -1
- package/dist/modelChoice.js.map +1 -1
- package/dist/modelChoiceOptions.d.ts.map +1 -1
- package/dist/modelChoiceOptions.js.map +1 -1
- package/dist/modelChoiceTraits.d.ts.map +1 -1
- package/dist/modelChoiceTraits.js.map +1 -1
- package/dist/modelDisplayName.d.ts.map +1 -1
- package/dist/modelDisplayName.js.map +1 -1
- package/dist/pending-requests.d.ts.map +1 -1
- package/dist/pending-requests.js.map +1 -1
- package/dist/plugin-tools.d.ts.map +1 -1
- package/dist/plugin-tools.js.map +1 -1
- package/dist/pluginContextCommands.d.ts.map +1 -1
- package/dist/pluginContextCommands.js.map +1 -1
- package/dist/pluginContextProviders.d.ts.map +1 -1
- package/dist/pluginContextProviders.js.map +1 -1
- package/dist/pluginContextThreads.d.ts.map +1 -1
- package/dist/pluginContextThreads.js.map +1 -1
- package/dist/pluginContextWorkspace.d.ts.map +1 -1
- package/dist/pluginContextWorkspace.js.map +1 -1
- package/dist/process-operation.d.ts.map +1 -1
- package/dist/process-operation.js.map +1 -1
- package/dist/process-socket.d.ts.map +1 -1
- package/dist/process-socket.js.map +1 -1
- package/dist/process-stdin.d.ts.map +1 -1
- package/dist/process-stdin.js.map +1 -1
- package/dist/projects.d.ts.map +1 -1
- package/dist/projects.js.map +1 -1
- package/dist/provider-settings.d.ts.map +1 -1
- package/dist/provider-settings.js.map +1 -1
- package/dist/providerInstanceSelection.d.ts.map +1 -1
- package/dist/providerInstanceSelection.js.map +1 -1
- package/dist/reasoningLevelFallback.d.ts.map +1 -1
- package/dist/reasoningLevelFallback.js.map +1 -1
- package/dist/runtime-maintenance.d.ts.map +1 -1
- package/dist/runtime-maintenance.js.map +1 -1
- package/dist/runtimes.d.ts.map +1 -1
- package/dist/runtimes.js.map +1 -1
- package/dist/selectAllCopy.d.ts.map +1 -1
- package/dist/selectAllCopy.js.map +1 -1
- package/dist/session-history.d.ts +6 -0
- package/dist/session-history.d.ts.map +1 -0
- package/dist/session-history.js +6 -0
- package/dist/session-history.js.map +1 -0
- package/dist/settings-actions.d.ts.map +1 -1
- package/dist/settings-actions.js.map +1 -1
- package/dist/settings-card-shape.d.ts.map +1 -1
- package/dist/settings-card-shape.js.map +1 -1
- package/dist/settings-card.d.ts.map +1 -1
- package/dist/settings-card.js.map +1 -1
- package/dist/settings-ui.d.ts.map +1 -1
- package/dist/settings-ui.js.map +1 -1
- package/dist/sign-in.d.ts.map +1 -1
- package/dist/sign-in.js.map +1 -1
- package/dist/slashCommands.d.ts.map +1 -1
- package/dist/slashCommands.js.map +1 -1
- package/dist/slots.d.ts.map +1 -1
- package/dist/slots.js.map +1 -1
- package/dist/source/_private/ycodium-attachment-kinds/chatAttachmentKinds.ts +105 -0
- package/dist/source/_private/ycodium-attachment-kinds/mediaKinds.ts +83 -0
- package/dist/source/_private/ycodium-composer-tokens/approvalFileChanges.ts +58 -0
- package/dist/source/_private/ycodium-composer-tokens/composerFileLink.ts +23 -0
- package/dist/source/_private/ycodium-composer-tokens/composerInlineTokens.ts +130 -0
- package/dist/source/_private/ycodium-composer-tokens/composerLogic.ts +251 -0
- package/dist/source/_private/ycodium-composer-tokens/composerMentionDrag.ts +98 -0
- package/dist/source/_private/ycodium-composer-tokens/composerPromptSegments.ts +222 -0
- package/dist/source/_private/ycodium-composer-tokens/composerTrigger.ts +64 -0
- package/dist/source/_private/ycodium-composer-tokens/contextWindowFormat.ts +16 -0
- package/dist/source/_private/ycodium-composer-tokens/diffCount.ts +14 -0
- package/dist/source/_private/ycodium-composer-tokens/pendingUserInput.ts +256 -0
- package/dist/source/_private/ycodium-composer-tokens/promptContextBlocks.ts +179 -0
- package/dist/source/_private/ycodium-composer-tokens/proposedPlan.ts +134 -0
- package/dist/source/_private/ycodium-composer-tokens/providerSkillSearch.ts +105 -0
- package/dist/source/_private/ycodium-composer-tokens/providerSkills.ts +86 -0
- package/dist/source/_private/ycodium-composer-tokens/queueEntry.ts +49 -0
- package/dist/source/_private/ycodium-composer-tokens/reviewCommentBlocks.ts +177 -0
- package/dist/source/_private/ycodium-composer-tokens/searchRanking.ts +192 -0
- package/dist/source/_private/ycodium-composer-tokens/skillTokens.ts +192 -0
- package/dist/source/_private/ycodium-composer-tokens/slashMenu.ts +293 -0
- package/dist/source/_private/ycodium-composer-tokens/userInputOptionText.ts +51 -0
- package/dist/source/_private/ycodium-credential-account/credentialAccount.ts +83 -0
- package/dist/source/_private/ycodium-credential-account/quotaJson.ts +25 -0
- package/dist/source/_private/ycodium-credential-account/quotaRequest.ts +79 -0
- package/dist/source/_private/ycodium-day-format/dayFormat.ts +57 -0
- package/dist/source/_private/ycodium-day-format/timestampFormat.ts +165 -0
- package/dist/source/_private/ycodium-decision-order/decisionOrder.ts +54 -0
- package/dist/source/_private/ycodium-diff-format/diffRendering.ts +229 -0
- package/dist/source/_private/ycodium-duration-format/durationFormat.ts +60 -0
- package/dist/source/_private/ycodium-executor-common/catalogModel.ts +40 -0
- package/dist/source/_private/ycodium-executor-common/eventTypes.ts +97 -0
- package/dist/source/_private/ycodium-executor-common/modelSelection.ts +24 -0
- package/dist/source/_private/ycodium-executor-common/nodeStreams.ts +212 -0
- package/dist/source/_private/ycodium-executor-common/raceAbort.ts +25 -0
- package/dist/source/_private/ycodium-executor-common/reasoningLevelFallback.ts +28 -0
- package/dist/source/_private/ycodium-executor-common/stderrTail.ts +27 -0
- package/dist/source/_private/ycodium-executor-common/toolPresentation.ts +268 -0
- package/dist/source/_private/ycodium-fetch-ports/fetchPorts.ts +84 -0
- package/dist/source/_private/ycodium-fetch-ports/netFault.ts +30 -0
- package/dist/source/_private/ycodium-full-access-mode/fullAccessNativeMode.ts +32 -0
- package/dist/source/_private/ycodium-instance-config/homePath.ts +140 -0
- package/dist/source/_private/ycodium-instance-config/instanceConfig.ts +149 -0
- package/dist/source/_private/ycodium-instance-config/launchArgs.ts +60 -0
- package/dist/source/_private/ycodium-instance-config/probeProcess.ts +89 -0
- package/dist/source/_private/ycodium-instance-config/programHomeSchema.ts +74 -0
- package/dist/source/_private/ycodium-instance-config/tomlScalar.ts +10 -0
- package/dist/source/_private/ycodium-jsonl-stream/appendedJsonl.ts +222 -0
- package/dist/source/_private/ycodium-jsonl-stream/claudeSessions.ts +263 -0
- package/dist/source/_private/ycodium-jsonl-stream/codexSessions.ts +254 -0
- package/dist/source/_private/ycodium-jsonl-stream/history.ts +492 -0
- package/dist/source/_private/ycodium-jsonl-stream/historyErrors.ts +6 -0
- package/dist/source/_private/ycodium-jsonl-stream/historyFile.ts +139 -0
- package/dist/source/_private/ycodium-jsonl-stream/historyRecord.ts +180 -0
- package/dist/source/_private/ycodium-jsonl-stream/historyWaiting.ts +140 -0
- package/dist/source/_private/ycodium-jsonl-stream/jsonObjectLine.ts +15 -0
- package/dist/source/_private/ycodium-jsonl-stream/jsonlStream.ts +650 -0
- package/dist/source/_private/ycodium-jsonl-stream/scanCache.ts +163 -0
- package/dist/source/_private/ycodium-jsonl-stream/sessionDirectory.ts +39 -0
- package/dist/source/_private/ycodium-jsonl-stream/sessionTranscript.ts +136 -0
- package/dist/source/_private/ycodium-jsonl-stream/usageFields.ts +13 -0
- package/dist/source/_private/ycodium-markdown-fence/markdownFence.ts +28 -0
- package/dist/source/_private/ycodium-source-control/pullRequestScope.ts +35 -0
- package/dist/source/_private/ycodium-sse-stream/sseStream.ts +118 -0
- package/dist/source/_private/ycodium-system-text/memberInstructions.ts +24 -0
- package/dist/source/_private/ycodium-system-text/systemText.ts +356 -0
- package/dist/source/_private/ycodium-system-text/threadPreset.ts +35 -0
- package/dist/source/_private/ycodium-text-generation/branchName.ts +29 -0
- package/dist/source/_private/ycodium-text-generation/prompts.ts +342 -0
- package/dist/source/_private/ycodium-text-generation/sanitize.ts +125 -0
- package/dist/source/_private/ycodium-text-generation/structuredTextGeneration.ts +237 -0
- package/dist/source/_private/ycodium-tool-label/toolLabel.ts +287 -0
- package/dist/source/_private/ycodium-ui-hooks/DiffStatCounts.tsx +76 -0
- package/dist/source/_private/ycodium-ui-hooks/ProviderSignInChallenge.tsx +115 -0
- package/dist/source/_private/ycodium-ui-hooks/RenderErrorBoundary.tsx +34 -0
- package/dist/source/_private/ycodium-ui-hooks/RuntimeMaintenanceActions.tsx +63 -0
- package/dist/source/_private/ycodium-ui-hooks/SkillInlineText.tsx +28 -0
- package/dist/source/_private/ycodium-ui-hooks/bundleStyle.ts +52 -0
- package/dist/source/_private/ycodium-ui-hooks/catalogKeys.ts +11 -0
- package/dist/source/_private/ycodium-ui-hooks/clipboard.ts +176 -0
- package/dist/source/_private/ycodium-ui-hooks/hostControls.ts +43 -0
- package/dist/source/_private/ycodium-ui-hooks/inlineChips.tsx +114 -0
- package/dist/source/_private/ycodium-ui-hooks/notifyMessages.ts +36 -0
- package/dist/source/_private/ycodium-ui-hooks/presenterInputState.ts +341 -0
- package/dist/source/_private/ycodium-ui-hooks/processRowHeader.ts +7 -0
- package/dist/source/_private/ycodium-ui-hooks/timelineDisclosure.ts +98 -0
- package/dist/source/_private/ycodium-ui-hooks/useMediaQuery.ts +87 -0
- package/dist/source/_private/ycodium-ui-hooks/workEntryIcons.ts +99 -0
- package/dist/source/_private/ycodium-workspace-path/directoryScope.ts +34 -0
- package/dist/source/_private/ycodium-workspace-path/workspacePath.ts +110 -0
- package/dist/source/cache.ts +55 -0
- package/dist/source/capabilityPorts.ts +272 -0
- package/dist/source/cli.ts +69 -0
- package/dist/source/commands.ts +208 -0
- package/dist/source/communication-view.ts +107 -0
- package/dist/source/communication.ts +26 -0
- package/dist/source/composer-control.ts +16 -0
- package/dist/source/composer.ts +108 -0
- package/dist/source/conversation-queue.ts +165 -0
- package/dist/source/conversation-view.ts +49 -0
- package/dist/source/conversation.ts +695 -0
- package/dist/source/conversationAttachments.ts +139 -0
- package/dist/source/conversationBase.ts +128 -0
- package/dist/source/conversationComposerApi.ts +339 -0
- package/dist/source/conversationComposerEnvironment.ts +76 -0
- package/dist/source/conversationComposerHandle.ts +89 -0
- package/dist/source/conversationComposerParts.ts +10 -0
- package/dist/source/conversationDerive.ts +252 -0
- package/dist/source/conversationDrafts.ts +281 -0
- package/dist/source/conversationForks.ts +40 -0
- package/dist/source/conversationHostModels.ts +467 -0
- package/dist/source/conversationLoadFailure.ts +9 -0
- package/dist/source/conversationMemberMentions.ts +63 -0
- package/dist/source/conversationMessageLinks.ts +153 -0
- package/dist/source/conversationMessageMemory.ts +45 -0
- package/dist/source/conversationPresets.ts +15 -0
- package/dist/source/conversationRows.ts +134 -0
- package/dist/source/conversationSessionMessage.ts +18 -0
- package/dist/source/conversationSkills.ts +26 -0
- package/dist/source/conversationTrajectory.ts +116 -0
- package/dist/source/conversationTranscript.ts +33 -0
- package/dist/source/conversationTurnSummaries.ts +57 -0
- package/dist/source/conversationViewProps.ts +486 -0
- package/dist/source/conversationWorkEntry.ts +104 -0
- package/dist/source/credential-account.ts +18 -0
- package/dist/source/dataPorts.gen.ts +2207 -0
- package/dist/source/decision-card.ts +87 -0
- package/dist/source/decisions.ts +43 -0
- package/dist/source/definition.ts +28 -0
- package/dist/source/derivedState.ts +55 -0
- package/dist/source/diagnosticData.ts +238 -0
- package/dist/source/diff-rendering.ts +6 -0
- package/dist/source/display-format.ts +14 -0
- package/dist/source/entity-names.ts +73 -0
- package/dist/source/events.ts +326 -0
- package/dist/source/executor-mode.ts +1 -0
- package/dist/source/executor.ts +623 -0
- package/dist/source/executorCapabilities.ts +89 -0
- package/dist/source/executorCard.ts +426 -0
- package/dist/source/executorCommandArgv.ts +114 -0
- package/dist/source/executorEffective.ts +99 -0
- package/dist/source/executorErrors.ts +73 -0
- package/dist/source/executorEvents.ts +258 -0
- package/dist/source/executorModelOptions.ts +179 -0
- package/dist/source/executorProcesses.ts +43 -0
- package/dist/source/executorSession.ts +508 -0
- package/dist/source/executorSpawn.ts +141 -0
- package/dist/source/fetch-ports.ts +1 -0
- package/dist/source/file-preview.ts +32 -0
- package/dist/source/index.ts +416 -0
- package/dist/source/inline-tag.ts +27 -0
- package/dist/source/instance-config.ts +31 -0
- package/dist/source/interval.ts +32 -0
- package/dist/source/jsonl.ts +21 -0
- package/dist/source/keyedSubscribers.ts +55 -0
- package/dist/source/logger.ts +16 -0
- package/dist/source/messages.ts +27 -0
- package/dist/source/model-picker.ts +82 -0
- package/dist/source/modelCatalogNotice.ts +34 -0
- package/dist/source/modelChoice.ts +371 -0
- package/dist/source/modelChoiceOptions.ts +309 -0
- package/dist/source/modelChoiceTraits.ts +133 -0
- package/dist/source/modelDisplayName.ts +42 -0
- package/dist/source/pending-requests.ts +56 -0
- package/dist/source/plugin-tools.ts +181 -0
- package/dist/source/pluginContextCommands.ts +224 -0
- package/dist/source/pluginContextProviders.ts +136 -0
- package/dist/source/pluginContextThreads.ts +83 -0
- package/dist/source/pluginContextWorkspace.ts +74 -0
- package/dist/source/process-operation.ts +291 -0
- package/dist/source/process-socket.ts +371 -0
- package/dist/source/process-stdin.ts +214 -0
- package/dist/source/projects.ts +31 -0
- package/dist/source/provider-settings.ts +343 -0
- package/dist/source/providerInstanceSelection.ts +72 -0
- package/dist/source/reasoningLevelFallback.ts +13 -0
- package/dist/source/runtime-maintenance.ts +307 -0
- package/dist/source/runtimes.ts +14 -0
- package/dist/source/selectAllCopy.ts +12 -0
- package/dist/source/session-history.ts +45 -0
- package/dist/source/settings-actions.ts +91 -0
- package/dist/source/settings-card-shape.ts +229 -0
- package/dist/source/settings-card.ts +311 -0
- package/dist/source/settings-ui.ts +48 -0
- package/dist/source/sign-in.ts +52 -0
- package/dist/source/slashCommands.ts +36 -0
- package/dist/source/slots.ts +243 -0
- package/dist/source/source-control.ts +5 -0
- package/dist/source/sse.ts +1 -0
- package/dist/source/system-text.ts +18 -0
- package/dist/source/teamView.ts +67 -0
- package/dist/source/testing.ts +203 -0
- package/dist/source/text-generation.ts +5 -0
- package/dist/source/threadAnnotation.ts +12 -0
- package/dist/source/threads.ts +77 -0
- package/dist/source/timeline-process.ts +87 -0
- package/dist/source/timeline-row-error.ts +14 -0
- package/dist/source/tool-display.ts +130 -0
- package/dist/source/traits-picker.ts +84 -0
- package/dist/source/ui-bridge-version.ts +64 -0
- package/dist/source/ui-hooks.ts +26 -0
- package/dist/source/ui-i18n.ts +1 -0
- package/dist/source/ui-media-query.ts +1 -0
- package/dist/source/ui-presenter-state.ts +6 -0
- package/dist/source/ui.ts +671 -0
- package/dist/source/uiHostCapabilities.ts +85 -0
- package/dist/source/uiMachineAdmission.ts +21 -0
- package/dist/source/uiSessionProjections.ts +19 -0
- package/dist/source/usage.ts +225 -0
- package/dist/source/version.ts +31 -0
- package/dist/source/workspace-path.ts +2 -0
- package/dist/source-control.d.ts +3 -0
- package/dist/source-control.d.ts.map +1 -0
- package/dist/source-control.js +3 -0
- package/dist/source-control.js.map +1 -0
- package/dist/sse.d.ts +2 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +2 -0
- package/dist/sse.js.map +1 -0
- package/dist/system-text.d.ts +4 -0
- package/dist/system-text.d.ts.map +1 -0
- package/dist/system-text.js +4 -0
- package/dist/system-text.js.map +1 -0
- package/dist/teamView.d.ts.map +1 -1
- package/dist/teamView.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/text-generation.d.ts +3 -0
- package/dist/text-generation.d.ts.map +1 -0
- package/dist/text-generation.js +3 -0
- package/dist/text-generation.js.map +1 -0
- package/dist/threadAnnotation.d.ts.map +1 -1
- package/dist/threadAnnotation.js.map +1 -1
- package/dist/threads.d.ts.map +1 -1
- package/dist/threads.js.map +1 -1
- package/dist/timeline-process.d.ts +32 -0
- package/dist/timeline-process.d.ts.map +1 -1
- package/dist/timeline-process.js.map +1 -1
- package/dist/timeline-row-error.d.ts.map +1 -1
- package/dist/timeline-row-error.js.map +1 -1
- package/dist/tool-display.d.ts.map +1 -1
- package/dist/tool-display.js.map +1 -1
- package/dist/traits-picker.d.ts.map +1 -1
- package/dist/traits-picker.js.map +1 -1
- package/dist/ui-bridge-version.d.ts.map +1 -1
- package/dist/ui-bridge-version.js.map +1 -1
- package/dist/ui-hooks.d.ts +14 -0
- package/dist/ui-hooks.d.ts.map +1 -0
- package/dist/ui-hooks.js +14 -0
- package/dist/ui-hooks.js.map +1 -0
- package/dist/ui-i18n.d.ts +2 -0
- package/dist/ui-i18n.d.ts.map +1 -0
- package/dist/ui-i18n.js +2 -0
- package/dist/ui-i18n.js.map +1 -0
- package/dist/ui-media-query.d.ts +2 -0
- package/dist/ui-media-query.d.ts.map +1 -0
- package/dist/ui-media-query.js +2 -0
- package/dist/ui-media-query.js.map +1 -0
- package/dist/ui-presenter-state.d.ts +2 -0
- package/dist/ui-presenter-state.d.ts.map +1 -0
- package/dist/ui-presenter-state.js +2 -0
- package/dist/ui-presenter-state.js.map +1 -0
- package/dist/ui.d.ts +2 -2
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js.map +1 -1
- package/dist/uiHostCapabilities.d.ts.map +1 -1
- package/dist/uiHostCapabilities.js.map +1 -1
- package/dist/uiMachineAdmission.d.ts.map +1 -1
- package/dist/uiMachineAdmission.js.map +1 -1
- package/dist/uiSessionProjections.d.ts.map +1 -1
- package/dist/uiSessionProjections.js.map +1 -1
- package/dist/usage.d.ts.map +1 -1
- package/dist/usage.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/workspace-path.d.ts +3 -0
- package/dist/workspace-path.d.ts.map +1 -0
- package/dist/workspace-path.js +3 -0
- package/dist/workspace-path.js.map +1 -0
- package/package.json +114 -3
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
// @effect-diagnostics globalDate:off nodeBuiltinImport:off - 纯 TS/Promise 工具,被官方插件打进各自的 bundle,不碰 Effect 运行时。
|
|
2
|
+
/**
|
|
3
|
+
* 转录 jsonl 的逐行读取,外加超长行的流式字段筛选。
|
|
4
|
+
*
|
|
5
|
+
* 转录里偶尔有一行大到几十 MB(工具输出、整文件写入的 input)。`ctx.fs.readLines`
|
|
6
|
+
* 会把整行读成一个字符串,这样的行既占内存又只能被丢掉。这里改走字节流:
|
|
7
|
+
* - 不超过 `maxLineChars` 的行照旧交回完整字符串,由调用方 `JSON.parse`,行为不变;
|
|
8
|
+
* - 超过的行不再整行落成字符串,而是边读边按字段清单解析,只把清单里的字段装配
|
|
9
|
+
* 成对象,其余值读过即弃;清单内的长字符串只留头尾各 `maxChars` 个字符。
|
|
10
|
+
*
|
|
11
|
+
* 字段清单是调用方真正读取的字段,不是对记录结构的另一份描述;清单外的字段在
|
|
12
|
+
* 超长行里不存在。
|
|
13
|
+
*
|
|
14
|
+
* 官方插件(session-import、agent-claude)共用,各自用 esbuild 打进自己的 bundle:插件之间
|
|
15
|
+
* 不能互相 import,所以这份读取器放在独立的工作区包里。
|
|
16
|
+
*
|
|
17
|
+
* @module ycodium-jsonl-stream
|
|
18
|
+
*/
|
|
19
|
+
const DEFAULT_MAX_RETAINED_CHARS = 8_000_000;
|
|
20
|
+
const MAX_DEPTH = 128;
|
|
21
|
+
/** 键长超过它就不再逐字符保留:清单里没有这么长的键。 */
|
|
22
|
+
const MAX_KEY_CHARS = 256;
|
|
23
|
+
const MAX_BARE_CHARS = 64;
|
|
24
|
+
const NUMBER_PATTERN = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/u;
|
|
25
|
+
/**
|
|
26
|
+
* 一条 JSON 记录的增量解析器:一次一个字符块,行尾 `finish` 取结果。
|
|
27
|
+
* 任何不合法的输入都只把这一条记录标成作废,不抛。
|
|
28
|
+
*/
|
|
29
|
+
export class OversizedRecordParser {
|
|
30
|
+
#fields;
|
|
31
|
+
#budget;
|
|
32
|
+
#options;
|
|
33
|
+
#retained = 0;
|
|
34
|
+
#malformed = false;
|
|
35
|
+
#done = false;
|
|
36
|
+
#result = undefined;
|
|
37
|
+
#stack = [];
|
|
38
|
+
// 词法状态。
|
|
39
|
+
#inString = false;
|
|
40
|
+
#stringIsKey = false;
|
|
41
|
+
#escape = false;
|
|
42
|
+
#unicodeLeft = 0;
|
|
43
|
+
#unicodeValue = 0;
|
|
44
|
+
#bare = "";
|
|
45
|
+
// 当前字符串的保留规则与累积。
|
|
46
|
+
#strObserver;
|
|
47
|
+
#strRetain = false;
|
|
48
|
+
#strCap = undefined;
|
|
49
|
+
#strHead = "";
|
|
50
|
+
#strTail = "";
|
|
51
|
+
#strLength = 0;
|
|
52
|
+
#key = "";
|
|
53
|
+
#keyOverflow = false;
|
|
54
|
+
// 值之间的位置。
|
|
55
|
+
#expectKey = false;
|
|
56
|
+
#expectColon = false;
|
|
57
|
+
#expectComma = false;
|
|
58
|
+
#expectValue = true;
|
|
59
|
+
constructor(fields, maxRetainedChars = DEFAULT_MAX_RETAINED_CHARS, options) {
|
|
60
|
+
this.#fields = fields;
|
|
61
|
+
this.#budget = maxRetainedChars;
|
|
62
|
+
this.#options = options;
|
|
63
|
+
}
|
|
64
|
+
write(chunk) {
|
|
65
|
+
if (this.#malformed)
|
|
66
|
+
return;
|
|
67
|
+
try {
|
|
68
|
+
this.#consume(chunk);
|
|
69
|
+
}
|
|
70
|
+
catch (cause) {
|
|
71
|
+
if (cause instanceof MalformedRecord) {
|
|
72
|
+
this.#malformed = true;
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
throw cause;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** 完整且合法才返回记录;其余(含空行)返回 `undefined`。 */
|
|
79
|
+
finish() {
|
|
80
|
+
if (this.#malformed)
|
|
81
|
+
return undefined;
|
|
82
|
+
try {
|
|
83
|
+
if (this.#bare.length > 0)
|
|
84
|
+
this.#finishBare();
|
|
85
|
+
}
|
|
86
|
+
catch (cause) {
|
|
87
|
+
if (cause instanceof MalformedRecord)
|
|
88
|
+
return undefined;
|
|
89
|
+
throw cause;
|
|
90
|
+
}
|
|
91
|
+
if (!this.#done || this.#inString || this.#result === SKIPPED)
|
|
92
|
+
return undefined;
|
|
93
|
+
return this.#result;
|
|
94
|
+
}
|
|
95
|
+
#fail() {
|
|
96
|
+
throw new MalformedRecord();
|
|
97
|
+
}
|
|
98
|
+
#charge(chars) {
|
|
99
|
+
this.#retained += chars;
|
|
100
|
+
if (this.#retained > this.#budget)
|
|
101
|
+
this.#fail();
|
|
102
|
+
}
|
|
103
|
+
#consume(chunk) {
|
|
104
|
+
const n = chunk.length;
|
|
105
|
+
let i = 0;
|
|
106
|
+
while (i < n) {
|
|
107
|
+
if (this.#inString) {
|
|
108
|
+
i = this.#consumeString(chunk, i);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const c = chunk.charCodeAt(i);
|
|
112
|
+
if (this.#bare.length > 0) {
|
|
113
|
+
// 数字与 true/false/null 的字符;遇到分隔符就结算。
|
|
114
|
+
if (isBareChar(c)) {
|
|
115
|
+
if (this.#bare.length >= MAX_BARE_CHARS)
|
|
116
|
+
this.#fail();
|
|
117
|
+
this.#bare += chunk[i];
|
|
118
|
+
i += 1;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
this.#finishBare();
|
|
122
|
+
}
|
|
123
|
+
i += 1;
|
|
124
|
+
// 空白。
|
|
125
|
+
if (c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d)
|
|
126
|
+
continue;
|
|
127
|
+
if (this.#done)
|
|
128
|
+
this.#fail();
|
|
129
|
+
switch (c) {
|
|
130
|
+
case 0x7b: // {
|
|
131
|
+
this.#requireValue();
|
|
132
|
+
this.#openContainer(false);
|
|
133
|
+
break;
|
|
134
|
+
case 0x5b: // [
|
|
135
|
+
this.#requireValue();
|
|
136
|
+
this.#openContainer(true);
|
|
137
|
+
break;
|
|
138
|
+
case 0x7d: // }
|
|
139
|
+
this.#closeContainer(false);
|
|
140
|
+
break;
|
|
141
|
+
case 0x5d: // ]
|
|
142
|
+
this.#closeContainer(true);
|
|
143
|
+
break;
|
|
144
|
+
case 0x2c: // ,
|
|
145
|
+
this.#comma();
|
|
146
|
+
break;
|
|
147
|
+
case 0x3a: // :
|
|
148
|
+
if (!this.#expectColon)
|
|
149
|
+
this.#fail();
|
|
150
|
+
this.#expectColon = false;
|
|
151
|
+
this.#expectValue = true;
|
|
152
|
+
break;
|
|
153
|
+
case 0x22: // "
|
|
154
|
+
this.#openString();
|
|
155
|
+
break;
|
|
156
|
+
default:
|
|
157
|
+
if (isBareChar(c)) {
|
|
158
|
+
this.#requireValue();
|
|
159
|
+
this.#bare = chunk[i - 1] ?? "";
|
|
160
|
+
}
|
|
161
|
+
else
|
|
162
|
+
this.#fail();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
#top() {
|
|
167
|
+
return this.#stack[this.#stack.length - 1];
|
|
168
|
+
}
|
|
169
|
+
#requireValue() {
|
|
170
|
+
if (!this.#expectValue)
|
|
171
|
+
this.#fail();
|
|
172
|
+
this.#expectValue = false;
|
|
173
|
+
}
|
|
174
|
+
/** 当前要读的值(刚要开始)落在什么模式;`isContainer` 决定 scalarOnly 清单项是否适用。 */
|
|
175
|
+
#childMode(isContainer) {
|
|
176
|
+
const parent = this.#top();
|
|
177
|
+
if (parent === undefined)
|
|
178
|
+
return this.#classify([], isContainer);
|
|
179
|
+
if (parent.mode === "skip")
|
|
180
|
+
return { mode: "skip", cap: undefined, path: [] };
|
|
181
|
+
if (parent.mode === "keep")
|
|
182
|
+
return { mode: "keep", cap: parent.cap, path: [] };
|
|
183
|
+
const segment = parent.isArray ? String(parent.index) : (parent.key ?? "");
|
|
184
|
+
if (parent.skipValue)
|
|
185
|
+
return { mode: "skip", cap: undefined, path: [] };
|
|
186
|
+
return this.#classify([...parent.path, segment], isContainer);
|
|
187
|
+
}
|
|
188
|
+
#classify(path, isContainer) {
|
|
189
|
+
let descend = false;
|
|
190
|
+
for (const field of this.#fields) {
|
|
191
|
+
const fieldPath = field.path;
|
|
192
|
+
if (fieldPath.length <= path.length) {
|
|
193
|
+
if (field.scalarOnly === true && (isContainer || fieldPath.length !== path.length)) {
|
|
194
|
+
// scalarOnly 项只管它自己那个位置,且只管标量。
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (matchesPrefix(fieldPath, path, fieldPath.length)) {
|
|
198
|
+
return { mode: "keep", cap: field.maxChars, path };
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else if (matchesPrefix(fieldPath, path, path.length)) {
|
|
202
|
+
descend = true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return { mode: descend ? "descend" : "skip", cap: undefined, path };
|
|
206
|
+
}
|
|
207
|
+
#openContainer(isArray) {
|
|
208
|
+
if (this.#stack.length >= MAX_DEPTH)
|
|
209
|
+
this.#fail();
|
|
210
|
+
const { mode, cap, path } = this.#childMode(true);
|
|
211
|
+
const keeping = mode !== "skip";
|
|
212
|
+
let target = null;
|
|
213
|
+
if (keeping) {
|
|
214
|
+
this.#charge(16);
|
|
215
|
+
target = isArray ? [] : {};
|
|
216
|
+
}
|
|
217
|
+
this.#stack.push({ isArray, mode, path, cap, target, key: null, skipValue: false, index: 0 });
|
|
218
|
+
this.#expectValue = isArray;
|
|
219
|
+
this.#expectKey = !isArray;
|
|
220
|
+
this.#expectComma = false;
|
|
221
|
+
this.#expectColon = false;
|
|
222
|
+
}
|
|
223
|
+
#closeContainer(isArray) {
|
|
224
|
+
const top = this.#top();
|
|
225
|
+
if (top === undefined || top.isArray !== isArray)
|
|
226
|
+
this.#fail();
|
|
227
|
+
// 刚开就关的空容器合法;逗号之后紧接关括号、或键后没有值都不合法。
|
|
228
|
+
if (!this.#expectComma && top.index > 0)
|
|
229
|
+
this.#fail();
|
|
230
|
+
if (this.#expectColon || (!isArray && this.#expectValue))
|
|
231
|
+
this.#fail();
|
|
232
|
+
this.#stack.pop();
|
|
233
|
+
this.#expectValue = false;
|
|
234
|
+
this.#expectKey = false;
|
|
235
|
+
this.#expectColon = false;
|
|
236
|
+
this.#expectComma = true;
|
|
237
|
+
const empty = top.target !== null && Object.keys(top.target).length === 0;
|
|
238
|
+
this.#store(this.#options?.pruneEmpty && top.mode === "descend" && empty && this.#stack.length > 0
|
|
239
|
+
? SKIPPED
|
|
240
|
+
: (top.target ?? SKIPPED));
|
|
241
|
+
}
|
|
242
|
+
#comma() {
|
|
243
|
+
const top = this.#top();
|
|
244
|
+
if (top === undefined || !this.#expectComma)
|
|
245
|
+
this.#fail();
|
|
246
|
+
this.#expectComma = false;
|
|
247
|
+
if (top.isArray) {
|
|
248
|
+
this.#expectValue = true;
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
this.#expectKey = true;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/** 一个值读完:交给外层容器,或成为整条记录。 */
|
|
255
|
+
#store(value) {
|
|
256
|
+
const parent = this.#top();
|
|
257
|
+
if (parent === undefined) {
|
|
258
|
+
this.#result = value;
|
|
259
|
+
this.#done = true;
|
|
260
|
+
this.#expectComma = false;
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
this.#expectComma = true;
|
|
264
|
+
if (parent.isArray) {
|
|
265
|
+
parent.index += 1;
|
|
266
|
+
if (parent.target !== null && value !== SKIPPED) {
|
|
267
|
+
parent.target.push(value);
|
|
268
|
+
this.#charge(8);
|
|
269
|
+
}
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
parent.index += 1;
|
|
273
|
+
const key = parent.key;
|
|
274
|
+
parent.key = null;
|
|
275
|
+
parent.skipValue = false;
|
|
276
|
+
if (parent.target !== null && value !== SKIPPED && key !== null) {
|
|
277
|
+
// defineProperty 才能像 JSON.parse 一样把 "__proto__" 当普通自有键。
|
|
278
|
+
Object.defineProperty(parent.target, key, {
|
|
279
|
+
value,
|
|
280
|
+
enumerable: true,
|
|
281
|
+
writable: true,
|
|
282
|
+
configurable: true,
|
|
283
|
+
});
|
|
284
|
+
this.#charge(key.length + 8);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
#openString() {
|
|
288
|
+
const parent = this.#top();
|
|
289
|
+
const asKey = parent !== undefined && !parent.isArray && this.#expectKey;
|
|
290
|
+
if (!asKey)
|
|
291
|
+
this.#requireValue();
|
|
292
|
+
this.#inString = true;
|
|
293
|
+
this.#stringIsKey = asKey;
|
|
294
|
+
this.#escape = false;
|
|
295
|
+
this.#unicodeLeft = 0;
|
|
296
|
+
this.#strLength = 0;
|
|
297
|
+
this.#strHead = "";
|
|
298
|
+
this.#strTail = "";
|
|
299
|
+
this.#key = "";
|
|
300
|
+
if (asKey) {
|
|
301
|
+
this.#keyOverflow = false;
|
|
302
|
+
this.#strRetain = true;
|
|
303
|
+
this.#strCap = undefined;
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const { mode, cap, path } = this.#childMode(false);
|
|
307
|
+
this.#strObserver = this.#fields.find((field) => field.path.length === path.length && matchesPrefix(field.path, path, path.length));
|
|
308
|
+
this.#strRetain = mode === "keep" && this.#strObserver?.onChunk === undefined;
|
|
309
|
+
this.#strCap = cap;
|
|
310
|
+
}
|
|
311
|
+
/** 字符串里的一个解码后片段;按保留规则累积。 */
|
|
312
|
+
#append(text) {
|
|
313
|
+
if (text.length === 0)
|
|
314
|
+
return;
|
|
315
|
+
if (this.#stringIsKey) {
|
|
316
|
+
if (this.#keyOverflow)
|
|
317
|
+
return;
|
|
318
|
+
this.#key += text;
|
|
319
|
+
if (this.#key.length > MAX_KEY_CHARS) {
|
|
320
|
+
this.#keyOverflow = true;
|
|
321
|
+
this.#key = "";
|
|
322
|
+
}
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
this.#strLength += text.length;
|
|
326
|
+
this.#strObserver?.onChunk?.(text);
|
|
327
|
+
if (!this.#strRetain)
|
|
328
|
+
return;
|
|
329
|
+
const cap = this.#strCap;
|
|
330
|
+
if (cap === undefined) {
|
|
331
|
+
this.#strHead += text;
|
|
332
|
+
this.#charge(text.length);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (this.#strHead.length < cap) {
|
|
336
|
+
const room = cap - this.#strHead.length;
|
|
337
|
+
this.#strHead += text.slice(0, room);
|
|
338
|
+
text = text.slice(room);
|
|
339
|
+
if (text.length === 0)
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
this.#strTail += text;
|
|
343
|
+
if (this.#strTail.length > cap * 2)
|
|
344
|
+
this.#strTail = this.#strTail.slice(-cap);
|
|
345
|
+
}
|
|
346
|
+
#consumeString(chunk, start) {
|
|
347
|
+
const n = chunk.length;
|
|
348
|
+
let i = start;
|
|
349
|
+
while (i < n) {
|
|
350
|
+
if (this.#unicodeLeft > 0) {
|
|
351
|
+
const digit = hexValue(chunk.charCodeAt(i));
|
|
352
|
+
if (digit < 0)
|
|
353
|
+
this.#fail();
|
|
354
|
+
this.#unicodeValue = this.#unicodeValue * 16 + digit;
|
|
355
|
+
this.#unicodeLeft -= 1;
|
|
356
|
+
i += 1;
|
|
357
|
+
if (this.#unicodeLeft === 0)
|
|
358
|
+
this.#append(String.fromCharCode(this.#unicodeValue));
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
if (this.#escape) {
|
|
362
|
+
this.#escape = false;
|
|
363
|
+
const c = chunk[i] ?? "";
|
|
364
|
+
i += 1;
|
|
365
|
+
switch (c) {
|
|
366
|
+
case '"':
|
|
367
|
+
case "\\":
|
|
368
|
+
case "/":
|
|
369
|
+
this.#append(c);
|
|
370
|
+
break;
|
|
371
|
+
case "b":
|
|
372
|
+
this.#append("\b");
|
|
373
|
+
break;
|
|
374
|
+
case "f":
|
|
375
|
+
this.#append("\f");
|
|
376
|
+
break;
|
|
377
|
+
case "n":
|
|
378
|
+
this.#append("\n");
|
|
379
|
+
break;
|
|
380
|
+
case "r":
|
|
381
|
+
this.#append("\r");
|
|
382
|
+
break;
|
|
383
|
+
case "t":
|
|
384
|
+
this.#append("\t");
|
|
385
|
+
break;
|
|
386
|
+
case "u":
|
|
387
|
+
this.#unicodeLeft = 4;
|
|
388
|
+
this.#unicodeValue = 0;
|
|
389
|
+
break;
|
|
390
|
+
default:
|
|
391
|
+
this.#fail();
|
|
392
|
+
}
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
// 普通字符:一路扫到下一个引号、反斜杠或控制字符。
|
|
396
|
+
const runStart = i;
|
|
397
|
+
while (i < n) {
|
|
398
|
+
const c = chunk.charCodeAt(i);
|
|
399
|
+
if (c === 0x22 || c === 0x5c || c < 0x20)
|
|
400
|
+
break;
|
|
401
|
+
i += 1;
|
|
402
|
+
}
|
|
403
|
+
if (i > runStart)
|
|
404
|
+
this.#append(chunk.slice(runStart, i));
|
|
405
|
+
if (i >= n)
|
|
406
|
+
break;
|
|
407
|
+
const c = chunk.charCodeAt(i);
|
|
408
|
+
i += 1;
|
|
409
|
+
if (c === 0x5c) {
|
|
410
|
+
this.#escape = true;
|
|
411
|
+
}
|
|
412
|
+
else if (c === 0x22) {
|
|
413
|
+
this.#inString = false;
|
|
414
|
+
this.#endString();
|
|
415
|
+
return i;
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
this.#fail(); // 字符串里不许有裸控制字符。
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return i;
|
|
422
|
+
}
|
|
423
|
+
#endString() {
|
|
424
|
+
if (this.#stringIsKey) {
|
|
425
|
+
const parent = this.#top();
|
|
426
|
+
if (parent === undefined)
|
|
427
|
+
this.#fail();
|
|
428
|
+
parent.key = this.#key;
|
|
429
|
+
parent.skipValue = this.#keyOverflow;
|
|
430
|
+
this.#key = "";
|
|
431
|
+
this.#expectKey = false;
|
|
432
|
+
this.#expectColon = true;
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
this.#strObserver?.onEnd?.(this.#strLength);
|
|
436
|
+
this.#strObserver = undefined;
|
|
437
|
+
if (!this.#strRetain) {
|
|
438
|
+
this.#store(SKIPPED);
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const cap = this.#strCap;
|
|
442
|
+
let text = this.#strHead;
|
|
443
|
+
if (cap !== undefined) {
|
|
444
|
+
let tail = this.#strTail;
|
|
445
|
+
if (tail.length > cap)
|
|
446
|
+
tail = tail.slice(-cap);
|
|
447
|
+
if (this.#strLength > text.length + tail.length) {
|
|
448
|
+
// 确有省略:别把代理对从边界中间劈开。
|
|
449
|
+
if (isHighSurrogate(text.charCodeAt(text.length - 1)))
|
|
450
|
+
text = text.slice(0, -1);
|
|
451
|
+
if (isLowSurrogate(tail.charCodeAt(0)))
|
|
452
|
+
tail = tail.slice(1);
|
|
453
|
+
const omitted = this.#strLength - text.length - tail.length;
|
|
454
|
+
text = `${text}\n[… ${omitted} chars omitted …]\n${tail}`;
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
text = `${text}${tail}`;
|
|
458
|
+
}
|
|
459
|
+
this.#charge(text.length);
|
|
460
|
+
}
|
|
461
|
+
this.#strHead = "";
|
|
462
|
+
this.#strTail = "";
|
|
463
|
+
this.#store(text);
|
|
464
|
+
}
|
|
465
|
+
#finishBare() {
|
|
466
|
+
const text = this.#bare;
|
|
467
|
+
this.#bare = "";
|
|
468
|
+
const { mode, path } = this.#childMode(false);
|
|
469
|
+
let value;
|
|
470
|
+
if (text === "true")
|
|
471
|
+
value = true;
|
|
472
|
+
else if (text === "false")
|
|
473
|
+
value = false;
|
|
474
|
+
else if (text === "null")
|
|
475
|
+
value = null;
|
|
476
|
+
else if (NUMBER_PATTERN.test(text))
|
|
477
|
+
value = Number(text);
|
|
478
|
+
else
|
|
479
|
+
this.#fail();
|
|
480
|
+
const observer = this.#fields.find((field) => field.path.length === path.length && matchesPrefix(field.path, path, path.length));
|
|
481
|
+
if (observer?.onScalar !== undefined) {
|
|
482
|
+
observer.onScalar(value);
|
|
483
|
+
this.#store(SKIPPED);
|
|
484
|
+
}
|
|
485
|
+
else
|
|
486
|
+
this.#store(mode === "keep" ? value : SKIPPED);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
const SKIPPED = Symbol("skipped");
|
|
490
|
+
class MalformedRecord extends Error {
|
|
491
|
+
}
|
|
492
|
+
function isBareChar(c) {
|
|
493
|
+
return ((c >= 0x30 && c <= 0x39) || // 0-9
|
|
494
|
+
(c >= 0x61 && c <= 0x7a) || // a-z
|
|
495
|
+
(c >= 0x41 && c <= 0x5a) || // A-Z
|
|
496
|
+
c === 0x2b ||
|
|
497
|
+
c === 0x2d ||
|
|
498
|
+
c === 0x2e);
|
|
499
|
+
}
|
|
500
|
+
function hexValue(c) {
|
|
501
|
+
if (c >= 0x30 && c <= 0x39)
|
|
502
|
+
return c - 0x30;
|
|
503
|
+
if (c >= 0x61 && c <= 0x66)
|
|
504
|
+
return c - 0x61 + 10;
|
|
505
|
+
if (c >= 0x41 && c <= 0x46)
|
|
506
|
+
return c - 0x41 + 10;
|
|
507
|
+
return -1;
|
|
508
|
+
}
|
|
509
|
+
const isHighSurrogate = (c) => c >= 0xd800 && c <= 0xdbff;
|
|
510
|
+
const isLowSurrogate = (c) => c >= 0xdc00 && c <= 0xdfff;
|
|
511
|
+
function matchesPrefix(pattern, path, length) {
|
|
512
|
+
for (let index = 0; index < length; index += 1) {
|
|
513
|
+
const expected = pattern[index];
|
|
514
|
+
if (expected !== "*" && expected !== path[index])
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* 一行转成记录:没超长的先过 `accepts` 预筛再 `JSON.parse`,超长的已经是筛好的记录。
|
|
521
|
+
* 解析失败(写到一半的尾行是常态)返回 `undefined`。
|
|
522
|
+
*/
|
|
523
|
+
export function jsonlEntryRecord(entry, accepts) {
|
|
524
|
+
if ("oversized" in entry)
|
|
525
|
+
return entry.oversized;
|
|
526
|
+
if (!accepts(entry.line))
|
|
527
|
+
return undefined;
|
|
528
|
+
try {
|
|
529
|
+
return JSON.parse(entry.line);
|
|
530
|
+
}
|
|
531
|
+
catch {
|
|
532
|
+
return undefined;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* 逐行读一份 jsonl。行以 `\n` 结尾(尾部 `\r` 去掉),空行不吐。
|
|
537
|
+
*
|
|
538
|
+
* 读失败(文件不存在、权限)原样抛出,由调用方决定是空还是错。
|
|
539
|
+
*/
|
|
540
|
+
export async function* readJsonlEntries(fs, path, options) {
|
|
541
|
+
const decoder = new TextDecoder("utf-8");
|
|
542
|
+
let pieces = [];
|
|
543
|
+
let pending = 0;
|
|
544
|
+
let parser = null;
|
|
545
|
+
const startOversized = () => {
|
|
546
|
+
const next = new OversizedRecordParser(options.fields, options.maxRetainedChars);
|
|
547
|
+
for (const piece of pieces)
|
|
548
|
+
next.write(piece);
|
|
549
|
+
pieces = [];
|
|
550
|
+
pending = 0;
|
|
551
|
+
return next;
|
|
552
|
+
};
|
|
553
|
+
// 把一段不含换行的文本接到当前行上。
|
|
554
|
+
const append = (text) => {
|
|
555
|
+
if (text.length === 0)
|
|
556
|
+
return;
|
|
557
|
+
if (parser !== null) {
|
|
558
|
+
parser.write(text);
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
pieces.push(text);
|
|
562
|
+
pending += text.length;
|
|
563
|
+
if (pending > options.maxLineChars)
|
|
564
|
+
parser = startOversized();
|
|
565
|
+
};
|
|
566
|
+
const takeLine = () => {
|
|
567
|
+
if (parser !== null) {
|
|
568
|
+
const record = parser.finish();
|
|
569
|
+
parser = null;
|
|
570
|
+
return { oversized: record };
|
|
571
|
+
}
|
|
572
|
+
if (pending === 0)
|
|
573
|
+
return null;
|
|
574
|
+
let line = pieces.length === 1 ? (pieces[0] ?? "") : pieces.join("");
|
|
575
|
+
pieces = [];
|
|
576
|
+
pending = 0;
|
|
577
|
+
if (line.endsWith("\r"))
|
|
578
|
+
line = line.slice(0, -1);
|
|
579
|
+
return line.length === 0 ? null : { line };
|
|
580
|
+
};
|
|
581
|
+
const feed = function* (text) {
|
|
582
|
+
let from = 0;
|
|
583
|
+
while (from <= text.length) {
|
|
584
|
+
const newline = text.indexOf("\n", from);
|
|
585
|
+
if (newline < 0) {
|
|
586
|
+
append(text.slice(from));
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
append(text.slice(from, newline));
|
|
590
|
+
const entry = takeLine();
|
|
591
|
+
if (entry !== null)
|
|
592
|
+
yield entry;
|
|
593
|
+
from = newline + 1;
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
for await (const chunk of fs.createReadStream(path)) {
|
|
597
|
+
yield* feed(decoder.decode(chunk, { stream: true }));
|
|
598
|
+
}
|
|
599
|
+
yield* feed(decoder.decode());
|
|
600
|
+
const last = takeLine();
|
|
601
|
+
if (last !== null)
|
|
602
|
+
yield last;
|
|
603
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type AppendedJsonlPosition } from "./appendedJsonl.ts";
|
|
2
|
+
/** 落盘时把重复的字符串(模型名、会话 id)驻留成下标。 */
|
|
3
|
+
/**
|
|
4
|
+
* 落盘缓存的驻留表与文件表。版本不对、表不是字符串数组、或 files 不是对象时整份作废。
|
|
5
|
+
* 驻留表必须全是字符串:混进一个数字会越过后面的 undefined 守卫,落到记录的 model 里,
|
|
6
|
+
* 到宿主按模型名查价时才崩。
|
|
7
|
+
*/
|
|
8
|
+
export type ScanCacheTables = {
|
|
9
|
+
readonly models: readonly string[];
|
|
10
|
+
readonly sessions: readonly string[];
|
|
11
|
+
readonly files: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
export declare function decodeScanCacheTables(document: unknown, version: number): ScanCacheTables | undefined;
|
|
14
|
+
export declare function createStringTable(): {
|
|
15
|
+
readonly values: readonly string[];
|
|
16
|
+
readonly intern: (value: string) => number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* 一个文件的缓存条目落盘:`s` 大小、`m` 修改时间、`r` / `t` 行记录与末尾段记录(按 `serialize`
|
|
20
|
+
* 的行式形状)、`o` / `gl` / `gh` 续读位置。执行器自己的字段接在后面。
|
|
21
|
+
*/
|
|
22
|
+
export declare function encodeCachedFile<R, Row>(entry: {
|
|
23
|
+
readonly size: number;
|
|
24
|
+
readonly mtimeMs: number;
|
|
25
|
+
readonly records: readonly R[];
|
|
26
|
+
readonly tailRecords: readonly R[];
|
|
27
|
+
readonly position: AppendedJsonlPosition;
|
|
28
|
+
}, serialize: (record: R) => Row): {
|
|
29
|
+
s: number;
|
|
30
|
+
m: number;
|
|
31
|
+
r: Row[];
|
|
32
|
+
t: Row[];
|
|
33
|
+
o: number;
|
|
34
|
+
gl: number;
|
|
35
|
+
gh: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 落盘的续读位置:`o` 偏移、`gl` guard 长度、`gh` guard 哈希。
|
|
39
|
+
*
|
|
40
|
+
* 位置字段会变成读取的字节偏移与窗口长度:越界的值必须整条拒掉(返回 undefined),否则一个
|
|
41
|
+
* 离谱的 guard 长度会让这个文件的每次解析都失败,用量悄悄丢掉,而不是付一次冷重扫。
|
|
42
|
+
*/
|
|
43
|
+
export declare function decodeCachedPosition(entry: {
|
|
44
|
+
readonly o?: unknown;
|
|
45
|
+
readonly gl?: unknown;
|
|
46
|
+
readonly gh?: unknown;
|
|
47
|
+
}): AppendedJsonlPosition | undefined;
|
|
48
|
+
export type PruneOptions = {
|
|
49
|
+
/** 这次遍历刚看到的文件。只在遍历过的窗口里有意义。 */
|
|
50
|
+
readonly livePaths: ReadonlySet<string>;
|
|
51
|
+
/**
|
|
52
|
+
* 遍历实际走完的根。文件不在 `livePaths` 里,只有它的根确实走过才说明它没了:这次解析不出
|
|
53
|
+
* 目录的根,它的热条目不能被清掉。
|
|
54
|
+
*/
|
|
55
|
+
readonly walkedRoots: readonly string[];
|
|
56
|
+
/** 遍历窗口的起点;比它更早的条目当时没去找。 */
|
|
57
|
+
readonly windowStartMs: number;
|
|
58
|
+
/** 比它更老的条目不论如何都丢。 */
|
|
59
|
+
readonly retentionCutoffMs: number;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* 丢掉过期条目,以及文件已经消失的条目。返回丢掉的条数。
|
|
63
|
+
*
|
|
64
|
+
* 遍历只覆盖请求的窗口,所以「不在 livePaths 里」只对窗口内的条目说明文件被删了。
|
|
65
|
+
* 把遍历没碰到的全剪掉,会让每次看 7 天都把 30 天的条目逐出去。
|
|
66
|
+
*/
|
|
67
|
+
export declare function pruneScanCache<T extends {
|
|
68
|
+
readonly mtimeMs: number;
|
|
69
|
+
}>(cache: Map<string, T>, options: PruneOptions): number;
|