@leviyuan/lodestar 0.1.8 → 0.1.9

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/session.ts +40 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leviyuan/lodestar",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/session.ts CHANGED
@@ -152,6 +152,19 @@ export class Session {
152
152
  }
153
153
  }
154
154
 
155
+ /** Patch the card-level summary (the text Feishu uses for chat-list
156
+ * preview AND lock-screen push), then return when the API call has
157
+ * landed. Used right before urgent_app so the push notification's
158
+ * derived preview describes the *action that needs attention* (an
159
+ * unanswered question, a pending permission ask) rather than the
160
+ * stale assistant-text tail that patchSummaryThrottled was streaming.
161
+ * cancelSummary kills any in-flight throttled write so our explicit
162
+ * patch isn't immediately clobbered. */
163
+ private async setUrgentSummary(cardId: string, content: string): Promise<void> {
164
+ cardkit.cancelSummary(cardId)
165
+ await cardkit.patchSettings(cardId, { config: { summary: { content } } })
166
+ }
167
+
155
168
  /** Minimal cross-chat snapshot for the `hi` peer-list section.
156
169
  * `startedAt` stays private so this is the documented read path. */
157
170
  peerSnapshot(): { name: string; status: Status; uptimeMs?: number } {
@@ -745,9 +758,21 @@ export class Session {
745
758
  targetElementId: cards.ELEMENTS.footer,
746
759
  })
747
760
  // Phone push — user has to come back and answer before Claude can
748
- // continue. urgentApp no-ops when userOpenId is empty.
761
+ // continue. Set summary to the question text so the lock-screen
762
+ // notification preview shows what the user needs to answer.
749
763
  if (this.currentTurn.userOpenId && this.currentTurn.messageId) {
750
- void feishu.urgentApp(this.currentTurn.messageId, [this.currentTurn.userOpenId])
764
+ const turn = this.currentTurn
765
+ const q0 = questions[0]?.question?.trim() ?? ''
766
+ const truncated = q0.length > 40 ? q0.slice(0, 40) + '…' : q0
767
+ const summary = questions.length > 1
768
+ ? `❓ 待回答 ${questions.length} 题${truncated ? `: ${truncated}` : ''}`
769
+ : truncated
770
+ ? `❓ ${truncated}`
771
+ : '❓ 等你回答问题'
772
+ void (async () => {
773
+ await this.setUrgentSummary(turn.cardId, summary)
774
+ await feishu.urgentApp(turn.messageId, [turn.userOpenId])
775
+ })()
751
776
  }
752
777
  return
753
778
  }
@@ -925,8 +950,20 @@ export class Session {
925
950
  const el = cards.toolCallPermissionElement(meta.i, meta.name, meta.input, req.request_id)
926
951
  void cardkit.replaceElement(turn.cardId, cards.ELEMENTS.tool(meta.i), el)
927
952
  // Phone push — Claude is blocked until the user approves/denies.
953
+ // Set summary to "🔐 等审批: <tool>(<input summary>)" so the lock-
954
+ // screen notification shows which tool needs approval.
928
955
  if (turn.userOpenId && turn.messageId) {
929
- void feishu.urgentApp(turn.messageId, [turn.userOpenId])
956
+ const inputSummary = cards.summarizeToolInput(meta.name, meta.input)
957
+ const tail = inputSummary && inputSummary.length > 30
958
+ ? inputSummary.slice(0, 30) + '…'
959
+ : inputSummary
960
+ const summary = tail
961
+ ? `🔐 等审批: ${meta.name} · ${tail}`
962
+ : `🔐 等审批: ${meta.name}`
963
+ void (async () => {
964
+ await this.setUrgentSummary(turn.cardId, summary)
965
+ await feishu.urgentApp(turn.messageId, [turn.userOpenId])
966
+ })()
930
967
  }
931
968
  }
932
969