@volter/twin-xai 0.1.0 → 0.1.1

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.
@@ -1,6 +1,7 @@
1
1
  // Server half of xAI's Grok Build device-authorization UI. This is protocol UI, not an
2
2
  // invented dashboard: it is served on the OAuth paths and coupled directly to the pending
3
3
  // device authorization projected from the Twin kernel.
4
+ import { worldNow } from '@volter/world-core';
4
5
  import { createElement } from 'react';
5
6
  import { renderToStaticMarkup } from 'react-dom/server';
6
7
  import { DeviceConsentPage, DeviceDonePage, DeviceEntryPage, XAI_DEVICE_PERMISSIONS, } from "../client/xai-device-auth.js";
@@ -33,7 +34,7 @@ export function xaiDeviceAuthView(userCode, root, error, nowAt) {
33
34
  const normalized = userCode.trim().toUpperCase().replace(/[^A-Z0-9-]/gu, '');
34
35
  const state = inspectXaiTwinDeviceAuthorization(normalized, root);
35
36
  let status = typeof state?.status === 'string' ? state.status : 'unknown';
36
- if (state?.expiresAt && Date.parse(String(state.expiresAt)) <= Date.parse(nowAt ?? new Date().toISOString()) && status === 'pending')
37
+ if (state?.expiresAt && Date.parse(String(state.expiresAt)) <= Date.parse(nowAt ?? worldNow()) && status === 'pending')
37
38
  status = 'expired';
38
39
  const supported = new Set(['pending', 'approved', 'denied', 'connected', 'expired', 'unknown']);
39
40
  const scopes = new Set(String(state?.scope ?? '').split(/\s+/u).filter(Boolean));
@@ -1,11 +1,11 @@
1
- import { applyTwinWrite, applyTwinWriteAtomic, projectResources } from '@volter/world-core';
1
+ import { applyTwinWrite, applyTwinWriteAtomic, projectResources, worldNow } from '@volter/world-core';
2
2
  const SERVICE = 'xai';
3
3
  const ACCOUNT_ID = 'acct_twin_grok';
4
4
  const DEFAULT_SCOPE = 'openid profile email offline_access grok-cli:access api:access conversations:read conversations:write workspaces:read workspaces:write';
5
5
  const ACCESS_TTL_SECONDS = 3_600;
6
6
  const DEVICE_TTL_SECONDS = 900;
7
7
  function at(occurredAt) {
8
- return new Date(occurredAt ?? new Date().toISOString());
8
+ return new Date(occurredAt ?? worldNow());
9
9
  }
10
10
  /** FNV-1a over the seed, widened by re-hashing with a round counter until `n` hex chars exist. */
11
11
  function stableHex(seed, n) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/twin-xai",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Local xAI (Grok) twin — a faithful, stateful local API plus the Grok Build device-OAuth browser surface. The model is stubbed (deterministic) and Live Search citations are labeled stubs, while the OAuth/account/usage world and API protocol envelopes remain coherent and vendor-shaped. Built on @volter/world-core.",
5
5
  "keywords": [
6
6
  "twin",
@@ -56,10 +56,10 @@
56
56
  "react-dom": "^19.2.7"
57
57
  },
58
58
  "peerDependencies": {
59
- "@volter/world-core": "2.0.0"
59
+ "@volter/world-core": "2.0.1"
60
60
  },
61
61
  "devDependencies": {
62
- "@volter/world-core": "2.0.0",
62
+ "@volter/world-core": "2.0.1",
63
63
  "@volter/world-tooling": "0.1.0",
64
64
  "@ai-sdk/xai": "^3.0.111",
65
65
  "ai": "^6.0.0",
@@ -1,6 +1,7 @@
1
1
  // Server half of xAI's Grok Build device-authorization UI. This is protocol UI, not an
2
2
  // invented dashboard: it is served on the OAuth paths and coupled directly to the pending
3
3
  // device authorization projected from the Twin kernel.
4
+ import { worldNow } from '@volter/world-core';
4
5
  import { createElement } from 'react';
5
6
  import { renderToStaticMarkup } from 'react-dom/server';
6
7
  import {
@@ -46,7 +47,7 @@ export function xaiDeviceAuthView(userCode: string, root?: string, error?: strin
46
47
  const normalized = userCode.trim().toUpperCase().replace(/[^A-Z0-9-]/gu, '');
47
48
  const state = inspectXaiTwinDeviceAuthorization(normalized, root);
48
49
  let status = typeof state?.status === 'string' ? state.status : 'unknown';
49
- if (state?.expiresAt && Date.parse(String(state.expiresAt)) <= Date.parse(nowAt ?? new Date().toISOString()) && status === 'pending') status = 'expired';
50
+ if (state?.expiresAt && Date.parse(String(state.expiresAt)) <= Date.parse(nowAt ?? worldNow()) && status === 'pending') status = 'expired';
50
51
  const supported = new Set<XaiDeviceAuthView['status']>(['pending', 'approved', 'denied', 'connected', 'expired', 'unknown']);
51
52
  const scopes = new Set(String(state?.scope ?? '').split(/\s+/u).filter(Boolean));
52
53
  const permissions = XAI_DEVICE_PERMISSIONS.filter((_, index) => [
package/src/xai-oauth.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { applyTwinWrite, applyTwinWriteAtomic, projectResources, type TwinResource } from '@volter/world-core';
1
+ import { applyTwinWrite, applyTwinWriteAtomic, projectResources, type TwinResource, worldNow } from '@volter/world-core';
2
2
 
3
3
  const SERVICE = 'xai';
4
4
  const ACCOUNT_ID = 'acct_twin_grok';
@@ -9,7 +9,7 @@ const DEVICE_TTL_SECONDS = 900;
9
9
  export type XaiOauthResult = { status: number; body: Record<string, unknown> };
10
10
 
11
11
  function at(occurredAt?: string): Date {
12
- return new Date(occurredAt ?? new Date().toISOString());
12
+ return new Date(occurredAt ?? worldNow());
13
13
  }
14
14
 
15
15
  /** FNV-1a over the seed, widened by re-hashing with a round counter until `n` hex chars exist. */