@crewx/sdk 0.9.0-rc.120 → 0.9.0-rc.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,27 @@
1
+ export type ThreadOriginKind = 'human' | 'agent' | 'system';
2
+ export interface ThreadOriginRow {
3
+ origin: 'direct' | 'delegated';
4
+ delegatedByAgentId: string | null;
5
+ }
6
+ export interface RawThreadOriginRow {
7
+ task_id: string;
8
+ thread_id: string;
9
+ caller_agent_id: string | null;
10
+ parent_task_id: string | null;
11
+ schedule_id: unknown;
12
+ platform: string | null;
13
+ parent_thread_id: string | null;
14
+ parent_agent_id: string | null;
15
+ }
16
+ export interface RawThreadCreatorPointerRow {
17
+ thread_id: string;
18
+ created_by_kind: string | null;
19
+ created_by_id: string | null;
20
+ created_by_task_id: string | null;
21
+ creator_task_id: string | null;
22
+ creator_actor_kind: string | null;
23
+ creator_actor_id: string | null;
24
+ creator_pointer_unverified: number;
25
+ }
26
+ export declare function lineageThreadOrigin(row: RawThreadOriginRow): ThreadOriginRow;
27
+ export declare function resolveThreadOrigin(row: RawThreadCreatorPointerRow, pointerLineage?: RawThreadOriginRow, fallbackLineage?: RawThreadOriginRow): ThreadOriginRow | undefined;
@@ -1,7 +1,9 @@
1
1
  import { BaseSqliteRepository } from './base-sqlite-repository.js';
2
2
  import { RepositoryError } from './errors.js';
3
3
  import { threads } from '../schema/index.js';
4
+ import type { ThreadOriginRow } from './thread-origin-verdict.js';
4
5
  import type { TaskRow, TaskListRow } from './task.repository.js';
6
+ export type { ThreadOriginRow } from './thread-origin-verdict.js';
5
7
  export type ThreadRow = typeof threads.$inferSelect;
6
8
  export type NewThread = typeof threads.$inferInsert;
7
9
  export type ThreadActorKind = NonNullable<NewThread['created_by_kind']>;
@@ -12,10 +14,6 @@ export interface ThreadCreationOptions {
12
14
  }
13
15
  export type ThreadOriginFilter = 'direct' | 'delegated' | 'all';
14
16
  type ThreadOriginScope = Exclude<ThreadOriginFilter, 'all'>;
15
- export interface ThreadOriginRow {
16
- origin: 'direct' | 'delegated';
17
- delegatedByAgentId: string | null;
18
- }
19
17
  export interface ThreadTitleMetadataPatch {
20
18
  priority?: string | null;
21
19
  state?: string | null;
@@ -38,9 +36,12 @@ export declare class ThreadRepository extends BaseSqliteRepository {
38
36
  });
39
37
  resolveDbPath(): string;
40
38
  private openHandle;
41
- private validateWorkspaceId;
42
39
  private topLevelTaskPredicateSql;
43
40
  private findAllThreadsQuery;
41
+ private findThreadIdsQuery;
42
+ private readThreadIds;
43
+ private readThreadRowsByIds;
44
+ private readThreadRows;
44
45
  findAllThreads(workspaceId?: string, createdByKind?: ThreadActorKind): ThreadRow[];
45
46
  explainFindAllThreadsPlan(workspaceId?: string, createdByKind?: ThreadActorKind): string[];
46
47
  findThreadsByIdsOrTitles(ids: string[], workspaceId?: string): ThreadRow[];
@@ -63,9 +64,8 @@ export declare class ThreadRepository extends BaseSqliteRepository {
63
64
  private batchFetchTasksQuery;
64
65
  batchFetchTasks(threadIds: string[], workspaceId?: string): Map<string, TaskListRow[]>;
65
66
  private findThreadOriginsQuery;
66
- private findRecordedThreadOriginsQuery;
67
- private findThreadsByOriginQuery;
68
- private findLegacyThreadsQuery;
67
+ private findCreatorPointersQuery;
68
+ private findTaskOriginLineageQuery;
69
69
  findThreadOrigins(threadIds: string[], workspaceId?: string): Map<string, ThreadOriginRow>;
70
70
  findThreadsByOrigin(origin: ThreadOriginScope, workspaceId?: string): ThreadRow[];
71
71
  explainBatchFetchTasksPlan(threadIds: string[], workspaceId?: string): string[];
@@ -116,4 +116,3 @@ export declare class ThreadRepository extends BaseSqliteRepository {
116
116
  remaining: number;
117
117
  } | null;
118
118
  }
119
- export {};
@@ -2,6 +2,7 @@ export * from './workspaces.js';
2
2
  export * from './tasks.js';
3
3
  export * from './task-log-events.js';
4
4
  export * from './threads.js';
5
+ export * from './thread-creator-unverified.js';
5
6
  export * from './spans.js';
6
7
  export * from './tool-calls.js';
7
8
  export * from './thread-boxes.js';
@@ -0,0 +1,45 @@
1
+ export declare const thread_creator_unverified: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
2
+ name: "thread_creator_unverified";
3
+ schema: undefined;
4
+ columns: {
5
+ thread_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
6
+ name: "thread_id";
7
+ tableName: "thread_creator_unverified";
8
+ dataType: "string";
9
+ columnType: "SQLiteText";
10
+ data: string;
11
+ driverParam: string;
12
+ notNull: true;
13
+ hasDefault: false;
14
+ isPrimaryKey: false;
15
+ isAutoincrement: false;
16
+ hasRuntimeDefault: false;
17
+ enumValues: [string, ...string[]];
18
+ baseColumn: never;
19
+ identity: undefined;
20
+ generated: undefined;
21
+ }, {}, {
22
+ length: number | undefined;
23
+ }>;
24
+ created_by_task_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
25
+ name: "created_by_task_id";
26
+ tableName: "thread_creator_unverified";
27
+ dataType: "string";
28
+ columnType: "SQLiteText";
29
+ data: string;
30
+ driverParam: string;
31
+ notNull: true;
32
+ hasDefault: false;
33
+ isPrimaryKey: false;
34
+ isAutoincrement: false;
35
+ hasRuntimeDefault: false;
36
+ enumValues: [string, ...string[]];
37
+ baseColumn: never;
38
+ identity: undefined;
39
+ generated: undefined;
40
+ }, {}, {
41
+ length: number | undefined;
42
+ }>;
43
+ };
44
+ dialect: "sqlite";
45
+ }>;
@@ -2868,6 +2868,7 @@ export interface QueryOptions {
2868
2868
  messages?: import('../conversation/types').TemplateMessage[];
2869
2869
  uiProjections?: readonly import('../ui-instance/types').UiAgentContextProjection[];
2870
2870
  mcpAppProjections?: readonly McpAppStateDescriptor[];
2871
+ mcpAppModelContext?: import('../mcp-app/model-context.js').McpAppModelContext;
2871
2872
  vars?: Record<string, unknown>;
2872
2873
  cwd?: string;
2873
2874
  resumeSessionId?: string;
@@ -2917,6 +2918,7 @@ export interface ExecuteOptions {
2917
2918
  messages?: import('../conversation/types').TemplateMessage[];
2918
2919
  uiProjections?: readonly import('../ui-instance/types').UiAgentContextProjection[];
2919
2920
  mcpAppProjections?: readonly McpAppStateDescriptor[];
2921
+ mcpAppModelContext?: import('../mcp-app/model-context.js').McpAppModelContext;
2920
2922
  vars?: Record<string, unknown>;
2921
2923
  cwd?: string;
2922
2924
  resumeSessionId?: string;
@@ -1,4 +1,4 @@
1
- export type { ActionReceipt, ActionReceiptOutcome, CreateUiInstanceInput, JsonObject, JsonPrimitive, JsonValue, UiActionHandlerContext, UiActionHandlerRegistration, UiActionHandlerResult, UiActionEnvelope, UiActionConfirmation, UiActor, UiDefinition, UiDefinitionAction, UiDefinitionDisplayMode, UiDefinitionInput, UiDefinitionRef, UiDefinitionUsage, UiProjectionPolicy, UiExecutionContext, UiAuthenticatedActor, UiTaskActorSnapshot, UiAuthenticatedExecutionContext, UiAuthenticatedGrantPolicy, UiServerRuntimeFacade, UiServerRuntimeOptions, UiAgentContextProjection, UiExternalActionHandlerRegistration, UiInstance, UiInstanceStatus, UiLocalGrantPolicy, UiRuntimeFacade, UiRuntimeOptions, UiStateActionHandlerRegistration, } from './types.js';
1
+ export type { ActionReceipt, ActionReceiptOutcome, CreateUiInstanceInput, JsonObject, JsonPrimitive, JsonValue, UiActionHandlerContext, UiActionHandlerRegistration, UiActionHandlerResult, UiActionEnvelope, UiActionConfirmation, UiActor, UiDefinition, UiDefinitionAction, UiDefinitionDisplayMode, UiDefinitionInput, UiDefinitionRef, UiDefinitionUsage, UiProjectionPolicy, UiExecutionContext, UiAuthenticatedActor, UiTaskActorSnapshot, UiAuthenticatedExecutionContext, UiApprovalRequestContext, UiTaskExecutionContext, UiApprovalDecisionProvenance, UiApprovalPendingReceipt, UiApprovalRequestReceiptResult, UiAuthenticatedGrantPolicy, UiServerRuntimeFacade, UiServerRuntimeOptions, UiAgentContextProjection, UiExternalActionHandlerRegistration, UiInstance, UiInstanceStatus, UiLocalGrantPolicy, UiRuntimeFacade, UiRuntimeOptions, UiStateActionHandlerRegistration, } from './types.js';
2
2
  export { isUiAuthenticatedActor, resolveUiEffectiveCapabilities } from './types.js';
3
3
  export { UiRuntimeError } from './errors.js';
4
4
  export type { UiRuntimeErrorCode } from './errors.js';
@@ -1,4 +1,4 @@
1
- import type { ActionReceipt, ActionReceiptOutcome, JsonObject, UiActionHandlerContext, UiActor, UiInstance, UiAuthenticatedActor, UiDefinitionRef } from './types.js';
1
+ import type { ActionReceipt, ActionReceiptOutcome, UiApprovalDecisionProvenance, UiApprovalPendingReceipt, UiApprovalRequestReceiptResult, JsonObject, UiActionHandlerContext, UiActor, UiInstance, UiAuthenticatedActor, UiDefinitionRef } from './types.js';
2
2
  export type UiInstanceDataPathResolver = (definition: UiDefinitionRef) => readonly string[];
3
3
  interface UiInstanceStoreTestHooks {
4
4
  injectDatabaseError?: () => unknown | undefined;
@@ -17,6 +17,30 @@ export interface ReservationInput {
17
17
  receiptInput?: JsonObject;
18
18
  now: number;
19
19
  }
20
+ export interface ApprovalPendingReservationInput {
21
+ readonly reservation: ReservationInput;
22
+ readonly approvalId: string;
23
+ readonly expiresAt: number;
24
+ }
25
+ export type ApprovalPendingReservationResult = {
26
+ readonly kind: 'reserved';
27
+ readonly reservation: ExternalReservation;
28
+ } | {
29
+ readonly kind: 'settled';
30
+ readonly receipt: ActionReceipt;
31
+ };
32
+ interface ApprovalReceiptMarker {
33
+ state: 'pending' | 'executing' | 'settled';
34
+ approvalId: string;
35
+ expiresAt: number;
36
+ decidedBy?: string;
37
+ }
38
+ interface ApprovalReceiptRecord {
39
+ readonly receipt: ActionReceipt;
40
+ readonly approvalId: string;
41
+ readonly expiresAt: number;
42
+ readonly state: ApprovalReceiptMarker['state'];
43
+ }
20
44
  export interface StateHandlerExecution {
21
45
  handle: (context: UiActionHandlerContext) => {
22
46
  state?: JsonObject;
@@ -90,9 +114,18 @@ export declare class UiInstanceStore {
90
114
  updateAuditSnapshot(input: UiAuditSnapshotInput): UiInstance | null;
91
115
  getReceipt(instanceId: string, requestId: string): ActionReceipt | null;
92
116
  getReceiptById(receiptId: string): ActionReceipt | null;
117
+ createApprovalPendingReceipt(reservation: ReservationInput, approval: {
118
+ readonly approvalId: string;
119
+ readonly expiresAt: number;
120
+ }): UiApprovalRequestReceiptResult;
121
+ getApprovalPendingReceipt(receiptId: string): UiApprovalPendingReceipt | null;
122
+ getApprovalReceipt(receiptId: string): ApprovalReceiptRecord | null;
123
+ listApprovalPendingReceipts(): UiApprovalPendingReceipt[];
124
+ settleApprovalPendingReceipt(receiptId: string, outcome: 'rejected' | 'expired' | 'conflicted', provenance: UiApprovalDecisionProvenance, now: number): ActionReceipt | null;
93
125
  getLatestReceiptForInstance(instanceId: string): ActionReceipt | null;
94
126
  runStateOnly(reservation: ReservationInput, handler: StateHandlerExecution['handle']): ActionReceipt;
95
127
  reserveExternal(reservation: ReservationInput): ExternalReservation;
128
+ reserveApprovalPendingReceipt(reservation: ReservationInput, receiptId: string, provenance: UiApprovalDecisionProvenance): ApprovalPendingReservationResult;
96
129
  settleExternal(input: {
97
130
  reservation: ReservationInput;
98
131
  reservedRevision: number;
@@ -35,7 +35,6 @@ export interface UiDefinitionInput {
35
35
  readonly surfaces?: readonly string[];
36
36
  readonly stateProjection?: UiProjectionPolicy;
37
37
  readonly dataPaths?: readonly string[];
38
- readonly focusedAiDataPaths?: readonly string[];
39
38
  }
40
39
  export interface UiDefinition extends UiDefinitionInput {
41
40
  readonly hash: string;
@@ -103,6 +102,36 @@ export interface UiAuthenticatedExecutionContext {
103
102
  threadId: string;
104
103
  actor: UiAuthenticatedActor;
105
104
  }
105
+ export interface UiApprovalRequestContext {
106
+ source: 'cli';
107
+ workspaceId: string;
108
+ threadId: string;
109
+ actor: UiAuthenticatedActor;
110
+ }
111
+ export interface UiTaskExecutionContext {
112
+ source: 'cli';
113
+ workspaceId: string;
114
+ threadId: string;
115
+ actor: UiAuthenticatedActor & {
116
+ task: UiTaskActorSnapshot;
117
+ };
118
+ }
119
+ export interface UiApprovalDecisionProvenance {
120
+ approvalId: string;
121
+ decidedBy: string;
122
+ }
123
+ export interface UiApprovalPendingReceipt {
124
+ receipt: ActionReceipt;
125
+ approvalId: string;
126
+ expiresAt: number;
127
+ }
128
+ export interface UiApprovalRequestReceiptResult {
129
+ receipt: ActionReceipt;
130
+ approval: {
131
+ approvalId: string;
132
+ expiresAt: number;
133
+ } | null;
134
+ }
106
135
  export type ActionReceiptOutcome = 'succeeded' | 'rejected' | 'failed' | 'conflicted' | 'expired';
107
136
  export interface ActionReceipt {
108
137
  id: string;
@@ -193,7 +222,7 @@ export interface UiAuthenticatedGrantPolicy {
193
222
  definition: UiDefinitionRef;
194
223
  actionId: string;
195
224
  actor: UiAuthenticatedActor;
196
- source: 'ui_host' | 'system';
225
+ source: 'ui_host' | 'system' | 'cli';
197
226
  }): readonly string[];
198
227
  }
199
228
  export declare function resolveUiEffectiveCapabilities(declared: readonly string[], instanceGranted: readonly string[], dispatchGranted?: readonly string[]): readonly string[];
@@ -209,8 +238,15 @@ export interface UiServerRuntimeFacade {
209
238
  resolveDefinition(ref: UiDefinitionRef): UiDefinition | null;
210
239
  getInstance(instanceId: string, context: UiAuthenticatedExecutionContext): Promise<UiInstance | null>;
211
240
  createInstance(input: CreateUiInstanceInput, context: UiAuthenticatedExecutionContext): Promise<UiInstance>;
212
- dispatchAction(input: UiActionEnvelope, context: UiAuthenticatedExecutionContext): Promise<ActionReceipt>;
241
+ dispatchAction(input: UiActionEnvelope, context: UiAuthenticatedExecutionContext | UiTaskExecutionContext): Promise<ActionReceipt>;
213
242
  getReceipt(instanceId: string, requestId: string, context: UiAuthenticatedExecutionContext): Promise<ActionReceipt | null>;
243
+ createApprovalPendingReceipt(input: UiActionEnvelope, context: UiApprovalRequestContext, approval: {
244
+ approvalId: string;
245
+ expiresAt: number;
246
+ }): Promise<UiApprovalRequestReceiptResult>;
247
+ executeApprovalPending(input: UiActionEnvelope, receiptId: string, provenance: UiApprovalDecisionProvenance): Promise<ActionReceipt>;
248
+ settleApprovalPending(receiptId: string, outcome: 'rejected' | 'expired' | 'conflicted', provenance: UiApprovalDecisionProvenance): Promise<ActionReceipt | null>;
249
+ listApprovalPendingReceipts(): Promise<UiApprovalPendingReceipt[]>;
214
250
  close(): void;
215
251
  }
216
252
  export interface UiAgentContextProjection {
@@ -1,4 +1,4 @@
1
- import type { JsonValue, UiActionConfirmation, UiDefinitionInput } from '../ui-instance/types.js';
1
+ import type { JsonObject, JsonValue, UiActionConfirmation, UiDefinitionInput } from '../ui-instance/types.js';
2
2
  export type UiPluginPrimitive = 'card-shell' | 'meta-banner' | 'heading' | 'labeled-text' | 'step-flow' | 'text-list';
3
3
  export type UiPluginSchemaType = 'text' | 'text-list' | 'step-list';
4
4
  export interface UiPluginTextSchema {
@@ -110,6 +110,7 @@ export interface UiPluginAction {
110
110
  readonly backend: UiPluginBackend;
111
111
  readonly dataInputs?: readonly string[];
112
112
  readonly confirmation?: UiActionConfirmation;
113
+ readonly _meta?: JsonObject;
113
114
  }
114
115
  export interface UiPluginResourceRef {
115
116
  readonly path: 'ui/index.html' | 'ui/state.json';
@@ -140,8 +141,8 @@ export interface UiPluginManifestV2 {
140
141
  readonly size: UiPluginSize;
141
142
  readonly stateProjection: UiPluginProjectionPolicy;
142
143
  readonly dataPaths?: readonly string[];
143
- readonly focusedAiDataPaths?: readonly string[];
144
144
  readonly actions: readonly UiPluginAction[];
145
+ readonly _meta?: JsonObject;
145
146
  }
146
147
  export type UiPluginManifest = UiPluginManifestV1 | UiPluginManifestV2;
147
148
  export interface UiPluginHandlerMetadata {
@@ -0,0 +1,2 @@
1
+ export declare function normalizeLocalActorId(username: string, hostname: string): string | null;
2
+ export declare function getLocalActorId(): string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crewx/sdk",
3
- "version": "0.9.0-rc.120",
3
+ "version": "0.9.0-rc.121",
4
4
  "license": "UNLICENSED",
5
5
  "engines": {
6
6
  "node": ">=20.19.0"
@@ -20,6 +20,14 @@
20
20
  "types": "./dist/index.browser.d.ts",
21
21
  "import": "./dist/index.browser.js"
22
22
  },
23
+ "./node": {
24
+ "types": "./dist/node/index.d.ts",
25
+ "node": {
26
+ "import": "./dist/node/index.js",
27
+ "require": "./dist/node/index.js"
28
+ },
29
+ "browser": null
30
+ },
23
31
  "./skills": {
24
32
  "types": "./dist/skills/index.d.ts",
25
33
  "import": "./dist/skills/index.js",