@dsmm/dsmm 0.3.14 → 0.3.16

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.
Files changed (65) hide show
  1. package/README.md +83 -36
  2. package/docs/agent-presets.md +1 -1
  3. package/docs/compatibility.md +3 -3
  4. package/docs/deferred-native-approval-risk.md +1 -1
  5. package/docs/design.md +1 -1
  6. package/docs/lsp.md +1 -1
  7. package/docs/model-routing.md +13 -6
  8. package/docs/native-permissions.md +1 -1
  9. package/docs/profiles.md +3 -1
  10. package/docs/roadmap.md +2 -2
  11. package/docs/runtime-recovery.md +4 -4
  12. package/docs/safety-guards.md +1 -1
  13. package/docs/settings-status.md +4 -2
  14. package/docs/tui.md +53 -0
  15. package/dsh-plugin.json +41 -0
  16. package/lib/client/DeploymentFields.js +3 -1
  17. package/lib/client/DeploymentPage.js +4 -1
  18. package/lib/client/EditableChoice.js +5 -2
  19. package/lib/client/ProfileModelsDialog.d.ts +2 -1
  20. package/lib/client/ProfileModelsDialog.js +9 -5
  21. package/lib/client/ProfilesSection.js +1 -1
  22. package/lib/client/RoleToolView-locales.d.ts +1 -1
  23. package/lib/client/RoleToolView-locales.js +2 -2
  24. package/lib/client/SessionProfiles.js +8 -7
  25. package/lib/client/children-locales.d.ts +1 -1
  26. package/lib/client/controller.d.ts +13 -1
  27. package/lib/client/controller.js +114 -20
  28. package/lib/client/deployment-locales.d.ts +2 -0
  29. package/lib/client/deployment-locales.js +6 -3
  30. package/lib/client/deployment-modules.js +1 -1
  31. package/lib/client/index.js +22 -4
  32. package/lib/client/locales.d.ts +1 -0
  33. package/lib/client/locales.js +6 -4
  34. package/lib/client/session-labels.d.ts +1 -0
  35. package/lib/client/session-labels.js +3 -0
  36. package/lib/client/styles.d.ts +1 -1
  37. package/lib/client/styles.js +23 -13
  38. package/lib/client.js +226 -86
  39. package/lib/commands.d.ts +7 -3
  40. package/lib/commands.js +20 -11
  41. package/lib/host-llm.js +6 -1
  42. package/lib/index.d.ts +1 -1
  43. package/lib/index.js +2 -6
  44. package/lib/model-routing.js +43 -19
  45. package/lib/profile-diagnostics.js +1 -0
  46. package/lib/profile-runtime.js +1 -1
  47. package/lib/request-routing.d.ts +27 -0
  48. package/lib/request-routing.js +69 -0
  49. package/lib/role-llm-runtime.js +15 -2
  50. package/lib/role-routing.d.ts +4 -3
  51. package/lib/role-routing.js +17 -10
  52. package/lib/runtime-recovery.js +56 -16
  53. package/lib/settings.d.ts +3 -0
  54. package/lib/settings.js +9 -0
  55. package/lib/state.d.ts +2 -2
  56. package/lib/state.js +13 -4
  57. package/lib/status.d.ts +5 -0
  58. package/lib/status.js +18 -7
  59. package/lib/tui-actions.d.ts +21 -0
  60. package/lib/tui-actions.js +301 -0
  61. package/lib/tui-adapter.d.ts +25 -0
  62. package/lib/tui-adapter.js +422 -0
  63. package/lib/tui-types.d.ts +98 -0
  64. package/lib/tui-types.js +2 -0
  65. package/package.json +3 -1
@@ -5,6 +5,8 @@ import { DSMM_RATE_LIMIT_BOUNDS, normalizeRateLimitPolicy } from "../routing-pol
5
5
  import { LevelFields, PolicyFields, RouteFields } from "./StructuredEditor.js";
6
6
  import { RoleAvailability, roleAvailability } from "./RoleAvailability.js";
7
7
  import { IssueDetails, issueKey } from "./diagnostics.js";
8
+ import { displayRoleLabel } from "./session-labels.js";
9
+ export { displayRoleLabel };
8
10
  function locateFieldInsideRole(roleCard, field) {
9
11
  if (!field)
10
12
  return null;
@@ -233,7 +235,8 @@ export function ProfileModelsDialog({ open, onClose, state, actions, disabled, d
233
235
  if (searchQuery.trim()) {
234
236
  const q = searchQuery.trim().toLowerCase();
235
237
  const matchesId = role.id.toLowerCase().includes(q);
236
- const matchesLabel = role.label.toLowerCase().includes(q);
238
+ const displayLabel = displayRoleLabel(role.label);
239
+ const matchesLabel = role.label.toLowerCase().includes(q) || displayLabel.toLowerCase().includes(q);
237
240
  if (!matchesId && !matchesLabel)
238
241
  return false;
239
242
  }
@@ -276,6 +279,7 @@ export function ProfileModelsDialog({ open, onClose, state, actions, disabled, d
276
279
  return (_jsxs(Modal, { open: open, onClose: onClose, title: t("modelsDialogTitle"), description: t("modelsDialogDesc"), closeLabel: t("cancel"), className: "dsmm-profile-models-dialog", contentClassName: "dsmm-profile-models-dialog-content", onKeyDownCapture: handleKeyDownCapture, children: [_jsxs("div", { ref: dialogTopBarRef, className: "dsmm-dialog-top-bar", children: [_jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: !canSave, onClick: () => { void actions.save(); }, children: t(state.busy === "save" ? "saving" : "save") }), _jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: t("cancel") })] }), state.busy === "save" ? (_jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: t("saving") })) : state.dirty ? (_jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: t("dirty") })) : null, isSaveLocked && (_jsx("div", { className: "dsmm-save-lock-reason", role: "status", children: _jsx("span", { className: "dsmm-save-lock-text", children: isInvalidProjection
277
280
  ? t("rawInvalid")
278
281
  : t("saveLockedReason", { count: state.invalidFields.length }) }) }))] }), _jsxs("div", { className: "dsmm-models-filter-bar dsmm-dialog-filter-bar", children: [_jsx("div", { className: "dsmm-field dsmm-filter-search", children: _jsx(Input, { id: `${prefix}-role-search`, className: "dsmm-input", type: "search", value: searchQuery, placeholder: t("searchRolesPlaceholder"), disabled: effectiveDisabled, onChange: (e) => setSearchQuery(e.currentTarget.value), "data-dsmm-role-search": true, "data-modal-autofocus": true }) }), _jsxs("label", { className: "dsmm-filter-label dsmm-filter-override-toggle", children: [_jsx("input", { type: "checkbox", checked: filterExplicitOnly, disabled: effectiveDisabled, onChange: (e) => setFilterExplicitOnly(e.currentTarget.checked), "data-dsmm-filter-overrides": true }), _jsx("span", { children: t("filterExplicitOverrides") })] })] }), state.issue !== null && (_jsxs("div", { className: "dsmm-issue dsmm-dialog-issue", role: "region", "aria-label": t("savedInventory"), children: [_jsx("p", { className: "dsmm-dialog-issue-title", children: t(issueKey(state.issue)) }), _jsx(IssueDetails, { issue: state.issue, t: t }), onJumpToJsonc && (_jsx("div", { className: "dsmm-dialog-issue-action", children: _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onJumpToJsonc, children: t("jumpToJsonc") }) }))] })), doc === null && (_jsxs("div", { className: "dsmm-structured-invalid", "data-dsmm-structured-invalid": true, children: [_jsx("p", { children: t("rawInvalid") }), _jsx("p", { className: "dsmm-hint", children: t("rawInvalidFormDisabled") }), onJumpToJsonc && (_jsx(Button, { type: "button", variant: "outline", onClick: onJumpToJsonc, children: t("viewConfiguration") }))] })), doc !== null && (_jsxs("div", { className: "dsmm-roles-list dsmm-dialog-roles-list", children: [filteredRoles.length === 0 && (_jsx("p", { className: "dsmm-hint dsmm-no-roles", children: t("noMatchingRoles") })), filteredRoles.map((role) => {
282
+ const roleName = displayRoleLabel(role.label);
279
283
  const policy = doc.roleRouting[role.id] ?? {};
280
284
  const rolePath = ["settings", "roleRouting", role.id];
281
285
  const isOrchestrator = role.id === "dsmm-orchestrator";
@@ -318,8 +322,8 @@ export function ProfileModelsDialog({ open, onClose, state, actions, disabled, d
318
322
  ? t("roleSettingsOverridden")
319
323
  : t("roleSettingsInherited");
320
324
  const nonModelSummary = t("roleSettingsSummary", { status: statusSummary, retry: retrySummary });
321
- return (_jsxs("div", { className: "dsmm-role-card dsmm-dialog-role-card", "data-dsmm-role": role.id, children: [_jsxs("div", { className: "dsmm-role-main-row", children: [_jsx("div", { className: "dsmm-dialog-role-header", children: _jsxs("div", { className: "dsmm-role-title-group", children: [_jsx("span", { className: "dsmm-role-title", children: role.label }), _jsx("code", { className: "dsmm-role-id-badge", children: role.id }), explicitOverride && (_jsx("span", { className: "dsmm-override-badge", children: t("roleSettingsOverridden") }))] }) }), _jsxs("div", { className: "dsmm-role-primary-route", children: [_jsxs("div", { className: "dsmm-field dsmm-primary-mode-field", children: [_jsx("label", { htmlFor: `${prefix}-${role.id}-primary-mode`, children: t("primaryMode", { name: role.label }) }), _jsxs("select", { id: `${prefix}-${role.id}-primary-mode`, disabled: effectiveDisabled, value: policy.primary === undefined ? "inherit" : "explicit", onChange: (event) => actions.editPath([...rolePath, "primary"], event.currentTarget.value === "inherit" ? undefined : { provider: "", model: "" }), children: [_jsx("option", { value: "inherit", children: t("inheritRoute") }), _jsx("option", { value: "explicit", children: t("configuredRoute") })] })] }), policy.primary !== undefined ? (_jsx(RouteFields, { t: t, value: policy.primary, path: [...rolePath, "primary"], name: t("primaryName", { name: role.label }), catalog: state.catalog, disabled: effectiveDisabled, edit: actions.editPath, editRoute: actions.editRoute, naturalLabels: true })) : (_jsx("div", { className: "dsmm-route-inherited-hint", children: _jsx("span", { children: t("inheritRouteDesc") }) })), isOrchestrator && (_jsx("span", { className: "dsmm-orchestrator-tag", children: t("orchestratorNoLevelsHint") }))] })] }), _jsxs("div", { className: "dsmm-role-details-bar", children: [!isOrchestrator && (_jsxs("details", { className: "dsmm-role-levels-details dsmm-compact-details", "data-dsmm-details": "levels", children: [_jsxs("summary", { className: "dsmm-details-summary dsmm-details-pill", children: [_jsxs("span", { className: "dsmm-pill-label", children: [t("callingLevels"), ":"] }), _jsx("span", { className: "dsmm-pill-val", children: levelsSummary })] }), _jsxs("div", { className: "dsmm-details-content", children: [_jsx("p", { className: "dsmm-hint", children: t("levelsHint") }), ["low", "high", "max"].map((level) => (_jsx(LevelFields, { level: level, value: policy.levels?.[level], path: [...rolePath, "levels", level], catalog: state.catalog, disabled: effectiveDisabled, actions: actions, t: t }, level)))] })] })), _jsxs("details", { className: "dsmm-role-fallback-details dsmm-compact-details", "data-dsmm-details": "fallback", children: [_jsxs("summary", { className: "dsmm-details-summary dsmm-details-pill", children: [_jsxs("span", { className: "dsmm-pill-label", children: [t("fallbackRoutes"), ":"] }), _jsx("span", { className: "dsmm-pill-val", children: fallbackSummary })] }), _jsxs("div", { className: "dsmm-details-content", children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-${role.id}-fallback-mode`, children: t("fallbackMode", { name: role.label }) }), _jsxs("select", { id: `${prefix}-${role.id}-fallback-mode`, disabled: effectiveDisabled, value: policy.fallbackRoutes === undefined ? "inherit" : "explicit", onChange: (event) => actions.editPath([...rolePath, "fallbackRoutes"], event.currentTarget.value === "inherit" ? undefined : []), children: [_jsx("option", { value: "inherit", children: t("inheritChain") }), _jsx("option", { value: "explicit", children: t("configuredChain") })] })] }), policy.fallbackRoutes?.length === 0 && (_jsx("p", { className: "dsmm-hint", children: t("emptyChain") })), policy.fallbackRoutes?.map((candidate, index) => {
322
- const name = t("fallbackName", { name: role.label, index: index + 1 });
325
+ return (_jsxs("div", { className: "dsmm-role-card dsmm-dialog-role-card", "data-dsmm-role": role.id, children: [_jsxs("div", { className: "dsmm-role-main-row", children: [_jsx("div", { className: "dsmm-dialog-role-header", children: _jsxs("div", { className: "dsmm-role-title-group", children: [_jsx("span", { className: "dsmm-role-title", children: roleName }), _jsx("code", { className: "dsmm-role-id-badge", children: role.id }), explicitOverride && (_jsx("span", { className: "dsmm-override-badge", children: t("roleSettingsOverridden") }))] }) }), _jsxs("div", { className: "dsmm-role-primary-route", children: [_jsxs("div", { className: "dsmm-field dsmm-primary-mode-field", children: [_jsx("label", { htmlFor: `${prefix}-${role.id}-primary-mode`, children: t("primaryMode", { name: roleName }) }), _jsxs("select", { id: `${prefix}-${role.id}-primary-mode`, disabled: effectiveDisabled, value: policy.primary === undefined ? "inherit" : "explicit", onChange: (event) => actions.editPath([...rolePath, "primary"], event.currentTarget.value === "inherit" ? undefined : { provider: "", model: "" }), children: [_jsx("option", { value: "inherit", children: t("inheritRoute") }), _jsx("option", { value: "explicit", children: t("configuredRoute") })] })] }), policy.primary !== undefined ? (_jsx(RouteFields, { t: t, value: policy.primary, path: [...rolePath, "primary"], name: t("primaryName", { name: roleName }), catalog: state.catalog, disabled: effectiveDisabled, edit: actions.editPath, editRoute: actions.editRoute, naturalLabels: true })) : (_jsx("div", { className: "dsmm-route-inherited-hint", children: _jsx("span", { children: t("inheritRouteDesc") }) })), isOrchestrator && (_jsx("span", { className: "dsmm-orchestrator-tag", children: t("orchestratorNoLevelsHint") }))] })] }), _jsxs("div", { className: "dsmm-role-details-bar", children: [!isOrchestrator && (_jsxs("details", { className: "dsmm-role-levels-details dsmm-compact-details", "data-dsmm-details": "levels", children: [_jsxs("summary", { className: "dsmm-details-summary dsmm-details-pill", children: [_jsxs("span", { className: "dsmm-pill-label", children: [t("callingLevels"), ":"] }), _jsx("span", { className: "dsmm-pill-val", children: levelsSummary })] }), _jsxs("div", { className: "dsmm-details-content", children: [_jsx("p", { className: "dsmm-hint", children: t("levelsHint") }), ["low", "high", "max"].map((level) => (_jsx(LevelFields, { level: level, value: policy.levels?.[level], path: [...rolePath, "levels", level], catalog: state.catalog, disabled: effectiveDisabled, actions: actions, t: t }, level)))] })] })), _jsxs("details", { className: "dsmm-role-fallback-details dsmm-compact-details", "data-dsmm-details": "fallback", children: [_jsxs("summary", { className: "dsmm-details-summary dsmm-details-pill", children: [_jsxs("span", { className: "dsmm-pill-label", children: [t("fallbackRoutes"), ":"] }), _jsx("span", { className: "dsmm-pill-val", children: fallbackSummary })] }), _jsxs("div", { className: "dsmm-details-content", children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-${role.id}-fallback-mode`, children: t("fallbackMode", { name: roleName }) }), _jsxs("select", { id: `${prefix}-${role.id}-fallback-mode`, disabled: effectiveDisabled, value: policy.fallbackRoutes === undefined ? "inherit" : "explicit", onChange: (event) => actions.editPath([...rolePath, "fallbackRoutes"], event.currentTarget.value === "inherit" ? undefined : []), children: [_jsx("option", { value: "inherit", children: t("inheritChain") }), _jsx("option", { value: "explicit", children: t("configuredChain") })] })] }), policy.fallbackRoutes?.length === 0 && (_jsx("p", { className: "dsmm-hint", children: t("emptyChain") })), policy.fallbackRoutes?.map((candidate, index) => {
326
+ const name = t("fallbackName", { name: roleName, index: index + 1 });
323
327
  return (_jsxs("fieldset", { className: "dsmm-fallback-item", "data-dsmm-fallback-index": index, children: [_jsx("legend", { children: name }), _jsx(RouteFields, { t: t, value: candidate, path: [...rolePath, "fallbackRoutes", index], name: name, catalog: state.catalog, disabled: effectiveDisabled, edit: actions.editPath, editRoute: actions.editRoute, naturalLabels: true }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", "data-dsmm-action": "moveUp", disabled: effectiveDisabled || index === 0, onClick: () => {
324
328
  pendingFallbackFocusRef.current = { roleId: role.id, index: index - 1, action: "moveUp" };
325
329
  actions.moveFallback(role.id, index, index - 1);
@@ -344,10 +348,10 @@ export function ProfileModelsDialog({ open, onClose, state, actions, disabled, d
344
348
  else {
345
349
  actions.editPath([...rolePath, "fallbackRoutes", policy.fallbackRoutes.length], { provider: "", model: "" });
346
350
  }
347
- }, children: t("addFallback", { name: role.label }) })] })] }), _jsxs("details", { className: "dsmm-role-nonmodel-details dsmm-compact-details", "data-dsmm-details": "non-model", children: [_jsxs("summary", { className: "dsmm-details-summary dsmm-details-pill", children: [_jsxs("span", { className: "dsmm-pill-label", children: [t("roleNonModelSettings"), ":"] }), _jsx("span", { className: "dsmm-pill-val", children: nonModelSummary })] }), _jsxs("div", { className: "dsmm-details-content", children: [_jsx(RoleAvailability, { value: role.availability, t: t }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-${role.id}-role-enabled`, children: t("namedRole", { name: role.label }) }), _jsxs("select", { id: `${prefix}-${role.id}-role-enabled`, value: namedRoles?.[role.id] === undefined ? "" : String(namedRoles[role.id]), disabled: effectiveDisabled, "aria-describedby": `${prefix}-${role.id}-role-hint`, onChange: (event) => actions.editPath(["settings", "roles", role.id], event.currentTarget.value === "" ? undefined : event.currentTarget.value === "true"), children: [_jsx("option", { value: "", children: t("inherit") }), _jsx("option", { value: "true", disabled: availability === undefined ||
351
+ }, children: t("addFallback", { name: roleName }) })] })] }), _jsxs("details", { className: "dsmm-role-nonmodel-details dsmm-compact-details", "data-dsmm-details": "non-model", children: [_jsxs("summary", { className: "dsmm-details-summary dsmm-details-pill", children: [_jsxs("span", { className: "dsmm-pill-label", children: [t("roleNonModelSettings"), ":"] }), _jsx("span", { className: "dsmm-pill-val", children: nonModelSummary })] }), _jsxs("div", { className: "dsmm-details-content", children: [_jsx(RoleAvailability, { value: role.availability, t: t }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-${role.id}-role-enabled`, children: t("namedRole", { name: roleName }) }), _jsxs("select", { id: `${prefix}-${role.id}-role-enabled`, value: namedRoles?.[role.id] === undefined ? "" : String(namedRoles[role.id]), disabled: effectiveDisabled, "aria-describedby": `${prefix}-${role.id}-role-hint`, onChange: (event) => actions.editPath(["settings", "roles", role.id], event.currentTarget.value === "" ? undefined : event.currentTarget.value === "true"), children: [_jsx("option", { value: "", children: t("inherit") }), _jsx("option", { value: "true", disabled: availability === undefined ||
348
352
  !availability.startupAvailable ||
349
353
  !availability.deploymentEnabled ||
350
- availability.reason === "module-off", children: t("enabled") }), _jsx("option", { value: "false", disabled: availability === undefined || availability.required, children: t("disabled") })] }), _jsx("p", { id: `${prefix}-${role.id}-role-hint`, className: "dsmm-hint", children: t("namedRoleHint") })] }), _jsx(PolicyFields, { t: t, value: policy, inherited: inherited, path: rolePath, name: role.label, disabled: effectiveDisabled, actions: actions })] })] })] })] }, role.id));
354
+ availability.reason === "module-off", children: t("enabled") }), _jsx("option", { value: "false", disabled: availability === undefined || availability.required, children: t("disabled") })] }), _jsx("p", { id: `${prefix}-${role.id}-role-hint`, className: "dsmm-hint", children: t("namedRoleHint") })] }), _jsx(PolicyFields, { t: t, value: policy, inherited: inherited, path: rolePath, name: roleName, disabled: effectiveDisabled, actions: actions })] })] })] })] }, role.id));
351
355
  })] }))] }));
352
356
  }
353
357
  //# sourceMappingURL=ProfileModelsDialog.js.map
@@ -218,7 +218,7 @@ export function ProfilesSection(props) {
218
218
  void props.open(event.currentTarget.value); }, children: [_jsx("option", { value: "", children: t(editor?.revision === null ? "newDraft" : "choose") }), snapshot.profiles.map((profile, index) => _jsxs("option", { value: profile.id, children: [profile.label?.trim() ? `${profile.label} (${profile.id})` : profile.id, profile.error === undefined ? "" : ` — ${t("invalidProfile", { id: profile.id })}`, profile.warnings?.length ? ` — ${t("warningProfile")}` : ""] }, `${index}:${profile.id}`))] })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || snapshot === null, onClick: (event) => { initiatorRef.current = event.currentTarget; void props.create(); }, children: t("new") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: (event) => { initiatorRef.current = event.currentTarget; void props.refresh(); }, children: t(state.busy === "refresh" ? "refreshing" : "refresh") })] }), editor !== null && _jsx("p", { className: "dsmm-badge", "data-dsmm-editor-state": state.invalidFields.length > 0 || invalid || rawInvalid ? "invalid" : state.dirty ? "dirty" : readOnly ? "readonly" : "ready", children: t(editor.refreshRequired ? "savedRefreshRequired" : state.invalidFields.length > 0 || invalid || rawInvalid ? "validation" : state.dirty ? "dirty" : applied ? "savedApplied" : relationship === "unknown" ? "savedRelationshipUnknown" : "savedNotApplied") })] }), snapshot?.profiles.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("empty") }), snapshot !== null && snapshot.profiles.some(profile => profile.error !== undefined || profile.warnings?.length) && _jsx("ul", { className: "dsmm-profile-list", "aria-label": t("savedInventory"), children: snapshot.profiles.filter(profile => profile.error !== undefined || profile.warnings?.length).map((profile, index) => _jsxs("li", { children: [_jsx("p", { children: profile.label?.trim() ? `${profile.label} (${profile.id})` : profile.id }), _jsx(ProfileWarnings, { warnings: profile.warnings, t: t }), profile.error !== undefined && _jsx(IssueDetails, { issue: profile.error, t: t })] }, `${index}:${profile.id}`)) }), state.pendingEditor !== null && _jsxs("div", { className: "dsmm-confirm", role: "group", "aria-labelledby": `${prefix}-confirm`, onKeyDown: (event) => { if (event.key === "Escape") {
219
219
  event.preventDefault();
220
220
  props.cancelDiscard();
221
- } }, children: [_jsx("p", { id: `${prefix}-confirm`, children: t("discardPrompt") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => { void props.discardAndOpen(); }, children: t("discard") }), _jsx(Button, { ref: cancelRef, type: "button", variant: "primary", onClick: props.cancelDiscard, children: t("cancel") })] })] }), _jsxs("div", { className: "dsmm-effective-summary", "data-dsmm-effective-summary": true, children: [_jsxs("div", { className: "dsmm-summary-row", children: [_jsxs("div", { children: [_jsx("span", { className: "dsmm-summary-label", children: t("futureDefaultSummary") }), " ", _jsx("span", { className: "dsmm-summary-val", "data-dsmm-selection": true, children: selection })] }), _jsx(Button, { type: "button", variant: "primary", size: "sm", disabled: editorDisabled || state.dirty || state.invalidFields.length > 0 || editor?.revision == null || !reconcilable || (applied && !selectionConflict), onClick: () => { void props.apply(); }, children: t(state.busy === "apply" ? "applying" : "apply") })] }), snapshot?.refreshRequired && _jsx("p", { role: "status", children: t("savedRefreshRequired") }), snapshot?.selectedWarnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("futureWarnings") }), _jsx(ProfileWarnings, { warnings: snapshot.selectedWarnings, t: t })] }) : null, snapshot?.selectionError !== undefined && _jsxs("div", { className: "dsmm-issue", children: [_jsx("p", { children: t(selectionConflict ? "selectionConflict" : "retry") }), _jsx(IssueDetails, { issue: snapshot.selectionError, t: t })] }), _jsxs("div", { className: "dsmm-summary-row", children: [_jsxs("div", { children: [_jsx("span", { className: "dsmm-summary-label", children: t("currentSessionSummary") }), " ", _jsx("span", { className: "dsmm-summary-val", children: state.session === null ? t("sessionUnavailable") : sessionProfileLabels(state.session, t).admitted })] }), _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => {
221
+ } }, children: [_jsx("p", { id: `${prefix}-confirm`, children: t("discardPrompt") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => { void props.discardAndOpen(); }, children: t("discard") }), _jsx(Button, { ref: cancelRef, type: "button", variant: "primary", onClick: props.cancelDiscard, children: t("cancel") })] })] }), _jsxs("div", { className: "dsmm-effective-summary", "data-dsmm-effective-summary": true, children: [_jsxs("div", { className: "dsmm-summary-row", children: [_jsxs("div", { children: [_jsx("span", { className: "dsmm-summary-label", children: t("futureDefaultSummary") }), " ", _jsx("span", { className: "dsmm-summary-val", "data-dsmm-selection": true, children: selection })] }), _jsx(Button, { type: "button", variant: "primary", size: "sm", disabled: editorDisabled || state.dirty || state.invalidFields.length > 0 || editor?.revision == null || !reconcilable || (applied && !selectionConflict), onClick: () => { void props.apply(); }, children: t(state.busy === "apply" ? "applying" : "apply") })] }), snapshot?.refreshRequired && _jsx("p", { role: "status", children: t("savedRefreshRequired") }), snapshot?.selectedWarnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("futureWarnings") }), _jsx(ProfileWarnings, { warnings: snapshot.selectedWarnings, t: t })] }) : null, snapshot?.selectionError !== undefined && _jsxs("div", { className: "dsmm-issue", children: [_jsx("p", { children: t(selectionConflict ? "selectionConflict" : "retry") }), _jsx(IssueDetails, { issue: snapshot.selectionError, t: t })] }), _jsxs("div", { className: "dsmm-summary-row", children: [_jsxs("div", { children: [_jsx("span", { className: "dsmm-summary-label", children: t("currentSessionSummary") }), " ", _jsx("span", { className: "dsmm-summary-val", children: state.session === null ? t(state.sessionReadinessPending ? "sessionWaitingReady" : "sessionUnavailable") : sessionProfileLabels(state.session, t).admitted })] }), _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => {
222
222
  if (moreActionsRef.current !== null) {
223
223
  moreActionsRef.current.open = true;
224
224
  moreActionsOpenRef.current = true;
@@ -21,7 +21,7 @@ export declare const roleToolEn: {
21
21
  readonly output: "Complete result content";
22
22
  readonly failure: "Error details";
23
23
  readonly metadata: "Invocation metadata";
24
- readonly inspect: "Inspect tool call";
24
+ readonly inspect: "View call details";
25
25
  readonly copy: "Copy";
26
26
  readonly copied: "Copied";
27
27
  readonly emptyArgs: "Arguments not available yet";
@@ -7,7 +7,7 @@ export const roleToolEn = {
7
7
  background: "Background", error: "Failed", stopped: "Interrupted",
8
8
  technicalDetails: "Technical details",
9
9
  args: "Original arguments", preparingArgs: "Arguments received so far", output: "Complete result content", failure: "Error details", metadata: "Invocation metadata",
10
- inspect: "Inspect tool call", copy: "Copy", copied: "Copied", emptyArgs: "Arguments not available yet",
10
+ inspect: "View call details", copy: "Copy", copied: "Copied", emptyArgs: "Arguments not available yet",
11
11
  unavailable: "Actual identity unavailable; requested identity only", level: "Level", route: "Reported route", routeSource: "Route source",
12
12
  table: "Table", json: "JSON", viewMode: "View mode", property: "Property", value: "Value",
13
13
  };
@@ -19,7 +19,7 @@ export const roleToolZh = {
19
19
  background: "后台调用", error: "失败", stopped: "已中断",
20
20
  technicalDetails: "技术详情",
21
21
  args: "原始参数", preparingArgs: "目前已收到的参数", output: "完整结果内容", failure: "错误详情", metadata: "调用元数据",
22
- inspect: "检查工具调用", copy: "复制", copied: "已复制", emptyArgs: "参数尚不可用",
22
+ inspect: "查看调用详情", copy: "复制", copied: "已复制", emptyArgs: "参数尚不可用",
23
23
  unavailable: "实际身份不可用,仅显示请求身份", level: "等级", route: "报告的路由", routeSource: "路由来源",
24
24
  table: "表格", json: "JSON", viewMode: "视图模式", property: "属性", value: "值",
25
25
  };
@@ -31,7 +31,7 @@ function menuIssue(issue) {
31
31
  export function SessionScopeFeedback({ state, t }) {
32
32
  const session = state.session;
33
33
  const status = state.sessionNotice === null ? "" : t(state.sessionNotice === "mode-on" ? "headerModeOn" : state.sessionNotice === "mode-off" ? "headerModeOff" : state.sessionNotice === "applied-with-model" ? "sessionAppliedWithModel" : state.sessionNotice === "applied" ? "sessionApplied" : "sessionResetDone");
34
- return _jsxs("div", { "data-dsmm-session-feedback": true, children: [session?.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("admissionWarnings") }), _jsx(ProfileWarnings, { warnings: session.warnings, t: t })] }) : null, state.dirty && _jsx("p", { className: "dsmm-hint", children: t("sessionDirty") }), (session?.refreshRequired || session?.selection.refreshRequired) && _jsx("p", { role: "status", children: t("sessionCommittedRefresh") }), state.sessionUnconfirmed && _jsx("p", { role: "status", children: t(state.sessionIssue?.code === "blank-identity-unconfirmed" ? "sessionPreparationUnknown" : "sessionUnconfirmedRefresh") }), state.sessionIssue !== null && _jsxs(_Fragment, { children: [_jsx("p", { role: "alert", children: state.sessionIssue.source === "profile-model" ? t(state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed")
34
+ return _jsxs("div", { "data-dsmm-session-feedback": true, children: [session?.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("admissionWarnings") }), _jsx(ProfileWarnings, { warnings: session.warnings, t: t })] }) : null, state.dirty && _jsx("p", { className: "dsmm-hint", children: t("sessionDirty") }), (session?.refreshRequired || session?.selection.refreshRequired) && _jsx("p", { role: "status", children: t("sessionCommittedRefresh") }), state.sessionUnconfirmed && _jsx("p", { role: "status", children: t(state.sessionIssue?.code === "blank-identity-unconfirmed" ? "sessionPreparationUnknown" : "sessionUnconfirmedRefresh") }), state.sessionReadinessPending && _jsx("p", { role: "status", children: t("sessionWaitingReady") }), state.sessionIssue !== null && !state.sessionReadinessPending && _jsxs(_Fragment, { children: [_jsx("p", { role: "alert", children: state.sessionIssue.source === "profile-model" ? t(state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed")
35
35
  : state.sessionIssue.code === "conflict" ? t("sessionConflict")
36
36
  : ["busy", "maintenance", "disposed", "not-owned"].includes(state.sessionIssue.code) ? t("sessionBusy", { reason: state.sessionIssue.code })
37
37
  : t(state.sessionIssue.code === "validation" ? "validation" : "sessionUnavailable") }), _jsx(IssueDetails, { issue: state.sessionIssue, t: t })] }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.sessionBusy === "read" ? t("reading") : status })] });
@@ -58,7 +58,7 @@ export function SessionScope({ state, actions, t, compact = false, showFeedback
58
58
  void actions.chooseSessionWorkspace(event.currentTarget.value); }, children: [_jsx("option", { value: "", children: t("sessionWorkspacePlaceholder") }), state.sessionWorkspaces.map(workspace => _jsx("option", { value: workspace.id, children: workspace.label }, workspace.id))] })] }), state.sessionWorkspaces.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("sessionNoWorkspaces") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }), _jsxs("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: !state.sessionPreparationAvailable || disabled || state.sessionUnconfirmed, onChange: event => { if (current())
59
59
  actions.chooseSessionProfile(event.currentTarget.value || null); }, children: [_jsx("option", { value: "", children: t("sessionBaseline") }), state.snapshot?.profiles.map(profile => _jsx("option", { value: profile.id, disabled: !isConfigRevision(profile.revision) || profile.error !== undefined, children: profile.label?.trim() || profile.id }, profile.id))] })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: !state.sessionPreparationAvailable || disabled || state.sessionUnconfirmed || state.snapshot === null, onClick: () => { if (current())
60
60
  void actions.applySession(); }, children: t("sessionPrepare") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.sessionBusy !== null || state.busy !== null || state.pendingEditor !== null, onClick: () => { if (current())
61
- void actions.refreshSession(); }, children: t("sessionRefresh") })] })] }) : _jsxs(_Fragment, { children: [labels !== null && _jsx("p", { "data-dsmm-session-state": true, children: labels.admitted }), labels !== null && !compact && _jsx("p", { className: "dsmm-hint", "data-dsmm-session-future-default": true, children: labels.futureDefault }), session === null && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: t("sessionUnavailable") }), session !== null && !allowed && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: capabilityReason(session.applyOverlayUnavailableReason, t) }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }), _jsxs("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onChange: (event) => { if (current())
61
+ void actions.refreshSession(); }, children: t("sessionRefresh") })] })] }) : _jsxs(_Fragment, { children: [labels !== null && _jsx("p", { "data-dsmm-session-state": true, children: labels.admitted }), labels !== null && !compact && _jsx("p", { className: "dsmm-hint", "data-dsmm-session-future-default": true, children: labels.futureDefault }), session === null && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: t(state.sessionReadinessPending ? "sessionWaitingReady" : "sessionUnavailable") }), session !== null && !allowed && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: capabilityReason(session.applyOverlayUnavailableReason, t) }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }), _jsxs("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onChange: (event) => { if (current())
62
62
  actions.chooseSessionProfile(event.currentTarget.value || null); }, children: [_jsx("option", { value: "", children: t("sessionBaseline") }), state.sessionChoice !== null && selected === undefined && _jsx("option", { value: state.sessionChoice, children: state.sessionChoice }), state.snapshot?.profiles.map((profile) => _jsxs("option", { value: profile.id, disabled: !isConfigRevision(profile.revision) || profile.error !== undefined, children: [profile.label?.trim() || profile.id, profileWarnings(profile.warnings).length ? ` — ${t("warningProfile")}` : ""] }, profile.id))] })] }), !compact && _jsxs(_Fragment, { children: [_jsx("p", { className: "dsmm-hint", id: `${prefix}-model-hint`, children: t("useSessionProfileModelDesc") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !modelAllowed, "aria-describedby": `${prefix}-model-hint${!modelAllowed ? ` ${prefix}-model-reason` : ""}`, onClick: () => { if (current())
63
63
  void actions.useSessionProfileModel(); }, children: t("headerUseCurrentModel") }), !modelAllowed && _jsx("p", { className: "dsmm-hint", id: `${prefix}-model-reason`, children: capabilityReason(session?.selectModelUnavailableReason, t) }), session !== null && _jsxs("details", { children: [_jsx("summary", { children: t("technicalDetails") }), _jsxs("div", { className: "dsmm-availability", children: [_jsx("p", { children: binding === undefined ? t("bindingUnknown") : t("bindingState", { binding: binding.binding, ready: t(binding.deliveryFenceReady ? "enabled" : "disabled"), restart: t(binding.restartRequired ? "enabled" : "disabled") }) }), binding?.reason !== undefined && _jsx("p", { children: t("bindingReason", { reason: binding.reason }) })] }), session.roles !== undefined && _jsxs("details", { children: [_jsx("summary", { children: t("admittedRoles") }), session.roles.map(role => _jsxs("div", { className: "dsmm-availability", children: [_jsx("p", { children: role.id }), _jsx(RoleAvailability, { value: role, t: t })] }, role.id))] }), session.rolePolicy !== undefined && _jsx("p", { "data-dsmm-session-policy": true, children: t("roleState", { route: session.rolePolicy.route === undefined ? t("inheritRoute") : `${session.rolePolicy.route.provider}/${session.rolePolicy.route.model}${session.rolePolicy.route.reasoningEffort === undefined ? "" : ` (${session.rolePolicy.route.reasoningEffort})`}`, strategy: session.rolePolicy.strategy, retries: session.rolePolicy.retries, failures: session.rolePolicy.rateLimitFailures, switches: session.rolePolicy.switches, delay: session.rolePolicy.totalDelayMs }) })] })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed || (state.sessionChoice !== null && !isConfigRevision(selected?.revision)), "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onClick: () => { if (current())
64
64
  void actions.applySession(); }, children: t(state.sessionBusy === "apply" ? "sessionApplying" : "sessionApply") }), !compact && _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onClick: () => { if (current())
@@ -92,6 +92,8 @@ export function SessionProfiles(props) {
92
92
  feedback = t(state.sessionIssue?.code === "blank-identity-unconfirmed" ? "sessionPreparationUnknown" : "sessionUnconfirmedRefresh");
93
93
  else if (session?.refreshRequired || session?.selection.refreshRequired)
94
94
  feedback = t("sessionCommittedRefresh");
95
+ else if (state.sessionReadinessPending)
96
+ feedback = t("sessionWaitingReady");
95
97
  else if (state.sessionIssue !== null)
96
98
  feedback = t(state.sessionIssue.source === "profile-model" ? state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed"
97
99
  : state.sessionIssue.code === "conflict" ? "headerConflict" : state.sessionIssue.code === "activation" ? "headerActivationRefused"
@@ -108,7 +110,7 @@ export function SessionProfiles(props) {
108
110
  else if (state.sessionNotice !== null)
109
111
  feedback = t(state.sessionNotice === "mode-on" ? "headerModeOn" : state.sessionNotice === "mode-off" ? "headerModeOff" : state.sessionNotice === "applied-with-model" ? "headerAppliedWithModel" : "headerApplied");
110
112
  const profileName = unknownCaptured ? t("headerCaptured") : admission !== undefined && sourceRelationship(admission, currentSaved?.revision) === "current" && currentSaved?.label?.trim() ? currentSaved.label : admission?.selectedId ?? t("sessionBaseline");
111
- const currentLabel = t("headerCurrentProfile", { profile: session === null ? t("headerUnavailable") : profileName });
113
+ const currentLabel = t("headerCurrentProfile", { profile: session === null ? t(state.sessionReadinessPending ? "sessionWaitingReady" : "headerUnavailable") : profileName });
112
114
  const entries = [{ type: "label", id: "@current", text: currentLabel }];
113
115
  for (const warning of profileWarnings(session?.warnings))
114
116
  entries.push({ type: "label", id: `@warning:${warning.code}`, text: t("warningMarker", { code: warning.code, field: warning.field }) });
@@ -121,7 +123,7 @@ export function SessionProfiles(props) {
121
123
  disabled: unavailable || session?.canToggleMode !== true || mode === undefined || mode.locked });
122
124
  if (session !== null && session.canToggleMode !== true)
123
125
  entries.push({ type: "label", id: "@mode-reason", text: capabilityReason(session.toggleModeUnavailableReason, t) });
124
- const diagnostic = state.sessionIssue === null ? null : menuIssue(state.sessionIssue);
126
+ const diagnostic = state.sessionIssue === null || state.sessionReadinessPending ? null : menuIssue(state.sessionIssue);
125
127
  const diagnosticText = diagnostic === null ? "" : t("headerIssueCode", { code: diagnostic.code }) + (diagnostic.field === undefined ? "" : ` ${t("headerIssueField", { field: diagnostic.field })}`);
126
128
  const retryHint = t(state.sessionUnconfirmed ? "sessionUnconfirmedRefresh" : diagnostic?.code === "maintenance" || diagnostic?.code === "busy" ? "headerWaitRetryHint" : "headerRetryHint");
127
129
  if (diagnostic !== null)
@@ -153,8 +155,7 @@ export function SessionProfiles(props) {
153
155
  if (value === "@refresh") {
154
156
  if (committing || state.busy !== null)
155
157
  return;
156
- void (async () => { await props.refresh(); if (props.readProfileView().currentSessionId === id && props.readProfileView().sessionViewEpoch === state.sessionViewEpoch)
157
- await props.refreshSession(); })();
158
+ void props.refresh();
158
159
  }
159
160
  else {
160
161
  const row = entries.find((entry) => entry.id === value && !("type" in entry));
@@ -178,6 +179,6 @@ export function SessionProfiles(props) {
178
179
  }
179
180
  }
180
181
  setOpenFor(undefined);
181
- } }), _jsxs("span", { className: "dsmm-profile-announcement", id: `${prefix}-feedback`, role: state.sessionIssue === null ? "status" : "alert", "aria-live": "polite", "aria-atomic": "true", children: [feedback || currentLabel, diagnostic === null ? "" : ` ${diagnosticText} ${retryHint}`] })] });
182
+ } }), _jsxs("span", { className: "dsmm-profile-announcement", id: `${prefix}-feedback`, role: state.sessionIssue === null || state.sessionReadinessPending ? "status" : "alert", "aria-live": "polite", "aria-atomic": "true", children: [feedback || currentLabel, diagnostic === null ? "" : ` ${diagnosticText} ${retryHint}`] })] });
182
183
  }
183
184
  //# sourceMappingURL=SessionProfiles.js.map
@@ -263,6 +263,7 @@ export declare const childrenLocaleZh: {
263
263
  activity: string;
264
264
  refresh: string;
265
265
  images: string;
266
+ restart: string;
266
267
  title: string;
267
268
  liveRoute: string;
268
269
  descendants: string;
@@ -319,7 +320,6 @@ export declare const childrenLocaleZh: {
319
320
  interruptAvailability: string;
320
321
  imageAvailability: string;
321
322
  fence: string;
322
- restart: string;
323
323
  authority: string;
324
324
  evidence: string;
325
325
  evidenceMissing: string;
@@ -47,6 +47,7 @@ export interface ProfilesViewSnapshot {
47
47
  currentSessionId: string | null;
48
48
  sessionViewEpoch: number;
49
49
  sessionUnconfirmed: boolean;
50
+ sessionReadinessPending: boolean;
50
51
  session: SessionProfileSnapshot | null;
51
52
  sessionChoice: string | null;
52
53
  sessionWorkspaces: readonly ProfileWorkspace[];
@@ -140,6 +141,13 @@ export declare class ProfilesController {
140
141
  private modeRefreshPending;
141
142
  private sessionSource;
142
143
  private sessionSourceId;
144
+ private sessionBinding;
145
+ private agentAvailable;
146
+ private availabilityEpoch;
147
+ private availabilityReadSucceeded;
148
+ private initialSessionRead;
149
+ private sessionReadIssue;
150
+ private readinessTimer;
143
151
  private stopSessionSource;
144
152
  private stopModelEvents;
145
153
  private modelInteraction;
@@ -170,7 +178,11 @@ export declare class ProfilesController {
170
178
  private syncComposerBlock;
171
179
  attachModelSelector(remote: ProfileModelSelectorRemote | null): void;
172
180
  attachModelSelectionSource(sessionId: string | null, source: HostObservable<unknown> | null): void;
173
- attachSessionSource(sessionId: string | null, source: HostObservable<SessionSnapshot> | null): void;
181
+ attachSessionSource(sessionId: string | null, source: HostObservable<SessionSnapshot> | null, binding?: object | null): void;
182
+ private endReadiness;
183
+ private resetReadiness;
184
+ private sessionSourceFailed;
185
+ observeSessionAvailability(id: string, source: HostObservable<SessionSnapshot>, available: boolean): void;
174
186
  attachModelEventSource(sessionId: string | null, source: SessionEventSource | null): void;
175
187
  attachModelInteractionSource(sessionId: string | null, source: ModelInteractionSource | null): void;
176
188
  attachCatalog(remote: ModelCatalogRemote | null): void;
@@ -28,7 +28,7 @@ export function canReconcileSelection(snapshot) {
28
28
  export class ProfilesController {
29
29
  remote;
30
30
  current = { snapshot: null, editor: null, dirty: false, busy: null, issue: null, notice: null, pendingEditor: null,
31
- catalog: null, catalogBusy: false, catalogUnavailable: true, currentSessionId: null, sessionViewEpoch: 0, sessionUnconfirmed: false, session: null, sessionChoice: null, sessionWorkspaces: [], sessionWorkspaceId: null, sessionPreparationAvailable: false, sessionPreparationPending: false, sessionBusy: null, sessionIssue: null, sessionNotice: null, invalidFields: [], editorEpoch: 0, validationEpoch: 0 };
31
+ catalog: null, catalogBusy: false, catalogUnavailable: true, currentSessionId: null, sessionViewEpoch: 0, sessionUnconfirmed: false, sessionReadinessPending: false, session: null, sessionChoice: null, sessionWorkspaces: [], sessionWorkspaceId: null, sessionPreparationAvailable: false, sessionPreparationPending: false, sessionBusy: null, sessionIssue: null, sessionNotice: null, invalidFields: [], editorEpoch: 0, validationEpoch: 0 };
32
32
  accepted = null;
33
33
  listeners = new Set();
34
34
  generation = 0;
@@ -61,6 +61,13 @@ export class ProfilesController {
61
61
  modeRefreshPending = false;
62
62
  sessionSource = null;
63
63
  sessionSourceId = null;
64
+ sessionBinding = null;
65
+ agentAvailable;
66
+ availabilityEpoch = 0;
67
+ availabilityReadSucceeded = false;
68
+ initialSessionRead = true;
69
+ sessionReadIssue = null;
70
+ readinessTimer = null;
64
71
  stopSessionSource = null;
65
72
  stopModelEvents = null;
66
73
  modelInteraction = null;
@@ -114,7 +121,7 @@ export class ProfilesController {
114
121
  constructor(remote) {
115
122
  this.remote = remote;
116
123
  }
117
- dispose() { this.releasePreparation(); this.stopWorkspaces?.(); this.releaseComposerBlock(); this.numberDrafts.clear(); this.stopConnection?.(); this.stopSessionSource?.(); this.sessionSource = null; this.disposed = true; this.generation += 1; this.sessionGeneration += 1; this.catalogGeneration += 1; this.modelSelectorGeneration += 1; this.modelSelectionGeneration += 1; this.stopModelSelection?.(); this.stopModelEvents?.(); this.stopModelInteraction?.(); this.stopModelSelection = null; this.stopModelEvents = null; this.stopModelInteraction = null; this.modelSelectionSource = null; this.modelEvents = null; this.modelInteraction = null; this.catalogRemote = null; this.modelSelector = null; this.listeners.clear(); }
124
+ dispose() { this.endReadiness(); this.releasePreparation(); this.stopWorkspaces?.(); this.releaseComposerBlock(); this.numberDrafts.clear(); this.stopConnection?.(); this.stopSessionSource?.(); this.sessionSource = null; this.disposed = true; this.generation += 1; this.sessionGeneration += 1; this.catalogGeneration += 1; this.modelSelectorGeneration += 1; this.modelSelectionGeneration += 1; this.stopModelSelection?.(); this.stopModelEvents?.(); this.stopModelInteraction?.(); this.stopModelSelection = null; this.stopModelEvents = null; this.stopModelInteraction = null; this.modelSelectionSource = null; this.modelEvents = null; this.modelInteraction = null; this.catalogRemote = null; this.modelSelector = null; this.listeners.clear(); }
118
125
  bindConnection(source) {
119
126
  if (this.disposed)
120
127
  return;
@@ -124,6 +131,7 @@ export class ProfilesController {
124
131
  this.connectionBound = true;
125
132
  this.connectionBaseline = source?.getSnapshot();
126
133
  const invalidate = () => {
134
+ this.resetReadiness();
127
135
  this.releasePreparation();
128
136
  this.connectionBaseline = source?.getSnapshot();
129
137
  this.generation += 1;
@@ -133,17 +141,15 @@ export class ProfilesController {
133
141
  // A replaced connection only discards what it observed. It never records a
134
142
  // durable refusal for the session: an unread configuration is read again
135
143
  // by the next refresh, and typing stays available in the meantime.
136
- this.publish({ session: null, sessionBusy: null, sessionNotice: null, sessionUnconfirmed: false,
144
+ this.publish({ session: null, sessionBusy: null, sessionIssue: null, sessionNotice: null, sessionUnconfirmed: false,
137
145
  sessionViewEpoch: this.current.sessionViewEpoch + 1, sessionWorkspaceId: null, sessionPreparationPending: false, busy: null, issue: { kind: "transport", code: "unavailable" } });
138
146
  };
139
147
  if (replacement || source === null || this.connectionBaseline === undefined)
140
148
  invalidate();
141
149
  this.stopConnection = source?.subscribe(() => {
142
150
  invalidate();
143
- if (this.connectionCurrent()) {
151
+ if (this.connectionCurrent())
144
152
  void this.refresh();
145
- void this.refreshSession();
146
- }
147
153
  }) ?? null;
148
154
  }
149
155
  connectionCurrent() {
@@ -410,21 +416,27 @@ export class ProfilesController {
410
416
  this.modelSelectionSource = source;
411
417
  this.stopModelSelection = source?.subscribe(() => { this.modelSelectionGeneration += 1; }) ?? null;
412
418
  }
413
- attachSessionSource(sessionId, source) {
414
- if (this.disposed || sessionId === this.sessionSourceId && source === this.sessionSource)
419
+ attachSessionSource(sessionId, source, binding = source) {
420
+ if (this.disposed || sessionId === this.sessionSourceId && source === this.sessionSource && binding === this.sessionBinding)
415
421
  return;
422
+ this.resetReadiness();
416
423
  this.stopSessionSource?.();
417
424
  this.sessionSourceId = sessionId;
418
425
  this.sessionSource = source;
426
+ this.sessionBinding = binding;
419
427
  let running = source?.getSnapshot().running;
420
- const current = () => !this.disposed && sessionId !== null && sessionId === this.current.currentSessionId && source === this.sessionSource;
428
+ const current = () => !this.disposed && sessionId !== null && sessionId === this.current.currentSessionId && source === this.sessionSource && binding === this.sessionBinding;
421
429
  this.stopSessionSource = source?.subscribe(() => {
422
430
  if (!current())
423
431
  return;
432
+ if (this.connectionCurrent() && this.sessionSourceFailed())
433
+ return;
424
434
  const next = source.getSnapshot().running;
425
435
  if (next === running)
426
436
  return;
427
437
  running = next;
438
+ if (!this.connectionCurrent())
439
+ return;
428
440
  // Running is an invalidation signal, never permission to apply an overlay.
429
441
  this.modeRefreshPending = true;
430
442
  this.refreshObservedMode();
@@ -432,11 +444,60 @@ export class ProfilesController {
432
444
  if (current()) {
433
445
  this.sessionGeneration += 1;
434
446
  this.modeRefreshPending = source !== null;
435
- this.publish({ session: null, sessionBusy: null, sessionNotice: null, sessionViewEpoch: this.current.sessionViewEpoch + 1,
447
+ this.publish({ session: null, sessionBusy: null, sessionIssue: null, sessionNotice: null, sessionViewEpoch: this.current.sessionViewEpoch + 1,
436
448
  sessionUnconfirmed: this.pendingSessionSelections.has(sessionId) });
437
449
  this.refreshObservedMode();
438
450
  }
439
451
  }
452
+ endReadiness() {
453
+ if (this.readinessTimer !== null)
454
+ clearTimeout(this.readinessTimer);
455
+ this.readinessTimer = null;
456
+ if (this.current.sessionReadinessPending)
457
+ this.publish({ sessionReadinessPending: false });
458
+ }
459
+ resetReadiness() {
460
+ this.endReadiness();
461
+ this.agentAvailable = undefined;
462
+ this.availabilityEpoch += 1;
463
+ this.availabilityReadSucceeded = false;
464
+ this.initialSessionRead = true;
465
+ this.sessionReadIssue = null;
466
+ }
467
+ sessionSourceFailed() {
468
+ const source = this.sessionSource?.getSnapshot();
469
+ if (source === undefined || !source.removed && source.openError === null)
470
+ return false;
471
+ this.endReadiness();
472
+ this.initialSessionRead = false;
473
+ this.availabilityEpoch += 1;
474
+ this.availabilityReadSucceeded = false;
475
+ this.sessionGeneration += 1;
476
+ this.modeRefreshPending = false;
477
+ const issue = source.removed ? { kind: "domain", code: "disposed", field: "sessionId" }
478
+ : { kind: "transport", code: source.openError.code };
479
+ this.sessionReadIssue = issue;
480
+ const { currentSessionId: id, session, sessionUnconfirmed } = this.current;
481
+ this.publish({ session: null, sessionBusy: null, sessionIssue: issue,
482
+ sessionUnconfirmed: sessionUnconfirmed || id !== null && this.pendingSessionSelections.has(id)
483
+ || session?.refreshRequired === true || session?.selection.refreshRequired === true });
484
+ return true;
485
+ }
486
+ observeSessionAvailability(id, source, available) {
487
+ if (this.disposed || !this.connectionCurrent() || id !== this.current.currentSessionId || id !== this.sessionSourceId || source !== this.sessionSource || this.sessionSourceFailed())
488
+ return;
489
+ const changed = available !== this.agentAvailable;
490
+ this.agentAvailable = available;
491
+ if (!available) {
492
+ this.availabilityEpoch += 1;
493
+ this.availabilityReadSucceeded = false;
494
+ return;
495
+ }
496
+ if (changed || !this.availabilityReadSucceeded) {
497
+ this.modeRefreshPending = true;
498
+ this.refreshObservedMode();
499
+ }
500
+ }
440
501
  attachModelEventSource(sessionId, source) {
441
502
  if (this.disposed || (sessionId === this.modelEventsSessionId && source === this.modelEvents))
442
503
  return;
@@ -493,6 +554,7 @@ export class ProfilesController {
493
554
  setSession(id) {
494
555
  if (this.disposed || id === this.current.currentSessionId)
495
556
  return;
557
+ this.resetReadiness();
496
558
  const task = this.preparation;
497
559
  const preparationUnconfirmed = task?.id === id && this.current.sessionUnconfirmed;
498
560
  if (task?.id === id && task.held !== null && id !== null) {
@@ -547,20 +609,51 @@ export class ProfilesController {
547
609
  }
548
610
  if (this.disposed || !this.connectionCurrent() || id === null || this.current.sessionBusy !== null || this.sessionSourceId === id && this.sessionSource === null)
549
611
  return;
612
+ if (this.sessionSourceFailed())
613
+ return;
614
+ const initial = this.initialSessionRead;
615
+ const availabilityEpoch = this.availabilityEpoch;
616
+ this.initialSessionRead = false;
550
617
  this.modeRefreshPending = false;
551
618
  const generation = ++this.sessionGeneration;
552
619
  const live = () => !this.disposed && this.connectionCurrent() && generation === this.sessionGeneration && id === this.current.currentSessionId;
553
- this.publish({ sessionBusy: "read", ...(preserveFeedback ? {} : { sessionIssue: null, sessionNotice: null }) });
620
+ this.publish({ sessionBusy: "read" });
554
621
  try {
555
622
  const session = await this.unwrap(this.remote.describeSession(id));
556
623
  if (session.sessionId !== id)
557
624
  throw { kind: "assembly", code: "unavailable" };
558
- if (live())
559
- this.publish({ session, sessionChoice: (session.admittedSelection ?? session.selection).selectedId, sessionUnconfirmed: this.pendingSessionSelections.has(id) });
625
+ if (live()) {
626
+ if (availabilityEpoch === this.availabilityEpoch && this.agentAvailable !== false)
627
+ this.availabilityReadSucceeded = true;
628
+ this.endReadiness();
629
+ this.publish({ session, sessionChoice: (session.admittedSelection ?? session.selection).selectedId, sessionUnconfirmed: this.pendingSessionSelections.has(id),
630
+ ...(this.current.sessionIssue === this.sessionReadIssue ? { sessionIssue: null } : {}) });
631
+ this.sessionReadIssue = null;
632
+ }
560
633
  }
561
634
  catch (error) {
562
- if (live())
563
- this.publish({ sessionIssue: this.issue(error) });
635
+ if (live()) {
636
+ const issue = this.issue(error);
637
+ const waiting = (initial || this.current.sessionReadinessPending) && this.sessionSourceId === id && this.sessionSource !== null && this.current.session === null
638
+ && this.sessionSource.getSnapshot().sessionId === id
639
+ && issue.kind === "domain" && issue.code === "unavailable" && issue.field === "sessionId";
640
+ if (!waiting)
641
+ this.endReadiness();
642
+ if (!preserveFeedback || this.current.sessionIssue === null || this.current.sessionIssue === this.sessionReadIssue)
643
+ this.publish({ sessionIssue: issue });
644
+ this.sessionReadIssue = issue;
645
+ if (waiting && this.readinessTimer === null) {
646
+ const source = this.sessionSource, connection = this.connectionBaseline;
647
+ const timer = setTimeout(() => {
648
+ if (this.readinessTimer !== timer || this.disposed || source !== this.sessionSource || id !== this.current.currentSessionId || connection !== this.connectionBaseline)
649
+ return;
650
+ this.readinessTimer = null;
651
+ this.publish({ sessionReadinessPending: false });
652
+ }, 10_000);
653
+ this.readinessTimer = timer;
654
+ this.publish({ sessionReadinessPending: true });
655
+ }
656
+ }
564
657
  }
565
658
  finally {
566
659
  if (live()) {
@@ -774,11 +867,12 @@ export class ProfilesController {
774
867
  }
775
868
  }
776
869
  async refresh() {
777
- await this.perform("refresh", async (live) => {
778
- const snapshot = await this.unwrap(this.remote.describe());
779
- if (live())
780
- this.publish({ snapshot });
781
- });
870
+ const session = this.refreshSession();
871
+ await Promise.all([session, this.perform("refresh", async (live) => {
872
+ const snapshot = await this.unwrap(this.remote.describe());
873
+ if (live())
874
+ this.publish({ snapshot });
875
+ })]);
782
876
  }
783
877
  async open(id) {
784
878
  if (this.disposed || this.current.busy !== null || this.current.pendingEditor !== null)
@@ -44,6 +44,8 @@ export declare const deploymentEn: {
44
44
  unitChars: string;
45
45
  useDefaults: string;
46
46
  restoreInheritance: string;
47
+ gitWriteAllWrites: string;
48
+ gitWriteHighRisk: string;
47
49
  nativeRuntimeState: string;
48
50
  nativeRuntimeBinding: string;
49
51
  nativeRuntimeFence: string;
@@ -1,7 +1,7 @@
1
1
  export const DEPLOYMENT_NS = "plugins.dsmm";
2
2
  export const deploymentEn = {
3
3
  title: "DSMM", summary: "Global config and profile overrides",
4
- description: "Layers save independently; native models and running sessions stay unchanged.",
4
+ description: "Layers save independently; running sessions retain their admitted settings.",
5
5
  global: "DSMM Global config", globalHint: "Shared by this Home. Unset fields use built-in defaults.",
6
6
  profile: "Current DSH profile overrides", profileHint: "This profile only. Unset fields use Global, then Host defaults.",
7
7
  profileUnavailable: "Unavailable",
@@ -22,6 +22,7 @@ export const deploymentEn = {
22
22
  nativeRuntimeReadinessHint: "Task progress is available in the session.",
23
23
  unsetGroup: "Use defaults for this group", unitBytes: "bytes", unitChars: "characters",
24
24
  useDefaults: "Use defaults", restoreInheritance: "Restore inheritance",
25
+ gitWriteAllWrites: "All write operations", gitWriteHighRisk: "High-risk write operations only",
25
26
  nativeRuntimeState: "Observed native runtime", nativeRuntimeBinding: "Observed runtime composition", nativeRuntimeFence: "Execution admission ready", nativeRuntimeRestart: "Restart required", nativeRuntimeStock: "Official Host runtime", nativeRuntimeUnavailable: "Unavailable / unknown",
26
27
  "nativeRuntimeReason-explicit-composition-required": "The Host requires an explicit native runtime composition.", "nativeRuntimeReason-duplicate-provider": "More than one native provider is present; readiness is not confirmed.", "nativeRuntimeReason-authority-not-ready": "Native execution authority is not ready.", "nativeRuntimeReason-disabled": "The saved native runtime is disabled.", "nativeRuntimeReason-pending-restart": "Saved desired state differs from the mounted native composition; restart is pending.", "nativeRuntimeReason-scope-conflict": "Native scope ownership conflicts; readiness is not confirmed.",
27
28
  saveGlobal: "Save", saveProfile: "Save", saving: "Saving…", refresh: "Refresh", discard: "Discard and reload", dirty: "Unsaved changes", saved: "Saved",
@@ -44,7 +45,7 @@ export const deploymentEn = {
44
45
  };
45
46
  export const deploymentZh = {
46
47
  title: "DSMM", summary: "全局配置与当前配置覆盖",
47
- description: "两层独立保存,不改原生模型或运行中会话。",
48
+ description: "两层独立保存,运行中会话保留已准入设置。",
48
49
  global: "DSMM 全局配置", globalHint: "同一 Home 共用;未设置字段使用内建默认值。",
49
50
  profile: "当前 DSH 配置覆盖", profileHint: "仅影响此配置。未设置字段依次使用全局与宿主默认值。",
50
51
  profileUnavailable: "不可用",
@@ -65,6 +66,7 @@ export const deploymentZh = {
65
66
  nativeRuntimeReadinessHint: "任务进度可在会话中查看。",
66
67
  unsetGroup: "整组使用默认配置", unitBytes: "字节", unitChars: "字符",
67
68
  useDefaults: "使用默认值", restoreInheritance: "恢复继承",
69
+ gitWriteAllWrites: "所有写操作", gitWriteHighRisk: "仅高风险写操作",
68
70
  nativeRuntimeState: "已观测原生运行时", nativeRuntimeBinding: "已观测运行时组合", nativeRuntimeFence: "执行准入已就绪", nativeRuntimeRestart: "需要重启", nativeRuntimeStock: "官方 Host 运行时", nativeRuntimeUnavailable: "不可用/未知",
69
71
  "nativeRuntimeReason-explicit-composition-required": "Host 需要显式的原生运行时组合。", "nativeRuntimeReason-duplicate-provider": "存在重复原生 provider,无法确认就绪状态。", "nativeRuntimeReason-authority-not-ready": "原生执行权限尚未就绪。", "nativeRuntimeReason-disabled": "已保存的原生运行时为关闭。", "nativeRuntimeReason-pending-restart": "已保存 desired 与已挂载原生组合不同,等待独立重启。", "nativeRuntimeReason-scope-conflict": "原生 scope 所有权冲突,无法确认就绪状态。",
70
72
  saveGlobal: "保存", saveProfile: "保存", saving: "正在保存…", refresh: "刷新", discard: "丢弃并重载", dirty: "未保存", saved: "已保存",
@@ -87,6 +89,7 @@ export const deploymentZh = {
87
89
  };
88
90
  /** Stable public field names stay visible alongside localized context. */
89
91
  export const deploymentFieldLabels = {
92
+ rootModelPolicy: ["Root model policy (native: user model; configured: admitted routes, all clients)", "根模型策略(native:用户模型;configured:准入路由,所有客户端)"],
90
93
  modelParameters: ["Model parameters", "模型参数"], passthrough: ["Model parameter passthrough", "模型参数透传"], locale: ["Agent business language", "Agent 业务语言"],
91
94
  permissionControl: ["Permission-control module", "权限控制子模块"],
92
95
  modules: ["Modules", "子模块"], skills: ["Skills", "技能"], roles: ["Agent roles", "Agent 角色"],
@@ -97,7 +100,7 @@ export const deploymentFieldLabels = {
97
100
  promptOrder: ["Prompt order", "提示词顺序"], defaultActive: ["Default Deepwork mode", "默认 Deepwork 模式"],
98
101
  enabled: ["Enabled", "启用"], materialize: ["Materialize presets", "物化预设"], scope: ["Guard scope", "保护范围"],
99
102
  shellCommandSafety: ["Shell command safety", "Shell 命令安全"], gitWriteGuard: ["Git write policy", "Git 写入策略"],
100
- gitWriteScope: ["Automatic Git write scope (all-writes / high-risk)", "自动 Git 写入范围(all-writes 全部写入 / high-risk 仅高危)"],
103
+ gitWriteScope: ["Git write protection scope", "Git 写操作保护范围"],
101
104
  toolOutputTruncation: ["Tool output truncation", "工具输出截断"], maxInlineBytes: ["Inline byte limit", "内联字节上限"],
102
105
  planFormatValidation: ["Plan format validation", "计划格式校验"], questionLabelHelper: ["Question labels", "提问标签"], maxLabelChars: ["Label character limit", "标签字符上限"], todoDisciplineHelper: ["Todo discipline", "待办纪律"],
103
106
  enableRunInBackground: ["Allow background runs", "允许后台执行"], backgroundMode: ["Background mode", "后台模式"], maxDepth: ["Maximum depth", "最大深度"],
@@ -6,7 +6,7 @@ export function moduleFor(path) {
6
6
  const key = path.split(".")[0];
7
7
  if (["defaultActive", "modules", "modelParameters", "runtime"].includes(key))
8
8
  return "run";
9
- if (["roleRouting", "runtimePolicy", "runtimeRecovery"].includes(key))
9
+ if (["rootModelPolicy", "roleRouting", "runtimePolicy", "runtimeRecovery"].includes(key))
10
10
  return "routes";
11
11
  if (["workflow", "roles", "skills", "presets", "businessLocale", "locale", "promptOrder", "subagents"].includes(key))
12
12
  return "workflow";