@hugex/artifact 0.5.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.
Files changed (76) hide show
  1. package/dist/{host.d.ts → artifact/host.d.ts} +3 -0
  2. package/dist/{mcp → artifact/mcp}/context.d.ts +10 -0
  3. package/dist/artifact/mcp/domains/draftAccess.d.ts +6 -0
  4. package/dist/artifact/mcp/domains/guide.d.ts +11 -0
  5. package/dist/{mcp → artifact/mcp}/domains/read.d.ts +10 -0
  6. package/dist/artifact/mcp/domains/secrets.d.ts +5 -0
  7. package/dist/artifact/mcp/domains/worker-authoring-io.d.ts +19 -0
  8. package/dist/artifact/mcp/domains/worker-authoring.d.ts +22 -0
  9. package/dist/artifact/mcp/domains/worker-write.d.ts +109 -0
  10. package/dist/{mcp → artifact/mcp}/index.d.ts +1 -1
  11. package/dist/{mcp → artifact/mcp}/oauth/provider.d.ts +2 -1
  12. package/dist/artifact/mcp/registry.d.ts +13 -0
  13. package/dist/artifact/mcp/scopes.d.ts +37 -0
  14. package/dist/{mcp → artifact/mcp}/tools.d.ts +9 -0
  15. package/dist/common/constants/clef-models.d.ts +48 -0
  16. package/dist/common/constants/tools-registry.d.ts +8 -0
  17. package/dist/common/flow-graph/catalog.d.ts +40 -0
  18. package/dist/common/flow-graph/classifier.d.ts +2 -0
  19. package/dist/common/flow-graph/composio.d.ts +2 -0
  20. package/dist/common/flow-graph/credentials.d.ts +3 -0
  21. package/dist/common/flow-graph/index.d.ts +11 -0
  22. package/dist/common/flow-graph/ops.d.ts +21 -0
  23. package/dist/common/flow-graph/refs.d.ts +18 -0
  24. package/dist/common/flow-graph/schema.d.ts +570 -0
  25. package/dist/common/flow-graph/templates.d.ts +2 -0
  26. package/dist/common/flow-graph/validate.d.ts +77 -0
  27. package/dist/common/types/classifier-types.d.ts +57 -0
  28. package/dist/common/types/classifier-validation.d.ts +2 -0
  29. package/dist/common/types/crawl-types.d.ts +59 -0
  30. package/dist/common/types/node-types.d.ts +12 -0
  31. package/dist/common/types/trigger-types.d.ts +106 -0
  32. package/dist/common/types/var-scope.d.ts +43 -0
  33. package/dist/common/utils/agentMemory.d.ts +31 -0
  34. package/dist/common/utils/crawlClient.d.ts +38 -0
  35. package/dist/common/utils/flowInputs.d.ts +19 -0
  36. package/dist/common/utils/flowScope.d.ts +16 -0
  37. package/dist/common/utils/httpPayload.d.ts +4 -0
  38. package/dist/common/utils/outVars.d.ts +6 -0
  39. package/dist/common/utils/templateUtils.d.ts +37 -0
  40. package/dist/index.js +45 -45
  41. package/package.json +3 -3
  42. package/dist/mcp/registry.d.ts +0 -3
  43. package/dist/mcp/scopes.d.ts +0 -18
  44. /package/dist/{catalog.d.ts → artifact/catalog.d.ts} +0 -0
  45. /package/dist/{dev-prefix.d.ts → artifact/dev-prefix.d.ts} +0 -0
  46. /package/dist/{do → artifact/do}/ArtifactDO.d.ts +0 -0
  47. /package/dist/{do → artifact/do}/ArtifactIndexDO.d.ts +0 -0
  48. /package/dist/{do → artifact/do}/file-storage.d.ts +0 -0
  49. /package/dist/{do → artifact/do}/index-upsert.d.ts +0 -0
  50. /package/dist/{do → artifact/do}/meta-migrate.d.ts +0 -0
  51. /package/dist/{do → artifact/do}/ora-index.d.ts +0 -0
  52. /package/dist/{hash.d.ts → artifact/hash.d.ts} +0 -0
  53. /package/dist/{host-route.d.ts → artifact/host-route.d.ts} +0 -0
  54. /package/dist/{index.d.ts → artifact/index.d.ts} +0 -0
  55. /package/dist/{inject.d.ts → artifact/inject.d.ts} +0 -0
  56. /package/dist/{internal.d.ts → artifact/internal.d.ts} +0 -0
  57. /package/dist/{limits.d.ts → artifact/limits.d.ts} +0 -0
  58. /package/dist/{mcp → artifact/mcp}/access.d.ts +0 -0
  59. /package/dist/{mcp → artifact/mcp}/auth.d.ts +0 -0
  60. /package/dist/{mcp → artifact/mcp}/authz.d.ts +0 -0
  61. /package/dist/{mcp → artifact/mcp}/domains/artifacts.d.ts +0 -0
  62. /package/dist/{mcp → artifact/mcp}/domains/memos.d.ts +0 -0
  63. /package/dist/{mcp → artifact/mcp}/domains/skills.d.ts +0 -0
  64. /package/dist/{mcp → artifact/mcp}/domains/tools.d.ts +0 -0
  65. /package/dist/{mcp → artifact/mcp}/domains/workers.d.ts +0 -0
  66. /package/dist/{mcp → artifact/mcp}/oauth/config.d.ts +0 -0
  67. /package/dist/{mcp → artifact/mcp}/oauth/contract.d.ts +0 -0
  68. /package/dist/{rpc.d.ts → artifact/rpc.d.ts} +0 -0
  69. /package/dist/{runtime → artifact/runtime}/artifact-app-source.d.ts +0 -0
  70. /package/dist/{sql.d.ts → artifact/sql.d.ts} +0 -0
  71. /package/dist/{templates.d.ts → artifact/templates.d.ts} +0 -0
  72. /package/dist/{types.d.ts → artifact/types.d.ts} +0 -0
  73. /package/dist/{url.d.ts → artifact/url.d.ts} +0 -0
  74. /package/dist/{validate.d.ts → artifact/validate.d.ts} +0 -0
  75. /package/dist/{version.d.ts → artifact/version.d.ts} +0 -0
  76. /package/dist/{worker-client.d.ts → artifact/worker-client.d.ts} +0 -0
@@ -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
  }
@@ -0,0 +1,6 @@
1
+ import type { McpRequestContext } from '../context';
2
+ /** Owner by email, admin of the Worker's org, or superadmin. With `access === null`, only the owner counts. */
3
+ export declare function canManageDraft(context: McpRequestContext, row: {
4
+ owner?: unknown;
5
+ org?: unknown;
6
+ }): boolean;
@@ -0,0 +1,11 @@
1
+ import type { McpRequestContext } from '../context';
2
+ import type { McpDomain } from './artifacts';
3
+ /** Per-isolate cache and fetch bounds. Tests may lower the timings. */
4
+ export declare const guideLimits: {
5
+ fetchTimeoutMs: number;
6
+ cacheTtlMs: number;
7
+ maxFileBytes: number;
8
+ };
9
+ export declare const guideDomain: McpDomain;
10
+ export declare function clearGuideCache(): void;
11
+ export declare function executeGuideTool(name: string, args: Record<string, unknown>, context: McpRequestContext, serverVersion: string): Promise<import("../tools").ToolTextResult>;
@@ -20,6 +20,15 @@ export declare const idSchema: {
20
20
  pattern: string;
21
21
  };
22
22
  export declare function checkContext(context: McpRequestContext, modules: string[]): void;
23
+ type UpstreamMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE';
24
+ /** Timeout or network failure. Callers map this to `write_unknown` instead of a definite 4xx. */
25
+ export declare class UpstreamUncertain extends Error {
26
+ constructor(message?: string);
27
+ }
28
+ export declare function upstreamRaw(context: McpRequestContext, service: 'ora' | 'core', path: string, method: UpstreamMethod, body?: Row): Promise<{
29
+ status: number;
30
+ json: unknown;
31
+ }>;
23
32
  export declare function upstream(context: McpRequestContext, service: 'ora' | 'core', path: string, body?: Row): Promise<unknown>;
24
33
  export type UpstreamWriteError = 'duplicate_name' | 'invalid_arguments' | 'forbidden' | 'unavailable';
25
34
  export declare function upstreamWrite(context: McpRequestContext, service: 'ora' | 'core', path: string, method: 'POST' | 'PATCH' | 'DELETE', body?: Row): Promise<{
@@ -35,3 +44,4 @@ export declare function summary(row: Row): {
35
44
  description: string;
36
45
  status: string;
37
46
  };
47
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { McpRequestContext } from '../context';
2
+ import type { McpDomain } from './artifacts';
3
+ import { type Row } from './read';
4
+ export declare const secretsDomain: McpDomain;
5
+ export declare function executeSecretTool(name: string, args: Row, context: McpRequestContext): Promise<import("../tools").ToolTextResult>;
@@ -0,0 +1,19 @@
1
+ import { type WorkerGraph } from '../../../common/flow-graph';
2
+ import type { GraphIssue } from '../../../common/flow-graph';
3
+ import type { McpRequestContext } from '../context';
4
+ export type IoResult = {
5
+ ok: true;
6
+ issues: GraphIssue[];
7
+ } | {
8
+ ok: false;
9
+ error: 'models_unavailable' | 'unavailable';
10
+ };
11
+ /**
12
+ * L3 for refs that are new or changed. Other inherited refs are left alone.
13
+ * When a new model ref already loaded the catalog, inherited model refs are
14
+ * reported as warnings. The caller's input schema is never authorization.
15
+ */
16
+ export declare function checkNewExternalRefs(context: McpRequestContext, before: WorkerGraph | null, after: WorkerGraph, meta: {
17
+ flowId?: string;
18
+ org: string;
19
+ }): Promise<IoResult>;
@@ -0,0 +1,22 @@
1
+ import type { WorkerGraph } from '../../../common/flow-graph';
2
+ import type { McpRequestContext } from '../context';
3
+ import type { ToolTextResult } from '../tools';
4
+ import type { McpDomain } from './artifacts';
5
+ import { type Row } from './read';
6
+ export interface AuthoringTool {
7
+ name: string;
8
+ description: string;
9
+ inputSchema: Record<string, unknown>;
10
+ }
11
+ export declare const workerAuthoringTools: AuthoringTool[];
12
+ export declare const workerAuthoringDomain: McpDomain;
13
+ export declare function graphFromEnvelope(json: unknown): {
14
+ ok: true;
15
+ graph: WorkerGraph;
16
+ raw: WorkerGraph;
17
+ stateVersion: number;
18
+ } | {
19
+ ok: false;
20
+ error: 'legacy_graph';
21
+ };
22
+ export declare function executeWorkerAuthoringTool(name: string, args: Row, context: McpRequestContext): Promise<ToolTextResult>;
@@ -0,0 +1,109 @@
1
+ import { type WorkerGraph } from '../../../common/flow-graph';
2
+ import type { McpRequestContext } from '../context';
3
+ import { type Row } from './read';
4
+ export declare const WRITE_HINT = "Call worker_get_graph with this flowId before retrying.";
5
+ export type WritePhase = 'create' | 'save' | 'activate' | 'metadata' | 'status';
6
+ export type WriteCleanup = 'deleted' | 'failed' | 'skipped' | 'not_needed';
7
+ export type WriteFailure = {
8
+ ok: false;
9
+ error: 'write_partial' | 'write_unknown';
10
+ flowId: string;
11
+ phase: WritePhase;
12
+ confirmedVersion?: number;
13
+ cleanup: WriteCleanup;
14
+ hint: string;
15
+ };
16
+ export type FlowSummary = {
17
+ id: string;
18
+ name: string;
19
+ description: string;
20
+ status: string;
21
+ visibility: string;
22
+ owner: string;
23
+ group: string;
24
+ org: string;
25
+ blocked: boolean;
26
+ type: string;
27
+ };
28
+ export type ReadRowResult = {
29
+ ok: true;
30
+ row: FlowSummary;
31
+ } | {
32
+ ok: false;
33
+ error: 'worker_unavailable' | 'forbidden' | 'unavailable';
34
+ };
35
+ export type FreshEnvelope = {
36
+ ok: true;
37
+ json: Row;
38
+ } | {
39
+ ok: false;
40
+ error: 'unavailable';
41
+ };
42
+ /** Integer version on the envelope. Missing means the caller decides (0 on a fresh read, unconfirmed on reconcile). */
43
+ export declare function stateVersionOf(json: unknown): number | undefined;
44
+ export declare function observedStateVersion(json: unknown): number;
45
+ export type SaveResult = {
46
+ ok: true;
47
+ stateVersion: number;
48
+ } | {
49
+ ok: false;
50
+ error: 'version_conflict';
51
+ stateVersion?: number;
52
+ } | {
53
+ ok: false;
54
+ error: 'rejected';
55
+ status: number;
56
+ } | WriteFailure;
57
+ /** POST the graph. A 2xx is confirmed. An uncertain result needs version+1 and the same canonical graph. */
58
+ export declare function saveState(context: McpRequestContext, flowId: string, graph: WorkerGraph, expectedVersion: number): Promise<SaveResult>;
59
+ export type CreateResult = {
60
+ ok: true;
61
+ flowId: string;
62
+ stateVersion: number;
63
+ } | {
64
+ ok: false;
65
+ error: 'duplicate_id' | 'forbidden' | 'unavailable';
66
+ } | WriteFailure;
67
+ /**
68
+ * Reserve an id, save the graph at version 0, then activate.
69
+ * `duplicate_id` retries once. An uncertain create is reconciled and never minted again.
70
+ * A definite 4xx after a confirmed create deletes the row. `write_unknown` does not.
71
+ */
72
+ export declare function createWorker(context: McpRequestContext, input: {
73
+ name: string;
74
+ description: string;
75
+ graph: WorkerGraph;
76
+ }): Promise<CreateResult>;
77
+ export type UpdateResult = {
78
+ ok: true;
79
+ flowId: string;
80
+ stateVersion?: number;
81
+ } | {
82
+ ok: false;
83
+ error: 'version_conflict';
84
+ stateVersion?: number;
85
+ } | {
86
+ ok: false;
87
+ error: 'forbidden' | 'unavailable';
88
+ } | WriteFailure;
89
+ /** Graph first, then metadata. A definite metadata failure after a saved graph is `write_partial`. */
90
+ export declare function commitUpdate(context: McpRequestContext, input: {
91
+ flowId: string;
92
+ graph?: {
93
+ body: WorkerGraph;
94
+ expectedVersion: number;
95
+ };
96
+ metadata?: {
97
+ name?: string;
98
+ description?: string;
99
+ };
100
+ }): Promise<UpdateResult>;
101
+ export type StatusResult = {
102
+ ok: true;
103
+ } | {
104
+ ok: false;
105
+ error: 'forbidden' | 'unavailable';
106
+ } | WriteFailure;
107
+ export declare function setWorkerStatus(context: McpRequestContext, flowId: string, status: 'active' | 'inactive'): Promise<StatusResult>;
108
+ export declare function readWorkerRow(context: McpRequestContext, flowId: string): Promise<ReadRowResult>;
109
+ export declare function readFreshEnvelope(context: McpRequestContext, flowId: string): Promise<FreshEnvelope>;
@@ -5,7 +5,7 @@ import type { ArtifactEnv } from '../types';
5
5
  import type { McpRequestContext } from './context';
6
6
  export declare const MAX_BODY_BYTES: number;
7
7
  export declare const SERVER_NAME = "hugex";
8
- export declare const SERVER_VERSION = "2.0.0";
8
+ export declare const SERVER_VERSION = "2.1.0";
9
9
  export declare const DEFAULT_PROTOCOL_VERSION = "2025-11-25";
10
10
  export declare const SUPPORTED_PROTOCOL_VERSIONS: readonly ['2024-11-05', '2025-03-26', '2025-06-18', '2025-11-25'];
11
11
  export type AccessMode = 'phase1' | 'rbac';
@@ -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>;
@@ -0,0 +1,13 @@
1
+ import { type McpDomain } from './domains/artifacts';
2
+ export declare const GUIDE_DOMAIN_ID: string;
3
+ /**
4
+ * `guide` is attached to `/mcp` and to every `/mcp/<domain>`.
5
+ * `/mcp/guide` is not a route: the entry gate would demand `guide:read`, and that
6
+ * scope does not exist. A session that can open any domain can call `hugex_guide`.
7
+ */
8
+ export declare function domainForPath(pathname: string, resourcePath: string): McpDomain[] | null;
9
+ /** OAuth read scopes that open a path. Authoring shares `workers:read`. */
10
+ export declare function entryReadScopes(domains: readonly McpDomain[]): string[];
11
+ export declare function domainForTool(name: string): McpDomain | null;
12
+ /** Sorted tool names from every domain, including `hugex_guide`. */
13
+ export declare function registeredToolNames(): string[];
@@ -0,0 +1,37 @@
1
+ export declare const ARTIFACT_READ_SCOPE = "artifacts:read";
2
+ export declare const ARTIFACT_WRITE_SCOPE = "artifacts:write";
3
+ export declare const WORKER_READ_SCOPE = "workers:read";
4
+ export declare const WORKER_RUN_SCOPE = "workers:run";
5
+ export declare const WORKER_WRITE_SCOPE = "workers:write";
6
+ export declare const ARTIFACT_SCOPES: readonly ["artifacts:read", "artifacts:write"];
7
+ export declare const SKILL_READ_SCOPE = "skills:read";
8
+ export declare const SKILL_WRITE_SCOPE = "skills:write";
9
+ export declare const SKILL_SCOPES: readonly ["skills:read", "skills:write"];
10
+ export declare const TOOL_READ_SCOPE = "tools:read";
11
+ export declare const MEMO_READ_SCOPE = "memos:read";
12
+ export declare const SECRET_READ_SCOPE = "secrets:read";
13
+ export declare const SECRET_WRITE_SCOPE = "secrets:write";
14
+ export declare const SECRET_SCOPES: readonly ["secrets:read", "secrets:write"];
15
+ export declare const MCP_SCOPES: readonly ["artifacts:read", "artifacts:write", "workers:read", "workers:run", "workers:write", "skills:read", "skills:write", "tools:read", "memos:read", "secrets:read", "secrets:write"];
16
+ /** Any authenticated grant may call this tool. It is not an OAuth scope. */
17
+ export declare const GUIDE_TOOL_NAME = "hugex_guide";
18
+ /**
19
+ * Sentinel from `requiredScope` for tools that do not map to an OAuth scope.
20
+ * Callers must not send it as a `WWW-Authenticate` scope.
21
+ */
22
+ export declare const NO_OAUTH_SCOPE = "";
23
+ export declare const SKILL_WRITE_TOOLS: Set<string>;
24
+ /** Authoring tools. Each one needs the workers:read + workers:write pair. */
25
+ export declare const WORKER_WRITE_TOOLS: Set<string>;
26
+ /** `secret_set` needs the secrets:read + secrets:write pair. `secret_list` stays read-only. */
27
+ export declare const SECRET_WRITE_TOOLS: Set<string>;
28
+ export declare function effectiveScopes(scopes: ReadonlySet<string>): ReadonlySet<string>;
29
+ export declare function requiredScope(tool: string, args: Record<string, unknown>): string;
30
+ export declare function hasScope(scopes: ReadonlySet<string>, required: string): boolean;
31
+ /** Both scopes must be present. effectiveScopes never adds read for these pairs. */
32
+ export declare function hasPair(scopes: ReadonlySet<string>, read: string, write: string): boolean;
33
+ /** Skill writes require both scopes in the grant; effectiveScopes never adds skills:read. */
34
+ export declare function hasSkillWriteAccess(scopes: ReadonlySet<string>): boolean;
35
+ export declare function hasToolAccess(scopes: ReadonlySet<string>, tool: string, args?: Record<string, unknown>): boolean;
36
+ /** A grant can open MCP only when it carries at least one domain read scope. */
37
+ export declare function hasAnyDomainRead(scopes: ReadonlySet<string>): boolean;
@@ -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[];
@@ -0,0 +1,48 @@
1
+ import type { ClassifierRoute } from '../types/classifier-types';
2
+ export declare const CLEF_MODELS: {
3
+ readonly 'clef-omni': {
4
+ readonly id: '@cf/cloudflare/clef-omni';
5
+ readonly contextWindow: 65529;
6
+ readonly pricePerMillionInputTokens: 0.15;
7
+ };
8
+ readonly clef: {
9
+ readonly id: '@cf/cloudflare/clef';
10
+ readonly contextWindow: 65536;
11
+ readonly pricePerMillionInputTokens: 0.24;
12
+ };
13
+ readonly 'clef-flash': {
14
+ readonly id: '@cf/cloudflare/clef-flash';
15
+ readonly contextWindow: 24576;
16
+ readonly pricePerMillionInputTokens: 0.038;
17
+ };
18
+ };
19
+ export declare const CLASSIFIER_DEFAULTS: {
20
+ readonly model: 'clef-omni';
21
+ readonly question: '';
22
+ readonly options: readonly [{
23
+ readonly id: 'option';
24
+ readonly label: '';
25
+ readonly criteria: '';
26
+ }, {
27
+ readonly id: 'option_2';
28
+ readonly label: '';
29
+ readonly criteria: '';
30
+ }];
31
+ readonly checks: readonly [];
32
+ readonly input: {
33
+ readonly message: 'user_input';
34
+ readonly historyTurns: 3;
35
+ readonly vars: string[];
36
+ };
37
+ readonly confidence: {
38
+ readonly threshold: 0.6;
39
+ readonly margin: 0.15;
40
+ };
41
+ };
42
+ export declare const CLASSIFIER_RESERVED_HANDLES: {
43
+ readonly uncertain: 'source-__uncertain';
44
+ readonly blocked: 'source-__blocked';
45
+ readonly error: 'source-__error';
46
+ };
47
+ /** Pass ('class', id) for class ids that also happen to be route names. */
48
+ export declare function classifierHandle(routeOrClassId: ClassifierRoute | string, classId?: string): string;
@@ -0,0 +1,8 @@
1
+ interface ToolEntry {
2
+ id: string;
3
+ label: string;
4
+ description: string;
5
+ parameters?: Record<string, any>;
6
+ }
7
+ export declare const TOOL_REGISTRY_SNAPSHOT: Record<string, ToolEntry>;
8
+ export {};
@@ -0,0 +1,40 @@
1
+ import type { NodeTypeName } from './schema';
2
+ export type ExternalRefKind = 'model' | 'clefModel' | 'tool' | 'composioSlug' | 'memo' | 'worker' | 'secret';
3
+ export interface FieldSpec {
4
+ name: string;
5
+ type: 'string' | 'template' | 'ref' | 'ref[]' | 'number' | 'integer' | 'boolean' | 'enum' | 'object' | 'array';
6
+ required: boolean;
7
+ persisted: boolean;
8
+ default?: unknown;
9
+ enum?: readonly string[];
10
+ min?: number;
11
+ max?: number;
12
+ description: string;
13
+ externalRef?: ExternalRefKind;
14
+ }
15
+ export interface NodeSpec {
16
+ type: NodeTypeName;
17
+ label: string;
18
+ idPrefix: string;
19
+ summary: string;
20
+ fields: FieldSpec[];
21
+ outputs: {
22
+ name: string;
23
+ type?: string;
24
+ path: string;
25
+ description: string;
26
+ }[];
27
+ handles: {
28
+ target: boolean;
29
+ source: 'none' | 'single' | 'classifier';
30
+ };
31
+ refFields: {
32
+ templates: string[];
33
+ nestedTemplates: string[];
34
+ directRefs: string[];
35
+ };
36
+ discovery: Partial<Record<ExternalRefKind, string>>;
37
+ example: Record<string, unknown>;
38
+ }
39
+ export declare const NODE_CATALOG: Readonly<Record<NodeTypeName, NodeSpec>>;
40
+ export declare function defaultNodeData(type: NodeTypeName): Record<string, unknown>;
@@ -0,0 +1,2 @@
1
+ /** Same stem rules as the canvas helper in hx-base classifier-data.ts. */
2
+ export declare function classifierIdFromLabel(label: string, taken: Iterable<string>): string;
@@ -0,0 +1,2 @@
1
+ /** Slugs listed in execution.tools[*].enable. Same result as flattenEnabledToolSlugs. */
2
+ export declare function enabledComposioSlugs(execution: unknown): string[];
@@ -0,0 +1,3 @@
1
+ import type { GraphIssue, WorkerGraph } from './schema';
2
+ /** L4 findings. The value itself is never copied into the issue. */
3
+ export declare function detectInlineCredentials(graph: WorkerGraph): GraphIssue[];
@@ -0,0 +1,11 @@
1
+ export * from './schema';
2
+ export * from './catalog';
3
+ export * from './validate';
4
+ export * from './refs';
5
+ export * from './ops';
6
+ export * from './credentials';
7
+ export * from './templates';
8
+ export * from './composio';
9
+ export * from './classifier';
10
+ export { CLEF_MODELS } from '../constants/clef-models';
11
+ export { TOOL_REGISTRY_SNAPSHOT } from '../constants/tools-registry';
@@ -0,0 +1,21 @@
1
+ import type { GraphIssue, NodeTypeName, WorkerGraph, WorkerOp } from './schema';
2
+ export interface GraphChanges {
3
+ nodesAdded: string[];
4
+ nodesRemoved: string[];
5
+ nodesChanged: string[];
6
+ edgesAdded: string[];
7
+ edgesRemoved: string[];
8
+ }
9
+ export declare function edgeId(source: string, target: string, sourceHandle?: string | null): string;
10
+ export declare function nextNodeId(graph: WorkerGraph, type: NodeTypeName): string;
11
+ /** Stable JSON shape: sorted keys, nodes by id, edges by id. UI keys stay. */
12
+ export declare function canonicalGraph(graph: WorkerGraph): unknown;
13
+ export declare function diffGraphs(before: WorkerGraph, after: WorkerGraph): GraphChanges;
14
+ export declare function applyWorkerOps(graph: WorkerGraph, ops: WorkerOp[]): {
15
+ ok: true;
16
+ graph: WorkerGraph;
17
+ changes: GraphChanges;
18
+ } | {
19
+ ok: false;
20
+ issue: GraphIssue;
21
+ };
@@ -0,0 +1,18 @@
1
+ import type { AuthoringNode, WorkerGraph } from './schema';
2
+ import type { ExternalRefKind } from './catalog';
3
+ export interface ExternalRef {
4
+ kind: ExternalRefKind;
5
+ id: string;
6
+ nodeId: string;
7
+ field: string;
8
+ extra?: Record<string, unknown>;
9
+ }
10
+ /** Template and direct refs the runners actually resolve. jsonPrompt is excluded. */
11
+ export declare function collectNodeRefs(node: AuthoringNode): {
12
+ field: string;
13
+ ref: string;
14
+ }[];
15
+ /** Rewrites ancestor refs, including string leaves of an object or array body. Leaves jsonPrompt, keys, and defaults alone. */
16
+ export declare function rewriteNodeDataRefs(data: Record<string, unknown>, oldId: string, newId: string): Record<string, unknown>;
17
+ export declare function collectExternalRefs(graph: WorkerGraph): ExternalRef[];
18
+ export declare function newExternalRefs(before: WorkerGraph | null, after: WorkerGraph): ExternalRef[];