@hypercli.com/sdk 0.9.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.
- package/README.md +629 -0
- package/dist/acp-driver.d.ts +72 -0
- package/dist/acp-driver.d.ts.map +1 -0
- package/dist/acp-driver.js +147 -0
- package/dist/acp-driver.js.map +1 -0
- package/dist/acp-pool.d.ts +70 -0
- package/dist/acp-pool.d.ts.map +1 -0
- package/dist/acp-pool.js +181 -0
- package/dist/acp-pool.js.map +1 -0
- package/dist/acp.d.ts +179 -0
- package/dist/acp.d.ts.map +1 -0
- package/dist/acp.js +487 -0
- package/dist/acp.js.map +1 -0
- package/dist/agent-persona.d.ts +68 -0
- package/dist/agent-persona.d.ts.map +1 -0
- package/dist/agent-persona.js +78 -0
- package/dist/agent-persona.js.map +1 -0
- package/dist/agent-slots.d.ts +18 -0
- package/dist/agent-slots.d.ts.map +1 -0
- package/dist/agent-slots.js +24 -0
- package/dist/agent-slots.js.map +1 -0
- package/dist/agent-urls.d.ts +47 -0
- package/dist/agent-urls.d.ts.map +1 -0
- package/dist/agent-urls.js +178 -0
- package/dist/agent-urls.js.map +1 -0
- package/dist/agent.d.ts +482 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +926 -0
- package/dist/agent.js.map +1 -0
- package/dist/agents.d.ts +1452 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +4022 -0
- package/dist/agents.js.map +1 -0
- package/dist/billing.d.ts +72 -0
- package/dist/billing.d.ts.map +1 -0
- package/dist/billing.js +93 -0
- package/dist/billing.js.map +1 -0
- package/dist/browser-jobs.d.ts +24 -0
- package/dist/browser-jobs.d.ts.map +1 -0
- package/dist/browser-jobs.js +209 -0
- package/dist/browser-jobs.js.map +1 -0
- package/dist/browser.d.ts +41 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +57 -0
- package/dist/browser.js.map +1 -0
- package/dist/buzz-activity.d.ts +169 -0
- package/dist/buzz-activity.d.ts.map +1 -0
- package/dist/buzz-activity.js +844 -0
- package/dist/buzz-activity.js.map +1 -0
- package/dist/channels.d.ts +99 -0
- package/dist/channels.d.ts.map +1 -0
- package/dist/channels.js +27 -0
- package/dist/channels.js.map +1 -0
- package/dist/chat-integrations.d.ts +44 -0
- package/dist/chat-integrations.d.ts.map +1 -0
- package/dist/chat-integrations.js +138 -0
- package/dist/chat-integrations.js.map +1 -0
- package/dist/client.d.ts +88 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +144 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +44 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +192 -0
- package/dist/config.js.map +1 -0
- package/dist/connectors.d.ts +80 -0
- package/dist/connectors.d.ts.map +1 -0
- package/dist/connectors.js +2 -0
- package/dist/connectors.js.map +1 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +26 -0
- package/dist/errors.js.map +1 -0
- package/dist/files.d.ts +60 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +128 -0
- package/dist/files.js.map +1 -0
- package/dist/http.d.ts +56 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +362 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/instances.d.ts +94 -0
- package/dist/instances.d.ts.map +1 -0
- package/dist/instances.js +197 -0
- package/dist/instances.js.map +1 -0
- package/dist/integrations.d.ts +111 -0
- package/dist/integrations.d.ts.map +1 -0
- package/dist/integrations.js +206 -0
- package/dist/integrations.js.map +1 -0
- package/dist/job/base.d.ts +86 -0
- package/dist/job/base.d.ts.map +1 -0
- package/dist/job/base.js +206 -0
- package/dist/job/base.js.map +1 -0
- package/dist/job/comfyui.d.ts +259 -0
- package/dist/job/comfyui.d.ts.map +1 -0
- package/dist/job/comfyui.js +1563 -0
- package/dist/job/comfyui.js.map +1 -0
- package/dist/job/gradio.d.ts +48 -0
- package/dist/job/gradio.d.ts.map +1 -0
- package/dist/job/gradio.js +90 -0
- package/dist/job/gradio.js.map +1 -0
- package/dist/job-codecs.d.ts +66 -0
- package/dist/job-codecs.d.ts.map +1 -0
- package/dist/job-codecs.js +132 -0
- package/dist/job-codecs.js.map +1 -0
- package/dist/jobs.d.ts +148 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +480 -0
- package/dist/jobs.js.map +1 -0
- package/dist/keys.d.ts +99 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +145 -0
- package/dist/keys.js.map +1 -0
- package/dist/logs.d.ts +54 -0
- package/dist/logs.d.ts.map +1 -0
- package/dist/logs.js +256 -0
- package/dist/logs.js.map +1 -0
- package/dist/managed-context.d.ts +20 -0
- package/dist/managed-context.d.ts.map +1 -0
- package/dist/managed-context.js +95 -0
- package/dist/managed-context.js.map +1 -0
- package/dist/mcp.d.ts +7 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +8 -0
- package/dist/mcp.js.map +1 -0
- package/dist/memory.d.ts +87 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +79 -0
- package/dist/memory.js.map +1 -0
- package/dist/models.d.ts +15 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +19 -0
- package/dist/models.js.map +1 -0
- package/dist/openclaw-control-ui-origin.d.ts +23 -0
- package/dist/openclaw-control-ui-origin.d.ts.map +1 -0
- package/dist/openclaw-control-ui-origin.js +53 -0
- package/dist/openclaw-control-ui-origin.js.map +1 -0
- package/dist/renders.d.ts +187 -0
- package/dist/renders.d.ts.map +1 -0
- package/dist/renders.js +360 -0
- package/dist/renders.js.map +1 -0
- package/dist/routines.d.ts +59 -0
- package/dist/routines.d.ts.map +1 -0
- package/dist/routines.js +135 -0
- package/dist/routines.js.map +1 -0
- package/dist/runners.d.ts +61 -0
- package/dist/runners.d.ts.map +1 -0
- package/dist/runners.js +127 -0
- package/dist/runners.js.map +1 -0
- package/dist/sessions.d.ts +280 -0
- package/dist/sessions.d.ts.map +1 -0
- package/dist/sessions.js +292 -0
- package/dist/sessions.js.map +1 -0
- package/dist/skills.d.ts +170 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +2 -0
- package/dist/skills.js.map +1 -0
- package/dist/user.d.ts +78 -0
- package/dist/user.d.ts.map +1 -0
- package/dist/user.js +143 -0
- package/dist/user.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/dist/voice-session.d.ts +66 -0
- package/dist/voice-session.d.ts.map +1 -0
- package/dist/voice-session.js +366 -0
- package/dist/voice-session.js.map +1 -0
- package/dist/voice-transcription-session.d.ts +64 -0
- package/dist/voice-transcription-session.d.ts.map +1 -0
- package/dist/voice-transcription-session.js +228 -0
- package/dist/voice-transcription-session.js.map +1 -0
- package/dist/voice.d.ts +62 -0
- package/dist/voice.d.ts.map +1 -0
- package/dist/voice.js +134 -0
- package/dist/voice.js.map +1 -0
- package/dist/workspace-tomd.d.ts +61 -0
- package/dist/workspace-tomd.d.ts.map +1 -0
- package/dist/workspace-tomd.js +177 -0
- package/dist/workspace-tomd.js.map +1 -0
- package/dist/workspaces.d.ts +255 -0
- package/dist/workspaces.d.ts.map +1 -0
- package/dist/workspaces.js +653 -0
- package/dist/workspaces.js.map +1 -0
- package/package.json +115 -0
- package/runtime/config-require.browser.js +4 -0
- package/runtime/config-require.d.ts +2 -0
- package/runtime/config-require.node.js +8 -0
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DEFAULT_AGENTS_API_BASE_URL, DEFAULT_AGENTS_WS_URL, DEV_AGENTS_API_BASE_URL, DEV_AGENTS_WS_URL } from './agent-urls.js';
|
|
2
|
+
export declare const DEFAULT_API_URL = "https://api.hypercli.com";
|
|
3
|
+
export { DEFAULT_AGENTS_API_BASE_URL, DEFAULT_AGENTS_WS_URL, DEV_AGENTS_API_BASE_URL, DEV_AGENTS_WS_URL, };
|
|
4
|
+
export declare const WS_LOGS_PATH = "/orchestra/ws/logs";
|
|
5
|
+
export declare const COMFYUI_IMAGE = "ghcr.io/compute3ai/images/comfyui";
|
|
6
|
+
/**
|
|
7
|
+
* Get config value: env var > config file > default
|
|
8
|
+
*/
|
|
9
|
+
export declare function getConfigValue(key: string, defaultValue?: string): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Get API key from env or config file
|
|
12
|
+
*/
|
|
13
|
+
export declare function getApiKey(): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Get the user-selected key, falling back to the managed runtime token.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAgentApiKey(): string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Get API URL
|
|
20
|
+
*/
|
|
21
|
+
export declare function getApiUrl(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Get WebSocket URL, derived from the product API URL
|
|
24
|
+
*/
|
|
25
|
+
export declare function getWsUrl(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Resolve Agents independently, falling back to the selected product base.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getAgentsApiBaseUrl(dev?: boolean, productBase?: string): string;
|
|
30
|
+
export declare function getAgentsApiBaseUrlFromProductBase(productBase: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Derive the agents admin API base (service-key surface) from a product API base
|
|
33
|
+
*/
|
|
34
|
+
export declare function getAgentsAdminApiBaseUrlFromProductBase(productBase: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Get HyperClaw agents WebSocket URL, derived from the agents API base
|
|
37
|
+
*/
|
|
38
|
+
export declare function getAgentsWsUrl(dev?: boolean): string;
|
|
39
|
+
export declare function getAgentsWsUrlFromProductBase(productBase: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Save configuration to ~/.hypercli/config
|
|
42
|
+
*/
|
|
43
|
+
export declare function configure(apiKey: string, apiUrl?: string): void;
|
|
44
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,2BAA2B,EAC3B,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EAElB,MAAM,iBAAiB,CAAC;AAmBzB,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAG1D,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,GAClB,CAAC;AACF,eAAO,MAAM,YAAY,uBAAuB,CAAC;AAIjD,eAAO,MAAM,aAAa,sCAA2B,CAAC;AAkDtD;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAerF;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAO9C;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,SAAS,CAGnD;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,MAAM,CAGjC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,OAAe,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAYtF;AAED,wBAAgB,kCAAkC,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED;;GAEG;AACH,wBAAgB,uCAAuC,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEnF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,GAAE,OAAe,GAAG,MAAM,CAE3D;AAED,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GACd,IAAI,CAmCN"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration handling for HyperCLI SDK
|
|
3
|
+
* Priority: env vars > config file > defaults
|
|
4
|
+
*/
|
|
5
|
+
import { getNodeRequire } from '#config-require';
|
|
6
|
+
import { agentsAdminApiBaseFromProductBase, defaultAgentsWsUrl, DEFAULT_AGENTS_API_BASE_URL, DEFAULT_AGENTS_WS_URL, DEV_AGENTS_API_BASE_URL, DEV_AGENTS_WS_URL, resolveAgentsApiBase, } from './agent-urls.js';
|
|
7
|
+
function getNodeConfigPaths() {
|
|
8
|
+
const req = getNodeRequire();
|
|
9
|
+
if (!req)
|
|
10
|
+
return null;
|
|
11
|
+
try {
|
|
12
|
+
const { homedir } = req('os');
|
|
13
|
+
const { join } = req('path');
|
|
14
|
+
const hyperHome = readEnvValue('HYPER_HOME')?.trim();
|
|
15
|
+
const configDir = hyperHome || join(homedir(), '.hypercli');
|
|
16
|
+
return {
|
|
17
|
+
configDir,
|
|
18
|
+
configFile: join(configDir, 'config'),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const DEFAULT_API_URL = 'https://api.hypercli.com';
|
|
26
|
+
// The agents defaults live in agent-urls.ts (single source for derivation);
|
|
27
|
+
// re-exported here for SDK surface compatibility.
|
|
28
|
+
export { DEFAULT_AGENTS_API_BASE_URL, DEFAULT_AGENTS_WS_URL, DEV_AGENTS_API_BASE_URL, DEV_AGENTS_WS_URL, };
|
|
29
|
+
export const WS_LOGS_PATH = '/orchestra/ws/logs'; // WebSocket path for job logs
|
|
30
|
+
// GHCR images
|
|
31
|
+
const GHCR_IMAGES = 'ghcr.io/compute3ai/images';
|
|
32
|
+
export const COMFYUI_IMAGE = `${GHCR_IMAGES}/comfyui`;
|
|
33
|
+
/**
|
|
34
|
+
* Load config from the active HyperCLI data directory.
|
|
35
|
+
*/
|
|
36
|
+
function loadConfigFile() {
|
|
37
|
+
const config = {};
|
|
38
|
+
const req = getNodeRequire();
|
|
39
|
+
if (!req) {
|
|
40
|
+
return config;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const paths = getNodeConfigPaths();
|
|
44
|
+
if (!paths) {
|
|
45
|
+
return config;
|
|
46
|
+
}
|
|
47
|
+
const { existsSync, readFileSync } = req('fs');
|
|
48
|
+
if (!existsSync(paths.configFile)) {
|
|
49
|
+
return config;
|
|
50
|
+
}
|
|
51
|
+
const content = readFileSync(paths.configFile, 'utf-8');
|
|
52
|
+
for (const line of content.split('\n')) {
|
|
53
|
+
const trimmed = line.trim();
|
|
54
|
+
if (trimmed && !trimmed.startsWith('#') && trimmed.includes('=')) {
|
|
55
|
+
const normalized = trimmed.startsWith('export ') ? trimmed.slice('export '.length).trim() : trimmed;
|
|
56
|
+
const [key, ...valueParts] = normalized.split('=');
|
|
57
|
+
const value = valueParts.join('=').trim();
|
|
58
|
+
config[key.trim()] = ((value.startsWith('"') && value.endsWith('"')) ||
|
|
59
|
+
(value.startsWith("'") && value.endsWith("'"))) ? value.slice(1, -1) : value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Ignore read errors
|
|
65
|
+
}
|
|
66
|
+
return config;
|
|
67
|
+
}
|
|
68
|
+
function readEnvValue(key) {
|
|
69
|
+
if (typeof process === 'undefined' || !process?.env) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
return process.env[key];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get config value: env var > config file > default
|
|
76
|
+
*/
|
|
77
|
+
export function getConfigValue(key, defaultValue) {
|
|
78
|
+
// Try environment variable first
|
|
79
|
+
const envVal = readEnvValue(key);
|
|
80
|
+
if (envVal) {
|
|
81
|
+
return envVal;
|
|
82
|
+
}
|
|
83
|
+
// Try config file
|
|
84
|
+
const config = loadConfigFile();
|
|
85
|
+
const fileVal = config[key];
|
|
86
|
+
if (fileVal) {
|
|
87
|
+
return fileVal;
|
|
88
|
+
}
|
|
89
|
+
return defaultValue;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get API key from env or config file
|
|
93
|
+
*/
|
|
94
|
+
export function getApiKey() {
|
|
95
|
+
const envKey = readEnvValue('HYPER_API_KEY')?.trim();
|
|
96
|
+
if (envKey) {
|
|
97
|
+
return envKey;
|
|
98
|
+
}
|
|
99
|
+
const config = loadConfigFile();
|
|
100
|
+
return config.HYPER_API_KEY || undefined;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get the user-selected key, falling back to the managed runtime token.
|
|
104
|
+
*/
|
|
105
|
+
export function getAgentApiKey() {
|
|
106
|
+
const agentEnvKey = readEnvValue('HYPER_AGENTS_API_KEY')?.trim();
|
|
107
|
+
return getApiKey() || agentEnvKey || undefined;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get API URL
|
|
111
|
+
*/
|
|
112
|
+
export function getApiUrl() {
|
|
113
|
+
return getConfigValue('HYPER_API_BASE') || DEFAULT_API_URL;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get WebSocket URL, derived from the product API URL
|
|
117
|
+
*/
|
|
118
|
+
export function getWsUrl() {
|
|
119
|
+
const apiUrl = getApiUrl();
|
|
120
|
+
return apiUrl.replace('https://', 'wss://').replace('http://', 'ws://');
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Resolve Agents independently, falling back to the selected product base.
|
|
124
|
+
*/
|
|
125
|
+
export function getAgentsApiBaseUrl(dev = false, productBase) {
|
|
126
|
+
const fallback = dev ? DEV_AGENTS_API_BASE_URL : DEFAULT_AGENTS_API_BASE_URL;
|
|
127
|
+
if (dev) {
|
|
128
|
+
return fallback;
|
|
129
|
+
}
|
|
130
|
+
const agentsBase = getConfigValue('HYPER_AGENTS_API_BASE');
|
|
131
|
+
if (agentsBase)
|
|
132
|
+
return resolveAgentsApiBase(agentsBase, true);
|
|
133
|
+
const configuredBase = productBase || getConfigValue('HYPER_API_BASE');
|
|
134
|
+
if (configuredBase) {
|
|
135
|
+
return resolveAgentsApiBase(configuredBase);
|
|
136
|
+
}
|
|
137
|
+
return fallback;
|
|
138
|
+
}
|
|
139
|
+
export function getAgentsApiBaseUrlFromProductBase(productBase) {
|
|
140
|
+
return resolveAgentsApiBase(productBase);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Derive the agents admin API base (service-key surface) from a product API base
|
|
144
|
+
*/
|
|
145
|
+
export function getAgentsAdminApiBaseUrlFromProductBase(productBase) {
|
|
146
|
+
return agentsAdminApiBaseFromProductBase(productBase);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get HyperClaw agents WebSocket URL, derived from the agents API base
|
|
150
|
+
*/
|
|
151
|
+
export function getAgentsWsUrl(dev = false) {
|
|
152
|
+
return defaultAgentsWsUrl(getAgentsApiBaseUrl(dev));
|
|
153
|
+
}
|
|
154
|
+
export function getAgentsWsUrlFromProductBase(productBase) {
|
|
155
|
+
return defaultAgentsWsUrl(getAgentsApiBaseUrlFromProductBase(productBase));
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Save configuration to ~/.hypercli/config
|
|
159
|
+
*/
|
|
160
|
+
export function configure(apiKey, apiUrl) {
|
|
161
|
+
const req = getNodeRequire();
|
|
162
|
+
if (!req) {
|
|
163
|
+
throw new Error('configure() is only available in Node.js environments');
|
|
164
|
+
}
|
|
165
|
+
const paths = getNodeConfigPaths();
|
|
166
|
+
if (!paths) {
|
|
167
|
+
throw new Error('configure() is only available in Node.js environments');
|
|
168
|
+
}
|
|
169
|
+
const { existsSync, writeFileSync, mkdirSync, chmodSync } = req('fs');
|
|
170
|
+
// Create directory if it doesn't exist
|
|
171
|
+
if (!existsSync(paths.configDir)) {
|
|
172
|
+
mkdirSync(paths.configDir, { recursive: true });
|
|
173
|
+
}
|
|
174
|
+
// Load existing config
|
|
175
|
+
const config = loadConfigFile();
|
|
176
|
+
// Update values
|
|
177
|
+
config['HYPER_API_KEY'] = apiKey;
|
|
178
|
+
if (apiUrl) {
|
|
179
|
+
config['HYPER_API_BASE'] = apiUrl;
|
|
180
|
+
}
|
|
181
|
+
// Write config file
|
|
182
|
+
const lines = Object.entries(config).map(([k, v]) => `${k}=${v}`);
|
|
183
|
+
writeFileSync(paths.configFile, lines.join('\n') + '\n', 'utf-8');
|
|
184
|
+
// Set permissions to 0600 (owner read/write only)
|
|
185
|
+
try {
|
|
186
|
+
chmodSync(paths.configFile, 0o600);
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
// Ignore permission errors (Windows doesn't support chmod)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,iCAAiC,EACjC,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,SAAS,kBAAkB;IACzB,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAC7B,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,IAAI,CAAC;QACH,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,IAAI,CAAwB,CAAC;QACrD,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,MAAM,CAA0B,CAAC;QACtD,MAAM,SAAS,GAAG,YAAY,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC;QACrD,MAAM,SAAS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AC,CAAC;IAC3E,CAAC;IACD,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,IAAI,CAAwB,CAAC;IAE7F,uCAAuC;IACvC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QACjC,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,uBAAuB;IACvB,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAEhC,gBAAgB;IAChB,MAAM,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC;IACjC,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,CAAC,gBAAgB,CAAC,GAAG,MAAM,CAAC;IACpC,CAAC;IAED,oBAAoB;IACpB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClE,aAAa,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;IAElE,kDAAkD;IAClD,IAAI,CAAC;QACH,SAAS,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,2DAA2D;IAC7D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export * from './chat-integrations.js';
|
|
2
|
+
export type AgentConnectorSetupMode = 'managed-auth' | 'config';
|
|
3
|
+
export type AgentConnectorAuthorizationProtocol = 'short-code';
|
|
4
|
+
export interface AgentRuntimeDescriptor {
|
|
5
|
+
provider: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
protocol?: string;
|
|
8
|
+
image?: string;
|
|
9
|
+
schemaVersion?: string;
|
|
10
|
+
capabilities: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
export interface AgentConnectorDescriptor {
|
|
13
|
+
connectorId: string;
|
|
14
|
+
configured: boolean;
|
|
15
|
+
authenticated: boolean;
|
|
16
|
+
usable: boolean;
|
|
17
|
+
setupModes: AgentConnectorSetupMode[];
|
|
18
|
+
}
|
|
19
|
+
export interface AgentConnectorListOptions {
|
|
20
|
+
connectorId?: string;
|
|
21
|
+
probe?: boolean;
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
}
|
|
24
|
+
export interface AgentConnectorSetupRequest {
|
|
25
|
+
connectorId: string;
|
|
26
|
+
mode?: AgentConnectorSetupMode;
|
|
27
|
+
accountId?: string;
|
|
28
|
+
scopes?: string[];
|
|
29
|
+
force?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface AgentConnectorRuntimeSetupResult {
|
|
32
|
+
connectorId: string;
|
|
33
|
+
mode: AgentConnectorSetupMode;
|
|
34
|
+
setupId?: string;
|
|
35
|
+
instructions?: string;
|
|
36
|
+
deviceUrl?: string;
|
|
37
|
+
deviceCode?: string;
|
|
38
|
+
expiresAt?: string | number;
|
|
39
|
+
pollIntervalMs?: number;
|
|
40
|
+
scopes?: string[];
|
|
41
|
+
provenance: AgentRuntimeDescriptor;
|
|
42
|
+
}
|
|
43
|
+
export type AgentConnectorSetupState = 'pending' | 'complete' | 'failed' | 'unknown';
|
|
44
|
+
export interface AgentConnectorSetupStatus {
|
|
45
|
+
connectorId: string;
|
|
46
|
+
setupId: string;
|
|
47
|
+
state: AgentConnectorSetupState;
|
|
48
|
+
connectionId?: string;
|
|
49
|
+
accountId?: string;
|
|
50
|
+
accountDisplayName?: string;
|
|
51
|
+
scopes?: string[];
|
|
52
|
+
error?: string;
|
|
53
|
+
provenance: AgentRuntimeDescriptor;
|
|
54
|
+
}
|
|
55
|
+
export interface AgentConnectorSetupStatusRequest {
|
|
56
|
+
connectorId: string;
|
|
57
|
+
setupId: string;
|
|
58
|
+
accountId?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface AgentConnectorAuthorizationRequest {
|
|
61
|
+
connectorId: string;
|
|
62
|
+
protocol: AgentConnectorAuthorizationProtocol;
|
|
63
|
+
code: string;
|
|
64
|
+
accountId?: string;
|
|
65
|
+
notify?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface AgentConnectorAuthorizationResult {
|
|
68
|
+
connectorId: string;
|
|
69
|
+
protocol: AgentConnectorAuthorizationProtocol;
|
|
70
|
+
state: 'complete';
|
|
71
|
+
}
|
|
72
|
+
export interface AgentConnectorsProvider {
|
|
73
|
+
readonly runtime: AgentRuntimeDescriptor;
|
|
74
|
+
list(options?: AgentConnectorListOptions): Promise<AgentConnectorDescriptor[]>;
|
|
75
|
+
startSetup(request: AgentConnectorSetupRequest): Promise<AgentConnectorRuntimeSetupResult>;
|
|
76
|
+
pollSetup(request: AgentConnectorSetupStatusRequest): Promise<AgentConnectorSetupStatus>;
|
|
77
|
+
configure(connectorId: string, config: Record<string, unknown>, accountId?: string): Promise<void>;
|
|
78
|
+
approveAuthorization?(request: AgentConnectorAuthorizationRequest): Promise<AgentConnectorAuthorizationResult>;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=connectors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectors.d.ts","sourceRoot":"","sources":["../src/connectors.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AAEvC,MAAM,MAAM,uBAAuB,GAAG,cAAc,GAAG,QAAQ,CAAC;AAChE,MAAM,MAAM,mCAAmC,GAAG,YAAY,CAAC;AAE/D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,C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@
|
|
|
1
|
+
{"version":3,"file":"connectors.js","sourceRoot":"","sources":["../src/connectors.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API error with status code and detail message
|
|
3
|
+
*/
|
|
4
|
+
export declare class APIError extends Error {
|
|
5
|
+
readonly statusCode: number;
|
|
6
|
+
readonly detail: string;
|
|
7
|
+
readonly method?: string | undefined;
|
|
8
|
+
readonly url?: string | undefined;
|
|
9
|
+
readonly responseText?: string | undefined;
|
|
10
|
+
/** Parsed Retry-After response header (delta-seconds), when the server sent one. */
|
|
11
|
+
readonly retryAfterSeconds?: number | undefined;
|
|
12
|
+
constructor(statusCode: number, detail: string, method?: string | undefined, url?: string | undefined, responseText?: string | undefined,
|
|
13
|
+
/** Parsed Retry-After response header (delta-seconds), when the server sent one. */
|
|
14
|
+
retryAfterSeconds?: number | undefined);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;aAEf,UAAU,EAAE,MAAM;aAClB,MAAM,EAAE,MAAM;aACd,MAAM,CAAC,EAAE,MAAM;aACf,GAAG,CAAC,EAAE,MAAM;aACZ,YAAY,CAAC,EAAE,MAAM;IACrC,oFAAoF;aACpE,iBAAiB,CAAC,EAAE,MAAM;gBAN1B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,GAAG,CAAC,EAAE,MAAM,YAAA,EACZ,YAAY,CAAC,EAAE,MAAM,YAAA;IACrC,oFAAoF;IACpE,iBAAiB,CAAC,EAAE,MAAM,YAAA;CAO7C"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API error with status code and detail message
|
|
3
|
+
*/
|
|
4
|
+
export class APIError extends Error {
|
|
5
|
+
statusCode;
|
|
6
|
+
detail;
|
|
7
|
+
method;
|
|
8
|
+
url;
|
|
9
|
+
responseText;
|
|
10
|
+
retryAfterSeconds;
|
|
11
|
+
constructor(statusCode, detail, method, url, responseText,
|
|
12
|
+
/** Parsed Retry-After response header (delta-seconds), when the server sent one. */
|
|
13
|
+
retryAfterSeconds) {
|
|
14
|
+
const context = [method, url].filter(Boolean).join(' ');
|
|
15
|
+
super(`API Error ${statusCode}${context ? ` (${context})` : ''}: ${detail}`);
|
|
16
|
+
this.statusCode = statusCode;
|
|
17
|
+
this.detail = detail;
|
|
18
|
+
this.method = method;
|
|
19
|
+
this.url = url;
|
|
20
|
+
this.responseText = responseText;
|
|
21
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
22
|
+
this.name = 'APIError';
|
|
23
|
+
Object.setPrototypeOf(this, APIError.prototype);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAEf;IACA;IACA;IACA;IACA;IAEA;IAPlB,YACkB,UAAkB,EAClB,MAAc,EACd,MAAe,EACf,GAAY,EACZ,YAAqB;IACrC,oFAAoF;IACpE,iBAA0B;QAE1C,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxD,KAAK,CAAC,aAAa,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC,CAAC;QAT7D,eAAU,GAAV,UAAU,CAAQ;QAClB,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAS;QACf,QAAG,GAAH,GAAG,CAAS;QACZ,iBAAY,GAAZ,YAAY,CAAS;QAErB,sBAAiB,GAAjB,iBAAiB,CAAS;QAI1C,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;CACF"}
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Files API - upload assets for use in renders
|
|
3
|
+
*/
|
|
4
|
+
import type { HTTPClient } from './http.js';
|
|
5
|
+
export interface File {
|
|
6
|
+
id: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
filename: string;
|
|
9
|
+
contentType: string;
|
|
10
|
+
fileSize: number;
|
|
11
|
+
url: string;
|
|
12
|
+
state: string | null;
|
|
13
|
+
error: string | null;
|
|
14
|
+
createdAt: string | null;
|
|
15
|
+
}
|
|
16
|
+
export declare class Files {
|
|
17
|
+
private http;
|
|
18
|
+
constructor(http: HTTPClient);
|
|
19
|
+
/**
|
|
20
|
+
* Upload a file for use in renders
|
|
21
|
+
*/
|
|
22
|
+
upload(filePath: string): Promise<File>;
|
|
23
|
+
/**
|
|
24
|
+
* Upload file bytes directly
|
|
25
|
+
*/
|
|
26
|
+
uploadBytes(content: Buffer, filename: string, contentType: string): Promise<File>;
|
|
27
|
+
/**
|
|
28
|
+
* Upload a file from a URL (async backend processing)
|
|
29
|
+
*/
|
|
30
|
+
uploadUrl(url: string, path?: string): Promise<File>;
|
|
31
|
+
/**
|
|
32
|
+
* Upload a file from base64-encoded data (async backend processing)
|
|
33
|
+
*/
|
|
34
|
+
uploadB64(data: string, filename: string, contentType?: string, path?: string): Promise<File>;
|
|
35
|
+
/**
|
|
36
|
+
* Get file metadata and URL
|
|
37
|
+
*/
|
|
38
|
+
get(fileId: string): Promise<File>;
|
|
39
|
+
/**
|
|
40
|
+
* Delete an uploaded file
|
|
41
|
+
*/
|
|
42
|
+
delete(fileId: string): Promise<any>;
|
|
43
|
+
/**
|
|
44
|
+
* Wait for an async upload to complete
|
|
45
|
+
*/
|
|
46
|
+
waitReady(fileId: string, timeout?: number, pollInterval?: number): Promise<File>;
|
|
47
|
+
/**
|
|
48
|
+
* Check if file is ready
|
|
49
|
+
*/
|
|
50
|
+
isReady(file: File): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Check if file upload failed
|
|
53
|
+
*/
|
|
54
|
+
isFailed(file: File): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Check if file is processing
|
|
57
|
+
*/
|
|
58
|
+
isProcessing(file: File): boolean;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAI5C,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAgBD,qBAAa,KAAK;IACJ,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAEpC;;OAEG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB7C;;OAEG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxF;;OAEG;IACG,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1D;;OAEG;IACG,SAAS,CACb,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC;IAShB;;OAEG;IACG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxC;;OAEG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAI1C;;OAEG;IACG,SAAS,CACb,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,MAAc,EACvB,YAAY,GAAE,MAAa,GAC1B,OAAO,CAAC,IAAI,CAAC;IAoBhB;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAI5B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAI7B;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;CAGlC"}
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { basename } from 'path';
|
|
3
|
+
function fileFromDict(data) {
|
|
4
|
+
return {
|
|
5
|
+
id: data.id || '',
|
|
6
|
+
userId: data.user_id || '',
|
|
7
|
+
filename: data.filename || '',
|
|
8
|
+
contentType: data.content_type || '',
|
|
9
|
+
fileSize: data.file_size || 0,
|
|
10
|
+
url: data.url || '',
|
|
11
|
+
state: data.state || null,
|
|
12
|
+
error: data.error || null,
|
|
13
|
+
createdAt: data.created_at || null,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export class Files {
|
|
17
|
+
http;
|
|
18
|
+
constructor(http) {
|
|
19
|
+
this.http = http;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Upload a file for use in renders
|
|
23
|
+
*/
|
|
24
|
+
async upload(filePath) {
|
|
25
|
+
const content = readFileSync(filePath);
|
|
26
|
+
const filename = basename(filePath);
|
|
27
|
+
// Guess content type
|
|
28
|
+
let contentType = 'application/octet-stream';
|
|
29
|
+
if (filename.endsWith('.png'))
|
|
30
|
+
contentType = 'image/png';
|
|
31
|
+
else if (filename.endsWith('.jpg') || filename.endsWith('.jpeg'))
|
|
32
|
+
contentType = 'image/jpeg';
|
|
33
|
+
else if (filename.endsWith('.gif'))
|
|
34
|
+
contentType = 'image/gif';
|
|
35
|
+
else if (filename.endsWith('.webp'))
|
|
36
|
+
contentType = 'image/webp';
|
|
37
|
+
else if (filename.endsWith('.mp3'))
|
|
38
|
+
contentType = 'audio/mpeg';
|
|
39
|
+
else if (filename.endsWith('.wav'))
|
|
40
|
+
contentType = 'audio/wav';
|
|
41
|
+
else if (filename.endsWith('.mp4'))
|
|
42
|
+
contentType = 'video/mp4';
|
|
43
|
+
else if (filename.endsWith('.webm'))
|
|
44
|
+
contentType = 'video/webm';
|
|
45
|
+
return this.uploadBytes(content, filename, contentType);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Upload file bytes directly
|
|
49
|
+
*/
|
|
50
|
+
async uploadBytes(content, filename, contentType) {
|
|
51
|
+
const files = {
|
|
52
|
+
file: { filename, content, contentType },
|
|
53
|
+
};
|
|
54
|
+
const data = await this.http.postMultipart('/api/files/multi', files);
|
|
55
|
+
return fileFromDict(data);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Upload a file from a URL (async backend processing)
|
|
59
|
+
*/
|
|
60
|
+
async uploadUrl(url, path) {
|
|
61
|
+
const payload = { url };
|
|
62
|
+
if (path)
|
|
63
|
+
payload.path = path;
|
|
64
|
+
const data = await this.http.post('/api/files/url', payload);
|
|
65
|
+
return fileFromDict(data);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Upload a file from base64-encoded data (async backend processing)
|
|
69
|
+
*/
|
|
70
|
+
async uploadB64(data, filename, contentType, path) {
|
|
71
|
+
const payload = { data, filename };
|
|
72
|
+
if (contentType)
|
|
73
|
+
payload.content_type = contentType;
|
|
74
|
+
if (path)
|
|
75
|
+
payload.path = path;
|
|
76
|
+
const result = await this.http.post('/api/files/b64', payload);
|
|
77
|
+
return fileFromDict(result);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get file metadata and URL
|
|
81
|
+
*/
|
|
82
|
+
async get(fileId) {
|
|
83
|
+
const data = await this.http.get(`/api/files/${fileId}`);
|
|
84
|
+
return fileFromDict(data);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Delete an uploaded file
|
|
88
|
+
*/
|
|
89
|
+
async delete(fileId) {
|
|
90
|
+
return await this.http.delete(`/api/files/${fileId}`);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Wait for an async upload to complete
|
|
94
|
+
*/
|
|
95
|
+
async waitReady(fileId, timeout = 60000, pollInterval = 1000) {
|
|
96
|
+
const start = Date.now();
|
|
97
|
+
while (Date.now() - start < timeout) {
|
|
98
|
+
const file = await this.get(fileId);
|
|
99
|
+
if (file.state === 'done') {
|
|
100
|
+
return file;
|
|
101
|
+
}
|
|
102
|
+
if (file.state === 'failed') {
|
|
103
|
+
throw new Error(`File upload failed: ${file.error}`);
|
|
104
|
+
}
|
|
105
|
+
await new Promise(resolve => setTimeout(resolve, pollInterval));
|
|
106
|
+
}
|
|
107
|
+
throw new Error(`File ${fileId} did not complete within ${timeout}ms`);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Check if file is ready
|
|
111
|
+
*/
|
|
112
|
+
isReady(file) {
|
|
113
|
+
return file.state === 'done';
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Check if file upload failed
|
|
117
|
+
*/
|
|
118
|
+
isFailed(file) {
|
|
119
|
+
return file.state === 'failed';
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Check if file is processing
|
|
123
|
+
*/
|
|
124
|
+
isProcessing(file) {
|
|
125
|
+
return file.state === 'processing';
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAchC,SAAS,YAAY,CAAC,IAAS;IAC7B,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE;QACjB,MAAM,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE;QAC1B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;QAC7B,WAAW,EAAE,IAAI,CAAC,YAAY,IAAI,EAAE;QACpC,QAAQ,EAAE,IAAI,CAAC,SAAS,IAAI,CAAC;QAC7B,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE;QACnB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI;QACzB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI;QACzB,SAAS,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI;KACnC,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,KAAK;IACI;IAApB,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAExC;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,QAAgB;QAC3B,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAEpC,q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,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAEpC,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;gBAC1B,OAAO,IAAI,CAAC;YACd,CAAC;YAED,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YACvD,CAAC;YAED,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;QAClE,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,QAAQ,MAAM,4BAA4B,OAAO,IAAI,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,IAAU;QAChB,OAAO,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,IAAU;QACjB,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,IAAU;QACrB,OAAO,IAAI,CAAC,KAAK,KAAK,YAAY,CAAC;IACrC,CAAC;CACF"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client utilities with retry logic
|
|
3
|
+
*/
|
|
4
|
+
import { APIError } from './errors.js';
|
|
5
|
+
export interface RequestOptions {
|
|
6
|
+
method: string;
|
|
7
|
+
url: string;
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
body?: any;
|
|
10
|
+
params?: Record<string, string | number | Array<string | number>>;
|
|
11
|
+
retries?: number;
|
|
12
|
+
backoff?: number;
|
|
13
|
+
timeout?: number;
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
retryStatuses?: readonly number[];
|
|
16
|
+
rawBody?: boolean;
|
|
17
|
+
/** Optional fetch redirect policy; omitted preserves the existing fetch default. */
|
|
18
|
+
redirect?: RequestInit['redirect'];
|
|
19
|
+
}
|
|
20
|
+
export type RequestOverrides = Pick<RequestOptions, 'retries' | 'backoff' | 'timeout' | 'signal' | 'retryStatuses' | 'redirect' | 'headers'>;
|
|
21
|
+
/**
|
|
22
|
+
* Make an HTTP request with retry logic for transient errors
|
|
23
|
+
*/
|
|
24
|
+
export declare function requestWithRetry(options: RequestOptions): Promise<Response>;
|
|
25
|
+
export declare function responseAPIError(response: Response, method?: string, requestUrl?: string): Promise<APIError>;
|
|
26
|
+
/**
|
|
27
|
+
* HTTP Client for making authenticated requests to the API
|
|
28
|
+
*/
|
|
29
|
+
export declare class HTTPClient {
|
|
30
|
+
private baseUrl;
|
|
31
|
+
private apiKey;
|
|
32
|
+
private timeout;
|
|
33
|
+
constructor(baseUrl: string, apiKey: string, timeout?: number);
|
|
34
|
+
get base(): string;
|
|
35
|
+
get credential(): string;
|
|
36
|
+
private get headers();
|
|
37
|
+
get<T = any>(path: string, params?: Record<string, string | number | Array<string | number>>, options?: RequestOverrides): Promise<T>;
|
|
38
|
+
/** Consume a streamed response while the request deadline remains active. */
|
|
39
|
+
getStream<T>(path: string, consume: (response: Response) => Promise<T>, options?: RequestOverrides): Promise<T>;
|
|
40
|
+
getWithHeaders<T = any>(path: string, params?: Record<string, string | number | Array<string | number>>, headers?: Record<string, string>): Promise<T>;
|
|
41
|
+
post<T = any>(path: string, body?: any, options?: RequestOverrides): Promise<T>;
|
|
42
|
+
postBytes(path: string, body?: any, options?: RequestOverrides): Promise<Uint8Array>;
|
|
43
|
+
postRaw<T = any>(path: string, body: any, contentType: string, options?: RequestOverrides): Promise<T>;
|
|
44
|
+
patch<T = any>(path: string, body?: any): Promise<T>;
|
|
45
|
+
put<T = any>(path: string, body?: any): Promise<T>;
|
|
46
|
+
delete<T = any>(path: string, body?: any): Promise<T>;
|
|
47
|
+
/**
|
|
48
|
+
* POST with multipart form data for file uploads
|
|
49
|
+
*/
|
|
50
|
+
postMultipart<T = any>(path: string, files: Record<string, {
|
|
51
|
+
filename: string;
|
|
52
|
+
content: Buffer;
|
|
53
|
+
contentType: string;
|
|
54
|
+
}>, params?: Record<string, string>): Promise<T>;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=http.d.ts.map
|