@tryvira/sdk 0.1.74 → 0.1.93

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 CHANGED
@@ -8,10 +8,14 @@ The official JavaScript and TypeScript client for Vira. Use it to connect an AI
8
8
  application, record observations, author governed behavior, evaluate changes, release
9
9
  approved behavior, and resolve it at runtime.
10
10
 
11
+ Organization owners and Billing Admins can inspect credits with `getAICreditWallet()` and `listAICreditBudgets()`. Rated provider usage is available through `listAIUsageReceipts({organizationUnitId, limit})` and monthly summaries through `getAIUsageSummary({organizationUnitId})`. Provider costs remain in their source currency minor units, separate from customer microcredits; the Control API enforces billing role and organization scope. Managed execution callers can reserve an approved upper bound with `reserveAICredits(...)` before provider invocation and release unused holds with `releaseAICreditReservation(...)`; both require organization billing authority and server-side budget admission.
12
+
13
+ Compound execution plans can be persisted with `saveCompoundTaskPlan(plan, {idempotencyKey})`, listed with `listCompoundTaskPlans({limit, cursor})`, and read by ID with `getCompoundTaskPlan(planId)`. These methods use the authenticated organization/project/environment scope; the server validates plan digest and tenant binding, and saving a plan does not execute it. A first save returns `201`; replaying the same plan returns `200` with `replayed: true`.
14
+
11
15
  ## Install
12
16
 
13
17
  ```bash
14
- npm install @tryvira/sdk@0.1.46
18
+ npm install @tryvira/sdk@0.1.92
15
19
  ```
16
20
 
17
21
  Configure the organization, project, and environment for every request. Keep the API
@@ -171,6 +175,7 @@ if (route.body.route !== "ROUTED") {
171
175
  }
172
176
 
173
177
  const admitted = await vira.startTaskRunFromPrompt({
178
+ aiSystemId: "ais_support_agent",
174
179
  input: "Prepare a customer report and send it for approval",
175
180
  budget: { maxChildren: 4, maxCalls: 6, maxCostMicros: 50000 },
176
181
  }, { idempotencyKey: "task-run:customer-report-request-001" });
@@ -208,6 +213,13 @@ const events = await vira.listTaskRunEvents("customer-report-run-001");
208
213
 
209
214
  - Send an idempotency key with mutations.
210
215
  - Treat `401`/`403` as credential or scope errors; do not retry blindly.
216
+
217
+ For host-managed OAuth, pass `accessTokenProvider: async () => token` to
218
+ `ViraClient`. The provider is called for each API request and its result is
219
+ sent only as `Authorization: Bearer`; keep refresh, expiry, and revocation
220
+ handling in the host's secure credential store. When configured, this provider
221
+ takes precedence over `apiKey`. Existing scoped API-key configuration remains
222
+ supported.
211
223
  - Treat a runtime deny or abstain as a governed decision, not permission to bypass Vira.
212
224
  - Persist request IDs and receipts with application logs for support and audit.
213
225
 
@@ -0,0 +1,23 @@
1
+ /**
2
+ * An MCP/OpenCode/customer-host observation is a report, NOT provider billing
3
+ * authority. Only the Vira-owned model egress / credit journal can produce a
4
+ * chargeable managed receipt. This contract intentionally cannot upgrade a
5
+ * host report to managed settlement, even with a reported provider request ID.
6
+ */
7
+ export declare const externalHostCommercialEvidence: Readonly<{
8
+ schemaVersion: 1;
9
+ chargeClass: "byok";
10
+ authority: "HOST_REPORTED_UNVERIFIED";
11
+ settlementStatus: "NOT_CHARGEABLE";
12
+ managedCreditEligible: false;
13
+ }>;
14
+ /** Keep observed model counters as signals, without granting spend authority. */
15
+ export declare function normalizeExternalHostCommercialPayload(eventType: string, value: unknown): unknown;
16
+ /** Must remain false for any host-origin observation, even if reported usage
17
+ * appears plausible or claims a verified provider request. */
18
+ export declare function isManagedHostUsageChargeable(_value: unknown): false;
19
+ /** Called only after the original unredacted host report has been validated.
20
+ * Server privacy minimization masks strings, including submitted 'byok'.
21
+ * Reattest with server-owned constants AFTER minimization, never trust
22
+ * redacted client metadata as an authority claim. */
23
+ export declare function sealSanitizedExternalHostCommercialPayload(eventType: string, sanitized: unknown): unknown;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
- export * from "./js-client.js";
2
- export * from "./framework-adapters.js";
3
- export * from "./host-lifecycle.js";
1
+ export * from "./sdks/js-client.js";
2
+ export * from "./sdks/framework-adapters.js";
3
+ export * from "./sdks/host-lifecycle.js";
4
+ export * from "./sdks/host-completion.js";
5
+ export * from "./sdks/host-completion-postgres.js";
6
+ export * from "./sdks/host-completion-adapters.js";