@hugex/artifact 0.6.0 → 0.6.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,4 +1,5 @@
1
1
  import { artifactDevPrefix } from "./dev-prefix";
2
+ import type { WorkerConnectionSupport } from "./mcp/context";
2
3
  import type { ArtifactEnv, ArtifactHostOptions } from "./types";
3
4
  export { artifactDevPrefix };
4
5
  /**
@@ -8,3 +9,5 @@ export { artifactDevPrefix };
8
9
  * `options.agentProxy` turns on `<base>/__hx/agent/<flowId>/<sessionId>`.
9
10
  */
10
11
  export declare function handleArtifactHost(request: Request, env: ArtifactEnv, ctx: ExecutionContext, options?: ArtifactHostOptions): Promise<Response | null>;
12
+ /** Reports the tenant wiring that artifact Worker calls depend on (see `WorkerConnectionSupport`). */
13
+ export declare function workerConnectionSupport(ctx: ExecutionContext, options?: ArtifactHostOptions): WorkerConnectionSupport;
@@ -2,6 +2,15 @@ import type { ArtifactEnv } from '../types';
2
2
  import type { ArtifactAccess } from './authz';
3
3
  import type { ArtifactIdentity } from './auth';
4
4
  import type { ConnectionSummary } from './oauth/contract';
5
+ /**
6
+ * Which artifact-to-Worker paths this tenant wires. `server`: the tenant exports
7
+ * `ArtifactWorkerGateway` (artifact `env.HX`); `browser`: `handleArtifactHost` got an
8
+ * `agentProxy` (`window.hx.worker`). Undefined means unknown, so no warning is emitted.
9
+ */
10
+ export interface WorkerConnectionSupport {
11
+ server: boolean;
12
+ browser: boolean;
13
+ }
5
14
  export interface McpRequestContext {
6
15
  env: ArtifactEnv;
7
16
  identity: ArtifactIdentity;
@@ -16,4 +25,5 @@ export interface McpRequestContext {
16
25
  cursor?: string;
17
26
  }>;
18
27
  revokeConnection?: (grantId: string) => Promise<boolean>;
28
+ workerConnections?: WorkerConnectionSupport;
19
29
  }
@@ -1,3 +1,4 @@
1
1
  import type { ArtifactEnv } from '../../types';
2
+ import type { WorkerConnectionSupport } from '../context';
2
3
  export type { McpAccessTokenProps } from './contract';
3
- export declare function handleOAuthRequest(request: Request, env: ArtifactEnv, ctx: ExecutionContext): Promise<Response>;
4
+ export declare function handleOAuthRequest(request: Request, env: ArtifactEnv, ctx: ExecutionContext, workerConnections?: WorkerConnectionSupport): Promise<Response>;
@@ -5,6 +5,7 @@ import { buildArtifactUrl } from '../url';
5
5
  export { isSingleSelect };
6
6
  export { artifactIndexRpc, artifactRpc, buildArtifactUrl };
7
7
  import type { ArtifactIdentity } from './auth';
8
+ import type { WorkerConnectionSupport } from './context';
8
9
  import { type ArtifactAccess } from './authz';
9
10
  interface ToolDeps {
10
11
  env: ArtifactEnv;
@@ -13,6 +14,7 @@ interface ToolDeps {
13
14
  access: ArtifactAccess | null;
14
15
  /** Verified upstream Keycloak token, never the opaque MCP credential. */
15
16
  upstreamToken?: string;
17
+ workerConnections?: WorkerConnectionSupport;
16
18
  }
17
19
  export interface ToolDefinition {
18
20
  name: string;
@@ -42,3 +44,10 @@ export declare function initialArtifactFiles(title: string): {
42
44
  content: string;
43
45
  }[];
44
46
  export declare function executeTool(name: string, args: Record<string, unknown>, deps: ToolDeps): Promise<ToolTextResult>;
47
+ /** Warnings for the artifact Worker paths this tenant does not wire; empty when support is unknown. */
48
+ export declare function connectionWarnings(support: WorkerConnectionSupport | undefined): string[];
49
+ /** Only warns when a written file actually uses a Worker path the tenant does not wire. */
50
+ export declare function writeConnectionWarnings(changes: ReadonlyArray<{
51
+ path: string;
52
+ content: string | null;
53
+ }>, support: WorkerConnectionSupport | undefined): string[];