@fbincon/claude-code-statusline 3.5.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -74
- package/candidate.json +437 -315
- package/node_modules/@fbincon/statusline-cli/dist/src/config/arguments.js +23 -5
- package/node_modules/@fbincon/statusline-cli/dist/src/config/arguments.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.js +43 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/config/commands.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/config/profiles.js +2 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/config/profiles.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/config/transfer.js +5 -3
- package/node_modules/@fbincon/statusline-cli/dist/src/config/transfer.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/service.js +24 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/diagnostics/service.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/help.js +4 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/help.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/doctor.js +2 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/doctor.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/install.js +2 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/install.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/model.js +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/mods.js +2 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/integration/mods.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/main.js +19 -3
- package/node_modules/@fbincon/statusline-cli/dist/src/main.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/journal.js +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/recovery/journal.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/rendering/environment.js +46 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/rendering/environment.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/protocol.js +11 -3
- package/node_modules/@fbincon/statusline-cli/dist/src/runtime/live/protocol.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic-state.d.ts +35 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic-state.js +75 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic-state.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic.d.ts +12 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic.js +99 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/automatic.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/command.d.ts +3 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/command.js +119 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/command.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/context.d.ts +4 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/context.js +35 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/context.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/lifecycle.d.ts +6 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/lifecycle.js +12 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/lifecycle.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/providers.d.ts +8 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/providers.js +118 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/providers.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/service.d.ts +40 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/service.js +425 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/sources/service.js.map +1 -0
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.d.ts +2 -2
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js +30 -1
- package/node_modules/@fbincon/statusline-cli/dist/src/ui/protocol.js.map +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/.claude-plugin/plugin.json +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/hooks/register.ts +15 -5
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/backend.ts +15 -8
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/keys.ts +10 -2
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/client/settings.ts +2 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/appearance.ts +26 -6
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/cost-rate.ts +9 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/draft.ts +8 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/forms.ts +4 -2
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/group-manager.ts +102 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/groups.ts +89 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/indicators.ts +20 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/source-manager.ts +304 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/editor/source-validation.ts +46 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/generated-contracts.ts +94 -11
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/generated-locales.ts +1020 -6
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/i18n/presentation.ts +3 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/lib/session.ts +2 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/resource-manifest.json +23 -17
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/draw.ts +9 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-native/ui/client/help.ts +2 -0
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/.claude-plugin/plugin.json +7 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/hooks/observe.ts +27 -2
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/lib/generated-contracts.ts +1 -1
- package/node_modules/@fbincon/statusline-cli/resources/statusline-runtime/resource-manifest.json +6 -6
- package/node_modules/@fbincon/statusline-core/dist/src/config/catalog-data.d.ts +214 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/catalog-data.js +418 -0
- package/node_modules/@fbincon/statusline-core/dist/src/config/catalog-data.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.js +2 -2
- package/node_modules/@fbincon/statusline-core/dist/src/config/defaults.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/display.d.ts +2 -2
- package/node_modules/@fbincon/statusline-core/dist/src/config/display.js +31 -14
- package/node_modules/@fbincon/statusline-core/dist/src/config/display.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/editor-fields.js +13 -10
- package/node_modules/@fbincon/statusline-core/dist/src/config/editor-fields.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.js +11 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/formatting.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/import-review.js +6 -2
- package/node_modules/@fbincon/statusline-core/dist/src/config/import-review.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/instances.js +14 -7
- package/node_modules/@fbincon/statusline-core/dist/src/config/instances.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/presets.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/presets.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/profiles.js +2 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/profiles.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/config/transfer.js +5 -3
- package/node_modules/@fbincon/statusline-core/dist/src/config/transfer.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.d.ts +2 -2
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.js +2 -2
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/generated-catalog.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/runtime.d.ts +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/runtime.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.d.ts +170 -9
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js +5 -5
- package/node_modules/@fbincon/statusline-core/dist/src/contracts/ui.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/appearance.d.ts +4 -2
- package/node_modules/@fbincon/statusline-core/dist/src/editor/appearance.js +31 -6
- package/node_modules/@fbincon/statusline-core/dist/src/editor/appearance.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js +18 -8
- package/node_modules/@fbincon/statusline-core/dist/src/editor/backend.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/cost-rate.d.ts +7 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/cost-rate.js +8 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/cost-rate.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js +6 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/draft.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.js +4 -2
- package/node_modules/@fbincon/statusline-core/dist/src/editor/forms.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.d.ts +23 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.js +131 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/group-manager.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/groups.d.ts +18 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/groups.js +103 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/groups.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/indicators.d.ts +11 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/indicators.js +18 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/indicators.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.d.ts +40 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.js +279 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-manager.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-validation.d.ts +2 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-validation.js +47 -0
- package/node_modules/@fbincon/statusline-core/dist/src/editor/source-validation.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/extensions/model.d.ts +27 -0
- package/node_modules/@fbincon/statusline-core/dist/src/extensions/model.js +238 -0
- package/node_modules/@fbincon/statusline-core/dist/src/extensions/model.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/extensions/portable.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/extensions/portable.js +6 -0
- package/node_modules/@fbincon/statusline-core/dist/src/extensions/portable.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.d.ts +1014 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js +1020 -6
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/generated-locales.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/en.d.ts +30 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/en.js +31 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/en.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ja.d.ts +30 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ja.js +31 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ja.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ko.d.ts +30 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ko.js +31 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/ko.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-CN.d.ts +30 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-CN.js +31 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-CN.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-HK.d.ts +30 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-HK.js +31 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-HK.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-TW.d.ts +30 -0
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-TW.js +31 -1
- package/node_modules/@fbincon/statusline-core/dist/src/i18n/statusline/zh-TW.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/release.d.ts +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/release.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/appearance.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/context.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/diagnose.d.ts +2 -2
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/diagnose.js +6 -3
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/diagnose.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js +6 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/explain.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/extensions.d.ts +7 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/extensions.js +35 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/extensions.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.d.ts +7 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.js +124 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/groups.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/indicators.d.ts +4 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/indicators.js +48 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/indicators.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js +19 -2
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/items.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/layout.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/layout.js +30 -9
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/layout.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/metrics.d.ts +3 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/metrics.js +14 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/metrics.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/powerline.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/preferences.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.js +3 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/preview.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/spans.d.ts +1 -0
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/spans.js +2 -2
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/spans.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js +23 -2
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/subagents.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/rendering/trace.d.ts +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/model.d.ts +2 -1
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/model.js +2 -1
- package/node_modules/@fbincon/statusline-core/dist/src/runtime/live/model.js.map +1 -1
- package/node_modules/@fbincon/statusline-core/dist/src/terminal/links.d.ts +6 -0
- package/node_modules/@fbincon/statusline-core/dist/src/terminal/links.js +37 -0
- package/node_modules/@fbincon/statusline-core/dist/src/terminal/links.js.map +1 -0
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/en.json +170 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ja.json +170 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/ko.json +170 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-CN.json +170 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-HK.json +170 -1
- package/node_modules/@fbincon/statusline-core/resources/i18n/locales/zh-TW.json +170 -1
- package/node_modules/@fbincon/statusline-platform/dist/src/files.d.ts +3 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/files.js +7 -2
- package/node_modules/@fbincon/statusline-platform/dist/src/files.js.map +1 -1
- package/node_modules/@fbincon/statusline-platform/dist/src/posix-source-exec.d.ts +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/posix-source-exec.js +26 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/posix-source-exec.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/source-files.d.ts +2 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/source-files.js +52 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/source-files.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/source-process.d.ts +19 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/source-process.js +122 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/source-process.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/windows-source-environment.d.ts +4 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/windows-source-environment.js +61 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/windows-source-environment.js.map +1 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/windows-source-job.d.ts +3 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/windows-source-job.js +61 -0
- package/node_modules/@fbincon/statusline-platform/dist/src/windows-source-job.js.map +1 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/canvas.js +3 -2
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/canvas.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js +10 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/pages.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js +8 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/presentation.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js +4 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing/shortcuts.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/drawing.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/session.js +6 -0
- package/node_modules/@fbincon/statusline-tui/dist/src/session.js.map +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/state.d.ts +1 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/state.js +23 -1
- package/node_modules/@fbincon/statusline-tui/dist/src/state.js.map +1 -1
- package/package.json +1 -1
|
@@ -1703,5 +1703,174 @@
|
|
|
1703
1703
|
"setup.value.requested": "要求啟用",
|
|
1704
1704
|
"setup.value.disabled": "已關閉",
|
|
1705
1705
|
"setup.value.suspended": "已暫停",
|
|
1706
|
-
"setup.value.unknown": "未知"
|
|
1706
|
+
"setup.value.unknown": "未知",
|
|
1707
|
+
"sources.title": "資料來源",
|
|
1708
|
+
"sources.separate_save": "資料來源獨立儲存;顯示綁定仍需儲存顯示設定。",
|
|
1709
|
+
"sources.add": "新增資料來源",
|
|
1710
|
+
"sources.edit": "編輯(停用資料來源)",
|
|
1711
|
+
"sources.review": "檢視並啟用",
|
|
1712
|
+
"sources.disable": "停用",
|
|
1713
|
+
"sources.enabled": "已啟用",
|
|
1714
|
+
"sources.disabled": "已停用",
|
|
1715
|
+
"sources.remove": "刪除資料來源",
|
|
1716
|
+
"sources.bind": "綁定至元件",
|
|
1717
|
+
"sources.unbind": "解除元件繫結",
|
|
1718
|
+
"sources.refresh": "立即重新整理",
|
|
1719
|
+
"sources.status": "重新整理狀態",
|
|
1720
|
+
"sources.cancel": "取消執行中的重新整理",
|
|
1721
|
+
"sources.diagnose": "檢視來源與觀測",
|
|
1722
|
+
"sources.json": "本機 JSON 檔案",
|
|
1723
|
+
"sources.github": "GitHub PR 與檢查",
|
|
1724
|
+
"sources.command": "指定程式與參數",
|
|
1725
|
+
"sources.save": "儲存資料來源",
|
|
1726
|
+
"sources.reload": "重新載入資料來源",
|
|
1727
|
+
"sources.empty": "尚未註冊本機資料來源。",
|
|
1728
|
+
"sources.saved": "資料來源已儲存;變更後須重新檢視才能啟用。",
|
|
1729
|
+
"sources.bound": "已綁定至顯示草稿;儲存顯示設定後生效。",
|
|
1730
|
+
"sources.failed": "資料來源操作失敗;請檢查欄位或重新載入目前狀態。",
|
|
1731
|
+
"sources.refresh_started": "已開始重新整理。可檢視狀態或取消;關閉會取消未完成的工作。",
|
|
1732
|
+
"sources.form_help": "Tab/Enter:下一欄位 · Ctrl+S:儲存為停用狀態",
|
|
1733
|
+
"sources.no_components": "請先在主狀態列或子代理頁新增外部元件。",
|
|
1734
|
+
"sources.remove_confirm": "Enter 刪除此本機資料來源與綁定:",
|
|
1735
|
+
"sources.enable_review": "請檢視全部欄位。Enter 啟用此修訂;Esc 取消。",
|
|
1736
|
+
"sources.help": "管理本機明確啟用的資料來源。手動重新整理;繪製不執行命令或網路查詢。",
|
|
1737
|
+
"sources.field.id": "資料來源 ID",
|
|
1738
|
+
"sources.field.name": "名稱",
|
|
1739
|
+
"sources.field.project": "專案 / worktree 路徑",
|
|
1740
|
+
"sources.field.session": "工作階段 ID(選填)",
|
|
1741
|
+
"sources.field.agent": "子代理 ID(選填)",
|
|
1742
|
+
"sources.field.ttl_seconds": "有效期限(秒)",
|
|
1743
|
+
"sources.field.path": "JSON 檔案路徑",
|
|
1744
|
+
"sources.field.pointer": "數值 JSON Pointer",
|
|
1745
|
+
"sources.field.observed_at_pointer": "觀察時間 JSON Pointer",
|
|
1746
|
+
"sources.field.unit": "單位(選填)",
|
|
1747
|
+
"sources.field.host": "GitHub 主機名稱",
|
|
1748
|
+
"sources.field.repository": "儲存庫(owner/name)",
|
|
1749
|
+
"sources.field.branch": "分支",
|
|
1750
|
+
"sources.field.account": "GitHub 帳號",
|
|
1751
|
+
"sources.field.pr": "PR 編號(選填)",
|
|
1752
|
+
"sources.field.executable": "可執行程式",
|
|
1753
|
+
"sources.field.args": "參數(JSON 陣列)",
|
|
1754
|
+
"sources.field.cwd": "工作目錄",
|
|
1755
|
+
"sources.field.input": "輸入欄位(JSON 對應)",
|
|
1756
|
+
"sources.field.output": "輸出:json / text",
|
|
1757
|
+
"sources.field.timeout_ms": "逾時(毫秒)",
|
|
1758
|
+
"statusline.source.value": "外部值",
|
|
1759
|
+
"statusline.source.unbound": "未綁定",
|
|
1760
|
+
"statusline.source.disabled": "已停用",
|
|
1761
|
+
"statusline.source.mismatch": "範圍不符",
|
|
1762
|
+
"statusline.source.missing": "缺少",
|
|
1763
|
+
"statusline.source.partial": "部分結果",
|
|
1764
|
+
"statusline.source.error": "錯誤",
|
|
1765
|
+
"statusline.source.unsupported": "不支援",
|
|
1766
|
+
"statusline.source.stale": "已過期",
|
|
1767
|
+
"statusline.source.unknown": "時間未知",
|
|
1768
|
+
"statusline.source.unknown_checks": "檢查未知",
|
|
1769
|
+
"statusline.source.no_pr": "無 PR",
|
|
1770
|
+
"statusline.source.no_checks": "無檢查",
|
|
1771
|
+
"statusline.source.failure": "失敗",
|
|
1772
|
+
"statusline.source.pending": "等待中",
|
|
1773
|
+
"statusline.source.success": "通過",
|
|
1774
|
+
"statusline.source.cancelled": "已取消",
|
|
1775
|
+
"statusline.source.skipped": "已略過",
|
|
1776
|
+
"sources.error.invalid": "資料來源設定無效",
|
|
1777
|
+
"sources.error.pointer": "JSON Pointer 無效",
|
|
1778
|
+
"sources.error.input": "不支援的輸入對應",
|
|
1779
|
+
"sources.error.scope": "資料來源範圍不符",
|
|
1780
|
+
"sources.error.version": "不支援的觀測版本",
|
|
1781
|
+
"sources.error.time": "觀察時間無效",
|
|
1782
|
+
"sources.error.type": "需要純量值",
|
|
1783
|
+
"sources.error.not_found": "找不到資料來源或重新整理工作",
|
|
1784
|
+
"sources.error.conflict": "資料來源設定已變更,請重新載入",
|
|
1785
|
+
"sources.error.review": "啟用前請檢視此修訂",
|
|
1786
|
+
"sources.error.binding": "請選擇相容的外部元件",
|
|
1787
|
+
"sources.error.disabled": "資料來源已停用",
|
|
1788
|
+
"sources.error.busy": "已有重新整理工作執行中",
|
|
1789
|
+
"sources.error.output_limit": "輸出超過 1 MiB",
|
|
1790
|
+
"sources.error.missing_program": "找不到可執行程式",
|
|
1791
|
+
"sources.error.missing_file": "找不到 JSON 檔案",
|
|
1792
|
+
"sources.error.timeout": "重新整理逾時",
|
|
1793
|
+
"sources.error.cancelled": "重新整理已取消",
|
|
1794
|
+
"sources.error.identity": "儲存庫、帳號、分支或 HEAD 已變更",
|
|
1795
|
+
"sources.error.account": "目前 GitHub 帳號不符",
|
|
1796
|
+
"sources.error.ambiguous": "請明確選擇 PR 編號",
|
|
1797
|
+
"sources.error.lookup_failed": "GitHub 查詢失敗",
|
|
1798
|
+
"sources.error.invalid_output": "資料來源輸出無效",
|
|
1799
|
+
"sources.error.read_error": "無法讀取資料來源檔案",
|
|
1800
|
+
"sources.error.refresh_failed": "重新整理失敗",
|
|
1801
|
+
"sources.error.authentication": "GitHub 認證無法使用",
|
|
1802
|
+
"sources.error.permission": "GitHub 存取遭拒",
|
|
1803
|
+
"sources.error.network": "GitHub 網路要求失敗",
|
|
1804
|
+
"sources.error.rate_limit": "GitHub 請求次數超限",
|
|
1805
|
+
"fields.item.link.label": "連結",
|
|
1806
|
+
"settings.sources": "資料來源",
|
|
1807
|
+
"native.settings.sources": "資料來源",
|
|
1808
|
+
"ui.actions.sources": "資料來源",
|
|
1809
|
+
"cli.help.source_management": "資料來源",
|
|
1810
|
+
"catalog.categories.extensions": "資料來源",
|
|
1811
|
+
"items.main.external-value.label": "外部值",
|
|
1812
|
+
"items.main.external-value.description": "管理本機明確啟用的資料來源。手動重新整理;繪製不執行命令或網路查詢。",
|
|
1813
|
+
"statusline.prefix.main.external-value": "外部值",
|
|
1814
|
+
"statusline.short.main.external-value": "外部值",
|
|
1815
|
+
"items.subagent.external-value.label": "外部值",
|
|
1816
|
+
"items.subagent.external-value.description": "管理本機明確啟用的資料來源。手動重新整理;繪製不執行命令或網路查詢。",
|
|
1817
|
+
"statusline.prefix.subagent.external-value": "外部值",
|
|
1818
|
+
"statusline.short.subagent.external-value": "外部值",
|
|
1819
|
+
"items.main.github-pr.label": "GitHub PR",
|
|
1820
|
+
"items.main.github-pr.description": "管理本機明確啟用的資料來源。手動重新整理;繪製不執行命令或網路查詢。",
|
|
1821
|
+
"statusline.prefix.main.github-pr": "GitHub PR",
|
|
1822
|
+
"statusline.short.main.github-pr": "GitHub PR",
|
|
1823
|
+
"items.main.github-ci.label": "GitHub CI",
|
|
1824
|
+
"items.main.github-ci.description": "管理本機明確啟用的資料來源。手動重新整理;繪製不執行命令或網路查詢。",
|
|
1825
|
+
"statusline.prefix.main.github-ci": "GitHub CI",
|
|
1826
|
+
"statusline.short.main.github-ci": "GitHub CI",
|
|
1827
|
+
"explain.reason.source_bound": "已綁定本機資料來源;啟用狀態與實際可用性須另外檢查。",
|
|
1828
|
+
"explain.reason.source_unbound": "請明確綁定本機資料來源;範例不代表實際資料。",
|
|
1829
|
+
"fields.item.presentation.label": "指標顯示方式",
|
|
1830
|
+
"fields.item.bar_width.label": "短條寬度(4–20 格)",
|
|
1831
|
+
"fields.item.bar_style.label": "短條字元",
|
|
1832
|
+
"indicators.presentation.numeric": "數字",
|
|
1833
|
+
"indicators.presentation.bar": "短條",
|
|
1834
|
+
"explain.reason.indicator_bar": "短條表示觀測百分比,不表示經過時間或預測。",
|
|
1835
|
+
"composition.groups.title": "元件分組",
|
|
1836
|
+
"composition.groups.main": "主狀態列",
|
|
1837
|
+
"composition.groups.subagent": "子代理範本",
|
|
1838
|
+
"composition.groups.create": "建立分組",
|
|
1839
|
+
"composition.groups.edit": "編輯分組",
|
|
1840
|
+
"composition.groups.up": "向前移動",
|
|
1841
|
+
"composition.groups.down": "向後移動",
|
|
1842
|
+
"composition.groups.copy": "複製分組",
|
|
1843
|
+
"composition.groups.ungroup": "解除分組",
|
|
1844
|
+
"composition.groups.first": "首個成員",
|
|
1845
|
+
"composition.groups.last": "末尾成員",
|
|
1846
|
+
"composition.groups.primary": "主指標",
|
|
1847
|
+
"composition.groups.linked": "連動裝飾可見性",
|
|
1848
|
+
"composition.groups.shared": "共用 Powerline 色塊",
|
|
1849
|
+
"composition.groups.apply": "套用至草稿",
|
|
1850
|
+
"composition.groups.help": "方向鍵選取和調整,Enter 套用至草稿;關閉面板後儲存顯示設定。",
|
|
1851
|
+
"composition.groups.invalid": "請選取同一列內連續的至少兩個成員及一個主指標。分組不能重疊或包含 spacer。",
|
|
1852
|
+
"explain.reason.sample_group_hidden": "主指標不可見,因此隱藏連動裝飾。",
|
|
1853
|
+
"settings.component-groups": "元件分組",
|
|
1854
|
+
"native.settings.component-groups": "元件分組",
|
|
1855
|
+
"cli.help.component_groups": "元件分組",
|
|
1856
|
+
"ui.actions.component-groups": "編輯分組",
|
|
1857
|
+
"sources.auto-review": "審核自動重新整理",
|
|
1858
|
+
"sources.auto-off": "關閉自動重新整理",
|
|
1859
|
+
"sources.automatic_on": "自動重新整理:開",
|
|
1860
|
+
"sources.automatic_off": "自動重新整理:關",
|
|
1861
|
+
"sources.automatic_review": "審核此來源,允許在支援的使用中工作階段定期查詢 GitHub PR/CI。Enter 儲存本機策略;←/→ 調整間隔。",
|
|
1862
|
+
"sources.interval": "重新整理間隔",
|
|
1863
|
+
"sources.automatic_saved": "自動策略已儲存。若執行時 Mod 尚未安裝或設定,請套用主機整合並重新啟動工作階段。",
|
|
1864
|
+
"items.main.session-cost-rate.label": "會話費用速率",
|
|
1865
|
+
"items.main.session-cost-rate.description": "由官方會話費用與所選會話/API 時長推導的每小時估算速率",
|
|
1866
|
+
"fields.item.cost_rate_basis.label": "費用速率分母",
|
|
1867
|
+
"cost_rate.basis.session": "會話時長",
|
|
1868
|
+
"cost_rate.basis.api": "累計 API 時長",
|
|
1869
|
+
"statusline.cost.rate_session": "費用速率 ~${value}/會話小時",
|
|
1870
|
+
"statusline.cost.rate_api": "費用速率 ~${value}/API 小時",
|
|
1871
|
+
"statusline.prefix.main.session-cost-rate": "費用速率",
|
|
1872
|
+
"statusline.short.main.session-cost-rate": "費用速率",
|
|
1873
|
+
"explain.reason.cost_rate_session": "以官方會話時長為分母,至少需要 60 秒。",
|
|
1874
|
+
"explain.reason.cost_rate_api": "以官方累計 API 時長為分母,與任務活躍時長獨立。",
|
|
1875
|
+
"guidance.requirements.cost_rate": "推導估算值:費用除以所選官方時長(小時),要求至少 60 秒。費用為零有效;缺失、負數或非有限值不可用,不代表帳單或未來消費預測。"
|
|
1707
1876
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
|
+
export declare class FileChangedError extends Error {
|
|
3
|
+
constructor(message?: string);
|
|
4
|
+
}
|
|
2
5
|
/** Older Windows libuv reports a 64-bit path volume serial but a 32-bit fd
|
|
3
6
|
* serial. Match the low 32 bits, as current libuv does, without rounding IDs
|
|
4
7
|
* through number. POSIX device identifiers retain all their bits. */
|
|
@@ -2,6 +2,9 @@ import * as fs from 'node:fs';
|
|
|
2
2
|
import { dirname, basename, join, resolve, toNamespacedPath } from 'node:path';
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { library, nativeApi, nativeFunction, winError } from './native.js';
|
|
5
|
+
export class FileChangedError extends Error {
|
|
6
|
+
constructor(message = 'file_changed') { super(message); this.name = 'FileChangedError'; }
|
|
7
|
+
}
|
|
5
8
|
/** Older Windows libuv reports a 64-bit path volume serial but a 32-bit fd
|
|
6
9
|
* serial. Match the low 32 bits, as current libuv does, without rounding IDs
|
|
7
10
|
* through number. POSIX device identifiers retain all their bits. */
|
|
@@ -27,8 +30,10 @@ export function fileIdentity(path, stat) {
|
|
|
27
30
|
throw winError('GetFileInformationByHandle');
|
|
28
31
|
const attributes = info.readUInt32LE(0), dev = BigInt(info.readUInt32LE(28));
|
|
29
32
|
const ino = BigInt(info.readUInt32LE(44)) << 32n | BigInt(info.readUInt32LE(48));
|
|
30
|
-
if (attributes & (0x400 | 0x10)
|
|
31
|
-
throw new Error('File
|
|
33
|
+
if (attributes & (0x400 | 0x10))
|
|
34
|
+
throw new Error('File became a reparse point or directory while checking identity');
|
|
35
|
+
if (ino !== stat.ino)
|
|
36
|
+
throw new FileChangedError('File changed while checking identity');
|
|
32
37
|
return { dev, ino };
|
|
33
38
|
}
|
|
34
39
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":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;QAAC,YAAY,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IAAC,CAAC;IAChD,OAAO,KAAK,EAAE,CAAC;QAAC,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO;QAAC,MAAM,KAAK,CAAC;IAAC,CAAC;IAC9F,aAAa,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function execSource(): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** A short-lived execve handoff: unlike execvp, it never retries ENOEXEC in sh. */
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { nativeFunction } from './native.js';
|
|
4
|
+
export function execSource() {
|
|
5
|
+
try {
|
|
6
|
+
const spec = JSON.parse(process.env.STATUSLINE_SOURCE_LAUNCH ?? 'null');
|
|
7
|
+
if (process.platform === 'win32' || !spec || typeof spec.executable !== 'string' || !Array.isArray(spec.args) || spec.args.some((arg) => typeof arg !== 'string') || !spec.environment || typeof spec.environment !== 'object')
|
|
8
|
+
throw new Error('Invalid source handoff');
|
|
9
|
+
const environment = Object.entries(spec.environment).filter((entry) => typeof entry[1] === 'string').map(([key, value]) => key + '=' + value);
|
|
10
|
+
const library = process.platform === 'darwin' ? '/usr/lib/libSystem.B.dylib' : 'libc.so.6';
|
|
11
|
+
const fcntl = nativeFunction(library, 'int fcntl(int fd, int command, ...)');
|
|
12
|
+
// Node marks inherited stdio close-on-exec during startup. Preserve only
|
|
13
|
+
// the three pipes explicitly provided by the source process adapter.
|
|
14
|
+
for (const fd of [0, 1, 2])
|
|
15
|
+
if (fcntl(fd, 2, 'int', 0) < 0)
|
|
16
|
+
throw new Error('Cannot preserve source pipes');
|
|
17
|
+
// execve replaces this process, preserving its process group and pipes.
|
|
18
|
+
// https://man7.org/linux/man-pages/man2/execve.2.html
|
|
19
|
+
nativeFunction(library, 'int execve(const char *file, const char **argv, const char **envp)')(spec.executable, [spec.executable, ...spec.args, null], [...environment, null]);
|
|
20
|
+
}
|
|
21
|
+
catch { /* Handoff errors must never disclose the command environment. */ }
|
|
22
|
+
process.exitCode = 126;
|
|
23
|
+
}
|
|
24
|
+
if (process.argv[1] === fileURLToPath(import.meta.url))
|
|
25
|
+
execSource();
|
|
26
|
+
//# sourceMappingURL=posix-source-exec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posix-source-exec.js","sourceRoot":"","sources":["../../src/posix-source-exec.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,UAAU,UAAU;IACtB,IAAI,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,MAAM,CAAC,CAAC;QACxE,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAY,EAAE,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ;YACnO,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC9C,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAA6B,EAAE,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC;QACzK,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,WAAW,CAAC;QAC3F,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE,qCAAqC,CAAC,CAAC;QAC7E,yEAAyE;QACzE,qEAAqE;QACrE,KAAK,MAAM,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YAAE,IAAI,KAAK,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC5G,wEAAwE;QACxE,sDAAsD;QACtD,cAAc,CAAC,OAAO,EAAE,oEAAoE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;IAClL,CAAC;IAAC,MAAM,CAAC,CAAC,iEAAiE,CAAC,CAAC;IAC7E,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAC;AAC3B,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { constants, openSync, closeSync, fstatSync, readSync, lstatSync } from 'node:fs';
|
|
2
|
+
import { MAX_SOURCE_BYTES } from '@fbincon/statusline-core/extensions/model';
|
|
3
|
+
import { isLinkOrReparse, fileIdentity, sameFileIdentity, FileChangedError } from './files.js';
|
|
4
|
+
/** Reject devices/FIFOs and links before reading; bound growth during the read too. */
|
|
5
|
+
export function readSourceFile(path) {
|
|
6
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
7
|
+
try {
|
|
8
|
+
return readSnapshot(path);
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (!(error instanceof FileChangedError) || attempt === 2)
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
throw new FileChangedError();
|
|
16
|
+
}
|
|
17
|
+
/** Each retry starts over with no-follow, size and identity checks intact. */
|
|
18
|
+
function readSnapshot(path) {
|
|
19
|
+
let fd;
|
|
20
|
+
try {
|
|
21
|
+
const before = lstatSync(path, { bigint: true });
|
|
22
|
+
if (!before.isFile() || isLinkOrReparse(path))
|
|
23
|
+
throw new Error('file_type');
|
|
24
|
+
const identity = fileIdentity(path, before);
|
|
25
|
+
fd = openSync(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
26
|
+
const stat = fstatSync(fd, { bigint: true });
|
|
27
|
+
if (!stat.isFile() || stat.size > MAX_SOURCE_BYTES)
|
|
28
|
+
throw new Error('file_size_or_type');
|
|
29
|
+
if (!sameFileIdentity(identity, stat))
|
|
30
|
+
throw new FileChangedError();
|
|
31
|
+
const bytes = Buffer.alloc(MAX_SOURCE_BYTES + 1);
|
|
32
|
+
let size = 0, count;
|
|
33
|
+
while (size < bytes.length && (count = readSync(fd, bytes, size, bytes.length - size, null)) > 0)
|
|
34
|
+
size += count;
|
|
35
|
+
if (size > MAX_SOURCE_BYTES)
|
|
36
|
+
throw new Error('output_limit');
|
|
37
|
+
const after = fstatSync(fd, { bigint: true });
|
|
38
|
+
if (after.mtimeNs !== stat.mtimeNs || after.size !== stat.size)
|
|
39
|
+
throw new FileChangedError();
|
|
40
|
+
return bytes.subarray(0, size);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (error.code === 'ENOENT')
|
|
44
|
+
return null;
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
if (fd !== undefined)
|
|
49
|
+
closeSync(fd);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=source-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-files.js","sourceRoot":"","sources":["../../src/source-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/F,uFAAuF;AACvF,MAAM,UAAU,cAAc,CAAC,IAAY;IACvC,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC;QAC3C,IAAI,CAAC;YAAC,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;QAAC,CAAC;QAClC,OAAO,KAAK,EAAE,CAAC;YACX,IAAI,CAAC,CAAC,KAAK,YAAY,gBAAgB,CAAC,IAAI,OAAO,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;QAC3E,CAAC;IACL,CAAC;IACD,MAAM,IAAI,gBAAgB,EAAE,CAAC;AACjC,CAAC;AACD,8EAA8E;AAC9E,SAAS,YAAY,CAAC,IAAY;IAC9B,IAAI,EAAsB,CAAC;IAC3B,IAAI,CAAC;QACD,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,eAAe,CAAC,IAAI,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;QACjC,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,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C,CAAC;IACnC,CAAC;IACD,OAAO,KAAK,EAAE,CAAC;QACX,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAClD,OAAO,IAAI,CAAC;QAChB,MAAM,KAAK,CAAC;IAChB,CAAC;YACO,CAAC;QACL,IAAI,EAAE,KAAK,SAAS;YAChB,SAAS,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface SourceProcessOptions {
|
|
2
|
+
executable: string;
|
|
3
|
+
args: readonly string[];
|
|
4
|
+
cwd: string;
|
|
5
|
+
input: string;
|
|
6
|
+
timeoutMs: number;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
environment?: NodeJS.ProcessEnv;
|
|
9
|
+
}
|
|
10
|
+
export interface SourceProcessResult {
|
|
11
|
+
code: number | null;
|
|
12
|
+
stdout: string;
|
|
13
|
+
errorKind?: 'authentication' | 'permission' | 'network' | 'rate_limit' | 'no_checks';
|
|
14
|
+
reason: 'completed' | 'exit' | 'missing_program' | 'timeout' | 'cancelled' | 'output_limit' | 'io_error' | 'invalid_output';
|
|
15
|
+
}
|
|
16
|
+
/** User commands inherit only the OS essentials, never model/forge credentials. */
|
|
17
|
+
export declare function sourceEnvironment(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
18
|
+
/** Bound the entire tree, both output streams and the final pipe drain. No shell. */
|
|
19
|
+
export declare function runSourceProcess(options: SourceProcessOptions): Promise<SourceProcessResult>;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { which } from './commands.js';
|
|
5
|
+
import { windowsJobScript } from './windows-source-job.js';
|
|
6
|
+
import { windowsSourceEnvironment, WINDOWS_RUNTIME_FOLDERS } from './windows-source-environment.js';
|
|
7
|
+
import { decodeUtf8 } from './utf8.js';
|
|
8
|
+
/** User commands inherit only the OS essentials, never model/forge credentials. */
|
|
9
|
+
export function sourceEnvironment(env = process.env) {
|
|
10
|
+
const allowed = new Set(['PATH', 'HOME', 'USER', 'LOGNAME', 'USERPROFILE', 'SYSTEMROOT', 'WINDIR', 'COMSPEC', 'PATHEXT', 'TEMP', 'TMP', 'TMPDIR', 'LANG', 'LC_ALL', 'LC_CTYPE', ...(process.platform === 'win32' ? WINDOWS_RUNTIME_FOLDERS : [])]);
|
|
11
|
+
return Object.fromEntries(Object.entries(env).filter(([key]) => allowed.has(key.toUpperCase())));
|
|
12
|
+
}
|
|
13
|
+
/** Bound the entire tree, both output streams and the final pipe drain. No shell. */
|
|
14
|
+
export function runSourceProcess(options) {
|
|
15
|
+
if (options.signal?.aborted)
|
|
16
|
+
return Promise.resolve({ code: null, stdout: '', reason: 'cancelled' });
|
|
17
|
+
return new Promise(resolve => {
|
|
18
|
+
const started = performance.now(), windows = process.platform === 'win32', commandEnvironment = { ...(options.environment ?? sourceEnvironment()) };
|
|
19
|
+
let environment = commandEnvironment;
|
|
20
|
+
const lookupEnvironment = windows ? Object.fromEntries(Object.entries(commandEnvironment).map(([key, value]) => [key.toUpperCase(), value])) : commandEnvironment;
|
|
21
|
+
const found = which(options.executable, lookupEnvironment);
|
|
22
|
+
if (!found) {
|
|
23
|
+
resolve({ code: null, stdout: '', reason: 'missing_program' });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
let executable = found, args = [...options.args];
|
|
27
|
+
if (windows) {
|
|
28
|
+
try {
|
|
29
|
+
environment = windowsSourceEnvironment(commandEnvironment);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
resolve({ code: null, stdout: '', reason: 'io_error' });
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
environment.STATUSLINE_SOURCE_LAUNCH = JSON.stringify({ executable, args, cwd: options.cwd, environment: commandEnvironment });
|
|
36
|
+
executable = join(process.env.SystemRoot ?? 'C:\\Windows', 'System32/WindowsPowerShell/v1.0/powershell.exe');
|
|
37
|
+
args = ['-NoLogo', '-NoProfile', '-NonInteractive', '-EncodedCommand', Buffer.from(windowsJobScript, 'utf16le').toString('base64')];
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// Node/libuv uses execvp, whose ENOEXEC fallback can run plain text
|
|
41
|
+
// in /bin/sh even with shell:false. Hand off through execve instead.
|
|
42
|
+
// Bootstrap Node without applying target-only NODE_OPTIONS/LD_*.
|
|
43
|
+
environment = sourceEnvironment(commandEnvironment);
|
|
44
|
+
environment.STATUSLINE_SOURCE_LAUNCH = JSON.stringify({ executable, args, environment: commandEnvironment });
|
|
45
|
+
executable = process.execPath;
|
|
46
|
+
args = [fileURLToPath(new URL('./posix-source-exec.js', import.meta.url))];
|
|
47
|
+
}
|
|
48
|
+
const child = spawn(executable, args, { cwd: options.cwd, env: environment, shell: false, detached: !windows, windowsHide: true, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
49
|
+
let reason = 'completed', code = null, bytes = 0, done = false;
|
|
50
|
+
const chunks = [], errors = [];
|
|
51
|
+
let drain;
|
|
52
|
+
const kill = () => {
|
|
53
|
+
try {
|
|
54
|
+
if (!windows && child.pid)
|
|
55
|
+
process.kill(-child.pid, 'SIGKILL');
|
|
56
|
+
else
|
|
57
|
+
child.kill('SIGKILL');
|
|
58
|
+
}
|
|
59
|
+
catch { /* Already exited. */ }
|
|
60
|
+
};
|
|
61
|
+
const finish = () => {
|
|
62
|
+
if (done)
|
|
63
|
+
return;
|
|
64
|
+
done = true;
|
|
65
|
+
clearTimeout(timer);
|
|
66
|
+
if (drain)
|
|
67
|
+
clearTimeout(drain);
|
|
68
|
+
options.signal?.removeEventListener('abort', cancel);
|
|
69
|
+
child.stdin.destroy();
|
|
70
|
+
child.stdout.destroy();
|
|
71
|
+
child.stderr.destroy();
|
|
72
|
+
const detail = Buffer.concat(errors).toString('utf8');
|
|
73
|
+
const errorKind = /^no checks reported on the '[^\r\n]*' branch\s*$/u.test(detail) ? 'no_checks' : /rate limit|HTTP 429/iu.test(detail) ? 'rate_limit' : /HTTP 403|forbidden|not accessible|permission denied/iu.test(detail) ? 'permission' : /HTTP 401|auth login|not logged|authentication/iu.test(detail) ? 'authentication' : /timeout|connection|resolve host|network|TLS|dial tcp|\bEOF\b/iu.test(detail) ? 'network' : undefined;
|
|
74
|
+
let stdout = '';
|
|
75
|
+
try {
|
|
76
|
+
stdout = decodeUtf8(Buffer.concat(chunks));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
if (reason === 'completed')
|
|
80
|
+
reason = 'invalid_output';
|
|
81
|
+
}
|
|
82
|
+
resolve({ code, stdout, ...(errorKind ? { errorKind } : {}), reason: reason === 'completed' && code !== 0 ? 'exit' : reason });
|
|
83
|
+
};
|
|
84
|
+
const stop = (why) => {
|
|
85
|
+
if (done || reason !== 'completed')
|
|
86
|
+
return;
|
|
87
|
+
reason = why;
|
|
88
|
+
kill();
|
|
89
|
+
drain = setTimeout(finish, 500);
|
|
90
|
+
};
|
|
91
|
+
const cancel = () => stop('cancelled');
|
|
92
|
+
const timer = setTimeout(() => stop('timeout'), Math.max(1, options.timeoutMs - (performance.now() - started)));
|
|
93
|
+
options.signal?.addEventListener('abort', cancel, { once: true });
|
|
94
|
+
const output = (data, stdout) => {
|
|
95
|
+
bytes += data.length;
|
|
96
|
+
if (bytes > 1048576) {
|
|
97
|
+
stop('output_limit');
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (stdout)
|
|
101
|
+
chunks.push(data);
|
|
102
|
+
else
|
|
103
|
+
errors.push(data);
|
|
104
|
+
};
|
|
105
|
+
child.stdout.on('data', data => output(data, true));
|
|
106
|
+
child.stderr.on('data', data => output(data, false));
|
|
107
|
+
child.stdin.on('error', error => {
|
|
108
|
+
if (error.code !== 'EPIPE')
|
|
109
|
+
stop('io_error');
|
|
110
|
+
});
|
|
111
|
+
child.once('error', error => { reason = error.code === 'ENOENT' ? 'missing_program' : 'io_error'; finish(); });
|
|
112
|
+
child.once('exit', status => {
|
|
113
|
+
code = status;
|
|
114
|
+
kill(); // Also terminate descendants after their parent exits normally.
|
|
115
|
+
if (!done)
|
|
116
|
+
drain = setTimeout(finish, 500);
|
|
117
|
+
});
|
|
118
|
+
child.once('close', finish);
|
|
119
|
+
child.stdin.end(options.input, 'utf8');
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=source-process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-process.js","sourceRoot":"","sources":["../../src/source-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAgBvC,mFAAmF;AACnF,MAAM,UAAU,iBAAiB,CAAC,MAAyB,OAAO,CAAC,GAAG;IAClE,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACnP,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,GAA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CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1I,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;YACxB,IAAI,GAAG,MAAM,CAAC;YACd,IAAI,EAAE,CAAC,CAAC,gEAAgE;YACxE,IAAI,CAAC,IAAI;gBACL,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5B,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const WINDOWS_RUNTIME_FOLDERS: string[];
|
|
2
|
+
/** Bootstrap only the static supervisor with valid .NET known folders. The tool
|
|
3
|
+
* receives the original, separately serialized minimum environment instead. */
|
|
4
|
+
export declare function windowsSourceEnvironment(command: NodeJS.ProcessEnv, folders?: Record<string, string>): NodeJS.ProcessEnv;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { nativeApi, nativeFunction, winError } from './native.js';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
export const WINDOWS_RUNTIME_FOLDERS = ['USERPROFILE', 'HOME', 'HOMEDRIVE', 'HOMEPATH', 'APPDATA', 'LOCALAPPDATA', 'SYSTEMDRIVE', 'PROGRAMDATA', 'PROGRAMFILES', 'PROGRAMFILES(X86)', 'PROGRAMW6432', 'COMMONPROGRAMFILES', 'COMMONPROGRAMFILES(X86)', 'COMMONPROGRAMW6432'];
|
|
4
|
+
/** Recover the loaded Windows profile independently of a caller's isolated HOME.
|
|
5
|
+
* Only OS folder variables leave this adapter; registry credentials never do.
|
|
6
|
+
* https://learn.microsoft.com/windows/win32/api/userenv/nf-userenv-createenvironmentblock
|
|
7
|
+
*/
|
|
8
|
+
function operatingSystemFolders() {
|
|
9
|
+
const api = nativeApi(), tokenBytes = Buffer.alloc(api.sizeof('void *'));
|
|
10
|
+
const directory = Buffer.alloc(65536);
|
|
11
|
+
const length = nativeFunction('kernel32.dll', 'uint32_t GetSystemDirectoryW(_Out_ void *buffer, uint32_t size)')(directory, directory.length / 2);
|
|
12
|
+
if (!length || length >= directory.length / 2)
|
|
13
|
+
throw winError('GetSystemDirectoryW');
|
|
14
|
+
// Never resolve this newly loaded DLL relative to a project directory.
|
|
15
|
+
const userenv = join(directory.toString('utf16le', 0, length * 2), 'userenv.dll');
|
|
16
|
+
const current = nativeFunction('kernel32.dll', 'void *GetCurrentProcess()')();
|
|
17
|
+
if (!nativeFunction('advapi32.dll', 'bool OpenProcessToken(void *process, uint32_t access, _Out_ void *token)')(current, 0x000a, tokenBytes))
|
|
18
|
+
throw winError('OpenProcessToken');
|
|
19
|
+
const token = api.decode(tokenBytes, 'void *');
|
|
20
|
+
let block;
|
|
21
|
+
try {
|
|
22
|
+
const pointer = Buffer.alloc(api.sizeof('void *'));
|
|
23
|
+
if (!nativeFunction(userenv, 'bool CreateEnvironmentBlock(_Out_ void *environment, void *token, bool inherit)')(pointer, token, false))
|
|
24
|
+
throw winError('CreateEnvironmentBlock');
|
|
25
|
+
block = api.decode(pointer, 'void *');
|
|
26
|
+
const result = {};
|
|
27
|
+
let entry = '';
|
|
28
|
+
for (let offset = 0; offset < 1024 * 1024; offset += 2) {
|
|
29
|
+
const character = api.decode(block, offset, 'uint16_t');
|
|
30
|
+
if (character) {
|
|
31
|
+
entry += String.fromCharCode(character);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (!entry)
|
|
35
|
+
return result;
|
|
36
|
+
const equals = entry.indexOf('='), name = entry.slice(0, equals).toUpperCase();
|
|
37
|
+
if (equals > 0 && WINDOWS_RUNTIME_FOLDERS.includes(name))
|
|
38
|
+
result[name] = entry.slice(equals + 1);
|
|
39
|
+
entry = '';
|
|
40
|
+
}
|
|
41
|
+
throw new Error('Windows environment block exceeds its bound');
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
if (block)
|
|
45
|
+
nativeFunction(userenv, 'bool DestroyEnvironmentBlock(void *environment)')(block);
|
|
46
|
+
nativeFunction('kernel32.dll', 'bool CloseHandle(void *handle)')(token);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Bootstrap only the static supervisor with valid .NET known folders. The tool
|
|
50
|
+
* receives the original, separately serialized minimum environment instead. */
|
|
51
|
+
export function windowsSourceEnvironment(command, folders = operatingSystemFolders()) {
|
|
52
|
+
const result = { ...command };
|
|
53
|
+
for (const name of Object.keys(result))
|
|
54
|
+
if (WINDOWS_RUNTIME_FOLDERS.includes(name.toUpperCase()) || name.toUpperCase() === 'PSMODULEPATH')
|
|
55
|
+
delete result[name];
|
|
56
|
+
for (const [name, value] of Object.entries(folders))
|
|
57
|
+
if (WINDOWS_RUNTIME_FOLDERS.includes(name.toUpperCase()))
|
|
58
|
+
result[name] = value;
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=windows-source-environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windows-source-environment.js","sourceRoot":"","sources":["../../src/windows-source-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,cAAc,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,oBAAoB,CAAC,CAAC;AAE7Q;;;GAG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