dsh-working-activity 0.2.6 → 0.3.0
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 +28 -28
- package/README.i18n.yaml +6 -6
- package/README.md +122 -122
- package/README.zh.md +113 -113
- package/cordis.patch.yml +19 -19
- package/lib/client.js +6 -6
- package/lib/client.js.map +1 -1
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +11 -4
- package/lib/types/lang.d.ts +90 -0
- package/lib/types/lang.d.ts.map +1 -0
- package/lib/types/lang.js +128 -0
- package/lib/types/phrases.d.ts +39 -5
- package/lib/types/phrases.d.ts.map +1 -1
- package/lib/types/phrases.js +115 -11
- package/lib/types/status.d.ts.map +1 -1
- package/lib/types/status.js +26 -16
- package/package.json +119 -117
- package/src/client/WorkingLine.module.css +74 -74
- package/src/client/WorkingLine.tsx +42 -42
- package/src/client/activity.ts +50 -50
- package/src/client/css-modules.d.ts +6 -6
- package/src/client/index.ts +42 -42
- package/src/events.ts +45 -45
- package/src/index.ts +237 -228
- package/src/invariant.ts +69 -69
- package/src/lang.ts +141 -0
- package/src/phrases.ts +306 -180
- package/src/registration.ts +99 -99
- package/src/status.ts +511 -501
package/src/registration.ts
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime registration of the `activity/status` session-event type.
|
|
3
|
-
*
|
|
4
|
-
* dsh-session's read paths (resume seed validation, persistence load)
|
|
5
|
-
* refuse any log containing a type outside KNOWN_SESSION_EVENT_TYPES unless
|
|
6
|
-
* every such event carries the envelope's `ignorable` marker — and
|
|
7
|
-
* `session.append()` exposes no ignorable flag, so this plugin's published
|
|
8
|
-
* snapshots used to make the whole session unresumable (and broke tolerant
|
|
9
|
-
* title reads). Upstream's catalog header defers a registration surface
|
|
10
|
-
* "until such a consumer exists" — this plugin is that consumer, so it
|
|
11
|
-
* registers its own type at load.
|
|
12
|
-
*
|
|
13
|
-
* Why "every reachable copy": a runtime can load dsh-session more than
|
|
14
|
-
* once. The dsh CLI tree and a plugin profile tree resolve different
|
|
15
|
-
* physical copies (e.g. rc.5 vs rc.6 during upgrade windows), and the
|
|
16
|
-
* strict validators consult only THEIR copy's Set. Registering through the
|
|
17
|
-
* plugin's own import alone would leave the validator's copy untouched.
|
|
18
|
-
* Anchors: this module (plugin/profile tree) and the process entry point
|
|
19
|
-
* (the CLI tree the persistence backend resolves from). Each anchor covers
|
|
20
|
-
* its own tree's top-level copy, then walks one edge further — through
|
|
21
|
-
* `@deepseek-ai/dsh-session-persistence`'s own resolution — because the
|
|
22
|
-
* strict validators (persistence load / resume seed checks) consult the
|
|
23
|
-
* copy THEY resolve, a third physical copy under nested or split-tree
|
|
24
|
-
* layouts that neither anchor's top-level resolution can reach. Copies are
|
|
25
|
-
* deduped by realpath; a copy that cannot be resolved from an anchor simply
|
|
26
|
-
* is not there; registration never throws.
|
|
27
|
-
*
|
|
28
|
-
* Self-adjusting per the compat house rules: when upstream's generated
|
|
29
|
-
* catalog adopts `activity/status` (or a real registration API ships), the
|
|
30
|
-
* add() calls are no-ops and this module can be deleted.
|
|
31
|
-
* @module dsh-working-activity/registration
|
|
32
|
-
*/
|
|
33
|
-
import { realpathSync } from 'node:fs'
|
|
34
|
-
import { createRequire } from 'node:module'
|
|
35
|
-
|
|
36
|
-
/** The session-event type this plugin publishes. */
|
|
37
|
-
const ACTIVITY_EVENT_TYPE = 'activity/status'
|
|
38
|
-
|
|
39
|
-
/** The package whose own resolution chain leads to the validators' dsh-session copy. */
|
|
40
|
-
const PERSISTENCE_PACKAGE = '@deepseek-ai/dsh-session-persistence'
|
|
41
|
-
const SESSION_PACKAGE = '@deepseek-ai/dsh-session'
|
|
42
|
-
|
|
43
|
-
interface KnownTypesModule {
|
|
44
|
-
KNOWN_SESSION_EVENT_TYPES?: Set<string>
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Register `activity/status` as a known session-event type in every
|
|
49
|
-
* reachable dsh-session copy. Idempotent; silently skips anchors whose
|
|
50
|
-
* resolution fails.
|
|
51
|
-
*/
|
|
52
|
-
export function registerActivityEventType(): void {
|
|
53
|
-
const anchors = [import.meta.url, process.argv[1]].filter(
|
|
54
|
-
(anchor): anchor is string => typeof anchor === 'string' && anchor.length > 0,
|
|
55
|
-
)
|
|
56
|
-
/** Realpaths already registered — split trees symlink heavily, and require caches by realpath. */
|
|
57
|
-
const registered = new Set<string>()
|
|
58
|
-
for (const anchor of anchors) {
|
|
59
|
-
let req: NodeRequire
|
|
60
|
-
try {
|
|
61
|
-
req = createRequire(anchor)
|
|
62
|
-
} catch {
|
|
63
|
-
continue // Anchor not on disk (e.g. no argv[1] under some runners) — skip.
|
|
64
|
-
}
|
|
65
|
-
registerSessionCopy(req, registered)
|
|
66
|
-
// The validator edge: persistence's load()/resume seed checks consult
|
|
67
|
-
// THEIR OWN resolved dsh-session copy — a third physical copy under
|
|
68
|
-
// nested/split-tree layouts (CLI/profile split, rc.5↔rc.6 upgrade
|
|
69
|
-
// windows, pnpm nesting) that the anchor's top-level resolution misses.
|
|
70
|
-
try {
|
|
71
|
-
const persistenceReq = createRequire(req.resolve(PERSISTENCE_PACKAGE))
|
|
72
|
-
registerSessionCopy(persistenceReq, registered)
|
|
73
|
-
} catch {
|
|
74
|
-
// No persistence package reachable from this anchor — nothing more to cover.
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Register into the dsh-session copy resolved by `req`, once per realpath.
|
|
81
|
-
* @param req - require anchored at the tree (or nested package) to probe.
|
|
82
|
-
* @param registered - realpaths already handled in this registration pass.
|
|
83
|
-
*/
|
|
84
|
-
function registerSessionCopy(req: NodeRequire, registered: Set<string>): void {
|
|
85
|
-
try {
|
|
86
|
-
const resolved = req.resolve(SESSION_PACKAGE)
|
|
87
|
-
let key = resolved
|
|
88
|
-
try {
|
|
89
|
-
key = realpathSync(resolved)
|
|
90
|
-
} catch {
|
|
91
|
-
// Vanished between resolve and realpath — dedupe by the resolved path.
|
|
92
|
-
}
|
|
93
|
-
if (registered.has(key)) return
|
|
94
|
-
registered.add(key)
|
|
95
|
-
;(req(resolved) as KnownTypesModule).KNOWN_SESSION_EVENT_TYPES?.add(ACTIVITY_EVENT_TYPE)
|
|
96
|
-
} catch {
|
|
97
|
-
// No resolvable dsh-session copy from this anchor — nothing to register into.
|
|
98
|
-
}
|
|
99
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Runtime registration of the `activity/status` session-event type.
|
|
3
|
+
*
|
|
4
|
+
* dsh-session's read paths (resume seed validation, persistence load)
|
|
5
|
+
* refuse any log containing a type outside KNOWN_SESSION_EVENT_TYPES unless
|
|
6
|
+
* every such event carries the envelope's `ignorable` marker — and
|
|
7
|
+
* `session.append()` exposes no ignorable flag, so this plugin's published
|
|
8
|
+
* snapshots used to make the whole session unresumable (and broke tolerant
|
|
9
|
+
* title reads). Upstream's catalog header defers a registration surface
|
|
10
|
+
* "until such a consumer exists" — this plugin is that consumer, so it
|
|
11
|
+
* registers its own type at load.
|
|
12
|
+
*
|
|
13
|
+
* Why "every reachable copy": a runtime can load dsh-session more than
|
|
14
|
+
* once. The dsh CLI tree and a plugin profile tree resolve different
|
|
15
|
+
* physical copies (e.g. rc.5 vs rc.6 during upgrade windows), and the
|
|
16
|
+
* strict validators consult only THEIR copy's Set. Registering through the
|
|
17
|
+
* plugin's own import alone would leave the validator's copy untouched.
|
|
18
|
+
* Anchors: this module (plugin/profile tree) and the process entry point
|
|
19
|
+
* (the CLI tree the persistence backend resolves from). Each anchor covers
|
|
20
|
+
* its own tree's top-level copy, then walks one edge further — through
|
|
21
|
+
* `@deepseek-ai/dsh-session-persistence`'s own resolution — because the
|
|
22
|
+
* strict validators (persistence load / resume seed checks) consult the
|
|
23
|
+
* copy THEY resolve, a third physical copy under nested or split-tree
|
|
24
|
+
* layouts that neither anchor's top-level resolution can reach. Copies are
|
|
25
|
+
* deduped by realpath; a copy that cannot be resolved from an anchor simply
|
|
26
|
+
* is not there; registration never throws.
|
|
27
|
+
*
|
|
28
|
+
* Self-adjusting per the compat house rules: when upstream's generated
|
|
29
|
+
* catalog adopts `activity/status` (or a real registration API ships), the
|
|
30
|
+
* add() calls are no-ops and this module can be deleted.
|
|
31
|
+
* @module dsh-working-activity/registration
|
|
32
|
+
*/
|
|
33
|
+
import { realpathSync } from 'node:fs'
|
|
34
|
+
import { createRequire } from 'node:module'
|
|
35
|
+
|
|
36
|
+
/** The session-event type this plugin publishes. */
|
|
37
|
+
const ACTIVITY_EVENT_TYPE = 'activity/status'
|
|
38
|
+
|
|
39
|
+
/** The package whose own resolution chain leads to the validators' dsh-session copy. */
|
|
40
|
+
const PERSISTENCE_PACKAGE = '@deepseek-ai/dsh-session-persistence'
|
|
41
|
+
const SESSION_PACKAGE = '@deepseek-ai/dsh-session'
|
|
42
|
+
|
|
43
|
+
interface KnownTypesModule {
|
|
44
|
+
KNOWN_SESSION_EVENT_TYPES?: Set<string>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Register `activity/status` as a known session-event type in every
|
|
49
|
+
* reachable dsh-session copy. Idempotent; silently skips anchors whose
|
|
50
|
+
* resolution fails.
|
|
51
|
+
*/
|
|
52
|
+
export function registerActivityEventType(): void {
|
|
53
|
+
const anchors = [import.meta.url, process.argv[1]].filter(
|
|
54
|
+
(anchor): anchor is string => typeof anchor === 'string' && anchor.length > 0,
|
|
55
|
+
)
|
|
56
|
+
/** Realpaths already registered — split trees symlink heavily, and require caches by realpath. */
|
|
57
|
+
const registered = new Set<string>()
|
|
58
|
+
for (const anchor of anchors) {
|
|
59
|
+
let req: NodeRequire
|
|
60
|
+
try {
|
|
61
|
+
req = createRequire(anchor)
|
|
62
|
+
} catch {
|
|
63
|
+
continue // Anchor not on disk (e.g. no argv[1] under some runners) — skip.
|
|
64
|
+
}
|
|
65
|
+
registerSessionCopy(req, registered)
|
|
66
|
+
// The validator edge: persistence's load()/resume seed checks consult
|
|
67
|
+
// THEIR OWN resolved dsh-session copy — a third physical copy under
|
|
68
|
+
// nested/split-tree layouts (CLI/profile split, rc.5↔rc.6 upgrade
|
|
69
|
+
// windows, pnpm nesting) that the anchor's top-level resolution misses.
|
|
70
|
+
try {
|
|
71
|
+
const persistenceReq = createRequire(req.resolve(PERSISTENCE_PACKAGE))
|
|
72
|
+
registerSessionCopy(persistenceReq, registered)
|
|
73
|
+
} catch {
|
|
74
|
+
// No persistence package reachable from this anchor — nothing more to cover.
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Register into the dsh-session copy resolved by `req`, once per realpath.
|
|
81
|
+
* @param req - require anchored at the tree (or nested package) to probe.
|
|
82
|
+
* @param registered - realpaths already handled in this registration pass.
|
|
83
|
+
*/
|
|
84
|
+
function registerSessionCopy(req: NodeRequire, registered: Set<string>): void {
|
|
85
|
+
try {
|
|
86
|
+
const resolved = req.resolve(SESSION_PACKAGE)
|
|
87
|
+
let key = resolved
|
|
88
|
+
try {
|
|
89
|
+
key = realpathSync(resolved)
|
|
90
|
+
} catch {
|
|
91
|
+
// Vanished between resolve and realpath — dedupe by the resolved path.
|
|
92
|
+
}
|
|
93
|
+
if (registered.has(key)) return
|
|
94
|
+
registered.add(key)
|
|
95
|
+
;(req(resolved) as KnownTypesModule).KNOWN_SESSION_EVENT_TYPES?.add(ACTIVITY_EVENT_TYPE)
|
|
96
|
+
} catch {
|
|
97
|
+
// No resolvable dsh-session copy from this anchor — nothing to register into.
|
|
98
|
+
}
|
|
99
|
+
}
|