@usine/core 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -21
- package/README.md +43 -18
- package/dist/agent/agent.d.ts +12 -8
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.js +14 -10
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/brain.d.ts +2 -6
- package/dist/agent/brain.d.ts.map +1 -1
- package/dist/agent/brain.js +3 -7
- package/dist/agent/brain.js.map +1 -1
- package/dist/agent/capability.d.ts +4 -4
- package/dist/agent/capability.d.ts.map +1 -1
- package/dist/agent/capability.js +4 -4
- package/dist/agent/capability.js.map +1 -1
- package/dist/agent/session.d.ts +90 -28
- package/dist/agent/session.d.ts.map +1 -1
- package/dist/agent/session.js +103 -28
- package/dist/agent/session.js.map +1 -1
- package/dist/attempt/attempt.d.ts +92 -12
- package/dist/attempt/attempt.d.ts.map +1 -1
- package/dist/attempt/attempt.js +114 -13
- package/dist/attempt/attempt.js.map +1 -1
- package/dist/attempt/channel.d.ts +91 -51
- package/dist/attempt/channel.d.ts.map +1 -1
- package/dist/attempt/channel.js +74 -45
- package/dist/attempt/channel.js.map +1 -1
- package/dist/attempt/failure.d.ts +27 -14
- package/dist/attempt/failure.d.ts.map +1 -1
- package/dist/attempt/failure.js +27 -14
- package/dist/attempt/failure.js.map +1 -1
- package/dist/attempt/outcome.d.ts +3 -5
- package/dist/attempt/outcome.d.ts.map +1 -1
- package/dist/attempt/outcome.js +2 -4
- package/dist/attempt/outcome.js.map +1 -1
- package/dist/attempt/salvage.d.ts +77 -0
- package/dist/attempt/salvage.d.ts.map +1 -0
- package/dist/attempt/salvage.js +49 -0
- package/dist/attempt/salvage.js.map +1 -0
- package/dist/attempt/start.d.ts +35 -0
- package/dist/attempt/start.d.ts.map +1 -0
- package/dist/attempt/start.js +30 -0
- package/dist/attempt/start.js.map +1 -0
- package/dist/closed-struct.d.ts +7 -0
- package/dist/closed-struct.d.ts.map +1 -0
- package/dist/closed-struct.js +12 -0
- package/dist/closed-struct.js.map +1 -0
- package/dist/cycle-budget.d.ts +7 -8
- package/dist/cycle-budget.d.ts.map +1 -1
- package/dist/cycle-budget.js +16 -20
- package/dist/cycle-budget.js.map +1 -1
- package/dist/event.d.ts +4 -8
- package/dist/event.d.ts.map +1 -1
- package/dist/event.js +4 -8
- package/dist/event.js.map +1 -1
- package/dist/instance.d.ts +7 -1
- package/dist/instance.d.ts.map +1 -1
- package/dist/instance.js +6 -1
- package/dist/instance.js.map +1 -1
- package/dist/item.d.ts +1 -2
- package/dist/item.d.ts.map +1 -1
- package/dist/item.js +1 -2
- package/dist/item.js.map +1 -1
- package/dist/loop.d.ts +10 -2
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +9 -2
- package/dist/loop.js.map +1 -1
- package/dist/operator.d.ts +8 -0
- package/dist/operator.d.ts.map +1 -0
- package/dist/operator.js +9 -0
- package/dist/operator.js.map +1 -0
- package/dist/repository.d.ts +6 -8
- package/dist/repository.d.ts.map +1 -1
- package/dist/repository.js +8 -10
- package/dist/repository.js.map +1 -1
- package/dist/run/again.d.ts +13 -0
- package/dist/run/again.d.ts.map +1 -0
- package/dist/run/again.js +14 -0
- package/dist/run/again.js.map +1 -0
- package/dist/run/approval.d.ts +27 -0
- package/dist/run/approval.d.ts.map +1 -0
- package/dist/run/approval.js +25 -0
- package/dist/run/approval.js.map +1 -0
- package/dist/run/run.d.ts +2 -2
- package/dist/run/run.d.ts.map +1 -1
- package/dist/run/run.js +2 -2
- package/dist/run/run.js.map +1 -1
- package/dist/run/state.d.ts +22 -31
- package/dist/run/state.d.ts.map +1 -1
- package/dist/run/state.js +23 -36
- package/dist/run/state.js.map +1 -1
- package/dist/step/harvest.d.ts +44 -0
- package/dist/step/harvest.d.ts.map +1 -0
- package/dist/step/harvest.js +368 -0
- package/dist/step/harvest.js.map +1 -0
- package/dist/step/result.d.ts +15 -4
- package/dist/step/result.d.ts.map +1 -1
- package/dist/step/result.js +14 -4
- package/dist/step/result.js.map +1 -1
- package/dist/step/step.d.ts +2 -8
- package/dist/step/step.d.ts.map +1 -1
- package/dist/step/step.js +2 -8
- package/dist/step/step.js.map +1 -1
- package/dist/worker.d.ts +160 -4
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +171 -4
- package/dist/worker.js.map +1 -1
- package/package.json +32 -7
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { Effect, Result, Schema } from "effect";
|
|
2
2
|
import { Agent } from "../agent/agent.ts";
|
|
3
|
-
import { AttemptId } from "./attempt.ts";
|
|
4
|
-
import { StepResult } from "../step/result.ts";
|
|
3
|
+
import { AttemptId, type AttemptWindows, type ContainerOutOfMemoryKills } from "./attempt.ts";
|
|
4
|
+
import { type Comment, StepResult } from "../step/result.ts";
|
|
5
5
|
import { AttemptFailure } from "./failure.ts";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* engine's transcript sequence, which orders persisted rows globally.
|
|
10
|
-
*/
|
|
6
|
+
import { AttemptSalvage, SalvagePushed } from "./salvage.ts";
|
|
7
|
+
export declare const PROTOCOL_VERSION: 7;
|
|
8
|
+
/** The per-Attempt, per-direction message sequence, starting at 1; distinct from the transcript sequence. */
|
|
11
9
|
export declare const Sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
12
10
|
export type Sequence = typeof Sequence.Type;
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* The directions relative to the Attempt's parent: `inbound` for operator input and Cancel, and
|
|
13
|
+
* `outbound` for activity and outcome.
|
|
16
14
|
*/
|
|
17
15
|
export declare const DIRECTIONS: readonly ["inbound", "outbound"];
|
|
18
16
|
export declare const Direction: Schema.Literals<readonly ["inbound", "outbound"]>;
|
|
@@ -28,23 +26,32 @@ declare const RunSpec_base: Schema.Class<RunSpec, Schema.Struct<{
|
|
|
28
26
|
readonly parentModel: Schema.OptionFromNullOr<Schema.brand<Schema.String, "ModelId">>;
|
|
29
27
|
readonly maxChildren: Schema.brand<Schema.Int, "ChildSessionBudget">;
|
|
30
28
|
readonly parentEffort: Schema.Literals<readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"]>;
|
|
29
|
+
/** The previous Attempt's pushed salvage, applied on top of `baseCommit` and rebased if the base moved. */
|
|
30
|
+
readonly resume: Schema.OptionFromNullOr<typeof SalvagePushed>;
|
|
31
|
+
/** The previous Attempt's pushed salvage that conflicts with `baseCommit` and isn't applied. */
|
|
32
|
+
readonly conflictingSalvage: Schema.withConstructorDefault<Schema.withDecodingDefaultKey<Schema.OptionFromNullOr<typeof SalvagePushed>, never>>;
|
|
33
|
+
/** The time the Worker prepared the checkout, from which harvesting reads the Item, or `None` for older Attempts. */
|
|
34
|
+
readonly preparedAt: Schema.withDecodingDefaultKey<Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>, never>;
|
|
35
|
+
/**
|
|
36
|
+
* The GitHub login the Attempt writes as. If `None`, harvesting asks GitHub for the credential's
|
|
37
|
+
* login.
|
|
38
|
+
*/
|
|
39
|
+
readonly botLogin: Schema.withDecodingDefaultKey<Schema.OptionFromNullOr<Schema.brand<Schema.String, "BotLogin">>, never>;
|
|
31
40
|
}>, {}>;
|
|
32
|
-
/**
|
|
41
|
+
/** The launch input for one Attempt, without Worker credentials. */
|
|
33
42
|
export declare class RunSpec extends RunSpec_base {
|
|
34
43
|
}
|
|
35
44
|
declare const Started_base: Schema.Class<Started, Schema.TaggedStruct<"Started", {
|
|
36
45
|
readonly parentModel: Schema.brand<Schema.String, "ModelId">;
|
|
46
|
+
readonly conflictingSalvage: Schema.withConstructorDefault<Schema.withDecodingDefaultKey<Schema.OptionFromNullOr<typeof SalvagePushed>, never>>;
|
|
37
47
|
}>, {}>;
|
|
38
|
-
/**
|
|
39
|
-
* The parent model the SDK selected at launch, which the roster may not declare.
|
|
40
|
-
* Child sessions report their own model in `SessionStarted` events.
|
|
41
|
-
*/
|
|
48
|
+
/** The start of an Attempt, with the parent model selected at launch, which can differ from the roster. */
|
|
42
49
|
export declare class Started extends Started_base {
|
|
43
50
|
}
|
|
44
51
|
declare const SessionEvent_base: Schema.Class<SessionEvent, Schema.TaggedStruct<"SessionEvent", {
|
|
45
|
-
readonly event: Schema.Union<readonly [typeof import("../agent/session.ts").SessionStarted, typeof import("../agent/session.ts").TextOutput, typeof import("../agent/session.ts").ToolStarted, typeof import("../agent/session.ts").ToolFinished, typeof import("../agent/session.ts").PoolRateLimitsUpdated, typeof import("../agent/session.ts").SessionFinished, typeof import("../agent/session.ts").SessionIdle, typeof import("../agent/session.ts").SessionResumed, typeof import("../agent/session.ts").SessionTokensUpdated]>;
|
|
52
|
+
readonly event: Schema.Union<readonly [typeof import("../agent/session.ts").SessionStarted, typeof import("../agent/session.ts").TextOutput, typeof import("../agent/session.ts").ToolStarted, typeof import("../agent/session.ts").ToolFinished, typeof import("../agent/session.ts").PoolRateLimitsUpdated, typeof import("../agent/session.ts").SessionFinished, typeof import("../agent/session.ts").SessionIdle, typeof import("../agent/session.ts").SessionResumed, typeof import("../agent/session.ts").SessionTokensUpdated, typeof import("../agent/session.ts").ProviderRetrying, typeof import("../agent/session.ts").ProviderRecovered]>;
|
|
46
53
|
}>, {}>;
|
|
47
|
-
/**
|
|
54
|
+
/** A normalized parent or child session event, persisted in the Attempt transcript. */
|
|
48
55
|
export declare class SessionEvent extends SessionEvent_base {
|
|
49
56
|
}
|
|
50
57
|
declare const Final_base: Schema.Class<Final, Schema.TaggedStruct<"Final", {
|
|
@@ -53,12 +60,12 @@ declare const Final_base: Schema.Class<Final, Schema.TaggedStruct<"Final", {
|
|
|
53
60
|
export declare class Final extends Final_base {
|
|
54
61
|
}
|
|
55
62
|
declare const Failed_base: Schema.Class<Failed, Schema.TaggedStruct<"Failed", {
|
|
56
|
-
readonly failure: Schema.Union<readonly [typeof import("./failure.ts").InfraFailure, typeof import("./failure.ts").DefectFailure, typeof import("./failure.ts").AgentFailure, typeof import("./failure.ts").RunawayFailure, typeof import("./failure.ts").ChildSessionBudgetFailure]>;
|
|
63
|
+
readonly failure: Schema.Union<readonly [typeof import("./failure.ts").InfraFailure, typeof import("./failure.ts").DefectFailure, typeof import("./failure.ts").AgentFailure, typeof import("./failure.ts").BlockedFailure, typeof import("./failure.ts").QuestionFailure, typeof import("./failure.ts").RunawayFailure, typeof import("./failure.ts").ChildSessionBudgetFailure]>;
|
|
57
64
|
}>, {}>;
|
|
58
65
|
export declare class Failed extends Failed_base {
|
|
59
66
|
}
|
|
60
67
|
declare const Interrupted_base: Schema.Class<Interrupted, Schema.TaggedStruct<"Interrupted", {}>, {}>;
|
|
61
|
-
/** The
|
|
68
|
+
/** The parent's terminal acknowledgment of cancellation. */
|
|
62
69
|
export declare class Interrupted extends Interrupted_base {
|
|
63
70
|
}
|
|
64
71
|
declare const Steer_base: Schema.Class<Steer, Schema.TaggedStruct<"Steer", {
|
|
@@ -70,35 +77,37 @@ declare const Interrupt_base: Schema.Class<Interrupt, Schema.TaggedStruct<"Inter
|
|
|
70
77
|
export declare class Interrupt extends Interrupt_base {
|
|
71
78
|
}
|
|
72
79
|
declare const Cancel_base: Schema.Class<Cancel, Schema.TaggedStruct<"Cancel", {}>, {}>;
|
|
73
|
-
/**
|
|
80
|
+
/** The request to stop the whole Attempt, including held and paused sessions. */
|
|
74
81
|
export declare class Cancel extends Cancel_base {
|
|
75
82
|
}
|
|
76
83
|
declare const OperatorMessage_base: Schema.Class<OperatorMessage, Schema.TaggedStruct<"OperatorMessage", {
|
|
77
84
|
readonly message: Schema.NonEmptyString;
|
|
78
85
|
}>, {}>;
|
|
79
|
-
/** An operator turn
|
|
86
|
+
/** An operator turn for the target session; unlike `Steer`, it puts the session on hold (ADR 0018). */
|
|
80
87
|
export declare class OperatorMessage extends OperatorMessage_base {
|
|
81
88
|
}
|
|
82
89
|
declare const Release_base: Schema.Class<Release, Schema.TaggedStruct<"Release", {}>, {}>;
|
|
83
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* The request to end a takeover (ADR 0018). A held child returns its idle result to the parent,
|
|
92
|
+
* and a held or paused parent resumes the task.
|
|
93
|
+
*/
|
|
84
94
|
export declare class Release extends Release_base {
|
|
85
95
|
}
|
|
86
|
-
/**
|
|
96
|
+
/** The non-terminal operator actions; `Cancel` is separate. */
|
|
87
97
|
export declare const OperatorAction: Schema.Union<readonly [typeof Steer, typeof Interrupt, typeof OperatorMessage, typeof Release]>;
|
|
88
98
|
export type OperatorAction = typeof OperatorAction.Type;
|
|
89
99
|
export declare const InboundPayload: Schema.Union<readonly [Schema.Union<readonly [typeof Steer, typeof Interrupt, typeof OperatorMessage, typeof Release]>, typeof Cancel]>;
|
|
90
100
|
export type InboundPayload = typeof InboundPayload.Type;
|
|
91
101
|
declare const ParentTarget_base: Schema.Class<ParentTarget, Schema.TaggedStruct<"Parent", {}>, {}>;
|
|
92
|
-
/** The
|
|
102
|
+
/** The default target of operator input. */
|
|
93
103
|
export declare class ParentTarget extends ParentTarget_base {
|
|
94
104
|
}
|
|
95
105
|
declare const ChildTarget_base: Schema.Class<ChildTarget, Schema.TaggedStruct<"Child", {
|
|
96
106
|
readonly sessionId: Schema.brand<Schema.NonEmptyString, "AgentSessionId">;
|
|
97
107
|
}>, {}>;
|
|
98
|
-
/** A
|
|
108
|
+
/** A child session, addressed by the session ID in its events. */
|
|
99
109
|
export declare class ChildTarget extends ChildTarget_base {
|
|
100
110
|
}
|
|
101
|
-
/** Which session inside an Attempt an inbound frame addresses: the Pi parent, or one of its children. */
|
|
102
111
|
export declare const SessionTarget: Schema.Union<readonly [typeof ParentTarget, typeof ChildTarget]>;
|
|
103
112
|
export type SessionTarget = typeof SessionTarget.Type;
|
|
104
113
|
declare const Intervention_base: Schema.Class<Intervention, Schema.Struct<{
|
|
@@ -106,12 +115,17 @@ declare const Intervention_base: Schema.Class<Intervention, Schema.Struct<{
|
|
|
106
115
|
readonly target: Schema.Union<readonly [typeof ParentTarget, typeof ChildTarget]>;
|
|
107
116
|
readonly action: Schema.Union<readonly [typeof Steer, typeof Interrupt, typeof OperatorMessage, typeof Release]>;
|
|
108
117
|
}>, {}>;
|
|
109
|
-
/**
|
|
118
|
+
/** Operator input for one live session, never stored as an Event. */
|
|
110
119
|
export declare class Intervention extends Intervention_base {
|
|
111
120
|
}
|
|
112
121
|
declare const InterventionState_base: Schema.Class<InterventionState, Schema.Struct<{
|
|
113
122
|
readonly held: Schema.Boolean;
|
|
114
123
|
readonly paused: Schema.Boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Whether the session reads the message only after its current tool call returns. A later
|
|
126
|
+
* receipt with the same input sequence reports delivery or rejection.
|
|
127
|
+
*/
|
|
128
|
+
readonly queued: Schema.withConstructorDefault<Schema.withDecodingDefaultKey<Schema.Boolean, never>>;
|
|
115
129
|
}>, {}>;
|
|
116
130
|
/** The session's supervision state after an accepted operator action. */
|
|
117
131
|
export declare class InterventionState extends InterventionState_base {
|
|
@@ -121,7 +135,10 @@ declare const InterventionApplied_base: Schema.Class<InterventionApplied, Schema
|
|
|
121
135
|
readonly intervention: typeof Intervention;
|
|
122
136
|
readonly state: typeof InterventionState;
|
|
123
137
|
}>, {}>;
|
|
124
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* The receipt for an accepted operator input, with the resulting hold or pause state. A queued
|
|
140
|
+
* input gets a second receipt with the same `inputSequence` when the session reads it.
|
|
141
|
+
*/
|
|
125
142
|
export declare class InterventionApplied extends InterventionApplied_base {
|
|
126
143
|
}
|
|
127
144
|
declare const InterventionRejected_base: Schema.Class<InterventionRejected, Schema.TaggedStruct<"InterventionRejected", {
|
|
@@ -129,26 +146,49 @@ declare const InterventionRejected_base: Schema.Class<InterventionRejected, Sche
|
|
|
129
146
|
readonly intervention: typeof Intervention;
|
|
130
147
|
readonly message: Schema.NonEmptyString;
|
|
131
148
|
}>, {}>;
|
|
132
|
-
/**
|
|
149
|
+
/** The rejection of an operator action by a closed or refusing session; the Attempt continues. */
|
|
133
150
|
export declare class InterventionRejected extends InterventionRejected_base {
|
|
134
151
|
}
|
|
135
|
-
|
|
152
|
+
declare const WorkerUnresponsive_base: Schema.Class<WorkerUnresponsive, Schema.TaggedStruct<"WorkerUnresponsive", {
|
|
153
|
+
readonly worker: Schema.brand<Schema.String, "WorkerName">;
|
|
154
|
+
/** The last successful probe, or the Attempt's launch time if no probe has run. */
|
|
155
|
+
readonly lastAnsweredAt: Schema.DateTimeUtcFromString;
|
|
156
|
+
/** The probe error, such as the SSH client's error or the exceeded timeout. */
|
|
157
|
+
readonly reason: Schema.NonEmptyString;
|
|
158
|
+
}>, {}>;
|
|
159
|
+
/**
|
|
160
|
+
* A probe of the Worker that didn't run a command over a new SSH connection within its timeout.
|
|
161
|
+
* The Attempt isn't stopped or failed (ADR 0013).
|
|
162
|
+
*/
|
|
163
|
+
export declare class WorkerUnresponsive extends WorkerUnresponsive_base {
|
|
164
|
+
}
|
|
165
|
+
declare const WorkerResponsive_base: Schema.Class<WorkerResponsive, Schema.TaggedStruct<"WorkerResponsive", {
|
|
166
|
+
readonly worker: Schema.brand<Schema.String, "WorkerName">;
|
|
167
|
+
/** The value from the preceding `WorkerUnresponsive`. */
|
|
168
|
+
readonly lastAnsweredAt: Schema.DateTimeUtcFromString;
|
|
169
|
+
}>, {}>;
|
|
170
|
+
/** A successful probe after `WorkerUnresponsive`. */
|
|
171
|
+
export declare class WorkerResponsive extends WorkerResponsive_base {
|
|
172
|
+
}
|
|
173
|
+
export declare const WorkerNotice: Schema.Union<readonly [typeof WorkerUnresponsive, typeof WorkerResponsive]>;
|
|
174
|
+
export type WorkerNotice = typeof WorkerNotice.Type;
|
|
175
|
+
export declare const OutboundPayload: Schema.Union<readonly [typeof Started, typeof SessionEvent, typeof Final, typeof Failed, typeof Interrupted, typeof InterventionApplied, typeof InterventionRejected, typeof WorkerUnresponsive, typeof WorkerResponsive]>;
|
|
136
176
|
export type OutboundPayload = typeof OutboundPayload.Type;
|
|
137
177
|
declare const OutboundEnvelope_base: Schema.Class<OutboundEnvelope, Schema.TaggedStruct<"OutboundEnvelope", {
|
|
138
|
-
readonly version: Schema.Literal<
|
|
178
|
+
readonly version: Schema.Literal<7>;
|
|
139
179
|
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
140
180
|
readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
141
181
|
readonly sentAt: Schema.DateTimeUtcFromString;
|
|
142
|
-
readonly payload: Schema.Union<readonly [typeof Started, typeof SessionEvent, typeof Final, typeof Failed, typeof Interrupted, typeof InterventionApplied, typeof InterventionRejected]>;
|
|
182
|
+
readonly payload: Schema.Union<readonly [typeof Started, typeof SessionEvent, typeof Final, typeof Failed, typeof Interrupted, typeof InterventionApplied, typeof InterventionRejected, typeof WorkerUnresponsive, typeof WorkerResponsive]>;
|
|
143
183
|
}>, {}>;
|
|
144
184
|
export declare class OutboundEnvelope extends OutboundEnvelope_base {
|
|
145
185
|
}
|
|
146
186
|
declare const InboundEnvelope_base: Schema.Class<InboundEnvelope, Schema.TaggedStruct<"InboundEnvelope", {
|
|
147
|
-
readonly version: Schema.Literal<
|
|
187
|
+
readonly version: Schema.Literal<7>;
|
|
148
188
|
readonly attemptId: Schema.brand<Schema.NonEmptyString, "AttemptId">;
|
|
149
189
|
readonly sequence: Schema.brand<Schema.Int, "AttemptChannelSequence">;
|
|
150
190
|
readonly sentAt: Schema.DateTimeUtcFromString;
|
|
151
|
-
/** The session
|
|
191
|
+
/** The target session, the parent by default. */
|
|
152
192
|
readonly target: Schema.withDecodingDefaultKey<Schema.Union<readonly [typeof ParentTarget, typeof ChildTarget]>, never>;
|
|
153
193
|
readonly operator: Schema.NonEmptyString;
|
|
154
194
|
readonly payload: Schema.Union<readonly [Schema.Union<readonly [typeof Steer, typeof Interrupt, typeof OperatorMessage, typeof Release]>, typeof Cancel]>;
|
|
@@ -157,37 +197,37 @@ export declare class InboundEnvelope extends InboundEnvelope_base {
|
|
|
157
197
|
}
|
|
158
198
|
export declare const Envelope: Schema.Union<readonly [typeof OutboundEnvelope, typeof InboundEnvelope]>;
|
|
159
199
|
export type Envelope = typeof Envelope.Type;
|
|
160
|
-
|
|
161
|
-
readonly version: Schema.Literal<6>;
|
|
162
|
-
readonly spec: typeof RunSpec;
|
|
163
|
-
}>, {}>;
|
|
164
|
-
/** The first framed stdin message. Later frames are inbound envelopes. */
|
|
165
|
-
export declare class Start extends Start_base {
|
|
166
|
-
}
|
|
167
|
-
export declare const InputFrame: Schema.Union<readonly [typeof Start, typeof InboundEnvelope]>;
|
|
168
|
-
export type InputFrame = typeof InputFrame.Type;
|
|
169
|
-
export declare const EnvelopeFromJson: Schema.fromJsonString<Schema.Union<readonly [typeof OutboundEnvelope, typeof InboundEnvelope]>>;
|
|
170
|
-
export declare const InputFrameFromJson: Schema.fromJsonString<Schema.Union<readonly [typeof Start, typeof InboundEnvelope]>>;
|
|
171
|
-
export declare const OutboundEnvelopeFromJson: Schema.fromJsonString<typeof OutboundEnvelope>;
|
|
172
|
-
/** Where a channel consumer persists envelopes. */
|
|
200
|
+
/** The orchestrator storage that an executor uses for one Attempt. */
|
|
173
201
|
export interface Sink {
|
|
174
202
|
readonly append: (direction: Direction, envelope: Envelope) => Effect.Effect<void, AttemptFailure>;
|
|
203
|
+
/** Records what the executor kept of the workspace after an unsuccessful end. */
|
|
204
|
+
readonly salvage: (salvage: AttemptSalvage) => Effect.Effect<void, AttemptFailure>;
|
|
205
|
+
/** Records the comments and reviews an unsuccessful Attempt posted on the Run's Item. */
|
|
206
|
+
readonly comments: (comments: ReadonlyArray<Comment>) => Effect.Effect<void, AttemptFailure>;
|
|
207
|
+
/**
|
|
208
|
+
* Records the processes that the kernel killed in one of the Attempt's containers for memory.
|
|
209
|
+
* The kills of the Attempt's other containers stay; a second record of a container replaces
|
|
210
|
+
* its count.
|
|
211
|
+
*/
|
|
212
|
+
readonly outOfMemory: (kills: ContainerOutOfMemoryKills) => Effect.Effect<void, AttemptFailure>;
|
|
213
|
+
/** Reads the Attempt windows; harvesting runs it after GitHub lists the Attempt's comments. */
|
|
214
|
+
readonly windows: Effect.Effect<AttemptWindows, AttemptFailure>;
|
|
215
|
+
/** Reads the envelopes recorded by `append`, in order; reattach uses them to restore counters. */
|
|
216
|
+
readonly transcript: Effect.Effect<ReadonlyArray<Envelope>, AttemptFailure>;
|
|
175
217
|
}
|
|
176
|
-
/** How far one outbound channel has legally progressed. */
|
|
177
218
|
export interface Progress {
|
|
178
219
|
readonly state: "AwaitingStarted" | "Running" | "Terminal";
|
|
179
220
|
readonly nextSequence: number;
|
|
180
221
|
}
|
|
181
222
|
export declare const initialProgress: Progress;
|
|
182
|
-
/**
|
|
223
|
+
/** A protocol violation, reported as an infrastructure failure. */
|
|
183
224
|
export interface Violation {
|
|
184
225
|
readonly message: string;
|
|
185
226
|
readonly detail: string;
|
|
186
227
|
}
|
|
187
228
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* machine through it.
|
|
229
|
+
* Validates an outbound envelope against `progress` and returns the next progress or the
|
|
230
|
+
* violation. Every outbound envelope passes through it before `append`.
|
|
191
231
|
*/
|
|
192
232
|
export declare const admit: (progress: Progress, attemptId: AttemptId, envelope: OutboundEnvelope) => Result.Result<Progress, Violation>;
|
|
193
233
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/attempt/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../src/attempt/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,OAAO,EACL,SAAS,EAET,KAAK,cAAc,EACnB,KAAK,yBAAyB,EAC/B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,O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,EAAE,SAAS,CAuCnC,CAAC"}
|
package/dist/attempt/channel.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import { Effect, Result, Schema } from "effect";
|
|
1
|
+
import { Effect, Option, Result, Schema } from "effect";
|
|
2
2
|
import { Agent } from "../agent/agent.js";
|
|
3
3
|
import { Effort, ModelId } from "../agent/brain.js";
|
|
4
4
|
import { AgentSessionEvent, AgentSessionId, ChildSessionBudget } from "../agent/session.js";
|
|
5
|
-
import { AttemptId, AttemptTask } from "./attempt.js";
|
|
5
|
+
import { AttemptId, AttemptTask, } from "./attempt.js";
|
|
6
6
|
import { RepositoryName, CommitSha, RepositoryRevision } from "../repository.js";
|
|
7
7
|
import { StepResult } from "../step/result.js";
|
|
8
|
+
import { BotLogin, WorkerName } from "../worker.js";
|
|
8
9
|
import { AttemptFailure } from "./failure.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* engine's transcript sequence, which orders persisted rows globally.
|
|
13
|
-
*/
|
|
10
|
+
import { AttemptSalvage, SalvagePushed } from "./salvage.js";
|
|
11
|
+
export const PROTOCOL_VERSION = 7;
|
|
12
|
+
/** The per-Attempt, per-direction message sequence, starting at 1; distinct from the transcript sequence. */
|
|
14
13
|
export const Sequence = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("AttemptChannelSequence"));
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* The directions relative to the Attempt's parent: `inbound` for operator input and Cancel, and
|
|
16
|
+
* `outbound` for activity and outcome.
|
|
18
17
|
*/
|
|
19
18
|
export const DIRECTIONS = ["inbound", "outbound"];
|
|
20
19
|
export const Direction = Schema.Literals(DIRECTIONS);
|
|
21
|
-
/**
|
|
20
|
+
/** The launch input for one Attempt, without Worker credentials. */
|
|
22
21
|
export class RunSpec extends Schema.Class("AttemptChannel/RunSpec")({
|
|
23
22
|
attemptId: AttemptId,
|
|
24
23
|
repository: RepositoryName,
|
|
@@ -30,17 +29,26 @@ export class RunSpec extends Schema.Class("AttemptChannel/RunSpec")({
|
|
|
30
29
|
parentModel: Schema.OptionFromNullOr(ModelId),
|
|
31
30
|
maxChildren: ChildSessionBudget,
|
|
32
31
|
parentEffort: Effort,
|
|
32
|
+
/** The previous Attempt's pushed salvage, applied on top of `baseCommit` and rebased if the base moved. */
|
|
33
|
+
resume: Schema.OptionFromNullOr(SalvagePushed),
|
|
34
|
+
/** The previous Attempt's pushed salvage that conflicts with `baseCommit` and isn't applied. */
|
|
35
|
+
conflictingSalvage: Schema.OptionFromNullOr(SalvagePushed).pipe(Schema.withDecodingDefaultKey(Effect.succeed(null)), Schema.withConstructorDefault(Effect.succeed(Option.none()))),
|
|
36
|
+
/** The time the Worker prepared the checkout, from which harvesting reads the Item, or `None` for older Attempts. */
|
|
37
|
+
preparedAt: Schema.OptionFromNullOr(Schema.DateTimeUtcFromString).pipe(Schema.withDecodingDefaultKey(Effect.succeed(null))),
|
|
38
|
+
/**
|
|
39
|
+
* The GitHub login the Attempt writes as. If `None`, harvesting asks GitHub for the credential's
|
|
40
|
+
* login.
|
|
41
|
+
*/
|
|
42
|
+
botLogin: Schema.OptionFromNullOr(BotLogin).pipe(Schema.withDecodingDefaultKey(Effect.succeed(null))),
|
|
33
43
|
}) {
|
|
34
44
|
}
|
|
35
|
-
/**
|
|
36
|
-
* The parent model the SDK selected at launch, which the roster may not declare.
|
|
37
|
-
* Child sessions report their own model in `SessionStarted` events.
|
|
38
|
-
*/
|
|
45
|
+
/** The start of an Attempt, with the parent model selected at launch, which can differ from the roster. */
|
|
39
46
|
export class Started extends Schema.TaggedClass("AttemptChannel/Started")("Started", {
|
|
40
47
|
parentModel: ModelId,
|
|
48
|
+
conflictingSalvage: Schema.OptionFromNullOr(SalvagePushed).pipe(Schema.withDecodingDefaultKey(Effect.succeed(null)), Schema.withConstructorDefault(Effect.succeed(Option.none()))),
|
|
41
49
|
}) {
|
|
42
50
|
}
|
|
43
|
-
/**
|
|
51
|
+
/** A normalized parent or child session event, persisted in the Attempt transcript. */
|
|
44
52
|
export class SessionEvent extends Schema.TaggedClass("AttemptChannel/SessionEvent")("SessionEvent", { event: AgentSessionEvent }) {
|
|
45
53
|
}
|
|
46
54
|
export class Final extends Schema.TaggedClass("AttemptChannel/Final")("Final", {
|
|
@@ -51,7 +59,7 @@ export class Failed extends Schema.TaggedClass("AttemptChannel/Failed")("Failed"
|
|
|
51
59
|
failure: AttemptFailure,
|
|
52
60
|
}) {
|
|
53
61
|
}
|
|
54
|
-
/** The
|
|
62
|
+
/** The parent's terminal acknowledgment of cancellation. */
|
|
55
63
|
export class Interrupted extends Schema.TaggedClass("AttemptChannel/Interrupted")("Interrupted", {}) {
|
|
56
64
|
}
|
|
57
65
|
export class Steer extends Schema.TaggedClass("AttemptChannel/Steer")("Steer", {
|
|
@@ -60,29 +68,31 @@ export class Steer extends Schema.TaggedClass("AttemptChannel/Steer")("Steer", {
|
|
|
60
68
|
}
|
|
61
69
|
export class Interrupt extends Schema.TaggedClass("AttemptChannel/Interrupt")("Interrupt", {}) {
|
|
62
70
|
}
|
|
63
|
-
/**
|
|
71
|
+
/** The request to stop the whole Attempt, including held and paused sessions. */
|
|
64
72
|
export class Cancel extends Schema.TaggedClass("AttemptChannel/Cancel")("Cancel", {}) {
|
|
65
73
|
}
|
|
66
|
-
/** An operator turn
|
|
74
|
+
/** An operator turn for the target session; unlike `Steer`, it puts the session on hold (ADR 0018). */
|
|
67
75
|
export class OperatorMessage extends Schema.TaggedClass("AttemptChannel/OperatorMessage")("OperatorMessage", {
|
|
68
76
|
message: Schema.NonEmptyString,
|
|
69
77
|
}) {
|
|
70
78
|
}
|
|
71
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* The request to end a takeover (ADR 0018). A held child returns its idle result to the parent,
|
|
81
|
+
* and a held or paused parent resumes the task.
|
|
82
|
+
*/
|
|
72
83
|
export class Release extends Schema.TaggedClass("AttemptChannel/Release")("Release", {}) {
|
|
73
84
|
}
|
|
74
|
-
/**
|
|
85
|
+
/** The non-terminal operator actions; `Cancel` is separate. */
|
|
75
86
|
export const OperatorAction = Schema.Union([Steer, Interrupt, OperatorMessage, Release]);
|
|
76
87
|
export const InboundPayload = Schema.Union([OperatorAction, Cancel]);
|
|
77
|
-
/** The
|
|
88
|
+
/** The default target of operator input. */
|
|
78
89
|
export class ParentTarget extends Schema.TaggedClass("AttemptChannel/ParentTarget")("Parent", {}) {
|
|
79
90
|
}
|
|
80
|
-
/** A
|
|
91
|
+
/** A child session, addressed by the session ID in its events. */
|
|
81
92
|
export class ChildTarget extends Schema.TaggedClass("AttemptChannel/ChildTarget")("Child", { sessionId: AgentSessionId }) {
|
|
82
93
|
}
|
|
83
|
-
/** Which session inside an Attempt an inbound frame addresses: the Pi parent, or one of its children. */
|
|
84
94
|
export const SessionTarget = Schema.Union([ParentTarget, ChildTarget]);
|
|
85
|
-
/**
|
|
95
|
+
/** Operator input for one live session, never stored as an Event. */
|
|
86
96
|
export class Intervention extends Schema.Class("AttemptChannel/Intervention")({
|
|
87
97
|
operator: Schema.NonEmptyString,
|
|
88
98
|
target: SessionTarget,
|
|
@@ -93,22 +103,50 @@ export class Intervention extends Schema.Class("AttemptChannel/Intervention")({
|
|
|
93
103
|
export class InterventionState extends Schema.Class("AttemptChannel/InterventionState")({
|
|
94
104
|
held: Schema.Boolean,
|
|
95
105
|
paused: Schema.Boolean,
|
|
106
|
+
/**
|
|
107
|
+
* Whether the session reads the message only after its current tool call returns. A later
|
|
108
|
+
* receipt with the same input sequence reports delivery or rejection.
|
|
109
|
+
*/
|
|
110
|
+
queued: Schema.Boolean.pipe(Schema.withDecodingDefaultKey(Effect.succeed(false)), Schema.withConstructorDefault(Effect.succeed(false))),
|
|
96
111
|
}) {
|
|
97
112
|
}
|
|
98
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* The receipt for an accepted operator input, with the resulting hold or pause state. A queued
|
|
115
|
+
* input gets a second receipt with the same `inputSequence` when the session reads it.
|
|
116
|
+
*/
|
|
99
117
|
export class InterventionApplied extends Schema.TaggedClass("AttemptChannel/InterventionApplied")("InterventionApplied", {
|
|
100
118
|
inputSequence: Sequence,
|
|
101
119
|
intervention: Intervention,
|
|
102
120
|
state: InterventionState,
|
|
103
121
|
}) {
|
|
104
122
|
}
|
|
105
|
-
/**
|
|
123
|
+
/** The rejection of an operator action by a closed or refusing session; the Attempt continues. */
|
|
106
124
|
export class InterventionRejected extends Schema.TaggedClass("AttemptChannel/InterventionRejected")("InterventionRejected", {
|
|
107
125
|
inputSequence: Sequence,
|
|
108
126
|
intervention: Intervention,
|
|
109
127
|
message: Schema.NonEmptyString,
|
|
110
128
|
}) {
|
|
111
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* A probe of the Worker that didn't run a command over a new SSH connection within its timeout.
|
|
132
|
+
* The Attempt isn't stopped or failed (ADR 0013).
|
|
133
|
+
*/
|
|
134
|
+
export class WorkerUnresponsive extends Schema.TaggedClass("AttemptChannel/WorkerUnresponsive")("WorkerUnresponsive", {
|
|
135
|
+
worker: WorkerName,
|
|
136
|
+
/** The last successful probe, or the Attempt's launch time if no probe has run. */
|
|
137
|
+
lastAnsweredAt: Schema.DateTimeUtcFromString,
|
|
138
|
+
/** The probe error, such as the SSH client's error or the exceeded timeout. */
|
|
139
|
+
reason: Schema.NonEmptyString,
|
|
140
|
+
}) {
|
|
141
|
+
}
|
|
142
|
+
/** A successful probe after `WorkerUnresponsive`. */
|
|
143
|
+
export class WorkerResponsive extends Schema.TaggedClass("AttemptChannel/WorkerResponsive")("WorkerResponsive", {
|
|
144
|
+
worker: WorkerName,
|
|
145
|
+
/** The value from the preceding `WorkerUnresponsive`. */
|
|
146
|
+
lastAnsweredAt: Schema.DateTimeUtcFromString,
|
|
147
|
+
}) {
|
|
148
|
+
}
|
|
149
|
+
export const WorkerNotice = Schema.Union([WorkerUnresponsive, WorkerResponsive]);
|
|
112
150
|
export const OutboundPayload = Schema.Union([
|
|
113
151
|
Started,
|
|
114
152
|
SessionEvent,
|
|
@@ -117,6 +155,8 @@ export const OutboundPayload = Schema.Union([
|
|
|
117
155
|
Interrupted,
|
|
118
156
|
InterventionApplied,
|
|
119
157
|
InterventionRejected,
|
|
158
|
+
WorkerUnresponsive,
|
|
159
|
+
WorkerResponsive,
|
|
120
160
|
]);
|
|
121
161
|
const EnvelopeFields = {
|
|
122
162
|
version: Schema.Literal(PROTOCOL_VERSION),
|
|
@@ -131,46 +171,35 @@ export class OutboundEnvelope extends Schema.TaggedClass("AttemptChannel/Outboun
|
|
|
131
171
|
}
|
|
132
172
|
export class InboundEnvelope extends Schema.TaggedClass("AttemptChannel/InboundEnvelope")("InboundEnvelope", {
|
|
133
173
|
...EnvelopeFields,
|
|
134
|
-
/** The session
|
|
174
|
+
/** The target session, the parent by default. */
|
|
135
175
|
target: SessionTarget.pipe(Schema.withDecodingDefaultKey(Effect.succeed({ _tag: "Parent" }))),
|
|
136
176
|
operator: Schema.NonEmptyString,
|
|
137
177
|
payload: InboundPayload,
|
|
138
178
|
}) {
|
|
139
179
|
}
|
|
140
180
|
export const Envelope = Schema.Union([OutboundEnvelope, InboundEnvelope]);
|
|
141
|
-
/** The first framed stdin message. Later frames are inbound envelopes. */
|
|
142
|
-
export class Start extends Schema.TaggedClass("AttemptChannel/Start")("Start", {
|
|
143
|
-
version: Schema.Literal(PROTOCOL_VERSION),
|
|
144
|
-
spec: RunSpec,
|
|
145
|
-
}) {
|
|
146
|
-
}
|
|
147
|
-
export const InputFrame = Schema.Union([Start, InboundEnvelope]);
|
|
148
|
-
export const EnvelopeFromJson = Schema.fromJsonString(Envelope);
|
|
149
|
-
export const InputFrameFromJson = Schema.fromJsonString(InputFrame);
|
|
150
|
-
export const OutboundEnvelopeFromJson = Schema.fromJsonString(OutboundEnvelope);
|
|
151
181
|
export const initialProgress = { state: "AwaitingStarted", nextSequence: 1 };
|
|
152
182
|
const isTerminal = (payload) => payload._tag === "Final" || payload._tag === "Failed" || payload._tag === "Interrupted";
|
|
153
183
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
* machine through it.
|
|
184
|
+
* Validates an outbound envelope against `progress` and returns the next progress or the
|
|
185
|
+
* violation. Every outbound envelope passes through it before `append`.
|
|
157
186
|
*/
|
|
158
187
|
export const admit = (progress, attemptId, envelope) => {
|
|
159
188
|
if (envelope.attemptId !== attemptId) {
|
|
160
189
|
return Result.fail({
|
|
161
|
-
message: "The
|
|
190
|
+
message: "The outbound channel has an envelope for another attempt",
|
|
162
191
|
detail: String(envelope.attemptId),
|
|
163
192
|
});
|
|
164
193
|
}
|
|
165
194
|
if (envelope.sequence !== progress.nextSequence) {
|
|
166
195
|
return Result.fail({
|
|
167
|
-
message: "The
|
|
196
|
+
message: "The outbound channel has a non-contiguous sequence number",
|
|
168
197
|
detail: `expected ${progress.nextSequence}, received ${envelope.sequence}`,
|
|
169
198
|
});
|
|
170
199
|
}
|
|
171
200
|
if (progress.state === "Terminal") {
|
|
172
201
|
return Result.fail({
|
|
173
|
-
message: "The
|
|
202
|
+
message: "The outbound channel has an envelope after the terminal envelope",
|
|
174
203
|
detail: envelope.payload._tag,
|
|
175
204
|
});
|
|
176
205
|
}
|
|
@@ -178,13 +207,13 @@ export const admit = (progress, attemptId, envelope) => {
|
|
|
178
207
|
envelope.payload._tag !== "Started" &&
|
|
179
208
|
envelope.payload._tag !== "Failed") {
|
|
180
209
|
return Result.fail({
|
|
181
|
-
message: "The
|
|
210
|
+
message: "The outbound channel doesn't start with a Started or Failed envelope",
|
|
182
211
|
detail: envelope.payload._tag,
|
|
183
212
|
});
|
|
184
213
|
}
|
|
185
214
|
if (progress.state === "Running" && envelope.payload._tag === "Started") {
|
|
186
215
|
return Result.fail({
|
|
187
|
-
message: "The
|
|
216
|
+
message: "The outbound channel has more than one Started envelope",
|
|
188
217
|
detail: "duplicate Started envelope",
|
|
189
218
|
});
|
|
190
219
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/attempt/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../src/attempt/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EACL,SAAS,EACT,WAAW,GAGZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAgB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAE3C,6GAA6G;AAC7G,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAC7E,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CACvC,CAAC;AAGF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,UAAU,CAAU,CAAC;AAC3D,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ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