@xandreed/core 0.11.0 → 0.13.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/README.md +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -8
- package/dist/loop/cacheKey.d.ts +1 -1
- package/dist/loop/mapping.d.ts +1 -1
- package/dist/ports/harness.port.d.ts +1 -99
- package/dist/ports/harness.port.js +0 -24
- package/package.json +6 -6
- package/dist/harness/session.entity.d.ts +0 -33
- package/dist/harness/session.entity.js +0 -25
- package/dist/ports/conversation-store.port.d.ts +0 -127
- package/dist/ports/conversation-store.port.js +0 -36
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export type { ModelCallPolicy as ModelCallPolicyType } from "./domain/model-call
|
|
|
15
15
|
export { CurrentEmptyResponseTolerance, CurrentModelCallPolicy } from "./loop/modelPolicy.js";
|
|
16
16
|
export { formatModelSelection, parseModelSelection } from "./domain/model-selection.entity.functions.js";
|
|
17
17
|
export type { LoopEvent, ToolCallSummary } from "./domain/loop-event.entity.js";
|
|
18
|
-
export { ConversationStore, ConversationSummary, RunOutcomeRecord, StoredMessage, StoreError, } from "./ports/conversation-store.port.js";
|
|
19
18
|
export { EngineSettings, SETTINGS_KEYS, SettingsError, SettingsStore, } from "./ports/settings-store.port.js";
|
|
20
19
|
export type { ModelRole, SettingsKey } from "./ports/settings-store.port.js";
|
|
21
20
|
export { AuthError, AuthStore, Credential } from "./ports/auth-store.port.js";
|
|
@@ -54,7 +53,6 @@ export * from "./harness/plugin.entity.js";
|
|
|
54
53
|
export * from "./harness/plugin.adapter.js";
|
|
55
54
|
export * from "./harness/plugin-stack.adapter.js";
|
|
56
55
|
export * from "./harness/config.entity.js";
|
|
57
|
-
export * from "./harness/session.entity.js";
|
|
58
56
|
export * from "./ports/harness.port.js";
|
|
59
57
|
export { defineAgent, defineConfig } from "./harness/config.entity.functions.js";
|
|
60
58
|
export * from "./domain/prompt-provenance.entity.js";
|
package/dist/index.js
CHANGED
|
@@ -27,13 +27,6 @@ export { ModelCallPolicy, ReasoningEffort } from "./domain/model-call-policy.ent
|
|
|
27
27
|
export { ModelCatalogEntry } from "./domain/model-catalog.entity.js";
|
|
28
28
|
export { CurrentEmptyResponseTolerance, CurrentModelCallPolicy } from "./loop/modelPolicy.js";
|
|
29
29
|
export { formatModelSelection, parseModelSelection } from "./domain/model-selection.entity.functions.js";
|
|
30
|
-
export {
|
|
31
|
-
ConversationStore,
|
|
32
|
-
ConversationSummary,
|
|
33
|
-
RunOutcomeRecord,
|
|
34
|
-
StoredMessage,
|
|
35
|
-
StoreError
|
|
36
|
-
} from "./ports/conversation-store.port.js";
|
|
37
30
|
export {
|
|
38
31
|
EngineSettings,
|
|
39
32
|
SETTINGS_KEYS,
|
|
@@ -102,7 +95,6 @@ export * from "./harness/plugin.entity.js";
|
|
|
102
95
|
export * from "./harness/plugin.adapter.js";
|
|
103
96
|
export * from "./harness/plugin-stack.adapter.js";
|
|
104
97
|
export * from "./harness/config.entity.js";
|
|
105
|
-
export * from "./harness/session.entity.js";
|
|
106
98
|
export * from "./ports/harness.port.js";
|
|
107
99
|
export { defineAgent, defineConfig } from "./harness/config.entity.functions.js";
|
|
108
100
|
export * from "./domain/prompt-provenance.entity.js";
|
package/dist/loop/cacheKey.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, Option } from "effect";
|
|
2
2
|
/**
|
|
3
|
-
* The CURRENT conversation's cache identity, stamped by
|
|
3
|
+
* The CURRENT conversation's cache identity, stamped by the step loop for the
|
|
4
4
|
* duration of a run. Adapters that can key server-side prompt caches on a
|
|
5
5
|
* stable id (OpenAI-compatible `prompt_cache_key`) read it at call time —
|
|
6
6
|
* one conversation, one cache lane, so parallel sessions stop evicting
|
package/dist/loop/mapping.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type { TokenUsage } from "../domain/token-usage.entity.js";
|
|
|
11
11
|
* by hand and keeps the blob). Everything here is pure: no mutation, no IO.
|
|
12
12
|
*/
|
|
13
13
|
/** Wrap a fold summary as the single user message standing in for the folded
|
|
14
|
-
* history — prepended
|
|
14
|
+
* history — prepended when memory replays a conversation from a checkpoint. */
|
|
15
15
|
export declare const handoffToMessage: (summary: string) => AgentMessage;
|
|
16
16
|
/**
|
|
17
17
|
* The largest SAFE fold cut keeping at least `keepTurns` assistant turns
|
|
@@ -1,112 +1,14 @@
|
|
|
1
1
|
import { Context } from "effect";
|
|
2
|
-
import type { Effect
|
|
3
|
-
import type { Tool, Toolkit } from "effect/ai";
|
|
4
|
-
import type { AgentMessage, ConversationId } from "../domain/message.entity.js";
|
|
2
|
+
import type { Effect } from "effect";
|
|
5
3
|
import type { HarnessError } from "../harness/plugin.entity.js";
|
|
6
|
-
import type { EventBody, MemoryEntry, SessionEvent, SessionRecord } from "../harness/session.entity.js";
|
|
7
|
-
import type { UserMessage } from "../turn/user-message.entity.js";
|
|
8
|
-
declare const SessionStore_base: Context.ServiceClass<SessionStore, "efferent/SessionStore", {
|
|
9
|
-
readonly create: (workspace: string, profile: string) => Effect.Effect<SessionRecord, HarnessError>;
|
|
10
|
-
readonly get: (id: ConversationId) => Effect.Effect<SessionRecord, HarnessError>;
|
|
11
|
-
readonly list: (workspace: string) => Effect.Effect<ReadonlyArray<SessionRecord>, HarnessError>;
|
|
12
|
-
readonly read: (id: ConversationId, after: number) => Effect.Effect<ReadonlyArray<SessionEvent>, HarnessError>;
|
|
13
|
-
readonly append: (id: ConversationId, body: EventBody) => Effect.Effect<SessionEvent, HarnessError>;
|
|
14
|
-
readonly fork: (id: ConversationId, through: number) => Effect.Effect<SessionRecord, HarnessError>;
|
|
15
|
-
}>;
|
|
16
|
-
/** @deprecated Historical event vocabulary; live adapters project it over SessionLog. New hosts use Sessions and TurnWriter. */
|
|
17
|
-
export declare class SessionStore extends SessionStore_base {
|
|
18
|
-
}
|
|
19
|
-
export interface LoopInput {
|
|
20
|
-
readonly session: SessionRecord;
|
|
21
|
-
readonly runId: string;
|
|
22
|
-
readonly userMessage: UserMessage;
|
|
23
|
-
readonly system: string;
|
|
24
|
-
readonly publish: (event: EventBody) => Effect.Effect<SessionEvent, HarnessError>;
|
|
25
|
-
readonly transient: (event: EventBody) => Effect.Effect<void>;
|
|
26
|
-
readonly steering: Effect.Effect<Option.Option<string>, HarnessError>;
|
|
27
|
-
/** Journal reads for memory plugins: events after `after`, filtered by name (all when empty). */
|
|
28
|
-
readonly history: (after: number, names: ReadonlyArray<string>) => Effect.Effect<ReadonlyArray<SessionEvent>, HarnessError>;
|
|
29
|
-
/** Host services the run's tools and hooks may require (data ports, per-turn models). */
|
|
30
|
-
readonly services: Context.Context<never>;
|
|
31
|
-
}
|
|
32
|
-
declare const AgentLoop_base: Context.ServiceClass<AgentLoop, "efferent/AgentLoop", {
|
|
33
|
-
readonly run: (input: LoopInput) => Effect.Effect<{
|
|
34
|
-
readonly text: string;
|
|
35
|
-
readonly outcome: "completed" | "partial";
|
|
36
|
-
}, HarnessError>;
|
|
37
|
-
}>;
|
|
38
|
-
export declare class AgentLoop extends AgentLoop_base {
|
|
39
|
-
}
|
|
40
|
-
declare const DelegateLoop_base: Context.ServiceClass<DelegateLoop, "efferent/DelegateLoop", {
|
|
41
|
-
readonly run: (input: LoopInput) => Effect.Effect<{
|
|
42
|
-
readonly text: string;
|
|
43
|
-
readonly outcome: "completed" | "partial";
|
|
44
|
-
}, HarnessError>;
|
|
45
|
-
}>;
|
|
46
|
-
/** A workflow can delegate coding while retaining its own outer loop. */
|
|
47
|
-
export declare class DelegateLoop extends DelegateLoop_base {
|
|
48
|
-
}
|
|
49
|
-
declare const AgentTools_base: Context.ServiceClass<AgentTools, "efferent/AgentTools", {
|
|
50
|
-
readonly toolkit: Toolkit.Toolkit<Record<string, Tool.Any>>;
|
|
51
|
-
readonly handlers: Context.Context<Tool.HandlersFor<Record<string, Tool.Any>>>;
|
|
52
|
-
readonly prompt: string;
|
|
53
|
-
}>;
|
|
54
|
-
export declare class AgentTools extends AgentTools_base {
|
|
55
|
-
}
|
|
56
4
|
declare const ActionPolicy_base: Context.ServiceClass<ActionPolicy, "efferent/ActionPolicy", {
|
|
57
5
|
readonly authorize: (tool: string, input: unknown) => Effect.Effect<void, HarnessError>;
|
|
58
6
|
}>;
|
|
59
7
|
export declare class ActionPolicy extends ActionPolicy_base {
|
|
60
8
|
}
|
|
61
|
-
declare const Approval_base: Context.ServiceClass<Approval, "efferent/Approval", {
|
|
62
|
-
readonly request: (description: string) => Effect.Effect<boolean, HarnessError>;
|
|
63
|
-
}>;
|
|
64
|
-
export declare class Approval extends Approval_base {
|
|
65
|
-
}
|
|
66
|
-
declare const ContextManager_base: Context.ServiceClass<ContextManager, "efferent/ContextManager", {
|
|
67
|
-
readonly compact: (messages: ReadonlyArray<AgentMessage>, tokens: number) => Effect.Effect<Option.Option<{
|
|
68
|
-
readonly summary: string;
|
|
69
|
-
readonly keepFrom: number;
|
|
70
|
-
}>, HarnessError>;
|
|
71
|
-
}>;
|
|
72
|
-
export declare class ContextManager extends ContextManager_base {
|
|
73
|
-
}
|
|
74
|
-
declare const Memory_base: Context.ServiceClass<Memory, "efferent/Memory", {
|
|
75
|
-
readonly recall: (workspace: string, query: string) => Effect.Effect<ReadonlyArray<MemoryEntry>, HarnessError>;
|
|
76
|
-
readonly remember: (workspace: string, text: string) => Effect.Effect<MemoryEntry, HarnessError>;
|
|
77
|
-
readonly forget: (workspace: string, id: string) => Effect.Effect<void, HarnessError>;
|
|
78
|
-
}>;
|
|
79
|
-
export declare class Memory extends Memory_base {
|
|
80
|
-
}
|
|
81
9
|
declare const SessionEnvironment_base: Context.ServiceClass<SessionEnvironment, "efferent/SessionEnvironment", {
|
|
82
10
|
readonly workspace: string;
|
|
83
|
-
readonly session?: SessionRecord;
|
|
84
11
|
}>;
|
|
85
12
|
export declare class SessionEnvironment extends SessionEnvironment_base {
|
|
86
13
|
}
|
|
87
|
-
declare const TurnHooks_base: Context.ServiceClass<TurnHooks, "efferent/TurnHooks", {
|
|
88
|
-
readonly before: (input: LoopInput) => Effect.Effect<LoopInput, HarnessError>;
|
|
89
|
-
readonly after: (input: LoopInput) => Effect.Effect<void, HarnessError>;
|
|
90
|
-
}>;
|
|
91
|
-
/** Ordered hooks alter a turn; observers subscribe to the journal separately. */
|
|
92
|
-
export declare class TurnHooks extends TurnHooks_base {
|
|
93
|
-
}
|
|
94
|
-
export interface SessionHandle {
|
|
95
|
-
readonly record: SessionRecord;
|
|
96
|
-
readonly use: <I, A, B, E, R>(tag: Context.Service<I, A>, run: (service: A) => Effect.Effect<B, E, R>) => Effect.Effect<B, E | HarnessError, R>;
|
|
97
|
-
readonly send: (text: string) => Effect.Effect<void, HarnessError>;
|
|
98
|
-
readonly steer: (text: string) => Effect.Effect<void, HarnessError>;
|
|
99
|
-
readonly interrupt: Effect.Effect<void>;
|
|
100
|
-
readonly events: (after?: number) => Stream.Stream<SessionEvent, HarnessError>;
|
|
101
|
-
readonly transient: Stream.Stream<EventBody>;
|
|
102
|
-
readonly history: Effect.Effect<ReadonlyArray<SessionEvent>, HarnessError>;
|
|
103
|
-
readonly busy: Effect.Effect<boolean>;
|
|
104
|
-
readonly pending: Effect.Effect<ReadonlyArray<{
|
|
105
|
-
readonly id: string;
|
|
106
|
-
readonly text: string;
|
|
107
|
-
}>>;
|
|
108
|
-
readonly continue: Effect.Effect<void, HarnessError>;
|
|
109
|
-
readonly refresh: Effect.Effect<void, HarnessError>;
|
|
110
|
-
readonly close: Effect.Effect<void>;
|
|
111
|
-
}
|
|
112
14
|
export {};
|
|
@@ -1,31 +1,7 @@
|
|
|
1
1
|
import { Context } from "effect";
|
|
2
2
|
|
|
3
|
-
export class SessionStore extends Context.Service()("efferent/SessionStore") {
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export class AgentLoop extends Context.Service()("efferent/AgentLoop") {
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export class DelegateLoop extends Context.Service()("efferent/DelegateLoop") {
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class AgentTools extends Context.Service()("efferent/AgentTools") {
|
|
13
|
-
}
|
|
14
|
-
|
|
15
3
|
export class ActionPolicy extends Context.Service()("efferent/ActionPolicy") {
|
|
16
4
|
}
|
|
17
5
|
|
|
18
|
-
export class Approval extends Context.Service()("efferent/Approval") {
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class ContextManager extends Context.Service()("efferent/ContextManager") {
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class Memory extends Context.Service()("efferent/Memory") {
|
|
25
|
-
}
|
|
26
|
-
|
|
27
6
|
export class SessionEnvironment extends Context.Service()("efferent/SessionEnvironment") {
|
|
28
7
|
}
|
|
29
|
-
|
|
30
|
-
export class TurnHooks extends Context.Service()("efferent/TurnHooks") {
|
|
31
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xandreed/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": ">=24",
|
|
6
|
+
"bun": ">=1.3.0"
|
|
7
|
+
},
|
|
4
8
|
"private": false,
|
|
5
9
|
"type": "module",
|
|
6
10
|
"description": "The agent kernel of the new line: entities, ports, the provider-agnostic agent loop, and the session chassis — pure Effect, no IO, no provider SDKs.",
|
|
@@ -12,7 +16,7 @@
|
|
|
12
16
|
}
|
|
13
17
|
},
|
|
14
18
|
"dependencies": {
|
|
15
|
-
"effect": "4.0.
|
|
19
|
+
"effect": "4.0.7"
|
|
16
20
|
},
|
|
17
21
|
"types": "./dist/index.d.ts",
|
|
18
22
|
"files": [
|
|
@@ -22,9 +26,5 @@
|
|
|
22
26
|
"README.md",
|
|
23
27
|
"LICENSE"
|
|
24
28
|
],
|
|
25
|
-
"engines": {
|
|
26
|
-
"node": ">=24",
|
|
27
|
-
"bun": ">=1.3.0"
|
|
28
|
-
},
|
|
29
29
|
"license": "MIT"
|
|
30
30
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
export declare const SessionRecord: Schema.Struct<{
|
|
3
|
-
readonly id: Schema.brand<Schema.String, "ConversationId">;
|
|
4
|
-
readonly workspace: Schema.String;
|
|
5
|
-
readonly profile: Schema.String;
|
|
6
|
-
readonly createdAt: Schema.Number;
|
|
7
|
-
readonly parent: Schema.optional<Schema.brand<Schema.String, "ConversationId">>;
|
|
8
|
-
}>;
|
|
9
|
-
export type SessionRecord = typeof SessionRecord.Type;
|
|
10
|
-
export declare const EventBody: Schema.Struct<{
|
|
11
|
-
readonly name: Schema.NonEmptyString;
|
|
12
|
-
readonly runId: Schema.optional<Schema.String>;
|
|
13
|
-
readonly data: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
14
|
-
}>;
|
|
15
|
-
export type EventBody = typeof EventBody.Type;
|
|
16
|
-
export declare const SessionEvent: Schema.Struct<{
|
|
17
|
-
readonly version: Schema.Literal<1>;
|
|
18
|
-
readonly id: Schema.String;
|
|
19
|
-
readonly sessionId: Schema.brand<Schema.String, "ConversationId">;
|
|
20
|
-
readonly seq: Schema.Int;
|
|
21
|
-
readonly at: Schema.Number;
|
|
22
|
-
readonly name: Schema.NonEmptyString;
|
|
23
|
-
readonly runId: Schema.optional<Schema.String>;
|
|
24
|
-
readonly data: Schema.$Record<Schema.String, Schema.Unknown>;
|
|
25
|
-
}>;
|
|
26
|
-
export type SessionEvent = typeof SessionEvent.Type;
|
|
27
|
-
export declare const MemoryEntry: Schema.Struct<{
|
|
28
|
-
readonly id: Schema.String;
|
|
29
|
-
readonly workspace: Schema.String;
|
|
30
|
-
readonly text: Schema.String;
|
|
31
|
-
readonly createdAt: Schema.Number;
|
|
32
|
-
}>;
|
|
33
|
-
export type MemoryEntry = typeof MemoryEntry.Type;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Schema } from "effect";
|
|
2
|
-
import { ConversationId } from "../domain/message.entity.js";
|
|
3
|
-
export const SessionRecord = Schema.Struct({
|
|
4
|
-
id: ConversationId,
|
|
5
|
-
workspace: Schema.String,
|
|
6
|
-
profile: Schema.String,
|
|
7
|
-
createdAt: Schema.Number,
|
|
8
|
-
parent: Schema.optional(ConversationId)
|
|
9
|
-
}), EventBody = Schema.Struct({
|
|
10
|
-
name: Schema.NonEmptyString,
|
|
11
|
-
runId: Schema.optional(Schema.String),
|
|
12
|
-
data: Schema.Record(Schema.String, Schema.Unknown)
|
|
13
|
-
}), SessionEvent = Schema.Struct({
|
|
14
|
-
...EventBody.fields,
|
|
15
|
-
version: Schema.Literal(1),
|
|
16
|
-
id: Schema.String,
|
|
17
|
-
sessionId: ConversationId,
|
|
18
|
-
seq: Schema.Int,
|
|
19
|
-
at: Schema.Number
|
|
20
|
-
}), MemoryEntry = Schema.Struct({
|
|
21
|
-
id: Schema.String,
|
|
22
|
-
workspace: Schema.String,
|
|
23
|
-
text: Schema.String,
|
|
24
|
-
createdAt: Schema.Number
|
|
25
|
-
});
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { Context, Option, Schema } from "effect";
|
|
2
|
-
import type { Effect } from "effect";
|
|
3
|
-
import { AgentMessage, ConversationId } from "../domain/message.entity.js";
|
|
4
|
-
import type { Checkpoint } from "../domain/message.entity.js";
|
|
5
|
-
declare const StoreError_base: Schema.Class<StoreError, Schema.TaggedStruct<"StoreError", {
|
|
6
|
-
readonly message: Schema.String;
|
|
7
|
-
}>, import("effect/Cause").YieldableError>;
|
|
8
|
-
export declare class StoreError extends StoreError_base {
|
|
9
|
-
}
|
|
10
|
-
declare const RunOutcomeRecord_base: Schema.Class<RunOutcomeRecord, Schema.Struct<{
|
|
11
|
-
readonly conversationId: Schema.brand<Schema.String, "ConversationId">;
|
|
12
|
-
/** Epoch millis. */
|
|
13
|
-
readonly at: Schema.Number;
|
|
14
|
-
readonly outcome: Schema.Literals<readonly ["ok", "partial"]>;
|
|
15
|
-
readonly reason: Schema.Literals<readonly ["completed", "step-cap", "degenerate-loop"]>;
|
|
16
|
-
}>, {}>;
|
|
17
|
-
/** How a run ENDED — persisted beside the trail so the database alone says
|
|
18
|
-
* whether the last run completed on its own or was stopped by the step cap
|
|
19
|
-
* or the degenerate-loop breaker (the loop's `agent_end` was in-memory only). */
|
|
20
|
-
export declare class RunOutcomeRecord extends RunOutcomeRecord_base {
|
|
21
|
-
}
|
|
22
|
-
declare const ConversationSummary_base: Schema.Class<ConversationSummary, Schema.Struct<{
|
|
23
|
-
readonly id: Schema.brand<Schema.String, "ConversationId">;
|
|
24
|
-
readonly createdAt: Schema.Number;
|
|
25
|
-
readonly firstPrompt: Schema.OptionFromOptional<Schema.String>;
|
|
26
|
-
readonly title: Schema.OptionFromOptional<Schema.String>;
|
|
27
|
-
/** The latest recorded run outcome, when a run has finished in it. */
|
|
28
|
-
readonly lastOutcome: Schema.OptionFromOptional<Schema.Struct<{
|
|
29
|
-
readonly outcome: Schema.Literals<readonly ["ok", "partial"]>;
|
|
30
|
-
readonly reason: Schema.Literals<readonly ["completed", "step-cap", "degenerate-loop"]>;
|
|
31
|
-
}>>;
|
|
32
|
-
}>, {}>;
|
|
33
|
-
export declare class ConversationSummary extends ConversationSummary_base {
|
|
34
|
-
}
|
|
35
|
-
declare const StoredMessage_base: Schema.Class<StoredMessage, Schema.Struct<{
|
|
36
|
-
readonly position: Schema.Int;
|
|
37
|
-
readonly message: Schema.Union<readonly [Schema.Struct<{
|
|
38
|
-
readonly role: Schema.Literal<"user">;
|
|
39
|
-
readonly content: Schema.String;
|
|
40
|
-
readonly providerOptions: Schema.optional<Schema.Unknown>;
|
|
41
|
-
}>, Schema.Struct<{
|
|
42
|
-
readonly role: Schema.Literal<"assistant">;
|
|
43
|
-
readonly content: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
|
|
44
|
-
readonly type: Schema.Literal<"text">;
|
|
45
|
-
readonly text: Schema.String;
|
|
46
|
-
readonly providerOptions: Schema.optional<Schema.Unknown>;
|
|
47
|
-
}>, Schema.Struct<{
|
|
48
|
-
readonly type: Schema.Literal<"reasoning">;
|
|
49
|
-
readonly text: Schema.String;
|
|
50
|
-
readonly providerOptions: Schema.optional<Schema.Unknown>;
|
|
51
|
-
}>, Schema.Struct<{
|
|
52
|
-
readonly type: Schema.Literal<"tool-call">;
|
|
53
|
-
readonly toolCallId: Schema.brand<Schema.String, "ToolCallId">;
|
|
54
|
-
readonly toolName: Schema.String;
|
|
55
|
-
readonly input: Schema.Unknown;
|
|
56
|
-
readonly providerOptions: Schema.optional<Schema.Unknown>;
|
|
57
|
-
readonly providerExecuted: Schema.optional<Schema.Boolean>;
|
|
58
|
-
}>]>>;
|
|
59
|
-
readonly providerOptions: Schema.optional<Schema.Unknown>;
|
|
60
|
-
}>, Schema.Struct<{
|
|
61
|
-
readonly role: Schema.Literal<"tool">;
|
|
62
|
-
readonly content: Schema.$Array<Schema.Struct<{
|
|
63
|
-
readonly type: Schema.Literal<"tool-result">;
|
|
64
|
-
readonly toolCallId: Schema.brand<Schema.String, "ToolCallId">;
|
|
65
|
-
readonly toolName: Schema.String;
|
|
66
|
-
readonly output: Schema.Unknown;
|
|
67
|
-
readonly providerOptions: Schema.optional<Schema.Unknown>;
|
|
68
|
-
readonly isError: Schema.optional<Schema.Boolean>;
|
|
69
|
-
}>>;
|
|
70
|
-
readonly providerOptions: Schema.optional<Schema.Unknown>;
|
|
71
|
-
}>]>;
|
|
72
|
-
}>, {}>;
|
|
73
|
-
/** A persisted row WITH its durable position — what the active window is
|
|
74
|
-
* made of, so a loader never reconstructs positions by arithmetic (an
|
|
75
|
-
* undecodable row in between would shift every later one). */
|
|
76
|
-
export declare class StoredMessage extends StoredMessage_base {
|
|
77
|
-
}
|
|
78
|
-
declare const ConversationStore_base: Context.ServiceClass<ConversationStore, "@xandreed/core/ConversationStore", {
|
|
79
|
-
readonly create: (workspaceDir?: string) => Effect.Effect<ConversationId, StoreError>;
|
|
80
|
-
readonly append: (id: ConversationId, message: AgentMessage) => Effect.Effect<number, StoreError>;
|
|
81
|
-
/** One turn's rows land TOGETHER or not at all — an assistant tool call
|
|
82
|
-
* without its results is a row the next run cannot send. Returns the
|
|
83
|
-
* positions, aligned with the input. */
|
|
84
|
-
readonly appendAll: (id: ConversationId, messages: ReadonlyArray<AgentMessage>) => Effect.Effect<ReadonlyArray<number>, StoreError>;
|
|
85
|
-
readonly list: (id: ConversationId) => Effect.Effect<ReadonlyArray<AgentMessage>, StoreError>;
|
|
86
|
-
/** The rows after the latest fold, each with its position. */
|
|
87
|
-
readonly listActive: (id: ConversationId) => Effect.Effect<ReadonlyArray<StoredMessage>, StoreError>;
|
|
88
|
-
readonly checkpoint: (id: ConversationId, summary: string) => Effect.Effect<void, StoreError>;
|
|
89
|
-
/** A fold up to an EXPLICIT position (the within-run compaction seam):
|
|
90
|
-
* rows at or before it are covered by the summary; `listActive` returns
|
|
91
|
-
* only the rows after. `checkpoint` folds everything appended so far. */
|
|
92
|
-
readonly checkpointAt: (id: ConversationId, summary: string, messagePosition: number) => Effect.Effect<void, StoreError>;
|
|
93
|
-
readonly latestCheckpoint: (id: ConversationId) => Effect.Effect<Option.Option<Checkpoint>, StoreError>;
|
|
94
|
-
readonly setTitle: (id: ConversationId, title: string) => Effect.Effect<void, StoreError>;
|
|
95
|
-
/** Record how a run ended (appended; the latest is the conversation's). */
|
|
96
|
-
readonly recordOutcome: (id: ConversationId, outcome: RunOutcomeRecord["outcome"], reason: RunOutcomeRecord["reason"]) => Effect.Effect<void, StoreError>;
|
|
97
|
-
readonly latestOutcome: (id: ConversationId) => Effect.Effect<Option.Option<RunOutcomeRecord>, StoreError>;
|
|
98
|
-
readonly listByWorkspace: (workspaceDir: string) => Effect.Effect<ReadonlyArray<ConversationSummary>, StoreError>;
|
|
99
|
-
/** BRANCH: copy rows [0..upToPosition] (default: all) into a NEW
|
|
100
|
-
* conversation in the same workspace, along with the latest covered
|
|
101
|
-
* checkpoint — the original stays untouched; the fork continues
|
|
102
|
-
* independently (git-branch semantics over the trail). */
|
|
103
|
-
readonly fork: (id: ConversationId, upToPosition?: number) => Effect.Effect<ConversationId, StoreError>;
|
|
104
|
-
/** RETENTION: delete whole conversations created before `beforeEpochMs`
|
|
105
|
-
* (messages + checkpoints + the conversation row) and reclaim the
|
|
106
|
-
* space. Nothing calls this automatically — deletion is a deliberate,
|
|
107
|
-
* human-initiated act on an otherwise append-only store. Returns the
|
|
108
|
-
* number of conversations removed. */
|
|
109
|
-
readonly prune: (beforeEpochMs: number) => Effect.Effect<number, StoreError>;
|
|
110
|
-
}>;
|
|
111
|
-
/**
|
|
112
|
-
* @deprecated Positional compatibility projection over SessionLog. New composable
|
|
113
|
-
* hosts use Sessions, TurnWriter and ConversationMemory directly.
|
|
114
|
-
*
|
|
115
|
-
* The conversation persistence port. Positions are the durable identity:
|
|
116
|
-
* `append` assigns a monotonic, immutable absolute position per conversation,
|
|
117
|
-
* and UIs key their blocks on it so a live-streamed block and a later
|
|
118
|
-
* re-projection of the same message reconcile instead of duplicating.
|
|
119
|
-
*
|
|
120
|
-
* A checkpoint FOLDS the history for loading purposes only: `list` always
|
|
121
|
-
* returns every row; `listActive` returns the rows after the latest fold.
|
|
122
|
-
* The loop prepends the fold's summary itself (domain logic stays here,
|
|
123
|
-
* not in the adapter).
|
|
124
|
-
*/
|
|
125
|
-
export declare class ConversationStore extends ConversationStore_base {
|
|
126
|
-
}
|
|
127
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Context, Option, Schema } from "effect";
|
|
2
|
-
import { AgentMessage, ConversationId } from "../domain/message.entity.js";
|
|
3
|
-
|
|
4
|
-
export class StoreError extends Schema.TaggedError()("StoreError", {
|
|
5
|
-
message: Schema.String
|
|
6
|
-
}) {
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export class RunOutcomeRecord extends Schema.Class("RunOutcomeRecord")({
|
|
10
|
-
conversationId: ConversationId,
|
|
11
|
-
at: Schema.Number,
|
|
12
|
-
outcome: Schema.Literals(["ok", "partial"]),
|
|
13
|
-
reason: Schema.Literals(["completed", "step-cap", "degenerate-loop"])
|
|
14
|
-
}) {
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class ConversationSummary extends Schema.Class("ConversationSummary")({
|
|
18
|
-
id: ConversationId,
|
|
19
|
-
createdAt: Schema.Number,
|
|
20
|
-
firstPrompt: Schema.OptionFromOptional(Schema.String),
|
|
21
|
-
title: Schema.OptionFromOptional(Schema.String),
|
|
22
|
-
lastOutcome: Schema.OptionFromOptional(Schema.Struct({
|
|
23
|
-
outcome: Schema.Literals(["ok", "partial"]),
|
|
24
|
-
reason: Schema.Literals(["completed", "step-cap", "degenerate-loop"])
|
|
25
|
-
}))
|
|
26
|
-
}) {
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export class StoredMessage extends Schema.Class("StoredMessage")({
|
|
30
|
-
position: Schema.Int,
|
|
31
|
-
message: AgentMessage
|
|
32
|
-
}) {
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export class ConversationStore extends Context.Service()("@xandreed/core/ConversationStore") {
|
|
36
|
-
}
|