@ohoooho/taoxian-runtime-sdk 0.0.0-stage → 0.1.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.
@@ -0,0 +1,144 @@
1
+ export type FetchLike = (input: string, init?: any) => Promise<any>;
2
+
3
+ export interface RuntimeDescriptor {
4
+ url: string;
5
+ source?: 'env' | 'descriptor' | 'default';
6
+ port?: number;
7
+ host?: string;
8
+ pid?: number;
9
+ version?: string;
10
+ api_version?: number;
11
+ started_at?: string;
12
+ health_path?: string;
13
+ mobile_path?: string;
14
+ lan_urls?: string[];
15
+ lan_mobile_urls?: string[];
16
+ lan_enabled?: boolean;
17
+ descriptor_path?: string;
18
+ }
19
+
20
+ export interface RuntimeStatus {
21
+ ok: true;
22
+ url: string;
23
+ service: string;
24
+ version: string | null;
25
+ apiVersion: number | null;
26
+ pid: number | null;
27
+ startedAt: string | null;
28
+ host: string | null;
29
+ lanEnabled: boolean;
30
+ db: { ready: boolean; schemaVersion: number | null };
31
+ mcp: { servers: number };
32
+ }
33
+
34
+ export interface RuntimeClientOptions {
35
+ url?: string;
36
+ descriptor?: RuntimeDescriptor | null;
37
+ homeDir?: string;
38
+ env?: Record<string, string | undefined>;
39
+ timeoutMs?: number;
40
+ fetchImpl?: FetchLike;
41
+ }
42
+
43
+ export interface RuntimeRequestOptions extends RuntimeClientOptions {
44
+ token?: string;
45
+ headers?: Record<string, string>;
46
+ }
47
+
48
+ export interface LocalUser {
49
+ id: string;
50
+ username: string;
51
+ display_name: string | null;
52
+ logto_bound: boolean;
53
+ created_at: string;
54
+ updated_at: string;
55
+ }
56
+
57
+ export interface LocalSession {
58
+ session_token: string;
59
+ expires_at: string;
60
+ }
61
+
62
+ export interface LocalAuthStatus {
63
+ configured: boolean;
64
+ mode?: string;
65
+ api_key_issuer?: string;
66
+ logto_configured?: boolean;
67
+ }
68
+
69
+ export interface LocalApiKey {
70
+ id: string;
71
+ name: string;
72
+ key_prefix: string;
73
+ key_last4: string;
74
+ status: 'active' | 'revoked' | 'expired';
75
+ created_at: string;
76
+ expires_at: string | null;
77
+ revoked_at: string | null;
78
+ last_used_at: string | null;
79
+ use_count: number;
80
+ }
81
+
82
+ export interface FenshenRecord {
83
+ id: string;
84
+ database: string | null;
85
+ role: string | null;
86
+ dsn_env: string | null;
87
+ health_path: string | null;
88
+ process: Record<string, unknown> | null;
89
+ mcp: Record<string, unknown> | null;
90
+ ui: { url?: string; mobile_url?: string | null; label?: string | null } | null;
91
+ status: Record<string, string>;
92
+ created_at: string | null;
93
+ updated_at: string | null;
94
+ }
95
+
96
+ export class RuntimeUnavailableError extends Error {
97
+ code: 'runtime_unavailable';
98
+ cause?: unknown;
99
+ }
100
+ export class RuntimeIncompatibleError extends Error {
101
+ code: 'runtime_incompatible';
102
+ }
103
+ export class RuntimeApiError extends Error {
104
+ code: string;
105
+ status: number;
106
+ body: any;
107
+ }
108
+
109
+ export const RUNTIME_SERVICE_NAME: 'taoxian-runtime';
110
+ export const RUNTIME_API_VERSION: 1;
111
+ export const DEFAULT_RUNTIME_URL: string;
112
+ export const DEFAULT_RUNTIME_HOME: string;
113
+
114
+ export function compareRuntimeVersions(a: string, b: string): number | null;
115
+ export function runtimeDescriptorPath(options?: { homeDir?: string }): string;
116
+ export function readRuntimeDescriptor(options?: { homeDir?: string; env?: Record<string, string | undefined>; fsImpl?: any }): Promise<RuntimeDescriptor>;
117
+ export function getRuntimeStatus(options?: RuntimeClientOptions): Promise<RuntimeStatus>;
118
+ export function assertRuntimeCompatible(status: RuntimeStatus, options?: { minVersion?: string | null; apiVersion?: number | null }): RuntimeStatus;
119
+
120
+ export function initFenshen(payload: Record<string, unknown>, options?: RuntimeRequestOptions): Promise<any>;
121
+ export function listFenshens(options?: RuntimeClientOptions): Promise<FenshenRecord[]>;
122
+ export function getFenshen(id: string, options?: RuntimeClientOptions): Promise<FenshenRecord | null>;
123
+ export function listMcpServers(options?: RuntimeClientOptions): Promise<any[]>;
124
+
125
+ export function getLocalAuthStatus(options?: RuntimeClientOptions): Promise<LocalAuthStatus>;
126
+ export function setupLocalIdentity(payload: Record<string, unknown>, options?: RuntimeRequestOptions): Promise<{ ok: true; mode: string; user: LocalUser } & LocalSession>;
127
+ export function loginLocal(payload: Record<string, unknown>, options?: RuntimeRequestOptions): Promise<{ ok: true; mode: string; user: LocalUser } & LocalSession>;
128
+ export function logoutLocal(sessionToken: string, options?: RuntimeRequestOptions): Promise<{ ok: true; revoked: boolean }>;
129
+ export function getLocalUser(sessionToken: string, options?: RuntimeRequestOptions): Promise<{ ok: true; user: LocalUser; session: { id: string; expires_at: string } }>;
130
+ export function getLocalUserFromCookie(cookie: string, options?: RuntimeRequestOptions): Promise<{ ok: true; user: LocalUser; session: { id: string; expires_at: string } }>;
131
+ export function getMobileAccess(sessionToken: string, options?: RuntimeRequestOptions): Promise<any>;
132
+ export function createMobilePairing(sessionToken: string, payload?: { label?: string; ttl_seconds?: number }, options?: RuntimeRequestOptions): Promise<any>;
133
+ export function redeemMobilePairing(payload: { code: string }, options?: RuntimeRequestOptions): Promise<any>;
134
+
135
+ export function listLocalApiKeys(sessionToken: string, options?: RuntimeRequestOptions): Promise<LocalApiKey[]>;
136
+ export function createLocalApiKey(sessionToken: string, payload: Record<string, unknown>, options?: RuntimeRequestOptions): Promise<any>;
137
+ export function revokeLocalApiKey(sessionToken: string, id: string, options?: RuntimeRequestOptions): Promise<any>;
138
+ export function verifyLocalApiKey(key: string, options?: RuntimeRequestOptions & { serviceToken?: string }): Promise<any>;
139
+
140
+ export function startRuntime(options?: RuntimeClientOptions & { autoStart?: boolean; command?: string }): Promise<any>;
141
+ export function stopRuntime(options?: RuntimeClientOptions & { command?: string }): Promise<any>;
142
+ export function restartRuntime(options?: RuntimeClientOptions & { command?: string }): Promise<any>;
143
+ export function waitForRuntime(options?: RuntimeClientOptions & { timeoutMs?: number; intervalMs?: number }): Promise<RuntimeStatus>;
144
+ export function ensureRuntime(options?: RuntimeClientOptions & { autoStart?: boolean; minVersion?: string; command?: string }): Promise<RuntimeStatus>;