@xandreed/core 0.3.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.
Files changed (95) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/domain/agent-failure.entity.d.ts +12 -0
  4. package/dist/domain/agent-failure.entity.functions.d.ts +5 -0
  5. package/dist/domain/agent-failure.entity.functions.js +8 -0
  6. package/dist/domain/agent-failure.entity.js +8 -0
  7. package/dist/domain/failure.entity.d.ts +12 -0
  8. package/dist/domain/failure.entity.functions.d.ts +3 -0
  9. package/dist/domain/failure.entity.functions.js +1 -0
  10. package/dist/domain/failure.entity.js +5 -0
  11. package/dist/domain/loop-event.entity.d.ts +94 -0
  12. package/dist/domain/loop-event.entity.js +0 -0
  13. package/dist/domain/message.entity.d.ts +227 -0
  14. package/dist/domain/message.entity.js +51 -0
  15. package/dist/domain/model-call-policy.entity.d.ts +12 -0
  16. package/dist/domain/model-call-policy.entity.js +5 -0
  17. package/dist/domain/model-catalog.entity.d.ts +10 -0
  18. package/dist/domain/model-catalog.entity.js +7 -0
  19. package/dist/domain/model-selection.entity.d.ts +24 -0
  20. package/dist/domain/model-selection.entity.functions.d.ts +5 -0
  21. package/dist/domain/model-selection.entity.functions.js +9 -0
  22. package/dist/domain/model-selection.entity.js +8 -0
  23. package/dist/domain/prompt-provenance.entity.d.ts +11 -0
  24. package/dist/domain/prompt-provenance.entity.js +8 -0
  25. package/dist/domain/token-usage.entity.d.ts +9 -0
  26. package/dist/domain/token-usage.entity.functions.d.ts +3 -0
  27. package/dist/domain/token-usage.entity.functions.js +11 -0
  28. package/dist/domain/token-usage.entity.js +7 -0
  29. package/dist/harness/capability.entity.d.ts +61 -0
  30. package/dist/harness/capability.entity.functions.d.ts +6 -0
  31. package/dist/harness/capability.entity.functions.js +10 -0
  32. package/dist/harness/capability.entity.js +26 -0
  33. package/dist/harness/capability.test.d.ts +1 -0
  34. package/dist/harness/config.entity.d.ts +48 -0
  35. package/dist/harness/config.entity.functions.d.ts +3 -0
  36. package/dist/harness/config.entity.functions.js +1 -0
  37. package/dist/harness/config.entity.js +18 -0
  38. package/dist/harness/plugin.adapter.d.ts +18 -0
  39. package/dist/harness/plugin.adapter.js +13 -0
  40. package/dist/harness/plugin.entity.d.ts +25 -0
  41. package/dist/harness/plugin.entity.js +9 -0
  42. package/dist/harness/session.entity.d.ts +33 -0
  43. package/dist/harness/session.entity.js +25 -0
  44. package/dist/index.d.ts +51 -0
  45. package/dist/index.js +99 -0
  46. package/dist/loop/cacheKey.d.ts +13 -0
  47. package/dist/loop/cacheKey.js +2 -0
  48. package/dist/loop/mapping.d.ts +79 -0
  49. package/dist/loop/mapping.js +154 -0
  50. package/dist/loop/mapping.test.d.ts +1 -0
  51. package/dist/loop/modelPolicy.d.ts +21 -0
  52. package/dist/loop/modelPolicy.js +2 -0
  53. package/dist/loop/promptProvenance.d.ts +8 -0
  54. package/dist/loop/promptProvenance.js +2 -0
  55. package/dist/loop/stepContext.d.ts +3 -0
  56. package/dist/loop/stepContext.js +2 -0
  57. package/dist/loop/streamFold.d.ts +31 -0
  58. package/dist/loop/streamFold.js +58 -0
  59. package/dist/loop/streamFold.test.d.ts +1 -0
  60. package/dist/mcp/bridge.d.ts +51 -0
  61. package/dist/mcp/bridge.js +70 -0
  62. package/dist/mcp/bridge.test.d.ts +1 -0
  63. package/dist/ports/auth-store.port.d.ts +50 -0
  64. package/dist/ports/auth-store.port.js +18 -0
  65. package/dist/ports/capability.port.d.ts +15 -0
  66. package/dist/ports/capability.port.js +7 -0
  67. package/dist/ports/conversation-store.port.d.ts +250 -0
  68. package/dist/ports/conversation-store.port.js +36 -0
  69. package/dist/ports/file-system.port.d.ts +26 -0
  70. package/dist/ports/file-system.port.js +10 -0
  71. package/dist/ports/harness.port.d.ts +106 -0
  72. package/dist/ports/harness.port.js +31 -0
  73. package/dist/ports/mcp-client.port.d.ts +74 -0
  74. package/dist/ports/mcp-client.port.js +24 -0
  75. package/dist/ports/model-catalog.port.d.ts +10 -0
  76. package/dist/ports/model-catalog.port.js +4 -0
  77. package/dist/ports/settings-store.port.d.ts +85 -0
  78. package/dist/ports/settings-store.port.js +36 -0
  79. package/dist/ports/shell.port.d.ts +44 -0
  80. package/dist/ports/shell.port.js +16 -0
  81. package/dist/ports/utility-llm.port.d.ts +48 -0
  82. package/dist/ports/utility-llm.port.js +16 -0
  83. package/dist/session/chassis.d.ts +59 -0
  84. package/dist/session/chassis.js +27 -0
  85. package/dist/session/chassis.test.d.ts +1 -0
  86. package/dist/spec/SpecDoc.d.ts +162 -0
  87. package/dist/spec/SpecDoc.js +59 -0
  88. package/dist/spec/codec.d.ts +30 -0
  89. package/dist/spec/codec.js +123 -0
  90. package/dist/spec/codec.test.d.ts +1 -0
  91. package/dist/spec/frontmatter.d.ts +16 -0
  92. package/dist/spec/frontmatter.js +25 -0
  93. package/dist/util/json.d.ts +19 -0
  94. package/dist/util/json.js +15 -0
  95. package/package.json +30 -0
@@ -0,0 +1,250 @@
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.TaggedErrorClass<StoreError, "StoreError", {
6
+ readonly _tag: Schema.tag<"StoreError">;
7
+ } & {
8
+ message: typeof Schema.String;
9
+ }>;
10
+ export declare class StoreError extends StoreError_base {
11
+ }
12
+ declare const RunOutcomeRecord_base: Schema.Class<RunOutcomeRecord, {
13
+ conversationId: Schema.brand<typeof Schema.UUID, "ConversationId">;
14
+ /** Epoch millis. */
15
+ at: typeof Schema.Number;
16
+ outcome: Schema.Literal<["ok", "partial"]>;
17
+ reason: Schema.Literal<["completed", "step-cap", "degenerate-loop"]>;
18
+ }, Schema.Struct.Encoded<{
19
+ conversationId: Schema.brand<typeof Schema.UUID, "ConversationId">;
20
+ /** Epoch millis. */
21
+ at: typeof Schema.Number;
22
+ outcome: Schema.Literal<["ok", "partial"]>;
23
+ reason: Schema.Literal<["completed", "step-cap", "degenerate-loop"]>;
24
+ }>, never, {
25
+ readonly at: number;
26
+ } & {
27
+ readonly conversationId: string & import("effect/Brand").Brand<"ConversationId">;
28
+ } & {
29
+ readonly outcome: "ok" | "partial";
30
+ } & {
31
+ readonly reason: "completed" | "step-cap" | "degenerate-loop";
32
+ }, {}, {}>;
33
+ /** How a run ENDED — persisted beside the trail so the database alone says
34
+ * whether the last run completed on its own or was stopped by the step cap
35
+ * or the degenerate-loop breaker (the loop's `agent_end` was in-memory only). */
36
+ export declare class RunOutcomeRecord extends RunOutcomeRecord_base {
37
+ }
38
+ declare const ConversationSummary_base: Schema.Class<ConversationSummary, {
39
+ id: Schema.brand<typeof Schema.UUID, "ConversationId">;
40
+ createdAt: typeof Schema.Number;
41
+ firstPrompt: Schema.optionalWith<typeof Schema.String, {
42
+ as: "Option";
43
+ }>;
44
+ title: Schema.optionalWith<typeof Schema.String, {
45
+ as: "Option";
46
+ }>;
47
+ /** The latest recorded run outcome, when a run has finished in it. */
48
+ lastOutcome: Schema.optionalWith<Schema.Struct<{
49
+ outcome: Schema.Literal<["ok", "partial"]>;
50
+ reason: Schema.Literal<["completed", "step-cap", "degenerate-loop"]>;
51
+ }>, {
52
+ as: "Option";
53
+ }>;
54
+ }, Schema.Struct.Encoded<{
55
+ id: Schema.brand<typeof Schema.UUID, "ConversationId">;
56
+ createdAt: typeof Schema.Number;
57
+ firstPrompt: Schema.optionalWith<typeof Schema.String, {
58
+ as: "Option";
59
+ }>;
60
+ title: Schema.optionalWith<typeof Schema.String, {
61
+ as: "Option";
62
+ }>;
63
+ /** The latest recorded run outcome, when a run has finished in it. */
64
+ lastOutcome: Schema.optionalWith<Schema.Struct<{
65
+ outcome: Schema.Literal<["ok", "partial"]>;
66
+ reason: Schema.Literal<["completed", "step-cap", "degenerate-loop"]>;
67
+ }>, {
68
+ as: "Option";
69
+ }>;
70
+ }>, never, {
71
+ readonly createdAt: number;
72
+ } & {
73
+ readonly id: string & import("effect/Brand").Brand<"ConversationId">;
74
+ } & {
75
+ readonly firstPrompt: Option.Option<string>;
76
+ } & {
77
+ readonly title: Option.Option<string>;
78
+ } & {
79
+ readonly lastOutcome: Option.Option<{
80
+ readonly outcome: "ok" | "partial";
81
+ readonly reason: "completed" | "step-cap" | "degenerate-loop";
82
+ }>;
83
+ }, {}, {}>;
84
+ export declare class ConversationSummary extends ConversationSummary_base {
85
+ }
86
+ declare const StoredMessage_base: Schema.Class<StoredMessage, {
87
+ position: typeof Schema.Int;
88
+ message: Schema.Union<[Schema.Struct<{
89
+ role: Schema.Literal<["user"]>;
90
+ content: typeof Schema.String;
91
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
92
+ }>, Schema.Struct<{
93
+ role: Schema.Literal<["assistant"]>;
94
+ content: Schema.Array$<Schema.Union<[Schema.Struct<{
95
+ type: Schema.Literal<["text"]>;
96
+ text: typeof Schema.String;
97
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
98
+ }>, Schema.Struct<{
99
+ type: Schema.Literal<["reasoning"]>;
100
+ text: typeof Schema.String;
101
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
102
+ }>, Schema.Struct<{
103
+ type: Schema.Literal<["tool-call"]>;
104
+ toolCallId: Schema.brand<typeof Schema.String, "ToolCallId">;
105
+ toolName: typeof Schema.String;
106
+ input: typeof Schema.Unknown;
107
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
108
+ providerExecuted: Schema.optional<typeof Schema.Boolean>;
109
+ }>]>>;
110
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
111
+ }>, Schema.Struct<{
112
+ role: Schema.Literal<["tool"]>;
113
+ content: Schema.Array$<Schema.Struct<{
114
+ type: Schema.Literal<["tool-result"]>;
115
+ toolCallId: Schema.brand<typeof Schema.String, "ToolCallId">;
116
+ toolName: typeof Schema.String;
117
+ output: typeof Schema.Unknown;
118
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
119
+ isError: Schema.optional<typeof Schema.Boolean>;
120
+ }>>;
121
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
122
+ }>]>;
123
+ }, Schema.Struct.Encoded<{
124
+ position: typeof Schema.Int;
125
+ message: Schema.Union<[Schema.Struct<{
126
+ role: Schema.Literal<["user"]>;
127
+ content: typeof Schema.String;
128
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
129
+ }>, Schema.Struct<{
130
+ role: Schema.Literal<["assistant"]>;
131
+ content: Schema.Array$<Schema.Union<[Schema.Struct<{
132
+ type: Schema.Literal<["text"]>;
133
+ text: typeof Schema.String;
134
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
135
+ }>, Schema.Struct<{
136
+ type: Schema.Literal<["reasoning"]>;
137
+ text: typeof Schema.String;
138
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
139
+ }>, Schema.Struct<{
140
+ type: Schema.Literal<["tool-call"]>;
141
+ toolCallId: Schema.brand<typeof Schema.String, "ToolCallId">;
142
+ toolName: typeof Schema.String;
143
+ input: typeof Schema.Unknown;
144
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
145
+ providerExecuted: Schema.optional<typeof Schema.Boolean>;
146
+ }>]>>;
147
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
148
+ }>, Schema.Struct<{
149
+ role: Schema.Literal<["tool"]>;
150
+ content: Schema.Array$<Schema.Struct<{
151
+ type: Schema.Literal<["tool-result"]>;
152
+ toolCallId: Schema.brand<typeof Schema.String, "ToolCallId">;
153
+ toolName: typeof Schema.String;
154
+ output: typeof Schema.Unknown;
155
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
156
+ isError: Schema.optional<typeof Schema.Boolean>;
157
+ }>>;
158
+ providerOptions: Schema.optional<typeof Schema.Unknown>;
159
+ }>]>;
160
+ }>, never, {
161
+ readonly message: {
162
+ readonly providerOptions?: unknown;
163
+ readonly role: "user";
164
+ readonly content: string;
165
+ } | {
166
+ readonly providerOptions?: unknown;
167
+ readonly role: "assistant";
168
+ readonly content: readonly ({
169
+ readonly type: "text";
170
+ readonly text: string;
171
+ readonly providerOptions?: unknown;
172
+ } | {
173
+ readonly type: "reasoning";
174
+ readonly text: string;
175
+ readonly providerOptions?: unknown;
176
+ } | {
177
+ readonly type: "tool-call";
178
+ readonly providerOptions?: unknown;
179
+ readonly toolCallId: string & import("effect/Brand").Brand<"ToolCallId">;
180
+ readonly toolName: string;
181
+ readonly input: unknown;
182
+ readonly providerExecuted?: boolean | undefined;
183
+ })[];
184
+ } | {
185
+ readonly providerOptions?: unknown;
186
+ readonly role: "tool";
187
+ readonly content: readonly {
188
+ readonly type: "tool-result";
189
+ readonly providerOptions?: unknown;
190
+ readonly toolCallId: string & import("effect/Brand").Brand<"ToolCallId">;
191
+ readonly toolName: string;
192
+ readonly output: unknown;
193
+ readonly isError?: boolean | undefined;
194
+ }[];
195
+ };
196
+ } & {
197
+ readonly position: number;
198
+ }, {}, {}>;
199
+ /** A persisted row WITH its durable position — what the active window is
200
+ * made of, so a loader never reconstructs positions by arithmetic (an
201
+ * undecodable row in between would shift every later one). */
202
+ export declare class StoredMessage extends StoredMessage_base {
203
+ }
204
+ declare const ConversationStore_base: Context.TagClass<ConversationStore, "@xandreed/core/ConversationStore", {
205
+ readonly create: (workspaceDir?: string) => Effect.Effect<ConversationId, StoreError>;
206
+ readonly append: (id: ConversationId, message: AgentMessage) => Effect.Effect<number, StoreError>;
207
+ /** One turn's rows land TOGETHER or not at all — an assistant tool call
208
+ * without its results is a row the next run cannot send. Returns the
209
+ * positions, aligned with the input. */
210
+ readonly appendAll: (id: ConversationId, messages: ReadonlyArray<AgentMessage>) => Effect.Effect<ReadonlyArray<number>, StoreError>;
211
+ readonly list: (id: ConversationId) => Effect.Effect<ReadonlyArray<AgentMessage>, StoreError>;
212
+ /** The rows after the latest fold, each with its position. */
213
+ readonly listActive: (id: ConversationId) => Effect.Effect<ReadonlyArray<StoredMessage>, StoreError>;
214
+ readonly checkpoint: (id: ConversationId, summary: string) => Effect.Effect<void, StoreError>;
215
+ /** A fold up to an EXPLICIT position (the within-run compaction seam):
216
+ * rows at or before it are covered by the summary; `listActive` returns
217
+ * only the rows after. `checkpoint` folds everything appended so far. */
218
+ readonly checkpointAt: (id: ConversationId, summary: string, messagePosition: number) => Effect.Effect<void, StoreError>;
219
+ readonly latestCheckpoint: (id: ConversationId) => Effect.Effect<Option.Option<Checkpoint>, StoreError>;
220
+ readonly setTitle: (id: ConversationId, title: string) => Effect.Effect<void, StoreError>;
221
+ /** Record how a run ended (appended; the latest is the conversation's). */
222
+ readonly recordOutcome: (id: ConversationId, outcome: RunOutcomeRecord["outcome"], reason: RunOutcomeRecord["reason"]) => Effect.Effect<void, StoreError>;
223
+ readonly latestOutcome: (id: ConversationId) => Effect.Effect<Option.Option<RunOutcomeRecord>, StoreError>;
224
+ readonly listByWorkspace: (workspaceDir: string) => Effect.Effect<ReadonlyArray<ConversationSummary>, StoreError>;
225
+ /** BRANCH: copy rows [0..upToPosition] (default: all) into a NEW
226
+ * conversation in the same workspace, along with the latest covered
227
+ * checkpoint — the original stays untouched; the fork continues
228
+ * independently (git-branch semantics over the trail). */
229
+ readonly fork: (id: ConversationId, upToPosition?: number) => Effect.Effect<ConversationId, StoreError>;
230
+ /** RETENTION: delete whole conversations created before `beforeEpochMs`
231
+ * (messages + checkpoints + the conversation row) and reclaim the
232
+ * space. Nothing calls this automatically — deletion is a deliberate,
233
+ * human-initiated act on an otherwise append-only store. Returns the
234
+ * number of conversations removed. */
235
+ readonly prune: (beforeEpochMs: number) => Effect.Effect<number, StoreError>;
236
+ }>;
237
+ /**
238
+ * The conversation persistence port. Positions are the durable identity:
239
+ * `append` assigns a monotonic, immutable absolute position per conversation,
240
+ * and UIs key their blocks on it so a live-streamed block and a later
241
+ * re-projection of the same message reconcile instead of duplicating.
242
+ *
243
+ * A checkpoint FOLDS the history for loading purposes only: `list` always
244
+ * returns every row; `listActive` returns the rows after the latest fold.
245
+ * The loop prepends the fold's summary itself (domain logic stays here,
246
+ * not in the adapter).
247
+ */
248
+ export declare class ConversationStore extends ConversationStore_base {
249
+ }
250
+ export {};
@@ -0,0 +1,36 @@
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.Literal("ok", "partial"),
13
+ reason: Schema.Literal("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.optionalWith(Schema.String, { as: "Option" }),
21
+ title: Schema.optionalWith(Schema.String, { as: "Option" }),
22
+ lastOutcome: Schema.optionalWith(Schema.Struct({
23
+ outcome: Schema.Literal("ok", "partial"),
24
+ reason: Schema.Literal("completed", "step-cap", "degenerate-loop")
25
+ }), { as: "Option" })
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.Tag("@xandreed/core/ConversationStore")() {
36
+ }
@@ -0,0 +1,26 @@
1
+ import { Context, Schema } from "effect";
2
+ import type { Effect } from "effect";
3
+ declare const FsError_base: Schema.TaggedErrorClass<FsError, "FsError", {
4
+ readonly _tag: Schema.tag<"FsError">;
5
+ } & {
6
+ path: typeof Schema.String;
7
+ message: typeof Schema.String;
8
+ }>;
9
+ export declare class FsError extends FsError_base {
10
+ }
11
+ declare const FileSystem_base: Context.TagClass<FileSystem, "@xandreed/core/FileSystem", {
12
+ readonly read: (path: string) => Effect.Effect<string, FsError>;
13
+ readonly write: (path: string, content: string) => Effect.Effect<void, FsError>;
14
+ readonly exists: (path: string) => Effect.Effect<boolean, FsError>;
15
+ readonly list: (dir: string) => Effect.Effect<ReadonlyArray<string>, FsError>;
16
+ readonly mkdir: (dir: string) => Effect.Effect<void, FsError>;
17
+ /** Resolve symlinks to the canonical absolute path. */
18
+ readonly realPath: (path: string) => Effect.Effect<string, FsError>;
19
+ /** Delete a file. A missing path is a no-op (idempotent), not an error. */
20
+ readonly remove: (path: string) => Effect.Effect<void, FsError>;
21
+ }>;
22
+ /** Minimal filesystem port for agent tools. Paths are absolute or
23
+ * caller-resolved — the port does no cwd magic. */
24
+ export declare class FileSystem extends FileSystem_base {
25
+ }
26
+ export {};
@@ -0,0 +1,10 @@
1
+ import { Context, Schema } from "effect";
2
+
3
+ export class FsError extends Schema.TaggedError()("FsError", {
4
+ path: Schema.String,
5
+ message: Schema.String
6
+ }) {
7
+ }
8
+
9
+ export class FileSystem extends Context.Tag("@xandreed/core/FileSystem")() {
10
+ }
@@ -0,0 +1,106 @@
1
+ import { Context } from "effect";
2
+ import type { Effect, Option, Stream } from "effect";
3
+ import type { Tool, Toolkit } from "@effect/ai";
4
+ import type { AgentMessage, ConversationId } from "../domain/message.entity.js";
5
+ import type { HarnessError } from "../harness/plugin.entity.js";
6
+ import type { EventBody, MemoryEntry, SessionEvent, SessionRecord } from "../harness/session.entity.js";
7
+ declare const SessionStore_base: Context.TagClass<SessionStore, "efferent/SessionStore", {
8
+ readonly create: (workspace: string, profile: string) => Effect.Effect<SessionRecord, HarnessError>;
9
+ readonly get: (id: ConversationId) => Effect.Effect<SessionRecord, HarnessError>;
10
+ readonly list: (workspace: string) => Effect.Effect<ReadonlyArray<SessionRecord>, HarnessError>;
11
+ readonly read: (id: ConversationId, after: number) => Effect.Effect<ReadonlyArray<SessionEvent>, HarnessError>;
12
+ readonly append: (id: ConversationId, body: EventBody) => Effect.Effect<SessionEvent, HarnessError>;
13
+ readonly fork: (id: ConversationId, through: number) => Effect.Effect<SessionRecord, HarnessError>;
14
+ }>;
15
+ export declare class SessionStore extends SessionStore_base {
16
+ }
17
+ export interface LoopInput {
18
+ readonly session: SessionRecord;
19
+ readonly runId: string;
20
+ readonly prompt: string;
21
+ readonly system: string;
22
+ readonly publish: (event: EventBody) => Effect.Effect<SessionEvent, HarnessError>;
23
+ readonly transient: (event: EventBody) => Effect.Effect<void>;
24
+ readonly steering: Effect.Effect<Option.Option<string>, HarnessError>;
25
+ }
26
+ declare const AgentLoop_base: Context.TagClass<AgentLoop, "efferent/AgentLoop", {
27
+ readonly run: (input: LoopInput) => Effect.Effect<{
28
+ readonly text: string;
29
+ readonly outcome: "completed" | "partial";
30
+ }, HarnessError>;
31
+ }>;
32
+ export declare class AgentLoop extends AgentLoop_base {
33
+ }
34
+ declare const DelegateLoop_base: Context.TagClass<DelegateLoop, "efferent/DelegateLoop", {
35
+ readonly run: (input: LoopInput) => Effect.Effect<{
36
+ readonly text: string;
37
+ readonly outcome: "completed" | "partial";
38
+ }, HarnessError>;
39
+ }>;
40
+ /** A workflow can delegate coding while retaining its own outer loop. */
41
+ export declare class DelegateLoop extends DelegateLoop_base {
42
+ }
43
+ declare const AgentTools_base: Context.TagClass<AgentTools, "efferent/AgentTools", {
44
+ readonly toolkit: Toolkit.Toolkit<Record<string, Tool.Any>>;
45
+ readonly handlers: Context.Context<Tool.HandlersFor<Record<string, Tool.Any>>>;
46
+ readonly prompt: string;
47
+ }>;
48
+ export declare class AgentTools extends AgentTools_base {
49
+ }
50
+ declare const ActionPolicy_base: Context.TagClass<ActionPolicy, "efferent/ActionPolicy", {
51
+ readonly authorize: (tool: string, input: unknown) => Effect.Effect<void, HarnessError>;
52
+ }>;
53
+ export declare class ActionPolicy extends ActionPolicy_base {
54
+ }
55
+ declare const Approval_base: Context.TagClass<Approval, "efferent/Approval", {
56
+ readonly request: (description: string) => Effect.Effect<boolean, HarnessError>;
57
+ }>;
58
+ export declare class Approval extends Approval_base {
59
+ }
60
+ declare const ContextManager_base: Context.TagClass<ContextManager, "efferent/ContextManager", {
61
+ readonly compact: (messages: ReadonlyArray<AgentMessage>, tokens: number) => Effect.Effect<Option.Option<{
62
+ readonly summary: string;
63
+ readonly keepFrom: number;
64
+ }>, HarnessError>;
65
+ }>;
66
+ export declare class ContextManager extends ContextManager_base {
67
+ }
68
+ declare const Memory_base: Context.TagClass<Memory, "efferent/Memory", {
69
+ readonly recall: (workspace: string, query: string) => Effect.Effect<ReadonlyArray<MemoryEntry>, HarnessError>;
70
+ readonly remember: (workspace: string, text: string) => Effect.Effect<MemoryEntry, HarnessError>;
71
+ readonly forget: (workspace: string, id: string) => Effect.Effect<void, HarnessError>;
72
+ }>;
73
+ export declare class Memory extends Memory_base {
74
+ }
75
+ declare const SessionEnvironment_base: Context.TagClass<SessionEnvironment, "efferent/SessionEnvironment", {
76
+ readonly workspace: string;
77
+ readonly session?: SessionRecord;
78
+ }>;
79
+ export declare class SessionEnvironment extends SessionEnvironment_base {
80
+ }
81
+ declare const TurnHooks_base: Context.TagClass<TurnHooks, "efferent/TurnHooks", {
82
+ readonly before: (input: LoopInput) => Effect.Effect<LoopInput, HarnessError>;
83
+ readonly after: (input: LoopInput) => Effect.Effect<void, HarnessError>;
84
+ }>;
85
+ /** Ordered hooks alter a turn; observers subscribe to the journal separately. */
86
+ export declare class TurnHooks extends TurnHooks_base {
87
+ }
88
+ export interface SessionHandle {
89
+ readonly record: SessionRecord;
90
+ readonly use: <I, A, B, E, R>(tag: Context.Tag<I, A>, run: (service: A) => Effect.Effect<B, E, R>) => Effect.Effect<B, E | HarnessError, R>;
91
+ readonly send: (text: string) => Effect.Effect<void, HarnessError>;
92
+ readonly steer: (text: string) => Effect.Effect<void, HarnessError>;
93
+ readonly interrupt: Effect.Effect<void>;
94
+ readonly events: (after?: number) => Stream.Stream<SessionEvent, HarnessError>;
95
+ readonly transient: Stream.Stream<EventBody>;
96
+ readonly history: Effect.Effect<ReadonlyArray<SessionEvent>, HarnessError>;
97
+ readonly busy: Effect.Effect<boolean>;
98
+ readonly pending: Effect.Effect<ReadonlyArray<{
99
+ readonly id: string;
100
+ readonly text: string;
101
+ }>>;
102
+ readonly continue: Effect.Effect<void, HarnessError>;
103
+ readonly refresh: Effect.Effect<void, HarnessError>;
104
+ readonly close: Effect.Effect<void>;
105
+ }
106
+ export {};
@@ -0,0 +1,31 @@
1
+ import { Context } from "effect";
2
+
3
+ export class SessionStore extends Context.Tag("efferent/SessionStore")() {
4
+ }
5
+
6
+ export class AgentLoop extends Context.Tag("efferent/AgentLoop")() {
7
+ }
8
+
9
+ export class DelegateLoop extends Context.Tag("efferent/DelegateLoop")() {
10
+ }
11
+
12
+ export class AgentTools extends Context.Tag("efferent/AgentTools")() {
13
+ }
14
+
15
+ export class ActionPolicy extends Context.Tag("efferent/ActionPolicy")() {
16
+ }
17
+
18
+ export class Approval extends Context.Tag("efferent/Approval")() {
19
+ }
20
+
21
+ export class ContextManager extends Context.Tag("efferent/ContextManager")() {
22
+ }
23
+
24
+ export class Memory extends Context.Tag("efferent/Memory")() {
25
+ }
26
+
27
+ export class SessionEnvironment extends Context.Tag("efferent/SessionEnvironment")() {
28
+ }
29
+
30
+ export class TurnHooks extends Context.Tag("efferent/TurnHooks")() {
31
+ }
@@ -0,0 +1,74 @@
1
+ import { Context, Schema } from "effect";
2
+ import type { Effect } from "effect";
3
+ declare const McpError_base: Schema.TaggedErrorClass<McpError, "McpError", {
4
+ readonly _tag: Schema.tag<"McpError">;
5
+ } & {
6
+ server: typeof Schema.String;
7
+ message: typeof Schema.String;
8
+ }>;
9
+ /**
10
+ * The MCP client port — external, user-configured tool servers surfaced to
11
+ * agents through the ordinary toolkit machinery (see `mcp/bridge.ts`). The
12
+ * adapter owns transport (stdio JSON-RPC) and lifecycle; the engine sees
13
+ * only descriptors and calls. Consent model: servers exist ONLY because the
14
+ * human wrote them into `.efferent/config.json`.
15
+ */
16
+ export declare class McpError extends McpError_base {
17
+ }
18
+ declare const McpToolDescriptor_base: Schema.Class<McpToolDescriptor, {
19
+ server: typeof Schema.String;
20
+ name: typeof Schema.String;
21
+ description: Schema.optionalWith<typeof Schema.String, {
22
+ as: "Option";
23
+ }>;
24
+ /** The server's inputSchema, verbatim JSON Schema — the provider sees it
25
+ * unchanged through the bridge's annotation override. */
26
+ inputSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
27
+ }, Schema.Struct.Encoded<{
28
+ server: typeof Schema.String;
29
+ name: typeof Schema.String;
30
+ description: Schema.optionalWith<typeof Schema.String, {
31
+ as: "Option";
32
+ }>;
33
+ /** The server's inputSchema, verbatim JSON Schema — the provider sees it
34
+ * unchanged through the bridge's annotation override. */
35
+ inputSchema: Schema.Record$<typeof Schema.String, typeof Schema.Unknown>;
36
+ }>, never, {
37
+ readonly description: import("effect/Option").Option<string>;
38
+ } & {
39
+ readonly name: string;
40
+ } & {
41
+ readonly server: string;
42
+ } & {
43
+ readonly inputSchema: {
44
+ readonly [x: string]: unknown;
45
+ };
46
+ }, {}, {}>;
47
+ export declare class McpToolDescriptor extends McpToolDescriptor_base {
48
+ }
49
+ declare const McpCallOutcome_base: Schema.Class<McpCallOutcome, {
50
+ /** MCP's in-band failure flag — bridged to failure-as-data, never thrown. */
51
+ isError: typeof Schema.Boolean;
52
+ /** structuredContent when the server sent it, else the text blocks joined. */
53
+ result: typeof Schema.Unknown;
54
+ }, Schema.Struct.Encoded<{
55
+ /** MCP's in-band failure flag — bridged to failure-as-data, never thrown. */
56
+ isError: typeof Schema.Boolean;
57
+ /** structuredContent when the server sent it, else the text blocks joined. */
58
+ result: typeof Schema.Unknown;
59
+ }>, never, {
60
+ readonly isError: boolean;
61
+ } & {
62
+ readonly result: unknown;
63
+ }, {}, {}>;
64
+ export declare class McpCallOutcome extends McpCallOutcome_base {
65
+ }
66
+ declare const McpClient_base: Context.TagClass<McpClient, "@xandreed/core/McpClient", {
67
+ /** Aggregate across every configured server — best-effort: an
68
+ * unreachable server contributes nothing, never a failure. */
69
+ readonly listTools: Effect.Effect<ReadonlyArray<McpToolDescriptor>>;
70
+ readonly callTool: (server: string, tool: string, args: unknown) => Effect.Effect<McpCallOutcome, McpError>;
71
+ }>;
72
+ export declare class McpClient extends McpClient_base {
73
+ }
74
+ export {};
@@ -0,0 +1,24 @@
1
+ import { Context, Schema } from "effect";
2
+
3
+ export class McpError extends Schema.TaggedError()("McpError", {
4
+ server: Schema.String,
5
+ message: Schema.String
6
+ }) {
7
+ }
8
+
9
+ export class McpToolDescriptor extends Schema.Class("McpToolDescriptor")({
10
+ server: Schema.String,
11
+ name: Schema.String,
12
+ description: Schema.optionalWith(Schema.String, { as: "Option" }),
13
+ inputSchema: Schema.Record({ key: Schema.String, value: Schema.Unknown })
14
+ }) {
15
+ }
16
+
17
+ export class McpCallOutcome extends Schema.Class("McpCallOutcome")({
18
+ isError: Schema.Boolean,
19
+ result: Schema.Unknown
20
+ }) {
21
+ }
22
+
23
+ export class McpClient extends Context.Tag("@xandreed/core/McpClient")() {
24
+ }
@@ -0,0 +1,10 @@
1
+ import { Context } from "effect";
2
+ import type { Effect } from "effect";
3
+ import type { ModelCatalogEntry } from "../domain/model-catalog.entity.js";
4
+ declare const ModelCatalog_base: Context.TagClass<ModelCatalog, "@xandreed/core/ModelCatalog", {
5
+ readonly list: Effect.Effect<ReadonlyArray<ModelCatalogEntry>>;
6
+ }>;
7
+ /** Provider-neutral discovery of models usable by configured adapters. */
8
+ export declare class ModelCatalog extends ModelCatalog_base {
9
+ }
10
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Context } from "effect";
2
+
3
+ export class ModelCatalog extends Context.Tag("@xandreed/core/ModelCatalog")() {
4
+ }