@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/dist/index.js ADDED
@@ -0,0 +1,152 @@
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 { defineTool } from "@deepseek-ai/dsh-tools";
13
+ import { buildStatus, runTokimekiDoctor } from "./doctor.js";
14
+ import { buildAttachPlan, buildHostPlan, buildSharePlan } from "./plans.js";
15
+ import { ACP_COMMANDS, ATTACH_SOURCES, HOST_PATHS, PLAN_OUTPUT_SCHEMA, renderJson, } from "./shared.js";
16
+ export const name = "tokimeki-dsh";
17
+ export const inject = ["tools"];
18
+ const EXIT_CODE_SCHEMA = {
19
+ required: true,
20
+ oneOf: [{ type: "integer" }, { type: "null" }],
21
+ };
22
+ export function apply(ctx) {
23
+ ctx.tools.register(defineTool({
24
+ name: "tokimeki_doctor",
25
+ description: "Run the allow-listed `tokimeki doctor` command and return its redacted report. Read-only; never starts host/attach.",
26
+ parameters: {},
27
+ output: {
28
+ schema: {
29
+ type: "object",
30
+ additionalProperties: false,
31
+ properties: {
32
+ ok: { type: "boolean", required: true },
33
+ exitCode: EXIT_CODE_SCHEMA,
34
+ output: { type: "string", required: true },
35
+ },
36
+ },
37
+ render: renderJson,
38
+ },
39
+ async execute() {
40
+ const result = await runTokimekiDoctor();
41
+ return { ok: result.ok, exitCode: result.exitCode, output: result.output };
42
+ },
43
+ }));
44
+ ctx.tools.register(defineTool({
45
+ name: "tokimeki_status",
46
+ description: "Report local tokimeki configuration presence (never values) plus the redacted doctor result. Cannot observe a separately running host or live connections.",
47
+ parameters: {},
48
+ output: {
49
+ schema: {
50
+ type: "object",
51
+ additionalProperties: false,
52
+ properties: {
53
+ configured: { type: "boolean", required: true },
54
+ authMode: { type: "string", required: true, enum: ["token", "master", "none"] },
55
+ hasSessionToken: { type: "boolean", required: true },
56
+ relay: { type: "string" },
57
+ namespace: { type: "string" },
58
+ session: { type: "string" },
59
+ doctorOk: { type: "boolean", required: true },
60
+ doctorExitCode: EXIT_CODE_SCHEMA,
61
+ doctorOutput: { type: "string", required: true },
62
+ availablePaths: {
63
+ type: "array",
64
+ items: { type: "string" },
65
+ required: true,
66
+ },
67
+ },
68
+ },
69
+ render: renderJson,
70
+ },
71
+ async execute() {
72
+ const doctor = await runTokimekiDoctor();
73
+ return buildStatus({ doctor });
74
+ },
75
+ }));
76
+ ctx.tools.register(defineTool({
77
+ name: "tokimeki_host_plan",
78
+ description: "Return host steps/commands for one of three paths: self-hosted relay, TokiAPI anonymous host, or TokiAPI account. Plan only; never executes or deploys.",
79
+ parameters: {
80
+ path: {
81
+ type: "string",
82
+ required: true,
83
+ enum: [...HOST_PATHS],
84
+ description: "self-hosted | anonymous | account",
85
+ },
86
+ command: {
87
+ type: "string",
88
+ enum: [...ACP_COMMANDS],
89
+ description: "ACP command to host (default claude)",
90
+ },
91
+ configPath: {
92
+ type: "string",
93
+ description: "Path to a downloaded tokimeki-config.json (interpolated into the plan only; never read)",
94
+ },
95
+ },
96
+ output: {
97
+ schema: PLAN_OUTPUT_SCHEMA,
98
+ render: renderJson,
99
+ },
100
+ async execute(args) {
101
+ return {
102
+ ...buildHostPlan({
103
+ path: args.path,
104
+ ...(args.command === undefined ? {} : { command: args.command }),
105
+ ...(args.configPath === undefined ? {} : { configPath: args.configPath }),
106
+ }),
107
+ };
108
+ },
109
+ }));
110
+ ctx.tools.register(defineTool({
111
+ name: "tokimeki_attach_plan",
112
+ description: "Return attach steps/commands for a share URL, explicit environment variables, or a user-prepared TOKIMEKI_CONFIG. Never accepts or echoes actual URL/code/token values and never attaches.",
113
+ parameters: {
114
+ source: {
115
+ type: "string",
116
+ required: true,
117
+ enum: [...ATTACH_SOURCES],
118
+ description: "share-url | env | config",
119
+ },
120
+ listen: {
121
+ type: "boolean",
122
+ description: "Return the read-only --listen variant",
123
+ },
124
+ },
125
+ output: {
126
+ schema: PLAN_OUTPUT_SCHEMA,
127
+ render: renderJson,
128
+ },
129
+ async execute(args) {
130
+ return {
131
+ ...buildAttachPlan({
132
+ source: args.source,
133
+ ...(args.listen === undefined ? {} : { listen: args.listen }),
134
+ }),
135
+ };
136
+ },
137
+ }));
138
+ ctx.tools.register(defineTool({
139
+ name: "tokimeki_share_plan",
140
+ description: "Return host-side sharing steps (F12 menu, session token handling, viewer config copy). Never returns session tokens, invite URLs, or viewer config contents.",
141
+ parameters: {},
142
+ output: {
143
+ schema: PLAN_OUTPUT_SCHEMA,
144
+ render: renderJson,
145
+ },
146
+ async execute() {
147
+ return { ...buildSharePlan() };
148
+ },
149
+ }));
150
+ }
151
+ export default apply;
152
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EACL,YAAY,EACZ,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,IAAI,GAAG,cAAc,CAAC;AACnC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC;AAEhC,MAAM,gBAAgB,GAAG;IACvB,QAAQ,EAAE,IAAa;IACvB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aACH,CAAC;QACJ,CAAC;KACF,CAAC,CACH,CAAC;IAEF,GAAG,CAAC,KAAK,CAAC,QAAQ,CAChB,UAAU,CAAC;QACT,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EACT,8JAA8J;QAChK,UAAU,EAAE,EAAE;QACd,MAAM,EAAE;YACN,MAAM,EAAE,kBAAkB;YAC1B,MAAM,EAAE,UAAU;SACnB;QACD,KAAK,CAAC,OAAO;YACX,OAAO,EAAE,GAAG,cAAc,EAAE,EAAE,CAAC;QACjC,CAAC;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAED,eAAe,KAAK,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Pure plan builders. These functions never execute anything and never accept
3
+ * secrets (share URLs, codes, tokens, or file contents).
4
+ */
5
+ import { type Plan } from "./shared.js";
6
+ export interface HostPlanInput {
7
+ readonly path: string;
8
+ readonly command?: string;
9
+ readonly configPath?: string;
10
+ }
11
+ export declare function buildHostPlan(input: HostPlanInput): Plan;
12
+ export interface AttachPlanInput {
13
+ readonly source: string;
14
+ readonly listen?: boolean;
15
+ }
16
+ export declare function buildAttachPlan(input: AttachPlanInput): Plan;
17
+ export declare function buildSharePlan(): Plan;
18
+ /** Commands the plugin is allowed to mention; exported for tests/docs. */
19
+ export declare const MENTIONED_COMMANDS: readonly ["claude", "pi", "codex", "gemini", "cursor", "aider", "opencode", "goose", "amp"];
20
+ //# sourceMappingURL=plans.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plans.d.ts","sourceRoot":"","sources":["../src/plans.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAOL,KAAK,IAAI,EAMV,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CA6ExD;AAUD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAsD5D;AAED,wBAAgB,cAAc,IAAI,IAAI,CAkBrC;AAED,0EAA0E;AAC1E,eAAO,MAAM,kBAAkB,6FAAe,CAAC"}
package/dist/plans.js ADDED
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Pure plan builders. These functions never execute anything and never accept
3
+ * secrets (share URLs, codes, tokens, or file contents).
4
+ */
5
+ import { ACP_COMMANDS, DEPLOY_BUTTON_URL, hostInvocation, TOKIAPI_URL, validateAttachSource, validateCommand, validateConfigPath, validateHostPath, } from "./shared.js";
6
+ export function buildHostPlan(input) {
7
+ const hostPath = validateHostPath(input.path);
8
+ const command = validateCommand(input.command);
9
+ const configPath = validateConfigPath(input.configPath);
10
+ if (hostPath === "self-hosted") {
11
+ return {
12
+ path: hostPath,
13
+ productionStatus: "self-hosted; the user deploys and owns the relay",
14
+ steps: [
15
+ `Deploy the relay with the Cloudflare Deploy Button: ${DEPLOY_BUTTON_URL}`,
16
+ "Or follow docs/deploy-cloudflare.md in the tokimeki repository.",
17
+ "On the relay, configure TOKIMEKI_NAMESPACE_TOKENS (or the single-owner fallback).",
18
+ "Locally export TOKIMEKI_RELAY_URL, TOKIMEKI_TOKEN (recommended), and TOKIMEKI_NAMESPACE.",
19
+ "Run the host command after the user confirms.",
20
+ ],
21
+ commands: [
22
+ "export TOKIMEKI_RELAY_URL='wss://<your-relay>'",
23
+ "export TOKIMEKI_TOKEN='<user-provided-token>'",
24
+ "export TOKIMEKI_NAMESPACE='<namespace>'",
25
+ hostInvocation(command),
26
+ ],
27
+ warnings: [
28
+ "The plugin only guides deployment: it never runs wrangler or touches Cloudflare credentials.",
29
+ "TOKIMEKI_MASTER_TOKEN is a deprecated compatibility alias; prefer TOKIMEKI_TOKEN.",
30
+ "Do not put real token values in a command line; let the user supply them through their environment.",
31
+ ],
32
+ };
33
+ }
34
+ if (hostPath === "anonymous") {
35
+ return {
36
+ path: hostPath,
37
+ productionStatus: "user-confirmed 2026-11-23 for TokiAPI production functional testing",
38
+ steps: [
39
+ `Open ${TOKIAPI_URL} and request an anonymous host.`,
40
+ "TokiAPI returns a 4-character namespace, a Host JWT, a session, and an invite URL.",
41
+ "Use TOKIMEKI_TOKEN + TOKIMEKI_NAMESPACE from that response; never paste the JWT into chat.",
42
+ "Host JWT and invite default to 24 hours; anonymity has no account, list, or revocation API.",
43
+ "Run the host command after the user confirms.",
44
+ ],
45
+ commands: [
46
+ "export TOKIMEKI_RELAY_URL='wss://relay.tokiapi.app'",
47
+ "export TOKIMEKI_TOKEN='<user-provided-anonymous-host-jwt>'",
48
+ "export TOKIMEKI_NAMESPACE='<provider-generated-namespace>'",
49
+ hostInvocation(command),
50
+ ],
51
+ warnings: [
52
+ "Anonymous hosting is rate-limited (about 10 requests/60s/IP) and can return 429 or 503.",
53
+ "Expiry requires a new anonymous request; the namespace/session may change.",
54
+ "The plugin never calls the anonymous-host endpoint and never handles the JWT.",
55
+ ],
56
+ };
57
+ }
58
+ const configCommand = configPath === undefined
59
+ ? hostInvocation(command)
60
+ : command === "claude" || command === "pi"
61
+ ? `tokimeki --config "${configPath}" ${command}`
62
+ : `tokimeki --config "${configPath}" run -- ${command}`;
63
+ return {
64
+ path: hostPath,
65
+ productionStatus: "TokiAPI account Host JWT (default 30 days)",
66
+ steps: [
67
+ "Sign in at https://tokiapi.app and create a Host JWT plus a 5-character namespace.",
68
+ "Either export TOKIMEKI_TOKEN + TOKIMEKI_NAMESPACE, or download tokimeki-config.json.",
69
+ "For a downloaded config, pass its path with the top-level --config flag (before the command).",
70
+ "Run the host command after the user confirms.",
71
+ ],
72
+ commands: configPath === undefined ? [configPathCommandFallback(command)] : [configCommand],
73
+ warnings: [
74
+ "Downloaded config files contain secrets: chmod 600 on POSIX and delete them when done.",
75
+ "A --config file that changes relayUrl must also contain the host credential; never mix a file relay with an env token.",
76
+ "Host JWTs have no relay-side revocation list; rotate by issuing a new token or changing the signing key.",
77
+ configPath === undefined
78
+ ? "The plugin does not read or parse the config file; pass the path only."
79
+ : "The plugin did not read the config file; the path is only interpolated into this plan.",
80
+ ],
81
+ };
82
+ }
83
+ function configPathCommandFallback(command) {
84
+ // Kept simple: the account path prefers the downloaded --config form, but
85
+ // the plan stays useful when the user has not downloaded one yet.
86
+ return command === "claude" || command === "pi"
87
+ ? `tokimeki --config "<tokimeki-config.json>" ${command}`
88
+ : `tokimeki --config "<tokimeki-config.json>" run -- ${command}`;
89
+ }
90
+ export function buildAttachPlan(input) {
91
+ const source = validateAttachSource(input.source);
92
+ const listen = input.listen === true;
93
+ const command = listen ? "tokimeki attach --listen" : "tokimeki attach";
94
+ if (source === "share-url") {
95
+ return {
96
+ source,
97
+ productionStatus: "TokiAPI share URL; exchange returns a short-lived Session JWT",
98
+ steps: [
99
+ "Ask the user to provide the share URL through TOKIMEKI_ATTACH_URL or the CLI position argument.",
100
+ "The CLI fetches /api/config and exchanges the #t-<code> fragment through /api/tokimeki/attach/cli.",
101
+ "The Session JWT stays in memory and is never written to config/history.",
102
+ "Run the attach command only after the user provides the URL and confirms.",
103
+ ],
104
+ commands: ["export TOKIMEKI_ATTACH_URL='<user-provided-share-url>'", command],
105
+ warnings: [
106
+ "The share URL is a capability secret; do not paste it into chat or command history.",
107
+ "The provider relay URL must be wss:// and bound to the TokiAPI origin; reject other schemes/hosts.",
108
+ "If the invite is a viewer invite, --listen is rejected; listener mode comes from the invite.",
109
+ ],
110
+ };
111
+ }
112
+ if (source === "env") {
113
+ return {
114
+ source,
115
+ productionStatus: "user-provided session and session token",
116
+ steps: [
117
+ "The user supplies TOKIMEKI_SESSION and TOKIMEKI_SESSION_TOKEN in their own environment.",
118
+ "Optionally set TOKIMEKI_RELAY_URL and TOKIMEKI_PASSCODE.",
119
+ "Run the attach command after the user confirms.",
120
+ ],
121
+ commands: [command],
122
+ warnings: [
123
+ "Never print, copy, or ask for the session token value.",
124
+ "Do not place tokens in argv, shell history, logs, or chat.",
125
+ "A listener receives snapshots only and sends no input/resize/ACK.",
126
+ ],
127
+ };
128
+ }
129
+ return {
130
+ source,
131
+ productionStatus: "user-prepared TOKIMEKI_CONFIG viewer JSON",
132
+ steps: [
133
+ "The user places the viewer config JSON in TOKIMEKI_CONFIG in their own environment.",
134
+ "Do not paste the JSON into a command line or tool argument.",
135
+ "Run the attach command after the user confirms.",
136
+ ],
137
+ commands: [command],
138
+ warnings: [
139
+ "Viewer config JSON contains the session token; treat it as a secret.",
140
+ "The plugin never reads config contents and never constructs token-bearing command lines.",
141
+ "A --config file is host-only; attach uses TOKIMEKI_CONFIG or explicit session variables.",
142
+ ],
143
+ };
144
+ }
145
+ export function buildSharePlan() {
146
+ return {
147
+ productionStatus: "host-side sharing only",
148
+ steps: [
149
+ "On the host, press F12 (or the configured TOKIMEKI_INVITE_KEY) to open the connection menu.",
150
+ "Choose 'Show/hide session token' only if the user explicitly wants it on screen.",
151
+ "Choose 'Copy viewer config (OSC 52)' to copy the version 1 viewer config.",
152
+ "Alternatively read the startup banner's viewer config line.",
153
+ "Send the config through a channel the user considers secure.",
154
+ ],
155
+ commands: [],
156
+ warnings: [
157
+ "The viewer config contains the session token; never print it in chat or logs.",
158
+ "OSC 52/clipboard managers may retain the value; do not claim the clipboard was cleared.",
159
+ "An anonymous-host invite URL is shown once in memory and is never saved; share it only with the intended viewer.",
160
+ "The relay can see terminal bytes; viewers can type unless the session is listener-only.",
161
+ ],
162
+ };
163
+ }
164
+ /** Commands the plugin is allowed to mention; exported for tests/docs. */
165
+ export const MENTIONED_COMMANDS = ACP_COMMANDS;
166
+ //# sourceMappingURL=plans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plans.js","sourceRoot":"","sources":["../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/**
2
+ * Local redaction helper (no CLI dependency).
3
+ *
4
+ * Values are used only to remove matching substrings from tool output; they
5
+ * are never returned, logged, or placed in tool arguments.
6
+ */
7
+ export declare function createRedactor(secrets: readonly (string | undefined)[]): (text: string) => string;
8
+ //# sourceMappingURL=redact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GACvC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAU1B"}
package/dist/redact.js ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Local redaction helper (no CLI dependency).
3
+ *
4
+ * Values are used only to remove matching substrings from tool output; they
5
+ * are never returned, logged, or placed in tool arguments.
6
+ */
7
+ export function createRedactor(secrets) {
8
+ const values = [...new Set(secrets.filter((value) => Boolean(value)))]
9
+ .filter((value) => value.length >= 4)
10
+ .sort((left, right) => right.length - left.length);
11
+ if (values.length === 0)
12
+ return (text) => text;
13
+ return (text) => {
14
+ let result = text;
15
+ for (const value of values)
16
+ result = result.split(value).join("[redacted]");
17
+ return result;
18
+ };
19
+ }
20
+ //# sourceMappingURL=redact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,UAAU,cAAc,CAC5B,OAAwC;IAExC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACpF,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;SACpC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IAC/C,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,KAAK,MAAM,KAAK,IAAI,MAAM;YAAE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC5E,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Shared constants and output helpers for the tokimeki-dsh plugin.
3
+ *
4
+ * Every tool is read-only/plan-only: no host/attach execution, no relay
5
+ * deployment, no arbitrary shell, no token/file-content access.
6
+ */
7
+ export declare const DEPLOY_BUTTON_URL = "https://deploy.workers.cloudflare.com/?url=https://github.com/limccn/tokimeki";
8
+ export declare const TOKIAPI_URL = "https://tokiapi.app/tokimeki";
9
+ export declare const TOKIMEKI_CONFIG_PATH_DOC = "tokimeki --config <tokimeki-config.json>";
10
+ /** The nine ACP commands shared with the CLI and TokiAPI. */
11
+ export declare const ACP_COMMANDS: readonly ["claude", "pi", "codex", "gemini", "cursor", "aider", "opencode", "goose", "amp"];
12
+ export type AcpCommand = (typeof ACP_COMMANDS)[number];
13
+ export declare const HOST_PATHS: readonly ["self-hosted", "anonymous", "account"];
14
+ export type HostPath = (typeof HOST_PATHS)[number];
15
+ export declare const ATTACH_SOURCES: readonly ["share-url", "env", "config"];
16
+ export type AttachSource = (typeof ATTACH_SOURCES)[number];
17
+ export interface Plan {
18
+ readonly path?: string;
19
+ readonly source?: string;
20
+ readonly productionStatus: string;
21
+ readonly steps: string[];
22
+ readonly commands: string[];
23
+ readonly warnings: string[];
24
+ }
25
+ export declare function validateHostPath(value: string): HostPath;
26
+ export declare function validateAttachSource(value: string): AttachSource;
27
+ export declare function validateCommand(value: string | undefined): AcpCommand;
28
+ /**
29
+ * Only used to build a display/copy command. The plugin never reads the path.
30
+ * Quotes, `$`, backticks, and newlines are rejected so the path cannot break
31
+ * out of the double-quoted argument.
32
+ */
33
+ export declare function validateConfigPath(value: string | undefined): string | undefined;
34
+ export declare function hostInvocation(command: AcpCommand): string;
35
+ export declare function redacted(text: string, env: NodeJS.ProcessEnv): string;
36
+ /** Strip ANSI escapes and control characters from remote tool output. */
37
+ export declare function sanitizeText(text: string): string;
38
+ export declare function renderJson(_args: unknown, value: unknown): Array<{
39
+ type: "text";
40
+ text: string;
41
+ }>;
42
+ export declare const PLAN_OUTPUT_SCHEMA: {
43
+ type: "object";
44
+ additionalProperties: boolean;
45
+ properties: {
46
+ path: {
47
+ type: "string";
48
+ };
49
+ source: {
50
+ type: "string";
51
+ };
52
+ productionStatus: {
53
+ type: "string";
54
+ required: true;
55
+ };
56
+ steps: {
57
+ type: "array";
58
+ items: {
59
+ type: "string";
60
+ };
61
+ required: true;
62
+ };
63
+ commands: {
64
+ type: "array";
65
+ items: {
66
+ type: "string";
67
+ };
68
+ required: true;
69
+ };
70
+ warnings: {
71
+ type: "array";
72
+ items: {
73
+ type: "string";
74
+ };
75
+ required: true;
76
+ };
77
+ };
78
+ };
79
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,eAAO,MAAM,iBAAiB,kFACmD,CAAC;AAClF,eAAO,MAAM,WAAW,iCAAiC,CAAC;AAC1D,eAAO,MAAM,wBAAwB,6CAA6C,CAAC;AAEnF,6DAA6D;AAC7D,eAAO,MAAM,YAAY,6FAUf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,eAAO,MAAM,UAAU,k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CAAA;CAAE,CAAC,CAEhG;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAW9B,CAAC"}
package/dist/shared.js ADDED
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Shared constants and output helpers for the tokimeki-dsh plugin.
3
+ *
4
+ * Every tool is read-only/plan-only: no host/attach execution, no relay
5
+ * deployment, no arbitrary shell, no token/file-content access.
6
+ */
7
+ import { createRedactor } from "./redact.js";
8
+ export const DEPLOY_BUTTON_URL = "https://deploy.workers.cloudflare.com/?url=https://github.com/limccn/tokimeki";
9
+ export const TOKIAPI_URL = "https://tokiapi.app/tokimeki";
10
+ export const TOKIMEKI_CONFIG_PATH_DOC = "tokimeki --config <tokimeki-config.json>";
11
+ /** The nine ACP commands shared with the CLI and TokiAPI. */
12
+ export const ACP_COMMANDS = [
13
+ "claude",
14
+ "pi",
15
+ "codex",
16
+ "gemini",
17
+ "cursor",
18
+ "aider",
19
+ "opencode",
20
+ "goose",
21
+ "amp",
22
+ ];
23
+ export const HOST_PATHS = ["self-hosted", "anonymous", "account"];
24
+ export const ATTACH_SOURCES = ["share-url", "env", "config"];
25
+ const CONFIG_PATH_PATTERN = /^[A-Za-z0-9._~/:\\ -]+$/;
26
+ export function validateHostPath(value) {
27
+ if (HOST_PATHS.includes(value))
28
+ return value;
29
+ throw new Error(`invalid path: expected one of ${HOST_PATHS.join(", ")}`);
30
+ }
31
+ export function validateAttachSource(value) {
32
+ if (ATTACH_SOURCES.includes(value))
33
+ return value;
34
+ throw new Error(`invalid source: expected one of ${ATTACH_SOURCES.join(", ")}`);
35
+ }
36
+ export function validateCommand(value) {
37
+ const command = value ?? "claude";
38
+ if (ACP_COMMANDS.includes(command))
39
+ return command;
40
+ throw new Error(`invalid command: expected one of ${ACP_COMMANDS.join(", ")}`);
41
+ }
42
+ /**
43
+ * Only used to build a display/copy command. The plugin never reads the path.
44
+ * Quotes, `$`, backticks, and newlines are rejected so the path cannot break
45
+ * out of the double-quoted argument.
46
+ */
47
+ export function validateConfigPath(value) {
48
+ if (value === undefined || value.length === 0)
49
+ return undefined;
50
+ if (value.length > 1024 || !CONFIG_PATH_PATTERN.test(value) || value.endsWith("\\")) {
51
+ throw new Error("invalid configPath: use a plain path without quotes, $, backticks, newlines, or a trailing backslash");
52
+ }
53
+ return value;
54
+ }
55
+ export function hostInvocation(command) {
56
+ return command === "claude" || command === "pi"
57
+ ? `tokimeki ${command}`
58
+ : `tokimeki run -- ${command}`;
59
+ }
60
+ function jsonStringValues(raw, keys) {
61
+ if (raw === undefined || raw.length === 0)
62
+ return [];
63
+ try {
64
+ const parsed = JSON.parse(raw);
65
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
66
+ return [];
67
+ const output = [];
68
+ for (const [key, value] of Object.entries(parsed)) {
69
+ if (keys !== undefined && !keys.includes(key))
70
+ continue;
71
+ if (typeof value === "string" && value.length >= 4)
72
+ output.push(value);
73
+ }
74
+ return output;
75
+ }
76
+ catch {
77
+ return [];
78
+ }
79
+ }
80
+ const CONFIG_ENVELOPE_SECRET_KEYS = [
81
+ "token",
82
+ "masterToken",
83
+ "sessionToken",
84
+ "passcode",
85
+ "tunnelSecret",
86
+ ];
87
+ export function redacted(text, env) {
88
+ return createRedactor([
89
+ env.TOKIMEKI_TOKEN,
90
+ env.TOKIMEKI_MASTER_TOKEN,
91
+ env.TOKIMEKI_SESSION_TOKEN,
92
+ env.TOKIMEKI_TUNNEL_SECRET,
93
+ env.TOKIMEKI_PASSCODE,
94
+ env.TOKIMEKI_ATTACH_URL,
95
+ env.TOKIMEKI_CONFIG,
96
+ env.TOKIMEKI_COTURN_SECRET,
97
+ env.TOKIMEKI_TURN_API_TOKEN,
98
+ env.TOKIMEKI_TURN_CREDENTIAL,
99
+ env.TOKIMEKI_NAMESPACE_TOKENS,
100
+ ...jsonStringValues(env.TOKIMEKI_CONFIG, CONFIG_ENVELOPE_SECRET_KEYS),
101
+ ...jsonStringValues(env.TOKIMEKI_NAMESPACE_TOKENS),
102
+ ])(sanitizeText(text));
103
+ }
104
+ /** Strip ANSI escapes and control characters from remote tool output. */
105
+ export function sanitizeText(text) {
106
+ // eslint-disable-next-line no-control-regex
107
+ const withoutAnsi = text.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "");
108
+ let result = "";
109
+ for (const char of withoutAnsi) {
110
+ const code = char.codePointAt(0) ?? 0;
111
+ if (code === 0x0a || code === 0x09)
112
+ result += char;
113
+ else if (code >= 0x20 && code !== 0x7f)
114
+ result += char;
115
+ }
116
+ return result;
117
+ }
118
+ export function renderJson(_args, value) {
119
+ return [{ type: "text", text: JSON.stringify(value, null, 2) }];
120
+ }
121
+ export const PLAN_OUTPUT_SCHEMA = {
122
+ type: "object",
123
+ additionalProperties: false,
124
+ properties: {
125
+ path: { type: "string" },
126
+ source: { type: "string" },
127
+ productionStatus: { type: "string", required: true },
128
+ steps: { type: "array", items: { type: "string" }, required: true },
129
+ commands: { type: "array", items: { type: "string" }, required: true },
130
+ warnings: { type: "array", items: { type: "string" }, required: true },
131
+ },
132
+ };
133
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,CAAC,MAAM,iBAAiB,GAC5B,+EAA+E,CAAC;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,8BAA8B,CAAC;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,0CAA0C,CAAC;AAEnF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ;IACR,IAAI;IACJ,OAAO;IACP,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,UAAU;IACV,OAAO;IACP,KAAK;CACG,CAAC;AAIX,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,aAAa,EAAE,WAAW,E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