effect-agent 0.1.0-beta.139 → 0.1.0-beta.140
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Admin-Fx85KT-W.d.mts → Admin-DGZXE5BU.d.mts} +7 -7
- package/dist/Agent-1DMSO_Fl.mjs.map +1 -1
- package/dist/{Agent-D9cXqfF3.d.mts → Agent-BWhD4Dvu.d.mts} +5 -2
- package/dist/{AgentRuntime-DEDvMkAR.d.mts → AgentRuntime-B4kIzmSF.d.mts} +5 -5
- package/dist/{AgentRuntime-Cp1hAb-W.mjs → AgentRuntime-RdmnK_aD.mjs} +5 -5
- package/dist/AgentRuntime-RdmnK_aD.mjs.map +1 -0
- package/dist/{DurableAgentRuntime-Bso5grIH.mjs → DurableAgentRuntime-BmG_UVZG.mjs} +2 -2
- package/dist/{DurableAgentRuntime-Bso5grIH.mjs.map → DurableAgentRuntime-BmG_UVZG.mjs.map} +1 -1
- package/dist/{EventSource-DLT8oDK8.d.mts → EventSource-Cg3IeJa6.d.mts} +2 -2
- package/dist/{Messaging-JYYN3oYS.d.mts → Messaging-Dnmk31yq.d.mts} +3 -3
- package/dist/{MessagingHost-CqzpxbGz.d.mts → MessagingHost-CajpPDPG.d.mts} +2 -2
- package/dist/{Output-V-6YL1_Z.d.mts → Output-DhtWbBcw.d.mts} +2 -2
- package/dist/{PreparedInputAdmission-CKFgG6Em.d.mts → PreparedInputAdmission-CLvaruRe.d.mts} +3 -3
- package/dist/{RunOptions-CSBsSj0X.d.mts → RunOptions-IlEXLG5F.d.mts} +2 -2
- package/dist/{Subagent-DJeZDrbD.mjs → Subagent-Bnc7I-kb.mjs} +2 -2
- package/dist/{Subagent-DJeZDrbD.mjs.map → Subagent-Bnc7I-kb.mjs.map} +1 -1
- package/dist/{Subagent-DRFyQxdb.d.mts → Subagent-Cl8D1mFM.d.mts} +5 -5
- package/dist/{SubagentHost-DQjHFGqH.d.mts → SubagentHost-B6f4PBC2.d.mts} +2 -2
- package/dist/{Subscription-CCmHgOYM.d.mts → Subscription-_VTIVN8o.d.mts} +2 -2
- package/dist/{SubscriptionInput-BFJMhu4K.d.mts → SubscriptionInput-BIH1f3Th.d.mts} +2 -2
- package/dist/capabilities/Commands.d.mts +1 -1
- package/dist/capabilities/Messaging.d.mts +1 -1
- package/dist/capabilities/RunHooks.d.mts +1 -1
- package/dist/capabilities/Subagent.d.mts +1 -1
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/core/Agent.d.mts +1 -1
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/AgentRegistration.d.mts +1 -1
- package/dist/durable/Certification.d.mts +1 -1
- package/dist/durable/CommittedActivity.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.d.mts +1 -1
- package/dist/durable/DurableAgentRuntime.mjs +1 -1
- package/dist/durable/EventSource.d.mts +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +3 -3
- package/dist/durable/MessageDelivery.d.mts +3 -3
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +1 -1
- package/dist/durable/PersistentHistory.d.mts +1 -1
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/RunJournal.d.mts +1 -1
- package/dist/durable/Scheduling.d.mts +1 -1
- package/dist/durable/SqlStorageV2Upgrade.d.mts +1 -1
- package/dist/durable/SqlSubscriptionStore.d.mts +1 -1
- package/dist/durable/SqlThreadNativeReads.d.mts +1 -1
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +1 -1
- package/dist/durable/SubscriptionInput.d.mts +1 -1
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionTools.d.mts +2 -2
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/Subscriptions.d.mts +5 -5
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadInvariants.d.mts +1 -1
- package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
- package/dist/durable/ThreadStore.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/WorkerHost.d.mts +2 -2
- package/dist/engine/AgentRuntime.d.mts +1 -1
- package/dist/engine/AgentRuntime.mjs +1 -1
- package/dist/engine/MessagingHost.d.mts +1 -1
- package/dist/engine/Output.d.mts +1 -1
- package/dist/engine/Output.mjs +1 -1
- package/dist/engine/RunOptions.d.mts +1 -1
- package/dist/engine/SubagentHost.d.mts +1 -1
- package/dist/index.d.mts +13 -13
- package/dist/index.mjs +3 -3
- package/dist/{output-contract-BC7tjlGw.mjs → output-contract-CANJJGA5.mjs} +34 -19
- package/dist/{output-contract-BC7tjlGw.mjs.map → output-contract-CANJJGA5.mjs.map} +1 -1
- package/package.json +1 -1
- package/src/core/Agent.ts +4 -1
- package/src/engine/internal/agent-runtime.ts +12 -8
- package/src/engine/internal/output-contract.ts +36 -18
- package/dist/AgentRuntime-Cp1hAb-W.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -20,14 +20,14 @@ import { a as FailureDiagnostic_d_exports } from "./FailureDiagnostic-CaAkzGHL.m
|
|
|
20
20
|
import { i as AgentError_d_exports } from "./AgentError-Bn1ytXRD.mjs";
|
|
21
21
|
import { r as ToolResult_d_exports } from "./ToolResult-BKdqWRff.mjs";
|
|
22
22
|
import { r as AgentPolicy_d_exports } from "./AgentPolicy-BqDoSXO6.mjs";
|
|
23
|
-
import { t as Agent_d_exports } from "./Agent-
|
|
23
|
+
import { t as Agent_d_exports } from "./Agent-BWhD4Dvu.mjs";
|
|
24
24
|
import { c as MemoryReference_d_exports } from "./MemoryReference-B8Q3UJoJ.mjs";
|
|
25
25
|
import { n as RunPolicyUsage_d_exports } from "./RunPolicyUsage-ClZxyR46.mjs";
|
|
26
26
|
import { x as Worker_d_exports } from "./Worker-fwWkBg12.mjs";
|
|
27
27
|
import { s as ContextWindow_d_exports } from "./ContextWindow-DRQ5Mbm2.mjs";
|
|
28
28
|
import { s as ContextCompactor_d_exports } from "./ContextCompactor-WwSIG_Z2.mjs";
|
|
29
29
|
import { i as DurableStep_d_exports } from "./DurableStep-Cry_iol4.mjs";
|
|
30
|
-
import { F as RunOptions_d_exports } from "./RunOptions-
|
|
30
|
+
import { F as RunOptions_d_exports } from "./RunOptions-IlEXLG5F.mjs";
|
|
31
31
|
import { t as Commands_d_exports } from "./capabilities/Commands.mjs";
|
|
32
32
|
import { t as ContextHistory_d_exports } from "./engine/ContextHistory.mjs";
|
|
33
33
|
import { t as ContextTools_d_exports } from "./capabilities/ContextTools.mjs";
|
|
@@ -36,8 +36,8 @@ import { t as McpClient_d_exports } from "./capabilities/McpClient.mjs";
|
|
|
36
36
|
import { i as MemoryNamespace_d_exports } from "./MemoryNamespace-BbRW5p71.mjs";
|
|
37
37
|
import { t as MemoryStore_d_exports } from "./core/MemoryStore.mjs";
|
|
38
38
|
import { t as MemoryNotes_d_exports } from "./capabilities/MemoryNotes.mjs";
|
|
39
|
-
import { n as MessagingHost_d_exports } from "./MessagingHost-
|
|
40
|
-
import { t as Messaging_d_exports } from "./Messaging-
|
|
39
|
+
import { n as MessagingHost_d_exports } from "./MessagingHost-CajpPDPG.mjs";
|
|
40
|
+
import { t as Messaging_d_exports } from "./Messaging-Dnmk31yq.mjs";
|
|
41
41
|
import { t as ModelContext_d_exports } from "./capabilities/ModelContext.mjs";
|
|
42
42
|
import { t as RememberingStore_d_exports } from "./core/RememberingStore.mjs";
|
|
43
43
|
import { t as Remembering_d_exports } from "./capabilities/Remembering.mjs";
|
|
@@ -46,10 +46,10 @@ import { t as MemoryRevalidation_d_exports } from "./core/MemoryRevalidation.mjs
|
|
|
46
46
|
import { t as SemanticMemoryIndex_d_exports } from "./core/SemanticMemoryIndex.mjs";
|
|
47
47
|
import { t as SemanticMemoryRevalidation_d_exports } from "./core/SemanticMemoryRevalidation.mjs";
|
|
48
48
|
import { t as SemanticMemory_d_exports } from "./capabilities/SemanticMemory.mjs";
|
|
49
|
-
import { s as SubagentHost_d_exports } from "./SubagentHost-
|
|
50
|
-
import { t as AgentRuntime_d_exports } from "./AgentRuntime-
|
|
49
|
+
import { s as SubagentHost_d_exports } from "./SubagentHost-B6f4PBC2.mjs";
|
|
50
|
+
import { t as AgentRuntime_d_exports } from "./AgentRuntime-B4kIzmSF.mjs";
|
|
51
51
|
import { i as RunEventSink_d_exports } from "./RunEventSink-D5aVhISG.mjs";
|
|
52
|
-
import { v as Subagent_d_exports } from "./Subagent-
|
|
52
|
+
import { v as Subagent_d_exports } from "./Subagent-Cl8D1mFM.mjs";
|
|
53
53
|
import { t as ToolDiscovery_d_exports } from "./capabilities/ToolDiscovery.mjs";
|
|
54
54
|
import { D as PageCapture_d_exports } from "./PageCapture-Df8Xwskw.mjs";
|
|
55
55
|
import { t as WebCapture_d_exports } from "./capabilities/WebCapture.mjs";
|
|
@@ -59,17 +59,17 @@ import { t as Memory_d_exports } from "./core/Memory.mjs";
|
|
|
59
59
|
import { N as Records_d_exports } from "./Records-B5GFWCpn.mjs";
|
|
60
60
|
import { t as ActivityStore_d_exports } from "./durable/ActivityStore.mjs";
|
|
61
61
|
import { n as Digest_d_exports } from "./Digest-U69rDHuO.mjs";
|
|
62
|
-
import { J as Recovery_d_exports, Qn as DurableAgentRuntime_d_exports, Sa as AgentRegistration_d_exports, Si as RunJournal_d_exports, _i as SubmissionStatus_d_exports, bn as SubmissionLedger_d_exports, oi as ThreadStore_d_exports, t as Admin_d_exports } from "./Admin-
|
|
62
|
+
import { J as Recovery_d_exports, Qn as DurableAgentRuntime_d_exports, Sa as AgentRegistration_d_exports, Si as RunJournal_d_exports, _i as SubmissionStatus_d_exports, bn as SubmissionLedger_d_exports, oi as ThreadStore_d_exports, t as Admin_d_exports } from "./Admin-DGZXE5BU.mjs";
|
|
63
63
|
import { t as DurableFailpoint_d_exports } from "./DurableFailpoint-Cnr3wx1L.mjs";
|
|
64
64
|
import { a as OperationAuthorizer_d_exports } from "./OperationAuthorizer-TzcQtpX5.mjs";
|
|
65
65
|
import { l as ToolReconciler_d_exports } from "./ToolReconciler-BmVRAHKs.mjs";
|
|
66
66
|
import { n as WakeScheduler_d_exports } from "./WakeScheduler-EjUF-GhC.mjs";
|
|
67
67
|
import { t as CommittedActivity_d_exports } from "./durable/CommittedActivity.mjs";
|
|
68
68
|
import { R as Schedule_d_exports } from "./Schedule-CtYREFnz.mjs";
|
|
69
|
-
import { k as Subscription_d_exports } from "./Subscription-
|
|
70
|
-
import { n as EventSource_d_exports } from "./EventSource-
|
|
71
|
-
import { n as PreparedInputAdmission_d_exports } from "./PreparedInputAdmission-
|
|
72
|
-
import { r as SubscriptionInput_d_exports } from "./SubscriptionInput-
|
|
69
|
+
import { k as Subscription_d_exports } from "./Subscription-_VTIVN8o.mjs";
|
|
70
|
+
import { n as EventSource_d_exports } from "./EventSource-Cg3IeJa6.mjs";
|
|
71
|
+
import { n as PreparedInputAdmission_d_exports } from "./PreparedInputAdmission-CLvaruRe.mjs";
|
|
72
|
+
import { r as SubscriptionInput_d_exports } from "./SubscriptionInput-BIH1f3Th.mjs";
|
|
73
73
|
import { t as Subscriptions_d_exports } from "./durable/Subscriptions.mjs";
|
|
74
74
|
import { t as MessageDelivery_d_exports } from "./durable/MessageDelivery.mjs";
|
|
75
75
|
import { t as PersistentHistory_d_exports } from "./durable/PersistentHistory.mjs";
|
|
@@ -85,7 +85,7 @@ import { t as ThreadProjection_d_exports } from "./durable/ThreadProjection.mjs"
|
|
|
85
85
|
import { t as ThreadProjectionMaintenance_d_exports } from "./durable/ThreadProjectionMaintenance.mjs";
|
|
86
86
|
import { t as WorkerHost_d_exports } from "./durable/WorkerHost.mjs";
|
|
87
87
|
import { t as Compaction_d_exports } from "./engine/Compaction.mjs";
|
|
88
|
-
import { t as Output_d_exports } from "./Output-
|
|
88
|
+
import { t as Output_d_exports } from "./Output-DhtWbBcw.mjs";
|
|
89
89
|
import { t as PageScreenshot_d_exports } from "./sandbox/PageScreenshot.mjs";
|
|
90
90
|
import { t as InteractiveBrowser_d_exports } from "./sandbox/InteractiveBrowser.mjs";
|
|
91
91
|
import { t as PageCrawl_d_exports } from "./sandbox/PageCrawl.mjs";
|
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import { n as MessagingHost_exports } from "./MessagingHost-DfsbMPvq.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-
|
|
18
|
+
import { t as AgentRuntime_exports } from "./AgentRuntime-RdmnK_aD.mjs";
|
|
19
19
|
import { t as ContextWindow_exports } from "./engine/ContextWindow.mjs";
|
|
20
20
|
import { t as DurableStep_exports } from "./engine/DurableStep.mjs";
|
|
21
21
|
import { t as ContextCompactor_exports } from "./engine/ContextCompactor.mjs";
|
|
@@ -56,7 +56,7 @@ import { t as RunHooks_exports } from "./capabilities/RunHooks.mjs";
|
|
|
56
56
|
import { t as SemanticMemoryIndex_exports } from "./core/SemanticMemoryIndex.mjs";
|
|
57
57
|
import { t as SemanticMemoryRevalidation_exports } from "./core/SemanticMemoryRevalidation.mjs";
|
|
58
58
|
import { t as SemanticMemory_exports } from "./capabilities/SemanticMemory.mjs";
|
|
59
|
-
import { r as Subagent_exports } from "./Subagent-
|
|
59
|
+
import { r as Subagent_exports } from "./Subagent-Bnc7I-kb.mjs";
|
|
60
60
|
import { t as ToolDiscovery_exports } from "./capabilities/ToolDiscovery.mjs";
|
|
61
61
|
import { t as ToolExposure_exports } from "./ToolExposure.mjs";
|
|
62
62
|
import { t as WebCapture_exports } from "./capabilities/WebCapture.mjs";
|
|
@@ -68,7 +68,7 @@ import { t as Recovery_exports } from "./durable/Recovery.mjs";
|
|
|
68
68
|
import { t as Admin_exports } from "./durable/Admin.mjs";
|
|
69
69
|
import { t as Digest_exports } from "./durable/Digest.mjs";
|
|
70
70
|
import { t as AgentRegistration_exports } from "./durable/AgentRegistration.mjs";
|
|
71
|
-
import { r as DurableAgentRuntime_exports } from "./DurableAgentRuntime-
|
|
71
|
+
import { r as DurableAgentRuntime_exports } from "./DurableAgentRuntime-BmG_UVZG.mjs";
|
|
72
72
|
import { n as RunJournal_exports } from "./RunJournal-Gd83HYqG.mjs";
|
|
73
73
|
import { t as ThreadStore_exports } from "./durable/ThreadStore.mjs";
|
|
74
74
|
import { t as CommittedActivity_exports } from "./durable/CommittedActivity.mjs";
|
|
@@ -56,29 +56,44 @@ const outputSchemaContract = (definition) => {
|
|
|
56
56
|
outputContracts.set(definition, contract);
|
|
57
57
|
return contract;
|
|
58
58
|
};
|
|
59
|
+
const sameSystemMessage = Schema.toEquivalence(Prompt.SystemMessage);
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
61
|
+
* Project system instructions and the output contract into one leading block.
|
|
62
|
+
* Repeated Runs append instructions to canonical history; letting those copies
|
|
63
|
+
* move the contract breaks the preceding user/tool prefix used by provider caches.
|
|
64
|
+
* Keep the last occurrence of each equivalent system message, preserving the
|
|
65
|
+
* precedence of distinct instructions and their native provider options.
|
|
66
|
+
*
|
|
67
|
+
* This runs after preparation and compaction. Canonical messages, protected
|
|
68
|
+
* instruction/input spans and compaction coverage retain their original positions.
|
|
69
|
+
* Conversation order and message identities are unchanged. A single system block
|
|
70
|
+
* also prevents Anthropic's last-system-group conversion from discarding earlier
|
|
71
|
+
* application instructions or the output contract.
|
|
70
72
|
*/
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const prepareModelPrompt = (prompt, contract) => {
|
|
74
|
+
const systems = [];
|
|
75
|
+
const conversation = [];
|
|
76
|
+
const seen = /* @__PURE__ */ new Map();
|
|
77
|
+
for (let index = prompt.content.length - 1; index >= 0; index -= 1) {
|
|
78
|
+
const message = prompt.content[index];
|
|
79
|
+
if (message === void 0) continue;
|
|
80
|
+
if (message.role !== "system") {
|
|
81
|
+
conversation.push(message);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const variants = seen.get(message.content);
|
|
85
|
+
if (variants?.some((previous) => sameSystemMessage(previous, message))) continue;
|
|
86
|
+
if (variants === void 0) seen.set(message.content, [message]);
|
|
87
|
+
else variants.push(message);
|
|
88
|
+
systems.push(message);
|
|
89
|
+
}
|
|
75
90
|
return Prompt.fromMessages([
|
|
76
|
-
...
|
|
77
|
-
|
|
78
|
-
...
|
|
91
|
+
...systems.reverse(),
|
|
92
|
+
...contract === void 0 ? [] : [contract],
|
|
93
|
+
...conversation.reverse()
|
|
79
94
|
]);
|
|
80
95
|
};
|
|
81
96
|
//#endregion
|
|
82
|
-
export { textOutput as i,
|
|
97
|
+
export { textOutput as i, outputSchemaContract as n, prepareModelPrompt as r, isTextOutput as t };
|
|
83
98
|
|
|
84
|
-
//# sourceMappingURL=output-contract-
|
|
99
|
+
//# sourceMappingURL=output-contract-CANJJGA5.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-contract-BC7tjlGw.mjs","names":[],"sources":["../src/engine/internal/output-contract.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { Prompt, Tool } from \"effect/unstable/ai\";\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\n/**\n * Insert the contract immediately after the request prompt's last system\n * message (position 0 when none exists), extending the last contiguous\n * system block. Placement is normative: the Anthropic provider replaces its\n * top-level `system` parameter per contiguous system group, so only the last\n * block survives there — an isolated trailing contract message would discard\n * the author's instructions, and a contract inside an earlier block (for\n * example a resumed Thread's original instructions ahead of this Run's\n * evaluated instructions) would itself be discarded. Extending the last\n * block keeps author content and contract together on every provider and\n * preserves the author's per-message cache-control annotations.\n */\nexport const insertOutputContract = (\n prompt: Prompt.Prompt,\n message: Prompt.SystemMessage,\n): Prompt.Prompt => {\n const content = prompt.content;\n let insertAt = 0;\n\n for (let index = 0; index < content.length; index += 1) {\n if (content[index]?.role === \"system\") {\n insertAt = index + 1;\n }\n }\n\n return Prompt.fromMessages([...content.slice(0, insertAt), message, ...content.slice(insertAt)]);\n};\n"],"mappings":";;;AAKA,MAAM,yBAAyB;;;;;;;;;;;;;AAc/B,MAAa,cACX,WACiB,OAAO,SAAS,GAAG,yBAAyB,OAAO,CAAC;AAEvE,MAAa,gBAAgB,WAC3B,OAAO,mBAAmB,MAAM,CAAC,GAAG,4BAA4B;AAoClE,MAAM,qBAAqB,eACzB,WAAW,eAAe,KAAA,IACtB,kNAGA,yEAAyE,WAAW,WAAW,KAAK,mMAErD,WAAW,WAAW,KAAK;AAEhF,MAAM,+BAA+B,MAAc,oBACjD,0BAA0B,kBAAkB,uBAAuB,gBAAgB,2CAA2C,KAAK,UAAU,IAAI,EAAE;;;;;;;;;AAYrJ,MAAM,YAAY,aAAqC;CACrD,MAAM;CACN;CACA,MAAM,OAAO,YAAY,UAAU,EAAE,SAAS,QAAQ,CAAC;AACzD;AAEA,MAAM,8BAA8B,eAAoD;CACtF,IAAI,WAAW,YAAY,aAAa,MACtC,OAAO,SACL,4BACE,WAAW,WAAW,OACrB,WAAW,qBAAqB,UAAU,KAAK,CAClD,CACF;CAEF,IAAI,aAAa,WAAW,MAAM,GAChC,OAAO,SACL,+LAEG,WAAW,eAAe,KAAA,IACvB,KACA,sBAAsB,WAAW,WAAW,KAAK,qRACzD;CAEF,IAAI;EACF,MAAM,aAAa,KAAK,wBAAwB,WAAW,MAAM;EAEjE,OAAO,SACL,GAAG,kBAAkB,UAAU,EAAE,MAAM,KAAK,UAAU,YAAY,KAAA,GAAW,CAAC,GAChF;CACF,SAAS,OAAO;EACd,OAAO;GACL,MAAM;GACN,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC/D;CACF;AACF;AAIA,MAAM,kCAAkB,IAAI,QAA6C;AAEzE,MAAa,wBAAwB,eAAoD;CACvF,MAAM,SAAS,gBAAgB,IAAI,UAAU;CAE7C,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,MAAM,OAAO,2BAA2B,UAAU;CAClD,MAAM,eAAe,WAAW,uBAAuB,CAAC;CAExD,MAAM,WACJ,KAAK,SAAS,cAAc,aAAa,SAAS,IAC9C,SACE,2FAA2F,aAAa,KAAK,gBAAgB,KAAK,UAAU,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;;IAGxK,KAAK,OACT,IACA;CAEN,gBAAgB,IAAI,YAAY,QAAQ;CAExC,OAAO;AACT;;;;;;;;;;;;;AAcA,MAAa,wBACX,QACA,YACkB;CAClB,MAAM,UAAU,OAAO;CACvB,IAAI,WAAW;CAEf,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS,GACnD,IAAI,QAAQ,MAAM,EAAE,SAAS,UAC3B,WAAW,QAAQ;CAIvB,OAAO,OAAO,aAAa;EAAC,GAAG,QAAQ,MAAM,GAAG,QAAQ;EAAG;EAAS,GAAG,QAAQ,MAAM,QAAQ;CAAC,CAAC;AACjG"}
|
|
1
|
+
{"version":3,"file":"output-contract-CANJJGA5.mjs","names":[],"sources":["../src/engine/internal/output-contract.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { Prompt, Tool } from \"effect/unstable/ai\";\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 * Project system instructions and the output contract into one leading block.\n * Repeated Runs append instructions to canonical history; letting those copies\n * move the contract breaks the preceding user/tool prefix used by provider caches.\n * Keep the last occurrence of each equivalent system message, preserving the\n * precedence of distinct instructions and their native provider options.\n *\n * This runs after preparation and compaction. Canonical messages, protected\n * instruction/input spans and compaction coverage retain their original positions.\n * Conversation order and message identities are unchanged. A single system block\n * also prevents Anthropic's last-system-group conversion from discarding earlier\n * application instructions or the output contract.\n */\nexport const prepareModelPrompt = (\n prompt: Prompt.Prompt,\n contract: Prompt.SystemMessage | undefined,\n): Prompt.Prompt => {\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":";;;AAKA,MAAM,yBAAyB;;;;;;;;;;;;;AAc/B,MAAa,cACX,WACiB,OAAO,SAAS,GAAG,yBAAyB,OAAO,CAAC;AAEvE,MAAa,gBAAgB,WAC3B,OAAO,mBAAmB,MAAM,CAAC,GAAG,4BAA4B;AAoClE,MAAM,qBAAqB,eACzB,WAAW,eAAe,KAAA,IACtB,kNAGA,yEAAyE,WAAW,WAAW,KAAK,mMAErD,WAAW,WAAW,KAAK;AAEhF,MAAM,+BAA+B,MAAc,oBACjD,0BAA0B,kBAAkB,uBAAuB,gBAAgB,2CAA2C,KAAK,UAAU,IAAI,EAAE;;;;;;;;;AAYrJ,MAAM,YAAY,aAAqC;CACrD,MAAM;CACN;CACA,MAAM,OAAO,YAAY,UAAU,EAAE,SAAS,QAAQ,CAAC;AACzD;AAEA,MAAM,8BAA8B,eAAoD;CACtF,IAAI,WAAW,YAAY,aAAa,MACtC,OAAO,SACL,4BACE,WAAW,WAAW,OACrB,WAAW,qBAAqB,UAAU,KAAK,CAClD,CACF;CAEF,IAAI,aAAa,WAAW,MAAM,GAChC,OAAO,SACL,+LAEG,WAAW,eAAe,KAAA,IACvB,KACA,sBAAsB,WAAW,WAAW,KAAK,qRACzD;CAEF,IAAI;EACF,MAAM,aAAa,KAAK,wBAAwB,WAAW,MAAM;EAEjE,OAAO,SACL,GAAG,kBAAkB,UAAU,EAAE,MAAM,KAAK,UAAU,YAAY,KAAA,GAAW,CAAC,GAChF;CACF,SAAS,OAAO;EACd,OAAO;GACL,MAAM;GACN,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC/D;CACF;AACF;AAIA,MAAM,kCAAkB,IAAI,QAA6C;AAEzE,MAAa,wBAAwB,eAAoD;CACvF,MAAM,SAAS,gBAAgB,IAAI,UAAU;CAE7C,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,MAAM,OAAO,2BAA2B,UAAU;CAClD,MAAM,eAAe,WAAW,uBAAuB,CAAC;CAExD,MAAM,WACJ,KAAK,SAAS,cAAc,aAAa,SAAS,IAC9C,SACE,2FAA2F,aAAa,KAAK,gBAAgB,KAAK,UAAU,YAAY,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;;IAGxK,KAAK,OACT,IACA;CAEN,gBAAgB,IAAI,YAAY,QAAQ;CAExC,OAAO;AACT;AAEA,MAAM,oBAAoB,OAAO,cAAc,OAAO,aAAa;;;;;;;;;;;;;;AAenE,MAAa,sBACX,QACA,aACkB;CAClB,MAAM,UAAuC,CAAC;CAC9C,MAAM,eAAsC,CAAC;CAC7C,MAAM,uBAAO,IAAI,IAAyC;CAE1D,KAAK,IAAI,QAAQ,OAAO,QAAQ,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG;EAClE,MAAM,UAAU,OAAO,QAAQ;EAE/B,IAAI,YAAY,KAAA,GAAW;EAC3B,IAAI,QAAQ,SAAS,UAAU;GAC7B,aAAa,KAAK,OAAO;GACzB;EACF;EACA,MAAM,WAAW,KAAK,IAAI,QAAQ,OAAO;EAEzC,IAAI,UAAU,MAAM,aAAa,kBAAkB,UAAU,OAAO,CAAC,GAAG;EACxE,IAAI,aAAa,KAAA,GAAW,KAAK,IAAI,QAAQ,SAAS,CAAC,OAAO,CAAC;OAC1D,SAAS,KAAK,OAAO;EAC1B,QAAQ,KAAK,OAAO;CACtB;CAEA,OAAO,OAAO,aAAa;EACzB,GAAG,QAAQ,QAAQ;EACnB,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,CAAC,QAAQ;EAC3C,GAAG,aAAa,QAAQ;CAC1B,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"effect-agent","version":"0.1.0-beta.139","devDependencies":{"@effect/platform-node":"4.0.0-rc.117","@effect/vitest":"4.0.0-rc.117","effect":"4.0.0-rc.117","typescript":"7.0.2","vite-plus":"0.3.2"},"peerDependencies":{"effect":"^4.0.0-rc.117"},"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"},"./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"},"./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-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"},"./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"},"./sql-thread-native-reads":{"types":"./dist/durable/SqlThreadNativeReads.d.mts","default":"./dist/durable/SqlThreadNativeReads.mjs"},"./sql-memory-store":{"types":"./dist/durable/SqlMemoryStore.d.mts","default":"./dist/durable/SqlMemoryStore.mjs"},"./sql-message-delivery-store":{"types":"./dist/durable/SqlMessageDeliveryStore.d.mts","default":"./dist/durable/SqlMessageDeliveryStore.mjs"},"./sql-storage-v2-upgrade":{"types":"./dist/durable/SqlStorageV2Upgrade.d.mts","default":"./dist/durable/SqlStorageV2Upgrade.mjs"},"./sql-subscription-store":{"types":"./dist/durable/SqlSubscriptionStore.d.mts","default":"./dist/durable/SqlSubscriptionStore.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-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-host":{"types":"./dist/durable/WorkerHost.d.mts","default":"./dist/durable/WorkerHost.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/danieljvdm/effect-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":"effect-agent","version":"0.1.0-beta.140","devDependencies":{"@effect/platform-node":"4.0.0-rc.117","@effect/vitest":"4.0.0-rc.117","effect":"4.0.0-rc.117","typescript":"7.0.2","vite-plus":"0.3.2"},"peerDependencies":{"effect":"^4.0.0-rc.117"},"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"},"./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"},"./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-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"},"./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"},"./sql-thread-native-reads":{"types":"./dist/durable/SqlThreadNativeReads.d.mts","default":"./dist/durable/SqlThreadNativeReads.mjs"},"./sql-memory-store":{"types":"./dist/durable/SqlMemoryStore.d.mts","default":"./dist/durable/SqlMemoryStore.mjs"},"./sql-message-delivery-store":{"types":"./dist/durable/SqlMessageDeliveryStore.d.mts","default":"./dist/durable/SqlMessageDeliveryStore.mjs"},"./sql-storage-v2-upgrade":{"types":"./dist/durable/SqlStorageV2Upgrade.d.mts","default":"./dist/durable/SqlStorageV2Upgrade.mjs"},"./sql-subscription-store":{"types":"./dist/durable/SqlSubscriptionStore.d.mts","default":"./dist/durable/SqlSubscriptionStore.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-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-host":{"types":"./dist/durable/WorkerHost.d.mts","default":"./dist/durable/WorkerHost.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/danieljvdm/effect-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"}}
|
package/src/core/Agent.ts
CHANGED
|
@@ -151,7 +151,10 @@ export interface Definition<
|
|
|
151
151
|
readonly input: InputSchema;
|
|
152
152
|
/** Canonical schema used to decode the final model output. */
|
|
153
153
|
readonly output: OutputSchema;
|
|
154
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Evaluated once while preparing each Run. Outgoing system messages form a leading block;
|
|
156
|
+
* exact repeats (including provider options) keep their last occurrence. Stored history is unchanged.
|
|
157
|
+
*/
|
|
155
158
|
readonly instructions: Instructions;
|
|
156
159
|
/** Optional projection from decoded input to model-visible native Effect AI prompt content. */
|
|
157
160
|
readonly inputPrompt?: InputPromptValue | undefined;
|
|
@@ -131,7 +131,7 @@ import { SubagentHost } from "../SubagentHost.ts";
|
|
|
131
131
|
import { ThreadHistory, ThreadHistoryError } from "../ThreadHistory.ts";
|
|
132
132
|
import { CurrentToolCatalog, RunToolVisibility, type CatalogEntry } from "../ToolExposure.ts";
|
|
133
133
|
import { boundedValueFootprint } from "./bounded-value.ts";
|
|
134
|
-
import {
|
|
134
|
+
import { isTextOutput, outputSchemaContract, prepareModelPrompt } from "./output-contract.ts";
|
|
135
135
|
import { ownPrimitiveDelta } from "./primitive-delta.ts";
|
|
136
136
|
import {
|
|
137
137
|
boundedCanonicalJsonSnapshot,
|
|
@@ -3884,7 +3884,9 @@ const nextContextEstimate = Effect.fn("AgentRuntime.nextContextEstimate")(functi
|
|
|
3884
3884
|
);
|
|
3885
3885
|
}
|
|
3886
3886
|
|
|
3887
|
-
return yield* estimateContextTokens(
|
|
3887
|
+
return yield* estimateContextTokens(
|
|
3888
|
+
prepareModelPrompt(Prompt.fromMessages(view), undefined).content,
|
|
3889
|
+
);
|
|
3888
3890
|
});
|
|
3889
3891
|
|
|
3890
3892
|
const snapshotCompactionMessages = Effect.fnUntraced(function* (
|
|
@@ -5732,11 +5734,13 @@ const makeTurn = <
|
|
|
5732
5734
|
|
|
5733
5735
|
// Preparation may replace an existing prefix, and transient context may
|
|
5734
5736
|
// change independently of history. Only ordinary append-only history can
|
|
5735
|
-
// reuse the last provider-reported input as an estimation anchor.
|
|
5737
|
+
// reuse the last provider-reported input as an estimation anchor. Full
|
|
5738
|
+
// estimates exclude system copies removed by the provider projection;
|
|
5739
|
+
// canonical indices still locate appended content and compaction coverage.
|
|
5736
5740
|
const estimateSourceContext = (view: ReadonlyArray<Prompt.Message>) =>
|
|
5737
5741
|
options.context === undefined && options.transientContext === undefined
|
|
5738
5742
|
? nextContextEstimate(context, view)
|
|
5739
|
-
: estimateCallTokens(view);
|
|
5743
|
+
: estimateCallTokens(prepareModelPrompt(Prompt.fromMessages(view), undefined).content);
|
|
5740
5744
|
|
|
5741
5745
|
let prepared = buildCompactedView(modelContext.prompt.content, context.compaction);
|
|
5742
5746
|
let sourceTokens: number | undefined;
|
|
@@ -6208,10 +6212,10 @@ const makeTurn = <
|
|
|
6208
6212
|
}
|
|
6209
6213
|
context.toolExposure = snapshot;
|
|
6210
6214
|
|
|
6211
|
-
const providerPrompt =
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
+
const providerPrompt = prepareModelPrompt(
|
|
6216
|
+
outgoing,
|
|
6217
|
+
outputContract._tag === "rendered" ? outputContract.part : undefined,
|
|
6218
|
+
);
|
|
6215
6219
|
|
|
6216
6220
|
// Prepared and transient context can change at every Turn. A
|
|
6217
6221
|
// final full-prompt check closes the per-call boundary for grace
|
|
@@ -144,30 +144,48 @@ export const outputSchemaContract = (definition: Agent.AnyDefinition): OutputCon
|
|
|
144
144
|
return contract;
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
+
const sameSystemMessage = Schema.toEquivalence(Prompt.SystemMessage);
|
|
148
|
+
|
|
147
149
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
150
|
+
* Project system instructions and the output contract into one leading block.
|
|
151
|
+
* Repeated Runs append instructions to canonical history; letting those copies
|
|
152
|
+
* move the contract breaks the preceding user/tool prefix used by provider caches.
|
|
153
|
+
* Keep the last occurrence of each equivalent system message, preserving the
|
|
154
|
+
* precedence of distinct instructions and their native provider options.
|
|
155
|
+
*
|
|
156
|
+
* This runs after preparation and compaction. Canonical messages, protected
|
|
157
|
+
* instruction/input spans and compaction coverage retain their original positions.
|
|
158
|
+
* Conversation order and message identities are unchanged. A single system block
|
|
159
|
+
* also prevents Anthropic's last-system-group conversion from discarding earlier
|
|
160
|
+
* application instructions or the output contract.
|
|
158
161
|
*/
|
|
159
|
-
export const
|
|
162
|
+
export const prepareModelPrompt = (
|
|
160
163
|
prompt: Prompt.Prompt,
|
|
161
|
-
|
|
164
|
+
contract: Prompt.SystemMessage | undefined,
|
|
162
165
|
): Prompt.Prompt => {
|
|
163
|
-
const
|
|
164
|
-
|
|
166
|
+
const systems: Array<Prompt.SystemMessage> = [];
|
|
167
|
+
const conversation: Array<Prompt.Message> = [];
|
|
168
|
+
const seen = new Map<string, Array<Prompt.SystemMessage>>();
|
|
165
169
|
|
|
166
|
-
for (let index =
|
|
167
|
-
|
|
168
|
-
|
|
170
|
+
for (let index = prompt.content.length - 1; index >= 0; index -= 1) {
|
|
171
|
+
const message = prompt.content[index];
|
|
172
|
+
|
|
173
|
+
if (message === undefined) continue;
|
|
174
|
+
if (message.role !== "system") {
|
|
175
|
+
conversation.push(message);
|
|
176
|
+
continue;
|
|
169
177
|
}
|
|
178
|
+
const variants = seen.get(message.content);
|
|
179
|
+
|
|
180
|
+
if (variants?.some((previous) => sameSystemMessage(previous, message))) continue;
|
|
181
|
+
if (variants === undefined) seen.set(message.content, [message]);
|
|
182
|
+
else variants.push(message);
|
|
183
|
+
systems.push(message);
|
|
170
184
|
}
|
|
171
185
|
|
|
172
|
-
return Prompt.fromMessages([
|
|
186
|
+
return Prompt.fromMessages([
|
|
187
|
+
...systems.reverse(),
|
|
188
|
+
...(contract === undefined ? [] : [contract]),
|
|
189
|
+
...conversation.reverse(),
|
|
190
|
+
]);
|
|
173
191
|
};
|