@khorsheed/dsh-local-agent-codex 0.1.0-rc.6

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.
@@ -0,0 +1,31 @@
1
+ //#region lib/types/invariant.js
2
+ /**
3
+ * Package-owned invariant companion for `@khorsheed/dsh-local-agent-codex`.
4
+ * @module @khorsheed/dsh-local-agent-codex/invariant
5
+ */
6
+ const PACKAGE_NAME = "@khorsheed/dsh-local-agent-codex";
7
+ /** Cordis companion plugin name. */
8
+ const name = "local-agent-codex-invariant";
9
+ /** Service required before the companion can reserve package ownership. */
10
+ const inject = ["invariants"];
11
+ /**
12
+ * The codex harness definition is this bundle's contract with the core
13
+ * registry: whenever a `codex` harness registers, its scoped-home variable
14
+ * must be the one this bundle pins.
15
+ */
16
+ const install = (ctx, fail) => {
17
+ ctx.on("internal/dispatch", (_mode, eventName, args) => {
18
+ if (eventName !== "localAgent/harness-added") return;
19
+ const harness = args[0];
20
+ if (harness.name !== "codex") return;
21
+ if (harness.homeEnvVar !== "CODEX_HOME") fail("codex harness registered with a home env other than the local-agent-codex contract");
22
+ }, { global: true });
23
+ };
24
+ /**
25
+ * Register this package's invariant companion.
26
+ * @param ctx - plugin context carrying the invariant registry.
27
+ * @returns the installed registration's disposer.
28
+ */
29
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
30
+ //#endregion
31
+ export { apply, inject, name };
@@ -0,0 +1,76 @@
1
+ import type { HarnessModelPickerInput } from '@khorsheed/dsh-local-agent/client';
2
+ import type { ReactNode } from 'react';
3
+ import type { SettingsScope } from '@khorsheed/dsh-local-agent/src/client/settings-scope.ts';
4
+ import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
5
+ import { type ProviderAuthBlockProps, type ProviderAuthInjected } from '@khorsheed/dsh-local-agent/src/client/ProviderAuthBlock.tsx';
6
+ import type { LocalAgentModelInfo } from '@khorsheed/dsh-local-agent/types';
7
+ import { NS } from './locales.ts';
8
+ /** The `local-agent-codex` settings namespace section the card edits. */
9
+ export interface CodexLiveSettings {
10
+ /** Resident (live) mode: one resident `codex app-server` process per member. */
11
+ live?: boolean;
12
+ /**
13
+ * The model every delegation round starts the CLI with. Absent (the field
14
+ * cleared) means the plugin passes no model at all — the scoped `config.toml`'s own `model` decides,
15
+ * exactly as before the key existed.
16
+ */
17
+ model?: string;
18
+ /** Model identifiers saved before; the input's suggestions, capped at five. */
19
+ recentModels?: readonly string[];
20
+ }
21
+ /** Injected face of the codex settings card. */
22
+ export interface CodexSettingsCardInjected {
23
+ renderModelPicker?: ((props: HarnessModelPickerInput) => ReactNode) | undefined;
24
+ /** Bound settings scope for the local-agent-codex namespace. */
25
+ scope: SettingsScope<CodexLiveSettings>;
26
+ /** The auth block's query/command faces, backed by the family core Remote. */
27
+ auth: ProviderAuthInjected;
28
+ /** Translate bound to the family core's `local-agent` namespace (the auth block's copy lives there). */
29
+ authT: ProviderAuthBlockProps['t'];
30
+ /**
31
+ * The harness's memberless model surface (the core gateway's `harnessModel`
32
+ * Remote): the inherited default an unset field displays and the menu's
33
+ * choice vocabulary. Undefined or null when the gateway or the broker is
34
+ * absent — the card then keeps the bare input exactly as before brokers
35
+ * existed.
36
+ */
37
+ harnessModel: () => Promise<LocalAgentModelInfo | null | undefined>;
38
+ hooks: {
39
+ /** The same scope as a hooks source, so the card reacts to external writes. */
40
+ settings: SettingsScope<CodexLiveSettings>;
41
+ };
42
+ }
43
+ /**
44
+ * Full props of the 0.1.5 settings.plugin.item card entry. The removed slot's
45
+ * owner share was intentionally empty and its root scope delivered the global
46
+ * seats; the structural type below is exact about the one seat the auth block
47
+ * consumes (the slot name is gone from the alpha.2 SlotMap, so the
48
+ * registration goes through a duck-typed narrow — see client/index.ts).
49
+ */
50
+ export type CodexSettingsCardProps = InjectFace<CodexSettingsCardInjected> & PropsLocale<typeof NS> & {
51
+ /** The standing root-scope global seat (ui-session's merge), delivered to the 0.1.5 card by the renderer. */
52
+ useSessions: ProviderAuthBlockProps['useSessions'];
53
+ };
54
+ /** Full props of the alpha.2 plugins.bundle.config entry (owner prop `view`). */
55
+ export type CodexBundleConfigProps = PropsRuntime<'plugins.bundle.config'> & InjectFace<CodexSettingsCardInjected> & PropsLocale<typeof NS>;
56
+ /**
57
+ * The codex harness settings card in the 0.1.5 plugin configuration tab: the
58
+ * same collapsible chrome the official plugin cards use, re-implemented
59
+ * locally (the bundle-purity gate forbids value-importing the official chrome
60
+ * — the context-guard pattern), with the at-a-glance credential dot in the
61
+ * header. Explanation copy lives in hover/focus bubbles behind ⓘ anchors —
62
+ * the card's rows stay one line each.
63
+ * @param props - the injected scope/auth faces and copy.
64
+ * @returns the card.
65
+ */
66
+ export declare function CodexSettingsCard(props: CodexSettingsCardProps): import("react").JSX.Element;
67
+ /**
68
+ * The bundle's configuration on the alpha.2 Plugins page
69
+ * (`plugins.bundle.config`, keyed by package name): the page draws the title,
70
+ * the icon, and the crumb itself, so the entry renders the one-liner for the
71
+ * `summary` view and the bare form — with its own save control — for `page`.
72
+ * @param props - the owner view, the injected scope/auth faces, and copy.
73
+ * @returns the entry.
74
+ */
75
+ export declare function CodexBundleConfig({ view, useSettings, scope, auth, authT, renderModelPicker, harnessModel, useSessions, t }: CodexBundleConfigProps): import("react").JSX.Element;
76
+ //# sourceMappingURL=SettingsCard.d.ts.map
@@ -0,0 +1,200 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { Tooltip } from '@deepseek-ai/dsh-client-ui-primitives';
4
+ import { IconChevronDownOutlineMedium } from './icons.js';
5
+ // The shared auth block is bundled from the family core's source — the
6
+ // sanctioned core/companion edge (the host half already depends on the core);
7
+ // the block carries no runtime identity to share.
8
+ import { ProviderAuthBlock, } from '@khorsheed/dsh-local-agent/src/client/ProviderAuthBlock.tsx';
9
+ import { AuthStatusDot } from '@khorsheed/dsh-local-agent/src/client/AuthStatusDot.tsx';
10
+ import { useHarnessAuthStatus } from '@khorsheed/dsh-local-agent/src/client/auth-status.ts';
11
+ import css from './SettingsCard.module.css';
12
+ /** How many previously-saved model identifiers the input suggests. */
13
+ const RECENT_MODEL_LIMIT = 5;
14
+ /**
15
+ * The staged card state both settings surfaces share: the resident-mode and
16
+ * model edits write through the bound settingsScope immediately
17
+ * (revision-fenced), so a flip takes effect on the next delegation round
18
+ * without a reload; the harness's model surface is fetched while the surface
19
+ * is active (the 0.1.5 card opened, the alpha.2 page mounted) and re-fetched
20
+ * after every save.
21
+ * @param active - whether the surface currently shows the body (gates the model-surface fetch).
22
+ * @param useSettings - the bound settings hook from the inject hooks compartment.
23
+ * @param scope - the bound settings scope the writes go through.
24
+ * @param harnessModel - the harness's memberless model surface read.
25
+ * @param t - copy.
26
+ */
27
+ function useCardState(active, useSettings, scope, harnessModel, t) {
28
+ const snapshot = useSettings(value => value);
29
+ const [saved, setSaved] = useState(false);
30
+ const [error, setError] = useState(false);
31
+ const ready = snapshot.status === 'ready' && snapshot.writable;
32
+ const live = snapshot.value?.live ?? false;
33
+ // The model input is a DRAFT until saved: `null` means "showing whatever the
34
+ // scope holds", so an external write (another tab, a YAML reload) still
35
+ // reaches the field while the user is not typing in it.
36
+ const storedModel = snapshot.value?.model ?? '';
37
+ const recentModels = snapshot.value?.recentModels ?? [];
38
+ const [modelDraft, setModelDraft] = useState(null);
39
+ const [modelSaved, setModelSaved] = useState(false);
40
+ const [modelError, setModelError] = useState(false);
41
+ const modelValue = modelDraft ?? storedModel;
42
+ // The harness's model surface, fetched while the surface is active (and
43
+ // re-fetched after a save): undefined until the first answer, null when the
44
+ // gateway or the broker is absent — the card then keeps the bare input with
45
+ // its recent-models suggestions, exactly as before brokers existed.
46
+ const [modelInfo, setModelInfo] = useState(undefined);
47
+ useEffect(() => {
48
+ if (!active)
49
+ return;
50
+ let stale = false;
51
+ void harnessModel().then((info) => {
52
+ if (!stale)
53
+ setModelInfo(info ?? null);
54
+ });
55
+ return () => { stale = true; };
56
+ }, [active, harnessModel, modelSaved]);
57
+ /**
58
+ * Commit the model field. A blank value UNSETS the key rather than storing
59
+ * an empty string, so the field re-inherits the YAML composition base — and
60
+ * with no base, the harness is back to passing no model at all.
61
+ */
62
+ const saveModel = () => {
63
+ const next = modelValue.trim();
64
+ setModelSaved(false);
65
+ setModelError(false);
66
+ const write = next === '' ? scope.unset('model') : scope.set('model', next);
67
+ void write.then(async () => {
68
+ // Most-recent-first, deduplicated, capped: the suggestion list is a
69
+ // memory of what this instance has actually run, never a catalog.
70
+ if (next !== '') {
71
+ await scope.set('recentModels', [next, ...recentModels.filter(value => value !== next)].slice(0, RECENT_MODEL_LIMIT));
72
+ }
73
+ setModelDraft(null);
74
+ setModelSaved(true);
75
+ }, () => { setModelError(true); });
76
+ };
77
+ const write = (field, value) => {
78
+ setSaved(false);
79
+ setError(false);
80
+ void scope.set(field, value).then(() => { setSaved(true); }, () => { setError(true); });
81
+ };
82
+ // The suggestion vocabulary: the broker's deduped union (settings + scoped
83
+ // config + discovered + recent) when the surface answered, the card's own
84
+ // recent-models memory when it did not. Never a hardcoded catalog. A
85
+ // non-empty list turns the field into a select-like control: the
86
+ // always-visible chevron opens the same vocabulary as a menu.
87
+ const choices = modelInfo?.choices ?? recentModels;
88
+ const [modelMenuOpen, setModelMenuOpen] = useState(false);
89
+ const [modelMenuUp, setModelMenuUp] = useState(false);
90
+ const modelFieldRef = useRef(null);
91
+ // Click-outside and Esc close the model menu (the member composer's picker
92
+ // pattern); the upward flip is measured when the menu opens.
93
+ useEffect(() => {
94
+ if (!modelMenuOpen)
95
+ return;
96
+ const onPointerDown = (event) => {
97
+ if (modelFieldRef.current?.contains(event.target) === true)
98
+ return;
99
+ setModelMenuOpen(false);
100
+ };
101
+ const onKeyDown = (event) => {
102
+ if (event.key === 'Escape')
103
+ setModelMenuOpen(false);
104
+ };
105
+ document.addEventListener('mousedown', onPointerDown);
106
+ document.addEventListener('keydown', onKeyDown);
107
+ return () => {
108
+ document.removeEventListener('mousedown', onPointerDown);
109
+ document.removeEventListener('keydown', onKeyDown);
110
+ };
111
+ }, [modelMenuOpen]);
112
+ const toggleModelMenu = () => {
113
+ if (!modelMenuOpen) {
114
+ const rect = modelFieldRef.current?.getBoundingClientRect();
115
+ if (rect !== undefined) {
116
+ const spaceBelow = window.innerHeight - rect.bottom;
117
+ setModelMenuUp(spaceBelow < 260 && rect.top > spaceBelow);
118
+ }
119
+ }
120
+ setModelMenuOpen(open => !open);
121
+ };
122
+ // An unset field DISPLAYS the default it follows (dimmed, as the input's
123
+ // placeholder — inherited, never pinned), down the chain the broker
124
+ // reports: the scoped config's model, then the account catalog's built-in
125
+ // default (source cli-builtin WITH an effective model — the one case
126
+ // cli-builtin names one), then the last observed model the records know,
127
+ // and last the generic copy.
128
+ const inheritedModel = modelInfo != null && modelInfo.cliDefault !== undefined && modelInfo.cliDefault !== ''
129
+ ? modelInfo.cliDefault
130
+ : modelInfo != null && modelInfo.source === 'cli-builtin' && modelInfo.effective !== undefined && modelInfo.effective !== ''
131
+ ? modelInfo.effective
132
+ : modelInfo != null && modelInfo.lastObserved !== undefined && modelInfo.lastObserved !== ''
133
+ ? modelInfo.lastObserved
134
+ : undefined;
135
+ const modelPlaceholder = inheritedModel ?? t('model.placeholder');
136
+ // The menu's leading item: the same chain, spelled as the follow-default
137
+ // choice. It reads checked while the field is unset, and picking it clears
138
+ // the draft back to follow-default (a save then unsets the key).
139
+ const modelDefaultItem = modelInfo != null && modelInfo.cliDefault !== undefined && modelInfo.cliDefault !== ''
140
+ ? t('model.menuDefault.cli-config', { model: modelInfo.cliDefault })
141
+ : modelInfo != null && modelInfo.source === 'cli-builtin' && modelInfo.effective !== undefined && modelInfo.effective !== ''
142
+ ? t('model.menuDefault.cli-builtin', { model: modelInfo.effective })
143
+ : modelInfo != null && modelInfo.lastObserved !== undefined && modelInfo.lastObserved !== ''
144
+ ? t('model.menuDefault.last-observed', { model: modelInfo.lastObserved })
145
+ : t('model.menuDefault');
146
+ return {
147
+ snapshot, saved, error, ready, live, storedModel, modelValue, modelSaved,
148
+ modelError, choices, modelMenuOpen, modelMenuUp, modelFieldRef,
149
+ modelPlaceholder, modelDefaultItem, saveModel, write, toggleModelMenu,
150
+ setModelDraft, setModelMenuOpen,
151
+ };
152
+ }
153
+ /** The card body both settings surfaces share: the auth block, the default-model block, and the resident-mode block. */
154
+ function CardBody({ state, auth, authT, renderModelPicker, useSessions, t }) {
155
+ const { snapshot, saved, error, ready, live, storedModel, modelValue, modelSaved, modelError, choices, modelMenuOpen, modelMenuUp, modelFieldRef, modelPlaceholder, modelDefaultItem, saveModel, write, toggleModelMenu, setModelDraft, setModelMenuOpen, } = state;
156
+ // The free-text input, single-sourced for both presentations: bare when no
157
+ // vocabulary exists (a fresh install degrades to exactly the pre-picker
158
+ // field), or inside the select-like field next to its chevron. No datalist:
159
+ // the chevron menu is the single choice list.
160
+ const modelInputElement = (_jsx("input", { type: "text", className: css.modelInput, value: modelValue, placeholder: modelPlaceholder, "aria-label": t('model.title'), disabled: !ready, onChange: (event) => { setModelDraft(event.target.value); } }));
161
+ return (_jsxs("div", { className: css.body, children: [_jsxs("section", { className: css.block, children: [_jsx("h3", { className: css.blockTitle, children: t('auth.title') }), _jsx(ProviderAuthBlock, { harness: { id: 'codex', label: 'Codex' }, useSessions: useSessions, status: auth.status, runCommand: auth.runCommand, t: authT })] }), _jsxs("section", { className: css.block, children: [_jsxs("h3", { className: css.blockTitle, children: [t('model.title'), _jsx(Tooltip, { label: t('model.info'), side: "bottom", maxWidth: 360, children: _jsx("button", { type: "button", className: css.info, "aria-label": t('model.info.aria'), children: "\u24D8" }) })] }), _jsxs("div", { className: css.row, children: [renderModelPicker?.({ value: modelValue, onChange: setModelDraft, disabled: !ready, defaultLabel: modelDefaultItem }) ?? (choices.length > 0 ? (_jsxs("div", { className: css.modelField, ref: modelFieldRef, children: [modelInputElement, _jsx("button", { type: "button", className: css.modelMenuButton, "aria-label": t('model.menu'), "aria-haspopup": "menu", "aria-expanded": modelMenuOpen, disabled: !ready, onClick: () => { toggleModelMenu(); }, children: _jsx(IconChevronDownOutlineMedium, { className: modelMenuOpen ? `${css.modelMenuChevron} ${css.modelMenuChevronOpen}` : css.modelMenuChevron }) }), modelMenuOpen && (_jsxs("div", { className: modelMenuUp ? `${css.modelMenu} ${css.modelMenuUp}` : css.modelMenu, role: "menu", "aria-label": t('model.menu'), children: [_jsxs("button", { type: "button", role: "menuitemradio", "aria-checked": modelValue.trim() === '', className: modelValue.trim() === '' ? `${css.modelItemDefault} ${css.modelItemCurrent}` : css.modelItemDefault, onClick: () => { setModelDraft(''); setModelMenuOpen(false); }, children: [_jsx("span", { className: css.modelItemLabel, children: modelDefaultItem }), _jsx("span", { className: css.modelItemCheck, "aria-hidden": true, children: modelValue.trim() === '' ? '✓' : '' })] }), choices.map(choice => (_jsxs("button", { type: "button", role: "menuitemradio", "aria-checked": choice === modelValue, className: choice === modelValue ? css.modelItemCurrent : css.modelItem, onClick: () => { setModelDraft(choice); setModelMenuOpen(false); }, children: [_jsx("span", { className: css.modelItemLabel, children: choice }), _jsx("span", { className: css.modelItemCheck, "aria-hidden": true, children: choice === modelValue ? '✓' : '' })] }, choice)))] }))] })) : modelInputElement), _jsx("button", { type: "button", className: css.modelSave, disabled: !ready || modelValue.trim() === storedModel, onClick: () => { saveModel(); }, children: t('model.save') })] }), modelSaved && _jsx("span", { className: css.saved, children: t('model.applied') }), modelError && _jsx("span", { className: css.errorText, children: t('model.error') })] }), _jsxs("section", { className: css.block, children: [_jsxs("div", { className: css.row, children: [_jsxs("span", { className: css.rowLabel, children: [t('live.title'), _jsx(Tooltip, { label: t('live.info'), side: "bottom", maxWidth: 360, children: _jsx("button", { type: "button", className: css.info, "aria-label": t('live.info.aria'), children: "\u24D8" }) })] }), _jsx("button", { type: "button", role: "switch", "aria-checked": live, "aria-label": t('live.title'), className: live ? `${css.switch} ${css.switchOn}` : css.switch, disabled: !ready, onClick: () => { write('live', !live); }, children: _jsx("span", { className: css.knob }) })] }), saved && _jsx("span", { className: css.saved, children: t('live.applied') }), error && _jsx("span", { className: css.errorText, children: t('live.error') }), snapshot.status === 'unavailable' && (_jsx("span", { className: css.hint, children: t('live.unavailable') }))] })] }));
162
+ }
163
+ /**
164
+ * The codex harness settings card in the 0.1.5 plugin configuration tab: the
165
+ * same collapsible chrome the official plugin cards use, re-implemented
166
+ * locally (the bundle-purity gate forbids value-importing the official chrome
167
+ * — the context-guard pattern), with the at-a-glance credential dot in the
168
+ * header. Explanation copy lives in hover/focus bubbles behind ⓘ anchors —
169
+ * the card's rows stay one line each.
170
+ * @param props - the injected scope/auth faces and copy.
171
+ * @returns the card.
172
+ */
173
+ export function CodexSettingsCard(props) {
174
+ const { useSettings, scope, auth, authT, renderModelPicker, harnessModel, useSessions, t } = props;
175
+ const [open, setOpen] = useState(false);
176
+ const state = useCardState(open, useSettings, scope, harnessModel, t);
177
+ // The at-a-glance credential dot in the collapsed header: every mount
178
+ // re-probes (a credential expiring mid-session must flip the dot at the
179
+ // next view); the bus dedupes identical results, so no re-render storm.
180
+ const authStatus = useHarnessAuthStatus('codex', auth.status);
181
+ const dotLabel = authT(authStatus === 'authenticated' ? 'settings.authenticated'
182
+ : authStatus === 'anonymous' ? 'settings.notAuthenticated'
183
+ : authStatus === 'checking' ? 'loading' : 'error');
184
+ const title = t('card.title');
185
+ return (_jsxs("li", { className: open ? `${css.card} ${css.cardOpen}` : css.card, children: [_jsxs("button", { type: "button", className: css.header, "aria-expanded": open, "aria-label": `${t(open ? 'card.collapse' : 'card.expand')}: ${title}`, onClick: () => { setOpen(!open); }, children: [_jsxs("span", { className: css.headText, children: [_jsxs("span", { className: css.nameRow, children: [_jsx("span", { className: css.name, children: title }), _jsx(AuthStatusDot, { status: authStatus, label: dotLabel })] }), _jsx("span", { className: css.description, children: t('card.description') })] }), _jsx(IconChevronDownOutlineMedium, { className: open ? `${css.chevron} ${css.chevronOpen}` : css.chevron })] }), open && _jsx(CardBody, { state: state, auth: auth, authT: authT, renderModelPicker: renderModelPicker, useSessions: useSessions, t: t })] }));
186
+ }
187
+ /**
188
+ * The bundle's configuration on the alpha.2 Plugins page
189
+ * (`plugins.bundle.config`, keyed by package name): the page draws the title,
190
+ * the icon, and the crumb itself, so the entry renders the one-liner for the
191
+ * `summary` view and the bare form — with its own save control — for `page`.
192
+ * @param props - the owner view, the injected scope/auth faces, and copy.
193
+ * @returns the entry.
194
+ */
195
+ export function CodexBundleConfig({ view, useSettings, scope, auth, authT, renderModelPicker, harnessModel, useSessions, t }) {
196
+ const state = useCardState(view === 'page', useSettings, scope, harnessModel, t);
197
+ if (view === 'summary')
198
+ return _jsx("span", { className: css.description, children: t('card.description') });
199
+ return _jsx(CardBody, { state: state, auth: auth, authT: authT, renderModelPicker: renderModelPicker, useSessions: useSessions, t: t });
200
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Generated by scripts/sync-icon-artwork.mts from @deepseek-ai/dsh-client-ui-primitives
3
+ * (v0.1.7-rc.1, harness 46a7f68b09) — do not edit by hand. The 0.1.5 and rc.1 host lines
4
+ * share no icon export name, so the rc.1 artwork is inlined here: pure SVG,
5
+ * no host runtime identity, identical on every line. Re-run the generator
6
+ * after adding an icon import or bumping the harness checkout.
7
+ *
8
+ * @module @khorsheed/dsh-local-agent-codex/client
9
+ */
10
+ /** Shared props for every product icon component (mirrors the upstream IconProps). */
11
+ export interface IconProps {
12
+ /** Square edge in px; defaults to the glyph's own drawn size. */
13
+ size?: number | undefined;
14
+ /** Extra class for layout placement; color rides currentColor. */
15
+ className?: string | undefined;
16
+ }
17
+ export declare const IconChevronDownOutlineMedium: ({ size, className }: IconProps) => import("react").JSX.Element;
18
+ //# sourceMappingURL=icons.d.ts.map
@@ -0,0 +1,2 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const IconChevronDownOutlineMedium = ({ size = 14, className }) => (_jsx("svg", { width: size, height: size, className: className, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", strokeWidth: 1.3, children: _jsx("path", { d: "M4 6L7.29289 9.29289C7.68342 9.68342 8.31658 9.68342 8.70711 9.29289L12 6", stroke: "currentColor" }) }));
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Local-agent-codex plugin, browser half: the codex settings surface, one
3
+ * face per install shape and host line — a standalone install renders the
4
+ * bundle's own configuration on its Plugins-page detail view
5
+ * (`plugins.bundle.config`, keyed by package name), a family-bundle install
6
+ * renders the same card through the row-level configure entry on the
7
+ * BUNDLE's detail view (`plugins.row.config`, keyed
8
+ * `@khorsheed/dsh-bundle-local-agent#local-agent-codex`), and 0.1.5 renders
9
+ * the `settings.plugin.item` card (keyed to the `local-agent-codex`
10
+ * settings namespace the host half registers) in the official
11
+ * Plugins → 可配置插件 tab. The card carries the family core's shared
12
+ * ProviderAuthBlock (login/logout/device-code, backed by the core's
13
+ * localAgentGateway Remote and the commands channel) plus the resident-mode
14
+ * block (live switch) and the default-model block (free-text input, the
15
+ * broker's effective-model line and suggestion vocabulary), whose writes ride
16
+ * the bound settingsScope — the host watcher hot-applies them, no reload.
17
+ * Every read degrades: an absent gateway renders the auth block's
18
+ * 'unavailable' state and drops the model surface to the bare input, an
19
+ * unregistered namespace disables the live controls.
20
+ * @module @khorsheed/dsh-local-agent-codex/client
21
+ */
22
+ import type { Context } from '@deepseek-ai/cordis';
23
+ import { en, NS, zh, type LocalAgentCodexKey } from './locales.ts';
24
+ export { CodexBundleConfig, CodexSettingsCard } from './SettingsCard.tsx';
25
+ export type { CodexLiveSettings, CodexBundleConfigProps, CodexSettingsCardInjected, CodexSettingsCardProps, } from './SettingsCard.tsx';
26
+ export { en, NS, zh };
27
+ export type { LocalAgentCodexKey };
28
+ /**
29
+ * Required services: slot registry, command Remote, and locale registry. The
30
+ * settings scope is NOT a static inject — its service name differs per host
31
+ * line (`settingsScope` on 0.1.5, `configForms` on rc.1), so a static entry
32
+ * would pend the whole client plugin on the other line; bindSettingsScope
33
+ * probes the serving one instead (the settings client package is a declared
34
+ * client inject, so one of them is always already up).
35
+ */
36
+ export declare const inject: string[];
37
+ /**
38
+ * Client plugin body: register the dictionaries and the codex settings
39
+ * surfaces bound to the local-agent-codex namespace.
40
+ * @param ctx - client root context.
41
+ */
42
+ export declare function apply(ctx: Context): void;
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,88 @@
1
+ import { bindSettingsScope } from '@khorsheed/dsh-local-agent/src/client/settings-scope.ts';
2
+ import { en, NS, zh } from './locales.js';
3
+ import { CodexBundleConfig, CodexSettingsCard, } from './SettingsCard.js';
4
+ export { CodexBundleConfig, CodexSettingsCard } from './SettingsCard.js';
5
+ export { en, NS, zh };
6
+ /**
7
+ * This bundle's package name — the key the Plugins page dispatches
8
+ * `plugins.bundle.config` entries on (identity triangle: cordis.patch.yml,
9
+ * tsdown.config.ts, invariant.ts).
10
+ */
11
+ const PACKAGE_NAME = '@khorsheed/dsh-local-agent-codex';
12
+ /**
13
+ * Required services: slot registry, command Remote, and locale registry. The
14
+ * settings scope is NOT a static inject — its service name differs per host
15
+ * line (`settingsScope` on 0.1.5, `configForms` on rc.1), so a static entry
16
+ * would pend the whole client plugin on the other line; bindSettingsScope
17
+ * probes the serving one instead (the settings client package is a declared
18
+ * client inject, so one of them is always already up).
19
+ */
20
+ export const inject = ['slots', 'remote', 'remote.commands', 'locale'];
21
+ /**
22
+ * Client plugin body: register the dictionaries and the codex settings
23
+ * surfaces bound to the local-agent-codex namespace.
24
+ * @param ctx - client root context.
25
+ */
26
+ export function apply(ctx) {
27
+ ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'local-agent-codex: dictionaries');
28
+ const scope = bindSettingsScope(ctx, 'local-agent-codex');
29
+ // The auth block's copy lives in the family core's dictionary; binding is
30
+ // stable per namespace and late dictionary registration still resolves.
31
+ const authT = ctx.locale.bind('local-agent');
32
+ // The gateway namespace is mounted by the family core's client half; read it
33
+ // lazily from the global store so boot order between the two client plugins
34
+ // never matters, and degrade to the auth block's 'unavailable' state when
35
+ // the core client is absent.
36
+ const gateway = () => ctx.get('remote.localAgentGateway');
37
+ // Both settings surfaces inject the same face.
38
+ const cardInject = () => ({
39
+ scope,
40
+ hooks: { settings: scope },
41
+ authT,
42
+ renderModelPicker: props => ctx.get('localAgentUi')?.renderHarnessModelPicker('codex', props),
43
+ // The harness's memberless model surface; absent gateway/broker
44
+ // degrades to the bare input with its recent-models suggestions.
45
+ harnessModel: () => gateway()?.harnessModel('codex').then(result => (result.ok ? result.value : undefined))
46
+ ?? Promise.resolve(undefined),
47
+ auth: {
48
+ status: name =>
49
+ // The Remote declares (name, scope?) and the client enforces exact arity:
50
+ // pass the default scope explicitly (undefined reads as omitted host-side).
51
+ gateway()?.status(name, undefined).then(result => (result.ok ? result.value : undefined))
52
+ ?? Promise.resolve(undefined),
53
+ runCommand: (sessionId, line) => ctx.remote.commands.execute(sessionId, line, [])
54
+ .then(result => (result.ok ? result.value?.result.text : undefined)),
55
+ },
56
+ });
57
+ // The settings surface follows the host line AND the install shape — three
58
+ // tracks, all riding slots.inject so each fires only where its declaration
59
+ // exists. Standalone install: the package's own Plugins-page detail view
60
+ // (`plugins.bundle.config`, keyed by package name). Installed as a family
61
+ // member: the member is no longer the profile's direct dependency, so only
62
+ // the bundle gets a detail view — the card rides the row-level slot
63
+ // (`plugins.row.config`, keyed `<bundle package>#<row id>` with the row id
64
+ // the bundle's patch declares) and the bundle's page gains a configure
65
+ // entry opening it. 0.1.5: the legacy configurable-plugins tab card
66
+ // (`settings.plugin.item`, keyed by the settings namespace) through a
67
+ // string-keyed duck narrow of the same service (the slot name is gone from
68
+ // the alpha.2 SlotMap).
69
+ ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({
70
+ name: 'plugins.bundle.config',
71
+ key: PACKAGE_NAME,
72
+ locale: NS,
73
+ inject: cardInject,
74
+ }, CodexBundleConfig));
75
+ ctx.slots.inject('plugins.row.config', () => ctx.slots.register({
76
+ name: 'plugins.row.config',
77
+ key: '@khorsheed/dsh-bundle-local-agent#local-agent-codex',
78
+ locale: NS,
79
+ inject: cardInject,
80
+ }, CodexBundleConfig));
81
+ const legacy = ctx.slots;
82
+ legacy.inject('settings.plugin.item', () => legacy.register({
83
+ name: 'settings.plugin.item',
84
+ key: 'local-agent-codex',
85
+ locale: NS,
86
+ inject: cardInject,
87
+ }, CodexSettingsCard));
88
+ }
@@ -0,0 +1,64 @@
1
+ /** `local-agent-codex` namespace dictionaries. */
2
+ /** Dictionary namespace owned by this plugin (matches the settings namespace). */
3
+ export declare const NS = "local-agent-codex";
4
+ /** Simplified Chinese dictionary (the key-set source of truth). */
5
+ export declare const zh: {
6
+ 'card.title': string;
7
+ 'card.description': string;
8
+ 'card.expand': string;
9
+ 'card.collapse': string;
10
+ 'auth.title': string;
11
+ 'model.title': string;
12
+ 'model.info.aria': string;
13
+ 'model.info': string;
14
+ 'model.placeholder': string;
15
+ 'model.menu': string;
16
+ 'model.menuDefault': string;
17
+ 'model.menuDefault.cli-config': string;
18
+ 'model.menuDefault.cli-builtin': string;
19
+ 'model.menuDefault.last-observed': string;
20
+ 'model.save': string;
21
+ 'model.applied': string;
22
+ 'model.error': string;
23
+ 'live.title': string;
24
+ 'live.info.aria': string;
25
+ 'live.info': string;
26
+ 'live.applied': string;
27
+ 'live.error': string;
28
+ 'live.unavailable': string;
29
+ };
30
+ /** The local-agent-codex namespace key union. */
31
+ export type LocalAgentCodexKey = keyof typeof zh;
32
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
33
+ interface LocaleNamespaceMap {
34
+ /** The codex harness settings card copy. */
35
+ 'local-agent-codex': LocalAgentCodexKey;
36
+ }
37
+ }
38
+ /** English dictionary, checked complete against the zh key set. */
39
+ export declare const en: {
40
+ 'card.title': string;
41
+ 'card.description': string;
42
+ 'card.expand': string;
43
+ 'card.collapse': string;
44
+ 'auth.title': string;
45
+ 'model.title': string;
46
+ 'model.info.aria': string;
47
+ 'model.info': string;
48
+ 'model.placeholder': string;
49
+ 'model.menu': string;
50
+ 'model.menuDefault': string;
51
+ 'model.menuDefault.cli-config': string;
52
+ 'model.menuDefault.cli-builtin': string;
53
+ 'model.menuDefault.last-observed': string;
54
+ 'model.save': string;
55
+ 'model.applied': string;
56
+ 'model.error': string;
57
+ 'live.title': string;
58
+ 'live.info.aria': string;
59
+ 'live.info': string;
60
+ 'live.applied': string;
61
+ 'live.error': string;
62
+ 'live.unavailable': string;
63
+ };
64
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,55 @@
1
+ /** `local-agent-codex` namespace dictionaries. */
2
+ /** Dictionary namespace owned by this plugin (matches the settings namespace). */
3
+ export const NS = 'local-agent-codex';
4
+ /** Simplified Chinese dictionary (the key-set source of truth). */
5
+ export const zh = {
6
+ 'card.title': 'Local Agent · Codex',
7
+ 'card.description': 'Codex 委派:登录授权与常驻模式(live)',
8
+ 'card.expand': '展开',
9
+ 'card.collapse': '收起',
10
+ 'auth.title': '认证',
11
+ 'model.title': '默认模型',
12
+ 'model.info.aria': '默认模型说明',
13
+ 'model.info': '留空 = 跟随默认(输入框里显示的就是当前跟随的模型)。从列表选择或手动输入一个模型名后保存,之后的每轮委派都以它起 CLI(一次性轮次走 `codex exec -m <模型>`,常驻模式走 app-server 的 `-c model=…`)。成员会话里还可用作曲器按会话切换,不影响这里的默认。改动在下一轮委派生效,进行中的轮次不受影响;评测 run 的条件在建立时冻结,中途换模型会被下一轮的模型回读判为 misattributed 而拦下。',
14
+ 'model.placeholder': '留空 = 不传模型,用 CLI 自己的默认',
15
+ 'model.menu': '选择模型',
16
+ 'model.menuDefault': '默认(跟随 CLI 内置默认)',
17
+ 'model.menuDefault.cli-config': '默认(跟随 CLI 配置:{model})',
18
+ 'model.menuDefault.cli-builtin': '默认(跟随 CLI 默认:{model})',
19
+ 'model.menuDefault.last-observed': '默认(跟随 CLI 内置默认(最近:{model}))',
20
+ 'model.save': '保存',
21
+ 'model.applied': '已保存,下一轮委派生效;进行中的轮次不受影响',
22
+ 'model.error': '保存失败,请重试',
23
+ 'live.title': '常驻模式(live)',
24
+ 'live.info.aria': '常驻模式说明',
25
+ 'live.info': '常驻模式 = 成员进程常驻:输出实时流入成员会话、取消不杀进程、崩溃后自动续上原会话;关闭则每轮独立进程,跑完一次性出结果。设置为全局偏好,对所有后续委派生效。',
26
+ 'live.applied': '已保存,下一轮委派生效;进行中的轮次不受影响',
27
+ 'live.error': '保存失败,请重试',
28
+ 'live.unavailable': '设置服务不可用(宿主未注册 local-agent-codex 命名空间)',
29
+ };
30
+ /** English dictionary, checked complete against the zh key set. */
31
+ export const en = {
32
+ 'card.title': 'Local Agent · Codex',
33
+ 'card.description': 'Codex delegation: sign-in and resident (live) mode',
34
+ 'card.expand': 'Expand',
35
+ 'card.collapse': 'Collapse',
36
+ 'auth.title': 'Authentication',
37
+ 'model.title': 'Default model',
38
+ 'model.info.aria': 'About the default model',
39
+ 'model.info': "Blank = follow the default (the input shows the model it currently follows). Pick from the list or type a model name by hand and save, and every later delegation round starts the CLI with it (`codex exec -m <model>` for one-shot rounds, `-c model=…` on the resident app-server). Inside a member session the composer can also switch the model per session, without touching this default. A change applies to the next round and never disturbs a round in flight; an evaluation run freezes its condition at setup, so switching mid-run is caught by the model read-back on the next round and fails the run as misattributed.",
40
+ 'model.placeholder': "Blank = pass no model, keep the CLI's own default",
41
+ 'model.menu': 'Pick a model',
42
+ 'model.menuDefault': "Default (follow the CLI's built-in default)",
43
+ 'model.menuDefault.cli-config': 'Default (follow the CLI config: {model})',
44
+ 'model.menuDefault.cli-builtin': 'Default (follow the CLI default: {model})',
45
+ 'model.menuDefault.last-observed': "Default (follow the CLI's built-in default (last: {model}))",
46
+ 'model.save': 'Save',
47
+ 'model.applied': 'Saved — takes effect on the next delegation round; rounds in flight are unaffected',
48
+ 'model.error': 'Save failed, please retry',
49
+ 'live.title': 'Resident mode (live)',
50
+ 'live.info.aria': 'About resident mode',
51
+ 'live.info': 'Resident mode keeps the member process alive: output streams into the member session in real time, cancelling does not kill the process, and a crash resumes the same session. Off means every round runs as an independent one-shot process. The setting is global and applies to every later delegation.',
52
+ 'live.applied': 'Saved — takes effect on the next delegation round; rounds in flight are unaffected',
53
+ 'live.error': 'Save failed, please retry',
54
+ 'live.unavailable': 'Settings service unavailable (the host did not register the local-agent-codex namespace)',
55
+ };