@arnilo/prism-server 0.2.9 → 0.3.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.
- package/CHANGELOG.md +5 -0
- package/dist/artifacts.js +2 -2
- package/dist/conversations.js +2 -2
- package/dist/handler/routing.js +2 -1
- package/dist/health.js +3 -2
- package/dist/replay.js +3 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/artifacts.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
2
|
-
import { ARTIFACT_CHECKPOINT_NAMESPACE, ArtifactError, artifactCheckpointKey, assertIdentityActive, assertIdentityMatchesOwnership, CheckpointConflictError, } from "@arnilo/prism";
|
|
2
|
+
import { ARTIFACT_CHECKPOINT_NAMESPACE, ArtifactError, artifactCheckpointKey, assertIdentityActive, assertIdentityMatchesOwnership, CheckpointConflictError, trimTrailingSlashes, } from "@arnilo/prism";
|
|
3
3
|
import { PrismServerError } from "./types.js";
|
|
4
4
|
/** Phase 9 freeze: artifacts/thread 64/256; revisions 32/128; record 8/64 KiB; preview 16/64 KiB;
|
|
5
5
|
* citations 32/128 and 2/8 KiB each; mime 128/512 B; hash 256/1 KiB; delivery TTL 5 min/24 h;
|
|
@@ -664,7 +664,7 @@ function artifactErrorResponse(error) {
|
|
|
664
664
|
function normalizeBasePath(value) {
|
|
665
665
|
if (!value.startsWith("/") || value.includes("?") || value.includes("#"))
|
|
666
666
|
throw new RangeError("basePath must be an absolute URL path");
|
|
667
|
-
const normalized = value.length > 1 ? value
|
|
667
|
+
const normalized = value.length > 1 ? trimTrailingSlashes(value) : value;
|
|
668
668
|
if (normalized === "/")
|
|
669
669
|
throw new RangeError("basePath cannot expose the URL root");
|
|
670
670
|
return normalized;
|
package/dist/conversations.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { assertIdentityActive, assertIdentityMatchesOwnership, CONVERSATION_METADATA_KEY, ConversationError, conversationMarkerMetadata, conversationThreadFromRecord, decodeConversationReplayCursor, encodeConversationReplayCursor, isSessionMetadataConflict, } from "@arnilo/prism";
|
|
2
|
+
import { assertIdentityActive, assertIdentityMatchesOwnership, CONVERSATION_METADATA_KEY, ConversationError, conversationMarkerMetadata, conversationThreadFromRecord, decodeConversationReplayCursor, encodeConversationReplayCursor, isSessionMetadataConflict, trimTrailingSlashes, } from "@arnilo/prism";
|
|
3
3
|
import { PrismServerError } from "./types.js";
|
|
4
4
|
/** Phase 9 freeze: thread page 50/200; replay page 100/500; cursor 4/16 KiB; title 256 B/2 KiB;
|
|
5
5
|
* request id 256 B/2 KiB; active branches 16/64; export 8/32 MiB and 100/500 pages; body 64 KiB/1 MiB. */
|
|
@@ -510,7 +510,7 @@ function conversationErrorResponse(error) {
|
|
|
510
510
|
function normalizeBasePath(value) {
|
|
511
511
|
if (!value.startsWith("/") || value.includes("?") || value.includes("#"))
|
|
512
512
|
throw new RangeError("basePath must be an absolute URL path");
|
|
513
|
-
const normalized = value.length > 1 ? value
|
|
513
|
+
const normalized = value.length > 1 ? trimTrailingSlashes(value) : value;
|
|
514
514
|
if (normalized === "/")
|
|
515
515
|
throw new RangeError("basePath cannot expose the URL root");
|
|
516
516
|
return normalized;
|
package/dist/handler/routing.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** routing (0.2.5 plan 025 Task 1 split). Moved verbatim from handler.ts; public surface unchanged behind the barrel. */
|
|
2
|
+
import { trimTrailingSlashes } from "@arnilo/prism";
|
|
2
3
|
import { PrismServerError } from "../types.js";
|
|
3
4
|
import { validId } from "./readers.js";
|
|
4
5
|
export function parseRoute(request, base) {
|
|
@@ -75,7 +76,7 @@ export function parseRoute(request, base) {
|
|
|
75
76
|
export function normalizeBasePath(value) {
|
|
76
77
|
if (!value.startsWith("/") || value.includes("?") || value.includes("#"))
|
|
77
78
|
throw new RangeError("basePath must be an absolute URL path");
|
|
78
|
-
const normalized = value.length > 1 ? value
|
|
79
|
+
const normalized = value.length > 1 ? trimTrailingSlashes(value) : value;
|
|
79
80
|
if (normalized === "/")
|
|
80
81
|
throw new RangeError("basePath cannot expose the URL root");
|
|
81
82
|
return normalized;
|
package/dist/health.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { trimTrailingSlashes } from "@arnilo/prism";
|
|
1
2
|
import { resolvePrismDeploymentLimits } from "./limits.js";
|
|
2
3
|
import { PrismServerError } from "./types.js";
|
|
3
4
|
const JSON_HEADERS = { "content-type": "application/json; charset=utf-8" };
|
|
@@ -10,7 +11,7 @@ export function createPrismHealthHandler(options = {}) {
|
|
|
10
11
|
throw new PrismServerError("Method not allowed", 405, "ERR_PRISM_SERVER_METHOD");
|
|
11
12
|
}
|
|
12
13
|
const url = new URL(request.url);
|
|
13
|
-
const path = url.pathname
|
|
14
|
+
const path = trimTrailingSlashes(url.pathname) || "/";
|
|
14
15
|
const livePath = `${base}/livez`;
|
|
15
16
|
const readyPath = `${base}/readyz`;
|
|
16
17
|
if (path !== base && path !== livePath && path !== readyPath) {
|
|
@@ -84,7 +85,7 @@ function normalizeHealthBase(basePath) {
|
|
|
84
85
|
if (!basePath.startsWith("/") || basePath.includes("?") || basePath.includes("#")) {
|
|
85
86
|
throw new PrismServerError("Invalid health basePath", 500, "ERR_PRISM_SERVER_CONFIG");
|
|
86
87
|
}
|
|
87
|
-
return basePath
|
|
88
|
+
return trimTrailingSlashes(basePath) || "/health";
|
|
88
89
|
}
|
|
89
90
|
function assertSafeDetail(value) {
|
|
90
91
|
for (const key of Object.keys(value)) {
|
package/dist/replay.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { trimTrailingSlashes } from "@arnilo/prism";
|
|
1
2
|
import { resolvePrismDeploymentLimits } from "./limits.js";
|
|
2
3
|
import { PrismServerError } from "./types.js";
|
|
3
4
|
/** Shared source-backed page/follow adapter. Authorization supplies ownership before each call. */
|
|
@@ -63,14 +64,14 @@ export function createPrismEventReplay(store, options = {}) {
|
|
|
63
64
|
}
|
|
64
65
|
/** Optional HTTP adapter: POST `{ sessionId, runId, cursor? }` → ownership-scoped page. */
|
|
65
66
|
export function createPrismReplayHandler(options) {
|
|
66
|
-
const base = (options.basePath ?? "/prism/replay/events")
|
|
67
|
+
const base = trimTrailingSlashes(options.basePath ?? "/prism/replay/events");
|
|
67
68
|
const limits = resolvePrismDeploymentLimits(options.limits);
|
|
68
69
|
return async (request) => {
|
|
69
70
|
try {
|
|
70
71
|
if (request.method !== "POST") {
|
|
71
72
|
throw new PrismServerError("Method not allowed", 405, "ERR_PRISM_SERVER_METHOD");
|
|
72
73
|
}
|
|
73
|
-
const path = new URL(request.url).pathname
|
|
74
|
+
const path = trimTrailingSlashes(new URL(request.url).pathname);
|
|
74
75
|
if (path !== base)
|
|
75
76
|
throw new PrismServerError("Not found", 404, "ERR_PRISM_SERVER_NOT_FOUND");
|
|
76
77
|
const ownership = await options.authorize(request);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arnilo/prism-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Optional framework-free Web Request-to-Response handler for explicitly selected Prism agents and workflows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"pack:dry-run": "npm pack --dry-run"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@arnilo/prism": "0.
|
|
33
|
-
"@arnilo/prism-workflows": "0.
|
|
32
|
+
"@arnilo/prism": "^0.3.1",
|
|
33
|
+
"@arnilo/prism-workflows": "^0.3.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@arnilo/prism": "file:../..",
|