@unson/brainbase-mcp 0.49.1 → 0.50.1
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/contracts/brainbase-public-contract.v1.json +288 -0
- package/contracts/judgment-dag/digest.json +3 -3
- package/contracts/judgment-dag/source-lock.json +1 -1
- package/dist/meeting-minutes-http.js +35 -5
- package/dist/meeting-minutes-storage-http.js +33 -4
- package/dist/meeting-minutes.d.ts +31 -0
- package/dist/meeting-minutes.js +71 -1
- package/dist/meeting-source-connection.d.ts +33 -1
- package/dist/meeting-source-connection.js +124 -1
- package/dist/meeting-source-reader.d.ts +9 -0
- package/dist/meeting-source-reader.js +10 -3
- package/dist/ownership-survey.d.ts +28 -0
- package/dist/ownership-survey.js +60 -0
- package/dist/queue-task-tools.d.ts +114 -0
- package/dist/queue-task-tools.js +263 -0
- package/dist/testing/queue-task-reference-backend.d.ts +43 -0
- package/dist/testing/queue-task-reference-backend.js +157 -0
- package/dist/testing/queue-task-tools-contract.d.ts +33 -0
- package/dist/testing/queue-task-tools-contract.js +487 -0
- package/docs/architecture/judgment-dag-core.md +13 -8
- package/package.json +21 -5
- package/ui/judgment-history.js +0 -15
- package/ui/meeting-minutes.js +18 -5
- package/ui/world/world-canvas-ui.js +25 -5
- package/ui/world/world-view.css +58 -0
- package/ui/world/world-view.js +43 -14
|
@@ -4,7 +4,7 @@ import { dirname } from 'node:path';
|
|
|
4
4
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
5
5
|
import { discoverOAuthServerInfo, exchangeAuthorization, registerClient, startAuthorization, } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
6
6
|
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
7
|
-
import { createTactiqTranscriptBudget, listMeetings, probeTranscript, readTranscript, } from './meeting-source-reader.js';
|
|
7
|
+
import { createTactiqTranscriptBudget, listMeetings, probeTranscript, readProviderSummary, readTranscript, } from './meeting-source-reader.js';
|
|
8
8
|
/**
|
|
9
9
|
* Connections to meeting sources (Plaud, Tactiq) and per-connection sync.
|
|
10
10
|
* Persistence, tenant and owner authorization, scheduling, and the delivery
|
|
@@ -370,6 +370,8 @@ export function emptyMeetingSourceSyncState(connection) {
|
|
|
370
370
|
syncEnabled: true,
|
|
371
371
|
listedThrough: null,
|
|
372
372
|
pending: [],
|
|
373
|
+
pendingSummaries: [],
|
|
374
|
+
unobtainableSummaries: [],
|
|
373
375
|
unobtainable: [],
|
|
374
376
|
delivered: {},
|
|
375
377
|
tactiqReads: [],
|
|
@@ -455,7 +457,120 @@ export async function syncMeetingSourceConnection(input) {
|
|
|
455
457
|
const budget = connection.provider === 'tactiq' ? createTactiqTranscriptBudget({ reads: state.tactiqReads }) : undefined;
|
|
456
458
|
const delivered = [];
|
|
457
459
|
let failure = null;
|
|
460
|
+
let connectionScopeFailed = false;
|
|
458
461
|
const queue = newestFirst([...candidates.values()]);
|
|
462
|
+
const summaryRetryMs = input.summaryRetryMs ?? 15 * 60 * 1000;
|
|
463
|
+
const pendingSummariesById = new Map((state.pendingSummaries ?? []).map((entry) => [entry.meeting.externalId, entry]));
|
|
464
|
+
// Meetings whose summary was read this run; the refresh pass skips them.
|
|
465
|
+
const summaryHandled = new Set();
|
|
466
|
+
/** Reads the provider summary at ingest. A failure is non-fatal: it is saved as `null`. */
|
|
467
|
+
const readDeliveredSummary = async (meeting) => {
|
|
468
|
+
const result = await readProviderSummary({ provider: connection.provider, callTool, meetingId: meeting.externalId, now });
|
|
469
|
+
if (result.status !== 'ok')
|
|
470
|
+
return null;
|
|
471
|
+
return { state: result.state, text: result.summary?.text ?? null, jobId: result.jobId, retrievedAt: now().toISOString() };
|
|
472
|
+
};
|
|
473
|
+
const trackSummary = (meeting, summary) => {
|
|
474
|
+
summaryHandled.add(meeting.externalId);
|
|
475
|
+
if (summary === null || summary.state === 'generating') {
|
|
476
|
+
const previous = pendingSummariesById.get(meeting.externalId);
|
|
477
|
+
pendingSummariesById.set(meeting.externalId, {
|
|
478
|
+
meeting,
|
|
479
|
+
jobId: summary?.jobId ?? null,
|
|
480
|
+
retryAt: new Date(now().getTime() + summaryRetryMs).toISOString(),
|
|
481
|
+
attempts: previous?.attempts ?? 0,
|
|
482
|
+
firstSeenAt: previous?.firstSeenAt ?? now().toISOString(),
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
// ready or empty: nothing left to re-read.
|
|
487
|
+
pendingSummariesById.delete(meeting.externalId);
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
const bumpSummaryRetry = (entry) => {
|
|
491
|
+
const attempts = entry.attempts + 1;
|
|
492
|
+
if (attempts >= (input.maxAttempts ?? 5)) {
|
|
493
|
+
pendingSummariesById.delete(entry.meeting.externalId);
|
|
494
|
+
(state.unobtainableSummaries ??= []).push({
|
|
495
|
+
meetingId: entry.meeting.externalId,
|
|
496
|
+
reason: 'summary_retry_exhausted',
|
|
497
|
+
message: 'Provider summary could not be resolved and delivered within maxAttempts.',
|
|
498
|
+
decidedAt: now().toISOString(),
|
|
499
|
+
});
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
pendingSummariesById.set(entry.meeting.externalId, {
|
|
503
|
+
...entry,
|
|
504
|
+
attempts,
|
|
505
|
+
retryAt: new Date(now().getTime() + summaryRetryMs).toISOString(),
|
|
506
|
+
});
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
509
|
+
* Re-reads summaries that were generating or unreadable on an earlier sync. The summary
|
|
510
|
+
* call (`get_meeting` / `get_note`) does not spend the Tactiq transcript budget;
|
|
511
|
+
* the transcript is re-read only once the summary resolves, so the saved record
|
|
512
|
+
* carries both together.
|
|
513
|
+
*/
|
|
514
|
+
const refreshGeneratingSummaries = async () => {
|
|
515
|
+
for (const entry of [...pendingSummariesById.values()]) {
|
|
516
|
+
const meetingId = entry.meeting.externalId;
|
|
517
|
+
if (summaryHandled.has(meetingId))
|
|
518
|
+
continue;
|
|
519
|
+
if (entry.retryAt && Date.parse(entry.retryAt) > currentTime)
|
|
520
|
+
continue;
|
|
521
|
+
const summaryResult = await readProviderSummary({ provider: connection.provider, callTool, meetingId, now });
|
|
522
|
+
if (summaryResult.status !== 'ok') {
|
|
523
|
+
bumpSummaryRetry(entry);
|
|
524
|
+
continue;
|
|
525
|
+
}
|
|
526
|
+
if (summaryResult.state === 'generating') {
|
|
527
|
+
bumpSummaryRetry({ ...entry, jobId: summaryResult.jobId });
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
if (budget) {
|
|
531
|
+
const slot = budget.tryAcquire(meetingId, now());
|
|
532
|
+
if (!slot.ok) {
|
|
533
|
+
pendingSummariesById.set(meetingId, { ...entry, retryAt: slot.retryAt });
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
const transcript = await readTranscript({ provider: connection.provider, callTool, meetingId, budget, now });
|
|
538
|
+
if (transcript.status !== 'complete') {
|
|
539
|
+
bumpSummaryRetry(entry);
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
const summary = {
|
|
543
|
+
state: summaryResult.state,
|
|
544
|
+
text: summaryResult.summary?.text ?? null,
|
|
545
|
+
jobId: summaryResult.jobId,
|
|
546
|
+
retrievedAt: now().toISOString(),
|
|
547
|
+
};
|
|
548
|
+
const previous = state.delivered[meetingId];
|
|
549
|
+
const version = (previous?.version ?? 0) + 1;
|
|
550
|
+
try {
|
|
551
|
+
await input.deliver({
|
|
552
|
+
connectionId: connection.connectionId,
|
|
553
|
+
tenantId: connection.tenantId,
|
|
554
|
+
provider: connection.provider,
|
|
555
|
+
scope: connection.scope,
|
|
556
|
+
ownerPersonId: connection.ownerPersonId,
|
|
557
|
+
orgId: connection.orgId,
|
|
558
|
+
meeting: entry.meeting,
|
|
559
|
+
transcript: { text: transcript.text, segments: transcript.segments, digest: transcript.digest },
|
|
560
|
+
summary,
|
|
561
|
+
version,
|
|
562
|
+
retrievedAt: now().toISOString(),
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
catch {
|
|
566
|
+
bumpSummaryRetry(entry);
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
state.delivered[meetingId] = { digest: transcript.digest, version, deliveredAt: now().toISOString() };
|
|
570
|
+
pendingSummariesById.delete(meetingId);
|
|
571
|
+
delivered.push({ meetingId, version });
|
|
572
|
+
}
|
|
573
|
+
};
|
|
459
574
|
const keepPending = (meeting, reason, message, retryAt, countAttempt) => {
|
|
460
575
|
const previous = pendingById.get(meeting.externalId);
|
|
461
576
|
const attempts = (previous?.attempts ?? 0) + (countAttempt ? 1 : 0);
|
|
@@ -492,6 +607,7 @@ export async function syncMeetingSourceConnection(input) {
|
|
|
492
607
|
for (const rest of queue.slice(index))
|
|
493
608
|
keepPending(rest, reason, message, retryAt, false);
|
|
494
609
|
failure = { reason, message };
|
|
610
|
+
connectionScopeFailed = true;
|
|
495
611
|
break;
|
|
496
612
|
}
|
|
497
613
|
keepPending(meeting, reason, message, retryAt, isFailure);
|
|
@@ -504,6 +620,7 @@ export async function syncMeetingSourceConnection(input) {
|
|
|
504
620
|
pendingById.delete(meeting.externalId);
|
|
505
621
|
continue;
|
|
506
622
|
}
|
|
623
|
+
const summary = await readDeliveredSummary(meeting);
|
|
507
624
|
const version = (previous?.version ?? 0) + 1;
|
|
508
625
|
try {
|
|
509
626
|
await input.deliver({
|
|
@@ -515,6 +632,7 @@ export async function syncMeetingSourceConnection(input) {
|
|
|
515
632
|
orgId: connection.orgId,
|
|
516
633
|
meeting,
|
|
517
634
|
transcript: { text: result.text, segments: result.segments, digest: result.digest },
|
|
635
|
+
summary,
|
|
518
636
|
version,
|
|
519
637
|
retrievedAt: now().toISOString(),
|
|
520
638
|
});
|
|
@@ -527,9 +645,14 @@ export async function syncMeetingSourceConnection(input) {
|
|
|
527
645
|
}
|
|
528
646
|
state.delivered[meeting.externalId] = { digest: result.digest, version, deliveredAt: now().toISOString() };
|
|
529
647
|
pendingById.delete(meeting.externalId);
|
|
648
|
+
trackSummary(meeting, summary);
|
|
530
649
|
delivered.push({ meetingId: meeting.externalId, version });
|
|
531
650
|
}
|
|
651
|
+
if (!connectionScopeFailed) {
|
|
652
|
+
await refreshGeneratingSummaries();
|
|
653
|
+
}
|
|
532
654
|
state.pending = [...pendingById.values()];
|
|
655
|
+
state.pendingSummaries = [...pendingSummariesById.values()];
|
|
533
656
|
if (budget)
|
|
534
657
|
state.tactiqReads = budget.reads(now());
|
|
535
658
|
if (!listed.complete) {
|
|
@@ -68,9 +68,18 @@ export interface MeetingSourceProviderSummary {
|
|
|
68
68
|
kind: 'provider_summary';
|
|
69
69
|
text: string;
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* `ready`: a usable summary is present. `generating`: the provider is still
|
|
73
|
+
* producing it (Tactiq), so it should be saved as unfinished and re-read later.
|
|
74
|
+
* `empty`: the provider has no summary for this meeting.
|
|
75
|
+
*/
|
|
76
|
+
export type MeetingSourceSummaryState = 'ready' | 'generating' | 'empty';
|
|
71
77
|
export type MeetingSourceSummaryResult = {
|
|
72
78
|
status: 'ok';
|
|
79
|
+
state: MeetingSourceSummaryState;
|
|
73
80
|
summary: MeetingSourceProviderSummary | null;
|
|
81
|
+
/** Tactiq generation job id while `state` is `generating`; `null` otherwise. */
|
|
82
|
+
jobId: string | null;
|
|
74
83
|
} | {
|
|
75
84
|
status: 'unavailable';
|
|
76
85
|
failure: MeetingSourceFailure;
|
|
@@ -99,13 +99,20 @@ export async function readProviderSummary(input) {
|
|
|
99
99
|
try {
|
|
100
100
|
if (input.provider === 'plaud') {
|
|
101
101
|
const payload = await invoke(input.callTool, 'get_note', { file_id: input.meetingId });
|
|
102
|
-
|
|
102
|
+
const summary = toSummary(extractText(payload));
|
|
103
|
+
return { status: 'ok', state: summary ? 'ready' : 'empty', summary, jobId: null };
|
|
103
104
|
}
|
|
104
105
|
const payload = asRecord(await invoke(input.callTool, 'get_meeting', { meetingId: input.meetingId }));
|
|
105
106
|
const detailed = asRecord(payload?.detailedSummary);
|
|
107
|
+
// A summary still being produced is saved as unfinished so it can be
|
|
108
|
+
// re-read with its jobId; it is never returned as a finished summary.
|
|
109
|
+
if (detailed?.status === 'generating') {
|
|
110
|
+
return { status: 'ok', state: 'generating', summary: null, jobId: stringValue(detailed.jobId) };
|
|
111
|
+
}
|
|
106
112
|
if (!detailed || detailed.status !== 'ready')
|
|
107
|
-
return { status: 'ok', summary: null };
|
|
108
|
-
|
|
113
|
+
return { status: 'ok', state: 'empty', summary: null, jobId: null };
|
|
114
|
+
const summary = toSummary(extractText(detailed.content));
|
|
115
|
+
return { status: 'ok', state: summary ? 'ready' : 'empty', summary, jobId: null };
|
|
109
116
|
}
|
|
110
117
|
catch (error) {
|
|
111
118
|
return { status: 'unavailable', failure: await classifyFailure(error, input.provider, input.callTool, 'meeting', now()) };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Repository-neutral validation for a caller-supplied ownership ledger and survey.
|
|
2
|
+
* Measurements and tenant data remain with the caller; validation performs no I/O.
|
|
3
|
+
*/
|
|
4
|
+
export interface OwnershipSurveyComponent {
|
|
5
|
+
id: string;
|
|
6
|
+
lifecycle: string;
|
|
7
|
+
current_paths?: string[];
|
|
8
|
+
retained_source_paths?: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface OwnershipSurveyEntry {
|
|
11
|
+
id: string;
|
|
12
|
+
wave: string;
|
|
13
|
+
duplicate: string;
|
|
14
|
+
production_use: string;
|
|
15
|
+
disposition: string;
|
|
16
|
+
files?: Array<{
|
|
17
|
+
path?: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export interface OwnershipSurvey {
|
|
21
|
+
version: number;
|
|
22
|
+
components?: OwnershipSurveyEntry[];
|
|
23
|
+
}
|
|
24
|
+
export interface OwnershipSurveyContract {
|
|
25
|
+
components?: OwnershipSurveyComponent[];
|
|
26
|
+
}
|
|
27
|
+
export declare const OWNERSHIP_SURVEY_WAVES: readonly string[];
|
|
28
|
+
export declare function validateOwnershipSurvey(contract: OwnershipSurveyContract | null | undefined, survey: OwnershipSurvey | null | undefined): string[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export const OWNERSHIP_SURVEY_WAVES = Object.freeze(['1', '2', '3a', '3b', '3c', '3d', '4a', '4b', '4c', '4d', '4e', '5']);
|
|
2
|
+
const SURVEY_DUPLICATES = new Set(['same', 'partial', 'none']);
|
|
3
|
+
const SURVEY_PRODUCTION_USES = new Set(['used', 'conditional', 'scripts_only', 'shim_only', 'schema_only',
|
|
4
|
+
'shim_and_schema', 'config_only', 'unused']);
|
|
5
|
+
const SURVEY_DISPOSITIONS = new Set(['move', 'switch_and_delete', 'delete_shim', 'inline_or_delete', 'delete', 'readback_and_close']);
|
|
6
|
+
export function validateOwnershipSurvey(contract, survey) {
|
|
7
|
+
if (!survey)
|
|
8
|
+
return [];
|
|
9
|
+
const errors = [];
|
|
10
|
+
if (survey.version !== 1)
|
|
11
|
+
errors.push('所有台帳の調査結果の version は 1 である必要があります');
|
|
12
|
+
const entries = new Map();
|
|
13
|
+
const components = new Map((contract?.components ?? []).map((component) => [component.id, component]));
|
|
14
|
+
for (const entry of Array.isArray(survey.components) ? survey.components : []) {
|
|
15
|
+
if (entries.has(entry?.id))
|
|
16
|
+
errors.push(`所有台帳の調査結果に項目が重複しています: ${entry?.id}`);
|
|
17
|
+
entries.set(entry?.id, entry);
|
|
18
|
+
const component = components.get(entry?.id);
|
|
19
|
+
if (!component || !['migration_pending', 'retired'].includes(component.lifecycle)) {
|
|
20
|
+
errors.push(`調査結果の項目は台帳の移設待ちか退役である必要があります: ${entry?.id}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
for (const component of contract?.components ?? []) {
|
|
24
|
+
if (component?.lifecycle !== 'migration_pending')
|
|
25
|
+
continue;
|
|
26
|
+
const entry = entries.get(component.id);
|
|
27
|
+
if (!entry) {
|
|
28
|
+
errors.push(`移設待ちの項目に調査結果(段・重複・本番での利用)がありません: ${component.id}`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (!OWNERSHIP_SURVEY_WAVES.includes(entry.wave))
|
|
32
|
+
errors.push(`${component.id} の調査結果の wave が不正です: ${entry.wave}`);
|
|
33
|
+
if (!SURVEY_DUPLICATES.has(entry.duplicate))
|
|
34
|
+
errors.push(`${component.id} の調査結果の duplicate が不正です: ${entry.duplicate}`);
|
|
35
|
+
if (!SURVEY_PRODUCTION_USES.has(entry.production_use)) {
|
|
36
|
+
errors.push(`${component.id} の調査結果の production_use が不正です: ${entry.production_use}`);
|
|
37
|
+
}
|
|
38
|
+
if (!SURVEY_DISPOSITIONS.has(entry.disposition))
|
|
39
|
+
errors.push(`${component.id} の調査結果の disposition が不正です: ${entry.disposition}`);
|
|
40
|
+
const expectedPaths = new Set([...(component.current_paths ?? []), ...(component.retained_source_paths ?? [])]);
|
|
41
|
+
if (!Array.isArray(entry.files)) {
|
|
42
|
+
errors.push(`${component.id} の調査結果に files 配列がありません`);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const actualPaths = new Set();
|
|
46
|
+
for (const file of entry.files) {
|
|
47
|
+
if (typeof file?.path !== 'string' || !expectedPaths.has(file.path)) {
|
|
48
|
+
errors.push(`${component.id} の調査結果に台帳にないパスがあります: ${file?.path}`);
|
|
49
|
+
}
|
|
50
|
+
if (actualPaths.has(file?.path))
|
|
51
|
+
errors.push(`${component.id} の調査結果のパスが重複しています: ${file?.path}`);
|
|
52
|
+
actualPaths.add(file?.path);
|
|
53
|
+
}
|
|
54
|
+
for (const expectedPath of expectedPaths) {
|
|
55
|
+
if (!actualPaths.has(expectedPath))
|
|
56
|
+
errors.push(`${component.id} の調査結果に台帳のパスがありません: ${expectedPath}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return errors.sort();
|
|
60
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
2
|
+
import type { Tool, ServerRequest, ServerNotification } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { LocalMcpRuntimeTool } from './mcp-runtime.js';
|
|
4
|
+
export declare const QUEUE_TASK_TOOLS_CONTRACT_VERSION: "queue_task_tools.v1";
|
|
5
|
+
export declare const QUEUE_TASK_TOOL_NAMES: readonly ["list_my_tasks", "get_task", "claim_task", "claim_next", "renew_claim", "attach_evidence", "update_status"];
|
|
6
|
+
export type QueueTaskToolName = (typeof QUEUE_TASK_TOOL_NAMES)[number];
|
|
7
|
+
export type QueueTaskStatus = 'pending' | 'in_progress' | 'waiting' | 'completed' | 'cancelled';
|
|
8
|
+
export type QueueTargetStatus = 'started' | 'waiting_for_review' | 'blocked' | 'done';
|
|
9
|
+
export type QueueEvidenceKind = 'pull_request' | 'ci' | 'production_readback';
|
|
10
|
+
export interface QueueAgentContext {
|
|
11
|
+
readonly kind: 'agent';
|
|
12
|
+
readonly agentId: string;
|
|
13
|
+
readonly credential: unknown;
|
|
14
|
+
}
|
|
15
|
+
export type QueueAgentResolver = (extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => QueueAgentContext | null | Promise<QueueAgentContext | null>;
|
|
16
|
+
type ResolvedKey = {
|
|
17
|
+
readonly idempotency_key: string;
|
|
18
|
+
};
|
|
19
|
+
export interface QueueListInput {
|
|
20
|
+
statuses?: QueueTaskStatus[];
|
|
21
|
+
limit?: number;
|
|
22
|
+
cursor?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface QueueGetInput {
|
|
25
|
+
task_id: string;
|
|
26
|
+
}
|
|
27
|
+
export type QueueClaimInput = ({
|
|
28
|
+
mode: 'next';
|
|
29
|
+
} | {
|
|
30
|
+
mode: 'by_id';
|
|
31
|
+
task_id: string;
|
|
32
|
+
}) & ResolvedKey;
|
|
33
|
+
export interface QueueRenewInput extends ResolvedKey {
|
|
34
|
+
task_id: string;
|
|
35
|
+
}
|
|
36
|
+
export interface QueueEvidenceInput extends ResolvedKey {
|
|
37
|
+
task_id: string;
|
|
38
|
+
expected_version: number;
|
|
39
|
+
kind: QueueEvidenceKind;
|
|
40
|
+
ref: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
export interface QueueStatusInput extends ResolvedKey {
|
|
43
|
+
task_id: string;
|
|
44
|
+
expected_version: number;
|
|
45
|
+
to_status: QueueTargetStatus;
|
|
46
|
+
waiting_on?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface QueueTask {
|
|
49
|
+
id: string;
|
|
50
|
+
version: number;
|
|
51
|
+
status: QueueTaskStatus;
|
|
52
|
+
[field: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
export interface QueueTaskPage {
|
|
55
|
+
items: QueueTask[];
|
|
56
|
+
next_cursor: string | null;
|
|
57
|
+
[field: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
export interface QueueTaskRead {
|
|
60
|
+
task: QueueTask;
|
|
61
|
+
[field: string]: unknown;
|
|
62
|
+
}
|
|
63
|
+
export type QueueClaimResult = {
|
|
64
|
+
status: 'claimed';
|
|
65
|
+
task: QueueTask;
|
|
66
|
+
claimed_until: string;
|
|
67
|
+
replayed?: boolean;
|
|
68
|
+
renew_interval_minutes?: number;
|
|
69
|
+
[field: string]: unknown;
|
|
70
|
+
} | {
|
|
71
|
+
status: 'no_claimable_task';
|
|
72
|
+
[field: string]: unknown;
|
|
73
|
+
};
|
|
74
|
+
export interface QueueRenewResult {
|
|
75
|
+
task: QueueTask;
|
|
76
|
+
claimed_until: string;
|
|
77
|
+
[field: string]: unknown;
|
|
78
|
+
}
|
|
79
|
+
export type QueueWriteOutcome = 'not_sent' | 'unknown';
|
|
80
|
+
export interface QueueTaskError {
|
|
81
|
+
code: string;
|
|
82
|
+
message: string;
|
|
83
|
+
http_status?: number;
|
|
84
|
+
details?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
export type QueueTaskResult<T> = {
|
|
87
|
+
status: 'ok';
|
|
88
|
+
queue: T;
|
|
89
|
+
} | {
|
|
90
|
+
status: 'error';
|
|
91
|
+
error: QueueTaskError;
|
|
92
|
+
} | {
|
|
93
|
+
status: 'unavailable';
|
|
94
|
+
error: QueueTaskError;
|
|
95
|
+
};
|
|
96
|
+
export interface QueueTaskBackend {
|
|
97
|
+
list(context: QueueAgentContext, input: QueueListInput): Promise<QueueTaskResult<QueueTaskPage>>;
|
|
98
|
+
get(context: QueueAgentContext, input: QueueGetInput): Promise<QueueTaskResult<QueueTaskRead>>;
|
|
99
|
+
claim(context: QueueAgentContext, input: QueueClaimInput): Promise<QueueTaskResult<QueueClaimResult>>;
|
|
100
|
+
renew(context: QueueAgentContext, input: QueueRenewInput): Promise<QueueTaskResult<QueueRenewResult>>;
|
|
101
|
+
evidence(context: QueueAgentContext, input: QueueEvidenceInput): Promise<QueueTaskResult<QueueTaskRead>>;
|
|
102
|
+
status(context: QueueAgentContext, input: QueueStatusInput): Promise<QueueTaskResult<QueueTaskRead>>;
|
|
103
|
+
}
|
|
104
|
+
export interface CreateQueueTaskToolsOptions {
|
|
105
|
+
backend?: QueueTaskBackend;
|
|
106
|
+
resolveAgent?: QueueAgentResolver;
|
|
107
|
+
generateKey?: () => string;
|
|
108
|
+
}
|
|
109
|
+
export declare class QueueTaskToolsConfigError extends Error {
|
|
110
|
+
readonly code = "queue_task_tools_config_invalid";
|
|
111
|
+
}
|
|
112
|
+
export declare const queueTaskToolDefinitions: readonly Tool[];
|
|
113
|
+
export declare function createQueueTaskTools(options: CreateQueueTaskToolsOptions): readonly LocalMcpRuntimeTool[];
|
|
114
|
+
export {};
|