@crewx/sdk 0.9.0-rc.103 → 0.9.0-rc.105

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 (36) hide show
  1. package/dist/activity-log/builder.d.ts +1 -0
  2. package/dist/esm/index.js +191 -181
  3. package/dist/esm/plugins/index.js +81 -78
  4. package/dist/esm/repository/index.js +69 -66
  5. package/dist/events/types.d.ts +1 -0
  6. package/dist/index.d.ts +8 -6
  7. package/dist/index.js +189 -179
  8. package/dist/lifecycle/task-stop.d.ts +4 -1
  9. package/dist/mcp-app/discovery.d.ts +105 -0
  10. package/dist/mcp-app/index.d.ts +9 -3
  11. package/dist/mcp-app/node-app-discovery-fs.d.ts +20 -0
  12. package/dist/mcp-app/registry.d.ts +9 -1
  13. package/dist/mcp-app/state-set.d.ts +9 -0
  14. package/dist/mcp-app/types.d.ts +134 -1
  15. package/dist/mcp-app/workspace-snapshot.d.ts +53 -0
  16. package/dist/migrations/0027_task_stop_scope_cleanup.sql +5 -0
  17. package/dist/migrations/0027_ui_instance_active_unique.sql +2 -0
  18. package/dist/migrations/0029_nice_rhino.sql +1 -0
  19. package/dist/migrations/meta/0029_snapshot.json +3206 -0
  20. package/dist/migrations/meta/_journal.json +21 -0
  21. package/dist/plugins/index.js +82 -79
  22. package/dist/plugins/sqlite-tracing.d.ts +2 -0
  23. package/dist/repository/index.d.ts +1 -1
  24. package/dist/repository/index.js +69 -66
  25. package/dist/repository/task.repository.d.ts +12 -1
  26. package/dist/schema/tasks.d.ts +19 -0
  27. package/dist/types/index.d.ts +1 -0
  28. package/dist/ui-instance/runtime.d.ts +7 -2
  29. package/dist/ui-instance/store.d.ts +1 -0
  30. package/dist/ui-instance/types.d.ts +1 -0
  31. package/dist/ui-plugin/index.d.ts +3 -2
  32. package/dist/ui-plugin/limits.d.ts +27 -0
  33. package/dist/ui-plugin/types.d.ts +97 -2
  34. package/dist/ui-plugin/validator.d.ts +9 -3
  35. package/dist/utils/workspace.d.ts +1 -0
  36. package/package.json +1 -1
@@ -22,6 +22,13 @@ export interface TaskStopRequestResult {
22
22
  runEpoch: number;
23
23
  alreadyRequestedAt?: string;
24
24
  }
25
+ export type TaskStopOrigin = 'http' | 'cli' | 'instruction' | 'workflow' | 'internal';
26
+ export interface TaskStopRequestContext {
27
+ origin?: TaskStopOrigin;
28
+ at?: string;
29
+ callerPid?: number;
30
+ callerTaskId?: string;
31
+ }
25
32
  export type TaskStopMethod = 'cooperative' | 'forced';
26
33
  export interface FinalizeTaskStopOptions {
27
34
  id: string;
@@ -177,6 +184,9 @@ export declare class TaskRepository extends BaseSqliteRepository {
177
184
  requestTaskStop(opts: {
178
185
  id: string;
179
186
  requestedAt: string;
187
+ origin?: TaskStopOrigin;
188
+ callerPid?: number;
189
+ callerTaskId?: string;
180
190
  }): TaskStopRequestResult;
181
191
  private requestTaskStopForInstruction;
182
192
  finalizeTaskStop(opts: FinalizeTaskStopOptions): boolean;
@@ -197,6 +207,7 @@ export declare class TaskRepository extends BaseSqliteRepository {
197
207
  command?: string | null;
198
208
  metadata?: string | null;
199
209
  workspaceId?: string | null;
210
+ cwd?: string | null;
200
211
  projectId?: string | null;
201
212
  platform?: string | null;
202
213
  crewxVersion?: string | null;
@@ -213,7 +224,7 @@ export declare class TaskRepository extends BaseSqliteRepository {
213
224
  }): boolean;
214
225
  adoptPendingTask(id: string): boolean;
215
226
  failPendingTask(id: string, error: string, completedAt?: string): boolean;
216
- stopPendingTask(id: string, error?: string, completedAt?: string): boolean;
227
+ stopPendingTask(id: string, error?: string, completedAt?: string, stopRequest?: TaskStopRequestContext): boolean;
217
228
  listTasksByProjectId(projectId: string): TaskRow[];
218
229
  finishTask(opts: {
219
230
  id: string;
@@ -668,6 +668,25 @@ export declare const tasks: import("drizzle-orm/sqlite-core").SQLiteTableWithCol
668
668
  }, {}, {
669
669
  length: number | undefined;
670
670
  }>;
671
+ cwd: import("drizzle-orm/sqlite-core").SQLiteColumn<{
672
+ name: "cwd";
673
+ tableName: "tasks";
674
+ dataType: "string";
675
+ columnType: "SQLiteText";
676
+ data: string;
677
+ driverParam: string;
678
+ notNull: false;
679
+ hasDefault: false;
680
+ isPrimaryKey: false;
681
+ isAutoincrement: false;
682
+ hasRuntimeDefault: false;
683
+ enumValues: [string, ...string[]];
684
+ baseColumn: never;
685
+ identity: undefined;
686
+ generated: undefined;
687
+ }, {}, {
688
+ length: number | undefined;
689
+ }>;
671
690
  project_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
672
691
  name: "project_id";
673
692
  tableName: "tasks";
@@ -2810,6 +2810,7 @@ export interface TraceContext {
2810
2810
  }
2811
2811
  export interface CrewxOptions {
2812
2812
  workspaceRoot?: string;
2813
+ inheritWorktreeOwner?: boolean;
2813
2814
  platform?: Platform;
2814
2815
  execPolicy?: import('../template/types').ExecPolicy;
2815
2816
  api?: {
@@ -1,4 +1,5 @@
1
1
  import type { UiRuntimeFacade, UiRuntimeOptions, UiServerRuntimeFacade, UiServerRuntimeOptions } from './types.js';
2
+ import { UiInstanceStore } from './store.js';
2
3
  export interface UiRuntimeTestHooks {
3
4
  beforeReservation?: () => Promise<void> | void;
4
5
  injectDatabaseError?: () => unknown | undefined;
@@ -7,7 +8,11 @@ export interface UiRuntimeTestHooks {
7
8
  export interface UiRuntimeForTestOptions extends UiRuntimeOptions {
8
9
  workspaceId: string;
9
10
  testHooks?: UiRuntimeTestHooks;
11
+ store?: UiInstanceStore;
10
12
  }
11
- export declare function createUiRuntime(workspaceId: string, options: UiRuntimeOptions): UiRuntimeFacade;
13
+ export interface UiRuntimeStoreOptions {
14
+ readonly store?: UiInstanceStore;
15
+ }
16
+ export declare function createUiRuntime(workspaceId: string, options: UiRuntimeOptions & UiRuntimeStoreOptions): UiRuntimeFacade;
12
17
  export declare function createUiRuntimeForTest(options: UiRuntimeForTestOptions): UiRuntimeFacade;
13
- export declare function createUiServerRuntime(options: UiServerRuntimeOptions): UiServerRuntimeFacade;
18
+ export declare function createUiServerRuntime(options: UiServerRuntimeOptions & UiRuntimeStoreOptions): UiServerRuntimeFacade;
@@ -2,6 +2,7 @@ import type { ActionReceipt, ActionReceiptOutcome, JsonObject, UiActionHandlerCo
2
2
  interface UiInstanceStoreTestHooks {
3
3
  injectDatabaseError?: () => unknown | undefined;
4
4
  bumpRevisionBeforeCas?: boolean;
5
+ beforeOpenRead?: () => void;
5
6
  }
6
7
  export interface ReservationInput {
7
8
  instanceId: string;
@@ -22,6 +22,7 @@ export interface UiProjectionPolicy {
22
22
  export interface UiDefinitionInput {
23
23
  readonly id: string;
24
24
  readonly version: number;
25
+ readonly sourceHash?: string;
25
26
  readonly actions: Readonly<Record<string, UiDefinitionAction>>;
26
27
  readonly renderer?: string;
27
28
  readonly surfaces?: readonly string[];
@@ -1,3 +1,4 @@
1
1
  export { canonicalManifestJson, manifestHash } from './manifest.js';
2
- export { UiPluginValidationError, normalizeManifest, validateManifest, validatePayload, } from './validator.js';
3
- export type { UiPluginActivation, UiPluginCardShellNode, UiPluginFieldSchema, UiPluginHeadingNode, UiPluginLabeledTextNode, UiPluginLayoutNode, UiPluginLayout, UiPluginManifest, UiPluginMetaBannerNode, UiPluginPayload, UiPluginPayloadValue, UiPluginPrimitive, UiPluginSchemaType, UiPluginSchema, UiPluginStep, UiPluginStepFlowNode, UiPluginStepListSchema, UiPluginTextListNode, UiPluginTextListSchema, UiPluginTextSchema, UiPluginValidationErrorCode, UiPluginValidationOptions, } from './types.js';
2
+ export { UiPluginValidationError, normalizeManifest, validateInitialState, validateManifest, validatePayload, } from './validator.js';
3
+ export { UI_PLUGIN_CAPABILITY_PATTERN, UI_PLUGIN_HANDLER_PATTERN, UI_PLUGIN_IDENTIFIER_PATTERN, UI_PLUGIN_MAX_ACTIONS, UI_PLUGIN_MAX_ARRAY_LENGTH, UI_PLUGIN_MAX_CANDIDATE_DEPTH, UI_PLUGIN_MAX_COMMAND_LENGTH, UI_PLUGIN_MAX_COMMAND_PARTS, UI_PLUGIN_MAX_DISCOVERED_APPS, UI_PLUGIN_MAX_DISCOVERY_TIME_MS, UI_PLUGIN_MAX_HEIGHT, UI_PLUGIN_MAX_INITIAL_STATE_BYTES, UI_PLUGIN_MAX_JSON_DEPTH, UI_PLUGIN_MAX_MANIFEST_BYTES, UI_PLUGIN_MAX_PROJECTION_PATHS, UI_PLUGIN_MAX_SCHEMA_DEPTH, UI_PLUGIN_MAX_SCHEMA_PROPERTIES, UI_PLUGIN_MAX_STRING_LENGTH, UI_PLUGIN_MAX_SUBTREE_BYTES, UI_PLUGIN_MAX_SURFACES, UI_PLUGIN_RESERVED_STATE_KEYS, UI_PLUGIN_SAFE_PATH_PATTERN, UI_PLUGIN_SAFE_PATH_SEGMENT_PATTERN, UI_PLUGIN_SKILL_TOKEN_PATTERN, UI_PLUGIN_SURFACES, UI_PLUGIN_TONES, isUiPluginReservedStateKey, } from './limits.js';
4
+ export type { UiPluginActivation, UiPluginAction, UiPluginBackend, UiPluginCardShellNode, UiPluginCoreBackend, UiPluginFieldSchema, UiPluginHeadingNode, UiPluginInputSchema, UiPluginJsonSchema, UiPluginJsonSchemaType, UiPluginLabeledTextNode, UiPluginLayoutNode, UiPluginLayout, UiPluginManifest, UiPluginManifestMode, UiPluginManifestV1, UiPluginManifestV2, UiPluginMetaBannerNode, UiPluginNormalizedManifestV2, UiPluginNormalizedV2, UiPluginPayload, UiPluginPayloadValue, UiPluginPrimitive, UiPluginProjectionPolicy, UiPluginResourceMetadata, UiPluginResourceRef, UiPluginSchemaType, UiPluginSchema, UiPluginSize, UiPluginSkillBackend, UiPluginStep, UiPluginStepFlowNode, UiPluginStepListSchema, UiPluginTextListNode, UiPluginTextListSchema, UiPluginTextSchema, UiPluginSurface, UiPluginTone, UiPluginHandlerMetadata, UiPluginValidationErrorCode, UiPluginValidationOptions, } from './types.js';
@@ -0,0 +1,27 @@
1
+ export declare const UI_PLUGIN_MAX_STRING_LENGTH = 4096;
2
+ export declare const UI_PLUGIN_MAX_ARRAY_LENGTH = 128;
3
+ export declare const UI_PLUGIN_MAX_SUBTREE_BYTES: number;
4
+ export declare const UI_PLUGIN_MAX_INITIAL_STATE_BYTES: number;
5
+ export declare const UI_PLUGIN_MAX_JSON_DEPTH = 8;
6
+ export declare const UI_PLUGIN_MAX_SCHEMA_DEPTH = 8;
7
+ export declare const UI_PLUGIN_MAX_SCHEMA_PROPERTIES = 64;
8
+ export declare const UI_PLUGIN_MAX_ACTIONS = 32;
9
+ export declare const UI_PLUGIN_MAX_SURFACES = 2;
10
+ export declare const UI_PLUGIN_MAX_PROJECTION_PATHS = 128;
11
+ export declare const UI_PLUGIN_MAX_COMMAND_PARTS = 16;
12
+ export declare const UI_PLUGIN_MAX_COMMAND_LENGTH = 256;
13
+ export declare const UI_PLUGIN_MAX_HEIGHT = 720;
14
+ export declare const UI_PLUGIN_MAX_DISCOVERED_APPS = 64;
15
+ export declare const UI_PLUGIN_MAX_MANIFEST_BYTES: number;
16
+ export declare const UI_PLUGIN_MAX_CANDIDATE_DEPTH = 2;
17
+ export declare const UI_PLUGIN_MAX_DISCOVERY_TIME_MS = 5000;
18
+ export declare const UI_PLUGIN_RESERVED_STATE_KEYS: readonly ["__proto__", "prototype", "constructor", "proof", "token", "secret", "password", "cookie", "authorization", "private_key", "private-key", "stack", "exception", "plugin_text", "url", "uri", "endpoint", "path", "filename", "filepath", "cwd", "shell", "directory", "dir", "folder"];
19
+ export declare function isUiPluginReservedStateKey(key: string): boolean;
20
+ export declare const UI_PLUGIN_SAFE_PATH_SEGMENT_PATTERN: RegExp;
21
+ export declare const UI_PLUGIN_SAFE_PATH_PATTERN: RegExp;
22
+ export declare const UI_PLUGIN_IDENTIFIER_PATTERN: RegExp;
23
+ export declare const UI_PLUGIN_CAPABILITY_PATTERN: RegExp;
24
+ export declare const UI_PLUGIN_HANDLER_PATTERN: RegExp;
25
+ export declare const UI_PLUGIN_SKILL_TOKEN_PATTERN: RegExp;
26
+ export declare const UI_PLUGIN_TONES: readonly ["blue", "violet", "emerald", "amber", "rose", "sky", "slate", "indigo"];
27
+ export declare const UI_PLUGIN_SURFACES: readonly ["inline", "panel"];
@@ -1,3 +1,4 @@
1
+ import type { JsonValue, UiDefinitionInput } from '../ui-instance/types.js';
1
2
  export type UiPluginPrimitive = 'card-shell' | 'meta-banner' | 'heading' | 'labeled-text' | 'step-flow' | 'text-list';
2
3
  export type UiPluginSchemaType = 'text' | 'text-list' | 'step-list';
3
4
  export interface UiPluginTextSchema {
@@ -54,7 +55,7 @@ export interface UiPluginTextListNode {
54
55
  }
55
56
  export type UiPluginLayoutNode = UiPluginCardShellNode | UiPluginMetaBannerNode | UiPluginHeadingNode | UiPluginLabeledTextNode | UiPluginStepFlowNode | UiPluginTextListNode;
56
57
  export type UiPluginLayout = readonly UiPluginLayoutNode[];
57
- export interface UiPluginManifest {
58
+ export interface UiPluginManifestV1 {
58
59
  readonly manifestVersion: 1;
59
60
  readonly pluginId: string;
60
61
  readonly definitionId: string;
@@ -64,6 +65,99 @@ export interface UiPluginManifest {
64
65
  readonly schema: UiPluginSchema;
65
66
  readonly layout: UiPluginLayout;
66
67
  }
68
+ export type UiPluginManifestMode = 'local' | 'installed' | 'published';
69
+ export type UiPluginSurface = 'inline' | 'panel';
70
+ export type UiPluginTone = 'blue' | 'violet' | 'emerald' | 'amber' | 'rose' | 'sky' | 'slate' | 'indigo';
71
+ export type UiPluginJsonSchemaType = 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'null';
72
+ export interface UiPluginJsonSchema {
73
+ readonly type: UiPluginJsonSchemaType;
74
+ readonly enum?: readonly JsonValue[];
75
+ readonly minLength?: number;
76
+ readonly maxLength?: number;
77
+ readonly minItems?: number;
78
+ readonly maxItems?: number;
79
+ readonly minProperties?: number;
80
+ readonly maxProperties?: number;
81
+ readonly minimum?: number;
82
+ readonly maximum?: number;
83
+ readonly items?: UiPluginJsonSchema;
84
+ readonly properties?: Readonly<Record<string, UiPluginJsonSchema>>;
85
+ readonly required?: readonly string[];
86
+ readonly additionalProperties?: false;
87
+ }
88
+ export interface UiPluginInputSchema extends UiPluginJsonSchema {
89
+ readonly type: 'object';
90
+ readonly properties: Readonly<Record<string, UiPluginJsonSchema>>;
91
+ }
92
+ export interface UiPluginProjectionPolicy {
93
+ readonly allow: readonly string[];
94
+ }
95
+ export interface UiPluginCoreBackend {
96
+ readonly type: 'core';
97
+ readonly handler: string;
98
+ }
99
+ export interface UiPluginSkillBackend {
100
+ readonly type: 'skill';
101
+ readonly command: readonly string[];
102
+ }
103
+ export type UiPluginBackend = UiPluginCoreBackend | UiPluginSkillBackend;
104
+ export interface UiPluginAction {
105
+ readonly actionId: string;
106
+ readonly capability: string;
107
+ readonly mutation: boolean;
108
+ readonly inputSchema: UiPluginInputSchema;
109
+ readonly resultProjection: UiPluginProjectionPolicy;
110
+ readonly backend: UiPluginBackend;
111
+ }
112
+ export interface UiPluginResourceRef {
113
+ readonly path: 'ui/index.html' | 'ui/state.json';
114
+ readonly hash?: string;
115
+ }
116
+ export interface UiPluginSize {
117
+ readonly height: number;
118
+ }
119
+ export interface UiPluginManifestV2 {
120
+ readonly manifestVersion: 2;
121
+ readonly pluginId: string;
122
+ readonly definitionId: string;
123
+ readonly version: number;
124
+ readonly name: string;
125
+ readonly description: string;
126
+ readonly icon?: string;
127
+ readonly tone?: UiPluginTone;
128
+ readonly entry: 'ui/index.html';
129
+ readonly entryHash?: string;
130
+ readonly initialState?: {
131
+ readonly path: 'ui/state.json';
132
+ readonly hash?: string;
133
+ };
134
+ readonly surfaces: readonly UiPluginSurface[];
135
+ readonly size: UiPluginSize;
136
+ readonly stateProjection: UiPluginProjectionPolicy;
137
+ readonly actions: readonly UiPluginAction[];
138
+ }
139
+ export type UiPluginManifest = UiPluginManifestV1 | UiPluginManifestV2;
140
+ export interface UiPluginHandlerMetadata {
141
+ readonly actionId: string;
142
+ readonly mutation: boolean;
143
+ readonly backend: UiPluginBackend;
144
+ readonly launchPolicy: 'allowed' | 'denied';
145
+ readonly denialCode?: 'EXEC_DENIED';
146
+ }
147
+ export interface UiPluginResourceMetadata {
148
+ readonly entry: UiPluginResourceRef;
149
+ readonly initialState?: {
150
+ readonly path: 'ui/state.json';
151
+ readonly hash?: string;
152
+ };
153
+ }
154
+ export interface UiPluginNormalizedManifestV2 {
155
+ readonly manifest: UiPluginManifestV2;
156
+ readonly definition: UiDefinitionInput;
157
+ readonly handlers: Readonly<Record<string, UiPluginHandlerMetadata>>;
158
+ readonly resources: UiPluginResourceMetadata;
159
+ }
160
+ export type UiPluginNormalizedV2 = UiPluginNormalizedManifestV2;
67
161
  export interface UiPluginStep {
68
162
  readonly label: string;
69
163
  readonly detail: string;
@@ -72,5 +166,6 @@ export type UiPluginPayloadValue = string | string[] | UiPluginStep[];
72
166
  export type UiPluginPayload = Record<string, UiPluginPayloadValue>;
73
167
  export interface UiPluginValidationOptions {
74
168
  readonly supportedPrimitiveSet?: number;
169
+ readonly mode?: UiPluginManifestMode;
75
170
  }
76
- export type UiPluginValidationErrorCode = 'MANIFEST_INVALID' | 'PRIMITIVE_UNKNOWN' | 'PRIMITIVE_SET_UNSUPPORTED' | 'SCHEMA_TYPE_UNSUPPORTED' | 'TOKEN_INVALID' | 'UNSAFE_VALUE';
171
+ export type UiPluginValidationErrorCode = 'MANIFEST_INVALID' | 'PRIMITIVE_UNKNOWN' | 'PRIMITIVE_SET_UNSUPPORTED' | 'SCHEMA_TYPE_UNSUPPORTED' | 'TOKEN_INVALID' | 'UNSAFE_VALUE' | 'LIMIT_EXCEEDED' | 'INITIAL_STATE_INVALID';
@@ -1,9 +1,15 @@
1
- import type { UiPluginManifest, UiPluginPayload, UiPluginValidationErrorCode, UiPluginValidationOptions } from './types.js';
1
+ import type { UiPluginManifest, UiPluginManifestV1, UiPluginManifestV2, UiPluginNormalizedManifestV2, UiPluginPayload, UiPluginValidationErrorCode, UiPluginValidationOptions } from './types.js';
2
+ import type { JsonObject } from '../ui-instance/types.js';
2
3
  export declare class UiPluginValidationError extends Error {
3
4
  readonly code: UiPluginValidationErrorCode;
4
5
  readonly name = "UiPluginValidationError";
5
6
  constructor(code: UiPluginValidationErrorCode, message?: string);
6
7
  }
8
+ export declare function validateInitialState(value: unknown): JsonObject;
9
+ export declare function validateManifest(input: UiPluginManifestV1, options?: UiPluginValidationOptions): UiPluginManifestV1;
10
+ export declare function validateManifest(input: UiPluginManifestV2, options?: UiPluginValidationOptions): UiPluginManifestV2;
7
11
  export declare function validateManifest(input: unknown, options?: UiPluginValidationOptions): UiPluginManifest;
8
- export declare function normalizeManifest(input: unknown, options?: UiPluginValidationOptions): UiPluginManifest;
9
- export declare function validatePayload(manifest: UiPluginManifest, rawPayload: unknown): UiPluginPayload;
12
+ export declare function normalizeManifest(input: UiPluginManifestV1, options?: UiPluginValidationOptions): UiPluginManifestV1;
13
+ export declare function normalizeManifest(input: UiPluginManifestV2, options?: UiPluginValidationOptions): UiPluginNormalizedManifestV2;
14
+ export declare function normalizeManifest(input: unknown, options?: UiPluginValidationOptions): UiPluginManifestV1 | UiPluginNormalizedManifestV2;
15
+ export declare function validatePayload(manifest: UiPluginManifestV1, rawPayload: unknown): UiPluginPayload;
@@ -1,4 +1,5 @@
1
1
  export declare function normalizeWorkspacePath(workspacePath: string): string;
2
2
  export declare function hashWorkspaceId(workspacePath: string): string;
3
+ export declare function resolveWorkspaceOwnerPath(workspacePath: string): string;
3
4
  export declare function slugify(input: string): string;
4
5
  export declare function isValidSlug(slug: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crewx/sdk",
3
- "version": "0.9.0-rc.103",
3
+ "version": "0.9.0-rc.105",
4
4
  "license": "UNLICENSED",
5
5
  "engines": {
6
6
  "node": ">=20.19.0"