mirror of
https://github.com/hansjone/dsh-ops-cron.git
synced 2026-10-09 03:03:18 +08:00
Fork dsh-cron-tasks as dsh-ops-cron with DSH/IM delivery.
Agent cron_* jobs default to IM when created from a WhatsApp session with a matching delivery target; otherwise DSH sidebar sessions. Fire path soft-calls ctx.dshIm.send for summaries. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
4447404361
commit
2f08136adf
17 changed files with 472 additions and 285 deletions
31
lib/index.js
31
lib/index.js
|
|
@ -1,8 +1,9 @@
|
|||
/**
|
||||
* dsh-cron-tasks, node half.
|
||||
* dsh-ops-cron, node half.
|
||||
*
|
||||
* Durable scheduled jobs: create a fresh root Session on fire, hide that
|
||||
* session from the workspace list, and keep history under 定时任务.
|
||||
* session from the workspace list, and keep history under 运维定时.
|
||||
* Jobs may deliver summaries to IM via soft-injected ctx.dshIm.
|
||||
*
|
||||
* Do not list @deepseek-ai/* in package.json — resolve schemastery from the
|
||||
* live profile so we share the host's settings identity.
|
||||
|
|
@ -48,6 +49,11 @@ export {
|
|||
export { wrapScheduledPrompt } from './prompt.js'
|
||||
export { normalizeJobModel } from './store.js'
|
||||
export { claimOccurrence, executeClaimedRun, extractAssistantText, TITLE_PREFIX } from './fire.js'
|
||||
export {
|
||||
deliverRunToIm,
|
||||
normalizeDelivery,
|
||||
resolveCreateDelivery,
|
||||
} from './delivery.js'
|
||||
|
||||
function loadPkg(id) {
|
||||
const homes = [
|
||||
|
|
@ -64,7 +70,7 @@ function loadPkg(id) {
|
|||
errors.push(`${from}: ${error instanceof Error ? error.message : String(error)}`)
|
||||
}
|
||||
}
|
||||
throw new Error(`[dsh-cron-tasks] cannot resolve ${id}\n${errors.join('\n')}`)
|
||||
throw new Error(`[dsh-ops-cron] cannot resolve ${id}\n${errors.join('\n')}`)
|
||||
}
|
||||
|
||||
const SchemaMod = loadPkg('@deepseek-ai/schemastery')
|
||||
|
|
@ -124,18 +130,21 @@ function registerWebRoute(ctx, handler) {
|
|||
|
||||
export function apply(ctx, config = {}) {
|
||||
const entry = resolveConfig(config)
|
||||
const getDshIm = () => tryGet(ctx, 'dshIm')
|
||||
const service = createHostService({
|
||||
sessionPort: makeLiveSessionPort(ctx),
|
||||
getDshIm,
|
||||
logger: ctx.logger,
|
||||
})
|
||||
|
||||
ctx.inject(['settings'], (sctx) => {
|
||||
sctx.settings.register(NS, Config, { base: entry, applies: 'live' })
|
||||
sctx.logger?.info?.(`[dsh-cron-tasks] settings namespace "${NS}" registered`)
|
||||
sctx.logger?.info?.(`[dsh-ops-cron] settings namespace "${NS}" registered`)
|
||||
})
|
||||
|
||||
ctx.inject(['tools'], (tctx) => {
|
||||
registerCronTools(tctx, service)
|
||||
tctx.logger?.info?.('[dsh-cron-tasks] tools cron_create/list/pause/resume/delete registered')
|
||||
registerCronTools(tctx, service, { getDshIm })
|
||||
tctx.logger?.info?.('[dsh-ops-cron] tools cron_create/list/pause/resume/delete registered')
|
||||
})
|
||||
|
||||
ctx.inject(['skills'], (sctx) => {
|
||||
|
|
@ -159,7 +168,7 @@ export function apply(ctx, config = {}) {
|
|||
}
|
||||
})
|
||||
return () => off()
|
||||
}, 'dsh-cron-tasks: settings watch')
|
||||
}, 'dsh-ops-cron: settings watch')
|
||||
|
||||
ctx.effect(() => registerWebRoute(ctx, (req, res) => {
|
||||
service.handleRequest(req, res).catch(() => {
|
||||
|
|
@ -168,7 +177,7 @@ export function apply(ctx, config = {}) {
|
|||
res.end(JSON.stringify({ ok: false, error: 'internal error' }))
|
||||
}
|
||||
})
|
||||
}), 'dsh-cron-tasks: web route')
|
||||
}), 'dsh-ops-cron: web route')
|
||||
|
||||
ctx.effect(() => {
|
||||
let stopped = false
|
||||
|
|
@ -181,13 +190,13 @@ export function apply(ctx, config = {}) {
|
|||
return service.tick()
|
||||
})
|
||||
.catch((error) => {
|
||||
ctx.logger?.warn?.(`[dsh-cron-tasks] recover failed: ${error instanceof Error ? error.message : error}`)
|
||||
ctx.logger?.warn?.(`[dsh-ops-cron] recover failed: ${error instanceof Error ? error.message : error}`)
|
||||
})
|
||||
return () => {
|
||||
stopped = true
|
||||
service.stopTimer()
|
||||
}
|
||||
}, 'dsh-cron-tasks: scheduler')
|
||||
}, 'dsh-ops-cron: scheduler')
|
||||
|
||||
ctx.logger?.info?.('[dsh-cron-tasks] host ready')
|
||||
ctx.logger?.info?.('[dsh-ops-cron] host ready')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue