@oxmumu3/dsh-project-companion 0.24.2 → 0.26.0

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 CHANGED
@@ -96,7 +96,7 @@ dsh plugin --profile web add @oxmumu3/dsh-project-companion
96
96
 
97
97
  ## 版本与数据
98
98
 
99
- - 当前版本 **`0.24.1`**:首次打开有示例简报,「记录」页可回看并再做一份;`0.24.0` 带来了自检(`health`)、私人外发确认和个人回顾的自然语言关注点。
99
+ - 当前版本 **`0.26.0`**:并入手机端任务控制的 Dot 侧(对端就绪后生效);`0.25.0` 补上滴答账户级只读搜索;`0.24.1` 带来示例简报与「记录」页。
100
100
  - 兼容官方 Harness `0.2.0-rc.2`、`0.2.1-rc.2` 至 `rc.5`、`0.2.2-rc.1`;清单在 [compatibility.json](compatibility.json)。
101
101
  - 数据留在本机 Harness profile 内,不经过第三方服务器;微信组件内置部分保留上游 MIT 许可,见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。
102
102
  - 已知边界(Google 数据权限审核、flomo MAX、主动关注与手机收件的验收状态)统一写在[验证记录](docs/verification.md),本页不重复。
@@ -137,4 +137,4 @@ Google 普通连接与滴答普通 OAuth 走固定官方只读 REST;flomo、
137
137
 
138
138
  ### 滴答普通登录的读取范围
139
139
 
140
- 普通 OAuth 使用官方 Open API,保留 `tasks:read`。清单只取首批(最多10项),指定单个清单后读取其中任务(最多展示10条,响应上限1MiB),或者指定清单和任务读取一条。暂不支持跨全账号关键词搜索,不自动翻页或扫描其他清单。手填旧 token 的高级 MCP 路径保留;普通 OAuth 失败不会改用它。
140
+ 普通 OAuth 使用官方 Open API,保留 `tasks:read`。清单只取首批(最多10项),指定单个清单后读取其中任务(最多展示10条,响应上限1MiB),或者指定清单和任务读取一条。另支持账户级只读搜索:按标题、正文或备注跨清单搜索,单次最多返回 50 条并标记截断;内部最多枚举 1000 个清单、每个清单最多 1000 条任务、3 并发,超出直接失败而不是静默截断。不自动翻页。手填旧 token 的高级 MCP 路径保留;普通 OAuth 失败不会改用它。
package/docs/install.md CHANGED
@@ -1,4 +1,4 @@
1
- # 安装 DSH Dot 0.24.2
1
+ # 安装 DSH Dot 0.26.0
2
2
 
3
3
  ## 在创造模式中安装/更新
4
4
 
@@ -8,7 +8,7 @@
8
8
  请安装或更新并启用 DSH Dot。先检查现有插件,避免重复添加和降级。从 npm 官方源实时查询 @oxmumu3/dsh-project-companion 的 latest,按查到的精确版本安装或更新,不直接采用本机缓存的旧 latest。保留已有微信绑定、账号授权、资料范围、设置和其他插件,不自动读取或新建计划。核对实际版本、启用状态,再打开 DSH Dot。
9
9
  ```
10
10
 
11
- 新用户也可在「插件 → 添加插件」填写 `@oxmumu3/dsh-project-companion`(或精确版本 `@oxmumu3/dsh-project-companion@0.24.2`),安装后启用。它是一个标准插件包,已内置独立微信组件。已有未带 namespace 的历史安装应沿原包名更新;不要将两个名称当成同一个插件重复添加。
11
+ 新用户也可在「插件 → 添加插件」填写 `@oxmumu3/dsh-project-companion`(或精确版本 `@oxmumu3/dsh-project-companion@0.26.0`),安装后启用。它是一个标准插件包,已内置独立微信组件。已有未带 namespace 的历史安装应沿原包名更新;不要将两个名称当成同一个插件重复添加。
12
12
 
13
13
  牛村木木山制作的 DeepSeek Harness 社区插件,非 DeepSeek 或 OpenAI 官方产品。本版内置微信组件,只需添加一个标准插件包,不包含 Harness 应用或 Family 家庭助手。
14
14
 
@@ -26,7 +26,7 @@
26
26
 
27
27
  无法联网或想用离线包时,到 [Releases](https://github.com/oxmumu3/dsh-project-companion/releases) 下载对应版本的 `.tgz`,在官方管理器填写下载后的文件实际路径;无需解压、另装微信组件或运行 macOS 脚本。
28
28
 
29
- [本版发布页](https://github.com/oxmumu3/dsh-project-companion/releases/tag/v0.24.2)记录本版变更。插件包从 npm 安装,npm 页面提供 integrity 与 provenance 可核;0.24 起 release 不再附带离线包。插件尚未上架官方插件市场,npm latest 同步为本版;不要用旧版 ZIP 或第二个微信安装包代替这条单插件路径。
29
+ [本版发布页](https://github.com/oxmumu3/dsh-project-companion/releases/tag/v0.26.0)记录本版变更。插件包从 npm 安装,npm 页面提供 integrity 与 provenance 可核;0.24 起 release 不再附带离线包。插件尚未上架官方插件市场,npm latest 同步为本版;不要用旧版 ZIP 或第二个微信安装包代替这条单插件路径。
30
30
 
31
31
  ## 已有用户
32
32
 
@@ -68,7 +68,7 @@ Google 品牌已验证,Gmail、日历、Drive 数据权限已提交审核但
68
68
 
69
69
  ## 本版验证与已知问题
70
70
 
71
- 0.24.2 源码全量回归 2,365 项 / 2,328 通过 / 0 失败 / 37 跳过(跳过项均需 Family 源码树,不在本包范围)。自检只读本机状态,不发外部请求;单项探测 2 秒上限,超时或抛错显示「未知」。私人外发确认只覆盖 `personal_review.run_now` 这条路径,宿主自带的 `send_wechat`、定时投递和带内容的 `remind` / `coordinate` 不经过这道门禁——插件单方面无法覆盖全部外发路径。
71
+ 0.26.0 源码全量回归 2,365 项 / 2,328 通过 / 0 失败 / 37 跳过(跳过项均需 Family 源码树,不在本包范围)。自检只读本机状态,不发外部请求;单项探测 2 秒上限,超时或抛错显示「未知」。私人外发确认只覆盖 `personal_review.run_now` 这条路径,宿主自带的 `send_wechat`、定时投递和带内容的 `remind` / `coordinate` 不经过这道门禁——插件单方面无法覆盖全部外发路径。
72
72
 
73
73
  自动回顾仍为实验能力:自然语言 `focus` 尚未用真实模型验证实际效果,手机端呈现也未验证。历史 flomo 范围投影与模型失败未全部归因。新用户独立扫码到收件、多日与休眠恢复、真实 macOS 输入法仍分别验收。通道报告发送不等于手机收到。详见[验证记录](verification.md)。
74
74
 
@@ -25,7 +25,7 @@
25
25
 
26
26
  > 从 Gmail 搜索「subject:DeepSeek」最多1条,日历未来24小时最多2条,Drive 搜索「DeepSeek」最多1条,flomo 搜索 DeepSeek 最多2条,滴答清单列出清单最多2个,生成 我的项目 的项目简报。先不要设置提醒,不要建立计划。
27
27
 
28
- 它保留各来源范围并生成带引用的进展、阻塞和下一步;零匹配不等于读取失败。本例滴答只查清单元数据,不代表已读任务。共用入口也支持明确命名清单的未完成任务,例如“滴答「工作」清单的未完成任务最多2条”;不支持全账号任务关键词搜索或任意资源 ID,真实任务正文仍待本人限定实读。
28
+ 它保留各来源范围并生成带引用的进展、阻塞和下一步;零匹配不等于读取失败。本例滴答只查清单元数据,不代表已读任务。共用入口也支持明确命名清单的未完成任务,例如“滴答「工作」清单的未完成任务最多2条”;账户级关键词搜索按标题、正文与备注跨清单检索,单次最多 50 条并标明截断;仍不支持任意资源 ID,真实任务正文与跨清单全量扫描的边界见连接说明。
29
29
 
30
30
  Google 三项权限已正式提交,当前 `UNDER_REVIEW`,未获批准、完成 CASA 或解除已知累计 100 个账号上限,不保证任意新账号可连接。flomo 需要 MAX,滴答普通连接只申请 `tasks:read`。登录和启用不会自动建立私人资料扫描或推送。旧版实读见[历史验证记录](verification.md);当前闭环范围见[个人资料闭环](context-loop.md)。
31
31
 
package/docs/roadmap.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 当前收尾 · 0.24.2 公开版本
2
2
 
3
- 最新公开版本 0.24.2:项目工具收敛到 `look`/`manage` 两个入口,新增自检、私人外发确认与回顾关注点,首次打开有示例卡,交办记录可复用。
3
+ 最新公开版本 0.26.0:并入手机端任务控制的 Dot 侧(`mobileTaskScope` / `mobileQuestionState` / 桥接注册),等家庭助手暴露接口后即可用;`0.25.0`:补上滴答账户级只读搜索(`search_task` / `search` / `list_all_tasks`);此前 0.24.2:项目工具收敛到 `look`/`manage` 两个入口,新增自检、私人外发确认与回顾关注点,首次打开有示例卡,交办记录可复用。
4
4
 
5
5
  下一步按影响排序:
6
6
 
@@ -1,3 +1,24 @@
1
+ # 0.26.0 验证增量
2
+
3
+ 2026-11-09,把私有构建里的手机端任务控制并入公开主线(Dot 侧)。
4
+
5
+ - `node --max-old-space-size=256 --test --test-concurrency=1 test/*.test.mjs`:2,370 项 / 2,333 通过 / 0 失败 / 37 跳过(0.25.0 基线 2,367 / 2,330 / 0 / 37)。
6
+ - 新增 3 条用例:唯一活跃任务才交出范围(两个并存时返回空)、非家庭来源任务不交出范围、问答状态忽略空或超长 callId。
7
+ - 该能力在家庭助手未暴露 `registerMobileTasks` 时完全静默:插件启动只做一次类型判断,不注册回调、不读私人来源、不改变现有工具。
8
+
9
+ **没有验证的**:真实微信手机端的停止/续接/审批往返。对端(家庭助手)尚未公开该接口,本轮只交付 Dot 侧与合成用例;真机闭环待对端发版后进行。
10
+
11
+ # 0.25.0 验证增量
12
+
13
+ 2026-11-09,补齐滴答账户级只读搜索(`search_task` / `search` / `list_all_tasks`),并把契约层一起放开。
14
+
15
+ - `node --max-old-space-size=256 --test --test-concurrency=1 test/*.test.mjs`:2,367 项 / 2,330 通过 / 0 失败 / 37 跳过(0.24.2 基线 2,365 / 2,328 / 0 / 37)。
16
+ - 新增 3 条用例:跨项目过滤与截断标记、项目列表超 1000 时拒绝且不发第二类请求、项目 ID 不匹配时拒绝。
17
+ - 更新 4 条旧断言:原先断言"滴答搜索必须被拒绝",现改为断言搜索按边界执行(`dida-rest`、`context-contracts`、`context-host`、`dida-rest-integration`)。
18
+ - 边界写死并有用例:单次返回最多 50 条、枚举最多 1000 个项目、每项目最多 1000 条任务、3 并发;超限失败而非静默截断。
19
+
20
+ **没有验证的**:本轮全部用合成响应,没有对真实滴答账号发起搜索;真实账号下的匹配质量、耗时与截断行为仍需本人限定范围实读确认。
21
+
1
22
  # 0.24.0 验证增量
2
23
 
3
24
  2026-11-04,新增自检、私人外发确认与回顾关注点三项能力;来源是对 OpenMuse 公开文档的一次阅读,实现按其可迁移部分裁剪。
package/index.js CHANGED
@@ -363,9 +363,23 @@ export async function installCompanion(ctx,options={}){
363
363
  });
364
364
  familyDelegate=createFamilyOwnerDelegation({store:{get:key=>familyTable.get(key),put:(key,value)=>familyTable.put(key,familyDelegationRow.parse(value))},getBridge:getFamilyBridge,readGrantedLeases:async()=>context.delegationLeases(),readGrantedLeasesSync:()=>context.delegationLeases(),readLegacySetup:readSetup});
365
365
  familyContext=createFamilyContextAdapter({delegation:familyDelegate,context});
366
+ let mobileBridge,mobileRelease;
367
+ const syncMobileBridge=()=>{
368
+ const bridge=getFamilyBridge();if(bridge===mobileBridge)return;
369
+ mobileRelease?.();mobileRelease=undefined;mobileBridge=bridge;
370
+ if(typeof bridge?.registerMobileTasks!=='function')return;
371
+ mobileRelease=bridge.registerMobileTasks((sessionId,messageId)=>{
372
+ const captured=taskResults.mobileTaskScope(sessionId,messageId);if(!captured)return null;
373
+ const authorize=()=>{const scope=familyDelegate.scopeFor(captured.origin.sessionId),binding=scope&&familyBinding(scope),current=binding&&taskResults.mobileTaskScope(sessionId,messageId,{expectedBinding:binding});return !disposed&&current?.jobId===captured.jobId&&scope?.bindingRevision===captured.origin.bindingRevision&&binding?.userHash===captured.returnBinding?.userHash&&(binding?.botHash??null)===(captured.returnBinding?.botHash??null)&&familyDelegate.current(scope);};
374
+ return authorize()?{...captured,authorize,questionState:input=>taskResults.mobileQuestionState(sessionId,messageId,input)}:null;
375
+ });
376
+ };
377
+ syncMobileBridge();
378
+
366
379
  ctx.effect(()=>async()=>{
367
380
  disposed=true;
368
381
  lifecycle.abort();
382
+ mobileRelease?.();
369
383
  goalBoard.close();goalBoardModel.close();workspaceAccess.close();
370
384
  await goalBoard.waitForIdle().catch(()=>{});
371
385
  workbench?.close();workbenchActions?.close();recoveryGuard.close();const familyClosing=familyDelegate.close();
@@ -999,6 +1013,7 @@ export async function installCompanion(ctx,options={}){
999
1013
  // General dispatch has its own exact original-message capability; the
1000
1014
  // constrained source turn never inherits the target's native tools.
1001
1015
  if(args.action==='coordinate'&&!familyReadOnlyIntent(scope.userText)){
1016
+ syncMobileBridge();
1002
1017
  const admission=await familyProject.acquire({scope,args:admittedArgs,signal:execution.signal});
1003
1018
  if(!admission)throw new Error('本次原始 Owner 消息或原生项目交办范围无法安全确认;尚未派发。');
1004
1019
  scope={...scope,nativeProjectAdmission:admission};
@@ -1314,7 +1329,7 @@ export async function installCompanion(ctx,options={}){
1314
1329
  const track=operation=>{if(disposed)return;void operation().catch(noteError).finally(syncTimer);};
1315
1330
  ctx.on('agent/inbox/claimed',payload=>{
1316
1331
  if(!payload?.agent?.id||!payload.message?.id||!Number.isInteger(payload.turn))return;
1317
- track(async()=>{await taskResults.claimed({sessionId:String(payload.agent.id),messageId:String(payload.message.id),turn:payload.turn,sourceKind:payload.message.source?.kind});await personalReview.reconcileJobs();});
1332
+ track(async()=>{await taskResults.claimed({sessionId:String(payload.agent.id),messageId:String(payload.message.id),turn:payload.turn,sourceKind:payload.message.source?.kind,sourceCallId:payload.message.source?.callId});await personalReview.reconcileJobs();});
1318
1333
  });
1319
1334
  ctx.on('agent/inbox/discarded',payload=>{
1320
1335
  if(!payload?.agent?.id||!payload.message?.id)return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxmumu3/dsh-project-companion",
3
- "version": "0.24.2",
3
+ "version": "0.26.0",
4
4
  "description": "DSH Dot: WeChat personal agent, project memory and proactive follow-up for DeepSeek Harness",
5
5
  "author": "牛村木木山",
6
6
  "license": "MIT",
@@ -12,16 +12,16 @@ const INPUT_KEYS = new Set(['operation', 'query', 'id', 'ids', 'projectId', 'ran
12
12
  const OPERATION_INPUTS = {
13
13
  gmail: { search: ['query', 'limit'], read: ['id'] }, calendar: { upcoming: ['from', 'to', 'calendarId', 'limit'] },
14
14
  drive: { search: ['query', 'limit'], recent: ['from', 'to', 'limit'], read: ['id'] }, docs: { read: ['id'] }, sheets: { read: ['id', 'range'] }, slides: { read: ['id'] },
15
- dida: { projects: ['limit'], tasks: ['projectId', 'query', 'limit'], read: ['id', 'projectId'], search: ['query'] },
15
+ dida: { projects: ['limit'], tasks: ['projectId', 'query', 'limit'], read: ['id', 'projectId'], search: ['query', 'limit'] },
16
16
  flomo: { search: ['query', 'limit'], recent: ['from', 'to', 'limit'], read: ['id', 'ids'] },
17
17
  };
18
- const READ_TOOLS = new Set(['search_threads', 'get_message', 'list_events', 'search_files', 'read_file_content', 'read_doc', 'get_values', 'read_presentation', 'list_projects', 'get_project_with_undone_tasks', 'get_project_tasks_bounded', 'get_named_project_with_undone_tasks', 'get_task_in_project', 'search', 'memo_search', 'memo_batch_get']);
18
+ const READ_TOOLS = new Set(['search_threads', 'get_message', 'list_events', 'search_files', 'read_file_content', 'read_doc', 'get_values', 'read_presentation', 'list_projects', 'get_project_with_undone_tasks', 'get_project_tasks_bounded', 'get_named_project_with_undone_tasks', 'get_task_in_project', 'search', 'search_task', 'list_all_tasks', 'memo_search', 'memo_batch_get']);
19
19
  const ARG_KEYS = {
20
20
  search_threads: ['query', 'pageSize', 'includeTrash', 'view'], get_message: ['messageId', 'messageFormat'],
21
21
  list_events: ['calendarId', 'startTime', 'endTime', 'orderBy', 'pageSize'], search_files: ['query', 'pageSize', 'excludeContentSnippets'],
22
22
  read_file_content: ['fileId', 'includeComments'], read_doc: ['documentId', 'commentsIncluded'], get_values: ['spreadsheetId', 'range'],
23
23
  read_presentation: ['presentationId', 'fields', 'commentsIncluded'], list_projects: ['limit', 'offset'],
24
- get_project_with_undone_tasks: ['project_id'], get_project_tasks_bounded: ['project_id','limit'], get_task_in_project: ['project_id', 'task_id'], search: ['query'],
24
+ get_project_with_undone_tasks: ['project_id'], get_project_tasks_bounded: ['project_id','limit'], get_task_in_project: ['project_id', 'task_id'], search: ['query','limit'], search_task: ['query','limit'], list_all_tasks: ['limit'],
25
25
  get_named_project_with_undone_tasks: ['project_name', 'limit'],
26
26
  memo_search: ['keywords', 'limit', 'start_date', 'end_date'], memo_batch_get: ['ids'],
27
27
  };
@@ -90,7 +90,7 @@ export function buildContextCall(source, input, { now = new Date() } = {}) {
90
90
  return make('get_project_with_undone_tasks', { project_id: id(input.projectId) });
91
91
  }
92
92
  if (operation === 'read') return make('get_task_in_project', { project_id: id(input.projectId), task_id: id(input.id) });
93
- if (operation === 'search') return make('search', { query: string(input.query) });
93
+ if (operation === 'search') return make('search', { query: string(input.query), ...(input.limit !== undefined ? { limit: limit(input.limit, 20) } : {}) });
94
94
  }
95
95
  if (source === 'flomo') {
96
96
  if (operation === 'search') return make('memo_search', { keywords: string(input.query), limit: limit(input.limit, 5) });
package/src/dida-rest.js CHANGED
@@ -7,7 +7,7 @@ import {validateContextCall} from './context-contracts.js';
7
7
  import {insufficientScope} from './context-transport.js';
8
8
 
9
9
  const ORIGIN='https://api.dida365.com';
10
- const MAX_BYTES=1024*1024,REQUEST_MS=20000,MAX_ITEMS=10;
10
+ const MAX_BYTES=1024*1024,REQUEST_MS=20000,MAX_ITEMS=10,SEARCH_ITEMS=50,MAX_ALL=1000,CONCURRENCY=3;
11
11
  const CONTROL=/[\u0000-\u001f\u007f]/u;
12
12
  const CODES=new Set(['CONTEXT_ARGUMENTS_INVALID','CONTEXT_UNSUPPORTED_OPERATION','CONTEXT_CANCELLED','CONTEXT_AUTH_REQUIRED','CONTEXT_INSUFFICIENT_SCOPE','CONTEXT_ABORTED','CONTEXT_TIMEOUT','CONTEXT_CLOSED','CONTEXT_HTTP_ERROR','CONTEXT_REDIRECT','CONTEXT_PROTOCOL_INVALID','CONTEXT_RESPONSE_TOO_LARGE','CONTEXT_CREDENTIALS_CHANGED']);
13
13
  const plain=v=>v!==null&&typeof v==='object'&&!Array.isArray(v);
@@ -16,12 +16,16 @@ const fail=code=>{throw error(code);};
16
16
  const validId=v=>typeof v==='string'&&/^[A-Za-z0-9_-]{1,512}$/u.test(v);
17
17
  const ident={type:'string',minLength:1,maxLength:512,pattern:'^[A-Za-z0-9_-]{1,512}$'};
18
18
  const tool=(name,properties)=>({name,inputSchema:{type:'object',additionalProperties:false,required:Object.keys(properties),properties}});
19
- const CATALOG={provenance:'bundled-contract',unsupportedOperations:['search'],tools:[
19
+ const searchTool=(name,required)=>({name,inputSchema:{type:'object',additionalProperties:false,required,properties:{...(required.includes('query')?{query:{type:'string',minLength:1,maxLength:120}}:{}) ,limit:{type:'integer',minimum:1,maximum:SEARCH_ITEMS}}}});
20
+ const CATALOG={provenance:'bundled-contract',tools:[
20
21
  tool('list_projects',{offset:{type:'integer',enum:[0]},limit:{type:'integer',minimum:1,maximum:MAX_ITEMS}}),
21
22
  tool('get_project_with_undone_tasks',{project_id:ident}),
22
23
  tool('get_project_tasks_bounded',{project_id:ident,limit:{type:'integer',minimum:1,maximum:MAX_ITEMS}}),
23
24
  tool('get_named_project_with_undone_tasks',{project_name:{type:'string',minLength:1,maxLength:180},limit:{type:'integer',minimum:1,maximum:MAX_ITEMS}}),
24
25
  tool('get_task_in_project',{project_id:ident,task_id:ident}),
26
+ searchTool('search_task',['query']),
27
+ searchTool('search',['query']),
28
+ searchTool('list_all_tasks',[]),
25
29
  ]};
26
30
 
27
31
  function validate(source,name,args){
@@ -126,6 +130,33 @@ export function createDidaRest({getToken,fetch:fetchImpl=globalThis.fetch,clock=
126
130
  }catch(e){if(CODES.has(e?.code))throw e;fail('CONTEXT_HTTP_ERROR');}
127
131
  const value=await readBody(reply,signal);await authorized(settings,signal);cancelled(settings);return value;
128
132
  };
133
+ if(name==='list_all_tasks'||name==='search_task'||name==='search'){
134
+ const take=Math.min(Number.isInteger(args.limit)?args.limit:20,SEARCH_ITEMS);
135
+ const key=name==='list_all_tasks'?null:String(args.query).toLowerCase();
136
+ const rows=await get(new URL('/open/v1/project',ORIGIN));
137
+ if(!Array.isArray(rows)||rows.length>MAX_ALL)fail('CONTEXT_PROTOCOL_INVALID');
138
+ const projects=rows.filter(row=>plain(row)&&validId(row.id)).slice(0,MAX_ALL);
139
+ const coverage={truncated:rows.length>MAX_ALL},collected=[];
140
+ for(let i=0;i<projects.length;i+=CONCURRENCY){
141
+ const batch=projects.slice(i,i+CONCURRENCY);
142
+ const pages=await Promise.all(batch.map(async row=>{
143
+ const raw=await get(new URL(`/open/v1/project/${encodeURIComponent(row.id)}/data`,ORIGIN));
144
+ if(!plain(raw)||!Array.isArray(raw.tasks))fail('CONTEXT_PROTOCOL_INVALID');
145
+ if(raw.project!==undefined&&(!plain(raw.project)||raw.project.id!==row.id))fail('CONTEXT_PROTOCOL_INVALID');
146
+ return raw.tasks.slice(0,MAX_ALL).map(t=>({row:t,projectId:row.id}));
147
+ }));
148
+ for(const page of pages)for(const entry of page)collected.push(entry);
149
+ }
150
+ collected.sort((a,b)=>{
151
+ const ta=Date.parse(a.row?.createdTime??a.row?.modifiedTime??'')||0;
152
+ const tb=Date.parse(b.row?.createdTime??b.row?.modifiedTime??'')||0;
153
+ return tb-ta;
154
+ });
155
+ const matched=key===null?collected:collected.filter(entry=>plain(entry.row)&&typeof entry.row.title==='string'&&`${entry.row.title}\n${entry.row.content??''}\n${entry.row.desc??''}`.toLowerCase().includes(key));
156
+ const items=matched.slice(0,take).map(entry=>task(entry.row,entry.projectId,null,coverage));
157
+ if(matched.length>take)coverage.truncated=true;
158
+ return{value:{items,truncated:coverage.truncated},fetchedAt:new Date(clock()).toISOString()};
159
+ }
129
160
  if(name==='get_named_project_with_undone_tasks'){
130
161
  const rows=await get(new URL('/open/v1/project',ORIGIN));
131
162
  if(!Array.isArray(rows)||rows.length>2048)fail('CONTEXT_PROTOCOL_INVALID');
@@ -134,7 +134,7 @@ export function createTaskResults({store,clock = () => new Date(),send = async (
134
134
  let closing = false;
135
135
  let closePromise;
136
136
  let storageFailed = false;
137
- const directClaims = new Map();
137
+ const directClaims = new Map(),mobileQuestions=new Map();
138
138
  const serial = work => { const run = queue.then(work); queue = run.catch(() => {}); return run; };
139
139
  const now = () => {
140
140
  const date = clock();
@@ -234,12 +234,26 @@ export function createTaskResults({store,clock = () => new Date(),send = async (
234
234
  if (closing) return;
235
235
  await load(); await expire();
236
236
  const {sessionId,messageId,turn,sourceKind}=event ?? {};
237
+ if(sourceKind==='user-question-reply'&&typeof event.sourceCallId==='string'){
238
+ const link=mobileQuestions.get(JSON.stringify([sessionId,event.sourceCallId])),job=link&&state.jobs.find(row=>row.id===link.jobId&&row.targetSessionId===sessionId&&LIVE.has(row.status));
239
+ if(job&&Number.isInteger(turn)&&turn>=0){
240
+ let claims=directClaims.get(sessionId);if(!claims){claims=new Map();directClaims.set(sessionId,claims);}
241
+ const existing=claims.get(turn);
242
+ if(existing&&(existing.mixed||existing.first!==job.targetMessageId)||!existing&&claims.size>=32){
243
+ if(existing)existing.mixed=true;
244
+ for(const other of state.jobs.filter(row=>row.targetSessionId===sessionId&&LIVE.has(row.status)&&(row.turn===turn||row.id===job.id)))stopMixed(other);
245
+ mobileQuestions.delete(JSON.stringify([sessionId,event.sourceCallId]));await save();return;
246
+ }
247
+ claims.set(turn,{first:job.targetMessageId,mixed:false});job.turn=turn;job.status='running';job.reply='';job.replyTruncated=false;mobileQuestions.delete(JSON.stringify([sessionId,event.sourceCallId]));await save();return;
248
+ }
249
+ }
250
+
237
251
  if (typeof sessionId!=='string' || typeof messageId!=='string' || !messageId || messageId.length>200 || !Number.isInteger(turn) || turn<0) return;
238
252
  const watching=state.jobs.filter(job=>job.targetSessionId===sessionId && LIVE.has(job.status));
239
253
  if (!watching.length) return;
240
254
  let claims=directClaims.get(sessionId);
241
255
  if (!claims) { claims=new Map(); directClaims.set(sessionId,claims); }
242
- if (sourceKind==='user') {
256
+ if (sourceKind==='user'||sourceKind==='user-question-reply') {
243
257
  if (!claims.has(turn) && claims.size>=32) {
244
258
  // An abnormal stream must fail closed instead of forgetting a prior
245
259
  // direct input and accidentally treating a later mixed turn as clean.
@@ -316,6 +330,10 @@ export function createTaskResults({store,clock = () => new Date(),send = async (
316
330
  if (event.type!=='turn/end') return;
317
331
  const rawReason=typeof event.reason==='string'?event.reason:event.reason?.kind;
318
332
  const reason=knownReasons.has(rawReason)?rawReason:'unknown';
333
+ if(reason==='completed'&&[...mobileQuestions.values()].some(link=>link.jobId===job.id)){
334
+ job.reply='';job.replyTruncated=false;await save();return;
335
+ }
336
+
319
337
  job.reason=reason; job.status=reason==='completed'?(job.reply?'completed':'no_text'):reason;
320
338
  if (job.status!=='completed') { job.reply=''; job.replyTruncated=false; }
321
339
  job.finishedAt=now().toISOString();
@@ -377,8 +395,22 @@ export function createTaskResults({store,clock = () => new Date(),send = async (
377
395
  const needsTimer = () => !closing && Boolean(state?.jobs.some(active));
378
396
  const close = () => {
379
397
  closing=true;
380
- closePromise ??= serial(async()=>{await load();directClaims.clear();});
398
+ closePromise ??= serial(async()=>{await load();directClaims.clear();mobileQuestions.clear();});
381
399
  return closePromise;
382
400
  };
383
- return {ready,byRequest,reviewOutcomes,prepare,admitted,notAdmitted,claimed,discarded,observe,status,inspect,trustedLastTarget,tick,needsTimer,close};
401
+ const mobileTaskScope = (sessionId,messageId,{expectedBinding}={}) => {
402
+ if(closing||storageFailed||!state)return null;
403
+ const matches=state.jobs.filter(job=>LIVE.has(job.status)&&job.targetSessionId===sessionId&&job.targetMessageId===messageId&&job.familyOrigin&&(!expectedBinding||job.returnBinding?.userHash===expectedBinding.userHash&&(job.returnBinding?.botHash??null)===(expectedBinding.botHash??null))&&now().getTime()<Date.parse(job.expiresAt));
404
+ if(matches.length!==1)return null;
405
+ const job=matches[0];return{jobId:job.id,origin:copy(job.familyOrigin),returnBinding:copy(job.returnBinding),label:job.projectLabel};
406
+ };
407
+ const mobileQuestionState=(sessionId,messageId,{callId,state:phase}={})=>{
408
+ if(typeof callId!=='string'||!callId||callId.length>200)return;
409
+ const scope=mobileTaskScope(sessionId,messageId);
410
+ if(!scope)return;
411
+ const key=JSON.stringify([sessionId,callId]);
412
+ if(phase==='closed'){if(mobileQuestions.get(key)?.jobId===scope.jobId)mobileQuestions.delete(key);}
413
+ else if(['open','continued','answered_continued'].includes(phase))mobileQuestions.set(key,{jobId:scope.jobId});
414
+ };
415
+ return {mobileQuestionState,mobileTaskScope,ready,byRequest,reviewOutcomes,prepare,admitted,notAdmitted,claimed,discarded,observe,status,inspect,trustedLastTarget,tick,needsTimer,close};
384
416
  }