@hugex/artifact 0.12.5 → 0.12.7
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/dist/artifact/do/ArtifactIndexDO.d.ts +10 -1
- package/dist/artifact/mcp/domains/toolConnections.d.ts +5 -0
- package/dist/artifact/mcp/domains/worker-authoring-io.d.ts +2 -0
- package/dist/artifact/mcp/toolRunContract.d.ts +42 -0
- package/dist/artifact/types.d.ts +10 -1
- package/dist/index.js +83 -66
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DurableObject } from "cloudflare:workers";
|
|
2
2
|
import type { ArtifactEnv, ArtifactIndexEntry, ArtifactIndexRpc } from "../types";
|
|
3
|
-
import { type ToolRunAdmitInput, type ToolRunAdmitResult, type ToolRunFinishInput, type ToolRunLogEntry } from "../mcp/toolRunContract";
|
|
3
|
+
import { type ToolConnectionAdmitInput, type ToolConnectionAdmitResult, type ToolConnectionFinishInput, type ToolConnectionLogEntry, type ToolRunAdmitInput, type ToolRunAdmitResult, type ToolRunFinishInput, type ToolRunLogEntry } from "../mcp/toolRunContract";
|
|
4
4
|
export { INDEX_TOMBSTONE_SQL, INDEX_UPSERT_SQL } from "./index-upsert";
|
|
5
5
|
/**
|
|
6
6
|
* One instance per tenant (`idFromName('index')`).
|
|
@@ -10,15 +10,24 @@ export declare class ArtifactIndexDO extends DurableObject<ArtifactEnv> implemen
|
|
|
10
10
|
constructor(ctx: DurableObjectState, env: ArtifactEnv);
|
|
11
11
|
/** Additive, idempotent. Separate tables: never touches artifact rows. */
|
|
12
12
|
private ensureToolRunSchema;
|
|
13
|
+
/** Additive, idempotent. Independent of tool_run_log and artifact rows. */
|
|
14
|
+
private ensureToolConnectionSchema;
|
|
13
15
|
admitToolRun(input: ToolRunAdmitInput): Promise<ToolRunAdmitResult>;
|
|
14
16
|
finishToolRun(input: ToolRunFinishInput): Promise<boolean>;
|
|
15
17
|
listToolRuns(opts?: {
|
|
16
18
|
actor?: string;
|
|
17
19
|
limit?: number;
|
|
18
20
|
}): Promise<ToolRunLogEntry[]>;
|
|
21
|
+
admitToolConnection(input: ToolConnectionAdmitInput): Promise<ToolConnectionAdmitResult>;
|
|
22
|
+
finishToolConnection(input: ToolConnectionFinishInput): Promise<boolean>;
|
|
23
|
+
listToolConnections(opts?: {
|
|
24
|
+
actor?: string;
|
|
25
|
+
limit?: number;
|
|
26
|
+
}): Promise<ToolConnectionLogEntry[]>;
|
|
19
27
|
/** Marks expired pending runs unknown and purges rows older than 30 days, in bounded batches. */
|
|
20
28
|
alarm(): Promise<void>;
|
|
21
29
|
private recordDenial;
|
|
30
|
+
private recordConnectionDenial;
|
|
22
31
|
put(entry: ArtifactIndexEntry): Promise<void>;
|
|
23
32
|
/**
|
|
24
33
|
* With `tombstone`, marks the row deleted instead of erasing it, so a snapshot still in flight
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { McpRequestContext } from '../context';
|
|
2
|
+
import type { ToolDefinition, ToolTextResult } from '../tools';
|
|
3
|
+
import { type Row } from './read';
|
|
4
|
+
export declare const toolConnectionTools: ToolDefinition[];
|
|
5
|
+
export declare function executeToolConnectionTool(name: string, args: Row, context: McpRequestContext): Promise<ToolTextResult>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type GraphIssue, type WorkerGraph } from '../../../common/flow-graph';
|
|
2
2
|
import type { McpRequestContext } from '../context';
|
|
3
|
+
import { type Row } from './read';
|
|
3
4
|
export type IoResult = {
|
|
4
5
|
ok: true;
|
|
5
6
|
issues: GraphIssue[];
|
|
7
|
+
toolRows: ReadonlyMap<string, Row>;
|
|
6
8
|
} | {
|
|
7
9
|
ok: false;
|
|
8
10
|
error: 'models_unavailable' | 'unavailable';
|
|
@@ -108,3 +108,45 @@ export declare const TOOL_RUN_LIMITS: {
|
|
|
108
108
|
readonly windowMs: 60000;
|
|
109
109
|
readonly retentionMs: number;
|
|
110
110
|
};
|
|
111
|
+
export type ToolConnectionOperation = 'connect' | 'disconnect';
|
|
112
|
+
/** Admission/audit rows kept by ArtifactIndexDO (`tool_connection_log`, 30 days). Never links, account IDs, tokens or bodies. */
|
|
113
|
+
export interface ToolConnectionAdmitInput {
|
|
114
|
+
connectionId: string;
|
|
115
|
+
actor: string;
|
|
116
|
+
grantId: string | null;
|
|
117
|
+
org: string;
|
|
118
|
+
operation: ToolConnectionOperation;
|
|
119
|
+
toolId: string;
|
|
120
|
+
toolkit: string | null;
|
|
121
|
+
}
|
|
122
|
+
export type ToolConnectionAdmitResult = {
|
|
123
|
+
ok: true;
|
|
124
|
+
} | {
|
|
125
|
+
ok: false;
|
|
126
|
+
code: 'rate_limited';
|
|
127
|
+
retryAfterSec: number;
|
|
128
|
+
scope: 'tool' | 'user';
|
|
129
|
+
};
|
|
130
|
+
export interface ToolConnectionFinishInput {
|
|
131
|
+
connectionId: string;
|
|
132
|
+
result: string;
|
|
133
|
+
toolkit?: string | null;
|
|
134
|
+
}
|
|
135
|
+
export interface ToolConnectionLogEntry {
|
|
136
|
+
connectionId: string;
|
|
137
|
+
actor: string;
|
|
138
|
+
grantId: string | null;
|
|
139
|
+
org: string;
|
|
140
|
+
operation: string;
|
|
141
|
+
toolId: string;
|
|
142
|
+
toolkit: string | null;
|
|
143
|
+
result: string;
|
|
144
|
+
startedAt: number;
|
|
145
|
+
finishedAt: number | null;
|
|
146
|
+
}
|
|
147
|
+
export declare const TOOL_CONNECTION_LIMITS: {
|
|
148
|
+
readonly perToolPerMinute: 5;
|
|
149
|
+
readonly perUserPerMinute: 20;
|
|
150
|
+
readonly windowMs: 60000;
|
|
151
|
+
readonly retentionMs: number;
|
|
152
|
+
};
|
package/dist/artifact/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AllowsWorkerResult, ArtifactAgentProxyTarget } from '../common/types/artifact-bridge';
|
|
2
|
-
import type { ToolRunAdmitInput, ToolRunAdmitResult, ToolRunExecutor, ToolRunFinishInput, ToolRunLogEntry } from './mcp/toolRunContract';
|
|
2
|
+
import type { ToolConnectionAdmitInput, ToolConnectionAdmitResult, ToolConnectionFinishInput, ToolConnectionLogEntry, ToolRunAdmitInput, ToolRunAdmitResult, ToolRunExecutor, ToolRunFinishInput, ToolRunLogEntry } from './mcp/toolRunContract';
|
|
3
3
|
export type { AllowsWorkerResult, ArtifactAgentProxyTarget };
|
|
4
4
|
/**
|
|
5
5
|
* Contract shared by the @hugex/artifact runtime (ArtifactDO, ArtifactIndexDO, host routing) and the MCP layer.
|
|
@@ -536,6 +536,15 @@ export interface ArtifactIndexRpc {
|
|
|
536
536
|
actor?: string;
|
|
537
537
|
limit?: number;
|
|
538
538
|
}): Promise<ToolRunLogEntry[]>;
|
|
539
|
+
/** `tool_connect` / `tool_disconnect` admission: sliding-window quotas + initial audit row in one transaction. */
|
|
540
|
+
admitToolConnection(input: ToolConnectionAdmitInput): Promise<ToolConnectionAdmitResult>;
|
|
541
|
+
/** Closes the connection audit row with the final outcome (never links, account IDs, tokens or bodies). */
|
|
542
|
+
finishToolConnection(input: ToolConnectionFinishInput): Promise<boolean>;
|
|
543
|
+
/** Administrative read of the connection audit log (newest first). */
|
|
544
|
+
listToolConnections(opts?: {
|
|
545
|
+
actor?: string;
|
|
546
|
+
limit?: number;
|
|
547
|
+
}): Promise<ToolConnectionLogEntry[]>;
|
|
539
548
|
}
|
|
540
549
|
/**
|
|
541
550
|
* Headers the host router sets when forwarding a browser request to ArtifactDO.fetch().
|