mirror of
https://ghproxy.cflmy.top/https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-11-29 08:39:35 +08:00
docs(vendor/im): fix ResponseLike/responseOf JSDoc and cover Lark ResponseLike classify
This commit is contained in:
1 parent
b52f95fcd3
commit
542d33ec92
4 files changed
+15
-5
No files matched your search
Vendored
+1
-1
@@ -142,7 +142,7 @@ Keep this log exhaustive — every divergence from upstream must be listed. Each
|
||||
- **V103 · `plugin-im-adapter-qq` and `plugin-im-adapter-lark` mark all token-acquisition failures as `published: 'no'`**: `AccessToken.refresh()` and `cancelledTokenError()` in both adapters (plus QQ's `bot.ts` token poster status check) ensure transport errors, HTTP 4xx/429/5xx responses (preserving `kind`, `retryAfterMs`, `cause`, and `body`), empty token responses, and rethrown `PlatformError` / `LarkApiError` failures carry `published: 'no'` so callers can safely retry with platform backoff or record `failed` rather than `uncertain`. Covered by `vendor/plugin-im-adapter-qq/tests/token.spec.ts` and `vendor/plugin-im-adapter-lark/tests/bot.spec.ts`.
|
||||
- **V104 · `plugin-im-core` re-evaluates `idempotentSend` across `Bot.withRetry` attempts**: `Bot.send` passes `() => this.adapterHooks.idempotentSend?.(target, ctx) ?? false` into `Bot.withRetry` (whose unused `target` parameter is removed), and `withRetry` checks it both before and after backoff sleep (requiring `isIdempotent()` once any prior attempt returned `published: 'unknown'`, even if a later attempt returned `published: 'no'`) so an expiring time-bounded deduplication window aborts the retry as `published: 'unknown'`. Covered by `vendor/plugin-im-core/tests/bot.spec.ts`.
|
||||
- **V105 · `plugin-im-adapter-qq` exempts live ticketed windows from passive LRU eviction**: `PassiveManager.shrink()` only evicts entries with `tickets.size === 0` when enforcing `max` (and `PassiveManagerOptions.max` / `DEFAULT_MAX_WINDOWS` document this soft bound) so an in-flight retry's `(msg_id, msg_seq)` dedupe ticket is retained until its window expires. Covered by `vendor/plugin-im-adapter-qq/tests/passive.spec.ts`.
|
||||
- **V106 · `plugin-im-adapter-qq` and `plugin-im-adapter-lark` match structural `ResponseLike` in `responseOf`**: `responseOf()` in both adapters' `errors.ts` checks `typeof status === 'number' && typeof headers?.get === 'function'` instead of `instanceof Response`, because `ctx.http` uses `undici.fetch` whose `Response` is not an instance of global `Response`. Covered by `vendor/plugin-im-adapter-qq/tests/token.spec.ts`.
|
||||
- **V106 · `plugin-im-adapter-qq` and `plugin-im-adapter-lark` match structural `ResponseLike` in `responseOf`**: `responseOf()` in both adapters' `errors.ts` checks `typeof status === 'number' && typeof headers?.get === 'function'` instead of `instanceof Response`, because `ctx.http` uses `undici.fetch` whose `Response` is not an instance of global `Response`. Covered by `vendor/plugin-im-adapter-qq/tests/token.spec.ts` and `vendor/plugin-im-adapter-lark/tests/errors.spec.ts`.
|
||||
- **V107 · `plugin-im-core` and `plugin-im-adapter-lark` forward `AbortSignal` through `editPayload` and bound abort-close**: `Adapter.editPayload`, `EditDriverAdapter.editPayload`, `createEditDriver` (`tick`/`close`), `Bot.applyEdit`, and Lark's `editMessagePayload` forward `signal` to `updateMessage`/`patchMessage`, and `Scheduler.abort()` bounds its best-effort `driver.close` with `AbortSignal.timeout(STREAM_ABORT_CLOSE_TIMEOUT_MS)`. Covered by `vendor/plugin-im-core/tests/stream.spec.ts`.
|
||||
- **V108 · `plugin-im-core` detaches the caller `AbortSignal` listener when a stream settles**: `Scheduler` keeps a reference to its `abort` listener and removes it in `close()`, `fail()`, and `abort()`, preventing settled streams from accumulating on a long-lived `AbortSignal`. Covered by `vendor/plugin-im-core/tests/stream.spec.ts`.
|
||||
|
||||
|
||||
+2
-2
@@ -167,13 +167,13 @@ function retryAfterOf(response: ResponseLike | undefined): number | undefined {
|
||||
return Number.isFinite(value) && value > 0 ? value * SECOND : undefined
|
||||
}
|
||||
|
||||
/** The HTTP answer a transport failure carried, if any. */
|
||||
/** Minimal `Response` shape (including `undici.Response`) read by {@link responseOf} and {@link retryAfterOf}. */
|
||||
interface ResponseLike {
|
||||
readonly status: number
|
||||
readonly headers: { get(name: string): string | null }
|
||||
}
|
||||
|
||||
/** `Response` (including `undici.Response`) attached by `ctx.http` when an error carries an HTTP answer. */
|
||||
/** The HTTP answer a transport failure carried, if any. */
|
||||
function responseOf(error: unknown): ResponseLike | undefined {
|
||||
const response = (error as { response?: unknown } | undefined)?.response
|
||||
if (typeof response !== 'object' || response === null) return undefined
|
||||
|
||||
@@ -165,4 +165,14 @@ describe('Lark error classification', () => {
|
||||
const error = new Http.Error('Unauthorized', 'STATUS_ERROR', new Response(null, { status: 401 }))
|
||||
expect(classify(error).kind).toBe('permission')
|
||||
})
|
||||
|
||||
it('classifies a non-global ResponseLike (undici) response with its status and Retry-After', () => {
|
||||
const classified = classify({
|
||||
response: {
|
||||
status: 429,
|
||||
headers: { get: (name: string) => name.toLowerCase() === 'retry-after' ? '4' : null },
|
||||
},
|
||||
})
|
||||
expect(classified).toMatchObject({ kind: 'rate-limit', published: 'no', retryAfterMs: 4000 })
|
||||
})
|
||||
})
|
||||
+2
-2
@@ -132,13 +132,13 @@ function ruleForStatus(status: number): QqErrorRule {
|
||||
return { kind: 'invalid', message: 'the platform rejected the request' }
|
||||
}
|
||||
|
||||
/** Whether a failure carried an HTTP answer at all. */
|
||||
/** Minimal `Response` shape (including `undici.Response`) read by {@link responseOf} and {@link retryAfterOf}. */
|
||||
interface ResponseLike {
|
||||
readonly status: number
|
||||
readonly headers: { get(name: string): string | null }
|
||||
}
|
||||
|
||||
/** `Response` (including `undici.Response`) attached by `ctx.http` when an error carries an HTTP answer. */
|
||||
/** Whether a failure carried an HTTP answer at all. */
|
||||
function responseOf(error: unknown): ResponseLike | undefined {
|
||||
const response = (error as { response?: unknown } | undefined)?.response
|
||||
if (typeof response !== 'object' || response === null) return undefined
|
||||
|
||||
Reference in new issue
Block a user