@inflexa-ai/harness 0.21.1 → 0.22.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/dist/agents/report-session-agent.d.ts +13 -1
- package/dist/agents/report-session-agent.js +3 -1
- package/dist/contracts/content-url.d.ts +43 -8
- package/dist/contracts/content-url.js +50 -8
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/runtime/assemble.d.ts +14 -1
- package/dist/runtime/assemble.js +2 -0
- package/dist/tools/report-session/examine-page.d.ts +22 -9
- package/dist/tools/report-session/examine-page.js +19 -7
- package/dist/tools/report-session/index.d.ts +3 -2
- package/dist/tools/report-session/index.js +1 -0
- package/dist/tools/report-session/preview-report.d.ts +27 -4
- package/dist/tools/report-session/preview-report.js +39 -4
- package/dist/tools/report-session/session-page-publisher.d.ts +55 -0
- package/dist/tools/report-session/session-page-publisher.js +42 -0
- package/package.json +2 -2
|
@@ -38,7 +38,7 @@ import type { ThreadStore } from "../memory/thread-store.js";
|
|
|
38
38
|
import type { ReferenceResolver } from "../report-model/reference-resolver.js";
|
|
39
39
|
import type { ReportVersionStore } from "../state/report-versions.js";
|
|
40
40
|
import type { ReportSessionStateGateway } from "../tools/report-authoring/authoring-tools.js";
|
|
41
|
-
import { type ResolvePageAsset } from "../tools/report-session/index.js";
|
|
41
|
+
import { type ResolvePageAsset, type ResolvePageUrl, type SessionPagePublisher } from "../tools/report-session/index.js";
|
|
42
42
|
/** Canonical agent id -- distinct from the id of the old templating agent. */
|
|
43
43
|
export declare const REPORT_SESSION_AGENT_ID: "report-session";
|
|
44
44
|
/**
|
|
@@ -98,6 +98,18 @@ export interface ReportSessionAgentDeps {
|
|
|
98
98
|
* installation of the harness.
|
|
99
99
|
*/
|
|
100
100
|
readonly resolvePageAsset?: ResolvePageAsset;
|
|
101
|
+
/**
|
|
102
|
+
* Session-page publisher -- the hosted view of the rendered page. Bound, the preview
|
|
103
|
+
* tool mints one grant after the page lands and attaches the URL beside the path.
|
|
104
|
+
* Omitted, the result carries the page path alone.
|
|
105
|
+
*/
|
|
106
|
+
readonly sessionPages?: SessionPagePublisher;
|
|
107
|
+
/**
|
|
108
|
+
* Page-URL formation of the eyes -- the URL that one look opens. A composition whose
|
|
109
|
+
* browser cannot reach the workspace tree binds a resolver that names a served URL.
|
|
110
|
+
* Omitted, the eyes tool navigates through a `file://` URL of the page path.
|
|
111
|
+
*/
|
|
112
|
+
readonly resolvePageUrl?: ResolvePageUrl;
|
|
101
113
|
/** Operational logging seam; omitted falls back to no-op. */
|
|
102
114
|
readonly logger?: Logger;
|
|
103
115
|
}
|
|
@@ -39,7 +39,7 @@ const REPORT_SESSION_MAX_ITERATIONS = 75;
|
|
|
39
39
|
/** Build the report `AgentDefinition` with every tool bound to its deps. */
|
|
40
40
|
export function createReportSessionAgent(deps) {
|
|
41
41
|
const { model, pool, embedding, workspaceFs, gateway, resolveWorkspaceRoot, store, threads, chrome, eyes, makeResolver, resolvePageAsset, logger } = deps;
|
|
42
|
-
const { derivations, sandboxClient, runAuthorizer } = deps;
|
|
42
|
+
const { derivations, sandboxClient, runAuthorizer, sessionPages, resolvePageUrl } = deps;
|
|
43
43
|
const authoring = createReportAuthoringTools(gateway);
|
|
44
44
|
const tools = [
|
|
45
45
|
// The read surface toward the analysis. It roams the tree read-only.
|
|
@@ -83,6 +83,7 @@ export function createReportSessionAgent(deps) {
|
|
|
83
83
|
resolveWorkspaceRoot,
|
|
84
84
|
...(makeResolver ? { makeResolver } : {}),
|
|
85
85
|
...(resolvePageAsset ? { resolvePageAsset } : {}),
|
|
86
|
+
...(sessionPages ? { sessionPages } : {}),
|
|
86
87
|
...(logger ? { logger } : {}),
|
|
87
88
|
}),
|
|
88
89
|
// The eyes tool. It opens the rendered page in headless Chrome.
|
|
@@ -91,6 +92,7 @@ export function createReportSessionAgent(deps) {
|
|
|
91
92
|
resolveWorkspaceRoot,
|
|
92
93
|
chrome,
|
|
93
94
|
...(eyes ? { eyes } : {}),
|
|
95
|
+
...(resolvePageUrl ? { resolvePageUrl } : {}),
|
|
94
96
|
...(logger ? { logger } : {}),
|
|
95
97
|
}),
|
|
96
98
|
// The record tool. It gates the whole document, records one version, then prunes each
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Content URL construction — shared between the frontend and Cortex.
|
|
3
3
|
*
|
|
4
|
-
* The `res` claim
|
|
5
|
-
* for the content-token
|
|
6
|
-
* sides are locked by the shared test
|
|
7
|
-
* `src/__tests__/fixtures/preview-res.json
|
|
4
|
+
* The `res` claim formulas and URL shapes are the canonical TypeScript contract
|
|
5
|
+
* for the content-token flow. The storage backend mirrors each formula in Go; both
|
|
6
|
+
* sides are locked by the shared test vectors at
|
|
7
|
+
* `src/__tests__/fixtures/preview-res.json` (previews) and
|
|
8
|
+
* `src/__tests__/fixtures/report-session-res.json` (report-session pages), each a
|
|
9
|
+
* byte-identical copy of the storage backend's `kernel/contenttoken/testdata` file.
|
|
8
10
|
*
|
|
9
|
-
* End-to-end contract:
|
|
11
|
+
* End-to-end contract (previews):
|
|
10
12
|
* token res claim : "previews/{analysisId}/{previewId}"
|
|
11
13
|
* URL : {contentBaseUrl}/previews/{analysisId}/{previewId}/{previewPath}?t={token}
|
|
12
14
|
* Caddy predicate : request.path.startsWith("/" + res + "/")
|
|
13
15
|
*
|
|
16
|
+
* End-to-end contract (report-session pages):
|
|
17
|
+
* token res claim : "report-sessions/{analysisId}/{threadId}" (token kind "rs")
|
|
18
|
+
* URL : {contentBaseUrl}/report-sessions/{analysisId}/{threadId}/{pagePath}?t={token}
|
|
19
|
+
* Caddy predicate : request.path.startsWith("/" + res + "/")
|
|
20
|
+
*
|
|
14
21
|
* This is URL space only. On disk a preview lives inside its analysis's workspace tree, at
|
|
15
22
|
* `{resolveWorkspaceRoot(analysisId)}/previews/{previewId}/{previewPath}` (the workspace-layout
|
|
16
|
-
* spec)
|
|
17
|
-
*
|
|
18
|
-
*
|
|
23
|
+
* spec), and a session page at `{resolveWorkspaceRoot(analysisId)}/report-sessions/{threadId}/{pagePath}`
|
|
24
|
+
* (the report-session-agent spec) — the `res` claim carries the analysis id because the URL needs an
|
|
25
|
+
* authorization boundary, whereas the resolved root already identifies the analysis and so does not
|
|
26
|
+
* repeat it. A host that serves either space owns the map between the two.
|
|
19
27
|
*
|
|
20
28
|
* The harness's contracts module owns this TS implementation so both the harness and
|
|
21
29
|
* react-client consume one canonical formula.
|
|
@@ -47,3 +55,30 @@ export declare function previewResourceId(analysisId: string, previewId: string)
|
|
|
47
55
|
* @param token - Short-lived content token minted by the storage backend (required)
|
|
48
56
|
*/
|
|
49
57
|
export declare function buildPreviewUrl(contentBaseUrl: string, analysisId: string, previewId: string, previewPath: string, token: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Canonical `res` claim formula for a report-session page. Returns the literal string
|
|
60
|
+
* `report-sessions/{analysisId}/{threadId}` with no leading or trailing slash.
|
|
61
|
+
*
|
|
62
|
+
* This is the URL sub-path served by the content-server (Caddy) and the token's
|
|
63
|
+
* authorization boundary — NOT a filesystem sub-path; see the module doc.
|
|
64
|
+
*
|
|
65
|
+
* MUST match `fmt.Sprintf("report-sessions/%s/%s", analysisID, threadID)` in
|
|
66
|
+
* the storage backend's Go `kernel/contenttoken` implementation. Drift is caught by the
|
|
67
|
+
* shared test vector at `src/__tests__/fixtures/report-session-res.json`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function reportSessionResourceId(analysisId: string, threadId: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Build a content-token URL for a report-session page.
|
|
72
|
+
*
|
|
73
|
+
* Produces `{contentBaseUrl}/{res}/{pagePath}?t={token}` where `res` is
|
|
74
|
+
* the output of `reportSessionResourceId(analysisId, threadId)`. The query parameter
|
|
75
|
+
* name is `t` (matching Caddy's `from_query t` directive). The token is
|
|
76
|
+
* URL-encoded.
|
|
77
|
+
*
|
|
78
|
+
* @param contentBaseUrl - Content server base URL (trailing slash tolerated)
|
|
79
|
+
* @param analysisId - The analysis ID (authorization boundary)
|
|
80
|
+
* @param threadId - The report thread ID (one session directory per thread)
|
|
81
|
+
* @param pagePath - Session-relative path (typically "index.html"). Leading slash tolerated.
|
|
82
|
+
* @param token - Short-lived content token minted by the storage backend (required)
|
|
83
|
+
*/
|
|
84
|
+
export declare function buildReportSessionUrl(contentBaseUrl: string, analysisId: string, threadId: string, pagePath: string, token: string): string;
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Content URL construction — shared between the frontend and Cortex.
|
|
3
3
|
*
|
|
4
|
-
* The `res` claim
|
|
5
|
-
* for the content-token
|
|
6
|
-
* sides are locked by the shared test
|
|
7
|
-
* `src/__tests__/fixtures/preview-res.json
|
|
4
|
+
* The `res` claim formulas and URL shapes are the canonical TypeScript contract
|
|
5
|
+
* for the content-token flow. The storage backend mirrors each formula in Go; both
|
|
6
|
+
* sides are locked by the shared test vectors at
|
|
7
|
+
* `src/__tests__/fixtures/preview-res.json` (previews) and
|
|
8
|
+
* `src/__tests__/fixtures/report-session-res.json` (report-session pages), each a
|
|
9
|
+
* byte-identical copy of the storage backend's `kernel/contenttoken/testdata` file.
|
|
8
10
|
*
|
|
9
|
-
* End-to-end contract:
|
|
11
|
+
* End-to-end contract (previews):
|
|
10
12
|
* token res claim : "previews/{analysisId}/{previewId}"
|
|
11
13
|
* URL : {contentBaseUrl}/previews/{analysisId}/{previewId}/{previewPath}?t={token}
|
|
12
14
|
* Caddy predicate : request.path.startsWith("/" + res + "/")
|
|
13
15
|
*
|
|
16
|
+
* End-to-end contract (report-session pages):
|
|
17
|
+
* token res claim : "report-sessions/{analysisId}/{threadId}" (token kind "rs")
|
|
18
|
+
* URL : {contentBaseUrl}/report-sessions/{analysisId}/{threadId}/{pagePath}?t={token}
|
|
19
|
+
* Caddy predicate : request.path.startsWith("/" + res + "/")
|
|
20
|
+
*
|
|
14
21
|
* This is URL space only. On disk a preview lives inside its analysis's workspace tree, at
|
|
15
22
|
* `{resolveWorkspaceRoot(analysisId)}/previews/{previewId}/{previewPath}` (the workspace-layout
|
|
16
|
-
* spec)
|
|
17
|
-
*
|
|
18
|
-
*
|
|
23
|
+
* spec), and a session page at `{resolveWorkspaceRoot(analysisId)}/report-sessions/{threadId}/{pagePath}`
|
|
24
|
+
* (the report-session-agent spec) — the `res` claim carries the analysis id because the URL needs an
|
|
25
|
+
* authorization boundary, whereas the resolved root already identifies the analysis and so does not
|
|
26
|
+
* repeat it. A host that serves either space owns the map between the two.
|
|
19
27
|
*
|
|
20
28
|
* The harness's contracts module owns this TS implementation so both the harness and
|
|
21
29
|
* react-client consume one canonical formula.
|
|
@@ -54,3 +62,37 @@ export function buildPreviewUrl(contentBaseUrl, analysisId, previewId, previewPa
|
|
|
54
62
|
const res = previewResourceId(analysisId, previewId);
|
|
55
63
|
return `${base}/${res}/${path}?t=${encodeURIComponent(token)}`;
|
|
56
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Canonical `res` claim formula for a report-session page. Returns the literal string
|
|
67
|
+
* `report-sessions/{analysisId}/{threadId}` with no leading or trailing slash.
|
|
68
|
+
*
|
|
69
|
+
* This is the URL sub-path served by the content-server (Caddy) and the token's
|
|
70
|
+
* authorization boundary — NOT a filesystem sub-path; see the module doc.
|
|
71
|
+
*
|
|
72
|
+
* MUST match `fmt.Sprintf("report-sessions/%s/%s", analysisID, threadID)` in
|
|
73
|
+
* the storage backend's Go `kernel/contenttoken` implementation. Drift is caught by the
|
|
74
|
+
* shared test vector at `src/__tests__/fixtures/report-session-res.json`.
|
|
75
|
+
*/
|
|
76
|
+
export function reportSessionResourceId(analysisId, threadId) {
|
|
77
|
+
return `report-sessions/${analysisId}/${threadId}`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Build a content-token URL for a report-session page.
|
|
81
|
+
*
|
|
82
|
+
* Produces `{contentBaseUrl}/{res}/{pagePath}?t={token}` where `res` is
|
|
83
|
+
* the output of `reportSessionResourceId(analysisId, threadId)`. The query parameter
|
|
84
|
+
* name is `t` (matching Caddy's `from_query t` directive). The token is
|
|
85
|
+
* URL-encoded.
|
|
86
|
+
*
|
|
87
|
+
* @param contentBaseUrl - Content server base URL (trailing slash tolerated)
|
|
88
|
+
* @param analysisId - The analysis ID (authorization boundary)
|
|
89
|
+
* @param threadId - The report thread ID (one session directory per thread)
|
|
90
|
+
* @param pagePath - Session-relative path (typically "index.html"). Leading slash tolerated.
|
|
91
|
+
* @param token - Short-lived content token minted by the storage backend (required)
|
|
92
|
+
*/
|
|
93
|
+
export function buildReportSessionUrl(contentBaseUrl, analysisId, threadId, pagePath, token) {
|
|
94
|
+
const base = contentBaseUrl.replace(/\/+$/, "");
|
|
95
|
+
const path = pagePath.replace(/^\/+/, "");
|
|
96
|
+
const res = reportSessionResourceId(analysisId, threadId);
|
|
97
|
+
return `${base}/${res}/${path}?t=${encodeURIComponent(token)}`;
|
|
98
|
+
}
|
|
@@ -15,4 +15,4 @@ export { CoverageSchema, RowCoverageSchema, EntitySchema, ClaimSupportSchema, Cl
|
|
|
15
15
|
export type { Coverage, RowCoverage, Entity, EvidenceItem, ClaimSupport, ClaimEvidence, LiabilityBullet, LiabilitySummary, TractabilitySection, ClinicalTrialAttribution, ClinicalTrialRow, ClinicalDevelopment, FailedTrialRow, TrialOutcomeRow, OrganRiskRow, OffTargetRow, RegulatoryActionRow, SafetyFlag, SafetyProfile, OffTissueRow, QualityGateStatus, QualityGates, Derived, Dossier, DossierBody, SectionBlurbKey, TargetAssessmentPhase, TargetAssessmentProgressEvent, } from "./target-dossier.js";
|
|
16
16
|
export { TargetAssessmentStatusSchema, TargetAssessmentErrorSchema, TargetAssessmentListRowSchema, TargetAssessmentRowSchema, } from "./target-assessment-row.js";
|
|
17
17
|
export type { TargetAssessmentStatus, TargetAssessmentError, TargetAssessmentListRow, TargetAssessmentRow } from "./target-assessment-row.js";
|
|
18
|
-
export { buildPreviewUrl, previewResourceId } from "./content-url.js";
|
|
18
|
+
export { buildPreviewUrl, buildReportSessionUrl, previewResourceId, reportSessionResourceId } from "./content-url.js";
|
package/dist/contracts/index.js
CHANGED
|
@@ -5,4 +5,4 @@ export { PART_REGISTRY, isTransient, isReconciling, isSidebarPart } from "./part
|
|
|
5
5
|
export { AnalogyCoverageSchema, AnalogyReportSchema, AnalogyReportErrorSchema, AnalogicalReasonerOutputSchema } from "./analogy-report.js";
|
|
6
6
|
export { CoverageSchema, RowCoverageSchema, EntitySchema, ClaimSupportSchema, ClaimEvidenceSchema, LiabilityBulletSchema, LiabilitySummarySchema, TractabilitySchema, IndicationsSchema, DrugInteractionsSchema, ClinicalTrialAttributionSchema, ClinicalDevelopmentSchema, OrganRiskRowSchema, OffTargetRowSchema, OffTargetPanelSchema, RegulatoryActionRowSchema, SafetyFlagSchema, SafetyProfileSchema, OffTissueRowSchema, OffTissueRiskSchema, ReferenceBiologyShape, EvidenceConflictsSchema, EvidenceTimelineSchema, TranslationalChainSchema, AdditionalEvidenceSchema, DiscoveryTrialsSchema, QualityGateStatusSchema, QualityGatesSchema, DerivedSchema, DossierSchema, DossierBodySchema, isDossier, dossierJsonSchema, SECTION_BLURBS, TargetAssessmentPhaseSchema, TargetAssessmentProgressEventSchema, } from "./target-dossier.js";
|
|
7
7
|
export { TargetAssessmentStatusSchema, TargetAssessmentErrorSchema, TargetAssessmentListRowSchema, TargetAssessmentRowSchema, } from "./target-assessment-row.js";
|
|
8
|
-
export { buildPreviewUrl, previewResourceId } from "./content-url.js";
|
|
8
|
+
export { buildPreviewUrl, buildReportSessionUrl, previewResourceId, reportSessionResourceId } from "./content-url.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,9 @@ export type { ArtifactManifestEntry } from "./schemas/artifact-manifest.js";
|
|
|
35
35
|
export type { ProvenanceCollector } from "./provenance/collector.js";
|
|
36
36
|
export { UnavailablePreviewPublisher } from "./tools/report/preview-publisher.js";
|
|
37
37
|
export type { PreviewPublisher, PreviewMintResult } from "./tools/report/preview-publisher.js";
|
|
38
|
+
export { UnavailableSessionPagePublisher } from "./tools/report-session/session-page-publisher.js";
|
|
39
|
+
export type { SessionPagePublisher, SessionPageMintResult } from "./tools/report-session/session-page-publisher.js";
|
|
40
|
+
export type { ResolvePageUrl, SessionPageAccess } from "./tools/report-session/index.js";
|
|
38
41
|
export { createDbosRunLauncher } from "./execution/dbos-run-launcher.js";
|
|
39
42
|
export type { RunLauncher, LaunchOptions } from "./execution/run-launcher.js";
|
|
40
43
|
export { createDbosWorkflowPurger } from "./execution/dbos-workflow-purger.js";
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,11 @@ export { createNoopUsageRecorder } from "./billing/noop-usage-recorder.js";
|
|
|
42
42
|
export { createNoopArtifactRegistry } from "./execution/noop-artifact-registry.js";
|
|
43
43
|
// Seam: report preview publishing.
|
|
44
44
|
export { UnavailablePreviewPublisher } from "./tools/report/preview-publisher.js";
|
|
45
|
+
// Seam: the hosted view of a report-session page. A managed host serves the URL space
|
|
46
|
+
// `report-sessions/{analysisId}/{threadId}` and mints access through its own publisher,
|
|
47
|
+
// thus the seam belongs on the front door. The URL seam of the eyes rides beside it: a
|
|
48
|
+
// host whose browser cannot reach the workspace tree binds a served URL for the look.
|
|
49
|
+
export { UnavailableSessionPagePublisher } from "./tools/report-session/session-page-publisher.js";
|
|
45
50
|
// Run launching.
|
|
46
51
|
export { createDbosRunLauncher } from "./execution/dbos-run-launcher.js";
|
|
47
52
|
// Seam: workflow-ledger reclamation — cancels and deletes an analysis's rows in
|
|
@@ -32,7 +32,7 @@ import { type CitationResolverConfig } from "../citations/resolve.js";
|
|
|
32
32
|
import type { CitationResolver } from "../citations/types.js";
|
|
33
33
|
import type { AuthContext } from "../auth/types.js";
|
|
34
34
|
import type { ReferenceResolver } from "../report-model/reference-resolver.js";
|
|
35
|
-
import type { ResolvePageAsset } from "../tools/report-session/index.js";
|
|
35
|
+
import type { ResolvePageAsset, ResolvePageUrl, SessionPagePublisher } from "../tools/report-session/index.js";
|
|
36
36
|
/** Registered child sandbox-step callable the parent's child dispatch closes over. */
|
|
37
37
|
export type SandboxStepCallable = (input: SandboxStepInput) => Promise<SandboxStepResult>;
|
|
38
38
|
/**
|
|
@@ -132,6 +132,19 @@ export interface CoreRuntimeDeps {
|
|
|
132
132
|
* materializes them to disk and binds its own lookup here.
|
|
133
133
|
*/
|
|
134
134
|
readonly resolveReportPageAsset?: ResolvePageAsset;
|
|
135
|
+
/**
|
|
136
|
+
* The hosted view of a report-session page. A managed host that serves the session URL
|
|
137
|
+
* space binds its publisher here, and the preview tool of the report agent then attaches
|
|
138
|
+
* the minted URL beside the page path. Absent, the tool attaches nothing and the page
|
|
139
|
+
* path stays the whole result, which is the whole local path.
|
|
140
|
+
*/
|
|
141
|
+
readonly sessionPagePublisher?: SessionPagePublisher;
|
|
142
|
+
/**
|
|
143
|
+
* The page-URL formation of the report-session eyes. A managed host whose browser cannot
|
|
144
|
+
* reach the workspace tree binds a resolver that names a served URL for the look. Absent,
|
|
145
|
+
* the eyes tool navigates through a `file://` URL of the page path.
|
|
146
|
+
*/
|
|
147
|
+
readonly resolveReportPageUrl?: ResolvePageUrl;
|
|
135
148
|
/**
|
|
136
149
|
* The eyes of a report session — where a browser comes from for one look at the rendered
|
|
137
150
|
* page. A host with no standing sidecar starts a browser for one look. Thus it binds its own
|
package/dist/runtime/assemble.js
CHANGED
|
@@ -164,6 +164,8 @@ export function assembleCoreRuntime(deps) {
|
|
|
164
164
|
makeResolver: makeReportResolver,
|
|
165
165
|
...(eyes ? { eyes } : {}),
|
|
166
166
|
...(deps.resolveReportPageAsset ? { resolvePageAsset: deps.resolveReportPageAsset } : {}),
|
|
167
|
+
...(deps.sessionPagePublisher ? { sessionPages: deps.sessionPagePublisher } : {}),
|
|
168
|
+
...(deps.resolveReportPageUrl ? { resolvePageUrl: deps.resolveReportPageUrl } : {}),
|
|
167
169
|
...(conversation.logger ? { logger: conversation.logger } : {}),
|
|
168
170
|
});
|
|
169
171
|
// The single registration point for every typed agent. A future thread type's
|
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
* see: the screenshot, the console errors, and the failed requests. The agent reads the picture and the
|
|
6
6
|
* faults, decides, and repairs. The tool never judges, thus it never blocks the loop.
|
|
7
7
|
*
|
|
8
|
-
* The
|
|
9
|
-
* page lives at `report-sessions/{threadId}/index.html`
|
|
10
|
-
* A missed page means that no preview ran, and it is a
|
|
8
|
+
* The composition says which URL one look opens, and the URL seam is that answer. Absent the seam, the tool
|
|
9
|
+
* navigates to the page file through a `file://` URL. The page lives at `report-sessions/{threadId}/index.html`
|
|
10
|
+
* under the workspace root, which the preview writes. A missed page means that no preview ran, and it is a
|
|
11
|
+
* typed outcome, not a throw.
|
|
11
12
|
*
|
|
12
13
|
* The composition says where a browser comes from, and the eyes seam is that answer. One look acquires one
|
|
13
14
|
* lease, and the tool captures against the endpoint of that lease.
|
|
14
15
|
*
|
|
15
|
-
* The `file://` URL resolves on the filesystem of the browser, because the connection is out of
|
|
16
|
-
* Thus the browser of a lease must hold the workspace tree of the harness host
|
|
17
|
-
* with no such mount reports the page as an unreachable request, and the tool
|
|
16
|
+
* The default `file://` URL resolves on the filesystem of the browser, because the connection is out of
|
|
17
|
+
* process. Thus, absent the URL seam, the browser of a lease must hold the workspace tree of the harness host
|
|
18
|
+
* at the same path. A browser with no such mount reports the page as an unreachable request, and the tool
|
|
19
|
+
* gives back that fault. A bound URL seam lifts that constraint, because the browser then opens a served URL.
|
|
18
20
|
*
|
|
19
21
|
* The tool releases the lease after the look. The release runs on a pass and on a failed capture alike. That
|
|
20
22
|
* release is hygiene, and it is not the guarantee against a leak. A process can die between the acquire and
|
|
@@ -51,6 +53,15 @@ import { type ResolveWorkspaceRoot } from "../../workspace/paths.js";
|
|
|
51
53
|
import { type Tool } from "../define-tool.js";
|
|
52
54
|
import { type ReportSessionStateGateway, type SessionRefusal } from "../report-authoring/authoring-tools.js";
|
|
53
55
|
export type { CapturePage, FailedRequest, PageCapture };
|
|
56
|
+
/**
|
|
57
|
+
* The URL formation of one look. It maps the page of the thread onto the URL that the browser opens.
|
|
58
|
+
* A composition whose browser cannot reach the workspace tree binds a resolver that names a served URL.
|
|
59
|
+
*/
|
|
60
|
+
export type ResolvePageUrl = (args: {
|
|
61
|
+
pagePath: string;
|
|
62
|
+
analysisId: string;
|
|
63
|
+
threadId: string;
|
|
64
|
+
}) => Promise<string>;
|
|
54
65
|
/** The empty input. The tool examines the current page of the thread, thus it needs no field. */
|
|
55
66
|
declare const examinePageInput: z.ZodObject<{}, z.core.$strip>;
|
|
56
67
|
export type ExaminePageInput = z.infer<typeof examinePageInput>;
|
|
@@ -90,15 +101,17 @@ export type ExaminePageResult = {
|
|
|
90
101
|
* `resolveWorkspaceRoot` maps the analysis of the call onto its workspace root, thus one singleton tool
|
|
91
102
|
* serves every analysis. `eyes` gives a browser for one look, and the scope of the acquire carries that
|
|
92
103
|
* analysis and its root. `chrome` carries the connection settings of the capture, and the browser that it
|
|
93
|
-
* names must hold the workspace tree at the same path
|
|
94
|
-
* `
|
|
95
|
-
*
|
|
104
|
+
* names must hold the workspace tree at the same path when the tool navigates to a `file://` URL.
|
|
105
|
+
* `resolvePageUrl` is optional and it replaces that URL, thus a composition whose browser cannot reach the
|
|
106
|
+
* tree names a served URL instead. `capture` is optional and it replaces the whole transport, thus a test
|
|
107
|
+
* injects a seam that reads no browser.
|
|
96
108
|
*/
|
|
97
109
|
export interface ExaminePageToolDeps {
|
|
98
110
|
readonly gateway: ReportSessionStateGateway;
|
|
99
111
|
readonly resolveWorkspaceRoot: ResolveWorkspaceRoot;
|
|
100
112
|
readonly chrome: ChromeConfig;
|
|
101
113
|
readonly eyes?: AcquireEyes;
|
|
114
|
+
readonly resolvePageUrl?: ResolvePageUrl;
|
|
102
115
|
readonly capture?: CapturePage;
|
|
103
116
|
readonly logger?: Logger;
|
|
104
117
|
/**
|
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
* see: the screenshot, the console errors, and the failed requests. The agent reads the picture and the
|
|
6
6
|
* faults, decides, and repairs. The tool never judges, thus it never blocks the loop.
|
|
7
7
|
*
|
|
8
|
-
* The
|
|
9
|
-
* page lives at `report-sessions/{threadId}/index.html`
|
|
10
|
-
* A missed page means that no preview ran, and it is a
|
|
8
|
+
* The composition says which URL one look opens, and the URL seam is that answer. Absent the seam, the tool
|
|
9
|
+
* navigates to the page file through a `file://` URL. The page lives at `report-sessions/{threadId}/index.html`
|
|
10
|
+
* under the workspace root, which the preview writes. A missed page means that no preview ran, and it is a
|
|
11
|
+
* typed outcome, not a throw.
|
|
11
12
|
*
|
|
12
13
|
* The composition says where a browser comes from, and the eyes seam is that answer. One look acquires one
|
|
13
14
|
* lease, and the tool captures against the endpoint of that lease.
|
|
14
15
|
*
|
|
15
|
-
* The `file://` URL resolves on the filesystem of the browser, because the connection is out of
|
|
16
|
-
* Thus the browser of a lease must hold the workspace tree of the harness host
|
|
17
|
-
* with no such mount reports the page as an unreachable request, and the tool
|
|
16
|
+
* The default `file://` URL resolves on the filesystem of the browser, because the connection is out of
|
|
17
|
+
* process. Thus, absent the URL seam, the browser of a lease must hold the workspace tree of the harness host
|
|
18
|
+
* at the same path. A browser with no such mount reports the page as an unreachable request, and the tool
|
|
19
|
+
* gives back that fault. A bound URL seam lifts that constraint, because the browser then opens a served URL.
|
|
18
20
|
*
|
|
19
21
|
* The tool releases the lease after the look. The release runs on a pass and on a failed capture alike. That
|
|
20
22
|
* release is hygiene, and it is not the guarantee against a leak. A process can die between the acquire and
|
|
@@ -270,13 +272,23 @@ export function createExaminePageTool(deps) {
|
|
|
270
272
|
logger.warn("the session page could not be read", { threadId, analysisId, ...defaultErrorFields(cause) });
|
|
271
273
|
return ok({ outcome: "capture-failed", detail: "the session page could not be read" });
|
|
272
274
|
}
|
|
275
|
+
// The URL seam speaks the throw protocol like the other seams, thus a fault of the formation
|
|
276
|
+
// becomes a typed outcome and the look never starts.
|
|
277
|
+
let url;
|
|
278
|
+
try {
|
|
279
|
+
url = deps.resolvePageUrl !== undefined ? await deps.resolvePageUrl({ pagePath, analysisId, threadId }) : pathToFileURL(pagePath).href;
|
|
280
|
+
}
|
|
281
|
+
catch (cause) {
|
|
282
|
+
logger.warn("the page URL did not resolve", { threadId, analysisId, ...defaultErrorFields(cause) });
|
|
283
|
+
return ok({ outcome: "capture-failed", detail: "the page URL did not resolve" });
|
|
284
|
+
}
|
|
273
285
|
// The scope of the acquire carries the analysis and the root that this call resolved. Thus a
|
|
274
286
|
// realization that starts a browser mounts the same tree, and it holds no second resolver.
|
|
275
287
|
const looked = await runLook({
|
|
276
288
|
transport,
|
|
277
289
|
chrome: deps.chrome,
|
|
278
290
|
scope: { analysisId, workspaceRoot: root },
|
|
279
|
-
url
|
|
291
|
+
url,
|
|
280
292
|
acquireMs,
|
|
281
293
|
releaseMs,
|
|
282
294
|
logger,
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* render seams, thus each tool binds the per-session state to the thread of the call. The barrel exports
|
|
6
6
|
* the factories and their public types for the composition root.
|
|
7
7
|
*/
|
|
8
|
-
export { createPreviewReportTool, type PreviewReportInput, type PreviewReportResult, type PreviewReportToolDeps, type ResolvePageAsset, } from "./preview-report.js";
|
|
9
|
-
export { createExaminePageTool, type CapturePage, type ExaminePageInput, type ExaminePageResult, type ExaminePageToolDeps, type FailedRequest, type PageCapture, } from "./examine-page.js";
|
|
8
|
+
export { createPreviewReportTool, type PreviewReportInput, type PreviewReportResult, type PreviewReportToolDeps, type ResolvePageAsset, type SessionPageAccess, } from "./preview-report.js";
|
|
9
|
+
export { createExaminePageTool, type CapturePage, type ExaminePageInput, type ExaminePageResult, type ExaminePageToolDeps, type FailedRequest, type PageCapture, type ResolvePageUrl, } from "./examine-page.js";
|
|
10
|
+
export { describeSessionPageMintFailure, UnavailableSessionPagePublisher, type SessionPageMintFailure, type SessionPageMintResult, type SessionPagePublisher, } from "./session-page-publisher.js";
|
|
10
11
|
export { createRecordVersionTool, type RecordVersionInput, type RecordVersionResult, type RecordVersionToolDeps } from "./record-version.js";
|
|
11
12
|
export { createDeriveTableTool, type DeriveTableInput, type DeriveTableResult, type DeriveTableToolDeps } from "./derive-table.js";
|
|
12
13
|
export { createListPinnedArtifactsTool, type ListPinnedArtifactsInput, type ListPinnedArtifactsResult, type ListPinnedArtifactsToolDeps, type PinnedArtifact, type PinnedCitation, } from "./list-artifacts.js";
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { createPreviewReportTool, } from "./preview-report.js";
|
|
9
9
|
export { createExaminePageTool, } from "./examine-page.js";
|
|
10
|
+
export { describeSessionPageMintFailure, UnavailableSessionPagePublisher, } from "./session-page-publisher.js";
|
|
10
11
|
export { createRecordVersionTool } from "./record-version.js";
|
|
11
12
|
export { createDeriveTableTool } from "./derive-table.js";
|
|
12
13
|
export { createListPinnedArtifactsTool, } from "./list-artifacts.js";
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
* namespace belongs to this path alone, thus the tool never writes under the old `previews/` or `reports/`
|
|
17
17
|
* trees. The result carries the absolute page path, thus a local host shows the page with no seam.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* A hosted view rides the same result. When the composition binds the session-page publisher, the tool
|
|
20
|
+
* mints one grant after the page lands, and the `rendered` arm carries the URL of the URL space
|
|
21
|
+
* `report-sessions/{analysisId}/{threadId}` (`contracts/content-url.ts`) beside the path. A refused mint
|
|
22
|
+
* rides the arm as data, and the page path stays good — a broken grant surface never costs the render. An
|
|
23
|
+
* unbound publisher changes nothing: the arm carries no access field, and a local host opens the file.
|
|
22
24
|
*
|
|
23
25
|
* Each degraded condition is a typed outcome in the ok channel: a session refusal, a gap list, a resolver
|
|
24
26
|
* absence, an unresolvable root at resolver construction, an unresolved reference, a bridge mismatch, a
|
|
@@ -41,12 +43,27 @@ import { type BridgeMismatch } from "../../report-render/value-bridge.js";
|
|
|
41
43
|
import type { RenderProblem } from "../../report-render/types.js";
|
|
42
44
|
import { type Tool } from "../define-tool.js";
|
|
43
45
|
import { type ReportSessionStateGateway, type SessionRefusal } from "../report-authoring/authoring-tools.js";
|
|
46
|
+
import { type SessionPagePublisher } from "./session-page-publisher.js";
|
|
44
47
|
/** The empty input. The tool renders the current draft of the thread, thus it needs no field. */
|
|
45
48
|
declare const previewReportInput: z.ZodObject<{}, z.core.$strip>;
|
|
46
49
|
export type PreviewReportInput = z.infer<typeof previewReportInput>;
|
|
50
|
+
/**
|
|
51
|
+
* The access grant of the hosted view, as data on the `rendered` arm. A granted mint carries the URL of
|
|
52
|
+
* the served page and its expiry. A refused mint carries the described refusal, and the page path stays
|
|
53
|
+
* good.
|
|
54
|
+
*/
|
|
55
|
+
export type SessionPageAccess = {
|
|
56
|
+
granted: true;
|
|
57
|
+
url: string;
|
|
58
|
+
expiresAt: string;
|
|
59
|
+
} | {
|
|
60
|
+
granted: false;
|
|
61
|
+
detail: string;
|
|
62
|
+
};
|
|
47
63
|
/**
|
|
48
64
|
* The typed outcome of the preview tool. Each arm is ok-channel data, thus the tool never throws for a
|
|
49
|
-
* degraded condition. `rendered` carries the absolute page path
|
|
65
|
+
* degraded condition. `rendered` carries the absolute page path, and the access grant of the hosted view
|
|
66
|
+
* when the composition binds the publisher.
|
|
50
67
|
*/
|
|
51
68
|
export type PreviewReportResult = {
|
|
52
69
|
outcome: "refused";
|
|
@@ -82,6 +99,7 @@ export type PreviewReportResult = {
|
|
|
82
99
|
} | {
|
|
83
100
|
outcome: "rendered";
|
|
84
101
|
pagePath: string;
|
|
102
|
+
access?: SessionPageAccess;
|
|
85
103
|
};
|
|
86
104
|
/**
|
|
87
105
|
* The lookup of the source file of one staged asset. It maps the module specifier of a manifest entry
|
|
@@ -99,6 +117,10 @@ export type ResolvePageAsset = (specifier: string) => string;
|
|
|
99
117
|
* `resolvePageAsset` is optional, and absent it resolves each specifier against the installation of the
|
|
100
118
|
* harness. An embedder that ships the asset bytes packed, for example a compiled single-file binary with no
|
|
101
119
|
* `node_modules` tree, materializes them to disk and binds its own lookup here.
|
|
120
|
+
*
|
|
121
|
+
* `sessionPages` is optional, because a local host opens the page path itself. Bound, the tool mints one
|
|
122
|
+
* grant after the page lands and attaches the URL beside the path. A refused mint rides the `rendered` arm
|
|
123
|
+
* as data, and it never fails the render.
|
|
102
124
|
*/
|
|
103
125
|
export interface PreviewReportToolDeps {
|
|
104
126
|
readonly gateway: ReportSessionStateGateway;
|
|
@@ -108,6 +130,7 @@ export interface PreviewReportToolDeps {
|
|
|
108
130
|
}) => ReferenceResolver;
|
|
109
131
|
readonly resolveWorkspaceRoot: ResolveWorkspaceRoot;
|
|
110
132
|
readonly resolvePageAsset?: ResolvePageAsset;
|
|
133
|
+
readonly sessionPages?: SessionPagePublisher;
|
|
111
134
|
readonly logger?: Logger;
|
|
112
135
|
}
|
|
113
136
|
/**
|
|
@@ -16,9 +16,11 @@
|
|
|
16
16
|
* namespace belongs to this path alone, thus the tool never writes under the old `previews/` or `reports/`
|
|
17
17
|
* trees. The result carries the absolute page path, thus a local host shows the page with no seam.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* A hosted view rides the same result. When the composition binds the session-page publisher, the tool
|
|
20
|
+
* mints one grant after the page lands, and the `rendered` arm carries the URL of the URL space
|
|
21
|
+
* `report-sessions/{analysisId}/{threadId}` (`contracts/content-url.ts`) beside the path. A refused mint
|
|
22
|
+
* rides the arm as data, and the page path stays good — a broken grant surface never costs the render. An
|
|
23
|
+
* unbound publisher changes nothing: the arm carries no access field, and a local host opens the file.
|
|
22
24
|
*
|
|
23
25
|
* Each degraded condition is a typed outcome in the ok channel: a session refusal, a gap list, a resolver
|
|
24
26
|
* absence, an unresolvable root at resolver construction, an unresolved reference, a bridge mismatch, a
|
|
@@ -36,6 +38,7 @@ import { extname, join } from "node:path";
|
|
|
36
38
|
import { relative as relativePosix } from "node:path/posix";
|
|
37
39
|
import { z } from "zod";
|
|
38
40
|
import { reportSessionDir, resolveWorkspacePath } from "../../workspace/paths.js";
|
|
41
|
+
import { buildReportSessionUrl } from "../../contracts/content-url.js";
|
|
39
42
|
import { createNoopLogger } from "../../lib/console-logger.js";
|
|
40
43
|
import { describeFsError, tryFsWrite } from "../../lib/fs-result.js";
|
|
41
44
|
import { defaultErrorFields } from "../../lib/logger.js";
|
|
@@ -49,6 +52,7 @@ import { ASSETS_DIR, DEPS_DIR, derivationScriptName, PAGE_ASSETS, stagedSource,
|
|
|
49
52
|
import { renderReportPage } from "../../report-render/render.js";
|
|
50
53
|
import { defineTool } from "../define-tool.js";
|
|
51
54
|
import { openReportThread } from "../report-authoring/authoring-tools.js";
|
|
55
|
+
import { describeSessionPageMintFailure } from "./session-page-publisher.js";
|
|
52
56
|
/** The empty input. The tool renders the current draft of the thread, thus it needs no field. */
|
|
53
57
|
const previewReportInput = z.object({});
|
|
54
58
|
/**
|
|
@@ -335,6 +339,36 @@ async function sweepAssets(assetsDir, staged, logger) {
|
|
|
335
339
|
}
|
|
336
340
|
}
|
|
337
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Mint the hosted view of the page that landed.
|
|
344
|
+
*
|
|
345
|
+
* An absent publisher gives no grant, and the arm carries no access field — the page path stays the whole
|
|
346
|
+
* local contract. A refusal and a thrown realization each become the not-granted arm, thus a broken grant
|
|
347
|
+
* surface never costs the render. The URL spells through `buildReportSessionUrl`, thus the formula lives in
|
|
348
|
+
* the contract and the seam gives the content-server base alone.
|
|
349
|
+
*/
|
|
350
|
+
async function mintAccess(publisher, analysisId, threadId, logger) {
|
|
351
|
+
if (publisher === undefined) {
|
|
352
|
+
return undefined;
|
|
353
|
+
}
|
|
354
|
+
let minted;
|
|
355
|
+
try {
|
|
356
|
+
minted = await publisher.mintSessionPageAccess(analysisId, threadId);
|
|
357
|
+
}
|
|
358
|
+
catch (cause) {
|
|
359
|
+
logger.warn("the session-page mint threw", { threadId, analysisId, ...defaultErrorFields(cause) });
|
|
360
|
+
return { granted: false, detail: "session-page-access mint failed" };
|
|
361
|
+
}
|
|
362
|
+
if (!minted.ok) {
|
|
363
|
+
logger.warn("the session-page mint refused", { threadId, analysisId, detail: describeSessionPageMintFailure(minted) });
|
|
364
|
+
return { granted: false, detail: describeSessionPageMintFailure(minted) };
|
|
365
|
+
}
|
|
366
|
+
return {
|
|
367
|
+
granted: true,
|
|
368
|
+
url: buildReportSessionUrl(minted.data.baseUrl, analysisId, threadId, "index.html", minted.data.token),
|
|
369
|
+
expiresAt: minted.data.expiresAt,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
338
372
|
/**
|
|
339
373
|
* Make the render-and-preview tool over the session-state gateway and the render seams.
|
|
340
374
|
*
|
|
@@ -438,7 +472,8 @@ export function createPreviewReportTool(deps) {
|
|
|
438
472
|
logger.warn("the rendered hash did not stamp", { threadId, analysisId, detail });
|
|
439
473
|
return ok({ outcome: "stamp-failed", pagePath: written.value, detail });
|
|
440
474
|
}
|
|
441
|
-
|
|
475
|
+
const access = await mintAccess(deps.sessionPages, analysisId, threadId, logger);
|
|
476
|
+
return ok({ outcome: "rendered", pagePath: written.value, ...(access !== undefined ? { access } : {}) });
|
|
442
477
|
},
|
|
443
478
|
});
|
|
444
479
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionPagePublisher — the seam between the report-session path and the hosted view of its page.
|
|
3
|
+
*
|
|
4
|
+
* The preview tool writes the page under the session directory and gives back the path. A local host
|
|
5
|
+
* opens the file, thus it needs no seam. A managed host serves the page over HTTP, and the one thing
|
|
6
|
+
* that reaches outside the process is the mint of a content-token grant for the URL space
|
|
7
|
+
* `report-sessions/{analysisId}/{threadId}` (`contracts/content-url.ts`). That mint hides behind this
|
|
8
|
+
* one method.
|
|
9
|
+
*
|
|
10
|
+
* The managed realization owns the grant mint and its client. The local default
|
|
11
|
+
* (`UnavailableSessionPagePublisher`) returns not-ok, thus the preview tool attaches no URL and the
|
|
12
|
+
* render still lands — the page path stays the whole local contract.
|
|
13
|
+
*/
|
|
14
|
+
export type SessionPageMintResult = {
|
|
15
|
+
ok: true;
|
|
16
|
+
data: {
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
token: string;
|
|
19
|
+
expiresAt: string;
|
|
20
|
+
};
|
|
21
|
+
} | {
|
|
22
|
+
ok: false;
|
|
23
|
+
status?: number;
|
|
24
|
+
error: {
|
|
25
|
+
message?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/** The not-ok arm of the seam's result — what a failed mint is allowed to carry. */
|
|
29
|
+
export type SessionPageMintFailure = Extract<SessionPageMintResult, {
|
|
30
|
+
ok: false;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Renders a failed mint as the line an agent reads back from the preview tool.
|
|
34
|
+
*
|
|
35
|
+
* The failure shape is sparse by design: a realization with no HTTP transport behind it supplies
|
|
36
|
+
* neither a status nor, necessarily, a message. Naming a field the seam left unset would put the
|
|
37
|
+
* literal `status=undefined` in front of the model, thus the line carries only what actually arrived.
|
|
38
|
+
* It lives beside the type because its whole job is to honour that type's optionality.
|
|
39
|
+
*/
|
|
40
|
+
export declare function describeSessionPageMintFailure(failure: SessionPageMintFailure): string;
|
|
41
|
+
export interface SessionPagePublisher {
|
|
42
|
+
/**
|
|
43
|
+
* Mint the access grant of one session page. `baseUrl` is the base URL of the content server, with
|
|
44
|
+
* no res path — the caller spells the whole URL through `buildReportSessionUrl`, thus the formula
|
|
45
|
+
* lives in the contract and never in a realization.
|
|
46
|
+
*/
|
|
47
|
+
mintSessionPageAccess(analysisId: string, threadId: string): Promise<SessionPageMintResult>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Local default — no hosted view of a session page. Returns not-ok, thus the preview tool carries the
|
|
51
|
+
* refusal as data and the page path stays the whole result.
|
|
52
|
+
*/
|
|
53
|
+
export declare class UnavailableSessionPagePublisher implements SessionPagePublisher {
|
|
54
|
+
mintSessionPageAccess(_analysisId: string, _threadId: string): Promise<SessionPageMintResult>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionPagePublisher — the seam between the report-session path and the hosted view of its page.
|
|
3
|
+
*
|
|
4
|
+
* The preview tool writes the page under the session directory and gives back the path. A local host
|
|
5
|
+
* opens the file, thus it needs no seam. A managed host serves the page over HTTP, and the one thing
|
|
6
|
+
* that reaches outside the process is the mint of a content-token grant for the URL space
|
|
7
|
+
* `report-sessions/{analysisId}/{threadId}` (`contracts/content-url.ts`). That mint hides behind this
|
|
8
|
+
* one method.
|
|
9
|
+
*
|
|
10
|
+
* The managed realization owns the grant mint and its client. The local default
|
|
11
|
+
* (`UnavailableSessionPagePublisher`) returns not-ok, thus the preview tool attaches no URL and the
|
|
12
|
+
* render still lands — the page path stays the whole local contract.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Renders a failed mint as the line an agent reads back from the preview tool.
|
|
16
|
+
*
|
|
17
|
+
* The failure shape is sparse by design: a realization with no HTTP transport behind it supplies
|
|
18
|
+
* neither a status nor, necessarily, a message. Naming a field the seam left unset would put the
|
|
19
|
+
* literal `status=undefined` in front of the model, thus the line carries only what actually arrived.
|
|
20
|
+
* It lives beside the type because its whole job is to honour that type's optionality.
|
|
21
|
+
*/
|
|
22
|
+
export function describeSessionPageMintFailure(failure) {
|
|
23
|
+
const detail = [];
|
|
24
|
+
if (failure.status !== undefined)
|
|
25
|
+
detail.push(`status=${failure.status}`);
|
|
26
|
+
const message = failure.error.message?.trim();
|
|
27
|
+
if (message)
|
|
28
|
+
detail.push(message);
|
|
29
|
+
return detail.length > 0 ? `session-page-access mint failed: ${detail.join(" ")}` : "session-page-access mint failed";
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Local default — no hosted view of a session page. Returns not-ok, thus the preview tool carries the
|
|
33
|
+
* refusal as data and the page path stays the whole result.
|
|
34
|
+
*/
|
|
35
|
+
export class UnavailableSessionPagePublisher {
|
|
36
|
+
async mintSessionPageAccess(_analysisId, _threadId) {
|
|
37
|
+
return {
|
|
38
|
+
ok: false,
|
|
39
|
+
error: { message: "the hosted view of a session page is unavailable in this environment" },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inflexa-ai/harness",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Host-agnostic bioinformatics agent harness
|
|
3
|
+
"version": "0.22.0",
|
|
4
|
+
"description": "Host-agnostic bioinformatics agent harness — hand-rolled agent loop, DBOS-durable workflows, sandboxed compute.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|