@crewx/sdk 0.9.0-rc.11 → 0.9.0-rc.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/README.md +1 -1
  2. package/dist/account/auth-client.d.ts +61 -0
  3. package/dist/account/auth-json-v2.d.ts +1 -0
  4. package/dist/account/auth-json.d.ts +30 -0
  5. package/dist/account/config.d.ts +37 -0
  6. package/dist/account/env-bootstrap.d.ts +5 -0
  7. package/dist/account/errors.d.ts +24 -0
  8. package/dist/account/index.d.ts +12 -0
  9. package/dist/account/index.js +2 -0
  10. package/dist/account/session-manager.d.ts +47 -0
  11. package/dist/activity-log/builder.d.ts +56 -6
  12. package/dist/agent/agent-list-view.d.ts +19 -0
  13. package/dist/boxing/box.types.d.ts +4 -0
  14. package/dist/config/canonicalize-agent-options.d.ts +17 -0
  15. package/dist/config/default-agent-models.d.ts +11 -0
  16. package/dist/config/global-settings.d.ts +33 -0
  17. package/dist/config/migrate-grok-mode.d.ts +6 -0
  18. package/dist/config/model-compat.d.ts +31 -0
  19. package/dist/config/models.generated.d.ts +37 -0
  20. package/dist/config/models.remote.d.ts +1 -0
  21. package/dist/config/overdrive.d.ts +7 -0
  22. package/dist/config/pricing.d.ts +7 -3
  23. package/dist/config/pricing.generated.d.ts +4 -0
  24. package/dist/config/pricing.types.d.ts +4 -10
  25. package/dist/config/timeout.config.d.ts +4 -0
  26. package/dist/config/wi-boards.d.ts +19 -0
  27. package/dist/context-budget/continuity.d.ts +61 -0
  28. package/dist/context-budget/index.d.ts +141 -0
  29. package/dist/conversation/index.d.ts +1 -1
  30. package/dist/conversation/sqlite-provider.d.ts +6 -2
  31. package/dist/conversation/to-template-messages.d.ts +9 -0
  32. package/dist/conversation/types.d.ts +47 -1
  33. package/dist/desktop/command-runner.d.ts +4 -0
  34. package/dist/desktop/default-adapters.d.ts +4 -0
  35. package/dist/desktop/global-install.d.ts +19 -0
  36. package/dist/desktop/index.d.ts +3 -0
  37. package/dist/desktop/index.js +3 -0
  38. package/dist/desktop/install.d.ts +5 -0
  39. package/dist/desktop/lnk.d.ts +22 -0
  40. package/dist/desktop/manifest.d.ts +21 -0
  41. package/dist/desktop/types.d.ts +67 -0
  42. package/dist/desktop/version.d.ts +1 -0
  43. package/dist/desktop/windows-paths.d.ts +21 -0
  44. package/dist/desktop/wrapper.d.ts +18 -0
  45. package/dist/esm/account/index.js +2 -0
  46. package/dist/esm/desktop/index.js +3 -0
  47. package/dist/esm/index.js +700 -183
  48. package/dist/esm/plugins/index.js +302 -180
  49. package/dist/esm/process/index.js +1 -0
  50. package/dist/esm/publish/index.js +2 -0
  51. package/dist/esm/repository/index.js +370 -170
  52. package/dist/esm/skills/index.js +1 -0
  53. package/dist/esm/testing/index.js +1 -1
  54. package/dist/events/types.d.ts +9 -0
  55. package/dist/facade/Crewx.d.ts +54 -4
  56. package/dist/highlight/thread-highlight-prompt.d.ts +2 -0
  57. package/dist/highlight/thread-highlighter.d.ts +326 -0
  58. package/dist/index.browser.d.ts +14 -1
  59. package/dist/index.browser.js +6 -2
  60. package/dist/index.d.ts +106 -15
  61. package/dist/index.js +700 -183
  62. package/dist/internal/console-decoder.d.ts +38 -0
  63. package/dist/internal/windows-spawn.d.ts +10 -0
  64. package/dist/layout/types.d.ts +18 -1
  65. package/dist/lifecycle/task-heartbeat.d.ts +41 -0
  66. package/dist/lifecycle/task-stop.d.ts +82 -0
  67. package/dist/lifecycle/update-admission.d.ts +44 -0
  68. package/dist/local-server/base-url.d.ts +18 -0
  69. package/dist/local-server/index.d.ts +8 -0
  70. package/dist/local-server/opencode.d.ts +8 -0
  71. package/dist/local-server/probe.d.ts +3 -0
  72. package/dist/local-server/runtime.d.ts +26 -0
  73. package/dist/local-server/types.d.ts +43 -0
  74. package/dist/mcp-app/apps-context.d.ts +5 -0
  75. package/dist/mcp-app/catalog.d.ts +7 -0
  76. package/dist/mcp-app/discovery.d.ts +105 -0
  77. package/dist/mcp-app/errors.d.ts +7 -0
  78. package/dist/mcp-app/index.d.ts +18 -0
  79. package/dist/mcp-app/installed-app-ref.d.ts +25 -0
  80. package/dist/mcp-app/node-app-discovery-fs.d.ts +20 -0
  81. package/dist/mcp-app/projection.d.ts +13 -0
  82. package/dist/mcp-app/registry.d.ts +19 -0
  83. package/dist/mcp-app/state-set.d.ts +9 -0
  84. package/dist/mcp-app/types.d.ts +362 -0
  85. package/dist/mcp-app/workspace-snapshot.d.ts +53 -0
  86. package/dist/migrations/0008_careful_black_bird.sql +17 -0
  87. package/dist/migrations/0009_hot_dark_phoenix.sql +1 -0
  88. package/dist/migrations/0010_analyze_stats.sql +6 -0
  89. package/dist/migrations/0011_far_black_tarantula.sql +1 -0
  90. package/dist/migrations/0012_blue_turbo.sql +23 -0
  91. package/dist/migrations/0013_hesitant_adam_destine.sql +15 -0
  92. package/dist/migrations/0014_organic_mongu.sql +73 -0
  93. package/dist/migrations/0015_panoramic_gorilla_man.sql +71 -0
  94. package/dist/migrations/0016_fuzzy_hemingway.sql +14 -0
  95. package/dist/migrations/0017_project_stage_sdk_migration.sql +29 -0
  96. package/dist/migrations/0018_bored_jackal.sql +33 -0
  97. package/dist/migrations/0019_backfill_task_thread_ids.sql +74 -0
  98. package/dist/migrations/0020_useful_iron_lad.sql +55 -0
  99. package/dist/migrations/0021_dashing_peter_quill.sql +51 -0
  100. package/dist/migrations/0022_wandering_bucky.sql +1 -0
  101. package/dist/migrations/0023_red_payback.sql +1 -0
  102. package/dist/migrations/0024_storage_metadata.sql +262 -0
  103. package/dist/migrations/0025_task_heartbeat.sql +8 -0
  104. package/dist/migrations/0025_thread_app_instance_ledger.sql +2 -0
  105. package/dist/migrations/0026_mcp_action_source.sql +47 -0
  106. package/dist/migrations/0027_task_stop_scope_cleanup.sql +5 -0
  107. package/dist/migrations/0027_ui_instance_active_unique.sql +2 -0
  108. package/dist/migrations/0029_nice_rhino.sql +1 -0
  109. package/dist/migrations/0031_petite_arclight.sql +6 -0
  110. package/dist/migrations/meta/0008_snapshot.json +1327 -0
  111. package/dist/migrations/meta/0009_snapshot.json +1335 -0
  112. package/dist/migrations/meta/0010_snapshot.json +1335 -0
  113. package/dist/migrations/meta/0011_snapshot.json +1342 -0
  114. package/dist/migrations/meta/0012_snapshot.json +1494 -0
  115. package/dist/migrations/meta/0013_snapshot.json +1592 -0
  116. package/dist/migrations/meta/0014_snapshot.json +1975 -0
  117. package/dist/migrations/meta/0015_snapshot.json +2315 -0
  118. package/dist/migrations/meta/0016_snapshot.json +2419 -0
  119. package/dist/migrations/meta/0017_snapshot.json +2419 -0
  120. package/dist/migrations/meta/0018_snapshot.json +2570 -0
  121. package/dist/migrations/meta/0020_snapshot.json +2895 -0
  122. package/dist/migrations/meta/0021_snapshot.json +3031 -0
  123. package/dist/migrations/meta/0022_snapshot.json +3039 -0
  124. package/dist/migrations/meta/0023_snapshot.json +3047 -0
  125. package/dist/migrations/meta/0029_snapshot.json +3206 -0
  126. package/dist/migrations/meta/0031_snapshot.json +3251 -0
  127. package/dist/migrations/meta/_journal.json +168 -0
  128. package/dist/paths.d.ts +1 -0
  129. package/dist/plugin/types.d.ts +1 -0
  130. package/dist/plugins/index.d.ts +1 -1
  131. package/dist/plugins/index.js +302 -180
  132. package/dist/plugins/sqlite-tracing.d.ts +46 -0
  133. package/dist/process/index.d.ts +2 -0
  134. package/dist/process/index.js +1 -0
  135. package/dist/process/process-control.d.ts +41 -0
  136. package/dist/prompt/tag-names.d.ts +20 -0
  137. package/dist/provider/acp/connection.d.ts +6 -0
  138. package/dist/provider/acp/meta.d.ts +11 -0
  139. package/dist/provider/bridge.d.ts +7 -1
  140. package/dist/provider/classify-task-error.d.ts +2 -0
  141. package/dist/provider/cli/adapter.types.d.ts +9 -1
  142. package/dist/provider/cli/adapters/agent-call.util.d.ts +1 -1
  143. package/dist/provider/cli/adapters/cli-knob.util.d.ts +7 -0
  144. package/dist/provider/cli/adapters/event-timestamp.util.d.ts +1 -0
  145. package/dist/provider/cli/adapters/grok.d.ts +2 -0
  146. package/dist/provider/cli/adapters/index.d.ts +1 -0
  147. package/dist/provider/cli/index.d.ts +1 -1
  148. package/dist/provider/cli/meta.d.ts +5 -0
  149. package/dist/provider/cli/protocol-envelope.d.ts +2 -0
  150. package/dist/provider/errors.d.ts +5 -1
  151. package/dist/provider/idle-watchdog.d.ts +19 -0
  152. package/dist/provider/models.d.ts +17 -12
  153. package/dist/provider/order.d.ts +1 -1
  154. package/dist/provider/parse-usage.d.ts +6 -0
  155. package/dist/provider/provider-selection.d.ts +8 -0
  156. package/dist/provider/redact-technical-message.d.ts +1 -0
  157. package/dist/provider/task-error.types.d.ts +17 -0
  158. package/dist/publish/constants.d.ts +6 -0
  159. package/dist/publish/errors.d.ts +7 -0
  160. package/dist/publish/index.d.ts +50 -0
  161. package/dist/publish/index.js +2 -0
  162. package/dist/publish/manifest.d.ts +47 -0
  163. package/dist/publish/marketplace-api.constants.d.ts +1 -0
  164. package/dist/publish/pack.d.ts +6 -0
  165. package/dist/publish/scan.d.ts +9 -0
  166. package/dist/publish/secrets.d.ts +6 -0
  167. package/dist/publish/upload.d.ts +19 -0
  168. package/dist/remote/execution-profile.d.ts +9 -0
  169. package/dist/remote/index.d.ts +1 -0
  170. package/dist/remote/types.d.ts +28 -0
  171. package/dist/repository/agent-suggestion.repository.d.ts +34 -0
  172. package/dist/repository/base-sqlite-repository.d.ts +1 -0
  173. package/dist/repository/common-code.repository.d.ts +45 -0
  174. package/dist/repository/db.d.ts +12 -1
  175. package/dist/repository/index.d.ts +38 -5
  176. package/dist/repository/index.js +370 -170
  177. package/dist/repository/notification.repository.d.ts +58 -0
  178. package/dist/repository/project.repository.d.ts +90 -0
  179. package/dist/repository/request-log.repository.d.ts +1 -0
  180. package/dist/repository/storage-metadata.repository.d.ts +64 -0
  181. package/dist/repository/task-log-migration.d.ts +74 -0
  182. package/dist/repository/task-log.repository.d.ts +44 -0
  183. package/dist/repository/task-status.d.ts +14 -0
  184. package/dist/repository/task.repository.d.ts +246 -7
  185. package/dist/repository/thread-history.repository.d.ts +193 -0
  186. package/dist/repository/thread-title.types.d.ts +29 -0
  187. package/dist/repository/thread.repository.d.ts +47 -5
  188. package/dist/repository/usage-backfill.d.ts +62 -0
  189. package/dist/repository/usage-from-logs.d.ts +21 -0
  190. package/dist/repository/usage-report.repository.d.ts +27 -0
  191. package/dist/repository/workspace.repository.d.ts +3 -0
  192. package/dist/schema/agent-suggestions.d.ts +199 -0
  193. package/dist/schema/common-codes.d.ts +216 -0
  194. package/dist/schema/index.d.ts +10 -0
  195. package/dist/schema/notifications.d.ts +303 -0
  196. package/dist/schema/projects.d.ts +610 -0
  197. package/dist/schema/storage-metadata.d.ts +181 -0
  198. package/dist/schema/task-log-events.d.ts +119 -0
  199. package/dist/schema/tasks.d.ts +165 -0
  200. package/dist/schema/thread-history.d.ts +734 -0
  201. package/dist/schema/threads.d.ts +59 -0
  202. package/dist/schema/ui-action-receipts.d.ts +303 -0
  203. package/dist/schema/ui-instances.d.ts +286 -0
  204. package/dist/schema/usage-reports.d.ts +252 -0
  205. package/dist/schema/workspaces.d.ts +17 -0
  206. package/dist/skills/index.d.ts +7 -0
  207. package/dist/skills/index.js +1 -0
  208. package/dist/skills/types.d.ts +18 -0
  209. package/dist/task-log/anchor-child-tasks.d.ts +7 -0
  210. package/dist/task-log/delegation-trailer.d.ts +34 -0
  211. package/dist/template/engine.d.ts +2 -2
  212. package/dist/template/helpers/exec.browser.d.ts +4 -3
  213. package/dist/template/helpers/exec.d.ts +4 -3
  214. package/dist/template/types.d.ts +20 -0
  215. package/dist/testing/index.js +1 -1
  216. package/dist/types/index.d.ts +1569 -3
  217. package/dist/types/task-log.types.d.ts +2 -0
  218. package/dist/ui-card/index.d.ts +2 -0
  219. package/dist/ui-card/legacy-card-parser.d.ts +11 -0
  220. package/dist/ui-instance/definition.d.ts +6 -0
  221. package/dist/ui-instance/errors.d.ts +17 -0
  222. package/dist/ui-instance/index.d.ts +9 -0
  223. package/dist/ui-instance/json.d.ts +5 -0
  224. package/dist/ui-instance/runtime.d.ts +18 -0
  225. package/dist/ui-instance/store.d.ts +99 -0
  226. package/dist/ui-instance/types.d.ts +213 -0
  227. package/dist/ui-plugin/index.d.ts +4 -0
  228. package/dist/ui-plugin/limits.d.ts +27 -0
  229. package/dist/ui-plugin/manifest.d.ts +3 -0
  230. package/dist/ui-plugin/types.d.ts +174 -0
  231. package/dist/ui-plugin/validator.d.ts +15 -0
  232. package/dist/utils/crewx-executable.d.ts +54 -0
  233. package/dist/utils/crewx-home.d.ts +1 -0
  234. package/dist/utils/env-defaults.d.ts +2 -0
  235. package/dist/utils/id.d.ts +1 -1
  236. package/dist/utils/runner-env.d.ts +3 -0
  237. package/dist/utils/timestamp.d.ts +1 -0
  238. package/dist/utils/workspace.d.ts +1 -0
  239. package/dist/wi/create.d.ts +48 -0
  240. package/dist/wi/select.d.ts +20 -0
  241. package/package.json +40 -2
  242. package/templates/agents/default.yaml +269 -127
  243. package/templates/documents/crewx-manual.md +138 -138
  244. package/templates/documents/crewx-quick-guide.md +1 -1
  245. package/templates/workflows/wi-default-flow.yaml +65 -0
  246. package/templates/workflows/wi-plan-flow.yaml +140 -0
@@ -0,0 +1,9 @@
1
+ import type { UiStateActionHandlerRegistration } from '../ui-instance/types.js';
2
+ import type { UiPluginNormalizedManifestV2 } from '../ui-plugin/types.js';
3
+ export interface StateSetHandlerBuildInput {
4
+ readonly normalized: UiPluginNormalizedManifestV2;
5
+ readonly actionId: string;
6
+ }
7
+ export declare function buildStateSetHandler(normalized: UiPluginNormalizedManifestV2, actionId: string): UiStateActionHandlerRegistration | undefined;
8
+ export declare function buildStateSetHandler(input: StateSetHandlerBuildInput): UiStateActionHandlerRegistration | undefined;
9
+ export declare const createStateSetHandler: typeof buildStateSetHandler;
@@ -0,0 +1,362 @@
1
+ import type { JsonObject, UiDefinition, UiDefinitionRef, UiDefinitionDisplayMode, UiDefinitionUsage, UiInstance, UiInstanceStatus, UiActionConfirmation, UiActionHandlerRegistration } from '../ui-instance/types.js';
2
+ import type { AppDiscoveryFileSystem } from './discovery.js';
3
+ export declare const MCP_APP_RESOURCE_MIME_TYPE: "text/html;profile=mcp-app";
4
+ export declare const MCP_APP_RESOURCE_URI_PREFIX = "ui://crewx/";
5
+ export type McpAppToolVisibility = 'model' | 'app';
6
+ export type McpAppTone = 'blue' | 'violet' | 'emerald' | 'amber' | 'rose' | 'sky' | 'slate' | 'indigo';
7
+ export declare const MCP_APP_HOST_TOOL_ALLOWLIST: readonly ["crewx_app_terminal_connect"];
8
+ export type McpAppHostToolName = typeof MCP_APP_HOST_TOOL_ALLOWLIST[number];
9
+ export interface McpUiResourceCsp {
10
+ readonly connectDomains?: readonly string[];
11
+ readonly resourceDomains?: readonly string[];
12
+ readonly frameDomains?: readonly string[];
13
+ readonly baseUriDomains?: readonly string[];
14
+ }
15
+ export type McpAppInputSchema = JsonObject;
16
+ export interface McpAppToolCommonInput {
17
+ readonly name: string;
18
+ readonly description: string;
19
+ readonly inputSchema: McpAppInputSchema;
20
+ readonly textFallback: string;
21
+ readonly visibility: readonly McpAppToolVisibility[];
22
+ }
23
+ export interface McpAppReadToolInput extends McpAppToolCommonInput {
24
+ readonly kind: 'read';
25
+ readonly actionId?: never;
26
+ }
27
+ export interface McpAppSingleActionToolInput extends McpAppToolCommonInput {
28
+ readonly kind: 'action';
29
+ readonly actionId: string;
30
+ readonly actionIds?: never;
31
+ }
32
+ export interface McpAppActionDispatcherToolInput extends McpAppToolCommonInput {
33
+ readonly kind: 'action';
34
+ readonly actionId?: never;
35
+ readonly actionIds: readonly string[];
36
+ }
37
+ export type McpAppActionToolInput = McpAppSingleActionToolInput | McpAppActionDispatcherToolInput;
38
+ export type McpAppActionToolDescriptor = (Omit<McpAppSingleActionToolInput, 'actionIds'> & {
39
+ readonly actionIds: readonly string[];
40
+ }) | (Omit<McpAppActionDispatcherToolInput, 'actionId'> & {
41
+ readonly actionIds: readonly string[];
42
+ });
43
+ type McpAppToolDescriptorMetadata = {
44
+ readonly resourceUri: string;
45
+ readonly _meta: McpAppToolMetadata;
46
+ };
47
+ export interface McpAppHostToolInput extends Omit<McpAppToolCommonInput, 'name' | 'visibility'> {
48
+ readonly name: McpAppHostToolName;
49
+ readonly kind: 'host';
50
+ readonly visibility: readonly ['app'];
51
+ readonly actionId?: never;
52
+ }
53
+ export type McpAppToolInput = McpAppReadToolInput | McpAppActionToolInput | McpAppHostToolInput;
54
+ export interface McpAppDescriptorInput {
55
+ readonly appId: string;
56
+ readonly html: string;
57
+ readonly name?: string;
58
+ readonly description?: string;
59
+ readonly icon?: string;
60
+ readonly tone?: McpAppTone;
61
+ readonly builtinOnly?: boolean;
62
+ readonly csp?: McpUiResourceCsp;
63
+ readonly tools: readonly McpAppToolInput[];
64
+ readonly definition?: UiDefinition;
65
+ }
66
+ export interface McpAppResource {
67
+ readonly uri: string;
68
+ readonly mimeType: typeof MCP_APP_RESOURCE_MIME_TYPE;
69
+ readonly text: string;
70
+ readonly _meta?: {
71
+ readonly ui?: {
72
+ readonly csp?: McpUiResourceCsp;
73
+ };
74
+ };
75
+ }
76
+ export declare const MCP_APP_LOCAL_RESOURCE_MIME_TYPE: "text/html";
77
+ export interface McpAppInstanceResourceBinding {
78
+ readonly kind: 'instance';
79
+ }
80
+ export interface McpAppMcpResourceBinding {
81
+ readonly kind: 'mcp';
82
+ readonly uri: string;
83
+ }
84
+ export type McpAppResourceBinding = McpAppInstanceResourceBinding | McpAppMcpResourceBinding;
85
+ export interface McpAppLocalResource {
86
+ readonly mimeType: typeof MCP_APP_LOCAL_RESOURCE_MIME_TYPE;
87
+ readonly entryHash: string;
88
+ readonly html: string;
89
+ readonly bytes: readonly number[];
90
+ readonly initialState?: {
91
+ readonly hash: string;
92
+ readonly bytes: readonly number[];
93
+ };
94
+ }
95
+ export interface McpAppLocalRegistrationInput {
96
+ readonly appId: string;
97
+ readonly name: string;
98
+ readonly description: string;
99
+ readonly icon?: string;
100
+ readonly tone?: McpAppTone;
101
+ readonly csp?: McpUiResourceCsp;
102
+ readonly definition: UiDefinition;
103
+ readonly html: string;
104
+ readonly entryHash: string;
105
+ readonly entryBytes?: readonly number[];
106
+ readonly initialState?: JsonObject;
107
+ readonly initialStateHash?: string;
108
+ readonly initialStateBytes?: readonly number[];
109
+ readonly readToolName: string;
110
+ readonly actionToolName?: string;
111
+ readonly actions: readonly {
112
+ readonly actionId: string;
113
+ readonly inputSchema: McpAppInputSchema;
114
+ }[];
115
+ }
116
+ export interface McpAppLocalReadToolDescriptor extends McpAppToolCommonInput {
117
+ readonly kind: 'read';
118
+ readonly resourceBinding: McpAppInstanceResourceBinding;
119
+ readonly actionIds?: never;
120
+ }
121
+ export interface McpAppLocalActionToolDescriptor extends McpAppToolCommonInput {
122
+ readonly kind: 'action';
123
+ readonly resourceBinding: McpAppInstanceResourceBinding;
124
+ readonly actionIds: readonly string[];
125
+ }
126
+ export type McpAppLocalToolDescriptor = McpAppLocalReadToolDescriptor | McpAppLocalActionToolDescriptor;
127
+ export interface McpAppLocalRegistration {
128
+ readonly appId: string;
129
+ readonly name: string;
130
+ readonly description: string;
131
+ readonly icon?: string;
132
+ readonly tone?: McpAppTone;
133
+ readonly builtinOnly: false;
134
+ readonly definition: UiDefinition;
135
+ readonly resourceBinding: McpAppInstanceResourceBinding;
136
+ readonly resource: McpAppLocalResource;
137
+ readonly tools: readonly McpAppLocalToolDescriptor[];
138
+ }
139
+ export interface McpAppBuiltinRegistration {
140
+ readonly appId: string;
141
+ readonly name: string;
142
+ readonly description: string;
143
+ readonly icon?: string;
144
+ readonly tone?: McpAppTone;
145
+ readonly builtinOnly: boolean;
146
+ readonly uiUri: string;
147
+ readonly definition?: UiDefinition;
148
+ readonly resourceBinding: McpAppMcpResourceBinding;
149
+ readonly resource: McpAppResource;
150
+ readonly tools: readonly McpAppToolDescriptor[];
151
+ readonly descriptor: McpAppDescriptor;
152
+ }
153
+ export type McpAppResolvedRegistration = McpAppLocalRegistration | McpAppBuiltinRegistration;
154
+ export interface McpAppLocalLauncher {
155
+ readonly appId: string;
156
+ readonly name: string;
157
+ readonly description: string;
158
+ readonly icon?: string;
159
+ readonly tone?: McpAppTone;
160
+ readonly builtinOnly: false;
161
+ readonly definition: UiDefinitionRef;
162
+ readonly entryHash: string;
163
+ readonly resourceBinding: McpAppInstanceResourceBinding;
164
+ readonly tools: readonly McpAppLocalToolDescriptor[];
165
+ }
166
+ export interface McpAppBuiltinLauncher {
167
+ readonly appId: string;
168
+ readonly name: string;
169
+ readonly description: string;
170
+ readonly icon?: string;
171
+ readonly tone?: McpAppTone;
172
+ readonly builtinOnly: boolean;
173
+ readonly uiUri: string;
174
+ readonly definition?: UiDefinitionRef;
175
+ readonly resourceBinding: McpAppMcpResourceBinding;
176
+ readonly tools: readonly McpAppToolDescriptor[];
177
+ }
178
+ export type McpAppLauncher = McpAppLocalLauncher | McpAppBuiltinLauncher;
179
+ export type WorkspaceAppLauncher = McpAppLauncher;
180
+ export type WorkspaceAppResolvedRegistration = McpAppResolvedRegistration;
181
+ export interface McpAppWorkspaceRegistry {
182
+ getMcpApp(appId: string): McpAppDescriptor | null;
183
+ listMcpApps(): readonly McpAppDescriptor[];
184
+ listMcpAppTools(): readonly McpAppToolDescriptor[];
185
+ resolveMcpAppTool(toolName: string): McpAppToolDescriptor | null;
186
+ resolveMcpAppResource(uri: string): McpAppResource | null;
187
+ requireMcpAppResource(uri: string): McpAppResource;
188
+ listLocalMcpApps(): readonly McpAppLocalRegistration[];
189
+ getLocalMcpApp(appId: string): McpAppLocalRegistration | null;
190
+ listLocalMcpAppTools(): readonly McpAppLocalToolDescriptor[];
191
+ resolveLocalMcpAppTool(toolName: string): McpAppLocalToolDescriptor | null;
192
+ resolveLocalMcpAppResource(appId: string, definitionHash?: string): McpAppLocalResource | null;
193
+ listRegistrations(): readonly McpAppResolvedRegistration[];
194
+ getRegistration(appId: string): McpAppResolvedRegistration | null;
195
+ listLaunchers(): readonly McpAppLauncher[];
196
+ getLauncher(appId: string): McpAppLauncher | null;
197
+ resolveDefinition(ref: UiDefinitionRef): UiDefinition | null;
198
+ resolveActionHandler(definitionId: string, version: number, actionId: string): UiActionHandlerRegistration | null;
199
+ }
200
+ export type WorkspaceAppRegistry = McpAppWorkspaceRegistry;
201
+ export interface McpAppWorkspaceRegistryInput {
202
+ readonly builtins?: McpAppRegistry;
203
+ readonly builtin?: McpAppRegistry;
204
+ readonly localApps?: readonly McpAppLocalRegistration[];
205
+ readonly locals?: readonly McpAppLocalRegistration[];
206
+ readonly definitions?: readonly UiDefinition[];
207
+ readonly handlers?: readonly UiActionHandlerRegistration[];
208
+ }
209
+ export interface McpAppToolMetadata {
210
+ readonly ui: {
211
+ readonly resourceUri: string;
212
+ readonly visibility: readonly McpAppToolVisibility[];
213
+ };
214
+ }
215
+ export type McpAppToolDescriptor = (McpAppReadToolInput & McpAppToolDescriptorMetadata) | (McpAppActionToolDescriptor & McpAppToolDescriptorMetadata) | (McpAppHostToolInput & McpAppToolDescriptorMetadata);
216
+ export interface McpAppToolRegistration {
217
+ readonly name: string;
218
+ readonly description: string;
219
+ readonly inputSchema: McpAppInputSchema;
220
+ readonly _meta: McpAppToolMetadata;
221
+ }
222
+ export interface McpAppDescriptor {
223
+ readonly appId: string;
224
+ readonly name: string;
225
+ readonly description: string;
226
+ readonly icon?: string;
227
+ readonly tone?: McpAppTone;
228
+ readonly builtinOnly: boolean;
229
+ readonly csp?: McpUiResourceCsp;
230
+ readonly uiUri: string;
231
+ readonly html: string;
232
+ readonly definition?: UiDefinition;
233
+ readonly tools: readonly McpAppToolDescriptor[];
234
+ }
235
+ export interface McpAppToolResult {
236
+ readonly content: readonly [{
237
+ readonly type: 'text';
238
+ readonly text: string;
239
+ }];
240
+ readonly structuredContent?: JsonObject;
241
+ readonly _meta?: JsonObject;
242
+ }
243
+ export interface McpAppButtonInput {
244
+ readonly id: string;
245
+ readonly label: string;
246
+ readonly enabled: boolean;
247
+ readonly confirmation?: UiActionConfirmation;
248
+ readonly requiresHumanConfirmation?: boolean;
249
+ readonly disabledReason?: string;
250
+ readonly inputSchema: McpAppInputSchema;
251
+ }
252
+ export interface McpAppServerStateInput {
253
+ readonly source: 'server';
254
+ readonly instance: Pick<UiInstance, 'id' | 'definition' | 'revision' | 'status' | 'state'>;
255
+ readonly definition: UiDefinition;
256
+ readonly buttons: readonly McpAppButtonInput[];
257
+ }
258
+ export interface McpAppButtonDescriptor {
259
+ readonly id: string;
260
+ readonly label: string;
261
+ readonly enabled: boolean;
262
+ readonly confirmation: UiActionConfirmation;
263
+ readonly requiresHumanConfirmation?: boolean;
264
+ readonly disabledReason: string | null;
265
+ readonly inputSchema: McpAppInputSchema;
266
+ }
267
+ export interface McpAppStateDescriptor {
268
+ readonly schemaVersion: 1;
269
+ readonly source: 'server';
270
+ readonly instanceId: string;
271
+ readonly definition: UiDefinitionRef;
272
+ readonly revision: number;
273
+ readonly status: UiInstanceStatus;
274
+ readonly state: JsonObject;
275
+ readonly buttons: readonly McpAppButtonDescriptor[];
276
+ }
277
+ export interface McpAppStateProjections {
278
+ readonly descriptor: McpAppStateDescriptor;
279
+ readonly card: McpAppStateDescriptor;
280
+ readonly developer: {
281
+ readonly descriptor: McpAppStateDescriptor;
282
+ readonly json: string;
283
+ };
284
+ readonly ai: {
285
+ readonly descriptor: McpAppStateDescriptor;
286
+ readonly json: string;
287
+ readonly xml: string;
288
+ };
289
+ }
290
+ export interface McpAppRegistry {
291
+ registerMcpApp(input: McpAppDescriptorInput): McpAppDescriptor;
292
+ getMcpApp(appId: string): McpAppDescriptor | null;
293
+ listMcpApps(): readonly McpAppDescriptor[];
294
+ listMcpAppTools(): readonly McpAppToolDescriptor[];
295
+ resolveMcpAppTool(toolName: string): McpAppToolDescriptor | null;
296
+ resolveMcpAppResource(uri: string): McpAppResource | null;
297
+ requireMcpAppResource(uri: string): McpAppResource;
298
+ }
299
+ export type CrewxAppCapability = 'screen' | 'skill';
300
+ export type CrewxAppOrigin = 'local' | 'installed' | 'builtin';
301
+ export type CrewxAppOwnership = 'mine' | 'external' | 'unknown';
302
+ export type CrewxAppShareability = 'shareable' | 'requiresPublish' | 'forbidden' | 'unknown';
303
+ export type CrewxAppSharingAvailability = 'ready' | 'loginRequired' | 'unavailable';
304
+ export interface CrewxAppLocalDefinitionRef {
305
+ readonly packageRoot: string;
306
+ }
307
+ export interface CrewxAppDefinitionSummary extends UiDefinitionRef {
308
+ readonly usage: UiDefinitionUsage;
309
+ readonly detailPanel?: boolean;
310
+ readonly displayModes?: readonly UiDefinitionDisplayMode[];
311
+ }
312
+ export interface CrewxAppDefinitionHashInput {
313
+ readonly screenHash?: string;
314
+ readonly skillHash?: string;
315
+ readonly relativePath?: string;
316
+ readonly fileBytes?: Uint8Array | ArrayBuffer | readonly number[] | string;
317
+ }
318
+ export interface CrewxAppSummary {
319
+ readonly appId: string;
320
+ readonly name: string;
321
+ readonly description: string;
322
+ readonly version?: string;
323
+ readonly capabilities: readonly CrewxAppCapability[];
324
+ readonly definition?: CrewxAppDefinitionSummary;
325
+ readonly skillName?: string;
326
+ readonly localDefinitionRef?: CrewxAppLocalDefinitionRef;
327
+ readonly origin: CrewxAppOrigin;
328
+ readonly ownership: CrewxAppOwnership;
329
+ readonly shareability: CrewxAppShareability;
330
+ readonly sharingAvailability: CrewxAppSharingAvailability;
331
+ readonly marketplaceContentId?: string;
332
+ readonly slug?: string;
333
+ readonly definitionHash: string;
334
+ }
335
+ export type CrewxAppDiagnosticCode = 'MANIFEST_MISSING' | 'MANIFEST_INVALID' | 'ENTRY_INVALID' | 'INITIAL_STATE_INVALID' | 'DUPLICATE_ID' | 'RESERVED_ID' | 'PATH_ESCAPED' | 'LIMIT_EXCEEDED' | 'EXEC_DENIED' | 'SKILL_INVALID' | 'SKILL_READ_FAILED' | 'INSTALLED_MISSING' | 'INSTALLED_CONTENT_ID_MISSING' | 'INSTALLED_IDENTITY_MISMATCH' | 'BUILTIN_INVALID';
336
+ export type CrewxAppDiagnosticSource = 'apps' | 'skills' | 'node_modules' | 'builtin' | 'installed';
337
+ export interface CrewxAppDiagnostic {
338
+ readonly code: CrewxAppDiagnosticCode;
339
+ readonly source: CrewxAppDiagnosticSource;
340
+ readonly relativePath: string;
341
+ readonly appId?: string;
342
+ }
343
+ export interface CrewxAppInstalledProjection {
344
+ readonly packageRoot?: string;
345
+ readonly relativePath?: string;
346
+ readonly packageRootPath?: string;
347
+ readonly appId?: string;
348
+ readonly definitionHash?: string;
349
+ readonly marketplaceContentId?: string;
350
+ readonly slug?: string;
351
+ }
352
+ export type CrewxAppBuiltinCatalog = Pick<McpAppRegistry, 'listMcpApps' | 'listMcpAppTools'>;
353
+ export interface CrewxAppCatalogOptions {
354
+ readonly filesystem?: AppDiscoveryFileSystem;
355
+ readonly builtinCatalog?: CrewxAppBuiltinCatalog;
356
+ readonly installed?: readonly CrewxAppInstalledProjection[];
357
+ }
358
+ export interface CrewxAppCatalogResult {
359
+ readonly items: readonly CrewxAppSummary[];
360
+ readonly diagnostics: readonly CrewxAppDiagnostic[];
361
+ }
362
+ export {};
@@ -0,0 +1,53 @@
1
+ import { type AppDiscoveryFileSystem, type WorkspaceAppDiagnostic, type WorkspaceAppDiscoveryOptions, type WorkspaceAppDiscoveryResult } from './discovery.js';
2
+ import type { JsonObject, UiActionHandlerRegistration, UiDefinition, UiDefinitionRef } from '../ui-instance/types.js';
3
+ import type { McpAppLauncher, McpAppLocalResource, McpAppRegistry, McpAppWorkspaceRegistry } from './types.js';
4
+ export interface WorkspaceAppSnapshotResource extends McpAppLocalResource {
5
+ readonly appId: string;
6
+ readonly definition: UiDefinitionRef;
7
+ }
8
+ export interface WorkspaceAppSnapshotInitialState {
9
+ readonly appId: string;
10
+ readonly definition: UiDefinitionRef;
11
+ readonly hash: string;
12
+ readonly bytes: readonly number[];
13
+ readonly state: JsonObject;
14
+ }
15
+ export type WorkspaceAppInitialState = WorkspaceAppSnapshotInitialState;
16
+ export interface WorkspaceAppSnapshotBuildOptions {
17
+ readonly builtins?: McpAppRegistry;
18
+ readonly builtin?: McpAppRegistry;
19
+ readonly registry?: McpAppRegistry;
20
+ }
21
+ export type WorkspaceAppSnapshotOptions = WorkspaceAppDiscoveryOptions & WorkspaceAppSnapshotBuildOptions;
22
+ export interface WorkspaceAppSnapshot {
23
+ readonly snapshotHash: string;
24
+ readonly launchers: readonly McpAppLauncher[];
25
+ readonly definitions: readonly UiDefinition[];
26
+ readonly actionHandlers: readonly UiActionHandlerRegistration[];
27
+ readonly resources: readonly WorkspaceAppSnapshotResource[];
28
+ readonly initialStates: readonly WorkspaceAppSnapshotInitialState[];
29
+ readonly diagnostics: readonly WorkspaceAppDiagnostic[];
30
+ readonly registry: McpAppWorkspaceRegistry;
31
+ resolveDefinition(ref: UiDefinitionRef): UiDefinition | null;
32
+ resolveActionHandler(definitionId: string, version: number, actionId: string): UiActionHandlerRegistration | null;
33
+ resolveResource(appId: string, definitionHash?: string): WorkspaceAppSnapshotResource | null;
34
+ }
35
+ export type WorkspaceAppSnapshotReconfirmResult = {
36
+ readonly kind: 'same_generation';
37
+ readonly snapshot: WorkspaceAppSnapshot;
38
+ readonly diagnostics: readonly WorkspaceAppDiagnostic[];
39
+ } | {
40
+ readonly kind: 'new_generation';
41
+ readonly previousSnapshot: WorkspaceAppSnapshot;
42
+ readonly snapshot: WorkspaceAppSnapshot;
43
+ readonly diagnostics: readonly WorkspaceAppDiagnostic[];
44
+ } | {
45
+ readonly kind: 'io_error';
46
+ readonly snapshot: WorkspaceAppSnapshot;
47
+ readonly diagnostics: readonly WorkspaceAppDiagnostic[];
48
+ };
49
+ export declare function buildWorkspaceAppSnapshot(discovery: WorkspaceAppDiscoveryResult, options?: WorkspaceAppSnapshotBuildOptions): WorkspaceAppSnapshot;
50
+ export declare function discoverWorkspaceAppSnapshot(workspaceRoot: string, options?: WorkspaceAppSnapshotOptions): Promise<WorkspaceAppSnapshot>;
51
+ export declare function discoverWorkspaceAppSnapshot(workspaceRoot: string, filesystem: AppDiscoveryFileSystem, options?: WorkspaceAppSnapshotOptions): Promise<WorkspaceAppSnapshot>;
52
+ export declare function reconfirmWorkspaceAppSnapshot(workspaceRoot: string, currentSnapshot: WorkspaceAppSnapshot, options?: WorkspaceAppSnapshotOptions): Promise<WorkspaceAppSnapshotReconfirmResult>;
53
+ export declare function reconfirmWorkspaceAppSnapshot(workspaceRoot: string, currentSnapshot: WorkspaceAppSnapshot, filesystem: AppDiscoveryFileSystem, options?: WorkspaceAppSnapshotOptions): Promise<WorkspaceAppSnapshotReconfirmResult>;
@@ -0,0 +1,17 @@
1
+ CREATE TABLE IF NOT EXISTS `usage_reports` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `workspace_id` text NOT NULL,
4
+ `month` text NOT NULL,
5
+ `generated_at` text NOT NULL,
6
+ `source_range` text NOT NULL,
7
+ `tier` text NOT NULL,
8
+ `total_tokens` integer NOT NULL,
9
+ `total_cost_usd` real NOT NULL,
10
+ `payload` text NOT NULL,
11
+ `payload_hash` text,
12
+ `signature` text,
13
+ `signed_at` text,
14
+ `issuer` text
15
+ );
16
+ --> statement-breakpoint
17
+ CREATE UNIQUE INDEX IF NOT EXISTS `uniq_usage_reports_ws_month` ON `usage_reports` (`workspace_id`,`month`);
@@ -0,0 +1 @@
1
+ CREATE INDEX IF NOT EXISTS `idx_threads_ws_updated` ON `threads` (`workspace_id`,`updated_at`);
@@ -0,0 +1,6 @@
1
+ -- Custom SQL migration file, put your code below! --
2
+ -- WI-20260706-006: seed sqlite_stat1 so the query planner has index
3
+ -- selectivity data from the very first run on a fresh DB (idempotent).
4
+ PRAGMA analysis_limit = 400;
5
+ --> statement-breakpoint
6
+ ANALYZE;
@@ -0,0 +1 @@
1
+ CREATE INDEX IF NOT EXISTS `idx_threads_title` ON `threads` (`title`);
@@ -0,0 +1,23 @@
1
+ CREATE TABLE IF NOT EXISTS `notification_reads` (
2
+ `notification_id` text NOT NULL,
3
+ `user_id` text NOT NULL,
4
+ `read_at` text NOT NULL,
5
+ PRIMARY KEY(`notification_id`, `user_id`)
6
+ );
7
+ --> statement-breakpoint
8
+ CREATE TABLE IF NOT EXISTS `notifications` (
9
+ `id` text PRIMARY KEY NOT NULL,
10
+ `workspace_id` text NOT NULL,
11
+ `agent_id` text,
12
+ `task_id` text,
13
+ `thread_id` text,
14
+ `source` text DEFAULT 'agent' NOT NULL,
15
+ `level` text DEFAULT 'info' NOT NULL,
16
+ `title` text NOT NULL,
17
+ `body` text,
18
+ `target_user_id` text,
19
+ `created_at` text NOT NULL,
20
+ `metadata` text
21
+ );
22
+ --> statement-breakpoint
23
+ CREATE INDEX IF NOT EXISTS `idx_notifications_ws_created` ON `notifications` (`workspace_id`,"created_at" DESC);
@@ -0,0 +1,15 @@
1
+ CREATE TABLE IF NOT EXISTS `agent_suggestions` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `workspace_id` text NOT NULL,
4
+ `agent_id` text NOT NULL,
5
+ `task_id` text,
6
+ `type` text NOT NULL,
7
+ `status` text DEFAULT 'pending' NOT NULL,
8
+ `payload` text NOT NULL,
9
+ `applied_commit_sha` text,
10
+ `created_at` text NOT NULL,
11
+ `updated_at` text NOT NULL
12
+ );
13
+ --> statement-breakpoint
14
+ CREATE INDEX IF NOT EXISTS `idx_agent_suggestions_ws_agent` ON `agent_suggestions` (`workspace_id`,`agent_id`);--> statement-breakpoint
15
+ CREATE INDEX IF NOT EXISTS `idx_agent_suggestions_ws_created` ON `agent_suggestions` (`workspace_id`,`created_at`);
@@ -0,0 +1,73 @@
1
+ CREATE TABLE IF NOT EXISTS `ui_instances` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `definition_id` text NOT NULL,
4
+ `definition_version` integer NOT NULL,
5
+ `definition_hash` text NOT NULL,
6
+ `workspace_id` text NOT NULL,
7
+ `thread_id` text NOT NULL,
8
+ `anchor_task_id` text,
9
+ `domain_ref_json` text NOT NULL,
10
+ `state_json` text NOT NULL,
11
+ `revision` integer DEFAULT 0 NOT NULL,
12
+ `status` text DEFAULT 'active' NOT NULL,
13
+ `granted_capabilities_json` text DEFAULT '[]' NOT NULL,
14
+ `created_at` integer NOT NULL,
15
+ `updated_at` integer NOT NULL,
16
+ CONSTRAINT "ui_instances_id_ck" CHECK(length("ui_instances"."id") BETWEEN 5 AND 128 AND "ui_instances"."id" GLOB 'uic_*'),
17
+ CONSTRAINT "ui_instances_definition_id_ck" CHECK(length("ui_instances"."definition_id") BETWEEN 1 AND 128),
18
+ CONSTRAINT "ui_instances_definition_version_ck" CHECK("ui_instances"."definition_version" >= 1),
19
+ CONSTRAINT "ui_instances_definition_hash_ck" CHECK(length("ui_instances"."definition_hash") = 64 AND "ui_instances"."definition_hash" NOT GLOB '*[^0-9a-f]*'),
20
+ CONSTRAINT "ui_instances_workspace_id_ck" CHECK(length("ui_instances"."workspace_id") BETWEEN 1 AND 256),
21
+ CONSTRAINT "ui_instances_thread_id_ck" CHECK(length("ui_instances"."thread_id") BETWEEN 1 AND 256),
22
+ CONSTRAINT "ui_instances_domain_ref_json_ck" CHECK(json_valid("ui_instances"."domain_ref_json") AND json_type("ui_instances"."domain_ref_json") = 'object'),
23
+ CONSTRAINT "ui_instances_state_json_ck" CHECK(json_valid("ui_instances"."state_json") AND json_type("ui_instances"."state_json") = 'object'),
24
+ CONSTRAINT "ui_instances_revision_ck" CHECK("ui_instances"."revision" >= 0),
25
+ CONSTRAINT "ui_instances_status_ck" CHECK("ui_instances"."status" IN ('active', 'completed', 'expired', 'revoked', 'unsupported')),
26
+ CONSTRAINT "ui_instances_granted_capabilities_json_ck" CHECK(json_valid("ui_instances"."granted_capabilities_json") AND json_type("ui_instances"."granted_capabilities_json") = 'array'),
27
+ CONSTRAINT "ui_instances_created_at_ck" CHECK("ui_instances"."created_at" >= 0),
28
+ CONSTRAINT "ui_instances_updated_at_ck" CHECK("ui_instances"."updated_at" >= "ui_instances"."created_at")
29
+ );
30
+ --> statement-breakpoint
31
+ CREATE INDEX IF NOT EXISTS `ui_instances_workspace_thread_idx` ON `ui_instances` (`workspace_id`,`thread_id`);--> statement-breakpoint
32
+ CREATE TABLE IF NOT EXISTS `ui_action_receipts` (
33
+ `id` text PRIMARY KEY NOT NULL,
34
+ `instance_id` text NOT NULL,
35
+ `request_id` text NOT NULL,
36
+ `action_id` text NOT NULL,
37
+ `actor_json` text NOT NULL,
38
+ `source` text NOT NULL,
39
+ `expected_revision` integer NOT NULL,
40
+ `before_revision` integer NOT NULL,
41
+ `after_revision` integer,
42
+ `status` text NOT NULL,
43
+ `outcome` text,
44
+ `input_json` text NOT NULL,
45
+ `result_json` text,
46
+ `error_code` text,
47
+ `requested_at` integer NOT NULL,
48
+ `settled_at` integer,
49
+ CONSTRAINT "ui_action_receipts_id_ck" CHECK(length("ui_action_receipts"."id") BETWEEN 5 AND 128),
50
+ CONSTRAINT "ui_action_receipts_instance_id_ck" CHECK(length("ui_action_receipts"."instance_id") BETWEEN 1 AND 128),
51
+ CONSTRAINT "ui_action_receipts_request_id_ck" CHECK(length("ui_action_receipts"."request_id") BETWEEN 1 AND 128),
52
+ CONSTRAINT "ui_action_receipts_action_id_ck" CHECK(length("ui_action_receipts"."action_id") BETWEEN 1 AND 128),
53
+ CONSTRAINT "ui_action_receipts_actor_json_ck" CHECK(json_valid("ui_action_receipts"."actor_json") AND json_type("ui_action_receipts"."actor_json") = 'object'),
54
+ CONSTRAINT "ui_action_receipts_source_ck" CHECK("ui_action_receipts"."source" IN ('ui_host', 'cli', 'system')),
55
+ CONSTRAINT "ui_action_receipts_expected_revision_ck" CHECK("ui_action_receipts"."expected_revision" >= 0),
56
+ CONSTRAINT "ui_action_receipts_before_revision_ck" CHECK("ui_action_receipts"."before_revision" >= 0),
57
+ CONSTRAINT "ui_action_receipts_after_revision_ck" CHECK("ui_action_receipts"."after_revision" IS NULL OR "ui_action_receipts"."after_revision" >= 0),
58
+ CONSTRAINT "ui_action_receipts_status_ck" CHECK("ui_action_receipts"."status" IN ('requested', 'settled')),
59
+ CONSTRAINT "ui_action_receipts_outcome_ck" CHECK("ui_action_receipts"."outcome" IS NULL OR "ui_action_receipts"."outcome" IN ('succeeded', 'rejected', 'failed', 'conflicted', 'expired')),
60
+ CONSTRAINT "ui_action_receipts_input_json_ck" CHECK(json_valid("ui_action_receipts"."input_json") AND json_type("ui_action_receipts"."input_json") = 'object'),
61
+ CONSTRAINT "ui_action_receipts_result_json_ck" CHECK("ui_action_receipts"."result_json" IS NULL OR (json_valid("ui_action_receipts"."result_json") AND json_type("ui_action_receipts"."result_json") = 'object')),
62
+ CONSTRAINT "ui_action_receipts_requested_at_ck" CHECK("ui_action_receipts"."requested_at" >= 0),
63
+ CONSTRAINT "ui_action_receipts_settled_at_ck" CHECK("ui_action_receipts"."settled_at" IS NULL OR "ui_action_receipts"."settled_at" >= "ui_action_receipts"."requested_at"),
64
+ CONSTRAINT "ui_action_receipts_status_transition_ck" CHECK((
65
+ ("ui_action_receipts"."status" = 'requested' AND "ui_action_receipts"."after_revision" IS NULL AND "ui_action_receipts"."outcome" IS NULL AND "ui_action_receipts"."settled_at" IS NULL)
66
+ OR
67
+ ("ui_action_receipts"."status" = 'settled' AND "ui_action_receipts"."after_revision" IS NOT NULL AND "ui_action_receipts"."outcome" IS NOT NULL AND "ui_action_receipts"."settled_at" IS NOT NULL)
68
+ ))
69
+ );
70
+ --> statement-breakpoint
71
+ CREATE UNIQUE INDEX IF NOT EXISTS `ui_action_receipts_instance_request_uq` ON `ui_action_receipts` (`instance_id`,`request_id`);--> statement-breakpoint
72
+ CREATE INDEX IF NOT EXISTS `ui_action_receipts_instance_id_idx` ON `ui_action_receipts` (`instance_id`);--> statement-breakpoint
73
+ CREATE INDEX IF NOT EXISTS `ui_action_receipts_requested_at_idx` ON `ui_action_receipts` (`requested_at`);
@@ -0,0 +1,71 @@
1
+ CREATE TABLE IF NOT EXISTS `project_criteria` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `project_id` text NOT NULL,
4
+ `position` integer NOT NULL,
5
+ `statement` text NOT NULL,
6
+ `verify_status` text DEFAULT 'pending' NOT NULL,
7
+ `verified_at` text,
8
+ `evidence_json` text DEFAULT '[]' NOT NULL,
9
+ `created_at` text NOT NULL,
10
+ `updated_at` text NOT NULL,
11
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE cascade,
12
+ CONSTRAINT "project_criteria_id_ck" CHECK("project_criteria"."id" GLOB 'pjc_*'),
13
+ CONSTRAINT "project_criteria_verify_status_ck" CHECK("project_criteria"."verify_status" IN ('pending', 'verifying', 'passed', 'failed')),
14
+ CONSTRAINT "project_criteria_evidence_json_ck" CHECK(json_valid("project_criteria"."evidence_json") AND json_type("project_criteria"."evidence_json") = 'array')
15
+ );
16
+ --> statement-breakpoint
17
+ CREATE UNIQUE INDEX IF NOT EXISTS `project_criteria_project_position_uq` ON `project_criteria` (`project_id`,`position`);--> statement-breakpoint
18
+ CREATE TABLE IF NOT EXISTS `project_events` (
19
+ `id` text PRIMARY KEY NOT NULL,
20
+ `project_id` text NOT NULL,
21
+ `seq` integer NOT NULL,
22
+ `actor_type` text NOT NULL,
23
+ `actor_id` text,
24
+ `type` text NOT NULL,
25
+ `title` text NOT NULL,
26
+ `summary` text,
27
+ `payload_json` text DEFAULT '{}' NOT NULL,
28
+ `created_at` text NOT NULL,
29
+ FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE restrict,
30
+ CONSTRAINT "project_events_id_ck" CHECK("project_events"."id" GLOB 'pje_*'),
31
+ CONSTRAINT "project_events_actor_type_ck" CHECK("project_events"."actor_type" IN ('user', 'project_manager', 'system')),
32
+ CONSTRAINT "project_events_payload_json_ck" CHECK(json_valid("project_events"."payload_json") AND json_type("project_events"."payload_json") = 'object')
33
+ );
34
+ --> statement-breakpoint
35
+ CREATE UNIQUE INDEX IF NOT EXISTS `project_events_project_seq_uq` ON `project_events` (`project_id`,`seq`);--> statement-breakpoint
36
+ CREATE TABLE IF NOT EXISTS `projects` (
37
+ `id` text PRIMARY KEY NOT NULL,
38
+ `workspace_id` text NOT NULL,
39
+ `name` text NOT NULL,
40
+ `outcome` text NOT NULL,
41
+ `due_date` text,
42
+ `scene` text DEFAULT 'planning' NOT NULL,
43
+ `stages_json` text NOT NULL,
44
+ `stage_index` integer NOT NULL,
45
+ `created_at` text NOT NULL,
46
+ `updated_at` text NOT NULL,
47
+ `accepted_at` text,
48
+ `archived_at` text,
49
+ CONSTRAINT "projects_id_ck" CHECK("projects"."id" GLOB 'prj_*'),
50
+ CONSTRAINT "projects_scene_ck" CHECK("projects"."scene" IN ('planning', 'plan_review', 'running', 'human_wait', 'limit_wait', 'failed_stop', 'analyzing_feedback', 'replanned', 'awaiting_review', 'accepted')),
51
+ CONSTRAINT "projects_stages_json_ck" CHECK(json_valid("projects"."stages_json") AND json_type("projects"."stages_json") = 'array'),
52
+ CONSTRAINT "projects_stage_index_ck" CHECK("projects"."stage_index" >= 1)
53
+ );
54
+ --> statement-breakpoint
55
+ CREATE TRIGGER IF NOT EXISTS project_events_no_update
56
+ BEFORE UPDATE ON project_events
57
+ BEGIN
58
+ SELECT RAISE(ABORT, 'project_events is append-only');
59
+ END;
60
+ --> statement-breakpoint
61
+ CREATE TRIGGER IF NOT EXISTS project_events_no_delete
62
+ BEFORE DELETE ON project_events
63
+ BEGIN
64
+ SELECT RAISE(ABORT, 'project_events is append-only');
65
+ END;
66
+ --> statement-breakpoint
67
+ UPDATE tasks
68
+ SET project_id = NULL
69
+ WHERE id = 'task_1773657200590_gu3z335oy'
70
+ AND project_id = '9c899c8b05f8d8d8d1df6d904c0a7fa8e5c95f1cb81602423c1e508f8b77d1dc'
71
+ AND workspace_id = '9c899c8b05f8d8d8d1df6d904c0a7fa8e5c95f1cb81602423c1e508f8b77d1dc';
@@ -0,0 +1,14 @@
1
+ CREATE TABLE IF NOT EXISTS `task_log_events` (
2
+ `id` integer PRIMARY KEY NOT NULL,
3
+ `task_id` text NOT NULL,
4
+ `seq` integer NOT NULL,
5
+ `timestamp` text NOT NULL,
6
+ `level` text NOT NULL,
7
+ `message` text NOT NULL,
8
+ FOREIGN KEY (`task_id`) REFERENCES `tasks`(`id`) ON UPDATE no action ON DELETE cascade
9
+ );
10
+ --> statement-breakpoint
11
+ CREATE UNIQUE INDEX IF NOT EXISTS `task_log_events_task_seq_uq` ON `task_log_events` (`task_id`,`seq`);--> statement-breakpoint
12
+ ALTER TABLE `tasks` ADD `log_storage` text DEFAULT 'blob' NOT NULL CONSTRAINT "tasks_log_storage_ck" CHECK("tasks"."log_storage" IN ('blob', 'events'));--> statement-breakpoint
13
+ ALTER TABLE `tasks` ADD `last_log_seq` integer DEFAULT 0 NOT NULL;--> statement-breakpoint
14
+ ALTER TABLE `tasks` ADD `log_revision` integer DEFAULT 0 NOT NULL;