@modelprofile.com/flexharness 3.3.0 → 3.4.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.
@@ -323,9 +323,18 @@ export interface IFlexExecutionContextHandle {
323
323
  export interface IFlexExecutionContextProvider<TScope> {
324
324
  provideExecutionContext(context: IFlexExecutionContextProviderContext<TScope>): Promise<IFlexExecutionContextHandle | undefined> | IFlexExecutionContextHandle | undefined;
325
325
  }
326
- export interface IFlexAgentSessionPolicy {
326
+ export interface IFlexAgentContextInvocation<TScope = unknown> {
327
+ readonly scopeId: string;
328
+ readonly scope: TScope;
329
+ readonly storageKey: string;
330
+ readonly sessionId: string;
331
+ }
332
+ export interface IFlexAgentContextCompactionOptions<TScope = unknown> extends plugins.IAgentContextCompactionOptions, IFlexAgentContextInvocation<TScope> {
333
+ }
334
+ export type TFlexAgentContextCompactor<TScope = unknown> = (messages: Parameters<plugins.TAgentContextCompactor>[0], events: Parameters<plugins.TAgentContextCompactor>[1], options: IFlexAgentContextCompactionOptions<TScope>) => ReturnType<plugins.TAgentContextCompactor>;
335
+ export interface IFlexAgentSessionPolicy<TScope = unknown> {
327
336
  contextBuilder?: plugins.TAgentContextBuilder;
328
- contextCompactor?: plugins.TAgentContextCompactor;
337
+ contextCompactor?: TFlexAgentContextCompactor<TScope>;
329
338
  eventRetention?: TFlexAgentSessionOptions['eventRetention'];
330
339
  changeListenerTimeoutMs?: number;
331
340
  maxPendingSessionChanges?: number;
@@ -339,7 +348,7 @@ export interface IFlexHarnessOptions<TScope> {
339
348
  toolProvider?: IFlexToolProvider<TScope>;
340
349
  executionContextProvider?: IFlexExecutionContextProvider<TScope>;
341
350
  stores?: IFlexHarnessStores;
342
- agentSessionPolicy?: IFlexAgentSessionPolicy;
351
+ agentSessionPolicy?: IFlexAgentSessionPolicy<TScope>;
343
352
  toolOutputLimits?: IFlexJsonLimits;
344
353
  callbackLimits?: IFlexCallbackLimits;
345
354
  promptQueueLimits?: IFlexPromptQueueLimits;
@@ -1,7 +1,8 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
1
2
  import * as crypto from 'node:crypto';
2
3
  import * as fs from 'node:fs/promises';
3
4
  import * as path from 'node:path';
4
- export { crypto, fs, path };
5
+ export { AsyncLocalStorage, crypto, fs, path };
5
6
  import { AgentEventStoreConflictError, AgentSession, buildModelMessages, ToolJobStoreConflictError, createAgentEvent, getAgentGenerationTransactions, modelMessagesToAgentEvents, validateAgentEventArchiveV2, validateAgentEventSnapshotV2 } from '@push.rocks/smartagent';
6
7
  export { AgentEventStoreConflictError, AgentSession, buildModelMessages, ToolJobStoreConflictError, createAgentEvent, getAgentGenerationTransactions, modelMessagesToAgentEvents, validateAgentEventArchiveV2, validateAgentEventSnapshotV2, };
7
- export type { IAgentEventArchiveV2, IAgentEventSnapshotV2, IAgentEventStoreV2, IAgentGenerateResult, IAgentGenerationHandle, IAgentGenerationLease, IAgentRunResult, IAgentSession, IAgentSessionOptions, IAgentRuntimeEventPayload, IGenerationBegunEvent, IGenerationExecutionCompletedEvent, IGenerationExecutionStartedEvent, IGenerationOutcomeEvent, IToolExecutionContext, IToolExecutionIntentEvent, IToolJobSnapshot, IToolJobState, IToolJobStore, TAgentContextBuilder, TAgentContextCompactor, TAgentEvent, TAgentGenerationOutcome, TAgentToolCallFinishEvent, TAgentToolExecutionReconciliationOptions, } from '@push.rocks/smartagent';
8
+ export type { IAgentEventArchiveV2, IAgentContextCompactionOptions, IAgentEventSnapshotV2, IAgentEventStoreV2, IAgentGenerateResult, IAgentGenerationHandle, IAgentGenerationLease, IAgentRunResult, IAgentSession, IAgentSessionOptions, IAgentRuntimeEventPayload, IGenerationBegunEvent, IGenerationExecutionCompletedEvent, IGenerationExecutionStartedEvent, IGenerationOutcomeEvent, IToolExecutionContext, IToolExecutionIntentEvent, IToolJobSnapshot, IToolJobState, IToolJobStore, TAgentContextBuilder, TAgentContextCompactor, TAgentEvent, TAgentGenerationOutcome, TAgentToolCallFinishEvent, TAgentToolExecutionReconciliationOptions, } from '@push.rocks/smartagent';
@@ -1,9 +1,10 @@
1
1
  // node native scope
2
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
3
  import * as crypto from 'node:crypto';
3
4
  import * as fs from 'node:fs/promises';
4
5
  import * as path from 'node:path';
5
- export { crypto, fs, path };
6
+ export { AsyncLocalStorage, crypto, fs, path };
6
7
  // @push.rocks scope
7
8
  import { AgentEventStoreConflictError, AgentSession, buildModelMessages, ToolJobStoreConflictError, createAgentEvent, getAgentGenerationTransactions, modelMessagesToAgentEvents, validateAgentEventArchiveV2, validateAgentEventSnapshotV2, } from '@push.rocks/smartagent';
8
9
  export { AgentEventStoreConflictError, AgentSession, buildModelMessages, ToolJobStoreConflictError, createAgentEvent, getAgentGenerationTransactions, modelMessagesToAgentEvents, validateAgentEventArchiveV2, validateAgentEventSnapshotV2, };
9
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3BsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsb0JBQW9CO0FBQ3BCLE9BQU8sS0FBSyxNQUFNLE1BQU0sYUFBYSxDQUFDO0FBQ3RDLE9BQU8sS0FBSyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDdkMsT0FBTyxLQUFLLElBQUksTUFBTSxXQUFXLENBQUM7QUFFbEMsT0FBTyxFQUFFLE1BQU0sRUFBRSxFQUFFLEVBQUUsSUFBSSxFQUFFLENBQUM7QUFFNUIsb0JBQW9CO0FBQ3BCLE9BQU8sRUFDTCw0QkFBNEIsRUFDNUIsWUFBWSxFQUNaLGtCQUFrQixFQUNsQix5QkFBeUIsRUFDekIsZ0JBQWdCLEVBQ2hCLDhCQUE4QixFQUM5QiwwQkFBMEIsRUFDMUIsMkJBQTJCLEVBQzNCLDRCQUE0QixHQUM3QixNQ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QUE0QixHQUM3QixDQUFDIn0=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelprofile.com/flexharness",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "private": false,
5
5
  "description": "Provider-neutral model-session runtime with durable history, permissions, typed events, and pluggable local or remote tool execution.",
6
6
  "main": "dist_ts/index.js",
package/readme.hints.md CHANGED
@@ -22,6 +22,7 @@ Implementation findings for flexharness.
22
22
  - Permission callbacks wait for the current save tail and then revalidate their run before reading remembered grants, so neither uncommitted grants nor captured callbacks can authorize later work.
23
23
  - Detached tool-provider settlement remains tracked after prompt finalization. Failed late handle closure stays owned by its storage state and is retried by a later retirement or disposal call.
24
24
  - Scope retirement fences older resolver calls and late state admissions, drains the complete resolved storage namespace, and evicts only the exact cached state promise. It never deletes the durable snapshot. Applications must close admission across every resolver alias before retirement because aliases are unknowable before resolution.
25
+ - Context compaction runs under immutable async invocation context rather than storage-state scope hints. This keeps `scopeId`, `scope`, `storageKey`, and `sessionId` exact for manual, retention, and context-overflow compaction even when aliases share one cached namespace. Autonomous job callbacks use their immutable session-owner context because no later public invocation owns them.
25
26
  - Detached tool-provider cleanup and retained session cleanup are owned by the exact loaded storage state. Failed drains retain that ownership and the cached state for retry. Scope retirement cannot await or consume another namespace's cleanup, while full disposal settles all storage drains and orphaned initialization cleanup before aggregating failures.
26
27
  - JSON provider release hooks evict non-destructive session wrapper caches after AgentSession and execution-context ownership ends. Failed partial-initialization releases remain storage-scoped orphan ownership and are retried by retirement or disposal.
27
28
  - `JsonFileFlexHarnessStores.dispose()` is the explicit final drain for file handles whose close failed on the last store operation; failed disposal retains the handle for another call.
package/readme.md CHANGED
@@ -280,7 +280,7 @@ Model resolver, tool provider, AgentSession, tool execution, tool callback, tool
280
280
 
281
281
  Transactional tool calls persist an execution intent before the tool side effect starts. After an interrupted process, `listUncertainToolExecutions()` exposes intents whose outcome cannot be proven. A controller must inspect the external system and call `reconcileToolExecution()` with `executed`, `not-executed`, or `abandoned-unknown` before allowing dependent work to continue. Reconciliation output is normalized using the same tool-output limits.
282
282
 
283
- `agentSessionPolicy` forwards bounded SmartAgent session controls for context building, compaction, event retention, change-listener pressure, lease cleanup, archived transaction tombstones, and context-overflow retries. With a configured `contextCompactor`, `compactSession()` writes a canonical compaction event. `archiveSessionEvents()` moves events covered by that compaction into the configured Agent event archive store and returns public archive metadata.
283
+ `agentSessionPolicy` forwards bounded SmartAgent session controls for context building, compaction, event retention, change-listener pressure, lease cleanup, archived transaction tombstones, and context-overflow retries. A configured `contextCompactor` receives the projected model messages, only the filtered model-visible covered events, SmartAgent's existing `reason` and `abortSignal`, and the exact resolved `scopeId`, `scope`, `storageKey`, and `sessionId` for the invocation causing compaction. The invocation context remains isolated when aliases share one storage key, so integrations can resolve the correct model without global mutable state. If no events are eligible for compaction, `compactSession()` returns without calling the compactor or writing a compaction event; otherwise it writes the canonical event. `archiveSessionEvents()` moves events covered by that compaction into the configured Agent event archive store and returns public archive metadata.
284
284
 
285
285
  `executionContextProvider` can construct a SmartAgent execution context for each session. FlexHarness supplies the resolved scope, storage key, and the session's private job store. The public background APIs expose only execution ID, type, state, exit code, and timestamps; command payloads, stdout, and stderr remain private. The provider's optional `close()` is owned by session deletion, scope retirement, and harness disposal.
286
286
 
@@ -316,7 +316,7 @@ const unsubscribe = harness.subscribe((event) => {
316
316
  unsubscribe();
317
317
  ```
318
318
 
319
- Events are discriminated, sequenced, deeply immutable snapshots. Listener exceptions are isolated from runs and other listeners. Every accepted queue entry emits `prompt.queued` and exactly one `prompt.finished`. Durable promotion additionally emits `prompt.started`, and actual model preparation emits `prompt.running`; cancellation or failure can omit either intermediate event. Existing durable run/message terminal events precede `prompt.finished`. Every `part.started`, `part.delta`, and `part.completed` event carries zero-based `messageIndex` and `partIndex` coordinates from the session's authoritative message and part sequences. Events contain public IDs and snapshots only; they do not expose prompt payloads, the resolved scope object, storage key, model object, or provider options.
319
+ Events are discriminated, sequenced, deeply immutable snapshots. Listener exceptions are isolated from runs and other listeners. Every accepted queue entry emits `prompt.queued` and exactly one `prompt.finished`. Durable promotion additionally emits `prompt.started`, and actual model preparation emits `prompt.running`; cancellation or failure can omit either intermediate event. Existing durable run/message terminal events precede `prompt.finished`. Every callback-backed streamed text part emits exactly one `part.completed` event before the corresponding `run.finished` event. Every `part.started`, `part.delta`, and `part.completed` event carries zero-based `messageIndex` and `partIndex` coordinates from the session's authoritative message and part sequences. Events contain public IDs and snapshots only; they do not expose prompt payloads, the resolved scope object, storage key, model object, or provider options.
320
320
 
321
321
  ## Stores
322
322
 
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@modelprofile.com/flexharness',
6
- version: '3.3.0',
6
+ version: '3.4.0',
7
7
  description: 'Provider-neutral model-session runtime with durable history, permissions, typed events, and pluggable local or remote tool execution.'
8
8
  }