@ycodium-ai/plugin-im 0.2.3016 → 0.2.3020
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/dist/index.js +75 -23
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -127224,6 +127224,9 @@ var makeChatQueue = (core) => {
|
|
|
127224
127224
|
return { enqueueForChat };
|
|
127225
127225
|
};
|
|
127226
127226
|
|
|
127227
|
+
// src/chatSetup.ts
|
|
127228
|
+
import { threadOrNull } from "@ycodium-ai/plugin-api";
|
|
127229
|
+
|
|
127227
127230
|
// src/projectList.ts
|
|
127228
127231
|
var PROJECT_LIST_MAX = 20;
|
|
127229
127232
|
var projectLine = (row, position) => `${String(position)}. ${row.title.replace(/\s+/g, " ").trim()}${row.current ? " \u2605" : ""}`;
|
|
@@ -127365,7 +127368,7 @@ var makeChatSetup = (core, deps) => {
|
|
|
127365
127368
|
}
|
|
127366
127369
|
const threadId = chatOf(core.state, chatKey).threadId;
|
|
127367
127370
|
if (threadId !== null) {
|
|
127368
|
-
const thread = await host.
|
|
127371
|
+
const thread = await threadOrNull(host.threads, threadId).catch(() => null);
|
|
127369
127372
|
if (isSessionRunning(thread?.session?.status)) {
|
|
127370
127373
|
await deliver(binding, t("repo.busy"));
|
|
127371
127374
|
return;
|
|
@@ -127410,6 +127413,9 @@ var makeChatSetup = (core, deps) => {
|
|
|
127410
127413
|
return { promptProject, handleRepo, handleGroup };
|
|
127411
127414
|
};
|
|
127412
127415
|
|
|
127416
|
+
// src/commands.ts
|
|
127417
|
+
import { threadOrNull as threadOrNull2 } from "@ycodium-ai/plugin-api";
|
|
127418
|
+
|
|
127413
127419
|
// src/chatCommand.ts
|
|
127414
127420
|
var teamArgument = (text3, chinese) => {
|
|
127415
127421
|
const match = text3.match(/^\/team(?:\s+([\s\S]*))?$/i);
|
|
@@ -127720,7 +127726,7 @@ var makeCommands = (core, deps) => {
|
|
|
127720
127726
|
);
|
|
127721
127727
|
return true;
|
|
127722
127728
|
}
|
|
127723
|
-
const thread = await host.
|
|
127729
|
+
const thread = await threadOrNull2(host.threads, threadId);
|
|
127724
127730
|
const running = isSessionRunning(thread?.session?.status);
|
|
127725
127731
|
await deliver(
|
|
127726
127732
|
binding,
|
|
@@ -127772,7 +127778,7 @@ var makeCommands = (core, deps) => {
|
|
|
127772
127778
|
await deliver(binding, t("command.stopNoSession"));
|
|
127773
127779
|
return true;
|
|
127774
127780
|
}
|
|
127775
|
-
const thread = await host.
|
|
127781
|
+
const thread = await threadOrNull2(host.threads, threadId);
|
|
127776
127782
|
const activeTurnId = thread?.session?.activeTurnId ?? null;
|
|
127777
127783
|
if (activeTurnId === null) {
|
|
127778
127784
|
await deliver(binding, t("command.stopNoTurn"));
|
|
@@ -139036,13 +139042,14 @@ var makeLiveTranslate = (initial) => {
|
|
|
139036
139042
|
};
|
|
139037
139043
|
|
|
139038
139044
|
// src/modelPlan.ts
|
|
139045
|
+
import { threadOrNull as threadOrNull3 } from "@ycodium-ai/plugin-api";
|
|
139039
139046
|
var makeModelPlan = (core, deps) => {
|
|
139040
139047
|
const { host, t, commit, deliver } = core;
|
|
139041
139048
|
const { threadStillUsable } = deps;
|
|
139042
139049
|
const currentModelOf = async (binding) => {
|
|
139043
139050
|
const chat = chatOf(core.state, chatKeyOf(binding));
|
|
139044
139051
|
if (chat.threadId !== null) {
|
|
139045
|
-
const thread = await host.
|
|
139052
|
+
const thread = await threadOrNull3(host.threads, chat.threadId).catch(() => null);
|
|
139046
139053
|
if (thread !== null) {
|
|
139047
139054
|
return {
|
|
139048
139055
|
instanceId: thread.modelSelection.instanceId,
|
|
@@ -139111,6 +139118,9 @@ var makeModelPlan = (core, deps) => {
|
|
|
139111
139118
|
return { currentModelOf, handleModel, handlePlan };
|
|
139112
139119
|
};
|
|
139113
139120
|
|
|
139121
|
+
// src/notifications.ts
|
|
139122
|
+
import { threadOrNull as threadOrNull4 } from "@ycodium-ai/plugin-api";
|
|
139123
|
+
|
|
139114
139124
|
// src/notificationTargets.ts
|
|
139115
139125
|
var notificationChatKeys = (state, threadId, projectId) => {
|
|
139116
139126
|
const owner = chatOfThread(state, threadId);
|
|
@@ -139118,6 +139128,40 @@ var notificationChatKeys = (state, threadId, projectId) => {
|
|
|
139118
139128
|
return projectId === null ? [] : chatsOnProject(state, projectId);
|
|
139119
139129
|
};
|
|
139120
139130
|
|
|
139131
|
+
// src/threadMessages.ts
|
|
139132
|
+
import {
|
|
139133
|
+
isThreadNotFound
|
|
139134
|
+
} from "@ycodium-ai/plugin-api";
|
|
139135
|
+
var PAGE_SIZE = 20;
|
|
139136
|
+
async function* newestFirst(threads, threadId) {
|
|
139137
|
+
let cursor = null;
|
|
139138
|
+
do {
|
|
139139
|
+
let page;
|
|
139140
|
+
try {
|
|
139141
|
+
page = await threads.messages.list({ threadId, limit: PAGE_SIZE, cursor });
|
|
139142
|
+
} catch (error) {
|
|
139143
|
+
if (isThreadNotFound(error)) return;
|
|
139144
|
+
throw error;
|
|
139145
|
+
}
|
|
139146
|
+
yield* page.items;
|
|
139147
|
+
cursor = page.nextCursor;
|
|
139148
|
+
} while (cursor !== null);
|
|
139149
|
+
}
|
|
139150
|
+
async function latestMessage(threads, threadId, accept) {
|
|
139151
|
+
for await (const message of newestFirst(threads, threadId)) {
|
|
139152
|
+
if (accept(message)) return message;
|
|
139153
|
+
}
|
|
139154
|
+
return void 0;
|
|
139155
|
+
}
|
|
139156
|
+
async function messagesAfterLastUser(threads, threadId) {
|
|
139157
|
+
const after = [];
|
|
139158
|
+
for await (const message of newestFirst(threads, threadId)) {
|
|
139159
|
+
if (message.role === "user") break;
|
|
139160
|
+
after.push(message);
|
|
139161
|
+
}
|
|
139162
|
+
return after.toReversed();
|
|
139163
|
+
}
|
|
139164
|
+
|
|
139121
139165
|
// src/turnOutcome.ts
|
|
139122
139166
|
var outcomeOfSession = (status) => {
|
|
139123
139167
|
if (status === "error") return "failed";
|
|
@@ -139137,7 +139181,7 @@ var makeNotifications = (core, deps) => {
|
|
|
139137
139181
|
const projectOfThread = async (threadId) => {
|
|
139138
139182
|
const known = projectByThread.get(threadId);
|
|
139139
139183
|
if (known !== void 0) return known;
|
|
139140
|
-
const thread = await host.
|
|
139184
|
+
const thread = await threadOrNull4(host.threads, threadId);
|
|
139141
139185
|
if (thread === null) return null;
|
|
139142
139186
|
if (projectByThread.size >= THREAD_PROJECT_CACHE_LIMIT) {
|
|
139143
139187
|
const oldest = projectByThread.keys().next().value;
|
|
@@ -139175,8 +139219,12 @@ var makeNotifications = (core, deps) => {
|
|
|
139175
139219
|
const targets = targetsForProject(threadId, await projectOfThread(threadId));
|
|
139176
139220
|
const reporters = said ? targets : [];
|
|
139177
139221
|
if (reporters.length > 0) {
|
|
139178
|
-
const thread = await host.
|
|
139179
|
-
const final = thread
|
|
139222
|
+
const thread = await threadOrNull4(host.threads, threadId);
|
|
139223
|
+
const final = thread === null ? void 0 : await latestMessage(
|
|
139224
|
+
host.threads,
|
|
139225
|
+
threadId,
|
|
139226
|
+
(message) => message.role === "assistant" && message.text.trim() !== ""
|
|
139227
|
+
);
|
|
139180
139228
|
if (thread !== null && final !== void 0) {
|
|
139181
139229
|
for (const binding of reporters) {
|
|
139182
139230
|
const text3 = streamsTo(binding, threadId) ? "" : `${thread.title}
|
|
@@ -139207,7 +139255,7 @@ ${final.text}`;
|
|
|
139207
139255
|
const drawingTurn = turnCards.drawingTurn(threadId);
|
|
139208
139256
|
const notice = textTargets.length > 0 || drawingTurn !== null ? failures.forFailure(
|
|
139209
139257
|
threadId,
|
|
139210
|
-
(await host.
|
|
139258
|
+
(await threadOrNull4(host.threads, threadId).catch(() => null))?.session?.lastError
|
|
139211
139259
|
) : null;
|
|
139212
139260
|
if (notice !== null && drawingTurn !== null)
|
|
139213
139261
|
failures.holdForCard(threadId, drawingTurn, notice);
|
|
@@ -139858,6 +139906,7 @@ var makeFailureNotices = (core) => {
|
|
|
139858
139906
|
// src/replyCards.ts
|
|
139859
139907
|
import {
|
|
139860
139908
|
readTurnProgress,
|
|
139909
|
+
threadOrNull as threadOrNull5,
|
|
139861
139910
|
TURN_PROGRESS_TRIGGER_KIND
|
|
139862
139911
|
} from "@ycodium-ai/plugin-api";
|
|
139863
139912
|
|
|
@@ -140166,15 +140215,18 @@ var makeReplyCards = (core, failures, anchors) => {
|
|
|
140166
140215
|
},
|
|
140167
140216
|
readText: async (messageId) => (await host.projections.getThreadMessage(messageId))?.text ?? null,
|
|
140168
140217
|
titleOf: async (threadId) => {
|
|
140169
|
-
const
|
|
140170
|
-
|
|
140218
|
+
const asked = await latestMessage(
|
|
140219
|
+
host.threads,
|
|
140220
|
+
threadId,
|
|
140171
140221
|
(message) => message.role === "user" && message.text.trim() !== ""
|
|
140172
|
-
);
|
|
140173
|
-
|
|
140222
|
+
).catch(() => void 0);
|
|
140223
|
+
if (asked !== void 0) return turnTitleOf(asked.text);
|
|
140224
|
+
const thread = await threadOrNull5(host.threads, threadId).catch(() => null);
|
|
140225
|
+
return turnTitleOf(thread?.title ?? "");
|
|
140174
140226
|
},
|
|
140175
140227
|
endOf: async (threadId, turnId) => {
|
|
140176
140228
|
const stopped = stopRequested.delete(threadId);
|
|
140177
|
-
const thread = await host.
|
|
140229
|
+
const thread = await threadOrNull5(host.threads, threadId).catch(() => null);
|
|
140178
140230
|
const session = thread?.session;
|
|
140179
140231
|
const outcome = outcomeOfSession(session?.status);
|
|
140180
140232
|
const errorText2 = failures.forCard(
|
|
@@ -140217,14 +140269,13 @@ var makeReplyCards = (core, failures, anchors) => {
|
|
|
140217
140269
|
const cards = binding === void 0 ? void 0 : adapterFor(binding.platform)?.turnCards;
|
|
140218
140270
|
if (binding !== void 0 && cards !== void 0) {
|
|
140219
140271
|
try {
|
|
140220
|
-
const
|
|
140272
|
+
const messages = await messagesAfterLastUser(host.threads, record2.threadId).catch(
|
|
140273
|
+
() => []
|
|
140274
|
+
);
|
|
140221
140275
|
await cards.update(
|
|
140222
140276
|
binding,
|
|
140223
140277
|
cardId,
|
|
140224
|
-
interruptedView({
|
|
140225
|
-
title: record2.title,
|
|
140226
|
-
body: trailingReply(thread?.messages ?? [])
|
|
140227
|
-
})
|
|
140278
|
+
interruptedView({ title: record2.title, body: trailingReply(messages) })
|
|
140228
140279
|
);
|
|
140229
140280
|
} catch (error) {
|
|
140230
140281
|
host.log.warn("chat could not mark a stale card as interrupted", {
|
|
@@ -140414,9 +140465,10 @@ var makeSendFileTool = (deps) => ({
|
|
|
140414
140465
|
});
|
|
140415
140466
|
|
|
140416
140467
|
// src/sessions.ts
|
|
140468
|
+
import { threadOrNull as threadOrNull6 } from "@ycodium-ai/plugin-api";
|
|
140417
140469
|
var WEB_LIST_PAGE = 100;
|
|
140418
140470
|
var shellOf = (thread) => ({
|
|
140419
|
-
threadId: thread.
|
|
140471
|
+
threadId: thread.id,
|
|
140420
140472
|
title: thread.title,
|
|
140421
140473
|
updatedAt: thread.updatedAt,
|
|
140422
140474
|
archivedAt: thread.archivedAt,
|
|
@@ -140474,7 +140526,7 @@ var makeSessions = (core) => {
|
|
|
140474
140526
|
});
|
|
140475
140527
|
};
|
|
140476
140528
|
const rowForThread = async (binding, chatKey, threadId) => {
|
|
140477
|
-
const thread = await host.
|
|
140529
|
+
const thread = await threadOrNull6(host.threads, threadId, { archived: "include" });
|
|
140478
140530
|
if (thread === null || thread.projectId !== binding.projectId) return null;
|
|
140479
140531
|
return rowFromThread(shellOf(thread), chatKey, originOf(threadId, binding.projectId));
|
|
140480
140532
|
};
|
|
@@ -141517,7 +141569,7 @@ ${line}`
|
|
|
141517
141569
|
};
|
|
141518
141570
|
|
|
141519
141571
|
// src/turns.ts
|
|
141520
|
-
import { projectOrNull as projectOrNull2 } from "@ycodium-ai/plugin-api";
|
|
141572
|
+
import { projectOrNull as projectOrNull2, threadOrNull as threadOrNull7 } from "@ycodium-ai/plugin-api";
|
|
141521
141573
|
var TITLE_MAX_CHARS = 72;
|
|
141522
141574
|
var titleFrom = (text3) => text3.replace(/\s+/g, " ").slice(0, TITLE_MAX_CHARS) || "Chat thread";
|
|
141523
141575
|
var makeTurns = (core, deps) => {
|
|
@@ -141526,7 +141578,7 @@ var makeTurns = (core, deps) => {
|
|
|
141526
141578
|
const { pendingByChat, pendingFor, collectResources } = deps.attachments;
|
|
141527
141579
|
const threadStillUsable = async (binding, threadId) => {
|
|
141528
141580
|
try {
|
|
141529
|
-
const thread = await host.
|
|
141581
|
+
const thread = await threadOrNull7(host.threads, threadId, { archived: "include" });
|
|
141530
141582
|
return thread !== null && thread.archivedAt == null && thread.projectId === binding.projectId;
|
|
141531
141583
|
} catch {
|
|
141532
141584
|
return true;
|
|
@@ -143927,7 +143979,7 @@ var makeWecomAppAdapter = (deps) => {
|
|
|
143927
143979
|
// src/index.ts
|
|
143928
143980
|
var imPlugin = definePlugin({
|
|
143929
143981
|
id: "im",
|
|
143930
|
-
apiVersion:
|
|
143982
|
+
apiVersion: 9,
|
|
143931
143983
|
activate: async (ctx) => {
|
|
143932
143984
|
const { t, setLanguage } = makeLiveTranslate(
|
|
143933
143985
|
parseReplyLanguage(ctx.config[REPLY_LANGUAGE_FIELD])
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/plugin-im",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3020",
|
|
4
4
|
"description": "Talk to your agents from Telegram, WeCom, Lark, or WeChat (experimental).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"im",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"markdown-it": "^15.0.2",
|
|
33
33
|
"react": "19.2.6",
|
|
34
34
|
"vite-plus": "0.2.2",
|
|
35
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
35
|
+
"@ycodium-ai/plugin-api": "0.2.3020"
|
|
36
36
|
},
|
|
37
37
|
"ycodium": {
|
|
38
38
|
"plugin": "./dist/index.js",
|