@yielded/agent 0.1.0-beta.174 → 0.1.0-beta.175

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 (175) hide show
  1. package/dist/{Admin-BHmp2V9p.d.mts → Admin-Qa3I1oA5.d.mts} +38 -7
  2. package/dist/{AgentRuntime-BD3ZHAMq.d.mts → AgentRuntime-CHDyRbSf.d.mts} +3 -3
  3. package/dist/{AgentRuntime-B6qZlD3f.mjs → AgentRuntime-DaDKMasp.mjs} +123 -114
  4. package/dist/AgentRuntime-DaDKMasp.mjs.map +1 -0
  5. package/dist/{Digest-EpeqWEdv.mjs → Digest-C3EODOee.mjs} +2 -2
  6. package/dist/{Digest-EpeqWEdv.mjs.map → Digest-C3EODOee.mjs.map} +1 -1
  7. package/dist/{DurableAgentRuntime-CBBjRNJN.mjs → DurableAgentRuntime-CPlw5_7e.mjs} +161 -85
  8. package/dist/DurableAgentRuntime-CPlw5_7e.mjs.map +1 -0
  9. package/dist/{EventSource-C9aaJaXT.d.mts → EventSource-BTu68yDW.d.mts} +2 -2
  10. package/dist/InMemory.d.mts +2 -2
  11. package/dist/{MessageDelivery-BGDm-c46.d.mts → MessageDelivery-DjAZJ4Fd.d.mts} +4 -4
  12. package/dist/{MessagingHost-CRUK4JBi.mjs → MessagingHost-CZCyrnvJ.mjs} +27 -26
  13. package/dist/MessagingHost-CZCyrnvJ.mjs.map +1 -0
  14. package/dist/{PreparedInputAdmission-BvDqlgiP.d.mts → PreparedInputAdmission-wgY4JMZY.d.mts} +3 -3
  15. package/dist/{Records-BiuJDWNe.mjs → Records-DzL4Kbtw.mjs} +2 -2
  16. package/dist/{Records-BiuJDWNe.mjs.map → Records-DzL4Kbtw.mjs.map} +1 -1
  17. package/dist/{RunContinuation-CTJ1jGrO.d.mts → RunContinuation-3jB5pULC.d.mts} +10 -4
  18. package/dist/{RunContinuation-4ZATcVLB.mjs → RunContinuation-BiyKJK32.mjs} +74 -40
  19. package/dist/RunContinuation-BiyKJK32.mjs.map +1 -0
  20. package/dist/{RunJournal-CNZqA3Ge.mjs → RunJournal-CPMKcfd0.mjs} +84 -79
  21. package/dist/RunJournal-CPMKcfd0.mjs.map +1 -0
  22. package/dist/{RunStorage-BHjuuERI.mjs → RunStorage-CzutHJBE.mjs} +3 -2
  23. package/dist/RunStorage-CzutHJBE.mjs.map +1 -0
  24. package/dist/{Scheduling-NG8slKdI.mjs → Scheduling-07_dsGED.mjs} +3 -3
  25. package/dist/{Scheduling-NG8slKdI.mjs.map → Scheduling-07_dsGED.mjs.map} +1 -1
  26. package/dist/{Subagent-CTIpnzlB.mjs → Subagent-CexndZSp.mjs} +2 -2
  27. package/dist/{Subagent-CTIpnzlB.mjs.map → Subagent-CexndZSp.mjs.map} +1 -1
  28. package/dist/{Subagent-DKhZA72u.d.mts → Subagent-xhN_aD1r.d.mts} +3 -3
  29. package/dist/{Subscription-BNg9VCRl.d.mts → Subscription-DmIHlOJK.d.mts} +2 -2
  30. package/dist/{SubscriptionInput-BUoXv-_K.d.mts → SubscriptionInput-DgcQhvbe.d.mts} +2 -2
  31. package/dist/{Thread-dk-QiNml.d.mts → Thread-DzdJAY4J.d.mts} +4 -3
  32. package/dist/{ThreadHistory-ByxS8HU1.d.mts → ThreadHistory-KPPBJLJb.d.mts} +12 -2
  33. package/dist/{ThreadImport-CodYoJoa.mjs → ThreadImport-CjlG57vH.mjs} +8 -8
  34. package/dist/{ThreadImport-CodYoJoa.mjs.map → ThreadImport-CjlG57vH.mjs.map} +1 -1
  35. package/dist/{ThreadImport-CMgzttvr.d.mts → ThreadImport-DP-vOk2F.d.mts} +4 -4
  36. package/dist/{ThreadStore-59uDGXul.mjs → ThreadStore-EuUilthA.mjs} +5 -7
  37. package/dist/ThreadStore-EuUilthA.mjs.map +1 -0
  38. package/dist/{ThreadTransfer-3jigUl3g.mjs → ThreadTransfer-DB_zsrtJ.mjs} +4 -4
  39. package/dist/{ThreadTransfer-3jigUl3g.mjs.map → ThreadTransfer-DB_zsrtJ.mjs.map} +1 -1
  40. package/dist/{WorkerAdmission-DDYJdOsU.mjs → WorkerAdmission-eBeXt_mu.mjs} +5 -5
  41. package/dist/{WorkerAdmission-DDYJdOsU.mjs.map → WorkerAdmission-eBeXt_mu.mjs.map} +1 -1
  42. package/dist/{agent-registration-DRbyhAu-.mjs → agent-registration-a6QYaG3h.mjs} +4 -4
  43. package/dist/{agent-registration-DRbyhAu-.mjs.map → agent-registration-a6QYaG3h.mjs.map} +1 -1
  44. package/dist/capabilities/Messaging.mjs +1 -1
  45. package/dist/capabilities/ModelContext.d.mts +1 -1
  46. package/dist/capabilities/RunHooks.d.mts +1 -1
  47. package/dist/capabilities/Subagent.d.mts +1 -1
  48. package/dist/capabilities/Subagent.mjs +1 -1
  49. package/dist/core/Thread.d.mts +2 -2
  50. package/dist/core/Thread.mjs +5 -3
  51. package/dist/core/Thread.mjs.map +1 -1
  52. package/dist/durable/ActivityStore.mjs +1 -1
  53. package/dist/durable/Admin.d.mts +1 -1
  54. package/dist/durable/Admin.mjs +1 -1
  55. package/dist/durable/AgentRegistration.d.mts +1 -1
  56. package/dist/durable/AgentRegistration.mjs +1 -1
  57. package/dist/durable/Certification.d.mts +1 -1
  58. package/dist/durable/CommittedActivity.d.mts +1 -1
  59. package/dist/durable/CommittedActivity.mjs +3 -3
  60. package/dist/durable/Digest.mjs +1 -1
  61. package/dist/durable/DurableAgentRuntime.d.mts +1 -1
  62. package/dist/durable/DurableAgentRuntime.mjs +2 -2
  63. package/dist/durable/EventSource.d.mts +1 -1
  64. package/dist/durable/EventSource.mjs +1 -1
  65. package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
  66. package/dist/durable/LifecyclePublication.d.mts +1 -1
  67. package/dist/durable/LifecyclePublication.mjs +2 -2
  68. package/dist/durable/MessageDelivery.d.mts +1 -1
  69. package/dist/durable/MessageDelivery.mjs +2 -2
  70. package/dist/durable/MessageDeliveryStoreConformance.d.mts +40 -40
  71. package/dist/durable/MessageDeliveryStoreConformance.mjs +2 -2
  72. package/dist/durable/PersistentHistory.d.mts +2 -2
  73. package/dist/durable/PersistentHistory.mjs +4 -4
  74. package/dist/durable/PreparedInputAdmission.d.mts +1 -1
  75. package/dist/durable/RecordFormat.mjs +1 -1
  76. package/dist/durable/Records.mjs +1 -1
  77. package/dist/durable/Recovery.d.mts +1 -1
  78. package/dist/durable/Recovery.mjs +1 -1
  79. package/dist/durable/RunContinuation.d.mts +2 -2
  80. package/dist/durable/RunContinuation.mjs +3 -3
  81. package/dist/durable/RunJournal.d.mts +2 -2
  82. package/dist/durable/RunJournal.mjs +2 -2
  83. package/dist/durable/RunStorage.d.mts +1 -1
  84. package/dist/durable/RunStorage.mjs +1 -1
  85. package/dist/durable/Schedule.mjs +1 -1
  86. package/dist/durable/ScheduleStoreConformance.mjs +1 -1
  87. package/dist/durable/ScheduleTransition.mjs +1 -1
  88. package/dist/durable/Scheduling.d.mts +1 -1
  89. package/dist/durable/Scheduling.mjs +1 -1
  90. package/dist/durable/SettlementPublisher.d.mts +1 -1
  91. package/dist/durable/SettlementPublisher.mjs +3 -3
  92. package/dist/durable/SqlMemoryStore.mjs +5 -3
  93. package/dist/durable/SqlMemoryStore.mjs.map +1 -1
  94. package/dist/durable/SubmissionLedger.d.mts +1 -1
  95. package/dist/durable/SubmissionLedger.mjs +7 -3
  96. package/dist/durable/SubmissionLedger.mjs.map +1 -1
  97. package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
  98. package/dist/durable/SubmissionLedgerConformance.mjs +6 -6
  99. package/dist/durable/SubmissionStatus.d.mts +1 -1
  100. package/dist/durable/Subscription.d.mts +1 -1
  101. package/dist/durable/Subscription.mjs +2 -2
  102. package/dist/durable/SubscriptionInput.d.mts +1 -1
  103. package/dist/durable/SubscriptionInput.mjs +2 -2
  104. package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
  105. package/dist/durable/SubscriptionStoreConformance.mjs +1 -1
  106. package/dist/durable/SubscriptionTools.d.mts +2 -2
  107. package/dist/durable/SubscriptionTransition.d.mts +1 -1
  108. package/dist/durable/SubscriptionTransition.mjs +1 -1
  109. package/dist/durable/Subscriptions.d.mts +5 -5
  110. package/dist/durable/Subscriptions.mjs +2 -2
  111. package/dist/durable/ThreadArchiveRange.d.mts +1 -1
  112. package/dist/durable/ThreadArchiveRange.mjs +1 -1
  113. package/dist/durable/ThreadContextHistory.d.mts +1 -1
  114. package/dist/durable/ThreadContextHistory.mjs +2 -2
  115. package/dist/durable/ThreadContextHistoryProjection.mjs +1 -1
  116. package/dist/durable/ThreadImport.d.mts +1 -1
  117. package/dist/durable/ThreadImport.mjs +1 -1
  118. package/dist/durable/ThreadInvariants.d.mts +3 -3
  119. package/dist/durable/ThreadInvariants.mjs +4 -4
  120. package/dist/durable/ThreadProjection.mjs +1 -1
  121. package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
  122. package/dist/durable/ThreadReader.d.mts +1 -1
  123. package/dist/durable/ThreadReader.mjs +1 -1
  124. package/dist/durable/ThreadStore.d.mts +1 -1
  125. package/dist/durable/ThreadStore.mjs +2 -2
  126. package/dist/durable/ThreadStoreConformance.d.mts +1 -1
  127. package/dist/durable/ThreadStoreConformance.mjs +4 -4
  128. package/dist/durable/ThreadTransfer.d.mts +1 -1
  129. package/dist/durable/ThreadTransfer.mjs +1 -1
  130. package/dist/durable/ThreadWork.d.mts +2 -2
  131. package/dist/durable/ThreadWork.mjs +12 -6
  132. package/dist/durable/ThreadWork.mjs.map +1 -1
  133. package/dist/durable/ToolReconciler.mjs +1 -1
  134. package/dist/durable/WakeScheduler.mjs +23 -39
  135. package/dist/durable/WakeScheduler.mjs.map +1 -1
  136. package/dist/durable/WorkerAdmission.d.mts +1 -1
  137. package/dist/durable/WorkerAdmission.mjs +1 -1
  138. package/dist/durable/WorkerHost.d.mts +1 -1
  139. package/dist/engine/AgentRuntime.d.mts +1 -1
  140. package/dist/engine/AgentRuntime.mjs +1 -1
  141. package/dist/engine/MessagingHost.mjs +1 -1
  142. package/dist/engine/Output.mjs +1 -1
  143. package/dist/engine/ThreadHistory.d.mts +1 -1
  144. package/dist/engine/ThreadHistory.mjs +3 -2
  145. package/dist/engine/ThreadHistory.mjs.map +1 -1
  146. package/dist/index.d.mts +12 -12
  147. package/dist/index.mjs +13 -13
  148. package/dist/{output-contract-CMIhu4Cw.mjs → output-contract-DCnLYCdp.mjs} +12 -15
  149. package/dist/{output-contract-CMIhu4Cw.mjs.map → output-contract-DCnLYCdp.mjs.map} +1 -1
  150. package/dist/{run-context-reader-CC7ZD95F.d.mts → run-context-reader-DVhJZ1Qe.d.mts} +2 -2
  151. package/package.json +1 -1
  152. package/src/core/Thread.ts +143 -146
  153. package/src/durable/DurableAgentRuntime.ts +381 -206
  154. package/src/durable/RunContinuation.ts +113 -62
  155. package/src/durable/RunJournal.ts +99 -108
  156. package/src/durable/RunStorage.ts +7 -0
  157. package/src/durable/SqlMemoryStore.ts +8 -6
  158. package/src/durable/SubmissionLedger.ts +7 -0
  159. package/src/durable/ThreadStore.ts +9 -7
  160. package/src/durable/ThreadWork.ts +10 -0
  161. package/src/durable/WakeScheduler.ts +34 -66
  162. package/src/durable/internal/usage-totals.ts +28 -31
  163. package/src/engine/MessagingHost.ts +4 -2
  164. package/src/engine/ThreadHistory.ts +47 -48
  165. package/src/engine/internal/agent-runtime.ts +234 -202
  166. package/src/engine/internal/output-contract.ts +15 -15
  167. package/src/engine/internal/primitive-delta.ts +2 -3
  168. package/src/engine/internal/tool-telemetry.ts +3 -5
  169. package/dist/AgentRuntime-B6qZlD3f.mjs.map +0 -1
  170. package/dist/DurableAgentRuntime-CBBjRNJN.mjs.map +0 -1
  171. package/dist/MessagingHost-CRUK4JBi.mjs.map +0 -1
  172. package/dist/RunContinuation-4ZATcVLB.mjs.map +0 -1
  173. package/dist/RunJournal-CNZqA3Ge.mjs.map +0 -1
  174. package/dist/RunStorage-BHjuuERI.mjs.map +0 -1
  175. package/dist/ThreadStore-59uDGXul.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadHistory.mjs","names":["ConversationStore"],"sources":["../../src/engine/ThreadHistory.ts"],"sourcesContent":["import type { Prompt } from \"effect/ai\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\n\nimport { ThreadId, type RunId } from \"../core/Identifiers.ts\";\nimport { type RunCompleted } from \"../core/RunEvent.ts\";\nimport {\n Store as ConversationStore,\n layerMemory,\n toPrompt,\n type ThreadError,\n} from \"../core/Thread.ts\";\n\n/** A history adapter rejected a read, staged value, or completed Run commit. */\nexport class ThreadHistoryError extends Schema.TaggedError<ThreadHistoryError>()(\n \"ThreadHistoryError\",\n {\n threadId: ThreadId,\n reason: Schema.Literals([\n \"not-found\",\n \"conflict\",\n \"fenced\",\n \"incompatible\",\n \"limit\",\n \"encoding\",\n \"storage\",\n ]),\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/**\n * One Run's history owner. Incremental adapters retain each stageHistory update; on-success\n * adapters stage privately until commit. Before commit, the interpreter\n * finishes run-owned work and closes resources acquired for that Run, then validates the result\n * for run/start.await. Shared model, provider, and client services supplied by an enclosing\n * application Layer remain owned by that application's Scope and may outlive multiple Runs.\n * Commit must succeed before RunCompleted becomes observable. Schema-encoded input is opaque\n * here; the adapter owns its persistence boundary. A failed commit may have reached storage;\n * callers must inspect history before retrying external execution.\n */\nexport interface ThreadHistoryRun {\n readonly prompt: Prompt.Prompt;\n readonly stageInput: (input: unknown) => Effect.Effect<void, ThreadHistoryError>;\n readonly stageHistory: (history: {\n /** Exact source messages; compaction changes only the model view. */\n readonly source: Prompt.Prompt;\n /** Retained context after native compaction, excluding transient recall. */\n readonly modelContext: Prompt.Prompt;\n }) => Effect.Effect<void, ThreadHistoryError>;\n readonly commit: (completed: RunCompleted) => Effect.Effect<void, ThreadHistoryError>;\n}\n\n/**\n * History shared by Runs with the same Thread ID. The default layer retains native messages\n * incrementally in memory for its application Scope, including completed updates before a failure.\n * PersistentHistory.layer from @yielded/agent/persistent-history instead commits successful\n * Runs to an explicit ThreadStore. Durable hosts retain history through their journal hooks.\n * No implementation may retry model or Tool execution or claim interrupted-work recovery.\n */\nexport class ThreadHistory extends Context.Service<\n ThreadHistory,\n {\n readonly retention: \"incremental\" | \"on-success\";\n /** Present only for the in-memory adapter; identifies its exact Store ownership view. */\n readonly memoryStore?: ConversationStore[\"Service\"];\n readonly open: (request: {\n readonly threadId: ThreadId;\n readonly runId: RunId;\n }) => Effect.Effect<ThreadHistoryRun, ThreadHistoryError>;\n readonly load: (threadId: ThreadId) => Effect.Effect<Prompt.Prompt, ThreadHistoryError>;\n }\n>()(\"@effect-agent/engine/ThreadHistory\") {\n /** Bind incremental history to the supplied Thread.Store, including scoped ownership views. */\n static readonly layerFromStore = Layer.effect(\n ThreadHistory,\n Effect.gen(function* () {\n const threads = yield* ConversationStore;\n\n const historyError = (cause: ThreadError): ThreadHistoryError =>\n ThreadHistoryError.make({\n threadId: cause.threadId,\n reason:\n cause._tag === \"ThreadNotFound\"\n ? \"not-found\"\n : cause._tag === \"ThreadLimitExceeded\"\n ? \"limit\"\n : cause._tag === \"ThreadHistoryDiverged\"\n ? \"conflict\"\n : cause._tag === \"ThreadOwnershipError\"\n ? cause.reason === \"closed\"\n ? \"fenced\"\n : \"conflict\"\n : \"encoding\",\n message:\n cause._tag === \"ThreadNotFound\"\n ? \"Thread history is not present in this application Scope\"\n : cause._tag === \"ThreadLimitExceeded\"\n ? `In-memory history exceeds the ${cause.limit} limit of ${cause.limitValue}`\n : cause.message,\n cause,\n });\n\n return ThreadHistory.of({\n retention: \"incremental\",\n memoryStore: threads,\n load: (threadId) =>\n threads.snapshot(threadId).pipe(Effect.map(toPrompt), Effect.mapError(historyError)),\n open: Effect.fnUntraced(function* ({ threadId, runId }) {\n const snapshot = yield* threads.create(threadId).pipe(Effect.mapError(historyError));\n\n return {\n prompt: toPrompt(snapshot),\n stageInput: () => Effect.void,\n stageHistory: ({ source }) =>\n threads\n .recordHistory(threadId, runId, source)\n .pipe(Effect.asVoid, Effect.mapError(historyError)),\n commit: () =>\n threads.snapshot(threadId).pipe(Effect.asVoid, Effect.mapError(historyError)),\n };\n }),\n });\n }),\n );\n\n /** Retain history for the application Scope, within message and host capacity. Separate Layer builds own separate stores. */\n static readonly layer = ThreadHistory.layerFromStore.pipe(Layer.provideMerge(layerMemory));\n}\n\n/** Retain in-memory conversation history for the application Scope. */\nexport const layer = ThreadHistory.layer;\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAa,qBAAb,cAAwC,OAAO,YAAgC,CAAC,CAC9E,sBACA;CACE,UAAU;CACV,QAAQ,OAAO,SAAS;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CACF,CAAC,CAAC,CAAC;;;;;;;;AA+BH,IAAa,gBAAb,MAAa,sBAAsB,QAAQ,QAYzC,CAAC,CAAC,oCAAoC,CAAC,CAAC;;CAExC,OAAgB,iBAAiB,MAAM,OACrC,eACA,OAAO,IAAI,aAAa;EACtB,MAAM,UAAU,OAAOA;EAEvB,MAAM,gBAAgB,UACpB,mBAAmB,KAAK;GACtB,UAAU,MAAM;GAChB,QACE,MAAM,SAAS,mBACX,cACA,MAAM,SAAS,wBACb,UACA,MAAM,SAAS,0BACb,aACA,MAAM,SAAS,yBACb,MAAM,WAAW,WACf,WACA,aACF;GACZ,SACE,MAAM,SAAS,mBACX,4DACA,MAAM,SAAS,wBACb,iCAAiC,MAAM,MAAM,YAAY,MAAM,eAC/D,MAAM;GACd;EACF,CAAC;EAEH,OAAO,cAAc,GAAG;GACtB,WAAW;GACX,aAAa;GACb,OAAO,aACL,QAAQ,SAAS,QAAQ,CAAC,CAAC,KAAK,OAAO,IAAI,QAAQ,GAAG,OAAO,SAAS,YAAY,CAAC;GACrF,MAAM,OAAO,WAAW,WAAW,EAAE,UAAU,SAAS;IACtD,MAAM,WAAW,OAAO,QAAQ,OAAO,QAAQ,CAAC,CAAC,KAAK,OAAO,SAAS,YAAY,CAAC;IAEnF,OAAO;KACL,QAAQ,SAAS,QAAQ;KACzB,kBAAkB,OAAO;KACzB,eAAe,EAAE,aACf,QACG,cAAc,UAAU,OAAO,MAAM,CAAC,CACtC,KAAK,OAAO,QAAQ,OAAO,SAAS,YAAY,CAAC;KACtD,cACE,QAAQ,SAAS,QAAQ,CAAC,CAAC,KAAK,OAAO,QAAQ,OAAO,SAAS,YAAY,CAAC;IAChF;GACF,CAAC;EACH,CAAC;CACH,CAAC,CACH;;CAGA,OAAgB,QAAQ,cAAc,eAAe,KAAK,MAAM,aAAa,WAAW,CAAC;AAC3F;;AAGA,MAAa,QAAQ,cAAc"}
1
+ {"version":3,"file":"ThreadHistory.mjs","names":["ConversationStore"],"sources":["../../src/engine/ThreadHistory.ts"],"sourcesContent":["import type { Prompt } from \"effect/ai\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\n\nimport { ThreadId, type RunId } from \"../core/Identifiers.ts\";\nimport { type RunCompleted } from \"../core/RunEvent.ts\";\nimport {\n Store as ConversationStore,\n layerMemory,\n toPrompt,\n type ThreadError,\n} from \"../core/Thread.ts\";\n\n/** A history adapter rejected a read, staged value, or completed Run commit. */\nexport class ThreadHistoryError extends Schema.TaggedError<ThreadHistoryError>()(\n \"ThreadHistoryError\",\n {\n threadId: ThreadId,\n reason: Schema.Literals([\n \"not-found\",\n \"conflict\",\n \"fenced\",\n \"incompatible\",\n \"limit\",\n \"encoding\",\n \"storage\",\n ]),\n message: Schema.String,\n cause: Schema.optionalKey(Schema.Defect()),\n },\n) {}\n\n/**\n * One Run's history owner. Incremental adapters retain each stageHistory update; on-success\n * adapters stage privately until commit. Before commit, the interpreter\n * finishes run-owned work and closes resources acquired for that Run, then validates the result\n * for run/start.await. Shared model, provider, and client services supplied by an enclosing\n * application Layer remain owned by that application's Scope and may outlive multiple Runs.\n * Commit must succeed before RunCompleted becomes observable. Schema-encoded input is opaque\n * here; the adapter owns its persistence boundary. A failed commit may have reached storage;\n * callers must inspect history before retrying external execution.\n */\nexport interface ThreadHistoryRun {\n readonly prompt: Prompt.Prompt;\n readonly stageInput: (input: unknown) => Effect.Effect<void, ThreadHistoryError>;\n readonly stageHistory: (history: {\n /** Exact source messages; compaction changes only the model view. */\n readonly source: Prompt.Prompt;\n /** Retained context after native compaction, excluding transient recall. */\n readonly modelContext: Prompt.Prompt;\n }) => Effect.Effect<void, ThreadHistoryError>;\n readonly commit: (completed: RunCompleted) => Effect.Effect<void, ThreadHistoryError>;\n}\n\n/**\n * History shared by Runs with the same Thread ID. The default layer retains native messages\n * incrementally in memory for its application Scope, including completed updates before a failure.\n * PersistentHistory.layer from @yielded/agent/persistent-history instead commits successful\n * Runs to an explicit ThreadStore. Durable hosts retain history through their journal hooks.\n * No implementation may retry model or Tool execution or claim interrupted-work recovery.\n */\nexport class ThreadHistory extends Context.Service<\n ThreadHistory,\n {\n readonly retention: \"incremental\" | \"on-success\";\n /** Present only for the in-memory adapter; identifies its exact Store ownership view. */\n readonly memoryStore?: ConversationStore[\"Service\"];\n readonly open: (request: {\n readonly threadId: ThreadId;\n readonly runId: RunId;\n }) => Effect.Effect<ThreadHistoryRun, ThreadHistoryError>;\n readonly load: (threadId: ThreadId) => Effect.Effect<Prompt.Prompt, ThreadHistoryError>;\n }\n>()(\"@effect-agent/engine/ThreadHistory\") {\n /** Bind incremental history to the supplied Thread.Store, including scoped ownership views. */\n static readonly makeFromStore = Effect.gen(function* () {\n const threads = yield* ConversationStore;\n\n const historyError = (cause: ThreadError): ThreadHistoryError =>\n ThreadHistoryError.make({\n threadId: cause.threadId,\n reason:\n cause._tag === \"ThreadNotFound\"\n ? \"not-found\"\n : cause._tag === \"ThreadLimitExceeded\"\n ? \"limit\"\n : cause._tag === \"ThreadHistoryDiverged\"\n ? \"conflict\"\n : cause._tag === \"ThreadOwnershipError\"\n ? cause.reason === \"closed\"\n ? \"fenced\"\n : \"conflict\"\n : \"encoding\",\n message:\n cause._tag === \"ThreadNotFound\"\n ? \"Thread history is not present in this application Scope\"\n : cause._tag === \"ThreadLimitExceeded\"\n ? `In-memory history exceeds the ${cause.limit} limit of ${cause.limitValue}`\n : cause.message,\n cause,\n });\n\n return ThreadHistory.of({\n retention: \"incremental\",\n memoryStore: threads,\n load: (threadId) =>\n threads.snapshot(threadId).pipe(Effect.map(toPrompt), Effect.mapError(historyError)),\n open: Effect.fnUntraced(function* ({ threadId, runId }) {\n const snapshot = yield* threads.create(threadId).pipe(Effect.mapError(historyError));\n\n return {\n prompt: toPrompt(snapshot),\n stageInput: () => Effect.void,\n stageHistory: ({ source }) =>\n threads\n .recordHistory(threadId, runId, source)\n .pipe(Effect.asVoid, Effect.mapError(historyError)),\n commit: () =>\n threads.snapshot(threadId).pipe(Effect.asVoid, Effect.mapError(historyError)),\n };\n }),\n });\n });\n\n static readonly layerFromStore = Layer.effect(ThreadHistory, ThreadHistory.makeFromStore);\n\n /** Retain history for the application Scope, within message and host capacity. Separate Layer builds own separate stores. */\n static readonly layer = ThreadHistory.layerFromStore.pipe(Layer.provideMerge(layerMemory));\n}\n\n/** Retain in-memory conversation history for the application Scope. */\nexport const layer = ThreadHistory.layer;\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAa,qBAAb,cAAwC,OAAO,YAAgC,CAAC,CAC9E,sBACA;CACE,UAAU;CACV,QAAQ,OAAO,SAAS;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,SAAS,OAAO;CAChB,OAAO,OAAO,YAAY,OAAO,OAAO,CAAC;AAC3C,CACF,CAAC,CAAC,CAAC;;;;;;;;AA+BH,IAAa,gBAAb,MAAa,sBAAsB,QAAQ,QAYzC,CAAC,CAAC,oCAAoC,CAAC,CAAC;;CAExC,OAAgB,gBAAgB,OAAO,IAAI,aAAa;EACtD,MAAM,UAAU,OAAOA;EAEvB,MAAM,gBAAgB,UACpB,mBAAmB,KAAK;GACtB,UAAU,MAAM;GAChB,QACE,MAAM,SAAS,mBACX,cACA,MAAM,SAAS,wBACb,UACA,MAAM,SAAS,0BACb,aACA,MAAM,SAAS,yBACb,MAAM,WAAW,WACf,WACA,aACF;GACZ,SACE,MAAM,SAAS,mBACX,4DACA,MAAM,SAAS,wBACb,iCAAiC,MAAM,MAAM,YAAY,MAAM,eAC/D,MAAM;GACd;EACF,CAAC;EAEH,OAAO,cAAc,GAAG;GACtB,WAAW;GACX,aAAa;GACb,OAAO,aACL,QAAQ,SAAS,QAAQ,CAAC,CAAC,KAAK,OAAO,IAAI,QAAQ,GAAG,OAAO,SAAS,YAAY,CAAC;GACrF,MAAM,OAAO,WAAW,WAAW,EAAE,UAAU,SAAS;IACtD,MAAM,WAAW,OAAO,QAAQ,OAAO,QAAQ,CAAC,CAAC,KAAK,OAAO,SAAS,YAAY,CAAC;IAEnF,OAAO;KACL,QAAQ,SAAS,QAAQ;KACzB,kBAAkB,OAAO;KACzB,eAAe,EAAE,aACf,QACG,cAAc,UAAU,OAAO,MAAM,CAAC,CACtC,KAAK,OAAO,QAAQ,OAAO,SAAS,YAAY,CAAC;KACtD,cACE,QAAQ,SAAS,QAAQ,CAAC,CAAC,KAAK,OAAO,QAAQ,OAAO,SAAS,YAAY,CAAC;IAChF;GACF,CAAC;EACH,CAAC;CACH,CAAC;CAED,OAAgB,iBAAiB,MAAM,OAAO,eAAe,cAAc,aAAa;;CAGxF,OAAgB,QAAQ,cAAc,eAAe,KAAK,MAAM,aAAa,WAAW,CAAC;AAC3F;;AAGA,MAAa,QAAQ,cAAc"}
package/dist/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { a as Identifiers_d_exports } from "./Identifiers-CN2s30fF.mjs";
2
2
  import { a as SubagentContract_d_exports } from "./SubagentContract-DdPzxYQj.mjs";
3
3
  import { t as SubagentReservations_d_exports } from "./capabilities/SubagentReservations.mjs";
4
- import { p as Thread_d_exports } from "./Thread-dk-QiNml.mjs";
4
+ import { p as Thread_d_exports } from "./Thread-DzdJAY4J.mjs";
5
5
  import { o as Receipt_d_exports } from "./Receipt-BkM21Qiu.mjs";
6
6
  import { t as AgentUpdates_d_exports } from "./AgentUpdates-DksV4D0A.mjs";
7
7
  import { f as Usage_d_exports } from "./Usage-CzZJ6A2n.mjs";
8
8
  import { d as RunEvent_d_exports } from "./RunEvent-C5jVQZ6K.mjs";
9
- import { i as ThreadHistory_d_exports } from "./ThreadHistory-ByxS8HU1.mjs";
9
+ import { i as ThreadHistory_d_exports } from "./ThreadHistory-KPPBJLJb.mjs";
10
10
  import { t as InMemory_d_exports } from "./InMemory.mjs";
11
11
  import { t as ToolExposure_d_exports } from "./ToolExposure.mjs";
12
12
  import { t as Redaction_d_exports } from "./capabilities/Redaction.mjs";
@@ -48,9 +48,9 @@ import { t as SemanticMemoryIndex_d_exports } from "./core/SemanticMemoryIndex.m
48
48
  import { t as SemanticMemoryRevalidation_d_exports } from "./core/SemanticMemoryRevalidation.mjs";
49
49
  import { t as SemanticMemory_d_exports } from "./capabilities/SemanticMemory.mjs";
50
50
  import { s as SubagentHost_d_exports } from "./SubagentHost-D1xBgn9g.mjs";
51
- import { t as AgentRuntime_d_exports } from "./AgentRuntime-BD3ZHAMq.mjs";
51
+ import { t as AgentRuntime_d_exports } from "./AgentRuntime-CHDyRbSf.mjs";
52
52
  import { i as RunEventSink_d_exports } from "./RunEventSink-shh6Qf9E.mjs";
53
- import { v as Subagent_d_exports } from "./Subagent-DKhZA72u.mjs";
53
+ import { v as Subagent_d_exports } from "./Subagent-xhN_aD1r.mjs";
54
54
  import { t as ToolDiscovery_d_exports } from "./capabilities/ToolDiscovery.mjs";
55
55
  import { D as PageCapture_d_exports } from "./PageCapture-Df8Xwskw.mjs";
56
56
  import { t as WebCapture_d_exports } from "./capabilities/WebCapture.mjs";
@@ -61,7 +61,7 @@ import { t as ProvisionalText_d_exports } from "./core/ProvisionalText.mjs";
61
61
  import { nt as Records_d_exports } from "./Records-BTnGRdcf.mjs";
62
62
  import { t as ActivityStore_d_exports } from "./durable/ActivityStore.mjs";
63
63
  import { n as Digest_d_exports } from "./Digest-DjUgS5PG.mjs";
64
- import { Ar as SubmissionStatus_d_exports, Eo as RunJournal_d_exports, Yn as DurableAgentRuntime_d_exports, do as LifecyclePublication_d_exports, pn as SubmissionLedger_d_exports, q as Recovery_d_exports, qi as ThreadStore_d_exports, t as Admin_d_exports, to as ThreadArchiveRange_d_exports, wa as ThreadWork_d_exports, ws as AgentRegistration_d_exports } from "./Admin-BHmp2V9p.mjs";
64
+ import { Ar as SubmissionStatus_d_exports, Do as RunJournal_d_exports, Es as AgentRegistration_d_exports, Ta as ThreadWork_d_exports, Yn as DurableAgentRuntime_d_exports, fo as LifecyclePublication_d_exports, no as ThreadArchiveRange_d_exports, pn as SubmissionLedger_d_exports, q as Recovery_d_exports, qi as ThreadStore_d_exports, t as Admin_d_exports } from "./Admin-Qa3I1oA5.mjs";
65
65
  import { t as DurableFailpoint_d_exports } from "./DurableFailpoint-BugHZKvJ.mjs";
66
66
  import { a as OperationAuthorizer_d_exports } from "./OperationAuthorizer-TzcQtpX5.mjs";
67
67
  import { s as RecordFormat_d_exports } from "./RecordFormat-BNiLpe43.mjs";
@@ -69,21 +69,21 @@ import { l as ToolReconciler_d_exports } from "./ToolReconciler-SrOHkvF8.mjs";
69
69
  import { n as WakeScheduler_d_exports } from "./WakeScheduler-DJIMMf77.mjs";
70
70
  import { t as CommittedActivity_d_exports } from "./durable/CommittedActivity.mjs";
71
71
  import { R as Schedule_d_exports } from "./Schedule-CDgTz0vj.mjs";
72
- import { k as Subscription_d_exports } from "./Subscription-BNg9VCRl.mjs";
73
- import { n as EventSource_d_exports } from "./EventSource-C9aaJaXT.mjs";
74
- import { n as PreparedInputAdmission_d_exports } from "./PreparedInputAdmission-BvDqlgiP.mjs";
75
- import { r as SubscriptionInput_d_exports } from "./SubscriptionInput-BUoXv-_K.mjs";
72
+ import { k as Subscription_d_exports } from "./Subscription-DmIHlOJK.mjs";
73
+ import { n as EventSource_d_exports } from "./EventSource-BTu68yDW.mjs";
74
+ import { n as PreparedInputAdmission_d_exports } from "./PreparedInputAdmission-wgY4JMZY.mjs";
75
+ import { r as SubscriptionInput_d_exports } from "./SubscriptionInput-DgcQhvbe.mjs";
76
76
  import { t as Subscriptions_d_exports } from "./durable/Subscriptions.mjs";
77
- import { g as MessageDelivery_d_exports } from "./MessageDelivery-BGDm-c46.mjs";
77
+ import { g as MessageDelivery_d_exports } from "./MessageDelivery-DjAZJ4Fd.mjs";
78
78
  import { t as PersistentHistory_d_exports } from "./durable/PersistentHistory.mjs";
79
- import { i as RunContinuation_d_exports } from "./RunContinuation-CTJ1jGrO.mjs";
79
+ import { i as RunContinuation_d_exports } from "./RunContinuation-3jB5pULC.mjs";
80
80
  import { t as ScheduleTransition_d_exports } from "./durable/ScheduleTransition.mjs";
81
81
  import { t as Scheduling_d_exports } from "./durable/Scheduling.mjs";
82
82
  import { t as SubscriptionTools_d_exports } from "./durable/SubscriptionTools.mjs";
83
83
  import { t as SubscriptionTransition_d_exports } from "./durable/SubscriptionTransition.mjs";
84
84
  import { t as ThreadContextHistory_d_exports } from "./durable/ThreadContextHistory.mjs";
85
85
  import { t as ThreadContextHistoryProjection_d_exports } from "./durable/ThreadContextHistoryProjection.mjs";
86
- import { l as ThreadImport_d_exports } from "./ThreadImport-CMgzttvr.mjs";
86
+ import { l as ThreadImport_d_exports } from "./ThreadImport-DP-vOk2F.mjs";
87
87
  import { t as ThreadInvariants_d_exports } from "./durable/ThreadInvariants.mjs";
88
88
  import { t as ThreadProjection_d_exports } from "./durable/ThreadProjection.mjs";
89
89
  import { t as ThreadProjectionMaintenance_d_exports } from "./durable/ThreadProjectionMaintenance.mjs";
package/dist/index.mjs CHANGED
@@ -11,11 +11,11 @@ import { t as SubagentContract_exports } from "./core/SubagentContract.mjs";
11
11
  import { t as Usage_exports } from "./core/Usage.mjs";
12
12
  import { t as RunEvent_exports } from "./core/RunEvent.mjs";
13
13
  import { x as Worker_exports } from "./Worker-DZjdMjZn.mjs";
14
- import { n as MessagingHost_exports } from "./MessagingHost-CRUK4JBi.mjs";
14
+ import { n as MessagingHost_exports } from "./MessagingHost-CZCyrnvJ.mjs";
15
15
  import { t as SubagentHost_exports } from "./engine/SubagentHost.mjs";
16
16
  import { t as Thread_exports } from "./core/Thread.mjs";
17
17
  import { t as ThreadHistory_exports } from "./engine/ThreadHistory.mjs";
18
- import { t as AgentRuntime_exports } from "./AgentRuntime-B6qZlD3f.mjs";
18
+ import { t as AgentRuntime_exports } from "./AgentRuntime-DaDKMasp.mjs";
19
19
  import { t as ProvisionalText_exports } from "./core/ProvisionalText.mjs";
20
20
  import { t as ContextWindow_exports } from "./engine/ContextWindow.mjs";
21
21
  import { t as DurableStep_exports } from "./engine/DurableStep.mjs";
@@ -58,21 +58,21 @@ import { t as RunHooks_exports } from "./capabilities/RunHooks.mjs";
58
58
  import { t as SemanticMemoryIndex_exports } from "./core/SemanticMemoryIndex.mjs";
59
59
  import { t as SemanticMemoryRevalidation_exports } from "./core/SemanticMemoryRevalidation.mjs";
60
60
  import { t as SemanticMemory_exports } from "./capabilities/SemanticMemory.mjs";
61
- import { r as Subagent_exports } from "./Subagent-CTIpnzlB.mjs";
61
+ import { r as Subagent_exports } from "./Subagent-CexndZSp.mjs";
62
62
  import { t as ToolDiscovery_exports } from "./capabilities/ToolDiscovery.mjs";
63
63
  import { t as ToolExposure_exports } from "./ToolExposure.mjs";
64
64
  import { t as WebCapture_exports } from "./capabilities/WebCapture.mjs";
65
65
  import { t as WebSearch_exports } from "./capabilities/WebSearch.mjs";
66
- import { $ as Records_exports } from "./Records-BiuJDWNe.mjs";
66
+ import { $ as Records_exports } from "./Records-DzL4Kbtw.mjs";
67
67
  import { t as ActivityStore_exports } from "./durable/ActivityStore.mjs";
68
- import { n as Digest_exports } from "./Digest-EpeqWEdv.mjs";
68
+ import { n as Digest_exports } from "./Digest-C3EODOee.mjs";
69
69
  import { t as SubmissionLedger_exports } from "./durable/SubmissionLedger.mjs";
70
70
  import { t as Recovery_exports } from "./durable/Recovery.mjs";
71
71
  import { t as Admin_exports } from "./durable/Admin.mjs";
72
72
  import { t as AgentRegistration_exports } from "./durable/AgentRegistration.mjs";
73
73
  import { t as RecordFormat_exports } from "./durable/RecordFormat.mjs";
74
- import { n as RunJournal_exports } from "./RunJournal-CNZqA3Ge.mjs";
75
- import { Z as ThreadStore_exports } from "./ThreadStore-59uDGXul.mjs";
74
+ import { n as RunJournal_exports } from "./RunJournal-CPMKcfd0.mjs";
75
+ import { Z as ThreadStore_exports } from "./ThreadStore-EuUilthA.mjs";
76
76
  import { t as Schedule_exports } from "./durable/Schedule.mjs";
77
77
  import { t as PreparedInputAdmission_exports } from "./durable/PreparedInputAdmission.mjs";
78
78
  import { t as Subscription_exports } from "./durable/Subscription.mjs";
@@ -80,11 +80,11 @@ import { t as MessageDelivery_exports } from "./durable/MessageDelivery.mjs";
80
80
  import { t as ThreadArchiveRange_exports } from "./durable/ThreadArchiveRange.mjs";
81
81
  import { t as CommittedActivity_exports } from "./durable/CommittedActivity.mjs";
82
82
  import { t as DurableFailpoint_exports } from "./durable/DurableFailpoint.mjs";
83
- import { i as RunContinuation_exports } from "./RunContinuation-4ZATcVLB.mjs";
83
+ import { i as RunContinuation_exports } from "./RunContinuation-BiyKJK32.mjs";
84
84
  import { t as ThreadWork_exports } from "./durable/ThreadWork.mjs";
85
85
  import { t as WakeScheduler_exports } from "./durable/WakeScheduler.mjs";
86
- import { r as DurableAgentRuntime_exports } from "./DurableAgentRuntime-CBBjRNJN.mjs";
87
- import { i as WorkerAdmission_exports } from "./WorkerAdmission-DDYJdOsU.mjs";
86
+ import { r as DurableAgentRuntime_exports } from "./DurableAgentRuntime-CPlw5_7e.mjs";
87
+ import { i as WorkerAdmission_exports } from "./WorkerAdmission-eBeXt_mu.mjs";
88
88
  import { t as WorkerHost_exports } from "./durable/WorkerHost.mjs";
89
89
  import { t as OperationAuthorizer_exports } from "./durable/OperationAuthorizer.mjs";
90
90
  import { t as SubmissionStatus_exports } from "./durable/SubmissionStatus.mjs";
@@ -92,13 +92,13 @@ import { t as ToolReconciler_exports } from "./durable/ToolReconciler.mjs";
92
92
  import { t as EventSource_exports } from "./durable/EventSource.mjs";
93
93
  import { t as PersistentHistory_exports } from "./durable/PersistentHistory.mjs";
94
94
  import { t as ScheduleTransition_exports } from "./durable/ScheduleTransition.mjs";
95
- import { i as Scheduling_exports } from "./Scheduling-NG8slKdI.mjs";
95
+ import { i as Scheduling_exports } from "./Scheduling-07_dsGED.mjs";
96
96
  import { t as SubscriptionInput_exports } from "./durable/SubscriptionInput.mjs";
97
97
  import { t as Subscriptions_exports } from "./durable/Subscriptions.mjs";
98
98
  import { t as SubscriptionTools_exports } from "./durable/SubscriptionTools.mjs";
99
99
  import { t as SubscriptionTransition_exports } from "./durable/SubscriptionTransition.mjs";
100
- import { o as ThreadImport_exports } from "./ThreadImport-CodYoJoa.mjs";
101
- import { n as ThreadTransfer_exports } from "./ThreadTransfer-3jigUl3g.mjs";
100
+ import { o as ThreadImport_exports } from "./ThreadImport-CjlG57vH.mjs";
101
+ import { n as ThreadTransfer_exports } from "./ThreadTransfer-DB_zsrtJ.mjs";
102
102
  import { t as ThreadInvariants_exports } from "./durable/ThreadInvariants.mjs";
103
103
  import { t as ThreadProjection_exports } from "./durable/ThreadProjection.mjs";
104
104
  import { t as ThreadProjectionMaintenance_exports } from "./durable/ThreadProjectionMaintenance.mjs";
@@ -75,6 +75,7 @@ const sameSystemMessage = Schema.toEquivalence(Prompt.SystemMessage);
75
75
  const prepareModelPrompt = (prompt, contract, systemMessagesInHistory, staticInstructions) => {
76
76
  if (systemMessagesInHistory) {
77
77
  const content = [];
78
+ let pendingContract = contract;
78
79
  let lastSystem;
79
80
  let ordered = prompt.content;
80
81
  if (staticInstructions !== void 0) {
@@ -100,37 +101,33 @@ const prepareModelPrompt = (prompt, contract, systemMessagesInHistory, staticIns
100
101
  if (lastSystem !== void 0 && sameSystemMessage(lastSystem, message)) continue;
101
102
  lastSystem = message;
102
103
  }
104
+ if (message.role !== "system" && pendingContract !== void 0) {
105
+ content.push(pendingContract);
106
+ pendingContract = void 0;
107
+ }
103
108
  content.push(message);
104
109
  }
105
- if (contract !== void 0) {
106
- const firstConversation = content.findIndex((message) => message.role !== "system");
107
- content.splice(firstConversation === -1 ? content.length : firstConversation, 0, contract);
108
- }
110
+ if (pendingContract !== void 0) content.push(pendingContract);
109
111
  return Prompt.fromMessages(content);
110
112
  }
111
113
  const systems = [];
112
- const conversation = [];
113
114
  const seen = /* @__PURE__ */ new Map();
114
115
  for (let index = prompt.content.length - 1; index >= 0; index -= 1) {
115
116
  const message = prompt.content[index];
116
117
  if (message === void 0) continue;
117
- if (message.role !== "system") {
118
- conversation.push(message);
119
- continue;
120
- }
118
+ if (message.role !== "system") continue;
121
119
  const variants = seen.get(message.content);
122
120
  if (variants?.some((previous) => sameSystemMessage(previous, message))) continue;
123
121
  if (variants === void 0) seen.set(message.content, [message]);
124
122
  else variants.push(message);
125
123
  systems.push(message);
126
124
  }
127
- return Prompt.fromMessages([
128
- ...systems.reverse(),
129
- ...contract === void 0 ? [] : [contract],
130
- ...conversation.reverse()
131
- ]);
125
+ const content = systems.reverse();
126
+ if (contract !== void 0) content.push(contract);
127
+ for (const message of prompt.content) if (message !== void 0 && message.role !== "system") content.push(message);
128
+ return Prompt.fromMessages(content);
132
129
  };
133
130
  //#endregion
134
131
  export { textOutput as i, outputSchemaContract as n, prepareModelPrompt as r, isTextOutput as t };
135
132
 
136
- //# sourceMappingURL=output-contract-CMIhu4Cw.mjs.map
133
+ //# sourceMappingURL=output-contract-DCnLYCdp.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"output-contract-CMIhu4Cw.mjs","names":[],"sources":["../src/engine/internal/output-contract.ts"],"sourcesContent":["import * as Prompt from \"effect/ai/Prompt\";\nimport * as Tool from \"effect/ai/Tool\";\nimport * as Schema from \"effect/Schema\";\n\nimport type * as Agent from \"../../core/Agent.ts\";\n\nconst outputFormatAnnotation = \"@effect-agent/engine/Output/format\";\n\n/**\n * Declare ordinary assistant text as an Agent's final-output wire format. Apply this to the\n * complete output Schema after composing transformations. Its encoded type must be string;\n * decoding, checks, transformations, and service requirements remain owned by that Schema.\n * Text is preserved verbatim, including whitespace, quotes, and an empty reply when allowed.\n * Required completion Tools still take precedence. Unmarked Schemas use JSON final output.\n *\n * @example\n * ```ts\n * output: Output.text(Schema.String.check(Schema.isMaxLength(20_000)))\n * ```\n */\nexport const textOutput = <S extends Schema.Top & { readonly Encoded: string }>(\n schema: S,\n): S[\"Rebuild\"] => schema.annotate({ [outputFormatAnnotation]: \"text\" });\n\nexport const isTextOutput = (schema: Schema.Top): boolean =>\n Schema.resolveAnnotations(schema)?.[outputFormatAnnotation] === \"text\";\n\n/**\n * Model-visible final-output contract (RUN-028).\n *\n * For ordinary text completion, the interpreter's only output-conformance\n * point is `decodeFinalOutput`, which validates the final text after the\n * model has already finished. This module renders that Schema's wire contract\n * with the same Effect AI derivation the providers use for Tool parameters\n * and states it as one framework-owned system message on every model request.\n * A required completion Tool instead gets a native-tool directive: its Tool\n * parameter Schema is already carried by the provider request, and ordinary\n * final text is not an allowed completion path.\n *\n * The contract is a per-request projection of the immutable definition —\n * exactly like the Tool schemas the request already carries. It is inserted\n * at model-request materialization (after context preparation) and never\n * into official history, so canonical records, run events, and the committed\n * DN/DC golden are unchanged.\n *\n */\n\n/** Rendering outcome for one definition's output Schema. */\ntype OutputContract =\n | {\n readonly _tag: \"rendered\";\n /** The complete system-message text: directive plus the derived JSON Schema. */\n readonly message: string;\n readonly part: Prompt.SystemMessage;\n }\n | {\n readonly _tag: \"unrenderable\";\n /** Why Effect AI's JSON-Schema derivation rejected the output Schema. */\n readonly reason: string;\n };\n\nconst contractDirective = (definition: Agent.AnyDefinition): string =>\n definition.completion === undefined\n ? \"Final output contract: when the task is complete, the final assistant message must be only \" +\n \"JSON that is valid against this JSON Schema — no prose, no Markdown code fences, nothing \" +\n \"before or after the JSON.\"\n : `Final output contract: when the task is complete without calling the \"${definition.completion.tool}\" completion Tool, the final assistant message must be only ` +\n \"JSON that is valid against this JSON Schema — no prose, no Markdown code fences, nothing \" +\n `before or after the JSON. When calling the \"${definition.completion.tool}\" completion Tool, never place this private Agent output JSON in any Tool argument; follow the Tool's parameter schema instead. Call it as the sole application Tool Call, after receiving any other needed application Tool results. Completed provider Tool results may accompany it. The engine projects the successful completion Tool result into the Agent output.`;\n\nconst requiredCompletionDirective = (tool: string, hasAlternatives: boolean): string =>\n `Final output contract: ${hasAlternatives ? \"otherwise complete\" : \"complete only\"} by calling the required completion Tool ${JSON.stringify(tool)} ` +\n \"as the sole application Tool Call in its batch. Completed provider Tool results may accompany it. Do not emit an ordinary final assistant text answer. \" +\n \"The Tool's canonical parameters and successful result are projected and validated as the Agent output.\";\n\n/**\n * Render the model-visible final-output contract for one definition. The\n * derivation and message identity are stable for an immutable definition.\n * An output Schema the Effect AI derivation cannot represent is reported as\n * `unrenderable`; the caller falls back to the prior behavior — the contract\n * is guidance, and a Schema that decodes but does not render must not become\n * a new failure mode.\n */\nconst rendered = (message: string): OutputContract => ({\n _tag: \"rendered\",\n message,\n part: Prompt.makeMessage(\"system\", { content: message }),\n});\n\nconst renderOutputSchemaContract = (definition: Agent.AnyDefinition): OutputContract => {\n if (definition.completion?.required === true) {\n return rendered(\n requiredCompletionDirective(\n definition.completion.tool,\n (definition.completionFromTools?.length ?? 0) > 0,\n ),\n );\n }\n if (isTextOutput(definition.output)) {\n return rendered(\n \"Final output contract: write the final reply as ordinary assistant text, without JSON wrapping. \" +\n \"An empty reply is valid only when allowed by the output Schema and the task instructions.\" +\n (definition.completion === undefined\n ? \"\"\n : ` When calling the \"${definition.completion.tool}\" completion Tool, follow its parameter schema instead and call it as the sole application Tool Call, after receiving any other needed application Tool results; completed provider Tool results may accompany it; the engine projects its successful result into the Agent output.`),\n );\n }\n try {\n const jsonSchema = Tool.getJsonSchemaFromSchema(definition.output);\n\n return rendered(\n `${contractDirective(definition)}\\n\\n${JSON.stringify(jsonSchema, undefined, 2)}`,\n );\n } catch (cause) {\n return {\n _tag: \"unrenderable\",\n reason: cause instanceof Error ? cause.message : String(cause),\n };\n }\n};\n\n// Native incremental-response tracking recognizes message objects, not rendered text.\n// Weak keys retain neither discarded definitions nor their Schema graphs.\nconst outputContracts = new WeakMap<Agent.AnyDefinition, OutputContract>();\n\nexport const outputSchemaContract = (definition: Agent.AnyDefinition): OutputContract => {\n const cached = outputContracts.get(definition);\n\n if (cached !== undefined) return cached;\n const base = renderOutputSchemaContract(definition);\n const alternatives = definition.completionFromTools ?? [];\n\n const contract =\n base._tag === \"rendered\" && alternatives.length > 0\n ? rendered(\n `The following action Tools may complete the Run from their successful canonical result: ${alternatives.map((declaration) => JSON.stringify(declaration.tool)).join(\", \")}. ` +\n \"Call such a Tool as the sole application Tool Call, following its parameter schema. Completed provider Tool results may accompany it. It may complete the Run only when it satisfies the whole request. \" +\n \"An incomplete or pending result continues the Run. These actions are unavailable during finalization after budget exhaustion.\\n\\n\" +\n base.message,\n )\n : base;\n\n outputContracts.set(definition, contract);\n\n return contract;\n};\n\nconst sameSystemMessage = Schema.toEquivalence(Prompt.SystemMessage);\n\n/**\n * Keep supported system instructions in conversation order so changing late guidance\n * cannot invalidate the preceding user/tool cache prefix. Omit an exact repeat\n * only when no distinct system instruction intervened; returning to an earlier\n * instruction after a different one must preserve the new directive's precedence.\n * Anchor the immutable output contract after the initial system block.\n * Restore leading static instructions for caller-supplied conversation-only history.\n *\n * This runs after preparation and compaction. Canonical messages, protected\n * instruction/input spans and compaction coverage retain their original positions.\n * Adapters without this capability retain the grouped-system projection: keep the\n * last equivalent instruction with its native options, then the contract and\n * conversation. This prevents older Anthropic adapters from discarding system groups.\n */\nexport const prepareModelPrompt = (\n prompt: Prompt.Prompt,\n contract: Prompt.SystemMessage | undefined,\n systemMessagesInHistory: boolean,\n staticInstructions: Prompt.RawInput | undefined,\n): Prompt.Prompt => {\n if (systemMessagesInHistory) {\n const content: Array<Prompt.Message> = [];\n let lastSystem: Prompt.SystemMessage | undefined;\n let ordered = prompt.content;\n\n if (staticInstructions !== undefined) {\n const firstConversation = prompt.content.findIndex((message) => message.role !== \"system\");\n\n const leading = prompt.content.slice(\n 0,\n firstConversation === -1 ? prompt.content.length : firstConversation,\n );\n\n const restored: Array<Prompt.Message> = [];\n\n const instructions =\n typeof staticInstructions === \"string\"\n ? [Prompt.systemMessage({ content: staticInstructions })]\n : Prompt.make(staticInstructions).content;\n\n for (const message of instructions) {\n if (message.role !== \"system\") break;\n if (\n leading.some(\n (candidate) => candidate.role === \"system\" && sameSystemMessage(candidate, message),\n )\n )\n break;\n\n const original = prompt.content.find(\n (candidate) => candidate.role === \"system\" && sameSystemMessage(candidate, message),\n );\n\n if (original === undefined) break;\n restored.push(original);\n }\n if (restored.length > 0)\n ordered = [...leading, ...restored, ...prompt.content.slice(leading.length)];\n }\n\n for (const message of ordered) {\n if (message.role === \"system\") {\n if (lastSystem !== undefined && sameSystemMessage(lastSystem, message)) continue;\n lastSystem = message;\n }\n content.push(message);\n }\n if (contract !== undefined) {\n const firstConversation = content.findIndex((message) => message.role !== \"system\");\n\n content.splice(firstConversation === -1 ? content.length : firstConversation, 0, contract);\n }\n\n return Prompt.fromMessages(content);\n }\n\n const systems: Array<Prompt.SystemMessage> = [];\n const conversation: Array<Prompt.Message> = [];\n const seen = new Map<string, Array<Prompt.SystemMessage>>();\n\n for (let index = prompt.content.length - 1; index >= 0; index -= 1) {\n const message = prompt.content[index];\n\n if (message === undefined) continue;\n if (message.role !== \"system\") {\n conversation.push(message);\n continue;\n }\n const variants = seen.get(message.content);\n\n if (variants?.some((previous) => sameSystemMessage(previous, message))) continue;\n if (variants === undefined) seen.set(message.content, [message]);\n else variants.push(message);\n systems.push(message);\n }\n\n return Prompt.fromMessages([\n ...systems.reverse(),\n ...(contract === undefined ? [] : [contract]),\n ...conversation.reverse(),\n ]);\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"output-contract-DCnLYCdp.mjs","names":[],"sources":["../src/engine/internal/output-contract.ts"],"sourcesContent":["import * as Prompt from \"effect/ai/Prompt\";\nimport * as Tool from \"effect/ai/Tool\";\nimport * as Schema from \"effect/Schema\";\n\nimport type * as Agent from \"../../core/Agent.ts\";\n\nconst outputFormatAnnotation = \"@effect-agent/engine/Output/format\";\n\n/**\n * Declare ordinary assistant text as an Agent's final-output wire format. Apply this to the\n * complete output Schema after composing transformations. Its encoded type must be string;\n * decoding, checks, transformations, and service requirements remain owned by that Schema.\n * Text is preserved verbatim, including whitespace, quotes, and an empty reply when allowed.\n * Required completion Tools still take precedence. Unmarked Schemas use JSON final output.\n *\n * @example\n * ```ts\n * output: Output.text(Schema.String.check(Schema.isMaxLength(20_000)))\n * ```\n */\nexport const textOutput = <S extends Schema.Top & { readonly Encoded: string }>(\n schema: S,\n): S[\"Rebuild\"] => schema.annotate({ [outputFormatAnnotation]: \"text\" });\n\nexport const isTextOutput = (schema: Schema.Top): boolean =>\n Schema.resolveAnnotations(schema)?.[outputFormatAnnotation] === \"text\";\n\n/**\n * Model-visible final-output contract (RUN-028).\n *\n * For ordinary text completion, the interpreter's only output-conformance\n * point is `decodeFinalOutput`, which validates the final text after the\n * model has already finished. This module renders that Schema's wire contract\n * with the same Effect AI derivation the providers use for Tool parameters\n * and states it as one framework-owned system message on every model request.\n * A required completion Tool instead gets a native-tool directive: its Tool\n * parameter Schema is already carried by the provider request, and ordinary\n * final text is not an allowed completion path.\n *\n * The contract is a per-request projection of the immutable definition —\n * exactly like the Tool schemas the request already carries. It is inserted\n * at model-request materialization (after context preparation) and never\n * into official history, so canonical records, run events, and the committed\n * DN/DC golden are unchanged.\n *\n */\n\n/** Rendering outcome for one definition's output Schema. */\ntype OutputContract =\n | {\n readonly _tag: \"rendered\";\n /** The complete system-message text: directive plus the derived JSON Schema. */\n readonly message: string;\n readonly part: Prompt.SystemMessage;\n }\n | {\n readonly _tag: \"unrenderable\";\n /** Why Effect AI's JSON-Schema derivation rejected the output Schema. */\n readonly reason: string;\n };\n\nconst contractDirective = (definition: Agent.AnyDefinition): string =>\n definition.completion === undefined\n ? \"Final output contract: when the task is complete, the final assistant message must be only \" +\n \"JSON that is valid against this JSON Schema — no prose, no Markdown code fences, nothing \" +\n \"before or after the JSON.\"\n : `Final output contract: when the task is complete without calling the \"${definition.completion.tool}\" completion Tool, the final assistant message must be only ` +\n \"JSON that is valid against this JSON Schema — no prose, no Markdown code fences, nothing \" +\n `before or after the JSON. When calling the \"${definition.completion.tool}\" completion Tool, never place this private Agent output JSON in any Tool argument; follow the Tool's parameter schema instead. Call it as the sole application Tool Call, after receiving any other needed application Tool results. Completed provider Tool results may accompany it. The engine projects the successful completion Tool result into the Agent output.`;\n\nconst requiredCompletionDirective = (tool: string, hasAlternatives: boolean): string =>\n `Final output contract: ${hasAlternatives ? \"otherwise complete\" : \"complete only\"} by calling the required completion Tool ${JSON.stringify(tool)} ` +\n \"as the sole application Tool Call in its batch. Completed provider Tool results may accompany it. Do not emit an ordinary final assistant text answer. \" +\n \"The Tool's canonical parameters and successful result are projected and validated as the Agent output.\";\n\n/**\n * Render the model-visible final-output contract for one definition. The\n * derivation and message identity are stable for an immutable definition.\n * An output Schema the Effect AI derivation cannot represent is reported as\n * `unrenderable`; the caller falls back to the prior behavior — the contract\n * is guidance, and a Schema that decodes but does not render must not become\n * a new failure mode.\n */\nconst rendered = (message: string): OutputContract => ({\n _tag: \"rendered\",\n message,\n part: Prompt.makeMessage(\"system\", { content: message }),\n});\n\nconst renderOutputSchemaContract = (definition: Agent.AnyDefinition): OutputContract => {\n if (definition.completion?.required === true) {\n return rendered(\n requiredCompletionDirective(\n definition.completion.tool,\n (definition.completionFromTools?.length ?? 0) > 0,\n ),\n );\n }\n if (isTextOutput(definition.output)) {\n return rendered(\n \"Final output contract: write the final reply as ordinary assistant text, without JSON wrapping. \" +\n \"An empty reply is valid only when allowed by the output Schema and the task instructions.\" +\n (definition.completion === undefined\n ? \"\"\n : ` When calling the \"${definition.completion.tool}\" completion Tool, follow its parameter schema instead and call it as the sole application Tool Call, after receiving any other needed application Tool results; completed provider Tool results may accompany it; the engine projects its successful result into the Agent output.`),\n );\n }\n try {\n const jsonSchema = Tool.getJsonSchemaFromSchema(definition.output);\n\n return rendered(\n `${contractDirective(definition)}\\n\\n${JSON.stringify(jsonSchema, undefined, 2)}`,\n );\n } catch (cause) {\n return {\n _tag: \"unrenderable\",\n reason: cause instanceof Error ? cause.message : String(cause),\n };\n }\n};\n\n// Native incremental-response tracking recognizes message objects, not rendered text.\n// Weak keys retain neither discarded definitions nor their Schema graphs.\nconst outputContracts = new WeakMap<Agent.AnyDefinition, OutputContract>();\n\nexport const outputSchemaContract = (definition: Agent.AnyDefinition): OutputContract => {\n const cached = outputContracts.get(definition);\n\n if (cached !== undefined) return cached;\n const base = renderOutputSchemaContract(definition);\n const alternatives = definition.completionFromTools ?? [];\n\n const contract =\n base._tag === \"rendered\" && alternatives.length > 0\n ? rendered(\n `The following action Tools may complete the Run from their successful canonical result: ${alternatives.map((declaration) => JSON.stringify(declaration.tool)).join(\", \")}. ` +\n \"Call such a Tool as the sole application Tool Call, following its parameter schema. Completed provider Tool results may accompany it. It may complete the Run only when it satisfies the whole request. \" +\n \"An incomplete or pending result continues the Run. These actions are unavailable during finalization after budget exhaustion.\\n\\n\" +\n base.message,\n )\n : base;\n\n outputContracts.set(definition, contract);\n\n return contract;\n};\n\nconst sameSystemMessage = Schema.toEquivalence(Prompt.SystemMessage);\n\n/**\n * Keep supported system instructions in conversation order so changing late guidance\n * cannot invalidate the preceding user/tool cache prefix. Omit an exact repeat\n * only when no distinct system instruction intervened; returning to an earlier\n * instruction after a different one must preserve the new directive's precedence.\n * Anchor the immutable output contract after the initial system block.\n * Restore leading static instructions for caller-supplied conversation-only history.\n *\n * This runs after preparation and compaction. Canonical messages, protected\n * instruction/input spans and compaction coverage retain their original positions.\n * Adapters without this capability retain the grouped-system projection: keep the\n * last equivalent instruction with its native options, then the contract and\n * conversation. This prevents older Anthropic adapters from discarding system groups.\n */\nexport const prepareModelPrompt = (\n prompt: Prompt.Prompt,\n contract: Prompt.SystemMessage | undefined,\n systemMessagesInHistory: boolean,\n staticInstructions: Prompt.RawInput | undefined,\n): Prompt.Prompt => {\n if (systemMessagesInHistory) {\n const content: Array<Prompt.Message> = [];\n let pendingContract = contract;\n let lastSystem: Prompt.SystemMessage | undefined;\n let ordered = prompt.content;\n\n if (staticInstructions !== undefined) {\n const firstConversation = prompt.content.findIndex((message) => message.role !== \"system\");\n\n const leading = prompt.content.slice(\n 0,\n firstConversation === -1 ? prompt.content.length : firstConversation,\n );\n\n const restored: Array<Prompt.Message> = [];\n\n const instructions =\n typeof staticInstructions === \"string\"\n ? [Prompt.systemMessage({ content: staticInstructions })]\n : Prompt.make(staticInstructions).content;\n\n for (const message of instructions) {\n if (message.role !== \"system\") break;\n if (\n leading.some(\n (candidate) => candidate.role === \"system\" && sameSystemMessage(candidate, message),\n )\n )\n break;\n\n const original = prompt.content.find(\n (candidate) => candidate.role === \"system\" && sameSystemMessage(candidate, message),\n );\n\n if (original === undefined) break;\n restored.push(original);\n }\n if (restored.length > 0)\n ordered = [...leading, ...restored, ...prompt.content.slice(leading.length)];\n }\n\n for (const message of ordered) {\n if (message.role === \"system\") {\n if (lastSystem !== undefined && sameSystemMessage(lastSystem, message)) continue;\n lastSystem = message;\n }\n if (message.role !== \"system\" && pendingContract !== undefined) {\n content.push(pendingContract);\n pendingContract = undefined;\n }\n content.push(message);\n }\n if (pendingContract !== undefined) content.push(pendingContract);\n\n return Prompt.fromMessages(content);\n }\n\n const systems: Array<Prompt.SystemMessage> = [];\n const seen = new Map<string, Array<Prompt.SystemMessage>>();\n\n for (let index = prompt.content.length - 1; index >= 0; index -= 1) {\n const message = prompt.content[index];\n\n if (message === undefined) continue;\n if (message.role !== \"system\") continue;\n const variants = seen.get(message.content);\n\n if (variants?.some((previous) => sameSystemMessage(previous, message))) continue;\n if (variants === undefined) seen.set(message.content, [message]);\n else variants.push(message);\n systems.push(message);\n }\n\n const content: Array<Prompt.Message> = systems.reverse();\n\n if (contract !== undefined) content.push(contract);\n for (const message of prompt.content) {\n if (message !== undefined && message.role !== \"system\") content.push(message);\n }\n\n return Prompt.fromMessages(content);\n};\n"],"mappings":"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"}
@@ -1,6 +1,6 @@
1
1
  import { u as ThreadId } from "./Identifiers-CN2s30fF.mjs";
2
2
  import { d as CanonicalRecordEnvelope, et as RecordId } from "./Records-BTnGRdcf.mjs";
3
- import { Fi as ThreadPromptRead, Gi as ThreadStoreError, Mi as ThreadNotMaterialized, Ri as ThreadReader, Ss as JournalRecordEnvelope } from "./Admin-BHmp2V9p.mjs";
3
+ import { Fi as ThreadPromptRead, Gi as ThreadStoreError, Mi as ThreadNotMaterialized, Ri as ThreadReader, ws as JournalRecordEnvelope } from "./Admin-Qa3I1oA5.mjs";
4
4
  import { Context, Effect, Layer, Stream } from "effect";
5
5
  //#region src/durable/internal/run-context-reader.d.ts
6
6
  declare const RunContextReader_base: Context.ServiceClass<RunContextReader, "@effect-agent/thread/RunContextReader", {
@@ -14,4 +14,4 @@ declare class RunContextReader extends RunContextReader_base {
14
14
  }
15
15
  //#endregion
16
16
  export { RunContextReader as t };
17
- //# sourceMappingURL=run-context-reader-CC7ZD95F.d.mts.map
17
+ //# sourceMappingURL=run-context-reader-DVhJZ1Qe.d.mts.map
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@yielded/agent","version":"0.1.0-beta.174","devDependencies":{"@effect/platform-node":"4.0.3","@effect/vitest":"4.0.3","effect":"4.0.3","typescript":"7.0.2","vite":"npm:@voidzero-dev/vite-plus-core@1.1.0","vite-plus":"1.1.0","vitest":"5.0.3"},"peerDependencies":{"effect":"^4.0.3"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./activity-store":{"types":"./dist/durable/ActivityStore.d.mts","default":"./dist/durable/ActivityStore.mjs"},"./admin":{"types":"./dist/durable/Admin.d.mts","default":"./dist/durable/Admin.mjs"},"./agent":{"types":"./dist/core/Agent.d.mts","default":"./dist/core/Agent.mjs"},"./agent-error":{"types":"./dist/core/AgentError.d.mts","default":"./dist/core/AgentError.mjs"},"./agent-policy":{"types":"./dist/core/AgentPolicy.d.mts","default":"./dist/core/AgentPolicy.mjs"},"./agent-registration":{"types":"./dist/durable/AgentRegistration.d.mts","default":"./dist/durable/AgentRegistration.mjs"},"./agent-runtime":{"types":"./dist/engine/AgentRuntime.d.mts","default":"./dist/engine/AgentRuntime.mjs"},"./agent-updates":{"types":"./dist/core/AgentUpdates.d.mts","default":"./dist/core/AgentUpdates.mjs"},"./approval":{"types":"./dist/capabilities/Approval.d.mts","default":"./dist/capabilities/Approval.mjs"},"./browser-use":{"types":"./dist/capabilities/BrowserUse.d.mts","default":"./dist/capabilities/BrowserUse.mjs"},"./budget":{"types":"./dist/capabilities/Budget.d.mts","default":"./dist/capabilities/Budget.mjs"},"./code-executor":{"types":"./dist/sandbox/CodeExecutor.d.mts","default":"./dist/sandbox/CodeExecutor.mjs"},"./code-mode":{"types":"./dist/capabilities/CodeMode.d.mts","default":"./dist/capabilities/CodeMode.mjs"},"./commands":{"types":"./dist/capabilities/Commands.d.mts","default":"./dist/capabilities/Commands.mjs"},"./committed-activity":{"types":"./dist/durable/CommittedActivity.d.mts","default":"./dist/durable/CommittedActivity.mjs"},"./compaction":{"types":"./dist/engine/Compaction.d.mts","default":"./dist/engine/Compaction.mjs"},"./context-compactor":{"types":"./dist/engine/ContextCompactor.d.mts","default":"./dist/engine/ContextCompactor.mjs"},"./context-history":{"types":"./dist/engine/ContextHistory.d.mts","default":"./dist/engine/ContextHistory.mjs"},"./context-tools":{"types":"./dist/capabilities/ContextTools.d.mts","default":"./dist/capabilities/ContextTools.mjs"},"./context-window":{"types":"./dist/engine/ContextWindow.d.mts","default":"./dist/engine/ContextWindow.mjs"},"./digest":{"types":"./dist/durable/Digest.d.mts","default":"./dist/durable/Digest.mjs"},"./durable-agent-runtime":{"types":"./dist/durable/DurableAgentRuntime.d.mts","default":"./dist/durable/DurableAgentRuntime.mjs"},"./durable-failpoint":{"types":"./dist/durable/DurableFailpoint.d.mts","default":"./dist/durable/DurableFailpoint.mjs"},"./durable-step":{"types":"./dist/engine/DurableStep.d.mts","default":"./dist/engine/DurableStep.mjs"},"./event-source":{"types":"./dist/durable/EventSource.d.mts","default":"./dist/durable/EventSource.mjs"},"./failure-diagnostic":{"types":"./dist/core/FailureDiagnostic.d.mts","default":"./dist/core/FailureDiagnostic.mjs"},"./git-hub-workflow-source":{"types":"./dist/durable/GitHubWorkflowSource.d.mts","default":"./dist/durable/GitHubWorkflowSource.mjs"},"./id-generator":{"types":"./dist/core/IdGenerator.d.mts","default":"./dist/core/IdGenerator.mjs"},"./identifiers":{"types":"./dist/core/Identifiers.d.mts","default":"./dist/core/Identifiers.mjs"},"./in-memory":{"types":"./dist/InMemory.d.mts","default":"./dist/InMemory.mjs"},"./interactive-browser":{"types":"./dist/sandbox/InteractiveBrowser.d.mts","default":"./dist/sandbox/InteractiveBrowser.mjs"},"./mcp":{"types":"./dist/capabilities/Mcp.d.mts","default":"./dist/capabilities/Mcp.mjs"},"./mcp-client":{"types":"./dist/capabilities/McpClient.d.mts","default":"./dist/capabilities/McpClient.mjs"},"./memory":{"types":"./dist/core/Memory.d.mts","default":"./dist/core/Memory.mjs"},"./memory-namespace":{"types":"./dist/core/MemoryNamespace.d.mts","default":"./dist/core/MemoryNamespace.mjs"},"./memory-notes":{"types":"./dist/capabilities/MemoryNotes.d.mts","default":"./dist/capabilities/MemoryNotes.mjs"},"./memory-reference":{"types":"./dist/core/MemoryReference.d.mts","default":"./dist/core/MemoryReference.mjs"},"./memory-revalidation":{"types":"./dist/core/MemoryRevalidation.d.mts","default":"./dist/core/MemoryRevalidation.mjs"},"./memory-store":{"types":"./dist/core/MemoryStore.d.mts","default":"./dist/core/MemoryStore.mjs"},"./message-delivery":{"types":"./dist/durable/MessageDelivery.d.mts","default":"./dist/durable/MessageDelivery.mjs"},"./messaging":{"types":"./dist/capabilities/Messaging.d.mts","default":"./dist/capabilities/Messaging.mjs"},"./messaging-host":{"types":"./dist/engine/MessagingHost.d.mts","default":"./dist/engine/MessagingHost.mjs"},"./model-context":{"types":"./dist/capabilities/ModelContext.d.mts","default":"./dist/capabilities/ModelContext.mjs"},"./operation-authorizer":{"types":"./dist/durable/OperationAuthorizer.d.mts","default":"./dist/durable/OperationAuthorizer.mjs"},"./output":{"types":"./dist/engine/Output.d.mts","default":"./dist/engine/Output.mjs"},"./page-capture":{"types":"./dist/sandbox/PageCapture.d.mts","default":"./dist/sandbox/PageCapture.mjs"},"./page-crawl":{"types":"./dist/sandbox/PageCrawl.d.mts","default":"./dist/sandbox/PageCrawl.mjs"},"./page-screenshot":{"types":"./dist/sandbox/PageScreenshot.d.mts","default":"./dist/sandbox/PageScreenshot.mjs"},"./persistent-history":{"types":"./dist/durable/PersistentHistory.d.mts","default":"./dist/durable/PersistentHistory.mjs"},"./prepared-input-admission":{"types":"./dist/durable/PreparedInputAdmission.d.mts","default":"./dist/durable/PreparedInputAdmission.mjs"},"./provisional-text":{"types":"./dist/core/ProvisionalText.d.mts","default":"./dist/core/ProvisionalText.mjs"},"./receipt":{"types":"./dist/core/Receipt.d.mts","default":"./dist/core/Receipt.mjs"},"./records":{"types":"./dist/durable/Records.d.mts","default":"./dist/durable/Records.mjs"},"./recovery":{"types":"./dist/durable/Recovery.d.mts","default":"./dist/durable/Recovery.mjs"},"./redaction":{"types":"./dist/capabilities/Redaction.d.mts","default":"./dist/capabilities/Redaction.mjs"},"./remembering":{"types":"./dist/capabilities/Remembering.d.mts","default":"./dist/capabilities/Remembering.mjs"},"./remembering-store":{"types":"./dist/core/RememberingStore.d.mts","default":"./dist/core/RememberingStore.mjs"},"./run-event":{"types":"./dist/core/RunEvent.d.mts","default":"./dist/core/RunEvent.mjs"},"./run-event-sink":{"types":"./dist/engine/RunEventSink.d.mts","default":"./dist/engine/RunEventSink.mjs"},"./run-hooks":{"types":"./dist/capabilities/RunHooks.d.mts","default":"./dist/capabilities/RunHooks.mjs"},"./run-journal":{"types":"./dist/durable/RunJournal.d.mts","default":"./dist/durable/RunJournal.mjs"},"./run-continuation":{"types":"./dist/durable/RunContinuation.d.mts","default":"./dist/durable/RunContinuation.mjs"},"./thread-work":{"types":"./dist/durable/ThreadWork.d.mts","default":"./dist/durable/ThreadWork.mjs"},"./run-options":{"types":"./dist/engine/RunOptions.d.mts","default":"./dist/engine/RunOptions.mjs"},"./run-policy-usage":{"types":"./dist/core/RunPolicyUsage.d.mts","default":"./dist/core/RunPolicyUsage.mjs"},"./run-storage":{"types":"./dist/durable/RunStorage.d.mts","default":"./dist/durable/RunStorage.mjs"},"./sandbox":{"types":"./dist/sandbox/Sandbox.d.mts","default":"./dist/sandbox/Sandbox.mjs"},"./schedule":{"types":"./dist/durable/Schedule.d.mts","default":"./dist/durable/Schedule.mjs"},"./schedule-transition":{"types":"./dist/durable/ScheduleTransition.d.mts","default":"./dist/durable/ScheduleTransition.mjs"},"./scheduling":{"types":"./dist/durable/Scheduling.d.mts","default":"./dist/durable/Scheduling.mjs"},"./semantic-memory":{"types":"./dist/capabilities/SemanticMemory.d.mts","default":"./dist/capabilities/SemanticMemory.mjs"},"./semantic-memory-index":{"types":"./dist/core/SemanticMemoryIndex.d.mts","default":"./dist/core/SemanticMemoryIndex.mjs"},"./semantic-memory-revalidation":{"types":"./dist/core/SemanticMemoryRevalidation.d.mts","default":"./dist/core/SemanticMemoryRevalidation.mjs"},"./settlement-publisher":{"types":"./dist/durable/SettlementPublisher.d.mts","default":"./dist/durable/SettlementPublisher.mjs"},"./sql-memory-store":{"types":"./dist/durable/SqlMemoryStore.d.mts","default":"./dist/durable/SqlMemoryStore.mjs"},"./subagent":{"types":"./dist/capabilities/Subagent.d.mts","default":"./dist/capabilities/Subagent.mjs"},"./subagent-contract":{"types":"./dist/core/SubagentContract.d.mts","default":"./dist/core/SubagentContract.mjs"},"./subagent-host":{"types":"./dist/engine/SubagentHost.d.mts","default":"./dist/engine/SubagentHost.mjs"},"./subagent-reservations":{"types":"./dist/capabilities/SubagentReservations.d.mts","default":"./dist/capabilities/SubagentReservations.mjs"},"./submission-ledger":{"types":"./dist/durable/SubmissionLedger.d.mts","default":"./dist/durable/SubmissionLedger.mjs"},"./submission-status":{"types":"./dist/durable/SubmissionStatus.d.mts","default":"./dist/durable/SubmissionStatus.mjs"},"./subscription":{"types":"./dist/durable/Subscription.d.mts","default":"./dist/durable/Subscription.mjs"},"./subscription-input":{"types":"./dist/durable/SubscriptionInput.d.mts","default":"./dist/durable/SubscriptionInput.mjs"},"./subscription-tools":{"types":"./dist/durable/SubscriptionTools.d.mts","default":"./dist/durable/SubscriptionTools.mjs"},"./subscription-transition":{"types":"./dist/durable/SubscriptionTransition.d.mts","default":"./dist/durable/SubscriptionTransition.mjs"},"./subscriptions":{"types":"./dist/durable/Subscriptions.d.mts","default":"./dist/durable/Subscriptions.mjs"},"./testing/certification":{"types":"./dist/durable/Certification.d.mts","default":"./dist/durable/Certification.mjs"},"./testing/durable-failpoint-test-control":{"types":"./dist/durable/DurableFailpointTestControl.d.mts","default":"./dist/durable/DurableFailpointTestControl.mjs"},"./testing/message-delivery-store-conformance":{"types":"./dist/durable/MessageDeliveryStoreConformance.d.mts","default":"./dist/durable/MessageDeliveryStoreConformance.mjs"},"./testing/schedule-store-conformance":{"types":"./dist/durable/ScheduleStoreConformance.d.mts","default":"./dist/durable/ScheduleStoreConformance.mjs"},"./testing/submission-ledger-conformance":{"types":"./dist/durable/SubmissionLedgerConformance.d.mts","default":"./dist/durable/SubmissionLedgerConformance.mjs"},"./testing/subscription-store-conformance":{"types":"./dist/durable/SubscriptionStoreConformance.d.mts","default":"./dist/durable/SubscriptionStoreConformance.mjs"},"./testing/thread-store-conformance":{"types":"./dist/durable/ThreadStoreConformance.d.mts","default":"./dist/durable/ThreadStoreConformance.mjs"},"./thread":{"types":"./dist/core/Thread.d.mts","default":"./dist/core/Thread.mjs"},"./thread-context-history":{"types":"./dist/durable/ThreadContextHistory.d.mts","default":"./dist/durable/ThreadContextHistory.mjs"},"./thread-context-history-projection":{"types":"./dist/durable/ThreadContextHistoryProjection.d.mts","default":"./dist/durable/ThreadContextHistoryProjection.mjs"},"./thread-history":{"types":"./dist/engine/ThreadHistory.d.mts","default":"./dist/engine/ThreadHistory.mjs"},"./thread-invariants":{"types":"./dist/durable/ThreadInvariants.d.mts","default":"./dist/durable/ThreadInvariants.mjs"},"./thread-projection":{"types":"./dist/durable/ThreadProjection.d.mts","default":"./dist/durable/ThreadProjection.mjs"},"./thread-projection-maintenance":{"types":"./dist/durable/ThreadProjectionMaintenance.d.mts","default":"./dist/durable/ThreadProjectionMaintenance.mjs"},"./thread-reader":{"types":"./dist/durable/ThreadReader.d.mts","default":"./dist/durable/ThreadReader.mjs"},"./thread-store":{"types":"./dist/durable/ThreadStore.d.mts","default":"./dist/durable/ThreadStore.mjs"},"./tool-broker":{"types":"./dist/engine/ToolBroker.d.mts","default":"./dist/engine/ToolBroker.mjs"},"./tool-discovery":{"types":"./dist/capabilities/ToolDiscovery.d.mts","default":"./dist/capabilities/ToolDiscovery.mjs"},"./tool-exposure":{"types":"./dist/ToolExposure.d.mts","default":"./dist/ToolExposure.mjs"},"./tool-reconciler":{"types":"./dist/durable/ToolReconciler.d.mts","default":"./dist/durable/ToolReconciler.mjs"},"./tool-result":{"types":"./dist/core/ToolResult.d.mts","default":"./dist/core/ToolResult.mjs"},"./usage":{"types":"./dist/core/Usage.d.mts","default":"./dist/core/Usage.mjs"},"./wake-scheduler":{"types":"./dist/durable/WakeScheduler.d.mts","default":"./dist/durable/WakeScheduler.mjs"},"./web-capture":{"types":"./dist/capabilities/WebCapture.d.mts","default":"./dist/capabilities/WebCapture.mjs"},"./web-search":{"types":"./dist/capabilities/WebSearch.d.mts","default":"./dist/capabilities/WebSearch.mjs"},"./worker":{"types":"./dist/core/Worker.d.mts","default":"./dist/core/Worker.mjs"},"./worker-admission":{"types":"./dist/durable/WorkerAdmission.d.mts","default":"./dist/durable/WorkerAdmission.mjs"},"./worker-host":{"types":"./dist/durable/WorkerHost.d.mts","default":"./dist/durable/WorkerHost.mjs"},"./lifecycle-publication":{"types":"./dist/durable/LifecyclePublication.d.mts","default":"./dist/durable/LifecyclePublication.mjs"},"./record-format":{"types":"./dist/durable/RecordFormat.d.mts","default":"./dist/durable/RecordFormat.mjs"},"./thread-import":{"types":"./dist/durable/ThreadImport.d.mts","default":"./dist/durable/ThreadImport.mjs"},"./thread-archive-range":{"types":"./dist/durable/ThreadArchiveRange.d.mts","default":"./dist/durable/ThreadArchiveRange.mjs"},"./thread-transfer":{"types":"./dist/durable/ThreadTransfer.d.mts","default":"./dist/durable/ThreadTransfer.mjs"}},"description":"Effect-native agents, execution, subagents, and sandbox contracts in one tree-shakeable package.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/yielded-dev/agent.git","directory":"packages/effect-agent"},"files":["dist","src"],"type":"module","sideEffects":[],"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"tsc --noEmit -p tsconfig.json","test":"vp test --passWithNoTests"}}
1
+ {"name":"@yielded/agent","version":"0.1.0-beta.175","devDependencies":{"@effect/platform-node":"4.0.3","@effect/vitest":"4.0.3","effect":"4.0.3","typescript":"7.0.2","vite":"npm:@voidzero-dev/vite-plus-core@1.1.0","vite-plus":"1.1.0","vitest":"5.0.3"},"peerDependencies":{"effect":"^4.0.3"},"exports":{".":{"types":"./dist/index.d.mts","default":"./dist/index.mjs"},"./activity-store":{"types":"./dist/durable/ActivityStore.d.mts","default":"./dist/durable/ActivityStore.mjs"},"./admin":{"types":"./dist/durable/Admin.d.mts","default":"./dist/durable/Admin.mjs"},"./agent":{"types":"./dist/core/Agent.d.mts","default":"./dist/core/Agent.mjs"},"./agent-error":{"types":"./dist/core/AgentError.d.mts","default":"./dist/core/AgentError.mjs"},"./agent-policy":{"types":"./dist/core/AgentPolicy.d.mts","default":"./dist/core/AgentPolicy.mjs"},"./agent-registration":{"types":"./dist/durable/AgentRegistration.d.mts","default":"./dist/durable/AgentRegistration.mjs"},"./agent-runtime":{"types":"./dist/engine/AgentRuntime.d.mts","default":"./dist/engine/AgentRuntime.mjs"},"./agent-updates":{"types":"./dist/core/AgentUpdates.d.mts","default":"./dist/core/AgentUpdates.mjs"},"./approval":{"types":"./dist/capabilities/Approval.d.mts","default":"./dist/capabilities/Approval.mjs"},"./browser-use":{"types":"./dist/capabilities/BrowserUse.d.mts","default":"./dist/capabilities/BrowserUse.mjs"},"./budget":{"types":"./dist/capabilities/Budget.d.mts","default":"./dist/capabilities/Budget.mjs"},"./code-executor":{"types":"./dist/sandbox/CodeExecutor.d.mts","default":"./dist/sandbox/CodeExecutor.mjs"},"./code-mode":{"types":"./dist/capabilities/CodeMode.d.mts","default":"./dist/capabilities/CodeMode.mjs"},"./commands":{"types":"./dist/capabilities/Commands.d.mts","default":"./dist/capabilities/Commands.mjs"},"./committed-activity":{"types":"./dist/durable/CommittedActivity.d.mts","default":"./dist/durable/CommittedActivity.mjs"},"./compaction":{"types":"./dist/engine/Compaction.d.mts","default":"./dist/engine/Compaction.mjs"},"./context-compactor":{"types":"./dist/engine/ContextCompactor.d.mts","default":"./dist/engine/ContextCompactor.mjs"},"./context-history":{"types":"./dist/engine/ContextHistory.d.mts","default":"./dist/engine/ContextHistory.mjs"},"./context-tools":{"types":"./dist/capabilities/ContextTools.d.mts","default":"./dist/capabilities/ContextTools.mjs"},"./context-window":{"types":"./dist/engine/ContextWindow.d.mts","default":"./dist/engine/ContextWindow.mjs"},"./digest":{"types":"./dist/durable/Digest.d.mts","default":"./dist/durable/Digest.mjs"},"./durable-agent-runtime":{"types":"./dist/durable/DurableAgentRuntime.d.mts","default":"./dist/durable/DurableAgentRuntime.mjs"},"./durable-failpoint":{"types":"./dist/durable/DurableFailpoint.d.mts","default":"./dist/durable/DurableFailpoint.mjs"},"./durable-step":{"types":"./dist/engine/DurableStep.d.mts","default":"./dist/engine/DurableStep.mjs"},"./event-source":{"types":"./dist/durable/EventSource.d.mts","default":"./dist/durable/EventSource.mjs"},"./failure-diagnostic":{"types":"./dist/core/FailureDiagnostic.d.mts","default":"./dist/core/FailureDiagnostic.mjs"},"./git-hub-workflow-source":{"types":"./dist/durable/GitHubWorkflowSource.d.mts","default":"./dist/durable/GitHubWorkflowSource.mjs"},"./id-generator":{"types":"./dist/core/IdGenerator.d.mts","default":"./dist/core/IdGenerator.mjs"},"./identifiers":{"types":"./dist/core/Identifiers.d.mts","default":"./dist/core/Identifiers.mjs"},"./in-memory":{"types":"./dist/InMemory.d.mts","default":"./dist/InMemory.mjs"},"./interactive-browser":{"types":"./dist/sandbox/InteractiveBrowser.d.mts","default":"./dist/sandbox/InteractiveBrowser.mjs"},"./mcp":{"types":"./dist/capabilities/Mcp.d.mts","default":"./dist/capabilities/Mcp.mjs"},"./mcp-client":{"types":"./dist/capabilities/McpClient.d.mts","default":"./dist/capabilities/McpClient.mjs"},"./memory":{"types":"./dist/core/Memory.d.mts","default":"./dist/core/Memory.mjs"},"./memory-namespace":{"types":"./dist/core/MemoryNamespace.d.mts","default":"./dist/core/MemoryNamespace.mjs"},"./memory-notes":{"types":"./dist/capabilities/MemoryNotes.d.mts","default":"./dist/capabilities/MemoryNotes.mjs"},"./memory-reference":{"types":"./dist/core/MemoryReference.d.mts","default":"./dist/core/MemoryReference.mjs"},"./memory-revalidation":{"types":"./dist/core/MemoryRevalidation.d.mts","default":"./dist/core/MemoryRevalidation.mjs"},"./memory-store":{"types":"./dist/core/MemoryStore.d.mts","default":"./dist/core/MemoryStore.mjs"},"./message-delivery":{"types":"./dist/durable/MessageDelivery.d.mts","default":"./dist/durable/MessageDelivery.mjs"},"./messaging":{"types":"./dist/capabilities/Messaging.d.mts","default":"./dist/capabilities/Messaging.mjs"},"./messaging-host":{"types":"./dist/engine/MessagingHost.d.mts","default":"./dist/engine/MessagingHost.mjs"},"./model-context":{"types":"./dist/capabilities/ModelContext.d.mts","default":"./dist/capabilities/ModelContext.mjs"},"./operation-authorizer":{"types":"./dist/durable/OperationAuthorizer.d.mts","default":"./dist/durable/OperationAuthorizer.mjs"},"./output":{"types":"./dist/engine/Output.d.mts","default":"./dist/engine/Output.mjs"},"./page-capture":{"types":"./dist/sandbox/PageCapture.d.mts","default":"./dist/sandbox/PageCapture.mjs"},"./page-crawl":{"types":"./dist/sandbox/PageCrawl.d.mts","default":"./dist/sandbox/PageCrawl.mjs"},"./page-screenshot":{"types":"./dist/sandbox/PageScreenshot.d.mts","default":"./dist/sandbox/PageScreenshot.mjs"},"./persistent-history":{"types":"./dist/durable/PersistentHistory.d.mts","default":"./dist/durable/PersistentHistory.mjs"},"./prepared-input-admission":{"types":"./dist/durable/PreparedInputAdmission.d.mts","default":"./dist/durable/PreparedInputAdmission.mjs"},"./provisional-text":{"types":"./dist/core/ProvisionalText.d.mts","default":"./dist/core/ProvisionalText.mjs"},"./receipt":{"types":"./dist/core/Receipt.d.mts","default":"./dist/core/Receipt.mjs"},"./records":{"types":"./dist/durable/Records.d.mts","default":"./dist/durable/Records.mjs"},"./recovery":{"types":"./dist/durable/Recovery.d.mts","default":"./dist/durable/Recovery.mjs"},"./redaction":{"types":"./dist/capabilities/Redaction.d.mts","default":"./dist/capabilities/Redaction.mjs"},"./remembering":{"types":"./dist/capabilities/Remembering.d.mts","default":"./dist/capabilities/Remembering.mjs"},"./remembering-store":{"types":"./dist/core/RememberingStore.d.mts","default":"./dist/core/RememberingStore.mjs"},"./run-event":{"types":"./dist/core/RunEvent.d.mts","default":"./dist/core/RunEvent.mjs"},"./run-event-sink":{"types":"./dist/engine/RunEventSink.d.mts","default":"./dist/engine/RunEventSink.mjs"},"./run-hooks":{"types":"./dist/capabilities/RunHooks.d.mts","default":"./dist/capabilities/RunHooks.mjs"},"./run-journal":{"types":"./dist/durable/RunJournal.d.mts","default":"./dist/durable/RunJournal.mjs"},"./run-continuation":{"types":"./dist/durable/RunContinuation.d.mts","default":"./dist/durable/RunContinuation.mjs"},"./thread-work":{"types":"./dist/durable/ThreadWork.d.mts","default":"./dist/durable/ThreadWork.mjs"},"./run-options":{"types":"./dist/engine/RunOptions.d.mts","default":"./dist/engine/RunOptions.mjs"},"./run-policy-usage":{"types":"./dist/core/RunPolicyUsage.d.mts","default":"./dist/core/RunPolicyUsage.mjs"},"./run-storage":{"types":"./dist/durable/RunStorage.d.mts","default":"./dist/durable/RunStorage.mjs"},"./sandbox":{"types":"./dist/sandbox/Sandbox.d.mts","default":"./dist/sandbox/Sandbox.mjs"},"./schedule":{"types":"./dist/durable/Schedule.d.mts","default":"./dist/durable/Schedule.mjs"},"./schedule-transition":{"types":"./dist/durable/ScheduleTransition.d.mts","default":"./dist/durable/ScheduleTransition.mjs"},"./scheduling":{"types":"./dist/durable/Scheduling.d.mts","default":"./dist/durable/Scheduling.mjs"},"./semantic-memory":{"types":"./dist/capabilities/SemanticMemory.d.mts","default":"./dist/capabilities/SemanticMemory.mjs"},"./semantic-memory-index":{"types":"./dist/core/SemanticMemoryIndex.d.mts","default":"./dist/core/SemanticMemoryIndex.mjs"},"./semantic-memory-revalidation":{"types":"./dist/core/SemanticMemoryRevalidation.d.mts","default":"./dist/core/SemanticMemoryRevalidation.mjs"},"./settlement-publisher":{"types":"./dist/durable/SettlementPublisher.d.mts","default":"./dist/durable/SettlementPublisher.mjs"},"./sql-memory-store":{"types":"./dist/durable/SqlMemoryStore.d.mts","default":"./dist/durable/SqlMemoryStore.mjs"},"./subagent":{"types":"./dist/capabilities/Subagent.d.mts","default":"./dist/capabilities/Subagent.mjs"},"./subagent-contract":{"types":"./dist/core/SubagentContract.d.mts","default":"./dist/core/SubagentContract.mjs"},"./subagent-host":{"types":"./dist/engine/SubagentHost.d.mts","default":"./dist/engine/SubagentHost.mjs"},"./subagent-reservations":{"types":"./dist/capabilities/SubagentReservations.d.mts","default":"./dist/capabilities/SubagentReservations.mjs"},"./submission-ledger":{"types":"./dist/durable/SubmissionLedger.d.mts","default":"./dist/durable/SubmissionLedger.mjs"},"./submission-status":{"types":"./dist/durable/SubmissionStatus.d.mts","default":"./dist/durable/SubmissionStatus.mjs"},"./subscription":{"types":"./dist/durable/Subscription.d.mts","default":"./dist/durable/Subscription.mjs"},"./subscription-input":{"types":"./dist/durable/SubscriptionInput.d.mts","default":"./dist/durable/SubscriptionInput.mjs"},"./subscription-tools":{"types":"./dist/durable/SubscriptionTools.d.mts","default":"./dist/durable/SubscriptionTools.mjs"},"./subscription-transition":{"types":"./dist/durable/SubscriptionTransition.d.mts","default":"./dist/durable/SubscriptionTransition.mjs"},"./subscriptions":{"types":"./dist/durable/Subscriptions.d.mts","default":"./dist/durable/Subscriptions.mjs"},"./testing/certification":{"types":"./dist/durable/Certification.d.mts","default":"./dist/durable/Certification.mjs"},"./testing/durable-failpoint-test-control":{"types":"./dist/durable/DurableFailpointTestControl.d.mts","default":"./dist/durable/DurableFailpointTestControl.mjs"},"./testing/message-delivery-store-conformance":{"types":"./dist/durable/MessageDeliveryStoreConformance.d.mts","default":"./dist/durable/MessageDeliveryStoreConformance.mjs"},"./testing/schedule-store-conformance":{"types":"./dist/durable/ScheduleStoreConformance.d.mts","default":"./dist/durable/ScheduleStoreConformance.mjs"},"./testing/submission-ledger-conformance":{"types":"./dist/durable/SubmissionLedgerConformance.d.mts","default":"./dist/durable/SubmissionLedgerConformance.mjs"},"./testing/subscription-store-conformance":{"types":"./dist/durable/SubscriptionStoreConformance.d.mts","default":"./dist/durable/SubscriptionStoreConformance.mjs"},"./testing/thread-store-conformance":{"types":"./dist/durable/ThreadStoreConformance.d.mts","default":"./dist/durable/ThreadStoreConformance.mjs"},"./thread":{"types":"./dist/core/Thread.d.mts","default":"./dist/core/Thread.mjs"},"./thread-context-history":{"types":"./dist/durable/ThreadContextHistory.d.mts","default":"./dist/durable/ThreadContextHistory.mjs"},"./thread-context-history-projection":{"types":"./dist/durable/ThreadContextHistoryProjection.d.mts","default":"./dist/durable/ThreadContextHistoryProjection.mjs"},"./thread-history":{"types":"./dist/engine/ThreadHistory.d.mts","default":"./dist/engine/ThreadHistory.mjs"},"./thread-invariants":{"types":"./dist/durable/ThreadInvariants.d.mts","default":"./dist/durable/ThreadInvariants.mjs"},"./thread-projection":{"types":"./dist/durable/ThreadProjection.d.mts","default":"./dist/durable/ThreadProjection.mjs"},"./thread-projection-maintenance":{"types":"./dist/durable/ThreadProjectionMaintenance.d.mts","default":"./dist/durable/ThreadProjectionMaintenance.mjs"},"./thread-reader":{"types":"./dist/durable/ThreadReader.d.mts","default":"./dist/durable/ThreadReader.mjs"},"./thread-store":{"types":"./dist/durable/ThreadStore.d.mts","default":"./dist/durable/ThreadStore.mjs"},"./tool-broker":{"types":"./dist/engine/ToolBroker.d.mts","default":"./dist/engine/ToolBroker.mjs"},"./tool-discovery":{"types":"./dist/capabilities/ToolDiscovery.d.mts","default":"./dist/capabilities/ToolDiscovery.mjs"},"./tool-exposure":{"types":"./dist/ToolExposure.d.mts","default":"./dist/ToolExposure.mjs"},"./tool-reconciler":{"types":"./dist/durable/ToolReconciler.d.mts","default":"./dist/durable/ToolReconciler.mjs"},"./tool-result":{"types":"./dist/core/ToolResult.d.mts","default":"./dist/core/ToolResult.mjs"},"./usage":{"types":"./dist/core/Usage.d.mts","default":"./dist/core/Usage.mjs"},"./wake-scheduler":{"types":"./dist/durable/WakeScheduler.d.mts","default":"./dist/durable/WakeScheduler.mjs"},"./web-capture":{"types":"./dist/capabilities/WebCapture.d.mts","default":"./dist/capabilities/WebCapture.mjs"},"./web-search":{"types":"./dist/capabilities/WebSearch.d.mts","default":"./dist/capabilities/WebSearch.mjs"},"./worker":{"types":"./dist/core/Worker.d.mts","default":"./dist/core/Worker.mjs"},"./worker-admission":{"types":"./dist/durable/WorkerAdmission.d.mts","default":"./dist/durable/WorkerAdmission.mjs"},"./worker-host":{"types":"./dist/durable/WorkerHost.d.mts","default":"./dist/durable/WorkerHost.mjs"},"./lifecycle-publication":{"types":"./dist/durable/LifecyclePublication.d.mts","default":"./dist/durable/LifecyclePublication.mjs"},"./record-format":{"types":"./dist/durable/RecordFormat.d.mts","default":"./dist/durable/RecordFormat.mjs"},"./thread-import":{"types":"./dist/durable/ThreadImport.d.mts","default":"./dist/durable/ThreadImport.mjs"},"./thread-archive-range":{"types":"./dist/durable/ThreadArchiveRange.d.mts","default":"./dist/durable/ThreadArchiveRange.mjs"},"./thread-transfer":{"types":"./dist/durable/ThreadTransfer.d.mts","default":"./dist/durable/ThreadTransfer.mjs"}},"description":"Effect-native agents, execution, subagents, and sandbox contracts in one tree-shakeable package.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/yielded-dev/agent.git","directory":"packages/effect-agent"},"files":["dist","src"],"type":"module","sideEffects":[],"publishConfig":{"access":"public"},"scripts":{"build":"vp pack","check":"tsc --noEmit -p tsconfig.json","test":"vp test --passWithNoTests"}}