@vibedeckx/darwin-arm64 0.3.45 → 0.3.46

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/dist/bin.js +331 -66
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -188008,7 +188008,7 @@ var mapRule = (row) => ({
188008
188008
  });
188009
188009
  var createWorkspaceRepos = (kdb, h) => ({
188010
188010
  tasks: {
188011
- create: async ({ id, project_id, title, description, status, priority, assigned_branch }) => {
188011
+ create: async ({ id, project_id, title, description, status, priority, assigned_branch, source }) => {
188012
188012
  await kdb.insertInto("tasks").values((eb) => ({
188013
188013
  id,
188014
188014
  project_id,
@@ -188017,10 +188017,25 @@ var createWorkspaceRepos = (kdb, h) => ({
188017
188017
  status: status ?? "todo",
188018
188018
  priority: priority ?? "medium",
188019
188019
  assigned_branch: assigned_branch ?? null,
188020
- position: eb.selectFrom("tasks").select(sql`coalesce(max(position), -1) + 1`.as("next_position")).where("project_id", "=", project_id)
188021
- })).execute();
188022
- const row = await kdb.selectFrom("tasks").selectAll().where("id", "=", id).executeTakeFirstOrThrow();
188023
- return mapTask2(row);
188020
+ position: eb.selectFrom("tasks").select(sql`coalesce(max(position), -1) + 1`.as("next_position")).where("project_id", "=", project_id),
188021
+ source_session_id: source?.session_id ?? null,
188022
+ source_tool_use_id: source?.tool_use_id ?? null,
188023
+ source_item_index: source?.item_index ?? null
188024
+ // DO NOTHING only for a proposal, so a concurrent replay races into
188025
+ // idx_tasks_source and is resolved below (same argument as
188026
+ // scheduledTasks.create); a plain insert keeps failing loudly.
188027
+ })).$if(!!source, (qb) => qb.onConflict((oc) => oc.doNothing())).execute();
188028
+ const row = await kdb.selectFrom("tasks").selectAll().where("id", "=", id).executeTakeFirst();
188029
+ if (row) return mapTask2(row);
188030
+ if (source) {
188031
+ const existing = await kdb.selectFrom("tasks").selectAll().where("project_id", "=", project_id).where("source_session_id", "=", source.session_id).where("source_tool_use_id", "=", source.tool_use_id).where("source_item_index", "=", source.item_index).executeTakeFirst();
188032
+ if (existing) return mapTask2(existing);
188033
+ }
188034
+ throw new Error(`Failed to create task ${id}`);
188035
+ },
188036
+ listOpenIdsBySourceSession: async (sessionId) => {
188037
+ const rows = await kdb.selectFrom("tasks").select("id").where("source_session_id", "=", sessionId).where("source_tool_use_id", "is not", null).where("archived_at", "is", null).where("status", "in", ["todo", "in_progress"]).orderBy("id", "asc").execute();
188038
+ return rows.map((row) => row.id);
188024
188039
  },
188025
188040
  getByProjectId: async (projectId, opts) => {
188026
188041
  let query = kdb.selectFrom("tasks").selectAll().where("project_id", "=", projectId);
@@ -205293,6 +205308,16 @@ var initializeSchema = (db) => {
205293
205308
  if (!hasArchivedAtColumn) {
205294
205309
  db.exec("ALTER TABLE tasks ADD COLUMN archived_at INTEGER DEFAULT NULL");
205295
205310
  }
205311
+ const taskSourceInfo = db.prepare("PRAGMA table_info(tasks)").all();
205312
+ if (!taskSourceInfo.some((col) => col.name === "source_session_id")) {
205313
+ db.exec("ALTER TABLE tasks ADD COLUMN source_session_id TEXT");
205314
+ }
205315
+ if (!taskSourceInfo.some((col) => col.name === "source_tool_use_id")) {
205316
+ db.exec("ALTER TABLE tasks ADD COLUMN source_tool_use_id TEXT");
205317
+ }
205318
+ if (!taskSourceInfo.some((col) => col.name === "source_item_index")) {
205319
+ db.exec("ALTER TABLE tasks ADD COLUMN source_item_index INTEGER");
205320
+ }
205296
205321
  const sessionTableInfo = db.prepare("PRAGMA table_info(agent_sessions)").all();
205297
205322
  const hasWorktreePathColumn = sessionTableInfo.some((col) => col.name === "worktree_path");
205298
205323
  if (hasWorktreePathColumn) {
@@ -206132,6 +206157,12 @@ var initializeSchema = (db) => {
206132
206157
  );
206133
206158
  `);
206134
206159
  db.exec(`
206160
+ -- Idempotency for agent-proposed tasks, one row per proposed item; same
206161
+ -- reasoning as idx_scheduled_tasks_source. Also serves the retention-hold
206162
+ -- lookup by source session.
206163
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_tasks_source
206164
+ ON tasks(source_session_id, source_tool_use_id, source_item_index)
206165
+ WHERE source_tool_use_id IS NOT NULL;
206135
206166
  CREATE INDEX IF NOT EXISTS idx_tasks_project_archived_position_id
206136
206167
  ON tasks(project_id, archived_at, position ASC, id ASC);
206137
206168
  CREATE INDEX IF NOT EXISTS idx_tasks_project_archived_status_position_id
@@ -206493,6 +206524,8 @@ var SESSION_TOOLS_MCP_PATH = "/api/session-mcp";
206493
206524
  var SESSION_TOOLS_MCP_SERVER_NAME = "vibedeckx";
206494
206525
  var PROPOSE_SCHEDULE_TOOL = "propose_schedule";
206495
206526
  var CANONICAL_PROPOSE_SCHEDULE_TOOL = `mcp__${SESSION_TOOLS_MCP_SERVER_NAME}__${PROPOSE_SCHEDULE_TOOL}`;
206527
+ var PROPOSE_TASK_TOOL = "propose_task";
206528
+ var CANONICAL_PROPOSE_TASK_TOOL = `mcp__${SESSION_TOOLS_MCP_SERVER_NAME}__${PROPOSE_TASK_TOOL}`;
206496
206529
  var PROPOSE_SCHEDULE_DESCRIPTION = [
206497
206530
  "Propose a recurring scheduled check to the user. This is the only way to schedule work in this",
206498
206531
  "environment. Call it in either situation:",
@@ -206526,12 +206559,15 @@ var PROPOSE_SCHEDULE_DESCRIPTION = [
206526
206559
  "Project, execution target and branch are taken from this session \u2014 do not describe them here."
206527
206560
  ].join("\n");
206528
206561
  var ARTIFACT_PATH_HINT = "Files for the user to look at: when you produce a screenshot, image, or report file for the user, write its absolute path on its own line in your reply so it can be previewed.";
206562
+ var TASK_ROUTING_HINT = `Tasks: when the user asks to record something as a task or to-do for later, call \`${CANONICAL_PROPOSE_TASK_TOOL}\` to propose it, and do not do the work itself now. Never call it, or suggest creating a task, unless the user asks.`;
206529
206563
  var SESSION_TOOLS_MCP_INSTRUCTIONS = [
206530
206564
  `\`${PROPOSE_SCHEDULE_TOOL}\` is the only way to schedule work in this environment.`,
206531
206565
  'When the user asks for anything recurring \u2014 nightly, hourly, every morning, on a cron, "keep',
206532
206566
  'watching" \u2014 call it instead of writing a crontab entry, systemd timer, or setInterval loop.',
206533
206567
  "Scheduling inside the user's own product remains ordinary coding work.",
206534
206568
  "",
206569
+ TASK_ROUTING_HINT,
206570
+ "",
206535
206571
  ARTIFACT_PATH_HINT
206536
206572
  ].join("\n");
206537
206573
  var SESSION_TOOLS_SYSTEM_PROMPT_HINT = [
@@ -206539,6 +206575,7 @@ var SESSION_TOOLS_SYSTEM_PROMPT_HINT = [
206539
206575
  `morning, on a cron, "keep watching"), call the \`${CANONICAL_PROPOSE_SCHEDULE_TOOL}\` tool. That`,
206540
206576
  "is the only way to schedule work here \u2014 do not hand-roll a crontab entry, systemd timer, or",
206541
206577
  "setInterval loop for it. Writing scheduling into the user's own project is still normal coding.",
206578
+ TASK_ROUTING_HINT,
206542
206579
  ARTIFACT_PATH_HINT
206543
206580
  ].join(" ");
206544
206581
  var PROPOSE_SCHEDULE_INPUT_SCHEMA = {
@@ -206580,19 +206617,96 @@ function parseProposeScheduleArgs(args) {
206580
206617
  }
206581
206618
  return { ok: true, value: { name: name25, cron_expr: cronExpr, run_type, content, ...timezone ? { timezone } : {} } };
206582
206619
  }
206583
- var PROPOSE_SCHEDULE_ALIASES = new Set(
206620
+ var PROPOSE_TASK_DESCRIPTION = [
206621
+ "Propose one or more tasks for the project's task list: work to be done LATER, recorded so it",
206622
+ `isn't lost. Call this only when the user asks to record work as a task ("make this a task",`,
206623
+ '"add a to-do for the skipped test"). Never call it on your own initiative.',
206624
+ "",
206625
+ 'Do not do the work. Even when the task reads like an instruction ("add error handling to X"),',
206626
+ "the user is asking you to write it down, not to carry it out now.",
206627
+ "",
206628
+ "The proposal is shown to the user as a confirmation card; it does NOT create anything by itself",
206629
+ "and this call does not wait for the user. Say you have proposed the task (never that you created",
206630
+ "it) and continue.",
206631
+ "",
206632
+ "Each description must be self-contained: the task may be picked up later in a fresh session with",
206633
+ "none of this conversation's context. Cover the background, the relevant files, what remains to",
206634
+ "be done, and how to tell it is finished. Propose several tasks in one call when the user asks to",
206635
+ "split the work.",
206636
+ "",
206637
+ "Project and source session are taken from this session \u2014 do not describe them here."
206638
+ ].join("\n");
206639
+ var PROPOSE_TASK_INPUT_SCHEMA = {
206640
+ type: "object",
206641
+ properties: {
206642
+ tasks: {
206643
+ type: "array",
206644
+ minItems: 1,
206645
+ maxItems: 5,
206646
+ description: "The tasks to propose, usually one.",
206647
+ items: {
206648
+ type: "object",
206649
+ properties: {
206650
+ title: { type: "string", description: 'Short, specific title, e.g. "Cover remote path in retention-hold tests"' },
206651
+ description: { type: "string", description: "Self-contained description: background, relevant files, remaining work, definition of done." },
206652
+ priority: { type: "string", enum: ["low", "medium", "high", "urgent"], description: "Optional; defaults to medium." }
206653
+ },
206654
+ required: ["title", "description"]
206655
+ }
206656
+ }
206657
+ },
206658
+ required: ["tasks"]
206659
+ };
206660
+ var PROPOSE_TASK_ACK = "Proposal shown to the user as a confirmation card. Nothing has been created yet \u2014 the user decides whether to accept it. Tell the user you PROPOSED the task and that they can confirm it on the card above. Do not start working on it.";
206661
+ var PROPOSE_TASK_MAX_ITEMS = 5;
206662
+ var TASK_TITLE_MAX = 200;
206663
+ var TASK_DESCRIPTION_MAX = 2e4;
206664
+ var TASK_PRIORITIES = ["low", "medium", "high", "urgent"];
206665
+ function parseProposeTaskArgs(args) {
206666
+ const raw = args.tasks;
206667
+ if (!Array.isArray(raw) || raw.length === 0) return { ok: false, error: "tasks must be a non-empty array" };
206668
+ if (raw.length > PROPOSE_TASK_MAX_ITEMS) {
206669
+ return { ok: false, error: `propose at most ${PROPOSE_TASK_MAX_ITEMS} tasks at a time` };
206670
+ }
206671
+ const tasks = [];
206672
+ for (const [i, item] of raw.entries()) {
206673
+ const obj = item && typeof item === "object" ? item : {};
206674
+ const title = str(obj.title);
206675
+ if (!title) return { ok: false, error: `tasks[${i}].title is required` };
206676
+ if (title.length > TASK_TITLE_MAX) {
206677
+ return { ok: false, error: `tasks[${i}].title must be at most ${TASK_TITLE_MAX} characters` };
206678
+ }
206679
+ const description = str(obj.description);
206680
+ if (!description) return { ok: false, error: `tasks[${i}].description is required` };
206681
+ if (description.length > TASK_DESCRIPTION_MAX) {
206682
+ return { ok: false, error: `tasks[${i}].description must be at most ${TASK_DESCRIPTION_MAX} characters` };
206683
+ }
206684
+ const priorityRaw = str(obj.priority)?.toLowerCase();
206685
+ if (priorityRaw && !TASK_PRIORITIES.includes(priorityRaw)) {
206686
+ return { ok: false, error: `tasks[${i}].priority must be one of: ${TASK_PRIORITIES.join(", ")}` };
206687
+ }
206688
+ tasks.push({ title, description, priority: priorityRaw || "medium" });
206689
+ }
206690
+ return { ok: true, value: tasks };
206691
+ }
206692
+ var aliasesOf = (tool2, canonical) => new Set(
206584
206693
  [
206585
- PROPOSE_SCHEDULE_TOOL,
206586
- CANONICAL_PROPOSE_SCHEDULE_TOOL,
206587
- `${SESSION_TOOLS_MCP_SERVER_NAME}.${PROPOSE_SCHEDULE_TOOL}`,
206588
- `${SESSION_TOOLS_MCP_SERVER_NAME}/${PROPOSE_SCHEDULE_TOOL}`,
206589
- `${SESSION_TOOLS_MCP_SERVER_NAME}__${PROPOSE_SCHEDULE_TOOL}`,
206590
- `${SESSION_TOOLS_MCP_SERVER_NAME}-${PROPOSE_SCHEDULE_TOOL}`
206694
+ tool2,
206695
+ canonical,
206696
+ `${SESSION_TOOLS_MCP_SERVER_NAME}.${tool2}`,
206697
+ `${SESSION_TOOLS_MCP_SERVER_NAME}/${tool2}`,
206698
+ `${SESSION_TOOLS_MCP_SERVER_NAME}__${tool2}`,
206699
+ `${SESSION_TOOLS_MCP_SERVER_NAME}-${tool2}`
206591
206700
  ].map((n) => n.toLowerCase())
206592
206701
  );
206702
+ var SESSION_TOOL_ALIASES = [
206703
+ [aliasesOf(PROPOSE_SCHEDULE_TOOL, CANONICAL_PROPOSE_SCHEDULE_TOOL), CANONICAL_PROPOSE_SCHEDULE_TOOL],
206704
+ [aliasesOf(PROPOSE_TASK_TOOL, CANONICAL_PROPOSE_TASK_TOOL), CANONICAL_PROPOSE_TASK_TOOL]
206705
+ ];
206593
206706
  function canonicalizeSessionToolName(tool2, server) {
206594
206707
  if (server !== void 0 && server.trim().toLowerCase() !== SESSION_TOOLS_MCP_SERVER_NAME) return tool2;
206595
- return PROPOSE_SCHEDULE_ALIASES.has(tool2.trim().toLowerCase()) ? CANONICAL_PROPOSE_SCHEDULE_TOOL : tool2;
206708
+ const key2 = tool2.trim().toLowerCase();
206709
+ return SESSION_TOOL_ALIASES.find(([aliases]) => aliases.has(key2))?.[1] ?? tool2;
206596
206710
  }
206597
206711
  async function mintSessionToolsMcpConfig(deps, args) {
206598
206712
  const origin = args.origin?.trim();
@@ -208252,6 +208366,48 @@ function scheduleHoldSource(storage2) {
208252
208366
  listHolders: (sessionId) => storage2.scheduledTasks.listIdsBySourceSession(sessionId)
208253
208367
  };
208254
208368
  }
208369
+ function taskHoldSource(storage2) {
208370
+ return {
208371
+ kind: "task",
208372
+ listHolders: (sessionId) => storage2.tasks.listOpenIdsBySourceSession(sessionId)
208373
+ };
208374
+ }
208375
+ function subscribeTaskHoldSync(eventBus, holds) {
208376
+ return eventBus.subscribe((event) => {
208377
+ if (event.type !== "task:updated") return;
208378
+ const sourceSessionId = event.task.source_session_id;
208379
+ if (typeof sourceSessionId !== "string" || !sourceSessionId) return;
208380
+ void holds.sync(sourceSessionId).catch((error48) => {
208381
+ console.warn(`[RetentionHolds] task hold sync for ${sourceSessionId} deferred:`, error48);
208382
+ });
208383
+ });
208384
+ }
208385
+ function taskHoldsSource(task) {
208386
+ return !!task.source_session_id && !!task.source_tool_use_id && task.archived_at === null && (task.status === "todo" || task.status === "in_progress");
208387
+ }
208388
+ async function applyTaskChange(deps, taskId, apply, revert) {
208389
+ const existing = await deps.storage.tasks.getById(taskId);
208390
+ if (!existing?.source_session_id) return apply();
208391
+ return deps.retentionHolds.exclusive(existing.source_session_id, async (syncNow) => {
208392
+ const before = await deps.storage.tasks.getById(taskId);
208393
+ if (!before) return void 0;
208394
+ const task = await apply();
208395
+ if (!task || taskHoldsSource(before) || !taskHoldsSource(task)) return task;
208396
+ try {
208397
+ await syncNow();
208398
+ return task;
208399
+ } catch (error48) {
208400
+ await revert(before);
208401
+ await syncNow().catch(() => void 0);
208402
+ throw error48;
208403
+ }
208404
+ });
208405
+ }
208406
+ function revertTaskPatch(storage2, taskId, patch) {
208407
+ return (before) => storage2.tasks.update(taskId, Object.fromEntries(
208408
+ Object.keys(patch).filter((key2) => patch[key2] !== void 0).map((key2) => [key2, before[key2]])
208409
+ ));
208410
+ }
208255
208411
 
208256
208412
  // src/agent-session-manager.ts
208257
208413
  import { spawn as spawn3 } from "child_process";
@@ -208347,7 +208503,7 @@ var ClaudeCodeProvider = class {
208347
208503
  permissionMode,
208348
208504
  Object.keys(mcpServers).length > 0 ? buildClaudeMcpConfigArg(mcpServers) : void 0,
208349
208505
  model,
208350
- sessionToolsMcp ? [CANONICAL_PROPOSE_SCHEDULE_TOOL] : void 0,
208506
+ sessionToolsMcp ? [CANONICAL_PROPOSE_SCHEDULE_TOOL, CANONICAL_PROPOSE_TASK_TOOL] : void 0,
208351
208507
  sessionToolsMcp ? SESSION_TOOLS_SYSTEM_PROMPT_HINT : void 0
208352
208508
  );
208353
208509
  }
@@ -230672,6 +230828,7 @@ async function appendRemoteGrantContext(storage2, sessionId, userId, content) {
230672
230828
  // src/utils/conversation-title.ts
230673
230829
  var TITLE_MAX_CHARS = 60;
230674
230830
  var VSCHEDULE_BLOCK_RE = /<vschedule(?:\s[^>]*)?>[\s\S]*?<\/vschedule>/g;
230831
+ var VTASK_BLOCK_RE = /<vtask(?:\s[^>]*)?>[\s\S]*?<\/vtask>/g;
230675
230832
  var AI_TIMEOUT_MS = 15e3;
230676
230833
  var MAX_INPUT_CHARS = 2e3;
230677
230834
  var SYSTEM_PROMPT = "You write very short, descriptive titles for chat conversations. Reply with the title only \u2014 no quotes, no trailing punctuation, no markdown, no prefixes like 'Title:'. Use the same language as the user's message. Keep it under 8 words and 50 characters.";
@@ -230688,7 +230845,7 @@ async function isChatModelConfigured(storage2, userId) {
230688
230845
  }
230689
230846
  function extractUserText(content) {
230690
230847
  const text2 = typeof content === "string" ? content : content.filter((p2) => p2.type === "text").map((p2) => p2.text).join(" ");
230691
- return stripRemoteGrantContext(text2.replace(VSCHEDULE_BLOCK_RE, ""));
230848
+ return stripRemoteGrantContext(text2.replace(VSCHEDULE_BLOCK_RE, "").replace(VTASK_BLOCK_RE, ""));
230692
230849
  }
230693
230850
  function snippetTitle(text2) {
230694
230851
  const trimmed = text2.trim();
@@ -238596,6 +238753,7 @@ function createRemoteProjectSessionReader(options) {
238596
238753
  }
238597
238754
  };
238598
238755
  }
238756
+ var applyTaskChangeDirectly = (_taskId, apply) => apply();
238599
238757
  var emptySchema = external_exports.object({}).strict();
238600
238758
  var selectorSchema = external_exports.string().min(1).max(MAX_TOOL_SELECTOR_ID);
238601
238759
  var taskStatusSchema = external_exports.enum(["todo", "in_progress", "done", "cancelled"]);
@@ -239103,10 +239261,15 @@ async function createProjectChatTools(options) {
239103
239261
  const current = await storage2.tasks.getById(taskId);
239104
239262
  if (!current || current.project_id !== projectId) throw new Error("Task is no longer authorized");
239105
239263
  await validateAssignedBranch(assignedBranch);
239106
- const updated = await storage2.tasks.update(taskId, {
239264
+ const storagePatch = {
239107
239265
  ...patch,
239108
239266
  ...assignedBranch !== void 0 ? { assigned_branch: assignedBranch } : {}
239109
- });
239267
+ };
239268
+ const updated = await (options.applyTaskChange ?? applyTaskChangeDirectly)(
239269
+ taskId,
239270
+ () => storage2.tasks.update(taskId, storagePatch),
239271
+ revertTaskPatch(storage2, taskId, storagePatch)
239272
+ );
239110
239273
  if (!updated) throw new Error("Task update failed");
239111
239274
  await touch("task", taskId);
239112
239275
  await finishOperation(operation, "completed", { taskId, title: updated.title });
@@ -240802,10 +240965,15 @@ var ProjectChatManager = class {
240802
240965
  }
240803
240966
  try {
240804
240967
  const { assignedBranch, ...patch } = payload.patch;
240805
- const updated = await this.storage.tasks.update(payload.taskId, {
240968
+ const storagePatch = {
240806
240969
  ...patch,
240807
240970
  ...assignedBranch !== void 0 ? { assigned_branch: assignedBranch } : {}
240808
- });
240971
+ };
240972
+ const updated = await (this.toolDependencies?.applyTaskChange ?? applyTaskChangeDirectly)(
240973
+ payload.taskId,
240974
+ () => this.storage.tasks.update(payload.taskId, storagePatch),
240975
+ revertTaskPatch(this.storage, payload.taskId, storagePatch)
240976
+ );
240809
240977
  if (!updated) throw new Error("Task update failed");
240810
240978
  } catch (error48) {
240811
240979
  console.warn(`[ProjectChat] task update ${operation.id} remains retryable:`, boundedStreamError(error48).message);
@@ -248832,6 +249000,12 @@ var sharedServices = async (fastify2, opts) => {
248832
249000
  }
248833
249001
  }
248834
249002
  const reverseConnectManager = new ReverseConnectManager();
249003
+ const retentionHolds = new RetentionHoldSync({
249004
+ storage: opts.storage,
249005
+ reverseConnectManager,
249006
+ remoteSessionMap,
249007
+ sources: [scheduleHoldSource(opts.storage), taskHoldSource(opts.storage)]
249008
+ });
248835
249009
  const browserManager = new BrowserManager();
248836
249010
  const remoteExecutorMonitor = new RemoteExecutorMonitor(reverseConnectManager, eventBus, opts.storage, remoteExecutorMap);
248837
249011
  const scheduler = new SchedulerService(opts.storage, processManager, {
@@ -248865,6 +249039,7 @@ var sharedServices = async (fastify2, opts) => {
248865
249039
  toolDependencies: {
248866
249040
  agentSessionManager,
248867
249041
  remoteSessions: projectChatRemoteSessions,
249042
+ applyTaskChange: (taskId, apply, revert) => applyTaskChange({ storage: opts.storage, retentionHolds }, taskId, apply, revert),
248868
249043
  mutationServices: {
248869
249044
  // Prepared-session lifecycle §10.3: one `start` under the operation's
248870
249045
  // own idempotency key. A replay of the same operation returns the
@@ -249085,13 +249260,8 @@ var sharedServices = async (fastify2, opts) => {
249085
249260
  fastify2.decorate("reverseConnectManager", reverseConnectManager);
249086
249261
  fastify2.decorate("browserManager", browserManager);
249087
249262
  fastify2.decorate("scheduler", scheduler);
249088
- const retentionHolds = new RetentionHoldSync({
249089
- storage: opts.storage,
249090
- reverseConnectManager,
249091
- remoteSessionMap,
249092
- sources: [scheduleHoldSource(opts.storage)]
249093
- });
249094
249263
  fastify2.decorate("retentionHolds", retentionHolds);
249264
+ subscribeTaskHoldSync(eventBus, retentionHolds);
249095
249265
  const releaseStaleHolds = (remoteServerId) => {
249096
249266
  void retentionHolds.releaseStale(remoteServerId).then((failed) => {
249097
249267
  if (failed > 0) console.warn(`[RetentionHolds] ${failed} session(s) on ${remoteServerId} not re-synced`);
@@ -256956,7 +257126,46 @@ var project_activity_routes_default = (0, import_fastify_plugin18.default)(route
256956
257126
  // src/routes/task-routes.ts
256957
257127
  var import_fastify_plugin19 = __toESM(require_plugin2(), 1);
256958
257128
  import { randomUUID as randomUUID22 } from "crypto";
257129
+
257130
+ // src/routes/source-sessions.ts
257131
+ var SOURCE_ID_MAX = 200;
257132
+ var validSourceId = (value) => typeof value === "string" && value.length > 0 && value.length <= SOURCE_ID_MAX && value.trim() === value;
257133
+ async function isProjectSourceSession(storage2, sessionId, projectId) {
257134
+ const sourceSession = await storage2.agentSessions.getById(sessionId);
257135
+ return sourceSession ? sourceSession.project_id === projectId : !!await storage2.remoteSessionMappings.getAuthorizedByLocal(sessionId, projectId);
257136
+ }
257137
+ async function resolveSourceSessions(storage2, ids) {
257138
+ const unique = [...new Set(ids)];
257139
+ const remoteIds = unique.filter((id) => id.startsWith("remote-"));
257140
+ const remoteTitles = await storage2.searchCache.getCachedSessionTitles(remoteIds);
257141
+ const branchOf2 = async (row) => {
257142
+ if (!row) return null;
257143
+ const registered = row.workspace_checkout_id ? await storage2.workspaceRegistry.getCheckoutById(row.workspace_checkout_id) : void 0;
257144
+ return (registered ? registered.workspace.branch : row.branch) || null;
257145
+ };
257146
+ const out = /* @__PURE__ */ new Map();
257147
+ await Promise.all(unique.map(async (id) => {
257148
+ if (id.startsWith("remote-")) {
257149
+ const mapping = await storage2.remoteSessionMappings.getByLocal(id);
257150
+ out.set(id, {
257151
+ id,
257152
+ exists: !!mapping,
257153
+ branch: await branchOf2(mapping),
257154
+ title: remoteTitles.get(id) ?? null
257155
+ });
257156
+ return;
257157
+ }
257158
+ const session = await storage2.agentSessions.getById(id);
257159
+ out.set(id, { id, exists: !!session, branch: await branchOf2(session), title: session?.title ?? null });
257160
+ }));
257161
+ return out;
257162
+ }
257163
+
257164
+ // src/routes/task-routes.ts
257165
+ var SOURCE_ITEM_INDEX_MAX = 100;
256959
257166
  var routes18 = async (fastify2) => {
257167
+ const applyHoldingChange = (taskId, apply, revert) => applyTaskChange(fastify2, taskId, apply, revert);
257168
+ const holdFailed = (error48) => `Could not protect the source session from retention: ${error48 instanceof Error ? error48.message : String(error48)}`;
256960
257169
  fastify2.get(
256961
257170
  "/api/projects/:projectId/tasks",
256962
257171
  async (req, reply) => {
@@ -256968,7 +257177,16 @@ var routes18 = async (fastify2) => {
256968
257177
  }
256969
257178
  const includeArchived = req.query.includeArchived === "true";
256970
257179
  const tasks = await fastify2.storage.tasks.getByProjectId(req.params.projectId, { includeArchived });
256971
- return reply.code(200).send({ tasks });
257180
+ const sources = await resolveSourceSessions(
257181
+ fastify2.storage,
257182
+ tasks.flatMap((t) => t.source_session_id ? [t.source_session_id] : [])
257183
+ );
257184
+ return reply.code(200).send({
257185
+ tasks: tasks.map((t) => ({
257186
+ ...t,
257187
+ source_session: t.source_session_id ? sources.get(t.source_session_id) ?? null : null
257188
+ }))
257189
+ });
256972
257190
  }
256973
257191
  );
256974
257192
  fastify2.get(
@@ -256992,10 +257210,23 @@ var routes18 = async (fastify2) => {
256992
257210
  if (!project) {
256993
257211
  return reply.code(404).send({ error: "Project not found" });
256994
257212
  }
256995
- const { title: providedTitle, description, status, priority, assigned_branch } = req.body;
257213
+ const { title: providedTitle, description, status, priority } = req.body;
257214
+ let { assigned_branch } = req.body;
256996
257215
  if (!description) {
256997
257216
  return reply.code(400).send({ error: "description is required" });
256998
257217
  }
257218
+ let source = null;
257219
+ if (req.body.source) {
257220
+ const { session_id, tool_use_id, item_index } = req.body.source;
257221
+ if (!validSourceId(session_id) || !validSourceId(tool_use_id) || typeof item_index !== "number" || !Number.isInteger(item_index) || item_index < 0 || item_index > SOURCE_ITEM_INDEX_MAX) {
257222
+ return reply.code(400).send({ error: "Invalid source" });
257223
+ }
257224
+ if (!await isProjectSourceSession(fastify2.storage, session_id, req.params.projectId)) {
257225
+ return reply.code(400).send({ error: "Invalid source" });
257226
+ }
257227
+ source = { session_id, tool_use_id, item_index };
257228
+ assigned_branch = null;
257229
+ }
256999
257230
  let title = providedTitle;
257000
257231
  if (!title) {
257001
257232
  try {
@@ -257020,16 +257251,44 @@ Description: ${description}`,
257020
257251
  }
257021
257252
  }
257022
257253
  const id = randomUUID22();
257023
- const task = await fastify2.storage.tasks.create({
257254
+ const insert = () => fastify2.storage.tasks.create({
257024
257255
  id,
257025
257256
  project_id: req.params.projectId,
257026
257257
  title,
257027
257258
  description,
257028
257259
  status,
257029
257260
  priority,
257030
- assigned_branch
257261
+ assigned_branch,
257262
+ source
257031
257263
  });
257032
- return reply.code(201).send({ task });
257264
+ let task;
257265
+ if (source) {
257266
+ const sourceSessionId = source.session_id;
257267
+ try {
257268
+ task = await fastify2.retentionHolds.exclusive(sourceSessionId, async (syncNow) => {
257269
+ const row = await insert();
257270
+ try {
257271
+ await syncNow();
257272
+ return row;
257273
+ } catch (error48) {
257274
+ if (row.id === id) {
257275
+ await fastify2.storage.tasks.delete(row.id);
257276
+ await syncNow().catch(() => void 0);
257277
+ }
257278
+ throw error48;
257279
+ }
257280
+ });
257281
+ } catch (error48) {
257282
+ return reply.code(502).send({ error: holdFailed(error48) });
257283
+ }
257284
+ } else {
257285
+ task = await insert();
257286
+ }
257287
+ const created = task.id === id;
257288
+ if (created) {
257289
+ fastify2.eventBus.emit({ type: "task:created", projectId: req.params.projectId, task: { ...task } });
257290
+ }
257291
+ return reply.code(created ? 201 : 200).send({ task });
257033
257292
  });
257034
257293
  fastify2.put("/api/tasks/:id", async (req, reply) => {
257035
257294
  const userId = requireUserFacingUserId(req, reply);
@@ -257042,14 +257301,25 @@ Description: ${description}`,
257042
257301
  if (!project) {
257043
257302
  return reply.code(404).send({ error: "Task not found" });
257044
257303
  }
257045
- const task = await fastify2.storage.tasks.update(req.params.id, {
257304
+ const patch = {
257046
257305
  title: req.body.title,
257047
257306
  description: req.body.description,
257048
257307
  status: req.body.status,
257049
257308
  priority: req.body.priority,
257050
257309
  assigned_branch: req.body.assigned_branch,
257051
257310
  position: req.body.position
257052
- });
257311
+ };
257312
+ let task;
257313
+ try {
257314
+ task = await applyHoldingChange(
257315
+ req.params.id,
257316
+ () => fastify2.storage.tasks.update(req.params.id, patch),
257317
+ revertTaskPatch(fastify2.storage, req.params.id, patch)
257318
+ );
257319
+ } catch (error48) {
257320
+ return reply.code(502).send({ error: holdFailed(error48) });
257321
+ }
257322
+ if (task) fastify2.eventBus.emit({ type: "task:updated", projectId: existing.project_id, task: { ...task } });
257053
257323
  return reply.code(200).send({ task });
257054
257324
  });
257055
257325
  fastify2.delete("/api/tasks/:id", async (req, reply) => {
@@ -257064,6 +257334,12 @@ Description: ${description}`,
257064
257334
  return reply.code(404).send({ error: "Task not found" });
257065
257335
  }
257066
257336
  await fastify2.storage.tasks.delete(req.params.id);
257337
+ fastify2.eventBus.emit({ type: "task:deleted", projectId: existing.project_id, taskId: req.params.id });
257338
+ if (existing.source_session_id) {
257339
+ await fastify2.retentionHolds.sync(existing.source_session_id).catch((error48) => {
257340
+ console.warn(`[RetentionHolds] release for ${existing.source_session_id} deferred:`, error48);
257341
+ });
257342
+ }
257067
257343
  return reply.code(200).send({ success: true });
257068
257344
  });
257069
257345
  fastify2.post("/api/tasks/:id/archive", async (req, reply) => {
@@ -257078,6 +257354,7 @@ Description: ${description}`,
257078
257354
  return reply.code(404).send({ error: "Task not found" });
257079
257355
  }
257080
257356
  const task = await fastify2.storage.tasks.archive(req.params.id);
257357
+ if (task) fastify2.eventBus.emit({ type: "task:updated", projectId: existing.project_id, task: { ...task } });
257081
257358
  return reply.code(200).send({ task });
257082
257359
  });
257083
257360
  fastify2.post("/api/tasks/:id/unarchive", async (req, reply) => {
@@ -257091,7 +257368,17 @@ Description: ${description}`,
257091
257368
  if (!project) {
257092
257369
  return reply.code(404).send({ error: "Task not found" });
257093
257370
  }
257094
- const task = await fastify2.storage.tasks.unarchive(req.params.id);
257371
+ let task;
257372
+ try {
257373
+ task = await applyHoldingChange(
257374
+ req.params.id,
257375
+ () => fastify2.storage.tasks.unarchive(req.params.id),
257376
+ () => fastify2.storage.tasks.archive(req.params.id)
257377
+ );
257378
+ } catch (error48) {
257379
+ return reply.code(502).send({ error: holdFailed(error48) });
257380
+ }
257381
+ if (task) fastify2.eventBus.emit({ type: "task:updated", projectId: existing.project_id, task: { ...task } });
257095
257382
  return reply.code(200).send({ task });
257096
257383
  });
257097
257384
  fastify2.put("/api/projects/:projectId/tasks/reorder", async (req, reply) => {
@@ -267052,6 +267339,11 @@ var TOOLS2 = [
267052
267339
  name: PROPOSE_SCHEDULE_TOOL,
267053
267340
  description: PROPOSE_SCHEDULE_DESCRIPTION,
267054
267341
  inputSchema: PROPOSE_SCHEDULE_INPUT_SCHEMA
267342
+ },
267343
+ {
267344
+ name: PROPOSE_TASK_TOOL,
267345
+ description: PROPOSE_TASK_DESCRIPTION,
267346
+ inputSchema: PROPOSE_TASK_INPUT_SCHEMA
267055
267347
  }
267056
267348
  ];
267057
267349
  var textResult2 = (text2, isError = false) => ({
@@ -267074,6 +267366,10 @@ var routes33 = async (fastify2) => {
267074
267366
  return payload;
267075
267367
  };
267076
267368
  const callTool = (toolName, args) => {
267369
+ if (toolName === PROPOSE_TASK_TOOL) {
267370
+ const parsed2 = parseProposeTaskArgs(args);
267371
+ return parsed2.ok ? textResult2(PROPOSE_TASK_ACK) : textResult2(parsed2.error, true);
267372
+ }
267077
267373
  if (toolName !== PROPOSE_SCHEDULE_TOOL) return textResult2(`Unknown tool: ${toolName}`, true);
267078
267374
  const parsed = parseProposeScheduleArgs(args);
267079
267375
  if (!parsed.ok) return textResult2(parsed.error, true);
@@ -267126,8 +267422,6 @@ import { randomUUID as randomUUID29 } from "crypto";
267126
267422
  import path20 from "path";
267127
267423
  var RUN_TYPES = ["command", "prompt"];
267128
267424
  var CWD_MODES = ["branch", "directory"];
267129
- var SOURCE_ID_MAX = 200;
267130
- var validSourceId = (value) => typeof value === "string" && value.length > 0 && value.length <= SOURCE_ID_MAX && value.trim() === value;
267131
267425
  function validRequestId(value) {
267132
267426
  return typeof value === "string" && value.length > 0 && value.length <= 200 && value.trim() === value;
267133
267427
  }
@@ -267167,32 +267461,6 @@ var routes34 = async (fastify2) => {
267167
267461
  }
267168
267462
  return schedule;
267169
267463
  };
267170
- const resolveSourceSessions = async (ids) => {
267171
- const unique = [...new Set(ids)];
267172
- const remoteIds = unique.filter((id) => id.startsWith("remote-"));
267173
- const remoteTitles = await fastify2.storage.searchCache.getCachedSessionTitles(remoteIds);
267174
- const branchOf2 = async (row) => {
267175
- if (!row) return null;
267176
- const registered = row.workspace_checkout_id ? await fastify2.storage.workspaceRegistry.getCheckoutById(row.workspace_checkout_id) : void 0;
267177
- return (registered ? registered.workspace.branch : row.branch) || null;
267178
- };
267179
- const out = /* @__PURE__ */ new Map();
267180
- await Promise.all(unique.map(async (id) => {
267181
- if (id.startsWith("remote-")) {
267182
- const mapping = await fastify2.storage.remoteSessionMappings.getByLocal(id);
267183
- out.set(id, {
267184
- id,
267185
- exists: !!mapping,
267186
- branch: await branchOf2(mapping),
267187
- title: remoteTitles.get(id) ?? null
267188
- });
267189
- return;
267190
- }
267191
- const session = await fastify2.storage.agentSessions.getById(id);
267192
- out.set(id, { id, exists: !!session, branch: await branchOf2(session), title: session?.title ?? null });
267193
- }));
267194
- return out;
267195
- };
267196
267464
  fastify2.get(
267197
267465
  "/api/projects/:projectId/schedules",
267198
267466
  async (req, reply) => {
@@ -267203,6 +267471,7 @@ var routes34 = async (fastify2) => {
267203
267471
  const schedules = await fastify2.storage.scheduledTasks.getByProjectId(req.params.projectId);
267204
267472
  const lastRuns = await fastify2.storage.scheduledTaskRuns.getLastByScheduleIds(schedules.map((s3) => s3.id));
267205
267473
  const sources = await resolveSourceSessions(
267474
+ fastify2.storage,
267206
267475
  schedules.flatMap((s3) => s3.source_session_id ? [s3.source_session_id] : [])
267207
267476
  );
267208
267477
  return reply.code(200).send({
@@ -267247,11 +267516,7 @@ var routes34 = async (fastify2) => {
267247
267516
  if (!validSourceId(b2.source.session_id) || !validSourceId(b2.source.tool_use_id)) {
267248
267517
  return reply.code(400).send({ error: "Invalid source" });
267249
267518
  }
267250
- const sourceSession = await fastify2.storage.agentSessions.getById(b2.source.session_id);
267251
- const owned = sourceSession ? sourceSession.project_id === req.params.projectId : !!await fastify2.storage.remoteSessionMappings.getAuthorizedByLocal(
267252
- b2.source.session_id,
267253
- req.params.projectId
267254
- );
267519
+ const owned = await isProjectSourceSession(fastify2.storage, b2.source.session_id, req.params.projectId);
267255
267520
  if (!owned) return reply.code(400).send({ error: "Invalid source" });
267256
267521
  source = { session_id: b2.source.session_id, tool_use_id: b2.source.tool_use_id };
267257
267522
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibedeckx/darwin-arm64",
3
- "version": "0.3.45",
3
+ "version": "0.3.46",
4
4
  "description": "Vibedeckx platform binaries for macOS ARM64",
5
5
  "os": [
6
6
  "darwin"