@zhivex-ai/gateway 0.3.0 → 0.3.1-next.0
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/README.md +37 -0
- package/dist/attempts.d.ts +19 -0
- package/dist/attempts.d.ts.map +1 -0
- package/dist/attempts.js +221 -0
- package/dist/attempts.js.map +1 -0
- package/dist/compat.d.ts +1 -2
- package/dist/compat.d.ts.map +1 -1
- package/dist/compat.js +0 -6
- package/dist/compat.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +157 -260
- package/dist/index.js.map +1 -1
- package/dist/policies.d.ts +10 -0
- package/dist/policies.d.ts.map +1 -0
- package/dist/policies.js +210 -0
- package/dist/policies.js.map +1 -0
- package/dist/runtime-state.d.ts +32 -0
- package/dist/runtime-state.d.ts.map +1 -0
- package/dist/runtime-state.js +158 -0
- package/dist/runtime-state.js.map +1 -0
- package/dist/types.d.ts +194 -14
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type { GenerateObjectOutput, GenerateTextOutput, ModelCatalog, ProviderAdapter, ReasoningConfig, StreamObjectResult, StreamTextResult, TokenUsage, ToolChoice, ToolExecutionOptions, ToolSet } from "@zhivex-ai/core";
|
|
1
|
+
import type { AgentStepType, GenerateObjectOutput, GenerateTextOutput, GroundedLanguageModel, ModelCapabilities, ModelCatalog, LanguageModel, ProviderAdapter, ReasoningConfig, StreamObjectResult, StreamTextResult, TokenUsage, ToolChoice, ToolExecutionOptions, ToolSet } from "@zhivex-ai/core";
|
|
2
2
|
import type { ZodTypeAny } from "zod";
|
|
3
3
|
export type GatewayProviderId = "openai" | "anthropic" | "gemini" | "vertex" | "qwen" | "kimi" | "bedrock" | "ollama" | "azure-openai" | "openrouter";
|
|
4
4
|
export type GatewayRoutingMode = "speed" | "balanced" | "quality";
|
|
5
5
|
export type GatewayTaskIntent = "chat" | "reasoning" | "tool-heavy";
|
|
6
|
+
export type GatewayCostStrategy = "strict" | "prefer-cheaper" | "ignore";
|
|
7
|
+
export type GatewaySkipReason = "missing-adapter" | "capabilities" | "cost" | "cooldown" | "latency-budget";
|
|
8
|
+
export type GatewayCircuitState = "closed" | "open" | "half-open";
|
|
9
|
+
export type GatewayErrorClass = "timeout" | "rate-limit" | "connectivity" | "provider" | "validation" | "unknown";
|
|
6
10
|
export interface GatewayImageAttachment {
|
|
7
11
|
dataUrl: string;
|
|
8
12
|
mimeType: string;
|
|
@@ -16,6 +20,13 @@ export interface GatewayModelTarget {
|
|
|
16
20
|
provider: GatewayProviderId;
|
|
17
21
|
modelId: string;
|
|
18
22
|
}
|
|
23
|
+
export type GatewayRequiredCapabilities = Partial<Record<"streaming" | "tools" | "structuredOutput" | "jsonMode" | "vision" | "reasoning" | "webSearch", boolean>>;
|
|
24
|
+
export interface GatewayRetryPolicyOverride {
|
|
25
|
+
maxRetries?: number;
|
|
26
|
+
backoffMs?: number;
|
|
27
|
+
cooldownAfterRetryableFailures?: number;
|
|
28
|
+
cooldownMs?: number;
|
|
29
|
+
}
|
|
19
30
|
export interface GatewayRequest {
|
|
20
31
|
messages: GatewayMessage[];
|
|
21
32
|
systemPrompt?: string;
|
|
@@ -27,21 +38,191 @@ export interface GatewayRequest {
|
|
|
27
38
|
maxSteps?: number;
|
|
28
39
|
reasoning?: ReasoningConfig;
|
|
29
40
|
providerOptions?: Record<string, unknown>;
|
|
30
|
-
requiredCapabilities?:
|
|
41
|
+
requiredCapabilities?: GatewayRequiredCapabilities;
|
|
31
42
|
maxCostPer1kTokens?: number;
|
|
32
43
|
routingMode?: GatewayRoutingMode;
|
|
33
44
|
taskIntent?: GatewayTaskIntent;
|
|
45
|
+
stepType?: AgentStepType;
|
|
34
46
|
abortSignal?: AbortSignal;
|
|
35
47
|
primary: GatewayModelTarget;
|
|
36
48
|
fallbacks?: GatewayModelTarget[];
|
|
49
|
+
latencyBudgetMs?: number;
|
|
50
|
+
costStrategy?: GatewayCostStrategy;
|
|
51
|
+
retryPolicy?: GatewayRetryPolicyOverride;
|
|
52
|
+
allowDegradedCapabilities?: boolean;
|
|
53
|
+
preferLocal?: boolean;
|
|
37
54
|
}
|
|
38
55
|
export interface GatewayAttempt {
|
|
39
56
|
provider: GatewayProviderId;
|
|
40
57
|
modelId: string;
|
|
41
58
|
ok: boolean;
|
|
42
59
|
latencyMs: number;
|
|
60
|
+
retry: number;
|
|
61
|
+
targetRank: number;
|
|
43
62
|
errorMessage?: string;
|
|
63
|
+
retryable?: boolean;
|
|
64
|
+
skipReason?: GatewaySkipReason;
|
|
65
|
+
}
|
|
66
|
+
export interface GatewayTargetRuntimeState {
|
|
67
|
+
targetKey: string;
|
|
68
|
+
provider: GatewayProviderId;
|
|
69
|
+
modelId: string;
|
|
70
|
+
circuitState: GatewayCircuitState;
|
|
71
|
+
requestCount: number;
|
|
72
|
+
successCount: number;
|
|
73
|
+
failureCount: number;
|
|
74
|
+
retryableFailureCount: number;
|
|
75
|
+
nonRetryableFailureCount: number;
|
|
76
|
+
consecutiveFailures: number;
|
|
77
|
+
consecutiveRetryableFailures: number;
|
|
78
|
+
consecutiveErrorClass?: GatewayErrorClass;
|
|
79
|
+
lastLatencyMs?: number;
|
|
80
|
+
avgLatencyMs?: number;
|
|
81
|
+
latencyEwmaMs?: number;
|
|
82
|
+
latencyP95Ms?: number;
|
|
83
|
+
recentLatenciesMs: number[];
|
|
84
|
+
lastErrorMessage?: string;
|
|
85
|
+
lastErrorClass?: GatewayErrorClass;
|
|
86
|
+
errorCounts: Partial<Record<GatewayErrorClass, number>>;
|
|
87
|
+
cooldownUntil?: number;
|
|
88
|
+
createdAt: number;
|
|
89
|
+
lastUpdatedAt: number;
|
|
90
|
+
expiresAt?: number;
|
|
91
|
+
}
|
|
92
|
+
export interface GatewayRuntimeStore {
|
|
93
|
+
get(targetKey: string): GatewayTargetRuntimeState | undefined | Promise<GatewayTargetRuntimeState | undefined>;
|
|
94
|
+
set(targetKey: string, state: GatewayTargetRuntimeState): void | Promise<void>;
|
|
95
|
+
update(targetKey: string, updater: (state: GatewayTargetRuntimeState | undefined) => GatewayTargetRuntimeState): GatewayTargetRuntimeState | Promise<GatewayTargetRuntimeState>;
|
|
96
|
+
list?(): GatewayTargetRuntimeState[] | Promise<GatewayTargetRuntimeState[]>;
|
|
97
|
+
delete?(targetKey: string): void | Promise<void>;
|
|
98
|
+
clear?(): void | Promise<void>;
|
|
99
|
+
prune?(): number | Promise<number>;
|
|
100
|
+
}
|
|
101
|
+
export interface GatewayRetryErrorInfo {
|
|
102
|
+
message: string;
|
|
103
|
+
retryable: boolean;
|
|
104
|
+
errorClass: GatewayErrorClass;
|
|
105
|
+
}
|
|
106
|
+
export interface GatewayRetryPolicyContext {
|
|
107
|
+
request: GatewayRequest;
|
|
108
|
+
target: GatewayModelTarget;
|
|
109
|
+
state?: GatewayTargetRuntimeState;
|
|
110
|
+
retry: number;
|
|
111
|
+
targetRank: number;
|
|
112
|
+
error: GatewayRetryErrorInfo;
|
|
113
|
+
}
|
|
114
|
+
export interface GatewayRetryPolicy {
|
|
115
|
+
name: string;
|
|
116
|
+
classifyError(error: unknown): GatewayRetryErrorInfo;
|
|
117
|
+
shouldRetry(context: GatewayRetryPolicyContext): boolean;
|
|
118
|
+
getBackoffMs(context: GatewayRetryPolicyContext): number;
|
|
119
|
+
getCooldownMs(context: GatewayRetryPolicyContext): number;
|
|
120
|
+
}
|
|
121
|
+
export interface GatewayEvaluatedTarget {
|
|
122
|
+
target: GatewayModelTarget;
|
|
123
|
+
score: number;
|
|
124
|
+
available: boolean;
|
|
125
|
+
estimatedCostPer1kTokens?: number;
|
|
126
|
+
degradedCapabilities?: Array<keyof GatewayRequiredCapabilities>;
|
|
127
|
+
skipReason?: GatewaySkipReason;
|
|
128
|
+
state?: GatewayTargetRuntimeState;
|
|
129
|
+
}
|
|
130
|
+
export interface GatewayRouteDecision {
|
|
131
|
+
mode: GatewayRoutingMode;
|
|
132
|
+
intent: GatewayTaskIntent;
|
|
133
|
+
policy: string;
|
|
134
|
+
orderedTargets: GatewayModelTarget[];
|
|
135
|
+
evaluatedTargets: GatewayEvaluatedTarget[];
|
|
136
|
+
reason: string;
|
|
137
|
+
}
|
|
138
|
+
export interface GatewayResolvedModel {
|
|
139
|
+
target: GatewayModelTarget;
|
|
140
|
+
routeDecision: GatewayRouteDecision;
|
|
141
|
+
model: LanguageModel | GroundedLanguageModel;
|
|
142
|
+
kind: "language" | "grounded";
|
|
143
|
+
}
|
|
144
|
+
export interface GatewayRoutePlanningContext {
|
|
145
|
+
request: GatewayRequest;
|
|
146
|
+
targets: GatewayModelTarget[];
|
|
147
|
+
requiredCapabilities: GatewayRequiredCapabilities;
|
|
148
|
+
adapters: Partial<Record<GatewayProviderId, ProviderAdapter>>;
|
|
149
|
+
runtimeStates: Map<string, GatewayTargetRuntimeState | undefined>;
|
|
150
|
+
modelCatalog?: ModelCatalog;
|
|
151
|
+
providerCostsPer1kTokens?: Partial<Record<GatewayProviderId, number>>;
|
|
152
|
+
latencyBiasMs?: Partial<Record<GatewayProviderId, number>>;
|
|
153
|
+
now: number;
|
|
154
|
+
}
|
|
155
|
+
export interface GatewayRouterPolicy {
|
|
156
|
+
name: string;
|
|
157
|
+
plan(context: GatewayRoutePlanningContext): GatewayRouteDecision | Promise<GatewayRouteDecision>;
|
|
158
|
+
}
|
|
159
|
+
export interface GatewayAttemptStartedEvent {
|
|
160
|
+
type: "attempt-started";
|
|
161
|
+
request: GatewayRequest;
|
|
162
|
+
target: GatewayModelTarget;
|
|
163
|
+
retry: number;
|
|
164
|
+
targetRank: number;
|
|
165
|
+
timestamp: number;
|
|
166
|
+
}
|
|
167
|
+
export interface GatewayAttemptSucceededEvent {
|
|
168
|
+
type: "attempt-succeeded";
|
|
169
|
+
request: GatewayRequest;
|
|
170
|
+
target: GatewayModelTarget;
|
|
171
|
+
retry: number;
|
|
172
|
+
targetRank: number;
|
|
173
|
+
timestamp: number;
|
|
174
|
+
latencyMs: number;
|
|
175
|
+
}
|
|
176
|
+
export interface GatewayAttemptFailedEvent {
|
|
177
|
+
type: "attempt-failed";
|
|
178
|
+
request: GatewayRequest;
|
|
179
|
+
target: GatewayModelTarget;
|
|
180
|
+
retry: number;
|
|
181
|
+
targetRank: number;
|
|
182
|
+
timestamp: number;
|
|
183
|
+
latencyMs: number;
|
|
184
|
+
errorMessage: string;
|
|
185
|
+
retryable: boolean;
|
|
186
|
+
errorClass: GatewayErrorClass;
|
|
187
|
+
}
|
|
188
|
+
export interface GatewayAttemptRetriedEvent {
|
|
189
|
+
type: "attempt-retried";
|
|
190
|
+
request: GatewayRequest;
|
|
191
|
+
target: GatewayModelTarget;
|
|
192
|
+
retry: number;
|
|
193
|
+
targetRank: number;
|
|
194
|
+
timestamp: number;
|
|
195
|
+
delayMs: number;
|
|
44
196
|
}
|
|
197
|
+
export interface GatewayTargetSkippedEvent {
|
|
198
|
+
type: "target-skipped";
|
|
199
|
+
request: GatewayRequest;
|
|
200
|
+
target: GatewayModelTarget;
|
|
201
|
+
targetRank: number;
|
|
202
|
+
timestamp: number;
|
|
203
|
+
reason: GatewaySkipReason;
|
|
204
|
+
}
|
|
205
|
+
export interface GatewayRouteSelectedEvent {
|
|
206
|
+
type: "route-selected";
|
|
207
|
+
request: GatewayRequest;
|
|
208
|
+
timestamp: number;
|
|
209
|
+
decision: GatewayRouteDecision;
|
|
210
|
+
}
|
|
211
|
+
export interface GatewayTargetCooledDownEvent {
|
|
212
|
+
type: "target-cooled-down";
|
|
213
|
+
request: GatewayRequest;
|
|
214
|
+
target: GatewayModelTarget;
|
|
215
|
+
timestamp: number;
|
|
216
|
+
cooldownUntil: number;
|
|
217
|
+
}
|
|
218
|
+
export interface GatewayRouteFailedEvent {
|
|
219
|
+
type: "route-failed";
|
|
220
|
+
request: GatewayRequest;
|
|
221
|
+
timestamp: number;
|
|
222
|
+
attempts: GatewayAttempt[];
|
|
223
|
+
errorMessage: string;
|
|
224
|
+
}
|
|
225
|
+
export type GatewayEvent = GatewayAttemptStartedEvent | GatewayAttemptSucceededEvent | GatewayAttemptFailedEvent | GatewayAttemptRetriedEvent | GatewayTargetSkippedEvent | GatewayRouteSelectedEvent | GatewayTargetCooledDownEvent | GatewayRouteFailedEvent;
|
|
45
226
|
export interface GatewayResponse {
|
|
46
227
|
text: string;
|
|
47
228
|
finishReason?: GenerateTextOutput["finishReason"];
|
|
@@ -53,12 +234,7 @@ export interface GatewayResponse {
|
|
|
53
234
|
usage: TokenUsage & {
|
|
54
235
|
estimated: boolean;
|
|
55
236
|
};
|
|
56
|
-
routeDecision:
|
|
57
|
-
mode: GatewayRoutingMode;
|
|
58
|
-
intent: GatewayTaskIntent;
|
|
59
|
-
orderedTargets: GatewayModelTarget[];
|
|
60
|
-
reason: string;
|
|
61
|
-
};
|
|
237
|
+
routeDecision: GatewayRouteDecision;
|
|
62
238
|
steps: GenerateTextOutput["steps"];
|
|
63
239
|
messages: GenerateTextOutput["messages"];
|
|
64
240
|
toolResults: GenerateTextOutput["toolResults"];
|
|
@@ -81,21 +257,25 @@ export interface GatewayStreamObjectResult<TSchema extends ZodTypeAny> extends O
|
|
|
81
257
|
}
|
|
82
258
|
export interface GatewayConfig {
|
|
83
259
|
adapters: Partial<Record<GatewayProviderId, ProviderAdapter>>;
|
|
84
|
-
groundedAdapters?: Partial<Record<GatewayProviderId, Pick<ProviderAdapter, "groundedLanguageModel">>>;
|
|
85
260
|
modelCatalog?: ModelCatalog;
|
|
86
261
|
providerCostsPer1kTokens?: Partial<Record<GatewayProviderId, number>>;
|
|
87
262
|
latencyBiasMs?: Partial<Record<GatewayProviderId, number>>;
|
|
88
|
-
maxRetries?: number;
|
|
89
263
|
attemptTimeoutMs?: number;
|
|
90
264
|
attemptTimeoutsMs?: Partial<Record<GatewayProviderId, number>>;
|
|
265
|
+
runtimeStore?: GatewayRuntimeStore;
|
|
266
|
+
routerPolicy?: GatewayRouterPolicy;
|
|
267
|
+
retryPolicy?: GatewayRetryPolicy;
|
|
268
|
+
onAttempt?: (attempt: GatewayAttempt) => void | Promise<void>;
|
|
269
|
+
onEvent?: (event: GatewayEvent) => void | Promise<void>;
|
|
270
|
+
maxRetries?: number;
|
|
91
271
|
retryBackoffMs?: number;
|
|
92
|
-
|
|
93
|
-
retry: number;
|
|
94
|
-
targetRank: number;
|
|
95
|
-
}) => void | Promise<void>;
|
|
272
|
+
now?: () => number;
|
|
96
273
|
}
|
|
97
274
|
export declare class GatewayError extends Error {
|
|
98
275
|
readonly retryable: boolean;
|
|
99
276
|
constructor(message: string, retryable: boolean);
|
|
100
277
|
}
|
|
278
|
+
export declare const gatewayCapabilityKeys: readonly ["streaming", "tools", "structuredOutput", "jsonMode", "vision", "reasoning", "webSearch"];
|
|
279
|
+
export type GatewayCapabilityKey = (typeof gatewayCapabilityKeys)[number];
|
|
280
|
+
export declare const toCapabilityMismatch: (capabilities: ModelCapabilities, requiredCapabilities: GatewayRequiredCapabilities) => GatewayCapabilityKey[];
|
|
101
281
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,oBAAoB,EACpB,OAAO,EACR,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEtC,MAAM,MAAM,iBAAiB,GACzB,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AM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/D,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,qBAAa,YAAa,SAAQ,KAAK;IAGnC,QAAQ,CAAC,SAAS,EAAE,OAAO;gBAD3B,OAAO,EAAE,MAAM,EACN,SAAS,EAAE,OAAO;CAK9B;AAED,eAAO,MAAM,qBAAqB,qGAQmC,CAAC;AAEtE,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E,eAAO,MAAM,oBAAoB,GAC/B,cAAc,iBAAiB,EAC/B,sBAAsB,2BAA2B,KAChD,oBAAoB,EACkF,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -6,4 +6,14 @@ export class GatewayError extends Error {
|
|
|
6
6
|
this.name = "GatewayError";
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
+
export const gatewayCapabilityKeys = [
|
|
10
|
+
"streaming",
|
|
11
|
+
"tools",
|
|
12
|
+
"structuredOutput",
|
|
13
|
+
"jsonMode",
|
|
14
|
+
"vision",
|
|
15
|
+
"reasoning",
|
|
16
|
+
"webSearch"
|
|
17
|
+
];
|
|
18
|
+
export const toCapabilityMismatch = (capabilities, requiredCapabilities) => gatewayCapabilityKeys.filter((key) => requiredCapabilities[key] === true && capabilities[key] !== true);
|
|
9
19
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA2VA,MAAM,OAAO,YAAa,SAAQ,KAAK;IAG1B;IAFX,YACE,OAAe,EACN,SAAkB;QAE3B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,cAAS,GAAT,SAAS,CAAS;QAG3B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,WAAW;IACX,OAAO;IACP,kBAAkB;IAClB,UAAU;IACV,QAAQ;IACR,WAAW;IACX,WAAW;CACwD,CAAC;AAItE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,YAA+B,EAC/B,oBAAiD,EACzB,EAAE,CAC1B,qBAAqB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhivex-ai/gateway",
|
|
3
|
-
"version": "0.3.0",
|
|
3
|
+
"version": "0.3.1-next.0",
|
|
4
4
|
"description": "Routing and fallback helpers for Zhivex AI SDK.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,6 +41,6 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@zhivex-ai/core": "^0.
|
|
44
|
+
"@zhivex-ai/core": "^0.5.0-next.0"
|
|
45
45
|
}
|
|
46
46
|
}
|