@crewx/sdk 0.9.0-rc.203 → 0.9.0-rc.205
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 +288 -288
- package/dist/esm/plugins/index.js +92 -92
- package/dist/esm/repository/index.js +146 -146
- package/dist/index.browser.js +4 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +293 -293
- package/dist/migrations/0049_blue_sleepwalker.sql +25 -0
- package/dist/migrations/meta/0049_snapshot.json +5165 -0
- package/dist/migrations/meta/_journal.json +7 -0
- package/dist/plugins/index.js +97 -97
- package/dist/provider/cli/meta.d.ts +1 -0
- package/dist/repository/index.js +148 -148
- package/dist/route/decide.d.ts +2 -0
- package/dist/route/index.d.ts +2 -2
- package/dist/route/sqlite-store.d.ts +3 -2
- package/dist/route/store.d.ts +7 -4
- package/dist/route/types.d.ts +111 -18
- package/dist/schema/model-routes.d.ts +58 -1
- package/dist/types/index.d.ts +35 -370
- package/dist/ui-plugin/app-manifest.d.ts +1 -1
- package/package.json +1 -1
package/dist/route/decide.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { RouteDecisionStore } from './store.js';
|
|
|
4
4
|
export interface RouteDecisionServiceOptions {
|
|
5
5
|
store: RouteDecisionStore;
|
|
6
6
|
observationSource?: RouteObservationSource;
|
|
7
|
+
workspaceKey?: string;
|
|
7
8
|
workspaceRoot?: string;
|
|
8
9
|
clock?: () => number;
|
|
9
10
|
chainTimeoutMs?: number;
|
|
@@ -31,6 +32,7 @@ export declare class RouteDecisionService {
|
|
|
31
32
|
private readonly store;
|
|
32
33
|
private readonly observationSource?;
|
|
33
34
|
private readonly workspaceRoot;
|
|
35
|
+
private readonly workspaceKey;
|
|
34
36
|
private readonly clock;
|
|
35
37
|
private readonly chainTimeoutMs;
|
|
36
38
|
private readonly maxCasRetries;
|
package/dist/route/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { RouteConfigSchema, RouteCandidateConfigSchema, RouteLinkConfigSchema } from './types.js';
|
|
2
|
-
export type { JsonPrimitive, JsonValue, RouteBlockedCause, RouteCandidate, RouteCandidateConfig, RouteConfig, RouteContext, RouteDecision, RouteFunction, RouteHealth, RouteLinkConfig, RouteLinkError, RouteMode, RouteOutput, RoutePassOutput, RouteQuotaObservation, RouteRequest, RouteRunner, RouteSelectOutput, } from './types.js';
|
|
1
|
+
export { RouteConfigSchema, RouteModelConfigSchema, RouteCandidateConfigSchema, RouteLinkConfigSchema, } from './types.js';
|
|
2
|
+
export type { JsonPrimitive, JsonValue, RouteBlockedCause, RouteModel, RouteModelConfig, RouteCandidate, RouteCandidateConfig, RouteConfig, RouteContext, RouteDecision, RouteFunction, RouteHealth, RouteLinkConfig, RouteLinkError, RouteMode, RouteOutput, RoutePassOutput, RouteQuotaObservation, RouteRequest, RouteRunner, RouteSelectOutput, } from './types.js';
|
|
3
3
|
export { RouteError, RouteRunnerError } from './errors.js';
|
|
4
4
|
export type { RouteErrorCode, RouteRunnerErrorCode } from './errors.js';
|
|
5
5
|
export { builtInStrategy, roundRobin, smoothWeighted } from './strategies.js';
|
|
@@ -9,8 +9,9 @@ export declare class RouteSqliteStore extends BaseSqliteRepository implements Ro
|
|
|
9
9
|
});
|
|
10
10
|
resolveDbPath(): string;
|
|
11
11
|
private openHandle;
|
|
12
|
-
getDecision(routeId: string, taskId: string): Promise<RouteDecision | undefined>;
|
|
13
|
-
|
|
12
|
+
getDecision(workspaceKey: string, routeId: string, taskId: string): Promise<RouteDecision | undefined>;
|
|
13
|
+
listDecisions(workspaceKey: string, routeId: string, limit: number): Promise<RouteDecision[]>;
|
|
14
|
+
loadState(workspaceKey: string, routeId: string, threadId: string | null, configRevision: string): Promise<RouteStateSnapshot>;
|
|
14
15
|
commitDecision(input: RouteDecisionCommit): Promise<RouteCommitResult>;
|
|
15
16
|
recordQuotaObservation(observation: RouteQuotaObservation, observedAt: number): Promise<void>;
|
|
16
17
|
getObservations(candidates: readonly RouteCandidateConfig[], _now: number): Promise<RouteQuotaObservation[]>;
|
package/dist/route/store.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface RouteStateSnapshot {
|
|
|
6
6
|
stickyCandidateId?: string;
|
|
7
7
|
}
|
|
8
8
|
export interface RouteDecisionCommit {
|
|
9
|
+
workspaceKey: string;
|
|
9
10
|
decision: RouteDecision;
|
|
10
11
|
expectedRevision: number;
|
|
11
12
|
expectedStoredConfigRevision: string | null;
|
|
@@ -24,8 +25,9 @@ export type RouteCommitResult = {
|
|
|
24
25
|
decision: RouteDecision;
|
|
25
26
|
};
|
|
26
27
|
export interface RouteDecisionStore {
|
|
27
|
-
getDecision(routeId: string, taskId: string): Promise<RouteDecision | undefined>;
|
|
28
|
-
|
|
28
|
+
getDecision(workspaceKey: string, routeId: string, taskId: string): Promise<RouteDecision | undefined>;
|
|
29
|
+
listDecisions(workspaceKey: string, routeId: string, limit: number): Promise<RouteDecision[]>;
|
|
30
|
+
loadState(workspaceKey: string, routeId: string, threadId: string | null, configRevision: string): Promise<RouteStateSnapshot>;
|
|
29
31
|
commitDecision(input: RouteDecisionCommit): Promise<RouteCommitResult>;
|
|
30
32
|
recordQuotaObservation(observation: RouteQuotaObservation, observedAt: number): Promise<void>;
|
|
31
33
|
}
|
|
@@ -37,8 +39,9 @@ export declare class MemoryRouteStore implements RouteDecisionStore, RouteObserv
|
|
|
37
39
|
private readonly sticky;
|
|
38
40
|
private readonly decisions;
|
|
39
41
|
private readonly observations;
|
|
40
|
-
getDecision(routeId: string, taskId: string): Promise<RouteDecision | undefined>;
|
|
41
|
-
|
|
42
|
+
getDecision(workspaceKey: string, routeId: string, taskId: string): Promise<RouteDecision | undefined>;
|
|
43
|
+
listDecisions(workspaceKey: string, routeId: string, limit: number): Promise<RouteDecision[]>;
|
|
44
|
+
loadState(workspaceKey: string, routeId: string, threadId: string | null, configRevision: string): Promise<RouteStateSnapshot>;
|
|
42
45
|
commitDecision(input: RouteDecisionCommit): Promise<RouteCommitResult>;
|
|
43
46
|
recordQuotaObservation(observation: RouteQuotaObservation, observedAt: number): Promise<void>;
|
|
44
47
|
getObservations(candidates: readonly RouteCandidateConfig[], _now: number): Promise<RouteQuotaObservation[]>;
|
package/dist/route/types.d.ts
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export declare const RouteModelConfigSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
provider: z.ZodString;
|
|
5
|
+
model: z.ZodString;
|
|
6
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
7
|
+
account: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strict", z.ZodTypeAny, {
|
|
9
|
+
id: string;
|
|
10
|
+
model: string;
|
|
11
|
+
provider: string;
|
|
12
|
+
weight: number;
|
|
13
|
+
account?: string | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
id: string;
|
|
16
|
+
model: string;
|
|
17
|
+
provider: string;
|
|
18
|
+
weight?: number | undefined;
|
|
19
|
+
account?: string | undefined;
|
|
20
|
+
}>;
|
|
2
21
|
export declare const RouteCandidateConfigSchema: z.ZodObject<{
|
|
3
22
|
id: z.ZodString;
|
|
4
23
|
provider: z.ZodString;
|
|
@@ -28,7 +47,8 @@ export declare const RouteLinkConfigSchema: z.ZodObject<{
|
|
|
28
47
|
kind: "custom";
|
|
29
48
|
run: string;
|
|
30
49
|
}>;
|
|
31
|
-
|
|
50
|
+
declare const RouteConfigInputSchema: z.ZodEffects<z.ZodObject<{
|
|
51
|
+
name: z.ZodOptional<z.ZodString>;
|
|
32
52
|
strategy: z.ZodEnum<["round-robin", "weighted"]>;
|
|
33
53
|
chain: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
34
54
|
kind: z.ZodLiteral<"custom">;
|
|
@@ -40,7 +60,26 @@ export declare const RouteConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
40
60
|
kind: "custom";
|
|
41
61
|
run: string;
|
|
42
62
|
}>, "many">>;
|
|
43
|
-
|
|
63
|
+
models: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
64
|
+
id: z.ZodString;
|
|
65
|
+
provider: z.ZodString;
|
|
66
|
+
model: z.ZodString;
|
|
67
|
+
weight: z.ZodDefault<z.ZodNumber>;
|
|
68
|
+
account: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, "strict", z.ZodTypeAny, {
|
|
70
|
+
id: string;
|
|
71
|
+
model: string;
|
|
72
|
+
provider: string;
|
|
73
|
+
weight: number;
|
|
74
|
+
account?: string | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
id: string;
|
|
77
|
+
model: string;
|
|
78
|
+
provider: string;
|
|
79
|
+
weight?: number | undefined;
|
|
80
|
+
account?: string | undefined;
|
|
81
|
+
}>, "many">>;
|
|
82
|
+
candidates: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
44
83
|
id: z.ZodString;
|
|
45
84
|
provider: z.ZodString;
|
|
46
85
|
model: z.ZodString;
|
|
@@ -58,80 +97,131 @@ export declare const RouteConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
58
97
|
provider: string;
|
|
59
98
|
weight?: number | undefined;
|
|
60
99
|
account?: string | undefined;
|
|
61
|
-
}>, "many"
|
|
100
|
+
}>, "many">>;
|
|
62
101
|
sticky: z.ZodDefault<z.ZodEnum<["conversation", "none"]>>;
|
|
102
|
+
defaultModel: z.ZodOptional<z.ZodString>;
|
|
63
103
|
defaultCandidate: z.ZodOptional<z.ZodString>;
|
|
64
104
|
}, "strict", z.ZodTypeAny, {
|
|
65
105
|
strategy: "round-robin" | "weighted";
|
|
66
|
-
|
|
106
|
+
sticky: "none" | "conversation";
|
|
107
|
+
name?: string | undefined;
|
|
108
|
+
models?: {
|
|
67
109
|
id: string;
|
|
68
110
|
model: string;
|
|
69
111
|
provider: string;
|
|
70
112
|
weight: number;
|
|
71
113
|
account?: string | undefined;
|
|
72
|
-
}[];
|
|
73
|
-
sticky: "none" | "conversation";
|
|
114
|
+
}[] | undefined;
|
|
74
115
|
chain?: {
|
|
75
116
|
kind: "custom";
|
|
76
117
|
run: string;
|
|
77
118
|
}[] | undefined;
|
|
119
|
+
candidates?: {
|
|
120
|
+
id: string;
|
|
121
|
+
model: string;
|
|
122
|
+
provider: string;
|
|
123
|
+
weight: number;
|
|
124
|
+
account?: string | undefined;
|
|
125
|
+
}[] | undefined;
|
|
126
|
+
defaultModel?: string | undefined;
|
|
78
127
|
defaultCandidate?: string | undefined;
|
|
79
128
|
}, {
|
|
80
129
|
strategy: "round-robin" | "weighted";
|
|
81
|
-
|
|
130
|
+
name?: string | undefined;
|
|
131
|
+
models?: {
|
|
82
132
|
id: string;
|
|
83
133
|
model: string;
|
|
84
134
|
provider: string;
|
|
85
135
|
weight?: number | undefined;
|
|
86
136
|
account?: string | undefined;
|
|
87
|
-
}[];
|
|
137
|
+
}[] | undefined;
|
|
88
138
|
chain?: {
|
|
89
139
|
kind: "custom";
|
|
90
140
|
run: string;
|
|
91
141
|
}[] | undefined;
|
|
142
|
+
candidates?: {
|
|
143
|
+
id: string;
|
|
144
|
+
model: string;
|
|
145
|
+
provider: string;
|
|
146
|
+
weight?: number | undefined;
|
|
147
|
+
account?: string | undefined;
|
|
148
|
+
}[] | undefined;
|
|
92
149
|
sticky?: "none" | "conversation" | undefined;
|
|
150
|
+
defaultModel?: string | undefined;
|
|
93
151
|
defaultCandidate?: string | undefined;
|
|
94
152
|
}>, {
|
|
95
153
|
strategy: "round-robin" | "weighted";
|
|
96
|
-
|
|
154
|
+
sticky: "none" | "conversation";
|
|
155
|
+
name?: string | undefined;
|
|
156
|
+
models?: {
|
|
97
157
|
id: string;
|
|
98
158
|
model: string;
|
|
99
159
|
provider: string;
|
|
100
160
|
weight: number;
|
|
101
161
|
account?: string | undefined;
|
|
102
|
-
}[];
|
|
103
|
-
sticky: "none" | "conversation";
|
|
162
|
+
}[] | undefined;
|
|
104
163
|
chain?: {
|
|
105
164
|
kind: "custom";
|
|
106
165
|
run: string;
|
|
107
166
|
}[] | undefined;
|
|
167
|
+
candidates?: {
|
|
168
|
+
id: string;
|
|
169
|
+
model: string;
|
|
170
|
+
provider: string;
|
|
171
|
+
weight: number;
|
|
172
|
+
account?: string | undefined;
|
|
173
|
+
}[] | undefined;
|
|
174
|
+
defaultModel?: string | undefined;
|
|
108
175
|
defaultCandidate?: string | undefined;
|
|
109
176
|
}, {
|
|
110
177
|
strategy: "round-robin" | "weighted";
|
|
111
|
-
|
|
178
|
+
name?: string | undefined;
|
|
179
|
+
models?: {
|
|
112
180
|
id: string;
|
|
113
181
|
model: string;
|
|
114
182
|
provider: string;
|
|
115
183
|
weight?: number | undefined;
|
|
116
184
|
account?: string | undefined;
|
|
117
|
-
}[];
|
|
185
|
+
}[] | undefined;
|
|
118
186
|
chain?: {
|
|
119
187
|
kind: "custom";
|
|
120
188
|
run: string;
|
|
121
189
|
}[] | undefined;
|
|
190
|
+
candidates?: {
|
|
191
|
+
id: string;
|
|
192
|
+
model: string;
|
|
193
|
+
provider: string;
|
|
194
|
+
weight?: number | undefined;
|
|
195
|
+
account?: string | undefined;
|
|
196
|
+
}[] | undefined;
|
|
122
197
|
sticky?: "none" | "conversation" | undefined;
|
|
198
|
+
defaultModel?: string | undefined;
|
|
123
199
|
defaultCandidate?: string | undefined;
|
|
124
200
|
}>;
|
|
125
|
-
export type
|
|
201
|
+
export type RouteConfig = {
|
|
202
|
+
name?: string;
|
|
203
|
+
strategy: 'round-robin' | 'weighted';
|
|
204
|
+
chain?: RouteLinkConfig[];
|
|
205
|
+
models: RouteModelConfig[];
|
|
206
|
+
sticky: 'conversation' | 'none';
|
|
207
|
+
defaultModel?: string;
|
|
208
|
+
candidates?: RouteModelConfig[];
|
|
209
|
+
defaultCandidate?: string;
|
|
210
|
+
};
|
|
211
|
+
type ParsedRouteConfig = RouteConfig & {
|
|
212
|
+
candidates: RouteModelConfig[];
|
|
213
|
+
};
|
|
214
|
+
export declare const RouteConfigSchema: z.ZodType<ParsedRouteConfig, z.ZodTypeDef, z.input<typeof RouteConfigInputSchema>>;
|
|
215
|
+
export type RouteModelConfig = z.infer<typeof RouteModelConfigSchema>;
|
|
216
|
+
export type RouteCandidateConfig = RouteModelConfig;
|
|
126
217
|
export type RouteLinkConfig = z.infer<typeof RouteLinkConfigSchema>;
|
|
127
|
-
export type RouteConfig = z.infer<typeof RouteConfigSchema>;
|
|
128
218
|
export type JsonPrimitive = string | number | boolean | null;
|
|
129
219
|
export type JsonValue = JsonPrimitive | JsonValue[] | {
|
|
130
220
|
[key: string]: JsonValue;
|
|
131
221
|
};
|
|
132
222
|
export type RouteHealth = 'ok' | 'unknown' | 'blocked';
|
|
133
223
|
export type RouteMode = 'query' | 'execute';
|
|
134
|
-
export interface
|
|
224
|
+
export interface RouteModel {
|
|
135
225
|
id: string;
|
|
136
226
|
provider: string;
|
|
137
227
|
model: string;
|
|
@@ -140,6 +230,7 @@ export interface RouteCandidate {
|
|
|
140
230
|
health: RouteHealth;
|
|
141
231
|
resetAt?: number;
|
|
142
232
|
}
|
|
233
|
+
export type RouteCandidate = RouteModel;
|
|
143
234
|
export interface RouteContext {
|
|
144
235
|
v: 1;
|
|
145
236
|
route: {
|
|
@@ -153,12 +244,13 @@ export interface RouteContext {
|
|
|
153
244
|
mode: RouteMode;
|
|
154
245
|
};
|
|
155
246
|
now: number;
|
|
156
|
-
|
|
247
|
+
models: RouteModel[];
|
|
248
|
+
candidates: RouteModel[];
|
|
157
249
|
state: JsonValue;
|
|
158
250
|
}
|
|
159
251
|
export interface RouteSelectOutput {
|
|
160
252
|
type: 'select';
|
|
161
|
-
|
|
253
|
+
modelId: string;
|
|
162
254
|
nextState: JsonValue;
|
|
163
255
|
reason: string;
|
|
164
256
|
}
|
|
@@ -210,3 +302,4 @@ export interface RouteRequest {
|
|
|
210
302
|
mode: RouteMode;
|
|
211
303
|
namedAcpSession?: boolean;
|
|
212
304
|
}
|
|
305
|
+
export {};
|
|
@@ -2,6 +2,25 @@ export declare const route_states: import("drizzle-orm/sqlite-core").SQLiteTable
|
|
|
2
2
|
name: "route_states";
|
|
3
3
|
schema: undefined;
|
|
4
4
|
columns: {
|
|
5
|
+
workspace_key: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
6
|
+
name: "workspace_key";
|
|
7
|
+
tableName: "route_states";
|
|
8
|
+
dataType: "string";
|
|
9
|
+
columnType: "SQLiteText";
|
|
10
|
+
data: string;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
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
|
+
}>;
|
|
5
24
|
route_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
6
25
|
name: "route_id";
|
|
7
26
|
tableName: "route_states";
|
|
@@ -11,7 +30,7 @@ export declare const route_states: import("drizzle-orm/sqlite-core").SQLiteTable
|
|
|
11
30
|
driverParam: string;
|
|
12
31
|
notNull: true;
|
|
13
32
|
hasDefault: false;
|
|
14
|
-
isPrimaryKey:
|
|
33
|
+
isPrimaryKey: false;
|
|
15
34
|
isAutoincrement: false;
|
|
16
35
|
hasRuntimeDefault: false;
|
|
17
36
|
enumValues: [string, ...string[]];
|
|
@@ -102,6 +121,25 @@ export declare const route_sticky_bindings: import("drizzle-orm/sqlite-core").SQ
|
|
|
102
121
|
name: "route_sticky_bindings";
|
|
103
122
|
schema: undefined;
|
|
104
123
|
columns: {
|
|
124
|
+
workspace_key: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
125
|
+
name: "workspace_key";
|
|
126
|
+
tableName: "route_sticky_bindings";
|
|
127
|
+
dataType: "string";
|
|
128
|
+
columnType: "SQLiteText";
|
|
129
|
+
data: string;
|
|
130
|
+
driverParam: string;
|
|
131
|
+
notNull: true;
|
|
132
|
+
hasDefault: true;
|
|
133
|
+
isPrimaryKey: false;
|
|
134
|
+
isAutoincrement: false;
|
|
135
|
+
hasRuntimeDefault: false;
|
|
136
|
+
enumValues: [string, ...string[]];
|
|
137
|
+
baseColumn: never;
|
|
138
|
+
identity: undefined;
|
|
139
|
+
generated: undefined;
|
|
140
|
+
}, {}, {
|
|
141
|
+
length: number | undefined;
|
|
142
|
+
}>;
|
|
105
143
|
route_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
106
144
|
name: "route_id";
|
|
107
145
|
tableName: "route_sticky_bindings";
|
|
@@ -204,6 +242,25 @@ export declare const route_decisions: import("drizzle-orm/sqlite-core").SQLiteTa
|
|
|
204
242
|
}, {}, {
|
|
205
243
|
length: number | undefined;
|
|
206
244
|
}>;
|
|
245
|
+
workspace_key: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
246
|
+
name: "workspace_key";
|
|
247
|
+
tableName: "route_decisions";
|
|
248
|
+
dataType: "string";
|
|
249
|
+
columnType: "SQLiteText";
|
|
250
|
+
data: string;
|
|
251
|
+
driverParam: string;
|
|
252
|
+
notNull: true;
|
|
253
|
+
hasDefault: true;
|
|
254
|
+
isPrimaryKey: false;
|
|
255
|
+
isAutoincrement: false;
|
|
256
|
+
hasRuntimeDefault: false;
|
|
257
|
+
enumValues: [string, ...string[]];
|
|
258
|
+
baseColumn: never;
|
|
259
|
+
identity: undefined;
|
|
260
|
+
generated: undefined;
|
|
261
|
+
}, {}, {
|
|
262
|
+
length: number | undefined;
|
|
263
|
+
}>;
|
|
207
264
|
route_id: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
208
265
|
name: "route_id";
|
|
209
266
|
tableName: "route_decisions";
|