@modelprofile.com/flexharness 9.4.0 → 9.6.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.
@@ -0,0 +1,241 @@
1
+ import { FlexHarnessValidationError } from './errors.js';
2
+ import { FLEX_PROJECT_MANAGEMENT_LIMITS, FLEX_SESSION_IMPORT_DEFAULT_LIMITS, FLEX_SESSION_IMPORT_MAXIMUM_LIMITS, FLEX_SESSION_IMPORT_MAX_DETAILS_BYTES, FLEX_SESSION_IMPORT_MAX_MESSAGE_BYTES, } from './interfaces.js';
3
+ import { maxSubagentNameBytes } from './utils.harnessoptions.js';
4
+ import { assertFlexMessageRecord, assertJsonSerializable, cloneSerializable } from './utils.json.js';
5
+ import { createBoundedTransferMessage, jsonBytes, maxTransferIdentifierBytes, requireTransferIdentifier, } from './utils.transfer.js';
6
+ import { validateIdentifier, validateUtf8String } from './utils.validation.js';
7
+ const maxSourceBytes = 128;
8
+ const maxDigestBytes = 256;
9
+ const maxImportParts = 1024;
10
+ const controlCharacterPattern = /[\u0000-\u001f\u007f]/u;
11
+ export function resolveSessionImportLimits(limits = {}) {
12
+ const resolved = {
13
+ maxOpenImports: limits.maxOpenImports ?? FLEX_SESSION_IMPORT_DEFAULT_LIMITS.maxOpenImports,
14
+ maxMessagesPerSession: limits.maxMessagesPerSession
15
+ ?? FLEX_SESSION_IMPORT_DEFAULT_LIMITS.maxMessagesPerSession,
16
+ maxSessionBytes: limits.maxSessionBytes ?? FLEX_SESSION_IMPORT_DEFAULT_LIMITS.maxSessionBytes,
17
+ maxPageBytes: limits.maxPageBytes ?? FLEX_SESSION_IMPORT_DEFAULT_LIMITS.maxPageBytes,
18
+ stagedImportIdleTimeoutMs: limits.stagedImportIdleTimeoutMs
19
+ ?? FLEX_SESSION_IMPORT_DEFAULT_LIMITS.stagedImportIdleTimeoutMs,
20
+ };
21
+ for (const [name, value] of Object.entries(resolved)) {
22
+ const maximum = FLEX_SESSION_IMPORT_MAXIMUM_LIMITS[name];
23
+ if (!Number.isSafeInteger(value) || value < 1 || value > maximum) {
24
+ throw new FlexHarnessValidationError(`sessionImportLimits.${name} must be an integer from 1 through ${maximum}.`);
25
+ }
26
+ }
27
+ return resolved;
28
+ }
29
+ function requirePlainRecord(value, name) {
30
+ if (!value
31
+ || typeof value !== 'object'
32
+ || Array.isArray(value)
33
+ || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) {
34
+ throw new FlexHarnessValidationError(`${name} must be a plain object.`);
35
+ }
36
+ return value;
37
+ }
38
+ function requireKnownKeys(record, allowedKeys, name) {
39
+ const unsupported = Reflect.ownKeys(record).find((key) => typeof key !== 'string' || !allowedKeys.includes(key));
40
+ if (unsupported !== undefined) {
41
+ throw new FlexHarnessValidationError(`${name} does not support "${String(unsupported)}".`);
42
+ }
43
+ }
44
+ function requireBoundedText(value, name, maxBytes) {
45
+ validateUtf8String(value, name, maxBytes, true);
46
+ if (controlCharacterPattern.test(value)) {
47
+ throw new FlexHarnessValidationError(`${name} must not contain control characters.`);
48
+ }
49
+ return value;
50
+ }
51
+ /** A timestamp exactly as `Date.prototype.toISOString()` renders it. */
52
+ export function requireCanonicalTimestamp(value, name) {
53
+ if (typeof value !== 'string' || value.length > 64) {
54
+ throw new FlexHarnessValidationError(`${name} must be an ISO 8601 timestamp.`);
55
+ }
56
+ const time = Date.parse(value);
57
+ if (!Number.isFinite(time) || new Date(time).toISOString() !== value) {
58
+ throw new FlexHarnessValidationError(`${name} must be an ISO 8601 timestamp as Date.prototype.toISOString() renders it.`);
59
+ }
60
+ return value;
61
+ }
62
+ function normalizeImportPart(value) {
63
+ const part = requirePlainRecord(value, 'origin.part');
64
+ requireKnownKeys(part, ['index', 'count'], 'origin.part');
65
+ const { index, count } = part;
66
+ if (!Number.isSafeInteger(count)
67
+ || Number(count) < 1
68
+ || Number(count) > maxImportParts
69
+ || !Number.isSafeInteger(index)
70
+ || Number(index) < 0
71
+ || Number(index) >= Number(count)) {
72
+ throw new FlexHarnessValidationError(`origin.part must have a count from 1 through ${maxImportParts} and a zero-based index below it.`);
73
+ }
74
+ return { index: index, count: count };
75
+ }
76
+ function normalizeImportDetails(value) {
77
+ requirePlainRecord(value, 'origin.details');
78
+ try {
79
+ assertJsonSerializable(value, 'origin.details');
80
+ }
81
+ catch (error) {
82
+ throw new FlexHarnessValidationError('origin.details must be a JSON object.', { cause: error });
83
+ }
84
+ if (jsonBytes(value) > FLEX_SESSION_IMPORT_MAX_DETAILS_BYTES) {
85
+ throw new FlexHarnessValidationError(`origin.details must be at most ${FLEX_SESSION_IMPORT_MAX_DETAILS_BYTES} JSON bytes.`);
86
+ }
87
+ return cloneSerializable(value);
88
+ }
89
+ function normalizeImportSource(value) {
90
+ const origin = requirePlainRecord(value, 'origin');
91
+ requireKnownKeys(origin, ['source', 'sourceId', 'digest', 'part', 'details'], 'origin');
92
+ return {
93
+ source: requireBoundedText(origin.source, 'origin.source', maxSourceBytes),
94
+ sourceId: requireBoundedText(origin.sourceId, 'origin.sourceId', maxTransferIdentifierBytes),
95
+ digest: requireBoundedText(origin.digest, 'origin.digest', maxDigestBytes),
96
+ ...(origin.part === undefined ? {} : { part: normalizeImportPart(origin.part) }),
97
+ ...(origin.details === undefined ? {} : { details: normalizeImportDetails(origin.details) }),
98
+ };
99
+ }
100
+ function normalizeImportParent(value) {
101
+ const parent = requirePlainRecord(value, 'parent');
102
+ requireKnownKeys(parent, ['sessionId', 'runId', 'toolCallId', 'agent'], 'parent');
103
+ return {
104
+ sessionId: requireBoundedText(parent.sessionId, 'parent.sessionId', maxTransferIdentifierBytes),
105
+ runId: requireBoundedText(parent.runId, 'parent.runId', maxTransferIdentifierBytes),
106
+ toolCallId: requireBoundedText(parent.toolCallId, 'parent.toolCallId', maxTransferIdentifierBytes),
107
+ agent: requireBoundedText(parent.agent, 'parent.agent', maxSubagentNameBytes),
108
+ };
109
+ }
110
+ export function normalizeBeginSessionImportOptions(options) {
111
+ const record = requirePlainRecord(options, 'beginSessionImport options');
112
+ requireKnownKeys(record, ['sessionId', 'title', 'createdAt', 'updatedAt', 'origin', 'parent'], 'beginSessionImport options');
113
+ const sessionId = record.sessionId;
114
+ validateIdentifier(sessionId, 'sessionId');
115
+ requireTransferIdentifier(sessionId, 'sessionId');
116
+ if (record.title !== undefined) {
117
+ validateUtf8String(record.title, 'title', FLEX_PROJECT_MANAGEMENT_LIMITS.maxTitleBytes, true);
118
+ }
119
+ const createdAt = requireCanonicalTimestamp(record.createdAt, 'createdAt');
120
+ const updatedAt = record.updatedAt === undefined
121
+ ? createdAt
122
+ : requireCanonicalTimestamp(record.updatedAt, 'updatedAt');
123
+ if (Date.parse(updatedAt) < Date.parse(createdAt)) {
124
+ throw new FlexHarnessValidationError('updatedAt must not be earlier than createdAt.');
125
+ }
126
+ const parent = record.parent === undefined ? undefined : normalizeImportParent(record.parent);
127
+ if (parent?.sessionId === sessionId) {
128
+ throw new FlexHarnessValidationError('An imported session cannot be its own parent.');
129
+ }
130
+ return {
131
+ sessionId,
132
+ ...(record.title === undefined ? {} : { title: record.title }),
133
+ createdAt,
134
+ updatedAt,
135
+ origin: normalizeImportSource(record.origin),
136
+ ...(parent === undefined ? {} : { parent }),
137
+ };
138
+ }
139
+ /** The identity an import is idempotent by: its source, source id and part. */
140
+ export function sessionImportIdentity(origin) {
141
+ return JSON.stringify([origin.source, origin.sourceId, origin.part?.index ?? null]);
142
+ }
143
+ function normalizeImportedMessage(value, path, role, sessionId) {
144
+ try {
145
+ assertFlexMessageRecord(value, path);
146
+ }
147
+ catch (error) {
148
+ throw new FlexHarnessValidationError(`${path} is not a valid message: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
149
+ }
150
+ const message = cloneSerializable(value);
151
+ if (message.role !== role) {
152
+ throw new FlexHarnessValidationError(`${path}.role must be "${role}".`);
153
+ }
154
+ if (message.sessionId !== sessionId) {
155
+ throw new FlexHarnessValidationError(`${path}.sessionId must be the imported session "${sessionId}".`);
156
+ }
157
+ if (message.status === 'streaming') {
158
+ throw new FlexHarnessValidationError(`${path}.status must be completed, failed or cancelled.`);
159
+ }
160
+ requireCanonicalTimestamp(message.createdAt, `${path}.createdAt`);
161
+ if (message.completedAt !== undefined) {
162
+ requireCanonicalTimestamp(message.completedAt, `${path}.completedAt`);
163
+ }
164
+ for (const [index, part] of message.parts.entries()) {
165
+ if (part.type !== 'reasoning' && part.type !== 'tool')
166
+ continue;
167
+ if (part.status === 'running') {
168
+ throw new FlexHarnessValidationError(`${path}.parts[${index}] must not be running.`);
169
+ }
170
+ }
171
+ const bytes = jsonBytes(message);
172
+ if (bytes > FLEX_SESSION_IMPORT_MAX_MESSAGE_BYTES) {
173
+ throw new FlexHarnessValidationError(`${path} exceeds ${FLEX_SESSION_IMPORT_MAX_MESSAGE_BYTES} JSON bytes.`);
174
+ }
175
+ try {
176
+ createBoundedTransferMessage(message);
177
+ }
178
+ catch (error) {
179
+ throw new FlexHarnessValidationError(`${path} cannot be read back within the transfer limits.`, {
180
+ cause: error,
181
+ });
182
+ }
183
+ return { message, bytes };
184
+ }
185
+ /**
186
+ * Validates one page of imported runs. Every message must belong to `sessionId`, be terminal and
187
+ * fit the transfer limits; a run's user and assistant message share its run id and status.
188
+ */
189
+ export function normalizeImportedRunPage(runs, sessionId, maxPageBytes) {
190
+ if (!Array.isArray(runs) || runs.length === 0) {
191
+ throw new FlexHarnessValidationError('Imported runs must be a non-empty array.');
192
+ }
193
+ let pageBytes;
194
+ try {
195
+ assertJsonSerializable(runs, 'runs');
196
+ pageBytes = jsonBytes(runs);
197
+ }
198
+ catch (error) {
199
+ throw new FlexHarnessValidationError('Imported runs must be JSON-safe.', { cause: error });
200
+ }
201
+ if (pageBytes > maxPageBytes) {
202
+ throw new FlexHarnessValidationError(`Imported runs exceed the page limit of ${maxPageBytes} JSON bytes.`);
203
+ }
204
+ const normalized = [];
205
+ let bytes = 0;
206
+ for (const [index, value] of runs.entries()) {
207
+ const path = `runs[${index}]`;
208
+ const run = requirePlainRecord(value, path);
209
+ requireKnownKeys(run, ['user', 'assistant'], path);
210
+ const user = normalizeImportedMessage(run.user, `${path}.user`, 'user', sessionId);
211
+ const assistant = normalizeImportedMessage(run.assistant, `${path}.assistant`, 'assistant', sessionId);
212
+ if (user.message.runId !== assistant.message.runId) {
213
+ throw new FlexHarnessValidationError(`${path} user and assistant messages must share one runId.`);
214
+ }
215
+ if (user.message.messageId === assistant.message.messageId) {
216
+ throw new FlexHarnessValidationError(`${path} user and assistant messages must have distinct ids.`);
217
+ }
218
+ if (user.message.status !== assistant.message.status) {
219
+ throw new FlexHarnessValidationError(`${path} user and assistant messages must share one status.`);
220
+ }
221
+ normalized.push({ user: user.message, assistant: assistant.message });
222
+ bytes += user.bytes + assistant.bytes;
223
+ }
224
+ return { runs: normalized, bytes };
225
+ }
226
+ /** Validates the shape of a handle `beginSessionImport()` returned. */
227
+ export function validateSessionImportHandle(handle) {
228
+ const record = requirePlainRecord(handle, 'Session import handle');
229
+ requireKnownKeys(record, ['importId', 'scopeId', 'sessionId'], 'Session import handle');
230
+ for (const key of ['importId', 'scopeId', 'sessionId']) {
231
+ if (typeof record[key] !== 'string' || record[key] === '') {
232
+ throw new FlexHarnessValidationError(`Session import handle ${key} must be a non-empty string.`);
233
+ }
234
+ }
235
+ return {
236
+ importId: record.importId,
237
+ scopeId: record.scopeId,
238
+ sessionId: record.sessionId,
239
+ };
240
+ }
241
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuc2Vzc2lvbmltcG9ydC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3V0aWxzLnNlc3Npb25pbXBvcnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLDBCQUEwQixFQUFFLE1BQU0sYUFBYSxDQUFDO0FBQ3pELE9BQU8sRUFDTCw4QkFBOEIsRUFDOUIsa0NBQWtDLEVBQ2xDLGtDQUFrQyxFQUNsQyxxQ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/flexharness",
5
- "version": "9.4.0",
5
+ "version": "9.6.0",
6
6
  "type": "module",
7
7
  "description": "Managed agent sessions with tools, MCP, chat, OCR, documents and browser control through focused subpath imports.",
8
8
  "main": "./dist_ts/index.js",
@@ -62,8 +62,8 @@
62
62
  }
63
63
  },
64
64
  "dependencies": {
65
- "@modelprofile.com/flexharness-agent": "9.4.0",
66
- "@modelprofile.com/flexharness-models": "9.4.0",
65
+ "@modelprofile.com/flexharness-agent": "9.6.0",
66
+ "@modelprofile.com/flexharness-models": "9.6.0",
67
67
  "@push.rocks/smartrequest": "^5.0.1",
68
68
  "ai": "^7.0.107",
69
69
  "zod": "^4.4.1"
package/readme.md CHANGED
@@ -235,6 +235,13 @@ const harness = new FlexHarness<IProjectScope>({
235
235
  maxExcludedRunIds: 1000,
236
236
  maxPendingReversionReleases: 1000,
237
237
  },
238
+ sessionImportLimits: {
239
+ maxOpenImports: 2,
240
+ maxMessagesPerSession: 2048,
241
+ maxSessionBytes: 64 * 1024 * 1024,
242
+ maxPageBytes: 1024 * 1024,
243
+ stagedImportIdleTimeoutMs: 5 * 60 * 1000,
244
+ },
238
245
  subagents: [
239
246
  {
240
247
  name: 'researcher',
@@ -601,9 +608,9 @@ Queue payloads, status records, and `prompt.*` queue events are process-local. T
601
608
 
602
609
  The reservation save is the admission point. A save failure produces no start events or active audit. If disposal begins while that save is in flight and the save commits, admission still resolves and its completion settles as cancelled; disposal waits for terminal finalization.
603
610
 
604
- `listMessagePage()` returns the newest contiguous page in chronological order. `limit` must be an integer from 1 through 50 and defaults to 50. `nextCursor` is opaque, limited to 4096 UTF-8 bytes, bound to the resolved storage namespace and session, and remains stable when newer messages are appended. Mismatched and stale cursors fail validation. `getMessage()` performs an exact lookup. Transfer identifiers are limited to 512 bytes, text and reasoning parts to 96 KiB, complete messages to 480 KiB, and complete page envelopes to 512 KiB. A page may therefore contain fewer messages than requested. Oversized text is truncated and an otherwise oversized parts collection is replaced with an explicit elision marker; metadata that still cannot fit fails validation. Canonical private Agent events are unchanged.
611
+ `listMessagePage()` returns the newest contiguous page in chronological order. `limit` must be an integer from 1 through 50 and defaults to 50. `nextCursor` is opaque, limited to 4096 UTF-8 bytes, bound to the resolved storage namespace and session, and remains stable when newer messages are appended. Mismatched and stale cursors fail validation. Each page carries `startIndex`, the zero-based index of its first message in the session's visible history (for an empty page, the index the page ends at), so a consumer can order and page by absolute position. Appending messages leaves every index unchanged; a branch after an undo reuses the positions of the history it replaces, so a consumer re-reads its pages after `session.history.changed`. `getMessage()` performs an exact lookup. Transfer identifiers are limited to 512 bytes, text and reasoning parts to 96 KiB, complete messages to 480 KiB, and complete page envelopes to 512 KiB. A page may therefore contain fewer messages than requested. Oversized text is truncated and an otherwise oversized parts collection is replaced with an explicit elision marker; metadata that still cannot fit fails validation. Canonical private Agent events are unchanged.
605
612
 
606
- `updateSession()` supports title replacement, explicit title clearing with `null`, and archive state through `archived`. Title-only updates remain available while prompts are queued or running, while permission is pending, and after archival. Requests containing `archived` are rejected while the session has any outstanding prompt or pending permission; a mixed title-and-archive request is rejected atomically without changing the title. Archived sessions expose `archivedAt`. Deleting a session cascades through its complete descendant subtree. One durable root-keyed tombstone group hides every newly affected live session, and the delete also joins any already-separate descendant cleanup groups without rewriting their roots. FlexHarness then cancels queued and active subtree work, emits terminal queue events, waits for admitted initialization, and purges runtime queue status while cleaning runtime and persisted domains child-first. The requested root tombstone is removed last after every domain confirms cleanup; project-management cleanup confirmation is a retained durable project tombstone rather than physical removal. A successful live `deleteSession()` call emits `session.deleted` for each session it newly tombstoned; retries of an existing tombstone and automatic load, retirement, or disposal cleanup emit no deletion events. Direct deletion of a descendant cascades only through that descendant's subtree. Cleanup authority follows the resolved storage namespace, so scope aliases share the same groups. A partial failure retains durable ownership for retry by a later `deleteSession()`, namespace load, `retireScope()`, or `dispose()` call.
613
+ `updateSession()` supports title replacement, explicit title clearing with `null`, and archive state through `archived`. Title-only updates remain available while prompts are queued or running, while permission is pending, and after archival. Requests containing `archived` are rejected while the session has any outstanding prompt or pending permission; a mixed title-and-archive request is rejected atomically without changing the title. Archived sessions expose `archivedAt`. Deleting a session cascades through its complete descendant subtree. One durable root-keyed tombstone group hides every newly affected live session, and the delete also joins any already-separate descendant cleanup groups without rewriting their roots. FlexHarness then cancels queued and active subtree work, emits terminal queue events, waits for admitted initialization, and purges runtime queue status while cleaning runtime and persisted domains child-first. The requested root tombstone is removed last after every domain confirms cleanup; project-management cleanup confirmation is a retained durable project tombstone rather than physical removal. An imported session can hold no project-management state, so its deletion writes no project tombstone. A successful live `deleteSession()` call emits `session.deleted` for each session it newly tombstoned; retries of an existing tombstone and automatic load, retirement, or disposal cleanup emit no deletion events. Direct deletion of a descendant cascades only through that descendant's subtree. Cleanup authority follows the resolved storage namespace, so scope aliases share the same groups. A partial failure retains durable ownership for retry by a later `deleteSession()`, namespace load, `retireScope()`, or `dispose()` call.
607
614
 
608
615
  `deleteSessionGenerationCohort()` is the generation-fenced destructive form for controllers. Its `root` and every `authorizedCohort` entry use the exact `{ sessionId, sessionGenerationId, sessionGenerationSequence }` shape. The cohort contains unique entries in strictly ascending `sessionId` order and is limited by `FLEX_SESSION_GENERATION_COHORT_MAX_ENTRIES` (2048). FlexHarness atomically validates the matching root, its complete live subtree, and every retained descendant tombstone group before reserving deletion. A missing or different root generation returns `{ matched: false }` without touching a newer generation; a missing or mismatched cascade entry throws before new tombstoning or cleanup. Extra valid entries do not expand the cascade. A matched partial cleanup remains retryable with the same authority and resolves to `{ matched: true }` when cleanup completes. The existing `deleteSession()` method remains available for callers that intentionally own the complete reusable-ID namespace.
609
616
 
@@ -783,7 +790,7 @@ Workspace reversion is generic and application-defined. It does not reverse netw
783
790
 
784
791
  Every configured value must be an integer from 1 through its hard maximum. Pruning removes complete prefixes rather than splitting an undo unit. Excluded run IDs prevent a committed branch from re-entering model context, while pending releases retain provider ownership until acknowledgement.
785
792
 
786
- `retireScope()` stops runtime ownership for the complete resolved storage namespace without deleting its durable snapshot. It does not load a namespace that has no cached or in-flight state. For loaded state, it preserves and waits for persistence that has already started, while later queued reads, writes, and run admissions reject with `FlexHarnessAbortError`. It cancels queued prompts and cancellable runs, rejects pending permissions, emits queue terminal events, waits for committing runs, terminal persistence, queue drains, tool-handle closure, and detached tool-provider cleanup, then purges queue status and clears and evicts the cached state. Failed cleanup ownership remains cached so a later `retireScope()` or `dispose()` call can retry it. Calls through storage-key aliases share the same retirement drain. A later call can load the durable namespace again after successful retirement if the application still resolves it.
793
+ `retireScope()` stops runtime ownership for the complete resolved storage namespace without deleting its durable snapshot. It does not load a namespace that has no cached or in-flight state. For loaded state, it preserves and waits for persistence that has already started, while later queued reads, writes, and run admissions reject with `FlexHarnessAbortError`. It cancels queued prompts and cancellable runs, rejects pending permissions, emits queue terminal events, waits for committing runs, terminal persistence, queue drains, tool-handle closure, and detached tool-provider cleanup, then purges queue status and clears and evicts the cached state. Failed cleanup ownership remains cached so a later `retireScope()` or `dispose()` call can retry it. Calls through storage-key aliases share the same retirement drain. A later call can load the durable namespace again after successful retirement if the application still resolves it. A loaded namespace keeps every session's messages in memory, so `retireScope()` is also the supported way for a host to evict a scope it has stopped using, such as an opened archive of imported sessions. Retirement releases every staged session import and cancels queued prompts and runs, so a host retires only a scope with no open import and no work it still wants.
787
794
 
788
795
  Normal retirement-induced cancellation does not make `retireScope()` reject. Unexpected failures observed through run finalization or scoped cleanup are surfaced without dropping the resources that still require cleanup. One such failure is thrown directly; multiple failures are reported through `FlexHarnessRunError`. Calling retirement or disposal again retries retained cleanup ownership.
789
796
 
@@ -805,6 +812,82 @@ Public audit history is safe to send to controllers: attachment parts contain so
805
812
 
806
813
  Sessions expose `idle`, `scheduled`, `running`, `waiting_permission`, `failed`, and `cancelled` status. Persisted non-terminal activity is repaired from canonical Agent generation outcomes after process restart; incomplete messages and parts normalize to `cancelled` unless an accepted hidden terminal stage can be promoted.
807
814
 
815
+ ## Conversation Import
816
+
817
+ A finished conversation from another tool can be imported as an archived, read-only session. The import is staged in three steps, so a large conversation crosses a process boundary in bounded pages. Turning a source format into Flex messages is the importer's job; the core validates, bounds, persists and protects the result.
818
+
819
+ ```typescript
820
+ const started = await harness.beginSessionImport('project:billing', {
821
+ sessionId: 'claude-7f3c2a',
822
+ title: 'Fix the billing export',
823
+ createdAt: '2026-09-01T09:00:00.000Z',
824
+ updatedAt: '2026-09-01T11:00:00.000Z',
825
+ origin: {
826
+ source: 'claude-code-transcript',
827
+ sourceId: '7f3c2a',
828
+ digest: 'sha256:9b1d…',
829
+ details: { cwd: '/workspace' },
830
+ },
831
+ });
832
+
833
+ if (started.status === 'started') {
834
+ try {
835
+ for (const page of pages) {
836
+ await harness.appendImportedRuns(started.handle, page);
837
+ }
838
+ const session = await harness.commitSessionImport(started.handle);
839
+ } finally {
840
+ await harness.abortSessionImport(started.handle);
841
+ }
842
+ }
843
+ ```
844
+
845
+ - **`beginSessionImport(scopeId, options)`** validates the options and reserves the caller-chosen `sessionId`. Choose a deterministic id, derived from the source. The result is one of three:
846
+ - `started`, with a handle `{ importId, scopeId, sessionId }`;
847
+ - `already_imported`, with the existing session;
848
+ - `digest_mismatch`, with the existing session.
849
+
850
+ A scope holds at most one import per `origin.source`, `origin.sourceId` and `origin.part.index`, whatever its session id. `already_imported` means that session has the same `origin.digest`, so the caller skips it. `digest_mismatch` means the source changed since; the caller deletes that session and imports again. A staged import of the same session id or source identity throws `FlexHarnessSessionBusyError`. Until the commit completes, `listSessions()` omits the session and `createSession()` refuses its id. While the import is staged, `getSession()` throws `FlexHarnessSessionBusyError`. While its commit runs, `getSession()` throws `FlexHarnessNotFoundError`, because a deletion tombstone reserves the id.
851
+ - **`appendImportedRuns(handle, runs)`** stages one page of runs, in order. A run is `{ user, assistant }`, two messages of the exact `IFlexMessage` shape. Both belong to the imported session, share one `runId` and one terminal status (`completed`, `failed` or `cancelled`), and have no `running` reasoning or tool part. Timestamps are ISO 8601 as `Date.prototype.toISOString()` renders them. Run ids and message ids are unique within the import. A page that breaks a rule or a bound stages nothing, and the import stays open. The result reports the staged `runs`, `messages` and `bytes`.
852
+ - **`commitSessionImport(handle)`** persists the runs and publishes the session, with one `session.created` event:
853
+ - `origin` is `{ kind: 'import', source, sourceId, digest, part?, details?, importedAt }`, and `archivedAt` equals `importedAt`;
854
+ - `createdAt` and `updatedAt` are the ones passed to `beginSessionImport()`, and the status is `idle`.
855
+
856
+ The commit first persists a deletion tombstone for the id, then writes the projection, then replaces the tombstone with the session in one scope save. A failed commit removes what it persisted through the normal tombstone cleanup. After a crash, or a save whose outcome is uncertain, the next load of the namespace resolves it: a surviving tombstone is cleaned up, and a published session is kept. A commit needs at least one run.
857
+ - **`abortSessionImport(handle)`** discards a staged import. Nothing of it was persisted. An unknown or finished handle is ignored, so the call is safe in a `finally`. A staged import that receives no `appendImportedRuns()` call for `stagedImportIdleTimeoutMs` expires and is discarded the same way; its handle then reports `FlexHarnessNotFoundError`.
858
+ - **Child sessions.** `parent: { sessionId, runId, toolCallId, agent }` imports a child session, such as a subagent's conversation. The parent must be a committed imported session in the same scope. Its assistant message of `runId` must hold the tool call `toolCallId` whose `childSessionId` names the child. No other session may claim that tool call. The child gets `depth` one below its parent, at most `FLEX_SESSION_IMPORT_MAX_DEPTH` (8). Deleting the parent deletes its children.
859
+
860
+ **Read-only.** An imported session never runs, and nothing writes model context for it: it has no Agent events and no tool jobs. Every operation that would change its history or model context throws `FlexHarnessImportedSessionError` (code `FLEX_SESSION_READ_ONLY`):
861
+
862
+ - `prompt`, `startPrompt`, `enqueuePrompt` and `schedulePrompt`;
863
+ - `executeSlashCommand` and `compactSession`;
864
+ - `undoSession` and `redoSession`;
865
+ - `pushRuntimeEvent`, `reconcileToolExecution` and `archiveSessionEvents`;
866
+ - the project-management writes: tasks, goal and scratchpad.
867
+
868
+ `listSlashCommands()` reports every command unavailable with the reason `Session is an imported conversation and is read-only.` Reads work: sessions, messages, message pages, reversion info and project state. So do `updateSession()` (title and archived flag), `deleteSession()` and `deleteSessionGenerationCohort()`. A load never repairs an imported session's runs from Agent generation outcomes, because it has none.
869
+
870
+ **Bounds.** `sessionImportLimits` sets the bounds; each must be an integer from 1 through its maximum:
871
+
872
+ | Limit | Default | Maximum |
873
+ |---|---|---|
874
+ | `maxOpenImports` (staged imports at once, per harness) | 2 | 64 |
875
+ | `maxMessagesPerSession` | 2048 | 20000 |
876
+ | `maxSessionBytes` (JSON bytes of all messages) | 64 MiB | 256 MiB |
877
+ | `maxPageBytes` (JSON bytes of one `appendImportedRuns()` page) | 1 MiB | 1.5 MiB |
878
+ | `stagedImportIdleTimeoutMs` (idle time before a staged import expires) | 5 minutes | 1 hour |
879
+
880
+ Some bounds are fixed:
881
+
882
+ - one message is at most `FLEX_SESSION_IMPORT_MAX_MESSAGE_BYTES` (480 KiB), and must read back through the message transfer limits;
883
+ - `origin.details` is a JSON object of at most `FLEX_SESSION_IMPORT_MAX_DETAILS_BYTES` (16 KiB);
884
+ - `origin.source` is at most 128 UTF-8 bytes, `origin.sourceId` 512 and `origin.digest` 256, none with control characters;
885
+ - `origin.part` has a `count` from 1 through 1024 and a zero-based `index` below it.
886
+
887
+ Staged runs are held in memory until the commit, so the memory of open imports is bounded by `maxOpenImports` × `maxSessionBytes`. Retiring the scope, disposing the harness or the idle expiry discards staged imports. The expiry timer does not keep the process alive.
888
+
889
+ **Stores.** The import adds no store method. Scope snapshots carry the optional session `origin`, and a store that validates session keys exactly must accept it. The commit writes the whole projection in one save at revision 1. FlexHarness versions before 9.5.0 reject the new key under their strict reader, so a downgrade over imported sessions is unsupported. The tombstone that reserves an import, or that deletes an imported session, carries the optional `imported: true`, and a store that validates tombstone keys exactly must accept it. FlexHarness 9.5.x rejects a scope snapshot that holds such a tombstone; one exists only while an import commits or an imported session is deleted, or after either was interrupted.
890
+
808
891
  ## Permissions
809
892
 
810
893
  Tools request permission through the run-scoped provider context:
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@modelprofile.com/flexharness',
6
- version: '9.4.0',
6
+ version: '9.6.0',
7
7
  description: 'The FlexHarness toolbox source repository and shared dependency catalog.'
8
8
  }