@arnilo/prism-server 0.0.13 → 0.0.14
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/CHANGELOG.md +6 -0
- package/README.md +2 -0
- package/dist/artifacts.d.ts +199 -0
- package/dist/artifacts.js +719 -0
- package/dist/conversations.d.ts +149 -0
- package/dist/conversations.js +552 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.14] - 2026-07-26
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Durable user-scoped conversation service (`createConversationService`/`createConversationHandler`) and durable artifact service with review/approval/authorized delivery links (`createArtifactService`/`createArtifactHandler`) (Plan 077 Tasks 1, 3).
|
|
8
|
+
|
|
3
9
|
## [0.0.13] - 2026-07-24
|
|
4
10
|
|
|
5
11
|
### Changed
|
package/README.md
CHANGED
|
@@ -26,6 +26,8 @@ const response = await handler(new Request("https://api.example.test/prism/agent
|
|
|
26
26
|
|
|
27
27
|
Routes: direct/SSE agent run, explicitly selected durable agent status/resume through `agentRuns`, direct/SSE workflow run, durable workflow enqueue/status/cancel/resume/replay, and optional ownership-scoped schedule create/list/pause/resume/trigger/delete. `agentRuns` uses core `createAgentRunLifecycle()`; no lifecycle route exists by default. All bodies, responses, events, queues, concurrency, and timeouts are bounded.
|
|
28
28
|
|
|
29
|
+
Optional 0.0.14 co-work handlers (mount beside the API handler): `createConversationHandler` (durable user-scoped conversation threads with reconnectable redacted replay — `createConversationService`) and `createArtifactHandler` (artifact revisions, approve/reject review, expiring authorized delivery links — `createArtifactService` over the existing checkpoint store). Both are ownership-scoped and fail closed without authorization.
|
|
30
|
+
|
|
29
31
|
Optional deployment helpers (compose beside the API handler — no embedded listener):
|
|
30
32
|
|
|
31
33
|
```ts
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { type AgentIdentity, type ArtifactCitation, type ArtifactDeliveryToken, type ArtifactRecord, type ArtifactRevision, type CheckpointStore, type OwnershipScope, type PersistencePage, type SecretRedactor } from "@arnilo/prism";
|
|
2
|
+
import type { PrismRequestHandler, PrismServerAuthorization } from "./types.js";
|
|
3
|
+
/** Phase 9 freeze: artifacts/thread 64/256; revisions 32/128; record 8/64 KiB; preview 16/64 KiB;
|
|
4
|
+
* citations 32/128 and 2/8 KiB each; mime 128/512 B; hash 256/1 KiB; delivery TTL 5 min/24 h;
|
|
5
|
+
* delivery token 4/16 KiB. Compare is exactly 2 revisions (hash+metadata only; host renders content). */
|
|
6
|
+
export declare const DEFAULT_ARTIFACTS_PER_THREAD = 64;
|
|
7
|
+
export declare const HARD_ARTIFACTS_PER_THREAD = 256;
|
|
8
|
+
export declare const DEFAULT_ARTIFACT_REVISIONS = 32;
|
|
9
|
+
export declare const HARD_ARTIFACT_REVISIONS = 128;
|
|
10
|
+
export declare const DEFAULT_ARTIFACT_RECORD_BYTES: number;
|
|
11
|
+
export declare const HARD_ARTIFACT_RECORD_BYTES: number;
|
|
12
|
+
export declare const DEFAULT_ARTIFACT_PREVIEW_BYTES: number;
|
|
13
|
+
export declare const HARD_ARTIFACT_PREVIEW_BYTES: number;
|
|
14
|
+
export declare const DEFAULT_ARTIFACT_CITATIONS = 32;
|
|
15
|
+
export declare const HARD_ARTIFACT_CITATIONS = 128;
|
|
16
|
+
export declare const DEFAULT_ARTIFACT_CITATION_BYTES: number;
|
|
17
|
+
export declare const HARD_ARTIFACT_CITATION_BYTES: number;
|
|
18
|
+
export declare const DEFAULT_ARTIFACT_MIME_BYTES = 128;
|
|
19
|
+
export declare const HARD_ARTIFACT_MIME_BYTES = 512;
|
|
20
|
+
export declare const DEFAULT_ARTIFACT_HASH_BYTES = 256;
|
|
21
|
+
export declare const HARD_ARTIFACT_HASH_BYTES = 1024;
|
|
22
|
+
export declare const DEFAULT_ARTIFACT_URI_BYTES: number;
|
|
23
|
+
export declare const HARD_ARTIFACT_URI_BYTES: number;
|
|
24
|
+
export declare const DEFAULT_ARTIFACT_NOTE_BYTES = 1024;
|
|
25
|
+
export declare const HARD_ARTIFACT_NOTE_BYTES: number;
|
|
26
|
+
export declare const DEFAULT_ARTIFACT_TITLE_BYTES = 256;
|
|
27
|
+
export declare const HARD_ARTIFACT_TITLE_BYTES: number;
|
|
28
|
+
export declare const DEFAULT_ARTIFACT_LIST_PAGE_LIMIT = 50;
|
|
29
|
+
export declare const HARD_ARTIFACT_LIST_PAGE_LIMIT = 200;
|
|
30
|
+
export declare const DEFAULT_DELIVERY_LINK_TTL_SECONDS = 300;
|
|
31
|
+
export declare const HARD_DELIVERY_LINK_TTL_SECONDS: number;
|
|
32
|
+
export declare const DEFAULT_DELIVERY_LINK_TOKEN_BYTES: number;
|
|
33
|
+
export declare const HARD_DELIVERY_LINK_TOKEN_BYTES: number;
|
|
34
|
+
export declare const DEFAULT_ARTIFACT_REQUEST_BYTES: number;
|
|
35
|
+
export declare const HARD_ARTIFACT_REQUEST_BYTES: number;
|
|
36
|
+
export interface ArtifactLimits {
|
|
37
|
+
readonly artifactsPerThread?: number;
|
|
38
|
+
readonly revisionsPerArtifact?: number;
|
|
39
|
+
readonly recordBytes?: number;
|
|
40
|
+
readonly previewBytes?: number;
|
|
41
|
+
readonly citations?: number;
|
|
42
|
+
readonly citationBytes?: number;
|
|
43
|
+
readonly mimeBytes?: number;
|
|
44
|
+
readonly hashBytes?: number;
|
|
45
|
+
readonly uriBytes?: number;
|
|
46
|
+
readonly noteBytes?: number;
|
|
47
|
+
readonly titleBytes?: number;
|
|
48
|
+
readonly listPageLimit?: number;
|
|
49
|
+
readonly deliveryLinkTtlSeconds?: number;
|
|
50
|
+
readonly deliveryLinkTokenBytes?: number;
|
|
51
|
+
readonly maxRequestBytes?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface ResolvedArtifactLimits {
|
|
54
|
+
readonly artifactsPerThread: number;
|
|
55
|
+
readonly revisionsPerArtifact: number;
|
|
56
|
+
readonly recordBytes: number;
|
|
57
|
+
readonly previewBytes: number;
|
|
58
|
+
readonly citations: number;
|
|
59
|
+
readonly citationBytes: number;
|
|
60
|
+
readonly mimeBytes: number;
|
|
61
|
+
readonly hashBytes: number;
|
|
62
|
+
readonly uriBytes: number;
|
|
63
|
+
readonly noteBytes: number;
|
|
64
|
+
readonly titleBytes: number;
|
|
65
|
+
readonly listPageLimit: number;
|
|
66
|
+
readonly deliveryLinkTtlSeconds: number;
|
|
67
|
+
readonly deliveryLinkTokenBytes: number;
|
|
68
|
+
readonly maxRequestBytes: number;
|
|
69
|
+
}
|
|
70
|
+
export declare function resolveArtifactLimits(input?: ArtifactLimits): ResolvedArtifactLimits;
|
|
71
|
+
export interface ArtifactServiceInput {
|
|
72
|
+
readonly ownership: OwnershipScope;
|
|
73
|
+
readonly identity?: AgentIdentity;
|
|
74
|
+
readonly signal?: AbortSignal;
|
|
75
|
+
}
|
|
76
|
+
export interface ArtifactAttachInput extends ArtifactServiceInput {
|
|
77
|
+
readonly threadId: string;
|
|
78
|
+
readonly uri: string;
|
|
79
|
+
readonly mime: string;
|
|
80
|
+
readonly hash: string;
|
|
81
|
+
/** Explicit id makes attach idempotent (get-or-create). Generated when omitted. */
|
|
82
|
+
readonly id?: string;
|
|
83
|
+
readonly title?: string;
|
|
84
|
+
readonly changeNote?: string;
|
|
85
|
+
readonly producerRunId?: string;
|
|
86
|
+
readonly citations?: readonly ArtifactCitation[];
|
|
87
|
+
readonly preview?: Readonly<Record<string, unknown>>;
|
|
88
|
+
}
|
|
89
|
+
export interface ArtifactListInput extends ArtifactServiceInput {
|
|
90
|
+
readonly threadId: string;
|
|
91
|
+
readonly cursor?: string;
|
|
92
|
+
readonly limit?: number;
|
|
93
|
+
}
|
|
94
|
+
export interface ArtifactRefInput extends ArtifactServiceInput {
|
|
95
|
+
readonly threadId: string;
|
|
96
|
+
readonly artifactId: string;
|
|
97
|
+
}
|
|
98
|
+
export interface ArtifactReviseInput extends ArtifactRefInput {
|
|
99
|
+
readonly uri: string;
|
|
100
|
+
/** Defaults to the previous revision's mime when omitted. */
|
|
101
|
+
readonly mime?: string;
|
|
102
|
+
readonly hash: string;
|
|
103
|
+
readonly changeNote?: string;
|
|
104
|
+
readonly producerRunId?: string;
|
|
105
|
+
readonly citations?: readonly ArtifactCitation[];
|
|
106
|
+
readonly preview?: Readonly<Record<string, unknown>>;
|
|
107
|
+
}
|
|
108
|
+
export interface ArtifactCompareInput extends ArtifactRefInput {
|
|
109
|
+
readonly from: number;
|
|
110
|
+
readonly to: number;
|
|
111
|
+
}
|
|
112
|
+
export interface ArtifactCompareResult {
|
|
113
|
+
readonly artifactId: string;
|
|
114
|
+
readonly from: ArtifactRevision;
|
|
115
|
+
readonly to: ArtifactRevision;
|
|
116
|
+
/** Hash+metadata-bounded change flags; the host renders content bodies. */
|
|
117
|
+
readonly changed: {
|
|
118
|
+
readonly hash: boolean;
|
|
119
|
+
readonly mime: boolean;
|
|
120
|
+
readonly uri: boolean;
|
|
121
|
+
readonly citations: boolean;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
export interface ArtifactDecisionInput extends ArtifactRefInput {
|
|
125
|
+
readonly version: number;
|
|
126
|
+
readonly note?: string;
|
|
127
|
+
/** Redacted reviewer ref; derived from identity when omitted. */
|
|
128
|
+
readonly reviewer?: string;
|
|
129
|
+
}
|
|
130
|
+
export interface ArtifactDeliveryInput extends ArtifactRefInput {
|
|
131
|
+
/** Defaults to the last validated revision, else the latest. */
|
|
132
|
+
readonly version?: number;
|
|
133
|
+
readonly ttlSeconds?: number;
|
|
134
|
+
}
|
|
135
|
+
export interface ArtifactDeliveryResult {
|
|
136
|
+
readonly link: string;
|
|
137
|
+
readonly token: ArtifactDeliveryToken;
|
|
138
|
+
}
|
|
139
|
+
export type ArtifactDecisionEvent = {
|
|
140
|
+
readonly type: "artifact_attached" | "artifact_revised";
|
|
141
|
+
readonly artifactId: string;
|
|
142
|
+
readonly threadId: string;
|
|
143
|
+
readonly version: number;
|
|
144
|
+
readonly actor?: string;
|
|
145
|
+
readonly timestamp: string;
|
|
146
|
+
} | {
|
|
147
|
+
readonly type: "artifact_approved" | "artifact_rejected";
|
|
148
|
+
readonly artifactId: string;
|
|
149
|
+
readonly threadId: string;
|
|
150
|
+
readonly version: number;
|
|
151
|
+
readonly reviewer: string;
|
|
152
|
+
readonly timestamp: string;
|
|
153
|
+
};
|
|
154
|
+
export interface CreateArtifactServiceOptions {
|
|
155
|
+
/** Required: records are redacted before persist and on every response. */
|
|
156
|
+
readonly redactor: SecretRedactor;
|
|
157
|
+
/** Host HMAC key material for signing/verifying delivery links. */
|
|
158
|
+
readonly linkSecret: string;
|
|
159
|
+
readonly limits?: ArtifactLimits;
|
|
160
|
+
/** Audit seam (redacted refs only); hosts bridge to @arnilo/prism-policy. */
|
|
161
|
+
readonly onDecision?: (event: ArtifactDecisionEvent) => void | Promise<void>;
|
|
162
|
+
}
|
|
163
|
+
export interface ArtifactService {
|
|
164
|
+
attach(input: ArtifactAttachInput): Promise<ArtifactRecord>;
|
|
165
|
+
list(input: ArtifactListInput): Promise<PersistencePage<ArtifactRecord>>;
|
|
166
|
+
get(input: ArtifactRefInput): Promise<ArtifactRecord>;
|
|
167
|
+
revise(input: ArtifactReviseInput): Promise<ArtifactRecord>;
|
|
168
|
+
compare(input: ArtifactCompareInput): Promise<ArtifactCompareResult>;
|
|
169
|
+
approve(input: ArtifactDecisionInput): Promise<ArtifactRecord>;
|
|
170
|
+
reject(input: ArtifactDecisionInput): Promise<ArtifactRecord>;
|
|
171
|
+
lastValidated(input: ArtifactRefInput): Promise<ArtifactRevision>;
|
|
172
|
+
deliveryLink(input: ArtifactDeliveryInput): Promise<ArtifactDeliveryResult>;
|
|
173
|
+
}
|
|
174
|
+
export declare function createArtifactService(store: CheckpointStore, options: CreateArtifactServiceOptions): ArtifactService;
|
|
175
|
+
/** Sign an expiring delivery token: base64url(payload).base64url(HMAC-SHA256). */
|
|
176
|
+
export declare function signArtifactDeliveryLink(token: ArtifactDeliveryToken, secret: string): string;
|
|
177
|
+
/** Verify signature + expiry and parse a delivery link. Fail-closed on any tamper/expiry. */
|
|
178
|
+
export declare function verifyArtifactDeliveryLink(link: string, secret: string, maxBytes?: number): ArtifactDeliveryToken;
|
|
179
|
+
export type ArtifactOperation = "artifact.attach" | "artifact.list" | "artifact.get" | "artifact.revise" | "artifact.compare" | "artifact.approve" | "artifact.reject" | "artifact.last-validated" | "artifact.delivery-link" | "artifact.download";
|
|
180
|
+
export interface ArtifactAuthorizationInput {
|
|
181
|
+
readonly request: Request;
|
|
182
|
+
readonly operation: ArtifactOperation;
|
|
183
|
+
readonly threadId?: string;
|
|
184
|
+
readonly artifactId?: string;
|
|
185
|
+
/** Present for download: the verified delivery token to reauthorize against. */
|
|
186
|
+
readonly deliveryToken?: ArtifactDeliveryToken;
|
|
187
|
+
readonly signal: AbortSignal;
|
|
188
|
+
}
|
|
189
|
+
export type ArtifactAuthorizer = (input: ArtifactAuthorizationInput) => false | PrismServerAuthorization | Promise<false | PrismServerAuthorization>;
|
|
190
|
+
export interface CreateArtifactHandlerOptions {
|
|
191
|
+
readonly service: ArtifactService;
|
|
192
|
+
readonly authorize: ArtifactAuthorizer;
|
|
193
|
+
readonly linkSecret: string;
|
|
194
|
+
readonly basePath?: string;
|
|
195
|
+
readonly redactor?: SecretRedactor;
|
|
196
|
+
readonly limits?: ArtifactLimits;
|
|
197
|
+
}
|
|
198
|
+
/** Framework-free HTTP adapter for one mounted artifact service (default base `/prism/artifacts`). */
|
|
199
|
+
export declare function createArtifactHandler(options: CreateArtifactHandlerOptions): PrismRequestHandler;
|