@michengai/dsh-automation 0.1.19 → 0.1.21

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.
@@ -1,21 +1,14 @@
1
1
  import { type ComponentType, type ReactNode } from 'react';
2
- import type { Translate } from './contracts.js';
2
+ import type { SessionSelector, Translate, WorkspaceSelector } from './contracts.js';
3
3
  import type { AutomationRuntime } from './runtime.js';
4
- import { type NativeSessionLike, type NativeWorkspaceLike } from './schedule-rail-model.js';
4
+ import { type ScheduleView } from './schedule-overview.js';
5
5
  import type { NativeTabRegistry } from './native-tabs.js';
6
- type SessionSelector = <S>(select: (state: {
7
- ids?: string[];
8
- byId?: Record<string, NativeSessionLike>;
9
- current?: string | null;
10
- }) => S, eq?: (a: S, b: S) => boolean) => S;
11
- type WorkspaceSelector = <S>(select: (state: {
12
- items?: NativeWorkspaceLike[];
13
- archivedSessionIds?: string[];
14
- }) => S, eq?: (a: S, b: S) => boolean) => S;
15
- export declare function ScheduleRail({ t, runtime, openSession, }: {
6
+ export declare function ScheduleRail({ t, runtime, openSession, view: controlledView, showViewSwitch, }: {
16
7
  readonly t: Translate;
17
8
  readonly runtime: AutomationRuntime;
18
9
  readonly openSession?: (sessionId: string) => void;
10
+ readonly view?: ScheduleView;
11
+ readonly showViewSwitch?: boolean;
19
12
  }): JSX.Element;
20
13
  export declare function NativeScheduleShell({ t, runtime, officialTree, hostProps, openSession, useSessions, useWorkspaces, renderSlot, hasChannels, subscribeChannels, tabRegistry, wide, }: {
21
14
  readonly t: Translate;
@@ -31,4 +24,3 @@ export declare function NativeScheduleShell({ t, runtime, officialTree, hostProp
31
24
  readonly tabRegistry?: NativeTabRegistry;
32
25
  readonly wide?: boolean;
33
26
  }): JSX.Element | null;
34
- export {};
@@ -2,8 +2,11 @@ import type { ComponentType, ReactNode } from 'react';
2
2
  import type { AutomationLocaleKey } from './locales.js';
3
3
  import type { AutomationRuntime } from './runtime.js';
4
4
  import type { PermissionTranslate } from './permissions.js';
5
+ import type { SessionListState, WorkspaceListState } from './schedule-rail-model.js';
5
6
  export type Translate = (key: AutomationLocaleKey, params?: Record<string, unknown>) => string;
6
7
  export type ModelTranslate = (key: string, params?: Record<string, unknown>) => string;
8
+ export type SessionSelector = <Selected>(select: (state: SessionListState) => Selected, equals?: (left: Selected, right: Selected) => boolean) => Selected;
9
+ export type WorkspaceSelector = <Selected>(select: (state: WorkspaceListState) => Selected, equals?: (left: Selected, right: Selected) => boolean) => Selected;
7
10
  export interface AutomationViewProps {
8
11
  readonly t: Translate;
9
12
  readonly permissionT: PermissionTranslate;
@@ -63,7 +66,7 @@ export interface NativeSwitcherProps {
63
66
  readonly wide?: boolean;
64
67
  readonly openSession?: (sessionId: string) => void;
65
68
  readonly open?: (sessionId: string) => void;
66
- readonly useSessions?: (select: (state: any) => any) => any;
67
- readonly useWorkspaces?: (select: (state: any) => any) => any;
69
+ readonly useSessions?: SessionSelector;
70
+ readonly useWorkspaces?: WorkspaceSelector;
68
71
  readonly renderSlot?: (name: string, props?: Record<string, unknown>) => ReactNode;
69
72
  }
@@ -0,0 +1,22 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface DropdownMenuOption {
3
+ readonly key: string;
4
+ readonly label: string;
5
+ readonly selected: boolean;
6
+ readonly onSelect: () => void;
7
+ readonly keepOpen?: boolean;
8
+ readonly trailing?: {
9
+ readonly label: string;
10
+ readonly active: boolean;
11
+ readonly onSelect: () => void;
12
+ };
13
+ }
14
+ /** 设置页与侧栏共用的紧凑下拉菜单:显示当前选中项,支持点击外部与 Escape 关闭。 */
15
+ export declare function DropdownMenu({ ariaLabel, className, buttonClassName, menuClassName, options, trigger, }: {
16
+ readonly ariaLabel: string;
17
+ readonly className?: string;
18
+ readonly buttonClassName?: string;
19
+ readonly menuClassName?: string;
20
+ readonly options: readonly DropdownMenuOption[];
21
+ readonly trigger?: ReactNode;
22
+ }): JSX.Element;
@@ -68,6 +68,18 @@ export interface HistoryGroup {
68
68
  }
69
69
  /** 设置页任务列表排序:计划时间 = nextRunAt,无计划的任务固定排最后。 */
70
70
  export declare function sortAutomations(items: readonly AutomationViewModel[], key: AutomationSortKey, direction: AutomationSortDirection): AutomationViewModel[];
71
+ export interface SortPreferenceStorage {
72
+ getItem(key: string): string | null;
73
+ setItem(key: string, value: string): void;
74
+ }
75
+ export declare const SETTINGS_SORT_DEFAULT_KEY = "dsh-automation.sort-default.settings";
76
+ export declare const OVERVIEW_SORT_DEFAULT_KEY = "dsh-automation.sort-default.overview";
77
+ /** 读取已保存的默认排序;缺失、损坏或无存储时返回 undefined,由调用方用自身默认值。 */
78
+ export declare function readSortDefault(storage: SortPreferenceStorage | undefined, storageKey: string): {
79
+ readonly key: AutomationSortKey;
80
+ readonly direction: AutomationSortDirection;
81
+ } | undefined;
82
+ export declare function writeSortDefault(storage: SortPreferenceStorage, storageKey: string, key: AutomationSortKey, direction: AutomationSortDirection): void;
71
83
  export declare function groupHistory(runs: readonly import('./protocol.js').AutomationRunViewModel[], range: HistoryRange, now: Date, t: Translate): HistoryGroup[];
72
84
  export declare function formFromAutomation(item: import('./protocol.js').AutomationViewModel, workspaces?: readonly WorkspaceOption[], defaultModel?: ModelOption | null, defaultPermission?: string): AutomationFormState;
73
85
  export declare function prettyModelName(model: string): string;
@@ -5,6 +5,8 @@ export declare const en: {
5
5
  readonly 'sidebar.tabs': "Workspace views";
6
6
  readonly 'sidebar.tasksTab': "Tasks";
7
7
  readonly 'sidebar.channelsTab': "Channels";
8
+ readonly 'sidebar.views': "Scheduled views";
9
+ readonly 'sidebar.viewOverview': "Task overview";
8
10
  readonly 'sidebar.empty': "No scheduled runs yet.";
9
11
  readonly 'sidebar.tasksEmpty': "No web tasks yet.";
10
12
  readonly 'sidebar.ungrouped': "Ungrouped";
@@ -39,6 +41,16 @@ export declare const en: {
39
41
  readonly 'session.rename': "Rename";
40
42
  readonly 'session.fork': "Fork session";
41
43
  readonly 'session.archive': "Archive session";
44
+ readonly 'session.moreActions': "More actions for {title}";
45
+ readonly 'session.groupActions': "Actions for {name}";
46
+ readonly 'session.taskSettings': "Task settings";
47
+ readonly 'session.archiveGroup': "Archive all conversations";
48
+ readonly 'session.archiveGroupConfirm': "Archive all";
49
+ readonly 'session.archiveGroupDescription': "Archive all {count} conversations for “{name}”. You can restore them later in Settings → Archived.";
50
+ readonly 'session.archiveGroupPending': "Archiving conversations…";
51
+ readonly 'session.archiveGroupFailed': "Some conversations could not be archived: {message}";
52
+ readonly 'session.archiveGroupClose': "Close";
53
+ readonly 'session.archiveGroupCancel': "Cancel";
42
54
  readonly 'session.idle': "Idle";
43
55
  readonly 'session.runningStatus': "Running";
44
56
  readonly 'session.delete': "Remove from Scheduled";
@@ -72,6 +84,7 @@ export declare const en: {
72
84
  readonly 'sort.created.desc': "Created time descending";
73
85
  readonly 'sort.planned.asc': "Planned time ascending";
74
86
  readonly 'sort.planned.desc': "Planned time descending";
87
+ readonly 'sort.default.saved': "Default";
75
88
  readonly 'form.workspace': "Workspace";
76
89
  readonly 'form.workspacePath': "Folder path";
77
90
  readonly 'form.workspacePathPlaceholder': "D:\\work\\project";
@@ -108,6 +121,7 @@ export declare const en: {
108
121
  readonly 'empty.body': "Save a self-contained task, a schedule, and a permission boundary. Every run starts in a new Session.";
109
122
  readonly 'empty.action': "Create the first automation";
110
123
  readonly 'runs.empty': "No runs yet. Run one now, or wait for the next scheduled occurrence.";
124
+ readonly 'overview.empty': "No scheduled tasks yet. Create one in Settings.";
111
125
  readonly 'form.title': "Create automation";
112
126
  readonly 'form.subtitle': "Write a complete, standalone task. Scheduled runs do not inherit this conversation.";
113
127
  readonly 'form.name': "Name";
@@ -190,6 +204,7 @@ export declare const en: {
190
204
  readonly 'error.title': "Automations could not be loaded";
191
205
  readonly 'error.retry': "Try again";
192
206
  readonly 'error.action': "The action failed. Please try again.";
207
+ readonly 'error.taskMissing': "This scheduled task no longer exists.";
193
208
  readonly 'error.offline': "Could not reach the local automation service. Check that DSH is still running and try again.";
194
209
  readonly 'time.now': "now";
195
210
  readonly 'time.minuteAgo': "{count}m ago";
@@ -0,0 +1,7 @@
1
+ export declare const ARCHIVE_MANAGER_PLUGIN = "@michengai/dsh-archive-manager";
2
+ export declare function hasArchiveManagerPlugin(root: {
3
+ querySelector(selector: string): unknown;
4
+ } | undefined): boolean;
5
+ export declare function scheduledGroupShowsActiveFolder(expanded: boolean, sessionIds: readonly string[], selectedId: string | null): boolean;
6
+ /** 串行归档,避免多个 workspace 状态写入相互覆盖。 */
7
+ export declare function archiveScheduledGroup(sessionIds: readonly string[], archiveSession: (sessionId: string) => void | Promise<void>): Promise<void>;
@@ -1,14 +1,16 @@
1
- import type { Translate } from './contracts.js';
1
+ import type { SessionSelector, Translate, WorkspaceSelector } from './contracts.js';
2
2
  import type { AutomationRuntime } from './runtime.js';
3
+ import type { AutomationTaskSettingsRequest } from './task-settings-request.js';
3
4
  export { nativeSessionMenuStyle, nextOpenSessionMenu, nextOpenSessionMenuId, pointerPoint, relativeTime, resolveEventElement, shouldCloseNativeSessionMenu, } from './native-session-menu.js';
4
5
  export declare function NativeScheduleSessionList(props: {
5
6
  readonly t: Translate;
6
7
  readonly runtime: AutomationRuntime;
7
8
  readonly openSession?: (sessionId: string) => void;
8
- readonly useSessions?: (select: (state: any) => any) => any;
9
- readonly useWorkspaces?: (select: (state: any) => any) => any;
9
+ readonly useSessions?: SessionSelector;
10
+ readonly useWorkspaces?: WorkspaceSelector;
10
11
  readonly renameSession?: (sessionId: string, title: string) => void | Promise<void>;
11
12
  readonly archiveSession?: (sessionId: string) => void | Promise<void>;
12
13
  readonly deleteSession?: (sessionId: string) => void | Promise<void>;
13
14
  readonly forkSession?: (sessionId: string) => void | Promise<void>;
15
+ readonly openTaskSettings?: (request: AutomationTaskSettingsRequest) => void;
14
16
  }): JSX.Element;
@@ -0,0 +1,19 @@
1
+ import type { Translate } from './contracts.js';
2
+ import type { AutomationViewModel } from './protocol.js';
3
+ import { type ScheduleRunLike } from './schedule-rail-model.js';
4
+ export type ScheduleView = 'runs' | 'overview';
5
+ export declare function ScheduleViewSwitch({ t, view, onChange, }: {
6
+ readonly t: Translate;
7
+ readonly view: ScheduleView;
8
+ readonly onChange: (view: ScheduleView) => void;
9
+ }): JSX.Element;
10
+ /** 侧栏任务总览:只读列表,有上次会话的任务可点开,其余仅展示。 */
11
+ export declare function ScheduleOverview({ t, automations, runs, openSession, serverNow, archived, presentIds, }: {
12
+ readonly t: Translate;
13
+ readonly automations: readonly AutomationViewModel[];
14
+ readonly runs: readonly ScheduleRunLike[];
15
+ readonly openSession?: (sessionId: string) => void;
16
+ readonly serverNow?: string;
17
+ readonly archived?: ReadonlySet<string>;
18
+ readonly presentIds?: ReadonlySet<string>;
19
+ }): JSX.Element;
@@ -44,6 +44,21 @@ export declare function groupScheduledSessions(automations: readonly {
44
44
  readonly id: string;
45
45
  readonly name: string;
46
46
  }[], runs: readonly ScheduleRunLike[]): ScheduleRailGroup[];
47
+ export interface OverviewAutomationLike {
48
+ readonly id: string;
49
+ readonly name: string;
50
+ readonly status: string;
51
+ readonly nextRunAt?: string;
52
+ }
53
+ export interface TaskOverviewRow {
54
+ readonly id: string;
55
+ readonly name: string;
56
+ readonly status: string;
57
+ readonly nextRunAt?: string;
58
+ readonly lastSessionId?: string;
59
+ }
60
+ /** 任务总览:每个定义一行;最近一次留有会话的运行决定该行是否可点开。 */
61
+ export declare function deriveTaskOverviewRows(automations: readonly OverviewAutomationLike[], runs: readonly ScheduleRunLike[]): TaskOverviewRow[];
47
62
  /** 归档中的、以及宿主已经不认识的 Session,都不应再出现在定时页。 */
48
63
  export declare function keepScheduledSessionLink(sessionId: string | undefined, archived: ReadonlySet<string>, presentIds?: ReadonlySet<string>): boolean;
49
64
  export declare function collectScheduledSessionIds(runs: readonly {
@@ -0,0 +1,10 @@
1
+ type SettingsButton = {
2
+ readonly textContent: string | null;
3
+ readonly getAttribute: (name: string) => string | null;
4
+ click(): void;
5
+ };
6
+ export declare function pickSettingsSectionButton<T extends Pick<SettingsButton, 'textContent'>>(buttons: readonly T[], labels: readonly string[]): T | undefined;
7
+ export declare function pickSettingsLauncher<T extends Pick<SettingsButton, 'textContent' | 'getAttribute'>>(buttons: readonly T[]): T | undefined;
8
+ /** 打开宿主设置弹窗并选择定时任务分区;宿主提供公开 section API 后可集中替换。 */
9
+ export declare function openSettingsSection(labels: readonly string[], onSelected?: () => void, onMissing?: () => void): void;
10
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { Translate } from './contracts.js';
2
+ import { type AutomationSortDirection, type AutomationSortKey, type SortPreferenceStorage } from './helpers.js';
3
+ /** 设置页与侧栏总览共用的排序菜单;当前选中行可一键保存为各自的默认排序。 */
4
+ export declare function SortMenu({ t, storage, storageKey, sortKey, sortDirection, onSelect, compact, iconOnly, className, }: {
5
+ readonly t: Translate;
6
+ readonly storage?: SortPreferenceStorage;
7
+ readonly storageKey: string;
8
+ readonly sortKey: AutomationSortKey;
9
+ readonly sortDirection: AutomationSortDirection;
10
+ readonly onSelect: (key: AutomationSortKey, direction: AutomationSortDirection) => void;
11
+ readonly compact?: boolean;
12
+ readonly iconOnly?: boolean;
13
+ readonly className?: string;
14
+ }): JSX.Element;
@@ -0,0 +1,14 @@
1
+ import type { AutomationRunViewModel, AutomationViewModel } from './protocol.js';
2
+ export declare const AUTOMATION_TASK_SETTINGS_EVENT = "dsh-automation:open-task-settings";
3
+ export declare const AUTOMATION_TASK_SETTINGS_STORAGE_KEY = "dsh-automation:pending-task-settings";
4
+ export type AutomationTaskSettingsRequest = {
5
+ automationId?: string;
6
+ name: string;
7
+ sessionIds: string[];
8
+ };
9
+ export declare function parseAutomationTaskSettingsRequest(value: unknown): AutomationTaskSettingsRequest | undefined;
10
+ export declare function writeAutomationTaskSettingsRequest(storage: Storage | undefined, request: AutomationTaskSettingsRequest): void;
11
+ export declare function requestAutomationTaskSettings(request: AutomationTaskSettingsRequest): void;
12
+ export declare function readAutomationTaskSettingsRequest(storage: Storage | undefined): AutomationTaskSettingsRequest | undefined;
13
+ export declare function clearAutomationTaskSettingsRequest(storage: Storage | undefined): void;
14
+ export declare function resolveAutomationTaskSettings(request: AutomationTaskSettingsRequest, automations: readonly AutomationViewModel[], runs: readonly AutomationRunViewModel[]): AutomationViewModel | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michengai/dsh-automation",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "在独立 DSH Session 中按计划执行编码任务,支持 Web 设置页与 Agent 双入口管理。",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",