@dudousxd/nestjs-agent 1.15.0 → 1.16.1
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 +2 -0
- package/dist/durable/index.cjs +114 -21
- package/dist/durable/index.cjs.map +1 -1
- package/dist/durable/index.d.cts +2 -0
- package/dist/durable/index.d.ts +2 -0
- package/dist/durable/index.js +108 -15
- package/dist/durable/index.js.map +1 -1
- package/dist/index.cjs +72 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -158,6 +158,21 @@ declare class AgentService {
|
|
|
158
158
|
}): Promise<ChatQueueState>;
|
|
159
159
|
/** `DELETE <base>/queue/:messageId` — drop a waiting message. Answers the thread's queue. */
|
|
160
160
|
removeQueuedMessage(actor: Actor, messageId: string): Promise<ChatQueueState>;
|
|
161
|
+
/**
|
|
162
|
+
* `POST <base>/queue/:messageId/interrupt` — run a message that is already waiting NOW: it moves
|
|
163
|
+
* to the head of its queue marked as an interrupt, any pause is lifted, and the running turn is
|
|
164
|
+
* cancelled (its settle starts this message — the same path a `mode: 'interrupt'` send takes).
|
|
165
|
+
* With nothing running, the message starts at once.
|
|
166
|
+
*
|
|
167
|
+
* One request, and the message never leaves the queue: a client that removed it and sent it again
|
|
168
|
+
* would lose it if the second call failed, and would run it twice if another tab's drain started
|
|
169
|
+
* it in between. Answers the queue, plus `interrupting` (the run that was cancelled) or `runId`
|
|
170
|
+
* (the run this message started).
|
|
171
|
+
*/
|
|
172
|
+
interruptQueuedMessage(actor: Actor, messageId: string): Promise<ChatQueueState & {
|
|
173
|
+
runId?: string;
|
|
174
|
+
interrupting?: string;
|
|
175
|
+
}>;
|
|
161
176
|
/** `DELETE <base>/threads/:id/queue` — drop every waiting message (and any pause). */
|
|
162
177
|
clearQueue(actor: Actor, threadId: string): Promise<ChatQueueState>;
|
|
163
178
|
/**
|
|
@@ -1051,6 +1066,15 @@ declare class QueueController {
|
|
|
1051
1066
|
runId?: string;
|
|
1052
1067
|
}>;
|
|
1053
1068
|
update(req: Request, messageId: string, body: UpdateQueuedMessageBody): Promise<ChatQueueState>;
|
|
1069
|
+
/**
|
|
1070
|
+
* Run a waiting message now: it moves to the head as an interrupt and the running turn is
|
|
1071
|
+
* cancelled for it. Carries `interrupting` (the cancelled run), or `runId` when nothing was
|
|
1072
|
+
* running and it started at once.
|
|
1073
|
+
*/
|
|
1074
|
+
interrupt(req: Request, messageId: string): Promise<ChatQueueState & {
|
|
1075
|
+
runId?: string;
|
|
1076
|
+
interrupting?: string;
|
|
1077
|
+
}>;
|
|
1054
1078
|
remove(req: Request, messageId: string): Promise<ChatQueueState>;
|
|
1055
1079
|
}
|
|
1056
1080
|
|
package/dist/index.d.ts
CHANGED
|
@@ -158,6 +158,21 @@ declare class AgentService {
|
|
|
158
158
|
}): Promise<ChatQueueState>;
|
|
159
159
|
/** `DELETE <base>/queue/:messageId` — drop a waiting message. Answers the thread's queue. */
|
|
160
160
|
removeQueuedMessage(actor: Actor, messageId: string): Promise<ChatQueueState>;
|
|
161
|
+
/**
|
|
162
|
+
* `POST <base>/queue/:messageId/interrupt` — run a message that is already waiting NOW: it moves
|
|
163
|
+
* to the head of its queue marked as an interrupt, any pause is lifted, and the running turn is
|
|
164
|
+
* cancelled (its settle starts this message — the same path a `mode: 'interrupt'` send takes).
|
|
165
|
+
* With nothing running, the message starts at once.
|
|
166
|
+
*
|
|
167
|
+
* One request, and the message never leaves the queue: a client that removed it and sent it again
|
|
168
|
+
* would lose it if the second call failed, and would run it twice if another tab's drain started
|
|
169
|
+
* it in between. Answers the queue, plus `interrupting` (the run that was cancelled) or `runId`
|
|
170
|
+
* (the run this message started).
|
|
171
|
+
*/
|
|
172
|
+
interruptQueuedMessage(actor: Actor, messageId: string): Promise<ChatQueueState & {
|
|
173
|
+
runId?: string;
|
|
174
|
+
interrupting?: string;
|
|
175
|
+
}>;
|
|
161
176
|
/** `DELETE <base>/threads/:id/queue` — drop every waiting message (and any pause). */
|
|
162
177
|
clearQueue(actor: Actor, threadId: string): Promise<ChatQueueState>;
|
|
163
178
|
/**
|
|
@@ -1051,6 +1066,15 @@ declare class QueueController {
|
|
|
1051
1066
|
runId?: string;
|
|
1052
1067
|
}>;
|
|
1053
1068
|
update(req: Request, messageId: string, body: UpdateQueuedMessageBody): Promise<ChatQueueState>;
|
|
1069
|
+
/**
|
|
1070
|
+
* Run a waiting message now: it moves to the head as an interrupt and the running turn is
|
|
1071
|
+
* cancelled for it. Carries `interrupting` (the cancelled run), or `runId` when nothing was
|
|
1072
|
+
* running and it started at once.
|
|
1073
|
+
*/
|
|
1074
|
+
interrupt(req: Request, messageId: string): Promise<ChatQueueState & {
|
|
1075
|
+
runId?: string;
|
|
1076
|
+
interrupting?: string;
|
|
1077
|
+
}>;
|
|
1054
1078
|
remove(req: Request, messageId: string): Promise<ChatQueueState>;
|
|
1055
1079
|
}
|
|
1056
1080
|
|
package/dist/index.js
CHANGED
|
@@ -1112,6 +1112,59 @@ var AgentService = class {
|
|
|
1112
1112
|
}
|
|
1113
1113
|
return queue.publish(threadId);
|
|
1114
1114
|
}
|
|
1115
|
+
/**
|
|
1116
|
+
* `POST <base>/queue/:messageId/interrupt` — run a message that is already waiting NOW: it moves
|
|
1117
|
+
* to the head of its queue marked as an interrupt, any pause is lifted, and the running turn is
|
|
1118
|
+
* cancelled (its settle starts this message — the same path a `mode: 'interrupt'` send takes).
|
|
1119
|
+
* With nothing running, the message starts at once.
|
|
1120
|
+
*
|
|
1121
|
+
* One request, and the message never leaves the queue: a client that removed it and sent it again
|
|
1122
|
+
* would lose it if the second call failed, and would run it twice if another tab's drain started
|
|
1123
|
+
* it in between. Answers the queue, plus `interrupting` (the run that was cancelled) or `runId`
|
|
1124
|
+
* (the run this message started).
|
|
1125
|
+
*/
|
|
1126
|
+
async interruptQueuedMessage(actor, messageId) {
|
|
1127
|
+
const queue = this.requireQueue();
|
|
1128
|
+
const store = queue.queueStore();
|
|
1129
|
+
const threadId = await this.assertOwnsQueuedMessage(actor, messageId);
|
|
1130
|
+
const gone = /* @__PURE__ */ __name(() => new GoneException(`queued message ${messageId} already started or was removed`), "gone");
|
|
1131
|
+
const marked = await store.updateQueuedMessage(messageId, {
|
|
1132
|
+
interrupt: true
|
|
1133
|
+
});
|
|
1134
|
+
if (marked === null) {
|
|
1135
|
+
throw gone();
|
|
1136
|
+
}
|
|
1137
|
+
if (marked.interrupt !== true) {
|
|
1138
|
+
throw new NotImplementedException2("Interrupting a queued message requires a ChatQueueStore whose updateQueuedMessage stores `interrupt`; the bound store ignored it.");
|
|
1139
|
+
}
|
|
1140
|
+
if (!await store.moveQueuedMessage(messageId, 0)) {
|
|
1141
|
+
throw gone();
|
|
1142
|
+
}
|
|
1143
|
+
await store.setQueuePause(threadId, null);
|
|
1144
|
+
const { live } = await queue.holder(threadId, this.runner);
|
|
1145
|
+
if (live !== null && live !== messageId && await store.getQueuedMessage(messageId) !== null) {
|
|
1146
|
+
const state2 = await queue.publish(threadId);
|
|
1147
|
+
await this.runner.cancel(live);
|
|
1148
|
+
return {
|
|
1149
|
+
...state2,
|
|
1150
|
+
interrupting: live
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
if (live !== null) {
|
|
1154
|
+
return {
|
|
1155
|
+
...await queue.state(threadId),
|
|
1156
|
+
runId: messageId
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
const runId = await queue.kick(threadId, this.runner);
|
|
1160
|
+
const state = runId === void 0 ? await queue.publish(threadId) : await queue.state(threadId);
|
|
1161
|
+
return {
|
|
1162
|
+
...state,
|
|
1163
|
+
...runId !== void 0 ? {
|
|
1164
|
+
runId
|
|
1165
|
+
} : {}
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1115
1168
|
/** `DELETE <base>/threads/:id/queue` — drop every waiting message (and any pause). */
|
|
1116
1169
|
async clearQueue(actor, threadId) {
|
|
1117
1170
|
await this.assertOwnsThread(actor, threadId);
|
|
@@ -2754,6 +2807,14 @@ var QueueController = class {
|
|
|
2754
2807
|
} : {}
|
|
2755
2808
|
});
|
|
2756
2809
|
}
|
|
2810
|
+
/**
|
|
2811
|
+
* Run a waiting message now: it moves to the head as an interrupt and the running turn is
|
|
2812
|
+
* cancelled for it. Carries `interrupting` (the cancelled run), or `runId` when nothing was
|
|
2813
|
+
* running and it started at once.
|
|
2814
|
+
*/
|
|
2815
|
+
async interrupt(req, messageId) {
|
|
2816
|
+
return this.agent.interruptQueuedMessage(await this.actorResolver.resolve(req), messageId);
|
|
2817
|
+
}
|
|
2757
2818
|
async remove(req, messageId) {
|
|
2758
2819
|
return this.agent.removeQueuedMessage(await this.actorResolver.resolve(req), messageId);
|
|
2759
2820
|
}
|
|
@@ -2804,6 +2865,17 @@ _ts_decorate12([
|
|
|
2804
2865
|
]),
|
|
2805
2866
|
_ts_metadata12("design:returntype", Promise)
|
|
2806
2867
|
], QueueController.prototype, "update", null);
|
|
2868
|
+
_ts_decorate12([
|
|
2869
|
+
Post4("queue/:messageId/interrupt"),
|
|
2870
|
+
_ts_param11(0, Req7()),
|
|
2871
|
+
_ts_param11(1, Param4("messageId")),
|
|
2872
|
+
_ts_metadata12("design:type", Function),
|
|
2873
|
+
_ts_metadata12("design:paramtypes", [
|
|
2874
|
+
typeof Request === "undefined" ? Object : Request,
|
|
2875
|
+
String
|
|
2876
|
+
]),
|
|
2877
|
+
_ts_metadata12("design:returntype", Promise)
|
|
2878
|
+
], QueueController.prototype, "interrupt", null);
|
|
2807
2879
|
_ts_decorate12([
|
|
2808
2880
|
Delete2("queue/:messageId"),
|
|
2809
2881
|
_ts_param11(0, Req7()),
|