@kabmo-labs/kabmo 0.18.0 → 0.19.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 +10 -7
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +475 -474
- package/dist/client/static/js/{index-tc09dtca.js → index-fcee4c13.js} +766 -765
- package/dist/client/static/js/index-sxdw908m.css +1 -0
- package/marketplace/plugins/command-runner/package.json +3 -2
- package/marketplace/plugins/git-forge/package.json +3 -2
- package/marketplace/plugins/session-info/package.json +3 -2
- package/marketplace/plugins/stats/package.json +3 -2
- package/package.json +3 -1
- package/src/client/components/auth/login-screen/index.tsx +2 -1
- package/src/client/components/common/ComposerPicker.tsx +1 -1
- package/src/client/components/common/FolderPicker.tsx +2 -2
- package/src/client/components/common/Modal.tsx +2 -2
- package/src/client/components/common/PWAInstallButton.tsx +2 -2
- package/src/client/components/common/ViewportSelector.tsx +1 -1
- package/src/client/components/common/anchored-menu/index.tsx +5 -1
- package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
- package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
- package/src/client/components/common/brand-wordmark/index.tsx +13 -2
- package/src/client/components/common/checkbox/style.test.ts +139 -0
- package/src/client/components/common/checkbox/style.ts +51 -0
- package/src/client/components/common/context-usage-button/index.tsx +2 -2
- package/src/client/components/common/file-icon/index.tsx +23 -9
- package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
- package/src/client/components/common/markdown-review/ReviewPopover.tsx +1 -1
- package/src/client/components/common/panel-mark/index.tsx +97 -0
- package/src/client/components/common/provider-icon/glyphs.test.ts +1 -1
- package/src/client/components/common/provider-icon/index.test.ts +14 -0
- package/src/client/components/common/provider-icon/index.tsx +4 -0
- package/src/client/components/common/provider-icon/resolve.test.ts +8 -7
- package/src/client/components/common/provider-icon/resolve.ts +16 -3
- package/src/client/components/common/session-actions-menu/index.tsx +1 -1
- package/src/client/components/common/toolbar-row/index.tsx +1 -1
- package/src/client/components/layout/ActivityBar.tsx +22 -3
- package/src/client/components/layout/LeftDock.tsx +9 -2
- package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
- package/src/client/components/layout/WindowAura.tsx +27 -0
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
- package/src/client/components/layout/desktop-layout/index.tsx +3 -1
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +3 -3
- package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
- package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
- package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +2 -2
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +1 -1
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +13 -5
- package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
- package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
- package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/mobile/panel-chips.tsx +10 -2
- package/src/client/components/settings/Modal.tsx +4 -4
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
- package/src/client/components/settings/apply-side-effects.test.ts +30 -0
- package/src/client/components/settings/apply-side-effects.ts +14 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
- package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -0
- package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +2 -1
- package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +2 -2
- package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +51 -2
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +43 -10
- package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
- package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
- package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
- package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +2 -1
- package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +1 -1
- package/src/client/components/workspace/btw-panel/TopicMenu.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/UndoConfirmModal.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
- package/src/client/components/workspace/context-panel/CostBreakdownPopover.tsx +1 -1
- package/src/client/components/workspace/diff-panel/index.tsx +2 -2
- package/src/client/components/workspace/editor/PluginRail.tsx +1 -1
- package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
- package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
- package/src/client/components/workspace/editor/Tabs.tsx +1 -1
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +1 -1
- package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
- package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
- package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
- package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
- package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
- package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
- package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
- package/src/client/components/workspace/git-panel/index.tsx +7 -0
- package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
- package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
- package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
- package/src/client/components/workspace/search-panel/Body.tsx +1 -1
- package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
- package/src/client/glass.css +785 -0
- package/src/client/glass.test.ts +346 -0
- package/src/client/hooks/ui/glass-support.ts +57 -0
- package/src/client/hooks/ui/icon-style.ts +59 -0
- package/src/client/hooks/ui/stuck-header.test.ts +188 -0
- package/src/client/hooks/ui/stuck-header.ts +91 -0
- package/src/client/hooks/ui/style-attributes.test.ts +120 -0
- package/src/client/hooks/ui/surface-style.ts +56 -0
- package/src/client/hooks/workspace/panel-hues.ts +23 -0
- package/src/client/main.tsx +10 -0
- package/src/client/tailwind.css +264 -11
- package/src/server/lib/assets/shell-attributes.server.ts +80 -0
- package/src/server/lib/assets/shell-attributes.test.ts +86 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
- package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
- package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
- package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
- package/src/server/lib/omp/rpc/manager.ts +2 -2
- package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
- package/src/server/lib/omp/rpc/process.test.ts +106 -0
- package/src/server/lib/omp/rpc/process.ts +28 -4
- package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
- package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
- package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
- package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
- package/src/server/lib/omp/rpc/session-commands.ts +11 -0
- package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
- package/src/server/lib/panels/bundled-catalog.server.ts +1 -0
- package/src/server/lib/panels/manifest.test.ts +20 -0
- package/src/server/lib/panels/manifest.ts +12 -0
- package/src/server/lib/panels/scan.server.ts +4 -0
- package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
- package/src/server/lib/queue/delivery-harness.ts +8 -4
- package/src/server/lib/queue/delivery.server.test.ts +29 -0
- package/src/server/lib/queue/delivery.server.ts +39 -0
- package/src/server/lib/queue/store.server.test.ts +22 -2
- package/src/server/lib/queue/store.server.ts +33 -11
- package/src/server/plugins/ssr.ts +22 -5
- package/src/shared/lib/icons/file-brand-color.ts +38 -0
- package/src/shared/lib/icons/icon-paint-css.test.ts +234 -0
- package/src/shared/lib/icons/icon-paint-css.ts +284 -0
- package/src/shared/lib/icons/icon-paint-panel.ts +100 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +230 -0
- package/src/shared/lib/icons/tint.test.ts +273 -0
- package/src/shared/lib/icons/tint.ts +219 -0
- package/src/shared/lib/models/provider/brand-color.test.ts +116 -0
- package/src/shared/lib/models/provider/brand-color.ts +103 -0
- package/src/shared/lib/omp/rpc/frame.test.ts +65 -0
- package/src/shared/lib/omp/rpc/frame.ts +58 -3
- package/src/shared/lib/settings/defaults.ts +4 -0
- package/src/shared/lib/theme/catalog.test.ts +5 -4
- package/src/shared/lib/theme/catalog.ts +18 -3
- package/src/shared/lib/theme/glass-support.test.ts +38 -0
- package/src/shared/lib/theme/glass-support.ts +73 -0
- package/src/shared/lib/theme/icon-style.test.ts +74 -0
- package/src/shared/lib/theme/icon-style.ts +90 -0
- package/src/shared/lib/theme/legibility.ts +91 -0
- package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
- package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
- package/src/shared/lib/theme/surface-style.test.ts +68 -0
- package/src/shared/lib/theme/surface-style.ts +91 -0
- package/src/shared/lib/theme/theme.test.ts +11 -7
- package/src/shared/lib/workspace/panel-hues.test.ts +68 -0
- package/src/shared/lib/workspace/panel-hues.ts +57 -0
- package/src/shared/types/panels-registry.ts +6 -0
- package/src/shared/types/panels.ts +14 -0
- package/src/shared/types/settings/state.ts +26 -0
- package/src/test-support/fake-omp-frames.ts +163 -0
- package/dist/client/static/js/index-hp75vsv9.css +0 -1
- /package/src/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The surface style's contract.
|
|
8
|
+
*
|
|
9
|
+
* The rule that matters is the FALLBACK and the DEFAULT: a stored value this
|
|
10
|
+
* build cannot draw must resolve to the shipped default, and that default must
|
|
11
|
+
* be the opaque style — a document that resolved to `glass` by accident would
|
|
12
|
+
* restyle every window on upgrade.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { describe, expect, test } from 'bun:test';
|
|
16
|
+
import {
|
|
17
|
+
DEFAULT_SURFACE_STYLE,
|
|
18
|
+
SURFACE_ATTRIBUTE,
|
|
19
|
+
SURFACE_STYLES,
|
|
20
|
+
SURFACE_STYLE_COPY,
|
|
21
|
+
isSurfaceStyle,
|
|
22
|
+
resolveSurfaceStyle,
|
|
23
|
+
} from '@/shared/lib/theme/surface-style';
|
|
24
|
+
|
|
25
|
+
describe('isSurfaceStyle', () => {
|
|
26
|
+
test('accepts exactly the two styles', () => {
|
|
27
|
+
expect(SURFACE_STYLES.map(isSurfaceStyle)).toEqual([true, true]);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('refuses what another build or a corrupted blob could carry', () => {
|
|
31
|
+
for (const value of ['', 'Glass', 'frosted', 'blurred', 0, 1, true, null, undefined, {}, ['glass']]) {
|
|
32
|
+
expect(isSurfaceStyle(value)).toBe(false);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('resolveSurfaceStyle', () => {
|
|
38
|
+
test('keeps a style this build draws', () => {
|
|
39
|
+
expect(resolveSurfaceStyle('classic')).toBe('classic');
|
|
40
|
+
expect(resolveSurfaceStyle('glass')).toBe('glass');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('an unknown value lands on the shipped default, not on undefined', () => {
|
|
44
|
+
expect(resolveSurfaceStyle('liquid')).toBe(DEFAULT_SURFACE_STYLE);
|
|
45
|
+
expect(resolveSurfaceStyle(undefined)).toBe(DEFAULT_SURFACE_STYLE);
|
|
46
|
+
expect(resolveSurfaceStyle(null)).toBe(DEFAULT_SURFACE_STYLE);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('the style table', () => {
|
|
51
|
+
test('the default is the opaque style, so an upgrade restyles nothing', () => {
|
|
52
|
+
expect(DEFAULT_SURFACE_STYLE).toBe('classic');
|
|
53
|
+
expect(SURFACE_STYLES).toContain(DEFAULT_SURFACE_STYLE);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('the attribute is a plain `data-` name', () => {
|
|
57
|
+
expect(SURFACE_ATTRIBUTE).toBe('data-surface');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('every style carries its own label, caption and description', () => {
|
|
61
|
+
const labels = SURFACE_STYLES.map((style) => SURFACE_STYLE_COPY[style].label);
|
|
62
|
+
expect(new Set(labels).size).toBe(SURFACE_STYLES.length);
|
|
63
|
+
for (const style of SURFACE_STYLES) {
|
|
64
|
+
expect(SURFACE_STYLE_COPY[style].description.length).toBeGreaterThan(0);
|
|
65
|
+
expect(SURFACE_STYLE_COPY[style].caption.length).toBeGreaterThan(0);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How the app's surfaces are painted, as ONE of two styles.
|
|
8
|
+
*
|
|
9
|
+
* This is a PRESENTATION choice over the same shell: both styles render the
|
|
10
|
+
* same panels, rows, controls and dialogs. Nothing is hidden, moved or
|
|
11
|
+
* re-ordered — only the material the surfaces are cut from changes, which is
|
|
12
|
+
* why this module states names and copy while `src/client/tailwind.css` states
|
|
13
|
+
* every pixel.
|
|
14
|
+
*
|
|
15
|
+
* - `classic` — opaque paper over the palette's canvas. The look Kabmo has
|
|
16
|
+
* always shipped, and the DEFAULT: an upgrade must not restyle a window the
|
|
17
|
+
* user did not ask to change (the rule `DEFAULT_SIDEBAR_STYLE` follows).
|
|
18
|
+
* - `glass` — one frosted plane over a palette-coloured aura, with the
|
|
19
|
+
* panels above it as translucent tints. The plane owns the blur (a single
|
|
20
|
+
* `backdrop-filter` per window), so the panel count does not decide the
|
|
21
|
+
* frame budget.
|
|
22
|
+
*
|
|
23
|
+
* The style reaches the document as `data-surface` on `<html>`, never as a
|
|
24
|
+
* prop: the sidebar, the navbar, the composer and every modal are separate
|
|
25
|
+
* subtrees, and a prop would be one call site each — the exact shape that lets
|
|
26
|
+
* one surface stay classic while the rest turn to glass.
|
|
27
|
+
*
|
|
28
|
+
* A style added here without a CSS rule renders EXACTLY like `classic`, and the
|
|
29
|
+
* settings card is the only place that can notice. There is deliberately no
|
|
30
|
+
* error for that: an attribute with no matching rule is a valid document.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
export type SurfaceStyle = 'classic' | 'glass';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The style a document with no stored preference renders at — the one Kabmo
|
|
37
|
+
* shipped before the setting existed, so an upgrade changes nothing.
|
|
38
|
+
*/
|
|
39
|
+
export const DEFAULT_SURFACE_STYLE: SurfaceStyle = 'classic';
|
|
40
|
+
|
|
41
|
+
/** Document attribute carrying the style. Read by CSS only. */
|
|
42
|
+
export const SURFACE_ATTRIBUTE = 'data-surface';
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* `app_settings` key holding the style, in the `kabmo_settings` blob.
|
|
46
|
+
*
|
|
47
|
+
* It lives HERE, beside the type and the copy, because two processes read it:
|
|
48
|
+
* the browser (`client/hooks/ui/surface-style.ts`) and the SSR shell that has to
|
|
49
|
+
* paint the first frame (`server/lib/assets/shell-attributes.server.ts`). A key
|
|
50
|
+
* spelled at both ends is a setting that saves and never loads.
|
|
51
|
+
*/
|
|
52
|
+
export const SURFACE_STYLE_SETTING_KEY = 'surfaceStyle';
|
|
53
|
+
|
|
54
|
+
/** Every style, in the order the settings control lists them. */
|
|
55
|
+
export const SURFACE_STYLES = ['classic', 'glass'] as const;
|
|
56
|
+
|
|
57
|
+
/** A stored value written by another build is not a style this one can draw. */
|
|
58
|
+
export function isSurfaceStyle(value: unknown): value is SurfaceStyle {
|
|
59
|
+
return value === 'classic' || value === 'glass';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The style to APPLY for a stored value. Anything this build cannot draw — a
|
|
64
|
+
* value from a newer build, a corrupted blob, `undefined` on a fresh install —
|
|
65
|
+
* resolves to the default rather than to a rule that does not exist.
|
|
66
|
+
*/
|
|
67
|
+
export function resolveSurfaceStyle(value: unknown): SurfaceStyle {
|
|
68
|
+
return isSurfaceStyle(value) ? value : DEFAULT_SURFACE_STYLE;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface SurfaceStyleCopy {
|
|
72
|
+
/** Card title. */
|
|
73
|
+
label: string;
|
|
74
|
+
/** One line under the title: the tradeoff, not the aesthetic. */
|
|
75
|
+
description: string;
|
|
76
|
+
/** The card's miniature caption, so the drawing is not the only cue. */
|
|
77
|
+
caption: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const SURFACE_STYLE_COPY: Record<SurfaceStyle, SurfaceStyleCopy> = {
|
|
81
|
+
classic: {
|
|
82
|
+
label: 'Classic',
|
|
83
|
+
description: 'Opaque panels on the palette canvas. The sharpest text, the cheapest frame, and what an upgrade keeps.',
|
|
84
|
+
caption: 'Opaque · no blur',
|
|
85
|
+
},
|
|
86
|
+
glass: {
|
|
87
|
+
label: 'Glass',
|
|
88
|
+
description: 'One frosted plane under a palette-tinted glow, with translucent panels above it. Softer edges, one blur pass per window.',
|
|
89
|
+
caption: 'Frosted · 1 blur pass',
|
|
90
|
+
},
|
|
91
|
+
};
|
|
@@ -30,7 +30,9 @@ import { mixHex, parseHexColor, relativeLuminance, rgbaToHex } from '@/shared/li
|
|
|
30
30
|
import { THEME_STYLE_ELEMENT_ID, themeStyleSheet } from '@/shared/lib/theme/css';
|
|
31
31
|
import { KABMO_PALETTES } from '@/shared/lib/theme/palettes/kabmo';
|
|
32
32
|
import { DARK_PALETTES } from '@/shared/lib/theme/palettes/dark';
|
|
33
|
+
import { DARK_EXTENDED_PALETTES } from '@/shared/lib/theme/palettes/dark-extended';
|
|
33
34
|
import { LIGHT_PALETTES } from '@/shared/lib/theme/palettes/light';
|
|
35
|
+
import { LIGHT_EXTENDED_PALETTES } from '@/shared/lib/theme/palettes/light-extended';
|
|
34
36
|
import { THEMES } from '@/shared/lib/theme/catalog';
|
|
35
37
|
|
|
36
38
|
const PALETTE_KEYS = [
|
|
@@ -160,7 +162,9 @@ describe('generated stylesheet', () => {
|
|
|
160
162
|
});
|
|
161
163
|
|
|
162
164
|
describe('palette sources', () => {
|
|
163
|
-
const
|
|
165
|
+
const LIGHT_ALL = [...LIGHT_PALETTES, ...LIGHT_EXTENDED_PALETTES];
|
|
166
|
+
const DARK_ALL = [...DARK_PALETTES, ...DARK_EXTENDED_PALETTES];
|
|
167
|
+
const all = [...KABMO_PALETTES, ...LIGHT_ALL, ...DARK_ALL];
|
|
164
168
|
|
|
165
169
|
test('every palette declares the same twelve keys', () => {
|
|
166
170
|
for (const palette of all) {
|
|
@@ -183,16 +187,16 @@ describe('palette sources', () => {
|
|
|
183
187
|
expect(seen.has(palette.id), `duplicate id ${palette.id}`).toBe(false);
|
|
184
188
|
seen.add(palette.id);
|
|
185
189
|
}
|
|
186
|
-
for (const palette of
|
|
187
|
-
for (const palette of
|
|
190
|
+
for (const palette of LIGHT_ALL) expect(palette.variant).toBe('light');
|
|
191
|
+
for (const palette of DARK_ALL) expect(palette.variant).toBe('dark');
|
|
188
192
|
expect(all.length).toBe(THEMES.length);
|
|
189
193
|
});
|
|
190
194
|
|
|
191
195
|
test('the ported families pair up: every light family has a dark twin', () => {
|
|
192
|
-
const light = new Set(
|
|
193
|
-
const dark = new Set(
|
|
194
|
-
expect(
|
|
195
|
-
expect(
|
|
196
|
+
const light = new Set(LIGHT_ALL.map((palette) => palette.family));
|
|
197
|
+
const dark = new Set(DARK_ALL.map((palette) => palette.family));
|
|
198
|
+
expect(light.size).toBe(LIGHT_ALL.length);
|
|
199
|
+
expect(dark.size).toBe(DARK_ALL.length);
|
|
196
200
|
expect([...light].filter((family) => !dark.has(family))).toEqual([]);
|
|
197
201
|
expect([...dark].filter((family) => !light.has(family))).toEqual([]);
|
|
198
202
|
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One panel id, ONE hue — the property that four surfaces were breaking.
|
|
8
|
+
*
|
|
9
|
+
* The measurements that motivated this: `Files` drew at `hsl(0 …)` on the
|
|
10
|
+
* activity bar (hash of the PANEL id) and `hsl(320 …)` in Settings → Panel
|
|
11
|
+
* Plugins → Built-in (hash of the GLYPH `Files`), and `Wiki`'s `BookOpen` was
|
|
12
|
+
* `info` in Settings because a glyph that MEANS something takes a signal colour.
|
|
13
|
+
* These tests pin the two things that make the disagreement impossible: the map
|
|
14
|
+
* is derived from the whole built-in set (so it cannot depend on what a surface
|
|
15
|
+
* is drawing), and every view gets a slot of its own.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { describe, expect, test } from 'bun:test';
|
|
19
|
+
import { RIGHT_PANEL_TYPES } from '@/shared/lib/workspace/right-panels';
|
|
20
|
+
import { SESSIONS_VIEW_ID } from '@/shared/lib/workspace/left-dock';
|
|
21
|
+
import { hashHue } from '@/shared/lib/icons/tint';
|
|
22
|
+
import { panelHueOf, panelHueUniverse, resolvePanelHues } from '@/shared/lib/workspace/panel-hues';
|
|
23
|
+
|
|
24
|
+
describe('panel hues', () => {
|
|
25
|
+
test('the universe holds every built-in view and the dock view, and nothing else', () => {
|
|
26
|
+
const universe = panelHueUniverse();
|
|
27
|
+
expect(new Set(universe)).toEqual(new Set([SESSIONS_VIEW_ID, ...RIGHT_PANEL_TYPES]));
|
|
28
|
+
expect(universe.length).toBe(RIGHT_PANEL_TYPES.length + 1);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('every built-in view gets a hue of its own', () => {
|
|
32
|
+
// A collision is what `assignPanelHues` exists to resolve: 13 views on a
|
|
33
|
+
// 36-slot wheel collide by birthday about nine times in ten, and two
|
|
34
|
+
// neighbours on one blue is the opposite of "each panel has its colour".
|
|
35
|
+
const hues = resolvePanelHues();
|
|
36
|
+
expect(hues.size).toBe(panelHueUniverse().length);
|
|
37
|
+
expect(new Set(hues.values()).size).toBe(hues.size);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('the answer does not depend on what a surface draws or the order it asks', () => {
|
|
41
|
+
// The defect this replaces: the rail built its map from the panels it was
|
|
42
|
+
// DRAWING, so switching one off or dragging it recoloured the rest, and
|
|
43
|
+
// Settings (which lists the switched-off views too) could never agree.
|
|
44
|
+
// `panelHueOf` is a pure lookup on one static map.
|
|
45
|
+
const hues = resolvePanelHues();
|
|
46
|
+
const forward = panelHueUniverse().map((id) => panelHueOf(hues, id));
|
|
47
|
+
const reversed = [...panelHueUniverse()].reverse().map((id) => panelHueOf(hues, id));
|
|
48
|
+
expect(reversed).toEqual([...forward].reverse());
|
|
49
|
+
expect(panelHueOf(hues, 'files')).toBe(hues.get('files')!);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('an id outside the map keeps a stable hue instead of a shared default', () => {
|
|
53
|
+
// A plugin's slot id, or an id from a newer version. Falling back to
|
|
54
|
+
// `DEFAULT_ICON_HUE` would paint every unknown panel the same neutral blue,
|
|
55
|
+
// which is the "one colour for everything" failure the mode exists to avoid.
|
|
56
|
+
const hues = resolvePanelHues();
|
|
57
|
+
expect(panelHueOf(hues, 'plugin:unknown:rightPanel')).toBe(hashHue('plugin:unknown:rightPanel'));
|
|
58
|
+
expect(panelHueOf(hues, 'plugin:a:rightPanel')).not.toBe(panelHueOf(hues, 'plugin:b:rightPanel'));
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('a built-in hue is keyed by the PANEL id, never the glyph', () => {
|
|
62
|
+
// The literal defect: `lucide-files` hashes to 320, `files` to 0. If the map
|
|
63
|
+
// ever answered with the glyph's hue again, these two lines catch it.
|
|
64
|
+
const hues = resolvePanelHues();
|
|
65
|
+
expect(panelHueOf(hues, 'files')).toBe(hashHue('files'));
|
|
66
|
+
expect(panelHueOf(hues, 'files')).not.toBe(hashHue('Files'));
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The colour a BUILT-IN panel's mark is drawn in, as one fact for every surface.
|
|
8
|
+
*
|
|
9
|
+
* A built-in panel's mark is drawn by the activity bar, the phone's chip strip
|
|
10
|
+
* and the Built-in list in Settings, and each of them used to answer "what
|
|
11
|
+
* colour is this?" differently: the rail hashed the PANEL ID (`files` → 0°),
|
|
12
|
+
* while the two lists drew the glyph and therefore took the GLYPH's hue
|
|
13
|
+
* (`lucide-files` → 320°, and `lucide-book-open` even fell through to the `info`
|
|
14
|
+
* signal colour). One panel, two colours — measured, the same `Files` mark was
|
|
15
|
+
* `hsl(0 …)` in the rail and `hsl(320 …)` in Settings.
|
|
16
|
+
*
|
|
17
|
+
* The answer is computed ONCE, over the whole SET of built-in views rather than
|
|
18
|
+
* over whatever a surface happens to be drawing:
|
|
19
|
+
*
|
|
20
|
+
* - **The universe is fixed, not the drawn set.** Every built-in view plus the
|
|
21
|
+
* dock's own view, including the ones switched OFF — because the Settings list
|
|
22
|
+
* draws exactly those, and the colour must not change when a view is toggled
|
|
23
|
+
* or dragged.
|
|
24
|
+
* - **Collisions are resolved over that same universe** (`assignPanelHues`), so
|
|
25
|
+
* two neighbours never land on one blue, and the answer does not depend on the
|
|
26
|
+
* order a surface asks in.
|
|
27
|
+
*
|
|
28
|
+
* A PLUGIN panel is deliberately absent: its colour is the plugin's OWN mark
|
|
29
|
+
* colour (the brand hex its manifest declares, else the hue of its name), the
|
|
30
|
+
* same one its marketplace card draws. Keying that by the slot id instead would
|
|
31
|
+
* give one plugin two colours — the exact defect this module removes.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import { assignPanelHues, hashHue } from '@/shared/lib/icons/tint';
|
|
35
|
+
import { RIGHT_PANEL_TYPES } from '@/shared/lib/workspace/right-panels';
|
|
36
|
+
import { SESSIONS_VIEW_ID } from '@/shared/lib/workspace/left-dock';
|
|
37
|
+
|
|
38
|
+
/** Every id the built-in hue map is computed over: all of them, drawn or not. */
|
|
39
|
+
export function panelHueUniverse(): string[] {
|
|
40
|
+
return [SESSIONS_VIEW_ID, ...RIGHT_PANEL_TYPES];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The hue map every surface reads. */
|
|
44
|
+
export function resolvePanelHues(): Map<string, number> {
|
|
45
|
+
return assignPanelHues(panelHueUniverse());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The hue for one panel id, with the plain hash as the fallback.
|
|
50
|
+
*
|
|
51
|
+
* An id outside the universe is one this build does not know — a plugin's slot,
|
|
52
|
+
* an id from a newer version. A stable hash still gives it a colour on the same
|
|
53
|
+
* wheel instead of the neutral default every unknown glyph shares.
|
|
54
|
+
*/
|
|
55
|
+
export function panelHueOf(hues: ReadonlyMap<string, number>, panelId: string): number {
|
|
56
|
+
return hues.get(panelId) ?? hashHue(panelId);
|
|
57
|
+
}
|
|
@@ -46,6 +46,8 @@ export interface PanelRegistryEntry {
|
|
|
46
46
|
cssUrl?: string;
|
|
47
47
|
/** Absolute URL of the plugin's icon, when it declares one. */
|
|
48
48
|
iconUrl?: string;
|
|
49
|
+
/** The colour the plugin's mark is drawn in, when its manifest declares one. */
|
|
50
|
+
color?: string;
|
|
49
51
|
/** Absolute URL of the plugin's README, when it ships one. */
|
|
50
52
|
readmeUrl?: string;
|
|
51
53
|
}
|
|
@@ -165,6 +167,8 @@ export interface PanelPluginStatus {
|
|
|
165
167
|
homepage?: string;
|
|
166
168
|
/** The slots the manifest DECLARES; live registrations are authoritative. */
|
|
167
169
|
slots?: PanelSlotName[];
|
|
170
|
+
/** The mark colour the manifest declares, when it declares one. */
|
|
171
|
+
color?: string;
|
|
168
172
|
capabilities?: string[];
|
|
169
173
|
/** How many settings the manifest declares, so the card can say what is configurable. */
|
|
170
174
|
settingsCount?: number;
|
|
@@ -203,6 +207,8 @@ export interface PanelCatalogEntry {
|
|
|
203
207
|
description?: string;
|
|
204
208
|
/** Absolute URL of the plugin's icon, when the store's copy declares one. */
|
|
205
209
|
iconUrl?: string;
|
|
210
|
+
/** The mark colour the store's copy declares, so a card can preview it. */
|
|
211
|
+
color?: string;
|
|
206
212
|
/** Absolute URL of the plugin's README, when the store's copy ships one. */
|
|
207
213
|
readmeUrl?: string;
|
|
208
214
|
/** True once the plugin is installed — the row then offers Enable/Remove. */
|
|
@@ -95,6 +95,20 @@ export interface PanelPluginManifest {
|
|
|
95
95
|
capabilities?: string[];
|
|
96
96
|
/** Optional icon file, relative to the plugin root. */
|
|
97
97
|
icon?: string;
|
|
98
|
+
/**
|
|
99
|
+
* The colour this plugin's mark is drawn in, as a CSS hex (`#RRGGBB`).
|
|
100
|
+
*
|
|
101
|
+
* Declared by the plugin because only the plugin knows its own brand — the
|
|
102
|
+
* host's alternative is a hue hashed from the plugin's NAME, which is stable
|
|
103
|
+
* but arbitrary (`hashHue`), and a marketplace author who ships a logo should
|
|
104
|
+
* not have that logo tinted by a hash. Read by the activity bar's colour mode;
|
|
105
|
+
* absent means the host falls back to the hashed hue.
|
|
106
|
+
*
|
|
107
|
+
* Hex only, and validated on the server: the value reaches an inline custom
|
|
108
|
+
* property, so `color: url(...)` or `red; background: …` must not be able to
|
|
109
|
+
* arrive through a manifest. The same rule the project accent follows.
|
|
110
|
+
*/
|
|
111
|
+
color?: string;
|
|
98
112
|
/**
|
|
99
113
|
* Optional README, relative to the plugin root. Markdown, shown in the pane's
|
|
100
114
|
* reader so a user can judge a plugin before installing it.
|
|
@@ -3,6 +3,8 @@ import type { ChatWidthMode } from '@/shared/lib/chat/timeline/width-mode';
|
|
|
3
3
|
import type { ToolRenderMode } from '@/shared/lib/chat/timeline/tool-render-mode';
|
|
4
4
|
import type { SidebarStyle } from '@/shared/lib/workspace/sidebar-style';
|
|
5
5
|
import type { ComposerStyle } from '@/shared/lib/chat/composer/style';
|
|
6
|
+
import type { SurfaceStyle } from '@/shared/lib/theme/surface-style';
|
|
7
|
+
import type { IconStyle } from '@/shared/lib/theme/icon-style';
|
|
6
8
|
|
|
7
9
|
/** Wire protocol for the live agent event stream (chat timeline). */
|
|
8
10
|
export type SettingsCategoryId =
|
|
@@ -127,6 +129,30 @@ export interface SettingsState {
|
|
|
127
129
|
* style. `classic` is the default so an upgrade rearranges nothing.
|
|
128
130
|
*/
|
|
129
131
|
composerStyle: ComposerStyle;
|
|
132
|
+
/**
|
|
133
|
+
* What the app's surfaces are cut from (`classic` | `glass`). A
|
|
134
|
+
* PRESENTATION choice over one shell: both styles draw the same panels, rows,
|
|
135
|
+
* controls and dialogs, and only the material changes. The table lives in
|
|
136
|
+
* `shared/lib/theme/surface-style.ts`; the pixels are the `[data-surface]`
|
|
137
|
+
* blocks in `tailwind.css`.
|
|
138
|
+
*
|
|
139
|
+
* It reaches the document as `data-surface` on `<html>` because the sidebar,
|
|
140
|
+
* navbar, composer and every modal are separate subtrees — a prop would be one
|
|
141
|
+
* call site each. `classic` is the default so an upgrade restyles nothing.
|
|
142
|
+
*/
|
|
143
|
+
surfaceStyle: SurfaceStyle;
|
|
144
|
+
/**
|
|
145
|
+
* How EVERY icon is painted (`monochrome` | `color`): functional Lucide
|
|
146
|
+
* glyphs, provider/model marks and file-type marks. `color` gives each glyph
|
|
147
|
+
* its own hue, keeps the palette signals for the ones whose meaning is a
|
|
148
|
+
* signal, and paints brand art in the brand's colour; a colour that would
|
|
149
|
+
* vanish on the active variant falls back to the ink. The rules are
|
|
150
|
+
* `:where()`-wrapped, so a control's own colour still wins.
|
|
151
|
+
*
|
|
152
|
+
* Document attribute `data-icon-style`; see `shared/lib/theme/icon-style.ts`
|
|
153
|
+
* and `shared/lib/icons/icon-paint-css.ts`.
|
|
154
|
+
*/
|
|
155
|
+
iconStyle: IconStyle;
|
|
130
156
|
followUpBehavior: 'queue' | 'steering';
|
|
131
157
|
keybindingSend: 'Enter' | 'Shift + Enter' | 'Ctrl / Cmd + Enter';
|
|
132
158
|
keybindingNewLine: 'Enter' | 'Shift + Enter' | 'Ctrl / Cmd + Enter';
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* SPDX-License-Identifier: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A scripted `omp` RPC child for the TRANSPORT questions `RpcProcess` owns.
|
|
9
|
+
*
|
|
10
|
+
* It exists because those questions cannot be asked of a real child: omp 18.16.0
|
|
11
|
+
* never advertises ceilings other than its own, and it never emits a malformed
|
|
12
|
+
* `rpc_chunk` sequence. Both are exactly what the reader must survive, so the
|
|
13
|
+
* child says what the test needs it to say.
|
|
14
|
+
*
|
|
15
|
+
* `ready` advertises what these env vars name, defaulting to omp's own values:
|
|
16
|
+
* FAKE_OMP_READY_MAX_FRAME_BYTES (default 1048576)
|
|
17
|
+
* FAKE_OMP_READY_MAX_REASSEMBLED_BYTES (default 67108864)
|
|
18
|
+
*
|
|
19
|
+
* `bash` is the trigger: it writes `FAKE_OMP_CHUNK` BEFORE answering, which is
|
|
20
|
+
* the only way to put a chunk record in front of the reader from inside the
|
|
21
|
+
* protocol. Values:
|
|
22
|
+
* `valid-1mib` — a complete 1 MiB sequence. Valid under the default 1 MiB
|
|
23
|
+
* physical ceiling, invalid under an advertised 4 MiB one
|
|
24
|
+
* (a frame that small is never chunked there).
|
|
25
|
+
* `bad-index` — a chunk that does not start at index 0: a hard fault.
|
|
26
|
+
* Anything else writes nothing.
|
|
27
|
+
*
|
|
28
|
+
* The source MUST stay constant: it is spawned as-is on every run.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
import { appendFileSync } from 'node:fs';
|
|
32
|
+
|
|
33
|
+
const encoder = new TextEncoder();
|
|
34
|
+
const write = (frame: unknown) => {
|
|
35
|
+
process.stdout.write(encoder.encode(`${JSON.stringify(frame)}\n`));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const numberFromEnv = (name: string, fallback: number): number => {
|
|
39
|
+
const raw = Bun.env[name];
|
|
40
|
+
const parsed = raw === undefined ? Number.NaN : Number(raw);
|
|
41
|
+
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : fallback;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const ready = {
|
|
45
|
+
type: 'ready',
|
|
46
|
+
protocolVersion: 1,
|
|
47
|
+
supportedProtocolVersions: [1, 2],
|
|
48
|
+
maxFrameBytes: numberFromEnv('FAKE_OMP_READY_MAX_FRAME_BYTES', 1024 * 1024),
|
|
49
|
+
maxReassembledFrameBytes: numberFromEnv('FAKE_OMP_READY_MAX_REASSEMBLED_BYTES', 64 * 1024 * 1024),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A complete, VALID chunk sequence for a 1 MiB logical frame — 4 slices of the
|
|
54
|
+
* 256 KiB a chunk may carry, and a byte length exactly at omp's default physical
|
|
55
|
+
* ceiling (so `byteLength >= maxFrameBytes` holds there and fails under any
|
|
56
|
+
* larger advertised ceiling).
|
|
57
|
+
*
|
|
58
|
+
* The demand is what makes the ceiling test meaningful: the SAME bytes are a
|
|
59
|
+
* valid sequence under the default ceiling and a protocol fault under an
|
|
60
|
+
* advertised 4 MiB one, because a frame that small is never chunked then.
|
|
61
|
+
*/
|
|
62
|
+
const CHUNK_BYTES = 1024 * 1024;
|
|
63
|
+
const CHUNK_SLICE = 256 * 1024;
|
|
64
|
+
const CHUNK_COUNT = CHUNK_BYTES / CHUNK_SLICE;
|
|
65
|
+
|
|
66
|
+
function validSequence(): Uint8Array[] {
|
|
67
|
+
const head = '{"type":"noop","pad":"';
|
|
68
|
+
const tail = '"}';
|
|
69
|
+
const json = `${head}${'A'.repeat(CHUNK_BYTES - head.length - tail.length)}${tail}`;
|
|
70
|
+
const bytes = new TextEncoder().encode(json);
|
|
71
|
+
return Array.from({ length: CHUNK_COUNT }, (_, index) => bytes.subarray(index * CHUNK_SLICE, (index + 1) * CHUNK_SLICE));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function scriptedChunks(mode: string | undefined): Record<string, unknown>[] {
|
|
75
|
+
if (mode === 'valid-1mib') {
|
|
76
|
+
const slices = validSequence();
|
|
77
|
+
return slices.map((slice, index) => ({
|
|
78
|
+
type: 'rpc_chunk',
|
|
79
|
+
chunkId: 'fake-1',
|
|
80
|
+
index,
|
|
81
|
+
count: CHUNK_COUNT,
|
|
82
|
+
byteLength: CHUNK_BYTES,
|
|
83
|
+
data: slice.toBase64(),
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
if (mode === 'bad-index') {
|
|
87
|
+
return [{
|
|
88
|
+
type: 'rpc_chunk',
|
|
89
|
+
chunkId: 'fake-2',
|
|
90
|
+
index: 5,
|
|
91
|
+
count: CHUNK_COUNT,
|
|
92
|
+
byteLength: CHUNK_BYTES,
|
|
93
|
+
data: new Uint8Array(1024).fill(65).toBase64(),
|
|
94
|
+
}];
|
|
95
|
+
}
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const respond = (id: unknown, command: string, data: unknown) => {
|
|
100
|
+
write({ type: 'response', id, command, success: true, data });
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const state = {
|
|
104
|
+
sessionId: 'fake-session',
|
|
105
|
+
sessionFile: '/tmp/fake-session.jsonl',
|
|
106
|
+
isStreaming: false,
|
|
107
|
+
isSettled: true,
|
|
108
|
+
isCompacting: false,
|
|
109
|
+
autoCompactionEnabled: true,
|
|
110
|
+
interruptMode: 'immediate',
|
|
111
|
+
steeringMode: 'one-at-a-time',
|
|
112
|
+
followUpMode: 'one-at-a-time',
|
|
113
|
+
messageCount: 0,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
write(ready);
|
|
117
|
+
|
|
118
|
+
const decoder = new TextDecoder();
|
|
119
|
+
let buffer = '';
|
|
120
|
+
const stdin = Bun.stdin.stream().getReader();
|
|
121
|
+
|
|
122
|
+
for (;;) {
|
|
123
|
+
const { done, value } = await stdin.read();
|
|
124
|
+
if (done) break;
|
|
125
|
+
buffer += decoder.decode(value, { stream: true });
|
|
126
|
+
let newline = buffer.indexOf('\n');
|
|
127
|
+
while (newline !== -1) {
|
|
128
|
+
const line = buffer.slice(0, newline).trim();
|
|
129
|
+
buffer = buffer.slice(newline + 1);
|
|
130
|
+
newline = buffer.indexOf('\n');
|
|
131
|
+
if (!line) continue;
|
|
132
|
+
let frame: Record<string, unknown>;
|
|
133
|
+
try {
|
|
134
|
+
frame = JSON.parse(line) as Record<string, unknown>;
|
|
135
|
+
} catch {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const id = frame.id;
|
|
139
|
+
switch (frame.type) {
|
|
140
|
+
case 'negotiate_protocol':
|
|
141
|
+
respond(id, 'negotiate_protocol', { protocolVersion: 2 });
|
|
142
|
+
break;
|
|
143
|
+
case 'bash': {
|
|
144
|
+
for (const chunk of scriptedChunks(Bun.env.FAKE_OMP_CHUNK)) write(chunk);
|
|
145
|
+
respond(id, 'bash', { output: 'fake', exitCode: 0, cancelled: false, truncated: false, totalLines: 1, totalBytes: 4, outputLines: 1, outputBytes: 4 });
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case 'prompt': {
|
|
149
|
+
const log = Bun.env.FAKE_OMP_PROMPT_LOG;
|
|
150
|
+
if (log) {
|
|
151
|
+
try {
|
|
152
|
+
appendFileSync(log, `${JSON.stringify({ id, type: frame.type })}\n`);
|
|
153
|
+
} catch {}
|
|
154
|
+
}
|
|
155
|
+
respond(id, 'prompt', { agentInvoked: false });
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
default:
|
|
159
|
+
respond(id, String(frame.type), state);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|