@rei-standard/amsg-server 2.6.0-next.32 → 2.6.0-next.34
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/README.md +64 -2
- package/dist/adapters/d1.d.ts +84 -9
- package/dist/adapters/schema.sqlite.d.ts +1 -0
- package/dist/{chunk-KZT3YC62.cjs → chunk-5GRXWKQR.cjs} +1894 -96
- package/dist/{chunk-INNZZFGJ.mjs → chunk-BACG4KJQ.mjs} +1887 -89
- package/dist/cloudflare.cjs +4 -2
- package/dist/cloudflare.d.ts +1 -0
- package/dist/cloudflare.mjs +3 -1
- package/dist/handlers/cloud-data.d.ts +4 -0
- package/dist/index.cjs +27 -25
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +3 -1
- package/dist/lib/agentic-fire.d.ts +43 -1
- package/dist/lib/cloud-data-cleanup.d.ts +36 -0
- package/dist/lib/cloud-data-guard.d.ts +14 -0
- package/dist/lib/cloud-data-inventory.d.ts +15 -0
- package/dist/lib/message-processor.d.ts +9 -1
- package/dist/lib/run-tick.d.ts +6 -2
- package/dist/lib/schema-version.d.ts +1 -1
- package/dist/single-user.d.ts +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -364,6 +364,16 @@ hook 在 `pushPayloads` 里自己写了这几个字段的话会被库覆盖:
|
|
|
364
364
|
|
|
365
365
|
配上 `hooks: { onBeforeFire, onLLMOutput, executeToolCalls }` 之后,AI 类任务的 prompt 不再是排程那一刻冻结的文本,而是 cron 触发时现场组装,工具也在服务端就地跑完,全程不需要客户端在线。完整用法见 [`examples/cloudflare-single-user/README.md`](https://github.com/Tosd0/ReiStandard/blob/main/packages/rei-standard-amsg/server/examples/cloudflare-single-user/README.md) 的「Fire 时刻 hooks」。
|
|
366
366
|
|
|
367
|
+
`onBeforeFire` 的返回值决定这次触发怎么走:
|
|
368
|
+
|
|
369
|
+
| 返回值 | 这次触发怎么走 |
|
|
370
|
+
|---|---|
|
|
371
|
+
| 消息数组,或 `{ messages, maxToolIterations?, totalTimeoutMs?, tools?, toolChoice? }` | 用这份 prompt 生成 |
|
|
372
|
+
| `{ skip: true }` | 这次不发,按零推送的成功收场:一次性任务删掉、循环任务推进到下一次 |
|
|
373
|
+
| `{ defer: { afterMs } }` | 现在不合适,`afterMs` 毫秒后再来问。见下面[推迟这次触发](#推迟这次触发defer) |
|
|
374
|
+
| `null` | 交还给排程时冻结的 prompt |
|
|
375
|
+
| 抛错 | 按投递失败处理:占一次重试、写 `last_error`、2 / 4 / 6 分钟退避 |
|
|
376
|
+
|
|
367
377
|
三个 hook 拿到的 ctx 上都有这几个口子:
|
|
368
378
|
|
|
369
379
|
| ctx 上的口子 | 干什么 |
|
|
@@ -383,6 +393,41 @@ hook 在 `pushPayloads` 里自己写了这几个字段的话会被库覆盖:
|
|
|
383
393
|
|
|
384
394
|
`sessionId` 是给日志和去重用的不透明字符串,格式随版本变,别拆它拿上面这些值。
|
|
385
395
|
|
|
396
|
+
### 推迟这次触发(defer)
|
|
397
|
+
|
|
398
|
+
任务到点了,但宿主这会儿不方便生成——比如同一段对话里正有另一轮回复在生成,想等它结束再说。`onBeforeFire` 返回 `{ defer: { afterMs } }`:
|
|
399
|
+
|
|
400
|
+
```js
|
|
401
|
+
async onBeforeFire(ctx) {
|
|
402
|
+
if (await isConversationBusy(ctx)) return { defer: { afterMs: 30_000 } };
|
|
403
|
+
return buildMessages(ctx);
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
这一次不调 LLM、不推送,也不调 `onLLMOutput` / `onAfterSend`。任务行上只有两处变化:`retry_after` 写成现在 + `afterMs`,租约放掉。到点之后 cron 把它重新捞起来,从 `onBeforeFire` 再走一遍,那时可以继续推迟。
|
|
408
|
+
|
|
409
|
+
跟抛错重试的区别:
|
|
410
|
+
|
|
411
|
+
| | 抛错 | `{ defer }` |
|
|
412
|
+
|---|---|---|
|
|
413
|
+
| `retry_count` | 加一,用完就终审 | 不变 |
|
|
414
|
+
| `last_error` | 写上这次的原因 | 不写,也不清已有的 |
|
|
415
|
+
| 多久之后再来 | 固定 2 / 4 / 6 分钟 | 宿主给的 `afterMs` |
|
|
416
|
+
| `onFireSettled` 的 `status` | `failed` | `deferred`,带 `retryAfter` |
|
|
417
|
+
|
|
418
|
+
两边相同的是 `next_send_at` 都不动:它一直是这次触发的名义时刻,`ctx.task.nextSendAt`、`occurrenceMs`、推送的 `messageId` 在推迟前后都是同一套。循环任务被推迟时不会推进到下一次。
|
|
419
|
+
|
|
420
|
+
几条规矩:
|
|
421
|
+
|
|
422
|
+
- `afterMs` 必须是有限正数,最大 24 小时(导出为 `MAX_DEFER_AFTER_MS`)。不合法的值按 hook 契约违约处理(`AGENTIC_BAD_BEFORE_FIRE`,一跳终审)。没有下限,但 cron 一分钟一跳,实际是「到点之后的第一跳」才会再问;用 `runTask` 自己触发的话,到点之前调它会得到 `retry_pending`。
|
|
423
|
+
- 推迟不会让任务永远挂着。名义时刻过去超过 `staleAfterMs`(默认 60 分钟)的任务照常按过期处理:一次性任务标 `failed`、循环任务快进到下一次,并调 `onStaleSkip`。某次推迟的唤醒时刻已经越过这条线时,库不再等那一轮,当场按过期收场——这时宿主会先收到 `status: 'deferred'` 的 `onFireSettled`,紧接着收到 `onStaleSkip`。
|
|
424
|
+
- 每次被重新问到都是一次新的 fire:`scratch` 是新的,`onFireSettled` 各调各的。
|
|
425
|
+
- 只有定时投递(`runScheduledTick`、单用户 Worker 的 `scheduled()`、`runTask`)支持推迟,并且适配器要实现 `claimTask`(任务表有 `retry_after` 列,内置适配器都有)。`messageType: 'instant'` 在请求里当场投递的任务、以及没实现 `claimTask` 的自定义适配器返回 `{ defer }` 会得到 `AGENTIC_DEFER_UNSUPPORTED`,按[部署配错了算可重试](#部署配错了算可重试)处理。
|
|
426
|
+
- 内容已经落进收件箱、只是推送没发完的重试不调 `onBeforeFire`(见[生成成功之后推送失败:只补推送](#生成成功之后推送失败只补推送)),那一跳也就不会被推迟。
|
|
427
|
+
- 配了 `serializeBy` 时,被推迟的任务不占着分组:同组里排在它后面的任务可以先跑。
|
|
428
|
+
|
|
429
|
+
tick 汇总的 `details.deferredTasks`(`{ taskId, retryAfter }`)列出这一跳被推迟的任务,它们不计入 `successCount` / `failedCount`。`GET /capabilities` 的 features 里有 `before-fire-defer`。
|
|
430
|
+
|
|
386
431
|
### config 级 hook
|
|
387
432
|
|
|
388
433
|
这两个挂在 worker 工厂 config 的顶层(不在 `hooks` 里):
|
|
@@ -390,7 +435,7 @@ hook 在 `pushPayloads` 里自己写了这几个字段的话会被库覆盖:
|
|
|
390
435
|
| hook | 什么时候调 | 载荷 |
|
|
391
436
|
|---|---|---|
|
|
392
437
|
| `onAfterSend` | fire 的 pushPayloads 逐段发完,或中途发挂 | `{ task, sentCount, pushedCount, total, error, usage, usageTotal, llmCalls, outboxed, scratch, readState, writeState, emitResult }` |
|
|
393
|
-
| `onFireSettled` | 一次 fire 收尾——只要 `onBeforeFire` 被调用过,什么结局都调一次 | `{ task, status, skipReason, sentCount, pushedCount, total, iterations, error, metadata, usage, usageTotal, llmCalls, outboxed, scratch, readState, writeState, emitResult }` |
|
|
438
|
+
| `onFireSettled` | 一次 fire 收尾——只要 `onBeforeFire` 被调用过,什么结局都调一次 | `{ task, status, skipReason, retryAfter, sentCount, pushedCount, total, iterations, error, metadata, usage, usageTotal, llmCalls, outboxed, scratch, readState, writeState, emitResult }` |
|
|
394
439
|
| `onStaleSkip` | 任务错过触发时刻超过 60 分钟、这一次(或这几次)不再补发 | `{ reason, action, metadata, recurrenceType, occurrenceMs, skippedCount, skippedOccurrences, skippedTruncated, nextSendAt, readState, writeState, emitResult }` |
|
|
395
440
|
|
|
396
441
|
三个 hook 都自带 `readState` / `writeState` / `emitResult`,作用于当前用户,语义与 fire 级那套一致。`onStaleSkip` 尤其需要:服务停摆恢复后的第一跳里可能一次 fire 都没跑过,而那正是它要留痕迹的时候。
|
|
@@ -405,7 +450,9 @@ hook 在 `pushPayloads` 里自己写了这几个字段的话会被库覆盖:
|
|
|
405
450
|
|---|---|
|
|
406
451
|
| `sent` | pushPayloads 全部发完(`sentCount === total`) |
|
|
407
452
|
| `skipped` | 这次不发。`skipReason` 区分是 `onBeforeFire` 直接 `{ skip: true }`(`'before-fire'`)还是模型跑完后判定不发(`'skip-push'`) |
|
|
453
|
+
| `deferred` | `onBeforeFire` 返回了 `{ defer: { afterMs } }`:这次没生成也没发,任务还在。`retryAfter`(ISO 时刻)之后会从 `onBeforeFire` 重新走一遍;这个字段在其余结局都是 `null` |
|
|
408
454
|
| `failed` | 链路抛错,`error` 带原始错误。发到第 k 段挂了也是这个:`sentCount = k`、`total` 是原本要发的段数 |
|
|
455
|
+
| `cancelled` | 任务在投递期间被取消或顶替,见[取消正在执行的任务](#取消正在执行的生成与工具) |
|
|
409
456
|
| `not-handled` | `onBeforeFire` 返回 `null`,这条任务交还给排程时冻结的 prompt 老链路。那条链路不归 fire hook 管,它后面发没发出去不体现在这里 |
|
|
410
457
|
|
|
411
458
|
**用量记账**看这三个字段,两个 hook 都带,`onFireSettled` 的每种结局(发完、跳过、失败)都带——失败也花了钱:
|
|
@@ -507,7 +554,7 @@ const { messageId, pushed } = await ctx.emitResult({
|
|
|
507
554
|
|
|
508
555
|
### hook 契约违约算确定性失败
|
|
509
556
|
|
|
510
|
-
宿主 hook 返回了库不认的东西(`onBeforeFire` 的返回形状、`onLLMOutput` 的决策标签),或者建后续任务时 `createTask` 没把行交回来——这些错误带 `permanent: true` 和一个稳定的 `code`(`AGENTIC_BAD_BEFORE_FIRE` / `AGENTIC_BAD_DECISION` / `AGENTIC_SCHEDULE_FAILED` / `TASK_PAYLOAD_TOO_LARGE`),投递侧据此跳过退避阶梯:一次性任务直接标 `failed`,循环任务作废本次 occurrence。重试也是同一个结果,而每重试一轮都要把 `onBeforeFire` 和一整轮 LLM 重跑一遍。
|
|
557
|
+
宿主 hook 返回了库不认的东西(`onBeforeFire` 的返回形状、`{ defer }` 里不合法的 `afterMs`、`onLLMOutput` 的决策标签),或者建后续任务时 `createTask` 没把行交回来——这些错误带 `permanent: true` 和一个稳定的 `code`(`AGENTIC_BAD_BEFORE_FIRE` / `AGENTIC_BAD_DECISION` / `AGENTIC_SCHEDULE_FAILED` / `TASK_PAYLOAD_TOO_LARGE`),投递侧据此跳过退避阶梯:一次性任务直接标 `failed`,循环任务作废本次 occurrence。重试也是同一个结果,而每重试一轮都要把 `onBeforeFire` 和一整轮 LLM 重跑一遍。
|
|
511
558
|
|
|
512
559
|
分界线是「谁写错了」:契约由宿主代码定死,重掷一次还是同一个形状;而模型这一轮掷出了什么则是每轮都可能不同的。所以「tool-request 决策里没有能解析的 `toolCalls`」(`AGENTIC_EMPTY_TOOL_REQUEST`)和「轮数用尽也没等到 `finish` / `skip-push`」(`AGENTIC_LOOP_EXCEEDED`)带 `code` 但不带 `permanent`,留在退避阶梯上——隔两分钟重掷一次多半就正常收尾了,判终态的话一次性任务第一次掷歪就永久 `failed`,行离开 `pending` 之后连 `PUT /update-message` 都救不回来(回 409)。
|
|
513
560
|
|
|
@@ -967,3 +1014,18 @@ async function executeToolCalls(calls, ctx) {
|
|
|
967
1014
|
取消收尾使用 `onFireSettled({ status: 'cancelled', willRetry: false, error, ... })`,不是生成失败。应用应在这里释放资源、结算已发生的用量,避免发出失败提示或把未送达内容记为已回复。取消时已经开始写入的 outbox 批次会在写完后检查信号并撤掉未投递部分;已经发到客户端的消息仍由客户端处理。应用需要记录停止的任务身份,拦住迟到推送、补收以及尚未显示的本地内容。已完成的外部副作用无法撤销;不支持 AbortSignal 的工具也需要自己在执行步骤之间检查取消。
|
|
968
1015
|
|
|
969
1016
|
执行阶段的 `ctx.writeState`、`scheduleTask`、`cancelTask`、`renewTask` 和 `emitResult` 会拒绝取消后新发起的操作。`onFireSettled` 的 `info.writeState` 特意仍可用,供宿主释放锁、保存账单等收尾;它不能用于继续生成阶段的业务动作。已经开始的数据库写入不支持回滚,宿主仍需处理并发状态版本。
|
|
1017
|
+
|
|
1018
|
+
### Cloud data inventory and cleanup (D1)
|
|
1019
|
+
|
|
1020
|
+
Single-user D1 deployments expose `cloud-data-management` in `/capabilities`.
|
|
1021
|
+
The management API lists actual cloud resources, including acknowledged outbox
|
|
1022
|
+
rows, orphan state chunks and resources missing a local character. Cleanup uses
|
|
1023
|
+
server previews, persistent operations and cron continuation. Owner retirement
|
|
1024
|
+
fences future writes and in-flight task outputs; restoration is explicit and
|
|
1025
|
+
returns the generation required on subsequent writes.
|
|
1026
|
+
|
|
1027
|
+
See the repository [cloud data management contract](../../../docs/cloud-data-management.md)
|
|
1028
|
+
for routes, encrypted metadata, host `cloudData.resolveOwner` configuration,
|
|
1029
|
+
retention, and upgrade requirements. Other adapters do not advertise this
|
|
1030
|
+
capability. Use the matching client SDK management methods rather than composing
|
|
1031
|
+
bulk deletes from the browser's local resource list.
|
package/dist/adapters/d1.d.ts
CHANGED
|
@@ -49,6 +49,81 @@ export class D1Adapter {
|
|
|
49
49
|
* @returns {Promise<number>} 各批影响行数之和
|
|
50
50
|
*/
|
|
51
51
|
private _runInClauseWrite;
|
|
52
|
+
/** A complete management implementation needs real transactional batches. */
|
|
53
|
+
get cloudDataManagement(): boolean;
|
|
54
|
+
_cloudGuardPredicate(userId: any, guard: any): {
|
|
55
|
+
sql: string;
|
|
56
|
+
args: any[];
|
|
57
|
+
};
|
|
58
|
+
_cloudBatch(statements: any, userId: any, guards?: any[], metadata?: Map<any, any>): Promise<any[]>;
|
|
59
|
+
getCloudResourceMetadata(userId: any, resourceKey: any): Promise<any>;
|
|
60
|
+
listCloudResourceRows(userId: any): Promise<{
|
|
61
|
+
gaps: any[];
|
|
62
|
+
}>;
|
|
63
|
+
_cloudRecord(row: any): Promise<{
|
|
64
|
+
id: any;
|
|
65
|
+
userId: any;
|
|
66
|
+
kind: any;
|
|
67
|
+
data: any;
|
|
68
|
+
updatedAt: any;
|
|
69
|
+
}>;
|
|
70
|
+
putCloudDataRecord(userId: any, kind: any, id: any, data: any, { idempotencyKey, createOnly, leaseToken }?: {
|
|
71
|
+
idempotencyKey?: any;
|
|
72
|
+
createOnly?: boolean;
|
|
73
|
+
}): Promise<{
|
|
74
|
+
id: any;
|
|
75
|
+
userId: any;
|
|
76
|
+
kind: any;
|
|
77
|
+
data: any;
|
|
78
|
+
updatedAt: any;
|
|
79
|
+
}>;
|
|
80
|
+
getCloudDataRecord(userId: any, kind: any, id: any): Promise<{
|
|
81
|
+
id: any;
|
|
82
|
+
userId: any;
|
|
83
|
+
kind: any;
|
|
84
|
+
data: any;
|
|
85
|
+
updatedAt: any;
|
|
86
|
+
}>;
|
|
87
|
+
getCloudDataRecordByIdempotency(userId: any, kind: any, idempotencyKey: any): Promise<{
|
|
88
|
+
id: any;
|
|
89
|
+
userId: any;
|
|
90
|
+
kind: any;
|
|
91
|
+
data: any;
|
|
92
|
+
updatedAt: any;
|
|
93
|
+
}>;
|
|
94
|
+
_cloudRecordForList(row: any): Promise<{
|
|
95
|
+
id: any;
|
|
96
|
+
userId: any;
|
|
97
|
+
kind: any;
|
|
98
|
+
data: any;
|
|
99
|
+
updatedAt: any;
|
|
100
|
+
}>;
|
|
101
|
+
listCloudDataRecords(userId: any, kind: any): Promise<any[]>;
|
|
102
|
+
listCloudDataRecordsAcrossUsers(kind: any): Promise<any[]>;
|
|
103
|
+
claimCloudDataRecord(userId: any, kind: any, id: any, leaseMs: any, leaseToken?: any): Promise<boolean>;
|
|
104
|
+
releaseCloudDataRecord(userId: any, kind: any, id: any, leaseToken: any): Promise<void>;
|
|
105
|
+
renewCloudDataRecordLease(userId: any, kind: any, id: any, leaseMs: any, leaseToken: any): Promise<boolean>;
|
|
106
|
+
deleteCloudDataRecord(userId: any, kind: any, id: any): Promise<boolean>;
|
|
107
|
+
cleanupCloudDataRecords(kind: any, beforeMs: any): Promise<any>;
|
|
108
|
+
/** Sidecars are indexes only. Remove them only while their backing row is absent. */
|
|
109
|
+
cleanupCloudResourceMetadata(userId?: any): Promise<any>;
|
|
110
|
+
listCloudOwners(userId: any): Promise<any>;
|
|
111
|
+
getCloudOwner(userId: any, owner: any): Promise<{
|
|
112
|
+
active: boolean;
|
|
113
|
+
generation: any;
|
|
114
|
+
updatedAt: any;
|
|
115
|
+
}>;
|
|
116
|
+
setCloudOwnerActive(userId: any, owner: any, active: any, expectedGeneration: any): Promise<{
|
|
117
|
+
active: boolean;
|
|
118
|
+
generation: any;
|
|
119
|
+
updatedAt: any;
|
|
120
|
+
}>;
|
|
121
|
+
isCloudOwnerGuardValid(userId: any, guard: any): Promise<boolean>;
|
|
122
|
+
/** Delete only the exact physical snapshot; no untrusted SQL identifiers. */
|
|
123
|
+
deleteCloudResourceRows(userId: any, locators: any, { operationId, leaseToken }?: {}): Promise<{
|
|
124
|
+
deleted: number;
|
|
125
|
+
changed: number;
|
|
126
|
+
}>;
|
|
52
127
|
initSchema(): Promise<{
|
|
53
128
|
columnsCreated: number;
|
|
54
129
|
indexesCreated: number;
|
|
@@ -83,7 +158,7 @@ export class D1Adapter {
|
|
|
83
158
|
indexes: string[];
|
|
84
159
|
}>;
|
|
85
160
|
dropSchema(): Promise<void>;
|
|
86
|
-
createTask(params: any): Promise<any>;
|
|
161
|
+
createTask(params: any, cloudGuard?: any): Promise<any>;
|
|
87
162
|
/**
|
|
88
163
|
* 建新任务的同时取消旧的那条(`POST /schedule-message` 的 supersedesUuid)。
|
|
89
164
|
*
|
|
@@ -96,7 +171,7 @@ export class D1Adapter {
|
|
|
96
171
|
* @returns {Promise<Object>} createTask 的返回行 + `superseded`(旧行是否
|
|
97
172
|
* 真的被删掉;false = 旧行本就不存在)
|
|
98
173
|
*/
|
|
99
|
-
createTaskSuperseding(params: import("./interface.js").InsertTaskParams, supersedesUuid: string): Promise<any>;
|
|
174
|
+
createTaskSuperseding(params: import("./interface.js").InsertTaskParams, supersedesUuid: string, cloudGuard?: any): Promise<any>;
|
|
100
175
|
getTaskByUuid(uuid: any, userId: any): Promise<any>;
|
|
101
176
|
getTaskByUuidOnly(uuid: any): Promise<any>;
|
|
102
177
|
/**
|
|
@@ -109,7 +184,7 @@ export class D1Adapter {
|
|
|
109
184
|
getTaskStatusByUuidOnly(uuid: string): Promise<{
|
|
110
185
|
status: string;
|
|
111
186
|
} | null>;
|
|
112
|
-
updateTaskById(taskId: any, updates: any): Promise<any>;
|
|
187
|
+
updateTaskById(taskId: any, updates: any, cloudGuard?: any): Promise<any>;
|
|
113
188
|
/**
|
|
114
189
|
* 按 uuid 改一条 pending 任务(PUT /update-message、fire hook 的 renewTask)。
|
|
115
190
|
*
|
|
@@ -119,7 +194,7 @@ export class D1Adapter {
|
|
|
119
194
|
* ——用户以为改期生效了,实际什么都没留下。正文这类字段不受这道门约束:它们
|
|
120
195
|
* 只影响以后的触发,收尾那边本来就不会覆盖(见 run-tick 的收尾守卫)。
|
|
121
196
|
*/
|
|
122
|
-
updateTaskByUuid(uuid: any, userId: any, encryptedPayload: any, extraFields: any): Promise<{
|
|
197
|
+
updateTaskByUuid(uuid: any, userId: any, encryptedPayload: any, extraFields: any, cloudGuard?: any): Promise<{
|
|
123
198
|
uuid: any;
|
|
124
199
|
updated_at: string;
|
|
125
200
|
}>;
|
|
@@ -160,7 +235,7 @@ export class D1Adapter {
|
|
|
160
235
|
* @returns {Promise<boolean>} true = 领到了;false = 别人正拿着租约、同分组
|
|
161
236
|
* 有任务正在跑、排期被改过、或行已不是 pending
|
|
162
237
|
*/
|
|
163
|
-
claimTask(taskId: number, expectedNextSendAt: string, leaseUntil: string | Date, serializeGroup?: string | null): Promise<boolean>;
|
|
238
|
+
claimTask(taskId: number, expectedNextSendAt: string, leaseUntil: string | Date, serializeGroup?: string | null, cloudGuard?: any): Promise<boolean>;
|
|
164
239
|
/**
|
|
165
240
|
* 投递期间的租约续期(run-tick 的心跳用)。只在行仍是 pending 且确实持有
|
|
166
241
|
* 租约(lease_until 非空)时生效——收尾把租约放掉之后,迟到的心跳不会把
|
|
@@ -170,7 +245,7 @@ export class D1Adapter {
|
|
|
170
245
|
* @param {string|Date} leaseUntil - 新的租期末尾
|
|
171
246
|
* @returns {Promise<boolean>} true = 续上了
|
|
172
247
|
*/
|
|
173
|
-
renewTaskLease(taskId: number, leaseUntil: string | Date): Promise<boolean>;
|
|
248
|
+
renewTaskLease(taskId: number, leaseUntil: string | Date, cloudGuard?: any): Promise<boolean>;
|
|
174
249
|
listTasks(userId: any, opts?: {}): Promise<{
|
|
175
250
|
tasks: any;
|
|
176
251
|
total: number;
|
|
@@ -241,7 +316,7 @@ export class D1Adapter {
|
|
|
241
316
|
key?: string;
|
|
242
317
|
keyPrefix?: string;
|
|
243
318
|
updatedAt: number;
|
|
244
|
-
}>, now?: number): Promise<{
|
|
319
|
+
}>, now?: number, cloudGuard?: any): Promise<{
|
|
245
320
|
upserted: number;
|
|
246
321
|
skipped: number;
|
|
247
322
|
outcomes: boolean[];
|
|
@@ -377,7 +452,7 @@ export class D1Adapter {
|
|
|
377
452
|
upsertLlmCredentials(userId: string, entries: Array<{
|
|
378
453
|
credId: string;
|
|
379
454
|
encryptedValue: string;
|
|
380
|
-
}
|
|
455
|
+
}>, cloudGuard?: any): Promise<number>;
|
|
381
456
|
/**
|
|
382
457
|
* 按 cred_id 批量读这个用户的凭据行(`encrypted_value` 是密文,解密在上
|
|
383
458
|
* 层)。排程时的存在性检查和 fire 时的解析共用这一个口。
|
|
@@ -456,7 +531,7 @@ export class D1Adapter {
|
|
|
456
531
|
total_messages?: number | null;
|
|
457
532
|
payload: string;
|
|
458
533
|
created_at: number;
|
|
459
|
-
}
|
|
534
|
+
}>, cloudGuard?: any): Promise<number>;
|
|
460
535
|
/**
|
|
461
536
|
* 把这一批标记为「Web Push 已发出」。发送失败的段不标——delivered_at 为
|
|
462
537
|
* null 的行正是客户端最需要拉的那部分。
|