@inixiative/foundry-core 0.1.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/LICENSE +21 -0
- package/package.json +39 -0
- package/src/action-prompt.ts +248 -0
- package/src/adapters/file-memory.ts +718 -0
- package/src/adapters/http-memory.ts +141 -0
- package/src/adapters/index.ts +4 -0
- package/src/adapters/markdown-docs.ts +213 -0
- package/src/adapters/sqlite-memory.ts +188 -0
- package/src/base-agent.ts +137 -0
- package/src/bounded-set.ts +42 -0
- package/src/cache-lifecycle.ts +187 -0
- package/src/capability.ts +252 -0
- package/src/classifier.ts +43 -0
- package/src/context-layer.ts +706 -0
- package/src/context-stack.ts +223 -0
- package/src/credentials.ts +14 -0
- package/src/decider.ts +62 -0
- package/src/delivery-evidence.ts +85 -0
- package/src/event-stream.ts +105 -0
- package/src/executor.ts +185 -0
- package/src/harness.ts +749 -0
- package/src/hooks.ts +133 -0
- package/src/hydrator.ts +148 -0
- package/src/id.ts +39 -0
- package/src/index.ts +273 -0
- package/src/intervention.ts +134 -0
- package/src/messages.ts +315 -0
- package/src/middleware.ts +118 -0
- package/src/native-evidence.ts +140 -0
- package/src/permission-middleware.ts +92 -0
- package/src/retry.ts +91 -0
- package/src/router.ts +41 -0
- package/src/scope.ts +20 -0
- package/src/signal.ts +117 -0
- package/src/thread.ts +528 -0
- package/src/token-counts.ts +30 -0
- package/src/token-tracker.ts +433 -0
- package/src/tools.ts +714 -0
- package/src/trace.ts +261 -0
- package/src/types.ts +167 -0
package/src/hooks.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Types
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
export type HookPoint =
|
|
6
|
+
| "pre:dispatch"
|
|
7
|
+
| "post:dispatch"
|
|
8
|
+
| "pre:classify"
|
|
9
|
+
| "post:classify"
|
|
10
|
+
| "pre:route"
|
|
11
|
+
| "post:route"
|
|
12
|
+
| "pre:compact"
|
|
13
|
+
| "post:compact"
|
|
14
|
+
| "session:create"
|
|
15
|
+
| "session:archive"
|
|
16
|
+
| "budget:warning"
|
|
17
|
+
| "budget:exceeded"
|
|
18
|
+
| "plan:enter"
|
|
19
|
+
| "plan:exit"
|
|
20
|
+
| "error:agent"
|
|
21
|
+
| "error:provider";
|
|
22
|
+
|
|
23
|
+
export interface HookContext {
|
|
24
|
+
hookPoint: HookPoint;
|
|
25
|
+
threadId?: string;
|
|
26
|
+
agentId?: string;
|
|
27
|
+
payload?: unknown;
|
|
28
|
+
result?: unknown;
|
|
29
|
+
meta: Record<string, unknown>;
|
|
30
|
+
timestamp: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface HookResult {
|
|
34
|
+
action: "continue" | "skip" | "abort" | "redirect";
|
|
35
|
+
redirectTo?: string;
|
|
36
|
+
modified?: Partial<HookContext>;
|
|
37
|
+
annotations?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface HookHandler {
|
|
41
|
+
id: string;
|
|
42
|
+
points: HookPoint[];
|
|
43
|
+
priority?: number;
|
|
44
|
+
handler: (ctx: HookContext) => Promise<HookResult>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface PlanModeTrigger {
|
|
48
|
+
kind: "complexity" | "newDomain" | "largeDiff" | "custom";
|
|
49
|
+
threshold?: number;
|
|
50
|
+
detect?: (ctx: HookContext) => boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface PlanModeConfig {
|
|
54
|
+
triggers: PlanModeTrigger[];
|
|
55
|
+
plannerAgentId: string;
|
|
56
|
+
requireApproval?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// HookRegistry — engine mechanism, no built-in behaviors
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
const DEFAULT_PRIORITY = 100;
|
|
64
|
+
|
|
65
|
+
export class HookRegistry {
|
|
66
|
+
private _handlers: Map<string, HookHandler> = new Map();
|
|
67
|
+
|
|
68
|
+
register(handler: HookHandler): () => void {
|
|
69
|
+
this._handlers.set(handler.id, handler);
|
|
70
|
+
return () => { this._handlers.delete(handler.id); };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
unregister(id: string): boolean {
|
|
74
|
+
return this._handlers.delete(id);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async execute(
|
|
78
|
+
point: HookPoint,
|
|
79
|
+
ctx: HookContext
|
|
80
|
+
): Promise<HookContext & { action: HookResult["action"] }> {
|
|
81
|
+
const handlers = this.forPoint(point);
|
|
82
|
+
let current = { ...ctx };
|
|
83
|
+
let action: HookResult["action"] = "continue";
|
|
84
|
+
|
|
85
|
+
for (const handler of handlers) {
|
|
86
|
+
const result = await handler.handler(current);
|
|
87
|
+
action = result.action;
|
|
88
|
+
|
|
89
|
+
if (result.modified) {
|
|
90
|
+
current = {
|
|
91
|
+
...current,
|
|
92
|
+
...result.modified,
|
|
93
|
+
meta: { ...current.meta, ...result.modified.meta },
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (result.annotations) {
|
|
98
|
+
current.meta = { ...current.meta, ...result.annotations };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (result.redirectTo) {
|
|
102
|
+
current.meta = { ...current.meta, redirectTo: result.redirectTo };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (action === "abort" || action === "skip" || action === "redirect") {
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return { ...current, action };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
forPoint(point: HookPoint): ReadonlyArray<HookHandler> {
|
|
114
|
+
const matching: HookHandler[] = [];
|
|
115
|
+
for (const handler of this._handlers.values()) {
|
|
116
|
+
if (handler.points.includes(point)) {
|
|
117
|
+
matching.push(handler);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
matching.sort(
|
|
121
|
+
(a, b) => (a.priority ?? DEFAULT_PRIORITY) - (b.priority ?? DEFAULT_PRIORITY)
|
|
122
|
+
);
|
|
123
|
+
return matching;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get size(): number {
|
|
127
|
+
return this._handlers.size;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get handlers(): ReadonlyArray<HookHandler> {
|
|
131
|
+
return [...this._handlers.values()];
|
|
132
|
+
}
|
|
133
|
+
}
|
package/src/hydrator.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { ContextSource } from "./context-layer";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A ref is a pointer into a knowledge system.
|
|
5
|
+
* It carries just enough to locate the content — not the content itself.
|
|
6
|
+
* Agents pass refs around, and adapters hydrate them on demand.
|
|
7
|
+
*/
|
|
8
|
+
export interface ContextRef {
|
|
9
|
+
/** Which system this ref points into (e.g. "docs", "memory", "corpus", "api") */
|
|
10
|
+
readonly system: string;
|
|
11
|
+
|
|
12
|
+
/** Location within that system (path, key, query, URI — system-specific) */
|
|
13
|
+
readonly locator: string;
|
|
14
|
+
|
|
15
|
+
/** Optional version/revision for pinning */
|
|
16
|
+
readonly version?: string;
|
|
17
|
+
|
|
18
|
+
/** Arbitrary system-specific metadata */
|
|
19
|
+
readonly meta?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* An adapter knows how to hydrate refs from a specific system.
|
|
24
|
+
* Each knowledge system (docs, memory, MuninnDB, etc.) implements one.
|
|
25
|
+
*/
|
|
26
|
+
export interface HydrationAdapter {
|
|
27
|
+
/** Which system this adapter handles — must match ContextRef.system */
|
|
28
|
+
readonly system: string;
|
|
29
|
+
|
|
30
|
+
/** Hydrate a single ref into content. */
|
|
31
|
+
hydrate(ref: ContextRef): Promise<string>;
|
|
32
|
+
|
|
33
|
+
/** Hydrate multiple refs (batch optimization). Default: serial hydrate. */
|
|
34
|
+
hydrateBatch?(refs: ContextRef[]): Promise<string[]>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A ContextSource backed by refs + adapters.
|
|
39
|
+
* Drop this into a ContextLayer as a source — it hydrates on warm().
|
|
40
|
+
*/
|
|
41
|
+
export class RefSource implements ContextSource {
|
|
42
|
+
readonly id: string;
|
|
43
|
+
private _refs: ContextRef[];
|
|
44
|
+
private _registry: HydrationRegistry;
|
|
45
|
+
|
|
46
|
+
constructor(id: string, refs: ContextRef[], registry: HydrationRegistry) {
|
|
47
|
+
this.id = id;
|
|
48
|
+
this._refs = refs;
|
|
49
|
+
this._registry = registry;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async load(): Promise<string> {
|
|
53
|
+
return this._registry.hydrateAll(this._refs);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get refs(): ReadonlyArray<ContextRef> {
|
|
57
|
+
return this._refs;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
addRef(ref: ContextRef): void {
|
|
61
|
+
this._refs.push(ref);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
removeRef(locator: string): boolean {
|
|
65
|
+
const idx = this._refs.findIndex((r) => r.locator === locator);
|
|
66
|
+
if (idx === -1) return false;
|
|
67
|
+
this._refs.splice(idx, 1);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Registry of hydration adapters.
|
|
74
|
+
*
|
|
75
|
+
* You register one adapter per system. When refs come in,
|
|
76
|
+
* the registry routes each ref to the right adapter and hydrates.
|
|
77
|
+
* Refs from different systems in the same batch are hydrated
|
|
78
|
+
* in parallel (one batch per system).
|
|
79
|
+
*/
|
|
80
|
+
export class HydrationRegistry {
|
|
81
|
+
private _adapters: Map<string, HydrationAdapter> = new Map();
|
|
82
|
+
|
|
83
|
+
register(adapter: HydrationAdapter): void {
|
|
84
|
+
this._adapters.set(adapter.system, adapter);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
unregister(system: string): boolean {
|
|
88
|
+
return this._adapters.delete(system);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
getAdapter(system: string): HydrationAdapter | undefined {
|
|
92
|
+
return this._adapters.get(system);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Hydrate a single ref. */
|
|
96
|
+
async hydrate(ref: ContextRef): Promise<string> {
|
|
97
|
+
const adapter = this._adapters.get(ref.system);
|
|
98
|
+
if (!adapter) {
|
|
99
|
+
throw new Error(`No hydration adapter registered for system: ${ref.system}`);
|
|
100
|
+
}
|
|
101
|
+
return adapter.hydrate(ref);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Hydrate multiple refs, grouped by system for batch efficiency.
|
|
106
|
+
* Returns concatenated content in ref order.
|
|
107
|
+
*/
|
|
108
|
+
async hydrateAll(refs: ContextRef[]): Promise<string> {
|
|
109
|
+
if (refs.length === 0) return "";
|
|
110
|
+
|
|
111
|
+
// Group by system
|
|
112
|
+
const bySystem = new Map<string, { idx: number; ref: ContextRef }[]>();
|
|
113
|
+
for (let i = 0; i < refs.length; i++) {
|
|
114
|
+
const ref = refs[i];
|
|
115
|
+
if (!bySystem.has(ref.system)) bySystem.set(ref.system, []);
|
|
116
|
+
bySystem.get(ref.system)!.push({ idx: i, ref });
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Hydrate each system's batch in parallel
|
|
120
|
+
const results: string[] = new Array(refs.length);
|
|
121
|
+
|
|
122
|
+
await Promise.all(
|
|
123
|
+
[...bySystem.entries()].map(async ([system, entries]) => {
|
|
124
|
+
const adapter = this._adapters.get(system);
|
|
125
|
+
if (!adapter) {
|
|
126
|
+
throw new Error(`No hydration adapter registered for system: ${system}`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (adapter.hydrateBatch && entries.length > 1) {
|
|
130
|
+
const batchResults = await adapter.hydrateBatch(
|
|
131
|
+
entries.map((e) => e.ref)
|
|
132
|
+
);
|
|
133
|
+
for (let i = 0; i < entries.length; i++) {
|
|
134
|
+
results[entries[i].idx] = batchResults[i];
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
await Promise.all(
|
|
138
|
+
entries.map(async (entry) => {
|
|
139
|
+
results[entry.idx] = await adapter.hydrate(entry.ref);
|
|
140
|
+
})
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
return results.join("\n\n");
|
|
147
|
+
}
|
|
148
|
+
}
|
package/src/id.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { uuidv7 } from "uuidv7";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mint a new UUID v7 identifier, optionally prefixed.
|
|
5
|
+
*
|
|
6
|
+
* UUID v7 encodes a millisecond Unix timestamp in its first 48 bits, so IDs are
|
|
7
|
+
* lexicographically sortable by creation time. That's why the system stores no
|
|
8
|
+
* `created_at` columns — the ID itself carries the timestamp.
|
|
9
|
+
*
|
|
10
|
+
* Prefixes are cosmetic (for log readability). Sort order is preserved because
|
|
11
|
+
* the prefix is constant within a given table.
|
|
12
|
+
*/
|
|
13
|
+
export function newId(prefix?: string): string {
|
|
14
|
+
const id = uuidv7();
|
|
15
|
+
return prefix ? `${prefix}_${id}` : id;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Synthesize a UUID v7 at the given point in time, for range queries.
|
|
20
|
+
*
|
|
21
|
+
* Used to translate `createdAt < cutoff` into `id < idAtTime(prefix, cutoff)`
|
|
22
|
+
* when cleaning up stale rows by age.
|
|
23
|
+
*/
|
|
24
|
+
export function idAtTime(prefix: string | undefined, date: Date): string {
|
|
25
|
+
const ms = date.getTime();
|
|
26
|
+
if (ms < 0 || ms > 0xffffffffffff) {
|
|
27
|
+
throw new RangeError(`timestamp ${ms} out of UUID v7 range`);
|
|
28
|
+
}
|
|
29
|
+
const hex = ms.toString(16).padStart(12, "0");
|
|
30
|
+
const uuid = `${hex.slice(0, 8)}-${hex.slice(8, 12)}-7000-8000-000000000000`;
|
|
31
|
+
return prefix ? `${prefix}_${uuid}` : uuid;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Extract the millisecond timestamp encoded in a UUID v7 id (with or without prefix). */
|
|
35
|
+
export function timeFromId(id: string): number {
|
|
36
|
+
const uuid = id.includes("_") ? id.slice(id.lastIndexOf("_") + 1) : id;
|
|
37
|
+
const hex = uuid.slice(0, 8) + uuid.slice(9, 13);
|
|
38
|
+
return parseInt(hex, 16);
|
|
39
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// @inixiative/foundry-core — the engine
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
// Shared types
|
|
6
|
+
export type {
|
|
7
|
+
InvocationCondition,
|
|
8
|
+
AgentModeConfig,
|
|
9
|
+
LayerModeConfig,
|
|
10
|
+
LLMMessage,
|
|
11
|
+
CompletionOpts,
|
|
12
|
+
CompletionResult,
|
|
13
|
+
ToolDefinition,
|
|
14
|
+
ToolCall,
|
|
15
|
+
ToolCallResult,
|
|
16
|
+
EmbeddingResult,
|
|
17
|
+
LLMStreamEvent,
|
|
18
|
+
LLMProvider,
|
|
19
|
+
EmbeddingProvider,
|
|
20
|
+
} from "./types";
|
|
21
|
+
|
|
22
|
+
// Ownership scope — which thread/project owns a source read or tool call
|
|
23
|
+
export { normalizeScope, type OwnershipScope } from "./scope";
|
|
24
|
+
|
|
25
|
+
// Message utilities
|
|
26
|
+
export {
|
|
27
|
+
assembledToMessages,
|
|
28
|
+
buildInjectionArtifact,
|
|
29
|
+
splitSystemMessage,
|
|
30
|
+
type BuildInjectionArtifactOpts,
|
|
31
|
+
type InjectionArtifact,
|
|
32
|
+
type InjectionBlock,
|
|
33
|
+
type InjectionSegmentKind,
|
|
34
|
+
type MessageDecoration,
|
|
35
|
+
type DecorationParticipant,
|
|
36
|
+
type ParticipantRequest,
|
|
37
|
+
type DeliveryRecord,
|
|
38
|
+
} from "./messages";
|
|
39
|
+
|
|
40
|
+
// Context primitives
|
|
41
|
+
export {
|
|
42
|
+
ContextLayer,
|
|
43
|
+
computeHash,
|
|
44
|
+
copyMessageIdentity,
|
|
45
|
+
type LogicalMessageIdentity,
|
|
46
|
+
type ContextSource,
|
|
47
|
+
type ContextLayerConfig,
|
|
48
|
+
type LayerDefinition,
|
|
49
|
+
type LayerInstanceState,
|
|
50
|
+
type LayerVersionMark,
|
|
51
|
+
type LayerSegment,
|
|
52
|
+
LAYER_SEGMENTS,
|
|
53
|
+
isLayerSegment,
|
|
54
|
+
type LayerMutationEvent,
|
|
55
|
+
type LayerSelectionState,
|
|
56
|
+
type LayerState,
|
|
57
|
+
type SourceLoadHint,
|
|
58
|
+
type SourceSelectionReport,
|
|
59
|
+
type VersionEntry,
|
|
60
|
+
type VersionLog,
|
|
61
|
+
} from "./context-layer";
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
ContextStack,
|
|
65
|
+
type LayerFilter,
|
|
66
|
+
type ContextSnapshot,
|
|
67
|
+
type ContextStackView,
|
|
68
|
+
type PromptBlock,
|
|
69
|
+
type AssembledContext,
|
|
70
|
+
} from "./context-stack";
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
CacheLifecycle,
|
|
74
|
+
type LifecycleEvent,
|
|
75
|
+
type LifecycleHandler,
|
|
76
|
+
type LifecycleRule,
|
|
77
|
+
} from "./cache-lifecycle";
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
HydrationRegistry,
|
|
81
|
+
RefSource,
|
|
82
|
+
type ContextRef,
|
|
83
|
+
type HydrationAdapter,
|
|
84
|
+
} from "./hydrator";
|
|
85
|
+
|
|
86
|
+
// Agent primitives
|
|
87
|
+
export {
|
|
88
|
+
BaseAgent,
|
|
89
|
+
type ExecutionResult,
|
|
90
|
+
type AgentConfig,
|
|
91
|
+
type AgentLLMConfig,
|
|
92
|
+
} from "./base-agent";
|
|
93
|
+
|
|
94
|
+
export { Executor, type ExecuteHandler, type ExecuteMeta, type ExecutorConfig } from "./executor";
|
|
95
|
+
export { Decider, type Decision, type DecideHandler, type DeciderConfig } from "./decider";
|
|
96
|
+
export { Classifier, type Classification, type ClassifyHandler, type ClassifierConfig } from "./classifier";
|
|
97
|
+
export { Router, type Route, type RouteHandler, type RouterConfig } from "./router";
|
|
98
|
+
|
|
99
|
+
// Middleware
|
|
100
|
+
export {
|
|
101
|
+
MiddlewareChain,
|
|
102
|
+
type Middleware,
|
|
103
|
+
type MiddlewareTier,
|
|
104
|
+
type MiddlewareEntry,
|
|
105
|
+
type DispatchContext,
|
|
106
|
+
type DispatchOutcome,
|
|
107
|
+
type MiddlewareNext,
|
|
108
|
+
} from "./middleware";
|
|
109
|
+
|
|
110
|
+
// Signals
|
|
111
|
+
export { SignalBus, type Signal, type SignalKind, type SignalHandler } from "./signal";
|
|
112
|
+
|
|
113
|
+
// Orchestration
|
|
114
|
+
export {
|
|
115
|
+
Thread,
|
|
116
|
+
type ThreadStatus,
|
|
117
|
+
type ThreadMeta,
|
|
118
|
+
type ThreadConfig,
|
|
119
|
+
type Dispatch,
|
|
120
|
+
type DispatchOptions,
|
|
121
|
+
type DispatchObservation,
|
|
122
|
+
type FanResult,
|
|
123
|
+
} from "./thread";
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
Harness,
|
|
127
|
+
matchesCondition,
|
|
128
|
+
type Message,
|
|
129
|
+
type HarnessResult,
|
|
130
|
+
type PipelineStep,
|
|
131
|
+
type FlowStage,
|
|
132
|
+
type FlowConfig,
|
|
133
|
+
type RequestContext,
|
|
134
|
+
} from "./harness";
|
|
135
|
+
|
|
136
|
+
// Tracing
|
|
137
|
+
export { Trace, type Span, type SpanKind, type SpanStatus, type TraceSummary, type StageSummary } from "./trace";
|
|
138
|
+
|
|
139
|
+
// Interventions
|
|
140
|
+
export { InterventionLog, type Intervention } from "./intervention";
|
|
141
|
+
|
|
142
|
+
// Observability
|
|
143
|
+
export { EventStream, type StreamEvent, type SessionEvent } from "./event-stream";
|
|
144
|
+
|
|
145
|
+
// Token & Cost Tracking
|
|
146
|
+
export {
|
|
147
|
+
TokenTracker,
|
|
148
|
+
BudgetExceededError,
|
|
149
|
+
estimateTokens,
|
|
150
|
+
DEFAULT_COST_TABLE,
|
|
151
|
+
type TokenUsage,
|
|
152
|
+
type UsageEntry,
|
|
153
|
+
type ModelPricing,
|
|
154
|
+
type CostTable,
|
|
155
|
+
type BudgetConfig,
|
|
156
|
+
type BudgetStatus,
|
|
157
|
+
type UsageBreakdown,
|
|
158
|
+
type UsageSummary,
|
|
159
|
+
} from "./token-tracker";
|
|
160
|
+
|
|
161
|
+
// Lifecycle Hooks (registry only — built-in hooks in @inixiative/foundry)
|
|
162
|
+
export {
|
|
163
|
+
HookRegistry,
|
|
164
|
+
type HookPoint,
|
|
165
|
+
type HookContext,
|
|
166
|
+
type HookResult,
|
|
167
|
+
type HookHandler,
|
|
168
|
+
type PlanModeConfig,
|
|
169
|
+
type PlanModeTrigger,
|
|
170
|
+
} from "./hooks";
|
|
171
|
+
|
|
172
|
+
// Action Prompts (agent→human interaction)
|
|
173
|
+
export {
|
|
174
|
+
ActionQueue,
|
|
175
|
+
type ActionPrompt,
|
|
176
|
+
type ActionResolution,
|
|
177
|
+
type ActionOption,
|
|
178
|
+
type PromptKind,
|
|
179
|
+
type PromptUrgency,
|
|
180
|
+
type PromptStatus,
|
|
181
|
+
type PromptOpts,
|
|
182
|
+
type PromptListener,
|
|
183
|
+
type PromptPolicy,
|
|
184
|
+
} from "./action-prompt";
|
|
185
|
+
|
|
186
|
+
// Capabilities (permission flags + gating)
|
|
187
|
+
export {
|
|
188
|
+
CapabilityGate,
|
|
189
|
+
CapabilityDeniedError,
|
|
190
|
+
UNATTENDED_POLICY,
|
|
191
|
+
SUPERVISED_POLICY,
|
|
192
|
+
RESTRICTED_POLICY,
|
|
193
|
+
BROWSER_POLICY,
|
|
194
|
+
type Capability,
|
|
195
|
+
type BuiltinCapability,
|
|
196
|
+
type PermissionLevel,
|
|
197
|
+
type PermissionPolicy,
|
|
198
|
+
type GateContext,
|
|
199
|
+
} from "./capability";
|
|
200
|
+
|
|
201
|
+
// Lightweight adapters (zero external deps)
|
|
202
|
+
export {
|
|
203
|
+
FileMemory,
|
|
204
|
+
MemoryView,
|
|
205
|
+
entryVisibleTo,
|
|
206
|
+
inlineSource,
|
|
207
|
+
fileSource,
|
|
208
|
+
selectMemory,
|
|
209
|
+
focusTerms,
|
|
210
|
+
DEFAULT_MEMORY_SELECTION, validateMemorySelection,
|
|
211
|
+
type MemoryEntry,
|
|
212
|
+
type MemoryReadScope,
|
|
213
|
+
type MemorySourceOpts,
|
|
214
|
+
type MemorySelectionPolicy,
|
|
215
|
+
type MemorySelectionReport,
|
|
216
|
+
} from "./adapters/file-memory";
|
|
217
|
+
|
|
218
|
+
export { SqliteMemory, type SqliteEntry } from "./adapters/sqlite-memory";
|
|
219
|
+
export { HttpMemory } from "./adapters/http-memory";
|
|
220
|
+
export { MarkdownDocs, claudemdSource } from "./adapters/markdown-docs";
|
|
221
|
+
|
|
222
|
+
// Tools — typed execution interfaces
|
|
223
|
+
export {
|
|
224
|
+
ToolRegistry,
|
|
225
|
+
type Tool,
|
|
226
|
+
type ToolKind,
|
|
227
|
+
type ToolInfo,
|
|
228
|
+
type ToolResult,
|
|
229
|
+
type ToolCallObservation,
|
|
230
|
+
type BrowserTool,
|
|
231
|
+
type PageSnapshot,
|
|
232
|
+
type PageElement,
|
|
233
|
+
type NavigateOpts,
|
|
234
|
+
type ApiTool,
|
|
235
|
+
type ApiRequest,
|
|
236
|
+
type ApiResponse,
|
|
237
|
+
type ApiToolConfig,
|
|
238
|
+
type ShellTool,
|
|
239
|
+
type ShellResult,
|
|
240
|
+
type ShellOpts,
|
|
241
|
+
type OutputFilter,
|
|
242
|
+
type ScriptTool,
|
|
243
|
+
type ScriptResult,
|
|
244
|
+
type ScriptOpts,
|
|
245
|
+
type MemoryTool,
|
|
246
|
+
type MemoryEntry as ToolMemoryEntry,
|
|
247
|
+
type MemoryVisibility,
|
|
248
|
+
type MemorySearchOpts,
|
|
249
|
+
} from "./tools";
|
|
250
|
+
|
|
251
|
+
// Bounded data structures
|
|
252
|
+
export { BoundedSet } from "./bounded-set";
|
|
253
|
+
|
|
254
|
+
// IDs (UUID v7 — carries its own creation timestamp)
|
|
255
|
+
export { newId, idAtTime, timeFromId } from "./id";
|
|
256
|
+
|
|
257
|
+
// Retry middleware
|
|
258
|
+
export { retryMiddleware, type RetryConfig } from "./retry";
|
|
259
|
+
|
|
260
|
+
// Permission middleware
|
|
261
|
+
export {
|
|
262
|
+
permissionMiddleware,
|
|
263
|
+
type PermissionMiddlewareConfig,
|
|
264
|
+
type PermissionCheck,
|
|
265
|
+
type PermissionCheckResult,
|
|
266
|
+
} from "./permission-middleware";
|
|
267
|
+
|
|
268
|
+
export { REQUIRED_CONTEXT_BLOCKED } from "./context-layer";
|
|
269
|
+
export * from "./native-evidence";
|
|
270
|
+
export type { CredentialReference, CredentialScope, CredentialResolver } from "./credentials";
|
|
271
|
+
export { evidenceDigest, assemblyDigest, boundaryReceipt, verifyExpertDelivery } from "./delivery-evidence";
|
|
272
|
+
export type { ProviderBoundaryReceipt, DeliveryOwner, ExpertDeliveryProof } from "./delivery-evidence";
|
|
273
|
+
export { type TokenCounts, totalTokenCount, sumTokenCounts } from "./token-counts";
|