@vxil/sdk 0.2.0 → 0.3.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/dist/index.d.ts +57 -2
- package/dist/index.js +11 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type ApiVersion = 'v1';
|
|
|
8
8
|
* (`/v1/<namespace>/…`). Matches the segment `versionedPath` rewrites, so an
|
|
9
9
|
* override changes exactly that namespace's paths. Renamed client accessors map
|
|
10
10
|
* onto their real namespaces (`vx.search` → `search`, `vx.feeds` → `feeds`). */
|
|
11
|
-
export type FeatureKey = 'users' | 'notifications' | 'config' | 'features' | 'audit' | 'jobs' | 'auth' | 'rate-limits' | 'files' | 'cms' | 'comments' | 'dm' | 'feeds' | 'realtime' | 'orgs' | 'webhooks' | 'search' | 'ai' | 'rag' | 'payments' | 'fn' | 'copilot';
|
|
11
|
+
export type FeatureKey = 'users' | 'notifications' | 'config' | 'features' | 'audit' | 'usage' | 'jobs' | 'auth' | 'rate-limits' | 'files' | 'cms' | 'comments' | 'dm' | 'feeds' | 'realtime' | 'orgs' | 'webhooks' | 'search' | 'ai' | 'rag' | 'payments' | 'fn' | 'copilot';
|
|
12
12
|
export interface VxilOptions {
|
|
13
13
|
apiKey: string;
|
|
14
14
|
/** defaults to the production edge */
|
|
@@ -131,6 +131,33 @@ export interface VxilPlan {
|
|
|
131
131
|
/** which brain produced the plan. */
|
|
132
132
|
source: 'ai' | 'deterministic';
|
|
133
133
|
}
|
|
134
|
+
/** Current-month usage projection (GET /v1/usage) — the same meter the
|
|
135
|
+
* platform bills and enforces request quotas from. */
|
|
136
|
+
export interface UsageCurrent {
|
|
137
|
+
/** the current UTC month, 'YYYY-MM'. */
|
|
138
|
+
period: string;
|
|
139
|
+
/** the plan tier the quota is derived from. */
|
|
140
|
+
tier: string;
|
|
141
|
+
requests: {
|
|
142
|
+
/** requests recorded this month (0 until the meter has rows). */
|
|
143
|
+
used: number;
|
|
144
|
+
/** the plan's included monthly requests; null = no fixed cap. */
|
|
145
|
+
quota: number | null;
|
|
146
|
+
/** max(quota − used, 0); null when quota is null. */
|
|
147
|
+
remaining: number | null;
|
|
148
|
+
/** the PLAN's hard-cap policy — true only on the free tier (which is cut
|
|
149
|
+
* off with 429 quota_exceeded when exhausted); paid tiers are never
|
|
150
|
+
* interrupted mid-month. Not a live "the next request will 429" signal. */
|
|
151
|
+
enforced: boolean;
|
|
152
|
+
};
|
|
153
|
+
/** month-to-date per-feature metered detail. Aggregated periodically — it
|
|
154
|
+
* may lag and may be empty. */
|
|
155
|
+
features: Array<{
|
|
156
|
+
feature: string;
|
|
157
|
+
metric: string;
|
|
158
|
+
quantity: number;
|
|
159
|
+
}>;
|
|
160
|
+
}
|
|
134
161
|
export interface DeadLetter {
|
|
135
162
|
delivery_id: string;
|
|
136
163
|
template_id: string;
|
|
@@ -351,6 +378,12 @@ export interface AiGeneration {
|
|
|
351
378
|
usage: AiUsage;
|
|
352
379
|
finish: string;
|
|
353
380
|
tool_calls?: AiToolCall[];
|
|
381
|
+
/** the parsed JSON output — present when the request (or its template)
|
|
382
|
+
* carried a response schema; guaranteed to satisfy it (a 200 never violates
|
|
383
|
+
* the schema — final-invalid is a 422 output_schema_mismatch). */
|
|
384
|
+
output?: unknown;
|
|
385
|
+
/** true when the output only validated after the single repair pass. */
|
|
386
|
+
repaired?: boolean;
|
|
354
387
|
cached: boolean;
|
|
355
388
|
}
|
|
356
389
|
/** A streamed generation handle: open the realtime channel for token frames. */
|
|
@@ -1249,6 +1282,13 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
|
|
|
1249
1282
|
}>;
|
|
1250
1283
|
}>;
|
|
1251
1284
|
};
|
|
1285
|
+
/** Current-month usage: requests used vs the plan's included quota, plus
|
|
1286
|
+
* month-to-date per-feature metered detail. Read-only (needs `usage:read`
|
|
1287
|
+
* or `features:read`). Agents: call this before a bulk run to self-check
|
|
1288
|
+
* remaining quota. */
|
|
1289
|
+
readonly usage: {
|
|
1290
|
+
current: () => Promise<UsageCurrent>;
|
|
1291
|
+
};
|
|
1252
1292
|
readonly jobs: {
|
|
1253
1293
|
/** Enqueue a one-off job; Vxil POSTs a signed callback to target_url with
|
|
1254
1294
|
* retries. deliver_after (ISO) / delay_seconds (≤ 30 d, at most one of the
|
|
@@ -2730,7 +2770,10 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
|
|
|
2730
2770
|
readonly ai: {
|
|
2731
2771
|
templates: {
|
|
2732
2772
|
/** Store a tenant-authored prompt template; versions are monotonic per name.
|
|
2733
|
-
* `{{var}}` placeholders are filled from `generate`'s `input`.
|
|
2773
|
+
* `{{var}}` placeholders are filled from `generate`'s `input`.
|
|
2774
|
+
* `schema` (a JSON Schema) is now ENFORCED at generate time on sync/job
|
|
2775
|
+
* requests — the output is validated (with one repair pass) against it;
|
|
2776
|
+
* a per-request `response_schema` overrides it. Ignored on streams. */
|
|
2734
2777
|
put: (input: {
|
|
2735
2778
|
template: string;
|
|
2736
2779
|
user: string;
|
|
@@ -2772,6 +2815,13 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
|
|
|
2772
2815
|
* role:'tool' results) — vxil relays; you execute the tools. */
|
|
2773
2816
|
messages?: AiChatMessage[];
|
|
2774
2817
|
json_mode?: boolean;
|
|
2818
|
+
/** JSON Schema the completion must satisfy (schema-guaranteed structured
|
|
2819
|
+
* output): enforced natively where the provider supports strict
|
|
2820
|
+
* structured output, else via one validate-and-repair pass; the parsed
|
|
2821
|
+
* object lands in `output` (+`repaired` when the repair pass fired). A
|
|
2822
|
+
* still-invalid result is a 422 `output_schema_mismatch` (billed). Wins
|
|
2823
|
+
* over the template's stored schema. */
|
|
2824
|
+
response_schema?: Record<string, unknown>;
|
|
2775
2825
|
images?: string[];
|
|
2776
2826
|
user_id?: string;
|
|
2777
2827
|
}) => Promise<AiGeneration>;
|
|
@@ -2823,6 +2873,11 @@ export declare class Vxil<S extends VxilSchemaShape = VxilSchemaShape> {
|
|
|
2823
2873
|
}>;
|
|
2824
2874
|
messages?: AiChatMessage[];
|
|
2825
2875
|
json_mode?: boolean;
|
|
2876
|
+
/** JSON Schema the completion must satisfy — same contract as
|
|
2877
|
+
* `generate`; the validated answer lands in the replay buffer (a
|
|
2878
|
+
* schema-mismatch delivers finish:'schema_mismatch' on the terminal
|
|
2879
|
+
* usage frame). */
|
|
2880
|
+
response_schema?: Record<string, unknown>;
|
|
2826
2881
|
images?: string[];
|
|
2827
2882
|
user_id?: string;
|
|
2828
2883
|
}) => Promise<AiJobHandle>;
|
package/dist/index.js
CHANGED
|
@@ -429,6 +429,13 @@ export class Vxil {
|
|
|
429
429
|
};
|
|
430
430
|
},
|
|
431
431
|
};
|
|
432
|
+
/** Current-month usage: requests used vs the plan's included quota, plus
|
|
433
|
+
* month-to-date per-feature metered detail. Read-only (needs `usage:read`
|
|
434
|
+
* or `features:read`). Agents: call this before a bulk run to self-check
|
|
435
|
+
* remaining quota. */
|
|
436
|
+
usage = {
|
|
437
|
+
current: async () => (await this.call('GET', '/v1/usage')).data,
|
|
438
|
+
};
|
|
432
439
|
jobs = {
|
|
433
440
|
/** Enqueue a one-off job; Vxil POSTs a signed callback to target_url with
|
|
434
441
|
* retries. deliver_after (ISO) / delay_seconds (≤ 30 d, at most one of the
|
|
@@ -1190,7 +1197,10 @@ export class Vxil {
|
|
|
1190
1197
|
ai = {
|
|
1191
1198
|
templates: {
|
|
1192
1199
|
/** Store a tenant-authored prompt template; versions are monotonic per name.
|
|
1193
|
-
* `{{var}}` placeholders are filled from `generate`'s `input`.
|
|
1200
|
+
* `{{var}}` placeholders are filled from `generate`'s `input`.
|
|
1201
|
+
* `schema` (a JSON Schema) is now ENFORCED at generate time on sync/job
|
|
1202
|
+
* requests — the output is validated (with one repair pass) against it;
|
|
1203
|
+
* a per-request `response_schema` overrides it. Ignored on streams. */
|
|
1194
1204
|
put: async (input) => (await this.call('POST', '/v1/ai/templates', input)).data,
|
|
1195
1205
|
/** List stored templates (each name + its latest version). */
|
|
1196
1206
|
list: async () => (await this.call('GET', '/v1/ai/templates')).data.templates,
|
package/package.json
CHANGED