@limccn/tokimeki-dsh 0.0.0-stage → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,27 @@
1
+ # Changelog
2
+
3
+ ## [0.1.1] - 2026-11-26
4
+
5
+ - Widen the `@deepseek-ai/dsh-tools` peer range to
6
+ `^0.0.1-rc.1 || ^0.2.2-rc.5` and typecheck against `0.2.2-rc.5`, so dsh
7
+ 0.2.2-rc.5 accepts the plugin instead of rejecting the old peer requirement.
8
+ - No tool behavior changes; the five read-only/plan-only tools are unchanged.
9
+
10
+ ## [0.1.0] - 2026-11-23
11
+
12
+ - Initial native dsh bundle: `tokimeki_doctor`, `tokimeki_status`,
13
+ `tokimeki_host_plan`, `tokimeki_attach_plan`, `tokimeki_share_plan`.
14
+ - Read-only/plan-only: no host_start, no attach execution, no deployment, no
15
+ arbitrary shell, no token/file-content access, no plugin-owned network calls.
16
+ - Redacted doctor execution (fixed `tokimeki doctor` allow-list), 15s timeout,
17
+ 64 KiB output cap, ANSI/control-character stripping.
18
+ - Host paths aligned with the tokimeki v1.4 skill: self-hosted (one-click
19
+ deploy, guide-only), TokiAPI anonymous (24h/rate-limited/no revocation), and
20
+ TokiAPI account (30d Host JWT or downloaded `--config`).
21
+ - README rewritten with the shared tokimeki icon, npm/CI/license/Node badges,
22
+ and a shorter quick-start-first structure; detailed material moved to docs.
23
+ - New `docs/usage.md` (tool reference, host paths, attach sources, listener,
24
+ passcode, troubleshooting) and three scenario guides: home-NAT mobile via
25
+ the TokiAPI web viewer, US host running Claude Code, and cross-Pacific
26
+ transport/encryption.
27
+ - First public npm release: `0.1.0`.
package/LICENSE ADDED
@@ -0,0 +1,204 @@
1
+
2
+ Copyright 2026 limccn
3
+
4
+ Apache License
5
+ Version 2.0, January 2004
6
+ http://www.apache.org/licenses/
7
+
8
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
9
+
10
+ 1. Definitions.
11
+
12
+ "License" shall mean the terms and conditions for use, reproduction,
13
+ and distribution as defined by Sections 1 through 9 of this document.
14
+
15
+ "Licensor" shall mean the copyright owner or entity authorized by
16
+ the copyright owner that is granting the License.
17
+
18
+ "Legal Entity" shall mean the union of the acting entity and all
19
+ other entities that control, are controlled by, or are under common
20
+ control with that entity. For the purposes of this definition,
21
+ "control" means (i) the power, direct or indirect, to cause the
22
+ direction or management of such entity, whether by contract or
23
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
24
+ outstanding shares, or (iii) beneficial ownership of such entity.
25
+
26
+ "You" (or "Your") shall mean an individual or Legal Entity
27
+ exercising permissions granted by this License.
28
+
29
+ "Source" form shall mean the preferred form for making modifications,
30
+ including but not limited to software source code, documentation
31
+ source, and configuration files.
32
+
33
+ "Object" form shall mean any form resulting from mechanical
34
+ transformation or translation of a Source form, including but
35
+ not limited to compiled object code, generated documentation,
36
+ and conversions to other media types.
37
+
38
+ "Work" shall mean the work of authorship, whether in Source or
39
+ Object form, made available under the License, as indicated by a
40
+ copyright notice that is included in or attached to the work
41
+ (an example is provided in the Appendix below).
42
+
43
+ "Derivative Works" shall mean any work, whether in Source or Object
44
+ form, that is based on (or derived from) the Work and for which the
45
+ editorial revisions, annotations, elaborations, or other modifications
46
+ represent, as a whole, an original work of authorship. For the purposes
47
+ of this License, Derivative Works shall not include works that remain
48
+ separable from, or merely link (or bind by name) to the interfaces of,
49
+ the Work and Derivative Works thereof.
50
+
51
+ "Contribution" shall mean any work of authorship, including
52
+ the original version of the Work and any modifications or additions
53
+ to that Work or Derivative Works thereof, that is intentionally
54
+ submitted to Licensor for inclusion in the Work by the copyright owner
55
+ or by an individual or Legal Entity authorized to submit on behalf of
56
+ the copyright owner. For the purposes of this definition, "submitted"
57
+ means any form of electronic, verbal, or written communication sent
58
+ to the Licensor or its representatives, including but not limited to
59
+ communication on electronic mailing lists, source code control systems,
60
+ and issue tracking systems that are managed by, or on behalf of, the
61
+ Licensor for the purpose of discussing and improving the Work, but
62
+ excluding communication that is conspicuously marked or otherwise
63
+ designated in writing by the copyright owner as "Not a Contribution."
64
+
65
+ "Contributor" shall mean Licensor and any individual or Legal Entity
66
+ on behalf of whom a Contribution has been received by Licensor and
67
+ subsequently incorporated within the Work.
68
+
69
+ 2. Grant of Copyright License. Subject to the terms and conditions of
70
+ this License, each Contributor hereby grants to You a perpetual,
71
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
72
+ copyright license to reproduce, prepare Derivative Works of,
73
+ publicly display, publicly perform, sublicense, and distribute the
74
+ Work and such Derivative Works in Source or Object form.
75
+
76
+ 3. Grant of Patent License. Subject to the terms and conditions of
77
+ this License, each Contributor hereby grants to You a perpetual,
78
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
79
+ (except as stated in this section) patent license to make, have made,
80
+ use, offer to sell, sell, import, and otherwise transfer the Work,
81
+ where such license applies only to those patent claims licensable
82
+ by such Contributor that are necessarily infringed by their
83
+ Contribution(s) alone or by combination of their Contribution(s)
84
+ with the Work to which such Contribution(s) was submitted. If You
85
+ institute patent litigation against any entity (including a
86
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
87
+ or a Contribution incorporated within the Work constitutes direct
88
+ or contributory patent infringement, then any patent licenses
89
+ granted to You under this License for that Work shall terminate
90
+ as of the date such litigation is filed.
91
+
92
+ 4. Redistribution. You may reproduce and distribute copies of the
93
+ Work or Derivative Works thereof in any medium, with or without
94
+ modifications, and in Source or Object form, provided that You
95
+ meet the following conditions:
96
+
97
+ (a) You must give any other recipients of the Work or
98
+ Derivative Works a copy of this License; and
99
+
100
+ (b) You must cause any modified files to carry prominent notices
101
+ stating that You changed the files; and
102
+
103
+ (c) You must retain, in the Source form of any Derivative Works
104
+ that You distribute, all copyright, patent, trademark, and
105
+ attribution notices from the Source form of the Work,
106
+ excluding those notices that do not pertain to any part of
107
+ the Derivative Works; and
108
+
109
+ (d) If the Work includes a "NOTICE" text file as part of its
110
+ distribution, then any Derivative Works that You distribute must
111
+ include a readable copy of the attribution notices contained
112
+ within such NOTICE file, excluding those notices that do not
113
+ pertain to any part of the Derivative Works, in at least one
114
+ of the following places: within a NOTICE text file distributed
115
+ as part of the Derivative Works; within the Source form or
116
+ documentation, if provided along with the Derivative Works; or,
117
+ within a display generated by the Derivative Works, if and
118
+ wherever such third-party notices normally appear. The contents
119
+ of the NOTICE file are for informational purposes only and
120
+ do not modify the License. You may add Your own attribution
121
+ notices within Derivative Works that You distribute, alongside
122
+ or as an addendum to the NOTICE text from the Work, provided
123
+ that such additional attribution notices cannot be construed
124
+ as modifying the License.
125
+
126
+ You may add Your own copyright statement to Your modifications and
127
+ may provide additional or different license terms and conditions
128
+ for use, reproduction, or distribution of Your modifications, or
129
+ for any such Derivative Works as a whole, provided Your use,
130
+ reproduction, and distribution of the Work otherwise complies with
131
+ the conditions stated in this License.
132
+
133
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
134
+ any Contribution intentionally submitted for inclusion in the Work
135
+ by You to the Licensor shall be under the terms and conditions of
136
+ this License, without any additional terms or conditions.
137
+ Notwithstanding the above, nothing herein shall supersede or modify
138
+ the terms of any separate license agreement you may have executed
139
+ with Licensor regarding such Contributions.
140
+
141
+ 6. Trademarks. This License does not grant permission to use the trade
142
+ names, trademarks, service marks, or product names of the Licensor,
143
+ except as required for reasonable and customary use in describing the
144
+ origin of the Work and reproducing the content of the NOTICE file.
145
+
146
+ 7. Disclaimer of Warranty. Unless required by applicable law or
147
+ agreed to in writing, Licensor provides the Work (and each
148
+ Contributor provides its Contributions) on an "AS IS" BASIS,
149
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
150
+ implied, including, without limitation, any warranties or conditions
151
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
152
+ PARTICULAR PURPOSE. You are solely responsible for determining the
153
+ appropriateness of using or redistributing the Work and assume any
154
+ risks associated with Your exercise of permissions under this License.
155
+
156
+ 8. Limitation of Liability. In no event and under no legal theory,
157
+ whether in tort (including negligence), contract, or otherwise,
158
+ unless required by applicable law (such as deliberate and grossly
159
+ negligent acts) or agreed to in writing, shall any Contributor be
160
+ liable to You for damages, including any direct, indirect, special,
161
+ incidental, or consequential damages of any character arising as a
162
+ result of this License or out of the use or inability to use the
163
+ Work (including but not limited to damages for loss of goodwill,
164
+ work stoppage, computer failure or malfunction, or any and all
165
+ other commercial damages or losses), even if such Contributor
166
+ has been advised of the possibility of such damages.
167
+
168
+ 9. Accepting Warranty or Additional Liability. While redistributing
169
+ the Work or Derivative Works thereof, You may choose to offer,
170
+ and charge a fee for, acceptance of support, warranty, indemnity,
171
+ or other liability obligations and/or rights consistent with this
172
+ License. However, in accepting such obligations, You may act only
173
+ on Your own behalf and on Your sole responsibility, not on behalf
174
+ of any other Contributor, and only if You agree to indemnify,
175
+ defend, and hold each Contributor harmless for any liability
176
+ incurred by, or claims asserted against, such Contributor by reason
177
+ of your accepting any such warranty or additional liability.
178
+
179
+ END OF TERMS AND CONDITIONS
180
+
181
+ APPENDIX: How to apply the Apache License to your work.
182
+
183
+ To apply the Apache License to your work, attach the following
184
+ boilerplate notice, with the fields enclosed by brackets "[]"
185
+ replaced with your own identifying information. (Don't include
186
+ the brackets!) The text should be enclosed in the appropriate
187
+ comment syntax for the file format. We also recommend that a
188
+ file or class name and description of purpose be included on the
189
+ same "printed page" as the copyright notice for easier
190
+ identification within third-party archives.
191
+
192
+ Copyright [yyyy] [name of copyright owner]
193
+
194
+ Licensed under the Apache License, Version 2.0 (the "License");
195
+ you may not use this file except in compliance with the License.
196
+ You may obtain a copy of the License at
197
+
198
+ http://www.apache.org/licenses/LICENSE-2.0
199
+
200
+ Unless required by applicable law or agreed to in writing, software
201
+ distributed under the License is distributed on an "AS IS" BASIS,
202
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
203
+ See the License for the specific language governing permissions and
204
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,123 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/limccn/tokimeki-dsh/main/assets/icon.png" width="128" alt="tokimeki">
3
+ </p>
4
+
5
+ <h1 align="center">@limccn/tokimeki-dsh</h1>
6
+
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/@limccn/tokimeki-dsh"><img alt="npm version" src="https://img.shields.io/npm/v/@limccn/tokimeki-dsh.svg"></a>
9
+ <a href="https://www.npmjs.com/package/@limccn/tokimeki-dsh"><img alt="npm downloads" src="https://img.shields.io/npm/dm/@limccn/tokimeki-dsh.svg"></a>
10
+ <a href="https://github.com/limccn/tokimeki-dsh/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/limccn/tokimeki-dsh/actions/workflows/ci.yml/badge.svg"></a>
11
+ <a href="https://github.com/limccn/tokimeki-dsh/blob/main/LICENSE"><img alt="license" src="https://img.shields.io/badge/license-Apache--2.0-blue.svg"></a>
12
+ <img alt="Node" src="https://img.shields.io/badge/node-%3E%3D24.9-brightgreen">
13
+ <img alt="dsh plugin" src="https://img.shields.io/badge/dsh-plugin-5B4BFF">
14
+ </p>
15
+
16
+ <p align="center">
17
+ Read-only, plan-only <a href="https://github.com/limccn/tokimeki">tokimeki</a> tools for DeepSeek Harness (dsh).
18
+ </p>
19
+
20
+ > **Status:** `0.1.1` is the current release (dsh 0.2.2-rc.5 compatible).
21
+ > `0.1.0` was the first public release.
22
+
23
+ `tokimeki-dsh` lets a dsh agent inspect a tokimeki setup, generate host /
24
+ attach / share plans, and run a redacted `tokimeki doctor`. It never starts a
25
+ host or attach, never deploys a relay, never executes arbitrary shell, and
26
+ never reads token file contents. The plugin makes no network calls of its own;
27
+ the only spawned command is the fixed `tokimeki doctor`, which may read
28
+ `~/.tokimeki/config.json` and contact the configured relay with the user's
29
+ credential.
30
+
31
+ ## Why
32
+
33
+ - **Diagnose without leaking.** `tokimeki_doctor` and `tokimeki_status` return
34
+ redacted, size-capped output; token values are never printed.
35
+ - **Plan, then let the human act.** Host / attach / share plans are plain
36
+ steps and commands. The agent never starts a PTY, redeems an invite, or
37
+ deploys anything.
38
+ - **Minimal safety surface.** No `host_start`, no attach execution, no token
39
+ arguments, no file writes, no plugin-owned HTTP/WS requests.
40
+
41
+ ## Quick start
42
+
43
+ ```bash
44
+ dsh plugin --profile <profile> add @limccn/tokimeki-dsh
45
+ tokimeki --version # or: npx @limccn/tokimeki --version
46
+ ```
47
+
48
+ Then ask the agent:
49
+
50
+ - “Check my tokimeki setup and tell me what is missing.”
51
+ - “Plan an anonymous tokimeki host for Claude Code.”
52
+ - “Plan how to attach to a TokiAPI share URL.” (Keep the URL in your own
53
+ environment; do not paste it into chat.)
54
+
55
+ Requirements: dsh with the cordis `tools` service and Node >= 24.9 (verified
56
+ with dsh 0.2.2-rc.5 / `@deepseek-ai/dsh-tools` 0.2.2-rc.5). The tokimeki CLI
57
+ needs Node >= 22.12 and npm >= 11; onboarding paths below need tokimeki
58
+ >= 0.1.5 (0.1.7 is the current release). The plugin ships as a native dsh
59
+ bundle (`package.json.dsh.bundle.patch` + `cordis.patch.yml`).
60
+
61
+ Uninstall: remove the plugin from the dsh profile and
62
+ `npm uninstall @limccn/tokimeki-dsh`. There are no hooks, caches, or state
63
+ files; `~/.tokimeki/` user data is left untouched.
64
+
65
+ **dsh has no official plugin marketplace.** Discovery is via the GitHub topic
66
+ `dsh-plugin` and community lists (`awesome-dsh-plugin`), best-effort.
67
+ `marketplace.json` is a Claude Code format and is not dsh marketplace metadata.
68
+
69
+ ## Tools
70
+
71
+ | Tool | Behavior |
72
+ |---|---|
73
+ | `tokimeki_doctor` | Runs the allow-listed `tokimeki doctor` with no extra args; returns a redacted report |
74
+ | `tokimeki_status` | Reports local configuration presence (no values) plus the redacted doctor result; cannot see a separate host process or live connections |
75
+ | `tokimeki_host_plan({path, command?, configPath?})` | Returns steps/commands for `self-hosted`, `anonymous`, or `account`; never executes |
76
+ | `tokimeki_attach_plan({source, listen?})` | Returns steps/commands for `share-url`, `env`, or `config`; never accepts or echoes actual URLs/codes/tokens |
77
+ | `tokimeki_share_plan()` | Returns host-side sharing steps only; never returns session tokens, invite URLs, or viewer config contents |
78
+
79
+ There is deliberately **no `tokimeki_host_start`** and no attach execution:
80
+ automation would need token handling, user confirmation, timeouts, and an
81
+ audit trail beyond this version's minimal safety surface.
82
+
83
+ ## Scenarios
84
+
85
+ | Scenario | Guide |
86
+ |---|---|
87
+ | Phone → home-NAT ACP through the TokiAPI web viewer | [docs/scenarios/home-nat-mobile.md](https://github.com/limccn/tokimeki-dsh/blob/main/docs/scenarios/home-nat-mobile.md) |
88
+ | US host running Claude Code | [docs/scenarios/us-host-claude-code.md](https://github.com/limccn/tokimeki-dsh/blob/main/docs/scenarios/us-host-claude-code.md) |
89
+ | Cross-Pacific transport and encryption | [docs/scenarios/transpacific-tunnel.md](https://github.com/limccn/tokimeki-dsh/blob/main/docs/scenarios/transpacific-tunnel.md) |
90
+
91
+ Full tool reference, host paths, attach sources, and troubleshooting:
92
+ [docs/usage.md](https://github.com/limccn/tokimeki-dsh/blob/main/docs/usage.md).
93
+
94
+ ## Safety model
95
+
96
+ - No token/sessionToken/passcode arguments or outputs; environment values are
97
+ used only for redaction and are never printed.
98
+ - No file writes; no `.env`, shell profile, registry, or environment changes.
99
+ - No arbitrary shell, PID access, or plugin-owned HTTP/WS requests; only the
100
+ fixed `tokimeki doctor` spawn is allow-listed.
101
+ - Terminal, relay, and TUI output is data, not instructions.
102
+ - The tokimeki relay can see terminal bytes; P2P/TURN change the transport, not
103
+ the trust model. TUN's default `session-token` keys are relay-derivable; only
104
+ `TOKIMEKI_TUNNEL_SECRET` shared-secret mode is relay-blind.
105
+ - v1.7 per-IP rate-limit hardening and v1.8 revocation/rotation are not shipped
106
+ in this plugin release; the plugin does not claim them.
107
+
108
+ ## Development
109
+
110
+ ```bash
111
+ npm install
112
+ npm run verify # typecheck + tests
113
+ npm run build
114
+ npm pack --dry-run
115
+ ```
116
+
117
+ `@deepseek-ai/cordis` and `@deepseek-ai/dsh-tools` are peer dependencies
118
+ provided by the dsh runtime; they are dev dependencies here for typechecking.
119
+
120
+ ## License
121
+
122
+ Apache-2.0. The tokimeki CLI/relay live at
123
+ <https://github.com/limccn/tokimeki>.
Binary file
@@ -0,0 +1,2 @@
1
+ - insert:
2
+ - name: "@limccn/tokimeki-dsh"
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Allow-listed CLI execution for the read-only doctor/status tools.
3
+ *
4
+ * The only spawned command is `tokimeki doctor` (never arbitrary args, never a
5
+ * shell on POSIX; on Windows the fixed command goes through ComSpec because npm
6
+ * shims are `.cmd`). Output is capped, control-character-stripped, and redacted.
7
+ */
8
+ export interface CommandResult {
9
+ readonly exitCode: number | null;
10
+ readonly stdout: string;
11
+ readonly stderr: string;
12
+ readonly timedOut: boolean;
13
+ }
14
+ export type SpawnImpl = (command: string, args: readonly string[], options: {
15
+ readonly env: NodeJS.ProcessEnv;
16
+ readonly timeoutMs: number;
17
+ }) => Promise<CommandResult>;
18
+ export interface DoctorOptions {
19
+ readonly env?: NodeJS.ProcessEnv;
20
+ readonly spawnImpl?: SpawnImpl;
21
+ readonly timeoutMs?: number;
22
+ }
23
+ export interface DoctorResult {
24
+ readonly ok: boolean;
25
+ readonly exitCode: number | null;
26
+ readonly output: string;
27
+ }
28
+ export declare function runTokimekiDoctor(options?: DoctorOptions): Promise<DoctorResult>;
29
+ export interface StatusInput {
30
+ readonly env?: NodeJS.ProcessEnv;
31
+ readonly doctor?: DoctorResult;
32
+ }
33
+ export declare function buildStatus(input?: StatusInput): {
34
+ configured: boolean;
35
+ authMode: "token" | "master" | "none";
36
+ hasSessionToken: boolean;
37
+ relay?: string;
38
+ namespace?: string;
39
+ session?: string;
40
+ doctorOk: boolean;
41
+ doctorExitCode: number | null;
42
+ doctorOutput: string;
43
+ availablePaths: string[];
44
+ };
45
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,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O,CAAC;IACpB,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IACtC,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,CA6BA"}
package/dist/doctor.js ADDED
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Allow-listed CLI execution for the read-only doctor/status tools.
3
+ *
4
+ * The only spawned command is `tokimeki doctor` (never arbitrary args, never a
5
+ * shell on POSIX; on Windows the fixed command goes through ComSpec because npm
6
+ * shims are `.cmd`). Output is capped, control-character-stripped, and redacted.
7
+ */
8
+ import { spawn } from "node:child_process";
9
+ import { redacted, sanitizeText } from "./shared.js";
10
+ const MAX_OUTPUT_BYTES = 64 * 1024;
11
+ const DOCTOR_TIMEOUT_MS = 15_000;
12
+ function defaultSpawn(command, args, options) {
13
+ return new Promise((resolve) => {
14
+ let stdout = "";
15
+ let stderr = "";
16
+ let settled = false;
17
+ let timedOut = false;
18
+ const append = (current, chunk) => {
19
+ const next = current + chunk.toString("utf8");
20
+ return next.length > MAX_OUTPUT_BYTES ? next.slice(0, MAX_OUTPUT_BYTES) : next;
21
+ };
22
+ let child;
23
+ try {
24
+ child = spawn(command, [...args], {
25
+ env: options.env,
26
+ shell: false,
27
+ windowsHide: true,
28
+ stdio: ["ignore", "pipe", "pipe"],
29
+ });
30
+ }
31
+ catch (error) {
32
+ resolve({
33
+ exitCode: null,
34
+ stdout: "",
35
+ stderr: error instanceof Error ? error.message : "spawn failed",
36
+ timedOut: false,
37
+ });
38
+ return;
39
+ }
40
+ let timer = null;
41
+ let killTimer = null;
42
+ const finish = (code) => {
43
+ if (settled)
44
+ return;
45
+ settled = true;
46
+ if (timer !== null)
47
+ clearTimeout(timer);
48
+ if (killTimer !== null)
49
+ clearTimeout(killTimer);
50
+ resolve({ exitCode: code, stdout, stderr, timedOut });
51
+ };
52
+ timer = setTimeout(() => {
53
+ timedOut = true;
54
+ try {
55
+ child.kill();
56
+ }
57
+ catch {
58
+ // best effort
59
+ }
60
+ // A SIGTERM-ignoring child or a Windows cmd.exe wrapper must not leave the
61
+ // tool promise pending forever. Escalate after a bounded grace period.
62
+ killTimer = setTimeout(() => {
63
+ if (process.platform === "win32" && child.pid !== undefined) {
64
+ try {
65
+ spawn("taskkill", ["/pid", String(child.pid), "/T", "/F"], {
66
+ stdio: "ignore",
67
+ windowsHide: true,
68
+ }).on("error", () => {
69
+ // best effort
70
+ });
71
+ }
72
+ catch {
73
+ // best effort
74
+ }
75
+ }
76
+ else {
77
+ try {
78
+ child.kill("SIGKILL");
79
+ }
80
+ catch {
81
+ // best effort
82
+ }
83
+ }
84
+ finish(null);
85
+ }, 2_000);
86
+ killTimer.unref?.();
87
+ }, options.timeoutMs);
88
+ timer.unref?.();
89
+ child.stdout?.on("data", (chunk) => {
90
+ stdout = append(stdout, chunk);
91
+ });
92
+ child.stderr?.on("data", (chunk) => {
93
+ stderr = append(stderr, chunk);
94
+ });
95
+ child.on("error", (error) => {
96
+ stderr = append(stderr, Buffer.from(error.message, "utf8"));
97
+ finish(null);
98
+ });
99
+ child.on("close", (code) => finish(code));
100
+ });
101
+ }
102
+ export async function runTokimekiDoctor(options = {}) {
103
+ const baseEnv = options.env ?? process.env;
104
+ const env = process.platform === "win32"
105
+ ? { ...baseEnv, NoDefaultCurrentDirectoryInExePath: "1" }
106
+ : baseEnv;
107
+ const spawnImpl = options.spawnImpl ?? defaultSpawn;
108
+ const command = process.platform === "win32" ? (env.ComSpec ?? "cmd.exe") : "tokimeki";
109
+ const args = process.platform === "win32"
110
+ ? ["/d", "/s", "/c", "tokimeki", "doctor"]
111
+ : ["doctor"];
112
+ const result = await spawnImpl(command, args, {
113
+ env,
114
+ timeoutMs: options.timeoutMs ?? DOCTOR_TIMEOUT_MS,
115
+ });
116
+ const combined = [result.stdout, result.stderr].filter((part) => part.length > 0).join("\n");
117
+ const suffix = result.timedOut ? "\n[tokimeki doctor timed out]" : "";
118
+ return {
119
+ ok: result.exitCode === 0 && !result.timedOut,
120
+ exitCode: result.exitCode,
121
+ output: redacted(`${combined}${suffix}`.trim(), env),
122
+ };
123
+ }
124
+ const SAFE_RELAY = /^wss?:\/\/[A-Za-z0-9.:[\]_-]+$/;
125
+ const SAFE_NAMESPACE = /^[a-z0-9][a-z0-9_-]{0,31}$/;
126
+ const SAFE_SESSION = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
127
+ function safe(value, pattern) {
128
+ return value !== undefined && pattern.test(value) ? value : undefined;
129
+ }
130
+ export function buildStatus(input = {}) {
131
+ const env = input.env ?? process.env;
132
+ const token = env.TOKIMEKI_TOKEN;
133
+ const master = env.TOKIMEKI_MASTER_TOKEN;
134
+ const authMode = token !== undefined && token.length > 0
135
+ ? "token"
136
+ : master !== undefined && master.length > 0
137
+ ? "master"
138
+ : "none";
139
+ const sessionToken = env.TOKIMEKI_SESSION_TOKEN;
140
+ const hasSessionToken = sessionToken !== undefined && sessionToken.length > 0;
141
+ const session = safe(env.TOKIMEKI_SESSION, SAFE_SESSION);
142
+ const relay = safe(env.TOKIMEKI_RELAY_URL, SAFE_RELAY);
143
+ const namespace = safe(env.TOKIMEKI_NAMESPACE, SAFE_NAMESPACE);
144
+ const hostReady = authMode !== "none";
145
+ const attachReady = session !== undefined && hasSessionToken;
146
+ const doctor = input.doctor;
147
+ return {
148
+ configured: relay !== undefined && (hostReady || attachReady),
149
+ authMode,
150
+ hasSessionToken,
151
+ ...(relay === undefined ? {} : { relay }),
152
+ ...(namespace === undefined ? {} : { namespace }),
153
+ ...(session === undefined ? {} : { session }),
154
+ doctorOk: doctor?.ok === true,
155
+ doctorExitCode: doctor?.exitCode ?? null,
156
+ doctorOutput: sanitizeText(doctor?.output ?? "").slice(0, MAX_OUTPUT_BYTES),
157
+ availablePaths: ["self-hosted", "anonymous", "account"],
158
+ };
159
+ }
160
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,CAAC;AACnC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAejC,SAAS,YAAY,CACnB,OAAe,EACf,IAAuB,EACvB,OAAwE;IAExE,OAAO,IAAI,OAAO,CAAgB,CAAC,OAAO,EAAE,EAAE;QAC5C,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,MAAM,MAAM,GAAG,CAAC,OAAe,EAAE,KAAa,EAAU,EAAE;YACxD,MAAM,IAAI,GAAG,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC9C,OAAO,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACjF,CAAC,CAAC;QACF,IAAI,KAA+B,CAAC;QACpC,IAAI,CAAC;YACH,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE;gBAChC,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,KAAK,EAAE,KAAK;gBACZ,WAAW,EAAE,IAAI;gBACjB,KAAK,EAAE,CAAC,Q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C;IACvD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,QAAQ,KAAK,MAAM,CAAC;IACtC,MAAM,WAAW,GAAG,OAAO,KAAK,SAAS,IAAI,eAAe,CAAC;IAC7D,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,OAAO;QACL,UAAU,EAAE,KAAK,KAAK,SAAS,IAAI,CAAC,SAAS,IAAI,WAAW,CAAC;QAC7D,QAAQ;QACR,eAAe;QACf,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QACzC,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;QACjD,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;QAC7C,QAAQ,EAAE,MAAM,EAAE,EAAE,KAAK,IAAI;QAC7B,cAAc,EAAE,MAAM,EAAE,QAAQ,IAAI,IAAI;QACxC,YAAY,EAAE,YAAY,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC;QAC3E,cAAc,EAAE,CAAC,aAAa,EAAE,WAAW,EAAE,SAAS,CAAC;KACxD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @limccn/tokimeki-dsh — DeepSeek Harness (dsh) native plugin.
3
+ *
4
+ * Registers read-only/plan-only tools:
5
+ * tokimeki_doctor, tokimeki_status, tokimeki_host_plan,
6
+ * tokimeki_attach_plan, tokimeki_share_plan
7
+ *
8
+ * There is deliberately no host_start/attach_start: the plugin never starts a
9
+ * PTY, never deploys a relay, never executes arbitrary shell, never reads token
10
+ * files, and never makes its own network calls.
11
+ */
12
+ import type { Context } from "@deepseek-ai/cordis";
13
+ export declare const name = "tokimeki-dsh";
14
+ export declare const inject: string[];
15
+ export declare function apply(ctx: Context): void;
16
+ export default apply;
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAanD,eAAO,MAAM,IAAI,iBAAiB,CAAC;AACnC,eAAO,MAAM,MAAM,UAAY,CAAC;AAOhC,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAoJxC;AAED,eAAe,KAAK,CAAC"}