@hugex/artifact 0.12.7 → 0.12.9
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,97 @@
|
|
|
1
|
+
import type { ArtifactEnv } from '../types';
|
|
2
|
+
import { type Row } from './domains/read';
|
|
3
|
+
import type { ToolRunExecutor, ToolRunOutcome } from './toolRunContract';
|
|
4
|
+
export type RunContextResult = {
|
|
5
|
+
ok: true;
|
|
6
|
+
body: Row;
|
|
7
|
+
} | {
|
|
8
|
+
ok: false;
|
|
9
|
+
status: number;
|
|
10
|
+
body: Row;
|
|
11
|
+
};
|
|
12
|
+
/** Server-only hx-ora call (ORA API key + user token). Returns config and, optionally, accessible secrets. */
|
|
13
|
+
export declare function fetchRunContext(params: {
|
|
14
|
+
hxOraUrl?: string;
|
|
15
|
+
hxApiKey?: string;
|
|
16
|
+
token: string;
|
|
17
|
+
toolId: string;
|
|
18
|
+
revision?: string;
|
|
19
|
+
includeSecrets: boolean;
|
|
20
|
+
}): Promise<RunContextResult>;
|
|
21
|
+
export declare function scopeOfToolRow(row: Row): 'tenant' | 'global';
|
|
22
|
+
export declare function admitStoredToolRun(env: ArtifactEnv, input: {
|
|
23
|
+
runId: string;
|
|
24
|
+
actor: string;
|
|
25
|
+
grantId: string | null;
|
|
26
|
+
org: string;
|
|
27
|
+
toolId: string;
|
|
28
|
+
kind: string;
|
|
29
|
+
revision: string;
|
|
30
|
+
selector: string | null;
|
|
31
|
+
dryRun: boolean;
|
|
32
|
+
deadlineMs: number;
|
|
33
|
+
}): Promise<{
|
|
34
|
+
ok: true;
|
|
35
|
+
} | {
|
|
36
|
+
ok: false;
|
|
37
|
+
code: 'unavailable' | 'rate_limited';
|
|
38
|
+
scope?: 'tool' | 'user';
|
|
39
|
+
retryAfterSec?: number;
|
|
40
|
+
}>;
|
|
41
|
+
export declare function finishStoredToolRun(env: ArtifactEnv, runId: string, status: 'preview' | 'completed' | 'failed' | 'unknown', code: string | null, bytes: number): Promise<boolean>;
|
|
42
|
+
export interface StoredToolRunPolicy {
|
|
43
|
+
requireScope?: 'tenant' | 'global';
|
|
44
|
+
requireKind?: 'http' | 'composio' | 'mcp';
|
|
45
|
+
requireActive?: boolean;
|
|
46
|
+
}
|
|
47
|
+
export type StoredToolRunOutcome = {
|
|
48
|
+
ok: true;
|
|
49
|
+
runId: string;
|
|
50
|
+
kind: string;
|
|
51
|
+
scope: 'tenant' | 'global';
|
|
52
|
+
revision: string;
|
|
53
|
+
status: 'preview' | 'completed' | 'failed' | 'unknown';
|
|
54
|
+
result?: unknown;
|
|
55
|
+
preview?: ToolRunOutcome['preview'];
|
|
56
|
+
truncated?: boolean;
|
|
57
|
+
omitted?: string[];
|
|
58
|
+
httpStatus?: number;
|
|
59
|
+
error?: ToolRunOutcome['error'];
|
|
60
|
+
warnings?: string[];
|
|
61
|
+
} | {
|
|
62
|
+
ok: false;
|
|
63
|
+
error: 'not_found' | 'conflict' | 'rate_limited' | 'unavailable';
|
|
64
|
+
revision?: string;
|
|
65
|
+
scope?: 'tool' | 'user';
|
|
66
|
+
retryAfterSec?: number;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Shared execution path for stored tool rows (used by MCP `tool_run` and runtime `POST /api/tools/:id/live-test`).
|
|
70
|
+
* Always enforces fresh run-context, ArtifactIndexDO admission/audit, and sanitized output.
|
|
71
|
+
*/
|
|
72
|
+
export declare function executeStoredToolRow(params: {
|
|
73
|
+
env: ArtifactEnv;
|
|
74
|
+
hxOraUrl?: string;
|
|
75
|
+
hxApiKey?: string;
|
|
76
|
+
upstreamToken: string;
|
|
77
|
+
tenant: string;
|
|
78
|
+
user: {
|
|
79
|
+
sub: string;
|
|
80
|
+
email: string;
|
|
81
|
+
org: string;
|
|
82
|
+
};
|
|
83
|
+
grantId: string | null;
|
|
84
|
+
toolId: string;
|
|
85
|
+
revision: string;
|
|
86
|
+
args: Row;
|
|
87
|
+
selector: {
|
|
88
|
+
remoteToolName?: string;
|
|
89
|
+
toolSlug?: string;
|
|
90
|
+
toolVersion?: string;
|
|
91
|
+
};
|
|
92
|
+
timeoutMs: number;
|
|
93
|
+
dryRun: boolean;
|
|
94
|
+
executor?: ToolRunExecutor;
|
|
95
|
+
initialContext: Row;
|
|
96
|
+
policy?: StoredToolRunPolicy;
|
|
97
|
+
}): Promise<StoredToolRunOutcome>;
|