@unson/brainbase-mcp 0.51.9 → 0.51.10
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.
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Canonical Task comment MCP contract.
|
|
4
|
+
*
|
|
5
|
+
* The host owns authentication, tenant binding and the HTTP client. This
|
|
6
|
+
* module owns the tool schema, the request it maps to, and the check of the
|
|
7
|
+
* answer, so hosts handle comment requests consistently.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ADD_TASK_COMMENT_TOOL_NAME = "add_task_comment";
|
|
10
|
+
export declare const LIST_TASK_COMMENTS_TOOL_NAME = "list_task_comments";
|
|
11
|
+
export declare const LIST_TASK_COMMENTS_DEFAULT_LIMIT = 100;
|
|
12
|
+
export declare const LIST_TASK_COMMENTS_MAX_LIMIT = 200;
|
|
13
|
+
export declare const listTaskCommentsTool: Tool;
|
|
14
|
+
export declare const addTaskCommentTool: Tool;
|
|
15
|
+
export type TaskComment = {
|
|
16
|
+
id: string;
|
|
17
|
+
body: string;
|
|
18
|
+
reply_to: string | null;
|
|
19
|
+
author: string | null;
|
|
20
|
+
created_at: string | null;
|
|
21
|
+
edited_at: string | null;
|
|
22
|
+
version: number;
|
|
23
|
+
};
|
|
24
|
+
export type TaskCommentPage = {
|
|
25
|
+
task_id: string;
|
|
26
|
+
comments: TaskComment[];
|
|
27
|
+
total_count: number;
|
|
28
|
+
truncated: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type TaskCommentToolError = {
|
|
31
|
+
code: string;
|
|
32
|
+
message: string;
|
|
33
|
+
http_status?: number;
|
|
34
|
+
};
|
|
35
|
+
export type ListTaskCommentsResult = {
|
|
36
|
+
status: 'ok';
|
|
37
|
+
page: TaskCommentPage;
|
|
38
|
+
} | {
|
|
39
|
+
status: 'error';
|
|
40
|
+
error: TaskCommentToolError;
|
|
41
|
+
};
|
|
42
|
+
export declare class TaskCommentArgumentError extends Error {
|
|
43
|
+
readonly code = "invalid_arguments";
|
|
44
|
+
}
|
|
45
|
+
export declare function addTaskCommentRequest(args: unknown): {
|
|
46
|
+
method: 'POST';
|
|
47
|
+
path: string;
|
|
48
|
+
taskId: string;
|
|
49
|
+
body: {
|
|
50
|
+
body: string;
|
|
51
|
+
idempotency_key: string;
|
|
52
|
+
reply_to?: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
/** The HTTP request a host sends for `list_task_comments`. Throws TaskCommentArgumentError on bad input. */
|
|
56
|
+
export declare function listTaskCommentsRequest(args: unknown): {
|
|
57
|
+
method: 'GET';
|
|
58
|
+
path: string;
|
|
59
|
+
taskId: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Checks the API answer for the requested Task. An error answer keeps only its
|
|
63
|
+
* code; any other body detail is dropped so a store message cannot reach the agent.
|
|
64
|
+
*/
|
|
65
|
+
export declare function readListTaskCommentsResponse(taskId: string, httpStatus: number, body: unknown): ListTaskCommentsResult;
|
|
66
|
+
export type AddTaskCommentResult = {
|
|
67
|
+
status: 'ok';
|
|
68
|
+
comment: TaskComment;
|
|
69
|
+
replayed: boolean;
|
|
70
|
+
notification: {
|
|
71
|
+
status: 'not_delivered';
|
|
72
|
+
reason: 'notification_delivery_not_configured';
|
|
73
|
+
};
|
|
74
|
+
} | {
|
|
75
|
+
status: 'error';
|
|
76
|
+
error: TaskCommentToolError;
|
|
77
|
+
};
|
|
78
|
+
export declare function readAddTaskCommentResponse(httpStatus: number, body: unknown): AddTaskCommentResult;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Task comment MCP contract.
|
|
3
|
+
*
|
|
4
|
+
* The host owns authentication, tenant binding and the HTTP client. This
|
|
5
|
+
* module owns the tool schema, the request it maps to, and the check of the
|
|
6
|
+
* answer, so hosts handle comment requests consistently.
|
|
7
|
+
*/
|
|
8
|
+
export const ADD_TASK_COMMENT_TOOL_NAME = 'add_task_comment';
|
|
9
|
+
export const LIST_TASK_COMMENTS_TOOL_NAME = 'list_task_comments';
|
|
10
|
+
export const LIST_TASK_COMMENTS_DEFAULT_LIMIT = 100;
|
|
11
|
+
export const LIST_TASK_COMMENTS_MAX_LIMIT = 200;
|
|
12
|
+
const TASK_ID_MAX_LENGTH = 200;
|
|
13
|
+
const MAX_COMMENT_BODY_LENGTH = 20000;
|
|
14
|
+
const BODY_CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/u;
|
|
15
|
+
const CONTROL = /[\u0000-\u001f\u007f]/u;
|
|
16
|
+
export const listTaskCommentsTool = {
|
|
17
|
+
name: LIST_TASK_COMMENTS_TOOL_NAME,
|
|
18
|
+
description: 'Read the comments on one Canonical Task, oldest first, with edits applied. '
|
|
19
|
+
+ 'Returns only what the caller\'s verified project scope can see; a Task outside it is task_not_found. '
|
|
20
|
+
+ 'This read never writes and does not notify anyone.',
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
task_id: { type: 'string', minLength: 1, maxLength: TASK_ID_MAX_LENGTH, description: 'Canonical Task ID (ct1....).' },
|
|
25
|
+
limit: {
|
|
26
|
+
type: 'integer',
|
|
27
|
+
minimum: 1,
|
|
28
|
+
maximum: LIST_TASK_COMMENTS_MAX_LIMIT,
|
|
29
|
+
description: `Newest comments to return, at most ${LIST_TASK_COMMENTS_MAX_LIMIT} (default ${LIST_TASK_COMMENTS_DEFAULT_LIMIT}).`,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
required: ['task_id'],
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
},
|
|
35
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
36
|
+
};
|
|
37
|
+
export const addTaskCommentTool = {
|
|
38
|
+
name: ADD_TASK_COMMENT_TOOL_NAME,
|
|
39
|
+
description: 'Post a comment on a Canonical Task. Reuse the same idempotency key when retrying.',
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
task_id: { type: 'string', minLength: 1, maxLength: TASK_ID_MAX_LENGTH },
|
|
44
|
+
body: { type: 'string', minLength: 1, maxLength: MAX_COMMENT_BODY_LENGTH },
|
|
45
|
+
reply_to: { type: 'string', minLength: 1, maxLength: TASK_ID_MAX_LENGTH },
|
|
46
|
+
idempotency_key: { type: 'string', minLength: 1, maxLength: TASK_ID_MAX_LENGTH },
|
|
47
|
+
},
|
|
48
|
+
required: ['task_id', 'body', 'idempotency_key'],
|
|
49
|
+
additionalProperties: false,
|
|
50
|
+
},
|
|
51
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
52
|
+
};
|
|
53
|
+
export class TaskCommentArgumentError extends Error {
|
|
54
|
+
code = 'invalid_arguments';
|
|
55
|
+
}
|
|
56
|
+
function record(value) {
|
|
57
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : null;
|
|
58
|
+
}
|
|
59
|
+
function requiredIdentifier(value, field) {
|
|
60
|
+
const trimmed = typeof value === 'string' ? value.trim() : '';
|
|
61
|
+
if (typeof value !== 'string' || !trimmed || value.length > TASK_ID_MAX_LENGTH || CONTROL.test(value)) {
|
|
62
|
+
throw new TaskCommentArgumentError(`${field} is invalid`);
|
|
63
|
+
}
|
|
64
|
+
return trimmed;
|
|
65
|
+
}
|
|
66
|
+
export function addTaskCommentRequest(args) {
|
|
67
|
+
const input = record(args);
|
|
68
|
+
if (!input)
|
|
69
|
+
throw new TaskCommentArgumentError('arguments must be an object');
|
|
70
|
+
const unsupported = Object.keys(input).filter(key => !['task_id', 'body', 'reply_to', 'idempotency_key'].includes(key));
|
|
71
|
+
if (unsupported.length)
|
|
72
|
+
throw new TaskCommentArgumentError(`unsupported argument: ${unsupported.join(', ')}`);
|
|
73
|
+
const taskId = requiredIdentifier(input.task_id, 'task_id');
|
|
74
|
+
if (taskId === '.' || taskId === '..')
|
|
75
|
+
throw new TaskCommentArgumentError('task_id is invalid');
|
|
76
|
+
if (typeof input.body !== 'string' || !input.body.trim()
|
|
77
|
+
|| input.body.length > MAX_COMMENT_BODY_LENGTH || BODY_CONTROL.test(input.body)) {
|
|
78
|
+
throw new TaskCommentArgumentError('body is invalid');
|
|
79
|
+
}
|
|
80
|
+
const idempotencyKey = requiredIdentifier(input.idempotency_key, 'idempotency_key');
|
|
81
|
+
return {
|
|
82
|
+
method: 'POST',
|
|
83
|
+
path: `/api/companion/tasks/${encodeURIComponent(taskId)}/comments`,
|
|
84
|
+
taskId,
|
|
85
|
+
body: {
|
|
86
|
+
body: input.body,
|
|
87
|
+
idempotency_key: idempotencyKey,
|
|
88
|
+
...(input.reply_to === undefined ? {} : { reply_to: requiredIdentifier(input.reply_to, 'reply_to') }),
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** The HTTP request a host sends for `list_task_comments`. Throws TaskCommentArgumentError on bad input. */
|
|
93
|
+
export function listTaskCommentsRequest(args) {
|
|
94
|
+
const input = record(args);
|
|
95
|
+
if (!input)
|
|
96
|
+
throw new TaskCommentArgumentError('arguments must be an object');
|
|
97
|
+
const unknown = Object.keys(input).filter((key) => key !== 'task_id' && key !== 'limit');
|
|
98
|
+
if (unknown.length)
|
|
99
|
+
throw new TaskCommentArgumentError(`unsupported argument: ${unknown.join(', ')}`);
|
|
100
|
+
const raw = typeof input.task_id === 'string' ? input.task_id : '';
|
|
101
|
+
const taskId = raw.trim();
|
|
102
|
+
if (!taskId || taskId.length > TASK_ID_MAX_LENGTH || CONTROL.test(raw))
|
|
103
|
+
throw new TaskCommentArgumentError('task_id is required');
|
|
104
|
+
let query = '';
|
|
105
|
+
if (input.limit !== undefined) {
|
|
106
|
+
const limit = input.limit;
|
|
107
|
+
if (typeof limit !== 'number' || !Number.isSafeInteger(limit) || limit < 1 || limit > LIST_TASK_COMMENTS_MAX_LIMIT) {
|
|
108
|
+
throw new TaskCommentArgumentError(`limit must be an integer from 1 to ${LIST_TASK_COMMENTS_MAX_LIMIT}`);
|
|
109
|
+
}
|
|
110
|
+
query = `?limit=${limit}`;
|
|
111
|
+
}
|
|
112
|
+
return { method: 'GET', path: `/api/companion/tasks/${encodeURIComponent(taskId)}/comments${query}`, taskId };
|
|
113
|
+
}
|
|
114
|
+
function comment(value) {
|
|
115
|
+
const item = record(value);
|
|
116
|
+
if (!item)
|
|
117
|
+
return null;
|
|
118
|
+
const optionalText = (key) => item[key] === null || typeof item[key] === 'string';
|
|
119
|
+
if (typeof item.id !== 'string' || !item.id || typeof item.body !== 'string'
|
|
120
|
+
|| !optionalText('reply_to') || !optionalText('author') || !optionalText('created_at') || !optionalText('edited_at')
|
|
121
|
+
|| typeof item.version !== 'number' || !Number.isSafeInteger(item.version) || item.version < 0)
|
|
122
|
+
return null;
|
|
123
|
+
return {
|
|
124
|
+
id: item.id,
|
|
125
|
+
body: item.body,
|
|
126
|
+
reply_to: item.reply_to,
|
|
127
|
+
author: item.author,
|
|
128
|
+
created_at: item.created_at,
|
|
129
|
+
edited_at: item.edited_at,
|
|
130
|
+
version: item.version,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function responseErrorCode(payload) {
|
|
134
|
+
const nested = record(payload?.error);
|
|
135
|
+
return typeof payload?.code === 'string' ? payload.code
|
|
136
|
+
: typeof nested?.code === 'string' ? nested.code : 'task_comments_unavailable';
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Checks the API answer for the requested Task. An error answer keeps only its
|
|
140
|
+
* code; any other body detail is dropped so a store message cannot reach the agent.
|
|
141
|
+
*/
|
|
142
|
+
export function readListTaskCommentsResponse(taskId, httpStatus, body) {
|
|
143
|
+
const payload = record(body);
|
|
144
|
+
if (httpStatus < 200 || httpStatus >= 300) {
|
|
145
|
+
const code = responseErrorCode(payload);
|
|
146
|
+
return { status: 'error', error: { code, message: `Task comments could not be read (${code})`, http_status: httpStatus } };
|
|
147
|
+
}
|
|
148
|
+
const comments = Array.isArray(payload?.comments) ? payload.comments.map(comment) : null;
|
|
149
|
+
if (!payload || payload.task_id !== taskId || !comments || comments.some((item) => item === null)
|
|
150
|
+
|| typeof payload.total_count !== 'number' || !Number.isSafeInteger(payload.total_count) || payload.total_count < comments.length
|
|
151
|
+
|| typeof payload.truncated !== 'boolean') {
|
|
152
|
+
return { status: 'error', error: { code: 'task_contract_error', message: 'Task comment response does not match the requested Task' } };
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
status: 'ok',
|
|
156
|
+
page: { task_id: taskId, comments: comments, total_count: payload.total_count, truncated: payload.truncated },
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
export function readAddTaskCommentResponse(httpStatus, body) {
|
|
160
|
+
const payload = record(body);
|
|
161
|
+
if (httpStatus < 200 || httpStatus >= 300) {
|
|
162
|
+
const code = responseErrorCode(payload);
|
|
163
|
+
return { status: 'error', error: { code, message: `Task comment could not be posted (${code})`, http_status: httpStatus } };
|
|
164
|
+
}
|
|
165
|
+
const saved = comment(payload?.comment);
|
|
166
|
+
const notification = record(payload?.notification);
|
|
167
|
+
if (!payload || !saved || (httpStatus !== 200 && httpStatus !== 201) || payload?.replayed !== (httpStatus === 200)
|
|
168
|
+
|| notification?.status !== 'not_delivered' || notification.reason !== 'notification_delivery_not_configured') {
|
|
169
|
+
return { status: 'error', error: { code: 'task_contract_error', message: 'Task comment response is invalid' } };
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
status: 'ok',
|
|
173
|
+
comment: saved,
|
|
174
|
+
replayed: payload.replayed,
|
|
175
|
+
notification: { status: notification.status, reason: notification.reason },
|
|
176
|
+
};
|
|
177
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Canonical Task `list_tasks` MCP contract.
|
|
4
|
+
*
|
|
5
|
+
* The host owns authentication, tenant binding, the HTTP client and the
|
|
6
|
+
* handling of non-2xx answers. This module owns the tool schema, the request
|
|
7
|
+
* it maps to on the companion task API, and the check of a page answer, so
|
|
8
|
+
* every host lists Tasks the same way instead of keeping its own copy.
|
|
9
|
+
*
|
|
10
|
+
* Archived Tasks are left out unless the caller passes include_archived: true.
|
|
11
|
+
* Only then is a single `include_archived=true` forwarded to the list or search
|
|
12
|
+
* endpoint; false or omitted sends the same request as before archiving existed.
|
|
13
|
+
*/
|
|
14
|
+
export declare const LIST_TASKS_TOOL_NAME = "list_tasks";
|
|
15
|
+
/** The task kernel caps list pages at 50 and full-text search pages at 20. */
|
|
16
|
+
export declare const LIST_TASKS_MAX_LIMIT = 50;
|
|
17
|
+
export declare const SEARCH_TASKS_MAX_LIMIT = 20;
|
|
18
|
+
export declare const listTasksTool: Tool;
|
|
19
|
+
export declare class TaskListArgumentError extends Error {
|
|
20
|
+
readonly code = "invalid_arguments";
|
|
21
|
+
}
|
|
22
|
+
export type ListTasksResult = {
|
|
23
|
+
status: 'ok';
|
|
24
|
+
page: Record<string, unknown>;
|
|
25
|
+
} | {
|
|
26
|
+
status: 'error';
|
|
27
|
+
error: {
|
|
28
|
+
code: 'task_contract_error';
|
|
29
|
+
message: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The HTTP request a host sends for `list_tasks`, relative to the companion
|
|
34
|
+
* task API base URL. Throws TaskListArgumentError before any request is made.
|
|
35
|
+
*/
|
|
36
|
+
export declare function listTasksRequest(args: unknown): {
|
|
37
|
+
method: 'GET';
|
|
38
|
+
path: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Checks a 2xx answer is a Task page and passes it through unchanged (archived_at and
|
|
42
|
+
* archive_reason included). Non-2xx answers stay with the host's common Task error mapping.
|
|
43
|
+
*/
|
|
44
|
+
export declare function readListTasksResponse(body: unknown): ListTasksResult;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Task `list_tasks` MCP contract.
|
|
3
|
+
*
|
|
4
|
+
* The host owns authentication, tenant binding, the HTTP client and the
|
|
5
|
+
* handling of non-2xx answers. This module owns the tool schema, the request
|
|
6
|
+
* it maps to on the companion task API, and the check of a page answer, so
|
|
7
|
+
* every host lists Tasks the same way instead of keeping its own copy.
|
|
8
|
+
*
|
|
9
|
+
* Archived Tasks are left out unless the caller passes include_archived: true.
|
|
10
|
+
* Only then is a single `include_archived=true` forwarded to the list or search
|
|
11
|
+
* endpoint; false or omitted sends the same request as before archiving existed.
|
|
12
|
+
*/
|
|
13
|
+
export const LIST_TASKS_TOOL_NAME = 'list_tasks';
|
|
14
|
+
/** The task kernel caps list pages at 50 and full-text search pages at 20. */
|
|
15
|
+
export const LIST_TASKS_MAX_LIMIT = 50;
|
|
16
|
+
export const SEARCH_TASKS_MAX_LIMIT = 20;
|
|
17
|
+
const TASK_STATUSES = ['pending', 'in_progress', 'waiting', 'completed', 'cancelled'];
|
|
18
|
+
const TASK_PRIORITIES = ['low', 'medium', 'high', 'urgent'];
|
|
19
|
+
export const listTasksTool = {
|
|
20
|
+
name: LIST_TASKS_TOOL_NAME,
|
|
21
|
+
description: `List Canonical Tasks page by page (at most ${LIST_TASKS_MAX_LIMIT} per page, ${SEARCH_TASKS_MAX_LIMIT} when query is set). `
|
|
22
|
+
+ 'Follow nextCursor until it is null; totalCount and countStatus report whether the total is exact. '
|
|
23
|
+
+ 'Passing query switches to full-text search. '
|
|
24
|
+
+ 'Archived Tasks are left out unless include_archived is true; keep the same value while following nextCursor.',
|
|
25
|
+
inputSchema: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: {
|
|
28
|
+
query: { type: 'string', description: 'Optional full-text search query.' },
|
|
29
|
+
statuses: { type: 'array', items: { type: 'string', enum: [...TASK_STATUSES] } },
|
|
30
|
+
priorities: { type: 'array', items: { type: 'string', enum: [...TASK_PRIORITIES] } },
|
|
31
|
+
project_codes: { type: 'array', items: { type: 'string' } },
|
|
32
|
+
assignee_person_id: { type: 'string' },
|
|
33
|
+
due_after: { type: 'string', description: 'ISO 8601 date-time lower bound.' },
|
|
34
|
+
due_before: { type: 'string', description: 'ISO 8601 date-time upper bound.' },
|
|
35
|
+
limit: { type: 'integer', minimum: 1, maximum: LIST_TASKS_MAX_LIMIT },
|
|
36
|
+
cursor: { type: 'string' },
|
|
37
|
+
include_archived: {
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
description: 'true also returns archived Tasks within the same scope, filters and paging. Omit or false for active Tasks only.',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
// Only readOnlyHint, so a host that merges its own annotations lists the same tool as before.
|
|
44
|
+
annotations: { readOnlyHint: true },
|
|
45
|
+
};
|
|
46
|
+
export class TaskListArgumentError extends Error {
|
|
47
|
+
code = 'invalid_arguments';
|
|
48
|
+
}
|
|
49
|
+
function record(value) {
|
|
50
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : null;
|
|
51
|
+
}
|
|
52
|
+
function optionalString(args, key) {
|
|
53
|
+
const value = args[key];
|
|
54
|
+
if (value === undefined || value === null || value === '')
|
|
55
|
+
return null;
|
|
56
|
+
if (typeof value !== 'string' || !value.trim())
|
|
57
|
+
throw new TaskListArgumentError(`${key} must be a non-empty string`);
|
|
58
|
+
return value.trim();
|
|
59
|
+
}
|
|
60
|
+
function optionalStringList(args, key) {
|
|
61
|
+
const value = args[key];
|
|
62
|
+
if (value === undefined || value === null)
|
|
63
|
+
return null;
|
|
64
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== 'string' || !item.trim())) {
|
|
65
|
+
throw new TaskListArgumentError(`${key} must be an array of non-empty strings`);
|
|
66
|
+
}
|
|
67
|
+
return value.length ? value.map((item) => item.trim()) : null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The HTTP request a host sends for `list_tasks`, relative to the companion
|
|
71
|
+
* task API base URL. Throws TaskListArgumentError before any request is made.
|
|
72
|
+
*/
|
|
73
|
+
export function listTasksRequest(args) {
|
|
74
|
+
const input = record(args);
|
|
75
|
+
if (!input)
|
|
76
|
+
throw new TaskListArgumentError('arguments must be an object');
|
|
77
|
+
const query = new URLSearchParams();
|
|
78
|
+
const text = optionalString(input, 'query');
|
|
79
|
+
if (text !== null)
|
|
80
|
+
query.set('q', text);
|
|
81
|
+
const lists = [
|
|
82
|
+
['statuses', 'statuses'], ['priorities', 'priorities'], ['project_codes', 'projectCodes'],
|
|
83
|
+
];
|
|
84
|
+
for (const [key, parameter] of lists) {
|
|
85
|
+
const values = optionalStringList(input, key);
|
|
86
|
+
if (values)
|
|
87
|
+
query.set(parameter, values.join(','));
|
|
88
|
+
}
|
|
89
|
+
const scalars = [
|
|
90
|
+
['assignee_person_id', 'assigneePersonId'], ['due_after', 'dueAfter'], ['due_before', 'dueBefore'], ['cursor', 'cursor'],
|
|
91
|
+
];
|
|
92
|
+
for (const [key, parameter] of scalars) {
|
|
93
|
+
const value = optionalString(input, key);
|
|
94
|
+
if (value !== null)
|
|
95
|
+
query.set(parameter, value);
|
|
96
|
+
}
|
|
97
|
+
if (input.limit !== undefined && input.limit !== null) {
|
|
98
|
+
const maxLimit = text !== null ? SEARCH_TASKS_MAX_LIMIT : LIST_TASKS_MAX_LIMIT;
|
|
99
|
+
if (typeof input.limit !== 'number' || !Number.isInteger(input.limit) || input.limit < 1 || input.limit > maxLimit) {
|
|
100
|
+
throw new TaskListArgumentError(`limit must be an integer from 1 to ${maxLimit}`);
|
|
101
|
+
}
|
|
102
|
+
query.set('limit', String(input.limit));
|
|
103
|
+
}
|
|
104
|
+
if (input.include_archived !== undefined && input.include_archived !== null) {
|
|
105
|
+
if (typeof input.include_archived !== 'boolean')
|
|
106
|
+
throw new TaskListArgumentError('include_archived must be a boolean');
|
|
107
|
+
// The task API includes archived Tasks only for exactly one include_archived=true.
|
|
108
|
+
if (input.include_archived)
|
|
109
|
+
query.set('include_archived', 'true');
|
|
110
|
+
}
|
|
111
|
+
const suffix = query.toString();
|
|
112
|
+
return {
|
|
113
|
+
method: 'GET',
|
|
114
|
+
path: `/api/companion/tasks${text !== null ? '/search' : ''}${suffix ? `?${suffix}` : ''}`,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Checks a 2xx answer is a Task page and passes it through unchanged (archived_at and
|
|
119
|
+
* archive_reason included). Non-2xx answers stay with the host's common Task error mapping.
|
|
120
|
+
*/
|
|
121
|
+
export function readListTasksResponse(body) {
|
|
122
|
+
const page = record(body);
|
|
123
|
+
if (!page) {
|
|
124
|
+
return { status: 'error', error: { code: 'task_contract_error', message: 'Expected a Canonical Task object response' } };
|
|
125
|
+
}
|
|
126
|
+
if (!Array.isArray(page.items)) {
|
|
127
|
+
return { status: 'error', error: { code: 'task_contract_error', message: 'Expected a Canonical Task page response' } };
|
|
128
|
+
}
|
|
129
|
+
return { status: 'ok', page };
|
|
130
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unson/brainbase-mcp",
|
|
3
|
-
"version": "0.51.
|
|
3
|
+
"version": "0.51.10",
|
|
4
4
|
"description": "Local-first Brainbase judgment OS that lets supported AI agents reuse a user's approved goals, priorities, decisions, and judgment criteria.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -159,6 +159,14 @@
|
|
|
159
159
|
"types": "./dist/canonical-task-operations.d.ts",
|
|
160
160
|
"import": "./dist/canonical-task-operations.js"
|
|
161
161
|
},
|
|
162
|
+
"./canonical-task-comment-tools": {
|
|
163
|
+
"types": "./dist/canonical-task-comment-tools.d.ts",
|
|
164
|
+
"import": "./dist/canonical-task-comment-tools.js"
|
|
165
|
+
},
|
|
166
|
+
"./canonical-task-list-tools": {
|
|
167
|
+
"types": "./dist/canonical-task-list-tools.d.ts",
|
|
168
|
+
"import": "./dist/canonical-task-list-tools.js"
|
|
169
|
+
},
|
|
162
170
|
"./canonical-task-store-config": {
|
|
163
171
|
"types": "./dist/canonical-task-store-config.d.ts",
|
|
164
172
|
"import": "./dist/canonical-task-store-config.js"
|
|
@@ -673,5 +681,5 @@
|
|
|
673
681
|
"url": "https://github.com/Unson-LLC/brainbase/issues"
|
|
674
682
|
},
|
|
675
683
|
"homepage": "https://github.com/Unson-LLC/brainbase#readme",
|
|
676
|
-
"gitHead": "
|
|
684
|
+
"gitHead": "4f0cd113a8fe2048bf5c2882f2c9e1402b32497a"
|
|
677
685
|
}
|