@goodandready/dsh-messenger-gateway 0.4.14 → 0.4.15
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/lib/file-manager.js +9 -0
- package/lib/gateway.js +4 -2
- package/lib/index.js +12 -7
- package/lib/stream.js +2 -1
- package/package.json +1 -1
package/lib/file-manager.js
CHANGED
|
@@ -76,6 +76,15 @@ export function resolveSafePath(baseCwd, userPath = '.') {
|
|
|
76
76
|
return { base, target, relativePath: rel || '.' }
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Resolves candidate path strictly inside base directory (Issue #127).
|
|
81
|
+
* Throws ERR_PATH_TRAVERSAL if candidate escapes base (lexically, absolute, drive letter or symlink).
|
|
82
|
+
* Returns the resolved absolute target path.
|
|
83
|
+
*/
|
|
84
|
+
export function resolveInside(base, candidate = '.') {
|
|
85
|
+
return resolveSafePath(base, candidate).target
|
|
86
|
+
}
|
|
87
|
+
|
|
79
88
|
export async function listFiles(baseCwd, subPath = '.', opts = {}) {
|
|
80
89
|
const { maxEntries = 50, showHidden = false } = opts
|
|
81
90
|
const { base, target, relativePath } = resolveSafePath(baseCwd, subPath)
|
package/lib/gateway.js
CHANGED
|
@@ -207,13 +207,13 @@ export class Gateway {
|
|
|
207
207
|
collector.onStream?.(collector.streamText, collector.toolName)
|
|
208
208
|
}
|
|
209
209
|
} else if (event.type === 'tool/call') {
|
|
210
|
-
collector.toolName = extractToolName(event.data) || collector.toolName
|
|
210
|
+
collector.toolName = extractToolName(event.data || event) || collector.toolName
|
|
211
211
|
collector.onStream?.(collector.streamText || '', collector.toolName)
|
|
212
212
|
} else if (event.type === 'tool/result') {
|
|
213
213
|
collector.toolName = ''
|
|
214
214
|
collector.onStream?.(collector.streamText || '', '')
|
|
215
215
|
} else if (event.type === 'turn/end') {
|
|
216
|
-
collector.reason = event.data?.reason || event.data
|
|
216
|
+
collector.reason = event.data?.reason || event.reason || event.data
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
@@ -225,6 +225,8 @@ export class Gateway {
|
|
|
225
225
|
this.ctx.on('turn/start', (session, data) => onHost(session, { type: 'turn/start', data })),
|
|
226
226
|
this.ctx.on('assistant/message', (session, message) => onHost(session, { type: 'assistant/message', data: { message } })),
|
|
227
227
|
this.ctx.on('assistant/chunk', (session, chunk) => onHost(session, { type: 'assistant/chunk', data: { chunk } })),
|
|
228
|
+
this.ctx.on('tool/call', (session, data) => onHost(session, { type: 'tool/call', data })),
|
|
229
|
+
this.ctx.on('tool/result', (session, data) => onHost(session, { type: 'tool/result', data })),
|
|
228
230
|
]
|
|
229
231
|
this.disposeListener = () => {
|
|
230
232
|
for (const un of unsubs) {
|
package/lib/index.js
CHANGED
|
@@ -343,13 +343,18 @@ export function apply(ctx, config) {
|
|
|
343
343
|
const gw = getGw()
|
|
344
344
|
if (gw) gw.syncTelegramCommands().catch((err) => ctx.logger?.debug?.(`sync telegram commands on skills change: ${err?.message || err}`))
|
|
345
345
|
}
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
346
|
+
const unbinds = [
|
|
347
|
+
ctx.on('tools/change', onSkillsChange),
|
|
348
|
+
ctx.on('tools/update', onSkillsChange),
|
|
349
|
+
ctx.on('tools/updated', onSkillsChange),
|
|
350
|
+
ctx.on('skills/change', onSkillsChange),
|
|
351
|
+
ctx.on('skills/updated', onSkillsChange),
|
|
352
|
+
ctx.on('skills/update', onSkillsChange),
|
|
353
|
+
]
|
|
349
354
|
return () => {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
355
|
+
for (const un of unbinds) {
|
|
356
|
+
if (typeof un === 'function') un()
|
|
357
|
+
}
|
|
353
358
|
}
|
|
354
359
|
}, 'dsh-messenger-gateway: dynamic skills sync')
|
|
355
360
|
|
|
@@ -372,7 +377,7 @@ export function apply(ctx, config) {
|
|
|
372
377
|
if (event.type !== 'turn/end') return
|
|
373
378
|
const prefixes = cfg.excludeSessionPrefixes || ['msgw-']
|
|
374
379
|
if (isExcludedSession(session.id, prefixes)) return
|
|
375
|
-
const reason = event.data?.reason
|
|
380
|
+
const reason = event.data?.reason || event.reason || event.data
|
|
376
381
|
const kind = reason?.kind === 'completed' ? 'task_done' : 'error'
|
|
377
382
|
const events = new Set(cfg.events?.length ? cfg.events : ['task_done', 'error'])
|
|
378
383
|
if (!events.has(kind)) return
|
package/lib/stream.js
CHANGED
|
@@ -11,7 +11,8 @@ export function extractTextDelta(chunk) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function extractToolName(eventData) {
|
|
14
|
-
|
|
14
|
+
if (typeof eventData === 'string') return eventData
|
|
15
|
+
const name = eventData?.tool?.name || eventData?.toolName || eventData?.name || eventData?.tool
|
|
15
16
|
return name ? String(name) : ''
|
|
16
17
|
}
|
|
17
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-messenger-gateway",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"description": "Telegram messenger bridge for DeepSeek Harness: sessions, steer, homes, inline asks, notify bridge, and optional TTS voice notes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|