@kabmo-labs/kabmo 0.13.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +319 -319
- package/dist/client/static/js/index-bnrrw242.css +1 -0
- package/dist/client/static/js/{index-vzb1qz51.js → index-w6jx0h0p.js} +780 -780
- package/marketplace/plugins/command-runner/package.json +2 -2
- package/marketplace/plugins/command-runner/src/server/ring.test.ts +41 -0
- package/marketplace/plugins/command-runner/src/server/run-types.ts +6 -0
- package/marketplace/plugins/command-runner/src/server/runner-harness.ts +69 -0
- package/marketplace/plugins/command-runner/src/server/runner-path.test.ts +127 -0
- package/marketplace/plugins/command-runner/src/server/runner.test.ts +2 -72
- package/marketplace/plugins/command-runner/src/server/runner.ts +31 -3
- package/package.json +2 -2
- package/src/client/components/common/batch-selection/BatchActionBar.test.ts +42 -5
- package/src/client/components/common/batch-selection/BatchActionBar.tsx +57 -14
- package/src/client/components/common/code-surface/extensions.ts +7 -1
- package/src/client/components/common/code-surface/fold-placeholder.ts +43 -0
- package/src/client/components/common/session-row/StatusSlot.tsx +133 -0
- package/src/client/components/common/session-row/TrailingSlot.tsx +84 -0
- package/src/client/components/common/session-row/index.tsx +215 -0
- package/src/client/components/common/session-row/session-row.test.tsx +154 -0
- package/src/client/components/layout/session-sidebar/ClassicView.tsx +121 -0
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +99 -112
- package/src/client/components/layout/session-sidebar/Toolbar.tsx +2 -2
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +149 -0
- package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +150 -0
- package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +75 -0
- package/src/client/components/layout/session-sidebar/modern/Skeleton.tsx +56 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +193 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +333 -0
- package/src/client/components/layout/session-sidebar/modern/index.tsx +147 -0
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +111 -0
- package/src/client/components/layout/session-sidebar/variant-props.ts +73 -0
- package/src/client/components/mobile/SessionSidebar.tsx +137 -146
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +140 -0
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +3 -3
- package/src/client/components/mobile/mobile-session-sidebar/use-drawer.ts +104 -0
- package/src/client/components/settings/Modal.tsx +5 -27
- package/src/client/components/settings/Sidebar.tsx +1 -1
- package/src/client/components/settings/apply-side-effects.test.ts +102 -0
- package/src/client/components/settings/apply-side-effects.ts +90 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +11 -1
- package/src/client/components/settings/categories/ChatSettings.test.tsx +121 -0
- package/src/client/components/settings/categories/ChatSettings.tsx +80 -15
- package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +157 -0
- package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +177 -0
- package/src/client/components/settings/categories/chat-settings/LayoutSection.tsx +1 -1
- package/src/client/components/settings/categories/chat-settings/SidebarList.tsx +73 -0
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +144 -0
- package/src/client/components/settings/categories/chat-settings/groups.test.ts +42 -0
- package/src/client/components/settings/categories/chat-settings/groups.ts +81 -0
- package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +1 -68
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +7 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +15 -5
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +90 -41
- package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +13 -6
- package/src/client/components/workspace/chat-timeline/ThinkingSection.test.tsx +117 -0
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +117 -75
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.test.ts +28 -8
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +48 -4
- package/src/client/components/workspace/chat-timeline/TurnRail.tsx +64 -0
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +178 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerNotice.tsx +50 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +178 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +102 -122
- package/src/client/components/workspace/chat-timeline/chat-input/props.ts +7 -0
- package/src/client/components/workspace/chat-timeline/chat-input/styles/index.tsx +111 -0
- package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +181 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/approval-gate.test.tsx +31 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/plugin-renderers.ts +6 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +98 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolCardShell.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph.tsx +56 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label.ts +19 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +132 -0
- package/src/client/components/workspace/chat-timeline/{ToolCallCard.plugin.test.ts → tool-renderers/styles/Card.plugin.test.ts} +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +60 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +89 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +72 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +84 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/props.ts +22 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +153 -0
- package/src/client/components/workspace/diff-panel/folding.ts +6 -1
- package/src/client/components/workspace/editor/viewers/SvgPreview.tsx +16 -2
- package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +86 -12
- package/src/client/components/workspace/model-dropdown/Item.tsx +56 -19
- package/src/client/components/workspace/model-dropdown/Panel.tsx +21 -13
- package/src/client/components/workspace/model-dropdown/Section.test.tsx +114 -4
- package/src/client/components/workspace/model-dropdown/Section.tsx +21 -9
- package/src/client/components/workspace/model-dropdown/groups.test.ts +164 -1
- package/src/client/components/workspace/model-dropdown/groups.ts +94 -17
- package/src/client/components/workspace/model-dropdown/index.tsx +27 -19
- package/src/client/data/settings/omp-schema.json +151 -6
- package/src/client/hooks/chat/composer/style.ts +66 -0
- package/src/client/hooks/chat/timeline/row-window-reveal.ts +130 -0
- package/src/client/hooks/chat/timeline/row-window.test.ts +35 -0
- package/src/client/hooks/chat/timeline/row-window.ts +59 -133
- package/src/client/hooks/chat/timeline/thinking-open.ts +67 -0
- package/src/client/hooks/chat/timeline/tool-render-mode.ts +65 -0
- package/src/client/hooks/settings/providers/login.ts +11 -2
- package/src/client/hooks/ui/window-event.ts +20 -4
- package/src/client/hooks/workspace/batch-archive-run.ts +47 -0
- package/src/client/hooks/workspace/batch-archive.test.ts +59 -0
- package/src/client/hooks/workspace/batch-archive.ts +78 -0
- package/src/client/hooks/workspace/sidebar-batch.ts +95 -0
- package/src/client/hooks/workspace/sidebar-style.ts +66 -0
- package/src/client/tailwind.css +111 -0
- package/src/server/index.ts +10 -134
- package/src/server/lib/lifecycle/after-listen.ts +178 -0
- package/src/server/lib/lifecycle/rejection-guard.test.ts +79 -0
- package/src/server/lib/lifecycle/rejection-guard.ts +74 -0
- package/src/server/lib/lifecycle/tls.test.ts +7 -7
- package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +131 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +46 -0
- package/src/server/lib/omp/rpc/frame-fold.test.ts +1 -100
- package/src/server/lib/omp/rpc/frame-fold.ts +13 -0
- package/src/server/lib/plugins/background.server.ts +17 -1
- package/src/server/lib/plugins/background.test.ts +33 -0
- package/src/server/routes/sessions/batch-archive.test.ts +113 -0
- package/src/server/routes/sessions/batch-archive.ts +80 -0
- package/src/server/routes/sessions/index.ts +4 -0
- package/src/shared/lib/chat/composer/style.test.ts +126 -0
- package/src/shared/lib/chat/composer/style.ts +171 -0
- package/src/shared/lib/chat/composer/tui-only.test.ts +3 -0
- package/src/shared/lib/chat/composer/tui-only.ts +5 -0
- package/src/shared/lib/chat/timeline/block-chrome.ts +129 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.test.ts +51 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.ts +74 -0
- package/src/shared/lib/chat/timeline/trace-groups.test.ts +132 -0
- package/src/shared/lib/chat/timeline/trace-groups.ts +95 -0
- package/src/shared/lib/settings/defaults.ts +6 -0
- package/src/shared/lib/workspace/session-focus.test.ts +93 -0
- package/src/shared/lib/workspace/session-focus.ts +71 -0
- package/src/shared/lib/workspace/session-state/store.ts +5 -0
- package/src/shared/lib/workspace/sidebar-filter-row.test.ts +73 -0
- package/src/shared/lib/workspace/sidebar-filter-row.ts +86 -0
- package/src/shared/lib/workspace/sidebar-style.test.ts +58 -0
- package/src/shared/lib/workspace/sidebar-style.ts +86 -0
- package/src/shared/types/omp/agent.ts +6 -0
- package/src/shared/types/settings/state.ts +31 -0
- package/dist/client/static/js/index-68w8h33q.css +0 -1
- package/src/client/components/workspace/chat-timeline/ToolCallCard.tsx +0 -194
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The batch machine, wired once for both sidebars.
|
|
8
|
+
*
|
|
9
|
+
* `useBatchSelection` and `useBatchDeleteRun` are the state; this joins them to
|
|
10
|
+
* the list that is actually on screen, because three facts have to be computed
|
|
11
|
+
* the same way by the desktop dock and the phone drawer or the bar claims
|
|
12
|
+
* something the user cannot act on:
|
|
13
|
+
*
|
|
14
|
+
* - **the scope folder** — the workspace a SESSION batch belongs to, found in
|
|
15
|
+
* the RENDERED list (a folder that was deleted under the selection is not a
|
|
16
|
+
* scope);
|
|
17
|
+
* - **what is available** — every workspace id in workspace mode, the scope
|
|
18
|
+
* folder's offerable rows in session mode, nothing otherwise;
|
|
19
|
+
* - **what is selected** — `liveSelection`, so an id that vanished from the
|
|
20
|
+
* list is neither counted nor sent to the server.
|
|
21
|
+
*
|
|
22
|
+
* The binding object it returns is the shape both category components read
|
|
23
|
+
* (`BatchBinding`), so a row cannot grow a checkbox in one layout and not the
|
|
24
|
+
* other.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { useCallback } from 'preact/hooks';
|
|
28
|
+
import { useBatchSelection } from '@/client/hooks/workspace/batch-selection';
|
|
29
|
+
import { useBatchDeleteRun } from '@/client/hooks/workspace/batch-delete-run';
|
|
30
|
+
import { useBatchArchiveRun } from '@/client/hooks/workspace/batch-archive-run';
|
|
31
|
+
import { liveSelection, selectableSessionIds } from '@/shared/lib/workspace/batch-select';
|
|
32
|
+
import type { BatchSelectionHandle } from '@/client/hooks/workspace/batch-selection';
|
|
33
|
+
import type { BatchDeleteRun } from '@/client/hooks/workspace/batch-delete-run';
|
|
34
|
+
import type { BatchArchiveRun } from '@/client/hooks/workspace/batch-archive-run';
|
|
35
|
+
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
36
|
+
import type { WorkspaceFolderData } from '@/shared/types';
|
|
37
|
+
|
|
38
|
+
export interface SidebarBatch {
|
|
39
|
+
/** The raw selection handle, for the bar's select-all/unselect-all and end. */
|
|
40
|
+
selection: BatchSelectionHandle;
|
|
41
|
+
/** The same machine's delete run, for the bar and the confirmation dialog. */
|
|
42
|
+
deleteRun: BatchDeleteRun;
|
|
43
|
+
/** The same machine's archive run, for the bar's Archive action. */
|
|
44
|
+
archiveRun: BatchArchiveRun;
|
|
45
|
+
/** Present only while a mode is active. */
|
|
46
|
+
binding: BatchBinding | undefined;
|
|
47
|
+
/** The workspace a session batch is scoped to, or null. */
|
|
48
|
+
scopeFolder: WorkspaceFolderData | null;
|
|
49
|
+
/** Ids the bar may act on right now. */
|
|
50
|
+
available: string[];
|
|
51
|
+
/** Ids actually selected, pruned against `available`. */
|
|
52
|
+
selected: string[];
|
|
53
|
+
/** The toolbar/chip Select control: toggles workspace mode. */
|
|
54
|
+
toggleWorkspaceSelection: () => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function useSidebarBatch(
|
|
58
|
+
folders: WorkspaceFolderData[],
|
|
59
|
+
showArchived: boolean,
|
|
60
|
+
refresh: () => void,
|
|
61
|
+
): SidebarBatch {
|
|
62
|
+
const selection = useBatchSelection();
|
|
63
|
+
const deleteRun = useBatchDeleteRun(refresh);
|
|
64
|
+
const archiveRun = useBatchArchiveRun(refresh);
|
|
65
|
+
|
|
66
|
+
const scopeFolder = selection.scopeFolderId === null
|
|
67
|
+
? null
|
|
68
|
+
: folders.find((folder) => folder.id === selection.scopeFolderId) ?? null;
|
|
69
|
+
|
|
70
|
+
const available = selection.mode === 'workspace'
|
|
71
|
+
? folders.map((folder) => String(folder.id))
|
|
72
|
+
: selection.mode === 'session'
|
|
73
|
+
? selectableSessionIds(scopeFolder?.sessions ?? [], showArchived)
|
|
74
|
+
: [];
|
|
75
|
+
const selected = liveSelection(selection.selected, available);
|
|
76
|
+
|
|
77
|
+
const binding: BatchBinding | undefined = selection.mode
|
|
78
|
+
? {
|
|
79
|
+
mode: selection.mode,
|
|
80
|
+
scopeFolderId: selection.scopeFolderId,
|
|
81
|
+
selected: selection.selected,
|
|
82
|
+
toggle: selection.toggle,
|
|
83
|
+
selectAllOf: selection.selectAllOf,
|
|
84
|
+
unselectAllOf: selection.unselectAllOf,
|
|
85
|
+
summaryOf: selection.summaryOf,
|
|
86
|
+
}
|
|
87
|
+
: undefined;
|
|
88
|
+
|
|
89
|
+
const toggleWorkspaceSelection = useCallback(() => {
|
|
90
|
+
if (selection.mode === 'workspace') selection.end();
|
|
91
|
+
else selection.begin('workspace');
|
|
92
|
+
}, [selection]);
|
|
93
|
+
|
|
94
|
+
return { selection, deleteRun, archiveRun, binding, scopeFolder, available, selected, toggleWorkspaceSelection };
|
|
95
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The one reader/writer of the session sidebar's style.
|
|
8
|
+
*
|
|
9
|
+
* A style picks a Preact component tree (`SessionsView`'s switch), so something
|
|
10
|
+
* in JavaScript must re-render when it changes — `appSettings` is a boot-time
|
|
11
|
+
* prop and would only show a new style after a reload. The settings modal calls
|
|
12
|
+
* `applySidebarStyle` when the value moves, which announces
|
|
13
|
+
* `omp:sidebar-style-changed`; `useSidebarStyle` is the single subscriber and
|
|
14
|
+
* the two sidebars (desktop dock, phone drawer) are its only consumers.
|
|
15
|
+
*
|
|
16
|
+
* The initial value comes from the primed settings snapshot
|
|
17
|
+
* (`primeKabmoSettings` in `main.tsx`), so a mounted sidebar draws the stored
|
|
18
|
+
* style on its first render — no flash of the other variant.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useState } from 'preact/hooks';
|
|
22
|
+
import { readKabmoSetting } from '@/shared/lib/settings/client';
|
|
23
|
+
import { useKabmoEvent } from '@/client/hooks/ui/window-event';
|
|
24
|
+
import type { SettingsState } from '@/shared/types';
|
|
25
|
+
import {
|
|
26
|
+
resolveSidebarStyle,
|
|
27
|
+
type SidebarStyle,
|
|
28
|
+
} from '@/shared/lib/workspace/sidebar-style';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* `app_settings` key holding the style (in the `kabmo_settings` blob).
|
|
32
|
+
*
|
|
33
|
+
* `satisfies keyof SettingsState` because the key and the field name must be
|
|
34
|
+
* the same string for persistence to work at all — renaming the field without
|
|
35
|
+
* this line would leave the setting silently unsaved.
|
|
36
|
+
*/
|
|
37
|
+
export const SIDEBAR_STYLE_SETTING_KEY = 'sidebarStyle' satisfies keyof SettingsState;
|
|
38
|
+
|
|
39
|
+
/** Window event carrying the resolved style as `detail`. */
|
|
40
|
+
export const SIDEBAR_STYLE_CHANGED_EVENT = 'omp:sidebar-style-changed';
|
|
41
|
+
|
|
42
|
+
/** The stored style, resolved against what this build can draw. */
|
|
43
|
+
export function currentSidebarStyle(appSettings?: Record<string, any>): SidebarStyle {
|
|
44
|
+
return resolveSidebarStyle(readKabmoSetting<unknown>(SIDEBAR_STYLE_SETTING_KEY, appSettings));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Announce a new style. Called by the settings modal when the value changes —
|
|
49
|
+
* the persisted copy is written by the modal's own `writeKabmoSettings`, so
|
|
50
|
+
* this function only has to make the mounted sidebar re-render.
|
|
51
|
+
*/
|
|
52
|
+
export function applySidebarStyle(style: unknown): void {
|
|
53
|
+
if (typeof window === 'undefined') return;
|
|
54
|
+
window.dispatchEvent(
|
|
55
|
+
new CustomEvent(SIDEBAR_STYLE_CHANGED_EVENT, { detail: resolveSidebarStyle(style) }),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The style the sidebar should draw, kept live across settings edits. */
|
|
60
|
+
export function useSidebarStyle(): SidebarStyle {
|
|
61
|
+
const [style, setStyle] = useState<SidebarStyle>(() => currentSidebarStyle());
|
|
62
|
+
useKabmoEvent(SIDEBAR_STYLE_CHANGED_EVENT, (event) => {
|
|
63
|
+
setStyle(resolveSidebarStyle((event as CustomEvent<unknown>).detail));
|
|
64
|
+
});
|
|
65
|
+
return style;
|
|
66
|
+
}
|
package/src/client/tailwind.css
CHANGED
|
@@ -326,6 +326,117 @@
|
|
|
326
326
|
margin-inline: auto;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
/* ---- Composer style -------------------------------------------------------
|
|
330
|
+
*
|
|
331
|
+
* The composer's style states ORDER and STRUCTURE in JavaScript
|
|
332
|
+
* (`shared/lib/chat/composer/style.ts`) and its PIXELS here, keyed by two
|
|
333
|
+
* attributes the card carries. The split is not stylistic: Tailwind resolves
|
|
334
|
+
* two utilities of the same property by the order its RULES were emitted, so a
|
|
335
|
+
* style writing `rounded-md` into the same element as the expansion frame's
|
|
336
|
+
* `rounded-xl` rendered 12px regardless of class order (measured on `console`).
|
|
337
|
+
* These rules are plain CSS, unlayered, so they beat both utilities.
|
|
338
|
+
*
|
|
339
|
+
* `classic` states nothing: it is the shipped card, and every rule below is an
|
|
340
|
+
* OVERRIDE of it.
|
|
341
|
+
*/
|
|
342
|
+
[data-composer-style="calm"] {
|
|
343
|
+
border-radius: 1rem; /* rounded-2xl */
|
|
344
|
+
}
|
|
345
|
+
[data-composer-style="calm"] .composer-attach-row {
|
|
346
|
+
padding-bottom: 0.25rem;
|
|
347
|
+
}
|
|
348
|
+
[data-composer-style="calm"] .composer-toolbar-row {
|
|
349
|
+
padding-bottom: 0.375rem;
|
|
350
|
+
}
|
|
351
|
+
[data-composer-style="calm"] .composer-draft {
|
|
352
|
+
padding-inline: 0.875rem;
|
|
353
|
+
padding-top: 0.875rem;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
[data-composer-style="console"] {
|
|
357
|
+
border-radius: 0.375rem; /* rounded-md */
|
|
358
|
+
}
|
|
359
|
+
[data-composer-style="console"] .composer-draft {
|
|
360
|
+
font-family: 'Fira Code', ui-monospace, SFMono-Regular, monospace;
|
|
361
|
+
font-size: 12.5px;
|
|
362
|
+
}
|
|
363
|
+
[data-composer-style="console"] .composer-attach-row,
|
|
364
|
+
[data-composer-style="console"] .composer-toolbar-row {
|
|
365
|
+
padding-bottom: 0.25rem;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/* `glass` — a translucent capsule. The ONE style that departs from the paper
|
|
369
|
+
* identity in `DESIGN.md` §4 (flat, opaque, zero gradients), and it is here
|
|
370
|
+
* because it was asked for as a choice, not because the default changed.
|
|
371
|
+
*
|
|
372
|
+
* Everything is still a TOKEN: no raw hex, no chroma. The frosted surface is
|
|
373
|
+
* `--theme-paper` at 58%, the sheen is `--theme-ink` at 3–5%, so every palette
|
|
374
|
+
* in the catalog moves this card with it. That is also why the source render's
|
|
375
|
+
* "coloured glow behind send" is NOT reproduced: chroma is reserved for
|
|
376
|
+
* `--theme-error` (`DESIGN.md` §1), and a style is not a licence to break it.
|
|
377
|
+
*
|
|
378
|
+
* The blur has nothing to blur in the DOCKED state — the card sits below the
|
|
379
|
+
* transcript in normal flow, over the canvas — so there it reads as frosted
|
|
380
|
+
* paper. It has a real subject when the phone STRETCHES the composer over the
|
|
381
|
+
* transcript (`fixed inset-0`), which is the state the effect was drawn for.
|
|
382
|
+
*/
|
|
383
|
+
[data-composer-style="glass"] {
|
|
384
|
+
border-radius: 1.25rem;
|
|
385
|
+
border-color: color-mix(in srgb, var(--theme-ink) 12%, transparent);
|
|
386
|
+
background-color: color-mix(in srgb, var(--theme-paper) 58%, transparent);
|
|
387
|
+
background-image: linear-gradient(
|
|
388
|
+
180deg,
|
|
389
|
+
color-mix(in srgb, var(--theme-ink) 5%, transparent) 0%,
|
|
390
|
+
color-mix(in srgb, var(--theme-ink) 1.5%, transparent) 38%,
|
|
391
|
+
transparent 100%
|
|
392
|
+
);
|
|
393
|
+
backdrop-filter: blur(16px) saturate(1.15);
|
|
394
|
+
-webkit-backdrop-filter: blur(16px) saturate(1.15);
|
|
395
|
+
box-shadow: 0 1px 0 0 color-mix(in srgb, var(--theme-ink) 6%, transparent);
|
|
396
|
+
}
|
|
397
|
+
[data-composer-style="glass"] .composer-attach-row {
|
|
398
|
+
padding-bottom: 0.25rem;
|
|
399
|
+
}
|
|
400
|
+
[data-composer-style="glass"] .composer-toolbar-row {
|
|
401
|
+
padding-bottom: 0.5rem;
|
|
402
|
+
}
|
|
403
|
+
[data-composer-style="glass"] .composer-draft {
|
|
404
|
+
padding-inline: 1rem;
|
|
405
|
+
padding-top: 0.875rem;
|
|
406
|
+
}
|
|
407
|
+
/* A browser without `backdrop-filter` gets an opaque card rather than a
|
|
408
|
+
* half-transparent one with nothing behind the blur: a 58% paper card over the
|
|
409
|
+
* canvas is legible, a 58% card over the transcript is not. */
|
|
410
|
+
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
|
|
411
|
+
[data-composer-style="glass"] {
|
|
412
|
+
background-color: var(--theme-paper);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/* A card that FILLS the viewport has no corners. The style rules above set a
|
|
417
|
+
* radius as plain CSS, so they beat the expansion frame's own `rounded-none`
|
|
418
|
+
* (measured: a stretched `glass` card kept 20px over a `fixed inset-0` surface,
|
|
419
|
+
* showing the canvas at its corners — and `console` kept 6px the same way).
|
|
420
|
+
* One rule, after every style, stated once. */
|
|
421
|
+
[data-composer-style][data-composer-expanded="true"] {
|
|
422
|
+
border-radius: 0;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/* `stage` differs ONLY while the chat is still empty, and only in the card and
|
|
426
|
+
* the draft: a taller, softer frame so the first prompt is not written into a
|
|
427
|
+
* 68px slot in the middle of a blank screen. `hero` is written by the composer
|
|
428
|
+
* from the transcript's own length. */
|
|
429
|
+
[data-composer-hero="true"] {
|
|
430
|
+
border-radius: 1rem;
|
|
431
|
+
border-color: color-mix(in srgb, var(--theme-ink) 15%, transparent);
|
|
432
|
+
}
|
|
433
|
+
[data-composer-hero="true"] .composer-draft {
|
|
434
|
+
min-height: 132px;
|
|
435
|
+
padding-inline: 1rem;
|
|
436
|
+
padding-block: 0.875rem;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
|
|
329
440
|
/* Markdown rendered output (marked) — mirrors the previous react-markdown
|
|
330
441
|
* component styling with semantic tags. */
|
|
331
442
|
:root {
|
package/src/server/index.ts
CHANGED
|
@@ -9,28 +9,20 @@ import { resolveRunPassword } from '@/server/lib/auth/env-password';
|
|
|
9
9
|
import { readHandoverFromStdin } from '@/shared/lib/auth/handover';
|
|
10
10
|
import { ssrRoutes } from '@/server/plugins/ssr';
|
|
11
11
|
import { setListener } from '@/server/lib/lifecycle/listener';
|
|
12
|
-
import { getDatabasePath
|
|
13
|
-
import { compactChatOverlayRows } from '@/server/lib/db/compact-chat-overlay';
|
|
12
|
+
import { getDatabasePath } from '@/server/db.server';
|
|
14
13
|
import { logDetectedRegistry } from '@/server/lib/models/detected-registry.server';
|
|
15
14
|
import { ompStartupError, ompStartupLogLines } from '@/server/lib/omp/core/startup';
|
|
16
15
|
import { readInstanceRecord, removeInstanceRecord, writeInstanceRecord } from '@/server/lib/lifecycle/instance';
|
|
17
16
|
import { resolveLaunchMode } from '@/server/lib/lifecycle/launch-mode';
|
|
18
17
|
import { isTrayEnabledByArgv } from '@/server/lib/lifecycle/argv-flags';
|
|
19
|
-
import { ensureTray } from '@/server/lib/tray/runtime.server';
|
|
20
|
-
import { packageDir } from '@/server/lib/fs/package-root';
|
|
21
18
|
import { acquirePortLock, claimPort, PortInUseError } from '@/server/lib/lifecycle/port-guard';
|
|
22
19
|
import { ensureTlsCertificate, isTlsEnabledByArgv } from '@/server/lib/lifecycle/tls';
|
|
23
20
|
import { SHELL_ROUTE } from '@/server/lib/lifecycle/shell-route';
|
|
24
21
|
import { isMockMode } from '@/server/mock.server';
|
|
25
22
|
import { migrateLegacyDataDir } from '@/server/lib/lifecycle/paths';
|
|
26
|
-
import { stopDiscoveryRootsWatch, syncDiscoveryRootsWatch } from '@/server/lib/omp/config/roots-watch.server';
|
|
27
|
-
import { installMemoryMaintenance, stopMemoryMaintenance } from '@/server/lib/lifecycle/memory';
|
|
28
|
-
import { startScheduleRuntime, stopScheduleRuntime } from '@/server/lib/schedule/runtime.server';
|
|
29
|
-
import { startWaitingRuntime, stopWaitingRuntime } from '@/server/lib/waiting/runtime.server';
|
|
30
23
|
import { seedDefaultMarketplace } from '@/server/lib/panels/seed.server';
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import { disposeAllPluginsOnShutdown, loadPluginServers } from '@/server/lib/plugins/loader.server';
|
|
24
|
+
import { installRejectionGuard } from '@/server/lib/lifecycle/rejection-guard';
|
|
25
|
+
import { installShutdownHandlers, runAfterListenTasks } from '@/server/lib/lifecycle/after-listen';
|
|
34
26
|
|
|
35
27
|
// A pre-rename install keeps its database, login and sessions: the data
|
|
36
28
|
// directory is moved into place before ANYTHING reads a path under it. This is
|
|
@@ -38,6 +30,11 @@ import { disposeAllPluginsOnShutdown, loadPluginServers } from '@/server/lib/plu
|
|
|
38
30
|
// instance record and the SQLite file all live there.
|
|
39
31
|
migrateLegacyDataDir();
|
|
40
32
|
|
|
33
|
+
// Before anything starts a timer, a plugin or a socket: a rejection from code we
|
|
34
|
+
// do not own (a marketplace plugin's own background loop) must be REPORTED, not
|
|
35
|
+
// allowed to exit a process that hosts every live session. See the module.
|
|
36
|
+
installRejectionGuard();
|
|
37
|
+
|
|
41
38
|
// Refuse to run without a resolvable omp binary — before the listener opens and
|
|
42
39
|
// before the first request can reach a route that shells out to it. The database
|
|
43
40
|
// is opened lazily by getDb(), so this exits without touching it.
|
|
@@ -223,126 +220,5 @@ await logDetectedRegistry();
|
|
|
223
220
|
|
|
224
221
|
console.log(`[kabmo] listening on ${tlsOptions ? 'https' : 'http'}://${host}:${port}`);
|
|
225
222
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
* existed. Deliberately HERE and NOT inside `getDb()`: the test suite reaches
|
|
229
|
-
* `getDb()` in real mode, and opening a database must not launch a rewrite of
|
|
230
|
-
* every mirrored conversation (measured: a `bun test` run compacted a live one).
|
|
231
|
-
* Marker-keyed, so from the second start it is one indexed SELECT.
|
|
232
|
-
*/
|
|
233
|
-
try {
|
|
234
|
-
await compactChatOverlayRows(await getDb());
|
|
235
|
-
} catch (error) {
|
|
236
|
-
console.error('[chat-overlay] compaction skipped:', error);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Watch the skill/command roots omp reads, so a SKILL.md written by anything
|
|
241
|
-
* other than Kabmo (a hand edit, `git pull`, the skills CLI, another
|
|
242
|
-
* agent) reaches the live sessions without a restart. See the module — the
|
|
243
|
-
* refresh itself is `/reload-plugins`, this only decides when.
|
|
244
|
-
*/
|
|
245
|
-
try {
|
|
246
|
-
await syncDiscoveryRootsWatch();
|
|
247
|
-
} catch (error) {
|
|
248
|
-
console.error('[discovery-watch] watcher setup skipped:', error);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* The scheduled-task clock. Started after the listener is up and the watchers
|
|
253
|
-
* are attached, so a task that fires early cannot race the schema or the
|
|
254
|
-
* discovery roots; the runtime's own first tick is delayed for the same reason.
|
|
255
|
-
* Idempotent, and anchored on `globalThis` — a `bun --hot` reload must not
|
|
256
|
-
* leave a second interval running.
|
|
257
|
-
*/
|
|
258
|
-
startScheduleRuntime();
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* The waiting-prompt clock: a prompt held until another session finishes. Same
|
|
262
|
-
* shape and the same placement — after the listener and the watchers, because
|
|
263
|
-
* the first sweep may spawn an omp child.
|
|
264
|
-
*/
|
|
265
|
-
startWaitingRuntime();
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Bring installed BUNDLED plugins up to the copy this package ships.
|
|
269
|
-
*
|
|
270
|
-
* A Kabmo update replaces the store and leaves the install — it is a
|
|
271
|
-
* copied directory of ordinary files — so this is the only thing that notices.
|
|
272
|
-
* An install Kabmo wrote is compared by CONTENT, so a shipped fix applies even
|
|
273
|
-
* when its version did not move; a directory of unknown provenance keeps the
|
|
274
|
-
* version gate, and git clones are skipped, so a plugin the user installed from
|
|
275
|
-
* a URL is never overwritten by a store entry that happens to share its id.
|
|
276
|
-
*
|
|
277
|
-
* BEFORE the server halves load, and that order is the whole point: a plugin's
|
|
278
|
-
* server half is `import()`ed from its BUILT bundle, so whichever copy is on
|
|
279
|
-
* disk when that import runs is the code this process runs until it restarts.
|
|
280
|
-
* Running the sync second meant the boot that shipped a fix loaded the OLD
|
|
281
|
-
* bundle (measured: a boot logging `synced command-runner 1.0.1 → 1.0.2` had
|
|
282
|
-
* already loaded the 1.0.1 half, so the panel kept spawning with the pre-fix
|
|
283
|
-
* environment until a manual restart). Syncing first makes the boot that
|
|
284
|
-
* installs a fix the boot that runs it.
|
|
285
|
-
*/
|
|
286
|
-
try {
|
|
287
|
-
const synced = await syncBundledPlugins();
|
|
288
|
-
for (const item of synced.updated) {
|
|
289
|
-
// A content-only sync has no version to show, and printing `1.0.0 → 1.0.0`
|
|
290
|
-
// would read as a no-op when a shipped fix actually landed.
|
|
291
|
-
const span = item.contentOnly ? `${item.to} (content changed, version unchanged)` : `${item.from} → ${item.to}`;
|
|
292
|
-
console.log(`[kabmo] plugins: synced ${item.pluginId} ${span}`);
|
|
293
|
-
if (item.warning) console.error(`[plugins] ${item.pluginId}: rebuild after sync failed — ${item.warning}`);
|
|
294
|
-
}
|
|
295
|
-
for (const failure of synced.failed) console.error(`[plugins] ${failure.pluginId}: bundled sync failed — ${failure.error}`);
|
|
296
|
-
} catch (error) {
|
|
297
|
-
console.error('[plugins] bundled sync skipped:', error);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* The plugin platform's server half. After the listener is up, the scheduled-task
|
|
302
|
-
* clock exists — a plugin's own schedules register with that runtime — and the
|
|
303
|
-
* bundled sync above, so the module imported here is the copy this package
|
|
304
|
-
* ships. Never throws: one broken plugin must not stop the boot, and its reason
|
|
305
|
-
* is reported here and by `GET /api/plugins`.
|
|
306
|
-
*/
|
|
307
|
-
try {
|
|
308
|
-
const result = await loadPluginServers();
|
|
309
|
-
if (result.loaded.length > 0) {
|
|
310
|
-
console.log(`[kabmo] plugins: ${result.loaded.length} server half(s) loaded (${result.loaded.join(', ')})`);
|
|
311
|
-
}
|
|
312
|
-
for (const failure of result.errors) console.error(`[plugins] ${failure.pluginId}: ${failure.reason}`);
|
|
313
|
-
} catch (error) {
|
|
314
|
-
console.error('[plugins] server halves skipped:', error);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/** The git-plugin freshness clock. Opt-in, started after the plugin platform so
|
|
318
|
-
* its first pass sees the installed plugins; the setting is re-read each pass. */
|
|
319
|
-
startPanelAutoUpdate();
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* The tray icon, when `--tray` was passed (`serve --tray`, or the login entry
|
|
323
|
-
* the CLI writes for `--startup`). After the listener is up, because the config
|
|
324
|
-
* carries the URL the icon opens. Never throws: a machine with no tray client
|
|
325
|
-
* (Linux without yad/zenity) reports why and keeps serving.
|
|
326
|
-
*/
|
|
327
|
-
if (isTrayEnabledByArgv()) {
|
|
328
|
-
const result = ensureTray({ port, host, tls: Boolean(tlsOptions), pkgRoot: packageDir() });
|
|
329
|
-
if (result.started) console.log('[kabmo] tray: icon shown');
|
|
330
|
-
else console.log(`[kabmo] tray: not shown — ${result.reason}`);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// A full collection past the ceiling, never a schedule (`lib/lifecycle/memory.ts`).
|
|
334
|
-
installMemoryMaintenance();
|
|
335
|
-
|
|
336
|
-
for (const signal of ['SIGTERM', 'SIGINT'] as const) {
|
|
337
|
-
process.once(signal, () => {
|
|
338
|
-
stopDiscoveryRootsWatch();
|
|
339
|
-
stopMemoryMaintenance();
|
|
340
|
-
stopScheduleRuntime();
|
|
341
|
-
stopWaitingRuntime();
|
|
342
|
-
void app.stop();
|
|
343
|
-
// Plugins own children and listeners nothing else releases, and a detached
|
|
344
|
-
// child outlives its parent — so this is awaited BEFORE the exit. It is
|
|
345
|
-
// bounded internally, so a plugin that hangs cannot hold the port.
|
|
346
|
-
void disposeAllPluginsOnShutdown().finally(() => process.exit(0));
|
|
347
|
-
});
|
|
348
|
-
}
|
|
223
|
+
await runAfterListenTasks({ port, host, tls: Boolean(tlsOptions) });
|
|
224
|
+
installShutdownHandlers(() => void app.stop());
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Everything the server starts AFTER its listener is accepting requests.
|
|
8
|
+
*
|
|
9
|
+
* Split out of `index.ts` so the entry file stays a readable boot script: the
|
|
10
|
+
* ordering rules below are the whole content of this module, and they are the
|
|
11
|
+
* part a reader needs to see in one place.
|
|
12
|
+
*
|
|
13
|
+
* The order is not cosmetic. Each clock starts once the thing it reads exists:
|
|
14
|
+
* the scheduled-task and waiting-prompt runtimes after the watchers (their first
|
|
15
|
+
* sweep may spawn an omp child), the bundled plugin sync before the server
|
|
16
|
+
* halves are imported (a half is `import()`ed from its BUILT bundle, so the copy
|
|
17
|
+
* on disk at that moment is the code this process runs until it restarts), and
|
|
18
|
+
* the tray last because its config carries the URL the listener now serves.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { getDb } from '@/server/db.server';
|
|
22
|
+
import { compactChatOverlayRows } from '@/server/lib/db/compact-chat-overlay';
|
|
23
|
+
import { packageDir } from '@/server/lib/fs/package-root';
|
|
24
|
+
import { isTrayEnabledByArgv } from '@/server/lib/lifecycle/argv-flags';
|
|
25
|
+
import { installMemoryMaintenance, stopMemoryMaintenance } from '@/server/lib/lifecycle/memory';
|
|
26
|
+
import { syncDiscoveryRootsWatch, stopDiscoveryRootsWatch } from '@/server/lib/omp/config/roots-watch.server';
|
|
27
|
+
import { startPanelAutoUpdate } from '@/server/lib/panels/auto-update.server';
|
|
28
|
+
import { syncBundledPlugins } from '@/server/lib/panels/sync.server';
|
|
29
|
+
import { disposeAllPluginsOnShutdown, loadPluginServers } from '@/server/lib/plugins/loader.server';
|
|
30
|
+
import { startScheduleRuntime, stopScheduleRuntime } from '@/server/lib/schedule/runtime.server';
|
|
31
|
+
import { ensureTray } from '@/server/lib/tray/runtime.server';
|
|
32
|
+
import { startWaitingRuntime, stopWaitingRuntime } from '@/server/lib/waiting/runtime.server';
|
|
33
|
+
|
|
34
|
+
/** What the tray needs from the listener that is already up. */
|
|
35
|
+
export interface AfterListenTarget {
|
|
36
|
+
port: number;
|
|
37
|
+
host: string;
|
|
38
|
+
tls: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Start every post-listen clock, in the order their inputs appear.
|
|
43
|
+
*
|
|
44
|
+
* Never throws: each step reports its own failure and the server keeps serving.
|
|
45
|
+
*/
|
|
46
|
+
export async function runAfterListenTasks(target: AfterListenTarget): Promise<void> {
|
|
47
|
+
await compactChatOverlay();
|
|
48
|
+
await watchDiscoveryRoots();
|
|
49
|
+
|
|
50
|
+
// The scheduled-task clock. Started after the listener is up and the watchers
|
|
51
|
+
// are attached, so a task that fires early cannot race the schema or the
|
|
52
|
+
// discovery roots; the runtime's own first tick is delayed for the same
|
|
53
|
+
// reason. Idempotent, and anchored on `globalThis` — a `bun --hot` reload must
|
|
54
|
+
// not leave a second interval running.
|
|
55
|
+
startScheduleRuntime();
|
|
56
|
+
|
|
57
|
+
// The waiting-prompt clock: a prompt held until another session finishes.
|
|
58
|
+
// Same shape and placement — its first sweep may spawn an omp child.
|
|
59
|
+
startWaitingRuntime();
|
|
60
|
+
|
|
61
|
+
await syncBundledPluginsAndReport();
|
|
62
|
+
await loadPluginServerHalves();
|
|
63
|
+
startPanelAutoUpdate();
|
|
64
|
+
startTray(target);
|
|
65
|
+
|
|
66
|
+
// A full collection past the ceiling, never a schedule (`lifecycle/memory.ts`).
|
|
67
|
+
installMemoryMaintenance();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Stop every clock this module started, and the listener, then exit.
|
|
72
|
+
*
|
|
73
|
+
* `stopListener` is passed in because the Elysia app belongs to the entry file;
|
|
74
|
+
* this only owns the order and the await-before-exit rule.
|
|
75
|
+
*/
|
|
76
|
+
export function installShutdownHandlers(stopListener: () => void | Promise<void>): void {
|
|
77
|
+
for (const signal of ['SIGTERM', 'SIGINT'] as const) {
|
|
78
|
+
process.once(signal, () => {
|
|
79
|
+
stopDiscoveryRootsWatch();
|
|
80
|
+
stopMemoryMaintenance();
|
|
81
|
+
stopScheduleRuntime();
|
|
82
|
+
stopWaitingRuntime();
|
|
83
|
+
void stopListener();
|
|
84
|
+
// Plugins own children and listeners nothing else releases, and a detached
|
|
85
|
+
// child outlives its parent — so this is awaited BEFORE the exit. It is
|
|
86
|
+
// bounded internally, so a plugin that hangs cannot hold the port.
|
|
87
|
+
void disposeAllPluginsOnShutdown().finally(() => process.exit(0));
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* One-time rewrite of the overlay rows written before
|
|
94
|
+
* `overlayRowsForOmpSession` existed. Deliberately HERE and NOT inside `getDb()`:
|
|
95
|
+
* the test suite reaches `getDb()` in real mode, and opening a database must not
|
|
96
|
+
* launch a rewrite of every mirrored conversation (measured: a `bun test` run
|
|
97
|
+
* compacted a live one). Marker-keyed, so from the second start it is one
|
|
98
|
+
* indexed SELECT.
|
|
99
|
+
*/
|
|
100
|
+
async function compactChatOverlay(): Promise<void> {
|
|
101
|
+
try {
|
|
102
|
+
await compactChatOverlayRows(await getDb());
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error('[chat-overlay] compaction skipped:', error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Watch the skill/command roots omp reads, so a SKILL.md written by anything
|
|
110
|
+
* other than Kabmo (a hand edit, `git pull`, the skills CLI, another agent)
|
|
111
|
+
* reaches the live sessions without a restart. See the module — the refresh
|
|
112
|
+
* itself is `/reload-plugins`, this only decides when.
|
|
113
|
+
*/
|
|
114
|
+
async function watchDiscoveryRoots(): Promise<void> {
|
|
115
|
+
try {
|
|
116
|
+
await syncDiscoveryRootsWatch();
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.error('[discovery-watch] watcher setup skipped:', error);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Bring installed BUNDLED plugins up to the copy this package ships.
|
|
124
|
+
*
|
|
125
|
+
* A Kabmo update replaces the store and leaves the install — it is a copied
|
|
126
|
+
* directory of ordinary files — so this is the only thing that notices. An
|
|
127
|
+
* install Kabmo wrote is compared by CONTENT, so a shipped fix applies even when
|
|
128
|
+
* its version did not move; a directory of unknown provenance keeps the version
|
|
129
|
+
* gate, and git clones are skipped, so a plugin the user installed from a URL is
|
|
130
|
+
* never overwritten by a store entry that happens to share its id.
|
|
131
|
+
*/
|
|
132
|
+
async function syncBundledPluginsAndReport(): Promise<void> {
|
|
133
|
+
try {
|
|
134
|
+
const synced = await syncBundledPlugins();
|
|
135
|
+
for (const item of synced.updated) {
|
|
136
|
+
// A content-only sync has no version to show, and printing `1.0.0 → 1.0.0`
|
|
137
|
+
// would read as a no-op when a shipped fix actually landed.
|
|
138
|
+
const span = item.contentOnly ? `${item.to} (content changed, version unchanged)` : `${item.from} → ${item.to}`;
|
|
139
|
+
console.log(`[kabmo] plugins: synced ${item.pluginId} ${span}`);
|
|
140
|
+
if (item.warning) console.error(`[plugins] ${item.pluginId}: rebuild after sync failed — ${item.warning}`);
|
|
141
|
+
}
|
|
142
|
+
for (const failure of synced.failed) console.error(`[plugins] ${failure.pluginId}: bundled sync failed — ${failure.error}`);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
console.error('[plugins] bundled sync skipped:', error);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The plugin platform's server half. After the listener is up, the scheduled-task
|
|
150
|
+
* clock exists — a plugin's own schedules register with that runtime — and the
|
|
151
|
+
* bundled sync ran, so the module imported here is the copy this package ships.
|
|
152
|
+
* Never throws: one broken plugin must not stop the boot, and its reason is
|
|
153
|
+
* reported here and by `GET /api/plugins`.
|
|
154
|
+
*/
|
|
155
|
+
async function loadPluginServerHalves(): Promise<void> {
|
|
156
|
+
try {
|
|
157
|
+
const result = await loadPluginServers();
|
|
158
|
+
if (result.loaded.length > 0) {
|
|
159
|
+
console.log(`[kabmo] plugins: ${result.loaded.length} server half(s) loaded (${result.loaded.join(', ')})`);
|
|
160
|
+
}
|
|
161
|
+
for (const failure of result.errors) console.error(`[plugins] ${failure.pluginId}: ${failure.reason}`);
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.error('[plugins] server halves skipped:', error);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* The tray icon, when `--tray` was passed (`serve --tray`, or the login entry the
|
|
169
|
+
* CLI writes for `--startup`). After the listener is up, because the config
|
|
170
|
+
* carries the URL the icon opens. Never throws: a machine with no tray client
|
|
171
|
+
* (Linux without yad/zenity) reports why and keeps serving.
|
|
172
|
+
*/
|
|
173
|
+
function startTray(target: AfterListenTarget): void {
|
|
174
|
+
if (!isTrayEnabledByArgv()) return;
|
|
175
|
+
const result = ensureTray({ ...target, pkgRoot: packageDir() });
|
|
176
|
+
if (result.started) console.log('[kabmo] tray: icon shown');
|
|
177
|
+
else console.log(`[kabmo] tray: not shown — ${result.reason}`);
|
|
178
|
+
}
|