@magpie-community/opencode-qoder-auth 0.2.32 → 0.2.33

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/index.mjs +9 -2
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -892,6 +892,13 @@ const TASKS = new Map()
892
892
  const TASK_MAX = 512
893
893
  const TASK_IDLE = 2 * 60 * 60 * 1000
894
894
 
895
+ // taskName is the business record's name for a task whose prompt is
896
+ // prompt, as Qoder's client names an agent task: the prompt's first ten
897
+ // characters (qoder-agent-sdk's AgentLifecycle, hdr → C6s: type
898
+ // "code_review" takes the session id, every other the prompt, sliced to
899
+ // 10 when longer).
900
+ const taskName = (prompt) => (prompt.length > 10 ? prompt.slice(0, 10) : prompt)
901
+
895
902
  // taskOf is the task chat's call belongs to, in session sid: made on its
896
903
  // first call, the same one on every call after.
897
904
  function taskOf(sid, chat, now = Date.now()) {
@@ -905,7 +912,7 @@ function taskOf(sid, chat, now = Date.now()) {
905
912
  let t = TASKS.get(key)
906
913
  if (t && now - t.used > TASK_IDLE) t = undefined
907
914
  TASKS.delete(key)
908
- t ??= { id: randomUUID(), begin: now, answered: false }
915
+ t ??= { id: randomUUID(), begin: now, answered: false, name: taskName(at < 0 ? "" : textOf(msgs[at].content)) }
909
916
  t.used = now
910
917
  TASKS.set(key, t)
911
918
  while (TASKS.size > TASK_MAX) TASKS.delete(TASKS.keys().next().value)
@@ -936,7 +943,7 @@ function qoderBody(chat, m, named = "", task) {
936
943
  chat_record_id: request,
937
944
  session_id: session,
938
945
  parameters: params,
939
- business: { product: "app", version: COSY_VERSION, type: "agent", id: task.id, name: "magpie session", begin_at: task.begin, stage: task.answered ? "processing" : "start" },
946
+ business: { product: "app", version: COSY_VERSION, type: "agent", id: task.id, name: task.name ?? "", begin_at: task.begin, stage: task.answered ? "processing" : "start" },
940
947
  agent_id: "agent_common",
941
948
  task_id: "common",
942
949
  session_type: "app",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-qoder-auth",
3
- "version": "0.2.32",
3
+ "version": "0.2.33",
4
4
  "description": "Qoder subscriptions in OpenCode and magpie: Qoder (qoder.com) and Qoder CN (qoder.cn)",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",