@deepseekharness-mobile/companion 0.0.0-stage → 0.1.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.
Files changed (131) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -2
  3. package/cordis.patch.yml +20 -0
  4. package/dist/core/devices.d.ts +35 -0
  5. package/dist/core/devices.d.ts.map +1 -0
  6. package/dist/core/devices.js +90 -0
  7. package/dist/core/devices.js.map +1 -0
  8. package/dist/core/pairing.d.ts +21 -0
  9. package/dist/core/pairing.d.ts.map +1 -0
  10. package/dist/core/pairing.js +74 -0
  11. package/dist/core/pairing.js.map +1 -0
  12. package/dist/dsh/errors.d.ts +3 -0
  13. package/dist/dsh/errors.d.ts.map +1 -0
  14. package/dist/dsh/errors.js +15 -0
  15. package/dist/dsh/errors.js.map +1 -0
  16. package/dist/dsh/lifecycle.d.ts +37 -0
  17. package/dist/dsh/lifecycle.d.ts.map +1 -0
  18. package/dist/dsh/lifecycle.js +95 -0
  19. package/dist/dsh/lifecycle.js.map +1 -0
  20. package/dist/dsh/models.d.ts +39 -0
  21. package/dist/dsh/models.d.ts.map +1 -0
  22. package/dist/dsh/models.js +171 -0
  23. package/dist/dsh/models.js.map +1 -0
  24. package/dist/dsh/prompt.d.ts +8 -0
  25. package/dist/dsh/prompt.d.ts.map +1 -0
  26. package/dist/dsh/prompt.js +25 -0
  27. package/dist/dsh/prompt.js.map +1 -0
  28. package/dist/dsh/providers.d.ts +25 -0
  29. package/dist/dsh/providers.d.ts.map +1 -0
  30. package/dist/dsh/providers.js +315 -0
  31. package/dist/dsh/providers.js.map +1 -0
  32. package/dist/dsh/question-bridge.d.ts +25 -0
  33. package/dist/dsh/question-bridge.d.ts.map +1 -0
  34. package/dist/dsh/question-bridge.js +140 -0
  35. package/dist/dsh/question-bridge.js.map +1 -0
  36. package/dist/dsh/questions.d.ts +15 -0
  37. package/dist/dsh/questions.d.ts.map +1 -0
  38. package/dist/dsh/questions.js +126 -0
  39. package/dist/dsh/questions.js.map +1 -0
  40. package/dist/dsh/session-activity.d.ts +5 -0
  41. package/dist/dsh/session-activity.d.ts.map +1 -0
  42. package/dist/dsh/session-activity.js +100 -0
  43. package/dist/dsh/session-activity.js.map +1 -0
  44. package/dist/dsh/session-source.d.ts +19 -0
  45. package/dist/dsh/session-source.d.ts.map +1 -0
  46. package/dist/dsh/session-source.js +104 -0
  47. package/dist/dsh/session-source.js.map +1 -0
  48. package/dist/dsh/sessions.d.ts +10 -0
  49. package/dist/dsh/sessions.d.ts.map +1 -0
  50. package/dist/dsh/sessions.js +51 -0
  51. package/dist/dsh/sessions.js.map +1 -0
  52. package/dist/dsh/slash-commands.d.ts +15 -0
  53. package/dist/dsh/slash-commands.d.ts.map +1 -0
  54. package/dist/dsh/slash-commands.js +60 -0
  55. package/dist/dsh/slash-commands.js.map +1 -0
  56. package/dist/dsh/transcript.d.ts +28 -0
  57. package/dist/dsh/transcript.d.ts.map +1 -0
  58. package/dist/dsh/transcript.js +211 -0
  59. package/dist/dsh/transcript.js.map +1 -0
  60. package/dist/dsh/workspaces.d.ts +20 -0
  61. package/dist/dsh/workspaces.d.ts.map +1 -0
  62. package/dist/dsh/workspaces.js +123 -0
  63. package/dist/dsh/workspaces.js.map +1 -0
  64. package/dist/host-api.d.ts +148 -0
  65. package/dist/host-api.d.ts.map +1 -0
  66. package/dist/host-api.js +54 -0
  67. package/dist/host-api.js.map +1 -0
  68. package/dist/index.d.ts +5 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.js +268 -0
  71. package/dist/index.js.map +1 -0
  72. package/dist/log.d.ts +5 -0
  73. package/dist/log.d.ts.map +1 -0
  74. package/dist/log.js +40 -0
  75. package/dist/log.js.map +1 -0
  76. package/dist/open-browser.d.ts +3 -0
  77. package/dist/open-browser.d.ts.map +1 -0
  78. package/dist/open-browser.js +46 -0
  79. package/dist/open-browser.js.map +1 -0
  80. package/dist/pairing-message.d.ts +16 -0
  81. package/dist/pairing-message.d.ts.map +1 -0
  82. package/dist/pairing-message.js +38 -0
  83. package/dist/pairing-message.js.map +1 -0
  84. package/dist/persist/devices-file.d.ts +8 -0
  85. package/dist/persist/devices-file.d.ts.map +1 -0
  86. package/dist/persist/devices-file.js +47 -0
  87. package/dist/persist/devices-file.js.map +1 -0
  88. package/dist/probe.d.ts +25 -0
  89. package/dist/probe.d.ts.map +1 -0
  90. package/dist/probe.js +143 -0
  91. package/dist/probe.js.map +1 -0
  92. package/dist/public-origin.d.ts +11 -0
  93. package/dist/public-origin.d.ts.map +1 -0
  94. package/dist/public-origin.js +79 -0
  95. package/dist/public-origin.js.map +1 -0
  96. package/dist/qr-text.d.ts +2 -0
  97. package/dist/qr-text.d.ts.map +1 -0
  98. package/dist/qr-text.js +31 -0
  99. package/dist/qr-text.js.map +1 -0
  100. package/dist/routes/origin.d.ts +17 -0
  101. package/dist/routes/origin.d.ts.map +1 -0
  102. package/dist/routes/origin.js +85 -0
  103. package/dist/routes/origin.js.map +1 -0
  104. package/dist/routes/static.d.ts +9 -0
  105. package/dist/routes/static.d.ts.map +1 -0
  106. package/dist/routes/static.js +129 -0
  107. package/dist/routes/static.js.map +1 -0
  108. package/dist/routes/web-root.d.ts +2 -0
  109. package/dist/routes/web-root.d.ts.map +1 -0
  110. package/dist/routes/web-root.js +21 -0
  111. package/dist/routes/web-root.js.map +1 -0
  112. package/dist/server.d.ts +140 -0
  113. package/dist/server.d.ts.map +1 -0
  114. package/dist/server.js +829 -0
  115. package/dist/server.js.map +1 -0
  116. package/dist/web/apple-touch-icon-precomposed.png +0 -0
  117. package/dist/web/apple-touch-icon.png +0 -0
  118. package/dist/web/assets/index-NOGXMIsS.js +65 -0
  119. package/dist/web/assets/index-NOGXMIsS.js.map +1 -0
  120. package/dist/web/assets/index-s7zoNGmx.css +1 -0
  121. package/dist/web/fonts/Montserrat-OFL.txt +93 -0
  122. package/dist/web/fonts/montserrat-medium.woff2 +0 -0
  123. package/dist/web/fonts/montserrat-regular.woff2 +0 -0
  124. package/dist/web/icon-192.png +0 -0
  125. package/dist/web/icon-512.png +0 -0
  126. package/dist/web/icon-maskable-512.png +0 -0
  127. package/dist/web/icon-maskable.svg +15 -0
  128. package/dist/web/icon.svg +6 -0
  129. package/dist/web/index.html +25 -0
  130. package/dist/web/manifest.webmanifest +37 -0
  131. package/package.json +60 -3
@@ -0,0 +1,54 @@
1
+ export function service(ctx, key) {
2
+ try {
3
+ const direct = ctx[key];
4
+ if (direct !== undefined)
5
+ return direct;
6
+ }
7
+ catch { }
8
+ try {
9
+ if (typeof ctx.get === 'function') {
10
+ const resolved = ctx.get(key);
11
+ if (resolved !== undefined)
12
+ return resolved;
13
+ }
14
+ }
15
+ catch { }
16
+ return undefined;
17
+ }
18
+ export function serviceNames(ctx) {
19
+ const reflect = ctx.reflect ??
20
+ service(ctx, 'reflect');
21
+ try {
22
+ const store = reflect?.store;
23
+ if (!store)
24
+ return [];
25
+ return Object.getOwnPropertySymbols(store)
26
+ .map((symbol) => store[symbol]?.name)
27
+ .filter((name) => typeof name === 'string')
28
+ .sort();
29
+ }
30
+ catch {
31
+ return [];
32
+ }
33
+ }
34
+ export function methodNames(value, limit = 24) {
35
+ if (value === null || typeof value !== 'object')
36
+ return [];
37
+ try {
38
+ const names = new Set();
39
+ let proto = Object.getPrototypeOf(value);
40
+ while (proto && proto !== Object.prototype) {
41
+ for (const name of Object.getOwnPropertyNames(proto)) {
42
+ if (name === 'constructor')
43
+ continue;
44
+ names.add(name);
45
+ }
46
+ proto = Object.getPrototypeOf(proto);
47
+ }
48
+ return [...names].slice(0, limit);
49
+ }
50
+ catch {
51
+ return [];
52
+ }
53
+ }
54
+ //# sourceMappingURL=host-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-api.js","sourceRoot":"","sources":["../src/host-api.ts"],"names":[],"mappings":"AA0JA,MAAM,UAAU,OAAO,CAAI,GAAgB,EAAE,GAAW;IACtD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,GAA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cAAc,CAAC,KAAK,CAAkB,CAAC;QAC1D,OAAO,KAAK,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;YAC3C,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;gBACrD,IAAI,IAAI,KAAK,aAAa;oBAAE,SAAS;gBACrC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC;YACD,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAkB,CAAC;QACxD,CAAC;QAED,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { HostContext } from './host-api.js';
2
+ export declare const name = "dsh-mobile-companion";
3
+ export declare const inject: string[];
4
+ export declare function apply(ctx: HostContext): void;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAKjD,eAAO,MAAM,IAAI,yBAAyB,CAAC;AAE3C,eAAO,MAAM,MAAM,UAAiD,CAAC;AAIrE,wBAAgB,KAAK,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI,CA2P5C"}
package/dist/index.js ADDED
@@ -0,0 +1,268 @@
1
+ import { PROBE_LOG_PATH, COMPANION_DIR, log } from './log.js';
2
+ import { DeviceRegistry } from './core/devices.js';
3
+ import { PairingService } from './core/pairing.js';
4
+ import { DevicesFile } from './persist/devices-file.js';
5
+ import { join } from 'node:path';
6
+ import { findWebRoot } from './routes/web-root.js';
7
+ import { resolvePublicOrigin } from './public-origin.js';
8
+ import { listSessions } from './dsh/session-source.js';
9
+ import { answerQuestion, listPendingQuestions } from './dsh/questions.js';
10
+ import { cancelRun, readHistory, subscribeSession } from './dsh/transcript.js';
11
+ import { injectText } from './dsh/prompt.js';
12
+ import { buildPairingMessage } from './pairing-message.js';
13
+ import { qrText } from './qr-text.js';
14
+ import { buildPairingUrl } from '@deepseekharness-mobile/protocol';
15
+ import { openInBrowser } from './open-browser.js';
16
+ import { resolveSessionId } from './dsh/sessions.js';
17
+ import { hasWorkspaces, listWorkspaces } from './dsh/workspaces.js';
18
+ import { archiveSession, canArchiveSession, canCreateSession, canUnarchiveSession, createSession, unarchiveSession, } from './dsh/lifecycle.js';
19
+ import { canListModels, canSelectModel, listModels, selectModel } from './dsh/models.js';
20
+ import { commandsAvailable, listCommands, runCommand } from './dsh/slash-commands.js';
21
+ import { activityAvailable, readSessionActivity } from './dsh/session-activity.js';
22
+ import { connectProvider, disconnectProvider, listProviders, providerConnectAvailable, providersAvailable, testProvider, } from './dsh/providers.js';
23
+ import { createQuestionBridge } from './dsh/question-bridge.js';
24
+ import { reportToLog, reportToText, runProbe } from './probe.js';
25
+ import { DEFAULT_PORT, startCompanionServer } from './server.js';
26
+ export const name = 'dsh-mobile-companion';
27
+ export const inject = ['sessions', 'sessionProjections', 'commands'];
28
+ const COMMAND_DESCRIPTION = 'Pair your phone, or check the companion status';
29
+ export function apply(ctx) {
30
+ log(`plugin loaded · evidence in ${PROBE_LOG_PATH}`);
31
+ const disposers = [];
32
+ const probe = () => {
33
+ const report = runProbe(ctx);
34
+ reportToLog(report);
35
+ return report;
36
+ };
37
+ let origin;
38
+ let listeningPort;
39
+ let listenerError;
40
+ let runningServer;
41
+ const questionBridge = createQuestionBridge(ctx, {
42
+ push: (message) => runningServer?.broadcast(message),
43
+ clients: () => runningServer?.clientCount() ?? 0,
44
+ });
45
+ disposers.push(() => questionBridge.dispose());
46
+ const linkFor = (code) => {
47
+ const port = listeningPort ?? DEFAULT_PORT;
48
+ return buildPairingUrl(origin?.origin ?? `http://127.0.0.1:${port}`, code);
49
+ };
50
+ const qrFor = (code) => {
51
+ try {
52
+ return qrText(linkFor(code));
53
+ }
54
+ catch {
55
+ return undefined;
56
+ }
57
+ };
58
+ const openPairingPage = () => {
59
+ const page = `${origin?.origin ?? `http://127.0.0.1:${listeningPort ?? DEFAULT_PORT}`}/pair`;
60
+ void openInBrowser(page).then((abierto) => {
61
+ if (!abierto)
62
+ log(`could not open the browser at ${page}`);
63
+ });
64
+ return `Opening ${page} in the desktop browser.`;
65
+ };
66
+ const detectOrigin = async (port) => {
67
+ try {
68
+ origin = await resolvePublicOrigin(publicUrl, port);
69
+ log(`public pairing origin: ${origin.origin} (${origin.source})`);
70
+ }
71
+ catch { }
72
+ };
73
+ if (ctx.commands) {
74
+ const register = () => ctx.commands.register({
75
+ name: 'mobile',
76
+ description: COMMAND_DESCRIPTION,
77
+ input: { hint: '[open|qr|link|status]' },
78
+ handler: (invocation) => {
79
+ const argument = (invocation.rawInput ?? '').trim().toLowerCase();
80
+ if (argument === 'status' || argument === 'probe') {
81
+ try {
82
+ const report = probe();
83
+ return {
84
+ kind: 'success',
85
+ text: `${reportToText(report)}\n\nFull evidence: ${PROBE_LOG_PATH}`,
86
+ };
87
+ }
88
+ catch (error) {
89
+ return { kind: 'error', text: `The probe failed: ${String(error)}` };
90
+ }
91
+ }
92
+ try {
93
+ const current = pairing.pending()[0] ?? pairing.issue();
94
+ const wantsQr = argument === 'qr';
95
+ const wantsLinkOnly = argument === 'link';
96
+ const message = buildPairingMessage({
97
+ code: current.code,
98
+ expiresAt: current.expiresAt,
99
+ origin,
100
+ port: listeningPort,
101
+ listenerError,
102
+ fallbackPort: DEFAULT_PORT,
103
+ qr: wantsQr ? qrFor(current.code) : undefined,
104
+ });
105
+ const opensBrowser = !wantsQr && !wantsLinkOnly && !listenerError;
106
+ return {
107
+ kind: message.compromised && listenerError ? 'error' : 'success',
108
+ text: opensBrowser ? `${message.text}\n\n${openPairingPage()}` : message.text,
109
+ };
110
+ }
111
+ catch (error) {
112
+ return { kind: 'error', text: `Could not prepare the pairing: ${String(error)}` };
113
+ }
114
+ },
115
+ });
116
+ const registerSay = () => ctx.commands.register({
117
+ name: 'mobile-say',
118
+ description: 'Inject a message into a session through sessionController.prompt',
119
+ input: { hint: '<sessionId> <text>' },
120
+ handler: (invocation) => {
121
+ const raw = (invocation.rawInput ?? '').trim();
122
+ const split = raw.indexOf(' ');
123
+ if (split <= 0) {
124
+ return { kind: 'error', text: 'Usage: /mobile-say <sessionId> <text>' };
125
+ }
126
+ const resolution = resolveSessionId(ctx, raw.slice(0, split));
127
+ if (!resolution.ok)
128
+ return { kind: 'error', text: resolution.error };
129
+ const text = raw.slice(split + 1).trim();
130
+ log(`E0.3: injecting ${text.length} characters into ${resolution.id}`);
131
+ void injectText(ctx, resolution.id, text).then((result) => log(`E0.3 resultado: ok=${result.ok} · ${result.detail}`));
132
+ return {
133
+ kind: 'success',
134
+ text: `Send dispatched to ${resolution.id}. The result is in ${PROBE_LOG_PATH}.`,
135
+ };
136
+ },
137
+ });
138
+ try {
139
+ if (typeof ctx.effect === 'function') {
140
+ ctx.effect(function* () {
141
+ yield register();
142
+ yield registerSay();
143
+ }, 'dsh-mobile commands');
144
+ }
145
+ else {
146
+ disposers.push(register(), registerSay());
147
+ }
148
+ }
149
+ catch (error) {
150
+ log(`could not register the commands: ${String(error)}`);
151
+ }
152
+ }
153
+ else {
154
+ log('the commands service is not available; /mobile is disabled');
155
+ }
156
+ const pairing = new PairingService();
157
+ const devices = new DeviceRegistry({
158
+ persistence: new DevicesFile(join(COMPANION_DIR, 'devices.json')),
159
+ });
160
+ const portFromEnv = Number(process.env.DSH_MOBILE_PORT ?? '');
161
+ const options = Number.isInteger(portFromEnv) && portFromEnv > 0 ? { port: portFromEnv } : {};
162
+ const publicUrl = process.env.DSH_MOBILE_PUBLIC_URL?.trim();
163
+ const webRoot = findWebRoot();
164
+ log(webRoot ? `PWA served from ${webRoot}` : 'PWA not found; the host serves the API only');
165
+ const limits = () => {
166
+ const list = [];
167
+ if (hasWorkspaces(ctx))
168
+ list.push('workspace.list');
169
+ if (canCreateSession(ctx))
170
+ list.push('session.create');
171
+ if (canArchiveSession(ctx))
172
+ list.push('workspace.archive');
173
+ if (canUnarchiveSession(ctx))
174
+ list.push('workspace.unarchive');
175
+ if (canListModels(ctx) && canSelectModel(ctx))
176
+ list.push('model.select');
177
+ if (commandsAvailable(ctx))
178
+ list.push('command.run');
179
+ if (activityAvailable(ctx))
180
+ list.push('session.activity');
181
+ if (providersAvailable(ctx))
182
+ list.push('providers.list');
183
+ if (providerConnectAvailable(ctx))
184
+ list.push('provider.connect');
185
+ list.push('devices.manage');
186
+ return list;
187
+ };
188
+ void startCompanionServer({
189
+ pairing,
190
+ devices,
191
+ capabilities: limits,
192
+ ...options,
193
+ ...(publicUrl ? { publicUrl } : {}),
194
+ ...(webRoot ? { webRoot } : {}),
195
+ listSessions: async (options) => {
196
+ const records = await listSessions(ctx, options);
197
+ const counts = questionBridge.counts();
198
+ for (const record of records) {
199
+ const extra = counts.get(record.id) ?? 0;
200
+ if (extra > 0)
201
+ record.pendingQuestions += extra;
202
+ }
203
+ return records;
204
+ },
205
+ listWorkspaces: () => listWorkspaces(ctx),
206
+ createSession: (request) => createSession(ctx, request),
207
+ archiveSession: (request) => archiveSession(ctx, request),
208
+ unarchiveSession: (request) => unarchiveSession(ctx, request),
209
+ listModels: () => listModels(ctx),
210
+ selectModel: (request) => selectModel(ctx, request),
211
+ listQuestions: () => [...listPendingQuestions(ctx), ...questionBridge.pendingBatches()],
212
+ listCommands: (sessionId) => listCommands(ctx, sessionId),
213
+ runCommand: (input) => runCommand(ctx, input),
214
+ readActivity: (sessionId) => readSessionActivity(ctx, sessionId),
215
+ listProviders: () => listProviders(ctx),
216
+ testProvider: (input) => testProvider(ctx, input),
217
+ connectProvider: (input) => connectProvider(ctx, input),
218
+ disconnectProvider: (input) => disconnectProvider(ctx, input),
219
+ answerQuestion: (input) => questionBridge.answer(input) ?? answerQuestion(ctx, input),
220
+ readHistory: (sessionId, options) => readHistory(ctx, sessionId, options),
221
+ subscribeSession: (sessionId, options) => subscribeSession(ctx, sessionId, options),
222
+ cancelRun: (sessionId) => cancelRun(ctx, sessionId),
223
+ sendReply: async (sessionId, text) => {
224
+ const result = await injectText(ctx, sessionId, text);
225
+ return result.ok
226
+ ? { ok: true }
227
+ : { ok: false, code: 'bad-request', message: result.detail };
228
+ },
229
+ report: () => probe(),
230
+ })
231
+ .then((running) => {
232
+ runningServer = running;
233
+ disposers.push(() => {
234
+ runningServer = undefined;
235
+ void running.close().catch(() => undefined);
236
+ });
237
+ listeningPort = running.port;
238
+ log(`listener ready on port ${running.port} (try: GET /health)`);
239
+ void detectOrigin(running.port);
240
+ })
241
+ .catch((error) => {
242
+ listenerError = String(error);
243
+ log(`could not open the listener: ${listenerError}`);
244
+ });
245
+ const timer = setTimeout(() => {
246
+ try {
247
+ probe();
248
+ }
249
+ catch (error) {
250
+ log(`the startup probe failed: ${String(error)}`);
251
+ }
252
+ }, 2000);
253
+ if (typeof timer.unref === 'function')
254
+ timer.unref();
255
+ ctx.effect?.(function* () {
256
+ yield () => {
257
+ clearTimeout(timer);
258
+ for (const dispose of disposers.reverse()) {
259
+ try {
260
+ dispose();
261
+ }
262
+ catch { }
263
+ }
264
+ log('plugin unloaded');
265
+ };
266
+ }, 'dsh-mobile lifecycle');
267
+ }
268
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,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AAC,QAAQ,CAAC;QACpB,MAAM,GAAG,EAAE;YACT,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,KAAK,MAAM,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC1C,IAAI,CAAC;oBACH,OAAO,EAAE,CAAC;gBACZ,CAAC;gBAAC,MAAM,CAAC,CAAA,CAAC;YACZ,CAAC;YACD,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACzB,CAAC,CAAC;IACJ,CAAC,EAAE,sBAAsB,CAAC,CAAC;AAC7B,CAAC"}
package/dist/log.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export declare const COMPANION_DIR: string;
2
+ export declare function rotateIfNeeded(file: string, limit?: number): void;
3
+ export declare function log(message: string): void;
4
+ export declare const PROBE_LOG_PATH: string;
5
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,aAAa,QAAM,CAAC;AAYjC,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAgB,GAAG,IAAI,CAOxE;AAED,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CASzC;AAED,eAAO,MAAM,cAAc,QAAO,CAAC"}
package/dist/log.js ADDED
@@ -0,0 +1,40 @@
1
+ import { appendFileSync, mkdirSync, renameSync, rmSync, statSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ const DSH_HOME = process.env.DSH_HOME ?? join(homedir(), '.dsh');
5
+ const DIR = join(DSH_HOME, 'companion');
6
+ const FILE = join(DIR, 'probe.log');
7
+ const MAX_LOG_BYTES = 1024 * 1024;
8
+ export const COMPANION_DIR = DIR;
9
+ const FILE_LOGGING = process.env.DSH_MOBILE_LOG_FILE !== '0';
10
+ let ready = false;
11
+ function ensureDir() {
12
+ if (ready)
13
+ return;
14
+ mkdirSync(DIR, { recursive: true });
15
+ ready = true;
16
+ }
17
+ export function rotateIfNeeded(file, limit = MAX_LOG_BYTES) {
18
+ try {
19
+ if (statSync(file).size < limit)
20
+ return;
21
+ const previous = `${file}.1`;
22
+ rmSync(previous, { force: true });
23
+ renameSync(file, previous);
24
+ }
25
+ catch { }
26
+ }
27
+ export function log(message) {
28
+ const line = `[${new Date().toISOString()}] ${message}`;
29
+ console.log(`[dsh-mobile] ${message}`);
30
+ if (!FILE_LOGGING)
31
+ return;
32
+ try {
33
+ ensureDir();
34
+ rotateIfNeeded(FILE);
35
+ appendFileSync(FILE, `${line}\n`, 'utf8');
36
+ }
37
+ catch { }
38
+ }
39
+ export const PROBE_LOG_PATH = FILE;
40
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;AACjE,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACxC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;AACpC,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC;AAElC,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,GAAG,CAAC;AAE7D,IAAI,KAAK,GAAG,KAAK,CAAC;AAElB,SAAS,SAAS;IAChB,IAAI,KAAK;QAAE,OAAO;IAClB,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACpC,KAAK,GAAG,IAAI,CAAC;AACf,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,KAAK,GAAG,aAAa;IAChE,IAAI,CAAC;QACH,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,KAAK;YAAE,OAAO;QACxC,MAAM,QAAQ,GAAG,GAAG,IAAI,IAAI,CAAC;QAC7B,MAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAClC,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,OAAe;IACjC,MAAM,IAAI,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,gBAAgB,OAAO,EAAE,CAAC,CAAC;IACvC,IAAI,CAAC,YAAY;QAAE,OAAO;IAC1B,IAAI,CAAC;QACH,SAAS,EAAE,CAAC;QACZ,cAAc,CAAC,IAAI,CAAC,CAAC;QACrB,cAAc,CAAC,IAAI,EAAE,GAAG,IAAI,IAAI,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;AACZ,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function browserOpener(): string | undefined;
2
+ export declare function openInBrowser(url: string, opener?: string | undefined): Promise<boolean>;
3
+ //# sourceMappingURL=open-browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-browser.d.ts","sourceRoot":"","sources":["../src/open-browser.ts"],"names":[],"mappings":"AAIA,wBAAgB,aAAa,IAAI,MAAM,GAAG,SAAS,CAqBlD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,qBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC,CAerF"}
@@ -0,0 +1,46 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { existsSync } from 'node:fs';
3
+ import { isAbsolute, join } from 'node:path';
4
+ export function browserOpener() {
5
+ const candidates = [];
6
+ if (process.platform === 'win32') {
7
+ const systemRoot = process.env['SystemRoot'];
8
+ if (systemRoot && isAbsolute(systemRoot))
9
+ candidates.push(join(systemRoot, 'explorer.exe'));
10
+ candidates.push(join('C:\\Windows', 'explorer.exe'));
11
+ }
12
+ else if (process.platform === 'darwin') {
13
+ candidates.push('/usr/bin/open');
14
+ }
15
+ else {
16
+ candidates.push('/usr/bin/xdg-open', '/usr/local/bin/xdg-open', '/bin/xdg-open');
17
+ }
18
+ return candidates.find((candidate) => {
19
+ if (!isAbsolute(candidate))
20
+ return false;
21
+ try {
22
+ return existsSync(candidate);
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ });
28
+ }
29
+ export function openInBrowser(url, opener = browserOpener()) {
30
+ if (!opener)
31
+ return Promise.resolve(false);
32
+ return new Promise((resolve) => {
33
+ try {
34
+ const child = spawn(opener, [url], { detached: true, stdio: 'ignore', windowsHide: true });
35
+ child.once('error', () => resolve(false));
36
+ child.once('spawn', () => {
37
+ child.unref();
38
+ resolve(true);
39
+ });
40
+ }
41
+ catch {
42
+ resolve(false);
43
+ }
44
+ });
45
+ }
46
+ //# sourceMappingURL=open-browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-browser.js","sourceRoot":"","sources":["../src/open-browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM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AAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3F,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1C,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;gBACvB,KAAK,CAAC,KAAK,EAAE,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { ResolvedOrigin } from './public-origin.js';
2
+ export interface PairingView {
3
+ code: string;
4
+ expiresAt: number;
5
+ origin?: ResolvedOrigin | undefined;
6
+ port?: number | undefined;
7
+ listenerError?: string | undefined;
8
+ fallbackPort: number;
9
+ qr?: string | undefined;
10
+ }
11
+ export interface PairingLink {
12
+ text: string;
13
+ compromised: boolean;
14
+ }
15
+ export declare function buildPairingMessage(view: PairingView): PairingLink;
16
+ //# sourceMappingURL=pairing-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pairing-message.d.ts","sourceRoot":"","sources":["../src/pairing-message.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AASzD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,CA6ClE"}
@@ -0,0 +1,38 @@
1
+ import { buildPairingUrl } from '@deepseekharness-mobile/protocol';
2
+ const ORIGIN_LABEL = {
3
+ config: 'the configured address',
4
+ tailscale: 'the tailnet name',
5
+ loopback: 'this machine only',
6
+ detectando: 'working it out',
7
+ };
8
+ export function buildPairingMessage(view) {
9
+ if (view.listenerError) {
10
+ return {
11
+ compromised: true,
12
+ text: [
13
+ 'The plugin could not open its listener, so there is nowhere to pair.',
14
+ '',
15
+ view.listenerError,
16
+ '',
17
+ 'Check that the port is free and start DSH again.',
18
+ ].join('\n'),
19
+ };
20
+ }
21
+ const port = view.port ?? view.fallbackPort;
22
+ const base = view.origin?.origin ?? `http://127.0.0.1:${port}`;
23
+ const link = buildPairingUrl(base, view.code);
24
+ const compromised = view.origin === undefined || view.origin.loopback;
25
+ const lines = ['Pair your phone', ''];
26
+ if (view.qr) {
27
+ lines.push('Scan this with your phone camera. It only works where line height equals', 'font size; if it does not scan, open the pairing page instead:', '', view.qr, '');
28
+ }
29
+ lines.push(`Link: ${link}`, `Code: ${view.code}`);
30
+ lines.push(`Expires at ${new Date(view.expiresAt).toLocaleTimeString()} · single use`);
31
+ if (compromised) {
32
+ lines.push('', 'Heads up: this link points at loopback, which on a phone is the phone itself.', 'Open it through the tailnet name, or set DSH_MOBILE_PUBLIC_URL.');
33
+ }
34
+ const source = view.origin?.source ?? 'detectando';
35
+ lines.push('', `Origin: ${ORIGIN_LABEL[source] ?? source}`);
36
+ return { text: lines.join('\n'), compromised };
37
+ }
38
+ //# sourceMappingURL=pairing-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pairing-message.js","sourceRoot":"","sources":["../src/pairing-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE,MAAM,YAAY,GA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AAI,CACR,EAAE,EACF,+EAA+E,EAC/E,iEAAiE,CAClE,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,YAAY,CAAC;IACnD,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,WAAW,YAAY,CAAC,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC,CAAC;IAC5D,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;AACjD,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { DevicePersistence, StoredDevice } from '../core/devices.js';
2
+ export declare class DevicesFile implements DevicePersistence {
3
+ #private;
4
+ constructor(file: string);
5
+ load(): StoredDevice[];
6
+ save(devices: StoredDevice[]): void;
7
+ }
8
+ //# sourceMappingURL=devices-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devices-file.d.ts","sourceRoot":"","sources":["../../src/persist/devices-file.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE1E,qBAAa,WAAY,YAAW,iBAAiB;;gBAGvC,IAAI,EAAE,MAAM;IAIxB,IAAI,IAAI,YAAY,EAAE;IAgBtB,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,IAAI;CAapC"}
@@ -0,0 +1,47 @@
1
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
2
+ import { dirname } from 'node:path';
3
+ export class DevicesFile {
4
+ #file;
5
+ constructor(file) {
6
+ this.#file = file;
7
+ }
8
+ load() {
9
+ let raw;
10
+ try {
11
+ raw = readFileSync(this.#file, 'utf8');
12
+ }
13
+ catch {
14
+ return [];
15
+ }
16
+ if (raw.charCodeAt(0) === 0xfeff)
17
+ raw = raw.slice(1);
18
+ const parsed = JSON.parse(raw);
19
+ if (!Array.isArray(parsed))
20
+ return [];
21
+ return parsed.filter(isStoredDevice);
22
+ }
23
+ save(devices) {
24
+ const dir = dirname(this.#file);
25
+ mkdirSync(dir, { recursive: true });
26
+ const temp = `${this.#file}.tmp`;
27
+ writeFileSync(temp, JSON.stringify(devices, null, 2), { encoding: 'utf8' });
28
+ try {
29
+ renameSync(temp, this.#file);
30
+ }
31
+ catch {
32
+ writeFileSync(this.#file, JSON.stringify(devices, null, 2), { encoding: 'utf8' });
33
+ }
34
+ }
35
+ }
36
+ function isStoredDevice(value) {
37
+ if (typeof value !== 'object' || value === null)
38
+ return false;
39
+ const record = value;
40
+ return (typeof record['id'] === 'string' &&
41
+ typeof record['name'] === 'string' &&
42
+ typeof record['platform'] === 'string' &&
43
+ typeof record['tokenHash'] === 'string' &&
44
+ typeof record['createdAt'] === 'number' &&
45
+ typeof record['lastSeenAt'] === 'number');
46
+ }
47
+ //# sourceMappingURL=devices-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devices-file.js","sourceRoot":"","sources":["../../src/persist/devices-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,OAAO,WAAW;IACb,KAAK,CAAS;IAEvB,YAAY,IAAY;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,IAAI;QACF,IAAI,GAAW,CAAC;QAChB,IAAI,CAAC;YACH,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACzC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM;YAAE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAErD,MAAM,MAAM,GAAY,IAAI,CAAC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QAAQ;QACvC,OAAO,MAAM,CAAC,YAAY,CAAC,KAAK,QAAQ,CACzC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { type HostContext } from './host-api.js';
2
+ export interface ServiceDetail {
3
+ name: string;
4
+ methods: string[];
5
+ }
6
+ export interface SessionFacts {
7
+ id: string;
8
+ messageCount: number | undefined;
9
+ asOfSeq: number | undefined;
10
+ projectionKeys: string[] | undefined;
11
+ pendingQuestions: unknown;
12
+ }
13
+ export interface ProbeReport {
14
+ timestamp: string;
15
+ serviceNames: string[];
16
+ serviceDetails: ServiceDetail[];
17
+ services: Record<string, string>;
18
+ sessionCount: number | undefined;
19
+ sessions: SessionFacts[];
20
+ injectionCandidates: Record<string, string>;
21
+ }
22
+ export declare function runProbe(ctx: HostContext): ProbeReport;
23
+ export declare function reportToLog(report: ProbeReport): void;
24
+ export declare function reportToText(report: ProbeReport): string;
25
+ //# sourceMappingURL=probe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../src/probe.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,WAAW,EAIjB,MAAM,eAAe,CAAC;AAKvB,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,cAAc,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACrC,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C;AAmDD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,CAwDtD;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAoBrD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CA+BxD"}