@crewx/sdk 0.9.0-rc.94 → 0.9.0-rc.96
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/conversation/to-template-messages.d.ts +2 -0
- package/dist/desktop/index.d.ts +1 -0
- package/dist/desktop/index.js +3 -3
- package/dist/esm/desktop/index.js +3 -3
- package/dist/esm/index.js +305 -234
- package/dist/esm/plugins/index.js +119 -88
- package/dist/esm/process/index.js +1 -0
- package/dist/esm/repository/index.js +205 -93
- package/dist/highlight/thread-highlighter.d.ts +24 -24
- package/dist/index.browser.js +3 -3
- package/dist/index.d.ts +17 -4
- package/dist/index.js +306 -235
- package/dist/lifecycle/task-heartbeat.d.ts +41 -0
- package/dist/lifecycle/task-stop.d.ts +30 -0
- package/dist/mcp-app/errors.d.ts +7 -0
- package/dist/mcp-app/index.d.ts +6 -0
- package/dist/mcp-app/projection.d.ts +12 -0
- package/dist/mcp-app/registry.d.ts +7 -0
- package/dist/mcp-app/types.d.ts +165 -0
- package/dist/migrations/0025_task_heartbeat.sql +8 -0
- package/dist/migrations/0025_thread_app_instance_ledger.sql +2 -0
- package/dist/migrations/0026_mcp_action_source.sql +47 -0
- package/dist/migrations/meta/_journal.json +21 -0
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.js +119 -88
- package/dist/plugins/sqlite-tracing.d.ts +10 -0
- package/dist/process/index.d.ts +2 -0
- package/dist/process/index.js +1 -0
- package/dist/process/process-control.d.ts +40 -0
- package/dist/repository/index.d.ts +13 -2
- package/dist/repository/index.js +255 -143
- package/dist/repository/task-status.d.ts +14 -0
- package/dist/repository/task.repository.d.ts +69 -8
- package/dist/repository/usage-backfill.d.ts +62 -0
- package/dist/repository/usage-from-logs.d.ts +21 -0
- package/dist/schema/tasks.d.ts +55 -0
- package/dist/schema/ui-instances.d.ts +19 -0
- package/dist/types/index.d.ts +5 -2
- package/dist/ui-instance/index.d.ts +2 -1
- package/dist/ui-instance/store.d.ts +20 -1
- package/dist/ui-instance/types.d.ts +9 -3
- package/dist/utils/runner-env.d.ts +3 -0
- package/package.json +8 -1
- package/templates/agents/default.yaml +16 -10
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { TaskRepository } from '../repository/task.repository.js';
|
|
2
|
+
export declare const TASK_HEARTBEAT_INTERVAL_MS = 10000;
|
|
3
|
+
export declare const TASK_HEARTBEAT_STALE_MS = 30000;
|
|
4
|
+
export declare const TASK_HEARTBEAT_HARD_STALE_MS: number;
|
|
5
|
+
export declare const TASK_STOP_POLL_INTERVAL_MS = 1000;
|
|
6
|
+
export declare function resolveTaskHeartbeatIntervalMs(): number;
|
|
7
|
+
export declare function resolveTaskHeartbeatStaleMs(): number;
|
|
8
|
+
export declare function resolveTaskHeartbeatHardStaleMs(): number;
|
|
9
|
+
export interface TaskHeartbeatRow {
|
|
10
|
+
id?: string;
|
|
11
|
+
status: string;
|
|
12
|
+
run_epoch: number | null;
|
|
13
|
+
stop_requested_at: string | null;
|
|
14
|
+
stop_requested_epoch: number | null;
|
|
15
|
+
pid?: number | null;
|
|
16
|
+
metadata?: string | null;
|
|
17
|
+
started_at?: string;
|
|
18
|
+
duration_ms?: number | null;
|
|
19
|
+
}
|
|
20
|
+
export interface HeartbeatTickResult {
|
|
21
|
+
accepted: boolean;
|
|
22
|
+
row: TaskHeartbeatRow | null;
|
|
23
|
+
}
|
|
24
|
+
export interface TaskHeartbeatOptions {
|
|
25
|
+
taskId: string;
|
|
26
|
+
runEpoch: number;
|
|
27
|
+
onStopRequested?: (row: TaskHeartbeatRow) => void | Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export interface TaskHeartbeatHandle {
|
|
30
|
+
timer: ReturnType<typeof setInterval>;
|
|
31
|
+
runEpoch: number;
|
|
32
|
+
stopRequested: boolean;
|
|
33
|
+
lastHeartbeatAt: number;
|
|
34
|
+
heartbeatElapsedMs: number;
|
|
35
|
+
}
|
|
36
|
+
export declare const taskHeartbeatRegistry: Map<string, TaskHeartbeatHandle>;
|
|
37
|
+
export declare function runHeartbeatTick(repo: Pick<TaskRepository, 'heartbeatTask' | 'getTask'>, options: TaskHeartbeatOptions & {
|
|
38
|
+
writeHeartbeat?: boolean;
|
|
39
|
+
}): HeartbeatTickResult;
|
|
40
|
+
export declare function stopTaskHeartbeat(taskId: string, runEpoch?: number | null): boolean;
|
|
41
|
+
export declare function startTaskHeartbeat(repo: Pick<TaskRepository, 'heartbeatTask' | 'getTask'>, options: TaskHeartbeatOptions): boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { TaskRepository } from '../repository/task.repository.js';
|
|
2
|
+
import { checkProcessOwnershipAsync as defaultCheckProcessOwnershipAsync, terminateProcessTree as defaultTerminateProcessTree, type ProcessControlOptions } from '../process/process-control.js';
|
|
3
|
+
export declare const TASK_STOP_DEFAULT_GRACE_MS = 5000;
|
|
4
|
+
export declare const TASK_STOP_DEFAULT_POLL_MS = 250;
|
|
5
|
+
export declare function resolveTaskStopMethod(requestedAt: string | null | undefined, completedAt?: string | number, graceMs?: number): 'cooperative' | 'forced';
|
|
6
|
+
export declare const TASK_STOP_OWNED_PROCESS_MARKERS: readonly ["crewx", "claude", "codex", "opencode", "grok", "node"];
|
|
7
|
+
export type StopTaskStatus = 'stopped' | 'not_running' | 'already_requested' | 'ownership_unverified' | 'failed';
|
|
8
|
+
export interface StopTaskResult {
|
|
9
|
+
status: StopTaskStatus;
|
|
10
|
+
method?: 'cooperative' | 'forced';
|
|
11
|
+
finalStatus: string | null;
|
|
12
|
+
pid?: number;
|
|
13
|
+
error?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface StopTaskProcessControl {
|
|
16
|
+
checkProcessOwnershipAsync?: typeof defaultCheckProcessOwnershipAsync;
|
|
17
|
+
terminateProcessTree?: typeof defaultTerminateProcessTree;
|
|
18
|
+
}
|
|
19
|
+
export interface StopTaskOptions {
|
|
20
|
+
graceMs?: number;
|
|
21
|
+
pollMs?: number;
|
|
22
|
+
platform?: NodeJS.Platform;
|
|
23
|
+
ownershipMarkers?: readonly string[];
|
|
24
|
+
processControl?: StopTaskProcessControl;
|
|
25
|
+
processControlOptions?: ProcessControlOptions;
|
|
26
|
+
}
|
|
27
|
+
type StopTaskRepository = Pick<TaskRepository, 'requestTaskStop' | 'getTask' | 'finalizeTaskStop'>;
|
|
28
|
+
export declare function stopTask(taskId: string, options?: StopTaskOptions): Promise<StopTaskResult>;
|
|
29
|
+
export declare function stopTask(repo: StopTaskRepository, taskId: string, options?: StopTaskOptions): Promise<StopTaskResult>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type McpAppContractErrorCode = 'APP_ID_INVALID' | 'APP_ID_CONFLICT' | 'TOOL_ID_INVALID' | 'TOOL_ID_CONFLICT' | 'RESOURCE_URI_INVALID' | 'RESOURCE_NOT_FOUND' | 'HTML_INVALID' | 'TOOL_INVALID' | 'STATE_INVALID' | 'STATE_PROJECTION_INVALID' | 'BUTTON_INVALID' | 'SERIALIZATION_INVALID';
|
|
2
|
+
export declare class McpAppContractError extends Error {
|
|
3
|
+
readonly code: McpAppContractErrorCode;
|
|
4
|
+
readonly name = "McpAppContractError";
|
|
5
|
+
constructor(code: McpAppContractErrorCode, message?: string);
|
|
6
|
+
}
|
|
7
|
+
export declare function rejectMcpApp(code: McpAppContractErrorCode, message?: string): never;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { McpAppContractErrorCode } from './errors.js';
|
|
2
|
+
export { McpAppContractError } from './errors.js';
|
|
3
|
+
export { createMcpAppRegistry, createBuiltinMcpAppRegistry, registerMcpApp, resolveMcpAppResource, requireMcpAppResource, toMcpAppToolRegistration, } from './registry.js';
|
|
4
|
+
export { buildMcpAppStateDescriptor, buildMcpAppStateProjections, buildTerminalMcpAppStateDescriptor, buildTerminalMcpAppStateProjections, createMcpAppToolResult, serializeMcpAppStateJson, serializeMcpAppStateXml, } from './projection.js';
|
|
5
|
+
export { MCP_APP_HOST_TOOL_ALLOWLIST, MCP_APP_RESOURCE_MIME_TYPE, MCP_APP_RESOURCE_URI_PREFIX, } from './types.js';
|
|
6
|
+
export type { McpAppActionDispatcherToolInput, McpAppActionToolDescriptor, McpAppActionToolInput, McpAppButtonDescriptor, McpAppButtonInput, McpAppDescriptor, McpAppDescriptorInput, McpAppInputSchema, McpAppTone, McpUiResourceCsp, McpAppRegistry, McpAppResource, McpAppServerStateInput, McpAppStateDescriptor, McpAppStateProjections, McpAppHostToolInput, McpAppHostToolName, McpAppReadToolInput, McpAppSingleActionToolInput, McpAppToolCommonInput, McpAppToolDescriptor, McpAppToolInput, McpAppToolMetadata, McpAppToolRegistration, McpAppToolResult, McpAppToolVisibility, } from './types.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { JsonObject } from '../ui-instance/types.js';
|
|
2
|
+
import type { McpAppServerStateInput, McpAppStateDescriptor, McpAppStateProjections, McpAppToolDescriptor, McpAppToolResult } from './types.js';
|
|
3
|
+
export declare function buildMcpAppStateDescriptor(input: McpAppServerStateInput): McpAppStateDescriptor;
|
|
4
|
+
export declare function buildTerminalMcpAppStateDescriptor(input: McpAppServerStateInput): McpAppStateDescriptor;
|
|
5
|
+
export declare function serializeMcpAppStateJson(descriptor: McpAppStateDescriptor): string;
|
|
6
|
+
export declare function serializeMcpAppStateXml(descriptor: McpAppStateDescriptor): string;
|
|
7
|
+
export declare function buildMcpAppStateProjections(input: McpAppServerStateInput): McpAppStateProjections;
|
|
8
|
+
export declare function buildTerminalMcpAppStateProjections(input: McpAppServerStateInput): McpAppStateProjections;
|
|
9
|
+
export declare function createMcpAppToolResult(tool: Pick<McpAppToolDescriptor, 'textFallback'>, options?: {
|
|
10
|
+
structuredContent?: JsonObject;
|
|
11
|
+
meta?: JsonObject;
|
|
12
|
+
}): McpAppToolResult;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type McpAppDescriptor, type McpAppDescriptorInput, type McpAppRegistry, type McpAppResource, type McpAppToolDescriptor, type McpAppToolRegistration } from './types.js';
|
|
2
|
+
export declare function createMcpAppRegistry(): McpAppRegistry;
|
|
3
|
+
export declare function createBuiltinMcpAppRegistry(): McpAppRegistry;
|
|
4
|
+
export declare function registerMcpApp(registry: McpAppRegistry, input: McpAppDescriptorInput): McpAppDescriptor;
|
|
5
|
+
export declare function resolveMcpAppResource(registry: McpAppRegistry, uri: string): McpAppResource | null;
|
|
6
|
+
export declare function requireMcpAppResource(registry: McpAppRegistry, uri: string): McpAppResource;
|
|
7
|
+
export declare function toMcpAppToolRegistration(tool: McpAppToolDescriptor): McpAppToolRegistration;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { JsonObject, UiDefinition, UiDefinitionRef, UiInstance, UiInstanceStatus, UiActionConfirmation } from '../ui-instance/types.js';
|
|
2
|
+
export declare const MCP_APP_RESOURCE_MIME_TYPE: "text/html;profile=mcp-app";
|
|
3
|
+
export declare const MCP_APP_RESOURCE_URI_PREFIX = "ui://crewx/";
|
|
4
|
+
export type McpAppToolVisibility = 'model' | 'app';
|
|
5
|
+
export type McpAppTone = 'blue' | 'violet' | 'emerald' | 'amber' | 'rose' | 'sky' | 'slate' | 'indigo';
|
|
6
|
+
export declare const MCP_APP_HOST_TOOL_ALLOWLIST: readonly ["crewx_app_terminal_connect"];
|
|
7
|
+
export type McpAppHostToolName = typeof MCP_APP_HOST_TOOL_ALLOWLIST[number];
|
|
8
|
+
export interface McpUiResourceCsp {
|
|
9
|
+
readonly connectDomains?: readonly string[];
|
|
10
|
+
readonly resourceDomains?: readonly string[];
|
|
11
|
+
readonly frameDomains?: readonly string[];
|
|
12
|
+
readonly baseUriDomains?: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
export type McpAppInputSchema = JsonObject;
|
|
15
|
+
export interface McpAppToolCommonInput {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly description: string;
|
|
18
|
+
readonly inputSchema: McpAppInputSchema;
|
|
19
|
+
readonly textFallback: string;
|
|
20
|
+
readonly visibility: readonly McpAppToolVisibility[];
|
|
21
|
+
}
|
|
22
|
+
export interface McpAppReadToolInput extends McpAppToolCommonInput {
|
|
23
|
+
readonly kind: 'read';
|
|
24
|
+
readonly actionId?: never;
|
|
25
|
+
}
|
|
26
|
+
export interface McpAppSingleActionToolInput extends McpAppToolCommonInput {
|
|
27
|
+
readonly kind: 'action';
|
|
28
|
+
readonly actionId: string;
|
|
29
|
+
readonly actionIds?: never;
|
|
30
|
+
}
|
|
31
|
+
export interface McpAppActionDispatcherToolInput extends McpAppToolCommonInput {
|
|
32
|
+
readonly kind: 'action';
|
|
33
|
+
readonly actionId?: never;
|
|
34
|
+
readonly actionIds: readonly string[];
|
|
35
|
+
}
|
|
36
|
+
export type McpAppActionToolInput = McpAppSingleActionToolInput | McpAppActionDispatcherToolInput;
|
|
37
|
+
export type McpAppActionToolDescriptor = (Omit<McpAppSingleActionToolInput, 'actionIds'> & {
|
|
38
|
+
readonly actionIds: readonly string[];
|
|
39
|
+
}) | (Omit<McpAppActionDispatcherToolInput, 'actionId'> & {
|
|
40
|
+
readonly actionIds: readonly string[];
|
|
41
|
+
});
|
|
42
|
+
type McpAppToolDescriptorMetadata = {
|
|
43
|
+
readonly resourceUri: string;
|
|
44
|
+
readonly _meta: McpAppToolMetadata;
|
|
45
|
+
};
|
|
46
|
+
export interface McpAppHostToolInput extends Omit<McpAppToolCommonInput, 'name' | 'visibility'> {
|
|
47
|
+
readonly name: McpAppHostToolName;
|
|
48
|
+
readonly kind: 'host';
|
|
49
|
+
readonly visibility: readonly ['app'];
|
|
50
|
+
readonly actionId?: never;
|
|
51
|
+
}
|
|
52
|
+
export type McpAppToolInput = McpAppReadToolInput | McpAppActionToolInput | McpAppHostToolInput;
|
|
53
|
+
export interface McpAppDescriptorInput {
|
|
54
|
+
readonly appId: string;
|
|
55
|
+
readonly html: string;
|
|
56
|
+
readonly name?: string;
|
|
57
|
+
readonly description?: string;
|
|
58
|
+
readonly icon?: string;
|
|
59
|
+
readonly tone?: McpAppTone;
|
|
60
|
+
readonly builtinOnly?: boolean;
|
|
61
|
+
readonly csp?: McpUiResourceCsp;
|
|
62
|
+
readonly tools: readonly McpAppToolInput[];
|
|
63
|
+
readonly definition?: UiDefinition;
|
|
64
|
+
}
|
|
65
|
+
export interface McpAppResource {
|
|
66
|
+
readonly uri: string;
|
|
67
|
+
readonly mimeType: typeof MCP_APP_RESOURCE_MIME_TYPE;
|
|
68
|
+
readonly text: string;
|
|
69
|
+
readonly _meta?: {
|
|
70
|
+
readonly ui?: {
|
|
71
|
+
readonly csp?: McpUiResourceCsp;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export interface McpAppToolMetadata {
|
|
76
|
+
readonly ui: {
|
|
77
|
+
readonly resourceUri: string;
|
|
78
|
+
readonly visibility: readonly McpAppToolVisibility[];
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export type McpAppToolDescriptor = (McpAppReadToolInput & McpAppToolDescriptorMetadata) | (McpAppActionToolDescriptor & McpAppToolDescriptorMetadata) | (McpAppHostToolInput & McpAppToolDescriptorMetadata);
|
|
82
|
+
export interface McpAppToolRegistration {
|
|
83
|
+
readonly name: string;
|
|
84
|
+
readonly description: string;
|
|
85
|
+
readonly inputSchema: McpAppInputSchema;
|
|
86
|
+
readonly _meta: McpAppToolMetadata;
|
|
87
|
+
}
|
|
88
|
+
export interface McpAppDescriptor {
|
|
89
|
+
readonly appId: string;
|
|
90
|
+
readonly name: string;
|
|
91
|
+
readonly description: string;
|
|
92
|
+
readonly icon?: string;
|
|
93
|
+
readonly tone?: McpAppTone;
|
|
94
|
+
readonly builtinOnly: boolean;
|
|
95
|
+
readonly csp?: McpUiResourceCsp;
|
|
96
|
+
readonly uiUri: string;
|
|
97
|
+
readonly html: string;
|
|
98
|
+
readonly definition?: UiDefinition;
|
|
99
|
+
readonly tools: readonly McpAppToolDescriptor[];
|
|
100
|
+
}
|
|
101
|
+
export interface McpAppToolResult {
|
|
102
|
+
readonly content: readonly [{
|
|
103
|
+
readonly type: 'text';
|
|
104
|
+
readonly text: string;
|
|
105
|
+
}];
|
|
106
|
+
readonly structuredContent?: JsonObject;
|
|
107
|
+
readonly _meta?: JsonObject;
|
|
108
|
+
}
|
|
109
|
+
export interface McpAppButtonInput {
|
|
110
|
+
readonly id: string;
|
|
111
|
+
readonly label: string;
|
|
112
|
+
readonly enabled: boolean;
|
|
113
|
+
readonly confirmation?: UiActionConfirmation;
|
|
114
|
+
readonly requiresHumanConfirmation?: boolean;
|
|
115
|
+
readonly disabledReason?: string;
|
|
116
|
+
readonly inputSchema: McpAppInputSchema;
|
|
117
|
+
}
|
|
118
|
+
export interface McpAppServerStateInput {
|
|
119
|
+
readonly source: 'server';
|
|
120
|
+
readonly instance: Pick<UiInstance, 'id' | 'definition' | 'revision' | 'status' | 'state'>;
|
|
121
|
+
readonly definition: UiDefinition;
|
|
122
|
+
readonly buttons: readonly McpAppButtonInput[];
|
|
123
|
+
}
|
|
124
|
+
export interface McpAppButtonDescriptor {
|
|
125
|
+
readonly id: string;
|
|
126
|
+
readonly label: string;
|
|
127
|
+
readonly enabled: boolean;
|
|
128
|
+
readonly confirmation: UiActionConfirmation;
|
|
129
|
+
readonly requiresHumanConfirmation?: boolean;
|
|
130
|
+
readonly disabledReason: string | null;
|
|
131
|
+
readonly inputSchema: McpAppInputSchema;
|
|
132
|
+
}
|
|
133
|
+
export interface McpAppStateDescriptor {
|
|
134
|
+
readonly schemaVersion: 1;
|
|
135
|
+
readonly source: 'server';
|
|
136
|
+
readonly instanceId: string;
|
|
137
|
+
readonly definition: UiDefinitionRef;
|
|
138
|
+
readonly revision: number;
|
|
139
|
+
readonly status: UiInstanceStatus;
|
|
140
|
+
readonly state: JsonObject;
|
|
141
|
+
readonly buttons: readonly McpAppButtonDescriptor[];
|
|
142
|
+
}
|
|
143
|
+
export interface McpAppStateProjections {
|
|
144
|
+
readonly descriptor: McpAppStateDescriptor;
|
|
145
|
+
readonly card: McpAppStateDescriptor;
|
|
146
|
+
readonly developer: {
|
|
147
|
+
readonly descriptor: McpAppStateDescriptor;
|
|
148
|
+
readonly json: string;
|
|
149
|
+
};
|
|
150
|
+
readonly ai: {
|
|
151
|
+
readonly descriptor: McpAppStateDescriptor;
|
|
152
|
+
readonly json: string;
|
|
153
|
+
readonly xml: string;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
export interface McpAppRegistry {
|
|
157
|
+
registerMcpApp(input: McpAppDescriptorInput): McpAppDescriptor;
|
|
158
|
+
getMcpApp(appId: string): McpAppDescriptor | null;
|
|
159
|
+
listMcpApps(): readonly McpAppDescriptor[];
|
|
160
|
+
listMcpAppTools(): readonly McpAppToolDescriptor[];
|
|
161
|
+
resolveMcpAppTool(toolName: string): McpAppToolDescriptor | null;
|
|
162
|
+
resolveMcpAppResource(uri: string): McpAppResource | null;
|
|
163
|
+
requireMcpAppResource(uri: string): McpAppResource;
|
|
164
|
+
}
|
|
165
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
ALTER TABLE `tasks` ADD `heartbeat_at` text;
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
ALTER TABLE `tasks` ADD `stop_requested_at` text;
|
|
4
|
+
--> statement-breakpoint
|
|
5
|
+
ALTER TABLE `tasks` ADD `stop_requested_epoch` integer;
|
|
6
|
+
--> statement-breakpoint
|
|
7
|
+
CREATE INDEX IF NOT EXISTS `idx_tasks_status_heartbeat`
|
|
8
|
+
ON `tasks` (`status`, `heartbeat_at`);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
ALTER TABLE `ui_instances` ADD `app_id` text CONSTRAINT "ui_instances_app_id_ck" CHECK("ui_instances"."app_id" IS NULL OR length("ui_instances"."app_id") BETWEEN 1 AND 128);--> statement-breakpoint
|
|
2
|
+
CREATE UNIQUE INDEX IF NOT EXISTS `ui_instances_workspace_thread_app_uq` ON `ui_instances` (`workspace_id`,`thread_id`,`app_id`);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
PRAGMA foreign_keys=OFF;--> statement-breakpoint
|
|
2
|
+
CREATE TABLE `__new_ui_action_receipts` (
|
|
3
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
4
|
+
`instance_id` text NOT NULL,
|
|
5
|
+
`request_id` text NOT NULL,
|
|
6
|
+
`action_id` text NOT NULL,
|
|
7
|
+
`actor_json` text NOT NULL,
|
|
8
|
+
`source` text NOT NULL,
|
|
9
|
+
`expected_revision` integer NOT NULL,
|
|
10
|
+
`before_revision` integer NOT NULL,
|
|
11
|
+
`after_revision` integer,
|
|
12
|
+
`status` text NOT NULL,
|
|
13
|
+
`outcome` text,
|
|
14
|
+
`input_json` text NOT NULL,
|
|
15
|
+
`result_json` text,
|
|
16
|
+
`error_code` text,
|
|
17
|
+
`requested_at` integer NOT NULL,
|
|
18
|
+
`settled_at` integer,
|
|
19
|
+
CONSTRAINT "ui_action_receipts_id_ck" CHECK(length("__new_ui_action_receipts"."id") BETWEEN 5 AND 128),
|
|
20
|
+
CONSTRAINT "ui_action_receipts_instance_id_ck" CHECK(length("__new_ui_action_receipts"."instance_id") BETWEEN 1 AND 128),
|
|
21
|
+
CONSTRAINT "ui_action_receipts_request_id_ck" CHECK(length("__new_ui_action_receipts"."request_id") BETWEEN 1 AND 128),
|
|
22
|
+
CONSTRAINT "ui_action_receipts_action_id_ck" CHECK(length("__new_ui_action_receipts"."action_id") BETWEEN 1 AND 128),
|
|
23
|
+
CONSTRAINT "ui_action_receipts_actor_json_ck" CHECK(json_valid("__new_ui_action_receipts"."actor_json") AND json_type("__new_ui_action_receipts"."actor_json") = 'object'),
|
|
24
|
+
CONSTRAINT "ui_action_receipts_source_ck" CHECK("__new_ui_action_receipts"."source" IN ('ui_host', 'cli', 'system', 'mcp')),
|
|
25
|
+
CONSTRAINT "ui_action_receipts_expected_revision_ck" CHECK("__new_ui_action_receipts"."expected_revision" >= 0),
|
|
26
|
+
CONSTRAINT "ui_action_receipts_before_revision_ck" CHECK("__new_ui_action_receipts"."before_revision" >= 0),
|
|
27
|
+
CONSTRAINT "ui_action_receipts_after_revision_ck" CHECK("__new_ui_action_receipts"."after_revision" IS NULL OR "__new_ui_action_receipts"."after_revision" >= 0),
|
|
28
|
+
CONSTRAINT "ui_action_receipts_status_ck" CHECK("__new_ui_action_receipts"."status" IN ('requested', 'settled')),
|
|
29
|
+
CONSTRAINT "ui_action_receipts_outcome_ck" CHECK("__new_ui_action_receipts"."outcome" IS NULL OR "__new_ui_action_receipts"."outcome" IN ('succeeded', 'rejected', 'failed', 'conflicted', 'expired')),
|
|
30
|
+
CONSTRAINT "ui_action_receipts_input_json_ck" CHECK(json_valid("__new_ui_action_receipts"."input_json") AND json_type("__new_ui_action_receipts"."input_json") = 'object'),
|
|
31
|
+
CONSTRAINT "ui_action_receipts_result_json_ck" CHECK("__new_ui_action_receipts"."result_json" IS NULL OR (json_valid("__new_ui_action_receipts"."result_json") AND json_type("__new_ui_action_receipts"."result_json") = 'object')),
|
|
32
|
+
CONSTRAINT "ui_action_receipts_requested_at_ck" CHECK("__new_ui_action_receipts"."requested_at" >= 0),
|
|
33
|
+
CONSTRAINT "ui_action_receipts_settled_at_ck" CHECK("__new_ui_action_receipts"."settled_at" IS NULL OR "__new_ui_action_receipts"."settled_at" >= "__new_ui_action_receipts"."requested_at"),
|
|
34
|
+
CONSTRAINT "ui_action_receipts_status_transition_ck" CHECK((
|
|
35
|
+
("__new_ui_action_receipts"."status" = 'requested' AND "__new_ui_action_receipts"."after_revision" IS NULL AND "__new_ui_action_receipts"."outcome" IS NULL AND "__new_ui_action_receipts"."settled_at" IS NULL)
|
|
36
|
+
OR
|
|
37
|
+
("__new_ui_action_receipts"."status" = 'settled' AND "__new_ui_action_receipts"."after_revision" IS NOT NULL AND "__new_ui_action_receipts"."outcome" IS NOT NULL AND "__new_ui_action_receipts"."settled_at" IS NOT NULL)
|
|
38
|
+
))
|
|
39
|
+
);
|
|
40
|
+
--> statement-breakpoint
|
|
41
|
+
INSERT INTO `__new_ui_action_receipts`("id", "instance_id", "request_id", "action_id", "actor_json", "source", "expected_revision", "before_revision", "after_revision", "status", "outcome", "input_json", "result_json", "error_code", "requested_at", "settled_at") SELECT "id", "instance_id", "request_id", "action_id", "actor_json", "source", "expected_revision", "before_revision", "after_revision", "status", "outcome", "input_json", "result_json", "error_code", "requested_at", "settled_at" FROM `ui_action_receipts`;--> statement-breakpoint
|
|
42
|
+
DROP TABLE `ui_action_receipts`;--> statement-breakpoint
|
|
43
|
+
ALTER TABLE `__new_ui_action_receipts` RENAME TO `ui_action_receipts`;--> statement-breakpoint
|
|
44
|
+
PRAGMA foreign_keys=ON;--> statement-breakpoint
|
|
45
|
+
CREATE UNIQUE INDEX `ui_action_receipts_instance_request_uq` ON `ui_action_receipts` (`instance_id`,`request_id`);--> statement-breakpoint
|
|
46
|
+
CREATE INDEX `ui_action_receipts_instance_id_idx` ON `ui_action_receipts` (`instance_id`);--> statement-breakpoint
|
|
47
|
+
CREATE INDEX `ui_action_receipts_requested_at_idx` ON `ui_action_receipts` (`requested_at`);
|
|
@@ -176,6 +176,27 @@
|
|
|
176
176
|
"when": 1788604428845,
|
|
177
177
|
"tag": "0024_storage_metadata",
|
|
178
178
|
"breakpoints": true
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"idx": 25,
|
|
182
|
+
"version": "6",
|
|
183
|
+
"when": 1788854442066,
|
|
184
|
+
"tag": "0025_thread_app_instance_ledger",
|
|
185
|
+
"breakpoints": true
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"idx": 26,
|
|
189
|
+
"version": "6",
|
|
190
|
+
"when": 1788944186188,
|
|
191
|
+
"tag": "0026_mcp_action_source",
|
|
192
|
+
"breakpoints": true
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"idx": 27,
|
|
196
|
+
"version": "6",
|
|
197
|
+
"when": 1789128000000,
|
|
198
|
+
"tag": "0025_task_heartbeat",
|
|
199
|
+
"breakpoints": true
|
|
179
200
|
}
|
|
180
201
|
]
|
|
181
202
|
}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { FileLoggerPlugin } from './file-logger';
|
|
2
2
|
export type { FileLoggerPluginOptions } from './file-logger';
|
|
3
3
|
export { SqliteTracingPlugin } from './sqlite-tracing';
|
|
4
|
-
export type { SqliteTracingPluginOptions } from './sqlite-tracing';
|
|
4
|
+
export type { SqliteTracingPluginOptions, SqliteTracingRunnerIdentity } from './sqlite-tracing';
|
|
5
5
|
export { ConversationPlugin } from './conversation';
|
|
6
6
|
export type { ConversationPluginOptions } from './conversation';
|