@ycodium-ai/plugin-im 0.2.3315 → 0.2.3317

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 CHANGED
@@ -126404,6 +126404,10 @@ var approvalSettlementText = (settlement, t) => settlement.kind === "chosen" ? t
126404
126404
  // src/botConfig.ts
126405
126405
  import { PLUGIN_PROXY_DIRECT } from "@ycodium-ai/plugin-api";
126406
126406
 
126407
+ // src/chatEventParsing.ts
126408
+ var isRecord = (value2) => typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
126409
+ var nonEmpty = (value2) => typeof value2 === "string" && value2 !== "" ? value2 : null;
126410
+
126407
126411
  // ../../node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=78523ded7c3dfc3efd3cec0247f4960d00eaa3d3c96a2077457694a4d8b453c6/node_modules/effect/dist/Pipeable.js
126408
126412
  var pipeArguments = (self2, args2) => {
126409
126413
  switch (args2.length) {
@@ -127611,23 +127615,23 @@ var ATTACHED_THREAD_LIMIT = 200;
127611
127615
  var attachedKey = (chatKey, threadId) => `${chatKey}
127612
127616
  ${threadId}`;
127613
127617
  var hasAttached = (state, chatKey, threadId) => state.attached?.[attachedKey(chatKey, threadId)] !== void 0;
127614
- var nonEmpty = (value2) => typeof value2 === "string" && value2 !== "" ? value2 : null;
127618
+ var nonEmpty2 = (value2) => typeof value2 === "string" && value2 !== "" ? value2 : null;
127615
127619
  var readAttached = (data) => {
127616
- const chatKey = nonEmpty(data["chatKey"]);
127617
- const threadId = nonEmpty(data["threadId"]);
127618
- const projectId = nonEmpty(data["projectId"]);
127619
- const attachedAt = nonEmpty(data["attachedAt"]);
127620
+ const chatKey = nonEmpty2(data["chatKey"]);
127621
+ const threadId = nonEmpty2(data["threadId"]);
127622
+ const projectId = nonEmpty2(data["projectId"]);
127623
+ const attachedAt = nonEmpty2(data["attachedAt"]);
127620
127624
  return chatKey === null || threadId === null || projectId === null || attachedAt === null ? null : { chatKey, threadId, projectId, attachedAt };
127621
127625
  };
127622
127626
 
127623
127627
  // src/chatAliases.ts
127624
127628
  var aliasKey = (rowId, alias) => `${rowId}:${alias}`;
127625
127629
  var chatAliasOf = (state, rowId, alias) => state.aliases?.[aliasKey(rowId, alias)];
127626
- var nonEmpty2 = (value2) => typeof value2 === "string" && value2 !== "" ? value2 : null;
127630
+ var nonEmpty3 = (value2) => typeof value2 === "string" && value2 !== "" ? value2 : null;
127627
127631
  var foldAliased = (state, data) => {
127628
- const rowId = nonEmpty2(data["rowId"]);
127629
- const alias = nonEmpty2(data["alias"]);
127630
- const chatId = nonEmpty2(data["chatId"]);
127632
+ const rowId = nonEmpty3(data["rowId"]);
127633
+ const alias = nonEmpty3(data["alias"]);
127634
+ const chatId = nonEmpty3(data["chatId"]);
127631
127635
  if (rowId === null || alias === null || chatId === null) return state;
127632
127636
  const key2 = aliasKey(rowId, alias);
127633
127637
  if (state.aliases?.[key2] !== void 0) return state;
@@ -127921,10 +127925,6 @@ var foldSessionTransferred = (state, data) => {
127921
127925
  return { ...state, chats };
127922
127926
  };
127923
127927
 
127924
- // src/chatEventParsing.ts
127925
- var isRecord = (value2) => typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
127926
- var nonEmpty3 = (value2) => typeof value2 === "string" && value2 !== "" ? value2 : null;
127927
-
127928
127928
  // src/runtimeMode.ts
127929
127929
  import {
127930
127930
  EXECUTOR_RUNTIME_MODES,
@@ -127947,16 +127947,16 @@ var effectiveRuntimeMode = (ceiling, override) => override == null || isLooserRu
127947
127947
  var readChatPatch = (data) => {
127948
127948
  const patch = {};
127949
127949
  if (data["projectId"] === null) patch.projectId = null;
127950
- else if (nonEmpty3(data["projectId"]) !== null) patch.projectId = nonEmpty3(data["projectId"]);
127950
+ else if (nonEmpty(data["projectId"]) !== null) patch.projectId = nonEmpty(data["projectId"]);
127951
127951
  if (data["threadId"] === null) patch.threadId = null;
127952
- else if (nonEmpty3(data["threadId"]) !== null) patch.threadId = nonEmpty3(data["threadId"]);
127952
+ else if (nonEmpty(data["threadId"]) !== null) patch.threadId = nonEmpty(data["threadId"]);
127953
127953
  const target2 = data["target"];
127954
127954
  if (isRecord(target2) && (target2["kind"] === "thread" || target2["kind"] === "team"))
127955
127955
  patch.target = { kind: target2["kind"] };
127956
127956
  if (data["model"] === null) patch.model = null;
127957
127957
  else if (isRecord(data["model"])) {
127958
- const instanceId = nonEmpty3(data["model"]["instanceId"]);
127959
- const model = nonEmpty3(data["model"]["model"]);
127958
+ const instanceId = nonEmpty(data["model"]["instanceId"]);
127959
+ const model = nonEmpty(data["model"]["model"]);
127960
127960
  if (instanceId !== null && model !== null) {
127961
127961
  const options = data["model"]["options"];
127962
127962
  patch.model = {
@@ -127964,14 +127964,14 @@ var readChatPatch = (data) => {
127964
127964
  model,
127965
127965
  ...Array.isArray(options) ? {
127966
127966
  options: options.flatMap(
127967
- (entry) => isRecord(entry) && nonEmpty3(entry["id"]) !== null && (typeof entry["value"] === "string" || typeof entry["value"] === "boolean") ? [{ id: String(entry["id"]), value: entry["value"] }] : []
127967
+ (entry) => isRecord(entry) && nonEmpty(entry["id"]) !== null && (typeof entry["value"] === "string" || typeof entry["value"] === "boolean") ? [{ id: String(entry["id"]), value: entry["value"] }] : []
127968
127968
  )
127969
127969
  } : {}
127970
127970
  };
127971
127971
  }
127972
127972
  }
127973
127973
  if (data["preset"] === null) patch.preset = null;
127974
- else if (nonEmpty3(data["preset"]) !== null) patch.preset = nonEmpty3(data["preset"]);
127974
+ else if (nonEmpty(data["preset"]) !== null) patch.preset = nonEmpty(data["preset"]);
127975
127975
  if (typeof data["plan"] === "boolean") patch.plan = data["plan"];
127976
127976
  if (data["runtimeMode"] === null || isRuntimeMode(data["runtimeMode"]))
127977
127977
  patch.runtimeMode = data["runtimeMode"];
@@ -132444,8 +132444,8 @@ var readButtons = (value2) => {
132444
132444
  const buttons = [];
132445
132445
  for (const entry of value2) {
132446
132446
  if (!isRecord(entry)) return null;
132447
- const token = nonEmpty3(entry["token"]);
132448
- const decision = nonEmpty3(entry["decision"]);
132447
+ const token = nonEmpty(entry["token"]);
132448
+ const decision = nonEmpty(entry["decision"]);
132449
132449
  const label = typeof entry["label"] === "string" ? entry["label"] : null;
132450
132450
  if (token === null || decision === null || label === null) return null;
132451
132451
  buttons.push({ token, label, decision });
@@ -132457,8 +132457,8 @@ var readQuestionOptions = (value2) => {
132457
132457
  const options = [];
132458
132458
  for (const entry of value2) {
132459
132459
  if (!isRecord(entry)) return null;
132460
- const token = nonEmpty3(entry["token"]);
132461
- const optionValue = nonEmpty3(entry["value"]);
132460
+ const token = nonEmpty(entry["token"]);
132461
+ const optionValue = nonEmpty(entry["value"]);
132462
132462
  if (token === null || optionValue === null || typeof entry["label"] !== "string") return null;
132463
132463
  const planAction = entry["planAction"];
132464
132464
  options.push({
@@ -132476,10 +132476,10 @@ var readQuestionItems = (value2) => {
132476
132476
  const items = [];
132477
132477
  for (const entry of value2) {
132478
132478
  if (!isRecord(entry)) return null;
132479
- const id = nonEmpty3(entry["id"]);
132479
+ const id = nonEmpty(entry["id"]);
132480
132480
  const options = readQuestionOptions(entry["options"]);
132481
132481
  if (id === null || options === null || typeof entry["question"] !== "string") return null;
132482
- const submitToken = nonEmpty3(entry["submitToken"]);
132482
+ const submitToken = nonEmpty(entry["submitToken"]);
132483
132483
  items.push({
132484
132484
  id,
132485
132485
  header: typeof entry["header"] === "string" ? entry["header"] : "",
@@ -132535,25 +132535,24 @@ var foldImEvent = (state, name, data) => {
132535
132535
  case "conclusion-delivered":
132536
132536
  return foldConclusionEvent(state, name, data);
132537
132537
  case "chat-updated": {
132538
- const chatKey = nonEmpty3(data["chatKey"]);
132538
+ const chatKey = nonEmpty(data["chatKey"]);
132539
132539
  if (chatKey === null) return state;
132540
132540
  return withChat(state, chatKey, readChatPatch(data));
132541
132541
  }
132542
132542
  case "thread-opened": {
132543
- const chatKey = nonEmpty3(data["chatKey"]);
132544
- const threadId = nonEmpty3(data["threadId"]);
132545
- const projectId = nonEmpty3(data["projectId"]);
132546
- const openedAt = nonEmpty3(data["openedAt"]);
132543
+ const chatKey = nonEmpty(data["chatKey"]);
132544
+ const threadId = nonEmpty(data["threadId"]);
132545
+ const projectId = nonEmpty(data["projectId"]);
132546
+ const openedAt = nonEmpty(data["openedAt"]);
132547
+ const platform = nonEmpty(data["platform"]);
132547
132548
  if (chatKey === null || threadId === null || projectId === null || openedAt === null) {
132548
132549
  return state;
132549
132550
  }
132550
132551
  const bound = withChat(state, chatKey, { threadId });
132552
+ const record4 = { chatKey, projectId, openedAt, ...platform === null ? {} : { platform } };
132551
132553
  return {
132552
132554
  ...bound,
132553
- opened: keepNewest(
132554
- { ...bound.opened, [threadId]: { chatKey, projectId, openedAt } },
132555
- OPENED_THREAD_LIMIT
132556
- )
132555
+ opened: keepNewest({ ...bound.opened, [threadId]: record4 }, OPENED_THREAD_LIMIT)
132557
132556
  };
132558
132557
  }
132559
132558
  case "team-goal-started": {
@@ -132570,9 +132569,9 @@ var foldImEvent = (state, name, data) => {
132570
132569
  return { ...state, attached: keepNewest(attached, ATTACHED_THREAD_LIMIT) };
132571
132570
  }
132572
132571
  case "approval-offered": {
132573
- const chatKey = nonEmpty3(data["chatKey"]);
132574
- const threadId = nonEmpty3(data["threadId"]);
132575
- const requestId = nonEmpty3(data["requestId"]);
132572
+ const chatKey = nonEmpty(data["chatKey"]);
132573
+ const threadId = nonEmpty(data["threadId"]);
132574
+ const requestId = nonEmpty(data["requestId"]);
132576
132575
  const options = readButtons(data["options"]);
132577
132576
  if (chatKey === null || threadId === null || requestId === null || options === null) {
132578
132577
  return state;
@@ -132596,7 +132595,7 @@ var foldImEvent = (state, name, data) => {
132596
132595
  };
132597
132596
  }
132598
132597
  case "approval-resolved": {
132599
- const requestId = nonEmpty3(data["requestId"]);
132598
+ const requestId = nonEmpty(data["requestId"]);
132600
132599
  const existing = requestId === null ? void 0 : state.approvals[requestId];
132601
132600
  if (requestId === null || existing === void 0) return state;
132602
132601
  return {
@@ -132605,8 +132604,8 @@ var foldImEvent = (state, name, data) => {
132605
132604
  };
132606
132605
  }
132607
132606
  case "approval-carded": {
132608
- const requestId = nonEmpty3(data["requestId"]);
132609
- const cardId = nonEmpty3(data["cardId"]);
132607
+ const requestId = nonEmpty(data["requestId"]);
132608
+ const cardId = nonEmpty(data["cardId"]);
132610
132609
  const existing = requestId === null ? void 0 : state.approvals[requestId];
132611
132610
  if (requestId === null || cardId === null || existing === void 0) return state;
132612
132611
  return {
@@ -132615,9 +132614,9 @@ var foldImEvent = (state, name, data) => {
132615
132614
  };
132616
132615
  }
132617
132616
  case "question-offered": {
132618
- const chatKey = nonEmpty3(data["chatKey"]);
132619
- const threadId = nonEmpty3(data["threadId"]);
132620
- const requestId = nonEmpty3(data["requestId"]);
132617
+ const chatKey = nonEmpty(data["chatKey"]);
132618
+ const threadId = nonEmpty(data["threadId"]);
132619
+ const requestId = nonEmpty(data["requestId"]);
132621
132620
  const items = readQuestionItems(data["items"]);
132622
132621
  if (chatKey === null || threadId === null || requestId === null || items === null) {
132623
132622
  return state;
@@ -132634,12 +132633,12 @@ var foldImEvent = (state, name, data) => {
132634
132633
  };
132635
132634
  }
132636
132635
  case "question-carded": {
132637
- const cardId = nonEmpty3(data["cardId"]);
132636
+ const cardId = nonEmpty(data["cardId"]);
132638
132637
  if (cardId === null) return state;
132639
132638
  return withQuestionItem(
132640
132639
  state,
132641
- nonEmpty3(data["requestId"]),
132642
- nonEmpty3(data["questionId"]),
132640
+ nonEmpty(data["requestId"]),
132641
+ nonEmpty(data["questionId"]),
132643
132642
  (item) => ({ ...item, cardId })
132644
132643
  );
132645
132644
  }
@@ -132648,8 +132647,8 @@ var foldImEvent = (state, name, data) => {
132648
132647
  if (!Array.isArray(selected)) return state;
132649
132648
  return withQuestionItem(
132650
132649
  state,
132651
- nonEmpty3(data["requestId"]),
132652
- nonEmpty3(data["questionId"]),
132650
+ nonEmpty(data["requestId"]),
132651
+ nonEmpty(data["questionId"]),
132653
132652
  (item) => ({ ...item, selected })
132654
132653
  );
132655
132654
  }
@@ -132660,8 +132659,8 @@ var foldImEvent = (state, name, data) => {
132660
132659
  const attachments = getOrUndefined(readStoredAttachments(data["attachments"]));
132661
132660
  return withQuestionItem(
132662
132661
  state,
132663
- nonEmpty3(data["requestId"]),
132664
- nonEmpty3(data["questionId"]),
132662
+ nonEmpty(data["requestId"]),
132663
+ nonEmpty(data["questionId"]),
132665
132664
  (item) => ({
132666
132665
  ...item,
132667
132666
  answer,
@@ -132671,7 +132670,7 @@ var foldImEvent = (state, name, data) => {
132671
132670
  );
132672
132671
  }
132673
132672
  case "question-resolved": {
132674
- const requestId = nonEmpty3(data["requestId"]);
132673
+ const requestId = nonEmpty(data["requestId"]);
132675
132674
  const existing = requestId === null ? void 0 : questionsOf(state)[requestId];
132676
132675
  if (requestId === null || existing === void 0) return state;
132677
132676
  const ending = data["ending"];
@@ -132688,12 +132687,12 @@ var foldImEvent = (state, name, data) => {
132688
132687
  };
132689
132688
  }
132690
132689
  case "queue-offered": {
132691
- const chatKey = nonEmpty3(data["chatKey"]);
132692
- const threadId = nonEmpty3(data["threadId"]);
132693
- const intentId = nonEmpty3(data["intentId"]);
132694
- const steerToken = nonEmpty3(data["steerToken"]);
132695
- const withdrawToken = nonEmpty3(data["withdrawToken"]);
132696
- const resumeToken = nonEmpty3(data["resumeToken"]);
132690
+ const chatKey = nonEmpty(data["chatKey"]);
132691
+ const threadId = nonEmpty(data["threadId"]);
132692
+ const intentId = nonEmpty(data["intentId"]);
132693
+ const steerToken = nonEmpty(data["steerToken"]);
132694
+ const withdrawToken = nonEmpty(data["withdrawToken"]);
132695
+ const resumeToken = nonEmpty(data["resumeToken"]);
132697
132696
  if (chatKey === null || threadId === null || intentId === null || steerToken === null || withdrawToken === null || resumeToken === null) {
132698
132697
  return state;
132699
132698
  }
@@ -132718,30 +132717,30 @@ var foldImEvent = (state, name, data) => {
132718
132717
  };
132719
132718
  }
132720
132719
  case "queue-carded": {
132721
- const cardId = nonEmpty3(data["cardId"]);
132720
+ const cardId = nonEmpty(data["cardId"]);
132722
132721
  if (cardId === null) return state;
132723
- return withQueueRecord(state, nonEmpty3(data["intentId"]), (record4) => ({
132722
+ return withQueueRecord(state, nonEmpty(data["intentId"]), (record4) => ({
132724
132723
  ...record4,
132725
132724
  cardId
132726
132725
  }));
132727
132726
  }
132728
132727
  case "queue-steering":
132729
- return withQueueRecord(state, nonEmpty3(data["intentId"]), (record4) => ({
132728
+ return withQueueRecord(state, nonEmpty(data["intentId"]), (record4) => ({
132730
132729
  ...record4,
132731
132730
  steering: data["steering"] === true
132732
132731
  }));
132733
132732
  case "queue-settled": {
132734
132733
  const outcome = data["outcome"];
132735
132734
  if (outcome !== "steered" && outcome !== "sent" && outcome !== "removed") return state;
132736
- return withQueueRecord(state, nonEmpty3(data["intentId"]), (record4) => ({
132735
+ return withQueueRecord(state, nonEmpty(data["intentId"]), (record4) => ({
132737
132736
  ...record4,
132738
132737
  settled: outcome
132739
132738
  }));
132740
132739
  }
132741
132740
  case "turn-card-opened": {
132742
- const cardId = nonEmpty3(data["cardId"]);
132743
- const chatKey = nonEmpty3(data["chatKey"]);
132744
- const threadId = nonEmpty3(data["threadId"]);
132741
+ const cardId = nonEmpty(data["cardId"]);
132742
+ const chatKey = nonEmpty(data["chatKey"]);
132743
+ const threadId = nonEmpty(data["threadId"]);
132745
132744
  if (cardId === null || chatKey === null || threadId === null) return state;
132746
132745
  const title = typeof data["title"] === "string" ? data["title"] : "";
132747
132746
  return {
@@ -132753,7 +132752,7 @@ var foldImEvent = (state, name, data) => {
132753
132752
  };
132754
132753
  }
132755
132754
  case "turn-card-closed": {
132756
- const cardId = nonEmpty3(data["cardId"]);
132755
+ const cardId = nonEmpty(data["cardId"]);
132757
132756
  if (cardId === null) return state;
132758
132757
  const { [cardId]: _closed, ...rest } = openTurnCardsOf(state);
132759
132758
  return { ...state, turnCards: rest };
@@ -133446,15 +133445,17 @@ var readBot = (adapterFor, rowId, row) => {
133446
133445
  };
133447
133446
  return adapter.isConfigured(bot) ? bot : null;
133448
133447
  };
133449
- var readBots = (config2, adapterFor) => {
133448
+ var botRows = (config2) => {
133450
133449
  const table2 = config2[BOTS_FIELD];
133451
- if (typeof table2 !== "object" || table2 === null) return [];
133452
- return Object.entries(table2).flatMap(([rowId, row]) => {
133453
- if (typeof row !== "object" || row === null) return [];
133454
- const bot = readBot(adapterFor, rowId, row);
133455
- return bot === null ? [] : [bot];
133456
- });
133450
+ if (!isRecord(table2)) return [];
133451
+ return Object.entries(table2).flatMap(
133452
+ ([rowId, row]) => isRecord(row) ? [[rowId, row]] : []
133453
+ );
133457
133454
  };
133455
+ var readBots = (config2, adapterFor) => botRows(config2).flatMap(([rowId, row]) => {
133456
+ const bot = readBot(adapterFor, rowId, row);
133457
+ return bot === null ? [] : [bot];
133458
+ });
133458
133459
  var bindingOf = (bot, chatId, state) => ({
133459
133460
  ...bot,
133460
133461
  reply: void 0,
@@ -134200,6 +134201,70 @@ var makeChatSetup = (core, deps) => {
134200
134201
  return { promptProject, handleRepo, handleGroup, decideProjectMessage, executeProjectDecision };
134201
134202
  };
134202
134203
 
134204
+ // src/channelAnnotations.ts
134205
+ var THREAD_ANNOTATIONS_COMMAND = "threadAnnotations";
134206
+ var LABEL_EXCEPTIONS = {
134207
+ "wecom-app": "platform.wecom",
134208
+ wechat: "annotation.channel.wechat"
134209
+ };
134210
+ var channelAnnotations = (state, config2, platforms) => {
134211
+ const rows = botRows(config2);
134212
+ const rowPlatform = (chatKey) => {
134213
+ const row = rows.find(([rowId]) => isChatKeyOfRow(chatKey, rowId))?.[1];
134214
+ return row === void 0 ? void 0 : platformOf(row);
134215
+ };
134216
+ return Object.entries(state.opened).map(([threadId, opened]) => {
134217
+ const platform = opened.platform ?? rowPlatform(opened.chatKey);
134218
+ const labelKey = platform === void 0 || !platforms.has(platform) ? "annotation.channel.chat" : LABEL_EXCEPTIONS[platform] ?? `platform.${platform}`;
134219
+ return { threadId, labelKey, tone: "muted" };
134220
+ });
134221
+ };
134222
+ var registerChannelAnnotations = (ctx, core, adapters) => {
134223
+ const platforms = new Set(adapters.map((adapter) => adapter.platform));
134224
+ const compute = () => channelAnnotations(core.state, ctx.config, platforms);
134225
+ const subscribers = /* @__PURE__ */ new Set();
134226
+ let opened = core.state.opened;
134227
+ let snapshot = compute();
134228
+ let encoded = JSON.stringify(snapshot);
134229
+ const refresh = () => {
134230
+ opened = core.state.opened;
134231
+ const next = compute();
134232
+ const nextEncoded = JSON.stringify(next);
134233
+ if (nextEncoded === encoded) return;
134234
+ snapshot = next;
134235
+ encoded = nextEncoded;
134236
+ for (const push of subscribers) push(snapshot);
134237
+ };
134238
+ core.onStateChange(() => {
134239
+ if (core.state.opened !== opened) refresh();
134240
+ });
134241
+ ctx.stream({
134242
+ name: THREAD_ANNOTATIONS_COMMAND,
134243
+ description: "Label the threads this plugin opened with the chat platform they came from.",
134244
+ scope: "read",
134245
+ payloadSchema: { type: "object", additionalProperties: false },
134246
+ buffer: { latest: 1 },
134247
+ handle: async (_payload, emit, signal) => {
134248
+ await core.ready;
134249
+ if (signal.aborted) return;
134250
+ const push = (next) => {
134251
+ if (!signal.aborted) emit(next);
134252
+ };
134253
+ subscribers.add(push);
134254
+ push(snapshot);
134255
+ try {
134256
+ await new Promise((resolve2) => {
134257
+ if (signal.aborted) resolve2();
134258
+ else signal.addEventListener("abort", () => resolve2(), { once: true });
134259
+ });
134260
+ } finally {
134261
+ subscribers.delete(push);
134262
+ }
134263
+ }
134264
+ });
134265
+ return { refresh };
134266
+ };
134267
+
134203
134268
  // src/commands.ts
134204
134269
  import { threadOrNull as threadOrNull4 } from "@ycodium-ai/plugin-api";
134205
134270
 
@@ -134933,7 +134998,7 @@ var makePermissionCommand = (core) => {
134933
134998
  // package.json
134934
134999
  var package_default = {
134935
135000
  name: "@ycodium-ai/plugin-im",
134936
- version: "0.2.3315",
135001
+ version: "0.2.3317",
134937
135002
  description: "Talk to your agents from Telegram, WeCom, Lark, or WeChat (experimental).",
134938
135003
  keywords: [
134939
135004
  "im",
@@ -135014,7 +135079,10 @@ var package_default = {
135014
135079
  ],
135015
135080
  ui: {
135016
135081
  assets: "./assets",
135017
- entry: "ui.js"
135082
+ entry: "ui.js",
135083
+ threadAnnotations: {
135084
+ command: "threadAnnotations"
135085
+ }
135018
135086
  }
135019
135087
  }
135020
135088
  };
@@ -136359,11 +136427,16 @@ var makeImCore = (input) => {
136359
136427
  let confirmed = emptyState();
136360
136428
  let state = confirmed;
136361
136429
  const pending = [];
136430
+ const stateListeners = /* @__PURE__ */ new Set();
136431
+ const stateChanged = () => {
136432
+ for (const listener of stateListeners) listener();
136433
+ };
136362
136434
  const rebuildState = () => {
136363
136435
  state = pending.reduce(
136364
136436
  (current, event) => foldImEvent(current, event.name, event.data),
136365
136437
  confirmed
136366
136438
  );
136439
+ stateChanged();
136367
136440
  };
136368
136441
  const stateHandle = input.derivedState({
136369
136442
  key: IM_STATE_KEY,
@@ -136385,6 +136458,7 @@ var makeImCore = (input) => {
136385
136458
  const commitDurably = (name, data) => {
136386
136459
  pending.push({ name, data });
136387
136460
  state = foldImEvent(state, name, data);
136461
+ stateChanged();
136388
136462
  const saved = persisting.then(
136389
136463
  () => host.events.append({ name, aggregate: { kind: "plugin", id: input.pluginId }, data })
136390
136464
  ).then(
@@ -136470,6 +136544,10 @@ var makeImCore = (input) => {
136470
136544
  return state;
136471
136545
  },
136472
136546
  ready,
136547
+ onStateChange: (listener) => {
136548
+ stateListeners.add(listener);
136549
+ return () => stateListeners.delete(listener);
136550
+ },
136473
136551
  commit,
136474
136552
  commitDurably,
136475
136553
  bindChat,
@@ -148088,6 +148166,12 @@ var en_default = {
148088
148166
  startFailed: "Could not give this goal to the team lead. Try sending the message again.",
148089
148167
  startedUnnamed: "Handed to the team lead. Goal: {{goal}}",
148090
148168
  started: "Given to team lead {{name}}. Goal: {{goal}}"
148169
+ },
148170
+ annotation: {
148171
+ channel: {
148172
+ wechat: "WeChat",
148173
+ chat: "Chat app"
148174
+ }
148091
148175
  }
148092
148176
  };
148093
148177
 
@@ -149136,6 +149220,12 @@ var zh_CN_default = {
149136
149220
  startFailed: "\u6CA1\u80FD\u628A\u76EE\u6807\u4EA4\u7ED9\u8D1F\u8D23\u4EBA\uFF0C\u8BF7\u91CD\u53D1\u8FD9\u6761\u6D88\u606F\u518D\u8BD5\u3002",
149137
149221
  startedUnnamed: "\u5DF2\u4EA4\u7ED9\u8D1F\u8D23\u4EBA\uFF0C\u76EE\u6807\uFF1A{{goal}}",
149138
149222
  started: "\u5DF2\u4EA4\u7ED9\u8D1F\u8D23\u4EBA {{name}}\uFF0C\u76EE\u6807\uFF1A{{goal}}"
149223
+ },
149224
+ annotation: {
149225
+ channel: {
149226
+ wechat: "\u5FAE\u4FE1",
149227
+ chat: "\u804A\u5929\u5E94\u7528"
149228
+ }
149139
149229
  }
149140
149230
  };
149141
149231
 
@@ -153330,7 +153420,8 @@ var makeTurns = (core, deps) => {
153330
153420
  chatKey,
153331
153421
  threadId: createdThreadId,
153332
153422
  projectId: binding.projectId,
153333
- openedAt: (/* @__PURE__ */ new Date()).toISOString()
153423
+ openedAt: (/* @__PURE__ */ new Date()).toISOString(),
153424
+ platform: binding.platform
153334
153425
  });
153335
153426
  rememberThreadProject(createdThreadId, binding.projectId);
153336
153427
  if (dropped) await deliver(binding, t("reply.threadGone"));
@@ -154061,44 +154152,40 @@ var targetViews = (config2) => {
154061
154152
  };
154062
154153
  var buildSettingsView = (config2, adapters) => {
154063
154154
  const columns = buildBotColumns(adapters);
154064
- const table2 = config2[BOTS_FIELD];
154065
154155
  const bots = [];
154066
- if (isRecord4(table2)) {
154067
- for (const [rowId, raw] of Object.entries(table2)) {
154068
- if (!isRecord4(raw)) continue;
154069
- const platform = platformOf(raw);
154070
- const values = {};
154071
- const secrets = {};
154072
- for (const column of columns) {
154073
- if (column.kind === "password") secrets[column.key] = hasStoredSecret(raw, column.key);
154074
- else
154075
- values[column.key] = column.kind === "number" && typeof raw[column.key] === "number" ? String(raw[column.key]) : readString(raw, column.key) || column.defaultValue || "";
154076
- }
154077
- const adapter = adapters.find((candidate) => candidate.platform === platform);
154078
- if (adapter === void 0) {
154079
- bots.push({
154080
- rowId,
154081
- platform,
154082
- configured: false,
154083
- values,
154084
- secrets,
154085
- issues: [],
154086
- publicFields: []
154087
- });
154088
- continue;
154089
- }
154090
- const bot = readBotView(rowId, raw, adapter);
154091
- const issues = validateBotSettings(bot, adapter);
154156
+ for (const [rowId, raw] of botRows(config2)) {
154157
+ const platform = platformOf(raw);
154158
+ const values = {};
154159
+ const secrets = {};
154160
+ for (const column of columns) {
154161
+ if (column.kind === "password") secrets[column.key] = hasStoredSecret(raw, column.key);
154162
+ else
154163
+ values[column.key] = column.kind === "number" && typeof raw[column.key] === "number" ? String(raw[column.key]) : readString(raw, column.key) || column.defaultValue || "";
154164
+ }
154165
+ const adapter = adapters.find((candidate) => candidate.platform === platform);
154166
+ if (adapter === void 0) {
154092
154167
  bots.push({
154093
154168
  rowId,
154094
154169
  platform,
154095
- configured: adapter.isConfigured(bot),
154170
+ configured: false,
154096
154171
  values,
154097
154172
  secrets,
154098
- issues,
154099
- publicFields: adapter.publicFields?.(bot) ?? []
154173
+ issues: [],
154174
+ publicFields: []
154100
154175
  });
154176
+ continue;
154101
154177
  }
154178
+ const bot = readBotView(rowId, raw, adapter);
154179
+ const issues = validateBotSettings(bot, adapter);
154180
+ bots.push({
154181
+ rowId,
154182
+ platform,
154183
+ configured: adapter.isConfigured(bot),
154184
+ values,
154185
+ secrets,
154186
+ issues,
154187
+ publicFields: adapter.publicFields?.(bot) ?? []
154188
+ });
154102
154189
  }
154103
154190
  return {
154104
154191
  replyLanguage: parseReplyLanguage(config2[REPLY_LANGUAGE_FIELD]),
@@ -157188,6 +157275,7 @@ var definition = {
157188
157275
  t,
157189
157276
  adapters
157190
157277
  });
157278
+ const channelLabels = registerChannelAnnotations(ctx, core, adapters);
157191
157279
  const acknowledgements = makeAcknowledgements(core, ctx.interval);
157192
157280
  const failures = makeFailureNotices(core);
157193
157281
  const replyAnchors = makeReplyAnchors(core.host);
@@ -157322,6 +157410,7 @@ var definition = {
157322
157410
  connections.reconcile();
157323
157411
  await approvals.reconcileTimeouts();
157324
157412
  await deliveryHttp.apply(config2);
157413
+ channelLabels.refresh();
157325
157414
  });
157326
157415
  }
157327
157416
  ctx.log.info("chat plugin active", { bots, connecting });
package/locales/en.json CHANGED
@@ -1042,5 +1042,11 @@
1042
1042
  "startFailed": "Could not give this goal to the team lead. Try sending the message again.",
1043
1043
  "startedUnnamed": "Handed to the team lead. Goal: {{goal}}",
1044
1044
  "started": "Given to team lead {{name}}. Goal: {{goal}}"
1045
+ },
1046
+ "annotation": {
1047
+ "channel": {
1048
+ "wechat": "WeChat",
1049
+ "chat": "Chat app"
1050
+ }
1045
1051
  }
1046
1052
  }
@@ -1042,5 +1042,11 @@
1042
1042
  "startFailed": "没能把目标交给负责人,请重发这条消息再试。",
1043
1043
  "startedUnnamed": "已交给负责人,目标:{{goal}}",
1044
1044
  "started": "已交给负责人 {{name}},目标:{{goal}}"
1045
+ },
1046
+ "annotation": {
1047
+ "channel": {
1048
+ "wechat": "微信",
1049
+ "chat": "聊天应用"
1050
+ }
1045
1051
  }
1046
1052
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/plugin-im",
3
- "version": "0.2.3315",
3
+ "version": "0.2.3317",
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.3315",
35
+ "@ycodium-ai/plugin-api": "0.2.0",
36
36
  "ycodium-react-test-harness": "0.0.0"
37
37
  },
38
38
  "ycodium": {
@@ -75,7 +75,10 @@
75
75
  ],
76
76
  "ui": {
77
77
  "assets": "./assets",
78
- "entry": "ui.js"
78
+ "entry": "ui.js",
79
+ "threadAnnotations": {
80
+ "command": "threadAnnotations"
81
+ }
79
82
  }
80
83
  },
81
84
  "scripts": {