@vibedeckx/darwin-arm64 0.3.49 → 0.3.50
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/dist/bin.js +141 -24
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -5737,7 +5737,7 @@ var require_EnvDetector = __commonJS({
|
|
|
5737
5737
|
if (!rawEnvAttributes)
|
|
5738
5738
|
return {};
|
|
5739
5739
|
const attributes = {};
|
|
5740
|
-
const rawAttributes = rawEnvAttributes.split(this._COMMA_SEPARATOR).filter((
|
|
5740
|
+
const rawAttributes = rawEnvAttributes.split(this._COMMA_SEPARATOR).filter((attr2) => attr2.trim() !== "");
|
|
5741
5741
|
for (const rawAttribute of rawAttributes) {
|
|
5742
5742
|
const keyValuePair = rawAttribute.split(this._LABEL_KEY_VALUE_SPLITTER);
|
|
5743
5743
|
if (keyValuePair.length !== 2) {
|
|
@@ -11486,16 +11486,16 @@ var require_Span = __commonJS({
|
|
|
11486
11486
|
const attributes = {};
|
|
11487
11487
|
let droppedAttributesCount = 0;
|
|
11488
11488
|
let eventAttributesCount = 0;
|
|
11489
|
-
for (const
|
|
11490
|
-
if (!Object.prototype.hasOwnProperty.call(sanitized,
|
|
11489
|
+
for (const attr2 in sanitized) {
|
|
11490
|
+
if (!Object.prototype.hasOwnProperty.call(sanitized, attr2)) {
|
|
11491
11491
|
continue;
|
|
11492
11492
|
}
|
|
11493
|
-
const attrVal = sanitized[
|
|
11493
|
+
const attrVal = sanitized[attr2];
|
|
11494
11494
|
if (attributePerEventCountLimit !== void 0 && eventAttributesCount >= attributePerEventCountLimit) {
|
|
11495
11495
|
droppedAttributesCount++;
|
|
11496
11496
|
continue;
|
|
11497
11497
|
}
|
|
11498
|
-
attributes[
|
|
11498
|
+
attributes[attr2] = this._truncateToSize(attrVal);
|
|
11499
11499
|
eventAttributesCount++;
|
|
11500
11500
|
}
|
|
11501
11501
|
this.events.push({
|
|
@@ -11526,16 +11526,16 @@ var require_Span = __commonJS({
|
|
|
11526
11526
|
const attributes = {};
|
|
11527
11527
|
let droppedAttributesCount = 0;
|
|
11528
11528
|
let linkAttributesCount = 0;
|
|
11529
|
-
for (const
|
|
11530
|
-
if (!Object.prototype.hasOwnProperty.call(sanitized,
|
|
11529
|
+
for (const attr2 in sanitized) {
|
|
11530
|
+
if (!Object.prototype.hasOwnProperty.call(sanitized, attr2)) {
|
|
11531
11531
|
continue;
|
|
11532
11532
|
}
|
|
11533
|
-
const attrVal = sanitized[
|
|
11533
|
+
const attrVal = sanitized[attr2];
|
|
11534
11534
|
if (attributePerLinkCountLimit !== void 0 && linkAttributesCount >= attributePerLinkCountLimit) {
|
|
11535
11535
|
droppedAttributesCount++;
|
|
11536
11536
|
continue;
|
|
11537
11537
|
}
|
|
11538
|
-
attributes[
|
|
11538
|
+
attributes[attr2] = this._truncateToSize(attrVal);
|
|
11539
11539
|
linkAttributesCount++;
|
|
11540
11540
|
}
|
|
11541
11541
|
const processedLink = { context: link.context };
|
|
@@ -51736,12 +51736,12 @@ var require_utils10 = __commonJS({
|
|
|
51736
51736
|
var RESOURCE_DETECTOR_SERVICE_INSTANCE_ID = "serviceinstance";
|
|
51737
51737
|
function getResourceFromConfiguration(config2) {
|
|
51738
51738
|
if (config2.resource && config2.resource.attributes) {
|
|
51739
|
-
const
|
|
51739
|
+
const attr2 = {};
|
|
51740
51740
|
for (let i = 0; i < config2.resource.attributes.length; i++) {
|
|
51741
51741
|
const a = config2.resource.attributes[i];
|
|
51742
|
-
|
|
51742
|
+
attr2[a.name] = a.value;
|
|
51743
51743
|
}
|
|
51744
|
-
return (0, resources_1.resourceFromAttributes)(
|
|
51744
|
+
return (0, resources_1.resourceFromAttributes)(attr2, {
|
|
51745
51745
|
schemaUrl: config2.resource.schema_url
|
|
51746
51746
|
});
|
|
51747
51747
|
}
|
|
@@ -93616,9 +93616,9 @@ var require_dist5 = __commonJS({
|
|
|
93616
93616
|
while (index < len) {
|
|
93617
93617
|
const endIdx2 = endIndex(str2, index, len);
|
|
93618
93618
|
const eqIdx2 = eqIndex(str2, index, endIdx2);
|
|
93619
|
-
const
|
|
93619
|
+
const attr2 = eqIdx2 === -1 ? valueSlice(str2, index, endIdx2) : valueSlice(str2, index, eqIdx2);
|
|
93620
93620
|
const val = eqIdx2 === -1 ? void 0 : valueSlice(str2, eqIdx2 + 1, endIdx2);
|
|
93621
|
-
switch (
|
|
93621
|
+
switch (attr2.toLowerCase()) {
|
|
93622
93622
|
case "httponly":
|
|
93623
93623
|
setCookie.httpOnly = true;
|
|
93624
93624
|
break;
|
|
@@ -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, source }) => {
|
|
188011
|
+
create: async ({ id, project_id, title, description, status, priority, assigned_branch, source, parent_id }) => {
|
|
188012
188012
|
await kdb.insertInto("tasks").values((eb) => ({
|
|
188013
188013
|
id,
|
|
188014
188014
|
project_id,
|
|
@@ -188020,7 +188020,8 @@ var createWorkspaceRepos = (kdb, h) => ({
|
|
|
188020
188020
|
position: eb.selectFrom("tasks").select(sql`coalesce(max(position), -1) + 1`.as("next_position")).where("project_id", "=", project_id),
|
|
188021
188021
|
source_session_id: source?.session_id ?? null,
|
|
188022
188022
|
source_tool_use_id: source?.tool_use_id ?? null,
|
|
188023
|
-
source_item_index: source?.item_index ?? null
|
|
188023
|
+
source_item_index: source?.item_index ?? null,
|
|
188024
|
+
parent_id: parent_id ?? null
|
|
188024
188025
|
// DO NOTHING only for a proposal, so a concurrent replay races into
|
|
188025
188026
|
// idx_tasks_source and is resolved below (same argument as
|
|
188026
188027
|
// scheduledTasks.create); a plain insert keeps failing loudly.
|
|
@@ -188033,6 +188034,14 @@ var createWorkspaceRepos = (kdb, h) => ({
|
|
|
188033
188034
|
}
|
|
188034
188035
|
throw new Error(`Failed to create task ${id}`);
|
|
188035
188036
|
},
|
|
188037
|
+
listUnreportedBySourceSession: async (sessionId) => {
|
|
188038
|
+
const rows = await kdb.selectFrom("tasks").selectAll().where("source_session_id", "=", sessionId).where("source_tool_use_id", "is not", null).where("source_reported_at", "is", null).orderBy("created_at", "asc").orderBy("position", "asc").execute();
|
|
188039
|
+
return rows.map(mapTask2);
|
|
188040
|
+
},
|
|
188041
|
+
markSourceReported: async (ids) => {
|
|
188042
|
+
if (ids.length === 0) return;
|
|
188043
|
+
await kdb.updateTable("tasks").set({ source_reported_at: Date.now() }).where("id", "in", ids).execute();
|
|
188044
|
+
},
|
|
188036
188045
|
listOpenIdsBySourceSession: async (sessionId) => {
|
|
188037
188046
|
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
188047
|
return rows.map((row) => row.id);
|
|
@@ -188081,6 +188090,7 @@ var createWorkspaceRepos = (kdb, h) => ({
|
|
|
188081
188090
|
if (opts.priority !== void 0) sets.priority = opts.priority;
|
|
188082
188091
|
if (opts.assigned_branch !== void 0) sets.assigned_branch = opts.assigned_branch;
|
|
188083
188092
|
if (opts.position !== void 0) sets.position = opts.position;
|
|
188093
|
+
if (opts.parent_id !== void 0) sets.parent_id = opts.parent_id;
|
|
188084
188094
|
if (Object.keys(sets).length > 0) {
|
|
188085
188095
|
sets.updated_at = sql`CURRENT_TIMESTAMP`;
|
|
188086
188096
|
await kdb.updateTable("tasks").set(sets).where("id", "=", id).execute();
|
|
@@ -188099,7 +188109,10 @@ var createWorkspaceRepos = (kdb, h) => ({
|
|
|
188099
188109
|
return row ? mapTask2(row) : void 0;
|
|
188100
188110
|
},
|
|
188101
188111
|
delete: async (id) => {
|
|
188102
|
-
await kdb.
|
|
188112
|
+
await kdb.transaction().execute(async (trx) => {
|
|
188113
|
+
await trx.updateTable("tasks").set({ parent_id: null, updated_at: sql`CURRENT_TIMESTAMP` }).where("parent_id", "=", id).execute();
|
|
188114
|
+
await trx.deleteFrom("tasks").where("id", "=", id).execute();
|
|
188115
|
+
});
|
|
188103
188116
|
},
|
|
188104
188117
|
reorder: async (projectId, orderedIds) => {
|
|
188105
188118
|
await kdb.transaction().execute(async (trx) => {
|
|
@@ -205318,6 +205331,14 @@ var initializeSchema = (db) => {
|
|
|
205318
205331
|
if (!taskSourceInfo.some((col) => col.name === "source_item_index")) {
|
|
205319
205332
|
db.exec("ALTER TABLE tasks ADD COLUMN source_item_index INTEGER");
|
|
205320
205333
|
}
|
|
205334
|
+
const taskParentInfo = db.prepare("PRAGMA table_info(tasks)").all();
|
|
205335
|
+
if (!taskParentInfo.some((col) => col.name === "parent_id")) {
|
|
205336
|
+
db.exec("ALTER TABLE tasks ADD COLUMN parent_id TEXT DEFAULT NULL");
|
|
205337
|
+
}
|
|
205338
|
+
if (!taskParentInfo.some((col) => col.name === "source_reported_at")) {
|
|
205339
|
+
db.exec("ALTER TABLE tasks ADD COLUMN source_reported_at INTEGER DEFAULT NULL");
|
|
205340
|
+
db.prepare("UPDATE tasks SET source_reported_at = ? WHERE source_session_id IS NOT NULL").run(Date.now());
|
|
205341
|
+
}
|
|
205321
205342
|
const sessionTableInfo = db.prepare("PRAGMA table_info(agent_sessions)").all();
|
|
205322
205343
|
const hasWorktreePathColumn = sessionTableInfo.some((col) => col.name === "worktree_path");
|
|
205323
205344
|
if (hasWorktreePathColumn) {
|
|
@@ -206163,6 +206184,9 @@ var initializeSchema = (db) => {
|
|
|
206163
206184
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_tasks_source
|
|
206164
206185
|
ON tasks(source_session_id, source_tool_use_id, source_item_index)
|
|
206165
206186
|
WHERE source_tool_use_id IS NOT NULL;
|
|
206187
|
+
CREATE INDEX IF NOT EXISTS idx_tasks_parent
|
|
206188
|
+
ON tasks(parent_id)
|
|
206189
|
+
WHERE parent_id IS NOT NULL;
|
|
206166
206190
|
CREATE INDEX IF NOT EXISTS idx_tasks_project_archived_position_id
|
|
206167
206191
|
ON tasks(project_id, archived_at, position ASC, id ASC);
|
|
206168
206192
|
CREATE INDEX IF NOT EXISTS idx_tasks_project_archived_status_position_id
|
|
@@ -206634,6 +206658,18 @@ var PROPOSE_TASK_DESCRIPTION = [
|
|
|
206634
206658
|
"be done, and how to tell it is finished. Propose several tasks in one call when the user asks to",
|
|
206635
206659
|
"split the work.",
|
|
206636
206660
|
"",
|
|
206661
|
+
"Write each file in this repository that a description refers to (a design doc, the source to",
|
|
206662
|
+
"change) as a Markdown link with a path relative to the repository root, e.g.",
|
|
206663
|
+
"[design doc](docs/foo-design.md) or [handler](src/routes/foo.ts:42). Such links open the file in",
|
|
206664
|
+
"the workspace; bare paths and absolute paths do not.",
|
|
206665
|
+
"",
|
|
206666
|
+
"To file the tasks as sub-tasks of an existing task (e.g. a follow-up found while working on",
|
|
206667
|
+
"step 2 of a plan), pass that task's id as `parent_task_id`. Ids of tasks the user created from",
|
|
206668
|
+
"your earlier proposals arrive in a <vtasks-created> note on a later user message; use one of",
|
|
206669
|
+
"those, never a guessed id. Omit it when you don't know the id \u2014 the user can still pick a",
|
|
206670
|
+
"parent on the card. One call files all its tasks under the same parent; make separate calls",
|
|
206671
|
+
"for different parents.",
|
|
206672
|
+
"",
|
|
206637
206673
|
"Project and source session are taken from this session \u2014 do not describe them here."
|
|
206638
206674
|
].join("\n");
|
|
206639
206675
|
var PROPOSE_TASK_INPUT_SCHEMA = {
|
|
@@ -206648,11 +206684,15 @@ var PROPOSE_TASK_INPUT_SCHEMA = {
|
|
|
206648
206684
|
type: "object",
|
|
206649
206685
|
properties: {
|
|
206650
206686
|
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." },
|
|
206687
|
+
description: { type: "string", description: "Self-contained Markdown description: background, relevant files (as repo-relative Markdown links, e.g. [design](docs/foo.md) or [handler](src/foo.ts:42)), remaining work, definition of done." },
|
|
206652
206688
|
priority: { type: "string", enum: ["low", "medium", "high", "urgent"], description: "Optional; defaults to medium." }
|
|
206653
206689
|
},
|
|
206654
206690
|
required: ["title", "description"]
|
|
206655
206691
|
}
|
|
206692
|
+
},
|
|
206693
|
+
parent_task_id: {
|
|
206694
|
+
type: "string",
|
|
206695
|
+
description: "Optional id of an existing task to file all these tasks under, taken from a <vtasks-created> note."
|
|
206656
206696
|
}
|
|
206657
206697
|
},
|
|
206658
206698
|
required: ["tasks"]
|
|
@@ -206661,6 +206701,7 @@ var PROPOSE_TASK_ACK = "Proposal shown to the user as a confirmation card. Nothi
|
|
|
206661
206701
|
var PROPOSE_TASK_MAX_ITEMS = 5;
|
|
206662
206702
|
var TASK_TITLE_MAX = 200;
|
|
206663
206703
|
var TASK_DESCRIPTION_MAX = 2e4;
|
|
206704
|
+
var PARENT_TASK_ID_MAX = 200;
|
|
206664
206705
|
var TASK_PRIORITIES = ["low", "medium", "high", "urgent"];
|
|
206665
206706
|
function parseProposeTaskArgs(args) {
|
|
206666
206707
|
const raw = args.tasks;
|
|
@@ -206668,6 +206709,10 @@ function parseProposeTaskArgs(args) {
|
|
|
206668
206709
|
if (raw.length > PROPOSE_TASK_MAX_ITEMS) {
|
|
206669
206710
|
return { ok: false, error: `propose at most ${PROPOSE_TASK_MAX_ITEMS} tasks at a time` };
|
|
206670
206711
|
}
|
|
206712
|
+
const parentTaskId = args.parent_task_id;
|
|
206713
|
+
if (parentTaskId !== void 0 && parentTaskId !== null && (typeof parentTaskId !== "string" || parentTaskId.length > PARENT_TASK_ID_MAX)) {
|
|
206714
|
+
return { ok: false, error: "parent_task_id must be a task id string" };
|
|
206715
|
+
}
|
|
206671
206716
|
const tasks = [];
|
|
206672
206717
|
for (const [i, item] of raw.entries()) {
|
|
206673
206718
|
const obj = item && typeof item === "object" ? item : {};
|
|
@@ -230825,6 +230870,32 @@ async function appendRemoteGrantContext(storage2, sessionId, userId, content) {
|
|
|
230825
230870
|
return appendContextBlock(content, await buildRemoteGrantContext(storage2, sessionId, userId));
|
|
230826
230871
|
}
|
|
230827
230872
|
|
|
230873
|
+
// src/tasks-created-context.ts
|
|
230874
|
+
var VTASKS_CREATED_BLOCK_RE = /<vtasks-created(?:\s[^>]*)?>[\s\S]*?<\/vtasks-created>/g;
|
|
230875
|
+
var attr = (value) => value.replace(/[\r\n]+/g, " ").replace(/[&<>"]/g, (c) => c === "&" ? "&" : c === "<" ? "<" : c === ">" ? ">" : """);
|
|
230876
|
+
async function buildTasksCreatedContext(storage2, sessionId, userId) {
|
|
230877
|
+
const tasks = await storage2.tasks.listUnreportedBySourceSession(sessionId);
|
|
230878
|
+
if (tasks.length === 0) return null;
|
|
230879
|
+
const owned = /* @__PURE__ */ new Map();
|
|
230880
|
+
const visible = [];
|
|
230881
|
+
for (const task of tasks) {
|
|
230882
|
+
if (!owned.has(task.project_id)) {
|
|
230883
|
+
owned.set(task.project_id, !!await storage2.projects.getById(task.project_id, userId));
|
|
230884
|
+
}
|
|
230885
|
+
if (owned.get(task.project_id)) visible.push(task);
|
|
230886
|
+
}
|
|
230887
|
+
if (visible.length === 0) return null;
|
|
230888
|
+
const lines = visible.map((task) => `<task id="${attr(task.id)}" title="${attr(task.title)}"${task.parent_id ? ` parent_id="${attr(task.parent_id)}"` : ""} />`);
|
|
230889
|
+
return {
|
|
230890
|
+
block: [
|
|
230891
|
+
'<vtasks-created note="Tasks the user created from your earlier propose_task proposals. For reference only, no action needed. Pass an id as parent_task_id to file sub-tasks under it.">',
|
|
230892
|
+
...lines,
|
|
230893
|
+
"</vtasks-created>"
|
|
230894
|
+
].join("\n"),
|
|
230895
|
+
ids: visible.map((task) => task.id)
|
|
230896
|
+
};
|
|
230897
|
+
}
|
|
230898
|
+
|
|
230828
230899
|
// src/utils/conversation-title.ts
|
|
230829
230900
|
var TITLE_MAX_CHARS = 60;
|
|
230830
230901
|
var VSCHEDULE_BLOCK_RE = /<vschedule(?:\s[^>]*)?>[\s\S]*?<\/vschedule>/g;
|
|
@@ -230845,7 +230916,9 @@ async function isChatModelConfigured(storage2, userId) {
|
|
|
230845
230916
|
}
|
|
230846
230917
|
function extractUserText(content) {
|
|
230847
230918
|
const text2 = typeof content === "string" ? content : content.filter((p2) => p2.type === "text").map((p2) => p2.text).join(" ");
|
|
230848
|
-
return stripRemoteGrantContext(
|
|
230919
|
+
return stripRemoteGrantContext(
|
|
230920
|
+
text2.replace(VSCHEDULE_BLOCK_RE, "").replace(VTASK_BLOCK_RE, "").replace(VTASKS_CREATED_BLOCK_RE, "")
|
|
230921
|
+
);
|
|
230849
230922
|
}
|
|
230850
230923
|
function snippetTitle(text2) {
|
|
230851
230924
|
const trimmed = text2.trim();
|
|
@@ -255111,10 +255184,21 @@ var routes11 = async (fastify2) => {
|
|
|
255111
255184
|
if (rejection) return reply.code(400).send({ error: rejection });
|
|
255112
255185
|
await fastify2.storage.sessionRemoteGrants.replace(req.params.sessionId, userId, ids);
|
|
255113
255186
|
}
|
|
255114
|
-
const
|
|
255187
|
+
const withGrants = await appendRemoteGrantContext(fastify2.storage, req.params.sessionId, userId, rawContent).catch((err) => {
|
|
255115
255188
|
console.error(`[API] grant context build failed for ${req.params.sessionId}:`, err);
|
|
255116
255189
|
return rawContent;
|
|
255117
255190
|
});
|
|
255191
|
+
const tasksCreated = await buildTasksCreatedContext(fastify2.storage, req.params.sessionId, userId).catch((err) => {
|
|
255192
|
+
console.error(`[API] tasks-created context build failed for ${req.params.sessionId}:`, err);
|
|
255193
|
+
return null;
|
|
255194
|
+
});
|
|
255195
|
+
const content = appendContextBlock(withGrants, tasksCreated?.block ?? null);
|
|
255196
|
+
const markTasksReported = async () => {
|
|
255197
|
+
if (!tasksCreated) return;
|
|
255198
|
+
await fastify2.storage.tasks.markSourceReported(tasksCreated.ids).catch((err) => {
|
|
255199
|
+
console.error(`[API] marking tasks reported failed for ${req.params.sessionId}:`, err);
|
|
255200
|
+
});
|
|
255201
|
+
};
|
|
255118
255202
|
if (req.params.sessionId.startsWith("remote-")) {
|
|
255119
255203
|
const remoteInfo = await getAuthorizedRemoteSessionInfo(req.params.sessionId, authResult);
|
|
255120
255204
|
if (!remoteInfo) {
|
|
@@ -255161,6 +255245,7 @@ var routes11 = async (fastify2) => {
|
|
|
255161
255245
|
detail: result.data
|
|
255162
255246
|
});
|
|
255163
255247
|
}
|
|
255248
|
+
if (result.data?.replayed !== true) await markTasksReported();
|
|
255164
255249
|
const projectId = projectIdFromRemoteSessionId(req.params.sessionId, remoteInfo);
|
|
255165
255250
|
const activityReady = await fastify2.storage.searchCache.updateRemoteSessionActivity({
|
|
255166
255251
|
localSessionId: req.params.sessionId,
|
|
@@ -255241,6 +255326,7 @@ var routes11 = async (fastify2) => {
|
|
|
255241
255326
|
console.log(`[API] /message 404: local session not found or not running. sessionId=${req.params.sessionId}, sessionExists=${!!currentSession}, dormant=${currentSession.dormant}`);
|
|
255242
255327
|
return reply.code(404).send({ error: "Session not found or not running" });
|
|
255243
255328
|
}
|
|
255329
|
+
await markTasksReported();
|
|
255244
255330
|
return reply.code(200).send({ success: true });
|
|
255245
255331
|
}
|
|
255246
255332
|
const result = await deliverInstruction({
|
|
@@ -255252,6 +255338,7 @@ var routes11 = async (fastify2) => {
|
|
|
255252
255338
|
});
|
|
255253
255339
|
switch (result) {
|
|
255254
255340
|
case "delivered":
|
|
255341
|
+
await markTasksReported();
|
|
255255
255342
|
return reply.code(200).send({ success: true });
|
|
255256
255343
|
case "replayed":
|
|
255257
255344
|
return reply.code(200).send({ success: true, replayed: true });
|
|
@@ -257236,9 +257323,23 @@ async function resolveSourceSessions(storage2, ids) {
|
|
|
257236
257323
|
|
|
257237
257324
|
// src/routes/task-routes.ts
|
|
257238
257325
|
var SOURCE_ITEM_INDEX_MAX = 100;
|
|
257326
|
+
var PARENT_DEPTH_MAX = 64;
|
|
257239
257327
|
var routes18 = async (fastify2) => {
|
|
257240
257328
|
const applyHoldingChange = (taskId, apply, revert) => applyTaskChange(fastify2, taskId, apply, revert);
|
|
257241
257329
|
const holdFailed = (error48) => `Could not protect the source session from retention: ${error48 instanceof Error ? error48.message : String(error48)}`;
|
|
257330
|
+
const parentError = async (projectId, taskId, parentId) => {
|
|
257331
|
+
if (parentId === null) return null;
|
|
257332
|
+
if (!validSourceId(parentId)) return "Invalid parent_id";
|
|
257333
|
+
let current = parentId;
|
|
257334
|
+
for (let depth = 0; current !== null; depth++) {
|
|
257335
|
+
if (current === taskId) return "A task can't be nested under itself or its own sub-task";
|
|
257336
|
+
if (depth >= PARENT_DEPTH_MAX) return "Task nesting is too deep";
|
|
257337
|
+
const ancestor = await fastify2.storage.tasks.getById(current);
|
|
257338
|
+
if (!ancestor || ancestor.project_id !== projectId) return "Parent task not found";
|
|
257339
|
+
current = ancestor.parent_id;
|
|
257340
|
+
}
|
|
257341
|
+
return null;
|
|
257342
|
+
};
|
|
257242
257343
|
fastify2.get(
|
|
257243
257344
|
"/api/projects/:projectId/tasks",
|
|
257244
257345
|
async (req, reply) => {
|
|
@@ -257288,6 +257389,9 @@ var routes18 = async (fastify2) => {
|
|
|
257288
257389
|
if (!description) {
|
|
257289
257390
|
return reply.code(400).send({ error: "description is required" });
|
|
257290
257391
|
}
|
|
257392
|
+
const parent_id = req.body.parent_id ?? null;
|
|
257393
|
+
const invalidParent = await parentError(req.params.projectId, null, parent_id);
|
|
257394
|
+
if (invalidParent) return reply.code(400).send({ error: invalidParent });
|
|
257291
257395
|
let source = null;
|
|
257292
257396
|
if (req.body.source) {
|
|
257293
257397
|
const { session_id, tool_use_id, item_index } = req.body.source;
|
|
@@ -257332,7 +257436,8 @@ Description: ${description}`,
|
|
|
257332
257436
|
status,
|
|
257333
257437
|
priority,
|
|
257334
257438
|
assigned_branch,
|
|
257335
|
-
source
|
|
257439
|
+
source,
|
|
257440
|
+
parent_id
|
|
257336
257441
|
});
|
|
257337
257442
|
let task;
|
|
257338
257443
|
if (source) {
|
|
@@ -257380,8 +257485,13 @@ Description: ${description}`,
|
|
|
257380
257485
|
status: req.body.status,
|
|
257381
257486
|
priority: req.body.priority,
|
|
257382
257487
|
assigned_branch: req.body.assigned_branch,
|
|
257383
|
-
position: req.body.position
|
|
257488
|
+
position: req.body.position,
|
|
257489
|
+
parent_id: req.body.parent_id
|
|
257384
257490
|
};
|
|
257491
|
+
if (patch.parent_id !== void 0) {
|
|
257492
|
+
const invalidParent = await parentError(existing.project_id, existing.id, patch.parent_id);
|
|
257493
|
+
if (invalidParent) return reply.code(400).send({ error: invalidParent });
|
|
257494
|
+
}
|
|
257385
257495
|
let task;
|
|
257386
257496
|
try {
|
|
257387
257497
|
task = await applyHoldingChange(
|
|
@@ -268401,6 +268511,10 @@ var getAuth = ((req, options) => {
|
|
|
268401
268511
|
});
|
|
268402
268512
|
|
|
268403
268513
|
// src/trace-context-hooks.ts
|
|
268514
|
+
var SLOW_REQUEST_MS = 3e3;
|
|
268515
|
+
function isLongLived(headers) {
|
|
268516
|
+
return headers.upgrade !== void 0 || (headers.accept ?? "").includes("text/event-stream");
|
|
268517
|
+
}
|
|
268404
268518
|
function registerTraceContext(server) {
|
|
268405
268519
|
server.addHook("onRequest", (req, _reply, done) => {
|
|
268406
268520
|
const ctx = newTraceContext(req.headers["traceparent"]);
|
|
@@ -268418,7 +268532,9 @@ function registerTraceContext(server) {
|
|
|
268418
268532
|
const ctx = req.traceContext;
|
|
268419
268533
|
if (ctx) {
|
|
268420
268534
|
const status = reply.statusCode;
|
|
268421
|
-
const
|
|
268535
|
+
const ms = req.traceStartMs ? Date.now() - req.traceStartMs : void 0;
|
|
268536
|
+
const slow = ms !== void 0 && ms >= SLOW_REQUEST_MS && !isLongLived(req.headers);
|
|
268537
|
+
const level = status >= 500 ? "error" : status >= 400 || slow ? "warn" : "debug";
|
|
268422
268538
|
getLogger()[level](
|
|
268423
268539
|
{
|
|
268424
268540
|
method: req.method,
|
|
@@ -268427,7 +268543,8 @@ function registerTraceContext(server) {
|
|
|
268427
268543
|
// string, where WebSocket/SSE auth material rides.
|
|
268428
268544
|
route: req.routeOptions?.url,
|
|
268429
268545
|
statusCode: status,
|
|
268430
|
-
ms
|
|
268546
|
+
ms,
|
|
268547
|
+
...slow ? { slow: true } : {},
|
|
268431
268548
|
continuedTrace: ctx.continued
|
|
268432
268549
|
},
|
|
268433
268550
|
"request completed"
|