mirror of
https://github.com/hansjone/dsh-ops-cron.git
synced 2026-10-09 04:33:18 +08:00
Extend jobs with lifecycle projection and history policies so listeners can poll state at scale without breaking existing cron_* flows. Co-authored-by: Cursor <cursoragent@cursor.com>
94 lines
4.2 KiB
JavaScript
94 lines
4.2 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { readFile } from 'node:fs/promises'
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { test } from 'node:test'
|
|
|
|
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
|
|
test('installable bundle declares host apply, client half, unique id, and no @deepseek-ai runtime deps', async () => {
|
|
const pkg = JSON.parse(await readFile(join(root, 'package.json'), 'utf8'))
|
|
assert.equal(pkg.name, 'dsh-ops-cron')
|
|
assert.equal(pkg.dsh.bundle.patch, './cordis.patch.yml')
|
|
assert.equal(pkg.dsh.client.platform, 'web')
|
|
assert.ok(pkg.exports['./client'])
|
|
assert.equal(pkg.main, 'lib/index.js')
|
|
assert.ok(!pkg.dependencies || !Object.keys(pkg.dependencies).some((id) => id.startsWith('@deepseek-ai/')))
|
|
const patch = await readFile(join(root, 'cordis.patch.yml'), 'utf8')
|
|
assert.match(patch, /id:\s*dsh-ops-cron/)
|
|
const index = await readFile(join(root, 'lib/index.js'), 'utf8')
|
|
assert.match(index, /export function apply\(/)
|
|
assert.match(index, /registerCronTools/)
|
|
assert.match(index, /inject\(\['tools'\]/)
|
|
assert.match(index, /getDshIm/)
|
|
const tools = await readFile(join(root, 'lib/tools.js'), 'utf8')
|
|
assert.match(tools, /name: 'cron_create'/)
|
|
assert.match(tools, /name: 'cron_list'/)
|
|
assert.match(tools, /name: 'cron_query'/)
|
|
assert.match(tools, /name: 'cron_runs'/)
|
|
assert.match(tools, /name: 'cron_progress'/)
|
|
assert.match(tools, /crontab/)
|
|
assert.match(tools, /scheduled-tasks/)
|
|
assert.match(tools, /hour/)
|
|
assert.match(tools, /Current local time/)
|
|
assert.match(tools, /source: 'runtime'/)
|
|
assert.match(tools, /resolveCreateDelivery/)
|
|
assert.match(tools, /im_bot_id/)
|
|
assert.match(tools, /resolveCreateCwd/)
|
|
assert.match(tools, /after_minutes/)
|
|
assert.match(tools, /Extra schedule fields are ignored/)
|
|
assert.match(tools, /agent_preset/)
|
|
assert.match(tools, /resolveCreateAgentPreset/)
|
|
assert.doesNotMatch(tools, /pass only one of expr, at, or hour/)
|
|
assert.match(index, /makeCronSkill/)
|
|
assert.doesNotMatch(index, /agent\/session-start/)
|
|
assert.doesNotMatch(index, /system-reminder/)
|
|
assert.doesNotMatch(tools, /from ['"]@deepseek-ai\//)
|
|
const host = await readFile(join(root, 'lib/host.js'), 'utf8')
|
|
assert.match(host, /agentDefaultModel/)
|
|
assert.match(host, /deliverRunToIm/)
|
|
assert.match(host, /mirrorRunToSession/)
|
|
assert.match(host, /mirrorToSession/)
|
|
assert.match(host, /getAgents/)
|
|
assert.match(host, /PLUGIN_NAME = 'dsh-ops-cron'/)
|
|
assert.match(host, /API_PREFIX = '\/dsh-ops-cron'/)
|
|
assert.match(host, /resolveSessionPlacement/)
|
|
assert.match(host, /\/models/)
|
|
assert.match(host, /\/presets/)
|
|
assert.match(host, /composeCronAgent/)
|
|
assert.match(host, /listPresetChoices/)
|
|
assert.doesNotMatch(host, /from ['"]@deepseek-ai\//)
|
|
const client = await readFile(join(root, 'lib/client.js'), 'utf8')
|
|
assert.match(client, /定时任务/)
|
|
assert.match(client, /dsh-ops-cron/)
|
|
assert.match(client, /settings\.plugin\.item/)
|
|
assert.match(client, /deliveryKind/)
|
|
assert.match(client, /imBotId/)
|
|
assert.match(client, /imTargetId/)
|
|
assert.match(client, /CwdField/)
|
|
assert.match(client, /ModelField/)
|
|
assert.match(client, /PresetField/)
|
|
assert.match(client, /agentPreset/)
|
|
assert.match(client, /mirrorToSession/)
|
|
assert.match(client, /inject = \['slots', 'locale', 'settingsScope'\]/)
|
|
assert.match(client, /locale\.bind/)
|
|
assert.match(client, /locale\/change/)
|
|
assert.match(client, /loginRequired/)
|
|
assert.match(client, /runNoSession/)
|
|
assert.match(client, /body\.message/)
|
|
const i18n = await readFile(join(root, 'lib/i18n.js'), 'utf8')
|
|
assert.match(i18n, /err\.login_required/)
|
|
assert.match(i18n, /export function apiError/)
|
|
assert.ok(pkg.exports['./i18n'])
|
|
const preset = await readFile(join(root, 'lib/preset.js'), 'utf8')
|
|
assert.match(preset, /resolveCreateAgentPreset/)
|
|
const delivery = await readFile(join(root, 'lib/delivery.js'), 'utf8')
|
|
assert.match(delivery, /resolveCreateDelivery/)
|
|
assert.match(delivery, /resolveCreateOrigin/)
|
|
assert.match(delivery, /mirrorRunToSession/)
|
|
assert.match(delivery, /deliverRunToIm/)
|
|
assert.match(client, /origin/)
|
|
const prd = await readFile(join(root, 'docs/PRD.md'), 'utf8')
|
|
assert.match(prd, /定时任务/)
|
|
assert.match(prd, /dsh-schedule/)
|
|
})
|