effect-agent 0.1.0-beta.91 → 0.1.0-beta.93
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/{AgentRuntime-CHipL2jG.mjs → AgentRuntime-BPjQM1Nv.mjs} +2 -2
- package/dist/AgentRuntime-BPjQM1Nv.mjs.map +1 -0
- package/dist/{DurableAgentRuntime-D7gDKGjH.mjs → DurableAgentRuntime-CdrBuKZY.mjs} +4 -4
- package/dist/{DurableAgentRuntime-D7gDKGjH.mjs.map → DurableAgentRuntime-CdrBuKZY.mjs.map} +1 -1
- package/dist/{EventSource-OqS_P9ug.d.mts → EventSource-c6GRTCsl.d.mts} +3 -3
- package/dist/{Ephemeral.d.mts → InMemory.d.mts} +5 -3
- package/dist/{Ephemeral.mjs → InMemory.mjs} +6 -4
- package/dist/InMemory.mjs.map +1 -0
- package/dist/{PreparedInputAdmission-C4HbjHgl.d.mts → PreparedInputAdmission-QzFbW2LQ.d.mts} +4 -4
- package/dist/Records-C9cezOEf.mjs +799 -0
- package/dist/Records-C9cezOEf.mjs.map +1 -0
- package/dist/{Records-BAGkekt8.d.mts → Records-vFp_ZQ9Y.d.mts} +21 -3
- package/dist/{RunJournal-Cgg1kNvc.mjs → RunJournal-lwbrh2hZ.mjs} +2 -2
- package/dist/{RunJournal-Cgg1kNvc.mjs.map → RunJournal-lwbrh2hZ.mjs.map} +1 -1
- package/dist/{Schedule-H3SEYX9g.d.mts → Schedule-BkZvKyMw.d.mts} +2 -2
- package/dist/{Scheduling-C9aIP8zT.mjs → Scheduling-D0QqOoeT.mjs} +2 -2
- package/dist/{Scheduling-C9aIP8zT.mjs.map → Scheduling-D0QqOoeT.mjs.map} +1 -1
- package/dist/{Subagent-U5qXOFE8.mjs → Subagent-CnTzCy8k.mjs} +2 -2
- package/dist/{Subagent-U5qXOFE8.mjs.map → Subagent-CnTzCy8k.mjs.map} +1 -1
- package/dist/{Subscription-BEP8oQO5.d.mts → Subscription-CKQ0KDHN.d.mts} +3 -3
- package/dist/{SubscriptionInput-vAAOBrK7.d.mts → SubscriptionInput-Cth8F_7b.d.mts} +3 -3
- package/dist/capabilities/Subagent.mjs +1 -1
- package/dist/capabilities/WebSearch.d.mts +3 -3
- package/dist/capabilities/WebSearch.mjs +9 -6
- package/dist/capabilities/WebSearch.mjs.map +1 -1
- package/dist/durable/ActivityStore.d.mts +1 -1
- package/dist/durable/ActivityStore.mjs +1 -1
- package/dist/durable/Admin.d.mts +1 -1
- package/dist/durable/Admin.mjs +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/CommittedActivity.mjs +1 -1
- package/dist/durable/Digest.d.mts +1 -1
- package/dist/durable/Digest.mjs +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/EventSource.mjs +1 -1
- package/dist/durable/GitHubWorkflowSource.d.mts +48 -6
- package/dist/durable/GitHubWorkflowSource.mjs +13 -13
- package/dist/durable/GitHubWorkflowSource.mjs.map +1 -1
- package/dist/durable/MessageDelivery.d.mts +3 -3
- package/dist/durable/MessageDelivery.mjs +1 -1
- package/dist/durable/MessageDeliveryStoreConformance.d.mts +39 -39
- package/dist/durable/MessageDeliveryStoreConformance.mjs +1 -1
- package/dist/durable/PersistentHistory.d.mts +1 -1
- package/dist/durable/PersistentHistory.mjs +2 -2
- package/dist/durable/PreparedInputAdmission.d.mts +1 -1
- package/dist/durable/Records.d.mts +1 -1
- package/dist/durable/Records.mjs +2 -795
- package/dist/durable/Recovery.d.mts +1 -1
- package/dist/durable/Recovery.mjs +1 -1
- package/dist/durable/RunJournal.d.mts +1 -1
- package/dist/durable/RunJournal.mjs +1 -1
- package/dist/durable/Schedule.d.mts +1 -1
- package/dist/durable/Schedule.mjs +1 -1
- package/dist/durable/ScheduleStoreConformance.d.mts +1 -1
- package/dist/durable/ScheduleStoreConformance.mjs +1 -1
- package/dist/durable/ScheduleTransition.d.mts +1 -1
- package/dist/durable/ScheduleTransition.mjs +1 -1
- package/dist/durable/Scheduling.d.mts +2 -2
- package/dist/durable/Scheduling.mjs +1 -1
- package/dist/durable/SqlStorageV2Upgrade.d.mts +2 -2
- package/dist/durable/SqlStorageV2Upgrade.mjs +1 -1
- package/dist/durable/SqlSubscriptionStore.d.mts +2 -2
- package/dist/durable/SqlSubscriptionStore.mjs +1 -1
- package/dist/durable/SubmissionLedger.d.mts +1 -1
- package/dist/durable/SubmissionLedger.mjs +1 -1
- package/dist/durable/SubmissionLedgerConformance.d.mts +1 -1
- package/dist/durable/SubmissionLedgerConformance.mjs +1 -1
- package/dist/durable/SubmissionStatus.d.mts +1 -1
- package/dist/durable/Subscription.d.mts +1 -1
- package/dist/durable/Subscription.mjs +1 -1
- package/dist/durable/SubscriptionInput.d.mts +1 -1
- package/dist/durable/SubscriptionInput.mjs +1 -1
- package/dist/durable/SubscriptionStoreConformance.d.mts +1 -1
- package/dist/durable/SubscriptionStoreConformance.mjs +1 -1
- package/dist/durable/SubscriptionTools.d.mts +3 -3
- package/dist/durable/SubscriptionTransition.d.mts +1 -1
- package/dist/durable/SubscriptionTransition.mjs +1 -1
- package/dist/durable/Subscriptions.d.mts +5 -5
- package/dist/durable/Subscriptions.mjs +1 -1
- package/dist/durable/ThreadContextHistory.d.mts +1 -1
- package/dist/durable/ThreadContextHistory.mjs +1 -1
- package/dist/durable/ThreadContextHistoryProjection.d.mts +1 -1
- package/dist/durable/ThreadContextHistoryProjection.mjs +1 -1
- package/dist/durable/ThreadInvariants.d.mts +1 -1
- package/dist/durable/ThreadInvariants.mjs +1 -1
- package/dist/durable/ThreadProjection.d.mts +1 -1
- package/dist/durable/ThreadProjection.mjs +1 -1
- package/dist/durable/ThreadProjectionMaintenance.d.mts +1 -1
- package/dist/durable/ThreadStore.d.mts +1 -1
- package/dist/durable/ThreadStore.mjs +1 -1
- package/dist/durable/ThreadStoreConformance.d.mts +1 -1
- package/dist/durable/ThreadStoreConformance.mjs +1 -1
- package/dist/durable/ToolReconciler.mjs +1 -1
- package/dist/durable/WorkerHost.d.mts +1 -1
- package/dist/engine/AgentRuntime.mjs +1 -1
- package/dist/index.d.mts +8 -8
- package/dist/index.mjs +8 -8
- package/dist/sandbox/InteractiveBrowser.mjs +2 -2
- package/dist/sandbox/InteractiveBrowser.mjs.map +1 -1
- package/dist/sandbox/PageCapture.mjs +4 -4
- package/dist/sandbox/PageCapture.mjs.map +1 -1
- package/dist/sandbox/ProtectedBrowser.mjs +1 -1
- package/dist/sandbox/ProtectedBrowser.mjs.map +1 -1
- package/package.json +1 -1
- package/src/{Ephemeral.ts → InMemory.ts} +2 -0
- package/src/capabilities/WebSearch.ts +23 -17
- package/src/core/internal/strict-schema.ts +14 -0
- package/src/durable/GitHubWorkflowSource.ts +32 -38
- package/src/durable/Records.ts +8 -4
- package/src/engine/internal/primitive-delta.ts +1 -1
- package/src/index.ts +1 -1
- package/src/sandbox/InteractiveBrowser.ts +2 -2
- package/src/sandbox/PageCapture.ts +6 -7
- package/src/sandbox/ProtectedBrowser.ts +1 -1
- package/dist/AgentRuntime-CHipL2jG.mjs.map +0 -1
- package/dist/Ephemeral.mjs.map +0 -1
- package/dist/durable/Records.mjs.map +0 -1
|
@@ -0,0 +1,799 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
import { n as utf8ByteLength } from "./utf8-DchGZRBd.mjs";
|
|
3
|
+
import { AgentPolicy } from "./core/AgentPolicy.mjs";
|
|
4
|
+
import { AgentId, AttemptId, DelegationId, ReceiptId, RunId, SettlementId, SubmissionId, ThreadId, ToolCallId, TurnId } from "./core/Identifiers.mjs";
|
|
5
|
+
import { IdempotencyKey, Principal } from "./core/Receipt.mjs";
|
|
6
|
+
import { Update } from "./core/AgentUpdates.mjs";
|
|
7
|
+
import { PolicyLimit } from "./core/AgentError.mjs";
|
|
8
|
+
import { DelegationDepth, SubagentBudgetReservation, SubagentGrant, SubagentParentLink, ToolExecutionKind } from "./core/SubagentContract.mjs";
|
|
9
|
+
import { o as Selection, s as Snapshot } from "./ToolExposure-C93U1sPu.mjs";
|
|
10
|
+
import { ModelCallUsage, RunTotals, RunUsageSummary } from "./core/Usage.mjs";
|
|
11
|
+
import { ExhaustedLimit } from "./core/RunEvent.mjs";
|
|
12
|
+
import { WorkerBudgetScope, WorkerRef, WorkerSource } from "./core/Worker.mjs";
|
|
13
|
+
import { l as InputMessage } from "./MessagingHost-CWi_PP3g.mjs";
|
|
14
|
+
import { ContextHandoff } from "./engine/ContextWindow.mjs";
|
|
15
|
+
import { RunPolicyUsage } from "./core/RunPolicyUsage.mjs";
|
|
16
|
+
import { Prompt } from "effect/unstable/ai";
|
|
17
|
+
import { Option, Schema, SchemaParser, SchemaTransformation } from "effect";
|
|
18
|
+
//#region src/core/internal/strict-schema.ts
|
|
19
|
+
/** Keep strict parsing on nested values even when an outer parser uses its defaults. */
|
|
20
|
+
const strictSchema = (schema) => Schema.declareConstructor()([schema], ([codec]) => (value, _ast, options) => SchemaParser.decodeUnknownEffect(codec)(value, {
|
|
21
|
+
...options,
|
|
22
|
+
onExcessProperty: "error"
|
|
23
|
+
}), { toCodecJson: ([codec]) => Schema.link()(codec, SchemaTransformation.passthrough()) });
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/durable/Records.ts
|
|
26
|
+
var Records_exports = /* @__PURE__ */ __exportAll({
|
|
27
|
+
AbortRequested: () => AbortRequested,
|
|
28
|
+
AgentUpdateEmitted: () => AgentUpdateEmitted,
|
|
29
|
+
ApprovalDecision: () => ApprovalDecision,
|
|
30
|
+
BatchId: () => BatchId,
|
|
31
|
+
CURRENT_CANONICAL_SCHEMA_VERSION: () => 1,
|
|
32
|
+
CanonicalBatch: () => CanonicalBatch,
|
|
33
|
+
CanonicalRecord: () => CanonicalRecord,
|
|
34
|
+
CanonicalRecordEnvelope: () => CanonicalRecordEnvelope,
|
|
35
|
+
CanonicalRecordPayload: () => CanonicalRecordPayload,
|
|
36
|
+
CanonicalSequence: () => CanonicalSequence,
|
|
37
|
+
CompactionCreated: () => CompactionCreated,
|
|
38
|
+
DefinitionDigestInput: () => DefinitionDigestInput,
|
|
39
|
+
DefinitionDigests: () => DefinitionDigests,
|
|
40
|
+
DeploymentId: () => DeploymentId,
|
|
41
|
+
Digest: () => Digest,
|
|
42
|
+
MAX_PERSISTED_JSON_BYTES: () => MAX_PERSISTED_JSON_BYTES,
|
|
43
|
+
MAX_PERSISTED_JSON_COLLECTION_LENGTH: () => MAX_PERSISTED_JSON_COLLECTION_LENGTH,
|
|
44
|
+
MAX_PERSISTED_JSON_DEPTH: () => 64,
|
|
45
|
+
MAX_PERSISTED_JSON_NODES: () => MAX_PERSISTED_JSON_NODES,
|
|
46
|
+
ModelCompleted: () => ModelCompleted,
|
|
47
|
+
ModelResponseInterrupted: () => ModelResponseInterrupted,
|
|
48
|
+
ModelResponseRecorded: () => ModelResponseRecorded,
|
|
49
|
+
ObservationOffset: () => ObservationOffset,
|
|
50
|
+
PeerMessagePrepared: () => PeerMessagePrepared,
|
|
51
|
+
PersistedJson: () => PersistedJson,
|
|
52
|
+
ProducerEpoch: () => ProducerEpoch,
|
|
53
|
+
ProducerId: () => ProducerId,
|
|
54
|
+
RecordEnvelope: () => RecordEnvelope,
|
|
55
|
+
RecordId: () => RecordId,
|
|
56
|
+
RepairAnnotated: () => RepairAnnotated,
|
|
57
|
+
RunCompleted: () => RunCompleted,
|
|
58
|
+
RunFailed: () => RunFailed,
|
|
59
|
+
RunPolicyUsageReserved: () => RunPolicyUsageReserved,
|
|
60
|
+
RunStartedRecord: () => RunStartedRecord,
|
|
61
|
+
SettlementFailureDiagnostic: () => SettlementFailureDiagnostic,
|
|
62
|
+
SettlementOutcome: () => SettlementOutcome,
|
|
63
|
+
SubagentJoined: () => SubagentJoined,
|
|
64
|
+
SubagentLineageRecorded: () => SubagentLineageRecorded,
|
|
65
|
+
SubagentRequested: () => SubagentRequested,
|
|
66
|
+
SubagentStarted: () => SubagentStarted,
|
|
67
|
+
SubmissionSettled: () => SubmissionSettled,
|
|
68
|
+
SubmissionSettledRecord: () => SubmissionSettledRecord,
|
|
69
|
+
SubtreeBudgetReserved: () => SubtreeBudgetReserved,
|
|
70
|
+
ThreadCreated: () => ThreadCreated,
|
|
71
|
+
ToolApprovalDecided: () => ToolApprovalDecided,
|
|
72
|
+
ToolApprovalRequested: () => ToolApprovalRequested,
|
|
73
|
+
ToolCallPrepared: () => ToolCallPrepared,
|
|
74
|
+
ToolCallResolution: () => ToolCallResolution,
|
|
75
|
+
ToolCallResolved: () => ToolCallResolved,
|
|
76
|
+
ToolCallSettled: () => ToolCallSettled,
|
|
77
|
+
ToolCallUnknown: () => ToolCallUnknown,
|
|
78
|
+
ToolStepSettled: () => ToolStepSettled,
|
|
79
|
+
UserInputRecorded: () => UserInputRecorded,
|
|
80
|
+
WorkerAdmission: () => WorkerAdmission,
|
|
81
|
+
WorkerInputCompleted: () => WorkerInputCompleted,
|
|
82
|
+
WorkerInputRequested: () => WorkerInputRequested,
|
|
83
|
+
WorkerOrigin: () => WorkerOrigin,
|
|
84
|
+
WorkerOriginRecorded: () => WorkerOriginRecorded,
|
|
85
|
+
WorkerReportPrepared: () => WorkerReportPrepared,
|
|
86
|
+
WorkerReportRefused: () => WorkerReportRefused,
|
|
87
|
+
WorkerReportingIntent: () => WorkerReportingIntent
|
|
88
|
+
});
|
|
89
|
+
const identifier = (name) => Schema.NonEmptyString.pipe(Schema.brand(`@effect-agent/thread/${name}`));
|
|
90
|
+
/** Stable identity of one canonical record. */
|
|
91
|
+
const RecordId = identifier("RecordId");
|
|
92
|
+
/** Stable idempotency identity of one atomic append. */
|
|
93
|
+
const BatchId = identifier("BatchId");
|
|
94
|
+
/** Identity of the deployment that produced a record. */
|
|
95
|
+
const DeploymentId = identifier("DeploymentId");
|
|
96
|
+
/** Identity of a fenced canonical-log producer. */
|
|
97
|
+
const ProducerId = identifier("ProducerId");
|
|
98
|
+
/** SHA-256 digest encoded as lowercase hexadecimal text. */
|
|
99
|
+
const Digest = Schema.String.check(Schema.isPattern(/^[a-f0-9]{64}$/)).pipe(Schema.brand("@effect-agent/thread/Digest"));
|
|
100
|
+
/** Adapter-owned resume cursor. Callers must not parse or synthesize it. */
|
|
101
|
+
const ObservationOffset = identifier("ObservationOffset");
|
|
102
|
+
/** Gap-free position in one Thread's canonical sequence. */
|
|
103
|
+
const CanonicalSequence = Schema.Natural.pipe(Schema.brand("@effect-agent/thread/CanonicalSequence"));
|
|
104
|
+
/** Monotonic fencing epoch for a Thread producer. */
|
|
105
|
+
const ProducerEpoch = Schema.Natural.pipe(Schema.brand("@effect-agent/thread/ProducerEpoch"));
|
|
106
|
+
const BoundedText = Schema.String.check(Schema.isMaxLength(65536));
|
|
107
|
+
const BoundedName = Schema.NonEmptyString.check(Schema.isMaxLength(256));
|
|
108
|
+
/** Stable, non-empty failure classification carried by a failed durable Settlement. */
|
|
109
|
+
const SettlementFailureTag = Schema.NonEmptyString.check(Schema.isMaxLength(256));
|
|
110
|
+
/** Diagnostic text is bounded independently from the broader persisted JSON envelope. */
|
|
111
|
+
const SettlementFailureMessage = Schema.String.check(Schema.isMaxLength(16384));
|
|
112
|
+
/**
|
|
113
|
+
* The complete generic diagnostic allowed on a failed durable Settlement. It deliberately has
|
|
114
|
+
* no raw Cause, stack, provider payload, or application-specific fields; those values can carry
|
|
115
|
+
* secrets and do not form a stable cross-process contract.
|
|
116
|
+
*/
|
|
117
|
+
const SettlementFailureDiagnostic = Schema.Struct({
|
|
118
|
+
errorTag: SettlementFailureTag,
|
|
119
|
+
message: SettlementFailureMessage
|
|
120
|
+
}).pipe(strictSchema, Schema.annotate({ identifier: "@effect-agent/thread/SettlementFailureDiagnostic" }));
|
|
121
|
+
/** Positive canonical (Run-relative, Attempt-independent) Turn number. */
|
|
122
|
+
const TurnNumber = Schema.Int.check(Schema.isGreaterThan(0));
|
|
123
|
+
const MAX_PERSISTED_JSON_DEPTH = 64;
|
|
124
|
+
const MAX_PERSISTED_JSON_COLLECTION_LENGTH = 4096;
|
|
125
|
+
const MAX_PERSISTED_JSON_NODES = 65536;
|
|
126
|
+
const MAX_PERSISTED_JSON_BYTES = 1048576;
|
|
127
|
+
/**
|
|
128
|
+
* Iteratively preflights an unknown value before Schema's recursive JSON validation. This is the
|
|
129
|
+
* one narrow `Schema.declare` exception in the persistence model: Effect v4's `Unknown.decodeTo`
|
|
130
|
+
* preserves `unknown` as the encoded type, which would leak through every nested record codec.
|
|
131
|
+
* Schema.Json still owns the accepted value shape after this resource preflight succeeds.
|
|
132
|
+
*/
|
|
133
|
+
const isJson = Schema.is(Schema.Json);
|
|
134
|
+
const isPersistedJson = (input) => {
|
|
135
|
+
const pending = [{
|
|
136
|
+
_tag: "visit",
|
|
137
|
+
value: input,
|
|
138
|
+
depth: 0
|
|
139
|
+
}];
|
|
140
|
+
const ancestors = /* @__PURE__ */ new WeakSet();
|
|
141
|
+
let nodes = 0;
|
|
142
|
+
let textUnits = 0;
|
|
143
|
+
try {
|
|
144
|
+
while (pending.length > 0) {
|
|
145
|
+
const current = pending.pop();
|
|
146
|
+
if (current === void 0) return false;
|
|
147
|
+
if (current._tag === "leave") {
|
|
148
|
+
ancestors.delete(current.value);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (current.depth > 64 || ++nodes > 65536) return false;
|
|
152
|
+
const value = current.value;
|
|
153
|
+
if (value === null || typeof value === "boolean") continue;
|
|
154
|
+
if (typeof value === "number") {
|
|
155
|
+
if (!Number.isFinite(value)) return false;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (typeof value === "string") {
|
|
159
|
+
textUnits += value.length;
|
|
160
|
+
if (textUnits > 1048576) return false;
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (typeof value !== "object" || ancestors.has(value)) return false;
|
|
164
|
+
ancestors.add(value);
|
|
165
|
+
pending.push({
|
|
166
|
+
_tag: "leave",
|
|
167
|
+
value
|
|
168
|
+
});
|
|
169
|
+
const entries = Array.isArray(value) ? Array.from(value, (entry, index) => [index, entry]) : Object.entries(value);
|
|
170
|
+
if (entries.length > 4096) return false;
|
|
171
|
+
for (const [key, entry] of entries) {
|
|
172
|
+
textUnits += typeof key === "string" ? key.length : 0;
|
|
173
|
+
if (textUnits > 1048576) return false;
|
|
174
|
+
pending.push({
|
|
175
|
+
_tag: "visit",
|
|
176
|
+
value: entry,
|
|
177
|
+
depth: current.depth + 1
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (!isJson(input)) return false;
|
|
182
|
+
const encoded = JSON.stringify(input);
|
|
183
|
+
return encoded !== void 0 && utf8ByteLength(encoded) <= 1048576;
|
|
184
|
+
} catch {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
/** Canonical JSON admitted to persisted records and checkpoints under explicit resource limits. */
|
|
189
|
+
const PersistedJson = Schema.declare(isPersistedJson, {
|
|
190
|
+
identifier: "@effect-agent/thread/PersistedJson",
|
|
191
|
+
description: "JSON bounded by canonical persistence depth, collection, node, and byte limits"
|
|
192
|
+
});
|
|
193
|
+
/** Schema-owned replay inputs whose individual definitions are incorporated into digests. */
|
|
194
|
+
var DefinitionDigestInput = class extends Schema.Class("@effect-agent/thread/DefinitionDigestInput")({
|
|
195
|
+
agent: PersistedJson,
|
|
196
|
+
model: PersistedJson,
|
|
197
|
+
tools: PersistedJson
|
|
198
|
+
}) {};
|
|
199
|
+
/** Digests make a replay-visible definition/configuration change explicit. */
|
|
200
|
+
var DefinitionDigests = class extends Schema.Class("@effect-agent/thread/DefinitionDigests")({
|
|
201
|
+
agent: Digest,
|
|
202
|
+
model: Digest,
|
|
203
|
+
tools: Digest
|
|
204
|
+
}) {};
|
|
205
|
+
var ThreadCreated = class extends Schema.TaggedClass("@effect-agent/thread/ThreadCreated")("ThreadCreated", {
|
|
206
|
+
agentId: AgentId,
|
|
207
|
+
definitions: DefinitionDigests
|
|
208
|
+
}) {};
|
|
209
|
+
/**
|
|
210
|
+
* One recorded Thread input. `submissionId` is present only for durably accepted work;
|
|
211
|
+
* retained history has no admission or settlement obligation. `kind` identifies the input seam.
|
|
212
|
+
*/
|
|
213
|
+
var UserInputRecorded = class extends Schema.TaggedClass("@effect-agent/thread/UserInputRecorded")("UserInputRecorded", {
|
|
214
|
+
submissionId: Schema.optionalKey(SubmissionId),
|
|
215
|
+
kind: Schema.Literals([
|
|
216
|
+
"user",
|
|
217
|
+
"steering",
|
|
218
|
+
"follow-up"
|
|
219
|
+
]),
|
|
220
|
+
runId: Schema.optionalKey(RunId),
|
|
221
|
+
input: PersistedJson,
|
|
222
|
+
messageAdmission: Schema.optionalKey(InputMessage)
|
|
223
|
+
}) {};
|
|
224
|
+
/** Immutable clock and duration allowance for one logical Run, before any agent execution. */
|
|
225
|
+
var RunStartedRecord = class extends Schema.TaggedClass("@effect-agent/thread/RunStartedRecord")("RunStarted", {
|
|
226
|
+
runId: RunId,
|
|
227
|
+
/** Older private histories cannot prove programmatic accounting and must be reset. */
|
|
228
|
+
policyAccountingVersion: Schema.Literal(1),
|
|
229
|
+
maxDurationMillis: Schema.Finite.check(Schema.isGreaterThan(0))
|
|
230
|
+
}) {};
|
|
231
|
+
const PersistedPromptMessages = Schema.toEncoded(Prompt.Prompt);
|
|
232
|
+
const isPersistedPromptMessages = Schema.is(PersistedPromptMessages);
|
|
233
|
+
/**
|
|
234
|
+
* Final model output. Immediate history may include the exact encoded Prompt suffix of the
|
|
235
|
+
* successful Run; durable execution instead journals individual ModelResponseRecorded Turns.
|
|
236
|
+
*/
|
|
237
|
+
var ModelCompleted = class extends Schema.TaggedClass("@effect-agent/thread/ModelCompleted")("ModelCompleted", Schema.Struct({
|
|
238
|
+
runId: RunId,
|
|
239
|
+
output: PersistedJson,
|
|
240
|
+
messages: Schema.optionalKey(PersistedJson)
|
|
241
|
+
}).check(Schema.makeFilter((record) => record.messages === void 0 || isPersistedPromptMessages(record.messages), { title: "Retained Run messages are Schema-encoded Effect AI Prompt messages" }))) {};
|
|
242
|
+
var ToolCallSettled = class extends Schema.TaggedClass("@effect-agent/thread/ToolCallSettled")("ToolCallSettled", {
|
|
243
|
+
toolSelection: Schema.optionalKey(Selection),
|
|
244
|
+
runId: RunId,
|
|
245
|
+
toolCallId: ToolCallId,
|
|
246
|
+
toolName: BoundedName,
|
|
247
|
+
result: PersistedJson,
|
|
248
|
+
isFailure: Schema.Boolean,
|
|
249
|
+
/** Explicit engine evidence, never inferred from Tool result data. */
|
|
250
|
+
budgetRejected: Schema.optionalKey(Schema.Literal(true))
|
|
251
|
+
}) {};
|
|
252
|
+
/**
|
|
253
|
+
* One committed model Turn. `messages` carries the Schema-encoded Effect AI Prompt messages this
|
|
254
|
+
* Turn appended (assistant response plus any tool-call declarations), committed atomically at the
|
|
255
|
+
* Turn boundary so a recovering Attempt can rebuild the next Prompt from canonical records alone.
|
|
256
|
+
* `messagesDigest` pins the exact encoded content.
|
|
257
|
+
*/
|
|
258
|
+
const ModelResponseRecordedFields = Schema.Struct({
|
|
259
|
+
toolExposure: Schema.optionalKey(Snapshot),
|
|
260
|
+
runId: RunId,
|
|
261
|
+
turnId: TurnId,
|
|
262
|
+
turn: TurnNumber,
|
|
263
|
+
messages: PersistedJson,
|
|
264
|
+
messagesDigest: Digest,
|
|
265
|
+
/**
|
|
266
|
+
* Number of leading messages that belong only to this Run's evaluated instructions and wake
|
|
267
|
+
* input. They remain canonical and are visible while recovering this Run, but later Runs omit
|
|
268
|
+
* them from their model-facing history. Records without this field retain their full history.
|
|
269
|
+
*/
|
|
270
|
+
runScopedPrefixLength: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
271
|
+
/**
|
|
272
|
+
* Exact normalized usage for every model call staged into this Turn. A
|
|
273
|
+
* summarizer and the Turn response are distinct entries. Absent on legacy
|
|
274
|
+
* records, whose aggregate totals below retain the old resume behavior.
|
|
275
|
+
*/
|
|
276
|
+
modelUsage: Schema.optionalKey(Schema.Array(ModelCallUsage)),
|
|
277
|
+
/** Observed invocations without retained accounting before this Turn committed. */
|
|
278
|
+
unobservedModelCalls: Schema.optionalKey(Schema.Natural),
|
|
279
|
+
/** Aggregate compatibility fields used by older projections. */
|
|
280
|
+
inputTokens: Schema.optionalKey(Schema.Natural),
|
|
281
|
+
outputTokens: Schema.optionalKey(Schema.Natural),
|
|
282
|
+
/** Estimated spend staged with the usage; recovery re-seeds the cost budget (RUN-023). */
|
|
283
|
+
costMicrousd: Schema.optionalKey(Schema.Natural)
|
|
284
|
+
}).check(Schema.makeFilter((response) => response.runScopedPrefixLength === void 0 || isPersistedPromptMessages(response.messages) && response.runScopedPrefixLength < response.messages.content.length && response.messages.content.slice(0, response.runScopedPrefixLength).every((message) => message.role === "system" || message.role === "user"), { title: "Run-scoped Prompt prefix contains only instruction/wake messages and leaves one response" }));
|
|
285
|
+
var ModelResponseRecorded = class extends Schema.TaggedClass("@effect-agent/thread/ModelResponseRecorded")("ModelResponseRecorded", ModelResponseRecordedFields) {};
|
|
286
|
+
/**
|
|
287
|
+
* One approved uncertain/idempotent ordinary Tool Call made durable BEFORE any handler starts
|
|
288
|
+
* (durability §10). `parameters` is the Schema-encoded wire form of the declared call and
|
|
289
|
+
* `parametersDigest` pins it; recovery that sees this record without a matching `ToolCallSettled`
|
|
290
|
+
* (or `ToolCallUnknown` → `ToolCallResolved`) must reconcile or mark unknown, never silently
|
|
291
|
+
* replay (DUR-009). Ordinary `readonly`-class Tools never produce this record. Delegation
|
|
292
|
+
* classification is always prepared, including for a Tool annotated `readonly`.
|
|
293
|
+
*/
|
|
294
|
+
var ToolCallPrepared = class extends Schema.TaggedClass("@effect-agent/thread/ToolCallPrepared")("ToolCallPrepared", {
|
|
295
|
+
runId: RunId,
|
|
296
|
+
turnId: TurnId,
|
|
297
|
+
turn: TurnNumber,
|
|
298
|
+
toolCallId: ToolCallId,
|
|
299
|
+
toolName: BoundedName,
|
|
300
|
+
parameters: PersistedJson,
|
|
301
|
+
parametersDigest: Digest,
|
|
302
|
+
/** Absent legacy evidence grants no delegation replay authority. */
|
|
303
|
+
executionKind: Schema.optionalKey(ToolExecutionKind)
|
|
304
|
+
}) {};
|
|
305
|
+
/** Monotonic reservations charged before programmatic execution or grace finalization. */
|
|
306
|
+
var RunPolicyUsageReserved = class extends Schema.TaggedClass()("RunPolicyUsageReserved", {
|
|
307
|
+
runId: RunId,
|
|
308
|
+
programmaticToolCalls: RunPolicyUsage.fields.programmaticToolCalls,
|
|
309
|
+
finalizationUsed: RunPolicyUsage.fields.finalizationUsed
|
|
310
|
+
}) {};
|
|
311
|
+
/**
|
|
312
|
+
* A durable Unknown Outcome: the external effect of one prepared ordinary Tool Call may have
|
|
313
|
+
* happened but was not confirmed canonically (DUR-009/DUR-017). It is neither success nor
|
|
314
|
+
* ordinary failure; automatic continuation stops until an authorized resolution arrives.
|
|
315
|
+
*/
|
|
316
|
+
var ToolCallUnknown = class extends Schema.TaggedClass("@effect-agent/thread/ToolCallUnknown")("ToolCallUnknown", {
|
|
317
|
+
runId: RunId,
|
|
318
|
+
turn: TurnNumber,
|
|
319
|
+
toolCallId: ToolCallId,
|
|
320
|
+
toolName: BoundedName,
|
|
321
|
+
reason: BoundedText
|
|
322
|
+
}) {};
|
|
323
|
+
/** How one open/unknown Tool Call was authoritatively closed (DUR-017 resolution audit). */
|
|
324
|
+
const ToolCallResolution = Schema.Literals([
|
|
325
|
+
"completed-with-result",
|
|
326
|
+
"failed-with-error",
|
|
327
|
+
"never-started",
|
|
328
|
+
"safe-retry"
|
|
329
|
+
]);
|
|
330
|
+
/**
|
|
331
|
+
* The canonical audit record closing one open or unknown Tool Call: reconciler-recovered supplier
|
|
332
|
+
* truth or an authorized `resolveUnknown` command. `author`/`reason` make every resolution an
|
|
333
|
+
* attributable decision (DUR-017); a `completed-with-result` resolution is accompanied by the
|
|
334
|
+
* per-call `ToolCallSettled` record carrying the recovered result.
|
|
335
|
+
*/
|
|
336
|
+
var ToolCallResolved = class extends Schema.TaggedClass("@effect-agent/thread/ToolCallResolved")("ToolCallResolved", {
|
|
337
|
+
runId: RunId,
|
|
338
|
+
toolCallId: ToolCallId,
|
|
339
|
+
resolution: ToolCallResolution,
|
|
340
|
+
author: BoundedName,
|
|
341
|
+
reason: BoundedText
|
|
342
|
+
}) {};
|
|
343
|
+
/**
|
|
344
|
+
* One accepted Durable Step result (durability §11): exactly-once-recorded while the Step's
|
|
345
|
+
* external side effect stays honestly at-least-once-executed. Only success is recorded — a failing
|
|
346
|
+
* Step body fails into the handler's error channel and re-executes on re-entry. `output` is the
|
|
347
|
+
* Schema-encoded Step output; `outputDigest` pins it for replay-divergence detection.
|
|
348
|
+
*/
|
|
349
|
+
var ToolStepSettled = class extends Schema.TaggedClass("@effect-agent/thread/ToolStepSettled")("ToolStepSettled", {
|
|
350
|
+
runId: RunId,
|
|
351
|
+
toolCallId: ToolCallId,
|
|
352
|
+
stepName: BoundedName,
|
|
353
|
+
output: PersistedJson,
|
|
354
|
+
outputDigest: Digest
|
|
355
|
+
}) {};
|
|
356
|
+
/**
|
|
357
|
+
* A canonical approval request for one declared Tool Call (CAP-006, durability §8): with this
|
|
358
|
+
* record durable, "waiting for explicit approval" is a safe suspension boundary — the resumed
|
|
359
|
+
* Attempt replays the declared batch instead of re-invoking the model.
|
|
360
|
+
*/
|
|
361
|
+
var ToolApprovalRequested = class extends Schema.TaggedClass("@effect-agent/thread/ToolApprovalRequested")("ToolApprovalRequested", {
|
|
362
|
+
runId: RunId,
|
|
363
|
+
turnId: TurnId,
|
|
364
|
+
turn: TurnNumber,
|
|
365
|
+
toolCallId: ToolCallId,
|
|
366
|
+
toolName: BoundedName,
|
|
367
|
+
parametersDigest: Digest
|
|
368
|
+
}) {};
|
|
369
|
+
/** The two-valued approval decision family shared by canonical records and ledger intents. */
|
|
370
|
+
const ApprovalDecision = Schema.Literals(["approved", "denied"]);
|
|
371
|
+
/**
|
|
372
|
+
* The canonical decision for one requested approval. Appended by the deciding Attempt (policy
|
|
373
|
+
* auto-decisions) or by the resuming Attempt after a durable `resolveApproval` intent; it is the
|
|
374
|
+
* deterministic decision authority for every later Attempt of the same Run.
|
|
375
|
+
*/
|
|
376
|
+
var ToolApprovalDecided = class extends Schema.TaggedClass("@effect-agent/thread/ToolApprovalDecided")("ToolApprovalDecided", {
|
|
377
|
+
runId: RunId,
|
|
378
|
+
turn: TurnNumber,
|
|
379
|
+
toolCallId: ToolCallId,
|
|
380
|
+
decision: ApprovalDecision,
|
|
381
|
+
resolver: BoundedName,
|
|
382
|
+
reason: BoundedText
|
|
383
|
+
}) {};
|
|
384
|
+
/**
|
|
385
|
+
* First-class interruption audit (durability §9): appended by a superseding Attempt before it
|
|
386
|
+
* re-invokes the model for a Turn whose prior owner died without a complete canonical response.
|
|
387
|
+
* Duplicate provider cost is thereby possible AND observable in canonical history.
|
|
388
|
+
*/
|
|
389
|
+
var ModelResponseInterrupted = class extends Schema.TaggedClass("@effect-agent/thread/ModelResponseInterrupted")("ModelResponseInterrupted", {
|
|
390
|
+
runId: RunId,
|
|
391
|
+
supersededEpoch: ProducerEpoch,
|
|
392
|
+
attemptId: AttemptId,
|
|
393
|
+
reason: BoundedText
|
|
394
|
+
}) {};
|
|
395
|
+
/**
|
|
396
|
+
* One engine-native compaction committed before the pre-Turn view changes (RUN-026).
|
|
397
|
+
* `coversThrough` is a Thread record sequence: the projection
|
|
398
|
+
* renders records at or below it as a summary (`summarize`), a fresh window (`rollover`), or with
|
|
399
|
+
* cleared tool results (kind `clear-tool-results`), never erasing source
|
|
400
|
+
* history. The record carries no digest by decision: it is appended by the
|
|
401
|
+
* fenced owner into the very log it covers, and re-verifying a digest would
|
|
402
|
+
* re-read the covered range on every wake — the O(history) work compaction
|
|
403
|
+
* exists to remove. Host-supplied ContextCompactor decisions use this same commit path.
|
|
404
|
+
* Summaries exceeding BoundedText are rejected before append, never truncated.
|
|
405
|
+
* `summary` is present exactly for `summarize` records; the projection
|
|
406
|
+
* treats a summarize record without one as invalid and ignores it fail-safe.
|
|
407
|
+
*/
|
|
408
|
+
var CompactionCreated = class extends Schema.TaggedClass("@effect-agent/thread/CompactionCreated")("CompactionCreated", {
|
|
409
|
+
runId: RunId,
|
|
410
|
+
turn: TurnNumber,
|
|
411
|
+
kind: Schema.Literals([
|
|
412
|
+
"clear-tool-results",
|
|
413
|
+
"summarize",
|
|
414
|
+
"rollover"
|
|
415
|
+
]),
|
|
416
|
+
coversThrough: CanonicalSequence,
|
|
417
|
+
summary: Schema.optionalKey(BoundedText),
|
|
418
|
+
handoff: Schema.optionalKey(ContextHandoff)
|
|
419
|
+
}) {};
|
|
420
|
+
var RunFailed = class extends Schema.TaggedClass("@effect-agent/thread/RunFailed")("RunFailed", {
|
|
421
|
+
runId: RunId,
|
|
422
|
+
failure: PersistedJson
|
|
423
|
+
}) {};
|
|
424
|
+
const RunCompletedFields = Schema.Struct({
|
|
425
|
+
runId: RunId,
|
|
426
|
+
output: PersistedJson,
|
|
427
|
+
/** Application disposition captured with an ordinary completion. */
|
|
428
|
+
runDisposition: Schema.optionalKey(PersistedJson),
|
|
429
|
+
/** Honest soft-landing marker, present exactly when `exhausted` is present. */
|
|
430
|
+
finishReason: Schema.optionalKey(Schema.Literal("budget-exhausted")),
|
|
431
|
+
/** Budget dimension paired with `finishReason` on a soft landing. */
|
|
432
|
+
exhausted: Schema.optionalKey(ExhaustedLimit)
|
|
433
|
+
}).check(Schema.makeFilter((completed) => completed.finishReason === void 0 === (completed.exhausted === void 0) && (completed.runDisposition === void 0 || completed.finishReason === void 0), { title: "Run completion metadata matches its terminal family" }));
|
|
434
|
+
var RunCompleted = class extends Schema.TaggedClass("@effect-agent/thread/RunCompleted")("RunCompleted", RunCompletedFields) {};
|
|
435
|
+
var RepairAnnotated = class extends Schema.TaggedClass("@effect-agent/thread/RepairAnnotated")("RepairAnnotated", {
|
|
436
|
+
reason: BoundedText,
|
|
437
|
+
details: PersistedJson
|
|
438
|
+
}) {};
|
|
439
|
+
/** Terminal outcome family for one accepted Submission (DUR-002). */
|
|
440
|
+
const SettlementOutcome = Schema.Literals([
|
|
441
|
+
"completed",
|
|
442
|
+
"failed",
|
|
443
|
+
"aborted"
|
|
444
|
+
]);
|
|
445
|
+
/**
|
|
446
|
+
* A durable abort command made canonical before the active worker is interrupted (DUR-012).
|
|
447
|
+
* Repeating the same abort command is idempotent; abort never rewrites a prior terminal outcome.
|
|
448
|
+
*/
|
|
449
|
+
var AbortRequested = class extends Schema.TaggedClass("@effect-agent/thread/AbortRequested")("AbortRequested", {
|
|
450
|
+
submissionId: SubmissionId,
|
|
451
|
+
author: BoundedName,
|
|
452
|
+
reason: BoundedText
|
|
453
|
+
}) {};
|
|
454
|
+
/**
|
|
455
|
+
* The single canonical settlement record owed to one accepted Submission (DUR-002, DUR-011).
|
|
456
|
+
* Canonical history is the outcome authority: the ledger row is finalized from this record and
|
|
457
|
+
* never the other way around (DUR-015).
|
|
458
|
+
*/
|
|
459
|
+
const RawSubmissionSettled = Schema.Struct({
|
|
460
|
+
submissionId: SubmissionId,
|
|
461
|
+
settlementId: SettlementId,
|
|
462
|
+
receiptId: ReceiptId,
|
|
463
|
+
outcome: SettlementOutcome,
|
|
464
|
+
runId: Schema.optionalKey(RunId),
|
|
465
|
+
result: Schema.optionalKey(PersistedJson),
|
|
466
|
+
/**
|
|
467
|
+
* Application-defined, Schema-encoded disposition for an ordinary completed
|
|
468
|
+
* Run. Absent for budget exhaustion and every non-completed or run-less
|
|
469
|
+
* settlement; consumers decode it with the application definition's Schema.
|
|
470
|
+
*/
|
|
471
|
+
runDisposition: Schema.optionalKey(PersistedJson),
|
|
472
|
+
/**
|
|
473
|
+
* Present only when a `completed` Run settled through the final-answer
|
|
474
|
+
* exhaustion resolution (RUN-011, RUN-018): the durable log must be able to
|
|
475
|
+
* distinguish honest-exhaustion completion from ordinary completion without
|
|
476
|
+
* the live event stream. Absent for every ordinary settlement, keeping
|
|
477
|
+
* existing histories and goldens byte-stable (additive, schemaVersion 1).
|
|
478
|
+
*/
|
|
479
|
+
finishReason: Schema.optionalKey(Schema.Literal("budget-exhausted")),
|
|
480
|
+
/**
|
|
481
|
+
* The dimension that bound a budget-exhausted completion (RUN-011,
|
|
482
|
+
* RUN-025), carried verbatim from the live `RunCompleted` event so
|
|
483
|
+
* consumers never reconstruct it from message text. Valid only alongside
|
|
484
|
+
* `finishReason: "budget-exhausted"`; absent on histories persisted before
|
|
485
|
+
* the dimension became durable (additive, schemaVersion 1).
|
|
486
|
+
*/
|
|
487
|
+
exhausted: Schema.optionalKey(ExhaustedLimit),
|
|
488
|
+
/**
|
|
489
|
+
* The typed `AgentPolicyError.limit` of a `failed` hard-rail settlement
|
|
490
|
+
* (RUN-011): which finite policy dimension failed the Run, preserved
|
|
491
|
+
* alongside the bounded `{errorTag, message}` failure projection in
|
|
492
|
+
* `result`. Absent for every non-policy failure and on histories persisted
|
|
493
|
+
* before the limit became durable (additive, schemaVersion 1).
|
|
494
|
+
*/
|
|
495
|
+
policyLimit: Schema.optionalKey(PolicyLimit),
|
|
496
|
+
/** Canonical aggregate of all priced model calls made by this Run. */
|
|
497
|
+
usageSummary: Schema.optionalKey(RunUsageSummary),
|
|
498
|
+
/** Calls included in usageSummary but not in any ModelResponseRecorded, retained on failure. */
|
|
499
|
+
uncommittedModelUsage: Schema.optionalKey(Schema.Array(ModelCallUsage))
|
|
500
|
+
});
|
|
501
|
+
const isPolicyFailureProjection = Schema.is(Schema.Struct({ errorTag: Schema.Literal("AgentPolicyError") }));
|
|
502
|
+
const decodeSettlementFailureDiagnostic = Schema.decodeUnknownOption(SettlementFailureDiagnostic, { onExcessProperty: "error" });
|
|
503
|
+
const hasValidSettlementFamily = (settled) => (settled.finishReason === void 0 || settled.outcome === "completed") && settled.finishReason === void 0 === (settled.exhausted === void 0) && (settled.usageSummary === void 0 || settled.runId !== void 0) && (settled.uncommittedModelUsage === void 0 || settled.runId !== void 0 && settled.usageSummary !== void 0) && (settled.runDisposition === void 0 || settled.outcome === "completed" && settled.finishReason === void 0 && settled.runId !== void 0 && settled.result !== void 0) && (settled.outcome !== "failed" || Option.isSome(decodeSettlementFailureDiagnostic(settled.result))) && (settled.outcome !== "aborted" || settled.result === void 0) && (settled.policyLimit === void 0 || settled.outcome === "failed" && isPolicyFailureProjection(settled.result));
|
|
504
|
+
const SubmissionSettledFields = RawSubmissionSettled.check(Schema.makeFilter(hasValidSettlementFamily, { title: "failed settlements require a bounded diagnostic; aborted settlements carry no result; budget metadata must match its settlement family" }));
|
|
505
|
+
var SubmissionSettled = class extends Schema.TaggedClass("@effect-agent/thread/SubmissionSettled")("SubmissionSettled", SubmissionSettledFields) {};
|
|
506
|
+
/**
|
|
507
|
+
* Canonical-boundary view of `SubmissionSettled`: `finishReason` is valid
|
|
508
|
+
* only on a `completed` outcome, `exhausted` only alongside
|
|
509
|
+
* `finishReason: "budget-exhausted"`, every `failed` outcome requires the exact bounded
|
|
510
|
+
* `SettlementFailureDiagnostic`, aborted outcomes carry no result, and `policyLimit` only occurs
|
|
511
|
+
* on a `failed` outcome whose diagnostic carries the `AgentPolicyError` tag. `runDisposition`
|
|
512
|
+
* occurs only on an ordinary completed settlement with a Run —
|
|
513
|
+
* so a malformed persisted combination such as
|
|
514
|
+
* `{ outcome: "failed", finishReason: "budget-exhausted" }` or a
|
|
515
|
+
* `policyLimit` contradicting `result.errorTag` fails closed at decode
|
|
516
|
+
* instead of becoming trusted audit history (STORE-006, RUN-011).
|
|
517
|
+
*/
|
|
518
|
+
const SubmissionSettledRecord = SubmissionSettled.pipe(Schema.refine((settled) => hasValidSettlementFamily(settled), { expected: "failed settlements require a bounded diagnostic, aborted settlements carry no result, finishReason only occurs on completed settlements, exhausted only occurs with finishReason budget-exhausted, runDisposition only occurs on an ordinary completed settlement with a Run result, and policyLimit only occurs on a failed AgentPolicyError settlement" }));
|
|
519
|
+
/**
|
|
520
|
+
* PARENT-log record of one durable child establishment request:
|
|
521
|
+
* the exact parent Tool Call, delegation and target identity, the digests that pin the child's
|
|
522
|
+
* Binding/input/grant, the fenced budget reservation, and the INTENDED child identity derived
|
|
523
|
+
* deterministically from the parent Run and Tool Call pair (D4). `childInput` carries the
|
|
524
|
+
* prepared child input in encoded form (D3) so recovery can complete child admission from this
|
|
525
|
+
* record alone — no live delegation handler is required. `childPrincipal`/`childIdempotencyKey`
|
|
526
|
+
* carry the ledger admission scope with the ledger's exact bounds; the layering keeps their
|
|
527
|
+
* branded Schemas in the ledger port.
|
|
528
|
+
*/
|
|
529
|
+
var SubagentRequested = class extends Schema.TaggedClass("@effect-agent/thread/SubagentRequested")("SubagentRequested", {
|
|
530
|
+
runId: RunId,
|
|
531
|
+
turnId: TurnId,
|
|
532
|
+
turn: TurnNumber,
|
|
533
|
+
toolCallId: ToolCallId,
|
|
534
|
+
delegationId: DelegationId,
|
|
535
|
+
targetAgentId: AgentId,
|
|
536
|
+
targetDigests: DefinitionDigests,
|
|
537
|
+
childInput: PersistedJson,
|
|
538
|
+
childInputDigest: Digest,
|
|
539
|
+
grantDigest: Digest,
|
|
540
|
+
reservationId: BoundedName,
|
|
541
|
+
reservationDigest: Digest,
|
|
542
|
+
childThreadId: ThreadId,
|
|
543
|
+
childPrincipal: BoundedName,
|
|
544
|
+
childIdempotencyKey: BoundedName,
|
|
545
|
+
/** Effective invocation bound, already clamped to the delegation and child Definition. */
|
|
546
|
+
toolCallAllowance: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
547
|
+
policy: Schema.optionalKey(Schema.toCodecJson(AgentPolicy)),
|
|
548
|
+
budget: Schema.optionalKey(SubagentBudgetReservation),
|
|
549
|
+
grant: Schema.optionalKey(SubagentGrant),
|
|
550
|
+
depth: Schema.optionalKey(DelegationDepth)
|
|
551
|
+
}) {};
|
|
552
|
+
/**
|
|
553
|
+
* PARENT-log record that the intended child exists as accepted work:
|
|
554
|
+
* the full established child identity. It is appended only after the child Receipt
|
|
555
|
+
* exists — SUB-017 holds by construction because `childReceiptId` is a required field.
|
|
556
|
+
*/
|
|
557
|
+
var SubagentStarted = class extends Schema.TaggedClass("@effect-agent/thread/SubagentStarted")("SubagentStarted", {
|
|
558
|
+
runId: RunId,
|
|
559
|
+
toolCallId: ToolCallId,
|
|
560
|
+
childThreadId: ThreadId,
|
|
561
|
+
childSubmissionId: SubmissionId,
|
|
562
|
+
childReceiptId: ReceiptId,
|
|
563
|
+
childRunId: RunId
|
|
564
|
+
}) {};
|
|
565
|
+
/**
|
|
566
|
+
* PARENT-log record of one verified child settlement join:
|
|
567
|
+
* the child's canonical Settlement identity and outcome, the digests pinning the verified child
|
|
568
|
+
* result and the bounded projected parent result, the child usage summary, and the FINAL
|
|
569
|
+
* consumed/released accounting decision for the reservation. It commits in ONE atomic batch with
|
|
570
|
+
* the parent `ToolCallSettled` record (SUB-019); `beginChildBudgetRelease` replays
|
|
571
|
+
* `finalAccounting` from this record, so canonical history authorizes the release (DUR-015).
|
|
572
|
+
*/
|
|
573
|
+
var SubagentJoined = class extends Schema.TaggedClass("@effect-agent/thread/SubagentJoined")("SubagentJoined", {
|
|
574
|
+
runId: RunId,
|
|
575
|
+
toolCallId: ToolCallId,
|
|
576
|
+
childSubmissionId: SubmissionId,
|
|
577
|
+
childSettlementId: SettlementId,
|
|
578
|
+
childOutcome: SettlementOutcome,
|
|
579
|
+
childResultDigest: Digest,
|
|
580
|
+
projectedResultDigest: Digest,
|
|
581
|
+
usageSummary: PersistedJson,
|
|
582
|
+
usage: Schema.optionalKey(RunTotals),
|
|
583
|
+
delegatedUsage: Schema.optionalKey(RunTotals),
|
|
584
|
+
reservationId: BoundedName,
|
|
585
|
+
finalAccounting: PersistedJson
|
|
586
|
+
}) {};
|
|
587
|
+
/**
|
|
588
|
+
* CHILD-log immutable lineage: the Parent Link plus the digests that pin
|
|
589
|
+
* the child's definition, input, and authority grant. It is the first record after the child's
|
|
590
|
+
* `ThreadCreated` (its own single-record batch, so the generic `thread-created:{cid}`
|
|
591
|
+
* batch identity is never contradicted) and the join path verifies it fail-closed — a fabricated
|
|
592
|
+
* child or parent identity fails Parent Link verification (SUB-004, D10).
|
|
593
|
+
*/
|
|
594
|
+
var SubagentLineageRecorded = class extends Schema.TaggedClass("@effect-agent/thread/SubagentLineageRecorded")("SubagentLineageRecorded", {
|
|
595
|
+
parentLink: SubagentParentLink,
|
|
596
|
+
parentSubmissionId: SubmissionId,
|
|
597
|
+
childDefinitionDigests: DefinitionDigests,
|
|
598
|
+
childInputDigest: Digest,
|
|
599
|
+
grantDigest: Digest,
|
|
600
|
+
/** Copied from the canonical request before readiness; restored for every child Attempt. */
|
|
601
|
+
toolCallAllowance: SubagentRequested.fields.toolCallAllowance,
|
|
602
|
+
policy: SubagentRequested.fields.policy,
|
|
603
|
+
budget: SubagentRequested.fields.budget,
|
|
604
|
+
grant: SubagentRequested.fields.grant
|
|
605
|
+
}) {};
|
|
606
|
+
const WorkerReportingIntent = Schema.Struct({
|
|
607
|
+
/** Omitted preserves existing application-mapped reports. */
|
|
608
|
+
mode: Schema.optionalKey(Schema.Literal("standard")),
|
|
609
|
+
sourceDigests: DefinitionDigests,
|
|
610
|
+
destinationDelegationId: Schema.optionalKey(DelegationId)
|
|
611
|
+
});
|
|
612
|
+
/** Immutable worker Thread origin. Each input has its own digest and parameters separately. */
|
|
613
|
+
const WorkerOrigin = Schema.Struct({
|
|
614
|
+
worker: WorkerRef,
|
|
615
|
+
source: WorkerSource,
|
|
616
|
+
/** Omitted retains source-subtree funding; worker-run renews only for a new native Run. */
|
|
617
|
+
budgetScope: Schema.optionalKey(WorkerBudgetScope),
|
|
618
|
+
targetDigests: DefinitionDigests,
|
|
619
|
+
policy: Schema.toCodecJson(AgentPolicy),
|
|
620
|
+
budget: SubagentBudgetReservation,
|
|
621
|
+
grant: SubagentGrant,
|
|
622
|
+
depth: DelegationDepth,
|
|
623
|
+
toolCallAllowance: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
624
|
+
firstMessageId: IdempotencyKey,
|
|
625
|
+
createdAtMillis: Schema.Natural,
|
|
626
|
+
expiresAtMillis: Schema.Natural,
|
|
627
|
+
/** Exact source registration owns projection; absence means reporting was not declared. */
|
|
628
|
+
reporting: Schema.optionalKey(WorkerReportingIntent)
|
|
629
|
+
}).check(Schema.makeFilter((value) => value.expiresAtMillis > value.createdAtMillis));
|
|
630
|
+
/** Frozen per-input metadata; it grants no attached-child or parent-abort semantics. */
|
|
631
|
+
const WorkerAdmission = Schema.Struct({
|
|
632
|
+
origin: WorkerOrigin,
|
|
633
|
+
messageId: IdempotencyKey,
|
|
634
|
+
parameters: PersistedJson,
|
|
635
|
+
createdAtMillis: Schema.Natural,
|
|
636
|
+
/** Host-bound source input whose subtree funds this input; never chosen by a model. */
|
|
637
|
+
sourceSubmissionId: Schema.optionalKey(SubmissionId),
|
|
638
|
+
/** Enables routed receipt lookup when the delivery is owned by a reporting child. */
|
|
639
|
+
deliveryPrincipal: Schema.optionalKey(Principal),
|
|
640
|
+
/** Proven framework updates use a separate bounded input-capacity partition. */
|
|
641
|
+
reportKind: Schema.optionalKey(Schema.Literal("update"))
|
|
642
|
+
});
|
|
643
|
+
/** Source-log capacity reservation, retained independently of the source Run's settlement. */
|
|
644
|
+
var WorkerInputRequested = class extends Schema.TaggedClass()("WorkerInputRequested", {
|
|
645
|
+
admission: WorkerAdmission,
|
|
646
|
+
inputDigest: Digest
|
|
647
|
+
}) {};
|
|
648
|
+
/** Child-log origin, reconstructed from a retained delivery before the child becomes ready. */
|
|
649
|
+
var WorkerOriginRecorded = class extends Schema.TaggedClass()("WorkerOriginRecorded", { origin: WorkerOrigin }) {};
|
|
650
|
+
/** Canonical child completion acknowledgement releases only this input's active capacity. */
|
|
651
|
+
var WorkerInputCompleted = class extends Schema.TaggedClass()("WorkerInputCompleted", {
|
|
652
|
+
messageId: IdempotencyKey,
|
|
653
|
+
workerThreadId: ThreadId,
|
|
654
|
+
submissionId: SubmissionId,
|
|
655
|
+
receiptId: ReceiptId,
|
|
656
|
+
settlementId: SettlementId,
|
|
657
|
+
completedAtMillis: Schema.Natural
|
|
658
|
+
}) {};
|
|
659
|
+
/**
|
|
660
|
+
* Frozen report decision for one actual Run, shared by every joined Receipt. The envelope is
|
|
661
|
+
* a Schema-encoded PreparedInput, validated before append and decoded again on recovery.
|
|
662
|
+
* Keeping the encoded value here avoids a Records/PreparedInput schema dependency cycle.
|
|
663
|
+
*/
|
|
664
|
+
var WorkerReportPrepared = class extends Schema.TaggedClass()("WorkerReportPrepared", {
|
|
665
|
+
runId: RunId,
|
|
666
|
+
messageId: IdempotencyKey,
|
|
667
|
+
envelope: PersistedJson,
|
|
668
|
+
createdAtMillis: Schema.Natural,
|
|
669
|
+
deadlineAtMillis: Schema.Natural,
|
|
670
|
+
predecessor: Schema.optionalKey(IdempotencyKey)
|
|
671
|
+
}) {};
|
|
672
|
+
/** Accepted update and its optional frozen parent delivery are one atomic canonical fact. */
|
|
673
|
+
var AgentUpdateEmitted = class extends Schema.TaggedClass()("AgentUpdateEmitted", {
|
|
674
|
+
update: Update,
|
|
675
|
+
definitions: DefinitionDigests,
|
|
676
|
+
delivery: Schema.optionalKey(Schema.Struct({
|
|
677
|
+
messageId: IdempotencyKey,
|
|
678
|
+
envelope: PersistedJson,
|
|
679
|
+
createdAtMillis: Schema.Natural,
|
|
680
|
+
deadlineAtMillis: Schema.Natural,
|
|
681
|
+
predecessor: Schema.optionalKey(IdempotencyKey)
|
|
682
|
+
}))
|
|
683
|
+
}) {};
|
|
684
|
+
/** Permanent bounded report refusal. Application errors and raw Run dispositions stay private. */
|
|
685
|
+
var WorkerReportRefused = class extends Schema.TaggedClass()("WorkerReportRefused", {
|
|
686
|
+
runId: RunId,
|
|
687
|
+
messageId: IdempotencyKey,
|
|
688
|
+
reason: Schema.Literals([
|
|
689
|
+
"declaration-unavailable",
|
|
690
|
+
"destination",
|
|
691
|
+
"projection",
|
|
692
|
+
"input",
|
|
693
|
+
"preparation",
|
|
694
|
+
"timeout",
|
|
695
|
+
"defect",
|
|
696
|
+
"expired",
|
|
697
|
+
"denied",
|
|
698
|
+
"capacity"
|
|
699
|
+
])
|
|
700
|
+
}) {};
|
|
701
|
+
/** Frozen source proof of peer provenance, readable through routed canonical storage. */
|
|
702
|
+
var PeerMessagePrepared = class extends Schema.TaggedClass()("PeerMessagePrepared", {
|
|
703
|
+
messageId: IdempotencyKey,
|
|
704
|
+
sourcePrincipal: Principal,
|
|
705
|
+
operation: Schema.Literals(["send", "reply"]),
|
|
706
|
+
deadlineAtMillis: Schema.Int.check(Schema.isGreaterThan(0)),
|
|
707
|
+
encodedEnvelope: PersistedJson
|
|
708
|
+
}) {};
|
|
709
|
+
/**
|
|
710
|
+
* One disjoint subtree slice shared by attached and background children of a source input.
|
|
711
|
+
* The source keeps its own execution ceiling; descendants spend only the remaining allocation.
|
|
712
|
+
* Reservations include future descendant slots and never refund, including after interruption.
|
|
713
|
+
* resultBytes reserves the terminal/projection result, not cumulative Tool output bytes.
|
|
714
|
+
*/
|
|
715
|
+
var SubtreeBudgetReserved = class extends Schema.TaggedClass()("SubtreeBudgetReserved", {
|
|
716
|
+
reservationId: BoundedName,
|
|
717
|
+
sourceSubmissionId: Schema.optionalKey(SubmissionId),
|
|
718
|
+
childThreadId: ThreadId,
|
|
719
|
+
lifetime: Schema.Literals(["attached", "background"]),
|
|
720
|
+
depth: DelegationDepth,
|
|
721
|
+
policy: Schema.toCodecJson(AgentPolicy),
|
|
722
|
+
grant: SubagentGrant,
|
|
723
|
+
budget: SubagentBudgetReservation
|
|
724
|
+
}) {};
|
|
725
|
+
/**
|
|
726
|
+
* Current private-development canonical payload family. Phase 5 adds the seven durable-Tool tags
|
|
727
|
+
* (prepared/unknown/resolved/step/approval-request/approval-decision/interrupted) additively; S2
|
|
728
|
+
* adds the four durable-Subagent tags (requested/started/joined/lineage) additively, so the
|
|
729
|
+
* envelope keeps `schemaVersion: 1` (P4 precedent for additive payload tags).
|
|
730
|
+
*/
|
|
731
|
+
const CanonicalRecordPayload = Schema.Union([
|
|
732
|
+
ThreadCreated,
|
|
733
|
+
UserInputRecorded,
|
|
734
|
+
RunStartedRecord,
|
|
735
|
+
RunPolicyUsageReserved,
|
|
736
|
+
ModelCompleted,
|
|
737
|
+
ModelResponseRecorded,
|
|
738
|
+
ToolCallPrepared,
|
|
739
|
+
ToolCallSettled,
|
|
740
|
+
ToolCallUnknown,
|
|
741
|
+
ToolCallResolved,
|
|
742
|
+
ToolStepSettled,
|
|
743
|
+
ToolApprovalRequested,
|
|
744
|
+
ToolApprovalDecided,
|
|
745
|
+
ModelResponseInterrupted,
|
|
746
|
+
CompactionCreated,
|
|
747
|
+
RunFailed,
|
|
748
|
+
RunCompleted,
|
|
749
|
+
AbortRequested,
|
|
750
|
+
SubmissionSettledRecord,
|
|
751
|
+
SubagentRequested,
|
|
752
|
+
SubagentStarted,
|
|
753
|
+
SubagentJoined,
|
|
754
|
+
SubagentLineageRecorded,
|
|
755
|
+
WorkerInputRequested,
|
|
756
|
+
WorkerOriginRecorded,
|
|
757
|
+
WorkerInputCompleted,
|
|
758
|
+
WorkerReportPrepared,
|
|
759
|
+
AgentUpdateEmitted,
|
|
760
|
+
WorkerReportRefused,
|
|
761
|
+
PeerMessagePrepared,
|
|
762
|
+
SubtreeBudgetReserved,
|
|
763
|
+
RepairAnnotated
|
|
764
|
+
]);
|
|
765
|
+
/**
|
|
766
|
+
* Versioned record envelope stored in an atomic batch. Thread ordering is assigned only
|
|
767
|
+
* when the batch is committed.
|
|
768
|
+
*/
|
|
769
|
+
var RecordEnvelope = class extends Schema.Class("@effect-agent/thread/RecordEnvelope")({
|
|
770
|
+
recordId: RecordId,
|
|
771
|
+
family: Schema.Literal("thread"),
|
|
772
|
+
schemaVersion: Schema.Literal(1),
|
|
773
|
+
createdAt: Schema.DateTimeUtcFromString,
|
|
774
|
+
deploymentId: DeploymentId,
|
|
775
|
+
payload: CanonicalRecordPayload
|
|
776
|
+
}) {};
|
|
777
|
+
/** Backward-compatible domain name for a canonical record. */
|
|
778
|
+
const CanonicalRecord = RecordEnvelope;
|
|
779
|
+
/** One non-empty, bounded, idempotent atomic append unit. */
|
|
780
|
+
var CanonicalBatch = class extends Schema.Class("@effect-agent/thread/CanonicalBatch")({
|
|
781
|
+
batchId: BatchId,
|
|
782
|
+
producerId: ProducerId,
|
|
783
|
+
records: Schema.NonEmptyArray(RecordEnvelope).check(Schema.isMaxLength(256))
|
|
784
|
+
}) {};
|
|
785
|
+
/**
|
|
786
|
+
* A committed record with its Thread ordering and opaque resumable observation cursor.
|
|
787
|
+
*/
|
|
788
|
+
var CanonicalRecordEnvelope = class extends Schema.Class("@effect-agent/thread/CanonicalRecordEnvelope")({
|
|
789
|
+
threadId: ThreadId,
|
|
790
|
+
batchId: BatchId,
|
|
791
|
+
sequence: CanonicalSequence,
|
|
792
|
+
offset: ObservationOffset,
|
|
793
|
+
record: RecordEnvelope
|
|
794
|
+
}) {};
|
|
795
|
+
const CURRENT_CANONICAL_SCHEMA_VERSION = 1;
|
|
796
|
+
//#endregion
|
|
797
|
+
export { ToolStepSettled as $, Records_exports as A, SubagentRequested as B, ObservationOffset as C, ProducerId as D, ProducerEpoch as E, RunStartedRecord as F, ThreadCreated as G, SubmissionSettled as H, SettlementFailureDiagnostic as I, ToolCallPrepared as J, ToolApprovalDecided as K, SettlementOutcome as L, RunCompleted as M, RunFailed as N, RecordEnvelope as O, RunPolicyUsageReserved as P, ToolCallUnknown as Q, SubagentJoined as R, ModelResponseRecorded as S, PersistedJson as T, SubmissionSettledRecord as U, SubagentStarted as V, SubtreeBudgetReserved as W, ToolCallResolved as X, ToolCallResolution as Y, ToolCallSettled as Z, MAX_PERSISTED_JSON_COLLECTION_LENGTH as _, CURRENT_CANONICAL_SCHEMA_VERSION as a, WorkerOriginRecorded as at, ModelCompleted as b, CanonicalRecordEnvelope as c, WorkerReportingIntent as ct, CompactionCreated as d, UserInputRecorded as et, DefinitionDigestInput as f, MAX_PERSISTED_JSON_BYTES as g, Digest as h, BatchId as i, WorkerOrigin as it, RepairAnnotated as j, RecordId as k, CanonicalRecordPayload as l, strictSchema as lt, DeploymentId as m, AgentUpdateEmitted as n, WorkerInputCompleted as nt, CanonicalBatch as o, WorkerReportPrepared as ot, DefinitionDigests as p, ToolApprovalRequested as q, ApprovalDecision as r, WorkerInputRequested as rt, CanonicalRecord as s, WorkerReportRefused as st, AbortRequested as t, WorkerAdmission as tt, CanonicalSequence as u, MAX_PERSISTED_JSON_DEPTH as v, PeerMessagePrepared as w, ModelResponseInterrupted as x, MAX_PERSISTED_JSON_NODES as y, SubagentLineageRecorded as z };
|
|
798
|
+
|
|
799
|
+
//# sourceMappingURL=Records-C9cezOEf.mjs.map
|