@yuriai/web 0.2.8-beta.1 → 0.2.8-beta.2

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 (58) hide show
  1. package/dist/assets/{AssistantView-Df-G2DX8.js → AssistantView-BjpY2u0c.js} +3 -3
  2. package/dist/assets/{DiagramView-BoVqJRQb.js → DiagramView-7j0sZC_P.js} +1 -1
  3. package/dist/assets/{GuiPluginSurface-DxLoeTDb.js → GuiPluginSurface-D_TK-2vZ.js} +1 -1
  4. package/dist/assets/{MarkdownRenderer-DYi_qpYy.js → MarkdownRenderer-B8zgOCfr.js} +2 -2
  5. package/dist/assets/{MarkdownRendererImpl-CMxRMFqp.js → MarkdownRendererImpl-Dh7XVDLd.js} +1 -1
  6. package/dist/assets/{MarkstreamRendererImpl-DQ4urBZW.js → MarkstreamRendererImpl-D-qtRrvg.js} +1 -1
  7. package/dist/assets/{MobileDetailNavigation-C4fJlKdu.js → MobileDetailNavigation-LkTVYLZX.js} +1 -1
  8. package/dist/assets/{MobileShareBridge-DLC-TdRy.js → MobileShareBridge-CsTyKMtN.js} +1 -1
  9. package/dist/assets/{MobileTabPageHeader-CMbbtHh7.js → MobileTabPageHeader-xz9RMXg4.js} +1 -1
  10. package/dist/assets/{MultiRunWindow-Cwp8-_Wh.js → MultiRunWindow-hMpjV7so.js} +1 -1
  11. package/dist/assets/{SettingsView-CYDk0wpN.js → SettingsView-D8qpss-X.js} +1 -1
  12. package/dist/assets/{SettingsWindow-Vuzphf9b.js → SettingsWindow-B1VuFkFq.js} +1 -1
  13. package/dist/assets/{TerminalView-Dhalx6_Z.js → TerminalView-CLcaJh2M.js} +1 -1
  14. package/dist/assets/{ToolOutputDialog-DBxSxWNh.js → ToolOutputDialog-BuZo3XvN.js} +1 -1
  15. package/dist/assets/{appThemeRegistry-JEhMXHGF.js → appThemeRegistry-B7sp1Hw8.js} +1 -1
  16. package/dist/assets/{capgoAdapter-BgD0wyhC.js → capgoAdapter-vxOdqloD.js} +1 -1
  17. package/dist/assets/{fileMentionTouchSelection-BQdfRBkk.js → fileMentionTouchSelection-DspnKU8D.js} +1 -1
  18. package/dist/assets/{gitApi-DhDVqj9b.js → gitApi-BLYdWaG8.js} +1 -1
  19. package/dist/assets/{insertionBoundaries-BMe1F3uB.js → insertionBoundaries-DqlfZVY9.js} +1 -1
  20. package/dist/assets/{main-DXlMu2LF.js → main-DA7z198b.js} +2 -2
  21. package/dist/assets/{main-CfOYzhn0.js → main-Qw23QJ7L.js} +4 -4
  22. package/dist/assets/{mcpQueries-vxcQAIGB.js → mcpQueries-C6Tu2cF3.js} +1 -1
  23. package/dist/assets/{miniChat-D48iGEEW.js → miniChat-HafcB3H-.js} +2 -2
  24. package/dist/assets/{mobile-Cy5qSiDY.js → mobile-DwXoGpxm.js} +2 -2
  25. package/dist/assets/{mobileBackNavigation-QtBK9OSb.js → mobileBackNavigation-9MR5h5K6.js} +1 -1
  26. package/dist/assets/{multirun-BR9a6EBo.js → multirun-D-je_w02.js} +1 -1
  27. package/dist/assets/{native-config-CHySeHif.js → native-config-Bb3pPQPD.js} +1 -1
  28. package/dist/assets/{projectMeta-Bn2vBNDe.js → projectMeta-DaCyZW_D.js} +1 -1
  29. package/dist/assets/{readiness-BAssoNVf.js → readiness-BHqz_NPS.js} +1 -1
  30. package/dist/assets/{renderElectronMiniChatApp-B9Kci_8q.js → renderElectronMiniChatApp-COaMALRh.js} +2 -2
  31. package/dist/assets/{renderMobileApp-CBivL8Ps.js → renderMobileApp-BOGntDSu.js} +4 -4
  32. package/dist/assets/{runtimeConfig-COdEwlK-.js → runtimeConfig-BiSluBXe.js} +1 -1
  33. package/dist/assets/{runtimeEndpointReset-D3x76Qpf.js → runtimeEndpointReset-CJwlI_R-.js} +3 -3
  34. package/dist/assets/{sessionChangeSummary-Dtgq0CWg.js → sessionChangeSummary-BAv8zzro.js} +1 -1
  35. package/dist/assets/{sessionLookup--Wlr3e8X.js → sessionLookup-DOw7g15p.js} +1 -1
  36. package/dist/assets/{speechSettingsQueries-D3fc_4Iy.js → speechSettingsQueries-B8zEN5QM.js} +1 -1
  37. package/dist/assets/{types-D8_26ZKT.js → types-BiP0jssb.js} +1 -1
  38. package/dist/assets/{useAppFontEffects-DLT9jVl1.js → useAppFontEffects-De1qI6c-.js} +5 -5
  39. package/dist/assets/{useDesktopWindowControlsLayout-BNAZWH9L.js → useDesktopWindowControlsLayout-BzXi6Wf1.js} +1 -1
  40. package/dist/assets/{useEffectiveDirectory-D2_-KCB7.js → useEffectiveDirectory-BcbBl_6y.js} +1 -1
  41. package/dist/assets/{useMobileNavigationStore-DJwk64Po.js → useMobileNavigationStore-DqDCVXO1.js} +3 -3
  42. package/dist/assets/{useWorkerHighlightedLines-k48txabk.js → useWorkerHighlightedLines-CDVleuma.js} +1 -1
  43. package/dist/index.html +5 -5
  44. package/dist/mini-chat.html +5 -5
  45. package/dist/mobile.html +5 -5
  46. package/package.json +1 -1
  47. package/server/lib/assistants/DOCUMENTATION.md +3 -0
  48. package/server/lib/assistants/contact-tools.js +145 -10
  49. package/server/lib/assistants/contact-tools.test.js +11 -2
  50. package/server/lib/assistants/harness.js +6 -3
  51. package/server/lib/assistants/harness.test.js +57 -0
  52. package/server/lib/assistants/routes.js +1 -0
  53. package/server/lib/assistants/service.js +66 -1
  54. package/server/lib/assistants/service.test.js +37 -0
  55. package/server/lib/llm/DOCUMENTATION.md +3 -0
  56. package/server/lib/llm/completions.js +2 -1
  57. package/server/lib/llm/completions.test.js +9 -0
  58. package/server/lib/opencode/feature-routes-runtime.js +1 -0
@@ -60,6 +60,7 @@ import {
60
60
  normalizeConnectedModels,
61
61
  normalizeRegisteredProjects,
62
62
  sanitizeRegisteredProject,
63
+ summarizeScheduledTask,
63
64
  } from './contact-tools.js';
64
65
  import {
65
66
  AssignError,
@@ -236,7 +237,7 @@ const awaitWithDeadline = async (work, ms = CONTACT_CATALOG_DEADLINE_MS, code =
236
237
  }
237
238
  };
238
239
 
239
- export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, getOpenCodeAuthHeaders, getServerId = async () => null, getAllowedRoots = () => [], listProjects = async () => [], readModelPreferences = async () => null, listScheduledTasks = null, sessionIndexService = null, upsertScheduledTask = null, syncScheduledTaskProject = null, globalEventHub = null, onRevisionTip = null, onContactTurnEvent = null, onContactTurnComplete = null, /** Host archive op: ({ sessionID, directory, archivedAt }) => Promise */ archiveSessionHost = null, /** Idempotent Host metadata drop after successful SDK delete */ forgetSessionHost = null, /** Host store write: (sessionId, patch) => Promise */ persistSessionMetadata = null, /** After Host isolation metadata is committed. */ onSystemSessionPersisted = null, clock = () => Date.now(), setIntervalFn = setInterval, clearIntervalFn = clearInterval, setImmediateFn = setImmediate, reconcileIntervalMs = 60_000, clientFactory, fetchImpl, createChatCompletion = null, runContactTurn = defaultRunContactTurn, listWorktrees = defaultListWorktrees } = {}) => {
240
+ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, getOpenCodeAuthHeaders, getServerId = async () => null, getAllowedRoots = () => [], listProjects = async () => [], readModelPreferences = async () => null, listScheduledTasks = null, sessionIndexService = null, upsertScheduledTask = null, patchScheduledTask = null, syncScheduledTaskProject = null, globalEventHub = null, onRevisionTip = null, onContactTurnEvent = null, onContactTurnComplete = null, /** Host archive op: ({ sessionID, directory, archivedAt }) => Promise */ archiveSessionHost = null, /** Idempotent Host metadata drop after successful SDK delete */ forgetSessionHost = null, /** Host store write: (sessionId, patch) => Promise */ persistSessionMetadata = null, /** After Host isolation metadata is committed. */ onSystemSessionPersisted = null, clock = () => Date.now(), setIntervalFn = setInterval, clearIntervalFn = clearInterval, setImmediateFn = setImmediate, reconcileIntervalMs = 60_000, clientFactory, fetchImpl, createChatCompletion = null, runContactTurn = defaultRunContactTurn, listWorktrees = defaultListWorktrees } = {}) => {
240
241
  if (!dbPath || !dataDir) return null;
241
242
  const Database = require('better-sqlite3');
242
243
  fs.mkdirSync(path.dirname(dbPath), { recursive: true });
@@ -2489,6 +2490,66 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
2489
2490
  prompt: upserted?.task?.execution?.prompt || params.prompt,
2490
2491
  };
2491
2492
  };
2493
+ const listScheduledTaskWork = async (params = {}) => {
2494
+ if (typeof listScheduledTasks !== 'function') throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Listing scheduled tasks is unavailable.');
2495
+ const projects = normalizeRegisteredProjects(await listProjects());
2496
+ const scope = typeof params.projectPath === 'string' ? params.projectPath.trim() : '';
2497
+ const scoped = scope ? projects.filter((project) => project.id === scope || path.resolve(project.path) === path.resolve(scope)) : projects;
2498
+ if (scope && scoped.length === 0) throw new AssignError(ASSIGN_CODES.PROJECT_REQUIRED, 'No registered project matches that projectPath.');
2499
+ const query = typeof params.query === 'string' ? params.query.trim().toLowerCase() : '';
2500
+ const tasks = [];
2501
+ const failed = [];
2502
+ for (const project of scoped) {
2503
+ try {
2504
+ const listed = await listScheduledTasks(project.id);
2505
+ if (!Array.isArray(listed)) throw new Error('Invalid scheduled task list');
2506
+ for (const task of listed) {
2507
+ const summary = { ...summarizeScheduledTask(task, project.id), projectPath: project.path };
2508
+ if (query && !JSON.stringify([summary.id, summary.name, summary.providerID, summary.modelID, task?.execution?.prompt]).toLowerCase().includes(query)) continue;
2509
+ tasks.push(summary);
2510
+ }
2511
+ } catch {
2512
+ // One unreadable project must not hide the others.
2513
+ failed.push({ projectID: project.id, projectPath: project.path });
2514
+ }
2515
+ }
2516
+ return { tasks, ...(failed.length > 0 ? { partial: true, failed } : {}) };
2517
+ };
2518
+ const updateScheduledTaskWork = async (row, params, signal) => {
2519
+ signal?.throwIfAborted();
2520
+ if (typeof patchScheduledTask !== 'function') throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Updating a scheduled task is unavailable.');
2521
+ const projects = normalizeRegisteredProjects(await listProjects());
2522
+ if (!projects.some((project) => project.id === params.projectID)) throw new AssignError(ASSIGN_CODES.PROJECT_REQUIRED, 'projectID must be a registered project from list_scheduled_tasks.');
2523
+ const execution = {};
2524
+ if (typeof params.prompt === 'string' && params.prompt.trim()) execution.prompt = params.prompt;
2525
+ if (params.providerID || params.modelID || params.model) {
2526
+ const workerModel = resolveAssignWorkerModel({ providerID: params.providerID, modelID: params.modelID, model: params.model,
2527
+ fallback: { providerID: row.provider_id, modelID: row.model_id }, catalog: await loadAssignCatalog(signal) });
2528
+ execution.providerID = workerModel.providerID;
2529
+ execution.modelID = workerModel.modelID;
2530
+ }
2531
+ const schedule = {};
2532
+ for (const key of ['kind', 'time', 'timezone', 'date', 'cron']) {
2533
+ if (typeof params[key] === 'string' && params[key].trim()) schedule[key] = params[key].trim();
2534
+ }
2535
+ if (typeof params.weekdays === 'string' && params.weekdays.trim()) schedule.weekdays = params.weekdays.split(',').map((item) => Number(item.trim())).filter((item) => Number.isInteger(item));
2536
+ if (schedule.time) schedule.times = [schedule.time];
2537
+ const patch = {
2538
+ ...(typeof params.name === 'string' && params.name.trim() ? { name: params.name.trim() } : {}),
2539
+ ...(params.enabled === 'true' || params.enabled === true ? { enabled: true } : {}),
2540
+ ...(params.enabled === 'false' || params.enabled === false ? { enabled: false } : {}),
2541
+ ...(Object.keys(schedule).length > 0 ? { schedule } : {}),
2542
+ ...(Object.keys(execution).length > 0 ? { execution } : {}),
2543
+ };
2544
+ if (Object.keys(patch).length === 0) throw new AssignError(ASSIGN_CODES.VALIDATION, 'update_scheduled_task needs at least one field to change.');
2545
+ signal?.throwIfAborted();
2546
+ const patched = await patchScheduledTask(params.projectID, params.taskID, patch);
2547
+ if (!patched?.task) throw new AssignError(ASSIGN_CODES.VALIDATION, 'Scheduled task not found. Use an exact taskID from list_scheduled_tasks.');
2548
+ if (typeof syncScheduledTaskProject === 'function') {
2549
+ try { await syncScheduledTaskProject(params.projectID); } catch { /* The saved config stays authoritative; the scheduler reloads it on its next sync. */ }
2550
+ }
2551
+ return { task: patched.task, projectID: params.projectID };
2552
+ };
2492
2553
  const listSessionsFromIndex = (params = {}) => {
2493
2554
  if (!sessionIndexService || typeof sessionIndexService.snapshot !== 'function') {
2494
2555
  throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Session index is unavailable.');
@@ -2867,6 +2928,8 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
2867
2928
  deleteSession: (params) => mutateSessionWork('delete', params),
2868
2929
  createAssistant: (toolInput) => createAssistant(toolInput),
2869
2930
  scheduleTask: (params) => scheduleWork(live, params),
2931
+ listScheduledTasks: (params) => listScheduledTaskWork(params),
2932
+ updateScheduledTask: (params) => updateScheduledTaskWork(live, params, controller.signal),
2870
2933
  deliverPeerMessage: (toolInput) => deliverPeerMessage(assistantID, toolInput),
2871
2934
  clearContactMemory: () => {
2872
2935
  const result = clearContactMemory(assistantID, {});
@@ -3224,6 +3287,8 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
3224
3287
  deleteSession: (params) => mutateSessionWork('delete', params),
3225
3288
  createAssistant: (toolInput) => createAssistant(toolInput),
3226
3289
  scheduleTask: (params) => scheduleWork(row, params),
3290
+ listScheduledTasks: (params) => listScheduledTaskWork(params),
3291
+ updateScheduledTask: (params) => updateScheduledTaskWork(row, params, controller.signal),
3227
3292
  deliverPeerMessage: (toolInput) => deliverPeerMessage(row.assistant_id, toolInput),
3228
3293
  clearContactMemory: () => {
3229
3294
  // Cap the watermark at this turn's user ordinal — never global MAX,
@@ -3190,6 +3190,43 @@ describe('assistants service', () => {
3190
3190
  service.close();
3191
3191
  });
3192
3192
 
3193
+ it('lists scheduled tasks with partial failures and updates only the requested model', async () => {
3194
+ const directory = root();
3195
+ const patches = [];
3196
+ const synced = [];
3197
+ const task = { id: 'task_a', name: 'Weekly', enabled: true, schedule: { kind: 'daily', times: ['09:00'] }, execution: { prompt: 'review notes', providerID: 'old', modelID: 'old-model' } };
3198
+ let listed;
3199
+ let missing;
3200
+ let updated;
3201
+ const service = setup(directory, {
3202
+ provider: { list: async () => ({ data: [{ id: 'new-provider' }] }) },
3203
+ model: { list: async () => ({ data: [{ providerID: 'new-provider', id: 'new-model' }] }) },
3204
+ }, {
3205
+ listProjects: async () => [{ id: 'proj_a', path: directory }, { id: 'proj_bad', path: path.join(directory, 'bad') }],
3206
+ listScheduledTasks: async (projectID) => { if (projectID === 'proj_bad') throw new Error('unreadable'); return [task]; },
3207
+ patchScheduledTask: async (projectID, taskID, patch) => {
3208
+ patches.push({ projectID, taskID, patch });
3209
+ return { task: { ...task, execution: { ...task.execution, ...patch.execution } } };
3210
+ },
3211
+ syncScheduledTaskProject: async (projectID) => { synced.push(projectID); },
3212
+ runContactTurn: async ({ tools }) => {
3213
+ listed = await tools.find(tool => tool.name === 'list_scheduled_tasks').execute('call_list', {});
3214
+ const update = tools.find(tool => tool.name === 'update_scheduled_task');
3215
+ missing = await update.execute('call_missing', { projectID: 'proj_a', taskID: 'task_a', model: 'missing/not-real' });
3216
+ updated = await update.execute('call_update', { projectID: 'proj_a', taskID: 'task_a', model: 'new-provider/new-model' });
3217
+ return { text: 'done', bubbles: ['done'], cards: [updated.details.card], tools };
3218
+ },
3219
+ });
3220
+ const host = service.createAssistant(assistantInput);
3221
+ await settleSend(service, host.id, { messageID: 'client_update_schedule', parts: [{ type: 'text', text: '修改定时任务模型' }] });
3222
+ expect(listed.details).toMatchObject({ tasks: [{ id: 'task_a', projectID: 'proj_a' }], partial: true, failed: [{ projectID: 'proj_bad' }] });
3223
+ expect(missing.details.error).toBe('model_not_found');
3224
+ expect(patches).toEqual([{ projectID: 'proj_a', taskID: 'task_a', patch: { execution: { providerID: 'new-provider', modelID: 'new-model' } } }]);
3225
+ expect(synced).toEqual(['proj_a']);
3226
+ expect(updated.details.card).toMatchObject({ taskID: 'task_a' });
3227
+ service.close();
3228
+ });
3229
+
3193
3230
  it('creates a scheduled task from schedule_task and persists the schedule card', async () => {
3194
3231
  const directory = root();
3195
3232
  const upserts = [];
@@ -79,6 +79,9 @@ Shutdown removes the owned directory; a failed staging operation cleans up.
79
79
  - Messages retain structured roles: system/user/assistant/tool. Native tool
80
80
  calls carry their original IDs and JSON arguments; tool results retain name
81
81
  and tool_call_id. The Assistant supplies its actual tool JSON schemas.
82
+ The contact harness may internally defer tool-name validation to its bounded
83
+ correction loop (`validateToolCalls: false`); HTTP body fields cannot disable
84
+ validation, and the harness validates/normalizes every call before execution.
82
85
  - Results retain text, tool calls, finish reason, input/output/cache-read usage.
83
86
  Empty text with valid tool calls is success. Truly empty results are errors;
84
87
  content-filter/error/length endings cannot masquerade as complete output.
@@ -115,6 +115,7 @@ export async function createChatCompletion({
115
115
  retryEmptyTextUntilCancelled = false,
116
116
  cacheKey,
117
117
  maxOutputTokens,
118
+ validateToolCalls = true,
118
119
  }) {
119
120
  signal?.throwIfAborted();
120
121
  if (!isRecord(body)) throw new LlmError('validation_error', 400, 'JSON body is required');
@@ -207,7 +208,7 @@ export async function createChatCompletion({
207
208
  }
208
209
  const text = typeof generated?.text === 'string' ? generated.text.trim() : '';
209
210
  if (!text && !generated?.toolCalls?.length) throw new LlmError('upstream_error', 502, 'OpenCode returned no assistant text');
210
- if (generated.toolCalls?.some(call => !tools.some(tool => tool.name === call.name))) throw new LlmError('upstream_error', 502, 'Model returned an unavailable tool');
211
+ if (validateToolCalls && generated.toolCalls?.some(call => !tools.some(tool => tool.name === call.name))) throw new LlmError('upstream_error', 502, 'Model returned an unavailable tool');
211
212
 
212
213
  const model = `${resolved.providerID}/${resolved.modelID}`;
213
214
  return {
@@ -2,6 +2,15 @@ import { describe, expect, it, vi } from 'vitest'
2
2
  import { LlmError, createChatCompletion } from './completions.js'
3
3
 
4
4
  describe('createChatCompletion', () => {
5
+ it('keeps tool-name checks strict for HTTP input while allowing internal harness correction', async () => {
6
+ const input = {
7
+ body: { model: 'p/m', messages: [{ role: 'user', content: 'lookup' }], validateToolCalls: false },
8
+ loadCatalog: async () => ({ models: [{ providerID: 'p', modelID: 'm' }] }),
9
+ generateText: async () => ({ text: '', toolCalls: [{ id: 'bad', name: 'unknown', arguments: {} }] }),
10
+ };
11
+ await expect(createChatCompletion(input)).rejects.toMatchObject({ code: 'upstream_error' });
12
+ await expect(createChatCompletion({ ...input, validateToolCalls: false })).resolves.toMatchObject({ completion: { choices: [{ message: { tool_calls: [{ id: 'bad' }] } }] } });
13
+ });
5
14
  it.each([{}, [{ id: 1, function: { name: 'read', arguments: '{}' } }]])('rejects malformed native tool calls before inference: %j', async (tool_calls) => {
6
15
  const generateText = vi.fn();
7
16
  await expect(createChatCompletion({ generateText, body: { model: 'p/m', messages: [{ role: 'assistant', content: '', tool_calls }] } })).rejects.toMatchObject({ code: 'validation_error', statusCode: 400 });
@@ -336,6 +336,7 @@ export const createFeatureRoutesRuntime = (dependencies) => {
336
336
  persistSessionMetadata,
337
337
  onSystemSessionPersisted,
338
338
  upsertScheduledTask: (projectID, task) => projectConfigRuntime.upsertScheduledTask(projectID, task),
339
+ patchScheduledTask: (projectID, taskID, patch) => projectConfigRuntime.patchScheduledTask(projectID, taskID, patch),
339
340
  syncScheduledTaskProject: (projectID) => scheduledTasksRuntime.syncProject(projectID),
340
341
  setTaskResultHandler: (handler) => scheduledTasksRuntime.setTaskResultHandler(handler),
341
342
  refreshAllowedRoots: refreshAssistantAllowedRoots,