@crewx/sdk 0.9.0-rc.141 → 0.9.0-rc.143
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/esm/index.js +241 -208
- package/dist/esm/plugins/index.js +90 -66
- package/dist/esm/repository/index.js +193 -169
- package/dist/index.d.ts +3 -1
- package/dist/index.js +241 -208
- package/dist/migrations/0037_ui_instance_agent_open_request.sql +1 -0
- package/dist/migrations/0038_task_rating.sql +3 -0
- package/dist/migrations/meta/0037_snapshot.json +3598 -0
- package/dist/migrations/meta/0038_snapshot.json +3626 -0
- package/dist/migrations/meta/_journal.json +14 -0
- package/dist/plugins/index.js +90 -66
- package/dist/repository/index.d.ts +2 -0
- package/dist/repository/index.js +153 -129
- package/dist/repository/task.repository.d.ts +47 -1
- package/dist/schema/tasks.d.ts +38 -0
- package/dist/schema/ui-instances.d.ts +19 -0
- package/dist/ui-instance/index.d.ts +1 -1
- package/dist/ui-instance/store.d.ts +13 -1
- package/dist/ui-instance/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BaseSqliteRepository } from './base-sqlite-repository.js';
|
|
2
|
+
import type { DrizzleDb } from './db.js';
|
|
3
|
+
import { RepositoryError } from './errors.js';
|
|
2
4
|
import { tasks } from '../schema/index.js';
|
|
3
5
|
import type { TaskLogEntry, TaskLogReadResult, TaskLogState } from './task-log.repository.js';
|
|
4
6
|
import { type TaskStatus, type TaskTerminalReason } from './task-status.js';
|
|
@@ -47,7 +49,7 @@ export interface FinalizeTaskForHostShutdownOptions {
|
|
|
47
49
|
completedAt?: string;
|
|
48
50
|
}
|
|
49
51
|
export type FinalizeTaskForHostShutdownOutcome = 'settled' | 'not_running' | 'epoch_mismatch' | 'workspace_mismatch';
|
|
50
|
-
export type TaskListRow = Pick<TaskRow, 'id' | 'thread_id' | 'agent_id' | 'status' | 'parent_task_id' | 'started_at' | 'completed_at' | 'duration_ms' | 'input_tokens' | 'output_tokens' | 'cost_usd' | 'error'> & {
|
|
52
|
+
export type TaskListRow = Pick<TaskRow, 'id' | 'thread_id' | 'agent_id' | 'status' | 'parent_task_id' | 'started_at' | 'completed_at' | 'duration_ms' | 'input_tokens' | 'output_tokens' | 'cost_usd' | 'error' | 'rating' | 'rated_at'> & {
|
|
51
53
|
terminalReason: TaskTerminalReason | null;
|
|
52
54
|
};
|
|
53
55
|
export type TaskActivityLogRow = Pick<TaskRow, 'id' | 'thread_id' | 'agent_id' | 'parent_task_id' | 'started_at' | 'completed_at'>;
|
|
@@ -374,3 +376,47 @@ export declare class TaskRepository extends BaseSqliteRepository {
|
|
|
374
376
|
maxTurnsPerThread?: number;
|
|
375
377
|
}): ThreadChain[];
|
|
376
378
|
}
|
|
379
|
+
export declare const TASK_RATINGS: readonly ["up", "down"];
|
|
380
|
+
export type TaskRating = (typeof TASK_RATINGS)[number];
|
|
381
|
+
export declare const RATED_TASK_EXCERPT_MAX_CHARS = 1000;
|
|
382
|
+
export declare const RATED_TASK_LIST_MAX_LIMIT = 200;
|
|
383
|
+
export type TaskRatingErrorCode = 'TASK_NOT_FOUND' | 'TASK_RATING_NOT_TERMINAL';
|
|
384
|
+
export declare class TaskRatingError extends RepositoryError {
|
|
385
|
+
readonly stableCode: TaskRatingErrorCode;
|
|
386
|
+
readonly taskId: string;
|
|
387
|
+
constructor(stableCode: TaskRatingErrorCode, taskId: string);
|
|
388
|
+
}
|
|
389
|
+
export interface SetTaskRatingInput {
|
|
390
|
+
workspaceId: string;
|
|
391
|
+
taskId: string;
|
|
392
|
+
rating: TaskRating | null;
|
|
393
|
+
now?: string;
|
|
394
|
+
}
|
|
395
|
+
export interface SetTaskRatingResult {
|
|
396
|
+
taskId: string;
|
|
397
|
+
rating: TaskRating | null;
|
|
398
|
+
ratedAt: string | null;
|
|
399
|
+
changed: boolean;
|
|
400
|
+
}
|
|
401
|
+
export declare function setTaskRating(db: DrizzleDb, input: SetTaskRatingInput): SetTaskRatingResult;
|
|
402
|
+
export interface ListRatedTasksInput {
|
|
403
|
+
workspaceId: string;
|
|
404
|
+
agentId?: string;
|
|
405
|
+
sinceIso?: string;
|
|
406
|
+
limit: number;
|
|
407
|
+
}
|
|
408
|
+
export interface RatedTaskRow {
|
|
409
|
+
taskId: string;
|
|
410
|
+
agentId: string;
|
|
411
|
+
threadId: string | null;
|
|
412
|
+
status: TaskStatus;
|
|
413
|
+
rating: TaskRating;
|
|
414
|
+
ratedAt: string;
|
|
415
|
+
promptExcerpt: string | null;
|
|
416
|
+
resultExcerpt: string | null;
|
|
417
|
+
}
|
|
418
|
+
export declare function buildRatedTasksQuery(input: ListRatedTasksInput): import("drizzle-orm").SQL<unknown>;
|
|
419
|
+
export declare function listRatedTasks(db: DrizzleDb, input: ListRatedTasksInput): RatedTaskRow[];
|
|
420
|
+
export type CountRatedTasksInput = Omit<ListRatedTasksInput, 'limit'>;
|
|
421
|
+
export declare function buildRatedTasksCountQuery(input: CountRatedTasksInput): import("drizzle-orm").SQL<unknown>;
|
|
422
|
+
export declare function countRatedTasks(db: DrizzleDb, input: CountRatedTasksInput): number;
|
package/dist/schema/tasks.d.ts
CHANGED
|
@@ -797,6 +797,44 @@ export declare const tasks: import("drizzle-orm/sqlite-core").SQLiteTableWithCol
|
|
|
797
797
|
identity: undefined;
|
|
798
798
|
generated: undefined;
|
|
799
799
|
}, {}, {}>;
|
|
800
|
+
rating: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
801
|
+
name: "rating";
|
|
802
|
+
tableName: "tasks";
|
|
803
|
+
dataType: "string";
|
|
804
|
+
columnType: "SQLiteText";
|
|
805
|
+
data: "up" | "down";
|
|
806
|
+
driverParam: string;
|
|
807
|
+
notNull: false;
|
|
808
|
+
hasDefault: false;
|
|
809
|
+
isPrimaryKey: false;
|
|
810
|
+
isAutoincrement: false;
|
|
811
|
+
hasRuntimeDefault: false;
|
|
812
|
+
enumValues: ["up", "down"];
|
|
813
|
+
baseColumn: never;
|
|
814
|
+
identity: undefined;
|
|
815
|
+
generated: undefined;
|
|
816
|
+
}, {}, {
|
|
817
|
+
length: number | undefined;
|
|
818
|
+
}>;
|
|
819
|
+
rated_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
820
|
+
name: "rated_at";
|
|
821
|
+
tableName: "tasks";
|
|
822
|
+
dataType: "string";
|
|
823
|
+
columnType: "SQLiteText";
|
|
824
|
+
data: string;
|
|
825
|
+
driverParam: string;
|
|
826
|
+
notNull: false;
|
|
827
|
+
hasDefault: false;
|
|
828
|
+
isPrimaryKey: false;
|
|
829
|
+
isAutoincrement: false;
|
|
830
|
+
hasRuntimeDefault: false;
|
|
831
|
+
enumValues: [string, ...string[]];
|
|
832
|
+
baseColumn: never;
|
|
833
|
+
identity: undefined;
|
|
834
|
+
generated: undefined;
|
|
835
|
+
}, {}, {
|
|
836
|
+
length: number | undefined;
|
|
837
|
+
}>;
|
|
800
838
|
};
|
|
801
839
|
dialect: "sqlite";
|
|
802
840
|
}>;
|
|
@@ -264,6 +264,25 @@ export declare const ui_instances: import("drizzle-orm/sqlite-core").SQLiteTable
|
|
|
264
264
|
}, {}, {
|
|
265
265
|
length: number | undefined;
|
|
266
266
|
}>;
|
|
267
|
+
agent_open_request_json: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
268
|
+
name: "agent_open_request_json";
|
|
269
|
+
tableName: "ui_instances";
|
|
270
|
+
dataType: "string";
|
|
271
|
+
columnType: "SQLiteText";
|
|
272
|
+
data: string;
|
|
273
|
+
driverParam: string;
|
|
274
|
+
notNull: false;
|
|
275
|
+
hasDefault: false;
|
|
276
|
+
isPrimaryKey: false;
|
|
277
|
+
isAutoincrement: false;
|
|
278
|
+
hasRuntimeDefault: false;
|
|
279
|
+
enumValues: [string, ...string[]];
|
|
280
|
+
baseColumn: never;
|
|
281
|
+
identity: undefined;
|
|
282
|
+
generated: undefined;
|
|
283
|
+
}, {}, {
|
|
284
|
+
length: number | undefined;
|
|
285
|
+
}>;
|
|
267
286
|
created_at: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
268
287
|
name: "created_at";
|
|
269
288
|
tableName: "ui_instances";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { ActionReceipt, ActionReceiptResultSummary, ActionExecutionReceipt, ActionReceiptOutcome, CreateUiInstanceInput, JsonObject, JsonPrimitive, JsonValue, UiActionHandlerContext, UiActionHandlerRegistration, UiActionHandlerResult, UiActionEnvelope, UiActionConfirmation, UiSkillBackendEnvironmentKey, UiActor, UiDefinition, UiDefinitionAction, UiDefinitionDisplayMode, UiDefinitionInput, UiDefinitionLegacyMetadata, 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';
|
|
1
|
+
export type { ActionReceipt, ActionReceiptResultSummary, ActionExecutionReceipt, ActionReceiptOutcome, CreateUiInstanceInput, JsonObject, JsonPrimitive, JsonValue, UiActionHandlerContext, UiActionHandlerRegistration, UiActionHandlerResult, UiActionEnvelope, UiActionConfirmation, UiSkillBackendEnvironmentKey, UiActor, UiDefinition, UiDefinitionAction, UiDefinitionDisplayMode, UiDefinitionInput, UiDefinitionLegacyMetadata, UiDefinitionRef, UiDefinitionUsage, UiProjectionPolicy, UiExecutionContext, UiAuthenticatedActor, UiTaskActorSnapshot, UiAuthenticatedExecutionContext, UiApprovalRequestContext, UiTaskExecutionContext, UiApprovalDecisionProvenance, UiApprovalPendingReceipt, UiApprovalRequestReceiptResult, UiAuthenticatedGrantPolicy, UiServerRuntimeFacade, UiServerRuntimeOptions, UiAgentContextProjection, UiExternalActionHandlerRegistration, UiAgentOpenReason, UiAgentOpenRequest, 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,5 +1,5 @@
|
|
|
1
1
|
import type { UiDefinitionLineageEntry } from './lineage.js';
|
|
2
|
-
import type { ActionReceipt, ActionReceiptOutcome, UiApprovalDecisionProvenance, UiApprovalPendingReceipt, UiApprovalRequestReceiptResult, JsonObject, UiActionHandlerContext, UiActor, UiInstance, UiAuthenticatedActor, UiDefinition, UiDefinitionRef } from './types.js';
|
|
2
|
+
import type { ActionReceipt, ActionReceiptOutcome, UiApprovalDecisionProvenance, UiApprovalPendingReceipt, UiApprovalRequestReceiptResult, JsonObject, UiActionHandlerContext, UiActor, UiAgentOpenReason, UiAgentOpenRequest, UiInstance, UiAuthenticatedActor, UiDefinition, UiDefinitionRef } from './types.js';
|
|
3
3
|
export type UiInstanceDataPathResolver = (definition: UiDefinitionRef) => readonly string[];
|
|
4
4
|
interface UiInstanceStoreTestHooks {
|
|
5
5
|
injectDatabaseError?: () => unknown | undefined;
|
|
@@ -109,6 +109,7 @@ export interface UiAuditSnapshotInput {
|
|
|
109
109
|
export interface UiInstanceReadStore {
|
|
110
110
|
get(instanceId: string): UiInstance | null;
|
|
111
111
|
listByThread(workspaceId: string, threadId: string): UiInstance[];
|
|
112
|
+
listAgentOpenRequests(workspaceId: string, threadId: string): Map<string, UiAgentOpenRequest>;
|
|
112
113
|
listUnboundByApp(workspaceId: string, appId: string): UiInstance[];
|
|
113
114
|
getThreadBinding(workspaceId: string, threadId: string): ThreadBinding;
|
|
114
115
|
close(): void;
|
|
@@ -147,6 +148,17 @@ export declare class UiInstanceStore {
|
|
|
147
148
|
now: number;
|
|
148
149
|
}): UiInstance;
|
|
149
150
|
get(instanceId: string, resolveDataPaths?: UiInstanceDataPathResolver): UiInstance | null;
|
|
151
|
+
getAgentOpenRequest(instanceId: string): UiAgentOpenRequest | null;
|
|
152
|
+
listAgentOpenRequests(workspaceId: string, threadId: string): Map<string, UiAgentOpenRequest>;
|
|
153
|
+
recordAgentOpenRequest(input: {
|
|
154
|
+
instanceId: string;
|
|
155
|
+
workspaceId: string;
|
|
156
|
+
threadId: string;
|
|
157
|
+
taskId: string;
|
|
158
|
+
reason: UiAgentOpenReason;
|
|
159
|
+
approvalId?: string;
|
|
160
|
+
requestedAt: number;
|
|
161
|
+
}): UiAgentOpenRequest | null;
|
|
150
162
|
open(input: {
|
|
151
163
|
id?: string;
|
|
152
164
|
appId: string;
|
|
@@ -73,6 +73,14 @@ export interface CreateUiInstanceInput {
|
|
|
73
73
|
domainRef: JsonObject;
|
|
74
74
|
state: JsonObject;
|
|
75
75
|
}
|
|
76
|
+
export type UiAgentOpenReason = 'open' | 'approval';
|
|
77
|
+
export interface UiAgentOpenRequest {
|
|
78
|
+
requestId: string;
|
|
79
|
+
taskId: string;
|
|
80
|
+
reason: UiAgentOpenReason;
|
|
81
|
+
approvalId?: string;
|
|
82
|
+
requestedAt: number;
|
|
83
|
+
}
|
|
76
84
|
export interface UiInstance {
|
|
77
85
|
id: string;
|
|
78
86
|
definition: UiDefinitionRef;
|