feat: wire Cordis apply lifecycle with soft-fail token check

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
owo
2026-08-14 16:30:48 +08:00
co-authored by Cursor
parent cdfe81cd9e
commit 27f02b7460
3 changed files with 55 additions and 6 deletions
+21
View File
@@ -0,0 +1,21 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { apply } from '../src/index.ts'
test('apply without token does not throw and does not start effect', () => {
const effects: string[] = []
const ctx = {
effect(_fn: () => () => void, name: string) {
effects.push(name)
return () => {}
},
logger: { error() {}, warn() {} },
agents: {},
} as any
const prev = process.env.DSH_TELEGRAM_TOKEN
delete process.env.DSH_TELEGRAM_TOKEN
assert.doesNotThrow(() => apply(ctx, { token: '', allowedUserIds: [1] }))
assert.deepEqual(effects, [])
if (prev !== undefined) process.env.DSH_TELEGRAM_TOKEN = prev
else delete process.env.DSH_TELEGRAM_TOKEN
})