@capekai/core 1.0.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 (148) hide show
  1. package/README.md +12 -0
  2. package/package.json +105 -0
  3. package/src/adapters/ai-sdk.ts +84 -0
  4. package/src/compaction/contracts.ts +82 -0
  5. package/src/compaction/executor.ts +161 -0
  6. package/src/compaction/policy.ts +318 -0
  7. package/src/compaction/recovery.ts +139 -0
  8. package/src/compaction/task.ts +540 -0
  9. package/src/configuration/contracts.ts +58 -0
  10. package/src/configuration/defaults.ts +27 -0
  11. package/src/configuration/runtime.ts +42 -0
  12. package/src/configuration/single-model.ts +75 -0
  13. package/src/context/assembler.ts +112 -0
  14. package/src/context/index.ts +2 -0
  15. package/src/context/sources.ts +119 -0
  16. package/src/context/workspace.ts +63 -0
  17. package/src/core/agent.ts +401 -0
  18. package/src/core/build-tools.ts +139 -0
  19. package/src/core/chat-handler.ts +858 -0
  20. package/src/core/error-handling.ts +18 -0
  21. package/src/core/fork.ts +103 -0
  22. package/src/core/interrupt.ts +192 -0
  23. package/src/core/message-utils.ts +261 -0
  24. package/src/core/model-utils.ts +149 -0
  25. package/src/core/part-utils.ts +88 -0
  26. package/src/core/provider-utils.ts +67 -0
  27. package/src/core/revert.ts +46 -0
  28. package/src/core/step-handlers.ts +157 -0
  29. package/src/core/stream/finalization.ts +65 -0
  30. package/src/core/stream/stream-config.ts +82 -0
  31. package/src/core/stream-handlers.ts +242 -0
  32. package/src/core/structured-output.ts +68 -0
  33. package/src/core/tool-builders/agent-tools.ts +71 -0
  34. package/src/core/tool-builders/external-tools.ts +179 -0
  35. package/src/core/tool-builders/types.ts +16 -0
  36. package/src/core/tool-builders/workspace-tools.ts +293 -0
  37. package/src/core/tool-capabilities.ts +65 -0
  38. package/src/goals/evaluator.ts +171 -0
  39. package/src/goals/index.ts +3 -0
  40. package/src/goals/loop.ts +167 -0
  41. package/src/goals/service.ts +39 -0
  42. package/src/index.ts +10 -0
  43. package/src/internal/ask-authority.ts +29 -0
  44. package/src/internal/composition.ts +44 -0
  45. package/src/internal/configuration.ts +22 -0
  46. package/src/internal/execution.ts +108 -0
  47. package/src/internal/hosts.ts +64 -0
  48. package/src/internal/plugins.ts +71 -0
  49. package/src/internal/providers.ts +32 -0
  50. package/src/internal/sandbox.ts +19 -0
  51. package/src/internal/tools.ts +48 -0
  52. package/src/internal/workspace.ts +25 -0
  53. package/src/kernel/diagnostics.ts +249 -0
  54. package/src/kernel/errors.ts +120 -0
  55. package/src/kernel/events.ts +82 -0
  56. package/src/kernel/index.ts +72 -0
  57. package/src/kernel/kernel.ts +62 -0
  58. package/src/kernel/lifecycle.ts +72 -0
  59. package/src/kernel/plugin.ts +218 -0
  60. package/src/kernel/registry.ts +493 -0
  61. package/src/kernel/scope.ts +776 -0
  62. package/src/kernel/service-key.ts +19 -0
  63. package/src/kernel/types.ts +317 -0
  64. package/src/memory/index.ts +2 -0
  65. package/src/memory/memory-tool.ts +75 -0
  66. package/src/memory/registry.ts +172 -0
  67. package/src/permission/ask-user-api.ts +70 -0
  68. package/src/permission/contracts.ts +135 -0
  69. package/src/permission/permission-request-manager.ts +58 -0
  70. package/src/permission/policy.ts +277 -0
  71. package/src/permission/runtime.ts +612 -0
  72. package/src/plugins/compaction-policy.ts +46 -0
  73. package/src/plugins/compose.ts +171 -0
  74. package/src/plugins/context-sections.ts +246 -0
  75. package/src/plugins/default-agent-driver.ts +14 -0
  76. package/src/plugins/facade-plugins.ts +129 -0
  77. package/src/plugins/goal-domain.ts +82 -0
  78. package/src/plugins/legacy-system-message.ts +152 -0
  79. package/src/plugins/loaded-tools.ts +23 -0
  80. package/src/plugins/memory-domain.ts +264 -0
  81. package/src/plugins/orchestrator-session.ts +29 -0
  82. package/src/plugins/permission-policy.ts +49 -0
  83. package/src/plugins/retry-policy.ts +28 -0
  84. package/src/plugins/scheduler-domain.ts +192 -0
  85. package/src/plugins/service-keys.ts +294 -0
  86. package/src/plugins/session-search-domain.ts +238 -0
  87. package/src/plugins/skills-domain.ts +272 -0
  88. package/src/plugins/subagent-domain.ts +287 -0
  89. package/src/plugins/tool-catalog.ts +78 -0
  90. package/src/plugins/tool-output-policy.ts +52 -0
  91. package/src/plugins/value-plugins.ts +150 -0
  92. package/src/plugins/workflow-domain.ts +198 -0
  93. package/src/plugins/workspace-policy.ts +37 -0
  94. package/src/providers/registry.ts +63 -0
  95. package/src/providers/types.ts +44 -0
  96. package/src/retry/policy.ts +282 -0
  97. package/src/retry/stream-chat.ts +312 -0
  98. package/src/runtime/agent-runtime.ts +83 -0
  99. package/src/runtime/default-agent-driver.ts +23 -0
  100. package/src/runtime/domain-tool-source.ts +156 -0
  101. package/src/runtime/events.ts +61 -0
  102. package/src/runtime/host-dependencies.ts +71 -0
  103. package/src/runtime/host-guidance.ts +22 -0
  104. package/src/runtime/host-layout.ts +23 -0
  105. package/src/runtime/host.ts +129 -0
  106. package/src/runtime/standalone-host.ts +118 -0
  107. package/src/sandbox/controller.ts +204 -0
  108. package/src/sandbox/model.ts +305 -0
  109. package/src/sandbox/provider.ts +53 -0
  110. package/src/sandbox/types.ts +110 -0
  111. package/src/scheduler/host.ts +22 -0
  112. package/src/scheduler/scheduler-tool.ts +172 -0
  113. package/src/session-search/host.ts +56 -0
  114. package/src/session-search/index.ts +23 -0
  115. package/src/session-search/session-search-tool.ts +151 -0
  116. package/src/skills/index.ts +3 -0
  117. package/src/skills/registry.ts +63 -0
  118. package/src/skills/skill-manage-tool.ts +205 -0
  119. package/src/skills/skill-tool.ts +42 -0
  120. package/src/storage/contracts.ts +159 -0
  121. package/src/storage/memory.ts +321 -0
  122. package/src/storage/options.ts +75 -0
  123. package/src/storage/runtime.ts +115 -0
  124. package/src/storage/sqlite-tool-output-artifacts.ts +106 -0
  125. package/src/storage/sqlite.ts +321 -0
  126. package/src/storage/tool-output-artifacts.ts +75 -0
  127. package/src/storage.ts +31 -0
  128. package/src/subagent/child-session.ts +282 -0
  129. package/src/subagent/guidance.ts +8 -0
  130. package/src/subagent/policy.ts +198 -0
  131. package/src/subagent/task-tool.ts +584 -0
  132. package/src/tool-output/contracts.ts +111 -0
  133. package/src/tool-output/policy.ts +410 -0
  134. package/src/tool.ts +1 -0
  135. package/src/tools/executor.ts +258 -0
  136. package/src/tools/install-manifest.ts +40 -0
  137. package/src/tools/llm-api.ts +77 -0
  138. package/src/tools/registry.ts +206 -0
  139. package/src/tools/tool-artifact.ts +182 -0
  140. package/src/tools/tool-source.ts +53 -0
  141. package/src/utils/errors.ts +334 -0
  142. package/src/utils/strip-visualization.ts +50 -0
  143. package/src/workflow/decomposer.ts +139 -0
  144. package/src/workflow/execution.ts +523 -0
  145. package/src/workflow/orchestrator-session.ts +161 -0
  146. package/src/workflow/synthesizer.ts +130 -0
  147. package/src/workspace/contracts.ts +135 -0
  148. package/src/workspace/policy.ts +327 -0
@@ -0,0 +1,167 @@
1
+ import type { GoalState, Session } from '@capekai/types';
2
+ import { emitSessionUpdated } from '../runtime/host-dependencies';
3
+ import { getSession, updateSession } from '../storage/runtime';
4
+ import type { BroadcastFn, BroadcastSessionFn } from '../runtime/host';
5
+ import {
6
+ buildContinuationMessage,
7
+ evaluateGoal,
8
+ evaluateGoalWithDeps,
9
+ type EvaluateGoalOptions,
10
+ } from './evaluator';
11
+
12
+ /**
13
+ * Goal domain: the persistent goal loop. Moved byte-for-byte from
14
+ * `core/goal-loop.ts`; the unscoped export keeps the pre-C5 module path
15
+ * (module storage, module broadcast, module evaluator), and
16
+ * `runGoalLoopWithDeps` runs against the injected session access, goal
17
+ * state updates, evaluator, and broadcast defaults captured by the goal
18
+ * domain plugin. Goal state stays on `session.metadata.goal` with the exact
19
+ * lifecycle transitions: active, met, failed, cancelled.
20
+ */
21
+
22
+ export type RunTurnFn = (content: string) => Promise<{ streamCompleted: boolean; interrupted: boolean }>;
23
+
24
+ export interface GoalLoopOptions {
25
+ sessionId: string;
26
+ condition: string;
27
+ initialPrompt?: string;
28
+ maxTurns?: number;
29
+ abortSignal?: AbortSignal;
30
+ broadcast?: BroadcastFn;
31
+ broadcastSessionCreated?: BroadcastSessionFn;
32
+ broadcastSessionUpdated?: BroadcastSessionFn;
33
+ runTurn: RunTurnFn;
34
+ evaluate?: typeof evaluateGoal;
35
+ }
36
+
37
+ export interface GoalLoopDeps {
38
+ getSession(id: string): Session | null | Promise<Session | null>;
39
+ updateSession(id: string, updates: Partial<Session>): Session | null | Promise<Session | null>;
40
+ evaluate(options: EvaluateGoalOptions): ReturnType<typeof evaluateGoalWithDeps>;
41
+ broadcastSessionUpdatedDefault(session: Session): void;
42
+ }
43
+
44
+ async function updateGoalStateWithDeps(
45
+ deps: GoalLoopDeps,
46
+ sessionId: string,
47
+ updates: Partial<GoalState>,
48
+ broadcastSessionUpdatedFn?: BroadcastSessionFn,
49
+ ): Promise<void> {
50
+ const session = await deps.getSession(sessionId);
51
+ if (!session) return;
52
+ const metadata = session.metadata ?? {};
53
+ const existingGoal = metadata.goal as GoalState | undefined;
54
+ if (!existingGoal) return;
55
+ const updated = await deps.updateSession(sessionId, { metadata: { ...metadata, goal: { ...existingGoal, ...updates } } });
56
+ if (updated) (broadcastSessionUpdatedFn ?? deps.broadcastSessionUpdatedDefault)(updated);
57
+ }
58
+
59
+ /** Unscoped goal loop: the pre-C5 module accessors. */
60
+ export async function runGoalLoop(options: GoalLoopOptions): Promise<void> {
61
+ return runGoalLoopWithDeps(options, {
62
+ getSession,
63
+ updateSession,
64
+ evaluate: (evaluateOptions) => evaluateGoal(evaluateOptions),
65
+ broadcastSessionUpdatedDefault: emitSessionUpdated,
66
+ });
67
+ }
68
+
69
+ /** Composed goal loop over the dependencies captured by the goal domain
70
+ * plugin. */
71
+ export async function runGoalLoopWithDeps(
72
+ options: GoalLoopOptions,
73
+ deps: GoalLoopDeps,
74
+ ): Promise<void> {
75
+ const maxTurns = options.maxTurns ?? 5;
76
+ const {
77
+ sessionId,
78
+ condition,
79
+ initialPrompt,
80
+ abortSignal,
81
+ broadcast,
82
+ broadcastSessionCreated,
83
+ broadcastSessionUpdated: broadcastSessUpdated,
84
+ runTurn,
85
+ evaluate = (evaluateOptions: EvaluateGoalOptions) => deps.evaluate(evaluateOptions),
86
+ } = options;
87
+
88
+ console.log('[goal:loop] Starting goal loop', {
89
+ sessionId,
90
+ conditionPreview: condition.slice(0, 80),
91
+ maxTurns,
92
+ hasInitialPrompt: !!initialPrompt,
93
+ });
94
+
95
+ const session = await deps.getSession(sessionId);
96
+ if (!session) {
97
+ console.error('[goal:loop] Session not found', { sessionId });
98
+ return;
99
+ }
100
+ const goalState: GoalState = {
101
+ condition,
102
+ maxTurns,
103
+ currentTurn: 0,
104
+ status: 'active',
105
+ startedAt: Date.now(),
106
+ };
107
+ const initialized = await deps.updateSession(sessionId, { metadata: { ...(session.metadata ?? {}), goal: goalState } });
108
+ if (initialized) (broadcastSessUpdated ?? deps.broadcastSessionUpdatedDefault)(initialized);
109
+
110
+ let nextTurnContent = initialPrompt || condition;
111
+ for (let turn = 1; turn <= maxTurns; turn++) {
112
+ if (abortSignal?.aborted) {
113
+ console.log('[goal:loop] Aborted before turn', { turn });
114
+ await updateGoalStateWithDeps(deps, sessionId, { status: 'cancelled', completedAt: Date.now() }, broadcastSessUpdated);
115
+ return;
116
+ }
117
+ await updateGoalStateWithDeps(deps, sessionId, { currentTurn: turn }, broadcastSessUpdated);
118
+ console.log('[goal:loop] Starting turn', { turn, maxTurns, contentPreview: nextTurnContent.slice(0, 80) });
119
+
120
+ const result = await runTurn(nextTurnContent);
121
+ console.log('[goal:loop] Turn completed', { turn, streamCompleted: result.streamCompleted, interrupted: result.interrupted });
122
+
123
+ if (result.interrupted) {
124
+ console.log('[goal:loop] Turn was interrupted, stopping goal loop', { turn });
125
+ await updateGoalStateWithDeps(deps, sessionId, { status: 'cancelled', completedAt: Date.now() }, broadcastSessUpdated);
126
+ return;
127
+ }
128
+
129
+ if (!result.streamCompleted) {
130
+ console.log('[goal:loop] Turn stream did not complete, stopping goal loop', { turn });
131
+ await updateGoalStateWithDeps(deps, sessionId, { status: 'failed', completedAt: Date.now() }, broadcastSessUpdated);
132
+ return;
133
+ }
134
+
135
+ if (abortSignal?.aborted) {
136
+ console.log('[goal:loop] Aborted after turn', { turn });
137
+ await updateGoalStateWithDeps(deps, sessionId, { status: 'cancelled', completedAt: Date.now() }, broadcastSessUpdated);
138
+ return;
139
+ }
140
+
141
+ let evaluation;
142
+ try {
143
+ evaluation = await evaluate({
144
+ sessionId,
145
+ condition,
146
+ turn,
147
+ maxTurns,
148
+ abortSignal,
149
+ broadcast,
150
+ broadcastSessionCreated,
151
+ broadcastSessionUpdated: broadcastSessUpdated,
152
+ });
153
+ } catch (err) {
154
+ console.error('[goal:loop] Evaluator failed', { turn, error: err instanceof Error ? err.message : String(err) });
155
+ evaluation = { goalMet: false, reason: 'Evaluator call failed — continuing work' };
156
+ }
157
+ if (evaluation.goalMet) {
158
+ console.log('[goal:loop] GOAL MET!', { turn, reason: evaluation.reason });
159
+ await updateGoalStateWithDeps(deps, sessionId, { status: 'met', completedAt: Date.now() }, broadcastSessUpdated);
160
+ return;
161
+ }
162
+ nextTurnContent = buildContinuationMessage(condition, evaluation.reason, evaluation.remainingWork);
163
+ console.log('[goal:loop] Prepared continuation for next turn', { turn, continuationPreview: nextTurnContent.slice(0, 80) });
164
+ }
165
+ console.log('[goal:loop] Max turns reached without meeting goal', { maxTurns });
166
+ await updateGoalStateWithDeps(deps, sessionId, { status: 'failed', completedAt: Date.now() }, broadcastSessUpdated);
167
+ }
@@ -0,0 +1,39 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import { evaluateGoal, type EvaluateGoalOptions } from './evaluator';
3
+ import { runGoalLoop, type GoalLoopOptions } from './loop';
4
+
5
+ /**
6
+ * Goal domain service access. The composed agent scope seeds the plugin
7
+ * service here through `enterAgentScope` (when the goal domain plugin is
8
+ * installed); consumers resolve the active service through `getGoalDomain()`.
9
+ * Unscoped consumers keep the pre-adoption module path (module storage,
10
+ * module broadcast, module evaluator) as the fallback, exactly like the C6
11
+ * policy accessors.
12
+ */
13
+
14
+ export interface GoalDomainService {
15
+ evaluateGoal(options: EvaluateGoalOptions): ReturnType<typeof evaluateGoal>;
16
+ runGoalLoop(options: GoalLoopOptions): Promise<void>;
17
+ }
18
+
19
+ const scopedService = new AsyncLocalStorage<GoalDomainService>();
20
+
21
+ function unscopedGoalDomain(): GoalDomainService {
22
+ return {
23
+ evaluateGoal: (options) => evaluateGoal(options),
24
+ runGoalLoop: (options) => runGoalLoop(options),
25
+ };
26
+ }
27
+
28
+ /** Resolves the scoped goal domain service, or the unscoped module-path
29
+ * fallback outside a composed agent scope. */
30
+ export function getGoalDomain(): GoalDomainService {
31
+ return scopedService.getStore() ?? unscopedGoalDomain();
32
+ }
33
+
34
+ /** Seeds a service for the callback duration. `enterAgentScope` seeds the
35
+ * composed agent scope's service here when the goal domain plugin is
36
+ * installed. */
37
+ export function withGoalDomain<T>(service: GoalDomainService, callback: () => T): T {
38
+ return scopedService.run(service, callback);
39
+ }
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ export const capekPackagePhase = 9 as const;
2
+
3
+ export type { ToolOutputArtifactPage } from './storage/contracts';
4
+ export type {
5
+ RuntimeAudience,
6
+ RuntimeDelivery,
7
+ RuntimeEvent,
8
+ RuntimeEventContext,
9
+ RuntimeEventSink,
10
+ } from './runtime/events';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Public ask authority entrypoint (`@capekai/core/ask-authority`).
3
+ *
4
+ * Exposes exactly the pending-ask permission identities the Jean2 server
5
+ * consumes at the wire boundary: response resolution, pending-ask session
6
+ * and authority lookup, and the fixed ask timeout. Every symbol resolves to
7
+ * the owning module's identity, identical to the compatibility barrel.
8
+ * S8a/S8d: this is the single authority surface for pending-ask
9
+ * resolution; the server consumes it only through the ask-authority
10
+ * adapter.
11
+ */
12
+
13
+ export {
14
+ ASK_TIMEOUT,
15
+ createAskApi,
16
+ getAuthorityForPendingAsk,
17
+ getSessionIdForPendingAsk,
18
+ hasPendingAsk,
19
+ rejectPendingAsksByToolCallId,
20
+ resolveAsk,
21
+ } from '../permission/ask-user-api';
22
+ export {
23
+ getPendingRequestsByRootSession,
24
+ hasPendingWaiter,
25
+ rejectPermission,
26
+ rejectPermissionsBySession,
27
+ requestPermission,
28
+ resolvePermission,
29
+ } from '../permission/permission-request-manager';
@@ -0,0 +1,44 @@
1
+ /** Public package-owned generic composition entrypoint. */
2
+
3
+ export {
4
+ createAgentScope,
5
+ createComposition,
6
+ createProcessScope,
7
+ enterAgentScope,
8
+ facadeProcessPlugins,
9
+ type Composition,
10
+ } from '../plugins/compose';
11
+ export type {
12
+ AgentScopeHandle,
13
+ CapekPlugin,
14
+ ProcessScopeHandle,
15
+ } from '../plugins/compose';
16
+ export {
17
+ capekAgentDriverKey,
18
+ capekContextAssemblerKey,
19
+ capekContextSourcesKey,
20
+ capekInstalledToolRegistryKey,
21
+ capekProviderOverridesKey,
22
+ capekProviderRegistryKey,
23
+ capekRuntimeConfigurationKey,
24
+ capekRuntimeHostKey,
25
+ capekSandboxControllerKey,
26
+ capekSchedulerHostKey,
27
+ capekSessionSearchHostKey,
28
+ capekStorageKey,
29
+ capekToolResolverKey,
30
+ capekWorkspaceToolDiscoveryKey,
31
+ } from '../plugins/service-keys';
32
+ export {
33
+ C2_PROCESS_KEYS,
34
+ C2_REQUIRED_AGENT_KEYS,
35
+ C2_SERVICE_KEYS,
36
+ } from '../plugins/service-keys';
37
+ export type {
38
+ InstalledToolRegistryContract,
39
+ ProviderRegistryContract,
40
+ } from '../plugins/service-keys';
41
+ export type {
42
+ ContextAssembler,
43
+ ContextAssemblyData,
44
+ } from '../plugins/service-keys';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Public configuration entrypoint (`@capekai/core/configuration`).
3
+ *
4
+ * Exposes exactly the runtime-configuration identities the Jean2 server
5
+ * consumes through its runtime-configuration adapter: the configuration
6
+ * accessors and the API-key resolution. Every symbol resolves to the owning
7
+ * module's identity, identical to the compatibility barrel. S8a.
8
+ */
9
+
10
+ export {
11
+ configureRuntimeConfiguration,
12
+ getApiKeyForProvider,
13
+ getRuntimeConfiguration,
14
+ withRuntimeConfiguration,
15
+ } from '../configuration/runtime';
16
+ export type { RuntimeConfiguration } from '../configuration/contracts';
17
+ export { createDefaultRuntimeConfiguration } from '../configuration/defaults';
18
+ export {
19
+ createSingleModelConfiguration,
20
+ resolveModelSpecifier,
21
+ type ModelSpecifierSelection,
22
+ } from '../configuration/single-model';
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Public execution entrypoint (`@capekai/core/execution`).
3
+ *
4
+ * Exposes exactly the agent execution identities the Jean2 server consumes
5
+ * through its execution port: chat, edit, title regeneration, compaction,
6
+ * fork, revert, and the interrupt manager. Every symbol resolves to the
7
+ * owning module's identity, identical to the compatibility barrel. S8a.
8
+ */
9
+
10
+ export {
11
+ handleChat,
12
+ handleSessionEditMessage,
13
+ regenerateSessionTitle,
14
+ type RuntimeRequestContext,
15
+ } from '../core/chat-handler';
16
+ export { interruptManager } from '../core/interrupt';
17
+ export { forkSession } from '../core/fork';
18
+ export { revertToStep } from '../core/revert';
19
+ export {
20
+ executeCompaction,
21
+ isCompactionActive,
22
+ } from '../compaction/executor';
23
+ export {
24
+ getDefaultCompactionPolicy,
25
+ resolveCompactionPolicy,
26
+ } from '../compaction/policy';
27
+ export {
28
+ buildConversationText,
29
+ createCompactionTrigger,
30
+ estimateToolOutputSize,
31
+ formatOutput,
32
+ persistCompactionFailure,
33
+ processCompactionTask,
34
+ } from '../compaction/task';
35
+ export type { GenerateSummaryFn } from '../compaction/contracts';
36
+ export {
37
+ reconcileAllSessionsCompaction as reconcileAllSessionsCompactionWithDeps,
38
+ reconcileSessionCompaction as reconcileSessionCompactionWithDeps,
39
+ type CompactionRecoveryDeps,
40
+ } from '../compaction/recovery';
41
+ export type { RuntimeEventSink } from '../runtime/events';
42
+
43
+ // S8f test-surface additions: the execution-domain identities the server
44
+ // tests consume (agent stream loop, retry policy, goal evaluation, workflow
45
+ // orchestration, subagent policy, tool building, message/part/model utils,
46
+ // error classification, structured output, stream configuration, tool
47
+ // capabilities, and the fixed legacy system-message builder). Each symbol
48
+ // keeps its owning module's identity, identical to the compatibility barrel.
49
+ export type { ChatOptions } from '../core/agent';
50
+ export {
51
+ createRetryCircuitState,
52
+ withRetryCircuitState,
53
+ } from '../retry/policy';
54
+ export {
55
+ streamChatWithRetry,
56
+ type StreamChatEvent,
57
+ type StreamChatFn,
58
+ } from '../retry/stream-chat';
59
+ export { buildContinuationMessage } from '../goals/evaluator';
60
+ export { runOrchestratorSession } from '../workflow/orchestrator-session';
61
+ export {
62
+ collectSubagentAncestry,
63
+ evaluateSubagentTarget,
64
+ getSubagentResumeError,
65
+ isSubagentSpawningDisabled,
66
+ isValidSubagentPreconfig,
67
+ isValidSubagentTargetPreconfig,
68
+ } from '../subagent/policy';
69
+ export {
70
+ buildAiSdkTools,
71
+ type BuildToolsOptions,
72
+ } from '../core/build-tools';
73
+ export { convertToAiSdkMessages } from '../core/message-utils';
74
+ export {
75
+ createStepPart,
76
+ isFilePart,
77
+ isImagePart,
78
+ isTextPart,
79
+ isToolPart,
80
+ parseToolInput,
81
+ } from '../core/part-utils';
82
+ export { getModelWithMetadata } from '../core/model-utils';
83
+ export { createErrorEvent } from '../core/error-handling';
84
+ export {
85
+ classifyApiError,
86
+ withRetry,
87
+ ApiErrorType,
88
+ type ClassifiedError,
89
+ } from '../utils/errors';
90
+ export {
91
+ buildSchemaPromptInstruction,
92
+ extractJsonFromText,
93
+ } from '../core/structured-output';
94
+ export {
95
+ resolveToolExecutionScopes,
96
+ isToolAllowedInContext,
97
+ } from '../core/tool-capabilities';
98
+ export { buildStreamConfig } from '../core/stream/stream-config';
99
+ export {
100
+ createStreamHandlers,
101
+ type StreamHandlerContext,
102
+ } from '../core/stream-handlers';
103
+ export {
104
+ createStepCallbacks,
105
+ type StepCallbacksContext,
106
+ } from '../core/step-handlers';
107
+ export { buildSystemMessage } from '../plugins/legacy-system-message';
108
+ export { createWorkspaceCapability } from '../workspace/policy';
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Public host-composition entrypoint (`@capekai/core/hosts`).
3
+ *
4
+ * Exposes exactly the process-global host configuration the Jean2 server
5
+ * bootstrap installs: runtime host bindings, session-search and scheduler
6
+ * hosts, and context sources. Every symbol resolves to the owning module's
7
+ * identity, identical to the compatibility barrel. S8a.
8
+ */
9
+
10
+ export {
11
+ configureRuntimeHost,
12
+ getRuntimeHost,
13
+ withRuntimeHost,
14
+ type AskBroadcastFn,
15
+ type BroadcastFn,
16
+ type BroadcastSessionFn,
17
+ type CreateGrantParams,
18
+ type DeliveryHost,
19
+ type InteractionHost,
20
+ type MatchGrantParams,
21
+ type PendingAskRecord,
22
+ type PermissionRequestStatus,
23
+ type RuntimeHost,
24
+ type SandboxBindings,
25
+ type TitleHost,
26
+ type WorkspaceCapabilityBindings,
27
+ } from '../runtime/host';
28
+ export { createStandaloneHost } from '../runtime/standalone-host';
29
+ export { installSchedulerToolFallback } from '../plugins/scheduler-domain';
30
+ export { installSessionSearchToolFallback } from '../plugins/session-search-domain';
31
+ export { installTaskToolFallback } from '../plugins/subagent-domain';
32
+ export { installWorkflowToolFallback } from '../plugins/workflow-domain';
33
+ export { installMemoryToolFallback } from '../plugins/memory-domain';
34
+ export { installSkillsToolFallback } from '../plugins/skills-domain';
35
+ export { setDefaultContextAssembler } from '../context/assembler';
36
+ export { fixedBuilderContextAssembler } from '../plugins/legacy-system-message';
37
+ export { configureSessionSearchHost, getSessionSearchHost, type SessionSearchHost } from '../session-search/host';
38
+ export { configureSchedulerHost, getSchedulerHost, type SchedulerHost } from '../scheduler/host';
39
+ export { executeSchedulerTool } from '../scheduler/scheduler-tool';
40
+ export { executeSessionSearchTool } from '../session-search/session-search-tool';
41
+ export { executeSkillManageTool, buildSkillManageToolDescription } from '../skills/skill-manage-tool';
42
+ export { executeMemoryTool } from '../memory/memory-tool';
43
+ export {
44
+ addEntry,
45
+ entriesToContent,
46
+ formatEntriesForDisplay,
47
+ formatMemorySection,
48
+ listEntries,
49
+ loadMemoryFile,
50
+ loadMemoryInstructions,
51
+ MEMORY_CHAR_LIMIT,
52
+ parseEntries,
53
+ removeEntry,
54
+ replaceEntry,
55
+ USER_CHAR_LIMIT,
56
+ } from '../memory/registry';
57
+ export {
58
+ configureAgentSource,
59
+ configureInstructionSource,
60
+ configurePreconfigSource,
61
+ type AgentSource,
62
+ type InstructionSource,
63
+ type PreconfigSource,
64
+ } from '../context/sources';
@@ -0,0 +1,71 @@
1
+ /** Public composition plugin inventory for embedding hosts. */
2
+
3
+ export {
4
+ contextSourcesValuePlugin,
5
+ installedToolRegistryValuePlugin,
6
+ providerOverridesValuePlugin,
7
+ providerRegistryValuePlugin,
8
+ runtimeConfigurationValuePlugin,
9
+ runtimeHostValuePlugin,
10
+ sandboxControllerValuePlugin,
11
+ schedulerHostValuePlugin,
12
+ sessionSearchHostValuePlugin,
13
+ storageValuePlugin,
14
+ toolResolverValuePlugin,
15
+ workspaceToolDiscoveryValuePlugin,
16
+ } from '../plugins/value-plugins';
17
+ export { retryPolicyPlugin } from '../plugins/retry-policy';
18
+ export { compactionPolicyPlugin } from '../plugins/compaction-policy';
19
+ export { permissionPolicyPlugin } from '../plugins/permission-policy';
20
+ export { workspacePolicyPlugin } from '../plugins/workspace-policy';
21
+ export { toolOutputPolicyPlugin } from '../plugins/tool-output-policy';
22
+ export { defaultAgentDriverPlugin } from '../plugins/default-agent-driver';
23
+ export { createContextSectionsPlugin } from '../plugins/context-sections';
24
+ export { orchestratorSessionProviderPlugin } from '../plugins/orchestrator-session';
25
+ export {
26
+ CURRENT_SESSION_SEARCH_DOMAIN_PLUGIN_ID,
27
+ sessionSearchDomainPlugin,
28
+ } from '../plugins/session-search-domain';
29
+ export {
30
+ CURRENT_SCHEDULER_DOMAIN_PLUGIN_ID,
31
+ schedulerDomainPlugin,
32
+ } from '../plugins/scheduler-domain';
33
+ export {
34
+ CURRENT_SUBAGENT_DOMAIN_PLUGIN_ID,
35
+ subagentDomainPlugin,
36
+ } from '../plugins/subagent-domain';
37
+ export {
38
+ CURRENT_WORKFLOW_DOMAIN_PLUGIN_ID,
39
+ workflowDomainPlugin,
40
+ } from '../plugins/workflow-domain';
41
+ export {
42
+ CURRENT_GOAL_DOMAIN_PLUGIN_ID,
43
+ goalDomainPlugin,
44
+ } from '../plugins/goal-domain';
45
+ export {
46
+ CURRENT_MEMORY_DOMAIN_PLUGIN_ID,
47
+ memoryDomainPlugin,
48
+ } from '../plugins/memory-domain';
49
+ export {
50
+ CURRENT_SKILLS_DOMAIN_PLUGIN_ID,
51
+ skillsDomainPlugin,
52
+ } from '../plugins/skills-domain';
53
+ export {
54
+ FACADE_AGENT_PLUGIN_IDS,
55
+ FACADE_PROCESS_PLUGIN_IDS,
56
+ createFacadeAgentPlugins,
57
+ facadeProcessPlugins,
58
+ type FacadeScopeValues,
59
+ } from '../plugins/facade-plugins';
60
+ export { loadedToolsPlugin } from '../plugins/loaded-tools';
61
+ export { createContributedToolResolver } from '../plugins/tool-catalog';
62
+ export {
63
+ getContextSources,
64
+ } from '../context/sources';
65
+ export { getRuntimeConfiguration } from '../configuration/runtime';
66
+ export { getRuntimeHost } from '../runtime/host';
67
+ export { getWorkspaceToolDiscovery } from '../tools/tool-source';
68
+ export { getSandboxController } from '../sandbox/controller';
69
+ export { getStorage } from '../storage/runtime';
70
+ export { getSessionSearchHost } from '../session-search/host';
71
+ export { getSchedulerHost } from '../scheduler/host';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Public providers entrypoint (`@capekai/core/providers`).
3
+ *
4
+ * Exposes exactly the provider-registry identities the Jean2 server
5
+ * consumes: registration, lookup, status, connect/disconnect, model
6
+ * factories, and the AI SDK model adapters (title generation, OpenAI
7
+ * Responses construction, capability tool conversion). Every symbol
8
+ * resolves to the owning module's identity, identical to the
9
+ * compatibility barrel. S8a.
10
+ */
11
+
12
+ export {
13
+ connectProvider,
14
+ createModelForProvider,
15
+ disconnectProvider,
16
+ getConnectableProviders,
17
+ getProvider,
18
+ getProviderStatus,
19
+ registerProvider,
20
+ withProviderOverrides,
21
+ } from '../providers/registry';
22
+ export type { ConnectableProvider } from '../providers/types';
23
+ export type { TokenResponse } from '../providers/types';
24
+ export type { ModelFactoryOptions } from '../providers/types';
25
+ export {
26
+ createCapabilityTool,
27
+ createOpenAiResponsesModel,
28
+ runTextModel,
29
+ type CapabilityTool,
30
+ } from '../adapters/ai-sdk';
31
+ export { findProviderFromModel } from '../core/provider-utils';
32
+ export { executeChildSession } from '../subagent/child-session';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Public sandbox entrypoint (`@capekai/core/sandbox`).
3
+ *
4
+ * Exposes exactly the sandbox identities the Jean2 server consumes: the
5
+ * process controller, provider registration, and the wire message types
6
+ * for auto-responder rules and responses. Every symbol resolves to the
7
+ * owning module's identity, identical to the compatibility barrel. S8a.
8
+ */
9
+
10
+ export { SandboxController, sandboxController } from '../sandbox/controller';
11
+ export { SandboxProvider } from '../sandbox/provider';
12
+ export { SandboxLanguageModel } from '../sandbox/model';
13
+ export type {
14
+ AutoResponderRule,
15
+ LlmCallContext,
16
+ SandboxControlEvent,
17
+ SandboxRespondMessage,
18
+ SandboxResponse,
19
+ } from '../sandbox/types';
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Public tools entrypoint (`@capekai/core/tools`).
3
+ *
4
+ * Exposes exactly the tool-registry and artifact identities the Jean2
5
+ * server consumes: scanning, listing, tool-path configuration, the tool
6
+ * source lifecycle, artifact download/verification/extraction, and install
7
+ * manifests. Every symbol resolves to the owning module's identity,
8
+ * identical to the compatibility barrel. S8a.
9
+ */
10
+
11
+ export {
12
+ clearCache,
13
+ configureToolsPath,
14
+ getInstalledTool,
15
+ getTool,
16
+ hasUnscannedToolCache,
17
+ listInstalledTools,
18
+ listTools,
19
+ loadToolModule,
20
+ scanTools,
21
+ } from '../tools/registry';
22
+ export type { ToolRegistryResolver } from '../tools/registry';
23
+ export { RETRIEVE_TOOL_OUTPUT_NAME } from '../tool-output/policy';
24
+ export {
25
+ configureWorkspaceToolDiscovery,
26
+ getWorkspaceToolDiscovery,
27
+ type WorkspaceToolDiscovery,
28
+ } from '../tools/tool-source';
29
+ export {
30
+ ArtifactError,
31
+ downloadArtifact,
32
+ extractArtifact,
33
+ validateArtifactStructure,
34
+ verifyChecksum,
35
+ } from '../tools/tool-artifact';
36
+ export {
37
+ getManifestPath,
38
+ readInstallManifest,
39
+ writeInstallManifest,
40
+ type InstallManifest,
41
+ } from '../tools/install-manifest';
42
+ export {
43
+ stripVisualization,
44
+ extractVisualization,
45
+ } from '../utils/strip-visualization';
46
+ export {
47
+ listDomainToolFallbackDefinitions,
48
+ } from '../runtime/domain-tool-source';