index.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /**
  2. * `@mavis/goal` —— codex-style Thread Goal primitives.
  3. *
  4. * This subpath is **IO-free** by design:
  5. * - 4-state status model + objective validation (`types.ts`)
  6. * - Pluggable persistence port (`store-port.ts`)
  7. * - 3 LLM-facing tool defs + impls (`tool-defs.ts` / `tool-impls.ts`)
  8. * - Continuation prompt renderer (`continuation.ts`)
  9. *
  10. * The model-facing `update_goal` surface separates host-settled complete /
  11. * blocked proposals from host-authorized token-budget edits. Neither path can
  12. * overwrite a concurrent user mutation because durable writes remain guarded
  13. * by the Host.
  14. *
  15. * Host packages wire a concrete `ThreadGoalStore` implementation
  16. * (`local-runtime/SqliteThreadGoalStore`, etc.) into the tool impls
  17. * and the HTTP API.
  18. *
  19. * Tool name convention is kept verbatim from codex (`create_goal` /
  20. * `update_goal` / `get_goal`) so models trained against codex tooling
  21. * recognize them without retraining.
  22. */
  23. export type {
  24. GoalTurnSignal,
  25. GoalTurnBinding,
  26. ThreadGoalAttachment,
  27. ThreadGoalKickoffState,
  28. LastVerificationV1,
  29. LastWorkerProposalV1,
  30. ThreadGoalFailureClass,
  31. ThreadGoalExecutionWait,
  32. ThreadGoalState,
  33. ThreadGoalSignalCollectionResult,
  34. ThreadGoalStatus,
  35. ThreadGoalStatusReason,
  36. ThreadGoalWaitReason,
  37. ThreadGoalVerification,
  38. } from './types.js';
  39. export {
  40. CONTINUATION_STATUSES,
  41. THREAD_GOAL_STATUSES,
  42. THREAD_GOAL_STATUS_REASONS,
  43. THREAD_GOAL_WAIT_REASONS,
  44. THREAD_GOAL_VERIFICATIONS,
  45. TERMINAL_STATUSES,
  46. isContinuationStatus,
  47. isTerminalStatus,
  48. validateThreadGoalObjective,
  49. } from './types.js';
  50. export type {
  51. ThreadGoalBoundStoreOperations,
  52. ThreadGoalBoundUsageDelta,
  53. ThreadGoalBoundUsageResult,
  54. ThreadGoalBoundUsageStaleReason,
  55. ThreadGoalBudgetCheckResult,
  56. ThreadGoalBudgetDimension,
  57. ThreadGoalBudgetLimits,
  58. ThreadGoalBreakerInput,
  59. ThreadGoalBreakerCause,
  60. ThreadGoalBreakerResult,
  61. ThreadGoalBreakerStaleReason,
  62. ThreadGoalToolActivity,
  63. ThreadGoalCreateInput,
  64. ThreadGoalDecisionResult,
  65. ThreadGoalDecisionStaleReason,
  66. ThreadGoalPatchInput,
  67. ThreadGoalRecordVerificationInput,
  68. ThreadGoalSettleBoundTurnInput,
  69. ThreadGoalStore,
  70. ThreadGoalWorkerProposalInput,
  71. } from './store-port.js';
  72. export {
  73. ThreadGoalAlreadyExistsError,
  74. ThreadGoalBudgetLimitedError,
  75. ThreadGoalEpochConflictError,
  76. ThreadGoalObjectiveConflictError,
  77. ThreadGoalStatusConflictError,
  78. ThreadGoalTokenBudgetExhaustedError,
  79. } from './store-port.js';
  80. export {
  81. DEFAULT_GOAL_CONTINUATION_TEMPLATE,
  82. DEFAULT_GOAL_RECOVERY_TEMPLATE,
  83. DEFAULT_GOAL_RECOVERY_TERMINAL_AUDIT_TEMPLATE,
  84. DEFAULT_GOAL_TERMINAL_AUDIT_TEMPLATE,
  85. renderKickoffPrompt,
  86. renderContinuationPrompt,
  87. renderNudgePrompt,
  88. renderRecoveryPrompt,
  89. renderRecoveryTerminalAuditPrompt,
  90. renderTerminalAuditPrompt,
  91. } from './continuation.js';
  92. export {
  93. DEFAULT_OBJECTIVE_UPDATED_TEMPLATE,
  94. renderObjectiveUpdatedPrompt,
  95. } from './objective-updated.js';
  96. export { DEFAULT_BUDGET_LIMIT_TEMPLATE, renderBudgetLimitPrompt } from './budget-limit.js';
  97. export { fingerprintThreadGoalReply } from './reply-fingerprint.js';
  98. export { digestThreadGoalObjective } from './objective-digest.js';
  99. export {
  100. boundVerificationTranscript,
  101. type TranscriptWindowResult,
  102. } from './verification/transcript-window.js';
  103. export type {
  104. TranscriptWindow,
  105. TranscriptWindowReader,
  106. VerificationEvidence,
  107. VerificationEvidenceMode,
  108. VerificationAttempt,
  109. VerificationBackend,
  110. VerificationHostContext,
  111. VerificationDispatchFailureCode,
  112. VerificationResult,
  113. VerificationTraceRef,
  114. VerificationUsage,
  115. VerificationVerdict,
  116. VerifierPort,
  117. } from './verification/verifier-port.js';
  118. export {
  119. assembleVerificationEvidence,
  120. MAX_EVALUATOR_TAIL_CHARS,
  121. MAX_EVALUATOR_TAIL_MESSAGES,
  122. MAX_SUBAGENT_VERIFICATION_PROMPT_CHARS,
  123. MAX_TRANSCRIPT_FALLBACK_CHARS,
  124. MAX_TRANSCRIPT_FALLBACK_MESSAGES,
  125. MAX_VERIFICATION_BRIEF_CHARS,
  126. } from './verification/evidence-brief.js';
  127. export { VerificationDispatchError } from './verification/verifier-port.js';
  128. export {
  129. createEvaluatorVerifierAdapter,
  130. evaluatorVerdictJsonSchema,
  131. EvaluatorModelCallError,
  132. parseVerificationVerdictJson,
  133. } from './verification/evaluator-adapter.js';
  134. export { createSubagentVerifierAdapter } from './verification/subagent.js';
  135. export { verificationModeForRoute } from './verification/verification-policy.js';
  136. export type {
  137. SubagentModelVerdict,
  138. SubagentVerificationExecutionPort,
  139. SubagentVerificationRunInput,
  140. SubagentVerificationRunResult,
  141. SubagentVerifierAdapterOptions,
  142. } from './verification/subagent.js';
  143. export type {
  144. EvaluatorAdapterOptions,
  145. EvaluatorModelCallFailureCode,
  146. EvaluatorModelCallInput,
  147. EvaluatorModelCallResult,
  148. EvaluatorModelPort,
  149. EvaluatorRouteIdentity,
  150. EvaluatorRouteKind,
  151. } from './verification/evaluator-adapter.js';
  152. export {
  153. INTERNAL_CONTEXT_OPEN_PREFIX,
  154. INTERNAL_CONTEXT_CLOSE_TAG,
  155. wrapInternalContext,
  156. isInternalContextMessage,
  157. } from './internal-context-fragment.js';
  158. export {
  159. CreateGoalToolDef,
  160. UpdateGoalToolDef,
  161. GetGoalToolDef,
  162. hasUpdateGoalTokenBudgetIntent,
  163. resolveUpdateGoalMode,
  164. type UpdateGoalResolvedMode,
  165. type CreateGoalToolInput,
  166. type UpdateGoalToolInput,
  167. type GetGoalToolInput,
  168. } from './tool-defs.js';
  169. export { CreateGoalTool, UpdateGoalTool, GetGoalTool } from './tool-impls.js';
  170. export type {
  171. ThreadGoalSignalCollector,
  172. ThreadGoalToolMutationListener,
  173. ThreadGoalTokenBudgetMutationInput,
  174. ThreadGoalTokenBudgetMutationPort,
  175. ThreadGoalTokenBudgetMutationResult,
  176. } from './tool-impls.js';