@hydraharness/harness-client-runtime 0.0.0-stage → 0.1.1-rc.7

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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +96 -2
  3. package/lib/client.js +10964 -0
  4. package/lib/index.js +6 -0
  5. package/lib/invariant.js +36 -0
  6. package/lib/types/client/agents/scope.d.ts +35 -0
  7. package/lib/types/client/contract/conversation.d.ts +242 -0
  8. package/lib/types/client/contract/session.d.ts +97 -0
  9. package/lib/types/client/contract/sessions-port.d.ts +55 -0
  10. package/lib/types/client/contract/sessions.d.ts +164 -0
  11. package/lib/types/client/contract/settings-scope.d.ts +79 -0
  12. package/lib/types/client/contract/store.d.ts +90 -0
  13. package/lib/types/client/contract/workspaces.d.ts +102 -0
  14. package/lib/types/client/conversation/definition-registry.d.ts +30 -0
  15. package/lib/types/client/conversation/event-registry.d.ts +27 -0
  16. package/lib/types/client/conversation/view-registry.d.ts +15 -0
  17. package/lib/types/client/index.d.ts +128 -0
  18. package/lib/types/client/ordered-baseline.d.ts +12 -0
  19. package/lib/types/client/sessions/assistant-timing.d.ts +34 -0
  20. package/lib/types/client/sessions/context-provenance.d.ts +58 -0
  21. package/lib/types/client/sessions/conversation-assembler.d.ts +107 -0
  22. package/lib/types/client/sessions/conversation-context.d.ts +22 -0
  23. package/lib/types/client/sessions/conversation-location-index.d.ts +70 -0
  24. package/lib/types/client/sessions/conversation-versions.d.ts +25 -0
  25. package/lib/types/client/sessions/conversation.d.ts +422 -0
  26. package/lib/types/client/sessions/failure-display.d.ts +7 -0
  27. package/lib/types/client/sessions/lineage.d.ts +47 -0
  28. package/lib/types/client/sessions/manager.d.ts +300 -0
  29. package/lib/types/client/sessions/notifier.d.ts +35 -0
  30. package/lib/types/client/sessions/partial.d.ts +40 -0
  31. package/lib/types/client/sessions/pending.d.ts +55 -0
  32. package/lib/types/client/sessions/projection-store.d.ts +111 -0
  33. package/lib/types/client/sessions/provide.d.ts +79 -0
  34. package/lib/types/client/sessions/queue-mirror.d.ts +33 -0
  35. package/lib/types/client/sessions/remotes.d.ts +10 -0
  36. package/lib/types/client/sessions/request-inspection.d.ts +74 -0
  37. package/lib/types/client/sessions/service.d.ts +415 -0
  38. package/lib/types/client/sessions/session.d.ts +287 -0
  39. package/lib/types/client/sessions/steering-history.d.ts +23 -0
  40. package/lib/types/client/sessions/subagent-lineage.d.ts +24 -0
  41. package/lib/types/client/sessions/tool-call-tree.d.ts +45 -0
  42. package/lib/types/client/slots.d.ts +191 -0
  43. package/lib/types/client/time-zone.d.ts +8 -0
  44. package/lib/types/client/workspaces/manager.d.ts +182 -0
  45. package/lib/types/client/workspaces/path.d.ts +17 -0
  46. package/lib/types/client/workspaces/service.d.ts +179 -0
  47. package/lib/types/client/workspaces/workspace.d.ts +65 -0
  48. package/lib/types/index.d.ts +4 -0
  49. package/lib/types/invariant.d.ts +16 -0
  50. package/package.json +94 -3
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The settings-namespace scope contract. The type lives here, in the common
3
+ * dependency of every feature that owns a preference, while the implementation
4
+ * and its Host transport live with the Settings surface
5
+ * (`@hydraharness/harness-client-ui-settings`): a feature service accepts a scope through
6
+ * `attachSettings` without depending on the surface that binds it, which would
7
+ * otherwise close a reference cycle.
8
+ */
9
+ /** Client-side sync state of one settings namespace. */
10
+ export interface SettingsScopeSnapshot<T> {
11
+ /**
12
+ * `loading` until the first accepted section, `ready` while one stands, and
13
+ * `unavailable` when the namespace is not exposed to this client or the
14
+ * connection keeps preferences process-local (memory mode).
15
+ */
16
+ status: 'loading' | 'ready' | 'unavailable';
17
+ /** Last accepted schema-resolved section; undefined before the first acceptance. */
18
+ value: T | undefined;
19
+ /**
20
+ * Composition layer the Host resolved {@link value} over, when the owning
21
+ * plugin declared one. What a field reverts to once cleared.
22
+ */
23
+ base: unknown;
24
+ /**
25
+ * Raw user layer as stored, when one exists. A field's PRESENCE here is what
26
+ * marks it overridden — an override whose value equals the composition
27
+ * default is still an override, and comparing values could not see it.
28
+ */
29
+ user: unknown;
30
+ /** Namespace revision fencing the next write; undefined before the first Host view. */
31
+ revision: number | undefined;
32
+ /** Whether the Host document accepts writes; memory mode never does. */
33
+ writable: boolean;
34
+ /** `host` syncs with the Host document; `memory` keeps a remote browser process-local. */
35
+ mode: 'host' | 'memory';
36
+ }
37
+ /** Domain-owned description of one settings namespace consumed by a browser plugin. */
38
+ export interface SettingsScopeSpec<T> {
39
+ /** Settings namespace registered by the owning Host plugin. */
40
+ namespace: string;
41
+ /**
42
+ * Narrow one wire section; undefined keeps the last accepted value. The
43
+ * default validates the section against the namespace's own serialized wire
44
+ * schema, so domains add a decoder only to narrow beyond that schema.
45
+ */
46
+ decode?: (section: unknown) => T | undefined;
47
+ }
48
+ /**
49
+ * Reactive owner handle over one namespace's durable section — the browser
50
+ * mirror of the Host-side `SettingsScope` owner seam. Domain services read
51
+ * and observe the snapshot and route explicit user choices through `set`.
52
+ */
53
+ export interface SettingsScope<T> {
54
+ /** @returns the current sync snapshot (stable reference until the next change). */
55
+ getSnapshot(): SettingsScopeSnapshot<T>;
56
+ /**
57
+ * Observe snapshot replacements.
58
+ * @param listener - invoked after each snapshot change.
59
+ * @returns the disposer removing this listener.
60
+ */
61
+ subscribe(listener: () => void): () => void;
62
+ /**
63
+ * Queue one field write. Rapid writes preserve mutation order, each carries
64
+ * the latest known namespace revision, and only the latest settlement may
65
+ * publish; a rejected or failed latest write reloads Host state instead.
66
+ * @param field - scalar field inside the namespace section.
67
+ * @param value - JSON-shaped value selected by the user.
68
+ * @returns settlement after the write and any latest-write recovery read.
69
+ */
70
+ set(field: string, value: unknown): Promise<void>;
71
+ /**
72
+ * Queue one field clear, so the field re-inherits the composition layer.
73
+ * Shares {@link set}'s ordering, revision, and recovery contract.
74
+ * @param field - scalar field inside the namespace section.
75
+ * @returns settlement after the clear and any latest-write recovery read.
76
+ */
77
+ unset(field: string): Promise<void>;
78
+ }
79
+ //# sourceMappingURL=settings-scope.d.ts.map
@@ -0,0 +1,90 @@
1
+ import type { ActionsDecl, StoreHandle, StoreInstance, StoreSpec } from '@hydraharness/harness-client-ui-slots';
2
+ export type { ActionsDecl, BakedActions, BoundActions, StoreFactory, StoreHandle, StoreInstance, StoreSpec, } from '@hydraharness/harness-client-ui-slots';
3
+ /** Minimal observable snapshot source: Session objects and snapshot stores both satisfy it. */
4
+ export interface ObservableSnapshot<T> {
5
+ getSnapshot(): T;
6
+ subscribe(fn: () => void): () => void;
7
+ }
8
+ /** Writable snapshot store (bare data face; React selector hooks are synthesized in ui-renderer). */
9
+ export interface SnapshotStore<T> extends ObservableSnapshot<T> {
10
+ /**
11
+ * Mutate the state through an immer draft.
12
+ * @param mutator - draft mutator.
13
+ */
14
+ update(mutator: (draft: T) => void): void;
15
+ /**
16
+ * Replace the state wholesale.
17
+ * @param next - next state.
18
+ */
19
+ set(next: T): void;
20
+ }
21
+ /**
22
+ * Shallow equality for selector slices (zustand/shallow semantics; travels
23
+ * with the engine so hook consumers need no zustand dependency).
24
+ * @param a - left value.
25
+ * @param b - right value.
26
+ * @returns whether the values are shallowly equal.
27
+ */
28
+ export declare function shallowEqual(a: unknown, b: unknown): boolean;
29
+ /**
30
+ * Create a snapshot store.
31
+ *
32
+ * Flush default is 'sync' (controlled inputs need same-tick echo); frame-driven
33
+ * stores opt into 'raf', where a frame's worth of updates coalesces into one
34
+ * notification. Known raf-mode tradeoff: a component mounting mid-frame reads
35
+ * fresh state while existing subscribers hear it next flush — transient
36
+ * frame-level skew, same nature as the object layer's microtask batching.
37
+ *
38
+ * @param init - initial state.
39
+ * @param opts - flush mode and opt-in persistence (localStorage, keyed by name).
40
+ * @returns the store.
41
+ */
42
+ export declare function createSnapshotStore<T>(init: T, opts?: {
43
+ flush?: 'raf' | 'sync';
44
+ persist?: {
45
+ name: string;
46
+ };
47
+ }): SnapshotStore<T>;
48
+ /** A live engine instance: the contract instance plus the raw engine store. */
49
+ export interface EngineStoreInstance<T, A extends ActionsDecl<T>> extends StoreInstance<T, A> {
50
+ /** The underlying engine store (framework/test API; components never see it). */
51
+ readonly store: SnapshotStore<T>;
52
+ }
53
+ /** The engine-backed handle: create() narrowed to the engine instance. */
54
+ export interface EngineStoreHandle<T, A extends ActionsDecl<T>> extends StoreHandle<T, A> {
55
+ /**
56
+ * Construct a live engine instance (see the contract JSDoc on
57
+ * {@link StoreHandle.create} for scopeKey/persist semantics).
58
+ *
59
+ * Known boundary: the persist key is the storage identity, so multiple live
60
+ * instances created under the same resolved key share (and cross-pollute)
61
+ * one localStorage entry. Instance uniqueness per key is the caller's
62
+ * responsibility — production is safe because the framework caches one
63
+ * instance per handle x scope key; tests wanting isolation use distinct
64
+ * scope keys or persist-free declarations (multi-create freedom is a
65
+ * feature there, so create() deliberately does not dedupe or throw).
66
+ * @param scopeKey - session id for session-scope instances; omitted for root scope.
67
+ * @returns the engine instance.
68
+ */
69
+ create(scopeKey?: string): EngineStoreInstance<T, A>;
70
+ }
71
+ /**
72
+ * Declare a store: initial state, optional persistence, and the full write
73
+ * set as pure draft mutators. The returned handle is the registration
74
+ * currency of the store seat — its identity keys instance sharing. Satisfies
75
+ * ui-slots' DefineStore contract (the handle/instance are the engine-extended
76
+ * subtypes).
77
+ *
78
+ * The `A & ActionsDecl<T>` actions position is load-bearing: T resolves from
79
+ * `init` in the first inference round, and the intersection then contextually
80
+ * types each mutator's draft parameter (context-sensitive functions defer),
81
+ * so call sites write `(d, x: X) => { ... }` with no draft annotation. If a
82
+ * future TS version breaks this single-literal inference, the design's
83
+ * documented fallback is currying (`defineStore(init).actions({...})`).
84
+ * @param decl - init lambda (fresh state per instance), optional persist key, actions table.
85
+ * @returns the store handle.
86
+ */
87
+ export declare function defineStore<T, A extends ActionsDecl<T>>(decl: StoreSpec<T, A> & {
88
+ actions: A & ActionsDecl<T>;
89
+ }): EngineStoreHandle<T, A>;
90
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1,102 @@
1
+ /**
2
+ * The outward workspaces-service face — what `ctx.workspaces` exposes to
3
+ * feature packages and the renderer host, and therefore exactly what the
4
+ * test runtime's workspaces double must implement. Wire-pump entry points
5
+ * (handleHostEnvelope/handleConnected/refresh/startInitialSelection) stay on
6
+ * the concrete class. Widening this interface is the explicit act of
7
+ * widening what features may do to the workspaces domain.
8
+ */
9
+ import type { DirectoryListing, SessionId, WorkspaceId, WorkspaceView } from '@hydraharness/harness-api-remotes/client';
10
+ import type { WorkspaceListState } from '../workspaces/service.ts';
11
+ import type { ObservableSnapshot } from './store.ts';
12
+ /** The workspaces-service face injected as `ctx.workspaces`. */
13
+ export interface IWorkspaces {
14
+ /** The useWorkspaces standard feed (read face — writes stay inside the domain). */
15
+ readonly list: ObservableSnapshot<WorkspaceListState>;
16
+ /**
17
+ * Connect a Workspace to its reusable or freshly created blank session.
18
+ * @param workspaceId - target workspace.
19
+ * @returns the connected session id.
20
+ */
21
+ connectWorkspace(workspaceId: WorkspaceId): Promise<SessionId>;
22
+ /**
23
+ * The New Session flow: connect the explicit, current-Session, or recent
24
+ * Workspace and open the resulting session; failures surface on the session
25
+ * list state.
26
+ * @param workspaceId - explicit target; omitted inherits the current
27
+ * Session's Workspace before falling back to the recency projection.
28
+ */
29
+ startSession(workspaceId?: WorkspaceId): void;
30
+ /**
31
+ * Register an existing path as a Workspace.
32
+ * @param input - the Host create payload.
33
+ * @returns the created or idempotently resolved Workspace.
34
+ */
35
+ create(input: {
36
+ path: string;
37
+ }): Promise<WorkspaceView>;
38
+ /**
39
+ * Open the Host's native directory picker.
40
+ * @returns the selected path, or null when the user cancelled.
41
+ */
42
+ pickDirectory(): Promise<string | null>;
43
+ /**
44
+ * List one directory level through the Host's `browse` capability.
45
+ * @param path - absolute directory to list; absent lists the Host home directory.
46
+ * @param signal - aborts the wire request (and the Host's scan) when the caller supersedes it.
47
+ * @returns the level's listing with breadcrumb ancestry.
48
+ */
49
+ listDirectory(path?: string, signal?: AbortSignal): Promise<DirectoryListing>;
50
+ /**
51
+ * Create one child directory through the Host's `browse` capability.
52
+ * @param path - absolute existing parent directory.
53
+ * @param name - single non-blank path segment.
54
+ * @returns the created directory's absolute path.
55
+ */
56
+ createDirectory(path: string, name: string): Promise<string>;
57
+ /**
58
+ * Open a filesystem path with the Host operating system's default application.
59
+ * @param path - absolute or host-resolvable path.
60
+ */
61
+ openPath(path: string): Promise<void>;
62
+ /**
63
+ * Rename a Workspace.
64
+ * @param workspaceId - target workspace.
65
+ * @param title - the new display title.
66
+ * @returns the updated Workspace view.
67
+ */
68
+ rename(workspaceId: WorkspaceId, title: string): Promise<WorkspaceView>;
69
+ /**
70
+ * Delete a Workspace (its sessions fall back to the unaccounted group).
71
+ * @param workspaceId - target workspace.
72
+ */
73
+ delete(workspaceId: WorkspaceId): Promise<void>;
74
+ /**
75
+ * Move a Workspace within the registry display order.
76
+ * @param workspaceId - Workspace to move.
77
+ * @param beforeWorkspaceId - Anchor workspace; omitted appends.
78
+ */
79
+ insertBefore(workspaceId: WorkspaceId, beforeWorkspaceId?: WorkspaceId): Promise<void>;
80
+ /**
81
+ * Move an accounted session within/into a Workspace's ordered list.
82
+ * @param workspaceId - target workspace.
83
+ * @param sessionId - accounted session to move.
84
+ * @param beforeSessionId - accounted anchor to insert before; omitted appends.
85
+ * @returns the updated Workspace view.
86
+ */
87
+ insertSessionBefore(workspaceId: WorkspaceId, sessionId: SessionId, beforeSessionId?: SessionId): Promise<WorkspaceView>;
88
+ /**
89
+ * Archive a session into the registry-global set (hidden from grouping
90
+ * surfaces; session log and accounting slot remain). Archiving the current
91
+ * session clears the selection into the New Session view state.
92
+ * @param sessionId - session to archive.
93
+ */
94
+ archiveSession(sessionId: SessionId): Promise<void>;
95
+ /**
96
+ * Restore one session from the registry-global archive set. Its retained
97
+ * Workspace account then makes it visible in the same Workspace again.
98
+ * @param sessionId - session to restore.
99
+ */
100
+ unarchiveSession(sessionId: SessionId): Promise<void>;
101
+ }
102
+ //# sourceMappingURL=workspaces.d.ts.map
@@ -0,0 +1,30 @@
1
+ import { Service } from '@hydraharness/cordis';
2
+ /** Shared lifecycle and stable-entry storage for one Conversation Definition registry. */
3
+ export declare abstract class ConversationDefinitionRegistry<Definition> extends Service {
4
+ protected readonly definitions: Map<string, Definition>;
5
+ private listeners;
6
+ private cached;
7
+ /**
8
+ * Return reference-stable Definitions in registration order.
9
+ * @returns current Definitions.
10
+ */
11
+ entries(): readonly Definition[];
12
+ /**
13
+ * Observe low-frequency registry changes.
14
+ * @param listener - synchronous invalidation callback.
15
+ * @returns unsubscribe callback.
16
+ */
17
+ subscribe(listener: () => void): () => void;
18
+ /**
19
+ * Register one uniquely keyed Definition for the caller's lifetime.
20
+ * @param key - registry-local unique key.
21
+ * @param definition - contributed Definition.
22
+ * @param duplicateMessage - error raised when the key is already owned.
23
+ * @param effectName - Cordis effect diagnostic label.
24
+ * @returns idempotent disposer.
25
+ */
26
+ protected registerDefinition(key: string, definition: Definition, duplicateMessage: string, effectName: string): () => void;
27
+ /** Refresh cached entries and synchronously invalidate subscribers. */
28
+ protected refresh(): void;
29
+ }
30
+ //# sourceMappingURL=definition-registry.d.ts.map
@@ -0,0 +1,27 @@
1
+ import type { Context } from '@hydraharness/cordis';
2
+ import type { ConversationNodeDefinition } from '../contract/conversation.ts';
3
+ import { ConversationDefinitionRegistry } from './definition-registry.ts';
4
+ /** Runtime registry of independently owned Conversation business Definitions. */
5
+ export declare class ConversationEventRegistry extends ConversationDefinitionRegistry<ConversationNodeDefinition> {
6
+ private fallback;
7
+ /** @param ctx - owning Client Runtime context. */
8
+ constructor(ctx: Context);
9
+ /**
10
+ * Register a uniquely named business Definition for the caller's lifetime.
11
+ * @param definition - Definition contribution.
12
+ * @returns idempotent disposer.
13
+ */
14
+ register(definition: ConversationNodeDefinition): () => void;
15
+ /**
16
+ * Register the sole fallback used only when no ordinary Definition matches.
17
+ * @param definition - fallback Definition.
18
+ * @returns idempotent disposer.
19
+ */
20
+ registerFallback(definition: ConversationNodeDefinition): () => void;
21
+ /**
22
+ * Return the current unmatched-event fallback.
23
+ * @returns installed fallback, when present.
24
+ */
25
+ fallbackEntry(): ConversationNodeDefinition | undefined;
26
+ }
27
+ //# sourceMappingURL=event-registry.d.ts.map
@@ -0,0 +1,15 @@
1
+ import type { Context } from '@hydraharness/cordis';
2
+ import type { ConversationViewDefinition } from '../contract/conversation.ts';
3
+ import { ConversationDefinitionRegistry } from './definition-registry.ts';
4
+ /** Runtime registry of per-target Conversation snapshot builders. */
5
+ export declare class ConversationViewRegistry extends ConversationDefinitionRegistry<ConversationViewDefinition> {
6
+ /** @param ctx - owning Client Runtime context. */
7
+ constructor(ctx: Context);
8
+ /**
9
+ * Register a uniquely named view builder factory for the caller's lifetime.
10
+ * @param definition - target builder contribution.
11
+ * @returns idempotent disposer.
12
+ */
13
+ register(definition: ConversationViewDefinition): () => void;
14
+ }
15
+ //# sourceMappingURL=view-registry.d.ts.map
@@ -0,0 +1,128 @@
1
+ /** Browser runtime services for slots, sessions, workspaces, and connection-stream delivery. */
2
+ import type { Context } from '@hydraharness/cordis';
3
+ import type { SessionId } from '@hydraharness/harness-api-remotes/client';
4
+ import type { TypertContext } from '@hydraharness/harness-typert-protocol';
5
+ import type { MaybeSnapshotSelectorHook, SnapshotSelectorHook } from '@hydraharness/harness-client-ui-slots';
6
+ import type { SessionListState } from './sessions/service.ts';
7
+ import type { ConversationSnapshot } from './sessions/conversation.ts';
8
+ import type { UseProjection } from './sessions/projection-store.ts';
9
+ export { isAppendSurfaceEvent, isReplacementSurfaceEvent } from '@hydraharness/harness-session/surface';
10
+ export { SlotRegistry } from './slots.ts';
11
+ export { ConversationEventRegistry } from './conversation/event-registry.ts';
12
+ export { ConversationViewRegistry } from './conversation/view-registry.ts';
13
+ export { ConversationNodeAssembler } from './sessions/conversation-assembler.ts';
14
+ export { ConversationLocationIndex } from './sessions/conversation-location-index.ts';
15
+ export { conversationContextKey } from './contract/conversation.ts';
16
+ export type { ChatConversationViewNode, ConversationContextReader, ConversationEventInput, ConversationLocationData, ConversationLocationDataScope, ConversationLocationDataStore, ConversationStepDataMap, ConversationLocation, ConversationMatch, ConversationMatchResult, ConversationNodeContext, ConversationNodeDefinition, ConversationPreviousContext, ConversationPublication, ConversationTimelineSnapshot, ConversationTurnDataMap, ConversationViewBuilder, ConversationViewDefinition, ConversationViewNode, ConversationViewSnapshotMap, ConversationViewSnapshotStore, StepLocation, TurnLocation, } from './contract/conversation.ts';
17
+ export type { ConversationRuntime } from './sessions/conversation-assembler.ts';
18
+ export type { RootOwnerProps } from './slots.ts';
19
+ export { SessionCreateError, SessionRuntime, scopeOf, workspaceTitleOf } from './sessions/service.ts';
20
+ export { indexSubagentDescendants } from './sessions/subagent-lineage.ts';
21
+ export { conversationVersions, conversationRepresentatives } from './sessions/conversation-versions.ts';
22
+ export type { ConversationVersion } from './sessions/conversation-versions.ts';
23
+ export type { SubagentDescendantSummary } from './sessions/subagent-lineage.ts';
24
+ export { SessionProvideChannel } from './sessions/provide.ts';
25
+ export type { SessionProvideChannelHost } from './sessions/provide.ts';
26
+ export { createScope } from './agents/scope.ts';
27
+ export type { AgentScopeHandle } from './agents/scope.ts';
28
+ export { DirectoryBrowseError, WorkspaceCreateError, WorkspaceRuntime } from './workspaces/service.ts';
29
+ export { abbreviateHomePath, resolveWorkspacePath } from './workspaces/path.ts';
30
+ export type { SettingsScope, SettingsScopeSnapshot, SettingsScopeSpec, } from './contract/settings-scope.ts';
31
+ export type { Session } from './sessions/session.ts';
32
+ export type { ISession, ProjectionsFace, SessionFace } from './contract/session.ts';
33
+ export type { AgentContext, ISessions } from './contract/sessions.ts';
34
+ export type { IWorkspaces } from './contract/workspaces.ts';
35
+ export type { SessionBinding, SessionListState, SessionProvideContribution, SessionProvideDescriptor, SessionSummary, } from './sessions/service.ts';
36
+ export type { SessionListPhase, SessionSearchResultItem, SubagentCatalogSnapshot } from './sessions/manager.ts';
37
+ export type { SubagentAddress, JobView } from '@hydraharness/harness-client-connection/client';
38
+ export type { WorkspaceListPhase } from './workspaces/manager.ts';
39
+ export type { WorkspaceListState } from './workspaces/service.ts';
40
+ export type { DirectoryEntry, DirectoryListing, WorkspaceId, WorkspaceView, } from '@hydraharness/harness-client-connection/client';
41
+ export { createSnapshotStore, defineStore, shallowEqual } from './contract/store.ts';
42
+ export type { EngineStoreHandle, EngineStoreInstance, ObservableSnapshot, SnapshotStore, } from './contract/store.ts';
43
+ export type { AssistantBlock, AssistantMessageNode, AssistantProvenanceView, AssistantRequestConfig, AssistantTiming, ChatLocationNodeIndex, ChatNodeStore, ChatSnapshot, CommandNode, CompactionSummaryNode, ComposerPhase, ContextMessageNode, ConversationNode, ConversationSnapshot, ModelRetryNode, QueuedMessage, LegacyConversationSlice, PartialAssistant, RunningToolCall, SteeringMessageNode, TodoItem, ToolCallBlock, ToolResultNode, TurnErrorNode, TurnMaxTokensNode, UnknownSurfaceNode, UserMessageNode, } from './sessions/conversation.ts';
44
+ export { EMPTY_CHAT_SNAPSHOT, EMPTY_CONVERSATION_VIEWS, toAssistantBlock, toAssistantBlocks, } from './sessions/conversation.ts';
45
+ export { emptyAssistantBlock } from './sessions/partial.ts';
46
+ export { isTokenDelta } from './sessions/assistant-timing.ts';
47
+ export { contextForm, contextProvenance, sessionRecallLabels } from './sessions/context-provenance.ts';
48
+ export { displayFailureMessage } from './sessions/failure-display.ts';
49
+ export type { ConversationContext, ConversationContextOriginKind, } from './sessions/conversation-context.ts';
50
+ export type { ContextProvenanceView, ContextRole, KnownContextForm, } from './sessions/context-provenance.ts';
51
+ export type { ConversationPromptSnapshot, RequestInspectionSnapshot, RequestPromptChange, RequestView, } from './sessions/request-inspection.ts';
52
+ export { PendingWait } from './sessions/pending.ts';
53
+ export type { PendingInteraction, PendingInteractionStatus, PendingKind, PendingPayloads, } from './sessions/pending.ts';
54
+ export type { ProjectionsBaseline, ProjectionValueStore, SessionProjectionMap, UseProjection, } from './sessions/projection-store.ts';
55
+ export type { SessionId } from '@hydraharness/harness-client-connection/client';
56
+ /** Client-side Cordis context after declaration merging. */
57
+ export type ClientContext = Context;
58
+ declare module '@hydraharness/harness-typert-protocol' {
59
+ interface TypertContextMap {
60
+ /** Client Agent scope identity; the agent and session share one wire id. */
61
+ agent: TypertContext<SessionId>;
62
+ }
63
+ }
64
+ /** The conversation-snapshot selector hook supplied to session-scoped UI entries. */
65
+ export type UseConversationSession = SnapshotSelectorHook<ConversationSnapshot>;
66
+ declare module '@hydraharness/harness-client-ui-slots' {
67
+ /**
68
+ * Session standard kit, real members (ui-slots declares the empty seat;
69
+ * the runtime — where the subjects live — merges the concrete types):
70
+ * every session-scope slot component receives these from the framework.
71
+ */
72
+ interface SessionStandardProps {
73
+ useSession: SnapshotSelectorHook<ConversationSnapshot>;
74
+ /** The framework-resolved session id (owners never pass it). */
75
+ sessionId: SessionId;
76
+ /** The fifth framework hook seat: key-addressed projection reader (undefined = capability absent). */
77
+ useProjection: UseProjection;
78
+ }
79
+ /** Standard kit for slots that remain mounted while current session changes. */
80
+ interface SessionMaybeStandardProps {
81
+ useSession: MaybeSnapshotSelectorHook<ConversationSnapshot>;
82
+ /** Current session id; absent in the no-session state. */
83
+ sessionId: SessionId | undefined;
84
+ /** Key-addressed projection reader; every key reads absent while no session is current. */
85
+ useProjection: UseProjection;
86
+ }
87
+ /** Props injected into every global slot component. */
88
+ interface GlobalStandardProps {
89
+ useSessions: SnapshotSelectorHook<SessionListState>;
90
+ /** Selector hook over real Workspaces and their independent baseline lifecycle. */
91
+ useWorkspaces: SnapshotSelectorHook<import('./workspaces/service.ts').WorkspaceListState>;
92
+ }
93
+ }
94
+ declare module '@hydraharness/cordis' {
95
+ interface Events {
96
+ /**
97
+ * A slot's definition or registration set changed.
98
+ * @mode emit
99
+ * @param key - the mutated SlotMap key.
100
+ */
101
+ 'slots/changed'(key: string): void;
102
+ /**
103
+ * A connection generation was (re-)established. Wire-derived caches must
104
+ * treat their state as stale and repull (commands directory; the queue
105
+ * mirrors reset themselves through the session resync path).
106
+ * @mode emit
107
+ */
108
+ 'connection/reset'(): void;
109
+ }
110
+ interface Context {
111
+ slots: import('./slots.ts').SlotRegistry;
112
+ /** Event-to-business-Context Definition registry. */
113
+ conversationEvents: import('./conversation/event-registry.ts').ConversationEventRegistry;
114
+ /** Per-target Conversation snapshot builder registry. */
115
+ conversationViews: import('./conversation/view-registry.ts').ConversationViewRegistry;
116
+ /** The outward face only; the concrete service stays inside the runtime. */
117
+ sessions: import('./contract/sessions.ts').ISessions;
118
+ /** The outward face only; the concrete service stays inside the runtime. */
119
+ workspaces: import('./contract/workspaces.ts').IWorkspaces;
120
+ }
121
+ }
122
+ /** Required services: the wire handle and Client Typert registry. */
123
+ export declare const inject: string[];
124
+ /** Mounts the browser runtime services and connection stream.
125
+ * @param ctx - Client Cordis context.
126
+ */
127
+ export declare function apply(ctx: Context): void;
128
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Merge an authoritative baseline without moving identities already visible to
3
+ * the client. Baseline-only identities are inserted relative to the nearest
4
+ * following known identity; identities absent from the baseline are removed.
5
+ *
6
+ * @param current - the established client order.
7
+ * @param baseline - the latest authoritative rows.
8
+ * @param keyOf - stable identity selector.
9
+ * @returns baseline-valued rows with the established relative order retained.
10
+ */
11
+ export declare function mergeOrderedBaseline<T>(current: readonly T[], baseline: readonly T[], keyOf: (value: T) => unknown): T[];
12
+ //# sourceMappingURL=ordered-baseline.d.ts.map
@@ -0,0 +1,34 @@
1
+ import type { SessionEvent } from '@hydraharness/harness-session/types';
2
+ import type { AssistantTiming } from './conversation.ts';
3
+ export { isTokenDelta } from '@hydraharness/harness-llm/message';
4
+ /** Pre-finalize timing boundaries for one assistant step (start + first token). */
5
+ export interface AssistantStepMetadata {
6
+ stepStartTime: number | null;
7
+ firstTokenTime: number | null;
8
+ }
9
+ /**
10
+ * Composite map key for one assistant step.
11
+ * @param turn - turn number from the event payload.
12
+ * @param step - step number from the event payload.
13
+ * @returns collision-free `turn`/`step` key (NUL separator).
14
+ */
15
+ export declare function assistantStepKey(turn: number, step: number): string;
16
+ /**
17
+ * Fold one event into the per-step timing index: step/start opens the entry,
18
+ * the first non-empty token delta stamps first-token time once. Other event
19
+ * types are no-ops.
20
+ * @param steps - the mutable per-step index, keyed by {@link assistantStepKey}.
21
+ * @param event - the raw window event.
22
+ */
23
+ export declare function indexAssistantStepTiming(steps: Map<string, AssistantStepMetadata>, event: SessionEvent): void;
24
+ /**
25
+ * Settle one finalized assistant message's timing from its step entry; a step
26
+ * whose start or first token fell outside the window yields null boundaries.
27
+ * @param steps - the per-step index built by {@link indexAssistantStepTiming}.
28
+ * @param turn - the assistant/message turn number.
29
+ * @param step - the assistant/message step number.
30
+ * @param completedTime - the assistant/message event timestamp (epoch ms).
31
+ * @returns the node-ready timing record.
32
+ */
33
+ export declare function settledAssistantTiming(steps: ReadonlyMap<string, AssistantStepMetadata>, turn: number, step: number, completedTime: number): AssistantTiming;
34
+ //# sourceMappingURL=assistant-timing.d.ts.map
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Which model-facing role a logged non-user message plays.
3
+ *
4
+ * `recall` marks material lifted out of another session's log; `inject` marks
5
+ * every other producer-supplied context. Mid-turn steering is the third role
6
+ * the transcript distinguishes, but it has its own event and node kind
7
+ * (`steering/message` / `SteeringMessageNode`) and never reaches here.
8
+ */
9
+ export type ContextRole = 'inject' | 'recall';
10
+ /** Role and producer name presented for one logged non-user message. */
11
+ export interface ContextProvenanceView {
12
+ /** The role this context plays in the model-facing conversation. */
13
+ role: ContextRole;
14
+ /**
15
+ * Producer name for the row header, taken from the durable source: the
16
+ * instruction paths, the referenced session titles, the plugin id, or the
17
+ * bare source kind for a producer this UI version does not know. Null only
18
+ * when the source carries no readable kind at all.
19
+ */
20
+ label: string | null;
21
+ }
22
+ /**
23
+ * The referenced-session labels of one durable `session-reference` recall
24
+ * source, in first-seen order; empty for every other source shape, including
25
+ * a foreign or older log whose reference entries carry no readable label.
26
+ * @param source - the logged `user/message` source, exactly as recorded.
27
+ * @returns distinct non-empty reference labels.
28
+ */
29
+ export declare function sessionRecallLabels(source: unknown): string[];
30
+ /**
31
+ * Project one durable message source onto its transcript role and producer name.
32
+ *
33
+ * The source arrives over the wire as opaque JSON (`MessageSource` is
34
+ * merge-extensible, so no client-side union can be exhaustive), and a durable
35
+ * log may predate or postdate this UI; every unreadable shape therefore
36
+ * degrades to `inject` with whatever name the record still carries.
37
+ * @param source - the logged `user/message` source, exactly as recorded.
38
+ * @returns the role and producer name to present for this context.
39
+ */
40
+ export declare function contextProvenance(source: unknown): ContextProvenanceView;
41
+ /**
42
+ * Context forms this UI version renders with a dedicated presentation. The
43
+ * durable vocabulary (`ContextForm` in `@hydraharness/harness-llm`) may already be wider — an
44
+ * unrecognized or absent value degrades to the opaque presentation rather than
45
+ * dropping the row, so a log written by a newer or foreign producer still
46
+ * renders.
47
+ */
48
+ declare const KNOWN_FORMS: readonly ["instructions", "catalog", "snapshot", "notice", "relay", "recall"];
49
+ /** One durable context form this UI version knows how to present. */
50
+ export type KnownContextForm = typeof KNOWN_FORMS[number];
51
+ /**
52
+ * Read the producer-declared form off one durable message source.
53
+ * @param source - the logged `user/message` source, exactly as recorded.
54
+ * @returns the form when this UI version presents it, otherwise null (opaque).
55
+ */
56
+ export declare function contextForm(source: unknown): KnownContextForm | null;
57
+ export {};
58
+ //# sourceMappingURL=context-provenance.d.ts.map