@chance722/dsh-inbox 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +155 -166
- package/README.zh.md +154 -166
- package/cordis.patch.yml +11 -11
- package/lib/cli.js +118 -30
- package/lib/client.js +978 -354
- package/lib/index.js +1 -1
- package/lib/types/cli.d.ts +73 -2
- package/lib/types/client/i18n.d.ts +109 -0
- package/lib/types/client/messages.d.ts +532 -0
- package/lib/types/host/classify/model.d.ts +9 -5
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { defineTool as defineTool2 } from "@deepseek-ai/dsh-tools";
|
|
|
3
3
|
|
|
4
4
|
// src/shared/constants.ts
|
|
5
5
|
var PACKAGE_NAME = "@chance722/dsh-inbox";
|
|
6
|
-
var VERSION = true ? "0.1
|
|
6
|
+
var VERSION = true ? "0.2.1" : "0.0.0-dev";
|
|
7
7
|
var DEFAULT_USER_AGENT = "dsh-inbox";
|
|
8
8
|
|
|
9
9
|
// src/shared/vocabulary.ts
|
package/lib/types/cli.d.ts
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* README that half its readers will skim past — so this does it.
|
|
11
11
|
*
|
|
12
12
|
* What it does, in order, and it is safe to run twice:
|
|
13
|
-
* 0.
|
|
13
|
+
* 0. decide which profile to install into — `--profile` when it was named,
|
|
14
|
+
* otherwise the one this machine already starts (`web`, or the only one);
|
|
15
|
+
* with `--create-profile`, create a missing profile first (off by default:
|
|
14
16
|
* a typo in a profile name should say so, not conjure a profile)
|
|
15
17
|
* 1. `dsh plugin --profile <profile> add <package>` (pnpm is idempotent)
|
|
16
18
|
* 2. copy the shipped `standard` preset into `<DSH_HOME>/.agent-presets/<id>`
|
|
@@ -39,7 +41,8 @@ export interface PresetRowOutcome {
|
|
|
39
41
|
*/
|
|
40
42
|
export declare function ensurePresetRow(body: string): PresetRowOutcome;
|
|
41
43
|
export interface Options {
|
|
42
|
-
profile
|
|
44
|
+
/** Profile named with `--profile`; undefined asks the installer to pick one. */
|
|
45
|
+
profile: string | undefined;
|
|
43
46
|
preset: string;
|
|
44
47
|
source: string;
|
|
45
48
|
defaultPreset: boolean;
|
|
@@ -47,3 +50,71 @@ export interface Options {
|
|
|
47
50
|
createProfile: boolean;
|
|
48
51
|
}
|
|
49
52
|
export declare function parse(argv: readonly string[]): Options | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* The profiles this machine has, in a stable order.
|
|
55
|
+
*
|
|
56
|
+
* A directory counts as a profile when it carries the `package.json` dsh writes
|
|
57
|
+
* there; `profiles/node_modules` is a package store, not a profile. A missing
|
|
58
|
+
* `profiles` directory is the fresh-machine case, not an error.
|
|
59
|
+
*
|
|
60
|
+
* @param home - `<DSH_HOME>`.
|
|
61
|
+
* @returns profile names, sorted.
|
|
62
|
+
*/
|
|
63
|
+
export declare function listProfiles(home: string): string[];
|
|
64
|
+
/** What to do about the profile, and how to describe the choice. */
|
|
65
|
+
export type ProfileChoice = {
|
|
66
|
+
kind: 'use';
|
|
67
|
+
profile: string;
|
|
68
|
+
label: string;
|
|
69
|
+
} | {
|
|
70
|
+
kind: 'refuse';
|
|
71
|
+
message: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Pick the profile to install into when the user did not name one.
|
|
75
|
+
*
|
|
76
|
+
* `dsh web` is `dsh --profile web`, so the profile people already start is the
|
|
77
|
+
* one the plugin belongs in — naming it by hand was a step the README had to
|
|
78
|
+
* teach, and the reason a fresh machine needed a second command at all. Guessing
|
|
79
|
+
* stops at the first ambiguity: several profiles and no `web` means asking, not
|
|
80
|
+
* serving someone the wrong one.
|
|
81
|
+
*
|
|
82
|
+
* @param options - `--profile` (if given) and `--create-profile`.
|
|
83
|
+
* @param existing - what {@link listProfiles} found.
|
|
84
|
+
* @returns the profile to use, or the refusal to print.
|
|
85
|
+
*/
|
|
86
|
+
export declare function chooseProfile(options: Pick<Options, 'profile' | 'createProfile'>, existing: readonly string[]): ProfileChoice;
|
|
87
|
+
/**
|
|
88
|
+
* Whether this module is the program being run.
|
|
89
|
+
*
|
|
90
|
+
* `import.meta.url` carries the **real** path — Node resolves symlinks — while
|
|
91
|
+
* `process.argv[1]` keeps the path the caller typed. Comparing the URLs
|
|
92
|
+
* directly therefore fails for a copy reached through a pnpm
|
|
93
|
+
* `node_modules/@chance722/dsh-inbox/...` junction or any symlink, and the
|
|
94
|
+
* failure is silent: the installer does nothing, prints nothing, exits 0.
|
|
95
|
+
* Resolve both sides first; an unresolvable path is not us.
|
|
96
|
+
*
|
|
97
|
+
* @param moduleUrl - `import.meta.url` of this module.
|
|
98
|
+
* @param entry - `process.argv[1]`, or undefined when node has no script.
|
|
99
|
+
* @returns true when `entry` is this very file.
|
|
100
|
+
*/
|
|
101
|
+
export declare function isEntryPoint(moduleUrl: string, entry: string | undefined): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* The commands that can create a missing profile, in the order to try them.
|
|
104
|
+
*
|
|
105
|
+
* A *shipped* template cannot be the target of `--from-default-profile`: dsh
|
|
106
|
+
* refuses with `profile "web" is shipped and cannot be a custom profile target;
|
|
107
|
+
* omit --from-default-profile to use it`. `init --profile web --create-profile`
|
|
108
|
+
* on a machine that has never run dsh is exactly that case — and since choosing
|
|
109
|
+
* `web` is what this installer now does by default, that would have been the
|
|
110
|
+
* *first* thing a new user hit (measured 2026-09-20, on a fresh `%DSH_HOME%`,
|
|
111
|
+
* before 0.2.0 shipped). The bare form is also the one that initializes a
|
|
112
|
+
* shipped profile at all, so it is the fallback rather than the first choice.
|
|
113
|
+
*
|
|
114
|
+
* Both forms are tried instead of special-casing `web`: `headless` is shipped
|
|
115
|
+
* too, and a future template should not need this file to change.
|
|
116
|
+
*
|
|
117
|
+
* @param profile - the profile to create.
|
|
118
|
+
* @returns argv lists for `dsh`, most specific first.
|
|
119
|
+
*/
|
|
120
|
+
export declare function profileCreationAttempts(profile: string): readonly (readonly string[])[];
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the panel follows dsh's language.
|
|
3
|
+
*
|
|
4
|
+
* dsh ships a locale service (`@deepseek-ai/dsh-client-locale`): the user picks
|
|
5
|
+
* a language under 设置 → 常规, the host persists it, and the page's `<html
|
|
6
|
+
* lang>` follows it. The panel does not invent a switch of its own — it
|
|
7
|
+
* registers its copy as a dictionary in that service and reads back whatever
|
|
8
|
+
* language is active, which is also why a language pack we have never heard of
|
|
9
|
+
* (say `ja` falling back to English) still reads correctly.
|
|
10
|
+
*
|
|
11
|
+
* Two paths, in this order:
|
|
12
|
+
*
|
|
13
|
+
* 1. **The locale service**, when the composition has one. Our namespace is
|
|
14
|
+
* registered for both shipped locales, and the active id is read from the
|
|
15
|
+
* service's own snapshot — so the panel switches the moment the user does.
|
|
16
|
+
* 2. **The document**, when it does not. `<html lang>` is the host's own
|
|
17
|
+
* statement of the active language and `navigator` covers the rest, so a
|
|
18
|
+
* bare composition still reads in the reader's language rather than
|
|
19
|
+
* defaulting to Chinese. This is the same seam `scheme.ts` uses for colour.
|
|
20
|
+
*
|
|
21
|
+
* `t()` reads the active language at call time, and `useLocaleRevision()`
|
|
22
|
+
* re-renders a tree when it changes, so no memoised copy outlives a switch.
|
|
23
|
+
*/
|
|
24
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
25
|
+
import type { Category, CategorySource, Kind } from '../shared/vocabulary.js';
|
|
26
|
+
import { type MessageKey } from './messages.js';
|
|
27
|
+
/** The namespace our copy registers under; nothing else may claim it. */
|
|
28
|
+
export declare const MESSAGES_NS = "dsh-inbox";
|
|
29
|
+
/** Translation parameters, substituted into `{name}` placeholders. */
|
|
30
|
+
export type TranslationParams = Record<string, string | number>;
|
|
31
|
+
/** Subscribe to language changes; `useSyncExternalStore` drives the panel. */
|
|
32
|
+
export declare function subscribeToLocale(listener: () => void): () => void;
|
|
33
|
+
/** A counter that changes whenever the active language does. */
|
|
34
|
+
export declare function localeRevision(): number;
|
|
35
|
+
/**
|
|
36
|
+
* Re-render a tree when the language changes.
|
|
37
|
+
*
|
|
38
|
+
* The panel, the dock and the conversation cards are three separate React trees
|
|
39
|
+
* (three slots), so each one subscribes — a tree that skipped this would keep
|
|
40
|
+
* the language it first rendered in. The returned number is the revision, and is
|
|
41
|
+
* only there so React has something that changes to compare.
|
|
42
|
+
*
|
|
43
|
+
* @returns the current locale revision.
|
|
44
|
+
*/
|
|
45
|
+
export declare function useLocaleRevision(): number;
|
|
46
|
+
/**
|
|
47
|
+
* Narrow a BCP 47 tag to one of the two dictionaries we carry.
|
|
48
|
+
*
|
|
49
|
+
* `zh`, `zh-CN`, `zh-Hant` are Chinese; everything else reads English, which is
|
|
50
|
+
* what dsh itself falls back to. Pure, so the rule is testable without a DOM.
|
|
51
|
+
*
|
|
52
|
+
* @param tag - a language tag, or undefined when nothing named one.
|
|
53
|
+
* @returns which dictionary to read.
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveLanguage(tag: string | undefined): 'zh' | 'en';
|
|
56
|
+
/** Which language the panel is reading right now. */
|
|
57
|
+
export declare function activeLanguage(): 'zh' | 'en';
|
|
58
|
+
/**
|
|
59
|
+
* Translate one key.
|
|
60
|
+
*
|
|
61
|
+
* Falls back from the active dictionary to English to the key itself, so a key
|
|
62
|
+
* that lost its translation reads as a visible key rather than as an empty
|
|
63
|
+
* string.
|
|
64
|
+
*
|
|
65
|
+
* @param key - a key of the shipped dictionary.
|
|
66
|
+
* @param params - values for the `{name}` placeholders.
|
|
67
|
+
* @returns the copy for the active language.
|
|
68
|
+
*/
|
|
69
|
+
export declare function t(key: MessageKey, params?: TranslationParams): string;
|
|
70
|
+
/**
|
|
71
|
+
* The panel's word for a record kind.
|
|
72
|
+
*
|
|
73
|
+
* The host half has its own labels for the same four kinds (`vocabulary.ts`),
|
|
74
|
+
* and they stay Chinese on purpose: they travel into tool results and into the
|
|
75
|
+
* readable copy the vault writes to the cloud, where the reader is the model or
|
|
76
|
+
* another device rather than this browser. The cast is the price of building a
|
|
77
|
+
* key from a value; `test/i18n.test.ts` checks that all four resolve.
|
|
78
|
+
*
|
|
79
|
+
* @param kind - the record's kind.
|
|
80
|
+
* @returns the label in the active language.
|
|
81
|
+
*/
|
|
82
|
+
export declare function kindLabel(kind: Kind): string;
|
|
83
|
+
/** The panel's word for a category; see {@link kindLabel} for the why. */
|
|
84
|
+
export declare function categoryLabel(category: Category): string;
|
|
85
|
+
/** The panel's badge for who judged a category (规则判定 / 模型判定 / 手动判定). */
|
|
86
|
+
export declare function sourceLabel(source: CategorySource): string;
|
|
87
|
+
/** One sentence explaining what that badge implies. */
|
|
88
|
+
export declare function sourceHint(source: CategorySource): string;
|
|
89
|
+
/**
|
|
90
|
+
* Why a link never got a name.
|
|
91
|
+
*
|
|
92
|
+
* The host stores a machine-readable code (`http:403`, `no-title`, …) — never a
|
|
93
|
+
* sentence, and deliberately not in the host's language — so the panel can say
|
|
94
|
+
* it in the reader's.
|
|
95
|
+
*
|
|
96
|
+
* @param code - the stored `linkTitleError`, or undefined when there is none.
|
|
97
|
+
* @returns a sentence, or undefined when there is nothing to explain.
|
|
98
|
+
*/
|
|
99
|
+
export declare function titleMissReason(code: string | undefined): string | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* Hook the panel's copy up to dsh's language.
|
|
102
|
+
*
|
|
103
|
+
* Called once from the browser half's `apply`, before any panel renders.
|
|
104
|
+
*
|
|
105
|
+
* @param ctx - the browser plugin context.
|
|
106
|
+
*/
|
|
107
|
+
export declare function installLocale(ctx: Context): void;
|
|
108
|
+
/** Whether the host's locale service took our dictionaries (for diagnostics). */
|
|
109
|
+
export declare function localeServiceBound(): boolean;
|