@hugex/artifact 0.6.7 → 0.7.0
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 +33 -9
- package/dist/artifact/do/ArtifactDO.d.ts +22 -2
- package/dist/artifact/do/publish.d.ts +93 -0
- package/dist/artifact/internal.d.ts +2 -1
- package/dist/artifact/limits.d.ts +13 -0
- package/dist/artifact/mcp/authz.d.ts +1 -0
- package/dist/artifact/mcp/index.d.ts +1 -1
- package/dist/artifact/types.d.ts +142 -5
- package/dist/common/flow-graph/schema.d.ts +1 -1
- package/dist/common/flow-graph/validate.d.ts +4 -1
- package/dist/common/utils/agentMemory.d.ts +1 -0
- package/dist/index.js +85 -44
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,21 +20,31 @@ In `workers/app.ts`, export both classes from this package (same pattern as `Age
|
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
22
|
import { handleArtifactHost } from '@hugex/artifact';
|
|
23
|
+
import { artifactAgentProxy } from '@hugex/ai';
|
|
23
24
|
|
|
24
25
|
export default {
|
|
25
|
-
async fetch(request, env, ctx) {
|
|
26
|
-
const artifactResponse = await handleArtifactHost(request, env, ctx);
|
|
26
|
+
async fetch(request, env, ctx): Promise<Response> {
|
|
27
|
+
const artifactResponse = await handleArtifactHost(request, env, ctx, { agentProxy: artifactAgentProxy });
|
|
27
28
|
if (artifactResponse) return artifactResponse;
|
|
28
|
-
|
|
29
|
-
//
|
|
29
|
+
// The tenant's previous fetch body. It must return a Response.
|
|
30
|
+
// In the hugex tenant that is the rest of workers/app.ts: auth, agents, then React Router.
|
|
31
|
+
return handleExistingTenantFetch(request, env, ctx);
|
|
30
32
|
},
|
|
31
33
|
} satisfies ExportedHandler<Env>;
|
|
32
34
|
|
|
33
|
-
export { AgentDO } from '@hugex/ai';
|
|
35
|
+
export { AgentDO, ArtifactWorkerGateway } from '@hugex/ai';
|
|
34
36
|
export { ArtifactDO, ArtifactIndexDO } from '@hugex/artifact';
|
|
35
37
|
```
|
|
36
38
|
|
|
37
|
-
`handleArtifactHost` returns `null` when the request is not for the artifact host, and a `Response` when it is. On the artifact host the response is terminal: `/mcp`, `/<slug>/`, `/<slug>/k/<key>/`, or 404. Do not fall through to login or agent routes.
|
|
39
|
+
`handleArtifactHost` returns `null` when the request is not for the artifact host, and a `Response` when it is. On the artifact host the response is terminal: `/mcp`, `/<slug>/`, `/<slug>/k/<key>/`, `/<slug>/__hx/agent/<flowId>/<sessionId>`, or 404. Do not fall through to login or agent routes. The fallback `handleExistingTenantFetch` is the handler the Worker already had; it returns a `Response` for every other path.
|
|
40
|
+
|
|
41
|
+
`agentProxy: artifactAgentProxy` is the browser path (`window.hx.worker`). The visitor's own session is checked by that proxy (`authorizeFlowChat` on the forwarded request). `export { ArtifactWorkerGateway }` is the server path (`env.HX.ask` inside `server.js`). The gateway checks the artifact uuid and the grant before it calls `AgentDO`; that identity is the artifact, not the visitor. The two checks are independent: exporting the gateway does not open the browser route, and passing `agentProxy` does not provide `env.HX`. A stored Worker grant does not enable either path by itself.
|
|
42
|
+
|
|
43
|
+
Browser check: a WebSocket upgrade to `/<slug>/__hx/agent/<flowId>/<sessionId>` with the visitor cookie. The proxy receives that request. Without `agentProxy` the same URL is 404.
|
|
44
|
+
|
|
45
|
+
Server check: `ArtifactWorkerGateway` is a function on `ctx.exports` and the compatibility flag `enable_ctx_exports` is set. `workerConnectionSupport` then reports `server: true` even when `agentProxy` is absent. Without the export, `env.HX.ask` fails.
|
|
46
|
+
|
|
47
|
+
The runtime reports a missing path when it can see the host wiring; an unknown wiring emits no warning. Skill: [hugex-artifacts](https://docs.hugex.co/skills/v2/hugex-artifacts/SKILL.md) (`/skills/v<contract>/<skill>/<path>` from the docs publish, contract 2).
|
|
38
48
|
|
|
39
49
|
### 2. Bindings
|
|
40
50
|
|
|
@@ -42,19 +52,29 @@ export { ArtifactDO, ArtifactIndexDO } from '@hugex/artifact';
|
|
|
42
52
|
|
|
43
53
|
```jsonc
|
|
44
54
|
{
|
|
55
|
+
"compatibility_flags": ["enable_ctx_exports"],
|
|
56
|
+
"worker_loaders": [{ "binding": "LOADER" }],
|
|
45
57
|
"durable_objects": {
|
|
46
58
|
"bindings": [
|
|
47
59
|
{ "name": "ARTIFACT", "class_name": "ArtifactDO" },
|
|
48
|
-
{ "name": "ARTIFACT_INDEX", "class_name": "ArtifactIndexDO" }
|
|
60
|
+
{ "name": "ARTIFACT_INDEX", "class_name": "ArtifactIndexDO" },
|
|
61
|
+
{ "name": "AGENT", "class_name": "AgentDO" }
|
|
49
62
|
]
|
|
50
63
|
},
|
|
51
|
-
"
|
|
64
|
+
"services": [{ "binding": "AUTH_SERVER", "service": "hx-oauth" }],
|
|
65
|
+
"migrations": [
|
|
66
|
+
{ "tag": "v2", "new_sqlite_classes": ["AgentDO"] },
|
|
67
|
+
{ "tag": "v3", "new_sqlite_classes": ["ArtifactDO", "ArtifactIndexDO"] }
|
|
68
|
+
],
|
|
52
69
|
"vars": {
|
|
53
|
-
"ARTIFACT_HOST": "
|
|
70
|
+
"ARTIFACT_HOST": "art-<tenant>.hugex.co",
|
|
71
|
+
"HX_CORE_URL": "https://core.example"
|
|
54
72
|
}
|
|
55
73
|
}
|
|
56
74
|
```
|
|
57
75
|
|
|
76
|
+
`enable_ctx_exports` lets the artifact runtime see the exported `ArtifactWorkerGateway`. `LOADER` runs artifact code. `AGENT` is the Durable Object the browser proxy and the gateway both call. `AUTH_SERVER` is the hx-oauth service binding for MCP. Put secret values only in Wrangler secrets or `.dev.vars`, never in this file.
|
|
77
|
+
|
|
58
78
|
Secrets and vars:
|
|
59
79
|
|
|
60
80
|
| Name | Where | Required |
|
|
@@ -64,6 +84,10 @@ Secrets and vars:
|
|
|
64
84
|
| `ARTIFACT_HOST` | production var, e.g. `app-vip.hugex.co` | production only |
|
|
65
85
|
| `ARTIFACT_DEV_PATH` | `.dev.vars` only, e.g. `/app` | local only |
|
|
66
86
|
| `LOADER` | `worker_loaders` binding | yes |
|
|
87
|
+
| `AGENT` | Durable Object binding for `AgentDO` | required for browser and server Worker connections |
|
|
88
|
+
| `enable_ctx_exports` | compatibility flag | required for `env.HX` |
|
|
89
|
+
| `HX_CORE_URL` | var, base URL of hx-core | required to grant a Worker from MCP |
|
|
90
|
+
| `HX_API_KEY` | secret | required for the internal API and for MCP Worker grants |
|
|
67
91
|
|
|
68
92
|
Leave `ARTIFACT_HOST` unset in local dev. With `ARTIFACT_DEV_PATH=/app` the same Worker serves `/app/mcp` and `/app/<slug>/…` on the main host.
|
|
69
93
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DurableObject } from "cloudflare:workers";
|
|
2
|
-
import type { AllowsWorkerInput, AllowsWorkerResult, ArtifactEnv, ArtifactFile, ArtifactFileSummary, ArtifactLogEntry, ArtifactMeta, ArtifactRpc, ArtifactStats, ArtifactVersion, CreateArtifactInput, QueryOptions, QueryResult, SchemaOptions, SchemaResult, SettingsInput, WorkerGrant, WriteInput, WriteResult } from "../types";
|
|
2
|
+
import type { AllowsWorkerInput, AllowsWorkerResult, ArtifactEnv, ArtifactFile, ArtifactFileSummary, ArtifactLogEntry, ArtifactMeta, ArtifactRpc, LogsPage, LogsPageInput, RollbackInput, BeginPublishInput, PublishDraftInput, PublishMutation, StagePublishInput, ArtifactStats, ArtifactVersion, CreateArtifactInput, QueryOptions, QueryResult, SchemaOptions, SchemaResult, SettingsInput, WorkerGrant, WriteInput, WriteResult } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* One instance per artifact (`idFromName(slug)`).
|
|
5
5
|
* Supervisor SQLite holds meta, files, versions, logs, Worker grants, and daily usage counters.
|
|
@@ -31,10 +31,19 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
31
31
|
path: string;
|
|
32
32
|
}): Promise<ArtifactFile[] | null>;
|
|
33
33
|
write(input: WriteInput): Promise<WriteResult>;
|
|
34
|
+
beginPublish(input: BeginPublishInput): Promise<PublishMutation | null>;
|
|
35
|
+
stagePublish(input: StagePublishInput): Promise<PublishMutation | null>;
|
|
36
|
+
getPublish(input: PublishDraftInput): Promise<PublishMutation | null>;
|
|
37
|
+
commitPublish(input: PublishDraftInput): Promise<PublishMutation | null>;
|
|
38
|
+
abortPublish(input: PublishDraftInput): Promise<PublishMutation | null>;
|
|
34
39
|
rollback(input: {
|
|
35
40
|
version: string;
|
|
36
41
|
author: string;
|
|
42
|
+
baseVersion?: string | null;
|
|
37
43
|
}): Promise<WriteResult>;
|
|
44
|
+
rollback(input: RollbackInput & {
|
|
45
|
+
expectUuid: string;
|
|
46
|
+
}): Promise<WriteResult | null>;
|
|
38
47
|
settings(input: SettingsInput): Promise<{
|
|
39
48
|
meta: ArtifactMeta;
|
|
40
49
|
key: string | null;
|
|
@@ -46,6 +55,7 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
46
55
|
limit?: number;
|
|
47
56
|
source?: ArtifactLogEntry["source"];
|
|
48
57
|
}): Promise<ArtifactLogEntry[] | null>;
|
|
58
|
+
logsPage(opts?: LogsPageInput): Promise<LogsPage | null>;
|
|
49
59
|
delete(input: {
|
|
50
60
|
author: string;
|
|
51
61
|
}): Promise<{
|
|
@@ -98,6 +108,16 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
98
108
|
private markFailed;
|
|
99
109
|
/** Active/previous/meta move together, and the index is marked dirty in the same transaction. */
|
|
100
110
|
private promote;
|
|
111
|
+
private applyPromotion;
|
|
112
|
+
private finishPublish;
|
|
113
|
+
private publishDb;
|
|
114
|
+
private expireDraftsNow;
|
|
115
|
+
private beginPublishLocked;
|
|
116
|
+
private stagePublishLocked;
|
|
117
|
+
private readPublishLocked;
|
|
118
|
+
private abortPublishLocked;
|
|
119
|
+
private commitPublishLocked;
|
|
120
|
+
private readBlob;
|
|
101
121
|
private workerGateway;
|
|
102
122
|
private hasWorkerGateway;
|
|
103
123
|
private runtimeId;
|
|
@@ -131,7 +151,7 @@ export declare class ArtifactDO extends DurableObject<ArtifactEnv> implements Ar
|
|
|
131
151
|
private flushIndex;
|
|
132
152
|
private flushLocalIndex;
|
|
133
153
|
private flushOraIndex;
|
|
134
|
-
/**
|
|
154
|
+
/** Shared alarm for index retries and the soonest open draft. The earlier deadline wins. */
|
|
135
155
|
private armIndexAlarm;
|
|
136
156
|
private indexEntry;
|
|
137
157
|
private readMeta;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { ArtifactFileChange, PublishMutation, PublishStatus, WriteResult } from "../types";
|
|
2
|
+
export interface PublishDb {
|
|
3
|
+
exec(sql: string, ...bindings: (string | number | null)[]): void;
|
|
4
|
+
rows(sql: string, ...bindings: (string | number | null)[]): Array<Record<string, string | number | null>>;
|
|
5
|
+
transaction<T>(fn: () => T): T;
|
|
6
|
+
databaseSize(): number;
|
|
7
|
+
}
|
|
8
|
+
export interface DraftRecord {
|
|
9
|
+
id: string;
|
|
10
|
+
artifactUuid: string;
|
|
11
|
+
actor: string;
|
|
12
|
+
baseVersion: string | null;
|
|
13
|
+
message: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
expiresAt: string;
|
|
16
|
+
state: PublishStatus["state"];
|
|
17
|
+
resultJson: string | null;
|
|
18
|
+
error: string | null;
|
|
19
|
+
stagedN: number;
|
|
20
|
+
batchN: number;
|
|
21
|
+
beginFp: string | null;
|
|
22
|
+
}
|
|
23
|
+
export interface StagedFile {
|
|
24
|
+
path: string;
|
|
25
|
+
hash: string | null;
|
|
26
|
+
size: number;
|
|
27
|
+
deleted: boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare function migratePublishSchema(exec: PublishDb["exec"], query: PublishDb["rows"]): void;
|
|
30
|
+
export declare function normalizeActor(actor: unknown): string | null;
|
|
31
|
+
export declare function isPublishUuid(value: unknown): value is string;
|
|
32
|
+
/**
|
|
33
|
+
* Path-sorted batch identity. Each entry is `{ path, contentHash }` where
|
|
34
|
+
* `contentHash` is the sha256 of that file, or null when the path is deleted.
|
|
35
|
+
* File bytes are never concatenated into the canonical string.
|
|
36
|
+
*/
|
|
37
|
+
export declare function hashPublishBatch(changes: ArtifactFileChange[]): Promise<string>;
|
|
38
|
+
export declare function expireDueDrafts(db: PublishDb, nowIso: string): number;
|
|
39
|
+
export declare function soonestOpenExpiryMs(db: PublishDb): number | null;
|
|
40
|
+
export declare function beginDraft(db: PublishDb, input: {
|
|
41
|
+
draftId: string;
|
|
42
|
+
expectUuid: string;
|
|
43
|
+
actor: string;
|
|
44
|
+
baseVersion: string | null;
|
|
45
|
+
message: string;
|
|
46
|
+
paths: string[];
|
|
47
|
+
nowMs: number;
|
|
48
|
+
}): PublishMutation;
|
|
49
|
+
export declare function stageDraft(db: PublishDb, input: {
|
|
50
|
+
draftId: string;
|
|
51
|
+
expectUuid: string;
|
|
52
|
+
actor: string;
|
|
53
|
+
batchId: string;
|
|
54
|
+
changes: ArtifactFileChange[];
|
|
55
|
+
prune: () => void;
|
|
56
|
+
}): Promise<PublishMutation>;
|
|
57
|
+
export declare function readPublish(db: PublishDb, input: {
|
|
58
|
+
draftId: string;
|
|
59
|
+
expectUuid: string;
|
|
60
|
+
actor: string;
|
|
61
|
+
}): PublishMutation;
|
|
62
|
+
export declare function abortDraft(db: PublishDb, input: {
|
|
63
|
+
draftId: string;
|
|
64
|
+
expectUuid: string;
|
|
65
|
+
actor: string;
|
|
66
|
+
}): PublishMutation;
|
|
67
|
+
export interface CommitReady {
|
|
68
|
+
draft: DraftRecord;
|
|
69
|
+
files: Map<string, {
|
|
70
|
+
hash: string;
|
|
71
|
+
size: number;
|
|
72
|
+
}>;
|
|
73
|
+
manifestText: string;
|
|
74
|
+
serverJs: string | null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolves the draft for commit. A stored success is returned as status and must not be activated again.
|
|
78
|
+
* Live base is checked before missing paths. Manifest and server.js are the only contents read.
|
|
79
|
+
*/
|
|
80
|
+
export declare function prepareCommit(db: PublishDb, input: {
|
|
81
|
+
draftId: string;
|
|
82
|
+
expectUuid: string;
|
|
83
|
+
actor: string;
|
|
84
|
+
}, activeVersion: string | null, baseFiles: ReadonlyMap<string, {
|
|
85
|
+
hash: string;
|
|
86
|
+
size: number;
|
|
87
|
+
}>, readBlob: (hash: string) => string | null): PublishMutation | CommitReady;
|
|
88
|
+
export declare function markDraftFailed(db: PublishDb, draftId: string, error: string): void;
|
|
89
|
+
export declare function markDraftCommitted(db: PublishDb, draftId: string, result: Extract<WriteResult, {
|
|
90
|
+
ok: true;
|
|
91
|
+
}>): void;
|
|
92
|
+
/** Drops the oldest aborted and expired headers once the terminal cap is exceeded. Receipts still inside their TTL stay. */
|
|
93
|
+
export declare function trimTerminalDrafts(db: PublishDb): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WorkerConnectionSupport } from "./mcp/context";
|
|
1
2
|
import type { ArtifactEnv, WriteResult } from "./types";
|
|
2
3
|
export declare const INTERNAL_ARTIFACTS_PATH = "/api/internal/artifacts";
|
|
3
4
|
export declare function isInternalArtifactsPath(pathname: string): boolean;
|
|
@@ -6,5 +7,5 @@ export declare function isInternalArtifactsPath(pathname: string): boolean;
|
|
|
6
7
|
* A missing or empty `HX_API_KEY` is always unauthorized.
|
|
7
8
|
*/
|
|
8
9
|
export declare function authorizeInternal(request: Request, env: ArtifactEnv): boolean;
|
|
9
|
-
export declare function handleArtifactInternal(request: Request, env: ArtifactEnv): Promise<Response>;
|
|
10
|
+
export declare function handleArtifactInternal(request: Request, env: ArtifactEnv, support?: WorkerConnectionSupport): Promise<Response>;
|
|
10
11
|
export declare function writeHttpStatus(result: WriteResult): number;
|
|
@@ -18,6 +18,19 @@ export declare const LIMITS: {
|
|
|
18
18
|
/** Default window for `stats()`. */
|
|
19
19
|
readonly statsDefaultDays: 30;
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Local caps for `artifact_publish`. Pending bytes are UTF-8 staged content
|
|
23
|
+
* across open drafts of one artifact, counted before each insert.
|
|
24
|
+
*/
|
|
25
|
+
export declare const PUBLISH_LIMITS: {
|
|
26
|
+
readonly ttlMs: number;
|
|
27
|
+
readonly maxOpenDrafts: 3;
|
|
28
|
+
readonly maxPaths: 500;
|
|
29
|
+
readonly maxBatches: 100;
|
|
30
|
+
/** Aborted and expired draft headers kept after their child rows are gone. */
|
|
31
|
+
readonly maxTerminalDrafts: 64;
|
|
32
|
+
readonly pendingBytes: number;
|
|
33
|
+
};
|
|
21
34
|
/**
|
|
22
35
|
* compatibilityDate pinned on every Dynamic Worker.
|
|
23
36
|
* The outer tenant worker can stay older; the loader sets this on the facet isolate.
|
|
@@ -32,6 +32,7 @@ export declare const TOOL_PERMISSION: {
|
|
|
32
32
|
readonly artifact_query: 'use';
|
|
33
33
|
readonly artifact_url: 'use';
|
|
34
34
|
readonly artifact_write: 'manage';
|
|
35
|
+
readonly artifact_publish: 'manage';
|
|
35
36
|
readonly artifact_rollback: 'manage';
|
|
36
37
|
readonly artifact_settings: 'manage';
|
|
37
38
|
readonly artifact_versions: 'use';
|
|
@@ -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.
|
|
8
|
+
export declare const SERVER_VERSION = "2.4.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';
|
package/dist/artifact/types.d.ts
CHANGED
|
@@ -169,6 +169,46 @@ export interface ArtifactLogEntry {
|
|
|
169
169
|
message: string;
|
|
170
170
|
version: string | null;
|
|
171
171
|
}
|
|
172
|
+
export interface LogsPageInput {
|
|
173
|
+
limit?: number;
|
|
174
|
+
source?: ArtifactLogEntry['source'];
|
|
175
|
+
level?: ArtifactLogEntry['level'];
|
|
176
|
+
/** Active or historical version id. Empty and overlong values are invalid. */
|
|
177
|
+
version?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Positive decimal log id, no leading zeros, within Number.MAX_SAFE_INTEGER.
|
|
180
|
+
* The page returns rows with `id < cursor`.
|
|
181
|
+
*/
|
|
182
|
+
cursor?: string;
|
|
183
|
+
/**
|
|
184
|
+
* When set, must equal the live artifact uuid. A mismatch returns null so a
|
|
185
|
+
* reused slug does not leak the new artifact's logs.
|
|
186
|
+
*/
|
|
187
|
+
expectUuid?: string;
|
|
188
|
+
}
|
|
189
|
+
export interface LogsPage {
|
|
190
|
+
logs: ArtifactLogEntry[];
|
|
191
|
+
nextCursor: string | null;
|
|
192
|
+
}
|
|
193
|
+
interface RollbackFields {
|
|
194
|
+
version: string;
|
|
195
|
+
author: string;
|
|
196
|
+
/**
|
|
197
|
+
* Absent: no precondition (previous clients).
|
|
198
|
+
* `null`: the active version must be null.
|
|
199
|
+
* A string must equal the active version id.
|
|
200
|
+
* Compared inside the write lock, before the target version is read or activated.
|
|
201
|
+
*/
|
|
202
|
+
baseVersion?: string | null;
|
|
203
|
+
}
|
|
204
|
+
/** Previous callers. The result is never null. */
|
|
205
|
+
export interface RollbackWithoutUuid extends RollbackFields {
|
|
206
|
+
}
|
|
207
|
+
/** Uuid check. Null when the artifact is missing or the uuid no longer matches. */
|
|
208
|
+
export interface RollbackWithUuid extends RollbackFields {
|
|
209
|
+
expectUuid: string;
|
|
210
|
+
}
|
|
211
|
+
export type RollbackInput = RollbackWithoutUuid | RollbackWithUuid;
|
|
172
212
|
export interface CreateArtifactInput {
|
|
173
213
|
slug: string;
|
|
174
214
|
title: string;
|
|
@@ -207,6 +247,77 @@ export type WriteResult = {
|
|
|
207
247
|
state: 'fallida';
|
|
208
248
|
error: string;
|
|
209
249
|
};
|
|
250
|
+
export type PublishState = 'open' | 'committed' | 'aborted' | 'expired';
|
|
251
|
+
/**
|
|
252
|
+
* Progress for one publish draft. `result` is the stored commit and is present
|
|
253
|
+
* only after success, until the original TTL. File contents are never included.
|
|
254
|
+
*/
|
|
255
|
+
export interface PublishStatus {
|
|
256
|
+
ok: true;
|
|
257
|
+
draftId: string;
|
|
258
|
+
baseVersion: string | null;
|
|
259
|
+
expiresAt: string;
|
|
260
|
+
state: PublishState;
|
|
261
|
+
missingPaths: string[];
|
|
262
|
+
stagedPaths: number;
|
|
263
|
+
batchCount: number;
|
|
264
|
+
result: Extract<WriteResult, {
|
|
265
|
+
ok: true;
|
|
266
|
+
}> | null;
|
|
267
|
+
error: string | null;
|
|
268
|
+
}
|
|
269
|
+
export type PublishFailure = {
|
|
270
|
+
ok: false;
|
|
271
|
+
code: 'conflict';
|
|
272
|
+
activeVersion: string | null;
|
|
273
|
+
draftId: string;
|
|
274
|
+
} | {
|
|
275
|
+
ok: false;
|
|
276
|
+
code: 'missing';
|
|
277
|
+
missingPaths: string[];
|
|
278
|
+
draftId: string;
|
|
279
|
+
} | {
|
|
280
|
+
ok: false;
|
|
281
|
+
code: 'invalid';
|
|
282
|
+
error: string;
|
|
283
|
+
} | {
|
|
284
|
+
ok: false;
|
|
285
|
+
code: 'limit';
|
|
286
|
+
error: string;
|
|
287
|
+
} | {
|
|
288
|
+
ok: false;
|
|
289
|
+
code: 'forbidden';
|
|
290
|
+
error: string;
|
|
291
|
+
} | {
|
|
292
|
+
ok: false;
|
|
293
|
+
code: 'failed';
|
|
294
|
+
version: string;
|
|
295
|
+
state: 'fallida';
|
|
296
|
+
error: string;
|
|
297
|
+
draftId: string;
|
|
298
|
+
};
|
|
299
|
+
export type PublishMutation = PublishStatus | PublishFailure;
|
|
300
|
+
interface PublishIdentity {
|
|
301
|
+
/** Client-assigned UUID. A repeat of begin with the same id is idempotent. */
|
|
302
|
+
draftId: string;
|
|
303
|
+
/** Must equal the live artifact uuid. A reused slug returns null. */
|
|
304
|
+
expectUuid: string;
|
|
305
|
+
/** Authenticated actor. The DO checks the draft holder; it does not apply ACL. */
|
|
306
|
+
actor: string;
|
|
307
|
+
}
|
|
308
|
+
export interface BeginPublishInput extends PublishIdentity {
|
|
309
|
+
/** Declared base. Compared with the live version inside the commit lock. */
|
|
310
|
+
baseVersion: string | null;
|
|
311
|
+
message: string;
|
|
312
|
+
/** Exact paths this draft may change, including deletions. */
|
|
313
|
+
paths: string[];
|
|
314
|
+
}
|
|
315
|
+
export interface StagePublishInput extends PublishIdentity {
|
|
316
|
+
/** Client-assigned UUID. The same id with the same changes is idempotent. */
|
|
317
|
+
batchId: string;
|
|
318
|
+
changes: ArtifactFileChange[];
|
|
319
|
+
}
|
|
320
|
+
export type PublishDraftInput = PublishIdentity;
|
|
210
321
|
export interface SettingsInput {
|
|
211
322
|
group?: ArtifactGroup;
|
|
212
323
|
public?: boolean;
|
|
@@ -288,11 +399,29 @@ export interface ArtifactRpc {
|
|
|
288
399
|
path: string;
|
|
289
400
|
}): Promise<ArtifactFile[] | null>;
|
|
290
401
|
write(input: WriteInput): Promise<WriteResult>;
|
|
291
|
-
/**
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
402
|
+
/**
|
|
403
|
+
* Opens a draft for a later atomic commit. Null when the artifact is missing
|
|
404
|
+
* or `expectUuid` does not match the live row.
|
|
405
|
+
*/
|
|
406
|
+
beginPublish(input: BeginPublishInput): Promise<PublishMutation | null>;
|
|
407
|
+
/** Stages one batch. Validates every change, then persists them in one transaction. */
|
|
408
|
+
stagePublish(input: StagePublishInput): Promise<PublishMutation | null>;
|
|
409
|
+
/** Progress and any stored commit result. No file contents. */
|
|
410
|
+
getPublish(input: PublishDraftInput): Promise<PublishMutation | null>;
|
|
411
|
+
/**
|
|
412
|
+
* Promotes the draft once. A later call returns the stored success without
|
|
413
|
+
* activating again or emitting reload, including after another write.
|
|
414
|
+
*/
|
|
415
|
+
commitPublish(input: PublishDraftInput): Promise<PublishMutation | null>;
|
|
416
|
+
/** Idempotent for the holder. A committed draft stays published. */
|
|
417
|
+
abortPublish(input: PublishDraftInput): Promise<PublishMutation | null>;
|
|
418
|
+
/**
|
|
419
|
+
* Re-activates an older version's code (data is untouched). Same result shape as write.
|
|
420
|
+
* Callers that omit `expectUuid` always receive `WriteResult`. With `expectUuid`, null
|
|
421
|
+
* means the artifact is missing or its uuid changed, and nothing was activated.
|
|
422
|
+
*/
|
|
423
|
+
rollback(input: RollbackWithoutUuid): Promise<WriteResult>;
|
|
424
|
+
rollback(input: RollbackWithUuid): Promise<WriteResult | null>;
|
|
296
425
|
settings(input: SettingsInput): Promise<{
|
|
297
426
|
meta: ArtifactMeta;
|
|
298
427
|
key: string | null;
|
|
@@ -300,10 +429,17 @@ export interface ArtifactRpc {
|
|
|
300
429
|
versions(opts?: {
|
|
301
430
|
limit?: number;
|
|
302
431
|
}): Promise<ArtifactVersion[] | null>;
|
|
432
|
+
/** Newest first. The array shape stays `ArtifactLogEntry` (no id, no cursor). */
|
|
303
433
|
logs(opts?: {
|
|
304
434
|
limit?: number;
|
|
305
435
|
source?: ArtifactLogEntry['source'];
|
|
306
436
|
}): Promise<ArtifactLogEntry[] | null>;
|
|
437
|
+
/**
|
|
438
|
+
* Same retention as `logs`. `id < cursor`, DESC by id, parameterized WHERE, then LIMIT.
|
|
439
|
+
* One extra row decides `nextCursor`. Null when the artifact does not exist.
|
|
440
|
+
* Invalid limit, source, level, version, or cursor throws.
|
|
441
|
+
*/
|
|
442
|
+
logsPage(opts?: LogsPageInput): Promise<LogsPage | null>;
|
|
307
443
|
query(sql: string, opts?: QueryOptions): Promise<QueryResult>;
|
|
308
444
|
schema(opts?: SchemaOptions): Promise<SchemaResult>;
|
|
309
445
|
/** Removes the artifact, index row, and hx-ora tombstone. Returns null if the slug was never created. */
|
|
@@ -356,3 +492,4 @@ export interface ArtifactIndexRpc {
|
|
|
356
492
|
export declare const HX_HEADER_KEY = "x-hx-artifact-key";
|
|
357
493
|
/** Public base path of the artifact including trailing slash, e.g. `/demo/k/abc/` or `/app/demo/`. */
|
|
358
494
|
export declare const HX_HEADER_BASE = "x-hx-artifact-base";
|
|
495
|
+
export {};
|
|
@@ -23,7 +23,7 @@ export interface WorkerGraph {
|
|
|
23
23
|
}
|
|
24
24
|
export type IssueSeverity = 'error' | 'warning';
|
|
25
25
|
export type CredentialKind = 'bearer_token' | 'basic_auth' | 'known_token' | 'url_userinfo' | 'url_query' | 'sensitive_key' | 'high_entropy';
|
|
26
|
-
export type IssueCode = 'missing_state' | 'schema_version' | 'var_mapping' | 'classifier_invalid' | 'classifier_edge_missing' | 'out_vars_invalid' | 'start_count' | 'answer_missing' | 'dead_end' | 'unknown_node_type' | 'duplicate_node_id' | 'invalid_node_id' | 'node_id_collides_with_input' | 'edge_unknown_node' | 'edge_bad_handle' | 'edge_duplicate' | 'start_has_input' | 'answer_has_output' | 'multiple_outgoing' | 'field_type' | 'field_required' | 'field_range' | 'field_enum' | 'ref_syntax' | 'ref_unknown_node' | 'ref_out_of_scope' | 'ref_unknown_output' | 'ref_binary_not_allowed' | 'start_input_invalid' | 'answer_mapping_invalid' | 'worker_self_reference' | 'classifier_error_unrouted' | 'classifier_handle_inactive' | 'unreachable_node' | 'graph_cycle' | 'crawl_prompt_literal' | 'model_unknown' | 'param_unsupported' | 'reasoning_effort_unsupported' | 'tool_unavailable' | 'tool_kind_mismatch' | 'skill_unavailable' | 'builtin_unknown' | 'tool_args_invalid' | 'tool_args_unknown' | 'composio_slug_disabled' | 'composio_schema_missing' | 'memo_unavailable' | 'worker_unavailable' | 'worker_child_no_output' | 'worker_inputs_mismatch' | 'worker_child_inactive_forbidden' | 'worker_child_inactive' | 'secret_unknown' | 'secret_check_skipped' | 'inline_credential' | 'op_invalid' | 'op_unknown_node' | 'already_connected' | 'edge_not_found' | 'edge_ambiguous' | 'cannot_remove_start';
|
|
26
|
+
export type IssueCode = 'missing_state' | 'schema_version' | 'var_mapping' | 'classifier_invalid' | 'classifier_edge_missing' | 'out_vars_invalid' | 'start_count' | 'answer_missing' | 'dead_end' | 'unknown_node_type' | 'duplicate_node_id' | 'invalid_node_id' | 'node_id_collides_with_input' | 'edge_unknown_node' | 'edge_bad_handle' | 'edge_duplicate' | 'start_has_input' | 'answer_has_output' | 'multiple_outgoing' | 'field_type' | 'field_required' | 'field_range' | 'field_enum' | 'ref_syntax' | 'ref_unknown_node' | 'ref_out_of_scope' | 'ref_unknown_output' | 'ref_binary_not_allowed' | 'start_input_invalid' | 'answer_mapping_invalid' | 'worker_self_reference' | 'classifier_error_unrouted' | 'classifier_handle_inactive' | 'unreachable_node' | 'graph_cycle' | 'crawl_prompt_literal' | 'model_unknown' | 'param_unsupported' | 'reasoning_effort_unsupported' | 'tool_unavailable' | 'tool_kind_mismatch' | 'skill_unavailable' | 'builtin_unknown' | 'tool_args_invalid' | 'tool_args_unknown' | 'composio_slug_disabled' | 'composio_schema_missing' | 'memo_unavailable' | 'worker_unavailable' | 'worker_child_no_output' | 'worker_inputs_mismatch' | 'worker_child_inactive_forbidden' | 'worker_child_inactive' | 'secret_unknown' | 'secret_check_skipped' | 'personal_memory_inactive' | 'inline_credential' | 'op_invalid' | 'op_unknown_node' | 'already_connected' | 'edge_not_found' | 'edge_ambiguous' | 'cannot_remove_start';
|
|
27
27
|
export interface GraphIssue {
|
|
28
28
|
code: IssueCode;
|
|
29
29
|
severity: IssueSeverity;
|
|
@@ -55,6 +55,7 @@ export declare const ISSUE_SEVERITY: {
|
|
|
55
55
|
readonly worker_child_inactive: 'advisory';
|
|
56
56
|
readonly secret_unknown: 'advisory';
|
|
57
57
|
readonly secret_check_skipped: 'advisory';
|
|
58
|
+
readonly personal_memory_inactive: 'advisory';
|
|
58
59
|
readonly inline_credential: 'blocking';
|
|
59
60
|
readonly op_invalid: 'blocking';
|
|
60
61
|
readonly op_unknown_node: 'blocking';
|
|
@@ -66,7 +67,9 @@ export declare const ISSUE_SEVERITY: {
|
|
|
66
67
|
/** L1, same order and same messages as FlowEngine.validateFlowStart. */
|
|
67
68
|
export declare function validateFlowStructure(graph: unknown): GraphIssue[];
|
|
68
69
|
/** L2 authoring issues, with intrinsic severity. Final severity is classifyIssues. */
|
|
69
|
-
export declare function validateAuthoring(graph: WorkerGraph
|
|
70
|
+
export declare function validateAuthoring(graph: WorkerGraph, opts?: {
|
|
71
|
+
flowType?: string;
|
|
72
|
+
}): GraphIssue[];
|
|
70
73
|
/** Fingerprint of code, node, field, ref, and credential kind. Message and op are excluded. */
|
|
71
74
|
export declare function issueFingerprint(issue: GraphIssue): string;
|
|
72
75
|
export declare function classifyIssues(before: GraphIssue[], after: GraphIssue[], opts?: {
|
|
@@ -21,6 +21,7 @@ export declare function capMemoryContent(content: string, maxTokens: number): {
|
|
|
21
21
|
truncated: boolean;
|
|
22
22
|
};
|
|
23
23
|
export declare function isStartMemoryEnabled(data: Record<string, unknown> | undefined | null): boolean;
|
|
24
|
+
export declare function isPersonalMemoryEnabled(data: Record<string, unknown> | undefined | null): boolean;
|
|
24
25
|
export declare function startMemoryModel(data: Record<string, unknown> | undefined | null): string;
|
|
25
26
|
export declare function startMemoryLength(data: Record<string, unknown> | undefined | null): MemoryLength;
|
|
26
27
|
/** Reasoning models spend output budget on thinking; request extra tokens then cap the document. */
|